@ai-matrx/records 0.99.26 → 0.99.27

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 CHANGED
@@ -1,10 +1,22 @@
1
1
  # Changelog — @ai-matrx/records
2
2
 
3
- ## 0.99.26
3
+ ## 0.99.27
4
4
 
5
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
6
  Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/records/src`.
7
7
 
8
+ ## 0.99.24
9
+
10
+ SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
11
+ so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
12
+ Diff: `git diff 8039f87bbd a293b83c1f -- apps/shared/records/src`
13
+
14
+ Changed shipped source files (4):
15
+ - `apps/shared/records/src/core/client.ts`
16
+ - `apps/shared/records/src/core/doors.ts`
17
+ - `apps/shared/records/src/dashboard.ts`
18
+ - `apps/shared/records/src/store.generated.ts`
19
+
8
20
  ## 0.99.23
9
21
  ### Unreleased
10
22
 
@@ -256,6 +256,7 @@ __export(core_exports, {
256
256
  parseTableMoved: () => parseTableMoved,
257
257
  personStampText: () => personStampText,
258
258
  planQuery: () => planQuery,
259
+ pointAtCopies: () => pointAtCopies,
259
260
  portalArchiveConsequence: () => portalArchiveConsequence,
260
261
  portalConfirmLine: () => portalConfirmLine,
261
262
  portalPath: () => portalPath,
@@ -2059,6 +2060,7 @@ async function duplicateBase(port, args) {
2059
2060
  }
2060
2061
  const fin = args.tables.length > 1 ? await port.finish({ organizationId: args.organizationId, pairs }) : null;
2061
2062
  if (fin && !fin.ok) return { ok: false, error: fin.error, stoppedAt: args.tables[args.tables.length - 1], made };
2063
+ const extras = await copyExtras(port, args.tables, pairs);
2062
2064
  return {
2063
2065
  ok: true,
2064
2066
  data: {
@@ -2066,10 +2068,53 @@ async function duplicateBase(port, args) {
2066
2068
  tables: made,
2067
2069
  relinkedColumns: fin?.ok ? fin.data.relinked_columns : 0,
2068
2070
  relinkedCells: fin?.ok ? fin.data.relinked_cells : 0,
2071
+ ...extras,
2069
2072
  notCopied: [...notCopied]
2070
2073
  }
2071
2074
  };
2072
2075
  }
2076
+ function pointAtCopies(doc, pairs) {
2077
+ let text2 = JSON.stringify(doc);
2078
+ for (const [from, to] of Object.entries(pairs)) text2 = text2.split(from).join(to);
2079
+ return JSON.parse(text2);
2080
+ }
2081
+ async function copyExtras(port, tables, pairs) {
2082
+ let automations = 0;
2083
+ let pages = 0;
2084
+ const extrasRefused = [];
2085
+ for (const t of tables) {
2086
+ const copy = pairs[t.id];
2087
+ if (!copy) continue;
2088
+ if (port.automations && port.automationDeclare) {
2089
+ const list = await port.automations(t.id);
2090
+ if (list.ok) {
2091
+ for (const a of list.data.automations) {
2092
+ const made = await port.automationDeclare({ table_id: copy, spec: pointAtCopies(a.spec, pairs) });
2093
+ if (made.ok && made.data.ok && made.data.automation_id) {
2094
+ await port.automationSetEnabled?.({ automation_id: made.data.automation_id, enabled: false });
2095
+ automations += 1;
2096
+ } else extrasRefused.push(`Automation "${a.name}" on ${t.name} was not copied.`);
2097
+ }
2098
+ }
2099
+ }
2100
+ if (port.dashboards && port.dashboardDeclare) {
2101
+ const list = await port.dashboards(t.id);
2102
+ if (list.ok) {
2103
+ for (const d of list.data) {
2104
+ const made = await port.dashboardDeclare({
2105
+ table_id: copy,
2106
+ name: d.name,
2107
+ blocks: pointAtCopies(d.blocks, pairs),
2108
+ presentation: pointAtCopies(d.presentation, pairs)
2109
+ });
2110
+ if (made.ok) pages += 1;
2111
+ else extrasRefused.push(`Page "${d.name}" on ${t.name} was not copied.`);
2112
+ }
2113
+ }
2114
+ }
2115
+ }
2116
+ return { automations, pages, extrasRefused };
2117
+ }
2073
2118
  async function snapshotBase(port, args) {
2074
2119
  const copied = await duplicateBase(port, {
2075
2120
  organizationId: args.organizationId,