@crvouga/mockingbird-service-google 0.5.0 → 0.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-24NJ7GVW.js";
7
- import "./chunk-PF2EJVUZ.js";
6
+ } from "./chunk-QQK5BNRP.js";
7
+ import "./chunk-ZFHZ4LGF.js";
8
8
  import "./chunk-6Z2MR3PO.js";
9
9
 
10
10
  // src/cli.ts
package/dist/index.d.ts CHANGED
@@ -832,6 +832,12 @@ interface SqliteClient {
832
832
  transaction<T>(fn: () => T): T;
833
833
  }
834
834
 
835
+ /**
836
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
837
+ * which derives the base from the wall clock when the runtime is created.
838
+ */
839
+ type IdBase = number | string;
840
+
835
841
  /**
836
842
  * The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
837
843
  * Unknown keys (including `x-*` extensions) are preserved on every object.
@@ -1079,6 +1085,15 @@ type FaultRule = {
1079
1085
  requestHeaders?: Record<string, string>;
1080
1086
  /** Fault only requests carrying these query parameters. `"*"` matches any value. */
1081
1087
  query?: Record<string, string>;
1088
+ /**
1089
+ * Fault only requests whose JSON body carries these fields. Each key is a dotted path into
1090
+ * the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
1091
+ * and each value is what the field must equal: a string, number, boolean or `null`, compared
1092
+ * strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
1093
+ * is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
1094
+ * response a rule injects.
1095
+ */
1096
+ requestBody?: Record<string, RequestBodyValue>;
1082
1097
  /**
1083
1098
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
1084
1099
  * an in-process caller usually wants, and what a parallel worker usually does not:
@@ -1145,6 +1160,8 @@ type FaultRule = {
1145
1160
  /** The preset this rule was expanded from, if any. */
1146
1161
  fromPreset?: string;
1147
1162
  };
1163
+ /** What a field of the request body must equal in {@link FaultRule.requestBody}. */
1164
+ type RequestBodyValue = string | number | boolean | null;
1148
1165
  /** A fault that fired for one request. */
1149
1166
  type FaultHit = {
1150
1167
  id: string;
@@ -1182,6 +1199,11 @@ type FaultCandidate = {
1182
1199
  /** Request headers and query, for rules that match on them. */
1183
1200
  headers?: Headers;
1184
1201
  query?: URLSearchParams;
1202
+ /**
1203
+ * The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
1204
+ * `undefined` for a body that is missing or not JSON. It must leave the request readable.
1205
+ */
1206
+ readJson?: () => Promise<unknown>;
1185
1207
  /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
1186
1208
  now?: number;
1187
1209
  /** How to spend a delay for this request. Default: the registry's own sleep. */
@@ -1794,6 +1816,13 @@ type RuntimeOptions<T extends ServiceInstance> = {
1794
1816
  sqlite?: SqliteClient;
1795
1817
  /** Defaults to a live clock over `Date.now`. */
1796
1818
  clock?: Clock;
1819
+ /**
1820
+ * Where this boot's generated ids start. Counters restart at 0 on every boot, so by default
1821
+ * every boot reissues the previous boot's ids; a different base gives an unrelated run of ids
1822
+ * (a reset returns to the same run). A non-negative integer, or `"boot"` for one derived from
1823
+ * the wall clock when the runtime is created. Default `0`: the same ids on every boot.
1824
+ */
1825
+ idBase?: IdBase;
1797
1826
  /** Seeds every random choice the runtime makes (fault rates, jitter). Default `0`. */
1798
1827
  seed?: number | string;
1799
1828
  /**
@@ -1877,6 +1906,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
1877
1906
  mount(prefix: string): MountedAPI;
1878
1907
  readonly sqlite: SqliteClient;
1879
1908
  readonly clock: Clock;
1909
+ /**
1910
+ * Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
1911
+ * return the number it resolved to. Set it before the first request so a boot's ids stay
1912
+ * one run.
1913
+ */
1914
+ setIdBase(base: IdBase): number;
1880
1915
  readonly faults: FaultRegistry;
1881
1916
  /** Baseline response time per namespace. */
1882
1917
  readonly latency: LatencyRegistry;
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  document,
6
6
  operationIds,
7
7
  supportedOperationIds
8
- } from "./chunk-PF2EJVUZ.js";
8
+ } from "./chunk-ZFHZ4LGF.js";
9
9
  import "./chunk-6Z2MR3PO.js";
10
10
  export {
11
11
  GOOGLE_NAMESPACE,
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,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. */
@@ -1082,6 +1125,12 @@ interface SqliteClient$2 {
1082
1125
  transaction<T>(fn: () => T): T;
1083
1126
  }
1084
1127
 
1128
+ /**
1129
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
1130
+ * which derives the base from the wall clock when the runtime is created.
1131
+ */
1132
+ type IdBase = number | string;
1133
+
1085
1134
  /**
1086
1135
  * The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
1087
1136
  * Unknown keys (including `x-*` extensions) are preserved on every object.
@@ -1329,6 +1378,15 @@ type FaultRule = {
1329
1378
  requestHeaders?: Record<string, string>;
1330
1379
  /** Fault only requests carrying these query parameters. `"*"` matches any value. */
1331
1380
  query?: Record<string, string>;
1381
+ /**
1382
+ * Fault only requests whose JSON body carries these fields. Each key is a dotted path into
1383
+ * the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
1384
+ * and each value is what the field must equal: a string, number, boolean or `null`, compared
1385
+ * strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
1386
+ * is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
1387
+ * response a rule injects.
1388
+ */
1389
+ requestBody?: Record<string, RequestBodyValue>;
1332
1390
  /**
1333
1391
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
1334
1392
  * an in-process caller usually wants, and what a parallel worker usually does not:
@@ -1395,6 +1453,8 @@ type FaultRule = {
1395
1453
  /** The preset this rule was expanded from, if any. */
1396
1454
  fromPreset?: string;
1397
1455
  };
1456
+ /** What a field of the request body must equal in {@link FaultRule.requestBody}. */
1457
+ type RequestBodyValue = string | number | boolean | null;
1398
1458
  /** A fault that fired for one request. */
1399
1459
  type FaultHit = {
1400
1460
  id: string;
@@ -1432,6 +1492,11 @@ type FaultCandidate = {
1432
1492
  /** Request headers and query, for rules that match on them. */
1433
1493
  headers?: Headers;
1434
1494
  query?: URLSearchParams;
1495
+ /**
1496
+ * The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
1497
+ * `undefined` for a body that is missing or not JSON. It must leave the request readable.
1498
+ */
1499
+ readJson?: () => Promise<unknown>;
1435
1500
  /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
1436
1501
  now?: number;
1437
1502
  /** How to spend a delay for this request. Default: the registry's own sleep. */
@@ -2044,6 +2109,13 @@ type RuntimeOptions<T extends ServiceInstance> = {
2044
2109
  sqlite?: SqliteClient$2;
2045
2110
  /** Defaults to a live clock over `Date.now`. */
2046
2111
  clock?: Clock;
2112
+ /**
2113
+ * Where this boot's generated ids start. Counters restart at 0 on every boot, so by default
2114
+ * every boot reissues the previous boot's ids; a different base gives an unrelated run of ids
2115
+ * (a reset returns to the same run). A non-negative integer, or `"boot"` for one derived from
2116
+ * the wall clock when the runtime is created. Default `0`: the same ids on every boot.
2117
+ */
2118
+ idBase?: IdBase;
2047
2119
  /** Seeds every random choice the runtime makes (fault rates, jitter). Default `0`. */
2048
2120
  seed?: number | string;
2049
2121
  /**
@@ -2127,6 +2199,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
2127
2199
  mount(prefix: string): MountedAPI;
2128
2200
  readonly sqlite: SqliteClient$2;
2129
2201
  readonly clock: Clock;
2202
+ /**
2203
+ * Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
2204
+ * return the number it resolved to. Set it before the first request so a boot's ids stay
2205
+ * one run.
2206
+ */
2207
+ setIdBase(base: IdBase): number;
2130
2208
  readonly faults: FaultRegistry;
2131
2209
  /** Baseline response time per namespace. */
2132
2210
  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-24NJ7GVW.js";
6
- import "./chunk-PF2EJVUZ.js";
5
+ } from "./chunk-QQK5BNRP.js";
6
+ import "./chunk-ZFHZ4LGF.js";
7
7
  import "./chunk-6Z2MR3PO.js";
8
8
  export {
9
9
  DEFAULT_PORT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-google",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Stateful Google public vendor API emulator with native namespaces, checkpoints and test controls.",
5
5
  "license": "MIT",
6
6
  "type": "module",