@crvouga/mockingbird-service-slack 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-6Z2MR3PO.js → chunk-3IUSFYOG.js} +5 -1
- package/dist/chunk-3IUSFYOG.js.map +7 -0
- package/dist/chunk-OUEYWMNG.js +12994 -0
- package/dist/chunk-OUEYWMNG.js.map +7 -0
- package/dist/{chunk-LW3C55S4.js → chunk-PLRHP2R3.js} +87 -21
- package/dist/chunk-PLRHP2R3.js.map +7 -0
- package/dist/cli.js +3 -3
- package/dist/{crypto-II2ETGQQ.js → crypto-BCOLH5QH.js} +2 -2
- package/dist/{helpers-5D4ROPWG.js → helpers-PUPWPGQS.js} +2 -2
- package/dist/index.js +2 -2
- package/dist/server.d.ts +62 -1504
- package/dist/server.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-4OFEQI5S.js +0 -12990
- package/dist/chunk-4OFEQI5S.js.map +0 -7
- package/dist/chunk-6Z2MR3PO.js.map +0 -7
- package/dist/chunk-LW3C55S4.js.map +0 -7
- /package/dist/{crypto-II2ETGQQ.js.map → crypto-BCOLH5QH.js.map} +0 -0
- /package/dist/{helpers-5D4ROPWG.js.map → helpers-PUPWPGQS.js.map} +0 -0
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
resolveAdminPrefix,
|
|
15
15
|
restoreClock,
|
|
16
16
|
unbindSocketTransport
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-OUEYWMNG.js";
|
|
18
18
|
|
|
19
19
|
// ../../adapters/node/dist/cli.js
|
|
20
20
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
@@ -1667,9 +1667,7 @@ data: ${JSON.stringify(data)}
|
|
|
1667
1667
|
async handle(request, path, namespace, body, admin) {
|
|
1668
1668
|
const route = path.slice("/fleet".length), method = request.method;
|
|
1669
1669
|
if (path === "/ui")
|
|
1670
|
-
return new Response(fleetConsole(this.ctx.config.adminPrefix ?? "/__admin"), {
|
|
1671
|
-
headers: { "content-type": "text/html; charset=utf-8" }
|
|
1672
|
-
});
|
|
1670
|
+
return new Response(fleetConsole(this.ctx.config.adminPrefix ?? "/__admin", this.ctx.dashboard?.()), { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
1673
1671
|
if (route === "" && method === "GET")
|
|
1674
1672
|
return Response.json({
|
|
1675
1673
|
...this.capability(),
|
|
@@ -2639,7 +2637,8 @@ data: ${JSON.stringify(data)}
|
|
|
2639
2637
|
clearInterval(this.expiryTimer);
|
|
2640
2638
|
}
|
|
2641
2639
|
};
|
|
2642
|
-
var
|
|
2640
|
+
var escapeAttribute = (value) => value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
2641
|
+
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>`;
|
|
2643
2642
|
|
|
2644
2643
|
// ../../adapters/node/dist/fleet-preflight.js
|
|
2645
2644
|
import { readFile, realpath } from "node:fs/promises";
|
|
@@ -2703,6 +2702,28 @@ var fleet_config_schema_default = {
|
|
|
2703
2702
|
}
|
|
2704
2703
|
}
|
|
2705
2704
|
},
|
|
2705
|
+
dashboard: {
|
|
2706
|
+
description: "Serve the dashboard (every emulator's admin UI and the notifications UI) next to the fleet. Honored by mockingbird-fleet serve.",
|
|
2707
|
+
anyOf: [
|
|
2708
|
+
{
|
|
2709
|
+
type: "boolean"
|
|
2710
|
+
},
|
|
2711
|
+
{
|
|
2712
|
+
type: "object",
|
|
2713
|
+
additionalProperties: false,
|
|
2714
|
+
properties: {
|
|
2715
|
+
port: {
|
|
2716
|
+
type: "integer",
|
|
2717
|
+
minimum: 0,
|
|
2718
|
+
maximum: 65535
|
|
2719
|
+
},
|
|
2720
|
+
host: {
|
|
2721
|
+
type: "string"
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2725
|
+
]
|
|
2726
|
+
},
|
|
2706
2727
|
cors: {
|
|
2707
2728
|
type: "object",
|
|
2708
2729
|
required: ["origins"],
|
|
@@ -2987,6 +3008,7 @@ async function preflightFleet(config, options) {
|
|
|
2987
3008
|
throw new Error("protected archive policy requires a protected repository; configure its protector before startup");
|
|
2988
3009
|
resolveAdminPrefix(config.adminPrefix);
|
|
2989
3010
|
normalizeBootControls(config.adminControls);
|
|
3011
|
+
validateDashboard(config.dashboard);
|
|
2990
3012
|
if (config.idBase !== void 0)
|
|
2991
3013
|
normalizeIdBase(config.idBase, "idBase");
|
|
2992
3014
|
const targets = /* @__PURE__ */ new Map();
|
|
@@ -3062,7 +3084,7 @@ async function preflightFleet(config, options) {
|
|
|
3062
3084
|
break;
|
|
3063
3085
|
}
|
|
3064
3086
|
}
|
|
3065
|
-
targets.set(name, { ...target, packageVersion: packageVersion ?? "3.
|
|
3087
|
+
targets.set(name, { ...target, packageVersion: packageVersion ?? "3.12.1" });
|
|
3066
3088
|
} catch (error) {
|
|
3067
3089
|
throw new Error(`service ${name}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
3068
3090
|
}
|
|
@@ -3147,6 +3169,22 @@ function validateFleetPolicies(options) {
|
|
|
3147
3169
|
if (duration !== void 0 && (!Number.isSafeInteger(duration) || duration < 1))
|
|
3148
3170
|
throw new Error("hook deadlines must be positive integer milliseconds");
|
|
3149
3171
|
}
|
|
3172
|
+
function validateDashboard(value) {
|
|
3173
|
+
if (value === void 0 || typeof value === "boolean")
|
|
3174
|
+
return;
|
|
3175
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
3176
|
+
throw new Error("dashboard: expected true, false or { port, host }");
|
|
3177
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
3178
|
+
if (key === "port") {
|
|
3179
|
+
if (!Number.isInteger(entry) || entry < 0 || entry > 65535)
|
|
3180
|
+
throw new Error("dashboard.port: expected an integer from 0 to 65535");
|
|
3181
|
+
} else if (key === "host") {
|
|
3182
|
+
if (typeof entry !== "string" || !entry)
|
|
3183
|
+
throw new Error("dashboard.host: expected a host");
|
|
3184
|
+
} else
|
|
3185
|
+
throw new Error(`dashboard.${key}: unknown key; expected port or host`);
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3150
3188
|
|
|
3151
3189
|
// ../../adapters/node/dist/serve.js
|
|
3152
3190
|
import { createServer } from "node:http";
|
|
@@ -3602,6 +3640,7 @@ async function startFleet(config, options) {
|
|
|
3602
3640
|
const checkpoints = /* @__PURE__ */ new Map();
|
|
3603
3641
|
let supervisor;
|
|
3604
3642
|
let management;
|
|
3643
|
+
let dashboard;
|
|
3605
3644
|
let manifest;
|
|
3606
3645
|
const privateConnections = () => Object.fromEntries([...children].map(([name, child]) => [
|
|
3607
3646
|
name,
|
|
@@ -3669,6 +3708,7 @@ async function startFleet(config, options) {
|
|
|
3669
3708
|
}
|
|
3670
3709
|
}
|
|
3671
3710
|
const cleanup = await Promise.allSettled([
|
|
3711
|
+
dashboard?.close(),
|
|
3672
3712
|
supervisor?.close(),
|
|
3673
3713
|
removeOwned(options.readyFile, id),
|
|
3674
3714
|
removeOwned(options.connectionsFile, id)
|
|
@@ -4035,6 +4075,7 @@ async function startFleet(config, options) {
|
|
|
4035
4075
|
clock,
|
|
4036
4076
|
transaction,
|
|
4037
4077
|
manifest: () => manifest,
|
|
4078
|
+
dashboard: () => dashboard?.url,
|
|
4038
4079
|
publish,
|
|
4039
4080
|
recovery,
|
|
4040
4081
|
controlling
|
|
@@ -4098,6 +4139,10 @@ async function startFleet(config, options) {
|
|
|
4098
4139
|
}
|
|
4099
4140
|
}
|
|
4100
4141
|
await management.startPolicies();
|
|
4142
|
+
if (options.dashboard) {
|
|
4143
|
+
dashboard = await options.dashboard({ manifest, config });
|
|
4144
|
+
manifest.dashboard = dashboard.url;
|
|
4145
|
+
}
|
|
4101
4146
|
await publish();
|
|
4102
4147
|
if (manifest.state === "ready")
|
|
4103
4148
|
options.onReady?.(manifest);
|
|
@@ -4897,20 +4942,35 @@ var start = async (target, values, config) => {
|
|
|
4897
4942
|
console.log(`${target.name} ${line.replaceAll("/__admin", adminPrefix)}`);
|
|
4898
4943
|
return listening;
|
|
4899
4944
|
};
|
|
4900
|
-
var
|
|
4901
|
-
|
|
4945
|
+
var watchSignals = () => {
|
|
4946
|
+
let received = false;
|
|
4947
|
+
let wake = () => {
|
|
4948
|
+
};
|
|
4949
|
+
const on = () => {
|
|
4950
|
+
received = true;
|
|
4951
|
+
wake();
|
|
4952
|
+
};
|
|
4953
|
+
const dispose = () => {
|
|
4902
4954
|
;
|
|
4903
|
-
process.removeListener("SIGINT",
|
|
4904
|
-
process.removeListener("SIGTERM",
|
|
4905
|
-
const results = await Promise.allSettled(servers.map((s) => s.close()));
|
|
4906
|
-
for (const result of results)
|
|
4907
|
-
if (result.status === "rejected")
|
|
4908
|
-
console.error(result.reason instanceof Error ? result.reason.message : String(result.reason));
|
|
4909
|
-
resolve4(results.some((r) => r.status === "rejected") ? 1 : 0);
|
|
4955
|
+
process.removeListener("SIGINT", on);
|
|
4956
|
+
process.removeListener("SIGTERM", on);
|
|
4910
4957
|
};
|
|
4911
|
-
process.once("SIGINT",
|
|
4912
|
-
process.once("SIGTERM",
|
|
4913
|
-
|
|
4958
|
+
process.once("SIGINT", on);
|
|
4959
|
+
process.once("SIGTERM", on);
|
|
4960
|
+
return {
|
|
4961
|
+
dispose,
|
|
4962
|
+
async untilSignal(servers) {
|
|
4963
|
+
if (!received)
|
|
4964
|
+
await new Promise((resolve4) => wake = resolve4);
|
|
4965
|
+
dispose();
|
|
4966
|
+
const results = await Promise.allSettled(servers.map((s) => s.close()));
|
|
4967
|
+
for (const result of results)
|
|
4968
|
+
if (result.status === "rejected")
|
|
4969
|
+
console.error(result.reason instanceof Error ? result.reason.message : String(result.reason));
|
|
4970
|
+
return results.some((r) => r.status === "rejected") ? 1 : 0;
|
|
4971
|
+
}
|
|
4972
|
+
};
|
|
4973
|
+
};
|
|
4914
4974
|
var serveCommand = (target) => ({
|
|
4915
4975
|
fleetTarget: target,
|
|
4916
4976
|
summary: `Serve the ${target.name} emulator or a configured fleet`,
|
|
@@ -4923,12 +4983,15 @@ var serveCommand = (target) => ({
|
|
|
4923
4983
|
}
|
|
4924
4984
|
const configPath = asString(values.config);
|
|
4925
4985
|
if (configPath !== void 0) {
|
|
4986
|
+
const signals2 = watchSignals();
|
|
4926
4987
|
try {
|
|
4927
4988
|
const config = JSON.parse(await readFile5(configPath, "utf8"));
|
|
4928
4989
|
config.adminPrefix = resolveAdminPrefix(config.adminPrefix ?? asString(values["admin-prefix"]) ?? process.env.MOCKINGBIRD_ADMIN_PREFIX);
|
|
4929
4990
|
const adminKey2 = config.adminKey ?? asString(values["admin-key"]) ?? process.env.MOCKINGBIRD_ADMIN_KEY;
|
|
4930
4991
|
if (adminKey2 !== void 0)
|
|
4931
4992
|
config.adminKey = adminKey2;
|
|
4993
|
+
if (config.dashboard)
|
|
4994
|
+
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`);
|
|
4932
4995
|
const adminControls = await resolveServeControls(values, process.env, config.adminControls);
|
|
4933
4996
|
if (adminControls !== void 0)
|
|
4934
4997
|
config.adminControls = adminControls;
|
|
@@ -4950,8 +5013,9 @@ var serveCommand = (target) => ({
|
|
|
4950
5013
|
console.log(`${name} emulator listening on ${endpoint.url}`);
|
|
4951
5014
|
}
|
|
4952
5015
|
});
|
|
4953
|
-
return untilSignal([fleet]);
|
|
5016
|
+
return signals2.untilSignal([fleet]);
|
|
4954
5017
|
} catch (error) {
|
|
5018
|
+
signals2.dispose();
|
|
4955
5019
|
console.error(error instanceof Error ? error.message : String(error));
|
|
4956
5020
|
return 1;
|
|
4957
5021
|
}
|
|
@@ -4964,6 +5028,7 @@ var serveCommand = (target) => ({
|
|
|
4964
5028
|
const adminKey = asString(values["admin-key"]) ?? process.env.MOCKINGBIRD_ADMIN_KEY;
|
|
4965
5029
|
const seed = asString(values.seed) ?? process.env.MOCKINGBIRD_SEED;
|
|
4966
5030
|
let listening;
|
|
5031
|
+
const signals = watchSignals();
|
|
4967
5032
|
try {
|
|
4968
5033
|
const adminControls = await resolveServeControls(values);
|
|
4969
5034
|
const idBase = resolveServeIdBase(values);
|
|
@@ -4980,10 +5045,11 @@ var serveCommand = (target) => ({
|
|
|
4980
5045
|
log
|
|
4981
5046
|
});
|
|
4982
5047
|
} catch (error) {
|
|
5048
|
+
signals.dispose();
|
|
4983
5049
|
console.error(error instanceof Error ? error.message : String(error));
|
|
4984
5050
|
return 1;
|
|
4985
5051
|
}
|
|
4986
|
-
return untilSignal([listening]);
|
|
5052
|
+
return signals.untilSignal([listening]);
|
|
4987
5053
|
}
|
|
4988
5054
|
});
|
|
4989
5055
|
|
|
@@ -5383,4 +5449,4 @@ export {
|
|
|
5383
5449
|
createServer2 as createServer,
|
|
5384
5450
|
serveTarget
|
|
5385
5451
|
};
|
|
5386
|
-
//# sourceMappingURL=chunk-
|
|
5452
|
+
//# sourceMappingURL=chunk-PLRHP2R3.js.map
|