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