@ai-matrx/records-ui 0.115.88 → 0.115.90
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 -1
- package/dist/index.cjs +29 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -2
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +29 -2
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +29 -2
- package/dist/pickers.js.map +1 -1
- package/package.json +5 -5
package/dist/pickers.cjs
CHANGED
|
@@ -5730,10 +5730,34 @@ async function writeRecordPatches(client, tableId, patches) {
|
|
|
5730
5730
|
}
|
|
5731
5731
|
}
|
|
5732
5732
|
async function writePersonWords(client, tableId, rows, people, key, as) {
|
|
5733
|
-
const patches =
|
|
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 = {};
|
|
5734
5739
|
for (const row of rows) {
|
|
5735
5740
|
const words = wordsFor(row.ids, people, as);
|
|
5736
|
-
if (words !== null)
|
|
5741
|
+
if (words !== null) out[row.recordId] = words;
|
|
5742
|
+
}
|
|
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 } }));
|
|
5747
|
+
}
|
|
5748
|
+
async function forgetWrittenWords(client, tableId, key, written) {
|
|
5749
|
+
const patches = [];
|
|
5750
|
+
for (let offset = 0; offset < CEILING; offset += PAGE) {
|
|
5751
|
+
const page = await client.list({ table_id: tableId, limit: PAGE, offset });
|
|
5752
|
+
if (!page.ok) throw new Error(refusalSentence(page.error));
|
|
5753
|
+
for (const row of page.data.rows) {
|
|
5754
|
+
const word = written[row.id];
|
|
5755
|
+
const kept = (row.document ?? {})["_retired"];
|
|
5756
|
+
if (word === void 0 || !Array.isArray(kept)) continue;
|
|
5757
|
+
const rest = kept.filter((e) => !(e?.key === key && e?.value === word));
|
|
5758
|
+
if (rest.length !== kept.length) patches.push({ recordId: row.id, patch: { _retired: rest } });
|
|
5759
|
+
}
|
|
5760
|
+
if (page.data.rows.length < PAGE) break;
|
|
5737
5761
|
}
|
|
5738
5762
|
await writeRecordPatches(client, tableId, patches);
|
|
5739
5763
|
return patches.length;
|
|
@@ -5858,6 +5882,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5858
5882
|
setRefusal(null);
|
|
5859
5883
|
let holding;
|
|
5860
5884
|
let aside;
|
|
5885
|
+
let wordsWritten;
|
|
5861
5886
|
const offerUndo = (migration) => {
|
|
5862
5887
|
if (!migration || !notify?.reversible) return;
|
|
5863
5888
|
const wasPerson = person && read && (to.id === "text" || to.id === "email") ? read : null;
|
|
@@ -5874,6 +5899,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5874
5899
|
tableId,
|
|
5875
5900
|
wasPerson.rows.map((r) => ({ recordId: r.recordId, patch: { [field.key]: field.multi ? r.ids : r.ids[0] ?? null } }))
|
|
5876
5901
|
);
|
|
5902
|
+
if (wordsWritten) await forgetWrittenWords(client, tableId, field.key, wordsWritten);
|
|
5877
5903
|
}
|
|
5878
5904
|
(0, import_react44.tableShapeChanged)(tableId);
|
|
5879
5905
|
onRetyped?.();
|
|
@@ -5906,6 +5932,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5906
5932
|
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
5907
5933
|
const as = to.id === "email" ? "email" : "name";
|
|
5908
5934
|
try {
|
|
5935
|
+
wordsWritten = personWordsWritten(read.rows, read.people, as);
|
|
5909
5936
|
const written = await writePersonWords(client, tableId, read.rows, read.people, field.key, as);
|
|
5910
5937
|
holding = written;
|
|
5911
5938
|
aside = read.rows.length - written;
|