@crvouga/mockingbird-service-easypost 1.6.1 → 1.7.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-easypost
2
2
 
3
+ ## 1.7.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.7.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.6.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());
@@ -1917,6 +1917,167 @@ function faultPresetList(value) {
1917
1917
  })
1918
1918
  };
1919
1919
  }
1920
+ function mountSqlExplorer(root, api) {
1921
+ const cell = (value) => {
1922
+ if (value === null || value === void 0)
1923
+ return "";
1924
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1925
+ return String(value);
1926
+ }
1927
+ return JSON.stringify(value) ?? "";
1928
+ };
1929
+ root.replaceChildren();
1930
+ const layout = document.createElement("div");
1931
+ layout.className = "sql-layout";
1932
+ const tables = document.createElement("div");
1933
+ tables.className = "sql-tables";
1934
+ const stack = document.createElement("div");
1935
+ stack.className = "stack";
1936
+ const banner = document.createElement("p");
1937
+ banner.className = "banner";
1938
+ const grid = document.createElement("div");
1939
+ const input = document.createElement("textarea");
1940
+ input.className = "sql-input";
1941
+ input.spellcheck = false;
1942
+ input.placeholder = "SELECT * FROM ...";
1943
+ const actions = document.createElement("div");
1944
+ actions.className = "row-actions";
1945
+ const run = document.createElement("button");
1946
+ run.type = "button";
1947
+ run.textContent = "Run";
1948
+ actions.append(run);
1949
+ const result = document.createElement("pre");
1950
+ stack.append(banner, grid, input, actions, result);
1951
+ layout.append(tables, stack);
1952
+ root.append(layout);
1953
+ const showError = (error) => {
1954
+ banner.textContent = error instanceof Error ? error.message : String(error);
1955
+ banner.classList.add("show");
1956
+ };
1957
+ const clearError = () => {
1958
+ banner.textContent = "";
1959
+ banner.classList.remove("show");
1960
+ };
1961
+ const renderGrid = (columns, rows) => {
1962
+ grid.replaceChildren();
1963
+ if (columns.length === 0) {
1964
+ const empty = document.createElement("p");
1965
+ empty.className = "empty";
1966
+ empty.textContent = "No rows.";
1967
+ grid.append(empty);
1968
+ return;
1969
+ }
1970
+ const table = document.createElement("table");
1971
+ const head = document.createElement("thead");
1972
+ const headRow = document.createElement("tr");
1973
+ for (const column of columns) {
1974
+ const th = document.createElement("th");
1975
+ th.textContent = column;
1976
+ headRow.append(th);
1977
+ }
1978
+ head.append(headRow);
1979
+ const body = document.createElement("tbody");
1980
+ for (const row of rows) {
1981
+ const tr = document.createElement("tr");
1982
+ for (const column of columns) {
1983
+ const td = document.createElement("td");
1984
+ td.dataset.label = column;
1985
+ td.textContent = cell(row[column]);
1986
+ tr.append(td);
1987
+ }
1988
+ body.append(tr);
1989
+ }
1990
+ table.append(head, body);
1991
+ grid.append(table);
1992
+ };
1993
+ const rowsOf = (value) => {
1994
+ if (!isRecord2(value) || !Array.isArray(value.rows))
1995
+ return [];
1996
+ return value.rows.flatMap((row) => isRecord2(row) ? [row] : []);
1997
+ };
1998
+ const columnsOf = (value, rows) => {
1999
+ if (isRecord2(value) && Array.isArray(value.columns)) {
2000
+ const named = value.columns.flatMap((column) => typeof column === "string" ? [column] : []);
2001
+ if (named.length > 0)
2002
+ return named;
2003
+ }
2004
+ const first = rows[0];
2005
+ return first === void 0 ? [] : Object.keys(first);
2006
+ };
2007
+ let selected = "";
2008
+ const loadPage = async (schema, name) => {
2009
+ selected = `${schema}.${name}`;
2010
+ const page = await api.get(`/sql/tables/${encodeURIComponent(schema)}/${encodeURIComponent(name)}?limit=50`);
2011
+ const rows = rowsOf(page);
2012
+ renderGrid(columnsOf(page, rows), rows);
2013
+ const total = isRecord2(page) && typeof page.total === "number" ? page.total : rows.length;
2014
+ result.textContent = `${selected} \xB7 ${total} rows`;
2015
+ for (const button of tables.querySelectorAll("button")) {
2016
+ if (!(button instanceof HTMLButtonElement))
2017
+ continue;
2018
+ button.setAttribute("aria-current", button.dataset.schema === schema && button.dataset.table === name ? "true" : "false");
2019
+ }
2020
+ };
2021
+ const loadTables = async () => {
2022
+ const payload = await api.get("/sql/tables");
2023
+ const listed = isRecord2(payload) && Array.isArray(payload.tables) ? payload.tables : [];
2024
+ tables.replaceChildren();
2025
+ if (listed.length === 0) {
2026
+ const empty = document.createElement("p");
2027
+ empty.className = "empty";
2028
+ empty.textContent = "No tables.";
2029
+ tables.append(empty);
2030
+ return;
2031
+ }
2032
+ for (const item of listed) {
2033
+ if (!isRecord2(item) || typeof item.schema !== "string" || typeof item.name !== "string")
2034
+ continue;
2035
+ const button = document.createElement("button");
2036
+ button.type = "button";
2037
+ button.dataset.schema = item.schema;
2038
+ button.dataset.table = item.name;
2039
+ button.textContent = `${item.schema}.${item.name}`;
2040
+ tables.append(button);
2041
+ }
2042
+ };
2043
+ tables.addEventListener("click", (event) => {
2044
+ const target = event.target;
2045
+ if (!(target instanceof Element))
2046
+ return;
2047
+ const button = target.closest("button");
2048
+ if (!(button instanceof HTMLButtonElement))
2049
+ return;
2050
+ const schema = button.dataset.schema;
2051
+ const name = button.dataset.table;
2052
+ if (schema === void 0 || name === void 0)
2053
+ return;
2054
+ clearError();
2055
+ loadPage(schema, name).catch(showError);
2056
+ });
2057
+ run.addEventListener("click", () => {
2058
+ const sql = input.value.trim();
2059
+ if (sql === "") {
2060
+ showError(new Error("Enter a statement"));
2061
+ return;
2062
+ }
2063
+ clearError();
2064
+ api.send("POST", "/sql/query", { sql }).then((payload) => {
2065
+ const rows = rowsOf(payload);
2066
+ renderGrid(columnsOf(payload, rows), rows);
2067
+ const count = isRecord2(payload) && typeof payload.rowCount === "number" ? payload.rowCount : rows.length;
2068
+ const truncated = isRecord2(payload) && payload.truncated === true ? " (truncated)" : "";
2069
+ result.textContent = `${count} rows${truncated}`;
2070
+ }).catch(showError);
2071
+ });
2072
+ const namespace = document.getElementById("namespace");
2073
+ if (namespace) {
2074
+ namespace.addEventListener("change", () => {
2075
+ clearError();
2076
+ loadTables().catch(showError);
2077
+ });
2078
+ }
2079
+ loadTables().catch(showError);
2080
+ }
1920
2081
  function bootAdmin(config) {
1921
2082
  const fieldKinds = ["string", "number", "boolean", "null", "object", "array", "unknown"];
1922
2083
  const sources = ["declared", "inferred", "mixed"];
@@ -2593,6 +2754,22 @@ function bootAdmin(config) {
2593
2754
  panel.script = value.script;
2594
2755
  return panel;
2595
2756
  };
2757
+ const decodeExtension = (value) => {
2758
+ if (!isRecord2(value))
2759
+ return void 0;
2760
+ if (value.kind === "sql") {
2761
+ return {
2762
+ kind: "sql",
2763
+ id: typeof value.id === "string" && value.id !== "" ? value.id : "sql",
2764
+ title: typeof value.title === "string" && value.title !== "" ? value.title : "SQL",
2765
+ description: typeof value.description === "string" ? value.description : "Browse tables and run queries."
2766
+ };
2767
+ }
2768
+ if (value.kind !== "panel")
2769
+ return void 0;
2770
+ const panel = decodePanel(value);
2771
+ return panel === void 0 ? void 0 : { kind: "panel", ...panel };
2772
+ };
2596
2773
  const mountPanels = (panels) => {
2597
2774
  const nav = el("nav", HTMLElement);
2598
2775
  const views = el("views", HTMLElement);
@@ -2646,10 +2823,48 @@ function bootAdmin(config) {
2646
2823
  return decoded === void 0 ? [] : [decoded];
2647
2824
  });
2648
2825
  mountPanels(panels);
2826
+ const extensions = requireList(isRecord2(manifest) ? manifest.extensions : void 0, "Extensions").flatMap((extension) => {
2827
+ const decoded = decodeExtension(extension);
2828
+ return decoded === void 0 ? [] : [decoded];
2829
+ });
2830
+ const extensionPanels = extensions.flatMap((extension) => extension.kind === "panel" ? [extension] : []);
2831
+ mountPanels(extensionPanels);
2832
+ for (const extension of extensions) {
2833
+ if (extension.kind !== "sql")
2834
+ continue;
2835
+ const nav = el("nav", HTMLElement);
2836
+ const views = el("views", HTMLElement);
2837
+ const button = document.createElement("button");
2838
+ button.type = "button";
2839
+ button.dataset.view = extension.id;
2840
+ button.textContent = extension.title;
2841
+ nav.append(button);
2842
+ const section = document.createElement("section");
2843
+ section.className = "view";
2844
+ section.id = `view-${extension.id}`;
2845
+ section.hidden = true;
2846
+ const title = document.createElement("h2");
2847
+ title.textContent = extension.title;
2848
+ const lede = document.createElement("p");
2849
+ lede.className = "lede";
2850
+ lede.textContent = extension.description;
2851
+ const body = document.createElement("div");
2852
+ body.className = "panel-body";
2853
+ section.append(title, lede, body);
2854
+ views.append(section);
2855
+ mountSqlExplorer(body, panelApi);
2856
+ }
2649
2857
  return refresh();
2650
2858
  }).catch(showError);
2651
2859
  }
2652
- var clientPrelude = [isRecord2, mountAdminBrand, startAdminBrand, faultPresetList, bootAdmin].map((fn) => fn.toString()).join("\n");
2860
+ var clientPrelude = [
2861
+ isRecord2,
2862
+ mountAdminBrand,
2863
+ startAdminBrand,
2864
+ faultPresetList,
2865
+ mountSqlExplorer,
2866
+ bootAdmin
2867
+ ].map((fn) => fn.toString()).join("\n");
2653
2868
  var adminClientSource = (config) => {
2654
2869
  const payload = JSON.stringify(config).replace(/</g, "\\u003c");
2655
2870
  const entry = bootAdmin.name;
@@ -2699,19 +2914,33 @@ var STANDARD_ADMIN_ROUTES = [
2699
2914
  "GET /ui/manifest"
2700
2915
  ];
2701
2916
  var PANEL_ID = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
2917
+ var RESERVED_VIEWS = /* @__PURE__ */ new Set(["overview", "state", "clock", "faults", "journal", "routes"]);
2918
+ var checkPanel = (panel, seen, label) => {
2919
+ if (!PANEL_ID.test(panel.id)) {
2920
+ throw new RangeError(`${label} id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
2921
+ }
2922
+ if (RESERVED_VIEWS.has(panel.id)) {
2923
+ throw new RangeError(`${label} id ${panel.id} is reserved by the admin shell`);
2924
+ }
2925
+ if (seen.has(panel.id))
2926
+ throw new RangeError(`duplicate admin view id ${panel.id}`);
2927
+ seen.add(panel.id);
2928
+ if (panel.title.trim() === "")
2929
+ throw new RangeError(`${label} ${panel.id} needs a title`);
2930
+ };
2702
2931
  var assertAdminUi = (ui) => {
2703
- if (!ui?.panels)
2932
+ if (!ui)
2704
2933
  return;
2705
2934
  const seen = /* @__PURE__ */ new Set();
2706
- for (const panel of ui.panels) {
2707
- if (!PANEL_ID.test(panel.id)) {
2708
- throw new RangeError(`admin panel id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
2935
+ for (const panel of ui.panels ?? [])
2936
+ checkPanel(panel, seen, "admin panel");
2937
+ for (const extension of ui.extensions ?? []) {
2938
+ if (extension.kind === "panel") {
2939
+ checkPanel(extension, seen, "admin extension");
2940
+ continue;
2709
2941
  }
2710
- if (seen.has(panel.id))
2711
- throw new RangeError(`duplicate admin panel id ${panel.id}`);
2712
- seen.add(panel.id);
2713
- if (panel.title.trim() === "")
2714
- throw new RangeError(`admin panel ${panel.id} needs a title`);
2942
+ const id = extension.id ?? "sql";
2943
+ checkPanel({ id, title: extension.title ?? "SQL" }, seen, "admin extension");
2715
2944
  }
2716
2945
  };
2717
2946
 
@@ -2945,6 +3174,12 @@ var renderAdminDocument = (service) => {
2945
3174
  border-radius: 999px; padding: 4px 8px;
2946
3175
  }
2947
3176
  .chip i { color: var(--faint); font-style: normal; }
3177
+ .sql-layout {
3178
+ display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 16px;
3179
+ }
3180
+ .sql-tables { display: flex; flex-direction: column; gap: 4px; max-height: 28rem; overflow: auto; }
3181
+ .sql-tables button { text-align: left; }
3182
+ .sql-input { font-family: var(--mono); min-height: 7rem; width: 100%; }
2948
3183
  table { width: 100%; border-collapse: collapse; font-size: 14px; }
2949
3184
  th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
2950
3185
  th { color: var(--faint); font-weight: 600; font-size: 12px; }
@@ -3008,7 +3243,7 @@ var renderAdminDocument = (service) => {
3008
3243
  padding: 8px;
3009
3244
  }
3010
3245
  nav.side button { white-space: nowrap; flex: none; }
3011
- .split { grid-template-columns: minmax(0, 1fr); }
3246
+ .split, .sql-layout { grid-template-columns: minmax(0, 1fr); }
3012
3247
  main { padding: 14px; }
3013
3248
  table, thead, tbody, tr, th, td { display: block; }
3014
3249
  thead { display: none; }
@@ -3179,6 +3414,24 @@ var json2 = (body) => new Response(JSON.stringify(body), {
3179
3414
  status: 200,
3180
3415
  headers: { "content-type": "application/json; charset=utf-8" }
3181
3416
  });
3417
+ var describeExtension = (extension) => {
3418
+ if (extension.kind === "sql") {
3419
+ return {
3420
+ kind: "sql",
3421
+ id: extension.id ?? "sql",
3422
+ title: extension.title ?? "SQL",
3423
+ ...extension.description !== void 0 ? { description: extension.description } : {}
3424
+ };
3425
+ }
3426
+ return {
3427
+ kind: "panel",
3428
+ id: extension.id,
3429
+ title: extension.title,
3430
+ ...extension.description !== void 0 ? { description: extension.description } : {},
3431
+ html: extension.html,
3432
+ ...extension.script !== void 0 ? { script: extension.script } : {}
3433
+ };
3434
+ };
3182
3435
  var adminUiRoutes = (service, ui) => {
3183
3436
  const shell = () => renderAdminDocument(service);
3184
3437
  const document3 = () => ui?.render ? ui.render({ service, defaultHtml: shell }) : shell();
@@ -3193,7 +3446,8 @@ var adminUiRoutes = (service, ui) => {
3193
3446
  ...panel.description !== void 0 ? { description: panel.description } : {},
3194
3447
  html: panel.html,
3195
3448
  ...panel.script !== void 0 ? { script: panel.script } : {}
3196
- }))
3449
+ })),
3450
+ extensions: (ui?.extensions ?? []).map(describeExtension)
3197
3451
  })
3198
3452
  };
3199
3453
  };
@@ -3870,7 +4124,7 @@ var stateAdminRoutes = (routes) => {
3870
4124
  };
3871
4125
 
3872
4126
  // ../core/dist/version.js
3873
- var PACKAGE_VERSION = true ? "1.6.1" : UNRELEASED_VERSION;
4127
+ var PACKAGE_VERSION = true ? "1.7.1" : UNRELEASED_VERSION;
3874
4128
 
3875
4129
  // ../core/dist/webhooks.js
3876
4130
  var json4 = (status, body) => new Response(JSON.stringify(body), { status, headers: { "content-type": "application/json" } });
@@ -4975,4 +5229,4 @@ export {
4975
5229
  isTrackerStatus,
4976
5230
  EasyPostAPI
4977
5231
  };
4978
- //# sourceMappingURL=chunk-3QIW75OT.js.map
5232
+ //# sourceMappingURL=chunk-3TOBBMZD.js.map