monsqlize 1.3.1 → 2.0.0
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 +415 -146
- package/LICENSE +201 -21
- package/README.md +537 -928
- package/changelogs/README.md +160 -0
- package/changelogs/v2.0.0.md +222 -0
- package/dist/cjs/index.cjs +10600 -0
- package/dist/cjs/mongodb/common/transaction-aware.cjs +10 -0
- package/dist/cjs/transaction/CacheLockManager.cjs +100 -0
- package/dist/cjs/transaction/Transaction.cjs +158 -0
- package/dist/cjs/transaction/TransactionManager.cjs +298 -0
- package/dist/esm/index.mjs +10650 -0
- package/dist/types/base.d.ts +81 -0
- package/dist/types/collection.d.ts +1031 -0
- package/dist/types/expression.d.ts +115 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/lock.d.ts +74 -0
- package/dist/types/model.d.ts +526 -0
- package/dist/types/mongodb.d.ts +49 -0
- package/dist/types/monsqlize.d.ts +491 -0
- package/dist/types/pool.d.ts +84 -0
- package/dist/types/runtime.d.ts +362 -0
- package/dist/types/saga.d.ts +143 -0
- package/dist/types/slow-query-log.d.ts +126 -0
- package/dist/types/sync.d.ts +103 -0
- package/dist/types/transaction.d.ts +132 -0
- package/package.json +69 -67
- package/index.d.ts +0 -1289
- package/lib/cache.js +0 -491
- package/lib/common/cursor.js +0 -58
- package/lib/common/docs-urls.js +0 -72
- package/lib/common/index-options.js +0 -222
- package/lib/common/log.js +0 -60
- package/lib/common/namespace.js +0 -21
- package/lib/common/normalize.js +0 -33
- package/lib/common/page-result.js +0 -42
- package/lib/common/runner.js +0 -56
- package/lib/common/server-features.js +0 -231
- package/lib/common/shape-builders.js +0 -26
- package/lib/common/validation.js +0 -112
- package/lib/connect.js +0 -76
- package/lib/constants.js +0 -54
- package/lib/count-queue.js +0 -187
- package/lib/distributed-cache-invalidator.js +0 -259
- package/lib/errors.js +0 -167
- package/lib/index.js +0 -461
- package/lib/infrastructure/ssh-tunnel-ssh2.js +0 -211
- package/lib/infrastructure/ssh-tunnel.js +0 -40
- package/lib/infrastructure/uri-parser.js +0 -35
- package/lib/lock/Lock.js +0 -66
- package/lib/lock/errors.js +0 -27
- package/lib/lock/index.js +0 -12
- package/lib/logger.js +0 -224
- package/lib/model/examples/test.js +0 -114
- package/lib/mongodb/common/accessor-helpers.js +0 -58
- package/lib/mongodb/common/agg-pipeline.js +0 -32
- package/lib/mongodb/common/iid.js +0 -27
- package/lib/mongodb/common/lexicographic-expr.js +0 -52
- package/lib/mongodb/common/shape.js +0 -31
- package/lib/mongodb/common/sort.js +0 -38
- package/lib/mongodb/common/transaction-aware.js +0 -24
- package/lib/mongodb/connect.js +0 -233
- package/lib/mongodb/index.js +0 -591
- package/lib/mongodb/management/admin-ops.js +0 -199
- package/lib/mongodb/management/bookmark-ops.js +0 -166
- package/lib/mongodb/management/cache-ops.js +0 -49
- package/lib/mongodb/management/collection-ops.js +0 -386
- package/lib/mongodb/management/database-ops.js +0 -201
- package/lib/mongodb/management/index-ops.js +0 -474
- package/lib/mongodb/management/index.js +0 -16
- package/lib/mongodb/management/namespace.js +0 -30
- package/lib/mongodb/management/validation-ops.js +0 -267
- package/lib/mongodb/queries/aggregate.js +0 -142
- package/lib/mongodb/queries/chain.js +0 -630
- package/lib/mongodb/queries/count.js +0 -98
- package/lib/mongodb/queries/distinct.js +0 -77
- package/lib/mongodb/queries/find-and-count.js +0 -192
- package/lib/mongodb/queries/find-by-ids.js +0 -235
- package/lib/mongodb/queries/find-one-by-id.js +0 -170
- package/lib/mongodb/queries/find-one.js +0 -70
- package/lib/mongodb/queries/find-page.js +0 -577
- package/lib/mongodb/queries/find.js +0 -170
- package/lib/mongodb/queries/index.js +0 -50
- package/lib/mongodb/queries/watch.js +0 -537
- package/lib/mongodb/writes/delete-many.js +0 -190
- package/lib/mongodb/writes/delete-one.js +0 -182
- package/lib/mongodb/writes/find-one-and-delete.js +0 -202
- package/lib/mongodb/writes/find-one-and-replace.js +0 -238
- package/lib/mongodb/writes/find-one-and-update.js +0 -239
- package/lib/mongodb/writes/increment-one.js +0 -252
- package/lib/mongodb/writes/index.js +0 -41
- package/lib/mongodb/writes/insert-batch.js +0 -507
- package/lib/mongodb/writes/insert-many.js +0 -227
- package/lib/mongodb/writes/insert-one.js +0 -180
- package/lib/mongodb/writes/replace-one.js +0 -215
- package/lib/mongodb/writes/result-handler.js +0 -236
- package/lib/mongodb/writes/update-many.js +0 -221
- package/lib/mongodb/writes/update-one.js +0 -223
- package/lib/mongodb/writes/upsert-one.js +0 -206
- package/lib/multi-level-cache.js +0 -189
- package/lib/operators.js +0 -330
- package/lib/redis-cache-adapter.js +0 -237
- package/lib/slow-query-log/base-storage.js +0 -69
- package/lib/slow-query-log/batch-queue.js +0 -96
- package/lib/slow-query-log/config-manager.js +0 -195
- package/lib/slow-query-log/index.js +0 -237
- package/lib/slow-query-log/mongodb-storage.js +0 -323
- package/lib/slow-query-log/query-hash.js +0 -38
- package/lib/transaction/CacheLockManager.js +0 -161
- package/lib/transaction/DistributedCacheLockManager.js +0 -474
- package/lib/transaction/Transaction.js +0 -314
- package/lib/transaction/TransactionManager.js +0 -266
- package/lib/transaction/index.js +0 -10
- package/lib/utils/objectid-converter.js +0 -566
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ChangeStreamDocument, Document, MongoClientOptions } from 'mongodb';
|
|
2
|
+
|
|
3
|
+
import type { LoggerLike } from './base';
|
|
4
|
+
|
|
5
|
+
export type SyncChangeEvent<TDocument extends Document = Document> = ChangeStreamDocument<TDocument> & {
|
|
6
|
+
_id?: unknown;
|
|
7
|
+
operationType: 'insert' | 'update' | 'replace' | 'delete';
|
|
8
|
+
ns: {
|
|
9
|
+
db: string;
|
|
10
|
+
coll: string;
|
|
11
|
+
};
|
|
12
|
+
documentKey?: Record<string, unknown>;
|
|
13
|
+
fullDocument?: TDocument;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export interface SyncTargetHealthCheckConfig {
|
|
17
|
+
/** Whether to enable health checks; defaults to true. */
|
|
18
|
+
enabled?: boolean;
|
|
19
|
+
/** Health check interval in milliseconds; defaults to 30000. */
|
|
20
|
+
interval?: number;
|
|
21
|
+
/** Timeout for a single health check in milliseconds; defaults to 5000. */
|
|
22
|
+
timeout?: number;
|
|
23
|
+
/** Number of retries after failure; defaults to 3. */
|
|
24
|
+
retries?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SyncTargetConfig {
|
|
28
|
+
name: string;
|
|
29
|
+
uri?: string;
|
|
30
|
+
pool?: string;
|
|
31
|
+
databaseName?: string;
|
|
32
|
+
collections?: string[];
|
|
33
|
+
options?: MongoClientOptions;
|
|
34
|
+
apply?: (event: SyncChangeEvent, document: Record<string, unknown> | undefined) => Promise<void>;
|
|
35
|
+
/** Target node health check configuration. @since v1.0.8 */
|
|
36
|
+
healthCheck?: SyncTargetHealthCheckConfig;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ResumeTokenRedisLike {
|
|
40
|
+
get(key: string): Promise<string | null> | string | null;
|
|
41
|
+
set(key: string, value: string): Promise<unknown> | unknown;
|
|
42
|
+
del?(key: string): Promise<unknown> | unknown;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ResumeTokenConfig {
|
|
46
|
+
storage?: 'file' | 'redis';
|
|
47
|
+
path?: string;
|
|
48
|
+
redis?: ResumeTokenRedisLike;
|
|
49
|
+
key?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface SyncConfig {
|
|
53
|
+
enabled: boolean;
|
|
54
|
+
targets: SyncTargetConfig[];
|
|
55
|
+
collections?: string[];
|
|
56
|
+
resumeToken?: ResumeTokenConfig;
|
|
57
|
+
filter?: (event: SyncChangeEvent) => boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Transform a change-stream document before forwarding to sync targets.
|
|
60
|
+
* v1 form took a single argument (`doc => ...`); v2 added a second `event` argument.
|
|
61
|
+
* Signature is permissive (`any`) to accept both forms — v1 was never typed.
|
|
62
|
+
*/
|
|
63
|
+
transform?: (document: any, event?: SyncChangeEvent) => any;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface SyncStats {
|
|
67
|
+
isRunning: boolean;
|
|
68
|
+
eventCount: number;
|
|
69
|
+
syncedCount: number;
|
|
70
|
+
errorCount: number;
|
|
71
|
+
startTime: Date | null;
|
|
72
|
+
lastEventTime: Date | null;
|
|
73
|
+
targets: Array<{
|
|
74
|
+
name: string;
|
|
75
|
+
syncCount: number;
|
|
76
|
+
errorCount: number;
|
|
77
|
+
lastSyncTime: Date | null;
|
|
78
|
+
lastError: Error | null;
|
|
79
|
+
successRate: string;
|
|
80
|
+
}>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export declare function validateSyncConfig(config: SyncConfig): void;
|
|
84
|
+
|
|
85
|
+
export declare class ResumeTokenStore {
|
|
86
|
+
constructor(options?: ResumeTokenConfig & { logger?: LoggerLike | null; });
|
|
87
|
+
load(): Promise<unknown | null>;
|
|
88
|
+
save(token: unknown): Promise<void>;
|
|
89
|
+
clear(): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export declare class ChangeStreamSyncManager {
|
|
93
|
+
constructor(options: {
|
|
94
|
+
db: unknown;
|
|
95
|
+
poolManager?: unknown;
|
|
96
|
+
config: SyncConfig;
|
|
97
|
+
logger?: LoggerLike | null;
|
|
98
|
+
});
|
|
99
|
+
start(): Promise<void>;
|
|
100
|
+
stop(): Promise<void>;
|
|
101
|
+
getStats(): SyncStats;
|
|
102
|
+
}
|
|
103
|
+
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { CacheLike } from './runtime';
|
|
2
|
+
import type { LoggerLike } from './base';
|
|
3
|
+
|
|
4
|
+
/** Minimal MongoDB session contract used by the transaction layer. */
|
|
5
|
+
export interface MongoSession {
|
|
6
|
+
id: unknown;
|
|
7
|
+
inTransaction(): boolean;
|
|
8
|
+
startTransaction(options?: Record<string, unknown>): void;
|
|
9
|
+
commitTransaction(): Promise<void>;
|
|
10
|
+
abortTransaction(): Promise<void>;
|
|
11
|
+
endSession(): Promise<void>;
|
|
12
|
+
/** v1 compat — v1 callers read `session.transaction?.state`; populated by the underlying driver. */
|
|
13
|
+
transaction?: { state?: string;[key: string]: unknown };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Options forwarded to the MongoDB driver when starting a transaction session. */
|
|
17
|
+
export interface TransactionOptions {
|
|
18
|
+
readConcern?: {
|
|
19
|
+
level: 'local' | 'majority' | 'snapshot' | 'linearizable' | 'available';
|
|
20
|
+
};
|
|
21
|
+
readPreference?: 'primary' | 'primaryPreferred' | 'secondary' | 'secondaryPreferred' | 'nearest';
|
|
22
|
+
causalConsistency?: boolean;
|
|
23
|
+
/** Maximum transaction duration in milliseconds before an automatic abort. */
|
|
24
|
+
maxDuration?: number;
|
|
25
|
+
/** @alias maxDuration — v1 compat field */
|
|
26
|
+
timeout?: number;
|
|
27
|
+
enableRetry?: boolean;
|
|
28
|
+
maxRetries?: number;
|
|
29
|
+
retryDelay?: number;
|
|
30
|
+
retryBackoff?: number;
|
|
31
|
+
enableCacheLock?: boolean;
|
|
32
|
+
lockCleanupInterval?: number;
|
|
33
|
+
writeConcern?: Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Snapshot of a transaction's current state. */
|
|
37
|
+
export interface TransactionInfo {
|
|
38
|
+
id: string;
|
|
39
|
+
status: 'pending' | 'started' | 'committed' | 'aborted';
|
|
40
|
+
duration: number;
|
|
41
|
+
sessionId: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Aggregate statistics for all transactions managed by a `TransactionManager`. */
|
|
45
|
+
export interface TransactionStats {
|
|
46
|
+
totalTransactions: number;
|
|
47
|
+
successfulTransactions: number;
|
|
48
|
+
failedTransactions: number;
|
|
49
|
+
activeTransactions: number;
|
|
50
|
+
averageDuration: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* In-memory lock tracker used to serialise cache invalidation across transaction boundaries.
|
|
55
|
+
* Attached to `TransactionManager`; locks are auto-released when a transaction commits or aborts.
|
|
56
|
+
*/
|
|
57
|
+
export declare class CacheLockManager {
|
|
58
|
+
constructor(options?: { logger?: LoggerLike | null; maxDuration?: number; cleanupInterval?: number; });
|
|
59
|
+
/** Register a lock for `key` owned by `owner`. */
|
|
60
|
+
addLock(key: string, owner: { id?: unknown; } | string): void;
|
|
61
|
+
/** Return `true` if `key` is currently locked. */
|
|
62
|
+
isLocked(key: string): boolean;
|
|
63
|
+
/** Release all locks held by `owner`. */
|
|
64
|
+
releaseLocks(owner: { id?: unknown; } | string): void;
|
|
65
|
+
/** Return lock usage statistics. */
|
|
66
|
+
getStats(): { totalLocks: number; activeLocks: number; maxDuration: number; };
|
|
67
|
+
/** Release all locks immediately. */
|
|
68
|
+
clear(): void;
|
|
69
|
+
/** Stop the background cleanup timer. */
|
|
70
|
+
stop(): void;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Represents a single MongoDB transaction session with optional cache-lock integration. */
|
|
74
|
+
export declare class Transaction {
|
|
75
|
+
readonly id: string;
|
|
76
|
+
readonly session: MongoSession;
|
|
77
|
+
readonly state: 'pending' | 'active' | 'committed' | 'aborted';
|
|
78
|
+
constructor(session: MongoSession, options?: {
|
|
79
|
+
cache?: CacheLike | null;
|
|
80
|
+
logger?: LoggerLike | null;
|
|
81
|
+
lockManager?: CacheLockManager | null;
|
|
82
|
+
timeout?: number;
|
|
83
|
+
});
|
|
84
|
+
/** Begin the transaction (starts the MongoDB session transaction). */
|
|
85
|
+
start(): Promise<void>;
|
|
86
|
+
/** Commit the transaction; replays recorded cache invalidations on success. */
|
|
87
|
+
commit(): Promise<void>;
|
|
88
|
+
/** Abort the transaction and discard pending cache invalidations. */
|
|
89
|
+
abort(): Promise<void>;
|
|
90
|
+
/** Alias for `commit()` — v1 compat shorthand. */
|
|
91
|
+
end(): Promise<void>;
|
|
92
|
+
/** Record a cache-invalidation pattern to be replayed on commit. */
|
|
93
|
+
recordInvalidation(pattern: string): Promise<void>;
|
|
94
|
+
/** Return the elapsed duration in milliseconds since the transaction started. */
|
|
95
|
+
getDuration(): number;
|
|
96
|
+
/** Return a snapshot of the transaction's current state and metadata. */
|
|
97
|
+
getInfo(): TransactionInfo;
|
|
98
|
+
/** Return v1-compatible per-transaction statistics. */
|
|
99
|
+
getStats(): {
|
|
100
|
+
id: string;
|
|
101
|
+
state: 'pending' | 'active' | 'committed' | 'aborted';
|
|
102
|
+
duration: number;
|
|
103
|
+
hasWriteOperation: boolean;
|
|
104
|
+
operationCount: number;
|
|
105
|
+
lockedKeysCount: number;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Manages the lifecycle of MongoDB transactions, including retry and session pooling. */
|
|
110
|
+
export declare class TransactionManager {
|
|
111
|
+
constructor(options: {
|
|
112
|
+
client: unknown;
|
|
113
|
+
cache?: CacheLike | null;
|
|
114
|
+
logger?: LoggerLike | null;
|
|
115
|
+
lockManager?: CacheLockManager | null;
|
|
116
|
+
maxDuration?: number;
|
|
117
|
+
enableRetry?: boolean;
|
|
118
|
+
maxRetries?: number;
|
|
119
|
+
retryDelay?: number;
|
|
120
|
+
retryBackoff?: number;
|
|
121
|
+
});
|
|
122
|
+
/** Open a new transaction session. */
|
|
123
|
+
startSession(options?: TransactionOptions): Promise<Transaction>;
|
|
124
|
+
/** Execute `callback` inside a transaction; commits on success, aborts on failure. */
|
|
125
|
+
withTransaction<T>(callback: (transaction: Transaction) => Promise<T>, options?: TransactionOptions): Promise<T>;
|
|
126
|
+
/** Return all currently active (uncommitted) transactions. */
|
|
127
|
+
getActiveTransactions(): Transaction[];
|
|
128
|
+
/** Abort all active transactions immediately. */
|
|
129
|
+
abortAll(): Promise<void>;
|
|
130
|
+
/** Return aggregate transaction statistics. */
|
|
131
|
+
getStats(): TransactionStats;
|
|
132
|
+
}
|
package/package.json
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monsqlize",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"module": "index.mjs",
|
|
3
|
+
"version": "2.0.0",
|
|
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",
|
|
7
5
|
"type": "commonjs",
|
|
6
|
+
"main": "./dist/cjs/index.cjs",
|
|
7
|
+
"module": "./dist/esm/index.mjs",
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"require": "./dist/cjs/index.cjs",
|
|
13
|
+
"import": "./dist/esm/index.mjs"
|
|
13
14
|
},
|
|
14
15
|
"./package.json": "./package.json"
|
|
15
|
-
},
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist/**/*.cjs",
|
|
19
|
+
"dist/**/*.mjs",
|
|
20
|
+
"dist/**/*.d.ts",
|
|
21
|
+
"changelogs/v2.0.0.md",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE",
|
|
22
24
|
"CHANGELOG.md"
|
|
23
25
|
],
|
|
24
26
|
"keywords": [
|
|
@@ -36,82 +38,82 @@
|
|
|
36
38
|
"api"
|
|
37
39
|
],
|
|
38
40
|
"author": "vext.js Team",
|
|
39
|
-
"license": "
|
|
41
|
+
"license": "Apache-2.0",
|
|
40
42
|
"repository": {
|
|
41
43
|
"type": "git",
|
|
42
|
-
"url": "https://github.com/vextjs/monSQLize.git"
|
|
44
|
+
"url": "git+https://github.com/vextjs/monSQLize.git"
|
|
43
45
|
},
|
|
44
46
|
"bugs": {
|
|
45
47
|
"url": "https://github.com/vextjs/monSQLize/issues"
|
|
46
48
|
},
|
|
47
|
-
"homepage": "https://github.
|
|
49
|
+
"homepage": "https://vextjs.github.io/monSQLize/",
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public",
|
|
52
|
+
"registry": "https://registry.npmjs.org/"
|
|
53
|
+
},
|
|
48
54
|
"engines": {
|
|
49
|
-
"node": ">=
|
|
55
|
+
"node": ">=18.0.0"
|
|
50
56
|
},
|
|
51
57
|
"scripts": {
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"test:
|
|
59
|
-
"test:compatibility:
|
|
60
|
-
"
|
|
61
|
-
"test:
|
|
62
|
-
"test:
|
|
63
|
-
"test:
|
|
64
|
-
"test:
|
|
65
|
-
"test:
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
58
|
+
"check:sizes": "node scripts/check-file-sizes.cjs",
|
|
59
|
+
"check:sizes:strict": "node scripts/check-file-sizes.cjs --strict",
|
|
60
|
+
"build": "node scripts/build-p1.cjs",
|
|
61
|
+
"build:tests": "node scripts/compile-tests.cjs",
|
|
62
|
+
"lint": "eslint . --ignore-pattern .generated/** --ignore-pattern dist/**",
|
|
63
|
+
"lint:fix": "eslint . --fix --ignore-pattern .generated/** --ignore-pattern dist/**",
|
|
64
|
+
"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",
|
|
65
|
+
"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",
|
|
66
|
+
"probe:server-matrix": "node scripts/validation/probe-memory-server-matrix.cjs",
|
|
67
|
+
"test:server-matrix": "node scripts/validation/run-memory-server-matrix.cjs",
|
|
68
|
+
"test:real-env:private": "node scripts/validation/run-private-real-env-checks.cjs",
|
|
69
|
+
"test:examples": "npm run build && tsc -p tsconfig.examples.json && node .generated/examples-dist/examples/quick-start/basic-connect.js && node .generated/examples-dist/examples/cache/with-cache.js && node .generated/examples-dist/examples/docs/insert.js && node .generated/examples-dist/examples/docs/insert-many.js && node .generated/examples-dist/examples/docs/update.js && node .generated/examples-dist/examples/docs/update-one.js && node .generated/examples-dist/examples/docs/delete.js && node .generated/examples-dist/examples/docs/delete-many.js && node .generated/examples-dist/examples/docs/upsert.js && node .generated/examples-dist/examples/docs/upsert-one.js && node .generated/examples-dist/examples/docs/find.js && node .generated/examples-dist/examples/docs/find-one.js && node .generated/examples-dist/examples/docs/find-one-by-id.js && node .generated/examples-dist/examples/docs/find-by-ids.js && node .generated/examples-dist/examples/docs/find-page.js && node .generated/examples-dist/examples/docs/find-and-count.js && node .generated/examples-dist/examples/docs/count.js && node .generated/examples-dist/examples/docs/distinct.js && node .generated/examples-dist/examples/docs/explain.js && node .generated/examples-dist/examples/docs/aggregate.js && node .generated/examples-dist/examples/docs/chaining-api.js && node .generated/examples-dist/examples/docs/expression-functions.js && node .generated/examples-dist/examples/docs/model.js && node .generated/examples-dist/examples/docs/collection-management.js && node .generated/examples-dist/examples/docs/bookmarks.js && node .generated/examples-dist/examples/docs/transaction.js && node .generated/examples-dist/examples/docs/transaction-rollback.js && node .generated/examples-dist/examples/docs/slow-query-log.js && node .generated/examples-dist/examples/docs/watch.js && node .generated/examples-dist/examples/docs/aggregate-advanced.js && node .generated/examples-dist/examples/docs/batch-operations.js && node .generated/examples-dist/examples/docs/soft-delete.js && node .generated/examples-dist/examples/docs/increment-one.js && node .generated/examples-dist/examples/docs/populate-relations.js && node .generated/examples-dist/examples/docs/saga.js && node .generated/examples-dist/examples/docs/lock.js && node .generated/examples-dist/examples/docs/lock-timeout.js && node .generated/examples-dist/examples/docs/cache-multilevel.js && node .generated/examples-dist/examples/docs/objectid.js && node .generated/examples-dist/examples/docs/pool.js && node .generated/examples-dist/examples/docs/pool-fallback.js && node .generated/examples-dist/examples/docs/sync.js && node .generated/examples-dist/examples/docs/sync-target-failure.js",
|
|
70
|
+
"test:performance": "npm run build && npm run build:tests && node .generated/test-dist/test/performance/baselines/function-cache.benchmark.js",
|
|
71
|
+
"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",
|
|
72
|
+
"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",
|
|
73
|
+
"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",
|
|
74
|
+
"test:refactor-guard:cache": "npm run build && npm run build:tests && node --test .generated/test-dist/test/unit/cache/cache-refactor-guard.test.js",
|
|
75
|
+
"test:coverage": "npm run build && npm run build:tests && c8 --reporter=text --reporter=lcov --reporter=json-summary --check-coverage --lines 95 --statements 95 --functions 95 --branches 95 node test/run-tests.cjs",
|
|
76
|
+
"test": "npm run build && npm run build:tests && node test/run-tests.cjs",
|
|
77
|
+
"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",
|
|
78
|
+
"check:test-language": "node scripts/check-test-language.cjs",
|
|
79
|
+
"verify:fast": "npm run lint && 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",
|
|
80
|
+
"verify:full": "npm run lint && npm run type-check && npm run check:sizes:strict && npm run test:coverage && npm run test:examples && npm run test:server-matrix",
|
|
81
|
+
"verify:release": "npm run verify:full && npm run test:real-env:private",
|
|
82
|
+
"verify": "npm run verify:full",
|
|
83
|
+
"release:preflight": "node scripts/release-preflight.cjs",
|
|
84
|
+
"prepublishOnly": "npm run release:preflight",
|
|
85
|
+
"release:publish": "npm run release:preflight && npm publish --ignore-scripts",
|
|
86
|
+
"postpublish": "echo '✅ 发布成功!请创建 GitHub Release: https://github.com/vextjs/monSQLize/releases/new?tag=v'$npm_package_version"
|
|
87
|
+
},
|
|
71
88
|
"peerDependenciesMeta": {
|
|
72
89
|
"ioredis": {
|
|
73
90
|
"optional": true
|
|
91
|
+
},
|
|
92
|
+
"ssh2": {
|
|
93
|
+
"optional": true
|
|
74
94
|
}
|
|
75
95
|
},
|
|
76
96
|
"optionalDependencies": {
|
|
77
|
-
"ioredis": "^5.8.2"
|
|
97
|
+
"ioredis": "^5.8.2",
|
|
98
|
+
"ssh2": "^1.17.0"
|
|
78
99
|
},
|
|
79
100
|
"devDependencies": {
|
|
80
101
|
"@eslint/js": "^9.39.1",
|
|
81
102
|
"@types/node": "^25.0.1",
|
|
82
|
-
"
|
|
83
|
-
"
|
|
103
|
+
"@types/semver": "^7.7.1",
|
|
104
|
+
"c8": "^11.0.0",
|
|
105
|
+
"chai": "^6.2.2",
|
|
106
|
+
"esbuild": "^0.25.5",
|
|
84
107
|
"eslint": "^9.39.1",
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"nyc": "^15.1.0",
|
|
88
|
-
"sinon": "^21.0.0",
|
|
108
|
+
"mongodb-memory-server": "^11.1.0",
|
|
109
|
+
"sinon": "^22.0.0",
|
|
89
110
|
"tsd": "^0.33.0",
|
|
90
111
|
"typescript": "^5.9.3"
|
|
91
112
|
},
|
|
92
|
-
"nyc": {
|
|
93
|
-
"include": [
|
|
94
|
-
"lib/**/*.js"
|
|
95
|
-
],
|
|
96
|
-
"exclude": [
|
|
97
|
-
"test/**",
|
|
98
|
-
"examples/**",
|
|
99
|
-
"scripts/**",
|
|
100
|
-
"reports/**"
|
|
101
|
-
],
|
|
102
|
-
"reporter": [
|
|
103
|
-
"text",
|
|
104
|
-
"lcov",
|
|
105
|
-
"html"
|
|
106
|
-
],
|
|
107
|
-
"check-coverage": true,
|
|
108
|
-
"lines": 70,
|
|
109
|
-
"statements": 70,
|
|
110
|
-
"functions": 70,
|
|
111
|
-
"branches": 65
|
|
112
|
-
},
|
|
113
113
|
"dependencies": {
|
|
114
|
-
"
|
|
115
|
-
"
|
|
114
|
+
"async-lock": "^1.4.1",
|
|
115
|
+
"cache-hub": "^1.0.0",
|
|
116
|
+
"mongodb": "^6.21.0",
|
|
117
|
+
"schema-dsl": "^2.0.3"
|
|
116
118
|
}
|
|
117
119
|
}
|