@contember/engine-actions 2.1.0-rc.3 → 2.2.0-alpha.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 (392) hide show
  1. package/CLAUDE.md +69 -0
  2. package/dist/development/index.cjs +24 -11
  3. package/dist/development/index.cjs.map +1 -1
  4. package/dist/development/index.js +24 -11
  5. package/dist/development/index.js.map +1 -1
  6. package/dist/development/src/ActionsExecutionContainerHookFactory.cjs +5 -2
  7. package/dist/development/src/ActionsExecutionContainerHookFactory.cjs.map +1 -1
  8. package/dist/development/src/ActionsExecutionContainerHookFactory.js +5 -2
  9. package/dist/development/src/ActionsExecutionContainerHookFactory.js.map +1 -1
  10. package/dist/development/src/ActionsMetrics.cjs +98 -0
  11. package/dist/development/src/ActionsMetrics.cjs.map +1 -0
  12. package/dist/development/src/ActionsMetrics.js +98 -0
  13. package/dist/development/src/ActionsMetrics.js.map +1 -0
  14. package/dist/development/src/ListenerStoreProvider.cjs.map +1 -1
  15. package/dist/development/src/ListenerStoreProvider.js.map +1 -1
  16. package/dist/development/src/authorization/ActionsPermissionsFactory.cjs.map +1 -1
  17. package/dist/development/src/authorization/ActionsPermissionsFactory.js.map +1 -1
  18. package/dist/development/src/dispatch/DispatchWorkerSupervisor.cjs.map +1 -1
  19. package/dist/development/src/dispatch/DispatchWorkerSupervisor.js.map +1 -1
  20. package/dist/development/src/dispatch/EventDispatcher.cjs +64 -23
  21. package/dist/development/src/dispatch/EventDispatcher.cjs.map +1 -1
  22. package/dist/development/src/dispatch/EventDispatcher.js +64 -23
  23. package/dist/development/src/dispatch/EventDispatcher.js.map +1 -1
  24. package/dist/development/src/dispatch/EventsRepository.cjs +49 -20
  25. package/dist/development/src/dispatch/EventsRepository.cjs.map +1 -1
  26. package/dist/development/src/dispatch/EventsRepository.js +49 -20
  27. package/dist/development/src/dispatch/EventsRepository.js.map +1 -1
  28. package/dist/development/src/dispatch/LazyDispatchWorker.cjs.map +1 -1
  29. package/dist/development/src/dispatch/LazyDispatchWorker.js.map +1 -1
  30. package/dist/development/src/dispatch/ProjectDispatcher.cjs +63 -21
  31. package/dist/development/src/dispatch/ProjectDispatcher.cjs.map +1 -1
  32. package/dist/development/src/dispatch/ProjectDispatcher.js +63 -21
  33. package/dist/development/src/dispatch/ProjectDispatcher.js.map +1 -1
  34. package/dist/development/src/dispatch/TargetHandlerResolver.cjs.map +1 -1
  35. package/dist/development/src/dispatch/TargetHandlerResolver.js.map +1 -1
  36. package/dist/development/src/dispatch/WebhookTargetHandler.cjs +104 -4
  37. package/dist/development/src/dispatch/WebhookTargetHandler.cjs.map +1 -1
  38. package/dist/development/src/dispatch/WebhookTargetHandler.js +104 -4
  39. package/dist/development/src/dispatch/WebhookTargetHandler.js.map +1 -1
  40. package/dist/development/src/graphql/http/ActionsApiMiddlewareFactory.cjs.map +1 -1
  41. package/dist/development/src/graphql/http/ActionsApiMiddlewareFactory.js.map +1 -1
  42. package/dist/development/src/graphql/http/ActionsContextResolver.cjs.map +1 -1
  43. package/dist/development/src/graphql/http/ActionsContextResolver.js.map +1 -1
  44. package/dist/development/src/graphql/http/ActionsGraphQLHandlerFactory.cjs.map +1 -1
  45. package/dist/development/src/graphql/http/ActionsGraphQLHandlerFactory.js.map +1 -1
  46. package/dist/development/src/graphql/http/ActionsWebsocketControllerFactory.cjs +68 -28
  47. package/dist/development/src/graphql/http/ActionsWebsocketControllerFactory.cjs.map +1 -1
  48. package/dist/development/src/graphql/http/ActionsWebsocketControllerFactory.js +68 -28
  49. package/dist/development/src/graphql/http/ActionsWebsocketControllerFactory.js.map +1 -1
  50. package/dist/development/src/graphql/resolvers/ResolversFactory.cjs +1 -1
  51. package/dist/development/src/graphql/resolvers/ResolversFactory.cjs.map +1 -1
  52. package/dist/development/src/graphql/resolvers/ResolversFactory.js +1 -1
  53. package/dist/development/src/graphql/resolvers/ResolversFactory.js.map +1 -1
  54. package/dist/development/src/graphql/resolvers/mutation/ProcessBatchMutationResolver.cjs.map +1 -1
  55. package/dist/development/src/graphql/resolvers/mutation/ProcessBatchMutationResolver.js.map +1 -1
  56. package/dist/development/src/graphql/resolvers/mutation/RetryEventMutationResolver.cjs.map +1 -1
  57. package/dist/development/src/graphql/resolvers/mutation/RetryEventMutationResolver.js.map +1 -1
  58. package/dist/development/src/graphql/resolvers/mutation/SetVariablesMutationResolver.cjs +1 -1
  59. package/dist/development/src/graphql/resolvers/mutation/SetVariablesMutationResolver.cjs.map +1 -1
  60. package/dist/development/src/graphql/resolvers/mutation/SetVariablesMutationResolver.js +1 -1
  61. package/dist/development/src/graphql/resolvers/mutation/SetVariablesMutationResolver.js.map +1 -1
  62. package/dist/development/src/graphql/resolvers/mutation/StopEventMutationResolver.cjs.map +1 -1
  63. package/dist/development/src/graphql/resolvers/mutation/StopEventMutationResolver.js.map +1 -1
  64. package/dist/development/src/graphql/resolvers/query/EventsQueryResolver.cjs +1 -1
  65. package/dist/development/src/graphql/resolvers/query/EventsQueryResolver.cjs.map +1 -1
  66. package/dist/development/src/graphql/resolvers/query/EventsQueryResolver.js +1 -1
  67. package/dist/development/src/graphql/resolvers/query/EventsQueryResolver.js.map +1 -1
  68. package/dist/development/src/graphql/resolvers/query/VariablesQueryResolver.cjs +1 -4
  69. package/dist/development/src/graphql/resolvers/query/VariablesQueryResolver.cjs.map +1 -1
  70. package/dist/development/src/graphql/resolvers/query/VariablesQueryResolver.js +1 -4
  71. package/dist/development/src/graphql/resolvers/query/VariablesQueryResolver.js.map +1 -1
  72. package/dist/development/src/graphql/schema/actions.graphql.cjs +20 -8
  73. package/dist/development/src/graphql/schema/actions.graphql.cjs.map +1 -1
  74. package/dist/development/src/graphql/schema/actions.graphql.js +20 -8
  75. package/dist/development/src/graphql/schema/actions.graphql.js.map +1 -1
  76. package/dist/development/src/migrations/index.cjs.map +1 -1
  77. package/dist/development/src/migrations/index.js.map +1 -1
  78. package/dist/development/src/model/EventByIdQuery.cjs.map +1 -1
  79. package/dist/development/src/model/EventByIdQuery.js.map +1 -1
  80. package/dist/development/src/model/EventsInProcessingQuery.cjs.map +1 -1
  81. package/dist/development/src/model/EventsInProcessingQuery.js.map +1 -1
  82. package/dist/development/src/model/EventsToProcessQuery.cjs.map +1 -1
  83. package/dist/development/src/model/EventsToProcessQuery.js.map +1 -1
  84. package/dist/development/src/model/FailedEventsQuery.cjs.map +1 -1
  85. package/dist/development/src/model/FailedEventsQuery.js.map +1 -1
  86. package/dist/development/src/model/VariablesManager.cjs +54 -5
  87. package/dist/development/src/model/VariablesManager.cjs.map +1 -1
  88. package/dist/development/src/model/VariablesManager.js +54 -5
  89. package/dist/development/src/model/VariablesManager.js.map +1 -1
  90. package/dist/development/src/triggers/TriggerHandler.cjs.map +1 -1
  91. package/dist/development/src/triggers/TriggerHandler.js.map +1 -1
  92. package/dist/development/src/triggers/TriggerIndirectChangesFetcher.cjs.map +1 -1
  93. package/dist/development/src/triggers/TriggerIndirectChangesFetcher.js.map +1 -1
  94. package/dist/development/src/triggers/TriggerListenersBuilder.cjs.map +1 -1
  95. package/dist/development/src/triggers/TriggerListenersBuilder.js.map +1 -1
  96. package/dist/development/src/triggers/TriggerListenersFactory.cjs.map +1 -1
  97. package/dist/development/src/triggers/TriggerListenersFactory.js.map +1 -1
  98. package/dist/development/src/triggers/TriggerListenersStore.cjs.map +1 -1
  99. package/dist/development/src/triggers/TriggerListenersStore.js.map +1 -1
  100. package/dist/development/src/triggers/TriggerPayloadBuilder.cjs.map +1 -1
  101. package/dist/development/src/triggers/TriggerPayloadBuilder.js.map +1 -1
  102. package/dist/development/src/triggers/TriggerPayloadManager.cjs.map +1 -1
  103. package/dist/development/src/triggers/TriggerPayloadManager.js.map +1 -1
  104. package/dist/development/src/triggers/TriggerPayloadPersister.cjs +3 -1
  105. package/dist/development/src/triggers/TriggerPayloadPersister.cjs.map +1 -1
  106. package/dist/development/src/triggers/TriggerPayloadPersister.js +3 -1
  107. package/dist/development/src/triggers/TriggerPayloadPersister.js.map +1 -1
  108. package/dist/production/index.cjs +24 -11
  109. package/dist/production/index.cjs.map +1 -1
  110. package/dist/production/index.js +24 -11
  111. package/dist/production/index.js.map +1 -1
  112. package/dist/production/src/ActionsExecutionContainerHookFactory.cjs +5 -2
  113. package/dist/production/src/ActionsExecutionContainerHookFactory.cjs.map +1 -1
  114. package/dist/production/src/ActionsExecutionContainerHookFactory.js +5 -2
  115. package/dist/production/src/ActionsExecutionContainerHookFactory.js.map +1 -1
  116. package/dist/production/src/ActionsMetrics.cjs +98 -0
  117. package/dist/production/src/ActionsMetrics.cjs.map +1 -0
  118. package/dist/production/src/ActionsMetrics.js +98 -0
  119. package/dist/production/src/ActionsMetrics.js.map +1 -0
  120. package/dist/production/src/ListenerStoreProvider.cjs.map +1 -1
  121. package/dist/production/src/ListenerStoreProvider.js.map +1 -1
  122. package/dist/production/src/authorization/ActionsPermissionsFactory.cjs.map +1 -1
  123. package/dist/production/src/authorization/ActionsPermissionsFactory.js.map +1 -1
  124. package/dist/production/src/dispatch/DispatchWorkerSupervisor.cjs.map +1 -1
  125. package/dist/production/src/dispatch/DispatchWorkerSupervisor.js.map +1 -1
  126. package/dist/production/src/dispatch/EventDispatcher.cjs +64 -23
  127. package/dist/production/src/dispatch/EventDispatcher.cjs.map +1 -1
  128. package/dist/production/src/dispatch/EventDispatcher.js +64 -23
  129. package/dist/production/src/dispatch/EventDispatcher.js.map +1 -1
  130. package/dist/production/src/dispatch/EventsRepository.cjs +49 -20
  131. package/dist/production/src/dispatch/EventsRepository.cjs.map +1 -1
  132. package/dist/production/src/dispatch/EventsRepository.js +49 -20
  133. package/dist/production/src/dispatch/EventsRepository.js.map +1 -1
  134. package/dist/production/src/dispatch/LazyDispatchWorker.cjs.map +1 -1
  135. package/dist/production/src/dispatch/LazyDispatchWorker.js.map +1 -1
  136. package/dist/production/src/dispatch/ProjectDispatcher.cjs +63 -21
  137. package/dist/production/src/dispatch/ProjectDispatcher.cjs.map +1 -1
  138. package/dist/production/src/dispatch/ProjectDispatcher.js +63 -21
  139. package/dist/production/src/dispatch/ProjectDispatcher.js.map +1 -1
  140. package/dist/production/src/dispatch/TargetHandlerResolver.cjs.map +1 -1
  141. package/dist/production/src/dispatch/TargetHandlerResolver.js.map +1 -1
  142. package/dist/production/src/dispatch/WebhookTargetHandler.cjs +104 -4
  143. package/dist/production/src/dispatch/WebhookTargetHandler.cjs.map +1 -1
  144. package/dist/production/src/dispatch/WebhookTargetHandler.js +104 -4
  145. package/dist/production/src/dispatch/WebhookTargetHandler.js.map +1 -1
  146. package/dist/production/src/graphql/http/ActionsApiMiddlewareFactory.cjs.map +1 -1
  147. package/dist/production/src/graphql/http/ActionsApiMiddlewareFactory.js.map +1 -1
  148. package/dist/production/src/graphql/http/ActionsContextResolver.cjs.map +1 -1
  149. package/dist/production/src/graphql/http/ActionsContextResolver.js.map +1 -1
  150. package/dist/production/src/graphql/http/ActionsGraphQLHandlerFactory.cjs.map +1 -1
  151. package/dist/production/src/graphql/http/ActionsGraphQLHandlerFactory.js.map +1 -1
  152. package/dist/production/src/graphql/http/ActionsWebsocketControllerFactory.cjs +68 -28
  153. package/dist/production/src/graphql/http/ActionsWebsocketControllerFactory.cjs.map +1 -1
  154. package/dist/production/src/graphql/http/ActionsWebsocketControllerFactory.js +68 -28
  155. package/dist/production/src/graphql/http/ActionsWebsocketControllerFactory.js.map +1 -1
  156. package/dist/production/src/graphql/resolvers/ResolversFactory.cjs +1 -1
  157. package/dist/production/src/graphql/resolvers/ResolversFactory.cjs.map +1 -1
  158. package/dist/production/src/graphql/resolvers/ResolversFactory.js +1 -1
  159. package/dist/production/src/graphql/resolvers/ResolversFactory.js.map +1 -1
  160. package/dist/production/src/graphql/resolvers/mutation/ProcessBatchMutationResolver.cjs.map +1 -1
  161. package/dist/production/src/graphql/resolvers/mutation/ProcessBatchMutationResolver.js.map +1 -1
  162. package/dist/production/src/graphql/resolvers/mutation/RetryEventMutationResolver.cjs.map +1 -1
  163. package/dist/production/src/graphql/resolvers/mutation/RetryEventMutationResolver.js.map +1 -1
  164. package/dist/production/src/graphql/resolvers/mutation/SetVariablesMutationResolver.cjs +1 -1
  165. package/dist/production/src/graphql/resolvers/mutation/SetVariablesMutationResolver.cjs.map +1 -1
  166. package/dist/production/src/graphql/resolvers/mutation/SetVariablesMutationResolver.js +1 -1
  167. package/dist/production/src/graphql/resolvers/mutation/SetVariablesMutationResolver.js.map +1 -1
  168. package/dist/production/src/graphql/resolvers/mutation/StopEventMutationResolver.cjs.map +1 -1
  169. package/dist/production/src/graphql/resolvers/mutation/StopEventMutationResolver.js.map +1 -1
  170. package/dist/production/src/graphql/resolvers/query/EventsQueryResolver.cjs +1 -1
  171. package/dist/production/src/graphql/resolvers/query/EventsQueryResolver.cjs.map +1 -1
  172. package/dist/production/src/graphql/resolvers/query/EventsQueryResolver.js +1 -1
  173. package/dist/production/src/graphql/resolvers/query/EventsQueryResolver.js.map +1 -1
  174. package/dist/production/src/graphql/resolvers/query/VariablesQueryResolver.cjs +1 -4
  175. package/dist/production/src/graphql/resolvers/query/VariablesQueryResolver.cjs.map +1 -1
  176. package/dist/production/src/graphql/resolvers/query/VariablesQueryResolver.js +1 -4
  177. package/dist/production/src/graphql/resolvers/query/VariablesQueryResolver.js.map +1 -1
  178. package/dist/production/src/graphql/schema/actions.graphql.cjs +20 -8
  179. package/dist/production/src/graphql/schema/actions.graphql.cjs.map +1 -1
  180. package/dist/production/src/graphql/schema/actions.graphql.js +20 -8
  181. package/dist/production/src/graphql/schema/actions.graphql.js.map +1 -1
  182. package/dist/production/src/migrations/index.cjs.map +1 -1
  183. package/dist/production/src/migrations/index.js.map +1 -1
  184. package/dist/production/src/model/EventByIdQuery.cjs.map +1 -1
  185. package/dist/production/src/model/EventByIdQuery.js.map +1 -1
  186. package/dist/production/src/model/EventsInProcessingQuery.cjs.map +1 -1
  187. package/dist/production/src/model/EventsInProcessingQuery.js.map +1 -1
  188. package/dist/production/src/model/EventsToProcessQuery.cjs.map +1 -1
  189. package/dist/production/src/model/EventsToProcessQuery.js.map +1 -1
  190. package/dist/production/src/model/FailedEventsQuery.cjs.map +1 -1
  191. package/dist/production/src/model/FailedEventsQuery.js.map +1 -1
  192. package/dist/production/src/model/VariablesManager.cjs +54 -5
  193. package/dist/production/src/model/VariablesManager.cjs.map +1 -1
  194. package/dist/production/src/model/VariablesManager.js +54 -5
  195. package/dist/production/src/model/VariablesManager.js.map +1 -1
  196. package/dist/production/src/triggers/TriggerHandler.cjs.map +1 -1
  197. package/dist/production/src/triggers/TriggerHandler.js.map +1 -1
  198. package/dist/production/src/triggers/TriggerIndirectChangesFetcher.cjs.map +1 -1
  199. package/dist/production/src/triggers/TriggerIndirectChangesFetcher.js.map +1 -1
  200. package/dist/production/src/triggers/TriggerListenersBuilder.cjs.map +1 -1
  201. package/dist/production/src/triggers/TriggerListenersBuilder.js.map +1 -1
  202. package/dist/production/src/triggers/TriggerListenersFactory.cjs.map +1 -1
  203. package/dist/production/src/triggers/TriggerListenersFactory.js.map +1 -1
  204. package/dist/production/src/triggers/TriggerListenersStore.cjs.map +1 -1
  205. package/dist/production/src/triggers/TriggerListenersStore.js.map +1 -1
  206. package/dist/production/src/triggers/TriggerPayloadBuilder.cjs.map +1 -1
  207. package/dist/production/src/triggers/TriggerPayloadBuilder.js.map +1 -1
  208. package/dist/production/src/triggers/TriggerPayloadManager.cjs.map +1 -1
  209. package/dist/production/src/triggers/TriggerPayloadManager.js.map +1 -1
  210. package/dist/production/src/triggers/TriggerPayloadPersister.cjs +3 -1
  211. package/dist/production/src/triggers/TriggerPayloadPersister.cjs.map +1 -1
  212. package/dist/production/src/triggers/TriggerPayloadPersister.js +3 -1
  213. package/dist/production/src/triggers/TriggerPayloadPersister.js.map +1 -1
  214. package/dist/tests/cases/unit/actionsMetrics.test.d.ts +2 -0
  215. package/dist/tests/cases/unit/actionsMetrics.test.d.ts.map +1 -0
  216. package/dist/tests/cases/unit/actionsWebsocketController.test.d.ts +2 -0
  217. package/dist/tests/cases/unit/actionsWebsocketController.test.d.ts.map +1 -0
  218. package/dist/tests/cases/unit/dispatchTracing.test.d.ts +2 -0
  219. package/dist/tests/cases/unit/dispatchTracing.test.d.ts.map +1 -0
  220. package/dist/tests/cases/unit/eventsRepository.test.d.ts +2 -0
  221. package/dist/tests/cases/unit/eventsRepository.test.d.ts.map +1 -0
  222. package/dist/tests/cases/unit/projectDispatcher.test.d.ts +2 -0
  223. package/dist/tests/cases/unit/projectDispatcher.test.d.ts.map +1 -0
  224. package/dist/tests/cases/unit/variablesManager.test.d.ts +2 -0
  225. package/dist/tests/cases/unit/variablesManager.test.d.ts.map +1 -0
  226. package/dist/tests/cases/unit/webhookTracing.test.d.ts +2 -0
  227. package/dist/tests/cases/unit/webhookTracing.test.d.ts.map +1 -0
  228. package/dist/tests/src/event.d.ts +4 -0
  229. package/dist/tests/src/event.d.ts.map +1 -0
  230. package/dist/tests/src/gql.d.ts.map +1 -1
  231. package/dist/tests/src/tracer.d.ts +7 -0
  232. package/dist/tests/src/tracer.d.ts.map +1 -0
  233. package/dist/tests/src/utils.d.ts +6 -0
  234. package/dist/tests/src/utils.d.ts.map +1 -0
  235. package/dist/tests/src/uuid.d.ts.map +1 -1
  236. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  237. package/dist/types/ActionsExecutionContainerHookFactory.d.ts +4 -2
  238. package/dist/types/ActionsExecutionContainerHookFactory.d.ts.map +1 -1
  239. package/dist/types/ActionsMetrics.d.ts +59 -0
  240. package/dist/types/ActionsMetrics.d.ts.map +1 -0
  241. package/dist/types/ListenerStoreProvider.d.ts +1 -1
  242. package/dist/types/ListenerStoreProvider.d.ts.map +1 -1
  243. package/dist/types/authorization/ActionsPermissionsFactory.d.ts.map +1 -1
  244. package/dist/types/authorization/index.d.ts +3 -3
  245. package/dist/types/authorization/index.d.ts.map +1 -1
  246. package/dist/types/dispatch/DispatchWorkerSupervisor.d.ts +1 -1
  247. package/dist/types/dispatch/DispatchWorkerSupervisor.d.ts.map +1 -1
  248. package/dist/types/dispatch/EventDispatcher.d.ts +18 -7
  249. package/dist/types/dispatch/EventDispatcher.d.ts.map +1 -1
  250. package/dist/types/dispatch/EventsRepository.d.ts +15 -3
  251. package/dist/types/dispatch/EventsRepository.d.ts.map +1 -1
  252. package/dist/types/dispatch/LazyDispatchWorker.d.ts +1 -1
  253. package/dist/types/dispatch/LazyDispatchWorker.d.ts.map +1 -1
  254. package/dist/types/dispatch/ProjectDispatcher.d.ts +11 -3
  255. package/dist/types/dispatch/ProjectDispatcher.d.ts.map +1 -1
  256. package/dist/types/dispatch/TargetHandlerResolver.d.ts +2 -2
  257. package/dist/types/dispatch/TargetHandlerResolver.d.ts.map +1 -1
  258. package/dist/types/dispatch/WebhookFetcher.d.ts.map +1 -1
  259. package/dist/types/dispatch/WebhookTargetHandler.d.ts +10 -3
  260. package/dist/types/dispatch/WebhookTargetHandler.d.ts.map +1 -1
  261. package/dist/types/dispatch/types.d.ts +2 -2
  262. package/dist/types/dispatch/types.d.ts.map +1 -1
  263. package/dist/types/graphql/http/ActionsApiMiddlewareFactory.d.ts +3 -3
  264. package/dist/types/graphql/http/ActionsApiMiddlewareFactory.d.ts.map +1 -1
  265. package/dist/types/graphql/http/ActionsContextResolver.d.ts +1 -1
  266. package/dist/types/graphql/http/ActionsContextResolver.d.ts.map +1 -1
  267. package/dist/types/graphql/http/ActionsGraphQLHandlerFactory.d.ts +2 -2
  268. package/dist/types/graphql/http/ActionsGraphQLHandlerFactory.d.ts.map +1 -1
  269. package/dist/types/graphql/http/ActionsWebsocketControllerFactory.d.ts +7 -5
  270. package/dist/types/graphql/http/ActionsWebsocketControllerFactory.d.ts.map +1 -1
  271. package/dist/types/graphql/resolvers/ResolversFactory.d.ts +4 -4
  272. package/dist/types/graphql/resolvers/ResolversFactory.d.ts.map +1 -1
  273. package/dist/types/graphql/resolvers/index.d.ts +2 -2
  274. package/dist/types/graphql/resolvers/index.d.ts.map +1 -1
  275. package/dist/types/graphql/resolvers/mutation/ProcessBatchMutationResolver.d.ts +3 -3
  276. package/dist/types/graphql/resolvers/mutation/ProcessBatchMutationResolver.d.ts.map +1 -1
  277. package/dist/types/graphql/resolvers/mutation/RetryEventMutationResolver.d.ts +3 -3
  278. package/dist/types/graphql/resolvers/mutation/RetryEventMutationResolver.d.ts.map +1 -1
  279. package/dist/types/graphql/resolvers/mutation/SetVariablesMutationResolver.d.ts +3 -3
  280. package/dist/types/graphql/resolvers/mutation/SetVariablesMutationResolver.d.ts.map +1 -1
  281. package/dist/types/graphql/resolvers/mutation/StopEventMutationResolver.d.ts +3 -3
  282. package/dist/types/graphql/resolvers/mutation/StopEventMutationResolver.d.ts.map +1 -1
  283. package/dist/types/graphql/resolvers/mutation/index.d.ts +4 -4
  284. package/dist/types/graphql/resolvers/mutation/index.d.ts.map +1 -1
  285. package/dist/types/graphql/resolvers/query/EventsQueryResolver.d.ts +2 -2
  286. package/dist/types/graphql/resolvers/query/EventsQueryResolver.d.ts.map +1 -1
  287. package/dist/types/graphql/resolvers/query/VariablesQueryResolver.d.ts +4 -7
  288. package/dist/types/graphql/resolvers/query/VariablesQueryResolver.d.ts.map +1 -1
  289. package/dist/types/graphql/resolvers/query/index.d.ts +1 -1
  290. package/dist/types/graphql/resolvers/query/index.d.ts.map +1 -1
  291. package/dist/types/graphql/schema/actions.graphql.d.ts.map +1 -1
  292. package/dist/types/graphql/schema/index.d.ts +27 -17
  293. package/dist/types/graphql/schema/index.d.ts.map +1 -1
  294. package/dist/types/index.d.ts +9 -3
  295. package/dist/types/index.d.ts.map +1 -1
  296. package/dist/types/model/EventByIdQuery.d.ts +1 -1
  297. package/dist/types/model/EventByIdQuery.d.ts.map +1 -1
  298. package/dist/types/model/EventsInProcessingQuery.d.ts +2 -2
  299. package/dist/types/model/EventsInProcessingQuery.d.ts.map +1 -1
  300. package/dist/types/model/EventsToProcessQuery.d.ts +2 -2
  301. package/dist/types/model/EventsToProcessQuery.d.ts.map +1 -1
  302. package/dist/types/model/FailedEventsQuery.d.ts +2 -2
  303. package/dist/types/model/FailedEventsQuery.d.ts.map +1 -1
  304. package/dist/types/model/SetVariableCommand.d.ts.map +1 -1
  305. package/dist/types/model/VariablesManager.d.ts +16 -3
  306. package/dist/types/model/VariablesManager.d.ts.map +1 -1
  307. package/dist/types/model/VariablesQuery.d.ts.map +1 -1
  308. package/dist/types/triggers/TriggerHandler.d.ts +3 -3
  309. package/dist/types/triggers/TriggerHandler.d.ts.map +1 -1
  310. package/dist/types/triggers/TriggerIndirectChangesFetcher.d.ts +1 -1
  311. package/dist/types/triggers/TriggerIndirectChangesFetcher.d.ts.map +1 -1
  312. package/dist/types/triggers/TriggerListeners.d.ts +1 -1
  313. package/dist/types/triggers/TriggerListeners.d.ts.map +1 -1
  314. package/dist/types/triggers/TriggerListenersBuilder.d.ts +1 -1
  315. package/dist/types/triggers/TriggerListenersBuilder.d.ts.map +1 -1
  316. package/dist/types/triggers/TriggerListenersFactory.d.ts +1 -1
  317. package/dist/types/triggers/TriggerListenersFactory.d.ts.map +1 -1
  318. package/dist/types/triggers/TriggerListenersStore.d.ts +1 -1
  319. package/dist/types/triggers/TriggerListenersStore.d.ts.map +1 -1
  320. package/dist/types/triggers/TriggerPayloadBuilder.d.ts +1 -1
  321. package/dist/types/triggers/TriggerPayloadBuilder.d.ts.map +1 -1
  322. package/dist/types/triggers/TriggerPayloadManager.d.ts +4 -4
  323. package/dist/types/triggers/TriggerPayloadManager.d.ts.map +1 -1
  324. package/dist/types/triggers/TriggerPayloadPersister.d.ts +3 -1
  325. package/dist/types/triggers/TriggerPayloadPersister.d.ts.map +1 -1
  326. package/dist/types/triggers/index.d.ts +7 -7
  327. package/dist/types/triggers/index.d.ts.map +1 -1
  328. package/dist/types/tsconfig.tsbuildinfo +1 -1
  329. package/dist/types/utils/map.d.ts.map +1 -1
  330. package/dist/types/utils/notifyChannel.d.ts.map +1 -1
  331. package/graphql.codegen.yml +1 -1
  332. package/package.json +19 -16
  333. package/src/ActionsExecutionContainerHookFactory.ts +10 -4
  334. package/src/ActionsMetrics.ts +135 -0
  335. package/src/ListenerStoreProvider.ts +1 -1
  336. package/src/authorization/ActionsPermissionsFactory.ts +1 -1
  337. package/src/authorization/index.ts +3 -3
  338. package/src/dispatch/DispatchWorkerSupervisor.ts +2 -2
  339. package/src/dispatch/EventDispatcher.ts +77 -28
  340. package/src/dispatch/EventsRepository.ts +72 -29
  341. package/src/dispatch/LazyDispatchWorker.ts +1 -1
  342. package/src/dispatch/ProjectDispatcher.ts +81 -21
  343. package/src/dispatch/TargetHandlerResolver.ts +3 -3
  344. package/src/dispatch/WebhookTargetHandler.ts +119 -5
  345. package/src/dispatch/types.ts +2 -2
  346. package/src/graphql/http/ActionsApiMiddlewareFactory.ts +4 -4
  347. package/src/graphql/http/ActionsContextResolver.ts +1 -1
  348. package/src/graphql/http/ActionsGraphQLHandlerFactory.ts +3 -2
  349. package/src/graphql/http/ActionsWebsocketControllerFactory.ts +73 -30
  350. package/src/graphql/resolvers/ResolversFactory.ts +11 -6
  351. package/src/graphql/resolvers/index.ts +2 -2
  352. package/src/graphql/resolvers/mutation/ProcessBatchMutationResolver.ts +4 -4
  353. package/src/graphql/resolvers/mutation/RetryEventMutationResolver.ts +5 -5
  354. package/src/graphql/resolvers/mutation/SetVariablesMutationResolver.ts +5 -5
  355. package/src/graphql/resolvers/mutation/StopEventMutationResolver.ts +4 -4
  356. package/src/graphql/resolvers/mutation/index.ts +4 -4
  357. package/src/graphql/resolvers/query/EventsQueryResolver.ts +9 -9
  358. package/src/graphql/resolvers/query/VariablesQueryResolver.ts +5 -8
  359. package/src/graphql/resolvers/query/index.ts +1 -1
  360. package/src/graphql/schema/actions.graphql.ts +20 -8
  361. package/src/graphql/schema/index.ts +30 -17
  362. package/src/index.ts +61 -32
  363. package/src/migrations/index.ts +3 -3
  364. package/src/model/EventByIdQuery.ts +1 -1
  365. package/src/model/EventsInProcessingQuery.ts +2 -2
  366. package/src/model/EventsToProcessQuery.ts +3 -3
  367. package/src/model/FailedEventsQuery.ts +2 -2
  368. package/src/model/VariablesManager.ts +68 -8
  369. package/src/triggers/TriggerHandler.ts +3 -3
  370. package/src/triggers/TriggerIndirectChangesFetcher.ts +1 -1
  371. package/src/triggers/TriggerListeners.ts +1 -1
  372. package/src/triggers/TriggerListenersBuilder.ts +4 -4
  373. package/src/triggers/TriggerListenersFactory.ts +2 -2
  374. package/src/triggers/TriggerListenersStore.ts +1 -1
  375. package/src/triggers/TriggerPayloadBuilder.ts +3 -3
  376. package/src/triggers/TriggerPayloadManager.ts +4 -4
  377. package/src/triggers/TriggerPayloadPersister.ts +8 -2
  378. package/src/triggers/index.ts +7 -7
  379. package/src/tsconfig.json +1 -0
  380. package/tests/cases/unit/actionsMetrics.test.ts +76 -0
  381. package/tests/cases/unit/actionsWebsocketController.test.ts +270 -0
  382. package/tests/cases/unit/dispatchTracing.test.ts +204 -0
  383. package/tests/cases/unit/eventsRepository.test.ts +158 -0
  384. package/tests/cases/unit/generator.test.ts +1 -1
  385. package/tests/cases/unit/lazyDispatchWorker.test.ts +2 -2
  386. package/tests/cases/unit/projectDispatcher.test.ts +114 -0
  387. package/tests/cases/unit/variablesManager.test.ts +154 -0
  388. package/tests/cases/unit/webhookHandler.test.ts +94 -35
  389. package/tests/cases/unit/webhookTracing.test.ts +163 -0
  390. package/tests/src/event.ts +27 -0
  391. package/tests/src/tracer.ts +11 -0
  392. package/tests/src/utils.ts +5 -0
@@ -1,7 +1,7 @@
1
- import { MutationResolvers, MutationRetryEventArgs } from '../../schema'
2
- import { ActionsContext } from '../ActionsContext'
3
- import { ActionsAuthorizationActions } from '../../../authorization'
4
- import { EventsRepository } from '../../../dispatch/EventsRepository'
1
+ import { MutationResolvers, MutationRetryEventArgs } from '../../schema/index.js'
2
+ import { ActionsContext } from '../ActionsContext.js'
3
+ import { ActionsAuthorizationActions } from '../../../authorization/index.js'
4
+ import { EventsRepository } from '../../../dispatch/EventsRepository.js'
5
5
 
6
6
  export class StopEventMutationResolver implements MutationResolvers<ActionsContext> {
7
7
  constructor(
@@ -1,4 +1,4 @@
1
- export * from './ProcessBatchMutationResolver'
2
- export * from './SetVariablesMutationResolver'
3
- export * from './RetryEventMutationResolver'
4
- export * from './StopEventMutationResolver'
1
+ export * from './ProcessBatchMutationResolver.js'
2
+ export * from './SetVariablesMutationResolver.js'
3
+ export * from './RetryEventMutationResolver.js'
4
+ export * from './StopEventMutationResolver.js'
@@ -1,13 +1,13 @@
1
- import { Event, QueryEventsInProcessingArgs, QueryEventsToProcessArgs, QueryFailedEventsArgs, QueryResolvers } from '../../schema'
2
- import { ActionsContext } from '../ActionsContext'
3
- import { EventsToProcessQuery } from '../../../model/EventsToProcessQuery'
4
- import { EventRow } from '../../../model/types'
1
+ import { Event, QueryEventsInProcessingArgs, QueryEventsToProcessArgs, QueryFailedEventsArgs, QueryResolvers } from '../../schema/index.js'
2
+ import { ActionsContext } from '../ActionsContext.js'
3
+ import { EventsToProcessQuery } from '../../../model/EventsToProcessQuery.js'
4
+ import { EventRow } from '../../../model/types.js'
5
5
  import { DatabaseContext, StagesQuery } from '@contember/engine-system-api'
6
6
  import { Client, DatabaseQuery } from '@contember/database'
7
- import { EventsInProcessingQuery } from '../../../model/EventsInProcessingQuery'
8
- import { FailedEventsQuery } from '../../../model/FailedEventsQuery'
9
- import { ActionsAuthorizationActions } from '../../../authorization'
10
- import { EventByIdQuery } from '../../../model/EventByIdQuery'
7
+ import { EventsInProcessingQuery } from '../../../model/EventsInProcessingQuery.js'
8
+ import { FailedEventsQuery } from '../../../model/FailedEventsQuery.js'
9
+ import { ActionsAuthorizationActions } from '../../../authorization/index.js'
10
+ import { EventByIdQuery } from '../../../model/EventByIdQuery.js'
11
11
 
12
12
  export class EventsQueryResolver implements QueryResolvers<ActionsContext> {
13
13
  async eventsInProcessing(parent: unknown, { args }: QueryEventsInProcessingArgs, ctx: ActionsContext) {
@@ -51,7 +51,7 @@ export class EventsQueryResolver implements QueryResolvers<ActionsContext> {
51
51
  return rows.map(row => ({
52
52
  id: row.id,
53
53
  createdAt: row.created_at,
54
- resolvedAt: row.created_at,
54
+ resolvedAt: row.resolved_at ?? undefined,
55
55
  lastStateChange: row.last_state_change,
56
56
  visibleAt: row.visible_at,
57
57
  log: row.log,
@@ -1,7 +1,7 @@
1
- import { QueryResolvers } from '../../schema'
2
- import { ActionsContext } from '../ActionsContext'
3
- import { VariablesManager } from '../../../model/VariablesManager'
4
- import { ActionsAuthorizationActions } from '../../../authorization'
1
+ import { QueryResolvers } from '../../schema/index.js'
2
+ import { ActionsContext } from '../ActionsContext.js'
3
+ import { VariablesManager } from '../../../model/VariablesManager.js'
4
+ import { ActionsAuthorizationActions } from '../../../authorization/index.js'
5
5
 
6
6
  export class VariablesQueryResolver implements QueryResolvers<ActionsContext> {
7
7
  constructor(
@@ -12,9 +12,6 @@ export class VariablesQueryResolver implements QueryResolvers<ActionsContext> {
12
12
  async variables(parent: unknown, args: unknown, ctx: ActionsContext) {
13
13
  await ctx.requireAccess(ActionsAuthorizationActions.VARIABLES_VIEW)
14
14
 
15
- return Object.entries(await this.variablesManager.fetchVariables(ctx.db)).map(([name, value]) => ({
16
- name,
17
- value,
18
- }))
15
+ return await this.variablesManager.listVariables(ctx.db, ctx.project.slug)
19
16
  }
20
17
  }
@@ -1 +1 @@
1
- export * from './EventsQueryResolver'
1
+ export * from './EventsQueryResolver.js'
@@ -4,7 +4,7 @@ import { DocumentNode } from 'graphql'
4
4
  export const schema: DocumentNode = gql`
5
5
  scalar DateTime
6
6
  scalar Json
7
- scalar Uuid
7
+ scalar UUID
8
8
 
9
9
  schema {
10
10
  query: Query
@@ -15,14 +15,14 @@ export const schema: DocumentNode = gql`
15
15
  failedEvents(args: EventArgs): [Event!]!
16
16
  eventsToProcess(args: EventArgs): [Event!]!
17
17
  eventsInProcessing(args: EventArgs): [Event!]!
18
- event(id: Uuid!): Event
18
+ event(id: UUID!): Event
19
19
  variables: [Variable!]!
20
20
  }
21
21
 
22
22
  type Mutation {
23
23
  processBatch: ProcessBatchResponse!
24
- retryEvent(id: Uuid!): RetryEventResponse!
25
- stopEvent(id: Uuid!): StopEventResponse!
24
+ retryEvent(id: UUID!): RetryEventResponse!
25
+ stopEvent(id: UUID!): StopEventResponse!
26
26
  setVariables(args: SetVariablesArgs!): SetVariablesResponse!
27
27
  }
28
28
 
@@ -33,9 +33,9 @@ export const schema: DocumentNode = gql`
33
33
  }
34
34
 
35
35
  type Event {
36
- id: Uuid!
37
- transactionId: Uuid!
38
- identityId: Uuid
36
+ id: UUID!
37
+ transactionId: UUID!
38
+ identityId: UUID
39
39
  ipAddress: String
40
40
  userAgent: String
41
41
  createdAt: DateTime!
@@ -99,7 +99,19 @@ export const schema: DocumentNode = gql`
99
99
 
100
100
  type Variable {
101
101
  name: String!
102
- value: String!
102
+ """Null when the value is not readable, which is every ENVIRONMENT one."""
103
+ value: String
104
+ source: VariableSource!
103
105
  }
104
106
 
107
+ """
108
+ Where the value comes from.
109
+ - DATABASE is stored in the project database, readable and writable with setVariables
110
+ - ENVIRONMENT is supplied by the engine environment, overrides a stored value of the same name, and is neither readable nor writable
111
+ """
112
+ enum VariableSource {
113
+ DATABASE
114
+ ENVIRONMENT
115
+ }
116
+
105
117
  `
@@ -16,14 +16,14 @@ export type Scalars = {
16
16
  Float: { input: number; output: number }
17
17
  DateTime: { input: Date; output: Date }
18
18
  Json: { input: any; output: any }
19
- Uuid: { input: string; output: string }
19
+ UUID: { input: string; output: string }
20
20
  }
21
21
 
22
22
  export type Event = {
23
23
  readonly __typename?: 'Event'
24
24
  readonly createdAt: Scalars['DateTime']['output']
25
- readonly id: Scalars['Uuid']['output']
26
- readonly identityId?: Maybe<Scalars['Uuid']['output']>
25
+ readonly id: Scalars['UUID']['output']
26
+ readonly identityId?: Maybe<Scalars['UUID']['output']>
27
27
  readonly ipAddress?: Maybe<Scalars['String']['output']>
28
28
  readonly lastStateChange: Scalars['DateTime']['output']
29
29
  readonly log: Scalars['Json']['output']
@@ -33,7 +33,7 @@ export type Event = {
33
33
  readonly stage: Scalars['String']['output']
34
34
  readonly state: EventState
35
35
  readonly target: Scalars['String']['output']
36
- readonly transactionId: Scalars['Uuid']['output']
36
+ readonly transactionId: Scalars['UUID']['output']
37
37
  readonly userAgent?: Maybe<Scalars['String']['output']>
38
38
  readonly visibleAt?: Maybe<Scalars['DateTime']['output']>
39
39
  }
@@ -61,7 +61,7 @@ export type Mutation = {
61
61
  }
62
62
 
63
63
  export type MutationRetryEventArgs = {
64
- id: Scalars['Uuid']['input']
64
+ id: Scalars['UUID']['input']
65
65
  }
66
66
 
67
67
  export type MutationSetVariablesArgs = {
@@ -69,7 +69,7 @@ export type MutationSetVariablesArgs = {
69
69
  }
70
70
 
71
71
  export type MutationStopEventArgs = {
72
- id: Scalars['Uuid']['input']
72
+ id: Scalars['UUID']['input']
73
73
  }
74
74
 
75
75
  export type ProcessBatchResponse = {
@@ -87,7 +87,7 @@ export type Query = {
87
87
  }
88
88
 
89
89
  export type QueryEventArgs = {
90
- id: Scalars['Uuid']['input']
90
+ id: Scalars['UUID']['input']
91
91
  }
92
92
 
93
93
  export type QueryEventsInProcessingArgs = {
@@ -136,7 +136,9 @@ export type StopEventResponse = {
136
136
  export type Variable = {
137
137
  readonly __typename?: 'Variable'
138
138
  readonly name: Scalars['String']['output']
139
- readonly value: Scalars['String']['output']
139
+ readonly source: VariableSource
140
+ /** Null when the value is not readable, which is every ENVIRONMENT one. */
141
+ readonly value?: Maybe<Scalars['String']['output']>
140
142
  }
141
143
 
142
144
  export type VariableInput = {
@@ -144,6 +146,15 @@ export type VariableInput = {
144
146
  readonly value: Scalars['String']['input']
145
147
  }
146
148
 
149
+ /**
150
+ * Where the value comes from.
151
+ * - DATABASE is stored in the project database, readable and writable with setVariables
152
+ * - ENVIRONMENT is supplied by the engine environment, overrides a stored value of the same name, and is neither readable nor writable
153
+ */
154
+ export type VariableSource =
155
+ | 'DATABASE'
156
+ | 'ENVIRONMENT'
157
+
147
158
  export type ResolverTypeWrapper<T> = Promise<T> | T
148
159
 
149
160
  export type ResolverWithResolve<TResult, TParent, TContext, TArgs> = {
@@ -228,9 +239,10 @@ export type ResolversTypes = {
228
239
  SetVariablesResponse: ResolverTypeWrapper<SetVariablesResponse>
229
240
  StopEventResponse: ResolverTypeWrapper<StopEventResponse>
230
241
  String: ResolverTypeWrapper<Scalars['String']['output']>
231
- Uuid: ResolverTypeWrapper<Scalars['Uuid']['output']>
242
+ UUID: ResolverTypeWrapper<Scalars['UUID']['output']>
232
243
  Variable: ResolverTypeWrapper<Variable>
233
244
  VariableInput: VariableInput
245
+ VariableSource: VariableSource
234
246
  }
235
247
 
236
248
  /** Mapping between all available schema types and the resolvers parents */
@@ -249,7 +261,7 @@ export type ResolversParentTypes = {
249
261
  SetVariablesResponse: SetVariablesResponse
250
262
  StopEventResponse: StopEventResponse
251
263
  String: Scalars['String']['output']
252
- Uuid: Scalars['Uuid']['output']
264
+ UUID: Scalars['UUID']['output']
253
265
  Variable: Variable
254
266
  VariableInput: VariableInput
255
267
  }
@@ -260,8 +272,8 @@ export interface DateTimeScalarConfig extends GraphQLScalarTypeConfig<ResolversT
260
272
 
261
273
  export type EventResolvers<ContextType = any, ParentType extends ResolversParentTypes['Event'] = ResolversParentTypes['Event']> = {
262
274
  createdAt?: Resolver<ResolversTypes['DateTime'], ParentType, ContextType>
263
- id?: Resolver<ResolversTypes['Uuid'], ParentType, ContextType>
264
- identityId?: Resolver<Maybe<ResolversTypes['Uuid']>, ParentType, ContextType>
275
+ id?: Resolver<ResolversTypes['UUID'], ParentType, ContextType>
276
+ identityId?: Resolver<Maybe<ResolversTypes['UUID']>, ParentType, ContextType>
265
277
  ipAddress?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>
266
278
  lastStateChange?: Resolver<ResolversTypes['DateTime'], ParentType, ContextType>
267
279
  log?: Resolver<ResolversTypes['Json'], ParentType, ContextType>
@@ -271,7 +283,7 @@ export type EventResolvers<ContextType = any, ParentType extends ResolversParent
271
283
  stage?: Resolver<ResolversTypes['String'], ParentType, ContextType>
272
284
  state?: Resolver<ResolversTypes['EventState'], ParentType, ContextType>
273
285
  target?: Resolver<ResolversTypes['String'], ParentType, ContextType>
274
- transactionId?: Resolver<ResolversTypes['Uuid'], ParentType, ContextType>
286
+ transactionId?: Resolver<ResolversTypes['UUID'], ParentType, ContextType>
275
287
  userAgent?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>
276
288
  visibleAt?: Resolver<Maybe<ResolversTypes['DateTime']>, ParentType, ContextType>
277
289
  __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>
@@ -328,13 +340,14 @@ export type StopEventResponseResolvers<
328
340
  __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>
329
341
  }
330
342
 
331
- export interface UuidScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['Uuid'], any> {
332
- name: 'Uuid'
343
+ export interface UUIDScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['UUID'], any> {
344
+ name: 'UUID'
333
345
  }
334
346
 
335
347
  export type VariableResolvers<ContextType = any, ParentType extends ResolversParentTypes['Variable'] = ResolversParentTypes['Variable']> = {
336
348
  name?: Resolver<ResolversTypes['String'], ParentType, ContextType>
337
- value?: Resolver<ResolversTypes['String'], ParentType, ContextType>
349
+ source?: Resolver<ResolversTypes['VariableSource'], ParentType, ContextType>
350
+ value?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>
338
351
  __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>
339
352
  }
340
353
 
@@ -348,6 +361,6 @@ export type Resolvers<ContextType = any> = {
348
361
  RetryEventResponse?: RetryEventResponseResolvers<ContextType>
349
362
  SetVariablesResponse?: SetVariablesResponseResolvers<ContextType>
350
363
  StopEventResponse?: StopEventResponseResolvers<ContextType>
351
- Uuid?: GraphQLScalarType
364
+ UUID?: GraphQLScalarType
352
365
  Variable?: VariableResolvers<ContextType>
353
366
  }
package/src/index.ts CHANGED
@@ -1,66 +1,88 @@
1
1
  import { Plugin } from '@contember/engine-plugins'
2
- import { migrationsGroup } from './migrations'
3
- import { ActionsExecutionContainerHookFactory } from './ActionsExecutionContainerHookFactory'
4
- import { ListenerStoreProvider } from './ListenerStoreProvider'
2
+ import { migrationsGroup } from './migrations/index.js'
3
+ import { ActionsExecutionContainerHookFactory } from './ActionsExecutionContainerHookFactory.js'
4
+ import { ListenerStoreProvider } from './ListenerStoreProvider.js'
5
5
  import { MigrationGroup } from '@contember/database-migrations'
6
6
  import { MasterContainerBuilder, MasterContainerHook } from '@contember/engine-http'
7
- import { ActionsApiMiddlewareFactory } from './graphql/http/ActionsApiMiddlewareFactory'
8
- import { ActionsGraphQLHandlerFactory } from './graphql/http/ActionsGraphQLHandlerFactory'
9
- import { ResolversFactory } from './graphql/resolvers/ResolversFactory'
7
+ import { ActionsApiMiddlewareFactory } from './graphql/http/ActionsApiMiddlewareFactory.js'
8
+ import { ActionsGraphQLHandlerFactory } from './graphql/http/ActionsGraphQLHandlerFactory.js'
9
+ import { ResolversFactory } from './graphql/resolvers/ResolversFactory.js'
10
10
  import {
11
11
  EventsQueryResolver,
12
12
  ProcessBatchMutationResolver,
13
13
  RetryEventMutationResolver,
14
14
  SetVariablesMutationResolver,
15
15
  StopEventMutationResolver,
16
- } from './graphql/resolvers'
17
- import { EventDispatcher } from './dispatch/EventDispatcher'
18
- import { EventsRepository } from './dispatch/EventsRepository'
19
- import { TargetHandlerResolver } from './dispatch/TargetHandlerResolver'
20
- import { WebhookTargetHandler } from './dispatch/WebhookTargetHandler'
21
- import { ActionsContextResolver } from './graphql/http/ActionsContextResolver'
22
- import { ActionsWebsocketControllerFactory } from './graphql/http/ActionsWebsocketControllerFactory'
23
- import { DispatchWorkerSupervisorFactory } from './dispatch/DispatchWorkerSupervisor'
24
- import { LazyDispatchWorker } from './dispatch/LazyDispatchWorker'
25
- import { ProjectDispatcherFactory } from './dispatch/ProjectDispatcher'
26
- import { VariablesQueryResolver } from './graphql/resolvers/query/VariablesQueryResolver'
27
- import { VariablesManager } from './model/VariablesManager'
16
+ } from './graphql/resolvers/index.js'
17
+ import { EventDispatcher } from './dispatch/EventDispatcher.js'
18
+ import { EventsRepository } from './dispatch/EventsRepository.js'
19
+ import { TargetHandlerResolver } from './dispatch/TargetHandlerResolver.js'
20
+ import { WebhookTargetHandler } from './dispatch/WebhookTargetHandler.js'
21
+ import { ActionsContextResolver } from './graphql/http/ActionsContextResolver.js'
22
+ import { ActionsWebsocketControllerFactory } from './graphql/http/ActionsWebsocketControllerFactory.js'
23
+ import { DispatchWorkerSupervisorFactory } from './dispatch/DispatchWorkerSupervisor.js'
24
+ import { LazyDispatchWorker } from './dispatch/LazyDispatchWorker.js'
25
+ import { ProjectDispatcherFactory } from './dispatch/ProjectDispatcher.js'
26
+ import { VariablesQueryResolver } from './graphql/resolvers/query/VariablesQueryResolver.js'
27
+ import { VariablesManager } from './model/VariablesManager.js'
28
28
  import { AccessEvaluator, Authorizator } from '@contember/authorization'
29
- import { ActionsPermissionsFactory } from './authorization'
30
- import { WebhookFetcherNative } from './dispatch/WebhookFetcher'
29
+ import { ActionsPermissionsFactory } from './authorization/index.js'
30
+ import { WebhookFetcherNative } from './dispatch/WebhookFetcher.js'
31
+ import { ActionsMetrics } from './ActionsMetrics.js'
31
32
 
32
- export { TriggerHandler, TriggerIndirectChangesFetcher, TriggerListenersFactory, TriggerListenersStore, TriggerPayloadManager } from './triggers'
33
- export { ActionsExecutionContainerHookFactory } from './ActionsExecutionContainerHookFactory'
34
- export { ListenerStoreProvider } from './ListenerStoreProvider'
33
+ export {
34
+ TriggerHandler,
35
+ TriggerIndirectChangesFetcher,
36
+ TriggerListenersFactory,
37
+ TriggerListenersStore,
38
+ TriggerPayloadManager,
39
+ } from './triggers/index.js'
40
+ export { ActionsExecutionContainerHookFactory } from './ActionsExecutionContainerHookFactory.js'
41
+ export { ListenerStoreProvider } from './ListenerStoreProvider.js'
35
42
 
36
43
  export default class ActionsPlugin implements Plugin {
37
44
  name = 'contember/actions'
38
45
 
46
+ /**
47
+ * Metrics singleton, created in {@link getMasterContainerHook} (where the Prometheus registry is
48
+ * available) and read back here in {@link getExecutionContainerHook}, which runs in the per-request
49
+ * content container with no access to master-level services.
50
+ */
51
+ private actionsMetrics: ActionsMetrics | undefined
52
+
39
53
  getSystemMigrations(): MigrationGroup {
40
54
  return migrationsGroup
41
55
  }
42
56
 
43
57
  getExecutionContainerHook() {
44
- const hookFactory = new ActionsExecutionContainerHookFactory(new ListenerStoreProvider())
58
+ const hookFactory = new ActionsExecutionContainerHookFactory(new ListenerStoreProvider(), () => this.actionsMetrics)
45
59
  return hookFactory.create()
46
60
  }
47
61
 
48
62
  getMasterContainerHook() {
49
63
  const hook: MasterContainerHook = (builder: MasterContainerBuilder) => {
50
64
  return builder
51
- .addService('actions_variableManager', () => {
52
- return new VariablesManager()
65
+ .addService('actions_metrics', ({ promRegistry }) => {
66
+ const metrics = new ActionsMetrics(promRegistry)
67
+ // expose to getExecutionContainerHook (runs in a different container scope)
68
+ this.actionsMetrics = metrics
69
+ return metrics
70
+ })
71
+ .addService('actions_variableManager', ({ env }) => {
72
+ return new VariablesManager(env)
53
73
  })
54
74
  .addService('actions_eventRepository', () => {
55
75
  return new EventsRepository()
56
76
  })
57
- .addService('actions_eventDispatcher', ({ actions_eventRepository, actions_variableManager }) => {
58
- const webhookTargetHandler = new WebhookTargetHandler(new WebhookFetcherNative())
77
+ .addService('actions_eventDispatcher', ({ actions_eventRepository, actions_variableManager, tracer, serverConfig }) => {
78
+ const webhookTargetHandler = new WebhookTargetHandler(new WebhookFetcherNative(), tracer, {
79
+ propagateToWebhooks: serverConfig.telemetry?.traces?.propagateToWebhooks ?? true,
80
+ })
59
81
  const targetHandlerResolver = new TargetHandlerResolver(webhookTargetHandler)
60
- return new EventDispatcher(actions_eventRepository, actions_variableManager, targetHandlerResolver)
82
+ return new EventDispatcher(actions_eventRepository, actions_variableManager, targetHandlerResolver, tracer)
61
83
  })
62
- .addService('actions_dispatchWorkerSupervisorFactory', ({ actions_eventDispatcher }) => {
63
- const projectDispatcherFactory = new ProjectDispatcherFactory(actions_eventDispatcher)
84
+ .addService('actions_dispatchWorkerSupervisorFactory', ({ actions_eventDispatcher, actions_metrics }) => {
85
+ const projectDispatcherFactory = new ProjectDispatcherFactory(actions_eventDispatcher, actions_metrics)
64
86
  return new DispatchWorkerSupervisorFactory(projectDispatcherFactory)
65
87
  })
66
88
  .addService('actions_authorizator', () => {
@@ -78,6 +100,7 @@ export default class ActionsPlugin implements Plugin {
78
100
  actions_dispatchWorkerSupervisorFactory,
79
101
  actions_variableManager,
80
102
  actions_authorizator,
103
+ panelApiMount,
81
104
  },
82
105
  ) => {
83
106
  const handlerFactory = new ActionsGraphQLHandlerFactory()
@@ -102,11 +125,17 @@ export default class ActionsPlugin implements Plugin {
102
125
  )
103
126
  const actionsWebsocketMiddlewareFactory = new ActionsWebsocketControllerFactory(
104
127
  debugMode,
105
- actionsContextResolver,
106
128
  actions_dispatchWorkerSupervisorFactory,
107
129
  )
108
130
  it.addRoute('actions', '/actions/:projectSlug', actionsMiddlewareFactory.create())
109
131
  it.addWebsocketRoute('actions', '/actions/_worker', actionsWebsocketMiddlewareFactory.create())
132
+ // Does nothing unless the panel is served; when it is, the panel's access gate applies
133
+ // and the UI learns the actions module has an API to talk to.
134
+ panelApiMount.mount(it, {
135
+ name: 'actions',
136
+ path: 'actions/:projectSlug',
137
+ controller: actionsMiddlewareFactory.create(),
138
+ })
110
139
  },
111
140
  )
112
141
  .setupService(
@@ -1,7 +1,7 @@
1
- import snapshot from './snapshot'
1
+ import snapshot from './snapshot.js'
2
2
  import { MigrationGroup } from '@contember/database-migrations'
3
- import _20230310145000actionsvariables from './2023-03-10-145000-actions-variables'
4
- import _20250528160000actioneventuser from './2025-05-28-160000-action-event-user'
3
+ import _20230310145000actionsvariables from './2023-03-10-145000-actions-variables.js'
4
+ import _20250528160000actioneventuser from './2025-05-28-160000-action-event-user.js'
5
5
 
6
6
  export const migrationsGroup = new MigrationGroup(snapshot, {
7
7
  '2023-03-10-145000-actions-variables': _20230310145000actionsvariables,
@@ -1,5 +1,5 @@
1
1
  import { DatabaseQuery, DatabaseQueryable, SelectBuilder } from '@contember/database'
2
- import { EventRow } from './types'
2
+ import { EventRow } from './types.js'
3
3
 
4
4
  export class EventByIdQuery extends DatabaseQuery<EventRow | null> {
5
5
  constructor(
@@ -1,6 +1,6 @@
1
1
  import { DatabaseQuery, DatabaseQueryable, SelectBuilder } from '@contember/database'
2
- import { EventRow } from './types'
3
- import { EventArgs } from '../graphql/schema'
2
+ import { EventRow } from './types.js'
3
+ import { EventArgs } from '../graphql/schema/index.js'
4
4
 
5
5
  export class EventsInProcessingQuery extends DatabaseQuery<EventRow[]> {
6
6
  constructor(
@@ -1,7 +1,7 @@
1
1
  import { DatabaseQuery, DatabaseQueryable, SelectBuilder } from '@contember/database'
2
- import { EventRow } from './types'
3
- import { EventArgs } from '../graphql/schema'
4
- import { eventsToProcessSpecification } from './EventsToProcessSpecification'
2
+ import { EventRow } from './types.js'
3
+ import { EventArgs } from '../graphql/schema/index.js'
4
+ import { eventsToProcessSpecification } from './EventsToProcessSpecification.js'
5
5
 
6
6
  export class EventsToProcessQuery extends DatabaseQuery<EventRow[]> {
7
7
  constructor(
@@ -1,6 +1,6 @@
1
1
  import { DatabaseQuery, DatabaseQueryable, SelectBuilder } from '@contember/database'
2
- import { EventRow } from './types'
3
- import { EventArgs } from '../graphql/schema'
2
+ import { EventRow } from './types.js'
3
+ import { EventArgs } from '../graphql/schema/index.js'
4
4
 
5
5
  export class FailedEventsQuery extends DatabaseQuery<EventRow[]> {
6
6
  constructor(
@@ -1,19 +1,54 @@
1
1
  import { DatabaseContext } from '@contember/engine-system-api'
2
- import { VariablesQuery } from './VariablesQuery'
3
- import { SetVariablesArgs } from '../graphql/schema'
2
+ import { VariablesQuery } from './VariablesQuery.js'
3
+ import { SetVariablesArgs, Variable } from '../graphql/schema/index.js'
4
4
  import { DeleteBuilder } from '@contember/database'
5
- import { SetVariableCommand } from './SetVariableCommand'
5
+ import { SetVariableCommand } from './SetVariableCommand.js'
6
+ import { Env, projectNameToEnvName } from '@contember/engine-http'
7
+ import { UserInputError } from '@contember/graphql-utils'
6
8
 
7
9
  export type VariablesMap = Record<string, string>
8
10
 
11
+ /** Between the project (or DEFAULT) prefix and the variable name: `MY_PROJECT_ACTIONS_VARIABLE_API_KEY`. */
12
+ const ENV_NAME_INFIX = '_ACTIONS_VARIABLE_'
13
+
9
14
  export class VariablesManager {
10
- public async fetchVariables(db: DatabaseContext): Promise<VariablesMap> {
11
- return Object.fromEntries((await db.queryHandler.fetch(new VariablesQuery())).map(it => [it.name, it.value]))
15
+ /** The environment does not change while the process runs, so each project resolves its prefixes once. */
16
+ private readonly envVariablesCache = new Map<string, VariablesMap>()
17
+
18
+ constructor(
19
+ private readonly env: Env,
20
+ ) {
21
+ }
22
+
23
+ /** Values for dispatch. A variable supplied by the environment shadows a stored row of the same name. */
24
+ public async fetchVariables(db: DatabaseContext, projectSlug: string): Promise<VariablesMap> {
25
+ return { ...await this.fetchStoredVariables(db), ...this.fetchEnvVariables(projectSlug) }
26
+ }
27
+
28
+ /**
29
+ * The listing is an inventory, not a way to read secrets: an environment value stays in the operator's
30
+ * secret store and is reported as a name with no value.
31
+ */
32
+ public async listVariables(db: DatabaseContext, projectSlug: string): Promise<Variable[]> {
33
+ const envVariables = this.fetchEnvVariables(projectSlug)
34
+ const stored = await this.fetchStoredVariables(db)
35
+ return [
36
+ ...Object.entries(stored)
37
+ .filter(([name]) => !Object.hasOwn(envVariables, name))
38
+ .map(([name, value]): Variable => ({ name, value, source: 'DATABASE' })),
39
+ ...Object.keys(envVariables).map((name): Variable => ({ name, value: null, source: 'ENVIRONMENT' })),
40
+ ].sort((a, b) => a.name.localeCompare(b.name))
12
41
  }
13
42
 
14
- public async setVariables(db: DatabaseContext, args: SetVariablesArgs) {
43
+ public async setVariables(db: DatabaseContext, args: SetVariablesArgs, projectSlug: string) {
44
+ const envVariables = this.fetchEnvVariables(projectSlug)
45
+ const readOnly = args.variables.map(it => it.name).filter(it => Object.hasOwn(envVariables, it))
46
+ if (readOnly.length > 0) {
47
+ throw new UserInputError(`Variables supplied by the environment are read-only: ${readOnly.join(', ')}`)
48
+ }
49
+
15
50
  return await db.transaction(async db => {
16
- const current = await this.fetchVariables(db)
51
+ const current = await this.fetchStoredVariables(db)
17
52
  const mode = args.mode ?? 'MERGE'
18
53
  const inputVariables = Object.fromEntries(args.variables.map(it => [it.name, it.value]))
19
54
 
@@ -30,7 +65,7 @@ export class VariablesManager {
30
65
  break
31
66
  }
32
67
 
33
- const toDelete = Object.keys(current).filter(it => !(it in newVariables))
68
+ const toDelete = Object.keys(current).filter(it => !Object.hasOwn(newVariables, it))
34
69
  if (toDelete.length > 0) {
35
70
  await DeleteBuilder.create()
36
71
  .from('actions_variable')
@@ -46,4 +81,29 @@ export class VariablesManager {
46
81
  }
47
82
  })
48
83
  }
84
+
85
+ private async fetchStoredVariables(db: DatabaseContext): Promise<VariablesMap> {
86
+ return Object.fromEntries((await db.queryHandler.fetch(new VariablesQuery())).map(it => [it.name, it.value]))
87
+ }
88
+
89
+ private fetchEnvVariables(projectSlug: string): VariablesMap {
90
+ const cached = this.envVariablesCache.get(projectSlug)
91
+ if (cached !== undefined) {
92
+ return cached
93
+ }
94
+ // the project prefix is read last, so it overrides the shared DEFAULT_ one
95
+ const prefixes = [`DEFAULT${ENV_NAME_INFIX}`, projectNameToEnvName(projectSlug) + ENV_NAME_INFIX]
96
+ const result: VariablesMap = {}
97
+ for (const prefix of prefixes) {
98
+ for (const [name, value] of Object.entries(this.env)) {
99
+ // an empty value counts as unset, the same as the `||` fallback of the config parameter resolver
100
+ if (!name.startsWith(prefix) || name.length === prefix.length || value === '') {
101
+ continue
102
+ }
103
+ result[name.slice(prefix.length)] = value
104
+ }
105
+ }
106
+ this.envVariablesCache.set(projectSlug, result)
107
+ return result
108
+ }
49
109
  }
@@ -7,9 +7,9 @@ import {
7
7
  EventManager,
8
8
  } from '@contember/engine-content-api'
9
9
  import { Input } from '@contember/schema'
10
- import { IndirectListener, JunctionListener, TriggerListenersStore } from './TriggerListenersStore'
11
- import { TriggerPayloadManager } from './TriggerPayloadManager'
12
- import { TriggerIndirectChangesFetcher } from './TriggerIndirectChangesFetcher'
10
+ import { IndirectListener, JunctionListener, TriggerListenersStore } from './TriggerListenersStore.js'
11
+ import { TriggerPayloadManager } from './TriggerPayloadManager.js'
12
+ import { TriggerIndirectChangesFetcher } from './TriggerIndirectChangesFetcher.js'
13
13
 
14
14
  export type EventCause =
15
15
  | BeforeUpdateEvent
@@ -1,5 +1,5 @@
1
1
  import { Mapper, PathFactory, WhereBuilder } from '@contember/engine-content-api'
2
- import { IndirectListener, JunctionListener } from './TriggerListenersStore'
2
+ import { IndirectListener, JunctionListener } from './TriggerListenersStore.js'
3
3
  import { SelectBuilder } from '@contember/database'
4
4
  import { ActionsPayload, Input, Model, Schema } from '@contember/schema'
5
5
  import { JoinBuilder } from '@contember/engine-content-api'
@@ -1,4 +1,4 @@
1
- import { CreateListener, DeleteListener, IndirectListener, JunctionListener, UpdateListener } from './TriggerListenersStore'
1
+ import { CreateListener, DeleteListener, IndirectListener, JunctionListener, UpdateListener } from './TriggerListenersStore.js'
2
2
 
3
3
  export interface TriggerListeners {
4
4
  readonly deleteListeners: Map<string, DeleteListener[]>
@@ -1,9 +1,9 @@
1
1
  import { Actions, Model } from '@contember/schema'
2
- import { TriggerListeners } from './TriggerListeners'
3
- import { JunctionListener, TriggerListenersStore } from './TriggerListenersStore'
2
+ import { TriggerListeners } from './TriggerListeners.js'
3
+ import { JunctionListener, TriggerListenersStore } from './TriggerListenersStore.js'
4
4
  import { acceptFieldVisitor, getEntity } from '@contember/schema-utils'
5
- import { mapGetOrPut } from '../utils/map'
6
- import { ImplementationException } from '../ImplementationException'
5
+ import { mapGetOrPut } from '../utils/map.js'
6
+ import { ImplementationException } from '../ImplementationException.js'
7
7
 
8
8
  export class TriggerListenerBuilder {
9
9
  private readonly data: TriggerListeners = {
@@ -1,5 +1,5 @@
1
- import { TriggerListenersStore } from './TriggerListenersStore'
2
- import { TriggerListenerBuilder } from './TriggerListenersBuilder'
1
+ import { TriggerListenersStore } from './TriggerListenersStore.js'
2
+ import { TriggerListenerBuilder } from './TriggerListenersBuilder.js'
3
3
  import { Schema } from '@contember/schema'
4
4
 
5
5
  export class TriggerListenersFactory {