@crvouga/mockingbird-service-step-functions 3.5.0 → 3.7.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-LSHC7AAT.js";
7
- import "./chunk-WM6TYPGJ.js";
6
+ } from "./chunk-RWOXKPES.js";
7
+ import "./chunk-3A5FTNZP.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -172,9 +172,15 @@ declare class Collection<T> {
172
172
  }>;
173
173
  }
174
174
 
175
+ /**
176
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
177
+ * which derives the base from the wall clock when the runtime is created.
178
+ */
179
+ type IdBase = number | string;
175
180
  /**
176
181
  * Sequential id source persisted in SQLite. Ids are deterministic for a given
177
182
  * sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
183
+ * A runtime's `idBase` is mixed in, so a different base reissues none of another's ids.
178
184
  */
179
185
  declare class IdSequence {
180
186
  private readonly sqlite;
@@ -279,6 +285,15 @@ type FaultRule = {
279
285
  requestHeaders?: Record<string, string>;
280
286
  /** Fault only requests carrying these query parameters. `"*"` matches any value. */
281
287
  query?: Record<string, string>;
288
+ /**
289
+ * Fault only requests whose JSON body carries these fields. Each key is a dotted path into
290
+ * the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
291
+ * and each value is what the field must equal: a string, number, boolean or `null`, compared
292
+ * strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
293
+ * is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
294
+ * response a rule injects.
295
+ */
296
+ requestBody?: Record<string, RequestBodyValue>;
282
297
  /**
283
298
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
284
299
  * an in-process caller usually wants, and what a parallel worker usually does not:
@@ -345,6 +360,8 @@ type FaultRule = {
345
360
  /** The preset this rule was expanded from, if any. */
346
361
  fromPreset?: string;
347
362
  };
363
+ /** What a field of the request body must equal in {@link FaultRule.requestBody}. */
364
+ type RequestBodyValue = string | number | boolean | null;
348
365
  /** A fault that fired for one request. */
349
366
  type FaultHit = {
350
367
  id: string;
@@ -382,6 +399,11 @@ type FaultCandidate = {
382
399
  /** Request headers and query, for rules that match on them. */
383
400
  headers?: Headers;
384
401
  query?: URLSearchParams;
402
+ /**
403
+ * The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
404
+ * `undefined` for a body that is missing or not JSON. It must leave the request readable.
405
+ */
406
+ readJson?: () => Promise<unknown>;
385
407
  /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
386
408
  now?: number;
387
409
  /** How to spend a delay for this request. Default: the registry's own sleep. */
@@ -904,6 +926,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
904
926
  mount(prefix: string): MountedAPI;
905
927
  readonly sqlite: SqliteClient$1;
906
928
  readonly clock: Clock;
929
+ /**
930
+ * Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
931
+ * return the number it resolved to. Set it before the first request so a boot's ids stay
932
+ * one run.
933
+ */
934
+ setIdBase(base: IdBase): number;
907
935
  readonly faults: FaultRegistry;
908
936
  /** Baseline response time per namespace. */
909
937
  readonly latency: LatencyRegistry;
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  document,
8
8
  operationIds,
9
9
  supportedOperationIds
10
- } from "./chunk-WM6TYPGJ.js";
10
+ } from "./chunk-3A5FTNZP.js";
11
11
  export {
12
12
  STEP_FUNCTIONS_NAMESPACE,
13
13
  STEP_FUNCTIONS_PRESETS,
package/dist/server.d.ts CHANGED
@@ -132,6 +132,12 @@ interface SqliteClient$2 {
132
132
  transaction<T>(fn: () => T): T;
133
133
  }
134
134
 
135
+ /**
136
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
137
+ * which derives the base from the wall clock when the runtime is created.
138
+ */
139
+ type IdBase$1 = number | string;
140
+
135
141
  /**
136
142
  * The single source of time for a service.
137
143
  *
@@ -214,6 +220,15 @@ type FaultRule$1 = {
214
220
  requestHeaders?: Record<string, string>;
215
221
  /** Fault only requests carrying these query parameters. `"*"` matches any value. */
216
222
  query?: Record<string, string>;
223
+ /**
224
+ * Fault only requests whose JSON body carries these fields. Each key is a dotted path into
225
+ * the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
226
+ * and each value is what the field must equal: a string, number, boolean or `null`, compared
227
+ * strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
228
+ * is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
229
+ * response a rule injects.
230
+ */
231
+ requestBody?: Record<string, RequestBodyValue$1>;
217
232
  /**
218
233
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
219
234
  * an in-process caller usually wants, and what a parallel worker usually does not:
@@ -280,6 +295,8 @@ type FaultRule$1 = {
280
295
  /** The preset this rule was expanded from, if any. */
281
296
  fromPreset?: string;
282
297
  };
298
+ /** What a field of the request body must equal in {@link FaultRule.requestBody}. */
299
+ type RequestBodyValue$1 = string | number | boolean | null;
283
300
  /** A fault that fired for one request. */
284
301
  type FaultHit$1 = {
285
302
  id: string;
@@ -304,6 +321,11 @@ type FaultCandidate$1 = {
304
321
  /** Request headers and query, for rules that match on them. */
305
322
  headers?: Headers;
306
323
  query?: URLSearchParams;
324
+ /**
325
+ * The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
326
+ * `undefined` for a body that is missing or not JSON. It must leave the request readable.
327
+ */
328
+ readJson?: () => Promise<unknown>;
307
329
  /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
308
330
  now?: number;
309
331
  /** How to spend a delay for this request. Default: the registry's own sleep. */
@@ -826,6 +848,12 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$1 & {
826
848
  mount(prefix: string): MountedAPI$1;
827
849
  readonly sqlite: SqliteClient$2;
828
850
  readonly clock: Clock$1;
851
+ /**
852
+ * Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
853
+ * return the number it resolved to. Set it before the first request so a boot's ids stay
854
+ * one run.
855
+ */
856
+ setIdBase(base: IdBase$1): number;
829
857
  readonly faults: FaultRegistry$1;
830
858
  /** Baseline response time per namespace. */
831
859
  readonly latency: LatencyRegistry$1;
@@ -931,6 +959,12 @@ type CommonServeOptions = {
931
959
  /** Synthetic provider fixture objects supplied by a fleet entry. */
932
960
  fixtures?: Record<string, unknown>;
933
961
  baseUrl?: string;
962
+ /**
963
+ * Boot settings from `--settings`, `MOCKINGBIRD_SETTINGS` or a fleet entry's `settings`,
964
+ * already checked by the target's {@link ServeTarget.parseSettings}. Pass them to the
965
+ * service's own `settings` option so they become every namespace's defaults.
966
+ */
967
+ settings?: Record<string, unknown>;
934
968
  };
935
969
  /**
936
970
  * What a service contributes to `serve`: how to build its runtime from CLI flags,
@@ -943,6 +977,13 @@ type ServeTarget = {
943
977
  defaultPort: number;
944
978
  /** Serve flags beyond the common ones. */
945
979
  options?: Record<string, CliOption>;
980
+ /**
981
+ * Check the boot settings a caller supplied (`--settings`, `MOCKINGBIRD_SETTINGS`, a fleet
982
+ * entry's `settings`) against the service's settings schema, returning them normalized
983
+ * or throwing a message naming the bad field. A target without one takes no boot settings,
984
+ * and supplying some is refused before a port is bound.
985
+ */
986
+ parseSettings?(settings: Record<string, unknown>): Record<string, unknown>;
946
987
  create(values: CliValues, common: CommonServeOptions): Promise<ServiceRuntime$1<ServiceInstance$1>> | ServiceRuntime$1<ServiceInstance$1>;
947
988
  /** Startup lines after the listen address, e.g. the loaded corpus version. */
948
989
  banner?(runtime: ServiceRuntime$1<ServiceInstance$1>): string[];
@@ -1124,9 +1165,15 @@ declare class Collection<T> {
1124
1165
  }>;
1125
1166
  }
1126
1167
 
1168
+ /**
1169
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
1170
+ * which derives the base from the wall clock when the runtime is created.
1171
+ */
1172
+ type IdBase = number | string;
1127
1173
  /**
1128
1174
  * Sequential id source persisted in SQLite. Ids are deterministic for a given
1129
1175
  * sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
1176
+ * A runtime's `idBase` is mixed in, so a different base reissues none of another's ids.
1130
1177
  */
1131
1178
  declare class IdSequence {
1132
1179
  private readonly sqlite;
@@ -1231,6 +1278,15 @@ type FaultRule = {
1231
1278
  requestHeaders?: Record<string, string>;
1232
1279
  /** Fault only requests carrying these query parameters. `"*"` matches any value. */
1233
1280
  query?: Record<string, string>;
1281
+ /**
1282
+ * Fault only requests whose JSON body carries these fields. Each key is a dotted path into
1283
+ * the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
1284
+ * and each value is what the field must equal: a string, number, boolean or `null`, compared
1285
+ * strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
1286
+ * is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
1287
+ * response a rule injects.
1288
+ */
1289
+ requestBody?: Record<string, RequestBodyValue>;
1234
1290
  /**
1235
1291
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
1236
1292
  * an in-process caller usually wants, and what a parallel worker usually does not:
@@ -1297,6 +1353,8 @@ type FaultRule = {
1297
1353
  /** The preset this rule was expanded from, if any. */
1298
1354
  fromPreset?: string;
1299
1355
  };
1356
+ /** What a field of the request body must equal in {@link FaultRule.requestBody}. */
1357
+ type RequestBodyValue = string | number | boolean | null;
1300
1358
  /** A fault that fired for one request. */
1301
1359
  type FaultHit = {
1302
1360
  id: string;
@@ -1321,6 +1379,11 @@ type FaultCandidate = {
1321
1379
  /** Request headers and query, for rules that match on them. */
1322
1380
  headers?: Headers;
1323
1381
  query?: URLSearchParams;
1382
+ /**
1383
+ * The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
1384
+ * `undefined` for a body that is missing or not JSON. It must leave the request readable.
1385
+ */
1386
+ readJson?: () => Promise<unknown>;
1324
1387
  /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
1325
1388
  now?: number;
1326
1389
  /** How to spend a delay for this request. Default: the registry's own sleep. */
@@ -1843,6 +1906,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
1843
1906
  mount(prefix: string): MountedAPI;
1844
1907
  readonly sqlite: SqliteClient$1;
1845
1908
  readonly clock: Clock;
1909
+ /**
1910
+ * Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
1911
+ * return the number it resolved to. Set it before the first request so a boot's ids stay
1912
+ * one run.
1913
+ */
1914
+ setIdBase(base: IdBase): number;
1846
1915
  readonly faults: FaultRegistry;
1847
1916
  /** Baseline response time per namespace. */
1848
1917
  readonly latency: LatencyRegistry;
package/dist/server.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  DEFAULT_PORT,
3
3
  createServer,
4
4
  serveTarget
5
- } from "./chunk-LSHC7AAT.js";
6
- import "./chunk-WM6TYPGJ.js";
5
+ } from "./chunk-RWOXKPES.js";
6
+ import "./chunk-3A5FTNZP.js";
7
7
  export {
8
8
  DEFAULT_PORT,
9
9
  createServer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-step-functions",
3
- "version": "3.5.0",
3
+ "version": "3.7.0",
4
4
  "description": "Stateful AWS Step Functions emulator with idempotent executions, callbacks, deterministic transitions, and history.",
5
5
  "license": "MIT",
6
6
  "type": "module",