@decaf-ts/as-graph 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (383) hide show
  1. package/README.md +92 -12
  2. package/assets/i18n/en.json +1519 -130
  3. package/dist/as-graph.cjs +1 -1
  4. package/dist/as-graph.cjs.map +1 -1
  5. package/dist/as-graph.js +1 -1
  6. package/dist/as-graph.js.map +1 -1
  7. package/lib/cjs/dagster/DagsterGraphExecutionBackend.cjs +13 -0
  8. package/lib/cjs/dagster/DagsterGraphExecutionBackend.cjs.map +1 -1
  9. package/lib/cjs/dagster/capabilities.cjs +5 -0
  10. package/lib/cjs/dagster/capabilities.cjs.map +1 -1
  11. package/lib/cjs/engine/execution/GraphCodeMode.cjs +42 -0
  12. package/lib/cjs/engine/execution/GraphCodeMode.cjs.map +1 -1
  13. package/lib/cjs/engine/execution/GraphExecutionEngine.cjs +35 -4
  14. package/lib/cjs/engine/execution/GraphExecutionEngine.cjs.map +1 -1
  15. package/lib/cjs/engine/validation/GraphNodeInstanceValidator.cjs +29 -1
  16. package/lib/cjs/engine/validation/GraphNodeInstanceValidator.cjs.map +1 -1
  17. package/lib/cjs/engine/validation/GraphWorkflowDocumentValidator.cjs +6 -2
  18. package/lib/cjs/engine/validation/GraphWorkflowDocumentValidator.cjs.map +1 -1
  19. package/lib/cjs/mastra/MastraWorkflowCompiler.cjs +41 -9
  20. package/lib/cjs/mastra/MastraWorkflowCompiler.cjs.map +1 -1
  21. package/lib/cjs/nest/graph/GraphEngineController.cjs +18 -0
  22. package/lib/cjs/nest/graph/GraphEngineController.cjs.map +1 -1
  23. package/lib/cjs/nest/graph/GraphNodeCatalogueController.cjs +14 -0
  24. package/lib/cjs/nest/graph/GraphNodeCatalogueController.cjs.map +1 -1
  25. package/lib/cjs/nest/graph/GraphRunController.cjs +17 -0
  26. package/lib/cjs/nest/graph/GraphRunController.cjs.map +1 -1
  27. package/lib/cjs/nest/graph/GraphWorkflowController.cjs +34 -5
  28. package/lib/cjs/nest/graph/GraphWorkflowController.cjs.map +1 -1
  29. package/lib/cjs/node/comms/discord/node.cjs +384 -0
  30. package/lib/cjs/node/comms/discord/node.cjs.map +1 -0
  31. package/lib/cjs/node/comms/outlook/node.cjs +395 -0
  32. package/lib/cjs/node/comms/outlook/node.cjs.map +1 -0
  33. package/lib/cjs/node/comms/whatsapp/node.cjs +341 -0
  34. package/lib/cjs/node/comms/whatsapp/node.cjs.map +1 -0
  35. package/lib/cjs/node/data/aggregate/node.cjs +196 -0
  36. package/lib/cjs/node/data/aggregate/node.cjs.map +1 -0
  37. package/lib/cjs/node/data/compare-datasets/node.cjs +331 -0
  38. package/lib/cjs/node/data/compare-datasets/node.cjs.map +1 -0
  39. package/lib/cjs/node/data/item-lists/node.cjs +416 -0
  40. package/lib/cjs/node/data/item-lists/node.cjs.map +1 -0
  41. package/lib/cjs/node/data/remove-duplicates/node.cjs +141 -0
  42. package/lib/cjs/node/data/remove-duplicates/node.cjs.map +1 -0
  43. package/lib/cjs/node/data/summarize/node.cjs +155 -0
  44. package/lib/cjs/node/data/summarize/node.cjs.map +1 -0
  45. package/lib/cjs/node/data/support.cjs +5 -0
  46. package/lib/cjs/node/data/support.cjs.map +1 -1
  47. package/lib/cjs/node/data/transform-utils.cjs +719 -0
  48. package/lib/cjs/node/data/transform-utils.cjs.map +1 -0
  49. package/lib/cjs/node/index.cjs +216 -110
  50. package/lib/cjs/node/index.cjs.map +1 -1
  51. package/lib/cjs/node/io/confluence/node.cjs +253 -0
  52. package/lib/cjs/node/io/confluence/node.cjs.map +1 -0
  53. package/lib/cjs/node/io/convert-to-file/node.cjs +349 -0
  54. package/lib/cjs/node/io/convert-to-file/node.cjs.map +1 -0
  55. package/lib/cjs/node/io/file-support.cjs +311 -0
  56. package/lib/cjs/node/io/file-support.cjs.map +1 -0
  57. package/lib/cjs/node/io/google-calendar/node.cjs +359 -0
  58. package/lib/cjs/node/io/google-calendar/node.cjs.map +1 -0
  59. package/lib/cjs/node/io/google-docs/node.cjs +272 -0
  60. package/lib/cjs/node/io/google-docs/node.cjs.map +1 -0
  61. package/lib/cjs/node/io/html/node.cjs +275 -0
  62. package/lib/cjs/node/io/html/node.cjs.map +1 -0
  63. package/lib/cjs/node/io/html-extract/node.cjs +162 -0
  64. package/lib/cjs/node/io/html-extract/node.cjs.map +1 -0
  65. package/lib/cjs/node/io/html-support.cjs +246 -0
  66. package/lib/cjs/node/io/html-support.cjs.map +1 -0
  67. package/lib/cjs/node/io/jira/node.cjs +351 -0
  68. package/lib/cjs/node/io/jira/node.cjs.map +1 -0
  69. package/lib/cjs/node/io/markdown/node.cjs +229 -0
  70. package/lib/cjs/node/io/markdown/node.cjs.map +1 -0
  71. package/lib/cjs/node/io/microsoft-excel/node.cjs +261 -0
  72. package/lib/cjs/node/io/microsoft-excel/node.cjs.map +1 -0
  73. package/lib/cjs/node/io/microsoft-sharepoint/node.cjs +274 -0
  74. package/lib/cjs/node/io/microsoft-sharepoint/node.cjs.map +1 -0
  75. package/lib/cjs/node/io/read-binary-file/node.cjs +114 -0
  76. package/lib/cjs/node/io/read-binary-file/node.cjs.map +1 -0
  77. package/lib/cjs/node/io/read-binary-files/node.cjs +113 -0
  78. package/lib/cjs/node/io/read-binary-files/node.cjs.map +1 -0
  79. package/lib/cjs/node/io/write-binary-file/node.cjs +164 -0
  80. package/lib/cjs/node/io/write-binary-file/node.cjs.map +1 -0
  81. package/lib/cjs/node/io/xml/node.cjs +322 -0
  82. package/lib/cjs/node/io/xml/node.cjs.map +1 -0
  83. package/lib/cjs/node/manifests.cjs +137 -79
  84. package/lib/cjs/node/manifests.cjs.map +1 -1
  85. package/lib/cjs/node/storage/rabbitmq/node.cjs +252 -0
  86. package/lib/cjs/node/storage/rabbitmq/node.cjs.map +1 -0
  87. package/lib/cjs/node/triggers/error/node.cjs +108 -0
  88. package/lib/cjs/node/triggers/error/node.cjs.map +1 -0
  89. package/lib/cjs/node/triggers/postgres/node.cjs +244 -0
  90. package/lib/cjs/node/triggers/postgres/node.cjs.map +1 -0
  91. package/lib/cjs/node/triggers/rabbitmq/node.cjs +284 -0
  92. package/lib/cjs/node/triggers/rabbitmq/node.cjs.map +1 -0
  93. package/lib/cjs/node/triggers/redis/node.cjs +233 -0
  94. package/lib/cjs/node/triggers/redis/node.cjs.map +1 -0
  95. package/lib/cjs/node/triggers/sse/node.cjs +196 -0
  96. package/lib/cjs/node/triggers/sse/node.cjs.map +1 -0
  97. package/lib/cjs/node/triggers/support.cjs +107 -0
  98. package/lib/cjs/node/triggers/support.cjs.map +1 -0
  99. package/lib/cjs/node/triggers/workflow/node.cjs +193 -0
  100. package/lib/cjs/node/triggers/workflow/node.cjs.map +1 -0
  101. package/lib/cjs/shared/graph/catalog/GraphValueSchemaDerivation.cjs +20 -3
  102. package/lib/cjs/shared/graph/catalog/GraphValueSchemaDerivation.cjs.map +1 -1
  103. package/lib/cjs/workflows/boundary-value.workflow.cjs +38 -0
  104. package/lib/cjs/workflows/boundary-value.workflow.cjs.map +1 -0
  105. package/lib/cjs/workflows/builders.cjs +47 -0
  106. package/lib/cjs/workflows/builders.cjs.map +1 -0
  107. package/lib/cjs/workflows/chat-agent.workflow.cjs +40 -0
  108. package/lib/cjs/workflows/chat-agent.workflow.cjs.map +1 -0
  109. package/lib/cjs/workflows/error-boundary.workflow.cjs +54 -0
  110. package/lib/cjs/workflows/error-boundary.workflow.cjs.map +1 -0
  111. package/lib/cjs/workflows/event-map.workflow.cjs +37 -0
  112. package/lib/cjs/workflows/event-map.workflow.cjs.map +1 -0
  113. package/lib/cjs/workflows/foreach-break.workflow.cjs +58 -0
  114. package/lib/cjs/workflows/foreach-break.workflow.cjs.map +1 -0
  115. package/lib/cjs/workflows/human-approval.workflow.cjs +44 -0
  116. package/lib/cjs/workflows/human-approval.workflow.cjs.map +1 -0
  117. package/lib/cjs/workflows/if-switch.workflow.cjs +66 -0
  118. package/lib/cjs/workflows/if-switch.workflow.cjs.map +1 -0
  119. package/lib/cjs/workflows/index.cjs +135 -0
  120. package/lib/cjs/workflows/index.cjs.map +1 -0
  121. package/lib/cjs/workflows/loops-while-until.workflow.cjs +76 -0
  122. package/lib/cjs/workflows/loops-while-until.workflow.cjs.map +1 -0
  123. package/lib/cjs/workflows/manual-log.workflow.cjs +52 -0
  124. package/lib/cjs/workflows/manual-log.workflow.cjs.map +1 -0
  125. package/lib/cjs/workflows/schedule-code.workflow.cjs +42 -0
  126. package/lib/cjs/workflows/schedule-code.workflow.cjs.map +1 -0
  127. package/lib/cjs/workflows/types.cjs +4 -0
  128. package/lib/cjs/workflows/types.cjs.map +1 -0
  129. package/lib/cjs/workflows/value-templates.workflow.cjs +43 -0
  130. package/lib/cjs/workflows/value-templates.workflow.cjs.map +1 -0
  131. package/lib/cjs/workflows/webhook-form.workflow.cjs +48 -0
  132. package/lib/cjs/workflows/webhook-form.workflow.cjs.map +1 -0
  133. package/lib/esm/dagster/DagsterGraphExecutionBackend.js +13 -0
  134. package/lib/esm/dagster/DagsterGraphExecutionBackend.js.map +1 -1
  135. package/lib/esm/dagster/capabilities.js +5 -0
  136. package/lib/esm/dagster/capabilities.js.map +1 -1
  137. package/lib/esm/engine/execution/GraphCodeMode.js +40 -0
  138. package/lib/esm/engine/execution/GraphCodeMode.js.map +1 -1
  139. package/lib/esm/engine/execution/GraphExecutionBackend.js.map +1 -1
  140. package/lib/esm/engine/execution/GraphExecutionEngine.js +36 -5
  141. package/lib/esm/engine/execution/GraphExecutionEngine.js.map +1 -1
  142. package/lib/esm/engine/validation/GraphNodeInstanceValidator.js +29 -1
  143. package/lib/esm/engine/validation/GraphNodeInstanceValidator.js.map +1 -1
  144. package/lib/esm/engine/validation/GraphWorkflowDocumentValidator.js +6 -2
  145. package/lib/esm/engine/validation/GraphWorkflowDocumentValidator.js.map +1 -1
  146. package/lib/esm/mastra/MastraMemory.js.map +1 -1
  147. package/lib/esm/mastra/MastraWorkflowCompiler.js +41 -9
  148. package/lib/esm/mastra/MastraWorkflowCompiler.js.map +1 -1
  149. package/lib/esm/nest/graph/GraphEngineController.js +19 -1
  150. package/lib/esm/nest/graph/GraphEngineController.js.map +1 -1
  151. package/lib/esm/nest/graph/GraphNodeCatalogueController.js +15 -1
  152. package/lib/esm/nest/graph/GraphNodeCatalogueController.js.map +1 -1
  153. package/lib/esm/nest/graph/GraphRunController.js +18 -1
  154. package/lib/esm/nest/graph/GraphRunController.js.map +1 -1
  155. package/lib/esm/nest/graph/GraphWorkflowController.js +35 -6
  156. package/lib/esm/nest/graph/GraphWorkflowController.js.map +1 -1
  157. package/lib/esm/node/comms/discord/node.js +375 -0
  158. package/lib/esm/node/comms/discord/node.js.map +1 -0
  159. package/lib/esm/node/comms/outlook/node.js +386 -0
  160. package/lib/esm/node/comms/outlook/node.js.map +1 -0
  161. package/lib/esm/node/comms/whatsapp/node.js +332 -0
  162. package/lib/esm/node/comms/whatsapp/node.js.map +1 -0
  163. package/lib/esm/node/data/aggregate/node.js +187 -0
  164. package/lib/esm/node/data/aggregate/node.js.map +1 -0
  165. package/lib/esm/node/data/compare-datasets/node.js +322 -0
  166. package/lib/esm/node/data/compare-datasets/node.js.map +1 -0
  167. package/lib/esm/node/data/item-lists/node.js +407 -0
  168. package/lib/esm/node/data/item-lists/node.js.map +1 -0
  169. package/lib/esm/node/data/remove-duplicates/node.js +132 -0
  170. package/lib/esm/node/data/remove-duplicates/node.js.map +1 -0
  171. package/lib/esm/node/data/summarize/node.js +146 -0
  172. package/lib/esm/node/data/summarize/node.js.map +1 -0
  173. package/lib/esm/node/data/support.js +5 -1
  174. package/lib/esm/node/data/support.js.map +1 -1
  175. package/lib/esm/node/data/transform-utils.js +702 -0
  176. package/lib/esm/node/data/transform-utils.js.map +1 -0
  177. package/lib/esm/node/index.js +110 -4
  178. package/lib/esm/node/index.js.map +1 -1
  179. package/lib/esm/node/io/confluence/node.js +244 -0
  180. package/lib/esm/node/io/confluence/node.js.map +1 -0
  181. package/lib/esm/node/io/convert-to-file/node.js +340 -0
  182. package/lib/esm/node/io/convert-to-file/node.js.map +1 -0
  183. package/lib/esm/node/io/file-support.js +299 -0
  184. package/lib/esm/node/io/file-support.js.map +1 -0
  185. package/lib/esm/node/io/google-calendar/node.js +350 -0
  186. package/lib/esm/node/io/google-calendar/node.js.map +1 -0
  187. package/lib/esm/node/io/google-docs/node.js +263 -0
  188. package/lib/esm/node/io/google-docs/node.js.map +1 -0
  189. package/lib/esm/node/io/html/node.js +266 -0
  190. package/lib/esm/node/io/html/node.js.map +1 -0
  191. package/lib/esm/node/io/html-extract/node.js +153 -0
  192. package/lib/esm/node/io/html-extract/node.js.map +1 -0
  193. package/lib/esm/node/io/html-support.js +206 -0
  194. package/lib/esm/node/io/html-support.js.map +1 -0
  195. package/lib/esm/node/io/jira/node.js +342 -0
  196. package/lib/esm/node/io/jira/node.js.map +1 -0
  197. package/lib/esm/node/io/markdown/node.js +217 -0
  198. package/lib/esm/node/io/markdown/node.js.map +1 -0
  199. package/lib/esm/node/io/microsoft-excel/node.js +252 -0
  200. package/lib/esm/node/io/microsoft-excel/node.js.map +1 -0
  201. package/lib/esm/node/io/microsoft-sharepoint/node.js +265 -0
  202. package/lib/esm/node/io/microsoft-sharepoint/node.js.map +1 -0
  203. package/lib/esm/node/io/read-binary-file/node.js +105 -0
  204. package/lib/esm/node/io/read-binary-file/node.js.map +1 -0
  205. package/lib/esm/node/io/read-binary-files/node.js +104 -0
  206. package/lib/esm/node/io/read-binary-files/node.js.map +1 -0
  207. package/lib/esm/node/io/write-binary-file/node.js +155 -0
  208. package/lib/esm/node/io/write-binary-file/node.js.map +1 -0
  209. package/lib/esm/node/io/xml/node.js +313 -0
  210. package/lib/esm/node/io/xml/node.js.map +1 -0
  211. package/lib/esm/node/manifests.js +58 -0
  212. package/lib/esm/node/manifests.js.map +1 -1
  213. package/lib/esm/node/storage/rabbitmq/node.js +243 -0
  214. package/lib/esm/node/storage/rabbitmq/node.js.map +1 -0
  215. package/lib/esm/node/triggers/error/node.js +99 -0
  216. package/lib/esm/node/triggers/error/node.js.map +1 -0
  217. package/lib/esm/node/triggers/postgres/node.js +235 -0
  218. package/lib/esm/node/triggers/postgres/node.js.map +1 -0
  219. package/lib/esm/node/triggers/rabbitmq/node.js +275 -0
  220. package/lib/esm/node/triggers/rabbitmq/node.js.map +1 -0
  221. package/lib/esm/node/triggers/redis/node.js +224 -0
  222. package/lib/esm/node/triggers/redis/node.js.map +1 -0
  223. package/lib/esm/node/triggers/sse/node.js +187 -0
  224. package/lib/esm/node/triggers/sse/node.js.map +1 -0
  225. package/lib/esm/node/triggers/support.js +99 -0
  226. package/lib/esm/node/triggers/support.js.map +1 -0
  227. package/lib/esm/node/triggers/workflow/node.js +184 -0
  228. package/lib/esm/node/triggers/workflow/node.js.map +1 -0
  229. package/lib/esm/shared/graph/catalog/GraphValueSchemaDerivation.js +20 -3
  230. package/lib/esm/shared/graph/catalog/GraphValueSchemaDerivation.js.map +1 -1
  231. package/lib/esm/workflows/boundary-value.workflow.js +34 -0
  232. package/lib/esm/workflows/boundary-value.workflow.js.map +1 -0
  233. package/lib/esm/workflows/builders.js +40 -0
  234. package/lib/esm/workflows/builders.js.map +1 -0
  235. package/lib/esm/workflows/chat-agent.workflow.js +36 -0
  236. package/lib/esm/workflows/chat-agent.workflow.js.map +1 -0
  237. package/lib/esm/workflows/error-boundary.workflow.js +50 -0
  238. package/lib/esm/workflows/error-boundary.workflow.js.map +1 -0
  239. package/lib/esm/workflows/event-map.workflow.js +33 -0
  240. package/lib/esm/workflows/event-map.workflow.js.map +1 -0
  241. package/lib/esm/workflows/foreach-break.workflow.js +54 -0
  242. package/lib/esm/workflows/foreach-break.workflow.js.map +1 -0
  243. package/lib/esm/workflows/human-approval.workflow.js +40 -0
  244. package/lib/esm/workflows/human-approval.workflow.js.map +1 -0
  245. package/lib/esm/workflows/if-switch.workflow.js +62 -0
  246. package/lib/esm/workflows/if-switch.workflow.js.map +1 -0
  247. package/lib/esm/workflows/index.js +116 -0
  248. package/lib/esm/workflows/index.js.map +1 -0
  249. package/lib/esm/workflows/loops-while-until.workflow.js +72 -0
  250. package/lib/esm/workflows/loops-while-until.workflow.js.map +1 -0
  251. package/lib/esm/workflows/manual-log.workflow.js +48 -0
  252. package/lib/esm/workflows/manual-log.workflow.js.map +1 -0
  253. package/lib/esm/workflows/schedule-code.workflow.js +38 -0
  254. package/lib/esm/workflows/schedule-code.workflow.js.map +1 -0
  255. package/lib/esm/workflows/types.js +2 -0
  256. package/lib/esm/workflows/types.js.map +1 -0
  257. package/lib/esm/workflows/value-templates.workflow.js +39 -0
  258. package/lib/esm/workflows/value-templates.workflow.js.map +1 -0
  259. package/lib/esm/workflows/webhook-form.workflow.js +44 -0
  260. package/lib/esm/workflows/webhook-form.workflow.js.map +1 -0
  261. package/lib/types/dagster/DagsterGraphExecutionBackend.d.cts +7 -0
  262. package/lib/types/dagster/DagsterGraphExecutionBackend.d.mts +7 -0
  263. package/lib/types/engine/execution/GraphCodeMode.d.cts +46 -0
  264. package/lib/types/engine/execution/GraphCodeMode.d.mts +46 -0
  265. package/lib/types/engine/execution/GraphExecutionBackend.d.cts +21 -0
  266. package/lib/types/engine/execution/GraphExecutionBackend.d.mts +21 -0
  267. package/lib/types/engine/execution/GraphExecutionEngine.d.cts +28 -3
  268. package/lib/types/engine/execution/GraphExecutionEngine.d.mts +28 -3
  269. package/lib/types/engine/validation/GraphNodeInstanceValidator.d.cts +11 -1
  270. package/lib/types/engine/validation/GraphNodeInstanceValidator.d.mts +11 -1
  271. package/lib/types/engine/validation/GraphWorkflowDocumentValidator.d.cts +7 -0
  272. package/lib/types/engine/validation/GraphWorkflowDocumentValidator.d.mts +7 -0
  273. package/lib/types/mastra/MastraWorkflowCompiler.d.cts +23 -8
  274. package/lib/types/mastra/MastraWorkflowCompiler.d.mts +23 -8
  275. package/lib/types/nest/graph/GraphEngineController.d.cts +19 -0
  276. package/lib/types/nest/graph/GraphEngineController.d.mts +19 -0
  277. package/lib/types/nest/graph/GraphNodeCatalogueController.d.cts +13 -0
  278. package/lib/types/nest/graph/GraphNodeCatalogueController.d.mts +13 -0
  279. package/lib/types/nest/graph/GraphRunController.d.cts +16 -0
  280. package/lib/types/nest/graph/GraphRunController.d.mts +16 -0
  281. package/lib/types/nest/graph/GraphWorkflowController.d.cts +26 -3
  282. package/lib/types/nest/graph/GraphWorkflowController.d.mts +26 -3
  283. package/lib/types/node/comms/discord/node.d.cts +67 -0
  284. package/lib/types/node/comms/discord/node.d.mts +67 -0
  285. package/lib/types/node/comms/outlook/node.d.cts +77 -0
  286. package/lib/types/node/comms/outlook/node.d.mts +77 -0
  287. package/lib/types/node/comms/whatsapp/node.d.cts +71 -0
  288. package/lib/types/node/comms/whatsapp/node.d.mts +71 -0
  289. package/lib/types/node/data/aggregate/node.d.cts +58 -0
  290. package/lib/types/node/data/aggregate/node.d.mts +58 -0
  291. package/lib/types/node/data/compare-datasets/node.d.cts +72 -0
  292. package/lib/types/node/data/compare-datasets/node.d.mts +72 -0
  293. package/lib/types/node/data/item-lists/node.d.cts +92 -0
  294. package/lib/types/node/data/item-lists/node.d.mts +92 -0
  295. package/lib/types/node/data/remove-duplicates/node.d.cts +47 -0
  296. package/lib/types/node/data/remove-duplicates/node.d.mts +47 -0
  297. package/lib/types/node/data/summarize/node.d.cts +44 -0
  298. package/lib/types/node/data/summarize/node.d.mts +44 -0
  299. package/lib/types/node/data/support.d.cts +13 -0
  300. package/lib/types/node/data/support.d.mts +13 -0
  301. package/lib/types/node/data/transform-utils.d.cts +236 -0
  302. package/lib/types/node/data/transform-utils.d.mts +236 -0
  303. package/lib/types/node/index.d.cts +54 -6
  304. package/lib/types/node/index.d.mts +54 -6
  305. package/lib/types/node/io/confluence/node.d.cts +49 -0
  306. package/lib/types/node/io/confluence/node.d.mts +49 -0
  307. package/lib/types/node/io/convert-to-file/node.d.cts +75 -0
  308. package/lib/types/node/io/convert-to-file/node.d.mts +75 -0
  309. package/lib/types/node/io/file-support.d.cts +118 -0
  310. package/lib/types/node/io/file-support.d.mts +118 -0
  311. package/lib/types/node/io/google-calendar/node.d.cts +65 -0
  312. package/lib/types/node/io/google-calendar/node.d.mts +65 -0
  313. package/lib/types/node/io/google-docs/node.d.cts +51 -0
  314. package/lib/types/node/io/google-docs/node.d.mts +51 -0
  315. package/lib/types/node/io/html/node.d.cts +68 -0
  316. package/lib/types/node/io/html/node.d.mts +68 -0
  317. package/lib/types/node/io/html-extract/node.d.cts +42 -0
  318. package/lib/types/node/io/html-extract/node.d.mts +42 -0
  319. package/lib/types/node/io/html-support.d.cts +69 -0
  320. package/lib/types/node/io/html-support.d.mts +69 -0
  321. package/lib/types/node/io/jira/node.d.cts +57 -0
  322. package/lib/types/node/io/jira/node.d.mts +57 -0
  323. package/lib/types/node/io/markdown/node.d.cts +61 -0
  324. package/lib/types/node/io/markdown/node.d.mts +61 -0
  325. package/lib/types/node/io/microsoft-excel/node.d.cts +45 -0
  326. package/lib/types/node/io/microsoft-excel/node.d.mts +45 -0
  327. package/lib/types/node/io/microsoft-sharepoint/node.d.cts +47 -0
  328. package/lib/types/node/io/microsoft-sharepoint/node.d.mts +47 -0
  329. package/lib/types/node/io/read-binary-file/node.d.cts +45 -0
  330. package/lib/types/node/io/read-binary-file/node.d.mts +45 -0
  331. package/lib/types/node/io/read-binary-files/node.d.cts +41 -0
  332. package/lib/types/node/io/read-binary-files/node.d.mts +41 -0
  333. package/lib/types/node/io/write-binary-file/node.d.cts +55 -0
  334. package/lib/types/node/io/write-binary-file/node.d.mts +55 -0
  335. package/lib/types/node/io/xml/node.d.cts +67 -0
  336. package/lib/types/node/io/xml/node.d.mts +67 -0
  337. package/lib/types/node/storage/rabbitmq/node.d.cts +55 -0
  338. package/lib/types/node/storage/rabbitmq/node.d.mts +55 -0
  339. package/lib/types/node/triggers/error/node.d.cts +34 -0
  340. package/lib/types/node/triggers/error/node.d.mts +34 -0
  341. package/lib/types/node/triggers/postgres/node.d.cts +54 -0
  342. package/lib/types/node/triggers/postgres/node.d.mts +54 -0
  343. package/lib/types/node/triggers/rabbitmq/node.d.cts +59 -0
  344. package/lib/types/node/triggers/rabbitmq/node.d.mts +59 -0
  345. package/lib/types/node/triggers/redis/node.d.cts +53 -0
  346. package/lib/types/node/triggers/redis/node.d.mts +53 -0
  347. package/lib/types/node/triggers/sse/node.d.cts +43 -0
  348. package/lib/types/node/triggers/sse/node.d.mts +43 -0
  349. package/lib/types/node/triggers/support.d.cts +41 -0
  350. package/lib/types/node/triggers/support.d.mts +41 -0
  351. package/lib/types/node/triggers/workflow/node.d.cts +46 -0
  352. package/lib/types/node/triggers/workflow/node.d.mts +46 -0
  353. package/lib/types/workflows/boundary-value.workflow.d.cts +3 -0
  354. package/lib/types/workflows/boundary-value.workflow.d.mts +3 -0
  355. package/lib/types/workflows/builders.d.cts +31 -0
  356. package/lib/types/workflows/builders.d.mts +31 -0
  357. package/lib/types/workflows/chat-agent.workflow.d.cts +3 -0
  358. package/lib/types/workflows/chat-agent.workflow.d.mts +3 -0
  359. package/lib/types/workflows/error-boundary.workflow.d.cts +3 -0
  360. package/lib/types/workflows/error-boundary.workflow.d.mts +3 -0
  361. package/lib/types/workflows/event-map.workflow.d.cts +3 -0
  362. package/lib/types/workflows/event-map.workflow.d.mts +3 -0
  363. package/lib/types/workflows/foreach-break.workflow.d.cts +3 -0
  364. package/lib/types/workflows/foreach-break.workflow.d.mts +3 -0
  365. package/lib/types/workflows/human-approval.workflow.d.cts +3 -0
  366. package/lib/types/workflows/human-approval.workflow.d.mts +3 -0
  367. package/lib/types/workflows/if-switch.workflow.d.cts +3 -0
  368. package/lib/types/workflows/if-switch.workflow.d.mts +3 -0
  369. package/lib/types/workflows/index.d.cts +37 -0
  370. package/lib/types/workflows/index.d.mts +37 -0
  371. package/lib/types/workflows/loops-while-until.workflow.d.cts +3 -0
  372. package/lib/types/workflows/loops-while-until.workflow.d.mts +3 -0
  373. package/lib/types/workflows/manual-log.workflow.d.cts +3 -0
  374. package/lib/types/workflows/manual-log.workflow.d.mts +3 -0
  375. package/lib/types/workflows/schedule-code.workflow.d.cts +3 -0
  376. package/lib/types/workflows/schedule-code.workflow.d.mts +3 -0
  377. package/lib/types/workflows/types.d.cts +32 -0
  378. package/lib/types/workflows/types.d.mts +32 -0
  379. package/lib/types/workflows/value-templates.workflow.d.cts +16 -0
  380. package/lib/types/workflows/value-templates.workflow.d.mts +16 -0
  381. package/lib/types/workflows/webhook-form.workflow.d.cts +3 -0
  382. package/lib/types/workflows/webhook-form.workflow.d.mts +3 -0
  383. package/package.json +247 -25
@@ -0,0 +1,719 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareGraphFields = prepareGraphFields;
4
+ exports.normalizeGraphFieldName = normalizeGraphFieldName;
5
+ exports.stableGraphKey = stableGraphKey;
6
+ exports.graphValueEquals = graphValueEquals;
7
+ exports.graphValuesLooselyEqual = graphValuesLooselyEqual;
8
+ exports.collectGraphFieldPaths = collectGraphFieldPaths;
9
+ exports.omitGraphFields = omitGraphFields;
10
+ exports.projectGraphRecord = projectGraphRecord;
11
+ exports.aggregateGraphItems = aggregateGraphItems;
12
+ exports.aggregateGraphItemData = aggregateGraphItemData;
13
+ exports.sortGraphItems = sortGraphItems;
14
+ exports.splitGraphOutItems = splitGraphOutItems;
15
+ exports.dedupeGraphItems = dedupeGraphItems;
16
+ exports.summarizeGraphItems = summarizeGraphItems;
17
+ /**
18
+ * @module as-graph/nodes/data/transform-utils
19
+ * @description Shared data-transform primitives for the Stage 5a Data nodes
20
+ * (`aggregate`, `itemLists`, `compareDatasets`, `summarize`, and
21
+ * `removeDuplicates`). The module owns field-list normalization, stable value
22
+ * signatures and equality, field path collection/projection, aggregation,
23
+ * sorting, split-out, deduplication, and the summarize engine. It builds on the
24
+ * path helpers in `./support` and throws `GraphExecutionError` with the
25
+ * `GRAPH_*` codes documented per function. Field-derived write keys are passed
26
+ * through `assertGraphDataSegment`, so a reserved segment fails closed with
27
+ * `GRAPH_DATA_UNSAFE_PATH` instead of reaching the prototype chain.
28
+ */
29
+ const GraphExecutionError_js_1 = require("./../../engine/errors/GraphExecutionError.cjs");
30
+ const support_js_1 = require("./support.cjs");
31
+ /**
32
+ * Normalizes a configured field list into trimmed, non-empty names.
33
+ *
34
+ * @param value - Comma-separated string, string array, or nil.
35
+ * @param fieldName - Label used in the validation error (default `Fields`).
36
+ * @returns The normalized field names; an empty array for nil input.
37
+ * @throws {GraphExecutionError} `GRAPH_DATA_INVALID_FIELDS` when the value is
38
+ * neither a string nor an array of strings.
39
+ */
40
+ function prepareGraphFields(value, fieldName = "Fields") {
41
+ if (value === undefined || value === null)
42
+ return [];
43
+ if (typeof value === "string") {
44
+ return value
45
+ .split(",")
46
+ .map((entry) => entry.trim())
47
+ .filter((entry) => entry.length > 0);
48
+ }
49
+ if (Array.isArray(value)) {
50
+ return value
51
+ .filter((entry) => typeof entry === "string")
52
+ .map((entry) => entry.trim())
53
+ .filter((entry) => entry.length > 0);
54
+ }
55
+ throw new GraphExecutionError_js_1.GraphExecutionError(`The '${fieldName}' parameter must be a comma-separated string or an array of strings`, "GRAPH_DATA_INVALID_FIELDS", { fieldName });
56
+ }
57
+ /**
58
+ * Converts a field path into an aggregation-key-safe name by removing
59
+ * brackets/quotes and replacing spaces and dots with underscores.
60
+ *
61
+ * @param name - The raw field name.
62
+ * @returns The normalized field name.
63
+ */
64
+ function normalizeGraphFieldName(name) {
65
+ return name.replace(/]/g, "").replace(/\[/g, "").replace(/"/g, "").replace(/[ .]/g, "_");
66
+ }
67
+ /**
68
+ * Builds a deterministic JSON signature for a value, used for deduplication
69
+ * and grouping.
70
+ *
71
+ * Object keys are sorted, dates become ISO strings, `NaN`, `undefined`, and
72
+ * bigint values get explicit markers, and arrays/records are normalized
73
+ * recursively so equal data always yields the same key.
74
+ *
75
+ * @param value - The value to serialize.
76
+ * @returns The stable signature string.
77
+ * @throws {GraphExecutionError} `GRAPH_DATA_UNSAFE_PATH` when a record key is
78
+ * a reserved prototype-pollution segment.
79
+ */
80
+ function stableGraphKey(value) {
81
+ const normalize = (entry) => {
82
+ if (Array.isArray(entry))
83
+ return entry.map(normalize);
84
+ if (entry instanceof Date)
85
+ return entry.toISOString();
86
+ if ((0, support_js_1.isGraphDataRecord)(entry)) {
87
+ return Object.keys(entry)
88
+ .sort()
89
+ .reduce((result, key) => {
90
+ (0, support_js_1.assertGraphDataSegment)(key, key);
91
+ result[key] = normalize(entry[key]);
92
+ return result;
93
+ }, {});
94
+ }
95
+ if (typeof entry === "number" && Number.isNaN(entry))
96
+ return "@NaN";
97
+ if (entry === undefined)
98
+ return "@undefined";
99
+ if (typeof entry === "bigint")
100
+ return `${entry.toString()}n`;
101
+ return entry;
102
+ };
103
+ return JSON.stringify(normalize(value));
104
+ }
105
+ /**
106
+ * Strict deep equality for graph data.
107
+ *
108
+ * Values compare by identity, `NaN` equals `NaN`, dates compare by timestamp,
109
+ * and arrays/records compare recursively with matching keys and lengths.
110
+ *
111
+ * @param left - First value.
112
+ * @param right - Second value.
113
+ * @returns `true` when both values are deeply equal.
114
+ */
115
+ function graphValueEquals(left, right) {
116
+ if (left === right)
117
+ return true;
118
+ if (typeof left === "number" &&
119
+ typeof right === "number" &&
120
+ Number.isNaN(left) &&
121
+ Number.isNaN(right)) {
122
+ return true;
123
+ }
124
+ if (left instanceof Date && right instanceof Date) {
125
+ return left.getTime() === right.getTime();
126
+ }
127
+ if (Array.isArray(left) && Array.isArray(right)) {
128
+ if (left.length !== right.length)
129
+ return false;
130
+ return left.every((entry, index) => graphValueEquals(entry, right[index]));
131
+ }
132
+ if ((0, support_js_1.isGraphDataRecord)(left) && (0, support_js_1.isGraphDataRecord)(right)) {
133
+ const leftKeys = Object.keys(left);
134
+ const rightKeys = Object.keys(right);
135
+ if (leftKeys.length !== rightKeys.length)
136
+ return false;
137
+ return leftKeys.every((key) => Object.prototype.hasOwnProperty.call(right, key) &&
138
+ graphValueEquals(left[key], right[key]));
139
+ }
140
+ return false;
141
+ }
142
+ function isFalsyCompareValue(value) {
143
+ if (value === undefined || value === null || value === "" || value === false) {
144
+ return true;
145
+ }
146
+ if (Array.isArray(value))
147
+ return value.length === 0;
148
+ if ((0, support_js_1.isGraphDataRecord)(value))
149
+ return Object.keys(value).length === 0;
150
+ return false;
151
+ }
152
+ /**
153
+ * Fuzzy equality used by the Compare Datasets node when `fuzzyCompare` is on.
154
+ *
155
+ * Besides strict equality it treats empty values (`null`, `undefined`, `""`,
156
+ * `false`, empty arrays/records) as equivalent, compares numeric strings to
157
+ * numbers, and parses JSON strings before comparing them to records.
158
+ *
159
+ * @param left - First value.
160
+ * @param right - Second value.
161
+ * @returns `true` when the values are loosely equivalent.
162
+ */
163
+ function graphValuesLooselyEqual(left, right) {
164
+ if (left !== null && right !== null && typeof left === typeof right) {
165
+ return graphValueEquals(left, right);
166
+ }
167
+ if (isFalsyCompareValue(left) && isFalsyCompareValue(right))
168
+ return true;
169
+ if (isFalsyCompareValue(left) && right === undefined)
170
+ return true;
171
+ if (left === undefined && isFalsyCompareValue(right))
172
+ return true;
173
+ if (typeof left === "number" && typeof right === "string") {
174
+ return left.toString() === right;
175
+ }
176
+ if (typeof left === "string" && typeof right === "number") {
177
+ return left === right.toString();
178
+ }
179
+ if ((0, support_js_1.isGraphDataRecord)(left) && typeof right === "string") {
180
+ try {
181
+ return graphValueEquals(left, JSON.parse(right));
182
+ }
183
+ catch {
184
+ return false;
185
+ }
186
+ }
187
+ if (typeof left === "string" && (0, support_js_1.isGraphDataRecord)(right)) {
188
+ try {
189
+ return graphValueEquals(JSON.parse(left), right);
190
+ }
191
+ catch {
192
+ return false;
193
+ }
194
+ }
195
+ return graphValueEquals(left, right);
196
+ }
197
+ /**
198
+ * Collects the leaf field paths of a value using dot notation or flat keys.
199
+ *
200
+ * Nested records recurse; arrays and scalars produce the current path. An
201
+ * empty record yields its own path (or no path at the root).
202
+ *
203
+ * @param value - The value to inspect.
204
+ * @param dotNotation - Whether nested records produce dot-separated paths.
205
+ * @param prefix - Accumulated path segments (used by recursion).
206
+ * @returns The collected field paths.
207
+ */
208
+ function collectGraphFieldPaths(value, dotNotation, prefix = []) {
209
+ if (!(0, support_js_1.isGraphDataRecord)(value) || Array.isArray(value)) {
210
+ return prefix.length ? [prefix.join(".")] : [];
211
+ }
212
+ if (!dotNotation) {
213
+ return prefix.length ? [prefix.join(".")] : Object.keys(value);
214
+ }
215
+ const keys = Object.keys(value);
216
+ if (keys.length === 0) {
217
+ return prefix.length ? [prefix.join(".")] : [];
218
+ }
219
+ const paths = [];
220
+ for (const key of keys) {
221
+ const child = value[key];
222
+ if ((0, support_js_1.isGraphDataRecord)(child) && !Array.isArray(child)) {
223
+ const childPaths = collectGraphFieldPaths(child, dotNotation, [
224
+ ...prefix,
225
+ key,
226
+ ]);
227
+ if (childPaths.length === 0) {
228
+ paths.push([...prefix, key].join("."));
229
+ }
230
+ else {
231
+ paths.push(...childPaths);
232
+ }
233
+ }
234
+ else {
235
+ paths.push([...prefix, key].join("."));
236
+ }
237
+ }
238
+ return paths;
239
+ }
240
+ /**
241
+ * Returns a shallow copy of a record without the configured fields.
242
+ *
243
+ * @param value - The source value; non-records are returned unchanged.
244
+ * @param fields - Field paths to remove.
245
+ * @param dotNotation - Whether field paths use dot notation.
246
+ * @returns The record without the omitted fields.
247
+ */
248
+ function omitGraphFields(value, fields, dotNotation) {
249
+ if (!(0, support_js_1.isGraphDataRecord)(value) || Array.isArray(value))
250
+ return value;
251
+ const result = { ...value };
252
+ for (const field of fields) {
253
+ if (!field)
254
+ continue;
255
+ (0, support_js_1.deleteGraphDataValue)(result, field, dotNotation);
256
+ }
257
+ return result;
258
+ }
259
+ /**
260
+ * Builds a record containing only the requested field paths.
261
+ *
262
+ * @param value - The source value; non-records are returned unchanged.
263
+ * @param fields - Field paths to keep.
264
+ * @param dotNotation - Whether field paths use dot notation.
265
+ * @returns The projected record.
266
+ */
267
+ function projectGraphRecord(value, fields, dotNotation) {
268
+ if (!(0, support_js_1.isGraphDataRecord)(value) || Array.isArray(value))
269
+ return value;
270
+ const result = {};
271
+ for (const field of fields) {
272
+ const selected = (0, support_js_1.getGraphDataValue)(value, field, dotNotation);
273
+ (0, support_js_1.setGraphDataValue)(result, field, selected, dotNotation);
274
+ }
275
+ return result;
276
+ }
277
+ function aggregateOutputName(source, spec, dotNotation) {
278
+ if (spec.outputFieldName)
279
+ return spec.outputFieldName;
280
+ if (dotNotation && source.includes(".")) {
281
+ return source.split(".").pop() ?? source;
282
+ }
283
+ return source;
284
+ }
285
+ /**
286
+ * Aggregates one output list of values per configured source field.
287
+ *
288
+ * Array values are flattened when `mergeLists` is set; `null`/`undefined`
289
+ * values are skipped unless `keepMissing` is set. Duplicate output names are
290
+ * rejected so no field is silently overwritten.
291
+ *
292
+ * @param items - The items to aggregate.
293
+ * @param fields - Source fields and their output options.
294
+ * @param options - Path, list-merging, and missing-value options.
295
+ * @returns A record keyed by output field name.
296
+ * @throws {GraphExecutionError} `GRAPH_AGGREGATE_DUPLICATE_FIELD` when two
297
+ * specs map to the same output field, or `GRAPH_DATA_UNSAFE_PATH` when an
298
+ * output field is a reserved prototype-pollution segment.
299
+ */
300
+ function aggregateGraphItems(items, fields, options = {}) {
301
+ const dotNotation = options.dotNotation !== false;
302
+ const result = {};
303
+ const used = new Set();
304
+ for (const spec of fields) {
305
+ const source = spec?.field ?? spec?.fieldToAggregate;
306
+ if (!source)
307
+ continue;
308
+ const output = aggregateOutputName(source, spec, dotNotation);
309
+ if (used.has(output)) {
310
+ throw new GraphExecutionError_js_1.GraphExecutionError(`The '${output}' output field is used more than once`, "GRAPH_AGGREGATE_DUPLICATE_FIELD", { field: output });
311
+ }
312
+ used.add(output);
313
+ const values = [];
314
+ for (const item of items) {
315
+ let value = (0, support_js_1.getGraphDataValue)(item, source, dotNotation);
316
+ if (Array.isArray(value) && !options.keepMissing) {
317
+ value = value.filter((entry) => entry !== null && entry !== undefined);
318
+ }
319
+ else if (!options.keepMissing &&
320
+ (value === undefined || value === null)) {
321
+ continue;
322
+ }
323
+ if (Array.isArray(value) && options.mergeLists) {
324
+ values.push(...value);
325
+ }
326
+ else {
327
+ values.push(value);
328
+ }
329
+ }
330
+ (0, support_js_1.setGraphDataValue)(result, output, values, dotNotation);
331
+ }
332
+ return result;
333
+ }
334
+ /**
335
+ * Groups every item into a projected record, dropping empty projections.
336
+ *
337
+ * @param items - The items to collect.
338
+ * @param options - Projection mode and the include/exclude field lists.
339
+ * @returns The projected item records.
340
+ * @throws {GraphExecutionError} `GRAPH_DATA_UNSAFE_PATH` when a projected key
341
+ * is a reserved prototype-pollution segment.
342
+ */
343
+ function aggregateGraphItemData(items, options = {}) {
344
+ const include = options.include ?? "allFields";
345
+ const fieldsToInclude = options.fieldsToInclude ?? [];
346
+ const fieldsToExclude = options.fieldsToExclude ?? [];
347
+ const records = [];
348
+ for (const item of items) {
349
+ const record = (0, support_js_1.isGraphDataRecord)(item)
350
+ ? { ...item }
351
+ : item === undefined
352
+ ? {}
353
+ : { value: item };
354
+ const keys = Object.keys(record);
355
+ let selected = keys;
356
+ if (include === "specifiedFields") {
357
+ selected = keys.filter((key) => fieldsToInclude.includes(key));
358
+ }
359
+ else if (include === "allFieldsExcept") {
360
+ selected = keys.filter((key) => !fieldsToExclude.includes(key));
361
+ }
362
+ const projected = {};
363
+ for (const key of selected) {
364
+ (0, support_js_1.assertGraphDataSegment)(key, key);
365
+ projected[key] = record[key];
366
+ }
367
+ if (Object.keys(projected).length > 0)
368
+ records.push(projected);
369
+ }
370
+ return records;
371
+ }
372
+ /**
373
+ * Returns a sorted copy of the items using the configured keys.
374
+ *
375
+ * Keys apply in order; the first non-zero comparison wins and `desc` reverses
376
+ * that key's comparison. An empty usable field list returns the input order.
377
+ *
378
+ * @param items - The items to sort.
379
+ * @param fields - Sort keys and directions.
380
+ * @param dotNotation - Whether field paths use dot notation.
381
+ * @param valueType - Coercion used for comparisons (default `auto`).
382
+ * @returns The sorted items.
383
+ */
384
+ function sortGraphItems(items, fields, dotNotation, valueType = "auto") {
385
+ const sorted = [...items];
386
+ const usable = fields.filter((entry) => entry && typeof entry.field === "string");
387
+ if (usable.length === 0)
388
+ return sorted;
389
+ sorted.sort((left, right) => {
390
+ for (const entry of usable) {
391
+ const comparison = (0, support_js_1.compareGraphDataValues)((0, support_js_1.getGraphDataValue)(left, entry.field, dotNotation), (0, support_js_1.getGraphDataValue)(right, entry.field, dotNotation), valueType);
392
+ if (comparison !== 0) {
393
+ return entry.direction === "desc" ? -comparison : comparison;
394
+ }
395
+ }
396
+ return 0;
397
+ });
398
+ return sorted;
399
+ }
400
+ /**
401
+ * Expands an array-valued field into one output item per value.
402
+ *
403
+ * Missing values are skipped. With `include: "allOtherFields"` each output
404
+ * keeps the other item fields and receives the value under `destinationField`
405
+ * (defaults to the split field).
406
+ *
407
+ * @param items - The items to split.
408
+ * @param field - The array-valued field path.
409
+ * @param options - Field retention and destination options.
410
+ * @returns The split-out items.
411
+ */
412
+ function splitGraphOutItems(items, field, options = {}) {
413
+ const dotNotation = options.dotNotation !== false;
414
+ const result = [];
415
+ for (const item of items) {
416
+ const value = (0, support_js_1.getGraphDataValue)(item, field, dotNotation);
417
+ if (value === undefined || value === null)
418
+ continue;
419
+ const values = Array.isArray(value) ? value : [value];
420
+ for (const entry of values) {
421
+ if (entry === undefined || entry === null)
422
+ continue;
423
+ if (options.include !== "allOtherFields") {
424
+ result.push(entry);
425
+ continue;
426
+ }
427
+ const destination = options.destinationField || field;
428
+ const base = (0, support_js_1.isGraphDataRecord)(item)
429
+ ? { ...item }
430
+ : {};
431
+ (0, support_js_1.deleteGraphDataValue)(base, field, true);
432
+ (0, support_js_1.setGraphDataValue)(base, destination, entry, true);
433
+ result.push(base);
434
+ }
435
+ }
436
+ return result;
437
+ }
438
+ /**
439
+ * Keeps the first item of each comparison signature.
440
+ *
441
+ * Signatures are built from every field, every field except the excluded
442
+ * list, or the selected field list. `removeOtherFields` projects kept items
443
+ * onto the compared fields.
444
+ *
445
+ * @param items - The items to deduplicate.
446
+ * @param options - Comparison mode, field lists, and projection option.
447
+ * @returns The unique items and the duplicates removed.
448
+ * @throws {GraphExecutionError} `GRAPH_REMOVE_DUPLICATES_FIELDS_REQUIRED` when
449
+ * the chosen mode has no field list, or
450
+ * `GRAPH_REMOVE_DUPLICATES_FIELD_MISSING` when selected fields are absent
451
+ * from every item.
452
+ */
453
+ function dedupeGraphItems(items, options = {}) {
454
+ const dotNotation = options.dotNotation !== false;
455
+ const compare = options.compare ?? "allFields";
456
+ let keys;
457
+ if (compare === "selectedFields") {
458
+ keys = prepareGraphFields(options.fieldsToCompare, "Fields To Compare");
459
+ if (keys.length === 0) {
460
+ throw new GraphExecutionError_js_1.GraphExecutionError("No fields specified to compare on", "GRAPH_REMOVE_DUPLICATES_FIELDS_REQUIRED");
461
+ }
462
+ const found = items.some((item) => keys.some((key) => (0, support_js_1.getGraphDataValue)(item, key, dotNotation) !== undefined));
463
+ if (!found) {
464
+ throw new GraphExecutionError_js_1.GraphExecutionError(`The fields '${keys.join(", ")}' are not present in any input item`, "GRAPH_REMOVE_DUPLICATES_FIELD_MISSING", { fields: keys });
465
+ }
466
+ }
467
+ else if (compare === "allFieldsExcept") {
468
+ const excluded = prepareGraphFields(options.fieldsToExclude, "Fields To Exclude");
469
+ if (excluded.length === 0) {
470
+ throw new GraphExecutionError_js_1.GraphExecutionError("No fields specified to exclude from comparison", "GRAPH_REMOVE_DUPLICATES_FIELDS_REQUIRED");
471
+ }
472
+ const all = new Set();
473
+ for (const item of items) {
474
+ for (const key of collectGraphFieldPaths(item, dotNotation)) {
475
+ all.add(key);
476
+ }
477
+ }
478
+ keys = Array.from(all).filter((key) => !excluded.includes(key));
479
+ }
480
+ else {
481
+ const all = new Set();
482
+ for (const item of items) {
483
+ for (const key of collectGraphFieldPaths(item, dotNotation)) {
484
+ all.add(key);
485
+ }
486
+ }
487
+ keys = Array.from(all);
488
+ }
489
+ const kept = [];
490
+ const discarded = [];
491
+ const seen = new Set();
492
+ for (const item of items) {
493
+ const signature = (0, support_js_1.isGraphDataRecord)(item)
494
+ ? stableGraphKey(keys.map((key) => (0, support_js_1.getGraphDataValue)(item, key, dotNotation)))
495
+ : stableGraphKey(item);
496
+ if (seen.has(signature)) {
497
+ discarded.push(item);
498
+ continue;
499
+ }
500
+ seen.add(signature);
501
+ kept.push(options.removeOtherFields
502
+ ? projectGraphRecord(item, keys, dotNotation)
503
+ : item);
504
+ }
505
+ return { kept, discarded };
506
+ }
507
+ const AGGREGATION_PREFIXES = {
508
+ append: "appended_",
509
+ average: "average_",
510
+ concatenate: "concatenated_",
511
+ count: "count_",
512
+ countUnique: "unique_count_",
513
+ max: "max_",
514
+ min: "min_",
515
+ sum: "sum_",
516
+ };
517
+ function summarizeIsEmpty(value) {
518
+ return value === undefined || value === null || value === "";
519
+ }
520
+ function summarizeAggregate(items, entry, dotNotation) {
521
+ const field = entry.field ?? "";
522
+ const read = (item) => field ? (0, support_js_1.getGraphDataValue)(item, field, dotNotation) : item;
523
+ const values = items.map(read);
524
+ const nonEmpty = entry.includeEmpty
525
+ ? values
526
+ : values.filter((value) => !summarizeIsEmpty(value));
527
+ switch (entry.aggregation) {
528
+ case "append":
529
+ return nonEmpty;
530
+ case "concatenate": {
531
+ const separator = entry.separator === "other"
532
+ ? (entry.customSeparator ?? "")
533
+ : (entry.separator ?? ",");
534
+ return nonEmpty
535
+ .map((value) => {
536
+ if (value === undefined)
537
+ return "undefined";
538
+ if (typeof value === "object")
539
+ return JSON.stringify(value);
540
+ return String(value);
541
+ })
542
+ .join(separator);
543
+ }
544
+ case "average": {
545
+ const numbers = nonEmpty.filter((value) => typeof value === "number" && Number.isFinite(value));
546
+ if (numbers.length === 0)
547
+ return null;
548
+ return numbers.reduce((total, value) => total + value, 0) / numbers.length;
549
+ }
550
+ case "sum": {
551
+ return nonEmpty
552
+ .filter((value) => typeof value === "number" && Number.isFinite(value))
553
+ .reduce((total, value) => total + value, 0);
554
+ }
555
+ case "min": {
556
+ let minimum;
557
+ for (const value of nonEmpty) {
558
+ if (value === undefined || value === null || value === "")
559
+ continue;
560
+ if (minimum === undefined ||
561
+ value < minimum) {
562
+ minimum = value;
563
+ }
564
+ }
565
+ return minimum ?? null;
566
+ }
567
+ case "max": {
568
+ let maximum;
569
+ for (const value of nonEmpty) {
570
+ if (value === undefined || value === null || value === "")
571
+ continue;
572
+ if (maximum === undefined ||
573
+ value > maximum) {
574
+ maximum = value;
575
+ }
576
+ }
577
+ return maximum ?? null;
578
+ }
579
+ case "countUnique":
580
+ return new Set(nonEmpty.map((value) => stableGraphKey(value))).size;
581
+ case "count":
582
+ default:
583
+ return nonEmpty.length;
584
+ }
585
+ }
586
+ function summarizeRecords(items, aggregations, dotNotation) {
587
+ const record = {};
588
+ for (const entry of aggregations) {
589
+ const field = entry.field ?? "";
590
+ const key = normalizeGraphFieldName(`${AGGREGATION_PREFIXES[entry.aggregation] ?? "count_"}${field}`);
591
+ (0, support_js_1.assertGraphDataSegment)(key, key);
592
+ record[key] = summarizeAggregate(items, entry, dotNotation);
593
+ }
594
+ return record;
595
+ }
596
+ function summarizeGroupKey(value) {
597
+ if (value === undefined)
598
+ return "undefined";
599
+ if (value === null)
600
+ return "null";
601
+ if (typeof value === "string")
602
+ return value;
603
+ if (typeof value === "number" ||
604
+ typeof value === "boolean" ||
605
+ typeof value === "bigint") {
606
+ return String(value);
607
+ }
608
+ return stableGraphKey(value);
609
+ }
610
+ function buildSummarizeGroups(items, fields, index, dotNotation, skipEmpty) {
611
+ if (index >= fields.length)
612
+ return [];
613
+ const field = fields[index];
614
+ const groups = new Map();
615
+ for (const item of items) {
616
+ let value = (0, support_js_1.getGraphDataValue)(item, field, dotNotation);
617
+ if (value && typeof value === "object")
618
+ value = JSON.stringify(value);
619
+ if (skipEmpty && typeof value !== "number" && !value)
620
+ continue;
621
+ const key = stableGraphKey(value);
622
+ const group = groups.get(key) ?? { value, items: [] };
623
+ group.items.push(item);
624
+ groups.set(key, group);
625
+ }
626
+ const last = index === fields.length - 1;
627
+ return Array.from(groups.values()).map((group) => ({
628
+ field,
629
+ value: group.value,
630
+ ...(last
631
+ ? { items: group.items }
632
+ : {
633
+ children: buildSummarizeGroups(group.items, fields, index + 1, dotNotation, skipEmpty),
634
+ }),
635
+ }));
636
+ }
637
+ /**
638
+ * Summarizes items by zero or more split fields.
639
+ *
640
+ * With no split fields it returns a single record. Otherwise it builds nested
641
+ * groups and emits either one record per leaf group (`separateItems`) or one
642
+ * nested record (`singleItem`). Unless `continueIfFieldNotFound` is set, a
643
+ * referenced field that is absent from every item fails the node.
644
+ *
645
+ * @param items - The items to summarize.
646
+ * @param aggregations - Aggregations to compute per group.
647
+ * @param options - Split fields, output format, empty-field and path options.
648
+ * @returns The summary records.
649
+ * @throws {GraphExecutionError} `GRAPH_SUMMARIZE_FIELD_NOT_FOUND` when a
650
+ * referenced field is absent from every item, or `GRAPH_DATA_UNSAFE_PATH`
651
+ * when a field-derived output or grouping key is a reserved
652
+ * prototype-pollution segment.
653
+ */
654
+ function summarizeGraphItems(items, aggregations, options = {}) {
655
+ const dotNotation = options.dotNotation !== false;
656
+ const splitFields = prepareGraphFields(options.fieldsToSplitBy, "Fields To Split By");
657
+ const outputFormat = options.outputFormat ?? "separateItems";
658
+ if (!options.continueIfFieldNotFound) {
659
+ for (const entry of aggregations) {
660
+ const field = entry.field ?? "";
661
+ if (!field)
662
+ continue;
663
+ const found = items.some((item) => (0, support_js_1.getGraphDataValue)(item, field, dotNotation) !== undefined);
664
+ if (!found) {
665
+ throw new GraphExecutionError_js_1.GraphExecutionError(`The field '${field}' does not exist in any items`, "GRAPH_SUMMARIZE_FIELD_NOT_FOUND", { field });
666
+ }
667
+ }
668
+ }
669
+ if (splitFields.length === 0) {
670
+ return [summarizeRecords(items, aggregations, dotNotation)];
671
+ }
672
+ const groups = buildSummarizeGroups(items, splitFields, splitFields.length > 0 ? 0 : -1, dotNotation, options.skipEmptySplitFields === true);
673
+ if (outputFormat === "singleItem") {
674
+ const record = summarizeRecords(items, aggregations, dotNotation);
675
+ const nest = (entries, target) => {
676
+ for (const entry of entries) {
677
+ const fieldKey = normalizeGraphFieldName(entry.field);
678
+ (0, support_js_1.assertGraphDataSegment)(fieldKey, fieldKey);
679
+ const byValue = target[fieldKey] ?? {};
680
+ target[fieldKey] = byValue;
681
+ const valueKey = summarizeGroupKey(entry.value);
682
+ (0, support_js_1.assertGraphDataSegment)(valueKey, valueKey);
683
+ if (entry.children && entry.children.length > 0) {
684
+ const child = byValue[valueKey] ?? {};
685
+ byValue[valueKey] = child;
686
+ nest(entry.children, child);
687
+ }
688
+ else if (entry.items) {
689
+ byValue[valueKey] = summarizeRecords(entry.items, aggregations, dotNotation);
690
+ }
691
+ }
692
+ };
693
+ nest(groups, record);
694
+ return [record];
695
+ }
696
+ const result = [];
697
+ const walk = (entries, fieldPrefix, valuePrefix) => {
698
+ for (const entry of entries) {
699
+ const fields = [...fieldPrefix, entry.field];
700
+ const values = [...valuePrefix, entry.value];
701
+ if (entry.children && entry.children.length > 0) {
702
+ walk(entry.children, fields, values);
703
+ }
704
+ else if (entry.items) {
705
+ const record = summarizeRecords(entry.items, aggregations, dotNotation);
706
+ fields.forEach((field, index) => {
707
+ const key = normalizeGraphFieldName(field);
708
+ (0, support_js_1.assertGraphDataSegment)(key, key);
709
+ record[key] = values[index];
710
+ });
711
+ result.push(record);
712
+ }
713
+ }
714
+ };
715
+ walk(groups, [], []);
716
+ return result;
717
+ }
718
+ //# sourceMappingURL=transform-utils.js.map
719
+ //# sourceMappingURL=transform-utils.cjs.map