@aglyn/aglyn 1.24.0 → 1.25.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.
- package/package.json +11 -11
- package/src/lib/app-utils/activity-labels.js +4 -1
- package/src/lib/app-utils/activity-labels.js.map +1 -1
- package/src/lib/app-utils/business-details.d.ts +5 -0
- package/src/lib/app-utils/business-details.js +4 -0
- package/src/lib/app-utils/business-details.js.map +1 -1
- package/src/lib/app-utils/crm.d.ts +17 -30
- package/src/lib/app-utils/crm.js +139 -3
- package/src/lib/app-utils/crm.js.map +1 -1
- package/src/lib/app-utils/docs-help-sections.generated.js +4 -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 +7 -0
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +28 -7
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/host-tokens.d.ts +17 -0
- package/src/lib/app-utils/host-tokens.js +18 -0
- package/src/lib/app-utils/host-tokens.js.map +1 -1
- package/src/lib/app-utils/native-app-association.d.ts +5 -3
- package/src/lib/app-utils/native-app-association.js +5 -3
- package/src/lib/app-utils/native-app-association.js.map +1 -1
- package/src/lib/app-utils/native-nav.js +1 -1
- package/src/lib/app-utils/native-nav.js.map +1 -1
- package/src/lib/app-utils/plan-entitlements.d.ts +227 -36
- package/src/lib/app-utils/plan-entitlements.js +335 -43
- package/src/lib/app-utils/plan-entitlements.js.map +1 -1
- package/src/lib/app-utils/reusable-component-keys.d.ts +9 -0
- package/src/lib/app-utils/reusable-component-keys.js +9 -0
- package/src/lib/app-utils/reusable-component-keys.js.map +1 -1
- package/src/lib/app-utils/server.d.ts +1 -0
- package/src/lib/app-utils/server.js +1 -0
- package/src/lib/app-utils/server.js.map +1 -1
- package/src/lib/app-utils/sign-in-visibility.d.ts +78 -0
- package/src/lib/app-utils/sign-in-visibility.js +79 -0
- package/src/lib/app-utils/sign-in-visibility.js.map +1 -0
- package/src/lib/app-utils/site-live-url.d.ts +4 -1
- package/src/lib/app-utils/site-live-url.js +17 -3
- package/src/lib/app-utils/site-live-url.js.map +1 -1
- package/src/lib/app-utils/usage-level.d.ts +50 -0
- package/src/lib/app-utils/usage-level.js +94 -0
- package/src/lib/app-utils/usage-level.js.map +1 -0
- package/src/lib/foundation/definitions/org-billing.types.d.ts +24 -2
- package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/aglyn",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
"./package.json": "./package.json"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@aglyn/shared-data-enums": "1.
|
|
41
|
-
"@aglyn/shared-data-mdi": "1.
|
|
42
|
-
"@aglyn/shared-data-types": "1.
|
|
43
|
-
"@aglyn/shared-util-email": "1.
|
|
44
|
-
"@aglyn/shared-util-first-touch": "1.
|
|
45
|
-
"@aglyn/shared-util-http": "1.
|
|
46
|
-
"@aglyn/shared-util-logger": "1.
|
|
47
|
-
"@aglyn/shared-util-timestamp": "1.
|
|
48
|
-
"@aglyn/shared-util-tools": "1.
|
|
49
|
-
"@aglyn/shared-util-vendor": "1.
|
|
40
|
+
"@aglyn/shared-data-enums": "1.25.0",
|
|
41
|
+
"@aglyn/shared-data-mdi": "1.25.0",
|
|
42
|
+
"@aglyn/shared-data-types": "1.25.0",
|
|
43
|
+
"@aglyn/shared-util-email": "1.25.0",
|
|
44
|
+
"@aglyn/shared-util-first-touch": "1.25.0",
|
|
45
|
+
"@aglyn/shared-util-http": "1.25.0",
|
|
46
|
+
"@aglyn/shared-util-logger": "1.25.0",
|
|
47
|
+
"@aglyn/shared-util-timestamp": "1.25.0",
|
|
48
|
+
"@aglyn/shared-util-tools": "1.25.0",
|
|
49
|
+
"@aglyn/shared-util-vendor": "1.25.0",
|
|
50
50
|
"@data-driven-forms/react-form-renderer": "^4.2.3",
|
|
51
51
|
"@msgpack/msgpack": "^3.1.3",
|
|
52
52
|
"@types/unist": "^3.0.3",
|
|
@@ -126,6 +126,7 @@ import { isPluginJobTargetType, pluginActivityActionSentence, pluginActivityTarg
|
|
|
126
126
|
'host.reattach-domain': 'Reattached a domain',
|
|
127
127
|
'host.set-subdomain': 'Changed a site address',
|
|
128
128
|
'host.transfer': 'Transferred a site',
|
|
129
|
+
'host.usageLevel': 'Set the site usage level',
|
|
129
130
|
'lockdown.lock': 'Locked the workspace down',
|
|
130
131
|
'lockdown.payouts-pause': 'Paused payouts',
|
|
131
132
|
'lockdown.payouts-restore': 'Restored payouts',
|
|
@@ -160,6 +161,7 @@ import { isPluginJobTargetType, pluginActivityActionSentence, pluginActivityTarg
|
|
|
160
161
|
'org.successManagerSet': 'Assigned a success manager',
|
|
161
162
|
'org.upgradeProposal.propose': 'Proposed an upgrade',
|
|
162
163
|
'org.upgradeProposal.withdraw': 'Withdrew an upgrade proposal',
|
|
164
|
+
'org.usageLevel': 'Set the workspace usage level',
|
|
163
165
|
'orgs.unverified.reap': 'Removed unverified organizations',
|
|
164
166
|
'person.erased': 'Erased a person',
|
|
165
167
|
'person.erasure-requested': 'Requested erasure of a person',
|
|
@@ -194,7 +196,8 @@ import { isPluginJobTargetType, pluginActivityActionSentence, pluginActivityTarg
|
|
|
194
196
|
'user.setAdAudienceOptOut': 'Changed the ad audience opt-out',
|
|
195
197
|
'user.setPassword': 'Set the password',
|
|
196
198
|
'user.signOutDevice': 'Signed a device out',
|
|
197
|
-
'user.updateProfile': 'Updated the profile'
|
|
199
|
+
'user.updateProfile': 'Updated the profile',
|
|
200
|
+
'user.usageLevel': 'Set the account usage level'
|
|
198
201
|
};
|
|
199
202
|
/** Leading namespaces as a reader names them. */ const NAMESPACE_LABELS = {
|
|
200
203
|
org: 'Organization',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/activity-labels.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * ONE LABEL MAP FOR EVERY ACTIVITY AND AUDIT LIST (AGL-3660).\n *\n * Two logs feed the console's lists. The activity logs\n * (`orgs/{id}/activity`, `hosts/{id}/activity`) store a prose sentence or a\n * plugin's code plus a `{ type, id, name }` target. The staff audit trail\n * (`adminAudit`) stores a dotted code (`ai.job.output`, `org.override`) and\n * a Firestore PATH as its target (`orgs/abc/aiJobs/xyz`). The staff tables\n * printed both raw, so a reader saw `ai.job.output` next to\n * `orgs/9fK…/aiJobs/Qe2…` and had to know the schema to read their own\n * audit trail.\n *\n * Every list now draws its words from here: an action as a sentence\n * (`Created page Home with Aglyn AI`), a target as the site and the item,\n * and — for an audit row — why, the credits it spent and what came of it.\n * The raw code and path are kept on the description, for a tooltip and for\n * the staff details dialog, and never as the visible text.\n */\n\nimport {\n activityActionLabel,\n activityPrimaryText,\n activityTypeLabel,\n type ActivityEntryLike,\n type ActivityTargetLike,\n} from './activity-presenter'\nimport { orgOverrideReasonSummary } from './org-override-reason'\nimport {\n isPluginJobTargetType,\n pluginActivityActionSentence,\n pluginActivityTargetLabel,\n pluginStaffAuditActionLabel,\n pluginStaffAuditCollection,\n pluginStaffAuditDescribe,\n} from '../plugin-manager/plugin-activity-actions'\n\n/** What a list row and the details dialog show for one entry. */\nexport interface ActivityDescription {\n /** The act, as a sentence. Never a code. */\n action: string\n /** What it was done to, in words: the site and the item. Never a path. */\n target: string\n /** Why it was done, when the writer recorded a reason. */\n why: string | null\n /** AI credits it spent, when it spent any. */\n credits: number | null\n /** What came of it, when the writer recorded an outcome. */\n result: string | null\n /** The stored code, when the action was one — for a tooltip and staff. */\n code: string | null\n /** The stored target path (audit) or `type/id` (activity) — staff only. */\n path: string | null\n /** The organization the entry concerns, when it names one. */\n orgId: string | null\n /** The site the entry concerns, when it names one. */\n hostId: string | null\n /** The plugin job behind the entry (an AI job), when there is one. */\n jobId: string | null\n /** The account the entry concerns, when it names one. */\n uid: string | null\n}\n\n/** Names a route resolved for the ids an entry carries. */\nexport interface ActivityNames {\n /** Organization name by org id. */\n orgs?: Readonly<Record<string, string | null | undefined>>\n /** Site name by host id. */\n hosts?: Readonly<Record<string, string | null | undefined>>\n /** An account's address (or name) by uid. */\n users?: Readonly<Record<string, string | null | undefined>>\n}\n\n/** `screen` → `page`, `Home` → `page Home`: the noun a sentence uses. */\nexport function activityTargetPhrase(target: ActivityTargetLike | null | undefined): string {\n const noun = activityTypeLabel(target?.type)\n const lower = noun === 'Item' ? 'item' : noun.charAt(0).toLowerCase() + noun.slice(1)\n const name = target?.name?.trim()\n return name ? `${lower} ${name}` : lower\n}\n\n/**\n * An activity row's action as a sentence about its target. A plugin code\n * with a declared sentence fills it (`Created {target} with Aglyn AI`); any\n * other code reads as its label, and a prose action as itself.\n */\nexport function activityActionSentence(\n action: string | undefined,\n target?: ActivityTargetLike | null,\n): string {\n const stored = action?.trim() ?? ''\n const sentence = pluginActivityActionSentence(stored)\n if (sentence) return sentence.replace('{target}', activityTargetPhrase(target))\n return activityActionLabel(stored)\n}\n\n/**\n * A one-column feed's line: the sentence when the code declares one, else\n * the action with its target's name (`Saved the screen — Home`).\n */\nexport function activityRowText(entry: ActivityEntryLike): string {\n const stored = entry.action?.trim() ?? ''\n return pluginActivityActionSentence(stored)\n ? activityActionSentence(stored, entry.target)\n : activityPrimaryText(entry)\n}\n\n/** Whether a stored action is a dotted code rather than a sentence. */\nexport function isActivityCode(action: unknown): action is string {\n return typeof action === 'string' && /^[a-z][\\w-]*(\\.[\\w-]+)+$/i.test(action.trim())\n}\n\n/*==========================================\n * THE STAFF AUDIT TRAIL'S WORDS.\n *\n * Every code core's doors write. A plugin's doors declare their own through\n * `staffAuditLabels` (the AI plugin's `ai.job.*`), and a code neither knows\n * is humanized from its segments rather than shown raw, so a new writer\n * reads as `Billing: invoice paid` until somebody names it properly.\n *==========================================*/\nexport const STAFF_AUDIT_ACTION_LABELS: Readonly<Record<string, string>> = {\n 'account.closed.self': 'Closed their own account',\n 'account.exported.self': 'Exported their own account data',\n 'ai-usage.exported': 'Exported AI usage',\n 'billing.assistOverage.setCap': 'Set the AI overage ceiling',\n 'billing.assistOverage.setHardCap': 'Set the AI stop-at-band switch',\n 'billing.autoLocked': 'Locked automatically for billing',\n 'billing.bundle-link-minted': 'Made a bundle checkout link',\n 'billing.collaboratorAllocation': 'Changed collaborator seats',\n 'billing.dispute.opened': 'Payment dispute opened',\n 'billing.disputeClosed': 'Payment dispute closed',\n 'billing.disputeOpened': 'Payment dispute opened',\n 'billing.disputeUnattributed': 'Unattributed payment dispute',\n 'billing.invoice': 'Invoice event',\n 'billing.invoice.closed': 'Invoice closed',\n 'billing.invoice.failed': 'Invoice payment failed',\n 'billing.invoice.paid': 'Invoice paid',\n 'billing.manage': 'Opened billing management',\n 'billing.orphanedSubscription': 'Found a subscription with no workspace',\n 'billing.paymentFailed': 'Payment failed',\n 'billing.paymentMethod.changed': 'Changed the payment method',\n 'billing.platformDisputeLost': 'Lost a payment dispute',\n 'billing.platformInvoiceUncollectible': 'Invoice marked uncollectible',\n 'billing.registerAllocation': 'Changed register allocation',\n 'billing.storageOverage.setCap': 'Set the storage overage ceiling',\n 'billing.subscriptionCanceled': 'Subscription canceled',\n 'billing.usage': 'Recorded usage',\n 'billing.usageBudget.set': 'Set the usage budget',\n 'billing.view': 'Viewed billing',\n 'billing.webhookInert': 'Ignored a billing webhook',\n 'billing.webhookSignatureRejected': 'Rejected a billing webhook signature',\n 'broadcast.send': 'Sent a broadcast',\n 'client-build.preview-sent': 'Sent a client build preview',\n 'contact.phone.erased': 'Erased a phone number',\n 'contact.suppression.recorded': 'Added a contact suppression',\n 'contact.suppression.released': 'Released a contact suppression',\n 'coupon.create': 'Created a coupon',\n 'coupon.promotion_code.update': 'Updated a promotion code',\n 'data.transfer.export': 'Exported data',\n 'data.transfer.plan': 'Planned a data transfer',\n 'email.history-imported': 'Imported email history',\n 'email.message-viewed': 'Viewed an email message',\n 'email.sending-domains.reap': 'Removed unused sending domains',\n 'email.suppression.release': 'Released an email suppression',\n 'emailSendRate.update': 'Changed the email send rate',\n 'erasure.runBatch': 'Ran an erasure batch',\n 'erasures.replayed': 'Replayed erasures',\n 'firestore.export': 'Exported the database',\n 'firstPartyHosts.update': 'Changed first-party sites',\n 'flags.update': 'Changed feature flags',\n 'freeWorkspaceCap.update': 'Changed the free workspace cap',\n 'host.deleted': 'Deleted a site',\n 'host.domain.released': 'Released a domain',\n 'host.reattach-domain': 'Reattached a domain',\n 'host.set-subdomain': 'Changed a site address',\n 'host.transfer': 'Transferred a site',\n 'lockdown.lock': 'Locked the workspace down',\n 'lockdown.payouts-pause': 'Paused payouts',\n 'lockdown.payouts-restore': 'Restored payouts',\n 'lockdown.renewals-pause': 'Paused renewals',\n 'lockdown.renewals-resume': 'Resumed renewals',\n 'lockdown.resend-notice': 'Resent the lockdown notice',\n 'maintenance.auditArchive.run': 'Archived the audit log',\n 'maintenance.reapArtifacts.run': 'Removed stale build artifacts',\n 'maintenance.reverifyPlugins.run': 'Re-verified plugins',\n 'operatorAlerts.test': 'Sent a test operator alert',\n 'operatorAlerts.update': 'Changed operator alerts',\n 'org.acquisition-viewed': 'Viewed where the organization came from',\n 'org.auditLog': 'Viewed the organization audit log',\n 'org.discount.apply': 'Applied a discount',\n 'org.discount.remove': 'Removed a discount',\n 'org.enterprise.provision': 'Provisioned enterprise billing',\n 'org.erase-failed': 'Organization erasure failed',\n 'org.erased': 'Erased the organization',\n 'org.erasureCanceled': 'Canceled the organization erasure',\n 'org.erasureRequested': 'Requested organization erasure',\n 'org.exported': 'Exported the organization',\n 'org.name': 'Renamed the organization',\n 'org.note': 'Added a staff note',\n 'org.override': 'Overrode the plan',\n 'org.refund': 'Issued a refund',\n 'org.seatAddons.changed': 'Changed seat add-ons',\n 'org.sso.enforceSignInMethods': 'Changed enforced sign-in methods',\n 'org.sso.jit': 'Changed single sign-on provisioning',\n 'org.subscription-cancel': 'Canceled the subscription',\n 'org.subscriptionStarted.settle': 'Settled a new subscription',\n 'org.successManagerCleared': 'Removed the success manager',\n 'org.successManagerSet': 'Assigned a success manager',\n 'org.upgradeProposal.propose': 'Proposed an upgrade',\n 'org.upgradeProposal.withdraw': 'Withdrew an upgrade proposal',\n 'orgs.unverified.reap': 'Removed unverified organizations',\n 'person.erased': 'Erased a person',\n 'person.erasure-requested': 'Requested erasure of a person',\n 'plan.name': 'Renamed a plan',\n 'plugins.artifacts.reap': 'Removed stale plugin builds',\n 'plugins.remoteServer.load': 'Loaded a remote plugin server',\n 'plugins.verification.decline': 'Declined a plugin verification',\n 'plugins.verifier.regression': 'Plugin verifier regression',\n 'security.pageSecurityHold': 'Put a page on security hold',\n 'security.paymentFraudHold': 'Put a workspace on hold for payment fraud',\n 'security.staffGranted': 'Granted staff access',\n 'site.package.apply': 'Applied a site package',\n 'site.package.undo': 'Undid a site package',\n 'sso.domain.driftDetected': 'Single sign-on domain drift detected',\n 'staff.evidence': 'Recorded evidence',\n 'staff.paymentFailed': 'Payment failed (staff notice)',\n 'staff.planChanged': 'Plan changed (staff notice)',\n 'staff.subscriptionCanceled': 'Subscription canceled (staff notice)',\n 'staff.subscriptionStarted': 'Subscription started (staff notice)',\n 'systemEmail.staffSend': 'Sent a system email',\n 'systemEmail.test': 'Sent a test system email',\n 'taxFilingConfig.clear': 'Cleared the tax filing settings',\n 'taxFilingConfig.update': 'Changed the tax filing settings',\n 'taxablePurchases.clear': 'Cleared taxable purchases',\n 'taxablePurchases.update': 'Changed taxable purchases',\n 'user.acquisition-viewed': 'Viewed where the account came from',\n 'user.erased': 'Erased the account',\n 'user.impersonate': 'Signed in as the account',\n 'user.nativeAppCheck': 'Verified the desktop app for the account',\n 'user.nativeAppSignIn': 'Signed in to the app through the console',\n 'user.sendPasswordReset': 'Sent a password reset',\n 'user.setAdAudienceOptOut': 'Changed the ad audience opt-out',\n 'user.setPassword': 'Set the password',\n 'user.signOutDevice': 'Signed a device out',\n 'user.updateProfile': 'Updated the profile',\n}\n\n/** Leading namespaces as a reader names them. */\nconst NAMESPACE_LABELS: Readonly<Record<string, string>> = {\n org: 'Organization',\n orgs: 'Organizations',\n user: 'Account',\n host: 'Site',\n}\n\n/** `paymentMethod` → `payment method`, `reattach-domain` → `reattach domain`. */\nfunction words(segment: string): string {\n return segment\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/[-_]+/g, ' ')\n .toLowerCase()\n .trim()\n}\n\n/** A code nobody named, as words: `billing.invoice.paid` → `Billing: invoice paid`. */\nexport function humanizeActivityCode(code: string): string {\n const [head = '', ...rest] = code.trim().split('.').filter(Boolean)\n const lead = NAMESPACE_LABELS[head] ?? words(head).replace(/^./, (c) => c.toUpperCase())\n if (!rest.length) return lead\n return `${lead}: ${rest.map(words).join(' ')}`\n}\n\n/** What a staff audit code reads as, everywhere it is shown. */\nexport function staffAuditActionLabel(action: string | null | undefined): string {\n const code = action?.trim() ?? ''\n if (!code) return '—'\n return (\n STAFF_AUDIT_ACTION_LABELS[code] ??\n pluginStaffAuditActionLabel(code) ??\n (isActivityCode(code) ? humanizeActivityCode(code) : code)\n )\n}\n\n/** The collections an audit path walks, named for a reader. */\nconst COLLECTION_NOUNS: Readonly<Record<string, string>> = {\n orgs: 'Organization',\n hosts: 'Site',\n users: 'Account',\n members: 'Member',\n invites: 'Invitation',\n screens: 'Page',\n layouts: 'Layout',\n components: 'Component',\n templates: 'Template',\n media: 'Media',\n emailDeliveries: 'Email',\n coupons: 'Coupon',\n flags: 'Feature flag',\n plugins: 'Plugin',\n subscriptions: 'Subscription',\n}\n\n/** `orgs/a/aiJobs/b` → `{ orgs: 'a', aiJobs: 'b' }`, in walk order. */\nfunction pathPairs(path: string): Array<[string, string]> {\n const segments = path.split('/').filter(Boolean)\n const pairs: Array<[string, string]> = []\n for (let at = 0; at < segments.length; at += 2) {\n pairs.push([segments[at] ?? '', segments[at + 1] ?? ''])\n }\n return pairs\n}\n\n/** The stored audit row, read defensively. */\nexport interface StaffAuditEntryLike {\n action?: string | null\n target?: string | null\n subjectUid?: string | null\n reason?: string | null\n note?: string | null\n /** The state the act left; AI rows carry `{ label, hostId, credits }`. */\n after?: Record<string, unknown> | null\n}\n\nconst str = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() ? value.trim() : null\nconst num = (value: unknown): number | null =>\n typeof value === 'number' && Number.isFinite(value) ? value : null\n\n/** What an audit act did, in words, and the words it was about. */\nexport function describeStaffAudit(\n entry: StaffAuditEntryLike,\n names: ActivityNames = {},\n): ActivityDescription {\n const code = str(entry.action)\n const path = str(entry.target)\n const after = entry.after ?? {}\n const pairs = path && path.includes('/') ? pathPairs(path) : []\n const idOf = (collection: string) => pairs.find(([name]) => name === collection)?.[1] || null\n const orgId = idOf('orgs')\n // A plugin's job collection (the AI plugin's jobs) names the job the row\n // links to; core knows it only through the plugin's declaration.\n const jobPair = pairs.find(([name]) => pluginStaffAuditCollection(name)?.job)\n const jobId = jobPair?.[1] || null\n const hostId = str(after['hostId']) ?? idOf('hosts')\n const uid = idOf('users') ?? str(entry.subjectUid)\n const label = str(after['label'])\n // A plugin may word the row from what the act left: the AI plugin names\n // what a job made (`Created page Home with Aglyn AI`).\n const declared = code ? pluginStaffAuditDescribe(code, after) : undefined\n const action = declared?.action ?? staffAuditActionLabel(code)\n\n const site = hostId ? (names.hosts?.[hostId] ?? null) : null\n const org = orgId ? (names.orgs?.[orgId] ?? null) : null\n const person = uid ? (names.users?.[uid] ?? null) : null\n const last = pairs[pairs.length - 1]\n const parts: string[] = []\n if (site) parts.push(site)\n else if (org) parts.push(org)\n if (jobPair) parts.push(label ?? pluginStaffAuditCollection(jobPair[0])?.noun ?? 'Job')\n else if (last && last[0] === 'users') parts.push(person ?? 'Account')\n else if (last && last[0] !== 'orgs' && last[0] !== 'hosts') {\n parts.push(\n COLLECTION_NOUNS[last[0]] ??\n pluginStaffAuditCollection(last[0])?.noun ??\n activityTypeLabel(last[0]),\n )\n }\n if (!parts.length) {\n if (last) parts.push(COLLECTION_NOUNS[last[0]] ?? pluginStaffAuditCollection(last[0])?.noun ?? 'Item')\n else if (path) parts.push(isActivityCode(path) || /^[\\w-]{16,}$/.test(path) ? 'Platform' : path)\n else parts.push('—')\n }\n\n const result = str(after['result']) ?? str(after['status']) ?? declared?.result ?? null\n\n return {\n action,\n target: parts.join(' · '),\n why: orgOverrideReasonSummary(entry.reason ?? null, entry.note ?? null) ?? str(entry.note),\n credits: num(after['credits']),\n result,\n code,\n path,\n orgId,\n hostId,\n jobId,\n uid,\n }\n}\n\n/** A stored activity row, read defensively, with where it was read from. */\nexport interface ActivityRowLike {\n action?: string | null\n target?: (ActivityTargetLike & { jobId?: string; credits?: number }) | null\n /** `host` or `org`: which log the row came from. */\n scopeType?: string\n scopeId?: string\n}\n\n/**\n * An activity row as the lists show it. Where is the site when the row came\n * from a site's log, else the organization.\n */\nexport function describeActivity(\n entry: ActivityRowLike,\n names: ActivityNames = {},\n): ActivityDescription {\n const stored = str(entry.action)\n const code = isActivityCode(stored) ? stored : null\n const target = entry.target ?? null\n const hostId = entry.scopeType === 'host' ? (entry.scopeId ?? null) : null\n const orgId = entry.scopeType === 'org' ? (entry.scopeId ?? null) : null\n const site = hostId ? (names.hosts?.[hostId] ?? null) : null\n const type = str(target?.type)\n const jobId = isPluginJobTargetType(type) ? str(target?.id) : str(target?.jobId)\n const noun = type ? (pluginActivityTargetLabel(type) ?? activityTypeLabel(type)) : null\n const item = str(target?.name) ?? noun\n const parts = [site, item].filter((part): part is string => Boolean(part))\n return {\n action: activityActionSentence(stored ?? undefined, target) || '—',\n target: parts.join(' · ') || '—',\n why: null,\n credits: num(target?.credits),\n result: null,\n code,\n path: type ? `${type}${target?.id ? `/${target.id}` : ''}` : null,\n orgId,\n hostId,\n jobId,\n uid: type === 'member' ? str(target?.id) : null,\n }\n}\n"],"names":["activityActionLabel","activityPrimaryText","activityTypeLabel","orgOverrideReasonSummary","isPluginJobTargetType","pluginActivityActionSentence","pluginActivityTargetLabel","pluginStaffAuditActionLabel","pluginStaffAuditCollection","pluginStaffAuditDescribe","activityTargetPhrase","target","noun","type","lower","charAt","toLowerCase","slice","name","trim","activityActionSentence","action","stored","sentence","replace","activityRowText","entry","isActivityCode","test","STAFF_AUDIT_ACTION_LABELS","NAMESPACE_LABELS","org","orgs","user","host","words","segment","humanizeActivityCode","code","head","rest","split","filter","Boolean","lead","c","toUpperCase","length","map","join","staffAuditActionLabel","COLLECTION_NOUNS","hosts","users","members","invites","screens","layouts","components","templates","media","emailDeliveries","coupons","flags","plugins","subscriptions","pathPairs","path","segments","pairs","at","push","str","value","num","Number","isFinite","describeStaffAudit","names","idOf","label","after","includes","collection","find","orgId","jobPair","job","jobId","hostId","uid","subjectUid","declared","undefined","site","person","last","parts","result","why","reason","note","credits","describeActivity","scopeType","scopeId","id","item","part"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;CAiBC,GAED,SACEA,mBAAmB,EACnBC,mBAAmB,EACnBC,iBAAiB,QAGZ,0BAAsB;AAC7B,SAASC,wBAAwB,QAAQ,2BAAuB;AAChE,SACEC,qBAAqB,EACrBC,4BAA4B,EAC5BC,yBAAyB,EACzBC,2BAA2B,EAC3BC,0BAA0B,EAC1BC,wBAAwB,QACnB,+C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E,WAAWlF,WAAW;QAC/DA,QAAQsF,MAAMhD,IAAI,CAAC,UAAU;QAC7BkD,KAAK;QACLG,SAAS5B,IAAI/D,0BAAAA,OAAQ2F,OAAO;QAC5BJ,QAAQ;QACR5D;QACA6B,MAAMtD,OAAO,GAAGA,OAAOF,CAAAA,0BAAAA,OAAQ+F,EAAE,IAAG,CAAC,CAAC,EAAE/F,OAAO+F,EAAE,EAAE,GAAG,IAAI,GAAG;QAC7DrB;QACAI;QACAD;QACAE,KAAK7E,SAAS,WAAW2D,IAAI7D,0BAAAA,OAAQ+F,EAAE,IAAI;IAC7C;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/activity-labels.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * ONE LABEL MAP FOR EVERY ACTIVITY AND AUDIT LIST (AGL-3660).\n *\n * Two logs feed the console's lists. The activity logs\n * (`orgs/{id}/activity`, `hosts/{id}/activity`) store a prose sentence or a\n * plugin's code plus a `{ type, id, name }` target. The staff audit trail\n * (`adminAudit`) stores a dotted code (`ai.job.output`, `org.override`) and\n * a Firestore PATH as its target (`orgs/abc/aiJobs/xyz`). The staff tables\n * printed both raw, so a reader saw `ai.job.output` next to\n * `orgs/9fK…/aiJobs/Qe2…` and had to know the schema to read their own\n * audit trail.\n *\n * Every list now draws its words from here: an action as a sentence\n * (`Created page Home with Aglyn AI`), a target as the site and the item,\n * and — for an audit row — why, the credits it spent and what came of it.\n * The raw code and path are kept on the description, for a tooltip and for\n * the staff details dialog, and never as the visible text.\n */\n\nimport {\n activityActionLabel,\n activityPrimaryText,\n activityTypeLabel,\n type ActivityEntryLike,\n type ActivityTargetLike,\n} from './activity-presenter'\nimport { orgOverrideReasonSummary } from './org-override-reason'\nimport {\n isPluginJobTargetType,\n pluginActivityActionSentence,\n pluginActivityTargetLabel,\n pluginStaffAuditActionLabel,\n pluginStaffAuditCollection,\n pluginStaffAuditDescribe,\n} from '../plugin-manager/plugin-activity-actions'\n\n/** What a list row and the details dialog show for one entry. */\nexport interface ActivityDescription {\n /** The act, as a sentence. Never a code. */\n action: string\n /** What it was done to, in words: the site and the item. Never a path. */\n target: string\n /** Why it was done, when the writer recorded a reason. */\n why: string | null\n /** AI credits it spent, when it spent any. */\n credits: number | null\n /** What came of it, when the writer recorded an outcome. */\n result: string | null\n /** The stored code, when the action was one — for a tooltip and staff. */\n code: string | null\n /** The stored target path (audit) or `type/id` (activity) — staff only. */\n path: string | null\n /** The organization the entry concerns, when it names one. */\n orgId: string | null\n /** The site the entry concerns, when it names one. */\n hostId: string | null\n /** The plugin job behind the entry (an AI job), when there is one. */\n jobId: string | null\n /** The account the entry concerns, when it names one. */\n uid: string | null\n}\n\n/** Names a route resolved for the ids an entry carries. */\nexport interface ActivityNames {\n /** Organization name by org id. */\n orgs?: Readonly<Record<string, string | null | undefined>>\n /** Site name by host id. */\n hosts?: Readonly<Record<string, string | null | undefined>>\n /** An account's address (or name) by uid. */\n users?: Readonly<Record<string, string | null | undefined>>\n}\n\n/** `screen` → `page`, `Home` → `page Home`: the noun a sentence uses. */\nexport function activityTargetPhrase(target: ActivityTargetLike | null | undefined): string {\n const noun = activityTypeLabel(target?.type)\n const lower = noun === 'Item' ? 'item' : noun.charAt(0).toLowerCase() + noun.slice(1)\n const name = target?.name?.trim()\n return name ? `${lower} ${name}` : lower\n}\n\n/**\n * An activity row's action as a sentence about its target. A plugin code\n * with a declared sentence fills it (`Created {target} with Aglyn AI`); any\n * other code reads as its label, and a prose action as itself.\n */\nexport function activityActionSentence(\n action: string | undefined,\n target?: ActivityTargetLike | null,\n): string {\n const stored = action?.trim() ?? ''\n const sentence = pluginActivityActionSentence(stored)\n if (sentence) return sentence.replace('{target}', activityTargetPhrase(target))\n return activityActionLabel(stored)\n}\n\n/**\n * A one-column feed's line: the sentence when the code declares one, else\n * the action with its target's name (`Saved the screen — Home`).\n */\nexport function activityRowText(entry: ActivityEntryLike): string {\n const stored = entry.action?.trim() ?? ''\n return pluginActivityActionSentence(stored)\n ? activityActionSentence(stored, entry.target)\n : activityPrimaryText(entry)\n}\n\n/** Whether a stored action is a dotted code rather than a sentence. */\nexport function isActivityCode(action: unknown): action is string {\n return typeof action === 'string' && /^[a-z][\\w-]*(\\.[\\w-]+)+$/i.test(action.trim())\n}\n\n/*==========================================\n * THE STAFF AUDIT TRAIL'S WORDS.\n *\n * Every code core's doors write. A plugin's doors declare their own through\n * `staffAuditLabels` (the AI plugin's `ai.job.*`), and a code neither knows\n * is humanized from its segments rather than shown raw, so a new writer\n * reads as `Billing: invoice paid` until somebody names it properly.\n *==========================================*/\nexport const STAFF_AUDIT_ACTION_LABELS: Readonly<Record<string, string>> = {\n 'account.closed.self': 'Closed their own account',\n 'account.exported.self': 'Exported their own account data',\n 'ai-usage.exported': 'Exported AI usage',\n 'billing.assistOverage.setCap': 'Set the AI overage ceiling',\n 'billing.assistOverage.setHardCap': 'Set the AI stop-at-band switch',\n 'billing.autoLocked': 'Locked automatically for billing',\n 'billing.bundle-link-minted': 'Made a bundle checkout link',\n 'billing.collaboratorAllocation': 'Changed collaborator seats',\n 'billing.dispute.opened': 'Payment dispute opened',\n 'billing.disputeClosed': 'Payment dispute closed',\n 'billing.disputeOpened': 'Payment dispute opened',\n 'billing.disputeUnattributed': 'Unattributed payment dispute',\n 'billing.invoice': 'Invoice event',\n 'billing.invoice.closed': 'Invoice closed',\n 'billing.invoice.failed': 'Invoice payment failed',\n 'billing.invoice.paid': 'Invoice paid',\n 'billing.manage': 'Opened billing management',\n 'billing.orphanedSubscription': 'Found a subscription with no workspace',\n 'billing.paymentFailed': 'Payment failed',\n 'billing.paymentMethod.changed': 'Changed the payment method',\n 'billing.platformDisputeLost': 'Lost a payment dispute',\n 'billing.platformInvoiceUncollectible': 'Invoice marked uncollectible',\n 'billing.registerAllocation': 'Changed register allocation',\n 'billing.storageOverage.setCap': 'Set the storage overage ceiling',\n 'billing.subscriptionCanceled': 'Subscription canceled',\n 'billing.usage': 'Recorded usage',\n 'billing.usageBudget.set': 'Set the usage budget',\n 'billing.view': 'Viewed billing',\n 'billing.webhookInert': 'Ignored a billing webhook',\n 'billing.webhookSignatureRejected': 'Rejected a billing webhook signature',\n 'broadcast.send': 'Sent a broadcast',\n 'client-build.preview-sent': 'Sent a client build preview',\n 'contact.phone.erased': 'Erased a phone number',\n 'contact.suppression.recorded': 'Added a contact suppression',\n 'contact.suppression.released': 'Released a contact suppression',\n 'coupon.create': 'Created a coupon',\n 'coupon.promotion_code.update': 'Updated a promotion code',\n 'data.transfer.export': 'Exported data',\n 'data.transfer.plan': 'Planned a data transfer',\n 'email.history-imported': 'Imported email history',\n 'email.message-viewed': 'Viewed an email message',\n 'email.sending-domains.reap': 'Removed unused sending domains',\n 'email.suppression.release': 'Released an email suppression',\n 'emailSendRate.update': 'Changed the email send rate',\n 'erasure.runBatch': 'Ran an erasure batch',\n 'erasures.replayed': 'Replayed erasures',\n 'firestore.export': 'Exported the database',\n 'firstPartyHosts.update': 'Changed first-party sites',\n 'flags.update': 'Changed feature flags',\n 'freeWorkspaceCap.update': 'Changed the free workspace cap',\n 'host.deleted': 'Deleted a site',\n 'host.domain.released': 'Released a domain',\n 'host.reattach-domain': 'Reattached a domain',\n 'host.set-subdomain': 'Changed a site address',\n 'host.transfer': 'Transferred a site',\n 'host.usageLevel': 'Set the site usage level',\n 'lockdown.lock': 'Locked the workspace down',\n 'lockdown.payouts-pause': 'Paused payouts',\n 'lockdown.payouts-restore': 'Restored payouts',\n 'lockdown.renewals-pause': 'Paused renewals',\n 'lockdown.renewals-resume': 'Resumed renewals',\n 'lockdown.resend-notice': 'Resent the lockdown notice',\n 'maintenance.auditArchive.run': 'Archived the audit log',\n 'maintenance.reapArtifacts.run': 'Removed stale build artifacts',\n 'maintenance.reverifyPlugins.run': 'Re-verified plugins',\n 'operatorAlerts.test': 'Sent a test operator alert',\n 'operatorAlerts.update': 'Changed operator alerts',\n 'org.acquisition-viewed': 'Viewed where the organization came from',\n 'org.auditLog': 'Viewed the organization audit log',\n 'org.discount.apply': 'Applied a discount',\n 'org.discount.remove': 'Removed a discount',\n 'org.enterprise.provision': 'Provisioned enterprise billing',\n 'org.erase-failed': 'Organization erasure failed',\n 'org.erased': 'Erased the organization',\n 'org.erasureCanceled': 'Canceled the organization erasure',\n 'org.erasureRequested': 'Requested organization erasure',\n 'org.exported': 'Exported the organization',\n 'org.name': 'Renamed the organization',\n 'org.note': 'Added a staff note',\n 'org.override': 'Overrode the plan',\n 'org.refund': 'Issued a refund',\n 'org.seatAddons.changed': 'Changed seat add-ons',\n 'org.sso.enforceSignInMethods': 'Changed enforced sign-in methods',\n 'org.sso.jit': 'Changed single sign-on provisioning',\n 'org.subscription-cancel': 'Canceled the subscription',\n 'org.subscriptionStarted.settle': 'Settled a new subscription',\n 'org.successManagerCleared': 'Removed the success manager',\n 'org.successManagerSet': 'Assigned a success manager',\n 'org.upgradeProposal.propose': 'Proposed an upgrade',\n 'org.upgradeProposal.withdraw': 'Withdrew an upgrade proposal',\n 'org.usageLevel': 'Set the workspace usage level',\n 'orgs.unverified.reap': 'Removed unverified organizations',\n 'person.erased': 'Erased a person',\n 'person.erasure-requested': 'Requested erasure of a person',\n 'plan.name': 'Renamed a plan',\n 'plugins.artifacts.reap': 'Removed stale plugin builds',\n 'plugins.remoteServer.load': 'Loaded a remote plugin server',\n 'plugins.verification.decline': 'Declined a plugin verification',\n 'plugins.verifier.regression': 'Plugin verifier regression',\n 'security.pageSecurityHold': 'Put a page on security hold',\n 'security.paymentFraudHold': 'Put a workspace on hold for payment fraud',\n 'security.staffGranted': 'Granted staff access',\n 'site.package.apply': 'Applied a site package',\n 'site.package.undo': 'Undid a site package',\n 'sso.domain.driftDetected': 'Single sign-on domain drift detected',\n 'staff.evidence': 'Recorded evidence',\n 'staff.paymentFailed': 'Payment failed (staff notice)',\n 'staff.planChanged': 'Plan changed (staff notice)',\n 'staff.subscriptionCanceled': 'Subscription canceled (staff notice)',\n 'staff.subscriptionStarted': 'Subscription started (staff notice)',\n 'systemEmail.staffSend': 'Sent a system email',\n 'systemEmail.test': 'Sent a test system email',\n 'taxFilingConfig.clear': 'Cleared the tax filing settings',\n 'taxFilingConfig.update': 'Changed the tax filing settings',\n 'taxablePurchases.clear': 'Cleared taxable purchases',\n 'taxablePurchases.update': 'Changed taxable purchases',\n 'user.acquisition-viewed': 'Viewed where the account came from',\n 'user.erased': 'Erased the account',\n 'user.impersonate': 'Signed in as the account',\n 'user.nativeAppCheck': 'Verified the desktop app for the account',\n 'user.nativeAppSignIn': 'Signed in to the app through the console',\n 'user.sendPasswordReset': 'Sent a password reset',\n 'user.setAdAudienceOptOut': 'Changed the ad audience opt-out',\n 'user.setPassword': 'Set the password',\n 'user.signOutDevice': 'Signed a device out',\n 'user.updateProfile': 'Updated the profile',\n 'user.usageLevel': 'Set the account usage level',\n}\n\n/** Leading namespaces as a reader names them. */\nconst NAMESPACE_LABELS: Readonly<Record<string, string>> = {\n org: 'Organization',\n orgs: 'Organizations',\n user: 'Account',\n host: 'Site',\n}\n\n/** `paymentMethod` → `payment method`, `reattach-domain` → `reattach domain`. */\nfunction words(segment: string): string {\n return segment\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/[-_]+/g, ' ')\n .toLowerCase()\n .trim()\n}\n\n/** A code nobody named, as words: `billing.invoice.paid` → `Billing: invoice paid`. */\nexport function humanizeActivityCode(code: string): string {\n const [head = '', ...rest] = code.trim().split('.').filter(Boolean)\n const lead = NAMESPACE_LABELS[head] ?? words(head).replace(/^./, (c) => c.toUpperCase())\n if (!rest.length) return lead\n return `${lead}: ${rest.map(words).join(' ')}`\n}\n\n/** What a staff audit code reads as, everywhere it is shown. */\nexport function staffAuditActionLabel(action: string | null | undefined): string {\n const code = action?.trim() ?? ''\n if (!code) return '—'\n return (\n STAFF_AUDIT_ACTION_LABELS[code] ??\n pluginStaffAuditActionLabel(code) ??\n (isActivityCode(code) ? humanizeActivityCode(code) : code)\n )\n}\n\n/** The collections an audit path walks, named for a reader. */\nconst COLLECTION_NOUNS: Readonly<Record<string, string>> = {\n orgs: 'Organization',\n hosts: 'Site',\n users: 'Account',\n members: 'Member',\n invites: 'Invitation',\n screens: 'Page',\n layouts: 'Layout',\n components: 'Component',\n templates: 'Template',\n media: 'Media',\n emailDeliveries: 'Email',\n coupons: 'Coupon',\n flags: 'Feature flag',\n plugins: 'Plugin',\n subscriptions: 'Subscription',\n}\n\n/** `orgs/a/aiJobs/b` → `{ orgs: 'a', aiJobs: 'b' }`, in walk order. */\nfunction pathPairs(path: string): Array<[string, string]> {\n const segments = path.split('/').filter(Boolean)\n const pairs: Array<[string, string]> = []\n for (let at = 0; at < segments.length; at += 2) {\n pairs.push([segments[at] ?? '', segments[at + 1] ?? ''])\n }\n return pairs\n}\n\n/** The stored audit row, read defensively. */\nexport interface StaffAuditEntryLike {\n action?: string | null\n target?: string | null\n subjectUid?: string | null\n reason?: string | null\n note?: string | null\n /** The state the act left; AI rows carry `{ label, hostId, credits }`. */\n after?: Record<string, unknown> | null\n}\n\nconst str = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() ? value.trim() : null\nconst num = (value: unknown): number | null =>\n typeof value === 'number' && Number.isFinite(value) ? value : null\n\n/** What an audit act did, in words, and the words it was about. */\nexport function describeStaffAudit(\n entry: StaffAuditEntryLike,\n names: ActivityNames = {},\n): ActivityDescription {\n const code = str(entry.action)\n const path = str(entry.target)\n const after = entry.after ?? {}\n const pairs = path && path.includes('/') ? pathPairs(path) : []\n const idOf = (collection: string) => pairs.find(([name]) => name === collection)?.[1] || null\n const orgId = idOf('orgs')\n // A plugin's job collection (the AI plugin's jobs) names the job the row\n // links to; core knows it only through the plugin's declaration.\n const jobPair = pairs.find(([name]) => pluginStaffAuditCollection(name)?.job)\n const jobId = jobPair?.[1] || null\n const hostId = str(after['hostId']) ?? idOf('hosts')\n const uid = idOf('users') ?? str(entry.subjectUid)\n const label = str(after['label'])\n // A plugin may word the row from what the act left: the AI plugin names\n // what a job made (`Created page Home with Aglyn AI`).\n const declared = code ? pluginStaffAuditDescribe(code, after) : undefined\n const action = declared?.action ?? staffAuditActionLabel(code)\n\n const site = hostId ? (names.hosts?.[hostId] ?? null) : null\n const org = orgId ? (names.orgs?.[orgId] ?? null) : null\n const person = uid ? (names.users?.[uid] ?? null) : null\n const last = pairs[pairs.length - 1]\n const parts: string[] = []\n if (site) parts.push(site)\n else if (org) parts.push(org)\n if (jobPair) parts.push(label ?? pluginStaffAuditCollection(jobPair[0])?.noun ?? 'Job')\n else if (last && last[0] === 'users') parts.push(person ?? 'Account')\n else if (last && last[0] !== 'orgs' && last[0] !== 'hosts') {\n parts.push(\n COLLECTION_NOUNS[last[0]] ??\n pluginStaffAuditCollection(last[0])?.noun ??\n activityTypeLabel(last[0]),\n )\n }\n if (!parts.length) {\n if (last) parts.push(COLLECTION_NOUNS[last[0]] ?? pluginStaffAuditCollection(last[0])?.noun ?? 'Item')\n else if (path) parts.push(isActivityCode(path) || /^[\\w-]{16,}$/.test(path) ? 'Platform' : path)\n else parts.push('—')\n }\n\n const result = str(after['result']) ?? str(after['status']) ?? declared?.result ?? null\n\n return {\n action,\n target: parts.join(' · '),\n why: orgOverrideReasonSummary(entry.reason ?? null, entry.note ?? null) ?? str(entry.note),\n credits: num(after['credits']),\n result,\n code,\n path,\n orgId,\n hostId,\n jobId,\n uid,\n }\n}\n\n/** A stored activity row, read defensively, with where it was read from. */\nexport interface ActivityRowLike {\n action?: string | null\n target?: (ActivityTargetLike & { jobId?: string; credits?: number }) | null\n /** `host` or `org`: which log the row came from. */\n scopeType?: string\n scopeId?: string\n}\n\n/**\n * An activity row as the lists show it. Where is the site when the row came\n * from a site's log, else the organization.\n */\nexport function describeActivity(\n entry: ActivityRowLike,\n names: ActivityNames = {},\n): ActivityDescription {\n const stored = str(entry.action)\n const code = isActivityCode(stored) ? stored : null\n const target = entry.target ?? null\n const hostId = entry.scopeType === 'host' ? (entry.scopeId ?? null) : null\n const orgId = entry.scopeType === 'org' ? (entry.scopeId ?? null) : null\n const site = hostId ? (names.hosts?.[hostId] ?? null) : null\n const type = str(target?.type)\n const jobId = isPluginJobTargetType(type) ? str(target?.id) : str(target?.jobId)\n const noun = type ? (pluginActivityTargetLabel(type) ?? activityTypeLabel(type)) : null\n const item = str(target?.name) ?? noun\n const parts = [site, item].filter((part): part is string => Boolean(part))\n return {\n action: activityActionSentence(stored ?? undefined, target) || '—',\n target: parts.join(' · ') || '—',\n why: null,\n credits: num(target?.credits),\n result: null,\n code,\n path: type ? `${type}${target?.id ? `/${target.id}` : ''}` : null,\n orgId,\n hostId,\n jobId,\n uid: type === 'member' ? str(target?.id) : null,\n }\n}\n"],"names":["activityActionLabel","activityPrimaryText","activityTypeLabel","orgOverrideReasonSummary","isPluginJobTargetType","pluginActivityActionSentence","pluginActivityTargetLabel","pluginStaffAuditActionLabel","pluginStaffAuditCollection","pluginStaffAuditDescribe","activityTargetPhrase","target","noun","type","lower","charAt","toLowerCase","slice","name","trim","activityActionSentence","action","stored","sentence","replace","activityRowText","entry","isActivityCode","test","STAFF_AUDIT_ACTION_LABELS","NAMESPACE_LABELS","org","orgs","user","host","words","segment","humanizeActivityCode","code","head","rest","split","filter","Boolean","lead","c","toUpperCase","length","map","join","staffAuditActionLabel","COLLECTION_NOUNS","hosts","users","members","invites","screens","layouts","components","templates","media","emailDeliveries","coupons","flags","plugins","subscriptions","pathPairs","path","segments","pairs","at","push","str","value","num","Number","isFinite","describeStaffAudit","names","idOf","label","after","includes","collection","find","orgId","jobPair","job","jobId","hostId","uid","subjectUid","declared","undefined","site","person","last","parts","result","why","reason","note","credits","describeActivity","scopeType","scopeId","id","item","part"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;CAiBC,GAED,SACEA,mBAAmB,EACnBC,mBAAmB,EACnBC,iBAAiB,QAGZ,0BAAsB;AAC7B,SAASC,wBAAwB,QAAQ,2BAAuB;AAChE,SACEC,qBAAqB,EACrBC,4BAA4B,EAC5BC,yBAAyB,EACzBC,2BAA2B,EAC3BC,0BAA0B,EAC1BC,wBAAwB,QACnB,+CAA2C;AAsClD,uEAAuE,GACvE,OAAO,SAASC,qBAAqBC,MAA6C;QAGnEA;IAFb,MAAMC,OAAOV,kBAAkBS,0BAAAA,OAAQE,IAAI;IAC3C,MAAMC,QAAQF,SAAS,SAAS,SAASA,KAAKG,MAAM,CAAC,GAAGC,WAAW,KAAKJ,KAAKK,KAAK,CAAC;IACnF,MAAMC,OAAOP,2BAAAA,eAAAA,OAAQO,IAAI,qBAAZP,aAAcQ,IAAI;IAC/B,OAAOD,OAAO,GAAGJ,MAAM,CAAC,EAAEI,MAAM,GAAGJ;AACrC;AAEA;;;;CAIC,GACD,OAAO,SAASM,uBACdC,MAA0B,EAC1BV,MAAkC;;IAElC,MAAMW,iBAASD,0BAAAA,OAAQF,IAAI,qBAAM;IACjC,MAAMI,WAAWlB,6BAA6BiB;IAC9C,IAAIC,UAAU,OAAOA,SAASC,OAAO,CAAC,YAAYd,qBAAqBC;IACvE,OAAOX,oBAAoBsB;AAC7B;AAEA;;;CAGC,GACD,OAAO,SAASG,gBAAgBC,KAAwB;;QACvCA;IAAf,MAAMJ,kBAASI,gBAAAA,MAAML,MAAM,qBAAZK,cAAcP,IAAI,qBAAM;IACvC,OAAOd,6BAA6BiB,UAChCF,uBAAuBE,QAAQI,MAAMf,MAAM,IAC3CV,oBAAoByB;AAC1B;AAEA,qEAAqE,GACrE,OAAO,SAASC,eAAeN,MAAe;IAC5C,OAAO,OAAOA,WAAW,YAAY,4BAA4BO,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2D,IAAI7D,0BAAAA,OAAQ+F,EAAE,IAAIlC,IAAI7D,0BAAAA,OAAQ6E,KAAK;IAC/E,MAAM5E,OAAOC,QAAQP,6BAAAA,0BAA0BO,iBAA1BP,6BAAmCJ,kBAAkBW,QAAS;IACnF,MAAM8F,QAAOnC,OAAAA,IAAI7D,0BAAAA,OAAQO,IAAI,aAAhBsD,OAAqB5D;IAClC,MAAMqF,QAAQ;QAACH;QAAMa;KAAK,CAACjE,MAAM,CAAC,CAACkE,OAAyBjE,QAAQiE;IACpE,OAAO;QACLvF,QAAQD,uBAAuBE,iBAAAA,SAAUuE,WAAWlF,WAAW;QAC/DA,QAAQsF,MAAMhD,IAAI,CAAC,UAAU;QAC7BkD,KAAK;QACLG,SAAS5B,IAAI/D,0BAAAA,OAAQ2F,OAAO;QAC5BJ,QAAQ;QACR5D;QACA6B,MAAMtD,OAAO,GAAGA,OAAOF,CAAAA,0BAAAA,OAAQ+F,EAAE,IAAG,CAAC,CAAC,EAAE/F,OAAO+F,EAAE,EAAE,GAAG,IAAI,GAAG;QAC7DrB;QACAI;QACAD;QACAE,KAAK7E,SAAS,WAAW2D,IAAI7D,0BAAAA,OAAQ+F,EAAE,IAAI;IAC7C;AACF"}
|
|
@@ -50,6 +50,11 @@ export declare const BUSINESS_SOCIAL_LINKS_MAX = 8;
|
|
|
50
50
|
* to leave its copy too, or the fallback would bring it straight back.
|
|
51
51
|
*/
|
|
52
52
|
export declare const BUSINESS_DETAILS_CLEARABLE_PATHS: readonly ["seo.entity.name", "seo.entity.slogan", "seo.entity.telephone", "seo.entity.email", "seo.entity.address.streetAddress", "seo.entity.address.addressLocality", "seo.entity.address.addressRegion", "seo.entity.address.postalCode", "seo.entity.address.addressCountry", "business.supportEmail", "business.address"];
|
|
53
|
+
/**
|
|
54
|
+
* {@link BUSINESS_DETAILS_CLEARABLE_PATHS} as a plain list: the native apps' Business details
|
|
55
|
+
* cards read it from the contracts, and so clear what the console clears.
|
|
56
|
+
*/
|
|
57
|
+
export declare const BUSINESS_DETAILS_CLEARABLE_PATH_LIST: readonly string[];
|
|
53
58
|
/** The host fields the business details read and write. */
|
|
54
59
|
export interface BusinessDetailsHost {
|
|
55
60
|
displayName?: string;
|
|
@@ -59,6 +59,10 @@ import { siteContactEmail } from "./host-tokens.js";
|
|
|
59
59
|
'business.supportEmail',
|
|
60
60
|
'business.address'
|
|
61
61
|
];
|
|
62
|
+
/**
|
|
63
|
+
* {@link BUSINESS_DETAILS_CLEARABLE_PATHS} as a plain list: the native apps' Business details
|
|
64
|
+
* cards read it from the contracts, and so clear what the console clears.
|
|
65
|
+
*/ export const BUSINESS_DETAILS_CLEARABLE_PATH_LIST = BUSINESS_DETAILS_CLEARABLE_PATHS;
|
|
62
66
|
const trimmed = (value)=>typeof value === 'string' ? value.trim() : '';
|
|
63
67
|
/**
|
|
64
68
|
* The host document as the Business details card is seeded with it: the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/business-details.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { structuredAddressLine } from './business-profile'\nimport type { HostSeoEntity } from './content-authors'\nimport { siteContactEmail } from './host-tokens'\n\n/**\n * A site's BUSINESS DETAILS, entered in one place (AGL-4136).\n *\n * The business name, slogan, phone, email, postal address and social links\n * are entered on Setup → Business profile and nowhere else, and everything that uses\n * them reads that one place. The storage did not move, so no site's data had\n * to: each fact has one canonical path, and the older path that used to hold\n * it is kept as a read fallback.\n *\n * | fact | canonical | kept in step |\n * | ------------ | ----------------------------- | -------------------------- |\n * | name | `seo.entity.name` | falls back to `displayName` |\n * | slogan | `seo.entity.slogan` | |\n * | phone | `seo.entity.telephone` | |\n * | email | `seo.entity.email` | mirrored to `business.supportEmail` |\n * | address | `seo.entity.address.*` | mirrored, formatted, to `business.address` |\n * | social links | `business.socialLinks` | `seo.entity.sameAs` joins it when read |\n *\n * The two mirrors exist for the readers that have not moved yet: the native\n * apps read and write the `business` copies, so a save here keeps them\n * showing what the console shows until they follow.\n */\n\n/** The longest slogan a site may set, as the field and the structured data hold it. */\nexport const SITE_SLOGAN_MAX_LENGTH = 120\n\n/** The most social links a site keeps, as the editor allows them. */\nexport const BUSINESS_SOCIAL_LINKS_MAX = 8\n\n/**\n * The paths a Setup → Business profile save may take back to EMPTY.\n *\n * The form drops a cleared input from what it submits, and the write merges,\n * so without this a cleared phone would save nothing and report \"Saved!\".\n * Both mirrors are here as well: an email or address cleared on the card has\n * to leave its copy too, or the fallback would bring it straight back.\n */\nexport const BUSINESS_DETAILS_CLEARABLE_PATHS = [\n 'seo.entity.name',\n 'seo.entity.slogan',\n 'seo.entity.telephone',\n 'seo.entity.email',\n 'seo.entity.address.streetAddress',\n 'seo.entity.address.addressLocality',\n 'seo.entity.address.addressRegion',\n 'seo.entity.address.postalCode',\n 'seo.entity.address.addressCountry',\n 'business.supportEmail',\n 'business.address',\n] as const\n\n/** The host fields the business details read and write. */\nexport interface BusinessDetailsHost {\n displayName?: string\n seo?: {\n entity?: Pick<\n HostSeoEntity,\n 'name' | 'slogan' | 'telephone' | 'email' | 'address'\n > | null\n } | null\n business?: {\n supportEmail?: unknown\n address?: unknown\n socialLinks?: Array<{ label?: unknown; url?: unknown } | null> | null\n } | null\n}\n\nconst trimmed = (value: unknown): string =>\n typeof value === 'string' ? value.trim() : ''\n\n/**\n * The host document as the Business details card is seeded with it: the\n * site's one email in the Email field, so a site whose email so far lived\n * only in the one-block copy shows it, and clearing the field clears it.\n * Everything else is the document as stored. A new object; `host` is not\n * changed.\n */\nexport function businessDetailsSeed<T extends BusinessDetailsHost>(\n host: T | null | undefined,\n): T | null | undefined {\n if (!host) return host\n const email = siteContactEmail(host)\n if (!email || trimmed(host.seo?.entity?.email)) return host\n return {\n ...host,\n seo: { ...(host.seo ?? {}), entity: { ...(host.seo?.entity ?? {}), email } },\n }\n}\n\n/**\n * What a Setup → Business profile save writes, from what the card submitted and what\n * the document stores now (AGL-4136):\n *\n * - every text value trimmed;\n * - the email mirrored into `business.supportEmail`, `''` when it was cleared\n * (a clearable path, so the save deletes it);\n * - the structured address mirrored, as the one line every reader prints,\n * into `business.address` — but ONLY when the structured address changed.\n * A site whose address so far lives only in the one block keeps that block\n * through a save that never touched the address, rather than losing it to\n * an empty structured one;\n * - social links without an address dropped, each label and address trimmed,\n * up to {@link BUSINESS_SOCIAL_LINKS_MAX}.\n *\n * A new object: the form's values are not this function's to edit.\n */\nexport function businessDetailsWrite<T extends Record<string, unknown>>(\n fields: T,\n stored: BusinessDetailsHost | null | undefined,\n): T {\n const seo = { ...((fields?.['seo'] as Record<string, unknown>) ?? {}) }\n const entity = { ...((seo['entity'] as Record<string, unknown>) ?? {}) }\n for (const key of ['name', 'slogan', 'telephone', 'email'] as const) {\n if (typeof entity[key] === 'string') entity[key] = trimmed(entity[key])\n }\n if (entity['address'] && typeof entity['address'] === 'object') {\n const address = { ...(entity['address'] as Record<string, unknown>) }\n for (const [key, value] of Object.entries(address)) {\n if (typeof value === 'string') address[key] = trimmed(value)\n }\n entity['address'] = address\n }\n seo['entity'] = entity\n\n const business = { ...((fields?.['business'] as Record<string, unknown>) ?? {}) }\n const email = trimmed(entity['email'])\n if (email) business['supportEmail'] = email\n else if (trimmed(stored?.business?.supportEmail)) business['supportEmail'] = ''\n else delete business['supportEmail']\n\n const before = structuredAddressLine(stored?.seo?.entity?.address)\n const after = structuredAddressLine(\n entity['address'] as HostSeoEntity['address'] | undefined,\n )\n if (after !== before) {\n if (after) business['address'] = after\n else if (trimmed(stored?.business?.address)) business['address'] = ''\n else delete business['address']\n }\n\n if (Array.isArray(business['socialLinks'])) {\n business['socialLinks'] = (business['socialLinks'] as unknown[])\n .map((link) => link as { label?: unknown; url?: unknown } | null)\n .filter((link) => trimmed(link?.url))\n .slice(0, BUSINESS_SOCIAL_LINKS_MAX)\n .map((link) => ({ label: trimmed(link?.label), url: trimmed(link?.url) }))\n }\n\n return { ...fields, seo, business }\n}\n"],"names":["structuredAddressLine","siteContactEmail","SITE_SLOGAN_MAX_LENGTH","BUSINESS_SOCIAL_LINKS_MAX","BUSINESS_DETAILS_CLEARABLE_PATHS","trimmed","value","trim","businessDetailsSeed","host","email","seo","entity","businessDetailsWrite","fields","stored","key","address","Object","entries","business","supportEmail","before","after","Array","isArray","map","link","filter","url","slice","label"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,qBAAqB,QAAQ,wBAAoB;AAE1D,SAASC,gBAAgB,QAAQ,mBAAe;AAEhD;;;;;;;;;;;;;;;;;;;;;CAqBC,GAED,qFAAqF,GACrF,OAAO,MAAMC,yBAAyB,IAAG;AAEzC,mEAAmE,GACnE,OAAO,MAAMC,4BAA4B,EAAC;AAE1C;;;;;;;CAOC,GACD,OAAO,MAAMC,mCAAmC;IAC9C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAS;AAkBV,MAAMC,UAAU,CAACC,QACf,OAAOA,UAAU,WAAWA,MAAMC,IAAI,KAAK;AAE7C;;;;;;CAMC,GACD,OAAO,SAASC,oBACdC,IAA0B;QAObA;QAHSA,kBAAAA,YAGsBA;IAL5C,IAAI,CAACA,MAAM,OAAOA;IAClB,MAAMC,QAAQT,iBAAiBQ;IAC/B,IAAI,CAACC,SAASL,SAAQI,aAAAA,KAAKE,GAAG,sBAARF,mBAAAA,WAAUG,MAAM,qBAAhBH,iBAAkBC,KAAK,GAAG,OAAOD;IACvD,OAAO,aACFA;QACHE,KAAK,cAAMF,YAAAA,KAAKE,GAAG,YAARF,YAAY,CAAC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qBAAAA,YAAaH,MAAM,qBAAnBG,mBAAqBE,OAAO;IACjE,MAAMM,QAAQvB,sBACZY,MAAM,CAAC,UAAU;IAEnB,IAAIW,UAAUD,QAAQ;YAEHP;QADjB,IAAIQ,OAAOH,QAAQ,CAAC,UAAU,GAAGG;aAC5B,IAAIlB,QAAQU,2BAAAA,oBAAAA,OAAQK,QAAQ,qBAAhBL,kBAAkBE,OAAO,GAAGG,QAAQ,CAAC,UAAU,GAAG;aAC9D,OAAOA,QAAQ,CAAC,UAAU;IACjC;IAEA,IAAII,MAAMC,OAAO,CAACL,QAAQ,CAAC,cAAc,GAAG;QAC1CA,QAAQ,CAAC,cAAc,GAAG,AAACA,QAAQ,CAAC,cAAc,CAC/CM,GAAG,CAAC,CAACC,OAASA,MACdC,MAAM,CAAC,CAACD,OAAStB,QAAQsB,wBAAAA,KAAME,GAAG,GAClCC,KAAK,CAAC,GAAG3B,2BACTuB,GAAG,CAAC,CAACC,OAAU,CAAA;gBAAEI,OAAO1B,QAAQsB,wBAAAA,KAAMI,KAAK;gBAAGF,KAAKxB,QAAQsB,wBAAAA,KAAME,GAAG;YAAE,CAAA;IAC3E;IAEA,OAAO,aAAKf;QAAQH;QAAKS;;AAC3B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/business-details.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { structuredAddressLine } from './business-profile'\nimport type { HostSeoEntity } from './content-authors'\nimport { siteContactEmail } from './host-tokens'\n\n/**\n * A site's BUSINESS DETAILS, entered in one place (AGL-4136).\n *\n * The business name, slogan, phone, email, postal address and social links\n * are entered on Setup → Business profile and nowhere else, and everything that uses\n * them reads that one place. The storage did not move, so no site's data had\n * to: each fact has one canonical path, and the older path that used to hold\n * it is kept as a read fallback.\n *\n * | fact | canonical | kept in step |\n * | ------------ | ----------------------------- | -------------------------- |\n * | name | `seo.entity.name` | falls back to `displayName` |\n * | slogan | `seo.entity.slogan` | |\n * | phone | `seo.entity.telephone` | |\n * | email | `seo.entity.email` | mirrored to `business.supportEmail` |\n * | address | `seo.entity.address.*` | mirrored, formatted, to `business.address` |\n * | social links | `business.socialLinks` | `seo.entity.sameAs` joins it when read |\n *\n * The two mirrors exist for the readers that have not moved yet: the native\n * apps read and write the `business` copies, so a save here keeps them\n * showing what the console shows until they follow.\n */\n\n/** The longest slogan a site may set, as the field and the structured data hold it. */\nexport const SITE_SLOGAN_MAX_LENGTH = 120\n\n/** The most social links a site keeps, as the editor allows them. */\nexport const BUSINESS_SOCIAL_LINKS_MAX = 8\n\n/**\n * The paths a Setup → Business profile save may take back to EMPTY.\n *\n * The form drops a cleared input from what it submits, and the write merges,\n * so without this a cleared phone would save nothing and report \"Saved!\".\n * Both mirrors are here as well: an email or address cleared on the card has\n * to leave its copy too, or the fallback would bring it straight back.\n */\nexport const BUSINESS_DETAILS_CLEARABLE_PATHS = [\n 'seo.entity.name',\n 'seo.entity.slogan',\n 'seo.entity.telephone',\n 'seo.entity.email',\n 'seo.entity.address.streetAddress',\n 'seo.entity.address.addressLocality',\n 'seo.entity.address.addressRegion',\n 'seo.entity.address.postalCode',\n 'seo.entity.address.addressCountry',\n 'business.supportEmail',\n 'business.address',\n] as const\n\n/**\n * {@link BUSINESS_DETAILS_CLEARABLE_PATHS} as a plain list: the native apps' Business details\n * cards read it from the contracts, and so clear what the console clears.\n */\nexport const BUSINESS_DETAILS_CLEARABLE_PATH_LIST: readonly string[] =\n BUSINESS_DETAILS_CLEARABLE_PATHS\n\n/** The host fields the business details read and write. */\nexport interface BusinessDetailsHost {\n displayName?: string\n seo?: {\n entity?: Pick<\n HostSeoEntity,\n 'name' | 'slogan' | 'telephone' | 'email' | 'address'\n > | null\n } | null\n business?: {\n supportEmail?: unknown\n address?: unknown\n socialLinks?: Array<{ label?: unknown; url?: unknown } | null> | null\n } | null\n}\n\nconst trimmed = (value: unknown): string =>\n typeof value === 'string' ? value.trim() : ''\n\n/**\n * The host document as the Business details card is seeded with it: the\n * site's one email in the Email field, so a site whose email so far lived\n * only in the one-block copy shows it, and clearing the field clears it.\n * Everything else is the document as stored. A new object; `host` is not\n * changed.\n */\nexport function businessDetailsSeed<T extends BusinessDetailsHost>(\n host: T | null | undefined,\n): T | null | undefined {\n if (!host) return host\n const email = siteContactEmail(host)\n if (!email || trimmed(host.seo?.entity?.email)) return host\n return {\n ...host,\n seo: { ...(host.seo ?? {}), entity: { ...(host.seo?.entity ?? {}), email } },\n }\n}\n\n/**\n * What a Setup → Business profile save writes, from what the card submitted and what\n * the document stores now (AGL-4136):\n *\n * - every text value trimmed;\n * - the email mirrored into `business.supportEmail`, `''` when it was cleared\n * (a clearable path, so the save deletes it);\n * - the structured address mirrored, as the one line every reader prints,\n * into `business.address` — but ONLY when the structured address changed.\n * A site whose address so far lives only in the one block keeps that block\n * through a save that never touched the address, rather than losing it to\n * an empty structured one;\n * - social links without an address dropped, each label and address trimmed,\n * up to {@link BUSINESS_SOCIAL_LINKS_MAX}.\n *\n * A new object: the form's values are not this function's to edit.\n */\nexport function businessDetailsWrite<T extends Record<string, unknown>>(\n fields: T,\n stored: BusinessDetailsHost | null | undefined,\n): T {\n const seo = { ...((fields?.['seo'] as Record<string, unknown>) ?? {}) }\n const entity = { ...((seo['entity'] as Record<string, unknown>) ?? {}) }\n for (const key of ['name', 'slogan', 'telephone', 'email'] as const) {\n if (typeof entity[key] === 'string') entity[key] = trimmed(entity[key])\n }\n if (entity['address'] && typeof entity['address'] === 'object') {\n const address = { ...(entity['address'] as Record<string, unknown>) }\n for (const [key, value] of Object.entries(address)) {\n if (typeof value === 'string') address[key] = trimmed(value)\n }\n entity['address'] = address\n }\n seo['entity'] = entity\n\n const business = { ...((fields?.['business'] as Record<string, unknown>) ?? {}) }\n const email = trimmed(entity['email'])\n if (email) business['supportEmail'] = email\n else if (trimmed(stored?.business?.supportEmail)) business['supportEmail'] = ''\n else delete business['supportEmail']\n\n const before = structuredAddressLine(stored?.seo?.entity?.address)\n const after = structuredAddressLine(\n entity['address'] as HostSeoEntity['address'] | undefined,\n )\n if (after !== before) {\n if (after) business['address'] = after\n else if (trimmed(stored?.business?.address)) business['address'] = ''\n else delete business['address']\n }\n\n if (Array.isArray(business['socialLinks'])) {\n business['socialLinks'] = (business['socialLinks'] as unknown[])\n .map((link) => link as { label?: unknown; url?: unknown } | null)\n .filter((link) => trimmed(link?.url))\n .slice(0, BUSINESS_SOCIAL_LINKS_MAX)\n .map((link) => ({ label: trimmed(link?.label), url: trimmed(link?.url) }))\n }\n\n return { ...fields, seo, business }\n}\n"],"names":["structuredAddressLine","siteContactEmail","SITE_SLOGAN_MAX_LENGTH","BUSINESS_SOCIAL_LINKS_MAX","BUSINESS_DETAILS_CLEARABLE_PATHS","BUSINESS_DETAILS_CLEARABLE_PATH_LIST","trimmed","value","trim","businessDetailsSeed","host","email","seo","entity","businessDetailsWrite","fields","stored","key","address","Object","entries","business","supportEmail","before","after","Array","isArray","map","link","filter","url","slice","label"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,qBAAqB,QAAQ,wBAAoB;AAE1D,SAASC,gBAAgB,QAAQ,mBAAe;AAEhD;;;;;;;;;;;;;;;;;;;;;CAqBC,GAED,qFAAqF,GACrF,OAAO,MAAMC,yBAAyB,IAAG;AAEzC,mEAAmE,GACnE,OAAO,MAAMC,4BAA4B,EAAC;AAE1C;;;;;;;CAOC,GACD,OAAO,MAAMC,mCAAmC;IAC9C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAS;AAEV;;;CA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|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
/**
|
|
18
|
-
* Contacts CRM v2 (AGL-2595): the records that sit BESIDE a contact.
|
|
19
|
-
*
|
|
20
|
-
* v1 is one collection — `contacts` — and everything a holder knows about a
|
|
21
|
-
* person lives in that holder's facet on the shared row. That shape is right
|
|
22
|
-
* for the person and wrong for everything a sales team keeps AROUND the
|
|
23
|
-
* person: a company is known by several contacts, a deal moves through
|
|
24
|
-
* stages on its own clock, a task is due whether or not anybody opens the
|
|
25
|
-
* contact it hangs off, and an activity log grows past anything a facet
|
|
26
|
-
* should carry. So each of those is a collection of its own under
|
|
27
|
-
* `orgs/{orgId}/`, pointing back at the contact by id.
|
|
28
|
-
*
|
|
29
|
-
* ## One scope model, not a second one
|
|
30
|
-
*
|
|
31
|
-
* Every collection here carries `visibleTo`, the same array `contacts`
|
|
32
|
-
* carries, and is stamped the same way — {@link crmScopeTokens} is the
|
|
33
|
-
* contact create path's expression, exported so that no creator computes its
|
|
34
|
-
* own. The rules gate all six on the contacts predicate (`canReadScopedPeople`,
|
|
35
|
-
* `data.manage`), because a deal or a call log is a fact about a person and
|
|
36
|
-
* discloses exactly what the contact row would.
|
|
37
|
-
*
|
|
38
|
-
* What these collections do NOT have is the facet map. A contact is shared
|
|
39
|
-
* across holders because one human is one row; a company, deal or task is
|
|
40
|
-
* one holder's record from the moment it is created, so `visibleTo` alone
|
|
41
|
-
* says who may see it and there is nothing to split per holder.
|
|
42
|
-
*
|
|
43
|
-
* Pure data module: types, constants and the small helpers every surface
|
|
44
|
-
* would otherwise write for itself. No Firestore, no React.
|
|
45
|
-
*/
|
|
46
17
|
import { type AglynPostalAddress } from '../foundation/definitions/contact.types';
|
|
47
18
|
import type { OrgCrmAssignmentRule } from '../foundation/definitions/org-billing.types';
|
|
48
19
|
import { type ConsentGroup } from './consent-groups';
|
|
@@ -1331,9 +1302,25 @@ export declare const PUBLIC_MAILBOX_DOMAINS: ReadonlySet<string>;
|
|
|
1331
1302
|
export declare function isPublicMailboxDomain(domainOrEmail: unknown): boolean;
|
|
1332
1303
|
/**
|
|
1333
1304
|
* The company domain an email address implies, or `null` when it implies
|
|
1334
|
-
* none — a malformed address,
|
|
1305
|
+
* none — a malformed address, one at a public mailbox provider, or one at a
|
|
1306
|
+
* disposable-mailbox service (AGL-4230): an inbox that expires in ten
|
|
1307
|
+
* minutes belongs to nobody, let alone a business.
|
|
1335
1308
|
*/
|
|
1336
1309
|
export declare function companyDomainForEmail(email: unknown): string | null;
|
|
1310
|
+
/**
|
|
1311
|
+
* Whether a company may be CREATED from this domain on its own (AGL-4230),
|
|
1312
|
+
* as opposed to linked to one that already exists.
|
|
1313
|
+
*
|
|
1314
|
+
* {@link companyDomainForEmail} has already turned away public and
|
|
1315
|
+
* disposable mailboxes. What it lets through and this does not is a school
|
|
1316
|
+
* or a university: a student's address at `k12.ipsd.org` or
|
|
1317
|
+
* `aluno.educa.go.gov.br` is a real organisation's domain, but the person
|
|
1318
|
+
* signing up is not that organisation's buyer, and minting "K12" or "Aluno"
|
|
1319
|
+
* from every pupil who tries the product fills the company list with
|
|
1320
|
+
* schools. So a school domain still LINKS to a company somebody created on
|
|
1321
|
+
* purpose, and is never minted into one by the capture door.
|
|
1322
|
+
*/
|
|
1323
|
+
export declare function companyDomainMintable(domain: unknown): boolean;
|
|
1337
1324
|
/**
|
|
1338
1325
|
* The name a company minted from a domain starts with: the first label with
|
|
1339
1326
|
* a capital — `acme.com` → `Acme`, `initech.co.uk` → `Initech`.
|
package/src/lib/app-utils/crm.js
CHANGED
|
@@ -42,7 +42,8 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
42
42
|
*
|
|
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
|
-
*/ import {
|
|
45
|
+
*/ import { isDisposableEmailDomain } from "@aglyn/shared-util-email/disposable-email-domains";
|
|
46
|
+
import { normalizeAddress, normalizePhone } from "../foundation/definitions/contact.types.js";
|
|
46
47
|
import { consentGroupScope, soloConsentGroup } from "./consent-groups.js";
|
|
47
48
|
import { CONTACT_LIFECYCLE_STAGES, CRM_TASK_KINDS, isContactLifecycleStage } from "./crm-kinds.js";
|
|
48
49
|
import { CONTACT_ALTERNATE_EMAILS_FIELD, CONTACT_FACETS_FIELD, composeContactName, normalizeContactEmail, readContactFacet } from "./contacts.js";
|
|
@@ -1439,7 +1440,104 @@ const blank = (value)=>value === null || typeof value === 'string' && value.trim
|
|
|
1439
1440
|
'laposte.net',
|
|
1440
1441
|
't-online.de',
|
|
1441
1442
|
'libero.it',
|
|
1442
|
-
'bigpond.com'
|
|
1443
|
+
'bigpond.com',
|
|
1444
|
+
// More of the free providers people sign up with (AGL-4230): Russia and
|
|
1445
|
+
// the CIS, central and eastern Europe, the rest of western Europe, Latin
|
|
1446
|
+
// America, and Asia.
|
|
1447
|
+
'mail.ru',
|
|
1448
|
+
'inbox.ru',
|
|
1449
|
+
'list.ru',
|
|
1450
|
+
'bk.ru',
|
|
1451
|
+
'internet.ru',
|
|
1452
|
+
'ya.ru',
|
|
1453
|
+
'yandex.ua',
|
|
1454
|
+
'yandex.by',
|
|
1455
|
+
'yandex.kz',
|
|
1456
|
+
'rambler.ru',
|
|
1457
|
+
'ukr.net',
|
|
1458
|
+
'i.ua',
|
|
1459
|
+
'abv.bg',
|
|
1460
|
+
'seznam.cz',
|
|
1461
|
+
'centrum.cz',
|
|
1462
|
+
'wp.pl',
|
|
1463
|
+
'o2.pl',
|
|
1464
|
+
'onet.pl',
|
|
1465
|
+
'interia.pl',
|
|
1466
|
+
'inbox.lv',
|
|
1467
|
+
'gmx.at',
|
|
1468
|
+
'gmx.ch',
|
|
1469
|
+
'gmx.fr',
|
|
1470
|
+
'gmx.es',
|
|
1471
|
+
'freenet.de',
|
|
1472
|
+
'posteo.de',
|
|
1473
|
+
'mailbox.org',
|
|
1474
|
+
'tutanota.de',
|
|
1475
|
+
'tutamail.com',
|
|
1476
|
+
'virgilio.it',
|
|
1477
|
+
'alice.it',
|
|
1478
|
+
'tiscali.it',
|
|
1479
|
+
'sfr.fr',
|
|
1480
|
+
'wanadoo.fr',
|
|
1481
|
+
'bluewin.ch',
|
|
1482
|
+
'telenet.be',
|
|
1483
|
+
'skynet.be',
|
|
1484
|
+
'ziggo.nl',
|
|
1485
|
+
'kpnmail.nl',
|
|
1486
|
+
'home.nl',
|
|
1487
|
+
'planet.nl',
|
|
1488
|
+
'hotmail.es',
|
|
1489
|
+
'hotmail.com.br',
|
|
1490
|
+
'outlook.es',
|
|
1491
|
+
'outlook.fr',
|
|
1492
|
+
'outlook.de',
|
|
1493
|
+
'outlook.it',
|
|
1494
|
+
'outlook.com.br',
|
|
1495
|
+
'live.fr',
|
|
1496
|
+
'live.nl',
|
|
1497
|
+
'live.it',
|
|
1498
|
+
'yahoo.es',
|
|
1499
|
+
'yahoo.it',
|
|
1500
|
+
'yahoo.com.br',
|
|
1501
|
+
'yahoo.com.mx',
|
|
1502
|
+
'yahoo.com.ar',
|
|
1503
|
+
'yahoo.co.jp',
|
|
1504
|
+
'yahoo.co.id',
|
|
1505
|
+
'yahoo.com.ph',
|
|
1506
|
+
'yahoo.com.sg',
|
|
1507
|
+
'yahoo.in',
|
|
1508
|
+
'aol.co.uk',
|
|
1509
|
+
'uol.com.br',
|
|
1510
|
+
'bol.com.br',
|
|
1511
|
+
'terra.com.br',
|
|
1512
|
+
'ig.com.br',
|
|
1513
|
+
'sohu.com',
|
|
1514
|
+
'aliyun.com',
|
|
1515
|
+
'foxmail.com',
|
|
1516
|
+
'yeah.net',
|
|
1517
|
+
'139.com',
|
|
1518
|
+
'daum.net',
|
|
1519
|
+
'nate.com',
|
|
1520
|
+
// Generic mailboxes from the mail.com family and the like.
|
|
1521
|
+
'email.com',
|
|
1522
|
+
'usa.com',
|
|
1523
|
+
'myself.com',
|
|
1524
|
+
'inbox.com',
|
|
1525
|
+
// Subscriber mailboxes at more US, Canadian, Australian and New Zealand
|
|
1526
|
+
// internet providers.
|
|
1527
|
+
'roadrunner.com',
|
|
1528
|
+
'twc.com',
|
|
1529
|
+
'mediacombb.net',
|
|
1530
|
+
'suddenlink.net',
|
|
1531
|
+
'embarqmail.com',
|
|
1532
|
+
'q.com',
|
|
1533
|
+
'cableone.net',
|
|
1534
|
+
'rogers.com',
|
|
1535
|
+
'telus.net',
|
|
1536
|
+
'videotron.ca',
|
|
1537
|
+
'cogeco.ca',
|
|
1538
|
+
'bigpond.net.au',
|
|
1539
|
+
'optusnet.com.au',
|
|
1540
|
+
'xtra.co.nz'
|
|
1443
1541
|
]);
|
|
1444
1542
|
/**
|
|
1445
1543
|
* Whether a domain — or the domain of an address — is one of the
|
|
@@ -1452,7 +1550,9 @@ const blank = (value)=>value === null || typeof value === 'string' && value.trim
|
|
|
1452
1550
|
}
|
|
1453
1551
|
/**
|
|
1454
1552
|
* The company domain an email address implies, or `null` when it implies
|
|
1455
|
-
* none — a malformed address,
|
|
1553
|
+
* none — a malformed address, one at a public mailbox provider, or one at a
|
|
1554
|
+
* disposable-mailbox service (AGL-4230): an inbox that expires in ten
|
|
1555
|
+
* minutes belongs to nobody, let alone a business.
|
|
1456
1556
|
*/ export function companyDomainForEmail(email) {
|
|
1457
1557
|
const value = String(email != null ? email : '').trim().toLowerCase();
|
|
1458
1558
|
const at = value.lastIndexOf('@');
|
|
@@ -1460,8 +1560,44 @@ const blank = (value)=>value === null || typeof value === 'string' && value.trim
|
|
|
1460
1560
|
if (/[\s@]/.test(value.slice(0, at))) return null;
|
|
1461
1561
|
const domain = normalizeCompanyDomain(value.slice(at + 1));
|
|
1462
1562
|
if (!domain || PUBLIC_MAILBOX_DOMAINS.has(domain)) return null;
|
|
1563
|
+
if (isDisposableEmailDomain(domain)) return null;
|
|
1463
1564
|
return domain;
|
|
1464
1565
|
}
|
|
1566
|
+
/**
|
|
1567
|
+
* Labels that mark a school's or a university's mailbox: `k12`, `edu` and
|
|
1568
|
+
* the academic `ac` (as in `ac.uk`), and the words a student mailbox's host
|
|
1569
|
+
* is built from.
|
|
1570
|
+
*/ const SCHOOL_DOMAIN_LABELS = new Set([
|
|
1571
|
+
'k12',
|
|
1572
|
+
'edu',
|
|
1573
|
+
'ac',
|
|
1574
|
+
'student',
|
|
1575
|
+
'students',
|
|
1576
|
+
'aluno',
|
|
1577
|
+
'alunos',
|
|
1578
|
+
'alumno',
|
|
1579
|
+
'alumnos',
|
|
1580
|
+
'estudiante',
|
|
1581
|
+
'estudiantes'
|
|
1582
|
+
]);
|
|
1583
|
+
/**
|
|
1584
|
+
* Whether a company may be CREATED from this domain on its own (AGL-4230),
|
|
1585
|
+
* as opposed to linked to one that already exists.
|
|
1586
|
+
*
|
|
1587
|
+
* {@link companyDomainForEmail} has already turned away public and
|
|
1588
|
+
* disposable mailboxes. What it lets through and this does not is a school
|
|
1589
|
+
* or a university: a student's address at `k12.ipsd.org` or
|
|
1590
|
+
* `aluno.educa.go.gov.br` is a real organisation's domain, but the person
|
|
1591
|
+
* signing up is not that organisation's buyer, and minting "K12" or "Aluno"
|
|
1592
|
+
* from every pupil who tries the product fills the company list with
|
|
1593
|
+
* schools. So a school domain still LINKS to a company somebody created on
|
|
1594
|
+
* purpose, and is never minted into one by the capture door.
|
|
1595
|
+
*/ export function companyDomainMintable(domain) {
|
|
1596
|
+
const value = normalizeCompanyDomain(domain);
|
|
1597
|
+
if (!value) return false;
|
|
1598
|
+
if (PUBLIC_MAILBOX_DOMAINS.has(value) || isDisposableEmailDomain(value)) return false;
|
|
1599
|
+
return !value.split('.').some((label)=>SCHOOL_DOMAIN_LABELS.has(label) || /schools?/.test(label));
|
|
1600
|
+
}
|
|
1465
1601
|
/**
|
|
1466
1602
|
* The name a company minted from a domain starts with: the first label with
|
|
1467
1603
|
* a capital — `acme.com` → `Acme`, `initech.co.uk` → `Initech`.
|