@aglyn/plugins-crm 1.29.1 → 1.29.2
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 +14 -14
- package/src/lib/transfer/aliases.js +8 -2
- package/src/lib/transfer/aliases.js.map +1 -1
- package/src/lib/transfer/contact-import-steps.d.ts +36 -0
- package/src/lib/transfer/contact-import-steps.js +81 -0
- package/src/lib/transfer/contact-import-steps.js.map +1 -0
- package/src/lib/transfer/contacts.js +119 -17
- package/src/lib/transfer/contacts.js.map +1 -1
- package/src/lib/transfer/customer-consent-plan.d.ts +90 -0
- package/src/lib/transfer/customer-consent-plan.js +258 -0
- package/src/lib/transfer/customer-consent-plan.js.map +1 -0
- package/src/lib/transfer/customer-sources.d.ts +68 -0
- package/src/lib/transfer/customer-sources.js +420 -0
- package/src/lib/transfer/customer-sources.js.map +1 -0
- package/src/lib/transfer/fields.js +7 -3
- package/src/lib/transfer/fields.js.map +1 -1
- package/src/lib/transfer/imported-consent.server.d.ts +74 -0
- package/src/lib/transfer/imported-consent.server.js +241 -0
- package/src/lib/transfer/imported-consent.server.js.map +1 -0
- package/src/lib/transfer/ui.d.ts +5 -1
- package/src/lib/transfer/ui.js +21 -2
- package/src/lib/transfer/ui.js.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/transfer/imported-consent.server.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 * A STORE FILE'S MARKETING CHOICE, WRITTEN AND UNDONE (AGL-4245).\n *\n * The plan (`customer-consent-plan.ts`) decided each row's change against\n * the contact as the dry run read it. This writes it against the contact as\n * it is NOW, checking again, because a person may have unsubscribed between\n * the dry run and the import:\n *\n * - **A grant** is the site's own entry (`marketingConsentByHost[site]`),\n * for that one site, and only when the plan carries the statement of the\n * member who planned it and the job's answer still says so. A contact\n * whose basis reads declined for the site, or whom the site's unsubscribe\n * list holds, is never granted.\n * - **A refusal** is the site's own entry too, read across its consent\n * group like every refusal. A contact who was subscribed here is also put\n * on the site's unsubscribe list (`recordSiteUnsubscribe`, `via`\n * `crm-import:<store>`), as their own unsubscribe link would. With no\n * site, the refusal is the record's unscoped one, honored by every site.\n * - **Provenance** rides with the entry, where the consent reader looks for\n * it: `marketingConsentSource` with the kind {@link CONTACT_IMPORT_CONSENT_KIND},\n * who, when, the store and the import job, and a sentence saying so.\n *\n * Undo takes back an opt-IN the import wrote — putting back exactly the\n * entry that stood before, only while the entry is still the import's own;\n * a choice the person made since is theirs and stays. It never takes back a\n * refusal: an unsubscribe the file carried is the person's own choice, made\n * at their old store, so the entry and its unsubscribe-list row stay through\n * an undo, and a contact the undo removes keeps it in the retained-refusals\n * store like any other refusal (`removeContactKeepingRefusals`).\n *=========================================*/\n\nimport {\n MARKETING_CONSENT_BY_HOST_FIELD,\n MARKETING_CONSENT_FIELD,\n MARKETING_CONSENT_SOURCE_FIELD,\n readMarketingBasis,\n} from '@aglyn/aglyn/app-utils/marketing-consent'\nimport type { ConsentGroup } from '@aglyn/aglyn/app-utils/consent-groups'\nimport { personKey } from '@aglyn/aglyn/app-utils/person-key'\nimport { recordSiteUnsubscribe } from '@aglyn/tenant-data-admin/server/site-marketing-sync'\nimport { FieldValue } from 'firebase-admin/firestore'\nimport type { ImportedConsentDetail } from './customer-consent-plan'\nimport { CUSTOMER_FILE_SOURCE_NAMES } from './customer-sources'\n\n/** The `kind` of the provenance an import's consent entry carries. */\nexport const CONTACT_IMPORT_CONSENT_KIND = 'contact-import'\n\n/** The suppression `via` an import's unsubscribe is filed under. */\nexport function importedConsentVia(source: ImportedConsentDetail['source']): string {\n return `crm-import:${source}`\n}\n\n/** The addresses any of `hostIds`' unsubscribe lists holds live, lowercased. */\nexport async function readSuppressedAddresses(\n firestore: FirebaseFirestore.Firestore,\n hostIds: readonly string[],\n emails: readonly string[],\n): Promise<Set<string>> {\n const out = new Set<string>()\n const keyed = emails.flatMap((email) => {\n const key = personKey(email)\n return key ? [{ email: email.trim().toLowerCase(), key }] : []\n })\n const refs = hostIds.flatMap((hostId) =>\n keyed.map((entry) => ({\n email: entry.email,\n ref: firestore.collection('hosts').doc(hostId).collection('suppressions').doc(entry.key),\n })),\n )\n for (let at = 0; at < refs.length; at += 300) {\n const page = refs.slice(at, at + 300)\n const snapshots = await firestore.getAll(...page.map((entry) => entry.ref))\n snapshots.forEach((snapshot, index) => {\n if (snapshot.exists && !snapshot.get('releasedAt')) out.add((page[index] as { email: string }).email)\n })\n }\n return out\n}\n\n/** What undo needs to take back one opt-in the import wrote. */\nexport interface ImportedConsentUndo {\n /** Field path → the value before the import, or `null` for none. */\n fields: Record<string, unknown>\n /** The provenance's `atMs`: the entry is still the import's while it reads this. */\n atMs: number\n}\n\n/** A stored value as plain data an undo snapshot can hold: a timestamp as its epoch ms. */\nfunction plain(value: unknown): unknown {\n if (value === null || value === undefined) return null\n if (typeof value !== 'object') return value\n const millis = (value as { toMillis?: () => number }).toMillis\n if (typeof millis === 'function') return millis.call(value)\n if (Array.isArray(value)) return value.map(plain)\n return Object.fromEntries(Object.entries(value as Record<string, unknown>).map(([key, entry]) => [key, plain(entry)]))\n}\n\n/** The sentence a consent record carries, for whoever reads it later. */\nfunction provenanceReason(detail: ImportedConsentDetail, atMs: number): string {\n const file = detail.source === 'file' ? 'a customer file' : `a ${CUSTOMER_FILE_SOURCE_NAMES[detail.source]} customer file`\n const day = new Date(atMs).toISOString().slice(0, 10)\n const job = detail.jobId ? ` (import ${detail.jobId})` : ''\n return detail.action === 'grant'\n ? `Opted in as ${file} recorded, imported on ${day}${job}. The member who imported it confirmed these people agreed to hear from this business.`\n : `Unsubscribed as ${file} recorded, imported on ${day}${job}.`\n}\n\n/** What one row's consent write did. */\nexport type ImportedConsentOutcome =\n /** `undo` for an opt-in; `null` for a refusal, which no undo takes back. */\n | { written: true; value: boolean; undo: ImportedConsentUndo | null }\n | { written: false; message?: string }\n\n/**\n * Writes one row's planned consent change onto the contact, checked against\n * the contact as it is now (see the module note). A grant needs both the\n * plan's own statement and `attestedNow`, the job's Permission answer as the\n * apply reads it.\n */\nexport async function writeImportedConsent(input: {\n firestore: FirebaseFirestore.Firestore\n contactRef: FirebaseFirestore.DocumentReference\n /** The import's site, or `null` with none. */\n hostId: string | null\n group: ConsentGroup\n detail: ImportedConsentDetail\n attestedNow: boolean\n /** Who to name on a refusal when the plan named nobody. */\n fallbackBy: string | null\n atMs: number\n}): Promise<ImportedConsentOutcome> {\n const { detail, hostId } = input\n const snapshot = await input.contactRef.get()\n const contact = snapshot.data()\n if (!snapshot.exists || !contact) return { written: false }\n const email = String(contact['email'] ?? '').trim().toLowerCase()\n if (!email) return { written: false }\n const basis = hostId\n ? readMarketingBasis(contact, input.group).basis\n : contact[MARKETING_CONSENT_FIELD] === false\n ? 'declined'\n : 'unrecorded'\n const by = detail.by ?? input.fallbackBy\n\n if (detail.action === 'grant') {\n if (!hostId || !detail.attested || !input.attestedNow || !detail.by) {\n return { written: false, message: 'Not opted in: nobody confirmed these people agreed to hear from you.' }\n }\n if (basis === 'declined') return { written: false, message: 'Not opted in: they unsubscribed here.' }\n if (basis === 'granted') return { written: false }\n const suppressed = await readSuppressedAddresses(input.firestore, input.group.hostIds.length ? input.group.hostIds : [hostId], [email])\n if (suppressed.size) return { written: false, message: 'Not opted in: they unsubscribed here.' }\n } else if (basis === 'declined') {\n return { written: false }\n }\n\n const source = {\n kind: CONTACT_IMPORT_CONSENT_KIND,\n by: by ?? 'import',\n atMs: input.atMs,\n reason: provenanceReason(detail, input.atMs),\n actor: 'operator' as const,\n source: detail.source,\n jobId: detail.jobId,\n }\n const granted = detail.action === 'grant'\n const update: Record<string, unknown> = {}\n const fields: Record<string, unknown> = {}\n if (hostId) {\n const path = `${MARKETING_CONSENT_BY_HOST_FIELD}.${hostId}`\n const byHost = contact[MARKETING_CONSENT_BY_HOST_FIELD] as Record<string, unknown> | undefined\n fields[path] = plain(byHost?.[hostId])\n update[path] = {\n [MARKETING_CONSENT_FIELD]: granted,\n marketingConsentAtMs: input.atMs,\n [MARKETING_CONSENT_SOURCE_FIELD]: source,\n }\n } else {\n // No site: the record's unscoped refusal, which every site honors, with\n // its provenance where the reader looks for an unscoped refusal's.\n for (const path of [MARKETING_CONSENT_FIELD, 'marketingConsentAtMs', MARKETING_CONSENT_SOURCE_FIELD]) {\n fields[path] = plain(contact[path])\n }\n update[MARKETING_CONSENT_FIELD] = false\n update['marketingConsentAtMs'] = input.atMs\n update[MARKETING_CONSENT_SOURCE_FIELD] = source\n }\n await input.contactRef.update({ ...update, updatedAt: FieldValue.serverTimestamp() })\n\n if (!granted && hostId && basis === 'granted') {\n const via = importedConsentVia(detail.source)\n const name = detail.source === 'file' ? 'customer file' : `${CUSTOMER_FILE_SOURCE_NAMES[detail.source]} customer file`\n await recordSiteUnsubscribe({\n hostId,\n email,\n via,\n detail: `Unsubscribed, as your ${name} records.`,\n firestore: input.firestore,\n })\n }\n return { written: true, value: granted, undo: granted ? { fields, atMs: input.atMs } : null }\n}\n\n/** Whether the consent at `path` on `contact` is still the one this import wrote. */\nfunction stillImported(contact: Record<string, unknown>, path: string, atMs: number): boolean {\n const source = path.startsWith(`${MARKETING_CONSENT_BY_HOST_FIELD}.`)\n ? ((contact[MARKETING_CONSENT_BY_HOST_FIELD] as Record<string, Record<string, unknown>> | undefined)?.[\n path.slice(MARKETING_CONSENT_BY_HOST_FIELD.length + 1)\n ]?.[MARKETING_CONSENT_SOURCE_FIELD] as Record<string, unknown> | undefined)\n : (contact[MARKETING_CONSENT_SOURCE_FIELD] as Record<string, unknown> | undefined)\n return source?.['kind'] === CONTACT_IMPORT_CONSENT_KIND && source['atMs'] === atMs\n}\n\n/**\n * Takes back an opt-in the import wrote, putting back the consent the\n * contact held before it. Nothing changes when the person's consent has\n * moved since: the choice they made since is theirs.\n *\n * @returns whether the import's opt-in was taken back.\n */\nexport async function revertImportedConsent(input: {\n firestore: FirebaseFirestore.Firestore\n contactRef: FirebaseFirestore.DocumentReference\n undo: ImportedConsentUndo\n}): Promise<boolean> {\n const snapshot = await input.contactRef.get()\n const contact = snapshot.data()\n if (!snapshot.exists || !contact) return false\n const paths = Object.keys(input.undo.fields ?? {})\n const own = paths.find((path) => path !== 'marketingConsentAtMs' && path !== MARKETING_CONSENT_FIELD) ?? paths[0]\n if (!own || !stillImported(contact, own, input.undo.atMs)) return false\n const update: Record<string, unknown> = {}\n for (const path of paths) {\n const previous = input.undo.fields[path]\n update[path] = previous === null || previous === undefined ? FieldValue.delete() : previous\n }\n await input.contactRef.update({ ...update, updatedAt: FieldValue.serverTimestamp() })\n return true\n}\n\n/** The undo an entry's `extras` holds, when it is well formed. */\nexport function readImportedConsentUndo(extras: Readonly<Record<string, unknown>> | undefined): ImportedConsentUndo | null {\n const value = extras?.['consent'] as Partial<ImportedConsentUndo> | undefined\n if (!value || typeof value !== 'object' || typeof value.atMs !== 'number' || !value.fields || typeof value.fields !== 'object') {\n return null\n }\n return { fields: value.fields, atMs: value.atMs }\n}\n"],"names":["MARKETING_CONSENT_BY_HOST_FIELD","MARKETING_CONSENT_FIELD","MARKETING_CONSENT_SOURCE_FIELD","readMarketingBasis","personKey","recordSiteUnsubscribe","FieldValue","CUSTOMER_FILE_SOURCE_NAMES","CONTACT_IMPORT_CONSENT_KIND","importedConsentVia","source","readSuppressedAddresses","firestore","hostIds","emails","out","Set","keyed","flatMap","email","key","trim","toLowerCase","refs","hostId","map","entry","ref","collection","doc","at","length","page","slice","snapshots","getAll","forEach","snapshot","index","exists","get","add","plain","value","undefined","millis","toMillis","call","Array","isArray","Object","fromEntries","entries","provenanceReason","detail","atMs","file","day","Date","toISOString","job","jobId","action","writeImportedConsent","input","contact","contactRef","data","written","String","basis","group","by","fallbackBy","attested","attestedNow","message","suppressed","size","kind","reason","actor","granted","update","fields","path","byHost","marketingConsentAtMs","updatedAt","serverTimestamp","via","name","undo","stillImported","startsWith","revertImportedConsent","paths","keys","own","find","previous","delete","readImportedConsentUndo","extras"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CA6B2C,GAE3C,SACEA,+BAA+B,EAC/BC,uBAAuB,EACvBC,8BAA8B,EAC9BC,kBAAkB,QACb,2CAA0C;AAEjD,SAASC,SAAS,QAAQ,oCAAmC;AAC7D,SAASC,qBAAqB,QAAQ,sDAAqD;AAC3F,SAASC,UAAU,QAAQ,2BAA0B;AAErD,SAASC,0BAA0B,QAAQ,wBAAoB;AAE/D,oEAAoE,GACpE,OAAO,MAAMC,8BAA8B,iBAAgB;AAE3D,kEAAkE,GAClE,OAAO,SAASC,mBAAmBC,MAAuC;IACxE,OAAO,CAAC,WAAW,EAAEA,QAAQ;AAC/B;AAEA,8EAA8E,GAC9E,OAAO,eAAeC,wBACpBC,SAAsC,EACtCC,OAA0B,EAC1BC,MAAyB;IAEzB,MAAMC,MAAM,IAAIC;IAChB,MAAMC,QAAQH,OAAOI,OAAO,CAAC,CAACC;QAC5B,MAAMC,MAAMhB,UAAUe;QACtB,OAAOC,MAAM;YAAC;gBAAED,OAAOA,MAAME,IAAI,GAAGC,WAAW;gBAAIF;YAAI;SAAE,GAAG,EAAE;IAChE;IACA,MAAMG,OAAOV,QAAQK,OAAO,CAAC,CAACM,SAC5BP,MAAMQ,GAAG,CAAC,CAACC,QAAW,CAAA;gBACpBP,OAAOO,MAAMP,KAAK;gBAClBQ,KAAKf,UAAUgB,UAAU,CAAC,SAASC,GAAG,CAACL,QAAQI,UAAU,CAAC,gBAAgBC,GAAG,CAACH,MAAMN,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C,IAAI,EAACjC,qBAAAA,MAAM4B,IAAI,CAACR,MAAM,YAAjBpB,qBAAqB,CAAC;IAChD,MAAMkC,OAAMF,cAAAA,MAAMG,IAAI,CAAC,CAACd,OAASA,SAAS,0BAA0BA,SAASpF,oCAAjE+F,cAA6FA,KAAK,CAAC,EAAE;IACjH,IAAI,CAACE,OAAO,CAACL,cAAc5B,SAASiC,KAAKlC,MAAM4B,IAAI,CAACrC,IAAI,GAAG,OAAO;IAClE,MAAM4B,SAAkC,CAAC;IACzC,KAAK,MAAME,QAAQW,MAAO;QACxB,MAAMI,WAAWpC,MAAM4B,IAAI,CAACR,MAAM,CAACC,KAAK;QACxCF,MAAM,CAACE,KAAK,GAAGe,aAAa,QAAQA,aAAaxD,YAAYtC,WAAW+F,MAAM,KAAKD;IACrF;IACA,MAAMpC,MAAME,UAAU,CAACiB,MAAM,CAAC,aAAKA;QAAQK,WAAWlF,WAAWmF,eAAe;;IAChF,OAAO;AACT;AAEA,gEAAgE,GAChE,OAAO,SAASa,wBAAwBC,MAAqD;IAC3F,MAAM5D,QAAQ4D,0BAAAA,MAAQ,CAAC,UAAU;IACjC,IAAI,CAAC5D,SAAS,OAAOA,UAAU,YAAY,OAAOA,MAAMY,IAAI,KAAK,YAAY,CAACZ,MAAMyC,MAAM,IAAI,OAAOzC,MAAMyC,MAAM,KAAK,UAAU;QAC9H,OAAO;IACT;IACA,OAAO;QAAEA,QAAQzC,MAAMyC,MAAM;QAAE7B,MAAMZ,MAAMY,IAAI;IAAC;AAClD"}
|
package/src/lib/transfer/ui.d.ts
CHANGED
|
@@ -16,5 +16,9 @@
|
|
|
16
16
|
*/
|
|
17
17
|
/** The wizard's title for each resource. */
|
|
18
18
|
export declare const CRM_TRANSFER_LABELS: Readonly<Record<string, string>>;
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Registers the client half of every CRM transfer resource. The contact
|
|
21
|
+
* import carries one step of its own: the statement of permission for the
|
|
22
|
+
* marketing opt-ins a store's customer file records.
|
|
23
|
+
*/
|
|
20
24
|
export declare function registerCrmTransferResourceUis(pluginId: string): void;
|
package/src/lib/transfer/ui.js
CHANGED
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
* (AGL-3527, AGL-3528) — the client half of each resource, registered from the
|
|
19
19
|
* console registrar, which loads where the wizard is drawn.
|
|
20
20
|
*=========================================*/ import { registerPluginTransferResourceUi } from "@aglyn/aglyn/plugin-manager/plugin-transfer-resources";
|
|
21
|
+
import { lazy } from "react";
|
|
22
|
+
import { CONTACT_CONSENT_STEP_ID } from "./customer-sources.js";
|
|
21
23
|
import { CRM_ACTIVITIES_RESOURCE, CRM_COMPANIES_RESOURCE, CRM_CONTACTS_RESOURCE, CRM_DEALS_RESOURCE, CRM_FIELDS_RESOURCE, CRM_LEADS_RESOURCE, CRM_PIPELINES_RESOURCE, CRM_TASKS_RESOURCE } from "./resource-keys.js";
|
|
22
24
|
/** The wizard's title for each resource. */ export const CRM_TRANSFER_LABELS = {
|
|
23
25
|
[CRM_CONTACTS_RESOURCE]: 'Contacts',
|
|
@@ -29,9 +31,26 @@ import { CRM_ACTIVITIES_RESOURCE, CRM_COMPANIES_RESOURCE, CRM_CONTACTS_RESOURCE,
|
|
|
29
31
|
[CRM_PIPELINES_RESOURCE]: 'Pipelines and stages',
|
|
30
32
|
[CRM_FIELDS_RESOURCE]: 'Custom fields'
|
|
31
33
|
};
|
|
32
|
-
|
|
34
|
+
/* The contact import's Permission step (AGL-4245), loaded when the wizard reaches it. */ const ContactConsentStep = lazy(()=>import("./contact-import-steps.js").then((steps)=>({
|
|
35
|
+
default: steps.ContactConsentStep
|
|
36
|
+
})));
|
|
37
|
+
/**
|
|
38
|
+
* Registers the client half of every CRM transfer resource. The contact
|
|
39
|
+
* import carries one step of its own: the statement of permission for the
|
|
40
|
+
* marketing opt-ins a store's customer file records.
|
|
41
|
+
*/ export function registerCrmTransferResourceUis(pluginId) {
|
|
33
42
|
for (const [key, label] of Object.entries(CRM_TRANSFER_LABELS)){
|
|
34
|
-
registerPluginTransferResourceUi(key, {
|
|
43
|
+
registerPluginTransferResourceUi(key, key === CRM_CONTACTS_RESOURCE ? {
|
|
44
|
+
label,
|
|
45
|
+
extraSteps: [
|
|
46
|
+
{
|
|
47
|
+
id: CONTACT_CONSENT_STEP_ID,
|
|
48
|
+
label: 'Permission',
|
|
49
|
+
after: 'conflicts',
|
|
50
|
+
component: ContactConsentStep
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
} : {
|
|
35
54
|
label
|
|
36
55
|
}, {
|
|
37
56
|
pluginId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/transfer/ui.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 * HOW THE IMPORT WIZARD AND THE EXPORT DIALOG NAME THE CRM'S RECORDS\n * (AGL-3527, AGL-3528) — the client half of each resource, registered from the\n * console registrar, which loads where the wizard is drawn.\n *=========================================*/\n\nimport { registerPluginTransferResourceUi } from '@aglyn/aglyn/plugin-manager/plugin-transfer-resources'\nimport {\n CRM_ACTIVITIES_RESOURCE,\n CRM_COMPANIES_RESOURCE,\n CRM_CONTACTS_RESOURCE,\n CRM_DEALS_RESOURCE,\n CRM_FIELDS_RESOURCE,\n CRM_LEADS_RESOURCE,\n CRM_PIPELINES_RESOURCE,\n CRM_TASKS_RESOURCE,\n} from './resource-keys'\n\n/** The wizard's title for each resource. */\nexport const CRM_TRANSFER_LABELS: Readonly<Record<string, string>> = {\n [CRM_CONTACTS_RESOURCE]: 'Contacts',\n [CRM_COMPANIES_RESOURCE]: 'Companies',\n [CRM_LEADS_RESOURCE]: 'Leads',\n [CRM_DEALS_RESOURCE]: 'Deals',\n [CRM_TASKS_RESOURCE]: 'Tasks',\n [CRM_ACTIVITIES_RESOURCE]: 'Activities',\n [CRM_PIPELINES_RESOURCE]: 'Pipelines and stages',\n [CRM_FIELDS_RESOURCE]: 'Custom fields',\n}\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/transfer/ui.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 * HOW THE IMPORT WIZARD AND THE EXPORT DIALOG NAME THE CRM'S RECORDS\n * (AGL-3527, AGL-3528) — the client half of each resource, registered from the\n * console registrar, which loads where the wizard is drawn.\n *=========================================*/\n\nimport { registerPluginTransferResourceUi } from '@aglyn/aglyn/plugin-manager/plugin-transfer-resources'\nimport { lazy } from 'react'\nimport { CONTACT_CONSENT_STEP_ID } from './customer-sources'\nimport {\n CRM_ACTIVITIES_RESOURCE,\n CRM_COMPANIES_RESOURCE,\n CRM_CONTACTS_RESOURCE,\n CRM_DEALS_RESOURCE,\n CRM_FIELDS_RESOURCE,\n CRM_LEADS_RESOURCE,\n CRM_PIPELINES_RESOURCE,\n CRM_TASKS_RESOURCE,\n} from './resource-keys'\n\n/** The wizard's title for each resource. */\nexport const CRM_TRANSFER_LABELS: Readonly<Record<string, string>> = {\n [CRM_CONTACTS_RESOURCE]: 'Contacts',\n [CRM_COMPANIES_RESOURCE]: 'Companies',\n [CRM_LEADS_RESOURCE]: 'Leads',\n [CRM_DEALS_RESOURCE]: 'Deals',\n [CRM_TASKS_RESOURCE]: 'Tasks',\n [CRM_ACTIVITIES_RESOURCE]: 'Activities',\n [CRM_PIPELINES_RESOURCE]: 'Pipelines and stages',\n [CRM_FIELDS_RESOURCE]: 'Custom fields',\n}\n\n/* The contact import's Permission step (AGL-4245), loaded when the wizard reaches it. */\nconst ContactConsentStep = lazy(() =>\n import('./contact-import-steps').then((steps) => ({ default: steps.ContactConsentStep })),\n)\n\n/**\n * Registers the client half of every CRM transfer resource. The contact\n * import carries one step of its own: the statement of permission for the\n * marketing opt-ins a store's customer file records.\n */\nexport function registerCrmTransferResourceUis(pluginId: string): void {\n for (const [key, label] of Object.entries(CRM_TRANSFER_LABELS)) {\n registerPluginTransferResourceUi(\n key,\n key === CRM_CONTACTS_RESOURCE\n ? {\n label,\n extraSteps: [\n { id: CONTACT_CONSENT_STEP_ID, label: 'Permission', after: 'conflicts', component: ContactConsentStep },\n ],\n }\n : { label },\n { pluginId },\n )\n }\n}\n"],"names":["registerPluginTransferResourceUi","lazy","CONTACT_CONSENT_STEP_ID","CRM_ACTIVITIES_RESOURCE","CRM_COMPANIES_RESOURCE","CRM_CONTACTS_RESOURCE","CRM_DEALS_RESOURCE","CRM_FIELDS_RESOURCE","CRM_LEADS_RESOURCE","CRM_PIPELINES_RESOURCE","CRM_TASKS_RESOURCE","CRM_TRANSFER_LABELS","ContactConsentStep","then","steps","default","registerCrmTransferResourceUis","pluginId","key","label","Object","entries","extraSteps","id","after","component"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;2CAI2C,GAE3C,SAASA,gCAAgC,QAAQ,wDAAuD;AACxG,SAASC,IAAI,QAAQ,QAAO;AAC5B,SAASC,uBAAuB,QAAQ,wBAAoB;AAC5D,SACEC,uBAAuB,EACvBC,sBAAsB,EACtBC,qBAAqB,EACrBC,kBAAkB,EAClBC,mBAAmB,EACnBC,kBAAkB,EAClBC,sBAAsB,EACtBC,kBAAkB,QACb,qBAAiB;AAExB,0CAA0C,GAC1C,OAAO,MAAMC,sBAAwD;IACnE,CAACN,sBAAsB,EAAE;IACzB,CAACD,uBAAuB,EAAE;IAC1B,CAACI,mBAAmB,EAAE;IACtB,CAACF,mBAAmB,EAAE;IACtB,CAACI,mBAAmB,EAAE;IACtB,CAACP,wBAAwB,EAAE;IAC3B,CAACM,uBAAuB,EAAE;IAC1B,CAACF,oBAAoB,EAAE;AACzB,EAAC;AAED,uFAAuF,GACvF,MAAMK,qBAAqBX,KAAK,IAC9B,MAAM,CAAC,6BAA0BY,IAAI,CAAC,CAACC,QAAW,CAAA;YAAEC,SAASD,MAAMF,kBAAkB;QAAC,CAAA;AAGxF;;;;CAIC,GACD,OAAO,SAASI,+BAA+BC,QAAgB;IAC7D,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACV,qBAAsB;QAC9DX,iCACEkB,KACAA,QAAQb,wBACJ;YACEc;YACAG,YAAY;gBACV;oBAAEC,IAAIrB;oBAAyBiB,OAAO;oBAAcK,OAAO;oBAAaC,WAAWb;gBAAmB;aACvG;QACH,IACA;YAAEO;QAAM,GACZ;YAAEF;QAAS;IAEf;AACF"}
|