@versori/run 0.5.0 → 0.5.1

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 (217) hide show
  1. package/esm/mod.d.ts +1 -1
  2. package/esm/mod.d.ts.map +1 -1
  3. package/esm/mod.js +1 -1
  4. package/esm/src/connection/VanillaConnectionFactory.d.ts +16 -0
  5. package/esm/src/connection/VanillaConnectionFactory.d.ts.map +1 -0
  6. package/esm/src/connection/VanillaConnectionFactory.js +35 -0
  7. package/esm/src/context/ActivationImpl.d.ts +2 -1
  8. package/esm/src/context/ActivationImpl.d.ts.map +1 -1
  9. package/esm/src/context/Context.d.ts +2 -1
  10. package/esm/src/context/Context.d.ts.map +1 -1
  11. package/esm/src/context/ContextProvider.d.ts +8 -8
  12. package/esm/src/context/ContextProvider.d.ts.map +1 -1
  13. package/esm/src/context/ContextProvider.js +1 -1
  14. package/esm/src/context/VanillaContext.d.ts +63 -0
  15. package/esm/src/context/VanillaContext.d.ts.map +1 -0
  16. package/esm/src/context/VanillaContext.js +313 -0
  17. package/esm/src/context/WorkflowClient.d.ts +2 -2
  18. package/esm/src/context/WorkflowClient.d.ts.map +1 -1
  19. package/esm/src/dsl/http/mod.d.ts +1 -1
  20. package/esm/src/dsl/http/mod.d.ts.map +1 -1
  21. package/esm/src/dsl/http/types.d.ts +20 -134
  22. package/esm/src/dsl/http/types.d.ts.map +1 -1
  23. package/esm/src/dsl/http/versori/configloader.d.ts.map +1 -1
  24. package/esm/src/dsl/http/versori/configloader.js +3 -0
  25. package/esm/src/dsl/http/versori/webhookmiddleware.d.ts +1 -1
  26. package/esm/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
  27. package/esm/src/dsl/tasks/HttpTask.d.ts +4 -4
  28. package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
  29. package/esm/src/dsl/triggers/ScheduleTrigger.d.ts +2 -2
  30. package/esm/src/dsl/triggers/ScheduleTrigger.d.ts.map +1 -1
  31. package/esm/src/interpreter/durable/DurableInterpreter.d.ts +1 -0
  32. package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
  33. package/esm/src/interpreter/durable/DurableInterpreter.js +24 -7
  34. package/esm/src/interpreter/durable/Queue.d.ts +1 -1
  35. package/esm/src/interpreter/durable/Queue.js +1 -1
  36. package/esm/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
  37. package/esm/src/interpreter/durable/compilers/durableworkflow.js +2 -1
  38. package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
  39. package/esm/src/interpreter/durable/compilers/fn.js +7 -4
  40. package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
  41. package/esm/src/interpreter/durable/compilers/webhook.js +7 -6
  42. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +3 -2
  43. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  44. package/esm/src/interpreter/memory/MemoryInterpreter.js +24 -7
  45. package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
  46. package/esm/src/interpreter/memory/compilers/fn.js +7 -4
  47. package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  48. package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  49. package/esm/src/interpreter/memory/compilers/webhook.js +7 -6
  50. package/esm/src/interpreter/mod.d.ts +1 -0
  51. package/esm/src/interpreter/mod.d.ts.map +1 -1
  52. package/esm/src/interpreter/mod.js +1 -0
  53. package/esm/src/interpreter/vanilla/ExecutionError.d.ts +25 -0
  54. package/esm/src/interpreter/vanilla/ExecutionError.d.ts.map +1 -0
  55. package/esm/src/interpreter/vanilla/ExecutionError.js +46 -0
  56. package/esm/src/interpreter/vanilla/ObservableCompiler.d.ts +38 -0
  57. package/esm/src/interpreter/vanilla/ObservableCompiler.d.ts.map +1 -0
  58. package/esm/src/interpreter/vanilla/ObservableCompiler.js +95 -0
  59. package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts +96 -0
  60. package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -0
  61. package/esm/src/interpreter/vanilla/VanillaInterpreter.js +435 -0
  62. package/esm/src/interpreter/vanilla/compilers/background.d.ts +4 -0
  63. package/esm/src/interpreter/vanilla/compilers/background.d.ts.map +1 -0
  64. package/esm/src/interpreter/vanilla/compilers/background.js +34 -0
  65. package/esm/src/interpreter/vanilla/compilers/catch.d.ts +4 -0
  66. package/esm/src/interpreter/vanilla/compilers/catch.d.ts.map +1 -0
  67. package/esm/src/interpreter/vanilla/compilers/catch.js +75 -0
  68. package/esm/src/interpreter/vanilla/compilers/chain.d.ts +3 -0
  69. package/esm/src/interpreter/vanilla/compilers/chain.d.ts.map +1 -0
  70. package/esm/src/interpreter/vanilla/compilers/chain.js +21 -0
  71. package/esm/src/interpreter/vanilla/compilers/durableworkflow.d.ts +8 -0
  72. package/esm/src/interpreter/vanilla/compilers/durableworkflow.d.ts.map +1 -0
  73. package/esm/src/interpreter/vanilla/compilers/durableworkflow.js +91 -0
  74. package/esm/src/interpreter/vanilla/compilers/fn.d.ts +4 -0
  75. package/esm/src/interpreter/vanilla/compilers/fn.d.ts.map +1 -0
  76. package/esm/src/interpreter/vanilla/compilers/fn.js +37 -0
  77. package/esm/src/interpreter/vanilla/compilers/http.d.ts +4 -0
  78. package/esm/src/interpreter/vanilla/compilers/http.d.ts.map +1 -0
  79. package/esm/src/interpreter/vanilla/compilers/http.js +54 -0
  80. package/esm/src/interpreter/vanilla/compilers/mod.d.ts +2 -0
  81. package/esm/src/interpreter/vanilla/compilers/mod.d.ts.map +1 -0
  82. package/esm/src/interpreter/vanilla/compilers/mod.js +13 -0
  83. package/esm/src/interpreter/vanilla/compilers/parallel.d.ts +4 -0
  84. package/esm/src/interpreter/vanilla/compilers/parallel.d.ts.map +1 -0
  85. package/esm/src/interpreter/vanilla/compilers/parallel.js +31 -0
  86. package/esm/src/interpreter/vanilla/compilers/schedule.d.ts +4 -0
  87. package/esm/src/interpreter/vanilla/compilers/schedule.d.ts.map +1 -0
  88. package/esm/src/interpreter/vanilla/compilers/schedule.js +76 -0
  89. package/esm/src/interpreter/vanilla/compilers/serial.d.ts +4 -0
  90. package/esm/src/interpreter/vanilla/compilers/serial.d.ts.map +1 -0
  91. package/esm/src/interpreter/vanilla/compilers/serial.js +28 -0
  92. package/esm/src/interpreter/vanilla/compilers/types.d.ts +15 -0
  93. package/esm/src/interpreter/vanilla/compilers/types.d.ts.map +1 -0
  94. package/esm/src/interpreter/vanilla/compilers/types.js +13 -0
  95. package/esm/src/interpreter/vanilla/compilers/unpack.d.ts +4 -0
  96. package/esm/src/interpreter/vanilla/compilers/unpack.d.ts.map +1 -0
  97. package/esm/src/interpreter/vanilla/compilers/unpack.js +34 -0
  98. package/esm/src/interpreter/vanilla/compilers/webhook.d.ts +4 -0
  99. package/esm/src/interpreter/vanilla/compilers/webhook.d.ts.map +1 -0
  100. package/esm/src/interpreter/vanilla/compilers/webhook.js +261 -0
  101. package/esm/src/interpreter/vanilla/mod.d.ts +3 -0
  102. package/esm/src/interpreter/vanilla/mod.d.ts.map +1 -0
  103. package/esm/src/interpreter/vanilla/mod.js +14 -0
  104. package/esm/src/issues/Issues.d.ts.map +1 -1
  105. package/esm/src/observability/logging/ConsoleLogger.d.ts +1 -1
  106. package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
  107. package/esm/src/observability/logging/ConsoleLogger.js +11 -1
  108. package/esm/src/services/platform/generated/core/pathSerializer.gen.d.ts +2 -2
  109. package/package.json +1 -1
  110. package/script/mod.d.ts +1 -1
  111. package/script/mod.d.ts.map +1 -1
  112. package/script/mod.js +2 -1
  113. package/script/src/connection/VanillaConnectionFactory.d.ts +16 -0
  114. package/script/src/connection/VanillaConnectionFactory.d.ts.map +1 -0
  115. package/script/src/connection/VanillaConnectionFactory.js +40 -0
  116. package/script/src/context/ActivationImpl.d.ts +2 -1
  117. package/script/src/context/ActivationImpl.d.ts.map +1 -1
  118. package/script/src/context/Context.d.ts +2 -1
  119. package/script/src/context/Context.d.ts.map +1 -1
  120. package/script/src/context/ContextProvider.d.ts +8 -8
  121. package/script/src/context/ContextProvider.d.ts.map +1 -1
  122. package/script/src/context/ContextProvider.js +1 -1
  123. package/script/src/context/VanillaContext.d.ts +63 -0
  124. package/script/src/context/VanillaContext.d.ts.map +1 -0
  125. package/script/src/context/VanillaContext.js +319 -0
  126. package/script/src/context/WorkflowClient.d.ts +2 -2
  127. package/script/src/context/WorkflowClient.d.ts.map +1 -1
  128. package/script/src/dsl/http/mod.d.ts +1 -1
  129. package/script/src/dsl/http/mod.d.ts.map +1 -1
  130. package/script/src/dsl/http/types.d.ts +20 -134
  131. package/script/src/dsl/http/types.d.ts.map +1 -1
  132. package/script/src/dsl/http/versori/configloader.d.ts.map +1 -1
  133. package/script/src/dsl/http/versori/configloader.js +3 -0
  134. package/script/src/dsl/http/versori/webhookmiddleware.d.ts +1 -1
  135. package/script/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
  136. package/script/src/dsl/tasks/HttpTask.d.ts +4 -4
  137. package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
  138. package/script/src/dsl/triggers/ScheduleTrigger.d.ts +2 -2
  139. package/script/src/dsl/triggers/ScheduleTrigger.d.ts.map +1 -1
  140. package/script/src/interpreter/durable/DurableInterpreter.d.ts +1 -0
  141. package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
  142. package/script/src/interpreter/durable/DurableInterpreter.js +24 -7
  143. package/script/src/interpreter/durable/Queue.d.ts +1 -1
  144. package/script/src/interpreter/durable/Queue.js +1 -1
  145. package/script/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
  146. package/script/src/interpreter/durable/compilers/durableworkflow.js +2 -1
  147. package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
  148. package/script/src/interpreter/durable/compilers/fn.js +7 -4
  149. package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
  150. package/script/src/interpreter/durable/compilers/webhook.js +7 -6
  151. package/script/src/interpreter/memory/MemoryInterpreter.d.ts +3 -2
  152. package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  153. package/script/src/interpreter/memory/MemoryInterpreter.js +24 -7
  154. package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
  155. package/script/src/interpreter/memory/compilers/fn.js +7 -4
  156. package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  157. package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  158. package/script/src/interpreter/memory/compilers/webhook.js +7 -6
  159. package/script/src/interpreter/mod.d.ts +1 -0
  160. package/script/src/interpreter/mod.d.ts.map +1 -1
  161. package/script/src/interpreter/mod.js +2 -1
  162. package/script/src/interpreter/vanilla/ExecutionError.d.ts +25 -0
  163. package/script/src/interpreter/vanilla/ExecutionError.d.ts.map +1 -0
  164. package/script/src/interpreter/vanilla/ExecutionError.js +50 -0
  165. package/script/src/interpreter/vanilla/ObservableCompiler.d.ts +38 -0
  166. package/script/src/interpreter/vanilla/ObservableCompiler.d.ts.map +1 -0
  167. package/script/src/interpreter/vanilla/ObservableCompiler.js +99 -0
  168. package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts +96 -0
  169. package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -0
  170. package/script/src/interpreter/vanilla/VanillaInterpreter.js +442 -0
  171. package/script/src/interpreter/vanilla/compilers/background.d.ts +4 -0
  172. package/script/src/interpreter/vanilla/compilers/background.d.ts.map +1 -0
  173. package/script/src/interpreter/vanilla/compilers/background.js +37 -0
  174. package/script/src/interpreter/vanilla/compilers/catch.d.ts +4 -0
  175. package/script/src/interpreter/vanilla/compilers/catch.d.ts.map +1 -0
  176. package/script/src/interpreter/vanilla/compilers/catch.js +78 -0
  177. package/script/src/interpreter/vanilla/compilers/chain.d.ts +3 -0
  178. package/script/src/interpreter/vanilla/compilers/chain.d.ts.map +1 -0
  179. package/script/src/interpreter/vanilla/compilers/chain.js +24 -0
  180. package/script/src/interpreter/vanilla/compilers/durableworkflow.d.ts +8 -0
  181. package/script/src/interpreter/vanilla/compilers/durableworkflow.d.ts.map +1 -0
  182. package/script/src/interpreter/vanilla/compilers/durableworkflow.js +95 -0
  183. package/script/src/interpreter/vanilla/compilers/fn.d.ts +4 -0
  184. package/script/src/interpreter/vanilla/compilers/fn.d.ts.map +1 -0
  185. package/script/src/interpreter/vanilla/compilers/fn.js +40 -0
  186. package/script/src/interpreter/vanilla/compilers/http.d.ts +4 -0
  187. package/script/src/interpreter/vanilla/compilers/http.d.ts.map +1 -0
  188. package/script/src/interpreter/vanilla/compilers/http.js +57 -0
  189. package/script/src/interpreter/vanilla/compilers/mod.d.ts +2 -0
  190. package/script/src/interpreter/vanilla/compilers/mod.d.ts.map +1 -0
  191. package/script/src/interpreter/vanilla/compilers/mod.js +14 -0
  192. package/script/src/interpreter/vanilla/compilers/parallel.d.ts +4 -0
  193. package/script/src/interpreter/vanilla/compilers/parallel.d.ts.map +1 -0
  194. package/script/src/interpreter/vanilla/compilers/parallel.js +34 -0
  195. package/script/src/interpreter/vanilla/compilers/schedule.d.ts +4 -0
  196. package/script/src/interpreter/vanilla/compilers/schedule.d.ts.map +1 -0
  197. package/script/src/interpreter/vanilla/compilers/schedule.js +79 -0
  198. package/script/src/interpreter/vanilla/compilers/serial.d.ts +4 -0
  199. package/script/src/interpreter/vanilla/compilers/serial.d.ts.map +1 -0
  200. package/script/src/interpreter/vanilla/compilers/serial.js +31 -0
  201. package/script/src/interpreter/vanilla/compilers/types.d.ts +15 -0
  202. package/script/src/interpreter/vanilla/compilers/types.d.ts.map +1 -0
  203. package/script/src/interpreter/vanilla/compilers/types.js +14 -0
  204. package/script/src/interpreter/vanilla/compilers/unpack.d.ts +4 -0
  205. package/script/src/interpreter/vanilla/compilers/unpack.d.ts.map +1 -0
  206. package/script/src/interpreter/vanilla/compilers/unpack.js +37 -0
  207. package/script/src/interpreter/vanilla/compilers/webhook.d.ts +4 -0
  208. package/script/src/interpreter/vanilla/compilers/webhook.d.ts.map +1 -0
  209. package/script/src/interpreter/vanilla/compilers/webhook.js +267 -0
  210. package/script/src/interpreter/vanilla/mod.d.ts +3 -0
  211. package/script/src/interpreter/vanilla/mod.d.ts.map +1 -0
  212. package/script/src/interpreter/vanilla/mod.js +30 -0
  213. package/script/src/issues/Issues.d.ts.map +1 -1
  214. package/script/src/observability/logging/ConsoleLogger.d.ts +1 -1
  215. package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
  216. package/script/src/observability/logging/ConsoleLogger.js +11 -1
  217. package/script/src/services/platform/generated/core/pathSerializer.gen.d.ts +2 -2
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Versori Group Inc
4
+ *
5
+ * Use of this software is governed by the Business Source License 1.1
6
+ * included in the LICENSE file at the root of this repository.
7
+ *
8
+ * Change Date: 2029-01-01
9
+ * Change License: Apache License, Version 2.0
10
+ *
11
+ * As of the Change Date, in accordance with the Business Source License,
12
+ * use of this software will be governed by the Apache License, Version 2.0.
13
+ */
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.webhookCompiler = void 0;
19
+ const cors_1 = __importDefault(require("cors"));
20
+ const express_1 = __importDefault(require("express"));
21
+ const express_xml_bodyparser_1 = __importDefault(require("express-xml-bodyparser"));
22
+ const promises_1 = require("node:stream/promises");
23
+ const rxjs_1 = require("rxjs");
24
+ const WebhookTrigger_js_1 = require("../../../dsl/triggers/WebhookTrigger.js");
25
+ const ObservableCompiler_js_1 = require("../ObservableCompiler.js");
26
+ const xml2jsDefaults = {
27
+ explicitArray: false,
28
+ normalize: false,
29
+ normalizeTags: false,
30
+ trim: true,
31
+ };
32
+ const vanillaWebhookMiddleware = () => {
33
+ return (_, res, next) => {
34
+ res.locals.activation = ObservableCompiler_js_1.VanillaActivation;
35
+ next();
36
+ };
37
+ };
38
+ const DEFAULT_SYNC_ON_SUCCESS = (ctx) => new Response(JSON.stringify(ctx.data), {
39
+ status: 200,
40
+ headers: {
41
+ 'Content-Type': 'application/json',
42
+ 'X-Execution-Id': ctx.executionId,
43
+ },
44
+ });
45
+ const DEFAULT_SYNC_ON_ERROR = (ctx) => new Response(JSON.stringify({ message: 'Internal server error', error: ctx.data }), {
46
+ status: 500,
47
+ headers: {
48
+ 'Content-Type': 'application/json',
49
+ 'X-Execution-Id': ctx.executionId,
50
+ },
51
+ });
52
+ const DEFAULT_ASYNC_ON_SUCCESS = (ctx) => new Response(JSON.stringify({
53
+ status: 'accepted',
54
+ executionId: ctx.executionId,
55
+ }), {
56
+ status: 202,
57
+ headers: {
58
+ 'Content-Type': 'application/json',
59
+ 'X-Execution-Id': ctx.executionId,
60
+ },
61
+ });
62
+ const DEFAULT_ASYNC_ON_ERROR = (ctx) => new Response(JSON.stringify({
63
+ message: 'Internal server error',
64
+ executionId: ctx.executionId,
65
+ }), {
66
+ status: 500,
67
+ headers: {
68
+ 'Content-Type': 'application/json',
69
+ 'X-Execution-Id': ctx.executionId,
70
+ },
71
+ });
72
+ exports.webhookCompiler = {
73
+ ctor: WebhookTrigger_js_1.WebhookTrigger,
74
+ compile: (ctx, trigger, signal) => {
75
+ const { response: { mode = 'async' } = {}, cors: corsOptions } = trigger.options;
76
+ const isSync = mode === 'sync';
77
+ const isAsync = mode === 'async';
78
+ if (!isSync && !isAsync) {
79
+ throw new Error('Invalid response mode, must be either "sync" or "async"');
80
+ }
81
+ const method = trigger.options.method || 'post';
82
+ const validMethods = ['get', 'post', 'put', 'delete', 'patch', 'options', 'head', 'all'];
83
+ if (method !== method.toLowerCase()) {
84
+ throw new Error(`HTTP method must be in lowercase: ${method} on webhook ${trigger.id}`);
85
+ }
86
+ if (!validMethods.includes(method)) {
87
+ throw new Error(`Unsupported HTTP method: ${method} on webhook ${trigger.id}. Must be one of: ${validMethods.join(', ')}`);
88
+ }
89
+ let onSuccess = isSync ? DEFAULT_SYNC_ON_SUCCESS : DEFAULT_ASYNC_ON_SUCCESS;
90
+ let onError = isSync ? DEFAULT_SYNC_ON_ERROR : DEFAULT_ASYNC_ON_ERROR;
91
+ if (trigger.options.response?.onSuccess) {
92
+ onSuccess = trigger.options.response.onSuccess;
93
+ }
94
+ if (trigger.options.response?.onError) {
95
+ onError = trigger.options.response.onError;
96
+ }
97
+ const ctxOptionsFn = (req, res) => ({
98
+ onSuccess: (ctx) => {
99
+ if (isSync) {
100
+ sendResponse(res, onSuccess(ctx));
101
+ }
102
+ },
103
+ onError: (ctx) => {
104
+ if (isSync) {
105
+ sendResponse(res, onError(ctx));
106
+ }
107
+ },
108
+ request: req,
109
+ });
110
+ const routeMiddleware = [];
111
+ if (!trigger.options.request?.rawBody) {
112
+ routeMiddleware.push(express_1.default.json({ limit: '50mb', type: ['application/json', '*/*+json'] }));
113
+ routeMiddleware.push((0, express_xml_bodyparser_1.default)(xml2jsDefaults));
114
+ }
115
+ else {
116
+ routeMiddleware.push(express_1.default.raw({ type: '*/*', limit: '50mb' }));
117
+ }
118
+ routeMiddleware.push(vanillaWebhookMiddleware());
119
+ return new rxjs_1.Observable((subscriber) => {
120
+ if (!ctx.webhookRouter) {
121
+ throw new Error('Router not available in compiler context');
122
+ }
123
+ // add the webhook endpoint to the router
124
+ ctx.log.info('webhook endpoint added:', { trigger });
125
+ if (corsOptions) {
126
+ if (typeof corsOptions === 'boolean') {
127
+ ctx.webhookRouter.use((0, cors_1.default)());
128
+ }
129
+ else {
130
+ ctx.webhookRouter.use((0, cors_1.default)(corsOptions));
131
+ }
132
+ }
133
+ // endpoint for sans user because I'm not quite sure how the dynamic routing works
134
+ ctx.webhookRouter[method](`/${trigger.id}`, ...routeMiddleware, async (req, res) => {
135
+ await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
136
+ span.setAttribute('task.id', trigger.id);
137
+ span.setAttribute('task.type', 'webhook');
138
+ const staticActivation = res.locals.activation;
139
+ const executionCtx = ctx.contextProvider.create(staticActivation, req.body, ctxOptionsFn(req, res));
140
+ span.setAttribute('execution.id', executionCtx.executionId);
141
+ try {
142
+ subscriber.next(executionCtx);
143
+ if (isAsync) {
144
+ sendResponse(res, onSuccess(executionCtx));
145
+ }
146
+ }
147
+ catch (error) {
148
+ executionCtx.log.error('webhook execution error', {
149
+ error: JSON.stringify(error),
150
+ });
151
+ if (isAsync) {
152
+ sendResponse(res, onError(executionCtx.withData(error)));
153
+ }
154
+ }
155
+ finally {
156
+ span.end();
157
+ }
158
+ });
159
+ });
160
+ // this endpoint will trigger the workflow for each activation given by the external user ID
161
+ ctx.webhookRouter[method](`/${trigger.id}/users/:userId`, ...routeMiddleware, async (req, res) => {
162
+ await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
163
+ span.setAttribute('task.id', trigger.id);
164
+ span.setAttribute('task.type', 'webhook');
165
+ span.setAttribute('user.id', req.params.userId);
166
+ const userId = req.params.userId;
167
+ const activation = res.locals.activation;
168
+ // Right now we only support a user having one activation
169
+ // so this will need changing when we support multiple activations per user
170
+ // as will the middleware
171
+ if (!activation) {
172
+ res.status(404).json({
173
+ status: 'error',
174
+ message: `No activations found for user: ${userId}`,
175
+ });
176
+ span.setAttribute('error.message', `No activations found for user: ${userId}`);
177
+ span.setAttribute('http.status_code', '404');
178
+ span.end();
179
+ return;
180
+ }
181
+ const executionCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
182
+ span.setAttribute('execution.id', executionCtx.executionId);
183
+ const errors = [];
184
+ try {
185
+ subscriber.next(executionCtx);
186
+ }
187
+ catch (error) {
188
+ executionCtx.log.error('webhook execution error', {
189
+ error: JSON.stringify(error),
190
+ });
191
+ errors.push({
192
+ activationId: activation.id,
193
+ error,
194
+ });
195
+ }
196
+ if (isAsync) {
197
+ if (errors.length === 0) {
198
+ sendResponse(res, onSuccess(executionCtx));
199
+ }
200
+ else {
201
+ sendResponse(res, onError(executionCtx.withData(errors)));
202
+ }
203
+ }
204
+ span.end();
205
+ });
206
+ });
207
+ // this endpoint will trigger the workflow only for the activation given by its ID
208
+ ctx.webhookRouter[method](`/${trigger.id}/activations/:activationId`, ...routeMiddleware, async (req, res) => {
209
+ await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
210
+ span.setAttribute('task.id', trigger.id);
211
+ span.setAttribute('task.type', 'webhook');
212
+ span.setAttribute('activation.id', req.params.activationId);
213
+ const activation = res.locals.activation;
214
+ const activationId = activation?.id ?? req.params.activationId;
215
+ if (!activation) {
216
+ // TODO report back actual errors
217
+ res.status(404).json({
218
+ status: 'error',
219
+ message: `No activation found for ID: ${activationId}`,
220
+ });
221
+ span.setAttribute('error.message', `No activation found for ID: ${activationId}`);
222
+ span.setAttribute('http.status_code', '404');
223
+ span.end();
224
+ return;
225
+ }
226
+ const activationCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
227
+ span.setAttribute('execution.id', activationCtx.executionId);
228
+ try {
229
+ subscriber.next(activationCtx);
230
+ if (isAsync) {
231
+ sendResponse(res, onSuccess(activationCtx));
232
+ }
233
+ }
234
+ catch (error) {
235
+ activationCtx.log.error('webhook execution error', {
236
+ error: JSON.stringify(error),
237
+ });
238
+ if (isAsync) {
239
+ sendResponse(res, onError(activationCtx.withData(error)));
240
+ }
241
+ }
242
+ finally {
243
+ span.end();
244
+ }
245
+ });
246
+ });
247
+ function cleanup() {
248
+ ctx.log.debug('webhook trigger stopped');
249
+ subscriber.complete();
250
+ }
251
+ signal.addEventListener('abort', cleanup, { once: true });
252
+ return () => {
253
+ signal.removeEventListener('abort', cleanup);
254
+ ctx.log.debug('webhook execution unsubscribed');
255
+ };
256
+ });
257
+ },
258
+ };
259
+ function sendResponse(res, response) {
260
+ res.status(response.status);
261
+ response.headers.forEach((value, key) => {
262
+ res.setHeader(key, value);
263
+ });
264
+ if (response.body) {
265
+ (0, promises_1.pipeline)(response.body, res);
266
+ }
267
+ }
@@ -0,0 +1,3 @@
1
+ export * from './VanillaInterpreter.js';
2
+ export * from './ExecutionError.js';
3
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/vanilla/mod.ts"],"names":[],"mappings":"AAaA,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Versori Group Inc
4
+ *
5
+ * Use of this software is governed by the Business Source License 1.1
6
+ * included in the LICENSE file at the root of this repository.
7
+ *
8
+ * Change Date: 2029-01-01
9
+ * Change License: Apache License, Version 2.0
10
+ *
11
+ * As of the Change Date, in accordance with the Business Source License,
12
+ * use of this software will be governed by the Apache License, Version 2.0.
13
+ */
14
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
+ desc = { enumerable: true, get: function() { return m[k]; } };
19
+ }
20
+ Object.defineProperty(o, k2, desc);
21
+ }) : (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ }));
25
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ __exportStar(require("./VanillaInterpreter.js"), exports);
30
+ __exportStar(require("./ExecutionError.js"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"Issues.d.ts","sourceRoot":"","sources":["../../../src/src/issues/Issues.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,MAAM,WAAW,GAAG;IACtB,MAAM,EAAE,Q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,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IAExC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAS;IAClC,OAAO,CAAC,GAAG,CAAS;gBAER,GAAG,EAAE,MAAM;IA2BjB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpD,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;QACtC,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;KAC3B,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;YAWX,MAAM;CA2DvB;AAED,qBAAa,UAAW,YAAW,QAAQ;IACvC,WAAW,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1C,WAAW,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE;QACnC,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;KAC3B,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CAG5B"}
@@ -10,7 +10,7 @@ export declare class ConsoleLogger implements Logger {
10
10
  log: log.Logger;
11
11
  level: LogLevel;
12
12
  fields: Record<string, unknown>;
13
- constructor(level: LogLevel, fields?: Record<string, unknown>);
13
+ constructor(level?: LogLevel, fields?: Record<string, unknown>);
14
14
  debug(message: string, fields?: Record<string, unknown>): void;
15
15
  warn(message: string, fields?: Record<string, unknown>): void;
16
16
  info(message: string, fields?: Record<string, unknown>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"ConsoleLogger.d.ts","sourceRoot":"","sources":["../../../../src/src/observability/logging/ConsoleLogger.ts"],"names":[],"mappings":"AAaA,OAAO,KAA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C;AACrE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAmN/C;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,MAAM;IACxC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC;IAEhB,KAAK,EAAE,QAAQ,CAAC;IAEhB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAEpB,KAAK,GAAE,QAAqD,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAO9G,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO9D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO7D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO7D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAC3E,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAsB9D,KAAK,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,aAAa;IAOvD,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;CAIlC"}
@@ -37,9 +37,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.ConsoleLogger = void 0;
39
39
  const log = __importStar(require("../../../deps/jsr.io/@std/log/0.224.14/mod.js"));
40
+ const defaultLogLevel = 'info';
41
+ const validLogLevels = ['debug', 'warn', 'info', 'error'];
40
42
  function isObjectLiteral(obj) {
41
43
  return Object.getPrototypeOf(obj) === Object.prototype;
42
44
  }
45
+ function resolveLogLevel(level) {
46
+ const normalized = level?.toLowerCase();
47
+ if (normalized && validLogLevels.includes(normalized)) {
48
+ return normalized;
49
+ }
50
+ return defaultLogLevel;
51
+ }
43
52
  function formatError(err) {
44
53
  if (Symbol.toPrimitive in err) {
45
54
  const toPrimitive = err[Symbol.toPrimitive];
@@ -204,7 +213,7 @@ const levelMap = {
204
213
  * and proper error serialization.
205
214
  */
206
215
  class ConsoleLogger {
207
- constructor(level, fields = {}) {
216
+ constructor(level = resolveLogLevel(Deno.env.get('LOG_LEVEL')), fields = {}) {
208
217
  Object.defineProperty(this, "log", {
209
218
  enumerable: true,
210
219
  configurable: true,
@@ -267,6 +276,7 @@ class ConsoleLogger {
267
276
  });
268
277
  }
269
278
  setLevel(level) {
279
+ this.level = level;
270
280
  this.log.level = levelMap[level] ?? log.getLevelByName('INFO');
271
281
  }
272
282
  }
@@ -19,9 +19,9 @@ type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
19
19
  interface SerializePrimitiveParam extends SerializePrimitiveOptions {
20
20
  value: string;
21
21
  }
22
- export declare const separatorArrayExplode: (style: ArraySeparatorStyle) => "," | ";" | "." | "&";
22
+ export declare const separatorArrayExplode: (style: ArraySeparatorStyle) => "." | ";" | "," | "&";
23
23
  export declare const separatorArrayNoExplode: (style: ArraySeparatorStyle) => "," | "|" | "%20";
24
- export declare const separatorObjectExplode: (style: ObjectSeparatorStyle) => "," | ";" | "." | "&";
24
+ export declare const separatorObjectExplode: (style: ObjectSeparatorStyle) => "." | ";" | "," | "&";
25
25
  export declare const serializeArrayParam: ({ allowReserved, explode, name, style, value, }: SerializeOptions<ArraySeparatorStyle> & {
26
26
  value: unknown[];
27
27
  }) => string;