@crvouga/mockingbird-service-docker 1.6.0 → 1.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/CHANGELOG.md +13 -1
- package/dist/{chunk-DG4KWFV5.js → chunk-2VTSZWES.js} +2 -2
- package/dist/{chunk-PEU54Q4H.js → chunk-7DDFNYJE.js} +115 -31
- package/dist/chunk-7DDFNYJE.js.map +7 -0
- package/dist/cli.js +115 -15
- package/dist/cli.js.map +3 -3
- package/dist/index.d.ts +35 -0
- package/dist/index.js +1 -1
- package/dist/server.d.ts +78 -0
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-PEU54Q4H.js.map +0 -7
- /package/dist/{chunk-DG4KWFV5.js.map → chunk-2VTSZWES.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -184,6 +184,12 @@ 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;
|
|
192
|
+
|
|
187
193
|
/**
|
|
188
194
|
* The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
|
|
189
195
|
* Unknown keys (including `x-*` extensions) are preserved on every object.
|
|
@@ -444,6 +450,15 @@ type FaultRule = {
|
|
|
444
450
|
requestHeaders?: Record<string, string>;
|
|
445
451
|
/** Fault only requests carrying these query parameters. `"*"` matches any value. */
|
|
446
452
|
query?: Record<string, string>;
|
|
453
|
+
/**
|
|
454
|
+
* Fault only requests whose JSON body carries these fields. Each key is a dotted path into
|
|
455
|
+
* the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
|
|
456
|
+
* and each value is what the field must equal: a string, number, boolean or `null`, compared
|
|
457
|
+
* strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
|
|
458
|
+
* is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
|
|
459
|
+
* response a rule injects.
|
|
460
|
+
*/
|
|
461
|
+
requestBody?: Record<string, RequestBodyValue>;
|
|
447
462
|
/**
|
|
448
463
|
* Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
|
|
449
464
|
* an in-process caller usually wants, and what a parallel worker usually does not:
|
|
@@ -510,6 +525,8 @@ type FaultRule = {
|
|
|
510
525
|
/** The preset this rule was expanded from, if any. */
|
|
511
526
|
fromPreset?: string;
|
|
512
527
|
};
|
|
528
|
+
/** What a field of the request body must equal in {@link FaultRule.requestBody}. */
|
|
529
|
+
type RequestBodyValue = string | number | boolean | null;
|
|
513
530
|
/** A fault that fired for one request. */
|
|
514
531
|
type FaultHit = {
|
|
515
532
|
id: string;
|
|
@@ -547,6 +564,11 @@ type FaultCandidate = {
|
|
|
547
564
|
/** Request headers and query, for rules that match on them. */
|
|
548
565
|
headers?: Headers;
|
|
549
566
|
query?: URLSearchParams;
|
|
567
|
+
/**
|
|
568
|
+
* The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
|
|
569
|
+
* `undefined` for a body that is missing or not JSON. It must leave the request readable.
|
|
570
|
+
*/
|
|
571
|
+
readJson?: () => Promise<unknown>;
|
|
550
572
|
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
551
573
|
now?: number;
|
|
552
574
|
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
@@ -1159,6 +1181,13 @@ type RuntimeOptions<T extends ServiceInstance> = {
|
|
|
1159
1181
|
sqlite?: SqliteClient$1;
|
|
1160
1182
|
/** Defaults to a live clock over `Date.now`. */
|
|
1161
1183
|
clock?: Clock;
|
|
1184
|
+
/**
|
|
1185
|
+
* Where this boot's generated ids start. Counters restart at 0 on every boot, so by default
|
|
1186
|
+
* every boot reissues the previous boot's ids; a different base gives an unrelated run of ids
|
|
1187
|
+
* (a reset returns to the same run). A non-negative integer, or `"boot"` for one derived from
|
|
1188
|
+
* the wall clock when the runtime is created. Default `0`: the same ids on every boot.
|
|
1189
|
+
*/
|
|
1190
|
+
idBase?: IdBase;
|
|
1162
1191
|
/** Seeds every random choice the runtime makes (fault rates, jitter). Default `0`. */
|
|
1163
1192
|
seed?: number | string;
|
|
1164
1193
|
/**
|
|
@@ -1242,6 +1271,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
|
|
|
1242
1271
|
mount(prefix: string): MountedAPI;
|
|
1243
1272
|
readonly sqlite: SqliteClient$1;
|
|
1244
1273
|
readonly clock: Clock;
|
|
1274
|
+
/**
|
|
1275
|
+
* Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
|
|
1276
|
+
* return the number it resolved to. Set it before the first request so a boot's ids stay
|
|
1277
|
+
* one run.
|
|
1278
|
+
*/
|
|
1279
|
+
setIdBase(base: IdBase): number;
|
|
1245
1280
|
readonly faults: FaultRegistry;
|
|
1246
1281
|
/** Baseline response time per namespace. */
|
|
1247
1282
|
readonly latency: LatencyRegistry;
|
package/dist/index.js
CHANGED
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. */
|
|
@@ -1135,6 +1178,12 @@ declare class Collection<T> {
|
|
|
1135
1178
|
}>;
|
|
1136
1179
|
}
|
|
1137
1180
|
|
|
1181
|
+
/**
|
|
1182
|
+
* What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
|
|
1183
|
+
* which derives the base from the wall clock when the runtime is created.
|
|
1184
|
+
*/
|
|
1185
|
+
type IdBase = number | string;
|
|
1186
|
+
|
|
1138
1187
|
/**
|
|
1139
1188
|
* The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
|
|
1140
1189
|
* Unknown keys (including `x-*` extensions) are preserved on every object.
|
|
@@ -1395,6 +1444,15 @@ type FaultRule = {
|
|
|
1395
1444
|
requestHeaders?: Record<string, string>;
|
|
1396
1445
|
/** Fault only requests carrying these query parameters. `"*"` matches any value. */
|
|
1397
1446
|
query?: Record<string, string>;
|
|
1447
|
+
/**
|
|
1448
|
+
* Fault only requests whose JSON body carries these fields. Each key is a dotted path into
|
|
1449
|
+
* the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
|
|
1450
|
+
* and each value is what the field must equal: a string, number, boolean or `null`, compared
|
|
1451
|
+
* strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
|
|
1452
|
+
* is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
|
|
1453
|
+
* response a rule injects.
|
|
1454
|
+
*/
|
|
1455
|
+
requestBody?: Record<string, RequestBodyValue>;
|
|
1398
1456
|
/**
|
|
1399
1457
|
* Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
|
|
1400
1458
|
* an in-process caller usually wants, and what a parallel worker usually does not:
|
|
@@ -1461,6 +1519,8 @@ type FaultRule = {
|
|
|
1461
1519
|
/** The preset this rule was expanded from, if any. */
|
|
1462
1520
|
fromPreset?: string;
|
|
1463
1521
|
};
|
|
1522
|
+
/** What a field of the request body must equal in {@link FaultRule.requestBody}. */
|
|
1523
|
+
type RequestBodyValue = string | number | boolean | null;
|
|
1464
1524
|
/** A fault that fired for one request. */
|
|
1465
1525
|
type FaultHit = {
|
|
1466
1526
|
id: string;
|
|
@@ -1498,6 +1558,11 @@ type FaultCandidate = {
|
|
|
1498
1558
|
/** Request headers and query, for rules that match on them. */
|
|
1499
1559
|
headers?: Headers;
|
|
1500
1560
|
query?: URLSearchParams;
|
|
1561
|
+
/**
|
|
1562
|
+
* The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
|
|
1563
|
+
* `undefined` for a body that is missing or not JSON. It must leave the request readable.
|
|
1564
|
+
*/
|
|
1565
|
+
readJson?: () => Promise<unknown>;
|
|
1501
1566
|
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
1502
1567
|
now?: number;
|
|
1503
1568
|
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
@@ -2110,6 +2175,13 @@ type RuntimeOptions<T extends ServiceInstance> = {
|
|
|
2110
2175
|
sqlite?: SqliteClient$1;
|
|
2111
2176
|
/** Defaults to a live clock over `Date.now`. */
|
|
2112
2177
|
clock?: Clock;
|
|
2178
|
+
/**
|
|
2179
|
+
* Where this boot's generated ids start. Counters restart at 0 on every boot, so by default
|
|
2180
|
+
* every boot reissues the previous boot's ids; a different base gives an unrelated run of ids
|
|
2181
|
+
* (a reset returns to the same run). A non-negative integer, or `"boot"` for one derived from
|
|
2182
|
+
* the wall clock when the runtime is created. Default `0`: the same ids on every boot.
|
|
2183
|
+
*/
|
|
2184
|
+
idBase?: IdBase;
|
|
2113
2185
|
/** Seeds every random choice the runtime makes (fault rates, jitter). Default `0`. */
|
|
2114
2186
|
seed?: number | string;
|
|
2115
2187
|
/**
|
|
@@ -2193,6 +2265,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
|
|
|
2193
2265
|
mount(prefix: string): MountedAPI;
|
|
2194
2266
|
readonly sqlite: SqliteClient$1;
|
|
2195
2267
|
readonly clock: Clock;
|
|
2268
|
+
/**
|
|
2269
|
+
* Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
|
|
2270
|
+
* return the number it resolved to. Set it before the first request so a boot's ids stay
|
|
2271
|
+
* one run.
|
|
2272
|
+
*/
|
|
2273
|
+
setIdBase(base: IdBase): number;
|
|
2196
2274
|
readonly faults: FaultRegistry;
|
|
2197
2275
|
/** Baseline response time per namespace. */
|
|
2198
2276
|
readonly latency: LatencyRegistry;
|
package/dist/server.js
CHANGED
package/package.json
CHANGED