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