@crvouga/mockingbird-service-resource-groups 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-SRVGZSIH.js → chunk-J6B2DZBX.js} +115 -15
- package/dist/chunk-J6B2DZBX.js.map +7 -0
- package/dist/{chunk-TOEIC3FK.js → chunk-NZ7TUWFA.js} +107 -23
- package/dist/chunk-NZ7TUWFA.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 +71 -0
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-SRVGZSIH.js.map +0 -7
- package/dist/chunk-TOEIC3FK.js.map +0 -7
package/dist/cli.js
CHANGED
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;
|
|
@@ -314,6 +320,15 @@ type FaultRule = {
|
|
|
314
320
|
requestHeaders?: Record<string, string>;
|
|
315
321
|
/** Fault only requests carrying these query parameters. `"*"` matches any value. */
|
|
316
322
|
query?: Record<string, string>;
|
|
323
|
+
/**
|
|
324
|
+
* Fault only requests whose JSON body carries these fields. Each key is a dotted path into
|
|
325
|
+
* the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
|
|
326
|
+
* and each value is what the field must equal: a string, number, boolean or `null`, compared
|
|
327
|
+
* strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
|
|
328
|
+
* is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
|
|
329
|
+
* response a rule injects.
|
|
330
|
+
*/
|
|
331
|
+
requestBody?: Record<string, RequestBodyValue>;
|
|
317
332
|
/**
|
|
318
333
|
* Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
|
|
319
334
|
* an in-process caller usually wants, and what a parallel worker usually does not:
|
|
@@ -380,6 +395,8 @@ type FaultRule = {
|
|
|
380
395
|
/** The preset this rule was expanded from, if any. */
|
|
381
396
|
fromPreset?: string;
|
|
382
397
|
};
|
|
398
|
+
/** What a field of the request body must equal in {@link FaultRule.requestBody}. */
|
|
399
|
+
type RequestBodyValue = string | number | boolean | null;
|
|
383
400
|
/** A fault that fired for one request. */
|
|
384
401
|
type FaultHit = {
|
|
385
402
|
id: string;
|
|
@@ -404,6 +421,11 @@ type FaultCandidate = {
|
|
|
404
421
|
/** Request headers and query, for rules that match on them. */
|
|
405
422
|
headers?: Headers;
|
|
406
423
|
query?: URLSearchParams;
|
|
424
|
+
/**
|
|
425
|
+
* The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
|
|
426
|
+
* `undefined` for a body that is missing or not JSON. It must leave the request readable.
|
|
427
|
+
*/
|
|
428
|
+
readJson?: () => Promise<unknown>;
|
|
407
429
|
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
408
430
|
now?: number;
|
|
409
431
|
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
@@ -926,6 +948,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
|
|
|
926
948
|
mount(prefix: string): MountedAPI;
|
|
927
949
|
readonly sqlite: SqliteClient$1;
|
|
928
950
|
readonly clock: Clock;
|
|
951
|
+
/**
|
|
952
|
+
* Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
|
|
953
|
+
* return the number it resolved to. Set it before the first request so a boot's ids stay
|
|
954
|
+
* one run.
|
|
955
|
+
*/
|
|
956
|
+
setIdBase(base: IdBase): number;
|
|
929
957
|
readonly faults: FaultRegistry;
|
|
930
958
|
/** Baseline response time per namespace. */
|
|
931
959
|
readonly latency: LatencyRegistry;
|
package/dist/index.js
CHANGED
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,7 +977,16 @@ 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>;
|
|
988
|
+
/** Largest request body the HTTP server accepts. Default 16 MiB. */
|
|
989
|
+
maxBodyBytes?: number;
|
|
947
990
|
/** Startup lines after the listen address, e.g. the loaded corpus version. */
|
|
948
991
|
banner?(runtime: ServiceRuntime$1<ServiceInstance$1>): string[];
|
|
949
992
|
/** After the HTTP server is bound. A service that speaks more than HTTP attaches it here. */
|
|
@@ -1124,9 +1167,15 @@ declare class Collection<T> {
|
|
|
1124
1167
|
}>;
|
|
1125
1168
|
}
|
|
1126
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;
|
|
1127
1175
|
/**
|
|
1128
1176
|
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
1129
1177
|
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
1178
|
+
* A runtime's `idBase` is mixed in, so a different base reissues none of another's ids.
|
|
1130
1179
|
*/
|
|
1131
1180
|
declare class IdSequence {
|
|
1132
1181
|
private readonly sqlite;
|
|
@@ -1266,6 +1315,15 @@ type FaultRule = {
|
|
|
1266
1315
|
requestHeaders?: Record<string, string>;
|
|
1267
1316
|
/** Fault only requests carrying these query parameters. `"*"` matches any value. */
|
|
1268
1317
|
query?: Record<string, string>;
|
|
1318
|
+
/**
|
|
1319
|
+
* Fault only requests whose JSON body carries these fields. Each key is a dotted path into
|
|
1320
|
+
* the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
|
|
1321
|
+
* and each value is what the field must equal: a string, number, boolean or `null`, compared
|
|
1322
|
+
* strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
|
|
1323
|
+
* is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
|
|
1324
|
+
* response a rule injects.
|
|
1325
|
+
*/
|
|
1326
|
+
requestBody?: Record<string, RequestBodyValue>;
|
|
1269
1327
|
/**
|
|
1270
1328
|
* Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
|
|
1271
1329
|
* an in-process caller usually wants, and what a parallel worker usually does not:
|
|
@@ -1332,6 +1390,8 @@ type FaultRule = {
|
|
|
1332
1390
|
/** The preset this rule was expanded from, if any. */
|
|
1333
1391
|
fromPreset?: string;
|
|
1334
1392
|
};
|
|
1393
|
+
/** What a field of the request body must equal in {@link FaultRule.requestBody}. */
|
|
1394
|
+
type RequestBodyValue = string | number | boolean | null;
|
|
1335
1395
|
/** A fault that fired for one request. */
|
|
1336
1396
|
type FaultHit = {
|
|
1337
1397
|
id: string;
|
|
@@ -1356,6 +1416,11 @@ type FaultCandidate = {
|
|
|
1356
1416
|
/** Request headers and query, for rules that match on them. */
|
|
1357
1417
|
headers?: Headers;
|
|
1358
1418
|
query?: URLSearchParams;
|
|
1419
|
+
/**
|
|
1420
|
+
* The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
|
|
1421
|
+
* `undefined` for a body that is missing or not JSON. It must leave the request readable.
|
|
1422
|
+
*/
|
|
1423
|
+
readJson?: () => Promise<unknown>;
|
|
1359
1424
|
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
1360
1425
|
now?: number;
|
|
1361
1426
|
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
@@ -1878,6 +1943,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
|
|
|
1878
1943
|
mount(prefix: string): MountedAPI;
|
|
1879
1944
|
readonly sqlite: SqliteClient$1;
|
|
1880
1945
|
readonly clock: Clock;
|
|
1946
|
+
/**
|
|
1947
|
+
* Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
|
|
1948
|
+
* return the number it resolved to. Set it before the first request so a boot's ids stay
|
|
1949
|
+
* one run.
|
|
1950
|
+
*/
|
|
1951
|
+
setIdBase(base: IdBase): number;
|
|
1881
1952
|
readonly faults: FaultRegistry;
|
|
1882
1953
|
/** Baseline response time per namespace. */
|
|
1883
1954
|
readonly latency: LatencyRegistry;
|
package/dist/server.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crvouga/mockingbird-service-resource-groups",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Stateful Amazon Resource Groups emulator with AWS SDK wire compatibility and deterministic local controls.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|