@crvouga/mockingbird-service-edamam 1.6.1 → 1.7.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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog — @crvouga/mockingbird-service-edamam
2
2
 
3
+ ## 1.7.0 (2026-10-01)
4
+
5
+ ### Features
6
+
7
+ - record SQL timelines and serve the admin explorer ([8ced17a](https://github.com/crvouga/mockingbird/commit/8ced17ac398e386ef4e9d7e01fc7744c34b95d07))
8
+
9
+ ### Dependencies
10
+
11
+ - `@crvouga/mockingbird-service-sqlite`
12
+
3
13
  ## 1.6.1 (2026-09-30)
4
14
 
5
15
  ### Fixes and improvements
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createRuntime
3
- } from "./chunk-JJTHVJWR.js";
3
+ } from "./chunk-T5KB3LZL.js";
4
4
 
5
5
  // ../../adapters/node/dist/cli.js
6
6
  import { readFile } from "node:fs/promises";
@@ -356,4 +356,4 @@ export {
356
356
  createServer2 as createServer,
357
357
  serveTarget
358
358
  };
359
- //# sourceMappingURL=chunk-6LNDHRUX.js.map
359
+ //# sourceMappingURL=chunk-DY2FJKJG.js.map
@@ -1857,6 +1857,167 @@ function faultPresetList(value) {
1857
1857
  })
1858
1858
  };
1859
1859
  }
1860
+ function mountSqlExplorer(root, api) {
1861
+ const cell = (value) => {
1862
+ if (value === null || value === void 0)
1863
+ return "";
1864
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1865
+ return String(value);
1866
+ }
1867
+ return JSON.stringify(value) ?? "";
1868
+ };
1869
+ root.replaceChildren();
1870
+ const layout = document.createElement("div");
1871
+ layout.className = "sql-layout";
1872
+ const tables = document.createElement("div");
1873
+ tables.className = "sql-tables";
1874
+ const stack = document.createElement("div");
1875
+ stack.className = "stack";
1876
+ const banner = document.createElement("p");
1877
+ banner.className = "banner";
1878
+ const grid = document.createElement("div");
1879
+ const input = document.createElement("textarea");
1880
+ input.className = "sql-input";
1881
+ input.spellcheck = false;
1882
+ input.placeholder = "SELECT * FROM ...";
1883
+ const actions = document.createElement("div");
1884
+ actions.className = "row-actions";
1885
+ const run = document.createElement("button");
1886
+ run.type = "button";
1887
+ run.textContent = "Run";
1888
+ actions.append(run);
1889
+ const result = document.createElement("pre");
1890
+ stack.append(banner, grid, input, actions, result);
1891
+ layout.append(tables, stack);
1892
+ root.append(layout);
1893
+ const showError = (error) => {
1894
+ banner.textContent = error instanceof Error ? error.message : String(error);
1895
+ banner.classList.add("show");
1896
+ };
1897
+ const clearError = () => {
1898
+ banner.textContent = "";
1899
+ banner.classList.remove("show");
1900
+ };
1901
+ const renderGrid = (columns, rows) => {
1902
+ grid.replaceChildren();
1903
+ if (columns.length === 0) {
1904
+ const empty = document.createElement("p");
1905
+ empty.className = "empty";
1906
+ empty.textContent = "No rows.";
1907
+ grid.append(empty);
1908
+ return;
1909
+ }
1910
+ const table = document.createElement("table");
1911
+ const head = document.createElement("thead");
1912
+ const headRow = document.createElement("tr");
1913
+ for (const column of columns) {
1914
+ const th = document.createElement("th");
1915
+ th.textContent = column;
1916
+ headRow.append(th);
1917
+ }
1918
+ head.append(headRow);
1919
+ const body = document.createElement("tbody");
1920
+ for (const row of rows) {
1921
+ const tr = document.createElement("tr");
1922
+ for (const column of columns) {
1923
+ const td = document.createElement("td");
1924
+ td.dataset.label = column;
1925
+ td.textContent = cell(row[column]);
1926
+ tr.append(td);
1927
+ }
1928
+ body.append(tr);
1929
+ }
1930
+ table.append(head, body);
1931
+ grid.append(table);
1932
+ };
1933
+ const rowsOf = (value) => {
1934
+ if (!isRecord2(value) || !Array.isArray(value.rows))
1935
+ return [];
1936
+ return value.rows.flatMap((row) => isRecord2(row) ? [row] : []);
1937
+ };
1938
+ const columnsOf = (value, rows) => {
1939
+ if (isRecord2(value) && Array.isArray(value.columns)) {
1940
+ const named = value.columns.flatMap((column) => typeof column === "string" ? [column] : []);
1941
+ if (named.length > 0)
1942
+ return named;
1943
+ }
1944
+ const first = rows[0];
1945
+ return first === void 0 ? [] : Object.keys(first);
1946
+ };
1947
+ let selected = "";
1948
+ const loadPage = async (schema, name) => {
1949
+ selected = `${schema}.${name}`;
1950
+ const page = await api.get(`/sql/tables/${encodeURIComponent(schema)}/${encodeURIComponent(name)}?limit=50`);
1951
+ const rows = rowsOf(page);
1952
+ renderGrid(columnsOf(page, rows), rows);
1953
+ const total = isRecord2(page) && typeof page.total === "number" ? page.total : rows.length;
1954
+ result.textContent = `${selected} \xB7 ${total} rows`;
1955
+ for (const button of tables.querySelectorAll("button")) {
1956
+ if (!(button instanceof HTMLButtonElement))
1957
+ continue;
1958
+ button.setAttribute("aria-current", button.dataset.schema === schema && button.dataset.table === name ? "true" : "false");
1959
+ }
1960
+ };
1961
+ const loadTables = async () => {
1962
+ const payload = await api.get("/sql/tables");
1963
+ const listed = isRecord2(payload) && Array.isArray(payload.tables) ? payload.tables : [];
1964
+ tables.replaceChildren();
1965
+ if (listed.length === 0) {
1966
+ const empty = document.createElement("p");
1967
+ empty.className = "empty";
1968
+ empty.textContent = "No tables.";
1969
+ tables.append(empty);
1970
+ return;
1971
+ }
1972
+ for (const item of listed) {
1973
+ if (!isRecord2(item) || typeof item.schema !== "string" || typeof item.name !== "string")
1974
+ continue;
1975
+ const button = document.createElement("button");
1976
+ button.type = "button";
1977
+ button.dataset.schema = item.schema;
1978
+ button.dataset.table = item.name;
1979
+ button.textContent = `${item.schema}.${item.name}`;
1980
+ tables.append(button);
1981
+ }
1982
+ };
1983
+ tables.addEventListener("click", (event) => {
1984
+ const target = event.target;
1985
+ if (!(target instanceof Element))
1986
+ return;
1987
+ const button = target.closest("button");
1988
+ if (!(button instanceof HTMLButtonElement))
1989
+ return;
1990
+ const schema = button.dataset.schema;
1991
+ const name = button.dataset.table;
1992
+ if (schema === void 0 || name === void 0)
1993
+ return;
1994
+ clearError();
1995
+ loadPage(schema, name).catch(showError);
1996
+ });
1997
+ run.addEventListener("click", () => {
1998
+ const sql = input.value.trim();
1999
+ if (sql === "") {
2000
+ showError(new Error("Enter a statement"));
2001
+ return;
2002
+ }
2003
+ clearError();
2004
+ api.send("POST", "/sql/query", { sql }).then((payload) => {
2005
+ const rows = rowsOf(payload);
2006
+ renderGrid(columnsOf(payload, rows), rows);
2007
+ const count = isRecord2(payload) && typeof payload.rowCount === "number" ? payload.rowCount : rows.length;
2008
+ const truncated = isRecord2(payload) && payload.truncated === true ? " (truncated)" : "";
2009
+ result.textContent = `${count} rows${truncated}`;
2010
+ }).catch(showError);
2011
+ });
2012
+ const namespace = document.getElementById("namespace");
2013
+ if (namespace) {
2014
+ namespace.addEventListener("change", () => {
2015
+ clearError();
2016
+ loadTables().catch(showError);
2017
+ });
2018
+ }
2019
+ loadTables().catch(showError);
2020
+ }
1860
2021
  function bootAdmin(config) {
1861
2022
  const fieldKinds = ["string", "number", "boolean", "null", "object", "array", "unknown"];
1862
2023
  const sources = ["declared", "inferred", "mixed"];
@@ -2533,6 +2694,22 @@ function bootAdmin(config) {
2533
2694
  panel.script = value.script;
2534
2695
  return panel;
2535
2696
  };
2697
+ const decodeExtension = (value) => {
2698
+ if (!isRecord2(value))
2699
+ return void 0;
2700
+ if (value.kind === "sql") {
2701
+ return {
2702
+ kind: "sql",
2703
+ id: typeof value.id === "string" && value.id !== "" ? value.id : "sql",
2704
+ title: typeof value.title === "string" && value.title !== "" ? value.title : "SQL",
2705
+ description: typeof value.description === "string" ? value.description : "Browse tables and run queries."
2706
+ };
2707
+ }
2708
+ if (value.kind !== "panel")
2709
+ return void 0;
2710
+ const panel = decodePanel(value);
2711
+ return panel === void 0 ? void 0 : { kind: "panel", ...panel };
2712
+ };
2536
2713
  const mountPanels = (panels) => {
2537
2714
  const nav = el("nav", HTMLElement);
2538
2715
  const views = el("views", HTMLElement);
@@ -2586,10 +2763,48 @@ function bootAdmin(config) {
2586
2763
  return decoded === void 0 ? [] : [decoded];
2587
2764
  });
2588
2765
  mountPanels(panels);
2766
+ const extensions = requireList(isRecord2(manifest) ? manifest.extensions : void 0, "Extensions").flatMap((extension) => {
2767
+ const decoded = decodeExtension(extension);
2768
+ return decoded === void 0 ? [] : [decoded];
2769
+ });
2770
+ const extensionPanels = extensions.flatMap((extension) => extension.kind === "panel" ? [extension] : []);
2771
+ mountPanels(extensionPanels);
2772
+ for (const extension of extensions) {
2773
+ if (extension.kind !== "sql")
2774
+ continue;
2775
+ const nav = el("nav", HTMLElement);
2776
+ const views = el("views", HTMLElement);
2777
+ const button = document.createElement("button");
2778
+ button.type = "button";
2779
+ button.dataset.view = extension.id;
2780
+ button.textContent = extension.title;
2781
+ nav.append(button);
2782
+ const section = document.createElement("section");
2783
+ section.className = "view";
2784
+ section.id = `view-${extension.id}`;
2785
+ section.hidden = true;
2786
+ const title = document.createElement("h2");
2787
+ title.textContent = extension.title;
2788
+ const lede = document.createElement("p");
2789
+ lede.className = "lede";
2790
+ lede.textContent = extension.description;
2791
+ const body = document.createElement("div");
2792
+ body.className = "panel-body";
2793
+ section.append(title, lede, body);
2794
+ views.append(section);
2795
+ mountSqlExplorer(body, panelApi);
2796
+ }
2589
2797
  return refresh();
2590
2798
  }).catch(showError);
2591
2799
  }
2592
- var clientPrelude = [isRecord2, mountAdminBrand, startAdminBrand, faultPresetList, bootAdmin].map((fn) => fn.toString()).join("\n");
2800
+ var clientPrelude = [
2801
+ isRecord2,
2802
+ mountAdminBrand,
2803
+ startAdminBrand,
2804
+ faultPresetList,
2805
+ mountSqlExplorer,
2806
+ bootAdmin
2807
+ ].map((fn) => fn.toString()).join("\n");
2593
2808
  var adminClientSource = (config) => {
2594
2809
  const payload = JSON.stringify(config).replace(/</g, "\\u003c");
2595
2810
  const entry = bootAdmin.name;
@@ -2639,19 +2854,33 @@ var STANDARD_ADMIN_ROUTES = [
2639
2854
  "GET /ui/manifest"
2640
2855
  ];
2641
2856
  var PANEL_ID = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
2857
+ var RESERVED_VIEWS = /* @__PURE__ */ new Set(["overview", "state", "clock", "faults", "journal", "routes"]);
2858
+ var checkPanel = (panel, seen, label) => {
2859
+ if (!PANEL_ID.test(panel.id)) {
2860
+ throw new RangeError(`${label} id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
2861
+ }
2862
+ if (RESERVED_VIEWS.has(panel.id)) {
2863
+ throw new RangeError(`${label} id ${panel.id} is reserved by the admin shell`);
2864
+ }
2865
+ if (seen.has(panel.id))
2866
+ throw new RangeError(`duplicate admin view id ${panel.id}`);
2867
+ seen.add(panel.id);
2868
+ if (panel.title.trim() === "")
2869
+ throw new RangeError(`${label} ${panel.id} needs a title`);
2870
+ };
2642
2871
  var assertAdminUi = (ui) => {
2643
- if (!ui?.panels)
2872
+ if (!ui)
2644
2873
  return;
2645
2874
  const seen = /* @__PURE__ */ new Set();
2646
- for (const panel of ui.panels) {
2647
- if (!PANEL_ID.test(panel.id)) {
2648
- throw new RangeError(`admin panel id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
2875
+ for (const panel of ui.panels ?? [])
2876
+ checkPanel(panel, seen, "admin panel");
2877
+ for (const extension of ui.extensions ?? []) {
2878
+ if (extension.kind === "panel") {
2879
+ checkPanel(extension, seen, "admin extension");
2880
+ continue;
2649
2881
  }
2650
- if (seen.has(panel.id))
2651
- throw new RangeError(`duplicate admin panel id ${panel.id}`);
2652
- seen.add(panel.id);
2653
- if (panel.title.trim() === "")
2654
- throw new RangeError(`admin panel ${panel.id} needs a title`);
2882
+ const id = extension.id ?? "sql";
2883
+ checkPanel({ id, title: extension.title ?? "SQL" }, seen, "admin extension");
2655
2884
  }
2656
2885
  };
2657
2886
 
@@ -2885,6 +3114,12 @@ var renderAdminDocument = (service) => {
2885
3114
  border-radius: 999px; padding: 4px 8px;
2886
3115
  }
2887
3116
  .chip i { color: var(--faint); font-style: normal; }
3117
+ .sql-layout {
3118
+ display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 16px;
3119
+ }
3120
+ .sql-tables { display: flex; flex-direction: column; gap: 4px; max-height: 28rem; overflow: auto; }
3121
+ .sql-tables button { text-align: left; }
3122
+ .sql-input { font-family: var(--mono); min-height: 7rem; width: 100%; }
2888
3123
  table { width: 100%; border-collapse: collapse; font-size: 14px; }
2889
3124
  th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
2890
3125
  th { color: var(--faint); font-weight: 600; font-size: 12px; }
@@ -2948,7 +3183,7 @@ var renderAdminDocument = (service) => {
2948
3183
  padding: 8px;
2949
3184
  }
2950
3185
  nav.side button { white-space: nowrap; flex: none; }
2951
- .split { grid-template-columns: minmax(0, 1fr); }
3186
+ .split, .sql-layout { grid-template-columns: minmax(0, 1fr); }
2952
3187
  main { padding: 14px; }
2953
3188
  table, thead, tbody, tr, th, td { display: block; }
2954
3189
  thead { display: none; }
@@ -3119,6 +3354,24 @@ var json2 = (body) => new Response(JSON.stringify(body), {
3119
3354
  status: 200,
3120
3355
  headers: { "content-type": "application/json; charset=utf-8" }
3121
3356
  });
3357
+ var describeExtension = (extension) => {
3358
+ if (extension.kind === "sql") {
3359
+ return {
3360
+ kind: "sql",
3361
+ id: extension.id ?? "sql",
3362
+ title: extension.title ?? "SQL",
3363
+ ...extension.description !== void 0 ? { description: extension.description } : {}
3364
+ };
3365
+ }
3366
+ return {
3367
+ kind: "panel",
3368
+ id: extension.id,
3369
+ title: extension.title,
3370
+ ...extension.description !== void 0 ? { description: extension.description } : {},
3371
+ html: extension.html,
3372
+ ...extension.script !== void 0 ? { script: extension.script } : {}
3373
+ };
3374
+ };
3122
3375
  var adminUiRoutes = (service, ui) => {
3123
3376
  const shell = () => renderAdminDocument(service);
3124
3377
  const document3 = () => ui?.render ? ui.render({ service, defaultHtml: shell }) : shell();
@@ -3133,7 +3386,8 @@ var adminUiRoutes = (service, ui) => {
3133
3386
  ...panel.description !== void 0 ? { description: panel.description } : {},
3134
3387
  html: panel.html,
3135
3388
  ...panel.script !== void 0 ? { script: panel.script } : {}
3136
- }))
3389
+ })),
3390
+ extensions: (ui?.extensions ?? []).map(describeExtension)
3137
3391
  })
3138
3392
  };
3139
3393
  };
@@ -3810,7 +4064,7 @@ var stateAdminRoutes = (routes) => {
3810
4064
  };
3811
4065
 
3812
4066
  // ../core/dist/version.js
3813
- var PACKAGE_VERSION = true ? "1.6.1" : UNRELEASED_VERSION;
4067
+ var PACKAGE_VERSION = true ? "1.7.0" : UNRELEASED_VERSION;
3814
4068
 
3815
4069
  // ../core/dist/signing.js
3816
4070
  var encoder = new TextEncoder();
@@ -5827,4 +6081,4 @@ export {
5827
6081
  appIdCredential,
5828
6082
  EdamamAPI
5829
6083
  };
5830
- //# sourceMappingURL=chunk-JJTHVJWR.js.map
6084
+ //# sourceMappingURL=chunk-T5KB3LZL.js.map