@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/index.js
CHANGED
|
@@ -2666,10 +2666,34 @@ async function writeRecordPatches(client, tableId, patches) {
|
|
|
2666
2666
|
}
|
|
2667
2667
|
}
|
|
2668
2668
|
async function writePersonWords(client, tableId, rows, people, key, as) {
|
|
2669
|
-
const patches =
|
|
2669
|
+
const patches = personWordsPatches(rows, people, key, as);
|
|
2670
|
+
await writeRecordPatches(client, tableId, patches);
|
|
2671
|
+
return patches.length;
|
|
2672
|
+
}
|
|
2673
|
+
function personWordsWritten(rows, people, as) {
|
|
2674
|
+
const out = {};
|
|
2670
2675
|
for (const row of rows) {
|
|
2671
2676
|
const words2 = wordsFor(row.ids, people, as);
|
|
2672
|
-
if (words2 !== null)
|
|
2677
|
+
if (words2 !== null) out[row.recordId] = words2;
|
|
2678
|
+
}
|
|
2679
|
+
return out;
|
|
2680
|
+
}
|
|
2681
|
+
function personWordsPatches(rows, people, key, as) {
|
|
2682
|
+
return Object.entries(personWordsWritten(rows, people, as)).map(([recordId, words2]) => ({ recordId, patch: { [key]: words2 } }));
|
|
2683
|
+
}
|
|
2684
|
+
async function forgetWrittenWords(client, tableId, key, written) {
|
|
2685
|
+
const patches = [];
|
|
2686
|
+
for (let offset = 0; offset < CEILING; offset += PAGE) {
|
|
2687
|
+
const page = await client.list({ table_id: tableId, limit: PAGE, offset });
|
|
2688
|
+
if (!page.ok) throw new Error(refusalSentence(page.error));
|
|
2689
|
+
for (const row of page.data.rows) {
|
|
2690
|
+
const word = written[row.id];
|
|
2691
|
+
const kept = (row.document ?? {})["_retired"];
|
|
2692
|
+
if (word === void 0 || !Array.isArray(kept)) continue;
|
|
2693
|
+
const rest = kept.filter((e) => !(e?.key === key && e?.value === word));
|
|
2694
|
+
if (rest.length !== kept.length) patches.push({ recordId: row.id, patch: { _retired: rest } });
|
|
2695
|
+
}
|
|
2696
|
+
if (page.data.rows.length < PAGE) break;
|
|
2673
2697
|
}
|
|
2674
2698
|
await writeRecordPatches(client, tableId, patches);
|
|
2675
2699
|
return patches.length;
|
|
@@ -2794,6 +2818,7 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
|
|
|
2794
2818
|
setRefusal(null);
|
|
2795
2819
|
let holding;
|
|
2796
2820
|
let aside;
|
|
2821
|
+
let wordsWritten;
|
|
2797
2822
|
const offerUndo = (migration) => {
|
|
2798
2823
|
if (!migration || !notify?.reversible) return;
|
|
2799
2824
|
const wasPerson = person && read && (to.id === "text" || to.id === "email") ? read : null;
|
|
@@ -2810,6 +2835,7 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
|
|
|
2810
2835
|
tableId,
|
|
2811
2836
|
wasPerson.rows.map((r) => ({ recordId: r.recordId, patch: { [field2.key]: field2.multi ? r.ids : r.ids[0] ?? null } }))
|
|
2812
2837
|
);
|
|
2838
|
+
if (wordsWritten) await forgetWrittenWords(client, tableId, field2.key, wordsWritten);
|
|
2813
2839
|
}
|
|
2814
2840
|
tableShapeChanged(tableId);
|
|
2815
2841
|
onRetyped?.();
|
|
@@ -2842,6 +2868,7 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
|
|
|
2842
2868
|
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
2843
2869
|
const as = to.id === "email" ? "email" : "name";
|
|
2844
2870
|
try {
|
|
2871
|
+
wordsWritten = personWordsWritten(read.rows, read.people, as);
|
|
2845
2872
|
const written = await writePersonWords(client, tableId, read.rows, read.people, field2.key, as);
|
|
2846
2873
|
holding = written;
|
|
2847
2874
|
aside = read.rows.length - written;
|