@crvouga/mockingbird-service-wholescripts 1.8.0 → 2.0.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 +23 -1
- package/DISCOVERY.md +55 -0
- package/README.md +1 -1
- package/SUPPORT.md +15 -0
- package/dist/{chunk-7AFJALQR.js → chunk-6JAPA3JS.js} +622 -235
- package/dist/chunk-6JAPA3JS.js.map +7 -0
- package/dist/{chunk-F2UKWPP7.js → chunk-GUAUOMFF.js} +44 -24
- package/dist/chunk-GUAUOMFF.js.map +7 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/server.d.ts +2 -0
- package/dist/server.js +2 -2
- package/openapi.yaml +487 -0
- package/package.json +28 -3
- package/dist/chunk-7AFJALQR.js.map +0 -7
- package/dist/chunk-F2UKWPP7.js.map +0 -7
|
@@ -110,13 +110,31 @@ var Collection = class {
|
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
// ../core/dist/control.js
|
|
113
|
-
var HEALTH_PATH = "/health";
|
|
114
113
|
var ADMIN_PREFIX = "/__admin";
|
|
114
|
+
var resolveAdminPrefix = (prefix = ADMIN_PREFIX) => {
|
|
115
|
+
if (!/^\/[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*$/.test(prefix)) {
|
|
116
|
+
throw new Error("adminPrefix must be an absolute non-root path of literal segments, without a trailing slash");
|
|
117
|
+
}
|
|
118
|
+
return prefix;
|
|
119
|
+
};
|
|
120
|
+
var isAdminPath = (path, prefix) => path === prefix || path.startsWith(`${prefix}/`);
|
|
121
|
+
var matchNamespacePath = (path, prefix) => /^\/ns\/([^/]+)(\/.*)?$/.exec(isAdminPath(path, prefix) ? path.slice(prefix.length) : "");
|
|
122
|
+
var assertAdminPrefixAvailable = (prefix, paths) => {
|
|
123
|
+
const reserved = prefix.split("/").slice(1);
|
|
124
|
+
for (const path of paths) {
|
|
125
|
+
const segments = path.split("/").slice(1);
|
|
126
|
+
if (segments.length < reserved.length || /^\{[^}]+\}$/.test(segments[0] ?? ""))
|
|
127
|
+
continue;
|
|
128
|
+
if (reserved.every((part, i) => segments[i] === part || /^\{[^}]+\}$/.test(segments[i] ?? ""))) {
|
|
129
|
+
throw new Error(`vendor route ${path} collides with adminPrefix ${prefix}; choose a different adminPrefix`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
115
133
|
var ADMIN_KEY_HEADER = "x-mockingbird-admin-key";
|
|
116
134
|
var NAMESPACE_HEADER = "x-mockingbird-namespace";
|
|
117
135
|
var json = (status, body) => new Response(JSON.stringify(body), {
|
|
118
136
|
status,
|
|
119
|
-
headers: { "content-type": "application/json" }
|
|
137
|
+
headers: { "content-type": "application/json; charset=utf-8" }
|
|
120
138
|
});
|
|
121
139
|
var adminError = (status, message) => json(status, { error: { type: "mockingbird_admin", message } });
|
|
122
140
|
var UNITS = {
|
|
@@ -168,11 +186,25 @@ var readJson = async (request) => {
|
|
|
168
186
|
};
|
|
169
187
|
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
170
188
|
var createControlPlane = (context) => {
|
|
189
|
+
const adminPrefix = resolveAdminPrefix(context.adminPrefix);
|
|
171
190
|
const snapshots = /* @__PURE__ */ new Map();
|
|
172
191
|
let snapshotCounter = 0;
|
|
173
192
|
const headerNamespace = (request) => request.headers.get(NAMESPACE_HEADER) ?? context.defaultNamespace;
|
|
174
193
|
const adminNamespace = (request, url) => url.searchParams.get("namespace") ?? headerNamespace(request);
|
|
194
|
+
const health = () => {
|
|
195
|
+
return json(200, {
|
|
196
|
+
...context.describe(),
|
|
197
|
+
status: "ok",
|
|
198
|
+
service: context.name,
|
|
199
|
+
uptimeMs: context.wallNow() - context.startedAt,
|
|
200
|
+
clock: context.clock.state(),
|
|
201
|
+
namespaces: context.namespaces().length,
|
|
202
|
+
adminPrefix,
|
|
203
|
+
adminUi: `${adminPrefix}/ui`
|
|
204
|
+
});
|
|
205
|
+
};
|
|
175
206
|
const builtin = {
|
|
207
|
+
"GET /health": health,
|
|
176
208
|
"GET /": () => json(200, {
|
|
177
209
|
service: context.name,
|
|
178
210
|
routes: [...Object.keys(builtin), ...Object.keys(context.routes)].sort()
|
|
@@ -339,7 +371,14 @@ var createControlPlane = (context) => {
|
|
|
339
371
|
return json(200, { status: "ok" });
|
|
340
372
|
}
|
|
341
373
|
};
|
|
342
|
-
const
|
|
374
|
+
for (const key of Object.keys(context.routes)) {
|
|
375
|
+
if (Object.hasOwn(builtin, key))
|
|
376
|
+
throw new Error(`admin route ${key} overrides a shared route`);
|
|
377
|
+
const path = key.slice(key.indexOf(" ") + 1);
|
|
378
|
+
if (isAdminPath(path, "/ns") || isAdminPath(path, "/blobs"))
|
|
379
|
+
throw new Error(`admin route ${key} overlaps an internal transport`);
|
|
380
|
+
}
|
|
381
|
+
const routes = [...Object.entries(builtin), ...Object.entries(context.routes)].map(([key, handler]) => {
|
|
343
382
|
const space = key.indexOf(" ");
|
|
344
383
|
return { method: key.slice(0, space), pattern: key.slice(space + 1), handler };
|
|
345
384
|
});
|
|
@@ -347,21 +386,13 @@ var createControlPlane = (context) => {
|
|
|
347
386
|
namespaceOf: headerNamespace,
|
|
348
387
|
async handle(request) {
|
|
349
388
|
const url = new URL(request.url);
|
|
350
|
-
if (url.pathname ===
|
|
351
|
-
return
|
|
352
|
-
status: "ok",
|
|
353
|
-
service: context.name,
|
|
354
|
-
uptimeMs: context.wallNow() - context.startedAt,
|
|
355
|
-
clock: context.clock.state(),
|
|
356
|
-
namespaces: context.namespaces().length,
|
|
357
|
-
adminUi: `${ADMIN_PREFIX}/ui`,
|
|
358
|
-
...context.describe()
|
|
359
|
-
});
|
|
389
|
+
if (url.pathname === `${adminPrefix}/health` && request.method === "GET") {
|
|
390
|
+
return health();
|
|
360
391
|
}
|
|
361
|
-
if (url.pathname
|
|
392
|
+
if (!isAdminPath(url.pathname, adminPrefix)) {
|
|
362
393
|
return void 0;
|
|
363
394
|
}
|
|
364
|
-
const path = url.pathname.slice(
|
|
395
|
+
const path = url.pathname.slice(adminPrefix.length) || "/";
|
|
365
396
|
const shell = request.method === "GET" && (path === "/ui" || path === "/ui/");
|
|
366
397
|
if (!shell && context.adminKey !== void 0 && request.headers.get(ADMIN_KEY_HEADER) !== context.adminKey) {
|
|
367
398
|
return adminError(401, `missing or wrong ${ADMIN_KEY_HEADER}`);
|
|
@@ -369,7 +400,12 @@ var createControlPlane = (context) => {
|
|
|
369
400
|
for (const route of routes) {
|
|
370
401
|
if (route.method !== request.method)
|
|
371
402
|
continue;
|
|
372
|
-
|
|
403
|
+
let params;
|
|
404
|
+
try {
|
|
405
|
+
params = matchRoute(route.pattern, path);
|
|
406
|
+
} catch {
|
|
407
|
+
return adminError(400, "invalid path encoding");
|
|
408
|
+
}
|
|
373
409
|
if (!params)
|
|
374
410
|
continue;
|
|
375
411
|
let body;
|
|
@@ -378,15 +414,18 @@ var createControlPlane = (context) => {
|
|
|
378
414
|
} catch {
|
|
379
415
|
return adminError(400, "request body is not valid JSON");
|
|
380
416
|
}
|
|
417
|
+
const namespace = adminNamespace(request, url);
|
|
418
|
+
if (!/^[A-Za-z0-9_.-]{1,64}$/.test(namespace))
|
|
419
|
+
return adminError(400, "invalid namespace");
|
|
381
420
|
return route.handler({
|
|
382
421
|
request,
|
|
383
422
|
url,
|
|
384
423
|
params,
|
|
385
|
-
namespace
|
|
424
|
+
namespace,
|
|
386
425
|
body
|
|
387
426
|
});
|
|
388
427
|
}
|
|
389
|
-
return adminError(404, `no admin route ${request.method} ${path}; GET ${
|
|
428
|
+
return adminError(404, `no admin route ${request.method} ${path}; GET ${adminPrefix} lists them`);
|
|
390
429
|
}
|
|
391
430
|
};
|
|
392
431
|
};
|
|
@@ -1756,6 +1795,34 @@ dialog:not([open]) {
|
|
|
1756
1795
|
function isRecord2(value) {
|
|
1757
1796
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1758
1797
|
}
|
|
1798
|
+
function highlightJsonText(text) {
|
|
1799
|
+
const escapeToken = (value) => value.replace(/[&<>"']/g, (char) => {
|
|
1800
|
+
switch (char) {
|
|
1801
|
+
case "&":
|
|
1802
|
+
return "&";
|
|
1803
|
+
case "<":
|
|
1804
|
+
return "<";
|
|
1805
|
+
case ">":
|
|
1806
|
+
return ">";
|
|
1807
|
+
case '"':
|
|
1808
|
+
return """;
|
|
1809
|
+
default:
|
|
1810
|
+
return "'";
|
|
1811
|
+
}
|
|
1812
|
+
});
|
|
1813
|
+
const token = /("(?:\\u[\da-fA-F]{4}|\\[^u]|[^\\"])*"\s*:|"(?:\\u[\da-fA-F]{4}|\\[^u]|[^\\"])*"|\b(?:true|false)\b|\bnull\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;
|
|
1814
|
+
let cursor = 0;
|
|
1815
|
+
let html = "";
|
|
1816
|
+
for (const match of text.matchAll(token)) {
|
|
1817
|
+
const index = match.index ?? 0;
|
|
1818
|
+
const value = match[0];
|
|
1819
|
+
html += escapeToken(text.slice(cursor, index));
|
|
1820
|
+
const kind = value.startsWith('"') ? value.trimEnd().endsWith(":") ? "key" : "string" : value === "true" || value === "false" ? "boolean" : value === "null" ? "null" : "number";
|
|
1821
|
+
html += `<span class="json-${kind}">${escapeToken(value)}</span>`;
|
|
1822
|
+
cursor = index + value.length;
|
|
1823
|
+
}
|
|
1824
|
+
return html + escapeToken(text.slice(cursor));
|
|
1825
|
+
}
|
|
1759
1826
|
function mountAdminBrand(doc, host, service, catalog) {
|
|
1760
1827
|
const clip = (value, max) => {
|
|
1761
1828
|
if (typeof value !== "string")
|
|
@@ -2117,14 +2184,16 @@ function bootAdmin(config) {
|
|
|
2117
2184
|
const state = {
|
|
2118
2185
|
namespace: "default",
|
|
2119
2186
|
key: sessionStorage.getItem("mockingbird-admin-key") || "",
|
|
2120
|
-
view: "overview",
|
|
2187
|
+
view: ["overview", "state", "clock", "faults", "journal", "routes"].includes(location.hash.slice(1)) ? location.hash.slice(1) : "overview",
|
|
2121
2188
|
collection: "",
|
|
2122
2189
|
shape: null,
|
|
2123
2190
|
route: null,
|
|
2191
|
+
routes: [],
|
|
2124
2192
|
editing: null
|
|
2125
2193
|
};
|
|
2126
2194
|
const standard = new Set(config.standardRoutes);
|
|
2127
2195
|
const banner = el("banner", HTMLElement);
|
|
2196
|
+
const bannerMessage = el("banner-message", HTMLElement);
|
|
2128
2197
|
const keyInput = el("admin-key", HTMLInputElement);
|
|
2129
2198
|
keyInput.value = state.key;
|
|
2130
2199
|
const params = new URLSearchParams(location.search);
|
|
@@ -2135,18 +2204,21 @@ function bootAdmin(config) {
|
|
|
2135
2204
|
sessionStorage.setItem("mockingbird-admin-key", state.key);
|
|
2136
2205
|
params.delete("key");
|
|
2137
2206
|
const next = params.toString();
|
|
2138
|
-
history.replaceState(null, "", location.pathname + (next ? `?${next}` : ""));
|
|
2207
|
+
history.replaceState(null, "", location.pathname + (next ? `?${next}` : "") + location.hash);
|
|
2139
2208
|
}
|
|
2140
2209
|
const queryNamespace = params.get("namespace");
|
|
2141
2210
|
if (queryNamespace)
|
|
2142
2211
|
state.namespace = queryNamespace;
|
|
2143
2212
|
const showError = (error) => {
|
|
2144
|
-
|
|
2213
|
+
bannerMessage.textContent = error instanceof Error ? error.message : String(error);
|
|
2145
2214
|
banner.classList.add("show");
|
|
2215
|
+
banner.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
2146
2216
|
};
|
|
2147
2217
|
const clearError = () => {
|
|
2148
2218
|
banner.classList.remove("show");
|
|
2219
|
+
bannerMessage.textContent = "";
|
|
2149
2220
|
};
|
|
2221
|
+
el("banner-dismiss", HTMLButtonElement).addEventListener("click", clearError);
|
|
2150
2222
|
const api = async (method, path, body) => {
|
|
2151
2223
|
const headers = { accept: "application/json" };
|
|
2152
2224
|
if (state.key !== "")
|
|
@@ -2190,16 +2262,21 @@ function bootAdmin(config) {
|
|
|
2190
2262
|
namespace: () => state.namespace
|
|
2191
2263
|
};
|
|
2192
2264
|
const isPanelScript = (value) => typeof value === "function";
|
|
2265
|
+
const themeButton = el("theme", HTMLButtonElement);
|
|
2193
2266
|
const setTheme = (theme) => {
|
|
2194
2267
|
if (theme)
|
|
2195
2268
|
document.documentElement.dataset.theme = theme;
|
|
2196
2269
|
else
|
|
2197
2270
|
delete document.documentElement.dataset.theme;
|
|
2271
|
+
const dark = theme ? theme === "dark" : matchMedia("(prefers-color-scheme: dark)").matches;
|
|
2272
|
+
themeButton.innerHTML = dark ? '<svg viewBox="0 0 20 20" fill="none" aria-hidden="true"><circle cx="10" cy="10" r="3.2" stroke="currentColor" stroke-width="1.5"/><path d="M10 2v1.5M10 16.5V18M18 10h-1.5M3.5 10H2M15.7 4.3l-1 1M5.3 14.7l-1 1M15.7 15.7l-1-1M5.3 5.3l-1-1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>' : '<svg viewBox="0 0 20 20" fill="none" aria-hidden="true"><path d="M16.8 12.2A7 7 0 0 1 7.8 3.2a7 7 0 1 0 9 9Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>';
|
|
2273
|
+
const label = dark ? "Use light theme" : "Use dark theme";
|
|
2274
|
+
themeButton.setAttribute("aria-label", label);
|
|
2275
|
+
themeButton.title = label;
|
|
2198
2276
|
};
|
|
2199
2277
|
const storedTheme = localStorage.getItem("mockingbird-admin-theme");
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
el("theme", HTMLButtonElement).addEventListener("click", () => {
|
|
2278
|
+
setTheme(storedTheme === "dark" || storedTheme === "light" ? storedTheme : null);
|
|
2279
|
+
themeButton.addEventListener("click", () => {
|
|
2203
2280
|
const current = document.documentElement.dataset.theme;
|
|
2204
2281
|
const dark = current ? current === "dark" : matchMedia("(prefers-color-scheme: dark)").matches;
|
|
2205
2282
|
const next = dark ? "light" : "dark";
|
|
@@ -2218,6 +2295,7 @@ function bootAdmin(config) {
|
|
|
2218
2295
|
continue;
|
|
2219
2296
|
section.hidden = section.id !== `view-${view}`;
|
|
2220
2297
|
}
|
|
2298
|
+
history.replaceState(null, "", `${location.pathname}${location.search}#${encodeURIComponent(view)}`);
|
|
2221
2299
|
};
|
|
2222
2300
|
el("nav", HTMLElement).addEventListener("click", (event) => {
|
|
2223
2301
|
const target = event.target;
|
|
@@ -2232,7 +2310,7 @@ function bootAdmin(config) {
|
|
|
2232
2310
|
show(view);
|
|
2233
2311
|
refresh().catch(showError);
|
|
2234
2312
|
});
|
|
2235
|
-
const cards = (items) => `<div class="grid">${items.map((item) => `<article class="card"><div class="k">${item.k}</div><div class="v">${item.v}</div></article>`).join("")}</div>`;
|
|
2313
|
+
const cards = (items) => `<div class="grid">${items.map((item) => `<article class="card stat-card"><div class="k">${item.k}</div><div class="v">${item.v}</div></article>`).join("")}</div>`;
|
|
2236
2314
|
const table = (columns, rows) => {
|
|
2237
2315
|
if (rows.length === 0)
|
|
2238
2316
|
return '<p class="empty">Nothing here yet.</p>';
|
|
@@ -2242,16 +2320,22 @@ function bootAdmin(config) {
|
|
|
2242
2320
|
const attrs = "attrs" in row && typeof row.attrs === "string" ? row.attrs : "";
|
|
2243
2321
|
return `<tr${attrs}>${cells}</tr>`;
|
|
2244
2322
|
}).join("");
|
|
2245
|
-
return `<table><thead>${head}</thead><tbody>${body}</tbody></table>`;
|
|
2323
|
+
return `<div class="table-shell"><table><thead>${head}</thead><tbody>${body}</tbody></table></div>`;
|
|
2246
2324
|
};
|
|
2247
2325
|
const preview = (value) => {
|
|
2248
2326
|
const text = JSON.stringify(value) ?? "null";
|
|
2249
|
-
|
|
2327
|
+
const clipped = text.length > 180 ? `${text.slice(0, 180)}\u2026` : text;
|
|
2328
|
+
return `<code class="json-inline">${highlightJsonText(clipped)}</code>`;
|
|
2250
2329
|
};
|
|
2251
2330
|
const when = (epoch) => {
|
|
2252
2331
|
const date = new Date(epoch);
|
|
2253
2332
|
return Number.isNaN(date.getTime()) ? String(epoch) : date.toISOString();
|
|
2254
2333
|
};
|
|
2334
|
+
const journalWhen = (value) => {
|
|
2335
|
+
const numeric = value.trim() === "" ? Number.NaN : Number(value);
|
|
2336
|
+
const epoch = Number.isFinite(numeric) ? numeric : Date.parse(value);
|
|
2337
|
+
return Number.isFinite(epoch) ? when(epoch) : value;
|
|
2338
|
+
};
|
|
2255
2339
|
const clockCard = (epoch) => {
|
|
2256
2340
|
const date = new Date(epoch);
|
|
2257
2341
|
if (Number.isNaN(date.getTime()))
|
|
@@ -2371,7 +2455,7 @@ function bootAdmin(config) {
|
|
|
2371
2455
|
};
|
|
2372
2456
|
const renderOverview = async () => {
|
|
2373
2457
|
const [health, shape, clock, journal] = await Promise.all([
|
|
2374
|
-
originGet(
|
|
2458
|
+
originGet(`${config.adminPrefix}/health`),
|
|
2375
2459
|
api("GET", "/state"),
|
|
2376
2460
|
api("GET", "/clock"),
|
|
2377
2461
|
api("GET", "/requests?limit=8")
|
|
@@ -2388,7 +2472,7 @@ function bootAdmin(config) {
|
|
|
2388
2472
|
},
|
|
2389
2473
|
{
|
|
2390
2474
|
k: "Status",
|
|
2391
|
-
v: esc(typeof health.status === "string" && health.status !== "" ? health.status : "ok")
|
|
2475
|
+
v: `<span class="badge ok">${esc(typeof health.status === "string" && health.status !== "" ? health.status : "ok")}</span>`
|
|
2392
2476
|
},
|
|
2393
2477
|
{ k: "Namespace", v: esc(state.namespace) },
|
|
2394
2478
|
{ k: "Collections", v: String(decoded.collections.length) },
|
|
@@ -2475,26 +2559,46 @@ function bootAdmin(config) {
|
|
|
2475
2559
|
const renderJournal = async () => {
|
|
2476
2560
|
const journal = await api("GET", "/requests?limit=100");
|
|
2477
2561
|
el("journal", HTMLElement).innerHTML = table([
|
|
2478
|
-
{ label: "When", cell: (row) => esc(row.at) },
|
|
2479
|
-
{
|
|
2562
|
+
{ label: "When", cell: (row) => esc(journalWhen(row.at)) },
|
|
2563
|
+
{
|
|
2564
|
+
label: "Method",
|
|
2565
|
+
cell: (row) => `<span class="method">${esc(row.method)}</span>`
|
|
2566
|
+
},
|
|
2480
2567
|
{ label: "Path", cell: (row) => esc(row.path) },
|
|
2481
|
-
{
|
|
2568
|
+
{
|
|
2569
|
+
label: "Status",
|
|
2570
|
+
cell: (row) => `<span class="badge ${row.status.startsWith("2") ? "ok" : row.status.startsWith("4") || row.status.startsWith("5") ? "warn" : ""}">${esc(row.status)}</span>`
|
|
2571
|
+
},
|
|
2482
2572
|
{ label: "ms", cell: (row) => esc(row.durationMs) }
|
|
2483
2573
|
], decodeJournal(journal));
|
|
2484
2574
|
};
|
|
2485
|
-
const
|
|
2486
|
-
const
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2575
|
+
const paintRoutes = () => {
|
|
2576
|
+
const query = el("route-search", HTMLInputElement).value.trim().toLocaleLowerCase();
|
|
2577
|
+
const routes = state.routes.filter((route) => route.toLocaleLowerCase().includes(query));
|
|
2578
|
+
el("route-count", HTMLElement).textContent = `${routes.length} of ${state.routes.length}`;
|
|
2579
|
+
if (state.routes.length === 0) {
|
|
2580
|
+
el("route-list", HTMLElement).innerHTML = '<p class="empty">No admin routes are available.</p>';
|
|
2581
|
+
return;
|
|
2582
|
+
}
|
|
2583
|
+
if (routes.length === 0) {
|
|
2584
|
+
el("route-list", HTMLElement).innerHTML = '<p class="empty">No routes match this filter.</p>';
|
|
2585
|
+
return;
|
|
2586
|
+
}
|
|
2490
2587
|
el("route-list", HTMLElement).innerHTML = routes.map((route) => {
|
|
2491
2588
|
const extra = standard.has(route) ? "" : " <span class='badge'>extension</span>";
|
|
2492
2589
|
const parts = route.split(" ");
|
|
2493
2590
|
const method = parts[0] ?? "";
|
|
2494
2591
|
const path = parts.slice(1).join(" ");
|
|
2495
|
-
return `<div class="route"><span class="method">${esc(method)}</span><span>${esc(path)}${extra}</span><button class="btn" type="button" data-route="${esc(route)}">Use</button></div>`;
|
|
2592
|
+
return `<div class="route"><span class="method">${esc(method)}</span><span>${esc(path)}${extra}</span><button class="btn" type="button" data-route="${esc(route)}" aria-label="Use ${esc(route)}">Use</button></div>`;
|
|
2496
2593
|
}).join("");
|
|
2497
2594
|
};
|
|
2595
|
+
const renderRoutes = async () => {
|
|
2596
|
+
const data = await api("GET", "/");
|
|
2597
|
+
if (!isRecord2(data))
|
|
2598
|
+
throw new Error("Route list was not an object");
|
|
2599
|
+
state.routes = requireList(data.routes, "Routes").map((route) => String(route));
|
|
2600
|
+
paintRoutes();
|
|
2601
|
+
};
|
|
2498
2602
|
const renderers = {
|
|
2499
2603
|
overview: renderOverview,
|
|
2500
2604
|
state: renderState,
|
|
@@ -2503,19 +2607,50 @@ function bootAdmin(config) {
|
|
|
2503
2607
|
journal: renderJournal,
|
|
2504
2608
|
routes: renderRoutes
|
|
2505
2609
|
};
|
|
2610
|
+
let refreshToken = 0;
|
|
2506
2611
|
async function refresh() {
|
|
2612
|
+
const token = ++refreshToken;
|
|
2507
2613
|
clearError();
|
|
2614
|
+
const main = el("views", HTMLElement);
|
|
2615
|
+
const sync = el("sync-status", HTMLElement);
|
|
2616
|
+
main.setAttribute("aria-busy", "true");
|
|
2617
|
+
sync.classList.add("busy");
|
|
2618
|
+
sync.textContent = "Updating";
|
|
2508
2619
|
const render = renderers[state.view];
|
|
2509
|
-
|
|
2510
|
-
|
|
2620
|
+
try {
|
|
2621
|
+
if (render)
|
|
2622
|
+
await render();
|
|
2623
|
+
if (token === refreshToken)
|
|
2624
|
+
sync.textContent = "Up to date";
|
|
2625
|
+
} finally {
|
|
2626
|
+
if (token === refreshToken) {
|
|
2627
|
+
main.removeAttribute("aria-busy");
|
|
2628
|
+
sync.classList.remove("busy");
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2511
2631
|
}
|
|
2512
2632
|
const delay = (ms) => new Promise((resolve) => {
|
|
2513
2633
|
window.setTimeout(resolve, ms);
|
|
2514
2634
|
});
|
|
2515
|
-
const confirmAction = async (button, pending, done, work) => {
|
|
2635
|
+
const confirmAction = async (button, pending, done, work, confirmLabel) => {
|
|
2516
2636
|
if (button.dataset.pending === "1")
|
|
2517
2637
|
return;
|
|
2518
2638
|
const label = button.textContent ?? "";
|
|
2639
|
+
if (confirmLabel !== void 0 && button.dataset.confirming !== "1") {
|
|
2640
|
+
button.dataset.confirming = "1";
|
|
2641
|
+
button.classList.add("confirming");
|
|
2642
|
+
button.textContent = confirmLabel;
|
|
2643
|
+
window.setTimeout(() => {
|
|
2644
|
+
if (button.dataset.confirming !== "1")
|
|
2645
|
+
return;
|
|
2646
|
+
button.textContent = label;
|
|
2647
|
+
button.classList.remove("confirming");
|
|
2648
|
+
delete button.dataset.confirming;
|
|
2649
|
+
}, 3e3);
|
|
2650
|
+
return;
|
|
2651
|
+
}
|
|
2652
|
+
button.classList.remove("confirming");
|
|
2653
|
+
delete button.dataset.confirming;
|
|
2519
2654
|
const width = button.offsetWidth;
|
|
2520
2655
|
button.dataset.pending = "1";
|
|
2521
2656
|
button.classList.add("pressed");
|
|
@@ -2536,6 +2671,65 @@ function bootAdmin(config) {
|
|
|
2536
2671
|
delete button.dataset.pending;
|
|
2537
2672
|
}
|
|
2538
2673
|
};
|
|
2674
|
+
const wireJsonEditor = (textareaId, highlightId, statusId, shellId, allowEmpty) => {
|
|
2675
|
+
const textarea = el(textareaId, HTMLTextAreaElement);
|
|
2676
|
+
const highlight = el(highlightId, HTMLElement);
|
|
2677
|
+
const status = el(statusId, HTMLElement);
|
|
2678
|
+
const shell = el(shellId, HTMLElement);
|
|
2679
|
+
const sync = () => {
|
|
2680
|
+
const text = textarea.value;
|
|
2681
|
+
highlight.innerHTML = `${highlightJsonText(text)}
|
|
2682
|
+
`;
|
|
2683
|
+
let valid = true;
|
|
2684
|
+
let message = "Valid JSON";
|
|
2685
|
+
if (allowEmpty && text.trim() === "")
|
|
2686
|
+
message = "No body";
|
|
2687
|
+
else {
|
|
2688
|
+
try {
|
|
2689
|
+
readJson2(text);
|
|
2690
|
+
} catch {
|
|
2691
|
+
valid = false;
|
|
2692
|
+
message = "Invalid JSON";
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
shell.classList.toggle("invalid", !valid);
|
|
2696
|
+
status.classList.toggle("invalid", !valid);
|
|
2697
|
+
status.textContent = message;
|
|
2698
|
+
textarea.setAttribute("aria-invalid", valid ? "false" : "true");
|
|
2699
|
+
};
|
|
2700
|
+
const syncScroll = () => {
|
|
2701
|
+
const preview2 = highlight.parentElement;
|
|
2702
|
+
if (!(preview2 instanceof HTMLElement))
|
|
2703
|
+
return;
|
|
2704
|
+
preview2.scrollTop = textarea.scrollTop;
|
|
2705
|
+
preview2.scrollLeft = textarea.scrollLeft;
|
|
2706
|
+
};
|
|
2707
|
+
textarea.addEventListener("input", sync);
|
|
2708
|
+
textarea.addEventListener("scroll", syncScroll);
|
|
2709
|
+
sync();
|
|
2710
|
+
return sync;
|
|
2711
|
+
};
|
|
2712
|
+
const syncRouteEditor = wireJsonEditor("route-body", "route-highlight", "route-json-status", "route-editor", true);
|
|
2713
|
+
const syncRecordEditor = wireJsonEditor("editor-value", "editor-highlight", "editor-json-status", "record-editor", false);
|
|
2714
|
+
for (const button of document.querySelectorAll("[data-format]")) {
|
|
2715
|
+
if (!(button instanceof HTMLButtonElement))
|
|
2716
|
+
continue;
|
|
2717
|
+
button.addEventListener("click", () => {
|
|
2718
|
+
const target = button.dataset.format;
|
|
2719
|
+
if (target === void 0)
|
|
2720
|
+
return;
|
|
2721
|
+
const textarea = document.getElementById(target);
|
|
2722
|
+
if (!(textarea instanceof HTMLTextAreaElement) || textarea.value.trim() === "")
|
|
2723
|
+
return;
|
|
2724
|
+
try {
|
|
2725
|
+
textarea.value = JSON.stringify(readJson2(textarea.value), null, 2) ?? "";
|
|
2726
|
+
textarea.dispatchEvent(new Event("input"));
|
|
2727
|
+
textarea.focus();
|
|
2728
|
+
} catch {
|
|
2729
|
+
showError(new Error("Fix the JSON before formatting it"));
|
|
2730
|
+
}
|
|
2731
|
+
});
|
|
2732
|
+
}
|
|
2539
2733
|
document.addEventListener("click", (event) => {
|
|
2540
2734
|
const target = event.target;
|
|
2541
2735
|
if (!(target instanceof Element))
|
|
@@ -2608,6 +2802,7 @@ function bootAdmin(config) {
|
|
|
2608
2802
|
} else {
|
|
2609
2803
|
editorValue.value = "{\n \n}";
|
|
2610
2804
|
}
|
|
2805
|
+
syncRecordEditor();
|
|
2611
2806
|
editor.showModal();
|
|
2612
2807
|
}
|
|
2613
2808
|
el("new-record", HTMLButtonElement).addEventListener("click", () => {
|
|
@@ -2637,10 +2832,10 @@ function bootAdmin(config) {
|
|
|
2637
2832
|
const id = state.editing;
|
|
2638
2833
|
if (!id)
|
|
2639
2834
|
return;
|
|
2640
|
-
api("DELETE", `/state/${encodeURIComponent(state.collection)}/${encodeURIComponent(id)}`).then(() => {
|
|
2835
|
+
confirmAction(editorDelete, "Deleting...", "Deleted", () => api("DELETE", `/state/${encodeURIComponent(state.collection)}/${encodeURIComponent(id)}`).then(() => {
|
|
2641
2836
|
editor.close();
|
|
2642
2837
|
return renderState();
|
|
2643
|
-
}).catch(showError);
|
|
2838
|
+
}), "Confirm delete").catch(showError);
|
|
2644
2839
|
});
|
|
2645
2840
|
for (const button of document.querySelectorAll("[data-advance]")) {
|
|
2646
2841
|
if (!(button instanceof HTMLButtonElement))
|
|
@@ -2686,10 +2881,10 @@ function bootAdmin(config) {
|
|
|
2686
2881
|
}).then(() => renderFaults()).catch(showError);
|
|
2687
2882
|
});
|
|
2688
2883
|
el("fault-clear", HTMLButtonElement).addEventListener("click", () => {
|
|
2689
|
-
confirmAction(el("fault-clear", HTMLButtonElement), "Clearing...", "Cleared", () => api("DELETE", "/faults").then(() => renderFaults())).catch(showError);
|
|
2884
|
+
confirmAction(el("fault-clear", HTMLButtonElement), "Clearing...", "Cleared", () => api("DELETE", "/faults").then(() => renderFaults()), "Confirm clear").catch(showError);
|
|
2690
2885
|
});
|
|
2691
2886
|
el("journal-clear", HTMLButtonElement).addEventListener("click", () => {
|
|
2692
|
-
confirmAction(el("journal-clear", HTMLButtonElement), "Clearing...", "Cleared", () => api("DELETE", "/requests").then(() => renderJournal())).catch(showError);
|
|
2887
|
+
confirmAction(el("journal-clear", HTMLButtonElement), "Clearing...", "Cleared", () => api("DELETE", "/requests").then(() => renderJournal()), "Confirm clear").catch(showError);
|
|
2693
2888
|
});
|
|
2694
2889
|
el("route-list", HTMLElement).addEventListener("click", (event) => {
|
|
2695
2890
|
const target = event.target;
|
|
@@ -2703,9 +2898,15 @@ function bootAdmin(config) {
|
|
|
2703
2898
|
return;
|
|
2704
2899
|
state.route = route;
|
|
2705
2900
|
el("route-title", HTMLElement).textContent = route;
|
|
2901
|
+
el("route-send", HTMLButtonElement).disabled = false;
|
|
2706
2902
|
const method = route.split(" ")[0] ?? "";
|
|
2707
|
-
el("route-body", HTMLTextAreaElement)
|
|
2903
|
+
const routeBody = el("route-body", HTMLTextAreaElement);
|
|
2904
|
+
routeBody.disabled = method === "GET" || method === "DELETE";
|
|
2905
|
+
el("route-editor", HTMLElement).hidden = routeBody.disabled;
|
|
2906
|
+
el("route-json-status", HTMLElement).parentElement?.toggleAttribute("hidden", routeBody.disabled);
|
|
2907
|
+
syncRouteEditor();
|
|
2708
2908
|
});
|
|
2909
|
+
el("route-search", HTMLInputElement).addEventListener("input", paintRoutes);
|
|
2709
2910
|
el("route-form", HTMLFormElement).addEventListener("submit", (event) => {
|
|
2710
2911
|
event.preventDefault();
|
|
2711
2912
|
const send = async () => {
|
|
@@ -2727,7 +2928,8 @@ function bootAdmin(config) {
|
|
|
2727
2928
|
}
|
|
2728
2929
|
}
|
|
2729
2930
|
const data = await api(method, concrete, body);
|
|
2730
|
-
|
|
2931
|
+
const text = JSON.stringify(data, null, 2) ?? "null";
|
|
2932
|
+
el("route-result", HTMLElement).innerHTML = `<code>${highlightJsonText(text)}</code>`;
|
|
2731
2933
|
};
|
|
2732
2934
|
send().catch(showError);
|
|
2733
2935
|
});
|
|
@@ -2845,11 +3047,13 @@ function bootAdmin(config) {
|
|
|
2845
3047
|
views.append(section);
|
|
2846
3048
|
mountSqlExplorer(body, panelApi);
|
|
2847
3049
|
}
|
|
3050
|
+
show(document.getElementById(`view-${state.view}`) === null ? "overview" : state.view);
|
|
2848
3051
|
return refresh();
|
|
2849
3052
|
}).catch(showError);
|
|
2850
3053
|
}
|
|
2851
3054
|
var clientPrelude = [
|
|
2852
3055
|
isRecord2,
|
|
3056
|
+
highlightJsonText,
|
|
2853
3057
|
mountAdminBrand,
|
|
2854
3058
|
startAdminBrand,
|
|
2855
3059
|
faultPresetList,
|
|
@@ -2872,6 +3076,7 @@ ${entry}(${payload});
|
|
|
2872
3076
|
var defineMock = (runtime) => runtime;
|
|
2873
3077
|
var STANDARD_ADMIN_ROUTES = [
|
|
2874
3078
|
"GET /",
|
|
3079
|
+
"GET /health",
|
|
2875
3080
|
"POST /reset",
|
|
2876
3081
|
"GET /namespaces",
|
|
2877
3082
|
"GET /clock",
|
|
@@ -2951,11 +3156,11 @@ var escapeHtml = (value) => value.replace(/[&<>"']/g, (char) => {
|
|
|
2951
3156
|
}
|
|
2952
3157
|
});
|
|
2953
3158
|
var ADMIN_BRANDS_URL = "https://mockingbird.chrisvouga.dev/brands.json";
|
|
2954
|
-
var renderAdminDocument = (service) => {
|
|
3159
|
+
var renderAdminDocument = (service, adminPrefix = ADMIN_PREFIX) => {
|
|
2955
3160
|
const name = escapeHtml(service);
|
|
2956
3161
|
const script = adminClientSource({
|
|
2957
3162
|
standardRoutes: STANDARD_ADMIN_ROUTES,
|
|
2958
|
-
adminPrefix
|
|
3163
|
+
adminPrefix,
|
|
2959
3164
|
adminKeyHeader: ADMIN_KEY_HEADER,
|
|
2960
3165
|
brandsUrl: ADMIN_BRANDS_URL,
|
|
2961
3166
|
service
|
|
@@ -2972,75 +3177,99 @@ var renderAdminDocument = (service) => {
|
|
|
2972
3177
|
${CSS_RESET}
|
|
2973
3178
|
:root {
|
|
2974
3179
|
color-scheme: light;
|
|
2975
|
-
--bg: #
|
|
3180
|
+
--bg: #f7f8fb;
|
|
2976
3181
|
--bg-elev: #ffffff;
|
|
2977
|
-
--bg-muted: #
|
|
2978
|
-
--bg-inset: #
|
|
2979
|
-
--line: #
|
|
2980
|
-
--line-strong: #
|
|
2981
|
-
--ink: #
|
|
2982
|
-
--muted: #
|
|
2983
|
-
--faint: #
|
|
2984
|
-
--accent: #
|
|
3182
|
+
--bg-muted: #f1f3f7;
|
|
3183
|
+
--bg-inset: #f8f9fc;
|
|
3184
|
+
--line: #e4e7ec;
|
|
3185
|
+
--line-strong: #cfd4dc;
|
|
3186
|
+
--ink: #101828;
|
|
3187
|
+
--muted: #475467;
|
|
3188
|
+
--faint: #667085;
|
|
3189
|
+
--accent: #6941c6;
|
|
3190
|
+
--accent-hover: #5933b4;
|
|
2985
3191
|
--accent-ink: #ffffff;
|
|
2986
|
-
--accent-soft: #
|
|
2987
|
-
--ok: #
|
|
2988
|
-
--ok-soft: #
|
|
2989
|
-
--warn: #
|
|
2990
|
-
--warn-soft: #
|
|
2991
|
-
--err: #
|
|
2992
|
-
--err-soft: #
|
|
2993
|
-
--
|
|
3192
|
+
--accent-soft: #f4f0ff;
|
|
3193
|
+
--ok: #067647;
|
|
3194
|
+
--ok-soft: #ecfdf3;
|
|
3195
|
+
--warn: #b54708;
|
|
3196
|
+
--warn-soft: #fffaeb;
|
|
3197
|
+
--err: #b42318;
|
|
3198
|
+
--err-soft: #fef3f2;
|
|
3199
|
+
--code-key: #6941c6;
|
|
3200
|
+
--code-string: #067647;
|
|
3201
|
+
--code-number: #175cd3;
|
|
3202
|
+
--code-boolean: #c11574;
|
|
3203
|
+
--code-null: #667085;
|
|
3204
|
+
--shadow-xs: 0 1px 2px rgb(16 24 40 / 0.05);
|
|
3205
|
+
--shadow-sm: 0 1px 3px rgb(16 24 40 / 0.08), 0 1px 2px rgb(16 24 40 / 0.04);
|
|
3206
|
+
--shadow-lg: 0 18px 48px rgb(16 24 40 / 0.16), 0 4px 12px rgb(16 24 40 / 0.08);
|
|
2994
3207
|
--sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
2995
3208
|
--mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
|
|
2996
|
-
--radius:
|
|
2997
|
-
--header:
|
|
2998
|
-
--nav:
|
|
3209
|
+
--radius: 12px;
|
|
3210
|
+
--header: 72px;
|
|
3211
|
+
--nav: 224px;
|
|
2999
3212
|
}
|
|
3000
3213
|
:root[data-theme="dark"] {
|
|
3001
3214
|
color-scheme: dark;
|
|
3002
|
-
--bg: #
|
|
3003
|
-
--bg-elev: #
|
|
3004
|
-
--bg-muted: #
|
|
3005
|
-
--bg-inset: #
|
|
3006
|
-
--line: #
|
|
3007
|
-
--line-strong: #
|
|
3008
|
-
--ink: #
|
|
3009
|
-
--muted: #
|
|
3010
|
-
--faint: #
|
|
3011
|
-
--accent: #
|
|
3012
|
-
--accent-
|
|
3013
|
-
--accent-
|
|
3014
|
-
--
|
|
3015
|
-
--ok
|
|
3016
|
-
--
|
|
3017
|
-
--warn
|
|
3018
|
-
--
|
|
3019
|
-
--err
|
|
3020
|
-
--
|
|
3215
|
+
--bg: #0c0e14;
|
|
3216
|
+
--bg-elev: #151821;
|
|
3217
|
+
--bg-muted: #20232e;
|
|
3218
|
+
--bg-inset: #11141c;
|
|
3219
|
+
--line: #2b303d;
|
|
3220
|
+
--line-strong: #414858;
|
|
3221
|
+
--ink: #f5f7fa;
|
|
3222
|
+
--muted: #b6bdc9;
|
|
3223
|
+
--faint: #8d96a7;
|
|
3224
|
+
--accent: #9e77ed;
|
|
3225
|
+
--accent-hover: #b692f6;
|
|
3226
|
+
--accent-ink: #ffffff;
|
|
3227
|
+
--accent-soft: #2b2142;
|
|
3228
|
+
--ok: #75e0a7;
|
|
3229
|
+
--ok-soft: #102a20;
|
|
3230
|
+
--warn: #fec84b;
|
|
3231
|
+
--warn-soft: #302611;
|
|
3232
|
+
--err: #fda29b;
|
|
3233
|
+
--err-soft: #321817;
|
|
3234
|
+
--code-key: #c3a6ff;
|
|
3235
|
+
--code-string: #75e0a7;
|
|
3236
|
+
--code-number: #84adff;
|
|
3237
|
+
--code-boolean: #f9a8d4;
|
|
3238
|
+
--code-null: #98a2b3;
|
|
3239
|
+
--shadow-xs: 0 1px 2px rgb(0 0 0 / 0.24);
|
|
3240
|
+
--shadow-sm: 0 4px 12px rgb(0 0 0 / 0.2);
|
|
3241
|
+
--shadow-lg: 0 20px 56px rgb(0 0 0 / 0.45);
|
|
3021
3242
|
}
|
|
3022
3243
|
@media (prefers-color-scheme: dark) {
|
|
3023
3244
|
:root:not([data-theme="light"]) {
|
|
3024
3245
|
color-scheme: dark;
|
|
3025
|
-
--bg: #
|
|
3026
|
-
--bg-elev: #
|
|
3027
|
-
--bg-muted: #
|
|
3028
|
-
--bg-inset: #
|
|
3029
|
-
--line: #
|
|
3030
|
-
--line-strong: #
|
|
3031
|
-
--ink: #
|
|
3032
|
-
--muted: #
|
|
3033
|
-
--faint: #
|
|
3034
|
-
--accent: #
|
|
3035
|
-
--accent-
|
|
3036
|
-
--accent-
|
|
3037
|
-
--
|
|
3038
|
-
--ok
|
|
3039
|
-
--
|
|
3040
|
-
--warn
|
|
3041
|
-
--
|
|
3042
|
-
--err
|
|
3043
|
-
--
|
|
3246
|
+
--bg: #0c0e14;
|
|
3247
|
+
--bg-elev: #151821;
|
|
3248
|
+
--bg-muted: #20232e;
|
|
3249
|
+
--bg-inset: #11141c;
|
|
3250
|
+
--line: #2b303d;
|
|
3251
|
+
--line-strong: #414858;
|
|
3252
|
+
--ink: #f5f7fa;
|
|
3253
|
+
--muted: #b6bdc9;
|
|
3254
|
+
--faint: #8d96a7;
|
|
3255
|
+
--accent: #9e77ed;
|
|
3256
|
+
--accent-hover: #b692f6;
|
|
3257
|
+
--accent-ink: #ffffff;
|
|
3258
|
+
--accent-soft: #2b2142;
|
|
3259
|
+
--ok: #75e0a7;
|
|
3260
|
+
--ok-soft: #102a20;
|
|
3261
|
+
--warn: #fec84b;
|
|
3262
|
+
--warn-soft: #302611;
|
|
3263
|
+
--err: #fda29b;
|
|
3264
|
+
--err-soft: #321817;
|
|
3265
|
+
--code-key: #c3a6ff;
|
|
3266
|
+
--code-string: #75e0a7;
|
|
3267
|
+
--code-number: #84adff;
|
|
3268
|
+
--code-boolean: #f9a8d4;
|
|
3269
|
+
--code-null: #98a2b3;
|
|
3270
|
+
--shadow-xs: 0 1px 2px rgb(0 0 0 / 0.24);
|
|
3271
|
+
--shadow-sm: 0 4px 12px rgb(0 0 0 / 0.2);
|
|
3272
|
+
--shadow-lg: 0 20px 56px rgb(0 0 0 / 0.45);
|
|
3044
3273
|
}
|
|
3045
3274
|
}
|
|
3046
3275
|
/* Fill the viewport, then grow with the content so the background covers the scroll. */
|
|
@@ -3058,13 +3287,17 @@ var renderAdminDocument = (service) => {
|
|
|
3058
3287
|
padding-right: env(safe-area-inset-right);
|
|
3059
3288
|
-webkit-text-size-adjust: 100%;
|
|
3060
3289
|
}
|
|
3061
|
-
|
|
3290
|
+
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
|
|
3291
|
+
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
|
|
3292
|
+
button, input, select, textarea { transition: border-color 140ms ease, box-shadow 140ms ease, transform 100ms ease; }
|
|
3293
|
+
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: 0.55; }
|
|
3062
3294
|
.app { flex: 1 0 auto; display: flex; flex-direction: column; min-width: 0; width: 100%; }
|
|
3063
3295
|
header.top {
|
|
3064
|
-
position: sticky; top: 0; z-index:
|
|
3296
|
+
position: sticky; top: 0; z-index: 20;
|
|
3065
3297
|
display: flex; align-items: center; gap: 12px;
|
|
3066
|
-
min-height: var(--header); padding:
|
|
3067
|
-
background: var(--bg-elev);
|
|
3298
|
+
min-height: var(--header); padding: 12px 20px;
|
|
3299
|
+
background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
|
|
3300
|
+
backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
|
|
3068
3301
|
border-bottom: 1px solid var(--line);
|
|
3069
3302
|
min-width: 0; max-width: 100%;
|
|
3070
3303
|
}
|
|
@@ -3072,12 +3305,21 @@ var renderAdminDocument = (service) => {
|
|
|
3072
3305
|
display: flex; flex-flow: row wrap; align-items: center; gap: 14px;
|
|
3073
3306
|
min-width: 0; max-width: 100%; margin-right: auto;
|
|
3074
3307
|
}
|
|
3075
|
-
.brand-
|
|
3076
|
-
.brand-
|
|
3308
|
+
.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
|
|
3309
|
+
.brand-mark {
|
|
3310
|
+
width: 38px; height: 38px; display: grid; place-items: center; flex: none;
|
|
3311
|
+
border-radius: 11px; color: #fff;
|
|
3312
|
+
background: linear-gradient(145deg, #7f56d9 0%, #53389e 100%);
|
|
3313
|
+
box-shadow: 0 6px 16px rgb(105 65 198 / 0.24), inset 0 1px 0 rgb(255 255 255 / 0.25);
|
|
3314
|
+
}
|
|
3315
|
+
.brand-mark svg { width: 22px; height: 22px; }
|
|
3316
|
+
.brand-id { display: flex; flex-direction: column; min-width: 0; flex: none; line-height: 1.25; }
|
|
3317
|
+
.brand-id strong { font-size: 15px; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
3077
3318
|
.brand-id span { color: var(--faint); font-size: 12px; }
|
|
3078
3319
|
.vendor {
|
|
3079
3320
|
display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
|
|
3080
3321
|
min-width: 0; max-width: 100%; font-size: 12px; color: var(--muted);
|
|
3322
|
+
padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-inset);
|
|
3081
3323
|
}
|
|
3082
3324
|
.vendor[hidden] { display: none; }
|
|
3083
3325
|
/* Logos are drawn for a light tile, same as the docs site, so the plate stays white. */
|
|
@@ -3089,12 +3331,17 @@ var renderAdminDocument = (service) => {
|
|
|
3089
3331
|
.vendor-sep { color: var(--faint); }
|
|
3090
3332
|
.vendor-link { color: inherit; text-decoration: none; }
|
|
3091
3333
|
.vendor-link:hover { color: var(--ink); text-decoration: underline; }
|
|
3092
|
-
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items:
|
|
3093
|
-
|
|
3334
|
+
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
|
|
3335
|
+
.sync-status { align-self: center; display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 12px; white-space: nowrap; }
|
|
3336
|
+
.sync-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
|
|
3337
|
+
.sync-status.busy::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 1.2s ease-in-out infinite; }
|
|
3338
|
+
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 600; color: var(--faint); }
|
|
3094
3339
|
label.field input, label.field select, .controls input[type="password"] {
|
|
3095
|
-
background-color: var(--bg-
|
|
3096
|
-
padding:
|
|
3340
|
+
background-color: var(--bg-elev); border: 1px solid var(--line-strong); border-radius: 9px;
|
|
3341
|
+
padding: 8px 10px; min-height: 38px; line-height: 1.2; box-shadow: var(--shadow-xs);
|
|
3097
3342
|
}
|
|
3343
|
+
label.field input:hover, label.field select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 38%, var(--line-strong)); }
|
|
3344
|
+
label.field input:focus, label.field select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); outline: none; }
|
|
3098
3345
|
/* A native menu ignores min-height, so Preset rendered about half as tall as
|
|
3099
3346
|
the text fields in the same form. Paint it like those fields. */
|
|
3100
3347
|
label.field select {
|
|
@@ -3111,12 +3358,20 @@ var renderAdminDocument = (service) => {
|
|
|
3111
3358
|
dialog .field > textarea { width: 100%; }
|
|
3112
3359
|
.icon-btn, .btn, .btn-primary, .btn-quiet, .btn-danger, nav.side button { cursor: pointer; }
|
|
3113
3360
|
.icon-btn, .btn, .btn-primary, .btn-quiet, .btn-danger {
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
.btn
|
|
3361
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 7px;
|
|
3362
|
+
border-radius: 9px; min-height: 38px; padding: 0 13px; border: 1px solid var(--line-strong);
|
|
3363
|
+
background: var(--bg-elev); color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1;
|
|
3364
|
+
box-shadow: var(--shadow-xs);
|
|
3365
|
+
}
|
|
3366
|
+
.icon-btn { width: 38px; padding: 0; }
|
|
3367
|
+
.icon-btn svg, .btn svg, .btn-primary svg { width: 16px; height: 16px; }
|
|
3368
|
+
.icon-btn:hover, .btn:hover { background: var(--bg-muted); border-color: var(--line-strong); }
|
|
3369
|
+
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); box-shadow: 0 1px 2px rgb(16 24 40 / 0.08), 0 0 0 1px rgb(255 255 255 / 0.08) inset; }
|
|
3370
|
+
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
|
|
3371
|
+
.btn-quiet { background: transparent; border-color: transparent; box-shadow: none; }
|
|
3372
|
+
.btn-quiet:hover { background: var(--bg-muted); }
|
|
3373
|
+
.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, var(--line)); }
|
|
3374
|
+
.btn-danger:hover, .btn-danger.confirming { background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 45%, var(--line)); }
|
|
3120
3375
|
/* Held after mouseup. Clearing an empty journal changes nothing on screen,
|
|
3121
3376
|
so the press itself has to stay visible. */
|
|
3122
3377
|
.icon-btn:active, .btn:active, .btn-quiet:active, .btn-danger:active, nav.side button:active,
|
|
@@ -3132,93 +3387,159 @@ var renderAdminDocument = (service) => {
|
|
|
3132
3387
|
flex: 1 0 auto; min-width: 0;
|
|
3133
3388
|
}
|
|
3134
3389
|
nav.side {
|
|
3135
|
-
|
|
3390
|
+
position: sticky; top: var(--header); align-self: start; height: calc(100vh - var(--header));
|
|
3391
|
+
border-right: 1px solid var(--line); padding: 18px 12px;
|
|
3136
3392
|
display: flex; flex-direction: column; gap: 4px;
|
|
3137
|
-
background: var(--bg-elev);
|
|
3393
|
+
background: var(--bg-elev); overflow-y: auto;
|
|
3138
3394
|
}
|
|
3395
|
+
.nav-label { padding: 0 10px 8px; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }
|
|
3139
3396
|
nav.side button {
|
|
3397
|
+
position: relative; display: flex; align-items: center; gap: 10px; width: 100%;
|
|
3140
3398
|
text-align: left; border: 0; background: transparent; border-radius: 9px;
|
|
3141
|
-
padding: 9px 10px; min-height:
|
|
3142
|
-
}
|
|
3143
|
-
nav.side button
|
|
3144
|
-
|
|
3145
|
-
.
|
|
3146
|
-
.
|
|
3147
|
-
.
|
|
3399
|
+
padding: 9px 10px; min-height: 42px; color: var(--muted); font-size: 13px; font-weight: 550;
|
|
3400
|
+
}
|
|
3401
|
+
nav.side button:hover { background: var(--bg-muted); color: var(--ink); }
|
|
3402
|
+
nav.side button[aria-current="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
|
|
3403
|
+
nav.side button[aria-current="true"]::before { content: ""; position: absolute; left: -12px; width: 3px; height: 22px; border-radius: 0 4px 4px 0; background: var(--accent); }
|
|
3404
|
+
.nav-icon { width: 18px; height: 18px; display: grid; place-items: center; flex: none; }
|
|
3405
|
+
.nav-icon svg { width: 18px; height: 18px; }
|
|
3406
|
+
main { padding: 32px clamp(20px, 4vw, 48px) 64px; max-width: 1320px; width: 100%; min-width: 0; }
|
|
3407
|
+
main[aria-busy="true"] .view { opacity: 0.62; }
|
|
3408
|
+
.view { animation: view-in 180ms ease-out; }
|
|
3409
|
+
.view[hidden] { display: none; }
|
|
3410
|
+
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
|
|
3411
|
+
.view h2 { margin: 0 0 5px; font-size: clamp(24px, 3vw, 30px); line-height: 1.2; letter-spacing: -0.035em; }
|
|
3412
|
+
.view h3 { margin: 24px 0 10px; font-size: 15px; letter-spacing: -0.01em; }
|
|
3413
|
+
.lede { margin: 0; color: var(--muted); max-width: 72ch; font-size: 14px; }
|
|
3414
|
+
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 175px), 1fr)); gap: 14px; }
|
|
3148
3415
|
.card {
|
|
3149
3416
|
background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
|
|
3150
|
-
padding:
|
|
3417
|
+
padding: 18px; box-shadow: var(--shadow-sm);
|
|
3151
3418
|
}
|
|
3152
|
-
.card
|
|
3153
|
-
.card
|
|
3419
|
+
.stat-card { position: relative; overflow: hidden; }
|
|
3420
|
+
.stat-card::after { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: linear-gradient(90deg, var(--accent), transparent 78%); opacity: 0.7; }
|
|
3421
|
+
.card .k { color: var(--faint); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; }
|
|
3422
|
+
.card .v { display: flex; flex-direction: column; gap: 2px; font-size: 24px; font-weight: 650; margin-top: 7px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; letter-spacing: -0.025em; }
|
|
3154
3423
|
.card .v .clock-time { font-size: 14px; color: var(--muted); }
|
|
3155
|
-
.
|
|
3424
|
+
.section-card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-xs); overflow: hidden; }
|
|
3425
|
+
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
|
|
3426
|
+
.section-title h3 { margin: 0; }
|
|
3427
|
+
.split { display: grid; grid-template-columns: minmax(0, 250px) minmax(0, 1fr); gap: 18px; align-items: start; }
|
|
3428
|
+
#collections { padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); box-shadow: var(--shadow-xs); }
|
|
3156
3429
|
.collection {
|
|
3157
3430
|
width: 100%; text-align: left; border: 1px solid transparent; background: transparent;
|
|
3158
|
-
border-radius:
|
|
3431
|
+
border-radius: 9px; padding: 10px 11px; min-height: 48px; color: var(--ink); cursor: pointer;
|
|
3159
3432
|
}
|
|
3160
|
-
.collection
|
|
3433
|
+
.collection:hover { background: var(--bg-muted); }
|
|
3434
|
+
.collection[aria-current="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 18%, var(--line)); color: var(--accent); }
|
|
3161
3435
|
.collection small { display: block; color: var(--faint); }
|
|
3162
3436
|
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
|
|
3163
|
-
.chip {
|
|
3164
|
-
font-family: var(--mono); font-size: 12px; background: var(--bg-muted);
|
|
3165
|
-
border-radius: 999px; padding: 4px 8px;
|
|
3166
|
-
}
|
|
3437
|
+
.chip { font-family: var(--mono); font-size: 11px; background: var(--bg-muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px; }
|
|
3167
3438
|
.chip i { color: var(--faint); font-style: normal; }
|
|
3168
3439
|
.sql-layout {
|
|
3169
3440
|
display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 16px;
|
|
3170
3441
|
}
|
|
3171
|
-
.sql-tables { display: flex; flex-direction: column; gap: 4px; max-height: 28rem; overflow: auto; }
|
|
3172
|
-
.sql-tables button { text-align: left; }
|
|
3442
|
+
.sql-tables { display: flex; flex-direction: column; gap: 4px; max-height: 28rem; overflow: auto; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); }
|
|
3443
|
+
.sql-tables button { text-align: left; border: 0; border-radius: 8px; padding: 9px 10px; background: transparent; color: var(--muted); cursor: pointer; }
|
|
3444
|
+
.sql-tables button:hover, .sql-tables button[aria-current="true"] { background: var(--accent-soft); color: var(--accent); }
|
|
3173
3445
|
.sql-input { font-family: var(--mono); min-height: 7rem; width: 100%; }
|
|
3174
|
-
table { width: 100%; border-
|
|
3175
|
-
|
|
3176
|
-
th {
|
|
3446
|
+
.table-shell { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); box-shadow: var(--shadow-xs); }
|
|
3447
|
+
table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
3448
|
+
th, td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); vertical-align: top; }
|
|
3449
|
+
th { color: var(--faint); background: var(--bg-inset); font-weight: 650; font-size: 11px; text-transform: uppercase; letter-spacing: 0.045em; }
|
|
3450
|
+
tbody tr:last-child td { border-bottom: 0; }
|
|
3177
3451
|
tr.clickable { cursor: pointer; }
|
|
3178
|
-
tr.clickable:hover { background: var(--
|
|
3452
|
+
tr.clickable:hover { background: var(--accent-soft); }
|
|
3179
3453
|
pre, code, .mono { font-family: var(--mono); overflow-wrap: anywhere; }
|
|
3180
3454
|
pre {
|
|
3181
3455
|
margin: 0; white-space: pre-wrap; word-break: break-word;
|
|
3182
|
-
background: var(--bg-inset); border-radius: 10px; padding:
|
|
3183
|
-
}
|
|
3184
|
-
.
|
|
3456
|
+
background: var(--bg-inset); border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-size: 12px; line-height: 1.65;
|
|
3457
|
+
}
|
|
3458
|
+
.json-key { color: var(--code-key); }
|
|
3459
|
+
.json-string { color: var(--code-string); }
|
|
3460
|
+
.json-number { color: var(--code-number); }
|
|
3461
|
+
.json-boolean { color: var(--code-boolean); }
|
|
3462
|
+
.json-null { color: var(--code-null); font-style: italic; }
|
|
3463
|
+
.json-inline { display: block; max-width: 44rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
|
3464
|
+
.json-view { position: relative; max-height: 26rem; overflow: auto; }
|
|
3465
|
+
.json-editor { position: relative; min-height: 190px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg-inset); overflow: hidden; }
|
|
3466
|
+
.json-editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
|
|
3467
|
+
.json-editor.invalid { border-color: var(--err); }
|
|
3468
|
+
.json-editor pre, .json-editor textarea { margin: 0; padding: 12px; border: 0; border-radius: 0; min-height: 190px; width: 100%; font: 12px/1.65 var(--mono); tab-size: 2; white-space: pre; overflow: auto; }
|
|
3469
|
+
.json-editor pre { position: absolute; inset: 0; pointer-events: none; background: transparent; }
|
|
3470
|
+
.json-editor textarea { position: relative; z-index: 1; resize: vertical; background: transparent; color: transparent; caret-color: var(--ink); -webkit-text-fill-color: transparent; }
|
|
3471
|
+
.json-editor textarea::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); }
|
|
3472
|
+
.editor-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 7px; }
|
|
3473
|
+
.json-status { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-size: 11px; }
|
|
3474
|
+
.json-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
|
|
3475
|
+
.json-status.invalid { color: var(--err); }
|
|
3476
|
+
.format-json { border: 0; padding: 3px 5px; background: transparent; color: var(--accent); font-size: 11px; font-weight: 650; cursor: pointer; }
|
|
3477
|
+
.row-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin: 14px 0; }
|
|
3185
3478
|
.banner {
|
|
3186
|
-
display: none;
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3479
|
+
display: none; position: sticky; top: calc(var(--header) + 12px); z-index: 15;
|
|
3480
|
+
align-items: center; gap: 10px; margin: 0 0 16px; padding: 11px 12px 11px 14px;
|
|
3481
|
+
border: 1px solid color-mix(in srgb, var(--err) 30%, var(--line)); border-radius: 10px;
|
|
3482
|
+
background: var(--err-soft); color: var(--err); box-shadow: var(--shadow-sm); font-size: 13px;
|
|
3483
|
+
}
|
|
3484
|
+
.banner.show { display: flex; }
|
|
3485
|
+
.banner span { flex: 1; }
|
|
3486
|
+
.banner button { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: currentColor; cursor: pointer; }
|
|
3487
|
+
.banner button:hover { background: color-mix(in srgb, var(--err) 10%, transparent); }
|
|
3488
|
+
.empty { color: var(--muted); padding: 34px 18px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: color-mix(in srgb, var(--bg-elev) 55%, transparent); }
|
|
3191
3489
|
dialog {
|
|
3192
|
-
border: 1px solid var(--line); border-radius:
|
|
3193
|
-
color: var(--ink); width: min(
|
|
3194
|
-
}
|
|
3195
|
-
dialog
|
|
3196
|
-
dialog
|
|
3490
|
+
border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--bg-elev);
|
|
3491
|
+
color: var(--ink); width: min(720px, calc(100% - 24px)); max-width: calc(100vw - 24px); box-shadow: var(--shadow-lg);
|
|
3492
|
+
}
|
|
3493
|
+
dialog[open] { animation: dialog-in 160ms ease-out; }
|
|
3494
|
+
dialog::backdrop { background: rgb(12 14 20 / 0.58); backdrop-filter: blur(3px); }
|
|
3495
|
+
dialog form, .dialog-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
|
|
3496
|
+
.dialog-heading { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
|
|
3497
|
+
.dialog-heading strong { font-size: 18px; letter-spacing: -0.02em; }
|
|
3498
|
+
.dialog-heading span { color: var(--muted); font-size: 12px; }
|
|
3197
3499
|
textarea {
|
|
3198
3500
|
width: 100%; min-height: 180px; resize: vertical; border-radius: 10px;
|
|
3199
3501
|
border: 1px solid var(--line); background: var(--bg-inset); padding: 10px;
|
|
3200
3502
|
font-family: var(--mono); font-size: 12px;
|
|
3201
3503
|
}
|
|
3202
|
-
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
3203
|
-
.
|
|
3504
|
+
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding-top: 4px; }
|
|
3505
|
+
.dialog-actions .btn-danger { margin-right: auto; }
|
|
3506
|
+
.badge { display: inline-flex; align-items: center; font-size: 10px; font-weight: 700; letter-spacing: 0.03em; border: 1px solid var(--line); border-radius: 999px; padding: 3px 7px; background: var(--bg-muted); color: var(--muted); }
|
|
3204
3507
|
.badge.ok { background: var(--ok-soft); color: var(--ok); }
|
|
3205
3508
|
.badge.warn { background: var(--warn-soft); color: var(--warn); }
|
|
3206
3509
|
.status-2 { color: var(--ok); }
|
|
3207
3510
|
.status-4, .status-5, .status-0 { color: var(--err); }
|
|
3208
3511
|
.stack { display: flex; flex-direction: column; gap: 12px; }
|
|
3512
|
+
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
|
|
3513
|
+
.form-grid .wide { grid-column: span 2; }
|
|
3209
3514
|
.route {
|
|
3210
|
-
display: grid; grid-template-columns:
|
|
3211
|
-
padding:
|
|
3212
|
-
}
|
|
3213
|
-
.
|
|
3515
|
+
display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 10px; align-items: center;
|
|
3516
|
+
padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg-elev);
|
|
3517
|
+
}
|
|
3518
|
+
.route:first-child { border-radius: var(--radius) var(--radius) 0 0; }
|
|
3519
|
+
.route:last-child { border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
|
|
3520
|
+
.route-tools { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
|
|
3521
|
+
.route-tools .field { flex: 1; }
|
|
3522
|
+
.route-tools input { width: 100%; }
|
|
3523
|
+
.route-count { padding-bottom: 10px; color: var(--faint); font-size: 12px; white-space: nowrap; }
|
|
3524
|
+
#route-list { max-height: 34rem; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow-xs); }
|
|
3525
|
+
.method { width: fit-content; font-family: var(--mono); font-size: 11px; font-weight: 750; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 4px 6px; }
|
|
3526
|
+
@keyframes view-in { from { transform: translateY(3px); } to { transform: translateY(0); } }
|
|
3527
|
+
@keyframes dialog-in { from { transform: translateY(8px) scale(0.99); } to { transform: translateY(0) scale(1); } }
|
|
3528
|
+
@keyframes pulse { 50% { opacity: 0.45; } }
|
|
3529
|
+
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
|
|
3530
|
+
@media (forced-colors: active) { .json-editor pre { display: none; } .json-editor textarea { color: CanvasText; -webkit-text-fill-color: CanvasText; } }
|
|
3214
3531
|
@media (max-width: 800px) {
|
|
3532
|
+
:root { --header: 0px; }
|
|
3215
3533
|
header.top {
|
|
3216
|
-
align-items: stretch; flex-direction: column;
|
|
3217
|
-
padding
|
|
3534
|
+
position: relative; align-items: stretch; flex-direction: column;
|
|
3535
|
+
padding: max(12px, env(safe-area-inset-top)) 14px 12px;
|
|
3218
3536
|
}
|
|
3219
3537
|
input, select, textarea { font-size: 16px; }
|
|
3220
3538
|
.brand, .vendor, .controls { width: 100%; }
|
|
3539
|
+
.brand { gap: 10px; }
|
|
3540
|
+
.vendor { order: 2; border-radius: 9px; }
|
|
3221
3541
|
label.field, label.field select, label.field input { flex: 1; min-width: 0; }
|
|
3542
|
+
.sync-status { display: none; }
|
|
3222
3543
|
/* The layout fills the screen. A single-column grid stretches every auto
|
|
3223
3544
|
row, so the tab bar grew with the leftover height and the buttons floated
|
|
3224
3545
|
in the middle of it. The bar stays one row; the page below takes the rest. */
|
|
@@ -3228,14 +3549,23 @@ var renderAdminDocument = (service) => {
|
|
|
3228
3549
|
align-content: start;
|
|
3229
3550
|
}
|
|
3230
3551
|
nav.side {
|
|
3231
|
-
align-self: start; height: auto;
|
|
3552
|
+
position: sticky; top: 0; z-index: 12; align-self: start; height: auto;
|
|
3232
3553
|
flex-direction: row; align-items: center; overflow-x: auto; min-width: 0;
|
|
3233
3554
|
border-right: 0; border-bottom: 1px solid var(--line);
|
|
3234
|
-
padding: 8px;
|
|
3555
|
+
padding: 8px; box-shadow: var(--shadow-xs);
|
|
3235
3556
|
}
|
|
3236
|
-
nav
|
|
3557
|
+
.nav-label { display: none; }
|
|
3558
|
+
nav.side button { width: auto; white-space: nowrap; flex: none; }
|
|
3559
|
+
nav.side button[aria-current="true"]::before { inset: auto 9px -8px; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
|
|
3237
3560
|
.split, .sql-layout { grid-template-columns: minmax(0, 1fr); }
|
|
3238
|
-
|
|
3561
|
+
.form-grid { grid-template-columns: minmax(0, 1fr); }
|
|
3562
|
+
.form-grid .wide { grid-column: auto; }
|
|
3563
|
+
main { padding: 22px 14px 48px; }
|
|
3564
|
+
.view-head { margin-bottom: 18px; }
|
|
3565
|
+
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
|
|
3566
|
+
.card { padding: 14px; }
|
|
3567
|
+
.card .v { font-size: 20px; }
|
|
3568
|
+
.table-shell { border: 0; background: transparent; box-shadow: none; overflow: visible; }
|
|
3239
3569
|
table, thead, tbody, tr, th, td { display: block; }
|
|
3240
3570
|
thead { display: none; }
|
|
3241
3571
|
tr {
|
|
@@ -3250,50 +3580,63 @@ var renderAdminDocument = (service) => {
|
|
|
3250
3580
|
.route { grid-template-columns: 72px 1fr; }
|
|
3251
3581
|
.route button { grid-column: 1 / -1; }
|
|
3252
3582
|
}
|
|
3583
|
+
@media (max-width: 460px) {
|
|
3584
|
+
.controls label.field { min-width: calc(50% - 4px); }
|
|
3585
|
+
.controls .icon-btn, .controls .btn { flex: 1; }
|
|
3586
|
+
.grid { grid-template-columns: minmax(0, 1fr); }
|
|
3587
|
+
.dialog-actions { flex-wrap: wrap; }
|
|
3588
|
+
.dialog-actions button { flex: 1; }
|
|
3589
|
+
.dialog-actions .btn-danger { flex-basis: 100%; margin-right: 0; }
|
|
3590
|
+
}
|
|
3253
3591
|
</style>
|
|
3254
3592
|
</head>
|
|
3255
3593
|
<body>
|
|
3256
3594
|
<div class="app" data-service="${name}" data-mockingbird-admin>
|
|
3257
3595
|
<header class="top">
|
|
3258
3596
|
<div class="brand">
|
|
3259
|
-
<div class="brand-
|
|
3260
|
-
<
|
|
3261
|
-
|
|
3597
|
+
<div class="brand-lockup">
|
|
3598
|
+
<div class="brand-mark" aria-hidden="true">
|
|
3599
|
+
<svg viewBox="0 0 24 24" fill="none"><path d="M5 17.5V7l7 5 7-5v10.5" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 15.5 12 18l4-2.5" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
|
3600
|
+
</div>
|
|
3601
|
+
<div class="brand-id">
|
|
3602
|
+
<strong>${name}</strong>
|
|
3603
|
+
<span>Mock admin</span>
|
|
3604
|
+
</div>
|
|
3262
3605
|
</div>
|
|
3263
3606
|
<div class="vendor" id="vendor" hidden></div>
|
|
3264
3607
|
</div>
|
|
3265
3608
|
<div class="controls">
|
|
3609
|
+
<span class="sync-status" id="sync-status" role="status" aria-live="polite">Ready</span>
|
|
3266
3610
|
<label class="field">Namespace
|
|
3267
3611
|
<select id="namespace" aria-label="Namespace"></select>
|
|
3268
3612
|
</label>
|
|
3269
3613
|
<label class="field">Admin key
|
|
3270
3614
|
<input id="admin-key" type="password" autocomplete="off" spellcheck="false" aria-label="Admin key">
|
|
3271
3615
|
</label>
|
|
3272
|
-
<button class="icon-btn" id="theme" type="button" aria-label="
|
|
3273
|
-
<button class="btn" id="refresh" type="button">Refresh</button>
|
|
3616
|
+
<button class="icon-btn" id="theme" type="button" aria-label="Use dark theme" title="Use dark theme"></button>
|
|
3617
|
+
<button class="btn" id="refresh" type="button"><svg viewBox="0 0 20 20" fill="none" aria-hidden="true"><path d="M15.8 7.2A6.2 6.2 0 1 0 16 12" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M12.8 7.2h3v-3" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>Refresh</button>
|
|
3274
3618
|
</div>
|
|
3275
3619
|
</header>
|
|
3276
3620
|
<div class="layout">
|
|
3277
3621
|
<nav class="side" id="nav" aria-label="Admin sections">
|
|
3278
|
-
<
|
|
3279
|
-
<button type="button" data-view="
|
|
3280
|
-
<button type="button" data-view="
|
|
3281
|
-
<button type="button" data-view="
|
|
3282
|
-
<button type="button" data-view="
|
|
3283
|
-
<button type="button" data-view="
|
|
3622
|
+
<span class="nav-label">Workspace</span>
|
|
3623
|
+
<button type="button" data-view="overview" aria-current="true"><span class="nav-icon" aria-hidden="true"><svg viewBox="0 0 20 20" fill="none"><rect x="2.5" y="2.5" width="6" height="6" rx="1.5" stroke="currentColor" stroke-width="1.5"/><rect x="11.5" y="2.5" width="6" height="6" rx="1.5" stroke="currentColor" stroke-width="1.5"/><rect x="2.5" y="11.5" width="6" height="6" rx="1.5" stroke="currentColor" stroke-width="1.5"/><rect x="11.5" y="11.5" width="6" height="6" rx="1.5" stroke="currentColor" stroke-width="1.5"/></svg></span>Overview</button>
|
|
3624
|
+
<button type="button" data-view="state"><span class="nav-icon" aria-hidden="true"><svg viewBox="0 0 20 20" fill="none"><ellipse cx="10" cy="5" rx="6.5" ry="2.5" stroke="currentColor" stroke-width="1.5"/><path d="M3.5 5v5c0 1.4 2.9 2.5 6.5 2.5s6.5-1.1 6.5-2.5V5M3.5 10v5c0 1.4 2.9 2.5 6.5 2.5s6.5-1.1 6.5-2.5v-5" stroke="currentColor" stroke-width="1.5"/></svg></span>State</button>
|
|
3625
|
+
<button type="button" data-view="clock"><span class="nav-icon" aria-hidden="true"><svg viewBox="0 0 20 20" fill="none"><circle cx="10" cy="10" r="7.5" stroke="currentColor" stroke-width="1.5"/><path d="M10 5.8v4.6l3 1.8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg></span>Clock</button>
|
|
3626
|
+
<button type="button" data-view="faults"><span class="nav-icon" aria-hidden="true"><svg viewBox="0 0 20 20" fill="none"><path d="m11.2 2.8-6.5 9h5.1l-1 5.4 6.5-9h-5.1l1-5.4Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg></span>Faults</button>
|
|
3627
|
+
<button type="button" data-view="journal"><span class="nav-icon" aria-hidden="true"><svg viewBox="0 0 20 20" fill="none"><path d="M5 3.5h10a1.5 1.5 0 0 1 1.5 1.5v12l-2.2-1.4-2.2 1.4-2.1-1.4L7.8 17l-2.2-1.4L3.5 17V5A1.5 1.5 0 0 1 5 3.5Z" stroke="currentColor" stroke-width="1.5"/><path d="M6.7 7h6.6M6.7 10h6.6M6.7 13h3.8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg></span>Journal</button>
|
|
3628
|
+
<button type="button" data-view="routes"><span class="nav-icon" aria-hidden="true"><svg viewBox="0 0 20 20" fill="none"><path d="M6.5 4.5h7a2 2 0 0 1 2 2v7M13 11l2.5 2.5L18 11M13.5 15.5h-7a2 2 0 0 1-2-2v-7M7 9 4.5 6.5 2 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg></span>Routes</button>
|
|
3284
3629
|
</nav>
|
|
3285
3630
|
<main id="views">
|
|
3286
|
-
<
|
|
3631
|
+
<div class="banner" id="banner" role="alert"><span id="banner-message"></span><button id="banner-dismiss" type="button" aria-label="Dismiss error">\xD7</button></div>
|
|
3287
3632
|
<section class="view" id="view-overview">
|
|
3288
|
-
<h2>Overview</h2>
|
|
3289
|
-
<p class="lede">Health, clock, and the collections this namespace is holding.</p>
|
|
3633
|
+
<div class="view-head"><div><h2>Overview</h2><p class="lede">Health, clock, and the collections this namespace is holding.</p></div></div>
|
|
3290
3634
|
<div class="grid" id="overview-cards"></div>
|
|
3291
3635
|
<h3>Recent requests</h3>
|
|
3292
3636
|
<div id="overview-requests"></div>
|
|
3293
3637
|
</section>
|
|
3294
3638
|
<section class="view" id="view-state" hidden>
|
|
3295
|
-
<h2>State</h2>
|
|
3296
|
-
<p class="lede">Every collection in this namespace. Declared fields stay visible before any row exists; stored rows add whatever else they contain.</p>
|
|
3639
|
+
<div class="view-head"><div><h2>State</h2><p class="lede">Inspect and edit every collection in this namespace.</p></div></div>
|
|
3297
3640
|
<div class="split">
|
|
3298
3641
|
<div id="collections"></div>
|
|
3299
3642
|
<div>
|
|
@@ -3306,8 +3649,7 @@ var renderAdminDocument = (service) => {
|
|
|
3306
3649
|
</div>
|
|
3307
3650
|
</section>
|
|
3308
3651
|
<section class="view" id="view-clock" hidden>
|
|
3309
|
-
<h2>Clock</h2>
|
|
3310
|
-
<p class="lede">The clock every timestamp in this mock reads.</p>
|
|
3652
|
+
<div class="view-head"><div><h2>Clock</h2><p class="lede">Control the source of time used by every timestamp in this mock.</p></div></div>
|
|
3311
3653
|
<div class="card" id="clock-readout"></div>
|
|
3312
3654
|
<div class="row-actions">
|
|
3313
3655
|
<button class="btn" type="button" data-advance="60000">+1m</button>
|
|
@@ -3326,21 +3668,22 @@ var renderAdminDocument = (service) => {
|
|
|
3326
3668
|
</form>
|
|
3327
3669
|
</section>
|
|
3328
3670
|
<section class="view" id="view-faults" hidden>
|
|
3329
|
-
<h2>Faults</h2>
|
|
3330
|
-
<p class="lede">Inject a response, a delay, or a named preset. Rules apply to this namespace.</p>
|
|
3671
|
+
<div class="view-head"><div><h2>Faults</h2><p class="lede">Test unhappy paths with a response, delay, or named preset scoped to this namespace.</p></div></div>
|
|
3331
3672
|
<form id="fault-form" class="card stack">
|
|
3332
|
-
<
|
|
3333
|
-
<
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
<
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
<
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
<
|
|
3343
|
-
|
|
3673
|
+
<div class="form-grid">
|
|
3674
|
+
<label class="field wide">Preset
|
|
3675
|
+
<select id="fault-preset"><option value="">Custom rule</option></select>
|
|
3676
|
+
</label>
|
|
3677
|
+
<label class="field">Status
|
|
3678
|
+
<input id="fault-status" inputmode="numeric" placeholder="503">
|
|
3679
|
+
</label>
|
|
3680
|
+
<label class="field wide">Path prefix
|
|
3681
|
+
<input id="fault-path" placeholder="/v1">
|
|
3682
|
+
</label>
|
|
3683
|
+
<label class="field">Method
|
|
3684
|
+
<input id="fault-method" placeholder="GET">
|
|
3685
|
+
</label>
|
|
3686
|
+
</div>
|
|
3344
3687
|
<div class="dialog-actions">
|
|
3345
3688
|
<button class="btn-primary" type="submit">Add fault</button>
|
|
3346
3689
|
<button class="btn-danger" id="fault-clear" type="button">Clear all</button>
|
|
@@ -3349,26 +3692,31 @@ var renderAdminDocument = (service) => {
|
|
|
3349
3692
|
<div id="fault-list"></div>
|
|
3350
3693
|
</section>
|
|
3351
3694
|
<section class="view" id="view-journal" hidden>
|
|
3352
|
-
<h2>Journal</h2>
|
|
3353
|
-
<p class="lede">Requests this namespace has seen. Bodies are not stored.</p>
|
|
3354
|
-
<div class="row-actions">
|
|
3355
|
-
<button class="btn-danger" id="journal-clear" type="button">Clear journal</button>
|
|
3356
|
-
</div>
|
|
3695
|
+
<div class="view-head"><div><h2>Journal</h2><p class="lede">Requests this namespace has seen. Bodies are never stored.</p></div><button class="btn-danger" id="journal-clear" type="button">Clear journal</button></div>
|
|
3357
3696
|
<div id="journal"></div>
|
|
3358
3697
|
</section>
|
|
3359
3698
|
<section class="view" id="view-routes" hidden>
|
|
3360
|
-
<h2>Routes</h2>
|
|
3361
|
-
<
|
|
3699
|
+
<div class="view-head"><div><h2>Routes</h2><p class="lede">Explore shared controls and service-specific admin endpoints.</p></div></div>
|
|
3700
|
+
<div class="route-tools">
|
|
3701
|
+
<label class="field">Filter routes
|
|
3702
|
+
<input id="route-search" type="search" placeholder="Method, path, or extension" autocomplete="off">
|
|
3703
|
+
</label>
|
|
3704
|
+
<span class="route-count" id="route-count"></span>
|
|
3705
|
+
</div>
|
|
3362
3706
|
<div id="route-list"></div>
|
|
3363
|
-
<form id="route-form" class="card stack">
|
|
3707
|
+
<form id="route-form" class="card stack" style="margin-top: 18px">
|
|
3364
3708
|
<strong id="route-title">Select a route</strong>
|
|
3365
3709
|
<label class="field">JSON body
|
|
3366
|
-
<
|
|
3710
|
+
<div class="json-editor" id="route-editor" hidden>
|
|
3711
|
+
<pre aria-hidden="true"><code id="route-highlight"></code></pre>
|
|
3712
|
+
<textarea id="route-body" placeholder="{ }" spellcheck="false" aria-describedby="route-json-status" disabled></textarea>
|
|
3713
|
+
</div>
|
|
3714
|
+
<span class="editor-meta" hidden><span class="json-status" id="route-json-status">Valid JSON</span><button class="format-json" type="button" data-format="route-body">Format JSON</button></span>
|
|
3367
3715
|
</label>
|
|
3368
3716
|
<div class="dialog-actions">
|
|
3369
|
-
<button class="btn-primary" type="submit">Send</button>
|
|
3717
|
+
<button class="btn-primary" id="route-send" type="submit" disabled>Send request</button>
|
|
3370
3718
|
</div>
|
|
3371
|
-
<pre id="route-result">Response will show here.</pre>
|
|
3719
|
+
<pre class="json-view" id="route-result"><code>Response will show here.</code></pre>
|
|
3372
3720
|
</form>
|
|
3373
3721
|
</section>
|
|
3374
3722
|
</main>
|
|
@@ -3376,12 +3724,16 @@ var renderAdminDocument = (service) => {
|
|
|
3376
3724
|
</div>
|
|
3377
3725
|
<dialog id="editor">
|
|
3378
3726
|
<form method="dialog" id="editor-form">
|
|
3379
|
-
<strong id="editor-title">Record</strong>
|
|
3727
|
+
<div class="dialog-heading"><div><strong id="editor-title">Record</strong><br><span>Edit the ID and JSON value stored in this collection.</span></div></div>
|
|
3380
3728
|
<label class="field">Id
|
|
3381
3729
|
<input id="editor-id" required>
|
|
3382
3730
|
</label>
|
|
3383
3731
|
<label class="field">JSON value
|
|
3384
|
-
<
|
|
3732
|
+
<div class="json-editor" id="record-editor">
|
|
3733
|
+
<pre aria-hidden="true"><code id="editor-highlight"></code></pre>
|
|
3734
|
+
<textarea id="editor-value" spellcheck="false" aria-describedby="editor-json-status"></textarea>
|
|
3735
|
+
</div>
|
|
3736
|
+
<span class="editor-meta"><span class="json-status" id="editor-json-status">Valid JSON</span><button class="format-json" type="button" data-format="editor-value">Format JSON</button></span>
|
|
3385
3737
|
</label>
|
|
3386
3738
|
<div class="dialog-actions">
|
|
3387
3739
|
<button class="btn-danger" id="editor-delete" type="button" value="delete">Delete</button>
|
|
@@ -3423,8 +3775,8 @@ var describeExtension = (extension) => {
|
|
|
3423
3775
|
...extension.script !== void 0 ? { script: extension.script } : {}
|
|
3424
3776
|
};
|
|
3425
3777
|
};
|
|
3426
|
-
var adminUiRoutes = (service, ui) => {
|
|
3427
|
-
const shell = () => renderAdminDocument(service);
|
|
3778
|
+
var adminUiRoutes = (service, ui, adminPrefix = ADMIN_PREFIX) => {
|
|
3779
|
+
const shell = () => renderAdminDocument(service, adminPrefix);
|
|
3428
3780
|
const document3 = () => ui?.render ? ui.render({ service, defaultHtml: shell }) : shell();
|
|
3429
3781
|
return {
|
|
3430
3782
|
"GET /ui": () => htmlResponse(document3()),
|
|
@@ -4115,10 +4467,13 @@ var stateAdminRoutes = (routes) => {
|
|
|
4115
4467
|
};
|
|
4116
4468
|
|
|
4117
4469
|
// ../core/dist/version.js
|
|
4118
|
-
var PACKAGE_VERSION = true ? "
|
|
4470
|
+
var PACKAGE_VERSION = true ? "2.0.0" : UNRELEASED_VERSION;
|
|
4119
4471
|
|
|
4120
4472
|
// ../core/dist/webhooks.js
|
|
4121
|
-
var json4 = (status, body) => new Response(JSON.stringify(body), {
|
|
4473
|
+
var json4 = (status, body) => new Response(JSON.stringify(body), {
|
|
4474
|
+
status,
|
|
4475
|
+
headers: { "content-type": "application/json; charset=utf-8" }
|
|
4476
|
+
});
|
|
4122
4477
|
var adminError3 = (status, message) => json4(status, { error: { type: "mockingbird_admin", message } });
|
|
4123
4478
|
var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4124
4479
|
var parseEndpoint = (value) => {
|
|
@@ -4226,7 +4581,6 @@ var AT_HEADER = "x-mockingbird-at";
|
|
|
4226
4581
|
var CHECKPOINT_HEADER = "x-mockingbird-checkpoint";
|
|
4227
4582
|
var DEFAULT_NAMESPACE = "default";
|
|
4228
4583
|
var NAMESPACE_PATTERN = /^[A-Za-z0-9_.-]{1,64}$/;
|
|
4229
|
-
var PATH_PREFIX = /^\/ns\/([^/]+)(\/.*)?$/;
|
|
4230
4584
|
var BRANCH_PATTERN2 = /^[A-Za-z0-9_.-]{1,64}$/;
|
|
4231
4585
|
var MUTATING_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
4232
4586
|
var effects = /* @__PURE__ */ new WeakMap();
|
|
@@ -4267,6 +4621,22 @@ var operationMatcher = (document3) => {
|
|
|
4267
4621
|
return (request, path) => matchers.find((m) => m.method === request.method && m.pattern.test(path))?.operationId;
|
|
4268
4622
|
};
|
|
4269
4623
|
var createRuntime = (options) => {
|
|
4624
|
+
const adminPrefix = resolveAdminPrefix(options.adminPrefix);
|
|
4625
|
+
const internalPaths = Object.entries(options.document?.paths ?? {}).filter(([, item]) => item["x-mockingbird-internal"] === true).map(([path]) => path);
|
|
4626
|
+
for (const path of internalPaths) {
|
|
4627
|
+
if (!path.startsWith(`${ADMIN_PREFIX}/blobs/`))
|
|
4628
|
+
throw new Error(`internal transport ${path} must live under ${ADMIN_PREFIX}/blobs/`);
|
|
4629
|
+
}
|
|
4630
|
+
assertAdminPrefixAvailable(adminPrefix, Object.keys(options.document?.paths ?? {}).filter((path) => !internalPaths.includes(path)));
|
|
4631
|
+
const internalMatch = (path) => {
|
|
4632
|
+
for (const pattern of internalPaths) {
|
|
4633
|
+
const actual = path.split("/");
|
|
4634
|
+
const expected = pattern.split("/");
|
|
4635
|
+
if (actual.length === expected.length && expected.every((part, i) => part.startsWith("{") || part === actual[i]))
|
|
4636
|
+
return pattern;
|
|
4637
|
+
}
|
|
4638
|
+
return void 0;
|
|
4639
|
+
};
|
|
4270
4640
|
assertAdminUi(options.adminUi);
|
|
4271
4641
|
const sqlite = bootSqlite(options.sqlite);
|
|
4272
4642
|
const clock = options.clock ?? createClock();
|
|
@@ -4312,6 +4682,7 @@ var createRuntime = (options) => {
|
|
|
4312
4682
|
const created = options.create({
|
|
4313
4683
|
namespace: storageNamespace(key),
|
|
4314
4684
|
publicNamespace,
|
|
4685
|
+
adminPrefix,
|
|
4315
4686
|
sqlite,
|
|
4316
4687
|
clock: namespaceClock(publicNamespace),
|
|
4317
4688
|
rng: createdContextRng
|
|
@@ -4544,10 +4915,10 @@ var createRuntime = (options) => {
|
|
|
4544
4915
|
namespaceClock,
|
|
4545
4916
|
namespaceOf(request) {
|
|
4546
4917
|
const url = new URL(request.url);
|
|
4547
|
-
const prefixed =
|
|
4918
|
+
const prefixed = matchNamespacePath(url.pathname, adminPrefix);
|
|
4548
4919
|
const selected = request.headers.get(NAMESPACE_HEADER) ?? (prefixed ? decodeURIComponent(prefixed[1]) : void 0);
|
|
4549
4920
|
const path = prefixed ? prefixed[2] ?? "/" : url.pathname;
|
|
4550
|
-
if (path
|
|
4921
|
+
if (isAdminPath(path, adminPrefix))
|
|
4551
4922
|
return url.searchParams.get("namespace") ?? selected ?? DEFAULT_NAMESPACE;
|
|
4552
4923
|
if (selected !== void 0)
|
|
4553
4924
|
return selected;
|
|
@@ -4613,7 +4984,7 @@ var createRuntime = (options) => {
|
|
|
4613
4984
|
state: (namespace = DEFAULT_NAMESPACE) => inspectState(stateScope(namespace)),
|
|
4614
4985
|
fetch: async (incoming) => {
|
|
4615
4986
|
let request = incoming;
|
|
4616
|
-
const prefixed =
|
|
4987
|
+
const prefixed = matchNamespacePath(new URL(request.url).pathname, adminPrefix);
|
|
4617
4988
|
if (prefixed) {
|
|
4618
4989
|
const url2 = new URL(request.url);
|
|
4619
4990
|
url2.pathname = prefixed[2] ?? "/";
|
|
@@ -4629,7 +5000,15 @@ var createRuntime = (options) => {
|
|
|
4629
5000
|
signal: request.signal
|
|
4630
5001
|
});
|
|
4631
5002
|
}
|
|
4632
|
-
|
|
5003
|
+
const internalUrl = new URL(request.url);
|
|
5004
|
+
const internalPath = isAdminPath(internalUrl.pathname, adminPrefix) ? `${ADMIN_PREFIX}${internalUrl.pathname.slice(adminPrefix.length)}` : "";
|
|
5005
|
+
const internal = internalMatch(internalPath);
|
|
5006
|
+
const obsoleteInternalPath = adminPrefix !== ADMIN_PREFIX && internalMatch(internalUrl.pathname) && !internal;
|
|
5007
|
+
if (internal) {
|
|
5008
|
+
internalUrl.pathname = internalPath;
|
|
5009
|
+
request = new Request(internalUrl, request);
|
|
5010
|
+
}
|
|
5011
|
+
let namespace = internal ? internalUrl.searchParams.get("namespace") ?? control.namespaceOf(request) : control.namespaceOf(request);
|
|
4633
5012
|
if (!request.headers.has(NAMESPACE_HEADER) && options.credential) {
|
|
4634
5013
|
const credential = options.credential(request);
|
|
4635
5014
|
const mapped = credential !== void 0 ? credentials.get(credential) : void 0;
|
|
@@ -4649,7 +5028,9 @@ var createRuntime = (options) => {
|
|
|
4649
5028
|
return copy;
|
|
4650
5029
|
}
|
|
4651
5030
|
};
|
|
4652
|
-
|
|
5031
|
+
if (obsoleteInternalPath)
|
|
5032
|
+
return stamp(adminFail(404, "internal transport is only available under adminPrefix"));
|
|
5033
|
+
const handled = internal ? void 0 : await control.handle(request);
|
|
4653
5034
|
if (handled)
|
|
4654
5035
|
return stamp(handled);
|
|
4655
5036
|
const started = monotonicNow();
|
|
@@ -4690,7 +5071,7 @@ var createRuntime = (options) => {
|
|
|
4690
5071
|
type: "mockingbird_admin",
|
|
4691
5072
|
message: `${NAMESPACE_HEADER} must match ${NAMESPACE_PATTERN}`
|
|
4692
5073
|
}
|
|
4693
|
-
}), { status: 400, headers: { "content-type": "application/json" } }));
|
|
5074
|
+
}), { status: 400, headers: { "content-type": "application/json; charset=utf-8" } }));
|
|
4694
5075
|
}
|
|
4695
5076
|
if (!BRANCH_PATTERN2.test(selectedBranch)) {
|
|
4696
5077
|
log(400);
|
|
@@ -4807,15 +5188,16 @@ var createRuntime = (options) => {
|
|
|
4807
5188
|
...options.admin?.(runtime) ?? {},
|
|
4808
5189
|
// Shell routes win a colliding key. Fault presets are one of them: the admin page
|
|
4809
5190
|
// maps `presets`, and a service route must not replace that list with a record.
|
|
4810
|
-
...options.presets ? presetRoutes(options.presets, runtime) : {},
|
|
5191
|
+
...options.presets ? presetRoutes(options.presets, runtime, adminPrefix) : {},
|
|
4811
5192
|
...stateAdminRoutes({
|
|
4812
5193
|
open: stateScope,
|
|
4813
5194
|
afterWrite: (namespace) => {
|
|
4814
5195
|
checkpoint(namespace, "main");
|
|
4815
5196
|
}
|
|
4816
5197
|
}),
|
|
4817
|
-
...adminUiRoutes(options.name, options.adminUi)
|
|
5198
|
+
...adminUiRoutes(options.name, options.adminUi, adminPrefix)
|
|
4818
5199
|
},
|
|
5200
|
+
adminPrefix,
|
|
4819
5201
|
adminKey: options.adminKey
|
|
4820
5202
|
});
|
|
4821
5203
|
return defineMock(runtime);
|
|
@@ -4829,7 +5211,10 @@ var mutableResponse = (response) => {
|
|
|
4829
5211
|
return new Response(response.body, response);
|
|
4830
5212
|
}
|
|
4831
5213
|
};
|
|
4832
|
-
var adminJson = (status, body) => new Response(JSON.stringify(body), {
|
|
5214
|
+
var adminJson = (status, body) => new Response(JSON.stringify(body), {
|
|
5215
|
+
status,
|
|
5216
|
+
headers: { "content-type": "application/json; charset=utf-8" }
|
|
5217
|
+
});
|
|
4833
5218
|
var adminFail = (status, message) => adminJson(status, { error: { type: "mockingbird_admin", message } });
|
|
4834
5219
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4835
5220
|
var credentialRoutes = (registry) => ({
|
|
@@ -4881,7 +5266,7 @@ var credentialRoutes = (registry) => ({
|
|
|
4881
5266
|
return adminJson(200, { status: "ok" });
|
|
4882
5267
|
}
|
|
4883
5268
|
});
|
|
4884
|
-
var presetRoutes = (presets, runtime) => ({
|
|
5269
|
+
var presetRoutes = (presets, runtime, adminPrefix) => ({
|
|
4885
5270
|
"GET /faults/presets": () => {
|
|
4886
5271
|
const body = {
|
|
4887
5272
|
presets: Object.entries(presets).map(([name, preset]) => ({ name, ...preset }))
|
|
@@ -4891,7 +5276,7 @@ var presetRoutes = (presets, runtime) => ({
|
|
|
4891
5276
|
"POST /faults/presets/:name": ({ params, body, namespace }) => {
|
|
4892
5277
|
const name = params.name;
|
|
4893
5278
|
if (!presets[name])
|
|
4894
|
-
return adminFail(404, `no fault preset ${name}; GET /
|
|
5279
|
+
return adminFail(404, `no fault preset ${name}; GET ${adminPrefix}/faults/presets`);
|
|
4895
5280
|
const overrides = isObject(body) ? body : {};
|
|
4896
5281
|
return adminJson(201, { preset: name, rules: runtime.applyPreset(name, namespace, overrides) });
|
|
4897
5282
|
}
|
|
@@ -5204,6 +5589,7 @@ var createRuntime2 = (options = {}) => {
|
|
|
5204
5589
|
...options.sqlite ? { sqlite: options.sqlite } : {},
|
|
5205
5590
|
...options.clock ? { clock: options.clock } : {},
|
|
5206
5591
|
...options.seed !== void 0 ? { seed: options.seed } : {},
|
|
5592
|
+
...options.adminPrefix !== void 0 ? { adminPrefix: options.adminPrefix } : {},
|
|
5207
5593
|
...options.adminKey !== void 0 ? { adminKey: options.adminKey } : {},
|
|
5208
5594
|
...options.onLog ? { onLog: options.onLog } : {},
|
|
5209
5595
|
credential: basicUsername,
|
|
@@ -5507,6 +5893,7 @@ var WholescriptsAPI = class {
|
|
|
5507
5893
|
|
|
5508
5894
|
export {
|
|
5509
5895
|
createClock,
|
|
5896
|
+
resolveAdminPrefix,
|
|
5510
5897
|
parseDuration,
|
|
5511
5898
|
MEDPAX_BOX_SKU,
|
|
5512
5899
|
DEFAULT_CATALOG,
|
|
@@ -5520,4 +5907,4 @@ export {
|
|
|
5520
5907
|
canonicalStatus,
|
|
5521
5908
|
WholescriptsAPI
|
|
5522
5909
|
};
|
|
5523
|
-
//# sourceMappingURL=chunk-
|
|
5910
|
+
//# sourceMappingURL=chunk-6JAPA3JS.js.map
|