monsqlize 2.0.6 → 3.1.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/CHANGELOG.md +12 -5
- package/MIGRATION.md +127 -0
- package/README.md +194 -202
- package/SECURITY.md +21 -0
- package/changelogs/README.md +16 -4
- package/changelogs/v2.0.7.md +63 -0
- package/changelogs/v3.0.0.md +99 -0
- package/changelogs/v3.1.0-rc.0.md +23 -0
- package/changelogs/v3.1.0.md +24 -0
- package/dist/cjs/cli/data-task.cjs +380 -0
- package/dist/cjs/index.cjs +12261 -5497
- package/dist/cjs/transaction/Transaction.cjs +151 -19
- package/dist/cjs/transaction/TransactionManager.cjs +152 -20
- package/dist/esm/index.mjs +12265 -5500
- package/dist/types/collection.d.mts +92 -13
- package/dist/types/collection.d.ts +92 -13
- package/dist/types/data-tasks.d.mts +221 -0
- package/dist/types/data-tasks.d.ts +221 -0
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lock.d.mts +7 -4
- package/dist/types/lock.d.ts +7 -4
- package/dist/types/model.d.mts +46 -14
- package/dist/types/model.d.ts +46 -14
- package/dist/types/monsqlize.d.mts +130 -16
- package/dist/types/monsqlize.d.ts +130 -16
- package/dist/types/runtime.d.mts +14 -1
- package/dist/types/runtime.d.ts +14 -1
- package/dist/types/saga.d.mts +11 -6
- package/dist/types/saga.d.ts +11 -6
- package/dist/types/sync.d.mts +47 -1
- package/dist/types/sync.d.ts +47 -1
- package/dist/types/transaction.d.mts +8 -0
- package/dist/types/transaction.d.ts +8 -0
- package/licenses/production-dependencies.json +11 -0
- package/package.json +45 -16
|
@@ -8,9 +8,64 @@ export interface MetaOptions {
|
|
|
8
8
|
includeCache?: boolean;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export type CacheInvalidationOperation =
|
|
12
|
+
| 'find'
|
|
13
|
+
| 'findOne'
|
|
14
|
+
| 'count'
|
|
15
|
+
| 'findPage'
|
|
16
|
+
| 'aggregate'
|
|
17
|
+
| 'distinct'
|
|
18
|
+
| 'findOneById'
|
|
19
|
+
| 'findByIds'
|
|
20
|
+
| 'all';
|
|
21
|
+
|
|
22
|
+
export type CacheInvalidationEntry =
|
|
23
|
+
| string
|
|
24
|
+
| {
|
|
25
|
+
/** Exact cache key to delete. */
|
|
26
|
+
cacheKey?: string;
|
|
27
|
+
/** Exact cache keys to delete. */
|
|
28
|
+
cacheKeys?: string[];
|
|
29
|
+
/** Cache pattern to delete with delPattern(). */
|
|
30
|
+
pattern?: string;
|
|
31
|
+
/** Cache patterns to delete with delPattern(). */
|
|
32
|
+
patterns?: string[];
|
|
33
|
+
/** Read operation to invalidate. Add query/options for exact key invalidation. */
|
|
34
|
+
operation?: CacheInvalidationOperation | string;
|
|
35
|
+
/** Alias for operation. */
|
|
36
|
+
op?: CacheInvalidationOperation | string;
|
|
37
|
+
query?: unknown;
|
|
38
|
+
options?: unknown;
|
|
39
|
+
pipeline?: unknown[];
|
|
40
|
+
/** Field name for distinct invalidation descriptors. */
|
|
41
|
+
field?: string;
|
|
42
|
+
/** ID for findOneById invalidation descriptors. */
|
|
43
|
+
id?: unknown;
|
|
44
|
+
/** IDs for findByIds invalidation descriptors. */
|
|
45
|
+
ids?: unknown[];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type CacheInvalidationRequest = CacheInvalidationEntry | CacheInvalidationEntry[];
|
|
49
|
+
|
|
50
|
+
export interface WriteCacheControlOptions {
|
|
51
|
+
cache?: {
|
|
52
|
+
/**
|
|
53
|
+
* Explicit invalidation for this write. `false` or `[]` means no invalidation for
|
|
54
|
+
* this write, even when instance-level cache.autoInvalidate is enabled.
|
|
55
|
+
*/
|
|
56
|
+
invalidate?: false | true | CacheInvalidationRequest;
|
|
57
|
+
/** Per-write broad invalidation shortcut. Prefer invalidate for precise entries. */
|
|
58
|
+
autoInvalidate?: boolean;
|
|
59
|
+
};
|
|
60
|
+
/** Per-write broad invalidation shortcut kept for compatibility. */
|
|
61
|
+
autoInvalidate?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
11
64
|
/** v1-compatible find options exported from the root package. */
|
|
12
65
|
export interface FindOptions {
|
|
13
66
|
projection?: Record<string, any> | string[];
|
|
67
|
+
/** Alias for `projection`; `projection` wins when both are provided. */
|
|
68
|
+
project?: Record<string, any> | string[];
|
|
14
69
|
sort?: Record<string, 1 | -1>;
|
|
15
70
|
limit?: number;
|
|
16
71
|
skip?: number;
|
|
@@ -157,6 +212,8 @@ export interface TotalsOptions {
|
|
|
157
212
|
/** Stream query options for collection.stream(). */
|
|
158
213
|
export interface StreamOptions {
|
|
159
214
|
projection?: Record<string, unknown> | string[];
|
|
215
|
+
/** Alias for `projection`; `projection` wins when both are provided. */
|
|
216
|
+
project?: Record<string, unknown> | string[];
|
|
160
217
|
sort?: Record<string, 1 | -1>;
|
|
161
218
|
limit?: number;
|
|
162
219
|
skip?: number;
|
|
@@ -171,6 +228,8 @@ export interface StreamOptions {
|
|
|
171
228
|
/** Explain/query plan options for collection.explain(). */
|
|
172
229
|
export interface ExplainOptions {
|
|
173
230
|
projection?: Record<string, unknown>;
|
|
231
|
+
/** Alias for `projection`; `projection` wins when both are provided. */
|
|
232
|
+
project?: Record<string, unknown>;
|
|
174
233
|
sort?: Record<string, 1 | -1>;
|
|
175
234
|
limit?: number;
|
|
176
235
|
skip?: number;
|
|
@@ -213,9 +272,11 @@ export interface HealthView {
|
|
|
213
272
|
status: 'up' | 'down';
|
|
214
273
|
connected: boolean;
|
|
215
274
|
/** @since v1 — driver connection state alias */
|
|
216
|
-
driver?: { connected: boolean };
|
|
275
|
+
driver?: { connected: boolean; error?: string };
|
|
217
276
|
defaults?: Record<string, unknown>;
|
|
218
277
|
cache?: Record<string, unknown>;
|
|
278
|
+
checks?: Record<string, Record<string, unknown> & { status: 'up' | 'down' | 'unknown' }>;
|
|
279
|
+
capabilities?: Record<string, unknown>;
|
|
219
280
|
}
|
|
220
281
|
|
|
221
282
|
export interface InsertOneResult {
|
|
@@ -242,6 +303,10 @@ export interface DeleteResult {
|
|
|
242
303
|
deletedCount: number;
|
|
243
304
|
}
|
|
244
305
|
|
|
306
|
+
export type CursorValueType = 'date' | 'objectId' | 'string' | 'number' | 'boolean' | 'raw';
|
|
307
|
+
|
|
308
|
+
export type CursorValueNormalizer = (field: string, value: unknown) => unknown;
|
|
309
|
+
|
|
245
310
|
export interface FindPageOptions<TSchema = any> {
|
|
246
311
|
query?: Document;
|
|
247
312
|
page?: number;
|
|
@@ -249,7 +314,9 @@ export interface FindPageOptions<TSchema = any> {
|
|
|
249
314
|
after?: string;
|
|
250
315
|
before?: string;
|
|
251
316
|
sort?: Sort;
|
|
252
|
-
projection?: Document;
|
|
317
|
+
projection?: Document | string[];
|
|
318
|
+
/** Alias for `projection`; `projection` wins when both are provided. */
|
|
319
|
+
project?: Document | string[];
|
|
253
320
|
pipeline?: Document[];
|
|
254
321
|
/** Totals/count configuration */
|
|
255
322
|
totals?: TotalsOptions;
|
|
@@ -257,6 +324,10 @@ export interface FindPageOptions<TSchema = any> {
|
|
|
257
324
|
explain?: boolean | string;
|
|
258
325
|
/** Query comment for server-side profiling. v1 compat — top-level shortcut for `options.comment`. */
|
|
259
326
|
comment?: string;
|
|
327
|
+
/** Cursor value type hints used when decoding after/before tokens. Keeps ISO-like string fields as strings when set to `string` or `raw`. */
|
|
328
|
+
cursorTypes?: Record<string, CursorValueType>;
|
|
329
|
+
/** Custom cursor value normalizer. Receives the sort field name and decoded cursor value. */
|
|
330
|
+
cursorValueNormalizer?: CursorValueNormalizer;
|
|
260
331
|
options?: MongoFindOptions;
|
|
261
332
|
/** Cursor-walking bookmark jump configuration */
|
|
262
333
|
jump?: JumpOptions;
|
|
@@ -432,12 +503,16 @@ export interface UpdateBatchResult {
|
|
|
432
503
|
totalCount: number | null;
|
|
433
504
|
matchedCount: number;
|
|
434
505
|
modifiedCount: number;
|
|
435
|
-
/**
|
|
506
|
+
/** Always 0; updateBatch rejects `upsert: true` before executing batch writes. */
|
|
436
507
|
upsertedCount: number;
|
|
437
508
|
batchCount: number;
|
|
438
509
|
errors: BatchErrorRecord[];
|
|
439
510
|
/** Per-batch retry records. */
|
|
440
511
|
retries: BatchRetryRecord[];
|
|
512
|
+
/** Number of documents skipped by strict model version conflict handling. */
|
|
513
|
+
conflictCount?: number;
|
|
514
|
+
/** Document ids skipped by strict model version conflict handling. */
|
|
515
|
+
conflictedIds?: unknown[];
|
|
441
516
|
}
|
|
442
517
|
|
|
443
518
|
export interface DeleteBatchResult {
|
|
@@ -450,7 +525,7 @@ export interface DeleteBatchResult {
|
|
|
450
525
|
retries: BatchRetryRecord[];
|
|
451
526
|
}
|
|
452
527
|
|
|
453
|
-
export interface BatchWriteOptions {
|
|
528
|
+
export interface BatchWriteOptions extends WriteCacheControlOptions {
|
|
454
529
|
batchSize?: number;
|
|
455
530
|
ordered?: boolean;
|
|
456
531
|
concurrency?: number;
|
|
@@ -462,7 +537,7 @@ export interface BatchWriteOptions {
|
|
|
462
537
|
}
|
|
463
538
|
|
|
464
539
|
/** Options for updateBatch operations. */
|
|
465
|
-
export interface UpdateBatchOptions {
|
|
540
|
+
export interface UpdateBatchOptions extends WriteCacheControlOptions {
|
|
466
541
|
/** Number of documents per batch (default: 1000). */
|
|
467
542
|
batchSize?: number;
|
|
468
543
|
/** Estimate total for progress reporting. */
|
|
@@ -479,7 +554,11 @@ export interface UpdateBatchOptions {
|
|
|
479
554
|
onRetry?: (retryInfo: RetryInfo) => void;
|
|
480
555
|
/** MongoDB write concern. */
|
|
481
556
|
writeConcern?: WriteConcern;
|
|
482
|
-
/**
|
|
557
|
+
/**
|
|
558
|
+
* @deprecated `updateBatch` does not support `upsert: true`; use `upsertOne` for
|
|
559
|
+
* single-document upserts, or `updateMany(..., { upsert: true })` only when you
|
|
560
|
+
* want MongoDB's native single-insert-on-no-match semantics. Passing `true` throws.
|
|
561
|
+
*/
|
|
483
562
|
upsert?: boolean;
|
|
484
563
|
/** Array filters for nested array updates. */
|
|
485
564
|
arrayFilters?: unknown[];
|
|
@@ -489,7 +568,7 @@ export interface UpdateBatchOptions {
|
|
|
489
568
|
sort?: Record<string, 1 | -1>;
|
|
490
569
|
}
|
|
491
570
|
|
|
492
|
-
export interface IncrementOneOptions extends Record<string, unknown> {
|
|
571
|
+
export interface IncrementOneOptions extends WriteCacheControlOptions, Record<string, unknown> {
|
|
493
572
|
returnDocument?: 'before' | 'after';
|
|
494
573
|
projection?: Record<string, unknown>;
|
|
495
574
|
$set?: Record<string, unknown>;
|
|
@@ -613,7 +692,7 @@ export interface AdminAccessor {
|
|
|
613
692
|
|
|
614
693
|
export interface Collection<TSchema = any> {
|
|
615
694
|
/** Returns the namespace descriptor (iid, db, collection) for this collection. */
|
|
616
|
-
getNamespace(): { iid: string; type: 'mongodb'; db: string; collection: string; };
|
|
695
|
+
getNamespace(): { iid: string; type: 'mongodb'; db: string; collection: string; pool?: string; };
|
|
617
696
|
/** Returns the underlying native MongoDB Collection object. */
|
|
618
697
|
raw(): unknown;
|
|
619
698
|
/**
|
|
@@ -783,7 +862,7 @@ export interface Collection<TSchema = any> {
|
|
|
783
862
|
* Updates matched documents in configurable batches, walking via a cursor.
|
|
784
863
|
* @param filter - MongoDB filter query.
|
|
785
864
|
* @param update - Update operators.
|
|
786
|
-
* @param options - UpdateBatchOptions (batchSize,
|
|
865
|
+
* @param options - UpdateBatchOptions (batchSize, onProgress, retry settings; `upsert: true` is rejected).
|
|
787
866
|
* @returns Aggregated update result across all batches.
|
|
788
867
|
* @since v1.2.0
|
|
789
868
|
*/
|
|
@@ -991,12 +1070,12 @@ export type ClearBookmarksResult = BookmarkClearResult;
|
|
|
991
1070
|
// ---------------------------------------------------------------------------
|
|
992
1071
|
|
|
993
1072
|
/** Simplified insertOne options (used for the shorthand call form). */
|
|
994
|
-
export interface InsertOneSimplifiedOptions {
|
|
1073
|
+
export interface InsertOneSimplifiedOptions extends WriteCacheControlOptions {
|
|
995
1074
|
writeConcern?: WriteConcern;
|
|
996
1075
|
bypassDocumentValidation?: boolean;
|
|
997
1076
|
comment?: string;
|
|
998
1077
|
session?: unknown;
|
|
999
|
-
/**
|
|
1078
|
+
/** Broadly invalidate query cache on success. Prefer `cache.invalidate` for precise entries. */
|
|
1000
1079
|
autoInvalidate?: boolean;
|
|
1001
1080
|
}
|
|
1002
1081
|
|
|
@@ -1009,13 +1088,13 @@ export interface InsertOneOptions {
|
|
|
1009
1088
|
}
|
|
1010
1089
|
|
|
1011
1090
|
/** Simplified insertMany options (used for the shorthand call form). */
|
|
1012
|
-
export interface InsertManySimplifiedOptions {
|
|
1091
|
+
export interface InsertManySimplifiedOptions extends WriteCacheControlOptions {
|
|
1013
1092
|
ordered?: boolean;
|
|
1014
1093
|
writeConcern?: WriteConcern;
|
|
1015
1094
|
bypassDocumentValidation?: boolean;
|
|
1016
1095
|
comment?: string;
|
|
1017
1096
|
session?: unknown;
|
|
1018
|
-
/**
|
|
1097
|
+
/** Broadly invalidate query cache on success. Prefer `cache.invalidate` for precise entries. */
|
|
1019
1098
|
autoInvalidate?: boolean;
|
|
1020
1099
|
}
|
|
1021
1100
|
|
|
@@ -8,9 +8,64 @@ export interface MetaOptions {
|
|
|
8
8
|
includeCache?: boolean;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export type CacheInvalidationOperation =
|
|
12
|
+
| 'find'
|
|
13
|
+
| 'findOne'
|
|
14
|
+
| 'count'
|
|
15
|
+
| 'findPage'
|
|
16
|
+
| 'aggregate'
|
|
17
|
+
| 'distinct'
|
|
18
|
+
| 'findOneById'
|
|
19
|
+
| 'findByIds'
|
|
20
|
+
| 'all';
|
|
21
|
+
|
|
22
|
+
export type CacheInvalidationEntry =
|
|
23
|
+
| string
|
|
24
|
+
| {
|
|
25
|
+
/** Exact cache key to delete. */
|
|
26
|
+
cacheKey?: string;
|
|
27
|
+
/** Exact cache keys to delete. */
|
|
28
|
+
cacheKeys?: string[];
|
|
29
|
+
/** Cache pattern to delete with delPattern(). */
|
|
30
|
+
pattern?: string;
|
|
31
|
+
/** Cache patterns to delete with delPattern(). */
|
|
32
|
+
patterns?: string[];
|
|
33
|
+
/** Read operation to invalidate. Add query/options for exact key invalidation. */
|
|
34
|
+
operation?: CacheInvalidationOperation | string;
|
|
35
|
+
/** Alias for operation. */
|
|
36
|
+
op?: CacheInvalidationOperation | string;
|
|
37
|
+
query?: unknown;
|
|
38
|
+
options?: unknown;
|
|
39
|
+
pipeline?: unknown[];
|
|
40
|
+
/** Field name for distinct invalidation descriptors. */
|
|
41
|
+
field?: string;
|
|
42
|
+
/** ID for findOneById invalidation descriptors. */
|
|
43
|
+
id?: unknown;
|
|
44
|
+
/** IDs for findByIds invalidation descriptors. */
|
|
45
|
+
ids?: unknown[];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type CacheInvalidationRequest = CacheInvalidationEntry | CacheInvalidationEntry[];
|
|
49
|
+
|
|
50
|
+
export interface WriteCacheControlOptions {
|
|
51
|
+
cache?: {
|
|
52
|
+
/**
|
|
53
|
+
* Explicit invalidation for this write. `false` or `[]` means no invalidation for
|
|
54
|
+
* this write, even when instance-level cache.autoInvalidate is enabled.
|
|
55
|
+
*/
|
|
56
|
+
invalidate?: false | true | CacheInvalidationRequest;
|
|
57
|
+
/** Per-write broad invalidation shortcut. Prefer invalidate for precise entries. */
|
|
58
|
+
autoInvalidate?: boolean;
|
|
59
|
+
};
|
|
60
|
+
/** Per-write broad invalidation shortcut kept for compatibility. */
|
|
61
|
+
autoInvalidate?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
11
64
|
/** v1-compatible find options exported from the root package. */
|
|
12
65
|
export interface FindOptions {
|
|
13
66
|
projection?: Record<string, any> | string[];
|
|
67
|
+
/** Alias for `projection`; `projection` wins when both are provided. */
|
|
68
|
+
project?: Record<string, any> | string[];
|
|
14
69
|
sort?: Record<string, 1 | -1>;
|
|
15
70
|
limit?: number;
|
|
16
71
|
skip?: number;
|
|
@@ -157,6 +212,8 @@ export interface TotalsOptions {
|
|
|
157
212
|
/** Stream query options for collection.stream(). */
|
|
158
213
|
export interface StreamOptions {
|
|
159
214
|
projection?: Record<string, unknown> | string[];
|
|
215
|
+
/** Alias for `projection`; `projection` wins when both are provided. */
|
|
216
|
+
project?: Record<string, unknown> | string[];
|
|
160
217
|
sort?: Record<string, 1 | -1>;
|
|
161
218
|
limit?: number;
|
|
162
219
|
skip?: number;
|
|
@@ -171,6 +228,8 @@ export interface StreamOptions {
|
|
|
171
228
|
/** Explain/query plan options for collection.explain(). */
|
|
172
229
|
export interface ExplainOptions {
|
|
173
230
|
projection?: Record<string, unknown>;
|
|
231
|
+
/** Alias for `projection`; `projection` wins when both are provided. */
|
|
232
|
+
project?: Record<string, unknown>;
|
|
174
233
|
sort?: Record<string, 1 | -1>;
|
|
175
234
|
limit?: number;
|
|
176
235
|
skip?: number;
|
|
@@ -213,9 +272,11 @@ export interface HealthView {
|
|
|
213
272
|
status: 'up' | 'down';
|
|
214
273
|
connected: boolean;
|
|
215
274
|
/** @since v1 — driver connection state alias */
|
|
216
|
-
driver?: { connected: boolean };
|
|
275
|
+
driver?: { connected: boolean; error?: string };
|
|
217
276
|
defaults?: Record<string, unknown>;
|
|
218
277
|
cache?: Record<string, unknown>;
|
|
278
|
+
checks?: Record<string, Record<string, unknown> & { status: 'up' | 'down' | 'unknown' }>;
|
|
279
|
+
capabilities?: Record<string, unknown>;
|
|
219
280
|
}
|
|
220
281
|
|
|
221
282
|
export interface InsertOneResult {
|
|
@@ -242,6 +303,10 @@ export interface DeleteResult {
|
|
|
242
303
|
deletedCount: number;
|
|
243
304
|
}
|
|
244
305
|
|
|
306
|
+
export type CursorValueType = 'date' | 'objectId' | 'string' | 'number' | 'boolean' | 'raw';
|
|
307
|
+
|
|
308
|
+
export type CursorValueNormalizer = (field: string, value: unknown) => unknown;
|
|
309
|
+
|
|
245
310
|
export interface FindPageOptions<TSchema = any> {
|
|
246
311
|
query?: Document;
|
|
247
312
|
page?: number;
|
|
@@ -249,7 +314,9 @@ export interface FindPageOptions<TSchema = any> {
|
|
|
249
314
|
after?: string;
|
|
250
315
|
before?: string;
|
|
251
316
|
sort?: Sort;
|
|
252
|
-
projection?: Document;
|
|
317
|
+
projection?: Document | string[];
|
|
318
|
+
/** Alias for `projection`; `projection` wins when both are provided. */
|
|
319
|
+
project?: Document | string[];
|
|
253
320
|
pipeline?: Document[];
|
|
254
321
|
/** Totals/count configuration */
|
|
255
322
|
totals?: TotalsOptions;
|
|
@@ -257,6 +324,10 @@ export interface FindPageOptions<TSchema = any> {
|
|
|
257
324
|
explain?: boolean | string;
|
|
258
325
|
/** Query comment for server-side profiling. v1 compat — top-level shortcut for `options.comment`. */
|
|
259
326
|
comment?: string;
|
|
327
|
+
/** Cursor value type hints used when decoding after/before tokens. Keeps ISO-like string fields as strings when set to `string` or `raw`. */
|
|
328
|
+
cursorTypes?: Record<string, CursorValueType>;
|
|
329
|
+
/** Custom cursor value normalizer. Receives the sort field name and decoded cursor value. */
|
|
330
|
+
cursorValueNormalizer?: CursorValueNormalizer;
|
|
260
331
|
options?: MongoFindOptions;
|
|
261
332
|
/** Cursor-walking bookmark jump configuration */
|
|
262
333
|
jump?: JumpOptions;
|
|
@@ -432,12 +503,16 @@ export interface UpdateBatchResult {
|
|
|
432
503
|
totalCount: number | null;
|
|
433
504
|
matchedCount: number;
|
|
434
505
|
modifiedCount: number;
|
|
435
|
-
/**
|
|
506
|
+
/** Always 0; updateBatch rejects `upsert: true` before executing batch writes. */
|
|
436
507
|
upsertedCount: number;
|
|
437
508
|
batchCount: number;
|
|
438
509
|
errors: BatchErrorRecord[];
|
|
439
510
|
/** Per-batch retry records. */
|
|
440
511
|
retries: BatchRetryRecord[];
|
|
512
|
+
/** Number of documents skipped by strict model version conflict handling. */
|
|
513
|
+
conflictCount?: number;
|
|
514
|
+
/** Document ids skipped by strict model version conflict handling. */
|
|
515
|
+
conflictedIds?: unknown[];
|
|
441
516
|
}
|
|
442
517
|
|
|
443
518
|
export interface DeleteBatchResult {
|
|
@@ -450,7 +525,7 @@ export interface DeleteBatchResult {
|
|
|
450
525
|
retries: BatchRetryRecord[];
|
|
451
526
|
}
|
|
452
527
|
|
|
453
|
-
export interface BatchWriteOptions {
|
|
528
|
+
export interface BatchWriteOptions extends WriteCacheControlOptions {
|
|
454
529
|
batchSize?: number;
|
|
455
530
|
ordered?: boolean;
|
|
456
531
|
concurrency?: number;
|
|
@@ -462,7 +537,7 @@ export interface BatchWriteOptions {
|
|
|
462
537
|
}
|
|
463
538
|
|
|
464
539
|
/** Options for updateBatch operations. */
|
|
465
|
-
export interface UpdateBatchOptions {
|
|
540
|
+
export interface UpdateBatchOptions extends WriteCacheControlOptions {
|
|
466
541
|
/** Number of documents per batch (default: 1000). */
|
|
467
542
|
batchSize?: number;
|
|
468
543
|
/** Estimate total for progress reporting. */
|
|
@@ -479,7 +554,11 @@ export interface UpdateBatchOptions {
|
|
|
479
554
|
onRetry?: (retryInfo: RetryInfo) => void;
|
|
480
555
|
/** MongoDB write concern. */
|
|
481
556
|
writeConcern?: WriteConcern;
|
|
482
|
-
/**
|
|
557
|
+
/**
|
|
558
|
+
* @deprecated `updateBatch` does not support `upsert: true`; use `upsertOne` for
|
|
559
|
+
* single-document upserts, or `updateMany(..., { upsert: true })` only when you
|
|
560
|
+
* want MongoDB's native single-insert-on-no-match semantics. Passing `true` throws.
|
|
561
|
+
*/
|
|
483
562
|
upsert?: boolean;
|
|
484
563
|
/** Array filters for nested array updates. */
|
|
485
564
|
arrayFilters?: unknown[];
|
|
@@ -489,7 +568,7 @@ export interface UpdateBatchOptions {
|
|
|
489
568
|
sort?: Record<string, 1 | -1>;
|
|
490
569
|
}
|
|
491
570
|
|
|
492
|
-
export interface IncrementOneOptions extends Record<string, unknown> {
|
|
571
|
+
export interface IncrementOneOptions extends WriteCacheControlOptions, Record<string, unknown> {
|
|
493
572
|
returnDocument?: 'before' | 'after';
|
|
494
573
|
projection?: Record<string, unknown>;
|
|
495
574
|
$set?: Record<string, unknown>;
|
|
@@ -613,7 +692,7 @@ export interface AdminAccessor {
|
|
|
613
692
|
|
|
614
693
|
export interface Collection<TSchema = any> {
|
|
615
694
|
/** Returns the namespace descriptor (iid, db, collection) for this collection. */
|
|
616
|
-
getNamespace(): { iid: string; type: 'mongodb'; db: string; collection: string; };
|
|
695
|
+
getNamespace(): { iid: string; type: 'mongodb'; db: string; collection: string; pool?: string; };
|
|
617
696
|
/** Returns the underlying native MongoDB Collection object. */
|
|
618
697
|
raw(): unknown;
|
|
619
698
|
/**
|
|
@@ -783,7 +862,7 @@ export interface Collection<TSchema = any> {
|
|
|
783
862
|
* Updates matched documents in configurable batches, walking via a cursor.
|
|
784
863
|
* @param filter - MongoDB filter query.
|
|
785
864
|
* @param update - Update operators.
|
|
786
|
-
* @param options - UpdateBatchOptions (batchSize,
|
|
865
|
+
* @param options - UpdateBatchOptions (batchSize, onProgress, retry settings; `upsert: true` is rejected).
|
|
787
866
|
* @returns Aggregated update result across all batches.
|
|
788
867
|
* @since v1.2.0
|
|
789
868
|
*/
|
|
@@ -991,12 +1070,12 @@ export type ClearBookmarksResult = BookmarkClearResult;
|
|
|
991
1070
|
// ---------------------------------------------------------------------------
|
|
992
1071
|
|
|
993
1072
|
/** Simplified insertOne options (used for the shorthand call form). */
|
|
994
|
-
export interface InsertOneSimplifiedOptions {
|
|
1073
|
+
export interface InsertOneSimplifiedOptions extends WriteCacheControlOptions {
|
|
995
1074
|
writeConcern?: WriteConcern;
|
|
996
1075
|
bypassDocumentValidation?: boolean;
|
|
997
1076
|
comment?: string;
|
|
998
1077
|
session?: unknown;
|
|
999
|
-
/**
|
|
1078
|
+
/** Broadly invalidate query cache on success. Prefer `cache.invalidate` for precise entries. */
|
|
1000
1079
|
autoInvalidate?: boolean;
|
|
1001
1080
|
}
|
|
1002
1081
|
|
|
@@ -1009,13 +1088,13 @@ export interface InsertOneOptions {
|
|
|
1009
1088
|
}
|
|
1010
1089
|
|
|
1011
1090
|
/** Simplified insertMany options (used for the shorthand call form). */
|
|
1012
|
-
export interface InsertManySimplifiedOptions {
|
|
1091
|
+
export interface InsertManySimplifiedOptions extends WriteCacheControlOptions {
|
|
1013
1092
|
ordered?: boolean;
|
|
1014
1093
|
writeConcern?: WriteConcern;
|
|
1015
1094
|
bypassDocumentValidation?: boolean;
|
|
1016
1095
|
comment?: string;
|
|
1017
1096
|
session?: unknown;
|
|
1018
|
-
/**
|
|
1097
|
+
/** Broadly invalidate query cache on success. Prefer `cache.invalidate` for precise entries. */
|
|
1019
1098
|
autoInvalidate?: boolean;
|
|
1020
1099
|
}
|
|
1021
1100
|
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import type { MonSQLizeOptions } from './monsqlize.mjs';
|
|
2
|
+
|
|
3
|
+
export type DataTaskEnvironment = 'development' | 'test' | 'staging' | 'production' | 'prod' | 'live';
|
|
4
|
+
|
|
5
|
+
export interface DataTaskIndexDefinition {
|
|
6
|
+
key: Record<string, unknown>;
|
|
7
|
+
options?: Record<string, unknown>;
|
|
8
|
+
name?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type DataTaskJobErrorCode =
|
|
12
|
+
| 'INVALID_JOB'
|
|
13
|
+
| 'IDENTITY_CONFLICT'
|
|
14
|
+
| 'INDEX_CONFLICT'
|
|
15
|
+
| 'APPROVAL_STALE'
|
|
16
|
+
| 'BACKUP_FAILED'
|
|
17
|
+
| 'LOCK_NOT_ACQUIRED'
|
|
18
|
+
| 'LOCK_LOST'
|
|
19
|
+
| 'APPLY_PARTIAL'
|
|
20
|
+
| 'RESTORE_DRIFT'
|
|
21
|
+
| 'RESTORE_FAILED';
|
|
22
|
+
|
|
23
|
+
export declare class DataTaskJobError extends Error {
|
|
24
|
+
readonly code: DataTaskJobErrorCode;
|
|
25
|
+
readonly phase: string;
|
|
26
|
+
readonly collection?: string;
|
|
27
|
+
constructor(code: DataTaskJobErrorCode, message: string, phase?: string, collection?: string);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface DataTaskConnectionRuntime {
|
|
31
|
+
readonly options?: MonSQLizeOptions;
|
|
32
|
+
collection(name: string): unknown;
|
|
33
|
+
connect?(): Promise<unknown>;
|
|
34
|
+
close?(): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type DataTaskConnection = DataTaskConnectionRuntime | MonSQLizeOptions;
|
|
38
|
+
|
|
39
|
+
export type DataTaskIdentity =
|
|
40
|
+
| { mode: 'fields'; fields: string[] }
|
|
41
|
+
| { mode: 'source-id'; conflictBy?: string[] };
|
|
42
|
+
|
|
43
|
+
export interface DataTaskDataRule {
|
|
44
|
+
filter?: Record<string, unknown>;
|
|
45
|
+
all?: boolean;
|
|
46
|
+
identity: DataTaskIdentity;
|
|
47
|
+
strategy?: 'upsert' | 'insert';
|
|
48
|
+
projection?: Record<string, unknown>;
|
|
49
|
+
/** Rename only the listed source fields before synchronizing them. */
|
|
50
|
+
rename?: Record<string, string>;
|
|
51
|
+
/** Set only the listed literal values before synchronizing the document. */
|
|
52
|
+
set?: Record<string, unknown>;
|
|
53
|
+
/** Remove only the listed field paths from the synchronized target document. */
|
|
54
|
+
unset?: string[];
|
|
55
|
+
/** Maximum source documents this collection may plan. Defaults to 10000. */
|
|
56
|
+
maxDocuments?: number;
|
|
57
|
+
/** Write-ahead checkpoint batch size. Writes remain ordered within each batch. */
|
|
58
|
+
batchSize?: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface DataTaskVerifyRule {
|
|
62
|
+
mode?: 'sample' | 'full';
|
|
63
|
+
fields?: string[];
|
|
64
|
+
sampleSize?: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface DataTaskCollectionJob {
|
|
68
|
+
name: string;
|
|
69
|
+
targetName?: string;
|
|
70
|
+
indexes?: DataTaskIndexDefinition[];
|
|
71
|
+
data?: DataTaskDataRule;
|
|
72
|
+
verify?: DataTaskVerifyRule;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface DataTaskBackupOptions {
|
|
76
|
+
dir?: string;
|
|
77
|
+
format?: 'extended-jsonl';
|
|
78
|
+
compression?: 'gzip' | 'none';
|
|
79
|
+
retentionDays?: number;
|
|
80
|
+
/** Maximum uncompressed affected-scope backup size in bytes. Defaults to 256 MiB. */
|
|
81
|
+
maxBytes?: number;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface DataTaskLeaseLockOptions {
|
|
85
|
+
ttlMs?: number;
|
|
86
|
+
waitTimeoutMs?: number;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface DataTaskJob {
|
|
90
|
+
name: string;
|
|
91
|
+
description?: string;
|
|
92
|
+
source: DataTaskConnection;
|
|
93
|
+
target: DataTaskConnection;
|
|
94
|
+
targetEnvironment: DataTaskEnvironment;
|
|
95
|
+
collections: DataTaskCollectionJob[];
|
|
96
|
+
backup?: DataTaskBackupOptions;
|
|
97
|
+
lock?: boolean | DataTaskLeaseLockOptions;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface DataTaskApproval {
|
|
101
|
+
kind: 'apply' | 'restore';
|
|
102
|
+
token: string;
|
|
103
|
+
jobHash: string;
|
|
104
|
+
sourceHash: string;
|
|
105
|
+
targetHash: string;
|
|
106
|
+
indexHash: string;
|
|
107
|
+
issuedAt: string;
|
|
108
|
+
expiresAt: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface DataTaskIndexPlan {
|
|
112
|
+
name?: string;
|
|
113
|
+
key: Record<string, unknown>;
|
|
114
|
+
options: Record<string, unknown>;
|
|
115
|
+
status: 'existing' | 'missing' | 'conflict';
|
|
116
|
+
reason?: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface DataTaskChangeSample {
|
|
120
|
+
identity: Record<string, unknown>;
|
|
121
|
+
operation: 'insert' | 'update';
|
|
122
|
+
before: Record<string, unknown> | null;
|
|
123
|
+
after: Record<string, unknown>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface DataTaskCollectionPreview {
|
|
127
|
+
source: string;
|
|
128
|
+
target: string;
|
|
129
|
+
data: {
|
|
130
|
+
source: number;
|
|
131
|
+
insert: number;
|
|
132
|
+
update: number;
|
|
133
|
+
unchanged: number;
|
|
134
|
+
conflict: number;
|
|
135
|
+
};
|
|
136
|
+
indexes: DataTaskIndexPlan[];
|
|
137
|
+
samples: DataTaskChangeSample[];
|
|
138
|
+
backupDocuments: number;
|
|
139
|
+
backupBytes: number;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface DataTaskPreviewResult {
|
|
143
|
+
mode: 'preview';
|
|
144
|
+
jobName: string;
|
|
145
|
+
passed: boolean;
|
|
146
|
+
collections: DataTaskCollectionPreview[];
|
|
147
|
+
warnings: string[];
|
|
148
|
+
errors: string[];
|
|
149
|
+
approval?: DataTaskApproval;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface DataTaskPreviewOptions {
|
|
153
|
+
approvalTtlMs?: number;
|
|
154
|
+
sampleSize?: number;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface DataTaskBackupRef {
|
|
158
|
+
runId: string;
|
|
159
|
+
manifestPath: string;
|
|
160
|
+
checksum: string;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface DataTaskApplyOptions {
|
|
164
|
+
approval: DataTaskApproval;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface DataTaskApplyResult {
|
|
168
|
+
mode: 'apply';
|
|
169
|
+
runId: string;
|
|
170
|
+
jobName: string;
|
|
171
|
+
passed: boolean;
|
|
172
|
+
status: 'passed' | 'partial' | 'failed';
|
|
173
|
+
collections: DataTaskCollectionPreview[];
|
|
174
|
+
backup: DataTaskBackupRef;
|
|
175
|
+
warnings: string[];
|
|
176
|
+
errors: string[];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface DataTaskRestoreTargetOptions {
|
|
180
|
+
target?: DataTaskConnection;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface DataTaskRestorePreviewResult {
|
|
184
|
+
mode: 'preview-restore';
|
|
185
|
+
runId: string;
|
|
186
|
+
passed: boolean;
|
|
187
|
+
restoreDocuments: number;
|
|
188
|
+
deleteDocuments: number;
|
|
189
|
+
dropIndexes: number;
|
|
190
|
+
createIndexes: number;
|
|
191
|
+
warnings: string[];
|
|
192
|
+
errors: string[];
|
|
193
|
+
approval?: DataTaskApproval;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface DataTaskRestoreOptions extends DataTaskRestoreTargetOptions {
|
|
197
|
+
approval: DataTaskApproval;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface DataTaskRestoreResult {
|
|
201
|
+
mode: 'restore';
|
|
202
|
+
runId: string;
|
|
203
|
+
passed: boolean;
|
|
204
|
+
status: 'passed' | 'partial' | 'failed';
|
|
205
|
+
safetyBackup: DataTaskBackupRef;
|
|
206
|
+
restoredDocuments: number;
|
|
207
|
+
deletedDocuments: number;
|
|
208
|
+
droppedIndexes: number;
|
|
209
|
+
createdIndexes: number;
|
|
210
|
+
warnings: string[];
|
|
211
|
+
errors: string[];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface DataTaskService {
|
|
215
|
+
preview(job: DataTaskJob, options?: DataTaskPreviewOptions): Promise<DataTaskPreviewResult>;
|
|
216
|
+
apply(job: DataTaskJob, options: DataTaskApplyOptions): Promise<DataTaskApplyResult>;
|
|
217
|
+
previewRestore(backup: DataTaskBackupRef, options?: DataTaskRestoreTargetOptions): Promise<DataTaskRestorePreviewResult>;
|
|
218
|
+
restore(backup: DataTaskBackupRef, options: DataTaskRestoreOptions): Promise<DataTaskRestoreResult>;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export declare const dataTasks: DataTaskService;
|