@crvouga/mockingbird-service-rxvortex 3.2.0 → 3.4.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
@@ -3,8 +3,8 @@ import {
3
3
  runCli,
4
4
  serveCommand,
5
5
  serveTarget
6
- } from "./chunk-7HMXBWW2.js";
7
- import "./chunk-V2QVAS5F.js";
6
+ } from "./chunk-5NISHHYG.js";
7
+ import "./chunk-IGSGSEGS.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -221,7 +221,7 @@ type ClockState = {
221
221
  now: number;
222
222
  /** True while time does not advance on its own. */
223
223
  frozen: boolean;
224
- /** Milliseconds this clock adds to its underlying source. */
224
+ /** Milliseconds a running clock adds to its underlying source. `0` while frozen. */
225
225
  offsetMs: number;
226
226
  };
227
227
  type Clock = {
@@ -257,7 +257,10 @@ type Rng = {
257
257
  state(): number;
258
258
  /** Restore a state previously returned by {@link state}. */
259
259
  setState(state: number): void;
260
- seed: number;
260
+ /** Restart the stream from a new seed. `reset` then returns to this seed. */
261
+ reseed(seed: number | string): void;
262
+ /** The seed the stream currently starts from. */
263
+ readonly seed: number;
261
264
  };
262
265
 
263
266
  /**
@@ -266,44 +269,83 @@ type Rng = {
266
269
  * This is how a suite reaches the vendor's failure modes without the vendor: the
267
270
  * quota error that only appears when a shared sandbox is full, the 429 that only
268
271
  * appears under load, the 5xx that proves a retry path works.
272
+ *
273
+ * A rule has three parts. What it **matches** (`operationId`, `method`, `path`, …), **when**
274
+ * it fires among the matching requests (`after`, `every`, `count`, `rate`, `from`, `until`),
275
+ * and what it **does** (`status`, `delay`, `timeout`, `drop`, `truncate`, `effect`).
269
276
  */
270
277
  type FaultRule = {
271
- /** Stable id, so a suite can retire exactly the rule it added. */
278
+ /** Stable id, so a suite can retire exactly the rule it added. Unique within a namespace. */
272
279
  id: string;
273
280
  /** Fault only this operation. Omit to match every operation. */
274
281
  operationId?: string;
275
282
  /** Fault only this HTTP method, case-insensitive. Omit to match every method. */
276
283
  method?: string;
284
+ /** Fault only this exact path. */
285
+ path?: string;
277
286
  /** Fault only paths starting with this prefix. Omit to match every path. */
278
287
  pathPrefix?: string;
288
+ /** Fault only paths matching this regular expression (JavaScript syntax, unanchored). */
289
+ pathPattern?: string;
290
+ /** Fault only requests carrying these headers. `"*"` matches any value. */
291
+ requestHeaders?: Record<string, string>;
292
+ /** Fault only requests carrying these query parameters. `"*"` matches any value. */
293
+ query?: Record<string, string>;
279
294
  /**
280
295
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
281
296
  * an in-process caller usually wants, and what a parallel worker usually does not:
282
297
  * rules added through `POST /__admin/faults` default to the calling namespace.
283
298
  */
284
299
  namespace?: string;
300
+ /** Let this many matching requests through first. */
301
+ after?: number;
302
+ /** Then fault only every nth matching request: `3` faults the 3rd, 6th, 9th. */
303
+ every?: number;
304
+ /** Retire the rule after this many faults. Omit to keep it until removed. */
305
+ count?: number;
306
+ /** Fault this fraction of the remaining requests, `0`–`1`, drawn from the seed. Default `1`. */
307
+ rate?: number;
308
+ /**
309
+ * Fault only from this instant on the namespace clock. A duration (`"5m"`) counts from the
310
+ * clock when the rule was added. Listed as epoch ms.
311
+ */
312
+ from?: Instant | Duration;
313
+ /** Stop faulting at this instant on the namespace clock. A duration counts from when added. */
314
+ until?: Instant | Duration;
285
315
  /**
286
- * Status of the injected response. Omit for a rule that only delays (`delayMs` /
287
- * `latencyMs`), only drops the connection (`drop`), or only switches on an `effect`:
288
- * the request then still reaches the service.
316
+ * Status of the injected response. Omit for a rule that only delays, times out, drops,
317
+ * truncates, or switches on an `effect`: the request then still reaches the service.
289
318
  */
290
319
  status?: number;
291
320
  /** Response body, serialized as JSON. A string is sent as-is. */
292
321
  body?: unknown;
322
+ /** Response headers. */
293
323
  headers?: Record<string, string>;
294
- /** Retire the rule after this many faults. Omit to keep it until removed. */
295
- count?: number;
296
- /** Fault this fraction of matching requests, `0`–`1`. Default `1`. */
297
- rate?: number;
298
- /** Hold the response back this long, to exercise timeouts. */
324
+ /** Hold the response back this long. Listed as `delayMs`. */
325
+ delay?: Duration;
326
+ /** `delay`, in milliseconds. */
299
327
  delayMs?: number;
300
328
  /** Alias of `delayMs`. */
301
329
  latencyMs?: number;
330
+ /** Extra seeded delay in `[0, jitter]`. Listed as `jitterMs`. */
331
+ jitter?: Duration;
332
+ jitterMs?: number;
333
+ /**
334
+ * Never answer: hold the request this long, then drop the connection. Listed as
335
+ * `timeoutMs`. With virtual time the wait is spent on the mock clock.
336
+ */
337
+ timeout?: Duration;
338
+ timeoutMs?: number;
302
339
  /**
303
340
  * Drop the connection instead of answering: an in-process `fetch` rejects with a
304
341
  * `TypeError`, and a served mock destroys the socket. Models "unknown outcome" failures.
305
342
  */
306
343
  drop?: boolean;
344
+ /**
345
+ * Cut the response body off after this many bytes: the status and headers arrive, then
346
+ * the connection dies mid-body.
347
+ */
348
+ truncate?: number;
307
349
  /**
308
350
  * A named service behaviour to switch on for the matching request instead of (or
309
351
  * before) a canned response, e.g. `created_but_500` or `numeric_tracking_id`. Services
@@ -312,8 +354,8 @@ type FaultRule = {
312
354
  effect?: string;
313
355
  /** Parameters for `effect`. */
314
356
  params?: Record<string, unknown>;
315
- /** From the preset this rule was expanded from, if any. */
316
- preset?: string;
357
+ /** The preset this rule was expanded from, if any. */
358
+ fromPreset?: string;
317
359
  };
318
360
  /** A fault that fired for one request. */
319
361
  type FaultHit = {
@@ -321,6 +363,10 @@ type FaultHit = {
321
363
  /** The injected response; absent when the rule only delays, drops, or sets an effect. */
322
364
  response?: Response;
323
365
  drop?: boolean;
366
+ /** Set with `drop` when the rule held the request for its `timeout` first. */
367
+ timeout?: boolean;
368
+ /** Bytes of response body to let through before the connection dies. */
369
+ truncate?: number;
324
370
  effect?: {
325
371
  name: string;
326
372
  params: Record<string, unknown>;
@@ -345,38 +391,202 @@ type FaultCandidate = {
345
391
  method: string;
346
392
  path: string;
347
393
  namespace: string;
394
+ /** Request headers and query, for rules that match on them. */
395
+ headers?: Headers;
396
+ query?: URLSearchParams;
397
+ /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
398
+ now?: number;
399
+ /** How to spend a delay for this request. Default: the registry's own sleep. */
400
+ wait?: (ms: number) => Promise<void>;
401
+ };
402
+ /** A stored rule and how often it was consulted. */
403
+ type FaultListing = FaultRule & {
404
+ /** Faults left before the rule retires. `null` when it has no `count`. */
405
+ remaining: number | null;
406
+ /** Times the rule faulted a request. */
407
+ hits: number;
408
+ /** Requests that matched the rule, faulted or not. */
409
+ seen: number;
410
+ };
411
+ /** A namespace's own rules, with their counters, in the order they are tried. */
412
+ type FaultSnapshot = {
413
+ /**
414
+ * `position` is how many `"*"` rules are tried before the rule, which is what its place
415
+ * in the order means to a request and holds in any process.
416
+ */
417
+ rules: (FaultListing & {
418
+ position?: number;
419
+ })[];
420
+ /** How many `fault_<n>` ids the namespace has handed out. */
421
+ nextId?: number;
348
422
  };
349
423
  type FaultRegistry = {
350
- isolateNamespaces(): void;
351
- snapshot(namespace: string): {
352
- rules: (FaultRule & {
353
- remaining: number | null;
354
- hits: number;
355
- position: number;
356
- })[];
357
- rngState: number;
358
- };
424
+ snapshot(namespace: string): FaultSnapshot;
425
+ /** Add a rule, or replace the rule with the same id in the same namespace. */
359
426
  add(rule: FaultRule): FaultRule;
360
- list(): (FaultRule & {
361
- remaining: number | null;
362
- hits: number;
363
- })[];
364
- remove(id: string): boolean;
365
- clear(): void;
366
- restore(namespace: string, state: {
367
- rules: (FaultRule & {
368
- remaining: number | null;
369
- hits: number;
370
- position: number;
371
- })[];
372
- rngState: number;
373
- }): void;
427
+ /** The next unused `fault_<n>` id in `namespace`. */
428
+ nextId(namespace: string): string;
429
+ /** Every rule, or the rules a namespace's requests can hit: its own and the global ones. */
430
+ list(namespace?: string): FaultListing[];
431
+ get(id: string, namespace?: string): FaultListing | undefined;
432
+ /** Remove a rule by id: from `namespace` (its own, then a global one), or wherever it is. */
433
+ remove(id: string, namespace?: string): boolean;
434
+ /** Remove every rule, or one namespace's own rules. */
435
+ clear(namespace?: string): void;
436
+ /** Replace a namespace's own rules with a snapshot's, wherever the snapshot was taken. */
437
+ restore(namespace: string, state: FaultSnapshot): void;
374
438
  /**
375
439
  * Every fault this request should get, in rule order, stopping at the first that answers
376
440
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
377
441
  * each matching rule's remaining uses.
378
442
  */
379
443
  take(candidate: FaultCandidate): Promise<FaultHit[]>;
444
+ /**
445
+ * Fire these rules at one request without storing them: no matching, no schedule, in order,
446
+ * stopping at the first that answers or drops. Jitter draws from the namespace's stream.
447
+ */
448
+ fire(rules: readonly FaultRule[], candidate: FaultCandidate): Promise<FaultHit[]>;
449
+ };
450
+
451
+ /**
452
+ * The admin controls every mock shares, as one document.
453
+ *
454
+ * The same shape is accepted in three places, and means the same thing in each:
455
+ *
456
+ * - at boot: `createRuntime({ adminControls })`, `serve --admin-controls`,
457
+ * `MOCKINGBIRD_ADMIN_CONTROLS`
458
+ * - over HTTP: `PUT /__admin/controls`
459
+ * - per request: the `x-mockingbird-*` headers in {@link CONTROL_HEADERS}
460
+ *
461
+ * Every control is deterministic: given the same seed, clock and requests, a mock answers
462
+ * the same bytes. Nothing here reads the wall clock or `Math.random`.
463
+ */
464
+ /** Milliseconds, or a string like `"250ms"`, `"2s"`, `"15m"`, `"1h"`, `"3d"`. */
465
+ type Duration = number | string;
466
+ /** Epoch milliseconds, or an ISO-8601 string. */
467
+ type Instant = number | string;
468
+ type ClockControls = {
469
+ /** Move the clock to this instant. */
470
+ now?: Instant;
471
+ /** Stop time. A frozen clock moves only when told to, so timestamps replay exactly. */
472
+ frozen?: boolean;
473
+ /**
474
+ * Step the clock forward by this much before every vendor request. With a frozen clock
475
+ * each request still gets its own, reproducible timestamp.
476
+ */
477
+ autoAdvance?: Duration;
478
+ };
479
+ /** How long a response takes: a fixed delay plus seeded jitter in `[0, jitter]`. */
480
+ type LatencyRuleInput = {
481
+ delay?: Duration;
482
+ jitter?: Duration;
483
+ };
484
+ type LatencyControls = LatencyRuleInput & {
485
+ /** Per-operation overrides, keyed by operationId. A bare duration is its `delay`. */
486
+ operations?: Record<string, Duration | LatencyRuleInput>;
487
+ };
488
+ /** A fault to add: a rule (the id is assigned when omitted), or a named preset with overrides. */
489
+ type FaultInput = (Omit<FaultRule, "id"> & {
490
+ id?: string;
491
+ }) | ({
492
+ preset: string;
493
+ } & Partial<FaultRule>);
494
+ /** Identifies a {@link SnapshotDocument}. */
495
+ declare const SNAPSHOT_FORMAT = "mockingbird.snapshot/v1";
496
+ /**
497
+ * A namespace, as portable JSON: what `GET /__admin/snapshots/:id` returns and what
498
+ * `PUT /__admin/snapshots/:id` and the boot `snapshot` control accept. Only `format` and
499
+ * `records` are required, so a hand-written seed file is a valid snapshot.
500
+ */
501
+ type SnapshotDocument = {
502
+ format: typeof SNAPSHOT_FORMAT;
503
+ /** The service that wrote it. A snapshot is rejected by any other service. */
504
+ service?: string;
505
+ /**
506
+ * Stored rows. `seq` orders a collection; omitted, rows keep their listed order. `raw` is
507
+ * the stored text of a row that is not a plain record, and replaces `value` when present.
508
+ */
509
+ records: {
510
+ collection: string;
511
+ id: string;
512
+ seq?: number;
513
+ value?: unknown;
514
+ raw?: string;
515
+ }[];
516
+ /** Id counters, so the next generated id continues where the snapshot left off. */
517
+ sequences?: {
518
+ name: string;
519
+ kind: string;
520
+ value: number;
521
+ }[];
522
+ clock?: {
523
+ now: number;
524
+ frozen: boolean;
525
+ autoAdvanceMs?: number;
526
+ };
527
+ seed?: number | string;
528
+ /** Positions of the seeded random streams. */
529
+ rng?: {
530
+ state: number;
531
+ faults?: number;
532
+ latency?: number;
533
+ };
534
+ faults?: unknown;
535
+ latency?: unknown;
536
+ virtualTime?: boolean;
537
+ /** Quiescent webhook endpoints, delivery history and fault state. Contains private configuration. */
538
+ webhooks?: unknown;
539
+ };
540
+ /** Controls for one namespace. */
541
+ type NamespaceControls = {
542
+ /** Seeds every random choice: fault rates, jitter, and whatever the service invents. */
543
+ seed?: number | string;
544
+ clock?: ClockControls;
545
+ /**
546
+ * Spend injected waits (latency, fault delays, timeouts) on the mock clock instead of the
547
+ * wall clock: the request returns at once, the clock has moved, and the journal records
548
+ * the wait exactly. Default `false`: waits are real, so a client's own timeout can fire.
549
+ */
550
+ virtualTime?: boolean;
551
+ /** Baseline response time for every vendor request. A bare duration is its `delay`. */
552
+ latency?: Duration | LatencyControls;
553
+ faults?: readonly FaultInput[];
554
+ /** Start from this state instead of the service's own seed data. */
555
+ snapshot?: SnapshotDocument;
556
+ };
557
+ /** {@link NamespaceControls} for every namespace, with per-namespace overrides. */
558
+ type MockControls = NamespaceControls & {
559
+ /** Vendor credential → namespace, for SDKs that cannot send a namespace header. */
560
+ credentials?: Record<string, string>;
561
+ /** Overrides for named namespaces. A key given here replaces the shared value. */
562
+ namespaces?: Record<string, NamespaceControls>;
563
+ };
564
+ /** A latency rule in milliseconds. */
565
+ type LatencyRule = {
566
+ delayMs: number;
567
+ jitterMs: number;
568
+ };
569
+ /** Baseline latency for a namespace, normalized. */
570
+ type LatencyState = LatencyRule & {
571
+ operations: Record<string, LatencyRule>;
572
+ };
573
+ /** What {@link controlHeaders} turns into request headers. */
574
+ type ControlHeaderInput = {
575
+ namespace?: string;
576
+ adminKey?: string;
577
+ branch?: string;
578
+ at?: string;
579
+ reset?: boolean;
580
+ restore?: string;
581
+ seed?: number | string;
582
+ time?: Instant | Date;
583
+ advance?: Duration;
584
+ virtualTime?: boolean;
585
+ delay?: Duration;
586
+ timeout?: Duration;
587
+ /** A status, `"drop"`, a preset name, or a fault rule. */
588
+ fault?: number | string | Record<string, unknown>;
589
+ snapshot?: string;
380
590
  };
381
591
 
382
592
  /**
@@ -416,6 +626,8 @@ type RequestLog = {
416
626
  unmatched: boolean;
417
627
  /** Set when a fault rule produced the response. */
418
628
  faultId?: string;
629
+ /** Milliseconds of injected wait: latency, fault delays and timeouts. Absent when none. */
630
+ delayMs?: number;
419
631
  /** Resource ids the handler touched (`userId`, `orderId`, …), when the service reports them. */
420
632
  ids?: Record<string, string>;
421
633
  /** Set when the service created a resource the request referred to but that did not exist. */
@@ -461,6 +673,12 @@ type JournalQuery = {
461
673
  /** Only this namespace. Omit for every namespace, oldest first across all of them. */
462
674
  namespace?: string;
463
675
  operationId?: string;
676
+ /** Only this HTTP method, case-insensitive. */
677
+ method?: string;
678
+ /** Only this exact path. */
679
+ path?: string;
680
+ /** Only requests this fault rule answered or shaped. */
681
+ faultId?: string;
464
682
  status?: number;
465
683
  /** Only entries at or after this instant (epoch ms). */
466
684
  since?: number;
@@ -475,6 +693,50 @@ type Journal = {
475
693
  clear(namespace?: string): void;
476
694
  };
477
695
 
696
+ /**
697
+ * Baseline response time, per namespace: how long every vendor request takes before any
698
+ * fault is considered. Jitter draws from a stream the caller owns, one per namespace and
699
+ * separate from the fault stream, so adding latency never shifts which requests a `rate`
700
+ * fault hits.
701
+ */
702
+ type LatencyRegistry = {
703
+ get(namespace: string): LatencyState;
704
+ set(namespace: string, state: LatencyState): LatencyState;
705
+ /** Remove one namespace's latency, or every namespace's. */
706
+ clear(namespace?: string): void;
707
+ /** Milliseconds this request waits. Draws jitter, so call it once per request. */
708
+ take(namespace: string, operationId: string | undefined): number;
709
+ };
710
+
711
+ /** Clock state as the admin API reports it. */
712
+ type ControlClock = ClockState & {
713
+ /** `now`, as ISO-8601. */
714
+ iso: string;
715
+ /** Milliseconds the clock steps before every vendor request. */
716
+ autoAdvanceMs: number;
717
+ };
718
+ /** One namespace's controls: the body of `GET /__admin/controls`. */
719
+ type ControlState = {
720
+ namespace: string;
721
+ seed: number | string;
722
+ clock: ControlClock;
723
+ virtualTime: boolean;
724
+ latency: LatencyState;
725
+ faults: FaultListing[];
726
+ };
727
+
728
+ /** What `GET /__admin/snapshots` lists for each snapshot. */
729
+ type SnapshotInfo = {
730
+ id: string;
731
+ namespace: string;
732
+ /** Stored rows in the snapshot. */
733
+ records: number;
734
+ /** The namespace clock when it was taken, epoch ms. */
735
+ at: number;
736
+ /** Whether `GET /snapshots/:id` can return it as a {@link SnapshotDocument}. */
737
+ portable: boolean;
738
+ };
739
+
478
740
  /** Credential → namespace mapping behind `PUT /__admin/credentials`. */
479
741
  type CredentialRegistry = {
480
742
  set(credential: string, namespace: string): void;
@@ -487,6 +749,8 @@ type CredentialRegistry = {
487
749
  }[];
488
750
  };
489
751
 
752
+ type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
753
+
490
754
  /**
491
755
  * A point-in-time copy of everything a service namespace holds.
492
756
  *
@@ -604,8 +868,16 @@ type PublishInput = {
604
868
  id?: string;
605
869
  };
606
870
  type WebhookHub = {
871
+ observeDeliveries(listener: (event: {
872
+ namespace: string;
873
+ state: string;
874
+ deliveryId: string;
875
+ }) => void): () => void;
876
+ setTransportPolicy(policy: OwnedTransport): void;
607
877
  pending(namespace: string): number;
608
878
  snapshot(namespace: string): unknown;
879
+ exportSnapshot(handle: unknown): unknown;
880
+ importSnapshot(namespace: string, document: unknown): unknown;
609
881
  restore(namespace: string, snapshot: unknown): void;
610
882
  publish(input: PublishInput): WebhookMessage;
611
883
  /** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
@@ -618,7 +890,7 @@ type WebhookHub = {
618
890
  /** Run every pending retry (and release held reordered messages) now, and every retry those attempts schedule, until nothing is pending. */
619
891
  flush(): Promise<void>;
620
892
  /** Resolve once nothing is in flight. */
621
- idle(): Promise<void>;
893
+ idle(namespace?: string): Promise<void>;
622
894
  fault(namespace: string, fault: WebhookFault): void;
623
895
  clear(namespace?: string): void;
624
896
  };
@@ -629,7 +901,10 @@ type ServiceInstance = FetchAPI & {
629
901
  };
630
902
  type ServiceTimelineState = Readonly<{
631
903
  snapshot: NamespaceSnapshot;
632
- clock: Readonly<ReturnType<Clock["state"]>>;
904
+ /** `pinned`: the namespace's clock was frozen itself, not just following a frozen base. */
905
+ clock: Readonly<ClockState & {
906
+ pinned?: boolean;
907
+ }>;
633
908
  rngState: number;
634
909
  }>;
635
910
  type ServiceCheckpoint = Checkpoint<ServiceTimelineState>;
@@ -642,27 +917,63 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
642
917
  readonly sqlite: SqliteClient$1;
643
918
  readonly clock: Clock;
644
919
  readonly faults: FaultRegistry;
920
+ /** Baseline response time per namespace. */
921
+ readonly latency: LatencyRegistry;
645
922
  readonly metrics: Metrics;
646
923
  readonly journal: Journal;
647
924
  readonly rng: Rng;
648
925
  readonly credentials: CredentialRegistry;
649
926
  /** The webhook hub, when the service has outbound webhooks. */
650
927
  readonly webhooks: WebhookHub | undefined;
651
- /** Enable independent namespace clocks and PRNGs before serving a fleet. */
652
- isolateNamespaces(): void;
928
+ /**
929
+ * A namespace's clock. Each follows the base clock, {@link ServiceRuntime.clock}, with an
930
+ * offset and a freeze of its own, so moving one never moves another.
931
+ */
653
932
  namespaceClock(namespace?: string): Clock;
654
933
  namespaceOf(request: Request): string;
655
934
  /** Opaque in-process checkpoint including records, controls and webhook history. */
656
935
  fleetSnapshot(namespace: string): object;
657
936
  fleetRestore(snapshot: unknown, namespace: string): void;
937
+ fleetExport(snapshot: unknown): SnapshotDocument;
938
+ fleetImport(namespace: string, document: unknown): object;
658
939
  /** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
659
940
  applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule>): FaultRule[];
660
941
  /** The instance behind `namespace` (the default one when omitted), created on first use. */
661
942
  instance(namespace?: string): T;
662
943
  /** Public names of every namespace created so far. */
663
944
  namespaces(): string[];
664
- /** Reset one namespace, or every namespace with `"*"`. */
945
+ /** Return one namespace to its boot state, or every namespace with `"*"`. */
665
946
  reset(namespace?: string): Promise<void>;
947
+ /** Reset a namespace and forget it, releasing everything it held. */
948
+ dropNamespace(namespace: string): Promise<void>;
949
+ /** A namespace's controls: seed, clock, virtual time, latency, faults and snapshots. */
950
+ controls(namespace?: string): ControlState & {
951
+ snapshots: SnapshotInfo[];
952
+ };
953
+ /** Apply a control document to a namespace. A given key replaces that control. */
954
+ configure(controls: NamespaceControls, namespace?: string): ControlState & {
955
+ snapshots: SnapshotInfo[];
956
+ };
957
+ /** Named snapshots of a namespace: records, clock, random streams, faults and latency. */
958
+ readonly snapshots: {
959
+ /** Capture the namespace now. Reusing a name replaces that snapshot. */
960
+ create(options?: {
961
+ name?: string;
962
+ namespace?: string;
963
+ }): SnapshotInfo;
964
+ list(namespace?: string): SnapshotInfo[];
965
+ /** The snapshot as portable JSON, to commit beside a suite or boot another mock from. */
966
+ export(id: string, namespace?: string): SnapshotDocument;
967
+ /** Store a document as a snapshot without restoring it. */
968
+ import(document: SnapshotDocument, options?: {
969
+ name?: string;
970
+ namespace?: string;
971
+ }): SnapshotInfo;
972
+ restore(id: string, namespace?: string): void;
973
+ delete(id: string, namespace?: string): boolean;
974
+ };
975
+ /** Request headers that carry controls, checked: spread them into a `fetch` or an SDK's defaults. */
976
+ headers(input: ControlHeaderInput): Record<string, string>;
666
977
  snapshot(namespace?: string): NamespaceSnapshot;
667
978
  restore(snapshot: NamespaceSnapshot, namespace?: string): void;
668
979
  /** Capture the current branch. Mutating HTTP calls do this automatically. */
@@ -998,6 +1309,8 @@ type RxVortexRuntimeOptions = {
998
1309
  seed?: number | string;
999
1310
  adminPrefix?: string;
1000
1311
  adminKey?: string;
1312
+ /** Admin controls to boot with: clock, latency, faults, seed, a starting snapshot. */
1313
+ adminControls?: MockControls;
1001
1314
  onLog?: (entry: RequestLog) => void;
1002
1315
  /**
1003
1316
  * Rows every namespace starts with, and returns to on `POST /__admin/reset` (`serve
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  parseCatalogItem,
12
12
  supportedOperationIds,
13
13
  tokenCredential
14
- } from "./chunk-V2QVAS5F.js";
14
+ } from "./chunk-IGSGSEGS.js";
15
15
  export {
16
16
  CUSTOM_CREAM_ANCHOR_PRESET_ID,
17
17
  DEFAULT_CATALOG,