@crvouga/mockingbird-service-mailosaur 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 +10 -0
- package/dist/{chunk-K4JQOFF4.js → chunk-QI7IPPVX.js} +268 -14
- package/dist/chunk-QI7IPPVX.js.map +7 -0
- package/dist/{chunk-ZJPTRVWG.js → chunk-W3PE5FFQ.js} +2 -2
- package/dist/cli.js +2 -2
- package/dist/index.js +1 -1
- package/dist/server.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-K4JQOFF4.js.map +0 -7
- /package/dist/{chunk-ZJPTRVWG.js.map → chunk-W3PE5FFQ.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-mailosaur
|
|
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
|
|
@@ -1947,6 +1947,167 @@ function faultPresetList(value) {
|
|
|
1947
1947
|
})
|
|
1948
1948
|
};
|
|
1949
1949
|
}
|
|
1950
|
+
function mountSqlExplorer(root, api) {
|
|
1951
|
+
const cell = (value) => {
|
|
1952
|
+
if (value === null || value === void 0)
|
|
1953
|
+
return "";
|
|
1954
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
1955
|
+
return String(value);
|
|
1956
|
+
}
|
|
1957
|
+
return JSON.stringify(value) ?? "";
|
|
1958
|
+
};
|
|
1959
|
+
root.replaceChildren();
|
|
1960
|
+
const layout = document.createElement("div");
|
|
1961
|
+
layout.className = "sql-layout";
|
|
1962
|
+
const tables = document.createElement("div");
|
|
1963
|
+
tables.className = "sql-tables";
|
|
1964
|
+
const stack = document.createElement("div");
|
|
1965
|
+
stack.className = "stack";
|
|
1966
|
+
const banner = document.createElement("p");
|
|
1967
|
+
banner.className = "banner";
|
|
1968
|
+
const grid = document.createElement("div");
|
|
1969
|
+
const input = document.createElement("textarea");
|
|
1970
|
+
input.className = "sql-input";
|
|
1971
|
+
input.spellcheck = false;
|
|
1972
|
+
input.placeholder = "SELECT * FROM ...";
|
|
1973
|
+
const actions = document.createElement("div");
|
|
1974
|
+
actions.className = "row-actions";
|
|
1975
|
+
const run = document.createElement("button");
|
|
1976
|
+
run.type = "button";
|
|
1977
|
+
run.textContent = "Run";
|
|
1978
|
+
actions.append(run);
|
|
1979
|
+
const result = document.createElement("pre");
|
|
1980
|
+
stack.append(banner, grid, input, actions, result);
|
|
1981
|
+
layout.append(tables, stack);
|
|
1982
|
+
root.append(layout);
|
|
1983
|
+
const showError = (error) => {
|
|
1984
|
+
banner.textContent = error instanceof Error ? error.message : String(error);
|
|
1985
|
+
banner.classList.add("show");
|
|
1986
|
+
};
|
|
1987
|
+
const clearError = () => {
|
|
1988
|
+
banner.textContent = "";
|
|
1989
|
+
banner.classList.remove("show");
|
|
1990
|
+
};
|
|
1991
|
+
const renderGrid = (columns, rows) => {
|
|
1992
|
+
grid.replaceChildren();
|
|
1993
|
+
if (columns.length === 0) {
|
|
1994
|
+
const empty = document.createElement("p");
|
|
1995
|
+
empty.className = "empty";
|
|
1996
|
+
empty.textContent = "No rows.";
|
|
1997
|
+
grid.append(empty);
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
const table = document.createElement("table");
|
|
2001
|
+
const head = document.createElement("thead");
|
|
2002
|
+
const headRow = document.createElement("tr");
|
|
2003
|
+
for (const column of columns) {
|
|
2004
|
+
const th = document.createElement("th");
|
|
2005
|
+
th.textContent = column;
|
|
2006
|
+
headRow.append(th);
|
|
2007
|
+
}
|
|
2008
|
+
head.append(headRow);
|
|
2009
|
+
const body = document.createElement("tbody");
|
|
2010
|
+
for (const row of rows) {
|
|
2011
|
+
const tr = document.createElement("tr");
|
|
2012
|
+
for (const column of columns) {
|
|
2013
|
+
const td = document.createElement("td");
|
|
2014
|
+
td.dataset.label = column;
|
|
2015
|
+
td.textContent = cell(row[column]);
|
|
2016
|
+
tr.append(td);
|
|
2017
|
+
}
|
|
2018
|
+
body.append(tr);
|
|
2019
|
+
}
|
|
2020
|
+
table.append(head, body);
|
|
2021
|
+
grid.append(table);
|
|
2022
|
+
};
|
|
2023
|
+
const rowsOf = (value) => {
|
|
2024
|
+
if (!isRecord2(value) || !Array.isArray(value.rows))
|
|
2025
|
+
return [];
|
|
2026
|
+
return value.rows.flatMap((row) => isRecord2(row) ? [row] : []);
|
|
2027
|
+
};
|
|
2028
|
+
const columnsOf = (value, rows) => {
|
|
2029
|
+
if (isRecord2(value) && Array.isArray(value.columns)) {
|
|
2030
|
+
const named = value.columns.flatMap((column) => typeof column === "string" ? [column] : []);
|
|
2031
|
+
if (named.length > 0)
|
|
2032
|
+
return named;
|
|
2033
|
+
}
|
|
2034
|
+
const first = rows[0];
|
|
2035
|
+
return first === void 0 ? [] : Object.keys(first);
|
|
2036
|
+
};
|
|
2037
|
+
let selected = "";
|
|
2038
|
+
const loadPage = async (schema, name) => {
|
|
2039
|
+
selected = `${schema}.${name}`;
|
|
2040
|
+
const page = await api.get(`/sql/tables/${encodeURIComponent(schema)}/${encodeURIComponent(name)}?limit=50`);
|
|
2041
|
+
const rows = rowsOf(page);
|
|
2042
|
+
renderGrid(columnsOf(page, rows), rows);
|
|
2043
|
+
const total = isRecord2(page) && typeof page.total === "number" ? page.total : rows.length;
|
|
2044
|
+
result.textContent = `${selected} \xB7 ${total} rows`;
|
|
2045
|
+
for (const button of tables.querySelectorAll("button")) {
|
|
2046
|
+
if (!(button instanceof HTMLButtonElement))
|
|
2047
|
+
continue;
|
|
2048
|
+
button.setAttribute("aria-current", button.dataset.schema === schema && button.dataset.table === name ? "true" : "false");
|
|
2049
|
+
}
|
|
2050
|
+
};
|
|
2051
|
+
const loadTables = async () => {
|
|
2052
|
+
const payload = await api.get("/sql/tables");
|
|
2053
|
+
const listed = isRecord2(payload) && Array.isArray(payload.tables) ? payload.tables : [];
|
|
2054
|
+
tables.replaceChildren();
|
|
2055
|
+
if (listed.length === 0) {
|
|
2056
|
+
const empty = document.createElement("p");
|
|
2057
|
+
empty.className = "empty";
|
|
2058
|
+
empty.textContent = "No tables.";
|
|
2059
|
+
tables.append(empty);
|
|
2060
|
+
return;
|
|
2061
|
+
}
|
|
2062
|
+
for (const item of listed) {
|
|
2063
|
+
if (!isRecord2(item) || typeof item.schema !== "string" || typeof item.name !== "string")
|
|
2064
|
+
continue;
|
|
2065
|
+
const button = document.createElement("button");
|
|
2066
|
+
button.type = "button";
|
|
2067
|
+
button.dataset.schema = item.schema;
|
|
2068
|
+
button.dataset.table = item.name;
|
|
2069
|
+
button.textContent = `${item.schema}.${item.name}`;
|
|
2070
|
+
tables.append(button);
|
|
2071
|
+
}
|
|
2072
|
+
};
|
|
2073
|
+
tables.addEventListener("click", (event) => {
|
|
2074
|
+
const target = event.target;
|
|
2075
|
+
if (!(target instanceof Element))
|
|
2076
|
+
return;
|
|
2077
|
+
const button = target.closest("button");
|
|
2078
|
+
if (!(button instanceof HTMLButtonElement))
|
|
2079
|
+
return;
|
|
2080
|
+
const schema = button.dataset.schema;
|
|
2081
|
+
const name = button.dataset.table;
|
|
2082
|
+
if (schema === void 0 || name === void 0)
|
|
2083
|
+
return;
|
|
2084
|
+
clearError();
|
|
2085
|
+
loadPage(schema, name).catch(showError);
|
|
2086
|
+
});
|
|
2087
|
+
run.addEventListener("click", () => {
|
|
2088
|
+
const sql = input.value.trim();
|
|
2089
|
+
if (sql === "") {
|
|
2090
|
+
showError(new Error("Enter a statement"));
|
|
2091
|
+
return;
|
|
2092
|
+
}
|
|
2093
|
+
clearError();
|
|
2094
|
+
api.send("POST", "/sql/query", { sql }).then((payload) => {
|
|
2095
|
+
const rows = rowsOf(payload);
|
|
2096
|
+
renderGrid(columnsOf(payload, rows), rows);
|
|
2097
|
+
const count = isRecord2(payload) && typeof payload.rowCount === "number" ? payload.rowCount : rows.length;
|
|
2098
|
+
const truncated = isRecord2(payload) && payload.truncated === true ? " (truncated)" : "";
|
|
2099
|
+
result.textContent = `${count} rows${truncated}`;
|
|
2100
|
+
}).catch(showError);
|
|
2101
|
+
});
|
|
2102
|
+
const namespace = document.getElementById("namespace");
|
|
2103
|
+
if (namespace) {
|
|
2104
|
+
namespace.addEventListener("change", () => {
|
|
2105
|
+
clearError();
|
|
2106
|
+
loadTables().catch(showError);
|
|
2107
|
+
});
|
|
2108
|
+
}
|
|
2109
|
+
loadTables().catch(showError);
|
|
2110
|
+
}
|
|
1950
2111
|
function bootAdmin(config) {
|
|
1951
2112
|
const fieldKinds = ["string", "number", "boolean", "null", "object", "array", "unknown"];
|
|
1952
2113
|
const sources = ["declared", "inferred", "mixed"];
|
|
@@ -2623,6 +2784,22 @@ function bootAdmin(config) {
|
|
|
2623
2784
|
panel.script = value.script;
|
|
2624
2785
|
return panel;
|
|
2625
2786
|
};
|
|
2787
|
+
const decodeExtension = (value) => {
|
|
2788
|
+
if (!isRecord2(value))
|
|
2789
|
+
return void 0;
|
|
2790
|
+
if (value.kind === "sql") {
|
|
2791
|
+
return {
|
|
2792
|
+
kind: "sql",
|
|
2793
|
+
id: typeof value.id === "string" && value.id !== "" ? value.id : "sql",
|
|
2794
|
+
title: typeof value.title === "string" && value.title !== "" ? value.title : "SQL",
|
|
2795
|
+
description: typeof value.description === "string" ? value.description : "Browse tables and run queries."
|
|
2796
|
+
};
|
|
2797
|
+
}
|
|
2798
|
+
if (value.kind !== "panel")
|
|
2799
|
+
return void 0;
|
|
2800
|
+
const panel = decodePanel(value);
|
|
2801
|
+
return panel === void 0 ? void 0 : { kind: "panel", ...panel };
|
|
2802
|
+
};
|
|
2626
2803
|
const mountPanels = (panels) => {
|
|
2627
2804
|
const nav = el("nav", HTMLElement);
|
|
2628
2805
|
const views = el("views", HTMLElement);
|
|
@@ -2676,10 +2853,48 @@ function bootAdmin(config) {
|
|
|
2676
2853
|
return decoded === void 0 ? [] : [decoded];
|
|
2677
2854
|
});
|
|
2678
2855
|
mountPanels(panels);
|
|
2856
|
+
const extensions = requireList(isRecord2(manifest) ? manifest.extensions : void 0, "Extensions").flatMap((extension) => {
|
|
2857
|
+
const decoded = decodeExtension(extension);
|
|
2858
|
+
return decoded === void 0 ? [] : [decoded];
|
|
2859
|
+
});
|
|
2860
|
+
const extensionPanels = extensions.flatMap((extension) => extension.kind === "panel" ? [extension] : []);
|
|
2861
|
+
mountPanels(extensionPanels);
|
|
2862
|
+
for (const extension of extensions) {
|
|
2863
|
+
if (extension.kind !== "sql")
|
|
2864
|
+
continue;
|
|
2865
|
+
const nav = el("nav", HTMLElement);
|
|
2866
|
+
const views = el("views", HTMLElement);
|
|
2867
|
+
const button = document.createElement("button");
|
|
2868
|
+
button.type = "button";
|
|
2869
|
+
button.dataset.view = extension.id;
|
|
2870
|
+
button.textContent = extension.title;
|
|
2871
|
+
nav.append(button);
|
|
2872
|
+
const section = document.createElement("section");
|
|
2873
|
+
section.className = "view";
|
|
2874
|
+
section.id = `view-${extension.id}`;
|
|
2875
|
+
section.hidden = true;
|
|
2876
|
+
const title = document.createElement("h2");
|
|
2877
|
+
title.textContent = extension.title;
|
|
2878
|
+
const lede = document.createElement("p");
|
|
2879
|
+
lede.className = "lede";
|
|
2880
|
+
lede.textContent = extension.description;
|
|
2881
|
+
const body = document.createElement("div");
|
|
2882
|
+
body.className = "panel-body";
|
|
2883
|
+
section.append(title, lede, body);
|
|
2884
|
+
views.append(section);
|
|
2885
|
+
mountSqlExplorer(body, panelApi);
|
|
2886
|
+
}
|
|
2679
2887
|
return refresh();
|
|
2680
2888
|
}).catch(showError);
|
|
2681
2889
|
}
|
|
2682
|
-
var clientPrelude = [
|
|
2890
|
+
var clientPrelude = [
|
|
2891
|
+
isRecord2,
|
|
2892
|
+
mountAdminBrand,
|
|
2893
|
+
startAdminBrand,
|
|
2894
|
+
faultPresetList,
|
|
2895
|
+
mountSqlExplorer,
|
|
2896
|
+
bootAdmin
|
|
2897
|
+
].map((fn) => fn.toString()).join("\n");
|
|
2683
2898
|
var adminClientSource = (config) => {
|
|
2684
2899
|
const payload = JSON.stringify(config).replace(/</g, "\\u003c");
|
|
2685
2900
|
const entry = bootAdmin.name;
|
|
@@ -2729,19 +2944,33 @@ var STANDARD_ADMIN_ROUTES = [
|
|
|
2729
2944
|
"GET /ui/manifest"
|
|
2730
2945
|
];
|
|
2731
2946
|
var PANEL_ID = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
|
|
2947
|
+
var RESERVED_VIEWS = /* @__PURE__ */ new Set(["overview", "state", "clock", "faults", "journal", "routes"]);
|
|
2948
|
+
var checkPanel = (panel, seen, label) => {
|
|
2949
|
+
if (!PANEL_ID.test(panel.id)) {
|
|
2950
|
+
throw new RangeError(`${label} id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
|
|
2951
|
+
}
|
|
2952
|
+
if (RESERVED_VIEWS.has(panel.id)) {
|
|
2953
|
+
throw new RangeError(`${label} id ${panel.id} is reserved by the admin shell`);
|
|
2954
|
+
}
|
|
2955
|
+
if (seen.has(panel.id))
|
|
2956
|
+
throw new RangeError(`duplicate admin view id ${panel.id}`);
|
|
2957
|
+
seen.add(panel.id);
|
|
2958
|
+
if (panel.title.trim() === "")
|
|
2959
|
+
throw new RangeError(`${label} ${panel.id} needs a title`);
|
|
2960
|
+
};
|
|
2732
2961
|
var assertAdminUi = (ui) => {
|
|
2733
|
-
if (!ui
|
|
2962
|
+
if (!ui)
|
|
2734
2963
|
return;
|
|
2735
2964
|
const seen = /* @__PURE__ */ new Set();
|
|
2736
|
-
for (const panel of ui.panels)
|
|
2737
|
-
|
|
2738
|
-
|
|
2965
|
+
for (const panel of ui.panels ?? [])
|
|
2966
|
+
checkPanel(panel, seen, "admin panel");
|
|
2967
|
+
for (const extension of ui.extensions ?? []) {
|
|
2968
|
+
if (extension.kind === "panel") {
|
|
2969
|
+
checkPanel(extension, seen, "admin extension");
|
|
2970
|
+
continue;
|
|
2739
2971
|
}
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
seen.add(panel.id);
|
|
2743
|
-
if (panel.title.trim() === "")
|
|
2744
|
-
throw new RangeError(`admin panel ${panel.id} needs a title`);
|
|
2972
|
+
const id = extension.id ?? "sql";
|
|
2973
|
+
checkPanel({ id, title: extension.title ?? "SQL" }, seen, "admin extension");
|
|
2745
2974
|
}
|
|
2746
2975
|
};
|
|
2747
2976
|
|
|
@@ -2975,6 +3204,12 @@ var renderAdminDocument = (service) => {
|
|
|
2975
3204
|
border-radius: 999px; padding: 4px 8px;
|
|
2976
3205
|
}
|
|
2977
3206
|
.chip i { color: var(--faint); font-style: normal; }
|
|
3207
|
+
.sql-layout {
|
|
3208
|
+
display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 16px;
|
|
3209
|
+
}
|
|
3210
|
+
.sql-tables { display: flex; flex-direction: column; gap: 4px; max-height: 28rem; overflow: auto; }
|
|
3211
|
+
.sql-tables button { text-align: left; }
|
|
3212
|
+
.sql-input { font-family: var(--mono); min-height: 7rem; width: 100%; }
|
|
2978
3213
|
table { width: 100%; border-collapse: collapse; font-size: 14px; }
|
|
2979
3214
|
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
|
|
2980
3215
|
th { color: var(--faint); font-weight: 600; font-size: 12px; }
|
|
@@ -3038,7 +3273,7 @@ var renderAdminDocument = (service) => {
|
|
|
3038
3273
|
padding: 8px;
|
|
3039
3274
|
}
|
|
3040
3275
|
nav.side button { white-space: nowrap; flex: none; }
|
|
3041
|
-
.split { grid-template-columns: minmax(0, 1fr); }
|
|
3276
|
+
.split, .sql-layout { grid-template-columns: minmax(0, 1fr); }
|
|
3042
3277
|
main { padding: 14px; }
|
|
3043
3278
|
table, thead, tbody, tr, th, td { display: block; }
|
|
3044
3279
|
thead { display: none; }
|
|
@@ -3209,6 +3444,24 @@ var json3 = (body) => new Response(JSON.stringify(body), {
|
|
|
3209
3444
|
status: 200,
|
|
3210
3445
|
headers: { "content-type": "application/json; charset=utf-8" }
|
|
3211
3446
|
});
|
|
3447
|
+
var describeExtension = (extension) => {
|
|
3448
|
+
if (extension.kind === "sql") {
|
|
3449
|
+
return {
|
|
3450
|
+
kind: "sql",
|
|
3451
|
+
id: extension.id ?? "sql",
|
|
3452
|
+
title: extension.title ?? "SQL",
|
|
3453
|
+
...extension.description !== void 0 ? { description: extension.description } : {}
|
|
3454
|
+
};
|
|
3455
|
+
}
|
|
3456
|
+
return {
|
|
3457
|
+
kind: "panel",
|
|
3458
|
+
id: extension.id,
|
|
3459
|
+
title: extension.title,
|
|
3460
|
+
...extension.description !== void 0 ? { description: extension.description } : {},
|
|
3461
|
+
html: extension.html,
|
|
3462
|
+
...extension.script !== void 0 ? { script: extension.script } : {}
|
|
3463
|
+
};
|
|
3464
|
+
};
|
|
3212
3465
|
var adminUiRoutes = (service, ui) => {
|
|
3213
3466
|
const shell = () => renderAdminDocument(service);
|
|
3214
3467
|
const document3 = () => ui?.render ? ui.render({ service, defaultHtml: shell }) : shell();
|
|
@@ -3223,7 +3476,8 @@ var adminUiRoutes = (service, ui) => {
|
|
|
3223
3476
|
...panel.description !== void 0 ? { description: panel.description } : {},
|
|
3224
3477
|
html: panel.html,
|
|
3225
3478
|
...panel.script !== void 0 ? { script: panel.script } : {}
|
|
3226
|
-
}))
|
|
3479
|
+
})),
|
|
3480
|
+
extensions: (ui?.extensions ?? []).map(describeExtension)
|
|
3227
3481
|
})
|
|
3228
3482
|
};
|
|
3229
3483
|
};
|
|
@@ -3900,7 +4154,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
3900
4154
|
};
|
|
3901
4155
|
|
|
3902
4156
|
// ../core/dist/version.js
|
|
3903
|
-
var PACKAGE_VERSION = true ? "1.
|
|
4157
|
+
var PACKAGE_VERSION = true ? "1.7.0" : UNRELEASED_VERSION;
|
|
3904
4158
|
|
|
3905
4159
|
// ../core/dist/signing.js
|
|
3906
4160
|
var encoder = new TextEncoder();
|
|
@@ -5224,4 +5478,4 @@ export {
|
|
|
5224
5478
|
matchesCriteria,
|
|
5225
5479
|
MailosaurAPI
|
|
5226
5480
|
};
|
|
5227
|
-
//# sourceMappingURL=chunk-
|
|
5481
|
+
//# sourceMappingURL=chunk-QI7IPPVX.js.map
|