@aglyn/aglyn 1.19.0 → 1.20.1
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/package.json +11 -11
- package/src/lib/app-utils/analytics-events.d.ts +44 -0
- package/src/lib/app-utils/analytics-events.js +226 -21
- package/src/lib/app-utils/analytics-events.js.map +1 -1
- package/src/lib/app-utils/analytics-link-clicks.js +3 -4
- package/src/lib/app-utils/analytics-link-clicks.js.map +1 -1
- package/src/lib/app-utils/crm.d.ts +80 -1
- package/src/lib/app-utils/crm.js +136 -5
- package/src/lib/app-utils/crm.js.map +1 -1
- package/src/lib/app-utils/docs-help-sections.generated.js +1 -1
- package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
- package/src/lib/app-utils/docs-help.generated.d.ts +1 -1
- package/src/lib/app-utils/docs-help.generated.js +5 -1
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +26 -12
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/error-beacon.d.ts +8 -0
- package/src/lib/app-utils/error-beacon.js +11 -0
- package/src/lib/app-utils/error-beacon.js.map +1 -1
- package/src/lib/plugin-manager/feature-plugins.d.ts +8 -0
- package/src/lib/plugin-manager/feature-plugins.js.map +1 -1
- package/src/lib/plugin-manager/first-party-plugins.generated.d.ts +6 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.js +20 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
- package/src/lib/plugin-manager/plugin-scope-sharing.d.ts +22 -0
- package/src/lib/plugin-manager/plugin-scope-sharing.js +21 -1
- package/src/lib/plugin-manager/plugin-scope-sharing.js.map +1 -1
- package/src/lib/plugin-manager/plugin-site-exclusions.d.ts +107 -0
- package/src/lib/plugin-manager/plugin-site-exclusions.js +169 -0
- package/src/lib/plugin-manager/plugin-site-exclusions.js.map +1 -0
- package/src/lib/plugin-manager/plugin-site-resources.d.ts +19 -0
- package/src/lib/plugin-manager/plugin-site-resources.js +2 -0
- package/src/lib/plugin-manager/plugin-site-resources.js.map +1 -1
package/src/lib/app-utils/crm.js
CHANGED
|
@@ -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
|
|
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
|