feat(smartdb): add operation log APIs, point-in-time revert support, and a web-based debug dashboard
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user