@flowuent-org/diagramming-core 1.3.10 → 1.4.1

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 (677) hide show
  1. package/.editorconfig +13 -13
  2. package/.eslintignore +1 -1
  3. package/.eslintrc.json +35 -35
  4. package/.prettierignore +3 -3
  5. package/.prettierrc +3 -3
  6. package/.vscode/settings.json +6 -6
  7. package/README.md +95 -95
  8. package/apps/authentication/tsconfig.app.json +23 -23
  9. package/apps/authentication/tsconfig.json +21 -21
  10. package/apps/authentication/tsconfig.spec.json +28 -28
  11. package/apps/diagramming/.eslintrc.json +18 -18
  12. package/apps/diagramming/index.html +16 -16
  13. package/apps/diagramming/project.json +53 -53
  14. package/apps/diagramming/public/aws-icons/compute/App Runner.svg +17 -17
  15. package/apps/diagramming/public/aws-icons/compute/Application Auto Scaling.svg +17 -17
  16. package/apps/diagramming/public/aws-icons/compute/Batch.svg +17 -17
  17. package/apps/diagramming/public/aws-icons/compute/Bottlerocket.svg +19 -19
  18. package/apps/diagramming/public/aws-icons/compute/Compute Optimizer.svg +17 -17
  19. package/apps/diagramming/public/aws-icons/compute/EC2 Auto Scaling.svg +17 -17
  20. package/apps/diagramming/public/aws-icons/compute/EC2 Image Builder.svg +17 -17
  21. package/apps/diagramming/public/aws-icons/compute/EC2.svg +17 -17
  22. package/apps/diagramming/public/aws-icons/compute/Elastic Beanstalk.svg +17 -17
  23. package/apps/diagramming/public/aws-icons/compute/Elastic Fabric Adapter.svg +17 -17
  24. package/apps/diagramming/public/aws-icons/compute/Fargate.svg +19 -19
  25. package/apps/diagramming/public/aws-icons/compute/Genomics CLI.svg +17 -17
  26. package/apps/diagramming/public/aws-icons/compute/Lambda.svg +17 -17
  27. package/apps/diagramming/public/aws-icons/compute/Local Zones.svg +17 -17
  28. package/apps/diagramming/public/aws-icons/compute/NICE DCV.svg +17 -17
  29. package/apps/diagramming/public/aws-icons/compute/NICE EnginFrame.svg +17 -17
  30. package/apps/diagramming/public/aws-icons/compute/Nitro Enclaves.svg +17 -17
  31. package/apps/diagramming/public/aws-icons/compute/Outposts family.svg +17 -17
  32. package/apps/diagramming/public/aws-icons/compute/Outposts rack.svg +17 -17
  33. package/apps/diagramming/public/aws-icons/compute/Outposts servers.svg +17 -17
  34. package/apps/diagramming/public/aws-icons/compute/ParallelCluster.svg +17 -17
  35. package/apps/diagramming/public/aws-icons/compute/Serverless Application Repository.svg +17 -17
  36. package/apps/diagramming/public/aws-icons/compute/SimSpace Weaver.svg +17 -17
  37. package/apps/diagramming/public/aws-icons/compute/Thinkbox Deadline.svg +17 -17
  38. package/apps/diagramming/public/aws-icons/compute/Thinkbox Frost.svg +17 -17
  39. package/apps/diagramming/public/aws-icons/compute/Thinkbox Sequoia.svg +17 -17
  40. package/apps/diagramming/public/aws-icons/compute/Thinkbox Stoke.svg +17 -17
  41. package/apps/diagramming/public/aws-icons/compute/Thinkbox XMesh.svg +17 -17
  42. package/apps/diagramming/public/aws-icons/compute/VMware Cloud on AWS.svg +17 -17
  43. package/apps/diagramming/public/aws-icons/compute/Wavelength.svg +17 -17
  44. package/apps/diagramming/public/aws-icons/container/ECS Anywhere.svg +17 -17
  45. package/apps/diagramming/public/aws-icons/container/EKS Anywhere.svg +17 -17
  46. package/apps/diagramming/public/aws-icons/container/EKS Cloud.svg +17 -17
  47. package/apps/diagramming/public/aws-icons/container/EKS Distro.svg +17 -17
  48. package/apps/diagramming/public/aws-icons/container/Elastic Container Registry.svg +17 -17
  49. package/apps/diagramming/public/aws-icons/container/Elastic Container Service.svg +17 -17
  50. package/apps/diagramming/public/aws-icons/container/Elastic Kubernetes Service.svg +17 -17
  51. package/apps/diagramming/public/aws-icons/container/Fargate.svg +19 -19
  52. package/apps/diagramming/public/aws-icons/container/Red Hat OpenShift Service on AWS.svg +17 -17
  53. package/apps/diagramming/public/aws-icons/database/Aurora.svg +17 -17
  54. package/apps/diagramming/public/aws-icons/database/Database Migration Service.svg +17 -17
  55. package/apps/diagramming/public/aws-icons/database/DocumentDB.svg +17 -17
  56. package/apps/diagramming/public/aws-icons/database/ElastiCache.svg +17 -17
  57. package/apps/diagramming/public/aws-icons/database/Keyspaces.svg +15 -15
  58. package/apps/diagramming/public/aws-icons/database/MemoryDB for Redis.svg +17 -17
  59. package/apps/diagramming/public/aws-icons/database/Neptune.svg +17 -17
  60. package/apps/diagramming/public/aws-icons/database/RDS on VMware.svg +17 -17
  61. package/apps/diagramming/public/aws-icons/database/RDS.svg +17 -17
  62. package/apps/diagramming/public/aws-icons/database/Timestream.svg +17 -17
  63. package/apps/diagramming/public/aws-icons/networking/App Mesh.svg +17 -17
  64. package/apps/diagramming/public/aws-icons/networking/Client VPN.svg +17 -17
  65. package/apps/diagramming/public/aws-icons/networking/Cloud Directory.svg +17 -17
  66. package/apps/diagramming/public/aws-icons/networking/Cloud Map.svg +17 -17
  67. package/apps/diagramming/public/aws-icons/networking/Cloud WAN.svg +17 -17
  68. package/apps/diagramming/public/aws-icons/networking/CloudFront.svg +17 -17
  69. package/apps/diagramming/public/aws-icons/networking/Direct Connect.svg +17 -17
  70. package/apps/diagramming/public/aws-icons/networking/Elastic Load Balancing.svg +17 -17
  71. package/apps/diagramming/public/aws-icons/networking/Global Accelerator.svg +17 -17
  72. package/apps/diagramming/public/aws-icons/networking/Private 5G.svg +17 -17
  73. package/apps/diagramming/public/aws-icons/networking/PrivateLink.svg +17 -17
  74. package/apps/diagramming/public/aws-icons/networking/Route 53.svg +17 -17
  75. package/apps/diagramming/public/aws-icons/networking/Site to Site VPN.svg +17 -17
  76. package/apps/diagramming/public/aws-icons/networking/Transit Gateway.svg +17 -17
  77. package/apps/diagramming/public/aws-icons/networking/VPC Lattice.svg +17 -17
  78. package/apps/diagramming/public/aws-icons/networking/Verified Access.svg +17 -17
  79. package/apps/diagramming/public/aws-icons/networking/Virtual Private Cloud.svg +17 -17
  80. package/apps/diagramming/public/aws-icons/security/Artifact.svg +17 -17
  81. package/apps/diagramming/public/aws-icons/security/Audit Manager.svg +17 -17
  82. package/apps/diagramming/public/aws-icons/security/Certificate Manager.svg +17 -17
  83. package/apps/diagramming/public/aws-icons/security/CloudHSM.svg +17 -17
  84. package/apps/diagramming/public/aws-icons/security/Cognito.svg +17 -17
  85. package/apps/diagramming/public/aws-icons/security/Detective.svg +17 -17
  86. package/apps/diagramming/public/aws-icons/security/Directory Service.svg +17 -17
  87. package/apps/diagramming/public/aws-icons/security/Firewall Manager.svg +17 -17
  88. package/apps/diagramming/public/aws-icons/security/GuardDuty.svg +17 -17
  89. package/apps/diagramming/public/aws-icons/security/IAM Identity Center.svg +17 -17
  90. package/apps/diagramming/public/aws-icons/security/Identity and Access Management.svg +17 -17
  91. package/apps/diagramming/public/aws-icons/security/Inspector.svg +17 -17
  92. package/apps/diagramming/public/aws-icons/security/Key Management Service.svg +17 -17
  93. package/apps/diagramming/public/aws-icons/security/Macie.svg +17 -17
  94. package/apps/diagramming/public/aws-icons/security/Network Firewall.svg +17 -17
  95. package/apps/diagramming/public/aws-icons/security/Resource Access Manager.svg +17 -17
  96. package/apps/diagramming/public/aws-icons/security/Secrets Manager.svg +17 -17
  97. package/apps/diagramming/public/aws-icons/security/Security Hub.svg +17 -17
  98. package/apps/diagramming/public/aws-icons/security/Security Lake.svg +17 -17
  99. package/apps/diagramming/public/aws-icons/security/Shield.svg +17 -17
  100. package/apps/diagramming/public/aws-icons/security/Signer.svg +17 -17
  101. package/apps/diagramming/public/aws-icons/security/Verified Permissions.svg +17 -17
  102. package/apps/diagramming/public/aws-icons/security/WAF.svg +17 -17
  103. package/apps/diagramming/public/aws-icons/storage/Backup.svg +17 -17
  104. package/apps/diagramming/public/aws-icons/storage/EFS.svg +17 -17
  105. package/apps/diagramming/public/aws-icons/storage/Elastic Block Store.svg +17 -17
  106. package/apps/diagramming/public/aws-icons/storage/Elastic Disaster Recovery.svg +15 -15
  107. package/apps/diagramming/public/aws-icons/storage/FSx for Lustre.svg +17 -17
  108. package/apps/diagramming/public/aws-icons/storage/FSx for NetApp ONTAP.svg +17 -17
  109. package/apps/diagramming/public/aws-icons/storage/FSx for OpenZFS.svg +17 -17
  110. package/apps/diagramming/public/aws-icons/storage/FSx for WFS.svg +17 -17
  111. package/apps/diagramming/public/aws-icons/storage/FSx.svg +17 -17
  112. package/apps/diagramming/public/aws-icons/storage/File Cache.svg +17 -17
  113. package/apps/diagramming/public/aws-icons/storage/S3 on Outposts.svg +17 -17
  114. package/apps/diagramming/public/aws-icons/storage/Simple Storage Service Glacier.svg +17 -17
  115. package/apps/diagramming/public/aws-icons/storage/Simple Storage Service.svg +17 -17
  116. package/apps/diagramming/public/aws-icons/storage/Snowball Edge.svg +17 -17
  117. package/apps/diagramming/public/aws-icons/storage/Snowball.svg +17 -17
  118. package/apps/diagramming/public/aws-icons/storage/Snowcone.svg +17 -17
  119. package/apps/diagramming/public/aws-icons/storage/Snowmobile.svg +17 -17
  120. package/apps/diagramming/public/aws-icons/storage/Storage Gateway.svg +17 -17
  121. package/apps/diagramming/public/azure-icons/compute/02112-icon-service-Automanaged-VM.svg +1 -1
  122. package/apps/diagramming/public/azure-icons/databases/02390-icon-service-Azure-SQL.svg +1 -1
  123. package/apps/diagramming/public/azure-icons/databases/02392-icon-service-SSIS-Lift-And-Shift-IR.svg +1 -1
  124. package/apps/diagramming/public/azure-icons/networking/02145-icon-service-Resource-Management-Private-Link.svg +1 -1
  125. package/apps/diagramming/public/azure-icons/security/02247-icon-service-Microsoft-Defender-for-IoT.svg +1 -1
  126. package/apps/diagramming/public/sample-node-complete.json +63 -63
  127. package/apps/diagramming/public/sample-node-data.json +63 -63
  128. package/apps/diagramming/src/AutomationDiagramData.ts +147 -480
  129. package/apps/diagramming/src/CollaborationDiagramData.ts +127 -127
  130. package/apps/diagramming/src/CustomIconExamples.ts +233 -233
  131. package/apps/diagramming/src/DiagramTabs.tsx +205 -205
  132. package/apps/diagramming/src/Pages/DevPlayground.tsx +3 -3
  133. package/apps/diagramming/src/Pages/Home.tsx +111 -111
  134. package/apps/diagramming/src/SequenceDiagramData.ts +215 -215
  135. package/apps/diagramming/src/StateMachineDiagramData.ts +64 -64
  136. package/apps/diagramming/src/UseCaseDiagramData.ts +52 -52
  137. package/apps/diagramming/src/cloud-data.ts +371 -371
  138. package/apps/diagramming/src/components/AddNodeView.tsx +252 -252
  139. package/apps/diagramming/src/createSelecors.tsx +17 -17
  140. package/apps/diagramming/src/index.scss +12 -12
  141. package/apps/diagramming/src/main.tsx +463 -463
  142. package/apps/diagramming/src/node-data.ts +664 -664
  143. package/apps/diagramming/src/sample-workflow-content.ts +55 -55
  144. package/apps/diagramming/src/stencil-items.ts +31 -31
  145. package/apps/diagramming/src/style.css +13 -13
  146. package/apps/diagramming/src/tabsStore.tsx +152 -152
  147. package/apps/diagramming/src/vite-env.d.ts +1 -1
  148. package/apps/diagramming/tsconfig.app.json +23 -23
  149. package/apps/diagramming/tsconfig.json +21 -21
  150. package/apps/diagramming/tsconfig.spec.json +28 -28
  151. package/apps/diagramming/vite.config.ts +34 -34
  152. package/apps/diagramming/webpack.config.js +13 -13
  153. package/apps/workflow/.eslintrc.json +18 -18
  154. package/apps/workflow/group/group-form-hooks/index.ts +3 -3
  155. package/apps/workflow/group/group-form-hooks/useFormValidation.ts +20 -20
  156. package/apps/workflow/group/group-form-schema/SettingsTabFormSchema.ts +7 -7
  157. package/apps/workflow/group/group-form-schema/index.ts +3 -3
  158. package/apps/workflow/i18n.ts +19 -19
  159. package/apps/workflow/index.html +16 -16
  160. package/apps/workflow/locales/en/translation.json +713 -713
  161. package/apps/workflow/project.json +8 -8
  162. package/apps/workflow/src/app/app.module.css +1 -1
  163. package/apps/workflow/src/app/app.spec.tsx +15 -15
  164. package/apps/workflow/src/app/app.tsx +370 -370
  165. package/apps/workflow/src/main.tsx +13 -13
  166. package/apps/workflow/src/styles.css +1 -1
  167. package/apps/workflow/src/theme/index.ts +546 -546
  168. package/apps/workflow/tsconfig.app.json +23 -23
  169. package/apps/workflow/tsconfig.json +21 -21
  170. package/apps/workflow/tsconfig.spec.json +28 -28
  171. package/apps/workflow/vite.config.ts +51 -51
  172. package/nx.json +58 -58
  173. package/package.json +1 -1
  174. package/packages/api/.babelrc +12 -12
  175. package/packages/api/.eslintrc.json +18 -18
  176. package/packages/api/README.md +7 -7
  177. package/packages/api/project.json +8 -8
  178. package/packages/api/src/index.ts +3 -3
  179. package/packages/api/src/lib/jsonPlaceholderService/endpoints.ts +3 -3
  180. package/packages/api/src/lib/jsonPlaceholderService/service.ts +13 -13
  181. package/packages/api/tsconfig.json +17 -17
  182. package/packages/api/tsconfig.lib.json +24 -24
  183. package/packages/atoms/.babelrc +12 -12
  184. package/packages/atoms/.eslintrc.json +18 -18
  185. package/packages/atoms/README.md +7 -7
  186. package/packages/atoms/forms/AuthenticationTabForm/authenticationTabForm.json +224 -224
  187. package/packages/atoms/forms/AuthenticationTabForm/index.tsx +255 -255
  188. package/packages/atoms/forms/SettingsTabForm/index.tsx +85 -85
  189. package/packages/atoms/forms/SettingsTabForm/settingTabForm.json +27 -27
  190. package/packages/atoms/forms/index.ts +4 -4
  191. package/packages/atoms/project.json +8 -8
  192. package/packages/atoms/src/index.ts +33 -33
  193. package/packages/atoms/src/lib/Accordion/Accordion.module.css +7 -7
  194. package/packages/atoms/src/lib/Accordion/Accordion.spec.tsx +13 -13
  195. package/packages/atoms/src/lib/Accordion/Accordion.tsx +29 -29
  196. package/packages/atoms/src/lib/Alert/Alert.module.css +7 -7
  197. package/packages/atoms/src/lib/Alert/Alert.spec.tsx +10 -10
  198. package/packages/atoms/src/lib/Alert/Alert.tsx +19 -19
  199. package/packages/atoms/src/lib/Avatar/Avatar.module.css +7 -7
  200. package/packages/atoms/src/lib/Avatar/Avatar.spec.tsx +10 -10
  201. package/packages/atoms/src/lib/Avatar/Avatar.tsx +22 -22
  202. package/packages/atoms/src/lib/Box/Box.module.css +7 -7
  203. package/packages/atoms/src/lib/Box/Box.spec.tsx +10 -10
  204. package/packages/atoms/src/lib/Box/Box.tsx +19 -19
  205. package/packages/atoms/src/lib/BulkEdit/BulkEdit.module.css +7 -7
  206. package/packages/atoms/src/lib/BulkEdit/BulkEdit.spec.tsx +10 -10
  207. package/packages/atoms/src/lib/BulkEdit/BulkEdit.tsx +15 -15
  208. package/packages/atoms/src/lib/Button/Button.module.css +7 -7
  209. package/packages/atoms/src/lib/Button/Button.spec.tsx +10 -10
  210. package/packages/atoms/src/lib/Button/Button.tsx +78 -78
  211. package/packages/atoms/src/lib/Card/Card.module.css +7 -7
  212. package/packages/atoms/src/lib/Card/Card.spec.tsx +10 -10
  213. package/packages/atoms/src/lib/Card/Card.tsx +19 -19
  214. package/packages/atoms/src/lib/CardContent/CardContent.module.css +7 -7
  215. package/packages/atoms/src/lib/CardContent/CardContent.spec.tsx +10 -10
  216. package/packages/atoms/src/lib/CardContent/CardContent.tsx +22 -22
  217. package/packages/atoms/src/lib/FormTextField/FormTextField.module.css +7 -7
  218. package/packages/atoms/src/lib/FormTextField/FormTextField.spec.tsx +10 -10
  219. package/packages/atoms/src/lib/FormTextField/FormTextField.tsx +35 -35
  220. package/packages/atoms/src/lib/Grid/Grid.module.css +7 -7
  221. package/packages/atoms/src/lib/Grid/Grid.spec.tsx +10 -10
  222. package/packages/atoms/src/lib/Grid/Grid.tsx +19 -19
  223. package/packages/atoms/src/lib/Stack/Stack.module.css +7 -7
  224. package/packages/atoms/src/lib/Stack/Stack.spec.tsx +10 -10
  225. package/packages/atoms/src/lib/Stack/Stack.tsx +19 -19
  226. package/packages/atoms/src/lib/Switch/Switch.module.css +7 -7
  227. package/packages/atoms/src/lib/Switch/Switch.spec.tsx +10 -10
  228. package/packages/atoms/src/lib/Switch/Switch.tsx +46 -46
  229. package/packages/atoms/src/lib/TableView/TableView.module.css +7 -7
  230. package/packages/atoms/src/lib/TableView/TableView.spec.tsx +10 -10
  231. package/packages/atoms/src/lib/TableView/TableView.tsx +88 -88
  232. package/packages/atoms/src/lib/TextField/TextField.module.css +7 -7
  233. package/packages/atoms/src/lib/TextField/TextField.spec.tsx +10 -10
  234. package/packages/atoms/src/lib/TextField/TextField.tsx +17 -17
  235. package/packages/atoms/src/lib/Typography/Typography.module.css +7 -7
  236. package/packages/atoms/src/lib/Typography/Typography.spec.tsx +10 -10
  237. package/packages/atoms/src/lib/Typography/Typography.tsx +22 -22
  238. package/packages/atoms/tsconfig.json +17 -17
  239. package/packages/atoms/tsconfig.lib.json +30 -30
  240. package/packages/common/.babelrc +12 -12
  241. package/packages/common/.eslintrc.json +18 -18
  242. package/packages/common/README.md +7 -7
  243. package/packages/common/project.json +8 -8
  244. package/packages/common/src/index.ts +4 -4
  245. package/packages/common/src/lib/generateRandomProfilePic.ts +3 -3
  246. package/packages/common/src/lib/generateValidationSchema.ts +46 -46
  247. package/packages/common/tsconfig.json +17 -17
  248. package/packages/common/tsconfig.lib.json +24 -24
  249. package/packages/contexts/.babelrc +12 -12
  250. package/packages/contexts/.eslintrc.json +18 -18
  251. package/packages/contexts/README.md +7 -7
  252. package/packages/contexts/project.json +8 -8
  253. package/packages/contexts/src/index.ts +2 -2
  254. package/packages/contexts/tsconfig.json +17 -17
  255. package/packages/contexts/tsconfig.lib.json +24 -24
  256. package/packages/diagrams/.babelrc +12 -12
  257. package/packages/diagrams/.ctirc +208 -208
  258. package/packages/diagrams/.eslintrc.json +17 -17
  259. package/packages/diagrams/CUSTOM_ICONS.md +232 -232
  260. package/packages/diagrams/GOOGLE_SHEETS_IMPLEMENTATION.md +233 -233
  261. package/packages/diagrams/NODE_DATA_UPDATE_API.md +430 -430
  262. package/packages/diagrams/README.md +7 -7
  263. package/packages/diagrams/UNDO_REDO_API.md +306 -306
  264. package/packages/diagrams/locales/en/translation.json +713 -713
  265. package/packages/diagrams/package.json +27 -27
  266. package/packages/diagrams/pnpm-lock.yaml +2606 -2606
  267. package/packages/diagrams/project.json +42 -42
  268. package/packages/diagrams/rollup.config.js +26 -26
  269. package/packages/diagrams/src/DiagramFlow.tsx +7 -7
  270. package/packages/diagrams/src/declarations.d.ts +7 -7
  271. package/packages/diagrams/src/index.ts +8 -1
  272. package/packages/diagrams/src/index.ts.bak +99 -99
  273. package/packages/diagrams/src/lib/assets/markers/markers.param.tsx +101 -101
  274. package/packages/diagrams/src/lib/assets/markers/markers.type.ts +10 -10
  275. package/packages/diagrams/src/lib/atoms/ActorNode.tsx +123 -123
  276. package/packages/diagrams/src/lib/atoms/AddParallelColButton.tsx +26 -26
  277. package/packages/diagrams/src/lib/atoms/BendpointNode.tsx +71 -71
  278. package/packages/diagrams/src/lib/atoms/CardBlockTypeSelector.tsx +35 -35
  279. package/packages/diagrams/src/lib/atoms/CardEditableTitle.tsx +76 -76
  280. package/packages/diagrams/src/lib/atoms/CardMainContent.tsx +19 -19
  281. package/packages/diagrams/src/lib/atoms/ConnectionPoints.tsx +149 -149
  282. package/packages/diagrams/src/lib/atoms/ContentAssist.tsx +341 -341
  283. package/packages/diagrams/src/lib/atoms/DiagramControls.tsx +56 -56
  284. package/packages/diagrams/src/lib/atoms/ExpressionInput.tsx +437 -437
  285. package/packages/diagrams/src/lib/atoms/FloatingConnectionLine.tsx +73 -73
  286. package/packages/diagrams/src/lib/atoms/LazyIcon.tsx +31 -31
  287. package/packages/diagrams/src/lib/atoms/MarkerSelector.tsx +106 -106
  288. package/packages/diagrams/src/lib/atoms/MultiSelectInput.tsx +87 -87
  289. package/packages/diagrams/src/lib/atoms/ParameterInput.tsx +199 -199
  290. package/packages/diagrams/src/lib/atoms/PropertyInput.tsx +114 -114
  291. package/packages/diagrams/src/lib/atoms/StyledBox.tsx +69 -69
  292. package/packages/diagrams/src/lib/atoms/ValidationError.tsx +37 -37
  293. package/packages/diagrams/src/lib/atoms/ValidationMessage.tsx +63 -63
  294. package/packages/diagrams/src/lib/components/AiButton.tsx +52 -52
  295. package/packages/diagrams/src/lib/components/ControlEdgeList.tsx +303 -303
  296. package/packages/diagrams/src/lib/components/CreateFunctionModal.tsx +264 -264
  297. package/packages/diagrams/src/lib/components/CustomCodeModal.tsx +287 -287
  298. package/packages/diagrams/src/lib/components/DiagramPanel.tsx +331 -331
  299. package/packages/diagrams/src/lib/components/FunctionModalTooltip.tsx +30 -30
  300. package/packages/diagrams/src/lib/components/GraphQLCustomCodeModal.tsx +210 -210
  301. package/packages/diagrams/src/lib/components/Header.tsx +143 -143
  302. package/packages/diagrams/src/lib/components/MiniMapCommon.tsx +24 -24
  303. package/packages/diagrams/src/lib/components/ResizeIcon.tsx +81 -81
  304. package/packages/diagrams/src/lib/components/SideBar.tsx +40 -40
  305. package/packages/diagrams/src/lib/components/automation/AISuggestionsModal.tsx +269 -269
  306. package/packages/diagrams/src/lib/components/automation/AISuggestionsPanel.tsx +28 -175
  307. package/packages/diagrams/src/lib/components/automation/AutomationApiNode.tsx +1 -1
  308. package/packages/diagrams/src/lib/components/automation/AutomationDecisionNode.tsx +94 -0
  309. package/packages/diagrams/src/lib/components/automation/AutomationEndNode.tsx +1 -1
  310. package/packages/diagrams/src/lib/components/automation/AutomationExecutionPanel.tsx +439 -439
  311. package/packages/diagrams/src/lib/components/automation/AutomationFormattingNode.tsx +1 -1
  312. package/packages/diagrams/src/lib/components/automation/AutomationInteractionNode.tsx +693 -693
  313. package/packages/diagrams/src/lib/components/automation/AutomationMonitoringNode.tsx +399 -399
  314. package/packages/diagrams/src/lib/components/automation/AutomationNavigationNode.tsx +1 -1
  315. package/packages/diagrams/src/lib/components/automation/AutomationNodeCard.tsx +414 -0
  316. package/packages/diagrams/src/lib/components/automation/AutomationSlackNode.tsx +694 -694
  317. package/packages/diagrams/src/lib/components/automation/AutomationSmsNode.tsx +62 -0
  318. package/packages/diagrams/src/lib/components/automation/AutomationStartNode.tsx +1 -1
  319. package/packages/diagrams/src/lib/components/automation/AutomationTelegramNode.tsx +664 -664
  320. package/packages/diagrams/src/lib/components/automation/AutomationVoiceCallNode.tsx +65 -0
  321. package/packages/diagrams/src/lib/components/automation/AutomationWorkflowNode.tsx +85 -0
  322. package/packages/diagrams/src/lib/components/automation/NodeAIAssistantPopup.tsx +504 -504
  323. package/packages/diagrams/src/lib/components/automation/index.ts +29 -19
  324. package/packages/diagrams/src/lib/components/automation/statusColors.ts +124 -124
  325. package/packages/diagrams/src/lib/contexts/CardDataProvider.tsx +111 -111
  326. package/packages/diagrams/src/lib/contexts/DiagramProvider.tsx +392 -391
  327. package/packages/diagrams/src/lib/contexts/diagramStoreTypes.tsx +134 -134
  328. package/packages/diagrams/src/lib/contexts/onConnect.ts +39 -39
  329. package/packages/diagrams/src/lib/contexts/onDragStart.ts +45 -45
  330. package/packages/diagrams/src/lib/contexts/onNodeDragEnd.ts +179 -179
  331. package/packages/diagrams/src/lib/contexts/onNodesChange.ts +406 -406
  332. package/packages/diagrams/src/lib/contexts/onReconnect.ts +59 -59
  333. package/packages/diagrams/src/lib/contexts/onWorkflowNodeDelete.ts +65 -65
  334. package/packages/diagrams/src/lib/contexts/setContentHeight.ts +14 -14
  335. package/packages/diagrams/src/lib/contexts/setDiagramType.ts +10 -10
  336. package/packages/diagrams/src/lib/contexts/setEdgeShapeType.ts +7 -7
  337. package/packages/diagrams/src/lib/contexts/setEdges.ts +9 -9
  338. package/packages/diagrams/src/lib/contexts/setLayoutDirection.ts +9 -9
  339. package/packages/diagrams/src/lib/contexts/setNodeSetting.ts +17 -17
  340. package/packages/diagrams/src/lib/contexts/setNodes.ts +10 -10
  341. package/packages/diagrams/src/lib/contexts/setPannable.ts +7 -7
  342. package/packages/diagrams/src/lib/contexts/setSelectedEdge.ts +7 -7
  343. package/packages/diagrams/src/lib/contexts/setSelectedNode.ts +7 -7
  344. package/packages/diagrams/src/lib/contexts/undo.ts +163 -163
  345. package/packages/diagrams/src/lib/contexts/updateNodeSetting.ts +17 -17
  346. package/packages/diagrams/src/lib/examples/TwilioWhatsAppConfigExample.ts +128 -128
  347. package/packages/diagrams/src/lib/externals.ts +4 -4
  348. package/packages/diagrams/src/lib/hooks/customUseReactFlow.tsx +90 -90
  349. package/packages/diagrams/src/lib/hooks/updateNodes.ts +45 -45
  350. package/packages/diagrams/src/lib/hooks/useAddChildButton.tsx +61 -61
  351. package/packages/diagrams/src/lib/hooks/useAddSwitchCase.ts +75 -75
  352. package/packages/diagrams/src/lib/hooks/useAutoRegisterFunctions.ts +135 -135
  353. package/packages/diagrams/src/lib/hooks/useAutoRegisterVariables.ts +286 -286
  354. package/packages/diagrams/src/lib/hooks/useDeleteNodeByEvent.ts +64 -64
  355. package/packages/diagrams/src/lib/hooks/useDragCallbacks.tsx +122 -122
  356. package/packages/diagrams/src/lib/hooks/useFormValidation.ts +349 -349
  357. package/packages/diagrams/src/lib/hooks/useFunctionFormCallbacks.ts +136 -136
  358. package/packages/diagrams/src/lib/hooks/useIsSelectedNode.ts +11 -11
  359. package/packages/diagrams/src/lib/hooks/useModalControls.ts +13 -13
  360. package/packages/diagrams/src/lib/hooks/useNodeDragHandlers.ts +43 -43
  361. package/packages/diagrams/src/lib/hooks/useNodeSelection.ts +55 -55
  362. package/packages/diagrams/src/lib/hooks/useRenderDividers.tsx +19 -19
  363. package/packages/diagrams/src/lib/hooks/useRenderPins.tsx +74 -74
  364. package/packages/diagrams/src/lib/hooks/useResizeObserver.ts +21 -21
  365. package/packages/diagrams/src/lib/hooks/useTreeChildNode.ts +536 -536
  366. package/packages/diagrams/src/lib/i18n.ts +42 -42
  367. package/packages/diagrams/src/lib/icons/icons.tsx +324 -0
  368. package/packages/diagrams/src/lib/icons/index.ts +29 -0
  369. package/packages/diagrams/src/lib/icons/types.ts +7 -0
  370. package/packages/diagrams/src/lib/molecules/AddingBlock.tsx +147 -147
  371. package/packages/diagrams/src/lib/molecules/AvailableVariablesDisplay.tsx +57 -57
  372. package/packages/diagrams/src/lib/molecules/Block.tsx +143 -143
  373. package/packages/diagrams/src/lib/molecules/BlockProvider.tsx +28 -28
  374. package/packages/diagrams/src/lib/molecules/BlockWrapper.tsx +14 -14
  375. package/packages/diagrams/src/lib/molecules/ConditionRule.tsx +131 -131
  376. package/packages/diagrams/src/lib/molecules/DraggablePane.tsx +198 -198
  377. package/packages/diagrams/src/lib/molecules/EntityNodeBlocks.tsx +66 -66
  378. package/packages/diagrams/src/lib/molecules/SideHandles.tsx +215 -215
  379. package/packages/diagrams/src/lib/molecules/StencilItem.tsx +85 -85
  380. package/packages/diagrams/src/lib/molecules/WorkflowNodeActionButtons.tsx +62 -62
  381. package/packages/diagrams/src/lib/molecules/animated-add-button.tsx +83 -83
  382. package/packages/diagrams/src/lib/molecules/json-viewer.tsx +107 -107
  383. package/packages/diagrams/src/lib/organisms/AddNodeView.tsx +102 -102
  384. package/packages/diagrams/src/lib/organisms/Card/EntityNode.tsx +259 -259
  385. package/packages/diagrams/src/lib/organisms/Card/card.params.ts +29 -29
  386. package/packages/diagrams/src/lib/organisms/Card/card.types.ts +5 -5
  387. package/packages/diagrams/src/lib/organisms/CodeModal.tsx +105 -105
  388. package/packages/diagrams/src/lib/organisms/ConditionRuleGroup.tsx +138 -138
  389. package/packages/diagrams/src/lib/organisms/CustomEdge/EdgeMarkers.tsx +51 -51
  390. package/packages/diagrams/src/lib/organisms/CustomEdge/custom-edge-generator.tsx +135 -135
  391. package/packages/diagrams/src/lib/organisms/CustomEdge/custom-edge.params.ts +6 -6
  392. package/packages/diagrams/src/lib/organisms/CustomEdge/custom-edge.type.ts +15 -15
  393. package/packages/diagrams/src/lib/organisms/CustomEdge/useCreateBendPoint.tsx +121 -121
  394. package/packages/diagrams/src/lib/organisms/CustomEdge/useEdgeModal.ts +37 -37
  395. package/packages/diagrams/src/lib/organisms/CustomEdge/useEdgePath.tsx +99 -99
  396. package/packages/diagrams/src/lib/organisms/DownloadPanel.tsx +345 -345
  397. package/packages/diagrams/src/lib/organisms/EdgeModal.tsx +243 -243
  398. package/packages/diagrams/src/lib/organisms/HistoryPane.tsx +118 -118
  399. package/packages/diagrams/src/lib/organisms/NodeContextMenu.tsx +259 -259
  400. package/packages/diagrams/src/lib/organisms/PropertiesPane.tsx +276 -276
  401. package/packages/diagrams/src/lib/organisms/SmartDynamicForm.tsx +226 -226
  402. package/packages/diagrams/src/lib/organisms/Stencil.tsx +60 -60
  403. package/packages/diagrams/src/lib/organisms/UseDiagramStore.tsx +4 -4
  404. package/packages/diagrams/src/lib/organisms/WorkFlowNode/NodeActionButtons.tsx +45 -45
  405. package/packages/diagrams/src/lib/organisms/WorkFlowNode/NodeTypeDisplay.tsx +114 -114
  406. package/packages/diagrams/src/lib/organisms/WorkFlowNode/WorkflowNodeIcons.tsx +21 -23
  407. package/packages/diagrams/src/lib/organisms/WorkflowNode.tsx +484 -484
  408. package/packages/diagrams/src/lib/services/GoogleSheetsService.ts +961 -961
  409. package/packages/diagrams/src/lib/services/SlackService.ts +134 -134
  410. package/packages/diagrams/src/lib/services/TwilioWhatsAppService.ts +273 -273
  411. package/packages/diagrams/src/lib/styles.css +55 -55
  412. package/packages/diagrams/src/lib/templates/PageLinks.tsx +13 -13
  413. package/packages/diagrams/src/lib/templates/arch/ArchDiagram.tsx +793 -793
  414. package/packages/diagrams/src/lib/templates/arch/components/EdgeDialog.tsx +82 -82
  415. package/packages/diagrams/src/lib/templates/arch/components/EdgeSettings.tsx +81 -81
  416. package/packages/diagrams/src/lib/templates/arch/components/GroupControls.tsx +59 -59
  417. package/packages/diagrams/src/lib/templates/arch/components/GroupSizeDialog.tsx +81 -81
  418. package/packages/diagrams/src/lib/templates/arch/components/NodeDialog.tsx +214 -214
  419. package/packages/diagrams/src/lib/templates/arch/components/nodeTypes.ts +91 -91
  420. package/packages/diagrams/src/lib/templates/arch/controls/ArchDiagramControls.tsx +349 -349
  421. package/packages/diagrams/src/lib/templates/arch/data/templatee-data.ts +212 -212
  422. package/packages/diagrams/src/lib/templates/cloud-arch/components/CloudArchitectureDiagram.tsx +3912 -3912
  423. package/packages/diagrams/src/lib/templates/cloud-arch/components/FormatConverter.tsx +809 -809
  424. package/packages/diagrams/src/lib/templates/cloud-arch/components/FragmentImporter.tsx +276 -276
  425. package/packages/diagrams/src/lib/templates/cloud-arch/components/PropertiesPanel.tsx +1063 -1063
  426. package/packages/diagrams/src/lib/templates/cloud-arch/components/ServiceIconPicker.tsx +138 -138
  427. package/packages/diagrams/src/lib/templates/cloud-arch/components/SettingsSidebar.tsx +656 -656
  428. package/packages/diagrams/src/lib/templates/cloud-arch/components/SubnetSelector.tsx +468 -468
  429. package/packages/diagrams/src/lib/templates/cloud-arch/components/nodes/ServiceNode.tsx +310 -310
  430. package/packages/diagrams/src/lib/templates/cloud-arch/components/nodes/SubnetNode.tsx +475 -475
  431. package/packages/diagrams/src/lib/templates/cloud-arch/components/nodes/UsersNode.tsx +277 -277
  432. package/packages/diagrams/src/lib/templates/cloud-arch/data/diagramManager.ts +364 -364
  433. package/packages/diagrams/src/lib/templates/cloud-arch/data/types.ts +183 -183
  434. package/packages/diagrams/src/lib/templates/cloud-arch/integration/diagramValidator.ts +379 -379
  435. package/packages/diagrams/src/lib/templates/cloud-arch/messages/errorMessages.json +95 -95
  436. package/packages/diagrams/src/lib/templates/cloud-arch/types/localization.ts +368 -368
  437. package/packages/diagrams/src/lib/templates/cloud-arch/types/validation.ts +72 -72
  438. package/packages/diagrams/src/lib/templates/cloud-arch/utils/aws-icons.ts +557 -557
  439. package/packages/diagrams/src/lib/templates/cloud-arch/utils/awsValidation.ts +446 -446
  440. package/packages/diagrams/src/lib/templates/cloud-arch/utils/azure-icons.ts +802 -802
  441. package/packages/diagrams/src/lib/templates/cloud-arch/utils/azureValidation.ts +495 -495
  442. package/packages/diagrams/src/lib/templates/cloud-arch/utils/cloudValidation.ts +929 -929
  443. package/packages/diagrams/src/lib/templates/cloud-arch/utils/errorMessages.ts +283 -283
  444. package/packages/diagrams/src/lib/templates/cloud-arch/utils/gcp-icons.ts +186 -186
  445. package/packages/diagrams/src/lib/templates/cloud-arch/utils/gcpValidation.ts +312 -312
  446. package/packages/diagrams/src/lib/templates/cloud-arch/utils/genericValidation.ts +689 -689
  447. package/packages/diagrams/src/lib/templates/cloud-arch/utils/iconMapping.ts +383 -383
  448. package/packages/diagrams/src/lib/templates/cloud-arch/utils/idGenerator.ts +220 -220
  449. package/packages/diagrams/src/lib/templates/cloud-arch/utils/localizationManager.ts +300 -300
  450. package/packages/diagrams/src/lib/templates/cloud-arch/utils/restrictionEngine.ts +550 -550
  451. package/packages/diagrams/src/lib/templates/cloud-arch/utils/restrictionValidator.ts +400 -400
  452. package/packages/diagrams/src/lib/templates/cloud-arch/utils/serviceIcons.tsx +129 -129
  453. package/packages/diagrams/src/lib/templates/cloud-arch/utils/serviceMapping.ts +330 -330
  454. package/packages/diagrams/src/lib/templates/cloud-arch/utils/translations.ts +54 -54
  455. package/packages/diagrams/src/lib/templates/cloud-arch/utils/validationExtractor.ts +342 -342
  456. package/packages/diagrams/src/lib/templates/collaborationDiagram/CollaborationDiagram.tsx +15 -15
  457. package/packages/diagrams/src/lib/templates/collaborationDiagram/components/AddCollabEdgeDialog.tsx +181 -181
  458. package/packages/diagrams/src/lib/templates/collaborationDiagram/components/CollabLayout.ts +182 -182
  459. package/packages/diagrams/src/lib/templates/collaborationDiagram/components/CollabObjectNodeSettings.tsx +86 -86
  460. package/packages/diagrams/src/lib/templates/collaborationDiagram/components/CollaborationDiagramFlow.tsx +731 -731
  461. package/packages/diagrams/src/lib/templates/collaborationDiagram/components/DraggableEdgeLabel.tsx +123 -123
  462. package/packages/diagrams/src/lib/templates/collaborationDiagram/controls/CollaborationControls.tsx +131 -131
  463. package/packages/diagrams/src/lib/templates/collaborationDiagram/nodes/CollabEdge.tsx +170 -170
  464. package/packages/diagrams/src/lib/templates/collaborationDiagram/nodes/CollabObjectNode.tsx +178 -178
  465. package/packages/diagrams/src/lib/templates/home.style.css +16 -16
  466. package/packages/diagrams/src/lib/templates/node-forms/ApiForm.tsx +416 -416
  467. package/packages/diagrams/src/lib/templates/node-forms/CallForm.tsx +370 -370
  468. package/packages/diagrams/src/lib/templates/node-forms/ForLoopNode.tsx +313 -313
  469. package/packages/diagrams/src/lib/templates/node-forms/FunctionForm.tsx +211 -211
  470. package/packages/diagrams/src/lib/templates/node-forms/GraphQLForm.tsx +679 -679
  471. package/packages/diagrams/src/lib/templates/node-forms/IfNodeForm.tsx +97 -97
  472. package/packages/diagrams/src/lib/templates/node-forms/LetNodeForm.tsx +533 -533
  473. package/packages/diagrams/src/lib/templates/node-forms/LoopNode.tsx +149 -149
  474. package/packages/diagrams/src/lib/templates/node-forms/NodeForm.tsx +383 -383
  475. package/packages/diagrams/src/lib/templates/node-forms/ReturnNodeForm.tsx +96 -96
  476. package/packages/diagrams/src/lib/templates/node-forms/SetNodeForm.tsx +141 -141
  477. package/packages/diagrams/src/lib/templates/node-forms/SwitchNodeForm.tsx +249 -249
  478. package/packages/diagrams/src/lib/templates/node-forms/TryCatchForm.tsx +167 -167
  479. package/packages/diagrams/src/lib/templates/nodeFormSchema.json +84 -84
  480. package/packages/diagrams/src/lib/templates/sequence/SequenceDiagram.tsx +22 -22
  481. package/packages/diagrams/src/lib/templates/sequence/components/ActivationBarNode.tsx +33 -33
  482. package/packages/diagrams/src/lib/templates/sequence/components/AddMessageDialog.tsx +302 -302
  483. package/packages/diagrams/src/lib/templates/sequence/components/CombinedFragmentNode.tsx +65 -65
  484. package/packages/diagrams/src/lib/templates/sequence/components/EntitySettings.tsx +559 -559
  485. package/packages/diagrams/src/lib/templates/sequence/components/FragmentSettings.tsx +116 -116
  486. package/packages/diagrams/src/lib/templates/sequence/components/SequenceComponents.tsx +14 -14
  487. package/packages/diagrams/src/lib/templates/sequence/components/SequenceDiagramFlow.tsx +1361 -1361
  488. package/packages/diagrams/src/lib/templates/sequence/components/SequenceEntityNode.tsx +394 -394
  489. package/packages/diagrams/src/lib/templates/sequence/components/SequenceMessageEdge.tsx +272 -272
  490. package/packages/diagrams/src/lib/templates/sequence/components/SimpleEntitySettings.tsx +89 -89
  491. package/packages/diagrams/src/lib/templates/sequence/controls/DiagramControls.tsx +707 -707
  492. package/packages/diagrams/src/lib/templates/sequence/data/template-data.ts +635 -635
  493. package/packages/diagrams/src/lib/templates/stateMachine/StateMachineDiagram.tsx +66 -66
  494. package/packages/diagrams/src/lib/templates/stateMachine/components/CompositeStateNodeSettings.tsx +638 -638
  495. package/packages/diagrams/src/lib/templates/stateMachine/components/CustomEdge.tsx +220 -220
  496. package/packages/diagrams/src/lib/templates/stateMachine/components/EdgeSettings.tsx +193 -193
  497. package/packages/diagrams/src/lib/templates/stateMachine/components/SelfConnectingEdge.tsx +41 -41
  498. package/packages/diagrams/src/lib/templates/stateMachine/components/StateMachineComponents.tsx +49 -49
  499. package/packages/diagrams/src/lib/templates/stateMachine/components/StateMachineDiagramFlow.tsx +1238 -1238
  500. package/packages/diagrams/src/lib/templates/stateMachine/components/StateMachineLayout.ts +350 -350
  501. package/packages/diagrams/src/lib/templates/stateMachine/components/StateNodeSettings.tsx +188 -188
  502. package/packages/diagrams/src/lib/templates/stateMachine/components/useSelfTransition.ts +114 -114
  503. package/packages/diagrams/src/lib/templates/stateMachine/controls/StateDiagramControls.tsx +488 -488
  504. package/packages/diagrams/src/lib/templates/stateMachine/data/template-data.ts +4 -4
  505. package/packages/diagrams/src/lib/templates/stateMachine/nodes/ChoicePointNode.tsx +54 -54
  506. package/packages/diagrams/src/lib/templates/stateMachine/nodes/CompositeStateNode.tsx +225 -225
  507. package/packages/diagrams/src/lib/templates/stateMachine/nodes/EntryPointNode.tsx +31 -31
  508. package/packages/diagrams/src/lib/templates/stateMachine/nodes/ExitPointNode.tsx +44 -44
  509. package/packages/diagrams/src/lib/templates/stateMachine/nodes/FinalStateNode.tsx +41 -41
  510. package/packages/diagrams/src/lib/templates/stateMachine/nodes/ForkJoinNode.tsx +53 -53
  511. package/packages/diagrams/src/lib/templates/stateMachine/nodes/HistoryStateNode.tsx +36 -36
  512. package/packages/diagrams/src/lib/templates/stateMachine/nodes/InitialStateNode.tsx +29 -29
  513. package/packages/diagrams/src/lib/templates/stateMachine/nodes/JunctionPointNode.tsx +33 -33
  514. package/packages/diagrams/src/lib/templates/stateMachine/nodes/PinPointNode.tsx +111 -111
  515. package/packages/diagrams/src/lib/templates/stateMachine/nodes/StateNode.tsx +124 -124
  516. package/packages/diagrams/src/lib/templates/stateMachine/nodes/bendPoint.tsx +71 -71
  517. package/packages/diagrams/src/lib/templates/systemFlow/SystemFlowDiagram.tsx +67 -67
  518. package/packages/diagrams/src/lib/templates/systemFlow/components/EdgeSettings.tsx +330 -330
  519. package/packages/diagrams/src/lib/templates/systemFlow/components/FloatingEdge.tsx +219 -219
  520. package/packages/diagrams/src/lib/templates/systemFlow/components/SystemFlowComponents.tsx +28 -28
  521. package/packages/diagrams/src/lib/templates/systemFlow/components/SystemFlowDiagramFlow.tsx +1179 -1179
  522. package/packages/diagrams/src/lib/templates/systemFlow/components/SystemFlowNodeSettings.tsx +151 -151
  523. package/packages/diagrams/src/lib/templates/systemFlow/controls/SystemFlowControls.tsx +435 -435
  524. package/packages/diagrams/src/lib/templates/systemFlow/data/template-data.ts +308 -308
  525. package/packages/diagrams/src/lib/templates/systemFlow/demo.tsx +91 -91
  526. package/packages/diagrams/src/lib/templates/systemFlow/index.ts +5 -5
  527. package/packages/diagrams/src/lib/templates/systemFlow/nodes/BendpointNode.tsx +80 -80
  528. package/packages/diagrams/src/lib/templates/systemFlow/nodes/SystemNode.tsx +92 -92
  529. package/packages/diagrams/src/lib/templates/systemFlow/nodes/TreeSystemNode.tsx +755 -755
  530. package/packages/diagrams/src/lib/templates/useCaseDiagram/UseCaseDiagram.tsx +16 -16
  531. package/packages/diagrams/src/lib/templates/useCaseDiagram/components/ActorNodeSettings.tsx +103 -103
  532. package/packages/diagrams/src/lib/templates/useCaseDiagram/components/AddRelationshipDialog.tsx +186 -186
  533. package/packages/diagrams/src/lib/templates/useCaseDiagram/components/PackageNodeSettings.tsx +205 -205
  534. package/packages/diagrams/src/lib/templates/useCaseDiagram/components/UseCaseDiagramFlow.tsx +637 -637
  535. package/packages/diagrams/src/lib/templates/useCaseDiagram/components/UseCaseNodeSettings.tsx +120 -120
  536. package/packages/diagrams/src/lib/templates/useCaseDiagram/controls/UseCaseControls.tsx +289 -289
  537. package/packages/diagrams/src/lib/templates/useCaseDiagram/nodes/PackageNode.tsx +83 -83
  538. package/packages/diagrams/src/lib/templates/useCaseDiagram/nodes/UseCaseEdge.tsx +115 -115
  539. package/packages/diagrams/src/lib/templates/useCaseDiagram/nodes/UseCaseNode.tsx +230 -230
  540. package/packages/diagrams/src/lib/templates/validationSchema.json +277 -277
  541. package/packages/diagrams/src/lib/theme.ts +439 -439
  542. package/packages/diagrams/src/lib/types/FunctionSignature.ts +11 -11
  543. package/packages/diagrams/src/lib/types/SmartDynamicFormField.ts +37 -37
  544. package/packages/diagrams/src/lib/types/automation-node-data-types.ts +45 -131
  545. package/packages/diagrams/src/lib/types/available-variables.ts +18 -18
  546. package/packages/diagrams/src/lib/types/card-node.ts +68 -68
  547. package/packages/diagrams/src/lib/types/collaboration-types.ts +114 -114
  548. package/packages/diagrams/src/lib/types/colors.ts +25 -25
  549. package/packages/diagrams/src/lib/types/condition-builder.ts +18 -18
  550. package/packages/diagrams/src/lib/types/diagram-types.ts +14 -14
  551. package/packages/diagrams/src/lib/types/edge-types.ts +39 -39
  552. package/packages/diagrams/src/lib/types/function-execution.ts +35 -35
  553. package/packages/diagrams/src/lib/types/hooks.types.ts +6 -6
  554. package/packages/diagrams/src/lib/types/ndoe-form-types.ts +139 -139
  555. package/packages/diagrams/src/lib/types/node-types.ts +13 -23
  556. package/packages/diagrams/src/lib/types/sequence-types.ts +178 -178
  557. package/packages/diagrams/src/lib/types/shared-node-types.ts +21 -21
  558. package/packages/diagrams/src/lib/types/state-machine-types.ts +225 -225
  559. package/packages/diagrams/src/lib/types/stencil-item.ts +7 -7
  560. package/packages/diagrams/src/lib/types/structures.ts +80 -80
  561. package/packages/diagrams/src/lib/types/system-flow-types.ts +129 -129
  562. package/packages/diagrams/src/lib/types/usecase-types.ts +84 -84
  563. package/packages/diagrams/src/lib/types/validation-types.ts +134 -134
  564. package/packages/diagrams/src/lib/types/workflow-content-dynamic-form-type.ts +23 -23
  565. package/packages/diagrams/src/lib/types/workflow-node-data-types.ts +172 -172
  566. package/packages/diagrams/src/lib/utils/AutomationExecutionEngine.ts +658 -1179
  567. package/packages/diagrams/src/lib/utils/add-new-block.ts +34 -34
  568. package/packages/diagrams/src/lib/utils/add-new-node.ts +52 -52
  569. package/packages/diagrams/src/lib/utils/addToHistory.ts +15 -15
  570. package/packages/diagrams/src/lib/utils/automation-flow-processor.ts +556 -619
  571. package/packages/diagrams/src/lib/utils/closestPoint.ts +45 -45
  572. package/packages/diagrams/src/lib/utils/color-options.tsx +26 -26
  573. package/packages/diagrams/src/lib/utils/compress-img.ts +59 -59
  574. package/packages/diagrams/src/lib/utils/configLoader.ts +329 -329
  575. package/packages/diagrams/src/lib/utils/constant-lengths.ts +8 -8
  576. package/packages/diagrams/src/lib/utils/create-updated.tsx +40 -40
  577. package/packages/diagrams/src/lib/utils/createHistoryChange.ts +3 -3
  578. package/packages/diagrams/src/lib/utils/dividerUtils.tsx +59 -59
  579. package/packages/diagrams/src/lib/utils/edge-hooks.ts +53 -53
  580. package/packages/diagrams/src/lib/utils/elkLayout.ts +297 -297
  581. package/packages/diagrams/src/lib/utils/event-hooks.ts +69 -69
  582. package/packages/diagrams/src/lib/utils/event-store.ts +58 -58
  583. package/packages/diagrams/src/lib/utils/flow-node-hooks.ts +28 -28
  584. package/packages/diagrams/src/lib/utils/flow-to-js.ts +1465 -1465
  585. package/packages/diagrams/src/lib/utils/functionGenerator.ts +38 -38
  586. package/packages/diagrams/src/lib/utils/generateEdgesFromNodeOrder.ts +113 -113
  587. package/packages/diagrams/src/lib/utils/helpers.types.ts +10 -10
  588. package/packages/diagrams/src/lib/utils/highlightText.tsx +93 -93
  589. package/packages/diagrams/src/lib/utils/iconMapper.tsx +76 -76
  590. package/packages/diagrams/src/lib/utils/logger.ts +5 -5
  591. package/packages/diagrams/src/lib/utils/model-hooks.ts +129 -129
  592. package/packages/diagrams/src/lib/utils/node-hooks.ts +78 -78
  593. package/packages/diagrams/src/lib/utils/nodeAIAssistantConfig.ts +54 -54
  594. package/packages/diagrams/src/lib/utils/nodeOrderByEdges.ts +437 -437
  595. package/packages/diagrams/src/lib/utils/nodeutils.ts +242 -242
  596. package/packages/diagrams/src/lib/utils/object.ts +13 -13
  597. package/packages/diagrams/src/lib/utils/useDebounce.ts +19 -19
  598. package/packages/diagrams/src/lib/utils/utilities.ts +105 -105
  599. package/packages/diagrams/src/lib/utils/validationEngine.ts +610 -610
  600. package/packages/diagrams/src/lib/utils/vhToPixels.ts +9 -9
  601. package/packages/diagrams/tsconfig.json +21 -21
  602. package/packages/diagrams/tsconfig.lib.json +26 -25
  603. package/packages/diagrams/webpack.config.js +17 -17
  604. package/packages/interfaces/.babelrc +12 -12
  605. package/packages/interfaces/.eslintrc.json +18 -18
  606. package/packages/interfaces/README.md +7 -7
  607. package/packages/interfaces/project.json +8 -8
  608. package/packages/interfaces/src/index.ts +21 -21
  609. package/packages/interfaces/src/lib/Button.tsx +1 -1
  610. package/packages/interfaces/src/lib/DataGrid.ts +14 -14
  611. package/packages/interfaces/src/lib/StyledBox.tsx +1 -1
  612. package/packages/interfaces/src/lib/ToolbarItem.ts +7 -7
  613. package/packages/interfaces/src/lib/UserCard.ts +8 -8
  614. package/packages/interfaces/src/lib/yup.ts +3 -3
  615. package/packages/interfaces/tsconfig.json +17 -17
  616. package/packages/interfaces/tsconfig.lib.json +24 -24
  617. package/packages/molecules/.babelrc +12 -12
  618. package/packages/molecules/.eslintrc.json +18 -18
  619. package/packages/molecules/README.md +7 -7
  620. package/packages/molecules/project.json +8 -8
  621. package/packages/molecules/src/index.ts +47 -41
  622. package/packages/molecules/src/lib/ActionTextField/ActionTextField.module.css +7 -7
  623. package/packages/molecules/src/lib/ActionTextField/ActionTextField.spec.tsx +10 -10
  624. package/packages/molecules/src/lib/ActionTextField/ActionTextField.tsx +33 -33
  625. package/packages/molecules/src/lib/ClosableButton/CloseableButton.module.css +7 -7
  626. package/packages/molecules/src/lib/ClosableButton/CloseableButton.spec.tsx +11 -11
  627. package/packages/molecules/src/lib/ClosableButton/CloseableButton.tsx +69 -69
  628. package/packages/molecules/src/lib/EditorTab/EditorTab.module.css +7 -7
  629. package/packages/molecules/src/lib/EditorTab/EditorTab.spec.tsx +10 -10
  630. package/packages/molecules/src/lib/EditorTab/EditorTab.tsx +42 -42
  631. package/packages/molecules/src/lib/EditorTab/TabPanel.tsx +25 -25
  632. package/packages/molecules/src/lib/ParamsActionField/ParamsActionField.module.css +7 -7
  633. package/packages/molecules/src/lib/ParamsActionField/ParamsActionField.spec.tsx +10 -10
  634. package/packages/molecules/src/lib/ParamsActionField/ParamsActionField.tsx +24 -24
  635. package/packages/molecules/src/lib/SvgIcons/icons.tsx +323 -291
  636. package/packages/molecules/src/lib/SvgIcons/index.ts +31 -25
  637. package/packages/molecules/src/lib/SvgIcons/types.ts +7 -7
  638. package/packages/molecules/src/lib/TableWithInlineView/TableWithInlineView.module.css +7 -7
  639. package/packages/molecules/src/lib/TableWithInlineView/TableWithInlineView.spec.tsx +10 -10
  640. package/packages/molecules/src/lib/TableWithInlineView/TableWithInlineView.tsx +47 -47
  641. package/packages/molecules/src/lib/UserCard/UserCard.module.css +7 -7
  642. package/packages/molecules/src/lib/UserCard/UserCard.spec.tsx +11 -11
  643. package/packages/molecules/src/lib/UserCard/UserCard.tsx +22 -22
  644. package/packages/molecules/src/lib/VerbSelection/HTTPVerbSelection.module.css +7 -7
  645. package/packages/molecules/src/lib/VerbSelection/HTTPVerbSelection.spec.tsx +10 -10
  646. package/packages/molecules/src/lib/VerbSelection/HTTPVerbSelection.tsx +72 -72
  647. package/packages/molecules/tsconfig.json +17 -17
  648. package/packages/molecules/tsconfig.lib.json +30 -30
  649. package/packages/organisms/.babelrc +12 -12
  650. package/packages/organisms/.eslintrc.json +18 -18
  651. package/packages/organisms/README.md +7 -7
  652. package/packages/organisms/project.json +8 -8
  653. package/packages/organisms/src/index.ts +4 -4
  654. package/packages/organisms/src/lib/EditorToolbar/EditorToolbar.module.css +7 -7
  655. package/packages/organisms/src/lib/EditorToolbar/EditorToolbar.spec.tsx +10 -10
  656. package/packages/organisms/src/lib/EditorToolbar/EditorToolbar.tsx +117 -117
  657. package/packages/organisms/src/lib/EditorToolbar/SortableItem.tsx +51 -51
  658. package/packages/organisms/src/lib/UserList/UserList.module.css +7 -7
  659. package/packages/organisms/src/lib/UserList/UserList.spec.tsx +11 -11
  660. package/packages/organisms/src/lib/UserList/UserList.tsx +48 -48
  661. package/packages/organisms/src/lib/UserList/store.ts +49 -49
  662. package/packages/organisms/tsconfig.json +17 -17
  663. package/packages/organisms/tsconfig.lib.json +24 -24
  664. package/packages/zustand/.babelrc +12 -12
  665. package/packages/zustand/.eslintrc.json +18 -18
  666. package/packages/zustand/README.md +7 -7
  667. package/packages/zustand/project.json +8 -8
  668. package/packages/zustand/src/index.ts +4 -4
  669. package/packages/zustand/tsconfig.json +17 -17
  670. package/packages/zustand/tsconfig.lib.json +24 -24
  671. package/tsconfig.base.json +29 -29
  672. package/packages/diagrams/src/lib/components/automation/AutomationAISuggestionNode.tsx +0 -304
  673. package/packages/diagrams/src/lib/components/automation/AutomationEmailNode.tsx +0 -773
  674. package/packages/diagrams/src/lib/components/automation/AutomationGoogleServicesNode.tsx +0 -779
  675. package/packages/diagrams/src/lib/components/automation/AutomationNoteNode.tsx +0 -422
  676. package/packages/diagrams/src/lib/components/automation/AutomationSheetsNode.tsx +0 -1135
  677. package/packages/diagrams/src/lib/examples/GoogleSheetsConfigurationExamples.ts +0 -306
@@ -1,1179 +1,658 @@
1
- import { Node, Edge } from '@xyflow/react';
2
- import {
3
- AutomationNodeForm,
4
- AutomationStartNodeForm,
5
- AutomationApiNodeForm,
6
- AutomationFormattingNodeForm,
7
- AutomationSheetsNodeForm,
8
- AutomationEndNodeForm,
9
- } from '../types/automation-node-data-types';
10
- import {
11
- GoogleSheetsService,
12
- SheetsExportOptions,
13
- } from '../services/GoogleSheetsService';
14
- import { SlackService } from '../services/SlackService';
15
- import { TwilioWhatsAppService } from '../services/TwilioWhatsAppService';
16
-
17
- export interface AutomationContext {
18
- runId: string;
19
- startTime: Date;
20
- variables: Record<string, string | number | boolean | object | null>;
21
- logs: AutomationLog[];
22
- }
23
-
24
- export interface AutomationLog {
25
- timestamp: Date;
26
- nodeId: string;
27
- nodeType: string;
28
- level: 'info' | 'warning' | 'error' | 'success';
29
- message: string;
30
- data?: string | number | boolean | object | null;
31
- }
32
-
33
- export interface AutomationResult {
34
- success: boolean;
35
- context: AutomationContext;
36
- finalOutput?: string | number | boolean | object | null;
37
- error?: string;
38
- }
39
-
40
- export class AutomationExecutionEngine {
41
- private nodes: Node[];
42
- private edges: Edge[];
43
- private context: AutomationContext;
44
- private onNodeUpdate?: (nodeId: string, updatedData: any) => void;
45
- private onLog?: (log: AutomationLog) => void;
46
-
47
- constructor(
48
- nodes: Node[],
49
- edges: Edge[],
50
- onNodeUpdate?: (nodeId: string, updatedData: any) => void,
51
- onLog?: (log: AutomationLog) => void,
52
- ) {
53
- this.nodes = nodes;
54
- this.edges = edges;
55
- this.onNodeUpdate = onNodeUpdate;
56
- this.onLog = onLog;
57
- this.context = {
58
- runId: this.generateRunId(),
59
- startTime: new Date(),
60
- variables: {},
61
- logs: [],
62
- };
63
- }
64
-
65
- private generateRunId(): string {
66
- return `run_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
67
- }
68
-
69
- private storeExecutionResult(
70
- nodeId: string,
71
- result: string | number | boolean | object | null,
72
- success: boolean = true,
73
- error?: string,
74
- executionTime?: number,
75
- ): void {
76
- const node = this.nodes.find((n) => n.id === nodeId);
77
- if (!node) return;
78
-
79
- const executionResult = {
80
- success,
81
- data: result,
82
- timestamp: new Date().toISOString(),
83
- error,
84
- executionTime,
85
- };
86
-
87
- // Update the node's formData with execution result
88
- if (node.data.formData) {
89
- (node.data.formData as any).executionResult = executionResult;
90
- } else {
91
- (node.data as any).executionResult = executionResult;
92
- }
93
-
94
- // Notify the parent component about the node update
95
- if (this.onNodeUpdate) {
96
- // Create new object reference with deep clone of formData so React detects the change
97
- const updatedData = {
98
- ...node.data,
99
- ...(node.data.formData ? { formData: { ...node.data.formData } } : {}),
100
- };
101
- this.onNodeUpdate(nodeId, updatedData);
102
- }
103
- }
104
-
105
- private log(
106
- level: AutomationLog['level'],
107
- nodeId: string,
108
- nodeType: string,
109
- message: string,
110
- data?: string | number | boolean | object | null,
111
- ) {
112
- const entry: AutomationLog = {
113
- timestamp: new Date(),
114
- nodeId,
115
- nodeType,
116
- level,
117
- message,
118
- data,
119
- };
120
- this.context.logs.push(entry);
121
- if (this.onLog) {
122
- try {
123
- this.onLog(entry);
124
- } catch {
125
- // ignore UI callback errors
126
- }
127
- }
128
- }
129
-
130
- private getNextNodes(currentNodeId: string): Node[] {
131
- const outgoingEdges = this.edges.filter(
132
- (edge) => edge.source === currentNodeId,
133
- );
134
- const nextNodeIds = outgoingEdges.map((edge) => edge.target);
135
- return this.nodes.filter((node) => nextNodeIds.includes(node.id));
136
- }
137
-
138
- private async executeStartNode(
139
- node: Node,
140
- ): Promise<{ runId: string; startTime: string }> {
141
- const data = node.data;
142
- this.log(
143
- 'info',
144
- node.id,
145
- 'AutomationStartNode',
146
- 'Starting automation workflow',
147
- );
148
-
149
- // Set initial context variables
150
- this.context.variables.runId = this.context.runId;
151
- this.context.variables.startTime = this.context.startTime.toISOString();
152
-
153
- const result = {
154
- runId: this.context.runId,
155
- startTime: this.context.startTime.toISOString(),
156
- };
157
-
158
- // Store the execution result in node data
159
- this.storeExecutionResult(node.id, result, true);
160
-
161
- return result;
162
- }
163
-
164
- private async executeApiNode(node: Node): Promise<object> {
165
- const data = node.data;
166
- const formData = (data.formData || data) as AutomationApiNodeForm;
167
-
168
- this.log(
169
- 'info',
170
- node.id,
171
- 'AutomationApiNode',
172
- `Making ${formData.method} request to ${formData.url}`,
173
- );
174
-
175
- try {
176
- const headers: Record<string, string> = {};
177
- if (formData.headers && Array.isArray(formData.headers)) {
178
- formData.headers.forEach((header) => {
179
- if (header.enabled) {
180
- headers[header.key] = header.value;
181
- }
182
- });
183
- }
184
-
185
- const queryParams = new URLSearchParams();
186
- if (formData.queryParams && Array.isArray(formData.queryParams)) {
187
- formData.queryParams.forEach((param) => {
188
- if (param.enabled) {
189
- queryParams.append(param.key, param.value);
190
- }
191
- });
192
- }
193
-
194
- const url = queryParams.toString()
195
- ? `${formData.url}?${queryParams.toString()}`
196
- : formData.url;
197
-
198
- const requestOptions: RequestInit = {
199
- method: formData.method,
200
- headers,
201
- signal: AbortSignal.timeout(formData.timeout || 30000),
202
- };
203
-
204
- if (
205
- formData.body &&
206
- (formData.method === 'POST' || formData.method === 'PUT')
207
- ) {
208
- requestOptions.body = formData.body;
209
- }
210
-
211
- const response = await fetch(url, requestOptions);
212
-
213
- if (!response.ok) {
214
- throw new Error(
215
- `HTTP ${response.status}: ${response.statusText} - ${url}`,
216
- );
217
- }
218
-
219
- const responseData = await response.json();
220
- this.log(
221
- 'success',
222
- node.id,
223
- 'AutomationApiNode',
224
- 'API call completed successfully',
225
- responseData,
226
- );
227
-
228
- // Store the execution result in node data
229
- this.storeExecutionResult(node.id, responseData, true);
230
-
231
- return responseData;
232
- } catch (error) {
233
- let errorMessage = `API call failed: ${error}`;
234
-
235
- if (error instanceof TypeError && error.message.includes('fetch')) {
236
- errorMessage = `Network error: Unable to connect to ${formData.url}. This might be due to CORS restrictions or network connectivity issues.`;
237
- }
238
-
239
- this.log(
240
- 'error',
241
- node.id,
242
- 'AutomationApiNode',
243
- errorMessage,
244
- error instanceof Error ? error.message : String(error),
245
- );
246
-
247
- // Store the error result in node data
248
- this.storeExecutionResult(node.id, null, false, errorMessage);
249
-
250
- throw new Error(errorMessage);
251
- }
252
- }
253
-
254
- private async executeFormattingNode(
255
- node: Node,
256
- inputData: string | number | boolean | object | null,
257
- ): Promise<string | number | boolean | object | null> {
258
- const data = node.data;
259
- const formData = (data.formData || data) as AutomationFormattingNodeForm;
260
-
261
- this.log(
262
- 'info',
263
- node.id,
264
- 'AutomationFormattingNode',
265
- 'Starting data formatting',
266
- );
267
-
268
- try {
269
- if (formData.formattingType === 'ai-powered' && formData.aiFormatting) {
270
- // AI-powered formatting
271
- this.log('info', node.id, 'AutomationFormattingNode', 'AI thinking...');
272
- const aiResponse = await this.callAiApi(
273
- formData.aiFormatting,
274
- inputData,
275
- );
276
- this.log(
277
- 'success',
278
- node.id,
279
- 'AutomationFormattingNode',
280
- 'AI formatting completed',
281
- aiResponse,
282
- );
283
-
284
- // Store the execution result in node data
285
- this.storeExecutionResult(node.id, aiResponse, true);
286
-
287
- return aiResponse;
288
- } else {
289
- // Basic formatting
290
- const formattedData = this.basicFormatting(inputData, formData);
291
- this.log(
292
- 'success',
293
- node.id,
294
- 'AutomationFormattingNode',
295
- 'Basic formatting completed',
296
- formattedData,
297
- );
298
-
299
- // Store the execution result in node data
300
- this.storeExecutionResult(node.id, formattedData, true);
301
-
302
- return formattedData;
303
- }
304
- } catch (error) {
305
- this.log(
306
- 'error',
307
- node.id,
308
- 'AutomationFormattingNode',
309
- `Formatting failed: ${error}`,
310
- error instanceof Error ? error.message : String(error),
311
- );
312
-
313
- // Store the error result in node data
314
- this.storeExecutionResult(
315
- node.id,
316
- null,
317
- false,
318
- error instanceof Error ? error.message : String(error),
319
- );
320
-
321
- throw error;
322
- }
323
- }
324
-
325
- private async callAiApi(
326
- aiConfig: NonNullable<AutomationFormattingNodeForm['aiFormatting']>,
327
- inputData: string | number | boolean | object | null,
328
- ): Promise<string | number | boolean | object | null> {
329
- // Validate API key is not a placeholder
330
- if (
331
- !aiConfig.apiKey ||
332
- aiConfig.apiKey.includes('your-openai-api-key-here') ||
333
- aiConfig.apiKey.length < 10
334
- ) {
335
- throw new Error('Invalid API key. Please provide a valid API key.');
336
- }
337
-
338
- // Additional validation for Gemini API key format
339
- if (aiConfig.apiUrl.includes('generativelanguage.googleapis.com')) {
340
- if (!aiConfig.apiKey.startsWith('AIza')) {
341
- throw new Error(
342
- 'Invalid Gemini API key format. Gemini API keys should start with "AIza".',
343
- );
344
- }
345
- }
346
-
347
- const prompt = `${aiConfig.instruction}\n\nInput data: ${JSON.stringify(inputData)}`;
348
-
349
- // Determine if this is Gemini API or OpenAI API based on URL
350
- const isGeminiApi = aiConfig.apiUrl.includes(
351
- 'generativelanguage.googleapis.com',
352
- );
353
-
354
- let requestBody: any;
355
- let headers: Record<string, string>;
356
-
357
- if (isGeminiApi) {
358
- // Gemini API format
359
- headers = {
360
- 'Content-Type': 'application/json',
361
- 'X-goog-api-key': aiConfig.apiKey,
362
- };
363
-
364
- requestBody = {
365
- contents: [
366
- {
367
- parts: [
368
- {
369
- text: `${aiConfig.systemPrompt || 'You are a data formatting assistant.'}\n\n${prompt}`,
370
- },
371
- ],
372
- },
373
- ],
374
- generationConfig: {
375
- temperature: aiConfig.temperature || 0.1,
376
- maxOutputTokens: aiConfig.maxTokens || 1000,
377
- responseMimeType: 'application/json',
378
- },
379
- };
380
- } else {
381
- // OpenAI API format
382
- headers = {
383
- 'Content-Type': 'application/json',
384
- Authorization: `Bearer ${aiConfig.apiKey}`,
385
- };
386
-
387
- requestBody = {
388
- model: aiConfig.model,
389
- messages: [
390
- {
391
- role: 'system',
392
- content:
393
- aiConfig.systemPrompt || 'You are a data formatting assistant.',
394
- },
395
- {
396
- role: 'user',
397
- content: prompt,
398
- },
399
- ],
400
- temperature: aiConfig.temperature || 0.1,
401
- max_tokens: aiConfig.maxTokens || 1000,
402
- };
403
- }
404
-
405
- const response = await fetch(aiConfig.apiUrl, {
406
- method: 'POST',
407
- headers,
408
- body: JSON.stringify(requestBody),
409
- });
410
-
411
- if (!response.ok) {
412
- const errorText = await response.text();
413
- throw new Error(
414
- `AI API call failed: ${response.status} ${response.statusText}. ${errorText}`,
415
- );
416
- }
417
-
418
- const result = await response.json();
419
-
420
- let content: string;
421
-
422
- if (isGeminiApi) {
423
- // Gemini API response format
424
- if (
425
- !result.candidates ||
426
- !result.candidates[0] ||
427
- !result.candidates[0].content ||
428
- !result.candidates[0].content.parts
429
- ) {
430
- throw new Error('Invalid Gemini API response format');
431
- }
432
- content = result.candidates[0].content.parts[0].text;
433
- } else {
434
- // OpenAI API response format
435
- if (!result.choices || !result.choices[0] || !result.choices[0].message) {
436
- throw new Error('Invalid AI API response format');
437
- }
438
- content = result.choices[0].message.content;
439
- }
440
-
441
- // Try to parse as JSON, fallback to string if parsing fails
442
- try {
443
- return JSON.parse(content);
444
- } catch {
445
- return content;
446
- }
447
- }
448
-
449
- private basicFormatting(
450
- inputData: string | number | boolean | object | null,
451
- config: AutomationFormattingNodeForm,
452
- ): string | number | boolean | object | null {
453
- // Basic data transformation logic
454
- if (typeof inputData === 'string') {
455
- return inputData.trim();
456
- }
457
-
458
- if (Array.isArray(inputData)) {
459
- return inputData.map((item) => this.basicFormatting(item, config));
460
- }
461
-
462
- if (typeof inputData === 'object' && inputData !== null) {
463
- const formatted: Record<string, unknown> = {};
464
- Object.keys(inputData).forEach((key) => {
465
- formatted[key] = this.basicFormatting(
466
- (inputData as Record<string, unknown>)[key] as
467
- | string
468
- | number
469
- | boolean
470
- | object
471
- | null,
472
- config,
473
- );
474
- });
475
- return formatted;
476
- }
477
-
478
- return inputData;
479
- }
480
-
481
- private async executeSheetsNode(
482
- node: Node,
483
- inputData: string | number | boolean | object | null,
484
- ): Promise<string | number | boolean | object | null> {
485
- const data = node.data;
486
- const formData = (data.formData || data) as AutomationSheetsNodeForm;
487
-
488
- this.log(
489
- 'info',
490
- node.id,
491
- 'AutomationSheetsNode',
492
- 'Starting Google Sheets export',
493
- );
494
-
495
- try {
496
- // Initialize/derive per-output-method statuses container
497
- const outputStatuses: any = (data as any).outputStatuses || {};
498
- // Only set Google Sheets status when exportFormat includes sheets
499
- if (
500
- formData.exportOptions?.exportFormat === 'sheets' ||
501
- formData.exportOptions?.exportFormat === 'both'
502
- ) {
503
- outputStatuses.googleSheets = 'running';
504
- }
505
- // Gmail runs only if enabled
506
- if (formData.exportOptions?.emailSendEnabled) {
507
- outputStatuses.gmail = 'running';
508
- }
509
- // Slack runs only if enabled
510
- if (formData.exportOptions?.slack?.enabled) {
511
- outputStatuses.slack = 'running';
512
- }
513
- // WhatsApp runs only if enabled
514
- if (formData.exportOptions?.whatsapp?.enabled) {
515
- outputStatuses.whatsapp = 'running';
516
- }
517
- (data as any).outputStatuses = outputStatuses;
518
- if (this.onNodeUpdate) this.onNodeUpdate(node.id, data);
519
-
520
- const sheetsConfig = formData.sheetsConfig;
521
- const dataMapping = formData.dataMapping;
522
- const exportOptions = formData.exportOptions;
523
- const wantsSheets =
524
- exportOptions?.exportFormat === 'sheets' ||
525
- exportOptions?.exportFormat === 'both';
526
- const wantsExcel =
527
- exportOptions?.exportFormat === 'excel' ||
528
- exportOptions?.exportFormat === 'both';
529
- const wantsGmail = Boolean(exportOptions?.emailSendEnabled);
530
-
531
- const sheetsService = new GoogleSheetsService();
532
- // Only perform Google auth/validation when Sheets or Gmail is in use
533
- if (wantsSheets || wantsGmail) {
534
- this.log(
535
- 'info',
536
- node.id,
537
- 'AutomationSheetsNode',
538
- 'Authenticating with Google (Sheets/Gmail)...',
539
- );
540
- // If Gmail send is enabled and we're using OAuth client, request both scopes in one consent
541
- try {
542
- const creds: any = sheetsConfig?.credentials || {};
543
- if (creds.type === 'oauth' && (creds.clientId || creds.oauthToken)) {
544
- const neededScopes = [
545
- 'https://www.googleapis.com/auth/spreadsheets',
546
- ];
547
- if (exportOptions?.emailSendEnabled) {
548
- neededScopes.push('https://www.googleapis.com/auth/gmail.send');
549
- }
550
- const existing = Array.isArray(creds.scopes) ? creds.scopes : [];
551
- const union = Array.from(new Set([...existing, ...neededScopes]));
552
- creds.scopes = union;
553
- sheetsConfig.credentials = creds;
554
- }
555
- } catch {
556
- // Non-fatal; initialization will still proceed with default scopes
557
- }
558
- const validation = sheetsService.validateConfig(sheetsConfig);
559
- if (!validation.valid) {
560
- throw new Error(
561
- `Configuration validation failed: ${validation.errors.join(', ')}`,
562
- );
563
- }
564
- }
565
-
566
- // Prepare data for export (only when exporting to Sheets/Excel)
567
- let exportData: any[] = [];
568
- if (wantsSheets || wantsExcel) {
569
- if (Array.isArray(inputData)) {
570
- exportData = inputData;
571
- } else if (inputData && typeof inputData === 'object') {
572
- exportData = [inputData];
573
- } else {
574
- throw new Error('Invalid input data format for export');
575
- }
576
- }
577
-
578
- // Initialize Google Sheets service only when using Sheets or Gmail
579
- if (wantsSheets || wantsGmail) {
580
- await sheetsService.initialize(sheetsConfig);
581
- this.log(
582
- 'success',
583
- node.id,
584
- 'AutomationSheetsNode',
585
- 'Authenticated with Google APIs (Sheets/Gmail)',
586
- );
587
- }
588
-
589
- // Prepare export options
590
- const sheetsExportOptions: SheetsExportOptions = {
591
- emailRecipients: exportOptions.emailRecipients,
592
- fileName: exportOptions.fileName,
593
- exportFormat:
594
- exportOptions.exportFormat === 'both'
595
- ? 'sheets'
596
- : exportOptions.exportFormat,
597
- includeHeaders: exportOptions.includeHeaders,
598
- };
599
-
600
- let response: any = null;
601
-
602
- // Export to Google Sheets
603
- if (
604
- exportOptions?.exportFormat === 'sheets' ||
605
- exportOptions?.exportFormat === 'both'
606
- ) {
607
- this.log(
608
- 'info',
609
- node.id,
610
- 'AutomationSheetsNode',
611
- 'Writing data to Google Sheets...',
612
- );
613
- response = await sheetsService.exportToSheets(
614
- exportData,
615
- sheetsConfig,
616
- dataMapping,
617
- sheetsExportOptions,
618
- );
619
-
620
- this.log(
621
- 'success',
622
- node.id,
623
- 'AutomationSheetsNode',
624
- `Successfully exported ${response.rowsAdded} rows to Google Sheets`,
625
- response,
626
- );
627
- // Mark GS connected on success
628
- outputStatuses.googleSheets = 'connected';
629
- (data as any).outputStatuses = outputStatuses;
630
- if (this.onNodeUpdate) this.onNodeUpdate(node.id, data);
631
- }
632
-
633
- // Export to Excel
634
- if (
635
- exportOptions.exportFormat === 'excel' ||
636
- exportOptions.exportFormat === 'both'
637
- ) {
638
- this.log(
639
- 'info',
640
- node.id,
641
- 'AutomationSheetsNode',
642
- 'Exporting data to Excel...',
643
- );
644
- const excelResponse = await sheetsService.exportToExcel(
645
- exportData,
646
- dataMapping,
647
- sheetsExportOptions,
648
- );
649
-
650
- this.log(
651
- 'success',
652
- node.id,
653
- 'AutomationSheetsNode',
654
- `Successfully exported ${excelResponse.rowsAdded} rows to Excel`,
655
- excelResponse,
656
- );
657
-
658
- // If we're doing both, merge the responses
659
- if (exportOptions.exportFormat === 'both') {
660
- response = {
661
- ...response,
662
- excelExport: excelResponse,
663
- combinedSuccess: response.success && excelResponse.success,
664
- };
665
- } else {
666
- response = excelResponse;
667
- }
668
- }
669
-
670
- // Optional email send (via mailto fallback or Gmail API if implemented)
671
- if (exportOptions.emailSendEnabled) {
672
- const emailRecipients = exportOptions.emailRecipients || [];
673
- if (emailRecipients.length > 0) {
674
- this.log(
675
- 'info',
676
- node.id,
677
- 'AutomationSheetsNode',
678
- `Sending email to ${emailRecipients.length} recipient(s)...`,
679
- );
680
- const emailSent = await sheetsService.sendEmail({
681
- from: exportOptions.emailSender,
682
- to: emailRecipients,
683
- subject: exportOptions.emailSubject || 'Automation Output',
684
- message: exportOptions.emailMessage,
685
- spreadsheetUrl:
686
- exportOptions.includeSpreadsheetLink &&
687
- (response as any)?.spreadsheetUrl
688
- ? (response as any).spreadsheetUrl
689
- : undefined,
690
- // Note: attachExcel via Gmail requires Gmail scope and MIME building;
691
- // mailto cannot attach files. This is a placeholder hook.
692
- attachExcelBlob: undefined,
693
- attachExcelFileName: sheetsExportOptions.fileName,
694
- // Critical: disable UI fallback to ensure fully automated send
695
- disableUiFallback: true,
696
- });
697
-
698
- if (emailSent) {
699
- this.log(
700
- 'success',
701
- node.id,
702
- 'AutomationSheetsNode',
703
- `Email sent to ${emailRecipients.length} recipient(s)`,
704
- );
705
- outputStatuses.gmail = 'connected';
706
- } else {
707
- this.log(
708
- 'error',
709
- node.id,
710
- 'AutomationSheetsNode',
711
- 'Email send failed (API)',
712
- );
713
- outputStatuses.gmail = 'failed';
714
- }
715
- (data as any).outputStatuses = outputStatuses;
716
- if (this.onNodeUpdate) this.onNodeUpdate(node.id, data);
717
- }
718
- }
719
-
720
- // Optional Slack send via webhook
721
- if (exportOptions.slack?.enabled) {
722
- const slackService = new SlackService();
723
- const validation = slackService.validateConfig(exportOptions.slack);
724
- if (!validation.valid) {
725
- throw new Error(
726
- `Slack configuration invalid: ${validation.errors.join(', ')}`,
727
- );
728
- }
729
-
730
- // Build message text with simple token replacements
731
- const template =
732
- exportOptions.slack.messageTemplate ||
733
- 'Automation update for {{fileName}}';
734
- const contextVars: Record<string, any> = {
735
- fileName: exportOptions.fileName,
736
- rowsAdded: (response as any)?.rowsAdded,
737
- sheetName:
738
- (response as any)?.sheetName || formData.sheetsConfig?.sheetName,
739
- };
740
- const messageText = template.replace(/\{\{(\w+)\}\}/g, (_, key) =>
741
- key in contextVars ? String(contextVars[key]) : '',
742
- );
743
-
744
- // Prefer spreadsheetUrl from Sheets response if available and flag set
745
- const spreadsheetUrl = exportOptions.slack.includeSpreadsheetLink
746
- ? (response as any)?.spreadsheetUrl || undefined
747
- : undefined;
748
-
749
- const payload = slackService.buildPayload(
750
- exportOptions.slack,
751
- messageText,
752
- inputData,
753
- spreadsheetUrl,
754
- );
755
-
756
- try {
757
- this.log(
758
- 'info',
759
- node.id,
760
- 'AutomationSheetsNode',
761
- `Sending Slack message to #${exportOptions.slack.channel}...`,
762
- );
763
- await slackService.sendMessage({
764
- webhookUrl: exportOptions.slack.webhookUrl,
765
- payload,
766
- });
767
- this.log(
768
- 'success',
769
- node.id,
770
- 'AutomationSheetsNode',
771
- `Slack message sent to #${exportOptions.slack.channel}`,
772
- );
773
- outputStatuses.slack = 'connected';
774
- (data as any).outputStatuses = outputStatuses;
775
- if (this.onNodeUpdate) this.onNodeUpdate(node.id, data);
776
- } catch (slackErr) {
777
- const msg =
778
- slackErr instanceof Error ? slackErr.message : String(slackErr);
779
- this.log(
780
- 'error',
781
- node.id,
782
- 'AutomationSheetsNode',
783
- `Slack send failed: ${msg}`,
784
- );
785
- // Do not fail the whole workflow due to Slack CORS; mark Slack as failed but continue
786
- outputStatuses.slack = 'failed';
787
- (data as any).outputStatuses = outputStatuses;
788
- if (this.onNodeUpdate) this.onNodeUpdate(node.id, data);
789
- }
790
- }
791
-
792
- // Optional WhatsApp send
793
- if (exportOptions.whatsapp?.enabled) {
794
- try {
795
- this.log(
796
- 'info',
797
- node.id,
798
- 'AutomationSheetsNode',
799
- `Sending WhatsApp message to ${exportOptions.whatsapp.phoneNumber}...`,
800
- );
801
-
802
- // Build WhatsApp message with template replacements
803
- const template =
804
- exportOptions.whatsapp.messageTemplate ||
805
- 'Automation Result: {{fileName}} completed successfully. Rows processed: {{rowsAdded}}.';
806
- const contextVars: Record<string, any> = {
807
- fileName: exportOptions.fileName,
808
- rowsAdded: (response as any)?.rowsAdded,
809
- sheetName:
810
- (response as any)?.sheetName || formData.sheetsConfig?.sheetName,
811
- timestamp: new Date().toLocaleString(),
812
- };
813
- const messageText = template.replace(/\{\{(\w+)\}\}/g, (_, key) =>
814
- key in contextVars ? String(contextVars[key]) : '',
815
- );
816
-
817
- // Create WhatsApp message with execution data
818
- const whatsappMessage = `
819
- Automation Result:
820
- ------------------
821
- ${messageText}
822
-
823
- Execution Details:
824
- - Run ID: ${this.context.runId}
825
- - Start Time: ${this.context.startTime.toLocaleString()}
826
- - Status: Completed Successfully
827
- - Data: ${JSON.stringify(inputData, null, 2)}
828
- `;
829
-
830
- // Check if Twilio is configured
831
- if (exportOptions.whatsapp.twilio?.enabled) {
832
- // Use Twilio WhatsApp API
833
- const twilioService = new TwilioWhatsAppService({
834
- accountSid: exportOptions.whatsapp.twilio.accountSid,
835
- authToken: exportOptions.whatsapp.twilio.authToken,
836
- fromNumber: exportOptions.whatsapp.twilio.fromNumber,
837
- isSandbox: exportOptions.whatsapp.twilio.isSandbox,
838
- });
839
-
840
- // Validate Twilio configuration
841
- const validation = twilioService.validateConfig();
842
- if (!validation.valid) {
843
- throw new Error(
844
- `Twilio configuration invalid: ${validation.errors.join(', ')}`,
845
- );
846
- }
847
-
848
- // Send message via Twilio
849
-
850
- const twilioResult = await twilioService.sendMessage({
851
- to: exportOptions.whatsapp.phoneNumber,
852
- message: whatsappMessage.trim(),
853
- templateSid: exportOptions.whatsapp.twilio.templateSid,
854
- templateVariables:
855
- exportOptions.whatsapp.twilio.templateVariables,
856
- });
857
-
858
- if (twilioResult.success) {
859
- this.log(
860
- 'success',
861
- node.id,
862
- 'AutomationSheetsNode',
863
- `WhatsApp message sent via Twilio (SID: ${twilioResult.messageSid})`,
864
- );
865
- outputStatuses.whatsapp = 'connected';
866
- } else {
867
- throw new Error(`Twilio send failed: ${twilioResult.error}`);
868
- }
869
- } else {
870
- // Fallback to WhatsApp Web (existing behavior)
871
- const encodedMsg = encodeURIComponent(whatsappMessage.trim());
872
- const whatsappUrl = `https://wa.me/${exportOptions.whatsapp.phoneNumber}?text=${encodedMsg}`;
873
-
874
- // Open WhatsApp in a new tab
875
- window.open(whatsappUrl, '_blank');
876
-
877
- this.log(
878
- 'success',
879
- node.id,
880
- 'AutomationSheetsNode',
881
- `WhatsApp message opened for ${exportOptions.whatsapp.phoneNumber}`,
882
- );
883
- outputStatuses.whatsapp = 'connected';
884
- }
885
-
886
- (data as any).outputStatuses = outputStatuses;
887
- if (this.onNodeUpdate) this.onNodeUpdate(node.id, data);
888
- } catch (whatsappErr) {
889
- const msg =
890
- whatsappErr instanceof Error
891
- ? whatsappErr.message
892
- : String(whatsappErr);
893
- this.log(
894
- 'error',
895
- node.id,
896
- 'AutomationSheetsNode',
897
- `WhatsApp send failed: ${msg}`,
898
- );
899
- outputStatuses.whatsapp = 'failed';
900
- (data as any).outputStatuses = outputStatuses;
901
- if (this.onNodeUpdate) this.onNodeUpdate(node.id, data);
902
- }
903
- }
904
-
905
- // Store the execution result in node data
906
- this.storeExecutionResult(node.id, response, true);
907
-
908
- return response;
909
- } catch (error) {
910
- const errorMessage =
911
- error instanceof Error ? error.message : 'Unknown error';
912
- this.log(
913
- 'error',
914
- node.id,
915
- 'AutomationSheetsNode',
916
- `Google Sheets export failed: ${errorMessage}`,
917
- );
918
-
919
- // Mark failing outputs
920
- const dataRef: any = node.data;
921
- dataRef.outputStatuses = dataRef.outputStatuses || {};
922
- // If config missing -> not-set should be turned failed on workflow failure
923
- const sheetsCfg =
924
- dataRef.formData?.sheetsConfig || dataRef.sheetsConfig || {};
925
- const creds = sheetsCfg.credentials || {};
926
- const gsHasRequired = Boolean(
927
- (sheetsCfg.spreadsheetId || creds.clientId) &&
928
- sheetsCfg.sheetName &&
929
- creds.type,
930
- );
931
- dataRef.outputStatuses.googleSheets = gsHasRequired ? 'failed' : 'failed';
932
-
933
- const ex = dataRef.formData?.exportOptions || dataRef.exportOptions || {};
934
- const gmHasRequired = Boolean(
935
- ex.emailSendEnabled &&
936
- ex.emailSender &&
937
- (ex.emailRecipients?.length || 0) > 0 &&
938
- ex.emailSubject &&
939
- ex.emailMessage,
940
- );
941
- if (ex.emailSendEnabled) {
942
- dataRef.outputStatuses.gmail = gmHasRequired ? 'failed' : 'failed';
943
- }
944
-
945
- const sl = ex.slack || {};
946
- const slackHasRequired = Boolean(
947
- sl.enabled && sl.webhookUrl && sl.channel,
948
- );
949
- if (sl.enabled) {
950
- dataRef.outputStatuses.slack = slackHasRequired ? 'failed' : 'failed';
951
- }
952
-
953
- const wa = ex.whatsapp || {};
954
- const whatsappHasRequired = Boolean(wa.enabled && wa.phoneNumber);
955
- if (wa.enabled) {
956
- dataRef.outputStatuses.whatsapp = whatsappHasRequired
957
- ? 'failed'
958
- : 'failed';
959
- }
960
-
961
- if (this.onNodeUpdate) this.onNodeUpdate(node.id, dataRef);
962
-
963
- // Store the execution result in node data
964
- this.storeExecutionResult(node.id, null, false, errorMessage);
965
-
966
- throw error;
967
- }
968
- }
969
-
970
- private getNestedValue(obj: any, path: string): any {
971
- return path.split('.').reduce((current, key) => current?.[key], obj);
972
- }
973
-
974
- private formatValueForSheets(value: any, dataType: string): any {
975
- if (value === null || value === undefined) {
976
- return '';
977
- }
978
-
979
- switch (dataType) {
980
- case 'string':
981
- return String(value);
982
- case 'number':
983
- return Number(value);
984
- case 'date':
985
- return new Date(value).toISOString();
986
- case 'boolean':
987
- return Boolean(value);
988
- default:
989
- return String(value);
990
- }
991
- }
992
-
993
- private async executeEndNode(
994
- node: Node,
995
- inputData: string | number | boolean | object | null,
996
- ): Promise<string | number | boolean | object | null> {
997
- const data = node.data;
998
- const formData = (data.formData || data) as AutomationEndNodeForm;
999
-
1000
- this.log(
1001
- 'info',
1002
- node.id,
1003
- 'AutomationEndNode',
1004
- 'Workflow completed successfully',
1005
- );
1006
-
1007
- // Handle different output types
1008
- switch (formData.outputType) {
1009
- case 'display':
1010
- this.log(
1011
- 'info',
1012
- node.id,
1013
- 'AutomationEndNode',
1014
- 'Output displayed in UI',
1015
- inputData,
1016
- );
1017
- break;
1018
- case 'store':
1019
- this.log(
1020
- 'info',
1021
- node.id,
1022
- 'AutomationEndNode',
1023
- 'Data stored to destination',
1024
- inputData,
1025
- );
1026
- break;
1027
- case 'send':
1028
- this.log(
1029
- 'info',
1030
- node.id,
1031
- 'AutomationEndNode',
1032
- 'Data sent to destination',
1033
- inputData,
1034
- );
1035
- break;
1036
- }
1037
-
1038
- // Store the execution result in node data
1039
- this.storeExecutionResult(node.id, inputData, true);
1040
-
1041
- return inputData;
1042
- }
1043
-
1044
- private async executeNode(
1045
- node: Node,
1046
- inputData?: string | number | boolean | object | null,
1047
- ): Promise<string | number | boolean | object | null> {
1048
- const nodeType = node.type;
1049
-
1050
- switch (nodeType) {
1051
- case 'AutomationStartNode':
1052
- return await this.executeStartNode(node);
1053
- case 'AutomationApiNode':
1054
- return await this.executeApiNode(node);
1055
- case 'AutomationFormattingNode':
1056
- return await this.executeFormattingNode(node, inputData || null);
1057
- case 'AutomationSheetsNode':
1058
- return await this.executeSheetsNode(node, inputData || null);
1059
- case 'AutomationEndNode':
1060
- return await this.executeEndNode(node, inputData || null);
1061
- default:
1062
- throw new Error(`Unknown node type: ${nodeType}`);
1063
- }
1064
- }
1065
-
1066
- public async executeWorkflow(): Promise<AutomationResult> {
1067
- try {
1068
- // Find start node
1069
- const startNode = this.nodes.find(
1070
- (node) => node.type === 'AutomationStartNode',
1071
- );
1072
- if (!startNode) {
1073
- throw new Error('No start node found in workflow');
1074
- }
1075
-
1076
- this.log('info', 'workflow', 'engine', 'Starting workflow execution');
1077
-
1078
- // Execute nodes in sequence
1079
- let currentNode: Node | null = startNode;
1080
- let currentData: string | number | boolean | object | null = null;
1081
- const visitedNodes = new Set<string>();
1082
-
1083
- while (currentNode) {
1084
- if (visitedNodes.has(currentNode.id)) {
1085
- throw new Error(
1086
- `Circular dependency detected: node ${currentNode.id} already visited`,
1087
- );
1088
- }
1089
-
1090
- visitedNodes.add(currentNode.id);
1091
-
1092
- // Announce node execution start
1093
- this.log(
1094
- 'info',
1095
- currentNode.id,
1096
- String(currentNode.type || 'node'),
1097
- 'Executing node...',
1098
- );
1099
-
1100
- // Update node status to running
1101
- (currentNode.data as Record<string, unknown>).status = 'Running';
1102
- if (this.onNodeUpdate) {
1103
- // Create new object reference so React detects the change
1104
- this.onNodeUpdate(currentNode.id, { ...currentNode.data });
1105
- }
1106
-
1107
- try {
1108
- currentData = await this.executeNode(currentNode, currentData);
1109
- (currentNode.data as Record<string, unknown>).status = 'Completed';
1110
- (currentNode.data as Record<string, unknown>).lastRun =
1111
- new Date().toISOString();
1112
- if (this.onNodeUpdate) {
1113
- // Create new object reference so React detects the change
1114
- this.onNodeUpdate(currentNode.id, { ...currentNode.data });
1115
- }
1116
- } catch (error) {
1117
- (currentNode.data as Record<string, unknown>).status = 'Error';
1118
- (currentNode.data as Record<string, unknown>).lastRun =
1119
- new Date().toISOString();
1120
- if (this.onNodeUpdate) {
1121
- // Create new object reference so React detects the change
1122
- this.onNodeUpdate(currentNode.id, { ...currentNode.data });
1123
- }
1124
- throw error;
1125
- }
1126
-
1127
- // Find next node
1128
- const nextNodes = this.getNextNodes(currentNode.id);
1129
- if (nextNodes.length > 0) {
1130
- const next = nextNodes[0];
1131
- this.log(
1132
- 'info',
1133
- next.id,
1134
- String(next.type || 'node'),
1135
- 'Moving to next node',
1136
- );
1137
- currentNode = next;
1138
- } else {
1139
- this.log('info', 'workflow', 'engine', 'No next node. Ending.');
1140
- currentNode = null;
1141
- }
1142
- }
1143
-
1144
- this.log(
1145
- 'success',
1146
- 'workflow',
1147
- 'engine',
1148
- 'Workflow execution completed successfully',
1149
- );
1150
-
1151
- return {
1152
- success: true,
1153
- context: this.context,
1154
- finalOutput: currentData,
1155
- };
1156
- } catch (error) {
1157
- this.log(
1158
- 'error',
1159
- 'workflow',
1160
- 'engine',
1161
- `Workflow execution failed: ${error}`,
1162
- );
1163
-
1164
- return {
1165
- success: false,
1166
- context: this.context,
1167
- error: error instanceof Error ? error.message : String(error),
1168
- };
1169
- }
1170
- }
1171
-
1172
- public getLogs(): AutomationLog[] {
1173
- return this.context.logs;
1174
- }
1175
-
1176
- public getContext(): AutomationContext {
1177
- return this.context;
1178
- }
1179
- }
1
+ import { Node, Edge } from '@xyflow/react';
2
+ import {
3
+ AutomationNodeForm,
4
+ AutomationStartNodeForm,
5
+ AutomationApiNodeForm,
6
+ AutomationFormattingNodeForm,
7
+ AutomationEndNodeForm,
8
+ } from '../types/automation-node-data-types';
9
+
10
+ export interface AutomationContext {
11
+ runId: string;
12
+ startTime: Date;
13
+ variables: Record<string, string | number | boolean | object | null>;
14
+ logs: AutomationLog[];
15
+ }
16
+
17
+ export interface AutomationLog {
18
+ timestamp: Date;
19
+ nodeId: string;
20
+ nodeType: string;
21
+ level: 'info' | 'warning' | 'error' | 'success';
22
+ message: string;
23
+ data?: string | number | boolean | object | null;
24
+ }
25
+
26
+ export interface AutomationResult {
27
+ success: boolean;
28
+ context: AutomationContext;
29
+ finalOutput?: string | number | boolean | object | null;
30
+ error?: string;
31
+ }
32
+
33
+ export class AutomationExecutionEngine {
34
+ private nodes: Node[];
35
+ private edges: Edge[];
36
+ private context: AutomationContext;
37
+ private onNodeUpdate?: (nodeId: string, updatedData: any) => void;
38
+ private onLog?: (log: AutomationLog) => void;
39
+
40
+ constructor(
41
+ nodes: Node[],
42
+ edges: Edge[],
43
+ onNodeUpdate?: (nodeId: string, updatedData: any) => void,
44
+ onLog?: (log: AutomationLog) => void,
45
+ ) {
46
+ this.nodes = nodes;
47
+ this.edges = edges;
48
+ this.onNodeUpdate = onNodeUpdate;
49
+ this.onLog = onLog;
50
+ this.context = {
51
+ runId: this.generateRunId(),
52
+ startTime: new Date(),
53
+ variables: {},
54
+ logs: [],
55
+ };
56
+ }
57
+
58
+ private generateRunId(): string {
59
+ return `run_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
60
+ }
61
+
62
+ private storeExecutionResult(
63
+ nodeId: string,
64
+ result: string | number | boolean | object | null,
65
+ success: boolean = true,
66
+ error?: string,
67
+ executionTime?: number,
68
+ ): void {
69
+ const node = this.nodes.find((n) => n.id === nodeId);
70
+ if (!node) return;
71
+
72
+ const executionResult = {
73
+ success,
74
+ data: result,
75
+ timestamp: new Date().toISOString(),
76
+ error,
77
+ executionTime,
78
+ };
79
+
80
+ // Update the node's formData with execution result
81
+ if (node.data.formData) {
82
+ (node.data.formData as any).executionResult = executionResult;
83
+ } else {
84
+ (node.data as any).executionResult = executionResult;
85
+ }
86
+
87
+ // Notify the parent component about the node update
88
+ if (this.onNodeUpdate) {
89
+ // Create new object reference with deep clone of formData so React detects the change
90
+ const updatedData = {
91
+ ...node.data,
92
+ ...(node.data.formData ? { formData: { ...node.data.formData } } : {}),
93
+ };
94
+ this.onNodeUpdate(nodeId, updatedData);
95
+ }
96
+ }
97
+
98
+ private log(
99
+ level: AutomationLog['level'],
100
+ nodeId: string,
101
+ nodeType: string,
102
+ message: string,
103
+ data?: string | number | boolean | object | null,
104
+ ) {
105
+ const entry: AutomationLog = {
106
+ timestamp: new Date(),
107
+ nodeId,
108
+ nodeType,
109
+ level,
110
+ message,
111
+ data,
112
+ };
113
+ this.context.logs.push(entry);
114
+ if (this.onLog) {
115
+ try {
116
+ this.onLog(entry);
117
+ } catch {
118
+ // ignore UI callback errors
119
+ }
120
+ }
121
+ }
122
+
123
+ private getNextNodes(currentNodeId: string): Node[] {
124
+ const outgoingEdges = this.edges.filter(
125
+ (edge) => edge.source === currentNodeId,
126
+ );
127
+ const nextNodeIds = outgoingEdges.map((edge) => edge.target);
128
+ return this.nodes.filter((node) => nextNodeIds.includes(node.id));
129
+ }
130
+
131
+ private async executeStartNode(
132
+ node: Node,
133
+ ): Promise<{ runId: string; startTime: string }> {
134
+ const data = node.data;
135
+ this.log(
136
+ 'info',
137
+ node.id,
138
+ 'AutomationStartNode',
139
+ 'Starting automation workflow',
140
+ );
141
+
142
+ // Set initial context variables
143
+ this.context.variables.runId = this.context.runId;
144
+ this.context.variables.startTime = this.context.startTime.toISOString();
145
+
146
+ const result = {
147
+ runId: this.context.runId,
148
+ startTime: this.context.startTime.toISOString(),
149
+ };
150
+
151
+ // Store the execution result in node data
152
+ this.storeExecutionResult(node.id, result, true);
153
+
154
+ return result;
155
+ }
156
+
157
+ private async executeApiNode(node: Node): Promise<object> {
158
+ const data = node.data;
159
+ const formData = (data.formData || data) as AutomationApiNodeForm;
160
+
161
+ this.log(
162
+ 'info',
163
+ node.id,
164
+ 'AutomationApiNode',
165
+ `Making ${formData.method} request to ${formData.url}`,
166
+ );
167
+
168
+ try {
169
+ const headers: Record<string, string> = {};
170
+ if (formData.headers && Array.isArray(formData.headers)) {
171
+ formData.headers.forEach((header) => {
172
+ if (header.enabled) {
173
+ headers[header.key] = header.value;
174
+ }
175
+ });
176
+ }
177
+
178
+ const queryParams = new URLSearchParams();
179
+ if (formData.queryParams && Array.isArray(formData.queryParams)) {
180
+ formData.queryParams.forEach((param) => {
181
+ if (param.enabled) {
182
+ queryParams.append(param.key, param.value);
183
+ }
184
+ });
185
+ }
186
+
187
+ const url = queryParams.toString()
188
+ ? `${formData.url}?${queryParams.toString()}`
189
+ : formData.url;
190
+
191
+ const requestOptions: RequestInit = {
192
+ method: formData.method,
193
+ headers,
194
+ signal: AbortSignal.timeout(formData.timeout || 30000),
195
+ };
196
+
197
+ if (
198
+ formData.body &&
199
+ (formData.method === 'POST' || formData.method === 'PUT')
200
+ ) {
201
+ requestOptions.body = formData.body;
202
+ }
203
+
204
+ const response = await fetch(url, requestOptions);
205
+
206
+ if (!response.ok) {
207
+ throw new Error(
208
+ `HTTP ${response.status}: ${response.statusText} - ${url}`,
209
+ );
210
+ }
211
+
212
+ const responseData = await response.json();
213
+ this.log(
214
+ 'success',
215
+ node.id,
216
+ 'AutomationApiNode',
217
+ 'API call completed successfully',
218
+ responseData,
219
+ );
220
+
221
+ // Store the execution result in node data
222
+ this.storeExecutionResult(node.id, responseData, true);
223
+
224
+ return responseData;
225
+ } catch (error) {
226
+ let errorMessage = `API call failed: ${error}`;
227
+
228
+ if (error instanceof TypeError && error.message.includes('fetch')) {
229
+ errorMessage = `Network error: Unable to connect to ${formData.url}. This might be due to CORS restrictions or network connectivity issues.`;
230
+ }
231
+
232
+ this.log(
233
+ 'error',
234
+ node.id,
235
+ 'AutomationApiNode',
236
+ errorMessage,
237
+ error instanceof Error ? error.message : String(error),
238
+ );
239
+
240
+ // Store the error result in node data
241
+ this.storeExecutionResult(node.id, null, false, errorMessage);
242
+
243
+ throw new Error(errorMessage);
244
+ }
245
+ }
246
+
247
+ private async executeFormattingNode(
248
+ node: Node,
249
+ inputData: string | number | boolean | object | null,
250
+ ): Promise<string | number | boolean | object | null> {
251
+ const data = node.data;
252
+ const formData = (data.formData || data) as AutomationFormattingNodeForm;
253
+
254
+ this.log(
255
+ 'info',
256
+ node.id,
257
+ 'AutomationFormattingNode',
258
+ 'Starting data formatting',
259
+ );
260
+
261
+ try {
262
+ if (formData.formattingType === 'ai-powered' && formData.aiFormatting) {
263
+ // AI-powered formatting
264
+ this.log('info', node.id, 'AutomationFormattingNode', 'AI thinking...');
265
+ const aiResponse = await this.callAiApi(
266
+ formData.aiFormatting,
267
+ inputData,
268
+ );
269
+ this.log(
270
+ 'success',
271
+ node.id,
272
+ 'AutomationFormattingNode',
273
+ 'AI formatting completed',
274
+ aiResponse,
275
+ );
276
+
277
+ // Store the execution result in node data
278
+ this.storeExecutionResult(node.id, aiResponse, true);
279
+
280
+ return aiResponse;
281
+ } else {
282
+ // Basic formatting
283
+ const formattedData = this.basicFormatting(inputData, formData);
284
+ this.log(
285
+ 'success',
286
+ node.id,
287
+ 'AutomationFormattingNode',
288
+ 'Basic formatting completed',
289
+ formattedData,
290
+ );
291
+
292
+ // Store the execution result in node data
293
+ this.storeExecutionResult(node.id, formattedData, true);
294
+
295
+ return formattedData;
296
+ }
297
+ } catch (error) {
298
+ this.log(
299
+ 'error',
300
+ node.id,
301
+ 'AutomationFormattingNode',
302
+ `Formatting failed: ${error}`,
303
+ error instanceof Error ? error.message : String(error),
304
+ );
305
+
306
+ // Store the error result in node data
307
+ this.storeExecutionResult(
308
+ node.id,
309
+ null,
310
+ false,
311
+ error instanceof Error ? error.message : String(error),
312
+ );
313
+
314
+ throw error;
315
+ }
316
+ }
317
+
318
+ private async callAiApi(
319
+ aiConfig: NonNullable<AutomationFormattingNodeForm['aiFormatting']>,
320
+ inputData: string | number | boolean | object | null,
321
+ ): Promise<string | number | boolean | object | null> {
322
+ // Validate API key is not a placeholder
323
+ if (
324
+ !aiConfig.apiKey ||
325
+ aiConfig.apiKey.includes('your-openai-api-key-here') ||
326
+ aiConfig.apiKey.length < 10
327
+ ) {
328
+ throw new Error('Invalid API key. Please provide a valid API key.');
329
+ }
330
+
331
+ // Additional validation for Gemini API key format
332
+ if (aiConfig.apiUrl.includes('generativelanguage.googleapis.com')) {
333
+ if (!aiConfig.apiKey.startsWith('AIza')) {
334
+ throw new Error(
335
+ 'Invalid Gemini API key format. Gemini API keys should start with "AIza".',
336
+ );
337
+ }
338
+ }
339
+
340
+ const prompt = `${aiConfig.instruction}\n\nInput data: ${JSON.stringify(inputData)}`;
341
+
342
+ // Determine if this is Gemini API or OpenAI API based on URL
343
+ const isGeminiApi = aiConfig.apiUrl.includes(
344
+ 'generativelanguage.googleapis.com',
345
+ );
346
+
347
+ let requestBody: any;
348
+ let headers: Record<string, string>;
349
+
350
+ if (isGeminiApi) {
351
+ // Gemini API format
352
+ headers = {
353
+ 'Content-Type': 'application/json',
354
+ 'X-goog-api-key': aiConfig.apiKey,
355
+ };
356
+
357
+ requestBody = {
358
+ contents: [
359
+ {
360
+ parts: [
361
+ {
362
+ text: `${aiConfig.systemPrompt || 'You are a data formatting assistant.'}\n\n${prompt}`,
363
+ },
364
+ ],
365
+ },
366
+ ],
367
+ generationConfig: {
368
+ temperature: aiConfig.temperature || 0.1,
369
+ maxOutputTokens: aiConfig.maxTokens || 1000,
370
+ responseMimeType: 'application/json',
371
+ },
372
+ };
373
+ } else {
374
+ // OpenAI API format
375
+ headers = {
376
+ 'Content-Type': 'application/json',
377
+ Authorization: `Bearer ${aiConfig.apiKey}`,
378
+ };
379
+
380
+ requestBody = {
381
+ model: aiConfig.model,
382
+ messages: [
383
+ {
384
+ role: 'system',
385
+ content:
386
+ aiConfig.systemPrompt || 'You are a data formatting assistant.',
387
+ },
388
+ {
389
+ role: 'user',
390
+ content: prompt,
391
+ },
392
+ ],
393
+ temperature: aiConfig.temperature || 0.1,
394
+ max_tokens: aiConfig.maxTokens || 1000,
395
+ };
396
+ }
397
+
398
+ const response = await fetch(aiConfig.apiUrl, {
399
+ method: 'POST',
400
+ headers,
401
+ body: JSON.stringify(requestBody),
402
+ });
403
+
404
+ if (!response.ok) {
405
+ const errorText = await response.text();
406
+ throw new Error(
407
+ `AI API call failed: ${response.status} ${response.statusText}. ${errorText}`,
408
+ );
409
+ }
410
+
411
+ const result = await response.json();
412
+
413
+ let content: string;
414
+
415
+ if (isGeminiApi) {
416
+ // Gemini API response format
417
+ if (
418
+ !result.candidates ||
419
+ !result.candidates[0] ||
420
+ !result.candidates[0].content ||
421
+ !result.candidates[0].content.parts
422
+ ) {
423
+ throw new Error('Invalid Gemini API response format');
424
+ }
425
+ content = result.candidates[0].content.parts[0].text;
426
+ } else {
427
+ // OpenAI API response format
428
+ if (!result.choices || !result.choices[0] || !result.choices[0].message) {
429
+ throw new Error('Invalid AI API response format');
430
+ }
431
+ content = result.choices[0].message.content;
432
+ }
433
+
434
+ // Try to parse as JSON, fallback to string if parsing fails
435
+ try {
436
+ return JSON.parse(content);
437
+ } catch {
438
+ return content;
439
+ }
440
+ }
441
+
442
+ private basicFormatting(
443
+ inputData: string | number | boolean | object | null,
444
+ config: AutomationFormattingNodeForm,
445
+ ): string | number | boolean | object | null {
446
+ // Basic data transformation logic
447
+ if (typeof inputData === 'string') {
448
+ return inputData.trim();
449
+ }
450
+
451
+ if (Array.isArray(inputData)) {
452
+ return inputData.map((item) => this.basicFormatting(item, config));
453
+ }
454
+
455
+ if (typeof inputData === 'object' && inputData !== null) {
456
+ const formatted: Record<string, unknown> = {};
457
+ Object.keys(inputData).forEach((key) => {
458
+ formatted[key] = this.basicFormatting(
459
+ (inputData as Record<string, unknown>)[key] as
460
+ | string
461
+ | number
462
+ | boolean
463
+ | object
464
+ | null,
465
+ config,
466
+ );
467
+ });
468
+ return formatted;
469
+ }
470
+
471
+ return inputData;
472
+ }
473
+
474
+ private async executeEndNode(
475
+ node: Node,
476
+ inputData: string | number | boolean | object | null,
477
+ ): Promise<string | number | boolean | object | null> {
478
+ const data = node.data;
479
+ const formData = (data.formData || data) as AutomationEndNodeForm;
480
+
481
+ this.log(
482
+ 'info',
483
+ node.id,
484
+ 'AutomationEndNode',
485
+ 'Workflow completed successfully',
486
+ );
487
+
488
+ // Handle different output types
489
+ switch (formData.outputType) {
490
+ case 'display':
491
+ this.log(
492
+ 'info',
493
+ node.id,
494
+ 'AutomationEndNode',
495
+ 'Output displayed in UI',
496
+ inputData,
497
+ );
498
+ break;
499
+ case 'store':
500
+ this.log(
501
+ 'info',
502
+ node.id,
503
+ 'AutomationEndNode',
504
+ 'Data stored to destination',
505
+ inputData,
506
+ );
507
+ break;
508
+ case 'send':
509
+ this.log(
510
+ 'info',
511
+ node.id,
512
+ 'AutomationEndNode',
513
+ 'Data sent to destination',
514
+ inputData,
515
+ );
516
+ break;
517
+ }
518
+
519
+ // Store the execution result in node data
520
+ this.storeExecutionResult(node.id, inputData, true);
521
+
522
+ return inputData;
523
+ }
524
+
525
+ private async executeNode(
526
+ node: Node,
527
+ inputData?: string | number | boolean | object | null,
528
+ ): Promise<string | number | boolean | object | null> {
529
+ const nodeType = node.type;
530
+
531
+ switch (nodeType) {
532
+ case 'AutomationStartNode':
533
+ return await this.executeStartNode(node);
534
+ case 'AutomationApiNode':
535
+ return await this.executeApiNode(node);
536
+ case 'AutomationFormattingNode':
537
+ return await this.executeFormattingNode(node, inputData || null);
538
+ case 'AutomationEndNode':
539
+ return await this.executeEndNode(node, inputData || null);
540
+ default:
541
+ throw new Error(`Unknown node type: ${nodeType}`);
542
+ }
543
+ }
544
+
545
+ public async executeWorkflow(): Promise<AutomationResult> {
546
+ try {
547
+ // Find start node
548
+ const startNode = this.nodes.find(
549
+ (node) => node.type === 'AutomationStartNode',
550
+ );
551
+ if (!startNode) {
552
+ throw new Error('No start node found in workflow');
553
+ }
554
+
555
+ this.log('info', 'workflow', 'engine', 'Starting workflow execution');
556
+
557
+ // Execute nodes in sequence
558
+ let currentNode: Node | null = startNode;
559
+ let currentData: string | number | boolean | object | null = null;
560
+ const visitedNodes = new Set<string>();
561
+
562
+ while (currentNode) {
563
+ if (visitedNodes.has(currentNode.id)) {
564
+ throw new Error(
565
+ `Circular dependency detected: node ${currentNode.id} already visited`,
566
+ );
567
+ }
568
+
569
+ visitedNodes.add(currentNode.id);
570
+
571
+ // Announce node execution start
572
+ this.log(
573
+ 'info',
574
+ currentNode.id,
575
+ String(currentNode.type || 'node'),
576
+ 'Executing node...',
577
+ );
578
+
579
+ // Update node status to running
580
+ (currentNode.data as Record<string, unknown>).status = 'Running';
581
+ if (this.onNodeUpdate) {
582
+ // Create new object reference so React detects the change
583
+ this.onNodeUpdate(currentNode.id, { ...currentNode.data });
584
+ }
585
+
586
+ try {
587
+ currentData = await this.executeNode(currentNode, currentData);
588
+ (currentNode.data as Record<string, unknown>).status = 'Completed';
589
+ (currentNode.data as Record<string, unknown>).lastRun =
590
+ new Date().toISOString();
591
+ if (this.onNodeUpdate) {
592
+ // Create new object reference so React detects the change
593
+ this.onNodeUpdate(currentNode.id, { ...currentNode.data });
594
+ }
595
+ } catch (error) {
596
+ (currentNode.data as Record<string, unknown>).status = 'Error';
597
+ (currentNode.data as Record<string, unknown>).lastRun =
598
+ new Date().toISOString();
599
+ if (this.onNodeUpdate) {
600
+ // Create new object reference so React detects the change
601
+ this.onNodeUpdate(currentNode.id, { ...currentNode.data });
602
+ }
603
+ throw error;
604
+ }
605
+
606
+ // Find next node
607
+ const nextNodes = this.getNextNodes(currentNode.id);
608
+ if (nextNodes.length > 0) {
609
+ const next = nextNodes[0];
610
+ this.log(
611
+ 'info',
612
+ next.id,
613
+ String(next.type || 'node'),
614
+ 'Moving to next node',
615
+ );
616
+ currentNode = next;
617
+ } else {
618
+ this.log('info', 'workflow', 'engine', 'No next node. Ending.');
619
+ currentNode = null;
620
+ }
621
+ }
622
+
623
+ this.log(
624
+ 'success',
625
+ 'workflow',
626
+ 'engine',
627
+ 'Workflow execution completed successfully',
628
+ );
629
+
630
+ return {
631
+ success: true,
632
+ context: this.context,
633
+ finalOutput: currentData,
634
+ };
635
+ } catch (error) {
636
+ this.log(
637
+ 'error',
638
+ 'workflow',
639
+ 'engine',
640
+ `Workflow execution failed: ${error}`,
641
+ );
642
+
643
+ return {
644
+ success: false,
645
+ context: this.context,
646
+ error: error instanceof Error ? error.message : String(error),
647
+ };
648
+ }
649
+ }
650
+
651
+ public getLogs(): AutomationLog[] {
652
+ return this.context.logs;
653
+ }
654
+
655
+ public getContext(): AutomationContext {
656
+ return this.context;
657
+ }
658
+ }