@ai-matrx/records-ui 0.115.68 → 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/dist/index.js CHANGED
@@ -28401,7 +28401,8 @@ import {
28401
28401
 
28402
28402
  // src/unfinishedTable.ts
28403
28403
  var UNFINISHED_WINDOW_MS = 24 * 60 * 60 * 1e3;
28404
- async function findUnfinishedTable(client, wantedName, wantedKeys, now = Date.now()) {
28404
+ var FILLED_WINDOW_MS = 15 * 60 * 1e3;
28405
+ async function findUnfinishedTable(client, wantedName, wantedKeys, wantedRows, now = Date.now()) {
28405
28406
  const name = wantedName.trim().toLowerCase();
28406
28407
  if (!name) return null;
28407
28408
  const listed = await client.tableList();
@@ -28419,11 +28420,12 @@ async function findUnfinishedTable(client, wantedName, wantedKeys, now = Date.no
28419
28420
  if (candidates.length === 0) return null;
28420
28421
  const counted = await client.tableRowCounts({ table_ids: candidates.map((t) => t.id) });
28421
28422
  if (!counted.ok) return null;
28422
- const withRows = new Set(counted.data.filter((c) => c.visible_rows > 0).map((c) => c.table_id));
28423
+ const rowsOf2 = new Map(counted.data.map((c) => [c.table_id, c.visible_rows]));
28423
28424
  const wanted = new Set(wantedKeys);
28424
28425
  const ordered = [...candidates].sort((a, b) => (madeAt.get(b.id) ?? 0) - (madeAt.get(a.id) ?? 0));
28425
28426
  for (const t of ordered) {
28426
- if (withRows.has(t.id)) continue;
28427
+ const rows = rowsOf2.get(t.id) ?? 0;
28428
+ if (rows > 0 && (rows > wantedRows || now - (madeAt.get(t.id) ?? 0) > FILLED_WINDOW_MS)) continue;
28427
28429
  const read = await client.fields({ table_id: t.id });
28428
28430
  if (!read.ok) continue;
28429
28431
  const have = new Set(read.data.map((f) => f.key));
@@ -30670,7 +30672,7 @@ function SaveToTable({ source, shapeIndex = 0, onOpenTable, onSaved, onClose, ma
30670
30672
  });
30671
30673
  setPhase("making");
30672
30674
  try {
30673
- const earlier = await findUnfinishedTable(client, name ?? proposedName, fields.map((f) => f.key));
30675
+ const earlier = await findUnfinishedTable(client, name ?? proposedName, fields.map((f) => f.key), rows.length);
30674
30676
  let tableName2;
30675
30677
  let newId;
30676
30678
  if (earlier) {