@versori/run 0.3.0-veta.2 → 0.4.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/src/connection/DirectConnectionFactory.d.ts +1 -1
- package/esm/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/DirectConnectionFactory.js +6 -9
- package/esm/src/connection/StaticFetchFactory.d.ts.map +1 -1
- package/esm/src/connection/internal/CredentialHolder.d.ts.map +1 -1
- package/esm/src/connection/internal/CredentialHolder.js +11 -2
- package/esm/src/connection/internal/FetchBuilder.d.ts +3 -2
- package/esm/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/esm/src/connection/internal/FetchBuilder.js +103 -4
- package/esm/src/connection/internal/OutboundConnectionFactory.d.ts +1 -1
- package/esm/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/internal/OutboundConnectionFactory.js +2 -3
- package/esm/src/context/AsyncWorkflow.js +1 -1
- package/esm/src/context/Context.d.ts +7 -6
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +3 -13
- package/esm/src/context/ContextProvider.d.ts +1 -3
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +3 -6
- package/esm/src/dsl/Workflow.d.ts.map +1 -1
- package/esm/src/dsl/Workflow.js +2 -0
- package/esm/src/dsl/http/versori/configloader.js +1 -1
- package/esm/src/dsl/http/versori/cronapi.d.ts +2 -3
- package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/cronapi.js +14 -14
- package/esm/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.d.ts +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.js +24 -19
- package/esm/src/dsl/tasks/HttpTask.d.ts +1 -2
- package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/esm/src/dsl/tasks/HttpTask.js +0 -3
- package/esm/src/dsl/triggers/DurableTrigger.d.ts +1 -0
- package/esm/src/dsl/triggers/DurableTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.js +3 -1
- package/esm/src/internal/constants.d.ts +3 -1
- package/esm/src/internal/constants.d.ts.map +1 -1
- package/esm/src/internal/constants.js +4 -1
- package/esm/src/internal/supervisor.d.ts +21 -0
- package/esm/src/internal/supervisor.d.ts.map +1 -0
- package/esm/src/internal/supervisor.js +122 -0
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/durable/DurableInterpreter.js +62 -22
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/durable/Queue.d.ts +16 -24
- package/esm/src/interpreter/durable/Queue.d.ts.map +1 -1
- package/esm/src/interpreter/durable/Queue.js +5 -4
- package/esm/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/catch.js +3 -2
- package/esm/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/durableworkflow.js +19 -19
- package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/fn.js +17 -4
- package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/http.js +8 -2
- package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/schedule.js +2 -1
- package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/webhook.js +4 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +8 -2
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +46 -18
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.js +3 -2
- package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/fn.js +17 -4
- package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/http.js +33 -3
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.js +2 -1
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +5 -1
- package/esm/src/issues/Issues.js +1 -1
- package/esm/src/kv/sdk/SDKKeyValue.d.ts.map +1 -1
- package/esm/src/kv/sdk/SDKKeyValue.js +3 -9
- package/esm/src/services/createConnectRpcClient.d.ts +16 -0
- package/esm/src/services/createConnectRpcClient.d.ts.map +1 -0
- package/esm/src/services/createConnectRpcClient.js +63 -0
- package/package.json +3 -1
- package/script/src/connection/DirectConnectionFactory.d.ts +1 -1
- package/script/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/DirectConnectionFactory.js +5 -8
- package/script/src/connection/StaticFetchFactory.d.ts.map +1 -1
- package/script/src/connection/internal/CredentialHolder.d.ts.map +1 -1
- package/script/src/connection/internal/CredentialHolder.js +11 -2
- package/script/src/connection/internal/FetchBuilder.d.ts +3 -2
- package/script/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/script/src/connection/internal/FetchBuilder.js +126 -4
- package/script/src/connection/internal/OutboundConnectionFactory.d.ts +1 -1
- package/script/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/internal/OutboundConnectionFactory.js +2 -3
- package/script/src/context/AsyncWorkflow.js +1 -1
- package/script/src/context/Context.d.ts +7 -6
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +3 -13
- package/script/src/context/ContextProvider.d.ts +1 -3
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +3 -6
- package/script/src/dsl/Workflow.d.ts.map +1 -1
- package/script/src/dsl/Workflow.js +2 -0
- package/script/src/dsl/http/versori/configloader.js +1 -1
- package/script/src/dsl/http/versori/cronapi.d.ts +2 -3
- package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/cronapi.js +14 -14
- package/script/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.d.ts +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.js +24 -19
- package/script/src/dsl/tasks/HttpTask.d.ts +1 -2
- package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/script/src/dsl/tasks/HttpTask.js +0 -3
- package/script/src/dsl/triggers/DurableTrigger.d.ts +1 -0
- package/script/src/dsl/triggers/DurableTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.js +3 -1
- package/script/src/internal/constants.d.ts +3 -1
- package/script/src/internal/constants.d.ts.map +1 -1
- package/script/src/internal/constants.js +5 -2
- package/script/src/internal/supervisor.d.ts +21 -0
- package/script/src/internal/supervisor.d.ts.map +1 -0
- package/script/src/internal/supervisor.js +129 -0
- package/script/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
- package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/durable/DurableInterpreter.js +62 -22
- package/script/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
- package/script/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/durable/Queue.d.ts +16 -24
- package/script/src/interpreter/durable/Queue.d.ts.map +1 -1
- package/script/src/interpreter/durable/Queue.js +5 -4
- package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/catch.js +3 -2
- package/script/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/durableworkflow.js +19 -19
- package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/fn.js +17 -4
- package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/http.js +8 -2
- package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/schedule.js +2 -1
- package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/webhook.js +4 -1
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +8 -2
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +46 -18
- package/script/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
- package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.js +3 -2
- package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/fn.js +17 -4
- package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/http.js +33 -3
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.js +2 -1
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +5 -1
- package/script/src/issues/Issues.js +1 -1
- package/script/src/kv/sdk/SDKKeyValue.d.ts.map +1 -1
- package/script/src/kv/sdk/SDKKeyValue.js +3 -9
- package/script/src/services/createConnectRpcClient.d.ts +16 -0
- package/script/src/services/createConnectRpcClient.d.ts.map +1 -0
- package/script/src/services/createConnectRpcClient.js +66 -0
- package/esm/src/context/WorkflowClient.d.ts +0 -29
- package/esm/src/context/WorkflowClient.d.ts.map +0 -1
- package/esm/src/context/WorkflowClient.js +0 -95
- package/esm/src/dsl/http/versori/activation.d.ts +0 -13
- package/esm/src/dsl/http/versori/activation.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/activation.js +0 -65
- package/esm/src/dsl/http/versori/cli.d.ts +0 -2
- package/esm/src/dsl/http/versori/cli.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/cli.js +0 -20
- package/esm/src/dsl/http/versori/constants.d.ts +0 -20
- package/esm/src/dsl/http/versori/constants.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/constants.js +0 -25
- package/esm/src/dsl/http/versori/internalauth.d.ts +0 -15
- package/esm/src/dsl/http/versori/internalauth.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/internalauth.js +0 -90
- package/esm/src/dsl/http/versori/platformapi.d.ts +0 -19
- package/esm/src/dsl/http/versori/platformapi.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/platformapi.js +0 -148
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/proxyroundtripper.js +0 -196
- package/script/src/context/WorkflowClient.d.ts +0 -29
- package/script/src/context/WorkflowClient.d.ts.map +0 -1
- package/script/src/context/WorkflowClient.js +0 -99
- package/script/src/dsl/http/versori/activation.d.ts +0 -13
- package/script/src/dsl/http/versori/activation.d.ts.map +0 -1
- package/script/src/dsl/http/versori/activation.js +0 -69
- package/script/src/dsl/http/versori/cli.d.ts +0 -2
- package/script/src/dsl/http/versori/cli.d.ts.map +0 -1
- package/script/src/dsl/http/versori/cli.js +0 -23
- package/script/src/dsl/http/versori/constants.d.ts +0 -20
- package/script/src/dsl/http/versori/constants.d.ts.map +0 -1
- package/script/src/dsl/http/versori/constants.js +0 -28
- package/script/src/dsl/http/versori/internalauth.d.ts +0 -15
- package/script/src/dsl/http/versori/internalauth.d.ts.map +0 -1
- package/script/src/dsl/http/versori/internalauth.js +0 -94
- package/script/src/dsl/http/versori/platformapi.d.ts +0 -19
- package/script/src/dsl/http/versori/platformapi.d.ts.map +0 -1
- package/script/src/dsl/http/versori/platformapi.js +0 -152
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
- package/script/src/dsl/http/versori/proxyroundtripper.js +0 -200
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
26
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
27
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
@@ -10,10 +33,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
33
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
34
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
35
|
};
|
|
13
|
-
var _FetchBuilder_base, _FetchBuilder_cnx;
|
|
36
|
+
var _FetchBuilder_base, _FetchBuilder_cnx, _FetchBuilder_tracer;
|
|
14
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
38
|
exports.FetchBuilder = void 0;
|
|
39
|
+
const api_1 = __importStar(require("@opentelemetry/api"));
|
|
16
40
|
const helpers_js_1 = require("../../dsl/http/versori/helpers.js");
|
|
41
|
+
const supervisor_js_1 = require("../../internal/supervisor.js");
|
|
17
42
|
/**
|
|
18
43
|
* FetchBuilder is used to build a fetch function which can be composed by multiple middlewares for
|
|
19
44
|
* modifying the request/response and makes the implementation of {@link ConnectionFetchFactory}
|
|
@@ -29,25 +54,105 @@ class FetchBuilder {
|
|
|
29
54
|
});
|
|
30
55
|
_FetchBuilder_base.set(this, void 0);
|
|
31
56
|
_FetchBuilder_cnx.set(this, void 0);
|
|
57
|
+
_FetchBuilder_tracer.set(this, void 0);
|
|
32
58
|
__classPrivateFieldSet(this, _FetchBuilder_base, fetch, "f");
|
|
33
59
|
__classPrivateFieldSet(this, _FetchBuilder_cnx, cnx, "f");
|
|
34
|
-
this
|
|
60
|
+
__classPrivateFieldSet(this, _FetchBuilder_tracer, api_1.default.trace.getTracer('fetch-builder', '1.0.0'), "f");
|
|
61
|
+
if (cnx) {
|
|
62
|
+
this.middlewares = [changeRequestbaseURLMiddleware(cnx)];
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.middlewares = [];
|
|
66
|
+
}
|
|
35
67
|
}
|
|
36
68
|
use(fn) {
|
|
37
69
|
this.middlewares.push(fn);
|
|
38
70
|
}
|
|
39
71
|
build() {
|
|
40
72
|
let fetch = __classPrivateFieldGet(this, _FetchBuilder_base, "f");
|
|
73
|
+
if (supervisor_js_1.enabled) {
|
|
74
|
+
// create fake fetcher that calls the supervisor to generate a mock reponse
|
|
75
|
+
fetch = (async (info, options) => {
|
|
76
|
+
return await (0, supervisor_js_1.mockAPIRequest)(info, __classPrivateFieldGet(this, _FetchBuilder_cnx, "f"), options);
|
|
77
|
+
}).bind(this);
|
|
78
|
+
}
|
|
41
79
|
for (let i = this.middlewares.length - 1; i >= 0; i--) {
|
|
42
80
|
// apply middlewares in reverse order so that the actual middleware executes in the
|
|
43
81
|
// order they were added
|
|
44
82
|
fetch = this.middlewares[i](fetch);
|
|
45
83
|
}
|
|
46
|
-
|
|
84
|
+
// Wrap the final fetch with OpenTelemetry tracing
|
|
85
|
+
return this.wrapWithTracing(fetch);
|
|
86
|
+
}
|
|
87
|
+
wrapWithTracing(fetch) {
|
|
88
|
+
const connectionId = __classPrivateFieldGet(this, _FetchBuilder_cnx, "f")?.id || '';
|
|
89
|
+
const connectionName = __classPrivateFieldGet(this, _FetchBuilder_cnx, "f")?.name || '';
|
|
90
|
+
return (input, init) => {
|
|
91
|
+
const url = getUrl(input);
|
|
92
|
+
return __classPrivateFieldGet(this, _FetchBuilder_tracer, "f").startActiveSpan(`fetch ${url}`, async (span) => {
|
|
93
|
+
// Set span attributes
|
|
94
|
+
span.setAttribute('http.url', url);
|
|
95
|
+
span.setAttribute('type', 'fetch');
|
|
96
|
+
span.setAttribute('connection.id', connectionId);
|
|
97
|
+
span.setAttribute('connection.name', connectionName);
|
|
98
|
+
if (init?.method) {
|
|
99
|
+
span.setAttribute('http.method', init.method);
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
const response = await fetch(input, init);
|
|
103
|
+
if (supervisor_js_1.enabled) {
|
|
104
|
+
// when we are in supervisor mode, we need to store the response body in the span attribute
|
|
105
|
+
// this will be shown the end-user in some Ui in the future
|
|
106
|
+
const body = await response.clone().arrayBuffer();
|
|
107
|
+
// if response is text/* pr json we store the body as a string, otherwise we store it as a base64 string
|
|
108
|
+
const contentType = response.headers.get('Content-Type');
|
|
109
|
+
if (contentType && (contentType.startsWith('text/') || contentType.startsWith('application/json'))) {
|
|
110
|
+
span.setAttribute('response.body', new TextDecoder().decode(body));
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
span.setAttribute('response.body', btoa(String.fromCharCode(...new Uint8Array(body))));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Record response status
|
|
117
|
+
span.setAttribute('http.status_code', response.status);
|
|
118
|
+
if (response.status >= 400) {
|
|
119
|
+
span.setStatus({
|
|
120
|
+
code: api_1.SpanStatusCode.ERROR,
|
|
121
|
+
message: `HTTP ${response.status}`,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
|
126
|
+
}
|
|
127
|
+
return response;
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
// Record exception
|
|
131
|
+
if (error instanceof Error) {
|
|
132
|
+
span.recordException(error);
|
|
133
|
+
span.setStatus({
|
|
134
|
+
code: api_1.SpanStatusCode.ERROR,
|
|
135
|
+
message: error.message,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
span.recordException(new Error(String(error)));
|
|
140
|
+
span.setStatus({
|
|
141
|
+
code: api_1.SpanStatusCode.ERROR,
|
|
142
|
+
message: String(error),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
span.end();
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
};
|
|
47
152
|
}
|
|
48
153
|
}
|
|
49
154
|
exports.FetchBuilder = FetchBuilder;
|
|
50
|
-
_FetchBuilder_base = new WeakMap(), _FetchBuilder_cnx = new WeakMap();
|
|
155
|
+
_FetchBuilder_base = new WeakMap(), _FetchBuilder_cnx = new WeakMap(), _FetchBuilder_tracer = new WeakMap();
|
|
51
156
|
function changeBaseUrl(pathname, conn) {
|
|
52
157
|
const connBaseURL = conn.baseUrl;
|
|
53
158
|
// if the connection has no baseUrl set, but the pathname is a valid URL, return it as is
|
|
@@ -91,3 +196,20 @@ function changeRequestbaseURLMiddleware(conn) {
|
|
|
91
196
|
};
|
|
92
197
|
};
|
|
93
198
|
}
|
|
199
|
+
function getUrl(input) {
|
|
200
|
+
// Extract URL for span naming
|
|
201
|
+
let url;
|
|
202
|
+
if (typeof input === 'string') {
|
|
203
|
+
url = input;
|
|
204
|
+
}
|
|
205
|
+
else if (input instanceof URL) {
|
|
206
|
+
url = input.toString();
|
|
207
|
+
}
|
|
208
|
+
else if (input instanceof Request) {
|
|
209
|
+
url = input.url;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
url = 'unknown';
|
|
213
|
+
}
|
|
214
|
+
return url;
|
|
215
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Client } from '@connectrpc/connect';
|
|
2
2
|
import { Logger } from '../../mod.js';
|
|
3
|
-
import { credentialv1alpha1,
|
|
3
|
+
import { credentialv1alpha1, oauth1v1, tokensv1 } from '../../services/credentials/mod.js';
|
|
4
4
|
import { Connection } from '../../services/platform/mod.js';
|
|
5
5
|
import { FetchLike } from '../types.js';
|
|
6
6
|
import { HttpClientFactory } from './HttpClientFactory.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OutboundConnectionFactory.d.ts","sourceRoot":"","sources":["../../../../src/src/connection/internal/OutboundConnectionFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"OutboundConnectionFactory.d.ts","sourceRoot":"","sources":["../../../../src/src/connection/internal/OutboundConnectionFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC3F,OAAO,EAGH,UAAU,EAGb,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,SAAS,EAAsB,MAAM,aAAa,CAAC;AAG5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,qBAAa,yBAAyB;IAI9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAP3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuC;gBAGxC,iBAAiB,EAAE,iBAAiB,EACpC,WAAW,EAAE,MAAM,CAAC,OAAO,kBAAkB,CAAC,iBAAiB,CAAC,EAChE,MAAM,EAAE,MAAM,CAAC,OAAO,QAAQ,CAAC,YAAY,CAAC,EAC5C,MAAM,EAAE,MAAM,CAAC,OAAO,QAAQ,CAAC,oBAAoB,CAAC,EACpD,MAAM,EAAE,MAAM;IAKnC,OAAO,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;YAkB9B,YAAY;IAmB1B,OAAO,CAAC,eAAe;YAiDT,0BAA0B;YAwB1B,qBAAqB;IA4DnC,OAAO,CAAC,2BAA2B;IAuBnC,OAAO,CAAC,0BAA0B;IAkDlC,OAAO,CAAC,2BAA2B;YA0BrB,wBAAwB;YAkCxB,qBAAqB;IAiCnC,OAAO,CAAC,8BAA8B;IAuBtC,OAAO,CAAC,2BAA2B;YA2ErB,wBAAwB;YAkCxB,qBAAqB;IA6CnC,OAAO,CAAC,kCAAkC;CAsB7C"}
|
|
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.OutboundConnectionFactory = void 0;
|
|
7
7
|
const lru_cache_1 = require("lru-cache");
|
|
8
|
+
const node_crypto_1 = require("node:crypto");
|
|
9
|
+
const oauth_1_0a_1 = __importDefault(require("oauth-1.0a"));
|
|
8
10
|
const isTokenValid_js_1 = require("../../services/credentials/isTokenValid.js");
|
|
9
11
|
const CredentialHolder_js_1 = require("./CredentialHolder.js");
|
|
10
12
|
const FetchBuilder_js_1 = require("./FetchBuilder.js");
|
|
11
|
-
const oauth_1_0a_1 = __importDefault(require("oauth-1.0a"));
|
|
12
|
-
const node_crypto_1 = require("node:crypto");
|
|
13
13
|
class OutboundConnectionFactory {
|
|
14
14
|
constructor(httpClientFactory, credentials, tokens, oauth1, logger) {
|
|
15
15
|
Object.defineProperty(this, "httpClientFactory", {
|
|
@@ -419,7 +419,6 @@ class OutboundConnectionFactory {
|
|
|
419
419
|
const token = await tokenHolder.get();
|
|
420
420
|
const headers = new Headers(init?.headers);
|
|
421
421
|
headers.set('Authorization', `${tokenType} ${token.accessToken}`);
|
|
422
|
-
console.log('headers', input);
|
|
423
422
|
return fetch(input, {
|
|
424
423
|
...init,
|
|
425
424
|
headers,
|
|
@@ -63,7 +63,7 @@ class AsyncWorkflow {
|
|
|
63
63
|
this.isWaiting = false;
|
|
64
64
|
throw new Error('wait timed out');
|
|
65
65
|
}
|
|
66
|
-
const workflow = await this.queue.
|
|
66
|
+
const workflow = await this.queue.poll(this.workflowId);
|
|
67
67
|
if (workflow.status === 'completed') {
|
|
68
68
|
// workflow is completed, parse the output and set the data and completed to true
|
|
69
69
|
const stringData = workflow.output;
|
|
@@ -5,17 +5,20 @@ import { Issue, IssueAPI } from '../issues/Issues.js';
|
|
|
5
5
|
import { KeyValue, KeyValueProvider, KeyValueScope } from '../kv/KeyValue.js';
|
|
6
6
|
import { Logger } from '../observability/logging/Logger.js';
|
|
7
7
|
import { AsyncWorkflow } from './AsyncWorkflow.js';
|
|
8
|
-
import { Workflow } from '../interpreter/durable/Queue.js';
|
|
9
8
|
import { ActivationImpl } from './ActivationImpl.js';
|
|
10
|
-
import { WorkflowInterface, WorkflowOpts } from './WorkflowClient.js';
|
|
11
9
|
export type OnSuccessFn = (ctx: Context<any>) => void;
|
|
12
10
|
export type OnErrorFn = (ctx: Context<any>) => void;
|
|
13
11
|
export type ContextOptions = {
|
|
14
|
-
|
|
12
|
+
workflowId?: string;
|
|
15
13
|
request?: express.Request;
|
|
16
14
|
onSuccess?: OnSuccessFn;
|
|
17
15
|
onError?: OnErrorFn;
|
|
18
16
|
};
|
|
17
|
+
export type WorkflowOpts = {
|
|
18
|
+
maxAttempts?: number;
|
|
19
|
+
data?: unknown;
|
|
20
|
+
dataRaw?: string;
|
|
21
|
+
};
|
|
19
22
|
export type CreateIssue = {
|
|
20
23
|
severity: 'low' | 'medium' | 'high';
|
|
21
24
|
title: string;
|
|
@@ -40,7 +43,6 @@ export interface Context<D> {
|
|
|
40
43
|
deduplicate?: boolean;
|
|
41
44
|
}): Promise<Issue | null>;
|
|
42
45
|
request(): express.Request | undefined;
|
|
43
|
-
workflowClient(): WorkflowInterface;
|
|
44
46
|
}
|
|
45
47
|
export declare class ContextImpl<D, Index = void> implements Context<D> {
|
|
46
48
|
#private;
|
|
@@ -54,12 +56,11 @@ export declare class ContextImpl<D, Index = void> implements Context<D> {
|
|
|
54
56
|
readonly options: ContextOptions;
|
|
55
57
|
constructor(log: Logger, kvp: KeyValueProvider, creds: CredentialsProvider, executionId: string, startTime: Date, data: D, activation: ActivationImpl, issues: IssueAPI, queue?: QueueAPI, options?: ContextOptions);
|
|
56
58
|
get activation(): ActivationImpl;
|
|
57
|
-
get
|
|
59
|
+
get workflowId(): string | undefined;
|
|
58
60
|
setIndex(idx: number): ContextImpl<D, number>;
|
|
59
61
|
withData<D2>(data: D2): ContextImpl<D2, Index>;
|
|
60
62
|
openKv(scope?: KeyValueScope): KeyValue;
|
|
61
63
|
request(): express.Request | undefined;
|
|
62
|
-
workflowClient(): WorkflowInterface;
|
|
63
64
|
start(group: string, opts: WorkflowOpts): Promise<AsyncWorkflow>;
|
|
64
65
|
createIssue(issue: CreateIssue, options?: {
|
|
65
66
|
deduplicate?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/src/context/Context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/src/context/Context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,QAAQ,EA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cAAc,CAE/B;IAED,IAAI,UAAU,IAAI,MAAM,GAAG,SAAS,CAEnC;IAED,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC;IAkB7C,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC;IAe9C,MAAM,CAAC,KAAK,GAAE,aAA2B,GAAG,QAAQ;IAepD,OAAO,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS;IAIhC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAgCtE,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAO3F,WAAW,IAAI,mBAAmB;IAUlC,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAe5C,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAQlD"}
|
|
@@ -14,7 +14,6 @@ var _ContextImpl_activation, _ContextImpl_issues, _ContextImpl_creds;
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ContextImpl = void 0;
|
|
16
16
|
const AsyncWorkflow_js_1 = require("./AsyncWorkflow.js");
|
|
17
|
-
const WorkflowClient_js_1 = require("./WorkflowClient.js");
|
|
18
17
|
class ContextImpl {
|
|
19
18
|
constructor(log, kvp, creds, executionId, startTime, data, activation, issues, queue, options = {}) {
|
|
20
19
|
Object.defineProperty(this, "log", {
|
|
@@ -88,13 +87,12 @@ class ContextImpl {
|
|
|
88
87
|
this.request = this.request.bind(this);
|
|
89
88
|
this.createIssue = this.createIssue.bind(this);
|
|
90
89
|
this.destroy = this.destroy.bind(this);
|
|
91
|
-
this.workflowClient = this.workflowClient.bind(this);
|
|
92
90
|
}
|
|
93
91
|
get activation() {
|
|
94
92
|
return __classPrivateFieldGet(this, _ContextImpl_activation, "f");
|
|
95
93
|
}
|
|
96
|
-
get
|
|
97
|
-
return this.options.
|
|
94
|
+
get workflowId() {
|
|
95
|
+
return this.options.workflowId;
|
|
98
96
|
}
|
|
99
97
|
setIndex(idx) {
|
|
100
98
|
const next = new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, this.data, __classPrivateFieldGet(this, _ContextImpl_activation, "f"), __classPrivateFieldGet(this, _ContextImpl_issues, "f"), this.queue, this.options);
|
|
@@ -120,12 +118,6 @@ class ContextImpl {
|
|
|
120
118
|
request() {
|
|
121
119
|
return this.options.request;
|
|
122
120
|
}
|
|
123
|
-
workflowClient() {
|
|
124
|
-
if (!this.queue) {
|
|
125
|
-
throw new Error('Queue is not available for this context, cannot start workflow');
|
|
126
|
-
}
|
|
127
|
-
return new WorkflowClient_js_1.WorkflowImpl(this.queue, this.executionId, this.activation);
|
|
128
|
-
}
|
|
129
121
|
async start(group, opts) {
|
|
130
122
|
// this makes a post request to the endpoint sending a message and schedule the workflow to run
|
|
131
123
|
if (!this.queue) {
|
|
@@ -142,14 +134,12 @@ class ContextImpl {
|
|
|
142
134
|
workflows: [
|
|
143
135
|
{
|
|
144
136
|
group,
|
|
145
|
-
projectId: Deno.env.get('VERSORI_PROJECT_ID') ?? 'unknown',
|
|
146
|
-
environmentId: Deno.env.get('VERSORI_ENVIRONMENT_ID') ?? 'unknown',
|
|
147
137
|
metadata: {
|
|
148
138
|
executionId: this.executionId,
|
|
149
139
|
activationId: this.activation?.id,
|
|
150
140
|
userId: this.activation?.user?.externalId,
|
|
151
141
|
},
|
|
152
|
-
payload
|
|
142
|
+
payload,
|
|
153
143
|
maxAttempts: opts.maxAttempts,
|
|
154
144
|
},
|
|
155
145
|
],
|
|
@@ -3,11 +3,10 @@ import { QueueAPI } from '../interpreter/durable/Queue.js';
|
|
|
3
3
|
import { IssueAPI } from '../issues/Issues.js';
|
|
4
4
|
import { KeyValueProvider } from '../kv/KeyValue.js';
|
|
5
5
|
import { Logger } from '../observability/logging/Logger.js';
|
|
6
|
-
import { Context, ContextImpl, ContextOptions } from './Context.js';
|
|
7
6
|
import { Activation, PlatformApi } from '../services/platform/mod.js';
|
|
7
|
+
import { Context, ContextImpl, ContextOptions } from './Context.js';
|
|
8
8
|
export interface ContextProvider {
|
|
9
9
|
create<D>(activation: Activation, data: D, options?: ContextOptions): ContextImpl<D, void>;
|
|
10
|
-
createWithExecutionId<D>(activation: Activation, data: D, executionId: string, options?: ContextOptions): ContextImpl<D, void>;
|
|
11
10
|
destroy(ctx: Context<any>): Promise<void>;
|
|
12
11
|
}
|
|
13
12
|
export declare class ContextProviderImpl implements ContextProvider {
|
|
@@ -20,7 +19,6 @@ export declare class ContextProviderImpl implements ContextProvider {
|
|
|
20
19
|
issues: IssueAPI;
|
|
21
20
|
queue?: QueueAPI;
|
|
22
21
|
constructor(log: Logger, kvp: KeyValueProvider, creds: CredentialsProvider, platformApi: PlatformApi, organisationId: string, environmentId: string, issues: IssueAPI, queue?: QueueAPI | undefined);
|
|
23
|
-
createWithExecutionId<D>(activation: Activation, data: D, executionId: string, options?: ContextOptions): ContextImpl<D, void>;
|
|
24
22
|
create<D>(activation: Activation, data: D, options?: ContextOptions): ContextImpl<D>;
|
|
25
23
|
destroy(_: Context<any>): Promise<void>;
|
|
26
24
|
}
|
|
@@ -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,OA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AAE,gBAAgB,EACrB,KAAK,EAAE,mBAAmB,EACT,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACtC,MAAM,EAAE,QAAQ,EAChB,KAAK,GAAE,QAAQ,GAAG,SAAqB;IAS3C,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,GAAE,cAAmB,GAAG,WAAW,CAAC,CAAC,CAAC;IAyBxF,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAG1C"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ContextProviderImpl = void 0;
|
|
4
4
|
const mod_js_1 = require("../../deps/jsr.io/@std/ulid/1.0.0/mod.js");
|
|
5
|
-
const Context_js_1 = require("./Context.js");
|
|
6
5
|
const ActivationImpl_js_1 = require("./ActivationImpl.js");
|
|
6
|
+
const Context_js_1 = require("./Context.js");
|
|
7
7
|
class ContextProviderImpl {
|
|
8
8
|
constructor(log, kvp, creds, platformApi, organisationId, environmentId, issues, queue = undefined) {
|
|
9
9
|
Object.defineProperty(this, "platformApi", {
|
|
@@ -60,7 +60,8 @@ class ContextProviderImpl {
|
|
|
60
60
|
this.issues = issues;
|
|
61
61
|
this.queue = queue;
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
create(activation, data, options = {}) {
|
|
64
|
+
const executionId = (0, mod_js_1.ulid)();
|
|
64
65
|
const logger = this.log.child({
|
|
65
66
|
executionId,
|
|
66
67
|
activationId: activation.id,
|
|
@@ -69,10 +70,6 @@ class ContextProviderImpl {
|
|
|
69
70
|
const activationImpl = new ActivationImpl_js_1.ActivationImpl(activation, this.platformApi, this.organisationId, this.environmentId, logger);
|
|
70
71
|
return new Context_js_1.ContextImpl(logger, this.kvp, this.creds, executionId, new Date(), data, activationImpl, this.issues, this.queue, options);
|
|
71
72
|
}
|
|
72
|
-
create(activation, data, options = {}) {
|
|
73
|
-
const executionId = (0, mod_js_1.ulid)();
|
|
74
|
-
return this.createWithExecutionId(activation, data, executionId, options);
|
|
75
|
-
}
|
|
76
73
|
destroy(_) {
|
|
77
74
|
return Promise.resolve();
|
|
78
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Workflow.d.ts","sourceRoot":"","sources":["../../../src/src/dsl/Workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"Workflow.d.ts","sourceRoot":"","sources":["../../../src/src/dsl/Workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAY,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,OAAO,EAAe,MAAM,cAAc,CAAC;AAIpD,MAAM,WAAW,QAAQ,CAAC,CAAC;IACvB,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC9C,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;CACvC;AAGD,qBAAa,YAAY,CAAC,CAAC,EAAE,CAAC,CAAE,YAAW,QAAQ,CAAC,CAAC,CAAC;IAClD,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAEL,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IAQjD,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC;IAI7C,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,GAAG,QAAQ,CAAC,EAAE,CAAC;CAGtC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VersoriConfigReader = void 0;
|
|
4
4
|
exports.LoadConfigFromFile = LoadConfigFromFile;
|
|
5
|
-
const constants_js_1 = require("
|
|
5
|
+
const constants_js_1 = require("../../../internal/constants.js");
|
|
6
6
|
//TODO(@teo): remove this file, it is implemented in the src/config directory now.
|
|
7
7
|
/**
|
|
8
8
|
* Loads the Versori SDK configuration from a JSON file.
|
|
@@ -5,11 +5,10 @@ type Cron = {
|
|
|
5
5
|
url: string;
|
|
6
6
|
};
|
|
7
7
|
export declare class CronAPIClient implements CronProvider {
|
|
8
|
-
private baseUrl
|
|
8
|
+
private baseUrl?;
|
|
9
9
|
private envId;
|
|
10
10
|
private integrationUrl;
|
|
11
|
-
|
|
12
|
-
constructor(baseUrl: string, envId: string, integrationUrl: string);
|
|
11
|
+
constructor(envId: string, integrationUrl: string, baseUrl?: string);
|
|
13
12
|
static fromEnv(): CronAPIClient;
|
|
14
13
|
static addDefaultCronPort(url: string): string;
|
|
15
14
|
makeCronPath(name: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cronapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/cronapi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cronapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/cronapi.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,KAAK,IAAI,GAAG;IACR,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,aAAc,YAAW,YAAY;IAC9C,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,cAAc,CAAS;gBAEnB,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAMnE,MAAM,CAAC,OAAO,IAAI,aAAa;IAmB/B,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAU9C,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAM5B,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC5D,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE;CAsB3B"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CronAPIClient = void 0;
|
|
4
|
-
const constants_js_1 = require("
|
|
4
|
+
const constants_js_1 = require("../../../internal/constants.js");
|
|
5
|
+
const supervisor_js_1 = require("../../../internal/supervisor.js");
|
|
5
6
|
class CronAPIClient {
|
|
6
|
-
constructor(
|
|
7
|
+
constructor(envId, integrationUrl, baseUrl) {
|
|
7
8
|
Object.defineProperty(this, "baseUrl", {
|
|
8
9
|
enumerable: true,
|
|
9
10
|
configurable: true,
|
|
@@ -22,29 +23,22 @@ class CronAPIClient {
|
|
|
22
23
|
writable: true,
|
|
23
24
|
value: void 0
|
|
24
25
|
});
|
|
25
|
-
Object.defineProperty(this, "runLocal", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
value: void 0
|
|
30
|
-
});
|
|
31
26
|
this.baseUrl = baseUrl;
|
|
32
27
|
this.envId = envId;
|
|
33
28
|
this.integrationUrl = integrationUrl;
|
|
34
|
-
this.runLocal = Deno.env.get(constants_js_1.envVarLocalRun) === 'true';
|
|
35
29
|
}
|
|
36
30
|
static fromEnv() {
|
|
37
|
-
const baseUrl = Deno.env.get(constants_js_1.envVarCronApiBaseURL)
|
|
31
|
+
const baseUrl = Deno.env.get(constants_js_1.envVarCronApiBaseURL);
|
|
38
32
|
const envId = Deno.env.get(constants_js_1.envVarEnvId);
|
|
39
33
|
const projectId = Deno.env.get(constants_js_1.envVarProjectId);
|
|
40
34
|
const orgSlug = Deno.env.get(constants_js_1.envVarOrgSlug);
|
|
41
35
|
const envName = Deno.env.get(constants_js_1.envVarEnvironmentName);
|
|
42
|
-
if (!
|
|
36
|
+
if (!envId || !projectId || !orgSlug || !envName) {
|
|
43
37
|
throw new Error('Missing required environment variables');
|
|
44
38
|
}
|
|
45
39
|
const integrationUrl = Deno.env.get(constants_js_1.envVarSelfRefURL) ||
|
|
46
40
|
`http://svc-${projectId.toLowerCase()}-${envName.toLowerCase()}.sb-${orgSlug.toLowerCase()}.svc.cluster.local:${constants_js_1.cronPort}`;
|
|
47
|
-
return new CronAPIClient(
|
|
41
|
+
return new CronAPIClient(envId, this.addDefaultCronPort(integrationUrl), baseUrl);
|
|
48
42
|
}
|
|
49
43
|
// Check if the URL has a port, if not, add the default cron port.
|
|
50
44
|
static addDefaultCronPort(url) {
|
|
@@ -65,7 +59,13 @@ class CronAPIClient {
|
|
|
65
59
|
schedule,
|
|
66
60
|
url: this.makeCronPath(name),
|
|
67
61
|
}));
|
|
68
|
-
if (
|
|
62
|
+
if (supervisor_js_1.enabled) {
|
|
63
|
+
// if we are in supervised mode we don't want to do run crons automatically
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!this.baseUrl) {
|
|
67
|
+
// we are no in supervised mode and there is no base URL
|
|
68
|
+
// run for local dev
|
|
69
69
|
this.runLocalFn(cronsArray);
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
@@ -84,7 +84,7 @@ class CronAPIClient {
|
|
|
84
84
|
if (crons.length === 0) {
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
const cronPort = Deno.env.get(
|
|
87
|
+
const cronPort = Deno.env.get(constants_js_1.envCronPort) || '3001';
|
|
88
88
|
console.log('----------------------------------------');
|
|
89
89
|
console.log('Running in local mode, your scheduler workflows will not trigger automatically.');
|
|
90
90
|
console.log('Instead you can trigger them by sending a request to the following URLs:');
|
|
@@ -4,7 +4,7 @@ exports.OpenAPI = void 0;
|
|
|
4
4
|
/* istanbul ignore file */
|
|
5
5
|
/* tslint:disable */
|
|
6
6
|
/* eslint-disable */
|
|
7
|
-
const constants_js_1 = require("
|
|
7
|
+
const constants_js_1 = require("../../../../../internal/constants.js");
|
|
8
8
|
exports.OpenAPI = {
|
|
9
9
|
BASE: Deno.env.get(constants_js_1.envVarSDKApiBaseURL) || 'http://localhost:8902',
|
|
10
10
|
VERSION: '1.0.0',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { NextFunction, Request, Response } from 'express';
|
|
2
2
|
import { ConnectionFactory } from '../../../connection/types.js';
|
|
3
3
|
import { Logger } from '../../../observability/mod.js';
|
|
4
|
-
import { ConfigReader } from '../types.js';
|
|
5
4
|
import { PlatformApi } from '../../../services/platform/mod.js';
|
|
5
|
+
import { ConfigReader } from '../types.js';
|
|
6
6
|
export type CreateWebhookMiddleWareOpts = {
|
|
7
7
|
id: string;
|
|
8
8
|
organisationId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhookmiddleware.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/webhookmiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"webhookmiddleware.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/webhookmiddleware.ts"],"names":[],"mappings":"AAAA,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;AAU3C,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;AAiCF,wBAAgB,6BAA6B,CACzC,IAAI,EAAE,2BAA2B,GAClC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAkFpE;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,CA6DpE;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,CAqFpE"}
|
|
@@ -3,26 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createStaticWebhookMiddleware = createStaticWebhookMiddleware;
|
|
4
4
|
exports.createActIdDynamicWebhookMiddleware = createActIdDynamicWebhookMiddleware;
|
|
5
5
|
exports.createUserIdDynamicWebhookMiddleware = createUserIdDynamicWebhookMiddleware;
|
|
6
|
+
const supervisor_js_1 = require("../../../internal/supervisor.js");
|
|
6
7
|
// TODO: this gets called for every request for all endpoints, can we cache this?
|
|
7
8
|
async function getStaticActivation(opts) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
throwOnError: true,
|
|
19
|
-
});
|
|
20
|
-
activations = data;
|
|
21
|
-
}
|
|
22
|
-
catch (err) {
|
|
23
|
-
opts.log.error('Failed to list activations', { error: err });
|
|
24
|
-
throw new Error('Failed to list activations');
|
|
25
|
-
}
|
|
9
|
+
const { data: activations } = await opts.platformApi.listActivations({
|
|
10
|
+
path: {
|
|
11
|
+
organisation_id: opts.organisationId,
|
|
12
|
+
environment_id: opts.environmentId,
|
|
13
|
+
},
|
|
14
|
+
query: {
|
|
15
|
+
static: true,
|
|
16
|
+
},
|
|
17
|
+
throwOnError: true,
|
|
18
|
+
});
|
|
26
19
|
let activation;
|
|
27
20
|
if (activations && activations.length > 0) {
|
|
28
21
|
if (activations.length > 1) {
|
|
@@ -42,7 +35,19 @@ function createStaticWebhookMiddleware(opts) {
|
|
|
42
35
|
if (opts.connName === undefined) {
|
|
43
36
|
opts.log.warn(`No connection ID found for webhook, accepting any requests which is unsecure!`, { webhookId: opts.id });
|
|
44
37
|
return async (_req, res, next) => {
|
|
45
|
-
|
|
38
|
+
try {
|
|
39
|
+
res.locals.activation = await getStaticActivation(opts);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
if (supervisor_js_1.enabled) {
|
|
43
|
+
res.locals.activation = {};
|
|
44
|
+
next();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
opts.log.error('Failed to get static activation', { error: err });
|
|
48
|
+
res.status(500).json({ error: 'Failed to get static activation' });
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
46
51
|
next();
|
|
47
52
|
};
|
|
48
53
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type * as express from 'express';
|
|
2
2
|
import { AsyncWorkflow } from '../../context/AsyncWorkflow.js';
|
|
3
3
|
import { Context, ContextImpl, CreateIssue } from '../../context/Context.js';
|
|
4
|
-
import { WorkflowInterface, WorkflowOpts } from '../../context/WorkflowClient.js';
|
|
5
4
|
import { Issue } from '../../issues/Issues.js';
|
|
6
5
|
import { KeyValue, KeyValueScope } from '../../kv/KeyValue.js';
|
|
6
|
+
import { WorkflowOpts } from '../../mod.js';
|
|
7
7
|
import { Logger } from '../../observability/logging/Logger.js';
|
|
8
8
|
import { CredentialsProvider } from '../http/versori/contextcredentials.js';
|
|
9
9
|
import { ArrayTask, Task, Taskable, TaskType } from '../Task.js';
|
|
@@ -59,7 +59,6 @@ export declare class HttpContextImpl<D, PageParams> implements HttpContext<D, Pa
|
|
|
59
59
|
}): Promise<Issue | null>;
|
|
60
60
|
nextPage(_nextParams: PageParams): Promise<void>;
|
|
61
61
|
request(): express.Request | undefined;
|
|
62
|
-
workflowClient(): WorkflowInterface;
|
|
63
62
|
}
|
|
64
63
|
export declare function http<In = any, Out = any, PageParams = unknown>(taskId: string, opts: HttpOptions<In, Out, PageParams>, fn: HttpContextFunc<In, Out, PageParams>): Task<In, Out>;
|
|
65
64
|
//# sourceMappingURL=HttpTask.d.ts.map
|