@ai-matrx/records-ui 0.115.67 → 0.115.68

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/dist/index.js CHANGED
@@ -28406,17 +28406,22 @@ async function findUnfinishedTable(client, wantedName, wantedKeys, now = Date.no
28406
28406
  if (!name) return null;
28407
28407
  const listed = await client.tableList();
28408
28408
  if (!listed.ok) return null;
28409
- const candidates = listed.data.filter((t) => {
28410
- if (t.is_kernel || t.name.trim().toLowerCase() !== name) return false;
28411
- const made = Date.parse(t.created_at);
28412
- return Number.isFinite(made) && now - made <= UNFINISHED_WINDOW_MS;
28413
- });
28409
+ const named = listed.data.filter((t) => !t.is_kernel && t.name.trim().toLowerCase() === name);
28410
+ if (named.length === 0) return null;
28411
+ const headers = await client.recordHeaders({ ids: named.map((t) => t.id) });
28412
+ if (!headers.ok) return null;
28413
+ const madeAt = /* @__PURE__ */ new Map();
28414
+ for (const h of headers.data) {
28415
+ const at = Date.parse(h.created_at);
28416
+ if (h.mine && h.deleted_at === null && Number.isFinite(at) && now - at <= UNFINISHED_WINDOW_MS) madeAt.set(h.id, at);
28417
+ }
28418
+ const candidates = named.filter((t) => madeAt.has(t.id));
28414
28419
  if (candidates.length === 0) return null;
28415
28420
  const counted = await client.tableRowCounts({ table_ids: candidates.map((t) => t.id) });
28416
28421
  if (!counted.ok) return null;
28417
28422
  const withRows = new Set(counted.data.filter((c) => c.visible_rows > 0).map((c) => c.table_id));
28418
28423
  const wanted = new Set(wantedKeys);
28419
- const ordered = [...candidates].sort((a, b) => Date.parse(b.created_at) - Date.parse(a.created_at));
28424
+ const ordered = [...candidates].sort((a, b) => (madeAt.get(b.id) ?? 0) - (madeAt.get(a.id) ?? 0));
28420
28425
  for (const t of ordered) {
28421
28426
  if (withRows.has(t.id)) continue;
28422
28427
  const read = await client.fields({ table_id: t.id });