@ai-matrx/records 0.99.28 → 0.99.29
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 +7 -0
- package/dist/{client-B7LYr-aE.d.cts → client-B7KEs9hi.d.cts} +10 -0
- package/dist/{client-m4soDpHA.d.ts → client-Dthx26hr.d.ts} +10 -0
- package/dist/core/index.cjs +76 -10
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +76 -10
- package/dist/core/index.js.map +1 -1
- package/dist/data/index.cjs +12 -1
- package/dist/data/index.cjs.map +1 -1
- package/dist/data/index.d.cts +1 -1
- package/dist/data/index.d.ts +1 -1
- package/dist/data/index.js +12 -1
- package/dist/data/index.js.map +1 -1
- package/dist/{declareTable-D5Zs-SjU.d.ts → declareTable-CvBu5dTJ.d.ts} +1 -1
- package/dist/{declareTable-Bnrzv-Bg.d.cts → declareTable-enQs2N0E.d.cts} +1 -1
- package/dist/first-page/index.d.cts +2 -0
- package/dist/first-page/index.d.ts +2 -0
- package/dist/index.cjs +64 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -3
- package/dist/index.d.ts +29 -3
- package/dist/index.js +64 -9
- package/dist/index.js.map +1 -1
- package/dist/questions/index.d.cts +1 -1
- package/dist/questions/index.d.ts +1 -1
- package/dist/react/index.cjs +78 -12
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +37 -1
- package/dist/react/index.d.ts +37 -1
- package/dist/react/index.js +78 -12
- package/dist/react/index.js.map +1 -1
- package/dist/setup/index.cjs +12 -1
- package/dist/setup/index.cjs.map +1 -1
- package/dist/setup/index.d.cts +1 -1
- package/dist/setup/index.d.ts +1 -1
- package/dist/setup/index.js +12 -1
- package/dist/setup/index.js.map +1 -1
- package/dist/typed-table/index.cjs +12 -1
- package/dist/typed-table/index.cjs.map +1 -1
- package/dist/typed-table/index.d.cts +2 -2
- package/dist/typed-table/index.d.ts +2 -2
- package/dist/typed-table/index.js +12 -1
- package/dist/typed-table/index.js.map +1 -1
- package/dist/views/index.d.cts +1 -1
- package/dist/views/index.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FieldDrift, R as RecordsClient } from './client-
|
|
1
|
+
import { F as FieldDrift, R as RecordsClient } from './client-Dthx26hr.js';
|
|
2
2
|
import { a as FieldTypeWord, N as NewFieldDeclaration } from './field-BHlhq24W.js';
|
|
3
3
|
import { U as Uuid, a as RecordsError } from './record-C8q21jjB.js';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FieldDrift, R as RecordsClient } from './client-
|
|
1
|
+
import { F as FieldDrift, R as RecordsClient } from './client-B7KEs9hi.cjs';
|
|
2
2
|
import { a as FieldTypeWord, N as NewFieldDeclaration } from './field-ppX29ddi.cjs';
|
|
3
3
|
import { U as Uuid, a as RecordsError } from './record-C8q21jjB.cjs';
|
|
4
4
|
|
|
@@ -882,6 +882,8 @@ interface Table {
|
|
|
882
882
|
row_order: string | null;
|
|
883
883
|
/** REC-14. Where this Table lives. Exactly one primary Home. */
|
|
884
884
|
home_id: Uuid | null;
|
|
885
|
+
/** The feature that keeps this Table out of the person's lists (`snapshot`, `copying`, …); absent for a person's own table. */
|
|
886
|
+
kept_for?: string | null;
|
|
885
887
|
/** REC-27. One of the nine, defined in code and not editable by Migration. */
|
|
886
888
|
is_kernel: boolean;
|
|
887
889
|
created_by: Uuid | null;
|
|
@@ -882,6 +882,8 @@ interface Table {
|
|
|
882
882
|
row_order: string | null;
|
|
883
883
|
/** REC-14. Where this Table lives. Exactly one primary Home. */
|
|
884
884
|
home_id: Uuid | null;
|
|
885
|
+
/** The feature that keeps this Table out of the person's lists (`snapshot`, `copying`, …); absent for a person's own table. */
|
|
886
|
+
kept_for?: string | null;
|
|
885
887
|
/** REC-27. One of the nine, defined in code and not editable by Migration. */
|
|
886
888
|
is_kernel: boolean;
|
|
887
889
|
created_by: Uuid | null;
|
package/dist/index.cjs
CHANGED
|
@@ -156,6 +156,7 @@ __export(src_exports, {
|
|
|
156
156
|
hasQuietHours: () => hasQuietHours,
|
|
157
157
|
highestLevel: () => highestLevel,
|
|
158
158
|
holdsARetiredChoice: () => holdsARetiredChoice,
|
|
159
|
+
idsOfCopies: () => idsOfCopies,
|
|
159
160
|
indexedDbStore: () => indexedDbStore,
|
|
160
161
|
isAddressValue: () => isAddressValue,
|
|
161
162
|
isArchiveLane: () => isArchiveLane,
|
|
@@ -231,6 +232,7 @@ __export(src_exports, {
|
|
|
231
232
|
removedChoicesInUse: () => removedChoicesInUse,
|
|
232
233
|
resolveObjectOrganization: () => resolveObjectOrganization,
|
|
233
234
|
restoreSnapshot: () => restoreSnapshot,
|
|
235
|
+
restoredBaseName: () => restoredBaseName,
|
|
234
236
|
richTextPlain: () => richTextPlain,
|
|
235
237
|
ruleThatRefuses: () => ruleThatRefuses,
|
|
236
238
|
rulesWithTopStar: () => rulesWithTopStar,
|
|
@@ -1964,6 +1966,9 @@ function moveConsequence(home, to) {
|
|
|
1964
1966
|
function baseCopyName(name) {
|
|
1965
1967
|
return `${name.trim() || "Base"} (copy)`;
|
|
1966
1968
|
}
|
|
1969
|
+
function restoredBaseName(name, on) {
|
|
1970
|
+
return `${name.trim() || "Base"} (restored ${on})`;
|
|
1971
|
+
}
|
|
1967
1972
|
async function duplicateBase(port, args) {
|
|
1968
1973
|
const made = [];
|
|
1969
1974
|
const pairs = {};
|
|
@@ -1983,10 +1988,21 @@ async function duplicateBase(port, args) {
|
|
|
1983
1988
|
}
|
|
1984
1989
|
const fin = args.tables.length > 1 ? await port.finish({ organizationId: args.organizationId, pairs }) : null;
|
|
1985
1990
|
if (fin && !fin.ok) return { ok: false, error: fin.error, stoppedAt: args.tables[args.tables.length - 1], made };
|
|
1991
|
+
let homeId = null;
|
|
1992
|
+
if (args.homeName && port.createHome && port.moveInto) {
|
|
1993
|
+
const home = await port.createHome(args.homeName);
|
|
1994
|
+
if (!home.ok) return { ok: false, error: home.error, stoppedAt: args.tables[args.tables.length - 1], made };
|
|
1995
|
+
homeId = home.data;
|
|
1996
|
+
for (const m of made) {
|
|
1997
|
+
const moved = await port.moveInto(m.copy.id, homeId);
|
|
1998
|
+
if (!moved.ok) return { ok: false, error: moved.error, stoppedAt: m.from, made };
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
1986
2001
|
const extras = await copyExtras(port, args.tables, pairs);
|
|
1987
2002
|
return {
|
|
1988
2003
|
ok: true,
|
|
1989
2004
|
data: {
|
|
2005
|
+
homeId,
|
|
1990
2006
|
pairs,
|
|
1991
2007
|
tables: made,
|
|
1992
2008
|
relinkedColumns: fin?.ok ? fin.data.relinked_columns : 0,
|
|
@@ -2001,10 +2017,47 @@ function pointAtCopies(doc, pairs) {
|
|
|
2001
2017
|
for (const [from, to] of Object.entries(pairs)) text = text.split(from).join(to);
|
|
2002
2018
|
return JSON.parse(text);
|
|
2003
2019
|
}
|
|
2020
|
+
function sentence(error) {
|
|
2021
|
+
const m = error?.message;
|
|
2022
|
+
return typeof m === "string" && m ? m : "the store gave no reason.";
|
|
2023
|
+
}
|
|
2024
|
+
function refusedSentence(data) {
|
|
2025
|
+
const errors = data?._errors;
|
|
2026
|
+
const lines = errors ? Object.entries(errors).map(([path, why]) => `${path}: ${why}`) : [];
|
|
2027
|
+
return lines.length ? lines.join("; ") : "the store gave no reason.";
|
|
2028
|
+
}
|
|
2029
|
+
async function idsOfCopies(port, pairs) {
|
|
2030
|
+
const ids = { ...pairs };
|
|
2031
|
+
if (!port.fieldsOf && !port.viewsOf) return ids;
|
|
2032
|
+
for (const [from, to] of Object.entries(pairs)) {
|
|
2033
|
+
if (port.fieldsOf) {
|
|
2034
|
+
const [a, b] = await Promise.all([port.fieldsOf(from), port.fieldsOf(to)]);
|
|
2035
|
+
if (a.ok && b.ok) {
|
|
2036
|
+
const byKey = new Map(b.data.map((f) => [f.key, f.id]));
|
|
2037
|
+
for (const f of a.data) {
|
|
2038
|
+
const n = byKey.get(f.key);
|
|
2039
|
+
if (n && n !== f.id) ids[f.id] = n;
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
if (port.viewsOf) {
|
|
2044
|
+
const [a, b] = await Promise.all([port.viewsOf(from), port.viewsOf(to)]);
|
|
2045
|
+
if (a.ok && b.ok) {
|
|
2046
|
+
const byName = new Map(b.data.map((v) => [v.name, v.id]));
|
|
2047
|
+
for (const v of a.data) {
|
|
2048
|
+
const n = byName.get(v.name);
|
|
2049
|
+
if (n && n !== v.id) ids[v.id] = n;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
return ids;
|
|
2055
|
+
}
|
|
2004
2056
|
async function copyExtras(port, tables, pairs) {
|
|
2005
2057
|
let automations = 0;
|
|
2006
2058
|
let pages = 0;
|
|
2007
2059
|
const extrasRefused = [];
|
|
2060
|
+
const ids = await idsOfCopies(port, pairs);
|
|
2008
2061
|
for (const t of tables) {
|
|
2009
2062
|
const copy = pairs[t.id];
|
|
2010
2063
|
if (!copy) continue;
|
|
@@ -2012,13 +2065,14 @@ async function copyExtras(port, tables, pairs) {
|
|
|
2012
2065
|
const list = await port.automations(t.id);
|
|
2013
2066
|
if (list.ok) {
|
|
2014
2067
|
for (const a of list.data.automations) {
|
|
2015
|
-
const made = await port.automationDeclare({ table_id: copy, spec: pointAtCopies(a.spec,
|
|
2068
|
+
const made = await port.automationDeclare({ table_id: copy, spec: pointAtCopies(a.spec, ids) });
|
|
2016
2069
|
if (made.ok && made.data.ok && made.data.automation_id) {
|
|
2017
|
-
await port.automationSetEnabled?.({ automation_id: made.data.automation_id, enabled: false });
|
|
2018
|
-
|
|
2019
|
-
|
|
2070
|
+
const off = await port.automationSetEnabled?.({ automation_id: made.data.automation_id, enabled: false });
|
|
2071
|
+
if (off && !off.ok) extrasRefused.push(`Automation "${a.name}" on ${t.name} was copied but could not be switched off: ${sentence(off.error)}`);
|
|
2072
|
+
else automations += 1;
|
|
2073
|
+
} else extrasRefused.push(`Automation "${a.name}" on ${t.name} was not copied: ${made.ok ? refusedSentence(made.data) : sentence(made.error)}`);
|
|
2020
2074
|
}
|
|
2021
|
-
}
|
|
2075
|
+
} else extrasRefused.push(`The automations of ${t.name} could not be read: ${sentence(list.error)}`);
|
|
2022
2076
|
}
|
|
2023
2077
|
if (port.dashboards && port.dashboardDeclare) {
|
|
2024
2078
|
const list = await port.dashboards(t.id);
|
|
@@ -2027,13 +2081,13 @@ async function copyExtras(port, tables, pairs) {
|
|
|
2027
2081
|
const made = await port.dashboardDeclare({
|
|
2028
2082
|
table_id: copy,
|
|
2029
2083
|
name: d.name,
|
|
2030
|
-
blocks: pointAtCopies(d.blocks,
|
|
2031
|
-
presentation: pointAtCopies(d.presentation,
|
|
2084
|
+
blocks: pointAtCopies(d.blocks, ids),
|
|
2085
|
+
presentation: pointAtCopies(d.presentation, ids)
|
|
2032
2086
|
});
|
|
2033
2087
|
if (made.ok) pages += 1;
|
|
2034
|
-
else extrasRefused.push(`Page "${d.name}" on ${t.name} was not copied
|
|
2088
|
+
else extrasRefused.push(`Page "${d.name}" on ${t.name} was not copied: ${sentence(made.error)}`);
|
|
2035
2089
|
}
|
|
2036
|
-
}
|
|
2090
|
+
} else extrasRefused.push(`The pages of ${t.name} could not be read: ${sentence(list.error)}`);
|
|
2037
2091
|
}
|
|
2038
2092
|
}
|
|
2039
2093
|
return { automations, pages, extrasRefused };
|
|
@@ -2072,6 +2126,7 @@ async function restoreSnapshot(port, args) {
|
|
|
2072
2126
|
tables: sources,
|
|
2073
2127
|
withRecords: true,
|
|
2074
2128
|
nameFor: (t) => `${byCopy.get(t.id) ?? t.name} (restored)`,
|
|
2129
|
+
homeName: restoredBaseName(args.baseName ?? "Base", args.restoredOn ?? (/* @__PURE__ */ new Date()).toLocaleDateString()),
|
|
2075
2130
|
...args.onProgress ? { onProgress: args.onProgress } : {}
|
|
2076
2131
|
});
|
|
2077
2132
|
for (const s of sources) await port.archive?.(s.id);
|