@crvouga/mockingbird-service-workos 1.4.0 → 1.6.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/CHANGELOG.md +13 -1
- package/dist/{chunk-JPFEQTV6.js → chunk-GRMUNXJH.js} +315 -51
- package/dist/chunk-GRMUNXJH.js.map +7 -0
- package/dist/{chunk-DW6XZF4X.js → chunk-MMXMGPOV.js} +107 -23
- package/dist/chunk-MMXMGPOV.js.map +7 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +28 -0
- package/dist/index.js +1 -1
- package/dist/server.d.ts +69 -0
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-DW6XZF4X.js.map +0 -7
- package/dist/chunk-JPFEQTV6.js.map +0 -7
package/dist/cli.js
CHANGED
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
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,6 +979,13 @@ 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>;
|
|
949
990
|
/** Startup lines after the listen address, e.g. the loaded corpus version. */
|
|
950
991
|
banner?(runtime: ServiceRuntime$1<ServiceInstance$1>): string[];
|
|
@@ -1126,6 +1167,12 @@ declare class Collection<T> {
|
|
|
1126
1167
|
}>;
|
|
1127
1168
|
}
|
|
1128
1169
|
|
|
1170
|
+
/**
|
|
1171
|
+
* What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
|
|
1172
|
+
* which derives the base from the wall clock when the runtime is created.
|
|
1173
|
+
*/
|
|
1174
|
+
type IdBase = number | string;
|
|
1175
|
+
|
|
1129
1176
|
/** Options every provider constructor accepts. */
|
|
1130
1177
|
type APIOptions = {
|
|
1131
1178
|
/** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
|
|
@@ -1221,6 +1268,15 @@ type FaultRule = {
|
|
|
1221
1268
|
requestHeaders?: Record<string, string>;
|
|
1222
1269
|
/** Fault only requests carrying these query parameters. `"*"` matches any value. */
|
|
1223
1270
|
query?: Record<string, string>;
|
|
1271
|
+
/**
|
|
1272
|
+
* Fault only requests whose JSON body carries these fields. Each key is a dotted path into
|
|
1273
|
+
* the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
|
|
1274
|
+
* and each value is what the field must equal: a string, number, boolean or `null`, compared
|
|
1275
|
+
* strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
|
|
1276
|
+
* is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
|
|
1277
|
+
* response a rule injects.
|
|
1278
|
+
*/
|
|
1279
|
+
requestBody?: Record<string, RequestBodyValue>;
|
|
1224
1280
|
/**
|
|
1225
1281
|
* Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
|
|
1226
1282
|
* an in-process caller usually wants, and what a parallel worker usually does not:
|
|
@@ -1287,6 +1343,8 @@ type FaultRule = {
|
|
|
1287
1343
|
/** The preset this rule was expanded from, if any. */
|
|
1288
1344
|
fromPreset?: string;
|
|
1289
1345
|
};
|
|
1346
|
+
/** What a field of the request body must equal in {@link FaultRule.requestBody}. */
|
|
1347
|
+
type RequestBodyValue = string | number | boolean | null;
|
|
1290
1348
|
/** A fault that fired for one request. */
|
|
1291
1349
|
type FaultHit = {
|
|
1292
1350
|
id: string;
|
|
@@ -1311,6 +1369,11 @@ type FaultCandidate = {
|
|
|
1311
1369
|
/** Request headers and query, for rules that match on them. */
|
|
1312
1370
|
headers?: Headers;
|
|
1313
1371
|
query?: URLSearchParams;
|
|
1372
|
+
/**
|
|
1373
|
+
* The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
|
|
1374
|
+
* `undefined` for a body that is missing or not JSON. It must leave the request readable.
|
|
1375
|
+
*/
|
|
1376
|
+
readJson?: () => Promise<unknown>;
|
|
1314
1377
|
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
1315
1378
|
now?: number;
|
|
1316
1379
|
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
@@ -1833,6 +1896,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
|
|
|
1833
1896
|
mount(prefix: string): MountedAPI;
|
|
1834
1897
|
readonly sqlite: SqliteClient$1;
|
|
1835
1898
|
readonly clock: Clock;
|
|
1899
|
+
/**
|
|
1900
|
+
* Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
|
|
1901
|
+
* return the number it resolved to. Set it before the first request so a boot's ids stay
|
|
1902
|
+
* one run.
|
|
1903
|
+
*/
|
|
1904
|
+
setIdBase(base: IdBase): number;
|
|
1836
1905
|
readonly faults: FaultRegistry;
|
|
1837
1906
|
/** Baseline response time per namespace. */
|
|
1838
1907
|
readonly latency: LatencyRegistry;
|
package/dist/server.js
CHANGED
package/package.json
CHANGED