@crvouga/mockingbird-runtime 0.3.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/adapter-node.d.ts +29 -1
- package/dist/adapter-node.js +11 -6
- package/dist/adapter-node.js.map +2 -2
- package/dist/admin-ui.js +1 -1
- package/dist/admin-ui.js.map +1 -1
- package/dist/{chunk-KD6FHYQP.js → chunk-BK5KDNUE.js} +454 -262
- package/dist/{chunk-KD6FHYQP.js.map → chunk-BK5KDNUE.js.map} +3 -3
- package/dist/{chunk-M4HUKBLC.js → chunk-GAIPLMRY.js} +22 -32
- package/dist/chunk-GAIPLMRY.js.map +7 -0
- package/dist/{chunk-ZQBZSSSP.js → chunk-SVG34QFE.js} +3 -3
- package/dist/client.bundle-6XOKJ6BJ.js +6 -0
- package/dist/client.bundle-6XOKJ6BJ.js.map +7 -0
- package/dist/http-provider.d.ts +3 -2
- package/dist/http-provider.js +649 -1054
- package/dist/http-provider.js.map +3 -3
- package/dist/mqtt-broker/node.d.ts +1 -0
- package/dist/mqtt-broker/node.js +3 -3
- package/dist/mqtt-broker.d.ts +1 -0
- package/dist/mqtt-broker.js +3 -3
- package/dist/server-32IZ5ZMR.js +17379 -0
- package/dist/server-32IZ5ZMR.js.map +7 -0
- package/dist/server-SXO3PUBW.js +16059 -0
- package/dist/server-SXO3PUBW.js.map +7 -0
- package/dist/service/admin.js +1 -1
- package/dist/service.d.ts +65 -3
- package/dist/service.js +6 -2
- package/package.json +6 -6
- package/dist/chunk-M4HUKBLC.js.map +0 -7
- /package/dist/{chunk-ZQBZSSSP.js.map → chunk-SVG34QFE.js.map} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @crvouga/mockingbird-runtime
|
|
2
2
|
|
|
3
|
-
> Local emulators. Real API contracts. Part of [Mockingbird](https://github.com/crvouga
|
|
3
|
+
> Local emulators. Real API contracts. Part of [Mockingbird](https://github.com/crvouga/mockingbird).
|
|
4
4
|
|
|
5
5
|
The runtime every Mockingbird emulator service is built on: the router, the `/__admin` API and
|
|
6
6
|
page, snapshots, faults, the clock, and the HTTP and OpenAPI helpers. Each
|
package/dist/adapter-node.d.ts
CHANGED
|
@@ -604,6 +604,29 @@ type MetricsReport = {
|
|
|
604
604
|
faults: number;
|
|
605
605
|
totalDurationMs: number;
|
|
606
606
|
};
|
|
607
|
+
/** What a runtime holds across every namespace: the gauges a long-running mock is watched by. */
|
|
608
|
+
type ResourceReport = {
|
|
609
|
+
/** Namespaces that hold state now (`GET /__admin/namespaces`). */
|
|
610
|
+
namespaces: number;
|
|
611
|
+
/** Stored records, every collection and branch included. */
|
|
612
|
+
records: number;
|
|
613
|
+
/** Journal entries held (`GET /__admin/requests`). */
|
|
614
|
+
journalEntries: number;
|
|
615
|
+
/** Named snapshots held. */
|
|
616
|
+
snapshots: number;
|
|
617
|
+
/** Webhook deliveries waiting for an attempt or a retry. */
|
|
618
|
+
webhooksPending: number;
|
|
619
|
+
/** Heap in use, or `null` where the host cannot say. */
|
|
620
|
+
heapUsedBytes: number | null;
|
|
621
|
+
/** Namespaces forgotten for being idle since the runtime started. */
|
|
622
|
+
namespacesExpired: number;
|
|
623
|
+
/** Idle namespaces whose drop failed; each is retried on a later request. */
|
|
624
|
+
idleExpiryFailures: number;
|
|
625
|
+
/** Requests answered `507` for the record cap, their writes rolled back. */
|
|
626
|
+
recordLimitRefusals: number;
|
|
627
|
+
/** Snapshots refused for the snapshot cap. */
|
|
628
|
+
snapshotLimitRefusals: number;
|
|
629
|
+
};
|
|
607
630
|
type Metrics = {
|
|
608
631
|
record(entry: RequestLog): void;
|
|
609
632
|
report(namespace?: string): MetricsReport;
|
|
@@ -634,6 +657,8 @@ type Journal = {
|
|
|
634
657
|
readonly size: number;
|
|
635
658
|
record(entry: JournalEntry): void;
|
|
636
659
|
list(query?: JournalQuery): JournalEntry[];
|
|
660
|
+
/** Entries held for one namespace, or for every namespace. */
|
|
661
|
+
count(namespace?: string): number;
|
|
637
662
|
/** Forget one namespace's entries, or every namespace's. */
|
|
638
663
|
clear(namespace?: string): void;
|
|
639
664
|
};
|
|
@@ -838,7 +863,8 @@ type WebhookHub = {
|
|
|
838
863
|
deliveryId: string;
|
|
839
864
|
}) => void): () => void;
|
|
840
865
|
setTransportPolicy(policy: OwnedTransport): void;
|
|
841
|
-
|
|
866
|
+
/** Deliveries waiting in one namespace, or in every namespace. */
|
|
867
|
+
pending(namespace?: string): number;
|
|
842
868
|
snapshot(namespace: string): unknown;
|
|
843
869
|
exportSnapshot(handle: unknown): unknown;
|
|
844
870
|
importSnapshot(namespace: string, document: unknown): unknown;
|
|
@@ -916,6 +942,8 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
|
|
|
916
942
|
reset(namespace?: string): Promise<void>;
|
|
917
943
|
/** Reset a namespace and forget it, releasing everything it held. */
|
|
918
944
|
dropNamespace(namespace: string): Promise<void>;
|
|
945
|
+
/** What the runtime holds across every namespace, as `GET /__admin/metrics` reports it. */
|
|
946
|
+
resources(): ResourceReport;
|
|
919
947
|
/** A namespace's controls: seed, clock, virtual time, latency, faults and snapshots. */
|
|
920
948
|
controls(namespace?: string): ControlState & {
|
|
921
949
|
snapshots: SnapshotInfo[];
|
package/dist/adapter-node.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
normalizeIdBase,
|
|
3
3
|
ownedTransport,
|
|
4
4
|
signV4
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-BK5KDNUE.js";
|
|
6
6
|
import "./chunk-2KDYLZXC.js";
|
|
7
7
|
import {
|
|
8
8
|
createClock,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
resolveAdminPrefix,
|
|
14
14
|
restoreClock,
|
|
15
15
|
upstreamRequest
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-GAIPLMRY.js";
|
|
17
17
|
import {
|
|
18
18
|
assertArchiveCompatibility,
|
|
19
19
|
assertCompatibilityTags,
|
|
@@ -2186,7 +2186,7 @@ data: ${JSON.stringify(data)}
|
|
|
2186
2186
|
async handle(request, path, namespace, body, admin) {
|
|
2187
2187
|
const route = path.slice("/fleet".length), method = request.method;
|
|
2188
2188
|
if (path === "/ui")
|
|
2189
|
-
return new Response(fleetConsole(this.ctx.config.adminPrefix ?? "/__admin", this.ctx.dashboard?.()), { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
2189
|
+
return new Response(await fleetConsole(this.ctx.config.adminPrefix ?? "/__admin", this.ctx.dashboard?.()), { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
2190
2190
|
if (route === "" && method === "GET")
|
|
2191
2191
|
return Response.json({
|
|
2192
2192
|
...this.capability(),
|
|
@@ -3172,8 +3172,13 @@ data: ${JSON.stringify(data)}
|
|
|
3172
3172
|
clearInterval(this.expiryTimer);
|
|
3173
3173
|
}
|
|
3174
3174
|
};
|
|
3175
|
-
var
|
|
3176
|
-
|
|
3175
|
+
var fleetConsole = async (prefix, dashboard) => {
|
|
3176
|
+
const [{ fleetConsolePage }, { BUNDLE }] = await Promise.all([
|
|
3177
|
+
import("./server-32IZ5ZMR.js"),
|
|
3178
|
+
import("./client.bundle-6XOKJ6BJ.js")
|
|
3179
|
+
]);
|
|
3180
|
+
return fleetConsolePage({ base: `${prefix}/fleet`, ...dashboard ? { dashboard } : {} }, { source: BUNDLE });
|
|
3181
|
+
};
|
|
3177
3182
|
|
|
3178
3183
|
// ../adapters/node/dist/fleet-preflight.js
|
|
3179
3184
|
import { readFile as readFile3, realpath } from "node:fs/promises";
|
|
@@ -3646,7 +3651,7 @@ async function preflightFleet(config, options) {
|
|
|
3646
3651
|
break;
|
|
3647
3652
|
}
|
|
3648
3653
|
}
|
|
3649
|
-
targets.set(name, { ...target, packageVersion: packageVersion ?? "0.
|
|
3654
|
+
targets.set(name, { ...target, packageVersion: packageVersion ?? "0.5.0" });
|
|
3650
3655
|
} catch (error) {
|
|
3651
3656
|
throw new Error(`service ${name}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
3652
3657
|
}
|