@crvouga/mockingbird-service-fullscript 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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog — @crvouga/mockingbird-service-fullscript
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
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createRuntime
3
- } from "./chunk-UZIN4H2O.js";
3
+ } from "./chunk-VPJ64KU3.js";
4
4
 
5
5
  // ../../adapters/node/dist/cli.js
6
6
  import { readFile } from "node:fs/promises";
@@ -381,4 +381,4 @@ export {
381
381
  createServer2 as createServer,
382
382
  serveTarget
383
383
  };
384
- //# sourceMappingURL=chunk-AJ6RYUHV.js.map
384
+ //# sourceMappingURL=chunk-DI3IPCT2.js.map
@@ -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());
@@ -1887,6 +1887,167 @@ function faultPresetList(value) {
1887
1887
  })
1888
1888
  };
1889
1889
  }
1890
+ function mountSqlExplorer(root, api) {
1891
+ const cell = (value) => {
1892
+ if (value === null || value === void 0)
1893
+ return "";
1894
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1895
+ return String(value);
1896
+ }
1897
+ return JSON.stringify(value) ?? "";
1898
+ };
1899
+ root.replaceChildren();
1900
+ const layout = document.createElement("div");
1901
+ layout.className = "sql-layout";
1902
+ const tables = document.createElement("div");
1903
+ tables.className = "sql-tables";
1904
+ const stack = document.createElement("div");
1905
+ stack.className = "stack";
1906
+ const banner = document.createElement("p");
1907
+ banner.className = "banner";
1908
+ const grid = document.createElement("div");
1909
+ const input = document.createElement("textarea");
1910
+ input.className = "sql-input";
1911
+ input.spellcheck = false;
1912
+ input.placeholder = "SELECT * FROM ...";
1913
+ const actions = document.createElement("div");
1914
+ actions.className = "row-actions";
1915
+ const run = document.createElement("button");
1916
+ run.type = "button";
1917
+ run.textContent = "Run";
1918
+ actions.append(run);
1919
+ const result = document.createElement("pre");
1920
+ stack.append(banner, grid, input, actions, result);
1921
+ layout.append(tables, stack);
1922
+ root.append(layout);
1923
+ const showError = (error) => {
1924
+ banner.textContent = error instanceof Error ? error.message : String(error);
1925
+ banner.classList.add("show");
1926
+ };
1927
+ const clearError = () => {
1928
+ banner.textContent = "";
1929
+ banner.classList.remove("show");
1930
+ };
1931
+ const renderGrid = (columns, rows) => {
1932
+ grid.replaceChildren();
1933
+ if (columns.length === 0) {
1934
+ const empty = document.createElement("p");
1935
+ empty.className = "empty";
1936
+ empty.textContent = "No rows.";
1937
+ grid.append(empty);
1938
+ return;
1939
+ }
1940
+ const table = document.createElement("table");
1941
+ const head = document.createElement("thead");
1942
+ const headRow = document.createElement("tr");
1943
+ for (const column of columns) {
1944
+ const th = document.createElement("th");
1945
+ th.textContent = column;
1946
+ headRow.append(th);
1947
+ }
1948
+ head.append(headRow);
1949
+ const body = document.createElement("tbody");
1950
+ for (const row of rows) {
1951
+ const tr = document.createElement("tr");
1952
+ for (const column of columns) {
1953
+ const td = document.createElement("td");
1954
+ td.dataset.label = column;
1955
+ td.textContent = cell(row[column]);
1956
+ tr.append(td);
1957
+ }
1958
+ body.append(tr);
1959
+ }
1960
+ table.append(head, body);
1961
+ grid.append(table);
1962
+ };
1963
+ const rowsOf = (value) => {
1964
+ if (!isRecord2(value) || !Array.isArray(value.rows))
1965
+ return [];
1966
+ return value.rows.flatMap((row) => isRecord2(row) ? [row] : []);
1967
+ };
1968
+ const columnsOf = (value, rows) => {
1969
+ if (isRecord2(value) && Array.isArray(value.columns)) {
1970
+ const named = value.columns.flatMap((column) => typeof column === "string" ? [column] : []);
1971
+ if (named.length > 0)
1972
+ return named;
1973
+ }
1974
+ const first = rows[0];
1975
+ return first === void 0 ? [] : Object.keys(first);
1976
+ };
1977
+ let selected = "";
1978
+ const loadPage = async (schema, name) => {
1979
+ selected = `${schema}.${name}`;
1980
+ const page2 = await api.get(`/sql/tables/${encodeURIComponent(schema)}/${encodeURIComponent(name)}?limit=50`);
1981
+ const rows = rowsOf(page2);
1982
+ renderGrid(columnsOf(page2, rows), rows);
1983
+ const total = isRecord2(page2) && typeof page2.total === "number" ? page2.total : rows.length;
1984
+ result.textContent = `${selected} \xB7 ${total} rows`;
1985
+ for (const button of tables.querySelectorAll("button")) {
1986
+ if (!(button instanceof HTMLButtonElement))
1987
+ continue;
1988
+ button.setAttribute("aria-current", button.dataset.schema === schema && button.dataset.table === name ? "true" : "false");
1989
+ }
1990
+ };
1991
+ const loadTables = async () => {
1992
+ const payload = await api.get("/sql/tables");
1993
+ const listed = isRecord2(payload) && Array.isArray(payload.tables) ? payload.tables : [];
1994
+ tables.replaceChildren();
1995
+ if (listed.length === 0) {
1996
+ const empty = document.createElement("p");
1997
+ empty.className = "empty";
1998
+ empty.textContent = "No tables.";
1999
+ tables.append(empty);
2000
+ return;
2001
+ }
2002
+ for (const item of listed) {
2003
+ if (!isRecord2(item) || typeof item.schema !== "string" || typeof item.name !== "string")
2004
+ continue;
2005
+ const button = document.createElement("button");
2006
+ button.type = "button";
2007
+ button.dataset.schema = item.schema;
2008
+ button.dataset.table = item.name;
2009
+ button.textContent = `${item.schema}.${item.name}`;
2010
+ tables.append(button);
2011
+ }
2012
+ };
2013
+ tables.addEventListener("click", (event) => {
2014
+ const target = event.target;
2015
+ if (!(target instanceof Element))
2016
+ return;
2017
+ const button = target.closest("button");
2018
+ if (!(button instanceof HTMLButtonElement))
2019
+ return;
2020
+ const schema = button.dataset.schema;
2021
+ const name = button.dataset.table;
2022
+ if (schema === void 0 || name === void 0)
2023
+ return;
2024
+ clearError();
2025
+ loadPage(schema, name).catch(showError);
2026
+ });
2027
+ run.addEventListener("click", () => {
2028
+ const sql = input.value.trim();
2029
+ if (sql === "") {
2030
+ showError(new Error("Enter a statement"));
2031
+ return;
2032
+ }
2033
+ clearError();
2034
+ api.send("POST", "/sql/query", { sql }).then((payload) => {
2035
+ const rows = rowsOf(payload);
2036
+ renderGrid(columnsOf(payload, rows), rows);
2037
+ const count = isRecord2(payload) && typeof payload.rowCount === "number" ? payload.rowCount : rows.length;
2038
+ const truncated = isRecord2(payload) && payload.truncated === true ? " (truncated)" : "";
2039
+ result.textContent = `${count} rows${truncated}`;
2040
+ }).catch(showError);
2041
+ });
2042
+ const namespace = document.getElementById("namespace");
2043
+ if (namespace) {
2044
+ namespace.addEventListener("change", () => {
2045
+ clearError();
2046
+ loadTables().catch(showError);
2047
+ });
2048
+ }
2049
+ loadTables().catch(showError);
2050
+ }
1890
2051
  function bootAdmin(config) {
1891
2052
  const fieldKinds = ["string", "number", "boolean", "null", "object", "array", "unknown"];
1892
2053
  const sources = ["declared", "inferred", "mixed"];
@@ -2563,6 +2724,22 @@ function bootAdmin(config) {
2563
2724
  panel.script = value.script;
2564
2725
  return panel;
2565
2726
  };
2727
+ const decodeExtension = (value) => {
2728
+ if (!isRecord2(value))
2729
+ return void 0;
2730
+ if (value.kind === "sql") {
2731
+ return {
2732
+ kind: "sql",
2733
+ id: typeof value.id === "string" && value.id !== "" ? value.id : "sql",
2734
+ title: typeof value.title === "string" && value.title !== "" ? value.title : "SQL",
2735
+ description: typeof value.description === "string" ? value.description : "Browse tables and run queries."
2736
+ };
2737
+ }
2738
+ if (value.kind !== "panel")
2739
+ return void 0;
2740
+ const panel = decodePanel(value);
2741
+ return panel === void 0 ? void 0 : { kind: "panel", ...panel };
2742
+ };
2566
2743
  const mountPanels = (panels) => {
2567
2744
  const nav = el("nav", HTMLElement);
2568
2745
  const views = el("views", HTMLElement);
@@ -2616,10 +2793,48 @@ function bootAdmin(config) {
2616
2793
  return decoded === void 0 ? [] : [decoded];
2617
2794
  });
2618
2795
  mountPanels(panels);
2796
+ const extensions = requireList(isRecord2(manifest) ? manifest.extensions : void 0, "Extensions").flatMap((extension) => {
2797
+ const decoded = decodeExtension(extension);
2798
+ return decoded === void 0 ? [] : [decoded];
2799
+ });
2800
+ const extensionPanels = extensions.flatMap((extension) => extension.kind === "panel" ? [extension] : []);
2801
+ mountPanels(extensionPanels);
2802
+ for (const extension of extensions) {
2803
+ if (extension.kind !== "sql")
2804
+ continue;
2805
+ const nav = el("nav", HTMLElement);
2806
+ const views = el("views", HTMLElement);
2807
+ const button = document.createElement("button");
2808
+ button.type = "button";
2809
+ button.dataset.view = extension.id;
2810
+ button.textContent = extension.title;
2811
+ nav.append(button);
2812
+ const section = document.createElement("section");
2813
+ section.className = "view";
2814
+ section.id = `view-${extension.id}`;
2815
+ section.hidden = true;
2816
+ const title = document.createElement("h2");
2817
+ title.textContent = extension.title;
2818
+ const lede = document.createElement("p");
2819
+ lede.className = "lede";
2820
+ lede.textContent = extension.description;
2821
+ const body = document.createElement("div");
2822
+ body.className = "panel-body";
2823
+ section.append(title, lede, body);
2824
+ views.append(section);
2825
+ mountSqlExplorer(body, panelApi);
2826
+ }
2619
2827
  return refresh();
2620
2828
  }).catch(showError);
2621
2829
  }
2622
- var clientPrelude = [isRecord2, mountAdminBrand, startAdminBrand, faultPresetList, bootAdmin].map((fn) => fn.toString()).join("\n");
2830
+ var clientPrelude = [
2831
+ isRecord2,
2832
+ mountAdminBrand,
2833
+ startAdminBrand,
2834
+ faultPresetList,
2835
+ mountSqlExplorer,
2836
+ bootAdmin
2837
+ ].map((fn) => fn.toString()).join("\n");
2623
2838
  var adminClientSource = (config) => {
2624
2839
  const payload = JSON.stringify(config).replace(/</g, "\\u003c");
2625
2840
  const entry = bootAdmin.name;
@@ -2669,19 +2884,33 @@ var STANDARD_ADMIN_ROUTES = [
2669
2884
  "GET /ui/manifest"
2670
2885
  ];
2671
2886
  var PANEL_ID = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
2887
+ var RESERVED_VIEWS = /* @__PURE__ */ new Set(["overview", "state", "clock", "faults", "journal", "routes"]);
2888
+ var checkPanel = (panel, seen, label) => {
2889
+ if (!PANEL_ID.test(panel.id)) {
2890
+ throw new RangeError(`${label} id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
2891
+ }
2892
+ if (RESERVED_VIEWS.has(panel.id)) {
2893
+ throw new RangeError(`${label} id ${panel.id} is reserved by the admin shell`);
2894
+ }
2895
+ if (seen.has(panel.id))
2896
+ throw new RangeError(`duplicate admin view id ${panel.id}`);
2897
+ seen.add(panel.id);
2898
+ if (panel.title.trim() === "")
2899
+ throw new RangeError(`${label} ${panel.id} needs a title`);
2900
+ };
2672
2901
  var assertAdminUi = (ui) => {
2673
- if (!ui?.panels)
2902
+ if (!ui)
2674
2903
  return;
2675
2904
  const seen = /* @__PURE__ */ new Set();
2676
- for (const panel of ui.panels) {
2677
- if (!PANEL_ID.test(panel.id)) {
2678
- throw new RangeError(`admin panel id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
2905
+ for (const panel of ui.panels ?? [])
2906
+ checkPanel(panel, seen, "admin panel");
2907
+ for (const extension of ui.extensions ?? []) {
2908
+ if (extension.kind === "panel") {
2909
+ checkPanel(extension, seen, "admin extension");
2910
+ continue;
2679
2911
  }
2680
- if (seen.has(panel.id))
2681
- throw new RangeError(`duplicate admin panel id ${panel.id}`);
2682
- seen.add(panel.id);
2683
- if (panel.title.trim() === "")
2684
- throw new RangeError(`admin panel ${panel.id} needs a title`);
2912
+ const id = extension.id ?? "sql";
2913
+ checkPanel({ id, title: extension.title ?? "SQL" }, seen, "admin extension");
2685
2914
  }
2686
2915
  };
2687
2916
 
@@ -2915,6 +3144,12 @@ var renderAdminDocument = (service) => {
2915
3144
  border-radius: 999px; padding: 4px 8px;
2916
3145
  }
2917
3146
  .chip i { color: var(--faint); font-style: normal; }
3147
+ .sql-layout {
3148
+ display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 16px;
3149
+ }
3150
+ .sql-tables { display: flex; flex-direction: column; gap: 4px; max-height: 28rem; overflow: auto; }
3151
+ .sql-tables button { text-align: left; }
3152
+ .sql-input { font-family: var(--mono); min-height: 7rem; width: 100%; }
2918
3153
  table { width: 100%; border-collapse: collapse; font-size: 14px; }
2919
3154
  th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
2920
3155
  th { color: var(--faint); font-weight: 600; font-size: 12px; }
@@ -2978,7 +3213,7 @@ var renderAdminDocument = (service) => {
2978
3213
  padding: 8px;
2979
3214
  }
2980
3215
  nav.side button { white-space: nowrap; flex: none; }
2981
- .split { grid-template-columns: minmax(0, 1fr); }
3216
+ .split, .sql-layout { grid-template-columns: minmax(0, 1fr); }
2982
3217
  main { padding: 14px; }
2983
3218
  table, thead, tbody, tr, th, td { display: block; }
2984
3219
  thead { display: none; }
@@ -3149,6 +3384,24 @@ var json2 = (body) => new Response(JSON.stringify(body), {
3149
3384
  status: 200,
3150
3385
  headers: { "content-type": "application/json; charset=utf-8" }
3151
3386
  });
3387
+ var describeExtension = (extension) => {
3388
+ if (extension.kind === "sql") {
3389
+ return {
3390
+ kind: "sql",
3391
+ id: extension.id ?? "sql",
3392
+ title: extension.title ?? "SQL",
3393
+ ...extension.description !== void 0 ? { description: extension.description } : {}
3394
+ };
3395
+ }
3396
+ return {
3397
+ kind: "panel",
3398
+ id: extension.id,
3399
+ title: extension.title,
3400
+ ...extension.description !== void 0 ? { description: extension.description } : {},
3401
+ html: extension.html,
3402
+ ...extension.script !== void 0 ? { script: extension.script } : {}
3403
+ };
3404
+ };
3152
3405
  var adminUiRoutes = (service, ui) => {
3153
3406
  const shell = () => renderAdminDocument(service);
3154
3407
  const document3 = () => ui?.render ? ui.render({ service, defaultHtml: shell }) : shell();
@@ -3163,7 +3416,8 @@ var adminUiRoutes = (service, ui) => {
3163
3416
  ...panel.description !== void 0 ? { description: panel.description } : {},
3164
3417
  html: panel.html,
3165
3418
  ...panel.script !== void 0 ? { script: panel.script } : {}
3166
- }))
3419
+ })),
3420
+ extensions: (ui?.extensions ?? []).map(describeExtension)
3167
3421
  })
3168
3422
  };
3169
3423
  };
@@ -3840,7 +4094,7 @@ var stateAdminRoutes = (routes) => {
3840
4094
  };
3841
4095
 
3842
4096
  // ../core/dist/version.js
3843
- var PACKAGE_VERSION = true ? "1.6.1" : UNRELEASED_VERSION;
4097
+ var PACKAGE_VERSION = true ? "1.7.1" : UNRELEASED_VERSION;
3844
4098
 
3845
4099
  // ../core/dist/signing.js
3846
4100
  var encoder = new TextEncoder();
@@ -5766,4 +6020,4 @@ export {
5766
6020
  envelope,
5767
6021
  FullscriptAPI
5768
6022
  };
5769
- //# sourceMappingURL=chunk-UZIN4H2O.js.map
6023
+ //# sourceMappingURL=chunk-VPJ64KU3.js.map