monsqlize 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -5
- package/README.md +35 -19
- package/changelogs/README.md +8 -4
- package/changelogs/v2.0.0.md +1 -1
- package/changelogs/v2.0.3.md +58 -0
- package/dist/cjs/index.cjs +648 -192
- package/dist/cjs/transaction/Transaction.cjs +88 -3
- package/dist/cjs/transaction/TransactionManager.cjs +135 -11
- package/dist/esm/index.mjs +643 -187
- package/dist/types/collection.d.ts +5 -3
- package/dist/types/model.d.ts +175 -175
- package/dist/types/mongodb.d.ts +8 -1
- package/dist/types/monsqlize.d.ts +28 -3
- package/dist/types/pool.d.ts +1 -1
- package/dist/types/runtime.d.ts +31 -7
- package/dist/types/transaction.d.ts +12 -0
- package/package.json +22 -22
package/dist/types/pool.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export declare class ConnectionPoolManager {
|
|
|
68
68
|
removePool(name: string): Promise<void>;
|
|
69
69
|
getPool(name: string): unknown | null;
|
|
70
70
|
getPoolNames(): string[];
|
|
71
|
-
selectPool(operation: string, options?: { pool?: string; tags?: string[]; databaseName?: string; }): {
|
|
71
|
+
selectPool(operation: string, options?: { pool?: string; tags?: string[]; databaseName?: string; poolPreference?: { role?: string; tags?: string[]; }; }): {
|
|
72
72
|
name: string;
|
|
73
73
|
client: unknown;
|
|
74
74
|
db: (name?: string) => unknown;
|
package/dist/types/runtime.d.ts
CHANGED
|
@@ -9,11 +9,16 @@ import type { ResumeTokenConfig, SyncChangeEvent, SyncConfig, SyncStats, SyncTar
|
|
|
9
9
|
import type { MongoSession, TransactionOptions, TransactionStats } from './transaction';
|
|
10
10
|
import type {
|
|
11
11
|
CacheLike as HubCacheLike,
|
|
12
|
+
CacheRemainingTtl as HubCacheRemainingTtl,
|
|
13
|
+
CacheSetOptions as HubCacheSetOptions,
|
|
12
14
|
CacheStats as HubCacheStats,
|
|
13
15
|
LockManager as HubCacheLockLike,
|
|
14
16
|
MemoryCacheOptions as HubMemoryCacheOptions,
|
|
15
17
|
} from 'cache-hub';
|
|
16
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
RedisCacheAdapter as HubRedisCacheAdapter,
|
|
20
|
+
RedisCacheAdapterOptions as HubRedisCacheAdapterOptions,
|
|
21
|
+
} from 'cache-hub/redis';
|
|
17
22
|
import type {
|
|
18
23
|
DistributedInvalidatorOptions as HubDistributedInvalidatorOptions,
|
|
19
24
|
InvalidatorStats as HubInvalidatorStats,
|
|
@@ -44,6 +49,8 @@ export declare class Logger {
|
|
|
44
49
|
|
|
45
50
|
export type CacheLockLike = HubCacheLockLike;
|
|
46
51
|
export type CacheLike = HubCacheLike;
|
|
52
|
+
export type CacheRemainingTtl = HubCacheRemainingTtl;
|
|
53
|
+
export type CacheSetOptions = HubCacheSetOptions;
|
|
47
54
|
export type MemoryCacheOptions = HubMemoryCacheOptions;
|
|
48
55
|
|
|
49
56
|
/**
|
|
@@ -80,15 +87,27 @@ export interface MultiLevelCacheOptions {
|
|
|
80
87
|
local?: MemoryCacheOptions;
|
|
81
88
|
remote?: CacheLike | (MemoryCacheOptions & { timeoutMs?: number });
|
|
82
89
|
policy?: MultiLevelCachePolicy;
|
|
83
|
-
publish?:
|
|
90
|
+
publish?: MultiLevelPublish;
|
|
84
91
|
}
|
|
85
92
|
|
|
93
|
+
export type MultiLevelInvalidationMessage = {
|
|
94
|
+
type: 'delPattern';
|
|
95
|
+
pattern: string;
|
|
96
|
+
ts: number;
|
|
97
|
+
} | {
|
|
98
|
+
type: 'invalidateTag';
|
|
99
|
+
tag: string;
|
|
100
|
+
ts: number;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export type MultiLevelPublish = (msg: MultiLevelInvalidationMessage) => void;
|
|
104
|
+
|
|
86
105
|
export declare class MemoryCache {
|
|
87
106
|
constructor(options?: MemoryCacheOptions);
|
|
88
107
|
setLockManager(lockManager: CacheLockLike): void;
|
|
89
108
|
getLockManager(): CacheLockLike | null;
|
|
90
109
|
get<T = unknown>(key: string): T | undefined;
|
|
91
|
-
set(key: string, value: unknown, ttl?: number): void;
|
|
110
|
+
set(key: string, value: unknown, ttl?: number, options?: CacheSetOptions): void;
|
|
92
111
|
del(key: string): boolean;
|
|
93
112
|
exists(key: string): boolean;
|
|
94
113
|
has(key: string): boolean;
|
|
@@ -98,6 +117,8 @@ export declare class MemoryCache {
|
|
|
98
117
|
clear(): void;
|
|
99
118
|
keys(pattern?: string): string[];
|
|
100
119
|
delPattern(pattern: string): number;
|
|
120
|
+
getRemainingTtl(key: string): CacheRemainingTtl | undefined;
|
|
121
|
+
getRemainingTtlMany(keys: string[]): Record<string, CacheRemainingTtl>;
|
|
101
122
|
getStats(): CacheStats;
|
|
102
123
|
resetStats(): void;
|
|
103
124
|
invalidateByTag(tag: string): void;
|
|
@@ -111,10 +132,11 @@ export declare class MultiLevelCache {
|
|
|
111
132
|
writePolicy?: 'both' | 'local-first-async-remote';
|
|
112
133
|
backfillOnRemoteHit?: boolean;
|
|
113
134
|
remoteTimeoutMs?: number;
|
|
114
|
-
publish?:
|
|
135
|
+
publish?: MultiLevelPublish;
|
|
136
|
+
remoteInvalidationErrors?: 'ignore' | 'throw';
|
|
115
137
|
});
|
|
116
138
|
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
117
|
-
set(key: string, value: unknown, ttl?: number): Promise<void>;
|
|
139
|
+
set(key: string, value: unknown, ttl?: number, options?: CacheSetOptions): Promise<void>;
|
|
118
140
|
del(key: string): Promise<boolean>;
|
|
119
141
|
exists(key: string): Promise<boolean>;
|
|
120
142
|
has(key: string): Promise<boolean>;
|
|
@@ -125,14 +147,14 @@ export declare class MultiLevelCache {
|
|
|
125
147
|
delPattern(pattern: string): Promise<number>;
|
|
126
148
|
keys(pattern?: string): Promise<string[]>;
|
|
127
149
|
invalidateByTag(tag: string): void | Promise<void>;
|
|
128
|
-
setPublish(publish:
|
|
150
|
+
setPublish(publish: MultiLevelPublish): void;
|
|
129
151
|
setLockManager(lockManager: CacheLockLike): void;
|
|
130
152
|
getStats(): CacheStats;
|
|
131
153
|
resetStats(): void;
|
|
132
154
|
destroy(): void;
|
|
133
155
|
}
|
|
134
156
|
|
|
135
|
-
export type RedisCacheAdapterOptions =
|
|
157
|
+
export type RedisCacheAdapterOptions = HubRedisCacheAdapterOptions;
|
|
136
158
|
export type RedisLike = object;
|
|
137
159
|
|
|
138
160
|
/**
|
|
@@ -156,11 +178,13 @@ export type RedisCacheAdapter = HubRedisCacheAdapter;
|
|
|
156
178
|
|
|
157
179
|
export declare function createRedisCacheAdapter(
|
|
158
180
|
redisUrlOrInstance: string | object | undefined,
|
|
181
|
+
options?: RedisCacheAdapterOptions,
|
|
159
182
|
): HubRedisCacheAdapter;
|
|
160
183
|
|
|
161
184
|
export type { LockOptions, LockStats, MongoSession, TransactionOptions, TransactionStats };
|
|
162
185
|
|
|
163
186
|
export type DistributedCacheInvalidatorOptions = HubDistributedInvalidatorOptions;
|
|
187
|
+
export type DistributedCacheInvalidatorStats = HubInvalidatorStats;
|
|
164
188
|
|
|
165
189
|
export declare class DistributedCacheInvalidator {
|
|
166
190
|
constructor(options: DistributedCacheInvalidatorOptions);
|
|
@@ -46,8 +46,15 @@ export interface TransactionStats {
|
|
|
46
46
|
totalTransactions: number;
|
|
47
47
|
successfulTransactions: number;
|
|
48
48
|
failedTransactions: number;
|
|
49
|
+
readOnlyTransactions: number;
|
|
50
|
+
writeTransactions: number;
|
|
49
51
|
activeTransactions: number;
|
|
50
52
|
averageDuration: number;
|
|
53
|
+
p95Duration: number;
|
|
54
|
+
p99Duration: number;
|
|
55
|
+
successRate: string;
|
|
56
|
+
readOnlyRatio: string;
|
|
57
|
+
sampleCount: number;
|
|
51
58
|
}
|
|
52
59
|
|
|
53
60
|
/**
|
|
@@ -80,6 +87,7 @@ export declare class Transaction {
|
|
|
80
87
|
logger?: LoggerLike | null;
|
|
81
88
|
lockManager?: CacheLockManager | null;
|
|
82
89
|
timeout?: number;
|
|
90
|
+
transactionOptions?: Record<string, unknown>;
|
|
83
91
|
});
|
|
84
92
|
/** Begin the transaction (starts the MongoDB session transaction). */
|
|
85
93
|
start(): Promise<void>;
|
|
@@ -118,6 +126,10 @@ export declare class TransactionManager {
|
|
|
118
126
|
maxRetries?: number;
|
|
119
127
|
retryDelay?: number;
|
|
120
128
|
retryBackoff?: number;
|
|
129
|
+
defaultReadConcern?: TransactionOptions['readConcern'];
|
|
130
|
+
defaultWriteConcern?: TransactionOptions['writeConcern'];
|
|
131
|
+
defaultReadPreference?: TransactionOptions['readPreference'];
|
|
132
|
+
maxStatsSamples?: number;
|
|
121
133
|
});
|
|
122
134
|
/** Open a new transaction session. */
|
|
123
135
|
startSession(options?: TransactionOptions): Promise<Transaction>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monsqlize",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "TypeScript-native MongoDB ODM with multi-level caching (cache-hub), distributed locks, Saga orchestration, unified expression system (122 operators), connection pool management, ChangeStream sync, slow-query logging, and full v1 API compatibility",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/cjs/index.cjs",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"dist/**/*.cjs",
|
|
19
19
|
"dist/**/*.mjs",
|
|
20
20
|
"dist/**/*.d.ts",
|
|
21
|
+
"changelogs/v2.0.3.md",
|
|
21
22
|
"changelogs/v2.0.2.md",
|
|
22
23
|
"changelogs/v2.0.1.md",
|
|
23
24
|
"changelogs/v2.0.0.md",
|
|
@@ -53,6 +54,13 @@
|
|
|
53
54
|
"access": "public",
|
|
54
55
|
"registry": "https://registry.npmjs.org/"
|
|
55
56
|
},
|
|
57
|
+
"config": {
|
|
58
|
+
"mongodbMemoryServer": {
|
|
59
|
+
"downloadDir": ".cache/mongodb-memory-server/binaries",
|
|
60
|
+
"preferGlobalPath": "false",
|
|
61
|
+
"version": "7.0.14"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
56
64
|
"engines": {
|
|
57
65
|
"node": ">=18.0.0"
|
|
58
66
|
},
|
|
@@ -61,43 +69,33 @@
|
|
|
61
69
|
"check:sizes:strict": "node scripts/check-file-sizes.cjs --strict",
|
|
62
70
|
"build": "node scripts/build-p1.cjs",
|
|
63
71
|
"build:tests": "node scripts/compile-tests.cjs",
|
|
64
|
-
"lint": "eslint . --ignore-pattern .generated/** --ignore-pattern dist/**",
|
|
65
|
-
"lint:fix": "eslint . --fix --ignore-pattern .generated/** --ignore-pattern dist/**",
|
|
72
|
+
"lint": "eslint . --ignore-pattern .generated/** --ignore-pattern dist/** --ignore-pattern .devcodex/**",
|
|
73
|
+
"lint:fix": "eslint . --fix --ignore-pattern .generated/** --ignore-pattern dist/** --ignore-pattern .devcodex/**",
|
|
66
74
|
"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",
|
|
67
75
|
"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",
|
|
68
76
|
"probe:server-matrix": "node scripts/validation/probe-memory-server-matrix.cjs",
|
|
69
77
|
"test:server-matrix": "node scripts/validation/run-memory-server-matrix.cjs",
|
|
70
78
|
"test:real-env:private": "node scripts/validation/run-private-real-env-checks.cjs",
|
|
71
|
-
"test:examples": "npm run build && tsc -p tsconfig.examples.json && node
|
|
79
|
+
"test:examples": "npm run build && tsc -p tsconfig.examples.json && node scripts/run-examples.cjs",
|
|
72
80
|
"test:performance": "npm run build && npm run build:tests && node .generated/test-dist/test/performance/baselines/function-cache.benchmark.js",
|
|
73
81
|
"test:unit": "npm run build && npm run build:tests && node --test .generated/test-dist/test/unit/expression/expression.test.js .generated/test-dist/test/unit/expression/operators.test.js .generated/test-dist/test/unit/errors/errors.test.js .generated/test-dist/test/unit/management/management.test.js .generated/test-dist/test/unit/writes/batch.test.js .generated/test-dist/test/unit/cache/cache.test.js .generated/test-dist/test/unit/cache/cache-refactor-guard.test.js .generated/test-dist/test/unit/coverage/core-helpers.test.js .generated/test-dist/test/unit/function-cache/function-cache.test.js .generated/test-dist/test/unit/model/model-registry.test.js .generated/test-dist/test/unit/lock/lock.test.js .generated/test-dist/test/unit/transaction/transaction.test.js .generated/test-dist/test/unit/pool/pool.test.js .generated/test-dist/test/unit/runtime/runtime-compat.test.js .generated/test-dist/test/unit/sync/sync.test.js .generated/test-dist/test/unit/slow-query-log/slow-query-log.test.js .generated/test-dist/test/unit/slow-query-log/slow-query-log-behavior.test.js .generated/test-dist/test/unit/saga/saga.test.js .generated/test-dist/test/unit/count-queue/count-queue.test.js .generated/test-dist/test/unit/model/model-softdelete-versioning.test.js .generated/test-dist/test/unit/function-cache/function-cache-behavior.test.js .generated/test-dist/test/unit/saga/saga-behavior.test.js .generated/test-dist/test/unit/lock/lock-distributed.test.js .generated/test-dist/test/unit/coverage/capability-wiring.test.js .generated/test-dist/test/unit/pool/pool-stats.test.js .generated/test-dist/test/unit/coverage/pure-functions.test.js",
|
|
74
82
|
"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",
|
|
75
83
|
"test:refactor-guard": "npm run build && npm run build:tests && node --test --test-concurrency=1 .generated/test-dist/test/compatibility/exports/exports.test.js .generated/test-dist/test/integration/model/model-features.test.js .generated/test-dist/test/integration/runtime/runtime-core-regression.test.js .generated/test-dist/test/integration/sync/sync.test.js",
|
|
76
84
|
"test:refactor-guard:cache": "npm run build && npm run build:tests && node --test .generated/test-dist/test/unit/cache/cache-refactor-guard.test.js",
|
|
77
|
-
"test:coverage": "npm run build && npm run build:tests && c8 --reporter=text --reporter=lcov --reporter=json-summary --check-coverage --lines
|
|
85
|
+
"test:coverage": "npm run build && npm run build:tests && c8 --reporter=text --reporter=lcov --reporter=json-summary --include \".generated/test-dist/dist/cjs/**/*.cjs\" --check-coverage --lines 90 --statements 90 --functions 90 --branches 90 node test/run-tests.cjs",
|
|
86
|
+
"test:audit": "npm audit --omit=dev --registry=https://registry.npmjs.org/",
|
|
78
87
|
"test": "npm run build && npm run build:tests && node test/run-tests.cjs",
|
|
79
88
|
"type-check": "npm run build && tsc -p tsconfig.json --noEmit && tsd --files test/types/root-import.test-d.ts --files test/types/cache-usage.test-d.ts --files test/types/model-usage.test-d.ts --files test/types/pool-usage.test-d.ts --files test/types/sync-usage.test-d.ts --files test/types/slow-query-log-usage.test-d.ts --files test/types/saga-usage.test-d.ts",
|
|
80
89
|
"check:test-language": "node scripts/check-test-language.cjs",
|
|
81
|
-
"
|
|
82
|
-
"verify:
|
|
90
|
+
"check:docs-examples": "node scripts/validation/check-doc-example-matrix.cjs",
|
|
91
|
+
"verify:fast": "npm run lint && npm run check:docs-examples && npm run type-check && npm run check:sizes:strict && npm run test:runtime && npm run test:compatibility && npm run test:refactor-guard && npm run test:refactor-guard:cache",
|
|
92
|
+
"verify:full": "npm run lint && npm run check:docs-examples && npm run type-check && npm run check:sizes:strict && npm run test:examples && npm run test:server-matrix",
|
|
83
93
|
"verify:release": "npm run verify:full && npm run test:real-env:private",
|
|
84
94
|
"verify": "npm run verify:full",
|
|
85
95
|
"release:preflight": "node scripts/release-preflight.cjs",
|
|
86
96
|
"prepublishOnly": "npm run release:preflight",
|
|
87
97
|
"release:publish": "npm run release:preflight && npm publish --ignore-scripts",
|
|
88
|
-
"postpublish": "echo '
|
|
89
|
-
},
|
|
90
|
-
"peerDependenciesMeta": {
|
|
91
|
-
"ioredis": {
|
|
92
|
-
"optional": true
|
|
93
|
-
},
|
|
94
|
-
"ssh2": {
|
|
95
|
-
"optional": true
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
"optionalDependencies": {
|
|
99
|
-
"ioredis": "5.8.2",
|
|
100
|
-
"ssh2": "1.17.0"
|
|
98
|
+
"postpublish": "echo 'Publish succeeded. Create GitHub Release: https://github.com/vextjs/monSQLize/releases/new?tag=v'$npm_package_version"
|
|
101
99
|
},
|
|
102
100
|
"devDependencies": {
|
|
103
101
|
"@eslint/js": "9.39.4",
|
|
@@ -114,8 +112,10 @@
|
|
|
114
112
|
},
|
|
115
113
|
"dependencies": {
|
|
116
114
|
"async-lock": "1.4.1",
|
|
117
|
-
"cache-hub": "
|
|
115
|
+
"cache-hub": "2.2.4",
|
|
116
|
+
"ioredis": "5.8.2",
|
|
118
117
|
"mongodb": "6.21.0",
|
|
119
|
-
"schema-dsl": "2.0.
|
|
118
|
+
"schema-dsl": "2.0.8",
|
|
119
|
+
"ssh2": "1.17.0"
|
|
120
120
|
}
|
|
121
121
|
}
|