monsqlize 3.2.0 → 3.3.1

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.
@@ -332,8 +332,8 @@ export interface FindPageOptions<TSchema = any> {
332
332
  hint?: Document | string;
333
333
  collation?: Document;
334
334
  batchSize?: number;
335
- /** Cache TTL in milliseconds for the non-stream/non-explain page result */
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
  }
@@ -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
- conflictCount?: number;
509
- /** Document ids skipped by strict model version conflict handling. */
510
- conflictedIds?: unknown[];
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 {
@@ -332,8 +332,8 @@ export interface FindPageOptions<TSchema = any> {
332
332
  hint?: Document | string;
333
333
  collation?: Document;
334
334
  batchSize?: number;
335
- /** Cache TTL in milliseconds for the non-stream/non-explain page result */
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
  }
@@ -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
- conflictCount?: number;
509
- /** Document ids skipped by strict model version conflict handling. */
510
- conflictedIds?: unknown[];
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;
@@ -1,4 +1,5 @@
1
1
  import type { BookmarkClearResult, BookmarkListResult, BookmarkPrewarmResult, DeleteBatchResult, DeleteResult, IncrementOneResult, IndexCreateResult, InsertBatchResult, InsertManyResult, InsertOneResult, UpdateBatchResult, UpdateResult, VectorSearchHit, VectorSearchOptions } from './collection.mjs';
2
+ import type { InferSchema } from 'schema-dsl';
2
3
  import type { SchemaDslRuntime } from 'schema-dsl/runtime';
3
4
 
4
5
  /**
@@ -12,6 +13,42 @@ export type ModelSchemaDsl = SchemaDslRuntime['s'];
12
13
  */
13
14
  export type SchemaDSL = (s: ModelSchemaDsl) => unknown;
14
15
 
16
+ /**
17
+ * A statically typed Model registration descriptor.
18
+ *
19
+ * The descriptor preserves the document type inferred from an object-literal
20
+ * schema while keeping Model registration explicit at runtime.
21
+ * @since v3.3.0
22
+ */
23
+ export interface ModelDescriptor<TName extends string = string, TDocument = Record<string, unknown>> {
24
+ readonly collectionName: TName;
25
+ readonly definition: ModelDefinition<TDocument>;
26
+ readonly __document?: TDocument;
27
+ }
28
+
29
+ /**
30
+ * Extract the document type carried by a Model descriptor.
31
+ * @since v3.3.0
32
+ */
33
+ export type InferModelDocument<TDescriptor> = TDescriptor extends ModelDescriptor<string, infer TDocument>
34
+ ? TDocument
35
+ : never;
36
+
37
+ /**
38
+ * Create a typed Model descriptor from a static object-literal schema.
39
+ *
40
+ * Register the returned descriptor with `Model.define(descriptor)` before
41
+ * binding it through a MonSQLize runtime. Callback schemas continue to use
42
+ * the existing explicit generic APIs because their static shape is not stable.
43
+ * @since v3.3.0
44
+ */
45
+ export declare function defineModel<
46
+ const TName extends string,
47
+ const TSchema extends Record<string, unknown>,
48
+ >(collectionName: TName, definition: Omit<ModelDefinition<InferSchema<TSchema>>, 'schema'> & {
49
+ schema: TSchema;
50
+ }): ModelDescriptor<TName, InferSchema<TSchema>>;
51
+
15
52
  /**
16
53
  * Default value for a model field — either a static value or a factory function.
17
54
  * @template T Field value type
@@ -169,6 +206,9 @@ export type ModelUpdateManyOptions = ModelWriteOptions & {
169
206
  export type ModelStrictUpdateManyResult = UpdateResult & {
170
207
  conflictCount: number;
171
208
  conflictedIds: unknown[];
209
+ /** Selected candidates no longer matching the business filter or removed before the write. */
210
+ skippedCount: number;
211
+ skippedIds: unknown[];
172
212
  };
173
213
 
174
214
  export type ModelIndexSource = 'definition' | 'softDelete';
@@ -739,6 +779,8 @@ export interface ModelInstance<TDocument = any> {
739
779
  }
740
780
 
741
781
  export declare class Model {
782
+ /** @since v3.3.0 */
783
+ static define<TName extends string, TDocument>(descriptor: ModelDescriptor<TName, TDocument>): void;
742
784
  static define<TDocument = Record<string, unknown>>(collectionName: string, definition: ModelDefinition<TDocument>): void;
743
785
  static get<TDocument = Record<string, unknown>>(collectionName: string): RegisteredModel<TDocument> | undefined;
744
786
  static has(collectionName: string): boolean;
@@ -1,4 +1,5 @@
1
1
  import type { BookmarkClearResult, BookmarkListResult, BookmarkPrewarmResult, DeleteBatchResult, DeleteResult, IncrementOneResult, IndexCreateResult, InsertBatchResult, InsertManyResult, InsertOneResult, UpdateBatchResult, UpdateResult, VectorSearchHit, VectorSearchOptions } from './collection';
2
+ import type { InferSchema } from 'schema-dsl';
2
3
  import type { SchemaDslRuntime } from 'schema-dsl/runtime';
3
4
 
4
5
  /**
@@ -12,6 +13,42 @@ export type ModelSchemaDsl = SchemaDslRuntime['s'];
12
13
  */
13
14
  export type SchemaDSL = (s: ModelSchemaDsl) => unknown;
14
15
 
16
+ /**
17
+ * A statically typed Model registration descriptor.
18
+ *
19
+ * The descriptor preserves the document type inferred from an object-literal
20
+ * schema while keeping Model registration explicit at runtime.
21
+ * @since v3.3.0
22
+ */
23
+ export interface ModelDescriptor<TName extends string = string, TDocument = Record<string, unknown>> {
24
+ readonly collectionName: TName;
25
+ readonly definition: ModelDefinition<TDocument>;
26
+ readonly __document?: TDocument;
27
+ }
28
+
29
+ /**
30
+ * Extract the document type carried by a Model descriptor.
31
+ * @since v3.3.0
32
+ */
33
+ export type InferModelDocument<TDescriptor> = TDescriptor extends ModelDescriptor<string, infer TDocument>
34
+ ? TDocument
35
+ : never;
36
+
37
+ /**
38
+ * Create a typed Model descriptor from a static object-literal schema.
39
+ *
40
+ * Register the returned descriptor with `Model.define(descriptor)` before
41
+ * binding it through a MonSQLize runtime. Callback schemas continue to use
42
+ * the existing explicit generic APIs because their static shape is not stable.
43
+ * @since v3.3.0
44
+ */
45
+ export declare function defineModel<
46
+ const TName extends string,
47
+ const TSchema extends Record<string, unknown>,
48
+ >(collectionName: TName, definition: Omit<ModelDefinition<InferSchema<TSchema>>, 'schema'> & {
49
+ schema: TSchema;
50
+ }): ModelDescriptor<TName, InferSchema<TSchema>>;
51
+
15
52
  /**
16
53
  * Default value for a model field — either a static value or a factory function.
17
54
  * @template T Field value type
@@ -169,6 +206,9 @@ export type ModelUpdateManyOptions = ModelWriteOptions & {
169
206
  export type ModelStrictUpdateManyResult = UpdateResult & {
170
207
  conflictCount: number;
171
208
  conflictedIds: unknown[];
209
+ /** Selected candidates no longer matching the business filter or removed before the write. */
210
+ skippedCount: number;
211
+ skippedIds: unknown[];
172
212
  };
173
213
 
174
214
  export type ModelIndexSource = 'definition' | 'softDelete';
@@ -739,6 +779,8 @@ export interface ModelInstance<TDocument = any> {
739
779
  }
740
780
 
741
781
  export declare class Model {
782
+ /** @since v3.3.0 */
783
+ static define<TName extends string, TDocument>(descriptor: ModelDescriptor<TName, TDocument>): void;
742
784
  static define<TDocument = Record<string, unknown>>(collectionName: string, definition: ModelDefinition<TDocument>): void;
743
785
  static get<TDocument = Record<string, unknown>>(collectionName: string): RegisteredModel<TDocument> | undefined;
744
786
  static has(collectionName: string): boolean;
@@ -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). */
@@ -35,7 +39,7 @@ export interface SSHConfig {
35
39
  import type { Collection, CursorValueNormalizer, CursorValueType, DbAccessor, HealthView } from './collection.mjs';
36
40
  import type { DataTaskJobError } from './data-tasks.mjs';
37
41
  import type { Lock, LockOptions, LockStats } from './lock.mjs';
38
- import type { ModelAutoIndexOptions, ModelEnsureAllIndexesOptions, ModelIndexEnsureSummary, ModelInstance } from './model.mjs';
42
+ import type { ModelAutoIndexOptions, ModelDescriptor, ModelEnsureAllIndexesOptions, ModelIndexEnsureSummary, ModelInstance } from './model.mjs';
39
43
  import type { MongoConnectConfig } from './mongodb.mjs';
40
44
  import type { ConnectionPoolManagerOptions, PoolConfig, PoolHealthStatus, PoolStats, PoolStrategy } from './pool.mjs';
41
45
  import type {
@@ -70,6 +74,15 @@ import type { SlowQueryLogConfigInput, SlowQueryLogEntry, SlowQueryLogFilter, Sl
70
74
  import type { ChangeStreamSyncManager, SyncConfig, SyncStats } from './sync.mjs';
71
75
  import type { Transaction, TransactionOptions, TransactionStats } from './transaction.mjs';
72
76
 
77
+ /**
78
+ * Callable model accessor that preserves a descriptor's inferred document type.
79
+ * @since v3.3.0
80
+ */
81
+ export interface ModelBindingAccessor {
82
+ <TDocument>(descriptor: ModelDescriptor<string, TDocument>): ModelInstance<TDocument>;
83
+ <TDocument = any>(modelName: string): ModelInstance<TDocument>;
84
+ }
85
+
73
86
  /** Write path policy mode. `allow-both` preserves the existing collection and model write behavior. */
74
87
  export type WritePathPolicyMode = 'allow-both' | 'model-only';
75
88
 
@@ -283,7 +296,7 @@ export interface MonSQLizeInstance {
283
296
  db: (name?: string) => DbAccessor;
284
297
  use: (name: string) => {
285
298
  collection: <TSchema = any>(collectionName: string) => Collection<TSchema>;
286
- model: <TDocument = any>(modelName: string) => ModelInstance<TDocument>;
299
+ model: ModelBindingAccessor;
287
300
  };
288
301
  instance: MonSQLize;
289
302
  }>;
@@ -315,7 +328,7 @@ export interface MonSQLizeInstance {
315
328
  */
316
329
  use(name: string): {
317
330
  collection: <TSchema = any>(collectionName: string) => Collection<TSchema>;
318
- model: <TDocument = any>(modelName: string) => ModelInstance<TDocument>;
331
+ model: ModelBindingAccessor;
319
332
  };
320
333
  /**
321
334
  * Return collection and model accessors for the named connection pool.
@@ -323,10 +336,10 @@ export interface MonSQLizeInstance {
323
336
  */
324
337
  pool(poolName: string): {
325
338
  collection: <TSchema = any>(name: string) => Collection<TSchema>;
326
- model: <TDocument = any>(name: string) => ModelInstance<TDocument>;
339
+ model: ModelBindingAccessor;
327
340
  use: (dbName: string) => {
328
341
  collection: <TSchema = any>(name: string) => Collection<TSchema>;
329
- model: <TDocument = any>(name: string) => ModelInstance<TDocument>;
342
+ model: ModelBindingAccessor;
330
343
  };
331
344
  };
332
345
  /**
@@ -341,12 +354,16 @@ export interface MonSQLizeInstance {
341
354
  * @param name Model name.
342
355
  * @param options Optional database or pool scope options.
343
356
  */
357
+ /** @since v3.3.0 */
358
+ scopedModel<TDocument>(descriptor: ModelDescriptor<string, TDocument>, options?: { database?: string; pool?: string; }): ModelInstance<TDocument>;
344
359
  scopedModel<TDocument = any>(name: string, options?: { database?: string; pool?: string; }): ModelInstance<TDocument>;
345
360
  scopedModel(name: string, options?: { database?: string; pool?: string; }): ModelInstance<any>;
346
361
  /**
347
362
  * Return the registered model instance for the given model name.
348
363
  * @param name Model name used during registration.
349
364
  */
365
+ /** @since v3.3.0 */
366
+ model<TDocument>(descriptor: ModelDescriptor<string, TDocument>): ModelInstance<TDocument>;
350
367
  model<TDocument = any>(name: string): ModelInstance<TDocument>;
351
368
  model(name: string): ModelInstance<any>;
352
369
  /**
@@ -516,7 +533,7 @@ export default class MonSQLize implements MonSQLizeInstance {
516
533
  db: (name?: string) => DbAccessor;
517
534
  use: (name: string) => {
518
535
  collection: <TSchema = any>(collectionName: string) => Collection<TSchema>;
519
- model: <TDocument = any>(modelName: string) => ModelInstance<TDocument>;
536
+ model: ModelBindingAccessor;
520
537
  };
521
538
  instance: MonSQLize;
522
539
  }>;
@@ -529,20 +546,24 @@ export default class MonSQLize implements MonSQLizeInstance {
529
546
  db(name?: string): DbAccessor;
530
547
  use(name: string): {
531
548
  collection: <TSchema = any>(collectionName: string) => Collection<TSchema>;
532
- model: <TDocument = any>(modelName: string) => ModelInstance<TDocument>;
549
+ model: ModelBindingAccessor;
533
550
  };
534
551
  pool(poolName: string): {
535
552
  collection: <TSchema = any>(name: string) => Collection<TSchema>;
536
- model: <TDocument = any>(name: string) => ModelInstance<TDocument>;
553
+ model: ModelBindingAccessor;
537
554
  use: (dbName: string) => {
538
555
  collection: <TSchema = any>(name: string) => Collection<TSchema>;
539
- model: <TDocument = any>(name: string) => ModelInstance<TDocument>;
556
+ model: ModelBindingAccessor;
540
557
  };
541
558
  };
542
559
  scopedCollection<TSchema = any>(name: string, options?: { database?: string; pool?: string; }): Collection<TSchema>;
543
560
  scopedCollection(name: string, options?: { database?: string; pool?: string; }): Collection<any>;
561
+ /** @since v3.3.0 */
562
+ scopedModel<TDocument>(descriptor: ModelDescriptor<string, TDocument>, options?: { database?: string; pool?: string; }): ModelInstance<TDocument>;
544
563
  scopedModel<TDocument = any>(name: string, options?: { database?: string; pool?: string; }): ModelInstance<TDocument>;
545
564
  scopedModel(name: string, options?: { database?: string; pool?: string; }): ModelInstance<any>;
565
+ /** @since v3.3.0 */
566
+ model<TDocument>(descriptor: ModelDescriptor<string, TDocument>): ModelInstance<TDocument>;
546
567
  model<TDocument = any>(name: string): ModelInstance<TDocument>;
547
568
  model(name: string): ModelInstance<any>;
548
569
  ensureModelIndexes(options?: ModelEnsureAllIndexesOptions): Promise<ModelIndexEnsureSummary>;
@@ -601,6 +622,8 @@ export default class MonSQLize implements MonSQLizeInstance {
601
622
  static LockTimeoutError: typeof import('./lock.mjs').LockTimeoutError;
602
623
  static DistributedCacheInvalidator: typeof DistributedCacheInvalidator;
603
624
  static ConnectionPoolManager: typeof import('./pool.mjs').ConnectionPoolManager;
625
+ /** @since v3.3.0 */
626
+ static defineModel: typeof import('./model.mjs').defineModel;
604
627
  static Model: typeof import('./runtime.mjs').Model;
605
628
  static ModelInstance: typeof import('./runtime.mjs').ModelInstance;
606
629
  static expr: typeof expr;
@@ -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). */
@@ -35,7 +39,7 @@ export interface SSHConfig {
35
39
  import type { Collection, CursorValueNormalizer, CursorValueType, DbAccessor, HealthView } from './collection';
36
40
  import type { DataTaskJobError } from './data-tasks';
37
41
  import type { Lock, LockOptions, LockStats } from './lock';
38
- import type { ModelAutoIndexOptions, ModelEnsureAllIndexesOptions, ModelIndexEnsureSummary, ModelInstance } from './model';
42
+ import type { ModelAutoIndexOptions, ModelDescriptor, ModelEnsureAllIndexesOptions, ModelIndexEnsureSummary, ModelInstance } from './model';
39
43
  import type { MongoConnectConfig } from './mongodb';
40
44
  import type { ConnectionPoolManagerOptions, PoolConfig, PoolHealthStatus, PoolStats, PoolStrategy } from './pool';
41
45
  import type {
@@ -70,6 +74,15 @@ import type { SlowQueryLogConfigInput, SlowQueryLogEntry, SlowQueryLogFilter, Sl
70
74
  import type { ChangeStreamSyncManager, SyncConfig, SyncStats } from './sync';
71
75
  import type { Transaction, TransactionOptions, TransactionStats } from './transaction';
72
76
 
77
+ /**
78
+ * Callable model accessor that preserves a descriptor's inferred document type.
79
+ * @since v3.3.0
80
+ */
81
+ export interface ModelBindingAccessor {
82
+ <TDocument>(descriptor: ModelDescriptor<string, TDocument>): ModelInstance<TDocument>;
83
+ <TDocument = any>(modelName: string): ModelInstance<TDocument>;
84
+ }
85
+
73
86
  /** Write path policy mode. `allow-both` preserves the existing collection and model write behavior. */
74
87
  export type WritePathPolicyMode = 'allow-both' | 'model-only';
75
88
 
@@ -283,7 +296,7 @@ export interface MonSQLizeInstance {
283
296
  db: (name?: string) => DbAccessor;
284
297
  use: (name: string) => {
285
298
  collection: <TSchema = any>(collectionName: string) => Collection<TSchema>;
286
- model: <TDocument = any>(modelName: string) => ModelInstance<TDocument>;
299
+ model: ModelBindingAccessor;
287
300
  };
288
301
  instance: MonSQLize;
289
302
  }>;
@@ -315,7 +328,7 @@ export interface MonSQLizeInstance {
315
328
  */
316
329
  use(name: string): {
317
330
  collection: <TSchema = any>(collectionName: string) => Collection<TSchema>;
318
- model: <TDocument = any>(modelName: string) => ModelInstance<TDocument>;
331
+ model: ModelBindingAccessor;
319
332
  };
320
333
  /**
321
334
  * Return collection and model accessors for the named connection pool.
@@ -323,10 +336,10 @@ export interface MonSQLizeInstance {
323
336
  */
324
337
  pool(poolName: string): {
325
338
  collection: <TSchema = any>(name: string) => Collection<TSchema>;
326
- model: <TDocument = any>(name: string) => ModelInstance<TDocument>;
339
+ model: ModelBindingAccessor;
327
340
  use: (dbName: string) => {
328
341
  collection: <TSchema = any>(name: string) => Collection<TSchema>;
329
- model: <TDocument = any>(name: string) => ModelInstance<TDocument>;
342
+ model: ModelBindingAccessor;
330
343
  };
331
344
  };
332
345
  /**
@@ -341,12 +354,16 @@ export interface MonSQLizeInstance {
341
354
  * @param name Model name.
342
355
  * @param options Optional database or pool scope options.
343
356
  */
357
+ /** @since v3.3.0 */
358
+ scopedModel<TDocument>(descriptor: ModelDescriptor<string, TDocument>, options?: { database?: string; pool?: string; }): ModelInstance<TDocument>;
344
359
  scopedModel<TDocument = any>(name: string, options?: { database?: string; pool?: string; }): ModelInstance<TDocument>;
345
360
  scopedModel(name: string, options?: { database?: string; pool?: string; }): ModelInstance<any>;
346
361
  /**
347
362
  * Return the registered model instance for the given model name.
348
363
  * @param name Model name used during registration.
349
364
  */
365
+ /** @since v3.3.0 */
366
+ model<TDocument>(descriptor: ModelDescriptor<string, TDocument>): ModelInstance<TDocument>;
350
367
  model<TDocument = any>(name: string): ModelInstance<TDocument>;
351
368
  model(name: string): ModelInstance<any>;
352
369
  /**
@@ -516,7 +533,7 @@ export default class MonSQLize implements MonSQLizeInstance {
516
533
  db: (name?: string) => DbAccessor;
517
534
  use: (name: string) => {
518
535
  collection: <TSchema = any>(collectionName: string) => Collection<TSchema>;
519
- model: <TDocument = any>(modelName: string) => ModelInstance<TDocument>;
536
+ model: ModelBindingAccessor;
520
537
  };
521
538
  instance: MonSQLize;
522
539
  }>;
@@ -529,20 +546,24 @@ export default class MonSQLize implements MonSQLizeInstance {
529
546
  db(name?: string): DbAccessor;
530
547
  use(name: string): {
531
548
  collection: <TSchema = any>(collectionName: string) => Collection<TSchema>;
532
- model: <TDocument = any>(modelName: string) => ModelInstance<TDocument>;
549
+ model: ModelBindingAccessor;
533
550
  };
534
551
  pool(poolName: string): {
535
552
  collection: <TSchema = any>(name: string) => Collection<TSchema>;
536
- model: <TDocument = any>(name: string) => ModelInstance<TDocument>;
553
+ model: ModelBindingAccessor;
537
554
  use: (dbName: string) => {
538
555
  collection: <TSchema = any>(name: string) => Collection<TSchema>;
539
- model: <TDocument = any>(name: string) => ModelInstance<TDocument>;
556
+ model: ModelBindingAccessor;
540
557
  };
541
558
  };
542
559
  scopedCollection<TSchema = any>(name: string, options?: { database?: string; pool?: string; }): Collection<TSchema>;
543
560
  scopedCollection(name: string, options?: { database?: string; pool?: string; }): Collection<any>;
561
+ /** @since v3.3.0 */
562
+ scopedModel<TDocument>(descriptor: ModelDescriptor<string, TDocument>, options?: { database?: string; pool?: string; }): ModelInstance<TDocument>;
544
563
  scopedModel<TDocument = any>(name: string, options?: { database?: string; pool?: string; }): ModelInstance<TDocument>;
545
564
  scopedModel(name: string, options?: { database?: string; pool?: string; }): ModelInstance<any>;
565
+ /** @since v3.3.0 */
566
+ model<TDocument>(descriptor: ModelDescriptor<string, TDocument>): ModelInstance<TDocument>;
546
567
  model<TDocument = any>(name: string): ModelInstance<TDocument>;
547
568
  model(name: string): ModelInstance<any>;
548
569
  ensureModelIndexes(options?: ModelEnsureAllIndexesOptions): Promise<ModelIndexEnsureSummary>;
@@ -601,6 +622,8 @@ export default class MonSQLize implements MonSQLizeInstance {
601
622
  static LockTimeoutError: typeof import('./lock').LockTimeoutError;
602
623
  static DistributedCacheInvalidator: typeof DistributedCacheInvalidator;
603
624
  static ConnectionPoolManager: typeof import('./pool').ConnectionPoolManager;
625
+ /** @since v3.3.0 */
626
+ static defineModel: typeof import('./model').defineModel;
604
627
  static Model: typeof import('./runtime').Model;
605
628
  static ModelInstance: typeof import('./runtime').ModelInstance;
606
629
  static expr: typeof expr;
@@ -1,6 +1,6 @@
1
1
  import type { BookmarkClearResult, BookmarkListResult, BookmarkPrewarmResult, DeleteBatchResult, DeleteResult, IncrementOneResult, IndexCreateResult, InsertBatchResult, InsertManyResult, UpdateBatchResult, UpdateResult } from './collection.mjs';
2
2
  import type { LoggerLike, ExpressionFunction, ExpressionObject } from './base.mjs';
3
- import type { ModelDefinition, ModelEnsureIndexesOptions, ModelIndexEnsureResult, ModelInstance as ModelInstanceContract, RegisteredModel, RelationConfig } from './model.mjs';
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';
6
6
  import type { SagaDefinition, SagaOrchestratorOptions, SagaResult, SagaStats, SagaStep } from './saga.mjs';
@@ -289,6 +289,8 @@ export declare class FunctionCache {
289
289
  }
290
290
 
291
291
  export declare class Model {
292
+ /** @since v3.3.0 */
293
+ static define<TName extends string, TDocument>(descriptor: ModelDescriptor<TName, TDocument>): void;
292
294
  static define<TDocument = any>(name: string, definition: ModelDefinition<TDocument>): void;
293
295
  static get<TDocument = any>(name: string): RegisteredModel<TDocument> | undefined;
294
296
  static has(name: string): boolean;
@@ -1,6 +1,6 @@
1
1
  import type { BookmarkClearResult, BookmarkListResult, BookmarkPrewarmResult, DeleteBatchResult, DeleteResult, IncrementOneResult, IndexCreateResult, InsertBatchResult, InsertManyResult, UpdateBatchResult, UpdateResult } from './collection';
2
2
  import type { LoggerLike, ExpressionFunction, ExpressionObject } from './base';
3
- import type { ModelDefinition, ModelEnsureIndexesOptions, ModelIndexEnsureResult, ModelInstance as ModelInstanceContract, RegisteredModel, RelationConfig } from './model';
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';
6
6
  import type { SagaDefinition, SagaOrchestratorOptions, SagaResult, SagaStats, SagaStep } from './saga';
@@ -289,6 +289,8 @@ export declare class FunctionCache {
289
289
  }
290
290
 
291
291
  export declare class Model {
292
+ /** @since v3.3.0 */
293
+ static define<TName extends string, TDocument>(descriptor: ModelDescriptor<TName, TDocument>): void;
292
294
  static define<TDocument = any>(name: string, definition: ModelDefinition<TDocument>): void;
293
295
  static get<TDocument = any>(name: string): RegisteredModel<TDocument> | undefined;
294
296
  static has(name: string): boolean;
@@ -5,7 +5,7 @@
5
5
  { "name": "cache-hub", "version": "2.2.4", "license": "Apache-2.0", "source": "package-metadata" },
6
6
  { "name": "ioredis", "version": "5.11.1", "license": "MIT", "source": "package-metadata" },
7
7
  { "name": "mongodb", "version": "6.21.0", "license": "Apache-2.0", "source": "package-metadata" },
8
- { "name": "schema-dsl", "version": "3.0.0", "license": "Apache-2.0", "source": "package-metadata" },
8
+ { "name": "schema-dsl", "version": "3.0.4", "license": "Apache-2.0", "source": "package-metadata" },
9
9
  { "name": "ssh2", "version": "1.17.0", "license": "MIT", "source": "LICENSE:d06b5d27bbbbe22c36b1fd88406b1208876e2d37d795f5b8eaed951a459a3111" }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monsqlize",
3
- "version": "3.2.0",
3
+ "version": "3.3.1",
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,8 @@
21
21
  "./package.json": "./package.json"
22
22
  },
23
23
  "files": [
24
+ "changelogs/v3.3.1.md",
25
+ "changelogs/v3.3.0.md",
24
26
  "changelogs/v3.2.0.md",
25
27
  "changelogs/v3.1.14.md",
26
28
  "changelogs/v3.1.13.md",
@@ -160,11 +162,11 @@
160
162
  "cache-hub": "2.2.4",
161
163
  "ioredis": "5.11.1",
162
164
  "mongodb": "6.21.0",
163
- "schema-dsl": "3.0.0",
165
+ "schema-dsl": "3.0.4",
164
166
  "ssh2": "1.17.0"
165
167
  },
166
168
  "overrides": {
167
- "fast-uri": "3.1.5",
169
+ "fast-uri": "^3.1.8",
168
170
  "minimatch@3.1.5": {
169
171
  "brace-expansion": "1.1.18"
170
172
  },