@ai-matrx/records-ui 0.115.67 → 0.115.69

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 — @ai-matrx/records-ui
2
2
 
3
+ ## 0.115.69
4
+
5
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
6
+ `git diff npm/records-ui/v0.115.68..npm/records-ui/v0.115.69 -- apps/shared/records-ui`).
7
+ No source changes intended and no consumer action required.
8
+
9
+ ## 0.115.68
10
+
11
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
12
+ `git diff npm/records-ui/v0.115.67..npm/records-ui/v0.115.68 -- apps/shared/records-ui`).
13
+ No source changes intended and no consumer action required.
14
+
3
15
  ## 0.115.67
4
16
 
5
17
  Automatic changed-only republish (docs/metadata drift since the last tag — see
package/dist/index.cjs CHANGED
@@ -28630,24 +28630,31 @@ var import_design_system85 = require("@ai-matrx/design-system");
28630
28630
 
28631
28631
  // src/unfinishedTable.ts
28632
28632
  var UNFINISHED_WINDOW_MS = 24 * 60 * 60 * 1e3;
28633
- async function findUnfinishedTable(client, wantedName, wantedKeys, now = Date.now()) {
28633
+ var FILLED_WINDOW_MS = 15 * 60 * 1e3;
28634
+ async function findUnfinishedTable(client, wantedName, wantedKeys, wantedRows, now = Date.now()) {
28634
28635
  const name = wantedName.trim().toLowerCase();
28635
28636
  if (!name) return null;
28636
28637
  const listed = await client.tableList();
28637
28638
  if (!listed.ok) return null;
28638
- const candidates = listed.data.filter((t) => {
28639
- if (t.is_kernel || t.name.trim().toLowerCase() !== name) return false;
28640
- const made = Date.parse(t.created_at);
28641
- return Number.isFinite(made) && now - made <= UNFINISHED_WINDOW_MS;
28642
- });
28639
+ const named = listed.data.filter((t) => !t.is_kernel && t.name.trim().toLowerCase() === name);
28640
+ if (named.length === 0) return null;
28641
+ const headers = await client.recordHeaders({ ids: named.map((t) => t.id) });
28642
+ if (!headers.ok) return null;
28643
+ const madeAt = /* @__PURE__ */ new Map();
28644
+ for (const h of headers.data) {
28645
+ const at = Date.parse(h.created_at);
28646
+ if (h.mine && h.deleted_at === null && Number.isFinite(at) && now - at <= UNFINISHED_WINDOW_MS) madeAt.set(h.id, at);
28647
+ }
28648
+ const candidates = named.filter((t) => madeAt.has(t.id));
28643
28649
  if (candidates.length === 0) return null;
28644
28650
  const counted = await client.tableRowCounts({ table_ids: candidates.map((t) => t.id) });
28645
28651
  if (!counted.ok) return null;
28646
- const withRows = new Set(counted.data.filter((c) => c.visible_rows > 0).map((c) => c.table_id));
28652
+ const rowsOf2 = new Map(counted.data.map((c) => [c.table_id, c.visible_rows]));
28647
28653
  const wanted = new Set(wantedKeys);
28648
- const ordered = [...candidates].sort((a, b) => Date.parse(b.created_at) - Date.parse(a.created_at));
28654
+ const ordered = [...candidates].sort((a, b) => (madeAt.get(b.id) ?? 0) - (madeAt.get(a.id) ?? 0));
28649
28655
  for (const t of ordered) {
28650
- if (withRows.has(t.id)) continue;
28656
+ const rows = rowsOf2.get(t.id) ?? 0;
28657
+ if (rows > 0 && (rows > wantedRows || now - (madeAt.get(t.id) ?? 0) > FILLED_WINDOW_MS)) continue;
28651
28658
  const read = await client.fields({ table_id: t.id });
28652
28659
  if (!read.ok) continue;
28653
28660
  const have = new Set(read.data.map((f) => f.key));
@@ -30872,7 +30879,7 @@ function SaveToTable({ source, shapeIndex = 0, onOpenTable, onSaved, onClose, ma
30872
30879
  });
30873
30880
  setPhase("making");
30874
30881
  try {
30875
- const earlier = await findUnfinishedTable(client, name ?? proposedName, fields.map((f) => f.key));
30882
+ const earlier = await findUnfinishedTable(client, name ?? proposedName, fields.map((f) => f.key), rows.length);
30876
30883
  let tableName2;
30877
30884
  let newId;
30878
30885
  if (earlier) {