@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 CHANGED
@@ -1,10 +1,21 @@
1
1
  # Changelog — @ai-matrx/records-ui
2
2
 
3
- ## 0.115.88
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`.
7
7
 
8
+ ## 0.115.88
9
+
10
+ SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
11
+ so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
12
+ Diff: `git diff 4703c9c0bf 7560bf9edf -- apps/shared/records-ui/src`
13
+
14
+ Changed shipped source files (3):
15
+ - `apps/shared/records-ui/src/FieldRetype.tsx`
16
+ - `apps/shared/records-ui/src/TablePage.tsx`
17
+ - `apps/shared/records-ui/src/personRetype.ts`
18
+
8
19
  ## 0.115.87
9
20
 
10
21
  SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
package/dist/index.cjs CHANGED
@@ -3287,10 +3287,34 @@ async function writeRecordPatches(client, tableId, patches) {
3287
3287
  }
3288
3288
  }
3289
3289
  async function writePersonWords(client, tableId, rows, people, key, as) {
3290
- const patches = [];
3290
+ const patches = personWordsPatches(rows, people, key, as);
3291
+ await writeRecordPatches(client, tableId, patches);
3292
+ return patches.length;
3293
+ }
3294
+ function personWordsWritten(rows, people, as) {
3295
+ const out = {};
3291
3296
  for (const row of rows) {
3292
3297
  const words2 = wordsFor(row.ids, people, as);
3293
- if (words2 !== null) patches.push({ recordId: row.recordId, patch: { [key]: words2 } });
3298
+ if (words2 !== null) out[row.recordId] = words2;
3299
+ }
3300
+ return out;
3301
+ }
3302
+ function personWordsPatches(rows, people, key, as) {
3303
+ return Object.entries(personWordsWritten(rows, people, as)).map(([recordId, words2]) => ({ recordId, patch: { [key]: words2 } }));
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;
3294
3318
  }
3295
3319
  await writeRecordPatches(client, tableId, patches);
3296
3320
  return patches.length;
@@ -3415,6 +3439,7 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
3415
3439
  setRefusal(null);
3416
3440
  let holding;
3417
3441
  let aside;
3442
+ let wordsWritten;
3418
3443
  const offerUndo = (migration) => {
3419
3444
  if (!migration || !notify?.reversible) return;
3420
3445
  const wasPerson = person && read && (to.id === "text" || to.id === "email") ? read : null;
@@ -3431,6 +3456,7 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
3431
3456
  tableId,
3432
3457
  wasPerson.rows.map((r) => ({ recordId: r.recordId, patch: { [field2.key]: field2.multi ? r.ids : r.ids[0] ?? null } }))
3433
3458
  );
3459
+ if (wordsWritten) await forgetWrittenWords(client, tableId, field2.key, wordsWritten);
3434
3460
  }
3435
3461
  (0, import_react16.tableShapeChanged)(tableId);
3436
3462
  onRetyped?.();
@@ -3463,6 +3489,7 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
3463
3489
  if (person && read && (to.id === "text" || to.id === "email")) {
3464
3490
  const as = to.id === "email" ? "email" : "name";
3465
3491
  try {
3492
+ wordsWritten = personWordsWritten(read.rows, read.people, as);
3466
3493
  const written = await writePersonWords(client, tableId, read.rows, read.people, field2.key, as);
3467
3494
  holding = written;
3468
3495
  aside = read.rows.length - written;