@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
|
@@ -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"}
|
|
@@ -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,15 +63,14 @@ 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();
|
|
70
70
|
}
|
|
71
71
|
// during testing the user can choose to use a real connection or AI mock.
|
|
72
72
|
// so in supervised mode this function is used instead of the normal build() function.
|
|
73
|
-
// and it will make the
|
|
73
|
+
// and it will make the decision on using mock or real at runtime at the cost of performance
|
|
74
74
|
supervisedFetch() {
|
|
75
75
|
return (input, init) => {
|
|
76
76
|
let fetch = (input, init) => {
|
|
@@ -81,35 +81,40 @@ 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('
|
|
100
|
-
if (init?.method) {
|
|
101
|
-
span.setAttribute('http.method', init.method);
|
|
102
|
-
}
|
|
98
|
+
span.setAttribute('isConnected', connectionId !== '');
|
|
103
99
|
try {
|
|
104
100
|
const response = await fetch(input, init);
|
|
105
101
|
if (supervisorEnabled) {
|
|
102
|
+
if (init?.method) {
|
|
103
|
+
span.setAttribute('http.method', init.method);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
span.setAttribute('http.method', 'GET');
|
|
107
|
+
}
|
|
106
108
|
// when we are in supervisor mode, we need to store the response body in the span attribute
|
|
107
109
|
// this will be shown the end-user in some UI in the future(the future is now)
|
|
108
110
|
const body = await response.clone().arrayBuffer();
|
|
109
111
|
// if response is text/* or json we store the body as a string, otherwise we store it as a base64 string
|
|
110
112
|
const contentType = response.headers.get('Content-Type');
|
|
111
113
|
span.setAttribute('response.content_type', contentType || '');
|
|
112
|
-
|
|
114
|
+
span.setAttribute('request.headers', JSON.stringify(init?.headers || {}));
|
|
115
|
+
if (contentType &&
|
|
116
|
+
(contentType.startsWith('text/') ||
|
|
117
|
+
contentType.startsWith('application/json'))) {
|
|
113
118
|
span.setAttribute('response.body', new TextDecoder().decode(body));
|
|
114
119
|
}
|
|
115
120
|
else {
|
|
@@ -63,7 +63,7 @@ export function createStaticWebhookMiddleware(opts) {
|
|
|
63
63
|
next();
|
|
64
64
|
};
|
|
65
65
|
if (opts.connName === undefined) {
|
|
66
|
-
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 });
|
|
67
67
|
return staticMiddleware;
|
|
68
68
|
}
|
|
69
69
|
// TODO(@teo): move db access to outside of the middleware??? (genuine question - not instruction)
|
|
@@ -131,7 +131,7 @@ export function createActIdDynamicWebhookMiddleware(opts) {
|
|
|
131
131
|
next();
|
|
132
132
|
};
|
|
133
133
|
if (!opts.connName) {
|
|
134
|
-
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 });
|
|
135
135
|
return staticMiddleware;
|
|
136
136
|
}
|
|
137
137
|
return async (req, res, next) => {
|
|
@@ -195,7 +195,7 @@ export function createUserIdDynamicWebhookMiddleware(opts) {
|
|
|
195
195
|
next();
|
|
196
196
|
};
|
|
197
197
|
if (!opts.connName) {
|
|
198
|
-
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 });
|
|
199
199
|
return staticMiddleware;
|
|
200
200
|
}
|
|
201
201
|
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"}
|
|
@@ -51,7 +51,6 @@ export class InternalAuth {
|
|
|
51
51
|
if (Deno.env.get(envVarInternalToken)) {
|
|
52
52
|
this.accessToken = Deno.env.get(envVarInternalToken) || '';
|
|
53
53
|
this.expiresAt = Date.now() + 365 * 24 * 60 * 60 * 1000; // expires in 1 year
|
|
54
|
-
console.log(`Using static token provided by ${envVarInternalToken}`);
|
|
55
54
|
return;
|
|
56
55
|
}
|
|
57
56
|
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();
|
|
@@ -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;AA2ClD,eAAO,MAAM,OAAO,SAEhB,CAAC;AA2BL,KAAK,cAAc,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AA0DF,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,CA0BxF;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,EAAE,CAAC,CAAC,CAAC,CAwC5B;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,25 @@
|
|
|
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
|
+
import { CatchTask } from '../dsl/tasks/CatchTask.js';
|
|
21
|
+
import { FnTask } from '../dsl/tasks/FnTask.js';
|
|
22
|
+
import { HttpTaskImpl } from '../dsl/tasks/HttpTask.js';
|
|
23
|
+
import { BackgroundTask } from '../dsl/tasks/BackgroundTask.js';
|
|
24
|
+
import { ParallelTask } from '../dsl/tasks/ParallelTask.js';
|
|
25
|
+
const supervisorURL = (function () {
|
|
16
26
|
return Deno.env.get('RUN_SUPERVISOR_URL') || '';
|
|
17
|
-
}();
|
|
18
|
-
export const enabled = function () {
|
|
27
|
+
})();
|
|
28
|
+
export const enabled = (function () {
|
|
19
29
|
return Deno.env.get('RUN_SUPERVISOR_URL') ? true : false;
|
|
20
|
-
}();
|
|
21
|
-
const flows = function () {
|
|
30
|
+
})();
|
|
31
|
+
const flows = (function () {
|
|
22
32
|
try {
|
|
23
33
|
const _cwd = Deno.cwd();
|
|
24
34
|
const flowsFile = Deno.readTextFileSync(_cwd + '/versori-flow.json');
|
|
@@ -26,8 +36,9 @@ const flows = function () {
|
|
|
26
36
|
const nodes = {};
|
|
27
37
|
for (const node of flows.nodes) {
|
|
28
38
|
nodes[node.id] = {
|
|
29
|
-
description: node
|
|
30
|
-
steps: node
|
|
39
|
+
description: node?.data?.description,
|
|
40
|
+
steps: node?.data?.steps,
|
|
41
|
+
files: node?.data?.files[0],
|
|
31
42
|
};
|
|
32
43
|
}
|
|
33
44
|
return nodes;
|
|
@@ -35,64 +46,140 @@ const flows = function () {
|
|
|
35
46
|
catch {
|
|
36
47
|
return {};
|
|
37
48
|
}
|
|
38
|
-
}();
|
|
49
|
+
})();
|
|
39
50
|
const logger = new ConsoleLogger('debug');
|
|
40
|
-
|
|
51
|
+
function getTriggerData(workflow) {
|
|
52
|
+
if (workflow.trigger instanceof WebhookTrigger) {
|
|
53
|
+
return {
|
|
54
|
+
id: workflow.trigger.id,
|
|
55
|
+
type: 'webhook',
|
|
56
|
+
method: workflow.trigger.options.method || 'post',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
else if (workflow.trigger instanceof ScheduleTrigger) {
|
|
60
|
+
return {
|
|
61
|
+
id: workflow.trigger.id,
|
|
62
|
+
type: 'schedule',
|
|
63
|
+
schedule: workflow.trigger.schedule,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
else if (workflow.trigger instanceof DurableWorkflowTrigger) {
|
|
67
|
+
return {
|
|
68
|
+
id: workflow.trigger.id,
|
|
69
|
+
type: 'durable',
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
function getTaskData(task) {
|
|
75
|
+
let taskData = [];
|
|
76
|
+
if (task instanceof ChainTask) {
|
|
77
|
+
taskData = task.tasks.map((t) => getTaskData(t)).flat();
|
|
78
|
+
}
|
|
79
|
+
else if (task instanceof CatchTask) {
|
|
80
|
+
taskData = [...getTaskData(task._base), ...getTaskData(task._errorHandler)];
|
|
81
|
+
}
|
|
82
|
+
else if (task instanceof BackgroundTask) {
|
|
83
|
+
taskData = getTaskData(task._base);
|
|
84
|
+
}
|
|
85
|
+
else if (task instanceof ParallelTask) {
|
|
86
|
+
// I'm not sure if this is correct, but I don't think there are any ParallelTasks out in the wild yet
|
|
87
|
+
taskData = [...getTaskData(task._base), ...getTaskData(task._each)];
|
|
88
|
+
}
|
|
89
|
+
else if (task instanceof FnTask) {
|
|
90
|
+
taskData.push({
|
|
91
|
+
taskId: task.id,
|
|
92
|
+
type: task[TaskType].toLowerCase(),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
else if (task instanceof HttpTaskImpl) {
|
|
96
|
+
taskData.push({
|
|
97
|
+
taskId: task.id,
|
|
98
|
+
type: task[TaskType].toLowerCase(),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
// yolo
|
|
103
|
+
taskData.push({
|
|
104
|
+
taskId: String(task.id || 'unknown'),
|
|
105
|
+
type: task[TaskType].toLowerCase(),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return taskData;
|
|
109
|
+
}
|
|
110
|
+
export async function signalReady() {
|
|
41
111
|
if (!enabled) {
|
|
42
112
|
return;
|
|
43
113
|
}
|
|
44
114
|
try {
|
|
45
|
-
await fetch(`${supervisorURL}/
|
|
46
|
-
method:
|
|
47
|
-
body: JSON.stringify(Object.fromEntries(webhooks)),
|
|
48
|
-
headers: {
|
|
49
|
-
"Content-Type": "application/json",
|
|
50
|
-
},
|
|
115
|
+
await fetch(`${supervisorURL}/ready`, {
|
|
116
|
+
method: 'POST',
|
|
51
117
|
});
|
|
52
118
|
}
|
|
53
119
|
catch (err) {
|
|
54
|
-
logger.error('Failed to
|
|
120
|
+
logger.error('Failed to signal ready to supervisor', { error: err });
|
|
55
121
|
}
|
|
56
122
|
}
|
|
57
|
-
export async function
|
|
123
|
+
export async function registerWorkflow(workflow) {
|
|
58
124
|
if (!enabled) {
|
|
59
125
|
return;
|
|
60
126
|
}
|
|
127
|
+
const triggerData = getTriggerData(workflow);
|
|
128
|
+
const tasks = getTaskData(workflow.task);
|
|
129
|
+
try {
|
|
130
|
+
if (triggerData) {
|
|
131
|
+
const data = {
|
|
132
|
+
workflowId: triggerData.id,
|
|
133
|
+
trigger: triggerData,
|
|
134
|
+
tasks,
|
|
135
|
+
};
|
|
136
|
+
await fetch(`${supervisorURL}/register-workflow`, {
|
|
137
|
+
method: 'POST',
|
|
138
|
+
body: JSON.stringify(data),
|
|
139
|
+
headers: {
|
|
140
|
+
'Content-Type': 'application/json',
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
logger.error('Failed to register workflow with supervisor', { error: err });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
export async function sendTaskStartEvent(taskId, ctx, span) {
|
|
150
|
+
if (!enabled) {
|
|
151
|
+
return ctx;
|
|
152
|
+
}
|
|
61
153
|
const data = {
|
|
62
154
|
taskId,
|
|
63
155
|
spanId: span.spanContext().spanId,
|
|
64
156
|
traceId: span.spanContext().traceId,
|
|
65
157
|
startTime: new Date().toISOString(), // assuming current time as start time
|
|
158
|
+
executionId: ctx.executionId,
|
|
159
|
+
workflowId: ctx.workflowId || '',
|
|
66
160
|
};
|
|
67
161
|
try {
|
|
68
|
-
await fetch(`${supervisorURL}/tasks/start`, {
|
|
69
|
-
method:
|
|
162
|
+
const resp = await fetch(`${supervisorURL}/tasks/start`, {
|
|
163
|
+
method: 'POST',
|
|
70
164
|
body: JSON.stringify(data),
|
|
71
165
|
headers: {
|
|
72
|
-
|
|
166
|
+
'Content-Type': 'application/json',
|
|
73
167
|
},
|
|
74
168
|
});
|
|
169
|
+
if (resp.ok) {
|
|
170
|
+
const bodyString = await resp.text();
|
|
171
|
+
if (!bodyString) {
|
|
172
|
+
return ctx;
|
|
173
|
+
}
|
|
174
|
+
// TODO: XML, CSV yada yada
|
|
175
|
+
const respData = JSON.parse(bodyString);
|
|
176
|
+
return ctx.withData(respData);
|
|
177
|
+
}
|
|
75
178
|
}
|
|
76
179
|
catch (err) {
|
|
77
180
|
logger.error('Failed to send task start event to supervisor', { error: err });
|
|
78
181
|
}
|
|
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
|
-
}
|
|
182
|
+
return ctx;
|
|
96
183
|
}
|
|
97
184
|
export async function mockAPIRequest(info, cnx, options) {
|
|
98
185
|
if (!enabled) {
|
|
@@ -101,17 +188,17 @@ export async function mockAPIRequest(info, cnx, options) {
|
|
|
101
188
|
const mockRequest = {
|
|
102
189
|
url: info.toString(),
|
|
103
190
|
payload: options?.body || '',
|
|
104
|
-
method: options?.method ||
|
|
191
|
+
method: options?.method || 'GET',
|
|
105
192
|
headers: options?.headers,
|
|
106
193
|
connection: cnx?.name,
|
|
107
194
|
connectionId: cnx?.id,
|
|
108
195
|
};
|
|
109
196
|
try {
|
|
110
197
|
const response = await fetch(`${supervisorURL}/ai/fake-fetch-call`, {
|
|
111
|
-
method:
|
|
198
|
+
method: 'POST',
|
|
112
199
|
body: JSON.stringify(mockRequest),
|
|
113
200
|
headers: {
|
|
114
|
-
|
|
201
|
+
'Content-Type': 'application/json',
|
|
115
202
|
},
|
|
116
203
|
});
|
|
117
204
|
if (!response.ok) {
|
|
@@ -139,10 +226,11 @@ function printableSpan(s) {
|
|
|
139
226
|
parentSpanContext: s.parentSpanContext,
|
|
140
227
|
spanContext: s.spanContext(),
|
|
141
228
|
};
|
|
142
|
-
const nodeDetail = flows[span.attributes['task.id']]; // I know I have coded all of those as string
|
|
229
|
+
const nodeDetail = flows[span.attributes['task.id']]; // I know I have coded all of those as string
|
|
143
230
|
if (nodeDetail) {
|
|
144
|
-
span.attributes['description'] = nodeDetail
|
|
145
|
-
span.attributes['steps'] = nodeDetail
|
|
231
|
+
span.attributes['description'] = nodeDetail?.description || '';
|
|
232
|
+
span.attributes['steps'] = nodeDetail?.steps || '';
|
|
233
|
+
span.attributes['files'] = nodeDetail?.files || '';
|
|
146
234
|
}
|
|
147
235
|
return span;
|
|
148
236
|
}
|
|
@@ -156,10 +244,10 @@ export class Fake {
|
|
|
156
244
|
const ss = spans.map(printableSpan);
|
|
157
245
|
try {
|
|
158
246
|
fetch(`${supervisorURL}/receive-spans`, {
|
|
159
|
-
method:
|
|
247
|
+
method: 'POST',
|
|
160
248
|
body: JSON.stringify({ spans: ss }),
|
|
161
249
|
headers: {
|
|
162
|
-
|
|
250
|
+
'Content-Type': 'application/json',
|
|
163
251
|
},
|
|
164
252
|
}).catch((err) => {
|
|
165
253
|
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"],"names":[],"mappings":"AAYA,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,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAuB,MAAM,kCAAkC,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,C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GxB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,kBAAkB,EAC5B,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAC3B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,eAAe,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,uBAAuB,EACxC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,YAAY,EACvB,aAAa,EAAE,QAAQ,EACvB,OAAO,CAAC,EAAE,OAAO,YAAA;WAWzB,WAAW,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgH9F,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAyDhE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAmO5B,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, 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 ?? '');
|
|
@@ -61,7 +62,7 @@ function compileCatch(compilerCtx, task) {
|
|
|
61
62
|
reason: 'error',
|
|
62
63
|
severity: 'low',
|
|
63
64
|
});
|
|
64
|
-
span.setAttribute('
|
|
65
|
+
span.setAttribute('status', 'fail');
|
|
65
66
|
span.end();
|
|
66
67
|
return errorOperator(of(ctx.withData(new ExecutionError(ctx, `${error}`, { cause: error }))));
|
|
67
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;AAoDnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
|
|
@@ -10,18 +10,18 @@
|
|
|
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 { mergeMap
|
|
13
|
+
import { mergeMap } 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
|
-
return (src) => src.pipe(
|
|
18
|
-
complete: () => compilerCtx.log.debug('fn.complete'),
|
|
19
|
-
}), mergeMap(async (ctx) => {
|
|
17
|
+
return (src) => src.pipe(mergeMap(async (ctx) => {
|
|
20
18
|
return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
|
|
19
|
+
await sendTaskStartEvent(task.id, ctx, span);
|
|
21
20
|
span.setAttribute('task.id', task.id);
|
|
22
21
|
span.setAttribute('type', 'task');
|
|
23
22
|
span.setAttribute('task.type', 'fn');
|
|
24
23
|
span.setAttribute('execution.id', ctx.executionId);
|
|
24
|
+
span.setAttribute('workflow.id', ctx.options.workflowId || 'unknown-workflow');
|
|
25
25
|
try {
|
|
26
26
|
const spanContext = span.spanContext();
|
|
27
27
|
const ctxWithLogger = ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
@@ -35,8 +35,19 @@ function compileFn(compilerCtx, task) {
|
|
|
35
35
|
if (supervisorEnabled) {
|
|
36
36
|
span.setAttribute('response.body', JSON.stringify(result.data));
|
|
37
37
|
}
|
|
38
|
+
span.setAttribute('status', 'pass');
|
|
38
39
|
return result;
|
|
39
40
|
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (error instanceof Error) {
|
|
43
|
+
span.setAttribute('status', 'fail');
|
|
44
|
+
span.recordException(error);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
span.recordException(new Error(String(error)));
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
40
51
|
finally {
|
|
41
52
|
span.end();
|
|
42
53
|
}
|
|
@@ -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;AAyHnE,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
|