@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
@@ -22,15 +22,16 @@ import { ContextProviderImpl } from '../../context/ContextProvider.js';
22
22
  import { VersoriConfigReader } from '../../dsl/http/versori/configloader.js';
23
23
  import { CronAPIClient } from '../../dsl/http/versori/cronapi.js';
24
24
  import { WorkflowImpl } from '../../dsl/Workflow.js';
25
- import { envVarEnvId, envVarEnvironmentName, envVarLocalRun, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion } from '../../internal/constants.js';
25
+ import { envCronPort, envPort, envReadyCheckURL, envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion } from '../../internal/constants.js';
26
+ import { Fake, registerCrons, registerWebhooks, enabled as supervisorEnabled } from '../../internal/supervisor.js';
26
27
  import { IssueImpl } from '../../issues/Issues.js';
27
28
  import { MemoryKeyValueProvider } from '../../kv/memory/MemoryKeyValueProvider.js';
28
29
  import { NatsKeyValueProvider } from '../../kv/nats/NatsKeyValueProvider.js';
29
30
  import { ConsoleLogger } from '../../observability/logging/ConsoleLogger.js';
30
31
  import { PlatformApiImpl } from '../../services/platform/PlatformApi.js';
31
32
  import { ObservableCompiler } from './ObservableCompiler.js';
32
- function getKVProvider(runLocal) {
33
- if (runLocal) {
33
+ function getKVProvider() {
34
+ if (supervisorEnabled) {
34
35
  return Promise.resolve(new MemoryKeyValueProvider());
35
36
  }
36
37
  return NatsKeyValueProvider.fromEnv();
@@ -57,7 +58,7 @@ function getKVProvider(runLocal) {
57
58
  * ```
58
59
  */
59
60
  export class MemoryInterpreter {
60
- constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, cnxFactory, cronProvider, tracer, issuesProvider, cfgReader, otelSDK) {
61
+ constructor(log, compiler, contextProvider, webhookRouter, cronRouter, cronRegistry, webhookRegistry, cnxFactory, cronProvider, tracer, issuesProvider, cfgReader, otelSDK) {
61
62
  Object.defineProperty(this, "log", {
62
63
  enumerable: true,
63
64
  configurable: true,
@@ -94,6 +95,12 @@ export class MemoryInterpreter {
94
95
  writable: true,
95
96
  value: cronRegistry
96
97
  });
98
+ Object.defineProperty(this, "webhookRegistry", {
99
+ enumerable: true,
100
+ configurable: true,
101
+ writable: true,
102
+ value: webhookRegistry
103
+ });
97
104
  Object.defineProperty(this, "cnxFactory", {
98
105
  enumerable: true,
99
106
  configurable: true,
@@ -178,7 +185,6 @@ export class MemoryInterpreter {
178
185
  const otelTracesURL = Deno.env.get(envVarOtelTracesURL);
179
186
  let otelSDK;
180
187
  const configReader = VersoriConfigReader.fromEnv(log);
181
- const runLocal = Deno.env.get(envVarLocalRun) === 'true';
182
188
  await waitForReady(log);
183
189
  // Do NOT change those attributes, they are used by the API to filter on
184
190
  const resource = resourceFromAttributes({
@@ -200,20 +206,29 @@ export class MemoryInterpreter {
200
206
  log.info('Starting OpenTelemetry SDK');
201
207
  otelSDK.start();
202
208
  }
209
+ else if (supervisorEnabled) {
210
+ otelSDK = new NodeSDK({
211
+ traceExporter: new Fake(),
212
+ serviceName: serviceName,
213
+ resource: resource,
214
+ });
215
+ log.info('Starting Testing OpenTelemetry SDK');
216
+ otelSDK.start();
217
+ }
203
218
  const tracer = opentelemetry.trace.getTracer(serviceName, version);
204
219
  const connectionFactory = DirectConnectionFactory.fromEnv(log);
205
220
  const issuesProvider = new IssueImpl(log);
206
221
  if (options.contextProvider) {
207
222
  // no need to set up a key-value provider if options.contextProvider is already
208
223
  // initialised.
209
- return new MemoryInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(), DirectConnectionFactory.fromEnv(log), CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
224
+ return new MemoryInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(), new Map(), connectionFactory, CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
210
225
  }
211
- const kvp = await getKVProvider(runLocal);
226
+ const kvp = await getKVProvider();
212
227
  const platformApi = PlatformApiImpl.fromEnv();
213
228
  const organisationId = Deno.env.get(envVarOrgId) || 'development';
214
229
  const environmentId = Deno.env.get(envVarEnvId) || 'development';
215
230
  const ctxProvider = new ContextProviderImpl(log, kvp, new CredentialsProviderImpl(connectionFactory.credentials, connectionFactory.tokens, connectionFactory.oauth1, configReader, platformApi), platformApi, organisationId, environmentId, issuesProvider);
216
- return new MemoryInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(), connectionFactory, CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
231
+ return new MemoryInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(), new Map(), connectionFactory, CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
217
232
  }
218
233
  register(workflow, options) {
219
234
  const localAbortController = new AbortController();
@@ -232,6 +247,7 @@ export class MemoryInterpreter {
232
247
  cnxFactory: this.cnxFactory,
233
248
  platformApi: PlatformApiImpl.fromEnv(),
234
249
  webhookRouter: this.webhookRouter,
250
+ webhookRegistry: this.webhookRegistry,
235
251
  cronRouter: this.cronRouter,
236
252
  cronRegistry: this.cronRegistry,
237
253
  configReader: this.cfgReader,
@@ -252,9 +268,9 @@ export class MemoryInterpreter {
252
268
  this.registeredWorkflows.push(registration);
253
269
  return registration;
254
270
  }
255
- start() {
256
- const port = Deno.env.get('PORT') || 3000;
257
- const cronPort = Deno.env.get('CRON_PORT') || 3001;
271
+ async start() {
272
+ const port = Deno.env.get(envPort) || 3000;
273
+ const cronPort = Deno.env.get(envCronPort) || 3001;
258
274
  const webhookApp = express();
259
275
  const cronApp = express();
260
276
  cronApp.use(express.json());
@@ -278,6 +294,12 @@ export class MemoryInterpreter {
278
294
  ctx.log.error('MemoryInterpreter.executionError', {
279
295
  error: err instanceof Error ? err.toString() : err,
280
296
  });
297
+ this.tracer.startActiveSpan('done', (span) => {
298
+ span.setAttribute('error.message', err instanceof Error ? err.toString() : err);
299
+ span.setAttribute('execution.id', ctx.executionId);
300
+ span.setAttribute('result', 'fail');
301
+ span.end();
302
+ });
281
303
  try {
282
304
  ctx.options.onError?.(ctx.withData(err));
283
305
  }
@@ -297,6 +319,11 @@ export class MemoryInterpreter {
297
319
  durationMs,
298
320
  data: ctx.data,
299
321
  });
322
+ this.tracer.startActiveSpan('done', (span) => {
323
+ span.setAttribute('execution.id', ctx.executionId);
324
+ span.setAttribute('result', 'pass');
325
+ span.end();
326
+ });
300
327
  try {
301
328
  ctx.options.onSuccess?.(ctx);
302
329
  }
@@ -333,6 +360,9 @@ export class MemoryInterpreter {
333
360
  });
334
361
  throw new Error('Unable to register scheduler tasks with central cron provider');
335
362
  }
363
+ // register with suopervisor
364
+ await registerCrons(this.cronRegistry);
365
+ await registerWebhooks(this.webhookRegistry);
336
366
  this.webhookServer = webhookApp.listen(port, () => {
337
367
  this.log.info(`Express server listening on port ${port}`);
338
368
  });
@@ -352,6 +382,7 @@ export class MemoryInterpreter {
352
382
  if (this.cronServer) {
353
383
  this.cronServer.close();
354
384
  }
385
+ this.otelSDK?.shutdown();
355
386
  // Remove all signal listeners
356
387
  for (const registration of this.registeredWorkflows) {
357
388
  Deno.removeSignalListener('SIGINT', registration.sigintListener);
@@ -404,7 +435,7 @@ export class MemoryInterpreter {
404
435
  }
405
436
  }
406
437
  async function waitForReady(log) {
407
- const readyCheckUrl = Deno.env.get('READY_CHECK_URL');
438
+ const readyCheckUrl = Deno.env.get(envReadyCheckURL);
408
439
  if (!readyCheckUrl) {
409
440
  return Promise.resolve();
410
441
  }
@@ -1,6 +1,7 @@
1
1
  import { Tracer } from '@opentelemetry/api';
2
2
  import { Router } from 'express';
3
3
  import { Observable, OperatorFunction } from 'rxjs';
4
+ import { ConnectionFactory } from '../../connection/types.js';
4
5
  import { ContextImpl } from '../../context/Context.js';
5
6
  import { ContextProvider } from '../../context/ContextProvider.js';
6
7
  import { ConfigReader } from '../../dsl/http/types.js';
@@ -10,7 +11,6 @@ import { IssueAPI } from '../../issues/Issues.js';
10
11
  import { Logger } from '../../observability/logging/Logger.js';
11
12
  import { PlatformApi } from '../../services/platform/PlatformApi.js';
12
13
  import { ContextOperatorFunction, TaskCompiler, TriggerCompiler } from './compilers/types.js';
13
- import { ConnectionFactory } from '../../connection/types.js';
14
14
  export type CompilerContext = {
15
15
  compiler: ObservableCompiler;
16
16
  log: Logger;
@@ -23,6 +23,11 @@ export type CompilerContext = {
23
23
  issueProvider: IssueAPI;
24
24
  configReader: ConfigReader;
25
25
  cronRegistry: Map<string, string>;
26
+ webhookRegistry: Map<string, {
27
+ method: string;
28
+ path: string;
29
+ options: any;
30
+ }>;
26
31
  organisationId: string;
27
32
  };
28
33
  export type CompilerFunc<In = any, Out = any, T extends Task<In, Out> = Task<In, Out>> = (ctx: CompilerContext, task: T) => OperatorFunction<In, Out>;
@@ -1 +1 @@
1
- {"version":3,"file":"ObservableCompiler.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/ObservableCompiler.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAY,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAe,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AASrE,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,MAAM,MAAM,eAAe,GAAG;IAC1B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,EAAE,iBAAi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AE,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAKjF,eAAe,CAAC,GAAG,EAAE,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,eAAe,CAAC,GAAG,EAAE,CAAC,CAAC;CAIjF"}
@@ -1 +1 @@
1
- {"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/catch.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAoFnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
1
+ {"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/catch.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAsFnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
@@ -19,8 +19,11 @@ function compileCatch(compilerCtx, task) {
19
19
  return (src) => src.pipe(mergeMap((ctx) => {
20
20
  return baseOperator(of(ctx)).pipe(catchError((error) => {
21
21
  return compilerCtx.tracer.startActiveSpan(`catch`, (span) => {
22
+ // TODO: do we even want this here? Can't be async in here I believe
23
+ // await sendTaskStartEvent(task.id, span);
22
24
  span.setAttribute('execution.id', ctx.executionId);
23
25
  span.setAttribute('task.type', 'catch');
26
+ span.setAttribute('type', 'task');
24
27
  if (error instanceof Error) {
25
28
  span.recordException(error);
26
29
  span.setAttribute('error.message', error.message);
@@ -34,10 +37,9 @@ function compileCatch(compilerCtx, task) {
34
37
  annotations: {
35
38
  'error': error.message,
36
39
  'stack': error.stack || '',
37
- 'workflowId': ctx.options.workflowId || ctx.workflowId || '',
40
+ 'workflowId': ctx.options.workflowId || ctx.workflowId ||
41
+ '',
38
42
  'executionId': ctx.executionId,
39
- 'activationId': ctx.activation.id,
40
- 'activationExternalId': ctx.activation?.user.externalId,
41
43
  },
42
44
  reason: 'error',
43
45
  severity: 'high',
@@ -46,12 +48,11 @@ function compileCatch(compilerCtx, task) {
46
48
  }
47
49
  compilerCtx.issueProvider.submitIssue({
48
50
  annotations: {
49
- 'error': error.message,
51
+ 'error': error.message || '',
50
52
  'stack': error.stack || '',
51
- 'workflowId': ctx.options.workflowId || ctx.workflowId || '',
53
+ 'workflowId': ctx.options.workflowId || ctx.workflowId ||
54
+ '',
52
55
  'executionId': ctx.executionId,
53
- 'activationId': ctx.activation.id,
54
- 'activationExternalId': ctx.activation?.user.externalId,
55
56
  },
56
57
  reason: 'error',
57
58
  severity: 'low',
@@ -1 +1 @@
1
- {"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/fn.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA+BnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
1
+ {"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/fn.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA6CnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
@@ -1,30 +1,34 @@
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
1
  import { mergeMap, tap } from 'rxjs';
14
2
  import { FnTask } from '../../../dsl/tasks/FnTask.js';
3
+ import { sendTaskStartEvent, enabled as supervisorEnabled } from '../../../internal/supervisor.js';
15
4
  function compileFn(compilerCtx, task) {
16
5
  return (src) => src.pipe(tap({
17
6
  complete: () => compilerCtx.log.debug('fn.complete'),
18
7
  }), mergeMap(async (ctx) => {
19
8
  return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
9
+ await sendTaskStartEvent(task.id, span);
20
10
  span.setAttribute('task.id', task.id);
11
+ span.setAttribute('type', 'task');
12
+ span.setAttribute('task.type', 'fn');
21
13
  span.setAttribute('execution.id', ctx.executionId);
22
- if (typeof ctx.idx === 'number') {
14
+ try {
15
+ let result;
16
+ const spanContext = span.spanContext();
17
+ const ctxWithLogger = ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
18
+ if (typeof ctx.idx === 'number') {
19
+ result = ctx.withData(await task._fn(ctxWithLogger, ctx.idx));
20
+ }
21
+ else {
22
+ result = ctx.withData(await task._fn(ctxWithLogger));
23
+ }
24
+ if (supervisorEnabled) {
25
+ span.setAttribute('response.body', JSON.stringify(result.data));
26
+ }
27
+ return result;
28
+ }
29
+ finally {
23
30
  span.end();
24
- return ctx.withData(await task._fn(ctx, ctx.idx));
25
31
  }
26
- span.end();
27
- return ctx.withData(await task._fn(ctx));
28
32
  });
29
33
  }));
30
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/http.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAqFnE,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/http.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAG/E,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAyHnE,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
@@ -13,17 +13,31 @@
13
13
  import { mergeMap } from 'rxjs';
14
14
  import { tap } from 'rxjs/operators';
15
15
  import { DynamicFetchFactory } from '../../../connection/DynamicFetchFactory.js';
16
+ import { FetchBuilder } from '../../../connection/internal/FetchBuilder.js';
16
17
  import { StaticFetchFactory } from '../../../connection/StaticFetchFactory.js';
17
18
  import { HttpContextImpl, HttpTaskImpl } from '../../../dsl/tasks/HttpTask.js';
19
+ import { sendTaskStartEvent, enabled as supervisorEnabled } from '../../../internal/supervisor.js';
18
20
  function compileHttp(compilerCtx, task) {
19
21
  const cnxMap = compilerCtx.configReader.getCnxMapping(task.opts.connection);
20
22
  let fetchFactory;
21
23
  if (!cnxMap) {
22
- compilerCtx.log.error(`Connection ${task.opts.connection} not found, using default fetch with no credentials`);
23
- fetchFactory = Promise.resolve(new StaticFetchFactory(globalThis.fetch));
24
+ compilerCtx.log.warn(`Connection ${task.opts.connection} not found, using default fetch with no credentials`);
25
+ if (supervisorEnabled) {
26
+ // missing connection map and we are in supervised mode, so we use the fake fetcher
27
+ fetchFactory = Promise.resolve(new StaticFetchFactory(new FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
28
+ }
29
+ else {
30
+ // missing connection map and not in supervised mode, so we use global fetch
31
+ fetchFactory = Promise.resolve(new StaticFetchFactory(globalThis.fetch));
32
+ }
24
33
  }
25
34
  else if (cnxMap.dynamic) {
26
- fetchFactory = Promise.resolve(new DynamicFetchFactory(compilerCtx.cnxFactory, compilerCtx.platformApi, compilerCtx.organisationId, cnxMap.templateId));
35
+ if (cnxMap.mockWithAI) {
36
+ fetchFactory = Promise.resolve(new StaticFetchFactory(new FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
37
+ }
38
+ else {
39
+ fetchFactory = Promise.resolve(new DynamicFetchFactory(compilerCtx.cnxFactory, compilerCtx.platformApi, compilerCtx.organisationId, cnxMap.templateId));
40
+ }
27
41
  }
28
42
  else {
29
43
  fetchFactory = compilerCtx.platformApi.getConnection({
@@ -33,8 +47,21 @@ function compileHttp(compilerCtx, task) {
33
47
  },
34
48
  throwOnError: true,
35
49
  })
36
- .then(({ data }) => Promise.all([compilerCtx.cnxFactory.fetcher(data), data.baseUrl ?? '']))
37
- .then(([fetcher, baseUrl]) => new StaticFetchFactory(fetcher, baseUrl));
50
+ .then(({ data }) => {
51
+ if (cnxMap.mockWithAI) {
52
+ // use the fake fetcher that calls the supervisor to generate a mock reponse
53
+ return new StaticFetchFactory(new FetchBuilder(globalThis.fetch, data).buildSupervisedFetch());
54
+ }
55
+ return Promise.all([compilerCtx.cnxFactory.fetcher(data), data.baseUrl ?? ''])
56
+ .then(([fetcher, baseUrl]) => new StaticFetchFactory(fetcher, baseUrl));
57
+ })
58
+ .catch((err) => {
59
+ compilerCtx.log.error(`Failed to get connection ${task.opts.connection}`, err);
60
+ if (supervisorEnabled) {
61
+ return new StaticFetchFactory(new FetchBuilder(globalThis.fetch, { name: task.opts.connection }).build());
62
+ }
63
+ throw err;
64
+ });
38
65
  }
39
66
  async function http(ctx) {
40
67
  const [fetch, baseUrl] = await fetchFactory.then((ff) => Promise.all([ff.fetcher(ctx), ff.baseUrl(ctx)]));
@@ -46,12 +73,19 @@ function compileHttp(compilerCtx, task) {
46
73
  complete: () => compilerCtx.log.debug('http.complete'),
47
74
  }), mergeMap((ctx) => {
48
75
  return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
76
+ await sendTaskStartEvent(task.id, span);
49
77
  span.setAttribute('task.id', task.id);
50
78
  span.setAttribute('task.type', 'http');
79
+ span.setAttribute('type', 'task');
51
80
  span.setAttribute('execution.id', ctx.executionId);
52
81
  span.setAttribute('connection.name', task.opts.connection);
82
+ const spanContext = span.spanContext();
53
83
  try {
54
- return await http(ctx);
84
+ const newCtx = await http(ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId })));
85
+ if (supervisorEnabled) {
86
+ span.setAttribute('response.body', JSON.stringify(newCtx.data));
87
+ }
88
+ return newCtx;
55
89
  }
56
90
  catch (error) {
57
91
  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"}
@@ -11,8 +11,9 @@
11
11
  * use of this software will be governed by the Apache License, Version 2.0.
12
12
  */
13
13
  import { Observable } from 'rxjs';
14
- import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarProjectId, } from '../../../dsl/http/versori/constants.js';
15
14
  import { ScheduleTrigger } from '../../../dsl/triggers/ScheduleTrigger.js';
15
+ import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarProjectId, } from '../../../internal/constants.js';
16
+ import { sendTaskStartEvent } from '../../../internal/supervisor.js';
16
17
  function compileSchedule(ctx, trigger, signal) {
17
18
  return new Observable((subscriber) => {
18
19
  // Add HTTP endpoint for manual triggering
@@ -94,8 +95,10 @@ function compileSchedule(ctx, trigger, signal) {
94
95
  }
95
96
  ctx.cronRouter.post(`/cron/${trigger.id}`, async (req, res) => {
96
97
  await ctx.tracer.startActiveSpan(`schedule-${trigger.id}`, async (span) => {
98
+ await sendTaskStartEvent(trigger.id, span);
97
99
  span.setAttribute('task.id', trigger.id);
98
100
  span.setAttribute('task.type', 'schedule');
101
+ span.setAttribute('type', 'task');
99
102
  span.setAttribute('schedule', trigger.schedule);
100
103
  span.setAttribute('project.id', projectId);
101
104
  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"}
@@ -12,12 +12,13 @@
12
12
  */
13
13
  import cors from 'cors';
14
14
  import express from 'express';
15
+ import xmlparser from 'express-xml-bodyparser';
15
16
  import { pipeline } from 'node:stream/promises';
16
17
  import { Observable } from 'rxjs';
17
18
  import { createActIdDynamicWebhookMiddleware, createStaticWebhookMiddleware, createUserIdDynamicWebhookMiddleware, } from '../../../dsl/http/versori/webhookmiddleware.js';
18
19
  import { WebhookTrigger } from '../../../dsl/triggers/WebhookTrigger.js';
19
20
  import { envVarEnvId } from '../../../internal/constants.js';
20
- import xmlparser from 'express-xml-bodyparser';
21
+ import { sendTaskStartEvent } from '../../../internal/supervisor.js';
21
22
  const xml2jsDefaults = {
22
23
  explicitArray: false,
23
24
  normalize: false,
@@ -117,6 +118,7 @@ export const webhookCompiler = {
117
118
  ctx.webhookRouter.use(cors(corsOptions));
118
119
  }
119
120
  }
121
+ ctx.webhookRegistry.set(trigger.id, { method, path: `/${trigger.id}`, options: trigger.options });
120
122
  // endpoint for sans user because I'm not quite sure how the dynamic routing works
121
123
  ctx.webhookRouter[method](`/${trigger.id}`, createStaticWebhookMiddleware({
122
124
  id: trigger.id,
@@ -128,11 +130,16 @@ export const webhookCompiler = {
128
130
  cfgReader: ctx.configReader,
129
131
  log: ctx.log,
130
132
  }), async (req, res) => {
131
- await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
133
+ await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
134
+ await sendTaskStartEvent(trigger.id, span);
132
135
  span.setAttribute('task.id', trigger.id);
133
136
  span.setAttribute('task.type', 'webhook');
137
+ span.setAttribute('type', 'task');
134
138
  const staticActivation = res.locals.activation;
135
- const executionCtx = ctx.contextProvider.create(staticActivation, req.body, ctxOptionsFn(req, res));
139
+ let executionCtx = ctx.contextProvider.create(staticActivation, req.body, ctxOptionsFn(req, res));
140
+ const spanContext = span.spanContext();
141
+ executionCtx = executionCtx.withLogger(executionCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
142
+ executionCtx.log.info("stack", { stack: new Error().stack });
136
143
  span.setAttribute('execution.id', executionCtx.executionId);
137
144
  try {
138
145
  subscriber.next(executionCtx);
@@ -164,9 +171,11 @@ export const webhookCompiler = {
164
171
  cfgReader: ctx.configReader,
165
172
  log: ctx.log,
166
173
  }), async (req, res) => {
167
- await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
174
+ await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
175
+ await sendTaskStartEvent(trigger.id, span);
168
176
  span.setAttribute('task.id', trigger.id);
169
177
  span.setAttribute('task.type', 'webhook');
178
+ span.setAttribute('type', 'task');
170
179
  span.setAttribute('user.id', req.params.userId);
171
180
  const userId = req.params.userId;
172
181
  // Right now we only support a user having one activation
@@ -183,7 +192,9 @@ export const webhookCompiler = {
183
192
  span.end();
184
193
  return;
185
194
  }
186
- const executionCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
195
+ let executionCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
196
+ const spanContext = span.spanContext();
197
+ executionCtx = executionCtx.withLogger(executionCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
187
198
  span.setAttribute('execution.id', executionCtx.executionId);
188
199
  const errors = [];
189
200
  try {
@@ -220,9 +231,11 @@ export const webhookCompiler = {
220
231
  cfgReader: ctx.configReader,
221
232
  log: ctx.log,
222
233
  }), async (req, res) => {
223
- await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
234
+ await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
235
+ await sendTaskStartEvent(trigger.id, span);
224
236
  span.setAttribute('task.id', trigger.id);
225
237
  span.setAttribute('task.type', 'webhook');
238
+ span.setAttribute('type', 'task');
226
239
  span.setAttribute('activation.id', req.params.activationId);
227
240
  const activation = res.locals.activation;
228
241
  const activationId = activation?.id ?? req.params.activationId;
@@ -237,7 +250,9 @@ export const webhookCompiler = {
237
250
  span.end();
238
251
  return;
239
252
  }
240
- const activationCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
253
+ let activationCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
254
+ const spanContext = span.spanContext();
255
+ activationCtx = activationCtx.withLogger(activationCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
241
256
  span.setAttribute('execution.id', activationCtx.executionId);
242
257
  try {
243
258
  subscriber.next(activationCtx);
@@ -11,7 +11,7 @@
11
11
  * use of this software will be governed by the Apache License, Version 2.0.
12
12
  */
13
13
  import { createHash } from 'node:crypto';
14
- import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarOrgSlug, envVarProjectId, envVarSDKApiBaseURL, envVarVersion, } from '../dsl/http/versori/constants.js';
14
+ import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarOrgSlug, envVarProjectId, envVarSDKApiBaseURL, envVarVersion, } from '../internal/constants.js';
15
15
  export class IssueImpl {
16
16
  constructor(log) {
17
17
  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,MA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E,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versori/run",
3
- "version": "0.4.7",
3
+ "version": "0.5.0-alpha.2",
4
4
  "description": "Versori Run",
5
5
  "homepage": "https://github.com/versori/versori-run#readme",
6
6
  "repository": {
@@ -27,9 +27,11 @@
27
27
  "@connectrpc/connect": "^2.0.4",
28
28
  "@connectrpc/connect-node": "^2.0.4",
29
29
  "@opentelemetry/api": "^1.9.0",
30
+ "@opentelemetry/core": "^2.1.0",
30
31
  "@opentelemetry/exporter-trace-otlp-proto": "^0.200.0",
31
32
  "@opentelemetry/resources": "^2.0.0",
32
33
  "@opentelemetry/sdk-node": "^0.200.0",
34
+ "@opentelemetry/sdk-trace-node": "^2.0.0",
33
35
  "cors": "^2.8.5",
34
36
  "express": "^4.21.2",
35
37
  "express-xml-bodyparser": "^0.3.0",
@@ -1 +1 @@
1
- {"version":3,"file":"CredentialHolder.d.ts","sourceRoot":"","sources":["../../../../src/src/connection/internal/CredentialHolder.ts"],"names":[],"mappings":"AAeA,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED;;GAEG;AACH,qBAAa,gBAAgB,CAAC,CAAC;;gBAQvB,YAAY,EAAE,CAAC,EACf,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,EAC1B,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAOlD,GAAG,CAAC,OAAO,GAAE,OAAe,GAAG,OAAO,CAAC,CAAC,CAAC;IA0B/C,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI;CAgClC"}
1
+ {"version":3,"file":"CredentialHolder.d.ts","sourceRoot":"","sources":["../../../../src/src/connection/internal/CredentialHolder.ts"],"names":[],"mappings":"AAcA,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED;;GAEG;AACH,qBAAa,gBAAgB,CAAC,CAAC;;gBAQvB,YAAY,EAAE,CAAC,EACf,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,EAC1B,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAOlD,GAAG,CAAC,OAAO,GAAE,OAAe,GAAG,OAAO,CAAC,CAAC,CAAC;IA0B/C,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI;CAgClC"}
@@ -47,7 +47,7 @@ class CredentialHolder {
47
47
  this.refresh();
48
48
  return __classPrivateFieldGet(this, _CredentialHolder_value, "f");
49
49
  }
50
- // if this.refresh returns a rejected promise we are stuck with it until a restart.
50
+ // if this.refresh returns a rejected promise we are stuck with it until a restart.
51
51
  // the try/catch bellow just keeps on trying to refresh the token if this.#value is rejected.
52
52
  //
53
53
  // We might have to change this because if credentials has an issue we might just make that issue worse by pamming more requests
@@ -1,5 +1,9 @@
1
1
  import { FetchLike, OutboundMiddleware } from '../types.js';
2
- import { Connection } from '../../services/platform/mod.js';
2
+ export type FetchConnection = {
3
+ name: string;
4
+ id?: string;
5
+ baseUrl?: string;
6
+ };
3
7
  /**
4
8
  * FetchBuilder is used to build a fetch function which can be composed by multiple middlewares for
5
9
  * modifying the request/response and makes the implementation of {@link ConnectionFetchFactory}
@@ -8,8 +12,11 @@ import { Connection } from '../../services/platform/mod.js';
8
12
  export declare class FetchBuilder {
9
13
  #private;
10
14
  middlewares: OutboundMiddleware[];
11
- constructor(fetch: FetchLike, cnx: Connection);
15
+ constructor(fetch: FetchLike, cnx: FetchConnection);
12
16
  use(fn: OutboundMiddleware): void;
13
17
  build(): FetchLike;
18
+ buildSupervisedFetch(): FetchLike;
19
+ private supervisedFetch;
20
+ private wrapWithTracing;
14
21
  }
15
22
  //# sourceMappingURL=FetchBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FetchBuilder.d.ts","sourceRoot":"","sources":["../../../../src/src/connection/internal/FetchBuilder.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAG5D;;;;GAIG;AACH,qBAAa,YAAY;;IACrB,WAAW,EAAE,kBAAkB,EAAE,CAAC;gBAKtB,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU;IAM7C,GAAG,CAAC,EAAE,EAAE,kBAAkB;IAI1B,KAAK,IAAI,SAAS;CAWrB"}
1
+ {"version":3,"file":"FetchBuilder.d.ts","sourceRoot":"","sources":["../../../../src/src/connection/internal/FetchBuilder.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,MAAM,eAAe,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAA;AAED;;;;GAIG;AACH,qBAAa,YAAY;;IACrB,WAAW,EAAE,kBAAkB,EAAE,CAAC;gBAMtB,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe;IAalD,GAAG,CAAC,EAAE,EAAE,kBAAkB;IAI1B,KAAK,IAAI,SAAS;IAalB,oBAAoB,IAAI,SAAS;IAOjC,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,eAAe;CAyE1B"}