@crvouga/mockingbird-service-rxvortex 3.11.0 → 3.12.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/CHANGELOG.md +7 -1
- package/DISCOVERY.md +29 -0
- package/dist/chunk-74KTYLZO.js +6620 -0
- package/dist/chunk-74KTYLZO.js.map +7 -0
- package/dist/{chunk-GJEFDIPI.js → chunk-TVEL6SVE.js} +54 -7
- package/dist/chunk-TVEL6SVE.js.map +7 -0
- package/dist/cli.js +2 -2
- package/dist/index.js +1 -1
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-GJEFDIPI.js.map +0 -7
- package/dist/chunk-KYF6NH62.js +0 -6620
- package/dist/chunk-KYF6NH62.js.map +0 -7
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
parseFaultHeader,
|
|
11
11
|
resolveAdminPrefix,
|
|
12
12
|
restoreClock
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-74KTYLZO.js";
|
|
14
14
|
|
|
15
15
|
// src/server.ts
|
|
16
16
|
import { readFileSync } from "node:fs";
|
|
@@ -1666,9 +1666,7 @@ data: ${JSON.stringify(data)}
|
|
|
1666
1666
|
async handle(request, path, namespace, body, admin) {
|
|
1667
1667
|
const route = path.slice("/fleet".length), method = request.method;
|
|
1668
1668
|
if (path === "/ui")
|
|
1669
|
-
return new Response(fleetConsole(this.ctx.config.adminPrefix ?? "/__admin"), {
|
|
1670
|
-
headers: { "content-type": "text/html; charset=utf-8" }
|
|
1671
|
-
});
|
|
1669
|
+
return new Response(fleetConsole(this.ctx.config.adminPrefix ?? "/__admin", this.ctx.dashboard?.()), { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
1672
1670
|
if (route === "" && method === "GET")
|
|
1673
1671
|
return Response.json({
|
|
1674
1672
|
...this.capability(),
|
|
@@ -2638,7 +2636,8 @@ data: ${JSON.stringify(data)}
|
|
|
2638
2636
|
clearInterval(this.expiryTimer);
|
|
2639
2637
|
}
|
|
2640
2638
|
};
|
|
2641
|
-
var
|
|
2639
|
+
var escapeAttribute = (value) => value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
2640
|
+
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>`;
|
|
2642
2641
|
|
|
2643
2642
|
// ../../adapters/node/dist/fleet-preflight.js
|
|
2644
2643
|
import { readFile, realpath } from "node:fs/promises";
|
|
@@ -2702,6 +2701,28 @@ var fleet_config_schema_default = {
|
|
|
2702
2701
|
}
|
|
2703
2702
|
}
|
|
2704
2703
|
},
|
|
2704
|
+
dashboard: {
|
|
2705
|
+
description: "Serve the dashboard (every emulator's admin UI and the notifications UI) next to the fleet. Honored by mockingbird-fleet serve.",
|
|
2706
|
+
anyOf: [
|
|
2707
|
+
{
|
|
2708
|
+
type: "boolean"
|
|
2709
|
+
},
|
|
2710
|
+
{
|
|
2711
|
+
type: "object",
|
|
2712
|
+
additionalProperties: false,
|
|
2713
|
+
properties: {
|
|
2714
|
+
port: {
|
|
2715
|
+
type: "integer",
|
|
2716
|
+
minimum: 0,
|
|
2717
|
+
maximum: 65535
|
|
2718
|
+
},
|
|
2719
|
+
host: {
|
|
2720
|
+
type: "string"
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
]
|
|
2725
|
+
},
|
|
2705
2726
|
cors: {
|
|
2706
2727
|
type: "object",
|
|
2707
2728
|
required: ["origins"],
|
|
@@ -2986,6 +3007,7 @@ async function preflightFleet(config, options) {
|
|
|
2986
3007
|
throw new Error("protected archive policy requires a protected repository; configure its protector before startup");
|
|
2987
3008
|
resolveAdminPrefix(config.adminPrefix);
|
|
2988
3009
|
normalizeBootControls(config.adminControls);
|
|
3010
|
+
validateDashboard(config.dashboard);
|
|
2989
3011
|
if (config.idBase !== void 0)
|
|
2990
3012
|
normalizeIdBase(config.idBase, "idBase");
|
|
2991
3013
|
const targets = /* @__PURE__ */ new Map();
|
|
@@ -3061,7 +3083,7 @@ async function preflightFleet(config, options) {
|
|
|
3061
3083
|
break;
|
|
3062
3084
|
}
|
|
3063
3085
|
}
|
|
3064
|
-
targets.set(name, { ...target, packageVersion: packageVersion ?? "3.
|
|
3086
|
+
targets.set(name, { ...target, packageVersion: packageVersion ?? "3.12.0" });
|
|
3065
3087
|
} catch (error) {
|
|
3066
3088
|
throw new Error(`service ${name}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
3067
3089
|
}
|
|
@@ -3146,6 +3168,22 @@ function validateFleetPolicies(options) {
|
|
|
3146
3168
|
if (duration !== void 0 && (!Number.isSafeInteger(duration) || duration < 1))
|
|
3147
3169
|
throw new Error("hook deadlines must be positive integer milliseconds");
|
|
3148
3170
|
}
|
|
3171
|
+
function validateDashboard(value) {
|
|
3172
|
+
if (value === void 0 || typeof value === "boolean")
|
|
3173
|
+
return;
|
|
3174
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
3175
|
+
throw new Error("dashboard: expected true, false or { port, host }");
|
|
3176
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
3177
|
+
if (key === "port") {
|
|
3178
|
+
if (!Number.isInteger(entry) || entry < 0 || entry > 65535)
|
|
3179
|
+
throw new Error("dashboard.port: expected an integer from 0 to 65535");
|
|
3180
|
+
} else if (key === "host") {
|
|
3181
|
+
if (typeof entry !== "string" || !entry)
|
|
3182
|
+
throw new Error("dashboard.host: expected a host");
|
|
3183
|
+
} else
|
|
3184
|
+
throw new Error(`dashboard.${key}: unknown key; expected port or host`);
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3149
3187
|
|
|
3150
3188
|
// ../../adapters/node/dist/serve.js
|
|
3151
3189
|
import { createServer } from "node:http";
|
|
@@ -3601,6 +3639,7 @@ async function startFleet(config, options) {
|
|
|
3601
3639
|
const checkpoints = /* @__PURE__ */ new Map();
|
|
3602
3640
|
let supervisor;
|
|
3603
3641
|
let management;
|
|
3642
|
+
let dashboard;
|
|
3604
3643
|
let manifest;
|
|
3605
3644
|
const privateConnections = () => Object.fromEntries([...children].map(([name, child]) => [
|
|
3606
3645
|
name,
|
|
@@ -3668,6 +3707,7 @@ async function startFleet(config, options) {
|
|
|
3668
3707
|
}
|
|
3669
3708
|
}
|
|
3670
3709
|
const cleanup = await Promise.allSettled([
|
|
3710
|
+
dashboard?.close(),
|
|
3671
3711
|
supervisor?.close(),
|
|
3672
3712
|
removeOwned(options.readyFile, id),
|
|
3673
3713
|
removeOwned(options.connectionsFile, id)
|
|
@@ -4034,6 +4074,7 @@ async function startFleet(config, options) {
|
|
|
4034
4074
|
clock,
|
|
4035
4075
|
transaction,
|
|
4036
4076
|
manifest: () => manifest,
|
|
4077
|
+
dashboard: () => dashboard?.url,
|
|
4037
4078
|
publish,
|
|
4038
4079
|
recovery,
|
|
4039
4080
|
controlling
|
|
@@ -4097,6 +4138,10 @@ async function startFleet(config, options) {
|
|
|
4097
4138
|
}
|
|
4098
4139
|
}
|
|
4099
4140
|
await management.startPolicies();
|
|
4141
|
+
if (options.dashboard) {
|
|
4142
|
+
dashboard = await options.dashboard({ manifest, config });
|
|
4143
|
+
manifest.dashboard = dashboard.url;
|
|
4144
|
+
}
|
|
4100
4145
|
await publish();
|
|
4101
4146
|
if (manifest.state === "ready")
|
|
4102
4147
|
options.onReady?.(manifest);
|
|
@@ -4928,6 +4973,8 @@ var serveCommand = (target) => ({
|
|
|
4928
4973
|
const adminKey2 = config.adminKey ?? asString(values["admin-key"]) ?? process.env.MOCKINGBIRD_ADMIN_KEY;
|
|
4929
4974
|
if (adminKey2 !== void 0)
|
|
4930
4975
|
config.adminKey = adminKey2;
|
|
4976
|
+
if (config.dashboard)
|
|
4977
|
+
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`);
|
|
4931
4978
|
const adminControls = await resolveServeControls(values, process.env, config.adminControls);
|
|
4932
4979
|
if (adminControls !== void 0)
|
|
4933
4980
|
config.adminControls = adminControls;
|
|
@@ -5100,4 +5147,4 @@ export {
|
|
|
5100
5147
|
loadCatalogFile,
|
|
5101
5148
|
serveTarget
|
|
5102
5149
|
};
|
|
5103
|
-
//# sourceMappingURL=chunk-
|
|
5150
|
+
//# sourceMappingURL=chunk-TVEL6SVE.js.map
|