@crvouga/mockingbird-service-rxvortex 3.6.0 → 3.8.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-ZYWNK53Z.js";
7
- import "./chunk-IGSGSEGS.js";
6
+ } from "./chunk-FMRGGCDW.js";
7
+ import "./chunk-OXSYA6RB.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -184,9 +184,15 @@ declare class Collection<T> {
184
184
  }>;
185
185
  }
186
186
 
187
+ /**
188
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
189
+ * which derives the base from the wall clock when the runtime is created.
190
+ */
191
+ type IdBase = number | string;
187
192
  /**
188
193
  * Sequential id source persisted in SQLite. Ids are deterministic for a given
189
194
  * sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
195
+ * A runtime's `idBase` is mixed in, so a different base reissues none of another's ids.
190
196
  */
191
197
  declare class IdSequence {
192
198
  private readonly sqlite;
@@ -291,6 +297,15 @@ type FaultRule = {
291
297
  requestHeaders?: Record<string, string>;
292
298
  /** Fault only requests carrying these query parameters. `"*"` matches any value. */
293
299
  query?: Record<string, string>;
300
+ /**
301
+ * Fault only requests whose JSON body carries these fields. Each key is a dotted path into
302
+ * the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
303
+ * and each value is what the field must equal: a string, number, boolean or `null`, compared
304
+ * strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
305
+ * is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
306
+ * response a rule injects.
307
+ */
308
+ requestBody?: Record<string, RequestBodyValue>;
294
309
  /**
295
310
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
296
311
  * an in-process caller usually wants, and what a parallel worker usually does not:
@@ -357,6 +372,8 @@ type FaultRule = {
357
372
  /** The preset this rule was expanded from, if any. */
358
373
  fromPreset?: string;
359
374
  };
375
+ /** What a field of the request body must equal in {@link FaultRule.requestBody}. */
376
+ type RequestBodyValue = string | number | boolean | null;
360
377
  /** A fault that fired for one request. */
361
378
  type FaultHit = {
362
379
  id: string;
@@ -394,6 +411,11 @@ type FaultCandidate = {
394
411
  /** Request headers and query, for rules that match on them. */
395
412
  headers?: Headers;
396
413
  query?: URLSearchParams;
414
+ /**
415
+ * The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
416
+ * `undefined` for a body that is missing or not JSON. It must leave the request readable.
417
+ */
418
+ readJson?: () => Promise<unknown>;
397
419
  /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
398
420
  now?: number;
399
421
  /** How to spend a delay for this request. Default: the registry's own sleep. */
@@ -916,6 +938,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
916
938
  mount(prefix: string): MountedAPI;
917
939
  readonly sqlite: SqliteClient$1;
918
940
  readonly clock: Clock;
941
+ /**
942
+ * Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
943
+ * return the number it resolved to. Set it before the first request so a boot's ids stay
944
+ * one run.
945
+ */
946
+ setIdBase(base: IdBase): number;
919
947
  readonly faults: FaultRegistry;
920
948
  /** Baseline response time per namespace. */
921
949
  readonly latency: LatencyRegistry;
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  parseCatalogItem,
12
12
  supportedOperationIds,
13
13
  tokenCredential
14
- } from "./chunk-IGSGSEGS.js";
14
+ } from "./chunk-OXSYA6RB.js";
15
15
  export {
16
16
  CUSTOM_CREAM_ANCHOR_PRESET_ID,
17
17
  DEFAULT_CATALOG,
package/dist/server.d.ts CHANGED
@@ -133,6 +133,12 @@ interface SqliteClient$2 {
133
133
  transaction<T>(fn: () => T): T;
134
134
  }
135
135
 
136
+ /**
137
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
138
+ * which derives the base from the wall clock when the runtime is created.
139
+ */
140
+ type IdBase$1 = number | string;
141
+
136
142
  /**
137
143
  * The single source of time for a service.
138
144
  *
@@ -215,6 +221,15 @@ type FaultRule$1 = {
215
221
  requestHeaders?: Record<string, string>;
216
222
  /** Fault only requests carrying these query parameters. `"*"` matches any value. */
217
223
  query?: Record<string, string>;
224
+ /**
225
+ * Fault only requests whose JSON body carries these fields. Each key is a dotted path into
226
+ * the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
227
+ * and each value is what the field must equal: a string, number, boolean or `null`, compared
228
+ * strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
229
+ * is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
230
+ * response a rule injects.
231
+ */
232
+ requestBody?: Record<string, RequestBodyValue$1>;
218
233
  /**
219
234
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
220
235
  * an in-process caller usually wants, and what a parallel worker usually does not:
@@ -281,6 +296,8 @@ type FaultRule$1 = {
281
296
  /** The preset this rule was expanded from, if any. */
282
297
  fromPreset?: string;
283
298
  };
299
+ /** What a field of the request body must equal in {@link FaultRule.requestBody}. */
300
+ type RequestBodyValue$1 = string | number | boolean | null;
284
301
  /** A fault that fired for one request. */
285
302
  type FaultHit$1 = {
286
303
  id: string;
@@ -305,6 +322,11 @@ type FaultCandidate$1 = {
305
322
  /** Request headers and query, for rules that match on them. */
306
323
  headers?: Headers;
307
324
  query?: URLSearchParams;
325
+ /**
326
+ * The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
327
+ * `undefined` for a body that is missing or not JSON. It must leave the request readable.
328
+ */
329
+ readJson?: () => Promise<unknown>;
308
330
  /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
309
331
  now?: number;
310
332
  /** How to spend a delay for this request. Default: the registry's own sleep. */
@@ -827,6 +849,12 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$2 & {
827
849
  mount(prefix: string): MountedAPI$1;
828
850
  readonly sqlite: SqliteClient$2;
829
851
  readonly clock: Clock$1;
852
+ /**
853
+ * Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
854
+ * return the number it resolved to. Set it before the first request so a boot's ids stay
855
+ * one run.
856
+ */
857
+ setIdBase(base: IdBase$1): number;
830
858
  readonly faults: FaultRegistry$1;
831
859
  /** Baseline response time per namespace. */
832
860
  readonly latency: LatencyRegistry$1;
@@ -932,6 +960,12 @@ type CommonServeOptions = {
932
960
  /** Synthetic provider fixture objects supplied by a fleet entry. */
933
961
  fixtures?: Record<string, unknown>;
934
962
  baseUrl?: string;
963
+ /**
964
+ * Boot settings from `--settings`, `MOCKINGBIRD_SETTINGS` or a fleet entry's `settings`,
965
+ * already checked by the target's {@link ServeTarget.parseSettings}. Pass them to the
966
+ * service's own `settings` option so they become every namespace's defaults.
967
+ */
968
+ settings?: Record<string, unknown>;
935
969
  };
936
970
  /**
937
971
  * What a service contributes to `serve`: how to build its runtime from CLI flags,
@@ -944,7 +978,16 @@ type ServeTarget = {
944
978
  defaultPort: number;
945
979
  /** Serve flags beyond the common ones. */
946
980
  options?: Record<string, CliOption>;
981
+ /**
982
+ * Check the boot settings a caller supplied (`--settings`, `MOCKINGBIRD_SETTINGS`, a fleet
983
+ * entry's `settings`) against the service's settings schema, returning them normalized
984
+ * or throwing a message naming the bad field. A target without one takes no boot settings,
985
+ * and supplying some is refused before a port is bound.
986
+ */
987
+ parseSettings?(settings: Record<string, unknown>): Record<string, unknown>;
947
988
  create(values: CliValues, common: CommonServeOptions): Promise<ServiceRuntime$1<ServiceInstance$1>> | ServiceRuntime$1<ServiceInstance$1>;
989
+ /** Largest request body the HTTP server accepts. Default 16 MiB. */
990
+ maxBodyBytes?: number;
948
991
  /** Startup lines after the listen address, e.g. the loaded corpus version. */
949
992
  banner?(runtime: ServiceRuntime$1<ServiceInstance$1>): string[];
950
993
  /** After the HTTP server is bound. A service that speaks more than HTTP attaches it here. */
@@ -1139,9 +1182,15 @@ declare class Collection<T> {
1139
1182
  }>;
1140
1183
  }
1141
1184
 
1185
+ /**
1186
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
1187
+ * which derives the base from the wall clock when the runtime is created.
1188
+ */
1189
+ type IdBase = number | string;
1142
1190
  /**
1143
1191
  * Sequential id source persisted in SQLite. Ids are deterministic for a given
1144
1192
  * sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
1193
+ * A runtime's `idBase` is mixed in, so a different base reissues none of another's ids.
1145
1194
  */
1146
1195
  declare class IdSequence {
1147
1196
  private readonly sqlite;
@@ -1246,6 +1295,15 @@ type FaultRule = {
1246
1295
  requestHeaders?: Record<string, string>;
1247
1296
  /** Fault only requests carrying these query parameters. `"*"` matches any value. */
1248
1297
  query?: Record<string, string>;
1298
+ /**
1299
+ * Fault only requests whose JSON body carries these fields. Each key is a dotted path into
1300
+ * the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
1301
+ * and each value is what the field must equal: a string, number, boolean or `null`, compared
1302
+ * strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
1303
+ * is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
1304
+ * response a rule injects.
1305
+ */
1306
+ requestBody?: Record<string, RequestBodyValue>;
1249
1307
  /**
1250
1308
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
1251
1309
  * an in-process caller usually wants, and what a parallel worker usually does not:
@@ -1312,6 +1370,8 @@ type FaultRule = {
1312
1370
  /** The preset this rule was expanded from, if any. */
1313
1371
  fromPreset?: string;
1314
1372
  };
1373
+ /** What a field of the request body must equal in {@link FaultRule.requestBody}. */
1374
+ type RequestBodyValue = string | number | boolean | null;
1315
1375
  /** A fault that fired for one request. */
1316
1376
  type FaultHit = {
1317
1377
  id: string;
@@ -1336,6 +1396,11 @@ type FaultCandidate = {
1336
1396
  /** Request headers and query, for rules that match on them. */
1337
1397
  headers?: Headers;
1338
1398
  query?: URLSearchParams;
1399
+ /**
1400
+ * The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
1401
+ * `undefined` for a body that is missing or not JSON. It must leave the request readable.
1402
+ */
1403
+ readJson?: () => Promise<unknown>;
1339
1404
  /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
1340
1405
  now?: number;
1341
1406
  /** How to spend a delay for this request. Default: the registry's own sleep. */
@@ -1858,6 +1923,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
1858
1923
  mount(prefix: string): MountedAPI;
1859
1924
  readonly sqlite: SqliteClient$1;
1860
1925
  readonly clock: Clock;
1926
+ /**
1927
+ * Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
1928
+ * return the number it resolved to. Set it before the first request so a boot's ids stay
1929
+ * one run.
1930
+ */
1931
+ setIdBase(base: IdBase): number;
1861
1932
  readonly faults: FaultRegistry;
1862
1933
  /** Baseline response time per namespace. */
1863
1934
  readonly latency: LatencyRegistry;
package/dist/server.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  createServer,
4
4
  loadCatalogFile,
5
5
  serveTarget
6
- } from "./chunk-ZYWNK53Z.js";
7
- import "./chunk-IGSGSEGS.js";
6
+ } from "./chunk-FMRGGCDW.js";
7
+ import "./chunk-OXSYA6RB.js";
8
8
  export {
9
9
  DEFAULT_PORT,
10
10
  createServer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-rxvortex",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
4
4
  "description": "Stateful emulator of the RxVortex (Strive) pharmacy API: OAuth token, order submit, status, cancel, recovery by sender order id, preset catalog, and signed status webhooks.",
5
5
  "license": "MIT",
6
6
  "type": "module",