@crvouga/mockingbird-service-rxvortex 1.7.1 → 1.8.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-rxvortex
2
2
 
3
+ ## 1.8.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.8.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.7.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());
@@ -1865,6 +1865,167 @@ function faultPresetList(value) {
1865
1865
  })
1866
1866
  };
1867
1867
  }
1868
+ function mountSqlExplorer(root, api) {
1869
+ const cell = (value) => {
1870
+ if (value === null || value === void 0)
1871
+ return "";
1872
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1873
+ return String(value);
1874
+ }
1875
+ return JSON.stringify(value) ?? "";
1876
+ };
1877
+ root.replaceChildren();
1878
+ const layout = document.createElement("div");
1879
+ layout.className = "sql-layout";
1880
+ const tables = document.createElement("div");
1881
+ tables.className = "sql-tables";
1882
+ const stack = document.createElement("div");
1883
+ stack.className = "stack";
1884
+ const banner = document.createElement("p");
1885
+ banner.className = "banner";
1886
+ const grid = document.createElement("div");
1887
+ const input = document.createElement("textarea");
1888
+ input.className = "sql-input";
1889
+ input.spellcheck = false;
1890
+ input.placeholder = "SELECT * FROM ...";
1891
+ const actions = document.createElement("div");
1892
+ actions.className = "row-actions";
1893
+ const run = document.createElement("button");
1894
+ run.type = "button";
1895
+ run.textContent = "Run";
1896
+ actions.append(run);
1897
+ const result = document.createElement("pre");
1898
+ stack.append(banner, grid, input, actions, result);
1899
+ layout.append(tables, stack);
1900
+ root.append(layout);
1901
+ const showError = (error) => {
1902
+ banner.textContent = error instanceof Error ? error.message : String(error);
1903
+ banner.classList.add("show");
1904
+ };
1905
+ const clearError = () => {
1906
+ banner.textContent = "";
1907
+ banner.classList.remove("show");
1908
+ };
1909
+ const renderGrid = (columns, rows) => {
1910
+ grid.replaceChildren();
1911
+ if (columns.length === 0) {
1912
+ const empty = document.createElement("p");
1913
+ empty.className = "empty";
1914
+ empty.textContent = "No rows.";
1915
+ grid.append(empty);
1916
+ return;
1917
+ }
1918
+ const table = document.createElement("table");
1919
+ const head = document.createElement("thead");
1920
+ const headRow = document.createElement("tr");
1921
+ for (const column of columns) {
1922
+ const th = document.createElement("th");
1923
+ th.textContent = column;
1924
+ headRow.append(th);
1925
+ }
1926
+ head.append(headRow);
1927
+ const body = document.createElement("tbody");
1928
+ for (const row of rows) {
1929
+ const tr = document.createElement("tr");
1930
+ for (const column of columns) {
1931
+ const td = document.createElement("td");
1932
+ td.dataset.label = column;
1933
+ td.textContent = cell(row[column]);
1934
+ tr.append(td);
1935
+ }
1936
+ body.append(tr);
1937
+ }
1938
+ table.append(head, body);
1939
+ grid.append(table);
1940
+ };
1941
+ const rowsOf = (value) => {
1942
+ if (!isRecord2(value) || !Array.isArray(value.rows))
1943
+ return [];
1944
+ return value.rows.flatMap((row) => isRecord2(row) ? [row] : []);
1945
+ };
1946
+ const columnsOf = (value, rows) => {
1947
+ if (isRecord2(value) && Array.isArray(value.columns)) {
1948
+ const named = value.columns.flatMap((column) => typeof column === "string" ? [column] : []);
1949
+ if (named.length > 0)
1950
+ return named;
1951
+ }
1952
+ const first = rows[0];
1953
+ return first === void 0 ? [] : Object.keys(first);
1954
+ };
1955
+ let selected = "";
1956
+ const loadPage = async (schema, name) => {
1957
+ selected = `${schema}.${name}`;
1958
+ const page = await api.get(`/sql/tables/${encodeURIComponent(schema)}/${encodeURIComponent(name)}?limit=50`);
1959
+ const rows = rowsOf(page);
1960
+ renderGrid(columnsOf(page, rows), rows);
1961
+ const total = isRecord2(page) && typeof page.total === "number" ? page.total : rows.length;
1962
+ result.textContent = `${selected} \xB7 ${total} rows`;
1963
+ for (const button of tables.querySelectorAll("button")) {
1964
+ if (!(button instanceof HTMLButtonElement))
1965
+ continue;
1966
+ button.setAttribute("aria-current", button.dataset.schema === schema && button.dataset.table === name ? "true" : "false");
1967
+ }
1968
+ };
1969
+ const loadTables = async () => {
1970
+ const payload = await api.get("/sql/tables");
1971
+ const listed = isRecord2(payload) && Array.isArray(payload.tables) ? payload.tables : [];
1972
+ tables.replaceChildren();
1973
+ if (listed.length === 0) {
1974
+ const empty = document.createElement("p");
1975
+ empty.className = "empty";
1976
+ empty.textContent = "No tables.";
1977
+ tables.append(empty);
1978
+ return;
1979
+ }
1980
+ for (const item of listed) {
1981
+ if (!isRecord2(item) || typeof item.schema !== "string" || typeof item.name !== "string")
1982
+ continue;
1983
+ const button = document.createElement("button");
1984
+ button.type = "button";
1985
+ button.dataset.schema = item.schema;
1986
+ button.dataset.table = item.name;
1987
+ button.textContent = `${item.schema}.${item.name}`;
1988
+ tables.append(button);
1989
+ }
1990
+ };
1991
+ tables.addEventListener("click", (event) => {
1992
+ const target = event.target;
1993
+ if (!(target instanceof Element))
1994
+ return;
1995
+ const button = target.closest("button");
1996
+ if (!(button instanceof HTMLButtonElement))
1997
+ return;
1998
+ const schema = button.dataset.schema;
1999
+ const name = button.dataset.table;
2000
+ if (schema === void 0 || name === void 0)
2001
+ return;
2002
+ clearError();
2003
+ loadPage(schema, name).catch(showError);
2004
+ });
2005
+ run.addEventListener("click", () => {
2006
+ const sql = input.value.trim();
2007
+ if (sql === "") {
2008
+ showError(new Error("Enter a statement"));
2009
+ return;
2010
+ }
2011
+ clearError();
2012
+ api.send("POST", "/sql/query", { sql }).then((payload) => {
2013
+ const rows = rowsOf(payload);
2014
+ renderGrid(columnsOf(payload, rows), rows);
2015
+ const count = isRecord2(payload) && typeof payload.rowCount === "number" ? payload.rowCount : rows.length;
2016
+ const truncated = isRecord2(payload) && payload.truncated === true ? " (truncated)" : "";
2017
+ result.textContent = `${count} rows${truncated}`;
2018
+ }).catch(showError);
2019
+ });
2020
+ const namespace = document.getElementById("namespace");
2021
+ if (namespace) {
2022
+ namespace.addEventListener("change", () => {
2023
+ clearError();
2024
+ loadTables().catch(showError);
2025
+ });
2026
+ }
2027
+ loadTables().catch(showError);
2028
+ }
1868
2029
  function bootAdmin(config) {
1869
2030
  const fieldKinds = ["string", "number", "boolean", "null", "object", "array", "unknown"];
1870
2031
  const sources = ["declared", "inferred", "mixed"];
@@ -2541,6 +2702,22 @@ function bootAdmin(config) {
2541
2702
  panel.script = value.script;
2542
2703
  return panel;
2543
2704
  };
2705
+ const decodeExtension = (value) => {
2706
+ if (!isRecord2(value))
2707
+ return void 0;
2708
+ if (value.kind === "sql") {
2709
+ return {
2710
+ kind: "sql",
2711
+ id: typeof value.id === "string" && value.id !== "" ? value.id : "sql",
2712
+ title: typeof value.title === "string" && value.title !== "" ? value.title : "SQL",
2713
+ description: typeof value.description === "string" ? value.description : "Browse tables and run queries."
2714
+ };
2715
+ }
2716
+ if (value.kind !== "panel")
2717
+ return void 0;
2718
+ const panel = decodePanel(value);
2719
+ return panel === void 0 ? void 0 : { kind: "panel", ...panel };
2720
+ };
2544
2721
  const mountPanels = (panels) => {
2545
2722
  const nav = el("nav", HTMLElement);
2546
2723
  const views = el("views", HTMLElement);
@@ -2594,10 +2771,48 @@ function bootAdmin(config) {
2594
2771
  return decoded === void 0 ? [] : [decoded];
2595
2772
  });
2596
2773
  mountPanels(panels);
2774
+ const extensions = requireList(isRecord2(manifest) ? manifest.extensions : void 0, "Extensions").flatMap((extension) => {
2775
+ const decoded = decodeExtension(extension);
2776
+ return decoded === void 0 ? [] : [decoded];
2777
+ });
2778
+ const extensionPanels = extensions.flatMap((extension) => extension.kind === "panel" ? [extension] : []);
2779
+ mountPanels(extensionPanels);
2780
+ for (const extension of extensions) {
2781
+ if (extension.kind !== "sql")
2782
+ continue;
2783
+ const nav = el("nav", HTMLElement);
2784
+ const views = el("views", HTMLElement);
2785
+ const button = document.createElement("button");
2786
+ button.type = "button";
2787
+ button.dataset.view = extension.id;
2788
+ button.textContent = extension.title;
2789
+ nav.append(button);
2790
+ const section = document.createElement("section");
2791
+ section.className = "view";
2792
+ section.id = `view-${extension.id}`;
2793
+ section.hidden = true;
2794
+ const title = document.createElement("h2");
2795
+ title.textContent = extension.title;
2796
+ const lede = document.createElement("p");
2797
+ lede.className = "lede";
2798
+ lede.textContent = extension.description;
2799
+ const body = document.createElement("div");
2800
+ body.className = "panel-body";
2801
+ section.append(title, lede, body);
2802
+ views.append(section);
2803
+ mountSqlExplorer(body, panelApi);
2804
+ }
2597
2805
  return refresh();
2598
2806
  }).catch(showError);
2599
2807
  }
2600
- var clientPrelude = [isRecord2, mountAdminBrand, startAdminBrand, faultPresetList, bootAdmin].map((fn) => fn.toString()).join("\n");
2808
+ var clientPrelude = [
2809
+ isRecord2,
2810
+ mountAdminBrand,
2811
+ startAdminBrand,
2812
+ faultPresetList,
2813
+ mountSqlExplorer,
2814
+ bootAdmin
2815
+ ].map((fn) => fn.toString()).join("\n");
2601
2816
  var adminClientSource = (config) => {
2602
2817
  const payload = JSON.stringify(config).replace(/</g, "\\u003c");
2603
2818
  const entry = bootAdmin.name;
@@ -2647,19 +2862,33 @@ var STANDARD_ADMIN_ROUTES = [
2647
2862
  "GET /ui/manifest"
2648
2863
  ];
2649
2864
  var PANEL_ID = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
2865
+ var RESERVED_VIEWS = /* @__PURE__ */ new Set(["overview", "state", "clock", "faults", "journal", "routes"]);
2866
+ var checkPanel = (panel, seen, label) => {
2867
+ if (!PANEL_ID.test(panel.id)) {
2868
+ throw new RangeError(`${label} id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
2869
+ }
2870
+ if (RESERVED_VIEWS.has(panel.id)) {
2871
+ throw new RangeError(`${label} id ${panel.id} is reserved by the admin shell`);
2872
+ }
2873
+ if (seen.has(panel.id))
2874
+ throw new RangeError(`duplicate admin view id ${panel.id}`);
2875
+ seen.add(panel.id);
2876
+ if (panel.title.trim() === "")
2877
+ throw new RangeError(`${label} ${panel.id} needs a title`);
2878
+ };
2650
2879
  var assertAdminUi = (ui) => {
2651
- if (!ui?.panels)
2880
+ if (!ui)
2652
2881
  return;
2653
2882
  const seen = /* @__PURE__ */ new Set();
2654
- for (const panel of ui.panels) {
2655
- if (!PANEL_ID.test(panel.id)) {
2656
- throw new RangeError(`admin panel id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
2883
+ for (const panel of ui.panels ?? [])
2884
+ checkPanel(panel, seen, "admin panel");
2885
+ for (const extension of ui.extensions ?? []) {
2886
+ if (extension.kind === "panel") {
2887
+ checkPanel(extension, seen, "admin extension");
2888
+ continue;
2657
2889
  }
2658
- if (seen.has(panel.id))
2659
- throw new RangeError(`duplicate admin panel id ${panel.id}`);
2660
- seen.add(panel.id);
2661
- if (panel.title.trim() === "")
2662
- throw new RangeError(`admin panel ${panel.id} needs a title`);
2890
+ const id = extension.id ?? "sql";
2891
+ checkPanel({ id, title: extension.title ?? "SQL" }, seen, "admin extension");
2663
2892
  }
2664
2893
  };
2665
2894
 
@@ -2893,6 +3122,12 @@ var renderAdminDocument = (service) => {
2893
3122
  border-radius: 999px; padding: 4px 8px;
2894
3123
  }
2895
3124
  .chip i { color: var(--faint); font-style: normal; }
3125
+ .sql-layout {
3126
+ display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 16px;
3127
+ }
3128
+ .sql-tables { display: flex; flex-direction: column; gap: 4px; max-height: 28rem; overflow: auto; }
3129
+ .sql-tables button { text-align: left; }
3130
+ .sql-input { font-family: var(--mono); min-height: 7rem; width: 100%; }
2896
3131
  table { width: 100%; border-collapse: collapse; font-size: 14px; }
2897
3132
  th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
2898
3133
  th { color: var(--faint); font-weight: 600; font-size: 12px; }
@@ -2956,7 +3191,7 @@ var renderAdminDocument = (service) => {
2956
3191
  padding: 8px;
2957
3192
  }
2958
3193
  nav.side button { white-space: nowrap; flex: none; }
2959
- .split { grid-template-columns: minmax(0, 1fr); }
3194
+ .split, .sql-layout { grid-template-columns: minmax(0, 1fr); }
2960
3195
  main { padding: 14px; }
2961
3196
  table, thead, tbody, tr, th, td { display: block; }
2962
3197
  thead { display: none; }
@@ -3127,6 +3362,24 @@ var json2 = (body) => new Response(JSON.stringify(body), {
3127
3362
  status: 200,
3128
3363
  headers: { "content-type": "application/json; charset=utf-8" }
3129
3364
  });
3365
+ var describeExtension = (extension) => {
3366
+ if (extension.kind === "sql") {
3367
+ return {
3368
+ kind: "sql",
3369
+ id: extension.id ?? "sql",
3370
+ title: extension.title ?? "SQL",
3371
+ ...extension.description !== void 0 ? { description: extension.description } : {}
3372
+ };
3373
+ }
3374
+ return {
3375
+ kind: "panel",
3376
+ id: extension.id,
3377
+ title: extension.title,
3378
+ ...extension.description !== void 0 ? { description: extension.description } : {},
3379
+ html: extension.html,
3380
+ ...extension.script !== void 0 ? { script: extension.script } : {}
3381
+ };
3382
+ };
3130
3383
  var adminUiRoutes = (service, ui) => {
3131
3384
  const shell = () => renderAdminDocument(service);
3132
3385
  const document3 = () => ui?.render ? ui.render({ service, defaultHtml: shell }) : shell();
@@ -3141,7 +3394,8 @@ var adminUiRoutes = (service, ui) => {
3141
3394
  ...panel.description !== void 0 ? { description: panel.description } : {},
3142
3395
  html: panel.html,
3143
3396
  ...panel.script !== void 0 ? { script: panel.script } : {}
3144
- }))
3397
+ })),
3398
+ extensions: (ui?.extensions ?? []).map(describeExtension)
3145
3399
  })
3146
3400
  };
3147
3401
  };
@@ -3828,7 +4082,7 @@ var stateAdminRoutes = (routes) => {
3828
4082
  };
3829
4083
 
3830
4084
  // ../core/dist/version.js
3831
- var PACKAGE_VERSION = true ? "1.7.1" : UNRELEASED_VERSION;
4085
+ var PACKAGE_VERSION = true ? "1.8.1" : UNRELEASED_VERSION;
3832
4086
 
3833
4087
  // ../core/dist/signing.js
3834
4088
  var encoder = new TextEncoder();
@@ -5651,4 +5905,4 @@ export {
5651
5905
  tokenCredential,
5652
5906
  RxVortexAPI
5653
5907
  };
5654
- //# sourceMappingURL=chunk-MTURRKQY.js.map
5908
+ //# sourceMappingURL=chunk-CNQMYSGI.js.map