@aglyn/plugins-crm 1.0.0-beta.221 → 1.0.0-beta.223

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 (541) hide show
  1. package/README.md +2 -1
  2. package/package.json +13 -13
  3. package/src/lib/components/activity-list.js +12 -5
  4. package/src/lib/components/activity-list.js.map +1 -1
  5. package/src/lib/components/companies-bulk-bar.d.ts +1 -4
  6. package/src/lib/components/companies-bulk-bar.js +7 -20
  7. package/src/lib/components/companies-bulk-bar.js.map +1 -1
  8. package/src/lib/components/companies-section.d.ts +3 -3
  9. package/src/lib/components/companies-section.js +149 -46
  10. package/src/lib/components/companies-section.js.map +1 -1
  11. package/src/lib/components/company-edit-drawer.js +281 -20
  12. package/src/lib/components/company-edit-drawer.js.map +1 -1
  13. package/src/lib/components/company-properties-card.js +99 -8
  14. package/src/lib/components/company-properties-card.js.map +1 -1
  15. package/src/lib/components/contact-detail-page.js +3 -1
  16. package/src/lib/components/contact-detail-page.js.map +1 -1
  17. package/src/lib/components/contact-merge-dialog.js +33 -10
  18. package/src/lib/components/contact-merge-dialog.js.map +1 -1
  19. package/src/lib/components/contact-properties-card.d.ts +0 -69
  20. package/src/lib/components/contact-properties-card.js +350 -60
  21. package/src/lib/components/contact-properties-card.js.map +1 -1
  22. package/src/lib/components/contact-reports-to-field.d.ts +46 -0
  23. package/src/lib/components/contact-reports-to-field.js +67 -0
  24. package/src/lib/components/contact-reports-to-field.js.map +1 -0
  25. package/src/lib/components/contacts-bulk-bar.d.ts +1 -8
  26. package/src/lib/components/contacts-bulk-bar.js +7 -19
  27. package/src/lib/components/contacts-bulk-bar.js.map +1 -1
  28. package/src/lib/components/contacts-section.js +46 -33
  29. package/src/lib/components/contacts-section.js.map +1 -1
  30. package/src/lib/components/crm-call-actions.d.ts +10 -0
  31. package/src/lib/components/crm-call-actions.js +26 -9
  32. package/src/lib/components/crm-call-actions.js.map +1 -1
  33. package/src/lib/components/crm-next-activity-column.js +1 -1
  34. package/src/lib/components/crm-next-activity-column.js.map +1 -1
  35. package/src/lib/components/crm-record-picker.d.ts +15 -0
  36. package/src/lib/components/crm-record-picker.js +16 -10
  37. package/src/lib/components/crm-record-picker.js.map +1 -1
  38. package/src/lib/components/crm-transfer-buttons.d.ts +54 -0
  39. package/src/lib/components/crm-transfer-buttons.js +167 -0
  40. package/src/lib/components/crm-transfer-buttons.js.map +1 -0
  41. package/src/lib/components/deal-contact-roles-card.d.ts +46 -0
  42. package/src/lib/components/deal-contact-roles-card.js +368 -0
  43. package/src/lib/components/deal-contact-roles-card.js.map +1 -0
  44. package/src/lib/components/deal-detail-page.d.ts +3 -2
  45. package/src/lib/components/deal-detail-page.js +25 -6
  46. package/src/lib/components/deal-detail-page.js.map +1 -1
  47. package/src/lib/components/deal-edit-drawer.d.ts +10 -0
  48. package/src/lib/components/deal-edit-drawer.js +219 -10
  49. package/src/lib/components/deal-edit-drawer.js.map +1 -1
  50. package/src/lib/components/deal-properties-card.d.ts +7 -0
  51. package/src/lib/components/deal-properties-card.js +34 -3
  52. package/src/lib/components/deal-properties-card.js.map +1 -1
  53. package/src/lib/components/deal-stage-card.d.ts +4 -0
  54. package/src/lib/components/deal-stage-card.js +10 -2
  55. package/src/lib/components/deal-stage-card.js.map +1 -1
  56. package/src/lib/components/deals-bulk-bar.d.ts +0 -3
  57. package/src/lib/components/deals-bulk-bar.js +7 -20
  58. package/src/lib/components/deals-bulk-bar.js.map +1 -1
  59. package/src/lib/components/deals-section.d.ts +3 -3
  60. package/src/lib/components/deals-section.js +123 -63
  61. package/src/lib/components/deals-section.js.map +1 -1
  62. package/src/lib/components/fields-section.js +31 -17
  63. package/src/lib/components/fields-section.js.map +1 -1
  64. package/src/lib/components/lead-convert-dialog.d.ts +4 -0
  65. package/src/lib/components/lead-convert-dialog.js +23 -1
  66. package/src/lib/components/lead-convert-dialog.js.map +1 -1
  67. package/src/lib/components/lead-detail-page.js +8 -2
  68. package/src/lib/components/lead-detail-page.js.map +1 -1
  69. package/src/lib/components/lead-profile-fields.d.ts +71 -0
  70. package/src/lib/components/lead-profile-fields.js +386 -0
  71. package/src/lib/components/lead-profile-fields.js.map +1 -0
  72. package/src/lib/components/lead-properties-card.d.ts +2 -1
  73. package/src/lib/components/lead-properties-card.js +85 -176
  74. package/src/lib/components/lead-properties-card.js.map +1 -1
  75. package/src/lib/components/lead-source-select.d.ts +4 -23
  76. package/src/lib/components/lead-source-select.js +9 -73
  77. package/src/lib/components/lead-source-select.js.map +1 -1
  78. package/src/lib/components/lead-status-chip.d.ts +9 -3
  79. package/src/lib/components/lead-status-chip.js +8 -4
  80. package/src/lib/components/lead-status-chip.js.map +1 -1
  81. package/src/lib/components/lead-status-options.d.ts +20 -0
  82. package/src/lib/components/lead-status-options.js +51 -0
  83. package/src/lib/components/lead-status-options.js.map +1 -0
  84. package/src/lib/components/lead-unqualify-dialog.d.ts +5 -0
  85. package/src/lib/components/lead-unqualify-dialog.js +50 -18
  86. package/src/lib/components/lead-unqualify-dialog.js.map +1 -1
  87. package/src/lib/components/leads-bulk-bar.d.ts +0 -3
  88. package/src/lib/components/leads-bulk-bar.js +29 -29
  89. package/src/lib/components/leads-bulk-bar.js.map +1 -1
  90. package/src/lib/components/leads-section.js +120 -68
  91. package/src/lib/components/leads-section.js.map +1 -1
  92. package/src/lib/components/linked-deals-card.d.ts +4 -0
  93. package/src/lib/components/linked-deals-card.js +47 -3
  94. package/src/lib/components/linked-deals-card.js.map +1 -1
  95. package/src/lib/components/log-activity-dialog.js +43 -3
  96. package/src/lib/components/log-activity-dialog.js.map +1 -1
  97. package/src/lib/components/new-contact-drawer.d.ts +8 -0
  98. package/src/lib/components/new-contact-drawer.js +108 -6
  99. package/src/lib/components/new-contact-drawer.js.map +1 -1
  100. package/src/lib/components/new-lead-drawer.d.ts +9 -2
  101. package/src/lib/components/new-lead-drawer.js +88 -121
  102. package/src/lib/components/new-lead-drawer.js.map +1 -1
  103. package/src/lib/components/picklist-select.d.ts +36 -0
  104. package/src/lib/components/picklist-select.js +114 -0
  105. package/src/lib/components/picklist-select.js.map +1 -0
  106. package/src/lib/components/picklist-values-card.d.ts +34 -0
  107. package/src/lib/components/{lead-source-values-card.js → picklist-values-card.js} +241 -58
  108. package/src/lib/components/picklist-values-card.js.map +1 -0
  109. package/src/lib/components/pipeline-stages-dialog.d.ts +7 -0
  110. package/src/lib/components/pipeline-stages-dialog.js +26 -4
  111. package/src/lib/components/pipeline-stages-dialog.js.map +1 -1
  112. package/src/lib/components/pipelines-dialog.js +15 -6
  113. package/src/lib/components/pipelines-dialog.js.map +1 -1
  114. package/src/lib/components/recent-activity-feed.js +20 -5
  115. package/src/lib/components/recent-activity-feed.js.map +1 -1
  116. package/src/lib/components/recipes-card.js +4 -2
  117. package/src/lib/components/recipes-card.js.map +1 -1
  118. package/src/lib/components/record-tasks-card.js +15 -8
  119. package/src/lib/components/record-tasks-card.js.map +1 -1
  120. package/src/lib/components/reports/forecast-card.d.ts +6 -0
  121. package/src/lib/components/reports/forecast-card.js +101 -3
  122. package/src/lib/components/reports/forecast-card.js.map +1 -1
  123. package/src/lib/components/reports/lead-funnel-card.d.ts +12 -0
  124. package/src/lib/components/reports/lead-funnel-card.js +9 -5
  125. package/src/lib/components/reports/lead-funnel-card.js.map +1 -1
  126. package/src/lib/components/reports/lead-source-card.d.ts +23 -0
  127. package/src/lib/components/reports/lead-source-card.js +318 -0
  128. package/src/lib/components/reports/lead-source-card.js.map +1 -0
  129. package/src/lib/components/reports/pipeline-card.js +2 -1
  130. package/src/lib/components/reports/pipeline-card.js.map +1 -1
  131. package/src/lib/components/reports/report-export.js +1 -1
  132. package/src/lib/components/reports/report-export.js.map +1 -1
  133. package/src/lib/components/reports-section.js +8 -0
  134. package/src/lib/components/reports-section.js.map +1 -1
  135. package/src/lib/components/sharing-rule-drawer.d.ts +5 -0
  136. package/src/lib/components/sharing-rule-drawer.js +108 -19
  137. package/src/lib/components/sharing-rule-drawer.js.map +1 -1
  138. package/src/lib/components/sharing-rules-card.js +11 -3
  139. package/src/lib/components/sharing-rules-card.js.map +1 -1
  140. package/src/lib/components/task-cells.d.ts +9 -1
  141. package/src/lib/components/task-cells.js +9 -4
  142. package/src/lib/components/task-cells.js.map +1 -1
  143. package/src/lib/components/task-edit-drawer.js +111 -43
  144. package/src/lib/components/task-edit-drawer.js.map +1 -1
  145. package/src/lib/components/tasks-bulk-bar.d.ts +0 -3
  146. package/src/lib/components/tasks-bulk-bar.js +7 -20
  147. package/src/lib/components/tasks-bulk-bar.js.map +1 -1
  148. package/src/lib/components/tasks-calendar.d.ts +3 -0
  149. package/src/lib/components/tasks-calendar.js +8 -1
  150. package/src/lib/components/tasks-calendar.js.map +1 -1
  151. package/src/lib/components/tasks-section.d.ts +3 -3
  152. package/src/lib/components/tasks-section.js +58 -43
  153. package/src/lib/components/tasks-section.js.map +1 -1
  154. package/src/lib/constants/api-routes.d.ts +2 -9
  155. package/src/lib/constants/api-routes.js +1 -7
  156. package/src/lib/constants/api-routes.js.map +1 -1
  157. package/src/lib/constants/bundle-common.d.ts +6 -0
  158. package/src/lib/constants/bundle-common.js +11 -0
  159. package/src/lib/constants/bundle-common.js.map +1 -1
  160. package/src/lib/constants/company-filters.d.ts +14 -0
  161. package/src/lib/constants/company-filters.js +51 -1
  162. package/src/lib/constants/company-filters.js.map +1 -1
  163. package/src/lib/constants/contact-filters.d.ts +2 -0
  164. package/src/lib/constants/contact-filters.js +18 -1
  165. package/src/lib/constants/contact-filters.js.map +1 -1
  166. package/src/lib/constants/deal-filters.d.ts +22 -1
  167. package/src/lib/constants/deal-filters.js +67 -4
  168. package/src/lib/constants/deal-filters.js.map +1 -1
  169. package/src/lib/declarations.console-server.d.ts +3 -0
  170. package/src/lib/declarations.console-server.js +35 -0
  171. package/src/lib/declarations.console-server.js.map +1 -1
  172. package/src/lib/declarations.d.ts +26 -0
  173. package/src/lib/declarations.js +35 -0
  174. package/src/lib/declarations.js.map +1 -0
  175. package/src/lib/declarations.server.d.ts +11 -0
  176. package/src/lib/declarations.server.js +97 -1
  177. package/src/lib/declarations.server.js.map +1 -1
  178. package/src/lib/hooks/use-company-picklists.d.ts +15 -0
  179. package/src/lib/hooks/use-company-picklists.js +55 -0
  180. package/src/lib/hooks/use-company-picklists.js.map +1 -0
  181. package/src/lib/hooks/use-crm-picklist.d.ts +25 -0
  182. package/src/lib/hooks/use-crm-picklist.js +53 -0
  183. package/src/lib/hooks/use-crm-picklist.js.map +1 -0
  184. package/src/lib/hooks/use-crm-record-names.d.ts +16 -0
  185. package/src/lib/hooks/use-crm-record-names.js +45 -19
  186. package/src/lib/hooks/use-crm-record-names.js.map +1 -1
  187. package/src/lib/hooks/use-crm-task-picklists.d.ts +11 -0
  188. package/src/lib/hooks/use-crm-task-picklists.js +45 -0
  189. package/src/lib/hooks/use-crm-task-picklists.js.map +1 -0
  190. package/src/lib/hooks/use-deals.d.ts +14 -0
  191. package/src/lib/hooks/use-deals.js +29 -0
  192. package/src/lib/hooks/use-deals.js.map +1 -1
  193. package/src/lib/hooks/use-lead-picklists.d.ts +14 -0
  194. package/src/lib/hooks/use-lead-picklists.js +46 -0
  195. package/src/lib/hooks/use-lead-picklists.js.map +1 -0
  196. package/src/lib/hooks/use-lead-source-picklist.d.ts +5 -19
  197. package/src/lib/hooks/use-lead-source-picklist.js +12 -22
  198. package/src/lib/hooks/use-lead-source-picklist.js.map +1 -1
  199. package/src/lib/hooks/use-lead-status-picklist.d.ts +9 -0
  200. package/src/lib/hooks/use-lead-status-picklist.js +40 -0
  201. package/src/lib/hooks/use-lead-status-picklist.js.map +1 -0
  202. package/src/lib/model/companies.d.ts +32 -3
  203. package/src/lib/model/companies.js +133 -16
  204. package/src/lib/model/companies.js.map +1 -1
  205. package/src/lib/model/contact-merge.d.ts +27 -3
  206. package/src/lib/model/contact-merge.js +81 -7
  207. package/src/lib/model/contact-merge.js.map +1 -1
  208. package/src/lib/model/contact-record.d.ts +17 -0
  209. package/src/lib/model/contact-record.js +17 -2
  210. package/src/lib/model/contact-record.js.map +1 -1
  211. package/src/lib/model/contact-update.d.ts +31 -2
  212. package/src/lib/model/contact-update.js +14 -0
  213. package/src/lib/model/contact-update.js.map +1 -1
  214. package/src/lib/model/crm-list-query.d.ts +5 -0
  215. package/src/lib/model/crm-list-query.js +8 -0
  216. package/src/lib/model/crm-list-query.js.map +1 -1
  217. package/src/lib/model/crm-next-activity.d.ts +107 -0
  218. package/src/lib/model/crm-next-activity.js +140 -0
  219. package/src/lib/model/crm-next-activity.js.map +1 -0
  220. package/src/lib/model/crm-recipes.d.ts +40 -0
  221. package/src/lib/model/crm-recipes.js +259 -0
  222. package/src/lib/model/crm-recipes.js.map +1 -0
  223. package/src/lib/model/crm-record-counts.d.ts +36 -0
  224. package/src/lib/model/crm-record-counts.js +54 -0
  225. package/src/lib/model/crm-record-counts.js.map +1 -0
  226. package/src/lib/model/crm-record-lists.d.ts +23 -0
  227. package/src/lib/model/crm-record-lists.js +161 -0
  228. package/src/lib/model/crm-record-lists.js.map +1 -0
  229. package/src/lib/model/crm-reports.d.ts +73 -3
  230. package/src/lib/model/crm-reports.js +120 -1
  231. package/src/lib/model/crm-reports.js.map +1 -1
  232. package/src/lib/model/crm-sharing.d.ts +21 -3
  233. package/src/lib/model/crm-sharing.js +27 -6
  234. package/src/lib/model/crm-sharing.js.map +1 -1
  235. package/src/lib/model/crm-task-reminders.d.ts +152 -0
  236. package/src/lib/model/crm-task-reminders.js +161 -0
  237. package/src/lib/model/crm-task-reminders.js.map +1 -0
  238. package/src/lib/model/deal-board-model.d.ts +8 -2
  239. package/src/lib/model/deal-board-model.js +15 -2
  240. package/src/lib/model/deal-board-model.js.map +1 -1
  241. package/src/lib/model/deal-contact-roles.d.ts +45 -0
  242. package/src/lib/model/deal-contact-roles.js +73 -0
  243. package/src/lib/model/deal-contact-roles.js.map +1 -0
  244. package/src/lib/model/deal-form-model.d.ts +56 -0
  245. package/src/lib/model/deal-form-model.js +79 -7
  246. package/src/lib/model/deal-form-model.js.map +1 -1
  247. package/src/lib/model/download-text-file.d.ts +23 -0
  248. package/src/lib/model/download-text-file.js +34 -0
  249. package/src/lib/model/download-text-file.js.map +1 -0
  250. package/src/lib/model/lead-filters.d.ts +36 -2
  251. package/src/lib/model/lead-filters.js +123 -2
  252. package/src/lib/model/lead-filters.js.map +1 -1
  253. package/src/lib/model/lead-source-direction.d.ts +38 -0
  254. package/src/lib/model/lead-source-direction.js +52 -0
  255. package/src/lib/model/lead-source-direction.js.map +1 -0
  256. package/src/lib/model/next-activity.d.ts +1 -1
  257. package/src/lib/model/next-activity.js.map +1 -1
  258. package/src/lib/model/picklist-values.d.ts +119 -0
  259. package/src/lib/model/picklist-values.js +256 -0
  260. package/src/lib/model/picklist-values.js.map +1 -0
  261. package/src/lib/model/record-facts-disclosed.d.ts +81 -0
  262. package/src/lib/model/record-facts-disclosed.js +281 -0
  263. package/src/lib/model/record-facts-disclosed.js.map +1 -0
  264. package/src/lib/model/record-facts.d.ts +215 -34
  265. package/src/lib/model/record-facts.js +307 -128
  266. package/src/lib/model/record-facts.js.map +1 -1
  267. package/src/lib/model/task-picklists.d.ts +52 -0
  268. package/src/lib/model/task-picklists.js +83 -0
  269. package/src/lib/model/task-picklists.js.map +1 -0
  270. package/src/lib/model/task-routes.d.ts +13 -0
  271. package/src/lib/model/task-routes.js +23 -4
  272. package/src/lib/model/task-routes.js.map +1 -1
  273. package/src/lib/plan-entitlements.js +6 -4
  274. package/src/lib/plan-entitlements.js.map +1 -1
  275. package/src/lib/plugin.js +17 -0
  276. package/src/lib/plugin.js.map +1 -1
  277. package/src/lib/server/api-v1/contacts.js +220 -14
  278. package/src/lib/server/api-v1/contacts.js.map +1 -1
  279. package/src/lib/server/api-v1/crm-activities.js +14 -1
  280. package/src/lib/server/api-v1/crm-activities.js.map +1 -1
  281. package/src/lib/server/api-v1/crm-companies.js +123 -14
  282. package/src/lib/server/api-v1/crm-companies.js.map +1 -1
  283. package/src/lib/server/api-v1/crm-deals.js +291 -26
  284. package/src/lib/server/api-v1/crm-deals.js.map +1 -1
  285. package/src/lib/server/api-v1/crm-leads.js +144 -38
  286. package/src/lib/server/api-v1/crm-leads.js.map +1 -1
  287. package/src/lib/server/api-v1/crm-pipelines.d.ts +6 -0
  288. package/src/lib/server/api-v1/crm-pipelines.js +8 -2
  289. package/src/lib/server/api-v1/crm-pipelines.js.map +1 -1
  290. package/src/lib/server/api-v1/crm-tasks.js +78 -34
  291. package/src/lib/server/api-v1/crm-tasks.js.map +1 -1
  292. package/src/lib/server/api-v1/openapi.d.ts +0 -11
  293. package/src/lib/server/api-v1/openapi.js +171 -16
  294. package/src/lib/server/api-v1/openapi.js.map +1 -1
  295. package/src/lib/server/assign-contact-owner.d.ts +188 -0
  296. package/src/lib/server/assign-contact-owner.js +446 -0
  297. package/src/lib/server/assign-contact-owner.js.map +1 -0
  298. package/src/lib/server/associate-company-by-domain.d.ts +70 -0
  299. package/src/lib/server/associate-company-by-domain.js +153 -0
  300. package/src/lib/server/associate-company-by-domain.js.map +1 -0
  301. package/src/lib/server/automation-steps.d.ts +140 -0
  302. package/src/lib/server/automation-steps.js +669 -0
  303. package/src/lib/server/automation-steps.js.map +1 -0
  304. package/src/lib/server/capture-contact.d.ts +17 -0
  305. package/src/lib/server/capture-contact.js +95 -26
  306. package/src/lib/server/capture-contact.js.map +1 -1
  307. package/src/lib/server/capture-host-contact.d.ts +104 -0
  308. package/src/lib/server/capture-host-contact.js +151 -0
  309. package/src/lib/server/capture-host-contact.js.map +1 -0
  310. package/src/lib/server/company-children.d.ts +25 -0
  311. package/src/lib/server/company-children.js +42 -0
  312. package/src/lib/server/company-children.js.map +1 -0
  313. package/src/lib/server/company-delete.d.ts +18 -0
  314. package/src/lib/server/company-delete.js +44 -21
  315. package/src/lib/server/company-delete.js.map +1 -1
  316. package/src/lib/server/contact-email-history.js +21 -19
  317. package/src/lib/server/contact-email-history.js.map +1 -1
  318. package/src/lib/server/contact-remove.js +27 -2
  319. package/src/lib/server/contact-remove.js.map +1 -1
  320. package/src/lib/server/contact-reports-to.d.ts +61 -0
  321. package/src/lib/server/contact-reports-to.js +114 -0
  322. package/src/lib/server/contact-reports-to.js.map +1 -0
  323. package/src/lib/server/contact-update.d.ts +42 -1
  324. package/src/lib/server/contact-update.js +204 -23
  325. package/src/lib/server/contact-update.js.map +1 -1
  326. package/src/lib/server/convert-host-lead.d.ts +46 -1
  327. package/src/lib/server/convert-host-lead.js +173 -15
  328. package/src/lib/server/convert-host-lead.js.map +1 -1
  329. package/src/lib/server/convert-open-lead.js +12 -5
  330. package/src/lib/server/convert-open-lead.js.map +1 -1
  331. package/src/lib/server/crm-email-activity.d.ts +118 -0
  332. package/src/lib/server/crm-email-activity.js +148 -0
  333. package/src/lib/server/crm-email-activity.js.map +1 -0
  334. package/src/lib/server/crm-inbound-email.js +1 -1
  335. package/src/lib/server/crm-inbound-email.js.map +1 -1
  336. package/src/lib/server/crm-next-activity.d.ts +74 -0
  337. package/src/lib/server/crm-next-activity.js +194 -0
  338. package/src/lib/server/crm-next-activity.js.map +1 -0
  339. package/src/lib/server/crm-record-indexes.d.ts +45 -0
  340. package/src/lib/server/crm-record-indexes.js +78 -0
  341. package/src/lib/server/crm-record-indexes.js.map +1 -0
  342. package/src/lib/server/crm-sharing.d.ts +9 -1
  343. package/src/lib/server/crm-sharing.js +23 -3
  344. package/src/lib/server/crm-sharing.js.map +1 -1
  345. package/src/lib/server/deal-contact-roles.d.ts +27 -0
  346. package/src/lib/server/deal-contact-roles.js +89 -0
  347. package/src/lib/server/deal-contact-roles.js.map +1 -0
  348. package/src/lib/server/email-send.js +2 -1
  349. package/src/lib/server/email-send.js.map +1 -1
  350. package/src/lib/server/lead-convert.d.ts +5 -0
  351. package/src/lib/server/lead-convert.js +19 -3
  352. package/src/lib/server/lead-convert.js.map +1 -1
  353. package/src/lib/server/lead-create.d.ts +17 -2
  354. package/src/lib/server/lead-create.js +46 -14
  355. package/src/lib/server/lead-create.js.map +1 -1
  356. package/src/lib/server/lead-nurturing.d.ts +6 -0
  357. package/src/lib/server/lead-nurturing.js +57 -20
  358. package/src/lib/server/lead-nurturing.js.map +1 -1
  359. package/src/lib/server/lead-picklists.d.ts +35 -0
  360. package/src/lib/server/lead-picklists.js +52 -0
  361. package/src/lib/server/lead-picklists.js.map +1 -0
  362. package/src/lib/server/lead-source-picklist.d.ts +1 -13
  363. package/src/lib/server/lead-source-picklist.js +6 -33
  364. package/src/lib/server/lead-source-picklist.js.map +1 -1
  365. package/src/lib/server/merge-contacts.js +23 -5
  366. package/src/lib/server/merge-contacts.js.map +1 -1
  367. package/src/lib/server/next-activity-routes.js +2 -1
  368. package/src/lib/server/next-activity-routes.js.map +1 -1
  369. package/src/lib/server/person-eraser.d.ts +53 -0
  370. package/src/lib/server/person-eraser.js +149 -0
  371. package/src/lib/server/person-eraser.js.map +1 -0
  372. package/src/lib/server/person-records.d.ts +69 -0
  373. package/src/lib/server/person-records.js +317 -0
  374. package/src/lib/server/person-records.js.map +1 -0
  375. package/src/lib/server/person-refund.d.ts +97 -0
  376. package/src/lib/server/person-refund.js +221 -0
  377. package/src/lib/server/person-refund.js.map +1 -0
  378. package/src/lib/server/picklist-values.d.ts +21 -0
  379. package/src/lib/server/picklist-values.js +308 -0
  380. package/src/lib/server/picklist-values.js.map +1 -0
  381. package/src/lib/server/read-picklist.d.ts +44 -0
  382. package/src/lib/server/read-picklist.js +65 -0
  383. package/src/lib/server/read-picklist.js.map +1 -0
  384. package/src/lib/server/recipe-routes.js +22 -8
  385. package/src/lib/server/recipe-routes.js.map +1 -1
  386. package/src/lib/server/record-email-state.js +7 -1
  387. package/src/lib/server/record-email-state.js.map +1 -1
  388. package/src/lib/server/record-facts.d.ts +3 -0
  389. package/src/lib/server/record-facts.js +233 -31
  390. package/src/lib/server/record-facts.js.map +1 -1
  391. package/src/lib/server/record-origin.d.ts +27 -0
  392. package/src/lib/server/record-origin.js +104 -0
  393. package/src/lib/server/record-origin.js.map +1 -0
  394. package/src/lib/server/record-timeline.js +40 -3
  395. package/src/lib/server/record-timeline.js.map +1 -1
  396. package/src/lib/server/suite-gate.js +4 -3
  397. package/src/lib/server/suite-gate.js.map +1 -1
  398. package/src/lib/server/task-reminders-route.js +2 -1
  399. package/src/lib/server/task-reminders-route.js.map +1 -1
  400. package/src/lib/server/task-routes.js +33 -17
  401. package/src/lib/server/task-routes.js.map +1 -1
  402. package/src/lib/server-deal-stage.d.ts +5 -1
  403. package/src/lib/server-deal-stage.js +10 -5
  404. package/src/lib/server-deal-stage.js.map +1 -1
  405. package/src/lib/server.d.ts +8 -3
  406. package/src/lib/server.js +47 -43
  407. package/src/lib/server.js.map +1 -1
  408. package/src/lib/testing/memory-firestore.d.ts +55 -0
  409. package/src/lib/testing/memory-firestore.js +335 -0
  410. package/src/lib/testing/memory-firestore.js.map +1 -0
  411. package/src/lib/testing/stand-in-email-send-index.d.ts +25 -0
  412. package/src/lib/testing/stand-in-email-send-index.js +49 -0
  413. package/src/lib/testing/stand-in-email-send-index.js.map +1 -0
  414. package/src/lib/transfer/activities.d.ts +30 -0
  415. package/src/lib/transfer/activities.js +132 -0
  416. package/src/lib/transfer/activities.js.map +1 -0
  417. package/src/lib/transfer/aliases.d.ts +22 -0
  418. package/src/lib/transfer/aliases.js +1342 -0
  419. package/src/lib/transfer/aliases.js.map +1 -0
  420. package/src/lib/transfer/common.d.ts +222 -0
  421. package/src/lib/transfer/common.js +832 -0
  422. package/src/lib/transfer/common.js.map +1 -0
  423. package/src/lib/transfer/companies.d.ts +43 -0
  424. package/src/lib/transfer/companies.js +549 -0
  425. package/src/lib/transfer/companies.js.map +1 -0
  426. package/src/lib/transfer/contacts.d.ts +31 -0
  427. package/src/lib/transfer/contacts.js +727 -0
  428. package/src/lib/transfer/contacts.js.map +1 -0
  429. package/src/lib/transfer/deals.d.ts +66 -0
  430. package/src/lib/transfer/deals.js +698 -0
  431. package/src/lib/transfer/deals.js.map +1 -0
  432. package/src/lib/transfer/email-templates-package.d.ts +40 -0
  433. package/src/lib/transfer/email-templates-package.js +76 -0
  434. package/src/lib/transfer/email-templates-package.js.map +1 -0
  435. package/src/lib/transfer/email-templates-package.server.d.ts +32 -0
  436. package/src/lib/transfer/email-templates-package.server.js +176 -0
  437. package/src/lib/transfer/email-templates-package.server.js.map +1 -0
  438. package/src/lib/transfer/fields.d.ts +102 -0
  439. package/src/lib/transfer/fields.js +1755 -0
  440. package/src/lib/transfer/fields.js.map +1 -0
  441. package/src/lib/transfer/leads.d.ts +30 -0
  442. package/src/lib/transfer/leads.js +582 -0
  443. package/src/lib/transfer/leads.js.map +1 -0
  444. package/src/lib/transfer/pipelines.d.ts +21 -0
  445. package/src/lib/transfer/pipelines.js +172 -0
  446. package/src/lib/transfer/pipelines.js.map +1 -0
  447. package/src/lib/transfer/register.d.ts +47 -0
  448. package/src/lib/transfer/register.js +277 -0
  449. package/src/lib/transfer/register.js.map +1 -0
  450. package/src/lib/transfer/tasks.d.ts +30 -0
  451. package/src/lib/transfer/tasks.js +418 -0
  452. package/src/lib/transfer/tasks.js.map +1 -0
  453. package/src/lib/transfer/ui.d.ts +20 -0
  454. package/src/lib/transfer/ui.js +42 -0
  455. package/src/lib/transfer/ui.js.map +1 -0
  456. package/src/lib/components/company-import-drawer.d.ts +0 -42
  457. package/src/lib/components/company-import-drawer.js +0 -99
  458. package/src/lib/components/company-import-drawer.js.map +0 -1
  459. package/src/lib/components/contact-import-drawer.d.ts +0 -46
  460. package/src/lib/components/contact-import-drawer.js +0 -149
  461. package/src/lib/components/contact-import-drawer.js.map +0 -1
  462. package/src/lib/components/crm-export-all-button.d.ts +0 -39
  463. package/src/lib/components/crm-export-all-button.js +0 -98
  464. package/src/lib/components/crm-export-all-button.js.map +0 -1
  465. package/src/lib/components/csv-import-drawer.d.ts +0 -139
  466. package/src/lib/components/csv-import-drawer.js +0 -757
  467. package/src/lib/components/csv-import-drawer.js.map +0 -1
  468. package/src/lib/components/deal-import-drawer.d.ts +0 -24
  469. package/src/lib/components/deal-import-drawer.js +0 -83
  470. package/src/lib/components/deal-import-drawer.js.map +0 -1
  471. package/src/lib/components/lead-import-drawer.d.ts +0 -27
  472. package/src/lib/components/lead-import-drawer.js +0 -118
  473. package/src/lib/components/lead-import-drawer.js.map +0 -1
  474. package/src/lib/components/lead-source-values-card.d.ts +0 -27
  475. package/src/lib/components/lead-source-values-card.js.map +0 -1
  476. package/src/lib/components/task-import-drawer.d.ts +0 -24
  477. package/src/lib/components/task-import-drawer.js +0 -82
  478. package/src/lib/components/task-import-drawer.js.map +0 -1
  479. package/src/lib/model/companies-csv.d.ts +0 -36
  480. package/src/lib/model/companies-csv.js +0 -38
  481. package/src/lib/model/companies-csv.js.map +0 -1
  482. package/src/lib/model/contacts-csv.d.ts +0 -54
  483. package/src/lib/model/contacts-csv.js +0 -67
  484. package/src/lib/model/contacts-csv.js.map +0 -1
  485. package/src/lib/model/crm-company-import.d.ts +0 -154
  486. package/src/lib/model/crm-company-import.js +0 -331
  487. package/src/lib/model/crm-company-import.js.map +0 -1
  488. package/src/lib/model/crm-csv.d.ts +0 -239
  489. package/src/lib/model/crm-csv.js +0 -467
  490. package/src/lib/model/crm-csv.js.map +0 -1
  491. package/src/lib/model/crm-deal-import.d.ts +0 -112
  492. package/src/lib/model/crm-deal-import.js +0 -263
  493. package/src/lib/model/crm-deal-import.js.map +0 -1
  494. package/src/lib/model/crm-import.d.ts +0 -250
  495. package/src/lib/model/crm-import.js +0 -467
  496. package/src/lib/model/crm-import.js.map +0 -1
  497. package/src/lib/model/crm-lead-import.d.ts +0 -138
  498. package/src/lib/model/crm-lead-import.js +0 -446
  499. package/src/lib/model/crm-lead-import.js.map +0 -1
  500. package/src/lib/model/crm-task-import.d.ts +0 -94
  501. package/src/lib/model/crm-task-import.js +0 -275
  502. package/src/lib/model/crm-task-import.js.map +0 -1
  503. package/src/lib/model/deals-csv.d.ts +0 -32
  504. package/src/lib/model/deals-csv.js +0 -36
  505. package/src/lib/model/deals-csv.js.map +0 -1
  506. package/src/lib/model/import-column-shapes.d.ts +0 -36
  507. package/src/lib/model/import-column-shapes.js +0 -76
  508. package/src/lib/model/import-column-shapes.js.map +0 -1
  509. package/src/lib/model/lead-source-values.d.ts +0 -82
  510. package/src/lib/model/lead-source-values.js +0 -149
  511. package/src/lib/model/lead-source-values.js.map +0 -1
  512. package/src/lib/model/leads-csv.d.ts +0 -40
  513. package/src/lib/model/leads-csv.js +0 -40
  514. package/src/lib/model/leads-csv.js.map +0 -1
  515. package/src/lib/model/tasks-csv.d.ts +0 -28
  516. package/src/lib/model/tasks-csv.js +0 -28
  517. package/src/lib/model/tasks-csv.js.map +0 -1
  518. package/src/lib/server/companies-import.d.ts +0 -57
  519. package/src/lib/server/companies-import.js +0 -242
  520. package/src/lib/server/companies-import.js.map +0 -1
  521. package/src/lib/server/contacts-import.d.ts +0 -109
  522. package/src/lib/server/contacts-import.js +0 -393
  523. package/src/lib/server/contacts-import.js.map +0 -1
  524. package/src/lib/server/deals-import.d.ts +0 -76
  525. package/src/lib/server/deals-import.js +0 -248
  526. package/src/lib/server/deals-import.js.map +0 -1
  527. package/src/lib/server/export-route.d.ts +0 -60
  528. package/src/lib/server/export-route.js +0 -447
  529. package/src/lib/server/export-route.js.map +0 -1
  530. package/src/lib/server/import-context.d.ts +0 -87
  531. package/src/lib/server/import-context.js +0 -182
  532. package/src/lib/server/import-context.js.map +0 -1
  533. package/src/lib/server/lead-source-values.d.ts +0 -50
  534. package/src/lib/server/lead-source-values.js +0 -191
  535. package/src/lib/server/lead-source-values.js.map +0 -1
  536. package/src/lib/server/leads-import.d.ts +0 -84
  537. package/src/lib/server/leads-import.js +0 -367
  538. package/src/lib/server/leads-import.js.map +0 -1
  539. package/src/lib/server/tasks-import.d.ts +0 -54
  540. package/src/lib/server/tasks-import.js +0 -160
  541. package/src/lib/server/tasks-import.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/contacts-bulk-bar.tsx"],"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\n/**\n * The bar over the contacts table, for whatever rows are ticked (AGL-2603).\n *\n * The table's selection is opt-in and this is what it is for: a chosen set\n * of people, and one act over all of them. Tag or untag them, hand them to\n * an owner, move them along the funnel, put them on an email audience, take\n * them into a spreadsheet, or let them go from this site's CRM.\n *\n * ## The chrome is the shared frame\n *\n * This bar settled how a bar over a table reads — it appears only for a\n * selection and says how many, its actions sit in one wrapping row with\n * Clear at the end, and whatever the last action could not do is listed by\n * name in an alert under it — and the companies, deals and tasks bars were\n * built on that shape as `CrmBulkBarFrame` and `useCrmBulkApply` (AGL-2621).\n * The contacts bar stands on the same two (AGL-2635): what is its own is the\n * actions, the dialog's field, the audience door, and how each act is sent.\n *\n * ## Each act goes where its field is written (AGL-2804)\n *\n * A contact's tags, owner and company live in the holder's facet, which is\n * the server's to write — the rules cannot tell one field of a facet from\n * another — so each of those acts is ONE request to `crm/contact-update` for\n * the rows it reaches (`contacts-bulk-writes.ts` decides which), sent in\n * pieces the route accepts. A stage move is `crm/contact-stage`, row by row:\n * a move is what an automation listens for, and only the route that\n * performed it can announce it. Letting the rows go is `crm/contact-remove`\n * (AGL-3338): the route decides detach or delete against each stored\n * document and keeps any marketing refusal the person gave.\n *\n * ## A refused row is named\n *\n * Whatever the server or the store refused comes back by address into the\n * alert under the bar — not into a count, and not into the console. A\n * merchant who tagged four hundred people and got three hundred and\n * ninety-eight needs the two addresses.\n *\n * ## Add to list goes through the audience's own door\n *\n * The membership routes, with the check-then-attest sequence the Emails\n * console runs — see `add-to-list-dialog.tsx`. Nothing here writes a\n * membership document.\n */\n\nimport {\n type AglynOrgBilling,\n CONTACT_LIFECYCLE_STAGE_LABELS,\n CONTACT_LIFECYCLE_STAGES,\n type ConsentGroup,\n type ContactLifecycleStage,\n crmMemberPickerLabel,\n} from '@aglyn/aglyn'\nimport { useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport { Button, MenuItem, TextField } from '@mui/material'\nimport { useCallback, useMemo, useState } from 'react'\nimport { useOrgMemberOptions, useUser } from '@aglyn/tenant-feature-instance'\nimport { useContactRemove } from '../hooks/use-contact-remove'\nimport { useContactUpdate } from '../hooks/use-contact-update'\nimport { useCrmBulkApply } from '../hooks/use-crm-bulk-apply'\nimport { useCrmScope } from '../hooks/use-crm-scope'\nimport { CRM_CONTACT_REMOVE_MAX } from '../model/contact-remove'\nimport { CRM_CONTACT_UPDATE_MAX, type ContactUpdateFields } from '../model/contact-update'\nimport { setContactStage } from '../model/crm-api'\nimport {\n contactBulkAddressOf,\n normalizeBulkTag,\n planAddTag,\n planRemoveTag,\n planSetCompany,\n type ContactBulkRow,\n type ContactBulkSelection,\n type ContactBulkSkip,\n} from '../model/contacts-bulk-writes'\nimport {\n type ContactCsvOptions,\n type ContactCsvRow,\n contactsCsv,\n downloadTextFile,\n} from '../model/contacts-csv'\nimport {\n type CrmBulkOutcome,\n runCrmBulkBatch,\n runCrmBulkCalls,\n} from '../model/crm-bulk-writes'\nimport AddToListDialog from './add-to-list-dialog'\nimport {\n CompanyPicker,\n type CompanyOption,\n useCompanyOptions,\n useCreateCompany,\n} from './company-picker'\nimport {\n type CrmBulkNoun,\n CrmBulkBarFrame,\n CrmBulkValueDialog,\n countNoun,\n} from './crm-bulk-bar-frame'\nimport CrmExportAllButton from './crm-export-all-button'\nimport { CrmBulkShareButton } from './record-sharing-card'\nimport { CrmSuiteLockedButton } from './crm-suite-lock'\n\nexport interface ContactsBulkBarProps {\n /** The site the list is read under, or `null` at the organization level. */\n hostId: string | null\n /** The org document the shell passed, for the company picker's scope. */\n org?: Partial<AglynOrgBilling> | null\n /** `['orgs', orgId]`, or `null` while the org is unresolved. */\n scope: readonly [string, string] | null\n /**\n * The holder these rows are being read AS — whose facet the acts land in.\n * `null` at the organization level (AGL-2630), where each row's own holder\n * (`groupId`) takes the act instead, and \"Remove from this site\" is not\n * offered because there is no site to remove from.\n */\n consentGroup: ConsentGroup | null\n /** The table's rows, already projected through the holder's facet. */\n rows: readonly (ContactBulkRow & ContactCsvRow)[]\n selected: readonly string[]\n onSelectedChange: (ids: string[]) => void\n /**\n * How the export names an owner and which custom fields it carries — the\n * table's own options, so the selection's file and the table's are one\n * format (AGL-2621).\n */\n csv?: ContactCsvOptions\n /**\n * The org's plan lacks the CRM (AGL-2788), which the shell mounts no CRM\n * page for (AGL-2851). The owner, the stage and the company stand locked;\n * tags, the exports, the audience door and removing people from a site\n * draw no lock of their own.\n */\n suiteLocked?: boolean\n}\n\nconst NOUN: CrmBulkNoun = { singular: 'contact', plural: 'contacts' }\n\n/** The one small dialog the value-taking actions share. */\ntype PendingAction = 'add-tag' | 'remove-tag' | 'owner' | 'stage' | 'company'\n\nconst ACTION_TITLES: Record<PendingAction, string> = {\n 'add-tag': 'Add a tag',\n 'remove-tag': 'Remove a tag',\n owner: 'Set the owner',\n stage: 'Set the lifecycle stage',\n company: 'Set the company',\n}\n\n/** How a finished action reads, given how many rows it reached. */\nconst doneSentence = (action: PendingAction | 'detach', done: number): string => {\n const people = countNoun(done, NOUN)\n switch (action) {\n case 'add-tag':\n return `Tagged ${people}`\n case 'remove-tag':\n return `Removed the tag from ${people}`\n case 'owner':\n return `Owner set on ${people}`\n case 'stage':\n return `Stage set on ${people}`\n case 'company':\n return `Company set on ${people}`\n case 'detach':\n return `${people} removed from this site`\n }\n}\n\n/** The report's line for a row an act left out on purpose. */\nconst skippedLine = (row: ContactBulkSkip) => ({ label: row.email, reason: row.reason })\n\n/**\n * The bar, or nothing.\n *\n * The empty state is a separate component boundary on purpose: with no\n * selection the body below is never mounted, so none of its hooks run — no\n * roster hook armed, no dialog state held — on the visit to the list that\n * every reader makes and most never tick a row on.\n */\nexport function ContactsBulkBar(props: ContactsBulkBarProps) {\n if (!props.selected.length) return null\n return <ContactsBulkBarBody {...props} />\n}\nContactsBulkBar.displayName = 'ContactsBulkBar'\n\nfunction ContactsBulkBarBody(props: ContactsBulkBarProps) {\n const {\n hostId,\n org,\n scope,\n consentGroup,\n rows,\n selected,\n onSelectedChange,\n csv,\n suiteLocked = false,\n } = props\n const { data: user } = useUser()\n const { confirm } = useConfirmationContext()\n const { busy, report, apply, dismissReport } = useCrmBulkApply({ recordKind: 'contact' })\n const contactUpdate = useContactUpdate(hostId)\n const contactRemove = useContactRemove(hostId)\n\n const selectedRows = useMemo(() => {\n const chosen = new Set(selected)\n return rows.filter((row) => chosen.has(row.$id))\n }, [rows, selected])\n\n const [pending, setPending] = useState<PendingAction | null>(null)\n const [value, setValue] = useState('')\n const [company, setCompany] = useState<CompanyOption | null>(null)\n const [listOpen, setListOpen] = useState(false)\n\n /*\n * The roster, read only while the owner dialog is open. A bulk bar sits on\n * every visit to the list; the team is a request for a control nobody has\n * opened until they open it. The company list follows the same rule for\n * its own dialog (AGL-2613).\n */\n const team = useOrgMemberOptions(scope?.[1], { enabled: pending === 'owner' })\n const companies = useCompanyOptions({\n hostId,\n org,\n enabled: pending === 'company',\n })\n const createCompany = useCreateCompany({ hostId, org })\n // The site the audiences API is asked from: the mounted one, or at the\n // organization level the one the reader picked (AGL-2630).\n const { createHostId } = useCrmScope({ hostId, org })\n\n const openAction = (action: PendingAction) => {\n setValue('')\n setCompany(null)\n setPending(action)\n }\n\n /** One act's request for the rows it reaches, in the pieces the route accepts. */\n const saveThroughRoute = useCallback(\n (targets: readonly ContactBulkRow[], set: ContactUpdateFields) =>\n runCrmBulkBatch(\n targets,\n (row) => row.$id,\n contactBulkAddressOf,\n (piece) => contactUpdate.updateMany(piece.map((row) => row.$id), set),\n CRM_CONTACT_UPDATE_MAX,\n ),\n [contactUpdate],\n )\n\n const handleApply = useCallback(async () => {\n if (!pending || !scope) return\n /*\n * A row no site holds has no facet to write. Under a site every selected\n * row is the viewing group's; at the organization level (AGL-2630) each\n * row was flattened through its own primary holder and is written back\n * through it, so a row nobody holds yet is left out and says so.\n */\n const held: ContactBulkRow[] = []\n const unheld: ContactBulkSkip[] = []\n for (const row of selectedRows) {\n if (consentGroup || row.groupId) held.push(row)\n else {\n unheld.push({\n email: contactBulkAddressOf(row),\n reason: 'no site holds this contact yet',\n })\n }\n }\n\n const planned = ((): { selection: ContactBulkSelection; job: () => Promise<CrmBulkOutcome> } | null => {\n if (pending === 'add-tag' || pending === 'remove-tag') {\n const tag = normalizeBulkTag(value)\n if (!tag) return null\n const selection =\n pending === 'add-tag' ? planAddTag(held, tag) : planRemoveTag(held, tag)\n const set: ContactUpdateFields =\n pending === 'add-tag' ? { addTag: tag } : { removeTag: tag }\n return { selection, job: () => saveThroughRoute(selection.rows, set) }\n }\n if (pending === 'owner') {\n return {\n selection: { rows: held, skipped: [] },\n job: () => saveThroughRoute(held, { ownerUid: value }),\n }\n }\n if (pending === 'company') {\n const companyId = company?.id ?? null\n const selection = planSetCompany(held, companyId)\n return { selection, job: () => saveThroughRoute(selection.rows, { companyId }) }\n }\n if (!value) return null\n const stage = value as ContactLifecycleStage\n return {\n selection: { rows: held, skipped: [] },\n /*\n * One row at a time through the one writer of a contact's stage, on\n * the site that holds the row: the mounted site, or at the\n * organization level the row's own holder's.\n */\n job: () =>\n runCrmBulkCalls(held, contactBulkAddressOf, async (row) => {\n const site = hostId ?? (row.holderHostId || null)\n if (!site) throw new Error('no site holds this contact yet')\n await setContactStage(user, site, row.$id, stage)\n }),\n }\n })()\n if (!planned) return\n const action = pending\n setPending(null)\n await apply({\n attempted: planned.selection.rows.length,\n skipped: [...unheld, ...planned.selection.skipped].map(skippedLine),\n job: planned.job,\n done: (count) => doneSentence(action, count),\n })\n }, [\n pending,\n scope,\n selectedRows,\n consentGroup,\n value,\n company,\n saveThroughRoute,\n hostId,\n user,\n apply,\n ])\n\n const handleExport = useCallback(() => {\n downloadTextFile(\n 'contacts-selected.csv',\n 'text/csv',\n contactsCsv(selectedRows, csv),\n )\n }, [selectedRows, csv])\n\n const handleDetach = useCallback(async () => {\n if (!scope || !selectedRows.length || !consentGroup) return\n const count = selectedRows.length\n const confirmed = await confirm({\n title: count === 1 ? 'Remove this contact?' : `Remove ${count} contacts?`,\n description:\n `${count === 1 ? 'This person is' : `These ${count} people are`} ` +\n \"removed from this site's Contacts, along with their notes, tags and \" +\n 'timeline. Other sites that captured the same people keep their own ' +\n 'records. Their form submissions, orders, bookings, and membership ' +\n 'records are separate — delete those from their own pages if the ' +\n 'request covers them.',\n confirmationText: count === 1 ? 'Remove contact' : 'Remove contacts',\n confirmationButtonProps: { color: 'error' },\n })\n // `confirm` resolves with no value and REJECTS on cancel.\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n const outcome = await apply({\n attempted: selectedRows.length,\n skipped: [],\n job: () =>\n runCrmBulkBatch(\n selectedRows,\n (row) => row.$id,\n contactBulkAddressOf,\n (piece) => contactRemove.removeMany(piece.map((row) => row.$id)),\n CRM_CONTACT_REMOVE_MAX,\n ),\n done: (done) => doneSentence('detach', done),\n })\n // The rows that went are gone from the table; the refused ones stay\n // selected, so the reader can see which they are and try again.\n const refused = new Set(outcome.refused.map((row) => row.label))\n onSelectedChange(\n selectedRows\n .filter((row) => refused.has(contactBulkAddressOf(row)))\n .map((row) => row.$id),\n )\n }, [scope, selectedRows, confirm, apply, contactRemove, consentGroup, onSelectedChange])\n\n const emails = selectedRows\n .map((row) => String(row.email ?? '').trim())\n .filter(Boolean)\n\n return (\n <CrmBulkBarFrame\n count={selected.length}\n noun={NOUN}\n busy={busy}\n onClear={() => onSelectedChange([])}\n report={report}\n onDismissReport={dismissReport}\n extras={\n <>\n <CrmBulkValueDialog\n open={pending !== null}\n title={pending ? ACTION_TITLES[pending] : ''}\n count={selected.length}\n noun={NOUN}\n busy={busy}\n canApply={\n !(pending === 'stage' && !value) &&\n !(\n (pending === 'add-tag' || pending === 'remove-tag') &&\n !normalizeBulkTag(value)\n )\n }\n onClose={() => setPending(null)}\n onApply={() => void handleApply()}\n >\n {pending === 'add-tag' || pending === 'remove-tag' ? (\n <TextField\n autoFocus\n size=\"small\"\n label=\"Tag\"\n placeholder=\"vip\"\n value={value}\n onChange={(event) => setValue(event.target.value)}\n helperText={\n pending === 'add-tag'\n ? 'Lowercased, like the tags on a profile'\n : 'Removed wherever it is present'\n }\n />\n ) : pending === 'owner' ? (\n <TextField\n select\n size=\"small\"\n label=\"Owner\"\n value={value}\n onChange={(event) => setValue(event.target.value)}\n error={Boolean(team.error)}\n helperText={team.error ?? (team.ready ? undefined : 'Loading the team…')}\n >\n <MenuItem value=\"\">{'Nobody — clear the owner'}</MenuItem>\n {team.options.map((member) => (\n <MenuItem key={member.uid} value={member.uid}>\n {crmMemberPickerLabel(member)}\n </MenuItem>\n ))}\n </TextField>\n ) : pending === 'stage' ? (\n <TextField\n select\n size=\"small\"\n label=\"Lifecycle stage\"\n value={value}\n onChange={(event) => setValue(event.target.value)}\n >\n {CONTACT_LIFECYCLE_STAGES.map((stage) => (\n <MenuItem key={stage} value={stage}>\n {CONTACT_LIFECYCLE_STAGE_LABELS[stage]}\n </MenuItem>\n ))}\n </TextField>\n ) : pending === 'company' ? (\n <CompanyPicker\n options={companies.options}\n ready={companies.ready}\n truncated={companies.truncated}\n value={company?.id ?? null}\n onChange={(_id, picked) => setCompany(picked)}\n onCreate={createCompany}\n helperText=\"Leave it empty to unlink the selected contacts from their companies.\"\n />\n ) : null}\n </CrmBulkValueDialog>\n {listOpen ? (\n <AddToListDialog\n open\n onClose={() => setListOpen(false)}\n hostId={createHostId}\n scope={scope}\n emails={emails}\n />\n ) : null}\n </>\n }\n >\n <Button size=\"small\" disabled={busy || !scope} onClick={() => openAction('add-tag')}>\n {'Add tag'}\n </Button>\n <Button\n size=\"small\"\n disabled={busy || !scope}\n onClick={() => openAction('remove-tag')}\n >\n {'Remove tag'}\n </Button>\n {suiteLocked ? (\n <>\n <CrmSuiteLockedButton>{'Set owner'}</CrmSuiteLockedButton>\n <CrmSuiteLockedButton>{'Set stage'}</CrmSuiteLockedButton>\n <CrmSuiteLockedButton>{'Set company'}</CrmSuiteLockedButton>\n </>\n ) : (\n <>\n <Button size=\"small\" disabled={busy || !scope} onClick={() => openAction('owner')}>\n {'Set owner'}\n </Button>\n <Button size=\"small\" disabled={busy || !scope} onClick={() => openAction('stage')}>\n {'Set stage'}\n </Button>\n <Button\n size=\"small\"\n disabled={busy || !scope}\n onClick={() => openAction('company')}\n >\n {'Set company'}\n </Button>\n </>\n )}\n <Button\n size=\"small\"\n disabled={busy || !scope || !emails.length || !createHostId}\n onClick={() => setListOpen(true)}\n >\n {'Add to list'}\n </Button>\n <CrmBulkShareButton\n object=\"contacts\"\n ids={selectedRows.map((row) => row.$id)}\n hostId={hostId ?? null}\n orgId={scope?.[1] ?? null}\n disabled={busy}\n />\n <Button size=\"small\" disabled={busy} onClick={handleExport}>\n {'Export CSV'}\n </Button>\n {/*\n The selection's file is the rows on screen; this one is the whole\n collection, streamed by the server (AGL-2662).\n */}\n <CrmExportAllButton\n resource=\"contacts\"\n orgId={scope?.[1] ?? null}\n hostId={hostId}\n disabled={busy}\n />\n {/*\n Only under a site. The act is a DETACH from the viewing site's\n CRM, and at the organization level there is no viewing site — an\n org-wide member removes a person from a site by opening the record\n under that site.\n */}\n {consentGroup ? (\n <Button\n size=\"small\"\n color=\"error\"\n disabled={busy || !scope}\n onClick={() => void handleDetach()}\n >\n {'Remove from this site'}\n </Button>\n ) : null}\n </CrmBulkBarFrame>\n )\n}\nContactsBulkBarBody.displayName = 'ContactsBulkBarBody'\n\nexport default ContactsBulkBar\n"],"names":["CONTACT_LIFECYCLE_STAGE_LABELS","CONTACT_LIFECYCLE_STAGES","crmMemberPickerLabel","useConfirmationContext","Button","MenuItem","TextField","useCallback","useMemo","useState","useOrgMemberOptions","useUser","useContactRemove","useContactUpdate","useCrmBulkApply","useCrmScope","CRM_CONTACT_REMOVE_MAX","CRM_CONTACT_UPDATE_MAX","setContactStage","contactBulkAddressOf","normalizeBulkTag","planAddTag","planRemoveTag","planSetCompany","contactsCsv","downloadTextFile","runCrmBulkBatch","runCrmBulkCalls","AddToListDialog","CompanyPicker","useCompanyOptions","useCreateCompany","CrmBulkBarFrame","CrmBulkValueDialog","countNoun","CrmExportAllButton","CrmBulkShareButton","CrmSuiteLockedButton","NOUN","singular","plural","ACTION_TITLES","owner","stage","company","doneSentence","action","done","people","skippedLine","row","label","email","reason","ContactsBulkBar","props","selected","length","ContactsBulkBarBody","displayName","team","hostId","org","scope","consentGroup","rows","onSelectedChange","csv","suiteLocked","data","user","confirm","busy","report","apply","dismissReport","recordKind","contactUpdate","contactRemove","selectedRows","chosen","Set","filter","has","$id","pending","setPending","value","setValue","setCompany","listOpen","setListOpen","enabled","companies","createCompany","createHostId","openAction","saveThroughRoute","targets","set","piece","updateMany","map","handleApply","held","unheld","groupId","push","planned","tag","selection","addTag","removeTag","job","skipped","ownerUid","companyId","id","site","holderHostId","Error","attempted","count","handleExport","handleDetach","confirmed","title","description","confirmationText","confirmationButtonProps","color","then","catch","outcome","removeMany","refused","emails","String","trim","Boolean","noun","onClear","onDismissReport","extras","open","canApply","onClose","onApply","autoFocus","size","placeholder","onChange","event","target","helperText","select","error","ready","undefined","options","member","uid","truncated","_id","picked","onCreate","disabled","onClick","object","ids","orgId","resource"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CC,GAED,SAEEA,8BAA8B,EAC9BC,wBAAwB,EAGxBC,oBAAoB,QACf,eAAc;AACrB,SAASC,sBAAsB,QAAQ,uBAAsB;AAC7D,SAASC,MAAM,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,gBAAe;AAC3D,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACtD,SAASC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CACtE;;kCAEH,KAAC5F;wBAAOiJ,MAAK;wBAAQiB,UAAU9F,QAAQ,CAACT;wBAAOwG,SAAS,IAAMvE,WAAW;kCACtE;;kCAEH,KAAC5F;wBACCiJ,MAAK;wBACLiB,UAAU9F,QAAQ,CAACT;wBACnBwG,SAAS,IAAMvE,WAAW;kCAEzB;;;;0BAIP,KAAC5F;gBACCiJ,MAAK;gBACLiB,UAAU9F,QAAQ,CAACT,SAAS,CAACyE,OAAO/E,MAAM,IAAI,CAACsC;gBAC/CwE,SAAS,IAAM5E,YAAY;0BAE1B;;0BAEH,KAACvD;gBACCoI,QAAO;gBACPC,KAAK1F,aAAauB,GAAG,CAAC,CAACpD,MAAQA,IAAIkC,GAAG;gBACtCvB,MAAM,EAAEA,iBAAAA,SAAU;gBAClB6G,KAAK,WAAE3G,yBAAAA,KAAO,CAAC,EAAE,oBAAI;gBACrBuG,UAAU9F;;0BAEZ,KAACpE;gBAAOiJ,MAAK;gBAAQiB,UAAU9F;gBAAM+F,SAAS5C;0BAC3C;;0BAMH,KAACxF;gBACCwI,UAAS;gBACTD,KAAK,WAAE3G,yBAAAA,KAAO,CAAC,EAAE,oBAAI;gBACrBF,QAAQA;gBACRyG,UAAU9F;;YAQXR,6BACC,KAAC5D;gBACCiJ,MAAK;gBACLnB,OAAM;gBACNoC,UAAU9F,QAAQ,CAACT;gBACnBwG,SAAS,IAAM,KAAK3C;0BAEnB;iBAED;;;AAGV;AACAlE,oBAAoBC,WAAW,GAAG;AAElC,eAAeL,gBAAe"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/contacts-bulk-bar.tsx"],"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\n/**\n * The bar over the contacts table, for whatever rows are ticked (AGL-2603).\n *\n * The table's selection is opt-in and this is what it is for: a chosen set\n * of people, and one act over all of them. Tag or untag them, hand them to\n * an owner, move them along the funnel, put them on an email audience, take\n * them into a spreadsheet, or let them go from this site's CRM.\n *\n * ## The chrome is the shared frame\n *\n * This bar settled how a bar over a table reads — it appears only for a\n * selection and says how many, its actions sit in one wrapping row with\n * Clear at the end, and whatever the last action could not do is listed by\n * name in an alert under it — and the companies, deals and tasks bars were\n * built on that shape as `CrmBulkBarFrame` and `useCrmBulkApply` (AGL-2621).\n * The contacts bar stands on the same two (AGL-2635): what is its own is the\n * actions, the dialog's field, the audience door, and how each act is sent.\n *\n * ## Each act goes where its field is written (AGL-2804)\n *\n * A contact's tags, owner and company live in the holder's facet, which is\n * the server's to write — the rules cannot tell one field of a facet from\n * another — so each of those acts is ONE request to `crm/contact-update` for\n * the rows it reaches (`contacts-bulk-writes.ts` decides which), sent in\n * pieces the route accepts. A stage move is `crm/contact-stage`, row by row:\n * a move is what an automation listens for, and only the route that\n * performed it can announce it. Letting the rows go is `crm/contact-remove`\n * (AGL-3338): the route decides detach or delete against each stored\n * document and keeps any marketing refusal the person gave.\n *\n * ## A refused row is named\n *\n * Whatever the server or the store refused comes back by address into the\n * alert under the bar — not into a count, and not into the console. A\n * merchant who tagged four hundred people and got three hundred and\n * ninety-eight needs the two addresses.\n *\n * ## Add to list goes through the audience's own door\n *\n * The membership routes, with the check-then-attest sequence the Emails\n * console runs — see `add-to-list-dialog.tsx`. Nothing here writes a\n * membership document.\n */\n\nimport {\n type AglynOrgBilling,\n CONTACT_LIFECYCLE_STAGE_LABELS,\n CONTACT_LIFECYCLE_STAGES,\n type ConsentGroup,\n type ContactLifecycleStage,\n crmMemberPickerLabel,\n} from '@aglyn/aglyn'\nimport { useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport { Button, MenuItem, TextField } from '@mui/material'\nimport { useCallback, useMemo, useState } from 'react'\nimport { useOrgMemberOptions, useUser } from '@aglyn/tenant-feature-instance'\nimport { useContactRemove } from '../hooks/use-contact-remove'\nimport { useContactUpdate } from '../hooks/use-contact-update'\nimport { useCrmBulkApply } from '../hooks/use-crm-bulk-apply'\nimport { useCrmScope } from '../hooks/use-crm-scope'\nimport { CRM_CONTACT_REMOVE_MAX } from '../model/contact-remove'\nimport { CRM_CONTACT_UPDATE_MAX, type ContactUpdateFields } from '../model/contact-update'\nimport { setContactStage } from '../model/crm-api'\nimport {\n contactBulkAddressOf,\n normalizeBulkTag,\n planAddTag,\n planRemoveTag,\n planSetCompany,\n type ContactBulkRow,\n type ContactBulkSelection,\n type ContactBulkSkip,\n} from '../model/contacts-bulk-writes'\nimport {\n type CrmBulkOutcome,\n runCrmBulkBatch,\n runCrmBulkCalls,\n} from '../model/crm-bulk-writes'\nimport AddToListDialog from './add-to-list-dialog'\nimport {\n CompanyPicker,\n type CompanyOption,\n useCompanyOptions,\n useCreateCompany,\n} from './company-picker'\nimport {\n type CrmBulkNoun,\n CrmBulkBarFrame,\n CrmBulkValueDialog,\n countNoun,\n} from './crm-bulk-bar-frame'\nimport { CrmExportButton } from './crm-transfer-buttons'\nimport { CRM_CONTACTS_RESOURCE } from '../transfer/fields'\nimport { CrmBulkShareButton } from './record-sharing-card'\nimport { CrmSuiteLockedButton } from './crm-suite-lock'\n\nexport interface ContactsBulkBarProps {\n /** The site the list is read under, or `null` at the organization level. */\n hostId: string | null\n /** The org document the shell passed, for the company picker's scope. */\n org?: Partial<AglynOrgBilling> | null\n /** `['orgs', orgId]`, or `null` while the org is unresolved. */\n scope: readonly [string, string] | null\n /**\n * The holder these rows are being read AS — whose facet the acts land in.\n * `null` at the organization level (AGL-2630), where each row's own holder\n * (`groupId`) takes the act instead, and \"Remove from this site\" is not\n * offered because there is no site to remove from.\n */\n consentGroup: ConsentGroup | null\n /** The table's rows, already projected through the holder's facet. */\n rows: readonly ContactBulkRow[]\n selected: readonly string[]\n onSelectedChange: (ids: string[]) => void\n /**\n * The org's plan lacks the CRM (AGL-2788), which the shell mounts no CRM\n * page for (AGL-2851). The owner, the stage and the company stand locked;\n * tags, the exports, the audience door and removing people from a site\n * draw no lock of their own.\n */\n suiteLocked?: boolean\n}\n\nconst NOUN: CrmBulkNoun = { singular: 'contact', plural: 'contacts' }\n\n/** The one small dialog the value-taking actions share. */\ntype PendingAction = 'add-tag' | 'remove-tag' | 'owner' | 'stage' | 'company'\n\nconst ACTION_TITLES: Record<PendingAction, string> = {\n 'add-tag': 'Add a tag',\n 'remove-tag': 'Remove a tag',\n owner: 'Set the owner',\n stage: 'Set the lifecycle stage',\n company: 'Set the company',\n}\n\n/** How a finished action reads, given how many rows it reached. */\nconst doneSentence = (action: PendingAction | 'detach', done: number): string => {\n const people = countNoun(done, NOUN)\n switch (action) {\n case 'add-tag':\n return `Tagged ${people}`\n case 'remove-tag':\n return `Removed the tag from ${people}`\n case 'owner':\n return `Owner set on ${people}`\n case 'stage':\n return `Stage set on ${people}`\n case 'company':\n return `Company set on ${people}`\n case 'detach':\n return `${people} removed from this site`\n }\n}\n\n/** The report's line for a row an act left out on purpose. */\nconst skippedLine = (row: ContactBulkSkip) => ({ label: row.email, reason: row.reason })\n\n/**\n * The bar, or nothing.\n *\n * The empty state is a separate component boundary on purpose: with no\n * selection the body below is never mounted, so none of its hooks run — no\n * roster hook armed, no dialog state held — on the visit to the list that\n * every reader makes and most never tick a row on.\n */\nexport function ContactsBulkBar(props: ContactsBulkBarProps) {\n if (!props.selected.length) return null\n return <ContactsBulkBarBody {...props} />\n}\nContactsBulkBar.displayName = 'ContactsBulkBar'\n\nfunction ContactsBulkBarBody(props: ContactsBulkBarProps) {\n const {\n hostId,\n org,\n scope,\n consentGroup,\n rows,\n selected,\n onSelectedChange,\n suiteLocked = false,\n } = props\n const { data: user } = useUser()\n const { confirm } = useConfirmationContext()\n const { busy, report, apply, dismissReport } = useCrmBulkApply({ recordKind: 'contact' })\n const contactUpdate = useContactUpdate(hostId)\n const contactRemove = useContactRemove(hostId)\n\n const selectedRows = useMemo(() => {\n const chosen = new Set(selected)\n return rows.filter((row) => chosen.has(row.$id))\n }, [rows, selected])\n\n const [pending, setPending] = useState<PendingAction | null>(null)\n const [value, setValue] = useState('')\n const [company, setCompany] = useState<CompanyOption | null>(null)\n const [listOpen, setListOpen] = useState(false)\n\n /*\n * The roster, read only while the owner dialog is open. A bulk bar sits on\n * every visit to the list; the team is a request for a control nobody has\n * opened until they open it. The company list follows the same rule for\n * its own dialog (AGL-2613).\n */\n const team = useOrgMemberOptions(scope?.[1], { enabled: pending === 'owner' })\n const companies = useCompanyOptions({\n hostId,\n org,\n enabled: pending === 'company',\n })\n const createCompany = useCreateCompany({ hostId, org })\n // The site the audiences API is asked from: the mounted one, or at the\n // organization level the one the reader picked (AGL-2630).\n const { createHostId } = useCrmScope({ hostId, org })\n\n const openAction = (action: PendingAction) => {\n setValue('')\n setCompany(null)\n setPending(action)\n }\n\n /** One act's request for the rows it reaches, in the pieces the route accepts. */\n const saveThroughRoute = useCallback(\n (targets: readonly ContactBulkRow[], set: ContactUpdateFields) =>\n runCrmBulkBatch(\n targets,\n (row) => row.$id,\n contactBulkAddressOf,\n (piece) => contactUpdate.updateMany(piece.map((row) => row.$id), set),\n CRM_CONTACT_UPDATE_MAX,\n ),\n [contactUpdate],\n )\n\n const handleApply = useCallback(async () => {\n if (!pending || !scope) return\n /*\n * A row no site holds has no facet to write. Under a site every selected\n * row is the viewing group's; at the organization level (AGL-2630) each\n * row was flattened through its own primary holder and is written back\n * through it, so a row nobody holds yet is left out and says so.\n */\n const held: ContactBulkRow[] = []\n const unheld: ContactBulkSkip[] = []\n for (const row of selectedRows) {\n if (consentGroup || row.groupId) held.push(row)\n else {\n unheld.push({\n email: contactBulkAddressOf(row),\n reason: 'no site holds this contact yet',\n })\n }\n }\n\n const planned = ((): { selection: ContactBulkSelection; job: () => Promise<CrmBulkOutcome> } | null => {\n if (pending === 'add-tag' || pending === 'remove-tag') {\n const tag = normalizeBulkTag(value)\n if (!tag) return null\n const selection =\n pending === 'add-tag' ? planAddTag(held, tag) : planRemoveTag(held, tag)\n const set: ContactUpdateFields =\n pending === 'add-tag' ? { addTag: tag } : { removeTag: tag }\n return { selection, job: () => saveThroughRoute(selection.rows, set) }\n }\n if (pending === 'owner') {\n return {\n selection: { rows: held, skipped: [] },\n job: () => saveThroughRoute(held, { ownerUid: value }),\n }\n }\n if (pending === 'company') {\n const companyId = company?.id ?? null\n const selection = planSetCompany(held, companyId)\n return { selection, job: () => saveThroughRoute(selection.rows, { companyId }) }\n }\n if (!value) return null\n const stage = value as ContactLifecycleStage\n return {\n selection: { rows: held, skipped: [] },\n /*\n * One row at a time through the one writer of a contact's stage, on\n * the site that holds the row: the mounted site, or at the\n * organization level the row's own holder's.\n */\n job: () =>\n runCrmBulkCalls(held, contactBulkAddressOf, async (row) => {\n const site = hostId ?? (row.holderHostId || null)\n if (!site) throw new Error('no site holds this contact yet')\n await setContactStage(user, site, row.$id, stage)\n }),\n }\n })()\n if (!planned) return\n const action = pending\n setPending(null)\n await apply({\n attempted: planned.selection.rows.length,\n skipped: [...unheld, ...planned.selection.skipped].map(skippedLine),\n job: planned.job,\n done: (count) => doneSentence(action, count),\n })\n }, [\n pending,\n scope,\n selectedRows,\n consentGroup,\n value,\n company,\n saveThroughRoute,\n hostId,\n user,\n apply,\n ])\n\n const handleDetach = useCallback(async () => {\n if (!scope || !selectedRows.length || !consentGroup) return\n const count = selectedRows.length\n const confirmed = await confirm({\n title: count === 1 ? 'Remove this contact?' : `Remove ${count} contacts?`,\n description:\n `${count === 1 ? 'This person is' : `These ${count} people are`} ` +\n \"removed from this site's Contacts, along with their notes, tags and \" +\n 'timeline. Other sites that captured the same people keep their own ' +\n 'records. Their form submissions, orders, bookings, and membership ' +\n 'records are separate — delete those from their own pages if the ' +\n 'request covers them.',\n confirmationText: count === 1 ? 'Remove contact' : 'Remove contacts',\n confirmationButtonProps: { color: 'error' },\n })\n // `confirm` resolves with no value and REJECTS on cancel.\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n const outcome = await apply({\n attempted: selectedRows.length,\n skipped: [],\n job: () =>\n runCrmBulkBatch(\n selectedRows,\n (row) => row.$id,\n contactBulkAddressOf,\n (piece) => contactRemove.removeMany(piece.map((row) => row.$id)),\n CRM_CONTACT_REMOVE_MAX,\n ),\n done: (done) => doneSentence('detach', done),\n })\n // The rows that went are gone from the table; the refused ones stay\n // selected, so the reader can see which they are and try again.\n const refused = new Set(outcome.refused.map((row) => row.label))\n onSelectedChange(\n selectedRows\n .filter((row) => refused.has(contactBulkAddressOf(row)))\n .map((row) => row.$id),\n )\n }, [scope, selectedRows, confirm, apply, contactRemove, consentGroup, onSelectedChange])\n\n const emails = selectedRows\n .map((row) => String(row.email ?? '').trim())\n .filter(Boolean)\n\n return (\n <CrmBulkBarFrame\n count={selected.length}\n noun={NOUN}\n busy={busy}\n onClear={() => onSelectedChange([])}\n report={report}\n onDismissReport={dismissReport}\n extras={\n <>\n <CrmBulkValueDialog\n open={pending !== null}\n title={pending ? ACTION_TITLES[pending] : ''}\n count={selected.length}\n noun={NOUN}\n busy={busy}\n canApply={\n !(pending === 'stage' && !value) &&\n !(\n (pending === 'add-tag' || pending === 'remove-tag') &&\n !normalizeBulkTag(value)\n )\n }\n onClose={() => setPending(null)}\n onApply={() => void handleApply()}\n >\n {pending === 'add-tag' || pending === 'remove-tag' ? (\n <TextField\n autoFocus\n size=\"small\"\n label=\"Tag\"\n placeholder=\"vip\"\n value={value}\n onChange={(event) => setValue(event.target.value)}\n helperText={\n pending === 'add-tag'\n ? 'Lowercased, like the tags on a profile'\n : 'Removed wherever it is present'\n }\n />\n ) : pending === 'owner' ? (\n <TextField\n select\n size=\"small\"\n label=\"Owner\"\n value={value}\n onChange={(event) => setValue(event.target.value)}\n error={Boolean(team.error)}\n helperText={team.error ?? (team.ready ? undefined : 'Loading the team…')}\n >\n <MenuItem value=\"\">{'Nobody — clear the owner'}</MenuItem>\n {team.options.map((member) => (\n <MenuItem key={member.uid} value={member.uid}>\n {crmMemberPickerLabel(member)}\n </MenuItem>\n ))}\n </TextField>\n ) : pending === 'stage' ? (\n <TextField\n select\n size=\"small\"\n label=\"Lifecycle stage\"\n value={value}\n onChange={(event) => setValue(event.target.value)}\n >\n {CONTACT_LIFECYCLE_STAGES.map((stage) => (\n <MenuItem key={stage} value={stage}>\n {CONTACT_LIFECYCLE_STAGE_LABELS[stage]}\n </MenuItem>\n ))}\n </TextField>\n ) : pending === 'company' ? (\n <CompanyPicker\n options={companies.options}\n ready={companies.ready}\n truncated={companies.truncated}\n value={company?.id ?? null}\n onChange={(_id, picked) => setCompany(picked)}\n onCreate={createCompany}\n helperText=\"Leave it empty to unlink the selected contacts from their companies.\"\n />\n ) : null}\n </CrmBulkValueDialog>\n {listOpen ? (\n <AddToListDialog\n open\n onClose={() => setListOpen(false)}\n hostId={createHostId}\n scope={scope}\n emails={emails}\n />\n ) : null}\n </>\n }\n >\n <Button size=\"small\" disabled={busy || !scope} onClick={() => openAction('add-tag')}>\n {'Add tag'}\n </Button>\n <Button\n size=\"small\"\n disabled={busy || !scope}\n onClick={() => openAction('remove-tag')}\n >\n {'Remove tag'}\n </Button>\n {suiteLocked ? (\n <>\n <CrmSuiteLockedButton>{'Set owner'}</CrmSuiteLockedButton>\n <CrmSuiteLockedButton>{'Set stage'}</CrmSuiteLockedButton>\n <CrmSuiteLockedButton>{'Set company'}</CrmSuiteLockedButton>\n </>\n ) : (\n <>\n <Button size=\"small\" disabled={busy || !scope} onClick={() => openAction('owner')}>\n {'Set owner'}\n </Button>\n <Button size=\"small\" disabled={busy || !scope} onClick={() => openAction('stage')}>\n {'Set stage'}\n </Button>\n <Button\n size=\"small\"\n disabled={busy || !scope}\n onClick={() => openAction('company')}\n >\n {'Set company'}\n </Button>\n </>\n )}\n <Button\n size=\"small\"\n disabled={busy || !scope || !emails.length || !createHostId}\n onClick={() => setListOpen(true)}\n >\n {'Add to list'}\n </Button>\n <CrmBulkShareButton\n object=\"contacts\"\n ids={selectedRows.map((row) => row.$id)}\n hostId={hostId ?? null}\n orgId={scope?.[1] ?? null}\n disabled={busy}\n />\n {/* The selection through the export dialog: every field, chosen (AGL-3527). */}\n <CrmExportButton\n resource={CRM_CONTACTS_RESOURCE}\n hostId={hostId}\n selection={selectedRows.map((row) => row.$id)}\n disabled={busy}\n />\n {/*\n Only under a site. The act is a DETACH from the viewing site's\n CRM, and at the organization level there is no viewing site — an\n org-wide member removes a person from a site by opening the record\n under that site.\n */}\n {consentGroup ? (\n <Button\n size=\"small\"\n color=\"error\"\n disabled={busy || !scope}\n onClick={() => void handleDetach()}\n >\n {'Remove from this site'}\n </Button>\n ) : null}\n </CrmBulkBarFrame>\n )\n}\nContactsBulkBarBody.displayName = 'ContactsBulkBarBody'\n\nexport default ContactsBulkBar\n"],"names":["CONTACT_LIFECYCLE_STAGE_LABELS","CONTACT_LIFECYCLE_STAGES","crmMemberPickerLabel","useConfirmationContext","Button","MenuItem","TextField","useCallback","useMemo","useState","useOrgMemberOptions","useUser","useContactRemove","useContactUpdate","useCrmBulkApply","useCrmScope","CRM_CONTACT_REMOVE_MAX","CRM_CONTACT_UPDATE_MAX","setContactStage","contactBulkAddressOf","normalizeBulkTag","planAddTag","planRemoveTag","planSetCompany","runCrmBulkBatch","runCrmBulkCalls","AddToListDialog","CompanyPicker","useCompanyOptions","useCreateCompany","CrmBulkBarFrame","CrmBulkValueDialog","countNoun","CrmExportButton","CRM_CONTACTS_RESOURCE","CrmBulkShareButton","CrmSuiteLockedButton","NOUN","singular","plural","ACTION_TITLES","owner","stage","company","doneSentence","action","done","people","skippedLine","row","label","email","reason","ContactsBulkBar","props","selected","length","ContactsBulkBarBody","displayName","team","hostId","org","scope","consentGroup","rows","onSelectedChange","suiteLocked","data","user","confirm","busy","report","apply","dismissReport","recordKind","contactUpdate","contactRemove","selectedRows","chosen","Set","filter","has","$id","pending","setPending","value","setValue","setCompany","listOpen","setListOpen","enabled","companies","createCompany","createHostId","openAction","saveThroughRoute","targets","set","piece","updateMany","map","handleApply","held","unheld","groupId","push","planned","tag","selection","addTag","removeTag","job","skipped","ownerUid","companyId","id","site","holderHostId","Error","attempted","count","handleDetach","confirmed","title","description","confirmationText","confirmationButtonProps","color","then","catch","outcome","removeMany","refused","emails","String","trim","Boolean","noun","onClear","onDismissReport","extras","open","canApply","onClose","onApply","autoFocus","size","placeholder","onChange","event","target","helperText","select","error","ready","undefined","options","member","uid","truncated","_id","picked","onCreate","disabled","onClick","object","ids","orgId","resource"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CC,GAED,SAEEA,8BAA8B,EAC9BC,wBAAwB,EAGxBC,oBAAoB,QACf,eAAc;AACrB,SAASC,sBAAsB,QAAQ,uBAAsB;AAC7D,SAASC,MAAM,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,gBAAe;AAC3D,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACtD,SAASC,mBAAmB,EAAEC,OAAO,QAAQ,iCAAgC;AAC7E,SAASC,gBAAgB,QAAQ,iCAA6B;AAC9D,SAASC,gBAAgB,QAAQ,iCAA6B;AAC9D,SAASC,eAAe,QAAQ,iCAA6B;AAC7D,SAASC,WAAW,QAAQ,4BAAwB;AACpD,SAASC,sBAAsB,QAAQ,6BAAyB;AAChE,SAASC,sBAAsB,QAAkC,6BAAyB;AAC1F,SAASC,eAAe,QAAQ,sBAAkB;AAClD,SACEC,oBAAoB,EACpBC,gBAAgB,EAChBC,UAAU,EACVC,aAAa,EACbC,cAAc,QAIT,mCAA+B;AACtC,SAEEC,eAAe,EACfC,eAAe,QACV,8BAA0B;AACjC,OAAOC,qBAAqB,0BAAsB;AAClD,SACEC,aAAa,EAEbC,iBAAiB,EACjBC,g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ACRgD,WAAW/B,aAAauB,GAAG,CAAC,CAACnD,MAAQA,IAAIiC,GAAG;gBAC5CiF,UAAU7F;;YAQXP,6BACC,KAAC3D;gBACC8I,MAAK;gBACLnB,OAAM;gBACNoC,UAAU7F,QAAQ,CAACR;gBACnBsG,SAAS,IAAM,KAAK3C;0BAEnB;iBAED;;;AAGV;AACAhE,oBAAoBC,WAAW,GAAG;AAElC,eAAeL,gBAAe"}
@@ -22,7 +22,7 @@ import { hiddenFilterVisibility } from "@aglyn/shared-ui-jsx/const/list-filter";
22
22
  import { ListTable } from "@aglyn/shared-ui-jsx/components/list-table.component";
23
23
  import { ListPagination } from "@aglyn/shared-ui-jsx/components/list-pagination.component";
24
24
  import ListQueryNotices from "@aglyn/shared-ui-jsx/components/list-query-notices.component";
25
- import { CONTACT_LIST_DECLARATION, CONTACT_LIST_FILTER_FIELDS, CONTACT_LIST_FILTER_HEADERS, CONTACT_PREFIX_SEARCH, contactClauseImpliesScope, contactSoloClause, contactCustomFilterFields, contactCustomFilterHeaders, contactQueryClause } from "../constants/contact-filters.js";
25
+ import { CONTACT_LEAD_SOURCE_COLUMN, CONTACT_LIST_DECLARATION, CONTACT_LIST_FILTER_FIELDS, CONTACT_LIST_FILTER_HEADERS, CONTACT_PREFIX_SEARCH, contactClauseImpliesScope, contactSoloClause, contactCustomFilterFields, contactCustomFilterHeaders, contactQueryClause } from "../constants/contact-filters.js";
26
26
  import { crmAskClauses, crmQueryRefusals } from "../model/crm-list-query.js";
27
27
  import { useCrmFoldsScope, useCrmListQuery } from "../hooks/use-crm-list-query.js";
28
28
  import { contactPrimaryGroup, contactRecordFromDoc } from "../model/contact-record.js";
@@ -32,13 +32,13 @@ import { crmShareChipLabel } from "../model/crm-sharing.js";
32
32
  import { useCrmScope } from "../hooks/use-crm-scope.js";
33
33
  import { contactsListSeed } from "../model/contacts-list-seed.js";
34
34
  import { crmRoutes } from "../model/crm-routes.js";
35
- import { contactsCsv, downloadTextFile } from "../model/contacts-csv.js";
35
+ import { CRM_CONTACTS_RESOURCE } from "../transfer/fields.js";
36
36
  import { useCrmRecordsQuota } from "../hooks/use-crm-records-quota.js";
37
37
  import { CardDisplay } from "@aglyn/shared-ui-jsx";
38
38
  import EmptyStateComponent from "@aglyn/shared-ui-jsx/components/empty-state.component";
39
39
  import ContactsBulkBar from "./contacts-bulk-bar.js";
40
40
  import { CrmListActions } from "./crm-list-toolbar.js";
41
- import { ContactImportButton } from "./contact-import-drawer.js";
41
+ import { CrmExportButton, CrmImportButton } from "./crm-transfer-buttons.js";
42
42
  import { useSnackbar } from "@aglyn/shared-ui-snackstack";
43
43
  import { useFirestore, useFirestoreCollection, useFirestoreDoc, useUser } from "@aglyn/tenant-feature-instance";
44
44
  import { Alert, Button, Dialog, DialogActions, DialogContent, DialogTitle, Stack, TextField, Typography } from "@mui/material";
@@ -51,6 +51,7 @@ import NewContactDrawer from "./new-contact-drawer.js";
51
51
  import { useCrmApi } from "./use-crm-api.js";
52
52
  import { useOrgMembers } from "./use-org-members.js";
53
53
  import { useContactFieldDefinitions } from "../hooks/use-contact-field-definitions.js";
54
+ import { useLeadSourcePicklist } from "../hooks/use-lead-source-picklist.js";
54
55
  import { customFieldColumns } from "./contact-custom-columns.js";
55
56
  import { useCrmSavedView } from "../hooks/use-crm-saved-view.js";
56
57
  import { useCrmViewGrid } from "../hooks/use-crm-view-grid.js";
@@ -163,6 +164,8 @@ import { CrmSuiteLockedButton, CrmSuiteNotice, crmSuiteIncluded } from "./crm-su
163
164
  const mount = useCrmOrgMount();
164
165
  // The org's custom fields, for the optional columns below (AGL-2601).
165
166
  const customFields = useContactFieldDefinitions((_ref2 = dataScope == null ? void 0 : dataScope[1]) != null ? _ref2 : null);
167
+ // The org's lead source values, the Lead source filter's choices (AGL-3511).
168
+ const leadSourceList = useLeadSourcePicklist(orgId);
166
169
  /*==========================================
167
170
  * THE CONTROLLER THIS PAGE IS SHOWING.
168
171
  *
@@ -502,6 +505,11 @@ import { CrmSuiteLockedButton, CrmSuiteNotice, crmSuiteIncluded } from "./crm-su
502
505
  value: company.id,
503
506
  label: company.name
504
507
  })),
508
+ // Every value the org keeps, inactive ones marked, as the Leads list offers them.
509
+ [CONTACT_LEAD_SOURCE_COLUMN]: leadSourceList.picklist.values.map((value)=>({
510
+ value: value.label,
511
+ label: value.active ? value.label : `${value.label} (inactive)`
512
+ })),
505
513
  // The verdict on the address (AGL-3245): "Email is bounced".
506
514
  emailState: Aglyn.EMAIL_STATE_STATUSES.map((status)=>({
507
515
  value: status,
@@ -523,7 +531,8 @@ import { CrmSuiteLockedButton, CrmSuiteNotice, crmSuiteIncluded } from "./crm-su
523
531
  uid,
524
532
  members.options,
525
533
  companies.options,
526
- customFields.active
534
+ customFields.active,
535
+ leadSourceList.picklist
527
536
  ]);
528
537
  // What the query could not hold, named by the clause the reader set.
529
538
  const refused = useMemo(()=>crmQueryRefusals(paged.plan, asked, {
@@ -665,6 +674,18 @@ import { CrmSuiteLockedButton, CrmSuiteNotice, crmSuiteIncluded } from "./crm-su
665
674
  email: values.email
666
675
  }, values.name ? {
667
676
  name: values.name
677
+ } : {}, values.salutation ? {
678
+ salutation: values.salutation
679
+ } : {}, values.firstName ? {
680
+ firstName: values.firstName
681
+ } : {}, values.lastName ? {
682
+ lastName: values.lastName
683
+ } : {}, values.mobilePhone ? {
684
+ mobilePhone: values.mobilePhone
685
+ } : {}, values.department ? {
686
+ department: values.department
687
+ } : {}, values.doNotCall ? {
688
+ doNotCall: true
668
689
  } : {}, values.phone ? {
669
690
  phone: values.phone
670
691
  } : {}, values.jobTitle ? {
@@ -717,23 +738,13 @@ import { CrmSuiteLockedButton, CrmSuiteNotice, crmSuiteIncluded } from "./crm-su
717
738
  router,
718
739
  routes
719
740
  ]);
720
- /*
721
- * The file is `contactsCsv()`'s — every CRM column, the owner by address,
722
- * one column per custom field — and the same options reach the bulk bar,
723
- * so the table's export and the selection's are one file over two row
724
- * sets (AGL-2621).
725
- */ const csvOptions = useMemo(()=>({
726
- ownerEmail: members.memberEmail,
727
- customFields: customFields.active
728
- }), [
729
- members.memberEmail,
730
- customFields.active
731
- ]);
732
- const handleExport = useCallback(()=>{
733
- downloadTextFile('contacts.csv', 'text/csv', contactsCsv(contacts, csvOptions));
734
- }, [
735
- contacts,
736
- csvOptions
741
+ // The list's filter, when one narrows it, for the export to read the same
742
+ // records the list does (AGL-3527).
743
+ const exportFilter = useMemo(()=>paged.plan.served.length || paged.plan.searched ? {
744
+ label: 'what the list shows',
745
+ plan: paged.plan
746
+ } : null, [
747
+ paged.plan
737
748
  ]);
738
749
  return /*#__PURE__*/ _jsxs(_Fragment, {
739
750
  children: [
@@ -751,17 +762,18 @@ import { CrmSuiteLockedButton, CrmSuiteNotice, crmSuiteIncluded } from "./crm-su
751
762
  // The record actions, top right and never clipped (AGL-3311).
752
763
  action: /*#__PURE__*/ _jsxs(CrmListActions, {
753
764
  children: [
754
- suiteIncluded ? /*#__PURE__*/ _jsx(ContactImportButton, {
765
+ suiteIncluded ? /*#__PURE__*/ _jsx(CrmImportButton, {
766
+ resource: CRM_CONTACTS_RESOURCE,
767
+ noun: "contacts",
755
768
  hostId: hostId,
756
- org: org
769
+ mappingZone: "contacts"
757
770
  }) : /*#__PURE__*/ _jsx(CrmSuiteLockedButton, {
758
- children: 'Import CSV'
771
+ children: 'Import'
759
772
  }),
760
- /*#__PURE__*/ _jsx(Button, {
761
- size: "small",
762
- onClick: handleExport,
763
- disabled: !contacts.length,
764
- children: 'Export CSV'
773
+ /*#__PURE__*/ _jsx(CrmExportButton, {
774
+ resource: CRM_CONTACTS_RESOURCE,
775
+ hostId: hostId,
776
+ filter: exportFilter
765
777
  }),
766
778
  suiteIncluded ? /*#__PURE__*/ _jsx(Button, {
767
779
  size: "small",
@@ -863,7 +875,7 @@ import { CrmSuiteLockedButton, CrmSuiteNotice, crmSuiteIncluded } from "./crm-su
863
875
  children: 'New contact'
864
876
  }),
865
877
  /*#__PURE__*/ _jsx(CrmSuiteLockedButton, {
866
- children: 'Import CSV'
878
+ children: 'Import'
867
879
  })
868
880
  ]
869
881
  }) : /*#__PURE__*/ _jsxs(Stack, {
@@ -881,9 +893,11 @@ import { CrmSuiteLockedButton, CrmSuiteNotice, crmSuiteIncluded } from "./crm-su
881
893
  },
882
894
  children: 'New contact'
883
895
  }),
884
- /*#__PURE__*/ _jsx(ContactImportButton, {
896
+ /*#__PURE__*/ _jsx(CrmImportButton, {
897
+ resource: CRM_CONTACTS_RESOURCE,
898
+ noun: "contacts",
885
899
  hostId: hostId,
886
- org: org
900
+ mappingZone: "contacts"
887
901
  })
888
902
  ]
889
903
  })
@@ -897,7 +911,6 @@ import { CrmSuiteLockedButton, CrmSuiteNotice, crmSuiteIncluded } from "./crm-su
897
911
  rows: contacts,
898
912
  selected: selectedIds,
899
913
  onSelectedChange: setSelectedIds,
900
- csv: csvOptions,
901
914
  suiteLocked: !suiteIncluded
902
915
  }),
903
916
  /*#__PURE__*/ _jsx(CrmColumnOrderProvider, {