@ai-matrx/records-ui 0.115.86 → 0.115.87

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.86
3
+ ## 0.115.87
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
@@ -3392,6 +3392,28 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
3392
3392
  setRefusal(null);
3393
3393
  let holding;
3394
3394
  let aside;
3395
+ const offerUndo = (migration) => {
3396
+ if (!migration || !notify?.reversible) return;
3397
+ const wasPerson = person && read && (to.id === "text" || to.id === "email") ? read : null;
3398
+ notify.reversible({
3399
+ verb: "change",
3400
+ noun: "column",
3401
+ subject: name,
3402
+ undo: async () => {
3403
+ const back = await client.migrateUndo({ migration_id: migration });
3404
+ if (!back.ok) throw new Error(refusalSentence(back.error));
3405
+ if (wasPerson) {
3406
+ const changes = wasPerson.rows.map((r) => ({ op: "update", record_id: r.recordId, patch: { [field2.key]: field2.multi ? r.ids : r.ids[0] ?? null } }));
3407
+ for (let i = 0; i < changes.length; i += 100) {
3408
+ const put = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
3409
+ if (!put.ok) throw new Error(refusalSentence(put.error));
3410
+ }
3411
+ }
3412
+ (0, import_react16.tableShapeChanged)(tableId);
3413
+ onRetyped?.();
3414
+ }
3415
+ });
3416
+ };
3395
3417
  if (to.via !== "behaviour") {
3396
3418
  const done = await client.fieldUpdate({ field_id: field2.id, patch: { parity_type: to.parity } });
3397
3419
  setBusy(false);
@@ -3401,6 +3423,9 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
3401
3423
  }
3402
3424
  holding = preview?.converts ?? 0;
3403
3425
  aside = preview?.keptAside ?? 0;
3426
+ const recorded = await client.migrations({ target_id: field2.id, limit: 1 });
3427
+ const newest = recorded.ok ? recorded.data[0] : void 0;
3428
+ if (newest && !newest.undone_at) offerUndo(newest.id);
3404
3429
  } else {
3405
3430
  const done = await client.migrateRetype({ field_id: field2.id, to: to.behaviour });
3406
3431
  setBusy(false);
@@ -3410,27 +3435,7 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
3410
3435
  }
3411
3436
  holding = done.data.records_still_holding_a_value ?? 0;
3412
3437
  aside = done.data.values_in_retired_for_this_field ?? 0;
3413
- const migration = done.data.migration_id;
3414
- if (migration && notify?.reversible) {
3415
- notify.reversible({
3416
- verb: "change",
3417
- noun: "column",
3418
- subject: name,
3419
- undo: async () => {
3420
- const back = await client.migrateUndo({ migration_id: migration });
3421
- if (!back.ok) throw new Error(refusalSentence(back.error));
3422
- if (person && read && (to.id === "text" || to.id === "email")) {
3423
- const changes = read.rows.map((r) => ({ op: "update", record_id: r.recordId, patch: { [field2.key]: field2.multi ? r.ids : r.ids[0] ?? null } }));
3424
- for (let i = 0; i < changes.length; i += 100) {
3425
- const put = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
3426
- if (!put.ok) throw new Error(refusalSentence(put.error));
3427
- }
3428
- }
3429
- (0, import_react16.tableShapeChanged)(tableId);
3430
- onRetyped?.();
3431
- }
3432
- });
3433
- }
3438
+ offerUndo(done.data.migration_id);
3434
3439
  }
3435
3440
  if (person && read && (to.id === "text" || to.id === "email")) {
3436
3441
  const as = to.id === "email" ? "email" : "name";