@crvouga/mockingbird-service-s3 4.1.0 → 4.2.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/{auth-v2-YGYT7VVQ.js → auth-v2-RZJ4AKKC.js} +3 -2
- package/dist/{auth-v2-YGYT7VVQ.js.map → auth-v2-RZJ4AKKC.js.map} +1 -1
- package/dist/{chunk-OJ6AYWXU.js → chunk-H3K742VW.js} +88 -22
- package/dist/chunk-H3K742VW.js.map +7 -0
- package/dist/{chunk-UQ4H4FZA.js → chunk-H77IK3F3.js} +4 -4
- package/dist/chunk-JX5VOLFN.js +7 -0
- package/dist/chunk-JX5VOLFN.js.map +7 -0
- package/dist/{chunk-Y75YGK7R.js → chunk-XPRD2L4L.js} +2 -2
- package/dist/chunk-YHC3JBLQ.js +9835 -0
- package/dist/chunk-YHC3JBLQ.js.map +7 -0
- package/dist/cli.js +5 -4
- package/dist/cli.js.map +1 -1
- package/dist/digest-WAT7AX3C.js +12 -0
- package/dist/index.d.ts +3 -1368
- package/dist/index.js +4 -3
- package/dist/server.d.ts +61 -1408
- package/dist/server.js +5 -4
- package/dist/types-HwqI9Aq6.d.ts +1368 -0
- package/package.json +1 -1
- package/dist/chunk-OJ6AYWXU.js.map +0 -7
- package/dist/chunk-R67TI76J.js +0 -9828
- package/dist/chunk-R67TI76J.js.map +0 -7
- package/dist/digest-7S5ZYCX4.js +0 -11
- /package/dist/{chunk-UQ4H4FZA.js.map → chunk-H77IK3F3.js.map} +0 -0
- /package/dist/{chunk-Y75YGK7R.js.map → chunk-XPRD2L4L.js.map} +0 -0
- /package/dist/{digest-7S5ZYCX4.js.map → digest-WAT7AX3C.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-s3
|
|
2
2
|
|
|
3
|
-
## 4.1
|
|
3
|
+
## 4.2.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
|
+
## 4.2.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
|
+
## 4.1.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-s3/`; 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-s3
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`mockingbird.json` (add one entry per installed emulator; `"port": 0` picks a free port):
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"services": {
|
|
21
|
+
"s3": { "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 |
|
|
@@ -3,7 +3,8 @@ import {
|
|
|
3
3
|
checkKey,
|
|
4
4
|
fail,
|
|
5
5
|
hmacRaw
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-XPRD2L4L.js";
|
|
7
|
+
import "./chunk-JX5VOLFN.js";
|
|
7
8
|
|
|
8
9
|
// src/auth-v2.ts
|
|
9
10
|
var encoder = new TextEncoder();
|
|
@@ -162,4 +163,4 @@ export {
|
|
|
162
163
|
requestAccessKeyV2,
|
|
163
164
|
verifyV2
|
|
164
165
|
};
|
|
165
|
-
//# sourceMappingURL=auth-v2-
|
|
166
|
+
//# sourceMappingURL=auth-v2-RZJ4AKKC.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/auth-v2.ts"],
|
|
4
4
|
"sourcesContent": ["/** AWS Signature Version 2 (header and presigned), as MinIO's `cmd/signature-v2.go` checks it. */\nimport { checkKey, hmacRaw, type Lookup, SIGN_V4, type SignedRequest } from \"./auth.js\"\nimport { fail } from \"./errors.js\"\n\nconst encoder = new TextEncoder()\n\n/** The sub-resources a V2 signature covers, in MinIO's `resourceList` order. */\nconst RESOURCES = [\n \"acl\",\n \"cors\",\n \"delete\",\n \"encryption\",\n \"legal-hold\",\n \"lifecycle\",\n \"location\",\n \"logging\",\n \"notification\",\n \"partNumber\",\n \"policy\",\n \"requestPayment\",\n \"response-cache-control\",\n \"response-content-disposition\",\n \"response-content-encoding\",\n \"response-content-language\",\n \"response-content-type\",\n \"response-expires\",\n \"retention\",\n \"select\",\n \"select-type\",\n \"tagging\",\n \"torrent\",\n \"uploadId\",\n \"uploads\",\n \"versionId\",\n \"versioning\",\n \"versions\",\n \"website\",\n]\n\nconst base64 = (bytes: Uint8Array) => btoa(String.fromCharCode(...bytes))\n\n/** Go's `url.QueryUnescape`: `+` is a space, a bad `%` escape is an error (`undefined`). */\nconst queryUnescape = (value: string) => {\n if (/%(?![0-9A-Fa-f]{2})/.test(value)) return undefined\n try {\n return decodeURIComponent(value.replace(/\\+/g, \" \"))\n } catch {\n // Go keeps invalid UTF-8 bytes; decode them one by one.\n return value\n .replace(/\\+/g, \" \")\n .replace(/%([0-9A-Fa-f]{2})/g, (_, code: string) =>\n String.fromCharCode(Number.parseInt(code, 16)),\n )\n }\n}\n\nconst unescapeQueries = (rawQuery: string) => {\n const out: string[] = []\n for (const query of rawQuery.split(\"&\")) {\n const value = queryUnescape(query)\n if (value === undefined) fail(\"InvalidQueryParams\")\n out.push(value as string)\n }\n return out\n}\n\n/** `x-amz-*` headers, lowercased, sorted, multi-values joined with `,`. */\nconst canonicalAmzHeaders = (headers: Headers) => {\n const lines: [string, string][] = []\n for (const [name, value] of headers) if (name.startsWith(\"x-amz-\")) lines.push([name, value])\n return lines\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([name, value]) => `${name}:${value}`)\n .join(\"\\n\")\n}\n\nconst canonicalResource = (resource: string, query: string) => {\n const values = new Map<string, string>()\n for (const entry of query.split(\"&\")) {\n const index = entry.indexOf(\"=\")\n if (index < 0) values.set(entry, \"\")\n else values.set(entry.slice(0, index), entry.slice(index + 1))\n }\n const parts: string[] = []\n for (const name of RESOURCES) {\n const value = values.get(name)\n if (value === undefined) continue\n parts.push(value === \"\" ? name : `${name}=${value}`)\n }\n return parts.length ? `${resource}?${parts.join(\"&\")}` : resource\n}\n\nconst stringToSign = (request: SignedRequest, query: string, date: string) => {\n let amz = canonicalAmzHeaders(request.headers)\n if (amz) amz += \"\\n\"\n return (\n [\n request.method,\n request.headers.get(\"content-md5\") ?? \"\",\n request.headers.get(\"content-type\") ?? \"\",\n date,\n amz,\n ].join(\"\\n\") + canonicalResource(request.rawPath, query)\n )\n}\n\nconst sign = async (secret: string, value: string) =>\n base64(await hmacRaw(\"SHA-1\", encoder.encode(secret), value))\n\n/** Go's `base64.StdEncoding.DecodeString`, or undefined. */\nconst decode64 = (value: string) => {\n if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value))\n return undefined\n return atob(value)\n}\nconst sameSignature = (a: string, b: string) => {\n const left = decode64(a)\n const right = decode64(b)\n return left !== undefined && right !== undefined && left === right\n}\n\n/** MinIO's `getReqAccessKeyV2`: the presigned `AWSAccessKeyId`, else `AWS <key>:<signature>`. */\nexport const requestAccessKeyV2 = (request: SignedRequest, lookup: Lookup) => {\n const presigned = request.query.get(\"AWSAccessKeyId\")\n if (presigned) {\n checkKey(lookup, presigned)\n return presigned\n }\n const fields = (request.headers.get(\"authorization\") ?? \"\").split(\" \")\n if (fields.length !== 2) fail(\"MissingFields\")\n const keySign = (fields[1] as string).trim().split(\":\")\n if (keySign.length !== 2) fail(\"MissingFields\")\n checkKey(lookup, keySign[0] as string)\n return keySign[0] as string\n}\n\n/** MinIO's `doesSignV2Match`. */\nconst verifyHeaderV2 = async (request: SignedRequest, lookup: Lookup) => {\n const header = request.headers.get(\"authorization\") ?? \"\"\n if (!header) fail(\"AuthHeaderEmpty\")\n if (!header.startsWith(\"AWS\") || header.startsWith(SIGN_V4)) fail(\"SignatureVersionNotSupported\")\n const accessKey = requestAccessKeyV2(request, lookup)\n const secret = checkKey(lookup, accessKey)\n const queries = unescapeQueries(request.rawQuery)\n const prefix = `AWS ${accessKey}:`\n if (!header.startsWith(prefix)) fail(\"SignatureDoesNotMatch\")\n const expected = await sign(\n secret,\n stringToSign(request, queries.join(\"&\"), request.headers.get(\"date\") ?? \"\"),\n )\n if (!sameSignature(header.slice(prefix.length), expected)) fail(\"SignatureDoesNotMatch\")\n return accessKey\n}\n\n/** MinIO's `doesPresignV2SignatureMatch`. */\nconst verifyPresignV2 = async (request: SignedRequest, lookup: Lookup, now: number) => {\n const filtered: string[] = []\n let signature = \"\"\n let expires = \"\"\n let accessKey = \"\"\n for (const query of unescapeQueries(request.rawQuery)) {\n const index = query.indexOf(\"=\")\n if (index < 0) fail(\"InvalidQueryParams\")\n const name = query.slice(0, index)\n const value = query.slice(index + 1)\n if (name === \"AWSAccessKeyId\") accessKey = value\n else if (name === \"Signature\") signature = value\n else if (name === \"Expires\") expires = value\n else filtered.push(query)\n }\n if (!accessKey || !signature || !expires) fail(\"InvalidQueryParams\")\n const secret = checkKey(lookup, accessKey)\n if (!/^[+-]?\\d+$/.test(expires)) fail(\"MalformedExpires\")\n if (Number(expires) < Math.floor(now / 1000)) fail(\"ExpiredPresignRequest\")\n const expected = await sign(secret, stringToSign(request, filtered.join(\"&\"), expires))\n if (!sameSignature(signature, expected)) fail(\"SignatureDoesNotMatch\")\n return accessKey\n}\n\n/** MinIO's `isReqAuthenticatedV2` then `getReqAccessKeyV2`: the verified access key. */\nexport const verifyV2 = async (\n request: SignedRequest,\n lookup: Lookup,\n now: number,\n presigned: boolean,\n): Promise<string> => {\n if (presigned) await verifyPresignV2(request, lookup, now)\n else await verifyHeaderV2(request, lookup)\n return requestAccessKeyV2(request, lookup)\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;AAIA,IAAM,UAAU,IAAI,YAAY;AAGhC,IAAM,YAAY;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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AG;AAC/B,QAAI,QAAQ,EAAG,MAAK,oBAAoB;AACxC,UAAM,OAAO,MAAM,MAAM,GAAG,KAAK;AACjC,UAAM,QAAQ,MAAM,MAAM,QAAQ,CAAC;AACnC,QAAI,SAAS,iBAAkB,aAAY;AAAA,aAClC,SAAS,YAAa,aAAY;AAAA,aAClC,SAAS,UAAW,WAAU;AAAA,QAClC,UAAS,KAAK,KAAK;AAAA,EAC1B;AACA,MAAI,CAAC,aAAa,CAAC,aAAa,CAAC,QAAS,MAAK,oBAAoB;AACnE,QAAM,SAAS,SAAS,QAAQ,SAAS;AACzC,MAAI,CAAC,aAAa,KAAK,OAAO,EAAG,MAAK,kBAAkB;AACxD,MAAI,OAAO,OAAO,IAAI,KAAK,MAAM,MAAM,GAAI,EAAG,MAAK,uBAAuB;AAC1E,QAAM,WAAW,MAAM,KAAK,QAAQ,aAAa,SAAS,SAAS,KAAK,GAAG,GAAG,OAAO,CAAC;AACtF,MAAI,CAAC,cAAc,WAAW,QAAQ,EAAG,MAAK,uBAAuB;AACrE,SAAO;AACT;AAGO,IAAM,WAAW,OACtB,SACA,QACA,KACA,cACoB;AACpB,MAAI,UAAW,OAAM,gBAAgB,SAAS,QAAQ,GAAG;AAAA,MACpD,OAAM,eAAe,SAAS,MAAM;AACzC,SAAO,mBAAmB,SAAS,MAAM;AAC3C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
S3_MAX_UPLOAD_BYTES,
|
|
3
3
|
createRuntime
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-H77IK3F3.js";
|
|
5
5
|
import {
|
|
6
6
|
createClock,
|
|
7
7
|
normalizeBootControls,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
parseFaultHeader,
|
|
13
13
|
resolveAdminPrefix,
|
|
14
14
|
restoreClock
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-YHC3JBLQ.js";
|
|
16
16
|
|
|
17
17
|
// ../../adapters/node/dist/cli.js
|
|
18
18
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
@@ -1665,9 +1665,7 @@ data: ${JSON.stringify(data)}
|
|
|
1665
1665
|
async handle(request, path, namespace, body, admin) {
|
|
1666
1666
|
const route = path.slice("/fleet".length), method = request.method;
|
|
1667
1667
|
if (path === "/ui")
|
|
1668
|
-
return new Response(fleetConsole(this.ctx.config.adminPrefix ?? "/__admin"), {
|
|
1669
|
-
headers: { "content-type": "text/html; charset=utf-8" }
|
|
1670
|
-
});
|
|
1668
|
+
return new Response(fleetConsole(this.ctx.config.adminPrefix ?? "/__admin", this.ctx.dashboard?.()), { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
1671
1669
|
if (route === "" && method === "GET")
|
|
1672
1670
|
return Response.json({
|
|
1673
1671
|
...this.capability(),
|
|
@@ -2637,7 +2635,8 @@ data: ${JSON.stringify(data)}
|
|
|
2637
2635
|
clearInterval(this.expiryTimer);
|
|
2638
2636
|
}
|
|
2639
2637
|
};
|
|
2640
|
-
var
|
|
2638
|
+
var escapeAttribute = (value) => value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
2639
|
+
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>`;
|
|
2641
2640
|
|
|
2642
2641
|
// ../../adapters/node/dist/fleet-preflight.js
|
|
2643
2642
|
import { readFile, realpath } from "node:fs/promises";
|
|
@@ -2701,6 +2700,28 @@ var fleet_config_schema_default = {
|
|
|
2701
2700
|
}
|
|
2702
2701
|
}
|
|
2703
2702
|
},
|
|
2703
|
+
dashboard: {
|
|
2704
|
+
description: "Serve the dashboard (every emulator's admin UI and the notifications UI) next to the fleet. Honored by mockingbird-fleet serve.",
|
|
2705
|
+
anyOf: [
|
|
2706
|
+
{
|
|
2707
|
+
type: "boolean"
|
|
2708
|
+
},
|
|
2709
|
+
{
|
|
2710
|
+
type: "object",
|
|
2711
|
+
additionalProperties: false,
|
|
2712
|
+
properties: {
|
|
2713
|
+
port: {
|
|
2714
|
+
type: "integer",
|
|
2715
|
+
minimum: 0,
|
|
2716
|
+
maximum: 65535
|
|
2717
|
+
},
|
|
2718
|
+
host: {
|
|
2719
|
+
type: "string"
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
]
|
|
2724
|
+
},
|
|
2704
2725
|
cors: {
|
|
2705
2726
|
type: "object",
|
|
2706
2727
|
required: ["origins"],
|
|
@@ -2985,6 +3006,7 @@ async function preflightFleet(config, options) {
|
|
|
2985
3006
|
throw new Error("protected archive policy requires a protected repository; configure its protector before startup");
|
|
2986
3007
|
resolveAdminPrefix(config.adminPrefix);
|
|
2987
3008
|
normalizeBootControls(config.adminControls);
|
|
3009
|
+
validateDashboard(config.dashboard);
|
|
2988
3010
|
if (config.idBase !== void 0)
|
|
2989
3011
|
normalizeIdBase(config.idBase, "idBase");
|
|
2990
3012
|
const targets = /* @__PURE__ */ new Map();
|
|
@@ -3060,7 +3082,7 @@ async function preflightFleet(config, options) {
|
|
|
3060
3082
|
break;
|
|
3061
3083
|
}
|
|
3062
3084
|
}
|
|
3063
|
-
targets.set(name, { ...target, packageVersion: packageVersion ?? "4.1
|
|
3085
|
+
targets.set(name, { ...target, packageVersion: packageVersion ?? "4.2.1" });
|
|
3064
3086
|
} catch (error) {
|
|
3065
3087
|
throw new Error(`service ${name}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
3066
3088
|
}
|
|
@@ -3145,6 +3167,22 @@ function validateFleetPolicies(options) {
|
|
|
3145
3167
|
if (duration !== void 0 && (!Number.isSafeInteger(duration) || duration < 1))
|
|
3146
3168
|
throw new Error("hook deadlines must be positive integer milliseconds");
|
|
3147
3169
|
}
|
|
3170
|
+
function validateDashboard(value) {
|
|
3171
|
+
if (value === void 0 || typeof value === "boolean")
|
|
3172
|
+
return;
|
|
3173
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
3174
|
+
throw new Error("dashboard: expected true, false or { port, host }");
|
|
3175
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
3176
|
+
if (key === "port") {
|
|
3177
|
+
if (!Number.isInteger(entry) || entry < 0 || entry > 65535)
|
|
3178
|
+
throw new Error("dashboard.port: expected an integer from 0 to 65535");
|
|
3179
|
+
} else if (key === "host") {
|
|
3180
|
+
if (typeof entry !== "string" || !entry)
|
|
3181
|
+
throw new Error("dashboard.host: expected a host");
|
|
3182
|
+
} else
|
|
3183
|
+
throw new Error(`dashboard.${key}: unknown key; expected port or host`);
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3148
3186
|
|
|
3149
3187
|
// ../../adapters/node/dist/serve.js
|
|
3150
3188
|
import { createServer } from "node:http";
|
|
@@ -3600,6 +3638,7 @@ async function startFleet(config, options) {
|
|
|
3600
3638
|
const checkpoints = /* @__PURE__ */ new Map();
|
|
3601
3639
|
let supervisor;
|
|
3602
3640
|
let management;
|
|
3641
|
+
let dashboard;
|
|
3603
3642
|
let manifest;
|
|
3604
3643
|
const privateConnections = () => Object.fromEntries([...children].map(([name, child]) => [
|
|
3605
3644
|
name,
|
|
@@ -3667,6 +3706,7 @@ async function startFleet(config, options) {
|
|
|
3667
3706
|
}
|
|
3668
3707
|
}
|
|
3669
3708
|
const cleanup = await Promise.allSettled([
|
|
3709
|
+
dashboard?.close(),
|
|
3670
3710
|
supervisor?.close(),
|
|
3671
3711
|
removeOwned(options.readyFile, id),
|
|
3672
3712
|
removeOwned(options.connectionsFile, id)
|
|
@@ -4033,6 +4073,7 @@ async function startFleet(config, options) {
|
|
|
4033
4073
|
clock,
|
|
4034
4074
|
transaction,
|
|
4035
4075
|
manifest: () => manifest,
|
|
4076
|
+
dashboard: () => dashboard?.url,
|
|
4036
4077
|
publish,
|
|
4037
4078
|
recovery,
|
|
4038
4079
|
controlling
|
|
@@ -4096,6 +4137,10 @@ async function startFleet(config, options) {
|
|
|
4096
4137
|
}
|
|
4097
4138
|
}
|
|
4098
4139
|
await management.startPolicies();
|
|
4140
|
+
if (options.dashboard) {
|
|
4141
|
+
dashboard = await options.dashboard({ manifest, config });
|
|
4142
|
+
manifest.dashboard = dashboard.url;
|
|
4143
|
+
}
|
|
4099
4144
|
await publish();
|
|
4100
4145
|
if (manifest.state === "ready")
|
|
4101
4146
|
options.onReady?.(manifest);
|
|
@@ -4895,20 +4940,35 @@ var start = async (target, values, config) => {
|
|
|
4895
4940
|
console.log(`${target.name} ${line.replaceAll("/__admin", adminPrefix)}`);
|
|
4896
4941
|
return listening;
|
|
4897
4942
|
};
|
|
4898
|
-
var
|
|
4899
|
-
|
|
4943
|
+
var watchSignals = () => {
|
|
4944
|
+
let received = false;
|
|
4945
|
+
let wake = () => {
|
|
4946
|
+
};
|
|
4947
|
+
const on = () => {
|
|
4948
|
+
received = true;
|
|
4949
|
+
wake();
|
|
4950
|
+
};
|
|
4951
|
+
const dispose = () => {
|
|
4900
4952
|
;
|
|
4901
|
-
process.removeListener("SIGINT",
|
|
4902
|
-
process.removeListener("SIGTERM",
|
|
4903
|
-
const results = await Promise.allSettled(servers.map((s) => s.close()));
|
|
4904
|
-
for (const result of results)
|
|
4905
|
-
if (result.status === "rejected")
|
|
4906
|
-
console.error(result.reason instanceof Error ? result.reason.message : String(result.reason));
|
|
4907
|
-
resolve4(results.some((r) => r.status === "rejected") ? 1 : 0);
|
|
4953
|
+
process.removeListener("SIGINT", on);
|
|
4954
|
+
process.removeListener("SIGTERM", on);
|
|
4908
4955
|
};
|
|
4909
|
-
process.once("SIGINT",
|
|
4910
|
-
process.once("SIGTERM",
|
|
4911
|
-
|
|
4956
|
+
process.once("SIGINT", on);
|
|
4957
|
+
process.once("SIGTERM", on);
|
|
4958
|
+
return {
|
|
4959
|
+
dispose,
|
|
4960
|
+
async untilSignal(servers) {
|
|
4961
|
+
if (!received)
|
|
4962
|
+
await new Promise((resolve4) => wake = resolve4);
|
|
4963
|
+
dispose();
|
|
4964
|
+
const results = await Promise.allSettled(servers.map((s) => s.close()));
|
|
4965
|
+
for (const result of results)
|
|
4966
|
+
if (result.status === "rejected")
|
|
4967
|
+
console.error(result.reason instanceof Error ? result.reason.message : String(result.reason));
|
|
4968
|
+
return results.some((r) => r.status === "rejected") ? 1 : 0;
|
|
4969
|
+
}
|
|
4970
|
+
};
|
|
4971
|
+
};
|
|
4912
4972
|
var serveCommand = (target) => ({
|
|
4913
4973
|
fleetTarget: target,
|
|
4914
4974
|
summary: `Serve the ${target.name} emulator or a configured fleet`,
|
|
@@ -4921,12 +4981,15 @@ var serveCommand = (target) => ({
|
|
|
4921
4981
|
}
|
|
4922
4982
|
const configPath = asString(values.config);
|
|
4923
4983
|
if (configPath !== void 0) {
|
|
4984
|
+
const signals2 = watchSignals();
|
|
4924
4985
|
try {
|
|
4925
4986
|
const config = JSON.parse(await readFile5(configPath, "utf8"));
|
|
4926
4987
|
config.adminPrefix = resolveAdminPrefix(config.adminPrefix ?? asString(values["admin-prefix"]) ?? process.env.MOCKINGBIRD_ADMIN_PREFIX);
|
|
4927
4988
|
const adminKey2 = config.adminKey ?? asString(values["admin-key"]) ?? process.env.MOCKINGBIRD_ADMIN_KEY;
|
|
4928
4989
|
if (adminKey2 !== void 0)
|
|
4929
4990
|
config.adminKey = adminKey2;
|
|
4991
|
+
if (config.dashboard)
|
|
4992
|
+
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`);
|
|
4930
4993
|
const adminControls = await resolveServeControls(values, process.env, config.adminControls);
|
|
4931
4994
|
if (adminControls !== void 0)
|
|
4932
4995
|
config.adminControls = adminControls;
|
|
@@ -4948,8 +5011,9 @@ var serveCommand = (target) => ({
|
|
|
4948
5011
|
console.log(`${name} emulator listening on ${endpoint.url}`);
|
|
4949
5012
|
}
|
|
4950
5013
|
});
|
|
4951
|
-
return untilSignal([fleet]);
|
|
5014
|
+
return signals2.untilSignal([fleet]);
|
|
4952
5015
|
} catch (error) {
|
|
5016
|
+
signals2.dispose();
|
|
4953
5017
|
console.error(error instanceof Error ? error.message : String(error));
|
|
4954
5018
|
return 1;
|
|
4955
5019
|
}
|
|
@@ -4962,6 +5026,7 @@ var serveCommand = (target) => ({
|
|
|
4962
5026
|
const adminKey = asString(values["admin-key"]) ?? process.env.MOCKINGBIRD_ADMIN_KEY;
|
|
4963
5027
|
const seed = asString(values.seed) ?? process.env.MOCKINGBIRD_SEED;
|
|
4964
5028
|
let listening;
|
|
5029
|
+
const signals = watchSignals();
|
|
4965
5030
|
try {
|
|
4966
5031
|
const adminControls = await resolveServeControls(values);
|
|
4967
5032
|
const idBase = resolveServeIdBase(values);
|
|
@@ -4978,10 +5043,11 @@ var serveCommand = (target) => ({
|
|
|
4978
5043
|
log
|
|
4979
5044
|
});
|
|
4980
5045
|
} catch (error) {
|
|
5046
|
+
signals.dispose();
|
|
4981
5047
|
console.error(error instanceof Error ? error.message : String(error));
|
|
4982
5048
|
return 1;
|
|
4983
5049
|
}
|
|
4984
|
-
return untilSignal([listening]);
|
|
5050
|
+
return signals.untilSignal([listening]);
|
|
4985
5051
|
}
|
|
4986
5052
|
});
|
|
4987
5053
|
|
|
@@ -5047,4 +5113,4 @@ export {
|
|
|
5047
5113
|
createServer2 as createServer,
|
|
5048
5114
|
serveTarget
|
|
5049
5115
|
};
|
|
5050
|
-
//# sourceMappingURL=chunk-
|
|
5116
|
+
//# sourceMappingURL=chunk-H3K742VW.js.map
|