monsqlize 3.3.0 → 3.3.2
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 +5 -3
- package/MIGRATION.md +66 -5
- package/README.md +37 -9
- package/changelogs/v3.3.1.md +28 -0
- package/changelogs/v3.3.2.md +37 -0
- package/dist/cjs/cli/data-task.cjs +7 -5
- package/dist/cjs/index.cjs +5032 -3325
- package/dist/cjs/transaction/Transaction.cjs +140 -14
- package/dist/cjs/transaction/TransactionManager.cjs +145 -25
- package/dist/esm/index.mjs +4836 -3130
- package/dist/types/base.d.mts +1 -1
- package/dist/types/base.d.ts +1 -1
- package/dist/types/collection.d.mts +10 -10
- package/dist/types/collection.d.ts +10 -10
- package/dist/types/data-tasks.d.mts +1 -0
- package/dist/types/data-tasks.d.ts +1 -0
- package/dist/types/index.d.mts +3 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/model.d.mts +16 -12
- package/dist/types/model.d.ts +16 -12
- package/dist/types/monsqlize.d.mts +8 -2
- package/dist/types/monsqlize.d.ts +8 -2
- package/dist/types/pool.d.mts +3 -0
- package/dist/types/pool.d.ts +3 -0
- package/dist/types/runtime.d.mts +11 -23
- package/dist/types/runtime.d.ts +11 -23
- package/dist/types/slow-query-log.d.mts +9 -1
- package/dist/types/slow-query-log.d.ts +9 -1
- package/dist/types/sync.d.mts +4 -2
- package/dist/types/sync.d.ts +4 -2
- package/dist/types/transaction.d.mts +6 -4
- package/dist/types/transaction.d.ts +6 -4
- package/package.json +7 -5
package/dist/types/base.d.mts
CHANGED
|
@@ -25,7 +25,7 @@ export interface LoggerLike {
|
|
|
25
25
|
export interface LoggerOptions {
|
|
26
26
|
/** Enable structured (JSON) log output. */
|
|
27
27
|
structured?: boolean;
|
|
28
|
-
/**
|
|
28
|
+
/** Attach the current trace ID to structured logs by default; false disables injection. */
|
|
29
29
|
enableTraceId?: boolean;
|
|
30
30
|
}
|
|
31
31
|
|
package/dist/types/base.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export interface LoggerLike {
|
|
|
25
25
|
export interface LoggerOptions {
|
|
26
26
|
/** Enable structured (JSON) log output. */
|
|
27
27
|
structured?: boolean;
|
|
28
|
-
/**
|
|
28
|
+
/** Attach the current trace ID to structured logs by default; false disables injection. */
|
|
29
29
|
enableTraceId?: boolean;
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { ChangeStream, Document, FindOptions as MongoFindOptions, Sort } from 'mongodb';
|
|
2
2
|
import type {
|
|
3
|
-
AggregateOptions,
|
|
4
3
|
MetaOptions,
|
|
5
4
|
VectorSearchHit,
|
|
6
5
|
VectorSearchOptions,
|
|
7
6
|
} from './aggregation.mjs';
|
|
8
|
-
|
|
9
7
|
export type {
|
|
10
8
|
AggregateOptions,
|
|
11
9
|
MetaOptions,
|
|
@@ -323,6 +321,8 @@ export interface FindPageOptions<TSchema = any> {
|
|
|
323
321
|
cursorTypes?: Record<string, CursorValueType>;
|
|
324
322
|
/** Custom cursor value normalizer. Receives the sort field name and decoded cursor value. */
|
|
325
323
|
cursorValueNormalizer?: CursorValueNormalizer;
|
|
324
|
+
/** Stable strategy identity and version. A per-query normalizer needs its own explicit version. */
|
|
325
|
+
cursorValueNormalizerVersion?: string;
|
|
326
326
|
options?: MongoFindOptions;
|
|
327
327
|
/** Cursor-walking bookmark jump configuration */
|
|
328
328
|
jump?: JumpOptions;
|
|
@@ -332,8 +332,8 @@ export interface FindPageOptions<TSchema = any> {
|
|
|
332
332
|
hint?: Document | string;
|
|
333
333
|
collation?: Document;
|
|
334
334
|
batchSize?: number;
|
|
335
|
-
/**
|
|
336
|
-
cache?: number;
|
|
335
|
+
/** MongoDB expression variables; overrides `options.let` when both are supplied. */ let?: Document;
|
|
336
|
+
/** Cache TTL in milliseconds for the non-stream/non-explain page result */ cache?: number;
|
|
337
337
|
/** Include timing/meta info in result — pass true or MetaOptions for sub-step detail */
|
|
338
338
|
meta?: boolean | MetaOptions;
|
|
339
339
|
}
|
|
@@ -365,7 +365,7 @@ export interface FindChain<TSchema = any, TPromise = TSchema[]> extends Promise<
|
|
|
365
365
|
batchSize(value: number): FindChain<TSchema, TPromise>;
|
|
366
366
|
explain(verbosity?: boolean | string): Promise<unknown>;
|
|
367
367
|
stream(): NodeJS.ReadableStream;
|
|
368
|
-
toArray(): Promise<
|
|
368
|
+
toArray(): Promise<TPromise>;
|
|
369
369
|
}
|
|
370
370
|
|
|
371
371
|
export interface AggregateChain<TResult = unknown, TPromise = TResult[]> extends Promise<TPromise> {
|
|
@@ -377,7 +377,7 @@ export interface AggregateChain<TResult = unknown, TPromise = TResult[]> extends
|
|
|
377
377
|
batchSize(value: number): AggregateChain<TResult, TPromise>;
|
|
378
378
|
explain(verbosity?: boolean | string): Promise<unknown>;
|
|
379
379
|
stream(): NodeJS.ReadableStream;
|
|
380
|
-
toArray(): Promise<
|
|
380
|
+
toArray(): Promise<TPromise>;
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
/** Write concern options for batch operations. */
|
|
@@ -504,10 +504,10 @@ export interface UpdateBatchResult {
|
|
|
504
504
|
errors: BatchErrorRecord[];
|
|
505
505
|
/** Per-batch retry records. */
|
|
506
506
|
retries: BatchRetryRecord[];
|
|
507
|
-
/** Number of documents skipped by strict model version conflict handling. */
|
|
508
|
-
|
|
509
|
-
/**
|
|
510
|
-
|
|
507
|
+
/** Number of documents skipped by strict model version conflict handling. */ conflictCount?: number;
|
|
508
|
+
/** Document ids skipped by strict model version conflict handling. */ conflictedIds?: unknown[];
|
|
509
|
+
/** Selected model candidates that no longer match the filter or were removed before writing. */ skippedCount?: number;
|
|
510
|
+
skippedIds?: unknown[];
|
|
511
511
|
}
|
|
512
512
|
|
|
513
513
|
export interface DeleteBatchResult {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { ChangeStream, Document, FindOptions as MongoFindOptions, Sort } from 'mongodb';
|
|
2
2
|
import type {
|
|
3
|
-
AggregateOptions,
|
|
4
3
|
MetaOptions,
|
|
5
4
|
VectorSearchHit,
|
|
6
5
|
VectorSearchOptions,
|
|
7
6
|
} from './aggregation';
|
|
8
|
-
|
|
9
7
|
export type {
|
|
10
8
|
AggregateOptions,
|
|
11
9
|
MetaOptions,
|
|
@@ -323,6 +321,8 @@ export interface FindPageOptions<TSchema = any> {
|
|
|
323
321
|
cursorTypes?: Record<string, CursorValueType>;
|
|
324
322
|
/** Custom cursor value normalizer. Receives the sort field name and decoded cursor value. */
|
|
325
323
|
cursorValueNormalizer?: CursorValueNormalizer;
|
|
324
|
+
/** Stable strategy identity and version. A per-query normalizer needs its own explicit version. */
|
|
325
|
+
cursorValueNormalizerVersion?: string;
|
|
326
326
|
options?: MongoFindOptions;
|
|
327
327
|
/** Cursor-walking bookmark jump configuration */
|
|
328
328
|
jump?: JumpOptions;
|
|
@@ -332,8 +332,8 @@ export interface FindPageOptions<TSchema = any> {
|
|
|
332
332
|
hint?: Document | string;
|
|
333
333
|
collation?: Document;
|
|
334
334
|
batchSize?: number;
|
|
335
|
-
/**
|
|
336
|
-
cache?: number;
|
|
335
|
+
/** MongoDB expression variables; overrides `options.let` when both are supplied. */ let?: Document;
|
|
336
|
+
/** Cache TTL in milliseconds for the non-stream/non-explain page result */ cache?: number;
|
|
337
337
|
/** Include timing/meta info in result — pass true or MetaOptions for sub-step detail */
|
|
338
338
|
meta?: boolean | MetaOptions;
|
|
339
339
|
}
|
|
@@ -365,7 +365,7 @@ export interface FindChain<TSchema = any, TPromise = TSchema[]> extends Promise<
|
|
|
365
365
|
batchSize(value: number): FindChain<TSchema, TPromise>;
|
|
366
366
|
explain(verbosity?: boolean | string): Promise<unknown>;
|
|
367
367
|
stream(): NodeJS.ReadableStream;
|
|
368
|
-
toArray(): Promise<
|
|
368
|
+
toArray(): Promise<TPromise>;
|
|
369
369
|
}
|
|
370
370
|
|
|
371
371
|
export interface AggregateChain<TResult = unknown, TPromise = TResult[]> extends Promise<TPromise> {
|
|
@@ -377,7 +377,7 @@ export interface AggregateChain<TResult = unknown, TPromise = TResult[]> extends
|
|
|
377
377
|
batchSize(value: number): AggregateChain<TResult, TPromise>;
|
|
378
378
|
explain(verbosity?: boolean | string): Promise<unknown>;
|
|
379
379
|
stream(): NodeJS.ReadableStream;
|
|
380
|
-
toArray(): Promise<
|
|
380
|
+
toArray(): Promise<TPromise>;
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
/** Write concern options for batch operations. */
|
|
@@ -504,10 +504,10 @@ export interface UpdateBatchResult {
|
|
|
504
504
|
errors: BatchErrorRecord[];
|
|
505
505
|
/** Per-batch retry records. */
|
|
506
506
|
retries: BatchRetryRecord[];
|
|
507
|
-
/** Number of documents skipped by strict model version conflict handling. */
|
|
508
|
-
|
|
509
|
-
/**
|
|
510
|
-
|
|
507
|
+
/** Number of documents skipped by strict model version conflict handling. */ conflictCount?: number;
|
|
508
|
+
/** Document ids skipped by strict model version conflict handling. */ conflictedIds?: unknown[];
|
|
509
|
+
/** Selected model candidates that no longer match the filter or were removed before writing. */ skippedCount?: number;
|
|
510
|
+
skippedIds?: unknown[];
|
|
511
511
|
}
|
|
512
512
|
|
|
513
513
|
export interface DeleteBatchResult {
|
|
@@ -155,6 +155,7 @@ export interface DataTaskPreviewOptions {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
export interface DataTaskBackupRef {
|
|
158
|
+
/** Canonical EJSON backup manifest. BSON identities and payloads remain typed when reopened. */
|
|
158
159
|
runId: string;
|
|
159
160
|
manifestPath: string;
|
|
160
161
|
checksum: string;
|
|
@@ -155,6 +155,7 @@ export interface DataTaskPreviewOptions {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
export interface DataTaskBackupRef {
|
|
158
|
+
/** Canonical EJSON backup manifest. BSON identities and payloads remain typed when reopened. */
|
|
158
159
|
runId: string;
|
|
159
160
|
manifestPath: string;
|
|
160
161
|
checksum: string;
|
package/dist/types/index.d.mts
CHANGED
|
@@ -17,7 +17,9 @@ export { default, MonSQLize } from './monsqlize.mjs';
|
|
|
17
17
|
export { Model, generateQueryHash, validateSyncConfig } from './runtime.mjs';
|
|
18
18
|
|
|
19
19
|
export type { Lock as LockContract } from './lock.mjs';
|
|
20
|
-
export type { ModelInstance as ModelAccessor
|
|
20
|
+
export type { ModelInstance as ModelAccessor } from './model.mjs';
|
|
21
|
+
export type ModelInstance<TDocument = any> = import('./model.mjs').ModelInstance<TDocument>;
|
|
22
|
+
export declare const ModelInstance: typeof import('./runtime.mjs').ModelInstance;
|
|
21
23
|
export type { SyncTargetConfig as SyncTarget } from './sync.mjs';
|
|
22
24
|
export type { Transaction as TransactionContract } from './transaction.mjs';
|
|
23
25
|
export type { MonSQLizeOptions as BaseOptions } from './monsqlize.mjs';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -17,7 +17,9 @@ export { default, MonSQLize } from './monsqlize';
|
|
|
17
17
|
export { Model, generateQueryHash, validateSyncConfig } from './runtime';
|
|
18
18
|
|
|
19
19
|
export type { Lock as LockContract } from './lock';
|
|
20
|
-
export type { ModelInstance as ModelAccessor
|
|
20
|
+
export type { ModelInstance as ModelAccessor } from './model';
|
|
21
|
+
export type ModelInstance<TDocument = any> = import('./model').ModelInstance<TDocument>;
|
|
22
|
+
export declare const ModelInstance: typeof import('./runtime').ModelInstance;
|
|
21
23
|
export type { SyncTargetConfig as SyncTarget } from './sync';
|
|
22
24
|
export type { Transaction as TransactionContract } from './transaction';
|
|
23
25
|
export type { MonSQLizeOptions as BaseOptions } from './monsqlize';
|
package/dist/types/model.d.mts
CHANGED
|
@@ -206,6 +206,9 @@ export type ModelUpdateManyOptions = ModelWriteOptions & {
|
|
|
206
206
|
export type ModelStrictUpdateManyResult = UpdateResult & {
|
|
207
207
|
conflictCount: number;
|
|
208
208
|
conflictedIds: unknown[];
|
|
209
|
+
/** Selected candidates no longer matching the business filter or removed before the write. */
|
|
210
|
+
skippedCount: number;
|
|
211
|
+
skippedIds: unknown[];
|
|
209
212
|
};
|
|
210
213
|
|
|
211
214
|
export type ModelIndexSource = 'definition' | 'softDelete';
|
|
@@ -405,6 +408,17 @@ type LegacyModelSyncTotalsInfo<TDocument = any> = unknown extends TDocument ? an
|
|
|
405
408
|
});
|
|
406
409
|
export type RestoreResult = Pick<UpdateResult, 'modifiedCount'> & Partial<UpdateResult>;
|
|
407
410
|
|
|
411
|
+
export interface ModelPageResult<TDocument = any> {
|
|
412
|
+
items: Array<ModelDocument<TDocument>>;
|
|
413
|
+
pageInfo: LegacyModelPageInfo<TDocument>;
|
|
414
|
+
totals?: LegacyModelTotalsInfo<TDocument>;
|
|
415
|
+
meta?: import('./collection.mjs').MetaInfo;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export interface ModelSyncPageResult<TDocument = any> extends Omit<ModelPageResult<TDocument>, 'totals'> {
|
|
419
|
+
totals: LegacyModelSyncTotalsInfo<TDocument>;
|
|
420
|
+
}
|
|
421
|
+
|
|
408
422
|
export type ModelDocument<TDocument = any> = TDocument & Record<string, unknown> & {
|
|
409
423
|
save(): Promise<ModelDocument<TDocument>>;
|
|
410
424
|
remove(): Promise<boolean>;
|
|
@@ -467,18 +481,8 @@ export interface ModelInstance<TDocument = any> {
|
|
|
467
481
|
* @param options Pagination options including `limit`, `cursor`/`page`, `filter`, and `sort`.
|
|
468
482
|
* @returns Result object containing items, page information, and optional totals.
|
|
469
483
|
*/
|
|
470
|
-
findPage(options: { totals: { mode: 'sync'; } & Record<string, unknown>; } & Record<string, unknown>): PopulateProxy<
|
|
471
|
-
|
|
472
|
-
pageInfo: LegacyModelPageInfo<TDocument>;
|
|
473
|
-
totals: LegacyModelSyncTotalsInfo<TDocument>;
|
|
474
|
-
meta?: import('./collection.mjs').MetaInfo;
|
|
475
|
-
}>;
|
|
476
|
-
findPage(options?: unknown): PopulateProxy<{
|
|
477
|
-
items: Array<ModelDocument<TDocument>>;
|
|
478
|
-
pageInfo: LegacyModelPageInfo<TDocument>;
|
|
479
|
-
totals?: LegacyModelTotalsInfo<TDocument>;
|
|
480
|
-
meta?: import('./collection.mjs').MetaInfo;
|
|
481
|
-
}>;
|
|
484
|
+
findPage(options: { totals: { mode: 'sync'; } & Record<string, unknown>; } & Record<string, unknown>): PopulateProxy<ModelSyncPageResult<TDocument>>;
|
|
485
|
+
findPage(options?: unknown): PopulateProxy<ModelPageResult<TDocument>>;
|
|
482
486
|
/**
|
|
483
487
|
* Finds documents and returns the unpaginated total count.
|
|
484
488
|
* @param query Optional filter.
|
package/dist/types/model.d.ts
CHANGED
|
@@ -206,6 +206,9 @@ export type ModelUpdateManyOptions = ModelWriteOptions & {
|
|
|
206
206
|
export type ModelStrictUpdateManyResult = UpdateResult & {
|
|
207
207
|
conflictCount: number;
|
|
208
208
|
conflictedIds: unknown[];
|
|
209
|
+
/** Selected candidates no longer matching the business filter or removed before the write. */
|
|
210
|
+
skippedCount: number;
|
|
211
|
+
skippedIds: unknown[];
|
|
209
212
|
};
|
|
210
213
|
|
|
211
214
|
export type ModelIndexSource = 'definition' | 'softDelete';
|
|
@@ -405,6 +408,17 @@ type LegacyModelSyncTotalsInfo<TDocument = any> = unknown extends TDocument ? an
|
|
|
405
408
|
});
|
|
406
409
|
export type RestoreResult = Pick<UpdateResult, 'modifiedCount'> & Partial<UpdateResult>;
|
|
407
410
|
|
|
411
|
+
export interface ModelPageResult<TDocument = any> {
|
|
412
|
+
items: Array<ModelDocument<TDocument>>;
|
|
413
|
+
pageInfo: LegacyModelPageInfo<TDocument>;
|
|
414
|
+
totals?: LegacyModelTotalsInfo<TDocument>;
|
|
415
|
+
meta?: import('./collection').MetaInfo;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export interface ModelSyncPageResult<TDocument = any> extends Omit<ModelPageResult<TDocument>, 'totals'> {
|
|
419
|
+
totals: LegacyModelSyncTotalsInfo<TDocument>;
|
|
420
|
+
}
|
|
421
|
+
|
|
408
422
|
export type ModelDocument<TDocument = any> = TDocument & Record<string, unknown> & {
|
|
409
423
|
save(): Promise<ModelDocument<TDocument>>;
|
|
410
424
|
remove(): Promise<boolean>;
|
|
@@ -467,18 +481,8 @@ export interface ModelInstance<TDocument = any> {
|
|
|
467
481
|
* @param options Pagination options including `limit`, `cursor`/`page`, `filter`, and `sort`.
|
|
468
482
|
* @returns Result object containing items, page information, and optional totals.
|
|
469
483
|
*/
|
|
470
|
-
findPage(options: { totals: { mode: 'sync'; } & Record<string, unknown>; } & Record<string, unknown>): PopulateProxy<
|
|
471
|
-
|
|
472
|
-
pageInfo: LegacyModelPageInfo<TDocument>;
|
|
473
|
-
totals: LegacyModelSyncTotalsInfo<TDocument>;
|
|
474
|
-
meta?: import('./collection').MetaInfo;
|
|
475
|
-
}>;
|
|
476
|
-
findPage(options?: unknown): PopulateProxy<{
|
|
477
|
-
items: Array<ModelDocument<TDocument>>;
|
|
478
|
-
pageInfo: LegacyModelPageInfo<TDocument>;
|
|
479
|
-
totals?: LegacyModelTotalsInfo<TDocument>;
|
|
480
|
-
meta?: import('./collection').MetaInfo;
|
|
481
|
-
}>;
|
|
484
|
+
findPage(options: { totals: { mode: 'sync'; } & Record<string, unknown>; } & Record<string, unknown>): PopulateProxy<ModelSyncPageResult<TDocument>>;
|
|
485
|
+
findPage(options?: unknown): PopulateProxy<ModelPageResult<TDocument>>;
|
|
482
486
|
/**
|
|
483
487
|
* Finds documents and returns the unpaginated total count.
|
|
484
488
|
* @param query Optional filter.
|
|
@@ -24,6 +24,10 @@ export interface SSHConfig {
|
|
|
24
24
|
readyTimeout?: number;
|
|
25
25
|
/** Keep-alive interval in milliseconds (default: 30000). */
|
|
26
26
|
keepaliveInterval?: number;
|
|
27
|
+
/** ssh2 host-key hash algorithm; pair with hostVerifier for pinned fingerprints. */
|
|
28
|
+
hostHash?: string;
|
|
29
|
+
/** Reject untrusted SSH server host keys by returning false. */
|
|
30
|
+
hostVerifier?: (key: string | Buffer) => boolean;
|
|
27
31
|
/** Target database host as seen from the SSH server (default: auto-parsed from URI). */
|
|
28
32
|
dstHost?: string;
|
|
29
33
|
/** Target database port as seen from the SSH server (default: auto-parsed from URI). */
|
|
@@ -210,9 +214,9 @@ export interface MonSQLizeOptions {
|
|
|
210
214
|
maxRetries?: number;
|
|
211
215
|
retryDelay?: number;
|
|
212
216
|
retryBackoff?: number;
|
|
213
|
-
/** Default transaction
|
|
217
|
+
/** Default transaction work deadline before commit, in milliseconds. Alias: `maxDuration`. */
|
|
214
218
|
defaultTimeout?: number;
|
|
215
|
-
/** Default transaction
|
|
219
|
+
/** Default transaction work deadline before commit, in milliseconds. Alias: `defaultTimeout`. */
|
|
216
220
|
maxDuration?: number;
|
|
217
221
|
defaultReadConcern?: TransactionOptions['readConcern'];
|
|
218
222
|
defaultWriteConcern?: TransactionOptions['writeConcern'];
|
|
@@ -257,6 +261,8 @@ export interface MonSQLizeOptions {
|
|
|
257
261
|
cursorTypes?: Record<string, CursorValueType>;
|
|
258
262
|
/** Global cursor value normalizer used when findPage decodes after/before tokens. @since v3.0.0 */
|
|
259
263
|
cursorValueNormalizer?: CursorValueNormalizer;
|
|
264
|
+
/** Stable strategy identity and version, e.g. 'string-id:v1'; bump when conversion changes. */
|
|
265
|
+
cursorValueNormalizerVersion?: string;
|
|
260
266
|
/** Logging tag configuration applied to slow-query event payloads. @since v1.3.0 */
|
|
261
267
|
log?: { slowQueryTag?: { event?: string; code?: string;[key: string]: unknown }; formatSlowQuery?: (meta: unknown) => unknown; };
|
|
262
268
|
/** Auto-convert valid 24-character hex strings to ObjectId across query/write paths. Pass `false` to disable, or use `excludeFields`, `maxDepth`, or `{ field: false }` escape hatches. Default: true for mongodb type. @since v1.3.0 */
|
|
@@ -24,6 +24,10 @@ export interface SSHConfig {
|
|
|
24
24
|
readyTimeout?: number;
|
|
25
25
|
/** Keep-alive interval in milliseconds (default: 30000). */
|
|
26
26
|
keepaliveInterval?: number;
|
|
27
|
+
/** ssh2 host-key hash algorithm; pair with hostVerifier for pinned fingerprints. */
|
|
28
|
+
hostHash?: string;
|
|
29
|
+
/** Reject untrusted SSH server host keys by returning false. */
|
|
30
|
+
hostVerifier?: (key: string | Buffer) => boolean;
|
|
27
31
|
/** Target database host as seen from the SSH server (default: auto-parsed from URI). */
|
|
28
32
|
dstHost?: string;
|
|
29
33
|
/** Target database port as seen from the SSH server (default: auto-parsed from URI). */
|
|
@@ -210,9 +214,9 @@ export interface MonSQLizeOptions {
|
|
|
210
214
|
maxRetries?: number;
|
|
211
215
|
retryDelay?: number;
|
|
212
216
|
retryBackoff?: number;
|
|
213
|
-
/** Default transaction
|
|
217
|
+
/** Default transaction work deadline before commit, in milliseconds. Alias: `maxDuration`. */
|
|
214
218
|
defaultTimeout?: number;
|
|
215
|
-
/** Default transaction
|
|
219
|
+
/** Default transaction work deadline before commit, in milliseconds. Alias: `defaultTimeout`. */
|
|
216
220
|
maxDuration?: number;
|
|
217
221
|
defaultReadConcern?: TransactionOptions['readConcern'];
|
|
218
222
|
defaultWriteConcern?: TransactionOptions['writeConcern'];
|
|
@@ -257,6 +261,8 @@ export interface MonSQLizeOptions {
|
|
|
257
261
|
cursorTypes?: Record<string, CursorValueType>;
|
|
258
262
|
/** Global cursor value normalizer used when findPage decodes after/before tokens. @since v3.0.0 */
|
|
259
263
|
cursorValueNormalizer?: CursorValueNormalizer;
|
|
264
|
+
/** Stable strategy identity and version, e.g. 'string-id:v1'; bump when conversion changes. */
|
|
265
|
+
cursorValueNormalizerVersion?: string;
|
|
260
266
|
/** Logging tag configuration applied to slow-query event payloads. @since v1.3.0 */
|
|
261
267
|
log?: { slowQueryTag?: { event?: string; code?: string;[key: string]: unknown }; formatSlowQuery?: (meta: unknown) => unknown; };
|
|
262
268
|
/** Auto-convert valid 24-character hex strings to ObjectId across query/write paths. Pass `false` to disable, or use `excludeFields`, `maxDepth`, or `{ field: false }` escape hatches. Default: true for mongodb type. @since v1.3.0 */
|
package/dist/types/pool.d.mts
CHANGED
|
@@ -16,7 +16,9 @@ export interface PoolConfig {
|
|
|
16
16
|
healthCheck?: {
|
|
17
17
|
enabled?: boolean;
|
|
18
18
|
interval?: number;
|
|
19
|
+
/** Logical deadline; a timed-out underlying ping still occupies its in-flight slot. */
|
|
19
20
|
timeout?: number;
|
|
21
|
+
/** Completed failures required before the pool is marked down. */
|
|
20
22
|
retries?: number;
|
|
21
23
|
};
|
|
22
24
|
}
|
|
@@ -79,6 +81,7 @@ export declare class ConnectionPoolManager {
|
|
|
79
81
|
getPoolHealth(): Map<string, PoolHealthStatus>;
|
|
80
82
|
getHealthStatus(): Record<string, PoolHealthStatus>;
|
|
81
83
|
getPoolStats(): Record<string, PoolStats>;
|
|
84
|
+
/** Attempt all closes; retain failed clients for retry. Concurrent calls share the in-flight close. */
|
|
82
85
|
close(): Promise<void>;
|
|
83
86
|
}
|
|
84
87
|
|
package/dist/types/pool.d.ts
CHANGED
|
@@ -16,7 +16,9 @@ export interface PoolConfig {
|
|
|
16
16
|
healthCheck?: {
|
|
17
17
|
enabled?: boolean;
|
|
18
18
|
interval?: number;
|
|
19
|
+
/** Logical deadline; a timed-out underlying ping still occupies its in-flight slot. */
|
|
19
20
|
timeout?: number;
|
|
21
|
+
/** Completed failures required before the pool is marked down. */
|
|
20
22
|
retries?: number;
|
|
21
23
|
};
|
|
22
24
|
}
|
|
@@ -79,6 +81,7 @@ export declare class ConnectionPoolManager {
|
|
|
79
81
|
getPoolHealth(): Map<string, PoolHealthStatus>;
|
|
80
82
|
getHealthStatus(): Record<string, PoolHealthStatus>;
|
|
81
83
|
getPoolStats(): Record<string, PoolStats>;
|
|
84
|
+
/** Attempt all closes; retain failed clients for retry. Concurrent calls share the in-flight close. */
|
|
82
85
|
close(): Promise<void>;
|
|
83
86
|
}
|
|
84
87
|
|
package/dist/types/runtime.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BookmarkClearResult, BookmarkListResult, BookmarkPrewarmResult, DeleteBatchResult, DeleteResult, IncrementOneResult, IndexCreateResult, InsertBatchResult, InsertManyResult, UpdateBatchResult, UpdateResult } from './collection.mjs';
|
|
2
|
-
import type { LoggerLike, ExpressionFunction, ExpressionObject } from './base.mjs';
|
|
2
|
+
import type { LoggerLike, LoggerOptions, ExpressionFunction, ExpressionObject } from './base.mjs';
|
|
3
3
|
import type { ModelDefinition, ModelDescriptor, ModelEnsureIndexesOptions, ModelIndexEnsureResult, ModelInstance as ModelInstanceContract, RegisteredModel, RelationConfig } from './model.mjs';
|
|
4
4
|
import type { LockOptions, LockStats } from './lock.mjs';
|
|
5
5
|
import type { ConnectionPoolManagerOptions, FallbackStrategy, PoolConfig, PoolHealthStatus, PoolRole, PoolStats, PoolStrategy } from './pool.mjs';
|
|
@@ -39,12 +39,18 @@ export { ChangeStreamSyncManager, ResumeTokenStore } from './sync.mjs';
|
|
|
39
39
|
export { CacheLockManager, Transaction, TransactionManager } from './transaction.mjs';
|
|
40
40
|
|
|
41
41
|
export declare class Logger {
|
|
42
|
-
constructor(logger?: LoggerLike | null);
|
|
42
|
+
constructor(logger?: LoggerLike | null, options?: LoggerOptions);
|
|
43
43
|
debug(...args: unknown[]): void;
|
|
44
44
|
info(...args: unknown[]): void;
|
|
45
45
|
warn(...args: unknown[]): void;
|
|
46
46
|
error(...args: unknown[]): void;
|
|
47
|
-
static create(logger?: LoggerLike | null): Logger;
|
|
47
|
+
static create(logger?: LoggerLike | null, options?: LoggerOptions): Logger;
|
|
48
|
+
static createSilent(): Pick<Logger, 'debug' | 'info' | 'warn' | 'error'>;
|
|
49
|
+
static generateTraceId(): string;
|
|
50
|
+
static isValidLogger(logger: unknown): boolean;
|
|
51
|
+
static withTraceId: ((fn: () => void | Promise<void>, traceId?: string) => void | Promise<void>) | undefined;
|
|
52
|
+
static getTraceId: (() => string | null) | undefined;
|
|
53
|
+
static createWithTimestamp(customLogger?: LoggerLike | null): Pick<Logger, 'debug' | 'info' | 'warn' | 'error'>;
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
export type CacheLockLike = HubCacheLockLike;
|
|
@@ -315,26 +321,8 @@ export declare class ModelInstance<TDocument = any> implements ModelInstanceCont
|
|
|
315
321
|
findOneById(id: unknown, options?: unknown): import('./model.mjs').PopulateProxy<import('./model.mjs').ModelDocument<TDocument> | null>;
|
|
316
322
|
findById(id: unknown, options?: unknown): import('./model.mjs').PopulateProxy<import('./model.mjs').ModelDocument<TDocument> | null>;
|
|
317
323
|
findByIds(ids: unknown[], options?: unknown): import('./model.mjs').PopulateProxy<Array<import('./model.mjs').ModelDocument<TDocument>>>;
|
|
318
|
-
findPage(options: { totals: { mode: 'sync'; } & Record<string, unknown>; } & Record<string, unknown>): import('./model.mjs').PopulateProxy<
|
|
319
|
-
|
|
320
|
-
pageInfo: import('./model.mjs').ModelInstance<TDocument> extends {
|
|
321
|
-
findPage(options?: unknown): import('./model.mjs').PopulateProxy<infer TResult>;
|
|
322
|
-
} ? TResult extends { pageInfo: infer TPageInfo } ? TPageInfo : never : never;
|
|
323
|
-
totals: import('./model.mjs').ModelInstance<TDocument> extends {
|
|
324
|
-
findPage(options: { totals: { mode: 'sync'; } & Record<string, unknown>; } & Record<string, unknown>): import('./model.mjs').PopulateProxy<infer TResult>;
|
|
325
|
-
} ? TResult extends { totals: infer TTotals } ? TTotals : never : never;
|
|
326
|
-
meta?: import('./collection.mjs').MetaInfo;
|
|
327
|
-
}>;
|
|
328
|
-
findPage(options?: unknown): import('./model.mjs').PopulateProxy<{
|
|
329
|
-
items: Array<import('./model.mjs').ModelDocument<TDocument>>;
|
|
330
|
-
pageInfo: import('./model.mjs').ModelInstance<TDocument> extends {
|
|
331
|
-
findPage(options?: unknown): import('./model.mjs').PopulateProxy<infer TResult>;
|
|
332
|
-
} ? TResult extends { pageInfo: infer TPageInfo } ? TPageInfo : never : never;
|
|
333
|
-
totals?: import('./model.mjs').ModelInstance<TDocument> extends {
|
|
334
|
-
findPage(options?: unknown): import('./model.mjs').PopulateProxy<infer TResult>;
|
|
335
|
-
} ? TResult extends { totals?: infer TTotals } ? TTotals : never : never;
|
|
336
|
-
meta?: import('./collection.mjs').MetaInfo;
|
|
337
|
-
}>;
|
|
324
|
+
findPage(options: { totals: { mode: 'sync'; } & Record<string, unknown>; } & Record<string, unknown>): import('./model.mjs').PopulateProxy<import('./model.mjs').ModelSyncPageResult<TDocument>>;
|
|
325
|
+
findPage(options?: unknown): import('./model.mjs').PopulateProxy<import('./model.mjs').ModelPageResult<TDocument>>;
|
|
338
326
|
findAndCount(query?: unknown, options?: unknown): import('./model.mjs').PopulateProxy<{ data: Array<import('./model.mjs').ModelDocument<TDocument>>; total: number; }>;
|
|
339
327
|
vectorSearch(options: import('./model.mjs').ModelVectorSearchOptions): Promise<Array<import('./collection.mjs').VectorSearchHit<import('./model.mjs').ModelDocument<TDocument>>>>;
|
|
340
328
|
count(query?: unknown, options?: unknown): Promise<number>;
|
package/dist/types/runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BookmarkClearResult, BookmarkListResult, BookmarkPrewarmResult, DeleteBatchResult, DeleteResult, IncrementOneResult, IndexCreateResult, InsertBatchResult, InsertManyResult, UpdateBatchResult, UpdateResult } from './collection';
|
|
2
|
-
import type { LoggerLike, ExpressionFunction, ExpressionObject } from './base';
|
|
2
|
+
import type { LoggerLike, LoggerOptions, ExpressionFunction, ExpressionObject } from './base';
|
|
3
3
|
import type { ModelDefinition, ModelDescriptor, ModelEnsureIndexesOptions, ModelIndexEnsureResult, ModelInstance as ModelInstanceContract, RegisteredModel, RelationConfig } from './model';
|
|
4
4
|
import type { LockOptions, LockStats } from './lock';
|
|
5
5
|
import type { ConnectionPoolManagerOptions, FallbackStrategy, PoolConfig, PoolHealthStatus, PoolRole, PoolStats, PoolStrategy } from './pool';
|
|
@@ -39,12 +39,18 @@ export { ChangeStreamSyncManager, ResumeTokenStore } from './sync';
|
|
|
39
39
|
export { CacheLockManager, Transaction, TransactionManager } from './transaction';
|
|
40
40
|
|
|
41
41
|
export declare class Logger {
|
|
42
|
-
constructor(logger?: LoggerLike | null);
|
|
42
|
+
constructor(logger?: LoggerLike | null, options?: LoggerOptions);
|
|
43
43
|
debug(...args: unknown[]): void;
|
|
44
44
|
info(...args: unknown[]): void;
|
|
45
45
|
warn(...args: unknown[]): void;
|
|
46
46
|
error(...args: unknown[]): void;
|
|
47
|
-
static create(logger?: LoggerLike | null): Logger;
|
|
47
|
+
static create(logger?: LoggerLike | null, options?: LoggerOptions): Logger;
|
|
48
|
+
static createSilent(): Pick<Logger, 'debug' | 'info' | 'warn' | 'error'>;
|
|
49
|
+
static generateTraceId(): string;
|
|
50
|
+
static isValidLogger(logger: unknown): boolean;
|
|
51
|
+
static withTraceId: ((fn: () => void | Promise<void>, traceId?: string) => void | Promise<void>) | undefined;
|
|
52
|
+
static getTraceId: (() => string | null) | undefined;
|
|
53
|
+
static createWithTimestamp(customLogger?: LoggerLike | null): Pick<Logger, 'debug' | 'info' | 'warn' | 'error'>;
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
export type CacheLockLike = HubCacheLockLike;
|
|
@@ -315,26 +321,8 @@ export declare class ModelInstance<TDocument = any> implements ModelInstanceCont
|
|
|
315
321
|
findOneById(id: unknown, options?: unknown): import('./model').PopulateProxy<import('./model').ModelDocument<TDocument> | null>;
|
|
316
322
|
findById(id: unknown, options?: unknown): import('./model').PopulateProxy<import('./model').ModelDocument<TDocument> | null>;
|
|
317
323
|
findByIds(ids: unknown[], options?: unknown): import('./model').PopulateProxy<Array<import('./model').ModelDocument<TDocument>>>;
|
|
318
|
-
findPage(options: { totals: { mode: 'sync'; } & Record<string, unknown>; } & Record<string, unknown>): import('./model').PopulateProxy<
|
|
319
|
-
|
|
320
|
-
pageInfo: import('./model').ModelInstance<TDocument> extends {
|
|
321
|
-
findPage(options?: unknown): import('./model').PopulateProxy<infer TResult>;
|
|
322
|
-
} ? TResult extends { pageInfo: infer TPageInfo } ? TPageInfo : never : never;
|
|
323
|
-
totals: import('./model').ModelInstance<TDocument> extends {
|
|
324
|
-
findPage(options: { totals: { mode: 'sync'; } & Record<string, unknown>; } & Record<string, unknown>): import('./model').PopulateProxy<infer TResult>;
|
|
325
|
-
} ? TResult extends { totals: infer TTotals } ? TTotals : never : never;
|
|
326
|
-
meta?: import('./collection').MetaInfo;
|
|
327
|
-
}>;
|
|
328
|
-
findPage(options?: unknown): import('./model').PopulateProxy<{
|
|
329
|
-
items: Array<import('./model').ModelDocument<TDocument>>;
|
|
330
|
-
pageInfo: import('./model').ModelInstance<TDocument> extends {
|
|
331
|
-
findPage(options?: unknown): import('./model').PopulateProxy<infer TResult>;
|
|
332
|
-
} ? TResult extends { pageInfo: infer TPageInfo } ? TPageInfo : never : never;
|
|
333
|
-
totals?: import('./model').ModelInstance<TDocument> extends {
|
|
334
|
-
findPage(options?: unknown): import('./model').PopulateProxy<infer TResult>;
|
|
335
|
-
} ? TResult extends { totals?: infer TTotals } ? TTotals : never : never;
|
|
336
|
-
meta?: import('./collection').MetaInfo;
|
|
337
|
-
}>;
|
|
324
|
+
findPage(options: { totals: { mode: 'sync'; } & Record<string, unknown>; } & Record<string, unknown>): import('./model').PopulateProxy<import('./model').ModelSyncPageResult<TDocument>>;
|
|
325
|
+
findPage(options?: unknown): import('./model').PopulateProxy<import('./model').ModelPageResult<TDocument>>;
|
|
338
326
|
findAndCount(query?: unknown, options?: unknown): import('./model').PopulateProxy<{ data: Array<import('./model').ModelDocument<TDocument>>; total: number; }>;
|
|
339
327
|
vectorSearch(options: import('./model').ModelVectorSearchOptions): Promise<Array<import('./collection').VectorSearchHit<import('./model').ModelDocument<TDocument>>>>;
|
|
340
328
|
count(query?: unknown, options?: unknown): Promise<number>;
|
|
@@ -66,12 +66,20 @@ export interface SlowQueryLogConfig {
|
|
|
66
66
|
minExecutionTimeMs: number;
|
|
67
67
|
};
|
|
68
68
|
advanced: {
|
|
69
|
+
/** Includes initialization failures; throw waits for direct storage even when batching is enabled. */
|
|
69
70
|
errorHandling: 'log' | 'throw' | 'silent';
|
|
71
|
+
/** False skips both TTL and unique-index creation without removing existing indexes. */
|
|
70
72
|
autoCreateIndexes: boolean;
|
|
71
73
|
};
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
export type SlowQueryLogConfigInput = boolean |
|
|
76
|
+
export type SlowQueryLogConfigInput = boolean | (
|
|
77
|
+
Omit<Partial<SlowQueryLogConfig>, 'batch' | 'filter' | 'advanced'> & {
|
|
78
|
+
batch?: Partial<SlowQueryLogConfig['batch']>;
|
|
79
|
+
filter?: Partial<SlowQueryLogConfig['filter']>;
|
|
80
|
+
advanced?: Partial<SlowQueryLogConfig['advanced']>;
|
|
81
|
+
}
|
|
82
|
+
);
|
|
75
83
|
|
|
76
84
|
export interface SlowQueryLogStorage {
|
|
77
85
|
initialize(): Promise<void>;
|
|
@@ -66,12 +66,20 @@ export interface SlowQueryLogConfig {
|
|
|
66
66
|
minExecutionTimeMs: number;
|
|
67
67
|
};
|
|
68
68
|
advanced: {
|
|
69
|
+
/** Includes initialization failures; throw waits for direct storage even when batching is enabled. */
|
|
69
70
|
errorHandling: 'log' | 'throw' | 'silent';
|
|
71
|
+
/** False skips both TTL and unique-index creation without removing existing indexes. */
|
|
70
72
|
autoCreateIndexes: boolean;
|
|
71
73
|
};
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
export type SlowQueryLogConfigInput = boolean |
|
|
76
|
+
export type SlowQueryLogConfigInput = boolean | (
|
|
77
|
+
Omit<Partial<SlowQueryLogConfig>, 'batch' | 'filter' | 'advanced'> & {
|
|
78
|
+
batch?: Partial<SlowQueryLogConfig['batch']>;
|
|
79
|
+
filter?: Partial<SlowQueryLogConfig['filter']>;
|
|
80
|
+
advanced?: Partial<SlowQueryLogConfig['advanced']>;
|
|
81
|
+
}
|
|
82
|
+
);
|
|
75
83
|
|
|
76
84
|
export interface SlowQueryLogStorage {
|
|
77
85
|
initialize(): Promise<void>;
|
package/dist/types/sync.d.mts
CHANGED
|
@@ -39,6 +39,7 @@ export interface SyncTargetConfig {
|
|
|
39
39
|
|
|
40
40
|
export interface SyncTargetApplyContext {
|
|
41
41
|
targetName: string;
|
|
42
|
+
/** Versioned JSON tuple ["v2", keyPrefix, targetName, rawKey]; treat as opaque. */
|
|
42
43
|
idempotencyKey?: string;
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -55,13 +56,13 @@ export interface SyncIdempotencyConfig {
|
|
|
55
56
|
enabled?: boolean;
|
|
56
57
|
/** Optional durable store; when omitted, an in-memory store is used. */
|
|
57
58
|
store?: SyncIdempotencyStoreLike;
|
|
58
|
-
/**
|
|
59
|
+
/** Logical prefix inside the versioned tuple. Defaults to monsqlize:sync:idempotency. */
|
|
59
60
|
keyPrefix?: string;
|
|
60
61
|
/** Marker TTL in milliseconds. Store implementations may ignore it. */
|
|
61
62
|
ttl?: number;
|
|
62
63
|
/** Mark after target success by default; start mode requires target-owned recovery for post-mark failures. */
|
|
63
64
|
markMode?: SyncIdempotencyMarkMode;
|
|
64
|
-
/**
|
|
65
|
+
/** Builds the raw event key; null/undefined/empty disables it. Inputs and raw return values are unchanged. */
|
|
65
66
|
keyBuilder?: (event: SyncChangeEvent, targetName: string) => string | null | undefined;
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -71,6 +72,7 @@ export interface ResumeTokenRedisLike {
|
|
|
71
72
|
del?(key: string): Promise<unknown> | unknown;
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
/** Stores opaque raw event tokens or a versioned initial EJSON operation-time checkpoint. */
|
|
74
76
|
export interface ResumeTokenConfig {
|
|
75
77
|
storage?: 'file' | 'redis';
|
|
76
78
|
path?: string;
|
package/dist/types/sync.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export interface SyncTargetConfig {
|
|
|
39
39
|
|
|
40
40
|
export interface SyncTargetApplyContext {
|
|
41
41
|
targetName: string;
|
|
42
|
+
/** Versioned JSON tuple ["v2", keyPrefix, targetName, rawKey]; treat as opaque. */
|
|
42
43
|
idempotencyKey?: string;
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -55,13 +56,13 @@ export interface SyncIdempotencyConfig {
|
|
|
55
56
|
enabled?: boolean;
|
|
56
57
|
/** Optional durable store; when omitted, an in-memory store is used. */
|
|
57
58
|
store?: SyncIdempotencyStoreLike;
|
|
58
|
-
/**
|
|
59
|
+
/** Logical prefix inside the versioned tuple. Defaults to monsqlize:sync:idempotency. */
|
|
59
60
|
keyPrefix?: string;
|
|
60
61
|
/** Marker TTL in milliseconds. Store implementations may ignore it. */
|
|
61
62
|
ttl?: number;
|
|
62
63
|
/** Mark after target success by default; start mode requires target-owned recovery for post-mark failures. */
|
|
63
64
|
markMode?: SyncIdempotencyMarkMode;
|
|
64
|
-
/**
|
|
65
|
+
/** Builds the raw event key; null/undefined/empty disables it. Inputs and raw return values are unchanged. */
|
|
65
66
|
keyBuilder?: (event: SyncChangeEvent, targetName: string) => string | null | undefined;
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -71,6 +72,7 @@ export interface ResumeTokenRedisLike {
|
|
|
71
72
|
del?(key: string): Promise<unknown> | unknown;
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
/** Stores opaque raw event tokens or a versioned initial EJSON operation-time checkpoint. */
|
|
74
76
|
export interface ResumeTokenConfig {
|
|
75
77
|
storage?: 'file' | 'redis';
|
|
76
78
|
path?: string;
|