@push.rocks/smartdb 2.17.0 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@push.rocks/smartdb",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
4
4
  "private": false,
5
5
  "description": "A MongoDB-compatible embedded database server with wire protocol support, backed by a high-performance Rust engine.",
6
6
  "exports": {
@@ -15,10 +15,10 @@
15
15
  "@api.global/typedserver": "^8.4.6",
16
16
  "@design.estate/dees-element": "^2.2.4",
17
17
  "@git.zone/tsbuild": "^4.4.2",
18
- "@git.zone/tsbundle": "^2.11.3",
18
+ "@git.zone/tsbundle": "^2.11.4",
19
19
  "@git.zone/tsrun": "^2.0.6",
20
20
  "@git.zone/tsrust": "^1.7.0",
21
- "@git.zone/tstest": "^3.6.7",
21
+ "@git.zone/tstest": "^4.0.0",
22
22
  "@types/node": "26.1.2",
23
23
  "mongodb": "^7.5.0"
24
24
  },
package/readme.md CHANGED
@@ -398,7 +398,9 @@ Coordinators that do not yet have their own durable record can call `getDatabase
398
398
 
399
399
  `exportDatabase()` drains live MongoDB wire commands for the selected database and holds an exclusive local and cross-process database lease while producing the snapshot. The export is therefore consistent across all collections. It enforces server ceilings while visiting documents instead of first materializing an unbounded database; callers can request lower `maxEncodedBytes`, `maxCollections`, `maxDocuments`, and `maxIndexes` limits. The result emits canonical MongoDB Extended JSON so every BSON type, including 64-bit integers, survives the JSON management channel exactly. `importDatabase()` accepts canonical or relaxed Extended JSON. Database migration clients should preserve the exported objects as JSON values and must not coerce Extended JSON numeric wrappers into JavaScript numbers.
400
400
 
401
- The lifecycle-critical health and fence-state inspections, export, import, publication-commit, tenant-ensure, and tenant-delete methods accept optional `ISmartDbManagementOperationOptions` with `signal?: AbortSignal` and `timeoutMs?: number`. `timeoutMs`, when provided, must be a positive safe integer. Cancellation and deadlines are fail-stop: SmartDB attempts to terminate the Rust engine before rejecting. Once termination is confirmed, the operation cannot continue after the caller releases ownership. If termination itself fails, the rejection is a `SmartDbManagementOperationTerminationError`; bridge ownership is retained and the service owner must retry `stop()` until it succeeds. After any cancellation or deadline, restart SmartDB before accepting more traffic.
401
+ `getDatabaseContentDigest()` computes a bounded, database-name-independent SHA-256 over collection names, exact BSON document bytes, and persisted index specifications. Collection, document, and index enumeration order is normalized; BSON field order and compound-index key order remain significant. `ISmartDbGetDatabaseContentDigestInput` accepts `databaseName` and optional `ISmartDbDatabaseContentDigestLimits` fields `maxScannedBsonBytes`, `maxCollections`, `maxDocuments`, and `maxIndexes`. Callers may lower the server ceilings of 96 MiB scanned BSON, 10,000 collections, 1,000,000 documents, and 100,000 indexes. The `ISmartDbDatabaseContentDigest` result reports format `smartdb.database.content-digest.v1`, algorithm `sha256`, the lowercase digest, and exact scan counters.
402
+
403
+ The lifecycle-critical health and fence-state inspections, digest, export, import, publication-commit, tenant-ensure, and tenant-delete methods accept optional `ISmartDbManagementOperationOptions` with `signal?: AbortSignal` and `timeoutMs?: number`. `timeoutMs`, when provided, must be a positive safe integer. Cancellation and deadlines are fail-stop: SmartDB attempts to terminate the Rust engine before rejecting. Once termination is confirmed, the operation cannot continue after the caller releases ownership. If termination itself fails, the rejection is a `SmartDbManagementOperationTerminationError`; bridge ownership is retained and the service owner must retry `stop()` until it succeeds. After any cancellation or deadline, restart SmartDB before accepting more traffic.
402
404
 
403
405
  ```typescript
404
406
  const controller = new AbortController();
@@ -440,6 +442,7 @@ await client.db('admin').command({ usersInfo: 'reader' });
440
442
  | `getHealth(options?)` | `Promise<ISmartDbHealth>` | Read readiness and explicit publication-hold capability fields with optional fail-stop cancellation/deadline ownership |
441
443
  | `ensureDatabaseTenant(params, options?)` | `Promise<ISmartDbEnsureDatabaseTenantResult>` | Idempotently ensure an exact fenced tenant; supports fail-stop cancellation and deadlines |
442
444
  | `getDatabaseResourceFenceState(params, options?)` | `Promise<ISmartDbDatabaseResourceFenceState \| null>` | Safely inspect a file-backed database fence high-water mark and publication phase without exposing receipts or capability material; supports fail-stop cancellation and deadlines |
445
+ | `getDatabaseContentDigest(params, options?)` | `Promise<ISmartDbDatabaseContentDigest>` | Compute a bounded, database-name-independent digest over exact BSON documents and persisted index specifications; supports fail-stop cancellation and deadlines |
443
446
  | `exportDatabase(params, options?)` | `Promise<ISmartDbDatabaseExport>` | Export one database as lossless canonical MongoDB Extended JSON; supports fail-stop cancellation and deadlines |
444
447
  | `importDatabase(params, options?)` | `Promise<ISmartDbImportDatabaseResult>` | Durably replace one database from canonical or relaxed MongoDB Extended JSON, optionally leaving publication held; supports fail-stop cancellation and deadlines |
445
448
  | `deleteDatabaseTenant(params, options?)` | `Promise<ISmartDbDeleteDatabaseTenantResult>` | Durably delete an exact tenant database/user, optionally leaving publication held; supports fail-stop cancellation and deadlines |
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartdb',
6
- version: '2.17.0',
6
+ version: '2.18.0',
7
7
  description: 'A MongoDB-compatible embedded database server with wire protocol support, backed by a high-performance Rust engine.'
8
8
  }
package/ts/index.ts CHANGED
@@ -53,6 +53,9 @@ export type {
53
53
  ISmartDbDatabaseExport,
54
54
  ISmartDbDatabaseExportLimits,
55
55
  ISmartDbExportDatabaseInput,
56
+ ISmartDbDatabaseContentDigestLimits,
57
+ ISmartDbGetDatabaseContentDigestInput,
58
+ ISmartDbDatabaseContentDigest,
56
59
  ISmartDbImportDatabaseInput,
57
60
  ISmartDbImportDatabaseResult,
58
61
  TSmartDbEffectivePayloadInputV1,
@@ -52,6 +52,9 @@ export type {
52
52
  ISmartDbDatabaseExport,
53
53
  ISmartDbDatabaseExportLimits,
54
54
  ISmartDbExportDatabaseInput,
55
+ ISmartDbDatabaseContentDigestLimits,
56
+ ISmartDbGetDatabaseContentDigestInput,
57
+ ISmartDbDatabaseContentDigest,
55
58
  ISmartDbImportDatabaseInput,
56
59
  ISmartDbImportDatabaseResult,
57
60
  } from './service-types.js';
@@ -18,6 +18,8 @@ import type {
18
18
  ISmartDbDeleteDatabaseTenantResult,
19
19
  ISmartDbDatabaseExport,
20
20
  ISmartDbExportDatabaseInput,
21
+ ISmartDbDatabaseContentDigest,
22
+ ISmartDbGetDatabaseContentDigestInput,
21
23
  ISmartDbImportDatabaseInput,
22
24
  ISmartDbImportDatabaseResult,
23
25
  ISmartDbCommitDatabasePublicationInput,
@@ -193,6 +195,10 @@ type TSmartDbCommands = {
193
195
  params: ISmartDbExportDatabaseInput;
194
196
  result: ISmartDbDatabaseExport;
195
197
  };
198
+ getDatabaseContentDigest: {
199
+ params: ISmartDbGetDatabaseContentDigestInput;
200
+ result: ISmartDbDatabaseContentDigest;
201
+ };
196
202
  importDatabase: {
197
203
  params: ISmartDbImportDatabaseInput;
198
204
  result: ISmartDbImportDatabaseResult;
@@ -658,6 +664,22 @@ export class RustDbBridge extends EventEmitter {
658
664
  }
659
665
  }
660
666
 
667
+ public async getDatabaseContentDigest(
668
+ params: ISmartDbGetDatabaseContentDigestInput,
669
+ optionsArg?: ISmartDbManagementOperationOptions,
670
+ ): Promise<ISmartDbDatabaseContentDigest> {
671
+ try {
672
+ return await this.bridge.sendCommand(
673
+ 'getDatabaseContentDigest',
674
+ params,
675
+ optionsArg,
676
+ ) as ISmartDbDatabaseContentDigest;
677
+ } catch (error) {
678
+ await this.awaitManagementOperationTermination(error);
679
+ throw error;
680
+ }
681
+ }
682
+
661
683
  public async importDatabase(
662
684
  params: ISmartDbImportDatabaseInput,
663
685
  optionsArg?: ISmartDbManagementOperationOptions,
@@ -23,6 +23,8 @@ import type {
23
23
  ISmartDbDeleteDatabaseTenantResult,
24
24
  ISmartDbDatabaseExport,
25
25
  ISmartDbExportDatabaseInput,
26
+ ISmartDbDatabaseContentDigest,
27
+ ISmartDbGetDatabaseContentDigestInput,
26
28
  ISmartDbImportDatabaseInput,
27
29
  ISmartDbImportDatabaseResult,
28
30
  ISmartDbCommitDatabasePublicationInput,
@@ -417,6 +419,16 @@ export class SmartdbServer {
417
419
  );
418
420
  }
419
421
 
422
+ /** Compute a bounded, database-name-independent digest of logical database content. */
423
+ async getDatabaseContentDigest(
424
+ params: ISmartDbGetDatabaseContentDigestInput,
425
+ optionsArg?: ISmartDbManagementOperationOptions,
426
+ ): Promise<ISmartDbDatabaseContentDigest> {
427
+ return this.runDatabaseManagementOperation(
428
+ () => this.bridge.getDatabaseContentDigest(params, optionsArg),
429
+ );
430
+ }
431
+
420
432
  /**
421
433
  * Replace one database with a previously exported snapshot.
422
434
  */
@@ -242,6 +242,29 @@ export interface ISmartDbExportDatabaseInput {
242
242
  limits?: ISmartDbDatabaseExportLimits;
243
243
  }
244
244
 
245
+ export interface ISmartDbDatabaseContentDigestLimits {
246
+ maxScannedBsonBytes?: number;
247
+ maxCollections?: number;
248
+ maxDocuments?: number;
249
+ maxIndexes?: number;
250
+ }
251
+
252
+ export interface ISmartDbGetDatabaseContentDigestInput {
253
+ databaseName: string;
254
+ limits?: ISmartDbDatabaseContentDigestLimits;
255
+ }
256
+
257
+ export interface ISmartDbDatabaseContentDigest {
258
+ format: 'smartdb.database.content-digest.v1';
259
+ algorithm: 'sha256';
260
+ databaseName: string;
261
+ sha256: string;
262
+ scannedBsonBytes: number;
263
+ collections: number;
264
+ documents: number;
265
+ indexes: number;
266
+ }
267
+
245
268
  export interface ISmartDbDatabaseExport {
246
269
  format: 'smartdb.database.export.v1';
247
270
  databaseName: string;