@crvouga/mockingbird-service-formbricks 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-6PARZPBY.js → chunk-D6GS7TTF.js} +2 -2
- package/dist/{chunk-JAVNDNOU.js → chunk-PISQJCVW.js} +268 -14
- package/dist/chunk-PISQJCVW.js.map +7 -0
- 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-JAVNDNOU.js.map +0 -7
- /package/dist/{chunk-6PARZPBY.js.map → chunk-D6GS7TTF.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-formbricks
|
|
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,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_SETTINGS,
|
|
3
3
|
createRuntime
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PISQJCVW.js";
|
|
5
5
|
|
|
6
6
|
// ../../adapters/node/dist/cli.js
|
|
7
7
|
import { readFile } from "node:fs/promises";
|
|
@@ -368,4 +368,4 @@ export {
|
|
|
368
368
|
createServer2 as createServer,
|
|
369
369
|
serveTarget
|
|
370
370
|
};
|
|
371
|
-
//# sourceMappingURL=chunk-
|
|
371
|
+
//# sourceMappingURL=chunk-D6GS7TTF.js.map
|
|
@@ -1667,6 +1667,167 @@ function faultPresetList(value) {
|
|
|
1667
1667
|
})
|
|
1668
1668
|
};
|
|
1669
1669
|
}
|
|
1670
|
+
function mountSqlExplorer(root, api) {
|
|
1671
|
+
const cell = (value) => {
|
|
1672
|
+
if (value === null || value === void 0)
|
|
1673
|
+
return "";
|
|
1674
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
1675
|
+
return String(value);
|
|
1676
|
+
}
|
|
1677
|
+
return JSON.stringify(value) ?? "";
|
|
1678
|
+
};
|
|
1679
|
+
root.replaceChildren();
|
|
1680
|
+
const layout = document.createElement("div");
|
|
1681
|
+
layout.className = "sql-layout";
|
|
1682
|
+
const tables = document.createElement("div");
|
|
1683
|
+
tables.className = "sql-tables";
|
|
1684
|
+
const stack = document.createElement("div");
|
|
1685
|
+
stack.className = "stack";
|
|
1686
|
+
const banner = document.createElement("p");
|
|
1687
|
+
banner.className = "banner";
|
|
1688
|
+
const grid = document.createElement("div");
|
|
1689
|
+
const input = document.createElement("textarea");
|
|
1690
|
+
input.className = "sql-input";
|
|
1691
|
+
input.spellcheck = false;
|
|
1692
|
+
input.placeholder = "SELECT * FROM ...";
|
|
1693
|
+
const actions = document.createElement("div");
|
|
1694
|
+
actions.className = "row-actions";
|
|
1695
|
+
const run = document.createElement("button");
|
|
1696
|
+
run.type = "button";
|
|
1697
|
+
run.textContent = "Run";
|
|
1698
|
+
actions.append(run);
|
|
1699
|
+
const result = document.createElement("pre");
|
|
1700
|
+
stack.append(banner, grid, input, actions, result);
|
|
1701
|
+
layout.append(tables, stack);
|
|
1702
|
+
root.append(layout);
|
|
1703
|
+
const showError = (error2) => {
|
|
1704
|
+
banner.textContent = error2 instanceof Error ? error2.message : String(error2);
|
|
1705
|
+
banner.classList.add("show");
|
|
1706
|
+
};
|
|
1707
|
+
const clearError = () => {
|
|
1708
|
+
banner.textContent = "";
|
|
1709
|
+
banner.classList.remove("show");
|
|
1710
|
+
};
|
|
1711
|
+
const renderGrid = (columns, rows) => {
|
|
1712
|
+
grid.replaceChildren();
|
|
1713
|
+
if (columns.length === 0) {
|
|
1714
|
+
const empty = document.createElement("p");
|
|
1715
|
+
empty.className = "empty";
|
|
1716
|
+
empty.textContent = "No rows.";
|
|
1717
|
+
grid.append(empty);
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1720
|
+
const table = document.createElement("table");
|
|
1721
|
+
const head = document.createElement("thead");
|
|
1722
|
+
const headRow = document.createElement("tr");
|
|
1723
|
+
for (const column of columns) {
|
|
1724
|
+
const th = document.createElement("th");
|
|
1725
|
+
th.textContent = column;
|
|
1726
|
+
headRow.append(th);
|
|
1727
|
+
}
|
|
1728
|
+
head.append(headRow);
|
|
1729
|
+
const body = document.createElement("tbody");
|
|
1730
|
+
for (const row of rows) {
|
|
1731
|
+
const tr = document.createElement("tr");
|
|
1732
|
+
for (const column of columns) {
|
|
1733
|
+
const td = document.createElement("td");
|
|
1734
|
+
td.dataset.label = column;
|
|
1735
|
+
td.textContent = cell(row[column]);
|
|
1736
|
+
tr.append(td);
|
|
1737
|
+
}
|
|
1738
|
+
body.append(tr);
|
|
1739
|
+
}
|
|
1740
|
+
table.append(head, body);
|
|
1741
|
+
grid.append(table);
|
|
1742
|
+
};
|
|
1743
|
+
const rowsOf = (value) => {
|
|
1744
|
+
if (!isRecord2(value) || !Array.isArray(value.rows))
|
|
1745
|
+
return [];
|
|
1746
|
+
return value.rows.flatMap((row) => isRecord2(row) ? [row] : []);
|
|
1747
|
+
};
|
|
1748
|
+
const columnsOf = (value, rows) => {
|
|
1749
|
+
if (isRecord2(value) && Array.isArray(value.columns)) {
|
|
1750
|
+
const named = value.columns.flatMap((column) => typeof column === "string" ? [column] : []);
|
|
1751
|
+
if (named.length > 0)
|
|
1752
|
+
return named;
|
|
1753
|
+
}
|
|
1754
|
+
const first = rows[0];
|
|
1755
|
+
return first === void 0 ? [] : Object.keys(first);
|
|
1756
|
+
};
|
|
1757
|
+
let selected = "";
|
|
1758
|
+
const loadPage = async (schema, name) => {
|
|
1759
|
+
selected = `${schema}.${name}`;
|
|
1760
|
+
const page = await api.get(`/sql/tables/${encodeURIComponent(schema)}/${encodeURIComponent(name)}?limit=50`);
|
|
1761
|
+
const rows = rowsOf(page);
|
|
1762
|
+
renderGrid(columnsOf(page, rows), rows);
|
|
1763
|
+
const total = isRecord2(page) && typeof page.total === "number" ? page.total : rows.length;
|
|
1764
|
+
result.textContent = `${selected} \xB7 ${total} rows`;
|
|
1765
|
+
for (const button of tables.querySelectorAll("button")) {
|
|
1766
|
+
if (!(button instanceof HTMLButtonElement))
|
|
1767
|
+
continue;
|
|
1768
|
+
button.setAttribute("aria-current", button.dataset.schema === schema && button.dataset.table === name ? "true" : "false");
|
|
1769
|
+
}
|
|
1770
|
+
};
|
|
1771
|
+
const loadTables = async () => {
|
|
1772
|
+
const payload = await api.get("/sql/tables");
|
|
1773
|
+
const listed = isRecord2(payload) && Array.isArray(payload.tables) ? payload.tables : [];
|
|
1774
|
+
tables.replaceChildren();
|
|
1775
|
+
if (listed.length === 0) {
|
|
1776
|
+
const empty = document.createElement("p");
|
|
1777
|
+
empty.className = "empty";
|
|
1778
|
+
empty.textContent = "No tables.";
|
|
1779
|
+
tables.append(empty);
|
|
1780
|
+
return;
|
|
1781
|
+
}
|
|
1782
|
+
for (const item of listed) {
|
|
1783
|
+
if (!isRecord2(item) || typeof item.schema !== "string" || typeof item.name !== "string")
|
|
1784
|
+
continue;
|
|
1785
|
+
const button = document.createElement("button");
|
|
1786
|
+
button.type = "button";
|
|
1787
|
+
button.dataset.schema = item.schema;
|
|
1788
|
+
button.dataset.table = item.name;
|
|
1789
|
+
button.textContent = `${item.schema}.${item.name}`;
|
|
1790
|
+
tables.append(button);
|
|
1791
|
+
}
|
|
1792
|
+
};
|
|
1793
|
+
tables.addEventListener("click", (event) => {
|
|
1794
|
+
const target = event.target;
|
|
1795
|
+
if (!(target instanceof Element))
|
|
1796
|
+
return;
|
|
1797
|
+
const button = target.closest("button");
|
|
1798
|
+
if (!(button instanceof HTMLButtonElement))
|
|
1799
|
+
return;
|
|
1800
|
+
const schema = button.dataset.schema;
|
|
1801
|
+
const name = button.dataset.table;
|
|
1802
|
+
if (schema === void 0 || name === void 0)
|
|
1803
|
+
return;
|
|
1804
|
+
clearError();
|
|
1805
|
+
loadPage(schema, name).catch(showError);
|
|
1806
|
+
});
|
|
1807
|
+
run.addEventListener("click", () => {
|
|
1808
|
+
const sql = input.value.trim();
|
|
1809
|
+
if (sql === "") {
|
|
1810
|
+
showError(new Error("Enter a statement"));
|
|
1811
|
+
return;
|
|
1812
|
+
}
|
|
1813
|
+
clearError();
|
|
1814
|
+
api.send("POST", "/sql/query", { sql }).then((payload) => {
|
|
1815
|
+
const rows = rowsOf(payload);
|
|
1816
|
+
renderGrid(columnsOf(payload, rows), rows);
|
|
1817
|
+
const count = isRecord2(payload) && typeof payload.rowCount === "number" ? payload.rowCount : rows.length;
|
|
1818
|
+
const truncated = isRecord2(payload) && payload.truncated === true ? " (truncated)" : "";
|
|
1819
|
+
result.textContent = `${count} rows${truncated}`;
|
|
1820
|
+
}).catch(showError);
|
|
1821
|
+
});
|
|
1822
|
+
const namespace = document.getElementById("namespace");
|
|
1823
|
+
if (namespace) {
|
|
1824
|
+
namespace.addEventListener("change", () => {
|
|
1825
|
+
clearError();
|
|
1826
|
+
loadTables().catch(showError);
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
loadTables().catch(showError);
|
|
1830
|
+
}
|
|
1670
1831
|
function bootAdmin(config) {
|
|
1671
1832
|
const fieldKinds = ["string", "number", "boolean", "null", "object", "array", "unknown"];
|
|
1672
1833
|
const sources = ["declared", "inferred", "mixed"];
|
|
@@ -2343,6 +2504,22 @@ function bootAdmin(config) {
|
|
|
2343
2504
|
panel.script = value.script;
|
|
2344
2505
|
return panel;
|
|
2345
2506
|
};
|
|
2507
|
+
const decodeExtension = (value) => {
|
|
2508
|
+
if (!isRecord2(value))
|
|
2509
|
+
return void 0;
|
|
2510
|
+
if (value.kind === "sql") {
|
|
2511
|
+
return {
|
|
2512
|
+
kind: "sql",
|
|
2513
|
+
id: typeof value.id === "string" && value.id !== "" ? value.id : "sql",
|
|
2514
|
+
title: typeof value.title === "string" && value.title !== "" ? value.title : "SQL",
|
|
2515
|
+
description: typeof value.description === "string" ? value.description : "Browse tables and run queries."
|
|
2516
|
+
};
|
|
2517
|
+
}
|
|
2518
|
+
if (value.kind !== "panel")
|
|
2519
|
+
return void 0;
|
|
2520
|
+
const panel = decodePanel(value);
|
|
2521
|
+
return panel === void 0 ? void 0 : { kind: "panel", ...panel };
|
|
2522
|
+
};
|
|
2346
2523
|
const mountPanels = (panels) => {
|
|
2347
2524
|
const nav = el("nav", HTMLElement);
|
|
2348
2525
|
const views = el("views", HTMLElement);
|
|
@@ -2396,10 +2573,48 @@ function bootAdmin(config) {
|
|
|
2396
2573
|
return decoded === void 0 ? [] : [decoded];
|
|
2397
2574
|
});
|
|
2398
2575
|
mountPanels(panels);
|
|
2576
|
+
const extensions = requireList(isRecord2(manifest) ? manifest.extensions : void 0, "Extensions").flatMap((extension) => {
|
|
2577
|
+
const decoded = decodeExtension(extension);
|
|
2578
|
+
return decoded === void 0 ? [] : [decoded];
|
|
2579
|
+
});
|
|
2580
|
+
const extensionPanels = extensions.flatMap((extension) => extension.kind === "panel" ? [extension] : []);
|
|
2581
|
+
mountPanels(extensionPanels);
|
|
2582
|
+
for (const extension of extensions) {
|
|
2583
|
+
if (extension.kind !== "sql")
|
|
2584
|
+
continue;
|
|
2585
|
+
const nav = el("nav", HTMLElement);
|
|
2586
|
+
const views = el("views", HTMLElement);
|
|
2587
|
+
const button = document.createElement("button");
|
|
2588
|
+
button.type = "button";
|
|
2589
|
+
button.dataset.view = extension.id;
|
|
2590
|
+
button.textContent = extension.title;
|
|
2591
|
+
nav.append(button);
|
|
2592
|
+
const section = document.createElement("section");
|
|
2593
|
+
section.className = "view";
|
|
2594
|
+
section.id = `view-${extension.id}`;
|
|
2595
|
+
section.hidden = true;
|
|
2596
|
+
const title = document.createElement("h2");
|
|
2597
|
+
title.textContent = extension.title;
|
|
2598
|
+
const lede = document.createElement("p");
|
|
2599
|
+
lede.className = "lede";
|
|
2600
|
+
lede.textContent = extension.description;
|
|
2601
|
+
const body = document.createElement("div");
|
|
2602
|
+
body.className = "panel-body";
|
|
2603
|
+
section.append(title, lede, body);
|
|
2604
|
+
views.append(section);
|
|
2605
|
+
mountSqlExplorer(body, panelApi);
|
|
2606
|
+
}
|
|
2399
2607
|
return refresh();
|
|
2400
2608
|
}).catch(showError);
|
|
2401
2609
|
}
|
|
2402
|
-
var clientPrelude = [
|
|
2610
|
+
var clientPrelude = [
|
|
2611
|
+
isRecord2,
|
|
2612
|
+
mountAdminBrand,
|
|
2613
|
+
startAdminBrand,
|
|
2614
|
+
faultPresetList,
|
|
2615
|
+
mountSqlExplorer,
|
|
2616
|
+
bootAdmin
|
|
2617
|
+
].map((fn) => fn.toString()).join("\n");
|
|
2403
2618
|
var adminClientSource = (config) => {
|
|
2404
2619
|
const payload = JSON.stringify(config).replace(/</g, "\\u003c");
|
|
2405
2620
|
const entry = bootAdmin.name;
|
|
@@ -2449,19 +2664,33 @@ var STANDARD_ADMIN_ROUTES = [
|
|
|
2449
2664
|
"GET /ui/manifest"
|
|
2450
2665
|
];
|
|
2451
2666
|
var PANEL_ID = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
|
|
2667
|
+
var RESERVED_VIEWS = /* @__PURE__ */ new Set(["overview", "state", "clock", "faults", "journal", "routes"]);
|
|
2668
|
+
var checkPanel = (panel, seen, label) => {
|
|
2669
|
+
if (!PANEL_ID.test(panel.id)) {
|
|
2670
|
+
throw new RangeError(`${label} id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
|
|
2671
|
+
}
|
|
2672
|
+
if (RESERVED_VIEWS.has(panel.id)) {
|
|
2673
|
+
throw new RangeError(`${label} id ${panel.id} is reserved by the admin shell`);
|
|
2674
|
+
}
|
|
2675
|
+
if (seen.has(panel.id))
|
|
2676
|
+
throw new RangeError(`duplicate admin view id ${panel.id}`);
|
|
2677
|
+
seen.add(panel.id);
|
|
2678
|
+
if (panel.title.trim() === "")
|
|
2679
|
+
throw new RangeError(`${label} ${panel.id} needs a title`);
|
|
2680
|
+
};
|
|
2452
2681
|
var assertAdminUi = (ui) => {
|
|
2453
|
-
if (!ui
|
|
2682
|
+
if (!ui)
|
|
2454
2683
|
return;
|
|
2455
2684
|
const seen = /* @__PURE__ */ new Set();
|
|
2456
|
-
for (const panel of ui.panels)
|
|
2457
|
-
|
|
2458
|
-
|
|
2685
|
+
for (const panel of ui.panels ?? [])
|
|
2686
|
+
checkPanel(panel, seen, "admin panel");
|
|
2687
|
+
for (const extension of ui.extensions ?? []) {
|
|
2688
|
+
if (extension.kind === "panel") {
|
|
2689
|
+
checkPanel(extension, seen, "admin extension");
|
|
2690
|
+
continue;
|
|
2459
2691
|
}
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
seen.add(panel.id);
|
|
2463
|
-
if (panel.title.trim() === "")
|
|
2464
|
-
throw new RangeError(`admin panel ${panel.id} needs a title`);
|
|
2692
|
+
const id = extension.id ?? "sql";
|
|
2693
|
+
checkPanel({ id, title: extension.title ?? "SQL" }, seen, "admin extension");
|
|
2465
2694
|
}
|
|
2466
2695
|
};
|
|
2467
2696
|
|
|
@@ -2695,6 +2924,12 @@ var renderAdminDocument = (service) => {
|
|
|
2695
2924
|
border-radius: 999px; padding: 4px 8px;
|
|
2696
2925
|
}
|
|
2697
2926
|
.chip i { color: var(--faint); font-style: normal; }
|
|
2927
|
+
.sql-layout {
|
|
2928
|
+
display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 16px;
|
|
2929
|
+
}
|
|
2930
|
+
.sql-tables { display: flex; flex-direction: column; gap: 4px; max-height: 28rem; overflow: auto; }
|
|
2931
|
+
.sql-tables button { text-align: left; }
|
|
2932
|
+
.sql-input { font-family: var(--mono); min-height: 7rem; width: 100%; }
|
|
2698
2933
|
table { width: 100%; border-collapse: collapse; font-size: 14px; }
|
|
2699
2934
|
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
|
|
2700
2935
|
th { color: var(--faint); font-weight: 600; font-size: 12px; }
|
|
@@ -2758,7 +2993,7 @@ var renderAdminDocument = (service) => {
|
|
|
2758
2993
|
padding: 8px;
|
|
2759
2994
|
}
|
|
2760
2995
|
nav.side button { white-space: nowrap; flex: none; }
|
|
2761
|
-
.split { grid-template-columns: minmax(0, 1fr); }
|
|
2996
|
+
.split, .sql-layout { grid-template-columns: minmax(0, 1fr); }
|
|
2762
2997
|
main { padding: 14px; }
|
|
2763
2998
|
table, thead, tbody, tr, th, td { display: block; }
|
|
2764
2999
|
thead { display: none; }
|
|
@@ -2929,6 +3164,24 @@ var json2 = (body) => new Response(JSON.stringify(body), {
|
|
|
2929
3164
|
status: 200,
|
|
2930
3165
|
headers: { "content-type": "application/json; charset=utf-8" }
|
|
2931
3166
|
});
|
|
3167
|
+
var describeExtension = (extension) => {
|
|
3168
|
+
if (extension.kind === "sql") {
|
|
3169
|
+
return {
|
|
3170
|
+
kind: "sql",
|
|
3171
|
+
id: extension.id ?? "sql",
|
|
3172
|
+
title: extension.title ?? "SQL",
|
|
3173
|
+
...extension.description !== void 0 ? { description: extension.description } : {}
|
|
3174
|
+
};
|
|
3175
|
+
}
|
|
3176
|
+
return {
|
|
3177
|
+
kind: "panel",
|
|
3178
|
+
id: extension.id,
|
|
3179
|
+
title: extension.title,
|
|
3180
|
+
...extension.description !== void 0 ? { description: extension.description } : {},
|
|
3181
|
+
html: extension.html,
|
|
3182
|
+
...extension.script !== void 0 ? { script: extension.script } : {}
|
|
3183
|
+
};
|
|
3184
|
+
};
|
|
2932
3185
|
var adminUiRoutes = (service, ui) => {
|
|
2933
3186
|
const shell = () => renderAdminDocument(service);
|
|
2934
3187
|
const document3 = () => ui?.render ? ui.render({ service, defaultHtml: shell }) : shell();
|
|
@@ -2943,7 +3196,8 @@ var adminUiRoutes = (service, ui) => {
|
|
|
2943
3196
|
...panel.description !== void 0 ? { description: panel.description } : {},
|
|
2944
3197
|
html: panel.html,
|
|
2945
3198
|
...panel.script !== void 0 ? { script: panel.script } : {}
|
|
2946
|
-
}))
|
|
3199
|
+
})),
|
|
3200
|
+
extensions: (ui?.extensions ?? []).map(describeExtension)
|
|
2947
3201
|
})
|
|
2948
3202
|
};
|
|
2949
3203
|
};
|
|
@@ -3546,7 +3800,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
3546
3800
|
};
|
|
3547
3801
|
|
|
3548
3802
|
// ../core/dist/version.js
|
|
3549
|
-
var PACKAGE_VERSION = true ? "1.
|
|
3803
|
+
var PACKAGE_VERSION = true ? "1.7.0" : UNRELEASED_VERSION;
|
|
3550
3804
|
|
|
3551
3805
|
// ../core/dist/signing.js
|
|
3552
3806
|
var encoder = new TextEncoder();
|
|
@@ -6322,4 +6576,4 @@ export {
|
|
|
6322
6576
|
formbricksError,
|
|
6323
6577
|
FormbricksAPI
|
|
6324
6578
|
};
|
|
6325
|
-
//# sourceMappingURL=chunk-
|
|
6579
|
+
//# sourceMappingURL=chunk-PISQJCVW.js.map
|