@crvouga/mockingbird-service-slack 3.1.0 → 3.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/server.d.ts CHANGED
@@ -1,34 +1,16 @@
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;
4
+ type MountedAPI$1 = FetchAPI$2 & {
5
+ readonly prefix: string;
6
+ GET: FetchHandler$1;
7
+ POST: FetchHandler$1;
8
+ PUT: FetchHandler$1;
9
+ PATCH: FetchHandler$1;
10
+ DELETE: FetchHandler$1;
11
+ HEAD: FetchHandler$1;
12
+ OPTIONS: FetchHandler$1;
10
13
  };
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
14
 
33
15
  /** A stable identifier for a point in a {@link Timeline}. */
34
16
  type CheckpointId$1 = string;
@@ -119,6 +101,37 @@ declare class Timeline$1<T> {
119
101
  interface FetchAPI$2 {
120
102
  fetch(request: Request): Promise<Response>;
121
103
  }
104
+ /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
105
+ type FetchHandler$1 = (request: Request) => Promise<Response>;
106
+
107
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
108
+ type SqliteValue$3 = null | number | bigint | string | Uint8Array | boolean;
109
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
110
+ type SqliteRunResult$3 = {
111
+ changes: number;
112
+ lastInsertRowid: number | bigint;
113
+ };
114
+ /**
115
+ * Prepared statement bound to a {@link SqliteClient}.
116
+ *
117
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
118
+ */
119
+ interface SqliteStatement$3 {
120
+ run(...params: SqliteValue$3[]): SqliteRunResult$3;
121
+ all<T = Record<string, unknown>>(...params: SqliteValue$3[]): T[];
122
+ get<T = Record<string, unknown>>(...params: SqliteValue$3[]): T | undefined;
123
+ }
124
+ /**
125
+ * Sync SQLite client port owned by Mockingbird.
126
+ *
127
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
128
+ * `bun:sqlite` instances all work when they expose this surface.
129
+ */
130
+ interface SqliteClient$3 {
131
+ exec(sql: string): void;
132
+ prepare(sql: string): SqliteStatement$3;
133
+ transaction<T>(fn: () => T): T;
134
+ }
122
135
 
123
136
  /**
124
137
  * The single source of time for a service.
@@ -132,7 +145,7 @@ type ClockState$1 = {
132
145
  now: number;
133
146
  /** True while time does not advance on its own. */
134
147
  frozen: boolean;
135
- /** Milliseconds this clock adds to its underlying source. */
148
+ /** Milliseconds a running clock adds to its underlying source. `0` while frozen. */
136
149
  offsetMs: number;
137
150
  };
138
151
  type Clock$1 = {
@@ -168,7 +181,10 @@ type Rng$1 = {
168
181
  state(): number;
169
182
  /** Restore a state previously returned by {@link state}. */
170
183
  setState(state: number): void;
171
- seed: number;
184
+ /** Restart the stream from a new seed. `reset` then returns to this seed. */
185
+ reseed(seed: number | string): void;
186
+ /** The seed the stream currently starts from. */
187
+ readonly seed: number;
172
188
  };
173
189
 
174
190
  /**
@@ -177,44 +193,83 @@ type Rng$1 = {
177
193
  * This is how a suite reaches the vendor's failure modes without the vendor: the
178
194
  * quota error that only appears when a shared sandbox is full, the 429 that only
179
195
  * appears under load, the 5xx that proves a retry path works.
196
+ *
197
+ * A rule has three parts. What it **matches** (`operationId`, `method`, `path`, …), **when**
198
+ * it fires among the matching requests (`after`, `every`, `count`, `rate`, `from`, `until`),
199
+ * and what it **does** (`status`, `delay`, `timeout`, `drop`, `truncate`, `effect`).
180
200
  */
181
201
  type FaultRule$1 = {
182
- /** Stable id, so a suite can retire exactly the rule it added. */
202
+ /** Stable id, so a suite can retire exactly the rule it added. Unique within a namespace. */
183
203
  id: string;
184
204
  /** Fault only this operation. Omit to match every operation. */
185
205
  operationId?: string;
186
206
  /** Fault only this HTTP method, case-insensitive. Omit to match every method. */
187
207
  method?: string;
208
+ /** Fault only this exact path. */
209
+ path?: string;
188
210
  /** Fault only paths starting with this prefix. Omit to match every path. */
189
211
  pathPrefix?: string;
212
+ /** Fault only paths matching this regular expression (JavaScript syntax, unanchored). */
213
+ pathPattern?: string;
214
+ /** Fault only requests carrying these headers. `"*"` matches any value. */
215
+ requestHeaders?: Record<string, string>;
216
+ /** Fault only requests carrying these query parameters. `"*"` matches any value. */
217
+ query?: Record<string, string>;
190
218
  /**
191
219
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
192
220
  * an in-process caller usually wants, and what a parallel worker usually does not:
193
221
  * rules added through `POST /__admin/faults` default to the calling namespace.
194
222
  */
195
223
  namespace?: string;
224
+ /** Let this many matching requests through first. */
225
+ after?: number;
226
+ /** Then fault only every nth matching request: `3` faults the 3rd, 6th, 9th. */
227
+ every?: number;
228
+ /** Retire the rule after this many faults. Omit to keep it until removed. */
229
+ count?: number;
230
+ /** Fault this fraction of the remaining requests, `0`–`1`, drawn from the seed. Default `1`. */
231
+ rate?: number;
196
232
  /**
197
- * Status of the injected response. Omit for a rule that only delays (`delayMs` /
198
- * `latencyMs`), only drops the connection (`drop`), or only switches on an `effect`:
199
- * the request then still reaches the service.
233
+ * Fault only from this instant on the namespace clock. A duration (`"5m"`) counts from the
234
+ * clock when the rule was added. Listed as epoch ms.
235
+ */
236
+ from?: Instant$1 | Duration$1;
237
+ /** Stop faulting at this instant on the namespace clock. A duration counts from when added. */
238
+ until?: Instant$1 | Duration$1;
239
+ /**
240
+ * Status of the injected response. Omit for a rule that only delays, times out, drops,
241
+ * truncates, or switches on an `effect`: the request then still reaches the service.
200
242
  */
201
243
  status?: number;
202
244
  /** Response body, serialized as JSON. A string is sent as-is. */
203
245
  body?: unknown;
246
+ /** Response headers. */
204
247
  headers?: Record<string, string>;
205
- /** Retire the rule after this many faults. Omit to keep it until removed. */
206
- count?: number;
207
- /** Fault this fraction of matching requests, `0`–`1`. Default `1`. */
208
- rate?: number;
209
- /** Hold the response back this long, to exercise timeouts. */
248
+ /** Hold the response back this long. Listed as `delayMs`. */
249
+ delay?: Duration$1;
250
+ /** `delay`, in milliseconds. */
210
251
  delayMs?: number;
211
252
  /** Alias of `delayMs`. */
212
253
  latencyMs?: number;
254
+ /** Extra seeded delay in `[0, jitter]`. Listed as `jitterMs`. */
255
+ jitter?: Duration$1;
256
+ jitterMs?: number;
257
+ /**
258
+ * Never answer: hold the request this long, then drop the connection. Listed as
259
+ * `timeoutMs`. With virtual time the wait is spent on the mock clock.
260
+ */
261
+ timeout?: Duration$1;
262
+ timeoutMs?: number;
213
263
  /**
214
264
  * Drop the connection instead of answering: an in-process `fetch` rejects with a
215
265
  * `TypeError`, and a served mock destroys the socket. Models "unknown outcome" failures.
216
266
  */
217
267
  drop?: boolean;
268
+ /**
269
+ * Cut the response body off after this many bytes: the status and headers arrive, then
270
+ * the connection dies mid-body.
271
+ */
272
+ truncate?: number;
218
273
  /**
219
274
  * A named service behaviour to switch on for the matching request instead of (or
220
275
  * before) a canned response, e.g. `created_but_500` or `numeric_tracking_id`. Services
@@ -223,8 +278,8 @@ type FaultRule$1 = {
223
278
  effect?: string;
224
279
  /** Parameters for `effect`. */
225
280
  params?: Record<string, unknown>;
226
- /** From the preset this rule was expanded from, if any. */
227
- preset?: string;
281
+ /** The preset this rule was expanded from, if any. */
282
+ fromPreset?: string;
228
283
  };
229
284
  /** A fault that fired for one request. */
230
285
  type FaultHit$1 = {
@@ -232,6 +287,10 @@ type FaultHit$1 = {
232
287
  /** The injected response; absent when the rule only delays, drops, or sets an effect. */
233
288
  response?: Response;
234
289
  drop?: boolean;
290
+ /** Set with `drop` when the rule held the request for its `timeout` first. */
291
+ timeout?: boolean;
292
+ /** Bytes of response body to let through before the connection dies. */
293
+ truncate?: number;
235
294
  effect?: {
236
295
  name: string;
237
296
  params: Record<string, unknown>;
@@ -243,38 +302,200 @@ type FaultCandidate$1 = {
243
302
  method: string;
244
303
  path: string;
245
304
  namespace: string;
305
+ /** Request headers and query, for rules that match on them. */
306
+ headers?: Headers;
307
+ query?: URLSearchParams;
308
+ /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
309
+ now?: number;
310
+ /** How to spend a delay for this request. Default: the registry's own sleep. */
311
+ wait?: (ms: number) => Promise<void>;
312
+ };
313
+ /** A stored rule and how often it was consulted. */
314
+ type FaultListing$1 = FaultRule$1 & {
315
+ /** Faults left before the rule retires. `null` when it has no `count`. */
316
+ remaining: number | null;
317
+ /** Times the rule faulted a request. */
318
+ hits: number;
319
+ /** Requests that matched the rule, faulted or not. */
320
+ seen: number;
321
+ };
322
+ /** A namespace's own rules, with their counters, in the order they are tried. */
323
+ type FaultSnapshot$1 = {
324
+ /**
325
+ * `position` is how many `"*"` rules are tried before the rule, which is what its place
326
+ * in the order means to a request and holds in any process.
327
+ */
328
+ rules: (FaultListing$1 & {
329
+ position?: number;
330
+ })[];
331
+ /** How many `fault_<n>` ids the namespace has handed out. */
332
+ nextId?: number;
246
333
  };
247
334
  type FaultRegistry$1 = {
248
- isolateNamespaces(): void;
249
- snapshot(namespace: string): {
250
- rules: (FaultRule$1 & {
251
- remaining: number | null;
252
- hits: number;
253
- position: number;
254
- })[];
255
- rngState: number;
256
- };
335
+ snapshot(namespace: string): FaultSnapshot$1;
336
+ /** Add a rule, or replace the rule with the same id in the same namespace. */
257
337
  add(rule: FaultRule$1): FaultRule$1;
258
- list(): (FaultRule$1 & {
259
- remaining: number | null;
260
- hits: number;
261
- })[];
262
- remove(id: string): boolean;
263
- clear(): void;
264
- restore(namespace: string, state: {
265
- rules: (FaultRule$1 & {
266
- remaining: number | null;
267
- hits: number;
268
- position: number;
269
- })[];
270
- rngState: number;
271
- }): void;
338
+ /** The next unused `fault_<n>` id in `namespace`. */
339
+ nextId(namespace: string): string;
340
+ /** Every rule, or the rules a namespace's requests can hit: its own and the global ones. */
341
+ list(namespace?: string): FaultListing$1[];
342
+ get(id: string, namespace?: string): FaultListing$1 | undefined;
343
+ /** Remove a rule by id: from `namespace` (its own, then a global one), or wherever it is. */
344
+ remove(id: string, namespace?: string): boolean;
345
+ /** Remove every rule, or one namespace's own rules. */
346
+ clear(namespace?: string): void;
347
+ /** Replace a namespace's own rules with a snapshot's, wherever the snapshot was taken. */
348
+ restore(namespace: string, state: FaultSnapshot$1): void;
272
349
  /**
273
350
  * Every fault this request should get, in rule order, stopping at the first that answers
274
351
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
275
352
  * each matching rule's remaining uses.
276
353
  */
277
354
  take(candidate: FaultCandidate$1): Promise<FaultHit$1[]>;
355
+ /**
356
+ * Fire these rules at one request without storing them: no matching, no schedule, in order,
357
+ * stopping at the first that answers or drops. Jitter draws from the namespace's stream.
358
+ */
359
+ fire(rules: readonly FaultRule$1[], candidate: FaultCandidate$1): Promise<FaultHit$1[]>;
360
+ };
361
+
362
+ /**
363
+ * The admin controls every mock shares, as one document.
364
+ *
365
+ * The same shape is accepted in three places, and means the same thing in each:
366
+ *
367
+ * - at boot: `createRuntime({ adminControls })`, `serve --admin-controls`,
368
+ * `MOCKINGBIRD_ADMIN_CONTROLS`
369
+ * - over HTTP: `PUT /__admin/controls`
370
+ * - per request: the `x-mockingbird-*` headers in {@link CONTROL_HEADERS}
371
+ *
372
+ * Every control is deterministic: given the same seed, clock and requests, a mock answers
373
+ * the same bytes. Nothing here reads the wall clock or `Math.random`.
374
+ */
375
+ /** Milliseconds, or a string like `"250ms"`, `"2s"`, `"15m"`, `"1h"`, `"3d"`. */
376
+ type Duration$1 = number | string;
377
+ /** Epoch milliseconds, or an ISO-8601 string. */
378
+ type Instant$1 = number | string;
379
+ type ClockControls$1 = {
380
+ /** Move the clock to this instant. */
381
+ now?: Instant$1;
382
+ /** Stop time. A frozen clock moves only when told to, so timestamps replay exactly. */
383
+ frozen?: boolean;
384
+ /**
385
+ * Step the clock forward by this much before every vendor request. With a frozen clock
386
+ * each request still gets its own, reproducible timestamp.
387
+ */
388
+ autoAdvance?: Duration$1;
389
+ };
390
+ /** How long a response takes: a fixed delay plus seeded jitter in `[0, jitter]`. */
391
+ type LatencyRuleInput$1 = {
392
+ delay?: Duration$1;
393
+ jitter?: Duration$1;
394
+ };
395
+ type LatencyControls$1 = LatencyRuleInput$1 & {
396
+ /** Per-operation overrides, keyed by operationId. A bare duration is its `delay`. */
397
+ operations?: Record<string, Duration$1 | LatencyRuleInput$1>;
398
+ };
399
+ /** A fault to add: a rule (the id is assigned when omitted), or a named preset with overrides. */
400
+ type FaultInput$1 = (Omit<FaultRule$1, "id"> & {
401
+ id?: string;
402
+ }) | ({
403
+ preset: string;
404
+ } & Partial<FaultRule$1>);
405
+ /** Identifies a {@link SnapshotDocument}. */
406
+ declare const SNAPSHOT_FORMAT$1 = "mockingbird.snapshot/v1";
407
+ /**
408
+ * A namespace, as portable JSON: what `GET /__admin/snapshots/:id` returns and what
409
+ * `PUT /__admin/snapshots/:id` and the boot `snapshot` control accept. Only `format` and
410
+ * `records` are required, so a hand-written seed file is a valid snapshot.
411
+ */
412
+ type SnapshotDocument$1 = {
413
+ format: typeof SNAPSHOT_FORMAT$1;
414
+ /** The service that wrote it. A snapshot is rejected by any other service. */
415
+ service?: string;
416
+ /**
417
+ * Stored rows. `seq` orders a collection; omitted, rows keep their listed order. `raw` is
418
+ * the stored text of a row that is not a plain record, and replaces `value` when present.
419
+ */
420
+ records: {
421
+ collection: string;
422
+ id: string;
423
+ seq?: number;
424
+ value?: unknown;
425
+ raw?: string;
426
+ }[];
427
+ /** Id counters, so the next generated id continues where the snapshot left off. */
428
+ sequences?: {
429
+ name: string;
430
+ kind: string;
431
+ value: number;
432
+ }[];
433
+ clock?: {
434
+ now: number;
435
+ frozen: boolean;
436
+ autoAdvanceMs?: number;
437
+ };
438
+ seed?: number | string;
439
+ /** Positions of the seeded random streams. */
440
+ rng?: {
441
+ state: number;
442
+ faults?: number;
443
+ latency?: number;
444
+ };
445
+ faults?: unknown;
446
+ latency?: unknown;
447
+ virtualTime?: boolean;
448
+ };
449
+ /** Controls for one namespace. */
450
+ type NamespaceControls$1 = {
451
+ /** Seeds every random choice: fault rates, jitter, and whatever the service invents. */
452
+ seed?: number | string;
453
+ clock?: ClockControls$1;
454
+ /**
455
+ * Spend injected waits (latency, fault delays, timeouts) on the mock clock instead of the
456
+ * wall clock: the request returns at once, the clock has moved, and the journal records
457
+ * the wait exactly. Default `false`: waits are real, so a client's own timeout can fire.
458
+ */
459
+ virtualTime?: boolean;
460
+ /** Baseline response time for every vendor request. A bare duration is its `delay`. */
461
+ latency?: Duration$1 | LatencyControls$1;
462
+ faults?: readonly FaultInput$1[];
463
+ /** Start from this state instead of the service's own seed data. */
464
+ snapshot?: SnapshotDocument$1;
465
+ };
466
+ /** {@link NamespaceControls} for every namespace, with per-namespace overrides. */
467
+ type MockControls$1 = NamespaceControls$1 & {
468
+ /** Vendor credential → namespace, for SDKs that cannot send a namespace header. */
469
+ credentials?: Record<string, string>;
470
+ /** Overrides for named namespaces. A key given here replaces the shared value. */
471
+ namespaces?: Record<string, NamespaceControls$1>;
472
+ };
473
+ /** A latency rule in milliseconds. */
474
+ type LatencyRule$1 = {
475
+ delayMs: number;
476
+ jitterMs: number;
477
+ };
478
+ /** Baseline latency for a namespace, normalized. */
479
+ type LatencyState$1 = LatencyRule$1 & {
480
+ operations: Record<string, LatencyRule$1>;
481
+ };
482
+ /** What {@link controlHeaders} turns into request headers. */
483
+ type ControlHeaderInput$1 = {
484
+ namespace?: string;
485
+ adminKey?: string;
486
+ branch?: string;
487
+ at?: string;
488
+ reset?: boolean;
489
+ restore?: string;
490
+ seed?: number | string;
491
+ time?: Instant$1 | Date;
492
+ advance?: Duration$1;
493
+ virtualTime?: boolean;
494
+ delay?: Duration$1;
495
+ timeout?: Duration$1;
496
+ /** A status, `"drop"`, a preset name, or a fault rule. */
497
+ fault?: number | string | Record<string, unknown>;
498
+ snapshot?: string;
278
499
  };
279
500
 
280
501
  /**
@@ -314,6 +535,8 @@ type RequestLog$1 = {
314
535
  unmatched: boolean;
315
536
  /** Set when a fault rule produced the response. */
316
537
  faultId?: string;
538
+ /** Milliseconds of injected wait: latency, fault delays and timeouts. Absent when none. */
539
+ delayMs?: number;
317
540
  /** Resource ids the handler touched (`userId`, `orderId`, …), when the service reports them. */
318
541
  ids?: Record<string, string>;
319
542
  /** Set when the service created a resource the request referred to but that did not exist. */
@@ -359,6 +582,12 @@ type JournalQuery$1 = {
359
582
  /** Only this namespace. Omit for every namespace, oldest first across all of them. */
360
583
  namespace?: string;
361
584
  operationId?: string;
585
+ /** Only this HTTP method, case-insensitive. */
586
+ method?: string;
587
+ /** Only this exact path. */
588
+ path?: string;
589
+ /** Only requests this fault rule answered or shaped. */
590
+ faultId?: string;
362
591
  status?: number;
363
592
  /** Only entries at or after this instant (epoch ms). */
364
593
  since?: number;
@@ -373,6 +602,50 @@ type Journal$1 = {
373
602
  clear(namespace?: string): void;
374
603
  };
375
604
 
605
+ /**
606
+ * Baseline response time, per namespace: how long every vendor request takes before any
607
+ * fault is considered. Jitter draws from a stream the caller owns, one per namespace and
608
+ * separate from the fault stream, so adding latency never shifts which requests a `rate`
609
+ * fault hits.
610
+ */
611
+ type LatencyRegistry$1 = {
612
+ get(namespace: string): LatencyState$1;
613
+ set(namespace: string, state: LatencyState$1): LatencyState$1;
614
+ /** Remove one namespace's latency, or every namespace's. */
615
+ clear(namespace?: string): void;
616
+ /** Milliseconds this request waits. Draws jitter, so call it once per request. */
617
+ take(namespace: string, operationId: string | undefined): number;
618
+ };
619
+
620
+ /** Clock state as the admin API reports it. */
621
+ type ControlClock$1 = ClockState$1 & {
622
+ /** `now`, as ISO-8601. */
623
+ iso: string;
624
+ /** Milliseconds the clock steps before every vendor request. */
625
+ autoAdvanceMs: number;
626
+ };
627
+ /** One namespace's controls: the body of `GET /__admin/controls`. */
628
+ type ControlState$1 = {
629
+ namespace: string;
630
+ seed: number | string;
631
+ clock: ControlClock$1;
632
+ virtualTime: boolean;
633
+ latency: LatencyState$1;
634
+ faults: FaultListing$1[];
635
+ };
636
+
637
+ /** What `GET /__admin/snapshots` lists for each snapshot. */
638
+ type SnapshotInfo$1 = {
639
+ id: string;
640
+ namespace: string;
641
+ /** Stored rows in the snapshot. */
642
+ records: number;
643
+ /** The namespace clock when it was taken, epoch ms. */
644
+ at: number;
645
+ /** Whether `GET /snapshots/:id` can return it as a {@link SnapshotDocument}. */
646
+ portable: boolean;
647
+ };
648
+
376
649
  /** Credential → namespace mapping behind `PUT /__admin/credentials`. */
377
650
  type CredentialRegistry$1 = {
378
651
  set(credential: string, namespace: string): void;
@@ -527,7 +800,10 @@ type ServiceInstance$1 = FetchAPI$2 & {
527
800
  };
528
801
  type ServiceTimelineState$1 = Readonly<{
529
802
  snapshot: NamespaceSnapshot$1;
530
- clock: Readonly<ReturnType<Clock$1["state"]>>;
803
+ /** `pinned`: the namespace's clock was frozen itself, not just following a frozen base. */
804
+ clock: Readonly<ClockState$1 & {
805
+ pinned?: boolean;
806
+ }>;
531
807
  rngState: number;
532
808
  }>;
533
809
  type ServiceCheckpoint$1 = Checkpoint$1<ServiceTimelineState$1>;
@@ -535,17 +811,23 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$2 & {
535
811
  /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
536
812
  stop?(): void;
537
813
  readonly name: string;
538
- readonly sqlite: SqliteClient$2;
814
+ /** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
815
+ mount(prefix: string): MountedAPI$1;
816
+ readonly sqlite: SqliteClient$3;
539
817
  readonly clock: Clock$1;
540
818
  readonly faults: FaultRegistry$1;
819
+ /** Baseline response time per namespace. */
820
+ readonly latency: LatencyRegistry$1;
541
821
  readonly metrics: Metrics$1;
542
822
  readonly journal: Journal$1;
543
823
  readonly rng: Rng$1;
544
824
  readonly credentials: CredentialRegistry$1;
545
825
  /** The webhook hub, when the service has outbound webhooks. */
546
826
  readonly webhooks: WebhookHub$1 | undefined;
547
- /** Enable independent namespace clocks and PRNGs before serving a fleet. */
548
- isolateNamespaces(): void;
827
+ /**
828
+ * A namespace's clock. Each follows the base clock, {@link ServiceRuntime.clock}, with an
829
+ * offset and a freeze of its own, so moving one never moves another.
830
+ */
549
831
  namespaceClock(namespace?: string): Clock$1;
550
832
  namespaceOf(request: Request): string;
551
833
  /** Opaque in-process checkpoint including records, controls and webhook history. */
@@ -557,8 +839,38 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$2 & {
557
839
  instance(namespace?: string): T;
558
840
  /** Public names of every namespace created so far. */
559
841
  namespaces(): string[];
560
- /** Reset one namespace, or every namespace with `"*"`. */
842
+ /** Return one namespace to its boot state, or every namespace with `"*"`. */
561
843
  reset(namespace?: string): Promise<void>;
844
+ /** Reset a namespace and forget it, releasing everything it held. */
845
+ dropNamespace(namespace: string): Promise<void>;
846
+ /** A namespace's controls: seed, clock, virtual time, latency, faults and snapshots. */
847
+ controls(namespace?: string): ControlState$1 & {
848
+ snapshots: SnapshotInfo$1[];
849
+ };
850
+ /** Apply a control document to a namespace. A given key replaces that control. */
851
+ configure(controls: NamespaceControls$1, namespace?: string): ControlState$1 & {
852
+ snapshots: SnapshotInfo$1[];
853
+ };
854
+ /** Named snapshots of a namespace: records, clock, random streams, faults and latency. */
855
+ readonly snapshots: {
856
+ /** Capture the namespace now. Reusing a name replaces that snapshot. */
857
+ create(options?: {
858
+ name?: string;
859
+ namespace?: string;
860
+ }): SnapshotInfo$1;
861
+ list(namespace?: string): SnapshotInfo$1[];
862
+ /** The snapshot as portable JSON, to commit beside a suite or boot another mock from. */
863
+ export(id: string, namespace?: string): SnapshotDocument$1;
864
+ /** Store a document as a snapshot without restoring it. */
865
+ import(document: SnapshotDocument$1, options?: {
866
+ name?: string;
867
+ namespace?: string;
868
+ }): SnapshotInfo$1;
869
+ restore(id: string, namespace?: string): void;
870
+ delete(id: string, namespace?: string): boolean;
871
+ };
872
+ /** Request headers that carry controls, checked: spread them into a `fetch` or an SDK's defaults. */
873
+ headers(input: ControlHeaderInput$1): Record<string, string>;
562
874
  snapshot(namespace?: string): NamespaceSnapshot$1;
563
875
  restore(snapshot: NamespaceSnapshot$1, namespace?: string): void;
564
876
  /** Capture the current branch. Mutating HTTP calls do this automatically. */
@@ -601,6 +913,11 @@ type CommonServeOptions = {
601
913
  adminKey: string | undefined;
602
914
  seed: string | undefined;
603
915
  onLog: ((entry: RequestLog$1) => void) | undefined;
916
+ /** Admin controls to boot with: clock, latency, faults, a starting snapshot. */
917
+ adminControls?: MockControls$1;
918
+ /** Synthetic provider fixture objects supplied by a fleet entry. */
919
+ fixtures?: Record<string, unknown>;
920
+ baseUrl?: string;
604
921
  };
605
922
  /**
606
923
  * What a service contributes to `serve`: how to build its runtime from CLI flags,
@@ -619,76 +936,16 @@ type ServeTarget = {
619
936
  listening?(server: Listening): void;
620
937
  };
621
938
 
622
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
623
- type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
624
- /** Mutation counters returned by {@link SqliteStatement.run}. */
625
- type SqliteRunResult$1 = {
626
- changes: number;
627
- lastInsertRowid: number | bigint;
939
+ type MountedAPI = FetchAPI$1 & {
940
+ readonly prefix: string;
941
+ GET: FetchHandler;
942
+ POST: FetchHandler;
943
+ PUT: FetchHandler;
944
+ PATCH: FetchHandler;
945
+ DELETE: FetchHandler;
946
+ HEAD: FetchHandler;
947
+ OPTIONS: FetchHandler;
628
948
  };
629
- /**
630
- * Prepared statement bound to a {@link SqliteClient}.
631
- *
632
- * Pass bind values as rest arguments on each call (no sticky `bind()`).
633
- */
634
- interface SqliteStatement$1 {
635
- run(...params: SqliteValue$1[]): SqliteRunResult$1;
636
- all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
637
- get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
638
- }
639
- /**
640
- * Sync SQLite client port owned by Mockingbird.
641
- *
642
- * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
643
- * `bun:sqlite` instances all work when they expose this surface.
644
- */
645
- interface SqliteClient$1 {
646
- exec(sql: string): void;
647
- prepare(sql: string): SqliteStatement$1;
648
- transaction<T>(fn: () => T): T;
649
- }
650
-
651
- /** Every stored record carries a monotonically increasing sequence for stable ordering. */
652
- type Stored<T> = {
653
- seq: number;
654
- value: T;
655
- };
656
- type ListRecordsOptions<T> = {
657
- /** Keep only records passing the predicate. */
658
- where?: (value: T, seq: number) => boolean;
659
- /** Sort order; default newest first. */
660
- order?: "newest" | "oldest";
661
- };
662
- /**
663
- * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
664
- * sequence, never by id lexicographic order, so list semantics stay stable.
665
- */
666
- declare class Collection<T> {
667
- private readonly sqlite;
668
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
669
- readonly namespace: string;
670
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
671
- readonly collectionName: string;
672
- constructor(sqlite: SqliteClient$1,
673
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
674
- namespace: string,
675
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
676
- collectionName: string);
677
- private bumpCollectionSeq;
678
- nextSequence(): number;
679
- get(id: string): T | undefined;
680
- has(id: string): boolean;
681
- /** Insert a new record, assigning it the next sequence number. */
682
- insert(id: string, value: T): Stored<T>;
683
- /** Replace an existing record's value, keeping its position. */
684
- update(id: string, value: T): Stored<T> | undefined;
685
- delete(id: string): boolean;
686
- /** How many records the collection holds, without reading them. */
687
- count(): number;
688
- list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
689
- id: string;
690
- }>;
691
- }
692
949
 
693
950
  /** A stable identifier for a point in a {@link Timeline}. */
694
951
  type CheckpointId = string;
@@ -779,11 +1036,84 @@ declare class Timeline<T> {
779
1036
  interface FetchAPI$1 {
780
1037
  fetch(request: Request): Promise<Response>;
781
1038
  }
1039
+ /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
1040
+ type FetchHandler = (request: Request) => Promise<Response>;
1041
+
1042
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
1043
+ type SqliteValue$2 = null | number | bigint | string | Uint8Array | boolean;
1044
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
1045
+ type SqliteRunResult$2 = {
1046
+ changes: number;
1047
+ lastInsertRowid: number | bigint;
1048
+ };
1049
+ /**
1050
+ * Prepared statement bound to a {@link SqliteClient}.
1051
+ *
1052
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
1053
+ */
1054
+ interface SqliteStatement$2 {
1055
+ run(...params: SqliteValue$2[]): SqliteRunResult$2;
1056
+ all<T = Record<string, unknown>>(...params: SqliteValue$2[]): T[];
1057
+ get<T = Record<string, unknown>>(...params: SqliteValue$2[]): T | undefined;
1058
+ }
1059
+ /**
1060
+ * Sync SQLite client port owned by Mockingbird.
1061
+ *
1062
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
1063
+ * `bun:sqlite` instances all work when they expose this surface.
1064
+ */
1065
+ interface SqliteClient$2 {
1066
+ exec(sql: string): void;
1067
+ prepare(sql: string): SqliteStatement$2;
1068
+ transaction<T>(fn: () => T): T;
1069
+ }
1070
+
1071
+ /** Every stored record carries a monotonically increasing sequence for stable ordering. */
1072
+ type Stored<T> = {
1073
+ seq: number;
1074
+ value: T;
1075
+ };
1076
+ type ListRecordsOptions<T> = {
1077
+ /** Keep only records passing the predicate. */
1078
+ where?: (value: T, seq: number) => boolean;
1079
+ /** Sort order; default newest first. */
1080
+ order?: "newest" | "oldest";
1081
+ };
1082
+ /**
1083
+ * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
1084
+ * sequence, never by id lexicographic order, so list semantics stay stable.
1085
+ */
1086
+ declare class Collection<T> {
1087
+ private readonly sqlite;
1088
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
1089
+ readonly namespace: string;
1090
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
1091
+ readonly collectionName: string;
1092
+ constructor(sqlite: SqliteClient$2,
1093
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
1094
+ namespace: string,
1095
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
1096
+ collectionName: string);
1097
+ private bumpCollectionSeq;
1098
+ nextSequence(): number;
1099
+ get(id: string): T | undefined;
1100
+ has(id: string): boolean;
1101
+ /** Insert a new record, assigning it the next sequence number. */
1102
+ insert(id: string, value: T): Stored<T>;
1103
+ /** Replace an existing record's value, keeping its position. */
1104
+ update(id: string, value: T): Stored<T> | undefined;
1105
+ delete(id: string): boolean;
1106
+ /** How many records the collection holds, without reading them. */
1107
+ count(): number;
1108
+ list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
1109
+ id: string;
1110
+ }>;
1111
+ }
782
1112
 
783
1113
  /** Options every provider constructor accepts. */
784
- type APIOptions = {
1114
+ type APIOptions$1 = {
785
1115
  /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
786
- sqlite?: SqliteClient$1;
1116
+ sqlite?: SqliteClient$2;
787
1117
  /** Clock used for `created`-style fields. Default `Date.now`. */
788
1118
  now?: () => number;
789
1119
  /**
@@ -805,7 +1135,7 @@ type ClockState = {
805
1135
  now: number;
806
1136
  /** True while time does not advance on its own. */
807
1137
  frozen: boolean;
808
- /** Milliseconds this clock adds to its underlying source. */
1138
+ /** Milliseconds a running clock adds to its underlying source. `0` while frozen. */
809
1139
  offsetMs: number;
810
1140
  };
811
1141
  type Clock = {
@@ -841,7 +1171,10 @@ type Rng = {
841
1171
  state(): number;
842
1172
  /** Restore a state previously returned by {@link state}. */
843
1173
  setState(state: number): void;
844
- seed: number;
1174
+ /** Restart the stream from a new seed. `reset` then returns to this seed. */
1175
+ reseed(seed: number | string): void;
1176
+ /** The seed the stream currently starts from. */
1177
+ readonly seed: number;
845
1178
  };
846
1179
 
847
1180
  /**
@@ -850,44 +1183,83 @@ type Rng = {
850
1183
  * This is how a suite reaches the vendor's failure modes without the vendor: the
851
1184
  * quota error that only appears when a shared sandbox is full, the 429 that only
852
1185
  * appears under load, the 5xx that proves a retry path works.
1186
+ *
1187
+ * A rule has three parts. What it **matches** (`operationId`, `method`, `path`, …), **when**
1188
+ * it fires among the matching requests (`after`, `every`, `count`, `rate`, `from`, `until`),
1189
+ * and what it **does** (`status`, `delay`, `timeout`, `drop`, `truncate`, `effect`).
853
1190
  */
854
1191
  type FaultRule = {
855
- /** Stable id, so a suite can retire exactly the rule it added. */
1192
+ /** Stable id, so a suite can retire exactly the rule it added. Unique within a namespace. */
856
1193
  id: string;
857
1194
  /** Fault only this operation. Omit to match every operation. */
858
1195
  operationId?: string;
859
1196
  /** Fault only this HTTP method, case-insensitive. Omit to match every method. */
860
1197
  method?: string;
1198
+ /** Fault only this exact path. */
1199
+ path?: string;
861
1200
  /** Fault only paths starting with this prefix. Omit to match every path. */
862
1201
  pathPrefix?: string;
1202
+ /** Fault only paths matching this regular expression (JavaScript syntax, unanchored). */
1203
+ pathPattern?: string;
1204
+ /** Fault only requests carrying these headers. `"*"` matches any value. */
1205
+ requestHeaders?: Record<string, string>;
1206
+ /** Fault only requests carrying these query parameters. `"*"` matches any value. */
1207
+ query?: Record<string, string>;
863
1208
  /**
864
1209
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
865
1210
  * an in-process caller usually wants, and what a parallel worker usually does not:
866
1211
  * rules added through `POST /__admin/faults` default to the calling namespace.
867
1212
  */
868
1213
  namespace?: string;
1214
+ /** Let this many matching requests through first. */
1215
+ after?: number;
1216
+ /** Then fault only every nth matching request: `3` faults the 3rd, 6th, 9th. */
1217
+ every?: number;
1218
+ /** Retire the rule after this many faults. Omit to keep it until removed. */
1219
+ count?: number;
1220
+ /** Fault this fraction of the remaining requests, `0`–`1`, drawn from the seed. Default `1`. */
1221
+ rate?: number;
869
1222
  /**
870
- * Status of the injected response. Omit for a rule that only delays (`delayMs` /
871
- * `latencyMs`), only drops the connection (`drop`), or only switches on an `effect`:
872
- * the request then still reaches the service.
1223
+ * Fault only from this instant on the namespace clock. A duration (`"5m"`) counts from the
1224
+ * clock when the rule was added. Listed as epoch ms.
1225
+ */
1226
+ from?: Instant | Duration;
1227
+ /** Stop faulting at this instant on the namespace clock. A duration counts from when added. */
1228
+ until?: Instant | Duration;
1229
+ /**
1230
+ * Status of the injected response. Omit for a rule that only delays, times out, drops,
1231
+ * truncates, or switches on an `effect`: the request then still reaches the service.
873
1232
  */
874
1233
  status?: number;
875
1234
  /** Response body, serialized as JSON. A string is sent as-is. */
876
1235
  body?: unknown;
1236
+ /** Response headers. */
877
1237
  headers?: Record<string, string>;
878
- /** Retire the rule after this many faults. Omit to keep it until removed. */
879
- count?: number;
880
- /** Fault this fraction of matching requests, `0`–`1`. Default `1`. */
881
- rate?: number;
882
- /** Hold the response back this long, to exercise timeouts. */
1238
+ /** Hold the response back this long. Listed as `delayMs`. */
1239
+ delay?: Duration;
1240
+ /** `delay`, in milliseconds. */
883
1241
  delayMs?: number;
884
1242
  /** Alias of `delayMs`. */
885
1243
  latencyMs?: number;
1244
+ /** Extra seeded delay in `[0, jitter]`. Listed as `jitterMs`. */
1245
+ jitter?: Duration;
1246
+ jitterMs?: number;
1247
+ /**
1248
+ * Never answer: hold the request this long, then drop the connection. Listed as
1249
+ * `timeoutMs`. With virtual time the wait is spent on the mock clock.
1250
+ */
1251
+ timeout?: Duration;
1252
+ timeoutMs?: number;
886
1253
  /**
887
1254
  * Drop the connection instead of answering: an in-process `fetch` rejects with a
888
1255
  * `TypeError`, and a served mock destroys the socket. Models "unknown outcome" failures.
889
1256
  */
890
1257
  drop?: boolean;
1258
+ /**
1259
+ * Cut the response body off after this many bytes: the status and headers arrive, then
1260
+ * the connection dies mid-body.
1261
+ */
1262
+ truncate?: number;
891
1263
  /**
892
1264
  * A named service behaviour to switch on for the matching request instead of (or
893
1265
  * before) a canned response, e.g. `created_but_500` or `numeric_tracking_id`. Services
@@ -896,8 +1268,8 @@ type FaultRule = {
896
1268
  effect?: string;
897
1269
  /** Parameters for `effect`. */
898
1270
  params?: Record<string, unknown>;
899
- /** From the preset this rule was expanded from, if any. */
900
- preset?: string;
1271
+ /** The preset this rule was expanded from, if any. */
1272
+ fromPreset?: string;
901
1273
  };
902
1274
  /** A fault that fired for one request. */
903
1275
  type FaultHit = {
@@ -905,6 +1277,10 @@ type FaultHit = {
905
1277
  /** The injected response; absent when the rule only delays, drops, or sets an effect. */
906
1278
  response?: Response;
907
1279
  drop?: boolean;
1280
+ /** Set with `drop` when the rule held the request for its `timeout` first. */
1281
+ timeout?: boolean;
1282
+ /** Bytes of response body to let through before the connection dies. */
1283
+ truncate?: number;
908
1284
  effect?: {
909
1285
  name: string;
910
1286
  params: Record<string, unknown>;
@@ -916,38 +1292,200 @@ type FaultCandidate = {
916
1292
  method: string;
917
1293
  path: string;
918
1294
  namespace: string;
1295
+ /** Request headers and query, for rules that match on them. */
1296
+ headers?: Headers;
1297
+ query?: URLSearchParams;
1298
+ /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
1299
+ now?: number;
1300
+ /** How to spend a delay for this request. Default: the registry's own sleep. */
1301
+ wait?: (ms: number) => Promise<void>;
1302
+ };
1303
+ /** A stored rule and how often it was consulted. */
1304
+ type FaultListing = FaultRule & {
1305
+ /** Faults left before the rule retires. `null` when it has no `count`. */
1306
+ remaining: number | null;
1307
+ /** Times the rule faulted a request. */
1308
+ hits: number;
1309
+ /** Requests that matched the rule, faulted or not. */
1310
+ seen: number;
1311
+ };
1312
+ /** A namespace's own rules, with their counters, in the order they are tried. */
1313
+ type FaultSnapshot = {
1314
+ /**
1315
+ * `position` is how many `"*"` rules are tried before the rule, which is what its place
1316
+ * in the order means to a request and holds in any process.
1317
+ */
1318
+ rules: (FaultListing & {
1319
+ position?: number;
1320
+ })[];
1321
+ /** How many `fault_<n>` ids the namespace has handed out. */
1322
+ nextId?: number;
919
1323
  };
920
1324
  type FaultRegistry = {
921
- isolateNamespaces(): void;
922
- snapshot(namespace: string): {
923
- rules: (FaultRule & {
924
- remaining: number | null;
925
- hits: number;
926
- position: number;
927
- })[];
928
- rngState: number;
929
- };
1325
+ snapshot(namespace: string): FaultSnapshot;
1326
+ /** Add a rule, or replace the rule with the same id in the same namespace. */
930
1327
  add(rule: FaultRule): FaultRule;
931
- list(): (FaultRule & {
932
- remaining: number | null;
933
- hits: number;
934
- })[];
935
- remove(id: string): boolean;
936
- clear(): void;
937
- restore(namespace: string, state: {
938
- rules: (FaultRule & {
939
- remaining: number | null;
940
- hits: number;
941
- position: number;
942
- })[];
943
- rngState: number;
944
- }): void;
1328
+ /** The next unused `fault_<n>` id in `namespace`. */
1329
+ nextId(namespace: string): string;
1330
+ /** Every rule, or the rules a namespace's requests can hit: its own and the global ones. */
1331
+ list(namespace?: string): FaultListing[];
1332
+ get(id: string, namespace?: string): FaultListing | undefined;
1333
+ /** Remove a rule by id: from `namespace` (its own, then a global one), or wherever it is. */
1334
+ remove(id: string, namespace?: string): boolean;
1335
+ /** Remove every rule, or one namespace's own rules. */
1336
+ clear(namespace?: string): void;
1337
+ /** Replace a namespace's own rules with a snapshot's, wherever the snapshot was taken. */
1338
+ restore(namespace: string, state: FaultSnapshot): void;
945
1339
  /**
946
1340
  * Every fault this request should get, in rule order, stopping at the first that answers
947
1341
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
948
1342
  * each matching rule's remaining uses.
949
1343
  */
950
1344
  take(candidate: FaultCandidate): Promise<FaultHit[]>;
1345
+ /**
1346
+ * Fire these rules at one request without storing them: no matching, no schedule, in order,
1347
+ * stopping at the first that answers or drops. Jitter draws from the namespace's stream.
1348
+ */
1349
+ fire(rules: readonly FaultRule[], candidate: FaultCandidate): Promise<FaultHit[]>;
1350
+ };
1351
+
1352
+ /**
1353
+ * The admin controls every mock shares, as one document.
1354
+ *
1355
+ * The same shape is accepted in three places, and means the same thing in each:
1356
+ *
1357
+ * - at boot: `createRuntime({ adminControls })`, `serve --admin-controls`,
1358
+ * `MOCKINGBIRD_ADMIN_CONTROLS`
1359
+ * - over HTTP: `PUT /__admin/controls`
1360
+ * - per request: the `x-mockingbird-*` headers in {@link CONTROL_HEADERS}
1361
+ *
1362
+ * Every control is deterministic: given the same seed, clock and requests, a mock answers
1363
+ * the same bytes. Nothing here reads the wall clock or `Math.random`.
1364
+ */
1365
+ /** Milliseconds, or a string like `"250ms"`, `"2s"`, `"15m"`, `"1h"`, `"3d"`. */
1366
+ type Duration = number | string;
1367
+ /** Epoch milliseconds, or an ISO-8601 string. */
1368
+ type Instant = number | string;
1369
+ type ClockControls = {
1370
+ /** Move the clock to this instant. */
1371
+ now?: Instant;
1372
+ /** Stop time. A frozen clock moves only when told to, so timestamps replay exactly. */
1373
+ frozen?: boolean;
1374
+ /**
1375
+ * Step the clock forward by this much before every vendor request. With a frozen clock
1376
+ * each request still gets its own, reproducible timestamp.
1377
+ */
1378
+ autoAdvance?: Duration;
1379
+ };
1380
+ /** How long a response takes: a fixed delay plus seeded jitter in `[0, jitter]`. */
1381
+ type LatencyRuleInput = {
1382
+ delay?: Duration;
1383
+ jitter?: Duration;
1384
+ };
1385
+ type LatencyControls = LatencyRuleInput & {
1386
+ /** Per-operation overrides, keyed by operationId. A bare duration is its `delay`. */
1387
+ operations?: Record<string, Duration | LatencyRuleInput>;
1388
+ };
1389
+ /** A fault to add: a rule (the id is assigned when omitted), or a named preset with overrides. */
1390
+ type FaultInput = (Omit<FaultRule, "id"> & {
1391
+ id?: string;
1392
+ }) | ({
1393
+ preset: string;
1394
+ } & Partial<FaultRule>);
1395
+ /** Identifies a {@link SnapshotDocument}. */
1396
+ declare const SNAPSHOT_FORMAT = "mockingbird.snapshot/v1";
1397
+ /**
1398
+ * A namespace, as portable JSON: what `GET /__admin/snapshots/:id` returns and what
1399
+ * `PUT /__admin/snapshots/:id` and the boot `snapshot` control accept. Only `format` and
1400
+ * `records` are required, so a hand-written seed file is a valid snapshot.
1401
+ */
1402
+ type SnapshotDocument = {
1403
+ format: typeof SNAPSHOT_FORMAT;
1404
+ /** The service that wrote it. A snapshot is rejected by any other service. */
1405
+ service?: string;
1406
+ /**
1407
+ * Stored rows. `seq` orders a collection; omitted, rows keep their listed order. `raw` is
1408
+ * the stored text of a row that is not a plain record, and replaces `value` when present.
1409
+ */
1410
+ records: {
1411
+ collection: string;
1412
+ id: string;
1413
+ seq?: number;
1414
+ value?: unknown;
1415
+ raw?: string;
1416
+ }[];
1417
+ /** Id counters, so the next generated id continues where the snapshot left off. */
1418
+ sequences?: {
1419
+ name: string;
1420
+ kind: string;
1421
+ value: number;
1422
+ }[];
1423
+ clock?: {
1424
+ now: number;
1425
+ frozen: boolean;
1426
+ autoAdvanceMs?: number;
1427
+ };
1428
+ seed?: number | string;
1429
+ /** Positions of the seeded random streams. */
1430
+ rng?: {
1431
+ state: number;
1432
+ faults?: number;
1433
+ latency?: number;
1434
+ };
1435
+ faults?: unknown;
1436
+ latency?: unknown;
1437
+ virtualTime?: boolean;
1438
+ };
1439
+ /** Controls for one namespace. */
1440
+ type NamespaceControls = {
1441
+ /** Seeds every random choice: fault rates, jitter, and whatever the service invents. */
1442
+ seed?: number | string;
1443
+ clock?: ClockControls;
1444
+ /**
1445
+ * Spend injected waits (latency, fault delays, timeouts) on the mock clock instead of the
1446
+ * wall clock: the request returns at once, the clock has moved, and the journal records
1447
+ * the wait exactly. Default `false`: waits are real, so a client's own timeout can fire.
1448
+ */
1449
+ virtualTime?: boolean;
1450
+ /** Baseline response time for every vendor request. A bare duration is its `delay`. */
1451
+ latency?: Duration | LatencyControls;
1452
+ faults?: readonly FaultInput[];
1453
+ /** Start from this state instead of the service's own seed data. */
1454
+ snapshot?: SnapshotDocument;
1455
+ };
1456
+ /** {@link NamespaceControls} for every namespace, with per-namespace overrides. */
1457
+ type MockControls = NamespaceControls & {
1458
+ /** Vendor credential → namespace, for SDKs that cannot send a namespace header. */
1459
+ credentials?: Record<string, string>;
1460
+ /** Overrides for named namespaces. A key given here replaces the shared value. */
1461
+ namespaces?: Record<string, NamespaceControls>;
1462
+ };
1463
+ /** A latency rule in milliseconds. */
1464
+ type LatencyRule = {
1465
+ delayMs: number;
1466
+ jitterMs: number;
1467
+ };
1468
+ /** Baseline latency for a namespace, normalized. */
1469
+ type LatencyState = LatencyRule & {
1470
+ operations: Record<string, LatencyRule>;
1471
+ };
1472
+ /** What {@link controlHeaders} turns into request headers. */
1473
+ type ControlHeaderInput = {
1474
+ namespace?: string;
1475
+ adminKey?: string;
1476
+ branch?: string;
1477
+ at?: string;
1478
+ reset?: boolean;
1479
+ restore?: string;
1480
+ seed?: number | string;
1481
+ time?: Instant | Date;
1482
+ advance?: Duration;
1483
+ virtualTime?: boolean;
1484
+ delay?: Duration;
1485
+ timeout?: Duration;
1486
+ /** A status, `"drop"`, a preset name, or a fault rule. */
1487
+ fault?: number | string | Record<string, unknown>;
1488
+ snapshot?: string;
951
1489
  };
952
1490
 
953
1491
  /**
@@ -987,6 +1525,8 @@ type RequestLog = {
987
1525
  unmatched: boolean;
988
1526
  /** Set when a fault rule produced the response. */
989
1527
  faultId?: string;
1528
+ /** Milliseconds of injected wait: latency, fault delays and timeouts. Absent when none. */
1529
+ delayMs?: number;
990
1530
  /** Resource ids the handler touched (`userId`, `orderId`, …), when the service reports them. */
991
1531
  ids?: Record<string, string>;
992
1532
  /** Set when the service created a resource the request referred to but that did not exist. */
@@ -1032,6 +1572,12 @@ type JournalQuery = {
1032
1572
  /** Only this namespace. Omit for every namespace, oldest first across all of them. */
1033
1573
  namespace?: string;
1034
1574
  operationId?: string;
1575
+ /** Only this HTTP method, case-insensitive. */
1576
+ method?: string;
1577
+ /** Only this exact path. */
1578
+ path?: string;
1579
+ /** Only requests this fault rule answered or shaped. */
1580
+ faultId?: string;
1035
1581
  status?: number;
1036
1582
  /** Only entries at or after this instant (epoch ms). */
1037
1583
  since?: number;
@@ -1046,6 +1592,50 @@ type Journal = {
1046
1592
  clear(namespace?: string): void;
1047
1593
  };
1048
1594
 
1595
+ /**
1596
+ * Baseline response time, per namespace: how long every vendor request takes before any
1597
+ * fault is considered. Jitter draws from a stream the caller owns, one per namespace and
1598
+ * separate from the fault stream, so adding latency never shifts which requests a `rate`
1599
+ * fault hits.
1600
+ */
1601
+ type LatencyRegistry = {
1602
+ get(namespace: string): LatencyState;
1603
+ set(namespace: string, state: LatencyState): LatencyState;
1604
+ /** Remove one namespace's latency, or every namespace's. */
1605
+ clear(namespace?: string): void;
1606
+ /** Milliseconds this request waits. Draws jitter, so call it once per request. */
1607
+ take(namespace: string, operationId: string | undefined): number;
1608
+ };
1609
+
1610
+ /** Clock state as the admin API reports it. */
1611
+ type ControlClock = ClockState & {
1612
+ /** `now`, as ISO-8601. */
1613
+ iso: string;
1614
+ /** Milliseconds the clock steps before every vendor request. */
1615
+ autoAdvanceMs: number;
1616
+ };
1617
+ /** One namespace's controls: the body of `GET /__admin/controls`. */
1618
+ type ControlState = {
1619
+ namespace: string;
1620
+ seed: number | string;
1621
+ clock: ControlClock;
1622
+ virtualTime: boolean;
1623
+ latency: LatencyState;
1624
+ faults: FaultListing[];
1625
+ };
1626
+
1627
+ /** What `GET /__admin/snapshots` lists for each snapshot. */
1628
+ type SnapshotInfo = {
1629
+ id: string;
1630
+ namespace: string;
1631
+ /** Stored rows in the snapshot. */
1632
+ records: number;
1633
+ /** The namespace clock when it was taken, epoch ms. */
1634
+ at: number;
1635
+ /** Whether `GET /snapshots/:id` can return it as a {@link SnapshotDocument}. */
1636
+ portable: boolean;
1637
+ };
1638
+
1049
1639
  /** Credential → namespace mapping behind `PUT /__admin/credentials`. */
1050
1640
  type CredentialRegistry = {
1051
1641
  set(credential: string, namespace: string): void;
@@ -1200,7 +1790,10 @@ type ServiceInstance = FetchAPI$1 & {
1200
1790
  };
1201
1791
  type ServiceTimelineState = Readonly<{
1202
1792
  snapshot: NamespaceSnapshot;
1203
- clock: Readonly<ReturnType<Clock["state"]>>;
1793
+ /** `pinned`: the namespace's clock was frozen itself, not just following a frozen base. */
1794
+ clock: Readonly<ClockState & {
1795
+ pinned?: boolean;
1796
+ }>;
1204
1797
  rngState: number;
1205
1798
  }>;
1206
1799
  type ServiceCheckpoint = Checkpoint<ServiceTimelineState>;
@@ -1208,17 +1801,23 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
1208
1801
  /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
1209
1802
  stop?(): void;
1210
1803
  readonly name: string;
1211
- readonly sqlite: SqliteClient$1;
1804
+ /** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
1805
+ mount(prefix: string): MountedAPI;
1806
+ readonly sqlite: SqliteClient$2;
1212
1807
  readonly clock: Clock;
1213
1808
  readonly faults: FaultRegistry;
1809
+ /** Baseline response time per namespace. */
1810
+ readonly latency: LatencyRegistry;
1214
1811
  readonly metrics: Metrics;
1215
1812
  readonly journal: Journal;
1216
1813
  readonly rng: Rng;
1217
1814
  readonly credentials: CredentialRegistry;
1218
1815
  /** The webhook hub, when the service has outbound webhooks. */
1219
1816
  readonly webhooks: WebhookHub | undefined;
1220
- /** Enable independent namespace clocks and PRNGs before serving a fleet. */
1221
- isolateNamespaces(): void;
1817
+ /**
1818
+ * A namespace's clock. Each follows the base clock, {@link ServiceRuntime.clock}, with an
1819
+ * offset and a freeze of its own, so moving one never moves another.
1820
+ */
1222
1821
  namespaceClock(namespace?: string): Clock;
1223
1822
  namespaceOf(request: Request): string;
1224
1823
  /** Opaque in-process checkpoint including records, controls and webhook history. */
@@ -1230,8 +1829,38 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
1230
1829
  instance(namespace?: string): T;
1231
1830
  /** Public names of every namespace created so far. */
1232
1831
  namespaces(): string[];
1233
- /** Reset one namespace, or every namespace with `"*"`. */
1832
+ /** Return one namespace to its boot state, or every namespace with `"*"`. */
1234
1833
  reset(namespace?: string): Promise<void>;
1834
+ /** Reset a namespace and forget it, releasing everything it held. */
1835
+ dropNamespace(namespace: string): Promise<void>;
1836
+ /** A namespace's controls: seed, clock, virtual time, latency, faults and snapshots. */
1837
+ controls(namespace?: string): ControlState & {
1838
+ snapshots: SnapshotInfo[];
1839
+ };
1840
+ /** Apply a control document to a namespace. A given key replaces that control. */
1841
+ configure(controls: NamespaceControls, namespace?: string): ControlState & {
1842
+ snapshots: SnapshotInfo[];
1843
+ };
1844
+ /** Named snapshots of a namespace: records, clock, random streams, faults and latency. */
1845
+ readonly snapshots: {
1846
+ /** Capture the namespace now. Reusing a name replaces that snapshot. */
1847
+ create(options?: {
1848
+ name?: string;
1849
+ namespace?: string;
1850
+ }): SnapshotInfo;
1851
+ list(namespace?: string): SnapshotInfo[];
1852
+ /** The snapshot as portable JSON, to commit beside a suite or boot another mock from. */
1853
+ export(id: string, namespace?: string): SnapshotDocument;
1854
+ /** Store a document as a snapshot without restoring it. */
1855
+ import(document: SnapshotDocument, options?: {
1856
+ name?: string;
1857
+ namespace?: string;
1858
+ }): SnapshotInfo;
1859
+ restore(id: string, namespace?: string): void;
1860
+ delete(id: string, namespace?: string): boolean;
1861
+ };
1862
+ /** Request headers that carry controls, checked: spread them into a `fetch` or an SDK's defaults. */
1863
+ headers(input: ControlHeaderInput): Record<string, string>;
1235
1864
  snapshot(namespace?: string): NamespaceSnapshot;
1236
1865
  restore(snapshot: NamespaceSnapshot, namespace?: string): void;
1237
1866
  /** Capture the current branch. Mutating HTTP calls do this automatically. */
@@ -1275,7 +1904,7 @@ type OutboxQuery = {
1275
1904
  };
1276
1905
  declare class OutboxStore<T extends OutboxItem = OutboxItem> {
1277
1906
  private readonly items;
1278
- constructor(sqlite: SqliteClient$1, namespace: string, name?: string);
1907
+ constructor(sqlite: SqliteClient$2, namespace: string, name?: string);
1279
1908
  record(item: T): T;
1280
1909
  get(id: string): T | undefined;
1281
1910
  update(id: string, item: T): void;
@@ -1284,9 +1913,9 @@ declare class OutboxStore<T extends OutboxItem = OutboxItem> {
1284
1913
  }
1285
1914
 
1286
1915
  /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
1287
- type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
1916
+ type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
1288
1917
  /** Mutation counters returned by {@link SqliteStatement.run}. */
1289
- type SqliteRunResult = {
1918
+ type SqliteRunResult$1 = {
1290
1919
  changes: number;
1291
1920
  lastInsertRowid: number | bigint;
1292
1921
  };
@@ -1295,10 +1924,10 @@ type SqliteRunResult = {
1295
1924
  *
1296
1925
  * Pass bind values as rest arguments on each call (no sticky `bind()`).
1297
1926
  */
1298
- interface SqliteStatement {
1299
- run(...params: SqliteValue[]): SqliteRunResult;
1300
- all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
1301
- get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
1927
+ interface SqliteStatement$1 {
1928
+ run(...params: SqliteValue$1[]): SqliteRunResult$1;
1929
+ all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
1930
+ get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
1302
1931
  }
1303
1932
  /**
1304
1933
  * Sync SQLite client port owned by Mockingbird.
@@ -1306,9 +1935,9 @@ interface SqliteStatement {
1306
1935
  * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
1307
1936
  * `bun:sqlite` instances all work when they expose this surface.
1308
1937
  */
1309
- interface SqliteClient {
1938
+ interface SqliteClient$1 {
1310
1939
  exec(sql: string): void;
1311
- prepare(sql: string): SqliteStatement;
1940
+ prepare(sql: string): SqliteStatement$1;
1312
1941
  transaction<T>(fn: () => T): T;
1313
1942
  }
1314
1943
 
@@ -1322,6 +1951,175 @@ interface FetchAPI {
1322
1951
  fetch(request: Request): Promise<Response>;
1323
1952
  }
1324
1953
 
1954
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
1955
+ type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
1956
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
1957
+ type SqliteRunResult = {
1958
+ changes: number;
1959
+ lastInsertRowid: number | bigint;
1960
+ };
1961
+ /**
1962
+ * Prepared statement bound to a {@link SqliteClient}.
1963
+ *
1964
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
1965
+ */
1966
+ interface SqliteStatement {
1967
+ run(...params: SqliteValue[]): SqliteRunResult;
1968
+ all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
1969
+ get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
1970
+ }
1971
+ /**
1972
+ * Sync SQLite client port owned by Mockingbird.
1973
+ *
1974
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
1975
+ * `bun:sqlite` instances all work when they expose this surface.
1976
+ */
1977
+ interface SqliteClient {
1978
+ exec(sql: string): void;
1979
+ prepare(sql: string): SqliteStatement;
1980
+ transaction<T>(fn: () => T): T;
1981
+ }
1982
+
1983
+ /** Options every provider constructor accepts. */
1984
+ type APIOptions = {
1985
+ /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
1986
+ sqlite?: SqliteClient;
1987
+ /** Clock used for `created`-style fields. Default `Date.now`. */
1988
+ now?: () => number;
1989
+ /**
1990
+ * Storage namespace for this instance's records. Instances sharing one SQLite
1991
+ * client stay isolated when their namespaces differ. Defaults to the service name.
1992
+ */
1993
+ namespace?: string;
1994
+ };
1995
+
1996
+ interface AuthUser {
1997
+ login: string;
1998
+ id: number;
1999
+ scopes: string[];
2000
+ installation?: AuthInstallation;
2001
+ }
2002
+ interface AuthInstallation {
2003
+ installationId: number;
2004
+ appId: number;
2005
+ accountId: number;
2006
+ accountType: "User" | "Organization";
2007
+ permissions: Record<string, string>;
2008
+ repositoryIds: number[];
2009
+ repositorySelection: "all" | "selected";
2010
+ }
2011
+ interface AuthFallback {
2012
+ login: string;
2013
+ id: number;
2014
+ scopes: string[];
2015
+ }
2016
+
2017
+ /*! Adapted from vercel-labs/emulate (Apache-2.0), modified for Mockingbird. See port.json, LICENSE_EMULATE and THIRD_PARTY_NOTICES.md. */
2018
+
2019
+ interface SlackUserProfile {
2020
+ display_name: string;
2021
+ real_name: string;
2022
+ email: string;
2023
+ image_48: string;
2024
+ image_192: string;
2025
+ title?: string;
2026
+ phone?: string;
2027
+ skype?: string;
2028
+ real_name_normalized?: string;
2029
+ display_name_normalized?: string;
2030
+ fields?: Record<string, {
2031
+ value: string;
2032
+ alt?: string;
2033
+ label?: string;
2034
+ }>;
2035
+ status_text?: string;
2036
+ status_emoji?: string;
2037
+ status_emoji_display_info?: Record<string, unknown>[];
2038
+ status_expiration?: number;
2039
+ avatar_hash?: string;
2040
+ start_date?: string;
2041
+ pronouns?: string;
2042
+ huddle_state?: string;
2043
+ huddle_state_expiration_ts?: number;
2044
+ first_name?: string;
2045
+ last_name?: string;
2046
+ image_24?: string;
2047
+ image_32?: string;
2048
+ image_72?: string;
2049
+ image_512?: string;
2050
+ }
2051
+ type SlackPresence = "active" | "away";
2052
+ type SlackTokenType = "bot" | "user" | "test";
2053
+
2054
+ interface SlackSeedConfig {
2055
+ port?: number;
2056
+ team?: {
2057
+ name?: string;
2058
+ domain?: string;
2059
+ };
2060
+ users?: Array<{
2061
+ name: string;
2062
+ real_name?: string;
2063
+ email?: string;
2064
+ is_admin?: boolean;
2065
+ profile?: Partial<SlackUserProfile>;
2066
+ presence?: SlackPresence;
2067
+ }>;
2068
+ channels?: Array<{
2069
+ name: string;
2070
+ topic?: string;
2071
+ purpose?: string;
2072
+ is_private?: boolean;
2073
+ }>;
2074
+ bots?: Array<{
2075
+ name: string;
2076
+ }>;
2077
+ oauth_apps?: Array<{
2078
+ app_id?: string;
2079
+ client_id: string;
2080
+ client_secret: string;
2081
+ name: string;
2082
+ redirect_uris: string[];
2083
+ scopes?: string[] | string;
2084
+ user_scopes?: string[] | string;
2085
+ bot_id?: string;
2086
+ bot_user_id?: string;
2087
+ bot_name?: string;
2088
+ }>;
2089
+ tokens?: Array<{
2090
+ token: string;
2091
+ type?: SlackTokenType;
2092
+ user?: string;
2093
+ user_id?: string;
2094
+ scopes?: string[] | string;
2095
+ app_id?: string;
2096
+ client_id?: string;
2097
+ team_id?: string;
2098
+ bot_id?: string;
2099
+ bot_user_id?: string;
2100
+ authed_user_id?: string;
2101
+ }>;
2102
+ incoming_webhooks?: Array<{
2103
+ channel: string;
2104
+ label?: string;
2105
+ }>;
2106
+ strict_scopes?: boolean;
2107
+ signing_secret?: string;
2108
+ }
2109
+
2110
+ type ProviderOptions = APIOptions & {
2111
+ baseUrl?: string;
2112
+ tokens?: Record<string, AuthUser>;
2113
+ fallbackUser?: AuthFallback;
2114
+ publicNamespace?: string;
2115
+ adminPrefix?: string;
2116
+ /**
2117
+ * A seeded stream of `[0, 1)` that ids and tokens are minted from, so a run replays from
2118
+ * its seed. Default: the platform's randomness.
2119
+ */
2120
+ random?: () => number;
2121
+ };
2122
+
1325
2123
  /**
1326
2124
  * One message the app "sent": an incoming-webhook post or a Web API post. The outbox is the
1327
2125
  * point of this mock, so it keeps the text and blocks (the request journal never does).
@@ -1439,7 +2237,7 @@ declare class SlackState {
1439
2237
  readonly settings: Collection<Settings>;
1440
2238
  /** Only its sequence is used: the microsecond part of every `ts`. */
1441
2239
  private readonly tsCounter;
1442
- constructor(sqlite: SqliteClient, namespace: string, seed: {
2240
+ constructor(sqlite: SqliteClient$1, namespace: string, seed: {
1443
2241
  settings: Partial<Settings>;
1444
2242
  });
1445
2243
  /** Re-apply the default workspace after a reset. */
@@ -1455,7 +2253,8 @@ declare class SlackState {
1455
2253
  findMessage(channel: string, ts: string): SlackMessage | undefined;
1456
2254
  }
1457
2255
 
1458
- type SlackAPIOptions = APIOptions & {
2256
+ type SlackAPIOptions = APIOptions$1 & Pick<ProviderOptions, "tokens" | "baseUrl" | "publicNamespace" | "adminPrefix" | "random"> & {
2257
+ fixtures?: SlackSeedConfig;
1459
2258
  /** Initial per-namespace settings (workspace identity, accepted tokens, strict channels). */
1460
2259
  settings?: Partial<Settings>;
1461
2260
  /**
@@ -1472,13 +2271,16 @@ type SlackAPIOptions = APIOptions & {
1472
2271
  */
1473
2272
  declare class SlackAPI implements FetchAPI {
1474
2273
  readonly app: Hono;
1475
- readonly sqlite: SqliteClient;
2274
+ readonly sqlite: SqliteClient$1;
1476
2275
  readonly state: SlackState;
2276
+ private tail;
2277
+ private readonly expansion;
1477
2278
  private readonly service;
1478
2279
  private readonly now;
1479
2280
  private readonly namespaceName;
1480
2281
  constructor(options?: SlackAPIOptions);
1481
2282
  fetch(request: Request): Promise<Response>;
2283
+ private handleFetch;
1482
2284
  reset(): Promise<void>;
1483
2285
  /** Every message in the outbox, oldest first. */
1484
2286
  messages(): SlackMessage[];
@@ -1520,12 +2322,14 @@ declare class SlackAPI implements FetchAPI {
1520
2322
  private openView;
1521
2323
  }
1522
2324
 
1523
- type SlackRuntimeOptions = {
1524
- sqlite?: SqliteClient;
2325
+ type SlackRuntimeOptions = Pick<SlackAPIOptions, "fixtures" | "baseUrl" | "tokens"> & {
2326
+ sqlite?: SqliteClient$1;
1525
2327
  clock?: Clock;
1526
2328
  seed?: number | string;
1527
2329
  adminPrefix?: string;
1528
2330
  adminKey?: string;
2331
+ /** Admin controls to boot with: clock, latency, faults, seed, a starting snapshot. */
2332
+ adminControls?: MockControls;
1529
2333
  onLog?: (entry: RequestLog) => void;
1530
2334
  settings?: Partial<Settings>;
1531
2335
  };