@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/server.d.ts
CHANGED
|
@@ -1,5 +1,124 @@
|
|
|
1
1
|
import { Server } from 'node:http';
|
|
2
2
|
|
|
3
|
+
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
4
|
+
type SqliteValue$2 = null | number | bigint | string | Uint8Array | boolean;
|
|
5
|
+
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
6
|
+
type SqliteRunResult$2 = {
|
|
7
|
+
changes: number;
|
|
8
|
+
lastInsertRowid: number | bigint;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Prepared statement bound to a {@link SqliteClient}.
|
|
12
|
+
*
|
|
13
|
+
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
14
|
+
*/
|
|
15
|
+
interface SqliteStatement$2 {
|
|
16
|
+
run(...params: SqliteValue$2[]): SqliteRunResult$2;
|
|
17
|
+
all<T = Record<string, unknown>>(...params: SqliteValue$2[]): T[];
|
|
18
|
+
get<T = Record<string, unknown>>(...params: SqliteValue$2[]): T | undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sync SQLite client port owned by Mockingbird.
|
|
22
|
+
*
|
|
23
|
+
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
24
|
+
* `bun:sqlite` instances all work when they expose this surface.
|
|
25
|
+
*/
|
|
26
|
+
interface SqliteClient$2 {
|
|
27
|
+
exec(sql: string): void;
|
|
28
|
+
prepare(sql: string): SqliteStatement$2;
|
|
29
|
+
transaction<T>(fn: () => T): T;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A stable identifier for a point in a {@link Timeline}. */
|
|
33
|
+
type CheckpointId$1 = string;
|
|
34
|
+
/** An immutable node in a timeline's checkpoint DAG. */
|
|
35
|
+
type Checkpoint$1<T> = Readonly<{
|
|
36
|
+
id: CheckpointId$1;
|
|
37
|
+
branch: string;
|
|
38
|
+
parent: CheckpointId$1 | null;
|
|
39
|
+
/** Logical time supplied by the timeline's injected clock. */
|
|
40
|
+
at: number;
|
|
41
|
+
value: T;
|
|
42
|
+
}>;
|
|
43
|
+
type TimelineOptions$1 = {
|
|
44
|
+
/** Logical clock used to stamp checkpoints. Defaults to a deterministic counter. */
|
|
45
|
+
now?: () => number;
|
|
46
|
+
/** Maximum retained checkpoints. Branch heads are never collected. Default 1,000. */
|
|
47
|
+
maxCheckpoints?: number;
|
|
48
|
+
/** Customize deterministic checkpoint IDs. */
|
|
49
|
+
id?: (sequence: number) => CheckpointId$1;
|
|
50
|
+
};
|
|
51
|
+
type CommitOptions$1 = {
|
|
52
|
+
branch?: string;
|
|
53
|
+
/** Parent checkpoint. Defaults to the selected branch's current head. */
|
|
54
|
+
parent?: CheckpointId$1 | null;
|
|
55
|
+
};
|
|
56
|
+
type ForkOptions$1 = {
|
|
57
|
+
/** Checkpoint to fork from. Defaults to the main branch's head. */
|
|
58
|
+
from?: CheckpointId$1;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Small, storage-agnostic checkpoint DAG shared by service runtimes. Its values may be immutable
|
|
62
|
+
* records, namespace images, or copy-on-write SQL engine snapshots.
|
|
63
|
+
*
|
|
64
|
+
* Values are retained by reference. Engines can therefore use persistent/COW snapshots while
|
|
65
|
+
* simpler services can use immutable values. IDs and GC order are deterministic, and all IO
|
|
66
|
+
* (the logical clock) is injected.
|
|
67
|
+
*/
|
|
68
|
+
declare class Timeline$1<T> {
|
|
69
|
+
readonly maxCheckpoints: number;
|
|
70
|
+
private readonly now;
|
|
71
|
+
private readonly makeId;
|
|
72
|
+
private readonly nodes;
|
|
73
|
+
private readonly heads;
|
|
74
|
+
/** Unreferenced nodes in the exact order they became collectible. */
|
|
75
|
+
private readonly evictable;
|
|
76
|
+
/** Branch heads plus explicit retainers. Absent means zero. */
|
|
77
|
+
private readonly references;
|
|
78
|
+
private readonly explicitPins;
|
|
79
|
+
private sequence;
|
|
80
|
+
constructor(options?: TimelineOptions$1);
|
|
81
|
+
/** Capture a new immutable value and move `branch` to it. */
|
|
82
|
+
commit(value: T, options?: CommitOptions$1): Checkpoint$1<T>;
|
|
83
|
+
/** Create a branch pointer without copying its checkpoint value. */
|
|
84
|
+
fork(branch: string, options?: ForkOptions$1): Checkpoint$1<T> | undefined;
|
|
85
|
+
/** Move a branch pointer to an existing checkpoint. */
|
|
86
|
+
checkout(branch: string, id: CheckpointId$1): Checkpoint$1<T>;
|
|
87
|
+
get(id: CheckpointId$1): Checkpoint$1<T>;
|
|
88
|
+
head(branch?: string): Checkpoint$1<T> | undefined;
|
|
89
|
+
hasBranch(branch: string): boolean;
|
|
90
|
+
branches(): Readonly<Record<string, CheckpointId$1>>;
|
|
91
|
+
checkpoints(): readonly Checkpoint$1<T>[];
|
|
92
|
+
/** Number of retained checkpoints without allocating an array. */
|
|
93
|
+
get size(): number;
|
|
94
|
+
/** Pin a checkpoint independently of branch heads (used by compatibility snapshot handles). */
|
|
95
|
+
retain(id: CheckpointId$1): Checkpoint$1<T>;
|
|
96
|
+
/** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
|
|
97
|
+
release(id: CheckpointId$1): boolean;
|
|
98
|
+
deleteBranch(branch: string): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Deterministically discard oldest unpinned checkpoints. Collection is O(number removed):
|
|
101
|
+
* commits never scan pinned nodes or the retained history. Parents are metadata rather than a
|
|
102
|
+
* storage dependency, so a retained node remains usable after pruning.
|
|
103
|
+
*/
|
|
104
|
+
gc(max?: number): CheckpointId$1[];
|
|
105
|
+
private collect;
|
|
106
|
+
private moveHead;
|
|
107
|
+
private addReference;
|
|
108
|
+
private removeReference;
|
|
109
|
+
private assertBranch;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Anything that can answer a Fetch `Request` with a `Response`.
|
|
114
|
+
*
|
|
115
|
+
* Every Mockingbird service implements this, and every runtime adapter consumes it.
|
|
116
|
+
* It is the only contract shared across the whole graph.
|
|
117
|
+
*/
|
|
118
|
+
interface FetchAPI$1 {
|
|
119
|
+
fetch(request: Request): Promise<Response>;
|
|
120
|
+
}
|
|
121
|
+
|
|
3
122
|
/**
|
|
4
123
|
* The single source of time for a service.
|
|
5
124
|
*
|
|
@@ -30,35 +149,6 @@ type Clock$1 = {
|
|
|
30
149
|
state(): ClockState$1;
|
|
31
150
|
};
|
|
32
151
|
|
|
33
|
-
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
34
|
-
type SqliteValue$2 = null | number | bigint | string | Uint8Array | boolean;
|
|
35
|
-
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
36
|
-
type SqliteRunResult$2 = {
|
|
37
|
-
changes: number;
|
|
38
|
-
lastInsertRowid: number | bigint;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Prepared statement bound to a {@link SqliteClient}.
|
|
42
|
-
*
|
|
43
|
-
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
44
|
-
*/
|
|
45
|
-
interface SqliteStatement$2 {
|
|
46
|
-
run(...params: SqliteValue$2[]): SqliteRunResult$2;
|
|
47
|
-
all<T = Record<string, unknown>>(...params: SqliteValue$2[]): T[];
|
|
48
|
-
get<T = Record<string, unknown>>(...params: SqliteValue$2[]): T | undefined;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Sync SQLite client port owned by Mockingbird.
|
|
52
|
-
*
|
|
53
|
-
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
54
|
-
* `bun:sqlite` instances all work when they expose this surface.
|
|
55
|
-
*/
|
|
56
|
-
interface SqliteClient$2 {
|
|
57
|
-
exec(sql: string): void;
|
|
58
|
-
prepare(sql: string): SqliteStatement$2;
|
|
59
|
-
transaction<T>(fn: () => T): T;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
152
|
/**
|
|
63
153
|
* Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
|
|
64
154
|
* request a percentage fault hits — is reproducible from a seed.
|
|
@@ -186,96 +276,6 @@ type FaultRegistry$1 = {
|
|
|
186
276
|
take(candidate: FaultCandidate$1): Promise<FaultHit$1[]>;
|
|
187
277
|
};
|
|
188
278
|
|
|
189
|
-
/** A stable identifier for a point in a {@link Timeline}. */
|
|
190
|
-
type CheckpointId$1 = string;
|
|
191
|
-
/** An immutable node in a timeline's checkpoint DAG. */
|
|
192
|
-
type Checkpoint$1<T> = Readonly<{
|
|
193
|
-
id: CheckpointId$1;
|
|
194
|
-
branch: string;
|
|
195
|
-
parent: CheckpointId$1 | null;
|
|
196
|
-
/** Logical time supplied by the timeline's injected clock. */
|
|
197
|
-
at: number;
|
|
198
|
-
value: T;
|
|
199
|
-
}>;
|
|
200
|
-
type TimelineOptions$1 = {
|
|
201
|
-
/** Logical clock used to stamp checkpoints. Defaults to a deterministic counter. */
|
|
202
|
-
now?: () => number;
|
|
203
|
-
/** Maximum retained checkpoints. Branch heads are never collected. Default 1,000. */
|
|
204
|
-
maxCheckpoints?: number;
|
|
205
|
-
/** Customize deterministic checkpoint IDs. */
|
|
206
|
-
id?: (sequence: number) => CheckpointId$1;
|
|
207
|
-
};
|
|
208
|
-
type CommitOptions$1 = {
|
|
209
|
-
branch?: string;
|
|
210
|
-
/** Parent checkpoint. Defaults to the selected branch's current head. */
|
|
211
|
-
parent?: CheckpointId$1 | null;
|
|
212
|
-
};
|
|
213
|
-
type ForkOptions$1 = {
|
|
214
|
-
/** Checkpoint to fork from. Defaults to the main branch's head. */
|
|
215
|
-
from?: CheckpointId$1;
|
|
216
|
-
};
|
|
217
|
-
/**
|
|
218
|
-
* Small, storage-agnostic checkpoint DAG shared by service runtimes. Its values may be immutable
|
|
219
|
-
* records, namespace images, or copy-on-write SQL engine snapshots.
|
|
220
|
-
*
|
|
221
|
-
* Values are retained by reference. Engines can therefore use persistent/COW snapshots while
|
|
222
|
-
* simpler services can use immutable values. IDs and GC order are deterministic, and all IO
|
|
223
|
-
* (the logical clock) is injected.
|
|
224
|
-
*/
|
|
225
|
-
declare class Timeline$1<T> {
|
|
226
|
-
readonly maxCheckpoints: number;
|
|
227
|
-
private readonly now;
|
|
228
|
-
private readonly makeId;
|
|
229
|
-
private readonly nodes;
|
|
230
|
-
private readonly heads;
|
|
231
|
-
/** Unreferenced nodes in the exact order they became collectible. */
|
|
232
|
-
private readonly evictable;
|
|
233
|
-
/** Branch heads plus explicit retainers. Absent means zero. */
|
|
234
|
-
private readonly references;
|
|
235
|
-
private readonly explicitPins;
|
|
236
|
-
private sequence;
|
|
237
|
-
constructor(options?: TimelineOptions$1);
|
|
238
|
-
/** Capture a new immutable value and move `branch` to it. */
|
|
239
|
-
commit(value: T, options?: CommitOptions$1): Checkpoint$1<T>;
|
|
240
|
-
/** Create a branch pointer without copying its checkpoint value. */
|
|
241
|
-
fork(branch: string, options?: ForkOptions$1): Checkpoint$1<T> | undefined;
|
|
242
|
-
/** Move a branch pointer to an existing checkpoint. */
|
|
243
|
-
checkout(branch: string, id: CheckpointId$1): Checkpoint$1<T>;
|
|
244
|
-
get(id: CheckpointId$1): Checkpoint$1<T>;
|
|
245
|
-
head(branch?: string): Checkpoint$1<T> | undefined;
|
|
246
|
-
hasBranch(branch: string): boolean;
|
|
247
|
-
branches(): Readonly<Record<string, CheckpointId$1>>;
|
|
248
|
-
checkpoints(): readonly Checkpoint$1<T>[];
|
|
249
|
-
/** Number of retained checkpoints without allocating an array. */
|
|
250
|
-
get size(): number;
|
|
251
|
-
/** Pin a checkpoint independently of branch heads (used by compatibility snapshot handles). */
|
|
252
|
-
retain(id: CheckpointId$1): Checkpoint$1<T>;
|
|
253
|
-
/** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
|
|
254
|
-
release(id: CheckpointId$1): boolean;
|
|
255
|
-
deleteBranch(branch: string): boolean;
|
|
256
|
-
/**
|
|
257
|
-
* Deterministically discard oldest unpinned checkpoints. Collection is O(number removed):
|
|
258
|
-
* commits never scan pinned nodes or the retained history. Parents are metadata rather than a
|
|
259
|
-
* storage dependency, so a retained node remains usable after pruning.
|
|
260
|
-
*/
|
|
261
|
-
gc(max?: number): CheckpointId$1[];
|
|
262
|
-
private collect;
|
|
263
|
-
private moveHead;
|
|
264
|
-
private addReference;
|
|
265
|
-
private removeReference;
|
|
266
|
-
private assertBranch;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Anything that can answer a Fetch `Request` with a `Response`.
|
|
271
|
-
*
|
|
272
|
-
* Every Mockingbird service implements this, and every runtime adapter consumes it.
|
|
273
|
-
* It is the only contract shared across the whole graph.
|
|
274
|
-
*/
|
|
275
|
-
interface FetchAPI$1 {
|
|
276
|
-
fetch(request: Request): Promise<Response>;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
279
|
/**
|
|
280
280
|
* One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
|
|
281
281
|
* `kind` is `media_type` when the body is present but its media type is not one the operation
|
|
@@ -317,6 +317,10 @@ type RequestLog$1 = {
|
|
|
317
317
|
ids?: Record<string, string>;
|
|
318
318
|
/** Set when the service created a resource the request referred to but that did not exist. */
|
|
319
319
|
adopted?: boolean;
|
|
320
|
+
/** Explicit durable acceptance, independent of response delivery. */
|
|
321
|
+
accepted?: boolean;
|
|
322
|
+
/** Checkpoint captured at explicit acceptance. */
|
|
323
|
+
checkpoint?: string;
|
|
320
324
|
/** Set on a rejection (status ≥ 400) the mock produced itself, never on a scripted fault. */
|
|
321
325
|
request?: RejectedRequest$1;
|
|
322
326
|
/** The validation issues behind a rejection, when the service found any. */
|
|
@@ -614,36 +618,6 @@ type ServeTarget = {
|
|
|
614
618
|
listening?(server: Listening): void;
|
|
615
619
|
};
|
|
616
620
|
|
|
617
|
-
/**
|
|
618
|
-
* The single source of time for a service.
|
|
619
|
-
*
|
|
620
|
-
* Every timestamp a mock writes reads from here, so a suite moves time instead of
|
|
621
|
-
* sleeping: appointment windows, result delays and expiries become reachable in
|
|
622
|
-
* milliseconds. A frozen clock also makes timestamps reproducible from a seed.
|
|
623
|
-
*/
|
|
624
|
-
type ClockState = {
|
|
625
|
-
/** Current epoch milliseconds. */
|
|
626
|
-
now: number;
|
|
627
|
-
/** True while time does not advance on its own. */
|
|
628
|
-
frozen: boolean;
|
|
629
|
-
/** Milliseconds this clock adds to its underlying source. */
|
|
630
|
-
offsetMs: number;
|
|
631
|
-
};
|
|
632
|
-
type Clock = {
|
|
633
|
-
now(): number;
|
|
634
|
-
/** Pin the clock to an exact instant, keeping it frozen if it already was. */
|
|
635
|
-
set(epochMs: number): void;
|
|
636
|
-
/** Move the clock forward, or back with a negative delta. */
|
|
637
|
-
advance(deltaMs: number): void;
|
|
638
|
-
/** Stop time at the current instant. */
|
|
639
|
-
freeze(): void;
|
|
640
|
-
/** Resume from the current instant. */
|
|
641
|
-
unfreeze(): void;
|
|
642
|
-
/** Drop back to the underlying source, live. */
|
|
643
|
-
reset(): void;
|
|
644
|
-
state(): ClockState;
|
|
645
|
-
};
|
|
646
|
-
|
|
647
621
|
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
648
622
|
type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
|
|
649
623
|
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
@@ -715,6 +689,139 @@ declare class Collection<T> {
|
|
|
715
689
|
}>;
|
|
716
690
|
}
|
|
717
691
|
|
|
692
|
+
/** A stable identifier for a point in a {@link Timeline}. */
|
|
693
|
+
type CheckpointId = string;
|
|
694
|
+
/** An immutable node in a timeline's checkpoint DAG. */
|
|
695
|
+
type Checkpoint<T> = Readonly<{
|
|
696
|
+
id: CheckpointId;
|
|
697
|
+
branch: string;
|
|
698
|
+
parent: CheckpointId | null;
|
|
699
|
+
/** Logical time supplied by the timeline's injected clock. */
|
|
700
|
+
at: number;
|
|
701
|
+
value: T;
|
|
702
|
+
}>;
|
|
703
|
+
type TimelineOptions = {
|
|
704
|
+
/** Logical clock used to stamp checkpoints. Defaults to a deterministic counter. */
|
|
705
|
+
now?: () => number;
|
|
706
|
+
/** Maximum retained checkpoints. Branch heads are never collected. Default 1,000. */
|
|
707
|
+
maxCheckpoints?: number;
|
|
708
|
+
/** Customize deterministic checkpoint IDs. */
|
|
709
|
+
id?: (sequence: number) => CheckpointId;
|
|
710
|
+
};
|
|
711
|
+
type CommitOptions = {
|
|
712
|
+
branch?: string;
|
|
713
|
+
/** Parent checkpoint. Defaults to the selected branch's current head. */
|
|
714
|
+
parent?: CheckpointId | null;
|
|
715
|
+
};
|
|
716
|
+
type ForkOptions = {
|
|
717
|
+
/** Checkpoint to fork from. Defaults to the main branch's head. */
|
|
718
|
+
from?: CheckpointId;
|
|
719
|
+
};
|
|
720
|
+
/**
|
|
721
|
+
* Small, storage-agnostic checkpoint DAG shared by service runtimes. Its values may be immutable
|
|
722
|
+
* records, namespace images, or copy-on-write SQL engine snapshots.
|
|
723
|
+
*
|
|
724
|
+
* Values are retained by reference. Engines can therefore use persistent/COW snapshots while
|
|
725
|
+
* simpler services can use immutable values. IDs and GC order are deterministic, and all IO
|
|
726
|
+
* (the logical clock) is injected.
|
|
727
|
+
*/
|
|
728
|
+
declare class Timeline<T> {
|
|
729
|
+
readonly maxCheckpoints: number;
|
|
730
|
+
private readonly now;
|
|
731
|
+
private readonly makeId;
|
|
732
|
+
private readonly nodes;
|
|
733
|
+
private readonly heads;
|
|
734
|
+
/** Unreferenced nodes in the exact order they became collectible. */
|
|
735
|
+
private readonly evictable;
|
|
736
|
+
/** Branch heads plus explicit retainers. Absent means zero. */
|
|
737
|
+
private readonly references;
|
|
738
|
+
private readonly explicitPins;
|
|
739
|
+
private sequence;
|
|
740
|
+
constructor(options?: TimelineOptions);
|
|
741
|
+
/** Capture a new immutable value and move `branch` to it. */
|
|
742
|
+
commit(value: T, options?: CommitOptions): Checkpoint<T>;
|
|
743
|
+
/** Create a branch pointer without copying its checkpoint value. */
|
|
744
|
+
fork(branch: string, options?: ForkOptions): Checkpoint<T> | undefined;
|
|
745
|
+
/** Move a branch pointer to an existing checkpoint. */
|
|
746
|
+
checkout(branch: string, id: CheckpointId): Checkpoint<T>;
|
|
747
|
+
get(id: CheckpointId): Checkpoint<T>;
|
|
748
|
+
head(branch?: string): Checkpoint<T> | undefined;
|
|
749
|
+
hasBranch(branch: string): boolean;
|
|
750
|
+
branches(): Readonly<Record<string, CheckpointId>>;
|
|
751
|
+
checkpoints(): readonly Checkpoint<T>[];
|
|
752
|
+
/** Number of retained checkpoints without allocating an array. */
|
|
753
|
+
get size(): number;
|
|
754
|
+
/** Pin a checkpoint independently of branch heads (used by compatibility snapshot handles). */
|
|
755
|
+
retain(id: CheckpointId): Checkpoint<T>;
|
|
756
|
+
/** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
|
|
757
|
+
release(id: CheckpointId): boolean;
|
|
758
|
+
deleteBranch(branch: string): boolean;
|
|
759
|
+
/**
|
|
760
|
+
* Deterministically discard oldest unpinned checkpoints. Collection is O(number removed):
|
|
761
|
+
* commits never scan pinned nodes or the retained history. Parents are metadata rather than a
|
|
762
|
+
* storage dependency, so a retained node remains usable after pruning.
|
|
763
|
+
*/
|
|
764
|
+
gc(max?: number): CheckpointId[];
|
|
765
|
+
private collect;
|
|
766
|
+
private moveHead;
|
|
767
|
+
private addReference;
|
|
768
|
+
private removeReference;
|
|
769
|
+
private assertBranch;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Anything that can answer a Fetch `Request` with a `Response`.
|
|
774
|
+
*
|
|
775
|
+
* Every Mockingbird service implements this, and every runtime adapter consumes it.
|
|
776
|
+
* It is the only contract shared across the whole graph.
|
|
777
|
+
*/
|
|
778
|
+
interface FetchAPI {
|
|
779
|
+
fetch(request: Request): Promise<Response>;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/** Options every provider constructor accepts. */
|
|
783
|
+
type APIOptions = {
|
|
784
|
+
/** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
|
|
785
|
+
sqlite?: SqliteClient$1;
|
|
786
|
+
/** Clock used for `created`-style fields. Default `Date.now`. */
|
|
787
|
+
now?: () => number;
|
|
788
|
+
/**
|
|
789
|
+
* Storage namespace for this instance's records. Instances sharing one SQLite
|
|
790
|
+
* client stay isolated when their namespaces differ. Defaults to the service name.
|
|
791
|
+
*/
|
|
792
|
+
namespace?: string;
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* The single source of time for a service.
|
|
797
|
+
*
|
|
798
|
+
* Every timestamp a mock writes reads from here, so a suite moves time instead of
|
|
799
|
+
* sleeping: appointment windows, result delays and expiries become reachable in
|
|
800
|
+
* milliseconds. A frozen clock also makes timestamps reproducible from a seed.
|
|
801
|
+
*/
|
|
802
|
+
type ClockState = {
|
|
803
|
+
/** Current epoch milliseconds. */
|
|
804
|
+
now: number;
|
|
805
|
+
/** True while time does not advance on its own. */
|
|
806
|
+
frozen: boolean;
|
|
807
|
+
/** Milliseconds this clock adds to its underlying source. */
|
|
808
|
+
offsetMs: number;
|
|
809
|
+
};
|
|
810
|
+
type Clock = {
|
|
811
|
+
now(): number;
|
|
812
|
+
/** Pin the clock to an exact instant, keeping it frozen if it already was. */
|
|
813
|
+
set(epochMs: number): void;
|
|
814
|
+
/** Move the clock forward, or back with a negative delta. */
|
|
815
|
+
advance(deltaMs: number): void;
|
|
816
|
+
/** Stop time at the current instant. */
|
|
817
|
+
freeze(): void;
|
|
818
|
+
/** Resume from the current instant. */
|
|
819
|
+
unfreeze(): void;
|
|
820
|
+
/** Drop back to the underlying source, live. */
|
|
821
|
+
reset(): void;
|
|
822
|
+
state(): ClockState;
|
|
823
|
+
};
|
|
824
|
+
|
|
718
825
|
/**
|
|
719
826
|
* Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
|
|
720
827
|
* request a percentage fault hits — is reproducible from a seed.
|
|
@@ -842,109 +949,6 @@ type FaultRegistry = {
|
|
|
842
949
|
take(candidate: FaultCandidate): Promise<FaultHit[]>;
|
|
843
950
|
};
|
|
844
951
|
|
|
845
|
-
/** A stable identifier for a point in a {@link Timeline}. */
|
|
846
|
-
type CheckpointId = string;
|
|
847
|
-
/** An immutable node in a timeline's checkpoint DAG. */
|
|
848
|
-
type Checkpoint<T> = Readonly<{
|
|
849
|
-
id: CheckpointId;
|
|
850
|
-
branch: string;
|
|
851
|
-
parent: CheckpointId | null;
|
|
852
|
-
/** Logical time supplied by the timeline's injected clock. */
|
|
853
|
-
at: number;
|
|
854
|
-
value: T;
|
|
855
|
-
}>;
|
|
856
|
-
type TimelineOptions = {
|
|
857
|
-
/** Logical clock used to stamp checkpoints. Defaults to a deterministic counter. */
|
|
858
|
-
now?: () => number;
|
|
859
|
-
/** Maximum retained checkpoints. Branch heads are never collected. Default 1,000. */
|
|
860
|
-
maxCheckpoints?: number;
|
|
861
|
-
/** Customize deterministic checkpoint IDs. */
|
|
862
|
-
id?: (sequence: number) => CheckpointId;
|
|
863
|
-
};
|
|
864
|
-
type CommitOptions = {
|
|
865
|
-
branch?: string;
|
|
866
|
-
/** Parent checkpoint. Defaults to the selected branch's current head. */
|
|
867
|
-
parent?: CheckpointId | null;
|
|
868
|
-
};
|
|
869
|
-
type ForkOptions = {
|
|
870
|
-
/** Checkpoint to fork from. Defaults to the main branch's head. */
|
|
871
|
-
from?: CheckpointId;
|
|
872
|
-
};
|
|
873
|
-
/**
|
|
874
|
-
* Small, storage-agnostic checkpoint DAG shared by service runtimes. Its values may be immutable
|
|
875
|
-
* records, namespace images, or copy-on-write SQL engine snapshots.
|
|
876
|
-
*
|
|
877
|
-
* Values are retained by reference. Engines can therefore use persistent/COW snapshots while
|
|
878
|
-
* simpler services can use immutable values. IDs and GC order are deterministic, and all IO
|
|
879
|
-
* (the logical clock) is injected.
|
|
880
|
-
*/
|
|
881
|
-
declare class Timeline<T> {
|
|
882
|
-
readonly maxCheckpoints: number;
|
|
883
|
-
private readonly now;
|
|
884
|
-
private readonly makeId;
|
|
885
|
-
private readonly nodes;
|
|
886
|
-
private readonly heads;
|
|
887
|
-
/** Unreferenced nodes in the exact order they became collectible. */
|
|
888
|
-
private readonly evictable;
|
|
889
|
-
/** Branch heads plus explicit retainers. Absent means zero. */
|
|
890
|
-
private readonly references;
|
|
891
|
-
private readonly explicitPins;
|
|
892
|
-
private sequence;
|
|
893
|
-
constructor(options?: TimelineOptions);
|
|
894
|
-
/** Capture a new immutable value and move `branch` to it. */
|
|
895
|
-
commit(value: T, options?: CommitOptions): Checkpoint<T>;
|
|
896
|
-
/** Create a branch pointer without copying its checkpoint value. */
|
|
897
|
-
fork(branch: string, options?: ForkOptions): Checkpoint<T> | undefined;
|
|
898
|
-
/** Move a branch pointer to an existing checkpoint. */
|
|
899
|
-
checkout(branch: string, id: CheckpointId): Checkpoint<T>;
|
|
900
|
-
get(id: CheckpointId): Checkpoint<T>;
|
|
901
|
-
head(branch?: string): Checkpoint<T> | undefined;
|
|
902
|
-
hasBranch(branch: string): boolean;
|
|
903
|
-
branches(): Readonly<Record<string, CheckpointId>>;
|
|
904
|
-
checkpoints(): readonly Checkpoint<T>[];
|
|
905
|
-
/** Number of retained checkpoints without allocating an array. */
|
|
906
|
-
get size(): number;
|
|
907
|
-
/** Pin a checkpoint independently of branch heads (used by compatibility snapshot handles). */
|
|
908
|
-
retain(id: CheckpointId): Checkpoint<T>;
|
|
909
|
-
/** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
|
|
910
|
-
release(id: CheckpointId): boolean;
|
|
911
|
-
deleteBranch(branch: string): boolean;
|
|
912
|
-
/**
|
|
913
|
-
* Deterministically discard oldest unpinned checkpoints. Collection is O(number removed):
|
|
914
|
-
* commits never scan pinned nodes or the retained history. Parents are metadata rather than a
|
|
915
|
-
* storage dependency, so a retained node remains usable after pruning.
|
|
916
|
-
*/
|
|
917
|
-
gc(max?: number): CheckpointId[];
|
|
918
|
-
private collect;
|
|
919
|
-
private moveHead;
|
|
920
|
-
private addReference;
|
|
921
|
-
private removeReference;
|
|
922
|
-
private assertBranch;
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
/**
|
|
926
|
-
* Anything that can answer a Fetch `Request` with a `Response`.
|
|
927
|
-
*
|
|
928
|
-
* Every Mockingbird service implements this, and every runtime adapter consumes it.
|
|
929
|
-
* It is the only contract shared across the whole graph.
|
|
930
|
-
*/
|
|
931
|
-
interface FetchAPI {
|
|
932
|
-
fetch(request: Request): Promise<Response>;
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
/** Options every provider constructor accepts. */
|
|
936
|
-
type APIOptions = {
|
|
937
|
-
/** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
|
|
938
|
-
sqlite?: SqliteClient$1;
|
|
939
|
-
/** Clock used for `created`-style fields. Default `Date.now`. */
|
|
940
|
-
now?: () => number;
|
|
941
|
-
/**
|
|
942
|
-
* Storage namespace for this instance's records. Instances sharing one SQLite
|
|
943
|
-
* client stay isolated when their namespaces differ. Defaults to the service name.
|
|
944
|
-
*/
|
|
945
|
-
namespace?: string;
|
|
946
|
-
};
|
|
947
|
-
|
|
948
952
|
/**
|
|
949
953
|
* One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
|
|
950
954
|
* `kind` is `media_type` when the body is present but its media type is not one the operation
|
|
@@ -986,6 +990,10 @@ type RequestLog = {
|
|
|
986
990
|
ids?: Record<string, string>;
|
|
987
991
|
/** Set when the service created a resource the request referred to but that did not exist. */
|
|
988
992
|
adopted?: boolean;
|
|
993
|
+
/** Explicit durable acceptance, independent of response delivery. */
|
|
994
|
+
accepted?: boolean;
|
|
995
|
+
/** Checkpoint captured at explicit acceptance. */
|
|
996
|
+
checkpoint?: string;
|
|
989
997
|
/** Set on a rejection (status ≥ 400) the mock produced itself, never on a scripted fault. */
|
|
990
998
|
request?: RejectedRequest;
|
|
991
999
|
/** The validation issues behind a rejection, when the service found any. */
|
package/dist/server.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crvouga/mockingbird-service-cognito",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Stateful Amazon Cognito User Pools mock for AWS SDK and browser authentication tests.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"pack:check": "bun ../../../scripts/pack-check.ts"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"@crvouga/mockingbird-service-sqlite": "2.1.
|
|
100
|
+
"@crvouga/mockingbird-service-sqlite": "2.1.1"
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
103
|
"@aws-sdk/client-cognito-identity-provider": "3.1132.0",
|