@crvouga/mockingbird-service-cognito 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-cognito
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());
@@ -1500,6 +1500,167 @@ function faultPresetList(value) {
1500
1500
  })
1501
1501
  };
1502
1502
  }
1503
+ function mountSqlExplorer(root, api) {
1504
+ const cell = (value) => {
1505
+ if (value === null || value === void 0)
1506
+ return "";
1507
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1508
+ return String(value);
1509
+ }
1510
+ return JSON.stringify(value) ?? "";
1511
+ };
1512
+ root.replaceChildren();
1513
+ const layout = document.createElement("div");
1514
+ layout.className = "sql-layout";
1515
+ const tables = document.createElement("div");
1516
+ tables.className = "sql-tables";
1517
+ const stack = document.createElement("div");
1518
+ stack.className = "stack";
1519
+ const banner = document.createElement("p");
1520
+ banner.className = "banner";
1521
+ const grid = document.createElement("div");
1522
+ const input = document.createElement("textarea");
1523
+ input.className = "sql-input";
1524
+ input.spellcheck = false;
1525
+ input.placeholder = "SELECT * FROM ...";
1526
+ const actions = document.createElement("div");
1527
+ actions.className = "row-actions";
1528
+ const run = document.createElement("button");
1529
+ run.type = "button";
1530
+ run.textContent = "Run";
1531
+ actions.append(run);
1532
+ const result = document.createElement("pre");
1533
+ stack.append(banner, grid, input, actions, result);
1534
+ layout.append(tables, stack);
1535
+ root.append(layout);
1536
+ const showError = (error) => {
1537
+ banner.textContent = error instanceof Error ? error.message : String(error);
1538
+ banner.classList.add("show");
1539
+ };
1540
+ const clearError = () => {
1541
+ banner.textContent = "";
1542
+ banner.classList.remove("show");
1543
+ };
1544
+ const renderGrid = (columns, rows) => {
1545
+ grid.replaceChildren();
1546
+ if (columns.length === 0) {
1547
+ const empty = document.createElement("p");
1548
+ empty.className = "empty";
1549
+ empty.textContent = "No rows.";
1550
+ grid.append(empty);
1551
+ return;
1552
+ }
1553
+ const table = document.createElement("table");
1554
+ const head = document.createElement("thead");
1555
+ const headRow = document.createElement("tr");
1556
+ for (const column of columns) {
1557
+ const th = document.createElement("th");
1558
+ th.textContent = column;
1559
+ headRow.append(th);
1560
+ }
1561
+ head.append(headRow);
1562
+ const body = document.createElement("tbody");
1563
+ for (const row of rows) {
1564
+ const tr = document.createElement("tr");
1565
+ for (const column of columns) {
1566
+ const td = document.createElement("td");
1567
+ td.dataset.label = column;
1568
+ td.textContent = cell(row[column]);
1569
+ tr.append(td);
1570
+ }
1571
+ body.append(tr);
1572
+ }
1573
+ table.append(head, body);
1574
+ grid.append(table);
1575
+ };
1576
+ const rowsOf = (value) => {
1577
+ if (!isRecord2(value) || !Array.isArray(value.rows))
1578
+ return [];
1579
+ return value.rows.flatMap((row) => isRecord2(row) ? [row] : []);
1580
+ };
1581
+ const columnsOf = (value, rows) => {
1582
+ if (isRecord2(value) && Array.isArray(value.columns)) {
1583
+ const named = value.columns.flatMap((column) => typeof column === "string" ? [column] : []);
1584
+ if (named.length > 0)
1585
+ return named;
1586
+ }
1587
+ const first = rows[0];
1588
+ return first === void 0 ? [] : Object.keys(first);
1589
+ };
1590
+ let selected = "";
1591
+ const loadPage = async (schema, name) => {
1592
+ selected = `${schema}.${name}`;
1593
+ const page = await api.get(`/sql/tables/${encodeURIComponent(schema)}/${encodeURIComponent(name)}?limit=50`);
1594
+ const rows = rowsOf(page);
1595
+ renderGrid(columnsOf(page, rows), rows);
1596
+ const total = isRecord2(page) && typeof page.total === "number" ? page.total : rows.length;
1597
+ result.textContent = `${selected} \xB7 ${total} rows`;
1598
+ for (const button of tables.querySelectorAll("button")) {
1599
+ if (!(button instanceof HTMLButtonElement))
1600
+ continue;
1601
+ button.setAttribute("aria-current", button.dataset.schema === schema && button.dataset.table === name ? "true" : "false");
1602
+ }
1603
+ };
1604
+ const loadTables = async () => {
1605
+ const payload = await api.get("/sql/tables");
1606
+ const listed = isRecord2(payload) && Array.isArray(payload.tables) ? payload.tables : [];
1607
+ tables.replaceChildren();
1608
+ if (listed.length === 0) {
1609
+ const empty = document.createElement("p");
1610
+ empty.className = "empty";
1611
+ empty.textContent = "No tables.";
1612
+ tables.append(empty);
1613
+ return;
1614
+ }
1615
+ for (const item of listed) {
1616
+ if (!isRecord2(item) || typeof item.schema !== "string" || typeof item.name !== "string")
1617
+ continue;
1618
+ const button = document.createElement("button");
1619
+ button.type = "button";
1620
+ button.dataset.schema = item.schema;
1621
+ button.dataset.table = item.name;
1622
+ button.textContent = `${item.schema}.${item.name}`;
1623
+ tables.append(button);
1624
+ }
1625
+ };
1626
+ tables.addEventListener("click", (event) => {
1627
+ const target = event.target;
1628
+ if (!(target instanceof Element))
1629
+ return;
1630
+ const button = target.closest("button");
1631
+ if (!(button instanceof HTMLButtonElement))
1632
+ return;
1633
+ const schema = button.dataset.schema;
1634
+ const name = button.dataset.table;
1635
+ if (schema === void 0 || name === void 0)
1636
+ return;
1637
+ clearError();
1638
+ loadPage(schema, name).catch(showError);
1639
+ });
1640
+ run.addEventListener("click", () => {
1641
+ const sql = input.value.trim();
1642
+ if (sql === "") {
1643
+ showError(new Error("Enter a statement"));
1644
+ return;
1645
+ }
1646
+ clearError();
1647
+ api.send("POST", "/sql/query", { sql }).then((payload) => {
1648
+ const rows = rowsOf(payload);
1649
+ renderGrid(columnsOf(payload, rows), rows);
1650
+ const count = isRecord2(payload) && typeof payload.rowCount === "number" ? payload.rowCount : rows.length;
1651
+ const truncated = isRecord2(payload) && payload.truncated === true ? " (truncated)" : "";
1652
+ result.textContent = `${count} rows${truncated}`;
1653
+ }).catch(showError);
1654
+ });
1655
+ const namespace = document.getElementById("namespace");
1656
+ if (namespace) {
1657
+ namespace.addEventListener("change", () => {
1658
+ clearError();
1659
+ loadTables().catch(showError);
1660
+ });
1661
+ }
1662
+ loadTables().catch(showError);
1663
+ }
1503
1664
  function bootAdmin(config) {
1504
1665
  const fieldKinds = ["string", "number", "boolean", "null", "object", "array", "unknown"];
1505
1666
  const sources = ["declared", "inferred", "mixed"];
@@ -2176,6 +2337,22 @@ function bootAdmin(config) {
2176
2337
  panel.script = value.script;
2177
2338
  return panel;
2178
2339
  };
2340
+ const decodeExtension = (value) => {
2341
+ if (!isRecord2(value))
2342
+ return void 0;
2343
+ if (value.kind === "sql") {
2344
+ return {
2345
+ kind: "sql",
2346
+ id: typeof value.id === "string" && value.id !== "" ? value.id : "sql",
2347
+ title: typeof value.title === "string" && value.title !== "" ? value.title : "SQL",
2348
+ description: typeof value.description === "string" ? value.description : "Browse tables and run queries."
2349
+ };
2350
+ }
2351
+ if (value.kind !== "panel")
2352
+ return void 0;
2353
+ const panel = decodePanel(value);
2354
+ return panel === void 0 ? void 0 : { kind: "panel", ...panel };
2355
+ };
2179
2356
  const mountPanels = (panels) => {
2180
2357
  const nav = el("nav", HTMLElement);
2181
2358
  const views = el("views", HTMLElement);
@@ -2229,10 +2406,48 @@ function bootAdmin(config) {
2229
2406
  return decoded === void 0 ? [] : [decoded];
2230
2407
  });
2231
2408
  mountPanels(panels);
2409
+ const extensions = requireList(isRecord2(manifest) ? manifest.extensions : void 0, "Extensions").flatMap((extension) => {
2410
+ const decoded = decodeExtension(extension);
2411
+ return decoded === void 0 ? [] : [decoded];
2412
+ });
2413
+ const extensionPanels = extensions.flatMap((extension) => extension.kind === "panel" ? [extension] : []);
2414
+ mountPanels(extensionPanels);
2415
+ for (const extension of extensions) {
2416
+ if (extension.kind !== "sql")
2417
+ continue;
2418
+ const nav = el("nav", HTMLElement);
2419
+ const views = el("views", HTMLElement);
2420
+ const button = document.createElement("button");
2421
+ button.type = "button";
2422
+ button.dataset.view = extension.id;
2423
+ button.textContent = extension.title;
2424
+ nav.append(button);
2425
+ const section = document.createElement("section");
2426
+ section.className = "view";
2427
+ section.id = `view-${extension.id}`;
2428
+ section.hidden = true;
2429
+ const title = document.createElement("h2");
2430
+ title.textContent = extension.title;
2431
+ const lede = document.createElement("p");
2432
+ lede.className = "lede";
2433
+ lede.textContent = extension.description;
2434
+ const body = document.createElement("div");
2435
+ body.className = "panel-body";
2436
+ section.append(title, lede, body);
2437
+ views.append(section);
2438
+ mountSqlExplorer(body, panelApi);
2439
+ }
2232
2440
  return refresh();
2233
2441
  }).catch(showError);
2234
2442
  }
2235
- var clientPrelude = [isRecord2, mountAdminBrand, startAdminBrand, faultPresetList, bootAdmin].map((fn) => fn.toString()).join("\n");
2443
+ var clientPrelude = [
2444
+ isRecord2,
2445
+ mountAdminBrand,
2446
+ startAdminBrand,
2447
+ faultPresetList,
2448
+ mountSqlExplorer,
2449
+ bootAdmin
2450
+ ].map((fn) => fn.toString()).join("\n");
2236
2451
  var adminClientSource = (config) => {
2237
2452
  const payload = JSON.stringify(config).replace(/</g, "\\u003c");
2238
2453
  const entry = bootAdmin.name;
@@ -2282,19 +2497,33 @@ var STANDARD_ADMIN_ROUTES = [
2282
2497
  "GET /ui/manifest"
2283
2498
  ];
2284
2499
  var PANEL_ID = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
2500
+ var RESERVED_VIEWS = /* @__PURE__ */ new Set(["overview", "state", "clock", "faults", "journal", "routes"]);
2501
+ var checkPanel = (panel, seen, label) => {
2502
+ if (!PANEL_ID.test(panel.id)) {
2503
+ throw new RangeError(`${label} id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
2504
+ }
2505
+ if (RESERVED_VIEWS.has(panel.id)) {
2506
+ throw new RangeError(`${label} id ${panel.id} is reserved by the admin shell`);
2507
+ }
2508
+ if (seen.has(panel.id))
2509
+ throw new RangeError(`duplicate admin view id ${panel.id}`);
2510
+ seen.add(panel.id);
2511
+ if (panel.title.trim() === "")
2512
+ throw new RangeError(`${label} ${panel.id} needs a title`);
2513
+ };
2285
2514
  var assertAdminUi = (ui) => {
2286
- if (!ui?.panels)
2515
+ if (!ui)
2287
2516
  return;
2288
2517
  const seen = /* @__PURE__ */ new Set();
2289
- for (const panel of ui.panels) {
2290
- if (!PANEL_ID.test(panel.id)) {
2291
- throw new RangeError(`admin panel id must match ${PANEL_ID}: ${JSON.stringify(panel.id)}`);
2518
+ for (const panel of ui.panels ?? [])
2519
+ checkPanel(panel, seen, "admin panel");
2520
+ for (const extension of ui.extensions ?? []) {
2521
+ if (extension.kind === "panel") {
2522
+ checkPanel(extension, seen, "admin extension");
2523
+ continue;
2292
2524
  }
2293
- if (seen.has(panel.id))
2294
- throw new RangeError(`duplicate admin panel id ${panel.id}`);
2295
- seen.add(panel.id);
2296
- if (panel.title.trim() === "")
2297
- throw new RangeError(`admin panel ${panel.id} needs a title`);
2525
+ const id = extension.id ?? "sql";
2526
+ checkPanel({ id, title: extension.title ?? "SQL" }, seen, "admin extension");
2298
2527
  }
2299
2528
  };
2300
2529
 
@@ -2528,6 +2757,12 @@ var renderAdminDocument = (service) => {
2528
2757
  border-radius: 999px; padding: 4px 8px;
2529
2758
  }
2530
2759
  .chip i { color: var(--faint); font-style: normal; }
2760
+ .sql-layout {
2761
+ display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: 16px;
2762
+ }
2763
+ .sql-tables { display: flex; flex-direction: column; gap: 4px; max-height: 28rem; overflow: auto; }
2764
+ .sql-tables button { text-align: left; }
2765
+ .sql-input { font-family: var(--mono); min-height: 7rem; width: 100%; }
2531
2766
  table { width: 100%; border-collapse: collapse; font-size: 14px; }
2532
2767
  th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
2533
2768
  th { color: var(--faint); font-weight: 600; font-size: 12px; }
@@ -2591,7 +2826,7 @@ var renderAdminDocument = (service) => {
2591
2826
  padding: 8px;
2592
2827
  }
2593
2828
  nav.side button { white-space: nowrap; flex: none; }
2594
- .split { grid-template-columns: minmax(0, 1fr); }
2829
+ .split, .sql-layout { grid-template-columns: minmax(0, 1fr); }
2595
2830
  main { padding: 14px; }
2596
2831
  table, thead, tbody, tr, th, td { display: block; }
2597
2832
  thead { display: none; }
@@ -2762,6 +2997,24 @@ var json2 = (body) => new Response(JSON.stringify(body), {
2762
2997
  status: 200,
2763
2998
  headers: { "content-type": "application/json; charset=utf-8" }
2764
2999
  });
3000
+ var describeExtension = (extension) => {
3001
+ if (extension.kind === "sql") {
3002
+ return {
3003
+ kind: "sql",
3004
+ id: extension.id ?? "sql",
3005
+ title: extension.title ?? "SQL",
3006
+ ...extension.description !== void 0 ? { description: extension.description } : {}
3007
+ };
3008
+ }
3009
+ return {
3010
+ kind: "panel",
3011
+ id: extension.id,
3012
+ title: extension.title,
3013
+ ...extension.description !== void 0 ? { description: extension.description } : {},
3014
+ html: extension.html,
3015
+ ...extension.script !== void 0 ? { script: extension.script } : {}
3016
+ };
3017
+ };
2765
3018
  var adminUiRoutes = (service, ui) => {
2766
3019
  const shell = () => renderAdminDocument(service);
2767
3020
  const document3 = () => ui?.render ? ui.render({ service, defaultHtml: shell }) : shell();
@@ -2776,7 +3029,8 @@ var adminUiRoutes = (service, ui) => {
2776
3029
  ...panel.description !== void 0 ? { description: panel.description } : {},
2777
3030
  html: panel.html,
2778
3031
  ...panel.script !== void 0 ? { script: panel.script } : {}
2779
- }))
3032
+ })),
3033
+ extensions: (ui?.extensions ?? []).map(describeExtension)
2780
3034
  })
2781
3035
  };
2782
3036
  };
@@ -3683,7 +3937,7 @@ var stateAdminRoutes = (routes) => {
3683
3937
  };
3684
3938
 
3685
3939
  // ../core/dist/version.js
3686
- var PACKAGE_VERSION = true ? "1.6.1" : UNRELEASED_VERSION;
3940
+ var PACKAGE_VERSION = true ? "1.7.1" : UNRELEASED_VERSION;
3687
3941
 
3688
3942
  // ../core/dist/webhooks.js
3689
3943
  var json4 = (status, body) => new Response(JSON.stringify(body), { status, headers: { "content-type": "application/json" } });
@@ -4963,4 +5217,4 @@ export {
4963
5217
  accessKeyCredential,
4964
5218
  CognitoAPI
4965
5219
  };
4966
- //# sourceMappingURL=chunk-7M34ZH6D.js.map
5220
+ //# sourceMappingURL=chunk-DAKLQBEB.js.map