@ai-matrx/records 0.99.22 → 0.99.23

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,32 @@
1
1
  # Changelog — @ai-matrx/records
2
2
 
3
- ## 0.99.22
3
+ ## 0.99.23
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.22
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 152b8592f0 c55c74416d -- apps/shared/records/src`
13
+
14
+ Changed shipped source files (3):
15
+ - `apps/shared/records/src/core/client.ts`
16
+ - `apps/shared/records/src/retype.ts`
17
+ - `apps/shared/records/src/store.generated.ts`
18
+
19
+ ## 0.99.21
20
+
21
+ SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
22
+ so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
23
+ Diff: `git diff 270152d48e 152b8592f0 -- apps/shared/records/src`
24
+
25
+ Changed shipped source files (3):
26
+ - `apps/shared/records/src/core/client.ts`
27
+ - `apps/shared/records/src/retype.ts`
28
+ - `apps/shared/records/src/store.generated.ts`
29
+
8
30
  ## 0.99.20
9
31
 
10
32
  SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
@@ -136,6 +136,7 @@ __export(core_exports, {
136
136
  autonumberPrefixOf: () => autonumberPrefixOf,
137
137
  autonumberSearchOf: () => autonumberSearchOf,
138
138
  autonumberWords: () => autonumberWords,
139
+ baseCopyName: () => baseCopyName,
139
140
  blockLandedInStore: () => blockLandedInStore,
140
141
  bookingPath: () => bookingPath,
141
142
  buttonNeeds: () => buttonNeeds,
@@ -164,6 +165,7 @@ __export(core_exports, {
164
165
  drillAnswerOf: () => drillAnswerOf,
165
166
  drillFindingKnob: () => drillFindingKnob,
166
167
  dropPrimedDoorAnswers: () => dropPrimedDoorAnswers,
168
+ duplicateBase: () => duplicateBase,
167
169
  durationText: () => durationText,
168
170
  emptyArchiveLine: () => emptyArchiveLine,
169
171
  emptyPortalArchiveLine: () => emptyPortalArchiveLine,
@@ -286,6 +288,7 @@ __export(core_exports, {
286
288
  rememberedOpCount: () => rememberedOpCount,
287
289
  removedChoicesInUse: () => removedChoicesInUse,
288
290
  resolveObjectOrganization: () => resolveObjectOrganization,
291
+ restoreSnapshot: () => restoreSnapshot,
289
292
  richTextPlain: () => richTextPlain,
290
293
  ruleThatRefuses: () => ruleThatRefuses,
291
294
  rulesWithTopStar: () => rulesWithTopStar,
@@ -296,6 +299,7 @@ __export(core_exports, {
296
299
  seedKey: () => seedKey,
297
300
  seededDataSource: () => seededDataSource,
298
301
  sheetSyncSpec: () => sheetSyncSpec,
302
+ snapshotBase: () => snapshotBase,
299
303
  sourceArchivedOf: () => sourceArchivedOf,
300
304
  splitListCell: () => splitListCell,
301
305
  splitLockedRows: () => splitLockedRows,
@@ -2025,6 +2029,80 @@ function moveConsequence(home, to) {
2025
2029
  return `${home.table.name} moves to ${to.name} with its ${parts.join(", ")}` + (c.tablesInside > 0 ? `, the ${plural(c.tablesInside, "table", "tables")} that live${c.tablesInside === 1 ? "s" : ""} inside it or its rows (with their own rows)` : "") + (extra > 0 ? `, and ${plural(extra, "thing", "things")} built only on it (choice lists, rules, dashboards, templates)` : "") + `, its comments, forms, saved views and history. ` + (c.linksAcross > 0 ? `${plural(c.linksAcross, "link", "links")} to rows that stay in ${home.organization.name} keep${c.linksAcross === 1 ? "s" : ""} pointing there, across the two organizations. ` : "") + `People who see it only because they are in ${home.organization.name} stop seeing it; people it was shared with by name keep it. You can move it back from the same place.`;
2026
2030
  }
2027
2031
 
2032
+ // src/base.ts
2033
+ function baseCopyName(name) {
2034
+ return `${name.trim() || "Base"} (copy)`;
2035
+ }
2036
+ async function duplicateBase(port, args) {
2037
+ const made = [];
2038
+ const pairs = {};
2039
+ const notCopied = /* @__PURE__ */ new Set();
2040
+ for (const [i, table] of args.tables.entries()) {
2041
+ const res = await port.tableDuplicate({
2042
+ tableId: table.id,
2043
+ withRecords: args.withRecords,
2044
+ organizationId: args.organizationId,
2045
+ name: args.nameFor ? args.nameFor(table) : table.name,
2046
+ onProgress: (pass) => args.onProgress?.({ at: i + 1, of: args.tables.length, tableName: table.name, pass })
2047
+ });
2048
+ if (!res.ok) return { ok: false, error: res.error, stoppedAt: table, made };
2049
+ pairs[table.id] = res.data.table.id;
2050
+ made.push({ from: table, copy: res.data.table, records: res.data.copied.records });
2051
+ for (const n of res.data.notCopied) notCopied.add(n);
2052
+ }
2053
+ const fin = args.tables.length > 1 ? await port.finish({ organizationId: args.organizationId, pairs }) : null;
2054
+ if (fin && !fin.ok) return { ok: false, error: fin.error, stoppedAt: args.tables[args.tables.length - 1], made };
2055
+ return {
2056
+ ok: true,
2057
+ data: {
2058
+ pairs,
2059
+ tables: made,
2060
+ relinkedColumns: fin?.ok ? fin.data.relinked_columns : 0,
2061
+ relinkedCells: fin?.ok ? fin.data.relinked_cells : 0,
2062
+ notCopied: [...notCopied]
2063
+ }
2064
+ };
2065
+ }
2066
+ async function snapshotBase(port, args) {
2067
+ const copied = await duplicateBase(port, {
2068
+ organizationId: args.organizationId,
2069
+ tables: args.tables,
2070
+ withRecords: true,
2071
+ nameFor: (t) => `Snapshot ${args.label} \xB7 ${t.name}`,
2072
+ ...args.onProgress ? { onProgress: args.onProgress } : {}
2073
+ });
2074
+ if (!copied.ok) {
2075
+ for (const m of copied.made) await port.archive?.(m.copy.id);
2076
+ return { ok: false, error: copied.error, stoppedAt: copied.stoppedAt };
2077
+ }
2078
+ for (const t of copied.data.tables) {
2079
+ const away = await port.archive?.(t.copy.id);
2080
+ if (away && !away.ok) return { ok: false, error: away.error, stoppedAt: t.from };
2081
+ }
2082
+ return {
2083
+ ok: true,
2084
+ snapshot: {
2085
+ label: args.label,
2086
+ origin: args.origin ?? "manual",
2087
+ tables: copied.data.tables.map((t) => ({ table_id: t.from.id, snapshot_table_id: t.copy.id, name: t.from.name, records: t.records }))
2088
+ }
2089
+ };
2090
+ }
2091
+ async function restoreSnapshot(port, args) {
2092
+ const sources = args.snapshot.tables.map((t) => ({ id: t.snapshot_table_id, name: t.name }));
2093
+ const byCopy = new Map(args.snapshot.tables.map((t) => [t.snapshot_table_id, t.name]));
2094
+ for (const s of sources) await port.unarchive?.(s.id);
2095
+ const out = await duplicateBase(port, {
2096
+ organizationId: args.organizationId,
2097
+ tables: sources,
2098
+ withRecords: true,
2099
+ nameFor: (t) => `${byCopy.get(t.id) ?? t.name} (restored)`,
2100
+ ...args.onProgress ? { onProgress: args.onProgress } : {}
2101
+ });
2102
+ for (const s of sources) await port.archive?.(s.id);
2103
+ return out;
2104
+ }
2105
+
2028
2106
  // src/capture-queue.ts
2029
2107
  var DB_NAME = "matrx-capture";
2030
2108
  var DB_VERSION = 1;