@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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Changelog — @ai-matrx/records-ui
2
2
 
3
- ## 0.115.89
3
+ ## 0.115.90
4
4
 
5
5
  UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
6
6
  Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/records-ui/src`.
package/dist/index.cjs CHANGED
@@ -3302,6 +3302,23 @@ function personWordsWritten(rows, people, as) {
3302
3302
  function personWordsPatches(rows, people, key, as) {
3303
3303
  return Object.entries(personWordsWritten(rows, people, as)).map(([recordId, words2]) => ({ recordId, patch: { [key]: words2 } }));
3304
3304
  }
3305
+ async function forgetWrittenWords(client, tableId, key, written) {
3306
+ const patches = [];
3307
+ for (let offset = 0; offset < CEILING; offset += PAGE) {
3308
+ const page = await client.list({ table_id: tableId, limit: PAGE, offset });
3309
+ if (!page.ok) throw new Error(refusalSentence(page.error));
3310
+ for (const row of page.data.rows) {
3311
+ const word = written[row.id];
3312
+ const kept = (row.document ?? {})["_retired"];
3313
+ if (word === void 0 || !Array.isArray(kept)) continue;
3314
+ const rest = kept.filter((e) => !(e?.key === key && e?.value === word));
3315
+ if (rest.length !== kept.length) patches.push({ recordId: row.id, patch: { _retired: rest } });
3316
+ }
3317
+ if (page.data.rows.length < PAGE) break;
3318
+ }
3319
+ await writeRecordPatches(client, tableId, patches);
3320
+ return patches.length;
3321
+ }
3305
3322
 
3306
3323
  // src/FieldRetype.tsx
3307
3324
  var import_jsx_runtime9 = require("react/jsx-runtime");
@@ -3431,7 +3448,7 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
3431
3448
  noun: "column",
3432
3449
  subject: name,
3433
3450
  undo: async () => {
3434
- const back = await client.migrateUndo({ migration_id: migration, ...wordsWritten ? { written: wordsWritten } : {} });
3451
+ const back = await client.migrateUndo({ migration_id: migration });
3435
3452
  if (!back.ok) throw new Error(refusalSentence(back.error));
3436
3453
  if (wasPerson) {
3437
3454
  await writeRecordPatches(
@@ -3439,6 +3456,7 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
3439
3456
  tableId,
3440
3457
  wasPerson.rows.map((r) => ({ recordId: r.recordId, patch: { [field2.key]: field2.multi ? r.ids : r.ids[0] ?? null } }))
3441
3458
  );
3459
+ if (wordsWritten) await forgetWrittenWords(client, tableId, field2.key, wordsWritten);
3442
3460
  }
3443
3461
  (0, import_react16.tableShapeChanged)(tableId);
3444
3462
  onRetyped?.();