@aglyn/plugins-crm 1.0.0-beta.199 → 1.0.0-beta.201

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/package.json +13 -13
  2. package/src/lib/components/activity-list.d.ts +36 -5
  3. package/src/lib/components/activity-list.js +159 -137
  4. package/src/lib/components/activity-list.js.map +1 -1
  5. package/src/lib/components/activity-timeline.d.ts +84 -0
  6. package/src/lib/components/activity-timeline.js +224 -0
  7. package/src/lib/components/activity-timeline.js.map +1 -0
  8. package/src/lib/components/companies-section.d.ts +6 -6
  9. package/src/lib/components/companies-section.js +54 -84
  10. package/src/lib/components/companies-section.js.map +1 -1
  11. package/src/lib/components/company-edit-drawer.js +17 -4
  12. package/src/lib/components/company-edit-drawer.js.map +1 -1
  13. package/src/lib/components/company-picker.js +6 -2
  14. package/src/lib/components/company-picker.js.map +1 -1
  15. package/src/lib/components/company-properties-card.js +53 -36
  16. package/src/lib/components/company-properties-card.js.map +1 -1
  17. package/src/lib/components/contact-associations-card.d.ts +3 -2
  18. package/src/lib/components/contact-associations-card.js +12 -12
  19. package/src/lib/components/contact-associations-card.js.map +1 -1
  20. package/src/lib/components/contact-detail-page.d.ts +4 -3
  21. package/src/lib/components/contact-detail-page.js +18 -12
  22. package/src/lib/components/contact-detail-page.js.map +1 -1
  23. package/src/lib/components/contact-list-columns.d.ts +3 -5
  24. package/src/lib/components/contact-list-columns.js +6 -8
  25. package/src/lib/components/contact-list-columns.js.map +1 -1
  26. package/src/lib/components/contact-properties-card.d.ts +21 -4
  27. package/src/lib/components/contact-properties-card.js +129 -29
  28. package/src/lib/components/contact-properties-card.js.map +1 -1
  29. package/src/lib/components/contact-timeline-card.d.ts +12 -6
  30. package/src/lib/components/contact-timeline-card.js +132 -174
  31. package/src/lib/components/contact-timeline-card.js.map +1 -1
  32. package/src/lib/components/contacts-bulk-bar.js +10 -1
  33. package/src/lib/components/contacts-bulk-bar.js.map +1 -1
  34. package/src/lib/components/contacts-section.js +282 -331
  35. package/src/lib/components/contacts-section.js.map +1 -1
  36. package/src/lib/components/crm-email-state-chip.js +4 -1
  37. package/src/lib/components/crm-email-state-chip.js.map +1 -1
  38. package/src/lib/components/crm-next-activity-column.d.ts +4 -2
  39. package/src/lib/components/crm-next-activity-column.js +6 -3
  40. package/src/lib/components/crm-next-activity-column.js.map +1 -1
  41. package/src/lib/components/deal-edit-drawer.js +8 -4
  42. package/src/lib/components/deal-edit-drawer.js.map +1 -1
  43. package/src/lib/components/deal-products-card.js +15 -13
  44. package/src/lib/components/deal-products-card.js.map +1 -1
  45. package/src/lib/components/deal-properties-card.js +7 -0
  46. package/src/lib/components/deal-properties-card.js.map +1 -1
  47. package/src/lib/components/deal-stage-card.js +31 -29
  48. package/src/lib/components/deal-stage-card.js.map +1 -1
  49. package/src/lib/components/deals-section.d.ts +2 -2
  50. package/src/lib/components/deals-section.js +67 -97
  51. package/src/lib/components/deals-section.js.map +1 -1
  52. package/src/lib/components/fields-section.d.ts +4 -0
  53. package/src/lib/components/fields-section.js +368 -154
  54. package/src/lib/components/fields-section.js.map +1 -1
  55. package/src/lib/components/form-contact-fields-card.js +24 -20
  56. package/src/lib/components/form-contact-fields-card.js.map +1 -1
  57. package/src/lib/components/lead-campaigns-card.d.ts +1 -1
  58. package/src/lib/components/lead-campaigns-card.js +43 -38
  59. package/src/lib/components/lead-campaigns-card.js.map +1 -1
  60. package/src/lib/components/lead-properties-card.d.ts +14 -6
  61. package/src/lib/components/lead-properties-card.js +323 -311
  62. package/src/lib/components/lead-properties-card.js.map +1 -1
  63. package/src/lib/components/lead-surfaces-note.js +13 -2
  64. package/src/lib/components/lead-surfaces-note.js.map +1 -1
  65. package/src/lib/components/leads-bulk-bar.js +16 -3
  66. package/src/lib/components/leads-bulk-bar.js.map +1 -1
  67. package/src/lib/components/leads-section.d.ts +2 -1
  68. package/src/lib/components/leads-section.js +110 -148
  69. package/src/lib/components/leads-section.js.map +1 -1
  70. package/src/lib/components/linked-deals-card.js +12 -10
  71. package/src/lib/components/linked-deals-card.js.map +1 -1
  72. package/src/lib/components/recent-activity-feed.d.ts +12 -8
  73. package/src/lib/components/recent-activity-feed.js +54 -29
  74. package/src/lib/components/recent-activity-feed.js.map +1 -1
  75. package/src/lib/components/record-activity-card.d.ts +4 -2
  76. package/src/lib/components/record-activity-card.js +29 -11
  77. package/src/lib/components/record-activity-card.js.map +1 -1
  78. package/src/lib/components/reports/activity-card.js +18 -12
  79. package/src/lib/components/reports/activity-card.js.map +1 -1
  80. package/src/lib/components/reports/lead-funnel-card.js +47 -37
  81. package/src/lib/components/reports/lead-funnel-card.js.map +1 -1
  82. package/src/lib/components/reports/pipeline-card.js +22 -16
  83. package/src/lib/components/reports/pipeline-card.js.map +1 -1
  84. package/src/lib/components/reports/report-export.d.ts +4 -11
  85. package/src/lib/components/reports/report-export.js +16 -33
  86. package/src/lib/components/reports/report-export.js.map +1 -1
  87. package/src/lib/components/reports/source-conversion-card.js +18 -12
  88. package/src/lib/components/reports/source-conversion-card.js.map +1 -1
  89. package/src/lib/components/reports/tasks-card.js +35 -25
  90. package/src/lib/components/reports/tasks-card.js.map +1 -1
  91. package/src/lib/components/tasks-section.js +151 -144
  92. package/src/lib/components/tasks-section.js.map +1 -1
  93. package/src/lib/constants/company-filters.d.ts +13 -0
  94. package/src/lib/constants/company-filters.js +47 -17
  95. package/src/lib/constants/company-filters.js.map +1 -1
  96. package/src/lib/constants/contact-filters.d.ts +61 -10
  97. package/src/lib/constants/contact-filters.js +373 -141
  98. package/src/lib/constants/contact-filters.js.map +1 -1
  99. package/src/lib/constants/deal-filters.d.ts +44 -0
  100. package/src/lib/constants/deal-filters.js +78 -0
  101. package/src/lib/constants/deal-filters.js.map +1 -0
  102. package/src/lib/constants/field-list-query.d.ts +23 -0
  103. package/src/lib/constants/field-list-query.js +80 -0
  104. package/src/lib/constants/field-list-query.js.map +1 -0
  105. package/src/lib/hooks/use-crm-list-query.d.ts +68 -0
  106. package/src/lib/hooks/use-crm-list-query.js +182 -0
  107. package/src/lib/hooks/use-crm-list-query.js.map +1 -0
  108. package/src/lib/hooks/use-crm-tasks.d.ts +23 -6
  109. package/src/lib/hooks/use-crm-tasks.js +44 -42
  110. package/src/lib/hooks/use-crm-tasks.js.map +1 -1
  111. package/src/lib/hooks/use-deals.d.ts +2 -34
  112. package/src/lib/hooks/use-deals.js +3 -62
  113. package/src/lib/hooks/use-deals.js.map +1 -1
  114. package/src/lib/model/crm-list-query.d.ts +91 -0
  115. package/src/lib/model/crm-list-query.js +182 -0
  116. package/src/lib/model/crm-list-query.js.map +1 -0
  117. package/src/lib/model/lead-filters.d.ts +50 -44
  118. package/src/lib/model/lead-filters.js +194 -88
  119. package/src/lib/model/lead-filters.js.map +1 -1
  120. package/src/lib/model/list-fields-api.d.ts +26 -0
  121. package/src/lib/model/list-fields-api.js +47 -0
  122. package/src/lib/model/list-fields-api.js.map +1 -0
  123. package/src/lib/model/list-fields.d.ts +47 -0
  124. package/src/lib/model/list-fields.js +39 -0
  125. package/src/lib/model/list-fields.js.map +1 -0
  126. package/src/lib/model/task-views.d.ts +15 -10
  127. package/src/lib/model/task-views.js +68 -9
  128. package/src/lib/model/task-views.js.map +1 -1
  129. package/src/lib/server/capture-contact.js +7 -5
  130. package/src/lib/server/capture-contact.js.map +1 -1
  131. package/src/lib/server/companies-import.js +3 -3
  132. package/src/lib/server/companies-import.js.map +1 -1
  133. package/src/lib/server/company-delete.js +3 -1
  134. package/src/lib/server/company-delete.js.map +1 -1
  135. package/src/lib/server/consent-group-participant.js +4 -0
  136. package/src/lib/server/consent-group-participant.js.map +1 -1
  137. package/src/lib/server/contact-update.js +14 -8
  138. package/src/lib/server/contact-update.js.map +1 -1
  139. package/src/lib/server/contacts-import.js +4 -2
  140. package/src/lib/server/contacts-import.js.map +1 -1
  141. package/src/lib/server/deals-import.js +4 -2
  142. package/src/lib/server/deals-import.js.map +1 -1
  143. package/src/lib/server/erase-person.js +2 -1
  144. package/src/lib/server/erase-person.js.map +1 -1
  145. package/src/lib/server/lead-create.js +4 -1
  146. package/src/lib/server/lead-create.js.map +1 -1
  147. package/src/lib/server/lead-source-values.js +9 -5
  148. package/src/lib/server/lead-source-values.js.map +1 -1
  149. package/src/lib/server/leads-import.js +4 -1
  150. package/src/lib/server/leads-import.js.map +1 -1
  151. package/src/lib/server/list-fields-routes.d.ts +29 -0
  152. package/src/lib/server/list-fields-routes.js +85 -0
  153. package/src/lib/server/list-fields-routes.js.map +1 -0
  154. package/src/lib/server/record-email-state.js +5 -2
  155. package/src/lib/server/record-email-state.js.map +1 -1
  156. package/src/lib/server/record-timeline.js +3 -2
  157. package/src/lib/server/record-timeline.js.map +1 -1
  158. package/src/lib/server/task-routes.js +6 -3
  159. package/src/lib/server/task-routes.js.map +1 -1
  160. package/src/lib/server/tasks-import.js +5 -2
  161. package/src/lib/server/tasks-import.js.map +1 -1
  162. package/src/lib/server.js +10 -1
  163. package/src/lib/server.js.map +1 -1
  164. package/src/lib/components/contact-custom-fields-card.d.ts +0 -39
  165. package/src/lib/components/contact-custom-fields-card.js +0 -204
  166. package/src/lib/components/contact-custom-fields-card.js.map +0 -1
  167. package/src/lib/hooks/use-org-leads.d.ts +0 -50
  168. package/src/lib/hooks/use-org-leads.js +0 -104
  169. package/src/lib/hooks/use-org-leads.js.map +0 -1
@@ -1,104 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2026 Aglyn LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */ 'use client';
17
- import { _ as _extends } from "@swc/helpers/_/_extends";
18
- import { useFirestore } from "@aglyn/tenant-feature-instance";
19
- import { collection, limit, onSnapshot, orderBy, query, where } from "firebase/firestore";
20
- import { useEffect, useMemo, useState } from "react";
21
- /**
22
- * THE ORGANIZATION'S LEADS, in one listener (AGL-3275).
23
- *
24
- * This opened one listener PER SITE and merged the answers, because a lead
25
- * lived at `hosts/{hostId}/leads` — host-scoped by path, with no org-level
26
- * collection to listen to, no `orgId` on the document to group by, and no
27
- * rule admitting a collection-group read. All three of those are now false:
28
- * the collection is `orgs/{orgId}/leads` and a lead says who may see it.
29
- *
30
- * So the fan-out is gone, and with it the merge that had to cut each site's
31
- * window at `windowSize + 1` and the whole list again, so that a site with a
32
- * thousand leads could not crowd out a site with ten. One ordered query needs
33
- * neither: `truncated` is simply "the window came back full".
34
- *
35
- * `visibleTo` is the caller's, and `null` means "ask for everything" — which
36
- * is what an org-wide member's listeners do, since the rules short-circuit on
37
- * `isOrgWideMember()` and a clause would only narrow what they may already
38
- * read. A scoped member passes their tokens. See `crmVisibleToClause`, which
39
- * builds the same clause for every other CRM listener.
40
- */ export function useOrgLeads(options) {
41
- const { orgId, visibleTo, windowSize } = options;
42
- const firestore = useFirestore();
43
- const scopeKey = visibleTo ? visibleTo.join('\n') : null;
44
- const [answer, setAnswer] = useState(null);
45
- useEffect(()=>{
46
- setAnswer(null);
47
- if (!orgId) return undefined;
48
- // An `array-contains-any` over nothing is a query Firestore refuses, so a
49
- // scoped member with no tokens lists nothing rather than asking.
50
- const tokens = scopeKey === null ? null : scopeKey ? scopeKey.split('\n') : [];
51
- if (tokens && !tokens.length) {
52
- setAnswer({
53
- rows: [],
54
- truncated: false
55
- });
56
- return undefined;
57
- }
58
- const clauses = tokens ? [
59
- where('visibleTo', 'array-contains-any', tokens)
60
- ] : [];
61
- return onSnapshot(query(collection(firestore, 'orgs', orgId, 'leads'), ...clauses, orderBy('lastSeenAtMs', 'desc'), limit(windowSize + 1)), (snapshot)=>{
62
- const rows = snapshot.docs.map((entry)=>_extends({}, entry.data(), {
63
- $id: entry.id,
64
- leadId: entry.id
65
- }));
66
- setAnswer({
67
- rows: rows.slice(0, windowSize),
68
- truncated: rows.length > windowSize
69
- });
70
- }, (error)=>{
71
- console.error(error);
72
- setAnswer('error');
73
- });
74
- }, [
75
- firestore,
76
- orgId,
77
- scopeKey,
78
- windowSize
79
- ]);
80
- return useMemo(()=>{
81
- if (answer === 'error') {
82
- return {
83
- data: [],
84
- status: 'error',
85
- truncated: false
86
- };
87
- }
88
- if (!answer) return {
89
- data: [],
90
- status: 'loading',
91
- truncated: false
92
- };
93
- return {
94
- data: answer.rows,
95
- status: 'success',
96
- truncated: answer.truncated
97
- };
98
- }, [
99
- answer
100
- ]);
101
- }
102
- export default useOrgLeads;
103
-
104
- //# sourceMappingURL=use-org-leads.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/hooks/use-org-leads.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'use client'\n\nimport { useFirestore } from '@aglyn/tenant-feature-instance'\nimport {\n collection,\n limit,\n onSnapshot,\n orderBy,\n query,\n where,\n type DocumentData,\n type QueryConstraint,\n} from 'firebase/firestore'\nimport { useEffect, useMemo, useState } from 'react'\n\n/** A lead, as the organization-level list carries it. */\nexport interface OrgLeadRow extends DocumentData {\n /**\n * The grid's row id, which is the lead's own document id.\n *\n * It used to be `{hostId}/{leadId}`, because a lead lived under its site\n * and the same person on two sites was two documents with the SAME id —\n * so the id alone could not key a list spanning sites. AGL-3275 made that\n * one document, and the compound key went with it.\n */\n $id: string\n /** `orgs/{orgId}/leads/{leadId}` — the document id, a person key. */\n leadId: string\n}\n\nexport interface OrgLeadsResult {\n /** The window, ordered newest-seen first. */\n data: OrgLeadRow[]\n /** `loading` until the listener has answered once; `error` when it refused. */\n status: 'loading' | 'success' | 'error'\n /** There are leads beyond the window this list is showing. */\n truncated: boolean\n}\n\n/**\n * THE ORGANIZATION'S LEADS, in one listener (AGL-3275).\n *\n * This opened one listener PER SITE and merged the answers, because a lead\n * lived at `hosts/{hostId}/leads` — host-scoped by path, with no org-level\n * collection to listen to, no `orgId` on the document to group by, and no\n * rule admitting a collection-group read. All three of those are now false:\n * the collection is `orgs/{orgId}/leads` and a lead says who may see it.\n *\n * So the fan-out is gone, and with it the merge that had to cut each site's\n * window at `windowSize + 1` and the whole list again, so that a site with a\n * thousand leads could not crowd out a site with ten. One ordered query needs\n * neither: `truncated` is simply \"the window came back full\".\n *\n * `visibleTo` is the caller's, and `null` means \"ask for everything\" — which\n * is what an org-wide member's listeners do, since the rules short-circuit on\n * `isOrgWideMember()` and a clause would only narrow what they may already\n * read. A scoped member passes their tokens. See `crmVisibleToClause`, which\n * builds the same clause for every other CRM listener.\n */\nexport function useOrgLeads(options: {\n orgId: string | null | undefined\n /** The scope clause, or `null` for an unscoped org-wide read. */\n visibleTo: readonly string[] | null\n windowSize: number\n}): OrgLeadsResult {\n const { orgId, visibleTo, windowSize } = options\n const firestore = useFirestore()\n const scopeKey = visibleTo ? visibleTo.join('\\n') : null\n const [answer, setAnswer] = useState<\n { rows: OrgLeadRow[]; truncated: boolean } | 'error' | null\n >(null)\n\n useEffect(() => {\n setAnswer(null)\n if (!orgId) return undefined\n // An `array-contains-any` over nothing is a query Firestore refuses, so a\n // scoped member with no tokens lists nothing rather than asking.\n const tokens = scopeKey === null ? null : scopeKey ? scopeKey.split('\\n') : []\n if (tokens && !tokens.length) {\n setAnswer({ rows: [], truncated: false })\n return undefined\n }\n const clauses: QueryConstraint[] = tokens\n ? [where('visibleTo', 'array-contains-any', tokens)]\n : []\n return onSnapshot(\n query(\n collection(firestore, 'orgs', orgId, 'leads'),\n ...clauses,\n orderBy('lastSeenAtMs', 'desc'),\n limit(windowSize + 1),\n ),\n (snapshot) => {\n const rows = snapshot.docs.map((entry) => ({\n ...(entry.data() as DocumentData),\n $id: entry.id,\n leadId: entry.id,\n }))\n setAnswer({\n rows: rows.slice(0, windowSize),\n truncated: rows.length > windowSize,\n })\n },\n (error) => {\n console.error(error)\n setAnswer('error')\n },\n )\n }, [firestore, orgId, scopeKey, windowSize])\n\n return useMemo(() => {\n if (answer === 'error') {\n return { data: [], status: 'error' as const, truncated: false }\n }\n if (!answer) return { data: [], status: 'loading' as const, truncated: false }\n return {\n data: answer.rows,\n status: 'success' as const,\n truncated: answer.truncated,\n }\n }, [answer])\n}\n\nexport default useOrgLeads\n"],"names":["useFirestore","collection","limit","onSnapshot","orderBy","query","where","useEffect","useMemo","useState","useOrgLeads","options","orgId","visibleTo","windowSize","firestore","scopeKey","join","answer","setAnswer","undefined","tokens","split","length","rows","truncated","clauses","snapshot","docs","map","entry","data","$id","id","leadId","slice","error","console","status"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,YAAY,QAAQ,iCAAgC;AAC7D,SACEC,UAAU,EACVC,KAAK,EACLC,UAAU,EACVC,OAAO,EACPC,KAAK,EACLC,KAAK,QAGA,qBAAoB;AAC3B,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AA0BpD;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASC,YAAYC,OAK3B;IACC,MAAM,EAAEC,KAAK,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGH;IACzC,MAAMI,YAAYf;IAClB,MAAMgB,WAAWH,YAAYA,UAAUI,IAAI,CAAC,QAAQ;IACpD,MAAM,CAACC,QAAQC,UAAU,GAAGV,SAE1B;IAEFF,UAAU;QACRY,UAAU;QACV,IAAI,CAACP,OAAO,OAAOQ;QACnB,0EAA0E;QAC1E,iEAAiE;QACjE,MAAMC,SAASL,aAAa,OAAO,OAAOA,WAAWA,SAASM,KAAK,CAAC,QAAQ,EAAE;QAC9E,IAAID,UAAU,CAACA,OAAOE,MAAM,EAAE;YAC5BJ,UAAU;gBAAEK,MAAM,EAAE;gBAAEC,WAAW;YAAM;YACvC,OAAOL;QACT;QACA,MAAMM,UAA6BL,SAC/B;YAACf,MAAM,aAAa,sBAAsBe;SAAQ,GAClD,EAAE;QACN,OAAOlB,WACLE,MACEJ,WAAWc,WAAW,QAAQH,OAAO,aAClCc,SACHtB,QAAQ,gBAAgB,SACxBF,MAAMY,aAAa,KAErB,CAACa;YACC,MAAMH,OAAOG,SAASC,IAAI,CAACC,GAAG,CAAC,CAACC,QAAW,aACrCA,MAAMC,IAAI;oBACdC,KAAKF,MAAMG,EAAE;oBACbC,QAAQJ,MAAMG,EAAE;;YAElBd,UAAU;gBACRK,MAAMA,KAAKW,KAAK,CAAC,GAAGrB;gBACpBW,WAAWD,KAAKD,MAAM,GAAGT;YAC3B;QACF,GACA,CAACsB;YACCC,QAAQD,KAAK,CAACA;YACdjB,UAAU;QACZ;IAEJ,GAAG;QAACJ;QAAWH;QAAOI;QAAUF;KAAW;IAE3C,OAAON,QAAQ;QACb,IAAIU,WAAW,SAAS;YACtB,OAAO;gBAAEa,MAAM,EAAE;gBAAEO,QAAQ;gBAAkBb,WAAW;YAAM;QAChE;QACA,IAAI,CAACP,QAAQ,OAAO;YAAEa,MAAM,EAAE;YAAEO,QAAQ;YAAoBb,WAAW;QAAM;QAC7E,OAAO;YACLM,MAAMb,OAAOM,IAAI;YACjBc,QAAQ;YACRb,WAAWP,OAAOO,SAAS;QAC7B;IACF,GAAG;QAACP;KAAO;AACb;AAEA,eAAeR,YAAW"}