@crvouga/mockingbird-service-resend 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-resend
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-RUK2K5Y6.js";
3
+ } from "./chunk-6IUFS2K3.js";
4
4
 
5
5
  // ../../adapters/node/dist/cli.js
6
6
  import { readFile } from "node:fs/promises";
@@ -370,4 +370,4 @@ export {
370
370
  createServer2 as createServer,
371
371
  serveTarget
372
372
  };
373
- //# sourceMappingURL=chunk-FVK4CBNZ.js.map
373
+ //# sourceMappingURL=chunk-4XYXP3QY.js.map
@@ -2002,6 +2002,167 @@ function faultPresetList(value) {
2002
2002
  })
2003
2003
  };
2004
2004
  }
2005
+ function mountSqlExplorer(root, api) {
2006
+ const cell = (value) => {
2007
+ if (value === null || value === void 0)
2008
+ return "";
2009
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
2010
+ return String(value);
2011
+ }
2012
+ return JSON.stringify(value) ?? "";
2013
+ };
2014
+ root.replaceChildren();
2015
+ const layout = document.createElement("div");
2016
+ layout.className = "sql-layout";
2017
+ const tables = document.createElement("div");
2018
+ tables.className = "sql-tables";
2019
+ const stack = document.createElement("div");
2020
+ stack.className = "stack";
2021
+ const banner = document.createElement("p");
2022
+ banner.className = "banner";
2023
+ const grid = document.createElement("div");
2024
+ const input = document.createElement("textarea");
2025
+ input.className = "sql-input";
2026
+ input.spellcheck = false;
2027
+ input.placeholder = "SELECT * FROM ...";
2028
+ const actions = document.createElement("div");
2029
+ actions.className = "row-actions";
2030
+ const run = document.createElement("button");
2031
+ run.type = "button";
2032
+ run.textContent = "Run";
2033
+ actions.append(run);
2034
+ const result = document.createElement("pre");
2035
+ stack.append(banner, grid, input, actions, result);
2036
+ layout.append(tables, stack);
2037
+ root.append(layout);
2038
+ const showError = (error2) => {
2039
+ banner.textContent = error2 instanceof Error ? error2.message : String(error2);
2040
+ banner.classList.add("show");
2041
+ };
2042
+ const clearError = () => {
2043
+ banner.textContent = "";
2044
+ banner.classList.remove("show");
2045
+ };
2046
+ const renderGrid = (columns, rows) => {
2047
+ grid.replaceChildren();
2048
+ if (columns.length === 0) {
2049
+ const empty = document.createElement("p");
2050
+ empty.className = "empty";
2051
+ empty.textContent = "No rows.";
2052
+ grid.append(empty);
2053
+ return;
2054
+ }
2055
+ const table = document.createElement("table");
2056
+ const head = document.createElement("thead");
2057
+ const headRow = document.createElement("tr");
2058
+ for (const column of columns) {
2059
+ const th = document.createElement("th");
2060
+ th.textContent = column;
2061
+ headRow.append(th);
2062
+ }
2063
+ head.append(headRow);
2064
+ const body = document.createElement("tbody");
2065
+ for (const row of rows) {
2066
+ const tr = document.createElement("tr");
2067
+ for (const column of columns) {
2068
+ const td = document.createElement("td");
2069
+ td.dataset.label = column;
2070
+ td.textContent = cell(row[column]);
2071
+ tr.append(td);
2072
+ }
2073
+ body.append(tr);
2074
+ }
2075
+ table.append(head, body);
2076
+ grid.append(table);
2077
+ };
2078
+ const rowsOf = (value) => {
2079
+ if (!isRecord2(value) || !Array.isArray(value.rows))
2080
+ return [];
2081
+ return value.rows.flatMap((row) => isRecord2(row) ? [row] : []);
2082
+ };
2083
+ const columnsOf = (value, rows) => {
2084
+ if (isRecord2(value) && Array.isArray(value.columns)) {
2085
+ const named = value.columns.flatMap((column) => typeof column === "string" ? [column] : []);
2086
+ if (named.length > 0)
2087
+ return named;
2088
+ }
2089
+ const first = rows[0];
2090
+ return first === void 0 ? [] : Object.keys(first);
2091
+ };
2092
+ let selected = "";
2093
+ const loadPage = async (schema, name) => {
2094
+ selected = `${schema}.${name}`;
2095
+ const page = await api.get(`/sql/tables/${encodeURIComponent(schema)}/${encodeURIComponent(name)}?limit=50`);
2096
+ const rows = rowsOf(page);
2097
+ renderGrid(columnsOf(page, rows), rows);
2098
+ const total = isRecord2(page) && typeof page.total === "number" ? page.total : rows.length;
2099
+ result.textContent = `${selected} \xB7 ${total} rows`;
2100
+ for (const button of tables.querySelectorAll("button")) {
2101
+ if (!(button instanceof HTMLButtonElement))
2102
+ continue;
2103
+ button.setAttribute("aria-current", button.dataset.schema === schema && button.dataset.table === name ? "true" : "false");
2104
+ }
2105
+ };
2106
+ const loadTables = async () => {
2107
+ const payload = await api.get("/sql/tables");
2108
+ const listed = isRecord2(payload) && Array.isArray(payload.tables) ? payload.tables : [];
2109
+ tables.replaceChildren();
2110
+ if (listed.length === 0) {
2111
+ const empty = document.createElement("p");
2112
+ empty.className = "empty";
2113
+ empty.textContent = "No tables.";
2114
+ tables.append(empty);
2115
+ return;
2116
+ }
2117
+ for (const item of listed) {
2118
+ if (!isRecord2(item) || typeof item.schema !== "string" || typeof item.name !== "string")
2119
+ continue;
2120
+ const button = document.createElement("button");
2121
+ button.type = "button";
2122
+ button.dataset.schema = item.schema;
2123
+ button.dataset.table = item.name;
2124
+ button.textContent = `${item.schema}.${item.name}`;
2125
+ tables.append(button);
2126
+ }
2127
+ };
2128
+ tables.addEventListener("click", (event) => {
2129
+ const target = event.target;
2130
+ if (!(target instanceof Element))
2131
+ return;
2132
+ const button = target.closest("button");
2133
+ if (!(button instanceof HTMLButtonElement))
2134
+ return;
2135
+ const schema = button.dataset.schema;
2136
+ const name = button.dataset.table;
2137
+ if (schema === void 0 || name === void 0)
2138
+ return;
2139
+ clearError();
2140
+ loadPage(schema, name).catch(showError);
2141
+ });
2142
+ run.addEventListener("click", () => {
2143
+ const sql = input.value.trim();
2144
+ if (sql === "") {
2145
+ showError(new Error("Enter a statement"));
2146
+ return;
2147
+ }
2148
+ clearError();
2149
+ api.send("POST", "/sql/query", { sql }).then((payload) => {
2150
+ const rows = rowsOf(payload);
2151
+ renderGrid(columnsOf(payload, rows), rows);
2152
+ const count = isRecord2(payload) && typeof payload.rowCount === "number" ? payload.rowCount : rows.length;
2153
+ const truncated = isRecord2(payload) && payload.truncated === true ? " (truncated)" : "";
2154
+ result.textContent = `${count} rows${truncated}`;
2155
+ }).catch(showError);
2156
+ });
2157
+ const namespace = document.getElementById("namespace");
2158
+ if (namespace) {
2159
+ namespace.addEventListener("change", () => {
2160
+ clearError();
2161
+ loadTables().catch(showError);
2162
+ });
2163
+ }
2164
+ loadTables().catch(showError);
2165
+ }
2005
2166
  function bootAdmin(config) {
2006
2167
  const fieldKinds = ["string", "number", "boolean", "null", "object", "array", "unknown"];
2007
2168
  const sources = ["declared", "inferred", "mixed"];
@@ -2678,6 +2839,22 @@ function bootAdmin(config) {
2678
2839
  panel.script = value.script;
2679
2840
  return panel;
2680
2841
  };
2842
+ const decodeExtension = (value) => {
2843
+ if (!isRecord2(value))
2844
+ return void 0;
2845
+ if (value.kind === "sql") {
2846
+ return {
2847
+ kind: "sql",
2848
+ id: typeof value.id === "string" && value.id !== "" ? value.id : "sql",
2849
+ title: typeof value.title === "string" && value.title !== "" ? value.title : "SQL",
2850
+ description: typeof value.description === "string" ? value.description : "Browse tables and run queries."
2851
+ };
2852
+ }
2853
+ if (value.kind !== "panel")
2854
+ return void 0;
2855
+ const panel = decodePanel(value);
2856
+ return panel === void 0 ? void 0 : { kind: "panel", ...panel };
2857
+ };
2681
2858
  const mountPanels = (panels) => {
2682
2859
  const nav = el("nav", HTMLElement);
2683
2860
  const views = el("views", HTMLElement);
@@ -2731,10 +2908,48 @@ function bootAdmin(config) {
2731
2908
  return decoded === void 0 ? [] : [decoded];
2732
2909
  });
2733
2910
  mountPanels(panels);
2911
+ const extensions = requireList(isRecord2(manifest) ? manifest.extensions : void 0, "Extensions").flatMap((extension) => {
2912
+ const decoded = decodeExtension(extension);
2913
+ return decoded === void 0 ? [] : [decoded];
2914
+ });
2915
+ const extensionPanels = extensions.flatMap((extension) => extension.kind === "panel" ? [extension] : []);
2916
+ mountPanels(extensionPanels);
2917
+ for (const extension of extensions) {
2918
+ if (extension.kind !== "sql")
2919
+ continue;
2920
+ const nav = el("nav", HTMLElement);
2921
+ const views = el("views", HTMLElement);
2922
+ const button = document.createElement("button");
2923
+ button.type = "button";
2924
+ button.dataset.view = extension.id;
2925
+ button.textContent = extension.title;
2926
+ nav.append(button);
2927
+ const section = document.createElement("section");
2928
+ section.className = "view";
2929
+ section.id = `view-${extension.id}`;
2930
+ section.hidden = true;
2931
+ const title = document.createElement("h2");
2932
+ title.textContent = extension.title;
2933
+ const lede = document.createElement("p");
2934
+ lede.className = "lede";
2935
+ lede.textContent = extension.description;
2936
+ const body = document.createElement("div");
2937
+ body.className = "panel-body";
2938
+ section.append(title, lede, body);
2939
+ views.append(section);
2940
+ mountSqlExplorer(body, panelApi);
2941
+ }
2734
2942
  return refresh();
2735
2943
  }).catch(showError);
2736
2944
  }
2737
- var clientPrelude = [isRecord2, mountAdminBrand, startAdminBrand, faultPresetList, bootAdmin].map((fn) => fn.toString()).join("\n");
2945
+ var clientPrelude = [
2946
+ isRecord2,
2947
+ mountAdminBrand,
2948
+ startAdminBrand,
2949
+ faultPresetList,
2950
+ mountSqlExplorer,
2951
+ bootAdmin
2952
+ ].map((fn) => fn.toString()).join("\n");
2738
2953
  var adminClientSource = (config) => {
2739
2954
  const payload = JSON.stringify(config).replace(/</g, "\\u003c");
2740
2955
  const entry = bootAdmin.name;
@@ -2784,19 +2999,33 @@ var STANDARD_ADMIN_ROUTES = [
2784
2999
  "GET /ui/manifest"
2785
3000
  ];
2786
3001
  var PANEL_ID = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
3002
+ var RESERVED_VIEWS = /* @__PURE__ */ new Set(["overview", "state", "clock", "faults", "journal", "routes"]);
3003
+ var checkPanel = (panel, seen, label) => {
3004
+ if (!PANEL_ID.test(panel.id)) {
3005
+ throw new RangeError(`${label} id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
3006
+ }
3007
+ if (RESERVED_VIEWS.has(panel.id)) {
3008
+ throw new RangeError(`${label} id ${panel.id} is reserved by the admin shell`);
3009
+ }
3010
+ if (seen.has(panel.id))
3011
+ throw new RangeError(`duplicate admin view id ${panel.id}`);
3012
+ seen.add(panel.id);
3013
+ if (panel.title.trim() === "")
3014
+ throw new RangeError(`${label} ${panel.id} needs a title`);
3015
+ };
2787
3016
  var assertAdminUi = (ui) => {
2788
- if (!ui?.panels)
3017
+ if (!ui)
2789
3018
  return;
2790
3019
  const seen = /* @__PURE__ */ new Set();
2791
- for (const panel of ui.panels) {
2792
- if (!PANEL_ID.test(panel.id)) {
2793
- throw new RangeError(`admin panel id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
3020
+ for (const panel of ui.panels ?? [])
3021
+ checkPanel(panel, seen, "admin panel");
3022
+ for (const extension of ui.extensions ?? []) {
3023
+ if (extension.kind === "panel") {
3024
+ checkPanel(extension, seen, "admin extension");
3025
+ continue;
2794
3026
  }
2795
- if (seen.has(panel.id))
2796
- throw new RangeError(`duplicate admin panel id ${panel.id}`);
2797
- seen.add(panel.id);
2798
- if (panel.title.trim() === "")
2799
- throw new RangeError(`admin panel ${panel.id} needs a title`);
3027
+ const id = extension.id ?? "sql";
3028
+ checkPanel({ id, title: extension.title ?? "SQL" }, seen, "admin extension");
2800
3029
  }
2801
3030
  };
2802
3031
 
@@ -3030,6 +3259,12 @@ var renderAdminDocument = (service) => {
3030
3259
  border-radius: 999px; padding: 4px 8px;
3031
3260
  }
3032
3261
  .chip i { color: var(--faint); font-style: normal; }
3262
+ .sql-layout {
3263
+ display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 16px;
3264
+ }
3265
+ .sql-tables { display: flex; flex-direction: column; gap: 4px; max-height: 28rem; overflow: auto; }
3266
+ .sql-tables button { text-align: left; }
3267
+ .sql-input { font-family: var(--mono); min-height: 7rem; width: 100%; }
3033
3268
  table { width: 100%; border-collapse: collapse; font-size: 14px; }
3034
3269
  th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
3035
3270
  th { color: var(--faint); font-weight: 600; font-size: 12px; }
@@ -3093,7 +3328,7 @@ var renderAdminDocument = (service) => {
3093
3328
  padding: 8px;
3094
3329
  }
3095
3330
  nav.side button { white-space: nowrap; flex: none; }
3096
- .split { grid-template-columns: minmax(0, 1fr); }
3331
+ .split, .sql-layout { grid-template-columns: minmax(0, 1fr); }
3097
3332
  main { padding: 14px; }
3098
3333
  table, thead, tbody, tr, th, td { display: block; }
3099
3334
  thead { display: none; }
@@ -3264,6 +3499,24 @@ var json3 = (body) => new Response(JSON.stringify(body), {
3264
3499
  status: 200,
3265
3500
  headers: { "content-type": "application/json; charset=utf-8" }
3266
3501
  });
3502
+ var describeExtension = (extension) => {
3503
+ if (extension.kind === "sql") {
3504
+ return {
3505
+ kind: "sql",
3506
+ id: extension.id ?? "sql",
3507
+ title: extension.title ?? "SQL",
3508
+ ...extension.description !== void 0 ? { description: extension.description } : {}
3509
+ };
3510
+ }
3511
+ return {
3512
+ kind: "panel",
3513
+ id: extension.id,
3514
+ title: extension.title,
3515
+ ...extension.description !== void 0 ? { description: extension.description } : {},
3516
+ html: extension.html,
3517
+ ...extension.script !== void 0 ? { script: extension.script } : {}
3518
+ };
3519
+ };
3267
3520
  var adminUiRoutes = (service, ui) => {
3268
3521
  const shell = () => renderAdminDocument(service);
3269
3522
  const document3 = () => ui?.render ? ui.render({ service, defaultHtml: shell }) : shell();
@@ -3278,7 +3531,8 @@ var adminUiRoutes = (service, ui) => {
3278
3531
  ...panel.description !== void 0 ? { description: panel.description } : {},
3279
3532
  html: panel.html,
3280
3533
  ...panel.script !== void 0 ? { script: panel.script } : {}
3281
- }))
3534
+ })),
3535
+ extensions: (ui?.extensions ?? []).map(describeExtension)
3282
3536
  })
3283
3537
  };
3284
3538
  };
@@ -3955,7 +4209,7 @@ var stateAdminRoutes = (routes) => {
3955
4209
  };
3956
4210
 
3957
4211
  // ../core/dist/version.js
3958
- var PACKAGE_VERSION = true ? "1.6.1" : UNRELEASED_VERSION;
4212
+ var PACKAGE_VERSION = true ? "1.7.0" : UNRELEASED_VERSION;
3959
4213
 
3960
4214
  // ../core/dist/signing.js
3961
4215
  var encoder = new TextEncoder();
@@ -5671,4 +5925,4 @@ export {
5671
5925
  bareAddress,
5672
5926
  ResendAPI
5673
5927
  };
5674
- //# sourceMappingURL=chunk-RUK2K5Y6.js.map
5928
+ //# sourceMappingURL=chunk-6IUFS2K3.js.map