@classytic/mongokit 3.43.0 → 3.44.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/README.md +14 -0
- package/dist/{PaginationEngine-DZnkbSrr.mjs → PaginationEngine-C9iS0U5l.mjs} +13 -27
- package/dist/{PaginationEngine-CRHyuUtw.d.mts → PaginationEngine-D17AthKw.d.mts} +1 -3
- package/dist/{Repository-DnL4xk5w.d.mts → Repository-B6oL6OMv.d.mts} +33 -11
- package/dist/{Repository-Dj6xqPxJ.mjs → Repository-eMRYZ_2Y.mjs} +204 -92
- package/dist/actions/index.d.mts +1 -1
- package/dist/actions/index.mjs +2 -12
- package/dist/actions-DExyXMTy.mjs +11 -0
- package/dist/adapter/index.d.mts +6 -10
- package/dist/adapter/index.mjs +1 -2
- package/dist/{adapter-CkMoMF83.mjs → adapter-Qzgc3ZD_.mjs} +4 -6
- package/dist/ai/index.d.mts +21 -8
- package/dist/ai/index.mjs +15 -9
- package/dist/better-auth/index.d.mts +18 -32
- package/dist/better-auth/index.mjs +3 -4
- package/dist/{coercion-BjdPX3YF.d.mts → coercion-COp9DRNw.d.mts} +0 -2
- package/dist/{create-repository-CJtVdwig.d.mts → create-repository-BOFUYj1l.d.mts} +5 -7
- package/dist/{create-repository-UjwPWR1z.mjs → create-repository-D7MQpIZo.mjs} +4 -5
- package/dist/{derive-DRBiegRH.mjs → derive-Dxsc31fV.mjs} +3 -6
- package/dist/{error-BuByZwKU.mjs → error-DjdmPLWO.mjs} +1 -2
- package/dist/{field-selection-FSQFLpsU.mjs → field-selection-DPFaFw9Y.mjs} +1 -2
- package/dist/{id-chunks-BmAwsqNk.mjs → id-chunks-DH-RAZWG.mjs} +13 -8
- package/dist/{id-resolution-BqDrk0S2.mjs → id-resolution-Cqh49d9J.mjs} +1 -2
- package/dist/idempotency/index.d.mts +4 -7
- package/dist/idempotency/index.mjs +1 -2
- package/dist/{index-SYF8N28D.d.mts → index-8QUEsOFI.d.mts} +3 -4
- package/dist/{index-C0AjVqX3.d.mts → index-ehGZLbrd.d.mts} +2 -8
- package/dist/index.d.mts +63 -96
- package/dist/index.mjs +36 -52
- package/dist/indexes/verify-indexes.d.mts +8 -11
- package/dist/indexes/verify-indexes.mjs +1 -2
- package/dist/{indexes-DIjMpYES.d.mts → indexes-FfyOuhDK.d.mts} +0 -2
- package/dist/{join-scope-DSAznE8E.mjs → join-scope-C1gOtZ59.mjs} +2 -3
- package/dist/kernel-conformance/index.d.mts +39 -13
- package/dist/kernel-conformance/index.mjs +4 -7
- package/dist/lock/index.d.mts +134 -7
- package/dist/lock/index.mjs +349 -14
- package/dist/{logger-K7dPmu2U.mjs → logger-hbWOlj_X.mjs} +1 -2
- package/dist/{method-registry.plugin-C63pGn1d.mjs → method-registry.plugin-CGAepsBU.mjs} +3 -5
- package/dist/{model-registry-ClKtWiHa.mjs → model-registry-DrVfJ3Nt.mjs} +1 -2
- package/dist/{mongooseToJsonSchema-C3k4ide0.mjs → mongooseToJsonSchema-DMDotz4_.mjs} +2 -3
- package/dist/{multi-tenant.plugin-B_q9NUHc.d.mts → multi-tenant.plugin-DfeDMiI8.d.mts} +143 -11
- package/dist/{operations-XiFgG5US.d.mts → operations-Dw9OFV0V.d.mts} +14 -5
- package/dist/outbox/index.d.mts +24 -9
- package/dist/outbox/index.mjs +17 -6
- package/dist/pagination/PaginationEngine.d.mts +1 -1
- package/dist/pagination/PaginationEngine.mjs +1 -2
- package/dist/pagination/utils/limits.d.mts +6 -9
- package/dist/pagination/utils/limits.mjs +2 -3
- package/dist/{pagination-D6psses0.d.mts → pagination-DAUg5zOY.d.mts} +2 -10
- package/dist/{plugin-options-Cirmb4Kp.d.mts → plugin-options-Bpcuz9kS.d.mts} +2 -4
- package/dist/plugins/index.d.mts +6 -7
- package/dist/plugins/index.mjs +6 -7
- package/dist/query/primitives/coercion.d.mts +1 -1
- package/dist/query/primitives/coercion.mjs +2 -3
- package/dist/query/primitives/geo.d.mts +11 -14
- package/dist/query/primitives/geo.mjs +1 -2
- package/dist/query/primitives/indexes.d.mts +1 -1
- package/dist/query/primitives/indexes.mjs +1 -2
- package/dist/{query-defaults-BxUcSOoF.mjs → query-defaults-aUoKlEbh.mjs} +2 -3
- package/dist/read-model/index.d.mts +18 -21
- package/dist/read-model/index.mjs +3 -4
- package/dist/{repository-MqAP409e.d.mts → repository-DzVIwhU2.d.mts} +25 -29
- package/dist/retention-purge-DqcYvRnG.d.mts +35 -0
- package/dist/{rolldown-runtime-D7D4PA-g.mjs → rolldown-runtime-D8jQpDG7.mjs} +1 -2
- package/dist/search/index.d.mts +1 -1
- package/dist/search/index.mjs +1 -2
- package/dist/sync/index.d.mts +95 -15
- package/dist/sync/index.mjs +308 -62
- package/dist/tenant/index.d.mts +8 -11
- package/dist/tenant/index.mjs +1 -2
- package/dist/testkit/index.d.mts +179 -23
- package/dist/testkit/index.mjs +421 -23
- package/dist/{timestamp.plugin-DpOWavVI.mjs → timestamp.plugin-Bz_zL9PX.mjs} +192 -49
- package/dist/{to-plain-vksRrLtc.mjs → to-plain-CEKv_ylg.mjs} +2 -4
- package/dist/{to-plain-o5tUY2nV.d.mts → to-plain-PO5r1Qoy.d.mts} +2 -16
- package/dist/{transaction-DmiB4k2P.mjs → transaction-C2PFxfIv.mjs} +5 -8
- package/dist/{type-utils-CLzRFtIA.d.mts → type-utils-CKvuewAL.d.mts} +0 -2
- package/dist/{update-WgeAUJ_I.mjs → update-DcfmNbJe.mjs} +12 -20
- package/dist/usage/index.d.mts +2 -5
- package/dist/usage/index.mjs +8 -6
- package/dist/utils/index.d.mts +8 -10
- package/dist/utils/index.mjs +7 -7
- package/dist/{validation-chain.plugin-BAeC5eVT.d.mts → validation-chain.plugin-B3gZCZj4.d.mts} +135 -48
- package/dist/{validation-chain.plugin-DRApTmkN.mjs → validation-chain.plugin-DNY6MIF6.mjs} +207 -55
- package/llms.txt +33 -0
- package/package.json +29 -25
- package/skills/mongokit/SKILL.md +112 -0
- package/skills/mongokit/references/pagination-search.md +87 -0
- package/skills/mongokit/references/plugins-tenancy.md +102 -0
- package/skills/mongokit/references/repository-api.md +83 -0
- package/skills/mongokit/references/transactions-outbox.md +101 -0
package/dist/testkit/index.d.mts
CHANGED
|
@@ -1,15 +1,126 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as CreateRepositoryConfig } from "../create-repository-BOFUYj1l.mjs";
|
|
2
|
+
import { r as Repository } from "../Repository-B6oL6OMv.mjs";
|
|
3
3
|
import { Connection, Model, Schema } from "mongoose";
|
|
4
4
|
import { MongoMemoryReplSet, MongoMemoryServer } from "mongodb-memory-server";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* mongodb-memory-server temp-dir hygiene: start, stop and sweep so that a test
|
|
7
|
+
* run that is killed, crashes or times out does not leave its data dir behind.
|
|
8
|
+
*
|
|
9
|
+
* ## Why this exists
|
|
10
|
+
*
|
|
11
|
+
* mongodb-memory-server creates `mongo-mem-XXXXXX` under `os.tmpdir()` for every
|
|
12
|
+
* server and removes it in `stop()` (`doCleanup: true` is the default since v9).
|
|
13
|
+
* That only covers the orderly path. A run killed from an IDE, a CI cancel, a
|
|
14
|
+
* worker terminated on timeout or a hard crash never reaches `stop()`, and the
|
|
15
|
+
* dir (a full WiredTiger data set, ~15 MB at minimum) stays forever. On one
|
|
16
|
+
* development machine that came to 3,698 dirs, about 57 GB, in `%TEMP%`.
|
|
17
|
+
* mongodb-memory-server also stops a server that FAILED to start with
|
|
18
|
+
* `doCleanup: false` ("for investigation"), so a failed boot leaks one too.
|
|
19
|
+
*
|
|
20
|
+
* Three measures, each one usable on its own:
|
|
21
|
+
*
|
|
22
|
+
* 1. `launchMongoMemory` always stops with cleanup, cleans up after a failed
|
|
23
|
+
* start, and has a synchronous `stopSync()` for a process `exit` handler,
|
|
24
|
+
* where nothing async completes.
|
|
25
|
+
* 2. `sweepStaleMongoMemoryDirs` removes `mongo-mem-*` dirs that are old AND
|
|
26
|
+
* whose `mongod.lock` names no live process. Both conditions, always: a live
|
|
27
|
+
* mongod rewrites its WiredTiger files on every checkpoint (60 s), so its dir
|
|
28
|
+
* is never old, and its lock names a live pid.
|
|
29
|
+
* 3. `TEST_MONGO_TMPDIR` puts the data dirs under a dedicated base (for example
|
|
30
|
+
* a project-local `.tmp`), so whatever does leak is contained and visible.
|
|
31
|
+
*
|
|
32
|
+
* Environment:
|
|
33
|
+
* - `TEST_MONGO_TMPDIR`: base dir for new data dirs. Unset: mongodb-memory-server's
|
|
34
|
+
* own default (`os.tmpdir()`).
|
|
35
|
+
* - `TEST_MONGO_SWEEP_HOURS`: minimum age of a dir the sweep may remove. Default 6.
|
|
36
|
+
* `0`, `off` or `false` turns the sweep off.
|
|
37
|
+
*/
|
|
38
|
+
/** Prefix mongodb-memory-server gives its data dirs (and that ours use). */
|
|
39
|
+
export declare const MONGO_MEM_DIR_PREFIX = "mongo-mem-";
|
|
40
|
+
/** The dedicated base dir from `TEST_MONGO_TMPDIR`, resolved, or undefined. */
|
|
41
|
+
export declare function mongoMemoryTmpBase(): string | undefined;
|
|
42
|
+
/** Minimum age (ms) of a dir the sweep may remove; `null` when the sweep is off. */
|
|
43
|
+
export declare function staleMongoMemoryAgeMs(): number | null;
|
|
44
|
+
/** Whether a process with this pid exists. EPERM means it exists but is not ours. */
|
|
45
|
+
export declare function isPidAlive(pid: number): boolean;
|
|
46
|
+
interface SweepMongoMemoryOptions {
|
|
47
|
+
/** Dirs to scan. Default: `os.tmpdir()` plus `TEST_MONGO_TMPDIR` when set. */
|
|
48
|
+
readonly dirs?: readonly string[];
|
|
49
|
+
/** Minimum age in ms; `null` turns the sweep off. Default: `staleMongoMemoryAgeMs()`. */
|
|
50
|
+
readonly maxAgeMs?: number | null;
|
|
51
|
+
/** Clock, for tests. Default `Date.now()`. */
|
|
52
|
+
readonly now?: number;
|
|
53
|
+
/** Liveness probe, for tests. Default `isPidAlive`. */
|
|
54
|
+
readonly isAlive?: (pid: number) => boolean;
|
|
55
|
+
}
|
|
56
|
+
interface SweepMongoMemoryResult {
|
|
57
|
+
readonly removed: string[];
|
|
58
|
+
readonly kept: Array<{
|
|
59
|
+
path: string;
|
|
60
|
+
reason: 'live-process' | 'recent';
|
|
61
|
+
}>;
|
|
62
|
+
readonly failed: Array<{
|
|
63
|
+
path: string;
|
|
64
|
+
error: string;
|
|
65
|
+
}>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Remove abandoned `mongo-mem-*` data dirs.
|
|
69
|
+
*
|
|
70
|
+
* A dir is removed only when BOTH hold: its `mongod.lock` names no live process
|
|
71
|
+
* (or is empty or missing), and nothing in it changed for `maxAgeMs`. Keyfile
|
|
72
|
+
* dirs and anything without the prefix are never touched. Errors are collected,
|
|
73
|
+
* never thrown: a sweep must not fail a test run.
|
|
74
|
+
*/
|
|
75
|
+
export declare function sweepStaleMongoMemoryDirs(options?: SweepMongoMemoryOptions): Promise<SweepMongoMemoryResult>;
|
|
76
|
+
/** The parts of `MongoMemoryServer` / `MongoMemoryReplSet` this module uses. */
|
|
77
|
+
interface MmsServerLike {
|
|
78
|
+
getUri(dbName?: string): string;
|
|
79
|
+
start(): Promise<unknown>;
|
|
80
|
+
stop(cleanup?: {
|
|
81
|
+
doCleanup?: boolean;
|
|
82
|
+
force?: boolean;
|
|
83
|
+
}): Promise<unknown>;
|
|
84
|
+
}
|
|
85
|
+
type MongoMemoryKind = 'standalone' | 'replset';
|
|
86
|
+
interface LaunchedMongoMemory<S extends MmsServerLike> {
|
|
87
|
+
readonly server: S;
|
|
88
|
+
/** Data dirs this module created under `TEST_MONGO_TMPDIR` (empty when unset). */
|
|
89
|
+
readonly ownedDirs: readonly string[];
|
|
90
|
+
/**
|
|
91
|
+
* Stop and remove the data dirs. Idempotent once it succeeded; a failed stop
|
|
92
|
+
* rejects and can be retried, and `stopSync()` stays effective until one succeeds.
|
|
93
|
+
*/
|
|
94
|
+
stop(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Best-effort SYNCHRONOUS stop for a process `exit` handler, where no async
|
|
97
|
+
* work completes: kill the mongod processes and remove their data dirs.
|
|
98
|
+
* Idempotent, never throws.
|
|
99
|
+
*/
|
|
100
|
+
stopSync(): void;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create and start a `MongoMemoryServer` (`standalone`) or `MongoMemoryReplSet`
|
|
104
|
+
* (`replset`) with the cleanup guarantees described at the top of this file.
|
|
105
|
+
*
|
|
106
|
+
* `Ctor` is the class itself, so a caller that loads mongodb-memory-server its
|
|
107
|
+
* own way (by resolved path, through an alias) keeps doing so.
|
|
108
|
+
*/
|
|
109
|
+
export declare function launchMongoMemory<S extends MmsServerLike>(Ctor: new (opts?: never) => S, kind: MongoMemoryKind, createOptions?: Record<string, unknown>): Promise<LaunchedMongoMemory<S>>;
|
|
110
|
+
/**
|
|
111
|
+
* Stop a launched server when the process ends without its teardown: Ctrl-C /
|
|
112
|
+
* SIGTERM stop it properly, then re-raise so the exit code stays truthful; an
|
|
113
|
+
* `exit` (including an uncaught exception) kills mongod and removes the dir
|
|
114
|
+
* synchronously. Returns an untrack function for the orderly path.
|
|
115
|
+
*/
|
|
116
|
+
export declare function stopOnProcessExit(handle: LaunchedMongoMemory<MmsServerLike>): () => void;
|
|
6
117
|
interface RecordedCommand {
|
|
7
118
|
name: string;
|
|
8
119
|
collection: string | undefined;
|
|
9
120
|
command: Record<string, unknown>;
|
|
10
121
|
}
|
|
11
122
|
/** Run `fn` and return every command it started on `connection` (in start order). */
|
|
12
|
-
declare function recordCommands<T>(connection: Connection, fn: () => Promise<T>): Promise<{
|
|
123
|
+
export declare function recordCommands<T>(connection: Connection, fn: () => Promise<T>): Promise<{
|
|
13
124
|
result: T;
|
|
14
125
|
commands: RecordedCommand[];
|
|
15
126
|
}>;
|
|
@@ -23,6 +134,12 @@ interface QueryPlanOptions {
|
|
|
23
134
|
leadingKeys?: readonly string[];
|
|
24
135
|
/** Only gate commands on these collections (default: every plannable command). */
|
|
25
136
|
collections?: readonly string[];
|
|
137
|
+
/**
|
|
138
|
+
* Command names to gate. Default the reads: `find`, `aggregate`, `count`, `distinct`. Add
|
|
139
|
+
* `findAndModify`, `update` or `delete` to gate a write's match as well (explained, never
|
|
140
|
+
* re-run). Any other name throws.
|
|
141
|
+
*/
|
|
142
|
+
commands?: readonly string[];
|
|
26
143
|
}
|
|
27
144
|
interface PlannedCommand {
|
|
28
145
|
name: string;
|
|
@@ -30,17 +147,53 @@ interface PlannedCommand {
|
|
|
30
147
|
stages: string[];
|
|
31
148
|
indexes: string[][];
|
|
32
149
|
}
|
|
150
|
+
interface ExplainCommandsOptions {
|
|
151
|
+
connection: Connection;
|
|
152
|
+
/**
|
|
153
|
+
* Command names to explain. Default every explainable one: `find`, `aggregate`, `count`,
|
|
154
|
+
* `distinct`, `findAndModify` (`findOneAndUpdate`, `findOneAndDelete`, ...), `update`,
|
|
155
|
+
* `delete`. Any other name throws.
|
|
156
|
+
*/
|
|
157
|
+
commands?: readonly string[];
|
|
158
|
+
/** Only explain commands on these collections (default: every collection). */
|
|
159
|
+
collections?: readonly string[];
|
|
160
|
+
/** Explain verbosity. Default `'executionStats'`. */
|
|
161
|
+
verbosity?: 'queryPlanner' | 'executionStats' | 'allPlansExecution';
|
|
162
|
+
}
|
|
163
|
+
interface ExplainedCommand extends RecordedCommand {
|
|
164
|
+
collection: string;
|
|
165
|
+
/** The command as handed to `explain`: session fields stripped, one statement for update / delete. */
|
|
166
|
+
explained: Record<string, unknown>;
|
|
167
|
+
/** The server's explain output as returned (`queryPlanner`, `executionStats`, ...). */
|
|
168
|
+
explain: Record<string, unknown>;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Run `run` and explain the commands it ACTUALLY sent, so a test plans the filter, sort and
|
|
172
|
+
* update a repository method or plugin built (a `leasePlugin` claim, a tenant-scoped read)
|
|
173
|
+
* rather than a copy of it. The explains run after `run` returns and never write. Throws when no
|
|
174
|
+
* command matched, so a renamed collection cannot pass vacuously. The connection must be opened
|
|
175
|
+
* with `{ monitorCommands: true }`.
|
|
176
|
+
*
|
|
177
|
+
* ```ts
|
|
178
|
+
* const { explains } = await explainCommands(() => repo.lease({ leaseFor, leasedBy }), {
|
|
179
|
+
* connection, commands: ['findAndModify'], collections: ['jobs'],
|
|
180
|
+
* });
|
|
181
|
+
* explains[0].explain.executionStats; // what the claim examined
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
export declare function explainCommands<T>(run: () => Promise<T>, options: ExplainCommandsOptions): Promise<{
|
|
185
|
+
result: T;
|
|
186
|
+
explains: ExplainedCommand[];
|
|
187
|
+
}>;
|
|
33
188
|
/**
|
|
34
189
|
* Run `run`, explain every read it issued and throw on a forbidden stage, a wrong leading index,
|
|
35
190
|
* an undersized fixture, or no plannable command at all. Returns what each command used.
|
|
36
191
|
*/
|
|
37
|
-
declare function assertQueryPlan<T>(run: () => Promise<T>, options: QueryPlanOptions): Promise<{
|
|
192
|
+
export declare function assertQueryPlan<T>(run: () => Promise<T>, options: QueryPlanOptions): Promise<{
|
|
38
193
|
result: T;
|
|
39
194
|
plans: PlannedCommand[];
|
|
40
195
|
}>;
|
|
41
|
-
|
|
42
|
-
//#region src/testkit/index.d.ts
|
|
43
|
-
interface MongoMemoryOptions {
|
|
196
|
+
export interface MongoMemoryOptions {
|
|
44
197
|
/**
|
|
45
198
|
* Boot a single-node replica set instead of a standalone mongod. Required for
|
|
46
199
|
* any code that opens a `session.startTransaction()` — a standalone server
|
|
@@ -62,12 +215,16 @@ interface MongoMemoryOptions {
|
|
|
62
215
|
*/
|
|
63
216
|
uri?: string;
|
|
64
217
|
}
|
|
65
|
-
interface MongoMemoryHandle {
|
|
218
|
+
export interface MongoMemoryHandle {
|
|
66
219
|
/** Connection string for the running (or external) server. */
|
|
67
220
|
uri: string;
|
|
68
221
|
/** The in-memory server; `undefined` when an external `uri` is used. */
|
|
69
222
|
server?: MongoMemoryServer | MongoMemoryReplSet;
|
|
70
|
-
/**
|
|
223
|
+
/**
|
|
224
|
+
* Stop the in-memory server. No-op for an external URI. Idempotent once it
|
|
225
|
+
* succeeded; a failed stop rejects and can be retried, and the server stays
|
|
226
|
+
* on the process-exit list (killed synchronously on exit) until one succeeds.
|
|
227
|
+
*/
|
|
71
228
|
stop(): Promise<void>;
|
|
72
229
|
}
|
|
73
230
|
/**
|
|
@@ -75,8 +232,8 @@ interface MongoMemoryHandle {
|
|
|
75
232
|
* a `stop()` teardown. Prefer `createTestConnection` / `createTestRepository`
|
|
76
233
|
* unless you need the server without a mongoose connection.
|
|
77
234
|
*/
|
|
78
|
-
declare function createMongoMemory(options?: MongoMemoryOptions): Promise<MongoMemoryHandle>;
|
|
79
|
-
interface TestConnection {
|
|
235
|
+
export declare function createMongoMemory(options?: MongoMemoryOptions): Promise<MongoMemoryHandle>;
|
|
236
|
+
export interface TestConnection {
|
|
80
237
|
/** An isolated mongoose connection (never the global `mongoose.connection`). */
|
|
81
238
|
connection: Connection;
|
|
82
239
|
uri: string;
|
|
@@ -86,13 +243,13 @@ interface TestConnection {
|
|
|
86
243
|
close(): Promise<void>;
|
|
87
244
|
}
|
|
88
245
|
/** Drop every document in every collection on a connection (models preserved). */
|
|
89
|
-
declare function clearCollections(connection: Connection): Promise<void>;
|
|
246
|
+
export declare function clearCollections(connection: Connection): Promise<void>;
|
|
90
247
|
/**
|
|
91
248
|
* Start (or resolve) a server AND open an isolated mongoose connection over it.
|
|
92
249
|
* Each call gets its own connection — model registries are per-connection, so
|
|
93
250
|
* repeated boots in one process never collide.
|
|
94
251
|
*/
|
|
95
|
-
declare function createTestConnection(options?: MongoMemoryOptions): Promise<TestConnection>;
|
|
252
|
+
export declare function createTestConnection(options?: MongoMemoryOptions): Promise<TestConnection>;
|
|
96
253
|
/**
|
|
97
254
|
* Scoped harness: start a connection, run `fn`, and tear down in a `finally`
|
|
98
255
|
* even if `fn` throws.
|
|
@@ -104,8 +261,8 @@ declare function createTestConnection(options?: MongoMemoryOptions): Promise<Tes
|
|
|
104
261
|
* });
|
|
105
262
|
* ```
|
|
106
263
|
*/
|
|
107
|
-
declare function withMongoMemory<T>(fn: (ctx: TestConnection) => Promise<T> | T, options?: MongoMemoryOptions): Promise<T>;
|
|
108
|
-
interface CreateTestRepositoryOptions<TDoc> extends MongoMemoryOptions {
|
|
264
|
+
export declare function withMongoMemory<T>(fn: (ctx: TestConnection) => Promise<T> | T, options?: MongoMemoryOptions): Promise<T>;
|
|
265
|
+
export interface CreateTestRepositoryOptions<TDoc> extends MongoMemoryOptions {
|
|
109
266
|
/** Model / collection name (unique per test to avoid cross-file collisions). */
|
|
110
267
|
name: string;
|
|
111
268
|
/** Mongoose schema for the model. */
|
|
@@ -113,7 +270,7 @@ interface CreateTestRepositoryOptions<TDoc> extends MongoMemoryOptions {
|
|
|
113
270
|
/** mongokit `createRepository` config — tenant, softDelete, plugins, cache… */
|
|
114
271
|
config?: CreateRepositoryConfig;
|
|
115
272
|
}
|
|
116
|
-
interface TestRepository<TDoc> {
|
|
273
|
+
export interface TestRepository<TDoc> {
|
|
117
274
|
/** A live mongokit repository over an in-memory collection. */
|
|
118
275
|
repository: Repository<TDoc>;
|
|
119
276
|
/** The underlying mongoose model (bound to the isolated connection). */
|
|
@@ -137,9 +294,9 @@ interface TestRepository<TDoc> {
|
|
|
137
294
|
* await t.close();
|
|
138
295
|
* ```
|
|
139
296
|
*/
|
|
140
|
-
declare function createTestRepository<TDoc>(options: CreateTestRepositoryOptions<TDoc>): Promise<TestRepository<TDoc>>;
|
|
297
|
+
export declare function createTestRepository<TDoc>(options: CreateTestRepositoryOptions<TDoc>): Promise<TestRepository<TDoc>>;
|
|
141
298
|
/** The context a module receives from the Mongo backend (live connection + URI). */
|
|
142
|
-
interface MongoTestContext {
|
|
299
|
+
export interface MongoTestContext {
|
|
143
300
|
connection: Connection;
|
|
144
301
|
uri: string;
|
|
145
302
|
}
|
|
@@ -148,7 +305,7 @@ interface MongoTestContext {
|
|
|
148
305
|
* a `TestBackend<MongoTestContext>` — no import of arc-testkit, so mongokit
|
|
149
306
|
* never depends on it (one-way: arc-testkit consumes this by shape).
|
|
150
307
|
*/
|
|
151
|
-
interface MongoMemoryBackend {
|
|
308
|
+
export interface MongoMemoryBackend {
|
|
152
309
|
setup(): Promise<{
|
|
153
310
|
ctx: MongoTestContext;
|
|
154
311
|
teardown: () => Promise<void>;
|
|
@@ -167,6 +324,5 @@ interface MongoMemoryBackend {
|
|
|
167
324
|
* );
|
|
168
325
|
* ```
|
|
169
326
|
*/
|
|
170
|
-
declare function mongoMemoryBackend(options?: MongoMemoryOptions): MongoMemoryBackend;
|
|
171
|
-
|
|
172
|
-
export { CreateTestRepositoryOptions, MongoMemoryBackend, MongoMemoryHandle, MongoMemoryOptions, MongoTestContext, type PlannedCommand, type QueryPlanOptions, type RecordedCommand, TestConnection, TestRepository, assertQueryPlan, clearCollections, createMongoMemory, createTestConnection, createTestRepository, mongoMemoryBackend, recordCommands, withMongoMemory };
|
|
327
|
+
export declare function mongoMemoryBackend(options?: MongoMemoryOptions): MongoMemoryBackend;
|
|
328
|
+
export type { ExplainCommandsOptions, ExplainedCommand, LaunchedMongoMemory, MmsServerLike, MongoMemoryKind, PlannedCommand, QueryPlanOptions, RecordedCommand, SweepMongoMemoryOptions, SweepMongoMemoryResult };
|