@crvouga/mockingbird-service-junction 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/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  runCli,
5
5
  serveCommand,
6
6
  serveTarget
7
- } from "./chunk-CC4RCCHM.js";
7
+ } from "./chunk-TRSGVIZL.js";
8
8
  import {
9
9
  DEFAULT_JUNCTION_BASE_URL,
10
10
  createRuntime,
@@ -12,7 +12,7 @@ import {
12
12
  isSandboxKey,
13
13
  pullCorpus,
14
14
  verifyAgainstReal
15
- } from "./chunk-5EF324W7.js";
15
+ } from "./chunk-UXBNCMYV.js";
16
16
  import {
17
17
  defaultCorpus
18
18
  } from "./chunk-C2UGIPPM.js";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,137 @@
1
1
  import { Hono } from 'hono';
2
2
 
3
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
4
+ type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
5
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
6
+ type SqliteRunResult$1 = {
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$1 {
16
+ run(...params: SqliteValue$1[]): SqliteRunResult$1;
17
+ all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
18
+ get<T = Record<string, unknown>>(...params: SqliteValue$1[]): 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$1 {
27
+ exec(sql: string): void;
28
+ prepare(sql: string): SqliteStatement$1;
29
+ transaction<T>(fn: () => T): T;
30
+ }
31
+
32
+ /** A stable identifier for a point in a {@link Timeline}. */
33
+ type CheckpointId = string;
34
+ /** An immutable node in a timeline's checkpoint DAG. */
35
+ type Checkpoint<T> = Readonly<{
36
+ id: CheckpointId;
37
+ branch: string;
38
+ parent: CheckpointId | null;
39
+ /** Logical time supplied by the timeline's injected clock. */
40
+ at: number;
41
+ value: T;
42
+ }>;
43
+ type TimelineOptions = {
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;
50
+ };
51
+ type CommitOptions = {
52
+ branch?: string;
53
+ /** Parent checkpoint. Defaults to the selected branch's current head. */
54
+ parent?: CheckpointId | null;
55
+ };
56
+ type ForkOptions = {
57
+ /** Checkpoint to fork from. Defaults to the main branch's head. */
58
+ from?: CheckpointId;
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<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);
81
+ /** Capture a new immutable value and move `branch` to it. */
82
+ commit(value: T, options?: CommitOptions): Checkpoint<T>;
83
+ /** Create a branch pointer without copying its checkpoint value. */
84
+ fork(branch: string, options?: ForkOptions): Checkpoint<T> | undefined;
85
+ /** Move a branch pointer to an existing checkpoint. */
86
+ checkout(branch: string, id: CheckpointId): Checkpoint<T>;
87
+ get(id: CheckpointId): Checkpoint<T>;
88
+ head(branch?: string): Checkpoint<T> | undefined;
89
+ hasBranch(branch: string): boolean;
90
+ branches(): Readonly<Record<string, CheckpointId>>;
91
+ checkpoints(): readonly Checkpoint<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): Checkpoint<T>;
96
+ /** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
97
+ release(id: CheckpointId): 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[];
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
+
122
+ /** Options every provider constructor accepts. */
123
+ type APIOptions = {
124
+ /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
125
+ sqlite?: SqliteClient$1;
126
+ /** Clock used for `created`-style fields. Default `Date.now`. */
127
+ now?: () => number;
128
+ /**
129
+ * Storage namespace for this instance's records. Instances sharing one SQLite
130
+ * client stay isolated when their namespaces differ. Defaults to the service name.
131
+ */
132
+ namespace?: string;
133
+ };
134
+
3
135
  /**
4
136
  * The single source of time for a service.
5
137
  *
@@ -30,35 +162,6 @@ type Clock = {
30
162
  state(): ClockState;
31
163
  };
32
164
 
33
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
34
- type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
35
- /** Mutation counters returned by {@link SqliteStatement.run}. */
36
- type SqliteRunResult$1 = {
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$1 {
46
- run(...params: SqliteValue$1[]): SqliteRunResult$1;
47
- all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
48
- get<T = Record<string, unknown>>(...params: SqliteValue$1[]): 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$1 {
57
- exec(sql: string): void;
58
- prepare(sql: string): SqliteStatement$1;
59
- transaction<T>(fn: () => T): T;
60
- }
61
-
62
165
  /**
63
166
  * Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
64
167
  * request a percentage fault hits — is reproducible from a seed.
@@ -186,109 +289,6 @@ type FaultRegistry = {
186
289
  take(candidate: FaultCandidate): Promise<FaultHit[]>;
187
290
  };
188
291
 
189
- /** A stable identifier for a point in a {@link Timeline}. */
190
- type CheckpointId = string;
191
- /** An immutable node in a timeline's checkpoint DAG. */
192
- type Checkpoint<T> = Readonly<{
193
- id: CheckpointId;
194
- branch: string;
195
- parent: CheckpointId | null;
196
- /** Logical time supplied by the timeline's injected clock. */
197
- at: number;
198
- value: T;
199
- }>;
200
- type TimelineOptions = {
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;
207
- };
208
- type CommitOptions = {
209
- branch?: string;
210
- /** Parent checkpoint. Defaults to the selected branch's current head. */
211
- parent?: CheckpointId | null;
212
- };
213
- type ForkOptions = {
214
- /** Checkpoint to fork from. Defaults to the main branch's head. */
215
- from?: CheckpointId;
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<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);
238
- /** Capture a new immutable value and move `branch` to it. */
239
- commit(value: T, options?: CommitOptions): Checkpoint<T>;
240
- /** Create a branch pointer without copying its checkpoint value. */
241
- fork(branch: string, options?: ForkOptions): Checkpoint<T> | undefined;
242
- /** Move a branch pointer to an existing checkpoint. */
243
- checkout(branch: string, id: CheckpointId): Checkpoint<T>;
244
- get(id: CheckpointId): Checkpoint<T>;
245
- head(branch?: string): Checkpoint<T> | undefined;
246
- hasBranch(branch: string): boolean;
247
- branches(): Readonly<Record<string, CheckpointId>>;
248
- checkpoints(): readonly Checkpoint<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): Checkpoint<T>;
253
- /** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
254
- release(id: CheckpointId): 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[];
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
- /** Options every provider constructor accepts. */
280
- type APIOptions = {
281
- /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
282
- sqlite?: SqliteClient$1;
283
- /** Clock used for `created`-style fields. Default `Date.now`. */
284
- now?: () => number;
285
- /**
286
- * Storage namespace for this instance's records. Instances sharing one SQLite
287
- * client stay isolated when their namespaces differ. Defaults to the service name.
288
- */
289
- namespace?: string;
290
- };
291
-
292
292
  /**
293
293
  * One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
294
294
  * `kind` is `media_type` when the body is present but its media type is not one the operation
@@ -330,6 +330,10 @@ type RequestLog = {
330
330
  ids?: Record<string, string>;
331
331
  /** Set when the service created a resource the request referred to but that did not exist. */
332
332
  adopted?: boolean;
333
+ /** Explicit durable acceptance, independent of response delivery. */
334
+ accepted?: boolean;
335
+ /** Checkpoint captured at explicit acceptance. */
336
+ checkpoint?: string;
333
337
  /** Set on a rejection (status ≥ 400) the mock produced itself, never on a scripted fault. */
334
338
  request?: RejectedRequest;
335
339
  /** The validation issues behind a rejection, when the service found any. */
package/dist/index.js CHANGED
@@ -53,7 +53,7 @@ import {
53
53
  supportedOperationIds,
54
54
  verifyAgainstReal,
55
55
  verifySvix
56
- } from "./chunk-5EF324W7.js";
56
+ } from "./chunk-UXBNCMYV.js";
57
57
  import {
58
58
  SEALED_CORPUS_VERSION,
59
59
  SUPPORTED_SEALED_CORPUS_VERSIONS,