@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.cjs
CHANGED
|
@@ -4547,6 +4547,10 @@ function knownPerson(id) {
|
|
|
4547
4547
|
return null;
|
|
4548
4548
|
}
|
|
4549
4549
|
|
|
4550
|
+
// src/recordVersions.ts
|
|
4551
|
+
var recordVersions_exports = {};
|
|
4552
|
+
__reExport(recordVersions_exports, require("@ai-matrx/records/versions"));
|
|
4553
|
+
|
|
4550
4554
|
// src/memberNames.ts
|
|
4551
4555
|
var import_react36 = require("react");
|
|
4552
4556
|
var import_react37 = require("@ai-matrx/records/react");
|
|
@@ -5665,7 +5669,7 @@ async function readPersonColumn(client, tableId, key) {
|
|
|
5665
5669
|
const out = [];
|
|
5666
5670
|
for (let offset = 0; offset < CEILING; offset += PAGE) {
|
|
5667
5671
|
const page = await client.list({ table_id: tableId, limit: PAGE, offset });
|
|
5668
|
-
if (!page.ok) throw new Error(page.error
|
|
5672
|
+
if (!page.ok) throw new Error(refusalSentence(page.error));
|
|
5669
5673
|
for (const row of page.data.rows) {
|
|
5670
5674
|
const doc = row.document ?? {};
|
|
5671
5675
|
let ids = idsIn(doc[key]);
|
|
@@ -5703,17 +5707,36 @@ function previewPersonWords(rows, people, as) {
|
|
|
5703
5707
|
}
|
|
5704
5708
|
return { converts, keptAside, examples, partial: false };
|
|
5705
5709
|
}
|
|
5710
|
+
async function versionsNow(client, ids) {
|
|
5711
|
+
const out = /* @__PURE__ */ new Map();
|
|
5712
|
+
for (let i = 0; i < ids.length; i += 200) {
|
|
5713
|
+
const got = await client.recordHeaders({ ids: ids.slice(i, i + 200) });
|
|
5714
|
+
if (!got.ok) throw new Error(refusalSentence(got.error));
|
|
5715
|
+
for (const h of got.data ?? []) if (typeof h.version === "number") out.set(h.id, h.version);
|
|
5716
|
+
}
|
|
5717
|
+
return out;
|
|
5718
|
+
}
|
|
5719
|
+
async function writeRecordPatches(client, tableId, patches) {
|
|
5720
|
+
const versions = await versionsNow(client, patches.map((p) => p.recordId));
|
|
5721
|
+
for (let i = 0; i < patches.length; i += 100) {
|
|
5722
|
+
const changes = patches.slice(i, i + 100).map((p) => ({
|
|
5723
|
+
op: "update",
|
|
5724
|
+
record_id: p.recordId,
|
|
5725
|
+
patch: p.patch,
|
|
5726
|
+
expected_version: versions.get(p.recordId) ?? null
|
|
5727
|
+
}));
|
|
5728
|
+
const done = await (0, recordVersions_exports.changeRecordsAt)(client, { table_id: tableId, changes });
|
|
5729
|
+
if (!done.ok) throw new Error(refusalSentence(done.error));
|
|
5730
|
+
}
|
|
5731
|
+
}
|
|
5706
5732
|
async function writePersonWords(client, tableId, rows, people, key, as) {
|
|
5707
|
-
const
|
|
5733
|
+
const patches = [];
|
|
5708
5734
|
for (const row of rows) {
|
|
5709
5735
|
const words = wordsFor(row.ids, people, as);
|
|
5710
|
-
if (words !== null)
|
|
5711
|
-
}
|
|
5712
|
-
for (let i = 0; i < changes.length; i += 100) {
|
|
5713
|
-
const done = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
|
|
5714
|
-
if (!done.ok) throw new Error(done.error.message ?? "The words could not be written");
|
|
5736
|
+
if (words !== null) patches.push({ recordId: row.recordId, patch: { [key]: words } });
|
|
5715
5737
|
}
|
|
5716
|
-
|
|
5738
|
+
await writeRecordPatches(client, tableId, patches);
|
|
5739
|
+
return patches.length;
|
|
5717
5740
|
}
|
|
5718
5741
|
|
|
5719
5742
|
// src/FieldRetype.tsx
|
|
@@ -5835,6 +5858,28 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5835
5858
|
setRefusal(null);
|
|
5836
5859
|
let holding;
|
|
5837
5860
|
let aside;
|
|
5861
|
+
const offerUndo = (migration) => {
|
|
5862
|
+
if (!migration || !notify?.reversible) return;
|
|
5863
|
+
const wasPerson = person && read && (to.id === "text" || to.id === "email") ? read : null;
|
|
5864
|
+
notify.reversible({
|
|
5865
|
+
verb: "change",
|
|
5866
|
+
noun: "column",
|
|
5867
|
+
subject: name,
|
|
5868
|
+
undo: async () => {
|
|
5869
|
+
const back = await client.migrateUndo({ migration_id: migration });
|
|
5870
|
+
if (!back.ok) throw new Error(refusalSentence(back.error));
|
|
5871
|
+
if (wasPerson) {
|
|
5872
|
+
await writeRecordPatches(
|
|
5873
|
+
client,
|
|
5874
|
+
tableId,
|
|
5875
|
+
wasPerson.rows.map((r) => ({ recordId: r.recordId, patch: { [field.key]: field.multi ? r.ids : r.ids[0] ?? null } }))
|
|
5876
|
+
);
|
|
5877
|
+
}
|
|
5878
|
+
(0, import_react44.tableShapeChanged)(tableId);
|
|
5879
|
+
onRetyped?.();
|
|
5880
|
+
}
|
|
5881
|
+
});
|
|
5882
|
+
};
|
|
5838
5883
|
if (to.via !== "behaviour") {
|
|
5839
5884
|
const done = await client.fieldUpdate({ field_id: field.id, patch: { parity_type: to.parity } });
|
|
5840
5885
|
setBusy(false);
|
|
@@ -5844,6 +5889,9 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5844
5889
|
}
|
|
5845
5890
|
holding = preview?.converts ?? 0;
|
|
5846
5891
|
aside = preview?.keptAside ?? 0;
|
|
5892
|
+
const recorded = await client.migrations({ target_id: field.id, limit: 1 });
|
|
5893
|
+
const newest = recorded.ok ? recorded.data[0] : void 0;
|
|
5894
|
+
if (newest && !newest.undone_at) offerUndo(newest.id);
|
|
5847
5895
|
} else {
|
|
5848
5896
|
const done = await client.migrateRetype({ field_id: field.id, to: to.behaviour });
|
|
5849
5897
|
setBusy(false);
|
|
@@ -5853,27 +5901,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5853
5901
|
}
|
|
5854
5902
|
holding = done.data.records_still_holding_a_value ?? 0;
|
|
5855
5903
|
aside = done.data.values_in_retired_for_this_field ?? 0;
|
|
5856
|
-
|
|
5857
|
-
if (migration && notify?.reversible) {
|
|
5858
|
-
notify.reversible({
|
|
5859
|
-
verb: "change",
|
|
5860
|
-
noun: "column",
|
|
5861
|
-
subject: name,
|
|
5862
|
-
undo: async () => {
|
|
5863
|
-
const back = await client.migrateUndo({ migration_id: migration });
|
|
5864
|
-
if (!back.ok) throw new Error(refusalSentence(back.error));
|
|
5865
|
-
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
5866
|
-
const changes = read.rows.map((r) => ({ op: "update", record_id: r.recordId, patch: { [field.key]: field.multi ? r.ids : r.ids[0] ?? null } }));
|
|
5867
|
-
for (let i = 0; i < changes.length; i += 100) {
|
|
5868
|
-
const put = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
|
|
5869
|
-
if (!put.ok) throw new Error(refusalSentence(put.error));
|
|
5870
|
-
}
|
|
5871
|
-
}
|
|
5872
|
-
(0, import_react44.tableShapeChanged)(tableId);
|
|
5873
|
-
onRetyped?.();
|
|
5874
|
-
}
|
|
5875
|
-
});
|
|
5876
|
-
}
|
|
5904
|
+
offerUndo(done.data.migration_id);
|
|
5877
5905
|
}
|
|
5878
5906
|
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
5879
5907
|
const as = to.id === "email" ? "email" : "name";
|