@aglyn/plugins-crm 1.26.6 → 1.28.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 +14 -14
- package/src/lib/native-nav.js +9 -3
- package/src/lib/native-nav.js.map +1 -1
- package/src/lib/server/api-v1/contacts.js +35 -8
- package/src/lib/server/api-v1/contacts.js.map +1 -1
- package/src/lib/server/api-v1/crm-activities.js +1 -1
- package/src/lib/server/api-v1/crm-activities.js.map +1 -1
- package/src/lib/server/api-v1/crm-companies.js +1 -1
- package/src/lib/server/api-v1/crm-companies.js.map +1 -1
- package/src/lib/server/api-v1/crm-deals.js +1 -1
- package/src/lib/server/api-v1/crm-deals.js.map +1 -1
- package/src/lib/server/api-v1/crm-email-templates.js +1 -1
- package/src/lib/server/api-v1/crm-email-templates.js.map +1 -1
- package/src/lib/server/api-v1/crm-leads.js +25 -12
- package/src/lib/server/api-v1/crm-leads.js.map +1 -1
- package/src/lib/server/api-v1/crm-shared.d.ts +8 -2
- package/src/lib/server/api-v1/crm-shared.js +12 -2
- package/src/lib/server/api-v1/crm-shared.js.map +1 -1
- package/src/lib/server/api-v1/crm-tasks.js +1 -1
- package/src/lib/server/api-v1/crm-tasks.js.map +1 -1
- package/src/lib/server/api-v1/openapi.js +2 -0
- package/src/lib/server/api-v1/openapi.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-crm",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,19 +25,19 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.
|
|
29
|
-
"@aglyn/shared-data-enums": "1.
|
|
30
|
-
"@aglyn/shared-data-mdi": "1.
|
|
31
|
-
"@aglyn/shared-ui-jsx": "1.
|
|
32
|
-
"@aglyn/shared-ui-next": "1.
|
|
33
|
-
"@aglyn/shared-ui-snackstack": "1.
|
|
34
|
-
"@aglyn/shared-util-email": "1.
|
|
35
|
-
"@aglyn/shared-util-http": "1.
|
|
36
|
-
"@aglyn/shared-util-timestamp": "1.
|
|
37
|
-
"@aglyn/shared-util-tools": "1.
|
|
38
|
-
"@aglyn/tenant-data-admin": "1.
|
|
39
|
-
"@aglyn/tenant-feature-instance": "1.
|
|
40
|
-
"@aglyn/tenant-runtime": "1.
|
|
28
|
+
"@aglyn/aglyn": "1.28.0",
|
|
29
|
+
"@aglyn/shared-data-enums": "1.28.0",
|
|
30
|
+
"@aglyn/shared-data-mdi": "1.28.0",
|
|
31
|
+
"@aglyn/shared-ui-jsx": "1.28.0",
|
|
32
|
+
"@aglyn/shared-ui-next": "1.28.0",
|
|
33
|
+
"@aglyn/shared-ui-snackstack": "1.28.0",
|
|
34
|
+
"@aglyn/shared-util-email": "1.28.0",
|
|
35
|
+
"@aglyn/shared-util-http": "1.28.0",
|
|
36
|
+
"@aglyn/shared-util-timestamp": "1.28.0",
|
|
37
|
+
"@aglyn/shared-util-tools": "1.28.0",
|
|
38
|
+
"@aglyn/tenant-data-admin": "1.28.0",
|
|
39
|
+
"@aglyn/tenant-feature-instance": "1.28.0",
|
|
40
|
+
"@aglyn/tenant-runtime": "1.28.0",
|
|
41
41
|
"@dnd-kit/core": "^6.3.1",
|
|
42
42
|
"@dnd-kit/utilities": "^3.2.2",
|
|
43
43
|
"@swc/helpers": "0.5.24",
|
package/src/lib/native-nav.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
1
2
|
/**
|
|
2
3
|
* @license
|
|
3
4
|
* Copyright 2026 Aglyn LLC
|
|
@@ -26,12 +27,17 @@
|
|
|
26
27
|
* (`orgNavItems`, `/[orgSlug]/crm`), the site's the site's hub; both list
|
|
27
28
|
* the same sections under the same ids.
|
|
28
29
|
*/ function row(scope, order) {
|
|
29
|
-
return {
|
|
30
|
+
return _extends({
|
|
30
31
|
id: 'crm',
|
|
31
32
|
label: 'CRM',
|
|
32
33
|
icon: nativeNavIcon('person.text.rectangle', 'contact_mail'),
|
|
33
34
|
screen: 'crm.contacts',
|
|
34
|
-
pluginId: 'crm'
|
|
35
|
+
pluginId: 'crm'
|
|
36
|
+
}, scope === 'org' ? {
|
|
37
|
+
permissions: [
|
|
38
|
+
'data.manage'
|
|
39
|
+
]
|
|
40
|
+
} : {}, {
|
|
35
41
|
order,
|
|
36
42
|
keywords: [
|
|
37
43
|
'contacts',
|
|
@@ -51,7 +57,7 @@
|
|
|
51
57
|
],
|
|
52
58
|
docs: scope === 'org' ? '/content-and-data/crm/overview#at-the-organization-level' : '/content-and-data/crm/overview',
|
|
53
59
|
console: nativeNavRef(scope === 'org' ? 'orgPluginTab' : 'hostPluginTab', '/crm')
|
|
54
|
-
};
|
|
60
|
+
});
|
|
55
61
|
}
|
|
56
62
|
export const NATIVE_NAV_ROWS = [
|
|
57
63
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/plugins/crm/src/lib/native-nav.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 {\n type NativeNavContribution,\n type NativeNavCreateContribution,\n type NativeNavRow,\n nativeNavHubSection,\n nativeNavIcon,\n nativeNavRef,\n} from '@aglyn/aglyn/app-utils/native-nav'\n\n/**\n * The CRM in the native apps' navigation (AGL-3943): the rows this plugin\n * adds to the manifest the shells draw, placed into the core's lists by\n * `order` (`assembleNativeNav`, `generate:native-contracts`). Labels are the\n * console's words, held by `apps/console/specs/native-nav-manifest.spec.ts`.\n *\n * Imports only the core's plain nav module, so the native contracts read it.\n */\n\n/**\n * The row at either scope. The workspace's opens the console's org page\n * (`orgNavItems`, `/[orgSlug]/crm`), the site's the site's hub; both list\n * the same sections under the same ids.\n */\nfunction row(scope: 'org' | 'host', order: number): NativeNavRow {\n return {\n id: 'crm',\n label: 'CRM',\n icon: nativeNavIcon('person.text.rectangle', 'contact_mail'),\n screen: 'crm.contacts',\n pluginId: 'crm',\n order,\n keywords: ['contacts', 'people', 'deals', 'tasks'],\n sections: [\n nativeNavHubSection(scope, '/crm', 'contacts', 'Contacts', 'crm.contacts'),\n nativeNavHubSection(scope, '/crm', 'leads', 'Leads', 'crm.leads'),\n nativeNavHubSection(scope, '/crm', 'companies', 'Companies', 'crm.companies'),\n nativeNavHubSection(scope, '/crm', 'deals', 'Deals / Opportunities', 'crm.deals'),\n nativeNavHubSection(scope, '/crm', 'tasks', 'Tasks', 'crm.tasks'),\n nativeNavHubSection(scope, '/crm', 'reports', 'Reports', 'crm.reports'),\n nativeNavHubSection(scope, '/crm', 'fields', 'Fields', 'crm.fields'),\n nativeNavHubSection(scope, '/crm', 'settings', 'Settings', 'crm.settings'),\n ],\n docs: scope === 'org' ? '/content-and-data/crm/overview#at-the-organization-level' : '/content-and-data/crm/overview',\n console: nativeNavRef(scope === 'org' ? 'orgPluginTab' : 'hostPluginTab', '/crm'),\n }\n}\n\nexport const NATIVE_NAV_ROWS: readonly NativeNavContribution[] = [\n { list: 'workspace', group: 'workspace', row: row('org', 20) },\n { list: 'site', group: 'customers', row: row('host', 20) },\n]\n\n/** A contact, at either scope: the console's \"New contact\" on the CRM's Contacts. */\nfunction contact(scope: 'org' | 'host', order: number): NativeNavCreateContribution['item'] {\n return {\n id: 'contact',\n label: 'Contact',\n icon: nativeNavIcon('person.badge.plus', 'person_add'),\n screen: 'crm.contacts',\n params: { new: '1' },\n pluginId: 'crm',\n permission: 'data.manage',\n planFeature: 'crm',\n order,\n console: nativeNavRef(scope === 'org' ? 'orgPluginSection' : 'hostPluginSection', '/crm/contacts'),\n }\n}\n\nexport const NATIVE_NAV_CREATE: readonly NativeNavCreateContribution[] = [\n { scope: 'workspace', item: contact('org', 20) },\n { scope: 'site', item: contact('host', 70) },\n]\n"],"names":["nativeNavHubSection","nativeNavIcon","nativeNavRef","row","scope","order","id","label","icon","screen","pluginId","keywords","sections","docs","console","NATIVE_NAV_ROWS","list","group","contact","params","new","permission","planFeature","NATIVE_NAV_CREATE","item"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAIEA,mBAAmB,EACnBC,aAAa,EACbC,YAAY,QACP,oCAAmC;AAE1C;;;;;;;CAOC,GAED;;;;CAIC,GACD,SAASC,IAAIC,KAAqB,EAAEC,KAAa;IAC/C,OAAO;QACLC,IAAI;QACJC,OAAO;QACPC,MAAMP,cAAc,yBAAyB;QAC7CQ,QAAQ;QACRC,UAAU;
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/plugins/crm/src/lib/native-nav.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 {\n type NativeNavContribution,\n type NativeNavCreateContribution,\n type NativeNavRow,\n nativeNavHubSection,\n nativeNavIcon,\n nativeNavRef,\n} from '@aglyn/aglyn/app-utils/native-nav'\n\n/**\n * The CRM in the native apps' navigation (AGL-3943): the rows this plugin\n * adds to the manifest the shells draw, placed into the core's lists by\n * `order` (`assembleNativeNav`, `generate:native-contracts`). Labels are the\n * console's words, held by `apps/console/specs/native-nav-manifest.spec.ts`.\n *\n * Imports only the core's plain nav module, so the native contracts read it.\n */\n\n/**\n * The row at either scope. The workspace's opens the console's org page\n * (`orgNavItems`, `/[orgSlug]/crm`), the site's the site's hub; both list\n * the same sections under the same ids.\n */\nfunction row(scope: 'org' | 'host', order: number): NativeNavRow {\n return {\n id: 'crm',\n label: 'CRM',\n icon: nativeNavIcon('person.text.rectangle', 'contact_mail'),\n screen: 'crm.contacts',\n pluginId: 'crm',\n // The org tab strip asks the extension's permission (plugin.ts).\n ...(scope === 'org' ? { permissions: ['data.manage'] } : {}),\n order,\n keywords: ['contacts', 'people', 'deals', 'tasks'],\n sections: [\n nativeNavHubSection(scope, '/crm', 'contacts', 'Contacts', 'crm.contacts'),\n nativeNavHubSection(scope, '/crm', 'leads', 'Leads', 'crm.leads'),\n nativeNavHubSection(scope, '/crm', 'companies', 'Companies', 'crm.companies'),\n nativeNavHubSection(scope, '/crm', 'deals', 'Deals / Opportunities', 'crm.deals'),\n nativeNavHubSection(scope, '/crm', 'tasks', 'Tasks', 'crm.tasks'),\n nativeNavHubSection(scope, '/crm', 'reports', 'Reports', 'crm.reports'),\n nativeNavHubSection(scope, '/crm', 'fields', 'Fields', 'crm.fields'),\n nativeNavHubSection(scope, '/crm', 'settings', 'Settings', 'crm.settings'),\n ],\n docs: scope === 'org' ? '/content-and-data/crm/overview#at-the-organization-level' : '/content-and-data/crm/overview',\n console: nativeNavRef(scope === 'org' ? 'orgPluginTab' : 'hostPluginTab', '/crm'),\n }\n}\n\nexport const NATIVE_NAV_ROWS: readonly NativeNavContribution[] = [\n { list: 'workspace', group: 'workspace', row: row('org', 20) },\n { list: 'site', group: 'customers', row: row('host', 20) },\n]\n\n/** A contact, at either scope: the console's \"New contact\" on the CRM's Contacts. */\nfunction contact(scope: 'org' | 'host', order: number): NativeNavCreateContribution['item'] {\n return {\n id: 'contact',\n label: 'Contact',\n icon: nativeNavIcon('person.badge.plus', 'person_add'),\n screen: 'crm.contacts',\n params: { new: '1' },\n pluginId: 'crm',\n permission: 'data.manage',\n planFeature: 'crm',\n order,\n console: nativeNavRef(scope === 'org' ? 'orgPluginSection' : 'hostPluginSection', '/crm/contacts'),\n }\n}\n\nexport const NATIVE_NAV_CREATE: readonly NativeNavCreateContribution[] = [\n { scope: 'workspace', item: contact('org', 20) },\n { scope: 'site', item: contact('host', 70) },\n]\n"],"names":["nativeNavHubSection","nativeNavIcon","nativeNavRef","row","scope","order","id","label","icon","screen","pluginId","permissions","keywords","sections","docs","console","NATIVE_NAV_ROWS","list","group","contact","params","new","permission","planFeature","NATIVE_NAV_CREATE","item"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAIEA,mBAAmB,EACnBC,aAAa,EACbC,YAAY,QACP,oCAAmC;AAE1C;;;;;;;CAOC,GAED;;;;CAIC,GACD,SAASC,IAAIC,KAAqB,EAAEC,KAAa;IAC/C,OAAO;QACLC,IAAI;QACJC,OAAO;QACPC,MAAMP,cAAc,yBAAyB;QAC7CQ,QAAQ;QACRC,UAAU;OAENN,UAAU,QAAQ;QAAEO,aAAa;YAAC;SAAc;IAAC,IAAI,CAAC;QAC1DN;QACAO,UAAU;YAAC;YAAY;YAAU;YAAS;SAAQ;QAClDC,UAAU;YACRb,oBAAoBI,OAAO,QAAQ,YAAY,YAAY;YAC3DJ,oBAAoBI,OAAO,QAAQ,SAAS,SAAS;YACrDJ,oBAAoBI,OAAO,QAAQ,aAAa,aAAa;YAC7DJ,oBAAoBI,OAAO,QAAQ,SAAS,yBAAyB;YACrEJ,oBAAoBI,OAAO,QAAQ,SAAS,SAAS;YACrDJ,oBAAoBI,OAAO,QAAQ,WAAW,WAAW;YACzDJ,oBAAoBI,OAAO,QAAQ,UAAU,UAAU;YACvDJ,oBAAoBI,OAAO,QAAQ,YAAY,YAAY;SAC5D;QACDU,MAAMV,UAAU,QAAQ,6DAA6D;QACrFW,SAASb,aAAaE,UAAU,QAAQ,iBAAiB,iBAAiB;;AAE9E;AAEA,OAAO,MAAMY,kBAAoD;IAC/D;QAAEC,MAAM;QAAaC,OAAO;QAAaf,KAAKA,IAAI,OAAO;IAAI;IAC7D;QAAEc,MAAM;QAAQC,OAAO;QAAaf,KAAKA,IAAI,QAAQ;IAAI;CAC1D,CAAA;AAED,mFAAmF,GACnF,SAASgB,QAAQf,KAAqB,EAAEC,KAAa;IACnD,OAAO;QACLC,IAAI;QACJC,OAAO;QACPC,MAAMP,cAAc,qBAAqB;QACzCQ,QAAQ;QACRW,QAAQ;YAAEC,KAAK;QAAI;QACnBX,UAAU;QACVY,YAAY;QACZC,aAAa;QACblB;QACAU,SAASb,aAAaE,UAAU,QAAQ,qBAAqB,qBAAqB;IACpF;AACF;AAEA,OAAO,MAAMoB,oBAA4D;IACvE;QAAEpB,OAAO;QAAaqB,MAAMN,QAAQ,OAAO;IAAI;IAC/C;QAAEf,OAAO;QAAQqB,MAAMN,QAAQ,QAAQ;IAAI;CAC5C,CAAA"}
|
|
@@ -17,7 +17,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
17
17
|
*/ import { nameSearchFields } from "@aglyn/aglyn/app-utils/name-search";
|
|
18
18
|
import { CAPTURED_BY_HOST_FIELD, composeContactName, CONTACT_BIRTHDATE_REFUSAL, CONTACT_COMPANY_IDS_FIELD, CONTACT_EXTRA_PHONE_FIELDS, CONTACT_FACETS_FIELD, ORG_CONTACT_HOLDER_ID, CONTACT_FIELDS_MAX_PER_ORG, CONTACT_LIFECYCLE_STAGES, CONTACT_NAME_PART_MAX, consentGroupForHost, crmDefaultScopeOf, crmScopeTokens, contactFacetPath, createResourceUid, CRM_COLLECTIONS, CRM_LEAD_SOURCE_PICKLIST, CRM_MEDIA_IDS_MAX, CRM_SALUTATION_PICKLIST, isContactLifecycleStage, judgeCrmPicklistValue, MARKETING_CONSENT_BY_HOST_FIELD, marketingConsentFieldsForGroup, marketingConsentHostIds, normalizeAddress, normalizeContactBirthdate, normalizeContactEmail, normalizeCrmMediaIds, normalizePhone, ORG_SCOPE_TOKEN, planContactCompanyLink, readContactCompanyLink, readContactCustomInput, readContactFacet, soloConsentGroup, crmRecordsRefusalMessage } from "@aglyn/aglyn/server";
|
|
19
19
|
import { ApiErrors, apiJson, contactCompanyMirrorValue, crmRecordsQuotaForOrg, listResponse, restampCrmListFieldsAt, settleCompanyContactsCounts } from "@aglyn/tenant-data-admin";
|
|
20
|
-
import { claimWrite, orgOwnsHost, paginate, readJsonBody, requireScope, serialize } from "@aglyn/tenant-data-admin/server/api-v1-kit";
|
|
20
|
+
import { admitNamedSite, claimWrite, orgOwnsHost, paginate, readJsonBody, requireScope, serialize } from "@aglyn/tenant-data-admin/server/api-v1-kit";
|
|
21
21
|
// The leaf, so a spec that stands a partial barrel in still reaches it.
|
|
22
22
|
import { scheduleCapturedEmailCheck } from "@aglyn/tenant-data-admin/server/capture-email-check";
|
|
23
23
|
// The leaf, not the barrel: the console's API specs substitute the barrel
|
|
@@ -650,12 +650,27 @@ function readContactInput(body, { partial }) {
|
|
|
650
650
|
link
|
|
651
651
|
};
|
|
652
652
|
}
|
|
653
|
+
/**
|
|
654
|
+
* The site a contact call names through `consentSiteId`, admitted the way
|
|
655
|
+
* the site router admits one in its path (AGL-4235, `admitNamedSite`): after
|
|
656
|
+
* the workspace-ownership check each caller already makes, a connected app
|
|
657
|
+
* whose person is not on the site hears `404 No such site`, and the site's
|
|
658
|
+
* own lock decides by the request's method. `null` to proceed.
|
|
659
|
+
*
|
|
660
|
+
* Asked of the writes too, though the contact itself is the workspace's:
|
|
661
|
+
* the console records a site as where consent was given only for a person
|
|
662
|
+
* whose access reaches that site (`crm/contacts-create`,
|
|
663
|
+
* `crm/contact-update`), so an app may not record one its person could not.
|
|
664
|
+
*/ async function consentSiteRefusal(ctx, request, siteId) {
|
|
665
|
+
const admitted = await admitNamedSite(ctx, request, siteId);
|
|
666
|
+
return 'snapshot' in admitted ? null : admitted;
|
|
667
|
+
}
|
|
653
668
|
/**
|
|
654
669
|
* The holder a contact READ is for, from `?consentSiteId=`: that site's
|
|
655
670
|
* consent group, or `null` for the union view. The parameter the writes take,
|
|
656
671
|
* validated the same way, so a client has one name for "which site" on every
|
|
657
|
-
* contact call.
|
|
658
|
-
*/ function contactViewGroup(ctx, url) {
|
|
672
|
+
* contact call — and admitted the same way ({@link consentSiteRefusal}).
|
|
673
|
+
*/ async function contactViewGroup(ctx, request, url) {
|
|
659
674
|
var _url_searchParams_get;
|
|
660
675
|
const siteId = ((_url_searchParams_get = url.searchParams.get('consentSiteId')) != null ? _url_searchParams_get : '').trim();
|
|
661
676
|
if (!siteId) return {
|
|
@@ -673,6 +688,10 @@ function readContactInput(body, { partial }) {
|
|
|
673
688
|
})
|
|
674
689
|
};
|
|
675
690
|
}
|
|
691
|
+
const refused = await consentSiteRefusal(ctx, request, siteId);
|
|
692
|
+
if (refused) return {
|
|
693
|
+
response: refused
|
|
694
|
+
};
|
|
676
695
|
return {
|
|
677
696
|
groupId: consentGroupForHost(ctx.org, siteId).groupId
|
|
678
697
|
};
|
|
@@ -761,6 +780,10 @@ const contactsCollection = (ctx)=>ctx.firestore.collection('orgs').doc(ctx.orgId
|
|
|
761
780
|
headers: ctx.headers
|
|
762
781
|
});
|
|
763
782
|
}
|
|
783
|
+
if (consentSiteId) {
|
|
784
|
+
const refused = await consentSiteRefusal(ctx, request, consentSiteId);
|
|
785
|
+
if (refused) return refused;
|
|
786
|
+
}
|
|
764
787
|
/*
|
|
765
788
|
* Who may see the new contact: the whole org, unless the org keeps each
|
|
766
789
|
* site's records apart — then the named site's group, and a contact named
|
|
@@ -953,6 +976,10 @@ const contactsCollection = (ctx)=>ctx.firestore.collection('orgs').doc(ctx.orgId
|
|
|
953
976
|
headers: ctx.headers
|
|
954
977
|
});
|
|
955
978
|
}
|
|
979
|
+
if (consentSiteId) {
|
|
980
|
+
const refused = await consentSiteRefusal(ctx, request, consentSiteId);
|
|
981
|
+
if (refused) return refused;
|
|
982
|
+
}
|
|
956
983
|
const crmErrors = await contactCrmRefErrors(ctx, crm, {
|
|
957
984
|
contactId: contactRef.id,
|
|
958
985
|
siteId: consentSiteId,
|
|
@@ -1157,7 +1184,7 @@ const contactsCollection = (ctx)=>ctx.firestore.collection('orgs').doc(ctx.orgId
|
|
|
1157
1184
|
* therefore come back empty with `has_more` false, which is the short-page
|
|
1158
1185
|
* case `conventions.md` already tells clients to expect and which
|
|
1159
1186
|
* `?channel=online` on orders already produces.
|
|
1160
|
-
*/ async function listContacts(ctx, collection, url) {
|
|
1187
|
+
*/ async function listContacts(request, ctx, collection, url) {
|
|
1161
1188
|
var _url_searchParams_get, _url_searchParams_get1, _url_searchParams_get2;
|
|
1162
1189
|
const rawEmail = url.searchParams.get('email');
|
|
1163
1190
|
let email = null;
|
|
@@ -1203,7 +1230,7 @@ const contactsCollection = (ctx)=>ctx.firestore.collection('orgs').doc(ctx.orgId
|
|
|
1203
1230
|
const lifecycleStage = rawStage || null;
|
|
1204
1231
|
const ownerUid = ((_url_searchParams_get1 = url.searchParams.get('ownerUid')) != null ? _url_searchParams_get1 : '').trim().slice(0, CONTACT_NAME_MAX) || null;
|
|
1205
1232
|
const companyId = ((_url_searchParams_get2 = url.searchParams.get('companyId')) != null ? _url_searchParams_get2 : '').trim().slice(0, CRM_ID_MAX) || null;
|
|
1206
|
-
const group = contactViewGroup(ctx, url);
|
|
1233
|
+
const group = await contactViewGroup(ctx, request, url);
|
|
1207
1234
|
if ('response' in group) return group.response;
|
|
1208
1235
|
// ONE selector, the most selective that was given: the unique email, then
|
|
1209
1236
|
// the company, then the tag. Every other filter is checked on the page.
|
|
@@ -1255,7 +1282,7 @@ export async function handleContacts(request, ctx, segments, url) {
|
|
|
1255
1282
|
if (request.method === 'GET') {
|
|
1256
1283
|
const denied = requireScope(ctx, 'contacts:read');
|
|
1257
1284
|
if (denied) return denied;
|
|
1258
|
-
return listContacts(ctx, collection, url);
|
|
1285
|
+
return listContacts(request, ctx, collection, url);
|
|
1259
1286
|
}
|
|
1260
1287
|
if (request.method === 'POST') {
|
|
1261
1288
|
const denied = requireScope(ctx, 'contacts:write');
|
|
@@ -1281,14 +1308,14 @@ export async function handleContacts(request, ctx, segments, url) {
|
|
|
1281
1308
|
}
|
|
1282
1309
|
const denied = requireScope(ctx, 'contacts:write');
|
|
1283
1310
|
if (denied) return denied;
|
|
1284
|
-
const group = contactViewGroup(ctx, url);
|
|
1311
|
+
const group = await contactViewGroup(ctx, request, url);
|
|
1285
1312
|
if ('response' in group) return group.response;
|
|
1286
1313
|
return mergeContactRoute(request, ctx, contactRef, (snap)=>contactView(snap, group.groupId));
|
|
1287
1314
|
}
|
|
1288
1315
|
if (request.method === 'GET') {
|
|
1289
1316
|
const denied = requireScope(ctx, 'contacts:read');
|
|
1290
1317
|
if (denied) return denied;
|
|
1291
|
-
const group = contactViewGroup(ctx, url);
|
|
1318
|
+
const group = await contactViewGroup(ctx, request, url);
|
|
1292
1319
|
if ('response' in group) return group.response;
|
|
1293
1320
|
const snap = await contactRef.get();
|
|
1294
1321
|
if (!snap.exists) {
|