@crvouga/mockingbird-service-fullscript 1.7.1 → 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
@@ -3,8 +3,8 @@ import {
3
3
  runCli,
4
4
  serveCommand,
5
5
  serveTarget
6
- } from "./chunk-DI3IPCT2.js";
7
- import "./chunk-VPJ64KU3.js";
6
+ } from "./chunk-EZGGE5JC.js";
7
+ import "./chunk-R7LD4QOX.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -219,6 +219,15 @@ type FaultCandidate = {
219
219
  namespace: string;
220
220
  };
221
221
  type FaultRegistry = {
222
+ isolateNamespaces(): void;
223
+ snapshot(namespace: string): {
224
+ rules: (FaultRule & {
225
+ remaining: number | null;
226
+ hits: number;
227
+ position: number;
228
+ })[];
229
+ rngState: number;
230
+ };
222
231
  add(rule: FaultRule): FaultRule;
223
232
  list(): (FaultRule & {
224
233
  remaining: number | null;
@@ -226,6 +235,14 @@ type FaultRegistry = {
226
235
  })[];
227
236
  remove(id: string): boolean;
228
237
  clear(): void;
238
+ restore(namespace: string, state: {
239
+ rules: (FaultRule & {
240
+ remaining: number | null;
241
+ hits: number;
242
+ position: number;
243
+ })[];
244
+ rngState: number;
245
+ }): void;
229
246
  /**
230
247
  * Every fault this request should get, in rule order, stopping at the first that answers
231
248
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
@@ -403,8 +420,8 @@ type MetricsReport = {
403
420
  };
404
421
  type Metrics = {
405
422
  record(entry: RequestLog): void;
406
- report(): MetricsReport;
407
- reset(): void;
423
+ report(namespace?: string): MetricsReport;
424
+ reset(namespace?: string): void;
408
425
  };
409
426
 
410
427
  /** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
@@ -558,6 +575,9 @@ type PublishInput = {
558
575
  id?: string;
559
576
  };
560
577
  type WebhookHub = {
578
+ pending(namespace: string): number;
579
+ snapshot(namespace: string): unknown;
580
+ restore(namespace: string, snapshot: unknown): void;
561
581
  publish(input: PublishInput): WebhookMessage;
562
582
  /** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
563
583
  setEndpoints(namespace: string, endpoints: WebhookEndpoint[]): WebhookEndpoint[];
@@ -585,6 +605,8 @@ type ServiceTimelineState = Readonly<{
585
605
  }>;
586
606
  type ServiceCheckpoint = Checkpoint<ServiceTimelineState>;
587
607
  type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
608
+ /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
609
+ stop?(): void;
588
610
  readonly name: string;
589
611
  readonly sqlite: SqliteClient$1;
590
612
  readonly clock: Clock;
@@ -595,6 +617,13 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
595
617
  readonly credentials: CredentialRegistry;
596
618
  /** The webhook hub, when the service has outbound webhooks. */
597
619
  readonly webhooks: WebhookHub | undefined;
620
+ /** Enable independent namespace clocks and PRNGs before serving a fleet. */
621
+ isolateNamespaces(): void;
622
+ namespaceClock(namespace?: string): Clock;
623
+ namespaceOf(request: Request): string;
624
+ /** Opaque in-process checkpoint including records, controls and webhook history. */
625
+ fleetSnapshot(namespace: string): object;
626
+ fleetRestore(snapshot: unknown, namespace: string): void;
598
627
  /** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
599
628
  applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule>): FaultRule[];
600
629
  /** The instance behind `namespace` (the default one when omitted), created on first use. */
@@ -947,6 +976,7 @@ type FullscriptRuntimeOptions = {
947
976
  sqlite?: SqliteClient;
948
977
  clock?: Clock;
949
978
  seed?: number | string;
979
+ adminPrefix?: string;
950
980
  adminKey?: string;
951
981
  onLog?: (entry: RequestLog) => void;
952
982
  settings?: Partial<Settings>;
@@ -966,8 +996,8 @@ type FullscriptRuntime = ServiceRuntime<FullscriptAPI> & {
966
996
  readonly webhooks: WebhookHub;
967
997
  };
968
998
  /**
969
- * The Fullscript mock with Mockingbird's full service contract: `/health`, `/__admin/*`,
970
- * namespaces by header, by `/ns/<name>` path prefix on FULLSCRIPT_API_URL, or by OAuth client
999
+ * The Fullscript mock with Mockingbird's full service contract: `/__admin/health`, `/__admin/*`,
1000
+ * namespaces by header, by `/__admin/ns/<name>` path prefix on FULLSCRIPT_API_URL, or by OAuth client
971
1001
  * (for API calls), clock control, fault presets, signed webhooks and a request journal.
972
1002
  */
973
1003
  declare const createRuntime: (options?: FullscriptRuntimeOptions) => FullscriptRuntime;
@@ -1001,7 +1031,8 @@ type SeedOrder = {
1001
1031
  type FullscriptAPIOptions = APIOptions & {
1002
1032
  settings?: Partial<Settings>;
1003
1033
  orders?: readonly SeedOrder[];
1004
- /** The public namespace, so result PDF URLs carry a `/ns/<name>` prefix. */
1034
+ /** The public namespace, so result PDF URLs carry a `/__admin/ns/<name>` prefix. */
1035
+ adminPrefix?: string;
1005
1036
  publicNamespace?: string;
1006
1037
  /** Called for every event; the runtime signs and delivers it. */
1007
1038
  onEvent?: (event: EventRecord) => void;
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  publicEvent,
19
19
  supportedOperationIds,
20
20
  tokenCredential
21
- } from "./chunk-VPJ64KU3.js";
21
+ } from "./chunk-R7LD4QOX.js";
22
22
  export {
23
23
  DEFAULT_CLINIC,
24
24
  DEFAULT_PRACTITIONER,
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$1[]): WebhookEndpoint$1[];
@@ -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;
@@ -781,6 +811,15 @@ type FaultCandidate = {
781
811
  namespace: string;
782
812
  };
783
813
  type FaultRegistry = {
814
+ isolateNamespaces(): void;
815
+ snapshot(namespace: string): {
816
+ rules: (FaultRule & {
817
+ remaining: number | null;
818
+ hits: number;
819
+ position: number;
820
+ })[];
821
+ rngState: number;
822
+ };
784
823
  add(rule: FaultRule): FaultRule;
785
824
  list(): (FaultRule & {
786
825
  remaining: number | null;
@@ -788,6 +827,14 @@ type FaultRegistry = {
788
827
  })[];
789
828
  remove(id: string): boolean;
790
829
  clear(): void;
830
+ restore(namespace: string, state: {
831
+ rules: (FaultRule & {
832
+ remaining: number | null;
833
+ hits: number;
834
+ position: number;
835
+ })[];
836
+ rngState: number;
837
+ }): void;
791
838
  /**
792
839
  * Every fault this request should get, in rule order, stopping at the first that answers
793
840
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
@@ -965,8 +1012,8 @@ type MetricsReport = {
965
1012
  };
966
1013
  type Metrics = {
967
1014
  record(entry: RequestLog): void;
968
- report(): MetricsReport;
969
- reset(): void;
1015
+ report(namespace?: string): MetricsReport;
1016
+ reset(namespace?: string): void;
970
1017
  };
971
1018
 
972
1019
  /** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
@@ -1120,6 +1167,9 @@ type PublishInput = {
1120
1167
  id?: string;
1121
1168
  };
1122
1169
  type WebhookHub = {
1170
+ pending(namespace: string): number;
1171
+ snapshot(namespace: string): unknown;
1172
+ restore(namespace: string, snapshot: unknown): void;
1123
1173
  publish(input: PublishInput): WebhookMessage;
1124
1174
  /** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
1125
1175
  setEndpoints(namespace: string, endpoints: WebhookEndpoint[]): WebhookEndpoint[];
@@ -1147,6 +1197,8 @@ type ServiceTimelineState = Readonly<{
1147
1197
  }>;
1148
1198
  type ServiceCheckpoint = Checkpoint<ServiceTimelineState>;
1149
1199
  type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
1200
+ /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
1201
+ stop?(): void;
1150
1202
  readonly name: string;
1151
1203
  readonly sqlite: SqliteClient$1;
1152
1204
  readonly clock: Clock;
@@ -1157,6 +1209,13 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
1157
1209
  readonly credentials: CredentialRegistry;
1158
1210
  /** The webhook hub, when the service has outbound webhooks. */
1159
1211
  readonly webhooks: WebhookHub | undefined;
1212
+ /** Enable independent namespace clocks and PRNGs before serving a fleet. */
1213
+ isolateNamespaces(): void;
1214
+ namespaceClock(namespace?: string): Clock;
1215
+ namespaceOf(request: Request): string;
1216
+ /** Opaque in-process checkpoint including records, controls and webhook history. */
1217
+ fleetSnapshot(namespace: string): object;
1218
+ fleetRestore(snapshot: unknown, namespace: string): void;
1160
1219
  /** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
1161
1220
  applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule>): FaultRule[];
1162
1221
  /** The instance behind `namespace` (the default one when omitted), created on first use. */
@@ -1345,7 +1404,8 @@ type SeedOrder = {
1345
1404
  type FullscriptAPIOptions = APIOptions & {
1346
1405
  settings?: Partial<Settings>;
1347
1406
  orders?: readonly SeedOrder[];
1348
- /** The public namespace, so result PDF URLs carry a `/ns/<name>` prefix. */
1407
+ /** The public namespace, so result PDF URLs carry a `/__admin/ns/<name>` prefix. */
1408
+ adminPrefix?: string;
1349
1409
  publicNamespace?: string;
1350
1410
  /** Called for every event; the runtime signs and delivers it. */
1351
1411
  onEvent?: (event: EventRecord) => void;
@@ -1402,6 +1462,7 @@ type FullscriptRuntimeOptions = {
1402
1462
  sqlite?: SqliteClient;
1403
1463
  clock?: Clock;
1404
1464
  seed?: number | string;
1465
+ adminPrefix?: string;
1405
1466
  adminKey?: string;
1406
1467
  onLog?: (entry: RequestLog) => void;
1407
1468
  settings?: Partial<Settings>;
package/dist/server.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  DEFAULT_PORT,
3
3
  createServer,
4
4
  serveTarget
5
- } from "./chunk-DI3IPCT2.js";
6
- import "./chunk-VPJ64KU3.js";
5
+ } from "./chunk-EZGGE5JC.js";
6
+ import "./chunk-R7LD4QOX.js";
7
7
  export {
8
8
  DEFAULT_PORT,
9
9
  createServer,