@versori/run 0.4.7 → 0.5.0-alpha.2

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 (151) hide show
  1. package/esm/src/connection/internal/CredentialHolder.d.ts.map +1 -1
  2. package/esm/src/connection/internal/CredentialHolder.js +1 -1
  3. package/esm/src/connection/internal/FetchBuilder.d.ts +9 -2
  4. package/esm/src/connection/internal/FetchBuilder.d.ts.map +1 -1
  5. package/esm/src/connection/internal/FetchBuilder.js +120 -4
  6. package/esm/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
  7. package/esm/src/connection/internal/OutboundConnectionFactory.js +2 -2
  8. package/esm/src/context/Context.d.ts +1 -0
  9. package/esm/src/context/Context.d.ts.map +1 -1
  10. package/esm/src/context/Context.js +3 -0
  11. package/esm/src/context/ContextProvider.d.ts +1 -1
  12. package/esm/src/context/ContextProvider.d.ts.map +1 -1
  13. package/esm/src/context/ContextProvider.js +2 -1
  14. package/esm/src/dsl/Workflow.d.ts.map +1 -1
  15. package/esm/src/dsl/Workflow.js +2 -0
  16. package/esm/src/dsl/http/types.d.ts +2 -0
  17. package/esm/src/dsl/http/types.d.ts.map +1 -1
  18. package/esm/src/dsl/http/versori/configloader.d.ts.map +1 -1
  19. package/esm/src/dsl/http/versori/configloader.js +1 -1
  20. package/esm/src/dsl/http/versori/cronapi.d.ts +2 -3
  21. package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -1
  22. package/esm/src/dsl/http/versori/cronapi.js +14 -15
  23. package/esm/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
  24. package/esm/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
  25. package/esm/src/dsl/http/versori/webhookmiddleware.js +77 -38
  26. package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
  27. package/esm/src/dsl/triggers/WebhookTrigger.js +3 -1
  28. package/esm/src/internal/InternalAuth.d.ts +0 -1
  29. package/esm/src/internal/InternalAuth.d.ts.map +1 -1
  30. package/esm/src/internal/InternalAuth.js +1 -14
  31. package/esm/src/internal/constants.d.ts +3 -1
  32. package/esm/src/internal/constants.d.ts.map +1 -1
  33. package/esm/src/internal/constants.js +4 -1
  34. package/esm/src/internal/supervisor.d.ts +27 -0
  35. package/esm/src/internal/supervisor.d.ts.map +1 -0
  36. package/esm/src/internal/supervisor.js +179 -0
  37. package/esm/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
  38. package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
  39. package/esm/src/interpreter/durable/DurableInterpreter.js +44 -13
  40. package/esm/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
  41. package/esm/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
  42. package/esm/src/interpreter/durable/Queue.js +1 -1
  43. package/esm/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
  44. package/esm/src/interpreter/durable/compilers/catch.js +6 -7
  45. package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
  46. package/esm/src/interpreter/durable/compilers/fn.js +19 -4
  47. package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -1
  48. package/esm/src/interpreter/durable/compilers/http.js +40 -7
  49. package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
  50. package/esm/src/interpreter/durable/compilers/schedule.js +2 -1
  51. package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
  52. package/esm/src/interpreter/durable/compilers/webhook.js +14 -4
  53. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +7 -1
  54. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  55. package/esm/src/interpreter/memory/MemoryInterpreter.js +43 -12
  56. package/esm/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
  57. package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
  58. package/esm/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
  59. package/esm/src/interpreter/memory/compilers/catch.js +8 -7
  60. package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
  61. package/esm/src/interpreter/memory/compilers/fn.js +20 -16
  62. package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
  63. package/esm/src/interpreter/memory/compilers/http.js +40 -6
  64. package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  65. package/esm/src/interpreter/memory/compilers/schedule.js +4 -1
  66. package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  67. package/esm/src/interpreter/memory/compilers/webhook.js +22 -7
  68. package/esm/src/issues/Issues.js +1 -1
  69. package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
  70. package/package.json +3 -1
  71. package/script/src/connection/internal/CredentialHolder.d.ts.map +1 -1
  72. package/script/src/connection/internal/CredentialHolder.js +1 -1
  73. package/script/src/connection/internal/FetchBuilder.d.ts +9 -2
  74. package/script/src/connection/internal/FetchBuilder.d.ts.map +1 -1
  75. package/script/src/connection/internal/FetchBuilder.js +143 -4
  76. package/script/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
  77. package/script/src/connection/internal/OutboundConnectionFactory.js +2 -2
  78. package/script/src/context/Context.d.ts +1 -0
  79. package/script/src/context/Context.d.ts.map +1 -1
  80. package/script/src/context/Context.js +3 -0
  81. package/script/src/context/ContextProvider.d.ts +1 -1
  82. package/script/src/context/ContextProvider.d.ts.map +1 -1
  83. package/script/src/context/ContextProvider.js +2 -1
  84. package/script/src/dsl/Workflow.d.ts.map +1 -1
  85. package/script/src/dsl/Workflow.js +2 -0
  86. package/script/src/dsl/http/types.d.ts +2 -0
  87. package/script/src/dsl/http/types.d.ts.map +1 -1
  88. package/script/src/dsl/http/versori/configloader.d.ts.map +1 -1
  89. package/script/src/dsl/http/versori/configloader.js +1 -1
  90. package/script/src/dsl/http/versori/cronapi.d.ts +2 -3
  91. package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -1
  92. package/script/src/dsl/http/versori/cronapi.js +14 -15
  93. package/script/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
  94. package/script/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
  95. package/script/src/dsl/http/versori/webhookmiddleware.js +77 -38
  96. package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
  97. package/script/src/dsl/triggers/WebhookTrigger.js +3 -1
  98. package/script/src/internal/InternalAuth.d.ts +0 -1
  99. package/script/src/internal/InternalAuth.d.ts.map +1 -1
  100. package/script/src/internal/InternalAuth.js +0 -13
  101. package/script/src/internal/constants.d.ts +3 -1
  102. package/script/src/internal/constants.d.ts.map +1 -1
  103. package/script/src/internal/constants.js +5 -2
  104. package/script/src/internal/supervisor.d.ts +27 -0
  105. package/script/src/internal/supervisor.d.ts.map +1 -0
  106. package/script/src/internal/supervisor.js +187 -0
  107. package/script/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
  108. package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
  109. package/script/src/interpreter/durable/DurableInterpreter.js +49 -18
  110. package/script/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
  111. package/script/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
  112. package/script/src/interpreter/durable/Queue.js +1 -1
  113. package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
  114. package/script/src/interpreter/durable/compilers/catch.js +6 -7
  115. package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
  116. package/script/src/interpreter/durable/compilers/fn.js +19 -4
  117. package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -1
  118. package/script/src/interpreter/durable/compilers/http.js +40 -7
  119. package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
  120. package/script/src/interpreter/durable/compilers/schedule.js +2 -1
  121. package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
  122. package/script/src/interpreter/durable/compilers/webhook.js +14 -4
  123. package/script/src/interpreter/memory/MemoryInterpreter.d.ts +7 -1
  124. package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  125. package/script/src/interpreter/memory/MemoryInterpreter.js +42 -11
  126. package/script/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
  127. package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
  128. package/script/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
  129. package/script/src/interpreter/memory/compilers/catch.js +8 -7
  130. package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
  131. package/script/src/interpreter/memory/compilers/fn.js +20 -16
  132. package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
  133. package/script/src/interpreter/memory/compilers/http.js +40 -6
  134. package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  135. package/script/src/interpreter/memory/compilers/schedule.js +4 -1
  136. package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  137. package/script/src/interpreter/memory/compilers/webhook.js +22 -7
  138. package/script/src/issues/Issues.js +1 -1
  139. package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
  140. package/esm/src/dsl/http/versori/constants.d.ts +0 -20
  141. package/esm/src/dsl/http/versori/constants.d.ts.map +0 -1
  142. package/esm/src/dsl/http/versori/constants.js +0 -37
  143. package/esm/src/internal/cli.d.ts +0 -2
  144. package/esm/src/internal/cli.d.ts.map +0 -1
  145. package/esm/src/internal/cli.js +0 -32
  146. package/script/src/dsl/http/versori/constants.d.ts +0 -20
  147. package/script/src/dsl/http/versori/constants.d.ts.map +0 -1
  148. package/script/src/dsl/http/versori/constants.js +0 -40
  149. package/script/src/internal/cli.d.ts +0 -2
  150. package/script/src/internal/cli.d.ts.map +0 -1
  151. package/script/src/internal/cli.js +0 -35
@@ -16,17 +16,31 @@ exports.httpCompiler = void 0;
16
16
  const rxjs_1 = require("rxjs");
17
17
  const operators_1 = require("rxjs/operators");
18
18
  const DynamicFetchFactory_js_1 = require("../../../connection/DynamicFetchFactory.js");
19
+ const FetchBuilder_js_1 = require("../../../connection/internal/FetchBuilder.js");
19
20
  const StaticFetchFactory_js_1 = require("../../../connection/StaticFetchFactory.js");
20
21
  const HttpTask_js_1 = require("../../../dsl/tasks/HttpTask.js");
22
+ const supervisor_js_1 = require("../../../internal/supervisor.js");
21
23
  function compileHttp(compilerCtx, task) {
22
24
  const cnxMap = compilerCtx.configReader.getCnxMapping(task.opts.connection);
23
25
  let fetchFactory;
24
26
  if (!cnxMap) {
25
- compilerCtx.log.error(`Connection ${task.opts.connection} not found, using default fetch with no credentials`);
26
- fetchFactory = Promise.resolve(new StaticFetchFactory_js_1.StaticFetchFactory(globalThis.fetch));
27
+ compilerCtx.log.warn(`Connection ${task.opts.connection} not found, using default fetch with no credentials`);
28
+ if (supervisor_js_1.enabled) {
29
+ // missing connection map and we are in supervised mode, so we use the fake fetcher
30
+ fetchFactory = Promise.resolve(new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
31
+ }
32
+ else {
33
+ // missing connection map and not in supervised mode, so we use global fetch
34
+ fetchFactory = Promise.resolve(new StaticFetchFactory_js_1.StaticFetchFactory(globalThis.fetch));
35
+ }
27
36
  }
28
37
  else if (cnxMap.dynamic) {
29
- fetchFactory = Promise.resolve(new DynamicFetchFactory_js_1.DynamicFetchFactory(compilerCtx.cnxFactory, compilerCtx.platformApi, compilerCtx.organisationId, cnxMap.templateId));
38
+ if (cnxMap.mockWithAI) {
39
+ fetchFactory = Promise.resolve(new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
40
+ }
41
+ else {
42
+ fetchFactory = Promise.resolve(new DynamicFetchFactory_js_1.DynamicFetchFactory(compilerCtx.cnxFactory, compilerCtx.platformApi, compilerCtx.organisationId, cnxMap.templateId));
43
+ }
30
44
  }
31
45
  else {
32
46
  fetchFactory = compilerCtx.platformApi.getConnection({
@@ -36,8 +50,21 @@ function compileHttp(compilerCtx, task) {
36
50
  },
37
51
  throwOnError: true,
38
52
  })
39
- .then(({ data }) => Promise.all([compilerCtx.cnxFactory.fetcher(data), data.baseUrl ?? '']))
40
- .then(([fetcher, baseUrl]) => new StaticFetchFactory_js_1.StaticFetchFactory(fetcher, baseUrl));
53
+ .then(({ data }) => {
54
+ if (cnxMap.mockWithAI) {
55
+ // use the fake fetcher that calls the supervisor to generate a mock reponse
56
+ return new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, data).buildSupervisedFetch());
57
+ }
58
+ return Promise.all([compilerCtx.cnxFactory.fetcher(data), data.baseUrl ?? ''])
59
+ .then(([fetcher, baseUrl]) => new StaticFetchFactory_js_1.StaticFetchFactory(fetcher, baseUrl));
60
+ })
61
+ .catch((err) => {
62
+ compilerCtx.log.error(`Failed to get connection ${task.opts.connection}`, err);
63
+ if (supervisor_js_1.enabled) {
64
+ return new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, { name: task.opts.connection }).build());
65
+ }
66
+ throw err;
67
+ });
41
68
  }
42
69
  async function http(ctx) {
43
70
  const [fetch, baseUrl] = await fetchFactory.then((ff) => Promise.all([ff.fetcher(ctx), ff.baseUrl(ctx)]));
@@ -49,12 +76,19 @@ function compileHttp(compilerCtx, task) {
49
76
  complete: () => compilerCtx.log.debug('http.complete'),
50
77
  }), (0, rxjs_1.mergeMap)((ctx) => {
51
78
  return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
79
+ await (0, supervisor_js_1.sendTaskStartEvent)(task.id, span);
52
80
  span.setAttribute('task.id', task.id);
53
81
  span.setAttribute('task.type', 'http');
82
+ span.setAttribute('type', 'task');
54
83
  span.setAttribute('execution.id', ctx.executionId);
55
84
  span.setAttribute('connection.name', task.opts.connection);
85
+ const spanContext = span.spanContext();
56
86
  try {
57
- return await http(ctx);
87
+ const newCtx = await http(ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId })));
88
+ if (supervisor_js_1.enabled) {
89
+ span.setAttribute('response.body', JSON.stringify(newCtx.data));
90
+ }
91
+ return newCtx;
58
92
  }
59
93
  catch (error) {
60
94
  if (error instanceof Error) {
@@ -1 +1 @@
1
- {"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAwI7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
1
+ {"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAQzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA4I7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
@@ -14,8 +14,9 @@
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.scheduleCompiler = void 0;
16
16
  const rxjs_1 = require("rxjs");
17
- const constants_js_1 = require("../../../dsl/http/versori/constants.js");
18
17
  const ScheduleTrigger_js_1 = require("../../../dsl/triggers/ScheduleTrigger.js");
18
+ const constants_js_1 = require("../../../internal/constants.js");
19
+ const supervisor_js_1 = require("../../../internal/supervisor.js");
19
20
  function compileSchedule(ctx, trigger, signal) {
20
21
  return new rxjs_1.Observable((subscriber) => {
21
22
  // Add HTTP endpoint for manual triggering
@@ -97,8 +98,10 @@ function compileSchedule(ctx, trigger, signal) {
97
98
  }
98
99
  ctx.cronRouter.post(`/cron/${trigger.id}`, async (req, res) => {
99
100
  await ctx.tracer.startActiveSpan(`schedule-${trigger.id}`, async (span) => {
101
+ await (0, supervisor_js_1.sendTaskStartEvent)(trigger.id, span);
100
102
  span.setAttribute('task.id', trigger.id);
101
103
  span.setAttribute('task.type', 'schedule');
104
+ span.setAttribute('type', 'task');
102
105
  span.setAttribute('schedule', trigger.schedule);
103
106
  span.setAttribute('project.id', projectId);
104
107
  span.setAttribute('environment.id', environmentId);
@@ -1 +1 @@
1
- {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAyD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CA4SxE,CAAC"}
1
+ {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAwD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CAkUxE,CAAC"}
@@ -18,12 +18,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.webhookCompiler = void 0;
19
19
  const cors_1 = __importDefault(require("cors"));
20
20
  const express_1 = __importDefault(require("express"));
21
+ const express_xml_bodyparser_1 = __importDefault(require("express-xml-bodyparser"));
21
22
  const promises_1 = require("node:stream/promises");
22
23
  const rxjs_1 = require("rxjs");
23
24
  const webhookmiddleware_js_1 = require("../../../dsl/http/versori/webhookmiddleware.js");
24
25
  const WebhookTrigger_js_1 = require("../../../dsl/triggers/WebhookTrigger.js");
25
26
  const constants_js_1 = require("../../../internal/constants.js");
26
- const express_xml_bodyparser_1 = __importDefault(require("express-xml-bodyparser"));
27
+ const supervisor_js_1 = require("../../../internal/supervisor.js");
27
28
  const xml2jsDefaults = {
28
29
  explicitArray: false,
29
30
  normalize: false,
@@ -123,6 +124,7 @@ exports.webhookCompiler = {
123
124
  ctx.webhookRouter.use((0, cors_1.default)(corsOptions));
124
125
  }
125
126
  }
127
+ ctx.webhookRegistry.set(trigger.id, { method, path: `/${trigger.id}`, options: trigger.options });
126
128
  // endpoint for sans user because I'm not quite sure how the dynamic routing works
127
129
  ctx.webhookRouter[method](`/${trigger.id}`, (0, webhookmiddleware_js_1.createStaticWebhookMiddleware)({
128
130
  id: trigger.id,
@@ -134,11 +136,16 @@ exports.webhookCompiler = {
134
136
  cfgReader: ctx.configReader,
135
137
  log: ctx.log,
136
138
  }), async (req, res) => {
137
- await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
139
+ await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
140
+ await (0, supervisor_js_1.sendTaskStartEvent)(trigger.id, span);
138
141
  span.setAttribute('task.id', trigger.id);
139
142
  span.setAttribute('task.type', 'webhook');
143
+ span.setAttribute('type', 'task');
140
144
  const staticActivation = res.locals.activation;
141
- const executionCtx = ctx.contextProvider.create(staticActivation, req.body, ctxOptionsFn(req, res));
145
+ let executionCtx = ctx.contextProvider.create(staticActivation, req.body, ctxOptionsFn(req, res));
146
+ const spanContext = span.spanContext();
147
+ executionCtx = executionCtx.withLogger(executionCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
148
+ executionCtx.log.info("stack", { stack: new Error().stack });
142
149
  span.setAttribute('execution.id', executionCtx.executionId);
143
150
  try {
144
151
  subscriber.next(executionCtx);
@@ -170,9 +177,11 @@ exports.webhookCompiler = {
170
177
  cfgReader: ctx.configReader,
171
178
  log: ctx.log,
172
179
  }), async (req, res) => {
173
- await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
180
+ await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
181
+ await (0, supervisor_js_1.sendTaskStartEvent)(trigger.id, span);
174
182
  span.setAttribute('task.id', trigger.id);
175
183
  span.setAttribute('task.type', 'webhook');
184
+ span.setAttribute('type', 'task');
176
185
  span.setAttribute('user.id', req.params.userId);
177
186
  const userId = req.params.userId;
178
187
  // Right now we only support a user having one activation
@@ -189,7 +198,9 @@ exports.webhookCompiler = {
189
198
  span.end();
190
199
  return;
191
200
  }
192
- const executionCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
201
+ let executionCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
202
+ const spanContext = span.spanContext();
203
+ executionCtx = executionCtx.withLogger(executionCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
193
204
  span.setAttribute('execution.id', executionCtx.executionId);
194
205
  const errors = [];
195
206
  try {
@@ -226,9 +237,11 @@ exports.webhookCompiler = {
226
237
  cfgReader: ctx.configReader,
227
238
  log: ctx.log,
228
239
  }), async (req, res) => {
229
- await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
240
+ await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
241
+ await (0, supervisor_js_1.sendTaskStartEvent)(trigger.id, span);
230
242
  span.setAttribute('task.id', trigger.id);
231
243
  span.setAttribute('task.type', 'webhook');
244
+ span.setAttribute('type', 'task');
232
245
  span.setAttribute('activation.id', req.params.activationId);
233
246
  const activation = res.locals.activation;
234
247
  const activationId = activation?.id ?? req.params.activationId;
@@ -243,7 +256,9 @@ exports.webhookCompiler = {
243
256
  span.end();
244
257
  return;
245
258
  }
246
- const activationCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
259
+ let activationCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
260
+ const spanContext = span.spanContext();
261
+ activationCtx = activationCtx.withLogger(activationCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
247
262
  span.setAttribute('execution.id', activationCtx.executionId);
248
263
  try {
249
264
  subscriber.next(activationCtx);
@@ -14,7 +14,7 @@
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.MockIssues = exports.IssueImpl = void 0;
16
16
  const node_crypto_1 = require("node:crypto");
17
- const constants_js_1 = require("../dsl/http/versori/constants.js");
17
+ const constants_js_1 = require("../internal/constants.js");
18
18
  class IssueImpl {
19
19
  constructor(log) {
20
20
  Object.defineProperty(this, "baseUrl", {
@@ -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;AAsM/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,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,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;CAGlC"}
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;;;;;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,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,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;CAGlC"}
@@ -1,20 +0,0 @@
1
- export declare const envVarOrgId = "RUN_ORGANISATION_ID";
2
- export declare const envVarEnvId = "RUN_ENVIRONMENT_ID";
3
- export declare const envVarEnvironmentName = "RUN_ENVIRONMENT";
4
- export declare const envVarProjectId = "RUN_SERVICE_ID";
5
- export declare const envVarOrgSlug = "RUN_ORGANISATION_SLUG";
6
- export declare const envVarPlatformApiBaseURL = "RUN_PLATFORM_API_INTERNAL_URL";
7
- export declare const envVarCronApiBaseURL = "RUN_CRON_API_INTERNAL_URL";
8
- export declare const envVarSDKApiBaseURL = "RUN_SDK_API_URL";
9
- export declare const envVarSelfRefURL = "RUN_SELF_REF_URL";
10
- export declare const envVarCredsBaseURL = "RUN_CREDENTIALS_SERVICE_INTERNAL_URL";
11
- export declare const envVarOtelTracesURL = "RUN_OTEL_TRACES_URL";
12
- export declare const envVarVersion = "RUN_SERVICE_VERSION";
13
- export declare const envVarConfigFile = "RUN_CONFIG_FILE";
14
- export declare const envVarClientId = "RUN_CLIENT_ID";
15
- export declare const envVarClientSecret = "RUN_CLIENT_SECRET";
16
- export declare const envVarTokenEndpoint = "RUN_TOKEN_ENDPOINT";
17
- export declare const envVarInternalToken = "RUN_INTERNAL_TOKEN";
18
- export declare const envVarLocalRun = "RUN_LOCAL";
19
- export declare const cronPort = 3001;
20
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/constants.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,WAAW,wBAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAChD,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AACrD,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AACxE,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AACrD,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,aAAa,wBAAwB,CAAC;AAEnD,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAGlD,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AACxD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AAGxD,eAAO,MAAM,cAAc,cAAc,CAAC;AAG1C,eAAO,MAAM,QAAQ,OAAO,CAAC"}
@@ -1,37 +0,0 @@
1
- /*
2
- * Copyright (c) 2025 Versori Group Inc
3
- *
4
- * Use of this software is governed by the Business Source License 1.1
5
- * included in the LICENSE file at the root of this repository.
6
- *
7
- * Change Date: 2029-01-01
8
- * Change License: Apache License, Version 2.0
9
- *
10
- * As of the Change Date, in accordance with the Business Source License,
11
- * use of this software will be governed by the Apache License, Version 2.0.
12
- */
13
- //TODO(@teo): remove this file, it is implemented in the src/internal/constants.ts directory now.
14
- // This file contains constants used in the Versori DSL HTTP client.
15
- export const envVarOrgId = 'RUN_ORGANISATION_ID';
16
- export const envVarEnvId = 'RUN_ENVIRONMENT_ID';
17
- export const envVarEnvironmentName = 'RUN_ENVIRONMENT';
18
- export const envVarProjectId = 'RUN_SERVICE_ID';
19
- export const envVarOrgSlug = 'RUN_ORGANISATION_SLUG';
20
- export const envVarPlatformApiBaseURL = 'RUN_PLATFORM_API_INTERNAL_URL';
21
- export const envVarCronApiBaseURL = 'RUN_CRON_API_INTERNAL_URL';
22
- export const envVarSDKApiBaseURL = 'RUN_SDK_API_URL';
23
- export const envVarSelfRefURL = 'RUN_SELF_REF_URL';
24
- export const envVarCredsBaseURL = 'RUN_CREDENTIALS_SERVICE_INTERNAL_URL';
25
- export const envVarOtelTracesURL = 'RUN_OTEL_TRACES_URL';
26
- export const envVarVersion = 'RUN_SERVICE_VERSION';
27
- // The following environment variables are used for the config file
28
- export const envVarConfigFile = 'RUN_CONFIG_FILE';
29
- // The following environment variables are used for internal authentication
30
- export const envVarClientId = 'RUN_CLIENT_ID';
31
- export const envVarClientSecret = 'RUN_CLIENT_SECRET';
32
- export const envVarTokenEndpoint = 'RUN_TOKEN_ENDPOINT';
33
- export const envVarInternalToken = 'RUN_INTERNAL_TOKEN';
34
- // The following are for running locally
35
- export const envVarLocalRun = 'RUN_LOCAL';
36
- // please no changerino
37
- export const cronPort = 3001; // The port on which the cron API communicates with the service
@@ -1,2 +0,0 @@
1
- export declare function getVersoriCookie(): string;
2
- //# sourceMappingURL=cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/src/internal/cli.ts"],"names":[],"mappings":"AA8BA,wBAAgB,gBAAgB,IAAI,MAAM,CAmBzC"}
@@ -1,32 +0,0 @@
1
- /*
2
- * Copyright (c) 2025 Versori Group Inc
3
- *
4
- * Use of this software is governed by the Business Source License 1.1
5
- * included in the LICENSE file at the root of this repository.
6
- *
7
- * Change Date: 2029-01-01
8
- * Change License: Apache License, Version 2.0
9
- *
10
- * As of the Change Date, in accordance with the Business Source License,
11
- * use of this software will be governed by the Apache License, Version 2.0.
12
- */
13
- // This file contains functions that can read stuff generated by the Versori CLI. This is used when running locally.
14
- import { homedir } from 'node:os';
15
- const cookiesFileName = 'cookies.json';
16
- const versoriCookieName = 'versori_sess';
17
- export function getVersoriCookie() {
18
- const cookiesFilePath = `${homedir()}/.config/versori/${cookiesFileName}`;
19
- let cookiesFile;
20
- try {
21
- cookiesFile = JSON.parse(Deno.readTextFileSync(cookiesFilePath));
22
- }
23
- catch (e) {
24
- console.error('Error reading file, have you run the Versori CLI to log in?');
25
- throw new Error(`Failed to read or parse cookies file at ${cookiesFilePath}: ${e}`);
26
- }
27
- const versoriCookie = cookiesFile.cookies.find((cookie) => cookie.Name === versoriCookieName);
28
- if (!versoriCookie) {
29
- throw new Error(`Cookie 'versori_sess' not found in ${cookiesFilePath}`);
30
- }
31
- return `${versoriCookieName}=${versoriCookie.Value}`;
32
- }
@@ -1,20 +0,0 @@
1
- export declare const envVarOrgId = "RUN_ORGANISATION_ID";
2
- export declare const envVarEnvId = "RUN_ENVIRONMENT_ID";
3
- export declare const envVarEnvironmentName = "RUN_ENVIRONMENT";
4
- export declare const envVarProjectId = "RUN_SERVICE_ID";
5
- export declare const envVarOrgSlug = "RUN_ORGANISATION_SLUG";
6
- export declare const envVarPlatformApiBaseURL = "RUN_PLATFORM_API_INTERNAL_URL";
7
- export declare const envVarCronApiBaseURL = "RUN_CRON_API_INTERNAL_URL";
8
- export declare const envVarSDKApiBaseURL = "RUN_SDK_API_URL";
9
- export declare const envVarSelfRefURL = "RUN_SELF_REF_URL";
10
- export declare const envVarCredsBaseURL = "RUN_CREDENTIALS_SERVICE_INTERNAL_URL";
11
- export declare const envVarOtelTracesURL = "RUN_OTEL_TRACES_URL";
12
- export declare const envVarVersion = "RUN_SERVICE_VERSION";
13
- export declare const envVarConfigFile = "RUN_CONFIG_FILE";
14
- export declare const envVarClientId = "RUN_CLIENT_ID";
15
- export declare const envVarClientSecret = "RUN_CLIENT_SECRET";
16
- export declare const envVarTokenEndpoint = "RUN_TOKEN_ENDPOINT";
17
- export declare const envVarInternalToken = "RUN_INTERNAL_TOKEN";
18
- export declare const envVarLocalRun = "RUN_LOCAL";
19
- export declare const cronPort = 3001;
20
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/constants.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,WAAW,wBAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAChD,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AACrD,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AACxE,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AACrD,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,aAAa,wBAAwB,CAAC;AAEnD,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAGlD,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AACxD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AAGxD,eAAO,MAAM,cAAc,cAAc,CAAC;AAG1C,eAAO,MAAM,QAAQ,OAAO,CAAC"}
@@ -1,40 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.cronPort = exports.envVarLocalRun = exports.envVarInternalToken = exports.envVarTokenEndpoint = exports.envVarClientSecret = exports.envVarClientId = exports.envVarConfigFile = exports.envVarVersion = exports.envVarOtelTracesURL = exports.envVarCredsBaseURL = exports.envVarSelfRefURL = exports.envVarSDKApiBaseURL = exports.envVarCronApiBaseURL = exports.envVarPlatformApiBaseURL = exports.envVarOrgSlug = exports.envVarProjectId = exports.envVarEnvironmentName = exports.envVarEnvId = exports.envVarOrgId = void 0;
16
- //TODO(@teo): remove this file, it is implemented in the src/internal/constants.ts directory now.
17
- // This file contains constants used in the Versori DSL HTTP client.
18
- exports.envVarOrgId = 'RUN_ORGANISATION_ID';
19
- exports.envVarEnvId = 'RUN_ENVIRONMENT_ID';
20
- exports.envVarEnvironmentName = 'RUN_ENVIRONMENT';
21
- exports.envVarProjectId = 'RUN_SERVICE_ID';
22
- exports.envVarOrgSlug = 'RUN_ORGANISATION_SLUG';
23
- exports.envVarPlatformApiBaseURL = 'RUN_PLATFORM_API_INTERNAL_URL';
24
- exports.envVarCronApiBaseURL = 'RUN_CRON_API_INTERNAL_URL';
25
- exports.envVarSDKApiBaseURL = 'RUN_SDK_API_URL';
26
- exports.envVarSelfRefURL = 'RUN_SELF_REF_URL';
27
- exports.envVarCredsBaseURL = 'RUN_CREDENTIALS_SERVICE_INTERNAL_URL';
28
- exports.envVarOtelTracesURL = 'RUN_OTEL_TRACES_URL';
29
- exports.envVarVersion = 'RUN_SERVICE_VERSION';
30
- // The following environment variables are used for the config file
31
- exports.envVarConfigFile = 'RUN_CONFIG_FILE';
32
- // The following environment variables are used for internal authentication
33
- exports.envVarClientId = 'RUN_CLIENT_ID';
34
- exports.envVarClientSecret = 'RUN_CLIENT_SECRET';
35
- exports.envVarTokenEndpoint = 'RUN_TOKEN_ENDPOINT';
36
- exports.envVarInternalToken = 'RUN_INTERNAL_TOKEN';
37
- // The following are for running locally
38
- exports.envVarLocalRun = 'RUN_LOCAL';
39
- // please no changerino
40
- exports.cronPort = 3001; // The port on which the cron API communicates with the service
@@ -1,2 +0,0 @@
1
- export declare function getVersoriCookie(): string;
2
- //# sourceMappingURL=cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/src/internal/cli.ts"],"names":[],"mappings":"AA8BA,wBAAgB,gBAAgB,IAAI,MAAM,CAmBzC"}
@@ -1,35 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getVersoriCookie = getVersoriCookie;
16
- // This file contains functions that can read stuff generated by the Versori CLI. This is used when running locally.
17
- const node_os_1 = require("node:os");
18
- const cookiesFileName = 'cookies.json';
19
- const versoriCookieName = 'versori_sess';
20
- function getVersoriCookie() {
21
- const cookiesFilePath = `${(0, node_os_1.homedir)()}/.config/versori/${cookiesFileName}`;
22
- let cookiesFile;
23
- try {
24
- cookiesFile = JSON.parse(Deno.readTextFileSync(cookiesFilePath));
25
- }
26
- catch (e) {
27
- console.error('Error reading file, have you run the Versori CLI to log in?');
28
- throw new Error(`Failed to read or parse cookies file at ${cookiesFilePath}: ${e}`);
29
- }
30
- const versoriCookie = cookiesFile.cookies.find((cookie) => cookie.Name === versoriCookieName);
31
- if (!versoriCookie) {
32
- throw new Error(`Cookie 'versori_sess' not found in ${cookiesFilePath}`);
33
- }
34
- return `${versoriCookieName}=${versoriCookie.Value}`;
35
- }