@versori/run 0.5.0-alpha.2 → 0.5.0-alpha.4
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 +8 -9
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +0 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.js +3 -4
- package/esm/src/internal/supervisor.d.ts +5 -9
- package/esm/src/internal/supervisor.d.ts.map +1 -1
- package/esm/src/internal/supervisor.js +108 -48
- 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 +9 -6
- package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/fn.js +14 -1
- package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/http.js +5 -1
- 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 +9 -5
- package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/fn.js +13 -1
- package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/http.js +4 -1
- 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 +8 -9
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +0 -1
- package/script/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.js +3 -4
- package/script/src/internal/supervisor.d.ts +5 -9
- package/script/src/internal/supervisor.d.ts.map +1 -1
- package/script/src/internal/supervisor.js +109 -49
- 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 +9 -6
- package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/fn.js +13 -0
- package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/http.js +4 -0
- 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 +9 -5
- package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/fn.js +13 -1
- package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/http.js +4 -1
- 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
|
@@ -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,CAAA;AAED;;;;GAIG;AACH,qBAAa,YAAY;;IACrB,WAAW,EAAE,kBAAkB,EAAE,CAAC;gBAMtB,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe;
|
|
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;IAelD,GAAG,CAAC,EAAE,EAAE,kBAAkB;IAI1B,KAAK,IAAI,SAAS;IAYlB,oBAAoB,IAAI,SAAS;IAOjC,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,eAAe;CAyE1B"}
|
|
@@ -44,11 +44,12 @@ export class FetchBuilder {
|
|
|
44
44
|
__classPrivateFieldSet(this, _FetchBuilder_base, fetch, "f");
|
|
45
45
|
__classPrivateFieldSet(this, _FetchBuilder_cnx, cnx, "f");
|
|
46
46
|
__classPrivateFieldSet(this, _FetchBuilder_tracer, opentelemetry.trace.getTracer('fetch-builder', '1.0.0'), "f");
|
|
47
|
+
const traceMiddleware = this.wrapWithTracing.bind(this);
|
|
47
48
|
if (cnx.baseUrl) {
|
|
48
|
-
this.middlewares = [changeRequestbaseURLMiddleware(cnx)];
|
|
49
|
+
this.middlewares = [changeRequestbaseURLMiddleware(cnx), traceMiddleware];
|
|
49
50
|
}
|
|
50
51
|
else {
|
|
51
|
-
this.middlewares = [];
|
|
52
|
+
this.middlewares = [traceMiddleware];
|
|
52
53
|
}
|
|
53
54
|
this.supervisedFetch = this.supervisedFetch.bind(this);
|
|
54
55
|
}
|
|
@@ -62,8 +63,7 @@ export class FetchBuilder {
|
|
|
62
63
|
// order they were added
|
|
63
64
|
fetch = this.middlewares[i](fetch);
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
-
return this.wrapWithTracing(fetch, false);
|
|
66
|
+
return fetch;
|
|
67
67
|
}
|
|
68
68
|
buildSupervisedFetch() {
|
|
69
69
|
return this.supervisedFetch();
|
|
@@ -81,22 +81,21 @@ export class FetchBuilder {
|
|
|
81
81
|
// order they were added
|
|
82
82
|
fetch = this.middlewares[i](fetch);
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
return traced(input, init);
|
|
84
|
+
return fetch(input, init);
|
|
86
85
|
};
|
|
87
86
|
}
|
|
88
|
-
wrapWithTracing(fetch
|
|
87
|
+
wrapWithTracing(fetch) {
|
|
89
88
|
const connectionId = __classPrivateFieldGet(this, _FetchBuilder_cnx, "f")?.id || '';
|
|
90
89
|
const connectionName = __classPrivateFieldGet(this, _FetchBuilder_cnx, "f")?.name || '';
|
|
91
90
|
return (input, init) => {
|
|
92
91
|
const url = getUrl(input);
|
|
93
|
-
return __classPrivateFieldGet(this, _FetchBuilder_tracer, "f").startActiveSpan(`fetch ${
|
|
92
|
+
return __classPrivateFieldGet(this, _FetchBuilder_tracer, "f").startActiveSpan(`fetch ${connectionName}/${connectionId}`, async (span) => {
|
|
94
93
|
// Set span attributes
|
|
95
94
|
span.setAttribute('http.url', url);
|
|
96
95
|
span.setAttribute('type', 'fetch');
|
|
97
96
|
span.setAttribute('connection.id', connectionId);
|
|
98
97
|
span.setAttribute('connection.name', connectionName);
|
|
99
|
-
span.setAttribute('
|
|
98
|
+
span.setAttribute('isConnected', connectionId !== '');
|
|
100
99
|
if (init?.method) {
|
|
101
100
|
span.setAttribute('http.method', init.method);
|
|
102
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextProvider.d.ts","sourceRoot":"","sources":["../../../src/src/context/ContextProvider.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEp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
|
|
1
|
-
{"version":3,"file":"webhookmiddleware.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/webhookmiddleware.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAc,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,2BAA2B,GAAG;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,SAAS,EAAE,YAAY,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAmCF,wBAAgB,6BAA6B,CACzC,IAAI,EAAE,2BAA2B,GAClC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"webhookmiddleware.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/webhookmiddleware.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAc,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,2BAA2B,GAAG;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,SAAS,EAAE,YAAY,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAmCF,wBAAgB,6BAA6B,CACzC,IAAI,EAAE,2BAA2B,GAClC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAqGpE;AAED,wBAAgB,mCAAmC,CAC/C,IAAI,EAAE,2BAA2B,GAClC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAyEpE;AAED,wBAAgB,oCAAoC,CAChD,IAAI,EAAE,2BAA2B,GAClC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CA2FpE"}
|
|
@@ -43,7 +43,6 @@ export function createStaticWebhookMiddleware(opts) {
|
|
|
43
43
|
const staticMiddleware = async (_req, res, next) => {
|
|
44
44
|
try {
|
|
45
45
|
res.locals.activation = await getStaticActivation(opts);
|
|
46
|
-
console.log("activation", res.locals.activation);
|
|
47
46
|
}
|
|
48
47
|
catch (err) {
|
|
49
48
|
// when working in mocks users might not be connected so there might not be an activation
|
|
@@ -64,7 +63,7 @@ export function createStaticWebhookMiddleware(opts) {
|
|
|
64
63
|
next();
|
|
65
64
|
};
|
|
66
65
|
if (opts.connName === undefined) {
|
|
67
|
-
opts.log.warn(`No connection ID found for webhook, accepting any requests which is
|
|
66
|
+
opts.log.warn(`No connection ID found for webhook, accepting any requests which is insecure!`, { webhookId: opts.id });
|
|
68
67
|
return staticMiddleware;
|
|
69
68
|
}
|
|
70
69
|
// TODO(@teo): move db access to outside of the middleware??? (genuine question - not instruction)
|
|
@@ -132,7 +131,7 @@ export function createActIdDynamicWebhookMiddleware(opts) {
|
|
|
132
131
|
next();
|
|
133
132
|
};
|
|
134
133
|
if (!opts.connName) {
|
|
135
|
-
opts.log.warn(`No template ID found for webhook, accepting any requests which is
|
|
134
|
+
opts.log.warn(`No template ID found for webhook, accepting any requests which is insecure!`, { webhookId: opts.id });
|
|
136
135
|
return staticMiddleware;
|
|
137
136
|
}
|
|
138
137
|
return async (req, res, next) => {
|
|
@@ -196,7 +195,7 @@ export function createUserIdDynamicWebhookMiddleware(opts) {
|
|
|
196
195
|
next();
|
|
197
196
|
};
|
|
198
197
|
if (!opts.connName) {
|
|
199
|
-
opts.log.warn(`No template ID found for webhook, accepting any requests which is
|
|
198
|
+
opts.log.warn(`No template ID found for webhook, accepting any requests which is insecure!`, { webhookId: opts.id });
|
|
200
199
|
return staticMiddleware;
|
|
201
200
|
}
|
|
202
201
|
return async (req, res, next) => {
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import { ExportResult } from '@opentelemetry/core';
|
|
2
2
|
import { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-node';
|
|
3
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();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../../../src/src/internal/supervisor.ts"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../../../src/src/internal/supervisor.ts"],"names":[],"mappings":"AAaA,OAAO,EACH,YAAY,EAIf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAuClD,eAAO,MAAM,OAAO,SAEhB,CAAC;AA0BL,KAAK,cAAc,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAqCF,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAYjD;AAED,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCxF;AAED,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,CAAC,EACzC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EACtB,IAAI,EAAE,IAAI,GACX,OAAO,CAAC,WAAW,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAyC3B;AAED,wBAAsB,cAAc,CAChC,IAAI,EAAE,WAAW,GAAG,GAAG,EACvB,GAAG,CAAC,EAAE,cAAc,EACpB,OAAO,CAAC,EAAE,WAAW,GACtB,OAAO,CAAC,QAAQ,CAAC,CAoCnB;AA0BD,qBAAa,IAAK,YAAW,YAAY;;IAOrC,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,GAAG,IAAI;IAmBnF,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
|
|
@@ -10,15 +10,20 @@
|
|
|
10
10
|
* As of the Change Date, in accordance with the Business Source License,
|
|
11
11
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
12
|
*/
|
|
13
|
-
import { ExportResultCode, hrTimeToMilliseconds, hrTimeToTimeStamp } from '@opentelemetry/core';
|
|
13
|
+
import { ExportResultCode, hrTimeToMilliseconds, hrTimeToTimeStamp, } from '@opentelemetry/core';
|
|
14
14
|
import { ConsoleLogger } from '../observability/logging/ConsoleLogger.js';
|
|
15
|
-
|
|
15
|
+
import { ChainTask } from '../dsl/tasks/ChainTask.js';
|
|
16
|
+
import { ScheduleTrigger } from '../dsl/triggers/ScheduleTrigger.js';
|
|
17
|
+
import { WebhookTrigger } from '../dsl/triggers/WebhookTrigger.js';
|
|
18
|
+
import { DurableWorkflowTrigger } from '../dsl/triggers/DurableTrigger.js';
|
|
19
|
+
import { TaskType } from '../dsl/Task.js';
|
|
20
|
+
const supervisorURL = (function () {
|
|
16
21
|
return Deno.env.get('RUN_SUPERVISOR_URL') || '';
|
|
17
|
-
}();
|
|
18
|
-
export const enabled = function () {
|
|
22
|
+
})();
|
|
23
|
+
export const enabled = (function () {
|
|
19
24
|
return Deno.env.get('RUN_SUPERVISOR_URL') ? true : false;
|
|
20
|
-
}();
|
|
21
|
-
const flows = function () {
|
|
25
|
+
})();
|
|
26
|
+
const flows = (function () {
|
|
22
27
|
try {
|
|
23
28
|
const _cwd = Deno.cwd();
|
|
24
29
|
const flowsFile = Deno.readTextFileSync(_cwd + '/versori-flow.json');
|
|
@@ -26,73 +31,127 @@ const flows = function () {
|
|
|
26
31
|
const nodes = {};
|
|
27
32
|
for (const node of flows.nodes) {
|
|
28
33
|
nodes[node.id] = {
|
|
29
|
-
description: node
|
|
30
|
-
steps: node
|
|
34
|
+
description: node?.data?.description,
|
|
35
|
+
steps: node?.data?.steps,
|
|
36
|
+
files: node?.data?.files[0]
|
|
31
37
|
};
|
|
32
38
|
}
|
|
33
39
|
return nodes;
|
|
34
40
|
}
|
|
35
|
-
catch
|
|
41
|
+
catch {
|
|
36
42
|
return {};
|
|
37
43
|
}
|
|
38
|
-
}();
|
|
44
|
+
})();
|
|
39
45
|
const logger = new ConsoleLogger('debug');
|
|
40
|
-
|
|
46
|
+
function getTriggerData(workflow) {
|
|
47
|
+
if (workflow.trigger instanceof WebhookTrigger) {
|
|
48
|
+
return {
|
|
49
|
+
id: workflow.trigger.id,
|
|
50
|
+
type: 'webhook',
|
|
51
|
+
method: workflow.trigger.options.method || 'post',
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
else if (workflow.trigger instanceof ScheduleTrigger) {
|
|
55
|
+
return {
|
|
56
|
+
id: workflow.trigger.id,
|
|
57
|
+
type: 'schedule',
|
|
58
|
+
schedule: workflow.trigger.schedule,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
else if (workflow.trigger instanceof DurableWorkflowTrigger) {
|
|
62
|
+
return {
|
|
63
|
+
id: workflow.trigger.id,
|
|
64
|
+
type: 'durable',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
function getTaskData(task) {
|
|
70
|
+
const rawType = task[TaskType] ?? 'unknown';
|
|
71
|
+
const type = String(rawType).toLowerCase();
|
|
72
|
+
const taskId = String(task.id) ?? 'unknown';
|
|
73
|
+
return {
|
|
74
|
+
taskId,
|
|
75
|
+
type,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export async function signalReady() {
|
|
41
79
|
if (!enabled) {
|
|
42
80
|
return;
|
|
43
81
|
}
|
|
44
82
|
try {
|
|
45
|
-
await fetch(`${supervisorURL}/
|
|
46
|
-
method:
|
|
47
|
-
body: JSON.stringify(Object.fromEntries(webhooks)),
|
|
48
|
-
headers: {
|
|
49
|
-
"Content-Type": "application/json",
|
|
50
|
-
},
|
|
83
|
+
await fetch(`${supervisorURL}/ready`, {
|
|
84
|
+
method: 'POST',
|
|
51
85
|
});
|
|
52
86
|
}
|
|
53
87
|
catch (err) {
|
|
54
|
-
logger.error('Failed to
|
|
88
|
+
logger.error('Failed to signal ready to supervisor', { error: err });
|
|
55
89
|
}
|
|
56
90
|
}
|
|
57
|
-
export async function
|
|
91
|
+
export async function registerWorkflow(workflow) {
|
|
58
92
|
if (!enabled) {
|
|
59
93
|
return;
|
|
60
94
|
}
|
|
95
|
+
if (workflow.task instanceof ChainTask) {
|
|
96
|
+
const triggerData = getTriggerData(workflow);
|
|
97
|
+
if (!triggerData) {
|
|
98
|
+
logger.error('Unable to determine trigger data for workflow');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const tasks = workflow.task.tasks.map((t) => getTaskData(t));
|
|
102
|
+
const data = {
|
|
103
|
+
workflowId: triggerData.id,
|
|
104
|
+
trigger: triggerData,
|
|
105
|
+
tasks,
|
|
106
|
+
};
|
|
107
|
+
try {
|
|
108
|
+
await fetch(`${supervisorURL}/register-workflow`, {
|
|
109
|
+
method: 'POST',
|
|
110
|
+
body: JSON.stringify(data),
|
|
111
|
+
headers: {
|
|
112
|
+
'Content-Type': 'application/json',
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
logger.error('Failed to register workflow with supervisor', { error: err });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export async function sendTaskStartEvent(taskId, ctx, span) {
|
|
122
|
+
if (!enabled) {
|
|
123
|
+
return ctx;
|
|
124
|
+
}
|
|
61
125
|
const data = {
|
|
62
126
|
taskId,
|
|
63
127
|
spanId: span.spanContext().spanId,
|
|
64
128
|
traceId: span.spanContext().traceId,
|
|
65
129
|
startTime: new Date().toISOString(), // assuming current time as start time
|
|
130
|
+
executionId: ctx.executionId,
|
|
131
|
+
workflowId: ctx.workflowId || '',
|
|
66
132
|
};
|
|
67
133
|
try {
|
|
68
|
-
await fetch(`${supervisorURL}/tasks/start`, {
|
|
69
|
-
method:
|
|
134
|
+
const resp = await fetch(`${supervisorURL}/tasks/start`, {
|
|
135
|
+
method: 'POST',
|
|
70
136
|
body: JSON.stringify(data),
|
|
71
137
|
headers: {
|
|
72
|
-
|
|
138
|
+
'Content-Type': 'application/json',
|
|
73
139
|
},
|
|
74
140
|
});
|
|
141
|
+
if (resp.ok) {
|
|
142
|
+
const bodyString = await resp.text();
|
|
143
|
+
if (!bodyString) {
|
|
144
|
+
return ctx;
|
|
145
|
+
}
|
|
146
|
+
// TODO: XML, CSV yada yada
|
|
147
|
+
const respData = JSON.parse(bodyString);
|
|
148
|
+
return ctx.withData(respData);
|
|
149
|
+
}
|
|
75
150
|
}
|
|
76
151
|
catch (err) {
|
|
77
152
|
logger.error('Failed to send task start event to supervisor', { error: err });
|
|
78
153
|
}
|
|
79
|
-
|
|
80
|
-
export async function registerCrons(crons) {
|
|
81
|
-
if (!enabled) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
await fetch(`${supervisorURL}/register-schedulers`, {
|
|
86
|
-
method: "POST",
|
|
87
|
-
body: JSON.stringify(Object.fromEntries(crons)),
|
|
88
|
-
headers: {
|
|
89
|
-
"Content-Type": "application/json",
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
catch (err) {
|
|
94
|
-
logger.error('Failed to register crons with supervisor', { error: err });
|
|
95
|
-
}
|
|
154
|
+
return ctx;
|
|
96
155
|
}
|
|
97
156
|
export async function mockAPIRequest(info, cnx, options) {
|
|
98
157
|
if (!enabled) {
|
|
@@ -101,17 +160,17 @@ export async function mockAPIRequest(info, cnx, options) {
|
|
|
101
160
|
const mockRequest = {
|
|
102
161
|
url: info.toString(),
|
|
103
162
|
payload: options?.body || '',
|
|
104
|
-
method: options?.method ||
|
|
163
|
+
method: options?.method || 'GET',
|
|
105
164
|
headers: options?.headers,
|
|
106
165
|
connection: cnx?.name,
|
|
107
166
|
connectionId: cnx?.id,
|
|
108
167
|
};
|
|
109
168
|
try {
|
|
110
169
|
const response = await fetch(`${supervisorURL}/ai/fake-fetch-call`, {
|
|
111
|
-
method:
|
|
170
|
+
method: 'POST',
|
|
112
171
|
body: JSON.stringify(mockRequest),
|
|
113
172
|
headers: {
|
|
114
|
-
|
|
173
|
+
'Content-Type': 'application/json',
|
|
115
174
|
},
|
|
116
175
|
});
|
|
117
176
|
if (!response.ok) {
|
|
@@ -127,7 +186,7 @@ export async function mockAPIRequest(info, cnx, options) {
|
|
|
127
186
|
}
|
|
128
187
|
}
|
|
129
188
|
function printableSpan(s) {
|
|
130
|
-
|
|
189
|
+
const span = {
|
|
131
190
|
name: s.name,
|
|
132
191
|
startTime: hrTimeToTimeStamp(s.startTime),
|
|
133
192
|
endTime: hrTimeToTimeStamp(s.endTime),
|
|
@@ -139,10 +198,11 @@ function printableSpan(s) {
|
|
|
139
198
|
parentSpanContext: s.parentSpanContext,
|
|
140
199
|
spanContext: s.spanContext(),
|
|
141
200
|
};
|
|
142
|
-
const nodeDetail = flows[span.attributes['task.id']]; // I know I have coded all of those as string
|
|
201
|
+
const nodeDetail = flows[span.attributes['task.id']]; // I know I have coded all of those as string
|
|
143
202
|
if (nodeDetail) {
|
|
144
|
-
span.attributes['description'] = nodeDetail
|
|
145
|
-
span.attributes['steps'] = nodeDetail
|
|
203
|
+
span.attributes['description'] = nodeDetail?.description || '';
|
|
204
|
+
span.attributes['steps'] = nodeDetail?.steps || '';
|
|
205
|
+
span.attributes['files'] = nodeDetail?.files || '';
|
|
146
206
|
}
|
|
147
207
|
return span;
|
|
148
208
|
}
|
|
@@ -156,10 +216,10 @@ export class Fake {
|
|
|
156
216
|
const ss = spans.map(printableSpan);
|
|
157
217
|
try {
|
|
158
218
|
fetch(`${supervisorURL}/receive-spans`, {
|
|
159
|
-
method:
|
|
219
|
+
method: 'POST',
|
|
160
220
|
body: JSON.stringify({ spans: ss }),
|
|
161
221
|
headers: {
|
|
162
|
-
|
|
222
|
+
'Content-Type': 'application/json',
|
|
163
223
|
},
|
|
164
224
|
}).catch((err) => {
|
|
165
225
|
logger.error('Failed to send spans to supervisor', { error: err });
|
|
@@ -95,6 +95,7 @@ export declare class DurableInterpreter {
|
|
|
95
95
|
private cronServer?;
|
|
96
96
|
private shutdownServer?;
|
|
97
97
|
private isShuttingDown;
|
|
98
|
+
private wfRegistration;
|
|
98
99
|
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, webhookRegistry: WebhookRegistry, platformApi: PlatformApi, cnxFetchFactory: DirectConnectionFactory, cronProvider: CronProvider, tracer: Tracer, issue: IssueAPI, cfgReader: ConfigReader, queueProvider: QueueAPI, otelSDK?: NodeSDK | undefined);
|
|
99
100
|
static newInstance(options?: DurableInterpreterOptions): Promise<DurableInterpreter>;
|
|
100
101
|
register<O>(workflow: Workflow<O>, options?: DurableInterpreterOptions): Registration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DurableInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/DurableInterpreter.ts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/versori/cronapi.js';
|
|
24
24
|
import { WorkflowImpl } from '../../dsl/Workflow.js';
|
|
25
25
|
import { envCronPort, envPort, envReadyCheckURL, envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarSDKApiBaseURL, 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 { SDKKeyValueProvider } from '../../kv/sdk/SDKKeyValueProvider.js';
|
|
@@ -183,6 +183,13 @@ export class DurableInterpreter {
|
|
|
183
183
|
writable: true,
|
|
184
184
|
value: false
|
|
185
185
|
});
|
|
186
|
+
// Workflow registration promises only used when supervisor is enabled
|
|
187
|
+
Object.defineProperty(this, "wfRegistration", {
|
|
188
|
+
enumerable: true,
|
|
189
|
+
configurable: true,
|
|
190
|
+
writable: true,
|
|
191
|
+
value: []
|
|
192
|
+
});
|
|
186
193
|
if (typeof this.log === 'undefined') {
|
|
187
194
|
// this captures the old way of instantiating the DurableInterpreter and provides an
|
|
188
195
|
// error message back to the user to let them know they should use the new way.
|
|
@@ -286,6 +293,9 @@ export class DurableInterpreter {
|
|
|
286
293
|
},
|
|
287
294
|
};
|
|
288
295
|
this.registeredWorkflows.push(registration);
|
|
296
|
+
if (supervisorEnabled) {
|
|
297
|
+
this.wfRegistration.push(registerWorkflow(workflow));
|
|
298
|
+
}
|
|
289
299
|
return registration;
|
|
290
300
|
}
|
|
291
301
|
async start() {
|
|
@@ -318,6 +328,7 @@ export class DurableInterpreter {
|
|
|
318
328
|
span.setAttribute('error.message', err instanceof Error ? err.toString() : err);
|
|
319
329
|
span.setAttribute('execution.id', ctx.executionId);
|
|
320
330
|
span.setAttribute('result', 'fail');
|
|
331
|
+
span.setAttribute('workflow.id', ctx.workflowId || 'unknown-workflow');
|
|
321
332
|
span.end();
|
|
322
333
|
});
|
|
323
334
|
try {
|
|
@@ -342,6 +353,7 @@ export class DurableInterpreter {
|
|
|
342
353
|
this.tracer.startActiveSpan('done', (span) => {
|
|
343
354
|
span.setAttribute('execution.id', ctx.executionId);
|
|
344
355
|
span.setAttribute('result', 'pass');
|
|
356
|
+
span.setAttribute('workflow.id', ctx.workflowId || 'unknown-workflow');
|
|
345
357
|
span.end();
|
|
346
358
|
});
|
|
347
359
|
try {
|
|
@@ -391,9 +403,6 @@ export class DurableInterpreter {
|
|
|
391
403
|
});
|
|
392
404
|
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
393
405
|
}
|
|
394
|
-
// register with supervisor
|
|
395
|
-
await registerCrons(this.cronRegistry);
|
|
396
|
-
await registerWebhooks(this.webhookRegistry);
|
|
397
406
|
this.webhookServer = webhookApp.listen(port, () => {
|
|
398
407
|
this.log.info(`Express server listening on port ${port}`);
|
|
399
408
|
});
|
|
@@ -430,6 +439,10 @@ export class DurableInterpreter {
|
|
|
430
439
|
}
|
|
431
440
|
};
|
|
432
441
|
Deno.addSignalListener('SIGINT', this.shutdownServer);
|
|
442
|
+
if (supervisorEnabled) {
|
|
443
|
+
await Promise.all(this.wfRegistration);
|
|
444
|
+
await signalReady();
|
|
445
|
+
}
|
|
433
446
|
return new Promise((resolve) => {
|
|
434
447
|
let serversClosed = 0;
|
|
435
448
|
const totalServers = [this.webhookServer, this.cronServer].filter(Boolean).length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/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/durable/compilers/catch.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAuFnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
|
|
@@ -24,6 +24,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
24
24
|
span.setAttribute('task.type', 'catch');
|
|
25
25
|
span.setAttribute('type', 'task');
|
|
26
26
|
if (error instanceof Error) {
|
|
27
|
+
span.setAttribute('status', 'fail');
|
|
27
28
|
span.recordException(error);
|
|
28
29
|
span.setAttribute('error.message', error.message);
|
|
29
30
|
span.setAttribute('error.stack', error.stack ?? '');
|
|
@@ -36,9 +37,10 @@ function compileCatch(compilerCtx, task) {
|
|
|
36
37
|
annotations: {
|
|
37
38
|
'error': error.message,
|
|
38
39
|
'stack': error.stack || '',
|
|
39
|
-
'workflowId': ctx.options.workflowId || ctx.workflowId ||
|
|
40
|
-
'',
|
|
40
|
+
'workflowId': ctx.options.workflowId || ctx.workflowId || '',
|
|
41
41
|
'executionId': ctx.executionId,
|
|
42
|
+
'activationId': ctx.activation.id,
|
|
43
|
+
'activationExternalId': ctx.activation?.user.externalId,
|
|
42
44
|
},
|
|
43
45
|
reason: 'error',
|
|
44
46
|
severity: 'high',
|
|
@@ -50,16 +52,17 @@ function compileCatch(compilerCtx, task) {
|
|
|
50
52
|
});
|
|
51
53
|
compilerCtx.issueProvider.submitIssue({
|
|
52
54
|
annotations: {
|
|
53
|
-
'error': error.message
|
|
55
|
+
'error': error.message,
|
|
54
56
|
'stack': error.stack || '',
|
|
55
|
-
'workflowId': ctx.options.workflowId || ctx.workflowId ||
|
|
56
|
-
'',
|
|
57
|
+
'workflowId': ctx.options.workflowId || ctx.workflowId || '',
|
|
57
58
|
'executionId': ctx.executionId,
|
|
59
|
+
'activationId': ctx.activation.id,
|
|
60
|
+
'activationExternalId': ctx.activation?.user.externalId,
|
|
58
61
|
},
|
|
59
62
|
reason: 'error',
|
|
60
63
|
severity: 'low',
|
|
61
64
|
});
|
|
62
|
-
span.setAttribute('
|
|
65
|
+
span.setAttribute('status', 'fail');
|
|
63
66
|
span.end();
|
|
64
67
|
return errorOperator(of(ctx.withData(new ExecutionError(ctx, `${error}`, { cause: error }))));
|
|
65
68
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/fn.ts"],"names":[],"mappings":"AA+BA,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/durable/compilers/fn.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAuDnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
|
|
@@ -12,16 +12,18 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { mergeMap, tap } from 'rxjs';
|
|
14
14
|
import { FnTask } from '../../../dsl/tasks/FnTask.js';
|
|
15
|
-
import { enabled as supervisorEnabled } from '../../../internal/supervisor.js';
|
|
15
|
+
import { sendTaskStartEvent, enabled as supervisorEnabled } from '../../../internal/supervisor.js';
|
|
16
16
|
function compileFn(compilerCtx, task) {
|
|
17
17
|
return (src) => src.pipe(tap({
|
|
18
18
|
complete: () => compilerCtx.log.debug('fn.complete'),
|
|
19
19
|
}), mergeMap(async (ctx) => {
|
|
20
20
|
return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
|
|
21
|
+
await sendTaskStartEvent(task.id, span);
|
|
21
22
|
span.setAttribute('task.id', task.id);
|
|
22
23
|
span.setAttribute('type', 'task');
|
|
23
24
|
span.setAttribute('task.type', 'fn');
|
|
24
25
|
span.setAttribute('execution.id', ctx.executionId);
|
|
26
|
+
span.setAttribute('workflow.id', ctx.options.workflowId || 'unknown-workflow');
|
|
25
27
|
try {
|
|
26
28
|
const spanContext = span.spanContext();
|
|
27
29
|
const ctxWithLogger = ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
@@ -35,8 +37,19 @@ function compileFn(compilerCtx, task) {
|
|
|
35
37
|
if (supervisorEnabled) {
|
|
36
38
|
span.setAttribute('response.body', JSON.stringify(result.data));
|
|
37
39
|
}
|
|
40
|
+
span.setAttribute('status', 'pass');
|
|
38
41
|
return result;
|
|
39
42
|
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (error instanceof Error) {
|
|
45
|
+
span.setAttribute('status', 'fail');
|
|
46
|
+
span.recordException(error);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
span.recordException(new Error(String(error)));
|
|
50
|
+
}
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
40
53
|
finally {
|
|
41
54
|
span.end();
|
|
42
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/http.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAG/E,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/http.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAG/E,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA4HnE,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
|
|
@@ -16,7 +16,7 @@ import { DynamicFetchFactory } from '../../../connection/DynamicFetchFactory.js'
|
|
|
16
16
|
import { FetchBuilder } from '../../../connection/internal/FetchBuilder.js';
|
|
17
17
|
import { StaticFetchFactory } from '../../../connection/StaticFetchFactory.js';
|
|
18
18
|
import { HttpContextImpl, HttpTaskImpl } from '../../../dsl/tasks/HttpTask.js';
|
|
19
|
-
import { enabled as supervisorEnabled } from '../../../internal/supervisor.js';
|
|
19
|
+
import { sendTaskStartEvent, enabled as supervisorEnabled } from '../../../internal/supervisor.js';
|
|
20
20
|
function compileHttp(compilerCtx, task) {
|
|
21
21
|
const cnxMap = compilerCtx.configReader.getCnxMapping(task.opts.connection);
|
|
22
22
|
let fetchFactory;
|
|
@@ -73,21 +73,25 @@ function compileHttp(compilerCtx, task) {
|
|
|
73
73
|
complete: () => compilerCtx.log.debug('http.complete'),
|
|
74
74
|
}), mergeMap((ctx) => {
|
|
75
75
|
return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
|
|
76
|
+
await sendTaskStartEvent(task.id, span);
|
|
76
77
|
span.setAttribute('task.id', task.id);
|
|
77
78
|
span.setAttribute('task.type', 'http');
|
|
78
79
|
span.setAttribute('type', 'task');
|
|
79
80
|
span.setAttribute('execution.id', ctx.executionId);
|
|
80
81
|
span.setAttribute('connection.name', task.opts.connection);
|
|
82
|
+
span.setAttribute('workflow.id', ctx.options.workflowId || 'unknown-workflow');
|
|
81
83
|
const spanContext = span.spanContext();
|
|
82
84
|
try {
|
|
83
85
|
const result = await http(ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId })));
|
|
84
86
|
if (supervisorEnabled) {
|
|
85
87
|
span.setAttribute('response.body', JSON.stringify(result.data));
|
|
86
88
|
}
|
|
89
|
+
span.setAttribute('status', 'pass');
|
|
87
90
|
return result;
|
|
88
91
|
}
|
|
89
92
|
catch (error) {
|
|
90
93
|
if (error instanceof Error) {
|
|
94
|
+
span.setAttribute('status', 'fail');
|
|
91
95
|
span.recordException(error);
|
|
92
96
|
}
|
|
93
97
|
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"}
|