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