@versori/run 0.5.0-alpha.3 → 0.5.0-alpha.5
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.
- package/esm/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/esm/src/connection/internal/FetchBuilder.js +19 -14
- package/esm/src/dsl/http/versori/webhookmiddleware.js +3 -3
- package/esm/src/internal/InternalAuth.d.ts.map +1 -1
- package/esm/src/internal/InternalAuth.js +0 -1
- package/esm/src/internal/supervisor.d.ts +6 -10
- package/esm/src/internal/supervisor.d.ts.map +1 -1
- package/esm/src/internal/supervisor.js +134 -46
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts +1 -0
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/durable/DurableInterpreter.js +17 -4
- package/esm/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/catch.js +2 -1
- package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/fn.js +16 -5
- package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/http.js +6 -5
- package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/schedule.js +2 -2
- package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/webhook.js +5 -2
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +1 -0
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +17 -4
- package/esm/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.js +2 -0
- package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/fn.js +15 -5
- package/esm/src/interpreter/memory/compilers/http.js +5 -5
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.js +4 -3
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +11 -6
- package/esm/src/issues/Issues.d.ts.map +1 -1
- package/esm/src/issues/Issues.js +5 -0
- package/package.json +1 -1
- package/script/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/script/src/connection/internal/FetchBuilder.js +19 -14
- package/script/src/dsl/http/versori/webhookmiddleware.js +3 -3
- package/script/src/internal/InternalAuth.d.ts.map +1 -1
- package/script/src/internal/InternalAuth.js +0 -1
- package/script/src/internal/supervisor.d.ts +6 -10
- package/script/src/internal/supervisor.d.ts.map +1 -1
- package/script/src/internal/supervisor.js +135 -47
- package/script/src/interpreter/durable/DurableInterpreter.d.ts +1 -0
- package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/durable/DurableInterpreter.js +16 -3
- package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/catch.js +2 -1
- package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/fn.js +14 -3
- package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/http.js +5 -4
- package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/schedule.js +2 -2
- package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/webhook.js +5 -2
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +1 -0
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +16 -3
- package/script/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.js +2 -0
- package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/fn.js +14 -4
- package/script/src/interpreter/memory/compilers/http.js +5 -5
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.js +4 -3
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +11 -6
- package/script/src/issues/Issues.d.ts.map +1 -1
- package/script/src/issues/Issues.js +5 -0
|
@@ -11,12 +11,11 @@
|
|
|
11
11
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
12
|
*/
|
|
13
13
|
import { mergeMap } from 'rxjs';
|
|
14
|
-
import { tap } from 'rxjs/operators';
|
|
15
14
|
import { DynamicFetchFactory } from '../../../connection/DynamicFetchFactory.js';
|
|
16
15
|
import { FetchBuilder } from '../../../connection/internal/FetchBuilder.js';
|
|
17
16
|
import { StaticFetchFactory } from '../../../connection/StaticFetchFactory.js';
|
|
18
17
|
import { HttpContextImpl, HttpTaskImpl } from '../../../dsl/tasks/HttpTask.js';
|
|
19
|
-
import { enabled as supervisorEnabled } from '../../../internal/supervisor.js';
|
|
18
|
+
import { sendTaskStartEvent, enabled as supervisorEnabled } from '../../../internal/supervisor.js';
|
|
20
19
|
function compileHttp(compilerCtx, task) {
|
|
21
20
|
const cnxMap = compilerCtx.configReader.getCnxMapping(task.opts.connection);
|
|
22
21
|
let fetchFactory;
|
|
@@ -69,25 +68,27 @@ function compileHttp(compilerCtx, task) {
|
|
|
69
68
|
const result = await task.fn(httpContext);
|
|
70
69
|
return ctx.withData(result);
|
|
71
70
|
}
|
|
72
|
-
return (src) => src.pipe(
|
|
73
|
-
complete: () => compilerCtx.log.debug('http.complete'),
|
|
74
|
-
}), mergeMap((ctx) => {
|
|
71
|
+
return (src) => src.pipe(mergeMap((ctx) => {
|
|
75
72
|
return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
|
|
73
|
+
await sendTaskStartEvent(task.id, ctx, span);
|
|
76
74
|
span.setAttribute('task.id', task.id);
|
|
77
75
|
span.setAttribute('task.type', 'http');
|
|
78
76
|
span.setAttribute('type', 'task');
|
|
79
77
|
span.setAttribute('execution.id', ctx.executionId);
|
|
80
78
|
span.setAttribute('connection.name', task.opts.connection);
|
|
79
|
+
span.setAttribute('workflow.id', ctx.options.workflowId || 'unknown-workflow');
|
|
81
80
|
const spanContext = span.spanContext();
|
|
82
81
|
try {
|
|
83
82
|
const result = await http(ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId })));
|
|
84
83
|
if (supervisorEnabled) {
|
|
85
84
|
span.setAttribute('response.body', JSON.stringify(result.data));
|
|
86
85
|
}
|
|
86
|
+
span.setAttribute('status', 'pass');
|
|
87
87
|
return result;
|
|
88
88
|
}
|
|
89
89
|
catch (error) {
|
|
90
90
|
if (error instanceof Error) {
|
|
91
|
+
span.setAttribute('status', 'fail');
|
|
91
92
|
span.recordException(error);
|
|
92
93
|
}
|
|
93
94
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/schedule.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAQzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/schedule.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAQzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAqJ7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
|
|
@@ -52,7 +52,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
52
52
|
});
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
const executionCtx = ctx.contextProvider.create(activation[0], {});
|
|
55
|
+
const executionCtx = ctx.contextProvider.create(activation[0], {}, { workflowId: trigger.id });
|
|
56
56
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
57
57
|
try {
|
|
58
58
|
subscriber.next(executionCtx);
|
|
@@ -84,7 +84,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
activations.forEach((activation) => {
|
|
87
|
-
const executionCtx = ctx.contextProvider.create(activation, {});
|
|
87
|
+
const executionCtx = ctx.contextProvider.create(activation, {}, { workflowId: trigger.id });
|
|
88
88
|
try {
|
|
89
89
|
subscriber.next(executionCtx);
|
|
90
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/webhook.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/webhook.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CA2TxE,CAAC"}
|
|
@@ -84,6 +84,7 @@ export const webhookCompiler = {
|
|
|
84
84
|
onError = trigger.options.response.onError;
|
|
85
85
|
}
|
|
86
86
|
const ctxOptionsFn = (req, res) => ({
|
|
87
|
+
workflowId: trigger.id,
|
|
87
88
|
onSuccess: (ctx) => {
|
|
88
89
|
if (isSync) {
|
|
89
90
|
sendResponse(res, onSuccess(ctx));
|
|
@@ -108,8 +109,10 @@ export const webhookCompiler = {
|
|
|
108
109
|
if (!ctx.webhookRouter) {
|
|
109
110
|
throw new Error('Router not available in compiler context');
|
|
110
111
|
}
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
ctx.log.info('webhook endpoint added', {
|
|
113
|
+
id: trigger.id,
|
|
114
|
+
method,
|
|
115
|
+
});
|
|
113
116
|
if (corsOptions) {
|
|
114
117
|
if (typeof corsOptions === 'boolean') {
|
|
115
118
|
ctx.webhookRouter.use(cors());
|
|
@@ -88,6 +88,7 @@ export declare class MemoryInterpreter {
|
|
|
88
88
|
private cronServer?;
|
|
89
89
|
private shutdownServer?;
|
|
90
90
|
private isShuttingDown;
|
|
91
|
+
private wfRegistration;
|
|
91
92
|
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, webhookRegistry: WebhookRegistry, cnxFactory: DirectConnectionFactory, cronProvider: CronProvider, tracer: Tracer, issuesProvider: IssueAPI, cfgReader: ConfigReader, otelSDK?: NodeSDK | undefined);
|
|
92
93
|
static newInstance(options?: MemoryInterpreterOptions): Promise<MemoryInterpreter>;
|
|
93
94
|
register<O>(workflow: Workflow<O>, options?: MemoryInterpreterOptions): Registration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"AAaA,OAAsB,EAAQ,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,EAA+B,UAAU,EAAM,YAAY,EAAO,MAAM,MAAM,CAAC;AAEtF,OAAO,EAAE,uB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,MAAM,EACrB,UAAU,EAAE,MAAM,EAC3B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,eAAe,EAAE,eAAe,EACvB,UAAU,EAAE,uBAAuB,EACnC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,QAAQ,EACxB,SAAS,EAAE,YAAY,EACvB,OAAO,CAAC,EAAE,OAAO,YAAA;WAWzB,WAAW,CAAC,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA8G5F,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,wBAAwB;IAwD/D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAuN5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CASxB"}
|
|
@@ -23,7 +23,7 @@ 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
25
|
import { envCronPort, envPort, envReadyCheckURL, envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion } from '../../internal/constants.js';
|
|
26
|
-
import { Fake,
|
|
26
|
+
import { Fake, registerWorkflow, signalReady, enabled as supervisorEnabled } from '../../internal/supervisor.js';
|
|
27
27
|
import { IssueImpl } from '../../issues/Issues.js';
|
|
28
28
|
import { MemoryKeyValueProvider } from '../../kv/memory/MemoryKeyValueProvider.js';
|
|
29
29
|
import { NatsKeyValueProvider } from '../../kv/nats/NatsKeyValueProvider.js';
|
|
@@ -167,6 +167,13 @@ export class MemoryInterpreter {
|
|
|
167
167
|
writable: true,
|
|
168
168
|
value: false
|
|
169
169
|
});
|
|
170
|
+
// Workflow registration promises only used when supervisor is enabled
|
|
171
|
+
Object.defineProperty(this, "wfRegistration", {
|
|
172
|
+
enumerable: true,
|
|
173
|
+
configurable: true,
|
|
174
|
+
writable: true,
|
|
175
|
+
value: []
|
|
176
|
+
});
|
|
170
177
|
if (typeof this.log === 'undefined') {
|
|
171
178
|
// this captures the old way of instantiating the MemoryInterpreter and provides an
|
|
172
179
|
// error message back to the user to let them know they should use the new way.
|
|
@@ -266,6 +273,9 @@ export class MemoryInterpreter {
|
|
|
266
273
|
},
|
|
267
274
|
};
|
|
268
275
|
this.registeredWorkflows.push(registration);
|
|
276
|
+
if (supervisorEnabled) {
|
|
277
|
+
this.wfRegistration.push(registerWorkflow(workflow));
|
|
278
|
+
}
|
|
269
279
|
return registration;
|
|
270
280
|
}
|
|
271
281
|
async start() {
|
|
@@ -298,6 +308,7 @@ export class MemoryInterpreter {
|
|
|
298
308
|
span.setAttribute('error.message', err instanceof Error ? err.toString() : err);
|
|
299
309
|
span.setAttribute('execution.id', ctx.executionId);
|
|
300
310
|
span.setAttribute('result', 'fail');
|
|
311
|
+
span.setAttribute('workflow.id', ctx.workflowId || 'unknown-workflow');
|
|
301
312
|
span.end();
|
|
302
313
|
});
|
|
303
314
|
try {
|
|
@@ -322,6 +333,7 @@ export class MemoryInterpreter {
|
|
|
322
333
|
this.tracer.startActiveSpan('done', (span) => {
|
|
323
334
|
span.setAttribute('execution.id', ctx.executionId);
|
|
324
335
|
span.setAttribute('result', 'pass');
|
|
336
|
+
span.setAttribute('workflow.id', ctx.workflowId || 'unknown-workflow');
|
|
325
337
|
span.end();
|
|
326
338
|
});
|
|
327
339
|
try {
|
|
@@ -360,9 +372,6 @@ export class MemoryInterpreter {
|
|
|
360
372
|
});
|
|
361
373
|
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
362
374
|
}
|
|
363
|
-
// register with suopervisor
|
|
364
|
-
await registerCrons(this.cronRegistry);
|
|
365
|
-
await registerWebhooks(this.webhookRegistry);
|
|
366
375
|
this.webhookServer = webhookApp.listen(port, () => {
|
|
367
376
|
this.log.info(`Express server listening on port ${port}`);
|
|
368
377
|
});
|
|
@@ -399,6 +408,10 @@ export class MemoryInterpreter {
|
|
|
399
408
|
}
|
|
400
409
|
};
|
|
401
410
|
Deno.addSignalListener('SIGINT', this.shutdownServer);
|
|
411
|
+
if (supervisorEnabled) {
|
|
412
|
+
await Promise.all(this.wfRegistration);
|
|
413
|
+
await signalReady();
|
|
414
|
+
}
|
|
402
415
|
return new Promise((resolve) => {
|
|
403
416
|
let serversClosed = 0;
|
|
404
417
|
const totalServers = [this.webhookServer, this.cronServer].filter(Boolean).length;
|
|
@@ -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;
|
|
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;AA0FnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
|
|
@@ -25,6 +25,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
25
25
|
span.setAttribute('task.type', 'catch');
|
|
26
26
|
span.setAttribute('type', 'task');
|
|
27
27
|
if (error instanceof Error) {
|
|
28
|
+
span.setAttribute('status', 'fail');
|
|
28
29
|
span.recordException(error);
|
|
29
30
|
span.setAttribute('error.message', error.message);
|
|
30
31
|
span.setAttribute('error.stack', error.stack ?? '');
|
|
@@ -62,6 +63,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
62
63
|
ctx.log.error('execution has encountered an error', {
|
|
63
64
|
error: error,
|
|
64
65
|
});
|
|
66
|
+
span.setAttribute('status', 'fail');
|
|
65
67
|
span.setAttribute('error', `${error}`);
|
|
66
68
|
span.end();
|
|
67
69
|
return errorOperator(of(ctx.withData(new ExecutionError(ctx, `${error}`, { cause: error }))));
|
|
@@ -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;AAGtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,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;AAoDnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { mergeMap
|
|
1
|
+
import { mergeMap } from 'rxjs';
|
|
2
2
|
import { FnTask } from '../../../dsl/tasks/FnTask.js';
|
|
3
3
|
import { sendTaskStartEvent, enabled as supervisorEnabled } from '../../../internal/supervisor.js';
|
|
4
4
|
function compileFn(compilerCtx, task) {
|
|
5
|
-
return (src) => src.pipe(
|
|
6
|
-
complete: () => compilerCtx.log.debug('fn.complete'),
|
|
7
|
-
}), mergeMap(async (ctx) => {
|
|
5
|
+
return (src) => src.pipe(mergeMap(async (ctx) => {
|
|
8
6
|
return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
|
|
9
|
-
await sendTaskStartEvent(task.id, span);
|
|
7
|
+
ctx = await sendTaskStartEvent(task.id, ctx, span);
|
|
10
8
|
span.setAttribute('task.id', task.id);
|
|
11
9
|
span.setAttribute('type', 'task');
|
|
12
10
|
span.setAttribute('task.type', 'fn');
|
|
13
11
|
span.setAttribute('execution.id', ctx.executionId);
|
|
12
|
+
span.setAttribute('workflow.id', ctx.options.workflowId || 'unknown-workflow');
|
|
14
13
|
try {
|
|
15
14
|
let result;
|
|
16
15
|
const spanContext = span.spanContext();
|
|
@@ -24,8 +23,19 @@ function compileFn(compilerCtx, task) {
|
|
|
24
23
|
if (supervisorEnabled) {
|
|
25
24
|
span.setAttribute('response.body', JSON.stringify(result.data));
|
|
26
25
|
}
|
|
26
|
+
span.setAttribute('status', 'pass');
|
|
27
27
|
return result;
|
|
28
28
|
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (error instanceof Error) {
|
|
31
|
+
span.setAttribute('status', 'fail');
|
|
32
|
+
span.recordException(error);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
span.recordException(new Error(String(error)));
|
|
36
|
+
}
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
29
39
|
finally {
|
|
30
40
|
span.end();
|
|
31
41
|
}
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
12
|
*/
|
|
13
13
|
import { mergeMap } from 'rxjs';
|
|
14
|
-
import { tap } from 'rxjs/operators';
|
|
15
14
|
import { DynamicFetchFactory } from '../../../connection/DynamicFetchFactory.js';
|
|
16
15
|
import { FetchBuilder } from '../../../connection/internal/FetchBuilder.js';
|
|
17
16
|
import { StaticFetchFactory } from '../../../connection/StaticFetchFactory.js';
|
|
@@ -69,26 +68,27 @@ function compileHttp(compilerCtx, task) {
|
|
|
69
68
|
const result = await task.fn(httpContext);
|
|
70
69
|
return ctx.withData(result);
|
|
71
70
|
}
|
|
72
|
-
return (src) => src.pipe(
|
|
73
|
-
complete: () => compilerCtx.log.debug('http.complete'),
|
|
74
|
-
}), mergeMap((ctx) => {
|
|
71
|
+
return (src) => src.pipe(mergeMap((ctx) => {
|
|
75
72
|
return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
|
|
76
|
-
await sendTaskStartEvent(task.id, span);
|
|
73
|
+
ctx = await sendTaskStartEvent(task.id, ctx, span);
|
|
77
74
|
span.setAttribute('task.id', task.id);
|
|
78
75
|
span.setAttribute('task.type', 'http');
|
|
79
76
|
span.setAttribute('type', 'task');
|
|
80
77
|
span.setAttribute('execution.id', ctx.executionId);
|
|
81
78
|
span.setAttribute('connection.name', task.opts.connection);
|
|
79
|
+
span.setAttribute('workflow.id', ctx.options.workflowId || 'unknown-workflow');
|
|
82
80
|
const spanContext = span.spanContext();
|
|
83
81
|
try {
|
|
84
82
|
const newCtx = await http(ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId })));
|
|
85
83
|
if (supervisorEnabled) {
|
|
86
84
|
span.setAttribute('response.body', JSON.stringify(newCtx.data));
|
|
87
85
|
}
|
|
86
|
+
span.setAttribute('status', 'pass');
|
|
88
87
|
return newCtx;
|
|
89
88
|
}
|
|
90
89
|
catch (error) {
|
|
91
90
|
if (error instanceof Error) {
|
|
91
|
+
span.setAttribute('status', 'fail');
|
|
92
92
|
span.recordException(error);
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AA+I7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
|
|
@@ -46,8 +46,9 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
46
46
|
});
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
const executionCtx = ctx.contextProvider.create(activation[0], {});
|
|
49
|
+
const executionCtx = ctx.contextProvider.create(activation[0], {}, { workflowId: trigger.id });
|
|
50
50
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
51
|
+
await sendTaskStartEvent(trigger.id, executionCtx, span);
|
|
51
52
|
try {
|
|
52
53
|
subscriber.next(executionCtx);
|
|
53
54
|
}
|
|
@@ -78,7 +79,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
78
79
|
return;
|
|
79
80
|
}
|
|
80
81
|
activations.forEach((activation) => {
|
|
81
|
-
const executionCtx = ctx.contextProvider.create(activation, {});
|
|
82
|
+
const executionCtx = ctx.contextProvider.create(activation, {}, { workflowId: trigger.id });
|
|
82
83
|
try {
|
|
83
84
|
subscriber.next(executionCtx);
|
|
84
85
|
}
|
|
@@ -95,7 +96,6 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
95
96
|
}
|
|
96
97
|
ctx.cronRouter.post(`/cron/${trigger.id}`, async (req, res) => {
|
|
97
98
|
await ctx.tracer.startActiveSpan(`schedule-${trigger.id}`, async (span) => {
|
|
98
|
-
await sendTaskStartEvent(trigger.id, span);
|
|
99
99
|
span.setAttribute('task.id', trigger.id);
|
|
100
100
|
span.setAttribute('task.type', 'schedule');
|
|
101
101
|
span.setAttribute('type', 'task');
|
|
@@ -104,6 +104,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
104
104
|
span.setAttribute('environment.id', environmentId);
|
|
105
105
|
span.setAttribute('environment.name', environmentName);
|
|
106
106
|
span.setAttribute('org.id', orgId);
|
|
107
|
+
span.setAttribute('workflow.id', trigger.id);
|
|
107
108
|
await handleSchedule(req, res, span);
|
|
108
109
|
span.end();
|
|
109
110
|
});
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAItF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CAsUxE,CAAC"}
|
|
@@ -85,6 +85,7 @@ export const webhookCompiler = {
|
|
|
85
85
|
onError = trigger.options.response.onError;
|
|
86
86
|
}
|
|
87
87
|
const ctxOptionsFn = (req, res) => ({
|
|
88
|
+
workflowId: trigger.id,
|
|
88
89
|
onSuccess: (ctx) => {
|
|
89
90
|
if (isSync) {
|
|
90
91
|
sendResponse(res, onSuccess(ctx));
|
|
@@ -108,8 +109,10 @@ export const webhookCompiler = {
|
|
|
108
109
|
if (!ctx.webhookRouter) {
|
|
109
110
|
throw new Error('Router not available in compiler context');
|
|
110
111
|
}
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
ctx.log.info('webhook endpoint added', {
|
|
113
|
+
id: trigger.id,
|
|
114
|
+
method,
|
|
115
|
+
});
|
|
113
116
|
if (corsOptions) {
|
|
114
117
|
if (typeof corsOptions === 'boolean') {
|
|
115
118
|
ctx.webhookRouter.use(cors());
|
|
@@ -131,16 +134,16 @@ export const webhookCompiler = {
|
|
|
131
134
|
log: ctx.log,
|
|
132
135
|
}), async (req, res) => {
|
|
133
136
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
|
|
134
|
-
await sendTaskStartEvent(trigger.id, span);
|
|
135
137
|
span.setAttribute('task.id', trigger.id);
|
|
138
|
+
span.setAttribute('workflow.id', trigger.id);
|
|
136
139
|
span.setAttribute('task.type', 'webhook');
|
|
137
140
|
span.setAttribute('type', 'task');
|
|
138
141
|
const staticActivation = res.locals.activation;
|
|
139
142
|
let executionCtx = ctx.contextProvider.create(staticActivation, req.body, ctxOptionsFn(req, res));
|
|
140
143
|
const spanContext = span.spanContext();
|
|
141
144
|
executionCtx = executionCtx.withLogger(executionCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
142
|
-
executionCtx.log.info("stack", { stack: new Error().stack });
|
|
143
145
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
146
|
+
await sendTaskStartEvent(trigger.id, executionCtx, span);
|
|
144
147
|
try {
|
|
145
148
|
subscriber.next(executionCtx);
|
|
146
149
|
if (isAsync) {
|
|
@@ -172,8 +175,8 @@ export const webhookCompiler = {
|
|
|
172
175
|
log: ctx.log,
|
|
173
176
|
}), async (req, res) => {
|
|
174
177
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
|
|
175
|
-
await sendTaskStartEvent(trigger.id, span);
|
|
176
178
|
span.setAttribute('task.id', trigger.id);
|
|
179
|
+
span.setAttribute('workflow.id', trigger.id);
|
|
177
180
|
span.setAttribute('task.type', 'webhook');
|
|
178
181
|
span.setAttribute('type', 'task');
|
|
179
182
|
span.setAttribute('user.id', req.params.userId);
|
|
@@ -193,6 +196,7 @@ export const webhookCompiler = {
|
|
|
193
196
|
return;
|
|
194
197
|
}
|
|
195
198
|
let executionCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
|
|
199
|
+
await sendTaskStartEvent(trigger.id, executionCtx, span);
|
|
196
200
|
const spanContext = span.spanContext();
|
|
197
201
|
executionCtx = executionCtx.withLogger(executionCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
198
202
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
@@ -232,8 +236,8 @@ export const webhookCompiler = {
|
|
|
232
236
|
log: ctx.log,
|
|
233
237
|
}), async (req, res) => {
|
|
234
238
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
|
|
235
|
-
await sendTaskStartEvent(trigger.id, span);
|
|
236
239
|
span.setAttribute('task.id', trigger.id);
|
|
240
|
+
span.setAttribute('workflow.id', trigger.id);
|
|
237
241
|
span.setAttribute('task.type', 'webhook');
|
|
238
242
|
span.setAttribute('type', 'task');
|
|
239
243
|
span.setAttribute('activation.id', req.params.activationId);
|
|
@@ -254,6 +258,7 @@ export const webhookCompiler = {
|
|
|
254
258
|
const spanContext = span.spanContext();
|
|
255
259
|
activationCtx = activationCtx.withLogger(activationCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
256
260
|
span.setAttribute('execution.id', activationCtx.executionId);
|
|
261
|
+
await sendTaskStartEvent(trigger.id, activationCtx, span);
|
|
257
262
|
try {
|
|
258
263
|
subscriber.next(activationCtx);
|
|
259
264
|
if (isAsync) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Issues.d.ts","sourceRoot":"","sources":["../../../src/src/issues/Issues.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Issues.d.ts","sourceRoot":"","sources":["../../../src/src/issues/Issues.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,MAAM,WAAW,GAAG;IACtB,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC3B,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC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AC,OAAO,CAAC,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAS;IAClC,OAAO,CAAC,GAAG,CAAS;gBAER,GAAG,EAAE,MAAM;IA2BjB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpD,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;QACtC,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;KAC3B,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;YAWX,MAAM;CAiEvB;AAED,qBAAa,UAAW,YAAW,QAAQ;IACvC,WAAW,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1C,WAAW,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE;QACnC,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;KAC3B,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CAG5B"}
|
package/esm/src/issues/Issues.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { createHash } from 'node:crypto';
|
|
14
14
|
import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarOrgSlug, envVarProjectId, envVarSDKApiBaseURL, envVarVersion, } from '../internal/constants.js';
|
|
15
|
+
import { enabled as supervisorEnabled } from '../internal/supervisor.js';
|
|
15
16
|
export class IssueImpl {
|
|
16
17
|
constructor(log) {
|
|
17
18
|
Object.defineProperty(this, "baseUrl", {
|
|
@@ -107,6 +108,10 @@ export class IssueImpl {
|
|
|
107
108
|
issue.annotations['environmentId'] = this.environmentId;
|
|
108
109
|
issue.annotations['organisationId'] = this.organisationId;
|
|
109
110
|
try {
|
|
111
|
+
if (supervisorEnabled) {
|
|
112
|
+
this.log.info('Issue to be submitted', { issue: issue });
|
|
113
|
+
return Promise.resolve(null);
|
|
114
|
+
}
|
|
110
115
|
const response = await fetch(`${this.baseUrl}/v1/issues/submit`, {
|
|
111
116
|
method: 'POST',
|
|
112
117
|
headers: {
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAAC;AAEF;;;;GAIG;AACH,qBAAa,YAAY;;IACrB,WAAW,EAAE,kBAAkB,EAAE,CAAC;gBAMtB,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe;IAelD,GAAG,CAAC,EAAE,EAAE,kBAAkB;IAI1B,KAAK,IAAI,SAAS;IAYlB,oBAAoB,IAAI,SAAS;IAOjC,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,eAAe;CAyF1B"}
|
|
@@ -70,11 +70,12 @@ class FetchBuilder {
|
|
|
70
70
|
__classPrivateFieldSet(this, _FetchBuilder_base, fetch, "f");
|
|
71
71
|
__classPrivateFieldSet(this, _FetchBuilder_cnx, cnx, "f");
|
|
72
72
|
__classPrivateFieldSet(this, _FetchBuilder_tracer, api_1.default.trace.getTracer('fetch-builder', '1.0.0'), "f");
|
|
73
|
+
const traceMiddleware = this.wrapWithTracing.bind(this);
|
|
73
74
|
if (cnx.baseUrl) {
|
|
74
|
-
this.middlewares = [changeRequestbaseURLMiddleware(cnx)];
|
|
75
|
+
this.middlewares = [changeRequestbaseURLMiddleware(cnx), traceMiddleware];
|
|
75
76
|
}
|
|
76
77
|
else {
|
|
77
|
-
this.middlewares = [];
|
|
78
|
+
this.middlewares = [traceMiddleware];
|
|
78
79
|
}
|
|
79
80
|
this.supervisedFetch = this.supervisedFetch.bind(this);
|
|
80
81
|
}
|
|
@@ -88,15 +89,14 @@ class FetchBuilder {
|
|
|
88
89
|
// order they were added
|
|
89
90
|
fetch = this.middlewares[i](fetch);
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
-
return this.wrapWithTracing(fetch, false);
|
|
92
|
+
return fetch;
|
|
93
93
|
}
|
|
94
94
|
buildSupervisedFetch() {
|
|
95
95
|
return this.supervisedFetch();
|
|
96
96
|
}
|
|
97
97
|
// during testing the user can choose to use a real connection or AI mock.
|
|
98
98
|
// so in supervised mode this function is used instead of the normal build() function.
|
|
99
|
-
// and it will make the
|
|
99
|
+
// and it will make the decision on using mock or real at runtime at the cost of performance
|
|
100
100
|
supervisedFetch() {
|
|
101
101
|
return (input, init) => {
|
|
102
102
|
let fetch = (input, init) => {
|
|
@@ -107,35 +107,40 @@ class FetchBuilder {
|
|
|
107
107
|
// order they were added
|
|
108
108
|
fetch = this.middlewares[i](fetch);
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
return traced(input, init);
|
|
110
|
+
return fetch(input, init);
|
|
112
111
|
};
|
|
113
112
|
}
|
|
114
|
-
wrapWithTracing(fetch
|
|
113
|
+
wrapWithTracing(fetch) {
|
|
115
114
|
const connectionId = __classPrivateFieldGet(this, _FetchBuilder_cnx, "f")?.id || '';
|
|
116
115
|
const connectionName = __classPrivateFieldGet(this, _FetchBuilder_cnx, "f")?.name || '';
|
|
117
116
|
return (input, init) => {
|
|
118
117
|
const url = getUrl(input);
|
|
119
|
-
return __classPrivateFieldGet(this, _FetchBuilder_tracer, "f").startActiveSpan(`fetch ${
|
|
118
|
+
return __classPrivateFieldGet(this, _FetchBuilder_tracer, "f").startActiveSpan(`fetch ${connectionName}/${connectionId}`, async (span) => {
|
|
120
119
|
// Set span attributes
|
|
121
120
|
span.setAttribute('http.url', url);
|
|
122
121
|
span.setAttribute('type', 'fetch');
|
|
123
122
|
span.setAttribute('connection.id', connectionId);
|
|
124
123
|
span.setAttribute('connection.name', connectionName);
|
|
125
|
-
span.setAttribute('
|
|
126
|
-
if (init?.method) {
|
|
127
|
-
span.setAttribute('http.method', init.method);
|
|
128
|
-
}
|
|
124
|
+
span.setAttribute('isConnected', connectionId !== '');
|
|
129
125
|
try {
|
|
130
126
|
const response = await fetch(input, init);
|
|
131
127
|
if (supervisor_js_1.enabled) {
|
|
128
|
+
if (init?.method) {
|
|
129
|
+
span.setAttribute('http.method', init.method);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
span.setAttribute('http.method', 'GET');
|
|
133
|
+
}
|
|
132
134
|
// when we are in supervisor mode, we need to store the response body in the span attribute
|
|
133
135
|
// this will be shown the end-user in some UI in the future(the future is now)
|
|
134
136
|
const body = await response.clone().arrayBuffer();
|
|
135
137
|
// if response is text/* or json we store the body as a string, otherwise we store it as a base64 string
|
|
136
138
|
const contentType = response.headers.get('Content-Type');
|
|
137
139
|
span.setAttribute('response.content_type', contentType || '');
|
|
138
|
-
|
|
140
|
+
span.setAttribute('request.headers', JSON.stringify(init?.headers || {}));
|
|
141
|
+
if (contentType &&
|
|
142
|
+
(contentType.startsWith('text/') ||
|
|
143
|
+
contentType.startsWith('application/json'))) {
|
|
139
144
|
span.setAttribute('response.body', new TextDecoder().decode(body));
|
|
140
145
|
}
|
|
141
146
|
else {
|
|
@@ -68,7 +68,7 @@ function createStaticWebhookMiddleware(opts) {
|
|
|
68
68
|
next();
|
|
69
69
|
};
|
|
70
70
|
if (opts.connName === undefined) {
|
|
71
|
-
opts.log.warn(`No connection ID found for webhook, accepting any requests which is
|
|
71
|
+
opts.log.warn(`No connection ID found for webhook, accepting any requests which is insecure!`, { webhookId: opts.id });
|
|
72
72
|
return staticMiddleware;
|
|
73
73
|
}
|
|
74
74
|
// TODO(@teo): move db access to outside of the middleware??? (genuine question - not instruction)
|
|
@@ -136,7 +136,7 @@ function createActIdDynamicWebhookMiddleware(opts) {
|
|
|
136
136
|
next();
|
|
137
137
|
};
|
|
138
138
|
if (!opts.connName) {
|
|
139
|
-
opts.log.warn(`No template ID found for webhook, accepting any requests which is
|
|
139
|
+
opts.log.warn(`No template ID found for webhook, accepting any requests which is insecure!`, { webhookId: opts.id });
|
|
140
140
|
return staticMiddleware;
|
|
141
141
|
}
|
|
142
142
|
return async (req, res, next) => {
|
|
@@ -200,7 +200,7 @@ function createUserIdDynamicWebhookMiddleware(opts) {
|
|
|
200
200
|
next();
|
|
201
201
|
};
|
|
202
202
|
if (!opts.connName) {
|
|
203
|
-
opts.log.warn(`No template ID found for webhook, accepting any requests which is
|
|
203
|
+
opts.log.warn(`No template ID found for webhook, accepting any requests which is insecure!`, { webhookId: opts.id });
|
|
204
204
|
return staticMiddleware;
|
|
205
205
|
}
|
|
206
206
|
return async (req, res, next) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalAuth.d.ts","sourceRoot":"","sources":["../../../src/src/internal/InternalAuth.ts"],"names":[],"mappings":"AAoBA,KAAK,kBAAkB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEpD,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;;
|
|
1
|
+
{"version":3,"file":"InternalAuth.d.ts","sourceRoot":"","sources":["../../../src/src/internal/InternalAuth.ts"],"names":[],"mappings":"AAoBA,KAAK,kBAAkB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEpD,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;;IAyBpB,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC;CAsBrD"}
|
|
@@ -54,7 +54,6 @@ class InternalAuth {
|
|
|
54
54
|
if (Deno.env.get(constants_js_1.envVarInternalToken)) {
|
|
55
55
|
this.accessToken = Deno.env.get(constants_js_1.envVarInternalToken) || '';
|
|
56
56
|
this.expiresAt = Date.now() + 365 * 24 * 60 * 60 * 1000; // expires in 1 year
|
|
57
|
-
console.log(`Using static token provided by ${constants_js_1.envVarInternalToken}`);
|
|
58
57
|
return;
|
|
59
58
|
}
|
|
60
59
|
if (!this.clientId || !this.clientSecret || !this.tokenEndpoint) {
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import { Span } from '@opentelemetry/api';
|
|
2
1
|
import { ExportResult } from '@opentelemetry/core';
|
|
3
2
|
import { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-node';
|
|
3
|
+
import { Span } from '@opentelemetry/api';
|
|
4
|
+
import { ContextImpl } from '../context/Context.js';
|
|
5
|
+
import { WorkflowImpl } from '../dsl/Workflow.js';
|
|
4
6
|
export declare const enabled: boolean;
|
|
5
|
-
type Webhooks = Map<string, {
|
|
6
|
-
method: string;
|
|
7
|
-
path: string;
|
|
8
|
-
options: any;
|
|
9
|
-
}>;
|
|
10
|
-
type Crons = Map<string, string>;
|
|
11
7
|
type MockConnection = {
|
|
12
8
|
name: string;
|
|
13
9
|
id?: string;
|
|
14
10
|
baseUrl?: string;
|
|
15
11
|
};
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function
|
|
12
|
+
export declare function signalReady(): Promise<void>;
|
|
13
|
+
export declare function registerWorkflow<I, O>(workflow: WorkflowImpl<I, O>): Promise<void>;
|
|
14
|
+
export declare function sendTaskStartEvent<I, O>(taskId: string, ctx: ContextImpl<I, O>, span: Span): Promise<ContextImpl<I, O>>;
|
|
19
15
|
export declare function mockAPIRequest(info: RequestInfo | URL, cnx?: MockConnection, options?: RequestInit): Promise<Response>;
|
|
20
16
|
export declare class Fake implements SpanExporter {
|
|
21
17
|
constructor();
|