@ai-matrx/records-ui 0.115.87 → 0.115.88

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,28 @@
1
1
  # Changelog — @ai-matrx/records-ui
2
2
 
3
- ## 0.115.87
3
+ ## 0.115.88
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.87
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 14f33fb01d 4703c9c0bf -- apps/shared/records-ui/src`
13
+
14
+ Changed shipped source files (1):
15
+ - `apps/shared/records-ui/src/FieldRetype.tsx`
16
+
17
+ ## 0.115.86
18
+
19
+ SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
20
+ so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
21
+ Diff: `git diff 7b1d72070c 14f33fb01d -- apps/shared/records-ui/src`
22
+
23
+ Changed shipped source files (1):
24
+ - `apps/shared/records-ui/src/cellMarks.tsx`
25
+
8
26
  ## 0.115.85
9
27
 
10
28
  SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
package/dist/index.cjs CHANGED
@@ -3212,6 +3212,10 @@ function useKeptPeople(value, roster) {
3212
3212
  return people;
3213
3213
  }
3214
3214
 
3215
+ // src/recordVersions.ts
3216
+ var recordVersions_exports = {};
3217
+ __reExport(recordVersions_exports, require("@ai-matrx/records/versions"));
3218
+
3215
3219
  // src/personRetype.ts
3216
3220
  var PAGE = 500;
3217
3221
  var CEILING = 2e4;
@@ -3222,7 +3226,7 @@ async function readPersonColumn(client, tableId, key) {
3222
3226
  const out = [];
3223
3227
  for (let offset = 0; offset < CEILING; offset += PAGE) {
3224
3228
  const page = await client.list({ table_id: tableId, limit: PAGE, offset });
3225
- if (!page.ok) throw new Error(page.error.message ?? "The records could not be read");
3229
+ if (!page.ok) throw new Error(refusalSentence(page.error));
3226
3230
  for (const row of page.data.rows) {
3227
3231
  const doc = row.document ?? {};
3228
3232
  let ids = idsIn(doc[key]);
@@ -3260,17 +3264,36 @@ function previewPersonWords(rows, people, as) {
3260
3264
  }
3261
3265
  return { converts, keptAside, examples, partial: false };
3262
3266
  }
3267
+ async function versionsNow(client, ids) {
3268
+ const out = /* @__PURE__ */ new Map();
3269
+ for (let i = 0; i < ids.length; i += 200) {
3270
+ const got = await client.recordHeaders({ ids: ids.slice(i, i + 200) });
3271
+ if (!got.ok) throw new Error(refusalSentence(got.error));
3272
+ for (const h of got.data ?? []) if (typeof h.version === "number") out.set(h.id, h.version);
3273
+ }
3274
+ return out;
3275
+ }
3276
+ async function writeRecordPatches(client, tableId, patches) {
3277
+ const versions = await versionsNow(client, patches.map((p) => p.recordId));
3278
+ for (let i = 0; i < patches.length; i += 100) {
3279
+ const changes = patches.slice(i, i + 100).map((p) => ({
3280
+ op: "update",
3281
+ record_id: p.recordId,
3282
+ patch: p.patch,
3283
+ expected_version: versions.get(p.recordId) ?? null
3284
+ }));
3285
+ const done = await (0, recordVersions_exports.changeRecordsAt)(client, { table_id: tableId, changes });
3286
+ if (!done.ok) throw new Error(refusalSentence(done.error));
3287
+ }
3288
+ }
3263
3289
  async function writePersonWords(client, tableId, rows, people, key, as) {
3264
- const changes = [];
3290
+ const patches = [];
3265
3291
  for (const row of rows) {
3266
3292
  const words2 = wordsFor(row.ids, people, as);
3267
- if (words2 !== null) changes.push({ op: "update", record_id: row.recordId, patch: { [key]: words2 } });
3293
+ if (words2 !== null) patches.push({ recordId: row.recordId, patch: { [key]: words2 } });
3268
3294
  }
3269
- for (let i = 0; i < changes.length; i += 100) {
3270
- const done = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
3271
- if (!done.ok) throw new Error(done.error.message ?? "The words could not be written");
3272
- }
3273
- return changes.length;
3295
+ await writeRecordPatches(client, tableId, patches);
3296
+ return patches.length;
3274
3297
  }
3275
3298
 
3276
3299
  // src/FieldRetype.tsx
@@ -3403,11 +3426,11 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
3403
3426
  const back = await client.migrateUndo({ migration_id: migration });
3404
3427
  if (!back.ok) throw new Error(refusalSentence(back.error));
3405
3428
  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
- }
3429
+ await writeRecordPatches(
3430
+ client,
3431
+ tableId,
3432
+ wasPerson.rows.map((r) => ({ recordId: r.recordId, patch: { [field2.key]: field2.multi ? r.ids : r.ids[0] ?? null } }))
3433
+ );
3411
3434
  }
3412
3435
  (0, import_react16.tableShapeChanged)(tableId);
3413
3436
  onRetyped?.();
@@ -3951,10 +3974,6 @@ function groupsOf(options) {
3951
3974
  return out;
3952
3975
  }
3953
3976
 
3954
- // src/recordVersions.ts
3955
- var recordVersions_exports = {};
3956
- __reExport(recordVersions_exports, require("@ai-matrx/records/versions"));
3957
-
3958
3977
  // src/writeOnTheWinningVersion.ts
3959
3978
  var writeOnTheWinningVersion_exports = {};
3960
3979
  __reExport(writeOnTheWinningVersion_exports, require("@ai-matrx/records/versions"));
@@ -54476,7 +54495,11 @@ function TablePage({
54476
54495
  setOpenRecord(activeRecordId);
54477
54496
  setSurface((now) => ({ ...now, rail: "record" }));
54478
54497
  }, [activeRecordId]);
54479
- const [shownIds, setShownIds] = (0, import_react318.useState)([]);
54498
+ const [shownIds, setShownIdsRaw] = (0, import_react318.useState)([]);
54499
+ const setShownIds = (0, import_react318.useCallback)(
54500
+ (next) => setShownIdsRaw((prev) => prev.length === next.length && prev.every((id, i) => id === next[i]) ? prev : next),
54501
+ []
54502
+ );
54480
54503
  const [recordExpanded, setRecordExpanded] = (0, import_react318.useState)(false);
54481
54504
  const shownRecord = rail === "record" ? openRecord : null;
54482
54505
  const reportedRecord = (0, import_react318.useRef)(activeRecordId ?? null);