@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
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
# Changelog — @ai-matrx/records
|
|
2
2
|
|
|
3
|
+
## 0.99.29
|
|
4
|
+
|
|
5
|
+
UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
|
|
6
|
+
Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/records/src`.
|
|
7
|
+
|
|
3
8
|
## 0.99.28
|
|
4
9
|
### Unreleased
|
|
5
10
|
|
|
11
|
+
- Bases (lane AT-BASE2): `duplicateBase` / `restoreSnapshot` put the copies in a NEW Home (`homeName`; `BaseCopied.homeId`), made by the door that makes a table's Home (`BasePort.createHome`) and moved in by the one move door, new `RecordsClient.recordReparent` (`custom.record_reparent`, `BasePort.moveInto`). A copy's automations and pages get the copy's column and view ids (`idsOfCopies`), and a refused automation, page or read says the store's own sentence in `extrasRefused`. `restoredBaseName`. `tableList()` exposes each table's Home as `home_id` (the record it sits in) and `kept_for` on `Table`.
|
|
12
|
+
|
|
6
13
|
- Registry: the view key `presentation.headerWrap` (boolean, grids) is declared, so a view can keep it.
|
|
7
14
|
|
|
8
15
|
## 0.99.27
|
|
@@ -162,6 +162,8 @@ interface Table {
|
|
|
162
162
|
row_order: string | null;
|
|
163
163
|
/** REC-14. Where this Table lives. Exactly one primary Home. */
|
|
164
164
|
home_id: Uuid | null;
|
|
165
|
+
/** The feature that keeps this Table out of the person's lists (`snapshot`, `copying`, …); absent for a person's own table. */
|
|
166
|
+
kept_for?: string | null;
|
|
165
167
|
/** REC-27. One of the nine, defined in code and not editable by Migration. */
|
|
166
168
|
is_kernel: boolean;
|
|
167
169
|
created_by: Uuid | null;
|
|
@@ -4352,6 +4354,14 @@ interface RecordsClient {
|
|
|
4352
4354
|
recordDelete(args: {
|
|
4353
4355
|
record_id: Uuid;
|
|
4354
4356
|
}): Promise<RecordsResult<Timestamp>>;
|
|
4357
|
+
/**
|
|
4358
|
+
* MOVE A RECORD (a Table included) INTO ANOTHER HOME — `custom.record_reparent`, the one door that changes where a
|
|
4359
|
+
* record is contained. `parent_id` is the Home's record id (null takes it out). Admin on the record, viewer on the Home.
|
|
4360
|
+
*/
|
|
4361
|
+
recordReparent(args: {
|
|
4362
|
+
record_id: Uuid;
|
|
4363
|
+
parent_id: Uuid | null;
|
|
4364
|
+
}): Promise<RecordsResult<null>>;
|
|
4355
4365
|
recordRestore(args: {
|
|
4356
4366
|
record_id: Uuid;
|
|
4357
4367
|
}): Promise<RecordsResult<void>>;
|
|
@@ -162,6 +162,8 @@ interface Table {
|
|
|
162
162
|
row_order: string | null;
|
|
163
163
|
/** REC-14. Where this Table lives. Exactly one primary Home. */
|
|
164
164
|
home_id: Uuid | null;
|
|
165
|
+
/** The feature that keeps this Table out of the person's lists (`snapshot`, `copying`, …); absent for a person's own table. */
|
|
166
|
+
kept_for?: string | null;
|
|
165
167
|
/** REC-27. One of the nine, defined in code and not editable by Migration. */
|
|
166
168
|
is_kernel: boolean;
|
|
167
169
|
created_by: Uuid | null;
|
|
@@ -4352,6 +4354,14 @@ interface RecordsClient {
|
|
|
4352
4354
|
recordDelete(args: {
|
|
4353
4355
|
record_id: Uuid;
|
|
4354
4356
|
}): Promise<RecordsResult<Timestamp>>;
|
|
4357
|
+
/**
|
|
4358
|
+
* MOVE A RECORD (a Table included) INTO ANOTHER HOME — `custom.record_reparent`, the one door that changes where a
|
|
4359
|
+
* record is contained. `parent_id` is the Home's record id (null takes it out). Admin on the record, viewer on the Home.
|
|
4360
|
+
*/
|
|
4361
|
+
recordReparent(args: {
|
|
4362
|
+
record_id: Uuid;
|
|
4363
|
+
parent_id: Uuid | null;
|
|
4364
|
+
}): Promise<RecordsResult<null>>;
|
|
4355
4365
|
recordRestore(args: {
|
|
4356
4366
|
record_id: Uuid;
|
|
4357
4367
|
}): Promise<RecordsResult<void>>;
|
package/dist/core/index.cjs
CHANGED
|
@@ -192,6 +192,7 @@ __export(core_exports, {
|
|
|
192
192
|
hasQuietHours: () => hasQuietHours,
|
|
193
193
|
highestLevel: () => highestLevel,
|
|
194
194
|
holdsARetiredChoice: () => holdsARetiredChoice,
|
|
195
|
+
idsOfCopies: () => idsOfCopies,
|
|
195
196
|
importCsv: () => importCsv,
|
|
196
197
|
importXlsx: () => importXlsx,
|
|
197
198
|
indexedDbStore: () => indexedDbStore,
|
|
@@ -291,6 +292,7 @@ __export(core_exports, {
|
|
|
291
292
|
removedChoicesInUse: () => removedChoicesInUse,
|
|
292
293
|
resolveObjectOrganization: () => resolveObjectOrganization,
|
|
293
294
|
restoreSnapshot: () => restoreSnapshot,
|
|
295
|
+
restoredBaseName: () => restoredBaseName,
|
|
294
296
|
richTextPlain: () => richTextPlain,
|
|
295
297
|
ruleThatRefuses: () => ruleThatRefuses,
|
|
296
298
|
rulesWithTopStar: () => rulesWithTopStar,
|
|
@@ -2041,6 +2043,9 @@ function moveConsequence(home, to) {
|
|
|
2041
2043
|
function baseCopyName(name) {
|
|
2042
2044
|
return `${name.trim() || "Base"} (copy)`;
|
|
2043
2045
|
}
|
|
2046
|
+
function restoredBaseName(name, on) {
|
|
2047
|
+
return `${name.trim() || "Base"} (restored ${on})`;
|
|
2048
|
+
}
|
|
2044
2049
|
async function duplicateBase(port, args) {
|
|
2045
2050
|
const made = [];
|
|
2046
2051
|
const pairs = {};
|
|
@@ -2060,10 +2065,21 @@ async function duplicateBase(port, args) {
|
|
|
2060
2065
|
}
|
|
2061
2066
|
const fin = args.tables.length > 1 ? await port.finish({ organizationId: args.organizationId, pairs }) : null;
|
|
2062
2067
|
if (fin && !fin.ok) return { ok: false, error: fin.error, stoppedAt: args.tables[args.tables.length - 1], made };
|
|
2068
|
+
let homeId = null;
|
|
2069
|
+
if (args.homeName && port.createHome && port.moveInto) {
|
|
2070
|
+
const home = await port.createHome(args.homeName);
|
|
2071
|
+
if (!home.ok) return { ok: false, error: home.error, stoppedAt: args.tables[args.tables.length - 1], made };
|
|
2072
|
+
homeId = home.data;
|
|
2073
|
+
for (const m of made) {
|
|
2074
|
+
const moved = await port.moveInto(m.copy.id, homeId);
|
|
2075
|
+
if (!moved.ok) return { ok: false, error: moved.error, stoppedAt: m.from, made };
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2063
2078
|
const extras = await copyExtras(port, args.tables, pairs);
|
|
2064
2079
|
return {
|
|
2065
2080
|
ok: true,
|
|
2066
2081
|
data: {
|
|
2082
|
+
homeId,
|
|
2067
2083
|
pairs,
|
|
2068
2084
|
tables: made,
|
|
2069
2085
|
relinkedColumns: fin?.ok ? fin.data.relinked_columns : 0,
|
|
@@ -2078,10 +2094,47 @@ function pointAtCopies(doc, pairs) {
|
|
|
2078
2094
|
for (const [from, to] of Object.entries(pairs)) text2 = text2.split(from).join(to);
|
|
2079
2095
|
return JSON.parse(text2);
|
|
2080
2096
|
}
|
|
2097
|
+
function sentence(error) {
|
|
2098
|
+
const m = error?.message;
|
|
2099
|
+
return typeof m === "string" && m ? m : "the store gave no reason.";
|
|
2100
|
+
}
|
|
2101
|
+
function refusedSentence(data) {
|
|
2102
|
+
const errors = data?._errors;
|
|
2103
|
+
const lines = errors ? Object.entries(errors).map(([path, why]) => `${path}: ${why}`) : [];
|
|
2104
|
+
return lines.length ? lines.join("; ") : "the store gave no reason.";
|
|
2105
|
+
}
|
|
2106
|
+
async function idsOfCopies(port, pairs) {
|
|
2107
|
+
const ids = { ...pairs };
|
|
2108
|
+
if (!port.fieldsOf && !port.viewsOf) return ids;
|
|
2109
|
+
for (const [from, to] of Object.entries(pairs)) {
|
|
2110
|
+
if (port.fieldsOf) {
|
|
2111
|
+
const [a, b] = await Promise.all([port.fieldsOf(from), port.fieldsOf(to)]);
|
|
2112
|
+
if (a.ok && b.ok) {
|
|
2113
|
+
const byKey = new Map(b.data.map((f) => [f.key, f.id]));
|
|
2114
|
+
for (const f of a.data) {
|
|
2115
|
+
const n = byKey.get(f.key);
|
|
2116
|
+
if (n && n !== f.id) ids[f.id] = n;
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
if (port.viewsOf) {
|
|
2121
|
+
const [a, b] = await Promise.all([port.viewsOf(from), port.viewsOf(to)]);
|
|
2122
|
+
if (a.ok && b.ok) {
|
|
2123
|
+
const byName = new Map(b.data.map((v) => [v.name, v.id]));
|
|
2124
|
+
for (const v of a.data) {
|
|
2125
|
+
const n = byName.get(v.name);
|
|
2126
|
+
if (n && n !== v.id) ids[v.id] = n;
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
return ids;
|
|
2132
|
+
}
|
|
2081
2133
|
async function copyExtras(port, tables, pairs) {
|
|
2082
2134
|
let automations = 0;
|
|
2083
2135
|
let pages = 0;
|
|
2084
2136
|
const extrasRefused = [];
|
|
2137
|
+
const ids = await idsOfCopies(port, pairs);
|
|
2085
2138
|
for (const t of tables) {
|
|
2086
2139
|
const copy = pairs[t.id];
|
|
2087
2140
|
if (!copy) continue;
|
|
@@ -2089,13 +2142,14 @@ async function copyExtras(port, tables, pairs) {
|
|
|
2089
2142
|
const list = await port.automations(t.id);
|
|
2090
2143
|
if (list.ok) {
|
|
2091
2144
|
for (const a of list.data.automations) {
|
|
2092
|
-
const made = await port.automationDeclare({ table_id: copy, spec: pointAtCopies(a.spec,
|
|
2145
|
+
const made = await port.automationDeclare({ table_id: copy, spec: pointAtCopies(a.spec, ids) });
|
|
2093
2146
|
if (made.ok && made.data.ok && made.data.automation_id) {
|
|
2094
|
-
await port.automationSetEnabled?.({ automation_id: made.data.automation_id, enabled: false });
|
|
2095
|
-
|
|
2096
|
-
|
|
2147
|
+
const off = await port.automationSetEnabled?.({ automation_id: made.data.automation_id, enabled: false });
|
|
2148
|
+
if (off && !off.ok) extrasRefused.push(`Automation "${a.name}" on ${t.name} was copied but could not be switched off: ${sentence(off.error)}`);
|
|
2149
|
+
else automations += 1;
|
|
2150
|
+
} else extrasRefused.push(`Automation "${a.name}" on ${t.name} was not copied: ${made.ok ? refusedSentence(made.data) : sentence(made.error)}`);
|
|
2097
2151
|
}
|
|
2098
|
-
}
|
|
2152
|
+
} else extrasRefused.push(`The automations of ${t.name} could not be read: ${sentence(list.error)}`);
|
|
2099
2153
|
}
|
|
2100
2154
|
if (port.dashboards && port.dashboardDeclare) {
|
|
2101
2155
|
const list = await port.dashboards(t.id);
|
|
@@ -2104,13 +2158,13 @@ async function copyExtras(port, tables, pairs) {
|
|
|
2104
2158
|
const made = await port.dashboardDeclare({
|
|
2105
2159
|
table_id: copy,
|
|
2106
2160
|
name: d.name,
|
|
2107
|
-
blocks: pointAtCopies(d.blocks,
|
|
2108
|
-
presentation: pointAtCopies(d.presentation,
|
|
2161
|
+
blocks: pointAtCopies(d.blocks, ids),
|
|
2162
|
+
presentation: pointAtCopies(d.presentation, ids)
|
|
2109
2163
|
});
|
|
2110
2164
|
if (made.ok) pages += 1;
|
|
2111
|
-
else extrasRefused.push(`Page "${d.name}" on ${t.name} was not copied
|
|
2165
|
+
else extrasRefused.push(`Page "${d.name}" on ${t.name} was not copied: ${sentence(made.error)}`);
|
|
2112
2166
|
}
|
|
2113
|
-
}
|
|
2167
|
+
} else extrasRefused.push(`The pages of ${t.name} could not be read: ${sentence(list.error)}`);
|
|
2114
2168
|
}
|
|
2115
2169
|
}
|
|
2116
2170
|
return { automations, pages, extrasRefused };
|
|
@@ -2149,6 +2203,7 @@ async function restoreSnapshot(port, args) {
|
|
|
2149
2203
|
tables: sources,
|
|
2150
2204
|
withRecords: true,
|
|
2151
2205
|
nameFor: (t) => `${byCopy.get(t.id) ?? t.name} (restored)`,
|
|
2206
|
+
homeName: restoredBaseName(args.baseName ?? "Base", args.restoredOn ?? (/* @__PURE__ */ new Date()).toLocaleDateString()),
|
|
2152
2207
|
...args.onProgress ? { onProgress: args.onProgress } : {}
|
|
2153
2208
|
});
|
|
2154
2209
|
for (const s of sources) await port.archive?.(s.id);
|
|
@@ -8215,6 +8270,15 @@ function createRecordsClient(given) {
|
|
|
8215
8270
|
}
|
|
8216
8271
|
return result;
|
|
8217
8272
|
},
|
|
8273
|
+
async recordReparent({ record_id, parent_id }) {
|
|
8274
|
+
const result = await callDoor(
|
|
8275
|
+
DOORS.recordReparent,
|
|
8276
|
+
{ p_organization_id: org, p_record_id: record_id, p_parent_id: parent_id },
|
|
8277
|
+
"recordReparent"
|
|
8278
|
+
);
|
|
8279
|
+
if (result.ok) announceRecordChanged(record_id);
|
|
8280
|
+
return result;
|
|
8281
|
+
},
|
|
8218
8282
|
async recordRestore({ record_id }) {
|
|
8219
8283
|
const result = await callDoor(
|
|
8220
8284
|
DOORS.recordRestore,
|
|
@@ -8762,7 +8826,9 @@ function createRecordsClient(given) {
|
|
|
8762
8826
|
}
|
|
8763
8827
|
const tables = read.map((row) => {
|
|
8764
8828
|
const { document } = unfold(row.document);
|
|
8765
|
-
|
|
8829
|
+
const doc = document;
|
|
8830
|
+
const home = typeof doc.home_id === "string" ? doc.home_id : typeof doc.parent_id === "string" ? doc.parent_id : null;
|
|
8831
|
+
return { ...doc, home_id: home, id: row.id, organization_id: org };
|
|
8766
8832
|
});
|
|
8767
8833
|
tables.sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
|
|
8768
8834
|
return ok(tables);
|