@lossless.org/nosqldb 8.0.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/.smartconfig.json +107 -0
- package/dist_rust/rustdb_linux_amd64 +0 -0
- package/dist_rust/rustdb_linux_amd64.tsrust-build.json +14 -0
- package/dist_rust/rustdb_linux_arm64 +0 -0
- package/dist_rust/rustdb_linux_arm64.tsrust-build.json +14 -0
- package/dist_rust/rustdb_macos_amd64 +0 -0
- package/dist_rust/rustdb_macos_amd64.tsrust-build.json +14 -0
- package/dist_rust/rustdb_macos_arm64 +0 -0
- package/dist_rust/rustdb_macos_arm64.tsrust-build.json +14 -0
- package/dist_ts/00_commitinfo_data.d.ts +8 -0
- package/dist_ts/00_commitinfo_data.js +9 -0
- package/dist_ts/index.d.ts +8 -0
- package/dist_ts/index.js +10 -0
- package/dist_ts/ts_local/classes.localnosqldb.d.ts +119 -0
- package/dist_ts/ts_local/classes.localnosqldb.js +386 -0
- package/dist_ts/ts_local/index.d.ts +5 -0
- package/dist_ts/ts_local/index.js +3 -0
- package/dist_ts/ts_local/plugins.d.ts +1 -0
- package/dist_ts/ts_local/plugins.js +3 -0
- package/dist_ts/ts_nosqldb/classes.storagerehearsal.d.ts +19 -0
- package/dist_ts/ts_nosqldb/classes.storagerehearsal.js +122 -0
- package/dist_ts/ts_nosqldb/file-storage-options.d.ts +13 -0
- package/dist_ts/ts_nosqldb/file-storage-options.js +24 -0
- package/dist_ts/ts_nosqldb/file-storage-startup.d.ts +3 -0
- package/dist_ts/ts_nosqldb/file-storage-startup.js +6 -0
- package/dist_ts/ts_nosqldb/index.d.ts +14 -0
- package/dist_ts/ts_nosqldb/index.js +11 -0
- package/dist_ts/ts_nosqldb/offline-inspection.d.ts +72 -0
- package/dist_ts/ts_nosqldb/offline-inspection.js +282 -0
- package/dist_ts/ts_nosqldb/plugins.d.ts +7 -0
- package/dist_ts/ts_nosqldb/plugins.js +10 -0
- package/dist_ts/ts_nosqldb/resource-fencing.d.ts +39 -0
- package/dist_ts/ts_nosqldb/resource-fencing.js +271 -0
- package/dist_ts/ts_nosqldb/rust-db-bridge.d.ts +213 -0
- package/dist_ts/ts_nosqldb/rust-db-bridge.js +439 -0
- package/dist_ts/ts_nosqldb/server/classes.nosqldbserver.d.ts +204 -0
- package/dist_ts/ts_nosqldb/server/classes.nosqldbserver.js +456 -0
- package/dist_ts/ts_nosqldb/server/index.d.ts +3 -0
- package/dist_ts/ts_nosqldb/server/index.js +3 -0
- package/dist_ts/ts_nosqldb/service-types.d.ts +341 -0
- package/dist_ts/ts_nosqldb/service-types.js +62 -0
- package/dist_ts/ts_nosqldb/storage-rehearsal.d.ts +103 -0
- package/dist_ts/ts_nosqldb/storage-rehearsal.js +131 -0
- package/dist_ts/ts_nosqldb/storage-root-relocation.d.ts +27 -0
- package/dist_ts/ts_nosqldb/storage-root-relocation.js +211 -0
- package/dist_ts_debugserver/bundled.d.ts +4 -0
- package/dist_ts_debugserver/bundled.js +16 -0
- package/dist_ts_debugserver/classes.debugserver.d.ts +36 -0
- package/dist_ts_debugserver/classes.debugserver.js +95 -0
- package/dist_ts_debugserver/index.d.ts +2 -0
- package/dist_ts_debugserver/index.js +2 -0
- package/dist_ts_debugserver/plugins.d.ts +2 -0
- package/dist_ts_debugserver/plugins.js +3 -0
- package/dist_ts_debugui/index.d.ts +2 -0
- package/dist_ts_debugui/index.js +2 -0
- package/dist_ts_debugui/nosqldb-debugui.d.ts +62 -0
- package/dist_ts_debugui/nosqldb-debugui.js +1132 -0
- package/dist_ts_debugui/plugins.d.ts +1 -0
- package/dist_ts_debugui/plugins.js +2 -0
- package/license +21 -0
- package/package.json +82 -0
- package/readme.md +1733 -0
- package/third-party-notices.md +925 -0
- package/ts/00_commitinfo_data.ts +8 -0
- package/ts/index.ts +85 -0
- package/ts/ts_local/classes.localnosqldb.ts +500 -0
- package/ts/ts_local/index.ts +19 -0
- package/ts/ts_local/plugins.ts +1 -0
- package/ts/ts_nosqldb/classes.storagerehearsal.ts +109 -0
- package/ts/ts_nosqldb/file-storage-options.ts +33 -0
- package/ts/ts_nosqldb/file-storage-startup.ts +9 -0
- package/ts/ts_nosqldb/index.ts +104 -0
- package/ts/ts_nosqldb/offline-inspection.ts +375 -0
- package/ts/ts_nosqldb/plugins.ts +12 -0
- package/ts/ts_nosqldb/resource-fencing.ts +368 -0
- package/ts/ts_nosqldb/rust-db-bridge.ts +964 -0
- package/ts/ts_nosqldb/server/classes.nosqldbserver.ts +696 -0
- package/ts/ts_nosqldb/server/index.ts +4 -0
- package/ts/ts_nosqldb/service-types.ts +484 -0
- package/ts/ts_nosqldb/storage-rehearsal.ts +215 -0
- package/ts/ts_nosqldb/storage-root-relocation.ts +277 -0
|
@@ -0,0 +1,964 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import { normalizeNoSqlDbFileStorageOptions } from './file-storage-options.js';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import * as url from 'url';
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
import {
|
|
7
|
+
normalizeNoSqlDbStorageRehearsalInput,
|
|
8
|
+
type INoSqlDbStorageRehearsalInput,
|
|
9
|
+
type INoSqlDbStorageRehearsalReceipt,
|
|
10
|
+
type TNormalizedNoSqlDbStorageRehearsalInput,
|
|
11
|
+
} from './storage-rehearsal.js';
|
|
12
|
+
import {
|
|
13
|
+
normalizeNoSqlDbAllocationReadAccessGrantError,
|
|
14
|
+
normalizeNoSqlDbResourceFenceError,
|
|
15
|
+
} from './service-types.js';
|
|
16
|
+
import {
|
|
17
|
+
normalizeLocalNoSqlDbOfflinePhysicalNamespaceInspectionInput,
|
|
18
|
+
normalizeLocalNoSqlDbOfflineInspectionInput,
|
|
19
|
+
validateNoSqlDbManagementOperationOptions,
|
|
20
|
+
} from './offline-inspection.js';
|
|
21
|
+
import {
|
|
22
|
+
normalizeLocalNoSqlDbStoppedStorageRootRelocationInput,
|
|
23
|
+
type ILocalNoSqlDbStoppedStorageRootRelocationInput,
|
|
24
|
+
type ILocalNoSqlDbStoppedStorageRootRelocationReceipt,
|
|
25
|
+
} from './storage-root-relocation.js';
|
|
26
|
+
import type {
|
|
27
|
+
INoSqlDbHealth,
|
|
28
|
+
INoSqlDbDatabaseTenantInput,
|
|
29
|
+
INoSqlDbAttestDatabaseTenantInput,
|
|
30
|
+
INoSqlDbAttestDatabaseTenantResult,
|
|
31
|
+
INoSqlDbEnsureDatabaseTenantInput,
|
|
32
|
+
INoSqlDbEnsureDatabaseTenantResult,
|
|
33
|
+
INoSqlDbAllocateDatabaseTenantInput,
|
|
34
|
+
INoSqlDbAllocateDatabaseTenantResult,
|
|
35
|
+
INoSqlDbDeleteDatabaseTenantInput,
|
|
36
|
+
INoSqlDbRotateDatabaseTenantPasswordInput,
|
|
37
|
+
INoSqlDbDatabaseTenantDescriptor,
|
|
38
|
+
INoSqlDbDeleteDatabaseTenantResult,
|
|
39
|
+
INoSqlDbIssueDatabaseAllocationReadAccessGrantInput,
|
|
40
|
+
INoSqlDbIssueDatabaseAllocationReadAccessGrantResult,
|
|
41
|
+
INoSqlDbRevokeDatabaseAllocationReadAccessGrantInput,
|
|
42
|
+
INoSqlDbRevokeDatabaseAllocationReadAccessGrantResult,
|
|
43
|
+
INoSqlDbDatabaseExport,
|
|
44
|
+
INoSqlDbExportDatabaseInput,
|
|
45
|
+
INoSqlDbDatabaseContentDigest,
|
|
46
|
+
INoSqlDbGetDatabaseContentDigestInput,
|
|
47
|
+
INoSqlDbImportDatabaseInput,
|
|
48
|
+
INoSqlDbImportDatabaseResult,
|
|
49
|
+
INoSqlDbCommitDatabasePublicationInput,
|
|
50
|
+
INoSqlDbManagementOperationOptions,
|
|
51
|
+
INoSqlDbDatabaseResourceFenceState,
|
|
52
|
+
ILocalNoSqlDbOfflinePhysicalNamespaceInspection,
|
|
53
|
+
ILocalNoSqlDbOfflinePhysicalNamespaceInspectionResult,
|
|
54
|
+
ILocalNoSqlDbOfflineStringValueInspection,
|
|
55
|
+
TLocalNoSqlDbOfflineStringValueInspectionResult,
|
|
56
|
+
TNoSqlDbCommitDatabasePublicationResult,
|
|
57
|
+
} from './service-types.js';
|
|
58
|
+
|
|
59
|
+
export type {
|
|
60
|
+
INoSqlDbHealth,
|
|
61
|
+
INoSqlDbDatabaseTenantInput,
|
|
62
|
+
INoSqlDbAttestDatabaseTenantInput,
|
|
63
|
+
INoSqlDbAttestDatabaseTenantResult,
|
|
64
|
+
INoSqlDbEnsureDatabaseTenantInput,
|
|
65
|
+
INoSqlDbEnsureDatabaseTenantResult,
|
|
66
|
+
INoSqlDbAllocateDatabaseTenantInput,
|
|
67
|
+
INoSqlDbAllocateDatabaseTenantResult,
|
|
68
|
+
INoSqlDbDeleteDatabaseTenantInput,
|
|
69
|
+
INoSqlDbRotateDatabaseTenantPasswordInput,
|
|
70
|
+
INoSqlDbDatabaseTenantDescriptor,
|
|
71
|
+
INoSqlDbDeleteDatabaseTenantResult,
|
|
72
|
+
INoSqlDbDatabaseAllocationReadAccessGrantIdentity,
|
|
73
|
+
INoSqlDbIssueDatabaseAllocationReadAccessGrantInput,
|
|
74
|
+
INoSqlDbIssueDatabaseAllocationReadAccessGrantResult,
|
|
75
|
+
INoSqlDbRevokeDatabaseAllocationReadAccessGrantInput,
|
|
76
|
+
INoSqlDbRevokeDatabaseAllocationReadAccessGrantResult,
|
|
77
|
+
INoSqlDbDatabaseExportCollection,
|
|
78
|
+
INoSqlDbDatabaseExport,
|
|
79
|
+
INoSqlDbImportDatabaseInput,
|
|
80
|
+
INoSqlDbImportDatabaseResult,
|
|
81
|
+
INoSqlDbHeldPublicationReceipt,
|
|
82
|
+
INoSqlDbCommitDatabasePublicationInput,
|
|
83
|
+
INoSqlDbManagementOperationOptions,
|
|
84
|
+
INoSqlDbDatabaseResourceFenceState,
|
|
85
|
+
ILocalNoSqlDbOfflineInspectionLimits,
|
|
86
|
+
ILocalNoSqlDbOfflinePhysicalNamespaceInspectionLimits,
|
|
87
|
+
ILocalNoSqlDbOfflinePhysicalNamespaceInspection,
|
|
88
|
+
ILocalNoSqlDbOfflinePhysicalNamespaceInspectionResult,
|
|
89
|
+
ILocalNoSqlDbOfflineStringValueInspection,
|
|
90
|
+
TLocalNoSqlDbOfflineStringValueInspectionResult,
|
|
91
|
+
TNoSqlDbCommitDatabasePublicationResult,
|
|
92
|
+
} from './service-types.js';
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* A single oplog entry returned from the Rust engine.
|
|
96
|
+
*/
|
|
97
|
+
export interface IOpLogEntry {
|
|
98
|
+
seq: number;
|
|
99
|
+
timestampMs: number;
|
|
100
|
+
op: 'insert' | 'update' | 'delete';
|
|
101
|
+
db: string;
|
|
102
|
+
collection: string;
|
|
103
|
+
documentId: string;
|
|
104
|
+
document: Record<string, any> | null;
|
|
105
|
+
previousDocument: Record<string, any> | null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Aggregate oplog statistics.
|
|
110
|
+
*/
|
|
111
|
+
export interface IOpLogStats {
|
|
112
|
+
currentSeq: number;
|
|
113
|
+
totalEntries: number;
|
|
114
|
+
oldestSeq: number;
|
|
115
|
+
/** Approximate retained bytes across all in-memory oplog entries. */
|
|
116
|
+
approxBytes: number;
|
|
117
|
+
entriesByOp: {
|
|
118
|
+
insert: number;
|
|
119
|
+
update: number;
|
|
120
|
+
delete: number;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Result of a getOpLog query.
|
|
126
|
+
*/
|
|
127
|
+
export interface IOpLogResult {
|
|
128
|
+
entries: IOpLogEntry[];
|
|
129
|
+
currentSeq: number;
|
|
130
|
+
totalEntries: number;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Result of a revertToSeq command.
|
|
135
|
+
*/
|
|
136
|
+
export interface IRevertResult {
|
|
137
|
+
dryRun: boolean;
|
|
138
|
+
reverted: number;
|
|
139
|
+
targetSeq?: number;
|
|
140
|
+
entries?: IOpLogEntry[];
|
|
141
|
+
errors?: string[];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* A collection info entry.
|
|
146
|
+
*/
|
|
147
|
+
export interface ICollectionInfo {
|
|
148
|
+
db: string;
|
|
149
|
+
name: string;
|
|
150
|
+
count: number;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Result of a getDocuments query.
|
|
155
|
+
*/
|
|
156
|
+
export interface IDocumentsResult {
|
|
157
|
+
documents: Record<string, any>[];
|
|
158
|
+
total: number;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export class NoSqlDbManagementOperationTerminationError extends AggregateError {
|
|
162
|
+
constructor(operationErrorArg: unknown, terminationErrorArg: unknown) {
|
|
163
|
+
super(
|
|
164
|
+
[operationErrorArg, terminationErrorArg],
|
|
165
|
+
'NoSQLDB management operation failed and Rust engine termination was incomplete',
|
|
166
|
+
{ cause: operationErrorArg },
|
|
167
|
+
);
|
|
168
|
+
this.name = 'NoSqlDbManagementOperationTerminationError';
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Server metrics.
|
|
174
|
+
*/
|
|
175
|
+
export interface INoSqlDbMetrics {
|
|
176
|
+
databases: number;
|
|
177
|
+
collections: number;
|
|
178
|
+
oplogEntries: number;
|
|
179
|
+
oplogCurrentSeq: number;
|
|
180
|
+
sessions: number;
|
|
181
|
+
activeTransactions: number;
|
|
182
|
+
authEnabled: boolean;
|
|
183
|
+
authUsers: number;
|
|
184
|
+
uptimeSeconds: number;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Type-safe command definitions for the RustDb IPC protocol.
|
|
189
|
+
*/
|
|
190
|
+
type TOfflinePhysicalNamespaceInspectionCommandParams = {
|
|
191
|
+
folderPath: string;
|
|
192
|
+
timeoutMs?: number;
|
|
193
|
+
} & ILocalNoSqlDbOfflinePhysicalNamespaceInspection['limits'];
|
|
194
|
+
|
|
195
|
+
type TNoSqlDbCommands = {
|
|
196
|
+
createStoppedStorageRehearsal: {
|
|
197
|
+
params: { request: TNormalizedNoSqlDbStorageRehearsalInput; timeoutMs: number };
|
|
198
|
+
result: INoSqlDbStorageRehearsalReceipt;
|
|
199
|
+
};
|
|
200
|
+
relocateStoppedStorageRoot: {
|
|
201
|
+
params: ILocalNoSqlDbStoppedStorageRootRelocationInput & { timeoutMs?: number };
|
|
202
|
+
result: ILocalNoSqlDbStoppedStorageRootRelocationReceipt;
|
|
203
|
+
};
|
|
204
|
+
inspectOfflinePhysicalNamespaces: {
|
|
205
|
+
params: TOfflinePhysicalNamespaceInspectionCommandParams;
|
|
206
|
+
result: ILocalNoSqlDbOfflinePhysicalNamespaceInspectionResult;
|
|
207
|
+
};
|
|
208
|
+
inspectOfflineStringValue: {
|
|
209
|
+
params: ILocalNoSqlDbOfflineStringValueInspection & { timeoutMs?: number };
|
|
210
|
+
result: TLocalNoSqlDbOfflineStringValueInspectionResult;
|
|
211
|
+
};
|
|
212
|
+
start: { params: { config: INoSqlDbRustConfig; timeoutMs?: number }; result: { connectionUri: string } };
|
|
213
|
+
stop: { params: Record<string, never>; result: void };
|
|
214
|
+
getStatus: { params: Record<string, never>; result: { running: boolean } };
|
|
215
|
+
getHealth: { params: Record<string, never>; result: INoSqlDbHealth };
|
|
216
|
+
getMetrics: { params: Record<string, never>; result: INoSqlDbMetrics };
|
|
217
|
+
createDatabaseTenant: {
|
|
218
|
+
params: INoSqlDbDatabaseTenantInput;
|
|
219
|
+
result: INoSqlDbDatabaseTenantDescriptor;
|
|
220
|
+
};
|
|
221
|
+
allocateDatabaseTenant: {
|
|
222
|
+
params: INoSqlDbAllocateDatabaseTenantInput;
|
|
223
|
+
result: INoSqlDbAllocateDatabaseTenantResult;
|
|
224
|
+
};
|
|
225
|
+
ensureDatabaseTenant: {
|
|
226
|
+
params: INoSqlDbEnsureDatabaseTenantInput;
|
|
227
|
+
result: INoSqlDbEnsureDatabaseTenantResult;
|
|
228
|
+
};
|
|
229
|
+
attestDatabaseTenant: {
|
|
230
|
+
params: INoSqlDbAttestDatabaseTenantInput;
|
|
231
|
+
result: INoSqlDbAttestDatabaseTenantResult;
|
|
232
|
+
};
|
|
233
|
+
deleteDatabaseTenant: {
|
|
234
|
+
params: INoSqlDbDeleteDatabaseTenantInput;
|
|
235
|
+
result: INoSqlDbDeleteDatabaseTenantResult;
|
|
236
|
+
};
|
|
237
|
+
issueDatabaseAllocationReadAccessGrant: {
|
|
238
|
+
params: INoSqlDbIssueDatabaseAllocationReadAccessGrantInput;
|
|
239
|
+
result: INoSqlDbIssueDatabaseAllocationReadAccessGrantResult;
|
|
240
|
+
};
|
|
241
|
+
revokeDatabaseAllocationReadAccessGrant: {
|
|
242
|
+
params: INoSqlDbRevokeDatabaseAllocationReadAccessGrantInput;
|
|
243
|
+
result: INoSqlDbRevokeDatabaseAllocationReadAccessGrantResult;
|
|
244
|
+
};
|
|
245
|
+
rotateDatabaseTenantPassword: {
|
|
246
|
+
params: INoSqlDbRotateDatabaseTenantPasswordInput;
|
|
247
|
+
result: INoSqlDbDatabaseTenantDescriptor;
|
|
248
|
+
};
|
|
249
|
+
listDatabaseTenants: {
|
|
250
|
+
params: Record<string, never>;
|
|
251
|
+
result: { tenants: INoSqlDbDatabaseTenantDescriptor[] };
|
|
252
|
+
};
|
|
253
|
+
getDatabaseTenantDescriptor: {
|
|
254
|
+
params: { databaseName: string; username: string };
|
|
255
|
+
result: INoSqlDbDatabaseTenantDescriptor;
|
|
256
|
+
};
|
|
257
|
+
getDatabaseResourceFenceState: {
|
|
258
|
+
params: { databaseName: string };
|
|
259
|
+
result: INoSqlDbDatabaseResourceFenceState | null;
|
|
260
|
+
};
|
|
261
|
+
exportDatabase: {
|
|
262
|
+
params: INoSqlDbExportDatabaseInput;
|
|
263
|
+
result: INoSqlDbDatabaseExport;
|
|
264
|
+
};
|
|
265
|
+
getDatabaseContentDigest: {
|
|
266
|
+
params: INoSqlDbGetDatabaseContentDigestInput;
|
|
267
|
+
result: INoSqlDbDatabaseContentDigest;
|
|
268
|
+
};
|
|
269
|
+
importDatabase: {
|
|
270
|
+
params: INoSqlDbImportDatabaseInput & { timeoutMs?: number };
|
|
271
|
+
result: INoSqlDbImportDatabaseResult;
|
|
272
|
+
};
|
|
273
|
+
commitDatabasePublication: {
|
|
274
|
+
params: INoSqlDbCommitDatabasePublicationInput;
|
|
275
|
+
result: TNoSqlDbCommitDatabasePublicationResult;
|
|
276
|
+
};
|
|
277
|
+
getOpLog: {
|
|
278
|
+
params: { sinceSeq?: number; limit?: number; db?: string; collection?: string };
|
|
279
|
+
result: IOpLogResult;
|
|
280
|
+
};
|
|
281
|
+
getOpLogStats: { params: Record<string, never>; result: IOpLogStats };
|
|
282
|
+
revertToSeq: {
|
|
283
|
+
params: { seq: number; dryRun?: boolean };
|
|
284
|
+
result: IRevertResult;
|
|
285
|
+
};
|
|
286
|
+
getCollections: {
|
|
287
|
+
params: { db?: string };
|
|
288
|
+
result: { collections: ICollectionInfo[] };
|
|
289
|
+
};
|
|
290
|
+
getDocuments: {
|
|
291
|
+
params: { db: string; collection: string; limit?: number; skip?: number };
|
|
292
|
+
result: IDocumentsResult;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
export const rustDbBridgeStorageRootRelocation = Symbol(
|
|
297
|
+
'nosqldb.internal.storage-root-relocation',
|
|
298
|
+
);
|
|
299
|
+
export const rustDbBridgeStorageRehearsal = Symbol('nosqldb.internal.storage-rehearsal');
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Configuration sent to the Rust binary on start.
|
|
303
|
+
*/
|
|
304
|
+
export interface INoSqlDbQueryOptions {
|
|
305
|
+
/** Target encoded bytes per in-memory sort run (default: 4 MiB). */
|
|
306
|
+
sortBufferBytes?: number;
|
|
307
|
+
/** Shared temporary sort-file budget, including merge output (default: 4 GiB). */
|
|
308
|
+
maxSortSpillBytes?: number;
|
|
309
|
+
/** Concurrent sort builders (default: 4). */
|
|
310
|
+
maxConcurrentSorts?: number;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
interface INoSqlDbRustConfig {
|
|
314
|
+
storageRehearsalId?: string;
|
|
315
|
+
port?: number;
|
|
316
|
+
host?: string;
|
|
317
|
+
socketPath?: string;
|
|
318
|
+
storage: 'memory' | 'file';
|
|
319
|
+
storagePath?: string;
|
|
320
|
+
query?: INoSqlDbQueryOptions;
|
|
321
|
+
auth?: {
|
|
322
|
+
enabled?: boolean;
|
|
323
|
+
users?: Array<{
|
|
324
|
+
username: string;
|
|
325
|
+
password: string;
|
|
326
|
+
database?: string;
|
|
327
|
+
roles?: string[];
|
|
328
|
+
}>;
|
|
329
|
+
scramIterations?: number;
|
|
330
|
+
};
|
|
331
|
+
tls?: {
|
|
332
|
+
enabled?: boolean;
|
|
333
|
+
certPath?: string;
|
|
334
|
+
keyPath?: string;
|
|
335
|
+
caPath?: string;
|
|
336
|
+
requireClientCert?: boolean;
|
|
337
|
+
};
|
|
338
|
+
oplog?: {
|
|
339
|
+
maxEntries?: number;
|
|
340
|
+
maxBytes?: number;
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Get the package root directory using import.meta.url.
|
|
346
|
+
* This file is at ts/ts_nosqldb/, so package root is 2 levels up.
|
|
347
|
+
*/
|
|
348
|
+
function getPackageRoot(): string {
|
|
349
|
+
const thisDir = path.dirname(url.fileURLToPath(import.meta.url));
|
|
350
|
+
return path.resolve(thisDir, '..', '..');
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Map Node.js process.platform/process.arch to tsrust's friendly name suffix.
|
|
355
|
+
* tsrust names cross-compiled binaries as: rustdb_linux_amd64, rustdb_linux_arm64, etc.
|
|
356
|
+
*/
|
|
357
|
+
function getTsrustPlatformSuffix(): string | null {
|
|
358
|
+
const archMap: Record<string, string> = { x64: 'amd64', arm64: 'arm64' };
|
|
359
|
+
const osMap: Record<string, string> = { linux: 'linux', darwin: 'macos' };
|
|
360
|
+
const os = osMap[process.platform];
|
|
361
|
+
const arch = archMap[process.arch];
|
|
362
|
+
if (os && arch) {
|
|
363
|
+
return `${os}_${arch}`;
|
|
364
|
+
}
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Build local search paths for the Rust binary, including dist_rust/ candidates
|
|
370
|
+
* (built by tsrust) and local development build paths.
|
|
371
|
+
*/
|
|
372
|
+
function buildLocalPaths(): string[] {
|
|
373
|
+
const packageRoot = getPackageRoot();
|
|
374
|
+
const suffix = getTsrustPlatformSuffix();
|
|
375
|
+
const paths: string[] = [];
|
|
376
|
+
|
|
377
|
+
// dist_rust/ candidates (tsrust cross-compiled output)
|
|
378
|
+
if (suffix) {
|
|
379
|
+
paths.push(path.join(packageRoot, 'dist_rust', `rustdb_${suffix}`));
|
|
380
|
+
}
|
|
381
|
+
paths.push(path.join(packageRoot, 'dist_rust', 'rustdb'));
|
|
382
|
+
|
|
383
|
+
// Local dev build paths
|
|
384
|
+
paths.push(path.resolve(process.cwd(), 'rust', 'target', 'release', 'rustdb'));
|
|
385
|
+
paths.push(path.resolve(process.cwd(), 'rust', 'target', 'debug', 'rustdb'));
|
|
386
|
+
|
|
387
|
+
return paths;
|
|
388
|
+
}
|
|
389
|
+
export function getRustDbAllocatorEnv(
|
|
390
|
+
environment: NodeJS.ProcessEnv = process.env,
|
|
391
|
+
): Record<string, string> {
|
|
392
|
+
return {
|
|
393
|
+
MIMALLOC_ARENA_EAGER_COMMIT: environment.MIMALLOC_ARENA_EAGER_COMMIT ?? '0',
|
|
394
|
+
MIMALLOC_ALLOW_LARGE_OS_PAGES: environment.MIMALLOC_ALLOW_LARGE_OS_PAGES ?? '0',
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
export interface IRustDbBridgeOptions {
|
|
399
|
+
/** Exact engine executable, validated by Smartrust without discovery fallback or permission changes. */
|
|
400
|
+
binaryPath?: string;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Bridge between TypeScript NoSqlDbServer and the Rust binary.
|
|
405
|
+
* Wraps @push.rocks/smartrust's RustBridge with type-safe command definitions.
|
|
406
|
+
*/
|
|
407
|
+
export class RustDbBridge extends EventEmitter {
|
|
408
|
+
private bridge: plugins.smartrust.RustBridge<TNoSqlDbCommands>;
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Operating-system process id of the spawned Rust engine while it runs as a
|
|
412
|
+
* child process of this Node.js process. Undefined before spawn, after
|
|
413
|
+
* termination, or when the bridge is connected to an external process.
|
|
414
|
+
*/
|
|
415
|
+
public get processId(): number | undefined {
|
|
416
|
+
const transport = (this.bridge as unknown as {
|
|
417
|
+
transport?: { childProcess?: { pid?: number } | null };
|
|
418
|
+
}).transport;
|
|
419
|
+
return transport?.childProcess?.pid;
|
|
420
|
+
}
|
|
421
|
+
private terminationConfirmed = true;
|
|
422
|
+
private terminationPromise: Promise<void> | undefined;
|
|
423
|
+
private terminationFailure: unknown;
|
|
424
|
+
|
|
425
|
+
constructor(options: IRustDbBridgeOptions = {}) {
|
|
426
|
+
super();
|
|
427
|
+
|
|
428
|
+
this.bridge = new plugins.smartrust.RustBridge<TNoSqlDbCommands>({
|
|
429
|
+
binaryName: 'rustdb',
|
|
430
|
+
binaryPath: options.binaryPath,
|
|
431
|
+
envVarName: 'NOSQLDB_RUST_BINARY',
|
|
432
|
+
platformPackagePrefix: '@lossless.org/nosqldb',
|
|
433
|
+
localPaths: buildLocalPaths(),
|
|
434
|
+
maxPayloadSize: 100 * 1024 * 1024, // database exports/imports can be larger than command replies
|
|
435
|
+
env: getRustDbAllocatorEnv(),
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
// Forward events from the inner bridge
|
|
439
|
+
this.bridge.on('exit', (code: number | null, signal: string | null) => {
|
|
440
|
+
this.terminationConfirmed = true;
|
|
441
|
+
this.emit('exit', code, signal);
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Spawn the Rust binary in management mode.
|
|
447
|
+
* Returns true if the binary was found and spawned successfully.
|
|
448
|
+
*/
|
|
449
|
+
public async spawn(optionsArg?: INoSqlDbManagementOperationOptions): Promise<boolean> {
|
|
450
|
+
validateNoSqlDbManagementOperationOptions(optionsArg);
|
|
451
|
+
if (optionsArg?.signal?.aborted) {
|
|
452
|
+
throw new plugins.smartrust.RustBridgeRequestError(
|
|
453
|
+
'NoSQLDB Rust sidecar spawn was aborted before it started',
|
|
454
|
+
{
|
|
455
|
+
code: 'ERR_RUST_BRIDGE_REQUEST_ABORTED',
|
|
456
|
+
method: 'spawn',
|
|
457
|
+
cause: optionsArg.signal.reason,
|
|
458
|
+
},
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
this.terminationConfirmed = false;
|
|
463
|
+
this.terminationFailure = undefined;
|
|
464
|
+
const spawnPromise = this.bridge.spawn();
|
|
465
|
+
let timeout: ReturnType<typeof setTimeout> | undefined;
|
|
466
|
+
let abortHandler: (() => void) | undefined;
|
|
467
|
+
const cancellationPromise = new Promise<never>((_resolveArg, rejectArg) => {
|
|
468
|
+
if (optionsArg?.timeoutMs !== undefined) {
|
|
469
|
+
timeout = setTimeout(() => {
|
|
470
|
+
rejectArg(new plugins.smartrust.RustBridgeRequestError(
|
|
471
|
+
`NoSQLDB Rust sidecar spawn timed out after ${optionsArg.timeoutMs}ms`,
|
|
472
|
+
{
|
|
473
|
+
code: 'ERR_RUST_BRIDGE_REQUEST_TIMEOUT',
|
|
474
|
+
method: 'spawn',
|
|
475
|
+
},
|
|
476
|
+
));
|
|
477
|
+
}, optionsArg.timeoutMs);
|
|
478
|
+
}
|
|
479
|
+
if (optionsArg?.signal) {
|
|
480
|
+
abortHandler = () => {
|
|
481
|
+
rejectArg(new plugins.smartrust.RustBridgeRequestError(
|
|
482
|
+
'NoSQLDB Rust sidecar spawn was aborted',
|
|
483
|
+
{
|
|
484
|
+
code: 'ERR_RUST_BRIDGE_REQUEST_ABORTED',
|
|
485
|
+
method: 'spawn',
|
|
486
|
+
cause: optionsArg.signal!.reason,
|
|
487
|
+
},
|
|
488
|
+
));
|
|
489
|
+
};
|
|
490
|
+
optionsArg.signal.addEventListener('abort', abortHandler, { once: true });
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
try {
|
|
495
|
+
const spawned = await Promise.race([spawnPromise, cancellationPromise]);
|
|
496
|
+
if (!spawned) {
|
|
497
|
+
await this.terminate({ gracePeriodMs: 0 });
|
|
498
|
+
}
|
|
499
|
+
return spawned;
|
|
500
|
+
} catch (error) {
|
|
501
|
+
try {
|
|
502
|
+
await this.terminate({ gracePeriodMs: 0 });
|
|
503
|
+
} catch (terminationError) {
|
|
504
|
+
throw new NoSqlDbManagementOperationTerminationError(error, terminationError);
|
|
505
|
+
}
|
|
506
|
+
throw error;
|
|
507
|
+
} finally {
|
|
508
|
+
if (timeout) clearTimeout(timeout);
|
|
509
|
+
if (abortHandler && optionsArg?.signal) {
|
|
510
|
+
optionsArg.signal.removeEventListener('abort', abortHandler);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Kill the Rust process and clean up.
|
|
517
|
+
*/
|
|
518
|
+
public kill(): void {
|
|
519
|
+
this.bridge.kill();
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Confirm that the Rust process has exited and all bridge resources are released.
|
|
524
|
+
*/
|
|
525
|
+
public terminate(
|
|
526
|
+
optionsArg?: plugins.smartrust.IRustBridgeTerminateOptions,
|
|
527
|
+
): Promise<void> {
|
|
528
|
+
if (this.terminationPromise) {
|
|
529
|
+
return this.terminationPromise;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
const terminationPromise = this.bridge.terminate(optionsArg).then(
|
|
533
|
+
() => {
|
|
534
|
+
this.terminationConfirmed = true;
|
|
535
|
+
this.terminationFailure = undefined;
|
|
536
|
+
},
|
|
537
|
+
(errorArg: unknown) => {
|
|
538
|
+
this.terminationFailure = errorArg;
|
|
539
|
+
throw errorArg;
|
|
540
|
+
},
|
|
541
|
+
);
|
|
542
|
+
this.terminationPromise = terminationPromise;
|
|
543
|
+
void terminationPromise.then(
|
|
544
|
+
() => {
|
|
545
|
+
if (this.terminationPromise === terminationPromise) {
|
|
546
|
+
this.terminationPromise = undefined;
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
() => {
|
|
550
|
+
if (this.terminationPromise === terminationPromise) {
|
|
551
|
+
this.terminationPromise = undefined;
|
|
552
|
+
}
|
|
553
|
+
},
|
|
554
|
+
);
|
|
555
|
+
return terminationPromise;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Whether the bridge is currently running.
|
|
560
|
+
*/
|
|
561
|
+
public get running(): boolean {
|
|
562
|
+
return this.bridge.running;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
public get ownershipReleased(): boolean {
|
|
566
|
+
return this.terminationConfirmed;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
private async awaitManagementOperationTermination(errorArg: unknown) {
|
|
570
|
+
const cancellationRequiresTermination =
|
|
571
|
+
errorArg instanceof plugins.smartrust.RustBridgeRequestError
|
|
572
|
+
&& [
|
|
573
|
+
'ERR_RUST_BRIDGE_REQUEST_ABORTED',
|
|
574
|
+
'ERR_RUST_BRIDGE_REQUEST_TIMEOUT',
|
|
575
|
+
].includes(errorArg.code);
|
|
576
|
+
let terminationPromise = this.terminationPromise;
|
|
577
|
+
if (cancellationRequiresTermination && !terminationPromise) {
|
|
578
|
+
terminationPromise = this.terminate({ gracePeriodMs: 0 });
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
if (!terminationPromise) {
|
|
582
|
+
if (!this.terminationConfirmed && this.terminationFailure !== undefined) {
|
|
583
|
+
throw new NoSqlDbManagementOperationTerminationError(
|
|
584
|
+
errorArg,
|
|
585
|
+
this.terminationFailure,
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
try {
|
|
592
|
+
await terminationPromise;
|
|
593
|
+
} catch (terminationError) {
|
|
594
|
+
throw new NoSqlDbManagementOperationTerminationError(
|
|
595
|
+
errorArg,
|
|
596
|
+
terminationError,
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// --- Convenience methods for each management command ---
|
|
602
|
+
|
|
603
|
+
public async [rustDbBridgeStorageRehearsal](inputArg: INoSqlDbStorageRehearsalInput,
|
|
604
|
+
optionsArg: INoSqlDbManagementOperationOptions & { timeoutMs: number }): Promise<INoSqlDbStorageRehearsalReceipt> {
|
|
605
|
+
const request = normalizeNoSqlDbStorageRehearsalInput(inputArg);
|
|
606
|
+
validateNoSqlDbManagementOperationOptions(optionsArg);
|
|
607
|
+
try {
|
|
608
|
+
return await this.bridge.sendCommand('createStoppedStorageRehearsal',
|
|
609
|
+
{ request, timeoutMs: optionsArg.timeoutMs }, optionsArg) as INoSqlDbStorageRehearsalReceipt;
|
|
610
|
+
} catch (error) {
|
|
611
|
+
await this.awaitManagementOperationTermination(error);
|
|
612
|
+
throw error;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
public async [rustDbBridgeStorageRootRelocation](
|
|
617
|
+
inputArg: ILocalNoSqlDbStoppedStorageRootRelocationInput,
|
|
618
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
619
|
+
): Promise<ILocalNoSqlDbStoppedStorageRootRelocationReceipt> {
|
|
620
|
+
const input = normalizeLocalNoSqlDbStoppedStorageRootRelocationInput(inputArg);
|
|
621
|
+
validateNoSqlDbManagementOperationOptions(optionsArg);
|
|
622
|
+
try {
|
|
623
|
+
return await this.bridge.sendCommand(
|
|
624
|
+
'relocateStoppedStorageRoot',
|
|
625
|
+
{ ...input, timeoutMs: optionsArg?.timeoutMs },
|
|
626
|
+
optionsArg,
|
|
627
|
+
) as ILocalNoSqlDbStoppedStorageRootRelocationReceipt;
|
|
628
|
+
} catch (error) {
|
|
629
|
+
await this.awaitManagementOperationTermination(error);
|
|
630
|
+
throw error;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
public async inspectOfflinePhysicalNamespaces(
|
|
635
|
+
inputArg: ILocalNoSqlDbOfflinePhysicalNamespaceInspection,
|
|
636
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
637
|
+
): Promise<ILocalNoSqlDbOfflinePhysicalNamespaceInspectionResult> {
|
|
638
|
+
const input = normalizeLocalNoSqlDbOfflinePhysicalNamespaceInspectionInput(inputArg);
|
|
639
|
+
validateNoSqlDbManagementOperationOptions(optionsArg);
|
|
640
|
+
const params: TOfflinePhysicalNamespaceInspectionCommandParams = {
|
|
641
|
+
folderPath: input.folderPath,
|
|
642
|
+
...input.limits,
|
|
643
|
+
timeoutMs: optionsArg?.timeoutMs,
|
|
644
|
+
};
|
|
645
|
+
try {
|
|
646
|
+
return await this.bridge.sendCommand(
|
|
647
|
+
'inspectOfflinePhysicalNamespaces',
|
|
648
|
+
params,
|
|
649
|
+
optionsArg,
|
|
650
|
+
) as ILocalNoSqlDbOfflinePhysicalNamespaceInspectionResult;
|
|
651
|
+
} catch (error) {
|
|
652
|
+
await this.awaitManagementOperationTermination(error);
|
|
653
|
+
throw error;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
public async inspectOfflineStringValue(
|
|
658
|
+
inputArg: ILocalNoSqlDbOfflineStringValueInspection,
|
|
659
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
660
|
+
): Promise<TLocalNoSqlDbOfflineStringValueInspectionResult> {
|
|
661
|
+
const input = normalizeLocalNoSqlDbOfflineInspectionInput(inputArg);
|
|
662
|
+
validateNoSqlDbManagementOperationOptions(optionsArg);
|
|
663
|
+
try {
|
|
664
|
+
return await this.bridge.sendCommand(
|
|
665
|
+
'inspectOfflineStringValue',
|
|
666
|
+
{ ...input, timeoutMs: optionsArg?.timeoutMs },
|
|
667
|
+
optionsArg,
|
|
668
|
+
) as TLocalNoSqlDbOfflineStringValueInspectionResult;
|
|
669
|
+
} catch (error) {
|
|
670
|
+
await this.awaitManagementOperationTermination(error);
|
|
671
|
+
throw error;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
public async startDb(
|
|
676
|
+
config: INoSqlDbRustConfig,
|
|
677
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
678
|
+
): Promise<{ connectionUri: string }> {
|
|
679
|
+
normalizeNoSqlDbFileStorageOptions(config);
|
|
680
|
+
validateNoSqlDbManagementOperationOptions(optionsArg);
|
|
681
|
+
try {
|
|
682
|
+
return await this.bridge.sendCommand(
|
|
683
|
+
'start',
|
|
684
|
+
{ config, timeoutMs: optionsArg?.timeoutMs },
|
|
685
|
+
optionsArg,
|
|
686
|
+
) as { connectionUri: string };
|
|
687
|
+
} catch (error) {
|
|
688
|
+
await this.awaitManagementOperationTermination(error);
|
|
689
|
+
throw error;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
public async stopDb(): Promise<void> {
|
|
694
|
+
await this.bridge.sendCommand('stop', {} as Record<string, never>);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
public async getStatus(): Promise<{ running: boolean }> {
|
|
698
|
+
return await this.bridge.sendCommand('getStatus', {} as Record<string, never>) as { running: boolean };
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
public async getMetrics(): Promise<INoSqlDbMetrics> {
|
|
702
|
+
return this.bridge.sendCommand('getMetrics', {} as Record<string, never>) as Promise<INoSqlDbMetrics>;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
public async getHealth(
|
|
706
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
707
|
+
): Promise<INoSqlDbHealth> {
|
|
708
|
+
try {
|
|
709
|
+
return await this.bridge.sendCommand(
|
|
710
|
+
'getHealth',
|
|
711
|
+
{} as Record<string, never>,
|
|
712
|
+
optionsArg,
|
|
713
|
+
) as INoSqlDbHealth;
|
|
714
|
+
} catch (error) {
|
|
715
|
+
await this.awaitManagementOperationTermination(error);
|
|
716
|
+
throw error;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
public async createDatabaseTenant(
|
|
721
|
+
params: INoSqlDbDatabaseTenantInput,
|
|
722
|
+
): Promise<INoSqlDbDatabaseTenantDescriptor> {
|
|
723
|
+
try {
|
|
724
|
+
return await this.bridge.sendCommand('createDatabaseTenant', params) as INoSqlDbDatabaseTenantDescriptor;
|
|
725
|
+
} catch (error) {
|
|
726
|
+
throw normalizeNoSqlDbResourceFenceError(error);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
public async ensureDatabaseTenant(
|
|
731
|
+
params: INoSqlDbEnsureDatabaseTenantInput,
|
|
732
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
733
|
+
): Promise<INoSqlDbEnsureDatabaseTenantResult> {
|
|
734
|
+
try {
|
|
735
|
+
return await this.bridge.sendCommand(
|
|
736
|
+
'ensureDatabaseTenant',
|
|
737
|
+
params,
|
|
738
|
+
optionsArg,
|
|
739
|
+
) as INoSqlDbEnsureDatabaseTenantResult;
|
|
740
|
+
} catch (error) {
|
|
741
|
+
await this.awaitManagementOperationTermination(error);
|
|
742
|
+
throw normalizeNoSqlDbResourceFenceError(error);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
public async attestDatabaseTenant(
|
|
747
|
+
params: INoSqlDbAttestDatabaseTenantInput,
|
|
748
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
749
|
+
): Promise<INoSqlDbAttestDatabaseTenantResult> {
|
|
750
|
+
try {
|
|
751
|
+
return await this.bridge.sendCommand(
|
|
752
|
+
'attestDatabaseTenant',
|
|
753
|
+
params,
|
|
754
|
+
optionsArg,
|
|
755
|
+
) as INoSqlDbAttestDatabaseTenantResult;
|
|
756
|
+
} catch (error) {
|
|
757
|
+
await this.awaitManagementOperationTermination(error);
|
|
758
|
+
throw normalizeNoSqlDbResourceFenceError(error);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
public async allocateDatabaseTenant(
|
|
763
|
+
params: INoSqlDbAllocateDatabaseTenantInput,
|
|
764
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
765
|
+
): Promise<INoSqlDbAllocateDatabaseTenantResult> {
|
|
766
|
+
try {
|
|
767
|
+
return await this.bridge.sendCommand(
|
|
768
|
+
'allocateDatabaseTenant',
|
|
769
|
+
params,
|
|
770
|
+
optionsArg,
|
|
771
|
+
) as INoSqlDbAllocateDatabaseTenantResult;
|
|
772
|
+
} catch (error) {
|
|
773
|
+
await this.awaitManagementOperationTermination(error);
|
|
774
|
+
throw normalizeNoSqlDbResourceFenceError(error);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
public async deleteDatabaseTenant(
|
|
779
|
+
params: INoSqlDbDeleteDatabaseTenantInput,
|
|
780
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
781
|
+
): Promise<INoSqlDbDeleteDatabaseTenantResult> {
|
|
782
|
+
try {
|
|
783
|
+
return await this.bridge.sendCommand(
|
|
784
|
+
'deleteDatabaseTenant',
|
|
785
|
+
params,
|
|
786
|
+
optionsArg,
|
|
787
|
+
) as INoSqlDbDeleteDatabaseTenantResult;
|
|
788
|
+
} catch (error) {
|
|
789
|
+
await this.awaitManagementOperationTermination(error);
|
|
790
|
+
throw normalizeNoSqlDbResourceFenceError(error);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
public async issueDatabaseAllocationReadAccessGrant(
|
|
795
|
+
params: INoSqlDbIssueDatabaseAllocationReadAccessGrantInput,
|
|
796
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
797
|
+
): Promise<INoSqlDbIssueDatabaseAllocationReadAccessGrantResult> {
|
|
798
|
+
try {
|
|
799
|
+
return await this.bridge.sendCommand(
|
|
800
|
+
'issueDatabaseAllocationReadAccessGrant',
|
|
801
|
+
params,
|
|
802
|
+
optionsArg,
|
|
803
|
+
) as INoSqlDbIssueDatabaseAllocationReadAccessGrantResult;
|
|
804
|
+
} catch (error) {
|
|
805
|
+
await this.awaitManagementOperationTermination(error);
|
|
806
|
+
throw normalizeNoSqlDbAllocationReadAccessGrantError(
|
|
807
|
+
normalizeNoSqlDbResourceFenceError(error),
|
|
808
|
+
error instanceof plugins.smartrust.RustBridgeRequestError
|
|
809
|
+
? error.responseErrorCode
|
|
810
|
+
: undefined,
|
|
811
|
+
);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
public async revokeDatabaseAllocationReadAccessGrant(
|
|
816
|
+
params: INoSqlDbRevokeDatabaseAllocationReadAccessGrantInput,
|
|
817
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
818
|
+
): Promise<INoSqlDbRevokeDatabaseAllocationReadAccessGrantResult> {
|
|
819
|
+
try {
|
|
820
|
+
return await this.bridge.sendCommand(
|
|
821
|
+
'revokeDatabaseAllocationReadAccessGrant',
|
|
822
|
+
params,
|
|
823
|
+
optionsArg,
|
|
824
|
+
) as INoSqlDbRevokeDatabaseAllocationReadAccessGrantResult;
|
|
825
|
+
} catch (error) {
|
|
826
|
+
await this.awaitManagementOperationTermination(error);
|
|
827
|
+
throw normalizeNoSqlDbAllocationReadAccessGrantError(
|
|
828
|
+
normalizeNoSqlDbResourceFenceError(error),
|
|
829
|
+
error instanceof plugins.smartrust.RustBridgeRequestError
|
|
830
|
+
? error.responseErrorCode
|
|
831
|
+
: undefined,
|
|
832
|
+
);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
public async rotateDatabaseTenantPassword(
|
|
837
|
+
params: INoSqlDbRotateDatabaseTenantPasswordInput,
|
|
838
|
+
): Promise<INoSqlDbDatabaseTenantDescriptor> {
|
|
839
|
+
return this.bridge.sendCommand('rotateDatabaseTenantPassword', params) as Promise<INoSqlDbDatabaseTenantDescriptor>;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
public async listDatabaseTenants(): Promise<INoSqlDbDatabaseTenantDescriptor[]> {
|
|
843
|
+
const result = await this.bridge.sendCommand('listDatabaseTenants', {} as Record<string, never>) as { tenants: INoSqlDbDatabaseTenantDescriptor[] };
|
|
844
|
+
return result.tenants;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
public async getDatabaseTenantDescriptor(params: {
|
|
848
|
+
databaseName: string;
|
|
849
|
+
username: string;
|
|
850
|
+
}): Promise<INoSqlDbDatabaseTenantDescriptor> {
|
|
851
|
+
return this.bridge.sendCommand('getDatabaseTenantDescriptor', params) as Promise<INoSqlDbDatabaseTenantDescriptor>;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
public async getDatabaseResourceFenceState(
|
|
855
|
+
params: { databaseName: string },
|
|
856
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
857
|
+
): Promise<INoSqlDbDatabaseResourceFenceState | null> {
|
|
858
|
+
try {
|
|
859
|
+
return await this.bridge.sendCommand(
|
|
860
|
+
'getDatabaseResourceFenceState',
|
|
861
|
+
params,
|
|
862
|
+
optionsArg,
|
|
863
|
+
) as INoSqlDbDatabaseResourceFenceState | null;
|
|
864
|
+
} catch (error) {
|
|
865
|
+
await this.awaitManagementOperationTermination(error);
|
|
866
|
+
throw normalizeNoSqlDbResourceFenceError(error);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
public async exportDatabase(
|
|
871
|
+
params: INoSqlDbExportDatabaseInput,
|
|
872
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
873
|
+
): Promise<INoSqlDbDatabaseExport> {
|
|
874
|
+
try {
|
|
875
|
+
return await this.bridge.sendCommand(
|
|
876
|
+
'exportDatabase',
|
|
877
|
+
params,
|
|
878
|
+
optionsArg,
|
|
879
|
+
) as INoSqlDbDatabaseExport;
|
|
880
|
+
} catch (error) {
|
|
881
|
+
await this.awaitManagementOperationTermination(error);
|
|
882
|
+
throw error;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
public async getDatabaseContentDigest(
|
|
887
|
+
params: INoSqlDbGetDatabaseContentDigestInput,
|
|
888
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
889
|
+
): Promise<INoSqlDbDatabaseContentDigest> {
|
|
890
|
+
try {
|
|
891
|
+
return await this.bridge.sendCommand(
|
|
892
|
+
'getDatabaseContentDigest',
|
|
893
|
+
params,
|
|
894
|
+
optionsArg,
|
|
895
|
+
) as INoSqlDbDatabaseContentDigest;
|
|
896
|
+
} catch (error) {
|
|
897
|
+
await this.awaitManagementOperationTermination(error);
|
|
898
|
+
throw error;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
public async importDatabase(
|
|
903
|
+
params: INoSqlDbImportDatabaseInput,
|
|
904
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
905
|
+
): Promise<INoSqlDbImportDatabaseResult> {
|
|
906
|
+
try {
|
|
907
|
+
return await this.bridge.sendCommand(
|
|
908
|
+
'importDatabase',
|
|
909
|
+
{ ...params, timeoutMs: optionsArg?.timeoutMs },
|
|
910
|
+
optionsArg,
|
|
911
|
+
) as INoSqlDbImportDatabaseResult;
|
|
912
|
+
} catch (error) {
|
|
913
|
+
await this.awaitManagementOperationTermination(error);
|
|
914
|
+
throw normalizeNoSqlDbResourceFenceError(error);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
public async commitDatabasePublication(
|
|
919
|
+
params: INoSqlDbCommitDatabasePublicationInput,
|
|
920
|
+
optionsArg?: INoSqlDbManagementOperationOptions,
|
|
921
|
+
): Promise<TNoSqlDbCommitDatabasePublicationResult> {
|
|
922
|
+
try {
|
|
923
|
+
return await this.bridge.sendCommand(
|
|
924
|
+
'commitDatabasePublication',
|
|
925
|
+
params,
|
|
926
|
+
optionsArg,
|
|
927
|
+
) as TNoSqlDbCommitDatabasePublicationResult;
|
|
928
|
+
} catch (error) {
|
|
929
|
+
await this.awaitManagementOperationTermination(error);
|
|
930
|
+
throw normalizeNoSqlDbResourceFenceError(error);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
public async getOpLog(params: {
|
|
935
|
+
sinceSeq?: number;
|
|
936
|
+
limit?: number;
|
|
937
|
+
db?: string;
|
|
938
|
+
collection?: string;
|
|
939
|
+
} = {}): Promise<IOpLogResult> {
|
|
940
|
+
return this.bridge.sendCommand('getOpLog', params) as Promise<IOpLogResult>;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
public async getOpLogStats(): Promise<IOpLogStats> {
|
|
944
|
+
return this.bridge.sendCommand('getOpLogStats', {} as Record<string, never>) as Promise<IOpLogStats>;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
public async revertToSeq(seq: number, dryRun = false): Promise<IRevertResult> {
|
|
948
|
+
return this.bridge.sendCommand('revertToSeq', { seq, dryRun }) as Promise<IRevertResult>;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
public async getCollections(db?: string): Promise<ICollectionInfo[]> {
|
|
952
|
+
const result = await this.bridge.sendCommand('getCollections', db ? { db } : {}) as { collections: ICollectionInfo[] };
|
|
953
|
+
return result.collections;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
public async getDocuments(
|
|
957
|
+
db: string,
|
|
958
|
+
collection: string,
|
|
959
|
+
limit = 50,
|
|
960
|
+
skip = 0,
|
|
961
|
+
): Promise<IDocumentsResult> {
|
|
962
|
+
return this.bridge.sendCommand('getDocuments', { db, collection, limit, skip }) as Promise<IDocumentsResult>;
|
|
963
|
+
}
|
|
964
|
+
}
|