@vertesia/workflow 0.42.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (406) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +24 -0
  3. package/bin/bundle-workflows.mjs +26 -0
  4. package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js +32 -0
  5. package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js.map +1 -0
  6. package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +66 -0
  7. package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +1 -0
  8. package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js +18 -0
  9. package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js.map +1 -0
  10. package/lib/cjs/activities/chunkDocument.js +79 -0
  11. package/lib/cjs/activities/chunkDocument.js.map +1 -0
  12. package/lib/cjs/activities/createDocumentFromOther.js +64 -0
  13. package/lib/cjs/activities/createDocumentFromOther.js.map +1 -0
  14. package/lib/cjs/activities/executeInteraction.js +135 -0
  15. package/lib/cjs/activities/executeInteraction.js.map +1 -0
  16. package/lib/cjs/activities/extractDocumentText.js +140 -0
  17. package/lib/cjs/activities/extractDocumentText.js.map +1 -0
  18. package/lib/cjs/activities/generateDocumentProperties.js +59 -0
  19. package/lib/cjs/activities/generateDocumentProperties.js.map +1 -0
  20. package/lib/cjs/activities/generateEmbeddings.js +292 -0
  21. package/lib/cjs/activities/generateEmbeddings.js.map +1 -0
  22. package/lib/cjs/activities/generateImageRendition.js +104 -0
  23. package/lib/cjs/activities/generateImageRendition.js.map +1 -0
  24. package/lib/cjs/activities/generateOrAssignContentType.js +103 -0
  25. package/lib/cjs/activities/generateOrAssignContentType.js.map +1 -0
  26. package/lib/cjs/activities/getObjectFromStore.js +20 -0
  27. package/lib/cjs/activities/getObjectFromStore.js.map +1 -0
  28. package/lib/cjs/activities/index.js +54 -0
  29. package/lib/cjs/activities/index.js.map +1 -0
  30. package/lib/cjs/activities/media/processPdfWithTextract.js +102 -0
  31. package/lib/cjs/activities/media/processPdfWithTextract.js.map +1 -0
  32. package/lib/cjs/activities/media/transcribeMediaWithGladia.js +51 -0
  33. package/lib/cjs/activities/media/transcribeMediaWithGladia.js.map +1 -0
  34. package/lib/cjs/activities/notifyWebhook.js +34 -0
  35. package/lib/cjs/activities/notifyWebhook.js.map +1 -0
  36. package/lib/cjs/activities/setDocumentStatus.js +15 -0
  37. package/lib/cjs/activities/setDocumentStatus.js.map +1 -0
  38. package/lib/cjs/conversion/TextractProcessor.js +416 -0
  39. package/lib/cjs/conversion/TextractProcessor.js.map +1 -0
  40. package/lib/cjs/conversion/image.js +22 -0
  41. package/lib/cjs/conversion/image.js.map +1 -0
  42. package/lib/cjs/conversion/mutool.js +147 -0
  43. package/lib/cjs/conversion/mutool.js.map +1 -0
  44. package/lib/cjs/conversion/pandoc.js +39 -0
  45. package/lib/cjs/conversion/pandoc.js.map +1 -0
  46. package/lib/cjs/conversion/pdf.js +13 -0
  47. package/lib/cjs/conversion/pdf.js.map +1 -0
  48. package/lib/cjs/dsl/conditions.js +81 -0
  49. package/lib/cjs/dsl/conditions.js.map +1 -0
  50. package/lib/cjs/dsl/dsl-workflow.js +223 -0
  51. package/lib/cjs/dsl/dsl-workflow.js.map +1 -0
  52. package/lib/cjs/dsl/projections.js +59 -0
  53. package/lib/cjs/dsl/projections.js.map +1 -0
  54. package/lib/cjs/dsl/setup/ActivityContext.js +96 -0
  55. package/lib/cjs/dsl/setup/ActivityContext.js.map +1 -0
  56. package/lib/cjs/dsl/setup/fetch/DataProvider.js +51 -0
  57. package/lib/cjs/dsl/setup/fetch/DataProvider.js.map +1 -0
  58. package/lib/cjs/dsl/setup/fetch/index.js +16 -0
  59. package/lib/cjs/dsl/setup/fetch/index.js.map +1 -0
  60. package/lib/cjs/dsl/setup/fetch/providers.js +67 -0
  61. package/lib/cjs/dsl/setup/fetch/providers.js.map +1 -0
  62. package/lib/cjs/dsl/test/test-child-workflow.js +10 -0
  63. package/lib/cjs/dsl/test/test-child-workflow.js.map +1 -0
  64. package/lib/cjs/dsl/validation.js +122 -0
  65. package/lib/cjs/dsl/validation.js.map +1 -0
  66. package/lib/cjs/dsl/vars.js +341 -0
  67. package/lib/cjs/dsl/vars.js.map +1 -0
  68. package/lib/cjs/dsl/walk.js +100 -0
  69. package/lib/cjs/dsl/walk.js.map +1 -0
  70. package/lib/cjs/errors.js +36 -0
  71. package/lib/cjs/errors.js.map +1 -0
  72. package/lib/cjs/index.js +43 -0
  73. package/lib/cjs/index.js.map +1 -0
  74. package/lib/cjs/iterative-generation/activities/extractToc.js +47 -0
  75. package/lib/cjs/iterative-generation/activities/extractToc.js.map +1 -0
  76. package/lib/cjs/iterative-generation/activities/finalizeOutput.js +69 -0
  77. package/lib/cjs/iterative-generation/activities/finalizeOutput.js.map +1 -0
  78. package/lib/cjs/iterative-generation/activities/generatePart.js +73 -0
  79. package/lib/cjs/iterative-generation/activities/generatePart.js.map +1 -0
  80. package/lib/cjs/iterative-generation/activities/generateToc.js +91 -0
  81. package/lib/cjs/iterative-generation/activities/generateToc.js.map +1 -0
  82. package/lib/cjs/iterative-generation/activities/index.js +12 -0
  83. package/lib/cjs/iterative-generation/activities/index.js.map +1 -0
  84. package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js +55 -0
  85. package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js.map +1 -0
  86. package/lib/cjs/iterative-generation/types.js +5 -0
  87. package/lib/cjs/iterative-generation/types.js.map +1 -0
  88. package/lib/cjs/iterative-generation/utils.js +118 -0
  89. package/lib/cjs/iterative-generation/utils.js.map +1 -0
  90. package/lib/cjs/package.json +3 -0
  91. package/lib/cjs/result-types.js +10 -0
  92. package/lib/cjs/result-types.js.map +1 -0
  93. package/lib/cjs/system/generateObjectText.js +89 -0
  94. package/lib/cjs/system/generateObjectText.js.map +1 -0
  95. package/lib/cjs/system/notifyWebhookWorkflow.js +52 -0
  96. package/lib/cjs/system/notifyWebhookWorkflow.js.map +1 -0
  97. package/lib/cjs/system/recalculateEmbeddingsWorkflow.js +37 -0
  98. package/lib/cjs/system/recalculateEmbeddingsWorkflow.js.map +1 -0
  99. package/lib/cjs/utils/auth.js +15 -0
  100. package/lib/cjs/utils/auth.js.map +1 -0
  101. package/lib/cjs/utils/blobs.js +63 -0
  102. package/lib/cjs/utils/blobs.js.map +1 -0
  103. package/lib/cjs/utils/client.js +25 -0
  104. package/lib/cjs/utils/client.js.map +1 -0
  105. package/lib/cjs/utils/expand-vars.js +33 -0
  106. package/lib/cjs/utils/expand-vars.js.map +1 -0
  107. package/lib/cjs/utils/memory.js +72 -0
  108. package/lib/cjs/utils/memory.js.map +1 -0
  109. package/lib/cjs/utils/tokens.js +38 -0
  110. package/lib/cjs/utils/tokens.js.map +1 -0
  111. package/lib/cjs/vars.js +20 -0
  112. package/lib/cjs/vars.js.map +1 -0
  113. package/lib/cjs/workflows.js +17 -0
  114. package/lib/cjs/workflows.js.map +1 -0
  115. package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js +29 -0
  116. package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js.map +1 -0
  117. package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +63 -0
  118. package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +1 -0
  119. package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js +15 -0
  120. package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js.map +1 -0
  121. package/lib/esm/activities/chunkDocument.js +76 -0
  122. package/lib/esm/activities/chunkDocument.js.map +1 -0
  123. package/lib/esm/activities/createDocumentFromOther.js +58 -0
  124. package/lib/esm/activities/createDocumentFromOther.js.map +1 -0
  125. package/lib/esm/activities/executeInteraction.js +131 -0
  126. package/lib/esm/activities/executeInteraction.js.map +1 -0
  127. package/lib/esm/activities/extractDocumentText.js +137 -0
  128. package/lib/esm/activities/extractDocumentText.js.map +1 -0
  129. package/lib/esm/activities/generateDocumentProperties.js +56 -0
  130. package/lib/esm/activities/generateDocumentProperties.js.map +1 -0
  131. package/lib/esm/activities/generateEmbeddings.js +256 -0
  132. package/lib/esm/activities/generateEmbeddings.js.map +1 -0
  133. package/lib/esm/activities/generateImageRendition.js +98 -0
  134. package/lib/esm/activities/generateImageRendition.js.map +1 -0
  135. package/lib/esm/activities/generateOrAssignContentType.js +100 -0
  136. package/lib/esm/activities/generateOrAssignContentType.js.map +1 -0
  137. package/lib/esm/activities/getObjectFromStore.js +17 -0
  138. package/lib/esm/activities/getObjectFromStore.js.map +1 -0
  139. package/lib/esm/activities/index.js +21 -0
  140. package/lib/esm/activities/index.js.map +1 -0
  141. package/lib/esm/activities/media/processPdfWithTextract.js +98 -0
  142. package/lib/esm/activities/media/processPdfWithTextract.js.map +1 -0
  143. package/lib/esm/activities/media/transcribeMediaWithGladia.js +48 -0
  144. package/lib/esm/activities/media/transcribeMediaWithGladia.js.map +1 -0
  145. package/lib/esm/activities/notifyWebhook.js +31 -0
  146. package/lib/esm/activities/notifyWebhook.js.map +1 -0
  147. package/lib/esm/activities/setDocumentStatus.js +12 -0
  148. package/lib/esm/activities/setDocumentStatus.js.map +1 -0
  149. package/lib/esm/conversion/TextractProcessor.js +409 -0
  150. package/lib/esm/conversion/TextractProcessor.js.map +1 -0
  151. package/lib/esm/conversion/image.js +16 -0
  152. package/lib/esm/conversion/image.js.map +1 -0
  153. package/lib/esm/conversion/mutool.js +139 -0
  154. package/lib/esm/conversion/mutool.js.map +1 -0
  155. package/lib/esm/conversion/pandoc.js +36 -0
  156. package/lib/esm/conversion/pandoc.js.map +1 -0
  157. package/lib/esm/conversion/pdf.js +7 -0
  158. package/lib/esm/conversion/pdf.js.map +1 -0
  159. package/lib/esm/dsl/conditions.js +75 -0
  160. package/lib/esm/dsl/conditions.js.map +1 -0
  161. package/lib/esm/dsl/dsl-workflow.js +216 -0
  162. package/lib/esm/dsl/dsl-workflow.js.map +1 -0
  163. package/lib/esm/dsl/projections.js +55 -0
  164. package/lib/esm/dsl/projections.js.map +1 -0
  165. package/lib/esm/dsl/setup/ActivityContext.js +91 -0
  166. package/lib/esm/dsl/setup/ActivityContext.js.map +1 -0
  167. package/lib/esm/dsl/setup/fetch/DataProvider.js +47 -0
  168. package/lib/esm/dsl/setup/fetch/DataProvider.js.map +1 -0
  169. package/lib/esm/dsl/setup/fetch/index.js +12 -0
  170. package/lib/esm/dsl/setup/fetch/index.js.map +1 -0
  171. package/lib/esm/dsl/setup/fetch/providers.js +61 -0
  172. package/lib/esm/dsl/setup/fetch/providers.js.map +1 -0
  173. package/lib/esm/dsl/test/test-child-workflow.js +5 -0
  174. package/lib/esm/dsl/test/test-child-workflow.js.map +1 -0
  175. package/lib/esm/dsl/validation.js +118 -0
  176. package/lib/esm/dsl/validation.js.map +1 -0
  177. package/lib/esm/dsl/vars.js +335 -0
  178. package/lib/esm/dsl/vars.js.map +1 -0
  179. package/lib/esm/dsl/walk.js +96 -0
  180. package/lib/esm/dsl/walk.js.map +1 -0
  181. package/lib/esm/errors.js +30 -0
  182. package/lib/esm/errors.js.map +1 -0
  183. package/lib/esm/index.js +25 -0
  184. package/lib/esm/index.js.map +1 -0
  185. package/lib/esm/iterative-generation/activities/extractToc.js +44 -0
  186. package/lib/esm/iterative-generation/activities/extractToc.js.map +1 -0
  187. package/lib/esm/iterative-generation/activities/finalizeOutput.js +66 -0
  188. package/lib/esm/iterative-generation/activities/finalizeOutput.js.map +1 -0
  189. package/lib/esm/iterative-generation/activities/generatePart.js +70 -0
  190. package/lib/esm/iterative-generation/activities/generatePart.js.map +1 -0
  191. package/lib/esm/iterative-generation/activities/generateToc.js +88 -0
  192. package/lib/esm/iterative-generation/activities/generateToc.js.map +1 -0
  193. package/lib/esm/iterative-generation/activities/index.js +5 -0
  194. package/lib/esm/iterative-generation/activities/index.js.map +1 -0
  195. package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js +52 -0
  196. package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js.map +1 -0
  197. package/lib/esm/iterative-generation/types.js +2 -0
  198. package/lib/esm/iterative-generation/types.js.map +1 -0
  199. package/lib/esm/iterative-generation/utils.js +109 -0
  200. package/lib/esm/iterative-generation/utils.js.map +1 -0
  201. package/lib/esm/result-types.js +7 -0
  202. package/lib/esm/result-types.js.map +1 -0
  203. package/lib/esm/system/generateObjectText.js +86 -0
  204. package/lib/esm/system/generateObjectText.js.map +1 -0
  205. package/lib/esm/system/notifyWebhookWorkflow.js +49 -0
  206. package/lib/esm/system/notifyWebhookWorkflow.js.map +1 -0
  207. package/lib/esm/system/recalculateEmbeddingsWorkflow.js +34 -0
  208. package/lib/esm/system/recalculateEmbeddingsWorkflow.js.map +1 -0
  209. package/lib/esm/utils/auth.js +8 -0
  210. package/lib/esm/utils/auth.js.map +1 -0
  211. package/lib/esm/utils/blobs.js +52 -0
  212. package/lib/esm/utils/blobs.js.map +1 -0
  213. package/lib/esm/utils/client.js +22 -0
  214. package/lib/esm/utils/client.js.map +1 -0
  215. package/lib/esm/utils/expand-vars.js +30 -0
  216. package/lib/esm/utils/expand-vars.js.map +1 -0
  217. package/lib/esm/utils/memory.js +60 -0
  218. package/lib/esm/utils/memory.js.map +1 -0
  219. package/lib/esm/utils/tokens.js +34 -0
  220. package/lib/esm/utils/tokens.js.map +1 -0
  221. package/lib/esm/vars.js +4 -0
  222. package/lib/esm/vars.js.map +1 -0
  223. package/lib/esm/workflows.js +9 -0
  224. package/lib/esm/workflows.js.map +1 -0
  225. package/lib/types/activities/advanced/createDocumentTypeFromInteractionRun.d.ts +17 -0
  226. package/lib/types/activities/advanced/createDocumentTypeFromInteractionRun.d.ts.map +1 -0
  227. package/lib/types/activities/advanced/createOrUpdateDocumentFromInteractionRun.d.ts +29 -0
  228. package/lib/types/activities/advanced/createOrUpdateDocumentFromInteractionRun.d.ts.map +1 -0
  229. package/lib/types/activities/advanced/updateDocumentFromInteractionRun.d.ts +19 -0
  230. package/lib/types/activities/advanced/updateDocumentFromInteractionRun.d.ts.map +1 -0
  231. package/lib/types/activities/chunkDocument.d.ts +18 -0
  232. package/lib/types/activities/chunkDocument.d.ts.map +1 -0
  233. package/lib/types/activities/createDocumentFromOther.d.ts +21 -0
  234. package/lib/types/activities/createDocumentFromOther.d.ts.map +1 -0
  235. package/lib/types/activities/executeInteraction.d.ts +40 -0
  236. package/lib/types/activities/executeInteraction.d.ts.map +1 -0
  237. package/lib/types/activities/extractDocumentText.d.ts +9 -0
  238. package/lib/types/activities/extractDocumentText.d.ts.map +1 -0
  239. package/lib/types/activities/generateDocumentProperties.d.ts +32 -0
  240. package/lib/types/activities/generateDocumentProperties.d.ts.map +1 -0
  241. package/lib/types/activities/generateEmbeddings.d.ts +49 -0
  242. package/lib/types/activities/generateEmbeddings.d.ts.map +1 -0
  243. package/lib/types/activities/generateImageRendition.d.ts +17 -0
  244. package/lib/types/activities/generateImageRendition.d.ts.map +1 -0
  245. package/lib/types/activities/generateOrAssignContentType.d.ts +44 -0
  246. package/lib/types/activities/generateOrAssignContentType.d.ts.map +1 -0
  247. package/lib/types/activities/getObjectFromStore.d.ts +14 -0
  248. package/lib/types/activities/getObjectFromStore.d.ts.map +1 -0
  249. package/lib/types/activities/index.d.ts +21 -0
  250. package/lib/types/activities/index.d.ts.map +1 -0
  251. package/lib/types/activities/media/processPdfWithTextract.d.ts +26 -0
  252. package/lib/types/activities/media/processPdfWithTextract.d.ts.map +1 -0
  253. package/lib/types/activities/media/transcribeMediaWithGladia.d.ts +14 -0
  254. package/lib/types/activities/media/transcribeMediaWithGladia.d.ts.map +1 -0
  255. package/lib/types/activities/notifyWebhook.d.ts +17 -0
  256. package/lib/types/activities/notifyWebhook.d.ts.map +1 -0
  257. package/lib/types/activities/setDocumentStatus.d.ts +15 -0
  258. package/lib/types/activities/setDocumentStatus.d.ts.map +1 -0
  259. package/lib/types/conversion/TextractProcessor.d.ts +45 -0
  260. package/lib/types/conversion/TextractProcessor.d.ts.map +1 -0
  261. package/lib/types/conversion/image.d.ts +9 -0
  262. package/lib/types/conversion/image.d.ts.map +1 -0
  263. package/lib/types/conversion/mutool.d.ts +19 -0
  264. package/lib/types/conversion/mutool.d.ts.map +1 -0
  265. package/lib/types/conversion/pandoc.d.ts +2 -0
  266. package/lib/types/conversion/pandoc.d.ts.map +1 -0
  267. package/lib/types/conversion/pdf.d.ts +2 -0
  268. package/lib/types/conversion/pdf.d.ts.map +1 -0
  269. package/lib/types/dsl/conditions.d.ts +2 -0
  270. package/lib/types/dsl/conditions.d.ts.map +1 -0
  271. package/lib/types/dsl/dsl-workflow.d.ts +5 -0
  272. package/lib/types/dsl/dsl-workflow.d.ts.map +1 -0
  273. package/lib/types/dsl/projections.d.ts +4 -0
  274. package/lib/types/dsl/projections.d.ts.map +1 -0
  275. package/lib/types/dsl/setup/ActivityContext.d.ts +14 -0
  276. package/lib/types/dsl/setup/ActivityContext.d.ts.map +1 -0
  277. package/lib/types/dsl/setup/fetch/DataProvider.d.ts +9 -0
  278. package/lib/types/dsl/setup/fetch/DataProvider.d.ts.map +1 -0
  279. package/lib/types/dsl/setup/fetch/index.d.ts +6 -0
  280. package/lib/types/dsl/setup/fetch/index.d.ts.map +1 -0
  281. package/lib/types/dsl/setup/fetch/providers.d.ts +25 -0
  282. package/lib/types/dsl/setup/fetch/providers.d.ts.map +1 -0
  283. package/lib/types/dsl/test/test-child-workflow.d.ts +4 -0
  284. package/lib/types/dsl/test/test-child-workflow.d.ts.map +1 -0
  285. package/lib/types/dsl/validation.d.ts +4 -0
  286. package/lib/types/dsl/validation.d.ts.map +1 -0
  287. package/lib/types/dsl/vars.d.ts +48 -0
  288. package/lib/types/dsl/vars.d.ts.map +1 -0
  289. package/lib/types/dsl/walk.d.ts +18 -0
  290. package/lib/types/dsl/walk.d.ts.map +1 -0
  291. package/lib/types/errors.d.ts +16 -0
  292. package/lib/types/errors.d.ts.map +1 -0
  293. package/lib/types/index.d.ts +24 -0
  294. package/lib/types/index.d.ts.map +1 -0
  295. package/lib/types/iterative-generation/activities/extractToc.d.ts +10 -0
  296. package/lib/types/iterative-generation/activities/extractToc.d.ts.map +1 -0
  297. package/lib/types/iterative-generation/activities/finalizeOutput.d.ts +3 -0
  298. package/lib/types/iterative-generation/activities/finalizeOutput.d.ts.map +1 -0
  299. package/lib/types/iterative-generation/activities/generatePart.d.ts +3 -0
  300. package/lib/types/iterative-generation/activities/generatePart.d.ts.map +1 -0
  301. package/lib/types/iterative-generation/activities/generateToc.d.ts +4 -0
  302. package/lib/types/iterative-generation/activities/generateToc.d.ts.map +1 -0
  303. package/lib/types/iterative-generation/activities/index.d.ts +5 -0
  304. package/lib/types/iterative-generation/activities/index.d.ts.map +1 -0
  305. package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts +3 -0
  306. package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts.map +1 -0
  307. package/lib/types/iterative-generation/types.d.ts +79 -0
  308. package/lib/types/iterative-generation/types.d.ts.map +1 -0
  309. package/lib/types/iterative-generation/utils.d.ts +27 -0
  310. package/lib/types/iterative-generation/utils.d.ts.map +1 -0
  311. package/lib/types/result-types.d.ts +22 -0
  312. package/lib/types/result-types.d.ts.map +1 -0
  313. package/lib/types/system/generateObjectText.d.ts +4 -0
  314. package/lib/types/system/generateObjectText.d.ts.map +1 -0
  315. package/lib/types/system/notifyWebhookWorkflow.d.ts +6 -0
  316. package/lib/types/system/notifyWebhookWorkflow.d.ts.map +1 -0
  317. package/lib/types/system/recalculateEmbeddingsWorkflow.d.ts +40 -0
  318. package/lib/types/system/recalculateEmbeddingsWorkflow.d.ts.map +1 -0
  319. package/lib/types/utils/auth.d.ts +4 -0
  320. package/lib/types/utils/auth.d.ts.map +1 -0
  321. package/lib/types/utils/blobs.d.ts +8 -0
  322. package/lib/types/utils/blobs.d.ts.map +1 -0
  323. package/lib/types/utils/client.d.ts +7 -0
  324. package/lib/types/utils/client.d.ts.map +1 -0
  325. package/lib/types/utils/expand-vars.d.ts +8 -0
  326. package/lib/types/utils/expand-vars.d.ts.map +1 -0
  327. package/lib/types/utils/memory.d.ts +12 -0
  328. package/lib/types/utils/memory.d.ts.map +1 -0
  329. package/lib/types/utils/tokens.d.ts +11 -0
  330. package/lib/types/utils/tokens.d.ts.map +1 -0
  331. package/lib/types/vars.d.ts +3 -0
  332. package/lib/types/vars.d.ts.map +1 -0
  333. package/lib/types/workflows.d.ts +9 -0
  334. package/lib/types/workflows.d.ts.map +1 -0
  335. package/lib/workflows-bundle.js +18394 -0
  336. package/package.json +109 -0
  337. package/src/activities/advanced/createDocumentTypeFromInteractionRun.ts +54 -0
  338. package/src/activities/advanced/createOrUpdateDocumentFromInteractionRun.ts +97 -0
  339. package/src/activities/advanced/updateDocumentFromInteractionRun.ts +34 -0
  340. package/src/activities/chunkDocument.ts +124 -0
  341. package/src/activities/createDocumentFromOther.ts +92 -0
  342. package/src/activities/executeInteraction.ts +191 -0
  343. package/src/activities/extractDocumentText.ts +174 -0
  344. package/src/activities/generateDocumentProperties.ts +93 -0
  345. package/src/activities/generateEmbeddings.ts +345 -0
  346. package/src/activities/generateImageRendition.ts +134 -0
  347. package/src/activities/generateOrAssignContentType.ts +152 -0
  348. package/src/activities/getObjectFromStore.ts +31 -0
  349. package/src/activities/index.ts +21 -0
  350. package/src/activities/media/processPdfWithTextract.ts +141 -0
  351. package/src/activities/media/transcribeMediaWithGladia.ts +83 -0
  352. package/src/activities/notifyWebhook.test.ts +32 -0
  353. package/src/activities/notifyWebhook.ts +51 -0
  354. package/src/activities/setDocumentStatus.ts +25 -0
  355. package/src/conversion/TextractProcessor.ts +505 -0
  356. package/src/conversion/image.test.ts +26 -0
  357. package/src/conversion/image.ts +22 -0
  358. package/src/conversion/mutool.test.ts +74 -0
  359. package/src/conversion/mutool.ts +180 -0
  360. package/src/conversion/pandoc.test.ts +22 -0
  361. package/src/conversion/pandoc.ts +44 -0
  362. package/src/conversion/pdf.test.ts +35 -0
  363. package/src/conversion/pdf.ts +8 -0
  364. package/src/dsl/conditions.ts +76 -0
  365. package/src/dsl/dsl-workflow.test.ts +58 -0
  366. package/src/dsl/dsl-workflow.ts +235 -0
  367. package/src/dsl/ms.d.ts +11 -0
  368. package/src/dsl/projections.test.ts +159 -0
  369. package/src/dsl/projections.ts +72 -0
  370. package/src/dsl/setup/ActivityContext.ts +106 -0
  371. package/src/dsl/setup/fetch/DataProvider.ts +45 -0
  372. package/src/dsl/setup/fetch/index.ts +19 -0
  373. package/src/dsl/setup/fetch/providers.ts +67 -0
  374. package/src/dsl/test/test-child-workflow.ts +6 -0
  375. package/src/dsl/validation.test.ts +257 -0
  376. package/src/dsl/validation.ts +125 -0
  377. package/src/dsl/vars.test.ts +245 -0
  378. package/src/dsl/vars.ts +340 -0
  379. package/src/dsl/walk.test.ts +81 -0
  380. package/src/dsl/walk.ts +103 -0
  381. package/src/dsl/workflow-exec-child.test.ts +182 -0
  382. package/src/dsl/workflow-fetch.test.ts +135 -0
  383. package/src/dsl/workflow-import.test.ts +89 -0
  384. package/src/dsl/workflow.test.ts +110 -0
  385. package/src/errors.ts +24 -0
  386. package/src/index.ts +27 -0
  387. package/src/iterative-generation/activities/extractToc.ts +49 -0
  388. package/src/iterative-generation/activities/finalizeOutput.ts +77 -0
  389. package/src/iterative-generation/activities/generatePart.ts +82 -0
  390. package/src/iterative-generation/activities/generateToc.ts +98 -0
  391. package/src/iterative-generation/activities/index.ts +4 -0
  392. package/src/iterative-generation/iterativeGenerationWorkflow.ts +67 -0
  393. package/src/iterative-generation/types.ts +99 -0
  394. package/src/iterative-generation/utils.ts +123 -0
  395. package/src/result-types.ts +25 -0
  396. package/src/system/generateObjectText.ts +109 -0
  397. package/src/system/notifyWebhookWorkflow.ts +64 -0
  398. package/src/system/recalculateEmbeddingsWorkflow.ts +46 -0
  399. package/src/utils/auth.ts +10 -0
  400. package/src/utils/blobs.ts +58 -0
  401. package/src/utils/client.ts +31 -0
  402. package/src/utils/expand-vars.ts +31 -0
  403. package/src/utils/memory.ts +66 -0
  404. package/src/utils/tokens.ts +44 -0
  405. package/src/vars.ts +3 -0
  406. package/src/workflows.ts +9 -0
@@ -0,0 +1,340 @@
1
+ import { ImportSpec } from "@vertesia/common";
2
+ import { matchCondition } from "./conditions.js";
3
+ import { ObjectKey, ObjectVisitor, ObjectWalker } from "./walk.js";
4
+
5
+ const FALLBACK_VALUE_SEP = "??";
6
+
7
+ function decodeLiteralValue(value: string) {
8
+ if (value.startsWith("'") && value.endsWith("'")) {
9
+ value = '"' + value.slice(1, -1).replace(/(?<!\\)"/g, '\\"') + '"'
10
+ }
11
+ return JSON.parse(value);
12
+ }
13
+
14
+ export function splitPath(path: string) {
15
+ if (path.indexOf('[') > -1) { // support array like paths
16
+ path = path.replace(/\[(\d+)\]/g, '.$1');
17
+ }
18
+ return path.split('.');
19
+ }
20
+
21
+ /**
22
+ * Get the property named by "name" of the given object
23
+ * If an array is idnexed using a string key then a map is done and an array with the content of the properties with that name are returned
24
+ * Ex: docs.text => will return an array of text properties of the docs array
25
+ * @param object the obejct
26
+ * @param name the name of the property.
27
+ * @returns the property value
28
+ */
29
+ function _prop(object: any, name: string) {
30
+ if (object === undefined) {
31
+ return undefined;
32
+ }
33
+ object = _valueOf(object); // resolve Value objects
34
+ if (Array.isArray(object)) {
35
+ const index = +name;
36
+ if (isNaN(index)) {
37
+ // map array to property
38
+ return object.map(item => item[name]);
39
+ } else {
40
+ return _valueOf(object[index]);
41
+ }
42
+ } else {
43
+ return _valueOf(object[name]);
44
+ }
45
+
46
+ }
47
+
48
+ function _valueOf(value: any) {
49
+ return value instanceof Value ? value.value : value;
50
+ }
51
+
52
+ export function resolveField(object: any, path: string[]) {
53
+ let p = object as any;
54
+ if (!p) return p;
55
+ if (!path.length) return _valueOf(p);
56
+ const last = path.length - 1;
57
+ for (let i = 0; i < last; i++) {
58
+ p = _prop(p, path[i])
59
+ if (!p) {
60
+ return undefined;
61
+ }
62
+ }
63
+ return _prop(p, path[last]);
64
+ }
65
+
66
+ abstract class Value<T = any> {
67
+ abstract value: T;
68
+ abstract stringify(): string;
69
+ }
70
+ class LiteralValue<T = any> extends Value<T> {
71
+ constructor(public value: T) {
72
+ super();
73
+ }
74
+ stringify() {
75
+ return String(this.value);
76
+ }
77
+ }
78
+
79
+ class RefValue extends Value {
80
+ constructor(public vars: Vars, public path: string[], public defaultValue?: any) {
81
+ super();
82
+ }
83
+ get value() {
84
+ const v = this.vars.getValueFromPath(this.path);
85
+ if (v === undefined) {
86
+ if (this.defaultValue !== undefined) {
87
+ return this.defaultValue;
88
+ } else {
89
+ return this.vars.preserveRefs ? this.stringify() : undefined;
90
+ }
91
+ } else {
92
+ return v;
93
+ }
94
+ }
95
+
96
+ stringify() {
97
+ return "${" + this.path.join('.') + "}";
98
+ }
99
+ }
100
+
101
+ class ExprValue extends Value {
102
+ constructor(public vars: Vars, public parts: Value[]) {
103
+ super();
104
+ }
105
+ get value() {
106
+ const out: string[] = [];
107
+ for (const seg of this.parts) {
108
+ const v = seg.value;
109
+ if (v !== undefined) {
110
+ out.push(String(seg.value));
111
+ }
112
+ }
113
+ return out.join('');
114
+ }
115
+
116
+ stringify() {
117
+ const out = [];
118
+ for (const seg of this.parts) {
119
+ out.push(seg.stringify());
120
+ }
121
+ return "${" + out.join('') + "}";
122
+ }
123
+
124
+ }
125
+
126
+
127
+ export class Vars {
128
+ map: Record<string, any>;
129
+ /**
130
+ * This property is used when resolving params. It contains the list of references that should not be resolved to their value
131
+ * but instead they need to return the string representation of the expression to eb able to regenrate another Vars instance with the same expression
132
+ */
133
+ //TODO this feature is no more used - it was replaced by importVars so we can now delete `preserveRefs`
134
+ preserveRefs: Set<string> | undefined;
135
+
136
+ constructor(vars?: Record<string, any>) {
137
+ this.map = vars ? this.parse(vars) : {};
138
+ }
139
+
140
+ parse(vars: Record<string, any>): Record<string, any> {
141
+ return new ObjectWalker().map(vars, (_key, value) => {
142
+ if (typeof value === 'string') {
143
+ return this.createValue(this, value);
144
+ } else {
145
+ return value;
146
+ }
147
+ });
148
+ }
149
+
150
+ load(vars: Record<string, any>) {
151
+ const toAppend = this.parse(vars);
152
+ this.map = Object.assign(this.map, toAppend);
153
+ return this;
154
+ }
155
+
156
+ /**
157
+ * Set a literal value (canboot set a ref)
158
+ * To add refs use `append()`
159
+ * @param name
160
+ * @param value
161
+ */
162
+ setValue(name: string, value: any) {
163
+ this.map[name] = value;
164
+ }
165
+
166
+ getValue(path: string) {
167
+ return resolveField(this.map, splitPath(path));
168
+ }
169
+
170
+ getValueFromPath(path: string[]) {
171
+ return resolveField(this.map, path);
172
+ }
173
+
174
+ has(name: string) {
175
+ return this.map[name] !== undefined;
176
+ }
177
+
178
+ match(match: Record<string, any>) {
179
+ for (const name of Object.keys(match)) {
180
+ const value = this.getValue(name);
181
+ if (!matchCondition(value, match[name])) {
182
+ return false;
183
+ }
184
+ }
185
+ return true;
186
+ }
187
+
188
+ resolveParams(params: Record<string, any>, preserveRefs?: Set<string>) {
189
+ this.preserveRefs = preserveRefs;
190
+ try {
191
+ return new ObjectWalker().map(params, (_key, value) => {
192
+ if (typeof value === 'string') {
193
+ const v = this.createValue(this, value)
194
+ return v instanceof Value ? v.value : v;
195
+ } else {
196
+ return value;
197
+ }
198
+ });
199
+ } finally {
200
+ this.preserveRefs = undefined;
201
+ }
202
+ }
203
+
204
+ resolve(preserveRefs?: Set<string>): Record<string, any> {
205
+ function map(_key: ObjectKey, value: any) {
206
+ if (value instanceof Value) {
207
+ const v = value.value;
208
+ if (v && typeof v === 'object') {
209
+ if (Array.isArray(v) || v.constructor === Object) {
210
+ // an array or plain object - recurse into the
211
+ // value to find other nested Ref values if any...
212
+ return new ObjectWalker().map(v, map);
213
+ }
214
+ } else {
215
+ return v;
216
+ }
217
+ } else {
218
+ return value
219
+ }
220
+ }
221
+ try {
222
+ this.preserveRefs = preserveRefs;
223
+ return new ObjectWalker().map(this.map, map);
224
+ } finally {
225
+ this.preserveRefs = undefined;
226
+ }
227
+ }
228
+
229
+ createRefValue(ref: string) {
230
+ const index = ref.indexOf(FALLBACK_VALUE_SEP);
231
+ let defaultValue: any;
232
+ if (index > -1) {
233
+ defaultValue = decodeLiteralValue(ref.substring(index + FALLBACK_VALUE_SEP.length).trim());
234
+ ref = ref.substring(0, index).trim();
235
+ }
236
+ if (ref === '.' || ref.indexOf('..') > -1) {
237
+ throw new Error("Invalid variable reference: " + ref)
238
+ }
239
+ return new RefValue(this, splitPath(ref), defaultValue);
240
+ }
241
+
242
+ createValue(vars: Vars, obj: any) {
243
+ if (!obj) {
244
+ return obj;
245
+ }
246
+ if (typeof obj === 'string') {
247
+ if (obj.indexOf('${') > -1) {
248
+ const segments = obj.split(/(\${[^}]+})/);
249
+ if (segments.length === 1) {
250
+ const seg = segments[0];
251
+ return this.createRefValue(seg.substring(2, seg.length - 1));
252
+ }
253
+ const parts: Value[] = [];
254
+ for (const seg of segments) {
255
+ if (seg === '') continue;
256
+ if (seg.startsWith('${') && seg.endsWith('}')) {
257
+ parts.push(this.createRefValue(seg.substring(2, seg.length - 1)));
258
+ } else {
259
+ parts.push(new LiteralValue(seg));
260
+ }
261
+ }
262
+ if (parts.length === 1) {
263
+ return parts[0];
264
+ } else {
265
+ return new ExprValue(vars, parts);
266
+ }
267
+ } else {
268
+ return obj;
269
+ }
270
+ } else {
271
+ return obj;
272
+ }
273
+ }
274
+
275
+ createImportVars(importSpec: ImportSpec | undefined) {
276
+ if (!importSpec || importSpec.length === 0) {
277
+ return {};
278
+ }
279
+ const result: Record<string, any> = {};
280
+
281
+ for (const importVar of importSpec) {
282
+ if (typeof importVar === "string") {
283
+ addImportVar(importVar, undefined, this, result);
284
+ } else {
285
+ for (const key of Object.keys(importVar)) {
286
+ addImportVar(importVar[key], key, this, result);
287
+ }
288
+ }
289
+ }
290
+ return result;
291
+ }
292
+
293
+ getUnknownReferences(obj: any) {
294
+ const visitor = new UnknownRefrencesVisitor(this);
295
+ new ObjectWalker().walk(obj, visitor);
296
+ return visitor.result;
297
+ }
298
+ }
299
+
300
+ function addImportVar(varPath: string, asName: string | undefined, vars: Vars, result: Record<string, any>) {
301
+ let isRequired = false;
302
+ if (varPath.endsWith("!")) {
303
+ isRequired = true;
304
+ varPath = varPath.slice(0, -1);
305
+ }
306
+ let value = vars.getValue(varPath);
307
+ if (value === undefined && isRequired) {
308
+ throw new Error(`Import variable ${varPath} is required but not found`);
309
+ }
310
+ result[asName || varPath] = value;
311
+ }
312
+
313
+
314
+ class UnknownRefrencesVisitor implements ObjectVisitor {
315
+
316
+ result: { name: string, expression: string }[] = [];
317
+
318
+ constructor(public vars: Vars) {
319
+ }
320
+
321
+ onValue(_key: ObjectKey, value: any) {
322
+ const vars = this.vars;
323
+ if (typeof value === "string") {
324
+ const v = vars.createValue(vars, value);
325
+ if (v instanceof ExprValue) {
326
+ for (const p of v.parts) {
327
+ if (p instanceof RefValue) {
328
+ if (!vars.has(p.path[0])) {
329
+ this.result.push({ name: p.path.join('.'), expression: p.stringify() });
330
+ }
331
+ }
332
+ }
333
+ } else if (v instanceof RefValue) {
334
+ if (!vars.has(v.path[0])) {
335
+ this.result.push({ name: v.path.join('.'), expression: v.stringify() });
336
+ }
337
+ }
338
+ }
339
+ }
340
+ }
@@ -0,0 +1,81 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { ObjectWalker } from "./walk.ts";
3
+
4
+ describe('walk object', () => {
5
+
6
+ test('find string values', () => {
7
+ const obj = {
8
+ name: "foo",
9
+ age: 42,
10
+ children: [{
11
+ name: "bar",
12
+ age: 12,
13
+ },
14
+ {
15
+ name: "baz",
16
+ age: 15,
17
+ }],
18
+ folder: {
19
+ subfolder: {
20
+ name: "file",
21
+ }
22
+ }
23
+ }
24
+ const values = ["foo", "bar", "baz", "file"].sort().join(',');
25
+ const found: string[] = [];
26
+ new ObjectWalker().walk(obj, {
27
+ onValue(key, value) {
28
+ if (typeof value === "string") {
29
+ found.push(value);
30
+ }
31
+ }
32
+ })
33
+ expect(found.sort().join(',')).toBe(values);
34
+ })
35
+
36
+ test('map numbers to string values', () => {
37
+ const obj = {
38
+ name: "foo",
39
+ age: 42,
40
+ children: [{
41
+ name: "bar",
42
+ age: 12,
43
+ },
44
+ {
45
+ name: "baz",
46
+ age: 15,
47
+ }],
48
+ folder: {
49
+ subfolder: {
50
+ name: 123,
51
+ }
52
+ }
53
+ }
54
+ const r = new ObjectWalker().map(obj, (_key, value) => {
55
+ if (typeof value === "number") {
56
+ return String(value)
57
+ }
58
+ return value;
59
+ });
60
+ expect(r.age).toBe("42");
61
+ expect(r.children[0].age).toBe("12");
62
+ expect(r.children[1].age).toBe("15");
63
+ expect(r.folder.subfolder.name).toBe("123");
64
+ })
65
+
66
+ test('map numbers in an array to string values', () => {
67
+ const obj = [123, { x: 1 }, { y: 2 }, { z: 3 }]
68
+ const r = new ObjectWalker().map(obj, (_key, value) => {
69
+ if (typeof value === "number") {
70
+ return String(value)
71
+ }
72
+ return value;
73
+ });
74
+ expect(r.length).toBe(4);
75
+ expect(r[0]).toBe("123");
76
+ expect(r[1].x).toBe("1");
77
+ expect(r[2].y).toBe("2");
78
+ expect(r[3].z).toBe("3");
79
+ })
80
+
81
+ })
@@ -0,0 +1,103 @@
1
+
2
+ export type ObjectKey = string | number | undefined;
3
+ export interface ObjectVisitor {
4
+ onStartObject?: (key: ObjectKey, value: any) => void;
5
+ onEndObject?: (key: ObjectKey, value: any) => void;
6
+ onStartIteration?: (key: ObjectKey, value: Iterable<any>) => void;
7
+ onEndIteration?: (key: ObjectKey, value: Iterable<any>) => void;
8
+ onValue?: (key: ObjectKey, value: any) => void;
9
+ }
10
+
11
+ export class ObjectWalker {
12
+ supportIterators = false; // only array are supported by default
13
+ constructor(supportIterators = false) {
14
+ this.supportIterators = supportIterators;
15
+ }
16
+ walk(obj: any, visitor: ObjectVisitor) {
17
+ this._walk(undefined, obj, visitor);
18
+ }
19
+ _walk(key: ObjectKey, obj: any, visitor: ObjectVisitor) {
20
+ const type = typeof obj;
21
+ if (!obj || type !== 'object' || obj instanceof Date) {
22
+ visitor.onValue && visitor.onValue(key, obj);
23
+ } else if (Array.isArray(obj)) {
24
+ this._walkIterable(key, obj, visitor);
25
+ } else if (this.supportIterators && obj[Symbol.iterator] === 'function') {
26
+ this._walkIterable(key, obj, visitor);
27
+ } else if (obj.constructor === Object) { // a plain object
28
+ this._walkObject(key, obj, visitor);
29
+ } else { // a random object - we treat it as a value
30
+ visitor.onValue && visitor.onValue(key, obj);
31
+ }
32
+ }
33
+
34
+ _walkIterable(key: ObjectKey, obj: any, visitor: ObjectVisitor) {
35
+ visitor.onStartIteration && visitor.onStartIteration(key, obj);
36
+ let i = 0;
37
+ for (const value of obj) {
38
+ this._walk(i++, value, visitor);
39
+ }
40
+ visitor.onEndIteration && visitor.onEndIteration(key, obj);
41
+ }
42
+
43
+ _walkObject(key: ObjectKey, obj: any, visitor: ObjectVisitor) {
44
+ visitor.onStartObject && visitor.onStartObject(key, obj);
45
+ for (const k of Object.keys(obj)) {
46
+ this._walk(k, obj[k], visitor);
47
+ }
48
+ visitor.onEndObject && visitor.onEndObject(key, obj);
49
+ }
50
+
51
+ map(obj: any, mapFn: (key: ObjectKey, value: any) => any) {
52
+ const visitor = new MapVisitor(mapFn);
53
+ this.walk(obj, visitor);
54
+ return visitor.result;
55
+ }
56
+ }
57
+
58
+ class MapVisitor implements ObjectVisitor {
59
+ result: any;
60
+ current: any;
61
+ stack: any[] = [];
62
+ constructor(private mapFn: (key: ObjectKey, value: any) => any) { }
63
+
64
+ onStartObject(key: ObjectKey) {
65
+ if (key === undefined) {
66
+ this.result = {};
67
+ this.current = this.result;
68
+ } else {
69
+ this.stack.push(this.current);
70
+ const obj = {};
71
+ this.current[key] = obj;
72
+ this.current = obj;
73
+ }
74
+ }
75
+ onEndObject() {
76
+ this.current = this.stack.pop();
77
+ }
78
+
79
+ onStartIteration(key: ObjectKey) {
80
+ if (key === undefined) {
81
+ this.result = [];
82
+ this.current = this.result;
83
+ } else {
84
+ this.stack.push(this.current);
85
+ const ar: any[] = [];
86
+ this.current[key] = ar;
87
+ this.current = ar;
88
+ }
89
+ }
90
+
91
+ onEndIteration() {
92
+ this.current = this.stack.pop();
93
+ }
94
+
95
+ onValue(key: ObjectKey, value: any) {
96
+ const r = this.mapFn(key, value);
97
+ if (key === undefined) {
98
+ this.result = r;
99
+ } else if (r !== undefined) {
100
+ this.current[key] = r;
101
+ }
102
+ }
103
+ }
@@ -0,0 +1,182 @@
1
+ import { ContentEventName, DSLActivityExecutionPayload, DSLWorkflowExecutionPayload, DSLWorkflowStep } from '@vertesia/common';
2
+ import { TestWorkflowEnvironment } from '@temporalio/testing';
3
+ import { Worker } from '@temporalio/worker';
4
+ import { afterAll, beforeAll, describe, expect, test } from 'vitest';
5
+ import { dslWorkflow } from './dsl-workflow.js';
6
+ import { setupActivity } from './setup/ActivityContext.js';
7
+
8
+ async function sayHelloFromParent(payload: DSLActivityExecutionPayload) {
9
+ const { params } = await setupActivity(payload);
10
+ return `Parent: Hello, ${params.name}!`;
11
+ }
12
+
13
+ async function sayHelloFromDSLChild(payload: DSLActivityExecutionPayload) {
14
+ const { params } = await setupActivity(payload);
15
+ return `DSL Child: Hello, ${params.name}!`;
16
+ }
17
+
18
+ async function prepareResult(payload: DSLActivityExecutionPayload) {
19
+ const { params } = await setupActivity(payload);
20
+ return [params.parent, params.child]
21
+ }
22
+
23
+ const steps1: DSLWorkflowStep[] = [
24
+ {
25
+ type: 'activity',
26
+ name: 'sayHelloFromParent',
27
+ output: 'parent',
28
+ import: ["name"],
29
+ },
30
+ {
31
+ type: 'workflow',
32
+ name: 'testChildWorkflow',
33
+ output: 'child',
34
+ },
35
+ {
36
+ type: 'activity',
37
+ name: 'prepareResult',
38
+ import: ["parent", "child"],
39
+ output: 'result',
40
+ }
41
+ ]
42
+
43
+ const childSteps: DSLWorkflowStep[] = [
44
+ {
45
+ type: 'activity',
46
+ name: 'sayHelloFromDSLChild',
47
+ output: 'result',
48
+ import: ["name"],
49
+ },
50
+ ]
51
+
52
+ const steps2: DSLWorkflowStep[] = [
53
+ {
54
+ type: 'activity',
55
+ name: 'sayHelloFromParent',
56
+ output: 'parent',
57
+ import: ["name"],
58
+ },
59
+ {
60
+ type: 'workflow',
61
+ name: 'dslWorkflow',
62
+ output: 'child',
63
+ spec: {
64
+ name: 'testChildWorkflow',
65
+ steps: childSteps,
66
+ vars: {}
67
+ }
68
+ },
69
+ {
70
+ type: 'activity',
71
+ name: 'prepareResult',
72
+ import: ["parent", "child"],
73
+ output: 'result',
74
+ }
75
+ ]
76
+
77
+
78
+ // ========== test env setup ==========
79
+
80
+
81
+ describe('DSL Workflow with chld workflows', () => {
82
+
83
+ let testEnv: TestWorkflowEnvironment;
84
+
85
+ beforeAll(async () => {
86
+ testEnv = await TestWorkflowEnvironment.createLocal();
87
+ });
88
+
89
+ afterAll(async () => {
90
+ await testEnv?.teardown();
91
+ });
92
+
93
+ test('execute child workflow', async () => {
94
+ const { client, nativeConnection } = testEnv;
95
+ const taskQueue = 'test';
96
+
97
+ const name = 'Foo';
98
+
99
+ const worker = await Worker.create({
100
+ connection: nativeConnection,
101
+ taskQueue,
102
+ workflowsPath: new URL("./test/test-child-workflow.ts", import.meta.url).pathname,
103
+ activities: { sayHelloFromParent, prepareResult },
104
+ });
105
+
106
+ const payload: DSLWorkflowExecutionPayload = {
107
+ event: ContentEventName.create,
108
+ objectIds: ['123'],
109
+ vars: {},
110
+ account_id: '123',
111
+ project_id: '123',
112
+ timestamp: Date.now(),
113
+ wf_rule_name: 'test',
114
+ auth_token: 'test',
115
+ config: {
116
+ studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
117
+ store_url: process.env.CP_STODRE_URL || "http://localhost:8082",
118
+ },
119
+ workflow: {
120
+ steps: steps1,
121
+ vars: {
122
+ name,
123
+ },
124
+ name: 'test',
125
+ }
126
+ }
127
+
128
+ let result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
129
+ args: [payload],
130
+ workflowId: 'test',
131
+ taskQueue,
132
+ }));
133
+
134
+ expect(result).toEqual([`Parent: Hello, ${name}!`, `Child: Hello, ${name}!`]);
135
+
136
+ });
137
+
138
+ test('execute DSL child workflow', async () => {
139
+ const { client, nativeConnection } = testEnv;
140
+ const taskQueue = 'test';
141
+
142
+ const name = 'Bar';
143
+
144
+ const worker = await Worker.create({
145
+ connection: nativeConnection,
146
+ taskQueue,
147
+ workflowsPath: new URL("./test/test-child-workflow.ts", import.meta.url).pathname,
148
+ activities: { sayHelloFromParent, prepareResult, sayHelloFromDSLChild },
149
+ });
150
+
151
+ const payload: DSLWorkflowExecutionPayload = {
152
+ event: ContentEventName.create,
153
+ objectIds: ['123'],
154
+ vars: {},
155
+ account_id: '123',
156
+ project_id: '123',
157
+ timestamp: Date.now(),
158
+ wf_rule_name: 'test',
159
+ auth_token: 'test',
160
+ config: {
161
+ studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
162
+ store_url: process.env.CP_STODRE_URL || "http://localhost:8082",
163
+ },
164
+ workflow: {
165
+ steps: steps2,
166
+ vars: {
167
+ name,
168
+ },
169
+ name: 'test',
170
+ }
171
+ }
172
+
173
+ let result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
174
+ args: [payload],
175
+ workflowId: 'test',
176
+ taskQueue,
177
+ }));
178
+
179
+ expect(result).toEqual([`Parent: Hello, ${name}!`, `DSL Child: Hello, ${name}!`]);
180
+
181
+ });
182
+ });