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