@crvouga/mockingbird-service-junction 1.8.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  runCli,
5
5
  serveCommand,
6
6
  serveTarget
7
- } from "./chunk-4QHCRJO4.js";
7
+ } from "./chunk-7LPCTLIJ.js";
8
8
  import {
9
9
  DEFAULT_JUNCTION_BASE_URL,
10
10
  createRuntime,
@@ -12,7 +12,7 @@ import {
12
12
  isSandboxKey,
13
13
  pullCorpus,
14
14
  verifyAgainstReal
15
- } from "./chunk-ADSZBAJZ.js";
15
+ } from "./chunk-FZVFIPML.js";
16
16
  import {
17
17
  defaultCorpus
18
18
  } from "./chunk-C2UGIPPM.js";
package/dist/index.d.ts CHANGED
@@ -154,6 +154,15 @@ type FaultCandidate = {
154
154
  namespace: string;
155
155
  };
156
156
  type FaultRegistry = {
157
+ isolateNamespaces(): void;
158
+ snapshot(namespace: string): {
159
+ rules: (FaultRule & {
160
+ remaining: number | null;
161
+ hits: number;
162
+ position: number;
163
+ })[];
164
+ rngState: number;
165
+ };
157
166
  add(rule: FaultRule): FaultRule;
158
167
  list(): (FaultRule & {
159
168
  remaining: number | null;
@@ -161,6 +170,14 @@ type FaultRegistry = {
161
170
  })[];
162
171
  remove(id: string): boolean;
163
172
  clear(): void;
173
+ restore(namespace: string, state: {
174
+ rules: (FaultRule & {
175
+ remaining: number | null;
176
+ hits: number;
177
+ position: number;
178
+ })[];
179
+ rngState: number;
180
+ }): void;
164
181
  /**
165
182
  * Every fault this request should get, in rule order, stopping at the first that answers
166
183
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
@@ -338,8 +355,8 @@ type MetricsReport = {
338
355
  };
339
356
  type Metrics = {
340
357
  record(entry: RequestLog): void;
341
- report(): MetricsReport;
342
- reset(): void;
358
+ report(namespace?: string): MetricsReport;
359
+ reset(namespace?: string): void;
343
360
  };
344
361
 
345
362
  /** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
@@ -493,6 +510,9 @@ type PublishInput = {
493
510
  id?: string;
494
511
  };
495
512
  type WebhookHub = {
513
+ pending(namespace: string): number;
514
+ snapshot(namespace: string): unknown;
515
+ restore(namespace: string, snapshot: unknown): void;
496
516
  publish(input: PublishInput): WebhookMessage;
497
517
  /** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
498
518
  setEndpoints(namespace: string, endpoints: WebhookEndpoint$1[]): WebhookEndpoint$1[];
@@ -520,6 +540,8 @@ type ServiceTimelineState = Readonly<{
520
540
  }>;
521
541
  type ServiceCheckpoint = Checkpoint<ServiceTimelineState>;
522
542
  type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
543
+ /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
544
+ stop?(): void;
523
545
  readonly name: string;
524
546
  readonly sqlite: SqliteClient$1;
525
547
  readonly clock: Clock;
@@ -530,6 +552,13 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
530
552
  readonly credentials: CredentialRegistry;
531
553
  /** The webhook hub, when the service has outbound webhooks. */
532
554
  readonly webhooks: WebhookHub | undefined;
555
+ /** Enable independent namespace clocks and PRNGs before serving a fleet. */
556
+ isolateNamespaces(): void;
557
+ namespaceClock(namespace?: string): Clock;
558
+ namespaceOf(request: Request): string;
559
+ /** Opaque in-process checkpoint including records, controls and webhook history. */
560
+ fleetSnapshot(namespace: string): object;
561
+ fleetRestore(snapshot: unknown, namespace: string): void;
533
562
  /** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
534
563
  applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule>): FaultRule[];
535
564
  /** The instance behind `namespace` (the default one when omitted), created on first use. */
@@ -1516,6 +1545,8 @@ type JunctionRuntimeOptions = {
1516
1545
  clock?: Clock;
1517
1546
  /** Seeds fault rates and webhook retry jitter. */
1518
1547
  seed?: number | string;
1548
+ /** Prefix for all internal HTTP paths. Default /__admin. */
1549
+ adminPrefix?: string;
1519
1550
  /** Require `x-mockingbird-admin-key` on `/__admin/*`. */
1520
1551
  adminKey?: string;
1521
1552
  onLog?: (entry: RequestLog) => void;
@@ -1526,7 +1557,7 @@ type JunctionRuntime = ServiceRuntime<JunctionAPI> & {
1526
1557
  };
1527
1558
  /**
1528
1559
  * The Junction mock with Mockingbird's full service contract: unauthenticated
1529
- * `/health`, the `/__admin/*` control plane, per-request namespaces
1560
+ * `/__admin/health`, the `/__admin/*` control plane, per-request namespaces
1530
1561
  * (`x-mockingbird-namespace`), clock control, fault injection and request metrics.
1531
1562
  * Runtime-neutral: serve it with any Fetch-native server, or use `./server` for Node.
1532
1563
  */
@@ -1644,7 +1675,7 @@ type JunctionAPIOptions = APIOptions & {
1644
1675
  /** Users and orders to load into every namespace, re-applied on every `reset()`. */
1645
1676
  fixtures?: JunctionFixtures;
1646
1677
  };
1647
- /** What a loaded corpus covers, for `/health` and startup logs. */
1678
+ /** What a loaded corpus covers, for `/__admin/health` and startup logs. */
1648
1679
  type CorpusInfo = {
1649
1680
  label: string;
1650
1681
  recordedAt: string;
package/dist/index.js CHANGED
@@ -53,7 +53,7 @@ import {
53
53
  supportedOperationIds,
54
54
  verifyAgainstReal,
55
55
  verifySvix
56
- } from "./chunk-ADSZBAJZ.js";
56
+ } from "./chunk-FZVFIPML.js";
57
57
  import {
58
58
  SEALED_CORPUS_VERSION,
59
59
  SUPPORTED_SEALED_CORPUS_VERSIONS,
package/dist/server.d.ts CHANGED
@@ -155,6 +155,15 @@ type FaultCandidate$1 = {
155
155
  namespace: string;
156
156
  };
157
157
  type FaultRegistry$1 = {
158
+ isolateNamespaces(): void;
159
+ snapshot(namespace: string): {
160
+ rules: (FaultRule$1 & {
161
+ remaining: number | null;
162
+ hits: number;
163
+ position: number;
164
+ })[];
165
+ rngState: number;
166
+ };
158
167
  add(rule: FaultRule$1): FaultRule$1;
159
168
  list(): (FaultRule$1 & {
160
169
  remaining: number | null;
@@ -162,6 +171,14 @@ type FaultRegistry$1 = {
162
171
  })[];
163
172
  remove(id: string): boolean;
164
173
  clear(): void;
174
+ restore(namespace: string, state: {
175
+ rules: (FaultRule$1 & {
176
+ remaining: number | null;
177
+ hits: number;
178
+ position: number;
179
+ })[];
180
+ rngState: number;
181
+ }): void;
165
182
  /**
166
183
  * Every fault this request should get, in rule order, stopping at the first that answers
167
184
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
@@ -326,8 +343,8 @@ type MetricsReport$1 = {
326
343
  };
327
344
  type Metrics$1 = {
328
345
  record(entry: RequestLog$1): void;
329
- report(): MetricsReport$1;
330
- reset(): void;
346
+ report(namespace?: string): MetricsReport$1;
347
+ reset(namespace?: string): void;
331
348
  };
332
349
 
333
350
  /** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
@@ -481,6 +498,9 @@ type PublishInput$1 = {
481
498
  id?: string;
482
499
  };
483
500
  type WebhookHub$1 = {
501
+ pending(namespace: string): number;
502
+ snapshot(namespace: string): unknown;
503
+ restore(namespace: string, snapshot: unknown): void;
484
504
  publish(input: PublishInput$1): WebhookMessage$1;
485
505
  /** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
486
506
  setEndpoints(namespace: string, endpoints: WebhookEndpoint$2[]): WebhookEndpoint$2[];
@@ -508,6 +528,8 @@ type ServiceTimelineState$1 = Readonly<{
508
528
  }>;
509
529
  type ServiceCheckpoint$1 = Checkpoint$1<ServiceTimelineState$1>;
510
530
  type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$2 & {
531
+ /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
532
+ stop?(): void;
511
533
  readonly name: string;
512
534
  readonly sqlite: SqliteClient$2;
513
535
  readonly clock: Clock$1;
@@ -518,6 +540,13 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$2 & {
518
540
  readonly credentials: CredentialRegistry$1;
519
541
  /** The webhook hub, when the service has outbound webhooks. */
520
542
  readonly webhooks: WebhookHub$1 | undefined;
543
+ /** Enable independent namespace clocks and PRNGs before serving a fleet. */
544
+ isolateNamespaces(): void;
545
+ namespaceClock(namespace?: string): Clock$1;
546
+ namespaceOf(request: Request): string;
547
+ /** Opaque in-process checkpoint including records, controls and webhook history. */
548
+ fleetSnapshot(namespace: string): object;
549
+ fleetRestore(snapshot: unknown, namespace: string): void;
521
550
  /** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
522
551
  applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule$1>): FaultRule$1[];
523
552
  /** The instance behind `namespace` (the default one when omitted), created on first use. */
@@ -564,6 +593,7 @@ type CliOption = {
564
593
  };
565
594
  type CliValues = Record<string, string | boolean | undefined>;
566
595
  type CommonServeOptions = {
596
+ adminPrefix?: string;
567
597
  adminKey: string | undefined;
568
598
  seed: string | undefined;
569
599
  onLog: ((entry: RequestLog$1) => void) | undefined;
@@ -739,6 +769,15 @@ type FaultCandidate = {
739
769
  namespace: string;
740
770
  };
741
771
  type FaultRegistry = {
772
+ isolateNamespaces(): void;
773
+ snapshot(namespace: string): {
774
+ rules: (FaultRule & {
775
+ remaining: number | null;
776
+ hits: number;
777
+ position: number;
778
+ })[];
779
+ rngState: number;
780
+ };
742
781
  add(rule: FaultRule): FaultRule;
743
782
  list(): (FaultRule & {
744
783
  remaining: number | null;
@@ -746,6 +785,14 @@ type FaultRegistry = {
746
785
  })[];
747
786
  remove(id: string): boolean;
748
787
  clear(): void;
788
+ restore(namespace: string, state: {
789
+ rules: (FaultRule & {
790
+ remaining: number | null;
791
+ hits: number;
792
+ position: number;
793
+ })[];
794
+ rngState: number;
795
+ }): void;
749
796
  /**
750
797
  * Every fault this request should get, in rule order, stopping at the first that answers
751
798
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
@@ -923,8 +970,8 @@ type MetricsReport = {
923
970
  };
924
971
  type Metrics = {
925
972
  record(entry: RequestLog): void;
926
- report(): MetricsReport;
927
- reset(): void;
973
+ report(namespace?: string): MetricsReport;
974
+ reset(namespace?: string): void;
928
975
  };
929
976
 
930
977
  /** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
@@ -1078,6 +1125,9 @@ type PublishInput = {
1078
1125
  id?: string;
1079
1126
  };
1080
1127
  type WebhookHub = {
1128
+ pending(namespace: string): number;
1129
+ snapshot(namespace: string): unknown;
1130
+ restore(namespace: string, snapshot: unknown): void;
1081
1131
  publish(input: PublishInput): WebhookMessage;
1082
1132
  /** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
1083
1133
  setEndpoints(namespace: string, endpoints: WebhookEndpoint$1[]): WebhookEndpoint$1[];
@@ -1105,6 +1155,8 @@ type ServiceTimelineState = Readonly<{
1105
1155
  }>;
1106
1156
  type ServiceCheckpoint = Checkpoint<ServiceTimelineState>;
1107
1157
  type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
1158
+ /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
1159
+ stop?(): void;
1108
1160
  readonly name: string;
1109
1161
  readonly sqlite: SqliteClient$1;
1110
1162
  readonly clock: Clock;
@@ -1115,6 +1167,13 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
1115
1167
  readonly credentials: CredentialRegistry;
1116
1168
  /** The webhook hub, when the service has outbound webhooks. */
1117
1169
  readonly webhooks: WebhookHub | undefined;
1170
+ /** Enable independent namespace clocks and PRNGs before serving a fleet. */
1171
+ isolateNamespaces(): void;
1172
+ namespaceClock(namespace?: string): Clock;
1173
+ namespaceOf(request: Request): string;
1174
+ /** Opaque in-process checkpoint including records, controls and webhook history. */
1175
+ fleetSnapshot(namespace: string): object;
1176
+ fleetRestore(snapshot: unknown, namespace: string): void;
1118
1177
  /** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
1119
1178
  applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule>): FaultRule[];
1120
1179
  /** The instance behind `namespace` (the default one when omitted), created on first use. */
@@ -1650,7 +1709,7 @@ type JunctionAPIOptions = APIOptions & {
1650
1709
  /** Users and orders to load into every namespace, re-applied on every `reset()`. */
1651
1710
  fixtures?: JunctionFixtures;
1652
1711
  };
1653
- /** What a loaded corpus covers, for `/health` and startup logs. */
1712
+ /** What a loaded corpus covers, for `/__admin/health` and startup logs. */
1654
1713
  type CorpusInfo = {
1655
1714
  label: string;
1656
1715
  recordedAt: string;
@@ -1789,6 +1848,8 @@ type JunctionRuntimeOptions = {
1789
1848
  clock?: Clock;
1790
1849
  /** Seeds fault rates and webhook retry jitter. */
1791
1850
  seed?: number | string;
1851
+ /** Prefix for all internal HTTP paths. Default /__admin. */
1852
+ adminPrefix?: string;
1792
1853
  /** Require `x-mockingbird-admin-key` on `/__admin/*`. */
1793
1854
  adminKey?: string;
1794
1855
  onLog?: (entry: RequestLog) => void;
package/dist/server.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  createServer,
4
4
  loadCorpus,
5
5
  serveTarget
6
- } from "./chunk-4QHCRJO4.js";
7
- import "./chunk-ADSZBAJZ.js";
6
+ } from "./chunk-7LPCTLIJ.js";
7
+ import "./chunk-FZVFIPML.js";
8
8
  import "./chunk-C2UGIPPM.js";
9
9
  import "./chunk-ISDNA2TU.js";
10
10
  export {