@ai-matrx/records-ui 0.115.87 → 0.115.89
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 +30 -1
- package/dist/index.cjs +51 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +52 -20
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +46 -14
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +47 -14
- package/dist/pickers.js.map +1 -1
- package/package.json +4 -4
package/dist/pickers.cjs
CHANGED
|
@@ -4547,6 +4547,10 @@ function knownPerson(id) {
|
|
|
4547
4547
|
return null;
|
|
4548
4548
|
}
|
|
4549
4549
|
|
|
4550
|
+
// src/recordVersions.ts
|
|
4551
|
+
var recordVersions_exports = {};
|
|
4552
|
+
__reExport(recordVersions_exports, require("@ai-matrx/records/versions"));
|
|
4553
|
+
|
|
4550
4554
|
// src/memberNames.ts
|
|
4551
4555
|
var import_react36 = require("react");
|
|
4552
4556
|
var import_react37 = require("@ai-matrx/records/react");
|
|
@@ -5665,7 +5669,7 @@ async function readPersonColumn(client, tableId, key) {
|
|
|
5665
5669
|
const out = [];
|
|
5666
5670
|
for (let offset = 0; offset < CEILING; offset += PAGE) {
|
|
5667
5671
|
const page = await client.list({ table_id: tableId, limit: PAGE, offset });
|
|
5668
|
-
if (!page.ok) throw new Error(page.error
|
|
5672
|
+
if (!page.ok) throw new Error(refusalSentence(page.error));
|
|
5669
5673
|
for (const row of page.data.rows) {
|
|
5670
5674
|
const doc = row.document ?? {};
|
|
5671
5675
|
let ids = idsIn(doc[key]);
|
|
@@ -5703,17 +5707,43 @@ function previewPersonWords(rows, people, as) {
|
|
|
5703
5707
|
}
|
|
5704
5708
|
return { converts, keptAside, examples, partial: false };
|
|
5705
5709
|
}
|
|
5710
|
+
async function versionsNow(client, ids) {
|
|
5711
|
+
const out = /* @__PURE__ */ new Map();
|
|
5712
|
+
for (let i = 0; i < ids.length; i += 200) {
|
|
5713
|
+
const got = await client.recordHeaders({ ids: ids.slice(i, i + 200) });
|
|
5714
|
+
if (!got.ok) throw new Error(refusalSentence(got.error));
|
|
5715
|
+
for (const h of got.data ?? []) if (typeof h.version === "number") out.set(h.id, h.version);
|
|
5716
|
+
}
|
|
5717
|
+
return out;
|
|
5718
|
+
}
|
|
5719
|
+
async function writeRecordPatches(client, tableId, patches) {
|
|
5720
|
+
const versions = await versionsNow(client, patches.map((p) => p.recordId));
|
|
5721
|
+
for (let i = 0; i < patches.length; i += 100) {
|
|
5722
|
+
const changes = patches.slice(i, i + 100).map((p) => ({
|
|
5723
|
+
op: "update",
|
|
5724
|
+
record_id: p.recordId,
|
|
5725
|
+
patch: p.patch,
|
|
5726
|
+
expected_version: versions.get(p.recordId) ?? null
|
|
5727
|
+
}));
|
|
5728
|
+
const done = await (0, recordVersions_exports.changeRecordsAt)(client, { table_id: tableId, changes });
|
|
5729
|
+
if (!done.ok) throw new Error(refusalSentence(done.error));
|
|
5730
|
+
}
|
|
5731
|
+
}
|
|
5706
5732
|
async function writePersonWords(client, tableId, rows, people, key, as) {
|
|
5707
|
-
const
|
|
5733
|
+
const patches = personWordsPatches(rows, people, key, as);
|
|
5734
|
+
await writeRecordPatches(client, tableId, patches);
|
|
5735
|
+
return patches.length;
|
|
5736
|
+
}
|
|
5737
|
+
function personWordsWritten(rows, people, as) {
|
|
5738
|
+
const out = {};
|
|
5708
5739
|
for (const row of rows) {
|
|
5709
5740
|
const words = wordsFor(row.ids, people, as);
|
|
5710
|
-
if (words !== null)
|
|
5711
|
-
}
|
|
5712
|
-
for (let i = 0; i < changes.length; i += 100) {
|
|
5713
|
-
const done = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
|
|
5714
|
-
if (!done.ok) throw new Error(done.error.message ?? "The words could not be written");
|
|
5741
|
+
if (words !== null) out[row.recordId] = words;
|
|
5715
5742
|
}
|
|
5716
|
-
return
|
|
5743
|
+
return out;
|
|
5744
|
+
}
|
|
5745
|
+
function personWordsPatches(rows, people, key, as) {
|
|
5746
|
+
return Object.entries(personWordsWritten(rows, people, as)).map(([recordId, words]) => ({ recordId, patch: { [key]: words } }));
|
|
5717
5747
|
}
|
|
5718
5748
|
|
|
5719
5749
|
// src/FieldRetype.tsx
|
|
@@ -5835,6 +5865,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5835
5865
|
setRefusal(null);
|
|
5836
5866
|
let holding;
|
|
5837
5867
|
let aside;
|
|
5868
|
+
let wordsWritten;
|
|
5838
5869
|
const offerUndo = (migration) => {
|
|
5839
5870
|
if (!migration || !notify?.reversible) return;
|
|
5840
5871
|
const wasPerson = person && read && (to.id === "text" || to.id === "email") ? read : null;
|
|
@@ -5843,14 +5874,14 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5843
5874
|
noun: "column",
|
|
5844
5875
|
subject: name,
|
|
5845
5876
|
undo: async () => {
|
|
5846
|
-
const back = await client.migrateUndo({ migration_id: migration });
|
|
5877
|
+
const back = await client.migrateUndo({ migration_id: migration, ...wordsWritten ? { written: wordsWritten } : {} });
|
|
5847
5878
|
if (!back.ok) throw new Error(refusalSentence(back.error));
|
|
5848
5879
|
if (wasPerson) {
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5880
|
+
await writeRecordPatches(
|
|
5881
|
+
client,
|
|
5882
|
+
tableId,
|
|
5883
|
+
wasPerson.rows.map((r) => ({ recordId: r.recordId, patch: { [field.key]: field.multi ? r.ids : r.ids[0] ?? null } }))
|
|
5884
|
+
);
|
|
5854
5885
|
}
|
|
5855
5886
|
(0, import_react44.tableShapeChanged)(tableId);
|
|
5856
5887
|
onRetyped?.();
|
|
@@ -5883,6 +5914,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5883
5914
|
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
5884
5915
|
const as = to.id === "email" ? "email" : "name";
|
|
5885
5916
|
try {
|
|
5917
|
+
wordsWritten = personWordsWritten(read.rows, read.people, as);
|
|
5886
5918
|
const written = await writePersonWords(client, tableId, read.rows, read.people, field.key, as);
|
|
5887
5919
|
holding = written;
|
|
5888
5920
|
aside = read.rows.length - written;
|