@crvouga/mockingbird-runtime 0.0.0-stage → 0.0.2
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/README.md +131 -2
- package/dist/adapter-node.d.ts +2521 -0
- package/dist/adapter-node.js +6920 -0
- package/dist/adapter-node.js.map +7 -0
- package/dist/admin-ui.js +25 -0
- package/dist/admin-ui.js.map +7 -0
- package/dist/chunk-2KDYLZXC.js +118 -0
- package/dist/chunk-2KDYLZXC.js.map +7 -0
- package/dist/chunk-2Y25NPCV.js +1289 -0
- package/dist/chunk-2Y25NPCV.js.map +7 -0
- package/dist/chunk-4SAK6MQT.js +246 -0
- package/dist/chunk-4SAK6MQT.js.map +7 -0
- package/dist/chunk-ANCCZFF2.js +778 -0
- package/dist/chunk-ANCCZFF2.js.map +7 -0
- package/dist/chunk-EBGYPQPA.js +198 -0
- package/dist/chunk-EBGYPQPA.js.map +7 -0
- package/dist/chunk-EQLY2YOA.js +274 -0
- package/dist/chunk-EQLY2YOA.js.map +7 -0
- package/dist/chunk-G62YDIIJ.js +7664 -0
- package/dist/chunk-G62YDIIJ.js.map +7 -0
- package/dist/chunk-HU6IOAFC.js +437 -0
- package/dist/chunk-HU6IOAFC.js.map +7 -0
- package/dist/chunk-RNAHPNUJ.js +97 -0
- package/dist/chunk-RNAHPNUJ.js.map +7 -0
- package/dist/chunk-UP4QOSFD.js +87 -0
- package/dist/chunk-UP4QOSFD.js.map +7 -0
- package/dist/chunk-XNS34BPF.js +2489 -0
- package/dist/chunk-XNS34BPF.js.map +7 -0
- package/dist/core.d.ts +356 -0
- package/dist/core.js +51 -0
- package/dist/core.js.map +7 -0
- package/dist/crypto-XS5XCMRJ.js +21 -0
- package/dist/crypto-XS5XCMRJ.js.map +7 -0
- package/dist/helpers-UD7CG4WQ.js +18 -0
- package/dist/helpers-UD7CG4WQ.js.map +7 -0
- package/dist/http-codec.d.ts +72 -0
- package/dist/http-codec.js +25 -0
- package/dist/http-codec.js.map +7 -0
- package/dist/http-provider.d.ts +3243 -0
- package/dist/http-provider.js +37920 -0
- package/dist/http-provider.js.map +7 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +7 -0
- package/dist/mqtt-broker/node.d.ts +632 -0
- package/dist/mqtt-broker/node.js +355 -0
- package/dist/mqtt-broker/node.js.map +7 -0
- package/dist/mqtt-broker.d.ts +990 -0
- package/dist/mqtt-broker.js +913 -0
- package/dist/mqtt-broker.js.map +7 -0
- package/dist/openapi-metadata.d.ts +290 -0
- package/dist/openapi-metadata.js +28 -0
- package/dist/openapi-metadata.js.map +7 -0
- package/dist/openapi.d.ts +252 -0
- package/dist/openapi.js +45 -0
- package/dist/openapi.js.map +7 -0
- package/dist/preview/artifacts.d.ts +19 -0
- package/dist/preview/artifacts.js +40 -0
- package/dist/preview/artifacts.js.map +7 -0
- package/dist/preview/bridge.d.ts +21 -0
- package/dist/preview/bridge.js +9 -0
- package/dist/preview/bridge.js.map +7 -0
- package/dist/preview/harness.d.ts +12 -0
- package/dist/preview/harness.js +65 -0
- package/dist/preview/harness.js.map +7 -0
- package/dist/preview/host.d.ts +30 -0
- package/dist/preview/host.js +70 -0
- package/dist/preview/host.js.map +7 -0
- package/dist/service/admin.d.ts +106 -0
- package/dist/service/admin.js +340 -0
- package/dist/service/admin.js.map +7 -0
- package/dist/service.d.ts +2665 -0
- package/dist/service.js +264 -0
- package/dist/service.js.map +7 -0
- package/dist/sqlite.d.ts +69 -0
- package/dist/sqlite.js +19 -0
- package/dist/sqlite.js.map +7 -0
- package/dist/ui.d.ts +37 -0
- package/dist/ui.js +702 -0
- package/dist/ui.js.map +7 -0
- package/package.json +135 -4
|
@@ -0,0 +1,2521 @@
|
|
|
1
|
+
import { Server } from 'node:http';
|
|
2
|
+
|
|
3
|
+
type MountedAPI = FetchAPI$1 & {
|
|
4
|
+
readonly prefix: string;
|
|
5
|
+
GET: FetchHandler;
|
|
6
|
+
POST: FetchHandler;
|
|
7
|
+
PUT: FetchHandler;
|
|
8
|
+
PATCH: FetchHandler;
|
|
9
|
+
DELETE: FetchHandler;
|
|
10
|
+
HEAD: FetchHandler;
|
|
11
|
+
OPTIONS: FetchHandler;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** A stable identifier for a point in a {@link Timeline}. */
|
|
15
|
+
type CheckpointId = string;
|
|
16
|
+
/** An immutable node in a timeline's checkpoint DAG. */
|
|
17
|
+
type Checkpoint<T> = Readonly<{
|
|
18
|
+
id: CheckpointId;
|
|
19
|
+
branch: string;
|
|
20
|
+
parent: CheckpointId | null;
|
|
21
|
+
/** Logical time supplied by the timeline's injected clock. */
|
|
22
|
+
at: number;
|
|
23
|
+
value: T;
|
|
24
|
+
}>;
|
|
25
|
+
type TimelineOptions = {
|
|
26
|
+
/** Logical clock used to stamp checkpoints. Defaults to a deterministic counter. */
|
|
27
|
+
now?: () => number;
|
|
28
|
+
/** Maximum retained checkpoints. Branch heads are never collected. Default 1,000. */
|
|
29
|
+
maxCheckpoints?: number;
|
|
30
|
+
/** Customize deterministic checkpoint IDs. */
|
|
31
|
+
id?: (sequence: number) => CheckpointId;
|
|
32
|
+
};
|
|
33
|
+
type CommitOptions = {
|
|
34
|
+
branch?: string;
|
|
35
|
+
/** Parent checkpoint. Defaults to the selected branch's current head. */
|
|
36
|
+
parent?: CheckpointId | null;
|
|
37
|
+
};
|
|
38
|
+
type ForkOptions = {
|
|
39
|
+
/** Checkpoint to fork from. Defaults to the main branch's head. */
|
|
40
|
+
from?: CheckpointId;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Small, storage-agnostic checkpoint DAG shared by service runtimes. Its values may be immutable
|
|
44
|
+
* records, namespace images, or copy-on-write SQL engine snapshots.
|
|
45
|
+
*
|
|
46
|
+
* Values are retained by reference. Engines can therefore use persistent/COW snapshots while
|
|
47
|
+
* simpler services can use immutable values. IDs and GC order are deterministic, and all IO
|
|
48
|
+
* (the logical clock) is injected.
|
|
49
|
+
*/
|
|
50
|
+
declare class Timeline<T> {
|
|
51
|
+
readonly maxCheckpoints: number;
|
|
52
|
+
private readonly now;
|
|
53
|
+
private readonly makeId;
|
|
54
|
+
private readonly nodes;
|
|
55
|
+
private readonly heads;
|
|
56
|
+
/** Unreferenced nodes in the exact order they became collectible. */
|
|
57
|
+
private readonly evictable;
|
|
58
|
+
/** Branch heads plus explicit retainers. Absent means zero. */
|
|
59
|
+
private readonly references;
|
|
60
|
+
private readonly explicitPins;
|
|
61
|
+
private sequence;
|
|
62
|
+
constructor(options?: TimelineOptions);
|
|
63
|
+
/** Capture a new immutable value and move `branch` to it. */
|
|
64
|
+
commit(value: T, options?: CommitOptions): Checkpoint<T>;
|
|
65
|
+
/** Create a branch pointer without copying its checkpoint value. */
|
|
66
|
+
fork(branch: string, options?: ForkOptions): Checkpoint<T> | undefined;
|
|
67
|
+
/** Move a branch pointer to an existing checkpoint. */
|
|
68
|
+
checkout(branch: string, id: CheckpointId): Checkpoint<T>;
|
|
69
|
+
get(id: CheckpointId): Checkpoint<T>;
|
|
70
|
+
head(branch?: string): Checkpoint<T> | undefined;
|
|
71
|
+
hasBranch(branch: string): boolean;
|
|
72
|
+
branches(): Readonly<Record<string, CheckpointId>>;
|
|
73
|
+
checkpoints(): readonly Checkpoint<T>[];
|
|
74
|
+
/** Number of retained checkpoints without allocating an array. */
|
|
75
|
+
get size(): number;
|
|
76
|
+
/** Pin a checkpoint independently of branch heads (used by compatibility snapshot handles). */
|
|
77
|
+
retain(id: CheckpointId): Checkpoint<T>;
|
|
78
|
+
/** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
|
|
79
|
+
release(id: CheckpointId): boolean;
|
|
80
|
+
deleteBranch(branch: string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Deterministically discard oldest unpinned checkpoints. Collection is O(number removed):
|
|
83
|
+
* commits never scan pinned nodes or the retained history. Parents are metadata rather than a
|
|
84
|
+
* storage dependency, so a retained node remains usable after pruning.
|
|
85
|
+
*/
|
|
86
|
+
gc(max?: number): CheckpointId[];
|
|
87
|
+
private collect;
|
|
88
|
+
private moveHead;
|
|
89
|
+
private addReference;
|
|
90
|
+
private removeReference;
|
|
91
|
+
private assertBranch;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Anything that can answer a Fetch `Request` with a `Response`.
|
|
96
|
+
*
|
|
97
|
+
* Every Mockingbird service implements this, and every runtime adapter consumes it.
|
|
98
|
+
* It is the only contract shared across the whole graph.
|
|
99
|
+
*/
|
|
100
|
+
interface FetchAPI$1 {
|
|
101
|
+
fetch(request: Request): Promise<Response>;
|
|
102
|
+
}
|
|
103
|
+
/** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
|
|
104
|
+
type FetchHandler = (request: Request) => Promise<Response>;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The single source of time for a service.
|
|
108
|
+
*
|
|
109
|
+
* Every timestamp a mock writes reads from here, so a suite moves time instead of
|
|
110
|
+
* sleeping: appointment windows, result delays and expiries become reachable in
|
|
111
|
+
* milliseconds. A frozen clock also makes timestamps reproducible from a seed.
|
|
112
|
+
*/
|
|
113
|
+
type ClockState = {
|
|
114
|
+
/** Current epoch milliseconds. */
|
|
115
|
+
now: number;
|
|
116
|
+
/** True while time does not advance on its own. */
|
|
117
|
+
frozen: boolean;
|
|
118
|
+
/** Milliseconds a running clock adds to its underlying source. `0` while frozen. */
|
|
119
|
+
offsetMs: number;
|
|
120
|
+
};
|
|
121
|
+
type Clock = {
|
|
122
|
+
now(): number;
|
|
123
|
+
/** Pin the clock to an exact instant, keeping it frozen if it already was. */
|
|
124
|
+
set(epochMs: number): void;
|
|
125
|
+
/** Move the clock forward, or back with a negative delta. */
|
|
126
|
+
advance(deltaMs: number): void;
|
|
127
|
+
/** Stop time at the current instant. */
|
|
128
|
+
freeze(): void;
|
|
129
|
+
/** Resume from the current instant. */
|
|
130
|
+
unfreeze(): void;
|
|
131
|
+
/** Drop back to the underlying source, live. */
|
|
132
|
+
reset(): void;
|
|
133
|
+
state(): ClockState;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
type UpstreamState = {
|
|
137
|
+
mode: "emulated" | "forward";
|
|
138
|
+
baseUrl: string;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
|
|
143
|
+
* request a percentage fault hits — is reproducible from a seed.
|
|
144
|
+
*
|
|
145
|
+
* mulberry32: small, fast, and stable across runtimes, which matters more here
|
|
146
|
+
* than statistical quality.
|
|
147
|
+
*/
|
|
148
|
+
type Rng = {
|
|
149
|
+
/** Next value in `[0, 1)`. */
|
|
150
|
+
next(): number;
|
|
151
|
+
/** Next integer in `[min, max]`. */
|
|
152
|
+
int(min: number, max: number): number;
|
|
153
|
+
/** Restart the stream from its seed. */
|
|
154
|
+
reset(): void;
|
|
155
|
+
/** Serializable engine state used by deterministic checkpoints. */
|
|
156
|
+
state(): number;
|
|
157
|
+
/** Restore a state previously returned by {@link state}. */
|
|
158
|
+
setState(state: number): void;
|
|
159
|
+
/** Restart the stream from a new seed. `reset` then returns to this seed. */
|
|
160
|
+
reseed(seed: number | string): void;
|
|
161
|
+
/** The seed the stream currently starts from. */
|
|
162
|
+
readonly seed: number;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* A deliberate failure injected in front of an operation.
|
|
167
|
+
*
|
|
168
|
+
* This is how a suite reaches the vendor's failure modes without the vendor: the
|
|
169
|
+
* quota error that only appears when a shared sandbox is full, the 429 that only
|
|
170
|
+
* appears under load, the 5xx that proves a retry path works.
|
|
171
|
+
*
|
|
172
|
+
* A rule has three parts. What it **matches** (`operationId`, `method`, `path`, …), **when**
|
|
173
|
+
* it fires among the matching requests (`after`, `every`, `count`, `rate`, `from`, `until`),
|
|
174
|
+
* and what it **does** (`status`, `delay`, `timeout`, `drop`, `truncate`, `effect`).
|
|
175
|
+
*/
|
|
176
|
+
type FaultRule = {
|
|
177
|
+
/** Stable id, so a suite can retire exactly the rule it added. Unique within a namespace. */
|
|
178
|
+
id: string;
|
|
179
|
+
/** Fault only this operation. Omit to match every operation. */
|
|
180
|
+
operationId?: string;
|
|
181
|
+
/** Fault only this HTTP method, case-insensitive. Omit to match every method. */
|
|
182
|
+
method?: string;
|
|
183
|
+
/** Fault only this exact path. */
|
|
184
|
+
path?: string;
|
|
185
|
+
/** Fault only paths starting with this prefix. Omit to match every path. */
|
|
186
|
+
pathPrefix?: string;
|
|
187
|
+
/** Fault only paths matching this regular expression (JavaScript syntax, unanchored). */
|
|
188
|
+
pathPattern?: string;
|
|
189
|
+
/** Fault only requests carrying these headers. `"*"` matches any value. */
|
|
190
|
+
requestHeaders?: Record<string, string>;
|
|
191
|
+
/** Fault only requests carrying these query parameters. `"*"` matches any value. */
|
|
192
|
+
query?: Record<string, string>;
|
|
193
|
+
/**
|
|
194
|
+
* Fault only requests whose JSON body carries these fields. Each key is a dotted path into
|
|
195
|
+
* the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
|
|
196
|
+
* and each value is what the field must equal: a string, number, boolean or `null`, compared
|
|
197
|
+
* strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
|
|
198
|
+
* is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
|
|
199
|
+
* response a rule injects.
|
|
200
|
+
*/
|
|
201
|
+
requestBody?: Record<string, RequestBodyValue>;
|
|
202
|
+
/**
|
|
203
|
+
* Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
|
|
204
|
+
* an in-process caller usually wants, and what a parallel worker usually does not:
|
|
205
|
+
* rules added through `POST /__admin/faults` default to the calling namespace.
|
|
206
|
+
*/
|
|
207
|
+
namespace?: string;
|
|
208
|
+
/** Let this many matching requests through first. */
|
|
209
|
+
after?: number;
|
|
210
|
+
/** Then fault only every nth matching request: `3` faults the 3rd, 6th, 9th. */
|
|
211
|
+
every?: number;
|
|
212
|
+
/** Retire the rule after this many faults. Omit to keep it until removed. */
|
|
213
|
+
count?: number;
|
|
214
|
+
/** Fault this fraction of the remaining requests, `0`–`1`, drawn from the seed. Default `1`. */
|
|
215
|
+
rate?: number;
|
|
216
|
+
/**
|
|
217
|
+
* Fault only from this instant on the namespace clock. A duration (`"5m"`) counts from the
|
|
218
|
+
* clock when the rule was added. Listed as epoch ms.
|
|
219
|
+
*/
|
|
220
|
+
from?: Instant | Duration;
|
|
221
|
+
/** Stop faulting at this instant on the namespace clock. A duration counts from when added. */
|
|
222
|
+
until?: Instant | Duration;
|
|
223
|
+
/**
|
|
224
|
+
* Status of the injected response. Omit for a rule that only delays, times out, drops,
|
|
225
|
+
* truncates, or switches on an `effect`: the request then still reaches the service.
|
|
226
|
+
*/
|
|
227
|
+
status?: number;
|
|
228
|
+
/** Response body, serialized as JSON. A string is sent as-is. */
|
|
229
|
+
body?: unknown;
|
|
230
|
+
/** Response headers. */
|
|
231
|
+
headers?: Record<string, string>;
|
|
232
|
+
/** Hold the response back this long. Listed as `delayMs`. */
|
|
233
|
+
delay?: Duration;
|
|
234
|
+
/** `delay`, in milliseconds. */
|
|
235
|
+
delayMs?: number;
|
|
236
|
+
/** Alias of `delayMs`. */
|
|
237
|
+
latencyMs?: number;
|
|
238
|
+
/** Extra seeded delay in `[0, jitter]`. Listed as `jitterMs`. */
|
|
239
|
+
jitter?: Duration;
|
|
240
|
+
jitterMs?: number;
|
|
241
|
+
/**
|
|
242
|
+
* Never answer: hold the request this long, then drop the connection. Listed as
|
|
243
|
+
* `timeoutMs`. With virtual time the wait is spent on the mock clock.
|
|
244
|
+
*/
|
|
245
|
+
timeout?: Duration;
|
|
246
|
+
timeoutMs?: number;
|
|
247
|
+
/**
|
|
248
|
+
* Drop the connection instead of answering: an in-process `fetch` rejects with a
|
|
249
|
+
* `TypeError`, and a served mock destroys the socket. Models "unknown outcome" failures.
|
|
250
|
+
*/
|
|
251
|
+
drop?: boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Cut the response body off after this many bytes: the status and headers arrive, then
|
|
254
|
+
* the connection dies mid-body.
|
|
255
|
+
*/
|
|
256
|
+
truncate?: number;
|
|
257
|
+
/**
|
|
258
|
+
* A named service behaviour to switch on for the matching request instead of (or
|
|
259
|
+
* before) a canned response, e.g. `created_but_500` or `numeric_tracking_id`. Services
|
|
260
|
+
* read it with `faultEffects(request)`.
|
|
261
|
+
*/
|
|
262
|
+
effect?: string;
|
|
263
|
+
/** Parameters for `effect`. */
|
|
264
|
+
params?: Record<string, unknown>;
|
|
265
|
+
/** The preset this rule was expanded from, if any. */
|
|
266
|
+
fromPreset?: string;
|
|
267
|
+
};
|
|
268
|
+
/** What a field of the request body must equal in {@link FaultRule.requestBody}. */
|
|
269
|
+
type RequestBodyValue = string | number | boolean | null;
|
|
270
|
+
/** A fault that fired for one request. */
|
|
271
|
+
type FaultHit = {
|
|
272
|
+
id: string;
|
|
273
|
+
/** The injected response; absent when the rule only delays, drops, or sets an effect. */
|
|
274
|
+
response?: Response;
|
|
275
|
+
drop?: boolean;
|
|
276
|
+
/** Set with `drop` when the rule held the request for its `timeout` first. */
|
|
277
|
+
timeout?: boolean;
|
|
278
|
+
/** Bytes of response body to let through before the connection dies. */
|
|
279
|
+
truncate?: number;
|
|
280
|
+
effect?: {
|
|
281
|
+
name: string;
|
|
282
|
+
params: Record<string, unknown>;
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
/** What a request looks like to the fault matcher. */
|
|
286
|
+
type FaultCandidate = {
|
|
287
|
+
operationId: string | undefined;
|
|
288
|
+
method: string;
|
|
289
|
+
path: string;
|
|
290
|
+
namespace: string;
|
|
291
|
+
/** Request headers and query, for rules that match on them. */
|
|
292
|
+
headers?: Headers;
|
|
293
|
+
query?: URLSearchParams;
|
|
294
|
+
/**
|
|
295
|
+
* The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
|
|
296
|
+
* `undefined` for a body that is missing or not JSON. It must leave the request readable.
|
|
297
|
+
*/
|
|
298
|
+
readJson?: () => Promise<unknown>;
|
|
299
|
+
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
300
|
+
now?: number;
|
|
301
|
+
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
302
|
+
wait?: (ms: number) => Promise<void>;
|
|
303
|
+
};
|
|
304
|
+
/** A stored rule and how often it was consulted. */
|
|
305
|
+
type FaultListing = FaultRule & {
|
|
306
|
+
/** Faults left before the rule retires. `null` when it has no `count`. */
|
|
307
|
+
remaining: number | null;
|
|
308
|
+
/** Times the rule faulted a request. */
|
|
309
|
+
hits: number;
|
|
310
|
+
/** Requests that matched the rule, faulted or not. */
|
|
311
|
+
seen: number;
|
|
312
|
+
};
|
|
313
|
+
/** A namespace's own rules, with their counters, in the order they are tried. */
|
|
314
|
+
type FaultSnapshot = {
|
|
315
|
+
/**
|
|
316
|
+
* `position` is how many `"*"` rules are tried before the rule, which is what its place
|
|
317
|
+
* in the order means to a request and holds in any process.
|
|
318
|
+
*/
|
|
319
|
+
rules: (FaultListing & {
|
|
320
|
+
position?: number;
|
|
321
|
+
})[];
|
|
322
|
+
/** How many `fault_<n>` ids the namespace has handed out. */
|
|
323
|
+
nextId?: number;
|
|
324
|
+
};
|
|
325
|
+
type FaultRegistry = {
|
|
326
|
+
snapshot(namespace: string): FaultSnapshot;
|
|
327
|
+
/** Add a rule, or replace the rule with the same id in the same namespace. */
|
|
328
|
+
add(rule: FaultRule): FaultRule;
|
|
329
|
+
/** The next unused `fault_<n>` id in `namespace`. */
|
|
330
|
+
nextId(namespace: string): string;
|
|
331
|
+
/** Every rule, or the rules a namespace's requests can hit: its own and the global ones. */
|
|
332
|
+
list(namespace?: string): FaultListing[];
|
|
333
|
+
get(id: string, namespace?: string): FaultListing | undefined;
|
|
334
|
+
/** Remove a rule by id: from `namespace` (its own, then a global one), or wherever it is. */
|
|
335
|
+
remove(id: string, namespace?: string): boolean;
|
|
336
|
+
/** Remove every rule, or one namespace's own rules. */
|
|
337
|
+
clear(namespace?: string): void;
|
|
338
|
+
/** Replace a namespace's own rules with a snapshot's, wherever the snapshot was taken. */
|
|
339
|
+
restore(namespace: string, state: FaultSnapshot): void;
|
|
340
|
+
/**
|
|
341
|
+
* Every fault this request should get, in rule order, stopping at the first that answers
|
|
342
|
+
* or drops (effect-only and delay-only rules let later rules match too). Consumes one of
|
|
343
|
+
* each matching rule's remaining uses.
|
|
344
|
+
*/
|
|
345
|
+
take(candidate: FaultCandidate): Promise<FaultHit[]>;
|
|
346
|
+
/**
|
|
347
|
+
* Fire these rules at one request without storing them: no matching, no schedule, in order,
|
|
348
|
+
* stopping at the first that answers or drops. Jitter draws from the namespace's stream.
|
|
349
|
+
*/
|
|
350
|
+
fire(rules: readonly FaultRule[], candidate: FaultCandidate): Promise<FaultHit[]>;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* The admin controls every mock shares, as one document.
|
|
355
|
+
*
|
|
356
|
+
* The same shape is accepted in three places, and means the same thing in each:
|
|
357
|
+
*
|
|
358
|
+
* - at boot: `createRuntime({ adminControls })`, `serve --admin-controls`,
|
|
359
|
+
* `MOCKINGBIRD_ADMIN_CONTROLS`
|
|
360
|
+
* - over HTTP: `PUT /__admin/controls`
|
|
361
|
+
* - per request: the `x-mockingbird-*` headers in {@link CONTROL_HEADERS}
|
|
362
|
+
*
|
|
363
|
+
* Every control is deterministic: given the same seed, clock and requests, a mock answers
|
|
364
|
+
* the same bytes. Nothing here reads the wall clock or `Math.random`.
|
|
365
|
+
*/
|
|
366
|
+
/** Milliseconds, or a string like `"250ms"`, `"2s"`, `"15m"`, `"1h"`, `"3d"`. */
|
|
367
|
+
type Duration = number | string;
|
|
368
|
+
/** Epoch milliseconds, or an ISO-8601 string. */
|
|
369
|
+
type Instant = number | string;
|
|
370
|
+
type ClockControls = {
|
|
371
|
+
/** Move the clock to this instant. */
|
|
372
|
+
now?: Instant;
|
|
373
|
+
/** Stop time. A frozen clock moves only when told to, so timestamps replay exactly. */
|
|
374
|
+
frozen?: boolean;
|
|
375
|
+
/**
|
|
376
|
+
* Step the clock forward by this much before every vendor request. With a frozen clock
|
|
377
|
+
* each request still gets its own, reproducible timestamp.
|
|
378
|
+
*/
|
|
379
|
+
autoAdvance?: Duration;
|
|
380
|
+
};
|
|
381
|
+
/** How long a response takes: a fixed delay plus seeded jitter in `[0, jitter]`. */
|
|
382
|
+
type LatencyRuleInput = {
|
|
383
|
+
delay?: Duration;
|
|
384
|
+
jitter?: Duration;
|
|
385
|
+
};
|
|
386
|
+
type LatencyControls = LatencyRuleInput & {
|
|
387
|
+
/** Per-operation overrides, keyed by operationId. A bare duration is its `delay`. */
|
|
388
|
+
operations?: Record<string, Duration | LatencyRuleInput>;
|
|
389
|
+
};
|
|
390
|
+
/** A fault to add: a rule (the id is assigned when omitted), or a named preset with overrides. */
|
|
391
|
+
type FaultInput = (Omit<FaultRule, "id"> & {
|
|
392
|
+
id?: string;
|
|
393
|
+
}) | ({
|
|
394
|
+
preset: string;
|
|
395
|
+
} & Partial<FaultRule>);
|
|
396
|
+
/** Identifies a {@link SnapshotDocument}. */
|
|
397
|
+
declare const SNAPSHOT_FORMAT = "mockingbird.snapshot/v1";
|
|
398
|
+
/**
|
|
399
|
+
* A namespace, as portable JSON: what `GET /__admin/snapshots/:id` returns and what
|
|
400
|
+
* `PUT /__admin/snapshots/:id` and the boot `snapshot` control accept. Only `format` and
|
|
401
|
+
* `records` are required, so a hand-written seed file is a valid snapshot.
|
|
402
|
+
*/
|
|
403
|
+
type SnapshotDocument = {
|
|
404
|
+
upstream?: UpstreamState;
|
|
405
|
+
format: typeof SNAPSHOT_FORMAT;
|
|
406
|
+
/** The service that wrote it. A snapshot is rejected by any other service. */
|
|
407
|
+
service?: string;
|
|
408
|
+
/**
|
|
409
|
+
* Stored rows. `seq` orders a collection; omitted, rows keep their listed order. `raw` is
|
|
410
|
+
* the stored text of a row that is not a plain record, and replaces `value` when present.
|
|
411
|
+
*/
|
|
412
|
+
records: {
|
|
413
|
+
collection: string;
|
|
414
|
+
id: string;
|
|
415
|
+
seq?: number;
|
|
416
|
+
value?: unknown;
|
|
417
|
+
raw?: string;
|
|
418
|
+
}[];
|
|
419
|
+
/** Id counters, so the next generated id continues where the snapshot left off. */
|
|
420
|
+
sequences?: {
|
|
421
|
+
name: string;
|
|
422
|
+
kind: string;
|
|
423
|
+
value: number;
|
|
424
|
+
}[];
|
|
425
|
+
clock?: {
|
|
426
|
+
now: number;
|
|
427
|
+
frozen: boolean;
|
|
428
|
+
autoAdvanceMs?: number;
|
|
429
|
+
};
|
|
430
|
+
seed?: number | string;
|
|
431
|
+
/** Positions of the seeded random streams. */
|
|
432
|
+
rng?: {
|
|
433
|
+
state: number;
|
|
434
|
+
faults?: number;
|
|
435
|
+
latency?: number;
|
|
436
|
+
};
|
|
437
|
+
faults?: unknown;
|
|
438
|
+
latency?: unknown;
|
|
439
|
+
virtualTime?: boolean;
|
|
440
|
+
/** Quiescent webhook endpoints, delivery history and fault state. Contains private configuration. */
|
|
441
|
+
webhooks?: unknown;
|
|
442
|
+
};
|
|
443
|
+
/** Controls for one namespace. */
|
|
444
|
+
type NamespaceControls = {
|
|
445
|
+
/** Seeds every random choice: fault rates, jitter, and whatever the service invents. */
|
|
446
|
+
seed?: number | string;
|
|
447
|
+
clock?: ClockControls;
|
|
448
|
+
/**
|
|
449
|
+
* Spend injected waits (latency, fault delays, timeouts) on the mock clock instead of the
|
|
450
|
+
* wall clock: the request returns at once, the clock has moved, and the journal records
|
|
451
|
+
* the wait exactly. Default `false`: waits are real, so a client's own timeout can fire.
|
|
452
|
+
*/
|
|
453
|
+
virtualTime?: boolean;
|
|
454
|
+
/** Baseline response time for every vendor request. A bare duration is its `delay`. */
|
|
455
|
+
latency?: Duration | LatencyControls;
|
|
456
|
+
faults?: readonly FaultInput[];
|
|
457
|
+
/** Start from this state instead of the service's own seed data. */
|
|
458
|
+
snapshot?: SnapshotDocument;
|
|
459
|
+
};
|
|
460
|
+
/** {@link NamespaceControls} for every namespace, with per-namespace overrides. */
|
|
461
|
+
type MockControls = NamespaceControls & {
|
|
462
|
+
/** Vendor credential → namespace, for SDKs that cannot send a namespace header. */
|
|
463
|
+
credentials?: Record<string, string>;
|
|
464
|
+
/** Overrides for named namespaces. A key given here replaces the shared value. */
|
|
465
|
+
namespaces?: Record<string, NamespaceControls>;
|
|
466
|
+
};
|
|
467
|
+
/** A latency rule in milliseconds. */
|
|
468
|
+
type LatencyRule = {
|
|
469
|
+
delayMs: number;
|
|
470
|
+
jitterMs: number;
|
|
471
|
+
};
|
|
472
|
+
/** Baseline latency for a namespace, normalized. */
|
|
473
|
+
type LatencyState = LatencyRule & {
|
|
474
|
+
operations: Record<string, LatencyRule>;
|
|
475
|
+
};
|
|
476
|
+
/** What {@link controlHeaders} turns into request headers. */
|
|
477
|
+
type ControlHeaderInput = {
|
|
478
|
+
upstream?: "emulated" | "forward";
|
|
479
|
+
namespace?: string;
|
|
480
|
+
adminKey?: string;
|
|
481
|
+
branch?: string;
|
|
482
|
+
at?: string;
|
|
483
|
+
reset?: boolean;
|
|
484
|
+
restore?: string;
|
|
485
|
+
seed?: number | string;
|
|
486
|
+
time?: Instant | Date;
|
|
487
|
+
advance?: Duration;
|
|
488
|
+
virtualTime?: boolean;
|
|
489
|
+
delay?: Duration;
|
|
490
|
+
timeout?: Duration;
|
|
491
|
+
/** A status, `"drop"`, a preset name, or a fault rule. */
|
|
492
|
+
fault?: number | string | Record<string, unknown>;
|
|
493
|
+
snapshot?: string;
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
497
|
+
type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
|
|
498
|
+
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
499
|
+
type SqliteRunResult = {
|
|
500
|
+
changes: number;
|
|
501
|
+
lastInsertRowid: number | bigint;
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* Prepared statement bound to a {@link SqliteClient}.
|
|
505
|
+
*
|
|
506
|
+
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
507
|
+
*/
|
|
508
|
+
interface SqliteStatement {
|
|
509
|
+
run(...params: SqliteValue[]): SqliteRunResult;
|
|
510
|
+
all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
|
|
511
|
+
get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Sync SQLite client port owned by Mockingbird.
|
|
515
|
+
*
|
|
516
|
+
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
517
|
+
* `bun:sqlite` instances all work when they expose this surface.
|
|
518
|
+
*/
|
|
519
|
+
interface SqliteClient {
|
|
520
|
+
exec(sql: string): void;
|
|
521
|
+
prepare(sql: string): SqliteStatement;
|
|
522
|
+
transaction<T>(fn: () => T): T;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
|
|
527
|
+
* `kind` is `media_type` when the body is present but its media type is not one the operation
|
|
528
|
+
* accepts (a `415` on most vendors), `syntax` when it could not be decoded, `required` when
|
|
529
|
+
* the operation needs a body and none arrived, and `schema` for a contract violation.
|
|
530
|
+
*/
|
|
531
|
+
type BodyIssue = {
|
|
532
|
+
path: string;
|
|
533
|
+
message: string;
|
|
534
|
+
kind?: "media_type" | "syntax" | "required" | "schema";
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* What the mock received from a request it rejected, so a 4xx can be attributed after the
|
|
539
|
+
* fact (an empty body, a missing `content-type`, a schema violation) without logging the body.
|
|
540
|
+
*/
|
|
541
|
+
type RejectedRequest = {
|
|
542
|
+
/** The raw `content-type` header, or `null` when the request sent none. */
|
|
543
|
+
contentType: string | null;
|
|
544
|
+
/** Bytes of body received from `content-length` (`0` for none), or `null` when the client sent no length (a streamed / chunked body). */
|
|
545
|
+
bodyBytes: number | null;
|
|
546
|
+
/** The raw `transfer-encoding` header (`chunked`), or `null`. */
|
|
547
|
+
transferEncoding: string | null;
|
|
548
|
+
};
|
|
549
|
+
/** One handled request, as the structured log sees it. */
|
|
550
|
+
type RequestLog = {
|
|
551
|
+
upstream?: boolean;
|
|
552
|
+
service: string;
|
|
553
|
+
namespace: string;
|
|
554
|
+
operationId: string | undefined;
|
|
555
|
+
method: string;
|
|
556
|
+
path: string;
|
|
557
|
+
status: number;
|
|
558
|
+
durationMs: number;
|
|
559
|
+
/** True when the path matched no operation in the contract. */
|
|
560
|
+
unmatched: boolean;
|
|
561
|
+
/** Set when a fault rule produced the response. */
|
|
562
|
+
faultId?: string;
|
|
563
|
+
/** Milliseconds of injected wait: latency, fault delays and timeouts. Absent when none. */
|
|
564
|
+
delayMs?: number;
|
|
565
|
+
/** Resource ids the handler touched (`userId`, `orderId`, …), when the service reports them. */
|
|
566
|
+
ids?: Record<string, string>;
|
|
567
|
+
/** Set when the service created a resource the request referred to but that did not exist. */
|
|
568
|
+
adopted?: boolean;
|
|
569
|
+
/** Explicit durable acceptance, independent of response delivery. */
|
|
570
|
+
accepted?: boolean;
|
|
571
|
+
/** Checkpoint captured at explicit acceptance. */
|
|
572
|
+
checkpoint?: string;
|
|
573
|
+
/** Set on a rejection (status ≥ 400) the mock produced itself, never on a scripted fault. */
|
|
574
|
+
request?: RejectedRequest;
|
|
575
|
+
/** The validation issues behind a rejection, when the service found any. */
|
|
576
|
+
issues?: BodyIssue[];
|
|
577
|
+
};
|
|
578
|
+
type MetricsReport = {
|
|
579
|
+
requests: number;
|
|
580
|
+
/** Counts keyed `<operationId> <status>`. */
|
|
581
|
+
byOperation: Record<string, number>;
|
|
582
|
+
/**
|
|
583
|
+
* Paths that matched no operation, most frequent first.
|
|
584
|
+
*
|
|
585
|
+
* This is the early-warning signal: a consumer calling something the mock does
|
|
586
|
+
* not implement shows up here as a count, before it fails a suite as a 404.
|
|
587
|
+
*/
|
|
588
|
+
unmatched: {
|
|
589
|
+
method: string;
|
|
590
|
+
path: string;
|
|
591
|
+
count: number;
|
|
592
|
+
}[];
|
|
593
|
+
faults: number;
|
|
594
|
+
totalDurationMs: number;
|
|
595
|
+
};
|
|
596
|
+
type Metrics = {
|
|
597
|
+
record(entry: RequestLog): void;
|
|
598
|
+
report(namespace?: string): MetricsReport;
|
|
599
|
+
reset(namespace?: string): void;
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
/** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
|
|
603
|
+
type JournalEntry = RequestLog & {
|
|
604
|
+
at: string;
|
|
605
|
+
};
|
|
606
|
+
type JournalQuery = {
|
|
607
|
+
/** Only this namespace. Omit for every namespace, oldest first across all of them. */
|
|
608
|
+
namespace?: string;
|
|
609
|
+
operationId?: string;
|
|
610
|
+
/** Only this HTTP method, case-insensitive. */
|
|
611
|
+
method?: string;
|
|
612
|
+
/** Only this exact path. */
|
|
613
|
+
path?: string;
|
|
614
|
+
/** Only requests this fault rule answered or shaped. */
|
|
615
|
+
faultId?: string;
|
|
616
|
+
status?: number;
|
|
617
|
+
/** Only entries at or after this instant (epoch ms). */
|
|
618
|
+
since?: number;
|
|
619
|
+
/** At most this many, the most recent kept. */
|
|
620
|
+
limit?: number;
|
|
621
|
+
};
|
|
622
|
+
type Journal = {
|
|
623
|
+
readonly size: number;
|
|
624
|
+
record(entry: JournalEntry): void;
|
|
625
|
+
list(query?: JournalQuery): JournalEntry[];
|
|
626
|
+
/** Forget one namespace's entries, or every namespace's. */
|
|
627
|
+
clear(namespace?: string): void;
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Baseline response time, per namespace: how long every vendor request takes before any
|
|
632
|
+
* fault is considered. Jitter draws from a stream the caller owns, one per namespace and
|
|
633
|
+
* separate from the fault stream, so adding latency never shifts which requests a `rate`
|
|
634
|
+
* fault hits.
|
|
635
|
+
*/
|
|
636
|
+
type LatencyRegistry = {
|
|
637
|
+
get(namespace: string): LatencyState;
|
|
638
|
+
set(namespace: string, state: LatencyState): LatencyState;
|
|
639
|
+
/** Remove one namespace's latency, or every namespace's. */
|
|
640
|
+
clear(namespace?: string): void;
|
|
641
|
+
/** Milliseconds this request waits. Draws jitter, so call it once per request. */
|
|
642
|
+
take(namespace: string, operationId: string | undefined): number;
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
/** Clock state as the admin API reports it. */
|
|
646
|
+
type ControlClock = ClockState & {
|
|
647
|
+
/** `now`, as ISO-8601. */
|
|
648
|
+
iso: string;
|
|
649
|
+
/** Milliseconds the clock steps before every vendor request. */
|
|
650
|
+
autoAdvanceMs: number;
|
|
651
|
+
};
|
|
652
|
+
/** One namespace's controls: the body of `GET /__admin/controls`. */
|
|
653
|
+
type ControlState = {
|
|
654
|
+
namespace: string;
|
|
655
|
+
seed: number | string;
|
|
656
|
+
clock: ControlClock;
|
|
657
|
+
virtualTime: boolean;
|
|
658
|
+
latency: LatencyState;
|
|
659
|
+
faults: FaultListing[];
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
/** What `GET /__admin/snapshots` lists for each snapshot. */
|
|
663
|
+
type SnapshotInfo = {
|
|
664
|
+
id: string;
|
|
665
|
+
namespace: string;
|
|
666
|
+
/** Stored rows in the snapshot. */
|
|
667
|
+
records: number;
|
|
668
|
+
/** The namespace clock when it was taken, epoch ms. */
|
|
669
|
+
at: number;
|
|
670
|
+
/** Whether `GET /snapshots/:id` can return it as a {@link SnapshotDocument}. */
|
|
671
|
+
portable: boolean;
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
/** Credential → namespace mapping behind `PUT /__admin/credentials`. */
|
|
675
|
+
type CredentialRegistry = {
|
|
676
|
+
set(credential: string, namespace: string): void;
|
|
677
|
+
get(credential: string): string | undefined;
|
|
678
|
+
remove(credential: string): boolean;
|
|
679
|
+
clear(): void;
|
|
680
|
+
entries(): {
|
|
681
|
+
credential: string;
|
|
682
|
+
namespace: string;
|
|
683
|
+
}[];
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* A point-in-time copy of everything a service namespace holds.
|
|
688
|
+
*
|
|
689
|
+
* All service state lives in the two core tables keyed by namespace, so a snapshot
|
|
690
|
+
* is generic: any service gets per-test rollback without knowing its own schema.
|
|
691
|
+
* Restoring is much cheaper than rebuilding a namespace from a corpus.
|
|
692
|
+
*/
|
|
693
|
+
type NamespaceSnapshot = {
|
|
694
|
+
namespace: string;
|
|
695
|
+
records: {
|
|
696
|
+
collection: string;
|
|
697
|
+
id: string;
|
|
698
|
+
seq: number;
|
|
699
|
+
value: string;
|
|
700
|
+
}[];
|
|
701
|
+
sequences: {
|
|
702
|
+
name: string;
|
|
703
|
+
kind: string;
|
|
704
|
+
value: number;
|
|
705
|
+
}[];
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
declare const STATE_FIELD_KINDS: readonly ["string", "number", "boolean", "null", "object", "array", "unknown"];
|
|
709
|
+
type StateFieldKind = (typeof STATE_FIELD_KINDS)[number];
|
|
710
|
+
/** JSON-safe annotations a bespoke admin UI may read. The default UI shows them as text. */
|
|
711
|
+
type StateMeta = Readonly<Record<string, string | number | boolean | null>>;
|
|
712
|
+
type StateField = {
|
|
713
|
+
name: string;
|
|
714
|
+
kind: StateFieldKind;
|
|
715
|
+
optional: boolean;
|
|
716
|
+
description?: string;
|
|
717
|
+
/** One level of nested object fields. */
|
|
718
|
+
fields?: StateField[];
|
|
719
|
+
meta?: StateMeta;
|
|
720
|
+
};
|
|
721
|
+
type StateCollectionView = {
|
|
722
|
+
name: string;
|
|
723
|
+
label: string;
|
|
724
|
+
description?: string;
|
|
725
|
+
count: number;
|
|
726
|
+
/** `mixed` when a declaration and stored rows both contribute fields. */
|
|
727
|
+
source: "declared" | "inferred" | "mixed";
|
|
728
|
+
fields: StateField[];
|
|
729
|
+
meta?: StateMeta;
|
|
730
|
+
};
|
|
731
|
+
/** The shape of one namespace, for an admin UI that has never seen the service before. */
|
|
732
|
+
type StateView = {
|
|
733
|
+
namespace: string;
|
|
734
|
+
storageNamespace: string;
|
|
735
|
+
collections: StateCollectionView[];
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
|
|
740
|
+
* which derives the base from the wall clock when the runtime is created.
|
|
741
|
+
*/
|
|
742
|
+
type IdBase = number | string;
|
|
743
|
+
|
|
744
|
+
/** Policy only for runtime-owned HTTP sends; it does not sandbox DNS or arbitrary sockets. */
|
|
745
|
+
type OutboundPolicy = {
|
|
746
|
+
mode: "offline" | "allowlist";
|
|
747
|
+
origins?: string[];
|
|
748
|
+
maxRedirects?: number;
|
|
749
|
+
maxBodyBytes?: number;
|
|
750
|
+
onReject?(event: {
|
|
751
|
+
namespace: string;
|
|
752
|
+
policy: string;
|
|
753
|
+
reason: string;
|
|
754
|
+
}): void;
|
|
755
|
+
};
|
|
756
|
+
type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
|
|
757
|
+
declare function ownedTransport(policy: OutboundPolicy): OwnedTransport;
|
|
758
|
+
|
|
759
|
+
type WebhookEndpoint = {
|
|
760
|
+
/** Stable id; generated when omitted. */
|
|
761
|
+
id?: string;
|
|
762
|
+
url: string;
|
|
763
|
+
secret?: string;
|
|
764
|
+
/** Event types to deliver; omit or include `"*"` for every type. */
|
|
765
|
+
events?: string[];
|
|
766
|
+
/** Deliver only messages whose tags include all of these (e.g. `{ account: "mso" }`). */
|
|
767
|
+
tags?: Record<string, string>;
|
|
768
|
+
/** The public URL the receiver verifies signatures against (Twilio), when it differs. */
|
|
769
|
+
signUrl?: string;
|
|
770
|
+
headers?: Record<string, string>;
|
|
771
|
+
};
|
|
772
|
+
type WebhookMessage = {
|
|
773
|
+
id: string;
|
|
774
|
+
namespace: string;
|
|
775
|
+
type: string;
|
|
776
|
+
body: string;
|
|
777
|
+
contentType: string;
|
|
778
|
+
tags: Record<string, string>;
|
|
779
|
+
headers?: Record<string, string>;
|
|
780
|
+
/** Wall-clock ISO-8601 time of publication. */
|
|
781
|
+
publishedAt: string;
|
|
782
|
+
};
|
|
783
|
+
type WebhookAttempt = {
|
|
784
|
+
attempt: number;
|
|
785
|
+
at: string;
|
|
786
|
+
status: number | null;
|
|
787
|
+
error: string | null;
|
|
788
|
+
durationMs: number;
|
|
789
|
+
/** Exact receiver response body, when one was returned. */
|
|
790
|
+
responseBody?: string | null;
|
|
791
|
+
};
|
|
792
|
+
type WebhookDelivery = {
|
|
793
|
+
id: string;
|
|
794
|
+
messageId: string;
|
|
795
|
+
namespace: string;
|
|
796
|
+
type: string;
|
|
797
|
+
endpointId: string;
|
|
798
|
+
url: string;
|
|
799
|
+
state: "pending" | "delivered" | "failed" | "dropped";
|
|
800
|
+
attempts: WebhookAttempt[];
|
|
801
|
+
};
|
|
802
|
+
/** A delivery-level fault: what happens to the next `count` messages in a namespace. */
|
|
803
|
+
type WebhookFault = {
|
|
804
|
+
mode: "duplicate" | "reorder" | "drop";
|
|
805
|
+
/** Messages affected; default 1. */
|
|
806
|
+
count?: number;
|
|
807
|
+
};
|
|
808
|
+
type PublishInput = {
|
|
809
|
+
namespace: string;
|
|
810
|
+
type: string;
|
|
811
|
+
/** Exact body; objects are JSON-encoded. */
|
|
812
|
+
body: string | Record<string, unknown> | unknown[];
|
|
813
|
+
/** Default `application/json`, or form-encoded when `form` is given. */
|
|
814
|
+
contentType?: string;
|
|
815
|
+
/** Form parameters, when the vendor posts `application/x-www-form-urlencoded`. */
|
|
816
|
+
form?: Record<string, string>;
|
|
817
|
+
tags?: Record<string, string>;
|
|
818
|
+
/** Message-specific delivery headers, captured as part of durable message state. */
|
|
819
|
+
headers?: Record<string, string>;
|
|
820
|
+
/** Message id; generated when omitted. */
|
|
821
|
+
id?: string;
|
|
822
|
+
};
|
|
823
|
+
type WebhookHub = {
|
|
824
|
+
observeDeliveries(listener: (event: {
|
|
825
|
+
namespace: string;
|
|
826
|
+
state: string;
|
|
827
|
+
deliveryId: string;
|
|
828
|
+
}) => void): () => void;
|
|
829
|
+
setTransportPolicy(policy: OwnedTransport): void;
|
|
830
|
+
pending(namespace: string): number;
|
|
831
|
+
snapshot(namespace: string): unknown;
|
|
832
|
+
exportSnapshot(handle: unknown): unknown;
|
|
833
|
+
importSnapshot(namespace: string, document: unknown): unknown;
|
|
834
|
+
restore(namespace: string, snapshot: unknown): void;
|
|
835
|
+
publish(input: PublishInput): WebhookMessage;
|
|
836
|
+
/** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
|
|
837
|
+
setEndpoints(namespace: string, endpoints: WebhookEndpoint[]): WebhookEndpoint[];
|
|
838
|
+
/** The endpoints a namespace delivers to: its own, plus the global ones. */
|
|
839
|
+
endpoints(namespace: string): WebhookEndpoint[];
|
|
840
|
+
messages(namespace?: string): WebhookMessage[];
|
|
841
|
+
deliveries(namespace?: string): WebhookDelivery[];
|
|
842
|
+
replay(deliveryId: string): Promise<WebhookDelivery | undefined>;
|
|
843
|
+
/** Run every pending retry (and release held reordered messages) now, and every retry those attempts schedule, until nothing is pending. */
|
|
844
|
+
flush(): Promise<void>;
|
|
845
|
+
/** Resolve once nothing is in flight. */
|
|
846
|
+
idle(namespace?: string): Promise<void>;
|
|
847
|
+
fault(namespace: string, fault: WebhookFault): void;
|
|
848
|
+
clear(namespace?: string): void;
|
|
849
|
+
};
|
|
850
|
+
|
|
851
|
+
/** What the runtime needs from a service: a Fetch handler it can reset. */
|
|
852
|
+
type ServiceInstance = FetchAPI$1 & {
|
|
853
|
+
reset(): Promise<void>;
|
|
854
|
+
};
|
|
855
|
+
type ServiceTimelineState = Readonly<{
|
|
856
|
+
snapshot: NamespaceSnapshot;
|
|
857
|
+
/** `pinned`: the namespace's clock was frozen itself, not just following a frozen base. */
|
|
858
|
+
clock: Readonly<ClockState & {
|
|
859
|
+
pinned?: boolean;
|
|
860
|
+
}>;
|
|
861
|
+
rngState: number;
|
|
862
|
+
}>;
|
|
863
|
+
type ServiceCheckpoint = Checkpoint<ServiceTimelineState>;
|
|
864
|
+
type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
|
|
865
|
+
/** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
|
|
866
|
+
stop?(): void;
|
|
867
|
+
readonly name: string;
|
|
868
|
+
/** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
|
|
869
|
+
mount(prefix: string): MountedAPI;
|
|
870
|
+
readonly sqlite: SqliteClient;
|
|
871
|
+
readonly clock: Clock;
|
|
872
|
+
/**
|
|
873
|
+
* Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
|
|
874
|
+
* return the number it resolved to. Set it before the first request so a boot's ids stay
|
|
875
|
+
* one run.
|
|
876
|
+
*/
|
|
877
|
+
setIdBase(base: IdBase): number;
|
|
878
|
+
readonly faults: FaultRegistry;
|
|
879
|
+
/** Baseline response time per namespace. */
|
|
880
|
+
readonly latency: LatencyRegistry;
|
|
881
|
+
readonly metrics: Metrics;
|
|
882
|
+
readonly journal: Journal;
|
|
883
|
+
readonly rng: Rng;
|
|
884
|
+
readonly credentials: CredentialRegistry;
|
|
885
|
+
/** The webhook hub, when the service has outbound webhooks. */
|
|
886
|
+
readonly webhooks: WebhookHub | undefined;
|
|
887
|
+
/**
|
|
888
|
+
* A namespace's clock. Each follows the base clock, {@link ServiceRuntime.clock}, with an
|
|
889
|
+
* offset and a freeze of its own, so moving one never moves another.
|
|
890
|
+
*/
|
|
891
|
+
namespaceClock(namespace?: string): Clock;
|
|
892
|
+
namespaceOf(request: Request): string;
|
|
893
|
+
/** Opaque in-process checkpoint including records, controls and webhook history. */
|
|
894
|
+
fleetSnapshot(namespace: string): object;
|
|
895
|
+
fleetRestore(snapshot: unknown, namespace: string): void;
|
|
896
|
+
fleetExport(snapshot: unknown): SnapshotDocument;
|
|
897
|
+
fleetImport(namespace: string, document: unknown): object;
|
|
898
|
+
/** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
|
|
899
|
+
applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule>): FaultRule[];
|
|
900
|
+
/** The instance behind `namespace` (the default one when omitted), created on first use. */
|
|
901
|
+
instance(namespace?: string): T;
|
|
902
|
+
/** Public names of every namespace created so far. */
|
|
903
|
+
namespaces(): string[];
|
|
904
|
+
/** Return one namespace to its boot state, or every namespace with `"*"`. */
|
|
905
|
+
reset(namespace?: string): Promise<void>;
|
|
906
|
+
/** Reset a namespace and forget it, releasing everything it held. */
|
|
907
|
+
dropNamespace(namespace: string): Promise<void>;
|
|
908
|
+
/** A namespace's controls: seed, clock, virtual time, latency, faults and snapshots. */
|
|
909
|
+
controls(namespace?: string): ControlState & {
|
|
910
|
+
snapshots: SnapshotInfo[];
|
|
911
|
+
};
|
|
912
|
+
/** Apply a control document to a namespace. A given key replaces that control. */
|
|
913
|
+
configure(controls: NamespaceControls, namespace?: string): ControlState & {
|
|
914
|
+
snapshots: SnapshotInfo[];
|
|
915
|
+
};
|
|
916
|
+
/** Named snapshots of a namespace: records, clock, random streams, faults and latency. */
|
|
917
|
+
readonly snapshots: {
|
|
918
|
+
/** Capture the namespace now. Reusing a name replaces that snapshot. */
|
|
919
|
+
create(options?: {
|
|
920
|
+
name?: string;
|
|
921
|
+
namespace?: string;
|
|
922
|
+
}): SnapshotInfo;
|
|
923
|
+
list(namespace?: string): SnapshotInfo[];
|
|
924
|
+
/** The snapshot as portable JSON, to commit beside a suite or boot another mock from. */
|
|
925
|
+
export(id: string, namespace?: string): SnapshotDocument;
|
|
926
|
+
/** Store a document as a snapshot without restoring it. */
|
|
927
|
+
import(document: SnapshotDocument, options?: {
|
|
928
|
+
name?: string;
|
|
929
|
+
namespace?: string;
|
|
930
|
+
}): SnapshotInfo;
|
|
931
|
+
restore(id: string, namespace?: string): void;
|
|
932
|
+
delete(id: string, namespace?: string): boolean;
|
|
933
|
+
};
|
|
934
|
+
/** Request headers that carry controls, checked: spread them into a `fetch` or an SDK's defaults. */
|
|
935
|
+
headers(input: ControlHeaderInput): Record<string, string>;
|
|
936
|
+
snapshot(namespace?: string): NamespaceSnapshot;
|
|
937
|
+
restore(snapshot: NamespaceSnapshot, namespace?: string): void;
|
|
938
|
+
/** Capture the current branch. Mutating HTTP calls do this automatically. */
|
|
939
|
+
checkpoint(namespace?: string, branch?: string): ServiceCheckpoint;
|
|
940
|
+
/** Create an isolated branch, optionally from a historical checkpoint. */
|
|
941
|
+
branch(name: string, options?: {
|
|
942
|
+
namespace?: string;
|
|
943
|
+
at?: string;
|
|
944
|
+
}): ServiceCheckpoint;
|
|
945
|
+
/** Restore a branch, clock, and PRNG to a checkpoint. */
|
|
946
|
+
checkout(checkpoint: string, options?: {
|
|
947
|
+
namespace?: string;
|
|
948
|
+
branch?: string;
|
|
949
|
+
}): void;
|
|
950
|
+
/** Inspect the retained history for a namespace. */
|
|
951
|
+
timeline(namespace?: string): Timeline<ServiceTimelineState>;
|
|
952
|
+
/** Collections in one namespace: declared shape plus what the rows actually hold. */
|
|
953
|
+
state(namespace?: string): StateView;
|
|
954
|
+
};
|
|
955
|
+
|
|
956
|
+
type FleetArchive = {
|
|
957
|
+
format: "mockingbird.fleet/v1";
|
|
958
|
+
createdAt: string;
|
|
959
|
+
sourceId: string;
|
|
960
|
+
/** Application-owned non-secret tags, independent of participant codecs. */
|
|
961
|
+
compatibility?: ArchiveCompatibilityTags;
|
|
962
|
+
namespaces: Record<string, {
|
|
963
|
+
clock: {
|
|
964
|
+
now: number;
|
|
965
|
+
frozen: boolean;
|
|
966
|
+
};
|
|
967
|
+
services: Record<string, {
|
|
968
|
+
protocol: "http" | "postgres" | "redis" | "external";
|
|
969
|
+
version: 1;
|
|
970
|
+
packageVersion?: string;
|
|
971
|
+
target?: string;
|
|
972
|
+
state: unknown;
|
|
973
|
+
}>;
|
|
974
|
+
}>;
|
|
975
|
+
sha256: string;
|
|
976
|
+
};
|
|
977
|
+
type ArchiveCompatibilityTags = Readonly<Record<string, string>>;
|
|
978
|
+
type ArchiveCompatibilityPolicy = {
|
|
979
|
+
tags: ArchiveCompatibilityTags;
|
|
980
|
+
/** Legacy archives are rejected by default when tags are required. */
|
|
981
|
+
missing?: "reject" | "allow";
|
|
982
|
+
};
|
|
983
|
+
declare function assertArchiveCompatibility(input: unknown, policy?: ArchiveCompatibilityPolicy): FleetArchive;
|
|
984
|
+
/** An explicit application migration works on a clone and produces a new verified identity. */
|
|
985
|
+
declare function migrateApplicationArchive(input: unknown, migration: {
|
|
986
|
+
from: ArchiveCompatibilityPolicy;
|
|
987
|
+
to: ArchiveCompatibilityTags;
|
|
988
|
+
transform(archive: FleetArchive): FleetArchive | Promise<FleetArchive>;
|
|
989
|
+
}): Promise<FleetArchive>;
|
|
990
|
+
declare function validateArchive(value: unknown): FleetArchive;
|
|
991
|
+
/** Read-only semantic summaries; values are omitted unless explicitly requested. */
|
|
992
|
+
declare function inspectArchive(input: unknown): {
|
|
993
|
+
namespaces: {
|
|
994
|
+
[k: string]: {
|
|
995
|
+
clock: {
|
|
996
|
+
now: number;
|
|
997
|
+
frozen: boolean;
|
|
998
|
+
};
|
|
999
|
+
services: {
|
|
1000
|
+
[k: string]: {
|
|
1001
|
+
protocol: "http" | "postgres" | "redis" | "external";
|
|
1002
|
+
version: 1;
|
|
1003
|
+
bytes: number;
|
|
1004
|
+
};
|
|
1005
|
+
};
|
|
1006
|
+
};
|
|
1007
|
+
};
|
|
1008
|
+
compatibility?: Readonly<Record<string, string>>;
|
|
1009
|
+
format: "mockingbird.fleet/v1";
|
|
1010
|
+
createdAt: string;
|
|
1011
|
+
sha256: string;
|
|
1012
|
+
};
|
|
1013
|
+
declare function diffArchives(left: unknown, right: unknown, options?: {
|
|
1014
|
+
namespace?: string;
|
|
1015
|
+
service?: string;
|
|
1016
|
+
values?: boolean;
|
|
1017
|
+
limit?: number;
|
|
1018
|
+
}): {
|
|
1019
|
+
format: string;
|
|
1020
|
+
total: number;
|
|
1021
|
+
truncated: boolean;
|
|
1022
|
+
changes: {
|
|
1023
|
+
namespace: string;
|
|
1024
|
+
service: string;
|
|
1025
|
+
path: string;
|
|
1026
|
+
kind: string;
|
|
1027
|
+
before?: unknown;
|
|
1028
|
+
after?: unknown;
|
|
1029
|
+
}[];
|
|
1030
|
+
};
|
|
1031
|
+
|
|
1032
|
+
/** Public readiness contract, usable before workspace packages have been built. */
|
|
1033
|
+
type EndpointManifest = {
|
|
1034
|
+
version: 1;
|
|
1035
|
+
capabilityVersion?: 1;
|
|
1036
|
+
state: "ready" | "recovery-required";
|
|
1037
|
+
pid: number;
|
|
1038
|
+
id: string;
|
|
1039
|
+
startedAt: string;
|
|
1040
|
+
adminBase: string;
|
|
1041
|
+
healthUrl: string;
|
|
1042
|
+
/** The dashboard's URL, when the fleet serves one. */
|
|
1043
|
+
dashboard?: string;
|
|
1044
|
+
services: Record<string, {
|
|
1045
|
+
protocol: "http" | "postgres" | "redis" | "external";
|
|
1046
|
+
url: string;
|
|
1047
|
+
healthUrl: string;
|
|
1048
|
+
adminUrl: string;
|
|
1049
|
+
namespaces: Record<string, unknown>;
|
|
1050
|
+
processReady: boolean;
|
|
1051
|
+
protocolReady: boolean;
|
|
1052
|
+
}>;
|
|
1053
|
+
};
|
|
1054
|
+
|
|
1055
|
+
type ProtectedArchive = {
|
|
1056
|
+
format: "mockingbird.jwe/v1";
|
|
1057
|
+
jwe: string;
|
|
1058
|
+
};
|
|
1059
|
+
type ArchiveProtector = {
|
|
1060
|
+
readonly policy: {
|
|
1061
|
+
format: string;
|
|
1062
|
+
activeKeyId: string;
|
|
1063
|
+
};
|
|
1064
|
+
seal(archive: FleetArchive): Promise<ProtectedArchive>;
|
|
1065
|
+
open(envelope: unknown): Promise<FleetArchive>;
|
|
1066
|
+
};
|
|
1067
|
+
type ProtectionOptions = {
|
|
1068
|
+
activeKeyId: string;
|
|
1069
|
+
trustedKeyIds: readonly string[];
|
|
1070
|
+
resolveKey(id: string): Promise<Uint8Array>;
|
|
1071
|
+
maxBytes?: number;
|
|
1072
|
+
};
|
|
1073
|
+
/** RFC 7516 compact JWE, RFC 7518 direct A256GCM; keys are resolved outside the archive. */
|
|
1074
|
+
declare function archiveProtector(options: ProtectionOptions): ArchiveProtector;
|
|
1075
|
+
|
|
1076
|
+
declare class FleetClientError extends Error {
|
|
1077
|
+
readonly status: number;
|
|
1078
|
+
readonly details: unknown;
|
|
1079
|
+
constructor(status: number, details: unknown);
|
|
1080
|
+
}
|
|
1081
|
+
declare class FleetClientResponseError extends FleetClientError {
|
|
1082
|
+
readonly code: "redirect" | "response_too_large" | "invalid_json";
|
|
1083
|
+
constructor(code: "redirect" | "response_too_large" | "invalid_json", status: number, origin?: string);
|
|
1084
|
+
}
|
|
1085
|
+
type FleetClientOptions = {
|
|
1086
|
+
adminKey?: string;
|
|
1087
|
+
namespace?: string;
|
|
1088
|
+
timeoutMs?: number;
|
|
1089
|
+
/** Custom adapters must honor redirect: manual and the supplied abort signal. */
|
|
1090
|
+
fetch?: typeof fetch;
|
|
1091
|
+
/** Decoded response byte limit; archives can explicitly select a larger limit. Default 64 MiB. */
|
|
1092
|
+
maxResponseBytes?: number;
|
|
1093
|
+
};
|
|
1094
|
+
/** Supported control client: credentials are headers; base URL includes the discovered prefix. */
|
|
1095
|
+
declare class FleetClient {
|
|
1096
|
+
readonly base: string;
|
|
1097
|
+
private readonly options;
|
|
1098
|
+
constructor(base: string, options?: FleetClientOptions);
|
|
1099
|
+
request<T = Record<string, unknown>>(path: string, options?: {
|
|
1100
|
+
method?: string;
|
|
1101
|
+
body?: unknown;
|
|
1102
|
+
namespace?: string;
|
|
1103
|
+
idempotencyKey?: string;
|
|
1104
|
+
signal?: AbortSignal;
|
|
1105
|
+
maxResponseBytes?: number;
|
|
1106
|
+
}): Promise<T>;
|
|
1107
|
+
discover(): Promise<{
|
|
1108
|
+
version: number;
|
|
1109
|
+
routes: {
|
|
1110
|
+
method: string;
|
|
1111
|
+
path: string;
|
|
1112
|
+
}[];
|
|
1113
|
+
manifest: EndpointManifest;
|
|
1114
|
+
}>;
|
|
1115
|
+
namespaces(): Promise<Record<string, unknown>>;
|
|
1116
|
+
createNamespace(namespace: string, baseline?: string): Promise<Record<string, unknown>>;
|
|
1117
|
+
deleteNamespace(namespace: string): Promise<Record<string, unknown>>;
|
|
1118
|
+
reset(namespace: string, options?: {
|
|
1119
|
+
services?: string[];
|
|
1120
|
+
idempotencyKey?: string;
|
|
1121
|
+
}): Promise<Record<string, unknown>>;
|
|
1122
|
+
snapshot(namespace: string, options?: {
|
|
1123
|
+
label?: string;
|
|
1124
|
+
services?: string[];
|
|
1125
|
+
idempotencyKey?: string;
|
|
1126
|
+
}): Promise<{
|
|
1127
|
+
id: string;
|
|
1128
|
+
}>;
|
|
1129
|
+
restore(namespace: string, id: string, idempotencyKey?: string): Promise<Record<string, unknown>>;
|
|
1130
|
+
exportArchive(namespace?: string, allNamespaces?: boolean): Promise<FleetArchive>;
|
|
1131
|
+
exportProtectedArchive(namespace?: string, allNamespaces?: boolean): Promise<ProtectedArchive>;
|
|
1132
|
+
importArchive(archive: FleetArchive | ProtectedArchive, namespace?: string): Promise<Record<string, unknown>>;
|
|
1133
|
+
operation(id: string): Promise<Record<string, unknown>>;
|
|
1134
|
+
}
|
|
1135
|
+
type ConnectionManifest = {
|
|
1136
|
+
version: 1;
|
|
1137
|
+
services: Record<string, {
|
|
1138
|
+
url: string;
|
|
1139
|
+
namespaces?: Record<string, string>;
|
|
1140
|
+
}>;
|
|
1141
|
+
};
|
|
1142
|
+
type ConnectionField = "url" | "hostname" | "port" | "username" | "password" | "pathname" | "database";
|
|
1143
|
+
type ConnectionMapping = Record<string, {
|
|
1144
|
+
service: string;
|
|
1145
|
+
field?: ConnectionField;
|
|
1146
|
+
fallback?: string;
|
|
1147
|
+
}>;
|
|
1148
|
+
/** Explicit variable mappings, with namespace-specific URLs taken from current discovery. */
|
|
1149
|
+
declare function renderConnections(manifest: EndpointManifest, privateManifest: ConnectionManifest, namespace: string, mapping: ConnectionMapping): Record<string, string>;
|
|
1150
|
+
declare function writeConnections(path: string, values: Record<string, string>, format?: "json" | "dotenv"): Promise<void>;
|
|
1151
|
+
|
|
1152
|
+
type FleetSubject = {
|
|
1153
|
+
manifest: EndpointManifest;
|
|
1154
|
+
connections: ConnectionManifest;
|
|
1155
|
+
client: FleetClient;
|
|
1156
|
+
close(): Promise<void>;
|
|
1157
|
+
};
|
|
1158
|
+
/** Launches a caller-selected installed service CLI without a shell or private workspace imports. */
|
|
1159
|
+
declare function launchFleet(command: readonly string[], config: MockingbirdConfig, options?: {
|
|
1160
|
+
cwd?: string;
|
|
1161
|
+
timeoutMs?: number;
|
|
1162
|
+
}): Promise<FleetSubject>;
|
|
1163
|
+
type ConformanceProbe = {
|
|
1164
|
+
declaredState: string[];
|
|
1165
|
+
excludedState: string[];
|
|
1166
|
+
populate(subject: FleetSubject, namespace: string): Promise<void>;
|
|
1167
|
+
observe(subject: FleetSubject, namespace: string): Promise<unknown>;
|
|
1168
|
+
continue(subject: FleetSubject, namespace: string): Promise<unknown>;
|
|
1169
|
+
injectFailure?(subject: FleetSubject, boundary: "capture" | "restore" | "rollback"): Promise<{
|
|
1170
|
+
request(): Promise<unknown>;
|
|
1171
|
+
verify(): Promise<void>;
|
|
1172
|
+
clear(): Promise<void>;
|
|
1173
|
+
}>;
|
|
1174
|
+
};
|
|
1175
|
+
/** Checks real public controls, deterministic continuation and namespace isolation across processes. */
|
|
1176
|
+
declare function participantConformance(factory: () => Promise<FleetSubject>, probe: ConformanceProbe, options?: {
|
|
1177
|
+
requireFreshProcess?: boolean;
|
|
1178
|
+
}): Promise<{
|
|
1179
|
+
version: number;
|
|
1180
|
+
passed: boolean;
|
|
1181
|
+
freshProcess: boolean;
|
|
1182
|
+
sourcePid: number;
|
|
1183
|
+
destinationPid: number;
|
|
1184
|
+
archive: string;
|
|
1185
|
+
declaredState: string[];
|
|
1186
|
+
exclusions: string[];
|
|
1187
|
+
checks: string[];
|
|
1188
|
+
}>;
|
|
1189
|
+
|
|
1190
|
+
type Observation = {
|
|
1191
|
+
id: number;
|
|
1192
|
+
namespace: string;
|
|
1193
|
+
service: string;
|
|
1194
|
+
kind: "http" | "webhook";
|
|
1195
|
+
method?: string;
|
|
1196
|
+
pathFingerprint?: string;
|
|
1197
|
+
operationId?: string;
|
|
1198
|
+
status?: number;
|
|
1199
|
+
unmatched?: boolean;
|
|
1200
|
+
fault?: boolean;
|
|
1201
|
+
deliveryState?: string;
|
|
1202
|
+
};
|
|
1203
|
+
type AssertionAllowance = {
|
|
1204
|
+
kind: "unmatched" | "rejected" | "fault";
|
|
1205
|
+
service: string;
|
|
1206
|
+
pathFingerprint?: string;
|
|
1207
|
+
operationId?: string;
|
|
1208
|
+
status?: number;
|
|
1209
|
+
maxCount: number;
|
|
1210
|
+
};
|
|
1211
|
+
type TraceEvent = {
|
|
1212
|
+
sequence: number;
|
|
1213
|
+
kind: "http" | "control";
|
|
1214
|
+
service?: string;
|
|
1215
|
+
method?: string;
|
|
1216
|
+
path?: string;
|
|
1217
|
+
body?: string;
|
|
1218
|
+
contentType?: string;
|
|
1219
|
+
status?: number;
|
|
1220
|
+
responseHash?: string;
|
|
1221
|
+
action?: "clock" | "reset";
|
|
1222
|
+
controls?: Record<string, unknown>;
|
|
1223
|
+
omitted: string[];
|
|
1224
|
+
};
|
|
1225
|
+
type FleetTrace = {
|
|
1226
|
+
format: "mockingbird.trace/v1";
|
|
1227
|
+
sourceProcess: string;
|
|
1228
|
+
namespace: string;
|
|
1229
|
+
baseline: FleetArchive;
|
|
1230
|
+
events: TraceEvent[];
|
|
1231
|
+
limitations: string[];
|
|
1232
|
+
truncated: boolean;
|
|
1233
|
+
active: boolean;
|
|
1234
|
+
};
|
|
1235
|
+
type TraceToken = {
|
|
1236
|
+
artifact: FleetTrace;
|
|
1237
|
+
event: TraceEvent;
|
|
1238
|
+
body: Promise<{
|
|
1239
|
+
text?: string;
|
|
1240
|
+
omitted: string[];
|
|
1241
|
+
}>;
|
|
1242
|
+
};
|
|
1243
|
+
declare class FleetObservations {
|
|
1244
|
+
private readonly processId;
|
|
1245
|
+
private readonly limits;
|
|
1246
|
+
private sequence;
|
|
1247
|
+
private readonly entries;
|
|
1248
|
+
private readonly baselines;
|
|
1249
|
+
private readonly traces;
|
|
1250
|
+
constructor(processId: string, limits?: {
|
|
1251
|
+
events: number;
|
|
1252
|
+
traceEvents: number;
|
|
1253
|
+
traceBytes: number;
|
|
1254
|
+
});
|
|
1255
|
+
record(event: Omit<Observation, "id">): void;
|
|
1256
|
+
baseline(namespace: string, services: string[]): {
|
|
1257
|
+
id: `${string}-${string}-${string}-${string}-${string}`;
|
|
1258
|
+
namespace: string;
|
|
1259
|
+
services: string[];
|
|
1260
|
+
sequence: number;
|
|
1261
|
+
};
|
|
1262
|
+
assertClean(id: string, namespace: string, diagnostics: Record<string, FleetDiagnostics>, options?: {
|
|
1263
|
+
allowances?: AssertionAllowance[];
|
|
1264
|
+
allowCheckpointablePending?: boolean;
|
|
1265
|
+
}): {
|
|
1266
|
+
format: string;
|
|
1267
|
+
clean: boolean;
|
|
1268
|
+
namespace: string;
|
|
1269
|
+
baseline: string;
|
|
1270
|
+
failures: unknown[];
|
|
1271
|
+
truncated: boolean;
|
|
1272
|
+
inspectedThrough: number;
|
|
1273
|
+
};
|
|
1274
|
+
startTrace(namespace: string, input: unknown, includeBodies?: boolean, limitations?: string[]): FleetTrace;
|
|
1275
|
+
private limitation;
|
|
1276
|
+
beginHTTP(namespace: string, service: string, request: Request, logicalPath?: string): TraceToken | undefined;
|
|
1277
|
+
finishHTTP(token: TraceToken | undefined, response: Response): Promise<void>;
|
|
1278
|
+
private append;
|
|
1279
|
+
unsupportedControl(namespace: string, action: string): void;
|
|
1280
|
+
control(namespace: string, action: "clock" | "reset", controls: Record<string, unknown>): void;
|
|
1281
|
+
trace(namespace: string, stop?: boolean): FleetTrace;
|
|
1282
|
+
}
|
|
1283
|
+
/** Replays only to discovered, explicitly selected synthetic endpoints in a different fleet. */
|
|
1284
|
+
declare function replayFleetTrace(trace: FleetTrace, subject: FleetSubject, options?: {
|
|
1285
|
+
allowIncomplete?: boolean;
|
|
1286
|
+
vendorHeaders?: Record<string, string>;
|
|
1287
|
+
allowedSyntheticOrigins?: string[];
|
|
1288
|
+
}): Promise<{
|
|
1289
|
+
version: number;
|
|
1290
|
+
matched: boolean;
|
|
1291
|
+
complete: boolean;
|
|
1292
|
+
limitations: string[];
|
|
1293
|
+
outcomes: {
|
|
1294
|
+
sequence: number;
|
|
1295
|
+
status?: number;
|
|
1296
|
+
matched: boolean;
|
|
1297
|
+
}[];
|
|
1298
|
+
baseline: string;
|
|
1299
|
+
}>;
|
|
1300
|
+
|
|
1301
|
+
type AuditEvent = {
|
|
1302
|
+
id: string;
|
|
1303
|
+
actor: string;
|
|
1304
|
+
namespace: string;
|
|
1305
|
+
action: string;
|
|
1306
|
+
services: string[];
|
|
1307
|
+
operationId?: string;
|
|
1308
|
+
stage: "denied" | "attempt" | "terminal";
|
|
1309
|
+
timestamp: string;
|
|
1310
|
+
result?: "succeeded" | "failed" | "cancelled";
|
|
1311
|
+
durable?: boolean;
|
|
1312
|
+
};
|
|
1313
|
+
type AuditPolicy = {
|
|
1314
|
+
write(event: AuditEvent): Promise<void>;
|
|
1315
|
+
failurePolicy: "open" | "closed";
|
|
1316
|
+
};
|
|
1317
|
+
type TelemetryEvent = {
|
|
1318
|
+
participant?: string;
|
|
1319
|
+
operationId: string;
|
|
1320
|
+
phase: string;
|
|
1321
|
+
action: string;
|
|
1322
|
+
services: string[];
|
|
1323
|
+
status: string;
|
|
1324
|
+
elapsedMs: number;
|
|
1325
|
+
recoveryRequired: boolean;
|
|
1326
|
+
};
|
|
1327
|
+
type InstrumentationOptions = {
|
|
1328
|
+
audit?: AuditPolicy;
|
|
1329
|
+
telemetry?(event: TelemetryEvent): void | Promise<void>;
|
|
1330
|
+
};
|
|
1331
|
+
declare class FleetInstrumentation {
|
|
1332
|
+
private readonly options;
|
|
1333
|
+
private readonly auditEntries;
|
|
1334
|
+
private readonly started;
|
|
1335
|
+
private readonly terminal;
|
|
1336
|
+
private readonly metrics;
|
|
1337
|
+
constructor(options?: InstrumentationOptions);
|
|
1338
|
+
audit(input: Omit<AuditEvent, "id" | "timestamp" | "durable">): Promise<boolean>;
|
|
1339
|
+
phase(operation: {
|
|
1340
|
+
id: string;
|
|
1341
|
+
participant?: string;
|
|
1342
|
+
phase: string;
|
|
1343
|
+
action: string;
|
|
1344
|
+
services?: string[];
|
|
1345
|
+
status: string;
|
|
1346
|
+
}, recoveryRequired: boolean): void;
|
|
1347
|
+
snapshot(): {
|
|
1348
|
+
version: number;
|
|
1349
|
+
metrics: {
|
|
1350
|
+
started: number;
|
|
1351
|
+
succeeded: number;
|
|
1352
|
+
failed: number;
|
|
1353
|
+
cancelled: number;
|
|
1354
|
+
recoveryRequired: number;
|
|
1355
|
+
phaseEvents: number;
|
|
1356
|
+
auditFailures: number;
|
|
1357
|
+
rollbackAttempts: number;
|
|
1358
|
+
rollbackFailures: number;
|
|
1359
|
+
telemetryFailures: number;
|
|
1360
|
+
durationsMs: {
|
|
1361
|
+
count: number;
|
|
1362
|
+
sum: number;
|
|
1363
|
+
max: number;
|
|
1364
|
+
};
|
|
1365
|
+
};
|
|
1366
|
+
cardinality: string;
|
|
1367
|
+
};
|
|
1368
|
+
auditTrail(): {
|
|
1369
|
+
version: number;
|
|
1370
|
+
entries: AuditEvent[];
|
|
1371
|
+
retention: number;
|
|
1372
|
+
durableSink: boolean;
|
|
1373
|
+
failurePolicy: string;
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
/** A repository must be independent of the application services being captured. */
|
|
1378
|
+
type ArchiveRepository = {
|
|
1379
|
+
readonly protectionPolicy?: ArchiveProtector["policy"];
|
|
1380
|
+
readonly writerGeneration?: number;
|
|
1381
|
+
publicationMetadata?(): Promise<{
|
|
1382
|
+
id: string;
|
|
1383
|
+
generation: number;
|
|
1384
|
+
verifiedAt: string;
|
|
1385
|
+
} | undefined>;
|
|
1386
|
+
put(archive: FleetArchive): Promise<string>;
|
|
1387
|
+
get(id: string): Promise<FleetArchive>;
|
|
1388
|
+
list(): Promise<string[]>;
|
|
1389
|
+
delete(id: string): Promise<void>;
|
|
1390
|
+
latest(): Promise<string | undefined>;
|
|
1391
|
+
publishLatest(id: string): Promise<void>;
|
|
1392
|
+
};
|
|
1393
|
+
declare function filesystemRepository(directory: string, maxBytes?: number, protection?: ArchiveProtector): ArchiveRepository;
|
|
1394
|
+
type S3RepositoryOptions = {
|
|
1395
|
+
protection?: ArchiveProtector;
|
|
1396
|
+
endpoint: string;
|
|
1397
|
+
bucket: string;
|
|
1398
|
+
region: string;
|
|
1399
|
+
accessKeyId: string;
|
|
1400
|
+
secretAccessKey: string;
|
|
1401
|
+
sessionToken?: string;
|
|
1402
|
+
prefix?: string;
|
|
1403
|
+
pathStyle?: boolean;
|
|
1404
|
+
maxBytes?: number;
|
|
1405
|
+
fetch?: typeof fetch;
|
|
1406
|
+
};
|
|
1407
|
+
/** Signed S3 general-purpose bucket API, with explicit endpoint/credentials and bounded transfers. */
|
|
1408
|
+
declare function s3Repository(options: S3RepositoryOptions): ArchiveRepository;
|
|
1409
|
+
|
|
1410
|
+
type JournalRecord = {
|
|
1411
|
+
version: 1;
|
|
1412
|
+
revision: number;
|
|
1413
|
+
operationId: string;
|
|
1414
|
+
controller: string;
|
|
1415
|
+
namespace: string;
|
|
1416
|
+
scope: string[];
|
|
1417
|
+
action: string;
|
|
1418
|
+
phase: "prepared" | "committing" | "uploading" | "publishing" | "succeeded" | "failed" | "recovery-required" | "resolved";
|
|
1419
|
+
timestamp: string;
|
|
1420
|
+
requestFingerprint: string;
|
|
1421
|
+
before?: string;
|
|
1422
|
+
after?: string;
|
|
1423
|
+
writerGeneration?: number;
|
|
1424
|
+
resolution?: string;
|
|
1425
|
+
};
|
|
1426
|
+
type OperationJournal = {
|
|
1427
|
+
load(): Promise<JournalRecord[]>;
|
|
1428
|
+
write(record: JournalRecord): Promise<void>;
|
|
1429
|
+
};
|
|
1430
|
+
/** One fsynced CAS record per operation. Stale controllers cannot overwrite later reconciliation. */
|
|
1431
|
+
declare function filesystemOperationJournal(directory: string): OperationJournal;
|
|
1432
|
+
declare function reconcileOperation(record: JournalRecord, repository: ArchiveRepository): Promise<{
|
|
1433
|
+
status: "terminal";
|
|
1434
|
+
operationId: string;
|
|
1435
|
+
archive?: never;
|
|
1436
|
+
reason?: never;
|
|
1437
|
+
scope?: never;
|
|
1438
|
+
} | {
|
|
1439
|
+
status: "abandoned-before-commit";
|
|
1440
|
+
operationId: string;
|
|
1441
|
+
archive?: never;
|
|
1442
|
+
reason?: never;
|
|
1443
|
+
scope?: never;
|
|
1444
|
+
} | {
|
|
1445
|
+
status: "verified-publication";
|
|
1446
|
+
operationId: string;
|
|
1447
|
+
archive: string;
|
|
1448
|
+
reason?: never;
|
|
1449
|
+
scope?: never;
|
|
1450
|
+
} | {
|
|
1451
|
+
status: "recovery-required";
|
|
1452
|
+
operationId: string;
|
|
1453
|
+
reason: string;
|
|
1454
|
+
scope: string[];
|
|
1455
|
+
archive?: never;
|
|
1456
|
+
}>;
|
|
1457
|
+
|
|
1458
|
+
type ClockSynchronization = (context: {
|
|
1459
|
+
namespace: string;
|
|
1460
|
+
services: string[];
|
|
1461
|
+
now: number;
|
|
1462
|
+
signal: AbortSignal;
|
|
1463
|
+
}) => Promise<void>;
|
|
1464
|
+
|
|
1465
|
+
type Operation = {
|
|
1466
|
+
scope?: string[];
|
|
1467
|
+
participant?: string;
|
|
1468
|
+
actor?: string;
|
|
1469
|
+
services?: string[];
|
|
1470
|
+
id: string;
|
|
1471
|
+
namespace: string;
|
|
1472
|
+
action: string;
|
|
1473
|
+
phase: string;
|
|
1474
|
+
startedAt: string;
|
|
1475
|
+
finishedAt?: string;
|
|
1476
|
+
status: "running" | "succeeded" | "failed" | "cancelled";
|
|
1477
|
+
completed: number;
|
|
1478
|
+
total: number;
|
|
1479
|
+
result?: unknown;
|
|
1480
|
+
};
|
|
1481
|
+
type WorkloadContext = {
|
|
1482
|
+
namespace: string;
|
|
1483
|
+
services: string[];
|
|
1484
|
+
signal: AbortSignal;
|
|
1485
|
+
operationId: string;
|
|
1486
|
+
};
|
|
1487
|
+
type WorkloadAdapter = {
|
|
1488
|
+
prepare?(context: WorkloadContext): Promise<void>;
|
|
1489
|
+
verify?(context: WorkloadContext): Promise<void>;
|
|
1490
|
+
resume?(context: WorkloadContext): Promise<void>;
|
|
1491
|
+
};
|
|
1492
|
+
type ScenarioBundle = {
|
|
1493
|
+
format: "mockingbird.scenario/v1";
|
|
1494
|
+
version: number;
|
|
1495
|
+
description?: string;
|
|
1496
|
+
services: Record<string, {
|
|
1497
|
+
protocol: FleetChild["protocol"];
|
|
1498
|
+
controls?: Record<string, unknown>;
|
|
1499
|
+
fixtures?: unknown;
|
|
1500
|
+
}>;
|
|
1501
|
+
seed?: string | number;
|
|
1502
|
+
clock?: {
|
|
1503
|
+
now: string | number;
|
|
1504
|
+
frozen?: boolean;
|
|
1505
|
+
};
|
|
1506
|
+
seedApplication?(context: WorkloadContext & {
|
|
1507
|
+
manifest: EndpointManifest;
|
|
1508
|
+
connections: Record<string, {
|
|
1509
|
+
url: string;
|
|
1510
|
+
namespaces: Record<string, string>;
|
|
1511
|
+
}>;
|
|
1512
|
+
headers: Record<string, string>;
|
|
1513
|
+
}): Promise<void>;
|
|
1514
|
+
};
|
|
1515
|
+
type ManagementOptions = InstrumentationOptions & {
|
|
1516
|
+
trace?: boolean;
|
|
1517
|
+
journal?: OperationJournal;
|
|
1518
|
+
synchronizeClock?: ClockSynchronization;
|
|
1519
|
+
outbound?: OutboundPolicy;
|
|
1520
|
+
archiveCompatibility?: ArchiveCompatibilityPolicy;
|
|
1521
|
+
archiveProtection?: ArchiveProtector;
|
|
1522
|
+
resolveArchiveSecret?(reference: string): Promise<string>;
|
|
1523
|
+
cors?: {
|
|
1524
|
+
origins: string[];
|
|
1525
|
+
methods?: string[];
|
|
1526
|
+
headers?: string[];
|
|
1527
|
+
};
|
|
1528
|
+
retention?: {
|
|
1529
|
+
maxCount?: number;
|
|
1530
|
+
ttlMs?: number;
|
|
1531
|
+
};
|
|
1532
|
+
limits?: {
|
|
1533
|
+
maxNamespaces?: number;
|
|
1534
|
+
maxListeners?: number;
|
|
1535
|
+
connections?: number;
|
|
1536
|
+
};
|
|
1537
|
+
workload?: WorkloadAdapter;
|
|
1538
|
+
hookTimeoutMs?: number;
|
|
1539
|
+
profiles?: Record<string, Record<string, Record<string, unknown>>>;
|
|
1540
|
+
scenarios?: Record<string, ScenarioBundle>;
|
|
1541
|
+
repository?: ArchiveRepository;
|
|
1542
|
+
backupPolicy?: {
|
|
1543
|
+
intervalMs: number;
|
|
1544
|
+
namespaces?: string[];
|
|
1545
|
+
keep?: number;
|
|
1546
|
+
};
|
|
1547
|
+
expiry?: {
|
|
1548
|
+
idleMs: number;
|
|
1549
|
+
intervalMs?: number;
|
|
1550
|
+
finalBackup?: boolean;
|
|
1551
|
+
};
|
|
1552
|
+
memberStatus?: boolean;
|
|
1553
|
+
};
|
|
1554
|
+
|
|
1555
|
+
type FleetDiagnostics = {
|
|
1556
|
+
activeRequests: number;
|
|
1557
|
+
activeConnections: number;
|
|
1558
|
+
blockedCommands: number;
|
|
1559
|
+
pendingJobs: number;
|
|
1560
|
+
activeJobs?: number;
|
|
1561
|
+
pendingWebhooks: number;
|
|
1562
|
+
unmatchedRequests: number;
|
|
1563
|
+
};
|
|
1564
|
+
/** Protocol packages own their state, listeners, credentials and namespace selection. */
|
|
1565
|
+
type FleetChild = {
|
|
1566
|
+
targetName?: string;
|
|
1567
|
+
dependencies?: string[];
|
|
1568
|
+
coverage?: {
|
|
1569
|
+
included: string[];
|
|
1570
|
+
excluded: string[];
|
|
1571
|
+
};
|
|
1572
|
+
outboundPolicy?: "webhook-hub" | "unsupported";
|
|
1573
|
+
packageVersion?: string;
|
|
1574
|
+
protocol: "http" | "postgres" | "redis" | "external";
|
|
1575
|
+
url: string;
|
|
1576
|
+
connection?: string;
|
|
1577
|
+
connections?: Record<string, string>;
|
|
1578
|
+
healthUrl?: string;
|
|
1579
|
+
adminUrl?: string;
|
|
1580
|
+
namespaces: Record<string, unknown>;
|
|
1581
|
+
ready(): Promise<boolean>;
|
|
1582
|
+
close(): Promise<void>;
|
|
1583
|
+
/** Fence new work synchronously; diagnostics must also account for work already in flight. */
|
|
1584
|
+
lock(namespace: string): () => void;
|
|
1585
|
+
diagnostics(namespace: string): FleetDiagnostics;
|
|
1586
|
+
checkpoint(namespace: string): Promise<unknown>;
|
|
1587
|
+
restore(namespace: string, checkpoint: unknown): Promise<void>;
|
|
1588
|
+
reset(namespace: string): Promise<void>;
|
|
1589
|
+
clock(namespace: string): Clock;
|
|
1590
|
+
nextEvent?(namespace: string): number | undefined | Promise<number | undefined>;
|
|
1591
|
+
settle?(namespace: string, signal?: AbortSignal): Promise<void>;
|
|
1592
|
+
exportCheckpoint?(namespace: string, checkpoint: unknown): Promise<unknown>;
|
|
1593
|
+
importCheckpoint?(namespace: string, document: unknown): Promise<unknown>;
|
|
1594
|
+
createNamespace?(namespace: string): Promise<void>;
|
|
1595
|
+
deleteNamespace?(namespace: string): Promise<void>;
|
|
1596
|
+
inspect?(namespace: string, options: {
|
|
1597
|
+
offset: number;
|
|
1598
|
+
limit: number;
|
|
1599
|
+
collection?: string;
|
|
1600
|
+
}): Promise<unknown>;
|
|
1601
|
+
configure?(namespace: string, controls: Record<string, unknown>): Promise<unknown>;
|
|
1602
|
+
unmatched?(namespace: string, limit: number): {
|
|
1603
|
+
entries: unknown[];
|
|
1604
|
+
truncated: boolean;
|
|
1605
|
+
};
|
|
1606
|
+
lastActivity?(namespace: string): number;
|
|
1607
|
+
setAdmission?(allow: (namespace: string) => boolean): void;
|
|
1608
|
+
initializationAccess?(): Promise<{
|
|
1609
|
+
connections: Record<string, string>;
|
|
1610
|
+
close(): Promise<void>;
|
|
1611
|
+
}>;
|
|
1612
|
+
};
|
|
1613
|
+
type ProtocolTarget = {
|
|
1614
|
+
packageVersion?: string;
|
|
1615
|
+
name: string;
|
|
1616
|
+
protocol: "postgres" | "redis" | "external";
|
|
1617
|
+
defaultPort: number;
|
|
1618
|
+
start(entry: ConfigService): Promise<FleetChild>;
|
|
1619
|
+
};
|
|
1620
|
+
/** Bundled service declarations contain distinct private runtime classes. The loader boundary
|
|
1621
|
+
* accepts their opaque runtime and validates the fleet protocol before starting a listener. */
|
|
1622
|
+
type FleetHttpTarget = Pick<ServeTarget, "name" | "defaultPort" | "options" | "packageVersion" | "listening" | "parseSettings" | "maxBodyBytes"> & {
|
|
1623
|
+
create(values: Parameters<ServeTarget["create"]>[0], common: CommonServeOptions): unknown;
|
|
1624
|
+
};
|
|
1625
|
+
type FleetTarget = FleetHttpTarget | ProtocolTarget;
|
|
1626
|
+
type FleetOptions = ManagementOptions & {
|
|
1627
|
+
participants?: Record<string, FleetChild>;
|
|
1628
|
+
load(name: string): Promise<FleetTarget>;
|
|
1629
|
+
onLog?: CommonServeOptions["onLog"];
|
|
1630
|
+
readyFile?: string | undefined;
|
|
1631
|
+
connectionsFile?: string | undefined;
|
|
1632
|
+
onReady?(manifest: EndpointManifest): void;
|
|
1633
|
+
/**
|
|
1634
|
+
* Start a dashboard once the fleet is up; its URL becomes `manifest.dashboard` and it closes
|
|
1635
|
+
* with the fleet. `@crvouga/mockingbird-fleet` supplies one (`fleetDashboard`): this package
|
|
1636
|
+
* only knows how to host it.
|
|
1637
|
+
*/
|
|
1638
|
+
dashboard?: FleetDashboardStarter;
|
|
1639
|
+
initialize?(context: {
|
|
1640
|
+
manifest: EndpointManifest;
|
|
1641
|
+
connections: Record<string, unknown>;
|
|
1642
|
+
headers: Record<string, string>;
|
|
1643
|
+
signal: AbortSignal;
|
|
1644
|
+
}): Promise<void>;
|
|
1645
|
+
initializationTimeoutMs?: number;
|
|
1646
|
+
beforeClose?(context: {
|
|
1647
|
+
manifest: EndpointManifest;
|
|
1648
|
+
signal: AbortSignal;
|
|
1649
|
+
capture(namespaces: string[]): Promise<unknown>;
|
|
1650
|
+
}): Promise<void>;
|
|
1651
|
+
shutdownTimeoutMs?: number;
|
|
1652
|
+
shutdownFailure?: "abort" | "close";
|
|
1653
|
+
};
|
|
1654
|
+
type FleetDashboard = {
|
|
1655
|
+
url: string;
|
|
1656
|
+
close(): Promise<void>;
|
|
1657
|
+
};
|
|
1658
|
+
type FleetDashboardStarter = (context: {
|
|
1659
|
+
/** The live manifest: `adminBase` is where the fleet controller answers. */
|
|
1660
|
+
manifest: EndpointManifest;
|
|
1661
|
+
config: MockingbirdConfig;
|
|
1662
|
+
}) => Promise<FleetDashboard>;
|
|
1663
|
+
type Fleet = {
|
|
1664
|
+
readonly manifest: EndpointManifest;
|
|
1665
|
+
readonly children: ReadonlyMap<string, FleetChild>;
|
|
1666
|
+
fetch(request: Request): Promise<Response>;
|
|
1667
|
+
close(): Promise<void>;
|
|
1668
|
+
};
|
|
1669
|
+
/** Resolves only after every child and the aggregate control listener are healthy. */
|
|
1670
|
+
declare function startFleet(config: MockingbirdConfig, options: FleetOptions): Promise<Fleet>;
|
|
1671
|
+
|
|
1672
|
+
/**
|
|
1673
|
+
* Anything that can answer a Fetch `Request` with a `Response`.
|
|
1674
|
+
*
|
|
1675
|
+
* Every Mockingbird service implements this, and every runtime adapter consumes it.
|
|
1676
|
+
* It is the only contract shared across the whole graph.
|
|
1677
|
+
*/
|
|
1678
|
+
interface FetchAPI {
|
|
1679
|
+
fetch(request: Request): Promise<Response>;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
type ListenOptions = {
|
|
1683
|
+
/** Default `0`: the OS picks a free port. */
|
|
1684
|
+
port?: number;
|
|
1685
|
+
/** Default `127.0.0.1`: a mock should not be reachable off the machine by accident. */
|
|
1686
|
+
host?: string;
|
|
1687
|
+
/** Largest request body accepted. Default 16 MiB. */
|
|
1688
|
+
maxBodyBytes?: number;
|
|
1689
|
+
};
|
|
1690
|
+
/** A running server, with the address it actually bound. */
|
|
1691
|
+
type Listening = {
|
|
1692
|
+
url: string;
|
|
1693
|
+
port: number;
|
|
1694
|
+
host: string;
|
|
1695
|
+
server: Server;
|
|
1696
|
+
close(): Promise<void>;
|
|
1697
|
+
};
|
|
1698
|
+
declare const listen: (api: FetchAPI, options?: ListenOptions) => Promise<Listening>;
|
|
1699
|
+
|
|
1700
|
+
type CliOption = {
|
|
1701
|
+
type: "string" | "boolean";
|
|
1702
|
+
description: string;
|
|
1703
|
+
/** Shown in help; the value placeholder, e.g. `<port>`. */
|
|
1704
|
+
value?: string;
|
|
1705
|
+
default?: string | boolean;
|
|
1706
|
+
};
|
|
1707
|
+
type CliValues = Record<string, string | boolean | undefined>;
|
|
1708
|
+
type CliCommand = {
|
|
1709
|
+
fleetTarget?: FleetTarget;
|
|
1710
|
+
summary: string;
|
|
1711
|
+
usage?: string;
|
|
1712
|
+
options?: Record<string, CliOption>;
|
|
1713
|
+
/** Resolves to an exit code; a server command resolves only when it stops. */
|
|
1714
|
+
run(values: CliValues, positionals: string[]): Promise<number>;
|
|
1715
|
+
};
|
|
1716
|
+
type CliSpec = {
|
|
1717
|
+
bin: string;
|
|
1718
|
+
description: string;
|
|
1719
|
+
commands: Record<string, CliCommand>;
|
|
1720
|
+
};
|
|
1721
|
+
/** Parse `argv` against `spec` and run the chosen command. Resolves to an exit code. */
|
|
1722
|
+
declare const runCli: (spec: CliSpec, argv: string[]) => Promise<number>;
|
|
1723
|
+
type LogFormat = "pretty" | "json" | "off";
|
|
1724
|
+
type CommonServeOptions = {
|
|
1725
|
+
adminPrefix?: string;
|
|
1726
|
+
adminKey: string | undefined;
|
|
1727
|
+
seed: string | undefined;
|
|
1728
|
+
onLog: ((entry: RequestLog) => void) | undefined;
|
|
1729
|
+
/** Admin controls to boot with: clock, latency, faults, a starting snapshot. */
|
|
1730
|
+
adminControls?: MockControls;
|
|
1731
|
+
/** Synthetic provider fixture objects supplied by a fleet entry. */
|
|
1732
|
+
fixtures?: Record<string, unknown>;
|
|
1733
|
+
baseUrl?: string;
|
|
1734
|
+
/**
|
|
1735
|
+
* Boot settings from `--settings`, `MOCKINGBIRD_SETTINGS` or a fleet entry's `settings`,
|
|
1736
|
+
* already checked by the target's {@link ServeTarget.parseSettings}. Pass them to the
|
|
1737
|
+
* service's own `settings` option so they become every namespace's defaults.
|
|
1738
|
+
*/
|
|
1739
|
+
settings?: Record<string, unknown>;
|
|
1740
|
+
};
|
|
1741
|
+
/**
|
|
1742
|
+
* What a service contributes to `serve`: how to build its runtime from CLI flags,
|
|
1743
|
+
* and what to say at startup. Every service's `./server` entry exports one as
|
|
1744
|
+
* `serveTarget`, which is also how `serve --config` finds services by name.
|
|
1745
|
+
*/
|
|
1746
|
+
type ServeTarget = {
|
|
1747
|
+
packageVersion?: string;
|
|
1748
|
+
name: string;
|
|
1749
|
+
defaultPort: number;
|
|
1750
|
+
/** Serve flags beyond the common ones. */
|
|
1751
|
+
options?: Record<string, CliOption>;
|
|
1752
|
+
/**
|
|
1753
|
+
* Check the boot settings a caller supplied (`--settings`, `MOCKINGBIRD_SETTINGS`, a fleet
|
|
1754
|
+
* entry's `settings`) against the service's settings schema, returning them normalized
|
|
1755
|
+
* or throwing a message naming the bad field. A target without one takes no boot settings,
|
|
1756
|
+
* and supplying some is refused before a port is bound.
|
|
1757
|
+
*/
|
|
1758
|
+
parseSettings?(settings: Record<string, unknown>): Record<string, unknown>;
|
|
1759
|
+
create(values: CliValues, common: CommonServeOptions): Promise<ServiceRuntime<ServiceInstance>> | ServiceRuntime<ServiceInstance>;
|
|
1760
|
+
/** Largest request body the HTTP server accepts. Default 16 MiB. */
|
|
1761
|
+
maxBodyBytes?: number;
|
|
1762
|
+
/** Startup lines after the listen address, e.g. the loaded corpus version. */
|
|
1763
|
+
banner?(runtime: ServiceRuntime<ServiceInstance>): string[];
|
|
1764
|
+
/** After the HTTP server is bound. A service that speaks more than HTTP attaches it here. */
|
|
1765
|
+
listening?(server: Listening): void;
|
|
1766
|
+
};
|
|
1767
|
+
/** A JSON option given inline (it starts with `{`, or `[`) or as the path of a JSON file. */
|
|
1768
|
+
declare const readJsonOption: (source: string, label: string) => Promise<unknown>;
|
|
1769
|
+
/**
|
|
1770
|
+
* The id base a `serve` invocation asks for: `--id-base` or `MOCKINGBIRD_ID_BASE`, a
|
|
1771
|
+
* non-negative integer or `boot`. Checked before a port is bound. `undefined` when not asked for.
|
|
1772
|
+
*/
|
|
1773
|
+
declare const resolveServeIdBase: (values: CliValues, env?: Record<string, string | undefined>) => string | undefined;
|
|
1774
|
+
/**
|
|
1775
|
+
* The boot settings a `serve` invocation asks for: `--settings` (or `MOCKINGBIRD_SETTINGS`) as
|
|
1776
|
+
* JSON or a JSON file, checked by the target's own settings schema. `undefined` when not asked for.
|
|
1777
|
+
*/
|
|
1778
|
+
declare const resolveServeSettings: (target: Pick<ServeTarget, "name" | "parseSettings">, values: CliValues, env?: Record<string, string | undefined>) => Promise<Record<string, unknown> | undefined>;
|
|
1779
|
+
/**
|
|
1780
|
+
* The boot controls a `serve` invocation asks for: `--admin-controls` (or `MOCKINGBIRD_ADMIN_CONTROLS`) as
|
|
1781
|
+
* the base document, with the single-purpose flags on top. Checked here, so a bad value stops
|
|
1782
|
+
* the command before a port is bound. `undefined` when nothing was asked for.
|
|
1783
|
+
*/
|
|
1784
|
+
declare const resolveServeControls: (values: CliValues, env?: Record<string, string | undefined>, base?: unknown) => Promise<MockControls | undefined>;
|
|
1785
|
+
/** A service entry in `mockingbird.json`. */
|
|
1786
|
+
type ConfigService = {
|
|
1787
|
+
/** Stable config key is the instance identity; target defaults to that key. */
|
|
1788
|
+
target?: string;
|
|
1789
|
+
publicOrigin?: string;
|
|
1790
|
+
publicPath?: string;
|
|
1791
|
+
dependsOn?: string[];
|
|
1792
|
+
protocol?: "http" | "postgres" | "redis";
|
|
1793
|
+
port?: number;
|
|
1794
|
+
host?: string;
|
|
1795
|
+
adminPrefix?: string;
|
|
1796
|
+
adminKey?: string;
|
|
1797
|
+
seed?: string;
|
|
1798
|
+
/**
|
|
1799
|
+
* Where this service's generated ids start: a non-negative integer or `"boot"` (derived from
|
|
1800
|
+
* the clock). Replaces the fleet-wide `idBase`. Default: the same ids on every boot.
|
|
1801
|
+
*/
|
|
1802
|
+
idBase?: number | string;
|
|
1803
|
+
/** Boot settings, checked by the service's settings schema; every namespace starts from them. */
|
|
1804
|
+
settings?: Record<string, unknown>;
|
|
1805
|
+
/** Admin controls this service boots with. A key given here replaces the fleet-wide one. */
|
|
1806
|
+
adminControls?: MockControls;
|
|
1807
|
+
fixtures?: Record<string, unknown>;
|
|
1808
|
+
baseUrl?: string;
|
|
1809
|
+
password?: string;
|
|
1810
|
+
user?: string;
|
|
1811
|
+
database?: string;
|
|
1812
|
+
/** Protocol namespace selectors: database names for Postgres, logical DB indexes for Redis. */
|
|
1813
|
+
namespaces?: Record<string, string | number>;
|
|
1814
|
+
/** Service-specific serve flags, by long name: `{ "webhook-url": "…" }`. */
|
|
1815
|
+
options?: Record<string, string | boolean>;
|
|
1816
|
+
};
|
|
1817
|
+
type MockingbirdConfig = {
|
|
1818
|
+
$schema?: string;
|
|
1819
|
+
schemaVersion?: 1;
|
|
1820
|
+
extensions?: Record<string, unknown>;
|
|
1821
|
+
cors?: {
|
|
1822
|
+
origins: string[];
|
|
1823
|
+
methods?: string[];
|
|
1824
|
+
headers?: string[];
|
|
1825
|
+
};
|
|
1826
|
+
/** Keyed by service name: `junction` loads `@crvouga/mockingbird-service-junction`. */
|
|
1827
|
+
services: Record<string, ConfigService>;
|
|
1828
|
+
log?: LogFormat;
|
|
1829
|
+
adminPrefix?: string;
|
|
1830
|
+
adminKey?: string;
|
|
1831
|
+
/** Where every HTTP service's generated ids start unless the service names its own `idBase`. */
|
|
1832
|
+
idBase?: number | string;
|
|
1833
|
+
/** Admin controls every HTTP service in the fleet boots with. */
|
|
1834
|
+
adminControls?: MockControls;
|
|
1835
|
+
namespace?: string;
|
|
1836
|
+
control?: {
|
|
1837
|
+
host?: string;
|
|
1838
|
+
port?: number;
|
|
1839
|
+
};
|
|
1840
|
+
/**
|
|
1841
|
+
* Serve the dashboard next to the fleet: every emulator's admin UI and the notifications UI on
|
|
1842
|
+
* one page. `mockingbird-fleet serve` and `startFleet` from `@crvouga/mockingbird-fleet` honor
|
|
1843
|
+
* it; the default port is 8790.
|
|
1844
|
+
*/
|
|
1845
|
+
dashboard?: boolean | {
|
|
1846
|
+
host?: string;
|
|
1847
|
+
port?: number;
|
|
1848
|
+
};
|
|
1849
|
+
};
|
|
1850
|
+
/** The standard `serve` command for a service, including multi-service `--config`. */
|
|
1851
|
+
declare const serveCommand: (target: ServeTarget | ProtocolTarget) => CliCommand;
|
|
1852
|
+
|
|
1853
|
+
declare const providerServeOptions: Record<string, CliOption>;
|
|
1854
|
+
/** Node-only input loading. Contents and parse errors never enter startup logs. */
|
|
1855
|
+
declare function providerServeValues<T>(values: CliValues, defaults?: Pick<CommonServeOptions, "fixtures" | "baseUrl">): Promise<{
|
|
1856
|
+
fixtures?: T;
|
|
1857
|
+
baseUrl?: string;
|
|
1858
|
+
}>;
|
|
1859
|
+
|
|
1860
|
+
type RestoreBinding = {
|
|
1861
|
+
namespace: string;
|
|
1862
|
+
service: string;
|
|
1863
|
+
endpointId: string;
|
|
1864
|
+
endpointRef: string;
|
|
1865
|
+
secretRef?: string;
|
|
1866
|
+
signing?: "preserve" | "replace";
|
|
1867
|
+
signingRef?: string;
|
|
1868
|
+
};
|
|
1869
|
+
type RestoreBindings = {
|
|
1870
|
+
bindings: RestoreBinding[];
|
|
1871
|
+
endpoints: Record<string, string>;
|
|
1872
|
+
};
|
|
1873
|
+
/** Explicitly relocates declared webhook configuration; opaque payloads/tokens are never rewritten. */
|
|
1874
|
+
declare function planRestoreBindings(input: unknown, plan: RestoreBindings, resolveSecret?: (reference: string) => Promise<string>): Promise<{
|
|
1875
|
+
report: {
|
|
1876
|
+
version: number;
|
|
1877
|
+
source: string;
|
|
1878
|
+
changes: {
|
|
1879
|
+
namespace: string;
|
|
1880
|
+
service: string;
|
|
1881
|
+
endpointId: string;
|
|
1882
|
+
endpointRef: string;
|
|
1883
|
+
secretRef?: string;
|
|
1884
|
+
previousFingerprint: string;
|
|
1885
|
+
destinationFingerprint: string;
|
|
1886
|
+
signing: string;
|
|
1887
|
+
}[];
|
|
1888
|
+
limitations: string[];
|
|
1889
|
+
};
|
|
1890
|
+
archive: FleetArchive;
|
|
1891
|
+
}>;
|
|
1892
|
+
declare const rebaseArchiveNamespace: (input: FleetArchive, source: string, destination: string) => FleetArchive;
|
|
1893
|
+
|
|
1894
|
+
declare const fleetConfigSchema: {
|
|
1895
|
+
$schema: string;
|
|
1896
|
+
$id: string;
|
|
1897
|
+
title: string;
|
|
1898
|
+
type: string;
|
|
1899
|
+
required: string[];
|
|
1900
|
+
additionalProperties: boolean;
|
|
1901
|
+
properties: {
|
|
1902
|
+
$schema: {
|
|
1903
|
+
const: string;
|
|
1904
|
+
};
|
|
1905
|
+
schemaVersion: {
|
|
1906
|
+
const: number;
|
|
1907
|
+
};
|
|
1908
|
+
services: {
|
|
1909
|
+
type: string;
|
|
1910
|
+
propertyNames: {
|
|
1911
|
+
pattern: string;
|
|
1912
|
+
};
|
|
1913
|
+
additionalProperties: {
|
|
1914
|
+
$ref: string;
|
|
1915
|
+
};
|
|
1916
|
+
};
|
|
1917
|
+
log: {
|
|
1918
|
+
enum: string[];
|
|
1919
|
+
};
|
|
1920
|
+
adminPrefix: {
|
|
1921
|
+
type: string;
|
|
1922
|
+
};
|
|
1923
|
+
adminKey: {
|
|
1924
|
+
type: string;
|
|
1925
|
+
};
|
|
1926
|
+
adminControls: {
|
|
1927
|
+
$ref: string;
|
|
1928
|
+
};
|
|
1929
|
+
idBase: {
|
|
1930
|
+
$ref: string;
|
|
1931
|
+
};
|
|
1932
|
+
namespace: {
|
|
1933
|
+
type: string;
|
|
1934
|
+
pattern: string;
|
|
1935
|
+
};
|
|
1936
|
+
control: {
|
|
1937
|
+
type: string;
|
|
1938
|
+
additionalProperties: boolean;
|
|
1939
|
+
properties: {
|
|
1940
|
+
port: {
|
|
1941
|
+
type: string;
|
|
1942
|
+
minimum: number;
|
|
1943
|
+
maximum: number;
|
|
1944
|
+
};
|
|
1945
|
+
host: {
|
|
1946
|
+
type: string;
|
|
1947
|
+
};
|
|
1948
|
+
};
|
|
1949
|
+
};
|
|
1950
|
+
dashboard: {
|
|
1951
|
+
description: string;
|
|
1952
|
+
anyOf: ({
|
|
1953
|
+
type: string;
|
|
1954
|
+
additionalProperties?: never;
|
|
1955
|
+
properties?: never;
|
|
1956
|
+
} | {
|
|
1957
|
+
type: string;
|
|
1958
|
+
additionalProperties: boolean;
|
|
1959
|
+
properties: {
|
|
1960
|
+
port: {
|
|
1961
|
+
type: string;
|
|
1962
|
+
minimum: number;
|
|
1963
|
+
maximum: number;
|
|
1964
|
+
};
|
|
1965
|
+
host: {
|
|
1966
|
+
type: string;
|
|
1967
|
+
};
|
|
1968
|
+
};
|
|
1969
|
+
})[];
|
|
1970
|
+
};
|
|
1971
|
+
cors: {
|
|
1972
|
+
type: string;
|
|
1973
|
+
required: string[];
|
|
1974
|
+
additionalProperties: boolean;
|
|
1975
|
+
properties: {
|
|
1976
|
+
origins: {
|
|
1977
|
+
type: string;
|
|
1978
|
+
items: {
|
|
1979
|
+
type: string;
|
|
1980
|
+
};
|
|
1981
|
+
};
|
|
1982
|
+
methods: {
|
|
1983
|
+
type: string;
|
|
1984
|
+
items: {
|
|
1985
|
+
enum: string[];
|
|
1986
|
+
};
|
|
1987
|
+
};
|
|
1988
|
+
headers: {
|
|
1989
|
+
type: string;
|
|
1990
|
+
items: {
|
|
1991
|
+
type: string;
|
|
1992
|
+
};
|
|
1993
|
+
};
|
|
1994
|
+
};
|
|
1995
|
+
};
|
|
1996
|
+
extensions: {
|
|
1997
|
+
type: string;
|
|
1998
|
+
propertyNames: {
|
|
1999
|
+
pattern: string;
|
|
2000
|
+
};
|
|
2001
|
+
additionalProperties: boolean;
|
|
2002
|
+
};
|
|
2003
|
+
};
|
|
2004
|
+
$defs: {
|
|
2005
|
+
service: {
|
|
2006
|
+
type: string;
|
|
2007
|
+
additionalProperties: boolean;
|
|
2008
|
+
properties: {
|
|
2009
|
+
target: {
|
|
2010
|
+
type: string;
|
|
2011
|
+
pattern: string;
|
|
2012
|
+
};
|
|
2013
|
+
dependsOn: {
|
|
2014
|
+
type: string;
|
|
2015
|
+
items: {
|
|
2016
|
+
type: string;
|
|
2017
|
+
};
|
|
2018
|
+
};
|
|
2019
|
+
protocol: {
|
|
2020
|
+
enum: string[];
|
|
2021
|
+
};
|
|
2022
|
+
port: {
|
|
2023
|
+
type: string;
|
|
2024
|
+
minimum: number;
|
|
2025
|
+
maximum: number;
|
|
2026
|
+
};
|
|
2027
|
+
host: {
|
|
2028
|
+
type: string;
|
|
2029
|
+
};
|
|
2030
|
+
adminPrefix: {
|
|
2031
|
+
type: string;
|
|
2032
|
+
};
|
|
2033
|
+
adminKey: {
|
|
2034
|
+
type: string;
|
|
2035
|
+
};
|
|
2036
|
+
seed: {
|
|
2037
|
+
type: string;
|
|
2038
|
+
};
|
|
2039
|
+
adminControls: {
|
|
2040
|
+
$ref: string;
|
|
2041
|
+
};
|
|
2042
|
+
idBase: {
|
|
2043
|
+
$ref: string;
|
|
2044
|
+
};
|
|
2045
|
+
settings: {
|
|
2046
|
+
type: string;
|
|
2047
|
+
};
|
|
2048
|
+
fixtures: {
|
|
2049
|
+
type: string;
|
|
2050
|
+
};
|
|
2051
|
+
baseUrl: {
|
|
2052
|
+
type: string;
|
|
2053
|
+
};
|
|
2054
|
+
password: {
|
|
2055
|
+
type: string;
|
|
2056
|
+
};
|
|
2057
|
+
user: {
|
|
2058
|
+
type: string;
|
|
2059
|
+
};
|
|
2060
|
+
database: {
|
|
2061
|
+
type: string;
|
|
2062
|
+
};
|
|
2063
|
+
namespaces: {
|
|
2064
|
+
type: string;
|
|
2065
|
+
propertyNames: {
|
|
2066
|
+
pattern: string;
|
|
2067
|
+
};
|
|
2068
|
+
additionalProperties: {
|
|
2069
|
+
anyOf: ({
|
|
2070
|
+
type: string;
|
|
2071
|
+
minimum?: never;
|
|
2072
|
+
maximum?: never;
|
|
2073
|
+
} | {
|
|
2074
|
+
type: string;
|
|
2075
|
+
minimum: number;
|
|
2076
|
+
maximum: number;
|
|
2077
|
+
})[];
|
|
2078
|
+
};
|
|
2079
|
+
};
|
|
2080
|
+
options: {
|
|
2081
|
+
type: string;
|
|
2082
|
+
additionalProperties: boolean;
|
|
2083
|
+
description: string;
|
|
2084
|
+
};
|
|
2085
|
+
publicOrigin: {
|
|
2086
|
+
type: string;
|
|
2087
|
+
};
|
|
2088
|
+
publicPath: {
|
|
2089
|
+
type: string;
|
|
2090
|
+
};
|
|
2091
|
+
};
|
|
2092
|
+
};
|
|
2093
|
+
idBase: {
|
|
2094
|
+
anyOf: ({
|
|
2095
|
+
type: string;
|
|
2096
|
+
minimum: number;
|
|
2097
|
+
pattern?: never;
|
|
2098
|
+
} | {
|
|
2099
|
+
type: string;
|
|
2100
|
+
pattern: string;
|
|
2101
|
+
minimum?: never;
|
|
2102
|
+
})[];
|
|
2103
|
+
};
|
|
2104
|
+
controls: {
|
|
2105
|
+
type: string;
|
|
2106
|
+
additionalProperties: boolean;
|
|
2107
|
+
properties: {
|
|
2108
|
+
seed: {};
|
|
2109
|
+
clock: {
|
|
2110
|
+
type: string;
|
|
2111
|
+
};
|
|
2112
|
+
latency: {};
|
|
2113
|
+
faults: {
|
|
2114
|
+
type: string;
|
|
2115
|
+
};
|
|
2116
|
+
snapshot: {
|
|
2117
|
+
type: string;
|
|
2118
|
+
};
|
|
2119
|
+
virtualTime: {
|
|
2120
|
+
type: string;
|
|
2121
|
+
};
|
|
2122
|
+
credentials: {
|
|
2123
|
+
type: string;
|
|
2124
|
+
};
|
|
2125
|
+
namespaces: {
|
|
2126
|
+
type: string;
|
|
2127
|
+
};
|
|
2128
|
+
};
|
|
2129
|
+
};
|
|
2130
|
+
};
|
|
2131
|
+
};
|
|
2132
|
+
type ConfigIssue = {
|
|
2133
|
+
path: string;
|
|
2134
|
+
message: string;
|
|
2135
|
+
};
|
|
2136
|
+
type Schema = {
|
|
2137
|
+
$ref?: string;
|
|
2138
|
+
type?: string;
|
|
2139
|
+
const?: unknown;
|
|
2140
|
+
enum?: unknown[];
|
|
2141
|
+
anyOf?: Schema[];
|
|
2142
|
+
required?: string[];
|
|
2143
|
+
properties?: Record<string, Schema>;
|
|
2144
|
+
additionalProperties?: boolean | Schema;
|
|
2145
|
+
items?: Schema;
|
|
2146
|
+
propertyNames?: Schema;
|
|
2147
|
+
pattern?: string;
|
|
2148
|
+
minimum?: number;
|
|
2149
|
+
maximum?: number;
|
|
2150
|
+
$defs?: Record<string, Schema>;
|
|
2151
|
+
};
|
|
2152
|
+
/** Standalone validation uses exactly the published schema; composing targets admits only declared flags. */
|
|
2153
|
+
declare function validateFleetConfig(value: unknown, targetOptions?: Record<string, Record<string, CliOption>>, extensions?: Record<string, Schema>): ConfigIssue[];
|
|
2154
|
+
declare function composeFleetSchema(value: unknown, targetOptions?: Record<string, Record<string, CliOption>>, extensions?: Record<string, Schema>): Schema;
|
|
2155
|
+
declare function assertFleetConfig(config: MockingbirdConfig, targetOptions?: Record<string, Record<string, CliOption>>): void;
|
|
2156
|
+
|
|
2157
|
+
/**
|
|
2158
|
+
* `mockingbird.yaml`: one file that declares an organization's fleets, the same whether they run
|
|
2159
|
+
* on Fleet Cloud or on a developer's machine.
|
|
2160
|
+
*
|
|
2161
|
+
* version: 1
|
|
2162
|
+
* organization: acme
|
|
2163
|
+
* projects:
|
|
2164
|
+
* web:
|
|
2165
|
+
* fleets:
|
|
2166
|
+
* acme-staging:
|
|
2167
|
+
* services:
|
|
2168
|
+
* stripe: { durability: strict }
|
|
2169
|
+
* resend: {}
|
|
2170
|
+
* db: { target: postgres, protocol: postgres, local: true }
|
|
2171
|
+
*
|
|
2172
|
+
* A fleet's `services` are the entries of a local fleet configuration (`mockingbird.json`), so
|
|
2173
|
+
* `mockingbird-fleet serve --config mockingbird.yaml` runs the fleet locally with nothing changed.
|
|
2174
|
+
* Fleet Cloud reads the same entries and adds what only a hosted fleet has: durability, access,
|
|
2175
|
+
* a request rate. Each side ignores the keys that are the other's.
|
|
2176
|
+
*/
|
|
2177
|
+
declare const DURABILITY_MODES: readonly ["strict", "buffered", "ephemeral"];
|
|
2178
|
+
declare const ACCESS_MODES: readonly ["open", "key"];
|
|
2179
|
+
/** A service of a declared fleet: a local fleet entry plus what Fleet Cloud adds to it. */
|
|
2180
|
+
type DeclaredService = ConfigService & {
|
|
2181
|
+
/** Fleet Cloud: how much of the emulator's state survives. Default `buffered`. */
|
|
2182
|
+
durability?: (typeof DURABILITY_MODES)[number];
|
|
2183
|
+
/** Fleet Cloud, `buffered` only: milliseconds from the first unsaved change to its write. */
|
|
2184
|
+
flushIntervalMs?: number;
|
|
2185
|
+
/** Fleet Cloud: public https origins the emulator may deliver webhooks to. */
|
|
2186
|
+
webhookOrigins?: string[];
|
|
2187
|
+
/**
|
|
2188
|
+
* Runs only in a local fleet. Fleet Cloud skips it: use this for wire-protocol servers
|
|
2189
|
+
* (PostgreSQL, Redis), which a hosted fleet cannot offer.
|
|
2190
|
+
*/
|
|
2191
|
+
local?: boolean;
|
|
2192
|
+
};
|
|
2193
|
+
type DeclaredFleet = {
|
|
2194
|
+
name?: string;
|
|
2195
|
+
/** Fleet Cloud: `open` (anyone with the URL) or `key` (an API key on every request). */
|
|
2196
|
+
access?: (typeof ACCESS_MODES)[number];
|
|
2197
|
+
/** Fleet Cloud: requests per minute the fleet accepts, at most the organization's ceiling. */
|
|
2198
|
+
requestsPerMinute?: number;
|
|
2199
|
+
services: Record<string, DeclaredService>;
|
|
2200
|
+
};
|
|
2201
|
+
type Declaration = {
|
|
2202
|
+
version: 1;
|
|
2203
|
+
/** The organization's slug. */
|
|
2204
|
+
organization: string;
|
|
2205
|
+
/** The organization's display name. */
|
|
2206
|
+
name?: string;
|
|
2207
|
+
/** Projects by slug; each holds fleets by slug. A fleet's slug is its URL: `/f/<slug>`. */
|
|
2208
|
+
projects: Record<string, {
|
|
2209
|
+
name?: string;
|
|
2210
|
+
fleets: Record<string, DeclaredFleet>;
|
|
2211
|
+
}>;
|
|
2212
|
+
};
|
|
2213
|
+
/** The keys of a service entry that only Fleet Cloud reads; a local fleet never sees them. */
|
|
2214
|
+
declare const CLOUD_SERVICE_KEYS: readonly ["durability", "flushIntervalMs", "webhookOrigins", "local"];
|
|
2215
|
+
/** Whether a parsed configuration file is a declaration (as opposed to a single local fleet). */
|
|
2216
|
+
declare const isDeclaration: (value: unknown) => boolean;
|
|
2217
|
+
/**
|
|
2218
|
+
* Check a parsed `mockingbird.yaml`. Every problem is reported with the path of the key it is
|
|
2219
|
+
* about, all at once. Service entries are checked only for the keys Fleet Cloud adds; the local
|
|
2220
|
+
* fleet and Fleet Cloud each check the rest when they start the service.
|
|
2221
|
+
*/
|
|
2222
|
+
declare function checkDeclaration(value: unknown): ConfigIssue[];
|
|
2223
|
+
/** A problem with a `mockingbird.yaml`, listing every issue with its path. */
|
|
2224
|
+
declare class DeclarationError extends Error {
|
|
2225
|
+
readonly issues: ConfigIssue[];
|
|
2226
|
+
constructor(issues: ConfigIssue[]);
|
|
2227
|
+
}
|
|
2228
|
+
/** A checked declaration with defaults filled in, or a {@link DeclarationError}. */
|
|
2229
|
+
declare function parseDeclaration(value: unknown): Declaration;
|
|
2230
|
+
/** Every fleet of a declaration, with the project it belongs to. */
|
|
2231
|
+
declare const declaredFleets: (declaration: Declaration) => {
|
|
2232
|
+
project: string;
|
|
2233
|
+
slug: string;
|
|
2234
|
+
fleet: DeclaredFleet;
|
|
2235
|
+
}[];
|
|
2236
|
+
/**
|
|
2237
|
+
* The local fleet configuration for one fleet of a declaration: its services with the keys
|
|
2238
|
+
* only Fleet Cloud reads removed. With one fleet declared, `slug` may be omitted.
|
|
2239
|
+
*/
|
|
2240
|
+
declare function localFleetConfig(declaration: Declaration, slug?: string): MockingbirdConfig;
|
|
2241
|
+
|
|
2242
|
+
type FileParticipant = FleetChild & {
|
|
2243
|
+
read(namespace: string, path: string): Promise<Uint8Array | undefined>;
|
|
2244
|
+
write(namespace: string, path: string, value: Uint8Array): Promise<void>;
|
|
2245
|
+
};
|
|
2246
|
+
/** Host-owned allowlist, scoped directories and bounded file contents. No archive chooses a host path. */
|
|
2247
|
+
declare function fileParticipant(root: string, files: readonly string[], options?: {
|
|
2248
|
+
maxBytes?: number;
|
|
2249
|
+
dependencies?: string[];
|
|
2250
|
+
}): Promise<FileParticipant>;
|
|
2251
|
+
|
|
2252
|
+
type IncrementalArchive = {
|
|
2253
|
+
format: "mockingbird.incremental/v1";
|
|
2254
|
+
base: string;
|
|
2255
|
+
baseSha256: string;
|
|
2256
|
+
target: Omit<FleetArchive, "sha256" | "namespaces"> & {
|
|
2257
|
+
namespaces: Record<string, {
|
|
2258
|
+
clock: {
|
|
2259
|
+
now: number;
|
|
2260
|
+
frozen: boolean;
|
|
2261
|
+
};
|
|
2262
|
+
services: Record<string, Omit<FleetArchive["namespaces"][string]["services"][string], "state"> & {
|
|
2263
|
+
object: string;
|
|
2264
|
+
}>;
|
|
2265
|
+
}>;
|
|
2266
|
+
};
|
|
2267
|
+
targetSha256: string;
|
|
2268
|
+
objects: Record<string, unknown>;
|
|
2269
|
+
sha256: string;
|
|
2270
|
+
capture: "full-sections-with-storage-deduplication";
|
|
2271
|
+
};
|
|
2272
|
+
type ArchiveChainEntry = FleetArchive | IncrementalArchive;
|
|
2273
|
+
/** Each participant may fall back to a full capture; unchanged section objects are deduplicated. */
|
|
2274
|
+
declare function incrementalArchive(baseInput: unknown, targetInput: unknown, baseReference?: string): IncrementalArchive;
|
|
2275
|
+
/** Every dependency is loaded and verified before returning a complete restorable archive. */
|
|
2276
|
+
declare function materializeArchive(entry: ArchiveChainEntry, load: (id: string) => Promise<ArchiveChainEntry>, depth?: number): Promise<FleetArchive>;
|
|
2277
|
+
/** Preview retention; bases reachable from any retained or pinned point remain protected. */
|
|
2278
|
+
declare function archiveReachability(retained: string[], load: (id: string) => Promise<ArchiveChainEntry>): Promise<string[]>;
|
|
2279
|
+
declare function publishIncremental(entry: IncrementalArchive, store: {
|
|
2280
|
+
put(id: string, entry: ArchiveChainEntry): Promise<void>;
|
|
2281
|
+
get(id: string): Promise<ArchiveChainEntry>;
|
|
2282
|
+
publishLatest(id: string): Promise<void>;
|
|
2283
|
+
}): Promise<void>;
|
|
2284
|
+
/** Compaction publishes a verified full object before changing a recovery pointer. */
|
|
2285
|
+
declare function compactArchive(entry: ArchiveChainEntry, store: {
|
|
2286
|
+
put(id: string, entry: ArchiveChainEntry): Promise<void>;
|
|
2287
|
+
get(id: string): Promise<ArchiveChainEntry>;
|
|
2288
|
+
publishLatest(id: string): Promise<void>;
|
|
2289
|
+
}): Promise<string>;
|
|
2290
|
+
|
|
2291
|
+
/** Resolve only declared installed packages, relative to the consumer (including pnpm links).
|
|
2292
|
+
* No downloads, arbitrary module paths, or public-request-selected imports are supported.
|
|
2293
|
+
*/
|
|
2294
|
+
declare function createInstalledServiceLoader(options: {
|
|
2295
|
+
projectRoot: string;
|
|
2296
|
+
services: readonly string[];
|
|
2297
|
+
targets?: readonly FleetTarget[];
|
|
2298
|
+
}): (name: string) => Promise<FleetTarget>;
|
|
2299
|
+
|
|
2300
|
+
type ParticipantMigration = {
|
|
2301
|
+
id: string;
|
|
2302
|
+
service: string;
|
|
2303
|
+
from: number;
|
|
2304
|
+
to: number;
|
|
2305
|
+
transform(state: unknown, parameters: Readonly<Record<string, unknown>>): unknown | Promise<unknown>;
|
|
2306
|
+
};
|
|
2307
|
+
type MigrationRegistry = {
|
|
2308
|
+
sourceFormats: readonly string[];
|
|
2309
|
+
transformations: readonly ParticipantMigration[];
|
|
2310
|
+
};
|
|
2311
|
+
declare function archiveCompatibility(input: unknown, registry: MigrationRegistry, policy?: ArchiveCompatibilityPolicy): {
|
|
2312
|
+
version: number;
|
|
2313
|
+
sourceId: string;
|
|
2314
|
+
sourceFormat: string;
|
|
2315
|
+
targetFormat: string;
|
|
2316
|
+
compatible: boolean;
|
|
2317
|
+
problems: string[];
|
|
2318
|
+
steps: {
|
|
2319
|
+
namespace: string;
|
|
2320
|
+
service: string;
|
|
2321
|
+
transformations: string[];
|
|
2322
|
+
}[];
|
|
2323
|
+
};
|
|
2324
|
+
/** Explicit transformations create a new immutable destination; nothing touches a running fleet. */
|
|
2325
|
+
declare function migrateArchive(input: unknown, registry: MigrationRegistry, parameters?: Readonly<Record<string, unknown>>): Promise<FleetArchive>;
|
|
2326
|
+
declare function migrateAndVerify(input: unknown, registry: MigrationRegistry, options: {
|
|
2327
|
+
parameters?: Readonly<Record<string, unknown>>;
|
|
2328
|
+
verify(archive: FleetArchive): Promise<void>;
|
|
2329
|
+
repository?: ArchiveRepository;
|
|
2330
|
+
publish?: boolean;
|
|
2331
|
+
}): Promise<FleetArchive>;
|
|
2332
|
+
|
|
2333
|
+
declare const ingressSupport: {
|
|
2334
|
+
readonly stripe: {
|
|
2335
|
+
readonly publicOrigin: true;
|
|
2336
|
+
readonly pathPrefix: true;
|
|
2337
|
+
readonly namespaces: "path-or-header";
|
|
2338
|
+
readonly streaming: true;
|
|
2339
|
+
readonly signing: "vendor request signing is not used; webhook signatures remain payload based";
|
|
2340
|
+
};
|
|
2341
|
+
readonly cognito: {
|
|
2342
|
+
readonly publicOrigin: true;
|
|
2343
|
+
readonly pathPrefix: true;
|
|
2344
|
+
readonly namespaces: "path-or-header";
|
|
2345
|
+
readonly streaming: true;
|
|
2346
|
+
readonly signing: "JWT issuer and JWKS use the configured public namespace; SigV4 verification is not modelled";
|
|
2347
|
+
};
|
|
2348
|
+
readonly medplum: {
|
|
2349
|
+
readonly publicOrigin: true;
|
|
2350
|
+
readonly pathPrefix: true;
|
|
2351
|
+
readonly namespaces: "path-or-header";
|
|
2352
|
+
readonly streaming: true;
|
|
2353
|
+
readonly signing: "FHIR, OAuth and storage URLs use the configured public namespace";
|
|
2354
|
+
};
|
|
2355
|
+
readonly other: {
|
|
2356
|
+
readonly publicOrigin: false;
|
|
2357
|
+
readonly reason: "host/path-sensitive signing and hosted URL rewriting are not certified; use a direct endpoint";
|
|
2358
|
+
};
|
|
2359
|
+
};
|
|
2360
|
+
/** Fixed configuration is the only authority for generated/advertised origins. */
|
|
2361
|
+
declare function advertisedHttpBase(entry: ConfigService): string | undefined;
|
|
2362
|
+
/** Fetch-based reference ingress. TLS/DNS are supplied by the caller. Bodies stream both ways. */
|
|
2363
|
+
declare function createFleetIngress(config: MockingbirdConfig, manifest: ConnectionManifest, transport?: typeof fetch): (request: Request) => Promise<Response>;
|
|
2364
|
+
|
|
2365
|
+
type RunDescriptor = {
|
|
2366
|
+
namespace: string;
|
|
2367
|
+
generation: string;
|
|
2368
|
+
baseline?: string;
|
|
2369
|
+
endpoints: Record<string, string>;
|
|
2370
|
+
expiresAt?: number;
|
|
2371
|
+
};
|
|
2372
|
+
type RunContext = RunDescriptor & {
|
|
2373
|
+
registerCleanup(close: () => Promise<void>): void;
|
|
2374
|
+
};
|
|
2375
|
+
declare class FleetRunError extends AggregateError {
|
|
2376
|
+
readonly run: RunDescriptor | undefined;
|
|
2377
|
+
readonly evidence: unknown;
|
|
2378
|
+
constructor(errors: unknown[], run: RunDescriptor | undefined, evidence: unknown);
|
|
2379
|
+
}
|
|
2380
|
+
type RunOptions = {
|
|
2381
|
+
baseline?: string;
|
|
2382
|
+
scenario?: string;
|
|
2383
|
+
preserveOnFailureMs?: number;
|
|
2384
|
+
verify?(context: RunContext): Promise<void>;
|
|
2385
|
+
};
|
|
2386
|
+
/** Owns one isolated run; the supplied client keeps admin credentials outside the descriptor. */
|
|
2387
|
+
declare function withFleetRun<T>(client: FleetClient, options: RunOptions, run: (context: RunContext) => Promise<T>): Promise<T>;
|
|
2388
|
+
type NamespaceLease = RunDescriptor & {
|
|
2389
|
+
leaseId: string;
|
|
2390
|
+
expiresAt: number;
|
|
2391
|
+
registerCleanup(close: () => Promise<void>): void;
|
|
2392
|
+
};
|
|
2393
|
+
declare class NamespacePool {
|
|
2394
|
+
private readonly client;
|
|
2395
|
+
private readonly options;
|
|
2396
|
+
private readonly entries;
|
|
2397
|
+
private readonly waiters;
|
|
2398
|
+
private closed;
|
|
2399
|
+
private baseline;
|
|
2400
|
+
constructor(client: FleetClient, options: {
|
|
2401
|
+
maxSize: number;
|
|
2402
|
+
baselineVersion: string;
|
|
2403
|
+
baseline?: string;
|
|
2404
|
+
leaseMs?: number;
|
|
2405
|
+
verify?(descriptor: RunDescriptor): Promise<void>;
|
|
2406
|
+
});
|
|
2407
|
+
private notify;
|
|
2408
|
+
private provision;
|
|
2409
|
+
acquire(options?: {
|
|
2410
|
+
timeoutMs?: number;
|
|
2411
|
+
signal?: AbortSignal;
|
|
2412
|
+
}): Promise<NamespaceLease>;
|
|
2413
|
+
release(lease: NamespaceLease): Promise<void>;
|
|
2414
|
+
setBaseline(version: string, checkpoint?: string): Promise<void>;
|
|
2415
|
+
status(): {
|
|
2416
|
+
version: string;
|
|
2417
|
+
entries: {
|
|
2418
|
+
namespace: string;
|
|
2419
|
+
state: "provisioning" | "warm" | "leased" | "quarantined";
|
|
2420
|
+
version: string;
|
|
2421
|
+
expiresAt: number | undefined;
|
|
2422
|
+
}[];
|
|
2423
|
+
};
|
|
2424
|
+
close(): Promise<void>;
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
declare function doctorFleet(config: MockingbirdConfig, options: FleetOptions, probes?: {
|
|
2428
|
+
url: string;
|
|
2429
|
+
timeoutMs?: number;
|
|
2430
|
+
}[]): Promise<{
|
|
2431
|
+
version: number;
|
|
2432
|
+
ok: boolean;
|
|
2433
|
+
findings: {
|
|
2434
|
+
check: string;
|
|
2435
|
+
ok: boolean;
|
|
2436
|
+
message: string;
|
|
2437
|
+
}[];
|
|
2438
|
+
plan: {
|
|
2439
|
+
service: string;
|
|
2440
|
+
protocol: string;
|
|
2441
|
+
port: number;
|
|
2442
|
+
version: string;
|
|
2443
|
+
}[];
|
|
2444
|
+
storageWritesPerformed: boolean;
|
|
2445
|
+
}>;
|
|
2446
|
+
/** Boots a separate in-memory fleet on ephemeral ports; never uses source files or repositories. */
|
|
2447
|
+
declare function rehearseFleet(config: MockingbirdConfig, options: Pick<FleetOptions, "load" | "archiveCompatibility">, input: unknown, probes?: ((fleet: Fleet, signal: AbortSignal) => Promise<void>)[], timeoutMs?: number): Promise<{
|
|
2448
|
+
version: number;
|
|
2449
|
+
ok: boolean;
|
|
2450
|
+
startedAt: string;
|
|
2451
|
+
finishedAt: string;
|
|
2452
|
+
sourceArchive: string;
|
|
2453
|
+
rehearsalProcess: string;
|
|
2454
|
+
probes: number;
|
|
2455
|
+
}>;
|
|
2456
|
+
declare function fleetCommands(load: (name: string) => Promise<FleetTarget>): Record<string, CliCommand>;
|
|
2457
|
+
|
|
2458
|
+
type ConditionalValue<T> = {
|
|
2459
|
+
revision: string;
|
|
2460
|
+
value: T;
|
|
2461
|
+
};
|
|
2462
|
+
type ConditionalStore<T> = {
|
|
2463
|
+
readonly kind: "filesystem" | "s3-etag";
|
|
2464
|
+
read(): Promise<ConditionalValue<T> | undefined>;
|
|
2465
|
+
compareAndSwap(expected: string | undefined, value: T): Promise<boolean>;
|
|
2466
|
+
};
|
|
2467
|
+
declare function filesystemConditionalStore<T>(path: string, options?: {
|
|
2468
|
+
durable?: boolean;
|
|
2469
|
+
}): ConditionalStore<T>;
|
|
2470
|
+
declare function s3ConditionalStore<T>(options: S3RepositoryOptions, key?: string): ConditionalStore<T>;
|
|
2471
|
+
type WriterLease = {
|
|
2472
|
+
owner: string;
|
|
2473
|
+
generation: number;
|
|
2474
|
+
id: string;
|
|
2475
|
+
expiresAt: number;
|
|
2476
|
+
};
|
|
2477
|
+
type WriterState = {
|
|
2478
|
+
lease: WriterLease;
|
|
2479
|
+
/** Voluntarily relinquished; unlike expiry, acquisition needs no takeover policy. */
|
|
2480
|
+
released?: boolean;
|
|
2481
|
+
latest?: {
|
|
2482
|
+
id: string;
|
|
2483
|
+
generation: number;
|
|
2484
|
+
verifiedAt: string;
|
|
2485
|
+
};
|
|
2486
|
+
};
|
|
2487
|
+
declare class RepositoryWriter {
|
|
2488
|
+
private readonly repository;
|
|
2489
|
+
readonly control: ConditionalStore<WriterState>;
|
|
2490
|
+
private readonly now;
|
|
2491
|
+
constructor(repository: ArchiveRepository, control: ConditionalStore<WriterState>, now?: () => number);
|
|
2492
|
+
acquire(owner: string, ttlMs: number, takeoverExpired?: boolean): Promise<WriterLease>;
|
|
2493
|
+
private valid;
|
|
2494
|
+
/** Release after draining workloads and awaiting the final verified publish.
|
|
2495
|
+
* A failed/uncertain storage operation throws; retry with the same lease to
|
|
2496
|
+
* discover whether it completed. Never clears the verified recovery pointer.
|
|
2497
|
+
*/
|
|
2498
|
+
release(lease: WriterLease): Promise<"released" | "already-released">;
|
|
2499
|
+
renew(lease: WriterLease, ttlMs: number): Promise<{
|
|
2500
|
+
expiresAt: number;
|
|
2501
|
+
owner: string;
|
|
2502
|
+
generation: number;
|
|
2503
|
+
id: string;
|
|
2504
|
+
}>;
|
|
2505
|
+
publish(id: string, lease: WriterLease): Promise<void>;
|
|
2506
|
+
latest(): Promise<string | undefined>;
|
|
2507
|
+
bind(lease: WriterLease): ArchiveRepository;
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
/** Limits apply incrementally, including chunked uploads. Bodies reach fetch as a stream. */
|
|
2511
|
+
type NodeServeOptions = {
|
|
2512
|
+
port?: number;
|
|
2513
|
+
host?: string;
|
|
2514
|
+
maxBodyBytes?: number;
|
|
2515
|
+
requestTimeoutMs?: number;
|
|
2516
|
+
};
|
|
2517
|
+
/** Serve a FetchAPI with bounded streaming uploads and disconnect-aware response backpressure. */
|
|
2518
|
+
declare const serve: (api: FetchAPI, options?: NodeServeOptions) => Promise<Server>;
|
|
2519
|
+
|
|
2520
|
+
export { ACCESS_MODES, CLOUD_SERVICE_KEYS, DURABILITY_MODES, DeclarationError, FleetClient, FleetClientError, FleetClientResponseError, FleetInstrumentation, FleetObservations, FleetRunError, NamespacePool, RepositoryWriter, advertisedHttpBase, archiveCompatibility, archiveProtector, archiveReachability, assertArchiveCompatibility, assertFleetConfig, checkDeclaration, compactArchive, composeFleetSchema, createFleetIngress, createInstalledServiceLoader, declaredFleets, diffArchives, doctorFleet, fileParticipant, filesystemConditionalStore, filesystemOperationJournal, filesystemRepository, fleetCommands, fleetConfigSchema, incrementalArchive, ingressSupport, inspectArchive, isDeclaration, launchFleet, listen, localFleetConfig, materializeArchive, migrateAndVerify, migrateApplicationArchive, migrateArchive, ownedTransport, parseDeclaration, participantConformance, planRestoreBindings, providerServeOptions, providerServeValues, publishIncremental, readJsonOption, rebaseArchiveNamespace, reconcileOperation, rehearseFleet, renderConnections, replayFleetTrace, resolveServeControls, resolveServeIdBase, resolveServeSettings, runCli, s3ConditionalStore, s3Repository, serve, serveCommand, startFleet, validateArchive, validateFleetConfig, withFleetRun, writeConnections };
|
|
2521
|
+
export type { ArchiveChainEntry, ArchiveCompatibilityPolicy, ArchiveCompatibilityTags, ArchiveProtector, ArchiveRepository, AssertionAllowance, AuditEvent, AuditPolicy, CliCommand, CliOption, CliSpec, CliValues, ClockSynchronization, CommonServeOptions, ConditionalStore, ConditionalValue, ConfigIssue, ConfigService, ConformanceProbe, ConnectionField, ConnectionManifest, ConnectionMapping, Declaration, DeclaredFleet, DeclaredService, EndpointManifest, FileParticipant, Fleet, FleetArchive, FleetChild, FleetClientOptions, FleetDashboard, FleetDashboardStarter, FleetDiagnostics, FleetOptions, FleetSubject, FleetTarget, FleetTrace, IncrementalArchive, InstrumentationOptions, JournalRecord, ListenOptions, Listening, LogFormat, ManagementOptions, MigrationRegistry, MockingbirdConfig, NamespaceLease, NodeServeOptions, Observation, Operation, OperationJournal, OutboundPolicy, OwnedTransport, ParticipantMigration, ProtectedArchive, ProtectionOptions, ProtocolTarget, RestoreBinding, RestoreBindings, RunContext, RunDescriptor, RunOptions, S3RepositoryOptions, ScenarioBundle, ServeTarget, TelemetryEvent, TraceEvent, WorkloadAdapter, WorkloadContext, WriterLease, WriterState };
|