@crvouga/mockingbird-service-bedrock 1.6.1 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/{chunk-HQ6HZNDD.js → chunk-KWJYXFIF.js} +270 -16
- package/dist/chunk-KWJYXFIF.js.map +7 -0
- package/dist/{chunk-PNL54SRB.js → chunk-PEDTFUZC.js} +2 -2
- package/dist/cli.js +2 -2
- package/dist/index.js +1 -1
- package/dist/server.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-HQ6HZNDD.js.map +0 -7
- /package/dist/{chunk-PNL54SRB.js.map → chunk-PEDTFUZC.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-bedrock
|
|
2
2
|
|
|
3
|
+
## 1.7.1 (2026-10-01)
|
|
4
|
+
|
|
5
|
+
### Fixes and improvements
|
|
6
|
+
|
|
7
|
+
- freeze clock before setting time ([a054a1d](https://github.com/crvouga/mockingbird/commit/a054a1defad62539d719b1d31c15107afea623bd))
|
|
8
|
+
|
|
9
|
+
## 1.7.0 (2026-09-30)
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
- record SQL timelines and serve the admin explorer ([8ced17a](https://github.com/crvouga/mockingbird/commit/8ced17ac398e386ef4e9d7e01fc7744c34b95d07))
|
|
14
|
+
|
|
3
15
|
## 1.6.1 (2026-09-30)
|
|
4
16
|
|
|
5
17
|
### Fixes and improvements
|
|
@@ -189,6 +189,8 @@ var createControlPlane = (context) => {
|
|
|
189
189
|
return adminError(400, "expected a JSON object");
|
|
190
190
|
if (body.reset === true)
|
|
191
191
|
context.clock.reset();
|
|
192
|
+
if (body.freeze === true)
|
|
193
|
+
context.clock.freeze();
|
|
192
194
|
if (body.set !== void 0) {
|
|
193
195
|
const instant = parseInstant(body.set);
|
|
194
196
|
if (instant === void 0)
|
|
@@ -201,8 +203,6 @@ var createControlPlane = (context) => {
|
|
|
201
203
|
return adminError(400, 'advance: expected ms or "15m"-style');
|
|
202
204
|
context.clock.advance(delta);
|
|
203
205
|
}
|
|
204
|
-
if (body.freeze === true)
|
|
205
|
-
context.clock.freeze();
|
|
206
206
|
if (body.freeze === false)
|
|
207
207
|
context.clock.unfreeze();
|
|
208
208
|
return json(200, context.clock.state());
|
|
@@ -1866,6 +1866,167 @@ function faultPresetList(value) {
|
|
|
1866
1866
|
})
|
|
1867
1867
|
};
|
|
1868
1868
|
}
|
|
1869
|
+
function mountSqlExplorer(root, api) {
|
|
1870
|
+
const cell = (value) => {
|
|
1871
|
+
if (value === null || value === void 0)
|
|
1872
|
+
return "";
|
|
1873
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
1874
|
+
return String(value);
|
|
1875
|
+
}
|
|
1876
|
+
return JSON.stringify(value) ?? "";
|
|
1877
|
+
};
|
|
1878
|
+
root.replaceChildren();
|
|
1879
|
+
const layout = document.createElement("div");
|
|
1880
|
+
layout.className = "sql-layout";
|
|
1881
|
+
const tables = document.createElement("div");
|
|
1882
|
+
tables.className = "sql-tables";
|
|
1883
|
+
const stack = document.createElement("div");
|
|
1884
|
+
stack.className = "stack";
|
|
1885
|
+
const banner = document.createElement("p");
|
|
1886
|
+
banner.className = "banner";
|
|
1887
|
+
const grid = document.createElement("div");
|
|
1888
|
+
const input = document.createElement("textarea");
|
|
1889
|
+
input.className = "sql-input";
|
|
1890
|
+
input.spellcheck = false;
|
|
1891
|
+
input.placeholder = "SELECT * FROM ...";
|
|
1892
|
+
const actions = document.createElement("div");
|
|
1893
|
+
actions.className = "row-actions";
|
|
1894
|
+
const run = document.createElement("button");
|
|
1895
|
+
run.type = "button";
|
|
1896
|
+
run.textContent = "Run";
|
|
1897
|
+
actions.append(run);
|
|
1898
|
+
const result = document.createElement("pre");
|
|
1899
|
+
stack.append(banner, grid, input, actions, result);
|
|
1900
|
+
layout.append(tables, stack);
|
|
1901
|
+
root.append(layout);
|
|
1902
|
+
const showError = (error) => {
|
|
1903
|
+
banner.textContent = error instanceof Error ? error.message : String(error);
|
|
1904
|
+
banner.classList.add("show");
|
|
1905
|
+
};
|
|
1906
|
+
const clearError = () => {
|
|
1907
|
+
banner.textContent = "";
|
|
1908
|
+
banner.classList.remove("show");
|
|
1909
|
+
};
|
|
1910
|
+
const renderGrid = (columns, rows) => {
|
|
1911
|
+
grid.replaceChildren();
|
|
1912
|
+
if (columns.length === 0) {
|
|
1913
|
+
const empty = document.createElement("p");
|
|
1914
|
+
empty.className = "empty";
|
|
1915
|
+
empty.textContent = "No rows.";
|
|
1916
|
+
grid.append(empty);
|
|
1917
|
+
return;
|
|
1918
|
+
}
|
|
1919
|
+
const table = document.createElement("table");
|
|
1920
|
+
const head = document.createElement("thead");
|
|
1921
|
+
const headRow = document.createElement("tr");
|
|
1922
|
+
for (const column of columns) {
|
|
1923
|
+
const th = document.createElement("th");
|
|
1924
|
+
th.textContent = column;
|
|
1925
|
+
headRow.append(th);
|
|
1926
|
+
}
|
|
1927
|
+
head.append(headRow);
|
|
1928
|
+
const body = document.createElement("tbody");
|
|
1929
|
+
for (const row of rows) {
|
|
1930
|
+
const tr = document.createElement("tr");
|
|
1931
|
+
for (const column of columns) {
|
|
1932
|
+
const td = document.createElement("td");
|
|
1933
|
+
td.dataset.label = column;
|
|
1934
|
+
td.textContent = cell(row[column]);
|
|
1935
|
+
tr.append(td);
|
|
1936
|
+
}
|
|
1937
|
+
body.append(tr);
|
|
1938
|
+
}
|
|
1939
|
+
table.append(head, body);
|
|
1940
|
+
grid.append(table);
|
|
1941
|
+
};
|
|
1942
|
+
const rowsOf = (value) => {
|
|
1943
|
+
if (!isRecord2(value) || !Array.isArray(value.rows))
|
|
1944
|
+
return [];
|
|
1945
|
+
return value.rows.flatMap((row) => isRecord2(row) ? [row] : []);
|
|
1946
|
+
};
|
|
1947
|
+
const columnsOf = (value, rows) => {
|
|
1948
|
+
if (isRecord2(value) && Array.isArray(value.columns)) {
|
|
1949
|
+
const named = value.columns.flatMap((column) => typeof column === "string" ? [column] : []);
|
|
1950
|
+
if (named.length > 0)
|
|
1951
|
+
return named;
|
|
1952
|
+
}
|
|
1953
|
+
const first = rows[0];
|
|
1954
|
+
return first === void 0 ? [] : Object.keys(first);
|
|
1955
|
+
};
|
|
1956
|
+
let selected = "";
|
|
1957
|
+
const loadPage = async (schema, name) => {
|
|
1958
|
+
selected = `${schema}.${name}`;
|
|
1959
|
+
const page = await api.get(`/sql/tables/${encodeURIComponent(schema)}/${encodeURIComponent(name)}?limit=50`);
|
|
1960
|
+
const rows = rowsOf(page);
|
|
1961
|
+
renderGrid(columnsOf(page, rows), rows);
|
|
1962
|
+
const total = isRecord2(page) && typeof page.total === "number" ? page.total : rows.length;
|
|
1963
|
+
result.textContent = `${selected} \xB7 ${total} rows`;
|
|
1964
|
+
for (const button of tables.querySelectorAll("button")) {
|
|
1965
|
+
if (!(button instanceof HTMLButtonElement))
|
|
1966
|
+
continue;
|
|
1967
|
+
button.setAttribute("aria-current", button.dataset.schema === schema && button.dataset.table === name ? "true" : "false");
|
|
1968
|
+
}
|
|
1969
|
+
};
|
|
1970
|
+
const loadTables = async () => {
|
|
1971
|
+
const payload = await api.get("/sql/tables");
|
|
1972
|
+
const listed = isRecord2(payload) && Array.isArray(payload.tables) ? payload.tables : [];
|
|
1973
|
+
tables.replaceChildren();
|
|
1974
|
+
if (listed.length === 0) {
|
|
1975
|
+
const empty = document.createElement("p");
|
|
1976
|
+
empty.className = "empty";
|
|
1977
|
+
empty.textContent = "No tables.";
|
|
1978
|
+
tables.append(empty);
|
|
1979
|
+
return;
|
|
1980
|
+
}
|
|
1981
|
+
for (const item of listed) {
|
|
1982
|
+
if (!isRecord2(item) || typeof item.schema !== "string" || typeof item.name !== "string")
|
|
1983
|
+
continue;
|
|
1984
|
+
const button = document.createElement("button");
|
|
1985
|
+
button.type = "button";
|
|
1986
|
+
button.dataset.schema = item.schema;
|
|
1987
|
+
button.dataset.table = item.name;
|
|
1988
|
+
button.textContent = `${item.schema}.${item.name}`;
|
|
1989
|
+
tables.append(button);
|
|
1990
|
+
}
|
|
1991
|
+
};
|
|
1992
|
+
tables.addEventListener("click", (event) => {
|
|
1993
|
+
const target = event.target;
|
|
1994
|
+
if (!(target instanceof Element))
|
|
1995
|
+
return;
|
|
1996
|
+
const button = target.closest("button");
|
|
1997
|
+
if (!(button instanceof HTMLButtonElement))
|
|
1998
|
+
return;
|
|
1999
|
+
const schema = button.dataset.schema;
|
|
2000
|
+
const name = button.dataset.table;
|
|
2001
|
+
if (schema === void 0 || name === void 0)
|
|
2002
|
+
return;
|
|
2003
|
+
clearError();
|
|
2004
|
+
loadPage(schema, name).catch(showError);
|
|
2005
|
+
});
|
|
2006
|
+
run.addEventListener("click", () => {
|
|
2007
|
+
const sql = input.value.trim();
|
|
2008
|
+
if (sql === "") {
|
|
2009
|
+
showError(new Error("Enter a statement"));
|
|
2010
|
+
return;
|
|
2011
|
+
}
|
|
2012
|
+
clearError();
|
|
2013
|
+
api.send("POST", "/sql/query", { sql }).then((payload) => {
|
|
2014
|
+
const rows = rowsOf(payload);
|
|
2015
|
+
renderGrid(columnsOf(payload, rows), rows);
|
|
2016
|
+
const count = isRecord2(payload) && typeof payload.rowCount === "number" ? payload.rowCount : rows.length;
|
|
2017
|
+
const truncated = isRecord2(payload) && payload.truncated === true ? " (truncated)" : "";
|
|
2018
|
+
result.textContent = `${count} rows${truncated}`;
|
|
2019
|
+
}).catch(showError);
|
|
2020
|
+
});
|
|
2021
|
+
const namespace = document.getElementById("namespace");
|
|
2022
|
+
if (namespace) {
|
|
2023
|
+
namespace.addEventListener("change", () => {
|
|
2024
|
+
clearError();
|
|
2025
|
+
loadTables().catch(showError);
|
|
2026
|
+
});
|
|
2027
|
+
}
|
|
2028
|
+
loadTables().catch(showError);
|
|
2029
|
+
}
|
|
1869
2030
|
function bootAdmin(config) {
|
|
1870
2031
|
const fieldKinds = ["string", "number", "boolean", "null", "object", "array", "unknown"];
|
|
1871
2032
|
const sources = ["declared", "inferred", "mixed"];
|
|
@@ -2542,6 +2703,22 @@ function bootAdmin(config) {
|
|
|
2542
2703
|
panel.script = value.script;
|
|
2543
2704
|
return panel;
|
|
2544
2705
|
};
|
|
2706
|
+
const decodeExtension = (value) => {
|
|
2707
|
+
if (!isRecord2(value))
|
|
2708
|
+
return void 0;
|
|
2709
|
+
if (value.kind === "sql") {
|
|
2710
|
+
return {
|
|
2711
|
+
kind: "sql",
|
|
2712
|
+
id: typeof value.id === "string" && value.id !== "" ? value.id : "sql",
|
|
2713
|
+
title: typeof value.title === "string" && value.title !== "" ? value.title : "SQL",
|
|
2714
|
+
description: typeof value.description === "string" ? value.description : "Browse tables and run queries."
|
|
2715
|
+
};
|
|
2716
|
+
}
|
|
2717
|
+
if (value.kind !== "panel")
|
|
2718
|
+
return void 0;
|
|
2719
|
+
const panel = decodePanel(value);
|
|
2720
|
+
return panel === void 0 ? void 0 : { kind: "panel", ...panel };
|
|
2721
|
+
};
|
|
2545
2722
|
const mountPanels = (panels) => {
|
|
2546
2723
|
const nav = el("nav", HTMLElement);
|
|
2547
2724
|
const views = el("views", HTMLElement);
|
|
@@ -2595,10 +2772,48 @@ function bootAdmin(config) {
|
|
|
2595
2772
|
return decoded === void 0 ? [] : [decoded];
|
|
2596
2773
|
});
|
|
2597
2774
|
mountPanels(panels);
|
|
2775
|
+
const extensions = requireList(isRecord2(manifest) ? manifest.extensions : void 0, "Extensions").flatMap((extension) => {
|
|
2776
|
+
const decoded = decodeExtension(extension);
|
|
2777
|
+
return decoded === void 0 ? [] : [decoded];
|
|
2778
|
+
});
|
|
2779
|
+
const extensionPanels = extensions.flatMap((extension) => extension.kind === "panel" ? [extension] : []);
|
|
2780
|
+
mountPanels(extensionPanels);
|
|
2781
|
+
for (const extension of extensions) {
|
|
2782
|
+
if (extension.kind !== "sql")
|
|
2783
|
+
continue;
|
|
2784
|
+
const nav = el("nav", HTMLElement);
|
|
2785
|
+
const views = el("views", HTMLElement);
|
|
2786
|
+
const button = document.createElement("button");
|
|
2787
|
+
button.type = "button";
|
|
2788
|
+
button.dataset.view = extension.id;
|
|
2789
|
+
button.textContent = extension.title;
|
|
2790
|
+
nav.append(button);
|
|
2791
|
+
const section = document.createElement("section");
|
|
2792
|
+
section.className = "view";
|
|
2793
|
+
section.id = `view-${extension.id}`;
|
|
2794
|
+
section.hidden = true;
|
|
2795
|
+
const title = document.createElement("h2");
|
|
2796
|
+
title.textContent = extension.title;
|
|
2797
|
+
const lede = document.createElement("p");
|
|
2798
|
+
lede.className = "lede";
|
|
2799
|
+
lede.textContent = extension.description;
|
|
2800
|
+
const body = document.createElement("div");
|
|
2801
|
+
body.className = "panel-body";
|
|
2802
|
+
section.append(title, lede, body);
|
|
2803
|
+
views.append(section);
|
|
2804
|
+
mountSqlExplorer(body, panelApi);
|
|
2805
|
+
}
|
|
2598
2806
|
return refresh();
|
|
2599
2807
|
}).catch(showError);
|
|
2600
2808
|
}
|
|
2601
|
-
var clientPrelude = [
|
|
2809
|
+
var clientPrelude = [
|
|
2810
|
+
isRecord2,
|
|
2811
|
+
mountAdminBrand,
|
|
2812
|
+
startAdminBrand,
|
|
2813
|
+
faultPresetList,
|
|
2814
|
+
mountSqlExplorer,
|
|
2815
|
+
bootAdmin
|
|
2816
|
+
].map((fn) => fn.toString()).join("\n");
|
|
2602
2817
|
var adminClientSource = (config) => {
|
|
2603
2818
|
const payload = JSON.stringify(config).replace(/</g, "\\u003c");
|
|
2604
2819
|
const entry = bootAdmin.name;
|
|
@@ -2648,19 +2863,33 @@ var STANDARD_ADMIN_ROUTES = [
|
|
|
2648
2863
|
"GET /ui/manifest"
|
|
2649
2864
|
];
|
|
2650
2865
|
var PANEL_ID = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
|
|
2866
|
+
var RESERVED_VIEWS = /* @__PURE__ */ new Set(["overview", "state", "clock", "faults", "journal", "routes"]);
|
|
2867
|
+
var checkPanel = (panel, seen, label) => {
|
|
2868
|
+
if (!PANEL_ID.test(panel.id)) {
|
|
2869
|
+
throw new RangeError(`${label} id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
|
|
2870
|
+
}
|
|
2871
|
+
if (RESERVED_VIEWS.has(panel.id)) {
|
|
2872
|
+
throw new RangeError(`${label} id ${panel.id} is reserved by the admin shell`);
|
|
2873
|
+
}
|
|
2874
|
+
if (seen.has(panel.id))
|
|
2875
|
+
throw new RangeError(`duplicate admin view id ${panel.id}`);
|
|
2876
|
+
seen.add(panel.id);
|
|
2877
|
+
if (panel.title.trim() === "")
|
|
2878
|
+
throw new RangeError(`${label} ${panel.id} needs a title`);
|
|
2879
|
+
};
|
|
2651
2880
|
var assertAdminUi = (ui) => {
|
|
2652
|
-
if (!ui
|
|
2881
|
+
if (!ui)
|
|
2653
2882
|
return;
|
|
2654
2883
|
const seen = /* @__PURE__ */ new Set();
|
|
2655
|
-
for (const panel of ui.panels)
|
|
2656
|
-
|
|
2657
|
-
|
|
2884
|
+
for (const panel of ui.panels ?? [])
|
|
2885
|
+
checkPanel(panel, seen, "admin panel");
|
|
2886
|
+
for (const extension of ui.extensions ?? []) {
|
|
2887
|
+
if (extension.kind === "panel") {
|
|
2888
|
+
checkPanel(extension, seen, "admin extension");
|
|
2889
|
+
continue;
|
|
2658
2890
|
}
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
seen.add(panel.id);
|
|
2662
|
-
if (panel.title.trim() === "")
|
|
2663
|
-
throw new RangeError(`admin panel ${panel.id} needs a title`);
|
|
2891
|
+
const id = extension.id ?? "sql";
|
|
2892
|
+
checkPanel({ id, title: extension.title ?? "SQL" }, seen, "admin extension");
|
|
2664
2893
|
}
|
|
2665
2894
|
};
|
|
2666
2895
|
|
|
@@ -2894,6 +3123,12 @@ var renderAdminDocument = (service) => {
|
|
|
2894
3123
|
border-radius: 999px; padding: 4px 8px;
|
|
2895
3124
|
}
|
|
2896
3125
|
.chip i { color: var(--faint); font-style: normal; }
|
|
3126
|
+
.sql-layout {
|
|
3127
|
+
display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 16px;
|
|
3128
|
+
}
|
|
3129
|
+
.sql-tables { display: flex; flex-direction: column; gap: 4px; max-height: 28rem; overflow: auto; }
|
|
3130
|
+
.sql-tables button { text-align: left; }
|
|
3131
|
+
.sql-input { font-family: var(--mono); min-height: 7rem; width: 100%; }
|
|
2897
3132
|
table { width: 100%; border-collapse: collapse; font-size: 14px; }
|
|
2898
3133
|
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
|
|
2899
3134
|
th { color: var(--faint); font-weight: 600; font-size: 12px; }
|
|
@@ -2957,7 +3192,7 @@ var renderAdminDocument = (service) => {
|
|
|
2957
3192
|
padding: 8px;
|
|
2958
3193
|
}
|
|
2959
3194
|
nav.side button { white-space: nowrap; flex: none; }
|
|
2960
|
-
.split { grid-template-columns: minmax(0, 1fr); }
|
|
3195
|
+
.split, .sql-layout { grid-template-columns: minmax(0, 1fr); }
|
|
2961
3196
|
main { padding: 14px; }
|
|
2962
3197
|
table, thead, tbody, tr, th, td { display: block; }
|
|
2963
3198
|
thead { display: none; }
|
|
@@ -3128,6 +3363,24 @@ var json2 = (body) => new Response(JSON.stringify(body), {
|
|
|
3128
3363
|
status: 200,
|
|
3129
3364
|
headers: { "content-type": "application/json; charset=utf-8" }
|
|
3130
3365
|
});
|
|
3366
|
+
var describeExtension = (extension) => {
|
|
3367
|
+
if (extension.kind === "sql") {
|
|
3368
|
+
return {
|
|
3369
|
+
kind: "sql",
|
|
3370
|
+
id: extension.id ?? "sql",
|
|
3371
|
+
title: extension.title ?? "SQL",
|
|
3372
|
+
...extension.description !== void 0 ? { description: extension.description } : {}
|
|
3373
|
+
};
|
|
3374
|
+
}
|
|
3375
|
+
return {
|
|
3376
|
+
kind: "panel",
|
|
3377
|
+
id: extension.id,
|
|
3378
|
+
title: extension.title,
|
|
3379
|
+
...extension.description !== void 0 ? { description: extension.description } : {},
|
|
3380
|
+
html: extension.html,
|
|
3381
|
+
...extension.script !== void 0 ? { script: extension.script } : {}
|
|
3382
|
+
};
|
|
3383
|
+
};
|
|
3131
3384
|
var adminUiRoutes = (service, ui) => {
|
|
3132
3385
|
const shell = () => renderAdminDocument(service);
|
|
3133
3386
|
const document3 = () => ui?.render ? ui.render({ service, defaultHtml: shell }) : shell();
|
|
@@ -3142,7 +3395,8 @@ var adminUiRoutes = (service, ui) => {
|
|
|
3142
3395
|
...panel.description !== void 0 ? { description: panel.description } : {},
|
|
3143
3396
|
html: panel.html,
|
|
3144
3397
|
...panel.script !== void 0 ? { script: panel.script } : {}
|
|
3145
|
-
}))
|
|
3398
|
+
})),
|
|
3399
|
+
extensions: (ui?.extensions ?? []).map(describeExtension)
|
|
3146
3400
|
})
|
|
3147
3401
|
};
|
|
3148
3402
|
};
|
|
@@ -3819,7 +4073,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
3819
4073
|
};
|
|
3820
4074
|
|
|
3821
4075
|
// ../core/dist/version.js
|
|
3822
|
-
var PACKAGE_VERSION = true ? "1.
|
|
4076
|
+
var PACKAGE_VERSION = true ? "1.7.1" : UNRELEASED_VERSION;
|
|
3823
4077
|
|
|
3824
4078
|
// ../core/dist/signing.js
|
|
3825
4079
|
var encoder = new TextEncoder();
|
|
@@ -6983,4 +7237,4 @@ export {
|
|
|
6983
7237
|
titanEmbedding,
|
|
6984
7238
|
BedrockAPI
|
|
6985
7239
|
};
|
|
6986
|
-
//# sourceMappingURL=chunk-
|
|
7240
|
+
//# sourceMappingURL=chunk-KWJYXFIF.js.map
|