@versori/run 0.2.1 → 0.2.2-alpha.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 (71) hide show
  1. package/esm/src/dsl/http/default.d.ts +2 -2
  2. package/esm/src/dsl/http/default.d.ts.map +1 -1
  3. package/esm/src/dsl/http/default.js +6 -5
  4. package/esm/src/dsl/http/types.d.ts +2 -2
  5. package/esm/src/dsl/http/types.d.ts.map +1 -1
  6. package/esm/src/dsl/http/versori/constants.d.ts +2 -0
  7. package/esm/src/dsl/http/versori/constants.d.ts.map +1 -1
  8. package/esm/src/dsl/http/versori/constants.js +2 -0
  9. package/esm/src/dsl/http/versori/contextcredentials.d.ts.map +1 -1
  10. package/esm/src/dsl/http/versori/credentials/client.d.ts +1 -1
  11. package/esm/src/dsl/http/versori/credentials/client.d.ts.map +1 -1
  12. package/esm/src/dsl/http/versori/credentials/client.js +4 -4
  13. package/esm/src/dsl/http/versori/roundtripper.d.ts +8 -6
  14. package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
  15. package/esm/src/dsl/http/versori/roundtripper.js +123 -73
  16. package/esm/src/dsl/tasks/HttpTask.d.ts +1 -1
  17. package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
  18. package/esm/src/dsl/tasks/HttpTask.js +4 -2
  19. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +6 -2
  20. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  21. package/esm/src/interpreter/memory/MemoryInterpreter.js +68 -14
  22. package/esm/src/interpreter/memory/ObservableCompiler.d.ts +2 -0
  23. package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
  24. package/esm/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
  25. package/esm/src/interpreter/memory/compilers/catch.js +24 -7
  26. package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
  27. package/esm/src/interpreter/memory/compilers/fn.js +12 -6
  28. package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
  29. package/esm/src/interpreter/memory/compilers/http.js +30 -6
  30. package/esm/src/interpreter/memory/compilers/parallel.d.ts.map +1 -1
  31. package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  32. package/esm/src/interpreter/memory/compilers/schedule.js +29 -3
  33. package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  34. package/esm/src/interpreter/memory/compilers/webhook.js +97 -68
  35. package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
  36. package/package.json +5 -1
  37. package/script/src/dsl/http/default.d.ts +2 -2
  38. package/script/src/dsl/http/default.d.ts.map +1 -1
  39. package/script/src/dsl/http/default.js +6 -5
  40. package/script/src/dsl/http/types.d.ts +2 -2
  41. package/script/src/dsl/http/types.d.ts.map +1 -1
  42. package/script/src/dsl/http/versori/constants.d.ts +2 -0
  43. package/script/src/dsl/http/versori/constants.d.ts.map +1 -1
  44. package/script/src/dsl/http/versori/constants.js +3 -1
  45. package/script/src/dsl/http/versori/contextcredentials.d.ts.map +1 -1
  46. package/script/src/dsl/http/versori/credentials/client.d.ts +1 -1
  47. package/script/src/dsl/http/versori/credentials/client.d.ts.map +1 -1
  48. package/script/src/dsl/http/versori/credentials/client.js +3 -3
  49. package/script/src/dsl/http/versori/roundtripper.d.ts +8 -6
  50. package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
  51. package/script/src/dsl/http/versori/roundtripper.js +123 -73
  52. package/script/src/dsl/tasks/HttpTask.d.ts +1 -1
  53. package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
  54. package/script/src/dsl/tasks/HttpTask.js +4 -2
  55. package/script/src/interpreter/memory/MemoryInterpreter.d.ts +6 -2
  56. package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  57. package/script/src/interpreter/memory/MemoryInterpreter.js +68 -14
  58. package/script/src/interpreter/memory/ObservableCompiler.d.ts +2 -0
  59. package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
  60. package/script/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
  61. package/script/src/interpreter/memory/compilers/catch.js +24 -7
  62. package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
  63. package/script/src/interpreter/memory/compilers/fn.js +12 -6
  64. package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
  65. package/script/src/interpreter/memory/compilers/http.js +30 -6
  66. package/script/src/interpreter/memory/compilers/parallel.d.ts.map +1 -1
  67. package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  68. package/script/src/interpreter/memory/compilers/schedule.js +29 -3
  69. package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  70. package/script/src/interpreter/memory/compilers/webhook.js +97 -68
  71. package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.webhookCompiler = void 0;
7
- // In src/interpreter/memory/compilers/webhook.ts
8
7
  const cors_1 = __importDefault(require("cors"));
9
8
  const promises_1 = require("node:stream/promises");
10
9
  const rxjs_1 = require("rxjs");
@@ -88,89 +87,119 @@ exports.webhookCompiler = {
88
87
  }
89
88
  // endpoint for sans user because I'm not quite sure how the dynamic routing works
90
89
  ctx.router.post(`/${trigger.id}`, (req, res) => {
91
- const executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
92
- try {
93
- subscriber.next(executionCtx);
94
- if (isAsync) {
95
- sendResponse(res, onSuccess(executionCtx));
90
+ ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
91
+ span.setAttribute('task.id', trigger.id);
92
+ span.setAttribute('task.type', 'webhook');
93
+ const executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
94
+ span.setAttribute('execution.id', executionCtx.executionId);
95
+ try {
96
+ subscriber.next(executionCtx);
97
+ if (isAsync) {
98
+ sendResponse(res, onSuccess(executionCtx));
99
+ }
96
100
  }
97
- }
98
- catch (error) {
99
- executionCtx.log.error('webhook execution error', {
100
- error: JSON.stringify(error),
101
- });
102
- if (isAsync) {
103
- sendResponse(res, onError(executionCtx.withData(error)));
101
+ catch (error) {
102
+ executionCtx.log.error('webhook execution error', {
103
+ error: JSON.stringify(error),
104
+ });
105
+ if (isAsync) {
106
+ sendResponse(res, onError(executionCtx.withData(error)));
107
+ }
104
108
  }
105
- }
109
+ finally {
110
+ span.end();
111
+ }
112
+ });
106
113
  });
107
114
  // this endpoint will trigger the workflow for each activation given by the external user ID
108
115
  ctx.router.post(`/${trigger.id}/users/:userId`, async (req, res) => {
109
- const userId = req.params.userId;
110
- const activations = await ctx.connectionProvider.getUserActivations(userId);
111
- if (!activations || activations.length === 0) {
112
- res.status(404).json({
113
- status: 'error',
114
- message: `No activations found for user: ${userId}`,
116
+ await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
117
+ span.setAttribute('task.id', trigger.id);
118
+ span.setAttribute('task.type', 'webhook');
119
+ span.setAttribute('user.id', req.params.userId);
120
+ const userId = req.params.userId;
121
+ const activations = await ctx.connectionProvider.getUserActivations(userId);
122
+ if (!activations || activations.length === 0) {
123
+ res.status(404).json({
124
+ status: 'error',
125
+ message: `No activations found for user: ${userId}`,
126
+ });
127
+ span.setAttribute('error.message', `No activations found for user: ${userId}`);
128
+ span.setAttribute('http.status_code', '404');
129
+ span.end();
130
+ return;
131
+ }
132
+ const executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
133
+ span.setAttribute('execution.id', executionCtx.executionId);
134
+ const errors = [];
135
+ activations.forEach((activation) => {
136
+ const activationCtx = executionCtx.withActivation(activation);
137
+ try {
138
+ subscriber.next(activationCtx);
139
+ }
140
+ catch (error) {
141
+ activationCtx.log.error('webhook execution error', {
142
+ error: JSON.stringify(error),
143
+ });
144
+ errors.push({
145
+ activationId: activation.id,
146
+ error,
147
+ });
148
+ }
115
149
  });
116
- return;
117
- }
118
- const executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
119
- const errors = [];
120
- activations.forEach((activation) => {
121
- const activationCtx = executionCtx.withActivation(activation);
150
+ if (isAsync) {
151
+ if (errors.length === 0) {
152
+ sendResponse(res, onSuccess(executionCtx));
153
+ }
154
+ else {
155
+ sendResponse(res, onError(executionCtx.withData(errors)));
156
+ }
157
+ }
158
+ span.end();
159
+ });
160
+ });
161
+ // this endpoint will trigger the workflow only for the activation given by its ID
162
+ ctx.router.post(`/${trigger.id}/activations/:activationId`, async (req, res) => {
163
+ await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
164
+ span.setAttribute('task.id', trigger.id);
165
+ span.setAttribute('task.type', 'webhook');
166
+ span.setAttribute('activation.id', req.params.activationId);
167
+ const activationId = req.params.activationId;
168
+ const activation = await ctx.connectionProvider.getActivation(activationId);
169
+ if (!activation) {
170
+ // TODO report back actual errors
171
+ res.status(404).json({
172
+ status: 'error',
173
+ message: `No activation found for ID: ${activationId}`,
174
+ });
175
+ span.setAttribute('error.message', `No activation found for ID: ${activationId}`);
176
+ span.setAttribute('http.status_code', '404');
177
+ span.end();
178
+ return;
179
+ }
180
+ const activationCtx = ctx.contextProvider.create(req.body, {
181
+ ...ctxOptionsFn(res),
182
+ activation,
183
+ });
184
+ span.setAttribute('execution.id', activationCtx.executionId);
122
185
  try {
123
186
  subscriber.next(activationCtx);
187
+ if (isAsync) {
188
+ sendResponse(res, onSuccess(activationCtx));
189
+ }
124
190
  }
125
191
  catch (error) {
126
192
  activationCtx.log.error('webhook execution error', {
127
193
  error: JSON.stringify(error),
128
194
  });
129
- errors.push({
130
- activationId: activation.id,
131
- error,
132
- });
133
- }
134
- });
135
- if (isAsync) {
136
- if (errors.length === 0) {
137
- sendResponse(res, onSuccess(executionCtx));
195
+ if (isAsync) {
196
+ sendResponse(res, onError(activationCtx.withData(error)));
197
+ }
138
198
  }
139
- else {
140
- sendResponse(res, onError(executionCtx.withData(errors)));
199
+ finally {
200
+ span.end();
141
201
  }
142
- }
143
- });
144
- // this endpoint will trigger the workflow only for the activation given by its ID
145
- ctx.router.post(`/${trigger.id}/activations/:activationId`, async (req, res) => {
146
- const activationId = req.params.activationId;
147
- const activation = await ctx.connectionProvider.getActivation(activationId);
148
- if (!activation) {
149
- // TODO report back actual errors
150
- res.status(404).json({
151
- status: 'error',
152
- message: `No activation found for ID: ${activationId}`,
153
- });
154
- return;
155
- }
156
- const activationCtx = ctx.contextProvider.create(req.body, {
157
- ...ctxOptionsFn(res),
158
- activation,
159
202
  });
160
- try {
161
- subscriber.next(activationCtx);
162
- if (isAsync) {
163
- sendResponse(res, onSuccess(activationCtx));
164
- }
165
- }
166
- catch (error) {
167
- activationCtx.log.error('webhook execution error', {
168
- error: JSON.stringify(error),
169
- });
170
- if (isAsync) {
171
- sendResponse(res, onError(activationCtx.withData(error)));
172
- }
173
- }
174
203
  });
175
204
  function cleanup() {
176
205
  ctx.log.debug('webhook trigger stopped');
@@ -1 +1 @@
1
- {"version":3,"file":"ConsoleLogger.d.ts","sourceRoot":"","sources":["../../../../src/src/observability/logging/ConsoleLogger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,+CAA+C,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAqM/C;;GAEG;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,EAAE,QAAQ,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAOjE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO9D,IAAI,CAAC,OAAO,EAAE,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