@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 +19 -1
- package/dist/index.cjs +41 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +42 -19
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +36 -13
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +37 -13
- package/dist/pickers.js.map +1 -1
- package/package.json +3 -3
package/dist/pickers.js
CHANGED
|
@@ -4611,6 +4611,11 @@ function knownPerson(id) {
|
|
|
4611
4611
|
return null;
|
|
4612
4612
|
}
|
|
4613
4613
|
|
|
4614
|
+
// src/recordVersions.ts
|
|
4615
|
+
var recordVersions_exports = {};
|
|
4616
|
+
__reExport(recordVersions_exports, versions_star3);
|
|
4617
|
+
import * as versions_star3 from "@ai-matrx/records/versions";
|
|
4618
|
+
|
|
4614
4619
|
// src/memberNames.ts
|
|
4615
4620
|
import { useEffect as useEffect13, useMemo as useMemo10, useState as useState19 } from "react";
|
|
4616
4621
|
import { useOptionalRecordsClient as useOptionalRecordsClient7 } from "@ai-matrx/records/react";
|
|
@@ -5729,7 +5734,7 @@ async function readPersonColumn(client, tableId, key) {
|
|
|
5729
5734
|
const out = [];
|
|
5730
5735
|
for (let offset = 0; offset < CEILING; offset += PAGE) {
|
|
5731
5736
|
const page = await client.list({ table_id: tableId, limit: PAGE, offset });
|
|
5732
|
-
if (!page.ok) throw new Error(page.error
|
|
5737
|
+
if (!page.ok) throw new Error(refusalSentence(page.error));
|
|
5733
5738
|
for (const row of page.data.rows) {
|
|
5734
5739
|
const doc = row.document ?? {};
|
|
5735
5740
|
let ids = idsIn(doc[key]);
|
|
@@ -5767,17 +5772,36 @@ function previewPersonWords(rows, people, as) {
|
|
|
5767
5772
|
}
|
|
5768
5773
|
return { converts, keptAside, examples, partial: false };
|
|
5769
5774
|
}
|
|
5775
|
+
async function versionsNow(client, ids) {
|
|
5776
|
+
const out = /* @__PURE__ */ new Map();
|
|
5777
|
+
for (let i = 0; i < ids.length; i += 200) {
|
|
5778
|
+
const got = await client.recordHeaders({ ids: ids.slice(i, i + 200) });
|
|
5779
|
+
if (!got.ok) throw new Error(refusalSentence(got.error));
|
|
5780
|
+
for (const h of got.data ?? []) if (typeof h.version === "number") out.set(h.id, h.version);
|
|
5781
|
+
}
|
|
5782
|
+
return out;
|
|
5783
|
+
}
|
|
5784
|
+
async function writeRecordPatches(client, tableId, patches) {
|
|
5785
|
+
const versions = await versionsNow(client, patches.map((p) => p.recordId));
|
|
5786
|
+
for (let i = 0; i < patches.length; i += 100) {
|
|
5787
|
+
const changes = patches.slice(i, i + 100).map((p) => ({
|
|
5788
|
+
op: "update",
|
|
5789
|
+
record_id: p.recordId,
|
|
5790
|
+
patch: p.patch,
|
|
5791
|
+
expected_version: versions.get(p.recordId) ?? null
|
|
5792
|
+
}));
|
|
5793
|
+
const done = await (0, recordVersions_exports.changeRecordsAt)(client, { table_id: tableId, changes });
|
|
5794
|
+
if (!done.ok) throw new Error(refusalSentence(done.error));
|
|
5795
|
+
}
|
|
5796
|
+
}
|
|
5770
5797
|
async function writePersonWords(client, tableId, rows, people, key, as) {
|
|
5771
|
-
const
|
|
5798
|
+
const patches = [];
|
|
5772
5799
|
for (const row of rows) {
|
|
5773
5800
|
const words = wordsFor(row.ids, people, as);
|
|
5774
|
-
if (words !== null)
|
|
5775
|
-
}
|
|
5776
|
-
for (let i = 0; i < changes.length; i += 100) {
|
|
5777
|
-
const done = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
|
|
5778
|
-
if (!done.ok) throw new Error(done.error.message ?? "The words could not be written");
|
|
5801
|
+
if (words !== null) patches.push({ recordId: row.recordId, patch: { [key]: words } });
|
|
5779
5802
|
}
|
|
5780
|
-
|
|
5803
|
+
await writeRecordPatches(client, tableId, patches);
|
|
5804
|
+
return patches.length;
|
|
5781
5805
|
}
|
|
5782
5806
|
|
|
5783
5807
|
// src/FieldRetype.tsx
|
|
@@ -5910,11 +5934,11 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5910
5934
|
const back = await client.migrateUndo({ migration_id: migration });
|
|
5911
5935
|
if (!back.ok) throw new Error(refusalSentence(back.error));
|
|
5912
5936
|
if (wasPerson) {
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5937
|
+
await writeRecordPatches(
|
|
5938
|
+
client,
|
|
5939
|
+
tableId,
|
|
5940
|
+
wasPerson.rows.map((r) => ({ recordId: r.recordId, patch: { [field.key]: field.multi ? r.ids : r.ids[0] ?? null } }))
|
|
5941
|
+
);
|
|
5918
5942
|
}
|
|
5919
5943
|
tableShapeChanged2(tableId);
|
|
5920
5944
|
onRetyped?.();
|