@crvouga/mockingbird-service-s3 4.0.8 → 4.2.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.
@@ -31,7 +31,7 @@ import {
31
31
  multipartEtag,
32
32
  sigV4AccessKeyId,
33
33
  signers
34
- } from "./chunk-R67TI76J.js";
34
+ } from "./chunk-FX4JECRB.js";
35
35
 
36
36
  // src/generated/openapi.ts
37
37
  var document = JSON.parse(`{"openapi":"3.1.0","info":{"title":"Amazon S3 (Mockingbird subset)","version":"2006-03-01","description":"Path-style S3 REST contract used by AWS SDK v3."},"servers":[{"url":"https://s3.us-east-1.amazonaws.com"}],"paths":{"/{bucket}":{"parameters":[{"name":"bucket","in":"path","required":true,"schema":{"type":"string"}}],"put":{"operationId":"CreateBucket","x-mockingbird":{"supported":true,"parity":{"safe":false}},"responses":{"200":{"description":"Created"},"400":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"}}},"head":{"operationId":"HeadBucket","responses":{"200":{"description":"Exists"},"404":{"description":"Missing"}}},"get":{"operationId":"ListObjectsV2","responses":{"200":{"description":"XML listing","content":{"application/xml":{"schema":{"type":"string"}}}},"404":{"$ref":"#/components/responses/Error"}}},"post":{"operationId":"BucketPost","x-mockingbird":{"supported":true,"parity":{"safe":false}},"responses":{"200":{"description":"DeleteObjects result","content":{"application/xml":{"schema":{"type":"string"}}}},"404":{"$ref":"#/components/responses/Error"}}}},"/{bucket}/{key}":{"parameters":[{"name":"bucket","in":"path","required":true,"schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}}],"put":{"operationId":"PutObject","x-mockingbird":{"supported":true,"parity":{"safe":false}},"requestBody":{"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"responses":{"200":{"description":"Stored"},"400":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"}}},"get":{"operationId":"GetObject","responses":{"200":{"description":"Object bytes","content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"206":{"description":"Range bytes"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"416":{"$ref":"#/components/responses/Error"}}},"head":{"operationId":"HeadObject","responses":{"200":{"description":"Object metadata"},"404":{"description":"Missing"}}},"delete":{"operationId":"DeleteObject","x-mockingbird":{"supported":true,"parity":{"safe":false}},"responses":{"204":{"description":"Deleted"},"403":{"$ref":"#/components/responses/Error"}}},"post":{"operationId":"MultipartPost","x-mockingbird":{"supported":true,"parity":{"enabled":false,"reason":"Multipart XML protocol."}},"responses":{"200":{"description":"Multipart response","content":{"application/xml":{"schema":{"type":"string"}}}},"404":{"$ref":"#/components/responses/Error"}}}}},"components":{"responses":{"Error":{"description":"Canonical S3 XML error.","content":{"application/xml":{"schema":{"type":"string"}}}}}}}`);
@@ -10977,7 +10977,7 @@ var S3API = class {
10977
10977
  if (!this.core.bucket(input.bucket))
10978
10978
  this.core.saveBucket(input.bucket, { createdAt: this.core.now() });
10979
10979
  const bytes = typeof input.body === "string" ? encoder5.encode(input.body) : input.body;
10980
- const { md5Hex: md5Hex2 } = await import("./digest-7S5ZYCX4.js");
10980
+ const { md5Hex: md5Hex2 } = await import("./digest-VNY5VGIS.js");
10981
10981
  const tagging = typeof input.tags === "string" ? input.tags : input.tags ? new URLSearchParams(Object.entries(input.tags)).toString() : void 0;
10982
10982
  return this.core.write(
10983
10983
  {
@@ -11337,4 +11337,4 @@ export {
11337
11337
  createRuntime2 as createRuntime,
11338
11338
  accessKeyCredential
11339
11339
  };
11340
- //# sourceMappingURL=chunk-UQ4H4FZA.js.map
11340
+ //# sourceMappingURL=chunk-G5M33PF4.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  S3_MAX_UPLOAD_BYTES,
3
3
  createRuntime
4
- } from "./chunk-UQ4H4FZA.js";
4
+ } from "./chunk-G5M33PF4.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-R67TI76J.js";
15
+ } from "./chunk-FX4JECRB.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 fleetConsole = (prefix) => `<!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><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>`;
2638
+ var escapeAttribute = (value) => value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
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.0.8" });
3085
+ targets.set(name, { ...target, packageVersion: packageVersion ?? "4.2.0" });
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);
@@ -4927,6 +4972,8 @@ var serveCommand = (target) => ({
4927
4972
  const adminKey2 = config.adminKey ?? asString(values["admin-key"]) ?? process.env.MOCKINGBIRD_ADMIN_KEY;
4928
4973
  if (adminKey2 !== void 0)
4929
4974
  config.adminKey = adminKey2;
4975
+ if (config.dashboard)
4976
+ 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
4977
  const adminControls = await resolveServeControls(values, process.env, config.adminControls);
4931
4978
  if (adminControls !== void 0)
4932
4979
  config.adminControls = adminControls;
@@ -5047,4 +5094,4 @@ export {
5047
5094
  createServer2 as createServer,
5048
5095
  serveTarget
5049
5096
  };
5050
- //# sourceMappingURL=chunk-3Q2B6J75.js.map
5097
+ //# sourceMappingURL=chunk-UEXWQB6F.js.map