@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.js
CHANGED
|
@@ -5795,10 +5795,34 @@ async function writeRecordPatches(client, tableId, patches) {
|
|
|
5795
5795
|
}
|
|
5796
5796
|
}
|
|
5797
5797
|
async function writePersonWords(client, tableId, rows, people, key, as) {
|
|
5798
|
-
const patches =
|
|
5798
|
+
const patches = personWordsPatches(rows, people, key, as);
|
|
5799
|
+
await writeRecordPatches(client, tableId, patches);
|
|
5800
|
+
return patches.length;
|
|
5801
|
+
}
|
|
5802
|
+
function personWordsWritten(rows, people, as) {
|
|
5803
|
+
const out = {};
|
|
5799
5804
|
for (const row of rows) {
|
|
5800
5805
|
const words = wordsFor(row.ids, people, as);
|
|
5801
|
-
if (words !== null)
|
|
5806
|
+
if (words !== null) out[row.recordId] = words;
|
|
5807
|
+
}
|
|
5808
|
+
return out;
|
|
5809
|
+
}
|
|
5810
|
+
function personWordsPatches(rows, people, key, as) {
|
|
5811
|
+
return Object.entries(personWordsWritten(rows, people, as)).map(([recordId, words]) => ({ recordId, patch: { [key]: words } }));
|
|
5812
|
+
}
|
|
5813
|
+
async function forgetWrittenWords(client, tableId, key, written) {
|
|
5814
|
+
const patches = [];
|
|
5815
|
+
for (let offset = 0; offset < CEILING; offset += PAGE) {
|
|
5816
|
+
const page = await client.list({ table_id: tableId, limit: PAGE, offset });
|
|
5817
|
+
if (!page.ok) throw new Error(refusalSentence(page.error));
|
|
5818
|
+
for (const row of page.data.rows) {
|
|
5819
|
+
const word = written[row.id];
|
|
5820
|
+
const kept = (row.document ?? {})["_retired"];
|
|
5821
|
+
if (word === void 0 || !Array.isArray(kept)) continue;
|
|
5822
|
+
const rest = kept.filter((e) => !(e?.key === key && e?.value === word));
|
|
5823
|
+
if (rest.length !== kept.length) patches.push({ recordId: row.id, patch: { _retired: rest } });
|
|
5824
|
+
}
|
|
5825
|
+
if (page.data.rows.length < PAGE) break;
|
|
5802
5826
|
}
|
|
5803
5827
|
await writeRecordPatches(client, tableId, patches);
|
|
5804
5828
|
return patches.length;
|
|
@@ -5923,6 +5947,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5923
5947
|
setRefusal(null);
|
|
5924
5948
|
let holding;
|
|
5925
5949
|
let aside;
|
|
5950
|
+
let wordsWritten;
|
|
5926
5951
|
const offerUndo = (migration) => {
|
|
5927
5952
|
if (!migration || !notify?.reversible) return;
|
|
5928
5953
|
const wasPerson = person && read && (to.id === "text" || to.id === "email") ? read : null;
|
|
@@ -5939,6 +5964,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5939
5964
|
tableId,
|
|
5940
5965
|
wasPerson.rows.map((r) => ({ recordId: r.recordId, patch: { [field.key]: field.multi ? r.ids : r.ids[0] ?? null } }))
|
|
5941
5966
|
);
|
|
5967
|
+
if (wordsWritten) await forgetWrittenWords(client, tableId, field.key, wordsWritten);
|
|
5942
5968
|
}
|
|
5943
5969
|
tableShapeChanged2(tableId);
|
|
5944
5970
|
onRetyped?.();
|
|
@@ -5971,6 +5997,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5971
5997
|
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
5972
5998
|
const as = to.id === "email" ? "email" : "name";
|
|
5973
5999
|
try {
|
|
6000
|
+
wordsWritten = personWordsWritten(read.rows, read.people, as);
|
|
5974
6001
|
const written = await writePersonWords(client, tableId, read.rows, read.people, field.key, as);
|
|
5975
6002
|
holding = written;
|
|
5976
6003
|
aside = read.rows.length - written;
|