@crvouga/mockingbird-service-intercom 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 +12 -0
- package/dist/{chunk-U46KHRXA.js → chunk-TWQJOOK7.js} +270 -16
- package/dist/chunk-TWQJOOK7.js.map +7 -0
- package/dist/{chunk-6CA2VLGC.js → chunk-VHZO3W3M.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-U46KHRXA.js.map +0 -7
- /package/dist/{chunk-6CA2VLGC.js.map → chunk-VHZO3W3M.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-intercom
|
|
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());
|
|
@@ -1973,6 +1973,167 @@ function faultPresetList(value) {
|
|
|
1973
1973
|
})
|
|
1974
1974
|
};
|
|
1975
1975
|
}
|
|
1976
|
+
function mountSqlExplorer(root, api) {
|
|
1977
|
+
const cell = (value) => {
|
|
1978
|
+
if (value === null || value === void 0)
|
|
1979
|
+
return "";
|
|
1980
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
1981
|
+
return String(value);
|
|
1982
|
+
}
|
|
1983
|
+
return JSON.stringify(value) ?? "";
|
|
1984
|
+
};
|
|
1985
|
+
root.replaceChildren();
|
|
1986
|
+
const layout = document.createElement("div");
|
|
1987
|
+
layout.className = "sql-layout";
|
|
1988
|
+
const tables = document.createElement("div");
|
|
1989
|
+
tables.className = "sql-tables";
|
|
1990
|
+
const stack = document.createElement("div");
|
|
1991
|
+
stack.className = "stack";
|
|
1992
|
+
const banner = document.createElement("p");
|
|
1993
|
+
banner.className = "banner";
|
|
1994
|
+
const grid = document.createElement("div");
|
|
1995
|
+
const input = document.createElement("textarea");
|
|
1996
|
+
input.className = "sql-input";
|
|
1997
|
+
input.spellcheck = false;
|
|
1998
|
+
input.placeholder = "SELECT * FROM ...";
|
|
1999
|
+
const actions = document.createElement("div");
|
|
2000
|
+
actions.className = "row-actions";
|
|
2001
|
+
const run = document.createElement("button");
|
|
2002
|
+
run.type = "button";
|
|
2003
|
+
run.textContent = "Run";
|
|
2004
|
+
actions.append(run);
|
|
2005
|
+
const result = document.createElement("pre");
|
|
2006
|
+
stack.append(banner, grid, input, actions, result);
|
|
2007
|
+
layout.append(tables, stack);
|
|
2008
|
+
root.append(layout);
|
|
2009
|
+
const showError = (error) => {
|
|
2010
|
+
banner.textContent = error instanceof Error ? error.message : String(error);
|
|
2011
|
+
banner.classList.add("show");
|
|
2012
|
+
};
|
|
2013
|
+
const clearError = () => {
|
|
2014
|
+
banner.textContent = "";
|
|
2015
|
+
banner.classList.remove("show");
|
|
2016
|
+
};
|
|
2017
|
+
const renderGrid = (columns, rows) => {
|
|
2018
|
+
grid.replaceChildren();
|
|
2019
|
+
if (columns.length === 0) {
|
|
2020
|
+
const empty = document.createElement("p");
|
|
2021
|
+
empty.className = "empty";
|
|
2022
|
+
empty.textContent = "No rows.";
|
|
2023
|
+
grid.append(empty);
|
|
2024
|
+
return;
|
|
2025
|
+
}
|
|
2026
|
+
const table = document.createElement("table");
|
|
2027
|
+
const head = document.createElement("thead");
|
|
2028
|
+
const headRow = document.createElement("tr");
|
|
2029
|
+
for (const column of columns) {
|
|
2030
|
+
const th = document.createElement("th");
|
|
2031
|
+
th.textContent = column;
|
|
2032
|
+
headRow.append(th);
|
|
2033
|
+
}
|
|
2034
|
+
head.append(headRow);
|
|
2035
|
+
const body = document.createElement("tbody");
|
|
2036
|
+
for (const row of rows) {
|
|
2037
|
+
const tr = document.createElement("tr");
|
|
2038
|
+
for (const column of columns) {
|
|
2039
|
+
const td = document.createElement("td");
|
|
2040
|
+
td.dataset.label = column;
|
|
2041
|
+
td.textContent = cell(row[column]);
|
|
2042
|
+
tr.append(td);
|
|
2043
|
+
}
|
|
2044
|
+
body.append(tr);
|
|
2045
|
+
}
|
|
2046
|
+
table.append(head, body);
|
|
2047
|
+
grid.append(table);
|
|
2048
|
+
};
|
|
2049
|
+
const rowsOf = (value) => {
|
|
2050
|
+
if (!isRecord2(value) || !Array.isArray(value.rows))
|
|
2051
|
+
return [];
|
|
2052
|
+
return value.rows.flatMap((row) => isRecord2(row) ? [row] : []);
|
|
2053
|
+
};
|
|
2054
|
+
const columnsOf = (value, rows) => {
|
|
2055
|
+
if (isRecord2(value) && Array.isArray(value.columns)) {
|
|
2056
|
+
const named = value.columns.flatMap((column) => typeof column === "string" ? [column] : []);
|
|
2057
|
+
if (named.length > 0)
|
|
2058
|
+
return named;
|
|
2059
|
+
}
|
|
2060
|
+
const first = rows[0];
|
|
2061
|
+
return first === void 0 ? [] : Object.keys(first);
|
|
2062
|
+
};
|
|
2063
|
+
let selected = "";
|
|
2064
|
+
const loadPage = async (schema, name) => {
|
|
2065
|
+
selected = `${schema}.${name}`;
|
|
2066
|
+
const page = await api.get(`/sql/tables/${encodeURIComponent(schema)}/${encodeURIComponent(name)}?limit=50`);
|
|
2067
|
+
const rows = rowsOf(page);
|
|
2068
|
+
renderGrid(columnsOf(page, rows), rows);
|
|
2069
|
+
const total = isRecord2(page) && typeof page.total === "number" ? page.total : rows.length;
|
|
2070
|
+
result.textContent = `${selected} \xB7 ${total} rows`;
|
|
2071
|
+
for (const button of tables.querySelectorAll("button")) {
|
|
2072
|
+
if (!(button instanceof HTMLButtonElement))
|
|
2073
|
+
continue;
|
|
2074
|
+
button.setAttribute("aria-current", button.dataset.schema === schema && button.dataset.table === name ? "true" : "false");
|
|
2075
|
+
}
|
|
2076
|
+
};
|
|
2077
|
+
const loadTables = async () => {
|
|
2078
|
+
const payload = await api.get("/sql/tables");
|
|
2079
|
+
const listed = isRecord2(payload) && Array.isArray(payload.tables) ? payload.tables : [];
|
|
2080
|
+
tables.replaceChildren();
|
|
2081
|
+
if (listed.length === 0) {
|
|
2082
|
+
const empty = document.createElement("p");
|
|
2083
|
+
empty.className = "empty";
|
|
2084
|
+
empty.textContent = "No tables.";
|
|
2085
|
+
tables.append(empty);
|
|
2086
|
+
return;
|
|
2087
|
+
}
|
|
2088
|
+
for (const item of listed) {
|
|
2089
|
+
if (!isRecord2(item) || typeof item.schema !== "string" || typeof item.name !== "string")
|
|
2090
|
+
continue;
|
|
2091
|
+
const button = document.createElement("button");
|
|
2092
|
+
button.type = "button";
|
|
2093
|
+
button.dataset.schema = item.schema;
|
|
2094
|
+
button.dataset.table = item.name;
|
|
2095
|
+
button.textContent = `${item.schema}.${item.name}`;
|
|
2096
|
+
tables.append(button);
|
|
2097
|
+
}
|
|
2098
|
+
};
|
|
2099
|
+
tables.addEventListener("click", (event) => {
|
|
2100
|
+
const target = event.target;
|
|
2101
|
+
if (!(target instanceof Element))
|
|
2102
|
+
return;
|
|
2103
|
+
const button = target.closest("button");
|
|
2104
|
+
if (!(button instanceof HTMLButtonElement))
|
|
2105
|
+
return;
|
|
2106
|
+
const schema = button.dataset.schema;
|
|
2107
|
+
const name = button.dataset.table;
|
|
2108
|
+
if (schema === void 0 || name === void 0)
|
|
2109
|
+
return;
|
|
2110
|
+
clearError();
|
|
2111
|
+
loadPage(schema, name).catch(showError);
|
|
2112
|
+
});
|
|
2113
|
+
run.addEventListener("click", () => {
|
|
2114
|
+
const sql = input.value.trim();
|
|
2115
|
+
if (sql === "") {
|
|
2116
|
+
showError(new Error("Enter a statement"));
|
|
2117
|
+
return;
|
|
2118
|
+
}
|
|
2119
|
+
clearError();
|
|
2120
|
+
api.send("POST", "/sql/query", { sql }).then((payload) => {
|
|
2121
|
+
const rows = rowsOf(payload);
|
|
2122
|
+
renderGrid(columnsOf(payload, rows), rows);
|
|
2123
|
+
const count = isRecord2(payload) && typeof payload.rowCount === "number" ? payload.rowCount : rows.length;
|
|
2124
|
+
const truncated = isRecord2(payload) && payload.truncated === true ? " (truncated)" : "";
|
|
2125
|
+
result.textContent = `${count} rows${truncated}`;
|
|
2126
|
+
}).catch(showError);
|
|
2127
|
+
});
|
|
2128
|
+
const namespace = document.getElementById("namespace");
|
|
2129
|
+
if (namespace) {
|
|
2130
|
+
namespace.addEventListener("change", () => {
|
|
2131
|
+
clearError();
|
|
2132
|
+
loadTables().catch(showError);
|
|
2133
|
+
});
|
|
2134
|
+
}
|
|
2135
|
+
loadTables().catch(showError);
|
|
2136
|
+
}
|
|
1976
2137
|
function bootAdmin(config) {
|
|
1977
2138
|
const fieldKinds = ["string", "number", "boolean", "null", "object", "array", "unknown"];
|
|
1978
2139
|
const sources = ["declared", "inferred", "mixed"];
|
|
@@ -2649,6 +2810,22 @@ function bootAdmin(config) {
|
|
|
2649
2810
|
panel.script = value.script;
|
|
2650
2811
|
return panel;
|
|
2651
2812
|
};
|
|
2813
|
+
const decodeExtension = (value) => {
|
|
2814
|
+
if (!isRecord2(value))
|
|
2815
|
+
return void 0;
|
|
2816
|
+
if (value.kind === "sql") {
|
|
2817
|
+
return {
|
|
2818
|
+
kind: "sql",
|
|
2819
|
+
id: typeof value.id === "string" && value.id !== "" ? value.id : "sql",
|
|
2820
|
+
title: typeof value.title === "string" && value.title !== "" ? value.title : "SQL",
|
|
2821
|
+
description: typeof value.description === "string" ? value.description : "Browse tables and run queries."
|
|
2822
|
+
};
|
|
2823
|
+
}
|
|
2824
|
+
if (value.kind !== "panel")
|
|
2825
|
+
return void 0;
|
|
2826
|
+
const panel = decodePanel(value);
|
|
2827
|
+
return panel === void 0 ? void 0 : { kind: "panel", ...panel };
|
|
2828
|
+
};
|
|
2652
2829
|
const mountPanels = (panels) => {
|
|
2653
2830
|
const nav = el("nav", HTMLElement);
|
|
2654
2831
|
const views = el("views", HTMLElement);
|
|
@@ -2702,10 +2879,48 @@ function bootAdmin(config) {
|
|
|
2702
2879
|
return decoded === void 0 ? [] : [decoded];
|
|
2703
2880
|
});
|
|
2704
2881
|
mountPanels(panels);
|
|
2882
|
+
const extensions = requireList(isRecord2(manifest) ? manifest.extensions : void 0, "Extensions").flatMap((extension) => {
|
|
2883
|
+
const decoded = decodeExtension(extension);
|
|
2884
|
+
return decoded === void 0 ? [] : [decoded];
|
|
2885
|
+
});
|
|
2886
|
+
const extensionPanels = extensions.flatMap((extension) => extension.kind === "panel" ? [extension] : []);
|
|
2887
|
+
mountPanels(extensionPanels);
|
|
2888
|
+
for (const extension of extensions) {
|
|
2889
|
+
if (extension.kind !== "sql")
|
|
2890
|
+
continue;
|
|
2891
|
+
const nav = el("nav", HTMLElement);
|
|
2892
|
+
const views = el("views", HTMLElement);
|
|
2893
|
+
const button = document.createElement("button");
|
|
2894
|
+
button.type = "button";
|
|
2895
|
+
button.dataset.view = extension.id;
|
|
2896
|
+
button.textContent = extension.title;
|
|
2897
|
+
nav.append(button);
|
|
2898
|
+
const section = document.createElement("section");
|
|
2899
|
+
section.className = "view";
|
|
2900
|
+
section.id = `view-${extension.id}`;
|
|
2901
|
+
section.hidden = true;
|
|
2902
|
+
const title = document.createElement("h2");
|
|
2903
|
+
title.textContent = extension.title;
|
|
2904
|
+
const lede = document.createElement("p");
|
|
2905
|
+
lede.className = "lede";
|
|
2906
|
+
lede.textContent = extension.description;
|
|
2907
|
+
const body = document.createElement("div");
|
|
2908
|
+
body.className = "panel-body";
|
|
2909
|
+
section.append(title, lede, body);
|
|
2910
|
+
views.append(section);
|
|
2911
|
+
mountSqlExplorer(body, panelApi);
|
|
2912
|
+
}
|
|
2705
2913
|
return refresh();
|
|
2706
2914
|
}).catch(showError);
|
|
2707
2915
|
}
|
|
2708
|
-
var clientPrelude = [
|
|
2916
|
+
var clientPrelude = [
|
|
2917
|
+
isRecord2,
|
|
2918
|
+
mountAdminBrand,
|
|
2919
|
+
startAdminBrand,
|
|
2920
|
+
faultPresetList,
|
|
2921
|
+
mountSqlExplorer,
|
|
2922
|
+
bootAdmin
|
|
2923
|
+
].map((fn) => fn.toString()).join("\n");
|
|
2709
2924
|
var adminClientSource = (config) => {
|
|
2710
2925
|
const payload = JSON.stringify(config).replace(/</g, "\\u003c");
|
|
2711
2926
|
const entry = bootAdmin.name;
|
|
@@ -2755,19 +2970,33 @@ var STANDARD_ADMIN_ROUTES = [
|
|
|
2755
2970
|
"GET /ui/manifest"
|
|
2756
2971
|
];
|
|
2757
2972
|
var PANEL_ID = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
|
|
2973
|
+
var RESERVED_VIEWS = /* @__PURE__ */ new Set(["overview", "state", "clock", "faults", "journal", "routes"]);
|
|
2974
|
+
var checkPanel = (panel, seen, label) => {
|
|
2975
|
+
if (!PANEL_ID.test(panel.id)) {
|
|
2976
|
+
throw new RangeError(`${label} id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
|
|
2977
|
+
}
|
|
2978
|
+
if (RESERVED_VIEWS.has(panel.id)) {
|
|
2979
|
+
throw new RangeError(`${label} id ${panel.id} is reserved by the admin shell`);
|
|
2980
|
+
}
|
|
2981
|
+
if (seen.has(panel.id))
|
|
2982
|
+
throw new RangeError(`duplicate admin view id ${panel.id}`);
|
|
2983
|
+
seen.add(panel.id);
|
|
2984
|
+
if (panel.title.trim() === "")
|
|
2985
|
+
throw new RangeError(`${label} ${panel.id} needs a title`);
|
|
2986
|
+
};
|
|
2758
2987
|
var assertAdminUi = (ui) => {
|
|
2759
|
-
if (!ui
|
|
2988
|
+
if (!ui)
|
|
2760
2989
|
return;
|
|
2761
2990
|
const seen = /* @__PURE__ */ new Set();
|
|
2762
|
-
for (const panel of ui.panels)
|
|
2763
|
-
|
|
2764
|
-
|
|
2991
|
+
for (const panel of ui.panels ?? [])
|
|
2992
|
+
checkPanel(panel, seen, "admin panel");
|
|
2993
|
+
for (const extension of ui.extensions ?? []) {
|
|
2994
|
+
if (extension.kind === "panel") {
|
|
2995
|
+
checkPanel(extension, seen, "admin extension");
|
|
2996
|
+
continue;
|
|
2765
2997
|
}
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
seen.add(panel.id);
|
|
2769
|
-
if (panel.title.trim() === "")
|
|
2770
|
-
throw new RangeError(`admin panel ${panel.id} needs a title`);
|
|
2998
|
+
const id = extension.id ?? "sql";
|
|
2999
|
+
checkPanel({ id, title: extension.title ?? "SQL" }, seen, "admin extension");
|
|
2771
3000
|
}
|
|
2772
3001
|
};
|
|
2773
3002
|
|
|
@@ -3001,6 +3230,12 @@ var renderAdminDocument = (service) => {
|
|
|
3001
3230
|
border-radius: 999px; padding: 4px 8px;
|
|
3002
3231
|
}
|
|
3003
3232
|
.chip i { color: var(--faint); font-style: normal; }
|
|
3233
|
+
.sql-layout {
|
|
3234
|
+
display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 16px;
|
|
3235
|
+
}
|
|
3236
|
+
.sql-tables { display: flex; flex-direction: column; gap: 4px; max-height: 28rem; overflow: auto; }
|
|
3237
|
+
.sql-tables button { text-align: left; }
|
|
3238
|
+
.sql-input { font-family: var(--mono); min-height: 7rem; width: 100%; }
|
|
3004
3239
|
table { width: 100%; border-collapse: collapse; font-size: 14px; }
|
|
3005
3240
|
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
|
|
3006
3241
|
th { color: var(--faint); font-weight: 600; font-size: 12px; }
|
|
@@ -3064,7 +3299,7 @@ var renderAdminDocument = (service) => {
|
|
|
3064
3299
|
padding: 8px;
|
|
3065
3300
|
}
|
|
3066
3301
|
nav.side button { white-space: nowrap; flex: none; }
|
|
3067
|
-
.split { grid-template-columns: minmax(0, 1fr); }
|
|
3302
|
+
.split, .sql-layout { grid-template-columns: minmax(0, 1fr); }
|
|
3068
3303
|
main { padding: 14px; }
|
|
3069
3304
|
table, thead, tbody, tr, th, td { display: block; }
|
|
3070
3305
|
thead { display: none; }
|
|
@@ -3235,6 +3470,24 @@ var json3 = (body) => new Response(JSON.stringify(body), {
|
|
|
3235
3470
|
status: 200,
|
|
3236
3471
|
headers: { "content-type": "application/json; charset=utf-8" }
|
|
3237
3472
|
});
|
|
3473
|
+
var describeExtension = (extension) => {
|
|
3474
|
+
if (extension.kind === "sql") {
|
|
3475
|
+
return {
|
|
3476
|
+
kind: "sql",
|
|
3477
|
+
id: extension.id ?? "sql",
|
|
3478
|
+
title: extension.title ?? "SQL",
|
|
3479
|
+
...extension.description !== void 0 ? { description: extension.description } : {}
|
|
3480
|
+
};
|
|
3481
|
+
}
|
|
3482
|
+
return {
|
|
3483
|
+
kind: "panel",
|
|
3484
|
+
id: extension.id,
|
|
3485
|
+
title: extension.title,
|
|
3486
|
+
...extension.description !== void 0 ? { description: extension.description } : {},
|
|
3487
|
+
html: extension.html,
|
|
3488
|
+
...extension.script !== void 0 ? { script: extension.script } : {}
|
|
3489
|
+
};
|
|
3490
|
+
};
|
|
3238
3491
|
var adminUiRoutes = (service, ui) => {
|
|
3239
3492
|
const shell = () => renderAdminDocument(service);
|
|
3240
3493
|
const document3 = () => ui?.render ? ui.render({ service, defaultHtml: shell }) : shell();
|
|
@@ -3249,7 +3502,8 @@ var adminUiRoutes = (service, ui) => {
|
|
|
3249
3502
|
...panel.description !== void 0 ? { description: panel.description } : {},
|
|
3250
3503
|
html: panel.html,
|
|
3251
3504
|
...panel.script !== void 0 ? { script: panel.script } : {}
|
|
3252
|
-
}))
|
|
3505
|
+
})),
|
|
3506
|
+
extensions: (ui?.extensions ?? []).map(describeExtension)
|
|
3253
3507
|
})
|
|
3254
3508
|
};
|
|
3255
3509
|
};
|
|
@@ -3926,7 +4180,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
3926
4180
|
};
|
|
3927
4181
|
|
|
3928
4182
|
// ../core/dist/version.js
|
|
3929
|
-
var PACKAGE_VERSION = true ? "1.
|
|
4183
|
+
var PACKAGE_VERSION = true ? "1.8.1" : UNRELEASED_VERSION;
|
|
3930
4184
|
|
|
3931
4185
|
// ../core/dist/signing.js
|
|
3932
4186
|
var encoder = new TextEncoder();
|
|
@@ -6304,4 +6558,4 @@ export {
|
|
|
6304
6558
|
IntercomError,
|
|
6305
6559
|
IntercomAPI
|
|
6306
6560
|
};
|
|
6307
|
-
//# sourceMappingURL=chunk-
|
|
6561
|
+
//# sourceMappingURL=chunk-TWQJOOK7.js.map
|