@ai-matrx/records-ui 0.115.89 → 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/dist/pickers.cjs CHANGED
@@ -5745,6 +5745,23 @@ function personWordsWritten(rows, people, as) {
5745
5745
  function personWordsPatches(rows, people, key, as) {
5746
5746
  return Object.entries(personWordsWritten(rows, people, as)).map(([recordId, words]) => ({ recordId, patch: { [key]: words } }));
5747
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;
5761
+ }
5762
+ await writeRecordPatches(client, tableId, patches);
5763
+ return patches.length;
5764
+ }
5748
5765
 
5749
5766
  // src/FieldRetype.tsx
5750
5767
  var import_jsx_runtime27 = require("react/jsx-runtime");
@@ -5874,7 +5891,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
5874
5891
  noun: "column",
5875
5892
  subject: name,
5876
5893
  undo: async () => {
5877
- const back = await client.migrateUndo({ migration_id: migration, ...wordsWritten ? { written: wordsWritten } : {} });
5894
+ const back = await client.migrateUndo({ migration_id: migration });
5878
5895
  if (!back.ok) throw new Error(refusalSentence(back.error));
5879
5896
  if (wasPerson) {
5880
5897
  await writeRecordPatches(
@@ -5882,6 +5899,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
5882
5899
  tableId,
5883
5900
  wasPerson.rows.map((r) => ({ recordId: r.recordId, patch: { [field.key]: field.multi ? r.ids : r.ids[0] ?? null } }))
5884
5901
  );
5902
+ if (wordsWritten) await forgetWrittenWords(client, tableId, field.key, wordsWritten);
5885
5903
  }
5886
5904
  (0, import_react44.tableShapeChanged)(tableId);
5887
5905
  onRetyped?.();