@ductape/sdk 0.1.8 → 0.1.10

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 (1000) hide show
  1. package/dist/agents/agent-context.d.ts +100 -0
  2. package/dist/agents/agent-context.js +604 -0
  3. package/dist/agents/agent-context.js.map +1 -0
  4. package/dist/agents/agent-executor.d.ts +180 -0
  5. package/dist/agents/agent-executor.js +715 -0
  6. package/dist/agents/agent-executor.js.map +1 -0
  7. package/dist/agents/agents.service.d.ts +310 -0
  8. package/dist/agents/agents.service.js +1255 -0
  9. package/dist/agents/agents.service.js.map +1 -0
  10. package/dist/agents/index.d.ts +55 -0
  11. package/dist/agents/index.js +110 -0
  12. package/dist/agents/index.js.map +1 -0
  13. package/dist/agents/memory-manager.d.ts +182 -0
  14. package/dist/agents/memory-manager.js +383 -0
  15. package/dist/agents/memory-manager.js.map +1 -0
  16. package/dist/agents/tool-registry.d.ts +141 -0
  17. package/dist/agents/tool-registry.js +355 -0
  18. package/dist/agents/tool-registry.js.map +1 -0
  19. package/dist/agents/types/agents.types.d.ts +1240 -0
  20. package/dist/agents/types/agents.types.js +12 -0
  21. package/dist/agents/types/agents.types.js.map +1 -0
  22. package/dist/agents/types/index.d.ts +6 -0
  23. package/dist/agents/types/index.js +23 -0
  24. package/dist/agents/types/index.js.map +1 -0
  25. package/dist/agents/vector-store-adapter.d.ts +108 -0
  26. package/dist/agents/vector-store-adapter.js +213 -0
  27. package/dist/agents/vector-store-adapter.js.map +1 -0
  28. package/dist/api/services/appApi.service.d.ts +78 -0
  29. package/dist/api/services/appApi.service.js +303 -0
  30. package/dist/api/services/appApi.service.js.map +1 -0
  31. package/dist/api/services/cloudApi.service.d.ts +31 -0
  32. package/dist/api/services/cloudApi.service.js +103 -0
  33. package/dist/api/services/cloudApi.service.js.map +1 -0
  34. package/dist/api/services/logsApi.service.d.ts +62 -0
  35. package/dist/api/services/logsApi.service.js +67 -0
  36. package/dist/api/services/logsApi.service.js.map +1 -0
  37. package/dist/api/services/pricingApi.service.d.ts +10 -0
  38. package/dist/api/services/pricingApi.service.js +34 -0
  39. package/dist/api/services/pricingApi.service.js.map +1 -0
  40. package/dist/api/services/processorApi.service.d.ts +927 -0
  41. package/dist/api/services/processorApi.service.js +787 -0
  42. package/dist/api/services/processorApi.service.js.map +1 -0
  43. package/dist/api/services/productsApi.service.d.ts +167 -0
  44. package/dist/api/services/productsApi.service.js +293 -0
  45. package/dist/api/services/productsApi.service.js.map +1 -0
  46. package/dist/api/services/resilienceApi.service.d.ts +106 -0
  47. package/dist/api/services/resilienceApi.service.js +224 -0
  48. package/dist/api/services/resilienceApi.service.js.map +1 -0
  49. package/dist/api/services/secretsApi.service.d.ts +51 -0
  50. package/dist/api/services/secretsApi.service.js +126 -0
  51. package/dist/api/services/secretsApi.service.js.map +1 -0
  52. package/dist/api/services/userApi.service.d.ts +10 -0
  53. package/dist/api/services/userApi.service.js +20 -0
  54. package/dist/api/services/userApi.service.js.map +1 -0
  55. package/dist/api/services/webhooksApi.service.d.ts +14 -0
  56. package/dist/api/services/webhooksApi.service.js +65 -0
  57. package/dist/api/services/webhooksApi.service.js.map +1 -0
  58. package/dist/api/services/workflowApi.service.d.ts +199 -0
  59. package/dist/api/services/workflowApi.service.js +201 -0
  60. package/dist/api/services/workflowApi.service.js.map +1 -0
  61. package/dist/api/services/workspaceApi.service.d.ts +20 -0
  62. package/dist/api/services/workspaceApi.service.js +54 -0
  63. package/dist/api/services/workspaceApi.service.js.map +1 -0
  64. package/dist/api/urls.d.ts +145 -0
  65. package/dist/api/urls.js +195 -0
  66. package/dist/api/urls.js.map +1 -0
  67. package/dist/api/utils/auth.utils.d.ts +10 -0
  68. package/dist/api/utils/auth.utils.js +24 -0
  69. package/dist/api/utils/auth.utils.js.map +1 -0
  70. package/dist/api/utils/cache.utils.d.ts +3 -0
  71. package/dist/api/utils/cache.utils.js +18 -0
  72. package/dist/api/utils/cache.utils.js.map +1 -0
  73. package/dist/api/utils/integration-api-error.d.ts +6 -0
  74. package/dist/api/utils/integration-api-error.js +45 -0
  75. package/dist/api/utils/integration-api-error.js.map +1 -0
  76. package/dist/api/utils/strings.utils.d.ts +7 -0
  77. package/dist/api/utils/strings.utils.js +64 -0
  78. package/dist/api/utils/strings.utils.js.map +1 -0
  79. package/dist/apps/services/app.service.d.ts +126 -0
  80. package/dist/apps/services/app.service.js +1436 -0
  81. package/dist/apps/services/app.service.js.map +1 -0
  82. package/dist/apps/utils/auth-context-manager.d.ts +137 -0
  83. package/dist/apps/utils/auth-context-manager.js +248 -0
  84. package/dist/apps/utils/auth-context-manager.js.map +1 -0
  85. package/dist/apps/utils/credential-manager.d.ts +128 -0
  86. package/dist/apps/utils/credential-manager.js +199 -0
  87. package/dist/apps/utils/credential-manager.js.map +1 -0
  88. package/dist/apps/utils/index.d.ts +10 -0
  89. package/dist/apps/utils/index.js +54 -0
  90. package/dist/apps/utils/index.js.map +1 -0
  91. package/dist/apps/utils/input-helpers.d.ts +67 -0
  92. package/dist/apps/utils/input-helpers.js +185 -0
  93. package/dist/apps/utils/input-helpers.js.map +1 -0
  94. package/dist/apps/utils/input-resolver.d.ts +165 -0
  95. package/dist/apps/utils/input-resolver.js +477 -0
  96. package/dist/apps/utils/input-resolver.js.map +1 -0
  97. package/dist/apps/utils/oauth-manager.d.ts +196 -0
  98. package/dist/apps/utils/oauth-manager.js +429 -0
  99. package/dist/apps/utils/oauth-manager.js.map +1 -0
  100. package/dist/apps/utils/objects.utils.d.ts +4 -0
  101. package/dist/apps/utils/objects.utils.js +59 -0
  102. package/dist/apps/utils/objects.utils.js.map +1 -0
  103. package/dist/apps/utils/string.utils.d.ts +9 -0
  104. package/dist/apps/utils/string.utils.js +89 -0
  105. package/dist/apps/utils/string.utils.js.map +1 -0
  106. package/dist/apps/validators/index.d.ts +17 -0
  107. package/dist/apps/validators/index.js +39 -0
  108. package/dist/apps/validators/index.js.map +1 -0
  109. package/dist/apps/validators/joi-validators/create.app.validator.d.ts +3 -0
  110. package/dist/apps/validators/joi-validators/create.app.validator.js +43 -0
  111. package/dist/apps/validators/joi-validators/create.app.validator.js.map +1 -0
  112. package/dist/apps/validators/joi-validators/create.appAction.validator.d.ts +3 -0
  113. package/dist/apps/validators/joi-validators/create.appAction.validator.js +72 -0
  114. package/dist/apps/validators/joi-validators/create.appAction.validator.js.map +1 -0
  115. package/dist/apps/validators/joi-validators/create.appActionResponse.validator.d.ts +7 -0
  116. package/dist/apps/validators/joi-validators/create.appActionResponse.validator.js +81 -0
  117. package/dist/apps/validators/joi-validators/create.appActionResponse.validator.js.map +1 -0
  118. package/dist/apps/validators/joi-validators/create.appAuth.validator.d.ts +3 -0
  119. package/dist/apps/validators/joi-validators/create.appAuth.validator.js +64 -0
  120. package/dist/apps/validators/joi-validators/create.appAuth.validator.js.map +1 -0
  121. package/dist/apps/validators/joi-validators/create.appBody.validators.d.ts +4 -0
  122. package/dist/apps/validators/joi-validators/create.appBody.validators.js +44 -0
  123. package/dist/apps/validators/joi-validators/create.appBody.validators.js.map +1 -0
  124. package/dist/apps/validators/joi-validators/create.appConstants.validator.d.ts +4 -0
  125. package/dist/apps/validators/joi-validators/create.appConstants.validator.js +45 -0
  126. package/dist/apps/validators/joi-validators/create.appConstants.validator.js.map +1 -0
  127. package/dist/apps/validators/joi-validators/create.appEnv.validator.d.ts +4 -0
  128. package/dist/apps/validators/joi-validators/create.appEnv.validator.js +50 -0
  129. package/dist/apps/validators/joi-validators/create.appEnv.validator.js.map +1 -0
  130. package/dist/apps/validators/joi-validators/create.appVariable.validator.d.ts +4 -0
  131. package/dist/apps/validators/joi-validators/create.appVariable.validator.js +47 -0
  132. package/dist/apps/validators/joi-validators/create.appVariable.validator.js.map +1 -0
  133. package/dist/apps/validators/joi-validators/create.appWebhook.validator.d.ts +4 -0
  134. package/dist/apps/validators/joi-validators/create.appWebhook.validator.js +60 -0
  135. package/dist/apps/validators/joi-validators/create.appWebhook.validator.js.map +1 -0
  136. package/dist/apps/validators/joi-validators/create.appWebhookEvent.validator.d.ts +3 -0
  137. package/dist/apps/validators/joi-validators/create.appWebhookEvent.validator.js +48 -0
  138. package/dist/apps/validators/joi-validators/create.appWebhookEvent.validator.js.map +1 -0
  139. package/dist/apps/validators/joi-validators/sample.validator.d.ts +6 -0
  140. package/dist/apps/validators/joi-validators/sample.validator.js +65 -0
  141. package/dist/apps/validators/joi-validators/sample.validator.js.map +1 -0
  142. package/dist/apps/validators/joi-validators/update.app.validator.d.ts +4 -0
  143. package/dist/apps/validators/joi-validators/update.app.validator.js +66 -0
  144. package/dist/apps/validators/joi-validators/update.app.validator.js.map +1 -0
  145. package/dist/apps/validators/joi-validators/update.appAction.validator.d.ts +4 -0
  146. package/dist/apps/validators/joi-validators/update.appAction.validator.js +76 -0
  147. package/dist/apps/validators/joi-validators/update.appAction.validator.js.map +1 -0
  148. package/dist/apps/validators/joi-validators/update.appActionResponse.validator.d.ts +3 -0
  149. package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js +57 -0
  150. package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js.map +1 -0
  151. package/dist/apps/validators/joi-validators/update.appAuth.validator.d.ts +4 -0
  152. package/dist/apps/validators/joi-validators/update.appAuth.validator.js +52 -0
  153. package/dist/apps/validators/joi-validators/update.appAuth.validator.js.map +1 -0
  154. package/dist/apps/validators/joi-validators/update.appConstants.validator.d.ts +4 -0
  155. package/dist/apps/validators/joi-validators/update.appConstants.validator.js +45 -0
  156. package/dist/apps/validators/joi-validators/update.appConstants.validator.js.map +1 -0
  157. package/dist/apps/validators/joi-validators/update.appEnv.validator.d.ts +4 -0
  158. package/dist/apps/validators/joi-validators/update.appEnv.validator.js +50 -0
  159. package/dist/apps/validators/joi-validators/update.appEnv.validator.js.map +1 -0
  160. package/dist/apps/validators/joi-validators/update.appVariables.validator.d.ts +4 -0
  161. package/dist/apps/validators/joi-validators/update.appVariables.validator.js +47 -0
  162. package/dist/apps/validators/joi-validators/update.appVariables.validator.js.map +1 -0
  163. package/dist/apps/validators/joi-validators/update.appWebhook.validator.d.ts +4 -0
  164. package/dist/apps/validators/joi-validators/update.appWebhook.validator.js +59 -0
  165. package/dist/apps/validators/joi-validators/update.appWebhook.validator.js.map +1 -0
  166. package/dist/apps/validators/joi-validators/update.appWebhookEvent.validator.d.ts +3 -0
  167. package/dist/apps/validators/joi-validators/update.appWebhookEvent.validator.js +48 -0
  168. package/dist/apps/validators/joi-validators/update.appWebhookEvent.validator.js.map +1 -0
  169. package/dist/apps/validators/joi-validators/update.validation.entityData.validator.d.ts +3 -0
  170. package/dist/apps/validators/joi-validators/update.validation.entityData.validator.js +60 -0
  171. package/dist/apps/validators/joi-validators/update.validation.entityData.validator.js.map +1 -0
  172. package/dist/bin.d.ts +26 -0
  173. package/dist/bin.js +28 -0
  174. package/dist/bin.js.map +1 -0
  175. package/dist/brokers/brokers.service.d.ts +438 -0
  176. package/dist/brokers/brokers.service.js +1315 -0
  177. package/dist/brokers/brokers.service.js.map +1 -0
  178. package/dist/brokers/index.d.ts +46 -0
  179. package/dist/brokers/index.js +83 -0
  180. package/dist/brokers/index.js.map +1 -0
  181. package/dist/brokers/types/index.d.ts +569 -0
  182. package/dist/brokers/types/index.js +8 -0
  183. package/dist/brokers/types/index.js.map +1 -0
  184. package/dist/brokers/utils/broker.util.d.ts +33 -0
  185. package/dist/brokers/utils/broker.util.js +125 -0
  186. package/dist/brokers/utils/broker.util.js.map +1 -0
  187. package/dist/brokers/utils/providers/aws-sqs.service.d.ts +16 -0
  188. package/dist/brokers/utils/providers/aws-sqs.service.js +71 -0
  189. package/dist/brokers/utils/providers/aws-sqs.service.js.map +1 -0
  190. package/dist/brokers/utils/providers/google-pubsub.service.d.ts +16 -0
  191. package/dist/brokers/utils/providers/google-pubsub.service.js +43 -0
  192. package/dist/brokers/utils/providers/google-pubsub.service.js.map +1 -0
  193. package/dist/brokers/utils/providers/index.d.ts +6 -0
  194. package/dist/brokers/utils/providers/index.js +16 -0
  195. package/dist/brokers/utils/providers/index.js.map +1 -0
  196. package/dist/brokers/utils/providers/kafka.service.d.ts +23 -0
  197. package/dist/brokers/utils/providers/kafka.service.js +131 -0
  198. package/dist/brokers/utils/providers/kafka.service.js.map +1 -0
  199. package/dist/brokers/utils/providers/nats.service.d.ts +18 -0
  200. package/dist/brokers/utils/providers/nats.service.js +63 -0
  201. package/dist/brokers/utils/providers/nats.service.js.map +1 -0
  202. package/dist/brokers/utils/providers/rabbitmq.service.d.ts +25 -0
  203. package/dist/brokers/utils/providers/rabbitmq.service.js +138 -0
  204. package/dist/brokers/utils/providers/rabbitmq.service.js.map +1 -0
  205. package/dist/brokers/utils/providers/redis.service.d.ts +18 -0
  206. package/dist/brokers/utils/providers/redis.service.js +93 -0
  207. package/dist/brokers/utils/providers/redis.service.js.map +1 -0
  208. package/dist/cache/cache.manager.d.ts +308 -0
  209. package/dist/cache/cache.manager.js +900 -0
  210. package/dist/cache/cache.manager.js.map +1 -0
  211. package/dist/cache/cache.service.d.ts +194 -0
  212. package/dist/cache/cache.service.js +601 -0
  213. package/dist/cache/cache.service.js.map +1 -0
  214. package/dist/cache/index.d.ts +52 -0
  215. package/dist/cache/index.js +81 -0
  216. package/dist/cache/index.js.map +1 -0
  217. package/dist/cache/types/index.d.ts +114 -0
  218. package/dist/cache/types/index.js +6 -0
  219. package/dist/cache/types/index.js.map +1 -0
  220. package/dist/clients/apps.client.d.ts +4 -0
  221. package/dist/clients/apps.client.js +31 -0
  222. package/dist/clients/apps.client.js.map +1 -0
  223. package/dist/clients/email.client.d.ts +4 -0
  224. package/dist/clients/email.client.js +29 -0
  225. package/dist/clients/email.client.js.map +1 -0
  226. package/dist/clients/expo.client.d.ts +3 -0
  227. package/dist/clients/expo.client.js +28 -0
  228. package/dist/clients/expo.client.js.map +1 -0
  229. package/dist/clients/function.client.d.ts +3 -0
  230. package/dist/clients/function.client.js +27 -0
  231. package/dist/clients/function.client.js.map +1 -0
  232. package/dist/clients/http.client.d.ts +3 -0
  233. package/dist/clients/http.client.js +27 -0
  234. package/dist/clients/http.client.js.map +1 -0
  235. package/dist/clients/logs.client.d.ts +4 -0
  236. package/dist/clients/logs.client.js +34 -0
  237. package/dist/clients/logs.client.js.map +1 -0
  238. package/dist/clients/pricing.client.d.ts +4 -0
  239. package/dist/clients/pricing.client.js +34 -0
  240. package/dist/clients/pricing.client.js.map +1 -0
  241. package/dist/clients/products.client.d.ts +3 -0
  242. package/dist/clients/products.client.js +32 -0
  243. package/dist/clients/products.client.js.map +1 -0
  244. package/dist/clients/users.client.d.ts +4 -0
  245. package/dist/clients/users.client.js +34 -0
  246. package/dist/clients/users.client.js.map +1 -0
  247. package/dist/clients/webhooks.client.d.ts +4 -0
  248. package/dist/clients/webhooks.client.js +34 -0
  249. package/dist/clients/webhooks.client.js.map +1 -0
  250. package/dist/clients/workspace.client.d.ts +7 -0
  251. package/dist/clients/workspace.client.js +39 -0
  252. package/dist/clients/workspace.client.js.map +1 -0
  253. package/dist/cloud/cloud-runtime.util.d.ts +22 -0
  254. package/dist/cloud/cloud-runtime.util.js +61 -0
  255. package/dist/cloud/cloud-runtime.util.js.map +1 -0
  256. package/dist/cloud/cloud.service.d.ts +43 -0
  257. package/dist/cloud/cloud.service.js +121 -0
  258. package/dist/cloud/cloud.service.js.map +1 -0
  259. package/dist/cloud/index.d.ts +5 -0
  260. package/dist/cloud/index.js +25 -0
  261. package/dist/cloud/index.js.map +1 -0
  262. package/dist/cloud/types/cloud.types.d.ts +140 -0
  263. package/dist/cloud/types/cloud.types.js +6 -0
  264. package/dist/cloud/types/cloud.types.js.map +1 -0
  265. package/dist/cloud/types/index.d.ts +1 -0
  266. package/dist/cloud/types/index.js +18 -0
  267. package/dist/cloud/types/index.js.map +1 -0
  268. package/dist/database/actions/action-manager.d.ts +170 -0
  269. package/dist/database/actions/action-manager.js +465 -0
  270. package/dist/database/actions/action-manager.js.map +1 -0
  271. package/dist/database/actions/index.d.ts +6 -0
  272. package/dist/database/actions/index.js +13 -0
  273. package/dist/database/actions/index.js.map +1 -0
  274. package/dist/database/adapters/adapter.factory.d.ts +62 -0
  275. package/dist/database/adapters/adapter.factory.js +97 -0
  276. package/dist/database/adapters/adapter.factory.js.map +1 -0
  277. package/dist/database/adapters/base.adapter.d.ts +423 -0
  278. package/dist/database/adapters/base.adapter.js +260 -0
  279. package/dist/database/adapters/base.adapter.js.map +1 -0
  280. package/dist/database/adapters/cassandra.adapter.d.ts +92 -0
  281. package/dist/database/adapters/cassandra.adapter.js +1091 -0
  282. package/dist/database/adapters/cassandra.adapter.js.map +1 -0
  283. package/dist/database/adapters/dynamodb.adapter.d.ts +110 -0
  284. package/dist/database/adapters/dynamodb.adapter.js +1564 -0
  285. package/dist/database/adapters/dynamodb.adapter.js.map +1 -0
  286. package/dist/database/adapters/index.d.ts +11 -0
  287. package/dist/database/adapters/index.js +27 -0
  288. package/dist/database/adapters/index.js.map +1 -0
  289. package/dist/database/adapters/mariadb.adapter.d.ts +100 -0
  290. package/dist/database/adapters/mariadb.adapter.js +247 -0
  291. package/dist/database/adapters/mariadb.adapter.js.map +1 -0
  292. package/dist/database/adapters/mongodb.adapter.d.ts +121 -0
  293. package/dist/database/adapters/mongodb.adapter.js +1284 -0
  294. package/dist/database/adapters/mongodb.adapter.js.map +1 -0
  295. package/dist/database/adapters/mysql.adapter.d.ts +86 -0
  296. package/dist/database/adapters/mysql.adapter.js +1371 -0
  297. package/dist/database/adapters/mysql.adapter.js.map +1 -0
  298. package/dist/database/adapters/postgresql.adapter.d.ts +90 -0
  299. package/dist/database/adapters/postgresql.adapter.js +1487 -0
  300. package/dist/database/adapters/postgresql.adapter.js.map +1 -0
  301. package/dist/database/databases.service.d.ts +1526 -0
  302. package/dist/database/databases.service.js +3370 -0
  303. package/dist/database/databases.service.js.map +1 -0
  304. package/dist/database/index.d.ts +46 -0
  305. package/dist/database/index.js +109 -0
  306. package/dist/database/index.js.map +1 -0
  307. package/dist/database/migrations/index.d.ts +6 -0
  308. package/dist/database/migrations/index.js +12 -0
  309. package/dist/database/migrations/index.js.map +1 -0
  310. package/dist/database/migrations/migration-engine.d.ts +136 -0
  311. package/dist/database/migrations/migration-engine.js +1421 -0
  312. package/dist/database/migrations/migration-engine.js.map +1 -0
  313. package/dist/database/operators/aggregation-builder.d.ts +67 -0
  314. package/dist/database/operators/aggregation-builder.js +841 -0
  315. package/dist/database/operators/aggregation-builder.js.map +1 -0
  316. package/dist/database/operators/index.d.ts +7 -0
  317. package/dist/database/operators/index.js +15 -0
  318. package/dist/database/operators/index.js.map +1 -0
  319. package/dist/database/operators/query-builder.d.ts +69 -0
  320. package/dist/database/operators/query-builder.js +447 -0
  321. package/dist/database/operators/query-builder.js.map +1 -0
  322. package/dist/database/presave/decrypt.d.ts +25 -0
  323. package/dist/database/presave/decrypt.js +146 -0
  324. package/dist/database/presave/decrypt.js.map +1 -0
  325. package/dist/database/presave/index.d.ts +9 -0
  326. package/dist/database/presave/index.js +18 -0
  327. package/dist/database/presave/index.js.map +1 -0
  328. package/dist/database/presave/presave-processor.d.ts +148 -0
  329. package/dist/database/presave/presave-processor.js +702 -0
  330. package/dist/database/presave/presave-processor.js.map +1 -0
  331. package/dist/database/schema/index.d.ts +7 -0
  332. package/dist/database/schema/index.js +13 -0
  333. package/dist/database/schema/index.js.map +1 -0
  334. package/dist/database/schema/schema-manager.d.ts +258 -0
  335. package/dist/database/schema/schema-manager.js +638 -0
  336. package/dist/database/schema/schema-manager.js.map +1 -0
  337. package/dist/database/transactions/index.d.ts +6 -0
  338. package/dist/database/transactions/index.js +13 -0
  339. package/dist/database/transactions/index.js.map +1 -0
  340. package/dist/database/transactions/transaction-manager.d.ts +113 -0
  341. package/dist/database/transactions/transaction-manager.js +344 -0
  342. package/dist/database/transactions/transaction-manager.js.map +1 -0
  343. package/dist/database/triggers/index.d.ts +7 -0
  344. package/dist/database/triggers/index.js +14 -0
  345. package/dist/database/triggers/index.js.map +1 -0
  346. package/dist/database/triggers/trigger-processor.d.ts +239 -0
  347. package/dist/database/triggers/trigger-processor.js +1034 -0
  348. package/dist/database/triggers/trigger-processor.js.map +1 -0
  349. package/dist/database/types/action.interface.d.ts +148 -0
  350. package/dist/database/types/action.interface.js +6 -0
  351. package/dist/database/types/action.interface.js.map +1 -0
  352. package/dist/database/types/aggregation.interface.d.ts +185 -0
  353. package/dist/database/types/aggregation.interface.js +6 -0
  354. package/dist/database/types/aggregation.interface.js.map +1 -0
  355. package/dist/database/types/connection.interface.d.ts +141 -0
  356. package/dist/database/types/connection.interface.js +6 -0
  357. package/dist/database/types/connection.interface.js.map +1 -0
  358. package/dist/database/types/dashboard.interface.d.ts +74 -0
  359. package/dist/database/types/dashboard.interface.js +7 -0
  360. package/dist/database/types/dashboard.interface.js.map +1 -0
  361. package/dist/database/types/enums.d.ts +195 -0
  362. package/dist/database/types/enums.js +244 -0
  363. package/dist/database/types/enums.js.map +1 -0
  364. package/dist/database/types/index.d.ts +15 -0
  365. package/dist/database/types/index.js +31 -0
  366. package/dist/database/types/index.js.map +1 -0
  367. package/dist/database/types/migration.interface.d.ts +686 -0
  368. package/dist/database/types/migration.interface.js +9 -0
  369. package/dist/database/types/migration.interface.js.map +1 -0
  370. package/dist/database/types/presave.interface.d.ts +292 -0
  371. package/dist/database/types/presave.interface.js +60 -0
  372. package/dist/database/types/presave.interface.js.map +1 -0
  373. package/dist/database/types/query.interface.d.ts +205 -0
  374. package/dist/database/types/query.interface.js +6 -0
  375. package/dist/database/types/query.interface.js.map +1 -0
  376. package/dist/database/types/schema.interface.d.ts +412 -0
  377. package/dist/database/types/schema.interface.js +6 -0
  378. package/dist/database/types/schema.interface.js.map +1 -0
  379. package/dist/database/types/transaction.interface.d.ts +84 -0
  380. package/dist/database/types/transaction.interface.js +6 -0
  381. package/dist/database/types/transaction.interface.js.map +1 -0
  382. package/dist/database/types/trigger.interface.d.ts +612 -0
  383. package/dist/database/types/trigger.interface.js +121 -0
  384. package/dist/database/types/trigger.interface.js.map +1 -0
  385. package/dist/database/types/write.interface.d.ts +216 -0
  386. package/dist/database/types/write.interface.js +6 -0
  387. package/dist/database/types/write.interface.js.map +1 -0
  388. package/dist/database/utils/database-error.d.ts +96 -0
  389. package/dist/database/utils/database-error.js +221 -0
  390. package/dist/database/utils/database-error.js.map +1 -0
  391. package/dist/database/utils/index.d.ts +6 -0
  392. package/dist/database/utils/index.js +11 -0
  393. package/dist/database/utils/index.js.map +1 -0
  394. package/dist/graph/adapters/adapter.factory.d.ts +47 -0
  395. package/dist/graph/adapters/adapter.factory.js +77 -0
  396. package/dist/graph/adapters/adapter.factory.js.map +1 -0
  397. package/dist/graph/adapters/arangodb.adapter.d.ts +86 -0
  398. package/dist/graph/adapters/arangodb.adapter.js +1588 -0
  399. package/dist/graph/adapters/arangodb.adapter.js.map +1 -0
  400. package/dist/graph/adapters/base.adapter.d.ts +264 -0
  401. package/dist/graph/adapters/base.adapter.js +156 -0
  402. package/dist/graph/adapters/base.adapter.js.map +1 -0
  403. package/dist/graph/adapters/index.d.ts +11 -0
  404. package/dist/graph/adapters/index.js +21 -0
  405. package/dist/graph/adapters/index.js.map +1 -0
  406. package/dist/graph/adapters/memgraph.adapter.d.ts +110 -0
  407. package/dist/graph/adapters/memgraph.adapter.js +1452 -0
  408. package/dist/graph/adapters/memgraph.adapter.js.map +1 -0
  409. package/dist/graph/adapters/neo4j.adapter.d.ts +81 -0
  410. package/dist/graph/adapters/neo4j.adapter.js +1317 -0
  411. package/dist/graph/adapters/neo4j.adapter.js.map +1 -0
  412. package/dist/graph/adapters/neptune.adapter.d.ts +82 -0
  413. package/dist/graph/adapters/neptune.adapter.js +1369 -0
  414. package/dist/graph/adapters/neptune.adapter.js.map +1 -0
  415. package/dist/graph/graphs.service.d.ts +633 -0
  416. package/dist/graph/graphs.service.js +2684 -0
  417. package/dist/graph/graphs.service.js.map +1 -0
  418. package/dist/graph/index.d.ts +58 -0
  419. package/dist/graph/index.js +77 -0
  420. package/dist/graph/index.js.map +1 -0
  421. package/dist/graph/transactions/index.d.ts +4 -0
  422. package/dist/graph/transactions/index.js +9 -0
  423. package/dist/graph/transactions/index.js.map +1 -0
  424. package/dist/graph/transactions/transaction-manager.d.ts +61 -0
  425. package/dist/graph/transactions/transaction-manager.js +126 -0
  426. package/dist/graph/transactions/transaction-manager.js.map +1 -0
  427. package/dist/graph/types/connection.interface.d.ts +161 -0
  428. package/dist/graph/types/connection.interface.js +9 -0
  429. package/dist/graph/types/connection.interface.js.map +1 -0
  430. package/dist/graph/types/enums.d.ts +101 -0
  431. package/dist/graph/types/enums.js +114 -0
  432. package/dist/graph/types/enums.js.map +1 -0
  433. package/dist/graph/types/index.d.ts +13 -0
  434. package/dist/graph/types/index.js +20 -0
  435. package/dist/graph/types/index.js.map +1 -0
  436. package/dist/graph/types/node.interface.d.ts +248 -0
  437. package/dist/graph/types/node.interface.js +9 -0
  438. package/dist/graph/types/node.interface.js.map +1 -0
  439. package/dist/graph/types/query.interface.d.ts +175 -0
  440. package/dist/graph/types/query.interface.js +9 -0
  441. package/dist/graph/types/query.interface.js.map +1 -0
  442. package/dist/graph/types/relationship.interface.d.ts +207 -0
  443. package/dist/graph/types/relationship.interface.js +9 -0
  444. package/dist/graph/types/relationship.interface.js.map +1 -0
  445. package/dist/graph/types/schema.interface.d.ts +295 -0
  446. package/dist/graph/types/schema.interface.js +9 -0
  447. package/dist/graph/types/schema.interface.js.map +1 -0
  448. package/dist/graph/types/transaction.interface.d.ts +55 -0
  449. package/dist/graph/types/transaction.interface.js +9 -0
  450. package/dist/graph/types/transaction.interface.js.map +1 -0
  451. package/dist/graph/types/traversal.interface.d.ts +181 -0
  452. package/dist/graph/types/traversal.interface.js +9 -0
  453. package/dist/graph/types/traversal.interface.js.map +1 -0
  454. package/dist/graph/utils/graph-error.d.ts +71 -0
  455. package/dist/graph/utils/graph-error.js +142 -0
  456. package/dist/graph/utils/graph-error.js.map +1 -0
  457. package/dist/graph/utils/index.d.ts +4 -0
  458. package/dist/graph/utils/index.js +9 -0
  459. package/dist/graph/utils/index.js.map +1 -0
  460. package/dist/imports/imports.repo.d.ts +0 -0
  461. package/dist/imports/imports.repo.js +1 -0
  462. package/dist/imports/imports.repo.js.map +1 -0
  463. package/dist/imports/imports.service.d.ts +23 -0
  464. package/dist/imports/imports.service.js +71 -0
  465. package/dist/imports/imports.service.js.map +1 -0
  466. package/dist/imports/imports.types.d.ts +350 -0
  467. package/dist/imports/imports.types.js +33 -0
  468. package/dist/imports/imports.types.js.map +1 -0
  469. package/dist/imports/openAPI3.0.types.d.ts +52 -0
  470. package/dist/imports/openAPI3.0.types.js +3 -0
  471. package/dist/imports/openAPI3.0.types.js.map +1 -0
  472. package/dist/imports/repos/openApi.repo.d.ts +6 -0
  473. package/dist/imports/repos/openApi.repo.js +422 -0
  474. package/dist/imports/repos/openApi.repo.js.map +1 -0
  475. package/dist/imports/repos/postmanV21.repo.d.ts +14 -0
  476. package/dist/imports/repos/postmanV21.repo.js +257 -0
  477. package/dist/imports/repos/postmanV21.repo.js.map +1 -0
  478. package/dist/imports/utils/imports.utils.d.ts +80 -0
  479. package/dist/imports/utils/imports.utils.js +114 -0
  480. package/dist/imports/utils/imports.utils.js.map +1 -0
  481. package/dist/imports/validators/index.d.ts +0 -0
  482. package/dist/imports/validators/index.js +1 -0
  483. package/dist/imports/validators/index.js.map +1 -0
  484. package/dist/imports/validators/joi-validators/postmanV21.validator.d.ts +5 -0
  485. package/dist/imports/validators/joi-validators/postmanV21.validator.js +96 -0
  486. package/dist/imports/validators/joi-validators/postmanV21.validator.js.map +1 -0
  487. package/dist/index.d.ts +4233 -0
  488. package/dist/index.js +5930 -0
  489. package/dist/index.js.map +1 -0
  490. package/dist/init.interface.d.ts +407 -0
  491. package/dist/init.interface.js +3 -0
  492. package/dist/init.interface.js.map +1 -0
  493. package/dist/inputs/inputs.repo.d.ts +7 -0
  494. package/dist/inputs/inputs.repo.js +16 -0
  495. package/dist/inputs/inputs.repo.js.map +1 -0
  496. package/dist/inputs/inputs.service.d.ts +61 -0
  497. package/dist/inputs/inputs.service.js +468 -0
  498. package/dist/inputs/inputs.service.js.map +1 -0
  499. package/dist/inputs/utils/inputs.utils.create.d.ts +11 -0
  500. package/dist/inputs/utils/inputs.utils.create.js +273 -0
  501. package/dist/inputs/utils/inputs.utils.create.js.map +1 -0
  502. package/dist/inputs/validators/inputs.validator.parse.d.ts +4 -0
  503. package/dist/inputs/validators/inputs.validator.parse.js +53 -0
  504. package/dist/inputs/validators/inputs.validator.parse.js.map +1 -0
  505. package/dist/jobs/index.d.ts +38 -0
  506. package/dist/jobs/index.js +50 -0
  507. package/dist/jobs/index.js.map +1 -0
  508. package/dist/jobs/jobs.service.d.ts +154 -0
  509. package/dist/jobs/jobs.service.js +491 -0
  510. package/dist/jobs/jobs.service.js.map +1 -0
  511. package/dist/jobs/jobs.state.d.ts +113 -0
  512. package/dist/jobs/jobs.state.js +447 -0
  513. package/dist/jobs/jobs.state.js.map +1 -0
  514. package/dist/jobs/types.d.ts +449 -0
  515. package/dist/jobs/types.js +74 -0
  516. package/dist/jobs/types.js.map +1 -0
  517. package/dist/logs/logs.repo.d.ts +6 -0
  518. package/dist/logs/logs.repo.js +12 -0
  519. package/dist/logs/logs.repo.js.map +1 -0
  520. package/dist/logs/logs.service.d.ts +30 -0
  521. package/dist/logs/logs.service.js +89 -0
  522. package/dist/logs/logs.service.js.map +1 -0
  523. package/dist/logs/logs.types.d.ts +85 -0
  524. package/dist/logs/logs.types.js +52 -0
  525. package/dist/logs/logs.types.js.map +1 -0
  526. package/dist/logs/utils/logs.utils.create.d.ts +0 -0
  527. package/dist/logs/utils/logs.utils.create.js +1 -0
  528. package/dist/logs/utils/logs.utils.create.js.map +1 -0
  529. package/dist/logs/utils/logs.utils.errors.d.ts +2 -0
  530. package/dist/logs/utils/logs.utils.errors.js +8 -0
  531. package/dist/logs/utils/logs.utils.errors.js.map +1 -0
  532. package/dist/models/index.d.ts +6 -0
  533. package/dist/models/index.js +11 -0
  534. package/dist/models/index.js.map +1 -0
  535. package/dist/models/models.service.d.ts +137 -0
  536. package/dist/models/models.service.js +195 -0
  537. package/dist/models/models.service.js.map +1 -0
  538. package/dist/notifications/index.d.ts +13 -0
  539. package/dist/notifications/index.js +26 -0
  540. package/dist/notifications/index.js.map +1 -0
  541. package/dist/notifications/notifications.service.d.ts +270 -0
  542. package/dist/notifications/notifications.service.js +912 -0
  543. package/dist/notifications/notifications.service.js.map +1 -0
  544. package/dist/notifications/types/index.d.ts +4 -0
  545. package/dist/notifications/types/index.js +21 -0
  546. package/dist/notifications/types/index.js.map +1 -0
  547. package/dist/notifications/types/notifications.types.d.ts +456 -0
  548. package/dist/notifications/types/notifications.types.js +51 -0
  549. package/dist/notifications/types/notifications.types.js.map +1 -0
  550. package/dist/parsers/index.d.ts +3 -0
  551. package/dist/parsers/index.js +27 -0
  552. package/dist/parsers/index.js.map +1 -0
  553. package/dist/parsers/pipelines/postman.pipelines.d.ts +15 -0
  554. package/dist/parsers/pipelines/postman.pipelines.js +103 -0
  555. package/dist/parsers/pipelines/postman.pipelines.js.map +1 -0
  556. package/dist/parsers/types/postman.types.d.ts +200 -0
  557. package/dist/parsers/types/postman.types.js +3 -0
  558. package/dist/parsers/types/postman.types.js.map +1 -0
  559. package/dist/parsers/utils/postman.utils.d.ts +12 -0
  560. package/dist/parsers/utils/postman.utils.js +116 -0
  561. package/dist/parsers/utils/postman.utils.js.map +1 -0
  562. package/dist/parsers/validators/postman-auth.validators.d.ts +10 -0
  563. package/dist/parsers/validators/postman-auth.validators.js +127 -0
  564. package/dist/parsers/validators/postman-auth.validators.js.map +1 -0
  565. package/dist/parsers/validators/postman-request.validators.d.ts +13 -0
  566. package/dist/parsers/validators/postman-request.validators.js +139 -0
  567. package/dist/parsers/validators/postman-request.validators.js.map +1 -0
  568. package/dist/parsers/validators/postman-response.validators.d.ts +13 -0
  569. package/dist/parsers/validators/postman-response.validators.js +150 -0
  570. package/dist/parsers/validators/postman-response.validators.js.map +1 -0
  571. package/dist/parsers/validators/postman-variable.validators.d.ts +14 -0
  572. package/dist/parsers/validators/postman-variable.validators.js +163 -0
  573. package/dist/parsers/validators/postman-variable.validators.js.map +1 -0
  574. package/dist/pricing/pricing.repo.d.ts +0 -0
  575. package/dist/pricing/pricing.repo.js +1 -0
  576. package/dist/pricing/pricing.repo.js.map +1 -0
  577. package/dist/pricing/pricing.service.d.ts +24 -0
  578. package/dist/pricing/pricing.service.js +51 -0
  579. package/dist/pricing/pricing.service.js.map +1 -0
  580. package/dist/pricing/pricing.types.d.ts +76 -0
  581. package/dist/pricing/pricing.types.js +21 -0
  582. package/dist/pricing/pricing.types.js.map +1 -0
  583. package/dist/pricing/utils/string.utils.d.ts +1 -0
  584. package/dist/pricing/utils/string.utils.js +9 -0
  585. package/dist/pricing/utils/string.utils.js.map +1 -0
  586. package/dist/processor/repos/mongo.repo.d.ts +39 -0
  587. package/dist/processor/repos/mongo.repo.js +260 -0
  588. package/dist/processor/repos/mongo.repo.js.map +1 -0
  589. package/dist/processor/repos/postgres.repo.d.ts +31 -0
  590. package/dist/processor/repos/postgres.repo.js +185 -0
  591. package/dist/processor/repos/postgres.repo.js.map +1 -0
  592. package/dist/processor/repos/sms.repo.d.ts +39 -0
  593. package/dist/processor/repos/sms.repo.js +124 -0
  594. package/dist/processor/repos/sms.repo.js.map +1 -0
  595. package/dist/processor/services/processor.service.d.ts +465 -0
  596. package/dist/processor/services/processor.service.js +5343 -0
  597. package/dist/processor/services/processor.service.js.map +1 -0
  598. package/dist/processor/services/request.service.d.ts +36 -0
  599. package/dist/processor/services/request.service.js +304 -0
  600. package/dist/processor/services/request.service.js.map +1 -0
  601. package/dist/processor/types/request.types.d.ts +14 -0
  602. package/dist/processor/types/request.types.js +3 -0
  603. package/dist/processor/types/request.types.js.map +1 -0
  604. package/dist/processor/utils/processor.utils.d.ts +104 -0
  605. package/dist/processor/utils/processor.utils.js +1066 -0
  606. package/dist/processor/utils/processor.utils.js.map +1 -0
  607. package/dist/processor/utils/request.utils.d.ts +20 -0
  608. package/dist/processor/utils/request.utils.js +113 -0
  609. package/dist/processor/utils/request.utils.js.map +1 -0
  610. package/dist/processor/utils/storage.util.d.ts +8 -0
  611. package/dist/processor/utils/storage.util.js +106 -0
  612. package/dist/processor/utils/storage.util.js.map +1 -0
  613. package/dist/products/services/products.service.d.ts +579 -0
  614. package/dist/products/services/products.service.js +5853 -0
  615. package/dist/products/services/products.service.js.map +1 -0
  616. package/dist/products/utils/crypt.utils.d.ts +1 -0
  617. package/dist/products/utils/crypt.utils.js +17 -0
  618. package/dist/products/utils/crypt.utils.js.map +1 -0
  619. package/dist/products/utils/functions.utils.d.ts +13 -0
  620. package/dist/products/utils/functions.utils.js +294 -0
  621. package/dist/products/utils/functions.utils.js.map +1 -0
  622. package/dist/products/utils/objects.utils.d.ts +13 -0
  623. package/dist/products/utils/objects.utils.js +89 -0
  624. package/dist/products/utils/objects.utils.js.map +1 -0
  625. package/dist/products/utils/string.utils.d.ts +12 -0
  626. package/dist/products/utils/string.utils.js +168 -0
  627. package/dist/products/utils/string.utils.js.map +1 -0
  628. package/dist/products/validators/index.d.ts +33 -0
  629. package/dist/products/validators/index.js +75 -0
  630. package/dist/products/validators/index.js.map +1 -0
  631. package/dist/products/validators/joi-validators/create.html.validator.d.ts +2 -0
  632. package/dist/products/validators/joi-validators/create.html.validator.js +55 -0
  633. package/dist/products/validators/joi-validators/create.html.validator.js.map +1 -0
  634. package/dist/products/validators/joi-validators/create.productAgent.validator.d.ts +3 -0
  635. package/dist/products/validators/joi-validators/create.productAgent.validator.js +266 -0
  636. package/dist/products/validators/joi-validators/create.productAgent.validator.js.map +1 -0
  637. package/dist/products/validators/joi-validators/create.productApp.validator.d.ts +4 -0
  638. package/dist/products/validators/joi-validators/create.productApp.validator.js +61 -0
  639. package/dist/products/validators/joi-validators/create.productApp.validator.js.map +1 -0
  640. package/dist/products/validators/joi-validators/create.productCache.validator.d.ts +3 -0
  641. package/dist/products/validators/joi-validators/create.productCache.validator.js +46 -0
  642. package/dist/products/validators/joi-validators/create.productCache.validator.js.map +1 -0
  643. package/dist/products/validators/joi-validators/create.productDatabase.validator.d.ts +3 -0
  644. package/dist/products/validators/joi-validators/create.productDatabase.validator.js +77 -0
  645. package/dist/products/validators/joi-validators/create.productDatabase.validator.js.map +1 -0
  646. package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.d.ts +7 -0
  647. package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js +194 -0
  648. package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js.map +1 -0
  649. package/dist/products/validators/joi-validators/create.productDatabaseMigration.validator.d.ts +4 -0
  650. package/dist/products/validators/joi-validators/create.productDatabaseMigration.validator.js +63 -0
  651. package/dist/products/validators/joi-validators/create.productDatabaseMigration.validator.js.map +1 -0
  652. package/dist/products/validators/joi-validators/create.productEnv.validator.d.ts +3 -0
  653. package/dist/products/validators/joi-validators/create.productEnv.validator.js +45 -0
  654. package/dist/products/validators/joi-validators/create.productEnv.validator.js.map +1 -0
  655. package/dist/products/validators/joi-validators/create.productFallback.validator.d.ts +3 -0
  656. package/dist/products/validators/joi-validators/create.productFallback.validator.js +64 -0
  657. package/dist/products/validators/joi-validators/create.productFallback.validator.js.map +1 -0
  658. package/dist/products/validators/joi-validators/create.productFeature.validator.d.ts +14 -0
  659. package/dist/products/validators/joi-validators/create.productFeature.validator.js +140 -0
  660. package/dist/products/validators/joi-validators/create.productFeature.validator.js.map +1 -0
  661. package/dist/products/validators/joi-validators/create.productFunction.validator.d.ts +3 -0
  662. package/dist/products/validators/joi-validators/create.productFunction.validator.js +57 -0
  663. package/dist/products/validators/joi-validators/create.productFunction.validator.js.map +1 -0
  664. package/dist/products/validators/joi-validators/create.productGraph.validator.d.ts +3 -0
  665. package/dist/products/validators/joi-validators/create.productGraph.validator.js +89 -0
  666. package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -0
  667. package/dist/products/validators/joi-validators/create.productHealthcheck.validator.d.ts +4 -0
  668. package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js +58 -0
  669. package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js.map +1 -0
  670. package/dist/products/validators/joi-validators/create.productJob.validator.d.ts +12 -0
  671. package/dist/products/validators/joi-validators/create.productJob.validator.js +60 -0
  672. package/dist/products/validators/joi-validators/create.productJob.validator.js.map +1 -0
  673. package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.d.ts +3 -0
  674. package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js +52 -0
  675. package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js.map +1 -0
  676. package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.d.ts +3 -0
  677. package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +193 -0
  678. package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -0
  679. package/dist/products/validators/joi-validators/create.productModel.validator.d.ts +3 -0
  680. package/dist/products/validators/joi-validators/create.productModel.validator.js +132 -0
  681. package/dist/products/validators/joi-validators/create.productModel.validator.js.map +1 -0
  682. package/dist/products/validators/joi-validators/create.productNotification.validator.d.ts +4 -0
  683. package/dist/products/validators/joi-validators/create.productNotification.validator.js +241 -0
  684. package/dist/products/validators/joi-validators/create.productNotification.validator.js.map +1 -0
  685. package/dist/products/validators/joi-validators/create.productNotificationMessage.validator.d.ts +3 -0
  686. package/dist/products/validators/joi-validators/create.productNotificationMessage.validator.js +57 -0
  687. package/dist/products/validators/joi-validators/create.productNotificationMessage.validator.js.map +1 -0
  688. package/dist/products/validators/joi-validators/create.productNotifications.validator.d.ts +0 -0
  689. package/dist/products/validators/joi-validators/create.productNotifications.validator.js +1 -0
  690. package/dist/products/validators/joi-validators/create.productNotifications.validator.js.map +1 -0
  691. package/dist/products/validators/joi-validators/create.productQuota.validator.d.ts +3 -0
  692. package/dist/products/validators/joi-validators/create.productQuota.validator.js +67 -0
  693. package/dist/products/validators/joi-validators/create.productQuota.validator.js.map +1 -0
  694. package/dist/products/validators/joi-validators/create.productStorage.validator.d.ts +3 -0
  695. package/dist/products/validators/joi-validators/create.productStorage.validator.js +158 -0
  696. package/dist/products/validators/joi-validators/create.productStorage.validator.js.map +1 -0
  697. package/dist/products/validators/joi-validators/create.productVector.validator.d.ts +3 -0
  698. package/dist/products/validators/joi-validators/create.productVector.validator.js +136 -0
  699. package/dist/products/validators/joi-validators/create.productVector.validator.js.map +1 -0
  700. package/dist/products/validators/joi-validators/create.products.validator.d.ts +3 -0
  701. package/dist/products/validators/joi-validators/create.products.validator.js +43 -0
  702. package/dist/products/validators/joi-validators/create.products.validator.js.map +1 -0
  703. package/dist/products/validators/joi-validators/create.requestAction.validator.d.ts +2 -0
  704. package/dist/products/validators/joi-validators/create.requestAction.validator.js +45 -0
  705. package/dist/products/validators/joi-validators/create.requestAction.validator.js.map +1 -0
  706. package/dist/products/validators/joi-validators/create.userAuth.validator.d.ts +3 -0
  707. package/dist/products/validators/joi-validators/create.userAuth.validator.js +48 -0
  708. package/dist/products/validators/joi-validators/create.userAuth.validator.js.map +1 -0
  709. package/dist/products/validators/joi-validators/register.productWebhooks.validator.d.ts +3 -0
  710. package/dist/products/validators/joi-validators/register.productWebhooks.validator.js +48 -0
  711. package/dist/products/validators/joi-validators/register.productWebhooks.validator.js.map +1 -0
  712. package/dist/products/validators/joi-validators/update.dataValue.validator.d.ts +3 -0
  713. package/dist/products/validators/joi-validators/update.dataValue.validator.js +104 -0
  714. package/dist/products/validators/joi-validators/update.dataValue.validator.js.map +1 -0
  715. package/dist/products/validators/joi-validators/update.productApp.validator.d.ts +3 -0
  716. package/dist/products/validators/joi-validators/update.productApp.validator.js +42 -0
  717. package/dist/products/validators/joi-validators/update.productApp.validator.js.map +1 -0
  718. package/dist/products/validators/joi-validators/update.productCache.validator.d.ts +3 -0
  719. package/dist/products/validators/joi-validators/update.productCache.validator.js +45 -0
  720. package/dist/products/validators/joi-validators/update.productCache.validator.js.map +1 -0
  721. package/dist/products/validators/joi-validators/update.productDatabase.validator.d.ts +3 -0
  722. package/dist/products/validators/joi-validators/update.productDatabase.validator.js +76 -0
  723. package/dist/products/validators/joi-validators/update.productDatabase.validator.js.map +1 -0
  724. package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.d.ts +3 -0
  725. package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js +79 -0
  726. package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js.map +1 -0
  727. package/dist/products/validators/joi-validators/update.productDatabaseMigration.validator.d.ts +4 -0
  728. package/dist/products/validators/joi-validators/update.productDatabaseMigration.validator.js +64 -0
  729. package/dist/products/validators/joi-validators/update.productDatabaseMigration.validator.js.map +1 -0
  730. package/dist/products/validators/joi-validators/update.productEnv.validator.d.ts +3 -0
  731. package/dist/products/validators/joi-validators/update.productEnv.validator.js +46 -0
  732. package/dist/products/validators/joi-validators/update.productEnv.validator.js.map +1 -0
  733. package/dist/products/validators/joi-validators/update.productFallback.validator.d.ts +3 -0
  734. package/dist/products/validators/joi-validators/update.productFallback.validator.js +60 -0
  735. package/dist/products/validators/joi-validators/update.productFallback.validator.js.map +1 -0
  736. package/dist/products/validators/joi-validators/update.productFeature.validator.d.ts +3 -0
  737. package/dist/products/validators/joi-validators/update.productFeature.validator.js +53 -0
  738. package/dist/products/validators/joi-validators/update.productFeature.validator.js.map +1 -0
  739. package/dist/products/validators/joi-validators/update.productFunction.validator.d.ts +3 -0
  740. package/dist/products/validators/joi-validators/update.productFunction.validator.js +41 -0
  741. package/dist/products/validators/joi-validators/update.productFunction.validator.js.map +1 -0
  742. package/dist/products/validators/joi-validators/update.productGraph.validator.d.ts +3 -0
  743. package/dist/products/validators/joi-validators/update.productGraph.validator.js +88 -0
  744. package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -0
  745. package/dist/products/validators/joi-validators/update.productJob.validator.d.ts +3 -0
  746. package/dist/products/validators/joi-validators/update.productJob.validator.js +50 -0
  747. package/dist/products/validators/joi-validators/update.productJob.validator.js.map +1 -0
  748. package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.d.ts +3 -0
  749. package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js +52 -0
  750. package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js.map +1 -0
  751. package/dist/products/validators/joi-validators/update.productNotification.validator.d.ts +3 -0
  752. package/dist/products/validators/joi-validators/update.productNotification.validator.js +47 -0
  753. package/dist/products/validators/joi-validators/update.productNotification.validator.js.map +1 -0
  754. package/dist/products/validators/joi-validators/update.productNotificationMessage.validator.d.ts +3 -0
  755. package/dist/products/validators/joi-validators/update.productNotificationMessage.validator.js +58 -0
  756. package/dist/products/validators/joi-validators/update.productNotificationMessage.validator.js.map +1 -0
  757. package/dist/products/validators/joi-validators/update.productQuota.validator.d.ts +3 -0
  758. package/dist/products/validators/joi-validators/update.productQuota.validator.js +64 -0
  759. package/dist/products/validators/joi-validators/update.productQuota.validator.js.map +1 -0
  760. package/dist/products/validators/joi-validators/update.userAuth.validator.d.ts +3 -0
  761. package/dist/products/validators/joi-validators/update.userAuth.validator.js +48 -0
  762. package/dist/products/validators/joi-validators/update.userAuth.validator.js.map +1 -0
  763. package/dist/resilience/fallback.service.d.ts +143 -0
  764. package/dist/resilience/fallback.service.js +771 -0
  765. package/dist/resilience/fallback.service.js.map +1 -0
  766. package/dist/resilience/healthcheck.service.d.ts +165 -0
  767. package/dist/resilience/healthcheck.service.js +1019 -0
  768. package/dist/resilience/healthcheck.service.js.map +1 -0
  769. package/dist/resilience/index.d.ts +104 -0
  770. package/dist/resilience/index.js +140 -0
  771. package/dist/resilience/index.js.map +1 -0
  772. package/dist/resilience/quota.service.d.ts +85 -0
  773. package/dist/resilience/quota.service.js +523 -0
  774. package/dist/resilience/quota.service.js.map +1 -0
  775. package/dist/resilience/resilience.service.d.ts +98 -0
  776. package/dist/resilience/resilience.service.js +560 -0
  777. package/dist/resilience/resilience.service.js.map +1 -0
  778. package/dist/resilience/types/index.d.ts +515 -0
  779. package/dist/resilience/types/index.js +29 -0
  780. package/dist/resilience/types/index.js.map +1 -0
  781. package/dist/runtime/runtime-defaults.d.ts +28 -0
  782. package/dist/runtime/runtime-defaults.js +38 -0
  783. package/dist/runtime/runtime-defaults.js.map +1 -0
  784. package/dist/secrets/index.d.ts +10 -0
  785. package/dist/secrets/index.js +33 -0
  786. package/dist/secrets/index.js.map +1 -0
  787. package/dist/secrets/secrets.resolver.d.ts +52 -0
  788. package/dist/secrets/secrets.resolver.js +236 -0
  789. package/dist/secrets/secrets.resolver.js.map +1 -0
  790. package/dist/secrets/secrets.service.d.ts +93 -0
  791. package/dist/secrets/secrets.service.js +246 -0
  792. package/dist/secrets/secrets.service.js.map +1 -0
  793. package/dist/secrets/secrets.types.d.ts +188 -0
  794. package/dist/secrets/secrets.types.js +87 -0
  795. package/dist/secrets/secrets.types.js.map +1 -0
  796. package/dist/sessions/index.d.ts +50 -0
  797. package/dist/sessions/index.js +96 -0
  798. package/dist/sessions/index.js.map +1 -0
  799. package/dist/sessions/sessions.helper.d.ts +88 -0
  800. package/dist/sessions/sessions.helper.js +190 -0
  801. package/dist/sessions/sessions.helper.js.map +1 -0
  802. package/dist/sessions/sessions.resolver.d.ts +188 -0
  803. package/dist/sessions/sessions.resolver.js +603 -0
  804. package/dist/sessions/sessions.resolver.js.map +1 -0
  805. package/dist/sessions/sessions.service.d.ts +196 -0
  806. package/dist/sessions/sessions.service.js +993 -0
  807. package/dist/sessions/sessions.service.js.map +1 -0
  808. package/dist/sessions/types/index.d.ts +347 -0
  809. package/dist/sessions/types/index.js +6 -0
  810. package/dist/sessions/types/index.js.map +1 -0
  811. package/dist/storage/index.d.ts +66 -0
  812. package/dist/storage/index.js +99 -0
  813. package/dist/storage/index.js.map +1 -0
  814. package/dist/storage/storage.service.d.ts +179 -0
  815. package/dist/storage/storage.service.js +938 -0
  816. package/dist/storage/storage.service.js.map +1 -0
  817. package/dist/storage/types/index.d.ts +273 -0
  818. package/dist/storage/types/index.js +6 -0
  819. package/dist/storage/types/index.js.map +1 -0
  820. package/dist/storage/utils/storage.util.d.ts +62 -0
  821. package/dist/storage/utils/storage.util.js +623 -0
  822. package/dist/storage/utils/storage.util.js.map +1 -0
  823. package/dist/types/actions.types.d.ts +0 -0
  824. package/dist/types/actions.types.js +1 -0
  825. package/dist/types/actions.types.js.map +1 -0
  826. package/dist/types/appBuilder.types.d.ts +316 -0
  827. package/dist/types/appBuilder.types.js +3 -0
  828. package/dist/types/appBuilder.types.js.map +1 -0
  829. package/dist/types/database.types.d.ts +9 -0
  830. package/dist/types/database.types.js +3 -0
  831. package/dist/types/database.types.js.map +1 -0
  832. package/dist/types/enums.d.ts +232 -0
  833. package/dist/types/enums.js +262 -0
  834. package/dist/types/enums.js.map +1 -0
  835. package/dist/types/index.d.ts +12 -0
  836. package/dist/types/index.js +29 -0
  837. package/dist/types/index.js.map +1 -0
  838. package/dist/types/index.types.d.ts +37 -0
  839. package/dist/types/index.types.js +18 -0
  840. package/dist/types/index.types.js.map +1 -0
  841. package/dist/types/inputs.types.d.ts +114 -0
  842. package/dist/types/inputs.types.js +44 -0
  843. package/dist/types/inputs.types.js.map +1 -0
  844. package/dist/types/logs.types.d.ts +19 -0
  845. package/dist/types/logs.types.js +8 -0
  846. package/dist/types/logs.types.js.map +1 -0
  847. package/dist/types/pricing.types.d.ts +4 -0
  848. package/dist/types/pricing.types.js +3 -0
  849. package/dist/types/pricing.types.js.map +1 -0
  850. package/dist/types/processor.types.d.ts +602 -0
  851. package/dist/types/processor.types.js +19 -0
  852. package/dist/types/processor.types.js.map +1 -0
  853. package/dist/types/productsBuilder.types.d.ts +1583 -0
  854. package/dist/types/productsBuilder.types.js +303 -0
  855. package/dist/types/productsBuilder.types.js.map +1 -0
  856. package/dist/types/request-tracker.interface.d.ts +0 -0
  857. package/dist/types/request-tracker.interface.js +1 -0
  858. package/dist/types/request-tracker.interface.js.map +1 -0
  859. package/dist/types/requests.types.d.ts +8 -0
  860. package/dist/types/requests.types.js +3 -0
  861. package/dist/types/requests.types.js.map +1 -0
  862. package/dist/types/workspaces.types.d.ts +28 -0
  863. package/dist/types/workspaces.types.js +4 -0
  864. package/dist/types/workspaces.types.js.map +1 -0
  865. package/dist/utils/constants.d.ts +1 -0
  866. package/dist/utils/constants.js +5 -0
  867. package/dist/utils/constants.js.map +1 -0
  868. package/dist/utils/index.d.ts +2 -0
  869. package/dist/utils/index.js +109 -0
  870. package/dist/utils/index.js.map +1 -0
  871. package/dist/vector/actions/action-manager.d.ts +140 -0
  872. package/dist/vector/actions/action-manager.js +356 -0
  873. package/dist/vector/actions/action-manager.js.map +1 -0
  874. package/dist/vector/adapters/base.adapter.d.ts +169 -0
  875. package/dist/vector/adapters/base.adapter.js +218 -0
  876. package/dist/vector/adapters/base.adapter.js.map +1 -0
  877. package/dist/vector/adapters/index.d.ts +10 -0
  878. package/dist/vector/adapters/index.js +19 -0
  879. package/dist/vector/adapters/index.js.map +1 -0
  880. package/dist/vector/adapters/memory.adapter.d.ts +85 -0
  881. package/dist/vector/adapters/memory.adapter.js +505 -0
  882. package/dist/vector/adapters/memory.adapter.js.map +1 -0
  883. package/dist/vector/adapters/pinecone.adapter.d.ts +52 -0
  884. package/dist/vector/adapters/pinecone.adapter.js +433 -0
  885. package/dist/vector/adapters/pinecone.adapter.js.map +1 -0
  886. package/dist/vector/adapters/qdrant.adapter.d.ts +56 -0
  887. package/dist/vector/adapters/qdrant.adapter.js +442 -0
  888. package/dist/vector/adapters/qdrant.adapter.js.map +1 -0
  889. package/dist/vector/adapters/weaviate.adapter.d.ts +68 -0
  890. package/dist/vector/adapters/weaviate.adapter.js +661 -0
  891. package/dist/vector/adapters/weaviate.adapter.js.map +1 -0
  892. package/dist/vector/index.d.ts +37 -0
  893. package/dist/vector/index.js +72 -0
  894. package/dist/vector/index.js.map +1 -0
  895. package/dist/vector/types/action.interface.d.ts +195 -0
  896. package/dist/vector/types/action.interface.js +100 -0
  897. package/dist/vector/types/action.interface.js.map +1 -0
  898. package/dist/vector/types/connection.interface.d.ts +151 -0
  899. package/dist/vector/types/connection.interface.js +8 -0
  900. package/dist/vector/types/connection.interface.js.map +1 -0
  901. package/dist/vector/types/embedding.interface.d.ts +144 -0
  902. package/dist/vector/types/embedding.interface.js +8 -0
  903. package/dist/vector/types/embedding.interface.js.map +1 -0
  904. package/dist/vector/types/enums.d.ts +104 -0
  905. package/dist/vector/types/enums.js +113 -0
  906. package/dist/vector/types/enums.js.map +1 -0
  907. package/dist/vector/types/index.d.ts +11 -0
  908. package/dist/vector/types/index.js +23 -0
  909. package/dist/vector/types/index.js.map +1 -0
  910. package/dist/vector/types/vector.interface.d.ts +315 -0
  911. package/dist/vector/types/vector.interface.js +8 -0
  912. package/dist/vector/types/vector.interface.js.map +1 -0
  913. package/dist/vector/utils/index.d.ts +7 -0
  914. package/dist/vector/utils/index.js +13 -0
  915. package/dist/vector/utils/index.js.map +1 -0
  916. package/dist/vector/utils/metadata-schema.d.ts +14 -0
  917. package/dist/vector/utils/metadata-schema.js +79 -0
  918. package/dist/vector/utils/metadata-schema.js.map +1 -0
  919. package/dist/vector/utils/vector-error.d.ts +69 -0
  920. package/dist/vector/utils/vector-error.js +116 -0
  921. package/dist/vector/utils/vector-error.js.map +1 -0
  922. package/dist/vector/vector-database.service.d.ts +511 -0
  923. package/dist/vector/vector-database.service.js +1073 -0
  924. package/dist/vector/vector-database.service.js.map +1 -0
  925. package/dist/vector/vector.service.d.ts +283 -0
  926. package/dist/vector/vector.service.js +544 -0
  927. package/dist/vector/vector.service.js.map +1 -0
  928. package/dist/warehouse/executor/index.d.ts +5 -0
  929. package/dist/warehouse/executor/index.js +12 -0
  930. package/dist/warehouse/executor/index.js.map +1 -0
  931. package/dist/warehouse/executor/joins/index.d.ts +5 -0
  932. package/dist/warehouse/executor/joins/index.js +11 -0
  933. package/dist/warehouse/executor/joins/index.js.map +1 -0
  934. package/dist/warehouse/executor/joins/join-executor.d.ts +101 -0
  935. package/dist/warehouse/executor/joins/join-executor.js +493 -0
  936. package/dist/warehouse/executor/joins/join-executor.js.map +1 -0
  937. package/dist/warehouse/executor/joins/semantic-join.d.ts +64 -0
  938. package/dist/warehouse/executor/joins/semantic-join.js +241 -0
  939. package/dist/warehouse/executor/joins/semantic-join.js.map +1 -0
  940. package/dist/warehouse/executor/single-source-executor.d.ts +155 -0
  941. package/dist/warehouse/executor/single-source-executor.js +573 -0
  942. package/dist/warehouse/executor/single-source-executor.js.map +1 -0
  943. package/dist/warehouse/index.d.ts +79 -0
  944. package/dist/warehouse/index.js +111 -0
  945. package/dist/warehouse/index.js.map +1 -0
  946. package/dist/warehouse/parser/index.d.ts +4 -0
  947. package/dist/warehouse/parser/index.js +10 -0
  948. package/dist/warehouse/parser/index.js.map +1 -0
  949. package/dist/warehouse/parser/query-parser.d.ts +181 -0
  950. package/dist/warehouse/parser/query-parser.js +415 -0
  951. package/dist/warehouse/parser/query-parser.js.map +1 -0
  952. package/dist/warehouse/registry/data-source-registry.d.ts +207 -0
  953. package/dist/warehouse/registry/data-source-registry.js +396 -0
  954. package/dist/warehouse/registry/data-source-registry.js.map +1 -0
  955. package/dist/warehouse/registry/index.d.ts +4 -0
  956. package/dist/warehouse/registry/index.js +9 -0
  957. package/dist/warehouse/registry/index.js.map +1 -0
  958. package/dist/warehouse/transactions/index.d.ts +4 -0
  959. package/dist/warehouse/transactions/index.js +9 -0
  960. package/dist/warehouse/transactions/index.js.map +1 -0
  961. package/dist/warehouse/transactions/saga-orchestrator.d.ts +92 -0
  962. package/dist/warehouse/transactions/saga-orchestrator.js +383 -0
  963. package/dist/warehouse/transactions/saga-orchestrator.js.map +1 -0
  964. package/dist/warehouse/types/index.d.ts +9 -0
  965. package/dist/warehouse/types/index.js +33 -0
  966. package/dist/warehouse/types/index.js.map +1 -0
  967. package/dist/warehouse/types/join.interface.d.ts +225 -0
  968. package/dist/warehouse/types/join.interface.js +87 -0
  969. package/dist/warehouse/types/join.interface.js.map +1 -0
  970. package/dist/warehouse/types/query.interface.d.ts +232 -0
  971. package/dist/warehouse/types/query.interface.js +9 -0
  972. package/dist/warehouse/types/query.interface.js.map +1 -0
  973. package/dist/warehouse/types/transaction.interface.d.ts +236 -0
  974. package/dist/warehouse/types/transaction.interface.js +74 -0
  975. package/dist/warehouse/types/transaction.interface.js.map +1 -0
  976. package/dist/warehouse/types/where.interface.d.ts +208 -0
  977. package/dist/warehouse/types/where.interface.js +89 -0
  978. package/dist/warehouse/types/where.interface.js.map +1 -0
  979. package/dist/warehouse/warehouse.service.d.ts +200 -0
  980. package/dist/warehouse/warehouse.service.js +470 -0
  981. package/dist/warehouse/warehouse.service.js.map +1 -0
  982. package/dist/workflows/index.d.ts +30 -0
  983. package/dist/workflows/index.js +64 -0
  984. package/dist/workflows/index.js.map +1 -0
  985. package/dist/workflows/types/index.d.ts +6 -0
  986. package/dist/workflows/types/index.js +23 -0
  987. package/dist/workflows/types/index.js.map +1 -0
  988. package/dist/workflows/types/workflows.types.d.ts +1095 -0
  989. package/dist/workflows/types/workflows.types.js +13 -0
  990. package/dist/workflows/types/workflows.types.js.map +1 -0
  991. package/dist/workflows/workflow-builder.d.ts +70 -0
  992. package/dist/workflows/workflow-builder.js +353 -0
  993. package/dist/workflows/workflow-builder.js.map +1 -0
  994. package/dist/workflows/workflow-executor.d.ts +289 -0
  995. package/dist/workflows/workflow-executor.js +2467 -0
  996. package/dist/workflows/workflow-executor.js.map +1 -0
  997. package/dist/workflows/workflows.service.d.ts +412 -0
  998. package/dist/workflows/workflows.service.js +2233 -0
  999. package/dist/workflows/workflows.service.js.map +1 -0
  1000. package/package.json +3 -2
@@ -0,0 +1,2467 @@
1
+ "use strict";
2
+ /**
3
+ * WorkflowExecutor - Executes workflow steps and manages rollbacks
4
+ *
5
+ * Handles the actual execution of workflow steps, including:
6
+ * - Processing each step type (action, database, notification, etc.)
7
+ * - Managing rollback on failure
8
+ * - Tracking workflow state and completed steps
9
+ * - Handling signals and checkpoints
10
+ */
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ var _a, _b;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.WorkflowExecutor = void 0;
17
+ const crypto_1 = require("crypto");
18
+ const processor_service_1 = __importDefault(require("../processor/services/processor.service"));
19
+ const products_service_1 = __importDefault(require("../products/services/products.service"));
20
+ const processorApi_service_1 = require("../api/services/processorApi.service");
21
+ const workflowApi_service_1 = require("../api/services/workflowApi.service");
22
+ const graph_1 = require("../graph");
23
+ const database_1 = require("../database");
24
+ const brokers_1 = require("../brokers");
25
+ const storage_1 = require("../storage");
26
+ const vector_1 = require("../vector");
27
+ const resilience_1 = require("../resilience");
28
+ const logs_service_1 = __importDefault(require("../logs/logs.service"));
29
+ const logs_types_1 = require("../logs/logs.types");
30
+ const types_1 = require("../types");
31
+ const inputs_types_1 = require("../types/inputs.types");
32
+ const processor_utils_1 = require("../processor/utils/processor.utils");
33
+ const productsBuilder_types_1 = require("../types/productsBuilder.types");
34
+ const date_fns_1 = require("date-fns");
35
+ /** Only log when DUCTAPE_DEBUG is set to avoid sync I/O and serialization cost in hot path */
36
+ const debugLog = typeof process !== 'undefined' && (((_a = process.env) === null || _a === void 0 ? void 0 : _a.DUCTAPE_DEBUG) === 'true' || ((_b = process.env) === null || _b === void 0 ? void 0 : _b.DUCTAPE_DEBUG) === '1')
37
+ ? (...args) => console.log(...args)
38
+ : () => { };
39
+ /** Always-on step/summary logging for visibility in tests and support */
40
+ const stepLog = typeof process !== 'undefined'
41
+ ? (msg, data) => {
42
+ if (data != null && Object.keys(data).length > 0) {
43
+ console.log(`[WorkflowExecutor] ${msg}`, data);
44
+ }
45
+ else {
46
+ console.log(`[WorkflowExecutor] ${msg}`);
47
+ }
48
+ }
49
+ : () => { };
50
+ /** Normalize error to a string and extract HTTP details when present (e.g. Axios) */
51
+ function formatErrorDetails(error) {
52
+ var _a, _b, _c, _d;
53
+ const err = error;
54
+ const message = (_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : String(error);
55
+ const out = { message };
56
+ if (err === null || err === void 0 ? void 0 : err.stack)
57
+ out.stack = err.stack;
58
+ if (err === null || err === void 0 ? void 0 : err.response) {
59
+ out.status = (_b = err.response) === null || _b === void 0 ? void 0 : _b.status;
60
+ const data = (_c = err.response) === null || _c === void 0 ? void 0 : _c.data;
61
+ out.responseBody = data;
62
+ // Prefer API error reason over generic "Request failed with status code N"
63
+ const apiErrors = data === null || data === void 0 ? void 0 : data.errors;
64
+ if (apiErrors != null) {
65
+ out.reason = typeof apiErrors === 'string' ? apiErrors : ((_d = apiErrors === null || apiErrors === void 0 ? void 0 : apiErrors.message) !== null && _d !== void 0 ? _d : JSON.stringify(apiErrors));
66
+ }
67
+ }
68
+ return out;
69
+ }
70
+ /**
71
+ * WorkflowExecutor handles the execution of workflow steps
72
+ */
73
+ class WorkflowExecutor {
74
+ constructor(config, workflow, options, private_key, sessionLogFields, preInitializedBuilder) {
75
+ var _a, _b;
76
+ this._processorService = null;
77
+ this._graphService = null;
78
+ this._databaseService = null;
79
+ this._brokersService = null;
80
+ this._storageService = null;
81
+ this._vectorService = null;
82
+ this._quotaService = null;
83
+ this._fallbackService = null;
84
+ this.productId = null;
85
+ /** Pending signals waiting to be resolved */
86
+ this.pendingSignals = new Map();
87
+ /** Signal polling interval (ms) */
88
+ this.signalPollInterval = 2000;
89
+ /** Signal polling timer */
90
+ this.signalPollTimer = null;
91
+ /** Session log fields for logging */
92
+ this.sessionLogFields = {};
93
+ /** LogService instance for logging operations */
94
+ this.logService = null;
95
+ /** Base log fields inherited by all step logs */
96
+ this.baseLogs = null;
97
+ /** Set when a graph step runs; we disconnect once at end of execute() instead of per-step. */
98
+ this.graphConnectionUsed = false;
99
+ /** Pre-fetched bootstrap data per step tag (workflow batch prefetch). */
100
+ this.stepBootstrapCache = new Map();
101
+ debugLog('[WorkflowExecutor] constructor ENTRY', {
102
+ workflow_tag: workflow.tag,
103
+ product: options.product,
104
+ env: options.env,
105
+ hasSessionFields: !!sessionLogFields && Object.keys(sessionLogFields).length > 0,
106
+ });
107
+ this.config = config;
108
+ this.workflow = workflow;
109
+ this.sessionLogFields = sessionLogFields || {};
110
+ this._privateKey = private_key || '';
111
+ this.preInitializedProduct = Boolean(preInitializedBuilder);
112
+ // Use pre-initialized builder from WorkflowService when provided to avoid duplicate initProduct API call
113
+ this.productBuilder = preInitializedBuilder !== null && preInitializedBuilder !== void 0 ? preInitializedBuilder : new products_service_1.default({
114
+ workspace_id: config.workspace_id,
115
+ public_key: config.public_key,
116
+ user_id: config.user_id,
117
+ token: config.token,
118
+ env_type: config.env_type,
119
+ access_key: config.access_key,
120
+ workspace_private_key: this._privateKey || undefined,
121
+ });
122
+ // Lightweight API services (created up front)
123
+ this.processorApiService = new processorApi_service_1.ProcessorApiService(config.env_type);
124
+ this.workflowApiService = new workflowApi_service_1.WorkflowApiService(config.env_type);
125
+ // Heavy services are lazy-initialized on first use (getProcessorService, getGraphService, etc.)
126
+ // Initialize workflow state
127
+ this.state = {
128
+ workflow_id: (0, crypto_1.randomUUID)(),
129
+ workflow_tag: workflow.tag,
130
+ product: options.product,
131
+ env: options.env,
132
+ input: options.input,
133
+ steps: {},
134
+ completed_steps: [],
135
+ step_timings: [],
136
+ state: {},
137
+ status: types_1.WorkflowStatus.PENDING,
138
+ started_at: Date.now(),
139
+ };
140
+ debugLog('[WorkflowExecutor] constructor DONE', {
141
+ workflow_id: this.state.workflow_id,
142
+ workflow_tag: this.state.workflow_tag,
143
+ steps_count: (_b = (_a = workflow.steps) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
144
+ });
145
+ }
146
+ /**
147
+ * Get auth payload for API calls
148
+ */
149
+ getAuthPayload() {
150
+ return {
151
+ user_id: this.config.user_id,
152
+ workspace_id: this.config.workspace_id,
153
+ public_key: this.config.public_key,
154
+ token: this.config.token,
155
+ };
156
+ }
157
+ /** Product private key for processor result encryption; must always match backend decryption key. No fallback to workspace key. */
158
+ getProcessorResultEncryptionKey() {
159
+ var _a, _b, _c;
160
+ return (_c = (_b = (_a = this.productBuilder) === null || _a === void 0 ? void 0 : _a.fetchPrivateKey) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : '';
161
+ }
162
+ /** Lazy-initialized processor (shares productBuilder to avoid duplicate product init per step). */
163
+ getProcessorService() {
164
+ if (!this._processorService) {
165
+ this._processorService = new processor_service_1.default({
166
+ workspace_id: this.config.workspace_id,
167
+ public_key: this.config.public_key,
168
+ user_id: this.config.user_id,
169
+ token: this.config.token,
170
+ env_type: this.config.env_type,
171
+ private_key: this._privateKey,
172
+ access_key: this.config.access_key,
173
+ preInitializedProductBuilder: this.productBuilder,
174
+ });
175
+ }
176
+ return this._processorService;
177
+ }
178
+ /** Lazy-initialized graph service. */
179
+ getGraphService() {
180
+ if (!this._graphService) {
181
+ this._graphService = new graph_1.GraphService({
182
+ workspace_id: this.config.workspace_id,
183
+ public_key: this.config.public_key,
184
+ user_id: this.config.user_id,
185
+ token: this.config.token,
186
+ env_type: this.config.env_type,
187
+ private_key: this._privateKey,
188
+ access_key: this.config.access_key,
189
+ });
190
+ }
191
+ return this._graphService;
192
+ }
193
+ /** Lazy-initialized database service. */
194
+ getDatabaseService() {
195
+ if (!this._databaseService) {
196
+ this._databaseService = new database_1.DatabaseService({
197
+ workspace_id: this.config.workspace_id,
198
+ public_key: this.config.public_key,
199
+ user_id: this.config.user_id,
200
+ token: this.config.token,
201
+ env_type: this.config.env_type,
202
+ private_key: this._privateKey,
203
+ access_key: this.config.access_key,
204
+ });
205
+ }
206
+ return this._databaseService;
207
+ }
208
+ /** Lazy-initialized brokers service. Used for produce steps so ctx.messaging.produce uses the same path as ductape.messaging.produce (pool, tracking, cache). */
209
+ getBrokersService() {
210
+ if (!this._brokersService) {
211
+ this._brokersService = new brokers_1.BrokersService({
212
+ workspace_id: this.config.workspace_id,
213
+ public_key: this.config.public_key,
214
+ user_id: this.config.user_id,
215
+ token: this.config.token,
216
+ env_type: this.config.env_type,
217
+ access_key: this.config.access_key,
218
+ redis_client: this.config.redis_client,
219
+ preInitializedProductBuilder: this.productBuilder,
220
+ });
221
+ }
222
+ return this._brokersService;
223
+ }
224
+ /** Lazy-initialized storage service. Used for storage steps (upload/download/delete) instead of processor. */
225
+ getStorageService() {
226
+ if (!this._storageService) {
227
+ this._storageService = new storage_1.StorageService({
228
+ workspace_id: this.config.workspace_id,
229
+ public_key: this.config.public_key,
230
+ user_id: this.config.user_id,
231
+ token: this.config.token,
232
+ env_type: this.config.env_type,
233
+ redis_client: this.config.redis_client,
234
+ private_key: this._privateKey,
235
+ });
236
+ }
237
+ return this._storageService;
238
+ }
239
+ /** Lazy-initialized vector service. Used for vector steps (query/upsert/delete/execute action). */
240
+ getVectorService() {
241
+ if (!this._vectorService) {
242
+ this._vectorService = new vector_1.VectorDatabaseService({
243
+ workspace_id: this.config.workspace_id,
244
+ public_key: this.config.public_key,
245
+ user_id: this.config.user_id,
246
+ token: this.config.token,
247
+ env_type: this.config.env_type,
248
+ redis_client: this.config.redis_client,
249
+ private_key: this._privateKey,
250
+ access_key: this.config.access_key,
251
+ });
252
+ }
253
+ return this._vectorService;
254
+ }
255
+ /** Lazy-initialized quota service. */
256
+ getQuotaService() {
257
+ if (!this._quotaService) {
258
+ this._quotaService = new resilience_1.QuotaService({
259
+ workspace_id: this.config.workspace_id,
260
+ public_key: this.config.public_key,
261
+ user_id: this.config.user_id,
262
+ token: this.config.token,
263
+ env_type: this.config.env_type,
264
+ private_key: this._privateKey,
265
+ });
266
+ }
267
+ return this._quotaService;
268
+ }
269
+ /** Lazy-initialized fallback service. */
270
+ getFallbackService() {
271
+ if (!this._fallbackService) {
272
+ this._fallbackService = new resilience_1.FallbackService({
273
+ workspace_id: this.config.workspace_id,
274
+ public_key: this.config.public_key,
275
+ user_id: this.config.user_id,
276
+ token: this.config.token,
277
+ env_type: this.config.env_type,
278
+ private_key: this._privateKey,
279
+ });
280
+ }
281
+ return this._fallbackService;
282
+ }
283
+ /**
284
+ * Persist workflow execution result to backend
285
+ */
286
+ async persistExecutionResult(status, output, error) {
287
+ debugLog('[WorkflowExecutor] persistExecutionResult ENTRY', {
288
+ workflow_id: this.state.workflow_id,
289
+ workflow_tag: this.state.workflow_tag,
290
+ status,
291
+ hasError: !!error,
292
+ });
293
+ try {
294
+ const resultData = {
295
+ workflow_tag: this.state.workflow_tag,
296
+ input: this.state.input,
297
+ output,
298
+ completed_steps: this.state.completed_steps,
299
+ failed_step: this.state.failed_step,
300
+ step_outputs: this.state.steps,
301
+ error,
302
+ };
303
+ const inputPayload = { product: this.state.product, env: this.state.env, event: this.state.workflow_tag, input: this.state.input };
304
+ const resultStr = JSON.stringify(resultData);
305
+ const inputStr = JSON.stringify(inputPayload);
306
+ const encKey = this.getProcessorResultEncryptionKey();
307
+ const processorResult = {
308
+ process_id: this.state.workflow_id,
309
+ product_id: this.productId || null,
310
+ env: this.state.env,
311
+ component: types_1.LogEventTypes.WORKFLOW,
312
+ status,
313
+ start: this.state.started_at,
314
+ end: Date.now(),
315
+ retryable: true,
316
+ result: encKey ? (0, processor_utils_1.encrypt)(resultStr, encKey) : resultStr,
317
+ feature_id: undefined,
318
+ input: encKey ? (0, processor_utils_1.encrypt)(inputStr, encKey) : inputStr,
319
+ workflow_id: this.state.workflow_id,
320
+ workflow_tag: this.state.workflow_tag,
321
+ product_tag: this.state.product,
322
+ workspace_id: this.config.workspace_id,
323
+ };
324
+ await this.processorApiService.saveResult(processorResult, this.getAuthPayload());
325
+ debugLog('[WorkflowExecutor] persistExecutionResult SUCCESS', { workflow_id: this.state.workflow_id, status });
326
+ }
327
+ catch (err) {
328
+ // Log error but don't throw - persistence failure shouldn't fail the workflow
329
+ debugLog('[WorkflowExecutor] persistExecutionResult FAILED', { workflow_id: this.state.workflow_id, status, error: err });
330
+ }
331
+ }
332
+ /**
333
+ * Step processor results must always use component: 'workflow_step'.
334
+ * step_type is the step kind: action, notification, storage, produce, database_action, graph, vector, quota, fallback, child_workflow, sleep, wait_for_signal, checkpoint, feature.
335
+ */
336
+ getStepTypeForResult(step) {
337
+ var _a;
338
+ if (step.type === types_1.WorkflowStepType.PUBLISH)
339
+ return 'produce';
340
+ return (_a = step.type) !== null && _a !== void 0 ? _a : 'action';
341
+ }
342
+ /**
343
+ * Persist individual step execution to backend (input/output per step in processor result).
344
+ * Processor results for steps always have component: 'workflow_step' and step_type set to the step kind.
345
+ */
346
+ async persistStepResult(step, status, output, error, duration, input) {
347
+ const resolvedInput = input !== null && input !== void 0 ? input : step.input;
348
+ const stepType = this.getStepTypeForResult(step);
349
+ debugLog('[WorkflowExecutor] persistStepResult ENTRY', {
350
+ workflow_id: this.state.workflow_id,
351
+ step_tag: step.tag,
352
+ step_type: stepType,
353
+ status,
354
+ durationMs: duration,
355
+ });
356
+ try {
357
+ // Caller passes the step return value (resolved shape) on success; we persist it as-is
358
+ const stepProcessId = `${this.state.workflow_id}:${step.tag}`;
359
+ const value = status === types_1.LogEventStatus.SUCCESS
360
+ ? output !== undefined && output !== null
361
+ ? output
362
+ : {}
363
+ : { error: error !== null && error !== void 0 ? error : 'Step failed' };
364
+ const resultStr = JSON.stringify(value);
365
+ const inputStr = JSON.stringify(resolvedInput);
366
+ const encKey = this.getProcessorResultEncryptionKey();
367
+ const stepResult = {
368
+ process_id: stepProcessId,
369
+ product_id: this.productId || null,
370
+ env: this.state.env,
371
+ component: types_1.LogEventTypes.WORKFLOW_STEP, // step results always workflow_step
372
+ status,
373
+ start: Date.now() - (duration || 0),
374
+ end: Date.now(),
375
+ retryable: true,
376
+ result: encKey ? (0, processor_utils_1.encrypt)(resultStr, encKey) : resultStr,
377
+ feature_id: undefined,
378
+ input: encKey ? (0, processor_utils_1.encrypt)(inputStr, encKey) : inputStr,
379
+ workflow_id: this.state.workflow_id,
380
+ workflow_tag: this.state.workflow_tag,
381
+ product_tag: this.state.product,
382
+ workspace_id: this.config.workspace_id,
383
+ step_tag: step.tag,
384
+ step_type: stepType, // action | notification | storage | produce | database_action | graph | vector | quota | fallback | child_workflow | sleep | wait_for_signal | checkpoint | feature
385
+ step_error: error,
386
+ step_duration_ms: duration,
387
+ };
388
+ this.processorApiService.saveResult(stepResult, this.getAuthPayload()).then(() => debugLog('[WorkflowExecutor] persistStepResult SUCCESS', { workflow_id: this.state.workflow_id, step_tag: step.tag }), (err) => debugLog('[WorkflowExecutor] persistStepResult FAILED', { workflow_id: this.state.workflow_id, step_tag: step.tag, error: err }));
389
+ }
390
+ catch (err) {
391
+ debugLog('[WorkflowExecutor] persistStepResult ENTRY FAILED', { workflow_id: this.state.workflow_id, step_tag: step.tag, error: err });
392
+ }
393
+ }
394
+ /**
395
+ * Initialize logging service and base log fields
396
+ */
397
+ initializeLogging() {
398
+ var _a;
399
+ if (!this.logService && this.productId) {
400
+ this.logService = new logs_service_1.default({
401
+ product_id: this.productId,
402
+ workspace_id: this.config.workspace_id,
403
+ public_key: this.config.public_key,
404
+ user_id: this.config.user_id,
405
+ token: this.config.token,
406
+ env_type: this.config.env_type,
407
+ workspace_private_key: (_a = this._privateKey) !== null && _a !== void 0 ? _a : undefined,
408
+ });
409
+ // Set up base logs that all step logs inherit
410
+ this.baseLogs = Object.assign({ product_tag: this.state.product, workspace_id: this.config.workspace_id, env: this.state.env, process_id: this.state.workflow_id, type: logs_types_1.LogEventTypes.WORKFLOW, parent_tag: this.state.workflow_tag }, this.sessionLogFields);
411
+ }
412
+ }
413
+ /**
414
+ * Log a step execution event
415
+ */
416
+ logStepEvent(step, message, status, additionalData) {
417
+ if (!this.logService || !this.baseLogs)
418
+ return;
419
+ const stepTypeDisplay = step.type === types_1.WorkflowStepType.PUBLISH ? 'produce' : step.type;
420
+ const stepProcessId = `${this.state.workflow_id}:${step.tag}`;
421
+ this.logService.add(Object.assign(Object.assign({}, this.baseLogs), { process_id: stepProcessId, type: logs_types_1.LogEventTypes.WORKFLOW_STEP, child_tag: step.tag, message,
422
+ status, data: Object.assign({ workflow: this.state.workflow_tag, workflow_id: this.state.workflow_id, step: step.tag, step_type: stepTypeDisplay }, additionalData) }));
423
+ }
424
+ /**
425
+ * Execute the workflow
426
+ */
427
+ async execute() {
428
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
429
+ const startTime = Date.now();
430
+ debugLog('[WorkflowExecutor] execute ENTRY', {
431
+ workflow_id: this.state.workflow_id,
432
+ workflow_tag: this.state.workflow_tag,
433
+ product: this.state.product,
434
+ env: this.state.env,
435
+ });
436
+ try {
437
+ // Track phase so failures before first step are reported as (initialization)
438
+ this.state.current_step = '(initialization)';
439
+ // Skip product init when builder was pre-initialized by WorkflowService (avoids duplicate initProduct API call)
440
+ if (this.preInitializedProduct) {
441
+ this.productId = this.productBuilder.fetchProductId();
442
+ }
443
+ else {
444
+ await this.productBuilder.initializeProductByTag(this.state.product);
445
+ this.productId = this.productBuilder.fetchProductId();
446
+ }
447
+ debugLog('[WorkflowExecutor] execute product initialized', { workflow_id: this.state.workflow_id, product_id: this.productId });
448
+ // Initialize logging after we have product ID
449
+ this.initializeLogging();
450
+ this.state.status = types_1.WorkflowStatus.RUNNING;
451
+ // Get steps in execution order (respecting dependencies)
452
+ const orderedSteps = this.getOrderedSteps();
453
+ stepLog('Ordered steps', {
454
+ count: orderedSteps.length,
455
+ steps: orderedSteps.map((s) => ({ tag: s.tag, type: s.type === types_1.WorkflowStepType.PUBLISH ? 'produce' : s.type })),
456
+ });
457
+ debugLog('[WorkflowExecutor] execute ordered steps', {
458
+ workflow_id: this.state.workflow_id,
459
+ steps_count: orderedSteps.length,
460
+ step_tags: orderedSteps.map((s) => s.tag),
461
+ });
462
+ // Pre-fetch all action/notification/storage bootstrap data in one backend call (cached for step executors)
463
+ try {
464
+ await this.prefetchStepBootstrap(orderedSteps);
465
+ }
466
+ catch (prefetchErr) {
467
+ stepLog('Bootstrap prefetch failed (continuing without prefetch)', {
468
+ error: (_a = prefetchErr === null || prefetchErr === void 0 ? void 0 : prefetchErr.message) !== null && _a !== void 0 ? _a : String(prefetchErr),
469
+ });
470
+ this.stepBootstrapCache.clear();
471
+ }
472
+ // Execute each step
473
+ for (const step of orderedSteps) {
474
+ // Check step condition if present
475
+ if (step.condition && !(await this.evaluateCondition(step.condition))) {
476
+ debugLog('[WorkflowExecutor] execute step SKIPPED (condition)', { workflow_id: this.state.workflow_id, step_tag: step.tag });
477
+ this.logStepEvent(step, `Step ${step.tag} - skipped (condition not met)`, logs_types_1.LogEventStatus.SUCCESS, { skipped: true });
478
+ continue; // Skip step if condition not met
479
+ }
480
+ this.state.current_step = step.tag;
481
+ stepLog('Step start', { tag: step.tag, type: step.type === types_1.WorkflowStepType.PUBLISH ? 'produce' : step.type });
482
+ debugLog('[WorkflowExecutor] execute step START', { workflow_id: this.state.workflow_id, step_tag: step.tag, step_type: step.type });
483
+ // Log step start
484
+ this.logStepEvent(step, `Step ${step.tag} - started`, logs_types_1.LogEventStatus.PROCESSING);
485
+ const result = await this.executeStep(step);
486
+ stepLog('Step end', Object.assign({ tag: step.tag, type: step.type === types_1.WorkflowStepType.PUBLISH ? 'produce' : step.type, success: result.success, duration_ms: result.duration }, (result.error && { error: result.error })));
487
+ if (result.error) {
488
+ console.warn(`[WorkflowExecutor] Step "${step.tag}" error:`, result.error);
489
+ }
490
+ debugLog('[WorkflowExecutor] execute step END', {
491
+ workflow_id: this.state.workflow_id,
492
+ step_tag: step.tag,
493
+ success: result.success,
494
+ durationMs: result.duration,
495
+ hasError: !!result.error,
496
+ input: result.input,
497
+ output: result.output,
498
+ });
499
+ // Log step completion
500
+ this.logStepEvent(step, result.success ? `Step ${step.tag} - completed` : `Step ${step.tag} - failed`, result.success ? logs_types_1.LogEventStatus.SUCCESS : logs_types_1.LogEventStatus.FAIL, { duration: result.duration, error: result.error });
501
+ // Step return value = resolved step.output schema with primitive result, or raw when no schema
502
+ const outputSchema = step.output;
503
+ const hasOutputSchema = outputSchema && typeof outputSchema === 'object' && !Array.isArray(outputSchema) && Object.keys(outputSchema).length > 0;
504
+ let stepReturnValue = result.output;
505
+ if (result.success && hasOutputSchema) {
506
+ try {
507
+ stepReturnValue = await this.resolveInput(outputSchema, result.output);
508
+ }
509
+ catch (_p) {
510
+ stepReturnValue = result.output;
511
+ }
512
+ }
513
+ else if (!result.success) {
514
+ stepReturnValue = undefined;
515
+ }
516
+ console.warn(`[WorkflowExecutor] Step "${step.tag}" output:`, stepReturnValue);
517
+ // Persist step result to backend (use step return shape, not raw primitive)
518
+ await this.persistStepResult(step, result.success ? types_1.LogEventStatus.SUCCESS : types_1.LogEventStatus.FAIL, stepReturnValue, result.error, result.duration, result.input);
519
+ this.state.step_timings.push({
520
+ tag: step.tag,
521
+ duration_ms: result.duration,
522
+ success: result.success,
523
+ });
524
+ if (!result.success) {
525
+ this.state.failed_step = step.tag;
526
+ stepLog('Step failed', { tag: step.tag, error: result.error, allow_fail: (_b = step.options) === null || _b === void 0 ? void 0 : _b.allow_fail, optional: (_c = step.options) === null || _c === void 0 ? void 0 : _c.optional });
527
+ debugLog('[WorkflowExecutor] execute step FAILED', {
528
+ workflow_id: this.state.workflow_id,
529
+ step_tag: step.tag,
530
+ error: result.error,
531
+ allow_fail: (_d = step.options) === null || _d === void 0 ? void 0 : _d.allow_fail,
532
+ optional: (_e = step.options) === null || _e === void 0 ? void 0 : _e.optional,
533
+ });
534
+ // Check if step allows failure
535
+ if ((_f = step.options) === null || _f === void 0 ? void 0 : _f.allow_fail) {
536
+ // Store error but continue
537
+ this.state.steps[step.tag] = { error: result.error };
538
+ continue;
539
+ }
540
+ // Check if step is optional
541
+ if ((_g = step.options) === null || _g === void 0 ? void 0 : _g.optional) {
542
+ // Don't trigger rollback, just continue
543
+ continue;
544
+ }
545
+ // Trigger rollback
546
+ this.state.status = types_1.WorkflowStatus.ROLLING_BACK;
547
+ debugLog('[WorkflowExecutor] execute ROLLBACK START', { workflow_id: this.state.workflow_id, failed_step: step.tag, reason: result.error });
548
+ const rollbackResult = await this.executeRollback(step.tag, result.error || 'Step failed');
549
+ debugLog('[WorkflowExecutor] execute ROLLBACK END', {
550
+ workflow_id: this.state.workflow_id,
551
+ success: rollbackResult.success,
552
+ rolled_back_steps: rollbackResult.rolled_back_steps,
553
+ failed_rollbacks: (_j = (_h = rollbackResult.failed_steps) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : 0,
554
+ });
555
+ // Persist failed workflow result
556
+ await this.persistExecutionResult(types_1.LogEventStatus.FAIL, undefined, result.error);
557
+ stepLog('Run finished (rollback)', {
558
+ status: types_1.WorkflowStatus.ROLLED_BACK,
559
+ failed_step: step.tag,
560
+ error: result.error,
561
+ completed_steps: this.state.completed_steps,
562
+ step_timings: this.state.step_timings,
563
+ });
564
+ await ((_k = this.logService) === null || _k === void 0 ? void 0 : _k.publish());
565
+ if (this.graphConnectionUsed) {
566
+ await this.getGraphService().disconnect().catch(() => { });
567
+ await this.getProcessorService().disconnectBrokerConnections().catch(() => { });
568
+ if (this._brokersService)
569
+ await this._brokersService.disconnectAll().catch(() => { });
570
+ await this.getProcessorService().disconnectMailTransporters().catch(() => { });
571
+ await this.getProcessorService().disconnectFirebaseApps().catch(() => { });
572
+ await this.getProcessorService().disconnectSmsClients().catch(() => { });
573
+ }
574
+ return {
575
+ status: types_1.WorkflowStatus.ROLLED_BACK,
576
+ workflow_id: this.state.workflow_id,
577
+ error: result.error,
578
+ execution_time: Date.now() - startTime,
579
+ completed_steps: this.state.completed_steps,
580
+ step_timings: this.state.step_timings,
581
+ failed_step: step.tag,
582
+ rollback_info: {
583
+ triggered_by: step.tag,
584
+ reason: result.error || 'Step failed',
585
+ rolled_back_steps: rollbackResult.rolled_back_steps,
586
+ failed_rollbacks: rollbackResult.failed_steps,
587
+ },
588
+ };
589
+ }
590
+ // Store step return shape in state (same value we persisted)
591
+ this.state.steps[step.tag] = stepReturnValue;
592
+ this.state.completed_steps.push(step.tag);
593
+ }
594
+ this.state.status = types_1.WorkflowStatus.COMPLETED;
595
+ this.state.ended_at = Date.now();
596
+ // Determine output - use last step output or aggregate (resolves $ operators)
597
+ const output = await this.determineWorkflowOutput();
598
+ stepLog('Run finished (completed)', {
599
+ status: types_1.WorkflowStatus.COMPLETED,
600
+ completed_steps: this.state.completed_steps,
601
+ step_timings: this.state.step_timings,
602
+ execution_time_ms: Date.now() - startTime,
603
+ });
604
+ debugLog('[WorkflowExecutor] execute COMPLETED', {
605
+ workflow_id: this.state.workflow_id,
606
+ workflow_tag: this.state.workflow_tag,
607
+ completed_steps: this.state.completed_steps.length,
608
+ execution_time_ms: Date.now() - startTime,
609
+ });
610
+ // Persist successful workflow result
611
+ await this.persistExecutionResult(types_1.LogEventStatus.SUCCESS, output);
612
+ // Fire-and-forget log publish on success so we don't block on log upload
613
+ (_l = this.logService) === null || _l === void 0 ? void 0 : _l.publish().catch(() => { });
614
+ if (this.graphConnectionUsed) {
615
+ await this.getGraphService().disconnect().catch(() => { });
616
+ await this.getProcessorService().disconnectBrokerConnections().catch(() => { });
617
+ if (this._brokersService)
618
+ await this._brokersService.disconnectAll().catch(() => { });
619
+ await this.getProcessorService().disconnectMailTransporters().catch(() => { });
620
+ await this.getProcessorService().disconnectFirebaseApps().catch(() => { });
621
+ await this.getProcessorService().disconnectSmsClients().catch(() => { });
622
+ }
623
+ return {
624
+ status: types_1.WorkflowStatus.COMPLETED,
625
+ workflow_id: this.state.workflow_id,
626
+ output: output,
627
+ execution_time: Date.now() - startTime,
628
+ completed_steps: this.state.completed_steps,
629
+ step_timings: this.state.step_timings,
630
+ };
631
+ }
632
+ catch (error) {
633
+ this.state.status = types_1.WorkflowStatus.FAILED;
634
+ this.state.ended_at = Date.now();
635
+ const details = formatErrorDetails(error);
636
+ const failedAt = (_m = this.state.current_step) !== null && _m !== void 0 ? _m : '(unknown)';
637
+ debugLog('[WorkflowExecutor] execute FAILED (exception)', Object.assign(Object.assign({ workflow_id: this.state.workflow_id, workflow_tag: this.state.workflow_tag, failed_at: failedAt, completed_steps: this.state.completed_steps, error: details.message }, (details.status != null && { http_status: details.status })), (details.responseBody != null && { response_body: details.responseBody })));
638
+ if (details.stack) {
639
+ debugLog('[WorkflowExecutor] execute FAILED stack', details.stack);
640
+ }
641
+ // Persist failed workflow result with clear failure reason
642
+ const errorSummary = details.status != null
643
+ ? `Failed at ${failedAt}: ${details.message} (HTTP ${details.status})`
644
+ : `Failed at ${failedAt}: ${details.message}`;
645
+ stepLog('Run finished (failed - exception)', Object.assign({ status: types_1.WorkflowStatus.FAILED, failed_step: failedAt, error: errorSummary, completed_steps: this.state.completed_steps, step_timings: this.state.step_timings }, (details.reason && { reason: details.reason })));
646
+ await this.persistExecutionResult(types_1.LogEventStatus.FAIL, undefined, errorSummary);
647
+ await ((_o = this.logService) === null || _o === void 0 ? void 0 : _o.publish());
648
+ if (this.graphConnectionUsed) {
649
+ await this.getGraphService().disconnect().catch(() => { });
650
+ await this.getProcessorService().disconnectBrokerConnections().catch(() => { });
651
+ if (this._brokersService)
652
+ await this._brokersService.disconnectAll().catch(() => { });
653
+ await this.getProcessorService().disconnectMailTransporters().catch(() => { });
654
+ await this.getProcessorService().disconnectFirebaseApps().catch(() => { });
655
+ await this.getProcessorService().disconnectSmsClients().catch(() => { });
656
+ }
657
+ return {
658
+ status: types_1.WorkflowStatus.FAILED,
659
+ workflow_id: this.state.workflow_id,
660
+ error: errorSummary,
661
+ execution_time: Date.now() - startTime,
662
+ completed_steps: this.state.completed_steps,
663
+ step_timings: this.state.step_timings,
664
+ failed_step: this.state.current_step,
665
+ };
666
+ }
667
+ }
668
+ /**
669
+ * Execute a single step
670
+ */
671
+ async executeStep(step) {
672
+ const startTime = Date.now();
673
+ debugLog('[WorkflowExecutor] executeStep ENTRY', {
674
+ workflow_id: this.state.workflow_id,
675
+ step_tag: step.tag,
676
+ step_type: step.type,
677
+ });
678
+ let resolvedInput = {};
679
+ try {
680
+ // Resolve input with data references and all $ operators
681
+ resolvedInput = (await this.resolveInput(step.input || {}));
682
+ debugLog('[WorkflowExecutor] executeStep input', {
683
+ workflow_id: this.state.workflow_id,
684
+ step_tag: step.tag,
685
+ input: resolvedInput,
686
+ });
687
+ let output;
688
+ // Route steps to dedicated services; only action and notification use ProcessorService.
689
+ switch (step.type) {
690
+ case types_1.WorkflowStepType.ACTION:
691
+ output = await this.executeActionStep(step, resolvedInput);
692
+ break;
693
+ case types_1.WorkflowStepType.DATABASE_ACTION:
694
+ output = await this.executeDatabaseStep(step, resolvedInput);
695
+ break;
696
+ case types_1.WorkflowStepType.NOTIFICATION:
697
+ output = await this.executeNotificationStep(step, resolvedInput);
698
+ break;
699
+ case types_1.WorkflowStepType.STORAGE:
700
+ output = await this.executeStorageStep(step, resolvedInput);
701
+ break;
702
+ case types_1.WorkflowStepType.PUBLISH:
703
+ case types_1.WorkflowStepType.PRODUCE:
704
+ output = await this.executeProduceStep(step, resolvedInput);
705
+ break;
706
+ case types_1.WorkflowStepType.GRAPH:
707
+ output = await this.executeGraphStep(step, resolvedInput);
708
+ break;
709
+ case types_1.WorkflowStepType.VECTOR:
710
+ output = await this.executeVectorStep(step, resolvedInput);
711
+ break;
712
+ case types_1.WorkflowStepType.QUOTA:
713
+ output = await this.executeQuotaStep(step, resolvedInput);
714
+ break;
715
+ case types_1.WorkflowStepType.FALLBACK:
716
+ output = await this.executeFallbackStep(step, resolvedInput);
717
+ break;
718
+ case types_1.WorkflowStepType.CHILD_WORKFLOW:
719
+ output = await this.executeChildWorkflowStep(step, resolvedInput);
720
+ break;
721
+ case types_1.WorkflowStepType.SLEEP:
722
+ await this.executeSleepStep(step, resolvedInput);
723
+ output = { slept: true };
724
+ break;
725
+ case types_1.WorkflowStepType.WAIT_FOR_SIGNAL:
726
+ output = await this.executeWaitForSignalStep(step, resolvedInput);
727
+ break;
728
+ case types_1.WorkflowStepType.CHECKPOINT:
729
+ await this.executeCheckpointStep(step, resolvedInput);
730
+ output = { checkpoint: step.tag };
731
+ break;
732
+ default:
733
+ stepLog('Step type not implemented (passthrough)', { tag: step.tag, type: step.type });
734
+ debugLog('[WorkflowExecutor] executeStep unknown step type (passthrough)', { step_tag: step.tag, step_type: step.type });
735
+ output = resolvedInput;
736
+ }
737
+ // For action steps with no app: if step.output is a template with $ refs (e.g. $Sequence{main}{step-a}{value}-b),
738
+ // resolve it so downstream steps get the correct value (checkpoint / closure-style steps).
739
+ if (step.type === types_1.WorkflowStepType.ACTION &&
740
+ !step.app &&
741
+ step.output &&
742
+ typeof step.output === 'object' &&
743
+ !Array.isArray(step.output) &&
744
+ this.hasOperatorRefsInOutput(step.output)) {
745
+ try {
746
+ output = (await this.resolveInput(step.output));
747
+ }
748
+ catch (_a) {
749
+ // keep output from executeActionStep if resolve fails
750
+ }
751
+ }
752
+ const duration = Date.now() - startTime;
753
+ debugLog('[WorkflowExecutor] executeStep output', {
754
+ workflow_id: this.state.workflow_id,
755
+ step_tag: step.tag,
756
+ output,
757
+ durationMs: duration,
758
+ });
759
+ return {
760
+ success: true,
761
+ input: resolvedInput,
762
+ output,
763
+ duration,
764
+ };
765
+ }
766
+ catch (error) {
767
+ const duration = Date.now() - startTime;
768
+ const details = formatErrorDetails(error);
769
+ // Use API reason when present so we log why it failed (e.g. "Notification X not found") not just "Request failed with status code 500"
770
+ const stepErrorMsg = details.reason != null
771
+ ? (details.status != null ? `${details.reason} (HTTP ${details.status})` : details.reason)
772
+ : (details.status != null ? `${details.message} (HTTP ${details.status})` : details.message);
773
+ debugLog('[WorkflowExecutor] executeStep FAILED', Object.assign(Object.assign({ workflow_id: this.state.workflow_id, step_tag: step.tag, step_type: step.type, durationMs: duration, input: resolvedInput, error: stepErrorMsg }, (details.status != null && { http_status: details.status })), (details.responseBody != null && { response_body: details.responseBody })));
774
+ return {
775
+ success: false,
776
+ input: resolvedInput,
777
+ error: stepErrorMsg,
778
+ duration,
779
+ };
780
+ }
781
+ }
782
+ /**
783
+ * Execute an action step
784
+ */
785
+ async executeActionStep(step, input) {
786
+ var _a, _b;
787
+ debugLog('[WorkflowExecutor] executeActionStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, app: step.app });
788
+ // Step that only returns (no component call): no app → passthrough, output = resolved input
789
+ if (!step.app) {
790
+ return input;
791
+ }
792
+ return this.getProcessorService().processAction({
793
+ product: this.state.product,
794
+ env: this.state.env,
795
+ app: step.app,
796
+ action: step.event,
797
+ input: input,
798
+ retries: ((_a = step.options) === null || _a === void 0 ? void 0 : _a.retries) || 0,
799
+ cache: (_b = step.options) === null || _b === void 0 ? void 0 : _b.cache,
800
+ preloadedBootstrap: this.stepBootstrapCache.get(step.tag),
801
+ });
802
+ }
803
+ /**
804
+ * Execute a database step: use query/insert/update/delete/upsert for DB operations, execute() for named actions.
805
+ */
806
+ async executeDatabaseStep(step, input) {
807
+ const database = step.database;
808
+ const product = this.state.product;
809
+ const env = this.state.env;
810
+ const event = (step.event || '').toLowerCase();
811
+ const db = this.getDatabaseService();
812
+ const opts = Object.assign({ product, env, database }, input);
813
+ debugLog('[WorkflowExecutor] executeDatabaseStep', {
814
+ workflow_id: this.state.workflow_id,
815
+ step_tag: step.tag,
816
+ database,
817
+ event,
818
+ });
819
+ switch (event) {
820
+ case 'query':
821
+ return db.query(opts);
822
+ case 'insert':
823
+ return db.insert(opts);
824
+ case 'update':
825
+ return db.update(opts);
826
+ case 'delete':
827
+ return db.delete(opts);
828
+ case 'upsert':
829
+ return db.upsert(opts);
830
+ default:
831
+ return db.execute({
832
+ product,
833
+ env,
834
+ database,
835
+ action: step.event,
836
+ input: input,
837
+ });
838
+ }
839
+ }
840
+ /**
841
+ * Execute a notification step
842
+ */
843
+ async executeNotificationStep(step, input) {
844
+ var _a;
845
+ const event = `${step.notification}:${step.event}`;
846
+ debugLog('[WorkflowExecutor] executeNotificationStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, event });
847
+ return this.getProcessorService().processNotification({
848
+ product: this.state.product,
849
+ env: this.state.env,
850
+ event,
851
+ input: input,
852
+ retries: ((_a = step.options) === null || _a === void 0 ? void 0 : _a.retries) || 0,
853
+ preloadedBootstrap: this.stepBootstrapCache.get(step.tag),
854
+ });
855
+ }
856
+ /**
857
+ * Execute a storage step using StorageService (upload, download, or delete by input shape).
858
+ */
859
+ async executeStorageStep(step, input) {
860
+ var _a, _b;
861
+ const product = this.state.product;
862
+ const env = this.state.env;
863
+ const storage = step.storage;
864
+ const opts = { product, env, storage };
865
+ debugLog('[WorkflowExecutor] executeStorageStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, storage, event: step.event });
866
+ const inp = input;
867
+ if (inp.buffer != null && inp.fileName != null) {
868
+ return this.getStorageService().upload(Object.assign(Object.assign({}, opts), { fileName: String(inp.fileName), buffer: inp.buffer, mimeType: inp.mimeType != null ? String(inp.mimeType) : undefined }));
869
+ }
870
+ if (inp.file_key != null) {
871
+ return this.getStorageService().delete(Object.assign(Object.assign({}, opts), { fileName: String(inp.file_key) }));
872
+ }
873
+ return this.getStorageService().download(Object.assign(Object.assign({}, opts), { fileName: String((_b = (_a = inp.fileName) !== null && _a !== void 0 ? _a : inp.file_key) !== null && _b !== void 0 ? _b : '') }));
874
+ }
875
+ /**
876
+ * Execute a produce step (message broker produce to topic).
877
+ * Uses BrokersService so ctx.messaging.produce has the same behavior as ductape.messaging.produce (pool, tracking, cache).
878
+ */
879
+ async executeProduceStep(step, input) {
880
+ const event = `${step.broker}:${step.event}`;
881
+ const message = (input && input.message != null) ? input.message : (input || {});
882
+ debugLog('[WorkflowExecutor] executeProduceStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, event });
883
+ return this.getBrokersService().publish({
884
+ product: this.state.product,
885
+ env: this.state.env,
886
+ event,
887
+ message: message,
888
+ });
889
+ }
890
+ /**
891
+ * Execute a graph step
892
+ * Supports: execute (custom action), createNode, updateNode, deleteNode,
893
+ * createRelationship, deleteRelationship, query
894
+ */
895
+ async executeGraphStep(step, input) {
896
+ const graphTag = step.graph;
897
+ const action = step.event;
898
+ debugLog('[WorkflowExecutor] executeGraphStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, graph: graphTag, action });
899
+ this.graphConnectionUsed = true;
900
+ await this.getGraphService().connect({
901
+ env: this.state.env,
902
+ product: this.state.product,
903
+ graph: graphTag,
904
+ });
905
+ try {
906
+ // Handle different graph operations based on action
907
+ switch (action) {
908
+ case 'createNode': {
909
+ const result = await this.getGraphService().createNode({
910
+ labels: input.labels,
911
+ properties: input.properties,
912
+ });
913
+ return result;
914
+ }
915
+ case 'updateNode': {
916
+ const result = await this.getGraphService().updateNode({
917
+ id: input.id,
918
+ properties: input.properties,
919
+ });
920
+ return result;
921
+ }
922
+ case 'deleteNode': {
923
+ const result = await this.getGraphService().deleteNode({
924
+ id: input.id,
925
+ detach: input.detach,
926
+ });
927
+ return result;
928
+ }
929
+ case 'createRelationship': {
930
+ const result = await this.getGraphService().createRelationship({
931
+ startNodeId: input.startNodeId || input.from,
932
+ endNodeId: input.endNodeId || input.to,
933
+ type: input.type,
934
+ properties: input.properties,
935
+ });
936
+ return result;
937
+ }
938
+ case 'deleteRelationship': {
939
+ const result = await this.getGraphService().deleteRelationship({
940
+ id: input.id,
941
+ });
942
+ return result;
943
+ }
944
+ case 'query': {
945
+ const result = await this.getGraphService().query(input.query, input.params);
946
+ return result;
947
+ }
948
+ case 'findNodes': {
949
+ const result = await this.getGraphService().findNodes({
950
+ labels: input.labels,
951
+ where: input.where,
952
+ limit: input.limit,
953
+ skip: input.skip,
954
+ });
955
+ return result;
956
+ }
957
+ case 'traverse': {
958
+ const result = await this.getGraphService().traverse({
959
+ startNodeId: input.startNodeId,
960
+ relationshipTypes: input.relationshipTypes,
961
+ direction: input.direction,
962
+ maxDepth: input.maxDepth,
963
+ });
964
+ return result;
965
+ }
966
+ default: {
967
+ // Execute a custom graph action
968
+ const result = await this.getGraphService().execute({
969
+ product: this.state.product,
970
+ env: this.state.env,
971
+ graph: graphTag,
972
+ action,
973
+ input,
974
+ });
975
+ return result;
976
+ }
977
+ }
978
+ }
979
+ finally {
980
+ // Disconnect is done once at end of execute() when graphConnectionUsed (see 2.8 optimization)
981
+ }
982
+ }
983
+ /**
984
+ * Execute a vector step (query, upsert, deleteVectors, or custom action via execute).
985
+ */
986
+ async executeVectorStep(step, input) {
987
+ var _a;
988
+ const vectorTag = step.vector;
989
+ if (!vectorTag) {
990
+ throw new Error(`Vector step "${step.tag}" has no vector tag`);
991
+ }
992
+ const product = this.state.product;
993
+ const env = this.state.env;
994
+ const event = (step.event || '').toLowerCase();
995
+ const svc = this.getVectorService();
996
+ debugLog('[WorkflowExecutor] executeVectorStep', {
997
+ workflow_id: this.state.workflow_id,
998
+ step_tag: step.tag,
999
+ vector: vectorTag,
1000
+ event,
1001
+ });
1002
+ switch (event) {
1003
+ case 'query': {
1004
+ const result = await svc.query(Object.assign({ product,
1005
+ env, tag: vectorTag }, input));
1006
+ return result;
1007
+ }
1008
+ case 'upsert': {
1009
+ const result = await svc.upsert(Object.assign({ product,
1010
+ env, tag: vectorTag }, input));
1011
+ return result;
1012
+ }
1013
+ case 'delete':
1014
+ case 'deletevectors': {
1015
+ const result = await svc.deleteVectors(Object.assign({ product,
1016
+ env, tag: vectorTag }, input));
1017
+ return result;
1018
+ }
1019
+ default: {
1020
+ // Custom vector action: resolve template then execute (resolve returns options for query/upsert/delete)
1021
+ const resolved = await svc.actions.resolve({
1022
+ product,
1023
+ env,
1024
+ vector: vectorTag,
1025
+ action: step.event,
1026
+ input: input,
1027
+ });
1028
+ const op = (_a = resolved === null || resolved === void 0 ? void 0 : resolved._operation) !== null && _a !== void 0 ? _a : resolved === null || resolved === void 0 ? void 0 : resolved.operation;
1029
+ const opts = Object.assign({ product, env, tag: vectorTag }, resolved);
1030
+ if (op === 'query' || !op) {
1031
+ return svc.query(opts);
1032
+ }
1033
+ if (op === 'upsert') {
1034
+ return svc.upsert(opts);
1035
+ }
1036
+ if (op === 'delete' || op === 'deleteVectors') {
1037
+ return svc.deleteVectors(opts);
1038
+ }
1039
+ return svc.query(opts);
1040
+ }
1041
+ }
1042
+ }
1043
+ /**
1044
+ * Execute a quota step
1045
+ */
1046
+ async executeQuotaStep(step, input) {
1047
+ debugLog('[WorkflowExecutor] executeQuotaStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, quota: step.quota });
1048
+ return this.getQuotaService().run({
1049
+ product: this.state.product,
1050
+ env: this.state.env,
1051
+ tag: step.quota,
1052
+ input,
1053
+ });
1054
+ }
1055
+ /**
1056
+ * Execute a fallback step
1057
+ */
1058
+ async executeFallbackStep(step, input) {
1059
+ debugLog('[WorkflowExecutor] executeFallbackStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, fallback: step.fallback });
1060
+ return this.getFallbackService().run({
1061
+ product: this.state.product,
1062
+ env: this.state.env,
1063
+ tag: step.fallback,
1064
+ input,
1065
+ });
1066
+ }
1067
+ /**
1068
+ * Execute a child workflow step
1069
+ */
1070
+ async executeChildWorkflowStep(step, input) {
1071
+ let childTag = step.workflow;
1072
+ if (childTag == null) {
1073
+ const fromResolved = input === null || input === void 0 ? void 0 : input.workflow;
1074
+ const fromStepInput = step.input && typeof step.input === 'object' ? step.input.workflow : undefined;
1075
+ childTag = typeof fromResolved === 'string' ? fromResolved : typeof fromStepInput === 'string' ? fromStepInput : undefined;
1076
+ }
1077
+ debugLog('[WorkflowExecutor] executeChildWorkflowStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, child_workflow: childTag });
1078
+ if (!childTag) {
1079
+ throw new Error('Child workflow step has no workflow tag (missing workflow or step.input.workflow)');
1080
+ }
1081
+ const childWorkflow = await this.productBuilder.fetchWorkflow(childTag);
1082
+ if (!childWorkflow) {
1083
+ debugLog('[WorkflowExecutor] executeChildWorkflowStep child not found', { step_tag: step.tag, child_workflow: childTag });
1084
+ throw new Error(`Child workflow ${childTag} not found`);
1085
+ }
1086
+ const childExecutor = new WorkflowExecutor(this.config, childWorkflow, {
1087
+ product: this.state.product,
1088
+ env: this.state.env,
1089
+ tag: childTag,
1090
+ input,
1091
+ }, this._privateKey);
1092
+ const result = await childExecutor.execute();
1093
+ debugLog('[WorkflowExecutor] executeChildWorkflowStep result', {
1094
+ workflow_id: this.state.workflow_id,
1095
+ step_tag: step.tag,
1096
+ child_status: result.status,
1097
+ });
1098
+ if (result.status !== types_1.WorkflowStatus.COMPLETED) {
1099
+ throw new Error(`Child workflow failed: ${result.error}`);
1100
+ }
1101
+ return result.output;
1102
+ }
1103
+ /**
1104
+ * Execute a sleep step
1105
+ */
1106
+ async executeSleepStep(step, input) {
1107
+ var _a;
1108
+ const duration = input.duration || ((_a = step.options) === null || _a === void 0 ? void 0 : _a.timeout) || 1000;
1109
+ debugLog('[WorkflowExecutor] executeSleepStep', { workflow_id: this.state.workflow_id, step_tag: step.tag, durationMs: duration });
1110
+ await this.sleep(duration);
1111
+ }
1112
+ /**
1113
+ * Execute a wait for signal step
1114
+ * Polls the backend API for signal delivery until received or timeout
1115
+ */
1116
+ async executeWaitForSignalStep(step, input) {
1117
+ var _a;
1118
+ const signalName = step.event;
1119
+ const signals = input.signals || [signalName];
1120
+ const timeout = ((_a = step.options) === null || _a === void 0 ? void 0 : _a.timeout) || 300000; // 5 min default
1121
+ const startTime = Date.now();
1122
+ debugLog('[WorkflowExecutor] executeWaitForSignalStep', {
1123
+ workflow_id: this.state.workflow_id,
1124
+ step_tag: step.tag,
1125
+ signals,
1126
+ timeoutMs: timeout,
1127
+ });
1128
+ // Store that we're waiting for these signals in state
1129
+ this.state.state[`waiting_for_signal:${step.tag}`] = {
1130
+ signals,
1131
+ started_at: startTime,
1132
+ timeout,
1133
+ };
1134
+ // Persist the waiting state to backend
1135
+ await this.persistExecutionResult(types_1.LogEventStatus.WAITING);
1136
+ return new Promise((resolve, reject) => {
1137
+ // Create pending signal entry
1138
+ const pendingSignal = {
1139
+ signal: signalName,
1140
+ resolve,
1141
+ reject,
1142
+ };
1143
+ // Store for each signal we're waiting for
1144
+ for (const sig of signals) {
1145
+ this.pendingSignals.set(sig, pendingSignal);
1146
+ }
1147
+ // Set up timeout
1148
+ if (timeout > 0) {
1149
+ pendingSignal.timeout = setTimeout(() => {
1150
+ // Clean up pending signals
1151
+ for (const sig of signals) {
1152
+ this.pendingSignals.delete(sig);
1153
+ }
1154
+ this.stopSignalPolling();
1155
+ // Update state
1156
+ delete this.state.state[`waiting_for_signal:${step.tag}`];
1157
+ this.state.state[`signal_timeout:${step.tag}`] = {
1158
+ signals,
1159
+ timed_out_at: Date.now(),
1160
+ };
1161
+ reject(new Error(`Signal wait timed out after ${timeout}ms waiting for: ${signals.join(', ')}`));
1162
+ }, timeout);
1163
+ }
1164
+ // Start polling for signals
1165
+ this.startSignalPolling(signals, step.tag);
1166
+ });
1167
+ }
1168
+ /**
1169
+ * Start polling the backend for signal delivery
1170
+ */
1171
+ startSignalPolling(signals, stepTag) {
1172
+ // Don't start multiple pollers
1173
+ if (this.signalPollTimer)
1174
+ return;
1175
+ debugLog('[WorkflowExecutor] startSignalPolling', { workflow_id: this.state.workflow_id, stepTag, signals });
1176
+ const poll = async () => {
1177
+ var _a;
1178
+ try {
1179
+ // Get workflow status from backend to check for received signals
1180
+ const status = await this.workflowApiService.getStatus(this.state.workflow_id, this.state.product, this.state.env, this.getAuthPayload());
1181
+ if (status) {
1182
+ // Check if any of the signals we're waiting for have been received
1183
+ const receivedSignals = ((_a = status.state) === null || _a === void 0 ? void 0 : _a.received_signals) || {};
1184
+ for (const signalName of signals) {
1185
+ const signalKey = `signal:${signalName}`;
1186
+ if (receivedSignals[signalKey]) {
1187
+ const signalData = receivedSignals[signalKey];
1188
+ const pendingSignal = this.pendingSignals.get(signalName);
1189
+ if (pendingSignal) {
1190
+ // Clear timeout
1191
+ if (pendingSignal.timeout) {
1192
+ clearTimeout(pendingSignal.timeout);
1193
+ }
1194
+ // Clean up
1195
+ for (const sig of signals) {
1196
+ this.pendingSignals.delete(sig);
1197
+ }
1198
+ this.stopSignalPolling();
1199
+ // Update state
1200
+ delete this.state.state[`waiting_for_signal:${stepTag}`];
1201
+ this.state.state[`signal_received:${stepTag}`] = {
1202
+ signal: signalName,
1203
+ payload: signalData,
1204
+ received_at: Date.now(),
1205
+ };
1206
+ // Resolve the promise
1207
+ pendingSignal.resolve({
1208
+ signal: signalName,
1209
+ payload: signalData,
1210
+ received_at: Date.now(),
1211
+ });
1212
+ return;
1213
+ }
1214
+ }
1215
+ }
1216
+ }
1217
+ }
1218
+ catch (error) {
1219
+ // Log but continue polling - transient errors shouldn't stop us
1220
+ debugLog('[WorkflowExecutor] Signal polling error', { workflow_id: this.state.workflow_id, error });
1221
+ }
1222
+ // Schedule next poll if we still have pending signals
1223
+ if (this.pendingSignals.size > 0) {
1224
+ this.signalPollTimer = setTimeout(poll, this.signalPollInterval);
1225
+ }
1226
+ };
1227
+ // Start polling
1228
+ poll();
1229
+ }
1230
+ /**
1231
+ * Stop the signal polling timer
1232
+ */
1233
+ stopSignalPolling() {
1234
+ if (this.signalPollTimer) {
1235
+ clearTimeout(this.signalPollTimer);
1236
+ this.signalPollTimer = null;
1237
+ }
1238
+ }
1239
+ /**
1240
+ * Deliver a signal to this workflow (called by external signal handler)
1241
+ */
1242
+ deliverSignal(signalName, payload) {
1243
+ debugLog('[WorkflowExecutor] deliverSignal', { workflow_id: this.state.workflow_id, signalName, hasPayload: payload !== undefined });
1244
+ const pendingSignal = this.pendingSignals.get(signalName);
1245
+ if (!pendingSignal) {
1246
+ debugLog('[WorkflowExecutor] deliverSignal no pending signal', { workflow_id: this.state.workflow_id, signalName });
1247
+ return false;
1248
+ }
1249
+ // Clear timeout
1250
+ if (pendingSignal.timeout) {
1251
+ clearTimeout(pendingSignal.timeout);
1252
+ }
1253
+ // Clean up all related pending signals
1254
+ // (in case we were waiting for multiple signals)
1255
+ for (const [key, value] of this.pendingSignals.entries()) {
1256
+ if (value === pendingSignal) {
1257
+ this.pendingSignals.delete(key);
1258
+ }
1259
+ }
1260
+ this.stopSignalPolling();
1261
+ // Resolve with the signal data
1262
+ pendingSignal.resolve({
1263
+ signal: signalName,
1264
+ payload,
1265
+ received_at: Date.now(),
1266
+ });
1267
+ return true;
1268
+ }
1269
+ /**
1270
+ * Execute a checkpoint step
1271
+ */
1272
+ async executeCheckpointStep(step, input) {
1273
+ debugLog('[WorkflowExecutor] executeCheckpointStep', { workflow_id: this.state.workflow_id, step_tag: step.tag });
1274
+ // Store checkpoint data in workflow state
1275
+ this.state.state[`checkpoint:${step.tag}`] = {
1276
+ timestamp: Date.now(),
1277
+ completed_steps: [...this.state.completed_steps],
1278
+ data: input,
1279
+ };
1280
+ }
1281
+ /**
1282
+ * Execute rollback for completed steps
1283
+ */
1284
+ async executeRollback(failedStep, reason) {
1285
+ var _a;
1286
+ const rolledBackSteps = [];
1287
+ const failedRollbacks = [];
1288
+ // Get rollback strategy
1289
+ const strategy = ((_a = this.workflow.options) === null || _a === void 0 ? void 0 : _a.rollback_strategy) || types_1.WorkflowRollbackStrategy.REVERSE_ALL;
1290
+ debugLog('[WorkflowExecutor] executeRollback ENTRY', {
1291
+ workflow_id: this.state.workflow_id,
1292
+ failedStep,
1293
+ reason,
1294
+ strategy,
1295
+ completed_steps: this.state.completed_steps,
1296
+ });
1297
+ // Determine which steps to rollback
1298
+ let stepsToRollback = [];
1299
+ switch (strategy) {
1300
+ case types_1.WorkflowRollbackStrategy.REVERSE_ALL:
1301
+ // Rollback all completed steps in reverse order
1302
+ stepsToRollback = this.state.completed_steps
1303
+ .slice()
1304
+ .reverse()
1305
+ .map((tag) => this.findStep(tag))
1306
+ .filter((step) => step !== undefined);
1307
+ break;
1308
+ case types_1.WorkflowRollbackStrategy.REVERSE_CRITICAL:
1309
+ // Only rollback steps marked as critical
1310
+ stepsToRollback = this.state.completed_steps
1311
+ .slice()
1312
+ .reverse()
1313
+ .map((tag) => this.findStep(tag))
1314
+ .filter((step) => { var _a; return step !== undefined && ((_a = step.options) === null || _a === void 0 ? void 0 : _a.critical) === true; });
1315
+ break;
1316
+ case types_1.WorkflowRollbackStrategy.NONE:
1317
+ // No rollback
1318
+ debugLog('[WorkflowExecutor] executeRollback NONE strategy', { workflow_id: this.state.workflow_id });
1319
+ return { success: true, rolled_back_steps: [], reason };
1320
+ }
1321
+ debugLog('[WorkflowExecutor] executeRollback steps to rollback', {
1322
+ workflow_id: this.state.workflow_id,
1323
+ count: stepsToRollback.length,
1324
+ tags: stepsToRollback.map((s) => s.tag),
1325
+ });
1326
+ // Execute rollback for each step
1327
+ for (const step of stepsToRollback) {
1328
+ if (!step.rollback) {
1329
+ debugLog('[WorkflowExecutor] executeRollback step has no rollback', { step_tag: step.tag });
1330
+ continue; // No rollback defined for this step
1331
+ }
1332
+ try {
1333
+ const stepOutput = this.state.steps[step.tag];
1334
+ await this.executeRollbackHandler(step.rollback, stepOutput);
1335
+ rolledBackSteps.push(step.tag);
1336
+ debugLog('[WorkflowExecutor] executeRollback step rolled back', { workflow_id: this.state.workflow_id, step_tag: step.tag });
1337
+ }
1338
+ catch (error) {
1339
+ debugLog('[WorkflowExecutor] executeRollback step failed', { workflow_id: this.state.workflow_id, step_tag: step.tag, error: error === null || error === void 0 ? void 0 : error.message });
1340
+ if (!step.rollback.continue_on_failure) {
1341
+ failedRollbacks.push({ tag: step.tag, error: error.message });
1342
+ // Stop rollback if continue_on_failure is not set
1343
+ break;
1344
+ }
1345
+ failedRollbacks.push({ tag: step.tag, error: error.message });
1346
+ }
1347
+ }
1348
+ const rollbackResult = {
1349
+ success: failedRollbacks.length === 0,
1350
+ rolled_back_steps: rolledBackSteps,
1351
+ failed_steps: failedRollbacks.length > 0 ? failedRollbacks : undefined,
1352
+ reason,
1353
+ };
1354
+ debugLog('[WorkflowExecutor] executeRollback DONE', {
1355
+ workflow_id: this.state.workflow_id,
1356
+ success: rollbackResult.success,
1357
+ rolled_back_count: rolledBackSteps.length,
1358
+ failed_count: failedRollbacks.length,
1359
+ });
1360
+ return rollbackResult;
1361
+ }
1362
+ /**
1363
+ * Execute a rollback handler
1364
+ */
1365
+ async executeRollbackHandler(rollback, stepOutput) {
1366
+ var _a, _b, _c, _d, _e, _f, _g;
1367
+ if (!rollback)
1368
+ return;
1369
+ debugLog('[WorkflowExecutor] executeRollbackHandler', { workflow_id: this.state.workflow_id, rollback_type: rollback.type });
1370
+ // Resolve rollback input, including step output references
1371
+ const resolvedInput = await this.resolveInput(rollback.input || {}, stepOutput);
1372
+ switch (rollback.type) {
1373
+ case types_1.WorkflowStepType.ACTION:
1374
+ await this.getProcessorService().processAction({
1375
+ product: this.state.product,
1376
+ env: this.state.env,
1377
+ app: rollback.app,
1378
+ action: rollback.event,
1379
+ input: resolvedInput,
1380
+ retries: (_a = rollback.retries) !== null && _a !== void 0 ? _a : 0,
1381
+ });
1382
+ break;
1383
+ case types_1.WorkflowStepType.DATABASE_ACTION: {
1384
+ const db = this.getDatabaseService();
1385
+ const product = this.state.product;
1386
+ const env = this.state.env;
1387
+ const database = rollback.database;
1388
+ const event = ((_b = rollback.event) !== null && _b !== void 0 ? _b : '').toLowerCase();
1389
+ const opts = Object.assign({ product, env, database }, resolvedInput);
1390
+ if (event === 'query')
1391
+ await db.query(opts);
1392
+ else if (event === 'insert')
1393
+ await db.insert(opts);
1394
+ else if (event === 'update')
1395
+ await db.update(opts);
1396
+ else if (event === 'delete')
1397
+ await db.delete(opts);
1398
+ else if (event === 'upsert')
1399
+ await db.upsert(opts);
1400
+ else
1401
+ await db.execute({
1402
+ product,
1403
+ env,
1404
+ database,
1405
+ action: rollback.event,
1406
+ input: resolvedInput,
1407
+ });
1408
+ break;
1409
+ }
1410
+ case types_1.WorkflowStepType.NOTIFICATION:
1411
+ const notifEvent = `${rollback.notification}:${rollback.event}`;
1412
+ await this.getProcessorService().processNotification({
1413
+ product: this.state.product,
1414
+ env: this.state.env,
1415
+ event: notifEvent,
1416
+ input: resolvedInput,
1417
+ retries: (_c = rollback.retries) !== null && _c !== void 0 ? _c : 0,
1418
+ });
1419
+ break;
1420
+ case types_1.WorkflowStepType.STORAGE: {
1421
+ const product = this.state.product;
1422
+ const env = this.state.env;
1423
+ const storage = rollback.storage;
1424
+ const opts = { product, env, storage };
1425
+ const inp = resolvedInput;
1426
+ if (inp.buffer != null && inp.fileName != null) {
1427
+ await this.getStorageService().upload(Object.assign(Object.assign({}, opts), { fileName: String(inp.fileName), buffer: inp.buffer, mimeType: inp.mimeType != null ? String(inp.mimeType) : undefined }));
1428
+ }
1429
+ else if (inp.file_key != null) {
1430
+ await this.getStorageService().delete(Object.assign(Object.assign({}, opts), { fileName: String(inp.file_key) }));
1431
+ }
1432
+ else {
1433
+ await this.getStorageService().download(Object.assign(Object.assign({}, opts), { fileName: String((_e = (_d = inp.fileName) !== null && _d !== void 0 ? _d : inp.file_key) !== null && _e !== void 0 ? _e : '') }));
1434
+ }
1435
+ break;
1436
+ }
1437
+ case types_1.WorkflowStepType.VECTOR: {
1438
+ const product = this.state.product;
1439
+ const env = this.state.env;
1440
+ const vectorTag = rollback.vector;
1441
+ const inp = resolvedInput;
1442
+ const event = ((_f = rollback.event) !== null && _f !== void 0 ? _f : '').toLowerCase();
1443
+ const svc = this.getVectorService();
1444
+ if (event === 'query') {
1445
+ await svc.query(Object.assign({ product, env, tag: vectorTag }, inp));
1446
+ }
1447
+ else if (event === 'upsert') {
1448
+ await svc.upsert(Object.assign({ product, env, tag: vectorTag }, inp));
1449
+ }
1450
+ else if (event === 'delete' || event === 'deletevectors') {
1451
+ await svc.deleteVectors(Object.assign({ product, env, tag: vectorTag }, inp));
1452
+ }
1453
+ else {
1454
+ const resolved = await svc.actions.resolve({
1455
+ product,
1456
+ env,
1457
+ vector: vectorTag,
1458
+ action: rollback.event,
1459
+ input: inp,
1460
+ });
1461
+ const op = (_g = resolved === null || resolved === void 0 ? void 0 : resolved._operation) !== null && _g !== void 0 ? _g : resolved === null || resolved === void 0 ? void 0 : resolved.operation;
1462
+ const opts = Object.assign({ product, env, tag: vectorTag }, resolved);
1463
+ if (op === 'upsert')
1464
+ await svc.upsert(opts);
1465
+ else if (op === 'delete' || op === 'deleteVectors')
1466
+ await svc.deleteVectors(opts);
1467
+ else
1468
+ await svc.query(opts);
1469
+ }
1470
+ break;
1471
+ }
1472
+ case types_1.WorkflowStepType.PUBLISH:
1473
+ case types_1.WorkflowStepType.PRODUCE:
1474
+ const pubEvent = `${rollback.broker}:${rollback.event}`;
1475
+ await this.getProcessorService().processMessageBrokerPublish({
1476
+ product: this.state.product,
1477
+ env: this.state.env,
1478
+ event: pubEvent,
1479
+ input: resolvedInput,
1480
+ });
1481
+ break;
1482
+ }
1483
+ }
1484
+ /**
1485
+ * Resolve input by replacing data references and all $ operators (per docs/operators).
1486
+ * Top-level keys are resolved in parallel for better performance.
1487
+ */
1488
+ async resolveInput(input, stepOutput) {
1489
+ const entries = Object.entries(input);
1490
+ const resolvedValues = await Promise.all(entries.map(([, value]) => this.resolveValue(value, stepOutput)));
1491
+ const resolved = {};
1492
+ entries.forEach(([key], i) => {
1493
+ resolved[key] = resolvedValues[i];
1494
+ });
1495
+ return resolved;
1496
+ }
1497
+ /**
1498
+ * Resolve a single value: refs ($Input{}, $Step{}, etc.) and operators ($Add, $Concat, etc.)
1499
+ */
1500
+ async resolveValue(value, stepOutput) {
1501
+ if (typeof value === 'string') {
1502
+ return this.resolveStringValue(value, stepOutput);
1503
+ }
1504
+ if (Array.isArray(value)) {
1505
+ return Promise.all(value.map((item) => this.resolveValue(item, stepOutput)));
1506
+ }
1507
+ if (value && typeof value === 'object') {
1508
+ return this.resolveInput(value, stepOutput);
1509
+ }
1510
+ return value;
1511
+ }
1512
+ /** Strip surrounding quotes from a string literal (e.g. '"foo"' -> 'foo') */
1513
+ unquote(part) {
1514
+ const t = part.trim();
1515
+ if ((t.startsWith('"') && t.endsWith('"')) || (t.startsWith("'") && t.endsWith("'"))) {
1516
+ return t.slice(1, -1);
1517
+ }
1518
+ return t;
1519
+ }
1520
+ /**
1521
+ * Resolve string value: data references and all $ operators from docs/operators
1522
+ * Supports: $Input{}, $Step{}, $Sequence{}, $State{}, $StepOutput{}, $Now,
1523
+ * $Add, $Subtract, $Concat, $Substring, $Trim, $Split, $Pick, $Join,
1524
+ * $Uppercase, $Lowercase, $Dateformat, $Replace, $Filter, $Find, $Size, $Length
1525
+ */
1526
+ async resolveStringValue(value, stepOutput) {
1527
+ var _a;
1528
+ const v = value.trim();
1529
+ // --- Data references (exact match) ---
1530
+ if (v === '$Now' || v === '$Now()')
1531
+ return Date.now();
1532
+ const inputMatch = v.match(/^\$Input\{(.+)\}$/);
1533
+ if (inputMatch)
1534
+ return this.getNestedValue(this.state.input, inputMatch[1]);
1535
+ const sequenceMatch = v.match(/^\$Sequence\{main\}\{([^}]+)\}\{(.+)\}$/);
1536
+ if (sequenceMatch) {
1537
+ const stepData = this.state.steps[sequenceMatch[1]];
1538
+ if (stepData)
1539
+ return this.getNestedValue(stepData, sequenceMatch[2]);
1540
+ return undefined;
1541
+ }
1542
+ const stepMatch = v.match(/^\$Step\{(.+)\}\{(.+)\}$/);
1543
+ if (stepMatch) {
1544
+ const stepData = this.state.steps[stepMatch[1]];
1545
+ if (stepData)
1546
+ return this.getNestedValue(stepData, stepMatch[2]);
1547
+ return undefined;
1548
+ }
1549
+ const stateMatch = v.match(/^\$State\{(.+)\}$/);
1550
+ if (stateMatch)
1551
+ return this.state.state[stateMatch[1]];
1552
+ const outputMatch = v.match(/^\$StepOutput\{(.+)\}$/);
1553
+ if (outputMatch && stepOutput)
1554
+ return this.getNestedValue(stepOutput, outputMatch[1]);
1555
+ // --- $Size{ref} / $Length{ref} ---
1556
+ const sizeMatch = v.match(/^\$Size\{(.+)\}$/);
1557
+ if (sizeMatch) {
1558
+ const inner = await this.resolveValue(sizeMatch[1].trim(), stepOutput);
1559
+ if (inner != null && typeof inner === 'object' && !Array.isArray(inner))
1560
+ return Object.keys(inner).length;
1561
+ return 0;
1562
+ }
1563
+ const lengthMatch = v.match(/^\$Length\{(.+)\}$/);
1564
+ if (lengthMatch) {
1565
+ const inner = await this.resolveValue(lengthMatch[1].trim(), stepOutput);
1566
+ if (Array.isArray(inner))
1567
+ return inner.length;
1568
+ if (typeof inner === 'string')
1569
+ return inner.length;
1570
+ return 0;
1571
+ }
1572
+ // --- Operators (whole-string forms) ---
1573
+ // $Add(...) or $Add{...}
1574
+ const addMatch = v.match(/^\$Add\(([^)]*)\)$/) || v.match(/^\$Add\{([^}]*)\}$/);
1575
+ if (addMatch) {
1576
+ const parts = addMatch[1].split(',').map((s) => this.unquote(s.trim()));
1577
+ const nums = await Promise.all(parts.map((p) => this.resolveValue(p, stepOutput)));
1578
+ return nums.reduce((sum, n) => sum + Number(n), 0);
1579
+ }
1580
+ // $Subtract(...) / $Substract(...) (typo) and $Subtract{...}
1581
+ const subMatch = v.match(/^\$Subtract?\(([^)]*)\)$/) || v.match(/^\$Subtract?\{([^}]*)\}$/);
1582
+ if (subMatch) {
1583
+ const parts = subMatch[1].split(',').map((s) => this.unquote(s.trim()));
1584
+ const nums = await Promise.all(parts.map((p) => this.resolveValue(p, stepOutput)));
1585
+ const n = nums.map((x) => Number(x));
1586
+ return n.length ? n.reduce((a, b) => a - b) : 0;
1587
+ }
1588
+ // $Concat([...], "sep")
1589
+ const concatMatch = v.match(inputs_types_1.concatRegex);
1590
+ if (concatMatch) {
1591
+ const arrContent = concatMatch[1];
1592
+ const separator = concatMatch[2];
1593
+ const parts = arrContent.split(',').map((s) => this.unquote(s.trim()));
1594
+ const resolvedParts = await Promise.all(parts.map((p) => this.resolveValue(p, stepOutput)));
1595
+ return resolvedParts.map((x) => (x == null ? '' : String(x))).join(separator);
1596
+ }
1597
+ // $Substring(str, start, end)
1598
+ const substrMatch = v.match(inputs_types_1.substringRegex);
1599
+ if (substrMatch) {
1600
+ const str = await this.resolveValue(this.unquote(substrMatch[1]), stepOutput);
1601
+ const start = Number(substrMatch[2]);
1602
+ const end = Number(substrMatch[3]);
1603
+ if (typeof str !== 'string')
1604
+ return '';
1605
+ return str.substring(start, end);
1606
+ }
1607
+ // $Trim(str)
1608
+ const trimMatch = v.match(inputs_types_1.trimRegex);
1609
+ if (trimMatch) {
1610
+ const str = await this.resolveValue(this.unquote(trimMatch[1]), stepOutput);
1611
+ return typeof str === 'string' ? str.trim() : String(str !== null && str !== void 0 ? str : '').trim();
1612
+ }
1613
+ // $Uppercase(str)
1614
+ const upperMatch = v.match(inputs_types_1.uppercaseRegex);
1615
+ if (upperMatch) {
1616
+ const str = await this.resolveValue(this.unquote(upperMatch[1]), stepOutput);
1617
+ return typeof str === 'string' ? str.toUpperCase() : String(str !== null && str !== void 0 ? str : '').toUpperCase();
1618
+ }
1619
+ // $Lowercase(str)
1620
+ const lowerMatch = v.match(inputs_types_1.lowercaseRegex);
1621
+ if (lowerMatch) {
1622
+ const str = await this.resolveValue(this.unquote(lowerMatch[1]), stepOutput);
1623
+ return typeof str === 'string' ? str.toLowerCase() : String(str !== null && str !== void 0 ? str : '').toLowerCase();
1624
+ }
1625
+ // $Dateformat(date, "format")
1626
+ const dateMatch = v.match(inputs_types_1.dateFormatRegex);
1627
+ if (dateMatch) {
1628
+ const dateVal = await this.resolveValue(this.unquote(dateMatch[1]), stepOutput);
1629
+ const formatStr = dateMatch[3];
1630
+ const d = typeof dateVal === 'string' ? (0, date_fns_1.parseISO)(dateVal) : new Date(dateVal);
1631
+ if (isNaN(d.getTime()))
1632
+ return '';
1633
+ return (0, date_fns_1.format)(d, formatStr);
1634
+ }
1635
+ // $Replace(str, search, replace)
1636
+ const replaceMatch = v.match(inputs_types_1.replaceRegex);
1637
+ if (replaceMatch) {
1638
+ const str = await this.resolveValue(this.unquote(replaceMatch[1]), stepOutput);
1639
+ const search = replaceMatch[3];
1640
+ const repl = replaceMatch[5];
1641
+ return typeof str === 'string' ? str.split(search).join(repl) : String(str !== null && str !== void 0 ? str : '');
1642
+ }
1643
+ // $Pick(value, index)
1644
+ const pickMatch = v.match(inputs_types_1.pickRegex);
1645
+ if (pickMatch) {
1646
+ const val = await this.resolveValue(this.unquote(pickMatch[1]), stepOutput);
1647
+ const idx = Number(pickMatch[2]);
1648
+ if (typeof val === 'string' || Array.isArray(val))
1649
+ return (_a = val[idx]) !== null && _a !== void 0 ? _a : '';
1650
+ return '';
1651
+ }
1652
+ // $Filter(array, "op", value)
1653
+ const filterMatch = v.match(inputs_types_1.filterRegex);
1654
+ if (filterMatch) {
1655
+ const arr = await this.resolveValue(this.unquote(filterMatch[1]), stepOutput);
1656
+ const op = filterMatch[2].trim();
1657
+ const compareVal = await this.resolveValue(this.unquote(filterMatch[3]), stepOutput);
1658
+ if (!productsBuilder_types_1.ValidOperators.includes(op) || !Array.isArray(arr))
1659
+ return [];
1660
+ return arr.filter((item) => (0, processor_utils_1.compareValues)(item, op, compareVal));
1661
+ }
1662
+ // $Find(array, "op", value)
1663
+ const findMatch = v.match(inputs_types_1.findRegex);
1664
+ if (findMatch) {
1665
+ const arr = await this.resolveValue(this.unquote(findMatch[1]), stepOutput);
1666
+ const op = findMatch[2].trim();
1667
+ const compareVal = await this.resolveValue(this.unquote(findMatch[3]), stepOutput);
1668
+ if (!productsBuilder_types_1.ValidOperators.includes(op) || !Array.isArray(arr))
1669
+ return undefined;
1670
+ return arr.find((item) => (0, processor_utils_1.compareValues)(item, op, compareVal));
1671
+ }
1672
+ // $Split(str, "sep")
1673
+ const splitMatch = v.match(inputs_types_1.splitRegex);
1674
+ if (splitMatch) {
1675
+ const str = await this.resolveValue(this.unquote(splitMatch[1]), stepOutput);
1676
+ const sep = splitMatch[2];
1677
+ return typeof str === 'string' ? str.split(sep) : [];
1678
+ }
1679
+ // $Join([[...], [...]]) - inner can be refs like $Sequence{main}{a}{data}
1680
+ const joinMatch = v.match(inputs_types_1.joinRegex);
1681
+ if (joinMatch) {
1682
+ const innerStr = joinMatch[1].trim();
1683
+ const parts = innerStr.slice(1, -1).split(',').map((s) => s.trim());
1684
+ const resolved = await Promise.all(parts.map((p) => this.resolveValue(p, stepOutput)));
1685
+ return resolved.reduce((acc, current) => {
1686
+ if (Array.isArray(current))
1687
+ return acc.concat(current);
1688
+ return acc;
1689
+ }, []);
1690
+ }
1691
+ // --- Inline references (string contains $Input{}, $Step{}, $Now, etc.) ---
1692
+ let out = value;
1693
+ out = out.replace(/\$Now(?:\(\))?/g, () => String(Date.now()));
1694
+ out = out.replace(/\$Input\{([^}]+)\}/g, (_, field) => {
1695
+ const val = this.getNestedValue(this.state.input, field);
1696
+ return String(val !== null && val !== void 0 ? val : '');
1697
+ });
1698
+ out = out.replace(/\$Sequence\{main\}\{([^}]+)\}\{([^}]+)\}/g, (_, stepTag, field) => {
1699
+ const stepData = this.state.steps[stepTag];
1700
+ if (stepData) {
1701
+ const val = this.getNestedValue(stepData, field);
1702
+ return String(val !== null && val !== void 0 ? val : '');
1703
+ }
1704
+ return '';
1705
+ });
1706
+ out = out.replace(/\$Step\{([^}]+)\}\{([^}]+)\}/g, (_, stepTag, field) => {
1707
+ const stepData = this.state.steps[stepTag];
1708
+ if (stepData) {
1709
+ const val = this.getNestedValue(stepData, field);
1710
+ return String(val !== null && val !== void 0 ? val : '');
1711
+ }
1712
+ return '';
1713
+ });
1714
+ return out;
1715
+ }
1716
+ /**
1717
+ * Get nested value from object using dot notation
1718
+ */
1719
+ getNestedValue(obj, path) {
1720
+ const keys = path.split('.');
1721
+ let current = obj;
1722
+ for (const key of keys) {
1723
+ if (current === null || current === undefined) {
1724
+ return undefined;
1725
+ }
1726
+ current = current[key];
1727
+ }
1728
+ return current;
1729
+ }
1730
+ /**
1731
+ * Get ordered steps respecting dependencies
1732
+ */
1733
+ getOrderedSteps() {
1734
+ const steps = this.workflow.steps;
1735
+ const ordered = [];
1736
+ const visited = new Set();
1737
+ const visiting = new Set();
1738
+ const visit = (step) => {
1739
+ if (visited.has(step.tag))
1740
+ return;
1741
+ if (visiting.has(step.tag)) {
1742
+ throw new Error(`Circular dependency detected at step ${step.tag}`);
1743
+ }
1744
+ visiting.add(step.tag);
1745
+ // Visit dependencies first
1746
+ if (step.depends_on) {
1747
+ for (const depTag of step.depends_on) {
1748
+ const depStep = steps.find((s) => s.tag === depTag);
1749
+ if (depStep) {
1750
+ visit(depStep);
1751
+ }
1752
+ }
1753
+ }
1754
+ visiting.delete(step.tag);
1755
+ visited.add(step.tag);
1756
+ ordered.push(step);
1757
+ };
1758
+ for (const step of steps) {
1759
+ visit(step);
1760
+ }
1761
+ return ordered;
1762
+ }
1763
+ /**
1764
+ * Pre-fetch all action/notification/storage bootstrap data for the given steps in one backend call.
1765
+ * Results are cached in stepBootstrapCache by step tag so step executors can skip their own bootstrap calls.
1766
+ */
1767
+ async prefetchStepBootstrap(steps) {
1768
+ this.stepBootstrapCache.clear();
1769
+ const product = this.state.product;
1770
+ const env = this.state.env;
1771
+ const workflowSteps = [];
1772
+ for (const step of steps) {
1773
+ if (step.type === types_1.WorkflowStepType.ACTION && step.app) {
1774
+ workflowSteps.push({
1775
+ step_tag: step.tag,
1776
+ type: 'action',
1777
+ access_tag: step.app,
1778
+ action_tag: step.event,
1779
+ });
1780
+ }
1781
+ else if (step.type === types_1.WorkflowStepType.NOTIFICATION && step.notification && step.event) {
1782
+ workflowSteps.push({
1783
+ step_tag: step.tag,
1784
+ type: 'notification',
1785
+ notification_tag: step.notification,
1786
+ message_tag: step.event,
1787
+ });
1788
+ }
1789
+ else if (step.type === types_1.WorkflowStepType.STORAGE && step.storage && step.event) {
1790
+ workflowSteps.push({
1791
+ step_tag: step.tag,
1792
+ type: 'storage',
1793
+ storage_tag: step.storage,
1794
+ });
1795
+ }
1796
+ }
1797
+ if (workflowSteps.length > 0) {
1798
+ stepLog('Bootstrap workflow API call (single request)', {
1799
+ product_tag: product,
1800
+ env_slug: env,
1801
+ steps_count: workflowSteps.length,
1802
+ step_tags: workflowSteps.map((s) => s.step_tag),
1803
+ });
1804
+ const bootstraps = await this.productBuilder.bootstrapWorkflow({
1805
+ product_tag: product,
1806
+ env_slug: env,
1807
+ steps: workflowSteps,
1808
+ });
1809
+ stepLog('Bootstrap workflow API response', {
1810
+ received_keys: Object.keys(bootstraps),
1811
+ keys_count: Object.keys(bootstraps).length,
1812
+ });
1813
+ for (const [stepTag, data] of Object.entries(bootstraps)) {
1814
+ if (data != null) {
1815
+ this.stepBootstrapCache.set(stepTag, data);
1816
+ }
1817
+ }
1818
+ }
1819
+ // Pre-fetch message brokers for produce steps so runBrokerPublish has broker/topic in cache
1820
+ const brokerTags = new Set();
1821
+ for (const step of steps) {
1822
+ if ((step.type === types_1.WorkflowStepType.PUBLISH || step.type === types_1.WorkflowStepType.PRODUCE) && step.broker) {
1823
+ brokerTags.add(step.broker);
1824
+ }
1825
+ }
1826
+ if (brokerTags.size > 0) {
1827
+ stepLog('Fetching message brokers for produce steps', { broker_tags: [...brokerTags] });
1828
+ await Promise.all([...brokerTags].map(async (tag) => {
1829
+ var _a;
1830
+ try {
1831
+ const broker = await this.productBuilder.fetchMessageBroker(tag);
1832
+ return { tag, found: !!broker };
1833
+ }
1834
+ catch (e) {
1835
+ stepLog('Broker fetch failed (step may fail later)', { broker_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
1836
+ return { tag, found: false };
1837
+ }
1838
+ }));
1839
+ }
1840
+ // Pre-fetch databases for DATABASE_ACTION steps
1841
+ const databaseTags = new Set();
1842
+ for (const step of steps) {
1843
+ if (step.type === types_1.WorkflowStepType.DATABASE_ACTION && step.database) {
1844
+ databaseTags.add(step.database);
1845
+ }
1846
+ }
1847
+ if (databaseTags.size > 0) {
1848
+ stepLog('Fetching databases for database steps', { database_tags: [...databaseTags] });
1849
+ await Promise.all([...databaseTags].map(async (tag) => {
1850
+ var _a;
1851
+ try {
1852
+ const db = await this.productBuilder.fetchDatabase(tag);
1853
+ return { tag, found: !!db };
1854
+ }
1855
+ catch (e) {
1856
+ stepLog('Database fetch failed (step may fail later)', { database_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
1857
+ return { tag, found: false };
1858
+ }
1859
+ }));
1860
+ }
1861
+ // Pre-fetch graphs for GRAPH steps
1862
+ const graphTags = new Set();
1863
+ for (const step of steps) {
1864
+ if (step.type === types_1.WorkflowStepType.GRAPH && step.graph) {
1865
+ graphTags.add(step.graph);
1866
+ }
1867
+ }
1868
+ if (graphTags.size > 0) {
1869
+ stepLog('Fetching graphs for graph steps', { graph_tags: [...graphTags] });
1870
+ await Promise.all([...graphTags].map(async (tag) => {
1871
+ var _a;
1872
+ try {
1873
+ const graph = await this.productBuilder.fetchGraph(tag);
1874
+ return { tag, found: !!graph };
1875
+ }
1876
+ catch (e) {
1877
+ stepLog('Graph fetch failed (step may fail later)', { graph_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
1878
+ return { tag, found: false };
1879
+ }
1880
+ }));
1881
+ }
1882
+ const vectorTags = new Set();
1883
+ for (const step of steps) {
1884
+ if (step.type === types_1.WorkflowStepType.VECTOR && step.vector) {
1885
+ vectorTags.add(step.vector);
1886
+ }
1887
+ }
1888
+ if (vectorTags.size > 0) {
1889
+ stepLog('Fetching vectors for vector steps', { vector_tags: [...vectorTags] });
1890
+ await Promise.all([...vectorTags].map(async (tag) => {
1891
+ var _a;
1892
+ try {
1893
+ const vec = await this.productBuilder.fetchVector(tag);
1894
+ return { tag, found: !!vec };
1895
+ }
1896
+ catch (e) {
1897
+ stepLog('Vector fetch failed (step may fail later)', { vector_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
1898
+ return { tag, found: false };
1899
+ }
1900
+ }));
1901
+ }
1902
+ // Pre-fetch quotas for QUOTA steps
1903
+ const quotaTags = new Set();
1904
+ for (const step of steps) {
1905
+ if (step.type === types_1.WorkflowStepType.QUOTA && step.quota) {
1906
+ quotaTags.add(step.quota);
1907
+ }
1908
+ }
1909
+ if (quotaTags.size > 0) {
1910
+ stepLog('Fetching quotas for quota steps', { quota_tags: [...quotaTags] });
1911
+ await Promise.all([...quotaTags].map(async (tag) => {
1912
+ var _a;
1913
+ try {
1914
+ const quota = await this.productBuilder.fetchQuota(tag);
1915
+ return { tag, found: !!quota };
1916
+ }
1917
+ catch (e) {
1918
+ stepLog('Quota fetch failed (step may fail later)', { quota_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
1919
+ return { tag, found: false };
1920
+ }
1921
+ }));
1922
+ }
1923
+ // Pre-fetch fallbacks for FALLBACK steps
1924
+ const fallbackTags = new Set();
1925
+ for (const step of steps) {
1926
+ if (step.type === types_1.WorkflowStepType.FALLBACK && step.fallback) {
1927
+ fallbackTags.add(step.fallback);
1928
+ }
1929
+ }
1930
+ if (fallbackTags.size > 0) {
1931
+ stepLog('Fetching fallbacks for fallback steps', { fallback_tags: [...fallbackTags] });
1932
+ await Promise.all([...fallbackTags].map(async (tag) => {
1933
+ var _a;
1934
+ try {
1935
+ const fallback = await this.productBuilder.fetchFallback(tag);
1936
+ return { tag, found: !!fallback };
1937
+ }
1938
+ catch (e) {
1939
+ stepLog('Fallback fetch failed (step may fail later)', { fallback_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
1940
+ return { tag, found: false };
1941
+ }
1942
+ }));
1943
+ }
1944
+ // Pre-fetch features for FEATURE steps (step.event is the feature tag)
1945
+ const featureTags = new Set();
1946
+ for (const step of steps) {
1947
+ if (step.type === types_1.WorkflowStepType.FEATURE && step.event) {
1948
+ featureTags.add(step.event);
1949
+ }
1950
+ }
1951
+ if (featureTags.size > 0) {
1952
+ stepLog('Fetching features for feature steps', { feature_tags: [...featureTags] });
1953
+ await Promise.all([...featureTags].map(async (tag) => {
1954
+ var _a;
1955
+ try {
1956
+ const feature = await this.productBuilder.fetchFeature(tag);
1957
+ return { tag, found: !!feature };
1958
+ }
1959
+ catch (e) {
1960
+ stepLog('Feature fetch failed (step may fail later)', { feature_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
1961
+ return { tag, found: false };
1962
+ }
1963
+ }));
1964
+ }
1965
+ // Pre-fetch child workflows for CHILD_WORKFLOW steps
1966
+ const workflowTags = new Set();
1967
+ for (const step of steps) {
1968
+ if (step.type === types_1.WorkflowStepType.CHILD_WORKFLOW && step.workflow) {
1969
+ workflowTags.add(step.workflow);
1970
+ }
1971
+ }
1972
+ if (workflowTags.size > 0) {
1973
+ stepLog('Fetching child workflows for child_workflow steps', { workflow_tags: [...workflowTags] });
1974
+ await Promise.all([...workflowTags].map(async (tag) => {
1975
+ var _a;
1976
+ try {
1977
+ const workflow = await this.productBuilder.fetchWorkflow(tag);
1978
+ return { tag, found: !!workflow };
1979
+ }
1980
+ catch (e) {
1981
+ stepLog('Child workflow fetch failed (step may fail later)', { workflow_tag: tag, error: (_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : String(e) });
1982
+ return { tag, found: false };
1983
+ }
1984
+ }));
1985
+ }
1986
+ // Pre-connect brokers, graphs, and databases so step execution reuses connections.
1987
+ // Security: product/env from this.state (same execution context). No connection URLs, config, or
1988
+ // credentials are ever logged. On pre-connect failure we log only tags and a generic message.
1989
+ if (brokerTags.size > 0) {
1990
+ stepLog('Pre-warming broker connections', { broker_tags: [...brokerTags] });
1991
+ try {
1992
+ await this.getBrokersService().warmBrokerConnections({ product, env, brokerTags: [...brokerTags] });
1993
+ }
1994
+ catch (_a) {
1995
+ stepLog('Broker pre-warm failed (steps may connect on first use)', { broker_tags: [...brokerTags] });
1996
+ }
1997
+ }
1998
+ if (graphTags.size > 0) {
1999
+ stepLog('Pre-connecting graph connections', { graph_tags: [...graphTags] });
2000
+ await Promise.all([...graphTags].map((tag) => this.getGraphService()
2001
+ .connect({ product, env, graph: tag })
2002
+ .catch(() => {
2003
+ stepLog('Graph pre-connect failed (step may connect on first use)', { graph_tag: tag });
2004
+ })));
2005
+ }
2006
+ if (databaseTags.size > 0) {
2007
+ stepLog('Pre-connecting database connections', { database_tags: [...databaseTags] });
2008
+ await Promise.all([...databaseTags].map((tag) => this.getDatabaseService()
2009
+ .connect({ product, env, database: tag })
2010
+ .catch(() => {
2011
+ stepLog('Database pre-connect failed (step may connect on first use)', { database_tag: tag });
2012
+ })));
2013
+ }
2014
+ if (vectorTags.size > 0) {
2015
+ stepLog('Pre-connecting vector connections', { vector_tags: [...vectorTags] });
2016
+ await Promise.all([...vectorTags].map((tag) => this.getVectorService()
2017
+ .connect({ product, env, vector: tag })
2018
+ .catch(() => {
2019
+ stepLog('Vector pre-connect failed (step may connect on first use)', { vector_tag: tag });
2020
+ })));
2021
+ }
2022
+ }
2023
+ /**
2024
+ * Find a step by tag
2025
+ */
2026
+ findStep(tag) {
2027
+ return this.workflow.steps.find((s) => s.tag === tag);
2028
+ }
2029
+ /**
2030
+ * Evaluate a condition string.
2031
+ * Supports: (cond1) || (cond2), (cond1) && (cond2), and in each part: ==, ===, !=, !==, >, <, >=, <=.
2032
+ * Left/right can be $Step{}, $Input{}, etc. (resolved before comparison).
2033
+ */
2034
+ async evaluateCondition(condition) {
2035
+ try {
2036
+ const orParts = condition.split(/\s*\|\|\s*/).map((p) => p.trim());
2037
+ for (const orPart of orParts) {
2038
+ const trimmed = orPart.replace(/^\(|\)$/g, '').trim();
2039
+ const andParts = trimmed.split(/\s*&&\s*/).map((p) => p.trim());
2040
+ let andResult = true;
2041
+ for (const andPart of andParts) {
2042
+ if (!(await this.evaluateConditionPart(andPart))) {
2043
+ andResult = false;
2044
+ break;
2045
+ }
2046
+ }
2047
+ if (andResult)
2048
+ return true;
2049
+ }
2050
+ return false;
2051
+ }
2052
+ catch (_a) {
2053
+ return false;
2054
+ }
2055
+ }
2056
+ /**
2057
+ * Coerce a trimmed condition literal (after resolve) to a comparable value: boolean, number, or string.
2058
+ */
2059
+ conditionLiteral(val) {
2060
+ const s = val.replace(/^["']|["']$/g, '').trim();
2061
+ if (s === 'true')
2062
+ return true;
2063
+ if (s === 'false')
2064
+ return false;
2065
+ if (s === 'null')
2066
+ return null;
2067
+ const n = Number(s);
2068
+ if (s !== '' && !Number.isNaN(n))
2069
+ return n;
2070
+ return s;
2071
+ }
2072
+ async evaluateConditionPart(condition) {
2073
+ try {
2074
+ const resolved = await this.resolveStringValue(condition);
2075
+ if (typeof resolved !== 'string') {
2076
+ return Boolean(resolved);
2077
+ }
2078
+ const match = resolved.match(WorkflowExecutor.CONDITION_OP_REGEX);
2079
+ if (!match) {
2080
+ return Boolean(this.conditionLiteral(resolved.trim()));
2081
+ }
2082
+ const [, leftStr, op, rightStr] = match;
2083
+ const left = this.conditionLiteral(leftStr.trim());
2084
+ const right = this.conditionLiteral(rightStr.trim());
2085
+ switch (op) {
2086
+ case '==':
2087
+ case '===':
2088
+ return this.compareLooseEqual(left, right);
2089
+ case '!=':
2090
+ case '!==':
2091
+ return !this.compareLooseEqual(left, right);
2092
+ case '>':
2093
+ return this.compareOrdered(left, right, (a, b) => a > b);
2094
+ case '<':
2095
+ return this.compareOrdered(left, right, (a, b) => a < b);
2096
+ case '>=':
2097
+ return this.compareOrdered(left, right, (a, b) => a >= b);
2098
+ case '<=':
2099
+ return this.compareOrdered(left, right, (a, b) => a <= b);
2100
+ default:
2101
+ return false;
2102
+ }
2103
+ }
2104
+ catch (_a) {
2105
+ return false;
2106
+ }
2107
+ }
2108
+ compareLooseEqual(a, b) {
2109
+ if (a === b)
2110
+ return true;
2111
+ if (a == null && b == null)
2112
+ return true;
2113
+ if (typeof a === 'boolean' && typeof b === 'boolean')
2114
+ return a === b;
2115
+ if (typeof a === 'number' && typeof b === 'number')
2116
+ return a === b;
2117
+ return String(a) === String(b);
2118
+ }
2119
+ /**
2120
+ * Compare for ordering (>, <, >=, <=). Uses numeric comparison when both sides are numeric, else string.
2121
+ */
2122
+ compareOrdered(left, right, cmp) {
2123
+ const l = typeof left === 'number' ? left : Number(left);
2124
+ const r = typeof right === 'number' ? right : Number(right);
2125
+ const bothNumeric = !Number.isNaN(l) && !Number.isNaN(r);
2126
+ if (bothNumeric)
2127
+ return cmp(l, r);
2128
+ return cmp(String(left !== null && left !== void 0 ? left : ''), String(right !== null && right !== void 0 ? right : ''));
2129
+ }
2130
+ /**
2131
+ * Returns true if the value tree contains any $ operator reference ($Input{}, $Step{}, $Sequence{}, etc.).
2132
+ * Used to distinguish output templates (to resolve) from type-only schemas (to ignore for persistence).
2133
+ */
2134
+ hasOperatorRefsInOutput(value) {
2135
+ if (typeof value === 'string') {
2136
+ const v = value.trim();
2137
+ return /^\$((Input|Step|Sequence|State|StepOutput|Now|Add|Subtract|Concat|Size|Length|Pick|Filter|Find|Join|Split|Replace|Substring|Trim|Uppercase|Lowercase|Dateformat)\{|[A-Za-z]+\()/.test(v);
2138
+ }
2139
+ if (Array.isArray(value)) {
2140
+ return value.some((item) => this.hasOperatorRefsInOutput(item));
2141
+ }
2142
+ if (value && typeof value === 'object') {
2143
+ return Object.values(value).some((v) => this.hasOperatorRefsInOutput(v));
2144
+ }
2145
+ return false;
2146
+ }
2147
+ /**
2148
+ * Returns true if the object looks like a workflow output type schema (e.g. { orderId: { type: 'string' }, ... })
2149
+ * rather than a template with $ operators or literal values.
2150
+ */
2151
+ isOutputTypeSchema(output) {
2152
+ if (Object.keys(output).length === 0)
2153
+ return false;
2154
+ return Object.values(output).every((v) => {
2155
+ if (v != null && typeof v === 'object' && !Array.isArray(v)) {
2156
+ const o = v;
2157
+ return 'type' in o && typeof o.type === 'string';
2158
+ }
2159
+ return false;
2160
+ });
2161
+ }
2162
+ /**
2163
+ * Determine workflow output for persistence and return value.
2164
+ * - If workflow.output has $ operator refs: resolve template to actual values (matches definition).
2165
+ * - If workflow.output is a type-only schema: use execution result (last step or step_outputs) so stored result matches runtime output, not the schema.
2166
+ * - If no workflow.output: use last step result or {}.
2167
+ */
2168
+ async determineWorkflowOutput() {
2169
+ const outputDef = this.workflow.output;
2170
+ if (!outputDef || Object.keys(outputDef).length === 0) {
2171
+ const lastStep = this.state.completed_steps[this.state.completed_steps.length - 1];
2172
+ return lastStep ? this.state.steps[lastStep] : {};
2173
+ }
2174
+ const hasRefs = this.hasOperatorRefsInOutput(outputDef);
2175
+ let result;
2176
+ if (hasRefs) {
2177
+ result = this.resolveInput(outputDef);
2178
+ }
2179
+ else if (this.isOutputTypeSchema(outputDef)) {
2180
+ const out = this.buildOutputFromStepsToMatchDefinition(outputDef);
2181
+ result = Object.keys(out).length > 0 ? out : {};
2182
+ }
2183
+ else {
2184
+ result = this.resolveInput(outputDef);
2185
+ }
2186
+ // recordScenarios: workflow.output is from last scenario; override outcome from which branch actually ran
2187
+ if (result != null && typeof result === 'object' && 'outcome' in result) {
2188
+ const res = result;
2189
+ if (this.state.completed_steps.includes('approve-request'))
2190
+ res.outcome = 'approved';
2191
+ else if (this.state.completed_steps.includes('reject-request'))
2192
+ res.outcome = 'rejected';
2193
+ }
2194
+ return result;
2195
+ }
2196
+ /**
2197
+ * Build output with same keys as workflow definition, values from step_outputs (last step first, then others).
2198
+ * Ensures persisted result shape matches the workflow definition output shape.
2199
+ */
2200
+ buildOutputFromStepsToMatchDefinition(definitionKeys) {
2201
+ var _a;
2202
+ const keys = Object.keys(definitionKeys);
2203
+ if (keys.length === 0)
2204
+ return {};
2205
+ const out = {};
2206
+ const stepsReversed = [...this.state.completed_steps].reverse();
2207
+ for (const key of keys) {
2208
+ let found = false;
2209
+ for (const stepTag of stepsReversed) {
2210
+ const stepData = this.state.steps[stepTag];
2211
+ if (stepData == null || typeof stepData !== 'object')
2212
+ continue;
2213
+ const rec = stepData;
2214
+ if (key in rec) {
2215
+ out[key] = rec[key];
2216
+ found = true;
2217
+ break;
2218
+ }
2219
+ const nested = (_a = rec.output) !== null && _a !== void 0 ? _a : rec.result;
2220
+ if (nested != null && typeof nested === 'object' && key in nested) {
2221
+ out[key] = nested[key];
2222
+ found = true;
2223
+ break;
2224
+ }
2225
+ }
2226
+ // Handler return shape { a, b } often maps to steps step-a, step-b; use step output so out.a.value / out.b.value exist
2227
+ if (!found && this.state.steps[`step-${key}`] != null) {
2228
+ const stepResult = this.state.steps[`step-${key}`];
2229
+ out[key] = ((stepResult === null || stepResult === void 0 ? void 0 : stepResult.output) != null ? stepResult.output : stepResult);
2230
+ }
2231
+ }
2232
+ if (Object.keys(out).length === 0 && this.state.completed_steps.length > 0) {
2233
+ const lastStep = this.state.completed_steps[this.state.completed_steps.length - 1];
2234
+ const lastOutput = this.state.steps[lastStep];
2235
+ return lastOutput != null && typeof lastOutput === 'object' ? lastOutput : {};
2236
+ }
2237
+ return out;
2238
+ }
2239
+ /**
2240
+ * Sleep for specified duration
2241
+ */
2242
+ sleep(ms) {
2243
+ return new Promise((resolve) => setTimeout(resolve, ms));
2244
+ }
2245
+ /**
2246
+ * Resume a workflow from a previous state
2247
+ *
2248
+ * @param options - Resume options including completed steps, state, and starting point
2249
+ */
2250
+ async resume(options) {
2251
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
2252
+ const startTime = Date.now();
2253
+ debugLog('[WorkflowExecutor] resume ENTRY', {
2254
+ workflow_id: this.state.workflow_id,
2255
+ workflow_tag: this.state.workflow_tag,
2256
+ completed_steps_count: (_b = (_a = options.completed_steps) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
2257
+ from_checkpoint: options.from_checkpoint,
2258
+ from_step: options.from_step,
2259
+ skip_steps: (_d = (_c = options.skip_steps) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
2260
+ });
2261
+ try {
2262
+ // Track phase so failures before first step are reported as (initialization)
2263
+ this.state.current_step = '(initialization)';
2264
+ // Initialize product builder with the product
2265
+ await this.productBuilder.initializeProductByTag(this.state.product);
2266
+ this.productId = this.productBuilder.fetchProductId();
2267
+ // Initialize logging after we have product ID
2268
+ this.initializeLogging();
2269
+ // Restore previous state
2270
+ this.state.completed_steps = options.completed_steps || [];
2271
+ this.state.state = options.state || {};
2272
+ // Restore step outputs if provided
2273
+ if (options.step_outputs) {
2274
+ this.state.steps = Object.assign(Object.assign({}, this.state.steps), options.step_outputs);
2275
+ }
2276
+ this.state.status = types_1.WorkflowStatus.RUNNING;
2277
+ // Get steps in execution order
2278
+ const orderedSteps = this.getOrderedSteps();
2279
+ // Find starting point
2280
+ let startIndex = 0;
2281
+ if (options.from_checkpoint) {
2282
+ // Find the step after the checkpoint
2283
+ const checkpointIndex = orderedSteps.findIndex((s) => s.type === types_1.WorkflowStepType.CHECKPOINT && s.tag === options.from_checkpoint);
2284
+ if (checkpointIndex >= 0) {
2285
+ startIndex = checkpointIndex + 1;
2286
+ }
2287
+ }
2288
+ else if (options.from_step) {
2289
+ // Start from the specified step
2290
+ startIndex = orderedSteps.findIndex((s) => s.tag === options.from_step);
2291
+ if (startIndex === -1) {
2292
+ throw new Error(`Step ${options.from_step} not found`);
2293
+ }
2294
+ }
2295
+ else {
2296
+ // Start after last completed step
2297
+ const lastCompleted = this.state.completed_steps[this.state.completed_steps.length - 1];
2298
+ if (lastCompleted) {
2299
+ const lastIndex = orderedSteps.findIndex((s) => s.tag === lastCompleted);
2300
+ startIndex = lastIndex + 1;
2301
+ }
2302
+ }
2303
+ debugLog('[WorkflowExecutor] resume starting from step index', {
2304
+ workflow_id: this.state.workflow_id,
2305
+ startIndex,
2306
+ total_steps: orderedSteps.length,
2307
+ steps_to_run: orderedSteps.slice(startIndex).map((s) => s.tag),
2308
+ });
2309
+ // Execute remaining steps
2310
+ for (let i = startIndex; i < orderedSteps.length; i++) {
2311
+ const step = orderedSteps[i];
2312
+ // Skip if already completed or in skip list
2313
+ if (this.state.completed_steps.includes(step.tag)) {
2314
+ this.logStepEvent(step, `Step ${step.tag} - skipped (already completed)`, logs_types_1.LogEventStatus.SUCCESS, { skipped: true });
2315
+ continue;
2316
+ }
2317
+ if ((_e = options.skip_steps) === null || _e === void 0 ? void 0 : _e.includes(step.tag)) {
2318
+ this.logStepEvent(step, `Step ${step.tag} - skipped (in skip list)`, logs_types_1.LogEventStatus.SUCCESS, { skipped: true });
2319
+ continue;
2320
+ }
2321
+ // Check step condition if present
2322
+ if (step.condition && !(await this.evaluateCondition(step.condition))) {
2323
+ this.logStepEvent(step, `Step ${step.tag} - skipped (condition not met)`, logs_types_1.LogEventStatus.SUCCESS, { skipped: true });
2324
+ continue;
2325
+ }
2326
+ this.state.current_step = step.tag;
2327
+ // Log step start
2328
+ this.logStepEvent(step, `Step ${step.tag} - started`, logs_types_1.LogEventStatus.PROCESSING);
2329
+ const result = await this.executeStep(step);
2330
+ // Log step completion
2331
+ this.logStepEvent(step, result.success ? `Step ${step.tag} - completed` : `Step ${step.tag} - failed`, result.success ? logs_types_1.LogEventStatus.SUCCESS : logs_types_1.LogEventStatus.FAIL, { duration: result.duration, error: result.error });
2332
+ // Step return value = resolved step.output schema with primitive result, or raw when no schema
2333
+ const outputSchemaResume = step.output;
2334
+ const hasOutputSchemaResume = outputSchemaResume && typeof outputSchemaResume === 'object' && !Array.isArray(outputSchemaResume) && Object.keys(outputSchemaResume).length > 0;
2335
+ let stepReturnValueResume = result.output;
2336
+ if (result.success && hasOutputSchemaResume) {
2337
+ try {
2338
+ stepReturnValueResume = await this.resolveInput(outputSchemaResume, result.output);
2339
+ }
2340
+ catch (_m) {
2341
+ stepReturnValueResume = result.output;
2342
+ }
2343
+ }
2344
+ else if (!result.success) {
2345
+ stepReturnValueResume = undefined;
2346
+ }
2347
+ // Persist step result to backend (use step return shape, not raw primitive)
2348
+ await this.persistStepResult(step, result.success ? types_1.LogEventStatus.SUCCESS : types_1.LogEventStatus.FAIL, stepReturnValueResume, result.error, result.duration, result.input);
2349
+ this.state.step_timings.push({
2350
+ tag: step.tag,
2351
+ duration_ms: result.duration,
2352
+ success: result.success,
2353
+ });
2354
+ if (!result.success) {
2355
+ this.state.failed_step = step.tag;
2356
+ // Check if step allows failure
2357
+ if ((_f = step.options) === null || _f === void 0 ? void 0 : _f.allow_fail) {
2358
+ this.state.steps[step.tag] = { error: result.error };
2359
+ continue;
2360
+ }
2361
+ // Check if step is optional
2362
+ if ((_g = step.options) === null || _g === void 0 ? void 0 : _g.optional) {
2363
+ continue;
2364
+ }
2365
+ // Trigger rollback
2366
+ this.state.status = types_1.WorkflowStatus.ROLLING_BACK;
2367
+ const rollbackResult = await this.executeRollback(step.tag, result.error || 'Step failed');
2368
+ await this.persistExecutionResult(types_1.LogEventStatus.FAIL, undefined, result.error);
2369
+ await ((_h = this.logService) === null || _h === void 0 ? void 0 : _h.publish());
2370
+ if (this.graphConnectionUsed) {
2371
+ await this.getGraphService().disconnect().catch(() => { });
2372
+ await this.getProcessorService().disconnectBrokerConnections().catch(() => { });
2373
+ if (this._brokersService)
2374
+ await this._brokersService.disconnectAll().catch(() => { });
2375
+ await this.getProcessorService().disconnectMailTransporters().catch(() => { });
2376
+ await this.getProcessorService().disconnectFirebaseApps().catch(() => { });
2377
+ await this.getProcessorService().disconnectSmsClients().catch(() => { });
2378
+ }
2379
+ return {
2380
+ status: types_1.WorkflowStatus.ROLLED_BACK,
2381
+ workflow_id: this.state.workflow_id,
2382
+ error: result.error,
2383
+ execution_time: Date.now() - startTime,
2384
+ completed_steps: this.state.completed_steps,
2385
+ step_timings: this.state.step_timings,
2386
+ failed_step: step.tag,
2387
+ rollback_info: {
2388
+ triggered_by: step.tag,
2389
+ reason: result.error || 'Step failed',
2390
+ rolled_back_steps: rollbackResult.rolled_back_steps,
2391
+ failed_rollbacks: rollbackResult.failed_steps,
2392
+ },
2393
+ };
2394
+ }
2395
+ // Store step return shape in state (same value we persisted)
2396
+ this.state.steps[step.tag] = stepReturnValueResume;
2397
+ this.state.completed_steps.push(step.tag);
2398
+ }
2399
+ this.state.status = types_1.WorkflowStatus.COMPLETED;
2400
+ this.state.ended_at = Date.now();
2401
+ const output = await this.determineWorkflowOutput();
2402
+ debugLog('[WorkflowExecutor] resume COMPLETED', {
2403
+ workflow_id: this.state.workflow_id,
2404
+ workflow_tag: this.state.workflow_tag,
2405
+ completed_steps: this.state.completed_steps.length,
2406
+ execution_time_ms: Date.now() - startTime,
2407
+ });
2408
+ await this.persistExecutionResult(types_1.LogEventStatus.SUCCESS, output);
2409
+ await ((_j = this.logService) === null || _j === void 0 ? void 0 : _j.publish());
2410
+ if (this.graphConnectionUsed) {
2411
+ await this.getGraphService().disconnect().catch(() => { });
2412
+ await this.getProcessorService().disconnectBrokerConnections().catch(() => { });
2413
+ if (this._brokersService)
2414
+ await this._brokersService.disconnectAll().catch(() => { });
2415
+ await this.getProcessorService().disconnectMailTransporters().catch(() => { });
2416
+ await this.getProcessorService().disconnectFirebaseApps().catch(() => { });
2417
+ await this.getProcessorService().disconnectSmsClients().catch(() => { });
2418
+ }
2419
+ return {
2420
+ status: types_1.WorkflowStatus.COMPLETED,
2421
+ workflow_id: this.state.workflow_id,
2422
+ output: output,
2423
+ execution_time: Date.now() - startTime,
2424
+ completed_steps: this.state.completed_steps,
2425
+ step_timings: this.state.step_timings,
2426
+ };
2427
+ }
2428
+ catch (error) {
2429
+ this.state.status = types_1.WorkflowStatus.FAILED;
2430
+ this.state.ended_at = Date.now();
2431
+ const details = formatErrorDetails(error);
2432
+ const failedAt = (_k = this.state.current_step) !== null && _k !== void 0 ? _k : '(unknown)';
2433
+ debugLog('[WorkflowExecutor] resume FAILED (exception)', Object.assign(Object.assign({ workflow_id: this.state.workflow_id, workflow_tag: this.state.workflow_tag, failed_at: failedAt, completed_steps: this.state.completed_steps, error: details.message }, (details.status != null && { http_status: details.status })), (details.responseBody != null && { response_body: details.responseBody })));
2434
+ if (details.stack) {
2435
+ debugLog('[WorkflowExecutor] resume FAILED stack', details.stack);
2436
+ }
2437
+ const errorSummary = details.status != null
2438
+ ? `Failed at ${failedAt}: ${details.message} (HTTP ${details.status})`
2439
+ : `Failed at ${failedAt}: ${details.message}`;
2440
+ await this.persistExecutionResult(types_1.LogEventStatus.FAIL, undefined, errorSummary);
2441
+ await ((_l = this.logService) === null || _l === void 0 ? void 0 : _l.publish());
2442
+ if (this.graphConnectionUsed) {
2443
+ await this.getGraphService().disconnect().catch(() => { });
2444
+ await this.getProcessorService().disconnectBrokerConnections().catch(() => { });
2445
+ if (this._brokersService)
2446
+ await this._brokersService.disconnectAll().catch(() => { });
2447
+ await this.getProcessorService().disconnectMailTransporters().catch(() => { });
2448
+ await this.getProcessorService().disconnectFirebaseApps().catch(() => { });
2449
+ await this.getProcessorService().disconnectSmsClients().catch(() => { });
2450
+ }
2451
+ return {
2452
+ status: types_1.WorkflowStatus.FAILED,
2453
+ workflow_id: this.state.workflow_id,
2454
+ error: errorSummary,
2455
+ execution_time: Date.now() - startTime,
2456
+ completed_steps: this.state.completed_steps,
2457
+ step_timings: this.state.step_timings,
2458
+ failed_step: this.state.current_step,
2459
+ };
2460
+ }
2461
+ }
2462
+ }
2463
+ exports.WorkflowExecutor = WorkflowExecutor;
2464
+ /** Comparison operators in parse order (multi-char before single-char). */
2465
+ WorkflowExecutor.CONDITION_OP_REGEX = /^\s*(.+?)\s*(!==|===|==|>=|<=|!=|>|<)\s*(.+)\s*$/;
2466
+ exports.default = WorkflowExecutor;
2467
+ //# sourceMappingURL=workflow-executor.js.map