openloops 0.3.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/README.md +9 -8
  2. package/dist/clients/llm/llm-client.js +6 -5
  3. package/dist/clients/llm/llm-client.mjs +6 -5
  4. package/dist/clients/llm/llm-types.d.ts +3 -0
  5. package/dist/clients/llm/llm-types.js +15 -0
  6. package/dist/clients/llm/llm-types.mjs +7 -0
  7. package/dist/db/index.d.ts +1 -0
  8. package/dist/db/index.js +3 -1
  9. package/dist/db/index.mjs +1 -0
  10. package/dist/db/indexes/automation-runs.d.ts +2 -0
  11. package/dist/db/indexes/automation-runs.js +33 -0
  12. package/dist/db/indexes/automation-runs.mjs +10 -0
  13. package/dist/db/indexes/automations.d.ts +2 -0
  14. package/dist/db/indexes/{agentic-jobs.js → automations.js} +6 -6
  15. package/dist/db/indexes/{agentic-jobs.mjs → automations.mjs} +2 -2
  16. package/dist/db/indexes/index.js +6 -4
  17. package/dist/db/indexes/index.mjs +6 -4
  18. package/dist/db/indexes/revoked-tokens.d.ts +2 -0
  19. package/dist/db/indexes/{agentic-job-runs.js → revoked-tokens.js} +8 -9
  20. package/dist/db/indexes/revoked-tokens.mjs +8 -0
  21. package/dist/db/migrations/automations.d.ts +12 -0
  22. package/dist/db/migrations/automations.js +70 -0
  23. package/dist/db/migrations/automations.mjs +47 -0
  24. package/dist/harness/agent-loop.d.ts +2 -0
  25. package/dist/harness/agent.d.ts +1 -0
  26. package/dist/harness/agent.js +8 -0
  27. package/dist/harness/agent.mjs +8 -0
  28. package/dist/loops/agi/loop.js +2 -1
  29. package/dist/loops/agi/loop.mjs +2 -1
  30. package/dist/loops/agi/skills/reasoning-engine.js +3 -2
  31. package/dist/loops/agi/skills/reasoning-engine.mjs +3 -2
  32. package/dist/loops/shared/skills/fast-responder.js +2 -2
  33. package/dist/loops/shared/skills/fast-responder.mjs +2 -2
  34. package/dist/services/authentication/entities/index.d.ts +1 -0
  35. package/dist/services/authentication/entities/index.js +22 -0
  36. package/dist/services/authentication/entities/index.mjs +1 -0
  37. package/dist/services/authentication/entities/revoked-token.entity.d.ts +17 -0
  38. package/dist/services/authentication/entities/revoked-token.entity.js +67 -0
  39. package/dist/services/authentication/entities/revoked-token.entity.mjs +44 -0
  40. package/dist/services/authentication/index.d.ts +1 -0
  41. package/dist/services/authentication/index.js +3 -1
  42. package/dist/services/authentication/index.mjs +1 -0
  43. package/dist/services/authentication/module.d.ts +4 -0
  44. package/dist/services/authentication/module.js +16 -2
  45. package/dist/services/authentication/module.mjs +13 -1
  46. package/dist/services/authentication/repositories/index.d.ts +1 -0
  47. package/dist/services/{agentic-jobs → authentication}/repositories/index.js +2 -4
  48. package/dist/services/authentication/repositories/index.mjs +1 -0
  49. package/dist/services/authentication/repositories/revoked-token.repository.d.ts +7 -0
  50. package/dist/services/authentication/repositories/revoked-token.repository.js +55 -0
  51. package/dist/services/authentication/repositories/revoked-token.repository.mjs +26 -0
  52. package/dist/services/authentication/use-cases/is-token-revoked.use-case.d.ts +15 -0
  53. package/dist/services/authentication/use-cases/is-token-revoked.use-case.js +55 -0
  54. package/dist/services/authentication/use-cases/is-token-revoked.use-case.mjs +26 -0
  55. package/dist/services/authentication/use-cases/revoke-token.use-case.d.ts +14 -0
  56. package/dist/services/authentication/use-cases/revoke-token.use-case.js +65 -0
  57. package/dist/services/authentication/use-cases/revoke-token.use-case.mjs +36 -0
  58. package/dist/services/automations/entities/automation-run.entity.d.ts +46 -0
  59. package/dist/services/{agentic-jobs/entities/agentic-job-run.entity.js → automations/entities/automation-run.entity.js} +22 -14
  60. package/dist/services/{agentic-jobs/entities/agentic-job-run.entity.mjs → automations/entities/automation-run.entity.mjs} +18 -10
  61. package/dist/services/automations/entities/automation.entity.d.ts +38 -0
  62. package/dist/services/{agentic-jobs/entities/agentic-job.entity.js → automations/entities/automation.entity.js} +17 -17
  63. package/dist/services/{agentic-jobs/entities/agentic-job.entity.mjs → automations/entities/automation.entity.mjs} +13 -13
  64. package/dist/services/automations/entities/index.d.ts +4 -0
  65. package/dist/services/{agentic-jobs → automations}/entities/index.js +6 -4
  66. package/dist/services/automations/entities/index.mjs +4 -0
  67. package/dist/services/automations/entities/trigger.d.ts +11 -0
  68. package/dist/services/automations/entities/trigger.js +49 -0
  69. package/dist/services/automations/entities/trigger.mjs +26 -0
  70. package/dist/services/automations/index.d.ts +5 -0
  71. package/dist/services/{agentic-jobs → automations}/index.js +9 -7
  72. package/dist/services/automations/index.mjs +5 -0
  73. package/dist/services/automations/module.d.ts +41 -0
  74. package/dist/services/automations/module.js +167 -0
  75. package/dist/services/automations/module.mjs +125 -0
  76. package/dist/services/automations/repositories/automation-run.repository.d.ts +14 -0
  77. package/dist/services/{agentic-jobs/repositories/agentic-job-run.repository.js → automations/repositories/automation-run.repository.js} +23 -11
  78. package/dist/services/{agentic-jobs/repositories/agentic-job-run.repository.mjs → automations/repositories/automation-run.repository.mjs} +19 -7
  79. package/dist/services/automations/repositories/automation.repository.d.ts +27 -0
  80. package/dist/services/{agentic-jobs/repositories/agentic-job.repository.js → automations/repositories/automation.repository.js} +17 -17
  81. package/dist/services/{agentic-jobs/repositories/agentic-job.repository.mjs → automations/repositories/automation.repository.mjs} +13 -13
  82. package/dist/services/automations/repositories/index.d.ts +2 -0
  83. package/dist/services/automations/repositories/index.js +24 -0
  84. package/dist/services/automations/repositories/index.mjs +2 -0
  85. package/dist/services/automations/runner/automation-runner.d.ts +49 -0
  86. package/dist/services/{agentic-jobs/runner/agentic-job-runner.js → automations/runner/automation-runner.js} +55 -45
  87. package/dist/services/{agentic-jobs/runner/agentic-job-runner.mjs → automations/runner/automation-runner.mjs} +50 -40
  88. package/dist/services/{agentic-jobs/use-cases/attach-agentic-job-run-chat.use-case.d.ts → automations/use-cases/attach-automation-run-chat.use-case.d.ts} +6 -6
  89. package/dist/services/{agentic-jobs/use-cases/attach-agentic-job-run-chat.use-case.js → automations/use-cases/attach-automation-run-chat.use-case.js} +14 -14
  90. package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.mjs +29 -0
  91. package/dist/services/automations/use-cases/claim-due-automations.use-case.d.ts +28 -0
  92. package/dist/services/{agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.js → automations/use-cases/claim-due-automations.use-case.js} +32 -43
  93. package/dist/services/automations/use-cases/claim-due-automations.use-case.mjs +70 -0
  94. package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.d.ts +27 -0
  95. package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.js +106 -0
  96. package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.mjs +77 -0
  97. package/dist/services/automations/use-cases/create-automation.use-case.d.ts +14 -0
  98. package/dist/services/{agentic-jobs/use-cases/create-agentic-job.use-case.js → automations/use-cases/create-automation.use-case.js} +24 -25
  99. package/dist/services/automations/use-cases/create-automation.use-case.mjs +43 -0
  100. package/dist/services/{agentic-jobs/use-cases/delete-agentic-job.use-case.d.ts → automations/use-cases/delete-automation.use-case.d.ts} +6 -6
  101. package/dist/services/{agentic-jobs/use-cases/delete-agentic-job.use-case.js → automations/use-cases/delete-automation.use-case.js} +17 -17
  102. package/dist/services/automations/use-cases/delete-automation.use-case.mjs +36 -0
  103. package/dist/services/{agentic-jobs/use-cases/finish-agentic-job-run.use-case.d.ts → automations/use-cases/finish-automation-run.use-case.d.ts} +8 -8
  104. package/dist/services/{agentic-jobs/use-cases/finish-agentic-job-run.use-case.js → automations/use-cases/finish-automation-run.use-case.js} +20 -20
  105. package/dist/services/automations/use-cases/finish-automation-run.use-case.mjs +46 -0
  106. package/dist/services/{agentic-jobs/use-cases/get-agentic-job-by-id.use-case.d.ts → automations/use-cases/get-automation-by-id.use-case.d.ts} +6 -6
  107. package/dist/services/{agentic-jobs/use-cases/get-agentic-job-by-id.use-case.js → automations/use-cases/get-automation-by-id.use-case.js} +13 -13
  108. package/dist/services/automations/use-cases/get-automation-by-id.use-case.mjs +26 -0
  109. package/dist/services/automations/use-cases/issue-automation-event-token.use-case.d.ts +17 -0
  110. package/dist/services/automations/use-cases/issue-automation-event-token.use-case.js +59 -0
  111. package/dist/services/automations/use-cases/issue-automation-event-token.use-case.mjs +30 -0
  112. package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-job.use-case.d.ts → automations/use-cases/list-automation-runs-by-automation.use-case.d.ts} +7 -7
  113. package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-job.use-case.js → automations/use-cases/list-automation-runs-by-automation.use-case.js} +15 -15
  114. package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +28 -0
  115. package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-user.use-case.d.ts → automations/use-cases/list-automation-runs-by-user.use-case.d.ts} +7 -7
  116. package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-user.use-case.js → automations/use-cases/list-automation-runs-by-user.use-case.js} +14 -14
  117. package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-user.use-case.mjs → automations/use-cases/list-automation-runs-by-user.use-case.mjs} +11 -11
  118. package/dist/services/{agentic-jobs/use-cases/list-agentic-jobs-by-user.use-case.d.ts → automations/use-cases/list-automations-by-user.use-case.d.ts} +6 -6
  119. package/dist/services/{agentic-jobs/use-cases/list-agentic-jobs-by-user.use-case.js → automations/use-cases/list-automations-by-user.use-case.js} +14 -14
  120. package/dist/services/{agentic-jobs/use-cases/list-agentic-jobs-by-user.use-case.mjs → automations/use-cases/list-automations-by-user.use-case.mjs} +11 -11
  121. package/dist/services/{agentic-jobs/use-cases/preview-agentic-job-runs.use-case.d.ts → automations/use-cases/preview-automation-runs.use-case.d.ts} +1 -1
  122. package/dist/services/{agentic-jobs/use-cases/preview-agentic-job-runs.use-case.js → automations/use-cases/preview-automation-runs.use-case.js} +8 -8
  123. package/dist/services/{agentic-jobs/use-cases/preview-agentic-job-runs.use-case.mjs → automations/use-cases/preview-automation-runs.use-case.mjs} +4 -4
  124. package/dist/services/automations/use-cases/receive-automation-event.use-case.d.ts +23 -0
  125. package/dist/services/automations/use-cases/receive-automation-event.use-case.js +97 -0
  126. package/dist/services/automations/use-cases/receive-automation-event.use-case.mjs +68 -0
  127. package/dist/services/{agentic-jobs/use-cases/renew-agentic-job-lease.use-case.d.ts → automations/use-cases/renew-automation-lease.use-case.d.ts} +5 -5
  128. package/dist/services/{agentic-jobs/use-cases/renew-agentic-job-lease.use-case.js → automations/use-cases/renew-automation-lease.use-case.js} +15 -15
  129. package/dist/services/automations/use-cases/renew-automation-lease.use-case.mjs +29 -0
  130. package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.d.ts +16 -0
  131. package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.js +65 -0
  132. package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.mjs +36 -0
  133. package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.d.ts +14 -0
  134. package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.js +63 -0
  135. package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.mjs +34 -0
  136. package/dist/services/automations/use-cases/start-automation-run.use-case.d.ts +21 -0
  137. package/dist/services/{agentic-jobs/use-cases/start-agentic-job-run.use-case.js → automations/use-cases/start-automation-run.use-case.js} +24 -24
  138. package/dist/services/automations/use-cases/start-automation-run.use-case.mjs +38 -0
  139. package/dist/services/automations/use-cases/sync-automation-run.use-case.d.ts +20 -0
  140. package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-run.use-case.js → automations/use-cases/sync-automation-run.use-case.js} +23 -23
  141. package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-run.use-case.mjs → automations/use-cases/sync-automation-run.use-case.mjs} +21 -21
  142. package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-runs.use-case.d.ts → automations/use-cases/sync-automation-runs.use-case.d.ts} +5 -5
  143. package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-runs.use-case.js → automations/use-cases/sync-automation-runs.use-case.js} +16 -16
  144. package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-runs.use-case.mjs → automations/use-cases/sync-automation-runs.use-case.mjs} +13 -13
  145. package/dist/services/automations/use-cases/update-automation.use-case.d.ts +15 -0
  146. package/dist/services/{agentic-jobs/use-cases/update-agentic-job.use-case.js → automations/use-cases/update-automation.use-case.js} +27 -27
  147. package/dist/services/automations/use-cases/update-automation.use-case.mjs +54 -0
  148. package/dist/services/automations/utils/automation-event-error.d.ts +6 -0
  149. package/dist/services/automations/utils/automation-event-error.js +37 -0
  150. package/dist/services/automations/utils/automation-event-error.mjs +14 -0
  151. package/dist/services/automations/utils/automation-fields.d.ts +14 -0
  152. package/dist/services/{agentic-jobs/utils/job-fields.js → automations/utils/automation-fields.js} +8 -10
  153. package/dist/services/{agentic-jobs/utils/job-fields.mjs → automations/utils/automation-fields.mjs} +4 -6
  154. package/dist/services/automations/utils/event-message.d.ts +1 -0
  155. package/dist/services/automations/utils/event-message.js +37 -0
  156. package/dist/services/automations/utils/event-message.mjs +14 -0
  157. package/dist/services/automations/utils/event-token.d.ts +18 -0
  158. package/dist/services/automations/utils/event-token.js +78 -0
  159. package/dist/services/automations/utils/event-token.mjs +43 -0
  160. package/dist/services/automations/utils/open-run.d.ts +14 -0
  161. package/dist/services/{agentic-jobs → automations}/utils/open-run.js +10 -8
  162. package/dist/services/automations/utils/open-run.mjs +26 -0
  163. package/dist/services/automations/utils/previous-run.d.ts +4 -0
  164. package/dist/services/automations/utils/previous-run.js +42 -0
  165. package/dist/services/automations/utils/previous-run.mjs +19 -0
  166. package/dist/services/{agentic-jobs → automations}/utils/settings.d.ts +1 -0
  167. package/dist/services/{agentic-jobs → automations}/utils/settings.js +6 -2
  168. package/dist/services/automations/utils/settings.mjs +13 -0
  169. package/dist/services/chats/entities/chat-settings.entity.d.ts +5 -1
  170. package/dist/services/chats/entities/chat-settings.entity.js +10 -3
  171. package/dist/services/chats/entities/chat-settings.entity.mjs +10 -3
  172. package/dist/skills/skill.d.ts +2 -1
  173. package/dist/skills/skill.js +4 -3
  174. package/dist/skills/skill.mjs +4 -3
  175. package/docs/README.md +1 -1
  176. package/docs/agent.md +3 -2
  177. package/docs/authentication.md +18 -1
  178. package/docs/automations.md +341 -0
  179. package/docs/chats.md +1 -1
  180. package/docs/configuration.md +8 -7
  181. package/docs/harness.md +1 -1
  182. package/docs/integration-guide.md +22 -18
  183. package/docs/llms.txt +1 -1
  184. package/docs/mcp-servers.md +1 -1
  185. package/docs/skills.md +1 -1
  186. package/examples/{agentic-jobs/create-agentic-job.ts → automations/create-automation.ts} +10 -7
  187. package/examples/automations/create-event-automation.ts +24 -0
  188. package/examples/{agentic-jobs/list-agentic-job-runs.ts → automations/list-automation-runs.ts} +8 -8
  189. package/examples/automations/list-automations.ts +25 -0
  190. package/examples/{agentic-jobs/preview-agentic-job-runs.ts → automations/preview-automation-runs.ts} +2 -2
  191. package/examples/automations/receive-automation-event.ts +26 -0
  192. package/examples/automations/revoke-automation-event-token.ts +25 -0
  193. package/examples/{agentic-jobs/run-agentic-job-now.ts → automations/run-automation-now.ts} +3 -3
  194. package/examples/{agentic-jobs/run-agentic-job-worker.ts → automations/run-automation-worker.ts} +6 -6
  195. package/examples/{agentic-jobs/update-agentic-job.ts → automations/update-automation.ts} +10 -10
  196. package/package.json +14 -13
  197. package/dist/db/indexes/agentic-job-runs.d.ts +0 -2
  198. package/dist/db/indexes/agentic-job-runs.mjs +0 -9
  199. package/dist/db/indexes/agentic-jobs.d.ts +0 -2
  200. package/dist/services/agentic-jobs/entities/agentic-job-run.entity.d.ts +0 -42
  201. package/dist/services/agentic-jobs/entities/agentic-job.entity.d.ts +0 -39
  202. package/dist/services/agentic-jobs/entities/index.d.ts +0 -3
  203. package/dist/services/agentic-jobs/entities/index.mjs +0 -3
  204. package/dist/services/agentic-jobs/index.d.ts +0 -4
  205. package/dist/services/agentic-jobs/index.mjs +0 -4
  206. package/dist/services/agentic-jobs/module.d.ts +0 -31
  207. package/dist/services/agentic-jobs/module.js +0 -132
  208. package/dist/services/agentic-jobs/module.mjs +0 -95
  209. package/dist/services/agentic-jobs/repositories/agentic-job-run.repository.d.ts +0 -11
  210. package/dist/services/agentic-jobs/repositories/agentic-job.repository.d.ts +0 -27
  211. package/dist/services/agentic-jobs/repositories/index.d.ts +0 -2
  212. package/dist/services/agentic-jobs/repositories/index.mjs +0 -2
  213. package/dist/services/agentic-jobs/runner/agentic-job-runner.d.ts +0 -48
  214. package/dist/services/agentic-jobs/use-cases/attach-agentic-job-run-chat.use-case.mjs +0 -29
  215. package/dist/services/agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.d.ts +0 -29
  216. package/dist/services/agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.mjs +0 -81
  217. package/dist/services/agentic-jobs/use-cases/create-agentic-job.use-case.d.ts +0 -14
  218. package/dist/services/agentic-jobs/use-cases/create-agentic-job.use-case.mjs +0 -44
  219. package/dist/services/agentic-jobs/use-cases/delete-agentic-job.use-case.mjs +0 -36
  220. package/dist/services/agentic-jobs/use-cases/finish-agentic-job-run.use-case.mjs +0 -46
  221. package/dist/services/agentic-jobs/use-cases/get-agentic-job-by-id.use-case.mjs +0 -26
  222. package/dist/services/agentic-jobs/use-cases/list-agentic-job-runs-by-job.use-case.mjs +0 -28
  223. package/dist/services/agentic-jobs/use-cases/renew-agentic-job-lease.use-case.mjs +0 -29
  224. package/dist/services/agentic-jobs/use-cases/start-agentic-job-run.use-case.d.ts +0 -21
  225. package/dist/services/agentic-jobs/use-cases/start-agentic-job-run.use-case.mjs +0 -38
  226. package/dist/services/agentic-jobs/use-cases/sync-agentic-job-run.use-case.d.ts +0 -20
  227. package/dist/services/agentic-jobs/use-cases/update-agentic-job.use-case.d.ts +0 -15
  228. package/dist/services/agentic-jobs/use-cases/update-agentic-job.use-case.mjs +0 -54
  229. package/dist/services/agentic-jobs/utils/job-fields.d.ts +0 -14
  230. package/dist/services/agentic-jobs/utils/open-run.d.ts +0 -12
  231. package/dist/services/agentic-jobs/utils/open-run.mjs +0 -24
  232. package/dist/services/agentic-jobs/utils/settings.mjs +0 -10
  233. package/docs/agentic-jobs.md +0 -217
  234. package/examples/agentic-jobs/list-agentic-jobs.ts +0 -25
  235. /package/dist/services/{agentic-jobs → automations}/entities/recurrence.d.ts +0 -0
  236. /package/dist/services/{agentic-jobs → automations}/entities/recurrence.js +0 -0
  237. /package/dist/services/{agentic-jobs → automations}/entities/recurrence.mjs +0 -0
  238. /package/dist/services/{agentic-jobs → automations}/utils/next-run.d.ts +0 -0
  239. /package/dist/services/{agentic-jobs → automations}/utils/next-run.js +0 -0
  240. /package/dist/services/{agentic-jobs → automations}/utils/next-run.mjs +0 -0
@@ -0,0 +1,14 @@
1
+ import { BaseUseCase, BaseUseCaseParams, BaseUseCaseOutput } from '../../../common/base/base.use-case.js';
2
+ import { RevokedTokenProps } from '../entities';
3
+ import { RevokedTokenRepository } from '../repositories';
4
+ export interface Params extends BaseUseCaseParams {
5
+ payload?: Pick<RevokedTokenProps, 'jti' | 'audience' | 'subject' | 'expiresAt'>;
6
+ }
7
+ export interface Output extends BaseUseCaseOutput {
8
+ data: RevokedTokenProps;
9
+ }
10
+ export declare class RevokeTokenUseCase extends BaseUseCase<Params, Output> {
11
+ private readonly revokedTokenRepository?;
12
+ constructor(revokedTokenRepository?: RevokedTokenRepository | undefined);
13
+ execute(params: Params): Promise<Output>;
14
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var __decorateClass = (decorators, target, key, kind) => {
20
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
21
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
22
+ if (decorator = decorators[i])
23
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
24
+ if (kind && result) __defProp(target, key, result);
25
+ return result;
26
+ };
27
+ var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
28
+ var revoke_token_use_case_exports = {};
29
+ __export(revoke_token_use_case_exports, {
30
+ RevokeTokenUseCase: () => RevokeTokenUseCase
31
+ });
32
+ module.exports = __toCommonJS(revoke_token_use_case_exports);
33
+ var import_tsyringe = require("tsyringe");
34
+ var import_base = require("../../../common/base/base.use-case.js");
35
+ var import_entities = require("../entities");
36
+ var import_repositories = require("../repositories");
37
+ let RevokeTokenUseCase = class extends import_base.BaseUseCase {
38
+ constructor(revokedTokenRepository) {
39
+ super();
40
+ this.revokedTokenRepository = revokedTokenRepository;
41
+ }
42
+ revokedTokenRepository;
43
+ async execute(params) {
44
+ const { payload, currentUser } = params;
45
+ if (!payload?.jti || !payload.audience || !payload.subject) throw new Error("The jti, the audience and the subject are required to revoke a token");
46
+ const existing = await this.revokedTokenRepository.findByJti(payload.jti);
47
+ if (existing) return { data: existing };
48
+ const revoked = import_entities.RevokedToken.fromJSON({ jti: payload.jti, audience: payload.audience, subject: payload.subject, expiresAt: payload.expiresAt });
49
+ revoked.setCreatedBy(currentUser);
50
+ try {
51
+ await this.revokedTokenRepository.create(revoked);
52
+ } catch (error) {
53
+ if (error?.code !== 11e3) throw error;
54
+ }
55
+ return { data: revoked.toJSON() };
56
+ }
57
+ };
58
+ RevokeTokenUseCase = __decorateClass([
59
+ (0, import_tsyringe.autoInjectable)(),
60
+ __decorateParam(0, (0, import_tsyringe.inject)(import_repositories.RevokedTokenRepository))
61
+ ], RevokeTokenUseCase);
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ RevokeTokenUseCase
65
+ });
@@ -0,0 +1,36 @@
1
+ import {
2
+ __decorateClass,
3
+ __decorateParam
4
+ } from "../../../chunk-CF3WOMB3.mjs";
5
+ import { autoInjectable, inject } from "tsyringe";
6
+ import { BaseUseCase } from "../../../common/base/base.use-case.js";
7
+ import { RevokedToken } from "../entities";
8
+ import { RevokedTokenRepository } from "../repositories";
9
+ let RevokeTokenUseCase = class extends BaseUseCase {
10
+ constructor(revokedTokenRepository) {
11
+ super();
12
+ this.revokedTokenRepository = revokedTokenRepository;
13
+ }
14
+ revokedTokenRepository;
15
+ async execute(params) {
16
+ const { payload, currentUser } = params;
17
+ if (!payload?.jti || !payload.audience || !payload.subject) throw new Error("The jti, the audience and the subject are required to revoke a token");
18
+ const existing = await this.revokedTokenRepository.findByJti(payload.jti);
19
+ if (existing) return { data: existing };
20
+ const revoked = RevokedToken.fromJSON({ jti: payload.jti, audience: payload.audience, subject: payload.subject, expiresAt: payload.expiresAt });
21
+ revoked.setCreatedBy(currentUser);
22
+ try {
23
+ await this.revokedTokenRepository.create(revoked);
24
+ } catch (error) {
25
+ if (error?.code !== 11e3) throw error;
26
+ }
27
+ return { data: revoked.toJSON() };
28
+ }
29
+ };
30
+ RevokeTokenUseCase = __decorateClass([
31
+ autoInjectable(),
32
+ __decorateParam(0, inject(RevokedTokenRepository))
33
+ ], RevokeTokenUseCase);
34
+ export {
35
+ RevokeTokenUseCase
36
+ };
@@ -0,0 +1,46 @@
1
+ import { ObjectId } from 'mongodb';
2
+ import { BaseEntity, BaseEntityProps } from '../../../common/base/base.entity.js';
3
+ export type AutomationRunStatus = 'queued' | 'running' | 'completed' | 'paused' | 'failed' | 'skipped';
4
+ export type AutomationRunTrigger = 'schedule' | 'manual' | 'event';
5
+ export interface AutomationRunError {
6
+ code?: string;
7
+ message: string;
8
+ }
9
+ export interface AutomationRunProps extends BaseEntityProps {
10
+ automationId?: string | ObjectId;
11
+ chatId?: string | ObjectId;
12
+ trigger?: AutomationRunTrigger;
13
+ status?: AutomationRunStatus;
14
+ scheduledFor?: string | Date;
15
+ startedAt?: string | Date;
16
+ finishedAt?: string | Date;
17
+ instructions?: string;
18
+ modelProvider?: string;
19
+ modelName?: string;
20
+ error?: AutomationRunError;
21
+ skipReason?: string;
22
+ workerId?: string;
23
+ payload?: string;
24
+ idempotencyKey?: string;
25
+ }
26
+ export declare class AutomationRun extends BaseEntity {
27
+ private readonly props;
28
+ automationId?: ObjectId | undefined;
29
+ chatId?: ObjectId | undefined;
30
+ trigger?: AutomationRunTrigger | undefined;
31
+ status?: AutomationRunStatus | undefined;
32
+ scheduledFor?: Date | undefined;
33
+ startedAt?: Date | undefined;
34
+ finishedAt?: Date | undefined;
35
+ instructions?: string | undefined;
36
+ modelProvider?: string | undefined;
37
+ modelName?: string | undefined;
38
+ error?: AutomationRunError | undefined;
39
+ skipReason?: string | undefined;
40
+ workerId?: string | undefined;
41
+ payload?: string | undefined;
42
+ idempotencyKey?: string | undefined;
43
+ static fromJSON(props: AutomationRunProps): AutomationRun;
44
+ constructor(props: AutomationRunProps, automationId?: ObjectId | undefined, chatId?: ObjectId | undefined, trigger?: AutomationRunTrigger | undefined, status?: AutomationRunStatus | undefined, scheduledFor?: Date | undefined, startedAt?: Date | undefined, finishedAt?: Date | undefined, instructions?: string | undefined, modelProvider?: string | undefined, modelName?: string | undefined, error?: AutomationRunError | undefined, skipReason?: string | undefined, workerId?: string | undefined, payload?: string | undefined, idempotencyKey?: string | undefined);
45
+ toJSON(): AutomationRunProps;
46
+ }
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var agentic_job_run_entity_exports = {};
20
- __export(agentic_job_run_entity_exports, {
21
- AgenticJobRun: () => AgenticJobRun
19
+ var automation_run_entity_exports = {};
20
+ __export(automation_run_entity_exports, {
21
+ AutomationRun: () => AutomationRun
22
22
  });
23
- module.exports = __toCommonJS(agentic_job_run_entity_exports);
23
+ module.exports = __toCommonJS(automation_run_entity_exports);
24
24
  var import_base = require("../../../common/base/base.entity.js");
25
25
  const toDate = (value) => {
26
26
  if (!value) return void 0;
@@ -28,11 +28,11 @@ const toDate = (value) => {
28
28
  if (Number.isNaN(date.getTime())) throw new Error("{{value_must_be_a_date}}");
29
29
  return date;
30
30
  };
31
- class AgenticJobRun extends import_base.BaseEntity {
32
- constructor(props, jobId, chatId, trigger, status, scheduledFor, startedAt, finishedAt, instructions, modelProvider, modelName, error, skipReason, workerId) {
31
+ class AutomationRun extends import_base.BaseEntity {
32
+ constructor(props, automationId, chatId, trigger, status, scheduledFor, startedAt, finishedAt, instructions, modelProvider, modelName, error, skipReason, workerId, payload, idempotencyKey) {
33
33
  super(props);
34
34
  this.props = props;
35
- this.jobId = jobId;
35
+ this.automationId = automationId;
36
36
  this.chatId = chatId;
37
37
  this.trigger = trigger;
38
38
  this.status = status;
@@ -45,9 +45,11 @@ class AgenticJobRun extends import_base.BaseEntity {
45
45
  this.error = error;
46
46
  this.skipReason = skipReason;
47
47
  this.workerId = workerId;
48
+ this.payload = payload;
49
+ this.idempotencyKey = idempotencyKey;
48
50
  }
49
51
  props;
50
- jobId;
52
+ automationId;
51
53
  chatId;
52
54
  trigger;
53
55
  status;
@@ -60,10 +62,12 @@ class AgenticJobRun extends import_base.BaseEntity {
60
62
  error;
61
63
  skipReason;
62
64
  workerId;
65
+ payload;
66
+ idempotencyKey;
63
67
  static fromJSON(props) {
64
- return new AgenticJobRun(
68
+ return new AutomationRun(
65
69
  props,
66
- import_base.BaseEntity.toObjectId(props.jobId),
70
+ import_base.BaseEntity.toObjectId(props.automationId),
67
71
  import_base.BaseEntity.toObjectId(props.chatId),
68
72
  props.trigger,
69
73
  props.status,
@@ -75,13 +79,15 @@ class AgenticJobRun extends import_base.BaseEntity {
75
79
  props.modelName || void 0,
76
80
  props.error,
77
81
  props.skipReason || void 0,
78
- props.workerId || void 0
82
+ props.workerId || void 0,
83
+ props.payload || void 0,
84
+ props.idempotencyKey || void 0
79
85
  );
80
86
  }
81
87
  toJSON() {
82
88
  return {
83
89
  ...super.toJSON(),
84
- jobId: this.jobId,
90
+ automationId: this.automationId,
85
91
  chatId: this.chatId,
86
92
  trigger: this.trigger,
87
93
  status: this.status,
@@ -93,11 +99,13 @@ class AgenticJobRun extends import_base.BaseEntity {
93
99
  modelName: this.modelName,
94
100
  error: this.error,
95
101
  skipReason: this.skipReason,
96
- workerId: this.workerId
102
+ workerId: this.workerId,
103
+ payload: this.payload,
104
+ idempotencyKey: this.idempotencyKey
97
105
  };
98
106
  }
99
107
  }
100
108
  // Annotate the CommonJS export names for ESM import in node:
101
109
  0 && (module.exports = {
102
- AgenticJobRun
110
+ AutomationRun
103
111
  });
@@ -6,11 +6,11 @@ const toDate = (value) => {
6
6
  if (Number.isNaN(date.getTime())) throw new Error("{{value_must_be_a_date}}");
7
7
  return date;
8
8
  };
9
- class AgenticJobRun extends BaseEntity {
10
- constructor(props, jobId, chatId, trigger, status, scheduledFor, startedAt, finishedAt, instructions, modelProvider, modelName, error, skipReason, workerId) {
9
+ class AutomationRun extends BaseEntity {
10
+ constructor(props, automationId, chatId, trigger, status, scheduledFor, startedAt, finishedAt, instructions, modelProvider, modelName, error, skipReason, workerId, payload, idempotencyKey) {
11
11
  super(props);
12
12
  this.props = props;
13
- this.jobId = jobId;
13
+ this.automationId = automationId;
14
14
  this.chatId = chatId;
15
15
  this.trigger = trigger;
16
16
  this.status = status;
@@ -23,9 +23,11 @@ class AgenticJobRun extends BaseEntity {
23
23
  this.error = error;
24
24
  this.skipReason = skipReason;
25
25
  this.workerId = workerId;
26
+ this.payload = payload;
27
+ this.idempotencyKey = idempotencyKey;
26
28
  }
27
29
  props;
28
- jobId;
30
+ automationId;
29
31
  chatId;
30
32
  trigger;
31
33
  status;
@@ -38,10 +40,12 @@ class AgenticJobRun extends BaseEntity {
38
40
  error;
39
41
  skipReason;
40
42
  workerId;
43
+ payload;
44
+ idempotencyKey;
41
45
  static fromJSON(props) {
42
- return new AgenticJobRun(
46
+ return new AutomationRun(
43
47
  props,
44
- BaseEntity.toObjectId(props.jobId),
48
+ BaseEntity.toObjectId(props.automationId),
45
49
  BaseEntity.toObjectId(props.chatId),
46
50
  props.trigger,
47
51
  props.status,
@@ -53,13 +57,15 @@ class AgenticJobRun extends BaseEntity {
53
57
  props.modelName || void 0,
54
58
  props.error,
55
59
  props.skipReason || void 0,
56
- props.workerId || void 0
60
+ props.workerId || void 0,
61
+ props.payload || void 0,
62
+ props.idempotencyKey || void 0
57
63
  );
58
64
  }
59
65
  toJSON() {
60
66
  return {
61
67
  ...super.toJSON(),
62
- jobId: this.jobId,
68
+ automationId: this.automationId,
63
69
  chatId: this.chatId,
64
70
  trigger: this.trigger,
65
71
  status: this.status,
@@ -71,10 +77,12 @@ class AgenticJobRun extends BaseEntity {
71
77
  modelName: this.modelName,
72
78
  error: this.error,
73
79
  skipReason: this.skipReason,
74
- workerId: this.workerId
80
+ workerId: this.workerId,
81
+ payload: this.payload,
82
+ idempotencyKey: this.idempotencyKey
75
83
  };
76
84
  }
77
85
  }
78
86
  export {
79
- AgenticJobRun
87
+ AutomationRun
80
88
  };
@@ -0,0 +1,38 @@
1
+ import { ObjectId } from 'mongodb';
2
+ import { BaseEntity, BaseEntityProps } from '../../../common/base/base.entity.js';
3
+ import { AutomationTrigger } from './trigger';
4
+ import type { AutomationRunStatus } from './automation-run.entity';
5
+ export interface AutomationProps extends BaseEntityProps {
6
+ name?: string;
7
+ instructions?: string;
8
+ enabled?: boolean;
9
+ trigger?: AutomationTrigger;
10
+ modelProvider?: string;
11
+ modelName?: string;
12
+ nextRunAt?: string | Date | null;
13
+ lastRunAt?: string | Date | null;
14
+ lastRunStatus?: AutomationRunStatus;
15
+ lockedBy?: string | null;
16
+ lockedUntil?: string | Date | null;
17
+ activeRunId?: string | ObjectId | null;
18
+ }
19
+ export declare class Automation extends BaseEntity {
20
+ private readonly props;
21
+ name?: string | undefined;
22
+ instructions?: string | undefined;
23
+ enabled?: boolean | undefined;
24
+ trigger?: AutomationTrigger | undefined;
25
+ modelProvider?: string | undefined;
26
+ modelName?: string | undefined;
27
+ nextRunAt?: Date | undefined;
28
+ lastRunAt?: Date | undefined;
29
+ lastRunStatus?: AutomationRunStatus | undefined;
30
+ lockedBy?: string | undefined;
31
+ lockedUntil?: Date | undefined;
32
+ activeRunId?: ObjectId | undefined;
33
+ static fromJSON(props: AutomationProps): Automation;
34
+ constructor(props: AutomationProps, name?: string | undefined, instructions?: string | undefined, enabled?: boolean | undefined, trigger?: AutomationTrigger | undefined, modelProvider?: string | undefined, modelName?: string | undefined, nextRunAt?: Date | undefined, lastRunAt?: Date | undefined, lastRunStatus?: AutomationRunStatus | undefined, lockedBy?: string | undefined, lockedUntil?: Date | undefined, activeRunId?: ObjectId | undefined);
35
+ toJSON(): AutomationProps;
36
+ isScheduled(): boolean;
37
+ scheduleNextRun(from?: Date): this;
38
+ }
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var agentic_job_entity_exports = {};
20
- __export(agentic_job_entity_exports, {
21
- AgenticJob: () => AgenticJob
19
+ var automation_entity_exports = {};
20
+ __export(automation_entity_exports, {
21
+ Automation: () => Automation
22
22
  });
23
- module.exports = __toCommonJS(agentic_job_entity_exports);
23
+ module.exports = __toCommonJS(automation_entity_exports);
24
24
  var import_base = require("../../../common/base/base.entity.js");
25
25
  var import_next_run = require("../utils/next-run");
26
26
  const toDate = (value) => {
@@ -29,15 +29,14 @@ const toDate = (value) => {
29
29
  if (Number.isNaN(date.getTime())) throw new Error("{{value_must_be_a_date}}");
30
30
  return date;
31
31
  };
32
- class AgenticJob extends import_base.BaseEntity {
33
- constructor(props, name, instructions, enabled, recurrence, timezone, modelProvider, modelName, nextRunAt, lastRunAt, lastRunStatus, lockedBy, lockedUntil, activeRunId) {
32
+ class Automation extends import_base.BaseEntity {
33
+ constructor(props, name, instructions, enabled, trigger, modelProvider, modelName, nextRunAt, lastRunAt, lastRunStatus, lockedBy, lockedUntil, activeRunId) {
34
34
  super(props);
35
35
  this.props = props;
36
36
  this.name = name;
37
37
  this.instructions = instructions;
38
38
  this.enabled = enabled;
39
- this.recurrence = recurrence;
40
- this.timezone = timezone;
39
+ this.trigger = trigger;
41
40
  this.modelProvider = modelProvider;
42
41
  this.modelName = modelName;
43
42
  this.nextRunAt = nextRunAt;
@@ -51,8 +50,7 @@ class AgenticJob extends import_base.BaseEntity {
51
50
  name;
52
51
  instructions;
53
52
  enabled;
54
- recurrence;
55
- timezone;
53
+ trigger;
56
54
  modelProvider;
57
55
  modelName;
58
56
  nextRunAt;
@@ -62,13 +60,12 @@ class AgenticJob extends import_base.BaseEntity {
62
60
  lockedUntil;
63
61
  activeRunId;
64
62
  static fromJSON(props) {
65
- return new AgenticJob(
63
+ return new Automation(
66
64
  props,
67
65
  props.name || void 0,
68
66
  props.instructions || void 0,
69
67
  props.enabled,
70
- props.recurrence,
71
- props.timezone || void 0,
68
+ props.trigger,
72
69
  props.modelProvider || void 0,
73
70
  props.modelName || void 0,
74
71
  toDate(props.nextRunAt),
@@ -85,8 +82,7 @@ class AgenticJob extends import_base.BaseEntity {
85
82
  name: this.name,
86
83
  instructions: this.instructions,
87
84
  enabled: this.enabled,
88
- recurrence: this.recurrence,
89
- timezone: this.timezone,
85
+ trigger: this.trigger,
90
86
  modelProvider: this.modelProvider,
91
87
  modelName: this.modelName,
92
88
  nextRunAt: this.nextRunAt,
@@ -97,8 +93,12 @@ class AgenticJob extends import_base.BaseEntity {
97
93
  activeRunId: this.activeRunId
98
94
  };
99
95
  }
96
+ isScheduled() {
97
+ return this.trigger?.type === "schedule";
98
+ }
100
99
  scheduleNextRun(from = /* @__PURE__ */ new Date()) {
101
- const next = this.enabled && this.recurrence && this.timezone ? (0, import_next_run.computeNextRun)(this.recurrence, this.timezone, from) : null;
100
+ const trigger = this.trigger;
101
+ const next = this.enabled && trigger?.type === "schedule" ? (0, import_next_run.computeNextRun)(trigger.recurrence, trigger.timezone, from) : null;
102
102
  if (next) {
103
103
  this.nextRunAt = next;
104
104
  } else {
@@ -109,5 +109,5 @@ class AgenticJob extends import_base.BaseEntity {
109
109
  }
110
110
  // Annotate the CommonJS export names for ESM import in node:
111
111
  0 && (module.exports = {
112
- AgenticJob
112
+ Automation
113
113
  });
@@ -7,15 +7,14 @@ const toDate = (value) => {
7
7
  if (Number.isNaN(date.getTime())) throw new Error("{{value_must_be_a_date}}");
8
8
  return date;
9
9
  };
10
- class AgenticJob extends BaseEntity {
11
- constructor(props, name, instructions, enabled, recurrence, timezone, modelProvider, modelName, nextRunAt, lastRunAt, lastRunStatus, lockedBy, lockedUntil, activeRunId) {
10
+ class Automation extends BaseEntity {
11
+ constructor(props, name, instructions, enabled, trigger, modelProvider, modelName, nextRunAt, lastRunAt, lastRunStatus, lockedBy, lockedUntil, activeRunId) {
12
12
  super(props);
13
13
  this.props = props;
14
14
  this.name = name;
15
15
  this.instructions = instructions;
16
16
  this.enabled = enabled;
17
- this.recurrence = recurrence;
18
- this.timezone = timezone;
17
+ this.trigger = trigger;
19
18
  this.modelProvider = modelProvider;
20
19
  this.modelName = modelName;
21
20
  this.nextRunAt = nextRunAt;
@@ -29,8 +28,7 @@ class AgenticJob extends BaseEntity {
29
28
  name;
30
29
  instructions;
31
30
  enabled;
32
- recurrence;
33
- timezone;
31
+ trigger;
34
32
  modelProvider;
35
33
  modelName;
36
34
  nextRunAt;
@@ -40,13 +38,12 @@ class AgenticJob extends BaseEntity {
40
38
  lockedUntil;
41
39
  activeRunId;
42
40
  static fromJSON(props) {
43
- return new AgenticJob(
41
+ return new Automation(
44
42
  props,
45
43
  props.name || void 0,
46
44
  props.instructions || void 0,
47
45
  props.enabled,
48
- props.recurrence,
49
- props.timezone || void 0,
46
+ props.trigger,
50
47
  props.modelProvider || void 0,
51
48
  props.modelName || void 0,
52
49
  toDate(props.nextRunAt),
@@ -63,8 +60,7 @@ class AgenticJob extends BaseEntity {
63
60
  name: this.name,
64
61
  instructions: this.instructions,
65
62
  enabled: this.enabled,
66
- recurrence: this.recurrence,
67
- timezone: this.timezone,
63
+ trigger: this.trigger,
68
64
  modelProvider: this.modelProvider,
69
65
  modelName: this.modelName,
70
66
  nextRunAt: this.nextRunAt,
@@ -75,8 +71,12 @@ class AgenticJob extends BaseEntity {
75
71
  activeRunId: this.activeRunId
76
72
  };
77
73
  }
74
+ isScheduled() {
75
+ return this.trigger?.type === "schedule";
76
+ }
78
77
  scheduleNextRun(from = /* @__PURE__ */ new Date()) {
79
- const next = this.enabled && this.recurrence && this.timezone ? computeNextRun(this.recurrence, this.timezone, from) : null;
78
+ const trigger = this.trigger;
79
+ const next = this.enabled && trigger?.type === "schedule" ? computeNextRun(trigger.recurrence, trigger.timezone, from) : null;
80
80
  if (next) {
81
81
  this.nextRunAt = next;
82
82
  } else {
@@ -86,5 +86,5 @@ class AgenticJob extends BaseEntity {
86
86
  }
87
87
  }
88
88
  export {
89
- AgenticJob
89
+ Automation
90
90
  };
@@ -0,0 +1,4 @@
1
+ export * from './recurrence';
2
+ export * from './automation.entity';
3
+ export * from './automation-run.entity';
4
+ export * from './trigger';
@@ -16,11 +16,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
16
16
  var entities_exports = {};
17
17
  module.exports = __toCommonJS(entities_exports);
18
18
  __reExport(entities_exports, require("./recurrence"), module.exports);
19
- __reExport(entities_exports, require("./agentic-job.entity"), module.exports);
20
- __reExport(entities_exports, require("./agentic-job-run.entity"), module.exports);
19
+ __reExport(entities_exports, require("./automation.entity"), module.exports);
20
+ __reExport(entities_exports, require("./automation-run.entity"), module.exports);
21
+ __reExport(entities_exports, require("./trigger"), module.exports);
21
22
  // Annotate the CommonJS export names for ESM import in node:
22
23
  0 && (module.exports = {
23
24
  ...require("./recurrence"),
24
- ...require("./agentic-job.entity"),
25
- ...require("./agentic-job-run.entity")
25
+ ...require("./automation.entity"),
26
+ ...require("./automation-run.entity"),
27
+ ...require("./trigger")
26
28
  });
@@ -0,0 +1,4 @@
1
+ export * from "./recurrence";
2
+ export * from "./automation.entity";
3
+ export * from "./automation-run.entity";
4
+ export * from "./trigger";
@@ -0,0 +1,11 @@
1
+ import { Recurrence } from './recurrence';
2
+ export type AutomationTrigger = {
3
+ type: 'schedule';
4
+ recurrence: Recurrence;
5
+ timezone: string;
6
+ } | {
7
+ type: 'event';
8
+ tokenVersion: number;
9
+ timezone?: string;
10
+ };
11
+ export declare function readTrigger(input: unknown, existing?: AutomationTrigger): AutomationTrigger;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var trigger_exports = {};
20
+ __export(trigger_exports, {
21
+ readTrigger: () => readTrigger
22
+ });
23
+ module.exports = __toCommonJS(trigger_exports);
24
+ var import_recurrence = require("./recurrence");
25
+ var import_next_run = require("../utils/next-run");
26
+ const isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
27
+ function readTrigger(input, existing) {
28
+ if (!isRecord(input)) throw new Error("The trigger is required");
29
+ const type = input.type ?? existing?.type;
30
+ if (type !== "schedule" && type !== "event") throw new Error("The trigger type must be schedule or event");
31
+ if (existing && type !== existing.type) throw new Error("The type of the trigger cannot be changed");
32
+ const previous = existing?.type === type ? existing : void 0;
33
+ const has = (key) => input[key] !== void 0;
34
+ if (type === "event") {
35
+ const event = previous;
36
+ const timezone = has("timezone") ? (0, import_next_run.assertTimezone)(input.timezone) : event?.timezone;
37
+ return { type, tokenVersion: event?.tokenVersion ?? 1, ...timezone ? { timezone } : {} };
38
+ }
39
+ const schedule = previous;
40
+ return {
41
+ type,
42
+ recurrence: has("recurrence") || !schedule ? (0, import_recurrence.validateRecurrence)(input.recurrence) : schedule.recurrence,
43
+ timezone: has("timezone") || !schedule ? (0, import_next_run.assertTimezone)(input.timezone) : schedule.timezone
44
+ };
45
+ }
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ readTrigger
49
+ });
@@ -0,0 +1,26 @@
1
+ import "../../../chunk-CF3WOMB3.mjs";
2
+ import { validateRecurrence } from "./recurrence";
3
+ import { assertTimezone } from "../utils/next-run";
4
+ const isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
5
+ function readTrigger(input, existing) {
6
+ if (!isRecord(input)) throw new Error("The trigger is required");
7
+ const type = input.type ?? existing?.type;
8
+ if (type !== "schedule" && type !== "event") throw new Error("The trigger type must be schedule or event");
9
+ if (existing && type !== existing.type) throw new Error("The type of the trigger cannot be changed");
10
+ const previous = existing?.type === type ? existing : void 0;
11
+ const has = (key) => input[key] !== void 0;
12
+ if (type === "event") {
13
+ const event = previous;
14
+ const timezone = has("timezone") ? assertTimezone(input.timezone) : event?.timezone;
15
+ return { type, tokenVersion: event?.tokenVersion ?? 1, ...timezone ? { timezone } : {} };
16
+ }
17
+ const schedule = previous;
18
+ return {
19
+ type,
20
+ recurrence: has("recurrence") || !schedule ? validateRecurrence(input.recurrence) : schedule.recurrence,
21
+ timezone: has("timezone") || !schedule ? assertTimezone(input.timezone) : schedule.timezone
22
+ };
23
+ }
24
+ export {
25
+ readTrigger
26
+ };
@@ -0,0 +1,5 @@
1
+ export * from './module';
2
+ export * from './entities';
3
+ export * from './repositories';
4
+ export * from './runner/automation-runner';
5
+ export * from './utils/automation-event-error';