@ai-matrx/records-ui 0.115.88 → 0.115.89

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.89
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,13 +3287,20 @@ 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;
3294
3299
  }
3295
- await writeRecordPatches(client, tableId, patches);
3296
- return patches.length;
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 } }));
3297
3304
  }
3298
3305
 
3299
3306
  // src/FieldRetype.tsx
@@ -3415,6 +3422,7 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
3415
3422
  setRefusal(null);
3416
3423
  let holding;
3417
3424
  let aside;
3425
+ let wordsWritten;
3418
3426
  const offerUndo = (migration) => {
3419
3427
  if (!migration || !notify?.reversible) return;
3420
3428
  const wasPerson = person && read && (to.id === "text" || to.id === "email") ? read : null;
@@ -3423,7 +3431,7 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
3423
3431
  noun: "column",
3424
3432
  subject: name,
3425
3433
  undo: async () => {
3426
- const back = await client.migrateUndo({ migration_id: migration });
3434
+ const back = await client.migrateUndo({ migration_id: migration, ...wordsWritten ? { written: wordsWritten } : {} });
3427
3435
  if (!back.ok) throw new Error(refusalSentence(back.error));
3428
3436
  if (wasPerson) {
3429
3437
  await writeRecordPatches(
@@ -3463,6 +3471,7 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
3463
3471
  if (person && read && (to.id === "text" || to.id === "email")) {
3464
3472
  const as = to.id === "email" ? "email" : "name";
3465
3473
  try {
3474
+ wordsWritten = personWordsWritten(read.rows, read.people, as);
3466
3475
  const written = await writePersonWords(client, tableId, read.rows, read.people, field2.key, as);
3467
3476
  holding = written;
3468
3477
  aside = read.rows.length - written;