@crvouga/mockingbird-service-microsoft 0.5.0 → 0.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 +7 -1
- package/dist/{chunk-4QU43IJC.js → chunk-4IBFJADE.js} +103 -12
- package/dist/chunk-4IBFJADE.js.map +7 -0
- package/dist/{chunk-2S244VQQ.js → chunk-T2ZALRB4.js} +109 -26
- package/dist/chunk-T2ZALRB4.js.map +7 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +35 -0
- package/dist/index.js +1 -1
- package/dist/server.d.ts +76 -0
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-2S244VQQ.js.map +0 -7
- package/dist/chunk-4QU43IJC.js.map +0 -7
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -751,6 +751,12 @@ interface SqliteClient {
|
|
|
751
751
|
transaction<T>(fn: () => T): T;
|
|
752
752
|
}
|
|
753
753
|
|
|
754
|
+
/**
|
|
755
|
+
* What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
|
|
756
|
+
* which derives the base from the wall clock when the runtime is created.
|
|
757
|
+
*/
|
|
758
|
+
type IdBase = number | string;
|
|
759
|
+
|
|
754
760
|
/**
|
|
755
761
|
* The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
|
|
756
762
|
* Unknown keys (including `x-*` extensions) are preserved on every object.
|
|
@@ -998,6 +1004,15 @@ type FaultRule = {
|
|
|
998
1004
|
requestHeaders?: Record<string, string>;
|
|
999
1005
|
/** Fault only requests carrying these query parameters. `"*"` matches any value. */
|
|
1000
1006
|
query?: Record<string, string>;
|
|
1007
|
+
/**
|
|
1008
|
+
* Fault only requests whose JSON body carries these fields. Each key is a dotted path into
|
|
1009
|
+
* the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
|
|
1010
|
+
* and each value is what the field must equal: a string, number, boolean or `null`, compared
|
|
1011
|
+
* strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
|
|
1012
|
+
* is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
|
|
1013
|
+
* response a rule injects.
|
|
1014
|
+
*/
|
|
1015
|
+
requestBody?: Record<string, RequestBodyValue>;
|
|
1001
1016
|
/**
|
|
1002
1017
|
* Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
|
|
1003
1018
|
* an in-process caller usually wants, and what a parallel worker usually does not:
|
|
@@ -1064,6 +1079,8 @@ type FaultRule = {
|
|
|
1064
1079
|
/** The preset this rule was expanded from, if any. */
|
|
1065
1080
|
fromPreset?: string;
|
|
1066
1081
|
};
|
|
1082
|
+
/** What a field of the request body must equal in {@link FaultRule.requestBody}. */
|
|
1083
|
+
type RequestBodyValue = string | number | boolean | null;
|
|
1067
1084
|
/** A fault that fired for one request. */
|
|
1068
1085
|
type FaultHit = {
|
|
1069
1086
|
id: string;
|
|
@@ -1101,6 +1118,11 @@ type FaultCandidate = {
|
|
|
1101
1118
|
/** Request headers and query, for rules that match on them. */
|
|
1102
1119
|
headers?: Headers;
|
|
1103
1120
|
query?: URLSearchParams;
|
|
1121
|
+
/**
|
|
1122
|
+
* The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
|
|
1123
|
+
* `undefined` for a body that is missing or not JSON. It must leave the request readable.
|
|
1124
|
+
*/
|
|
1125
|
+
readJson?: () => Promise<unknown>;
|
|
1104
1126
|
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
1105
1127
|
now?: number;
|
|
1106
1128
|
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
@@ -1713,6 +1735,13 @@ type RuntimeOptions<T extends ServiceInstance> = {
|
|
|
1713
1735
|
sqlite?: SqliteClient;
|
|
1714
1736
|
/** Defaults to a live clock over `Date.now`. */
|
|
1715
1737
|
clock?: Clock;
|
|
1738
|
+
/**
|
|
1739
|
+
* Where this boot's generated ids start. Counters restart at 0 on every boot, so by default
|
|
1740
|
+
* every boot reissues the previous boot's ids; a different base gives an unrelated run of ids
|
|
1741
|
+
* (a reset returns to the same run). A non-negative integer, or `"boot"` for one derived from
|
|
1742
|
+
* the wall clock when the runtime is created. Default `0`: the same ids on every boot.
|
|
1743
|
+
*/
|
|
1744
|
+
idBase?: IdBase;
|
|
1716
1745
|
/** Seeds every random choice the runtime makes (fault rates, jitter). Default `0`. */
|
|
1717
1746
|
seed?: number | string;
|
|
1718
1747
|
/**
|
|
@@ -1796,6 +1825,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
|
|
|
1796
1825
|
mount(prefix: string): MountedAPI;
|
|
1797
1826
|
readonly sqlite: SqliteClient;
|
|
1798
1827
|
readonly clock: Clock;
|
|
1828
|
+
/**
|
|
1829
|
+
* Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
|
|
1830
|
+
* return the number it resolved to. Set it before the first request so a boot's ids stay
|
|
1831
|
+
* one run.
|
|
1832
|
+
*/
|
|
1833
|
+
setIdBase(base: IdBase): number;
|
|
1799
1834
|
readonly faults: FaultRegistry;
|
|
1800
1835
|
/** Baseline response time per namespace. */
|
|
1801
1836
|
readonly latency: LatencyRegistry;
|
package/dist/index.js
CHANGED
package/dist/server.d.ts
CHANGED
|
@@ -132,6 +132,12 @@ interface SqliteClient$3 {
|
|
|
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$3;
|
|
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[];
|
|
@@ -1082,6 +1123,12 @@ interface SqliteClient$2 {
|
|
|
1082
1123
|
transaction<T>(fn: () => T): T;
|
|
1083
1124
|
}
|
|
1084
1125
|
|
|
1126
|
+
/**
|
|
1127
|
+
* What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
|
|
1128
|
+
* which derives the base from the wall clock when the runtime is created.
|
|
1129
|
+
*/
|
|
1130
|
+
type IdBase = number | string;
|
|
1131
|
+
|
|
1085
1132
|
/**
|
|
1086
1133
|
* The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
|
|
1087
1134
|
* Unknown keys (including `x-*` extensions) are preserved on every object.
|
|
@@ -1329,6 +1376,15 @@ type FaultRule = {
|
|
|
1329
1376
|
requestHeaders?: Record<string, string>;
|
|
1330
1377
|
/** Fault only requests carrying these query parameters. `"*"` matches any value. */
|
|
1331
1378
|
query?: Record<string, string>;
|
|
1379
|
+
/**
|
|
1380
|
+
* Fault only requests whose JSON body carries these fields. Each key is a dotted path into
|
|
1381
|
+
* the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
|
|
1382
|
+
* and each value is what the field must equal: a string, number, boolean or `null`, compared
|
|
1383
|
+
* strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
|
|
1384
|
+
* is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
|
|
1385
|
+
* response a rule injects.
|
|
1386
|
+
*/
|
|
1387
|
+
requestBody?: Record<string, RequestBodyValue>;
|
|
1332
1388
|
/**
|
|
1333
1389
|
* Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
|
|
1334
1390
|
* an in-process caller usually wants, and what a parallel worker usually does not:
|
|
@@ -1395,6 +1451,8 @@ type FaultRule = {
|
|
|
1395
1451
|
/** The preset this rule was expanded from, if any. */
|
|
1396
1452
|
fromPreset?: string;
|
|
1397
1453
|
};
|
|
1454
|
+
/** What a field of the request body must equal in {@link FaultRule.requestBody}. */
|
|
1455
|
+
type RequestBodyValue = string | number | boolean | null;
|
|
1398
1456
|
/** A fault that fired for one request. */
|
|
1399
1457
|
type FaultHit = {
|
|
1400
1458
|
id: string;
|
|
@@ -1432,6 +1490,11 @@ type FaultCandidate = {
|
|
|
1432
1490
|
/** Request headers and query, for rules that match on them. */
|
|
1433
1491
|
headers?: Headers;
|
|
1434
1492
|
query?: URLSearchParams;
|
|
1493
|
+
/**
|
|
1494
|
+
* The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
|
|
1495
|
+
* `undefined` for a body that is missing or not JSON. It must leave the request readable.
|
|
1496
|
+
*/
|
|
1497
|
+
readJson?: () => Promise<unknown>;
|
|
1435
1498
|
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
1436
1499
|
now?: number;
|
|
1437
1500
|
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
@@ -2044,6 +2107,13 @@ type RuntimeOptions<T extends ServiceInstance> = {
|
|
|
2044
2107
|
sqlite?: SqliteClient$2;
|
|
2045
2108
|
/** Defaults to a live clock over `Date.now`. */
|
|
2046
2109
|
clock?: Clock;
|
|
2110
|
+
/**
|
|
2111
|
+
* Where this boot's generated ids start. Counters restart at 0 on every boot, so by default
|
|
2112
|
+
* every boot reissues the previous boot's ids; a different base gives an unrelated run of ids
|
|
2113
|
+
* (a reset returns to the same run). A non-negative integer, or `"boot"` for one derived from
|
|
2114
|
+
* the wall clock when the runtime is created. Default `0`: the same ids on every boot.
|
|
2115
|
+
*/
|
|
2116
|
+
idBase?: IdBase;
|
|
2047
2117
|
/** Seeds every random choice the runtime makes (fault rates, jitter). Default `0`. */
|
|
2048
2118
|
seed?: number | string;
|
|
2049
2119
|
/**
|
|
@@ -2127,6 +2197,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
|
|
|
2127
2197
|
mount(prefix: string): MountedAPI;
|
|
2128
2198
|
readonly sqlite: SqliteClient$2;
|
|
2129
2199
|
readonly clock: Clock;
|
|
2200
|
+
/**
|
|
2201
|
+
* Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
|
|
2202
|
+
* return the number it resolved to. Set it before the first request so a boot's ids stay
|
|
2203
|
+
* one run.
|
|
2204
|
+
*/
|
|
2205
|
+
setIdBase(base: IdBase): number;
|
|
2130
2206
|
readonly faults: FaultRegistry;
|
|
2131
2207
|
/** Baseline response time per namespace. */
|
|
2132
2208
|
readonly latency: LatencyRegistry;
|
package/dist/server.js
CHANGED
package/package.json
CHANGED