monsqlize 2.0.0 → 2.0.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.
@@ -1,256 +1,256 @@
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';
3
- import type { ModelDefinition, ModelInstance as ModelInstanceContract, RegisteredModel, RelationConfig } from './model';
4
- import type { LockOptions, LockStats } from './lock';
5
- import type { ConnectionPoolManagerOptions, FallbackStrategy, PoolConfig, PoolHealthStatus, PoolRole, PoolStats, PoolStrategy } from './pool';
6
- import type { SagaDefinition, SagaOrchestratorOptions, SagaResult, SagaStats, SagaStep } from './saga';
7
- import type { SlowQueryLogConfig, SlowQueryLogConfigInput, SlowQueryLogEntry, SlowQueryLogFilter, SlowQueryLogQueryOptions, SlowQueryLogRecord, SlowQueryLogStorageConfig } from './slow-query-log';
8
- import type { ResumeTokenConfig, SyncChangeEvent, SyncConfig, SyncStats, SyncTargetConfig, SyncTargetHealthCheckConfig } from './sync';
9
- import type { MongoSession, TransactionOptions, TransactionStats } from './transaction';
10
- import type {
11
- CacheLike as HubCacheLike,
12
- CacheStats as HubCacheStats,
13
- LockManager as HubCacheLockLike,
14
- MemoryCacheOptions as HubMemoryCacheOptions,
15
- } from 'cache-hub';
16
- import type { RedisCacheAdapter as HubRedisCacheAdapter } from 'cache-hub/redis';
17
- import type {
18
- DistributedInvalidatorOptions as HubDistributedInvalidatorOptions,
19
- InvalidatorStats as HubInvalidatorStats,
20
- } from 'cache-hub/distributed';
21
- import type {
22
- FunctionCacheOptions as HubFunctionCacheOptions,
23
- FunctionCacheStats as HubFunctionCacheStats,
24
- WithCacheOptions as HubWithCacheOptions,
25
- WithCacheStats as HubWithCacheStats,
26
- WrappedFunction as HubWrappedFunction,
27
- } from 'cache-hub/function-cache';
28
-
29
- export { Lock, LockAcquireError, LockTimeoutError, LockManager } from './lock';
30
- export { ConnectionPoolManager } from './pool';
31
- export { SagaOrchestrator } from './saga';
32
- export { BatchQueue, SlowQueryLogConfigManager, SlowQueryLogManager, SlowQueryLogMemoryStorage, MongoDBSlowQueryLogStorage } from './slow-query-log';
33
- export { ChangeStreamSyncManager, ResumeTokenStore } from './sync';
34
- export { CacheLockManager, Transaction, TransactionManager } from './transaction';
35
-
36
- export declare class Logger {
37
- constructor(logger?: LoggerLike | null);
38
- debug(...args: unknown[]): void;
39
- info(...args: unknown[]): void;
40
- warn(...args: unknown[]): void;
41
- error(...args: unknown[]): void;
42
- static create(logger?: LoggerLike | null): Logger;
43
- }
44
-
45
- export type CacheLockLike = HubCacheLockLike;
46
- export type CacheLike = HubCacheLike;
47
- export type MemoryCacheOptions = HubMemoryCacheOptions;
48
-
49
- /**
50
- * Multi-level cache write policy.
51
- * - `both`: write to both local and remote simultaneously (waits for remote to complete)
52
- * - `local-first-async-remote`: return after local write; remote write is asynchronous (reduces tail latency)
53
- * @since v1.1.0
54
- */
55
- export type WritePolicy = 'both' | 'local-first-async-remote';
56
-
57
- /**
58
- * Multi-level cache policy configuration.
59
- * @since v1.1.0
60
- */
61
- export interface MultiLevelCachePolicy {
62
- /** Write policy; defaults to `both`. */
63
- writePolicy?: WritePolicy;
64
- /** Whether to backfill the local cache on a remote hit; defaults to true. */
65
- backfillLocalOnRemoteHit?: boolean;
66
- }
67
-
68
- /**
69
- * Multi-level cache configuration object (declarative two-tier cache setup).
70
- *
71
- * When passed to `MonSQLizeOptions.cache`, the framework automatically creates a MultiLevelCache:
72
- * - `local`: always uses the built-in memory cache (accepts MemoryCacheOptions only)
73
- * - `remote`: accepts a CacheLike instance (recommended for production) or a config object
74
- * that degrades to an in-memory placeholder
75
- * - `policy`: write policy and backfill policy configuration
76
- * @since v1.1.0
77
- */
78
- export interface MultiLevelCacheOptions {
79
- multiLevel: true;
80
- local?: MemoryCacheOptions;
81
- remote?: CacheLike | (MemoryCacheOptions & { timeoutMs?: number });
82
- policy?: MultiLevelCachePolicy;
83
- publish?: (msg: unknown) => void;
84
- }
85
-
86
- export declare class MemoryCache {
87
- constructor(options?: MemoryCacheOptions);
88
- setLockManager(lockManager: CacheLockLike): void;
89
- getLockManager(): CacheLockLike | null;
90
- get<T = unknown>(key: string): T | undefined;
91
- set(key: string, value: unknown, ttl?: number): void;
92
- del(key: string): boolean;
93
- exists(key: string): boolean;
94
- has(key: string): boolean;
95
- getMany(keys: string[]): Record<string, unknown>;
96
- setMany(values: Record<string, unknown>, ttl?: number): boolean;
97
- delMany(keys: string[]): number;
98
- clear(): void;
99
- keys(pattern?: string): string[];
100
- delPattern(pattern: string): number;
101
- getStats(): CacheStats;
102
- resetStats(): void;
103
- invalidateByTag(tag: string): void;
104
- destroy(): void;
105
- }
106
-
107
- export declare class MultiLevelCache {
108
- constructor(options: {
109
- local: CacheLike;
110
- remote?: CacheLike;
111
- writePolicy?: 'both' | 'local-first-async-remote';
112
- backfillOnRemoteHit?: boolean;
113
- remoteTimeoutMs?: number;
114
- publish?: (msg: { type: string; pattern: string; ts: number }) => void;
115
- });
116
- get<T = unknown>(key: string): Promise<T | undefined>;
117
- set(key: string, value: unknown, ttl?: number): Promise<void>;
118
- del(key: string): Promise<boolean>;
119
- exists(key: string): Promise<boolean>;
120
- has(key: string): Promise<boolean>;
121
- clear(): Promise<void>;
122
- getMany(keys: string[]): Promise<Record<string, unknown>>;
123
- setMany(values: Record<string, unknown>, ttl?: number): Promise<boolean>;
124
- delMany(keys: string[]): Promise<number>;
125
- delPattern(pattern: string): Promise<number>;
126
- keys(pattern?: string): Promise<string[]>;
127
- invalidateByTag(tag: string): void | Promise<void>;
128
- setPublish(publish: (msg: { type: string; pattern: string; ts: number }) => void): void;
129
- setLockManager(lockManager: CacheLockLike): void;
130
- getStats(): CacheStats;
131
- resetStats(): void;
132
- destroy(): void;
133
- }
134
-
135
- export type RedisCacheAdapterOptions = never;
136
- export type RedisLike = object;
137
-
138
- /**
139
- * Adapts a v1-style CacheLike object to the v2 CacheLike interface.
140
- *
141
- * v2 requires a `has()` method that was absent in v1. This helper adds it
142
- * by delegating to the existing `exists()`. All other methods are forwarded as-is.
143
- *
144
- * @param v1Cache - A v1 custom cache implementation missing `has()`.
145
- * @returns A fully v2-compatible `CacheLike` instance.
146
- * @example
147
- * ```ts
148
- * const v2Cache = adaptLegacyCacheLike(myV1Cache);
149
- * const msq = new MonSQLize({ cache: v2Cache });
150
- * ```
151
- */
152
- export declare function adaptLegacyCacheLike(v1Cache: Omit<CacheLike, 'has'>): CacheLike;
153
-
154
- /** Re-exported alias so consumers can type the return value of `createRedisCacheAdapter`. */
2
+ import type { LoggerLike, ExpressionFunction, ExpressionObject } from './base';
3
+ import type { ModelDefinition, ModelInstance as ModelInstanceContract, RegisteredModel, RelationConfig } from './model';
4
+ import type { LockOptions, LockStats } from './lock';
5
+ import type { ConnectionPoolManagerOptions, FallbackStrategy, PoolConfig, PoolHealthStatus, PoolRole, PoolStats, PoolStrategy } from './pool';
6
+ import type { SagaDefinition, SagaOrchestratorOptions, SagaResult, SagaStats, SagaStep } from './saga';
7
+ import type { SlowQueryLogConfig, SlowQueryLogConfigInput, SlowQueryLogEntry, SlowQueryLogFilter, SlowQueryLogQueryOptions, SlowQueryLogRecord, SlowQueryLogStorageConfig } from './slow-query-log';
8
+ import type { ResumeTokenConfig, SyncChangeEvent, SyncConfig, SyncStats, SyncTargetConfig, SyncTargetHealthCheckConfig } from './sync';
9
+ import type { MongoSession, TransactionOptions, TransactionStats } from './transaction';
10
+ import type {
11
+ CacheLike as HubCacheLike,
12
+ CacheStats as HubCacheStats,
13
+ LockManager as HubCacheLockLike,
14
+ MemoryCacheOptions as HubMemoryCacheOptions,
15
+ } from 'cache-hub';
16
+ import type { RedisCacheAdapter as HubRedisCacheAdapter } from 'cache-hub/redis';
17
+ import type {
18
+ DistributedInvalidatorOptions as HubDistributedInvalidatorOptions,
19
+ InvalidatorStats as HubInvalidatorStats,
20
+ } from 'cache-hub/distributed';
21
+ import type {
22
+ FunctionCacheOptions as HubFunctionCacheOptions,
23
+ FunctionCacheStats as HubFunctionCacheStats,
24
+ WithCacheOptions as HubWithCacheOptions,
25
+ WithCacheStats as HubWithCacheStats,
26
+ WrappedFunction as HubWrappedFunction,
27
+ } from 'cache-hub/function-cache';
28
+
29
+ export { Lock, LockAcquireError, LockTimeoutError, LockManager } from './lock';
30
+ export { ConnectionPoolManager } from './pool';
31
+ export { SagaOrchestrator } from './saga';
32
+ export { BatchQueue, SlowQueryLogConfigManager, SlowQueryLogManager, SlowQueryLogMemoryStorage, MongoDBSlowQueryLogStorage } from './slow-query-log';
33
+ export { ChangeStreamSyncManager, ResumeTokenStore } from './sync';
34
+ export { CacheLockManager, Transaction, TransactionManager } from './transaction';
35
+
36
+ export declare class Logger {
37
+ constructor(logger?: LoggerLike | null);
38
+ debug(...args: unknown[]): void;
39
+ info(...args: unknown[]): void;
40
+ warn(...args: unknown[]): void;
41
+ error(...args: unknown[]): void;
42
+ static create(logger?: LoggerLike | null): Logger;
43
+ }
44
+
45
+ export type CacheLockLike = HubCacheLockLike;
46
+ export type CacheLike = HubCacheLike;
47
+ export type MemoryCacheOptions = HubMemoryCacheOptions;
48
+
49
+ /**
50
+ * Multi-level cache write policy.
51
+ * - `both`: write to both local and remote simultaneously (waits for remote to complete)
52
+ * - `local-first-async-remote`: return after local write; remote write is asynchronous (reduces tail latency)
53
+ * @since v1.1.0
54
+ */
55
+ export type WritePolicy = 'both' | 'local-first-async-remote';
56
+
57
+ /**
58
+ * Multi-level cache policy configuration.
59
+ * @since v1.1.0
60
+ */
61
+ export interface MultiLevelCachePolicy {
62
+ /** Write policy; defaults to `both`. */
63
+ writePolicy?: WritePolicy;
64
+ /** Whether to backfill the local cache on a remote hit; defaults to true. */
65
+ backfillLocalOnRemoteHit?: boolean;
66
+ }
67
+
68
+ /**
69
+ * Multi-level cache configuration object (declarative two-tier cache setup).
70
+ *
71
+ * When passed to `MonSQLizeOptions.cache`, the framework automatically creates a MultiLevelCache:
72
+ * - `local`: always uses the built-in memory cache (accepts MemoryCacheOptions only)
73
+ * - `remote`: accepts a CacheLike instance (recommended for production) or a config object
74
+ * that degrades to an in-memory placeholder
75
+ * - `policy`: write policy and backfill policy configuration
76
+ * @since v1.1.0
77
+ */
78
+ export interface MultiLevelCacheOptions {
79
+ multiLevel: true;
80
+ local?: MemoryCacheOptions;
81
+ remote?: CacheLike | (MemoryCacheOptions & { timeoutMs?: number });
82
+ policy?: MultiLevelCachePolicy;
83
+ publish?: (msg: unknown) => void;
84
+ }
85
+
86
+ export declare class MemoryCache {
87
+ constructor(options?: MemoryCacheOptions);
88
+ setLockManager(lockManager: CacheLockLike): void;
89
+ getLockManager(): CacheLockLike | null;
90
+ get<T = unknown>(key: string): T | undefined;
91
+ set(key: string, value: unknown, ttl?: number): void;
92
+ del(key: string): boolean;
93
+ exists(key: string): boolean;
94
+ has(key: string): boolean;
95
+ getMany(keys: string[]): Record<string, unknown>;
96
+ setMany(values: Record<string, unknown>, ttl?: number): boolean;
97
+ delMany(keys: string[]): number;
98
+ clear(): void;
99
+ keys(pattern?: string): string[];
100
+ delPattern(pattern: string): number;
101
+ getStats(): CacheStats;
102
+ resetStats(): void;
103
+ invalidateByTag(tag: string): void;
104
+ destroy(): void;
105
+ }
106
+
107
+ export declare class MultiLevelCache {
108
+ constructor(options: {
109
+ local: CacheLike;
110
+ remote?: CacheLike;
111
+ writePolicy?: 'both' | 'local-first-async-remote';
112
+ backfillOnRemoteHit?: boolean;
113
+ remoteTimeoutMs?: number;
114
+ publish?: (msg: { type: string; pattern: string; ts: number }) => void;
115
+ });
116
+ get<T = unknown>(key: string): Promise<T | undefined>;
117
+ set(key: string, value: unknown, ttl?: number): Promise<void>;
118
+ del(key: string): Promise<boolean>;
119
+ exists(key: string): Promise<boolean>;
120
+ has(key: string): Promise<boolean>;
121
+ clear(): Promise<void>;
122
+ getMany(keys: string[]): Promise<Record<string, unknown>>;
123
+ setMany(values: Record<string, unknown>, ttl?: number): Promise<boolean>;
124
+ delMany(keys: string[]): Promise<number>;
125
+ delPattern(pattern: string): Promise<number>;
126
+ keys(pattern?: string): Promise<string[]>;
127
+ invalidateByTag(tag: string): void | Promise<void>;
128
+ setPublish(publish: (msg: { type: string; pattern: string; ts: number }) => void): void;
129
+ setLockManager(lockManager: CacheLockLike): void;
130
+ getStats(): CacheStats;
131
+ resetStats(): void;
132
+ destroy(): void;
133
+ }
134
+
135
+ export type RedisCacheAdapterOptions = never;
136
+ export type RedisLike = object;
137
+
138
+ /**
139
+ * Adapts a v1-style CacheLike object to the v2 CacheLike interface.
140
+ *
141
+ * v2 requires a `has()` method that was absent in v1. This helper adds it
142
+ * by delegating to the existing `exists()`. All other methods are forwarded as-is.
143
+ *
144
+ * @param v1Cache - A v1 custom cache implementation missing `has()`.
145
+ * @returns A fully v2-compatible `CacheLike` instance.
146
+ * @example
147
+ * ```ts
148
+ * const v2Cache = adaptLegacyCacheLike(myV1Cache);
149
+ * const msq = new MonSQLize({ cache: v2Cache });
150
+ * ```
151
+ */
152
+ export declare function adaptLegacyCacheLike(v1Cache: Omit<CacheLike, 'has'>): CacheLike;
153
+
154
+ /** Re-exported alias so consumers can type the return value of `createRedisCacheAdapter`. */
155
155
  export type RedisCacheAdapter = HubRedisCacheAdapter;
156
156
 
157
157
  export declare function createRedisCacheAdapter(
158
158
  redisUrlOrInstance: string | object | undefined,
159
159
  ): HubRedisCacheAdapter;
160
-
161
- export type { LockOptions, LockStats, MongoSession, TransactionOptions, TransactionStats };
162
-
163
- export type DistributedCacheInvalidatorOptions = HubDistributedInvalidatorOptions;
164
-
165
- export declare class DistributedCacheInvalidator {
166
- constructor(options: DistributedCacheInvalidatorOptions);
167
- invalidate(pattern: string): Promise<void>;
168
- getStats(): HubInvalidatorStats;
169
- close(): Promise<void>;
170
- }
171
-
172
- export type {
173
- ConnectionPoolManagerOptions,
174
- FallbackStrategy,
175
- PoolConfig,
176
- PoolHealthStatus,
177
- PoolRole,
178
- PoolStats,
179
- PoolStrategy,
180
- ResumeTokenConfig,
181
- SagaDefinition,
182
- SagaOrchestratorOptions,
183
- SagaResult,
184
- SagaStats,
185
- SagaStep,
186
- SlowQueryLogConfig,
187
- SlowQueryLogConfigInput,
188
- SlowQueryLogEntry,
189
- SlowQueryLogFilter,
190
- SlowQueryLogQueryOptions,
191
- SlowQueryLogRecord,
192
- SlowQueryLogStorageConfig,
193
- SyncChangeEvent,
194
- SyncConfig,
195
- SyncStats,
196
- SyncTargetConfig,
197
- SyncTargetHealthCheckConfig,
198
- };
199
-
200
- export declare function validateSyncConfig(config: SyncConfig): void;
201
- export declare function generateQueryHash(input: unknown): string;
202
-
203
- export type WithCacheOptions<
204
- T extends (...args: any[]) => Promise<any> = (...args: unknown[]) => Promise<unknown>,
205
- > = HubWithCacheOptions<T>;
206
-
207
- export type CacheStats = HubCacheStats;
208
-
209
- export interface WithCacheStats extends HubWithCacheStats {
210
- calls: number;
211
- totalTime: number;
212
- avgTime: number;
213
- }
214
-
215
- export interface FunctionCacheStats extends HubFunctionCacheStats {
216
- calls: number;
217
- totalTime: number;
218
- avgTime: number;
219
- }
220
-
221
- export type CachedFunction<TArgs extends unknown[] = unknown[], TResult = unknown> = HubWrappedFunction<(...args: TArgs) => Promise<TResult>> & {
222
- /** @deprecated Use `stats()`. v1 backward-compat alias. */
223
- getCacheStats(): WithCacheStats;
224
- stats(): WithCacheStats;
225
- };
226
-
227
- export interface FunctionCacheOptions extends HubFunctionCacheOptions {
228
- /** @deprecated v1 alias for `ttl`. Use `ttl` instead. */
229
- defaultTTL?: number;
230
- }
231
-
232
- export declare function withCache<TArgs extends unknown[], TResult>(
233
- fn: (...args: TArgs) => Promise<TResult>,
234
- options?: WithCacheOptions<(...args: TArgs) => Promise<TResult>>,
235
- ): CachedFunction<TArgs, TResult>;
236
-
237
- export declare class FunctionCache {
238
- constructor(cacheOrDb?: CacheLike | { getCache(): CacheLike; }, options?: FunctionCacheOptions);
239
- register(name: string, fn: (...args: unknown[]) => Promise<unknown>, options?: {
240
- ttl?: number;
241
- keyBuilder?: (...args: unknown[]) => string;
242
- namespace?: string;
243
- condition?: (result: unknown) => boolean;
244
- }): Promise<void>;
245
- execute(name: string, ...args: unknown[]): Promise<unknown>;
246
- invalidate(name: string, ...args: unknown[]): Promise<void>;
247
- invalidatePattern(pattern: string): Promise<number>;
248
- getStats(name?: string): FunctionCacheStats | Record<string, FunctionCacheStats> | null;
249
- list(): string[];
250
- resetStats(name?: string): void;
251
- clear(): void;
252
- }
253
-
160
+
161
+ export type { LockOptions, LockStats, MongoSession, TransactionOptions, TransactionStats };
162
+
163
+ export type DistributedCacheInvalidatorOptions = HubDistributedInvalidatorOptions;
164
+
165
+ export declare class DistributedCacheInvalidator {
166
+ constructor(options: DistributedCacheInvalidatorOptions);
167
+ invalidate(pattern: string): Promise<void>;
168
+ getStats(): HubInvalidatorStats;
169
+ close(): Promise<void>;
170
+ }
171
+
172
+ export type {
173
+ ConnectionPoolManagerOptions,
174
+ FallbackStrategy,
175
+ PoolConfig,
176
+ PoolHealthStatus,
177
+ PoolRole,
178
+ PoolStats,
179
+ PoolStrategy,
180
+ ResumeTokenConfig,
181
+ SagaDefinition,
182
+ SagaOrchestratorOptions,
183
+ SagaResult,
184
+ SagaStats,
185
+ SagaStep,
186
+ SlowQueryLogConfig,
187
+ SlowQueryLogConfigInput,
188
+ SlowQueryLogEntry,
189
+ SlowQueryLogFilter,
190
+ SlowQueryLogQueryOptions,
191
+ SlowQueryLogRecord,
192
+ SlowQueryLogStorageConfig,
193
+ SyncChangeEvent,
194
+ SyncConfig,
195
+ SyncStats,
196
+ SyncTargetConfig,
197
+ SyncTargetHealthCheckConfig,
198
+ };
199
+
200
+ export declare function validateSyncConfig(config: SyncConfig): void;
201
+ export declare function generateQueryHash(input: unknown): string;
202
+
203
+ export type WithCacheOptions<
204
+ T extends (...args: any[]) => Promise<any> = (...args: unknown[]) => Promise<unknown>,
205
+ > = HubWithCacheOptions<T>;
206
+
207
+ export type CacheStats = HubCacheStats;
208
+
209
+ export interface WithCacheStats extends HubWithCacheStats {
210
+ calls: number;
211
+ totalTime: number;
212
+ avgTime: number;
213
+ }
214
+
215
+ export interface FunctionCacheStats extends HubFunctionCacheStats {
216
+ calls: number;
217
+ totalTime: number;
218
+ avgTime: number;
219
+ }
220
+
221
+ export type CachedFunction<TArgs extends unknown[] = unknown[], TResult = unknown> = HubWrappedFunction<(...args: TArgs) => Promise<TResult>> & {
222
+ /** @deprecated Use `stats()`. v1 backward-compat alias. */
223
+ getCacheStats(): WithCacheStats;
224
+ stats(): WithCacheStats;
225
+ };
226
+
227
+ export interface FunctionCacheOptions extends HubFunctionCacheOptions {
228
+ /** @deprecated v1 alias for `ttl`. Use `ttl` instead. */
229
+ defaultTTL?: number;
230
+ }
231
+
232
+ export declare function withCache<TArgs extends unknown[], TResult>(
233
+ fn: (...args: TArgs) => Promise<TResult>,
234
+ options?: WithCacheOptions<(...args: TArgs) => Promise<TResult>>,
235
+ ): CachedFunction<TArgs, TResult>;
236
+
237
+ export declare class FunctionCache {
238
+ constructor(cacheOrDb?: CacheLike | { getCache(): CacheLike; }, options?: FunctionCacheOptions);
239
+ register(name: string, fn: (...args: unknown[]) => Promise<unknown>, options?: {
240
+ ttl?: number;
241
+ keyBuilder?: (...args: unknown[]) => string;
242
+ namespace?: string;
243
+ condition?: (result: unknown) => boolean;
244
+ }): Promise<void>;
245
+ execute(name: string, ...args: unknown[]): Promise<unknown>;
246
+ invalidate(name: string, ...args: unknown[]): Promise<void>;
247
+ invalidatePattern(pattern: string): Promise<number>;
248
+ getStats(name?: string): FunctionCacheStats | Record<string, FunctionCacheStats> | null;
249
+ list(): string[];
250
+ resetStats(name?: string): void;
251
+ clear(): void;
252
+ }
253
+
254
254
  export declare class Model {
255
255
  static define<TDocument = any>(name: string, definition: ModelDefinition<TDocument>): void;
256
256
  static get<TDocument = any>(name: string): RegisteredModel<TDocument> | undefined;
@@ -262,20 +262,20 @@ export declare class Model {
262
262
  }
263
263
 
264
264
  export declare class ModelInstance<TDocument = any> implements ModelInstanceContract<TDocument> {
265
- private constructor(...args: unknown[]);
266
- readonly collectionName: string;
267
- readonly dbName: string;
268
- readonly poolName?: string;
269
- readonly definition: ModelDefinition<TDocument>;
270
- getNamespace(): { iid: string; type: 'mongodb'; db: string; collection: string; };
271
- getRelations(): Record<string, RelationConfig>;
272
- getEnums(): Record<string, string>;
273
- raw(): unknown;
274
- find(query?: unknown, options?: unknown): import('./model').PopulateProxy<Array<import('./model').ModelDocument<TDocument>>>;
275
- findOne(query?: unknown, options?: unknown): import('./model').PopulateProxy<import('./model').ModelDocument<TDocument> | null>;
276
- findOneById(id: unknown, options?: unknown): import('./model').PopulateProxy<import('./model').ModelDocument<TDocument> | null>;
277
- findById(id: unknown, options?: unknown): import('./model').PopulateProxy<import('./model').ModelDocument<TDocument> | null>;
278
- findByIds(ids: unknown[], options?: unknown): import('./model').PopulateProxy<Array<import('./model').ModelDocument<TDocument>>>;
265
+ private constructor(...args: unknown[]);
266
+ readonly collectionName: string;
267
+ readonly dbName: string;
268
+ readonly poolName?: string;
269
+ readonly definition: ModelDefinition<TDocument>;
270
+ getNamespace(): { iid: string; type: 'mongodb'; db: string; collection: string; };
271
+ getRelations(): Record<string, RelationConfig>;
272
+ getEnums(): Record<string, string>;
273
+ raw(): unknown;
274
+ find(query?: unknown, options?: unknown): import('./model').PopulateProxy<Array<import('./model').ModelDocument<TDocument>>>;
275
+ findOne(query?: unknown, options?: unknown): import('./model').PopulateProxy<import('./model').ModelDocument<TDocument> | null>;
276
+ findOneById(id: unknown, options?: unknown): import('./model').PopulateProxy<import('./model').ModelDocument<TDocument> | null>;
277
+ findById(id: unknown, options?: unknown): import('./model').PopulateProxy<import('./model').ModelDocument<TDocument> | null>;
278
+ findByIds(ids: unknown[], options?: unknown): import('./model').PopulateProxy<Array<import('./model').ModelDocument<TDocument>>>;
279
279
  findPage(options: { totals: { mode: 'sync'; } & Record<string, unknown>; } & Record<string, unknown>): import('./model').PopulateProxy<{
280
280
  items: Array<import('./model').ModelDocument<TDocument>>;
281
281
  pageInfo: import('./model').ModelInstance<TDocument> extends {
@@ -296,67 +296,67 @@ export declare class ModelInstance<TDocument = any> implements ModelInstanceCont
296
296
  } ? TResult extends { totals?: infer TTotals } ? TTotals : never : never;
297
297
  meta?: import('./collection').MetaInfo;
298
298
  }>;
299
- findAndCount(query?: unknown, options?: unknown): import('./model').PopulateProxy<{ data: Array<import('./model').ModelDocument<TDocument>>; total: number; }>;
300
- count(query?: unknown, options?: unknown): Promise<number>;
299
+ findAndCount(query?: unknown, options?: unknown): import('./model').PopulateProxy<{ data: Array<import('./model').ModelDocument<TDocument>>; total: number; }>;
300
+ count(query?: unknown, options?: unknown): Promise<number>;
301
301
  insertOne(document?: unknown, options?: unknown): Promise<{ acknowledged: boolean; insertedId: any; }>;
302
302
  insertMany(documents?: unknown[], options?: unknown): Promise<InsertManyResult>;
303
303
  updateOne(filter?: unknown, update?: unknown, options?: unknown): Promise<UpdateResult>;
304
304
  updateMany(filter?: unknown, update?: unknown, options?: unknown): Promise<UpdateResult>;
305
305
  replaceOne(filter?: unknown, replacement?: unknown, options?: unknown): Promise<UpdateResult>;
306
- findOneAndUpdate(filter?: unknown, update?: unknown, options?: unknown): Promise<TDocument | null>;
307
- findOneAndDelete(filter?: unknown, options?: unknown): Promise<TDocument | null>;
308
- upsertOne(filter?: unknown, update?: unknown, options?: unknown): Promise<UpdateResult>;
309
- deleteOne(filter?: unknown, options?: unknown): Promise<DeleteResult>;
310
- deleteMany(filter?: unknown, options?: unknown): Promise<DeleteResult>;
311
- createIndex(keys: unknown, options?: unknown): Promise<IndexCreateResult>;
312
- createIndexes(specs: Array<{ key: unknown; } & Record<string, unknown>>): Promise<string[]>;
313
- listIndexes(): Promise<Record<string, unknown>[]>;
314
- dropIndex(name: string): Promise<unknown>;
315
- dropIndexes(): Promise<unknown>;
316
- prewarmBookmarks(keyDims?: unknown, pages?: number[]): Promise<BookmarkPrewarmResult>;
317
- listBookmarks(keyDims?: unknown): Promise<BookmarkListResult>;
318
- clearBookmarks(keyDims?: unknown): Promise<BookmarkClearResult>;
319
- distinct(key: string, query?: unknown, options?: unknown): Promise<unknown[]>;
320
- aggregate(pipeline?: unknown[], options?: unknown): Promise<unknown[]>;
321
- stream(query?: unknown, options?: unknown): NodeJS.ReadableStream;
322
- explain(query?: unknown, options?: unknown): Promise<unknown>;
323
- invalidate(op?: 'find' | 'findOne' | 'count' | 'findPage' | 'aggregate' | 'distinct'): Promise<number>;
324
- dropCollection(): Promise<boolean>;
325
- createCollection(name?: string, options?: Record<string, unknown>): Promise<boolean>;
326
- createView(name: string, source: string, pipeline?: unknown[]): Promise<boolean>;
327
- indexStats(): Promise<unknown[]>;
328
- setValidator(validator: unknown, options?: { validationLevel?: string; validationAction?: string }): Promise<{ ok: number; collection: string }>;
329
- setValidationLevel(level: 'off' | 'moderate' | 'strict' | string): Promise<{ ok: number; validationLevel: string }>;
330
- setValidationAction(action: 'error' | 'warn' | string): Promise<{ ok: number; validationAction: string }>;
331
- getValidator(): Promise<{ validator: Record<string, unknown> | null; validationLevel: string; validationAction: string }>;
332
- stats(options?: { scale?: number }): Promise<{ ns: string; count: number; size: number; storageSize: number; totalIndexSize: number; nindexes: number; avgObjSize?: number; scaleFactor?: number }>;
333
- renameCollection(newName: string, options?: { dropTarget?: boolean }): Promise<{ renamed: boolean; from: string; to: string }>;
334
- collMod(modifications: Record<string, unknown>): Promise<Record<string, unknown>>;
335
- convertToCapped(size: number, options?: { max?: number }): Promise<{ ok: number; collection: string; capped: boolean; size: number }>;
336
- watch(pipeline?: unknown[], options?: unknown): import('mongodb').ChangeStream;
337
- validate(document?: unknown): import('./model').ValidationResult;
338
- findOneAndReplace(filter?: unknown, replacement?: unknown, options?: unknown): Promise<TDocument | null>;
306
+ findOneAndUpdate(filter?: unknown, update?: unknown, options?: unknown): Promise<TDocument | null>;
307
+ findOneAndDelete(filter?: unknown, options?: unknown): Promise<TDocument | null>;
308
+ upsertOne(filter?: unknown, update?: unknown, options?: unknown): Promise<UpdateResult>;
309
+ deleteOne(filter?: unknown, options?: unknown): Promise<DeleteResult>;
310
+ deleteMany(filter?: unknown, options?: unknown): Promise<DeleteResult>;
311
+ createIndex(keys: unknown, options?: unknown): Promise<IndexCreateResult>;
312
+ createIndexes(specs: Array<{ key: unknown; } & Record<string, unknown>>): Promise<string[]>;
313
+ listIndexes(): Promise<Record<string, unknown>[]>;
314
+ dropIndex(name: string): Promise<unknown>;
315
+ dropIndexes(): Promise<unknown>;
316
+ prewarmBookmarks(keyDims?: unknown, pages?: number[]): Promise<BookmarkPrewarmResult>;
317
+ listBookmarks(keyDims?: unknown): Promise<BookmarkListResult>;
318
+ clearBookmarks(keyDims?: unknown): Promise<BookmarkClearResult>;
319
+ distinct(key: string, query?: unknown, options?: unknown): Promise<unknown[]>;
320
+ aggregate(pipeline?: unknown[], options?: unknown): Promise<unknown[]>;
321
+ stream(query?: unknown, options?: unknown): NodeJS.ReadableStream;
322
+ explain(query?: unknown, options?: unknown): Promise<unknown>;
323
+ invalidate(op?: 'find' | 'findOne' | 'count' | 'findPage' | 'aggregate' | 'distinct'): Promise<number>;
324
+ dropCollection(): Promise<boolean>;
325
+ createCollection(name?: string, options?: Record<string, unknown>): Promise<boolean>;
326
+ createView(name: string, source: string, pipeline?: unknown[]): Promise<boolean>;
327
+ indexStats(): Promise<unknown[]>;
328
+ setValidator(validator: unknown, options?: { validationLevel?: string; validationAction?: string }): Promise<{ ok: number; collection: string }>;
329
+ setValidationLevel(level: 'off' | 'moderate' | 'strict' | string): Promise<{ ok: number; validationLevel: string }>;
330
+ setValidationAction(action: 'error' | 'warn' | string): Promise<{ ok: number; validationAction: string }>;
331
+ getValidator(): Promise<{ validator: Record<string, unknown> | null; validationLevel: string; validationAction: string }>;
332
+ stats(options?: { scale?: number }): Promise<{ ns: string; count: number; size: number; storageSize: number; totalIndexSize: number; nindexes: number; avgObjSize?: number; scaleFactor?: number }>;
333
+ renameCollection(newName: string, options?: { dropTarget?: boolean }): Promise<{ renamed: boolean; from: string; to: string }>;
334
+ collMod(modifications: Record<string, unknown>): Promise<Record<string, unknown>>;
335
+ convertToCapped(size: number, options?: { max?: number }): Promise<{ ok: number; collection: string; capped: boolean; size: number }>;
336
+ watch(pipeline?: unknown[], options?: unknown): import('mongodb').ChangeStream;
337
+ validate(document?: unknown): import('./model').ValidationResult;
338
+ findOneAndReplace(filter?: unknown, replacement?: unknown, options?: unknown): Promise<TDocument | null>;
339
339
  incrementOne(filter?: unknown, field?: string | Record<string, number>, increment?: number, options?: unknown): Promise<IncrementOneResult<TDocument>>;
340
- findWithDeleted(query?: unknown, options?: unknown): import('./model').PopulateProxy<Array<import('./model').ModelDocument<TDocument>>>;
341
- findOnlyDeleted(query?: unknown, options?: unknown): import('./model').PopulateProxy<Array<import('./model').ModelDocument<TDocument>>>;
342
- findOneWithDeleted(query?: unknown, options?: unknown): import('./model').PopulateProxy<import('./model').ModelDocument<TDocument> | null>;
340
+ findWithDeleted(query?: unknown, options?: unknown): import('./model').PopulateProxy<Array<import('./model').ModelDocument<TDocument>>>;
341
+ findOnlyDeleted(query?: unknown, options?: unknown): import('./model').PopulateProxy<Array<import('./model').ModelDocument<TDocument>>>;
342
+ findOneWithDeleted(query?: unknown, options?: unknown): import('./model').PopulateProxy<import('./model').ModelDocument<TDocument> | null>;
343
343
  restore(filter?: unknown, options?: unknown): Promise<import('./model').RestoreResult>;
344
344
  restoreMany(filter?: unknown, options?: unknown): Promise<import('./model').RestoreResult>;
345
- forceDelete(filter?: unknown, options?: unknown): Promise<DeleteResult>;
346
- forceDeleteMany(filter?: unknown, options?: unknown): Promise<DeleteResult>;
347
- findOneOnlyDeleted(query?: unknown, options?: unknown): import('./model').PopulateProxy<import('./model').ModelDocument<TDocument> | null>;
348
- countWithDeleted(query?: unknown, options?: unknown): Promise<number>;
349
- countOnlyDeleted(query?: unknown, options?: unknown): Promise<number>;
345
+ forceDelete(filter?: unknown, options?: unknown): Promise<DeleteResult>;
346
+ forceDeleteMany(filter?: unknown, options?: unknown): Promise<DeleteResult>;
347
+ findOneOnlyDeleted(query?: unknown, options?: unknown): import('./model').PopulateProxy<import('./model').ModelDocument<TDocument> | null>;
348
+ countWithDeleted(query?: unknown, options?: unknown): Promise<number>;
349
+ countOnlyDeleted(query?: unknown, options?: unknown): Promise<number>;
350
350
  insertBatch(docs: unknown[], options?: unknown): Promise<InsertBatchResult>;
351
351
  updateBatch(filter?: unknown, update?: unknown, options?: unknown): Promise<UpdateBatchResult>;
352
- deleteBatch(filter?: unknown, options?: unknown): Promise<DeleteBatchResult>;
353
- }
354
-
355
- export declare const expr: ExpressionFunction;
356
- export declare const createExpression: ExpressionFunction;
357
- export declare function isExpressionObject(value: unknown): value is ExpressionObject;
358
- export declare function hasExpressionInObject(value: unknown): boolean;
359
- export declare function hasExpressionInPipeline(pipeline: unknown): boolean;
360
- /** Compile expression objects in a MongoDB pipeline into real operators. */
361
- export declare function compilePipelineExpressions<TPipeline>(pipeline: TPipeline): TPipeline;
362
-
352
+ deleteBatch(filter?: unknown, options?: unknown): Promise<DeleteBatchResult>;
353
+ }
354
+
355
+ export declare const expr: ExpressionFunction;
356
+ export declare const createExpression: ExpressionFunction;
357
+ export declare function isExpressionObject(value: unknown): value is ExpressionObject;
358
+ export declare function hasExpressionInObject(value: unknown): boolean;
359
+ export declare function hasExpressionInPipeline(pipeline: unknown): boolean;
360
+ /** Compile expression objects in a MongoDB pipeline into real operators. */
361
+ export declare function compilePipelineExpressions<TPipeline>(pipeline: TPipeline): TPipeline;
362
+