@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,5 +1,5 @@
|
|
|
1
1
|
import { A as AggregateBucket } from '../subscription-Ba8RKtPA.cjs';
|
|
2
|
-
import { R as RecordsClient } from '../client-
|
|
2
|
+
import { R as RecordsClient } from '../client-B7KEs9hi.cjs';
|
|
3
3
|
import { F as Field } from '../field-ppX29ddi.cjs';
|
|
4
4
|
import { H as HiddenFieldNotice, U as Uuid, R as RecordsResult } from '../record-C8q21jjB.cjs';
|
|
5
5
|
import { R as RuleExpression } from '../rule-BQwUtKk5.cjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as AggregateBucket } from '../subscription-eNzL9scc.js';
|
|
2
|
-
import { R as RecordsClient } from '../client-
|
|
2
|
+
import { R as RecordsClient } from '../client-Dthx26hr.js';
|
|
3
3
|
import { F as Field } from '../field-BHlhq24W.js';
|
|
4
4
|
import { H as HiddenFieldNotice, U as Uuid, R as RecordsResult } from '../record-C8q21jjB.js';
|
|
5
5
|
import { R as RuleExpression } from '../rule-cGqclk_0.js';
|
package/dist/react/index.cjs
CHANGED
|
@@ -181,6 +181,7 @@ __export(react_exports, {
|
|
|
181
181
|
hasQuietHours: () => hasQuietHours,
|
|
182
182
|
highestLevel: () => highestLevel,
|
|
183
183
|
holdsARetiredChoice: () => holdsARetiredChoice,
|
|
184
|
+
idsOfCopies: () => idsOfCopies,
|
|
184
185
|
indexedDbStore: () => indexedDbStore,
|
|
185
186
|
isAddressValue: () => isAddressValue,
|
|
186
187
|
isArchiveLane: () => isArchiveLane,
|
|
@@ -261,6 +262,7 @@ __export(react_exports, {
|
|
|
261
262
|
removedChoicesInUse: () => removedChoicesInUse,
|
|
262
263
|
resolveObjectOrganization: () => resolveObjectOrganization,
|
|
263
264
|
restoreSnapshot: () => restoreSnapshot,
|
|
265
|
+
restoredBaseName: () => restoredBaseName,
|
|
264
266
|
richTextPlain: () => richTextPlain,
|
|
265
267
|
rowFromDocument: () => rowFromDocument,
|
|
266
268
|
ruleThatRefuses: () => ruleThatRefuses,
|
|
@@ -6164,6 +6166,15 @@ function createRecordsClient(given) {
|
|
|
6164
6166
|
}
|
|
6165
6167
|
return result;
|
|
6166
6168
|
},
|
|
6169
|
+
async recordReparent({ record_id, parent_id }) {
|
|
6170
|
+
const result = await callDoor(
|
|
6171
|
+
DOORS.recordReparent,
|
|
6172
|
+
{ p_organization_id: org, p_record_id: record_id, p_parent_id: parent_id },
|
|
6173
|
+
"recordReparent"
|
|
6174
|
+
);
|
|
6175
|
+
if (result.ok) announceRecordChanged(record_id);
|
|
6176
|
+
return result;
|
|
6177
|
+
},
|
|
6167
6178
|
async recordRestore({ record_id }) {
|
|
6168
6179
|
const result = await callDoor(
|
|
6169
6180
|
DOORS.recordRestore,
|
|
@@ -6711,7 +6722,9 @@ function createRecordsClient(given) {
|
|
|
6711
6722
|
}
|
|
6712
6723
|
const tables = read.map((row) => {
|
|
6713
6724
|
const { document } = unfold(row.document);
|
|
6714
|
-
|
|
6725
|
+
const doc = document;
|
|
6726
|
+
const home = typeof doc.home_id === "string" ? doc.home_id : typeof doc.parent_id === "string" ? doc.parent_id : null;
|
|
6727
|
+
return { ...doc, home_id: home, id: row.id, organization_id: org };
|
|
6715
6728
|
});
|
|
6716
6729
|
tables.sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
|
|
6717
6730
|
return ok(tables);
|
|
@@ -12828,8 +12841,8 @@ var f = {
|
|
|
12828
12841
|
};
|
|
12829
12842
|
var SLUG = /^[a-z][a-z0-9_]*$/;
|
|
12830
12843
|
var WORD = /^[a-z][a-z0-9_]*$/;
|
|
12831
|
-
function refuse3(slug,
|
|
12832
|
-
throw new Error(`defineTypedTable(${JSON.stringify(slug)}): ${
|
|
12844
|
+
function refuse3(slug, sentence2) {
|
|
12845
|
+
throw new Error(`defineTypedTable(${JSON.stringify(slug)}): ${sentence2}`);
|
|
12833
12846
|
}
|
|
12834
12847
|
function labelFor(key) {
|
|
12835
12848
|
const words = key.replace(/_+/g, " ").trim();
|
|
@@ -13465,6 +13478,9 @@ function automationWebhookUrl(serverBase, item2) {
|
|
|
13465
13478
|
function baseCopyName(name) {
|
|
13466
13479
|
return `${name.trim() || "Base"} (copy)`;
|
|
13467
13480
|
}
|
|
13481
|
+
function restoredBaseName(name, on) {
|
|
13482
|
+
return `${name.trim() || "Base"} (restored ${on})`;
|
|
13483
|
+
}
|
|
13468
13484
|
async function duplicateBase(port, args) {
|
|
13469
13485
|
const made = [];
|
|
13470
13486
|
const pairs = {};
|
|
@@ -13484,10 +13500,21 @@ async function duplicateBase(port, args) {
|
|
|
13484
13500
|
}
|
|
13485
13501
|
const fin = args.tables.length > 1 ? await port.finish({ organizationId: args.organizationId, pairs }) : null;
|
|
13486
13502
|
if (fin && !fin.ok) return { ok: false, error: fin.error, stoppedAt: args.tables[args.tables.length - 1], made };
|
|
13503
|
+
let homeId = null;
|
|
13504
|
+
if (args.homeName && port.createHome && port.moveInto) {
|
|
13505
|
+
const home = await port.createHome(args.homeName);
|
|
13506
|
+
if (!home.ok) return { ok: false, error: home.error, stoppedAt: args.tables[args.tables.length - 1], made };
|
|
13507
|
+
homeId = home.data;
|
|
13508
|
+
for (const m of made) {
|
|
13509
|
+
const moved = await port.moveInto(m.copy.id, homeId);
|
|
13510
|
+
if (!moved.ok) return { ok: false, error: moved.error, stoppedAt: m.from, made };
|
|
13511
|
+
}
|
|
13512
|
+
}
|
|
13487
13513
|
const extras = await copyExtras(port, args.tables, pairs);
|
|
13488
13514
|
return {
|
|
13489
13515
|
ok: true,
|
|
13490
13516
|
data: {
|
|
13517
|
+
homeId,
|
|
13491
13518
|
pairs,
|
|
13492
13519
|
tables: made,
|
|
13493
13520
|
relinkedColumns: fin?.ok ? fin.data.relinked_columns : 0,
|
|
@@ -13502,10 +13529,47 @@ function pointAtCopies(doc, pairs) {
|
|
|
13502
13529
|
for (const [from, to] of Object.entries(pairs)) text2 = text2.split(from).join(to);
|
|
13503
13530
|
return JSON.parse(text2);
|
|
13504
13531
|
}
|
|
13532
|
+
function sentence(error) {
|
|
13533
|
+
const m = error?.message;
|
|
13534
|
+
return typeof m === "string" && m ? m : "the store gave no reason.";
|
|
13535
|
+
}
|
|
13536
|
+
function refusedSentence(data) {
|
|
13537
|
+
const errors = data?._errors;
|
|
13538
|
+
const lines = errors ? Object.entries(errors).map(([path, why]) => `${path}: ${why}`) : [];
|
|
13539
|
+
return lines.length ? lines.join("; ") : "the store gave no reason.";
|
|
13540
|
+
}
|
|
13541
|
+
async function idsOfCopies(port, pairs) {
|
|
13542
|
+
const ids = { ...pairs };
|
|
13543
|
+
if (!port.fieldsOf && !port.viewsOf) return ids;
|
|
13544
|
+
for (const [from, to] of Object.entries(pairs)) {
|
|
13545
|
+
if (port.fieldsOf) {
|
|
13546
|
+
const [a, b] = await Promise.all([port.fieldsOf(from), port.fieldsOf(to)]);
|
|
13547
|
+
if (a.ok && b.ok) {
|
|
13548
|
+
const byKey = new Map(b.data.map((f2) => [f2.key, f2.id]));
|
|
13549
|
+
for (const f2 of a.data) {
|
|
13550
|
+
const n = byKey.get(f2.key);
|
|
13551
|
+
if (n && n !== f2.id) ids[f2.id] = n;
|
|
13552
|
+
}
|
|
13553
|
+
}
|
|
13554
|
+
}
|
|
13555
|
+
if (port.viewsOf) {
|
|
13556
|
+
const [a, b] = await Promise.all([port.viewsOf(from), port.viewsOf(to)]);
|
|
13557
|
+
if (a.ok && b.ok) {
|
|
13558
|
+
const byName = new Map(b.data.map((v) => [v.name, v.id]));
|
|
13559
|
+
for (const v of a.data) {
|
|
13560
|
+
const n = byName.get(v.name);
|
|
13561
|
+
if (n && n !== v.id) ids[v.id] = n;
|
|
13562
|
+
}
|
|
13563
|
+
}
|
|
13564
|
+
}
|
|
13565
|
+
}
|
|
13566
|
+
return ids;
|
|
13567
|
+
}
|
|
13505
13568
|
async function copyExtras(port, tables, pairs) {
|
|
13506
13569
|
let automations = 0;
|
|
13507
13570
|
let pages = 0;
|
|
13508
13571
|
const extrasRefused = [];
|
|
13572
|
+
const ids = await idsOfCopies(port, pairs);
|
|
13509
13573
|
for (const t of tables) {
|
|
13510
13574
|
const copy = pairs[t.id];
|
|
13511
13575
|
if (!copy) continue;
|
|
@@ -13513,13 +13577,14 @@ async function copyExtras(port, tables, pairs) {
|
|
|
13513
13577
|
const list = await port.automations(t.id);
|
|
13514
13578
|
if (list.ok) {
|
|
13515
13579
|
for (const a of list.data.automations) {
|
|
13516
|
-
const made = await port.automationDeclare({ table_id: copy, spec: pointAtCopies(a.spec,
|
|
13580
|
+
const made = await port.automationDeclare({ table_id: copy, spec: pointAtCopies(a.spec, ids) });
|
|
13517
13581
|
if (made.ok && made.data.ok && made.data.automation_id) {
|
|
13518
|
-
await port.automationSetEnabled?.({ automation_id: made.data.automation_id, enabled: false });
|
|
13519
|
-
|
|
13520
|
-
|
|
13582
|
+
const off = await port.automationSetEnabled?.({ automation_id: made.data.automation_id, enabled: false });
|
|
13583
|
+
if (off && !off.ok) extrasRefused.push(`Automation "${a.name}" on ${t.name} was copied but could not be switched off: ${sentence(off.error)}`);
|
|
13584
|
+
else automations += 1;
|
|
13585
|
+
} else extrasRefused.push(`Automation "${a.name}" on ${t.name} was not copied: ${made.ok ? refusedSentence(made.data) : sentence(made.error)}`);
|
|
13521
13586
|
}
|
|
13522
|
-
}
|
|
13587
|
+
} else extrasRefused.push(`The automations of ${t.name} could not be read: ${sentence(list.error)}`);
|
|
13523
13588
|
}
|
|
13524
13589
|
if (port.dashboards && port.dashboardDeclare) {
|
|
13525
13590
|
const list = await port.dashboards(t.id);
|
|
@@ -13528,13 +13593,13 @@ async function copyExtras(port, tables, pairs) {
|
|
|
13528
13593
|
const made = await port.dashboardDeclare({
|
|
13529
13594
|
table_id: copy,
|
|
13530
13595
|
name: d.name,
|
|
13531
|
-
blocks: pointAtCopies(d.blocks,
|
|
13532
|
-
presentation: pointAtCopies(d.presentation,
|
|
13596
|
+
blocks: pointAtCopies(d.blocks, ids),
|
|
13597
|
+
presentation: pointAtCopies(d.presentation, ids)
|
|
13533
13598
|
});
|
|
13534
13599
|
if (made.ok) pages += 1;
|
|
13535
|
-
else extrasRefused.push(`Page "${d.name}" on ${t.name} was not copied
|
|
13600
|
+
else extrasRefused.push(`Page "${d.name}" on ${t.name} was not copied: ${sentence(made.error)}`);
|
|
13536
13601
|
}
|
|
13537
|
-
}
|
|
13602
|
+
} else extrasRefused.push(`The pages of ${t.name} could not be read: ${sentence(list.error)}`);
|
|
13538
13603
|
}
|
|
13539
13604
|
}
|
|
13540
13605
|
return { automations, pages, extrasRefused };
|
|
@@ -13573,6 +13638,7 @@ async function restoreSnapshot(port, args) {
|
|
|
13573
13638
|
tables: sources,
|
|
13574
13639
|
withRecords: true,
|
|
13575
13640
|
nameFor: (t) => `${byCopy.get(t.id) ?? t.name} (restored)`,
|
|
13641
|
+
homeName: restoredBaseName(args.baseName ?? "Base", args.restoredOn ?? (/* @__PURE__ */ new Date()).toLocaleDateString()),
|
|
13576
13642
|
...args.onProgress ? { onProgress: args.onProgress } : {}
|
|
13577
13643
|
});
|
|
13578
13644
|
for (const s of sources) await port.archive?.(s.id);
|