@erxes/api-shared 0.0.0-stage → 3.2.19-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (758) hide show
  1. package/LICENSE.md +672 -0
  2. package/core-modules/dist/erxes-api-shared-core-modules.cjs.d.ts +2 -0
  3. package/core-modules/dist/erxes-api-shared-core-modules.cjs.dev.js +6685 -0
  4. package/core-modules/dist/erxes-api-shared-core-modules.cjs.js +7 -0
  5. package/core-modules/dist/erxes-api-shared-core-modules.cjs.prod.js +6685 -0
  6. package/core-modules/dist/erxes-api-shared-core-modules.esm.js +6298 -0
  7. package/core-modules/package.json +5 -0
  8. package/core-types/dist/erxes-api-shared-core-types.cjs.d.ts +2 -0
  9. package/core-types/dist/erxes-api-shared-core-types.cjs.dev.js +12 -0
  10. package/core-types/dist/erxes-api-shared-core-types.cjs.js +7 -0
  11. package/core-types/dist/erxes-api-shared-core-types.cjs.prod.js +12 -0
  12. package/core-types/dist/erxes-api-shared-core-types.esm.js +8 -0
  13. package/core-types/package.json +5 -0
  14. package/dist/declarations/src/core-modules/approval/approvalChangeTypes.d.ts +15 -0
  15. package/dist/declarations/src/core-modules/approval/approvalChangeTypes.d.ts.map +1 -0
  16. package/dist/declarations/src/core-modules/approval/checkApprovalLock.d.ts +7 -0
  17. package/dist/declarations/src/core-modules/approval/checkApprovalLock.d.ts.map +1 -0
  18. package/dist/declarations/src/core-modules/approval/constants.d.ts +37 -0
  19. package/dist/declarations/src/core-modules/approval/constants.d.ts.map +1 -0
  20. package/dist/declarations/src/core-modules/approval/index.d.ts +7 -0
  21. package/dist/declarations/src/core-modules/approval/index.d.ts.map +1 -0
  22. package/dist/declarations/src/core-modules/approval/initApproval.d.ts +9 -0
  23. package/dist/declarations/src/core-modules/approval/initApproval.d.ts.map +1 -0
  24. package/dist/declarations/src/core-modules/approval/types.d.ts +164 -0
  25. package/dist/declarations/src/core-modules/approval/types.d.ts.map +1 -0
  26. package/dist/declarations/src/core-modules/approval/zodSchemas.d.ts +125 -0
  27. package/dist/declarations/src/core-modules/approval/zodSchemas.d.ts.map +1 -0
  28. package/dist/declarations/src/core-modules/apps/@types/app.d.ts +15 -0
  29. package/dist/declarations/src/core-modules/apps/@types/app.d.ts.map +1 -0
  30. package/dist/declarations/src/core-modules/apps/db/definitions/apps.d.ts +13 -0
  31. package/dist/declarations/src/core-modules/apps/db/definitions/apps.d.ts.map +1 -0
  32. package/dist/declarations/src/core-modules/apps/index.d.ts +3 -0
  33. package/dist/declarations/src/core-modules/apps/index.d.ts.map +1 -0
  34. package/dist/declarations/src/core-modules/automations/actionErrorPolicy.d.ts +68 -0
  35. package/dist/declarations/src/core-modules/automations/actionErrorPolicy.d.ts.map +1 -0
  36. package/dist/declarations/src/core-modules/automations/actionOutcome.d.ts +51 -0
  37. package/dist/declarations/src/core-modules/automations/actionOutcome.d.ts.map +1 -0
  38. package/dist/declarations/src/core-modules/automations/constants.d.ts +101 -0
  39. package/dist/declarations/src/core-modules/automations/constants.d.ts.map +1 -0
  40. package/dist/declarations/src/core-modules/automations/definitions/aiAgents.d.ts +141 -0
  41. package/dist/declarations/src/core-modules/automations/definitions/aiAgents.d.ts.map +1 -0
  42. package/dist/declarations/src/core-modules/automations/definitions/automations.d.ts +868 -0
  43. package/dist/declarations/src/core-modules/automations/definitions/automations.d.ts.map +1 -0
  44. package/dist/declarations/src/core-modules/automations/definitions/executions.d.ts +316 -0
  45. package/dist/declarations/src/core-modules/automations/definitions/executions.d.ts.map +1 -0
  46. package/dist/declarations/src/core-modules/automations/definitions/index.d.ts +4 -0
  47. package/dist/declarations/src/core-modules/automations/definitions/index.d.ts.map +1 -0
  48. package/dist/declarations/src/core-modules/automations/index.d.ts +14 -0
  49. package/dist/declarations/src/core-modules/automations/index.d.ts.map +1 -0
  50. package/dist/declarations/src/core-modules/automations/outputResolvers.d.ts +67 -0
  51. package/dist/declarations/src/core-modules/automations/outputResolvers.d.ts.map +1 -0
  52. package/dist/declarations/src/core-modules/automations/reEnrollment.d.ts +23 -0
  53. package/dist/declarations/src/core-modules/automations/reEnrollment.d.ts.map +1 -0
  54. package/dist/declarations/src/core-modules/automations/segmentMembership.d.ts +19 -0
  55. package/dist/declarations/src/core-modules/automations/segmentMembership.d.ts.map +1 -0
  56. package/dist/declarations/src/core-modules/automations/sendAutomationMessage.d.ts +51 -0
  57. package/dist/declarations/src/core-modules/automations/sendAutomationMessage.d.ts.map +1 -0
  58. package/dist/declarations/src/core-modules/automations/setupAutomationProducers.d.ts +4 -0
  59. package/dist/declarations/src/core-modules/automations/setupAutomationProducers.d.ts.map +1 -0
  60. package/dist/declarations/src/core-modules/automations/typeUtils.d.ts +2 -0
  61. package/dist/declarations/src/core-modules/automations/typeUtils.d.ts.map +1 -0
  62. package/dist/declarations/src/core-modules/automations/types.d.ts +474 -0
  63. package/dist/declarations/src/core-modules/automations/types.d.ts.map +1 -0
  64. package/dist/declarations/src/core-modules/automations/utils.d.ts +38 -0
  65. package/dist/declarations/src/core-modules/automations/utils.d.ts.map +1 -0
  66. package/dist/declarations/src/core-modules/automations/workflowValidation.d.ts +3 -0
  67. package/dist/declarations/src/core-modules/automations/workflowValidation.d.ts.map +1 -0
  68. package/dist/declarations/src/core-modules/automations/zodTypes.d.ts +2366 -0
  69. package/dist/declarations/src/core-modules/automations/zodTypes.d.ts.map +1 -0
  70. package/dist/declarations/src/core-modules/client-portals/definitions/clientPortal.d.ts +375 -0
  71. package/dist/declarations/src/core-modules/client-portals/definitions/clientPortal.d.ts.map +1 -0
  72. package/dist/declarations/src/core-modules/client-portals/definitions/comment.d.ts +53 -0
  73. package/dist/declarations/src/core-modules/client-portals/definitions/comment.d.ts.map +1 -0
  74. package/dist/declarations/src/core-modules/client-portals/definitions/cpNotification.d.ts +110 -0
  75. package/dist/declarations/src/core-modules/client-portals/definitions/cpNotification.d.ts.map +1 -0
  76. package/dist/declarations/src/core-modules/client-portals/definitions/cpUser.d.ts +828 -0
  77. package/dist/declarations/src/core-modules/client-portals/definitions/cpUser.d.ts.map +1 -0
  78. package/dist/declarations/src/core-modules/client-portals/index.d.ts +5 -0
  79. package/dist/declarations/src/core-modules/client-portals/index.d.ts.map +1 -0
  80. package/dist/declarations/src/core-modules/common/db/definitions/common.d.ts +77 -0
  81. package/dist/declarations/src/core-modules/common/db/definitions/common.d.ts.map +1 -0
  82. package/dist/declarations/src/core-modules/common/eventHandlers/createEventHandlers.d.ts +8 -0
  83. package/dist/declarations/src/core-modules/common/eventHandlers/createEventHandlers.d.ts.map +1 -0
  84. package/dist/declarations/src/core-modules/common/eventHandlers/generateEventHandlers.d.ts +4 -0
  85. package/dist/declarations/src/core-modules/common/eventHandlers/generateEventHandlers.d.ts.map +1 -0
  86. package/dist/declarations/src/core-modules/common/eventHandlers/index.d.ts +5 -0
  87. package/dist/declarations/src/core-modules/common/eventHandlers/index.d.ts.map +1 -0
  88. package/dist/declarations/src/core-modules/common/eventHandlers/runtimeContext.d.ts +9 -0
  89. package/dist/declarations/src/core-modules/common/eventHandlers/runtimeContext.d.ts.map +1 -0
  90. package/dist/declarations/src/core-modules/common/eventHandlers/schemas.d.ts +82 -0
  91. package/dist/declarations/src/core-modules/common/eventHandlers/schemas.d.ts.map +1 -0
  92. package/dist/declarations/src/core-modules/common/eventHandlers/types.d.ts +87 -0
  93. package/dist/declarations/src/core-modules/common/eventHandlers/types.d.ts.map +1 -0
  94. package/dist/declarations/src/core-modules/common/index.d.ts +5 -0
  95. package/dist/declarations/src/core-modules/common/index.d.ts.map +1 -0
  96. package/dist/declarations/src/core-modules/common/references/getRecordReferenceFields.d.ts +57 -0
  97. package/dist/declarations/src/core-modules/common/references/getRecordReferenceFields.d.ts.map +1 -0
  98. package/dist/declarations/src/core-modules/common/references/index.d.ts +6 -0
  99. package/dist/declarations/src/core-modules/common/references/index.d.ts.map +1 -0
  100. package/dist/declarations/src/core-modules/common/references/initRecordReferences.d.ts +4 -0
  101. package/dist/declarations/src/core-modules/common/references/initRecordReferences.d.ts.map +1 -0
  102. package/dist/declarations/src/core-modules/common/references/resolveRecordReferencePlaceholders.d.ts +12 -0
  103. package/dist/declarations/src/core-modules/common/references/resolveRecordReferencePlaceholders.d.ts.map +1 -0
  104. package/dist/declarations/src/core-modules/common/references/resolveRecordReferenceValue.d.ts +6 -0
  105. package/dist/declarations/src/core-modules/common/references/resolveRecordReferenceValue.d.ts.map +1 -0
  106. package/dist/declarations/src/core-modules/common/references/types.d.ts +63 -0
  107. package/dist/declarations/src/core-modules/common/references/types.d.ts.map +1 -0
  108. package/dist/declarations/src/core-modules/common/routeToModuleProducer.d.ts +55 -0
  109. package/dist/declarations/src/core-modules/common/routeToModuleProducer.d.ts.map +1 -0
  110. package/dist/declarations/src/core-modules/email-content/blocksToHtml.d.ts +72 -0
  111. package/dist/declarations/src/core-modules/email-content/blocksToHtml.d.ts.map +1 -0
  112. package/dist/declarations/src/core-modules/email-content/constants.d.ts +5 -0
  113. package/dist/declarations/src/core-modules/email-content/constants.d.ts.map +1 -0
  114. package/dist/declarations/src/core-modules/email-content/emailFooter.d.ts +5 -0
  115. package/dist/declarations/src/core-modules/email-content/emailFooter.d.ts.map +1 -0
  116. package/dist/declarations/src/core-modules/email-content/expandRepeatRows.d.ts +9 -0
  117. package/dist/declarations/src/core-modules/email-content/expandRepeatRows.d.ts.map +1 -0
  118. package/dist/declarations/src/core-modules/email-content/index.d.ts +9 -0
  119. package/dist/declarations/src/core-modules/email-content/index.d.ts.map +1 -0
  120. package/dist/declarations/src/core-modules/email-content/renderEmailContent.d.ts +19 -0
  121. package/dist/declarations/src/core-modules/email-content/renderEmailContent.d.ts.map +1 -0
  122. package/dist/declarations/src/core-modules/email-content/replacePlaceholders.d.ts +36 -0
  123. package/dist/declarations/src/core-modules/email-content/replacePlaceholders.d.ts.map +1 -0
  124. package/dist/declarations/src/core-modules/email-content/types.d.ts +48 -0
  125. package/dist/declarations/src/core-modules/email-content/types.d.ts.map +1 -0
  126. package/dist/declarations/src/core-modules/email-content/unresolvedPlaceholders.d.ts +4 -0
  127. package/dist/declarations/src/core-modules/email-content/unresolvedPlaceholders.d.ts.map +1 -0
  128. package/dist/declarations/src/core-modules/forms/index.d.ts +3 -0
  129. package/dist/declarations/src/core-modules/forms/index.d.ts.map +1 -0
  130. package/dist/declarations/src/core-modules/forms/types.d.ts +55 -0
  131. package/dist/declarations/src/core-modules/forms/types.d.ts.map +1 -0
  132. package/dist/declarations/src/core-modules/forms/utils.d.ts +4 -0
  133. package/dist/declarations/src/core-modules/forms/utils.d.ts.map +1 -0
  134. package/dist/declarations/src/core-modules/import-export/index.d.ts +8 -0
  135. package/dist/declarations/src/core-modules/import-export/index.d.ts.map +1 -0
  136. package/dist/declarations/src/core-modules/import-export/types.d.ts +181 -0
  137. package/dist/declarations/src/core-modules/import-export/types.d.ts.map +1 -0
  138. package/dist/declarations/src/core-modules/import-export/utils/exportCursor.d.ts +14 -0
  139. package/dist/declarations/src/core-modules/import-export/utils/exportCursor.d.ts.map +1 -0
  140. package/dist/declarations/src/core-modules/import-export/utils/headerMatcher.d.ts +32 -0
  141. package/dist/declarations/src/core-modules/import-export/utils/headerMatcher.d.ts.map +1 -0
  142. package/dist/declarations/src/core-modules/import-export/utils/importExportRuntime.d.ts +32 -0
  143. package/dist/declarations/src/core-modules/import-export/utils/importExportRuntime.d.ts.map +1 -0
  144. package/dist/declarations/src/core-modules/import-export/utils/importUtils.d.ts +25 -0
  145. package/dist/declarations/src/core-modules/import-export/utils/importUtils.d.ts.map +1 -0
  146. package/dist/declarations/src/core-modules/import-export/worker.d.ts +8 -0
  147. package/dist/declarations/src/core-modules/import-export/worker.d.ts.map +1 -0
  148. package/dist/declarations/src/core-modules/import-export/zodSchemas.d.ts +111 -0
  149. package/dist/declarations/src/core-modules/import-export/zodSchemas.d.ts.map +1 -0
  150. package/dist/declarations/src/core-modules/index.d.ts +16 -0
  151. package/dist/declarations/src/core-modules/index.d.ts.map +1 -0
  152. package/dist/declarations/src/core-modules/logs/activityLog/builder.d.ts +3 -0
  153. package/dist/declarations/src/core-modules/logs/activityLog/builder.d.ts.map +1 -0
  154. package/dist/declarations/src/core-modules/logs/activityLog/index.d.ts +5 -0
  155. package/dist/declarations/src/core-modules/logs/activityLog/index.d.ts.map +1 -0
  156. package/dist/declarations/src/core-modules/logs/activityLog/sharedBuilders.d.ts +18 -0
  157. package/dist/declarations/src/core-modules/logs/activityLog/sharedBuilders.d.ts.map +1 -0
  158. package/dist/declarations/src/core-modules/logs/activityLog/types.d.ts +21 -0
  159. package/dist/declarations/src/core-modules/logs/activityLog/types.d.ts.map +1 -0
  160. package/dist/declarations/src/core-modules/logs/activityLog/utils.d.ts +10 -0
  161. package/dist/declarations/src/core-modules/logs/activityLog/utils.d.ts.map +1 -0
  162. package/dist/declarations/src/core-modules/logs/activityLogUtils.d.ts +72 -0
  163. package/dist/declarations/src/core-modules/logs/activityLogUtils.d.ts.map +1 -0
  164. package/dist/declarations/src/core-modules/logs/definitions/activityLog.d.ts +84 -0
  165. package/dist/declarations/src/core-modules/logs/definitions/activityLog.d.ts.map +1 -0
  166. package/dist/declarations/src/core-modules/logs/definitions/logs.d.ts +39 -0
  167. package/dist/declarations/src/core-modules/logs/definitions/logs.d.ts.map +1 -0
  168. package/dist/declarations/src/core-modules/logs/index.d.ts +6 -0
  169. package/dist/declarations/src/core-modules/logs/index.d.ts.map +1 -0
  170. package/dist/declarations/src/core-modules/logs/types.d.ts +15 -0
  171. package/dist/declarations/src/core-modules/logs/types.d.ts.map +1 -0
  172. package/dist/declarations/src/core-modules/notifications/definitions/emailAddresses.d.ts +73 -0
  173. package/dist/declarations/src/core-modules/notifications/definitions/emailAddresses.d.ts.map +1 -0
  174. package/dist/declarations/src/core-modules/notifications/definitions/emailDeliveries.d.ts +115 -0
  175. package/dist/declarations/src/core-modules/notifications/definitions/emailDeliveries.d.ts.map +1 -0
  176. package/dist/declarations/src/core-modules/notifications/definitions/emailRamp.d.ts +65 -0
  177. package/dist/declarations/src/core-modules/notifications/definitions/emailRamp.d.ts.map +1 -0
  178. package/dist/declarations/src/core-modules/notifications/definitions/emailSenders.d.ts +58 -0
  179. package/dist/declarations/src/core-modules/notifications/definitions/emailSenders.d.ts.map +1 -0
  180. package/dist/declarations/src/core-modules/notifications/definitions/notificationSettings.d.ts +66 -0
  181. package/dist/declarations/src/core-modules/notifications/definitions/notificationSettings.d.ts.map +1 -0
  182. package/dist/declarations/src/core-modules/notifications/definitions/notifications.d.ts +89 -0
  183. package/dist/declarations/src/core-modules/notifications/definitions/notifications.d.ts.map +1 -0
  184. package/dist/declarations/src/core-modules/notifications/index.d.ts +8 -0
  185. package/dist/declarations/src/core-modules/notifications/index.d.ts.map +1 -0
  186. package/dist/declarations/src/core-modules/notifications/utils.d.ts +85 -0
  187. package/dist/declarations/src/core-modules/notifications/utils.d.ts.map +1 -0
  188. package/dist/declarations/src/core-modules/permissions/db/definitions/permissions.d.ts +60 -0
  189. package/dist/declarations/src/core-modules/permissions/db/definitions/permissions.d.ts.map +1 -0
  190. package/dist/declarations/src/core-modules/permissions/index.d.ts +4 -0
  191. package/dist/declarations/src/core-modules/permissions/index.d.ts.map +1 -0
  192. package/dist/declarations/src/core-modules/permissions/user-actions-map.d.ts +4 -0
  193. package/dist/declarations/src/core-modules/permissions/user-actions-map.d.ts.map +1 -0
  194. package/dist/declarations/src/core-modules/permissions/utils.d.ts +22 -0
  195. package/dist/declarations/src/core-modules/permissions/utils.d.ts.map +1 -0
  196. package/dist/declarations/src/core-modules/properties/filter.d.ts +5 -0
  197. package/dist/declarations/src/core-modules/properties/filter.d.ts.map +1 -0
  198. package/dist/declarations/src/core-modules/properties/importExport.d.ts +18 -0
  199. package/dist/declarations/src/core-modules/properties/importExport.d.ts.map +1 -0
  200. package/dist/declarations/src/core-modules/properties/index.d.ts +10 -0
  201. package/dist/declarations/src/core-modules/properties/index.d.ts.map +1 -0
  202. package/dist/declarations/src/core-modules/properties/keys.d.ts +46 -0
  203. package/dist/declarations/src/core-modules/properties/keys.d.ts.map +1 -0
  204. package/dist/declarations/src/core-modules/properties/mergeRows.d.ts +8 -0
  205. package/dist/declarations/src/core-modules/properties/mergeRows.d.ts.map +1 -0
  206. package/dist/declarations/src/core-modules/properties/operators.d.ts +6 -0
  207. package/dist/declarations/src/core-modules/properties/operators.d.ts.map +1 -0
  208. package/dist/declarations/src/core-modules/properties/options.d.ts +10 -0
  209. package/dist/declarations/src/core-modules/properties/options.d.ts.map +1 -0
  210. package/dist/declarations/src/core-modules/properties/setupPropertyProducers.d.ts +4 -0
  211. package/dist/declarations/src/core-modules/properties/setupPropertyProducers.d.ts.map +1 -0
  212. package/dist/declarations/src/core-modules/properties/types.d.ts +14 -0
  213. package/dist/declarations/src/core-modules/properties/types.d.ts.map +1 -0
  214. package/dist/declarations/src/core-modules/properties/valueUsage.d.ts +56 -0
  215. package/dist/declarations/src/core-modules/properties/valueUsage.d.ts.map +1 -0
  216. package/dist/declarations/src/core-modules/segments/dependencies.d.ts +6 -0
  217. package/dist/declarations/src/core-modules/segments/dependencies.d.ts.map +1 -0
  218. package/dist/declarations/src/core-modules/segments/evaluate.d.ts +11 -0
  219. package/dist/declarations/src/core-modules/segments/evaluate.d.ts.map +1 -0
  220. package/dist/declarations/src/core-modules/segments/evaluateBatch.d.ts +42 -0
  221. package/dist/declarations/src/core-modules/segments/evaluateBatch.d.ts.map +1 -0
  222. package/dist/declarations/src/core-modules/segments/evaluateFieldsRouter.d.ts +29 -0
  223. package/dist/declarations/src/core-modules/segments/evaluateFieldsRouter.d.ts.map +1 -0
  224. package/dist/declarations/src/core-modules/segments/evaluateOwned.d.ts +27 -0
  225. package/dist/declarations/src/core-modules/segments/evaluateOwned.d.ts.map +1 -0
  226. package/dist/declarations/src/core-modules/segments/events.d.ts +45 -0
  227. package/dist/declarations/src/core-modules/segments/events.d.ts.map +1 -0
  228. package/dist/declarations/src/core-modules/segments/fieldBuilders.d.ts +35 -0
  229. package/dist/declarations/src/core-modules/segments/fieldBuilders.d.ts.map +1 -0
  230. package/dist/declarations/src/core-modules/segments/fieldMeta.d.ts +62 -0
  231. package/dist/declarations/src/core-modules/segments/fieldMeta.d.ts.map +1 -0
  232. package/dist/declarations/src/core-modules/segments/fieldRequests.d.ts +33 -0
  233. package/dist/declarations/src/core-modules/segments/fieldRequests.d.ts.map +1 -0
  234. package/dist/declarations/src/core-modules/segments/fingerprint.d.ts +6 -0
  235. package/dist/declarations/src/core-modules/segments/fingerprint.d.ts.map +1 -0
  236. package/dist/declarations/src/core-modules/segments/index.d.ts +31 -0
  237. package/dist/declarations/src/core-modules/segments/index.d.ts.map +1 -0
  238. package/dist/declarations/src/core-modules/segments/joinChanges.d.ts +11 -0
  239. package/dist/declarations/src/core-modules/segments/joinChanges.d.ts.map +1 -0
  240. package/dist/declarations/src/core-modules/segments/materialized.d.ts +9 -0
  241. package/dist/declarations/src/core-modules/segments/materialized.d.ts.map +1 -0
  242. package/dist/declarations/src/core-modules/segments/measureRelations.d.ts +18 -0
  243. package/dist/declarations/src/core-modules/segments/measureRelations.d.ts.map +1 -0
  244. package/dist/declarations/src/core-modules/segments/memberQuery.d.ts +13 -0
  245. package/dist/declarations/src/core-modules/segments/memberQuery.d.ts.map +1 -0
  246. package/dist/declarations/src/core-modules/segments/membership.d.ts +24 -0
  247. package/dist/declarations/src/core-modules/segments/membership.d.ts.map +1 -0
  248. package/dist/declarations/src/core-modules/segments/mongoFilter.d.ts +15 -0
  249. package/dist/declarations/src/core-modules/segments/mongoFilter.d.ts.map +1 -0
  250. package/dist/declarations/src/core-modules/segments/nodeRefs.d.ts +5 -0
  251. package/dist/declarations/src/core-modules/segments/nodeRefs.d.ts.map +1 -0
  252. package/dist/declarations/src/core-modules/segments/nodes.d.ts +42 -0
  253. package/dist/declarations/src/core-modules/segments/nodes.d.ts.map +1 -0
  254. package/dist/declarations/src/core-modules/segments/operators.d.ts +46 -0
  255. package/dist/declarations/src/core-modules/segments/operators.d.ts.map +1 -0
  256. package/dist/declarations/src/core-modules/segments/ownedSource.d.ts +7 -0
  257. package/dist/declarations/src/core-modules/segments/ownedSource.d.ts.map +1 -0
  258. package/dist/declarations/src/core-modules/segments/plan.d.ts +35 -0
  259. package/dist/declarations/src/core-modules/segments/plan.d.ts.map +1 -0
  260. package/dist/declarations/src/core-modules/segments/relationRegistry.d.ts +33 -0
  261. package/dist/declarations/src/core-modules/segments/relationRegistry.d.ts.map +1 -0
  262. package/dist/declarations/src/core-modules/segments/setupSegmentProducers.d.ts +4 -0
  263. package/dist/declarations/src/core-modules/segments/setupSegmentProducers.d.ts.map +1 -0
  264. package/dist/declarations/src/core-modules/segments/subjectsReachedBy.d.ts +11 -0
  265. package/dist/declarations/src/core-modules/segments/subjectsReachedBy.d.ts.map +1 -0
  266. package/dist/declarations/src/core-modules/segments/timeZone.d.ts +2 -0
  267. package/dist/declarations/src/core-modules/segments/timeZone.d.ts.map +1 -0
  268. package/dist/declarations/src/core-modules/segments/types.d.ts +67 -0
  269. package/dist/declarations/src/core-modules/segments/types.d.ts.map +1 -0
  270. package/dist/declarations/src/core-modules/segments/utils.d.ts +4 -0
  271. package/dist/declarations/src/core-modules/segments/utils.d.ts.map +1 -0
  272. package/dist/declarations/src/core-modules/segments/walkNodes.d.ts +9 -0
  273. package/dist/declarations/src/core-modules/segments/walkNodes.d.ts.map +1 -0
  274. package/dist/declarations/src/core-modules/segments/zodSchemas.d.ts +532 -0
  275. package/dist/declarations/src/core-modules/segments/zodSchemas.d.ts.map +1 -0
  276. package/dist/declarations/src/core-modules/segments/zonedTime.d.ts +25 -0
  277. package/dist/declarations/src/core-modules/segments/zonedTime.d.ts.map +1 -0
  278. package/dist/declarations/src/core-modules/templates/index.d.ts +2 -0
  279. package/dist/declarations/src/core-modules/templates/index.d.ts.map +1 -0
  280. package/dist/declarations/src/core-modules/templates/utils.d.ts +11 -0
  281. package/dist/declarations/src/core-modules/templates/utils.d.ts.map +1 -0
  282. package/dist/declarations/src/core-modules/users/constants.d.ts +114 -0
  283. package/dist/declarations/src/core-modules/users/constants.d.ts.map +1 -0
  284. package/dist/declarations/src/core-modules/users/db/definitions/users.d.ts +24 -0
  285. package/dist/declarations/src/core-modules/users/db/definitions/users.d.ts.map +1 -0
  286. package/dist/declarations/src/core-modules/users/index.d.ts +3 -0
  287. package/dist/declarations/src/core-modules/users/index.d.ts.map +1 -0
  288. package/dist/declarations/src/core-types/common.d.ts +149 -0
  289. package/dist/declarations/src/core-types/common.d.ts.map +1 -0
  290. package/dist/declarations/src/core-types/index.d.ts +20 -0
  291. package/dist/declarations/src/core-types/index.d.ts.map +1 -0
  292. package/dist/declarations/src/core-types/modules/app/app.d.ts +12 -0
  293. package/dist/declarations/src/core-types/modules/app/app.d.ts.map +1 -0
  294. package/dist/declarations/src/core-types/modules/automations/automations.d.ts +19 -0
  295. package/dist/declarations/src/core-types/modules/automations/automations.d.ts.map +1 -0
  296. package/dist/declarations/src/core-types/modules/contacts/company.d.ts +53 -0
  297. package/dist/declarations/src/core-types/modules/contacts/company.d.ts.map +1 -0
  298. package/dist/declarations/src/core-types/modules/contacts/contacts-common.d.ts +32 -0
  299. package/dist/declarations/src/core-types/modules/contacts/contacts-common.d.ts.map +1 -0
  300. package/dist/declarations/src/core-types/modules/contacts/customer.d.ts +74 -0
  301. package/dist/declarations/src/core-types/modules/contacts/customer.d.ts.map +1 -0
  302. package/dist/declarations/src/core-types/modules/emailTemplates/emailTemplate.d.ts +18 -0
  303. package/dist/declarations/src/core-types/modules/emailTemplates/emailTemplate.d.ts.map +1 -0
  304. package/dist/declarations/src/core-types/modules/logs/logs.d.ts +28 -0
  305. package/dist/declarations/src/core-types/modules/logs/logs.d.ts.map +1 -0
  306. package/dist/declarations/src/core-types/modules/permissions/permission.d.ts +56 -0
  307. package/dist/declarations/src/core-types/modules/permissions/permission.d.ts.map +1 -0
  308. package/dist/declarations/src/core-types/modules/permissions/role.d.ts +21 -0
  309. package/dist/declarations/src/core-types/modules/permissions/role.d.ts.map +1 -0
  310. package/dist/declarations/src/core-types/modules/products/product.d.ts +76 -0
  311. package/dist/declarations/src/core-types/modules/products/product.d.ts.map +1 -0
  312. package/dist/declarations/src/core-types/modules/products/productCategory.d.ts +26 -0
  313. package/dist/declarations/src/core-types/modules/products/productCategory.d.ts.map +1 -0
  314. package/dist/declarations/src/core-types/modules/products/productConfig.d.ts +9 -0
  315. package/dist/declarations/src/core-types/modules/products/productConfig.d.ts.map +1 -0
  316. package/dist/declarations/src/core-types/modules/products/uom.d.ts +11 -0
  317. package/dist/declarations/src/core-types/modules/products/uom.d.ts.map +1 -0
  318. package/dist/declarations/src/core-types/modules/relations/relations.d.ts +13 -0
  319. package/dist/declarations/src/core-types/modules/relations/relations.d.ts.map +1 -0
  320. package/dist/declarations/src/core-types/modules/saas/organization.d.ts +8 -0
  321. package/dist/declarations/src/core-types/modules/saas/organization.d.ts.map +1 -0
  322. package/dist/declarations/src/core-types/modules/tags/tag.d.ts +16 -0
  323. package/dist/declarations/src/core-types/modules/tags/tag.d.ts.map +1 -0
  324. package/dist/declarations/src/core-types/modules/team-member/structure.d.ts +19 -0
  325. package/dist/declarations/src/core-types/modules/team-member/structure.d.ts.map +1 -0
  326. package/dist/declarations/src/core-types/modules/team-member/user.d.ts +90 -0
  327. package/dist/declarations/src/core-types/modules/team-member/user.d.ts.map +1 -0
  328. package/dist/declarations/src/index.d.ts +3 -0
  329. package/dist/declarations/src/index.d.ts.map +1 -0
  330. package/dist/declarations/src/utils/agent-tools/auth.d.ts +18 -0
  331. package/dist/declarations/src/utils/agent-tools/auth.d.ts.map +1 -0
  332. package/dist/declarations/src/utils/agent-tools/endpoints.d.ts +16 -0
  333. package/dist/declarations/src/utils/agent-tools/endpoints.d.ts.map +1 -0
  334. package/dist/declarations/src/utils/agent-tools/index.d.ts +6 -0
  335. package/dist/declarations/src/utils/agent-tools/index.d.ts.map +1 -0
  336. package/dist/declarations/src/utils/agent-tools/manifest.d.ts +11 -0
  337. package/dist/declarations/src/utils/agent-tools/manifest.d.ts.map +1 -0
  338. package/dist/declarations/src/utils/agent-tools/responseLimit.d.ts +26 -0
  339. package/dist/declarations/src/utils/agent-tools/responseLimit.d.ts.map +1 -0
  340. package/dist/declarations/src/utils/agent-tools/types.d.ts +48 -0
  341. package/dist/declarations/src/utils/agent-tools/types.d.ts.map +1 -0
  342. package/dist/declarations/src/utils/apollo/beforeResolvers.d.ts +41 -0
  343. package/dist/declarations/src/utils/apollo/beforeResolvers.d.ts.map +1 -0
  344. package/dist/declarations/src/utils/apollo/commonTypeDefs.d.ts +7 -0
  345. package/dist/declarations/src/utils/apollo/commonTypeDefs.d.ts.map +1 -0
  346. package/dist/declarations/src/utils/apollo/constants.d.ts +3 -0
  347. package/dist/declarations/src/utils/apollo/constants.d.ts.map +1 -0
  348. package/dist/declarations/src/utils/apollo/customScalars.d.ts +6 -0
  349. package/dist/declarations/src/utils/apollo/customScalars.d.ts.map +1 -0
  350. package/dist/declarations/src/utils/apollo/expectedErrorPlugin.d.ts +11 -0
  351. package/dist/declarations/src/utils/apollo/expectedErrorPlugin.d.ts.map +1 -0
  352. package/dist/declarations/src/utils/apollo/index.d.ts +10 -0
  353. package/dist/declarations/src/utils/apollo/index.d.ts.map +1 -0
  354. package/dist/declarations/src/utils/apollo/runBeforeResolvers.d.ts +27 -0
  355. package/dist/declarations/src/utils/apollo/runBeforeResolvers.d.ts.map +1 -0
  356. package/dist/declarations/src/utils/apollo/utils.d.ts +5 -0
  357. package/dist/declarations/src/utils/apollo/utils.d.ts.map +1 -0
  358. package/dist/declarations/src/utils/apollo/wrapperMutations.d.ts +8 -0
  359. package/dist/declarations/src/utils/apollo/wrapperMutations.d.ts.map +1 -0
  360. package/dist/declarations/src/utils/apollo/wrapperResolvers.d.ts +8 -0
  361. package/dist/declarations/src/utils/apollo/wrapperResolvers.d.ts.map +1 -0
  362. package/dist/declarations/src/utils/bulkUtils.d.ts +7 -0
  363. package/dist/declarations/src/utils/bulkUtils.d.ts.map +1 -0
  364. package/dist/declarations/src/utils/constants.d.ts +40 -0
  365. package/dist/declarations/src/utils/constants.d.ts.map +1 -0
  366. package/dist/declarations/src/utils/editor.d.ts +45 -0
  367. package/dist/declarations/src/utils/editor.d.ts.map +1 -0
  368. package/dist/declarations/src/utils/email/address.d.ts +10 -0
  369. package/dist/declarations/src/utils/email/address.d.ts.map +1 -0
  370. package/dist/declarations/src/utils/email/attachments.d.ts +12 -0
  371. package/dist/declarations/src/utils/email/attachments.d.ts.map +1 -0
  372. package/dist/declarations/src/utils/email/config.d.ts +10 -0
  373. package/dist/declarations/src/utils/email/config.d.ts.map +1 -0
  374. package/dist/declarations/src/utils/email/constants.d.ts +6 -0
  375. package/dist/declarations/src/utils/email/constants.d.ts.map +1 -0
  376. package/dist/declarations/src/utils/email/index.d.ts +12 -0
  377. package/dist/declarations/src/utils/email/index.d.ts.map +1 -0
  378. package/dist/declarations/src/utils/email/providers/sendgrid.d.ts +17 -0
  379. package/dist/declarations/src/utils/email/providers/sendgrid.d.ts.map +1 -0
  380. package/dist/declarations/src/utils/email/providers/sendgridEvents.d.ts +18 -0
  381. package/dist/declarations/src/utils/email/providers/sendgridEvents.d.ts.map +1 -0
  382. package/dist/declarations/src/utils/email/providers/ses.d.ts +19 -0
  383. package/dist/declarations/src/utils/email/providers/ses.d.ts.map +1 -0
  384. package/dist/declarations/src/utils/email/providers/smtp.d.ts +14 -0
  385. package/dist/declarations/src/utils/email/providers/smtp.d.ts.map +1 -0
  386. package/dist/declarations/src/utils/email/resolveProvider.d.ts +6 -0
  387. package/dist/declarations/src/utils/email/resolveProvider.d.ts.map +1 -0
  388. package/dist/declarations/src/utils/email/service.d.ts +50 -0
  389. package/dist/declarations/src/utils/email/service.d.ts.map +1 -0
  390. package/dist/declarations/src/utils/email/types.d.ts +87 -0
  391. package/dist/declarations/src/utils/email/types.d.ts.map +1 -0
  392. package/dist/declarations/src/utils/errorClassifier.d.ts +56 -0
  393. package/dist/declarations/src/utils/errorClassifier.d.ts.map +1 -0
  394. package/dist/declarations/src/utils/file/read.d.ts +14 -0
  395. package/dist/declarations/src/utils/file/read.d.ts.map +1 -0
  396. package/dist/declarations/src/utils/file/upload.d.ts +10 -0
  397. package/dist/declarations/src/utils/file/upload.d.ts.map +1 -0
  398. package/dist/declarations/src/utils/graphqlPubSub.d.ts +3 -0
  399. package/dist/declarations/src/utils/graphqlPubSub.d.ts.map +1 -0
  400. package/dist/declarations/src/utils/headers/get-hostname.d.ts +5 -0
  401. package/dist/declarations/src/utils/headers/get-hostname.d.ts.map +1 -0
  402. package/dist/declarations/src/utils/headers/index.d.ts +5 -0
  403. package/dist/declarations/src/utils/headers/index.d.ts.map +1 -0
  404. package/dist/declarations/src/utils/headers/sanitize.d.ts +3 -0
  405. package/dist/declarations/src/utils/headers/sanitize.d.ts.map +1 -0
  406. package/dist/declarations/src/utils/headers/subdomain.d.ts +4 -0
  407. package/dist/declarations/src/utils/headers/subdomain.d.ts.map +1 -0
  408. package/dist/declarations/src/utils/headers/user.d.ts +14 -0
  409. package/dist/declarations/src/utils/headers/user.d.ts.map +1 -0
  410. package/dist/declarations/src/utils/index.d.ts +28 -0
  411. package/dist/declarations/src/utils/index.d.ts.map +1 -0
  412. package/dist/declarations/src/utils/knowledge.d.ts +50 -0
  413. package/dist/declarations/src/utils/knowledge.d.ts.map +1 -0
  414. package/dist/declarations/src/utils/logs/index.d.ts +103 -0
  415. package/dist/declarations/src/utils/logs/index.d.ts.map +1 -0
  416. package/dist/declarations/src/utils/mongo/cursor-util.d.ts +41 -0
  417. package/dist/declarations/src/utils/mongo/cursor-util.d.ts.map +1 -0
  418. package/dist/declarations/src/utils/mongo/generate-models.d.ts +4 -0
  419. package/dist/declarations/src/utils/mongo/generate-models.d.ts.map +1 -0
  420. package/dist/declarations/src/utils/mongo/index.d.ts +6 -0
  421. package/dist/declarations/src/utils/mongo/index.d.ts.map +1 -0
  422. package/dist/declarations/src/utils/mongo/mongo-connection.d.ts +5 -0
  423. package/dist/declarations/src/utils/mongo/mongo-connection.d.ts.map +1 -0
  424. package/dist/declarations/src/utils/mongo/mongoose-types.d.ts +22 -0
  425. package/dist/declarations/src/utils/mongo/mongoose-types.d.ts.map +1 -0
  426. package/dist/declarations/src/utils/mongo/mongoose-utils.d.ts +30 -0
  427. package/dist/declarations/src/utils/mongo/mongoose-utils.d.ts.map +1 -0
  428. package/dist/declarations/src/utils/mongo/search-tokens.d.ts +21 -0
  429. package/dist/declarations/src/utils/mongo/search-tokens.d.ts.map +1 -0
  430. package/dist/declarations/src/utils/mq-worker.d.ts +19 -0
  431. package/dist/declarations/src/utils/mq-worker.d.ts.map +1 -0
  432. package/dist/declarations/src/utils/random.d.ts +3 -0
  433. package/dist/declarations/src/utils/random.d.ts.map +1 -0
  434. package/dist/declarations/src/utils/redis.d.ts +4 -0
  435. package/dist/declarations/src/utils/redis.d.ts.map +1 -0
  436. package/dist/declarations/src/utils/saas/index.d.ts +3 -0
  437. package/dist/declarations/src/utils/saas/index.d.ts.map +1 -0
  438. package/dist/declarations/src/utils/saas/saas-mongo-connection.d.ts +59 -0
  439. package/dist/declarations/src/utils/saas/saas-mongo-connection.d.ts.map +1 -0
  440. package/dist/declarations/src/utils/saas/types.d.ts +96 -0
  441. package/dist/declarations/src/utils/saas/types.d.ts.map +1 -0
  442. package/dist/declarations/src/utils/sanitize.d.ts +3 -0
  443. package/dist/declarations/src/utils/sanitize.d.ts.map +1 -0
  444. package/dist/declarations/src/utils/sentry-init.d.ts +15 -0
  445. package/dist/declarations/src/utils/sentry-init.d.ts.map +1 -0
  446. package/dist/declarations/src/utils/sentry-instrument.d.ts +2 -0
  447. package/dist/declarations/src/utils/sentry-instrument.d.ts.map +1 -0
  448. package/dist/declarations/src/utils/serializablePayload.d.ts +11 -0
  449. package/dist/declarations/src/utils/serializablePayload.d.ts.map +1 -0
  450. package/dist/declarations/src/utils/service-discovery.d.ts +25 -0
  451. package/dist/declarations/src/utils/service-discovery.d.ts.map +1 -0
  452. package/dist/declarations/src/utils/start-plugin.d.ts +85 -0
  453. package/dist/declarations/src/utils/start-plugin.d.ts.map +1 -0
  454. package/dist/declarations/src/utils/string.d.ts +82 -0
  455. package/dist/declarations/src/utils/string.d.ts.map +1 -0
  456. package/dist/declarations/src/utils/trpc/index.d.ts +79 -0
  457. package/dist/declarations/src/utils/trpc/index.d.ts.map +1 -0
  458. package/dist/declarations/src/utils/trpc/sendCoreModuleProducer.d.ts +53 -0
  459. package/dist/declarations/src/utils/trpc/sendCoreModuleProducer.d.ts.map +1 -0
  460. package/dist/declarations/src/utils/utils.d.ts +69 -0
  461. package/dist/declarations/src/utils/utils.d.ts.map +1 -0
  462. package/dist/erxes-api-shared.cjs.d.ts +3 -0
  463. package/dist/erxes-api-shared.cjs.dev.js +7 -0
  464. package/dist/erxes-api-shared.cjs.js +7 -0
  465. package/dist/erxes-api-shared.cjs.prod.js +7 -0
  466. package/dist/erxes-api-shared.esm.js +3 -0
  467. package/dist/start-plugin-576e707d.cjs.prod.js +23223 -0
  468. package/dist/start-plugin-6e76556c.esm.js +22742 -0
  469. package/dist/start-plugin-89fa2bd2.cjs.dev.js +23225 -0
  470. package/package.json +105 -4
  471. package/src/common-modules/payment/worker.ts +53 -0
  472. package/src/core-modules/approval/approvalChangeTypes.ts +31 -0
  473. package/src/core-modules/approval/checkApprovalLock.ts +85 -0
  474. package/src/core-modules/approval/constants.ts +45 -0
  475. package/src/core-modules/approval/index.ts +6 -0
  476. package/src/core-modules/approval/initApproval.ts +59 -0
  477. package/src/core-modules/approval/types.ts +206 -0
  478. package/src/core-modules/approval/zodSchemas.ts +55 -0
  479. package/src/core-modules/apps/@types/app.ts +15 -0
  480. package/src/core-modules/apps/db/definitions/apps.ts +30 -0
  481. package/src/core-modules/apps/index.ts +2 -0
  482. package/src/core-modules/automations/actionErrorPolicy.test.ts +125 -0
  483. package/src/core-modules/automations/actionErrorPolicy.ts +162 -0
  484. package/src/core-modules/automations/actionInputs.test.ts +70 -0
  485. package/src/core-modules/automations/actionOutcome.test.ts +87 -0
  486. package/src/core-modules/automations/actionOutcome.ts +128 -0
  487. package/src/core-modules/automations/constants.ts +181 -0
  488. package/src/core-modules/automations/definitions/aiAgents.ts +343 -0
  489. package/src/core-modules/automations/definitions/automations.ts +207 -0
  490. package/src/core-modules/automations/definitions/executions.ts +190 -0
  491. package/src/core-modules/automations/definitions/index.ts +3 -0
  492. package/src/core-modules/automations/getValueByPath.test.ts +49 -0
  493. package/src/core-modules/automations/index.ts +13 -0
  494. package/src/core-modules/automations/outputResolvers.test.ts +97 -0
  495. package/src/core-modules/automations/outputResolvers.ts +1238 -0
  496. package/src/core-modules/automations/reEnrollment.ts +34 -0
  497. package/src/core-modules/automations/segmentMembership.ts +34 -0
  498. package/src/core-modules/automations/sendAutomationMessage.ts +219 -0
  499. package/src/core-modules/automations/setPropertyOutcome.test.ts +105 -0
  500. package/src/core-modules/automations/setPropertyRows.test.ts +61 -0
  501. package/src/core-modules/automations/setupAutomationProducers.ts +187 -0
  502. package/src/core-modules/automations/typeUtils.ts +3 -0
  503. package/src/core-modules/automations/types.ts +577 -0
  504. package/src/core-modules/automations/utils.ts +1128 -0
  505. package/src/core-modules/automations/workflowValidation.ts +32 -0
  506. package/src/core-modules/automations/zodTypes.ts +221 -0
  507. package/src/core-modules/client-portals/definitions/clientPortal.ts +230 -0
  508. package/src/core-modules/client-portals/definitions/comment.ts +26 -0
  509. package/src/core-modules/client-portals/definitions/cpNotification.ts +112 -0
  510. package/src/core-modules/client-portals/definitions/cpUser.ts +236 -0
  511. package/src/core-modules/client-portals/index.ts +4 -0
  512. package/src/core-modules/common/db/definitions/common.ts +43 -0
  513. package/src/core-modules/common/eventHandlers/createEventHandlers.ts +236 -0
  514. package/src/core-modules/common/eventHandlers/generateEventHandlers.ts +37 -0
  515. package/src/core-modules/common/eventHandlers/index.ts +11 -0
  516. package/src/core-modules/common/eventHandlers/runtimeContext.ts +36 -0
  517. package/src/core-modules/common/eventHandlers/schemas.ts +53 -0
  518. package/src/core-modules/common/eventHandlers/types.ts +97 -0
  519. package/src/core-modules/common/eventHandlers/utils.ts +113 -0
  520. package/src/core-modules/common/index.ts +4 -0
  521. package/src/core-modules/common/references/fetchRecordReferenceTargets.ts +43 -0
  522. package/src/core-modules/common/references/getRecordReferenceFields.ts +243 -0
  523. package/src/core-modules/common/references/index.ts +9 -0
  524. package/src/core-modules/common/references/initRecordReferences.ts +84 -0
  525. package/src/core-modules/common/references/normalizeRecordReferenceConfig.ts +59 -0
  526. package/src/core-modules/common/references/resolveRecordReferencePath.ts +473 -0
  527. package/src/core-modules/common/references/resolveRecordReferencePlaceholders.ts +173 -0
  528. package/src/core-modules/common/references/resolveRecordReferenceValue.ts +41 -0
  529. package/src/core-modules/common/references/resolveRecordRelationIds.ts +57 -0
  530. package/src/core-modules/common/references/types.ts +78 -0
  531. package/src/core-modules/common/references/utils.ts +60 -0
  532. package/src/core-modules/common/references/zodInputs.ts +13 -0
  533. package/src/core-modules/common/routeToModuleProducer.ts +118 -0
  534. package/src/core-modules/email-content/blocksToHtml.ts +551 -0
  535. package/src/core-modules/email-content/constants.ts +4 -0
  536. package/src/core-modules/email-content/emailFooter.ts +17 -0
  537. package/src/core-modules/email-content/expandRepeatRows.test.ts +36 -0
  538. package/src/core-modules/email-content/expandRepeatRows.ts +59 -0
  539. package/src/core-modules/email-content/index.ts +8 -0
  540. package/src/core-modules/email-content/renderEmailContent.ts +88 -0
  541. package/src/core-modules/email-content/replacePlaceholders.ts +143 -0
  542. package/src/core-modules/email-content/types.ts +49 -0
  543. package/src/core-modules/email-content/unresolvedPlaceholders.ts +27 -0
  544. package/src/core-modules/forms/index.ts +2 -0
  545. package/src/core-modules/forms/types.ts +86 -0
  546. package/src/core-modules/forms/utils.ts +34 -0
  547. package/src/core-modules/import-export/index.ts +7 -0
  548. package/src/core-modules/import-export/types.ts +204 -0
  549. package/src/core-modules/import-export/utils/createCoreImportClient.ts +131 -0
  550. package/src/core-modules/import-export/utils/exportBatchProcess.ts +560 -0
  551. package/src/core-modules/import-export/utils/exportCursor.ts +47 -0
  552. package/src/core-modules/import-export/utils/headerMatcher.test.ts +90 -0
  553. package/src/core-modules/import-export/utils/headerMatcher.ts +229 -0
  554. package/src/core-modules/import-export/utils/importBatchProcess.ts +780 -0
  555. package/src/core-modules/import-export/utils/importExportError.ts +71 -0
  556. package/src/core-modules/import-export/utils/importExportRuntime.ts +96 -0
  557. package/src/core-modules/import-export/utils/importUtils.ts +59 -0
  558. package/src/core-modules/import-export/utils/progressUpdate.ts +25 -0
  559. package/src/core-modules/import-export/utils/tempWorkspace.ts +34 -0
  560. package/src/core-modules/import-export/worker.ts +215 -0
  561. package/src/core-modules/import-export/zodSchemas.ts +63 -0
  562. package/src/core-modules/index.ts +15 -0
  563. package/src/core-modules/logs/activityLog/builder.ts +232 -0
  564. package/src/core-modules/logs/activityLog/index.ts +4 -0
  565. package/src/core-modules/logs/activityLog/sharedBuilders.ts +95 -0
  566. package/src/core-modules/logs/activityLog/types.ts +26 -0
  567. package/src/core-modules/logs/activityLog/utils.ts +61 -0
  568. package/src/core-modules/logs/activityLogUtils.ts +677 -0
  569. package/src/core-modules/logs/definitions/activityLog.ts +71 -0
  570. package/src/core-modules/logs/definitions/logs.ts +49 -0
  571. package/src/core-modules/logs/index.ts +5 -0
  572. package/src/core-modules/logs/types.ts +16 -0
  573. package/src/core-modules/notifications/definitions/emailAddresses.ts +105 -0
  574. package/src/core-modules/notifications/definitions/emailDeliveries.ts +188 -0
  575. package/src/core-modules/notifications/definitions/emailRamp.ts +83 -0
  576. package/src/core-modules/notifications/definitions/emailSenders.ts +84 -0
  577. package/src/core-modules/notifications/definitions/notificationConfigs.ts +110 -0
  578. package/src/core-modules/notifications/definitions/notificationSettings.ts +67 -0
  579. package/src/core-modules/notifications/definitions/notifications.ts +130 -0
  580. package/src/core-modules/notifications/emailUtils.ts +88 -0
  581. package/src/core-modules/notifications/index.ts +7 -0
  582. package/src/core-modules/notifications/utils.ts +143 -0
  583. package/src/core-modules/permissions/db/definitions/permissions.ts +82 -0
  584. package/src/core-modules/permissions/index.ts +3 -0
  585. package/src/core-modules/permissions/oauth-scopes.test.ts +102 -0
  586. package/src/core-modules/permissions/user-actions-map.ts +170 -0
  587. package/src/core-modules/permissions/utils.ts +317 -0
  588. package/src/core-modules/properties/README.md +161 -0
  589. package/src/core-modules/properties/filter.test.ts +74 -0
  590. package/src/core-modules/properties/filter.ts +156 -0
  591. package/src/core-modules/properties/importExport.ts +159 -0
  592. package/src/core-modules/properties/index.ts +9 -0
  593. package/src/core-modules/properties/keys.test.ts +71 -0
  594. package/src/core-modules/properties/keys.ts +128 -0
  595. package/src/core-modules/properties/mergePropertyData.test.ts +65 -0
  596. package/src/core-modules/properties/mergeRows.ts +93 -0
  597. package/src/core-modules/properties/operators.ts +91 -0
  598. package/src/core-modules/properties/options.test.ts +119 -0
  599. package/src/core-modules/properties/options.ts +55 -0
  600. package/src/core-modules/properties/setupPropertyProducers.ts +32 -0
  601. package/src/core-modules/properties/types.ts +31 -0
  602. package/src/core-modules/properties/valueUsage.test.ts +158 -0
  603. package/src/core-modules/properties/valueUsage.ts +153 -0
  604. package/src/core-modules/segments/anniversary.test.ts +122 -0
  605. package/src/core-modules/segments/dependencies.test.ts +173 -0
  606. package/src/core-modules/segments/dependencies.ts +70 -0
  607. package/src/core-modules/segments/evaluate.test.ts +339 -0
  608. package/src/core-modules/segments/evaluate.ts +388 -0
  609. package/src/core-modules/segments/evaluateBatch.test.ts +233 -0
  610. package/src/core-modules/segments/evaluateBatch.ts +263 -0
  611. package/src/core-modules/segments/evaluateFieldsRouter.test.ts +148 -0
  612. package/src/core-modules/segments/evaluateFieldsRouter.ts +94 -0
  613. package/src/core-modules/segments/evaluateOwned.ts +162 -0
  614. package/src/core-modules/segments/events.ts +142 -0
  615. package/src/core-modules/segments/fieldBuilders.ts +152 -0
  616. package/src/core-modules/segments/fieldMeta.ts +96 -0
  617. package/src/core-modules/segments/fieldRequests.test.ts +302 -0
  618. package/src/core-modules/segments/fieldRequests.ts +172 -0
  619. package/src/core-modules/segments/fieldSources.test.ts +99 -0
  620. package/src/core-modules/segments/fingerprint.test.ts +111 -0
  621. package/src/core-modules/segments/fingerprint.ts +70 -0
  622. package/src/core-modules/segments/index.ts +30 -0
  623. package/src/core-modules/segments/joinChanges.test.ts +96 -0
  624. package/src/core-modules/segments/joinChanges.ts +67 -0
  625. package/src/core-modules/segments/materialized.ts +23 -0
  626. package/src/core-modules/segments/measureRelations.test.ts +222 -0
  627. package/src/core-modules/segments/measureRelations.ts +322 -0
  628. package/src/core-modules/segments/memberQuery.test.ts +60 -0
  629. package/src/core-modules/segments/memberQuery.ts +45 -0
  630. package/src/core-modules/segments/membership.ts +170 -0
  631. package/src/core-modules/segments/mongoFilter.test.ts +326 -0
  632. package/src/core-modules/segments/mongoFilter.ts +355 -0
  633. package/src/core-modules/segments/nodeRefs.ts +29 -0
  634. package/src/core-modules/segments/nodes.ts +48 -0
  635. package/src/core-modules/segments/operators.ts +243 -0
  636. package/src/core-modules/segments/ownedSource.ts +16 -0
  637. package/src/core-modules/segments/plan.test.ts +172 -0
  638. package/src/core-modules/segments/plan.ts +155 -0
  639. package/src/core-modules/segments/relationRegistry.test.ts +64 -0
  640. package/src/core-modules/segments/relationRegistry.ts +198 -0
  641. package/src/core-modules/segments/segmentReference.test.ts +142 -0
  642. package/src/core-modules/segments/setupSegmentProducers.ts +77 -0
  643. package/src/core-modules/segments/subjectsReachedBy.ts +70 -0
  644. package/src/core-modules/segments/timeZone.ts +56 -0
  645. package/src/core-modules/segments/types.ts +97 -0
  646. package/src/core-modules/segments/utils.ts +122 -0
  647. package/src/core-modules/segments/walkNodes.ts +76 -0
  648. package/src/core-modules/segments/zodSchemas.ts +130 -0
  649. package/src/core-modules/segments/zonedTime.test.ts +163 -0
  650. package/src/core-modules/segments/zonedTime.ts +198 -0
  651. package/src/core-modules/templates/index.ts +1 -0
  652. package/src/core-modules/templates/utils.ts +91 -0
  653. package/src/core-modules/users/constants.ts +318 -0
  654. package/src/core-modules/users/db/definitions/users.ts +226 -0
  655. package/src/core-modules/users/index.ts +2 -0
  656. package/src/core-types/common.ts +183 -0
  657. package/src/core-types/index.ts +19 -0
  658. package/src/core-types/modules/app/app.ts +13 -0
  659. package/src/core-types/modules/automations/automations.ts +23 -0
  660. package/src/core-types/modules/contacts/company.ts +70 -0
  661. package/src/core-types/modules/contacts/contacts-common.ts +32 -0
  662. package/src/core-types/modules/contacts/customer.ts +94 -0
  663. package/src/core-types/modules/emailTemplates/emailTemplate.ts +19 -0
  664. package/src/core-types/modules/emailTemplates/index.ts +1 -0
  665. package/src/core-types/modules/logs/logs.ts +30 -0
  666. package/src/core-types/modules/permissions/permission.ts +63 -0
  667. package/src/core-types/modules/permissions/role.ts +24 -0
  668. package/src/core-types/modules/products/product.ts +100 -0
  669. package/src/core-types/modules/products/productCategory.ts +27 -0
  670. package/src/core-types/modules/products/productConfig.ts +10 -0
  671. package/src/core-types/modules/products/uom.ts +12 -0
  672. package/src/core-types/modules/relations/relations.ts +14 -0
  673. package/src/core-types/modules/saas/organization.ts +7 -0
  674. package/src/core-types/modules/structure/structure.ts +29 -0
  675. package/src/core-types/modules/tags/tag.ts +17 -0
  676. package/src/core-types/modules/team-member/structure.ts +23 -0
  677. package/src/core-types/modules/team-member/user.ts +93 -0
  678. package/src/index.ts +1 -0
  679. package/src/utils/agent-tools/auth.ts +129 -0
  680. package/src/utils/agent-tools/endpoints.ts +274 -0
  681. package/src/utils/agent-tools/index.ts +5 -0
  682. package/src/utils/agent-tools/manifest.ts +152 -0
  683. package/src/utils/agent-tools/responseLimit.test.ts +99 -0
  684. package/src/utils/agent-tools/responseLimit.ts +66 -0
  685. package/src/utils/agent-tools/types.ts +52 -0
  686. package/src/utils/apollo/beforeResolvers.ts +117 -0
  687. package/src/utils/apollo/commonTypeDefs.ts +78 -0
  688. package/src/utils/apollo/constants.ts +16 -0
  689. package/src/utils/apollo/customScalars.ts +69 -0
  690. package/src/utils/apollo/expectedErrorPlugin.ts +83 -0
  691. package/src/utils/apollo/index.ts +10 -0
  692. package/src/utils/apollo/runBeforeResolvers.ts +214 -0
  693. package/src/utils/apollo/utils.ts +80 -0
  694. package/src/utils/apollo/wrapperMutations.ts +75 -0
  695. package/src/utils/apollo/wrapperResolvers.ts +182 -0
  696. package/src/utils/bulkUtils.ts +62 -0
  697. package/src/utils/constants.ts +99 -0
  698. package/src/utils/editor.ts +412 -0
  699. package/src/utils/email/address.ts +42 -0
  700. package/src/utils/email/attachments.ts +74 -0
  701. package/src/utils/email/config.ts +46 -0
  702. package/src/utils/email/constants.ts +25 -0
  703. package/src/utils/email/index.ts +11 -0
  704. package/src/utils/email/providers/sendgrid.ts +280 -0
  705. package/src/utils/email/providers/sendgridEvents.ts +48 -0
  706. package/src/utils/email/providers/ses.ts +250 -0
  707. package/src/utils/email/providers/smtp.ts +99 -0
  708. package/src/utils/email/resolveProvider.ts +75 -0
  709. package/src/utils/email/service.ts +192 -0
  710. package/src/utils/email/types.ts +127 -0
  711. package/src/utils/errorClassifier.test.ts +231 -0
  712. package/src/utils/errorClassifier.ts +458 -0
  713. package/src/utils/file/read.ts +464 -0
  714. package/src/utils/file/upload.ts +531 -0
  715. package/src/utils/graphqlPubSub.ts +28 -0
  716. package/src/utils/headers/get-hostname.ts +18 -0
  717. package/src/utils/headers/index.ts +4 -0
  718. package/src/utils/headers/sanitize.ts +9 -0
  719. package/src/utils/headers/subdomain.ts +13 -0
  720. package/src/utils/headers/user.test.ts +76 -0
  721. package/src/utils/headers/user.ts +113 -0
  722. package/src/utils/index.ts +27 -0
  723. package/src/utils/knowledge.ts +107 -0
  724. package/src/utils/logs/index.ts +247 -0
  725. package/src/utils/mongo/cursor-util.ts +153 -0
  726. package/src/utils/mongo/generate-models.ts +97 -0
  727. package/src/utils/mongo/index.ts +5 -0
  728. package/src/utils/mongo/mongo-connection.ts +42 -0
  729. package/src/utils/mongo/mongoose-types.ts +26 -0
  730. package/src/utils/mongo/mongoose-utils.ts +329 -0
  731. package/src/utils/mongo/search-tokens.ts +193 -0
  732. package/src/utils/mq-worker.ts +150 -0
  733. package/src/utils/random.ts +6 -0
  734. package/src/utils/redis.ts +23 -0
  735. package/src/utils/saas/constants.ts +32 -0
  736. package/src/utils/saas/definition.ts +318 -0
  737. package/src/utils/saas/index.ts +2 -0
  738. package/src/utils/saas/saas-mongo-connection.ts +595 -0
  739. package/src/utils/saas/types.ts +107 -0
  740. package/src/utils/sanitize.ts +73 -0
  741. package/src/utils/sentry-init.ts +128 -0
  742. package/src/utils/sentry-instrument.ts +5 -0
  743. package/src/utils/serializablePayload.test.ts +65 -0
  744. package/src/utils/serializablePayload.ts +44 -0
  745. package/src/utils/service-discovery.ts +256 -0
  746. package/src/utils/start-plugin.ts +482 -0
  747. package/src/utils/string.ts +159 -0
  748. package/src/utils/trpc/index.ts +278 -0
  749. package/src/utils/trpc/sendCoreModuleProducer.ts +146 -0
  750. package/src/utils/trpc/trpc-setup.ts +91 -0
  751. package/src/utils/utils.ts +669 -0
  752. package/utils/dist/erxes-api-shared-utils.cjs.d.ts +2 -0
  753. package/utils/dist/erxes-api-shared-utils.cjs.dev.js +3066 -0
  754. package/utils/dist/erxes-api-shared-utils.cjs.js +7 -0
  755. package/utils/dist/erxes-api-shared-utils.cjs.prod.js +3066 -0
  756. package/utils/dist/erxes-api-shared-utils.esm.js +2776 -0
  757. package/utils/package.json +5 -0
  758. package/README.md +0 -3
@@ -0,0 +1,1238 @@
1
+ import { parsePropertyDataKey, toPropertyGroupKey } from '../properties/keys';
2
+ import { getPlugin, sendCoreModuleProducer } from '../../utils';
3
+ import { sendTRPCMessage } from '../../utils/trpc';
4
+ import { resolveRecordReferenceValue } from '../common/references';
5
+ import { IAutomationExecution } from './definitions';
6
+ import {
7
+ AutomationConstants,
8
+ IAutomationsActionConfig,
9
+ IAutomationsTriggerConfig,
10
+ TAutomationOutputDefinition,
11
+ TAutomationProducers,
12
+ TAutomationRuntimeOutputDefinition,
13
+ } from './types';
14
+ import { splitType } from './typeUtils';
15
+
16
+ type TAutomationNodeConfig =
17
+ | IAutomationsTriggerConfig
18
+ | IAutomationsActionConfig;
19
+
20
+ type TAutomationOutputSource = Record<string, unknown>;
21
+ type TPropertyField = {
22
+ _id: string;
23
+ code?: string;
24
+ name?: string;
25
+ };
26
+ type TPlaceholderToken = {
27
+ token: string;
28
+ sourceKey: string;
29
+ sourceType: 'trigger' | 'action' | 'input';
30
+ path: string;
31
+ };
32
+ type TOutputResolveGroup = {
33
+ groupKey: string;
34
+ nodeType: string;
35
+ source: TAutomationOutputSource;
36
+ paths: Set<string>;
37
+ };
38
+
39
+ export const resolveFromSourceField =
40
+ (
41
+ sourceField: string,
42
+ resolver: (args: {
43
+ subdomain: string;
44
+ source: TAutomationOutputSource;
45
+ path: string;
46
+ value: unknown;
47
+ defaultValue?: unknown;
48
+ }) => Promise<unknown>,
49
+ ) =>
50
+ async ({
51
+ subdomain,
52
+ source,
53
+ path,
54
+ defaultValue,
55
+ }: {
56
+ subdomain: string;
57
+ source: TAutomationOutputSource;
58
+ path: string;
59
+ defaultValue?: unknown;
60
+ }) =>
61
+ resolver({
62
+ subdomain,
63
+ source,
64
+ path,
65
+ value: source?.[sourceField],
66
+ defaultValue,
67
+ });
68
+
69
+ export const matchAutomationResolverKey = (resolverKey: string, path: string) =>
70
+ resolverKey.endsWith('.*')
71
+ ? path.startsWith(resolverKey.slice(0, -1))
72
+ : resolverKey === path;
73
+
74
+ export const getValueByPath = (
75
+ source: TAutomationOutputSource,
76
+ path: string,
77
+ ) => {
78
+ const segments = path.split('.');
79
+ let current: unknown = source;
80
+
81
+ for (const segment of segments) {
82
+ if (
83
+ current === null ||
84
+ current === undefined ||
85
+ typeof current !== 'object'
86
+ ) {
87
+ return { found: false };
88
+ }
89
+
90
+ const bag = current as Record<string, unknown>;
91
+
92
+ if (segment in bag) {
93
+ current = bag[segment];
94
+ continue;
95
+ }
96
+
97
+ const key = parsePropertyDataKey(segment);
98
+ const rows =
99
+ key.kind === 'row' ? bag[toPropertyGroupKey(key.groupId)] : undefined;
100
+
101
+ if (!Array.isArray(rows)) {
102
+ return { found: false };
103
+ }
104
+
105
+ const collected = rows
106
+ .map((row) => (row as Record<string, unknown>)?.[key.fieldId])
107
+ .filter((item) => item !== undefined && item !== null);
108
+
109
+ if (!collected.length) {
110
+ return { found: false };
111
+ }
112
+
113
+ current = collected;
114
+ }
115
+
116
+ return { found: true, value: current };
117
+ };
118
+
119
+ const getPropertyFields = async (
120
+ subdomain: string,
121
+ propertyType: string,
122
+ ): Promise<TPropertyField[]> => {
123
+ return await sendTRPCMessage({
124
+ subdomain,
125
+ pluginName: 'core',
126
+ method: 'query',
127
+ module: 'fields',
128
+ action: 'find',
129
+ input: {
130
+ query: { contentType: propertyType },
131
+ projection: { _id: 1, code: 1, name: 1 },
132
+ sort: { order: 1 },
133
+ },
134
+ defaultValue: [],
135
+ }).catch(() => []);
136
+ };
137
+
138
+ const findReferenceVariable = (
139
+ definition: TAutomationRuntimeOutputDefinition,
140
+ head: string,
141
+ ) =>
142
+ (definition.variables || []).find(
143
+ (variable) =>
144
+ variable.exposure === 'reference' &&
145
+ (variable.key === head || variable.field === head),
146
+ );
147
+
148
+ const findSourceTypeReferenceVariable = (
149
+ definition: TAutomationRuntimeOutputDefinition,
150
+ head: string,
151
+ ) =>
152
+ (definition.variables || []).find(
153
+ (variable) =>
154
+ variable.sourceType && (variable.key === head || variable.field === head),
155
+ );
156
+
157
+ const getOutputSourceType = ({
158
+ propertySource,
159
+ }: TAutomationRuntimeOutputDefinition) => propertySource?.propertyType || '';
160
+
161
+ const getSourceReferenceTarget = (source: TAutomationOutputSource) => {
162
+ const targetId = source.targetId;
163
+
164
+ if (typeof targetId === 'string' && targetId) {
165
+ return { targetId };
166
+ }
167
+
168
+ return { target: source };
169
+ };
170
+
171
+ const resolveCurrentOutputSource = async ({
172
+ definition,
173
+ path,
174
+ source,
175
+ subdomain,
176
+ }: {
177
+ definition: TAutomationRuntimeOutputDefinition;
178
+ path: string;
179
+ source: TAutomationOutputSource;
180
+ subdomain: string;
181
+ }) => {
182
+ const sourceType = getOutputSourceType(definition);
183
+ const targetId = source.targetId;
184
+
185
+ if (!sourceType || typeof targetId !== 'string' || !targetId) {
186
+ return source;
187
+ }
188
+
189
+ const [head] = path.split('.');
190
+ const propertyKey = definition.propertySource?.key;
191
+ const sourceField =
192
+ propertyKey && head === propertyKey ? 'propertiesData' : head;
193
+ const currentValue = await resolveRecordReferenceValue({
194
+ subdomain,
195
+ type: sourceType,
196
+ targetId,
197
+ path: sourceField,
198
+ });
199
+
200
+ return currentValue === undefined
201
+ ? source
202
+ : { ...source, [sourceField]: currentValue };
203
+ };
204
+
205
+ /** `list.$count`: how many items a list output holds. */
206
+ export const AUTOMATION_OUTPUT_ITEM_COUNT = '$count';
207
+ const ITEM_COUNT = AUTOMATION_OUTPUT_ITEM_COUNT;
208
+
209
+ const toReferenceIds = (value: unknown) =>
210
+ (Array.isArray(value) ? value : [value])
211
+ .filter((item) => item !== undefined && item !== null && item !== '')
212
+ .map(String);
213
+
214
+ const resolveNestedFieldsOutputValue = (
215
+ definition: TAutomationRuntimeOutputDefinition,
216
+ source: TAutomationOutputSource,
217
+ path: string,
218
+ ) => {
219
+ const [head, ...restParts] = path.split('.');
220
+ const restPath = restParts.join('.');
221
+
222
+ if (!restPath) {
223
+ return { found: false };
224
+ }
225
+
226
+ const variable = (definition.variables || []).find(
227
+ (item) => item.fields?.length && (item.key === head || item.field === head),
228
+ );
229
+
230
+ if (!variable) {
231
+ return { found: false };
232
+ }
233
+
234
+ const sourceValue = getValueByPath(source, variable.field || variable.key);
235
+
236
+ if (!sourceValue.found) {
237
+ return { found: false };
238
+ }
239
+
240
+ const items = Array.isArray(sourceValue.value)
241
+ ? sourceValue.value
242
+ : sourceValue.value && typeof sourceValue.value === 'object'
243
+ ? [sourceValue.value]
244
+ : [];
245
+
246
+ if (restPath === ITEM_COUNT) {
247
+ return { found: true, value: items.length };
248
+ }
249
+
250
+ // `list.<index>.field`: one item's field, for a row written per item.
251
+ const [indexPart, ...itemParts] = restParts;
252
+
253
+ if (/^\d+$/.test(indexPart) && itemParts.length) {
254
+ const item = items[Number(indexPart)];
255
+ const field =
256
+ item && typeof item === 'object'
257
+ ? getValueByPath(item as TAutomationOutputSource, itemParts.join('.'))
258
+ : { found: false };
259
+
260
+ // An item without the field is an empty cell, not someone else's path.
261
+ return field.found ? field : { found: true, value: undefined };
262
+ }
263
+
264
+ if (Array.isArray(sourceValue.value)) {
265
+ const values = sourceValue.value
266
+ .map((item) =>
267
+ getValueByPath((item ?? {}) as TAutomationOutputSource, restPath),
268
+ )
269
+ .filter(
270
+ (result) => result.found && result.value != null && result.value !== '',
271
+ )
272
+ .map((result) => result.value);
273
+
274
+ return {
275
+ found: true,
276
+ value: values.length ? values.join(', ') : undefined,
277
+ };
278
+ }
279
+
280
+ if (sourceValue.value && typeof sourceValue.value === 'object') {
281
+ const nested = getValueByPath(
282
+ sourceValue.value as TAutomationOutputSource,
283
+ restPath,
284
+ );
285
+
286
+ return nested.found ? nested : { found: false };
287
+ }
288
+
289
+ return { found: false };
290
+ };
291
+
292
+ const resolveReferenceOutputValue = async ({
293
+ definition,
294
+ defaultValue,
295
+ source,
296
+ subdomain,
297
+ path,
298
+ }: {
299
+ definition: TAutomationRuntimeOutputDefinition;
300
+ defaultValue?: unknown;
301
+ source: TAutomationOutputSource;
302
+ subdomain: string;
303
+ path: string;
304
+ }) => {
305
+ const [head, ...restParts] = path.split('.');
306
+ const restPath = restParts.join('.');
307
+
308
+ const sourceTypeVariable = findSourceTypeReferenceVariable(definition, head);
309
+
310
+ if (sourceTypeVariable?.sourceType) {
311
+ return {
312
+ found: true,
313
+ value: await resolveRecordReferenceValue({
314
+ subdomain,
315
+ type: sourceTypeVariable.sourceType,
316
+ target: source,
317
+ path,
318
+ defaultValue,
319
+ }),
320
+ };
321
+ }
322
+
323
+ if (!restPath) {
324
+ return { found: false };
325
+ }
326
+
327
+ const variable = findReferenceVariable(definition, head);
328
+
329
+ if (!variable) {
330
+ return { found: false };
331
+ }
332
+
333
+ const sourceType = variable.sourceType || getOutputSourceType(definition);
334
+ const sourceField = variable.field || variable.key;
335
+ const sourceValue = getValueByPath(source, sourceField);
336
+ const targetIds = toReferenceIds(
337
+ sourceValue.found ? sourceValue.value : null,
338
+ );
339
+
340
+ if (variable.referenceType && targetIds.length) {
341
+ return {
342
+ found: true,
343
+ value: await resolveRecordReferenceValue({
344
+ subdomain,
345
+ type: variable.referenceType,
346
+ targetIds,
347
+ path: restPath,
348
+ defaultValue,
349
+ }),
350
+ };
351
+ }
352
+
353
+ if (!sourceType) {
354
+ return { found: true, value: defaultValue };
355
+ }
356
+
357
+ return {
358
+ found: true,
359
+ value: await resolveRecordReferenceValue({
360
+ subdomain,
361
+ type: sourceType,
362
+ ...getSourceReferenceTarget(source),
363
+ path,
364
+ defaultValue,
365
+ }),
366
+ };
367
+ };
368
+
369
+ const resolveSourceReferenceOutputValue = async ({
370
+ definition,
371
+ defaultValue,
372
+ source,
373
+ subdomain,
374
+ path,
375
+ }: {
376
+ definition: TAutomationRuntimeOutputDefinition;
377
+ defaultValue?: unknown;
378
+ source: TAutomationOutputSource;
379
+ subdomain: string;
380
+ path: string;
381
+ }) => {
382
+ const sourceType = getOutputSourceType(definition);
383
+
384
+ if (!sourceType) {
385
+ return { found: false };
386
+ }
387
+
388
+ return {
389
+ found: true,
390
+ value: await resolveRecordReferenceValue({
391
+ subdomain,
392
+ type: sourceType,
393
+ ...getSourceReferenceTarget(source),
394
+ path,
395
+ defaultValue,
396
+ }),
397
+ };
398
+ };
399
+
400
+ const resolveOutputPathsFromDefinition = async ({
401
+ definition,
402
+ subdomain,
403
+ source,
404
+ paths,
405
+ defaultValue,
406
+ }: {
407
+ definition: TAutomationRuntimeOutputDefinition;
408
+ subdomain: string;
409
+ source: TAutomationOutputSource;
410
+ paths: string[];
411
+ defaultValue?: unknown;
412
+ }) => {
413
+ const result: Record<string, unknown> = {};
414
+
415
+ for (const path of [...new Set(paths)]) {
416
+ const currentSource = await resolveCurrentOutputSource({
417
+ definition,
418
+ path,
419
+ source,
420
+ subdomain,
421
+ });
422
+ const matchedResolver = Object.entries(definition.resolvers || {}).find(
423
+ ([resolverKey]) => matchAutomationResolverKey(resolverKey, path),
424
+ );
425
+
426
+ if (matchedResolver) {
427
+ result[path] = await matchedResolver[1]({
428
+ subdomain,
429
+ source: currentSource,
430
+ path,
431
+ defaultValue,
432
+ });
433
+ continue;
434
+ }
435
+
436
+ const propertySource = definition.propertySource;
437
+
438
+ if (propertySource && path.startsWith(`${propertySource.key}.`)) {
439
+ const propertyCode = path.slice(`${propertySource.key}.`.length);
440
+ const fields = await getPropertyFields(
441
+ subdomain,
442
+ propertySource.propertyType,
443
+ );
444
+ const field = fields.find(
445
+ (item) => item.code === propertyCode || item.name === propertyCode,
446
+ );
447
+
448
+ const propertiesData = currentSource.propertiesData as
449
+ | Record<string, unknown>
450
+ | undefined;
451
+
452
+ result[path] = field
453
+ ? propertiesData?.[field._id] ?? defaultValue
454
+ : defaultValue;
455
+ continue;
456
+ }
457
+
458
+ const nestedFields = resolveNestedFieldsOutputValue(
459
+ definition,
460
+ currentSource,
461
+ path,
462
+ );
463
+
464
+ if (nestedFields.found) {
465
+ result[path] = nestedFields.value ?? defaultValue;
466
+ continue;
467
+ }
468
+
469
+ const reference = await resolveReferenceOutputValue({
470
+ definition,
471
+ defaultValue,
472
+ source: currentSource,
473
+ subdomain,
474
+ path,
475
+ });
476
+
477
+ if (reference.found) {
478
+ result[path] = reference.value;
479
+ continue;
480
+ }
481
+
482
+ const direct = getValueByPath(currentSource, path);
483
+
484
+ if (direct.found) {
485
+ result[path] = direct.value;
486
+ continue;
487
+ }
488
+
489
+ const sourceReference = await resolveSourceReferenceOutputValue({
490
+ definition,
491
+ defaultValue,
492
+ source: currentSource,
493
+ subdomain,
494
+ path,
495
+ });
496
+
497
+ result[path] = sourceReference.found ? sourceReference.value : defaultValue;
498
+ }
499
+
500
+ return result;
501
+ };
502
+
503
+ const resolveDirectOutputValues = (
504
+ source: TAutomationOutputSource,
505
+ paths: string[],
506
+ defaultValue?: unknown,
507
+ ) => {
508
+ const result: Record<string, unknown> = {};
509
+
510
+ for (const path of [...new Set(paths)]) {
511
+ const direct = getValueByPath(source, path);
512
+ result[path] = direct.found ? direct.value : defaultValue;
513
+ }
514
+
515
+ return result;
516
+ };
517
+
518
+ const STATIC_OUTPUT_PLACEHOLDERS: Record<string, number> = {
519
+ now: 0,
520
+ tomorrow: 1,
521
+ nextWeek: 7,
522
+ nextMonth: 30,
523
+ };
524
+
525
+ const resolveStaticOutputPlaceholder = (token: string) => {
526
+ const normalized = token.trim();
527
+ const offsetDays = STATIC_OUTPUT_PLACEHOLDERS[normalized];
528
+
529
+ if (offsetDays !== undefined) {
530
+ return new Date(
531
+ Date.now() + offsetDays * 24 * 60 * 60 * 1000,
532
+ ).toISOString();
533
+ }
534
+
535
+ const dynamicDate = normalized.match(/^now\+(\d+)d$/);
536
+
537
+ if (dynamicDate) {
538
+ return new Date(
539
+ Date.now() + Number(dynamicDate[1]) * 24 * 60 * 60 * 1000,
540
+ ).toISOString();
541
+ }
542
+
543
+ return undefined;
544
+ };
545
+
546
+ const ENTITY_PLACEHOLDER_TYPES = [
547
+ 'user',
548
+ 'tag',
549
+ 'product',
550
+ 'company',
551
+ 'customer',
552
+ ];
553
+
554
+ const BRACKET_PLACEHOLDER_REGEX = /\[\[\s*([^\]]+?)\s*\]\]/g;
555
+
556
+ // [[ user.XCMwd... ]] -> "XCMwd..." (use split[1] when split[0] is an entity)
557
+ // [[ High ]] -> "High" (use the full token when split[1] is missing)
558
+ const resolveBracketPlaceholderToken = (token: string) => {
559
+ const trimmed = token.trim();
560
+ const parts = trimmed.split('.');
561
+
562
+ if (parts[1] !== undefined && ENTITY_PLACEHOLDER_TYPES.includes(parts[0])) {
563
+ return parts.slice(1).join('.');
564
+ }
565
+
566
+ return trimmed;
567
+ };
568
+
569
+ const extractOutputPlaceholderTokens = (value: string) => {
570
+ // Token body excludes both braces so malformed nested placeholders like
571
+ // "{{ trigger.{{ trigger.content }} }}" never match as a whole.
572
+ const regex = /{{\s*([^{}]+)\s*}}/g;
573
+ const tokens = new Map<string, TPlaceholderToken>();
574
+
575
+ for (const match of value.matchAll(regex)) {
576
+ const token = match[1].trim();
577
+
578
+ if (tokens.has(token)) {
579
+ continue;
580
+ }
581
+
582
+ // Workflow member scope: resolved from the child execution's frozen inputs
583
+ if (token.startsWith('input.')) {
584
+ tokens.set(token, {
585
+ token,
586
+ sourceKey: 'input',
587
+ sourceType: 'input',
588
+ path: token.slice('input.'.length),
589
+ });
590
+ continue;
591
+ }
592
+
593
+ if (token.startsWith('trigger.')) {
594
+ tokens.set(token, {
595
+ token,
596
+ sourceKey: 'trigger',
597
+ sourceType: 'trigger',
598
+ path: token.slice('trigger.'.length),
599
+ });
600
+ continue;
601
+ }
602
+
603
+ if (token.startsWith('actions.')) {
604
+ const [, actionId, ...pathParts] = token.split('.');
605
+
606
+ if (!actionId || !pathParts.length) {
607
+ continue;
608
+ }
609
+
610
+ tokens.set(token, {
611
+ token,
612
+ sourceKey: actionId,
613
+ sourceType: 'action',
614
+ path: pathParts.join('.'),
615
+ });
616
+ continue;
617
+ }
618
+
619
+ if (resolveStaticOutputPlaceholder(token) !== undefined) {
620
+ continue;
621
+ }
622
+
623
+ tokens.set(token, {
624
+ token,
625
+ sourceKey: 'trigger',
626
+ sourceType: 'trigger',
627
+ path: token,
628
+ });
629
+ }
630
+
631
+ return [...tokens.values()];
632
+ };
633
+
634
+ const getOutputPlaceholderTokensByValueKey = (
635
+ values: Record<string, unknown>,
636
+ ) => {
637
+ const tokensByValueKey: Record<string, TPlaceholderToken[]> = {};
638
+
639
+ const collectTokens = (
640
+ value: unknown,
641
+ result = new Map<string, TPlaceholderToken>(),
642
+ ) => {
643
+ if (typeof value === 'string') {
644
+ for (const token of extractOutputPlaceholderTokens(value)) {
645
+ result.set(token.token, token);
646
+ }
647
+
648
+ return result;
649
+ }
650
+
651
+ if (Array.isArray(value)) {
652
+ value.forEach((item) => collectTokens(item, result));
653
+ return result;
654
+ }
655
+
656
+ if (value && typeof value === 'object') {
657
+ Object.values(value).forEach((item) => collectTokens(item, result));
658
+ }
659
+
660
+ return result;
661
+ };
662
+
663
+ for (const [key, value] of Object.entries(values)) {
664
+ const tokens = [...collectTokens(value).values()];
665
+
666
+ if (tokens.length) {
667
+ tokensByValueKey[key] = tokens;
668
+ }
669
+ }
670
+
671
+ return tokensByValueKey;
672
+ };
673
+
674
+ const addPathToOutputResolveGroup = (
675
+ groups: Map<string, TOutputResolveGroup>,
676
+ {
677
+ groupKey,
678
+ nodeType,
679
+ source,
680
+ path,
681
+ }: {
682
+ groupKey: string;
683
+ nodeType: string;
684
+ source: TAutomationOutputSource;
685
+ path: string;
686
+ },
687
+ ) => {
688
+ if (!path) {
689
+ return;
690
+ }
691
+
692
+ const existingGroup = groups.get(groupKey);
693
+
694
+ if (existingGroup) {
695
+ existingGroup.paths.add(path);
696
+ return;
697
+ }
698
+
699
+ groups.set(groupKey, {
700
+ groupKey,
701
+ nodeType,
702
+ source,
703
+ paths: new Set([path]),
704
+ });
705
+ };
706
+
707
+ const buildOutputResolveGroups = ({
708
+ execution,
709
+ tokensByValueKey,
710
+ }: {
711
+ execution: IAutomationExecution;
712
+ tokensByValueKey: Record<string, TPlaceholderToken[]>;
713
+ }) => {
714
+ const groups = new Map<string, TOutputResolveGroup>();
715
+
716
+ for (const tokens of Object.values(tokensByValueKey)) {
717
+ for (const token of tokens) {
718
+ // Direct lookup on the frozen input values — no plugin definition
719
+ if (token.sourceType === 'input') {
720
+ addPathToOutputResolveGroup(groups, {
721
+ groupKey: 'input',
722
+ nodeType: '',
723
+ source: execution.inputs || {},
724
+ path: token.path,
725
+ });
726
+ continue;
727
+ }
728
+
729
+ if (token.sourceType === 'trigger') {
730
+ addPathToOutputResolveGroup(groups, {
731
+ groupKey: 'trigger',
732
+ nodeType: execution.triggerType,
733
+ source: execution.target || {},
734
+ path: token.path,
735
+ });
736
+ continue;
737
+ }
738
+
739
+ const action = (execution.actions || []).find(
740
+ (item) =>
741
+ item.actionId === token.sourceKey && item.status === 'success',
742
+ );
743
+
744
+ if (!action) {
745
+ continue;
746
+ }
747
+
748
+ addPathToOutputResolveGroup(groups, {
749
+ groupKey: `actions.${action.actionId}`,
750
+ nodeType: action.actionType,
751
+ source: action.result || {},
752
+ path: token.path,
753
+ });
754
+ }
755
+ }
756
+
757
+ return [...groups.values()];
758
+ };
759
+
760
+ const findAutomationNodeConstant = async (
761
+ nodeType: string,
762
+ kinds: ('triggers' | 'actions' | 'findObjectTargets')[],
763
+ ) => {
764
+ const [pluginName, moduleName, collectionName, relType] = splitType(
765
+ nodeType || '',
766
+ );
767
+
768
+ if (!pluginName) {
769
+ return undefined;
770
+ }
771
+
772
+ const plugin = await getPlugin(pluginName);
773
+ const constants = plugin.config?.meta?.automations?.constants;
774
+ const outputs = kinds.flatMap((kind) => constants?.[kind] || []);
775
+
776
+ return outputs.find((output) => {
777
+ if (output.type === nodeType || output.value === nodeType) {
778
+ return true;
779
+ }
780
+
781
+ const isMatch =
782
+ output.moduleName === moduleName &&
783
+ output.collectionName === collectionName;
784
+
785
+ if (relType) {
786
+ return (
787
+ isMatch &&
788
+ (output.relationType === relType || output.method === relType)
789
+ );
790
+ }
791
+
792
+ return isMatch;
793
+ });
794
+ };
795
+
796
+ const getAutomationOutputDefinition = async (nodeType: string) =>
797
+ (
798
+ await findAutomationNodeConstant(nodeType, [
799
+ 'triggers',
800
+ 'actions',
801
+ 'findObjectTargets',
802
+ ])
803
+ )?.output as TAutomationRuntimeOutputDefinition | undefined;
804
+
805
+ /** Whether the trigger's own plugin lets an automation re-run on every event. */
806
+ export const isReEnrollableTrigger = async (triggerType: string) =>
807
+ Boolean(
808
+ (
809
+ (await findAutomationNodeConstant(triggerType, ['triggers'])) as
810
+ | IAutomationsTriggerConfig
811
+ | undefined
812
+ )?.reEnrollable,
813
+ );
814
+
815
+ /** Whether the trigger's own plugin declared every event a new run. */
816
+ export const isReEnrollingTrigger = async (triggerType: string) =>
817
+ Boolean(
818
+ (
819
+ (await findAutomationNodeConstant(triggerType, ['triggers'])) as
820
+ | IAutomationsTriggerConfig
821
+ | undefined
822
+ )?.reEnrollment,
823
+ );
824
+
825
+ /**
826
+ * Fills an action's inputs from the trigger that started the run, through the
827
+ * mapping the trigger's own plugin declared. Nothing is returned when the
828
+ * trigger declares no mapping for that action.
829
+ */
830
+ export const resolveAutomationActionInputs = async ({
831
+ subdomain,
832
+ triggerType,
833
+ actionType,
834
+ target,
835
+ }: {
836
+ subdomain: string;
837
+ triggerType: string;
838
+ actionType: string;
839
+ target: TAutomationOutputSource;
840
+ }): Promise<Record<string, unknown> | undefined> => {
841
+ const trigger = (await findAutomationNodeConstant(triggerType, [
842
+ 'triggers',
843
+ ])) as IAutomationsTriggerConfig | undefined;
844
+ const mapping = trigger?.actionInputs?.[actionType];
845
+
846
+ if (!mapping || !Object.keys(mapping).length) {
847
+ return undefined;
848
+ }
849
+
850
+ const resolved = await resolveOutputPathsByNodeType({
851
+ subdomain,
852
+ nodeType: triggerType,
853
+ source: target || {},
854
+ paths: [...new Set(Object.values(mapping))],
855
+ });
856
+
857
+ return Object.fromEntries(
858
+ Object.entries(mapping).map(([inputKey, outputKey]) => [
859
+ inputKey,
860
+ resolved?.[outputKey],
861
+ ]),
862
+ );
863
+ };
864
+
865
+ const hasMatchingResolverKey = (
866
+ definition: TAutomationRuntimeOutputDefinition,
867
+ paths: string[],
868
+ ) => {
869
+ const resolverKeys = [
870
+ ...Object.keys(definition.resolvers || {}),
871
+ ...(definition.resolverKeys || []),
872
+ ];
873
+
874
+ return resolverKeys.some((resolverKey) =>
875
+ paths.some((path) => matchAutomationResolverKey(resolverKey, path)),
876
+ );
877
+ };
878
+
879
+ export const resolveOutputPathsByNodeType = async ({
880
+ subdomain,
881
+ nodeType,
882
+ source,
883
+ paths,
884
+ defaultValue,
885
+ runtimeOutputs,
886
+ }: {
887
+ subdomain: string;
888
+ nodeType: string;
889
+ source: TAutomationOutputSource;
890
+ paths: string[];
891
+ defaultValue?: unknown;
892
+ runtimeOutputs?: Record<string, TAutomationRuntimeOutputDefinition>;
893
+ }) => {
894
+ const [pluginName] = splitType(nodeType || '');
895
+ const runtimeDefinition = runtimeOutputs?.[nodeType];
896
+ const definition =
897
+ runtimeDefinition || (await getAutomationOutputDefinition(nodeType));
898
+
899
+ if (!definition) {
900
+ return resolveDirectOutputValues(source, paths, defaultValue);
901
+ }
902
+
903
+ if (runtimeDefinition) {
904
+ return resolveOutputPathsFromDefinition({
905
+ definition: runtimeDefinition,
906
+ subdomain,
907
+ source,
908
+ paths,
909
+ defaultValue,
910
+ });
911
+ }
912
+
913
+ if (pluginName && hasMatchingResolverKey(definition, paths)) {
914
+ return sendCoreModuleProducer({
915
+ subdomain,
916
+ moduleName: 'automations',
917
+ pluginName,
918
+ producerName: TAutomationProducers.RESOLVE_OUTPUT_PATHS,
919
+ input: {
920
+ nodeType,
921
+ source,
922
+ paths,
923
+ defaultValue,
924
+ },
925
+ defaultValue: resolveDirectOutputValues(source, paths, defaultValue),
926
+ });
927
+ }
928
+
929
+ return resolveOutputPathsFromDefinition({
930
+ definition,
931
+ subdomain,
932
+ source,
933
+ paths,
934
+ defaultValue,
935
+ });
936
+ };
937
+
938
+ const resolveOutputGroups = async ({
939
+ subdomain,
940
+ groups,
941
+ defaultValue,
942
+ runtimeOutputs,
943
+ }: {
944
+ subdomain: string;
945
+ groups: TOutputResolveGroup[];
946
+ defaultValue?: unknown;
947
+ runtimeOutputs?: Record<string, TAutomationRuntimeOutputDefinition>;
948
+ }) => {
949
+ const resolvedByToken: Record<string, unknown> = {};
950
+
951
+ for (const group of groups) {
952
+ const resolvedValues = await resolveOutputPathsByNodeType({
953
+ subdomain,
954
+ nodeType: group.nodeType,
955
+ source: group.source,
956
+ paths: [...group.paths],
957
+ defaultValue,
958
+ runtimeOutputs,
959
+ });
960
+
961
+ for (const [path, value] of Object.entries(resolvedValues || {})) {
962
+ resolvedByToken[`${group.groupKey}.${path}`] = value;
963
+ }
964
+ }
965
+
966
+ return resolvedByToken;
967
+ };
968
+
969
+ // {{ token }} -> resolved raw value (object/number/string), or undefined
970
+ const resolveCurlyPlaceholderToken = (
971
+ token: string,
972
+ resolvedByToken: Record<string, unknown>,
973
+ ) => {
974
+ const trimmedToken = token.trim();
975
+ const staticValue = resolveStaticOutputPlaceholder(trimmedToken);
976
+
977
+ return (
978
+ staticValue ??
979
+ resolvedByToken[trimmedToken] ??
980
+ resolvedByToken[`trigger.${trimmedToken}`]
981
+ );
982
+ };
983
+
984
+ // Replace all {{ }} placeholders in a string.
985
+ const replaceCurlyPlaceholders = (
986
+ value: string,
987
+ resolvedByToken: Record<string, unknown>,
988
+ defaultValue?: unknown,
989
+ ) =>
990
+ value.replace(/{{\s*([^{}]+)\s*}}/g, (_, token: string) => {
991
+ const resolved = resolveCurlyPlaceholderToken(token, resolvedByToken);
992
+
993
+ if (resolved === undefined || resolved === null) {
994
+ return defaultValue === undefined ? '' : String(defaultValue);
995
+ }
996
+
997
+ return String(resolved);
998
+ });
999
+
1000
+ // Replace all [[ ]] placeholders in a string.
1001
+ const replaceBracketPlaceholders = (value: string) =>
1002
+ value.replace(BRACKET_PLACEHOLDER_REGEX, (_, token: string) =>
1003
+ resolveBracketPlaceholderToken(token),
1004
+ );
1005
+
1006
+ const replaceOutputPlaceholderValue = (
1007
+ value: string,
1008
+ resolvedByToken: Record<string, unknown>,
1009
+ defaultValue?: unknown,
1010
+ keepUnresolvedPlaceholders = true,
1011
+ ) => {
1012
+ const regex = /{{\s*([^{}]+)\s*}}/g;
1013
+ const matches = [...value.matchAll(regex)];
1014
+ const fullTokenMatch =
1015
+ matches.length === 1 && matches[0][0].trim() === value.trim();
1016
+
1017
+ // Return the raw value when the entire string is a single {{ ... }} token.
1018
+ if (fullTokenMatch) {
1019
+ const resolved = resolveCurlyPlaceholderToken(
1020
+ matches[0][1],
1021
+ resolvedByToken,
1022
+ );
1023
+
1024
+ if (resolved !== undefined) {
1025
+ return resolved;
1026
+ }
1027
+
1028
+ return keepUnresolvedPlaceholders ? defaultValue ?? value : defaultValue;
1029
+ }
1030
+
1031
+ // Otherwise replace placeholders in curly -> bracket order.
1032
+ return replaceBracketPlaceholders(
1033
+ replaceCurlyPlaceholders(value, resolvedByToken, defaultValue),
1034
+ );
1035
+ };
1036
+
1037
+ const replaceOutputPlaceholdersInValue = (
1038
+ value: unknown,
1039
+ resolvedByToken: Record<string, unknown>,
1040
+ defaultValue?: unknown,
1041
+ keepUnresolvedPlaceholders?: boolean,
1042
+ ): unknown => {
1043
+ if (typeof value === 'string') {
1044
+ return replaceOutputPlaceholderValue(
1045
+ value,
1046
+ resolvedByToken,
1047
+ defaultValue,
1048
+ keepUnresolvedPlaceholders,
1049
+ );
1050
+ }
1051
+
1052
+ if (Array.isArray(value)) {
1053
+ return value.map((item) =>
1054
+ replaceOutputPlaceholdersInValue(
1055
+ item,
1056
+ resolvedByToken,
1057
+ defaultValue,
1058
+ keepUnresolvedPlaceholders,
1059
+ ),
1060
+ );
1061
+ }
1062
+
1063
+ if (value && typeof value === 'object') {
1064
+ return Object.fromEntries(
1065
+ Object.entries(value).map(([key, item]) => [
1066
+ key,
1067
+ replaceOutputPlaceholdersInValue(
1068
+ item,
1069
+ resolvedByToken,
1070
+ defaultValue,
1071
+ keepUnresolvedPlaceholders,
1072
+ ),
1073
+ ]),
1074
+ );
1075
+ }
1076
+
1077
+ return value;
1078
+ };
1079
+
1080
+ export const replaceOutputPlaceholders = async ({
1081
+ subdomain,
1082
+ execution,
1083
+ values,
1084
+ defaultValue,
1085
+ runtimeOutputs,
1086
+ keepUnresolvedPlaceholders = true,
1087
+ }: {
1088
+ subdomain: string;
1089
+ execution: IAutomationExecution;
1090
+ values: Record<string, unknown>;
1091
+ defaultValue?: unknown;
1092
+ runtimeOutputs?: Record<string, TAutomationRuntimeOutputDefinition>;
1093
+ keepUnresolvedPlaceholders?: boolean;
1094
+ }) => {
1095
+ const tokensByValueKey = getOutputPlaceholderTokensByValueKey(values);
1096
+ const resolvedByToken = Object.keys(tokensByValueKey).length
1097
+ ? await resolveOutputGroups({
1098
+ subdomain,
1099
+ groups: buildOutputResolveGroups({ execution, tokensByValueKey }),
1100
+ defaultValue,
1101
+ runtimeOutputs,
1102
+ })
1103
+ : {};
1104
+
1105
+ return Object.entries(values).reduce<Record<string, unknown>>(
1106
+ (acc, [key, value]) => {
1107
+ acc[key] = replaceOutputPlaceholdersInValue(
1108
+ value,
1109
+ resolvedByToken,
1110
+ defaultValue,
1111
+ keepUnresolvedPlaceholders,
1112
+ );
1113
+
1114
+ return acc;
1115
+ },
1116
+ {},
1117
+ );
1118
+ };
1119
+
1120
+ export const getAutomationNodeType = ({
1121
+ pluginName,
1122
+ node,
1123
+ kind,
1124
+ }: {
1125
+ pluginName: string;
1126
+ node: TAutomationNodeConfig;
1127
+ kind: 'trigger' | 'action';
1128
+ }) => {
1129
+ if (node.type) {
1130
+ return node.type;
1131
+ }
1132
+
1133
+ if (!node.moduleName || !node.collectionName) {
1134
+ return '';
1135
+ }
1136
+
1137
+ const propertyType = `${pluginName}:${node.moduleName}.${node.collectionName}`;
1138
+
1139
+ if (kind === 'action') {
1140
+ const actionNode = node as IAutomationsActionConfig;
1141
+ return `${propertyType}.${actionNode.method || 'create'}`;
1142
+ }
1143
+
1144
+ const triggerNode = node as IAutomationsTriggerConfig;
1145
+ return `${propertyType}${
1146
+ triggerNode.relationType ? `.${triggerNode.relationType}` : ''
1147
+ }`;
1148
+ };
1149
+
1150
+ export const toTransportOutput = (
1151
+ output?: TAutomationRuntimeOutputDefinition,
1152
+ ): TAutomationOutputDefinition | undefined => {
1153
+ if (!output) {
1154
+ return undefined;
1155
+ }
1156
+
1157
+ return {
1158
+ variables: output.variables,
1159
+ propertySource: output.propertySource,
1160
+ resolverKeys: Object.keys(output.resolvers || {}),
1161
+ };
1162
+ };
1163
+
1164
+ export const normalizeAutomationConstantsForTransport = (
1165
+ pluginName: string,
1166
+ constants?: AutomationConstants,
1167
+ ): AutomationConstants => {
1168
+ const triggers = (constants?.triggers || []).map((trigger) => ({
1169
+ ...trigger,
1170
+ type: getAutomationNodeType({
1171
+ pluginName,
1172
+ node: trigger,
1173
+ kind: 'trigger',
1174
+ }),
1175
+ output: toTransportOutput(trigger.output),
1176
+ }));
1177
+
1178
+ const actions = (constants?.actions || []).map((action) => ({
1179
+ ...action,
1180
+ type: getAutomationNodeType({
1181
+ pluginName,
1182
+ node: action,
1183
+ kind: 'action',
1184
+ }),
1185
+ output: toTransportOutput(action.output),
1186
+ }));
1187
+
1188
+ return {
1189
+ ...constants,
1190
+ triggers,
1191
+ actions,
1192
+ findObjectTargets: (constants?.findObjectTargets || []).map((target) => ({
1193
+ ...target,
1194
+ output: toTransportOutput(target.output),
1195
+ })),
1196
+ };
1197
+ };
1198
+
1199
+ export const buildRuntimeOutputsIndex = (
1200
+ pluginName: string,
1201
+ constants?: AutomationConstants,
1202
+ ) => {
1203
+ const runtimeOutputs: Record<string, TAutomationRuntimeOutputDefinition> = {};
1204
+
1205
+ for (const trigger of constants?.triggers || []) {
1206
+ if (!trigger.output) {
1207
+ continue;
1208
+ }
1209
+
1210
+ const type = getAutomationNodeType({
1211
+ pluginName,
1212
+ node: trigger,
1213
+ kind: 'trigger',
1214
+ });
1215
+
1216
+ if (type) {
1217
+ runtimeOutputs[type] = trigger.output;
1218
+ }
1219
+ }
1220
+
1221
+ for (const action of constants?.actions || []) {
1222
+ if (!action.output) {
1223
+ continue;
1224
+ }
1225
+
1226
+ const type = getAutomationNodeType({
1227
+ pluginName,
1228
+ node: action,
1229
+ kind: 'action',
1230
+ });
1231
+
1232
+ if (type) {
1233
+ runtimeOutputs[type] = action.output;
1234
+ }
1235
+ }
1236
+
1237
+ return runtimeOutputs;
1238
+ };