@ai-matrx/records 0.99.28 → 0.99.30
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 +18 -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/entity/index.cjs +1 -1
- package/dist/entity/index.cjs.map +1 -1
- package/dist/entity/index.d.cts +3 -3
- package/dist/entity/index.d.ts +3 -3
- package/dist/entity/index.js +1 -1
- package/dist/entity/index.js.map +1 -1
- package/dist/entity/react.cjs +1 -1
- package/dist/entity/react.cjs.map +1 -1
- package/dist/entity/react.js +1 -1
- package/dist/entity/react.js.map +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/{port-DWHLj_Sa.d.ts → port-Bk7TG0aE.d.ts} +3 -3
- package/dist/{port-BbWB9Pgq.d.cts → port-rqQEGhew.d.cts} +3 -3
- package/dist/questions/index.d.cts +1 -1
- package/dist/questions/index.d.ts +1 -1
- package/dist/react/index.cjs +82 -128
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +37 -2
- package/dist/react/index.d.ts +37 -2
- package/dist/react/index.js +81 -127
- package/dist/react/index.js.map +1 -1
- package/dist/realtime/index.cjs +1 -1
- package/dist/realtime/index.cjs.map +1 -1
- package/dist/realtime/index.d.cts +4 -4
- package/dist/realtime/index.d.ts +4 -4
- package/dist/realtime/index.js +1 -1
- package/dist/realtime/index.js.map +1 -1
- package/dist/setup/index.cjs +15 -4
- package/dist/setup/index.cjs.map +1 -1
- package/dist/setup/index.d.cts +3 -3
- package/dist/setup/index.d.ts +3 -3
- package/dist/setup/index.js +15 -4
- package/dist/setup/index.js.map +1 -1
- package/dist/typed-table/index.cjs +16 -117
- package/dist/typed-table/index.cjs.map +1 -1
- package/dist/typed-table/index.d.cts +3 -4
- package/dist/typed-table/index.d.ts +3 -4
- package/dist/typed-table/index.js +15 -116
- 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 +7 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { L as Lane, H as HostDataPort, V as Values } from './types-CrkzINrb.js';
|
|
2
2
|
import { U as Uuid, R as RecordsResult } from './record-C8q21jjB.js';
|
|
3
3
|
import { O as OpLedger } from './ports-BCNNghmf.js';
|
|
4
|
-
import * as
|
|
5
|
-
import { RealtimeManager, ChannelSpec } from '@ai-matrx/realtime';
|
|
4
|
+
import * as _ai_matrx_data_realtime from '@ai-matrx/data/realtime';
|
|
5
|
+
import { RealtimeManager, ChannelSpec } from '@ai-matrx/data/realtime';
|
|
6
6
|
|
|
7
7
|
/** A link as the door words it: `{token, id, label}`. */
|
|
8
8
|
interface EntityWireRef {
|
|
@@ -177,7 +177,7 @@ interface EntityClient {
|
|
|
177
177
|
declare function createEntityClient(options: CreateEntityClientOptions): EntityClient;
|
|
178
178
|
|
|
179
179
|
/** The topic is a CONTRACT WITH THE DATABASE (a trigger writes it, an RLS policy parses it): built once, here. */
|
|
180
|
-
declare const entityOrgChannel:
|
|
180
|
+
declare const entityOrgChannel: _ai_matrx_data_realtime.ChannelNamespace;
|
|
181
181
|
/** The broadcast event the database sends on an organization topic. */
|
|
182
182
|
declare const ENTITY_NOTICE_EVENT = "entity_bump";
|
|
183
183
|
/** Starting values of the knobs the runtime coalesces with (entity_data.realtime_batch_ms / _max_wait_ms). */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { L as Lane, H as HostDataPort, V as Values } from './types-C4XCuv8O.cjs';
|
|
2
2
|
import { U as Uuid, R as RecordsResult } from './record-C8q21jjB.cjs';
|
|
3
3
|
import { O as OpLedger } from './ports-iATV-A2v.cjs';
|
|
4
|
-
import * as
|
|
5
|
-
import { RealtimeManager, ChannelSpec } from '@ai-matrx/realtime';
|
|
4
|
+
import * as _ai_matrx_data_realtime from '@ai-matrx/data/realtime';
|
|
5
|
+
import { RealtimeManager, ChannelSpec } from '@ai-matrx/data/realtime';
|
|
6
6
|
|
|
7
7
|
/** A link as the door words it: `{token, id, label}`. */
|
|
8
8
|
interface EntityWireRef {
|
|
@@ -177,7 +177,7 @@ interface EntityClient {
|
|
|
177
177
|
declare function createEntityClient(options: CreateEntityClientOptions): EntityClient;
|
|
178
178
|
|
|
179
179
|
/** The topic is a CONTRACT WITH THE DATABASE (a trigger writes it, an RLS policy parses it): built once, here. */
|
|
180
|
-
declare const entityOrgChannel:
|
|
180
|
+
declare const entityOrgChannel: _ai_matrx_data_realtime.ChannelNamespace;
|
|
181
181
|
/** The broadcast event the database sends on an organization topic. */
|
|
182
182
|
declare const ENTITY_NOTICE_EVENT = "entity_bump";
|
|
183
183
|
/** Starting values of the knobs the runtime coalesces with (entity_data.realtime_batch_ms / _max_wait_ms). */
|
|
@@ -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,
|
|
@@ -268,7 +270,6 @@ __export(react_exports, {
|
|
|
268
270
|
safeLinkHref: () => safeLinkHref,
|
|
269
271
|
sameDocument: () => sameDocument,
|
|
270
272
|
scopeChip: () => scopeChip,
|
|
271
|
-
sha256Hex: () => sha256Hex2,
|
|
272
273
|
sheetSyncSpec: () => sheetSyncSpec,
|
|
273
274
|
snapshotBase: () => snapshotBase,
|
|
274
275
|
sourceArchivedOf: () => sourceArchivedOf,
|
|
@@ -6164,6 +6165,15 @@ function createRecordsClient(given) {
|
|
|
6164
6165
|
}
|
|
6165
6166
|
return result;
|
|
6166
6167
|
},
|
|
6168
|
+
async recordReparent({ record_id, parent_id }) {
|
|
6169
|
+
const result = await callDoor(
|
|
6170
|
+
DOORS.recordReparent,
|
|
6171
|
+
{ p_organization_id: org, p_record_id: record_id, p_parent_id: parent_id },
|
|
6172
|
+
"recordReparent"
|
|
6173
|
+
);
|
|
6174
|
+
if (result.ok) announceRecordChanged(record_id);
|
|
6175
|
+
return result;
|
|
6176
|
+
},
|
|
6167
6177
|
async recordRestore({ record_id }) {
|
|
6168
6178
|
const result = await callDoor(
|
|
6169
6179
|
DOORS.recordRestore,
|
|
@@ -6711,7 +6721,9 @@ function createRecordsClient(given) {
|
|
|
6711
6721
|
}
|
|
6712
6722
|
const tables = read.map((row) => {
|
|
6713
6723
|
const { document } = unfold(row.document);
|
|
6714
|
-
|
|
6724
|
+
const doc = document;
|
|
6725
|
+
const home = typeof doc.home_id === "string" ? doc.home_id : typeof doc.parent_id === "string" ? doc.parent_id : null;
|
|
6726
|
+
return { ...doc, home_id: home, id: row.id, organization_id: org };
|
|
6715
6727
|
});
|
|
6716
6728
|
tables.sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
|
|
6717
6729
|
return ok(tables);
|
|
@@ -12667,6 +12679,9 @@ function useStoreTable(table, options = {}) {
|
|
|
12667
12679
|
};
|
|
12668
12680
|
}
|
|
12669
12681
|
|
|
12682
|
+
// src/typed-table/define.ts
|
|
12683
|
+
var import_sha256 = require("@ai-matrx/kit/sha256");
|
|
12684
|
+
|
|
12670
12685
|
// src/typed-table/graduate.ts
|
|
12671
12686
|
var import_uuid6 = require("@ai-matrx/kit/uuid");
|
|
12672
12687
|
var TO_CUSTOM_FIELDS = "custom_fields";
|
|
@@ -12828,8 +12843,8 @@ var f = {
|
|
|
12828
12843
|
};
|
|
12829
12844
|
var SLUG = /^[a-z][a-z0-9_]*$/;
|
|
12830
12845
|
var WORD = /^[a-z][a-z0-9_]*$/;
|
|
12831
|
-
function refuse3(slug,
|
|
12832
|
-
throw new Error(`defineTypedTable(${JSON.stringify(slug)}): ${
|
|
12846
|
+
function refuse3(slug, sentence2) {
|
|
12847
|
+
throw new Error(`defineTypedTable(${JSON.stringify(slug)}): ${sentence2}`);
|
|
12833
12848
|
}
|
|
12834
12849
|
function labelFor(key) {
|
|
12835
12850
|
const words = key.replace(/_+/g, " ").trim();
|
|
@@ -12932,7 +12947,7 @@ function defineTypedTable(input) {
|
|
|
12932
12947
|
fields: { ...input.fields },
|
|
12933
12948
|
specs,
|
|
12934
12949
|
canonicalSpec,
|
|
12935
|
-
specHash:
|
|
12950
|
+
specHash: (0, import_sha256.sha256Hex)(canonicalSpec),
|
|
12936
12951
|
graduatedTo: input.graduatedTo ? { token: input.graduatedTo.token, map: { ...input.graduatedTo.map } } : null,
|
|
12937
12952
|
confidential: input.confidential ? {
|
|
12938
12953
|
readers: input.confidential.readers.map((r) => ({ field: r.field, level: r.level, ...r.when ? { when: { ...r.when } } : {} })),
|
|
@@ -12941,120 +12956,6 @@ function defineTypedTable(input) {
|
|
|
12941
12956
|
} : null
|
|
12942
12957
|
});
|
|
12943
12958
|
}
|
|
12944
|
-
var K256 = new Uint32Array([
|
|
12945
|
-
1116352408,
|
|
12946
|
-
1899447441,
|
|
12947
|
-
3049323471,
|
|
12948
|
-
3921009573,
|
|
12949
|
-
961987163,
|
|
12950
|
-
1508970993,
|
|
12951
|
-
2453635748,
|
|
12952
|
-
2870763221,
|
|
12953
|
-
3624381080,
|
|
12954
|
-
310598401,
|
|
12955
|
-
607225278,
|
|
12956
|
-
1426881987,
|
|
12957
|
-
1925078388,
|
|
12958
|
-
2162078206,
|
|
12959
|
-
2614888103,
|
|
12960
|
-
3248222580,
|
|
12961
|
-
3835390401,
|
|
12962
|
-
4022224774,
|
|
12963
|
-
264347078,
|
|
12964
|
-
604807628,
|
|
12965
|
-
770255983,
|
|
12966
|
-
1249150122,
|
|
12967
|
-
1555081692,
|
|
12968
|
-
1996064986,
|
|
12969
|
-
2554220882,
|
|
12970
|
-
2821834349,
|
|
12971
|
-
2952996808,
|
|
12972
|
-
3210313671,
|
|
12973
|
-
3336571891,
|
|
12974
|
-
3584528711,
|
|
12975
|
-
113926993,
|
|
12976
|
-
338241895,
|
|
12977
|
-
666307205,
|
|
12978
|
-
773529912,
|
|
12979
|
-
1294757372,
|
|
12980
|
-
1396182291,
|
|
12981
|
-
1695183700,
|
|
12982
|
-
1986661051,
|
|
12983
|
-
2177026350,
|
|
12984
|
-
2456956037,
|
|
12985
|
-
2730485921,
|
|
12986
|
-
2820302411,
|
|
12987
|
-
3259730800,
|
|
12988
|
-
3345764771,
|
|
12989
|
-
3516065817,
|
|
12990
|
-
3600352804,
|
|
12991
|
-
4094571909,
|
|
12992
|
-
275423344,
|
|
12993
|
-
430227734,
|
|
12994
|
-
506948616,
|
|
12995
|
-
659060556,
|
|
12996
|
-
883997877,
|
|
12997
|
-
958139571,
|
|
12998
|
-
1322822218,
|
|
12999
|
-
1537002063,
|
|
13000
|
-
1747873779,
|
|
13001
|
-
1955562222,
|
|
13002
|
-
2024104815,
|
|
13003
|
-
2227730452,
|
|
13004
|
-
2361852424,
|
|
13005
|
-
2428436474,
|
|
13006
|
-
2756734187,
|
|
13007
|
-
3204031479,
|
|
13008
|
-
3329325298
|
|
13009
|
-
]);
|
|
13010
|
-
function sha256Hex2(text2) {
|
|
13011
|
-
const bytes = new TextEncoder().encode(text2);
|
|
13012
|
-
const bitLength = bytes.length * 8;
|
|
13013
|
-
const padded = new Uint8Array(bytes.length + 9 + 63 >> 6 << 6);
|
|
13014
|
-
padded.set(bytes);
|
|
13015
|
-
padded[bytes.length] = 128;
|
|
13016
|
-
const view = new DataView(padded.buffer);
|
|
13017
|
-
view.setUint32(padded.length - 8, Math.floor(bitLength / 4294967296));
|
|
13018
|
-
view.setUint32(padded.length - 4, bitLength >>> 0);
|
|
13019
|
-
const h = new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]);
|
|
13020
|
-
const w = new Uint32Array(64);
|
|
13021
|
-
const rotr = (x, n) => x >>> n | x << 32 - n;
|
|
13022
|
-
for (let off = 0; off < padded.length; off += 64) {
|
|
13023
|
-
for (let i = 0; i < 16; i++) w[i] = view.getUint32(off + i * 4);
|
|
13024
|
-
for (let i = 16; i < 64; i++) {
|
|
13025
|
-
const a2 = w[i - 15], b2 = w[i - 2];
|
|
13026
|
-
const s0 = rotr(a2, 7) ^ rotr(a2, 18) ^ a2 >>> 3;
|
|
13027
|
-
const s1 = rotr(b2, 17) ^ rotr(b2, 19) ^ b2 >>> 10;
|
|
13028
|
-
w[i] = w[i - 16] + s0 + w[i - 7] + s1 >>> 0;
|
|
13029
|
-
}
|
|
13030
|
-
let a = h[0], b = h[1], c = h[2], d = h[3], e = h[4], f2 = h[5], g = h[6], hh = h[7];
|
|
13031
|
-
for (let i = 0; i < 64; i++) {
|
|
13032
|
-
const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
13033
|
-
const ch = e & f2 ^ ~e & g;
|
|
13034
|
-
const t1 = hh + S1 + ch + K256[i] + w[i] >>> 0;
|
|
13035
|
-
const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
|
|
13036
|
-
const maj = a & b ^ a & c ^ b & c;
|
|
13037
|
-
const t2 = S0 + maj >>> 0;
|
|
13038
|
-
hh = g;
|
|
13039
|
-
g = f2;
|
|
13040
|
-
f2 = e;
|
|
13041
|
-
e = d + t1 >>> 0;
|
|
13042
|
-
d = c;
|
|
13043
|
-
c = b;
|
|
13044
|
-
b = a;
|
|
13045
|
-
a = t1 + t2 >>> 0;
|
|
13046
|
-
}
|
|
13047
|
-
h[0] = h[0] + a >>> 0;
|
|
13048
|
-
h[1] = h[1] + b >>> 0;
|
|
13049
|
-
h[2] = h[2] + c >>> 0;
|
|
13050
|
-
h[3] = h[3] + d >>> 0;
|
|
13051
|
-
h[4] = h[4] + e >>> 0;
|
|
13052
|
-
h[5] = h[5] + f2 >>> 0;
|
|
13053
|
-
h[6] = h[6] + g >>> 0;
|
|
13054
|
-
h[7] = h[7] + hh >>> 0;
|
|
13055
|
-
}
|
|
13056
|
-
return Array.from(h, (x) => x.toString(16).padStart(8, "0")).join("");
|
|
13057
|
-
}
|
|
13058
12959
|
|
|
13059
12960
|
// src/typed-table/archive.ts
|
|
13060
12961
|
var MAX_PASSES = 200;
|
|
@@ -13465,6 +13366,9 @@ function automationWebhookUrl(serverBase, item2) {
|
|
|
13465
13366
|
function baseCopyName(name) {
|
|
13466
13367
|
return `${name.trim() || "Base"} (copy)`;
|
|
13467
13368
|
}
|
|
13369
|
+
function restoredBaseName(name, on) {
|
|
13370
|
+
return `${name.trim() || "Base"} (restored ${on})`;
|
|
13371
|
+
}
|
|
13468
13372
|
async function duplicateBase(port, args) {
|
|
13469
13373
|
const made = [];
|
|
13470
13374
|
const pairs = {};
|
|
@@ -13484,10 +13388,21 @@ async function duplicateBase(port, args) {
|
|
|
13484
13388
|
}
|
|
13485
13389
|
const fin = args.tables.length > 1 ? await port.finish({ organizationId: args.organizationId, pairs }) : null;
|
|
13486
13390
|
if (fin && !fin.ok) return { ok: false, error: fin.error, stoppedAt: args.tables[args.tables.length - 1], made };
|
|
13391
|
+
let homeId = null;
|
|
13392
|
+
if (args.homeName && port.createHome && port.moveInto) {
|
|
13393
|
+
const home = await port.createHome(args.homeName);
|
|
13394
|
+
if (!home.ok) return { ok: false, error: home.error, stoppedAt: args.tables[args.tables.length - 1], made };
|
|
13395
|
+
homeId = home.data;
|
|
13396
|
+
for (const m of made) {
|
|
13397
|
+
const moved = await port.moveInto(m.copy.id, homeId);
|
|
13398
|
+
if (!moved.ok) return { ok: false, error: moved.error, stoppedAt: m.from, made };
|
|
13399
|
+
}
|
|
13400
|
+
}
|
|
13487
13401
|
const extras = await copyExtras(port, args.tables, pairs);
|
|
13488
13402
|
return {
|
|
13489
13403
|
ok: true,
|
|
13490
13404
|
data: {
|
|
13405
|
+
homeId,
|
|
13491
13406
|
pairs,
|
|
13492
13407
|
tables: made,
|
|
13493
13408
|
relinkedColumns: fin?.ok ? fin.data.relinked_columns : 0,
|
|
@@ -13502,10 +13417,47 @@ function pointAtCopies(doc, pairs) {
|
|
|
13502
13417
|
for (const [from, to] of Object.entries(pairs)) text2 = text2.split(from).join(to);
|
|
13503
13418
|
return JSON.parse(text2);
|
|
13504
13419
|
}
|
|
13420
|
+
function sentence(error) {
|
|
13421
|
+
const m = error?.message;
|
|
13422
|
+
return typeof m === "string" && m ? m : "the store gave no reason.";
|
|
13423
|
+
}
|
|
13424
|
+
function refusedSentence(data) {
|
|
13425
|
+
const errors = data?._errors;
|
|
13426
|
+
const lines = errors ? Object.entries(errors).map(([path, why]) => `${path}: ${why}`) : [];
|
|
13427
|
+
return lines.length ? lines.join("; ") : "the store gave no reason.";
|
|
13428
|
+
}
|
|
13429
|
+
async function idsOfCopies(port, pairs) {
|
|
13430
|
+
const ids = { ...pairs };
|
|
13431
|
+
if (!port.fieldsOf && !port.viewsOf) return ids;
|
|
13432
|
+
for (const [from, to] of Object.entries(pairs)) {
|
|
13433
|
+
if (port.fieldsOf) {
|
|
13434
|
+
const [a, b] = await Promise.all([port.fieldsOf(from), port.fieldsOf(to)]);
|
|
13435
|
+
if (a.ok && b.ok) {
|
|
13436
|
+
const byKey = new Map(b.data.map((f2) => [f2.key, f2.id]));
|
|
13437
|
+
for (const f2 of a.data) {
|
|
13438
|
+
const n = byKey.get(f2.key);
|
|
13439
|
+
if (n && n !== f2.id) ids[f2.id] = n;
|
|
13440
|
+
}
|
|
13441
|
+
}
|
|
13442
|
+
}
|
|
13443
|
+
if (port.viewsOf) {
|
|
13444
|
+
const [a, b] = await Promise.all([port.viewsOf(from), port.viewsOf(to)]);
|
|
13445
|
+
if (a.ok && b.ok) {
|
|
13446
|
+
const byName = new Map(b.data.map((v) => [v.name, v.id]));
|
|
13447
|
+
for (const v of a.data) {
|
|
13448
|
+
const n = byName.get(v.name);
|
|
13449
|
+
if (n && n !== v.id) ids[v.id] = n;
|
|
13450
|
+
}
|
|
13451
|
+
}
|
|
13452
|
+
}
|
|
13453
|
+
}
|
|
13454
|
+
return ids;
|
|
13455
|
+
}
|
|
13505
13456
|
async function copyExtras(port, tables, pairs) {
|
|
13506
13457
|
let automations = 0;
|
|
13507
13458
|
let pages = 0;
|
|
13508
13459
|
const extrasRefused = [];
|
|
13460
|
+
const ids = await idsOfCopies(port, pairs);
|
|
13509
13461
|
for (const t of tables) {
|
|
13510
13462
|
const copy = pairs[t.id];
|
|
13511
13463
|
if (!copy) continue;
|
|
@@ -13513,13 +13465,14 @@ async function copyExtras(port, tables, pairs) {
|
|
|
13513
13465
|
const list = await port.automations(t.id);
|
|
13514
13466
|
if (list.ok) {
|
|
13515
13467
|
for (const a of list.data.automations) {
|
|
13516
|
-
const made = await port.automationDeclare({ table_id: copy, spec: pointAtCopies(a.spec,
|
|
13468
|
+
const made = await port.automationDeclare({ table_id: copy, spec: pointAtCopies(a.spec, ids) });
|
|
13517
13469
|
if (made.ok && made.data.ok && made.data.automation_id) {
|
|
13518
|
-
await port.automationSetEnabled?.({ automation_id: made.data.automation_id, enabled: false });
|
|
13519
|
-
|
|
13520
|
-
|
|
13470
|
+
const off = await port.automationSetEnabled?.({ automation_id: made.data.automation_id, enabled: false });
|
|
13471
|
+
if (off && !off.ok) extrasRefused.push(`Automation "${a.name}" on ${t.name} was copied but could not be switched off: ${sentence(off.error)}`);
|
|
13472
|
+
else automations += 1;
|
|
13473
|
+
} else extrasRefused.push(`Automation "${a.name}" on ${t.name} was not copied: ${made.ok ? refusedSentence(made.data) : sentence(made.error)}`);
|
|
13521
13474
|
}
|
|
13522
|
-
}
|
|
13475
|
+
} else extrasRefused.push(`The automations of ${t.name} could not be read: ${sentence(list.error)}`);
|
|
13523
13476
|
}
|
|
13524
13477
|
if (port.dashboards && port.dashboardDeclare) {
|
|
13525
13478
|
const list = await port.dashboards(t.id);
|
|
@@ -13528,13 +13481,13 @@ async function copyExtras(port, tables, pairs) {
|
|
|
13528
13481
|
const made = await port.dashboardDeclare({
|
|
13529
13482
|
table_id: copy,
|
|
13530
13483
|
name: d.name,
|
|
13531
|
-
blocks: pointAtCopies(d.blocks,
|
|
13532
|
-
presentation: pointAtCopies(d.presentation,
|
|
13484
|
+
blocks: pointAtCopies(d.blocks, ids),
|
|
13485
|
+
presentation: pointAtCopies(d.presentation, ids)
|
|
13533
13486
|
});
|
|
13534
13487
|
if (made.ok) pages += 1;
|
|
13535
|
-
else extrasRefused.push(`Page "${d.name}" on ${t.name} was not copied
|
|
13488
|
+
else extrasRefused.push(`Page "${d.name}" on ${t.name} was not copied: ${sentence(made.error)}`);
|
|
13536
13489
|
}
|
|
13537
|
-
}
|
|
13490
|
+
} else extrasRefused.push(`The pages of ${t.name} could not be read: ${sentence(list.error)}`);
|
|
13538
13491
|
}
|
|
13539
13492
|
}
|
|
13540
13493
|
return { automations, pages, extrasRefused };
|
|
@@ -13573,6 +13526,7 @@ async function restoreSnapshot(port, args) {
|
|
|
13573
13526
|
tables: sources,
|
|
13574
13527
|
withRecords: true,
|
|
13575
13528
|
nameFor: (t) => `${byCopy.get(t.id) ?? t.name} (restored)`,
|
|
13529
|
+
homeName: restoredBaseName(args.baseName ?? "Base", args.restoredOn ?? (/* @__PURE__ */ new Date()).toLocaleDateString()),
|
|
13576
13530
|
...args.onProgress ? { onProgress: args.onProgress } : {}
|
|
13577
13531
|
});
|
|
13578
13532
|
for (const s of sources) await port.archive?.(s.id);
|