@crvouga/mockingbird-service-aha 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 +2 -2
- package/SUPPORT.md +12 -0
- package/dist/chunk-EBYGZUZ6.js +889 -0
- package/dist/chunk-EBYGZUZ6.js.map +7 -0
- package/dist/{chunk-7PAR2NE6.js → chunk-OPYCBZYR.js} +822 -258
- package/dist/chunk-OPYCBZYR.js.map +7 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +34 -4
- package/dist/index.js +1 -1
- package/dist/server.d.ts +64 -4
- package/dist/server.js +2 -2
- package/openapi.yaml +384 -0
- package/package.json +29 -4
- package/dist/chunk-7PAR2NE6.js.map +0 -7
- package/dist/chunk-G44JFJSF.js +0 -402
- package/dist/chunk-G44JFJSF.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 key2 of Object.keys(context.routes)) {
|
|
375
|
+
if (Object.hasOwn(builtin, key2))
|
|
376
|
+
throw new Error(`admin route ${key2} overrides a shared route`);
|
|
377
|
+
const path = key2.slice(key2.indexOf(" ") + 1);
|
|
378
|
+
if (isAdminPath(path, "/ns") || isAdminPath(path, "/blobs"))
|
|
379
|
+
throw new Error(`admin route ${key2} overlaps an internal transport`);
|
|
380
|
+
}
|
|
381
|
+
const routes = [...Object.entries(builtin), ...Object.entries(context.routes)].map(([key2, handler]) => {
|
|
342
382
|
const space = key2.indexOf(" ");
|
|
343
383
|
return { method: key2.slice(0, space), pattern: key2.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
|
};
|
|
@@ -467,7 +507,33 @@ var faultResponse = (rule) => {
|
|
|
467
507
|
};
|
|
468
508
|
var createFaultRegistry = (rng = createRng(0), sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))) => {
|
|
469
509
|
const entries = [];
|
|
510
|
+
let isolated = false;
|
|
511
|
+
const scopedRngs = /* @__PURE__ */ new Map();
|
|
512
|
+
const random = (namespace) => {
|
|
513
|
+
if (!isolated || namespace === "default")
|
|
514
|
+
return rng;
|
|
515
|
+
let scoped = scopedRngs.get(namespace);
|
|
516
|
+
if (!scoped) {
|
|
517
|
+
scoped = createRng(rng.seed);
|
|
518
|
+
scopedRngs.set(namespace, scoped);
|
|
519
|
+
}
|
|
520
|
+
return scoped;
|
|
521
|
+
};
|
|
470
522
|
return {
|
|
523
|
+
isolateNamespaces() {
|
|
524
|
+
isolated = true;
|
|
525
|
+
},
|
|
526
|
+
snapshot(namespace) {
|
|
527
|
+
return {
|
|
528
|
+
rules: structuredClone(entries.map((entry, position) => ({
|
|
529
|
+
...entry.rule,
|
|
530
|
+
remaining: entry.remaining,
|
|
531
|
+
hits: entry.hits,
|
|
532
|
+
position
|
|
533
|
+
})).filter((entry) => entry.namespace === namespace)),
|
|
534
|
+
rngState: random(namespace).state()
|
|
535
|
+
};
|
|
536
|
+
},
|
|
471
537
|
add(rule) {
|
|
472
538
|
const existing = entries.findIndex((e) => e.rule.id === rule.id);
|
|
473
539
|
const entry = { rule, remaining: rule.count ?? null, hits: 0 };
|
|
@@ -487,6 +553,16 @@ var createFaultRegistry = (rng = createRng(0), sleep = (ms) => new Promise((reso
|
|
|
487
553
|
},
|
|
488
554
|
clear() {
|
|
489
555
|
entries.length = 0;
|
|
556
|
+
rng.reset();
|
|
557
|
+
scopedRngs.clear();
|
|
558
|
+
},
|
|
559
|
+
restore(namespace, state) {
|
|
560
|
+
for (let i = entries.length - 1; i >= 0; i--)
|
|
561
|
+
if (entries[i]?.rule.namespace === namespace)
|
|
562
|
+
entries.splice(i, 1);
|
|
563
|
+
for (const { remaining, hits, position, ...rule } of state.rules)
|
|
564
|
+
entries.splice(Math.min(position, entries.length), 0, { rule, remaining, hits });
|
|
565
|
+
random(namespace).setState(state.rngState);
|
|
490
566
|
},
|
|
491
567
|
async take(candidate) {
|
|
492
568
|
const hits = [];
|
|
@@ -496,7 +572,7 @@ var createFaultRegistry = (rng = createRng(0), sleep = (ms) => new Promise((reso
|
|
|
496
572
|
if (!matches(entry.rule, candidate))
|
|
497
573
|
continue;
|
|
498
574
|
const rate = entry.rule.rate ?? 1;
|
|
499
|
-
if (
|
|
575
|
+
if (random(candidate.namespace).next() >= rate)
|
|
500
576
|
continue;
|
|
501
577
|
entry.hits++;
|
|
502
578
|
if (entry.remaining !== null)
|
|
@@ -1124,7 +1200,8 @@ var annotateResponse = (response, extra) => {
|
|
|
1124
1200
|
var responseNotes = (response) => notes.get(response);
|
|
1125
1201
|
|
|
1126
1202
|
// ../core/dist/metrics.js
|
|
1127
|
-
var createMetrics = () => {
|
|
1203
|
+
var createMetrics = (partition = true) => {
|
|
1204
|
+
const namespaces = /* @__PURE__ */ new Map();
|
|
1128
1205
|
let requests = 0;
|
|
1129
1206
|
let faults = 0;
|
|
1130
1207
|
let totalDurationMs = 0;
|
|
@@ -1132,6 +1209,14 @@ var createMetrics = () => {
|
|
|
1132
1209
|
const unmatched = /* @__PURE__ */ new Map();
|
|
1133
1210
|
return {
|
|
1134
1211
|
record(entry) {
|
|
1212
|
+
if (partition) {
|
|
1213
|
+
let scoped = namespaces.get(entry.namespace);
|
|
1214
|
+
if (!scoped) {
|
|
1215
|
+
scoped = createMetrics(false);
|
|
1216
|
+
namespaces.set(entry.namespace, scoped);
|
|
1217
|
+
}
|
|
1218
|
+
scoped.record(entry);
|
|
1219
|
+
}
|
|
1135
1220
|
requests++;
|
|
1136
1221
|
totalDurationMs += entry.durationMs;
|
|
1137
1222
|
if (entry.faultId !== void 0)
|
|
@@ -1143,7 +1228,7 @@ var createMetrics = () => {
|
|
|
1143
1228
|
unmatched.set(route, (unmatched.get(route) ?? 0) + 1);
|
|
1144
1229
|
}
|
|
1145
1230
|
},
|
|
1146
|
-
report: () => ({
|
|
1231
|
+
report: (namespace) => namespace !== void 0 ? (namespaces.get(namespace) ?? createMetrics(false)).report() : {
|
|
1147
1232
|
requests,
|
|
1148
1233
|
byOperation: Object.fromEntries([...byOperation].sort(([a], [b]) => a.localeCompare(b))),
|
|
1149
1234
|
unmatched: [...unmatched].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([route, count]) => {
|
|
@@ -1152,8 +1237,13 @@ var createMetrics = () => {
|
|
|
1152
1237
|
}),
|
|
1153
1238
|
faults,
|
|
1154
1239
|
totalDurationMs
|
|
1155
|
-
}
|
|
1156
|
-
reset() {
|
|
1240
|
+
},
|
|
1241
|
+
reset(namespace) {
|
|
1242
|
+
if (namespace !== void 0) {
|
|
1243
|
+
namespaces.delete(namespace);
|
|
1244
|
+
return;
|
|
1245
|
+
}
|
|
1246
|
+
namespaces.clear();
|
|
1157
1247
|
requests = 0;
|
|
1158
1248
|
faults = 0;
|
|
1159
1249
|
totalDurationMs = 0;
|
|
@@ -1766,6 +1856,34 @@ dialog:not([open]) {
|
|
|
1766
1856
|
function isRecord2(value) {
|
|
1767
1857
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1768
1858
|
}
|
|
1859
|
+
function highlightJsonText(text) {
|
|
1860
|
+
const escapeToken = (value) => value.replace(/[&<>"']/g, (char) => {
|
|
1861
|
+
switch (char) {
|
|
1862
|
+
case "&":
|
|
1863
|
+
return "&";
|
|
1864
|
+
case "<":
|
|
1865
|
+
return "<";
|
|
1866
|
+
case ">":
|
|
1867
|
+
return ">";
|
|
1868
|
+
case '"':
|
|
1869
|
+
return """;
|
|
1870
|
+
default:
|
|
1871
|
+
return "'";
|
|
1872
|
+
}
|
|
1873
|
+
});
|
|
1874
|
+
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;
|
|
1875
|
+
let cursor = 0;
|
|
1876
|
+
let html = "";
|
|
1877
|
+
for (const match of text.matchAll(token)) {
|
|
1878
|
+
const index = match.index ?? 0;
|
|
1879
|
+
const value = match[0];
|
|
1880
|
+
html += escapeToken(text.slice(cursor, index));
|
|
1881
|
+
const kind = value.startsWith('"') ? value.trimEnd().endsWith(":") ? "key" : "string" : value === "true" || value === "false" ? "boolean" : value === "null" ? "null" : "number";
|
|
1882
|
+
html += `<span class="json-${kind}">${escapeToken(value)}</span>`;
|
|
1883
|
+
cursor = index + value.length;
|
|
1884
|
+
}
|
|
1885
|
+
return html + escapeToken(text.slice(cursor));
|
|
1886
|
+
}
|
|
1769
1887
|
function mountAdminBrand(doc, host, service, catalog) {
|
|
1770
1888
|
const clip = (value, max) => {
|
|
1771
1889
|
if (typeof value !== "string")
|
|
@@ -2127,14 +2245,16 @@ function bootAdmin(config) {
|
|
|
2127
2245
|
const state = {
|
|
2128
2246
|
namespace: "default",
|
|
2129
2247
|
key: sessionStorage.getItem("mockingbird-admin-key") || "",
|
|
2130
|
-
view: "overview",
|
|
2248
|
+
view: ["overview", "state", "clock", "faults", "journal", "routes"].includes(location.hash.slice(1)) ? location.hash.slice(1) : "overview",
|
|
2131
2249
|
collection: "",
|
|
2132
2250
|
shape: null,
|
|
2133
2251
|
route: null,
|
|
2252
|
+
routes: [],
|
|
2134
2253
|
editing: null
|
|
2135
2254
|
};
|
|
2136
2255
|
const standard = new Set(config.standardRoutes);
|
|
2137
2256
|
const banner = el("banner", HTMLElement);
|
|
2257
|
+
const bannerMessage = el("banner-message", HTMLElement);
|
|
2138
2258
|
const keyInput = el("admin-key", HTMLInputElement);
|
|
2139
2259
|
keyInput.value = state.key;
|
|
2140
2260
|
const params = new URLSearchParams(location.search);
|
|
@@ -2145,18 +2265,21 @@ function bootAdmin(config) {
|
|
|
2145
2265
|
sessionStorage.setItem("mockingbird-admin-key", state.key);
|
|
2146
2266
|
params.delete("key");
|
|
2147
2267
|
const next = params.toString();
|
|
2148
|
-
history.replaceState(null, "", location.pathname + (next ? `?${next}` : ""));
|
|
2268
|
+
history.replaceState(null, "", location.pathname + (next ? `?${next}` : "") + location.hash);
|
|
2149
2269
|
}
|
|
2150
2270
|
const queryNamespace = params.get("namespace");
|
|
2151
2271
|
if (queryNamespace)
|
|
2152
2272
|
state.namespace = queryNamespace;
|
|
2153
2273
|
const showError = (error2) => {
|
|
2154
|
-
|
|
2274
|
+
bannerMessage.textContent = error2 instanceof Error ? error2.message : String(error2);
|
|
2155
2275
|
banner.classList.add("show");
|
|
2276
|
+
banner.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
2156
2277
|
};
|
|
2157
2278
|
const clearError = () => {
|
|
2158
2279
|
banner.classList.remove("show");
|
|
2280
|
+
bannerMessage.textContent = "";
|
|
2159
2281
|
};
|
|
2282
|
+
el("banner-dismiss", HTMLButtonElement).addEventListener("click", clearError);
|
|
2160
2283
|
const api = async (method, path, body) => {
|
|
2161
2284
|
const headers = { accept: "application/json" };
|
|
2162
2285
|
if (state.key !== "")
|
|
@@ -2200,16 +2323,21 @@ function bootAdmin(config) {
|
|
|
2200
2323
|
namespace: () => state.namespace
|
|
2201
2324
|
};
|
|
2202
2325
|
const isPanelScript = (value) => typeof value === "function";
|
|
2326
|
+
const themeButton = el("theme", HTMLButtonElement);
|
|
2203
2327
|
const setTheme = (theme) => {
|
|
2204
2328
|
if (theme)
|
|
2205
2329
|
document.documentElement.dataset.theme = theme;
|
|
2206
2330
|
else
|
|
2207
2331
|
delete document.documentElement.dataset.theme;
|
|
2332
|
+
const dark = theme ? theme === "dark" : matchMedia("(prefers-color-scheme: dark)").matches;
|
|
2333
|
+
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>';
|
|
2334
|
+
const label = dark ? "Use light theme" : "Use dark theme";
|
|
2335
|
+
themeButton.setAttribute("aria-label", label);
|
|
2336
|
+
themeButton.title = label;
|
|
2208
2337
|
};
|
|
2209
2338
|
const storedTheme = localStorage.getItem("mockingbird-admin-theme");
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
el("theme", HTMLButtonElement).addEventListener("click", () => {
|
|
2339
|
+
setTheme(storedTheme === "dark" || storedTheme === "light" ? storedTheme : null);
|
|
2340
|
+
themeButton.addEventListener("click", () => {
|
|
2213
2341
|
const current = document.documentElement.dataset.theme;
|
|
2214
2342
|
const dark = current ? current === "dark" : matchMedia("(prefers-color-scheme: dark)").matches;
|
|
2215
2343
|
const next = dark ? "light" : "dark";
|
|
@@ -2228,6 +2356,7 @@ function bootAdmin(config) {
|
|
|
2228
2356
|
continue;
|
|
2229
2357
|
section.hidden = section.id !== `view-${view}`;
|
|
2230
2358
|
}
|
|
2359
|
+
history.replaceState(null, "", `${location.pathname}${location.search}#${encodeURIComponent(view)}`);
|
|
2231
2360
|
};
|
|
2232
2361
|
el("nav", HTMLElement).addEventListener("click", (event) => {
|
|
2233
2362
|
const target = event.target;
|
|
@@ -2242,7 +2371,7 @@ function bootAdmin(config) {
|
|
|
2242
2371
|
show(view);
|
|
2243
2372
|
refresh().catch(showError);
|
|
2244
2373
|
});
|
|
2245
|
-
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>`;
|
|
2374
|
+
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>`;
|
|
2246
2375
|
const table = (columns, rows) => {
|
|
2247
2376
|
if (rows.length === 0)
|
|
2248
2377
|
return '<p class="empty">Nothing here yet.</p>';
|
|
@@ -2252,16 +2381,22 @@ function bootAdmin(config) {
|
|
|
2252
2381
|
const attrs = "attrs" in row && typeof row.attrs === "string" ? row.attrs : "";
|
|
2253
2382
|
return `<tr${attrs}>${cells}</tr>`;
|
|
2254
2383
|
}).join("");
|
|
2255
|
-
return `<table><thead>${head}</thead><tbody>${body}</tbody></table>`;
|
|
2384
|
+
return `<div class="table-shell"><table><thead>${head}</thead><tbody>${body}</tbody></table></div>`;
|
|
2256
2385
|
};
|
|
2257
2386
|
const preview = (value) => {
|
|
2258
2387
|
const text = JSON.stringify(value) ?? "null";
|
|
2259
|
-
|
|
2388
|
+
const clipped = text.length > 180 ? `${text.slice(0, 180)}\u2026` : text;
|
|
2389
|
+
return `<code class="json-inline">${highlightJsonText(clipped)}</code>`;
|
|
2260
2390
|
};
|
|
2261
2391
|
const when = (epoch) => {
|
|
2262
2392
|
const date = new Date(epoch);
|
|
2263
2393
|
return Number.isNaN(date.getTime()) ? String(epoch) : date.toISOString();
|
|
2264
2394
|
};
|
|
2395
|
+
const journalWhen = (value) => {
|
|
2396
|
+
const numeric = value.trim() === "" ? Number.NaN : Number(value);
|
|
2397
|
+
const epoch = Number.isFinite(numeric) ? numeric : Date.parse(value);
|
|
2398
|
+
return Number.isFinite(epoch) ? when(epoch) : value;
|
|
2399
|
+
};
|
|
2265
2400
|
const clockCard = (epoch) => {
|
|
2266
2401
|
const date = new Date(epoch);
|
|
2267
2402
|
if (Number.isNaN(date.getTime()))
|
|
@@ -2381,7 +2516,7 @@ function bootAdmin(config) {
|
|
|
2381
2516
|
};
|
|
2382
2517
|
const renderOverview = async () => {
|
|
2383
2518
|
const [health, shape, clock, journal] = await Promise.all([
|
|
2384
|
-
originGet(
|
|
2519
|
+
originGet(`${config.adminPrefix}/health`),
|
|
2385
2520
|
api("GET", "/state"),
|
|
2386
2521
|
api("GET", "/clock"),
|
|
2387
2522
|
api("GET", "/requests?limit=8")
|
|
@@ -2398,7 +2533,7 @@ function bootAdmin(config) {
|
|
|
2398
2533
|
},
|
|
2399
2534
|
{
|
|
2400
2535
|
k: "Status",
|
|
2401
|
-
v: esc(typeof health.status === "string" && health.status !== "" ? health.status : "ok")
|
|
2536
|
+
v: `<span class="badge ok">${esc(typeof health.status === "string" && health.status !== "" ? health.status : "ok")}</span>`
|
|
2402
2537
|
},
|
|
2403
2538
|
{ k: "Namespace", v: esc(state.namespace) },
|
|
2404
2539
|
{ k: "Collections", v: String(decoded.collections.length) },
|
|
@@ -2485,26 +2620,46 @@ function bootAdmin(config) {
|
|
|
2485
2620
|
const renderJournal = async () => {
|
|
2486
2621
|
const journal = await api("GET", "/requests?limit=100");
|
|
2487
2622
|
el("journal", HTMLElement).innerHTML = table([
|
|
2488
|
-
{ label: "When", cell: (row) => esc(row.at) },
|
|
2489
|
-
{
|
|
2623
|
+
{ label: "When", cell: (row) => esc(journalWhen(row.at)) },
|
|
2624
|
+
{
|
|
2625
|
+
label: "Method",
|
|
2626
|
+
cell: (row) => `<span class="method">${esc(row.method)}</span>`
|
|
2627
|
+
},
|
|
2490
2628
|
{ label: "Path", cell: (row) => esc(row.path) },
|
|
2491
|
-
{
|
|
2629
|
+
{
|
|
2630
|
+
label: "Status",
|
|
2631
|
+
cell: (row) => `<span class="badge ${row.status.startsWith("2") ? "ok" : row.status.startsWith("4") || row.status.startsWith("5") ? "warn" : ""}">${esc(row.status)}</span>`
|
|
2632
|
+
},
|
|
2492
2633
|
{ label: "ms", cell: (row) => esc(row.durationMs) }
|
|
2493
2634
|
], decodeJournal(journal));
|
|
2494
2635
|
};
|
|
2495
|
-
const
|
|
2496
|
-
const
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2636
|
+
const paintRoutes = () => {
|
|
2637
|
+
const query = el("route-search", HTMLInputElement).value.trim().toLocaleLowerCase();
|
|
2638
|
+
const routes = state.routes.filter((route) => route.toLocaleLowerCase().includes(query));
|
|
2639
|
+
el("route-count", HTMLElement).textContent = `${routes.length} of ${state.routes.length}`;
|
|
2640
|
+
if (state.routes.length === 0) {
|
|
2641
|
+
el("route-list", HTMLElement).innerHTML = '<p class="empty">No admin routes are available.</p>';
|
|
2642
|
+
return;
|
|
2643
|
+
}
|
|
2644
|
+
if (routes.length === 0) {
|
|
2645
|
+
el("route-list", HTMLElement).innerHTML = '<p class="empty">No routes match this filter.</p>';
|
|
2646
|
+
return;
|
|
2647
|
+
}
|
|
2500
2648
|
el("route-list", HTMLElement).innerHTML = routes.map((route) => {
|
|
2501
2649
|
const extra = standard.has(route) ? "" : " <span class='badge'>extension</span>";
|
|
2502
2650
|
const parts = route.split(" ");
|
|
2503
2651
|
const method = parts[0] ?? "";
|
|
2504
2652
|
const path = parts.slice(1).join(" ");
|
|
2505
|
-
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>`;
|
|
2653
|
+
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>`;
|
|
2506
2654
|
}).join("");
|
|
2507
2655
|
};
|
|
2656
|
+
const renderRoutes = async () => {
|
|
2657
|
+
const data = await api("GET", "/");
|
|
2658
|
+
if (!isRecord2(data))
|
|
2659
|
+
throw new Error("Route list was not an object");
|
|
2660
|
+
state.routes = requireList(data.routes, "Routes").map((route) => String(route));
|
|
2661
|
+
paintRoutes();
|
|
2662
|
+
};
|
|
2508
2663
|
const renderers = {
|
|
2509
2664
|
overview: renderOverview,
|
|
2510
2665
|
state: renderState,
|
|
@@ -2513,19 +2668,50 @@ function bootAdmin(config) {
|
|
|
2513
2668
|
journal: renderJournal,
|
|
2514
2669
|
routes: renderRoutes
|
|
2515
2670
|
};
|
|
2671
|
+
let refreshToken = 0;
|
|
2516
2672
|
async function refresh() {
|
|
2673
|
+
const token = ++refreshToken;
|
|
2517
2674
|
clearError();
|
|
2675
|
+
const main = el("views", HTMLElement);
|
|
2676
|
+
const sync = el("sync-status", HTMLElement);
|
|
2677
|
+
main.setAttribute("aria-busy", "true");
|
|
2678
|
+
sync.classList.add("busy");
|
|
2679
|
+
sync.textContent = "Updating";
|
|
2518
2680
|
const render = renderers[state.view];
|
|
2519
|
-
|
|
2520
|
-
|
|
2681
|
+
try {
|
|
2682
|
+
if (render)
|
|
2683
|
+
await render();
|
|
2684
|
+
if (token === refreshToken)
|
|
2685
|
+
sync.textContent = "Up to date";
|
|
2686
|
+
} finally {
|
|
2687
|
+
if (token === refreshToken) {
|
|
2688
|
+
main.removeAttribute("aria-busy");
|
|
2689
|
+
sync.classList.remove("busy");
|
|
2690
|
+
}
|
|
2691
|
+
}
|
|
2521
2692
|
}
|
|
2522
2693
|
const delay = (ms) => new Promise((resolve) => {
|
|
2523
2694
|
window.setTimeout(resolve, ms);
|
|
2524
2695
|
});
|
|
2525
|
-
const confirmAction = async (button, pending, done, work) => {
|
|
2696
|
+
const confirmAction = async (button, pending, done, work, confirmLabel) => {
|
|
2526
2697
|
if (button.dataset.pending === "1")
|
|
2527
2698
|
return;
|
|
2528
2699
|
const label = button.textContent ?? "";
|
|
2700
|
+
if (confirmLabel !== void 0 && button.dataset.confirming !== "1") {
|
|
2701
|
+
button.dataset.confirming = "1";
|
|
2702
|
+
button.classList.add("confirming");
|
|
2703
|
+
button.textContent = confirmLabel;
|
|
2704
|
+
window.setTimeout(() => {
|
|
2705
|
+
if (button.dataset.confirming !== "1")
|
|
2706
|
+
return;
|
|
2707
|
+
button.textContent = label;
|
|
2708
|
+
button.classList.remove("confirming");
|
|
2709
|
+
delete button.dataset.confirming;
|
|
2710
|
+
}, 3e3);
|
|
2711
|
+
return;
|
|
2712
|
+
}
|
|
2713
|
+
button.classList.remove("confirming");
|
|
2714
|
+
delete button.dataset.confirming;
|
|
2529
2715
|
const width = button.offsetWidth;
|
|
2530
2716
|
button.dataset.pending = "1";
|
|
2531
2717
|
button.classList.add("pressed");
|
|
@@ -2546,6 +2732,65 @@ function bootAdmin(config) {
|
|
|
2546
2732
|
delete button.dataset.pending;
|
|
2547
2733
|
}
|
|
2548
2734
|
};
|
|
2735
|
+
const wireJsonEditor = (textareaId, highlightId, statusId, shellId, allowEmpty) => {
|
|
2736
|
+
const textarea = el(textareaId, HTMLTextAreaElement);
|
|
2737
|
+
const highlight = el(highlightId, HTMLElement);
|
|
2738
|
+
const status = el(statusId, HTMLElement);
|
|
2739
|
+
const shell = el(shellId, HTMLElement);
|
|
2740
|
+
const sync = () => {
|
|
2741
|
+
const text = textarea.value;
|
|
2742
|
+
highlight.innerHTML = `${highlightJsonText(text)}
|
|
2743
|
+
`;
|
|
2744
|
+
let valid = true;
|
|
2745
|
+
let message = "Valid JSON";
|
|
2746
|
+
if (allowEmpty && text.trim() === "")
|
|
2747
|
+
message = "No body";
|
|
2748
|
+
else {
|
|
2749
|
+
try {
|
|
2750
|
+
readJson2(text);
|
|
2751
|
+
} catch {
|
|
2752
|
+
valid = false;
|
|
2753
|
+
message = "Invalid JSON";
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
shell.classList.toggle("invalid", !valid);
|
|
2757
|
+
status.classList.toggle("invalid", !valid);
|
|
2758
|
+
status.textContent = message;
|
|
2759
|
+
textarea.setAttribute("aria-invalid", valid ? "false" : "true");
|
|
2760
|
+
};
|
|
2761
|
+
const syncScroll = () => {
|
|
2762
|
+
const preview2 = highlight.parentElement;
|
|
2763
|
+
if (!(preview2 instanceof HTMLElement))
|
|
2764
|
+
return;
|
|
2765
|
+
preview2.scrollTop = textarea.scrollTop;
|
|
2766
|
+
preview2.scrollLeft = textarea.scrollLeft;
|
|
2767
|
+
};
|
|
2768
|
+
textarea.addEventListener("input", sync);
|
|
2769
|
+
textarea.addEventListener("scroll", syncScroll);
|
|
2770
|
+
sync();
|
|
2771
|
+
return sync;
|
|
2772
|
+
};
|
|
2773
|
+
const syncRouteEditor = wireJsonEditor("route-body", "route-highlight", "route-json-status", "route-editor", true);
|
|
2774
|
+
const syncRecordEditor = wireJsonEditor("editor-value", "editor-highlight", "editor-json-status", "record-editor", false);
|
|
2775
|
+
for (const button of document.querySelectorAll("[data-format]")) {
|
|
2776
|
+
if (!(button instanceof HTMLButtonElement))
|
|
2777
|
+
continue;
|
|
2778
|
+
button.addEventListener("click", () => {
|
|
2779
|
+
const target = button.dataset.format;
|
|
2780
|
+
if (target === void 0)
|
|
2781
|
+
return;
|
|
2782
|
+
const textarea = document.getElementById(target);
|
|
2783
|
+
if (!(textarea instanceof HTMLTextAreaElement) || textarea.value.trim() === "")
|
|
2784
|
+
return;
|
|
2785
|
+
try {
|
|
2786
|
+
textarea.value = JSON.stringify(readJson2(textarea.value), null, 2) ?? "";
|
|
2787
|
+
textarea.dispatchEvent(new Event("input"));
|
|
2788
|
+
textarea.focus();
|
|
2789
|
+
} catch {
|
|
2790
|
+
showError(new Error("Fix the JSON before formatting it"));
|
|
2791
|
+
}
|
|
2792
|
+
});
|
|
2793
|
+
}
|
|
2549
2794
|
document.addEventListener("click", (event) => {
|
|
2550
2795
|
const target = event.target;
|
|
2551
2796
|
if (!(target instanceof Element))
|
|
@@ -2618,6 +2863,7 @@ function bootAdmin(config) {
|
|
|
2618
2863
|
} else {
|
|
2619
2864
|
editorValue.value = "{\n \n}";
|
|
2620
2865
|
}
|
|
2866
|
+
syncRecordEditor();
|
|
2621
2867
|
editor.showModal();
|
|
2622
2868
|
}
|
|
2623
2869
|
el("new-record", HTMLButtonElement).addEventListener("click", () => {
|
|
@@ -2647,10 +2893,10 @@ function bootAdmin(config) {
|
|
|
2647
2893
|
const id = state.editing;
|
|
2648
2894
|
if (!id)
|
|
2649
2895
|
return;
|
|
2650
|
-
api("DELETE", `/state/${encodeURIComponent(state.collection)}/${encodeURIComponent(id)}`).then(() => {
|
|
2896
|
+
confirmAction(editorDelete, "Deleting...", "Deleted", () => api("DELETE", `/state/${encodeURIComponent(state.collection)}/${encodeURIComponent(id)}`).then(() => {
|
|
2651
2897
|
editor.close();
|
|
2652
2898
|
return renderState();
|
|
2653
|
-
}).catch(showError);
|
|
2899
|
+
}), "Confirm delete").catch(showError);
|
|
2654
2900
|
});
|
|
2655
2901
|
for (const button of document.querySelectorAll("[data-advance]")) {
|
|
2656
2902
|
if (!(button instanceof HTMLButtonElement))
|
|
@@ -2696,10 +2942,10 @@ function bootAdmin(config) {
|
|
|
2696
2942
|
}).then(() => renderFaults()).catch(showError);
|
|
2697
2943
|
});
|
|
2698
2944
|
el("fault-clear", HTMLButtonElement).addEventListener("click", () => {
|
|
2699
|
-
confirmAction(el("fault-clear", HTMLButtonElement), "Clearing...", "Cleared", () => api("DELETE", "/faults").then(() => renderFaults())).catch(showError);
|
|
2945
|
+
confirmAction(el("fault-clear", HTMLButtonElement), "Clearing...", "Cleared", () => api("DELETE", "/faults").then(() => renderFaults()), "Confirm clear").catch(showError);
|
|
2700
2946
|
});
|
|
2701
2947
|
el("journal-clear", HTMLButtonElement).addEventListener("click", () => {
|
|
2702
|
-
confirmAction(el("journal-clear", HTMLButtonElement), "Clearing...", "Cleared", () => api("DELETE", "/requests").then(() => renderJournal())).catch(showError);
|
|
2948
|
+
confirmAction(el("journal-clear", HTMLButtonElement), "Clearing...", "Cleared", () => api("DELETE", "/requests").then(() => renderJournal()), "Confirm clear").catch(showError);
|
|
2703
2949
|
});
|
|
2704
2950
|
el("route-list", HTMLElement).addEventListener("click", (event) => {
|
|
2705
2951
|
const target = event.target;
|
|
@@ -2713,9 +2959,15 @@ function bootAdmin(config) {
|
|
|
2713
2959
|
return;
|
|
2714
2960
|
state.route = route;
|
|
2715
2961
|
el("route-title", HTMLElement).textContent = route;
|
|
2962
|
+
el("route-send", HTMLButtonElement).disabled = false;
|
|
2716
2963
|
const method = route.split(" ")[0] ?? "";
|
|
2717
|
-
el("route-body", HTMLTextAreaElement)
|
|
2964
|
+
const routeBody = el("route-body", HTMLTextAreaElement);
|
|
2965
|
+
routeBody.disabled = method === "GET" || method === "DELETE";
|
|
2966
|
+
el("route-editor", HTMLElement).hidden = routeBody.disabled;
|
|
2967
|
+
el("route-json-status", HTMLElement).parentElement?.toggleAttribute("hidden", routeBody.disabled);
|
|
2968
|
+
syncRouteEditor();
|
|
2718
2969
|
});
|
|
2970
|
+
el("route-search", HTMLInputElement).addEventListener("input", paintRoutes);
|
|
2719
2971
|
el("route-form", HTMLFormElement).addEventListener("submit", (event) => {
|
|
2720
2972
|
event.preventDefault();
|
|
2721
2973
|
const send = async () => {
|
|
@@ -2737,7 +2989,8 @@ function bootAdmin(config) {
|
|
|
2737
2989
|
}
|
|
2738
2990
|
}
|
|
2739
2991
|
const data = await api(method, concrete, body);
|
|
2740
|
-
|
|
2992
|
+
const text = JSON.stringify(data, null, 2) ?? "null";
|
|
2993
|
+
el("route-result", HTMLElement).innerHTML = `<code>${highlightJsonText(text)}</code>`;
|
|
2741
2994
|
};
|
|
2742
2995
|
send().catch(showError);
|
|
2743
2996
|
});
|
|
@@ -2855,11 +3108,13 @@ function bootAdmin(config) {
|
|
|
2855
3108
|
views.append(section);
|
|
2856
3109
|
mountSqlExplorer(body, panelApi);
|
|
2857
3110
|
}
|
|
3111
|
+
show(document.getElementById(`view-${state.view}`) === null ? "overview" : state.view);
|
|
2858
3112
|
return refresh();
|
|
2859
3113
|
}).catch(showError);
|
|
2860
3114
|
}
|
|
2861
3115
|
var clientPrelude = [
|
|
2862
3116
|
isRecord2,
|
|
3117
|
+
highlightJsonText,
|
|
2863
3118
|
mountAdminBrand,
|
|
2864
3119
|
startAdminBrand,
|
|
2865
3120
|
faultPresetList,
|
|
@@ -2882,6 +3137,7 @@ ${entry}(${payload});
|
|
|
2882
3137
|
var defineMock = (runtime) => runtime;
|
|
2883
3138
|
var STANDARD_ADMIN_ROUTES = [
|
|
2884
3139
|
"GET /",
|
|
3140
|
+
"GET /health",
|
|
2885
3141
|
"POST /reset",
|
|
2886
3142
|
"GET /namespaces",
|
|
2887
3143
|
"GET /clock",
|
|
@@ -2961,11 +3217,11 @@ var escapeHtml = (value) => value.replace(/[&<>"']/g, (char) => {
|
|
|
2961
3217
|
}
|
|
2962
3218
|
});
|
|
2963
3219
|
var ADMIN_BRANDS_URL = "https://mockingbird.chrisvouga.dev/brands.json";
|
|
2964
|
-
var renderAdminDocument = (service) => {
|
|
3220
|
+
var renderAdminDocument = (service, adminPrefix = ADMIN_PREFIX) => {
|
|
2965
3221
|
const name = escapeHtml(service);
|
|
2966
3222
|
const script = adminClientSource({
|
|
2967
3223
|
standardRoutes: STANDARD_ADMIN_ROUTES,
|
|
2968
|
-
adminPrefix
|
|
3224
|
+
adminPrefix,
|
|
2969
3225
|
adminKeyHeader: ADMIN_KEY_HEADER,
|
|
2970
3226
|
brandsUrl: ADMIN_BRANDS_URL,
|
|
2971
3227
|
service
|
|
@@ -2982,75 +3238,99 @@ var renderAdminDocument = (service) => {
|
|
|
2982
3238
|
${CSS_RESET}
|
|
2983
3239
|
:root {
|
|
2984
3240
|
color-scheme: light;
|
|
2985
|
-
--bg: #
|
|
3241
|
+
--bg: #f7f8fb;
|
|
2986
3242
|
--bg-elev: #ffffff;
|
|
2987
|
-
--bg-muted: #
|
|
2988
|
-
--bg-inset: #
|
|
2989
|
-
--line: #
|
|
2990
|
-
--line-strong: #
|
|
2991
|
-
--ink: #
|
|
2992
|
-
--muted: #
|
|
2993
|
-
--faint: #
|
|
2994
|
-
--accent: #
|
|
3243
|
+
--bg-muted: #f1f3f7;
|
|
3244
|
+
--bg-inset: #f8f9fc;
|
|
3245
|
+
--line: #e4e7ec;
|
|
3246
|
+
--line-strong: #cfd4dc;
|
|
3247
|
+
--ink: #101828;
|
|
3248
|
+
--muted: #475467;
|
|
3249
|
+
--faint: #667085;
|
|
3250
|
+
--accent: #6941c6;
|
|
3251
|
+
--accent-hover: #5933b4;
|
|
2995
3252
|
--accent-ink: #ffffff;
|
|
2996
|
-
--accent-soft: #
|
|
2997
|
-
--ok: #
|
|
2998
|
-
--ok-soft: #
|
|
2999
|
-
--warn: #
|
|
3000
|
-
--warn-soft: #
|
|
3001
|
-
--err: #
|
|
3002
|
-
--err-soft: #
|
|
3003
|
-
--
|
|
3253
|
+
--accent-soft: #f4f0ff;
|
|
3254
|
+
--ok: #067647;
|
|
3255
|
+
--ok-soft: #ecfdf3;
|
|
3256
|
+
--warn: #b54708;
|
|
3257
|
+
--warn-soft: #fffaeb;
|
|
3258
|
+
--err: #b42318;
|
|
3259
|
+
--err-soft: #fef3f2;
|
|
3260
|
+
--code-key: #6941c6;
|
|
3261
|
+
--code-string: #067647;
|
|
3262
|
+
--code-number: #175cd3;
|
|
3263
|
+
--code-boolean: #c11574;
|
|
3264
|
+
--code-null: #667085;
|
|
3265
|
+
--shadow-xs: 0 1px 2px rgb(16 24 40 / 0.05);
|
|
3266
|
+
--shadow-sm: 0 1px 3px rgb(16 24 40 / 0.08), 0 1px 2px rgb(16 24 40 / 0.04);
|
|
3267
|
+
--shadow-lg: 0 18px 48px rgb(16 24 40 / 0.16), 0 4px 12px rgb(16 24 40 / 0.08);
|
|
3004
3268
|
--sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
3005
3269
|
--mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
|
|
3006
|
-
--radius:
|
|
3007
|
-
--header:
|
|
3008
|
-
--nav:
|
|
3270
|
+
--radius: 12px;
|
|
3271
|
+
--header: 72px;
|
|
3272
|
+
--nav: 224px;
|
|
3009
3273
|
}
|
|
3010
3274
|
:root[data-theme="dark"] {
|
|
3011
3275
|
color-scheme: dark;
|
|
3012
|
-
--bg: #
|
|
3013
|
-
--bg-elev: #
|
|
3014
|
-
--bg-muted: #
|
|
3015
|
-
--bg-inset: #
|
|
3016
|
-
--line: #
|
|
3017
|
-
--line-strong: #
|
|
3018
|
-
--ink: #
|
|
3019
|
-
--muted: #
|
|
3020
|
-
--faint: #
|
|
3021
|
-
--accent: #
|
|
3022
|
-
--accent-
|
|
3023
|
-
--accent-
|
|
3024
|
-
--
|
|
3025
|
-
--ok
|
|
3026
|
-
--
|
|
3027
|
-
--warn
|
|
3028
|
-
--
|
|
3029
|
-
--err
|
|
3030
|
-
--
|
|
3276
|
+
--bg: #0c0e14;
|
|
3277
|
+
--bg-elev: #151821;
|
|
3278
|
+
--bg-muted: #20232e;
|
|
3279
|
+
--bg-inset: #11141c;
|
|
3280
|
+
--line: #2b303d;
|
|
3281
|
+
--line-strong: #414858;
|
|
3282
|
+
--ink: #f5f7fa;
|
|
3283
|
+
--muted: #b6bdc9;
|
|
3284
|
+
--faint: #8d96a7;
|
|
3285
|
+
--accent: #9e77ed;
|
|
3286
|
+
--accent-hover: #b692f6;
|
|
3287
|
+
--accent-ink: #ffffff;
|
|
3288
|
+
--accent-soft: #2b2142;
|
|
3289
|
+
--ok: #75e0a7;
|
|
3290
|
+
--ok-soft: #102a20;
|
|
3291
|
+
--warn: #fec84b;
|
|
3292
|
+
--warn-soft: #302611;
|
|
3293
|
+
--err: #fda29b;
|
|
3294
|
+
--err-soft: #321817;
|
|
3295
|
+
--code-key: #c3a6ff;
|
|
3296
|
+
--code-string: #75e0a7;
|
|
3297
|
+
--code-number: #84adff;
|
|
3298
|
+
--code-boolean: #f9a8d4;
|
|
3299
|
+
--code-null: #98a2b3;
|
|
3300
|
+
--shadow-xs: 0 1px 2px rgb(0 0 0 / 0.24);
|
|
3301
|
+
--shadow-sm: 0 4px 12px rgb(0 0 0 / 0.2);
|
|
3302
|
+
--shadow-lg: 0 20px 56px rgb(0 0 0 / 0.45);
|
|
3031
3303
|
}
|
|
3032
3304
|
@media (prefers-color-scheme: dark) {
|
|
3033
3305
|
:root:not([data-theme="light"]) {
|
|
3034
3306
|
color-scheme: dark;
|
|
3035
|
-
--bg: #
|
|
3036
|
-
--bg-elev: #
|
|
3037
|
-
--bg-muted: #
|
|
3038
|
-
--bg-inset: #
|
|
3039
|
-
--line: #
|
|
3040
|
-
--line-strong: #
|
|
3041
|
-
--ink: #
|
|
3042
|
-
--muted: #
|
|
3043
|
-
--faint: #
|
|
3044
|
-
--accent: #
|
|
3045
|
-
--accent-
|
|
3046
|
-
--accent-
|
|
3047
|
-
--
|
|
3048
|
-
--ok
|
|
3049
|
-
--
|
|
3050
|
-
--warn
|
|
3051
|
-
--
|
|
3052
|
-
--err
|
|
3053
|
-
--
|
|
3307
|
+
--bg: #0c0e14;
|
|
3308
|
+
--bg-elev: #151821;
|
|
3309
|
+
--bg-muted: #20232e;
|
|
3310
|
+
--bg-inset: #11141c;
|
|
3311
|
+
--line: #2b303d;
|
|
3312
|
+
--line-strong: #414858;
|
|
3313
|
+
--ink: #f5f7fa;
|
|
3314
|
+
--muted: #b6bdc9;
|
|
3315
|
+
--faint: #8d96a7;
|
|
3316
|
+
--accent: #9e77ed;
|
|
3317
|
+
--accent-hover: #b692f6;
|
|
3318
|
+
--accent-ink: #ffffff;
|
|
3319
|
+
--accent-soft: #2b2142;
|
|
3320
|
+
--ok: #75e0a7;
|
|
3321
|
+
--ok-soft: #102a20;
|
|
3322
|
+
--warn: #fec84b;
|
|
3323
|
+
--warn-soft: #302611;
|
|
3324
|
+
--err: #fda29b;
|
|
3325
|
+
--err-soft: #321817;
|
|
3326
|
+
--code-key: #c3a6ff;
|
|
3327
|
+
--code-string: #75e0a7;
|
|
3328
|
+
--code-number: #84adff;
|
|
3329
|
+
--code-boolean: #f9a8d4;
|
|
3330
|
+
--code-null: #98a2b3;
|
|
3331
|
+
--shadow-xs: 0 1px 2px rgb(0 0 0 / 0.24);
|
|
3332
|
+
--shadow-sm: 0 4px 12px rgb(0 0 0 / 0.2);
|
|
3333
|
+
--shadow-lg: 0 20px 56px rgb(0 0 0 / 0.45);
|
|
3054
3334
|
}
|
|
3055
3335
|
}
|
|
3056
3336
|
/* Fill the viewport, then grow with the content so the background covers the scroll. */
|
|
@@ -3068,13 +3348,17 @@ var renderAdminDocument = (service) => {
|
|
|
3068
3348
|
padding-right: env(safe-area-inset-right);
|
|
3069
3349
|
-webkit-text-size-adjust: 100%;
|
|
3070
3350
|
}
|
|
3071
|
-
|
|
3351
|
+
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
|
|
3352
|
+
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
|
|
3353
|
+
button, input, select, textarea { transition: border-color 140ms ease, box-shadow 140ms ease, transform 100ms ease; }
|
|
3354
|
+
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: 0.55; }
|
|
3072
3355
|
.app { flex: 1 0 auto; display: flex; flex-direction: column; min-width: 0; width: 100%; }
|
|
3073
3356
|
header.top {
|
|
3074
|
-
position: sticky; top: 0; z-index:
|
|
3357
|
+
position: sticky; top: 0; z-index: 20;
|
|
3075
3358
|
display: flex; align-items: center; gap: 12px;
|
|
3076
|
-
min-height: var(--header); padding:
|
|
3077
|
-
background: var(--bg-elev);
|
|
3359
|
+
min-height: var(--header); padding: 12px 20px;
|
|
3360
|
+
background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
|
|
3361
|
+
backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
|
|
3078
3362
|
border-bottom: 1px solid var(--line);
|
|
3079
3363
|
min-width: 0; max-width: 100%;
|
|
3080
3364
|
}
|
|
@@ -3082,12 +3366,21 @@ var renderAdminDocument = (service) => {
|
|
|
3082
3366
|
display: flex; flex-flow: row wrap; align-items: center; gap: 14px;
|
|
3083
3367
|
min-width: 0; max-width: 100%; margin-right: auto;
|
|
3084
3368
|
}
|
|
3085
|
-
.brand-
|
|
3086
|
-
.brand-
|
|
3369
|
+
.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
|
|
3370
|
+
.brand-mark {
|
|
3371
|
+
width: 38px; height: 38px; display: grid; place-items: center; flex: none;
|
|
3372
|
+
border-radius: 11px; color: #fff;
|
|
3373
|
+
background: linear-gradient(145deg, #7f56d9 0%, #53389e 100%);
|
|
3374
|
+
box-shadow: 0 6px 16px rgb(105 65 198 / 0.24), inset 0 1px 0 rgb(255 255 255 / 0.25);
|
|
3375
|
+
}
|
|
3376
|
+
.brand-mark svg { width: 22px; height: 22px; }
|
|
3377
|
+
.brand-id { display: flex; flex-direction: column; min-width: 0; flex: none; line-height: 1.25; }
|
|
3378
|
+
.brand-id strong { font-size: 15px; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
3087
3379
|
.brand-id span { color: var(--faint); font-size: 12px; }
|
|
3088
3380
|
.vendor {
|
|
3089
3381
|
display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
|
|
3090
3382
|
min-width: 0; max-width: 100%; font-size: 12px; color: var(--muted);
|
|
3383
|
+
padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-inset);
|
|
3091
3384
|
}
|
|
3092
3385
|
.vendor[hidden] { display: none; }
|
|
3093
3386
|
/* Logos are drawn for a light tile, same as the docs site, so the plate stays white. */
|
|
@@ -3099,12 +3392,17 @@ var renderAdminDocument = (service) => {
|
|
|
3099
3392
|
.vendor-sep { color: var(--faint); }
|
|
3100
3393
|
.vendor-link { color: inherit; text-decoration: none; }
|
|
3101
3394
|
.vendor-link:hover { color: var(--ink); text-decoration: underline; }
|
|
3102
|
-
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items:
|
|
3103
|
-
|
|
3395
|
+
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
|
|
3396
|
+
.sync-status { align-self: center; display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 12px; white-space: nowrap; }
|
|
3397
|
+
.sync-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
|
|
3398
|
+
.sync-status.busy::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 1.2s ease-in-out infinite; }
|
|
3399
|
+
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 600; color: var(--faint); }
|
|
3104
3400
|
label.field input, label.field select, .controls input[type="password"] {
|
|
3105
|
-
background-color: var(--bg-
|
|
3106
|
-
padding:
|
|
3401
|
+
background-color: var(--bg-elev); border: 1px solid var(--line-strong); border-radius: 9px;
|
|
3402
|
+
padding: 8px 10px; min-height: 38px; line-height: 1.2; box-shadow: var(--shadow-xs);
|
|
3107
3403
|
}
|
|
3404
|
+
label.field input:hover, label.field select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 38%, var(--line-strong)); }
|
|
3405
|
+
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; }
|
|
3108
3406
|
/* A native menu ignores min-height, so Preset rendered about half as tall as
|
|
3109
3407
|
the text fields in the same form. Paint it like those fields. */
|
|
3110
3408
|
label.field select {
|
|
@@ -3121,12 +3419,20 @@ var renderAdminDocument = (service) => {
|
|
|
3121
3419
|
dialog .field > textarea { width: 100%; }
|
|
3122
3420
|
.icon-btn, .btn, .btn-primary, .btn-quiet, .btn-danger, nav.side button { cursor: pointer; }
|
|
3123
3421
|
.icon-btn, .btn, .btn-primary, .btn-quiet, .btn-danger {
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
.btn
|
|
3422
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 7px;
|
|
3423
|
+
border-radius: 9px; min-height: 38px; padding: 0 13px; border: 1px solid var(--line-strong);
|
|
3424
|
+
background: var(--bg-elev); color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1;
|
|
3425
|
+
box-shadow: var(--shadow-xs);
|
|
3426
|
+
}
|
|
3427
|
+
.icon-btn { width: 38px; padding: 0; }
|
|
3428
|
+
.icon-btn svg, .btn svg, .btn-primary svg { width: 16px; height: 16px; }
|
|
3429
|
+
.icon-btn:hover, .btn:hover { background: var(--bg-muted); border-color: var(--line-strong); }
|
|
3430
|
+
.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; }
|
|
3431
|
+
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
|
|
3432
|
+
.btn-quiet { background: transparent; border-color: transparent; box-shadow: none; }
|
|
3433
|
+
.btn-quiet:hover { background: var(--bg-muted); }
|
|
3434
|
+
.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, var(--line)); }
|
|
3435
|
+
.btn-danger:hover, .btn-danger.confirming { background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 45%, var(--line)); }
|
|
3130
3436
|
/* Held after mouseup. Clearing an empty journal changes nothing on screen,
|
|
3131
3437
|
so the press itself has to stay visible. */
|
|
3132
3438
|
.icon-btn:active, .btn:active, .btn-quiet:active, .btn-danger:active, nav.side button:active,
|
|
@@ -3142,93 +3448,159 @@ var renderAdminDocument = (service) => {
|
|
|
3142
3448
|
flex: 1 0 auto; min-width: 0;
|
|
3143
3449
|
}
|
|
3144
3450
|
nav.side {
|
|
3145
|
-
|
|
3451
|
+
position: sticky; top: var(--header); align-self: start; height: calc(100vh - var(--header));
|
|
3452
|
+
border-right: 1px solid var(--line); padding: 18px 12px;
|
|
3146
3453
|
display: flex; flex-direction: column; gap: 4px;
|
|
3147
|
-
background: var(--bg-elev);
|
|
3454
|
+
background: var(--bg-elev); overflow-y: auto;
|
|
3148
3455
|
}
|
|
3456
|
+
.nav-label { padding: 0 10px 8px; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }
|
|
3149
3457
|
nav.side button {
|
|
3458
|
+
position: relative; display: flex; align-items: center; gap: 10px; width: 100%;
|
|
3150
3459
|
text-align: left; border: 0; background: transparent; border-radius: 9px;
|
|
3151
|
-
padding: 9px 10px; min-height:
|
|
3152
|
-
}
|
|
3153
|
-
nav.side button
|
|
3154
|
-
|
|
3155
|
-
.
|
|
3156
|
-
.
|
|
3157
|
-
.
|
|
3460
|
+
padding: 9px 10px; min-height: 42px; color: var(--muted); font-size: 13px; font-weight: 550;
|
|
3461
|
+
}
|
|
3462
|
+
nav.side button:hover { background: var(--bg-muted); color: var(--ink); }
|
|
3463
|
+
nav.side button[aria-current="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
|
|
3464
|
+
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); }
|
|
3465
|
+
.nav-icon { width: 18px; height: 18px; display: grid; place-items: center; flex: none; }
|
|
3466
|
+
.nav-icon svg { width: 18px; height: 18px; }
|
|
3467
|
+
main { padding: 32px clamp(20px, 4vw, 48px) 64px; max-width: 1320px; width: 100%; min-width: 0; }
|
|
3468
|
+
main[aria-busy="true"] .view { opacity: 0.62; }
|
|
3469
|
+
.view { animation: view-in 180ms ease-out; }
|
|
3470
|
+
.view[hidden] { display: none; }
|
|
3471
|
+
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
|
|
3472
|
+
.view h2 { margin: 0 0 5px; font-size: clamp(24px, 3vw, 30px); line-height: 1.2; letter-spacing: -0.035em; }
|
|
3473
|
+
.view h3 { margin: 24px 0 10px; font-size: 15px; letter-spacing: -0.01em; }
|
|
3474
|
+
.lede { margin: 0; color: var(--muted); max-width: 72ch; font-size: 14px; }
|
|
3475
|
+
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 175px), 1fr)); gap: 14px; }
|
|
3158
3476
|
.card {
|
|
3159
3477
|
background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
|
|
3160
|
-
padding:
|
|
3478
|
+
padding: 18px; box-shadow: var(--shadow-sm);
|
|
3161
3479
|
}
|
|
3162
|
-
.card
|
|
3163
|
-
.card
|
|
3480
|
+
.stat-card { position: relative; overflow: hidden; }
|
|
3481
|
+
.stat-card::after { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: linear-gradient(90deg, var(--accent), transparent 78%); opacity: 0.7; }
|
|
3482
|
+
.card .k { color: var(--faint); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; }
|
|
3483
|
+
.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; }
|
|
3164
3484
|
.card .v .clock-time { font-size: 14px; color: var(--muted); }
|
|
3165
|
-
.
|
|
3485
|
+
.section-card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-xs); overflow: hidden; }
|
|
3486
|
+
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
|
|
3487
|
+
.section-title h3 { margin: 0; }
|
|
3488
|
+
.split { display: grid; grid-template-columns: minmax(0, 250px) minmax(0, 1fr); gap: 18px; align-items: start; }
|
|
3489
|
+
#collections { padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); box-shadow: var(--shadow-xs); }
|
|
3166
3490
|
.collection {
|
|
3167
3491
|
width: 100%; text-align: left; border: 1px solid transparent; background: transparent;
|
|
3168
|
-
border-radius:
|
|
3492
|
+
border-radius: 9px; padding: 10px 11px; min-height: 48px; color: var(--ink); cursor: pointer;
|
|
3169
3493
|
}
|
|
3170
|
-
.collection
|
|
3494
|
+
.collection:hover { background: var(--bg-muted); }
|
|
3495
|
+
.collection[aria-current="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 18%, var(--line)); color: var(--accent); }
|
|
3171
3496
|
.collection small { display: block; color: var(--faint); }
|
|
3172
3497
|
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
|
|
3173
|
-
.chip {
|
|
3174
|
-
font-family: var(--mono); font-size: 12px; background: var(--bg-muted);
|
|
3175
|
-
border-radius: 999px; padding: 4px 8px;
|
|
3176
|
-
}
|
|
3498
|
+
.chip { font-family: var(--mono); font-size: 11px; background: var(--bg-muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px; }
|
|
3177
3499
|
.chip i { color: var(--faint); font-style: normal; }
|
|
3178
3500
|
.sql-layout {
|
|
3179
3501
|
display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 16px;
|
|
3180
3502
|
}
|
|
3181
|
-
.sql-tables { display: flex; flex-direction: column; gap: 4px; max-height: 28rem; overflow: auto; }
|
|
3182
|
-
.sql-tables button { text-align: left; }
|
|
3503
|
+
.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); }
|
|
3504
|
+
.sql-tables button { text-align: left; border: 0; border-radius: 8px; padding: 9px 10px; background: transparent; color: var(--muted); cursor: pointer; }
|
|
3505
|
+
.sql-tables button:hover, .sql-tables button[aria-current="true"] { background: var(--accent-soft); color: var(--accent); }
|
|
3183
3506
|
.sql-input { font-family: var(--mono); min-height: 7rem; width: 100%; }
|
|
3184
|
-
table { width: 100%; border-
|
|
3185
|
-
|
|
3186
|
-
th {
|
|
3507
|
+
.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); }
|
|
3508
|
+
table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
3509
|
+
th, td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); vertical-align: top; }
|
|
3510
|
+
th { color: var(--faint); background: var(--bg-inset); font-weight: 650; font-size: 11px; text-transform: uppercase; letter-spacing: 0.045em; }
|
|
3511
|
+
tbody tr:last-child td { border-bottom: 0; }
|
|
3187
3512
|
tr.clickable { cursor: pointer; }
|
|
3188
|
-
tr.clickable:hover { background: var(--
|
|
3513
|
+
tr.clickable:hover { background: var(--accent-soft); }
|
|
3189
3514
|
pre, code, .mono { font-family: var(--mono); overflow-wrap: anywhere; }
|
|
3190
3515
|
pre {
|
|
3191
3516
|
margin: 0; white-space: pre-wrap; word-break: break-word;
|
|
3192
|
-
background: var(--bg-inset); border-radius: 10px; padding:
|
|
3193
|
-
}
|
|
3194
|
-
.
|
|
3517
|
+
background: var(--bg-inset); border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-size: 12px; line-height: 1.65;
|
|
3518
|
+
}
|
|
3519
|
+
.json-key { color: var(--code-key); }
|
|
3520
|
+
.json-string { color: var(--code-string); }
|
|
3521
|
+
.json-number { color: var(--code-number); }
|
|
3522
|
+
.json-boolean { color: var(--code-boolean); }
|
|
3523
|
+
.json-null { color: var(--code-null); font-style: italic; }
|
|
3524
|
+
.json-inline { display: block; max-width: 44rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
|
3525
|
+
.json-view { position: relative; max-height: 26rem; overflow: auto; }
|
|
3526
|
+
.json-editor { position: relative; min-height: 190px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg-inset); overflow: hidden; }
|
|
3527
|
+
.json-editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
|
|
3528
|
+
.json-editor.invalid { border-color: var(--err); }
|
|
3529
|
+
.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; }
|
|
3530
|
+
.json-editor pre { position: absolute; inset: 0; pointer-events: none; background: transparent; }
|
|
3531
|
+
.json-editor textarea { position: relative; z-index: 1; resize: vertical; background: transparent; color: transparent; caret-color: var(--ink); -webkit-text-fill-color: transparent; }
|
|
3532
|
+
.json-editor textarea::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); }
|
|
3533
|
+
.editor-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 7px; }
|
|
3534
|
+
.json-status { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-size: 11px; }
|
|
3535
|
+
.json-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
|
|
3536
|
+
.json-status.invalid { color: var(--err); }
|
|
3537
|
+
.format-json { border: 0; padding: 3px 5px; background: transparent; color: var(--accent); font-size: 11px; font-weight: 650; cursor: pointer; }
|
|
3538
|
+
.row-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin: 14px 0; }
|
|
3195
3539
|
.banner {
|
|
3196
|
-
display: none;
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3540
|
+
display: none; position: sticky; top: calc(var(--header) + 12px); z-index: 15;
|
|
3541
|
+
align-items: center; gap: 10px; margin: 0 0 16px; padding: 11px 12px 11px 14px;
|
|
3542
|
+
border: 1px solid color-mix(in srgb, var(--err) 30%, var(--line)); border-radius: 10px;
|
|
3543
|
+
background: var(--err-soft); color: var(--err); box-shadow: var(--shadow-sm); font-size: 13px;
|
|
3544
|
+
}
|
|
3545
|
+
.banner.show { display: flex; }
|
|
3546
|
+
.banner span { flex: 1; }
|
|
3547
|
+
.banner button { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: currentColor; cursor: pointer; }
|
|
3548
|
+
.banner button:hover { background: color-mix(in srgb, var(--err) 10%, transparent); }
|
|
3549
|
+
.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); }
|
|
3201
3550
|
dialog {
|
|
3202
|
-
border: 1px solid var(--line); border-radius:
|
|
3203
|
-
color: var(--ink); width: min(
|
|
3204
|
-
}
|
|
3205
|
-
dialog
|
|
3206
|
-
dialog
|
|
3551
|
+
border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--bg-elev);
|
|
3552
|
+
color: var(--ink); width: min(720px, calc(100% - 24px)); max-width: calc(100vw - 24px); box-shadow: var(--shadow-lg);
|
|
3553
|
+
}
|
|
3554
|
+
dialog[open] { animation: dialog-in 160ms ease-out; }
|
|
3555
|
+
dialog::backdrop { background: rgb(12 14 20 / 0.58); backdrop-filter: blur(3px); }
|
|
3556
|
+
dialog form, .dialog-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
|
|
3557
|
+
.dialog-heading { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
|
|
3558
|
+
.dialog-heading strong { font-size: 18px; letter-spacing: -0.02em; }
|
|
3559
|
+
.dialog-heading span { color: var(--muted); font-size: 12px; }
|
|
3207
3560
|
textarea {
|
|
3208
3561
|
width: 100%; min-height: 180px; resize: vertical; border-radius: 10px;
|
|
3209
3562
|
border: 1px solid var(--line); background: var(--bg-inset); padding: 10px;
|
|
3210
3563
|
font-family: var(--mono); font-size: 12px;
|
|
3211
3564
|
}
|
|
3212
|
-
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
3213
|
-
.
|
|
3565
|
+
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding-top: 4px; }
|
|
3566
|
+
.dialog-actions .btn-danger { margin-right: auto; }
|
|
3567
|
+
.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); }
|
|
3214
3568
|
.badge.ok { background: var(--ok-soft); color: var(--ok); }
|
|
3215
3569
|
.badge.warn { background: var(--warn-soft); color: var(--warn); }
|
|
3216
3570
|
.status-2 { color: var(--ok); }
|
|
3217
3571
|
.status-4, .status-5, .status-0 { color: var(--err); }
|
|
3218
3572
|
.stack { display: flex; flex-direction: column; gap: 12px; }
|
|
3573
|
+
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
|
|
3574
|
+
.form-grid .wide { grid-column: span 2; }
|
|
3219
3575
|
.route {
|
|
3220
|
-
display: grid; grid-template-columns:
|
|
3221
|
-
padding:
|
|
3222
|
-
}
|
|
3223
|
-
.
|
|
3576
|
+
display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 10px; align-items: center;
|
|
3577
|
+
padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg-elev);
|
|
3578
|
+
}
|
|
3579
|
+
.route:first-child { border-radius: var(--radius) var(--radius) 0 0; }
|
|
3580
|
+
.route:last-child { border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
|
|
3581
|
+
.route-tools { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
|
|
3582
|
+
.route-tools .field { flex: 1; }
|
|
3583
|
+
.route-tools input { width: 100%; }
|
|
3584
|
+
.route-count { padding-bottom: 10px; color: var(--faint); font-size: 12px; white-space: nowrap; }
|
|
3585
|
+
#route-list { max-height: 34rem; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow-xs); }
|
|
3586
|
+
.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; }
|
|
3587
|
+
@keyframes view-in { from { transform: translateY(3px); } to { transform: translateY(0); } }
|
|
3588
|
+
@keyframes dialog-in { from { transform: translateY(8px) scale(0.99); } to { transform: translateY(0) scale(1); } }
|
|
3589
|
+
@keyframes pulse { 50% { opacity: 0.45; } }
|
|
3590
|
+
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
|
|
3591
|
+
@media (forced-colors: active) { .json-editor pre { display: none; } .json-editor textarea { color: CanvasText; -webkit-text-fill-color: CanvasText; } }
|
|
3224
3592
|
@media (max-width: 800px) {
|
|
3593
|
+
:root { --header: 0px; }
|
|
3225
3594
|
header.top {
|
|
3226
|
-
align-items: stretch; flex-direction: column;
|
|
3227
|
-
padding
|
|
3595
|
+
position: relative; align-items: stretch; flex-direction: column;
|
|
3596
|
+
padding: max(12px, env(safe-area-inset-top)) 14px 12px;
|
|
3228
3597
|
}
|
|
3229
3598
|
input, select, textarea { font-size: 16px; }
|
|
3230
3599
|
.brand, .vendor, .controls { width: 100%; }
|
|
3600
|
+
.brand { gap: 10px; }
|
|
3601
|
+
.vendor { order: 2; border-radius: 9px; }
|
|
3231
3602
|
label.field, label.field select, label.field input { flex: 1; min-width: 0; }
|
|
3603
|
+
.sync-status { display: none; }
|
|
3232
3604
|
/* The layout fills the screen. A single-column grid stretches every auto
|
|
3233
3605
|
row, so the tab bar grew with the leftover height and the buttons floated
|
|
3234
3606
|
in the middle of it. The bar stays one row; the page below takes the rest. */
|
|
@@ -3238,14 +3610,23 @@ var renderAdminDocument = (service) => {
|
|
|
3238
3610
|
align-content: start;
|
|
3239
3611
|
}
|
|
3240
3612
|
nav.side {
|
|
3241
|
-
align-self: start; height: auto;
|
|
3613
|
+
position: sticky; top: 0; z-index: 12; align-self: start; height: auto;
|
|
3242
3614
|
flex-direction: row; align-items: center; overflow-x: auto; min-width: 0;
|
|
3243
3615
|
border-right: 0; border-bottom: 1px solid var(--line);
|
|
3244
|
-
padding: 8px;
|
|
3616
|
+
padding: 8px; box-shadow: var(--shadow-xs);
|
|
3245
3617
|
}
|
|
3246
|
-
nav
|
|
3618
|
+
.nav-label { display: none; }
|
|
3619
|
+
nav.side button { width: auto; white-space: nowrap; flex: none; }
|
|
3620
|
+
nav.side button[aria-current="true"]::before { inset: auto 9px -8px; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
|
|
3247
3621
|
.split, .sql-layout { grid-template-columns: minmax(0, 1fr); }
|
|
3248
|
-
|
|
3622
|
+
.form-grid { grid-template-columns: minmax(0, 1fr); }
|
|
3623
|
+
.form-grid .wide { grid-column: auto; }
|
|
3624
|
+
main { padding: 22px 14px 48px; }
|
|
3625
|
+
.view-head { margin-bottom: 18px; }
|
|
3626
|
+
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
|
|
3627
|
+
.card { padding: 14px; }
|
|
3628
|
+
.card .v { font-size: 20px; }
|
|
3629
|
+
.table-shell { border: 0; background: transparent; box-shadow: none; overflow: visible; }
|
|
3249
3630
|
table, thead, tbody, tr, th, td { display: block; }
|
|
3250
3631
|
thead { display: none; }
|
|
3251
3632
|
tr {
|
|
@@ -3260,50 +3641,63 @@ var renderAdminDocument = (service) => {
|
|
|
3260
3641
|
.route { grid-template-columns: 72px 1fr; }
|
|
3261
3642
|
.route button { grid-column: 1 / -1; }
|
|
3262
3643
|
}
|
|
3644
|
+
@media (max-width: 460px) {
|
|
3645
|
+
.controls label.field { min-width: calc(50% - 4px); }
|
|
3646
|
+
.controls .icon-btn, .controls .btn { flex: 1; }
|
|
3647
|
+
.grid { grid-template-columns: minmax(0, 1fr); }
|
|
3648
|
+
.dialog-actions { flex-wrap: wrap; }
|
|
3649
|
+
.dialog-actions button { flex: 1; }
|
|
3650
|
+
.dialog-actions .btn-danger { flex-basis: 100%; margin-right: 0; }
|
|
3651
|
+
}
|
|
3263
3652
|
</style>
|
|
3264
3653
|
</head>
|
|
3265
3654
|
<body>
|
|
3266
3655
|
<div class="app" data-service="${name}" data-mockingbird-admin>
|
|
3267
3656
|
<header class="top">
|
|
3268
3657
|
<div class="brand">
|
|
3269
|
-
<div class="brand-
|
|
3270
|
-
<
|
|
3271
|
-
|
|
3658
|
+
<div class="brand-lockup">
|
|
3659
|
+
<div class="brand-mark" aria-hidden="true">
|
|
3660
|
+
<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>
|
|
3661
|
+
</div>
|
|
3662
|
+
<div class="brand-id">
|
|
3663
|
+
<strong>${name}</strong>
|
|
3664
|
+
<span>Mock admin</span>
|
|
3665
|
+
</div>
|
|
3272
3666
|
</div>
|
|
3273
3667
|
<div class="vendor" id="vendor" hidden></div>
|
|
3274
3668
|
</div>
|
|
3275
3669
|
<div class="controls">
|
|
3670
|
+
<span class="sync-status" id="sync-status" role="status" aria-live="polite">Ready</span>
|
|
3276
3671
|
<label class="field">Namespace
|
|
3277
3672
|
<select id="namespace" aria-label="Namespace"></select>
|
|
3278
3673
|
</label>
|
|
3279
3674
|
<label class="field">Admin key
|
|
3280
3675
|
<input id="admin-key" type="password" autocomplete="off" spellcheck="false" aria-label="Admin key">
|
|
3281
3676
|
</label>
|
|
3282
|
-
<button class="icon-btn" id="theme" type="button" aria-label="
|
|
3283
|
-
<button class="btn" id="refresh" type="button">Refresh</button>
|
|
3677
|
+
<button class="icon-btn" id="theme" type="button" aria-label="Use dark theme" title="Use dark theme"></button>
|
|
3678
|
+
<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>
|
|
3284
3679
|
</div>
|
|
3285
3680
|
</header>
|
|
3286
3681
|
<div class="layout">
|
|
3287
3682
|
<nav class="side" id="nav" aria-label="Admin sections">
|
|
3288
|
-
<
|
|
3289
|
-
<button type="button" data-view="
|
|
3290
|
-
<button type="button" data-view="
|
|
3291
|
-
<button type="button" data-view="
|
|
3292
|
-
<button type="button" data-view="
|
|
3293
|
-
<button type="button" data-view="
|
|
3683
|
+
<span class="nav-label">Workspace</span>
|
|
3684
|
+
<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>
|
|
3685
|
+
<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>
|
|
3686
|
+
<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>
|
|
3687
|
+
<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>
|
|
3688
|
+
<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>
|
|
3689
|
+
<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>
|
|
3294
3690
|
</nav>
|
|
3295
3691
|
<main id="views">
|
|
3296
|
-
<
|
|
3692
|
+
<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>
|
|
3297
3693
|
<section class="view" id="view-overview">
|
|
3298
|
-
<h2>Overview</h2>
|
|
3299
|
-
<p class="lede">Health, clock, and the collections this namespace is holding.</p>
|
|
3694
|
+
<div class="view-head"><div><h2>Overview</h2><p class="lede">Health, clock, and the collections this namespace is holding.</p></div></div>
|
|
3300
3695
|
<div class="grid" id="overview-cards"></div>
|
|
3301
3696
|
<h3>Recent requests</h3>
|
|
3302
3697
|
<div id="overview-requests"></div>
|
|
3303
3698
|
</section>
|
|
3304
3699
|
<section class="view" id="view-state" hidden>
|
|
3305
|
-
<h2>State</h2>
|
|
3306
|
-
<p class="lede">Every collection in this namespace. Declared fields stay visible before any row exists; stored rows add whatever else they contain.</p>
|
|
3700
|
+
<div class="view-head"><div><h2>State</h2><p class="lede">Inspect and edit every collection in this namespace.</p></div></div>
|
|
3307
3701
|
<div class="split">
|
|
3308
3702
|
<div id="collections"></div>
|
|
3309
3703
|
<div>
|
|
@@ -3316,8 +3710,7 @@ var renderAdminDocument = (service) => {
|
|
|
3316
3710
|
</div>
|
|
3317
3711
|
</section>
|
|
3318
3712
|
<section class="view" id="view-clock" hidden>
|
|
3319
|
-
<h2>Clock</h2>
|
|
3320
|
-
<p class="lede">The clock every timestamp in this mock reads.</p>
|
|
3713
|
+
<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>
|
|
3321
3714
|
<div class="card" id="clock-readout"></div>
|
|
3322
3715
|
<div class="row-actions">
|
|
3323
3716
|
<button class="btn" type="button" data-advance="60000">+1m</button>
|
|
@@ -3336,21 +3729,22 @@ var renderAdminDocument = (service) => {
|
|
|
3336
3729
|
</form>
|
|
3337
3730
|
</section>
|
|
3338
3731
|
<section class="view" id="view-faults" hidden>
|
|
3339
|
-
<h2>Faults</h2>
|
|
3340
|
-
<p class="lede">Inject a response, a delay, or a named preset. Rules apply to this namespace.</p>
|
|
3732
|
+
<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>
|
|
3341
3733
|
<form id="fault-form" class="card stack">
|
|
3342
|
-
<
|
|
3343
|
-
<
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
<
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
<
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
<
|
|
3353
|
-
|
|
3734
|
+
<div class="form-grid">
|
|
3735
|
+
<label class="field wide">Preset
|
|
3736
|
+
<select id="fault-preset"><option value="">Custom rule</option></select>
|
|
3737
|
+
</label>
|
|
3738
|
+
<label class="field">Status
|
|
3739
|
+
<input id="fault-status" inputmode="numeric" placeholder="503">
|
|
3740
|
+
</label>
|
|
3741
|
+
<label class="field wide">Path prefix
|
|
3742
|
+
<input id="fault-path" placeholder="/v1">
|
|
3743
|
+
</label>
|
|
3744
|
+
<label class="field">Method
|
|
3745
|
+
<input id="fault-method" placeholder="GET">
|
|
3746
|
+
</label>
|
|
3747
|
+
</div>
|
|
3354
3748
|
<div class="dialog-actions">
|
|
3355
3749
|
<button class="btn-primary" type="submit">Add fault</button>
|
|
3356
3750
|
<button class="btn-danger" id="fault-clear" type="button">Clear all</button>
|
|
@@ -3359,26 +3753,31 @@ var renderAdminDocument = (service) => {
|
|
|
3359
3753
|
<div id="fault-list"></div>
|
|
3360
3754
|
</section>
|
|
3361
3755
|
<section class="view" id="view-journal" hidden>
|
|
3362
|
-
<h2>Journal</h2>
|
|
3363
|
-
<p class="lede">Requests this namespace has seen. Bodies are not stored.</p>
|
|
3364
|
-
<div class="row-actions">
|
|
3365
|
-
<button class="btn-danger" id="journal-clear" type="button">Clear journal</button>
|
|
3366
|
-
</div>
|
|
3756
|
+
<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>
|
|
3367
3757
|
<div id="journal"></div>
|
|
3368
3758
|
</section>
|
|
3369
3759
|
<section class="view" id="view-routes" hidden>
|
|
3370
|
-
<h2>Routes</h2>
|
|
3371
|
-
<
|
|
3760
|
+
<div class="view-head"><div><h2>Routes</h2><p class="lede">Explore shared controls and service-specific admin endpoints.</p></div></div>
|
|
3761
|
+
<div class="route-tools">
|
|
3762
|
+
<label class="field">Filter routes
|
|
3763
|
+
<input id="route-search" type="search" placeholder="Method, path, or extension" autocomplete="off">
|
|
3764
|
+
</label>
|
|
3765
|
+
<span class="route-count" id="route-count"></span>
|
|
3766
|
+
</div>
|
|
3372
3767
|
<div id="route-list"></div>
|
|
3373
|
-
<form id="route-form" class="card stack">
|
|
3768
|
+
<form id="route-form" class="card stack" style="margin-top: 18px">
|
|
3374
3769
|
<strong id="route-title">Select a route</strong>
|
|
3375
3770
|
<label class="field">JSON body
|
|
3376
|
-
<
|
|
3771
|
+
<div class="json-editor" id="route-editor" hidden>
|
|
3772
|
+
<pre aria-hidden="true"><code id="route-highlight"></code></pre>
|
|
3773
|
+
<textarea id="route-body" placeholder="{ }" spellcheck="false" aria-describedby="route-json-status" disabled></textarea>
|
|
3774
|
+
</div>
|
|
3775
|
+
<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>
|
|
3377
3776
|
</label>
|
|
3378
3777
|
<div class="dialog-actions">
|
|
3379
|
-
<button class="btn-primary" type="submit">Send</button>
|
|
3778
|
+
<button class="btn-primary" id="route-send" type="submit" disabled>Send request</button>
|
|
3380
3779
|
</div>
|
|
3381
|
-
<pre id="route-result">Response will show here.</pre>
|
|
3780
|
+
<pre class="json-view" id="route-result"><code>Response will show here.</code></pre>
|
|
3382
3781
|
</form>
|
|
3383
3782
|
</section>
|
|
3384
3783
|
</main>
|
|
@@ -3386,12 +3785,16 @@ var renderAdminDocument = (service) => {
|
|
|
3386
3785
|
</div>
|
|
3387
3786
|
<dialog id="editor">
|
|
3388
3787
|
<form method="dialog" id="editor-form">
|
|
3389
|
-
<strong id="editor-title">Record</strong>
|
|
3788
|
+
<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>
|
|
3390
3789
|
<label class="field">Id
|
|
3391
3790
|
<input id="editor-id" required>
|
|
3392
3791
|
</label>
|
|
3393
3792
|
<label class="field">JSON value
|
|
3394
|
-
<
|
|
3793
|
+
<div class="json-editor" id="record-editor">
|
|
3794
|
+
<pre aria-hidden="true"><code id="editor-highlight"></code></pre>
|
|
3795
|
+
<textarea id="editor-value" spellcheck="false" aria-describedby="editor-json-status"></textarea>
|
|
3796
|
+
</div>
|
|
3797
|
+
<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>
|
|
3395
3798
|
</label>
|
|
3396
3799
|
<div class="dialog-actions">
|
|
3397
3800
|
<button class="btn-danger" id="editor-delete" type="button" value="delete">Delete</button>
|
|
@@ -3433,8 +3836,8 @@ var describeExtension = (extension) => {
|
|
|
3433
3836
|
...extension.script !== void 0 ? { script: extension.script } : {}
|
|
3434
3837
|
};
|
|
3435
3838
|
};
|
|
3436
|
-
var adminUiRoutes = (service, ui) => {
|
|
3437
|
-
const shell = () => renderAdminDocument(service);
|
|
3839
|
+
var adminUiRoutes = (service, ui, adminPrefix = ADMIN_PREFIX) => {
|
|
3840
|
+
const shell = () => renderAdminDocument(service, adminPrefix);
|
|
3438
3841
|
const document3 = () => ui?.render ? ui.render({ service, defaultHtml: shell }) : shell();
|
|
3439
3842
|
return {
|
|
3440
3843
|
"GET /ui": () => htmlResponse(document3()),
|
|
@@ -4135,7 +4538,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
4135
4538
|
};
|
|
4136
4539
|
|
|
4137
4540
|
// ../core/dist/version.js
|
|
4138
|
-
var PACKAGE_VERSION = true ? "
|
|
4541
|
+
var PACKAGE_VERSION = true ? "2.0.0" : UNRELEASED_VERSION;
|
|
4139
4542
|
|
|
4140
4543
|
// ../core/dist/signing.js
|
|
4141
4544
|
var encoder = new TextEncoder();
|
|
@@ -4236,7 +4639,9 @@ var createWebhookHub = (options) => {
|
|
|
4236
4639
|
const faults = /* @__PURE__ */ new Map();
|
|
4237
4640
|
const held = /* @__PURE__ */ new Map();
|
|
4238
4641
|
const inFlight2 = /* @__PURE__ */ new Set();
|
|
4642
|
+
const controllers = /* @__PURE__ */ new Map();
|
|
4239
4643
|
let immediate = Promise.resolve();
|
|
4644
|
+
const snapshots = /* @__PURE__ */ new WeakMap();
|
|
4240
4645
|
const track = (work) => {
|
|
4241
4646
|
inFlight2.add(work);
|
|
4242
4647
|
void work.finally(() => inFlight2.delete(work));
|
|
@@ -4257,6 +4662,7 @@ var createWebhookHub = (options) => {
|
|
|
4257
4662
|
responseBody: null
|
|
4258
4663
|
};
|
|
4259
4664
|
const controller = new AbortController();
|
|
4665
|
+
controllers.set(delivery.id, controller);
|
|
4260
4666
|
const timer = scheduleTimer(() => controller.abort(), timeoutMs);
|
|
4261
4667
|
try {
|
|
4262
4668
|
const signed = await options.signer({
|
|
@@ -4286,6 +4692,7 @@ var createWebhookHub = (options) => {
|
|
|
4286
4692
|
} catch (error2) {
|
|
4287
4693
|
record2.error = controller.signal.aborted ? `timed out after ${timeoutMs}ms` : error2 instanceof Error ? error2.message : String(error2);
|
|
4288
4694
|
} finally {
|
|
4695
|
+
controllers.delete(delivery.id);
|
|
4289
4696
|
cancel(timer);
|
|
4290
4697
|
record2.durationMs = now() - started;
|
|
4291
4698
|
delivery.attempts.push(record2);
|
|
@@ -4303,6 +4710,8 @@ var createWebhookHub = (options) => {
|
|
|
4303
4710
|
if (!payloads.has(delivery.id))
|
|
4304
4711
|
return;
|
|
4305
4712
|
await attempt(delivery).then((ok) => {
|
|
4713
|
+
if (!payloads.has(delivery.id))
|
|
4714
|
+
return;
|
|
4306
4715
|
if (ok)
|
|
4307
4716
|
delivery.state = "delivered";
|
|
4308
4717
|
else
|
|
@@ -4364,6 +4773,37 @@ var createWebhookHub = (options) => {
|
|
|
4364
4773
|
fanOut(message);
|
|
4365
4774
|
};
|
|
4366
4775
|
const hub = {
|
|
4776
|
+
pending(namespace) {
|
|
4777
|
+
return inFlight2.size + (held.get(namespace)?.length ?? 0) + [...deliveries.values()].filter((d) => d.namespace === namespace && d.state === "pending").length;
|
|
4778
|
+
},
|
|
4779
|
+
snapshot(namespace) {
|
|
4780
|
+
if (hub.pending(namespace) > 0)
|
|
4781
|
+
throw new Error("webhooks are not quiescent");
|
|
4782
|
+
const handle = {};
|
|
4783
|
+
snapshots.set(handle, structuredClone({
|
|
4784
|
+
namespace,
|
|
4785
|
+
endpoints: own.get(namespace) ?? [],
|
|
4786
|
+
messages: messages.filter((m) => m.namespace === namespace),
|
|
4787
|
+
deliveries: [...deliveries].filter(([, d]) => d.namespace === namespace),
|
|
4788
|
+
payloads: [...payloads].filter(([, p]) => p.message.namespace === namespace),
|
|
4789
|
+
faults: faults.get(namespace) ?? []
|
|
4790
|
+
}));
|
|
4791
|
+
return handle;
|
|
4792
|
+
},
|
|
4793
|
+
restore(namespace, handle) {
|
|
4794
|
+
const point = typeof handle === "object" && handle !== null ? snapshots.get(handle) : void 0;
|
|
4795
|
+
if (!point || point.namespace !== namespace || hub.pending(namespace) > 0)
|
|
4796
|
+
throw new Error("invalid webhook restore");
|
|
4797
|
+
hub.clear(namespace);
|
|
4798
|
+
const copied = structuredClone(point);
|
|
4799
|
+
own.set(namespace, copied.endpoints);
|
|
4800
|
+
messages.push(...copied.messages);
|
|
4801
|
+
for (const [id2, delivery] of copied.deliveries)
|
|
4802
|
+
deliveries.set(id2, delivery);
|
|
4803
|
+
for (const [id2, payload] of copied.payloads)
|
|
4804
|
+
payloads.set(id2, payload);
|
|
4805
|
+
faults.set(namespace, copied.faults);
|
|
4806
|
+
},
|
|
4367
4807
|
publish(input) {
|
|
4368
4808
|
const contentType = input.contentType ?? (input.form ? "application/x-www-form-urlencoded" : "application/json");
|
|
4369
4809
|
const body = typeof input.body === "string" ? input.body : input.form ? new URLSearchParams(input.form).toString() : JSON.stringify(input.body);
|
|
@@ -4454,6 +4894,7 @@ var createWebhookHub = (options) => {
|
|
|
4454
4894
|
for (const [id2, delivery] of deliveries) {
|
|
4455
4895
|
if (namespace !== void 0 && delivery.namespace !== namespace)
|
|
4456
4896
|
continue;
|
|
4897
|
+
controllers.get(id2)?.abort();
|
|
4457
4898
|
const timer = pending.get(id2);
|
|
4458
4899
|
if (timer !== void 0)
|
|
4459
4900
|
cancel(timer);
|
|
@@ -4478,7 +4919,10 @@ var createWebhookHub = (options) => {
|
|
|
4478
4919
|
};
|
|
4479
4920
|
return hub;
|
|
4480
4921
|
};
|
|
4481
|
-
var json4 = (status, body) => new Response(JSON.stringify(body), {
|
|
4922
|
+
var json4 = (status, body) => new Response(JSON.stringify(body), {
|
|
4923
|
+
status,
|
|
4924
|
+
headers: { "content-type": "application/json; charset=utf-8" }
|
|
4925
|
+
});
|
|
4482
4926
|
var adminError3 = (status, message) => json4(status, { error: { type: "mockingbird_admin", message } });
|
|
4483
4927
|
var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4484
4928
|
var parseEndpoint = (value) => {
|
|
@@ -4586,7 +5030,6 @@ var AT_HEADER = "x-mockingbird-at";
|
|
|
4586
5030
|
var CHECKPOINT_HEADER = "x-mockingbird-checkpoint";
|
|
4587
5031
|
var DEFAULT_NAMESPACE = "default";
|
|
4588
5032
|
var NAMESPACE_PATTERN = /^[A-Za-z0-9_.-]{1,64}$/;
|
|
4589
|
-
var PATH_PREFIX = /^\/ns\/([^/]+)(\/.*)?$/;
|
|
4590
5033
|
var BRANCH_PATTERN2 = /^[A-Za-z0-9_.-]{1,64}$/;
|
|
4591
5034
|
var MUTATING_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
4592
5035
|
var effects = /* @__PURE__ */ new WeakMap();
|
|
@@ -4627,6 +5070,22 @@ var operationMatcher = (document3) => {
|
|
|
4627
5070
|
return (request, path) => matchers.find((m) => m.method === request.method && m.pattern.test(path))?.operationId;
|
|
4628
5071
|
};
|
|
4629
5072
|
var createRuntime = (options) => {
|
|
5073
|
+
const adminPrefix = resolveAdminPrefix(options.adminPrefix);
|
|
5074
|
+
const internalPaths = Object.entries(options.document?.paths ?? {}).filter(([, item]) => item["x-mockingbird-internal"] === true).map(([path]) => path);
|
|
5075
|
+
for (const path of internalPaths) {
|
|
5076
|
+
if (!path.startsWith(`${ADMIN_PREFIX}/blobs/`))
|
|
5077
|
+
throw new Error(`internal transport ${path} must live under ${ADMIN_PREFIX}/blobs/`);
|
|
5078
|
+
}
|
|
5079
|
+
assertAdminPrefixAvailable(adminPrefix, Object.keys(options.document?.paths ?? {}).filter((path) => !internalPaths.includes(path)));
|
|
5080
|
+
const internalMatch = (path) => {
|
|
5081
|
+
for (const pattern of internalPaths) {
|
|
5082
|
+
const actual = path.split("/");
|
|
5083
|
+
const expected = pattern.split("/");
|
|
5084
|
+
if (actual.length === expected.length && expected.every((part, i) => part.startsWith("{") || part === actual[i]))
|
|
5085
|
+
return pattern;
|
|
5086
|
+
}
|
|
5087
|
+
return void 0;
|
|
5088
|
+
};
|
|
4630
5089
|
assertAdminUi(options.adminUi);
|
|
4631
5090
|
const sqlite = bootSqlite(options.sqlite);
|
|
4632
5091
|
const clock = options.clock ?? createClock();
|
|
@@ -4641,6 +5100,20 @@ var createRuntime = (options) => {
|
|
|
4641
5100
|
const instances = /* @__PURE__ */ new Map();
|
|
4642
5101
|
const publicNamespaces = /* @__PURE__ */ new Set();
|
|
4643
5102
|
const branchRngs = /* @__PURE__ */ new Map();
|
|
5103
|
+
const namespaceClocks = /* @__PURE__ */ new Map();
|
|
5104
|
+
const namespaceForStorage = /* @__PURE__ */ new Map();
|
|
5105
|
+
let isolatedNamespaces = false;
|
|
5106
|
+
const namespaceClock = (name = DEFAULT_NAMESPACE) => {
|
|
5107
|
+
if (!isolatedNamespaces || name === DEFAULT_NAMESPACE)
|
|
5108
|
+
return clock;
|
|
5109
|
+
let found = namespaceClocks.get(name);
|
|
5110
|
+
if (!found) {
|
|
5111
|
+
found = createClock();
|
|
5112
|
+
namespaceClocks.set(name, found);
|
|
5113
|
+
}
|
|
5114
|
+
return found;
|
|
5115
|
+
};
|
|
5116
|
+
const fleetPoints = /* @__PURE__ */ new WeakMap();
|
|
4644
5117
|
const timelines = /* @__PURE__ */ new Map();
|
|
4645
5118
|
const branchStorage = /* @__PURE__ */ new Map();
|
|
4646
5119
|
const captured = /* @__PURE__ */ new Map();
|
|
@@ -4654,17 +5127,22 @@ var createRuntime = (options) => {
|
|
|
4654
5127
|
if (!NAMESPACE_PATTERN.test(key2) || !NAMESPACE_PATTERN.test(publicNamespace)) {
|
|
4655
5128
|
throw new RangeError(`namespace must match ${NAMESPACE_PATTERN}: ${JSON.stringify(publicNamespace)}`);
|
|
4656
5129
|
}
|
|
5130
|
+
const createdContextRng = isolatedRng ?? (isolatedNamespaces && key2 !== DEFAULT_NAMESPACE ? createRng(options.seed ?? 0) : rng);
|
|
4657
5131
|
const created = options.create({
|
|
4658
5132
|
namespace: storageNamespace(key2),
|
|
4659
5133
|
publicNamespace,
|
|
5134
|
+
adminPrefix,
|
|
4660
5135
|
sqlite,
|
|
4661
|
-
clock,
|
|
4662
|
-
rng:
|
|
5136
|
+
clock: namespaceClock(publicNamespace),
|
|
5137
|
+
rng: createdContextRng
|
|
4663
5138
|
});
|
|
4664
5139
|
instances.set(key2, created);
|
|
5140
|
+
namespaceForStorage.set(key2, publicNamespace);
|
|
4665
5141
|
publicNamespaces.add(publicNamespace);
|
|
4666
5142
|
if (isolatedRng)
|
|
4667
5143
|
branchRngs.set(key2, isolatedRng);
|
|
5144
|
+
else if (isolatedNamespaces && key2 !== DEFAULT_NAMESPACE)
|
|
5145
|
+
branchRngs.set(key2, createdContextRng);
|
|
4668
5146
|
return created;
|
|
4669
5147
|
};
|
|
4670
5148
|
const instance = (name = DEFAULT_NAMESPACE) => instanceFor(name);
|
|
@@ -4682,7 +5160,7 @@ var createRuntime = (options) => {
|
|
|
4682
5160
|
captured.set(storage, snapshot2);
|
|
4683
5161
|
return Object.freeze({
|
|
4684
5162
|
snapshot: snapshot2,
|
|
4685
|
-
clock: Object.freeze(
|
|
5163
|
+
clock: Object.freeze(namespaceClock(namespaceForStorage.get(storage) ?? storage).state()),
|
|
4686
5164
|
rngState: (branchRngs.get(storage) ?? rng).state()
|
|
4687
5165
|
});
|
|
4688
5166
|
};
|
|
@@ -4692,7 +5170,7 @@ var createRuntime = (options) => {
|
|
|
4692
5170
|
return found;
|
|
4693
5171
|
instance(name);
|
|
4694
5172
|
found = new Timeline({
|
|
4695
|
-
now:
|
|
5173
|
+
now: namespaceClock(name).now,
|
|
4696
5174
|
...options.maxCheckpoints !== void 0 ? { maxCheckpoints: options.maxCheckpoints } : {}
|
|
4697
5175
|
});
|
|
4698
5176
|
found.commit(capture(name));
|
|
@@ -4719,12 +5197,13 @@ var createRuntime = (options) => {
|
|
|
4719
5197
|
const point = history2.checkout("main", at);
|
|
4720
5198
|
restoreNamespace(sqlite, storageNamespace(namespace), point.value.snapshot);
|
|
4721
5199
|
captured.set(namespace, point.value.snapshot);
|
|
4722
|
-
rng.setState(point.value.rngState);
|
|
4723
|
-
|
|
5200
|
+
(branchRngs.get(namespace) ?? rng).setState(point.value.rngState);
|
|
5201
|
+
const selectedClock = namespaceClock(namespace);
|
|
5202
|
+
selectedClock.set(point.value.clock.now);
|
|
4724
5203
|
if (point.value.clock.frozen)
|
|
4725
|
-
|
|
5204
|
+
selectedClock.freeze();
|
|
4726
5205
|
else
|
|
4727
|
-
|
|
5206
|
+
selectedClock.unfreeze();
|
|
4728
5207
|
}
|
|
4729
5208
|
return namespace;
|
|
4730
5209
|
}
|
|
@@ -4782,11 +5261,12 @@ var createRuntime = (options) => {
|
|
|
4782
5261
|
const storage = ensureBranch(namespace, branchName);
|
|
4783
5262
|
restoreNamespace(sqlite, storageNamespace(storage), point.value.snapshot);
|
|
4784
5263
|
captured.set(storage, point.value.snapshot);
|
|
4785
|
-
|
|
5264
|
+
const selectedClock = namespaceClock(namespace);
|
|
5265
|
+
selectedClock.set(point.value.clock.now);
|
|
4786
5266
|
if (point.value.clock.frozen)
|
|
4787
|
-
|
|
5267
|
+
selectedClock.freeze();
|
|
4788
5268
|
else
|
|
4789
|
-
|
|
5269
|
+
selectedClock.unfreeze();
|
|
4790
5270
|
(branchRngs.get(storage) ?? rng).setState(point.value.rngState);
|
|
4791
5271
|
};
|
|
4792
5272
|
const reset = async (name = DEFAULT_NAMESPACE) => {
|
|
@@ -4794,10 +5274,21 @@ var createRuntime = (options) => {
|
|
|
4794
5274
|
options.webhooks?.clear();
|
|
4795
5275
|
for (const each of instances.values())
|
|
4796
5276
|
await each.reset();
|
|
5277
|
+
for (const each of branchRngs.values())
|
|
5278
|
+
each.reset();
|
|
4797
5279
|
timelines.clear();
|
|
5280
|
+
for (const storage of branchStorage.values()) {
|
|
5281
|
+
instances.delete(storage);
|
|
5282
|
+
branchRngs.delete(storage);
|
|
5283
|
+
namespaceForStorage.delete(storage);
|
|
5284
|
+
}
|
|
4798
5285
|
branchStorage.clear();
|
|
4799
|
-
branchRngs.clear();
|
|
4800
5286
|
captured.clear();
|
|
5287
|
+
faults.clear();
|
|
5288
|
+
clock.reset();
|
|
5289
|
+
rng.reset();
|
|
5290
|
+
for (const each of namespaceClocks.values())
|
|
5291
|
+
each.reset();
|
|
4801
5292
|
return;
|
|
4802
5293
|
}
|
|
4803
5294
|
options.webhooks?.clear(name);
|
|
@@ -4815,11 +5306,18 @@ var createRuntime = (options) => {
|
|
|
4815
5306
|
else
|
|
4816
5307
|
clearNamespace(sqlite, storageNamespace(storage));
|
|
4817
5308
|
branchStorage.delete(mapping);
|
|
5309
|
+
instances.delete(storage);
|
|
5310
|
+
namespaceForStorage.delete(storage);
|
|
4818
5311
|
branchRngs.delete(storage);
|
|
4819
5312
|
captured.delete(storage);
|
|
4820
5313
|
}
|
|
4821
5314
|
timelines.delete(name);
|
|
4822
5315
|
captured.delete(name);
|
|
5316
|
+
faults.restore(name, { rules: [], rngState: createRng(options.seed ?? 0).state() });
|
|
5317
|
+
namespaceClock(name).reset();
|
|
5318
|
+
(branchRngs.get(name) ?? rng).reset();
|
|
5319
|
+
journal.clear(name);
|
|
5320
|
+
metrics.reset(name);
|
|
4823
5321
|
};
|
|
4824
5322
|
const snapshot = (name = DEFAULT_NAMESPACE) => {
|
|
4825
5323
|
return checkpoint(name, "main").value.snapshot;
|
|
@@ -4857,6 +5355,53 @@ var createRuntime = (options) => {
|
|
|
4857
5355
|
rng,
|
|
4858
5356
|
credentials,
|
|
4859
5357
|
webhooks: options.webhooks,
|
|
5358
|
+
isolateNamespaces() {
|
|
5359
|
+
if (publicNamespaces.size > 1)
|
|
5360
|
+
throw new Error("enable namespace isolation before creating named namespaces");
|
|
5361
|
+
isolatedNamespaces = true;
|
|
5362
|
+
faults.isolateNamespaces();
|
|
5363
|
+
},
|
|
5364
|
+
namespaceClock,
|
|
5365
|
+
namespaceOf(request) {
|
|
5366
|
+
const url = new URL(request.url);
|
|
5367
|
+
const prefixed = matchNamespacePath(url.pathname, adminPrefix);
|
|
5368
|
+
const selected = request.headers.get(NAMESPACE_HEADER) ?? (prefixed ? decodeURIComponent(prefixed[1]) : void 0);
|
|
5369
|
+
const path = prefixed ? prefixed[2] ?? "/" : url.pathname;
|
|
5370
|
+
if (isAdminPath(path, adminPrefix))
|
|
5371
|
+
return url.searchParams.get("namespace") ?? selected ?? DEFAULT_NAMESPACE;
|
|
5372
|
+
if (selected !== void 0)
|
|
5373
|
+
return selected;
|
|
5374
|
+
const credential = options.credential?.(request);
|
|
5375
|
+
return (credential !== void 0 ? credentials.get(credential) : void 0) ?? DEFAULT_NAMESPACE;
|
|
5376
|
+
},
|
|
5377
|
+
fleetSnapshot(namespace) {
|
|
5378
|
+
instance(namespace);
|
|
5379
|
+
const handle = {};
|
|
5380
|
+
fleetPoints.set(handle, {
|
|
5381
|
+
namespace,
|
|
5382
|
+
state: capture(namespace),
|
|
5383
|
+
faults: faults.snapshot(namespace),
|
|
5384
|
+
webhooks: options.webhooks?.snapshot(namespace)
|
|
5385
|
+
});
|
|
5386
|
+
return handle;
|
|
5387
|
+
},
|
|
5388
|
+
fleetRestore(handle, namespace) {
|
|
5389
|
+
const point = typeof handle === "object" && handle !== null ? fleetPoints.get(handle) : void 0;
|
|
5390
|
+
if (!point || point.namespace !== namespace)
|
|
5391
|
+
throw new Error("invalid fleet checkpoint");
|
|
5392
|
+
restoreNamespace(sqlite, storageNamespace(namespace), point.state.snapshot);
|
|
5393
|
+
captured.set(namespace, point.state.snapshot);
|
|
5394
|
+
const selectedClock = namespaceClock(namespace);
|
|
5395
|
+
selectedClock.freeze();
|
|
5396
|
+
selectedClock.set(point.state.clock.now);
|
|
5397
|
+
if (!point.state.clock.frozen)
|
|
5398
|
+
selectedClock.unfreeze();
|
|
5399
|
+
(branchRngs.get(namespace) ?? rng).setState(point.state.rngState);
|
|
5400
|
+
faults.restore(namespace, point.faults);
|
|
5401
|
+
if (point.webhooks !== void 0)
|
|
5402
|
+
options.webhooks?.restore(namespace, point.webhooks);
|
|
5403
|
+
timelines.delete(namespace);
|
|
5404
|
+
},
|
|
4860
5405
|
applyPreset: (name, namespace = DEFAULT_NAMESPACE, overrides = {}) => {
|
|
4861
5406
|
const preset = options.presets?.[name];
|
|
4862
5407
|
if (!preset)
|
|
@@ -4888,7 +5433,7 @@ var createRuntime = (options) => {
|
|
|
4888
5433
|
state: (namespace = DEFAULT_NAMESPACE) => inspectState(stateScope(namespace)),
|
|
4889
5434
|
fetch: async (incoming) => {
|
|
4890
5435
|
let request = incoming;
|
|
4891
|
-
const prefixed =
|
|
5436
|
+
const prefixed = matchNamespacePath(new URL(request.url).pathname, adminPrefix);
|
|
4892
5437
|
if (prefixed) {
|
|
4893
5438
|
const url2 = new URL(request.url);
|
|
4894
5439
|
url2.pathname = prefixed[2] ?? "/";
|
|
@@ -4904,7 +5449,15 @@ var createRuntime = (options) => {
|
|
|
4904
5449
|
signal: request.signal
|
|
4905
5450
|
});
|
|
4906
5451
|
}
|
|
4907
|
-
|
|
5452
|
+
const internalUrl = new URL(request.url);
|
|
5453
|
+
const internalPath = isAdminPath(internalUrl.pathname, adminPrefix) ? `${ADMIN_PREFIX}${internalUrl.pathname.slice(adminPrefix.length)}` : "";
|
|
5454
|
+
const internal = internalMatch(internalPath);
|
|
5455
|
+
const obsoleteInternalPath = adminPrefix !== ADMIN_PREFIX && internalMatch(internalUrl.pathname) && !internal;
|
|
5456
|
+
if (internal) {
|
|
5457
|
+
internalUrl.pathname = internalPath;
|
|
5458
|
+
request = new Request(internalUrl, request);
|
|
5459
|
+
}
|
|
5460
|
+
let namespace = internal ? internalUrl.searchParams.get("namespace") ?? control.namespaceOf(request) : control.namespaceOf(request);
|
|
4908
5461
|
if (!request.headers.has(NAMESPACE_HEADER) && options.credential) {
|
|
4909
5462
|
const credential = options.credential(request);
|
|
4910
5463
|
const mapped = credential !== void 0 ? credentials.get(credential) : void 0;
|
|
@@ -4924,7 +5477,9 @@ var createRuntime = (options) => {
|
|
|
4924
5477
|
return copy;
|
|
4925
5478
|
}
|
|
4926
5479
|
};
|
|
4927
|
-
|
|
5480
|
+
if (obsoleteInternalPath)
|
|
5481
|
+
return stamp(adminFail(404, "internal transport is only available under adminPrefix"));
|
|
5482
|
+
const handled = internal ? void 0 : await control.handle(request);
|
|
4928
5483
|
if (handled)
|
|
4929
5484
|
return stamp(handled);
|
|
4930
5485
|
const started = monotonicNow();
|
|
@@ -4965,7 +5520,7 @@ var createRuntime = (options) => {
|
|
|
4965
5520
|
type: "mockingbird_admin",
|
|
4966
5521
|
message: `${NAMESPACE_HEADER} must match ${NAMESPACE_PATTERN}`
|
|
4967
5522
|
}
|
|
4968
|
-
}), { status: 400, headers: { "content-type": "application/json" } }));
|
|
5523
|
+
}), { status: 400, headers: { "content-type": "application/json; charset=utf-8" } }));
|
|
4969
5524
|
}
|
|
4970
5525
|
if (!BRANCH_PATTERN2.test(selectedBranch)) {
|
|
4971
5526
|
log(400);
|
|
@@ -5032,6 +5587,7 @@ var createRuntime = (options) => {
|
|
|
5032
5587
|
startedAt: wallNow(),
|
|
5033
5588
|
wallNow,
|
|
5034
5589
|
clock,
|
|
5590
|
+
namespaceClock,
|
|
5035
5591
|
faults,
|
|
5036
5592
|
metrics,
|
|
5037
5593
|
journal,
|
|
@@ -5081,15 +5637,16 @@ var createRuntime = (options) => {
|
|
|
5081
5637
|
...options.admin?.(runtime) ?? {},
|
|
5082
5638
|
// Shell routes win a colliding key. Fault presets are one of them: the admin page
|
|
5083
5639
|
// maps `presets`, and a service route must not replace that list with a record.
|
|
5084
|
-
...options.presets ? presetRoutes(options.presets, runtime) : {},
|
|
5640
|
+
...options.presets ? presetRoutes(options.presets, runtime, adminPrefix) : {},
|
|
5085
5641
|
...stateAdminRoutes({
|
|
5086
5642
|
open: stateScope,
|
|
5087
5643
|
afterWrite: (namespace) => {
|
|
5088
5644
|
checkpoint(namespace, "main");
|
|
5089
5645
|
}
|
|
5090
5646
|
}),
|
|
5091
|
-
...adminUiRoutes(options.name, options.adminUi)
|
|
5647
|
+
...adminUiRoutes(options.name, options.adminUi, adminPrefix)
|
|
5092
5648
|
},
|
|
5649
|
+
adminPrefix,
|
|
5093
5650
|
adminKey: options.adminKey
|
|
5094
5651
|
});
|
|
5095
5652
|
return defineMock(runtime);
|
|
@@ -5103,7 +5660,10 @@ var mutableResponse = (response) => {
|
|
|
5103
5660
|
return new Response(response.body, response);
|
|
5104
5661
|
}
|
|
5105
5662
|
};
|
|
5106
|
-
var adminJson = (status, body) => new Response(JSON.stringify(body), {
|
|
5663
|
+
var adminJson = (status, body) => new Response(JSON.stringify(body), {
|
|
5664
|
+
status,
|
|
5665
|
+
headers: { "content-type": "application/json; charset=utf-8" }
|
|
5666
|
+
});
|
|
5107
5667
|
var adminFail = (status, message) => adminJson(status, { error: { type: "mockingbird_admin", message } });
|
|
5108
5668
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5109
5669
|
var credentialRoutes = (registry) => ({
|
|
@@ -5155,7 +5715,7 @@ var credentialRoutes = (registry) => ({
|
|
|
5155
5715
|
return adminJson(200, { status: "ok" });
|
|
5156
5716
|
}
|
|
5157
5717
|
});
|
|
5158
|
-
var presetRoutes = (presets, runtime) => ({
|
|
5718
|
+
var presetRoutes = (presets, runtime, adminPrefix) => ({
|
|
5159
5719
|
"GET /faults/presets": () => {
|
|
5160
5720
|
const body = {
|
|
5161
5721
|
presets: Object.entries(presets).map(([name, preset]) => ({ name, ...preset }))
|
|
@@ -5165,7 +5725,7 @@ var presetRoutes = (presets, runtime) => ({
|
|
|
5165
5725
|
"POST /faults/presets/:name": ({ params, body, namespace }) => {
|
|
5166
5726
|
const name = params.name;
|
|
5167
5727
|
if (!presets[name])
|
|
5168
|
-
return adminFail(404, `no fault preset ${name}; GET /
|
|
5728
|
+
return adminFail(404, `no fault preset ${name}; GET ${adminPrefix}/faults/presets`);
|
|
5169
5729
|
const overrides = isObject(body) ? body : {};
|
|
5170
5730
|
return adminJson(201, { preset: name, rules: runtime.applyPreset(name, namespace, overrides) });
|
|
5171
5731
|
}
|
|
@@ -5467,6 +6027,7 @@ var createRuntime2 = (options = {}) => {
|
|
|
5467
6027
|
...options.sqlite ? { sqlite: options.sqlite } : {},
|
|
5468
6028
|
...options.clock ? { clock: options.clock } : {},
|
|
5469
6029
|
...options.seed !== void 0 ? { seed: options.seed } : {},
|
|
6030
|
+
...options.adminPrefix !== void 0 ? { adminPrefix: options.adminPrefix } : {},
|
|
5470
6031
|
...options.adminKey !== void 0 ? { adminKey: options.adminKey } : {},
|
|
5471
6032
|
...options.onLog ? { onLog: options.onLog } : {},
|
|
5472
6033
|
credential: apiKeyCredential,
|
|
@@ -5839,6 +6400,9 @@ var AhaAPI = class {
|
|
|
5839
6400
|
};
|
|
5840
6401
|
|
|
5841
6402
|
export {
|
|
6403
|
+
createClock,
|
|
6404
|
+
resolveAdminPrefix,
|
|
6405
|
+
parseDuration,
|
|
5842
6406
|
document2 as document,
|
|
5843
6407
|
operationIds,
|
|
5844
6408
|
supportedOperationIds,
|
|
@@ -5855,4 +6419,4 @@ export {
|
|
|
5855
6419
|
apiKeyCredential,
|
|
5856
6420
|
AhaAPI
|
|
5857
6421
|
};
|
|
5858
|
-
//# sourceMappingURL=chunk-
|
|
6422
|
+
//# sourceMappingURL=chunk-OPYCBZYR.js.map
|