monsqlize 3.3.1 → 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.
@@ -25,7 +25,7 @@ export interface LoggerLike {
25
25
  export interface LoggerOptions {
26
26
  /** Enable structured (JSON) log output. */
27
27
  structured?: boolean;
28
- /** Enable automatic trace ID injection into log entries. */
28
+ /** Attach the current trace ID to structured logs by default; false disables injection. */
29
29
  enableTraceId?: boolean;
30
30
  }
31
31
 
@@ -25,7 +25,7 @@ export interface LoggerLike {
25
25
  export interface LoggerOptions {
26
26
  /** Enable structured (JSON) log output. */
27
27
  structured?: boolean;
28
- /** Enable automatic trace ID injection into log entries. */
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;
@@ -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<TSchema[]>;
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<TResult[]>;
380
+ toArray(): Promise<TPromise>;
381
381
  }
382
382
 
383
383
  /** Write concern options for batch operations. */
@@ -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;
@@ -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<TSchema[]>;
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<TResult[]>;
380
+ toArray(): Promise<TPromise>;
381
381
  }
382
382
 
383
383
  /** Write concern options for batch operations. */
@@ -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, ModelInstance } from './model.mjs';
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';
@@ -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, ModelInstance } from './model';
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';
@@ -408,6 +408,17 @@ type LegacyModelSyncTotalsInfo<TDocument = any> = unknown extends TDocument ? an
408
408
  });
409
409
  export type RestoreResult = Pick<UpdateResult, 'modifiedCount'> & Partial<UpdateResult>;
410
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
+
411
422
  export type ModelDocument<TDocument = any> = TDocument & Record<string, unknown> & {
412
423
  save(): Promise<ModelDocument<TDocument>>;
413
424
  remove(): Promise<boolean>;
@@ -470,18 +481,8 @@ export interface ModelInstance<TDocument = any> {
470
481
  * @param options Pagination options including `limit`, `cursor`/`page`, `filter`, and `sort`.
471
482
  * @returns Result object containing items, page information, and optional totals.
472
483
  */
473
- findPage(options: { totals: { mode: 'sync'; } & Record<string, unknown>; } & Record<string, unknown>): PopulateProxy<{
474
- items: Array<ModelDocument<TDocument>>;
475
- pageInfo: LegacyModelPageInfo<TDocument>;
476
- totals: LegacyModelSyncTotalsInfo<TDocument>;
477
- meta?: import('./collection.mjs').MetaInfo;
478
- }>;
479
- findPage(options?: unknown): PopulateProxy<{
480
- items: Array<ModelDocument<TDocument>>;
481
- pageInfo: LegacyModelPageInfo<TDocument>;
482
- totals?: LegacyModelTotalsInfo<TDocument>;
483
- meta?: import('./collection.mjs').MetaInfo;
484
- }>;
484
+ findPage(options: { totals: { mode: 'sync'; } & Record<string, unknown>; } & Record<string, unknown>): PopulateProxy<ModelSyncPageResult<TDocument>>;
485
+ findPage(options?: unknown): PopulateProxy<ModelPageResult<TDocument>>;
485
486
  /**
486
487
  * Finds documents and returns the unpaginated total count.
487
488
  * @param query Optional filter.
@@ -408,6 +408,17 @@ type LegacyModelSyncTotalsInfo<TDocument = any> = unknown extends TDocument ? an
408
408
  });
409
409
  export type RestoreResult = Pick<UpdateResult, 'modifiedCount'> & Partial<UpdateResult>;
410
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
+
411
422
  export type ModelDocument<TDocument = any> = TDocument & Record<string, unknown> & {
412
423
  save(): Promise<ModelDocument<TDocument>>;
413
424
  remove(): Promise<boolean>;
@@ -470,18 +481,8 @@ export interface ModelInstance<TDocument = any> {
470
481
  * @param options Pagination options including `limit`, `cursor`/`page`, `filter`, and `sort`.
471
482
  * @returns Result object containing items, page information, and optional totals.
472
483
  */
473
- findPage(options: { totals: { mode: 'sync'; } & Record<string, unknown>; } & Record<string, unknown>): PopulateProxy<{
474
- items: Array<ModelDocument<TDocument>>;
475
- pageInfo: LegacyModelPageInfo<TDocument>;
476
- totals: LegacyModelSyncTotalsInfo<TDocument>;
477
- meta?: import('./collection').MetaInfo;
478
- }>;
479
- findPage(options?: unknown): PopulateProxy<{
480
- items: Array<ModelDocument<TDocument>>;
481
- pageInfo: LegacyModelPageInfo<TDocument>;
482
- totals?: LegacyModelTotalsInfo<TDocument>;
483
- meta?: import('./collection').MetaInfo;
484
- }>;
484
+ findPage(options: { totals: { mode: 'sync'; } & Record<string, unknown>; } & Record<string, unknown>): PopulateProxy<ModelSyncPageResult<TDocument>>;
485
+ findPage(options?: unknown): PopulateProxy<ModelPageResult<TDocument>>;
485
486
  /**
486
487
  * Finds documents and returns the unpaginated total count.
487
488
  * @param query Optional filter.
@@ -214,9 +214,9 @@ export interface MonSQLizeOptions {
214
214
  maxRetries?: number;
215
215
  retryDelay?: number;
216
216
  retryBackoff?: number;
217
- /** Default transaction timeout in milliseconds. Alias: `maxDuration`. */
217
+ /** Default transaction work deadline before commit, in milliseconds. Alias: `maxDuration`. */
218
218
  defaultTimeout?: number;
219
- /** Default transaction timeout in milliseconds. Alias: `defaultTimeout`. */
219
+ /** Default transaction work deadline before commit, in milliseconds. Alias: `defaultTimeout`. */
220
220
  maxDuration?: number;
221
221
  defaultReadConcern?: TransactionOptions['readConcern'];
222
222
  defaultWriteConcern?: TransactionOptions['writeConcern'];
@@ -261,6 +261,8 @@ export interface MonSQLizeOptions {
261
261
  cursorTypes?: Record<string, CursorValueType>;
262
262
  /** Global cursor value normalizer used when findPage decodes after/before tokens. @since v3.0.0 */
263
263
  cursorValueNormalizer?: CursorValueNormalizer;
264
+ /** Stable strategy identity and version, e.g. 'string-id:v1'; bump when conversion changes. */
265
+ cursorValueNormalizerVersion?: string;
264
266
  /** Logging tag configuration applied to slow-query event payloads. @since v1.3.0 */
265
267
  log?: { slowQueryTag?: { event?: string; code?: string;[key: string]: unknown }; formatSlowQuery?: (meta: unknown) => unknown; };
266
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 */
@@ -214,9 +214,9 @@ export interface MonSQLizeOptions {
214
214
  maxRetries?: number;
215
215
  retryDelay?: number;
216
216
  retryBackoff?: number;
217
- /** Default transaction timeout in milliseconds. Alias: `maxDuration`. */
217
+ /** Default transaction work deadline before commit, in milliseconds. Alias: `maxDuration`. */
218
218
  defaultTimeout?: number;
219
- /** Default transaction timeout in milliseconds. Alias: `defaultTimeout`. */
219
+ /** Default transaction work deadline before commit, in milliseconds. Alias: `defaultTimeout`. */
220
220
  maxDuration?: number;
221
221
  defaultReadConcern?: TransactionOptions['readConcern'];
222
222
  defaultWriteConcern?: TransactionOptions['writeConcern'];
@@ -261,6 +261,8 @@ export interface MonSQLizeOptions {
261
261
  cursorTypes?: Record<string, CursorValueType>;
262
262
  /** Global cursor value normalizer used when findPage decodes after/before tokens. @since v3.0.0 */
263
263
  cursorValueNormalizer?: CursorValueNormalizer;
264
+ /** Stable strategy identity and version, e.g. 'string-id:v1'; bump when conversion changes. */
265
+ cursorValueNormalizerVersion?: string;
264
266
  /** Logging tag configuration applied to slow-query event payloads. @since v1.3.0 */
265
267
  log?: { slowQueryTag?: { event?: string; code?: string;[key: string]: unknown }; formatSlowQuery?: (meta: unknown) => unknown; };
266
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 */
@@ -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
 
@@ -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
 
@@ -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
- items: Array<import('./model.mjs').ModelDocument<TDocument>>;
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>;
@@ -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
- items: Array<import('./model').ModelDocument<TDocument>>;
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 | Partial<SlowQueryLogConfig>;
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 | Partial<SlowQueryLogConfig>;
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>;
@@ -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
- /** Cache/store key prefix. Defaults to monsqlize:sync:idempotency. */
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
- /** Custom event key builder. Return null/undefined to disable idempotency for that event. */
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;
@@ -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
- /** Cache/store key prefix. Defaults to monsqlize:sync:idempotency. */
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
- /** Custom event key builder. Return null/undefined to disable idempotency for that event. */
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;
@@ -24,9 +24,9 @@ export interface TransactionOptions {
24
24
  };
25
25
  readPreference?: 'primary' | 'primaryPreferred' | 'secondary' | 'secondaryPreferred' | 'nearest';
26
26
  causalConsistency?: boolean;
27
- /** Maximum transaction duration in milliseconds before an automatic abort. */
27
+ /** Maximum transaction work duration in milliseconds before commit begins. */
28
28
  maxDuration?: number;
29
- /** @alias maxDuration — v1 compat field */
29
+ /** Deadline for transaction work before commit begins. Alias: `maxDuration`. */
30
30
  timeout?: number;
31
31
  enableRetry?: boolean;
32
32
  maxRetries?: number;
@@ -90,16 +90,18 @@ export declare class Transaction {
90
90
  cache?: CacheLike | null;
91
91
  logger?: LoggerLike | null;
92
92
  lockManager?: CacheLockManager | null;
93
+ /** Work deadline in milliseconds; the timer stops before commit is dispatched. */
93
94
  timeout?: number;
95
+ /** MongoDB transaction options, including driver commit limits such as `maxCommitTimeMS`. */
94
96
  transactionOptions?: Record<string, unknown>;
95
97
  });
96
98
  /** Begin the transaction (starts the MongoDB session transaction). */
97
99
  start(): Promise<void>;
98
- /** Commit the transaction; replays recorded cache invalidations on success. */
100
+ /** Commit the transaction; flushes cache invalidations on success or an unknown commit result. */
99
101
  commit(): Promise<void>;
100
102
  /** Abort the transaction and discard pending cache invalidations. */
101
103
  abort(): Promise<void>;
102
- /** Alias for `commit()` — v1 compat shorthand. */
104
+ /** End the session after pending lifecycle work; aborts an active transaction with a known outcome. */
103
105
  end(): Promise<void>;
104
106
  /** Record a cache-invalidation pattern to be replayed on commit. */
105
107
  recordInvalidation(pattern: string): Promise<void>;
@@ -24,9 +24,9 @@ export interface TransactionOptions {
24
24
  };
25
25
  readPreference?: 'primary' | 'primaryPreferred' | 'secondary' | 'secondaryPreferred' | 'nearest';
26
26
  causalConsistency?: boolean;
27
- /** Maximum transaction duration in milliseconds before an automatic abort. */
27
+ /** Maximum transaction work duration in milliseconds before commit begins. */
28
28
  maxDuration?: number;
29
- /** @alias maxDuration — v1 compat field */
29
+ /** Deadline for transaction work before commit begins. Alias: `maxDuration`. */
30
30
  timeout?: number;
31
31
  enableRetry?: boolean;
32
32
  maxRetries?: number;
@@ -90,16 +90,18 @@ export declare class Transaction {
90
90
  cache?: CacheLike | null;
91
91
  logger?: LoggerLike | null;
92
92
  lockManager?: CacheLockManager | null;
93
+ /** Work deadline in milliseconds; the timer stops before commit is dispatched. */
93
94
  timeout?: number;
95
+ /** MongoDB transaction options, including driver commit limits such as `maxCommitTimeMS`. */
94
96
  transactionOptions?: Record<string, unknown>;
95
97
  });
96
98
  /** Begin the transaction (starts the MongoDB session transaction). */
97
99
  start(): Promise<void>;
98
- /** Commit the transaction; replays recorded cache invalidations on success. */
100
+ /** Commit the transaction; flushes cache invalidations on success or an unknown commit result. */
99
101
  commit(): Promise<void>;
100
102
  /** Abort the transaction and discard pending cache invalidations. */
101
103
  abort(): Promise<void>;
102
- /** Alias for `commit()` — v1 compat shorthand. */
104
+ /** End the session after pending lifecycle work; aborts an active transaction with a known outcome. */
103
105
  end(): Promise<void>;
104
106
  /** Record a cache-invalidation pattern to be replayed on commit. */
105
107
  recordInvalidation(pattern: string): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monsqlize",
3
- "version": "3.3.1",
3
+ "version": "3.3.2",
4
4
  "description": "TypeScript production data runtime layer for MongoDB today, with cache, transactions, pools, models, sync, and observability",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/cjs/index.cjs",
@@ -21,6 +21,7 @@
21
21
  "./package.json": "./package.json"
22
22
  },
23
23
  "files": [
24
+ "changelogs/v3.3.2.md",
24
25
  "changelogs/v3.3.1.md",
25
26
  "changelogs/v3.3.0.md",
26
27
  "changelogs/v3.2.0.md",
@@ -112,8 +113,8 @@
112
113
  "check:sizes:strict": "node scripts/check-file-sizes.cjs --strict",
113
114
  "build": "node scripts/build-p1.cjs",
114
115
  "build:tests": "node scripts/compile-tests.cjs",
115
- "lint": "eslint . --ignore-pattern .generated/** --ignore-pattern dist/** --ignore-pattern .devcodex/**",
116
- "lint:fix": "eslint . --fix --ignore-pattern .generated/** --ignore-pattern dist/** --ignore-pattern .devcodex/**",
116
+ "lint": "eslint .",
117
+ "lint:fix": "eslint . --fix",
117
118
  "test:runtime": "npm run build && npm run build:tests && node --test .generated/test-dist/test/smoke/root-cjs.test.js .generated/test-dist/test/smoke/root-esm.test.js .generated/test-dist/test/smoke/pack-artifacts.test.js",
118
119
  "test:compatibility": "npm run build && npm run build:tests && node --test .generated/test-dist/test/compatibility/exports/exports.test.js .generated/test-dist/test/compatibility/matrix.test.js",
119
120
  "probe:server-matrix": "node scripts/validation/probe-memory-server-matrix.cjs",
@@ -122,7 +123,7 @@
122
123
  "test:examples": "npm run build && tsc -p tsconfig.examples.json && node scripts/run-examples.cjs",
123
124
  "test:performance": "npm run build && npm run build:tests && node .generated/test-dist/test/performance/baselines/function-cache.benchmark.js",
124
125
  "test:unit": "npm run build && npm run build:tests && node test/run-tests.cjs unit",
125
- "test:integration": "npm run build && npm run build:tests && node --test --test-concurrency=1 .generated/test-dist/test/integration/cache/cache.test.js .generated/test-dist/test/integration/cache/cache-behavior.test.js .generated/test-dist/test/integration/mongodb/connect.test.js .generated/test-dist/test/integration/mongodb/queries.test.js .generated/test-dist/test/integration/mongodb/management.test.js .generated/test-dist/test/integration/mongodb/writes-batch.test.js .generated/test-dist/test/integration/mongodb/find.test.js .generated/test-dist/test/integration/mongodb/find-one.test.js .generated/test-dist/test/integration/mongodb/find-page.test.js .generated/test-dist/test/integration/mongodb/aggregate.test.js .generated/test-dist/test/integration/mongodb/chaining.test.js .generated/test-dist/test/integration/mongodb/insert.test.js .generated/test-dist/test/integration/mongodb/update.test.js .generated/test-dist/test/integration/mongodb/delete.test.js .generated/test-dist/test/integration/mongodb/update-pipeline.test.js .generated/test-dist/test/integration/model/model-features.test.js .generated/test-dist/test/integration/transaction/transaction.test.js .generated/test-dist/test/integration/pool/pool.test.js .generated/test-dist/test/integration/pool/pool-behavior.test.js .generated/test-dist/test/integration/watch/watch-native.test.js .generated/test-dist/test/integration/runtime/runtime-core-regression.test.js .generated/test-dist/test/integration/sync/sync.test.js .generated/test-dist/test/integration/slow-query-log/slow-query-log.test.js .generated/test-dist/test/integration/model/model-crud-extended.test.js .generated/test-dist/test/integration/mongodb/management-complete.test.js .generated/test-dist/test/integration/runtime/runtime-methods-extended.test.js .generated/test-dist/test/integration/mongodb/find-page-advanced.test.js",
126
+ "test:integration": "npm run build && npm run build:tests && node --test --test-concurrency=1 .generated/test-dist/test/integration/cache/cache.test.js .generated/test-dist/test/integration/cache/cache-behavior.test.js .generated/test-dist/test/integration/mongodb/connect.test.js .generated/test-dist/test/integration/mongodb/queries.test.js .generated/test-dist/test/integration/mongodb/management.test.js .generated/test-dist/test/integration/mongodb/writes-batch.test.js .generated/test-dist/test/integration/mongodb/find.test.js .generated/test-dist/test/integration/mongodb/find-one.test.js .generated/test-dist/test/integration/mongodb/find-page.test.js .generated/test-dist/test/integration/mongodb/aggregate.test.js .generated/test-dist/test/integration/mongodb/chaining.test.js .generated/test-dist/test/integration/mongodb/insert.test.js .generated/test-dist/test/integration/mongodb/update.test.js .generated/test-dist/test/integration/mongodb/delete.test.js .generated/test-dist/test/integration/mongodb/update-pipeline.test.js .generated/test-dist/test/integration/model/model-features.test.js .generated/test-dist/test/integration/transaction/transaction.test.js .generated/test-dist/test/integration/pool/pool.test.js .generated/test-dist/test/integration/pool/pool-behavior.test.js .generated/test-dist/test/integration/watch/watch-native.test.js .generated/test-dist/test/integration/runtime/runtime-core-regression.test.js .generated/test-dist/test/integration/runtime/review-regressions.test.js .generated/test-dist/test/integration/sync/sync.test.js .generated/test-dist/test/integration/slow-query-log/slow-query-log.test.js .generated/test-dist/test/integration/model/model-crud-extended.test.js .generated/test-dist/test/integration/mongodb/management-complete.test.js .generated/test-dist/test/integration/runtime/runtime-methods-extended.test.js .generated/test-dist/test/integration/mongodb/find-page-advanced.test.js .generated/test-dist/test/integration/mongodb/review-repair-regressions.test.js .generated/test-dist/test/integration/model/review-model-regressions.test.js .generated/test-dist/test/integration/slow-query-log/review-storage-regressions.test.js",
126
127
  "test:data-tasks:integration": "npm run build && npm run build:tests && node test/run-tests.cjs data-tasks-integration",
127
128
  "test:data-task-cli": "npm run build && npm run build:tests && node test/run-tests.cjs data-task-cli",
128
129
  "test:pack-install": "npm run build && node scripts/pack-install-smoke.cjs",