@crvouga/mockingbird-service-bedrock 1.7.1 → 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 +37 -0
- package/DISCOVERY.md +55 -0
- package/README.md +1 -1
- package/SUPPORT.md +16 -0
- package/dist/{chunk-PEDTFUZC.js → chunk-6QLFWEJJ.js} +4 -3
- package/dist/{chunk-PEDTFUZC.js.map → chunk-6QLFWEJJ.js.map} +2 -2
- package/dist/{chunk-KWJYXFIF.js → chunk-LYWMNREM.js} +784 -258
- package/dist/chunk-LYWMNREM.js.map +7 -0
- package/dist/cli.js +529 -37
- package/dist/cli.js.map +4 -4
- package/dist/index.d.ts +35 -5
- package/dist/index.js +1 -1
- package/dist/server.d.ts +65 -5
- package/dist/server.js +2 -2
- package/openapi.yaml +786 -0
- package/package.json +29 -4
- package/dist/chunk-KWJYXFIF.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()
|
|
@@ -183,29 +215,30 @@ var createControlPlane = (context) => {
|
|
|
183
215
|
return json(200, { status: "ok", reset: target === "*" ? context.namespaces() : [target] });
|
|
184
216
|
},
|
|
185
217
|
"GET /namespaces": () => json(200, { default: context.defaultNamespace, namespaces: context.namespaces() }),
|
|
186
|
-
"GET /clock": () => json(200, context.clock.state()),
|
|
187
|
-
"POST /clock": ({ body }) => {
|
|
218
|
+
"GET /clock": ({ namespace }) => json(200, (context.namespaceClock?.(namespace) ?? context.clock).state()),
|
|
219
|
+
"POST /clock": ({ body, namespace }) => {
|
|
220
|
+
const clock = context.namespaceClock?.(namespace) ?? context.clock;
|
|
188
221
|
if (!isRecord(body))
|
|
189
222
|
return adminError(400, "expected a JSON object");
|
|
190
223
|
if (body.reset === true)
|
|
191
|
-
|
|
224
|
+
clock.reset();
|
|
192
225
|
if (body.freeze === true)
|
|
193
|
-
|
|
226
|
+
clock.freeze();
|
|
194
227
|
if (body.set !== void 0) {
|
|
195
228
|
const instant = parseInstant(body.set);
|
|
196
229
|
if (instant === void 0)
|
|
197
230
|
return adminError(400, "set: expected epoch ms or ISO-8601");
|
|
198
|
-
|
|
231
|
+
clock.set(instant);
|
|
199
232
|
}
|
|
200
233
|
if (body.advance !== void 0) {
|
|
201
234
|
const delta = parseDuration(body.advance);
|
|
202
235
|
if (delta === void 0)
|
|
203
236
|
return adminError(400, 'advance: expected ms or "15m"-style');
|
|
204
|
-
|
|
237
|
+
clock.advance(delta);
|
|
205
238
|
}
|
|
206
239
|
if (body.freeze === false)
|
|
207
|
-
|
|
208
|
-
return json(200,
|
|
240
|
+
clock.unfreeze();
|
|
241
|
+
return json(200, clock.state());
|
|
209
242
|
},
|
|
210
243
|
"GET /faults": () => json(200, { faults: context.faults.list() }),
|
|
211
244
|
"POST /faults": ({ body, namespace }) => {
|
|
@@ -338,7 +371,14 @@ var createControlPlane = (context) => {
|
|
|
338
371
|
return json(200, { status: "ok" });
|
|
339
372
|
}
|
|
340
373
|
};
|
|
341
|
-
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]) => {
|
|
342
382
|
const space = key.indexOf(" ");
|
|
343
383
|
return { method: key.slice(0, space), pattern: key.slice(space + 1), handler };
|
|
344
384
|
});
|
|
@@ -346,21 +386,13 @@ var createControlPlane = (context) => {
|
|
|
346
386
|
namespaceOf: headerNamespace,
|
|
347
387
|
async handle(request) {
|
|
348
388
|
const url = new URL(request.url);
|
|
349
|
-
if (url.pathname ===
|
|
350
|
-
return
|
|
351
|
-
status: "ok",
|
|
352
|
-
service: context.name,
|
|
353
|
-
uptimeMs: context.wallNow() - context.startedAt,
|
|
354
|
-
clock: context.clock.state(),
|
|
355
|
-
namespaces: context.namespaces().length,
|
|
356
|
-
adminUi: `${ADMIN_PREFIX}/ui`,
|
|
357
|
-
...context.describe()
|
|
358
|
-
});
|
|
389
|
+
if (url.pathname === `${adminPrefix}/health` && request.method === "GET") {
|
|
390
|
+
return health();
|
|
359
391
|
}
|
|
360
|
-
if (url.pathname
|
|
392
|
+
if (!isAdminPath(url.pathname, adminPrefix)) {
|
|
361
393
|
return void 0;
|
|
362
394
|
}
|
|
363
|
-
const path = url.pathname.slice(
|
|
395
|
+
const path = url.pathname.slice(adminPrefix.length) || "/";
|
|
364
396
|
const shell = request.method === "GET" && (path === "/ui" || path === "/ui/");
|
|
365
397
|
if (!shell && context.adminKey !== void 0 && request.headers.get(ADMIN_KEY_HEADER) !== context.adminKey) {
|
|
366
398
|
return adminError(401, `missing or wrong ${ADMIN_KEY_HEADER}`);
|
|
@@ -368,7 +400,12 @@ var createControlPlane = (context) => {
|
|
|
368
400
|
for (const route of routes) {
|
|
369
401
|
if (route.method !== request.method)
|
|
370
402
|
continue;
|
|
371
|
-
|
|
403
|
+
let params;
|
|
404
|
+
try {
|
|
405
|
+
params = matchRoute(route.pattern, path);
|
|
406
|
+
} catch {
|
|
407
|
+
return adminError(400, "invalid path encoding");
|
|
408
|
+
}
|
|
372
409
|
if (!params)
|
|
373
410
|
continue;
|
|
374
411
|
let body;
|
|
@@ -377,15 +414,18 @@ var createControlPlane = (context) => {
|
|
|
377
414
|
} catch {
|
|
378
415
|
return adminError(400, "request body is not valid JSON");
|
|
379
416
|
}
|
|
417
|
+
const namespace = adminNamespace(request, url);
|
|
418
|
+
if (!/^[A-Za-z0-9_.-]{1,64}$/.test(namespace))
|
|
419
|
+
return adminError(400, "invalid namespace");
|
|
380
420
|
return route.handler({
|
|
381
421
|
request,
|
|
382
422
|
url,
|
|
383
423
|
params,
|
|
384
|
-
namespace
|
|
424
|
+
namespace,
|
|
385
425
|
body
|
|
386
426
|
});
|
|
387
427
|
}
|
|
388
|
-
return adminError(404, `no admin route ${request.method} ${path}; GET ${
|
|
428
|
+
return adminError(404, `no admin route ${request.method} ${path}; GET ${adminPrefix} lists them`);
|
|
389
429
|
}
|
|
390
430
|
};
|
|
391
431
|
};
|
|
@@ -475,7 +515,33 @@ var faultResponse = (rule) => {
|
|
|
475
515
|
};
|
|
476
516
|
var createFaultRegistry = (rng = createRng(0), sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))) => {
|
|
477
517
|
const entries = [];
|
|
518
|
+
let isolated = false;
|
|
519
|
+
const scopedRngs = /* @__PURE__ */ new Map();
|
|
520
|
+
const random = (namespace) => {
|
|
521
|
+
if (!isolated || namespace === "default")
|
|
522
|
+
return rng;
|
|
523
|
+
let scoped = scopedRngs.get(namespace);
|
|
524
|
+
if (!scoped) {
|
|
525
|
+
scoped = createRng(rng.seed);
|
|
526
|
+
scopedRngs.set(namespace, scoped);
|
|
527
|
+
}
|
|
528
|
+
return scoped;
|
|
529
|
+
};
|
|
478
530
|
return {
|
|
531
|
+
isolateNamespaces() {
|
|
532
|
+
isolated = true;
|
|
533
|
+
},
|
|
534
|
+
snapshot(namespace) {
|
|
535
|
+
return {
|
|
536
|
+
rules: structuredClone(entries.map((entry, position) => ({
|
|
537
|
+
...entry.rule,
|
|
538
|
+
remaining: entry.remaining,
|
|
539
|
+
hits: entry.hits,
|
|
540
|
+
position
|
|
541
|
+
})).filter((entry) => entry.namespace === namespace)),
|
|
542
|
+
rngState: random(namespace).state()
|
|
543
|
+
};
|
|
544
|
+
},
|
|
479
545
|
add(rule) {
|
|
480
546
|
const existing = entries.findIndex((e) => e.rule.id === rule.id);
|
|
481
547
|
const entry = { rule, remaining: rule.count ?? null, hits: 0 };
|
|
@@ -495,6 +561,16 @@ var createFaultRegistry = (rng = createRng(0), sleep = (ms) => new Promise((reso
|
|
|
495
561
|
},
|
|
496
562
|
clear() {
|
|
497
563
|
entries.length = 0;
|
|
564
|
+
rng.reset();
|
|
565
|
+
scopedRngs.clear();
|
|
566
|
+
},
|
|
567
|
+
restore(namespace, state) {
|
|
568
|
+
for (let i = entries.length - 1; i >= 0; i--)
|
|
569
|
+
if (entries[i]?.rule.namespace === namespace)
|
|
570
|
+
entries.splice(i, 1);
|
|
571
|
+
for (const { remaining, hits, position, ...rule } of state.rules)
|
|
572
|
+
entries.splice(Math.min(position, entries.length), 0, { rule, remaining, hits });
|
|
573
|
+
random(namespace).setState(state.rngState);
|
|
498
574
|
},
|
|
499
575
|
async take(candidate) {
|
|
500
576
|
const hits = [];
|
|
@@ -504,7 +580,7 @@ var createFaultRegistry = (rng = createRng(0), sleep = (ms) => new Promise((reso
|
|
|
504
580
|
if (!matches(entry.rule, candidate))
|
|
505
581
|
continue;
|
|
506
582
|
const rate = entry.rule.rate ?? 1;
|
|
507
|
-
if (
|
|
583
|
+
if (random(candidate.namespace).next() >= rate)
|
|
508
584
|
continue;
|
|
509
585
|
entry.hits++;
|
|
510
586
|
if (entry.remaining !== null)
|
|
@@ -1072,7 +1148,8 @@ var annotateResponse = (response, extra) => {
|
|
|
1072
1148
|
var responseNotes = (response) => notes.get(response);
|
|
1073
1149
|
|
|
1074
1150
|
// ../core/dist/metrics.js
|
|
1075
|
-
var createMetrics = () => {
|
|
1151
|
+
var createMetrics = (partition = true) => {
|
|
1152
|
+
const namespaces = /* @__PURE__ */ new Map();
|
|
1076
1153
|
let requests = 0;
|
|
1077
1154
|
let faults = 0;
|
|
1078
1155
|
let totalDurationMs = 0;
|
|
@@ -1080,6 +1157,14 @@ var createMetrics = () => {
|
|
|
1080
1157
|
const unmatched = /* @__PURE__ */ new Map();
|
|
1081
1158
|
return {
|
|
1082
1159
|
record(entry) {
|
|
1160
|
+
if (partition) {
|
|
1161
|
+
let scoped = namespaces.get(entry.namespace);
|
|
1162
|
+
if (!scoped) {
|
|
1163
|
+
scoped = createMetrics(false);
|
|
1164
|
+
namespaces.set(entry.namespace, scoped);
|
|
1165
|
+
}
|
|
1166
|
+
scoped.record(entry);
|
|
1167
|
+
}
|
|
1083
1168
|
requests++;
|
|
1084
1169
|
totalDurationMs += entry.durationMs;
|
|
1085
1170
|
if (entry.faultId !== void 0)
|
|
@@ -1091,7 +1176,7 @@ var createMetrics = () => {
|
|
|
1091
1176
|
unmatched.set(route, (unmatched.get(route) ?? 0) + 1);
|
|
1092
1177
|
}
|
|
1093
1178
|
},
|
|
1094
|
-
report: () => ({
|
|
1179
|
+
report: (namespace) => namespace !== void 0 ? (namespaces.get(namespace) ?? createMetrics(false)).report() : {
|
|
1095
1180
|
requests,
|
|
1096
1181
|
byOperation: Object.fromEntries([...byOperation].sort(([a], [b]) => a.localeCompare(b))),
|
|
1097
1182
|
unmatched: [...unmatched].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([route, count]) => {
|
|
@@ -1100,8 +1185,13 @@ var createMetrics = () => {
|
|
|
1100
1185
|
}),
|
|
1101
1186
|
faults,
|
|
1102
1187
|
totalDurationMs
|
|
1103
|
-
}
|
|
1104
|
-
reset() {
|
|
1188
|
+
},
|
|
1189
|
+
reset(namespace) {
|
|
1190
|
+
if (namespace !== void 0) {
|
|
1191
|
+
namespaces.delete(namespace);
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
namespaces.clear();
|
|
1105
1195
|
requests = 0;
|
|
1106
1196
|
faults = 0;
|
|
1107
1197
|
totalDurationMs = 0;
|
|
@@ -1714,6 +1804,34 @@ dialog:not([open]) {
|
|
|
1714
1804
|
function isRecord2(value) {
|
|
1715
1805
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1716
1806
|
}
|
|
1807
|
+
function highlightJsonText(text2) {
|
|
1808
|
+
const escapeToken = (value) => value.replace(/[&<>"']/g, (char) => {
|
|
1809
|
+
switch (char) {
|
|
1810
|
+
case "&":
|
|
1811
|
+
return "&";
|
|
1812
|
+
case "<":
|
|
1813
|
+
return "<";
|
|
1814
|
+
case ">":
|
|
1815
|
+
return ">";
|
|
1816
|
+
case '"':
|
|
1817
|
+
return """;
|
|
1818
|
+
default:
|
|
1819
|
+
return "'";
|
|
1820
|
+
}
|
|
1821
|
+
});
|
|
1822
|
+
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;
|
|
1823
|
+
let cursor = 0;
|
|
1824
|
+
let html = "";
|
|
1825
|
+
for (const match of text2.matchAll(token)) {
|
|
1826
|
+
const index = match.index ?? 0;
|
|
1827
|
+
const value = match[0];
|
|
1828
|
+
html += escapeToken(text2.slice(cursor, index));
|
|
1829
|
+
const kind = value.startsWith('"') ? value.trimEnd().endsWith(":") ? "key" : "string" : value === "true" || value === "false" ? "boolean" : value === "null" ? "null" : "number";
|
|
1830
|
+
html += `<span class="json-${kind}">${escapeToken(value)}</span>`;
|
|
1831
|
+
cursor = index + value.length;
|
|
1832
|
+
}
|
|
1833
|
+
return html + escapeToken(text2.slice(cursor));
|
|
1834
|
+
}
|
|
1717
1835
|
function mountAdminBrand(doc, host, service, catalog) {
|
|
1718
1836
|
const clip = (value, max) => {
|
|
1719
1837
|
if (typeof value !== "string")
|
|
@@ -2075,14 +2193,16 @@ function bootAdmin(config) {
|
|
|
2075
2193
|
const state = {
|
|
2076
2194
|
namespace: "default",
|
|
2077
2195
|
key: sessionStorage.getItem("mockingbird-admin-key") || "",
|
|
2078
|
-
view: "overview",
|
|
2196
|
+
view: ["overview", "state", "clock", "faults", "journal", "routes"].includes(location.hash.slice(1)) ? location.hash.slice(1) : "overview",
|
|
2079
2197
|
collection: "",
|
|
2080
2198
|
shape: null,
|
|
2081
2199
|
route: null,
|
|
2200
|
+
routes: [],
|
|
2082
2201
|
editing: null
|
|
2083
2202
|
};
|
|
2084
2203
|
const standard = new Set(config.standardRoutes);
|
|
2085
2204
|
const banner = el("banner", HTMLElement);
|
|
2205
|
+
const bannerMessage = el("banner-message", HTMLElement);
|
|
2086
2206
|
const keyInput = el("admin-key", HTMLInputElement);
|
|
2087
2207
|
keyInput.value = state.key;
|
|
2088
2208
|
const params = new URLSearchParams(location.search);
|
|
@@ -2093,18 +2213,21 @@ function bootAdmin(config) {
|
|
|
2093
2213
|
sessionStorage.setItem("mockingbird-admin-key", state.key);
|
|
2094
2214
|
params.delete("key");
|
|
2095
2215
|
const next = params.toString();
|
|
2096
|
-
history.replaceState(null, "", location.pathname + (next ? `?${next}` : ""));
|
|
2216
|
+
history.replaceState(null, "", location.pathname + (next ? `?${next}` : "") + location.hash);
|
|
2097
2217
|
}
|
|
2098
2218
|
const queryNamespace = params.get("namespace");
|
|
2099
2219
|
if (queryNamespace)
|
|
2100
2220
|
state.namespace = queryNamespace;
|
|
2101
2221
|
const showError = (error) => {
|
|
2102
|
-
|
|
2222
|
+
bannerMessage.textContent = error instanceof Error ? error.message : String(error);
|
|
2103
2223
|
banner.classList.add("show");
|
|
2224
|
+
banner.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
2104
2225
|
};
|
|
2105
2226
|
const clearError = () => {
|
|
2106
2227
|
banner.classList.remove("show");
|
|
2228
|
+
bannerMessage.textContent = "";
|
|
2107
2229
|
};
|
|
2230
|
+
el("banner-dismiss", HTMLButtonElement).addEventListener("click", clearError);
|
|
2108
2231
|
const api = async (method, path, body) => {
|
|
2109
2232
|
const headers = { accept: "application/json" };
|
|
2110
2233
|
if (state.key !== "")
|
|
@@ -2148,16 +2271,21 @@ function bootAdmin(config) {
|
|
|
2148
2271
|
namespace: () => state.namespace
|
|
2149
2272
|
};
|
|
2150
2273
|
const isPanelScript = (value) => typeof value === "function";
|
|
2274
|
+
const themeButton = el("theme", HTMLButtonElement);
|
|
2151
2275
|
const setTheme = (theme) => {
|
|
2152
2276
|
if (theme)
|
|
2153
2277
|
document.documentElement.dataset.theme = theme;
|
|
2154
2278
|
else
|
|
2155
2279
|
delete document.documentElement.dataset.theme;
|
|
2280
|
+
const dark = theme ? theme === "dark" : matchMedia("(prefers-color-scheme: dark)").matches;
|
|
2281
|
+
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>';
|
|
2282
|
+
const label = dark ? "Use light theme" : "Use dark theme";
|
|
2283
|
+
themeButton.setAttribute("aria-label", label);
|
|
2284
|
+
themeButton.title = label;
|
|
2156
2285
|
};
|
|
2157
2286
|
const storedTheme = localStorage.getItem("mockingbird-admin-theme");
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
el("theme", HTMLButtonElement).addEventListener("click", () => {
|
|
2287
|
+
setTheme(storedTheme === "dark" || storedTheme === "light" ? storedTheme : null);
|
|
2288
|
+
themeButton.addEventListener("click", () => {
|
|
2161
2289
|
const current = document.documentElement.dataset.theme;
|
|
2162
2290
|
const dark = current ? current === "dark" : matchMedia("(prefers-color-scheme: dark)").matches;
|
|
2163
2291
|
const next = dark ? "light" : "dark";
|
|
@@ -2176,6 +2304,7 @@ function bootAdmin(config) {
|
|
|
2176
2304
|
continue;
|
|
2177
2305
|
section.hidden = section.id !== `view-${view}`;
|
|
2178
2306
|
}
|
|
2307
|
+
history.replaceState(null, "", `${location.pathname}${location.search}#${encodeURIComponent(view)}`);
|
|
2179
2308
|
};
|
|
2180
2309
|
el("nav", HTMLElement).addEventListener("click", (event) => {
|
|
2181
2310
|
const target = event.target;
|
|
@@ -2190,7 +2319,7 @@ function bootAdmin(config) {
|
|
|
2190
2319
|
show(view);
|
|
2191
2320
|
refresh().catch(showError);
|
|
2192
2321
|
});
|
|
2193
|
-
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>`;
|
|
2322
|
+
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>`;
|
|
2194
2323
|
const table = (columns, rows) => {
|
|
2195
2324
|
if (rows.length === 0)
|
|
2196
2325
|
return '<p class="empty">Nothing here yet.</p>';
|
|
@@ -2200,16 +2329,22 @@ function bootAdmin(config) {
|
|
|
2200
2329
|
const attrs = "attrs" in row && typeof row.attrs === "string" ? row.attrs : "";
|
|
2201
2330
|
return `<tr${attrs}>${cells}</tr>`;
|
|
2202
2331
|
}).join("");
|
|
2203
|
-
return `<table><thead>${head}</thead><tbody>${body}</tbody></table>`;
|
|
2332
|
+
return `<div class="table-shell"><table><thead>${head}</thead><tbody>${body}</tbody></table></div>`;
|
|
2204
2333
|
};
|
|
2205
2334
|
const preview = (value) => {
|
|
2206
2335
|
const text2 = JSON.stringify(value) ?? "null";
|
|
2207
|
-
|
|
2336
|
+
const clipped = text2.length > 180 ? `${text2.slice(0, 180)}\u2026` : text2;
|
|
2337
|
+
return `<code class="json-inline">${highlightJsonText(clipped)}</code>`;
|
|
2208
2338
|
};
|
|
2209
2339
|
const when = (epoch) => {
|
|
2210
2340
|
const date = new Date(epoch);
|
|
2211
2341
|
return Number.isNaN(date.getTime()) ? String(epoch) : date.toISOString();
|
|
2212
2342
|
};
|
|
2343
|
+
const journalWhen = (value) => {
|
|
2344
|
+
const numeric = value.trim() === "" ? Number.NaN : Number(value);
|
|
2345
|
+
const epoch = Number.isFinite(numeric) ? numeric : Date.parse(value);
|
|
2346
|
+
return Number.isFinite(epoch) ? when(epoch) : value;
|
|
2347
|
+
};
|
|
2213
2348
|
const clockCard = (epoch) => {
|
|
2214
2349
|
const date = new Date(epoch);
|
|
2215
2350
|
if (Number.isNaN(date.getTime()))
|
|
@@ -2329,7 +2464,7 @@ function bootAdmin(config) {
|
|
|
2329
2464
|
};
|
|
2330
2465
|
const renderOverview = async () => {
|
|
2331
2466
|
const [health, shape, clock, journal] = await Promise.all([
|
|
2332
|
-
originGet(
|
|
2467
|
+
originGet(`${config.adminPrefix}/health`),
|
|
2333
2468
|
api("GET", "/state"),
|
|
2334
2469
|
api("GET", "/clock"),
|
|
2335
2470
|
api("GET", "/requests?limit=8")
|
|
@@ -2346,7 +2481,7 @@ function bootAdmin(config) {
|
|
|
2346
2481
|
},
|
|
2347
2482
|
{
|
|
2348
2483
|
k: "Status",
|
|
2349
|
-
v: esc(typeof health.status === "string" && health.status !== "" ? health.status : "ok")
|
|
2484
|
+
v: `<span class="badge ok">${esc(typeof health.status === "string" && health.status !== "" ? health.status : "ok")}</span>`
|
|
2350
2485
|
},
|
|
2351
2486
|
{ k: "Namespace", v: esc(state.namespace) },
|
|
2352
2487
|
{ k: "Collections", v: String(decoded.collections.length) },
|
|
@@ -2433,26 +2568,46 @@ function bootAdmin(config) {
|
|
|
2433
2568
|
const renderJournal = async () => {
|
|
2434
2569
|
const journal = await api("GET", "/requests?limit=100");
|
|
2435
2570
|
el("journal", HTMLElement).innerHTML = table([
|
|
2436
|
-
{ label: "When", cell: (row) => esc(row.at) },
|
|
2437
|
-
{
|
|
2571
|
+
{ label: "When", cell: (row) => esc(journalWhen(row.at)) },
|
|
2572
|
+
{
|
|
2573
|
+
label: "Method",
|
|
2574
|
+
cell: (row) => `<span class="method">${esc(row.method)}</span>`
|
|
2575
|
+
},
|
|
2438
2576
|
{ label: "Path", cell: (row) => esc(row.path) },
|
|
2439
|
-
{
|
|
2577
|
+
{
|
|
2578
|
+
label: "Status",
|
|
2579
|
+
cell: (row) => `<span class="badge ${row.status.startsWith("2") ? "ok" : row.status.startsWith("4") || row.status.startsWith("5") ? "warn" : ""}">${esc(row.status)}</span>`
|
|
2580
|
+
},
|
|
2440
2581
|
{ label: "ms", cell: (row) => esc(row.durationMs) }
|
|
2441
2582
|
], decodeJournal(journal));
|
|
2442
2583
|
};
|
|
2443
|
-
const
|
|
2444
|
-
const
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2584
|
+
const paintRoutes = () => {
|
|
2585
|
+
const query = el("route-search", HTMLInputElement).value.trim().toLocaleLowerCase();
|
|
2586
|
+
const routes = state.routes.filter((route) => route.toLocaleLowerCase().includes(query));
|
|
2587
|
+
el("route-count", HTMLElement).textContent = `${routes.length} of ${state.routes.length}`;
|
|
2588
|
+
if (state.routes.length === 0) {
|
|
2589
|
+
el("route-list", HTMLElement).innerHTML = '<p class="empty">No admin routes are available.</p>';
|
|
2590
|
+
return;
|
|
2591
|
+
}
|
|
2592
|
+
if (routes.length === 0) {
|
|
2593
|
+
el("route-list", HTMLElement).innerHTML = '<p class="empty">No routes match this filter.</p>';
|
|
2594
|
+
return;
|
|
2595
|
+
}
|
|
2448
2596
|
el("route-list", HTMLElement).innerHTML = routes.map((route) => {
|
|
2449
2597
|
const extra = standard.has(route) ? "" : " <span class='badge'>extension</span>";
|
|
2450
2598
|
const parts = route.split(" ");
|
|
2451
2599
|
const method = parts[0] ?? "";
|
|
2452
2600
|
const path = parts.slice(1).join(" ");
|
|
2453
|
-
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>`;
|
|
2601
|
+
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>`;
|
|
2454
2602
|
}).join("");
|
|
2455
2603
|
};
|
|
2604
|
+
const renderRoutes = async () => {
|
|
2605
|
+
const data = await api("GET", "/");
|
|
2606
|
+
if (!isRecord2(data))
|
|
2607
|
+
throw new Error("Route list was not an object");
|
|
2608
|
+
state.routes = requireList(data.routes, "Routes").map((route) => String(route));
|
|
2609
|
+
paintRoutes();
|
|
2610
|
+
};
|
|
2456
2611
|
const renderers = {
|
|
2457
2612
|
overview: renderOverview,
|
|
2458
2613
|
state: renderState,
|
|
@@ -2461,19 +2616,50 @@ function bootAdmin(config) {
|
|
|
2461
2616
|
journal: renderJournal,
|
|
2462
2617
|
routes: renderRoutes
|
|
2463
2618
|
};
|
|
2619
|
+
let refreshToken = 0;
|
|
2464
2620
|
async function refresh() {
|
|
2621
|
+
const token = ++refreshToken;
|
|
2465
2622
|
clearError();
|
|
2623
|
+
const main = el("views", HTMLElement);
|
|
2624
|
+
const sync = el("sync-status", HTMLElement);
|
|
2625
|
+
main.setAttribute("aria-busy", "true");
|
|
2626
|
+
sync.classList.add("busy");
|
|
2627
|
+
sync.textContent = "Updating";
|
|
2466
2628
|
const render = renderers[state.view];
|
|
2467
|
-
|
|
2468
|
-
|
|
2629
|
+
try {
|
|
2630
|
+
if (render)
|
|
2631
|
+
await render();
|
|
2632
|
+
if (token === refreshToken)
|
|
2633
|
+
sync.textContent = "Up to date";
|
|
2634
|
+
} finally {
|
|
2635
|
+
if (token === refreshToken) {
|
|
2636
|
+
main.removeAttribute("aria-busy");
|
|
2637
|
+
sync.classList.remove("busy");
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2469
2640
|
}
|
|
2470
2641
|
const delay = (ms) => new Promise((resolve) => {
|
|
2471
2642
|
window.setTimeout(resolve, ms);
|
|
2472
2643
|
});
|
|
2473
|
-
const confirmAction = async (button, pending, done, work) => {
|
|
2644
|
+
const confirmAction = async (button, pending, done, work, confirmLabel) => {
|
|
2474
2645
|
if (button.dataset.pending === "1")
|
|
2475
2646
|
return;
|
|
2476
2647
|
const label = button.textContent ?? "";
|
|
2648
|
+
if (confirmLabel !== void 0 && button.dataset.confirming !== "1") {
|
|
2649
|
+
button.dataset.confirming = "1";
|
|
2650
|
+
button.classList.add("confirming");
|
|
2651
|
+
button.textContent = confirmLabel;
|
|
2652
|
+
window.setTimeout(() => {
|
|
2653
|
+
if (button.dataset.confirming !== "1")
|
|
2654
|
+
return;
|
|
2655
|
+
button.textContent = label;
|
|
2656
|
+
button.classList.remove("confirming");
|
|
2657
|
+
delete button.dataset.confirming;
|
|
2658
|
+
}, 3e3);
|
|
2659
|
+
return;
|
|
2660
|
+
}
|
|
2661
|
+
button.classList.remove("confirming");
|
|
2662
|
+
delete button.dataset.confirming;
|
|
2477
2663
|
const width = button.offsetWidth;
|
|
2478
2664
|
button.dataset.pending = "1";
|
|
2479
2665
|
button.classList.add("pressed");
|
|
@@ -2494,6 +2680,65 @@ function bootAdmin(config) {
|
|
|
2494
2680
|
delete button.dataset.pending;
|
|
2495
2681
|
}
|
|
2496
2682
|
};
|
|
2683
|
+
const wireJsonEditor = (textareaId, highlightId, statusId, shellId, allowEmpty) => {
|
|
2684
|
+
const textarea = el(textareaId, HTMLTextAreaElement);
|
|
2685
|
+
const highlight = el(highlightId, HTMLElement);
|
|
2686
|
+
const status = el(statusId, HTMLElement);
|
|
2687
|
+
const shell = el(shellId, HTMLElement);
|
|
2688
|
+
const sync = () => {
|
|
2689
|
+
const text2 = textarea.value;
|
|
2690
|
+
highlight.innerHTML = `${highlightJsonText(text2)}
|
|
2691
|
+
`;
|
|
2692
|
+
let valid = true;
|
|
2693
|
+
let message = "Valid JSON";
|
|
2694
|
+
if (allowEmpty && text2.trim() === "")
|
|
2695
|
+
message = "No body";
|
|
2696
|
+
else {
|
|
2697
|
+
try {
|
|
2698
|
+
readJson2(text2);
|
|
2699
|
+
} catch {
|
|
2700
|
+
valid = false;
|
|
2701
|
+
message = "Invalid JSON";
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
shell.classList.toggle("invalid", !valid);
|
|
2705
|
+
status.classList.toggle("invalid", !valid);
|
|
2706
|
+
status.textContent = message;
|
|
2707
|
+
textarea.setAttribute("aria-invalid", valid ? "false" : "true");
|
|
2708
|
+
};
|
|
2709
|
+
const syncScroll = () => {
|
|
2710
|
+
const preview2 = highlight.parentElement;
|
|
2711
|
+
if (!(preview2 instanceof HTMLElement))
|
|
2712
|
+
return;
|
|
2713
|
+
preview2.scrollTop = textarea.scrollTop;
|
|
2714
|
+
preview2.scrollLeft = textarea.scrollLeft;
|
|
2715
|
+
};
|
|
2716
|
+
textarea.addEventListener("input", sync);
|
|
2717
|
+
textarea.addEventListener("scroll", syncScroll);
|
|
2718
|
+
sync();
|
|
2719
|
+
return sync;
|
|
2720
|
+
};
|
|
2721
|
+
const syncRouteEditor = wireJsonEditor("route-body", "route-highlight", "route-json-status", "route-editor", true);
|
|
2722
|
+
const syncRecordEditor = wireJsonEditor("editor-value", "editor-highlight", "editor-json-status", "record-editor", false);
|
|
2723
|
+
for (const button of document.querySelectorAll("[data-format]")) {
|
|
2724
|
+
if (!(button instanceof HTMLButtonElement))
|
|
2725
|
+
continue;
|
|
2726
|
+
button.addEventListener("click", () => {
|
|
2727
|
+
const target = button.dataset.format;
|
|
2728
|
+
if (target === void 0)
|
|
2729
|
+
return;
|
|
2730
|
+
const textarea = document.getElementById(target);
|
|
2731
|
+
if (!(textarea instanceof HTMLTextAreaElement) || textarea.value.trim() === "")
|
|
2732
|
+
return;
|
|
2733
|
+
try {
|
|
2734
|
+
textarea.value = JSON.stringify(readJson2(textarea.value), null, 2) ?? "";
|
|
2735
|
+
textarea.dispatchEvent(new Event("input"));
|
|
2736
|
+
textarea.focus();
|
|
2737
|
+
} catch {
|
|
2738
|
+
showError(new Error("Fix the JSON before formatting it"));
|
|
2739
|
+
}
|
|
2740
|
+
});
|
|
2741
|
+
}
|
|
2497
2742
|
document.addEventListener("click", (event) => {
|
|
2498
2743
|
const target = event.target;
|
|
2499
2744
|
if (!(target instanceof Element))
|
|
@@ -2566,6 +2811,7 @@ function bootAdmin(config) {
|
|
|
2566
2811
|
} else {
|
|
2567
2812
|
editorValue.value = "{\n \n}";
|
|
2568
2813
|
}
|
|
2814
|
+
syncRecordEditor();
|
|
2569
2815
|
editor.showModal();
|
|
2570
2816
|
}
|
|
2571
2817
|
el("new-record", HTMLButtonElement).addEventListener("click", () => {
|
|
@@ -2595,10 +2841,10 @@ function bootAdmin(config) {
|
|
|
2595
2841
|
const id = state.editing;
|
|
2596
2842
|
if (!id)
|
|
2597
2843
|
return;
|
|
2598
|
-
api("DELETE", `/state/${encodeURIComponent(state.collection)}/${encodeURIComponent(id)}`).then(() => {
|
|
2844
|
+
confirmAction(editorDelete, "Deleting...", "Deleted", () => api("DELETE", `/state/${encodeURIComponent(state.collection)}/${encodeURIComponent(id)}`).then(() => {
|
|
2599
2845
|
editor.close();
|
|
2600
2846
|
return renderState();
|
|
2601
|
-
}).catch(showError);
|
|
2847
|
+
}), "Confirm delete").catch(showError);
|
|
2602
2848
|
});
|
|
2603
2849
|
for (const button of document.querySelectorAll("[data-advance]")) {
|
|
2604
2850
|
if (!(button instanceof HTMLButtonElement))
|
|
@@ -2644,10 +2890,10 @@ function bootAdmin(config) {
|
|
|
2644
2890
|
}).then(() => renderFaults()).catch(showError);
|
|
2645
2891
|
});
|
|
2646
2892
|
el("fault-clear", HTMLButtonElement).addEventListener("click", () => {
|
|
2647
|
-
confirmAction(el("fault-clear", HTMLButtonElement), "Clearing...", "Cleared", () => api("DELETE", "/faults").then(() => renderFaults())).catch(showError);
|
|
2893
|
+
confirmAction(el("fault-clear", HTMLButtonElement), "Clearing...", "Cleared", () => api("DELETE", "/faults").then(() => renderFaults()), "Confirm clear").catch(showError);
|
|
2648
2894
|
});
|
|
2649
2895
|
el("journal-clear", HTMLButtonElement).addEventListener("click", () => {
|
|
2650
|
-
confirmAction(el("journal-clear", HTMLButtonElement), "Clearing...", "Cleared", () => api("DELETE", "/requests").then(() => renderJournal())).catch(showError);
|
|
2896
|
+
confirmAction(el("journal-clear", HTMLButtonElement), "Clearing...", "Cleared", () => api("DELETE", "/requests").then(() => renderJournal()), "Confirm clear").catch(showError);
|
|
2651
2897
|
});
|
|
2652
2898
|
el("route-list", HTMLElement).addEventListener("click", (event) => {
|
|
2653
2899
|
const target = event.target;
|
|
@@ -2661,9 +2907,15 @@ function bootAdmin(config) {
|
|
|
2661
2907
|
return;
|
|
2662
2908
|
state.route = route;
|
|
2663
2909
|
el("route-title", HTMLElement).textContent = route;
|
|
2910
|
+
el("route-send", HTMLButtonElement).disabled = false;
|
|
2664
2911
|
const method = route.split(" ")[0] ?? "";
|
|
2665
|
-
el("route-body", HTMLTextAreaElement)
|
|
2912
|
+
const routeBody = el("route-body", HTMLTextAreaElement);
|
|
2913
|
+
routeBody.disabled = method === "GET" || method === "DELETE";
|
|
2914
|
+
el("route-editor", HTMLElement).hidden = routeBody.disabled;
|
|
2915
|
+
el("route-json-status", HTMLElement).parentElement?.toggleAttribute("hidden", routeBody.disabled);
|
|
2916
|
+
syncRouteEditor();
|
|
2666
2917
|
});
|
|
2918
|
+
el("route-search", HTMLInputElement).addEventListener("input", paintRoutes);
|
|
2667
2919
|
el("route-form", HTMLFormElement).addEventListener("submit", (event) => {
|
|
2668
2920
|
event.preventDefault();
|
|
2669
2921
|
const send = async () => {
|
|
@@ -2685,7 +2937,8 @@ function bootAdmin(config) {
|
|
|
2685
2937
|
}
|
|
2686
2938
|
}
|
|
2687
2939
|
const data = await api(method, concrete, body);
|
|
2688
|
-
|
|
2940
|
+
const text2 = JSON.stringify(data, null, 2) ?? "null";
|
|
2941
|
+
el("route-result", HTMLElement).innerHTML = `<code>${highlightJsonText(text2)}</code>`;
|
|
2689
2942
|
};
|
|
2690
2943
|
send().catch(showError);
|
|
2691
2944
|
});
|
|
@@ -2803,11 +3056,13 @@ function bootAdmin(config) {
|
|
|
2803
3056
|
views.append(section);
|
|
2804
3057
|
mountSqlExplorer(body, panelApi);
|
|
2805
3058
|
}
|
|
3059
|
+
show(document.getElementById(`view-${state.view}`) === null ? "overview" : state.view);
|
|
2806
3060
|
return refresh();
|
|
2807
3061
|
}).catch(showError);
|
|
2808
3062
|
}
|
|
2809
3063
|
var clientPrelude = [
|
|
2810
3064
|
isRecord2,
|
|
3065
|
+
highlightJsonText,
|
|
2811
3066
|
mountAdminBrand,
|
|
2812
3067
|
startAdminBrand,
|
|
2813
3068
|
faultPresetList,
|
|
@@ -2830,6 +3085,7 @@ ${entry}(${payload});
|
|
|
2830
3085
|
var defineMock = (runtime) => runtime;
|
|
2831
3086
|
var STANDARD_ADMIN_ROUTES = [
|
|
2832
3087
|
"GET /",
|
|
3088
|
+
"GET /health",
|
|
2833
3089
|
"POST /reset",
|
|
2834
3090
|
"GET /namespaces",
|
|
2835
3091
|
"GET /clock",
|
|
@@ -2909,11 +3165,11 @@ var escapeHtml = (value) => value.replace(/[&<>"']/g, (char) => {
|
|
|
2909
3165
|
}
|
|
2910
3166
|
});
|
|
2911
3167
|
var ADMIN_BRANDS_URL = "https://mockingbird.chrisvouga.dev/brands.json";
|
|
2912
|
-
var renderAdminDocument = (service) => {
|
|
3168
|
+
var renderAdminDocument = (service, adminPrefix = ADMIN_PREFIX) => {
|
|
2913
3169
|
const name = escapeHtml(service);
|
|
2914
3170
|
const script = adminClientSource({
|
|
2915
3171
|
standardRoutes: STANDARD_ADMIN_ROUTES,
|
|
2916
|
-
adminPrefix
|
|
3172
|
+
adminPrefix,
|
|
2917
3173
|
adminKeyHeader: ADMIN_KEY_HEADER,
|
|
2918
3174
|
brandsUrl: ADMIN_BRANDS_URL,
|
|
2919
3175
|
service
|
|
@@ -2930,75 +3186,99 @@ var renderAdminDocument = (service) => {
|
|
|
2930
3186
|
${CSS_RESET}
|
|
2931
3187
|
:root {
|
|
2932
3188
|
color-scheme: light;
|
|
2933
|
-
--bg: #
|
|
3189
|
+
--bg: #f7f8fb;
|
|
2934
3190
|
--bg-elev: #ffffff;
|
|
2935
|
-
--bg-muted: #
|
|
2936
|
-
--bg-inset: #
|
|
2937
|
-
--line: #
|
|
2938
|
-
--line-strong: #
|
|
2939
|
-
--ink: #
|
|
2940
|
-
--muted: #
|
|
2941
|
-
--faint: #
|
|
2942
|
-
--accent: #
|
|
3191
|
+
--bg-muted: #f1f3f7;
|
|
3192
|
+
--bg-inset: #f8f9fc;
|
|
3193
|
+
--line: #e4e7ec;
|
|
3194
|
+
--line-strong: #cfd4dc;
|
|
3195
|
+
--ink: #101828;
|
|
3196
|
+
--muted: #475467;
|
|
3197
|
+
--faint: #667085;
|
|
3198
|
+
--accent: #6941c6;
|
|
3199
|
+
--accent-hover: #5933b4;
|
|
2943
3200
|
--accent-ink: #ffffff;
|
|
2944
|
-
--accent-soft: #
|
|
2945
|
-
--ok: #
|
|
2946
|
-
--ok-soft: #
|
|
2947
|
-
--warn: #
|
|
2948
|
-
--warn-soft: #
|
|
2949
|
-
--err: #
|
|
2950
|
-
--err-soft: #
|
|
2951
|
-
--
|
|
3201
|
+
--accent-soft: #f4f0ff;
|
|
3202
|
+
--ok: #067647;
|
|
3203
|
+
--ok-soft: #ecfdf3;
|
|
3204
|
+
--warn: #b54708;
|
|
3205
|
+
--warn-soft: #fffaeb;
|
|
3206
|
+
--err: #b42318;
|
|
3207
|
+
--err-soft: #fef3f2;
|
|
3208
|
+
--code-key: #6941c6;
|
|
3209
|
+
--code-string: #067647;
|
|
3210
|
+
--code-number: #175cd3;
|
|
3211
|
+
--code-boolean: #c11574;
|
|
3212
|
+
--code-null: #667085;
|
|
3213
|
+
--shadow-xs: 0 1px 2px rgb(16 24 40 / 0.05);
|
|
3214
|
+
--shadow-sm: 0 1px 3px rgb(16 24 40 / 0.08), 0 1px 2px rgb(16 24 40 / 0.04);
|
|
3215
|
+
--shadow-lg: 0 18px 48px rgb(16 24 40 / 0.16), 0 4px 12px rgb(16 24 40 / 0.08);
|
|
2952
3216
|
--sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
2953
3217
|
--mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
|
|
2954
|
-
--radius:
|
|
2955
|
-
--header:
|
|
2956
|
-
--nav:
|
|
3218
|
+
--radius: 12px;
|
|
3219
|
+
--header: 72px;
|
|
3220
|
+
--nav: 224px;
|
|
2957
3221
|
}
|
|
2958
3222
|
:root[data-theme="dark"] {
|
|
2959
3223
|
color-scheme: dark;
|
|
2960
|
-
--bg: #
|
|
2961
|
-
--bg-elev: #
|
|
2962
|
-
--bg-muted: #
|
|
2963
|
-
--bg-inset: #
|
|
2964
|
-
--line: #
|
|
2965
|
-
--line-strong: #
|
|
2966
|
-
--ink: #
|
|
2967
|
-
--muted: #
|
|
2968
|
-
--faint: #
|
|
2969
|
-
--accent: #
|
|
2970
|
-
--accent-
|
|
2971
|
-
--accent-
|
|
2972
|
-
--
|
|
2973
|
-
--ok
|
|
2974
|
-
--
|
|
2975
|
-
--warn
|
|
2976
|
-
--
|
|
2977
|
-
--err
|
|
2978
|
-
--
|
|
3224
|
+
--bg: #0c0e14;
|
|
3225
|
+
--bg-elev: #151821;
|
|
3226
|
+
--bg-muted: #20232e;
|
|
3227
|
+
--bg-inset: #11141c;
|
|
3228
|
+
--line: #2b303d;
|
|
3229
|
+
--line-strong: #414858;
|
|
3230
|
+
--ink: #f5f7fa;
|
|
3231
|
+
--muted: #b6bdc9;
|
|
3232
|
+
--faint: #8d96a7;
|
|
3233
|
+
--accent: #9e77ed;
|
|
3234
|
+
--accent-hover: #b692f6;
|
|
3235
|
+
--accent-ink: #ffffff;
|
|
3236
|
+
--accent-soft: #2b2142;
|
|
3237
|
+
--ok: #75e0a7;
|
|
3238
|
+
--ok-soft: #102a20;
|
|
3239
|
+
--warn: #fec84b;
|
|
3240
|
+
--warn-soft: #302611;
|
|
3241
|
+
--err: #fda29b;
|
|
3242
|
+
--err-soft: #321817;
|
|
3243
|
+
--code-key: #c3a6ff;
|
|
3244
|
+
--code-string: #75e0a7;
|
|
3245
|
+
--code-number: #84adff;
|
|
3246
|
+
--code-boolean: #f9a8d4;
|
|
3247
|
+
--code-null: #98a2b3;
|
|
3248
|
+
--shadow-xs: 0 1px 2px rgb(0 0 0 / 0.24);
|
|
3249
|
+
--shadow-sm: 0 4px 12px rgb(0 0 0 / 0.2);
|
|
3250
|
+
--shadow-lg: 0 20px 56px rgb(0 0 0 / 0.45);
|
|
2979
3251
|
}
|
|
2980
3252
|
@media (prefers-color-scheme: dark) {
|
|
2981
3253
|
:root:not([data-theme="light"]) {
|
|
2982
3254
|
color-scheme: dark;
|
|
2983
|
-
--bg: #
|
|
2984
|
-
--bg-elev: #
|
|
2985
|
-
--bg-muted: #
|
|
2986
|
-
--bg-inset: #
|
|
2987
|
-
--line: #
|
|
2988
|
-
--line-strong: #
|
|
2989
|
-
--ink: #
|
|
2990
|
-
--muted: #
|
|
2991
|
-
--faint: #
|
|
2992
|
-
--accent: #
|
|
2993
|
-
--accent-
|
|
2994
|
-
--accent-
|
|
2995
|
-
--
|
|
2996
|
-
--ok
|
|
2997
|
-
--
|
|
2998
|
-
--warn
|
|
2999
|
-
--
|
|
3000
|
-
--err
|
|
3001
|
-
--
|
|
3255
|
+
--bg: #0c0e14;
|
|
3256
|
+
--bg-elev: #151821;
|
|
3257
|
+
--bg-muted: #20232e;
|
|
3258
|
+
--bg-inset: #11141c;
|
|
3259
|
+
--line: #2b303d;
|
|
3260
|
+
--line-strong: #414858;
|
|
3261
|
+
--ink: #f5f7fa;
|
|
3262
|
+
--muted: #b6bdc9;
|
|
3263
|
+
--faint: #8d96a7;
|
|
3264
|
+
--accent: #9e77ed;
|
|
3265
|
+
--accent-hover: #b692f6;
|
|
3266
|
+
--accent-ink: #ffffff;
|
|
3267
|
+
--accent-soft: #2b2142;
|
|
3268
|
+
--ok: #75e0a7;
|
|
3269
|
+
--ok-soft: #102a20;
|
|
3270
|
+
--warn: #fec84b;
|
|
3271
|
+
--warn-soft: #302611;
|
|
3272
|
+
--err: #fda29b;
|
|
3273
|
+
--err-soft: #321817;
|
|
3274
|
+
--code-key: #c3a6ff;
|
|
3275
|
+
--code-string: #75e0a7;
|
|
3276
|
+
--code-number: #84adff;
|
|
3277
|
+
--code-boolean: #f9a8d4;
|
|
3278
|
+
--code-null: #98a2b3;
|
|
3279
|
+
--shadow-xs: 0 1px 2px rgb(0 0 0 / 0.24);
|
|
3280
|
+
--shadow-sm: 0 4px 12px rgb(0 0 0 / 0.2);
|
|
3281
|
+
--shadow-lg: 0 20px 56px rgb(0 0 0 / 0.45);
|
|
3002
3282
|
}
|
|
3003
3283
|
}
|
|
3004
3284
|
/* Fill the viewport, then grow with the content so the background covers the scroll. */
|
|
@@ -3016,13 +3296,17 @@ var renderAdminDocument = (service) => {
|
|
|
3016
3296
|
padding-right: env(safe-area-inset-right);
|
|
3017
3297
|
-webkit-text-size-adjust: 100%;
|
|
3018
3298
|
}
|
|
3019
|
-
|
|
3299
|
+
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
|
|
3300
|
+
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
|
|
3301
|
+
button, input, select, textarea { transition: border-color 140ms ease, box-shadow 140ms ease, transform 100ms ease; }
|
|
3302
|
+
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: 0.55; }
|
|
3020
3303
|
.app { flex: 1 0 auto; display: flex; flex-direction: column; min-width: 0; width: 100%; }
|
|
3021
3304
|
header.top {
|
|
3022
|
-
position: sticky; top: 0; z-index:
|
|
3305
|
+
position: sticky; top: 0; z-index: 20;
|
|
3023
3306
|
display: flex; align-items: center; gap: 12px;
|
|
3024
|
-
min-height: var(--header); padding:
|
|
3025
|
-
background: var(--bg-elev);
|
|
3307
|
+
min-height: var(--header); padding: 12px 20px;
|
|
3308
|
+
background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
|
|
3309
|
+
backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
|
|
3026
3310
|
border-bottom: 1px solid var(--line);
|
|
3027
3311
|
min-width: 0; max-width: 100%;
|
|
3028
3312
|
}
|
|
@@ -3030,12 +3314,21 @@ var renderAdminDocument = (service) => {
|
|
|
3030
3314
|
display: flex; flex-flow: row wrap; align-items: center; gap: 14px;
|
|
3031
3315
|
min-width: 0; max-width: 100%; margin-right: auto;
|
|
3032
3316
|
}
|
|
3033
|
-
.brand-
|
|
3034
|
-
.brand-
|
|
3317
|
+
.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
|
|
3318
|
+
.brand-mark {
|
|
3319
|
+
width: 38px; height: 38px; display: grid; place-items: center; flex: none;
|
|
3320
|
+
border-radius: 11px; color: #fff;
|
|
3321
|
+
background: linear-gradient(145deg, #7f56d9 0%, #53389e 100%);
|
|
3322
|
+
box-shadow: 0 6px 16px rgb(105 65 198 / 0.24), inset 0 1px 0 rgb(255 255 255 / 0.25);
|
|
3323
|
+
}
|
|
3324
|
+
.brand-mark svg { width: 22px; height: 22px; }
|
|
3325
|
+
.brand-id { display: flex; flex-direction: column; min-width: 0; flex: none; line-height: 1.25; }
|
|
3326
|
+
.brand-id strong { font-size: 15px; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
3035
3327
|
.brand-id span { color: var(--faint); font-size: 12px; }
|
|
3036
3328
|
.vendor {
|
|
3037
3329
|
display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
|
|
3038
3330
|
min-width: 0; max-width: 100%; font-size: 12px; color: var(--muted);
|
|
3331
|
+
padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-inset);
|
|
3039
3332
|
}
|
|
3040
3333
|
.vendor[hidden] { display: none; }
|
|
3041
3334
|
/* Logos are drawn for a light tile, same as the docs site, so the plate stays white. */
|
|
@@ -3047,12 +3340,17 @@ var renderAdminDocument = (service) => {
|
|
|
3047
3340
|
.vendor-sep { color: var(--faint); }
|
|
3048
3341
|
.vendor-link { color: inherit; text-decoration: none; }
|
|
3049
3342
|
.vendor-link:hover { color: var(--ink); text-decoration: underline; }
|
|
3050
|
-
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items:
|
|
3051
|
-
|
|
3343
|
+
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
|
|
3344
|
+
.sync-status { align-self: center; display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 12px; white-space: nowrap; }
|
|
3345
|
+
.sync-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
|
|
3346
|
+
.sync-status.busy::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 1.2s ease-in-out infinite; }
|
|
3347
|
+
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 600; color: var(--faint); }
|
|
3052
3348
|
label.field input, label.field select, .controls input[type="password"] {
|
|
3053
|
-
background-color: var(--bg-
|
|
3054
|
-
padding:
|
|
3349
|
+
background-color: var(--bg-elev); border: 1px solid var(--line-strong); border-radius: 9px;
|
|
3350
|
+
padding: 8px 10px; min-height: 38px; line-height: 1.2; box-shadow: var(--shadow-xs);
|
|
3055
3351
|
}
|
|
3352
|
+
label.field input:hover, label.field select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 38%, var(--line-strong)); }
|
|
3353
|
+
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; }
|
|
3056
3354
|
/* A native menu ignores min-height, so Preset rendered about half as tall as
|
|
3057
3355
|
the text fields in the same form. Paint it like those fields. */
|
|
3058
3356
|
label.field select {
|
|
@@ -3069,12 +3367,20 @@ var renderAdminDocument = (service) => {
|
|
|
3069
3367
|
dialog .field > textarea { width: 100%; }
|
|
3070
3368
|
.icon-btn, .btn, .btn-primary, .btn-quiet, .btn-danger, nav.side button { cursor: pointer; }
|
|
3071
3369
|
.icon-btn, .btn, .btn-primary, .btn-quiet, .btn-danger {
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
.btn
|
|
3370
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 7px;
|
|
3371
|
+
border-radius: 9px; min-height: 38px; padding: 0 13px; border: 1px solid var(--line-strong);
|
|
3372
|
+
background: var(--bg-elev); color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1;
|
|
3373
|
+
box-shadow: var(--shadow-xs);
|
|
3374
|
+
}
|
|
3375
|
+
.icon-btn { width: 38px; padding: 0; }
|
|
3376
|
+
.icon-btn svg, .btn svg, .btn-primary svg { width: 16px; height: 16px; }
|
|
3377
|
+
.icon-btn:hover, .btn:hover { background: var(--bg-muted); border-color: var(--line-strong); }
|
|
3378
|
+
.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; }
|
|
3379
|
+
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
|
|
3380
|
+
.btn-quiet { background: transparent; border-color: transparent; box-shadow: none; }
|
|
3381
|
+
.btn-quiet:hover { background: var(--bg-muted); }
|
|
3382
|
+
.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, var(--line)); }
|
|
3383
|
+
.btn-danger:hover, .btn-danger.confirming { background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 45%, var(--line)); }
|
|
3078
3384
|
/* Held after mouseup. Clearing an empty journal changes nothing on screen,
|
|
3079
3385
|
so the press itself has to stay visible. */
|
|
3080
3386
|
.icon-btn:active, .btn:active, .btn-quiet:active, .btn-danger:active, nav.side button:active,
|
|
@@ -3090,93 +3396,159 @@ var renderAdminDocument = (service) => {
|
|
|
3090
3396
|
flex: 1 0 auto; min-width: 0;
|
|
3091
3397
|
}
|
|
3092
3398
|
nav.side {
|
|
3093
|
-
|
|
3399
|
+
position: sticky; top: var(--header); align-self: start; height: calc(100vh - var(--header));
|
|
3400
|
+
border-right: 1px solid var(--line); padding: 18px 12px;
|
|
3094
3401
|
display: flex; flex-direction: column; gap: 4px;
|
|
3095
|
-
background: var(--bg-elev);
|
|
3402
|
+
background: var(--bg-elev); overflow-y: auto;
|
|
3096
3403
|
}
|
|
3404
|
+
.nav-label { padding: 0 10px 8px; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }
|
|
3097
3405
|
nav.side button {
|
|
3406
|
+
position: relative; display: flex; align-items: center; gap: 10px; width: 100%;
|
|
3098
3407
|
text-align: left; border: 0; background: transparent; border-radius: 9px;
|
|
3099
|
-
padding: 9px 10px; min-height:
|
|
3100
|
-
}
|
|
3101
|
-
nav.side button
|
|
3102
|
-
|
|
3103
|
-
.
|
|
3104
|
-
.
|
|
3105
|
-
.
|
|
3408
|
+
padding: 9px 10px; min-height: 42px; color: var(--muted); font-size: 13px; font-weight: 550;
|
|
3409
|
+
}
|
|
3410
|
+
nav.side button:hover { background: var(--bg-muted); color: var(--ink); }
|
|
3411
|
+
nav.side button[aria-current="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
|
|
3412
|
+
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); }
|
|
3413
|
+
.nav-icon { width: 18px; height: 18px; display: grid; place-items: center; flex: none; }
|
|
3414
|
+
.nav-icon svg { width: 18px; height: 18px; }
|
|
3415
|
+
main { padding: 32px clamp(20px, 4vw, 48px) 64px; max-width: 1320px; width: 100%; min-width: 0; }
|
|
3416
|
+
main[aria-busy="true"] .view { opacity: 0.62; }
|
|
3417
|
+
.view { animation: view-in 180ms ease-out; }
|
|
3418
|
+
.view[hidden] { display: none; }
|
|
3419
|
+
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
|
|
3420
|
+
.view h2 { margin: 0 0 5px; font-size: clamp(24px, 3vw, 30px); line-height: 1.2; letter-spacing: -0.035em; }
|
|
3421
|
+
.view h3 { margin: 24px 0 10px; font-size: 15px; letter-spacing: -0.01em; }
|
|
3422
|
+
.lede { margin: 0; color: var(--muted); max-width: 72ch; font-size: 14px; }
|
|
3423
|
+
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 175px), 1fr)); gap: 14px; }
|
|
3106
3424
|
.card {
|
|
3107
3425
|
background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
|
|
3108
|
-
padding:
|
|
3426
|
+
padding: 18px; box-shadow: var(--shadow-sm);
|
|
3109
3427
|
}
|
|
3110
|
-
.card
|
|
3111
|
-
.card
|
|
3428
|
+
.stat-card { position: relative; overflow: hidden; }
|
|
3429
|
+
.stat-card::after { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: linear-gradient(90deg, var(--accent), transparent 78%); opacity: 0.7; }
|
|
3430
|
+
.card .k { color: var(--faint); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; }
|
|
3431
|
+
.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; }
|
|
3112
3432
|
.card .v .clock-time { font-size: 14px; color: var(--muted); }
|
|
3113
|
-
.
|
|
3433
|
+
.section-card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-xs); overflow: hidden; }
|
|
3434
|
+
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
|
|
3435
|
+
.section-title h3 { margin: 0; }
|
|
3436
|
+
.split { display: grid; grid-template-columns: minmax(0, 250px) minmax(0, 1fr); gap: 18px; align-items: start; }
|
|
3437
|
+
#collections { padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); box-shadow: var(--shadow-xs); }
|
|
3114
3438
|
.collection {
|
|
3115
3439
|
width: 100%; text-align: left; border: 1px solid transparent; background: transparent;
|
|
3116
|
-
border-radius:
|
|
3440
|
+
border-radius: 9px; padding: 10px 11px; min-height: 48px; color: var(--ink); cursor: pointer;
|
|
3117
3441
|
}
|
|
3118
|
-
.collection
|
|
3442
|
+
.collection:hover { background: var(--bg-muted); }
|
|
3443
|
+
.collection[aria-current="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 18%, var(--line)); color: var(--accent); }
|
|
3119
3444
|
.collection small { display: block; color: var(--faint); }
|
|
3120
3445
|
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
|
|
3121
|
-
.chip {
|
|
3122
|
-
font-family: var(--mono); font-size: 12px; background: var(--bg-muted);
|
|
3123
|
-
border-radius: 999px; padding: 4px 8px;
|
|
3124
|
-
}
|
|
3446
|
+
.chip { font-family: var(--mono); font-size: 11px; background: var(--bg-muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px; }
|
|
3125
3447
|
.chip i { color: var(--faint); font-style: normal; }
|
|
3126
3448
|
.sql-layout {
|
|
3127
3449
|
display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 16px;
|
|
3128
3450
|
}
|
|
3129
|
-
.sql-tables { display: flex; flex-direction: column; gap: 4px; max-height: 28rem; overflow: auto; }
|
|
3130
|
-
.sql-tables button { text-align: left; }
|
|
3451
|
+
.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); }
|
|
3452
|
+
.sql-tables button { text-align: left; border: 0; border-radius: 8px; padding: 9px 10px; background: transparent; color: var(--muted); cursor: pointer; }
|
|
3453
|
+
.sql-tables button:hover, .sql-tables button[aria-current="true"] { background: var(--accent-soft); color: var(--accent); }
|
|
3131
3454
|
.sql-input { font-family: var(--mono); min-height: 7rem; width: 100%; }
|
|
3132
|
-
table { width: 100%; border-
|
|
3133
|
-
|
|
3134
|
-
th {
|
|
3455
|
+
.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); }
|
|
3456
|
+
table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
3457
|
+
th, td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); vertical-align: top; }
|
|
3458
|
+
th { color: var(--faint); background: var(--bg-inset); font-weight: 650; font-size: 11px; text-transform: uppercase; letter-spacing: 0.045em; }
|
|
3459
|
+
tbody tr:last-child td { border-bottom: 0; }
|
|
3135
3460
|
tr.clickable { cursor: pointer; }
|
|
3136
|
-
tr.clickable:hover { background: var(--
|
|
3461
|
+
tr.clickable:hover { background: var(--accent-soft); }
|
|
3137
3462
|
pre, code, .mono { font-family: var(--mono); overflow-wrap: anywhere; }
|
|
3138
3463
|
pre {
|
|
3139
3464
|
margin: 0; white-space: pre-wrap; word-break: break-word;
|
|
3140
|
-
background: var(--bg-inset); border-radius: 10px; padding:
|
|
3141
|
-
}
|
|
3142
|
-
.
|
|
3465
|
+
background: var(--bg-inset); border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-size: 12px; line-height: 1.65;
|
|
3466
|
+
}
|
|
3467
|
+
.json-key { color: var(--code-key); }
|
|
3468
|
+
.json-string { color: var(--code-string); }
|
|
3469
|
+
.json-number { color: var(--code-number); }
|
|
3470
|
+
.json-boolean { color: var(--code-boolean); }
|
|
3471
|
+
.json-null { color: var(--code-null); font-style: italic; }
|
|
3472
|
+
.json-inline { display: block; max-width: 44rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
|
3473
|
+
.json-view { position: relative; max-height: 26rem; overflow: auto; }
|
|
3474
|
+
.json-editor { position: relative; min-height: 190px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg-inset); overflow: hidden; }
|
|
3475
|
+
.json-editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
|
|
3476
|
+
.json-editor.invalid { border-color: var(--err); }
|
|
3477
|
+
.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; }
|
|
3478
|
+
.json-editor pre { position: absolute; inset: 0; pointer-events: none; background: transparent; }
|
|
3479
|
+
.json-editor textarea { position: relative; z-index: 1; resize: vertical; background: transparent; color: transparent; caret-color: var(--ink); -webkit-text-fill-color: transparent; }
|
|
3480
|
+
.json-editor textarea::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); }
|
|
3481
|
+
.editor-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 7px; }
|
|
3482
|
+
.json-status { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-size: 11px; }
|
|
3483
|
+
.json-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
|
|
3484
|
+
.json-status.invalid { color: var(--err); }
|
|
3485
|
+
.format-json { border: 0; padding: 3px 5px; background: transparent; color: var(--accent); font-size: 11px; font-weight: 650; cursor: pointer; }
|
|
3486
|
+
.row-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin: 14px 0; }
|
|
3143
3487
|
.banner {
|
|
3144
|
-
display: none;
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3488
|
+
display: none; position: sticky; top: calc(var(--header) + 12px); z-index: 15;
|
|
3489
|
+
align-items: center; gap: 10px; margin: 0 0 16px; padding: 11px 12px 11px 14px;
|
|
3490
|
+
border: 1px solid color-mix(in srgb, var(--err) 30%, var(--line)); border-radius: 10px;
|
|
3491
|
+
background: var(--err-soft); color: var(--err); box-shadow: var(--shadow-sm); font-size: 13px;
|
|
3492
|
+
}
|
|
3493
|
+
.banner.show { display: flex; }
|
|
3494
|
+
.banner span { flex: 1; }
|
|
3495
|
+
.banner button { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: currentColor; cursor: pointer; }
|
|
3496
|
+
.banner button:hover { background: color-mix(in srgb, var(--err) 10%, transparent); }
|
|
3497
|
+
.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); }
|
|
3149
3498
|
dialog {
|
|
3150
|
-
border: 1px solid var(--line); border-radius:
|
|
3151
|
-
color: var(--ink); width: min(
|
|
3152
|
-
}
|
|
3153
|
-
dialog
|
|
3154
|
-
dialog
|
|
3499
|
+
border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--bg-elev);
|
|
3500
|
+
color: var(--ink); width: min(720px, calc(100% - 24px)); max-width: calc(100vw - 24px); box-shadow: var(--shadow-lg);
|
|
3501
|
+
}
|
|
3502
|
+
dialog[open] { animation: dialog-in 160ms ease-out; }
|
|
3503
|
+
dialog::backdrop { background: rgb(12 14 20 / 0.58); backdrop-filter: blur(3px); }
|
|
3504
|
+
dialog form, .dialog-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
|
|
3505
|
+
.dialog-heading { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
|
|
3506
|
+
.dialog-heading strong { font-size: 18px; letter-spacing: -0.02em; }
|
|
3507
|
+
.dialog-heading span { color: var(--muted); font-size: 12px; }
|
|
3155
3508
|
textarea {
|
|
3156
3509
|
width: 100%; min-height: 180px; resize: vertical; border-radius: 10px;
|
|
3157
3510
|
border: 1px solid var(--line); background: var(--bg-inset); padding: 10px;
|
|
3158
3511
|
font-family: var(--mono); font-size: 12px;
|
|
3159
3512
|
}
|
|
3160
|
-
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
3161
|
-
.
|
|
3513
|
+
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding-top: 4px; }
|
|
3514
|
+
.dialog-actions .btn-danger { margin-right: auto; }
|
|
3515
|
+
.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); }
|
|
3162
3516
|
.badge.ok { background: var(--ok-soft); color: var(--ok); }
|
|
3163
3517
|
.badge.warn { background: var(--warn-soft); color: var(--warn); }
|
|
3164
3518
|
.status-2 { color: var(--ok); }
|
|
3165
3519
|
.status-4, .status-5, .status-0 { color: var(--err); }
|
|
3166
3520
|
.stack { display: flex; flex-direction: column; gap: 12px; }
|
|
3521
|
+
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
|
|
3522
|
+
.form-grid .wide { grid-column: span 2; }
|
|
3167
3523
|
.route {
|
|
3168
|
-
display: grid; grid-template-columns:
|
|
3169
|
-
padding:
|
|
3170
|
-
}
|
|
3171
|
-
.
|
|
3524
|
+
display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 10px; align-items: center;
|
|
3525
|
+
padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg-elev);
|
|
3526
|
+
}
|
|
3527
|
+
.route:first-child { border-radius: var(--radius) var(--radius) 0 0; }
|
|
3528
|
+
.route:last-child { border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
|
|
3529
|
+
.route-tools { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
|
|
3530
|
+
.route-tools .field { flex: 1; }
|
|
3531
|
+
.route-tools input { width: 100%; }
|
|
3532
|
+
.route-count { padding-bottom: 10px; color: var(--faint); font-size: 12px; white-space: nowrap; }
|
|
3533
|
+
#route-list { max-height: 34rem; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow-xs); }
|
|
3534
|
+
.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; }
|
|
3535
|
+
@keyframes view-in { from { transform: translateY(3px); } to { transform: translateY(0); } }
|
|
3536
|
+
@keyframes dialog-in { from { transform: translateY(8px) scale(0.99); } to { transform: translateY(0) scale(1); } }
|
|
3537
|
+
@keyframes pulse { 50% { opacity: 0.45; } }
|
|
3538
|
+
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
|
|
3539
|
+
@media (forced-colors: active) { .json-editor pre { display: none; } .json-editor textarea { color: CanvasText; -webkit-text-fill-color: CanvasText; } }
|
|
3172
3540
|
@media (max-width: 800px) {
|
|
3541
|
+
:root { --header: 0px; }
|
|
3173
3542
|
header.top {
|
|
3174
|
-
align-items: stretch; flex-direction: column;
|
|
3175
|
-
padding
|
|
3543
|
+
position: relative; align-items: stretch; flex-direction: column;
|
|
3544
|
+
padding: max(12px, env(safe-area-inset-top)) 14px 12px;
|
|
3176
3545
|
}
|
|
3177
3546
|
input, select, textarea { font-size: 16px; }
|
|
3178
3547
|
.brand, .vendor, .controls { width: 100%; }
|
|
3548
|
+
.brand { gap: 10px; }
|
|
3549
|
+
.vendor { order: 2; border-radius: 9px; }
|
|
3179
3550
|
label.field, label.field select, label.field input { flex: 1; min-width: 0; }
|
|
3551
|
+
.sync-status { display: none; }
|
|
3180
3552
|
/* The layout fills the screen. A single-column grid stretches every auto
|
|
3181
3553
|
row, so the tab bar grew with the leftover height and the buttons floated
|
|
3182
3554
|
in the middle of it. The bar stays one row; the page below takes the rest. */
|
|
@@ -3186,14 +3558,23 @@ var renderAdminDocument = (service) => {
|
|
|
3186
3558
|
align-content: start;
|
|
3187
3559
|
}
|
|
3188
3560
|
nav.side {
|
|
3189
|
-
align-self: start; height: auto;
|
|
3561
|
+
position: sticky; top: 0; z-index: 12; align-self: start; height: auto;
|
|
3190
3562
|
flex-direction: row; align-items: center; overflow-x: auto; min-width: 0;
|
|
3191
3563
|
border-right: 0; border-bottom: 1px solid var(--line);
|
|
3192
|
-
padding: 8px;
|
|
3564
|
+
padding: 8px; box-shadow: var(--shadow-xs);
|
|
3193
3565
|
}
|
|
3194
|
-
nav
|
|
3566
|
+
.nav-label { display: none; }
|
|
3567
|
+
nav.side button { width: auto; white-space: nowrap; flex: none; }
|
|
3568
|
+
nav.side button[aria-current="true"]::before { inset: auto 9px -8px; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
|
|
3195
3569
|
.split, .sql-layout { grid-template-columns: minmax(0, 1fr); }
|
|
3196
|
-
|
|
3570
|
+
.form-grid { grid-template-columns: minmax(0, 1fr); }
|
|
3571
|
+
.form-grid .wide { grid-column: auto; }
|
|
3572
|
+
main { padding: 22px 14px 48px; }
|
|
3573
|
+
.view-head { margin-bottom: 18px; }
|
|
3574
|
+
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
|
|
3575
|
+
.card { padding: 14px; }
|
|
3576
|
+
.card .v { font-size: 20px; }
|
|
3577
|
+
.table-shell { border: 0; background: transparent; box-shadow: none; overflow: visible; }
|
|
3197
3578
|
table, thead, tbody, tr, th, td { display: block; }
|
|
3198
3579
|
thead { display: none; }
|
|
3199
3580
|
tr {
|
|
@@ -3208,50 +3589,63 @@ var renderAdminDocument = (service) => {
|
|
|
3208
3589
|
.route { grid-template-columns: 72px 1fr; }
|
|
3209
3590
|
.route button { grid-column: 1 / -1; }
|
|
3210
3591
|
}
|
|
3592
|
+
@media (max-width: 460px) {
|
|
3593
|
+
.controls label.field { min-width: calc(50% - 4px); }
|
|
3594
|
+
.controls .icon-btn, .controls .btn { flex: 1; }
|
|
3595
|
+
.grid { grid-template-columns: minmax(0, 1fr); }
|
|
3596
|
+
.dialog-actions { flex-wrap: wrap; }
|
|
3597
|
+
.dialog-actions button { flex: 1; }
|
|
3598
|
+
.dialog-actions .btn-danger { flex-basis: 100%; margin-right: 0; }
|
|
3599
|
+
}
|
|
3211
3600
|
</style>
|
|
3212
3601
|
</head>
|
|
3213
3602
|
<body>
|
|
3214
3603
|
<div class="app" data-service="${name}" data-mockingbird-admin>
|
|
3215
3604
|
<header class="top">
|
|
3216
3605
|
<div class="brand">
|
|
3217
|
-
<div class="brand-
|
|
3218
|
-
<
|
|
3219
|
-
|
|
3606
|
+
<div class="brand-lockup">
|
|
3607
|
+
<div class="brand-mark" aria-hidden="true">
|
|
3608
|
+
<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>
|
|
3609
|
+
</div>
|
|
3610
|
+
<div class="brand-id">
|
|
3611
|
+
<strong>${name}</strong>
|
|
3612
|
+
<span>Mock admin</span>
|
|
3613
|
+
</div>
|
|
3220
3614
|
</div>
|
|
3221
3615
|
<div class="vendor" id="vendor" hidden></div>
|
|
3222
3616
|
</div>
|
|
3223
3617
|
<div class="controls">
|
|
3618
|
+
<span class="sync-status" id="sync-status" role="status" aria-live="polite">Ready</span>
|
|
3224
3619
|
<label class="field">Namespace
|
|
3225
3620
|
<select id="namespace" aria-label="Namespace"></select>
|
|
3226
3621
|
</label>
|
|
3227
3622
|
<label class="field">Admin key
|
|
3228
3623
|
<input id="admin-key" type="password" autocomplete="off" spellcheck="false" aria-label="Admin key">
|
|
3229
3624
|
</label>
|
|
3230
|
-
<button class="icon-btn" id="theme" type="button" aria-label="
|
|
3231
|
-
<button class="btn" id="refresh" type="button">Refresh</button>
|
|
3625
|
+
<button class="icon-btn" id="theme" type="button" aria-label="Use dark theme" title="Use dark theme"></button>
|
|
3626
|
+
<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>
|
|
3232
3627
|
</div>
|
|
3233
3628
|
</header>
|
|
3234
3629
|
<div class="layout">
|
|
3235
3630
|
<nav class="side" id="nav" aria-label="Admin sections">
|
|
3236
|
-
<
|
|
3237
|
-
<button type="button" data-view="
|
|
3238
|
-
<button type="button" data-view="
|
|
3239
|
-
<button type="button" data-view="
|
|
3240
|
-
<button type="button" data-view="
|
|
3241
|
-
<button type="button" data-view="
|
|
3631
|
+
<span class="nav-label">Workspace</span>
|
|
3632
|
+
<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>
|
|
3633
|
+
<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>
|
|
3634
|
+
<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>
|
|
3635
|
+
<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>
|
|
3636
|
+
<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>
|
|
3637
|
+
<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>
|
|
3242
3638
|
</nav>
|
|
3243
3639
|
<main id="views">
|
|
3244
|
-
<
|
|
3640
|
+
<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>
|
|
3245
3641
|
<section class="view" id="view-overview">
|
|
3246
|
-
<h2>Overview</h2>
|
|
3247
|
-
<p class="lede">Health, clock, and the collections this namespace is holding.</p>
|
|
3642
|
+
<div class="view-head"><div><h2>Overview</h2><p class="lede">Health, clock, and the collections this namespace is holding.</p></div></div>
|
|
3248
3643
|
<div class="grid" id="overview-cards"></div>
|
|
3249
3644
|
<h3>Recent requests</h3>
|
|
3250
3645
|
<div id="overview-requests"></div>
|
|
3251
3646
|
</section>
|
|
3252
3647
|
<section class="view" id="view-state" hidden>
|
|
3253
|
-
<h2>State</h2>
|
|
3254
|
-
<p class="lede">Every collection in this namespace. Declared fields stay visible before any row exists; stored rows add whatever else they contain.</p>
|
|
3648
|
+
<div class="view-head"><div><h2>State</h2><p class="lede">Inspect and edit every collection in this namespace.</p></div></div>
|
|
3255
3649
|
<div class="split">
|
|
3256
3650
|
<div id="collections"></div>
|
|
3257
3651
|
<div>
|
|
@@ -3264,8 +3658,7 @@ var renderAdminDocument = (service) => {
|
|
|
3264
3658
|
</div>
|
|
3265
3659
|
</section>
|
|
3266
3660
|
<section class="view" id="view-clock" hidden>
|
|
3267
|
-
<h2>Clock</h2>
|
|
3268
|
-
<p class="lede">The clock every timestamp in this mock reads.</p>
|
|
3661
|
+
<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>
|
|
3269
3662
|
<div class="card" id="clock-readout"></div>
|
|
3270
3663
|
<div class="row-actions">
|
|
3271
3664
|
<button class="btn" type="button" data-advance="60000">+1m</button>
|
|
@@ -3284,21 +3677,22 @@ var renderAdminDocument = (service) => {
|
|
|
3284
3677
|
</form>
|
|
3285
3678
|
</section>
|
|
3286
3679
|
<section class="view" id="view-faults" hidden>
|
|
3287
|
-
<h2>Faults</h2>
|
|
3288
|
-
<p class="lede">Inject a response, a delay, or a named preset. Rules apply to this namespace.</p>
|
|
3680
|
+
<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>
|
|
3289
3681
|
<form id="fault-form" class="card stack">
|
|
3290
|
-
<
|
|
3291
|
-
<
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
<
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
<
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
<
|
|
3301
|
-
|
|
3682
|
+
<div class="form-grid">
|
|
3683
|
+
<label class="field wide">Preset
|
|
3684
|
+
<select id="fault-preset"><option value="">Custom rule</option></select>
|
|
3685
|
+
</label>
|
|
3686
|
+
<label class="field">Status
|
|
3687
|
+
<input id="fault-status" inputmode="numeric" placeholder="503">
|
|
3688
|
+
</label>
|
|
3689
|
+
<label class="field wide">Path prefix
|
|
3690
|
+
<input id="fault-path" placeholder="/v1">
|
|
3691
|
+
</label>
|
|
3692
|
+
<label class="field">Method
|
|
3693
|
+
<input id="fault-method" placeholder="GET">
|
|
3694
|
+
</label>
|
|
3695
|
+
</div>
|
|
3302
3696
|
<div class="dialog-actions">
|
|
3303
3697
|
<button class="btn-primary" type="submit">Add fault</button>
|
|
3304
3698
|
<button class="btn-danger" id="fault-clear" type="button">Clear all</button>
|
|
@@ -3307,26 +3701,31 @@ var renderAdminDocument = (service) => {
|
|
|
3307
3701
|
<div id="fault-list"></div>
|
|
3308
3702
|
</section>
|
|
3309
3703
|
<section class="view" id="view-journal" hidden>
|
|
3310
|
-
<h2>Journal</h2>
|
|
3311
|
-
<p class="lede">Requests this namespace has seen. Bodies are not stored.</p>
|
|
3312
|
-
<div class="row-actions">
|
|
3313
|
-
<button class="btn-danger" id="journal-clear" type="button">Clear journal</button>
|
|
3314
|
-
</div>
|
|
3704
|
+
<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>
|
|
3315
3705
|
<div id="journal"></div>
|
|
3316
3706
|
</section>
|
|
3317
3707
|
<section class="view" id="view-routes" hidden>
|
|
3318
|
-
<h2>Routes</h2>
|
|
3319
|
-
<
|
|
3708
|
+
<div class="view-head"><div><h2>Routes</h2><p class="lede">Explore shared controls and service-specific admin endpoints.</p></div></div>
|
|
3709
|
+
<div class="route-tools">
|
|
3710
|
+
<label class="field">Filter routes
|
|
3711
|
+
<input id="route-search" type="search" placeholder="Method, path, or extension" autocomplete="off">
|
|
3712
|
+
</label>
|
|
3713
|
+
<span class="route-count" id="route-count"></span>
|
|
3714
|
+
</div>
|
|
3320
3715
|
<div id="route-list"></div>
|
|
3321
|
-
<form id="route-form" class="card stack">
|
|
3716
|
+
<form id="route-form" class="card stack" style="margin-top: 18px">
|
|
3322
3717
|
<strong id="route-title">Select a route</strong>
|
|
3323
3718
|
<label class="field">JSON body
|
|
3324
|
-
<
|
|
3719
|
+
<div class="json-editor" id="route-editor" hidden>
|
|
3720
|
+
<pre aria-hidden="true"><code id="route-highlight"></code></pre>
|
|
3721
|
+
<textarea id="route-body" placeholder="{ }" spellcheck="false" aria-describedby="route-json-status" disabled></textarea>
|
|
3722
|
+
</div>
|
|
3723
|
+
<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>
|
|
3325
3724
|
</label>
|
|
3326
3725
|
<div class="dialog-actions">
|
|
3327
|
-
<button class="btn-primary" type="submit">Send</button>
|
|
3726
|
+
<button class="btn-primary" id="route-send" type="submit" disabled>Send request</button>
|
|
3328
3727
|
</div>
|
|
3329
|
-
<pre id="route-result">Response will show here.</pre>
|
|
3728
|
+
<pre class="json-view" id="route-result"><code>Response will show here.</code></pre>
|
|
3330
3729
|
</form>
|
|
3331
3730
|
</section>
|
|
3332
3731
|
</main>
|
|
@@ -3334,12 +3733,16 @@ var renderAdminDocument = (service) => {
|
|
|
3334
3733
|
</div>
|
|
3335
3734
|
<dialog id="editor">
|
|
3336
3735
|
<form method="dialog" id="editor-form">
|
|
3337
|
-
<strong id="editor-title">Record</strong>
|
|
3736
|
+
<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>
|
|
3338
3737
|
<label class="field">Id
|
|
3339
3738
|
<input id="editor-id" required>
|
|
3340
3739
|
</label>
|
|
3341
3740
|
<label class="field">JSON value
|
|
3342
|
-
<
|
|
3741
|
+
<div class="json-editor" id="record-editor">
|
|
3742
|
+
<pre aria-hidden="true"><code id="editor-highlight"></code></pre>
|
|
3743
|
+
<textarea id="editor-value" spellcheck="false" aria-describedby="editor-json-status"></textarea>
|
|
3744
|
+
</div>
|
|
3745
|
+
<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>
|
|
3343
3746
|
</label>
|
|
3344
3747
|
<div class="dialog-actions">
|
|
3345
3748
|
<button class="btn-danger" id="editor-delete" type="button" value="delete">Delete</button>
|
|
@@ -3381,8 +3784,8 @@ var describeExtension = (extension) => {
|
|
|
3381
3784
|
...extension.script !== void 0 ? { script: extension.script } : {}
|
|
3382
3785
|
};
|
|
3383
3786
|
};
|
|
3384
|
-
var adminUiRoutes = (service, ui) => {
|
|
3385
|
-
const shell = () => renderAdminDocument(service);
|
|
3787
|
+
var adminUiRoutes = (service, ui, adminPrefix = ADMIN_PREFIX) => {
|
|
3788
|
+
const shell = () => renderAdminDocument(service, adminPrefix);
|
|
3386
3789
|
const document3 = () => ui?.render ? ui.render({ service, defaultHtml: shell }) : shell();
|
|
3387
3790
|
return {
|
|
3388
3791
|
"GET /ui": () => htmlResponse(document3()),
|
|
@@ -4073,7 +4476,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
4073
4476
|
};
|
|
4074
4477
|
|
|
4075
4478
|
// ../core/dist/version.js
|
|
4076
|
-
var PACKAGE_VERSION = true ? "
|
|
4479
|
+
var PACKAGE_VERSION = true ? "2.0.0" : UNRELEASED_VERSION;
|
|
4077
4480
|
|
|
4078
4481
|
// ../core/dist/signing.js
|
|
4079
4482
|
var encoder = new TextEncoder();
|
|
@@ -4081,7 +4484,10 @@ var toHex = (bytes) => [...bytes instanceof Uint8Array ? bytes : new Uint8Array(
|
|
|
4081
4484
|
var sha = async (algorithm, input) => toHex(await crypto.subtle.digest(algorithm, typeof input === "string" ? encoder.encode(input) : input));
|
|
4082
4485
|
|
|
4083
4486
|
// ../core/dist/webhooks.js
|
|
4084
|
-
var json4 = (status, body) => new Response(JSON.stringify(body), {
|
|
4487
|
+
var json4 = (status, body) => new Response(JSON.stringify(body), {
|
|
4488
|
+
status,
|
|
4489
|
+
headers: { "content-type": "application/json; charset=utf-8" }
|
|
4490
|
+
});
|
|
4085
4491
|
var adminError3 = (status, message) => json4(status, { error: { type: "mockingbird_admin", message } });
|
|
4086
4492
|
var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4087
4493
|
var parseEndpoint = (value) => {
|
|
@@ -4189,7 +4595,6 @@ var AT_HEADER = "x-mockingbird-at";
|
|
|
4189
4595
|
var CHECKPOINT_HEADER = "x-mockingbird-checkpoint";
|
|
4190
4596
|
var DEFAULT_NAMESPACE = "default";
|
|
4191
4597
|
var NAMESPACE_PATTERN = /^[A-Za-z0-9_.-]{1,64}$/;
|
|
4192
|
-
var PATH_PREFIX = /^\/ns\/([^/]+)(\/.*)?$/;
|
|
4193
4598
|
var BRANCH_PATTERN2 = /^[A-Za-z0-9_.-]{1,64}$/;
|
|
4194
4599
|
var MUTATING_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
4195
4600
|
var effects = /* @__PURE__ */ new WeakMap();
|
|
@@ -4230,6 +4635,22 @@ var operationMatcher = (document3) => {
|
|
|
4230
4635
|
return (request, path) => matchers.find((m) => m.method === request.method && m.pattern.test(path))?.operationId;
|
|
4231
4636
|
};
|
|
4232
4637
|
var createRuntime = (options) => {
|
|
4638
|
+
const adminPrefix = resolveAdminPrefix(options.adminPrefix);
|
|
4639
|
+
const internalPaths = Object.entries(options.document?.paths ?? {}).filter(([, item]) => item["x-mockingbird-internal"] === true).map(([path]) => path);
|
|
4640
|
+
for (const path of internalPaths) {
|
|
4641
|
+
if (!path.startsWith(`${ADMIN_PREFIX}/blobs/`))
|
|
4642
|
+
throw new Error(`internal transport ${path} must live under ${ADMIN_PREFIX}/blobs/`);
|
|
4643
|
+
}
|
|
4644
|
+
assertAdminPrefixAvailable(adminPrefix, Object.keys(options.document?.paths ?? {}).filter((path) => !internalPaths.includes(path)));
|
|
4645
|
+
const internalMatch = (path) => {
|
|
4646
|
+
for (const pattern of internalPaths) {
|
|
4647
|
+
const actual = path.split("/");
|
|
4648
|
+
const expected = pattern.split("/");
|
|
4649
|
+
if (actual.length === expected.length && expected.every((part, i) => part.startsWith("{") || part === actual[i]))
|
|
4650
|
+
return pattern;
|
|
4651
|
+
}
|
|
4652
|
+
return void 0;
|
|
4653
|
+
};
|
|
4233
4654
|
assertAdminUi(options.adminUi);
|
|
4234
4655
|
const sqlite = bootSqlite(options.sqlite);
|
|
4235
4656
|
const clock = options.clock ?? createClock();
|
|
@@ -4244,6 +4665,20 @@ var createRuntime = (options) => {
|
|
|
4244
4665
|
const instances = /* @__PURE__ */ new Map();
|
|
4245
4666
|
const publicNamespaces = /* @__PURE__ */ new Set();
|
|
4246
4667
|
const branchRngs = /* @__PURE__ */ new Map();
|
|
4668
|
+
const namespaceClocks = /* @__PURE__ */ new Map();
|
|
4669
|
+
const namespaceForStorage = /* @__PURE__ */ new Map();
|
|
4670
|
+
let isolatedNamespaces = false;
|
|
4671
|
+
const namespaceClock = (name = DEFAULT_NAMESPACE) => {
|
|
4672
|
+
if (!isolatedNamespaces || name === DEFAULT_NAMESPACE)
|
|
4673
|
+
return clock;
|
|
4674
|
+
let found = namespaceClocks.get(name);
|
|
4675
|
+
if (!found) {
|
|
4676
|
+
found = createClock();
|
|
4677
|
+
namespaceClocks.set(name, found);
|
|
4678
|
+
}
|
|
4679
|
+
return found;
|
|
4680
|
+
};
|
|
4681
|
+
const fleetPoints = /* @__PURE__ */ new WeakMap();
|
|
4247
4682
|
const timelines = /* @__PURE__ */ new Map();
|
|
4248
4683
|
const branchStorage = /* @__PURE__ */ new Map();
|
|
4249
4684
|
const captured = /* @__PURE__ */ new Map();
|
|
@@ -4257,17 +4692,22 @@ var createRuntime = (options) => {
|
|
|
4257
4692
|
if (!NAMESPACE_PATTERN.test(key) || !NAMESPACE_PATTERN.test(publicNamespace)) {
|
|
4258
4693
|
throw new RangeError(`namespace must match ${NAMESPACE_PATTERN}: ${JSON.stringify(publicNamespace)}`);
|
|
4259
4694
|
}
|
|
4695
|
+
const createdContextRng = isolatedRng ?? (isolatedNamespaces && key !== DEFAULT_NAMESPACE ? createRng(options.seed ?? 0) : rng);
|
|
4260
4696
|
const created = options.create({
|
|
4261
4697
|
namespace: storageNamespace(key),
|
|
4262
4698
|
publicNamespace,
|
|
4699
|
+
adminPrefix,
|
|
4263
4700
|
sqlite,
|
|
4264
|
-
clock,
|
|
4265
|
-
rng:
|
|
4701
|
+
clock: namespaceClock(publicNamespace),
|
|
4702
|
+
rng: createdContextRng
|
|
4266
4703
|
});
|
|
4267
4704
|
instances.set(key, created);
|
|
4705
|
+
namespaceForStorage.set(key, publicNamespace);
|
|
4268
4706
|
publicNamespaces.add(publicNamespace);
|
|
4269
4707
|
if (isolatedRng)
|
|
4270
4708
|
branchRngs.set(key, isolatedRng);
|
|
4709
|
+
else if (isolatedNamespaces && key !== DEFAULT_NAMESPACE)
|
|
4710
|
+
branchRngs.set(key, createdContextRng);
|
|
4271
4711
|
return created;
|
|
4272
4712
|
};
|
|
4273
4713
|
const instance = (name = DEFAULT_NAMESPACE) => instanceFor(name);
|
|
@@ -4285,7 +4725,7 @@ var createRuntime = (options) => {
|
|
|
4285
4725
|
captured.set(storage, snapshot2);
|
|
4286
4726
|
return Object.freeze({
|
|
4287
4727
|
snapshot: snapshot2,
|
|
4288
|
-
clock: Object.freeze(
|
|
4728
|
+
clock: Object.freeze(namespaceClock(namespaceForStorage.get(storage) ?? storage).state()),
|
|
4289
4729
|
rngState: (branchRngs.get(storage) ?? rng).state()
|
|
4290
4730
|
});
|
|
4291
4731
|
};
|
|
@@ -4295,7 +4735,7 @@ var createRuntime = (options) => {
|
|
|
4295
4735
|
return found;
|
|
4296
4736
|
instance(name);
|
|
4297
4737
|
found = new Timeline({
|
|
4298
|
-
now:
|
|
4738
|
+
now: namespaceClock(name).now,
|
|
4299
4739
|
...options.maxCheckpoints !== void 0 ? { maxCheckpoints: options.maxCheckpoints } : {}
|
|
4300
4740
|
});
|
|
4301
4741
|
found.commit(capture(name));
|
|
@@ -4322,12 +4762,13 @@ var createRuntime = (options) => {
|
|
|
4322
4762
|
const point = history2.checkout("main", at);
|
|
4323
4763
|
restoreNamespace(sqlite, storageNamespace(namespace), point.value.snapshot);
|
|
4324
4764
|
captured.set(namespace, point.value.snapshot);
|
|
4325
|
-
rng.setState(point.value.rngState);
|
|
4326
|
-
|
|
4765
|
+
(branchRngs.get(namespace) ?? rng).setState(point.value.rngState);
|
|
4766
|
+
const selectedClock = namespaceClock(namespace);
|
|
4767
|
+
selectedClock.set(point.value.clock.now);
|
|
4327
4768
|
if (point.value.clock.frozen)
|
|
4328
|
-
|
|
4769
|
+
selectedClock.freeze();
|
|
4329
4770
|
else
|
|
4330
|
-
|
|
4771
|
+
selectedClock.unfreeze();
|
|
4331
4772
|
}
|
|
4332
4773
|
return namespace;
|
|
4333
4774
|
}
|
|
@@ -4385,11 +4826,12 @@ var createRuntime = (options) => {
|
|
|
4385
4826
|
const storage = ensureBranch(namespace, branchName);
|
|
4386
4827
|
restoreNamespace(sqlite, storageNamespace(storage), point.value.snapshot);
|
|
4387
4828
|
captured.set(storage, point.value.snapshot);
|
|
4388
|
-
|
|
4829
|
+
const selectedClock = namespaceClock(namespace);
|
|
4830
|
+
selectedClock.set(point.value.clock.now);
|
|
4389
4831
|
if (point.value.clock.frozen)
|
|
4390
|
-
|
|
4832
|
+
selectedClock.freeze();
|
|
4391
4833
|
else
|
|
4392
|
-
|
|
4834
|
+
selectedClock.unfreeze();
|
|
4393
4835
|
(branchRngs.get(storage) ?? rng).setState(point.value.rngState);
|
|
4394
4836
|
};
|
|
4395
4837
|
const reset = async (name = DEFAULT_NAMESPACE) => {
|
|
@@ -4397,10 +4839,21 @@ var createRuntime = (options) => {
|
|
|
4397
4839
|
options.webhooks?.clear();
|
|
4398
4840
|
for (const each of instances.values())
|
|
4399
4841
|
await each.reset();
|
|
4842
|
+
for (const each of branchRngs.values())
|
|
4843
|
+
each.reset();
|
|
4400
4844
|
timelines.clear();
|
|
4845
|
+
for (const storage of branchStorage.values()) {
|
|
4846
|
+
instances.delete(storage);
|
|
4847
|
+
branchRngs.delete(storage);
|
|
4848
|
+
namespaceForStorage.delete(storage);
|
|
4849
|
+
}
|
|
4401
4850
|
branchStorage.clear();
|
|
4402
|
-
branchRngs.clear();
|
|
4403
4851
|
captured.clear();
|
|
4852
|
+
faults.clear();
|
|
4853
|
+
clock.reset();
|
|
4854
|
+
rng.reset();
|
|
4855
|
+
for (const each of namespaceClocks.values())
|
|
4856
|
+
each.reset();
|
|
4404
4857
|
return;
|
|
4405
4858
|
}
|
|
4406
4859
|
options.webhooks?.clear(name);
|
|
@@ -4418,11 +4871,18 @@ var createRuntime = (options) => {
|
|
|
4418
4871
|
else
|
|
4419
4872
|
clearNamespace(sqlite, storageNamespace(storage));
|
|
4420
4873
|
branchStorage.delete(mapping);
|
|
4874
|
+
instances.delete(storage);
|
|
4875
|
+
namespaceForStorage.delete(storage);
|
|
4421
4876
|
branchRngs.delete(storage);
|
|
4422
4877
|
captured.delete(storage);
|
|
4423
4878
|
}
|
|
4424
4879
|
timelines.delete(name);
|
|
4425
4880
|
captured.delete(name);
|
|
4881
|
+
faults.restore(name, { rules: [], rngState: createRng(options.seed ?? 0).state() });
|
|
4882
|
+
namespaceClock(name).reset();
|
|
4883
|
+
(branchRngs.get(name) ?? rng).reset();
|
|
4884
|
+
journal.clear(name);
|
|
4885
|
+
metrics.reset(name);
|
|
4426
4886
|
};
|
|
4427
4887
|
const snapshot = (name = DEFAULT_NAMESPACE) => {
|
|
4428
4888
|
return checkpoint(name, "main").value.snapshot;
|
|
@@ -4460,6 +4920,53 @@ var createRuntime = (options) => {
|
|
|
4460
4920
|
rng,
|
|
4461
4921
|
credentials,
|
|
4462
4922
|
webhooks: options.webhooks,
|
|
4923
|
+
isolateNamespaces() {
|
|
4924
|
+
if (publicNamespaces.size > 1)
|
|
4925
|
+
throw new Error("enable namespace isolation before creating named namespaces");
|
|
4926
|
+
isolatedNamespaces = true;
|
|
4927
|
+
faults.isolateNamespaces();
|
|
4928
|
+
},
|
|
4929
|
+
namespaceClock,
|
|
4930
|
+
namespaceOf(request) {
|
|
4931
|
+
const url = new URL(request.url);
|
|
4932
|
+
const prefixed = matchNamespacePath(url.pathname, adminPrefix);
|
|
4933
|
+
const selected = request.headers.get(NAMESPACE_HEADER) ?? (prefixed ? decodeURIComponent(prefixed[1]) : void 0);
|
|
4934
|
+
const path = prefixed ? prefixed[2] ?? "/" : url.pathname;
|
|
4935
|
+
if (isAdminPath(path, adminPrefix))
|
|
4936
|
+
return url.searchParams.get("namespace") ?? selected ?? DEFAULT_NAMESPACE;
|
|
4937
|
+
if (selected !== void 0)
|
|
4938
|
+
return selected;
|
|
4939
|
+
const credential = options.credential?.(request);
|
|
4940
|
+
return (credential !== void 0 ? credentials.get(credential) : void 0) ?? DEFAULT_NAMESPACE;
|
|
4941
|
+
},
|
|
4942
|
+
fleetSnapshot(namespace) {
|
|
4943
|
+
instance(namespace);
|
|
4944
|
+
const handle = {};
|
|
4945
|
+
fleetPoints.set(handle, {
|
|
4946
|
+
namespace,
|
|
4947
|
+
state: capture(namespace),
|
|
4948
|
+
faults: faults.snapshot(namespace),
|
|
4949
|
+
webhooks: options.webhooks?.snapshot(namespace)
|
|
4950
|
+
});
|
|
4951
|
+
return handle;
|
|
4952
|
+
},
|
|
4953
|
+
fleetRestore(handle, namespace) {
|
|
4954
|
+
const point = typeof handle === "object" && handle !== null ? fleetPoints.get(handle) : void 0;
|
|
4955
|
+
if (!point || point.namespace !== namespace)
|
|
4956
|
+
throw new Error("invalid fleet checkpoint");
|
|
4957
|
+
restoreNamespace(sqlite, storageNamespace(namespace), point.state.snapshot);
|
|
4958
|
+
captured.set(namespace, point.state.snapshot);
|
|
4959
|
+
const selectedClock = namespaceClock(namespace);
|
|
4960
|
+
selectedClock.freeze();
|
|
4961
|
+
selectedClock.set(point.state.clock.now);
|
|
4962
|
+
if (!point.state.clock.frozen)
|
|
4963
|
+
selectedClock.unfreeze();
|
|
4964
|
+
(branchRngs.get(namespace) ?? rng).setState(point.state.rngState);
|
|
4965
|
+
faults.restore(namespace, point.faults);
|
|
4966
|
+
if (point.webhooks !== void 0)
|
|
4967
|
+
options.webhooks?.restore(namespace, point.webhooks);
|
|
4968
|
+
timelines.delete(namespace);
|
|
4969
|
+
},
|
|
4463
4970
|
applyPreset: (name, namespace = DEFAULT_NAMESPACE, overrides = {}) => {
|
|
4464
4971
|
const preset = options.presets?.[name];
|
|
4465
4972
|
if (!preset)
|
|
@@ -4491,7 +4998,7 @@ var createRuntime = (options) => {
|
|
|
4491
4998
|
state: (namespace = DEFAULT_NAMESPACE) => inspectState(stateScope(namespace)),
|
|
4492
4999
|
fetch: async (incoming) => {
|
|
4493
5000
|
let request = incoming;
|
|
4494
|
-
const prefixed =
|
|
5001
|
+
const prefixed = matchNamespacePath(new URL(request.url).pathname, adminPrefix);
|
|
4495
5002
|
if (prefixed) {
|
|
4496
5003
|
const url2 = new URL(request.url);
|
|
4497
5004
|
url2.pathname = prefixed[2] ?? "/";
|
|
@@ -4507,7 +5014,15 @@ var createRuntime = (options) => {
|
|
|
4507
5014
|
signal: request.signal
|
|
4508
5015
|
});
|
|
4509
5016
|
}
|
|
4510
|
-
|
|
5017
|
+
const internalUrl = new URL(request.url);
|
|
5018
|
+
const internalPath = isAdminPath(internalUrl.pathname, adminPrefix) ? `${ADMIN_PREFIX}${internalUrl.pathname.slice(adminPrefix.length)}` : "";
|
|
5019
|
+
const internal = internalMatch(internalPath);
|
|
5020
|
+
const obsoleteInternalPath = adminPrefix !== ADMIN_PREFIX && internalMatch(internalUrl.pathname) && !internal;
|
|
5021
|
+
if (internal) {
|
|
5022
|
+
internalUrl.pathname = internalPath;
|
|
5023
|
+
request = new Request(internalUrl, request);
|
|
5024
|
+
}
|
|
5025
|
+
let namespace = internal ? internalUrl.searchParams.get("namespace") ?? control.namespaceOf(request) : control.namespaceOf(request);
|
|
4511
5026
|
if (!request.headers.has(NAMESPACE_HEADER) && options.credential) {
|
|
4512
5027
|
const credential = options.credential(request);
|
|
4513
5028
|
const mapped = credential !== void 0 ? credentials.get(credential) : void 0;
|
|
@@ -4527,7 +5042,9 @@ var createRuntime = (options) => {
|
|
|
4527
5042
|
return copy;
|
|
4528
5043
|
}
|
|
4529
5044
|
};
|
|
4530
|
-
|
|
5045
|
+
if (obsoleteInternalPath)
|
|
5046
|
+
return stamp(adminFail(404, "internal transport is only available under adminPrefix"));
|
|
5047
|
+
const handled = internal ? void 0 : await control.handle(request);
|
|
4531
5048
|
if (handled)
|
|
4532
5049
|
return stamp(handled);
|
|
4533
5050
|
const started = monotonicNow();
|
|
@@ -4568,7 +5085,7 @@ var createRuntime = (options) => {
|
|
|
4568
5085
|
type: "mockingbird_admin",
|
|
4569
5086
|
message: `${NAMESPACE_HEADER} must match ${NAMESPACE_PATTERN}`
|
|
4570
5087
|
}
|
|
4571
|
-
}), { status: 400, headers: { "content-type": "application/json" } }));
|
|
5088
|
+
}), { status: 400, headers: { "content-type": "application/json; charset=utf-8" } }));
|
|
4572
5089
|
}
|
|
4573
5090
|
if (!BRANCH_PATTERN2.test(selectedBranch)) {
|
|
4574
5091
|
log(400);
|
|
@@ -4635,6 +5152,7 @@ var createRuntime = (options) => {
|
|
|
4635
5152
|
startedAt: wallNow(),
|
|
4636
5153
|
wallNow,
|
|
4637
5154
|
clock,
|
|
5155
|
+
namespaceClock,
|
|
4638
5156
|
faults,
|
|
4639
5157
|
metrics,
|
|
4640
5158
|
journal,
|
|
@@ -4684,15 +5202,16 @@ var createRuntime = (options) => {
|
|
|
4684
5202
|
...options.admin?.(runtime) ?? {},
|
|
4685
5203
|
// Shell routes win a colliding key. Fault presets are one of them: the admin page
|
|
4686
5204
|
// maps `presets`, and a service route must not replace that list with a record.
|
|
4687
|
-
...options.presets ? presetRoutes(options.presets, runtime) : {},
|
|
5205
|
+
...options.presets ? presetRoutes(options.presets, runtime, adminPrefix) : {},
|
|
4688
5206
|
...stateAdminRoutes({
|
|
4689
5207
|
open: stateScope,
|
|
4690
5208
|
afterWrite: (namespace) => {
|
|
4691
5209
|
checkpoint(namespace, "main");
|
|
4692
5210
|
}
|
|
4693
5211
|
}),
|
|
4694
|
-
...adminUiRoutes(options.name, options.adminUi)
|
|
5212
|
+
...adminUiRoutes(options.name, options.adminUi, adminPrefix)
|
|
4695
5213
|
},
|
|
5214
|
+
adminPrefix,
|
|
4696
5215
|
adminKey: options.adminKey
|
|
4697
5216
|
});
|
|
4698
5217
|
return defineMock(runtime);
|
|
@@ -4706,7 +5225,10 @@ var mutableResponse = (response) => {
|
|
|
4706
5225
|
return new Response(response.body, response);
|
|
4707
5226
|
}
|
|
4708
5227
|
};
|
|
4709
|
-
var adminJson = (status, body) => new Response(JSON.stringify(body), {
|
|
5228
|
+
var adminJson = (status, body) => new Response(JSON.stringify(body), {
|
|
5229
|
+
status,
|
|
5230
|
+
headers: { "content-type": "application/json; charset=utf-8" }
|
|
5231
|
+
});
|
|
4710
5232
|
var adminFail = (status, message) => adminJson(status, { error: { type: "mockingbird_admin", message } });
|
|
4711
5233
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4712
5234
|
var credentialRoutes = (registry) => ({
|
|
@@ -4758,7 +5280,7 @@ var credentialRoutes = (registry) => ({
|
|
|
4758
5280
|
return adminJson(200, { status: "ok" });
|
|
4759
5281
|
}
|
|
4760
5282
|
});
|
|
4761
|
-
var presetRoutes = (presets, runtime) => ({
|
|
5283
|
+
var presetRoutes = (presets, runtime, adminPrefix) => ({
|
|
4762
5284
|
"GET /faults/presets": () => {
|
|
4763
5285
|
const body = {
|
|
4764
5286
|
presets: Object.entries(presets).map(([name, preset]) => ({ name, ...preset }))
|
|
@@ -4768,7 +5290,7 @@ var presetRoutes = (presets, runtime) => ({
|
|
|
4768
5290
|
"POST /faults/presets/:name": ({ params, body, namespace }) => {
|
|
4769
5291
|
const name = params.name;
|
|
4770
5292
|
if (!presets[name])
|
|
4771
|
-
return adminFail(404, `no fault preset ${name}; GET /
|
|
5293
|
+
return adminFail(404, `no fault preset ${name}; GET ${adminPrefix}/faults/presets`);
|
|
4772
5294
|
const overrides = isObject(body) ? body : {};
|
|
4773
5295
|
return adminJson(201, { preset: name, rules: runtime.applyPreset(name, namespace, overrides) });
|
|
4774
5296
|
}
|
|
@@ -6684,6 +7206,7 @@ var createRuntime2 = (options = {}) => {
|
|
|
6684
7206
|
...options.sqlite ? { sqlite: options.sqlite } : {},
|
|
6685
7207
|
...options.clock ? { clock: options.clock } : {},
|
|
6686
7208
|
...options.seed !== void 0 ? { seed: options.seed } : {},
|
|
7209
|
+
...options.adminPrefix !== void 0 ? { adminPrefix: options.adminPrefix } : {},
|
|
6687
7210
|
...options.adminKey !== void 0 ? { adminKey: options.adminKey } : {},
|
|
6688
7211
|
...options.onLog ? { onLog: options.onLog } : {},
|
|
6689
7212
|
credential: accessKeyCredential,
|
|
@@ -7206,6 +7729,9 @@ var BedrockAPI = class {
|
|
|
7206
7729
|
};
|
|
7207
7730
|
|
|
7208
7731
|
export {
|
|
7732
|
+
createClock,
|
|
7733
|
+
resolveAdminPrefix,
|
|
7734
|
+
parseDuration,
|
|
7209
7735
|
document2 as document,
|
|
7210
7736
|
operationIds,
|
|
7211
7737
|
supportedOperationIds,
|
|
@@ -7237,4 +7763,4 @@ export {
|
|
|
7237
7763
|
titanEmbedding,
|
|
7238
7764
|
BedrockAPI
|
|
7239
7765
|
};
|
|
7240
|
-
//# sourceMappingURL=chunk-
|
|
7766
|
+
//# sourceMappingURL=chunk-LYWMNREM.js.map
|