@crvouga/mockingbird-service-wholescripts 3.11.0 → 3.12.1
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 +14 -1
- package/DISCOVERY.md +29 -0
- package/dist/{chunk-NJMIP5WN.js → chunk-7TX4HHBL.js} +87 -21
- package/dist/chunk-7TX4HHBL.js.map +7 -0
- package/dist/chunk-VUGYJWO6.js +6098 -0
- package/dist/chunk-VUGYJWO6.js.map +7 -0
- package/dist/cli.js +2 -2
- package/dist/index.js +1 -1
- package/dist/server.d.ts +66 -1275
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-MJV4TUGN.js +0 -6092
- package/dist/chunk-MJV4TUGN.js.map +0 -7
- package/dist/chunk-NJMIP5WN.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-wholescripts
|
|
2
2
|
|
|
3
|
-
## 3.
|
|
3
|
+
## 3.12.1 (2026-11-12)
|
|
4
|
+
|
|
5
|
+
### Fixes and improvements
|
|
6
|
+
|
|
7
|
+
- serve vendor brand data from each emulator instead of the docs site ([0c72a69](https://github.com/crvouga/mockingbird/commit/0c72a693fc76e612936150598faef9787ad1c824))
|
|
8
|
+
- take SIGINT/SIGTERM before readiness is published ([d5a98a0](https://github.com/crvouga/mockingbird/commit/d5a98a09a344e12818c5c94cbea03621b528f841))
|
|
9
|
+
|
|
10
|
+
## 3.12.0 (2026-11-11)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- one dashboard for every admin UI and notification view ([d9fdf4d](https://github.com/crvouga/mockingbird/commit/d9fdf4dc1faeaa5c385f34bd5516323e49284b4d))
|
|
15
|
+
|
|
16
|
+
## 3.11.0 (2026-11-10)
|
|
4
17
|
|
|
5
18
|
### Features
|
|
6
19
|
|
package/DISCOVERY.md
CHANGED
|
@@ -4,6 +4,35 @@ This is the installed-package index for coding agents and tooling. All relative
|
|
|
4
4
|
inside `node_modules/@crvouga/mockingbird-service-wholescripts/`; no repository checkout is needed to discover the emulator's
|
|
5
5
|
supported surface or documented behavior.
|
|
6
6
|
|
|
7
|
+
## Run it in a fleet
|
|
8
|
+
|
|
9
|
+
The recommended way to run this emulator is in a fleet, next to the other emulators the
|
|
10
|
+
application calls: one `mockingbird.json`, one process, each emulator on its own port.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install -D @crvouga/mockingbird-fleet @crvouga/mockingbird-service-wholescripts
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`mockingbird.json` (add one entry per installed emulator; `"port": 0` picks a free port):
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"services": {
|
|
21
|
+
"wholescripts": { "port": 0 }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npx mockingbird-fleet serve --config mockingbird.json --dashboard --ready-file ready.json
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Read this emulator's URL from `services.<name>.url` in `ready.json` and point the client at it.
|
|
31
|
+
`adminBase` in the same file is the fleet controller, which resets, snapshots and restores every
|
|
32
|
+
emulator in one call, and `dashboard` is one page with every HTTP emulator's admin UI and the
|
|
33
|
+
notifications the application sent. The guide: <https://mockingbird.chrisvouga.dev/docs/fleets>. The README covers running this
|
|
34
|
+
emulator alone or in-process.
|
|
35
|
+
|
|
7
36
|
## Capability and behavior sources
|
|
8
37
|
|
|
9
38
|
| Question | Authoritative file | What it contains |
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
parseFaultHeader,
|
|
13
13
|
resolveAdminPrefix,
|
|
14
14
|
restoreClock
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-VUGYJWO6.js";
|
|
16
16
|
|
|
17
17
|
// src/server.ts
|
|
18
18
|
import { readFileSync } from "node:fs";
|
|
@@ -1668,9 +1668,7 @@ data: ${JSON.stringify(data)}
|
|
|
1668
1668
|
async handle(request, path, namespace, body, admin) {
|
|
1669
1669
|
const route = path.slice("/fleet".length), method = request.method;
|
|
1670
1670
|
if (path === "/ui")
|
|
1671
|
-
return new Response(fleetConsole(this.ctx.config.adminPrefix ?? "/__admin"), {
|
|
1672
|
-
headers: { "content-type": "text/html; charset=utf-8" }
|
|
1673
|
-
});
|
|
1671
|
+
return new Response(fleetConsole(this.ctx.config.adminPrefix ?? "/__admin", this.ctx.dashboard?.()), { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
1674
1672
|
if (route === "" && method === "GET")
|
|
1675
1673
|
return Response.json({
|
|
1676
1674
|
...this.capability(),
|
|
@@ -2640,7 +2638,8 @@ data: ${JSON.stringify(data)}
|
|
|
2640
2638
|
clearInterval(this.expiryTimer);
|
|
2641
2639
|
}
|
|
2642
2640
|
};
|
|
2643
|
-
var
|
|
2641
|
+
var escapeAttribute = (value) => value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
2642
|
+
var fleetConsole = (prefix, dashboard) => `<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Mockingbird Fleet</title><style>body{font:16px system-ui;max-width:1000px;margin:3rem auto;padding:1rem;background:#10151b;color:#e0e9f2}input,select,button{padding:.7rem;margin:.3rem;background:#233142;color:inherit;border:1px solid #60768b;border-radius:5px}pre{white-space:pre-wrap;overflow-wrap:anywhere}a{color:#9fdbff}</style><h1>Mockingbird Fleet</h1>${dashboard ? `<p id="dashboard">Every emulator's admin UI and the notifications UI are on the <a href="${escapeAttribute(dashboard)}">dashboard</a>.</p>` : ""}<label>Admin key <input id="key" type="password" autocomplete="off"></label><label>Namespace <input id="ns" value="default"></label><button id="refresh">Refresh</button><section id="children"></section><label>Action <select id="action"><option value="snapshots">Capture checkpoint</option><option value="reset">Reset namespace</option></select></label><button id="run">Run</button><h2>Lifecycle and operations</h2><pre id="result"></pre><script type="module">const base=${JSON.stringify(`${prefix}/fleet`)};const key=document.querySelector('#key'),ns=document.querySelector('#ns'),result=document.querySelector('#result');async function api(path,method='GET',body){const r=await fetch(base+path,{method,headers:{'content-type':'application/json','x-mockingbird-admin-key':key.value},...(body?{body:JSON.stringify(body)}:{})});const data=await r.json();result.textContent=JSON.stringify(data,null,2);return data}document.querySelector('#refresh').onclick=async()=>{const data=await api('');const host=document.querySelector('#children');host.replaceChildren();for(const [name,child]of Object.entries(data.manifest?.services??{})){const link=document.createElement('a');link.href=child.adminUrl;link.textContent=name+' ('+child.protocol+') ';host.append(link)}await api('/operations?namespace='+encodeURIComponent(ns.value))};document.querySelector('#run').onclick=()=>api('/namespaces/'+encodeURIComponent(ns.value)+'/'+document.querySelector('#action').value,'POST',{});</script></html>`;
|
|
2644
2643
|
|
|
2645
2644
|
// ../../adapters/node/dist/fleet-preflight.js
|
|
2646
2645
|
import { readFile, realpath } from "node:fs/promises";
|
|
@@ -2704,6 +2703,28 @@ var fleet_config_schema_default = {
|
|
|
2704
2703
|
}
|
|
2705
2704
|
}
|
|
2706
2705
|
},
|
|
2706
|
+
dashboard: {
|
|
2707
|
+
description: "Serve the dashboard (every emulator's admin UI and the notifications UI) next to the fleet. Honored by mockingbird-fleet serve.",
|
|
2708
|
+
anyOf: [
|
|
2709
|
+
{
|
|
2710
|
+
type: "boolean"
|
|
2711
|
+
},
|
|
2712
|
+
{
|
|
2713
|
+
type: "object",
|
|
2714
|
+
additionalProperties: false,
|
|
2715
|
+
properties: {
|
|
2716
|
+
port: {
|
|
2717
|
+
type: "integer",
|
|
2718
|
+
minimum: 0,
|
|
2719
|
+
maximum: 65535
|
|
2720
|
+
},
|
|
2721
|
+
host: {
|
|
2722
|
+
type: "string"
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
]
|
|
2727
|
+
},
|
|
2707
2728
|
cors: {
|
|
2708
2729
|
type: "object",
|
|
2709
2730
|
required: ["origins"],
|
|
@@ -2988,6 +3009,7 @@ async function preflightFleet(config, options) {
|
|
|
2988
3009
|
throw new Error("protected archive policy requires a protected repository; configure its protector before startup");
|
|
2989
3010
|
resolveAdminPrefix(config.adminPrefix);
|
|
2990
3011
|
normalizeBootControls(config.adminControls);
|
|
3012
|
+
validateDashboard(config.dashboard);
|
|
2991
3013
|
if (config.idBase !== void 0)
|
|
2992
3014
|
normalizeIdBase(config.idBase, "idBase");
|
|
2993
3015
|
const targets = /* @__PURE__ */ new Map();
|
|
@@ -3063,7 +3085,7 @@ async function preflightFleet(config, options) {
|
|
|
3063
3085
|
break;
|
|
3064
3086
|
}
|
|
3065
3087
|
}
|
|
3066
|
-
targets.set(name, { ...target, packageVersion: packageVersion ?? "3.
|
|
3088
|
+
targets.set(name, { ...target, packageVersion: packageVersion ?? "3.12.1" });
|
|
3067
3089
|
} catch (error) {
|
|
3068
3090
|
throw new Error(`service ${name}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
3069
3091
|
}
|
|
@@ -3148,6 +3170,22 @@ function validateFleetPolicies(options) {
|
|
|
3148
3170
|
if (duration !== void 0 && (!Number.isSafeInteger(duration) || duration < 1))
|
|
3149
3171
|
throw new Error("hook deadlines must be positive integer milliseconds");
|
|
3150
3172
|
}
|
|
3173
|
+
function validateDashboard(value) {
|
|
3174
|
+
if (value === void 0 || typeof value === "boolean")
|
|
3175
|
+
return;
|
|
3176
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
3177
|
+
throw new Error("dashboard: expected true, false or { port, host }");
|
|
3178
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
3179
|
+
if (key === "port") {
|
|
3180
|
+
if (!Number.isInteger(entry) || entry < 0 || entry > 65535)
|
|
3181
|
+
throw new Error("dashboard.port: expected an integer from 0 to 65535");
|
|
3182
|
+
} else if (key === "host") {
|
|
3183
|
+
if (typeof entry !== "string" || !entry)
|
|
3184
|
+
throw new Error("dashboard.host: expected a host");
|
|
3185
|
+
} else
|
|
3186
|
+
throw new Error(`dashboard.${key}: unknown key; expected port or host`);
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3151
3189
|
|
|
3152
3190
|
// ../../adapters/node/dist/serve.js
|
|
3153
3191
|
import { createServer } from "node:http";
|
|
@@ -3603,6 +3641,7 @@ async function startFleet(config, options) {
|
|
|
3603
3641
|
const checkpoints = /* @__PURE__ */ new Map();
|
|
3604
3642
|
let supervisor;
|
|
3605
3643
|
let management;
|
|
3644
|
+
let dashboard;
|
|
3606
3645
|
let manifest;
|
|
3607
3646
|
const privateConnections = () => Object.fromEntries([...children].map(([name, child]) => [
|
|
3608
3647
|
name,
|
|
@@ -3670,6 +3709,7 @@ async function startFleet(config, options) {
|
|
|
3670
3709
|
}
|
|
3671
3710
|
}
|
|
3672
3711
|
const cleanup = await Promise.allSettled([
|
|
3712
|
+
dashboard?.close(),
|
|
3673
3713
|
supervisor?.close(),
|
|
3674
3714
|
removeOwned(options.readyFile, id),
|
|
3675
3715
|
removeOwned(options.connectionsFile, id)
|
|
@@ -4036,6 +4076,7 @@ async function startFleet(config, options) {
|
|
|
4036
4076
|
clock,
|
|
4037
4077
|
transaction,
|
|
4038
4078
|
manifest: () => manifest,
|
|
4079
|
+
dashboard: () => dashboard?.url,
|
|
4039
4080
|
publish,
|
|
4040
4081
|
recovery,
|
|
4041
4082
|
controlling
|
|
@@ -4099,6 +4140,10 @@ async function startFleet(config, options) {
|
|
|
4099
4140
|
}
|
|
4100
4141
|
}
|
|
4101
4142
|
await management.startPolicies();
|
|
4143
|
+
if (options.dashboard) {
|
|
4144
|
+
dashboard = await options.dashboard({ manifest, config });
|
|
4145
|
+
manifest.dashboard = dashboard.url;
|
|
4146
|
+
}
|
|
4102
4147
|
await publish();
|
|
4103
4148
|
if (manifest.state === "ready")
|
|
4104
4149
|
options.onReady?.(manifest);
|
|
@@ -4898,20 +4943,35 @@ var start = async (target, values, config) => {
|
|
|
4898
4943
|
console.log(`${target.name} ${line.replaceAll("/__admin", adminPrefix)}`);
|
|
4899
4944
|
return listening;
|
|
4900
4945
|
};
|
|
4901
|
-
var
|
|
4902
|
-
|
|
4946
|
+
var watchSignals = () => {
|
|
4947
|
+
let received = false;
|
|
4948
|
+
let wake = () => {
|
|
4949
|
+
};
|
|
4950
|
+
const on = () => {
|
|
4951
|
+
received = true;
|
|
4952
|
+
wake();
|
|
4953
|
+
};
|
|
4954
|
+
const dispose = () => {
|
|
4903
4955
|
;
|
|
4904
|
-
process.removeListener("SIGINT",
|
|
4905
|
-
process.removeListener("SIGTERM",
|
|
4906
|
-
const results = await Promise.allSettled(servers.map((s) => s.close()));
|
|
4907
|
-
for (const result of results)
|
|
4908
|
-
if (result.status === "rejected")
|
|
4909
|
-
console.error(result.reason instanceof Error ? result.reason.message : String(result.reason));
|
|
4910
|
-
resolve4(results.some((r) => r.status === "rejected") ? 1 : 0);
|
|
4956
|
+
process.removeListener("SIGINT", on);
|
|
4957
|
+
process.removeListener("SIGTERM", on);
|
|
4911
4958
|
};
|
|
4912
|
-
process.once("SIGINT",
|
|
4913
|
-
process.once("SIGTERM",
|
|
4914
|
-
|
|
4959
|
+
process.once("SIGINT", on);
|
|
4960
|
+
process.once("SIGTERM", on);
|
|
4961
|
+
return {
|
|
4962
|
+
dispose,
|
|
4963
|
+
async untilSignal(servers) {
|
|
4964
|
+
if (!received)
|
|
4965
|
+
await new Promise((resolve4) => wake = resolve4);
|
|
4966
|
+
dispose();
|
|
4967
|
+
const results = await Promise.allSettled(servers.map((s) => s.close()));
|
|
4968
|
+
for (const result of results)
|
|
4969
|
+
if (result.status === "rejected")
|
|
4970
|
+
console.error(result.reason instanceof Error ? result.reason.message : String(result.reason));
|
|
4971
|
+
return results.some((r) => r.status === "rejected") ? 1 : 0;
|
|
4972
|
+
}
|
|
4973
|
+
};
|
|
4974
|
+
};
|
|
4915
4975
|
var serveCommand = (target) => ({
|
|
4916
4976
|
fleetTarget: target,
|
|
4917
4977
|
summary: `Serve the ${target.name} emulator or a configured fleet`,
|
|
@@ -4924,12 +4984,15 @@ var serveCommand = (target) => ({
|
|
|
4924
4984
|
}
|
|
4925
4985
|
const configPath = asString(values.config);
|
|
4926
4986
|
if (configPath !== void 0) {
|
|
4987
|
+
const signals2 = watchSignals();
|
|
4927
4988
|
try {
|
|
4928
4989
|
const config = JSON.parse(await readFile5(configPath, "utf8"));
|
|
4929
4990
|
config.adminPrefix = resolveAdminPrefix(config.adminPrefix ?? asString(values["admin-prefix"]) ?? process.env.MOCKINGBIRD_ADMIN_PREFIX);
|
|
4930
4991
|
const adminKey2 = config.adminKey ?? asString(values["admin-key"]) ?? process.env.MOCKINGBIRD_ADMIN_KEY;
|
|
4931
4992
|
if (adminKey2 !== void 0)
|
|
4932
4993
|
config.adminKey = adminKey2;
|
|
4994
|
+
if (config.dashboard)
|
|
4995
|
+
console.error(`${configPath}: "dashboard" is served by mockingbird-fleet (npx @crvouga/mockingbird-fleet serve --config ${configPath}); a service's own serve command starts the fleet without it`);
|
|
4933
4996
|
const adminControls = await resolveServeControls(values, process.env, config.adminControls);
|
|
4934
4997
|
if (adminControls !== void 0)
|
|
4935
4998
|
config.adminControls = adminControls;
|
|
@@ -4951,8 +5014,9 @@ var serveCommand = (target) => ({
|
|
|
4951
5014
|
console.log(`${name} emulator listening on ${endpoint.url}`);
|
|
4952
5015
|
}
|
|
4953
5016
|
});
|
|
4954
|
-
return untilSignal([fleet]);
|
|
5017
|
+
return signals2.untilSignal([fleet]);
|
|
4955
5018
|
} catch (error) {
|
|
5019
|
+
signals2.dispose();
|
|
4956
5020
|
console.error(error instanceof Error ? error.message : String(error));
|
|
4957
5021
|
return 1;
|
|
4958
5022
|
}
|
|
@@ -4965,6 +5029,7 @@ var serveCommand = (target) => ({
|
|
|
4965
5029
|
const adminKey = asString(values["admin-key"]) ?? process.env.MOCKINGBIRD_ADMIN_KEY;
|
|
4966
5030
|
const seed = asString(values.seed) ?? process.env.MOCKINGBIRD_SEED;
|
|
4967
5031
|
let listening;
|
|
5032
|
+
const signals = watchSignals();
|
|
4968
5033
|
try {
|
|
4969
5034
|
const adminControls = await resolveServeControls(values);
|
|
4970
5035
|
const idBase = resolveServeIdBase(values);
|
|
@@ -4981,10 +5046,11 @@ var serveCommand = (target) => ({
|
|
|
4981
5046
|
log
|
|
4982
5047
|
});
|
|
4983
5048
|
} catch (error) {
|
|
5049
|
+
signals.dispose();
|
|
4984
5050
|
console.error(error instanceof Error ? error.message : String(error));
|
|
4985
5051
|
return 1;
|
|
4986
5052
|
}
|
|
4987
|
-
return untilSignal([listening]);
|
|
5053
|
+
return signals.untilSignal([listening]);
|
|
4988
5054
|
}
|
|
4989
5055
|
});
|
|
4990
5056
|
|
|
@@ -5096,4 +5162,4 @@ export {
|
|
|
5096
5162
|
loadCatalogFile,
|
|
5097
5163
|
serveTarget
|
|
5098
5164
|
};
|
|
5099
|
-
//# sourceMappingURL=chunk-
|
|
5165
|
+
//# sourceMappingURL=chunk-7TX4HHBL.js.map
|