@crvouga/mockingbird-service-google-maps 1.7.1 → 1.8.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-google-maps
2
2
 
3
+ ## 1.8.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.7.1 (2026-09-30)
4
14
 
5
15
  ### Fixes and improvements
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createRuntime
3
- } from "./chunk-AIMXHIOX.js";
3
+ } from "./chunk-R6B7E6A7.js";
4
4
 
5
5
  // ../../adapters/node/dist/cli.js
6
6
  import { readFile } from "node:fs/promises";
@@ -360,4 +360,4 @@ export {
360
360
  createServer2 as createServer,
361
361
  serveTarget
362
362
  };
363
- //# sourceMappingURL=chunk-VCAIWSHH.js.map
363
+ //# sourceMappingURL=chunk-OXERG4FV.js.map
@@ -1648,6 +1648,167 @@ function faultPresetList(value) {
1648
1648
  })
1649
1649
  };
1650
1650
  }
1651
+ function mountSqlExplorer(root, api) {
1652
+ const cell = (value) => {
1653
+ if (value === null || value === void 0)
1654
+ return "";
1655
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1656
+ return String(value);
1657
+ }
1658
+ return JSON.stringify(value) ?? "";
1659
+ };
1660
+ root.replaceChildren();
1661
+ const layout = document.createElement("div");
1662
+ layout.className = "sql-layout";
1663
+ const tables = document.createElement("div");
1664
+ tables.className = "sql-tables";
1665
+ const stack = document.createElement("div");
1666
+ stack.className = "stack";
1667
+ const banner = document.createElement("p");
1668
+ banner.className = "banner";
1669
+ const grid = document.createElement("div");
1670
+ const input = document.createElement("textarea");
1671
+ input.className = "sql-input";
1672
+ input.spellcheck = false;
1673
+ input.placeholder = "SELECT * FROM ...";
1674
+ const actions = document.createElement("div");
1675
+ actions.className = "row-actions";
1676
+ const run = document.createElement("button");
1677
+ run.type = "button";
1678
+ run.textContent = "Run";
1679
+ actions.append(run);
1680
+ const result = document.createElement("pre");
1681
+ stack.append(banner, grid, input, actions, result);
1682
+ layout.append(tables, stack);
1683
+ root.append(layout);
1684
+ const showError = (error) => {
1685
+ banner.textContent = error instanceof Error ? error.message : String(error);
1686
+ banner.classList.add("show");
1687
+ };
1688
+ const clearError = () => {
1689
+ banner.textContent = "";
1690
+ banner.classList.remove("show");
1691
+ };
1692
+ const renderGrid = (columns, rows) => {
1693
+ grid.replaceChildren();
1694
+ if (columns.length === 0) {
1695
+ const empty = document.createElement("p");
1696
+ empty.className = "empty";
1697
+ empty.textContent = "No rows.";
1698
+ grid.append(empty);
1699
+ return;
1700
+ }
1701
+ const table = document.createElement("table");
1702
+ const head = document.createElement("thead");
1703
+ const headRow = document.createElement("tr");
1704
+ for (const column of columns) {
1705
+ const th = document.createElement("th");
1706
+ th.textContent = column;
1707
+ headRow.append(th);
1708
+ }
1709
+ head.append(headRow);
1710
+ const body = document.createElement("tbody");
1711
+ for (const row2 of rows) {
1712
+ const tr = document.createElement("tr");
1713
+ for (const column of columns) {
1714
+ const td = document.createElement("td");
1715
+ td.dataset.label = column;
1716
+ td.textContent = cell(row2[column]);
1717
+ tr.append(td);
1718
+ }
1719
+ body.append(tr);
1720
+ }
1721
+ table.append(head, body);
1722
+ grid.append(table);
1723
+ };
1724
+ const rowsOf = (value) => {
1725
+ if (!isRecord2(value) || !Array.isArray(value.rows))
1726
+ return [];
1727
+ return value.rows.flatMap((row2) => isRecord2(row2) ? [row2] : []);
1728
+ };
1729
+ const columnsOf = (value, rows) => {
1730
+ if (isRecord2(value) && Array.isArray(value.columns)) {
1731
+ const named = value.columns.flatMap((column) => typeof column === "string" ? [column] : []);
1732
+ if (named.length > 0)
1733
+ return named;
1734
+ }
1735
+ const first = rows[0];
1736
+ return first === void 0 ? [] : Object.keys(first);
1737
+ };
1738
+ let selected = "";
1739
+ const loadPage = async (schema, name) => {
1740
+ selected = `${schema}.${name}`;
1741
+ const page = await api.get(`/sql/tables/${encodeURIComponent(schema)}/${encodeURIComponent(name)}?limit=50`);
1742
+ const rows = rowsOf(page);
1743
+ renderGrid(columnsOf(page, rows), rows);
1744
+ const total = isRecord2(page) && typeof page.total === "number" ? page.total : rows.length;
1745
+ result.textContent = `${selected} \xB7 ${total} rows`;
1746
+ for (const button of tables.querySelectorAll("button")) {
1747
+ if (!(button instanceof HTMLButtonElement))
1748
+ continue;
1749
+ button.setAttribute("aria-current", button.dataset.schema === schema && button.dataset.table === name ? "true" : "false");
1750
+ }
1751
+ };
1752
+ const loadTables = async () => {
1753
+ const payload = await api.get("/sql/tables");
1754
+ const listed = isRecord2(payload) && Array.isArray(payload.tables) ? payload.tables : [];
1755
+ tables.replaceChildren();
1756
+ if (listed.length === 0) {
1757
+ const empty = document.createElement("p");
1758
+ empty.className = "empty";
1759
+ empty.textContent = "No tables.";
1760
+ tables.append(empty);
1761
+ return;
1762
+ }
1763
+ for (const item of listed) {
1764
+ if (!isRecord2(item) || typeof item.schema !== "string" || typeof item.name !== "string")
1765
+ continue;
1766
+ const button = document.createElement("button");
1767
+ button.type = "button";
1768
+ button.dataset.schema = item.schema;
1769
+ button.dataset.table = item.name;
1770
+ button.textContent = `${item.schema}.${item.name}`;
1771
+ tables.append(button);
1772
+ }
1773
+ };
1774
+ tables.addEventListener("click", (event) => {
1775
+ const target = event.target;
1776
+ if (!(target instanceof Element))
1777
+ return;
1778
+ const button = target.closest("button");
1779
+ if (!(button instanceof HTMLButtonElement))
1780
+ return;
1781
+ const schema = button.dataset.schema;
1782
+ const name = button.dataset.table;
1783
+ if (schema === void 0 || name === void 0)
1784
+ return;
1785
+ clearError();
1786
+ loadPage(schema, name).catch(showError);
1787
+ });
1788
+ run.addEventListener("click", () => {
1789
+ const sql = input.value.trim();
1790
+ if (sql === "") {
1791
+ showError(new Error("Enter a statement"));
1792
+ return;
1793
+ }
1794
+ clearError();
1795
+ api.send("POST", "/sql/query", { sql }).then((payload) => {
1796
+ const rows = rowsOf(payload);
1797
+ renderGrid(columnsOf(payload, rows), rows);
1798
+ const count = isRecord2(payload) && typeof payload.rowCount === "number" ? payload.rowCount : rows.length;
1799
+ const truncated = isRecord2(payload) && payload.truncated === true ? " (truncated)" : "";
1800
+ result.textContent = `${count} rows${truncated}`;
1801
+ }).catch(showError);
1802
+ });
1803
+ const namespace = document.getElementById("namespace");
1804
+ if (namespace) {
1805
+ namespace.addEventListener("change", () => {
1806
+ clearError();
1807
+ loadTables().catch(showError);
1808
+ });
1809
+ }
1810
+ loadTables().catch(showError);
1811
+ }
1651
1812
  function bootAdmin(config) {
1652
1813
  const fieldKinds = ["string", "number", "boolean", "null", "object", "array", "unknown"];
1653
1814
  const sources = ["declared", "inferred", "mixed"];
@@ -2324,6 +2485,22 @@ function bootAdmin(config) {
2324
2485
  panel.script = value.script;
2325
2486
  return panel;
2326
2487
  };
2488
+ const decodeExtension = (value) => {
2489
+ if (!isRecord2(value))
2490
+ return void 0;
2491
+ if (value.kind === "sql") {
2492
+ return {
2493
+ kind: "sql",
2494
+ id: typeof value.id === "string" && value.id !== "" ? value.id : "sql",
2495
+ title: typeof value.title === "string" && value.title !== "" ? value.title : "SQL",
2496
+ description: typeof value.description === "string" ? value.description : "Browse tables and run queries."
2497
+ };
2498
+ }
2499
+ if (value.kind !== "panel")
2500
+ return void 0;
2501
+ const panel = decodePanel(value);
2502
+ return panel === void 0 ? void 0 : { kind: "panel", ...panel };
2503
+ };
2327
2504
  const mountPanels = (panels) => {
2328
2505
  const nav = el("nav", HTMLElement);
2329
2506
  const views = el("views", HTMLElement);
@@ -2377,10 +2554,48 @@ function bootAdmin(config) {
2377
2554
  return decoded === void 0 ? [] : [decoded];
2378
2555
  });
2379
2556
  mountPanels(panels);
2557
+ const extensions = requireList(isRecord2(manifest) ? manifest.extensions : void 0, "Extensions").flatMap((extension) => {
2558
+ const decoded = decodeExtension(extension);
2559
+ return decoded === void 0 ? [] : [decoded];
2560
+ });
2561
+ const extensionPanels = extensions.flatMap((extension) => extension.kind === "panel" ? [extension] : []);
2562
+ mountPanels(extensionPanels);
2563
+ for (const extension of extensions) {
2564
+ if (extension.kind !== "sql")
2565
+ continue;
2566
+ const nav = el("nav", HTMLElement);
2567
+ const views = el("views", HTMLElement);
2568
+ const button = document.createElement("button");
2569
+ button.type = "button";
2570
+ button.dataset.view = extension.id;
2571
+ button.textContent = extension.title;
2572
+ nav.append(button);
2573
+ const section = document.createElement("section");
2574
+ section.className = "view";
2575
+ section.id = `view-${extension.id}`;
2576
+ section.hidden = true;
2577
+ const title = document.createElement("h2");
2578
+ title.textContent = extension.title;
2579
+ const lede = document.createElement("p");
2580
+ lede.className = "lede";
2581
+ lede.textContent = extension.description;
2582
+ const body = document.createElement("div");
2583
+ body.className = "panel-body";
2584
+ section.append(title, lede, body);
2585
+ views.append(section);
2586
+ mountSqlExplorer(body, panelApi);
2587
+ }
2380
2588
  return refresh();
2381
2589
  }).catch(showError);
2382
2590
  }
2383
- var clientPrelude = [isRecord2, mountAdminBrand, startAdminBrand, faultPresetList, bootAdmin].map((fn) => fn.toString()).join("\n");
2591
+ var clientPrelude = [
2592
+ isRecord2,
2593
+ mountAdminBrand,
2594
+ startAdminBrand,
2595
+ faultPresetList,
2596
+ mountSqlExplorer,
2597
+ bootAdmin
2598
+ ].map((fn) => fn.toString()).join("\n");
2384
2599
  var adminClientSource = (config) => {
2385
2600
  const payload = JSON.stringify(config).replace(/</g, "\\u003c");
2386
2601
  const entry = bootAdmin.name;
@@ -2430,19 +2645,33 @@ var STANDARD_ADMIN_ROUTES = [
2430
2645
  "GET /ui/manifest"
2431
2646
  ];
2432
2647
  var PANEL_ID = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
2648
+ var RESERVED_VIEWS = /* @__PURE__ */ new Set(["overview", "state", "clock", "faults", "journal", "routes"]);
2649
+ var checkPanel = (panel, seen, label) => {
2650
+ if (!PANEL_ID.test(panel.id)) {
2651
+ throw new RangeError(`${label} id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
2652
+ }
2653
+ if (RESERVED_VIEWS.has(panel.id)) {
2654
+ throw new RangeError(`${label} id ${panel.id} is reserved by the admin shell`);
2655
+ }
2656
+ if (seen.has(panel.id))
2657
+ throw new RangeError(`duplicate admin view id ${panel.id}`);
2658
+ seen.add(panel.id);
2659
+ if (panel.title.trim() === "")
2660
+ throw new RangeError(`${label} ${panel.id} needs a title`);
2661
+ };
2433
2662
  var assertAdminUi = (ui) => {
2434
- if (!ui?.panels)
2663
+ if (!ui)
2435
2664
  return;
2436
2665
  const seen = /* @__PURE__ */ new Set();
2437
- for (const panel of ui.panels) {
2438
- if (!PANEL_ID.test(panel.id)) {
2439
- throw new RangeError(`admin panel id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
2666
+ for (const panel of ui.panels ?? [])
2667
+ checkPanel(panel, seen, "admin panel");
2668
+ for (const extension of ui.extensions ?? []) {
2669
+ if (extension.kind === "panel") {
2670
+ checkPanel(extension, seen, "admin extension");
2671
+ continue;
2440
2672
  }
2441
- if (seen.has(panel.id))
2442
- throw new RangeError(`duplicate admin panel id ${panel.id}`);
2443
- seen.add(panel.id);
2444
- if (panel.title.trim() === "")
2445
- throw new RangeError(`admin panel ${panel.id} needs a title`);
2673
+ const id = extension.id ?? "sql";
2674
+ checkPanel({ id, title: extension.title ?? "SQL" }, seen, "admin extension");
2446
2675
  }
2447
2676
  };
2448
2677
 
@@ -2676,6 +2905,12 @@ var renderAdminDocument = (service) => {
2676
2905
  border-radius: 999px; padding: 4px 8px;
2677
2906
  }
2678
2907
  .chip i { color: var(--faint); font-style: normal; }
2908
+ .sql-layout {
2909
+ display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 16px;
2910
+ }
2911
+ .sql-tables { display: flex; flex-direction: column; gap: 4px; max-height: 28rem; overflow: auto; }
2912
+ .sql-tables button { text-align: left; }
2913
+ .sql-input { font-family: var(--mono); min-height: 7rem; width: 100%; }
2679
2914
  table { width: 100%; border-collapse: collapse; font-size: 14px; }
2680
2915
  th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
2681
2916
  th { color: var(--faint); font-weight: 600; font-size: 12px; }
@@ -2739,7 +2974,7 @@ var renderAdminDocument = (service) => {
2739
2974
  padding: 8px;
2740
2975
  }
2741
2976
  nav.side button { white-space: nowrap; flex: none; }
2742
- .split { grid-template-columns: minmax(0, 1fr); }
2977
+ .split, .sql-layout { grid-template-columns: minmax(0, 1fr); }
2743
2978
  main { padding: 14px; }
2744
2979
  table, thead, tbody, tr, th, td { display: block; }
2745
2980
  thead { display: none; }
@@ -2910,6 +3145,24 @@ var json2 = (body) => new Response(JSON.stringify(body), {
2910
3145
  status: 200,
2911
3146
  headers: { "content-type": "application/json; charset=utf-8" }
2912
3147
  });
3148
+ var describeExtension = (extension) => {
3149
+ if (extension.kind === "sql") {
3150
+ return {
3151
+ kind: "sql",
3152
+ id: extension.id ?? "sql",
3153
+ title: extension.title ?? "SQL",
3154
+ ...extension.description !== void 0 ? { description: extension.description } : {}
3155
+ };
3156
+ }
3157
+ return {
3158
+ kind: "panel",
3159
+ id: extension.id,
3160
+ title: extension.title,
3161
+ ...extension.description !== void 0 ? { description: extension.description } : {},
3162
+ html: extension.html,
3163
+ ...extension.script !== void 0 ? { script: extension.script } : {}
3164
+ };
3165
+ };
2913
3166
  var adminUiRoutes = (service, ui) => {
2914
3167
  const shell = () => renderAdminDocument(service);
2915
3168
  const document3 = () => ui?.render ? ui.render({ service, defaultHtml: shell }) : shell();
@@ -2924,7 +3177,8 @@ var adminUiRoutes = (service, ui) => {
2924
3177
  ...panel.description !== void 0 ? { description: panel.description } : {},
2925
3178
  html: panel.html,
2926
3179
  ...panel.script !== void 0 ? { script: panel.script } : {}
2927
- }))
3180
+ })),
3181
+ extensions: (ui?.extensions ?? []).map(describeExtension)
2928
3182
  })
2929
3183
  };
2930
3184
  };
@@ -3527,7 +3781,7 @@ var stateAdminRoutes = (routes) => {
3527
3781
  };
3528
3782
 
3529
3783
  // ../core/dist/version.js
3530
- var PACKAGE_VERSION = true ? "1.7.1" : UNRELEASED_VERSION;
3784
+ var PACKAGE_VERSION = true ? "1.8.0" : UNRELEASED_VERSION;
3531
3785
 
3532
3786
  // ../core/dist/signing.js
3533
3787
  var encoder = new TextEncoder();
@@ -6385,4 +6639,4 @@ export {
6385
6639
  keyCredential,
6386
6640
  GoogleMapsAPI
6387
6641
  };
6388
- //# sourceMappingURL=chunk-AIMXHIOX.js.map
6642
+ //# sourceMappingURL=chunk-R6B7E6A7.js.map