@crvouga/mockingbird-service-cognito 2.2.0 → 2.3.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 +22 -1
- package/dist/{chunk-XHCTEX45.js → chunk-5BGXS6TY.js} +2 -2
- package/dist/chunk-O67R5MVN.js +3635 -0
- package/dist/chunk-O67R5MVN.js.map +7 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +137 -133
- package/dist/index.js +1 -1
- package/dist/server.d.ts +260 -252
- package/dist/server.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-6BRX6KWY.js +0 -3552
- package/dist/chunk-6BRX6KWY.js.map +0 -7
- /package/dist/{chunk-XHCTEX45.js.map → chunk-5BGXS6TY.js.map} +0 -0
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,33 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The single source of time for a service.
|
|
3
|
-
*
|
|
4
|
-
* Every timestamp a mock writes reads from here, so a suite moves time instead of
|
|
5
|
-
* sleeping: appointment windows, result delays and expiries become reachable in
|
|
6
|
-
* milliseconds. A frozen clock also makes timestamps reproducible from a seed.
|
|
7
|
-
*/
|
|
8
|
-
type ClockState = {
|
|
9
|
-
/** Current epoch milliseconds. */
|
|
10
|
-
now: number;
|
|
11
|
-
/** True while time does not advance on its own. */
|
|
12
|
-
frozen: boolean;
|
|
13
|
-
/** Milliseconds this clock adds to its underlying source. */
|
|
14
|
-
offsetMs: number;
|
|
15
|
-
};
|
|
16
|
-
type Clock = {
|
|
17
|
-
now(): number;
|
|
18
|
-
/** Pin the clock to an exact instant, keeping it frozen if it already was. */
|
|
19
|
-
set(epochMs: number): void;
|
|
20
|
-
/** Move the clock forward, or back with a negative delta. */
|
|
21
|
-
advance(deltaMs: number): void;
|
|
22
|
-
/** Stop time at the current instant. */
|
|
23
|
-
freeze(): void;
|
|
24
|
-
/** Resume from the current instant. */
|
|
25
|
-
unfreeze(): void;
|
|
26
|
-
/** Drop back to the underlying source, live. */
|
|
27
|
-
reset(): void;
|
|
28
|
-
state(): ClockState;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
1
|
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
32
2
|
type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
|
|
33
3
|
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
@@ -99,6 +69,139 @@ declare class Collection<T> {
|
|
|
99
69
|
}>;
|
|
100
70
|
}
|
|
101
71
|
|
|
72
|
+
/** A stable identifier for a point in a {@link Timeline}. */
|
|
73
|
+
type CheckpointId = string;
|
|
74
|
+
/** An immutable node in a timeline's checkpoint DAG. */
|
|
75
|
+
type Checkpoint<T> = Readonly<{
|
|
76
|
+
id: CheckpointId;
|
|
77
|
+
branch: string;
|
|
78
|
+
parent: CheckpointId | null;
|
|
79
|
+
/** Logical time supplied by the timeline's injected clock. */
|
|
80
|
+
at: number;
|
|
81
|
+
value: T;
|
|
82
|
+
}>;
|
|
83
|
+
type TimelineOptions = {
|
|
84
|
+
/** Logical clock used to stamp checkpoints. Defaults to a deterministic counter. */
|
|
85
|
+
now?: () => number;
|
|
86
|
+
/** Maximum retained checkpoints. Branch heads are never collected. Default 1,000. */
|
|
87
|
+
maxCheckpoints?: number;
|
|
88
|
+
/** Customize deterministic checkpoint IDs. */
|
|
89
|
+
id?: (sequence: number) => CheckpointId;
|
|
90
|
+
};
|
|
91
|
+
type CommitOptions = {
|
|
92
|
+
branch?: string;
|
|
93
|
+
/** Parent checkpoint. Defaults to the selected branch's current head. */
|
|
94
|
+
parent?: CheckpointId | null;
|
|
95
|
+
};
|
|
96
|
+
type ForkOptions = {
|
|
97
|
+
/** Checkpoint to fork from. Defaults to the main branch's head. */
|
|
98
|
+
from?: CheckpointId;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Small, storage-agnostic checkpoint DAG shared by service runtimes. Its values may be immutable
|
|
102
|
+
* records, namespace images, or copy-on-write SQL engine snapshots.
|
|
103
|
+
*
|
|
104
|
+
* Values are retained by reference. Engines can therefore use persistent/COW snapshots while
|
|
105
|
+
* simpler services can use immutable values. IDs and GC order are deterministic, and all IO
|
|
106
|
+
* (the logical clock) is injected.
|
|
107
|
+
*/
|
|
108
|
+
declare class Timeline<T> {
|
|
109
|
+
readonly maxCheckpoints: number;
|
|
110
|
+
private readonly now;
|
|
111
|
+
private readonly makeId;
|
|
112
|
+
private readonly nodes;
|
|
113
|
+
private readonly heads;
|
|
114
|
+
/** Unreferenced nodes in the exact order they became collectible. */
|
|
115
|
+
private readonly evictable;
|
|
116
|
+
/** Branch heads plus explicit retainers. Absent means zero. */
|
|
117
|
+
private readonly references;
|
|
118
|
+
private readonly explicitPins;
|
|
119
|
+
private sequence;
|
|
120
|
+
constructor(options?: TimelineOptions);
|
|
121
|
+
/** Capture a new immutable value and move `branch` to it. */
|
|
122
|
+
commit(value: T, options?: CommitOptions): Checkpoint<T>;
|
|
123
|
+
/** Create a branch pointer without copying its checkpoint value. */
|
|
124
|
+
fork(branch: string, options?: ForkOptions): Checkpoint<T> | undefined;
|
|
125
|
+
/** Move a branch pointer to an existing checkpoint. */
|
|
126
|
+
checkout(branch: string, id: CheckpointId): Checkpoint<T>;
|
|
127
|
+
get(id: CheckpointId): Checkpoint<T>;
|
|
128
|
+
head(branch?: string): Checkpoint<T> | undefined;
|
|
129
|
+
hasBranch(branch: string): boolean;
|
|
130
|
+
branches(): Readonly<Record<string, CheckpointId>>;
|
|
131
|
+
checkpoints(): readonly Checkpoint<T>[];
|
|
132
|
+
/** Number of retained checkpoints without allocating an array. */
|
|
133
|
+
get size(): number;
|
|
134
|
+
/** Pin a checkpoint independently of branch heads (used by compatibility snapshot handles). */
|
|
135
|
+
retain(id: CheckpointId): Checkpoint<T>;
|
|
136
|
+
/** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
|
|
137
|
+
release(id: CheckpointId): boolean;
|
|
138
|
+
deleteBranch(branch: string): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Deterministically discard oldest unpinned checkpoints. Collection is O(number removed):
|
|
141
|
+
* commits never scan pinned nodes or the retained history. Parents are metadata rather than a
|
|
142
|
+
* storage dependency, so a retained node remains usable after pruning.
|
|
143
|
+
*/
|
|
144
|
+
gc(max?: number): CheckpointId[];
|
|
145
|
+
private collect;
|
|
146
|
+
private moveHead;
|
|
147
|
+
private addReference;
|
|
148
|
+
private removeReference;
|
|
149
|
+
private assertBranch;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Anything that can answer a Fetch `Request` with a `Response`.
|
|
154
|
+
*
|
|
155
|
+
* Every Mockingbird service implements this, and every runtime adapter consumes it.
|
|
156
|
+
* It is the only contract shared across the whole graph.
|
|
157
|
+
*/
|
|
158
|
+
interface FetchAPI {
|
|
159
|
+
fetch(request: Request): Promise<Response>;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Options every provider constructor accepts. */
|
|
163
|
+
type APIOptions = {
|
|
164
|
+
/** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
|
|
165
|
+
sqlite?: SqliteClient$1;
|
|
166
|
+
/** Clock used for `created`-style fields. Default `Date.now`. */
|
|
167
|
+
now?: () => number;
|
|
168
|
+
/**
|
|
169
|
+
* Storage namespace for this instance's records. Instances sharing one SQLite
|
|
170
|
+
* client stay isolated when their namespaces differ. Defaults to the service name.
|
|
171
|
+
*/
|
|
172
|
+
namespace?: string;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The single source of time for a service.
|
|
177
|
+
*
|
|
178
|
+
* Every timestamp a mock writes reads from here, so a suite moves time instead of
|
|
179
|
+
* sleeping: appointment windows, result delays and expiries become reachable in
|
|
180
|
+
* milliseconds. A frozen clock also makes timestamps reproducible from a seed.
|
|
181
|
+
*/
|
|
182
|
+
type ClockState = {
|
|
183
|
+
/** Current epoch milliseconds. */
|
|
184
|
+
now: number;
|
|
185
|
+
/** True while time does not advance on its own. */
|
|
186
|
+
frozen: boolean;
|
|
187
|
+
/** Milliseconds this clock adds to its underlying source. */
|
|
188
|
+
offsetMs: number;
|
|
189
|
+
};
|
|
190
|
+
type Clock = {
|
|
191
|
+
now(): number;
|
|
192
|
+
/** Pin the clock to an exact instant, keeping it frozen if it already was. */
|
|
193
|
+
set(epochMs: number): void;
|
|
194
|
+
/** Move the clock forward, or back with a negative delta. */
|
|
195
|
+
advance(deltaMs: number): void;
|
|
196
|
+
/** Stop time at the current instant. */
|
|
197
|
+
freeze(): void;
|
|
198
|
+
/** Resume from the current instant. */
|
|
199
|
+
unfreeze(): void;
|
|
200
|
+
/** Drop back to the underlying source, live. */
|
|
201
|
+
reset(): void;
|
|
202
|
+
state(): ClockState;
|
|
203
|
+
};
|
|
204
|
+
|
|
102
205
|
/**
|
|
103
206
|
* Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
|
|
104
207
|
* request a percentage fault hits — is reproducible from a seed.
|
|
@@ -239,109 +342,6 @@ type FaultRegistry = {
|
|
|
239
342
|
take(candidate: FaultCandidate): Promise<FaultHit[]>;
|
|
240
343
|
};
|
|
241
344
|
|
|
242
|
-
/** A stable identifier for a point in a {@link Timeline}. */
|
|
243
|
-
type CheckpointId = string;
|
|
244
|
-
/** An immutable node in a timeline's checkpoint DAG. */
|
|
245
|
-
type Checkpoint<T> = Readonly<{
|
|
246
|
-
id: CheckpointId;
|
|
247
|
-
branch: string;
|
|
248
|
-
parent: CheckpointId | null;
|
|
249
|
-
/** Logical time supplied by the timeline's injected clock. */
|
|
250
|
-
at: number;
|
|
251
|
-
value: T;
|
|
252
|
-
}>;
|
|
253
|
-
type TimelineOptions = {
|
|
254
|
-
/** Logical clock used to stamp checkpoints. Defaults to a deterministic counter. */
|
|
255
|
-
now?: () => number;
|
|
256
|
-
/** Maximum retained checkpoints. Branch heads are never collected. Default 1,000. */
|
|
257
|
-
maxCheckpoints?: number;
|
|
258
|
-
/** Customize deterministic checkpoint IDs. */
|
|
259
|
-
id?: (sequence: number) => CheckpointId;
|
|
260
|
-
};
|
|
261
|
-
type CommitOptions = {
|
|
262
|
-
branch?: string;
|
|
263
|
-
/** Parent checkpoint. Defaults to the selected branch's current head. */
|
|
264
|
-
parent?: CheckpointId | null;
|
|
265
|
-
};
|
|
266
|
-
type ForkOptions = {
|
|
267
|
-
/** Checkpoint to fork from. Defaults to the main branch's head. */
|
|
268
|
-
from?: CheckpointId;
|
|
269
|
-
};
|
|
270
|
-
/**
|
|
271
|
-
* Small, storage-agnostic checkpoint DAG shared by service runtimes. Its values may be immutable
|
|
272
|
-
* records, namespace images, or copy-on-write SQL engine snapshots.
|
|
273
|
-
*
|
|
274
|
-
* Values are retained by reference. Engines can therefore use persistent/COW snapshots while
|
|
275
|
-
* simpler services can use immutable values. IDs and GC order are deterministic, and all IO
|
|
276
|
-
* (the logical clock) is injected.
|
|
277
|
-
*/
|
|
278
|
-
declare class Timeline<T> {
|
|
279
|
-
readonly maxCheckpoints: number;
|
|
280
|
-
private readonly now;
|
|
281
|
-
private readonly makeId;
|
|
282
|
-
private readonly nodes;
|
|
283
|
-
private readonly heads;
|
|
284
|
-
/** Unreferenced nodes in the exact order they became collectible. */
|
|
285
|
-
private readonly evictable;
|
|
286
|
-
/** Branch heads plus explicit retainers. Absent means zero. */
|
|
287
|
-
private readonly references;
|
|
288
|
-
private readonly explicitPins;
|
|
289
|
-
private sequence;
|
|
290
|
-
constructor(options?: TimelineOptions);
|
|
291
|
-
/** Capture a new immutable value and move `branch` to it. */
|
|
292
|
-
commit(value: T, options?: CommitOptions): Checkpoint<T>;
|
|
293
|
-
/** Create a branch pointer without copying its checkpoint value. */
|
|
294
|
-
fork(branch: string, options?: ForkOptions): Checkpoint<T> | undefined;
|
|
295
|
-
/** Move a branch pointer to an existing checkpoint. */
|
|
296
|
-
checkout(branch: string, id: CheckpointId): Checkpoint<T>;
|
|
297
|
-
get(id: CheckpointId): Checkpoint<T>;
|
|
298
|
-
head(branch?: string): Checkpoint<T> | undefined;
|
|
299
|
-
hasBranch(branch: string): boolean;
|
|
300
|
-
branches(): Readonly<Record<string, CheckpointId>>;
|
|
301
|
-
checkpoints(): readonly Checkpoint<T>[];
|
|
302
|
-
/** Number of retained checkpoints without allocating an array. */
|
|
303
|
-
get size(): number;
|
|
304
|
-
/** Pin a checkpoint independently of branch heads (used by compatibility snapshot handles). */
|
|
305
|
-
retain(id: CheckpointId): Checkpoint<T>;
|
|
306
|
-
/** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
|
|
307
|
-
release(id: CheckpointId): boolean;
|
|
308
|
-
deleteBranch(branch: string): boolean;
|
|
309
|
-
/**
|
|
310
|
-
* Deterministically discard oldest unpinned checkpoints. Collection is O(number removed):
|
|
311
|
-
* commits never scan pinned nodes or the retained history. Parents are metadata rather than a
|
|
312
|
-
* storage dependency, so a retained node remains usable after pruning.
|
|
313
|
-
*/
|
|
314
|
-
gc(max?: number): CheckpointId[];
|
|
315
|
-
private collect;
|
|
316
|
-
private moveHead;
|
|
317
|
-
private addReference;
|
|
318
|
-
private removeReference;
|
|
319
|
-
private assertBranch;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Anything that can answer a Fetch `Request` with a `Response`.
|
|
324
|
-
*
|
|
325
|
-
* Every Mockingbird service implements this, and every runtime adapter consumes it.
|
|
326
|
-
* It is the only contract shared across the whole graph.
|
|
327
|
-
*/
|
|
328
|
-
interface FetchAPI {
|
|
329
|
-
fetch(request: Request): Promise<Response>;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/** Options every provider constructor accepts. */
|
|
333
|
-
type APIOptions = {
|
|
334
|
-
/** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
|
|
335
|
-
sqlite?: SqliteClient$1;
|
|
336
|
-
/** Clock used for `created`-style fields. Default `Date.now`. */
|
|
337
|
-
now?: () => number;
|
|
338
|
-
/**
|
|
339
|
-
* Storage namespace for this instance's records. Instances sharing one SQLite
|
|
340
|
-
* client stay isolated when their namespaces differ. Defaults to the service name.
|
|
341
|
-
*/
|
|
342
|
-
namespace?: string;
|
|
343
|
-
};
|
|
344
|
-
|
|
345
345
|
/**
|
|
346
346
|
* One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
|
|
347
347
|
* `kind` is `media_type` when the body is present but its media type is not one the operation
|
|
@@ -383,6 +383,10 @@ type RequestLog = {
|
|
|
383
383
|
ids?: Record<string, string>;
|
|
384
384
|
/** Set when the service created a resource the request referred to but that did not exist. */
|
|
385
385
|
adopted?: boolean;
|
|
386
|
+
/** Explicit durable acceptance, independent of response delivery. */
|
|
387
|
+
accepted?: boolean;
|
|
388
|
+
/** Checkpoint captured at explicit acceptance. */
|
|
389
|
+
checkpoint?: string;
|
|
386
390
|
/** Set on a rejection (status ≥ 400) the mock produced itself, never on a scripted fault. */
|
|
387
391
|
request?: RejectedRequest;
|
|
388
392
|
/** The validation issues behind a rejection, when the service found any. */
|