@ai-matrx/records-ui 0.115.86 → 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 +62 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +63 -35
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +57 -29
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +58 -29
- package/dist/pickers.js.map +1 -1
- package/package.json +4 -4
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
|
|
@@ -5899,6 +5923,28 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5899
5923
|
setRefusal(null);
|
|
5900
5924
|
let holding;
|
|
5901
5925
|
let aside;
|
|
5926
|
+
const offerUndo = (migration) => {
|
|
5927
|
+
if (!migration || !notify?.reversible) return;
|
|
5928
|
+
const wasPerson = person && read && (to.id === "text" || to.id === "email") ? read : null;
|
|
5929
|
+
notify.reversible({
|
|
5930
|
+
verb: "change",
|
|
5931
|
+
noun: "column",
|
|
5932
|
+
subject: name,
|
|
5933
|
+
undo: async () => {
|
|
5934
|
+
const back = await client.migrateUndo({ migration_id: migration });
|
|
5935
|
+
if (!back.ok) throw new Error(refusalSentence(back.error));
|
|
5936
|
+
if (wasPerson) {
|
|
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
|
+
);
|
|
5942
|
+
}
|
|
5943
|
+
tableShapeChanged2(tableId);
|
|
5944
|
+
onRetyped?.();
|
|
5945
|
+
}
|
|
5946
|
+
});
|
|
5947
|
+
};
|
|
5902
5948
|
if (to.via !== "behaviour") {
|
|
5903
5949
|
const done = await client.fieldUpdate({ field_id: field.id, patch: { parity_type: to.parity } });
|
|
5904
5950
|
setBusy(false);
|
|
@@ -5908,6 +5954,9 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5908
5954
|
}
|
|
5909
5955
|
holding = preview?.converts ?? 0;
|
|
5910
5956
|
aside = preview?.keptAside ?? 0;
|
|
5957
|
+
const recorded = await client.migrations({ target_id: field.id, limit: 1 });
|
|
5958
|
+
const newest = recorded.ok ? recorded.data[0] : void 0;
|
|
5959
|
+
if (newest && !newest.undone_at) offerUndo(newest.id);
|
|
5911
5960
|
} else {
|
|
5912
5961
|
const done = await client.migrateRetype({ field_id: field.id, to: to.behaviour });
|
|
5913
5962
|
setBusy(false);
|
|
@@ -5917,27 +5966,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5917
5966
|
}
|
|
5918
5967
|
holding = done.data.records_still_holding_a_value ?? 0;
|
|
5919
5968
|
aside = done.data.values_in_retired_for_this_field ?? 0;
|
|
5920
|
-
|
|
5921
|
-
if (migration && notify?.reversible) {
|
|
5922
|
-
notify.reversible({
|
|
5923
|
-
verb: "change",
|
|
5924
|
-
noun: "column",
|
|
5925
|
-
subject: name,
|
|
5926
|
-
undo: async () => {
|
|
5927
|
-
const back = await client.migrateUndo({ migration_id: migration });
|
|
5928
|
-
if (!back.ok) throw new Error(refusalSentence(back.error));
|
|
5929
|
-
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
5930
|
-
const changes = read.rows.map((r) => ({ op: "update", record_id: r.recordId, patch: { [field.key]: field.multi ? r.ids : r.ids[0] ?? null } }));
|
|
5931
|
-
for (let i = 0; i < changes.length; i += 100) {
|
|
5932
|
-
const put = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
|
|
5933
|
-
if (!put.ok) throw new Error(refusalSentence(put.error));
|
|
5934
|
-
}
|
|
5935
|
-
}
|
|
5936
|
-
tableShapeChanged2(tableId);
|
|
5937
|
-
onRetyped?.();
|
|
5938
|
-
}
|
|
5939
|
-
});
|
|
5940
|
-
}
|
|
5969
|
+
offerUndo(done.data.migration_id);
|
|
5941
5970
|
}
|
|
5942
5971
|
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
5943
5972
|
const as = to.id === "email" ? "email" : "name";
|