@crvouga/mockingbird-service-workos 1.5.0 → 1.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-KPOYU6ZT.js";
7
- import "./chunk-DW6XZF4X.js";
6
+ } from "./chunk-4EWK2YQ2.js";
7
+ import "./chunk-MMXMGPOV.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -214,6 +214,12 @@ declare class Collection<T> {
214
214
  }>;
215
215
  }
216
216
 
217
+ /**
218
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
219
+ * which derives the base from the wall clock when the runtime is created.
220
+ */
221
+ type IdBase = number | string;
222
+
217
223
  /** Options every provider constructor accepts. */
218
224
  type APIOptions = {
219
225
  /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
@@ -309,6 +315,15 @@ type FaultRule = {
309
315
  requestHeaders?: Record<string, string>;
310
316
  /** Fault only requests carrying these query parameters. `"*"` matches any value. */
311
317
  query?: Record<string, string>;
318
+ /**
319
+ * Fault only requests whose JSON body carries these fields. Each key is a dotted path into
320
+ * the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
321
+ * and each value is what the field must equal: a string, number, boolean or `null`, compared
322
+ * strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
323
+ * is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
324
+ * response a rule injects.
325
+ */
326
+ requestBody?: Record<string, RequestBodyValue>;
312
327
  /**
313
328
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
314
329
  * an in-process caller usually wants, and what a parallel worker usually does not:
@@ -375,6 +390,8 @@ type FaultRule = {
375
390
  /** The preset this rule was expanded from, if any. */
376
391
  fromPreset?: string;
377
392
  };
393
+ /** What a field of the request body must equal in {@link FaultRule.requestBody}. */
394
+ type RequestBodyValue = string | number | boolean | null;
378
395
  /** A fault that fired for one request. */
379
396
  type FaultHit = {
380
397
  id: string;
@@ -412,6 +429,11 @@ type FaultCandidate = {
412
429
  /** Request headers and query, for rules that match on them. */
413
430
  headers?: Headers;
414
431
  query?: URLSearchParams;
432
+ /**
433
+ * The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
434
+ * `undefined` for a body that is missing or not JSON. It must leave the request readable.
435
+ */
436
+ readJson?: () => Promise<unknown>;
415
437
  /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
416
438
  now?: number;
417
439
  /** How to spend a delay for this request. Default: the registry's own sleep. */
@@ -934,6 +956,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
934
956
  mount(prefix: string): MountedAPI;
935
957
  readonly sqlite: SqliteClient;
936
958
  readonly clock: Clock;
959
+ /**
960
+ * Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
961
+ * return the number it resolved to. Set it before the first request so a boot's ids stay
962
+ * one run.
963
+ */
964
+ setIdBase(base: IdBase): number;
937
965
  readonly faults: FaultRegistry;
938
966
  /** Baseline response time per namespace. */
939
967
  readonly latency: LatencyRegistry;
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  document,
9
9
  operationIds,
10
10
  supportedOperationIds
11
- } from "./chunk-DW6XZF4X.js";
11
+ } from "./chunk-MMXMGPOV.js";
12
12
  export {
13
13
  DEFAULT_CLIENTS,
14
14
  DEFAULT_USERS,
package/dist/server.d.ts CHANGED
@@ -134,6 +134,12 @@ interface SqliteClient$2 {
134
134
  transaction<T>(fn: () => T): T;
135
135
  }
136
136
 
137
+ /**
138
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
139
+ * which derives the base from the wall clock when the runtime is created.
140
+ */
141
+ type IdBase$1 = number | string;
142
+
137
143
  /**
138
144
  * The single source of time for a service.
139
145
  *
@@ -216,6 +222,15 @@ type FaultRule$1 = {
216
222
  requestHeaders?: Record<string, string>;
217
223
  /** Fault only requests carrying these query parameters. `"*"` matches any value. */
218
224
  query?: Record<string, string>;
225
+ /**
226
+ * Fault only requests whose JSON body carries these fields. Each key is a dotted path into
227
+ * the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
228
+ * and each value is what the field must equal: a string, number, boolean or `null`, compared
229
+ * strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
230
+ * is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
231
+ * response a rule injects.
232
+ */
233
+ requestBody?: Record<string, RequestBodyValue$1>;
219
234
  /**
220
235
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
221
236
  * an in-process caller usually wants, and what a parallel worker usually does not:
@@ -282,6 +297,8 @@ type FaultRule$1 = {
282
297
  /** The preset this rule was expanded from, if any. */
283
298
  fromPreset?: string;
284
299
  };
300
+ /** What a field of the request body must equal in {@link FaultRule.requestBody}. */
301
+ type RequestBodyValue$1 = string | number | boolean | null;
285
302
  /** A fault that fired for one request. */
286
303
  type FaultHit$1 = {
287
304
  id: string;
@@ -306,6 +323,11 @@ type FaultCandidate$1 = {
306
323
  /** Request headers and query, for rules that match on them. */
307
324
  headers?: Headers;
308
325
  query?: URLSearchParams;
326
+ /**
327
+ * The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
328
+ * `undefined` for a body that is missing or not JSON. It must leave the request readable.
329
+ */
330
+ readJson?: () => Promise<unknown>;
309
331
  /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
310
332
  now?: number;
311
333
  /** How to spend a delay for this request. Default: the registry's own sleep. */
@@ -828,6 +850,12 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$2 & {
828
850
  mount(prefix: string): MountedAPI$1;
829
851
  readonly sqlite: SqliteClient$2;
830
852
  readonly clock: Clock$1;
853
+ /**
854
+ * Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
855
+ * return the number it resolved to. Set it before the first request so a boot's ids stay
856
+ * one run.
857
+ */
858
+ setIdBase(base: IdBase$1): number;
831
859
  readonly faults: FaultRegistry$1;
832
860
  /** Baseline response time per namespace. */
833
861
  readonly latency: LatencyRegistry$1;
@@ -933,6 +961,12 @@ type CommonServeOptions = {
933
961
  /** Synthetic provider fixture objects supplied by a fleet entry. */
934
962
  fixtures?: Record<string, unknown>;
935
963
  baseUrl?: string;
964
+ /**
965
+ * Boot settings from `--settings`, `MOCKINGBIRD_SETTINGS` or a fleet entry's `settings`,
966
+ * already checked by the target's {@link ServeTarget.parseSettings}. Pass them to the
967
+ * service's own `settings` option so they become every namespace's defaults.
968
+ */
969
+ settings?: Record<string, unknown>;
936
970
  };
937
971
  /**
938
972
  * What a service contributes to `serve`: how to build its runtime from CLI flags,
@@ -945,7 +979,16 @@ type ServeTarget = {
945
979
  defaultPort: number;
946
980
  /** Serve flags beyond the common ones. */
947
981
  options?: Record<string, CliOption>;
982
+ /**
983
+ * Check the boot settings a caller supplied (`--settings`, `MOCKINGBIRD_SETTINGS`, a fleet
984
+ * entry's `settings`) against the service's settings schema, returning them normalized
985
+ * or throwing a message naming the bad field. A target without one takes no boot settings,
986
+ * and supplying some is refused before a port is bound.
987
+ */
988
+ parseSettings?(settings: Record<string, unknown>): Record<string, unknown>;
948
989
  create(values: CliValues, common: CommonServeOptions): Promise<ServiceRuntime$1<ServiceInstance$1>> | ServiceRuntime$1<ServiceInstance$1>;
990
+ /** Largest request body the HTTP server accepts. Default 16 MiB. */
991
+ maxBodyBytes?: number;
949
992
  /** Startup lines after the listen address, e.g. the loaded corpus version. */
950
993
  banner?(runtime: ServiceRuntime$1<ServiceInstance$1>): string[];
951
994
  /** After the HTTP server is bound. A service that speaks more than HTTP attaches it here. */
@@ -1126,6 +1169,12 @@ declare class Collection<T> {
1126
1169
  }>;
1127
1170
  }
1128
1171
 
1172
+ /**
1173
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
1174
+ * which derives the base from the wall clock when the runtime is created.
1175
+ */
1176
+ type IdBase = number | string;
1177
+
1129
1178
  /** Options every provider constructor accepts. */
1130
1179
  type APIOptions = {
1131
1180
  /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
@@ -1221,6 +1270,15 @@ type FaultRule = {
1221
1270
  requestHeaders?: Record<string, string>;
1222
1271
  /** Fault only requests carrying these query parameters. `"*"` matches any value. */
1223
1272
  query?: Record<string, string>;
1273
+ /**
1274
+ * Fault only requests whose JSON body carries these fields. Each key is a dotted path into
1275
+ * the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
1276
+ * and each value is what the field must equal: a string, number, boolean or `null`, compared
1277
+ * strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
1278
+ * is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
1279
+ * response a rule injects.
1280
+ */
1281
+ requestBody?: Record<string, RequestBodyValue>;
1224
1282
  /**
1225
1283
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
1226
1284
  * an in-process caller usually wants, and what a parallel worker usually does not:
@@ -1287,6 +1345,8 @@ type FaultRule = {
1287
1345
  /** The preset this rule was expanded from, if any. */
1288
1346
  fromPreset?: string;
1289
1347
  };
1348
+ /** What a field of the request body must equal in {@link FaultRule.requestBody}. */
1349
+ type RequestBodyValue = string | number | boolean | null;
1290
1350
  /** A fault that fired for one request. */
1291
1351
  type FaultHit = {
1292
1352
  id: string;
@@ -1311,6 +1371,11 @@ type FaultCandidate = {
1311
1371
  /** Request headers and query, for rules that match on them. */
1312
1372
  headers?: Headers;
1313
1373
  query?: URLSearchParams;
1374
+ /**
1375
+ * The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
1376
+ * `undefined` for a body that is missing or not JSON. It must leave the request readable.
1377
+ */
1378
+ readJson?: () => Promise<unknown>;
1314
1379
  /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
1315
1380
  now?: number;
1316
1381
  /** How to spend a delay for this request. Default: the registry's own sleep. */
@@ -1833,6 +1898,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
1833
1898
  mount(prefix: string): MountedAPI;
1834
1899
  readonly sqlite: SqliteClient$1;
1835
1900
  readonly clock: Clock;
1901
+ /**
1902
+ * Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
1903
+ * return the number it resolved to. Set it before the first request so a boot's ids stay
1904
+ * one run.
1905
+ */
1906
+ setIdBase(base: IdBase): number;
1836
1907
  readonly faults: FaultRegistry;
1837
1908
  /** Baseline response time per namespace. */
1838
1909
  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-KPOYU6ZT.js";
6
- import "./chunk-DW6XZF4X.js";
5
+ } from "./chunk-4EWK2YQ2.js";
6
+ import "./chunk-MMXMGPOV.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-workos",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Stateful WorkOS AuthKit emulator with signed sessions, rotating refresh tokens and user pagination.",
5
5
  "license": "MIT",
6
6
  "type": "module",