@crvouga/mockingbird-service-step-functions 1.0.0 → 1.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/CHANGELOG.md +13 -4
- package/dist/{chunk-KFFQOSA5.js → chunk-3M5JN5V6.js} +5 -3
- package/dist/chunk-3M5JN5V6.js.map +7 -0
- package/dist/{chunk-MFKAN6YO.js → chunk-VEJHW5LK.js} +12 -3
- package/dist/chunk-VEJHW5LK.js.map +7 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +129 -101
- package/dist/index.js +1 -1
- package/dist/server.d.ts +233 -177
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-KFFQOSA5.js.map +0 -7
- package/dist/chunk-MFKAN6YO.js.map +0 -7
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -216,94 +216,6 @@ type FaultRegistry = {
|
|
|
216
216
|
take(candidate: FaultCandidate): Promise<FaultHit[]>;
|
|
217
217
|
};
|
|
218
218
|
|
|
219
|
-
/** One handled request, as the structured log sees it. */
|
|
220
|
-
type RequestLog = {
|
|
221
|
-
service: string;
|
|
222
|
-
namespace: string;
|
|
223
|
-
operationId: string | undefined;
|
|
224
|
-
method: string;
|
|
225
|
-
path: string;
|
|
226
|
-
status: number;
|
|
227
|
-
durationMs: number;
|
|
228
|
-
/** True when the path matched no operation in the contract. */
|
|
229
|
-
unmatched: boolean;
|
|
230
|
-
/** Set when a fault rule produced the response. */
|
|
231
|
-
faultId?: string;
|
|
232
|
-
/** Resource ids the handler touched (`userId`, `orderId`, …), when the service reports them. */
|
|
233
|
-
ids?: Record<string, string>;
|
|
234
|
-
/** Set when the service created a resource the request referred to but that did not exist. */
|
|
235
|
-
adopted?: boolean;
|
|
236
|
-
};
|
|
237
|
-
type MetricsReport = {
|
|
238
|
-
requests: number;
|
|
239
|
-
/** Counts keyed `<operationId> <status>`. */
|
|
240
|
-
byOperation: Record<string, number>;
|
|
241
|
-
/**
|
|
242
|
-
* Paths that matched no operation, most frequent first.
|
|
243
|
-
*
|
|
244
|
-
* This is the early-warning signal: a consumer calling something the mock does
|
|
245
|
-
* not implement shows up here as a count, before it fails a suite as a 404.
|
|
246
|
-
*/
|
|
247
|
-
unmatched: {
|
|
248
|
-
method: string;
|
|
249
|
-
path: string;
|
|
250
|
-
count: number;
|
|
251
|
-
}[];
|
|
252
|
-
faults: number;
|
|
253
|
-
totalDurationMs: number;
|
|
254
|
-
};
|
|
255
|
-
type Metrics = {
|
|
256
|
-
record(entry: RequestLog): void;
|
|
257
|
-
report(): MetricsReport;
|
|
258
|
-
reset(): void;
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
/** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
|
|
262
|
-
type JournalEntry = RequestLog & {
|
|
263
|
-
at: string;
|
|
264
|
-
};
|
|
265
|
-
type JournalQuery = {
|
|
266
|
-
/** Only this namespace. Omit for every namespace, oldest first across all of them. */
|
|
267
|
-
namespace?: string;
|
|
268
|
-
operationId?: string;
|
|
269
|
-
status?: number;
|
|
270
|
-
/** Only entries at or after this instant (epoch ms). */
|
|
271
|
-
since?: number;
|
|
272
|
-
/** At most this many, the most recent kept. */
|
|
273
|
-
limit?: number;
|
|
274
|
-
};
|
|
275
|
-
type Journal = {
|
|
276
|
-
readonly size: number;
|
|
277
|
-
record(entry: JournalEntry): void;
|
|
278
|
-
list(query?: JournalQuery): JournalEntry[];
|
|
279
|
-
/** Forget one namespace's entries, or every namespace's. */
|
|
280
|
-
clear(namespace?: string): void;
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
/** Credential → namespace mapping behind `PUT /__admin/credentials`. */
|
|
284
|
-
type CredentialRegistry = {
|
|
285
|
-
set(credential: string, namespace: string): void;
|
|
286
|
-
get(credential: string): string | undefined;
|
|
287
|
-
remove(credential: string): boolean;
|
|
288
|
-
clear(): void;
|
|
289
|
-
entries(): {
|
|
290
|
-
credential: string;
|
|
291
|
-
namespace: string;
|
|
292
|
-
}[];
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
297
|
-
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
298
|
-
*/
|
|
299
|
-
declare class IdSequence {
|
|
300
|
-
private readonly sqlite;
|
|
301
|
-
private readonly namespace;
|
|
302
|
-
private readonly salt;
|
|
303
|
-
constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
|
|
304
|
-
next(prefix: string, length?: number): string;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
219
|
/** A stable identifier for a point in a {@link Timeline}. */
|
|
308
220
|
type CheckpointId = string;
|
|
309
221
|
/** An immutable node in a timeline's checkpoint DAG. */
|
|
@@ -394,6 +306,135 @@ interface FetchAPI {
|
|
|
394
306
|
fetch(request: Request): Promise<Response>;
|
|
395
307
|
}
|
|
396
308
|
|
|
309
|
+
/** Options every provider constructor accepts. */
|
|
310
|
+
type APIOptions = {
|
|
311
|
+
/** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
|
|
312
|
+
sqlite?: SqliteClient$1;
|
|
313
|
+
/** Clock used for `created`-style fields. Default `Date.now`. */
|
|
314
|
+
now?: () => number;
|
|
315
|
+
/**
|
|
316
|
+
* Storage namespace for this instance's records. Instances sharing one SQLite
|
|
317
|
+
* client stay isolated when their namespaces differ. Defaults to the service name.
|
|
318
|
+
*/
|
|
319
|
+
namespace?: string;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
|
|
324
|
+
* `kind` is `media_type` when the body is present but its media type is not one the operation
|
|
325
|
+
* accepts (a `415` on most vendors), `syntax` when it could not be decoded, `required` when
|
|
326
|
+
* the operation needs a body and none arrived, and `schema` for a contract violation.
|
|
327
|
+
*/
|
|
328
|
+
type BodyIssue = {
|
|
329
|
+
path: string;
|
|
330
|
+
message: string;
|
|
331
|
+
kind?: "media_type" | "syntax" | "required" | "schema";
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* What the mock received from a request it rejected, so a 4xx can be attributed after the
|
|
336
|
+
* fact (an empty body, a missing `content-type`, a schema violation) without logging the body.
|
|
337
|
+
*/
|
|
338
|
+
type RejectedRequest = {
|
|
339
|
+
/** The raw `content-type` header, or `null` when the request sent none. */
|
|
340
|
+
contentType: string | null;
|
|
341
|
+
/** Bytes of body received from `content-length` (`0` for none), or `null` when the client sent no length (a streamed / chunked body). */
|
|
342
|
+
bodyBytes: number | null;
|
|
343
|
+
/** The raw `transfer-encoding` header (`chunked`), or `null`. */
|
|
344
|
+
transferEncoding: string | null;
|
|
345
|
+
};
|
|
346
|
+
/** One handled request, as the structured log sees it. */
|
|
347
|
+
type RequestLog = {
|
|
348
|
+
service: string;
|
|
349
|
+
namespace: string;
|
|
350
|
+
operationId: string | undefined;
|
|
351
|
+
method: string;
|
|
352
|
+
path: string;
|
|
353
|
+
status: number;
|
|
354
|
+
durationMs: number;
|
|
355
|
+
/** True when the path matched no operation in the contract. */
|
|
356
|
+
unmatched: boolean;
|
|
357
|
+
/** Set when a fault rule produced the response. */
|
|
358
|
+
faultId?: string;
|
|
359
|
+
/** Resource ids the handler touched (`userId`, `orderId`, …), when the service reports them. */
|
|
360
|
+
ids?: Record<string, string>;
|
|
361
|
+
/** Set when the service created a resource the request referred to but that did not exist. */
|
|
362
|
+
adopted?: boolean;
|
|
363
|
+
/** Set on a rejection (status ≥ 400) the mock produced itself, never on a scripted fault. */
|
|
364
|
+
request?: RejectedRequest;
|
|
365
|
+
/** The validation issues behind a rejection, when the service found any. */
|
|
366
|
+
issues?: BodyIssue[];
|
|
367
|
+
};
|
|
368
|
+
type MetricsReport = {
|
|
369
|
+
requests: number;
|
|
370
|
+
/** Counts keyed `<operationId> <status>`. */
|
|
371
|
+
byOperation: Record<string, number>;
|
|
372
|
+
/**
|
|
373
|
+
* Paths that matched no operation, most frequent first.
|
|
374
|
+
*
|
|
375
|
+
* This is the early-warning signal: a consumer calling something the mock does
|
|
376
|
+
* not implement shows up here as a count, before it fails a suite as a 404.
|
|
377
|
+
*/
|
|
378
|
+
unmatched: {
|
|
379
|
+
method: string;
|
|
380
|
+
path: string;
|
|
381
|
+
count: number;
|
|
382
|
+
}[];
|
|
383
|
+
faults: number;
|
|
384
|
+
totalDurationMs: number;
|
|
385
|
+
};
|
|
386
|
+
type Metrics = {
|
|
387
|
+
record(entry: RequestLog): void;
|
|
388
|
+
report(): MetricsReport;
|
|
389
|
+
reset(): void;
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
/** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
|
|
393
|
+
type JournalEntry = RequestLog & {
|
|
394
|
+
at: string;
|
|
395
|
+
};
|
|
396
|
+
type JournalQuery = {
|
|
397
|
+
/** Only this namespace. Omit for every namespace, oldest first across all of them. */
|
|
398
|
+
namespace?: string;
|
|
399
|
+
operationId?: string;
|
|
400
|
+
status?: number;
|
|
401
|
+
/** Only entries at or after this instant (epoch ms). */
|
|
402
|
+
since?: number;
|
|
403
|
+
/** At most this many, the most recent kept. */
|
|
404
|
+
limit?: number;
|
|
405
|
+
};
|
|
406
|
+
type Journal = {
|
|
407
|
+
readonly size: number;
|
|
408
|
+
record(entry: JournalEntry): void;
|
|
409
|
+
list(query?: JournalQuery): JournalEntry[];
|
|
410
|
+
/** Forget one namespace's entries, or every namespace's. */
|
|
411
|
+
clear(namespace?: string): void;
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
/** Credential → namespace mapping behind `PUT /__admin/credentials`. */
|
|
415
|
+
type CredentialRegistry = {
|
|
416
|
+
set(credential: string, namespace: string): void;
|
|
417
|
+
get(credential: string): string | undefined;
|
|
418
|
+
remove(credential: string): boolean;
|
|
419
|
+
clear(): void;
|
|
420
|
+
entries(): {
|
|
421
|
+
credential: string;
|
|
422
|
+
namespace: string;
|
|
423
|
+
}[];
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
428
|
+
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
429
|
+
*/
|
|
430
|
+
declare class IdSequence {
|
|
431
|
+
private readonly sqlite;
|
|
432
|
+
private readonly namespace;
|
|
433
|
+
private readonly salt;
|
|
434
|
+
constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
|
|
435
|
+
next(prefix: string, length?: number): string;
|
|
436
|
+
}
|
|
437
|
+
|
|
397
438
|
/**
|
|
398
439
|
* A point-in-time copy of everything a service namespace holds.
|
|
399
440
|
*
|
|
@@ -544,19 +585,6 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
|
|
|
544
585
|
timeline(namespace?: string): Timeline<ServiceTimelineState>;
|
|
545
586
|
};
|
|
546
587
|
|
|
547
|
-
/** Options every provider constructor accepts. */
|
|
548
|
-
type APIOptions = {
|
|
549
|
-
/** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
|
|
550
|
-
sqlite?: SqliteClient$1;
|
|
551
|
-
/** Clock used for `created`-style fields. Default `Date.now`. */
|
|
552
|
-
now?: () => number;
|
|
553
|
-
/**
|
|
554
|
-
* Storage namespace for this instance's records. Instances sharing one SQLite
|
|
555
|
-
* client stay isolated when their namespaces differ. Defaults to the service name.
|
|
556
|
-
*/
|
|
557
|
-
namespace?: string;
|
|
558
|
-
};
|
|
559
|
-
|
|
560
588
|
/**
|
|
561
589
|
* The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
|
|
562
590
|
* Unknown keys (including `x-*` extensions) are preserved on every object.
|