@crvouga/mockingbird-service-mongoatlas 0.1.0 → 0.3.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 +19 -1
- package/DISCOVERY.md +23 -0
- package/README.md +15 -3
- package/dist/{chunk-M73LWCCP.js → chunk-6Z2MR3PO.js} +33 -3
- package/dist/{chunk-M73LWCCP.js.map → chunk-6Z2MR3PO.js.map} +2 -2
- package/dist/chunk-OW5SEVWV.js +4795 -0
- package/dist/chunk-OW5SEVWV.js.map +7 -0
- package/dist/chunk-YPJETTFK.js +7003 -0
- package/dist/chunk-YPJETTFK.js.map +7 -0
- package/dist/cli.js +3 -3
- package/dist/crypto-II2ETGQQ.js +21 -0
- package/dist/{helpers-BMHFVPFA.js → helpers-5D4ROPWG.js} +2 -2
- package/dist/index.d.ts +376 -45
- package/dist/index.js +2 -2
- package/dist/server.d.ts +731 -86
- package/dist/server.js +3 -3
- package/package.json +3 -2
- package/dist/chunk-FRHQ7ANR.js +0 -876
- package/dist/chunk-FRHQ7ANR.js.map +0 -7
- package/dist/chunk-T3D2FSIN.js +0 -5102
- package/dist/chunk-T3D2FSIN.js.map +0 -7
- package/dist/crypto-I5AVO7Q3.js +0 -15
- /package/dist/{crypto-I5AVO7Q3.js.map → crypto-II2ETGQQ.js.map} +0 -0
- /package/dist/{helpers-BMHFVPFA.js.map → helpers-5D4ROPWG.js.map} +0 -0
package/dist/server.d.ts
CHANGED
|
@@ -144,7 +144,7 @@ type ClockState$1 = {
|
|
|
144
144
|
now: number;
|
|
145
145
|
/** True while time does not advance on its own. */
|
|
146
146
|
frozen: boolean;
|
|
147
|
-
/** Milliseconds
|
|
147
|
+
/** Milliseconds a running clock adds to its underlying source. `0` while frozen. */
|
|
148
148
|
offsetMs: number;
|
|
149
149
|
};
|
|
150
150
|
type Clock$1 = {
|
|
@@ -180,7 +180,10 @@ type Rng$1 = {
|
|
|
180
180
|
state(): number;
|
|
181
181
|
/** Restore a state previously returned by {@link state}. */
|
|
182
182
|
setState(state: number): void;
|
|
183
|
-
seed
|
|
183
|
+
/** Restart the stream from a new seed. `reset` then returns to this seed. */
|
|
184
|
+
reseed(seed: number | string): void;
|
|
185
|
+
/** The seed the stream currently starts from. */
|
|
186
|
+
readonly seed: number;
|
|
184
187
|
};
|
|
185
188
|
|
|
186
189
|
/**
|
|
@@ -189,44 +192,83 @@ type Rng$1 = {
|
|
|
189
192
|
* This is how a suite reaches the vendor's failure modes without the vendor: the
|
|
190
193
|
* quota error that only appears when a shared sandbox is full, the 429 that only
|
|
191
194
|
* appears under load, the 5xx that proves a retry path works.
|
|
195
|
+
*
|
|
196
|
+
* A rule has three parts. What it **matches** (`operationId`, `method`, `path`, …), **when**
|
|
197
|
+
* it fires among the matching requests (`after`, `every`, `count`, `rate`, `from`, `until`),
|
|
198
|
+
* and what it **does** (`status`, `delay`, `timeout`, `drop`, `truncate`, `effect`).
|
|
192
199
|
*/
|
|
193
200
|
type FaultRule$1 = {
|
|
194
|
-
/** Stable id, so a suite can retire exactly the rule it added. */
|
|
201
|
+
/** Stable id, so a suite can retire exactly the rule it added. Unique within a namespace. */
|
|
195
202
|
id: string;
|
|
196
203
|
/** Fault only this operation. Omit to match every operation. */
|
|
197
204
|
operationId?: string;
|
|
198
205
|
/** Fault only this HTTP method, case-insensitive. Omit to match every method. */
|
|
199
206
|
method?: string;
|
|
207
|
+
/** Fault only this exact path. */
|
|
208
|
+
path?: string;
|
|
200
209
|
/** Fault only paths starting with this prefix. Omit to match every path. */
|
|
201
210
|
pathPrefix?: string;
|
|
211
|
+
/** Fault only paths matching this regular expression (JavaScript syntax, unanchored). */
|
|
212
|
+
pathPattern?: string;
|
|
213
|
+
/** Fault only requests carrying these headers. `"*"` matches any value. */
|
|
214
|
+
requestHeaders?: Record<string, string>;
|
|
215
|
+
/** Fault only requests carrying these query parameters. `"*"` matches any value. */
|
|
216
|
+
query?: Record<string, string>;
|
|
202
217
|
/**
|
|
203
218
|
* Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
|
|
204
219
|
* an in-process caller usually wants, and what a parallel worker usually does not:
|
|
205
220
|
* rules added through `POST /__admin/faults` default to the calling namespace.
|
|
206
221
|
*/
|
|
207
222
|
namespace?: string;
|
|
223
|
+
/** Let this many matching requests through first. */
|
|
224
|
+
after?: number;
|
|
225
|
+
/** Then fault only every nth matching request: `3` faults the 3rd, 6th, 9th. */
|
|
226
|
+
every?: number;
|
|
227
|
+
/** Retire the rule after this many faults. Omit to keep it until removed. */
|
|
228
|
+
count?: number;
|
|
229
|
+
/** Fault this fraction of the remaining requests, `0`–`1`, drawn from the seed. Default `1`. */
|
|
230
|
+
rate?: number;
|
|
231
|
+
/**
|
|
232
|
+
* Fault only from this instant on the namespace clock. A duration (`"5m"`) counts from the
|
|
233
|
+
* clock when the rule was added. Listed as epoch ms.
|
|
234
|
+
*/
|
|
235
|
+
from?: Instant$1 | Duration$1;
|
|
236
|
+
/** Stop faulting at this instant on the namespace clock. A duration counts from when added. */
|
|
237
|
+
until?: Instant$1 | Duration$1;
|
|
208
238
|
/**
|
|
209
|
-
* Status of the injected response. Omit for a rule that only delays
|
|
210
|
-
*
|
|
211
|
-
* the request then still reaches the service.
|
|
239
|
+
* Status of the injected response. Omit for a rule that only delays, times out, drops,
|
|
240
|
+
* truncates, or switches on an `effect`: the request then still reaches the service.
|
|
212
241
|
*/
|
|
213
242
|
status?: number;
|
|
214
243
|
/** Response body, serialized as JSON. A string is sent as-is. */
|
|
215
244
|
body?: unknown;
|
|
245
|
+
/** Response headers. */
|
|
216
246
|
headers?: Record<string, string>;
|
|
217
|
-
/**
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
rate?: number;
|
|
221
|
-
/** Hold the response back this long, to exercise timeouts. */
|
|
247
|
+
/** Hold the response back this long. Listed as `delayMs`. */
|
|
248
|
+
delay?: Duration$1;
|
|
249
|
+
/** `delay`, in milliseconds. */
|
|
222
250
|
delayMs?: number;
|
|
223
251
|
/** Alias of `delayMs`. */
|
|
224
252
|
latencyMs?: number;
|
|
253
|
+
/** Extra seeded delay in `[0, jitter]`. Listed as `jitterMs`. */
|
|
254
|
+
jitter?: Duration$1;
|
|
255
|
+
jitterMs?: number;
|
|
256
|
+
/**
|
|
257
|
+
* Never answer: hold the request this long, then drop the connection. Listed as
|
|
258
|
+
* `timeoutMs`. With virtual time the wait is spent on the mock clock.
|
|
259
|
+
*/
|
|
260
|
+
timeout?: Duration$1;
|
|
261
|
+
timeoutMs?: number;
|
|
225
262
|
/**
|
|
226
263
|
* Drop the connection instead of answering: an in-process `fetch` rejects with a
|
|
227
264
|
* `TypeError`, and a served mock destroys the socket. Models "unknown outcome" failures.
|
|
228
265
|
*/
|
|
229
266
|
drop?: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Cut the response body off after this many bytes: the status and headers arrive, then
|
|
269
|
+
* the connection dies mid-body.
|
|
270
|
+
*/
|
|
271
|
+
truncate?: number;
|
|
230
272
|
/**
|
|
231
273
|
* A named service behaviour to switch on for the matching request instead of (or
|
|
232
274
|
* before) a canned response, e.g. `created_but_500` or `numeric_tracking_id`. Services
|
|
@@ -235,8 +277,8 @@ type FaultRule$1 = {
|
|
|
235
277
|
effect?: string;
|
|
236
278
|
/** Parameters for `effect`. */
|
|
237
279
|
params?: Record<string, unknown>;
|
|
238
|
-
/**
|
|
239
|
-
|
|
280
|
+
/** The preset this rule was expanded from, if any. */
|
|
281
|
+
fromPreset?: string;
|
|
240
282
|
};
|
|
241
283
|
/** A fault that fired for one request. */
|
|
242
284
|
type FaultHit$1 = {
|
|
@@ -244,6 +286,10 @@ type FaultHit$1 = {
|
|
|
244
286
|
/** The injected response; absent when the rule only delays, drops, or sets an effect. */
|
|
245
287
|
response?: Response;
|
|
246
288
|
drop?: boolean;
|
|
289
|
+
/** Set with `drop` when the rule held the request for its `timeout` first. */
|
|
290
|
+
timeout?: boolean;
|
|
291
|
+
/** Bytes of response body to let through before the connection dies. */
|
|
292
|
+
truncate?: number;
|
|
247
293
|
effect?: {
|
|
248
294
|
name: string;
|
|
249
295
|
params: Record<string, unknown>;
|
|
@@ -255,38 +301,202 @@ type FaultCandidate$1 = {
|
|
|
255
301
|
method: string;
|
|
256
302
|
path: string;
|
|
257
303
|
namespace: string;
|
|
304
|
+
/** Request headers and query, for rules that match on them. */
|
|
305
|
+
headers?: Headers;
|
|
306
|
+
query?: URLSearchParams;
|
|
307
|
+
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
308
|
+
now?: number;
|
|
309
|
+
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
310
|
+
wait?: (ms: number) => Promise<void>;
|
|
311
|
+
};
|
|
312
|
+
/** A stored rule and how often it was consulted. */
|
|
313
|
+
type FaultListing$1 = FaultRule$1 & {
|
|
314
|
+
/** Faults left before the rule retires. `null` when it has no `count`. */
|
|
315
|
+
remaining: number | null;
|
|
316
|
+
/** Times the rule faulted a request. */
|
|
317
|
+
hits: number;
|
|
318
|
+
/** Requests that matched the rule, faulted or not. */
|
|
319
|
+
seen: number;
|
|
320
|
+
};
|
|
321
|
+
/** A namespace's own rules, with their counters, in the order they are tried. */
|
|
322
|
+
type FaultSnapshot$1 = {
|
|
323
|
+
/**
|
|
324
|
+
* `position` is how many `"*"` rules are tried before the rule, which is what its place
|
|
325
|
+
* in the order means to a request and holds in any process.
|
|
326
|
+
*/
|
|
327
|
+
rules: (FaultListing$1 & {
|
|
328
|
+
position?: number;
|
|
329
|
+
})[];
|
|
330
|
+
/** How many `fault_<n>` ids the namespace has handed out. */
|
|
331
|
+
nextId?: number;
|
|
258
332
|
};
|
|
259
333
|
type FaultRegistry$1 = {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
rules: (FaultRule$1 & {
|
|
263
|
-
remaining: number | null;
|
|
264
|
-
hits: number;
|
|
265
|
-
position: number;
|
|
266
|
-
})[];
|
|
267
|
-
rngState: number;
|
|
268
|
-
};
|
|
334
|
+
snapshot(namespace: string): FaultSnapshot$1;
|
|
335
|
+
/** Add a rule, or replace the rule with the same id in the same namespace. */
|
|
269
336
|
add(rule: FaultRule$1): FaultRule$1;
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
})[];
|
|
282
|
-
rngState: number;
|
|
283
|
-
}): void;
|
|
337
|
+
/** The next unused `fault_<n>` id in `namespace`. */
|
|
338
|
+
nextId(namespace: string): string;
|
|
339
|
+
/** Every rule, or the rules a namespace's requests can hit: its own and the global ones. */
|
|
340
|
+
list(namespace?: string): FaultListing$1[];
|
|
341
|
+
get(id: string, namespace?: string): FaultListing$1 | undefined;
|
|
342
|
+
/** Remove a rule by id: from `namespace` (its own, then a global one), or wherever it is. */
|
|
343
|
+
remove(id: string, namespace?: string): boolean;
|
|
344
|
+
/** Remove every rule, or one namespace's own rules. */
|
|
345
|
+
clear(namespace?: string): void;
|
|
346
|
+
/** Replace a namespace's own rules with a snapshot's, wherever the snapshot was taken. */
|
|
347
|
+
restore(namespace: string, state: FaultSnapshot$1): void;
|
|
284
348
|
/**
|
|
285
349
|
* Every fault this request should get, in rule order, stopping at the first that answers
|
|
286
350
|
* or drops (effect-only and delay-only rules let later rules match too). Consumes one of
|
|
287
351
|
* each matching rule's remaining uses.
|
|
288
352
|
*/
|
|
289
353
|
take(candidate: FaultCandidate$1): Promise<FaultHit$1[]>;
|
|
354
|
+
/**
|
|
355
|
+
* Fire these rules at one request without storing them: no matching, no schedule, in order,
|
|
356
|
+
* stopping at the first that answers or drops. Jitter draws from the namespace's stream.
|
|
357
|
+
*/
|
|
358
|
+
fire(rules: readonly FaultRule$1[], candidate: FaultCandidate$1): Promise<FaultHit$1[]>;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* The admin controls every mock shares, as one document.
|
|
363
|
+
*
|
|
364
|
+
* The same shape is accepted in three places, and means the same thing in each:
|
|
365
|
+
*
|
|
366
|
+
* - at boot: `createRuntime({ adminControls })`, `serve --admin-controls`,
|
|
367
|
+
* `MOCKINGBIRD_ADMIN_CONTROLS`
|
|
368
|
+
* - over HTTP: `PUT /__admin/controls`
|
|
369
|
+
* - per request: the `x-mockingbird-*` headers in {@link CONTROL_HEADERS}
|
|
370
|
+
*
|
|
371
|
+
* Every control is deterministic: given the same seed, clock and requests, a mock answers
|
|
372
|
+
* the same bytes. Nothing here reads the wall clock or `Math.random`.
|
|
373
|
+
*/
|
|
374
|
+
/** Milliseconds, or a string like `"250ms"`, `"2s"`, `"15m"`, `"1h"`, `"3d"`. */
|
|
375
|
+
type Duration$1 = number | string;
|
|
376
|
+
/** Epoch milliseconds, or an ISO-8601 string. */
|
|
377
|
+
type Instant$1 = number | string;
|
|
378
|
+
type ClockControls$1 = {
|
|
379
|
+
/** Move the clock to this instant. */
|
|
380
|
+
now?: Instant$1;
|
|
381
|
+
/** Stop time. A frozen clock moves only when told to, so timestamps replay exactly. */
|
|
382
|
+
frozen?: boolean;
|
|
383
|
+
/**
|
|
384
|
+
* Step the clock forward by this much before every vendor request. With a frozen clock
|
|
385
|
+
* each request still gets its own, reproducible timestamp.
|
|
386
|
+
*/
|
|
387
|
+
autoAdvance?: Duration$1;
|
|
388
|
+
};
|
|
389
|
+
/** How long a response takes: a fixed delay plus seeded jitter in `[0, jitter]`. */
|
|
390
|
+
type LatencyRuleInput$1 = {
|
|
391
|
+
delay?: Duration$1;
|
|
392
|
+
jitter?: Duration$1;
|
|
393
|
+
};
|
|
394
|
+
type LatencyControls$1 = LatencyRuleInput$1 & {
|
|
395
|
+
/** Per-operation overrides, keyed by operationId. A bare duration is its `delay`. */
|
|
396
|
+
operations?: Record<string, Duration$1 | LatencyRuleInput$1>;
|
|
397
|
+
};
|
|
398
|
+
/** A fault to add: a rule (the id is assigned when omitted), or a named preset with overrides. */
|
|
399
|
+
type FaultInput$1 = (Omit<FaultRule$1, "id"> & {
|
|
400
|
+
id?: string;
|
|
401
|
+
}) | ({
|
|
402
|
+
preset: string;
|
|
403
|
+
} & Partial<FaultRule$1>);
|
|
404
|
+
/** Identifies a {@link SnapshotDocument}. */
|
|
405
|
+
declare const SNAPSHOT_FORMAT$1 = "mockingbird.snapshot/v1";
|
|
406
|
+
/**
|
|
407
|
+
* A namespace, as portable JSON: what `GET /__admin/snapshots/:id` returns and what
|
|
408
|
+
* `PUT /__admin/snapshots/:id` and the boot `snapshot` control accept. Only `format` and
|
|
409
|
+
* `records` are required, so a hand-written seed file is a valid snapshot.
|
|
410
|
+
*/
|
|
411
|
+
type SnapshotDocument$1 = {
|
|
412
|
+
format: typeof SNAPSHOT_FORMAT$1;
|
|
413
|
+
/** The service that wrote it. A snapshot is rejected by any other service. */
|
|
414
|
+
service?: string;
|
|
415
|
+
/**
|
|
416
|
+
* Stored rows. `seq` orders a collection; omitted, rows keep their listed order. `raw` is
|
|
417
|
+
* the stored text of a row that is not a plain record, and replaces `value` when present.
|
|
418
|
+
*/
|
|
419
|
+
records: {
|
|
420
|
+
collection: string;
|
|
421
|
+
id: string;
|
|
422
|
+
seq?: number;
|
|
423
|
+
value?: unknown;
|
|
424
|
+
raw?: string;
|
|
425
|
+
}[];
|
|
426
|
+
/** Id counters, so the next generated id continues where the snapshot left off. */
|
|
427
|
+
sequences?: {
|
|
428
|
+
name: string;
|
|
429
|
+
kind: string;
|
|
430
|
+
value: number;
|
|
431
|
+
}[];
|
|
432
|
+
clock?: {
|
|
433
|
+
now: number;
|
|
434
|
+
frozen: boolean;
|
|
435
|
+
autoAdvanceMs?: number;
|
|
436
|
+
};
|
|
437
|
+
seed?: number | string;
|
|
438
|
+
/** Positions of the seeded random streams. */
|
|
439
|
+
rng?: {
|
|
440
|
+
state: number;
|
|
441
|
+
faults?: number;
|
|
442
|
+
latency?: number;
|
|
443
|
+
};
|
|
444
|
+
faults?: unknown;
|
|
445
|
+
latency?: unknown;
|
|
446
|
+
virtualTime?: boolean;
|
|
447
|
+
/** Quiescent webhook endpoints, delivery history and fault state. Contains private configuration. */
|
|
448
|
+
webhooks?: unknown;
|
|
449
|
+
};
|
|
450
|
+
/** Controls for one namespace. */
|
|
451
|
+
type NamespaceControls$1 = {
|
|
452
|
+
/** Seeds every random choice: fault rates, jitter, and whatever the service invents. */
|
|
453
|
+
seed?: number | string;
|
|
454
|
+
clock?: ClockControls$1;
|
|
455
|
+
/**
|
|
456
|
+
* Spend injected waits (latency, fault delays, timeouts) on the mock clock instead of the
|
|
457
|
+
* wall clock: the request returns at once, the clock has moved, and the journal records
|
|
458
|
+
* the wait exactly. Default `false`: waits are real, so a client's own timeout can fire.
|
|
459
|
+
*/
|
|
460
|
+
virtualTime?: boolean;
|
|
461
|
+
/** Baseline response time for every vendor request. A bare duration is its `delay`. */
|
|
462
|
+
latency?: Duration$1 | LatencyControls$1;
|
|
463
|
+
faults?: readonly FaultInput$1[];
|
|
464
|
+
/** Start from this state instead of the service's own seed data. */
|
|
465
|
+
snapshot?: SnapshotDocument$1;
|
|
466
|
+
};
|
|
467
|
+
/** {@link NamespaceControls} for every namespace, with per-namespace overrides. */
|
|
468
|
+
type MockControls$1 = NamespaceControls$1 & {
|
|
469
|
+
/** Vendor credential → namespace, for SDKs that cannot send a namespace header. */
|
|
470
|
+
credentials?: Record<string, string>;
|
|
471
|
+
/** Overrides for named namespaces. A key given here replaces the shared value. */
|
|
472
|
+
namespaces?: Record<string, NamespaceControls$1>;
|
|
473
|
+
};
|
|
474
|
+
/** A latency rule in milliseconds. */
|
|
475
|
+
type LatencyRule$1 = {
|
|
476
|
+
delayMs: number;
|
|
477
|
+
jitterMs: number;
|
|
478
|
+
};
|
|
479
|
+
/** Baseline latency for a namespace, normalized. */
|
|
480
|
+
type LatencyState$1 = LatencyRule$1 & {
|
|
481
|
+
operations: Record<string, LatencyRule$1>;
|
|
482
|
+
};
|
|
483
|
+
/** What {@link controlHeaders} turns into request headers. */
|
|
484
|
+
type ControlHeaderInput$1 = {
|
|
485
|
+
namespace?: string;
|
|
486
|
+
adminKey?: string;
|
|
487
|
+
branch?: string;
|
|
488
|
+
at?: string;
|
|
489
|
+
reset?: boolean;
|
|
490
|
+
restore?: string;
|
|
491
|
+
seed?: number | string;
|
|
492
|
+
time?: Instant$1 | Date;
|
|
493
|
+
advance?: Duration$1;
|
|
494
|
+
virtualTime?: boolean;
|
|
495
|
+
delay?: Duration$1;
|
|
496
|
+
timeout?: Duration$1;
|
|
497
|
+
/** A status, `"drop"`, a preset name, or a fault rule. */
|
|
498
|
+
fault?: number | string | Record<string, unknown>;
|
|
499
|
+
snapshot?: string;
|
|
290
500
|
};
|
|
291
501
|
|
|
292
502
|
/**
|
|
@@ -326,6 +536,8 @@ type RequestLog$1 = {
|
|
|
326
536
|
unmatched: boolean;
|
|
327
537
|
/** Set when a fault rule produced the response. */
|
|
328
538
|
faultId?: string;
|
|
539
|
+
/** Milliseconds of injected wait: latency, fault delays and timeouts. Absent when none. */
|
|
540
|
+
delayMs?: number;
|
|
329
541
|
/** Resource ids the handler touched (`userId`, `orderId`, …), when the service reports them. */
|
|
330
542
|
ids?: Record<string, string>;
|
|
331
543
|
/** Set when the service created a resource the request referred to but that did not exist. */
|
|
@@ -371,6 +583,12 @@ type JournalQuery$1 = {
|
|
|
371
583
|
/** Only this namespace. Omit for every namespace, oldest first across all of them. */
|
|
372
584
|
namespace?: string;
|
|
373
585
|
operationId?: string;
|
|
586
|
+
/** Only this HTTP method, case-insensitive. */
|
|
587
|
+
method?: string;
|
|
588
|
+
/** Only this exact path. */
|
|
589
|
+
path?: string;
|
|
590
|
+
/** Only requests this fault rule answered or shaped. */
|
|
591
|
+
faultId?: string;
|
|
374
592
|
status?: number;
|
|
375
593
|
/** Only entries at or after this instant (epoch ms). */
|
|
376
594
|
since?: number;
|
|
@@ -385,6 +603,50 @@ type Journal$1 = {
|
|
|
385
603
|
clear(namespace?: string): void;
|
|
386
604
|
};
|
|
387
605
|
|
|
606
|
+
/**
|
|
607
|
+
* Baseline response time, per namespace: how long every vendor request takes before any
|
|
608
|
+
* fault is considered. Jitter draws from a stream the caller owns, one per namespace and
|
|
609
|
+
* separate from the fault stream, so adding latency never shifts which requests a `rate`
|
|
610
|
+
* fault hits.
|
|
611
|
+
*/
|
|
612
|
+
type LatencyRegistry$1 = {
|
|
613
|
+
get(namespace: string): LatencyState$1;
|
|
614
|
+
set(namespace: string, state: LatencyState$1): LatencyState$1;
|
|
615
|
+
/** Remove one namespace's latency, or every namespace's. */
|
|
616
|
+
clear(namespace?: string): void;
|
|
617
|
+
/** Milliseconds this request waits. Draws jitter, so call it once per request. */
|
|
618
|
+
take(namespace: string, operationId: string | undefined): number;
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
/** Clock state as the admin API reports it. */
|
|
622
|
+
type ControlClock$1 = ClockState$1 & {
|
|
623
|
+
/** `now`, as ISO-8601. */
|
|
624
|
+
iso: string;
|
|
625
|
+
/** Milliseconds the clock steps before every vendor request. */
|
|
626
|
+
autoAdvanceMs: number;
|
|
627
|
+
};
|
|
628
|
+
/** One namespace's controls: the body of `GET /__admin/controls`. */
|
|
629
|
+
type ControlState$1 = {
|
|
630
|
+
namespace: string;
|
|
631
|
+
seed: number | string;
|
|
632
|
+
clock: ControlClock$1;
|
|
633
|
+
virtualTime: boolean;
|
|
634
|
+
latency: LatencyState$1;
|
|
635
|
+
faults: FaultListing$1[];
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
/** What `GET /__admin/snapshots` lists for each snapshot. */
|
|
639
|
+
type SnapshotInfo$1 = {
|
|
640
|
+
id: string;
|
|
641
|
+
namespace: string;
|
|
642
|
+
/** Stored rows in the snapshot. */
|
|
643
|
+
records: number;
|
|
644
|
+
/** The namespace clock when it was taken, epoch ms. */
|
|
645
|
+
at: number;
|
|
646
|
+
/** Whether `GET /snapshots/:id` can return it as a {@link SnapshotDocument}. */
|
|
647
|
+
portable: boolean;
|
|
648
|
+
};
|
|
649
|
+
|
|
388
650
|
/** Credential → namespace mapping behind `PUT /__admin/credentials`. */
|
|
389
651
|
type CredentialRegistry$1 = {
|
|
390
652
|
set(credential: string, namespace: string): void;
|
|
@@ -397,6 +659,8 @@ type CredentialRegistry$1 = {
|
|
|
397
659
|
}[];
|
|
398
660
|
};
|
|
399
661
|
|
|
662
|
+
type OwnedTransport$1 = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
|
|
663
|
+
|
|
400
664
|
/**
|
|
401
665
|
* A point-in-time copy of everything a service namespace holds.
|
|
402
666
|
*
|
|
@@ -514,8 +778,16 @@ type PublishInput$1 = {
|
|
|
514
778
|
id?: string;
|
|
515
779
|
};
|
|
516
780
|
type WebhookHub$1 = {
|
|
781
|
+
observeDeliveries(listener: (event: {
|
|
782
|
+
namespace: string;
|
|
783
|
+
state: string;
|
|
784
|
+
deliveryId: string;
|
|
785
|
+
}) => void): () => void;
|
|
786
|
+
setTransportPolicy(policy: OwnedTransport$1): void;
|
|
517
787
|
pending(namespace: string): number;
|
|
518
788
|
snapshot(namespace: string): unknown;
|
|
789
|
+
exportSnapshot(handle: unknown): unknown;
|
|
790
|
+
importSnapshot(namespace: string, document: unknown): unknown;
|
|
519
791
|
restore(namespace: string, snapshot: unknown): void;
|
|
520
792
|
publish(input: PublishInput$1): WebhookMessage$1;
|
|
521
793
|
/** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
|
|
@@ -528,7 +800,7 @@ type WebhookHub$1 = {
|
|
|
528
800
|
/** Run every pending retry (and release held reordered messages) now, and every retry those attempts schedule, until nothing is pending. */
|
|
529
801
|
flush(): Promise<void>;
|
|
530
802
|
/** Resolve once nothing is in flight. */
|
|
531
|
-
idle(): Promise<void>;
|
|
803
|
+
idle(namespace?: string): Promise<void>;
|
|
532
804
|
fault(namespace: string, fault: WebhookFault$1): void;
|
|
533
805
|
clear(namespace?: string): void;
|
|
534
806
|
};
|
|
@@ -539,7 +811,10 @@ type ServiceInstance$1 = FetchAPI$1 & {
|
|
|
539
811
|
};
|
|
540
812
|
type ServiceTimelineState$1 = Readonly<{
|
|
541
813
|
snapshot: NamespaceSnapshot$1;
|
|
542
|
-
clock
|
|
814
|
+
/** `pinned`: the namespace's clock was frozen itself, not just following a frozen base. */
|
|
815
|
+
clock: Readonly<ClockState$1 & {
|
|
816
|
+
pinned?: boolean;
|
|
817
|
+
}>;
|
|
543
818
|
rngState: number;
|
|
544
819
|
}>;
|
|
545
820
|
type ServiceCheckpoint$1 = Checkpoint$1<ServiceTimelineState$1>;
|
|
@@ -552,27 +827,63 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$1 & {
|
|
|
552
827
|
readonly sqlite: SqliteClient$3;
|
|
553
828
|
readonly clock: Clock$1;
|
|
554
829
|
readonly faults: FaultRegistry$1;
|
|
830
|
+
/** Baseline response time per namespace. */
|
|
831
|
+
readonly latency: LatencyRegistry$1;
|
|
555
832
|
readonly metrics: Metrics$1;
|
|
556
833
|
readonly journal: Journal$1;
|
|
557
834
|
readonly rng: Rng$1;
|
|
558
835
|
readonly credentials: CredentialRegistry$1;
|
|
559
836
|
/** The webhook hub, when the service has outbound webhooks. */
|
|
560
837
|
readonly webhooks: WebhookHub$1 | undefined;
|
|
561
|
-
/**
|
|
562
|
-
|
|
838
|
+
/**
|
|
839
|
+
* A namespace's clock. Each follows the base clock, {@link ServiceRuntime.clock}, with an
|
|
840
|
+
* offset and a freeze of its own, so moving one never moves another.
|
|
841
|
+
*/
|
|
563
842
|
namespaceClock(namespace?: string): Clock$1;
|
|
564
843
|
namespaceOf(request: Request): string;
|
|
565
844
|
/** Opaque in-process checkpoint including records, controls and webhook history. */
|
|
566
845
|
fleetSnapshot(namespace: string): object;
|
|
567
846
|
fleetRestore(snapshot: unknown, namespace: string): void;
|
|
847
|
+
fleetExport(snapshot: unknown): SnapshotDocument$1;
|
|
848
|
+
fleetImport(namespace: string, document: unknown): object;
|
|
568
849
|
/** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
|
|
569
850
|
applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule$1>): FaultRule$1[];
|
|
570
851
|
/** The instance behind `namespace` (the default one when omitted), created on first use. */
|
|
571
852
|
instance(namespace?: string): T;
|
|
572
853
|
/** Public names of every namespace created so far. */
|
|
573
854
|
namespaces(): string[];
|
|
574
|
-
/**
|
|
855
|
+
/** Return one namespace to its boot state, or every namespace with `"*"`. */
|
|
575
856
|
reset(namespace?: string): Promise<void>;
|
|
857
|
+
/** Reset a namespace and forget it, releasing everything it held. */
|
|
858
|
+
dropNamespace(namespace: string): Promise<void>;
|
|
859
|
+
/** A namespace's controls: seed, clock, virtual time, latency, faults and snapshots. */
|
|
860
|
+
controls(namespace?: string): ControlState$1 & {
|
|
861
|
+
snapshots: SnapshotInfo$1[];
|
|
862
|
+
};
|
|
863
|
+
/** Apply a control document to a namespace. A given key replaces that control. */
|
|
864
|
+
configure(controls: NamespaceControls$1, namespace?: string): ControlState$1 & {
|
|
865
|
+
snapshots: SnapshotInfo$1[];
|
|
866
|
+
};
|
|
867
|
+
/** Named snapshots of a namespace: records, clock, random streams, faults and latency. */
|
|
868
|
+
readonly snapshots: {
|
|
869
|
+
/** Capture the namespace now. Reusing a name replaces that snapshot. */
|
|
870
|
+
create(options?: {
|
|
871
|
+
name?: string;
|
|
872
|
+
namespace?: string;
|
|
873
|
+
}): SnapshotInfo$1;
|
|
874
|
+
list(namespace?: string): SnapshotInfo$1[];
|
|
875
|
+
/** The snapshot as portable JSON, to commit beside a suite or boot another mock from. */
|
|
876
|
+
export(id: string, namespace?: string): SnapshotDocument$1;
|
|
877
|
+
/** Store a document as a snapshot without restoring it. */
|
|
878
|
+
import(document: SnapshotDocument$1, options?: {
|
|
879
|
+
name?: string;
|
|
880
|
+
namespace?: string;
|
|
881
|
+
}): SnapshotInfo$1;
|
|
882
|
+
restore(id: string, namespace?: string): void;
|
|
883
|
+
delete(id: string, namespace?: string): boolean;
|
|
884
|
+
};
|
|
885
|
+
/** Request headers that carry controls, checked: spread them into a `fetch` or an SDK's defaults. */
|
|
886
|
+
headers(input: ControlHeaderInput$1): Record<string, string>;
|
|
576
887
|
snapshot(namespace?: string): NamespaceSnapshot$1;
|
|
577
888
|
restore(snapshot: NamespaceSnapshot$1, namespace?: string): void;
|
|
578
889
|
/** Capture the current branch. Mutating HTTP calls do this automatically. */
|
|
@@ -615,6 +926,8 @@ type CommonServeOptions = {
|
|
|
615
926
|
adminKey: string | undefined;
|
|
616
927
|
seed: string | undefined;
|
|
617
928
|
onLog: ((entry: RequestLog$1) => void) | undefined;
|
|
929
|
+
/** Admin controls to boot with: clock, latency, faults, a starting snapshot. */
|
|
930
|
+
adminControls?: MockControls$1;
|
|
618
931
|
/** Synthetic provider fixture objects supplied by a fleet entry. */
|
|
619
932
|
fixtures?: Record<string, unknown>;
|
|
620
933
|
baseUrl?: string;
|
|
@@ -625,6 +938,7 @@ type CommonServeOptions = {
|
|
|
625
938
|
* `serveTarget`, which is also how `serve --config` finds services by name.
|
|
626
939
|
*/
|
|
627
940
|
type ServeTarget = {
|
|
941
|
+
packageVersion?: string;
|
|
628
942
|
name: string;
|
|
629
943
|
defaultPort: number;
|
|
630
944
|
/** Serve flags beyond the common ones. */
|
|
@@ -945,7 +1259,7 @@ type ClockState = {
|
|
|
945
1259
|
now: number;
|
|
946
1260
|
/** True while time does not advance on its own. */
|
|
947
1261
|
frozen: boolean;
|
|
948
|
-
/** Milliseconds
|
|
1262
|
+
/** Milliseconds a running clock adds to its underlying source. `0` while frozen. */
|
|
949
1263
|
offsetMs: number;
|
|
950
1264
|
};
|
|
951
1265
|
type Clock = {
|
|
@@ -981,7 +1295,10 @@ type Rng = {
|
|
|
981
1295
|
state(): number;
|
|
982
1296
|
/** Restore a state previously returned by {@link state}. */
|
|
983
1297
|
setState(state: number): void;
|
|
984
|
-
seed
|
|
1298
|
+
/** Restart the stream from a new seed. `reset` then returns to this seed. */
|
|
1299
|
+
reseed(seed: number | string): void;
|
|
1300
|
+
/** The seed the stream currently starts from. */
|
|
1301
|
+
readonly seed: number;
|
|
985
1302
|
};
|
|
986
1303
|
|
|
987
1304
|
/**
|
|
@@ -990,44 +1307,83 @@ type Rng = {
|
|
|
990
1307
|
* This is how a suite reaches the vendor's failure modes without the vendor: the
|
|
991
1308
|
* quota error that only appears when a shared sandbox is full, the 429 that only
|
|
992
1309
|
* appears under load, the 5xx that proves a retry path works.
|
|
1310
|
+
*
|
|
1311
|
+
* A rule has three parts. What it **matches** (`operationId`, `method`, `path`, …), **when**
|
|
1312
|
+
* it fires among the matching requests (`after`, `every`, `count`, `rate`, `from`, `until`),
|
|
1313
|
+
* and what it **does** (`status`, `delay`, `timeout`, `drop`, `truncate`, `effect`).
|
|
993
1314
|
*/
|
|
994
1315
|
type FaultRule = {
|
|
995
|
-
/** Stable id, so a suite can retire exactly the rule it added. */
|
|
1316
|
+
/** Stable id, so a suite can retire exactly the rule it added. Unique within a namespace. */
|
|
996
1317
|
id: string;
|
|
997
1318
|
/** Fault only this operation. Omit to match every operation. */
|
|
998
1319
|
operationId?: string;
|
|
999
1320
|
/** Fault only this HTTP method, case-insensitive. Omit to match every method. */
|
|
1000
1321
|
method?: string;
|
|
1322
|
+
/** Fault only this exact path. */
|
|
1323
|
+
path?: string;
|
|
1001
1324
|
/** Fault only paths starting with this prefix. Omit to match every path. */
|
|
1002
1325
|
pathPrefix?: string;
|
|
1326
|
+
/** Fault only paths matching this regular expression (JavaScript syntax, unanchored). */
|
|
1327
|
+
pathPattern?: string;
|
|
1328
|
+
/** Fault only requests carrying these headers. `"*"` matches any value. */
|
|
1329
|
+
requestHeaders?: Record<string, string>;
|
|
1330
|
+
/** Fault only requests carrying these query parameters. `"*"` matches any value. */
|
|
1331
|
+
query?: Record<string, string>;
|
|
1003
1332
|
/**
|
|
1004
1333
|
* Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
|
|
1005
1334
|
* an in-process caller usually wants, and what a parallel worker usually does not:
|
|
1006
1335
|
* rules added through `POST /__admin/faults` default to the calling namespace.
|
|
1007
1336
|
*/
|
|
1008
1337
|
namespace?: string;
|
|
1338
|
+
/** Let this many matching requests through first. */
|
|
1339
|
+
after?: number;
|
|
1340
|
+
/** Then fault only every nth matching request: `3` faults the 3rd, 6th, 9th. */
|
|
1341
|
+
every?: number;
|
|
1342
|
+
/** Retire the rule after this many faults. Omit to keep it until removed. */
|
|
1343
|
+
count?: number;
|
|
1344
|
+
/** Fault this fraction of the remaining requests, `0`–`1`, drawn from the seed. Default `1`. */
|
|
1345
|
+
rate?: number;
|
|
1009
1346
|
/**
|
|
1010
|
-
*
|
|
1011
|
-
*
|
|
1012
|
-
|
|
1347
|
+
* Fault only from this instant on the namespace clock. A duration (`"5m"`) counts from the
|
|
1348
|
+
* clock when the rule was added. Listed as epoch ms.
|
|
1349
|
+
*/
|
|
1350
|
+
from?: Instant | Duration;
|
|
1351
|
+
/** Stop faulting at this instant on the namespace clock. A duration counts from when added. */
|
|
1352
|
+
until?: Instant | Duration;
|
|
1353
|
+
/**
|
|
1354
|
+
* Status of the injected response. Omit for a rule that only delays, times out, drops,
|
|
1355
|
+
* truncates, or switches on an `effect`: the request then still reaches the service.
|
|
1013
1356
|
*/
|
|
1014
1357
|
status?: number;
|
|
1015
1358
|
/** Response body, serialized as JSON. A string is sent as-is. */
|
|
1016
1359
|
body?: unknown;
|
|
1360
|
+
/** Response headers. */
|
|
1017
1361
|
headers?: Record<string, string>;
|
|
1018
|
-
/**
|
|
1019
|
-
|
|
1020
|
-
/**
|
|
1021
|
-
rate?: number;
|
|
1022
|
-
/** Hold the response back this long, to exercise timeouts. */
|
|
1362
|
+
/** Hold the response back this long. Listed as `delayMs`. */
|
|
1363
|
+
delay?: Duration;
|
|
1364
|
+
/** `delay`, in milliseconds. */
|
|
1023
1365
|
delayMs?: number;
|
|
1024
1366
|
/** Alias of `delayMs`. */
|
|
1025
1367
|
latencyMs?: number;
|
|
1368
|
+
/** Extra seeded delay in `[0, jitter]`. Listed as `jitterMs`. */
|
|
1369
|
+
jitter?: Duration;
|
|
1370
|
+
jitterMs?: number;
|
|
1371
|
+
/**
|
|
1372
|
+
* Never answer: hold the request this long, then drop the connection. Listed as
|
|
1373
|
+
* `timeoutMs`. With virtual time the wait is spent on the mock clock.
|
|
1374
|
+
*/
|
|
1375
|
+
timeout?: Duration;
|
|
1376
|
+
timeoutMs?: number;
|
|
1026
1377
|
/**
|
|
1027
1378
|
* Drop the connection instead of answering: an in-process `fetch` rejects with a
|
|
1028
1379
|
* `TypeError`, and a served mock destroys the socket. Models "unknown outcome" failures.
|
|
1029
1380
|
*/
|
|
1030
1381
|
drop?: boolean;
|
|
1382
|
+
/**
|
|
1383
|
+
* Cut the response body off after this many bytes: the status and headers arrive, then
|
|
1384
|
+
* the connection dies mid-body.
|
|
1385
|
+
*/
|
|
1386
|
+
truncate?: number;
|
|
1031
1387
|
/**
|
|
1032
1388
|
* A named service behaviour to switch on for the matching request instead of (or
|
|
1033
1389
|
* before) a canned response, e.g. `created_but_500` or `numeric_tracking_id`. Services
|
|
@@ -1036,8 +1392,8 @@ type FaultRule = {
|
|
|
1036
1392
|
effect?: string;
|
|
1037
1393
|
/** Parameters for `effect`. */
|
|
1038
1394
|
params?: Record<string, unknown>;
|
|
1039
|
-
/**
|
|
1040
|
-
|
|
1395
|
+
/** The preset this rule was expanded from, if any. */
|
|
1396
|
+
fromPreset?: string;
|
|
1041
1397
|
};
|
|
1042
1398
|
/** A fault that fired for one request. */
|
|
1043
1399
|
type FaultHit = {
|
|
@@ -1045,6 +1401,10 @@ type FaultHit = {
|
|
|
1045
1401
|
/** The injected response; absent when the rule only delays, drops, or sets an effect. */
|
|
1046
1402
|
response?: Response;
|
|
1047
1403
|
drop?: boolean;
|
|
1404
|
+
/** Set with `drop` when the rule held the request for its `timeout` first. */
|
|
1405
|
+
timeout?: boolean;
|
|
1406
|
+
/** Bytes of response body to let through before the connection dies. */
|
|
1407
|
+
truncate?: number;
|
|
1048
1408
|
effect?: {
|
|
1049
1409
|
name: string;
|
|
1050
1410
|
params: Record<string, unknown>;
|
|
@@ -1069,38 +1429,202 @@ type FaultCandidate = {
|
|
|
1069
1429
|
method: string;
|
|
1070
1430
|
path: string;
|
|
1071
1431
|
namespace: string;
|
|
1432
|
+
/** Request headers and query, for rules that match on them. */
|
|
1433
|
+
headers?: Headers;
|
|
1434
|
+
query?: URLSearchParams;
|
|
1435
|
+
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
1436
|
+
now?: number;
|
|
1437
|
+
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
1438
|
+
wait?: (ms: number) => Promise<void>;
|
|
1439
|
+
};
|
|
1440
|
+
/** A stored rule and how often it was consulted. */
|
|
1441
|
+
type FaultListing = FaultRule & {
|
|
1442
|
+
/** Faults left before the rule retires. `null` when it has no `count`. */
|
|
1443
|
+
remaining: number | null;
|
|
1444
|
+
/** Times the rule faulted a request. */
|
|
1445
|
+
hits: number;
|
|
1446
|
+
/** Requests that matched the rule, faulted or not. */
|
|
1447
|
+
seen: number;
|
|
1448
|
+
};
|
|
1449
|
+
/** A namespace's own rules, with their counters, in the order they are tried. */
|
|
1450
|
+
type FaultSnapshot = {
|
|
1451
|
+
/**
|
|
1452
|
+
* `position` is how many `"*"` rules are tried before the rule, which is what its place
|
|
1453
|
+
* in the order means to a request and holds in any process.
|
|
1454
|
+
*/
|
|
1455
|
+
rules: (FaultListing & {
|
|
1456
|
+
position?: number;
|
|
1457
|
+
})[];
|
|
1458
|
+
/** How many `fault_<n>` ids the namespace has handed out. */
|
|
1459
|
+
nextId?: number;
|
|
1072
1460
|
};
|
|
1073
1461
|
type FaultRegistry = {
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
rules: (FaultRule & {
|
|
1077
|
-
remaining: number | null;
|
|
1078
|
-
hits: number;
|
|
1079
|
-
position: number;
|
|
1080
|
-
})[];
|
|
1081
|
-
rngState: number;
|
|
1082
|
-
};
|
|
1462
|
+
snapshot(namespace: string): FaultSnapshot;
|
|
1463
|
+
/** Add a rule, or replace the rule with the same id in the same namespace. */
|
|
1083
1464
|
add(rule: FaultRule): FaultRule;
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
})[];
|
|
1096
|
-
rngState: number;
|
|
1097
|
-
}): void;
|
|
1465
|
+
/** The next unused `fault_<n>` id in `namespace`. */
|
|
1466
|
+
nextId(namespace: string): string;
|
|
1467
|
+
/** Every rule, or the rules a namespace's requests can hit: its own and the global ones. */
|
|
1468
|
+
list(namespace?: string): FaultListing[];
|
|
1469
|
+
get(id: string, namespace?: string): FaultListing | undefined;
|
|
1470
|
+
/** Remove a rule by id: from `namespace` (its own, then a global one), or wherever it is. */
|
|
1471
|
+
remove(id: string, namespace?: string): boolean;
|
|
1472
|
+
/** Remove every rule, or one namespace's own rules. */
|
|
1473
|
+
clear(namespace?: string): void;
|
|
1474
|
+
/** Replace a namespace's own rules with a snapshot's, wherever the snapshot was taken. */
|
|
1475
|
+
restore(namespace: string, state: FaultSnapshot): void;
|
|
1098
1476
|
/**
|
|
1099
1477
|
* Every fault this request should get, in rule order, stopping at the first that answers
|
|
1100
1478
|
* or drops (effect-only and delay-only rules let later rules match too). Consumes one of
|
|
1101
1479
|
* each matching rule's remaining uses.
|
|
1102
1480
|
*/
|
|
1103
1481
|
take(candidate: FaultCandidate): Promise<FaultHit[]>;
|
|
1482
|
+
/**
|
|
1483
|
+
* Fire these rules at one request without storing them: no matching, no schedule, in order,
|
|
1484
|
+
* stopping at the first that answers or drops. Jitter draws from the namespace's stream.
|
|
1485
|
+
*/
|
|
1486
|
+
fire(rules: readonly FaultRule[], candidate: FaultCandidate): Promise<FaultHit[]>;
|
|
1487
|
+
};
|
|
1488
|
+
|
|
1489
|
+
/**
|
|
1490
|
+
* The admin controls every mock shares, as one document.
|
|
1491
|
+
*
|
|
1492
|
+
* The same shape is accepted in three places, and means the same thing in each:
|
|
1493
|
+
*
|
|
1494
|
+
* - at boot: `createRuntime({ adminControls })`, `serve --admin-controls`,
|
|
1495
|
+
* `MOCKINGBIRD_ADMIN_CONTROLS`
|
|
1496
|
+
* - over HTTP: `PUT /__admin/controls`
|
|
1497
|
+
* - per request: the `x-mockingbird-*` headers in {@link CONTROL_HEADERS}
|
|
1498
|
+
*
|
|
1499
|
+
* Every control is deterministic: given the same seed, clock and requests, a mock answers
|
|
1500
|
+
* the same bytes. Nothing here reads the wall clock or `Math.random`.
|
|
1501
|
+
*/
|
|
1502
|
+
/** Milliseconds, or a string like `"250ms"`, `"2s"`, `"15m"`, `"1h"`, `"3d"`. */
|
|
1503
|
+
type Duration = number | string;
|
|
1504
|
+
/** Epoch milliseconds, or an ISO-8601 string. */
|
|
1505
|
+
type Instant = number | string;
|
|
1506
|
+
type ClockControls = {
|
|
1507
|
+
/** Move the clock to this instant. */
|
|
1508
|
+
now?: Instant;
|
|
1509
|
+
/** Stop time. A frozen clock moves only when told to, so timestamps replay exactly. */
|
|
1510
|
+
frozen?: boolean;
|
|
1511
|
+
/**
|
|
1512
|
+
* Step the clock forward by this much before every vendor request. With a frozen clock
|
|
1513
|
+
* each request still gets its own, reproducible timestamp.
|
|
1514
|
+
*/
|
|
1515
|
+
autoAdvance?: Duration;
|
|
1516
|
+
};
|
|
1517
|
+
/** How long a response takes: a fixed delay plus seeded jitter in `[0, jitter]`. */
|
|
1518
|
+
type LatencyRuleInput = {
|
|
1519
|
+
delay?: Duration;
|
|
1520
|
+
jitter?: Duration;
|
|
1521
|
+
};
|
|
1522
|
+
type LatencyControls = LatencyRuleInput & {
|
|
1523
|
+
/** Per-operation overrides, keyed by operationId. A bare duration is its `delay`. */
|
|
1524
|
+
operations?: Record<string, Duration | LatencyRuleInput>;
|
|
1525
|
+
};
|
|
1526
|
+
/** A fault to add: a rule (the id is assigned when omitted), or a named preset with overrides. */
|
|
1527
|
+
type FaultInput = (Omit<FaultRule, "id"> & {
|
|
1528
|
+
id?: string;
|
|
1529
|
+
}) | ({
|
|
1530
|
+
preset: string;
|
|
1531
|
+
} & Partial<FaultRule>);
|
|
1532
|
+
/** Identifies a {@link SnapshotDocument}. */
|
|
1533
|
+
declare const SNAPSHOT_FORMAT = "mockingbird.snapshot/v1";
|
|
1534
|
+
/**
|
|
1535
|
+
* A namespace, as portable JSON: what `GET /__admin/snapshots/:id` returns and what
|
|
1536
|
+
* `PUT /__admin/snapshots/:id` and the boot `snapshot` control accept. Only `format` and
|
|
1537
|
+
* `records` are required, so a hand-written seed file is a valid snapshot.
|
|
1538
|
+
*/
|
|
1539
|
+
type SnapshotDocument = {
|
|
1540
|
+
format: typeof SNAPSHOT_FORMAT;
|
|
1541
|
+
/** The service that wrote it. A snapshot is rejected by any other service. */
|
|
1542
|
+
service?: string;
|
|
1543
|
+
/**
|
|
1544
|
+
* Stored rows. `seq` orders a collection; omitted, rows keep their listed order. `raw` is
|
|
1545
|
+
* the stored text of a row that is not a plain record, and replaces `value` when present.
|
|
1546
|
+
*/
|
|
1547
|
+
records: {
|
|
1548
|
+
collection: string;
|
|
1549
|
+
id: string;
|
|
1550
|
+
seq?: number;
|
|
1551
|
+
value?: unknown;
|
|
1552
|
+
raw?: string;
|
|
1553
|
+
}[];
|
|
1554
|
+
/** Id counters, so the next generated id continues where the snapshot left off. */
|
|
1555
|
+
sequences?: {
|
|
1556
|
+
name: string;
|
|
1557
|
+
kind: string;
|
|
1558
|
+
value: number;
|
|
1559
|
+
}[];
|
|
1560
|
+
clock?: {
|
|
1561
|
+
now: number;
|
|
1562
|
+
frozen: boolean;
|
|
1563
|
+
autoAdvanceMs?: number;
|
|
1564
|
+
};
|
|
1565
|
+
seed?: number | string;
|
|
1566
|
+
/** Positions of the seeded random streams. */
|
|
1567
|
+
rng?: {
|
|
1568
|
+
state: number;
|
|
1569
|
+
faults?: number;
|
|
1570
|
+
latency?: number;
|
|
1571
|
+
};
|
|
1572
|
+
faults?: unknown;
|
|
1573
|
+
latency?: unknown;
|
|
1574
|
+
virtualTime?: boolean;
|
|
1575
|
+
/** Quiescent webhook endpoints, delivery history and fault state. Contains private configuration. */
|
|
1576
|
+
webhooks?: unknown;
|
|
1577
|
+
};
|
|
1578
|
+
/** Controls for one namespace. */
|
|
1579
|
+
type NamespaceControls = {
|
|
1580
|
+
/** Seeds every random choice: fault rates, jitter, and whatever the service invents. */
|
|
1581
|
+
seed?: number | string;
|
|
1582
|
+
clock?: ClockControls;
|
|
1583
|
+
/**
|
|
1584
|
+
* Spend injected waits (latency, fault delays, timeouts) on the mock clock instead of the
|
|
1585
|
+
* wall clock: the request returns at once, the clock has moved, and the journal records
|
|
1586
|
+
* the wait exactly. Default `false`: waits are real, so a client's own timeout can fire.
|
|
1587
|
+
*/
|
|
1588
|
+
virtualTime?: boolean;
|
|
1589
|
+
/** Baseline response time for every vendor request. A bare duration is its `delay`. */
|
|
1590
|
+
latency?: Duration | LatencyControls;
|
|
1591
|
+
faults?: readonly FaultInput[];
|
|
1592
|
+
/** Start from this state instead of the service's own seed data. */
|
|
1593
|
+
snapshot?: SnapshotDocument;
|
|
1594
|
+
};
|
|
1595
|
+
/** {@link NamespaceControls} for every namespace, with per-namespace overrides. */
|
|
1596
|
+
type MockControls = NamespaceControls & {
|
|
1597
|
+
/** Vendor credential → namespace, for SDKs that cannot send a namespace header. */
|
|
1598
|
+
credentials?: Record<string, string>;
|
|
1599
|
+
/** Overrides for named namespaces. A key given here replaces the shared value. */
|
|
1600
|
+
namespaces?: Record<string, NamespaceControls>;
|
|
1601
|
+
};
|
|
1602
|
+
/** A latency rule in milliseconds. */
|
|
1603
|
+
type LatencyRule = {
|
|
1604
|
+
delayMs: number;
|
|
1605
|
+
jitterMs: number;
|
|
1606
|
+
};
|
|
1607
|
+
/** Baseline latency for a namespace, normalized. */
|
|
1608
|
+
type LatencyState = LatencyRule & {
|
|
1609
|
+
operations: Record<string, LatencyRule>;
|
|
1610
|
+
};
|
|
1611
|
+
/** What {@link controlHeaders} turns into request headers. */
|
|
1612
|
+
type ControlHeaderInput = {
|
|
1613
|
+
namespace?: string;
|
|
1614
|
+
adminKey?: string;
|
|
1615
|
+
branch?: string;
|
|
1616
|
+
at?: string;
|
|
1617
|
+
reset?: boolean;
|
|
1618
|
+
restore?: string;
|
|
1619
|
+
seed?: number | string;
|
|
1620
|
+
time?: Instant | Date;
|
|
1621
|
+
advance?: Duration;
|
|
1622
|
+
virtualTime?: boolean;
|
|
1623
|
+
delay?: Duration;
|
|
1624
|
+
timeout?: Duration;
|
|
1625
|
+
/** A status, `"drop"`, a preset name, or a fault rule. */
|
|
1626
|
+
fault?: number | string | Record<string, unknown>;
|
|
1627
|
+
snapshot?: string;
|
|
1104
1628
|
};
|
|
1105
1629
|
|
|
1106
1630
|
/**
|
|
@@ -1140,6 +1664,8 @@ type RequestLog = {
|
|
|
1140
1664
|
unmatched: boolean;
|
|
1141
1665
|
/** Set when a fault rule produced the response. */
|
|
1142
1666
|
faultId?: string;
|
|
1667
|
+
/** Milliseconds of injected wait: latency, fault delays and timeouts. Absent when none. */
|
|
1668
|
+
delayMs?: number;
|
|
1143
1669
|
/** Resource ids the handler touched (`userId`, `orderId`, …), when the service reports them. */
|
|
1144
1670
|
ids?: Record<string, string>;
|
|
1145
1671
|
/** Set when the service created a resource the request referred to but that did not exist. */
|
|
@@ -1185,6 +1711,12 @@ type JournalQuery = {
|
|
|
1185
1711
|
/** Only this namespace. Omit for every namespace, oldest first across all of them. */
|
|
1186
1712
|
namespace?: string;
|
|
1187
1713
|
operationId?: string;
|
|
1714
|
+
/** Only this HTTP method, case-insensitive. */
|
|
1715
|
+
method?: string;
|
|
1716
|
+
/** Only this exact path. */
|
|
1717
|
+
path?: string;
|
|
1718
|
+
/** Only requests this fault rule answered or shaped. */
|
|
1719
|
+
faultId?: string;
|
|
1188
1720
|
status?: number;
|
|
1189
1721
|
/** Only entries at or after this instant (epoch ms). */
|
|
1190
1722
|
since?: number;
|
|
@@ -1199,6 +1731,38 @@ type Journal = {
|
|
|
1199
1731
|
clear(namespace?: string): void;
|
|
1200
1732
|
};
|
|
1201
1733
|
|
|
1734
|
+
/**
|
|
1735
|
+
* Baseline response time, per namespace: how long every vendor request takes before any
|
|
1736
|
+
* fault is considered. Jitter draws from a stream the caller owns, one per namespace and
|
|
1737
|
+
* separate from the fault stream, so adding latency never shifts which requests a `rate`
|
|
1738
|
+
* fault hits.
|
|
1739
|
+
*/
|
|
1740
|
+
type LatencyRegistry = {
|
|
1741
|
+
get(namespace: string): LatencyState;
|
|
1742
|
+
set(namespace: string, state: LatencyState): LatencyState;
|
|
1743
|
+
/** Remove one namespace's latency, or every namespace's. */
|
|
1744
|
+
clear(namespace?: string): void;
|
|
1745
|
+
/** Milliseconds this request waits. Draws jitter, so call it once per request. */
|
|
1746
|
+
take(namespace: string, operationId: string | undefined): number;
|
|
1747
|
+
};
|
|
1748
|
+
|
|
1749
|
+
/** Clock state as the admin API reports it. */
|
|
1750
|
+
type ControlClock = ClockState & {
|
|
1751
|
+
/** `now`, as ISO-8601. */
|
|
1752
|
+
iso: string;
|
|
1753
|
+
/** Milliseconds the clock steps before every vendor request. */
|
|
1754
|
+
autoAdvanceMs: number;
|
|
1755
|
+
};
|
|
1756
|
+
/** One namespace's controls: the body of `GET /__admin/controls`. */
|
|
1757
|
+
type ControlState = {
|
|
1758
|
+
namespace: string;
|
|
1759
|
+
seed: number | string;
|
|
1760
|
+
clock: ControlClock;
|
|
1761
|
+
virtualTime: boolean;
|
|
1762
|
+
latency: LatencyState;
|
|
1763
|
+
faults: FaultListing[];
|
|
1764
|
+
};
|
|
1765
|
+
|
|
1202
1766
|
type AdminRequest = {
|
|
1203
1767
|
request: Request;
|
|
1204
1768
|
url: URL;
|
|
@@ -1215,6 +1779,17 @@ type AdminRoute = (request: AdminRequest) => Response | Promise<Response>;
|
|
|
1215
1779
|
* `:param` segments — e.g. `"POST /orders/:id/transition"`.
|
|
1216
1780
|
*/
|
|
1217
1781
|
type AdminRoutes = Record<string, AdminRoute>;
|
|
1782
|
+
/** What `GET /__admin/snapshots` lists for each snapshot. */
|
|
1783
|
+
type SnapshotInfo = {
|
|
1784
|
+
id: string;
|
|
1785
|
+
namespace: string;
|
|
1786
|
+
/** Stored rows in the snapshot. */
|
|
1787
|
+
records: number;
|
|
1788
|
+
/** The namespace clock when it was taken, epoch ms. */
|
|
1789
|
+
at: number;
|
|
1790
|
+
/** Whether `GET /snapshots/:id` can return it as a {@link SnapshotDocument}. */
|
|
1791
|
+
portable: boolean;
|
|
1792
|
+
};
|
|
1218
1793
|
|
|
1219
1794
|
/** Credential → namespace mapping behind `PUT /__admin/credentials`. */
|
|
1220
1795
|
type CredentialRegistry = {
|
|
@@ -1228,6 +1803,8 @@ type CredentialRegistry = {
|
|
|
1228
1803
|
}[];
|
|
1229
1804
|
};
|
|
1230
1805
|
|
|
1806
|
+
type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
|
|
1807
|
+
|
|
1231
1808
|
/**
|
|
1232
1809
|
* A point-in-time copy of everything a service namespace holds.
|
|
1233
1810
|
*
|
|
@@ -1414,8 +1991,16 @@ type PublishInput = {
|
|
|
1414
1991
|
id?: string;
|
|
1415
1992
|
};
|
|
1416
1993
|
type WebhookHub = {
|
|
1994
|
+
observeDeliveries(listener: (event: {
|
|
1995
|
+
namespace: string;
|
|
1996
|
+
state: string;
|
|
1997
|
+
deliveryId: string;
|
|
1998
|
+
}) => void): () => void;
|
|
1999
|
+
setTransportPolicy(policy: OwnedTransport): void;
|
|
1417
2000
|
pending(namespace: string): number;
|
|
1418
2001
|
snapshot(namespace: string): unknown;
|
|
2002
|
+
exportSnapshot(handle: unknown): unknown;
|
|
2003
|
+
importSnapshot(namespace: string, document: unknown): unknown;
|
|
1419
2004
|
restore(namespace: string, snapshot: unknown): void;
|
|
1420
2005
|
publish(input: PublishInput): WebhookMessage;
|
|
1421
2006
|
/** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
|
|
@@ -1428,7 +2013,7 @@ type WebhookHub = {
|
|
|
1428
2013
|
/** Run every pending retry (and release held reordered messages) now, and every retry those attempts schedule, until nothing is pending. */
|
|
1429
2014
|
flush(): Promise<void>;
|
|
1430
2015
|
/** Resolve once nothing is in flight. */
|
|
1431
|
-
idle(): Promise<void>;
|
|
2016
|
+
idle(namespace?: string): Promise<void>;
|
|
1432
2017
|
fault(namespace: string, fault: WebhookFault): void;
|
|
1433
2018
|
clear(namespace?: string): void;
|
|
1434
2019
|
};
|
|
@@ -1459,14 +2044,26 @@ type RuntimeOptions<T extends ServiceInstance> = {
|
|
|
1459
2044
|
sqlite?: SqliteClient$2;
|
|
1460
2045
|
/** Defaults to a live clock over `Date.now`. */
|
|
1461
2046
|
clock?: Clock;
|
|
1462
|
-
/** Seeds every random choice the runtime makes (fault rates). Default `0`. */
|
|
2047
|
+
/** Seeds every random choice the runtime makes (fault rates, jitter). Default `0`. */
|
|
1463
2048
|
seed?: number | string;
|
|
2049
|
+
/**
|
|
2050
|
+
* Admin controls to boot with: clock, latency, faults, a starting snapshot, credential
|
|
2051
|
+
* mappings and per-namespace overrides. `reset` returns a namespace to exactly this.
|
|
2052
|
+
*/
|
|
2053
|
+
adminControls?: MockControls;
|
|
1464
2054
|
/** Extra `GET /__admin/health` fields, such as the loaded corpus version. */
|
|
1465
2055
|
describe?: () => Record<string, unknown>;
|
|
1466
2056
|
/** Service-specific admin routes, given the runtime so they can reach any namespace. */
|
|
1467
2057
|
admin?: (runtime: ServiceRuntime<T>) => AdminRoutes;
|
|
1468
2058
|
/** Reserved tree for every internal HTTP endpoint, UI and namespace carrier. Default /__admin. */
|
|
1469
2059
|
adminPrefix?: string;
|
|
2060
|
+
/**
|
|
2061
|
+
* A namespace's clock was moved — by `/__admin/clock`, a header, a restore, a reset, or a
|
|
2062
|
+
* wait spent in virtual time. Run whatever the service schedules by that clock, so what
|
|
2063
|
+
* came due is seen at once and not on the next request. Moving the base clock in process
|
|
2064
|
+
* (`runtime.clock`) is the caller's own doing and is not reported here.
|
|
2065
|
+
*/
|
|
2066
|
+
onClockChange?: (namespace: string) => void;
|
|
1470
2067
|
/** Invalidate transient handles before replacing an existing instance's stored state. */
|
|
1471
2068
|
beforeRestore?: (instance: T) => void;
|
|
1472
2069
|
/** Require this value in `x-mockingbird-admin-key` on admin data routes. */
|
|
@@ -1484,7 +2081,10 @@ type RuntimeOptions<T extends ServiceInstance> = {
|
|
|
1484
2081
|
* `sigV4AccessKeyId`.
|
|
1485
2082
|
*/
|
|
1486
2083
|
credential?: (request: Request) => string | undefined;
|
|
1487
|
-
/**
|
|
2084
|
+
/**
|
|
2085
|
+
* Named faults, switched on with `POST /__admin/faults {"preset": "<name>"}`. They join the
|
|
2086
|
+
* standard presets every mock has; one with a standard name replaces it.
|
|
2087
|
+
*/
|
|
1488
2088
|
presets?: Record<string, FaultPreset>;
|
|
1489
2089
|
/** Outbound webhooks; adds the `/__admin/webhooks*` routes and clears on reset. */
|
|
1490
2090
|
webhooks?: WebhookHub;
|
|
@@ -1507,11 +2107,15 @@ type RuntimeOptions<T extends ServiceInstance> = {
|
|
|
1507
2107
|
type RuntimeIO = {
|
|
1508
2108
|
wallNow(): number;
|
|
1509
2109
|
monotonicNow(): number;
|
|
1510
|
-
|
|
2110
|
+
/** Wait on the wall clock. Rejects with the signal's reason when it aborts first. */
|
|
2111
|
+
sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
1511
2112
|
};
|
|
1512
2113
|
type ServiceTimelineState = Readonly<{
|
|
1513
2114
|
snapshot: NamespaceSnapshot;
|
|
1514
|
-
clock
|
|
2115
|
+
/** `pinned`: the namespace's clock was frozen itself, not just following a frozen base. */
|
|
2116
|
+
clock: Readonly<ClockState & {
|
|
2117
|
+
pinned?: boolean;
|
|
2118
|
+
}>;
|
|
1515
2119
|
rngState: number;
|
|
1516
2120
|
}>;
|
|
1517
2121
|
type ServiceCheckpoint = Checkpoint<ServiceTimelineState>;
|
|
@@ -1524,27 +2128,63 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
|
|
|
1524
2128
|
readonly sqlite: SqliteClient$2;
|
|
1525
2129
|
readonly clock: Clock;
|
|
1526
2130
|
readonly faults: FaultRegistry;
|
|
2131
|
+
/** Baseline response time per namespace. */
|
|
2132
|
+
readonly latency: LatencyRegistry;
|
|
1527
2133
|
readonly metrics: Metrics;
|
|
1528
2134
|
readonly journal: Journal;
|
|
1529
2135
|
readonly rng: Rng;
|
|
1530
2136
|
readonly credentials: CredentialRegistry;
|
|
1531
2137
|
/** The webhook hub, when the service has outbound webhooks. */
|
|
1532
2138
|
readonly webhooks: WebhookHub | undefined;
|
|
1533
|
-
/**
|
|
1534
|
-
|
|
2139
|
+
/**
|
|
2140
|
+
* A namespace's clock. Each follows the base clock, {@link ServiceRuntime.clock}, with an
|
|
2141
|
+
* offset and a freeze of its own, so moving one never moves another.
|
|
2142
|
+
*/
|
|
1535
2143
|
namespaceClock(namespace?: string): Clock;
|
|
1536
2144
|
namespaceOf(request: Request): string;
|
|
1537
2145
|
/** Opaque in-process checkpoint including records, controls and webhook history. */
|
|
1538
2146
|
fleetSnapshot(namespace: string): object;
|
|
1539
2147
|
fleetRestore(snapshot: unknown, namespace: string): void;
|
|
2148
|
+
fleetExport(snapshot: unknown): SnapshotDocument;
|
|
2149
|
+
fleetImport(namespace: string, document: unknown): object;
|
|
1540
2150
|
/** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
|
|
1541
2151
|
applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule>): FaultRule[];
|
|
1542
2152
|
/** The instance behind `namespace` (the default one when omitted), created on first use. */
|
|
1543
2153
|
instance(namespace?: string): T;
|
|
1544
2154
|
/** Public names of every namespace created so far. */
|
|
1545
2155
|
namespaces(): string[];
|
|
1546
|
-
/**
|
|
2156
|
+
/** Return one namespace to its boot state, or every namespace with `"*"`. */
|
|
1547
2157
|
reset(namespace?: string): Promise<void>;
|
|
2158
|
+
/** Reset a namespace and forget it, releasing everything it held. */
|
|
2159
|
+
dropNamespace(namespace: string): Promise<void>;
|
|
2160
|
+
/** A namespace's controls: seed, clock, virtual time, latency, faults and snapshots. */
|
|
2161
|
+
controls(namespace?: string): ControlState & {
|
|
2162
|
+
snapshots: SnapshotInfo[];
|
|
2163
|
+
};
|
|
2164
|
+
/** Apply a control document to a namespace. A given key replaces that control. */
|
|
2165
|
+
configure(controls: NamespaceControls, namespace?: string): ControlState & {
|
|
2166
|
+
snapshots: SnapshotInfo[];
|
|
2167
|
+
};
|
|
2168
|
+
/** Named snapshots of a namespace: records, clock, random streams, faults and latency. */
|
|
2169
|
+
readonly snapshots: {
|
|
2170
|
+
/** Capture the namespace now. Reusing a name replaces that snapshot. */
|
|
2171
|
+
create(options?: {
|
|
2172
|
+
name?: string;
|
|
2173
|
+
namespace?: string;
|
|
2174
|
+
}): SnapshotInfo;
|
|
2175
|
+
list(namespace?: string): SnapshotInfo[];
|
|
2176
|
+
/** The snapshot as portable JSON, to commit beside a suite or boot another mock from. */
|
|
2177
|
+
export(id: string, namespace?: string): SnapshotDocument;
|
|
2178
|
+
/** Store a document as a snapshot without restoring it. */
|
|
2179
|
+
import(document: SnapshotDocument, options?: {
|
|
2180
|
+
name?: string;
|
|
2181
|
+
namespace?: string;
|
|
2182
|
+
}): SnapshotInfo;
|
|
2183
|
+
restore(id: string, namespace?: string): void;
|
|
2184
|
+
delete(id: string, namespace?: string): boolean;
|
|
2185
|
+
};
|
|
2186
|
+
/** Request headers that carry controls, checked: spread them into a `fetch` or an SDK's defaults. */
|
|
2187
|
+
headers(input: ControlHeaderInput): Record<string, string>;
|
|
1548
2188
|
snapshot(namespace?: string): NamespaceSnapshot;
|
|
1549
2189
|
restore(snapshot: NamespaceSnapshot, namespace?: string): void;
|
|
1550
2190
|
/** Capture the current branch. Mutating HTTP calls do this automatically. */
|
|
@@ -1969,6 +2609,11 @@ type ProviderOptions = APIOptions & {
|
|
|
1969
2609
|
fallbackUser?: AuthFallback;
|
|
1970
2610
|
publicNamespace?: string;
|
|
1971
2611
|
adminPrefix?: string;
|
|
2612
|
+
/**
|
|
2613
|
+
* A seeded stream of `[0, 1)` that ids and tokens are minted from, so a run replays from
|
|
2614
|
+
* its seed. Default: the platform's randomness.
|
|
2615
|
+
*/
|
|
2616
|
+
random?: () => number;
|
|
1972
2617
|
};
|
|
1973
2618
|
/** Portable vendor API backed by the shared namespace; it owns no separate history or listener. */
|
|
1974
2619
|
declare class ProviderAPI {
|
|
@@ -2005,7 +2650,7 @@ declare class MongoAtlasAPI extends ProviderAPI {
|
|
|
2005
2650
|
reset(): Promise<void>;
|
|
2006
2651
|
}
|
|
2007
2652
|
|
|
2008
|
-
type MongoAtlasRuntimeOptions = Pick<RuntimeOptions<MongoAtlasAPI>, "sqlite" | "clock" | "seed" | "adminPrefix" | "adminKey" | "onLog" | "journalSize" | "maxCheckpoints"> & Pick<MongoAtlasAPIOptions, "fixtures" | "baseUrl" | "tokens">;
|
|
2653
|
+
type MongoAtlasRuntimeOptions = Pick<RuntimeOptions<MongoAtlasAPI>, "sqlite" | "clock" | "seed" | "adminPrefix" | "adminKey" | "adminControls" | "onLog" | "journalSize" | "maxCheckpoints"> & Pick<MongoAtlasAPIOptions, "fixtures" | "baseUrl" | "tokens">;
|
|
2009
2654
|
type MongoAtlasRuntime = ServiceRuntime<MongoAtlasAPI>;
|
|
2010
2655
|
|
|
2011
2656
|
declare const DEFAULT_PORT = 8905;
|