feat(smartdb): add operation log APIs, point-in-time revert support, and a web-based debug dashboard

This commit is contained in:
2026-04-02 17:02:03 +00:00
parent 943302f789
commit d34b8673e1
27 changed files with 3536 additions and 64 deletions

View File

@@ -1,4 +1,13 @@
import { RustDbBridge } from '../rust-db-bridge.js';
import type {
IOpLogEntry,
IOpLogResult,
IOpLogStats,
IRevertResult,
ICollectionInfo,
IDocumentsResult,
ISmartDbMetrics,
} from '../rust-db-bridge.js';
/**
* Server configuration options
@@ -156,4 +165,59 @@ export class SmartdbServer {
get host(): string {
return this.options.host ?? '127.0.0.1';
}
// --- OpLog / Debug API ---
/**
* Get oplog entries, optionally filtered.
*/
async getOpLog(params: {
sinceSeq?: number;
limit?: number;
db?: string;
collection?: string;
} = {}): Promise<IOpLogResult> {
return this.bridge.getOpLog(params);
}
/**
* Get aggregate oplog statistics.
*/
async getOpLogStats(): Promise<IOpLogStats> {
return this.bridge.getOpLogStats();
}
/**
* Revert database state to a specific oplog sequence number.
* Use dryRun=true to preview which entries would be reverted.
*/
async revertToSeq(seq: number, dryRun = false): Promise<IRevertResult> {
return this.bridge.revertToSeq(seq, dryRun);
}
/**
* List all collections across all databases, with document counts.
*/
async getCollections(db?: string): Promise<ICollectionInfo[]> {
return this.bridge.getCollections(db);
}
/**
* Get documents from a collection with pagination.
*/
async getDocuments(
db: string,
collection: string,
limit = 50,
skip = 0,
): Promise<IDocumentsResult> {
return this.bridge.getDocuments(db, collection, limit, skip);
}
/**
* Get server metrics including database/collection counts and oplog info.
*/
async getMetrics(): Promise<ISmartDbMetrics> {
return this.bridge.getMetrics();
}
}