@versori/run 0.1.0-alpha.9 → 0.2.0-alpha.10
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/_dnt.shims.d.ts +1 -5
- package/esm/_dnt.shims.d.ts.map +1 -1
- package/esm/_dnt.shims.js +1 -5
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +1 -2
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -1
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +6 -7
- package/{script/deps/jsr.io/@std/fmt/1.0.6 → esm/deps/jsr.io/@std/fmt/1.0.7}/colors.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/fs/1.0.16 → esm/deps/jsr.io/@std/fs/1.0.17}/exists.d.ts +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.17/exists.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.17}/exists.js +10 -12
- package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +0 -21
- package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts +2 -3
- package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.js +1 -2
- package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +7 -9
- package/esm/src/context/Context.d.ts +16 -4
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +31 -10
- package/esm/src/context/ContextProvider.d.ts +3 -4
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +5 -5
- package/esm/src/dsl/http/types.d.ts +13 -2
- package/esm/src/dsl/http/types.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/activation.d.ts +13 -0
- package/esm/src/dsl/http/versori/activation.d.ts.map +1 -0
- package/esm/src/dsl/http/versori/activation.js +65 -0
- package/esm/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/configloader.js +2 -3
- package/esm/src/dsl/http/versori/constants.d.ts +5 -0
- package/esm/src/dsl/http/versori/constants.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/constants.js +5 -0
- package/esm/src/dsl/http/versori/credentials/client.d.ts +1 -4
- package/esm/src/dsl/http/versori/credentials/client.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/credentials/client.js +3 -16
- package/esm/src/dsl/http/versori/cronapi.d.ts +10 -0
- package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -0
- package/esm/src/dsl/http/versori/cronapi.js +51 -0
- package/esm/src/dsl/http/versori/internalauth.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/internalauth.js +5 -6
- package/esm/src/dsl/http/versori/platformapi.d.ts +4 -1
- package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/platformapi.js +41 -10
- package/esm/src/dsl/http/versori/roundtripper.d.ts +3 -2
- package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/roundtripper.js +128 -78
- package/esm/src/dsl/tasks/HttpTask.d.ts +1 -1
- package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/esm/src/dsl/tasks/HttpTask.js +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.js +10 -6
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +10 -3
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +121 -13
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts +1 -0
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.js +19 -24
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +132 -25
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts +0 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.js +7 -8
- package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/esm/src/observability/logging/ConsoleLogger.js +55 -10
- package/package.json +3 -6
- package/script/_dnt.shims.d.ts +1 -5
- package/script/_dnt.shims.d.ts.map +1 -1
- package/script/_dnt.shims.js +2 -7
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +1 -2
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -1
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +9 -33
- package/{esm/deps/jsr.io/@std/fmt/1.0.6 → script/deps/jsr.io/@std/fmt/1.0.7}/colors.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/fs/1.0.16 → script/deps/jsr.io/@std/fs/1.0.17}/exists.d.ts +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.17/exists.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.17}/exists.js +10 -35
- package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +0 -21
- package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts +2 -3
- package/script/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/file_handler.js +1 -25
- package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +7 -32
- package/script/src/context/Context.d.ts +16 -4
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +31 -10
- package/script/src/context/ContextProvider.d.ts +3 -4
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +5 -5
- package/script/src/dsl/http/types.d.ts +13 -2
- package/script/src/dsl/http/types.d.ts.map +1 -1
- package/script/src/dsl/http/versori/activation.d.ts +13 -0
- package/script/src/dsl/http/versori/activation.d.ts.map +1 -0
- package/script/src/dsl/http/versori/activation.js +69 -0
- package/script/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/script/src/dsl/http/versori/configloader.js +2 -26
- package/script/src/dsl/http/versori/constants.d.ts +5 -0
- package/script/src/dsl/http/versori/constants.d.ts.map +1 -1
- package/script/src/dsl/http/versori/constants.js +6 -1
- package/script/src/dsl/http/versori/credentials/client.d.ts +1 -4
- package/script/src/dsl/http/versori/credentials/client.d.ts.map +1 -1
- package/script/src/dsl/http/versori/credentials/client.js +2 -15
- package/script/src/dsl/http/versori/cronapi.d.ts +10 -0
- package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -0
- package/script/src/dsl/http/versori/cronapi.js +55 -0
- package/script/src/dsl/http/versori/internalauth.d.ts.map +1 -1
- package/script/src/dsl/http/versori/internalauth.js +5 -29
- package/script/src/dsl/http/versori/platformapi.d.ts +4 -1
- package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/platformapi.js +41 -33
- package/script/src/dsl/http/versori/roundtripper.d.ts +3 -2
- package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/script/src/dsl/http/versori/roundtripper.js +128 -101
- package/script/src/dsl/tasks/HttpTask.d.ts +1 -1
- package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/script/src/dsl/tasks/HttpTask.js +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
- package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.js +10 -6
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +10 -3
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +121 -36
- package/script/src/interpreter/memory/ObservableCompiler.d.ts +1 -0
- package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.js +19 -24
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +135 -25
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts +0 -1
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/script/src/kv/nats/NatsKeyValueProvider.js +7 -31
- package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/script/src/observability/logging/ConsoleLogger.js +55 -10
- package/esm/deps/jsr.io/@std/fs/1.0.16/exists.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/fs/1.0.16/exists.d.ts.map +0 -1
- /package/esm/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.7}/colors.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.7}/colors.js +0 -0
- /package/script/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.7}/colors.d.ts +0 -0
- /package/script/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.7}/colors.js +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as dntShim from "../../../../_dnt.shims.js";
|
|
2
1
|
import { LoadConfigFromFile } from './configloader.js';
|
|
3
2
|
import { VersoriCredentialClient } from './credentials/mod.js';
|
|
4
3
|
import { PlatformAPIClient } from './platformapi.js';
|
|
5
4
|
import { ConsoleLogger } from '../../../observability/mod.js';
|
|
6
5
|
import { envVarCredsBaseURL, envVarEnvId, envVarOrgId, envVarPlatformApiBaseURL, } from './constants.js';
|
|
6
|
+
import { ConnectError, Code } from '@connectrpc/connect';
|
|
7
7
|
/**
|
|
8
8
|
* VersoriRoundTripper is an implementation of the RoundTripperFactory interface for Versori connections.
|
|
9
9
|
* This is the intended implementation for when projects/services are hosted on Versori infrastructure.
|
|
@@ -17,13 +17,19 @@ import { envVarCredsBaseURL, envVarEnvId, envVarOrgId, envVarPlatformApiBaseURL,
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
export class VersoriRoundTripperFactory {
|
|
20
|
-
constructor(credsClient, platformAPIClient, logger) {
|
|
20
|
+
constructor(credsClient, credsBaseURL, platformAPIClient, logger) {
|
|
21
21
|
Object.defineProperty(this, "tokenClient", {
|
|
22
22
|
enumerable: true,
|
|
23
23
|
configurable: true,
|
|
24
24
|
writable: true,
|
|
25
25
|
value: void 0
|
|
26
26
|
});
|
|
27
|
+
Object.defineProperty(this, "credsBaseURL", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true,
|
|
30
|
+
writable: true,
|
|
31
|
+
value: void 0
|
|
32
|
+
});
|
|
27
33
|
Object.defineProperty(this, "platformAPIClient", {
|
|
28
34
|
enumerable: true,
|
|
29
35
|
configurable: true,
|
|
@@ -54,15 +60,16 @@ export class VersoriRoundTripperFactory {
|
|
|
54
60
|
}
|
|
55
61
|
});
|
|
56
62
|
this.tokenClient = credsClient;
|
|
63
|
+
this.credsBaseURL = credsBaseURL;
|
|
57
64
|
this.platformAPIClient = platformAPIClient;
|
|
58
65
|
this.versoriCfg = LoadConfigFromFile();
|
|
59
66
|
this.log = logger;
|
|
60
67
|
}
|
|
61
68
|
static fromEnv(logger) {
|
|
62
|
-
const credsBaseURL =
|
|
63
|
-
const platformApiBaseURL =
|
|
64
|
-
const orgId =
|
|
65
|
-
const envId =
|
|
69
|
+
const credsBaseURL = Deno.env.get(envVarCredsBaseURL);
|
|
70
|
+
const platformApiBaseURL = Deno.env.get(envVarPlatformApiBaseURL);
|
|
71
|
+
const orgId = Deno.env.get(envVarOrgId);
|
|
72
|
+
const envId = Deno.env.get(envVarEnvId);
|
|
66
73
|
if (!orgId || !envId || !platformApiBaseURL || !credsBaseURL) {
|
|
67
74
|
const missingVars = [];
|
|
68
75
|
if (!orgId)
|
|
@@ -75,20 +82,23 @@ export class VersoriRoundTripperFactory {
|
|
|
75
82
|
missingVars.push(envVarCredsBaseURL);
|
|
76
83
|
throw new Error(`Missing environment variables: ${missingVars.join(', ')}`);
|
|
77
84
|
}
|
|
78
|
-
const pAPIClient = new PlatformAPIClient(platformApiBaseURL, orgId, envId, {});
|
|
79
|
-
const tokenClient = new VersoriCredentialClient(credsBaseURL);
|
|
80
85
|
const log = logger || new ConsoleLogger('debug');
|
|
81
|
-
|
|
86
|
+
const pAPIClient = new PlatformAPIClient(platformApiBaseURL, orgId, envId, log);
|
|
87
|
+
const tokenClient = new VersoriCredentialClient(credsBaseURL);
|
|
88
|
+
return new VersoriRoundTripperFactory(tokenClient, credsBaseURL, pAPIClient, log);
|
|
82
89
|
}
|
|
83
90
|
// takes the info and modifies the url using changeBaseUrl if necessary
|
|
91
|
+
// if a full valid URL is passed as a string, it will be returned as is
|
|
92
|
+
// if a valid URL object is passed, it will be returned as is
|
|
84
93
|
changeRequestInit(info, conn) {
|
|
85
94
|
if (typeof info === 'string') {
|
|
86
|
-
|
|
95
|
+
if (isValidURL(info)) {
|
|
96
|
+
return info;
|
|
97
|
+
}
|
|
87
98
|
return this.changeBaseUrl(info, conn);
|
|
88
99
|
}
|
|
89
100
|
else if (info instanceof URL) {
|
|
90
|
-
|
|
91
|
-
return newUrl;
|
|
101
|
+
return info;
|
|
92
102
|
}
|
|
93
103
|
else if (info instanceof Request) {
|
|
94
104
|
const url = this.changeBaseUrl(info.url, conn);
|
|
@@ -100,6 +110,7 @@ export class VersoriRoundTripperFactory {
|
|
|
100
110
|
const connBaseURL = conn.baseUrl;
|
|
101
111
|
// if the connection has no baseUrl set, but the pathname is a valid URL, return it as is
|
|
102
112
|
if (!connBaseURL && isValidURL(pathname)) {
|
|
113
|
+
this.log.debug('Using given URL as is', { url: pathname });
|
|
103
114
|
return pathname;
|
|
104
115
|
}
|
|
105
116
|
const connBaseURLObj = new URL(connBaseURL);
|
|
@@ -109,36 +120,45 @@ export class VersoriRoundTripperFactory {
|
|
|
109
120
|
_pathname = pathnameObj.pathname;
|
|
110
121
|
}
|
|
111
122
|
const newURL = new URL(_pathname, connBaseURLObj.origin);
|
|
123
|
+
this.log.debug('Using baseURL from connection', { url: newURL.toString() });
|
|
112
124
|
return newURL.toString();
|
|
113
125
|
}
|
|
114
|
-
|
|
115
|
-
async create(connName, fn = globalThis.fetch) {
|
|
126
|
+
create(connName, fn = globalThis.fetch) {
|
|
116
127
|
const cnxId = this.getConnectionID(connName);
|
|
117
|
-
|
|
118
|
-
|
|
128
|
+
if (!cnxId) {
|
|
129
|
+
this.log.debug('Connection not found in config, could be a dynamic connection', {
|
|
130
|
+
connectionName: connName,
|
|
131
|
+
});
|
|
119
132
|
return undefined;
|
|
120
133
|
}
|
|
121
|
-
const _fn = (input, init) => {
|
|
134
|
+
const _fn = async (input, init) => {
|
|
135
|
+
const conn = await this.platformAPIClient.getStaticConnection(cnxId);
|
|
136
|
+
if (!conn) {
|
|
137
|
+
this.log.error('Connection not found for user, using default fetch', {
|
|
138
|
+
connectionName: connName,
|
|
139
|
+
});
|
|
140
|
+
return globalThis.fetch(input, init);
|
|
141
|
+
}
|
|
122
142
|
const _input = this.changeRequestInit(input, conn);
|
|
123
|
-
|
|
143
|
+
switch (conn.credentials[0].authSchemeConfig.type) {
|
|
144
|
+
case 'api-key':
|
|
145
|
+
return (await this.apiKeyFetcher(conn, fn))(_input, init);
|
|
146
|
+
case 'basic-auth':
|
|
147
|
+
return (await this.basicAuthFetcher(conn, fn))(_input, init);
|
|
148
|
+
case 'jwt-bearer':
|
|
149
|
+
return (await this.bearerTokenFetcher(conn, fn))(_input, init);
|
|
150
|
+
case 'oauth2':
|
|
151
|
+
return (await this.oauth2Fetcher(conn, fn))(_input, init);
|
|
152
|
+
default:
|
|
153
|
+
return fn(_input, init);
|
|
154
|
+
}
|
|
124
155
|
};
|
|
125
|
-
|
|
126
|
-
case 'api-key':
|
|
127
|
-
return this.apiKeyFetcher(conn, _fn);
|
|
128
|
-
case 'basic-auth':
|
|
129
|
-
return this.basicAuthFetcher(conn, _fn);
|
|
130
|
-
case 'jwt-bearer':
|
|
131
|
-
return this.bearerTokenFetcher(conn, _fn);
|
|
132
|
-
case 'oauth2':
|
|
133
|
-
return this.oauth2Fetcher(conn, _fn);
|
|
134
|
-
default:
|
|
135
|
-
return fn;
|
|
136
|
-
}
|
|
156
|
+
return _fn;
|
|
137
157
|
}
|
|
138
|
-
|
|
158
|
+
createDynamic(templateName, fn = globalThis.fetch) {
|
|
139
159
|
const template = this.getTemplateID(templateName);
|
|
140
160
|
if (!template) {
|
|
141
|
-
this.log.
|
|
161
|
+
this.log.debug('Template not found in config, could be a static connection', {
|
|
142
162
|
templateName: templateName,
|
|
143
163
|
});
|
|
144
164
|
return undefined;
|
|
@@ -169,7 +189,8 @@ export class VersoriRoundTripperFactory {
|
|
|
169
189
|
return _fn;
|
|
170
190
|
}
|
|
171
191
|
getConnectionID(connName) {
|
|
172
|
-
const conn = this.versoriCfg.mappings.find((c) => (c.dynamic === undefined || c.dynamic === false) &&
|
|
192
|
+
const conn = this.versoriCfg.mappings.find((c) => (c.dynamic === undefined || c.dynamic === false) &&
|
|
193
|
+
c.name.toLowerCase() === connName.toLowerCase());
|
|
173
194
|
if (!conn || !conn.connId) {
|
|
174
195
|
return '';
|
|
175
196
|
}
|
|
@@ -182,17 +203,17 @@ export class VersoriRoundTripperFactory {
|
|
|
182
203
|
}
|
|
183
204
|
return template.templateId;
|
|
184
205
|
}
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
206
|
+
apiKeyFetcher(conn, fn) {
|
|
207
|
+
const _fn = async (input, init) => {
|
|
208
|
+
const tokenResponse = await this.getToken(conn.credentials[0].credential.id);
|
|
209
|
+
const token = tokenResponse.token?.accessToken;
|
|
210
|
+
const asc = conn.credentials[0].authSchemeConfig.apiKey;
|
|
211
|
+
if (!token) {
|
|
212
|
+
throw new Error('Token not found');
|
|
213
|
+
}
|
|
214
|
+
if (!asc) {
|
|
215
|
+
throw new Error('API Key configuration not found');
|
|
216
|
+
}
|
|
196
217
|
if (!init) {
|
|
197
218
|
init = {};
|
|
198
219
|
}
|
|
@@ -230,13 +251,13 @@ export class VersoriRoundTripperFactory {
|
|
|
230
251
|
};
|
|
231
252
|
return _fn;
|
|
232
253
|
}
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
254
|
+
basicAuthFetcher(conn, fn) {
|
|
255
|
+
const _fn = async (input, init) => {
|
|
256
|
+
const tokenResponse = await this.getToken(conn.credentials[0].credential.id);
|
|
257
|
+
const token = tokenResponse.token?.accessToken;
|
|
258
|
+
if (!token) {
|
|
259
|
+
throw new Error('Token not found');
|
|
260
|
+
}
|
|
240
261
|
if (!init) {
|
|
241
262
|
init = {};
|
|
242
263
|
}
|
|
@@ -260,13 +281,13 @@ export class VersoriRoundTripperFactory {
|
|
|
260
281
|
return _fn;
|
|
261
282
|
}
|
|
262
283
|
// TODO: need to make the prefix and header name configurable from authschemeconfig
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
284
|
+
bearerTokenFetcher(conn, fn) {
|
|
285
|
+
const _fn = async (input, init) => {
|
|
286
|
+
const tokenResponse = await this.getToken(conn.credentials[0].credential.id);
|
|
287
|
+
const token = tokenResponse.token?.accessToken;
|
|
288
|
+
if (!token) {
|
|
289
|
+
throw new Error('Token not found');
|
|
290
|
+
}
|
|
270
291
|
if (!init) {
|
|
271
292
|
init = {};
|
|
272
293
|
}
|
|
@@ -289,27 +310,27 @@ export class VersoriRoundTripperFactory {
|
|
|
289
310
|
};
|
|
290
311
|
return _fn;
|
|
291
312
|
}
|
|
292
|
-
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const _tokenType = () => {
|
|
300
|
-
const _tt = tokenType?.toLowerCase();
|
|
301
|
-
switch (_tt) {
|
|
302
|
-
case 'bearer':
|
|
303
|
-
return 'Bearer';
|
|
304
|
-
case 'mac':
|
|
305
|
-
return 'MAC';
|
|
306
|
-
case 'basic':
|
|
307
|
-
return 'Basic';
|
|
308
|
-
default:
|
|
309
|
-
return 'Bearer';
|
|
313
|
+
oauth2Fetcher(conn, fn) {
|
|
314
|
+
const refreshFn = async (input, init, forceRefresh = false) => {
|
|
315
|
+
const tokenResponse = await this.getToken(conn.credentials[0].credential.id, forceRefresh);
|
|
316
|
+
const token = tokenResponse.token?.accessToken;
|
|
317
|
+
const tokenType = tokenResponse.token?.tokenType;
|
|
318
|
+
if (!token) {
|
|
319
|
+
throw new Error('Token not found');
|
|
310
320
|
}
|
|
311
|
-
|
|
312
|
-
|
|
321
|
+
const _tokenType = () => {
|
|
322
|
+
const _tt = tokenType?.toLowerCase();
|
|
323
|
+
switch (_tt) {
|
|
324
|
+
case 'bearer':
|
|
325
|
+
return 'Bearer';
|
|
326
|
+
case 'mac':
|
|
327
|
+
return 'MAC';
|
|
328
|
+
case 'basic':
|
|
329
|
+
return 'Basic';
|
|
330
|
+
default:
|
|
331
|
+
return 'Bearer';
|
|
332
|
+
}
|
|
333
|
+
};
|
|
313
334
|
if (!init) {
|
|
314
335
|
init = {};
|
|
315
336
|
}
|
|
@@ -330,8 +351,37 @@ export class VersoriRoundTripperFactory {
|
|
|
330
351
|
}
|
|
331
352
|
return fn(input, init);
|
|
332
353
|
};
|
|
354
|
+
const _fn = async (input, init) => {
|
|
355
|
+
const resp = await refreshFn(input, init, false);
|
|
356
|
+
if (resp.status === 401) {
|
|
357
|
+
this.log.debug('Received 401 Unauthorized response, attempting refresh', {
|
|
358
|
+
url: input,
|
|
359
|
+
status: resp.status,
|
|
360
|
+
});
|
|
361
|
+
// TODO: attempt refresh until precondition failed??
|
|
362
|
+
return refreshFn(input, init, true);
|
|
363
|
+
}
|
|
364
|
+
return Promise.resolve(resp);
|
|
365
|
+
};
|
|
333
366
|
return _fn;
|
|
334
367
|
}
|
|
368
|
+
async getToken(id) {
|
|
369
|
+
try {
|
|
370
|
+
return await this.tokenClient.getToken(id);
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
this.log.error('unable to get credential', { error });
|
|
374
|
+
if (error instanceof ConnectError) {
|
|
375
|
+
if (error.rawMessage.includes("connection error received: not a result of an error") && error.code === Code.Internal) {
|
|
376
|
+
this.log.info('Connection error received, attempting to reconnect');
|
|
377
|
+
this.tokenClient = new VersoriCredentialClient(this.credsBaseURL);
|
|
378
|
+
return await this.tokenClient.getToken(id);
|
|
379
|
+
}
|
|
380
|
+
throw error;
|
|
381
|
+
}
|
|
382
|
+
throw error;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
335
385
|
}
|
|
336
386
|
function isValidURL(url) {
|
|
337
387
|
try {
|
|
@@ -33,7 +33,7 @@ export declare class HttpContextImpl<D, PageParams> extends ContextImpl<D> imple
|
|
|
33
33
|
pageParams?: PageParams;
|
|
34
34
|
private dynamicFetcher?;
|
|
35
35
|
private staticFetcher?;
|
|
36
|
-
constructor(ctx:
|
|
36
|
+
constructor(ctx: ContextImpl<D, any>, connectionVars: Record<string, any>, staticFetcher?: typeof globalThis.fetch, dynamicFetcher?: DynamicFetcher, pageParams?: PageParams);
|
|
37
37
|
get fetch(): typeof globalThis.fetch;
|
|
38
38
|
nextPage(nextParams: PageParams): Promise<void>;
|
|
39
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpTask.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/tasks/HttpTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAmB,MAAM,0BAA0B,CAAC;AAGjF,OAAO,EAAc,cAAc,EAAsB,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOjE,MAAM,WAAW,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAE,SAAQ,OAAO,CAAC,IAAI,CAAC;IAC5E,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACzC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvD;AAED,MAAM,MAAM,eAAe,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,IAAI,CAC/C,GAAG,EAAE,WAAW,CAAC,EAAE,EAAE,UAAU,CAAC,KAC/B,OAAO,CAAC,GAAG,CAAC,CAAC;AAElB,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC7B,aAAa,EAAE,CAAC,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,IAAI;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;CAC5C,CAAC;AAEF,qBAAa,YAAY,CAAC,EAAE,EAA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,GAAG,CAAC,CAAM;IAC9C,UAAU,CAAC,EAAE,UAAU,CAAC;IAGxB,OAAO,CAAC,cAAc,CAAC,CAAiB;IACxC,OAAO,CAAC,aAAa,CAAC,CAA0B;gBAG5C,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,EACxB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACnC,aAAa,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,EACvC,cAAc,CAAC,EAAE,cAAc,EAC/B,UAAU,CAAC,EAAE,UAAU;IAkB3B,IAAI,KAAK,IAAI,OAAO,UAAU,CAAC,KAAK,CAGnC;IAEK,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxD;AAED,wBAAgB,IAAI,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,UAAU,GAAG,OAAO,EAC1D,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,EACtC,EAAE,EAAE,eAAe,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,GACzC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAEf"}
|
|
@@ -61,7 +61,7 @@ export class HttpContextImpl extends ContextImpl {
|
|
|
61
61
|
constructor(ctx, connectionVars, staticFetcher, dynamicFetcher, pageParams) {
|
|
62
62
|
// We need to cast ctx to InternalContext to access kvp
|
|
63
63
|
const internalCtx = ctx;
|
|
64
|
-
super(ctx.log, internalCtx.kvp, ctx.executionId, ctx.startTime, ctx.data, ctx.
|
|
64
|
+
super(ctx.log, internalCtx.kvp, ctx.executionId, ctx.startTime, ctx.data, ctx.options);
|
|
65
65
|
Object.defineProperty(this, "connectionVariables", {
|
|
66
66
|
enumerable: true,
|
|
67
67
|
configurable: true,
|
|
@@ -1,13 +1,55 @@
|
|
|
1
|
+
import { Context } from '../../context/Context.js';
|
|
1
2
|
import { Taskable } from '../Task.js';
|
|
2
3
|
import { Trigger, TriggerType } from '../Trigger.js';
|
|
3
4
|
import { Workflow } from '../Workflow.js';
|
|
4
5
|
export type WebhookData = Record<string, never>;
|
|
6
|
+
export type WebhookCorsOptions = boolean | {
|
|
7
|
+
origin: string;
|
|
8
|
+
methods: string[];
|
|
9
|
+
allowedHeaders: string[];
|
|
10
|
+
exposedHeaders: string[];
|
|
11
|
+
credentials: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type WebhookResponseOptions = {
|
|
14
|
+
/**
|
|
15
|
+
* Mode determines how the response is sent to the client. The response can be customized by
|
|
16
|
+
* the `onSuccess` and `onError` functions, which have sensible defaults for each mode.
|
|
17
|
+
*
|
|
18
|
+
* - `sync`: The response is sent at the end of the workflow.
|
|
19
|
+
* - `async`: The response is sent immediately after the trigger is activated.
|
|
20
|
+
*
|
|
21
|
+
* @default 'sync'
|
|
22
|
+
*/
|
|
23
|
+
mode?: 'sync' | 'async';
|
|
24
|
+
/**
|
|
25
|
+
* Function that returns a response for a successful trigger activation.
|
|
26
|
+
*
|
|
27
|
+
* Defaults to a 202 Accepted response for 'async' mode, and a 200 OK response for 'sync' mode.
|
|
28
|
+
*
|
|
29
|
+
* @param ctx The current context of the workflow, containing data from the final step.
|
|
30
|
+
* @returns A response to send to the client.
|
|
31
|
+
*/
|
|
32
|
+
onSuccess?: <T>(ctx: Context<T>) => Response;
|
|
33
|
+
/**
|
|
34
|
+
* Function that returns a response for a failed trigger activation.
|
|
35
|
+
*
|
|
36
|
+
* Defaults to a 500 Internal Server Error response for both modes.
|
|
37
|
+
*
|
|
38
|
+
* @param ctx The current context of the workflow, containing data from the final step.
|
|
39
|
+
* @returns A response to send to the client.
|
|
40
|
+
*/
|
|
41
|
+
onError?: <T>(ctx: Context<T>) => Response;
|
|
42
|
+
};
|
|
43
|
+
export type WebhookOptions = {
|
|
44
|
+
cors?: WebhookCorsOptions;
|
|
45
|
+
response?: WebhookResponseOptions;
|
|
46
|
+
};
|
|
5
47
|
export declare class WebhookTrigger implements Trigger<WebhookData> {
|
|
6
48
|
id: string;
|
|
49
|
+
options: WebhookOptions;
|
|
7
50
|
[TriggerType]: string;
|
|
8
|
-
constructor(id: string);
|
|
51
|
+
constructor(id: string, options?: WebhookOptions);
|
|
9
52
|
then<OO>(task: Taskable<WebhookData, OO>): Workflow<OO>;
|
|
10
|
-
catch<OO>(error: any): Workflow<OO>;
|
|
11
53
|
}
|
|
12
|
-
export declare function webhook(id: string):
|
|
54
|
+
export declare function webhook(id: string, options?: WebhookOptions): Trigger<WebhookData>;
|
|
13
55
|
//# sourceMappingURL=WebhookTrigger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebhookTrigger.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/triggers/WebhookTrigger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WebhookTrigger.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/triggers/WebhookTrigger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AAExD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAEhD,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;CACxB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACjC;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAExB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;IAE7C;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;CAC9C,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IACzB,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,QAAQ,CAAC,EAAE,sBAAsB,CAAC;CACrC,CAAA;AAED,qBAAa,cAAe,YAAW,OAAO,CAAC,WAAW,CAAC;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,cAAc,CAAC;IAExB,CAAC,WAAW,CAAC,EAAE,MAAM,CAAa;gBAEtB,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;IAKpD,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC;CAG1D;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAElF"}
|
|
@@ -3,13 +3,19 @@ import { ensureTask } from "../ensureTask.js";
|
|
|
3
3
|
import { TriggerType } from '../Trigger.js';
|
|
4
4
|
import { WorkflowImpl } from '../Workflow.js';
|
|
5
5
|
export class WebhookTrigger {
|
|
6
|
-
constructor(id) {
|
|
6
|
+
constructor(id, options = {}) {
|
|
7
7
|
Object.defineProperty(this, "id", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
configurable: true,
|
|
10
10
|
writable: true,
|
|
11
11
|
value: void 0
|
|
12
12
|
});
|
|
13
|
+
Object.defineProperty(this, "options", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: void 0
|
|
18
|
+
});
|
|
13
19
|
Object.defineProperty(this, _a, {
|
|
14
20
|
enumerable: true,
|
|
15
21
|
configurable: true,
|
|
@@ -17,15 +23,13 @@ export class WebhookTrigger {
|
|
|
17
23
|
value: 'webhook'
|
|
18
24
|
});
|
|
19
25
|
this.id = id;
|
|
26
|
+
this.options = options;
|
|
20
27
|
}
|
|
21
28
|
then(task) {
|
|
22
29
|
return new WorkflowImpl(this, ensureTask(task));
|
|
23
30
|
}
|
|
24
|
-
catch(error) {
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
31
|
}
|
|
28
32
|
_a = TriggerType;
|
|
29
|
-
export function webhook(id) {
|
|
30
|
-
return new WebhookTrigger(id);
|
|
33
|
+
export function webhook(id, options) {
|
|
34
|
+
return new WebhookTrigger(id, options);
|
|
31
35
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
2
|
+
import { Observable, Subscription } from 'rxjs';
|
|
3
3
|
import { ContextProvider } from '../../context/ContextProvider.js';
|
|
4
|
-
import { ConnectionProvider, RoundTripperFactory } from '../../dsl/http/types.js';
|
|
4
|
+
import { ConnectionProvider, CronProvider, RoundTripperFactory } from '../../dsl/http/types.js';
|
|
5
5
|
import { Workflow } from '../../dsl/Workflow.js';
|
|
6
6
|
import { Logger } from '../../observability/logging/Logger.js';
|
|
7
7
|
import { ObservableCompiler } from './ObservableCompiler.js';
|
|
@@ -18,6 +18,7 @@ type Registration = {
|
|
|
18
18
|
task$: ContextOperatorFunction<any, any, any>;
|
|
19
19
|
localAbortController: AbortController;
|
|
20
20
|
sigintListener: () => void;
|
|
21
|
+
subscription?: Subscription;
|
|
21
22
|
};
|
|
22
23
|
export declare class MemoryInterpreter {
|
|
23
24
|
private readonly log;
|
|
@@ -25,12 +26,18 @@ export declare class MemoryInterpreter {
|
|
|
25
26
|
private readonly contextProvider;
|
|
26
27
|
private readonly roundTripperFactory;
|
|
27
28
|
private readonly router;
|
|
29
|
+
private cronRegistry;
|
|
28
30
|
private readonly connectionProvider;
|
|
31
|
+
private readonly cronProvider;
|
|
29
32
|
private registeredWorkflows;
|
|
30
|
-
|
|
33
|
+
private server?;
|
|
34
|
+
private shutdownServer?;
|
|
35
|
+
private isShuttingDown;
|
|
36
|
+
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, roundTripperFactory: RoundTripperFactory, router: Router, cronRegistry: Map<string, string>, connectionProvider: ConnectionProvider, cronProvider: CronProvider);
|
|
31
37
|
static newInstance(options?: MemoryInterpreterOptions): Promise<MemoryInterpreter>;
|
|
32
38
|
register<O>(workflow: Workflow<O>, options?: MemoryInterpreterOptions): Registration;
|
|
33
39
|
start(): Promise<void>;
|
|
40
|
+
stop(): Promise<void>;
|
|
34
41
|
}
|
|
35
42
|
export {};
|
|
36
43
|
//# sourceMappingURL=MemoryInterpreter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAA+B,UAAU,EAAW,YAAY,EAAE,MAAM,MAAM,CAAC;AACtF,OAAO,EAAE,eAAe,EAAuB,MAAM,kCAAkC,CAAC;AAExF,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGhG,OAAO,EAAE,QAAQ,EAAgB,MAAM,uBAAuB,CAAC;AAI/D,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAmB,kBAAkB,EAAE,MAAM,yBAAyB,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