@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.
@@ -5,7 +5,7 @@ import { d as RecordsDataSource } from '../ports-L9DlTlKi.cjs';
5
5
  export { M as MyLevel, O as OpLedger, P as PERMISSION_LEVELS, g as PermissionLevel, h as RecordsActor, e as RecordsChangeSink, a as RecordsConfig, c as RecordsErrorSink, i as RecordsFilter, R as RecordsRealtimePort, j as RecordsResolverPort, k as RecordsResponse, l as RecordsTableQuery, b as RowAgentPort, f as RowAgentTarget, m as asPermissionLevel, n as atLeast, o as createOpLedger, p as defaultOpLedger, q as forgetAllOps, r as highestLevel, s as isOwnOp, t as mintOpId, u as rememberedOpCount } from '../ports-L9DlTlKi.cjs';
6
6
  import { F as Field } from '../field-G-YJctb7.cjs';
7
7
  export { A as ADDRESS_PARTS, c as AGENT_WRITER_WORDS, d as AddressPart, e as AddressValue, B as BARCODE_SYMBOLOGIES, f as BUTTON_DOES, g as ButtonDoes, h as ButtonPressed, i as ButtonSettings, C as ChoiceOptions, j as CoerceOptions, k as Coerced, l as CoercedAnswers, m as CoercibleField, n as FIELD_KINDS, o as FieldDuplicated, p as FieldKind, q as FieldOptionEdit, r as FieldPatch, s as FieldProposal, b as FieldRule, a as FieldTypeWord, K as KernelTargets, t as NEWER_FIELD_KINDS, u as NOT_A_MEMBER_WORDS, N as NewFieldDeclaration, v as NewerFieldKind, P as ParityFieldTypeDescriptor, w as PersonStamp, R as RelationDisplay, x as RelationNameIndex, y as RelationNameMatch, z as RelationNamesAnswer, S as STATUS_GROUPS, D as STATUS_GROUP_WORDS, E as SYSTEM_WRITER_WORDS, G as StatusGroup, T as TableProposal, H as addressFromText, I as addressMapUrl, J as addressText, L as allowsOtherValues, M as buttonNeeds, O as buttonOf, Q as buttonUrlPlaceholders, U as coerceTypedAnswer, V as coerceTypedAnswers, W as coercionLabel, X as durationText, Y as entityReferenceKindsOf, Z as fieldKindFor, _ as isAddressValue, $ as isButtonField, a0 as isEntityReferenceConfig, a1 as isPersonStamp, a2 as newerKindExportWords, a3 as newerKindOf, a4 as newerKindWords, a5 as personStampText, a6 as ratingMaxOf, a7 as readTypedDuration, a8 as relationNameIndexOf, a9 as relationNameKey, aa as relationNamesIn, ab as richTextPlain, ac as safeLinkHref, ad as splitListCell, ae as statusGroupOf } from '../field-G-YJctb7.cjs';
8
- export { CaptureQueue, CaptureQueueCounts, CaptureQueueOptions, CaptureQueuePorts, CaptureQueueStore, CaptureSyncReport, ChooseAlternateArgs, MergeField, MergeFieldProvenance, MergeFieldResolution, MergeFieldTransform, MissingBehavior, QueuedCapture, QueuedCaptureFile, QueuedCaptureState, REFUSALS_WORTH_REPEATING, ResolutionTriple, TypedDate, TypedMatchScore, TypedNumber, TypedTime, alternatePatch, autonumberJoin, autonumberPrefixOf, autonumberSearchOf, autonumberWords, chooseAlternate, filterWithAutonumber, indexedDbStore, isAutonumberField, isDecided, localeDateOrder, memoryStore, mintClientKey, openCaptureQueue, rankTypedMatches, readTypedDate, readTypedNumber, readTypedTime, twoDigitYear, typedDateText, typedMatchScore, typedTimeText } from '../index.cjs';
8
+ export { BaseCopied, BaseCopyProgress, BaseCopyResult, BasePort, BaseSnapshotRecord, BaseTable, CaptureQueue, CaptureQueueCounts, CaptureQueueOptions, CaptureQueuePorts, CaptureQueueStore, CaptureSyncReport, ChooseAlternateArgs, MergeField, MergeFieldProvenance, MergeFieldResolution, MergeFieldTransform, MissingBehavior, QueuedCapture, QueuedCaptureFile, QueuedCaptureState, REFUSALS_WORTH_REPEATING, ResolutionTriple, TypedDate, TypedMatchScore, TypedNumber, TypedTime, alternatePatch, autonumberJoin, autonumberPrefixOf, autonumberSearchOf, autonumberWords, baseCopyName, chooseAlternate, duplicateBase, filterWithAutonumber, indexedDbStore, isAutonumberField, isDecided, localeDateOrder, memoryStore, mintClientKey, openCaptureQueue, rankTypedMatches, readTypedDate, readTypedNumber, readTypedTime, restoreSnapshot, snapshotBase, twoDigitYear, typedDateText, typedMatchScore, typedTimeText } from '../index.cjs';
9
9
  export { B as BookingAvailability, a as BookingDeclared, b as BookingSummary, c as BookingWindow, d as FormResults, e as FormRoute, F as FormSummary, f as Rule, g as RuleAnswer, R as RuleExpression, h as bookingPath, p as publicFormPath } from '../rule-DG2mLWnl.cjs';
10
10
  export { D as DEFAULT_PORTAL_ARCHIVE_FILTER, F as FormLookOptions, a as PORTAL_ACCENTS, b as PORTAL_ARCHIVE_FILTERS, P as PortalAccent, c as PortalArchiveAnswer, d as PortalArchiveFilter, e as PortalCard, f as PortalConfig, g as PortalConfigInput, h as PortalFooterLink, i as PortalFormAnswer, j as PortalFormInput, k as PortalFormRef, l as PortalFormSpec, m as PortalInvitation, n as PortalPreviewRow, o as PortalPrincipal, p as PortalRevocation, q as PortalStage, r as PortalStyle, s as PortalStyleInput, t as PortalSummary, u as PortalTableExposure, v as PortalTableRef, w as PublicPicture, x as emptyPortalArchiveLine, y as isPortalAccent, z as isPortalArchiveFilter, A as portalArchiveConsequence, B as portalConfirmLine, C as portalPath, E as portalTitleTypedBack } from '../portal-C-WIo2v2.cjs';
11
11
  export { A as AggregateBucket, e as AggregateCompare, f as AggregateCompareKind, g as AggregateCompareWindows, h as AggregateDelta, b as AggregateFilter, i as AggregateGroupValue, c as AggregateMeasure, a as AggregateOperation, j as AggregateRow, k as AggregateWindow, l as DashboardBlock, D as DashboardBlockKind, m as DashboardBlockResult, n as DashboardRunResult, o as DashboardSummary, p as DashboardTarget, q as DashboardTargetBase, r as DashboardTargetOp, s as DashboardTargetResult, t as DashboardTotals, u as DigestPreview, M as MySubscription, Q as QuietHours, R as RecordFilter, v as RowTemplateRow, w as SavedViewColorBy, x as SavedViewDefinition, y as SavedViewLayout, d as SavedViewRow, z as SavedViewSpecIn, B as StoreFilter, C as StuckRow, E as Subscription, F as SubscriptionBlock, S as SubscriptionCadence, G as SubscriptionSpec, H as callersTimeZone, I as hasQuietHours, J as isRuleFilter, K as liftWithheld, L as measureKey, N as stableFilterKey, O as withCallersClock } from '../subscription-Bgwz2bhc.cjs';
@@ -5,7 +5,7 @@ import { d as RecordsDataSource } from '../ports-Ds4p6jgW.js';
5
5
  export { M as MyLevel, O as OpLedger, P as PERMISSION_LEVELS, g as PermissionLevel, h as RecordsActor, e as RecordsChangeSink, a as RecordsConfig, c as RecordsErrorSink, i as RecordsFilter, R as RecordsRealtimePort, j as RecordsResolverPort, k as RecordsResponse, l as RecordsTableQuery, b as RowAgentPort, f as RowAgentTarget, m as asPermissionLevel, n as atLeast, o as createOpLedger, p as defaultOpLedger, q as forgetAllOps, r as highestLevel, s as isOwnOp, t as mintOpId, u as rememberedOpCount } from '../ports-Ds4p6jgW.js';
6
6
  import { F as Field } from '../field-DNZa8pwR.js';
7
7
  export { A as ADDRESS_PARTS, c as AGENT_WRITER_WORDS, d as AddressPart, e as AddressValue, B as BARCODE_SYMBOLOGIES, f as BUTTON_DOES, g as ButtonDoes, h as ButtonPressed, i as ButtonSettings, C as ChoiceOptions, j as CoerceOptions, k as Coerced, l as CoercedAnswers, m as CoercibleField, n as FIELD_KINDS, o as FieldDuplicated, p as FieldKind, q as FieldOptionEdit, r as FieldPatch, s as FieldProposal, b as FieldRule, a as FieldTypeWord, K as KernelTargets, t as NEWER_FIELD_KINDS, u as NOT_A_MEMBER_WORDS, N as NewFieldDeclaration, v as NewerFieldKind, P as ParityFieldTypeDescriptor, w as PersonStamp, R as RelationDisplay, x as RelationNameIndex, y as RelationNameMatch, z as RelationNamesAnswer, S as STATUS_GROUPS, D as STATUS_GROUP_WORDS, E as SYSTEM_WRITER_WORDS, G as StatusGroup, T as TableProposal, H as addressFromText, I as addressMapUrl, J as addressText, L as allowsOtherValues, M as buttonNeeds, O as buttonOf, Q as buttonUrlPlaceholders, U as coerceTypedAnswer, V as coerceTypedAnswers, W as coercionLabel, X as durationText, Y as entityReferenceKindsOf, Z as fieldKindFor, _ as isAddressValue, $ as isButtonField, a0 as isEntityReferenceConfig, a1 as isPersonStamp, a2 as newerKindExportWords, a3 as newerKindOf, a4 as newerKindWords, a5 as personStampText, a6 as ratingMaxOf, a7 as readTypedDuration, a8 as relationNameIndexOf, a9 as relationNameKey, aa as relationNamesIn, ab as richTextPlain, ac as safeLinkHref, ad as splitListCell, ae as statusGroupOf } from '../field-DNZa8pwR.js';
8
- export { CaptureQueue, CaptureQueueCounts, CaptureQueueOptions, CaptureQueuePorts, CaptureQueueStore, CaptureSyncReport, ChooseAlternateArgs, MergeField, MergeFieldProvenance, MergeFieldResolution, MergeFieldTransform, MissingBehavior, QueuedCapture, QueuedCaptureFile, QueuedCaptureState, REFUSALS_WORTH_REPEATING, ResolutionTriple, TypedDate, TypedMatchScore, TypedNumber, TypedTime, alternatePatch, autonumberJoin, autonumberPrefixOf, autonumberSearchOf, autonumberWords, chooseAlternate, filterWithAutonumber, indexedDbStore, isAutonumberField, isDecided, localeDateOrder, memoryStore, mintClientKey, openCaptureQueue, rankTypedMatches, readTypedDate, readTypedNumber, readTypedTime, twoDigitYear, typedDateText, typedMatchScore, typedTimeText } from '../index.js';
8
+ export { BaseCopied, BaseCopyProgress, BaseCopyResult, BasePort, BaseSnapshotRecord, BaseTable, CaptureQueue, CaptureQueueCounts, CaptureQueueOptions, CaptureQueuePorts, CaptureQueueStore, CaptureSyncReport, ChooseAlternateArgs, MergeField, MergeFieldProvenance, MergeFieldResolution, MergeFieldTransform, MissingBehavior, QueuedCapture, QueuedCaptureFile, QueuedCaptureState, REFUSALS_WORTH_REPEATING, ResolutionTriple, TypedDate, TypedMatchScore, TypedNumber, TypedTime, alternatePatch, autonumberJoin, autonumberPrefixOf, autonumberSearchOf, autonumberWords, baseCopyName, chooseAlternate, duplicateBase, filterWithAutonumber, indexedDbStore, isAutonumberField, isDecided, localeDateOrder, memoryStore, mintClientKey, openCaptureQueue, rankTypedMatches, readTypedDate, readTypedNumber, readTypedTime, restoreSnapshot, snapshotBase, twoDigitYear, typedDateText, typedMatchScore, typedTimeText } from '../index.js';
9
9
  export { B as BookingAvailability, a as BookingDeclared, b as BookingSummary, c as BookingWindow, d as FormResults, e as FormRoute, F as FormSummary, f as Rule, g as RuleAnswer, R as RuleExpression, h as bookingPath, p as publicFormPath } from '../rule-FYhputNm.js';
10
10
  export { D as DEFAULT_PORTAL_ARCHIVE_FILTER, F as FormLookOptions, a as PORTAL_ACCENTS, b as PORTAL_ARCHIVE_FILTERS, P as PortalAccent, c as PortalArchiveAnswer, d as PortalArchiveFilter, e as PortalCard, f as PortalConfig, g as PortalConfigInput, h as PortalFooterLink, i as PortalFormAnswer, j as PortalFormInput, k as PortalFormRef, l as PortalFormSpec, m as PortalInvitation, n as PortalPreviewRow, o as PortalPrincipal, p as PortalRevocation, q as PortalStage, r as PortalStyle, s as PortalStyleInput, t as PortalSummary, u as PortalTableExposure, v as PortalTableRef, w as PublicPicture, x as emptyPortalArchiveLine, y as isPortalAccent, z as isPortalArchiveFilter, A as portalArchiveConsequence, B as portalConfirmLine, C as portalPath, E as portalTitleTypedBack } from '../portal-SMT7B_YY.js';
11
11
  export { A as AggregateBucket, e as AggregateCompare, f as AggregateCompareKind, g as AggregateCompareWindows, h as AggregateDelta, b as AggregateFilter, i as AggregateGroupValue, c as AggregateMeasure, a as AggregateOperation, j as AggregateRow, k as AggregateWindow, l as DashboardBlock, D as DashboardBlockKind, m as DashboardBlockResult, n as DashboardRunResult, o as DashboardSummary, p as DashboardTarget, q as DashboardTargetBase, r as DashboardTargetOp, s as DashboardTargetResult, t as DashboardTotals, u as DigestPreview, M as MySubscription, Q as QuietHours, R as RecordFilter, v as RowTemplateRow, w as SavedViewColorBy, x as SavedViewDefinition, y as SavedViewLayout, d as SavedViewRow, z as SavedViewSpecIn, B as StoreFilter, C as StuckRow, E as Subscription, F as SubscriptionBlock, S as SubscriptionCadence, G as SubscriptionSpec, H as callersTimeZone, I as hasQuietHours, J as isRuleFilter, K as liftWithheld, L as measureKey, N as stableFilterKey, O as withCallersClock } from '../subscription-CgFzPsx2.js';
@@ -1690,6 +1690,80 @@ function moveConsequence(home, to) {
1690
1690
  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.`;
1691
1691
  }
1692
1692
 
1693
+ // src/base.ts
1694
+ function baseCopyName(name) {
1695
+ return `${name.trim() || "Base"} (copy)`;
1696
+ }
1697
+ async function duplicateBase(port, args) {
1698
+ const made = [];
1699
+ const pairs = {};
1700
+ const notCopied = /* @__PURE__ */ new Set();
1701
+ for (const [i, table] of args.tables.entries()) {
1702
+ const res = await port.tableDuplicate({
1703
+ tableId: table.id,
1704
+ withRecords: args.withRecords,
1705
+ organizationId: args.organizationId,
1706
+ name: args.nameFor ? args.nameFor(table) : table.name,
1707
+ onProgress: (pass) => args.onProgress?.({ at: i + 1, of: args.tables.length, tableName: table.name, pass })
1708
+ });
1709
+ if (!res.ok) return { ok: false, error: res.error, stoppedAt: table, made };
1710
+ pairs[table.id] = res.data.table.id;
1711
+ made.push({ from: table, copy: res.data.table, records: res.data.copied.records });
1712
+ for (const n of res.data.notCopied) notCopied.add(n);
1713
+ }
1714
+ const fin = args.tables.length > 1 ? await port.finish({ organizationId: args.organizationId, pairs }) : null;
1715
+ if (fin && !fin.ok) return { ok: false, error: fin.error, stoppedAt: args.tables[args.tables.length - 1], made };
1716
+ return {
1717
+ ok: true,
1718
+ data: {
1719
+ pairs,
1720
+ tables: made,
1721
+ relinkedColumns: fin?.ok ? fin.data.relinked_columns : 0,
1722
+ relinkedCells: fin?.ok ? fin.data.relinked_cells : 0,
1723
+ notCopied: [...notCopied]
1724
+ }
1725
+ };
1726
+ }
1727
+ async function snapshotBase(port, args) {
1728
+ const copied = await duplicateBase(port, {
1729
+ organizationId: args.organizationId,
1730
+ tables: args.tables,
1731
+ withRecords: true,
1732
+ nameFor: (t) => `Snapshot ${args.label} \xB7 ${t.name}`,
1733
+ ...args.onProgress ? { onProgress: args.onProgress } : {}
1734
+ });
1735
+ if (!copied.ok) {
1736
+ for (const m of copied.made) await port.archive?.(m.copy.id);
1737
+ return { ok: false, error: copied.error, stoppedAt: copied.stoppedAt };
1738
+ }
1739
+ for (const t of copied.data.tables) {
1740
+ const away = await port.archive?.(t.copy.id);
1741
+ if (away && !away.ok) return { ok: false, error: away.error, stoppedAt: t.from };
1742
+ }
1743
+ return {
1744
+ ok: true,
1745
+ snapshot: {
1746
+ label: args.label,
1747
+ origin: args.origin ?? "manual",
1748
+ tables: copied.data.tables.map((t) => ({ table_id: t.from.id, snapshot_table_id: t.copy.id, name: t.from.name, records: t.records }))
1749
+ }
1750
+ };
1751
+ }
1752
+ async function restoreSnapshot(port, args) {
1753
+ const sources = args.snapshot.tables.map((t) => ({ id: t.snapshot_table_id, name: t.name }));
1754
+ const byCopy = new Map(args.snapshot.tables.map((t) => [t.snapshot_table_id, t.name]));
1755
+ for (const s of sources) await port.unarchive?.(s.id);
1756
+ const out = await duplicateBase(port, {
1757
+ organizationId: args.organizationId,
1758
+ tables: sources,
1759
+ withRecords: true,
1760
+ nameFor: (t) => `${byCopy.get(t.id) ?? t.name} (restored)`,
1761
+ ...args.onProgress ? { onProgress: args.onProgress } : {}
1762
+ });
1763
+ for (const s of sources) await port.archive?.(s.id);
1764
+ return out;
1765
+ }
1766
+
1693
1767
  // src/capture-queue.ts
1694
1768
  var DB_NAME = "matrx-capture";
1695
1769
  var DB_VERSION = 1;
@@ -11876,6 +11950,7 @@ export {
11876
11950
  autonumberPrefixOf,
11877
11951
  autonumberSearchOf,
11878
11952
  autonumberWords,
11953
+ baseCopyName,
11879
11954
  blockLandedInStore,
11880
11955
  bookingPath,
11881
11956
  buttonNeeds,
@@ -11904,6 +11979,7 @@ export {
11904
11979
  drillAnswerOf,
11905
11980
  drillFindingKnob,
11906
11981
  dropPrimedDoorAnswers,
11982
+ duplicateBase,
11907
11983
  durationText,
11908
11984
  emptyArchiveLine,
11909
11985
  emptyPortalArchiveLine,
@@ -12026,6 +12102,7 @@ export {
12026
12102
  rememberedOpCount,
12027
12103
  removedChoicesInUse,
12028
12104
  resolveObjectOrganization,
12105
+ restoreSnapshot,
12029
12106
  richTextPlain,
12030
12107
  ruleThatRefuses,
12031
12108
  rulesWithTopStar,
@@ -12036,6 +12113,7 @@ export {
12036
12113
  seedKey,
12037
12114
  seededDataSource,
12038
12115
  sheetSyncSpec,
12116
+ snapshotBase,
12039
12117
  sourceArchivedOf,
12040
12118
  splitListCell,
12041
12119
  splitLockedRows,