@aglyn/aglyn 1.18.0 → 1.20.0

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.
Files changed (47) hide show
  1. package/package.json +11 -11
  2. package/src/lib/app-utils/analytics-events.d.ts +44 -0
  3. package/src/lib/app-utils/analytics-events.js +226 -21
  4. package/src/lib/app-utils/analytics-events.js.map +1 -1
  5. package/src/lib/app-utils/analytics-link-clicks.js +3 -4
  6. package/src/lib/app-utils/analytics-link-clicks.js.map +1 -1
  7. package/src/lib/app-utils/compose-reusable-components.js +7 -3
  8. package/src/lib/app-utils/compose-reusable-components.js.map +1 -1
  9. package/src/lib/app-utils/crm.d.ts +80 -1
  10. package/src/lib/app-utils/crm.js +136 -5
  11. package/src/lib/app-utils/crm.js.map +1 -1
  12. package/src/lib/app-utils/docs-help-sections.generated.js +1 -1
  13. package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
  14. package/src/lib/app-utils/docs-help.generated.d.ts +2 -2
  15. package/src/lib/app-utils/docs-help.generated.js +6 -1
  16. package/src/lib/app-utils/docs-help.generated.js.map +1 -1
  17. package/src/lib/app-utils/docs-index.generated.js +44 -16
  18. package/src/lib/app-utils/docs-index.generated.js.map +1 -1
  19. package/src/lib/app-utils/element-motion.js +6 -5
  20. package/src/lib/app-utils/element-motion.js.map +1 -1
  21. package/src/lib/app-utils/expand-repeatables.d.ts +23 -3
  22. package/src/lib/app-utils/expand-repeatables.js +61 -7
  23. package/src/lib/app-utils/expand-repeatables.js.map +1 -1
  24. package/src/lib/app-utils/plugin-connection-editor.d.ts +22 -0
  25. package/src/lib/app-utils/plugin-connection-editor.js.map +1 -1
  26. package/src/lib/app-utils/plugin-connection-repeat.d.ts +82 -0
  27. package/src/lib/app-utils/plugin-connection-repeat.js +162 -0
  28. package/src/lib/app-utils/plugin-connection-repeat.js.map +1 -0
  29. package/src/lib/app-utils/repeat-sources.d.ts +33 -1
  30. package/src/lib/app-utils/repeat-sources.js +27 -3
  31. package/src/lib/app-utils/repeat-sources.js.map +1 -1
  32. package/src/lib/app-utils/seo-page-facts.js +3 -6
  33. package/src/lib/app-utils/seo-page-facts.js.map +1 -1
  34. package/src/lib/plugin-manager/feature-plugins.d.ts +8 -0
  35. package/src/lib/plugin-manager/feature-plugins.js.map +1 -1
  36. package/src/lib/plugin-manager/first-party-plugins.generated.d.ts +6 -0
  37. package/src/lib/plugin-manager/first-party-plugins.generated.js +8 -0
  38. package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
  39. package/src/lib/plugin-manager/plugin-scope-sharing.d.ts +22 -0
  40. package/src/lib/plugin-manager/plugin-scope-sharing.js +21 -1
  41. package/src/lib/plugin-manager/plugin-scope-sharing.js.map +1 -1
  42. package/src/lib/plugin-manager/plugin-site-exclusions.d.ts +107 -0
  43. package/src/lib/plugin-manager/plugin-site-exclusions.js +169 -0
  44. package/src/lib/plugin-manager/plugin-site-exclusions.js.map +1 -0
  45. package/src/lib/plugin-manager/repeat-rows.d.ts +20 -2
  46. package/src/lib/plugin-manager/repeat-rows.js +42 -16
  47. package/src/lib/plugin-manager/repeat-rows.js.map +1 -1
@@ -50,7 +50,7 @@ import { type ContactLifecycleStage, type CrmActivityKind, type CrmTaskKind } fr
50
50
  import { type ContactInteraction, type ContactSegment, type ContactSource } from './contacts';
51
51
  import { type EmailState } from './email-state';
52
52
  import { mintPicklistValueId, normalizePicklistLabel, picklistActiveValues, picklistDefaultLabel, picklistFromLabels, type PicklistJudgement, picklistOptions, type PicklistOption, picklistRank, type PicklistSpec, type PicklistValue, picklistValueByLabel, type PicklistValueSet } from './picklists';
53
- import { type ScopeToken } from './scope-tokens';
53
+ import { SCOPE_MODE_ALL_EXCEPT, type ScopeToken } from './scope-tokens';
54
54
  export * from './crm-kinds';
55
55
  /**
56
56
  * The CRM's collections, every one under `orgs/{orgId}/`.
@@ -221,6 +221,14 @@ export type CrmCustomValue = ContactCustomValue;
221
221
  */
222
222
  export interface CrmScoped {
223
223
  visibleTo: string[];
224
+ /**
225
+ * Shared with all sites except some (AGL-4047): the marker the sweep keeps
226
+ * `visibleTo` level by as sites come and go. Only a server writes it — see
227
+ * `crmScopeFields` and `crmDefaultMarkerOf`.
228
+ */
229
+ scopeMode?: typeof SCOPE_MODE_ALL_EXCEPT;
230
+ /** The sites left out, as `host:` tokens, beside {@link CrmScoped.scopeMode}. */
231
+ scopeExcept?: string[];
224
232
  /** The site that created it, or `null` for one that came from no site. */
225
233
  hostId: string | null;
226
234
  createdAt?: unknown;
@@ -1462,6 +1470,72 @@ export declare const CRM_DEFAULT_RECORD_SCOPE_PATH = "crm.defaultRecordScope";
1462
1470
  * a record kept to its site is still visible where it was made.
1463
1471
  */
1464
1472
  export declare function crmDefaultScopeOf(orgDocument: Record<string, unknown> | null | undefined): 'org' | 'host' | undefined;
1473
+ /** Where the sites the CRM default leaves out are stored (AGL-4047). */
1474
+ export declare const CRM_DEFAULT_RECORD_EXCEPT_PATH = "crm.defaultRecordExcept";
1475
+ /**
1476
+ * When the default was last set to all sites except some, a server timestamp: a record
1477
+ * created before it was not stamped by it, so only an explicit "Apply to
1478
+ * existing records" run gives such a record the default (AGL-4047).
1479
+ */
1480
+ export declare const CRM_DEFAULT_RECORD_EXCEPT_AT_PATH = "crm.defaultRecordExceptAt";
1481
+ /**
1482
+ * The most sites the CRM default may reach when it leaves some out. A record's
1483
+ * scoped search fields grow by site and by prefix (`scopedSearchTokens`), so
1484
+ * past this the choice is switched off and a record stops gaining sites.
1485
+ */
1486
+ export declare const CRM_DEFAULT_MAX_INCLUDED = 30;
1487
+ /**
1488
+ * The sites the CRM default leaves out, when it is all sites except some, or
1489
+ * null. Only the org's own `crm.defaultRecordScope: 'host'` carries it: the
1490
+ * older dataset default never did.
1491
+ */
1492
+ export declare function crmDefaultExceptOf(orgDocument: Record<string, unknown> | null | undefined): string[] | null;
1493
+ /** The CRM default as the settings card offers it: one of three choices. */
1494
+ export declare function crmDefaultSharingOf(orgDocument: Record<string, unknown> | null | undefined): 'org' | 'host' | 'allExcept' | undefined;
1495
+ /** What a new record stores of its sites: `visibleTo`, and the marker when the default leaves sites out. */
1496
+ export interface CrmScopeFields {
1497
+ visibleTo: ScopeToken[];
1498
+ scopeMode?: typeof SCOPE_MODE_ALL_EXCEPT;
1499
+ scopeExcept?: ScopeToken[];
1500
+ }
1501
+ /**
1502
+ * The sites a new record is stamped with under the org's CRM default, and,
1503
+ * for all sites except some, the marker the sweep keeps it level by
1504
+ * (AGL-4047): the workspace's sites (`orgs/{orgId}.hosts`) less the ones left
1505
+ * out, plus the site it came in on, which keeps the person whatever the
1506
+ * default leaves out.
1507
+ *
1508
+ * It never guesses wider. A document with no sites map, or a choice that would
1509
+ * reach more than {@link CRM_DEFAULT_MAX_INCLUDED} sites, stamps the site it
1510
+ * came in on and its group, as "Only the site they came in on" does. Once no
1511
+ * site left out is still in the workspace the default IS all sites, and the
1512
+ * record is stamped `['org']`, as the sweep would collapse it.
1513
+ *
1514
+ * Only a server writer stores the marker; the rules refuse it from a client,
1515
+ * whose record the server marks on its follow-up (`crm/sharing` `evaluate`).
1516
+ */
1517
+ export declare function crmScopeFields(org: Record<string, unknown> | null | undefined, group: ConsentGroup): CrmScopeFields;
1518
+ /** The marker half of {@link CrmScopeFields}: both keys, or neither. */
1519
+ export type CrmScopeMarker = Pick<CrmScopeFields, 'scopeMode' | 'scopeExcept'>;
1520
+ /**
1521
+ * The marker a record about to be CREATED carries under the CRM default
1522
+ * "All sites except…" (AGL-4047), for a writer that stamped its sites some
1523
+ * other way than {@link crmScopeFields}: an activity or a task filed beside a
1524
+ * person, a company or a deal made from a site, an entry that copied the
1525
+ * record it is about.
1526
+ *
1527
+ * Only when the sites it is about to store are EXACTLY what the default
1528
+ * stamps for the site it came in on (`hostId`), so a record shared by hand,
1529
+ * one stamped narrower or wider, one from no site, and every record of an org
1530
+ * whose default is not all sites except some, gets `{}`. A writer spreads it
1531
+ * beside `visibleTo` and nothing it stamped moves; the sweep then keeps the
1532
+ * record level as sites come and go, as it keeps a record the default stamped
1533
+ * through `crmScopeFields`.
1534
+ */
1535
+ export declare function crmDefaultMarkerOf(org: Record<string, unknown> | null | undefined, record: {
1536
+ hostId?: unknown;
1537
+ visibleTo?: unknown;
1538
+ }): CrmScopeMarker;
1465
1539
  /**
1466
1540
  * Whether a capture from a work email domain no visible company carries
1467
1541
  * should CREATE the company. Off unless the org document says `true`: a
@@ -1609,6 +1683,11 @@ export declare function newAssignmentRuleId(existing: readonly string[]): string
1609
1683
  * a scoped member creating a record outside their own tokens, so a creator
1610
1684
  * that bypassed this could only make its record invisible to itself, never
1611
1685
  * wider.
1686
+ *
1687
+ * A third answer since AGL-4047: under "All sites except…", every site of
1688
+ * the workspace but the ones left out, plus the site it came in on
1689
+ * ({@link crmScopeFields}, which a server writer spreads to store the marker
1690
+ * as well).
1612
1691
  */
1613
1692
  export declare function crmScopeTokens(org: Record<string, unknown> | null | undefined, group: ConsentGroup): ScopeToken[];
1614
1693
  /**
@@ -43,13 +43,13 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
43
43
  * Pure data module: types, constants and the small helpers every surface
44
44
  * would otherwise write for itself. No Firestore, no React.
45
45
  */ import { normalizeAddress, normalizePhone } from "../foundation/definitions/contact.types.js";
46
- import { consentGroupScope } from "./consent-groups.js";
46
+ import { consentGroupScope, soloConsentGroup } from "./consent-groups.js";
47
47
  import { CONTACT_LIFECYCLE_STAGES, CRM_TASK_KINDS, isContactLifecycleStage } from "./crm-kinds.js";
48
48
  import { CONTACT_ALTERNATE_EMAILS_FIELD, CONTACT_FACETS_FIELD, composeContactName, normalizeContactEmail, readContactFacet } from "./contacts.js";
49
49
  import { isEmailStateStatus } from "./email-state.js";
50
50
  import { NAME_TOKEN_MAX_PREFIX, nameSearchKey, nameSearchTokens, SCOPED_SEARCH_JOIN, scopedSearchTokens } from "./name-search.js";
51
51
  import { effectivePicklistValueSet, isStandardPicklistValueId, judgePicklistValue, mintPicklistValueId, normalizePicklistLabel, normalizePicklistValueSet, PICKLIST_VALUES_MAX, picklistActiveValues, picklistDefaultLabel, picklistFromLabels, picklistOptions, picklistRank, picklistRefusalSentence, picklistValueByLabel } from "./picklists.js";
52
- import { MAX_SCOPE_HOSTS, ORG_SCOPE_TOKEN } from "./scope-tokens.js";
52
+ import { hostScopeToken, MAX_SCOPE_HOSTS, ORG_SCOPE_TOKEN, SCOPE_MODE_ALL_EXCEPT } from "./scope-tokens.js";
53
53
  import { isKnownContactSource, labelContactSource } from "../plugin-manager/plugin-contact-capture.js";
54
54
  // The fixed vocabularies and their guards live in a leaf module; every name
55
55
  // stays importable from here.
@@ -1662,6 +1662,134 @@ const blank = (value)=>value === null || typeof value === 'string' && value.trim
1662
1662
  const legacy = orgDocument['defaultResourceScope'];
1663
1663
  return legacy === 'org' || legacy === 'host' ? legacy : 'org';
1664
1664
  }
1665
+ /*==========================================
1666
+ * ALL SITES EXCEPT SOME, AS THE CRM DEFAULT (AGL-4047).
1667
+ *
1668
+ * Stored as `defaultRecordScope: 'host'` beside `defaultRecordExcept`, the
1669
+ * site ids left out, so a reader that predates the choice — an app build in
1670
+ * a tester's hands, a console tab open across the deploy — reads "the site it
1671
+ * came in on" and never shares a new record with a site left out. Every
1672
+ * reader here answers the third choice from the two together, and
1673
+ * `crmDefaultScopeOf` keeps answering `'host'` for it: a caller asking "does
1674
+ * every site get it?" gets the true no.
1675
+ *=========================================*/ /** Where the sites the CRM default leaves out are stored (AGL-4047). */ export const CRM_DEFAULT_RECORD_EXCEPT_PATH = `${ORG_CRM_SETTINGS_FIELD}.defaultRecordExcept`;
1676
+ /**
1677
+ * When the default was last set to all sites except some, a server timestamp: a record
1678
+ * created before it was not stamped by it, so only an explicit "Apply to
1679
+ * existing records" run gives such a record the default (AGL-4047).
1680
+ */ export const CRM_DEFAULT_RECORD_EXCEPT_AT_PATH = `${ORG_CRM_SETTINGS_FIELD}.defaultRecordExceptAt`;
1681
+ /**
1682
+ * The most sites the CRM default may reach when it leaves some out. A record's
1683
+ * scoped search fields grow by site and by prefix (`scopedSearchTokens`), so
1684
+ * past this the choice is switched off and a record stops gaining sites.
1685
+ */ export const CRM_DEFAULT_MAX_INCLUDED = MAX_SCOPE_HOSTS;
1686
+ function crmSettingsOf(orgDocument) {
1687
+ const settings = orgDocument == null ? void 0 : orgDocument[ORG_CRM_SETTINGS_FIELD];
1688
+ return settings && typeof settings === 'object' && !Array.isArray(settings) ? settings : {};
1689
+ }
1690
+ /** The sites `orgs/{orgId}.hosts` names, or null when the document carries no map. */ function orgHostMapIds(orgDocument) {
1691
+ const hosts = orgDocument == null ? void 0 : orgDocument['hosts'];
1692
+ if (!hosts || typeof hosts !== 'object' || Array.isArray(hosts)) return null;
1693
+ return Object.entries(hosts).filter(([, on])=>Boolean(on)).map(([id])=>id);
1694
+ }
1695
+ /**
1696
+ * The sites the CRM default leaves out, when it is all sites except some, or
1697
+ * null. Only the org's own `crm.defaultRecordScope: 'host'` carries it: the
1698
+ * older dataset default never did.
1699
+ */ export function crmDefaultExceptOf(orgDocument) {
1700
+ const settings = crmSettingsOf(orgDocument);
1701
+ if (settings['defaultRecordScope'] !== 'host') return null;
1702
+ const except = settings['defaultRecordExcept'];
1703
+ if (!Array.isArray(except)) return null;
1704
+ const ids = [
1705
+ ...new Set(except.filter((id)=>typeof id === 'string' && Boolean(id)))
1706
+ ];
1707
+ return ids.length ? ids : null;
1708
+ }
1709
+ /** The CRM default as the settings card offers it: one of three choices. */ export function crmDefaultSharingOf(orgDocument) {
1710
+ if (crmDefaultExceptOf(orgDocument)) return 'allExcept';
1711
+ return crmDefaultScopeOf(orgDocument);
1712
+ }
1713
+ /**
1714
+ * The sites a new record is stamped with under the org's CRM default, and,
1715
+ * for all sites except some, the marker the sweep keeps it level by
1716
+ * (AGL-4047): the workspace's sites (`orgs/{orgId}.hosts`) less the ones left
1717
+ * out, plus the site it came in on, which keeps the person whatever the
1718
+ * default leaves out.
1719
+ *
1720
+ * It never guesses wider. A document with no sites map, or a choice that would
1721
+ * reach more than {@link CRM_DEFAULT_MAX_INCLUDED} sites, stamps the site it
1722
+ * came in on and its group, as "Only the site they came in on" does. Once no
1723
+ * site left out is still in the workspace the default IS all sites, and the
1724
+ * record is stamped `['org']`, as the sweep would collapse it.
1725
+ *
1726
+ * Only a server writer stores the marker; the rules refuse it from a client,
1727
+ * whose record the server marks on its follow-up (`crm/sharing` `evaluate`).
1728
+ */ export function crmScopeFields(org, group) {
1729
+ const scope = crmDefaultScopeOf(org);
1730
+ if (scope === 'org') return {
1731
+ visibleTo: [
1732
+ ORG_SCOPE_TOKEN
1733
+ ]
1734
+ };
1735
+ const kept = consentGroupScope(group);
1736
+ const except = crmDefaultExceptOf(org);
1737
+ const orgHostIds = except ? orgHostMapIds(org) : null;
1738
+ if (!except || !(orgHostIds == null ? void 0 : orgHostIds.length)) return {
1739
+ visibleTo: kept
1740
+ };
1741
+ const left = except.filter((id)=>orgHostIds.includes(id));
1742
+ if (!left.length) return {
1743
+ visibleTo: [
1744
+ ORG_SCOPE_TOKEN
1745
+ ]
1746
+ };
1747
+ const out = new Set(left);
1748
+ const included = [
1749
+ ...new Set([
1750
+ ...orgHostIds.filter((id)=>!out.has(id)),
1751
+ group.hostId
1752
+ ])
1753
+ ].filter(Boolean).sort();
1754
+ if (included.length > CRM_DEFAULT_MAX_INCLUDED) return {
1755
+ visibleTo: kept
1756
+ };
1757
+ return {
1758
+ visibleTo: included.map(hostScopeToken),
1759
+ scopeMode: SCOPE_MODE_ALL_EXCEPT,
1760
+ scopeExcept: left.sort().map(hostScopeToken)
1761
+ };
1762
+ }
1763
+ /**
1764
+ * The marker a record about to be CREATED carries under the CRM default
1765
+ * "All sites except…" (AGL-4047), for a writer that stamped its sites some
1766
+ * other way than {@link crmScopeFields}: an activity or a task filed beside a
1767
+ * person, a company or a deal made from a site, an entry that copied the
1768
+ * record it is about.
1769
+ *
1770
+ * Only when the sites it is about to store are EXACTLY what the default
1771
+ * stamps for the site it came in on (`hostId`), so a record shared by hand,
1772
+ * one stamped narrower or wider, one from no site, and every record of an org
1773
+ * whose default is not all sites except some, gets `{}`. A writer spreads it
1774
+ * beside `visibleTo` and nothing it stamped moves; the sweep then keeps the
1775
+ * record level as sites come and go, as it keeps a record the default stamped
1776
+ * through `crmScopeFields`.
1777
+ */ export function crmDefaultMarkerOf(org, record) {
1778
+ const hostId = typeof record.hostId === 'string' ? record.hostId.trim() : '';
1779
+ if (!hostId || !Array.isArray(record.visibleTo) || !crmDefaultExceptOf(org)) return {};
1780
+ const stamped = crmScopeFields(org, soloConsentGroup(hostId));
1781
+ if (!stamped.scopeMode || !stamped.scopeExcept) return {};
1782
+ const held = new Set(record.visibleTo);
1783
+ if (held.size !== stamped.visibleTo.length || !stamped.visibleTo.every((token)=>held.has(token))) {
1784
+ return {};
1785
+ }
1786
+ return {
1787
+ scopeMode: stamped.scopeMode,
1788
+ scopeExcept: [
1789
+ ...stamped.scopeExcept
1790
+ ]
1791
+ };
1792
+ }
1665
1793
  /**
1666
1794
  * Whether a capture from a work email domain no visible company carries
1667
1795
  * should CREATE the company. Off unless the org document says `true`: a
@@ -1906,10 +2034,13 @@ export function readCrmAssignmentSettings(orgDocument) {
1906
2034
  * a scoped member creating a record outside their own tokens, so a creator
1907
2035
  * that bypassed this could only make its record invisible to itself, never
1908
2036
  * wider.
2037
+ *
2038
+ * A third answer since AGL-4047: under "All sites except…", every site of
2039
+ * the workspace but the ones left out, plus the site it came in on
2040
+ * ({@link crmScopeFields}, which a server writer spreads to store the marker
2041
+ * as well).
1909
2042
  */ export function crmScopeTokens(org, group) {
1910
- return crmDefaultScopeOf(org) === 'org' ? [
1911
- ORG_SCOPE_TOKEN
1912
- ] : consentGroupScope(group);
2043
+ return crmScopeFields(org, group).visibleTo;
1913
2044
  }
1914
2045
  /**
1915
2046
  * The `visibleTo` tokens a reader of this group may LIST, for the