@ai-matrx/records-ui 0.115.66 → 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/CHANGELOG.md +12 -0
- package/dist/index.cjs +58 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +58 -10
- package/dist/index.js.map +1 -1
- package/dist/table-shape.cjs +2 -2
- package/dist/table-shape.cjs.map +1 -1
- package/dist/table-shape.d.cts +3 -1
- package/dist/table-shape.d.ts +3 -1
- package/dist/table-shape.js +2 -2
- package/dist/table-shape.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog — @ai-matrx/records-ui
|
|
2
2
|
|
|
3
|
+
## 0.115.68
|
|
4
|
+
|
|
5
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
6
|
+
`git diff npm/records-ui/v0.115.67..npm/records-ui/v0.115.68 -- apps/shared/records-ui`).
|
|
7
|
+
No source changes intended and no consumer action required.
|
|
8
|
+
|
|
9
|
+
## 0.115.67
|
|
10
|
+
|
|
11
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
12
|
+
`git diff npm/records-ui/v0.115.66..npm/records-ui/v0.115.67 -- apps/shared/records-ui`).
|
|
13
|
+
No source changes intended and no consumer action required.
|
|
14
|
+
|
|
3
15
|
## 0.115.66
|
|
4
16
|
|
|
5
17
|
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
package/dist/index.cjs
CHANGED
|
@@ -23831,11 +23831,11 @@ function readTableShape(text) {
|
|
|
23831
23831
|
function hasTableShape(text) {
|
|
23832
23832
|
return readTableShapes(text).length > 0;
|
|
23833
23833
|
}
|
|
23834
|
-
function shapeOfGrid(headers, cells, name = null) {
|
|
23834
|
+
function shapeOfGrid(headers, cells, name = null, from = "table") {
|
|
23835
23835
|
const labels = uniqueLabels(headers.map((h) => cellWords(String(h ?? ""))));
|
|
23836
23836
|
const rows = rowsOf(labels, cells.map((r) => r.map((c) => cellWords(String(c ?? "")))));
|
|
23837
23837
|
if (labels.length === 0) return null;
|
|
23838
|
-
const said2 = rows.length === 0 ? `${plural3(labels.length, "column", "columns")} and no rows yet` : `${sizeWords(rows.length, labels.length)} from a
|
|
23838
|
+
const said2 = rows.length === 0 ? `${plural3(labels.length, "column", "columns")} and no rows yet` : `${sizeWords(rows.length, labels.length)} from a ${from}`;
|
|
23839
23839
|
return { kind: "table", headers: labels, rows, name, at: null, splits: [], said: said2 };
|
|
23840
23840
|
}
|
|
23841
23841
|
var MOST_GUESSED_CHOICES = 12;
|
|
@@ -28628,6 +28628,39 @@ var import_react167 = require("react");
|
|
|
28628
28628
|
var import_react168 = require("@ai-matrx/records/react");
|
|
28629
28629
|
var import_design_system85 = require("@ai-matrx/design-system");
|
|
28630
28630
|
|
|
28631
|
+
// src/unfinishedTable.ts
|
|
28632
|
+
var UNFINISHED_WINDOW_MS = 24 * 60 * 60 * 1e3;
|
|
28633
|
+
async function findUnfinishedTable(client, wantedName, wantedKeys, now = Date.now()) {
|
|
28634
|
+
const name = wantedName.trim().toLowerCase();
|
|
28635
|
+
if (!name) return null;
|
|
28636
|
+
const listed = await client.tableList();
|
|
28637
|
+
if (!listed.ok) return null;
|
|
28638
|
+
const named = listed.data.filter((t) => !t.is_kernel && t.name.trim().toLowerCase() === name);
|
|
28639
|
+
if (named.length === 0) return null;
|
|
28640
|
+
const headers = await client.recordHeaders({ ids: named.map((t) => t.id) });
|
|
28641
|
+
if (!headers.ok) return null;
|
|
28642
|
+
const madeAt = /* @__PURE__ */ new Map();
|
|
28643
|
+
for (const h of headers.data) {
|
|
28644
|
+
const at = Date.parse(h.created_at);
|
|
28645
|
+
if (h.mine && h.deleted_at === null && Number.isFinite(at) && now - at <= UNFINISHED_WINDOW_MS) madeAt.set(h.id, at);
|
|
28646
|
+
}
|
|
28647
|
+
const candidates = named.filter((t) => madeAt.has(t.id));
|
|
28648
|
+
if (candidates.length === 0) return null;
|
|
28649
|
+
const counted = await client.tableRowCounts({ table_ids: candidates.map((t) => t.id) });
|
|
28650
|
+
if (!counted.ok) return null;
|
|
28651
|
+
const withRows = new Set(counted.data.filter((c) => c.visible_rows > 0).map((c) => c.table_id));
|
|
28652
|
+
const wanted = new Set(wantedKeys);
|
|
28653
|
+
const ordered = [...candidates].sort((a, b) => (madeAt.get(b.id) ?? 0) - (madeAt.get(a.id) ?? 0));
|
|
28654
|
+
for (const t of ordered) {
|
|
28655
|
+
if (withRows.has(t.id)) continue;
|
|
28656
|
+
const read = await client.fields({ table_id: t.id });
|
|
28657
|
+
if (!read.ok) continue;
|
|
28658
|
+
const have = new Set(read.data.map((f) => f.key));
|
|
28659
|
+
if ([...have].every((k) => wanted.has(k))) return { tableId: t.id, haveKeys: have };
|
|
28660
|
+
}
|
|
28661
|
+
return null;
|
|
28662
|
+
}
|
|
28663
|
+
|
|
28631
28664
|
// src/TablesHome.tsx
|
|
28632
28665
|
var import_react165 = require("react");
|
|
28633
28666
|
var import_react166 = require("@ai-matrx/records/react");
|
|
@@ -30723,7 +30756,7 @@ var SAVE_TO_TABLE_TYPES = [
|
|
|
30723
30756
|
];
|
|
30724
30757
|
function shapesOfSource(source) {
|
|
30725
30758
|
if (source.grid) {
|
|
30726
|
-
const s = shapeOfGrid(source.grid.headers, source.grid.rows, source.title ?? null);
|
|
30759
|
+
const s = shapeOfGrid(source.grid.headers, source.grid.rows, source.title ?? null, source.grid.from);
|
|
30727
30760
|
return s ? [s] : [];
|
|
30728
30761
|
}
|
|
30729
30762
|
if (source.value !== void 0) {
|
|
@@ -30842,16 +30875,31 @@ function SaveToTable({ source, shapeIndex = 0, onOpenTable, onSaved, onClose, ma
|
|
|
30842
30875
|
...c.guess.type === "datetime" && c.guess.kind ? { kind: c.guess.kind } : {}
|
|
30843
30876
|
};
|
|
30844
30877
|
});
|
|
30845
|
-
const tableName2 = freeName(name ?? proposedName, (tables.data ?? []).map((t) => t.name));
|
|
30846
30878
|
setPhase("making");
|
|
30847
30879
|
try {
|
|
30848
|
-
const
|
|
30849
|
-
|
|
30850
|
-
|
|
30851
|
-
|
|
30852
|
-
|
|
30880
|
+
const earlier = await findUnfinishedTable(client, name ?? proposedName, fields.map((f) => f.key));
|
|
30881
|
+
let tableName2;
|
|
30882
|
+
let newId;
|
|
30883
|
+
if (earlier) {
|
|
30884
|
+
tableName2 = (name ?? proposedName).trim();
|
|
30885
|
+
newId = earlier.tableId;
|
|
30886
|
+
const lacking = fields.filter((f) => !earlier.haveKeys.has(f.key));
|
|
30887
|
+
const added = await (0, import_core3.addFields)(client, newId, lacking);
|
|
30888
|
+
if (!added.ok) {
|
|
30889
|
+
setProblem(added.error);
|
|
30890
|
+
setPhase("ready");
|
|
30891
|
+
return;
|
|
30892
|
+
}
|
|
30893
|
+
} else {
|
|
30894
|
+
tableName2 = freeName(name ?? proposedName, (tables.data ?? []).map((t) => t.name));
|
|
30895
|
+
const born = await (0, import_core3.declareTable)(client, { name: tableName2, fields });
|
|
30896
|
+
if (!born.ok) {
|
|
30897
|
+
setProblem(born.error);
|
|
30898
|
+
setPhase("ready");
|
|
30899
|
+
return;
|
|
30900
|
+
}
|
|
30901
|
+
newId = born.data;
|
|
30853
30902
|
}
|
|
30854
|
-
const newId = born.data;
|
|
30855
30903
|
if (description.trim()) {
|
|
30856
30904
|
const described = await (0, writeOnTheWinningVersion_exports.updateOnTheWinningVersion)(
|
|
30857
30905
|
client,
|