@crvouga/mockingbird-runtime 0.6.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/adapter-node.d.ts +31 -1
- package/dist/adapter-node.js +3 -3
- package/dist/authoring.d.ts +33 -1
- package/dist/authoring.js +2 -2
- package/dist/{chunk-SVG34QFE.js → chunk-BKXECY5O.js} +3 -3
- package/dist/{chunk-BK5KDNUE.js → chunk-CIJF35LX.js} +48 -26
- package/dist/{chunk-BK5KDNUE.js.map → chunk-CIJF35LX.js.map} +2 -2
- package/dist/{chunk-GAIPLMRY.js → chunk-MZMSHIAI.js} +223 -65
- package/dist/chunk-MZMSHIAI.js.map +7 -0
- package/dist/http-provider.js +3 -3
- package/dist/mqtt-broker/node.js +3 -3
- package/dist/mqtt-broker.d.ts +27 -1
- package/dist/mqtt-broker.js +3 -3
- package/dist/{server-SXO3PUBW.js → server-MIPFZS6D.js} +2 -2
- package/dist/{server-SXO3PUBW.js.map → server-MIPFZS6D.js.map} +2 -2
- package/dist/service/admin.js +1 -1
- package/dist/service.d.ts +34 -2
- package/dist/service.js +2 -2
- package/package.json +3 -3
- package/dist/chunk-GAIPLMRY.js.map +0 -7
- /package/dist/{chunk-SVG34QFE.js.map → chunk-BKXECY5O.js.map} +0 -0
package/dist/service/admin.js
CHANGED
package/dist/service.d.ts
CHANGED
|
@@ -174,6 +174,25 @@ type UpstreamOptions = {
|
|
|
174
174
|
};
|
|
175
175
|
declare const upstreamRequest: (request: Request, baseUrl: string) => Request;
|
|
176
176
|
|
|
177
|
+
/** An admission quota applied on the namespace clock. */
|
|
178
|
+
type FaultLimit = {
|
|
179
|
+
requests: number;
|
|
180
|
+
per: Duration;
|
|
181
|
+
key?: "namespace" | "credential";
|
|
182
|
+
window?: "fixed" | "sliding";
|
|
183
|
+
};
|
|
184
|
+
type LimitState = {
|
|
185
|
+
used: number;
|
|
186
|
+
windowStart: number | null;
|
|
187
|
+
windowResetsAt: number | null;
|
|
188
|
+
};
|
|
189
|
+
type LimitBucket = {
|
|
190
|
+
start: number;
|
|
191
|
+
used: number;
|
|
192
|
+
} | {
|
|
193
|
+
arrivals: number[];
|
|
194
|
+
};
|
|
195
|
+
|
|
177
196
|
/**
|
|
178
197
|
* Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
|
|
179
198
|
* request a percentage fault hits — is reproducible from a seed.
|
|
@@ -244,6 +263,8 @@ type FaultRule = {
|
|
|
244
263
|
* rules added through `POST /__admin/faults` default to the calling namespace.
|
|
245
264
|
*/
|
|
246
265
|
namespace?: string;
|
|
266
|
+
/** Admit at most this many matching requests per window. */
|
|
267
|
+
limit?: FaultLimit;
|
|
247
268
|
/** Let this many matching requests through first. */
|
|
248
269
|
after?: number;
|
|
249
270
|
/** Then fault only every nth matching request: `3` faults the 3rd, 6th, 9th. */
|
|
@@ -363,13 +384,17 @@ type FaultCandidate = {
|
|
|
363
384
|
* `undefined` for a body that is missing or not JSON. It must leave the request readable.
|
|
364
385
|
*/
|
|
365
386
|
readJson?: () => Promise<unknown>;
|
|
387
|
+
/** The service-specific credential, if it has one. */
|
|
388
|
+
credential?: () => string | undefined;
|
|
366
389
|
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
367
390
|
now?: number;
|
|
391
|
+
/** Read the clock again after asynchronous request matching. */
|
|
392
|
+
clockNow?: () => number;
|
|
368
393
|
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
369
394
|
wait?: (ms: number) => Promise<void>;
|
|
370
395
|
};
|
|
371
396
|
/** A stored rule and how often it was consulted. */
|
|
372
|
-
type FaultListing = FaultRule & {
|
|
397
|
+
type FaultListing = FaultRule & Partial<LimitState> & {
|
|
373
398
|
/** Faults left before the rule retires. `null` when it has no `count`. */
|
|
374
399
|
remaining: number | null;
|
|
375
400
|
/** Times the rule faulted a request. */
|
|
@@ -385,6 +410,7 @@ type FaultSnapshot = {
|
|
|
385
410
|
*/
|
|
386
411
|
rules: (FaultListing & {
|
|
387
412
|
position?: number;
|
|
413
|
+
limitBuckets?: [string, LimitBucket][];
|
|
388
414
|
})[];
|
|
389
415
|
/** How many `fault_<n>` ids the namespace has handed out. */
|
|
390
416
|
nextId?: number;
|
|
@@ -439,7 +465,7 @@ declare const normalizeFault: (input: unknown, context?: {
|
|
|
439
465
|
* registry used on its own: it serves `default`, and every other namespace gets a stream of
|
|
440
466
|
* its own from the same seed.
|
|
441
467
|
*/
|
|
442
|
-
declare const createFaultRegistry: (random?: Rng | ((namespace: string) => Rng), sleep?: (ms: number) => Promise<void
|
|
468
|
+
declare const createFaultRegistry: (random?: Rng | ((namespace: string) => Rng), sleep?: (ms: number) => Promise<void>, now?: (namespace: string) => number) => FaultRegistry;
|
|
443
469
|
|
|
444
470
|
/**
|
|
445
471
|
* The admin controls every mock shares, as one document.
|
|
@@ -2226,6 +2252,8 @@ type WebhookEndpoint = {
|
|
|
2226
2252
|
tags?: Record<string, string>;
|
|
2227
2253
|
/** The public URL the receiver verifies signatures against (Twilio), when it differs. */
|
|
2228
2254
|
signUrl?: string;
|
|
2255
|
+
/** Disable automatic retry attempts for this endpoint. Explicit replay remains available. */
|
|
2256
|
+
retry?: false;
|
|
2229
2257
|
headers?: Record<string, string>;
|
|
2230
2258
|
};
|
|
2231
2259
|
type WebhookMessage = {
|
|
@@ -2276,6 +2304,8 @@ type PublishInput = {
|
|
|
2276
2304
|
tags?: Record<string, string>;
|
|
2277
2305
|
/** Message-specific delivery headers, captured as part of durable message state. */
|
|
2278
2306
|
headers?: Record<string, string>;
|
|
2307
|
+
/** Additional delivery endpoint for this message only. */
|
|
2308
|
+
endpoint?: WebhookEndpoint;
|
|
2279
2309
|
/** Message id; generated when omitted. */
|
|
2280
2310
|
id?: string;
|
|
2281
2311
|
};
|
|
@@ -2382,6 +2412,8 @@ type RuntimeOptions<T extends ServiceInstance> = {
|
|
|
2382
2412
|
/** Reject unsupported forwarding surfaces before any network request. */
|
|
2383
2413
|
canForward?: (request: Request) => boolean;
|
|
2384
2414
|
upstreamRequest?: (request: Request, baseUrl: string) => Request;
|
|
2415
|
+
/** Return an emulated refusal before request fault rules are consumed. Read from a request clone. */
|
|
2416
|
+
beforeFaults?: (instance: T, request: Request) => Response | undefined | Promise<Response | undefined>;
|
|
2385
2417
|
/** Service name, e.g. `"junction"`. Also the default namespace's storage key. */
|
|
2386
2418
|
name: string;
|
|
2387
2419
|
/** Build the instance backing one namespace. Called once per namespace, on first use. */
|
package/dist/service.js
CHANGED
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
verifyOperations,
|
|
68
68
|
webhookAdminRoutes,
|
|
69
69
|
withNamespaceRollback
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-CIJF35LX.js";
|
|
71
71
|
import "./chunk-2KDYLZXC.js";
|
|
72
72
|
import {
|
|
73
73
|
ADMIN_CONTROL_PAGES,
|
|
@@ -129,7 +129,7 @@ import {
|
|
|
129
129
|
toBase64,
|
|
130
130
|
toHex,
|
|
131
131
|
upstreamRequest
|
|
132
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-MZMSHIAI.js";
|
|
133
133
|
import {
|
|
134
134
|
requestBaseUrl
|
|
135
135
|
} from "./chunk-U36J5GCB.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crvouga/mockingbird-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "The shared Mockingbird runtime every emulator service depends on: router, admin API and page, snapshots, faults and clock, installed once however many emulators an application uses.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -124,8 +124,8 @@
|
|
|
124
124
|
"graphql": "17.0.0",
|
|
125
125
|
"hono": "4.13.11",
|
|
126
126
|
"jose": "6.2.2",
|
|
127
|
-
"@crvouga/mockingbird-ui": "0.
|
|
128
|
-
"@crvouga/mockingbird-preview": "0.3.
|
|
127
|
+
"@crvouga/mockingbird-ui": "0.6.0",
|
|
128
|
+
"@crvouga/mockingbird-preview": "0.3.1"
|
|
129
129
|
},
|
|
130
130
|
"devDependencies": {
|
|
131
131
|
"@crvouga/mockingbird-adapter-node": "0.0.0-development",
|