@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.js CHANGED
@@ -5810,6 +5810,23 @@ function personWordsWritten(rows, people, as) {
5810
5810
  function personWordsPatches(rows, people, key, as) {
5811
5811
  return Object.entries(personWordsWritten(rows, people, as)).map(([recordId, words]) => ({ recordId, patch: { [key]: words } }));
5812
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;
5826
+ }
5827
+ await writeRecordPatches(client, tableId, patches);
5828
+ return patches.length;
5829
+ }
5813
5830
 
5814
5831
  // src/FieldRetype.tsx
5815
5832
  import { jsx as jsx27, jsxs as jsxs25 } from "react/jsx-runtime";
@@ -5939,7 +5956,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
5939
5956
  noun: "column",
5940
5957
  subject: name,
5941
5958
  undo: async () => {
5942
- const back = await client.migrateUndo({ migration_id: migration, ...wordsWritten ? { written: wordsWritten } : {} });
5959
+ const back = await client.migrateUndo({ migration_id: migration });
5943
5960
  if (!back.ok) throw new Error(refusalSentence(back.error));
5944
5961
  if (wasPerson) {
5945
5962
  await writeRecordPatches(
@@ -5947,6 +5964,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
5947
5964
  tableId,
5948
5965
  wasPerson.rows.map((r) => ({ recordId: r.recordId, patch: { [field.key]: field.multi ? r.ids : r.ids[0] ?? null } }))
5949
5966
  );
5967
+ if (wordsWritten) await forgetWrittenWords(client, tableId, field.key, wordsWritten);
5950
5968
  }
5951
5969
  tableShapeChanged2(tableId);
5952
5970
  onRetyped?.();