@versori/run 0.2.5 → 0.2.6
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/{script/deps/jsr.io/@std/fs/1.0.17 → esm/deps/jsr.io/@std/fs/1.0.18}/exists.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +1 -1
- package/esm/src/dsl/http/types.d.ts +2 -0
- package/esm/src/dsl/http/types.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/cli.d.ts +2 -0
- package/esm/src/dsl/http/versori/cli.d.ts.map +1 -0
- package/esm/src/dsl/http/versori/cli.js +20 -0
- package/esm/src/dsl/http/versori/constants.d.ts +1 -0
- package/esm/src/dsl/http/versori/constants.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/constants.js +2 -0
- package/esm/src/dsl/http/versori/cronapi.d.ts +8 -0
- package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/cronapi.js +35 -3
- package/esm/src/dsl/http/versori/helpers.d.ts +2 -0
- package/esm/src/dsl/http/versori/helpers.d.ts.map +1 -0
- package/esm/src/dsl/http/versori/helpers.js +9 -0
- package/esm/src/dsl/http/versori/internalauth.d.ts +6 -1
- package/esm/src/dsl/http/versori/internalauth.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/internalauth.js +20 -4
- package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/platformapi.js +14 -19
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts +22 -0
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts.map +1 -0
- package/esm/src/dsl/http/versori/proxyroundtripper.js +179 -0
- package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/roundtripper.js +1 -9
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +25 -7
- package/package.json +1 -1
- package/{esm/deps/jsr.io/@std/fs/1.0.17 → script/deps/jsr.io/@std/fs/1.0.18}/exists.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +1 -1
- package/script/src/dsl/http/types.d.ts +2 -0
- package/script/src/dsl/http/types.d.ts.map +1 -1
- package/script/src/dsl/http/versori/cli.d.ts +2 -0
- package/script/src/dsl/http/versori/cli.d.ts.map +1 -0
- package/script/src/dsl/http/versori/cli.js +23 -0
- package/script/src/dsl/http/versori/constants.d.ts +1 -0
- package/script/src/dsl/http/versori/constants.d.ts.map +1 -1
- package/script/src/dsl/http/versori/constants.js +3 -1
- package/script/src/dsl/http/versori/cronapi.d.ts +8 -0
- package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/cronapi.js +34 -2
- package/script/src/dsl/http/versori/helpers.d.ts +2 -0
- package/script/src/dsl/http/versori/helpers.d.ts.map +1 -0
- package/script/src/dsl/http/versori/helpers.js +12 -0
- package/script/src/dsl/http/versori/internalauth.d.ts +6 -1
- package/script/src/dsl/http/versori/internalauth.d.ts.map +1 -1
- package/script/src/dsl/http/versori/internalauth.js +19 -3
- package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/platformapi.js +14 -19
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts +22 -0
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts.map +1 -0
- package/script/src/dsl/http/versori/proxyroundtripper.js +183 -0
- package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/script/src/dsl/http/versori/roundtripper.js +4 -12
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +24 -6
- /package/esm/deps/jsr.io/@std/fs/{1.0.17 → 1.0.18}/exists.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/fs/{1.0.17 → 1.0.18}/exists.js +0 -0
- /package/script/deps/jsr.io/@std/fs/{1.0.17 → 1.0.18}/exists.d.ts +0 -0
- /package/script/deps/jsr.io/@std/fs/{1.0.17 → 1.0.18}/exists.js +0 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProxyRoundTripper = void 0;
|
|
4
|
+
const configloader_js_1 = require("./configloader.js");
|
|
5
|
+
const platformapi_js_1 = require("./platformapi.js");
|
|
6
|
+
const constants_js_1 = require("./constants.js");
|
|
7
|
+
const helpers_js_1 = require("./helpers.js");
|
|
8
|
+
const internalauth_js_1 = require("./internalauth.js");
|
|
9
|
+
// ProxyRoundTripper is a factory for creating roundtrippers that use the Versori Platform API proxy endpoints.
|
|
10
|
+
// this should allow code from the platform to be run locally.
|
|
11
|
+
class ProxyRoundTripper {
|
|
12
|
+
constructor(log, platformApiBaseUrl, platformApiClient) {
|
|
13
|
+
Object.defineProperty(this, "platformApiBaseUrl", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: void 0
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(this, "versoriCfg", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
23
|
+
value: void 0
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(this, "platformApiClient", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
value: void 0
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(this, "internalAuth", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(this, "log", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: void 0
|
|
42
|
+
});
|
|
43
|
+
this.versoriCfg = (0, configloader_js_1.LoadConfigFromFile)();
|
|
44
|
+
this.log = log;
|
|
45
|
+
this.platformApiBaseUrl = platformApiBaseUrl;
|
|
46
|
+
this.platformApiClient = platformApiClient;
|
|
47
|
+
this.internalAuth = new internalauth_js_1.InternalAuth();
|
|
48
|
+
}
|
|
49
|
+
static fromEnv(log) {
|
|
50
|
+
const baseUrl = Deno.env.get(constants_js_1.envVarPlatformApiBaseURL);
|
|
51
|
+
const orgId = Deno.env.get(constants_js_1.envVarOrgId);
|
|
52
|
+
const envId = Deno.env.get(constants_js_1.envVarEnvId);
|
|
53
|
+
if (!baseUrl || !orgId || !envId) {
|
|
54
|
+
const missingVars = [];
|
|
55
|
+
if (!baseUrl)
|
|
56
|
+
missingVars.push(constants_js_1.envVarPlatformApiBaseURL);
|
|
57
|
+
if (!orgId)
|
|
58
|
+
missingVars.push(constants_js_1.envVarOrgId);
|
|
59
|
+
if (!envId)
|
|
60
|
+
missingVars.push(constants_js_1.envVarEnvId);
|
|
61
|
+
log.error(`Missing required environment variables: ${missingVars.join(', ')}`);
|
|
62
|
+
throw new Error('Missing required environment variables: ' + missingVars.join(', '));
|
|
63
|
+
}
|
|
64
|
+
return new ProxyRoundTripper(log, baseUrl, new platformapi_js_1.PlatformAPIClient(baseUrl, orgId, envId, log));
|
|
65
|
+
}
|
|
66
|
+
getConnectionID(connName) {
|
|
67
|
+
const conn = this.versoriCfg.mappings.find((c) => (c.dynamic === undefined || c.dynamic === false) &&
|
|
68
|
+
c.name.toLowerCase() === connName.toLowerCase());
|
|
69
|
+
if (!conn || !conn.connId) {
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
return conn.connId;
|
|
73
|
+
}
|
|
74
|
+
getTemplateID(templateName) {
|
|
75
|
+
const template = this.versoriCfg.mappings.find((c) => c.dynamic && c.name.toLowerCase() === templateName.toLowerCase());
|
|
76
|
+
if (!template || !template.templateId) {
|
|
77
|
+
return '';
|
|
78
|
+
}
|
|
79
|
+
return template.templateId;
|
|
80
|
+
}
|
|
81
|
+
makeProxyUrlString(url, cnxId) {
|
|
82
|
+
if ((0, helpers_js_1.isValidURL)(url)) {
|
|
83
|
+
const _url = new URL(url);
|
|
84
|
+
const proxyUrl = `${this.platformApiBaseUrl}/proxy/${cnxId}${_url.pathname}${_url.search}`;
|
|
85
|
+
return proxyUrl;
|
|
86
|
+
}
|
|
87
|
+
// here we assume we just have the path and query string
|
|
88
|
+
// although we could have a leading slash
|
|
89
|
+
const proxyPath = url.startsWith('/') ? url : `/${url}`;
|
|
90
|
+
return `${this.platformApiBaseUrl}/proxy/${cnxId}${proxyPath}`;
|
|
91
|
+
}
|
|
92
|
+
makeProxyInput(input, cnxId) {
|
|
93
|
+
if (typeof input === 'string') {
|
|
94
|
+
return this.makeProxyUrlString(input, cnxId);
|
|
95
|
+
}
|
|
96
|
+
if (input instanceof URL) {
|
|
97
|
+
const proxyUrl = new URL(input);
|
|
98
|
+
proxyUrl.hostname = this.platformApiBaseUrl.replace(/^https?:\/\//, '');
|
|
99
|
+
proxyUrl.pathname = `/proxy/${cnxId}${input.pathname}`;
|
|
100
|
+
return proxyUrl;
|
|
101
|
+
}
|
|
102
|
+
if (input instanceof Request) {
|
|
103
|
+
const requestUrl = this.makeProxyUrlString(input.url, cnxId);
|
|
104
|
+
// not actually sure if these headers overwrite whatever is in init but I have never seen
|
|
105
|
+
// the AI use the Request type
|
|
106
|
+
const proxyRequest = new Request(requestUrl, {
|
|
107
|
+
...input,
|
|
108
|
+
headers: new Headers(input.headers),
|
|
109
|
+
});
|
|
110
|
+
return proxyRequest;
|
|
111
|
+
}
|
|
112
|
+
return input;
|
|
113
|
+
}
|
|
114
|
+
async makeProxyInit(init) {
|
|
115
|
+
if (!init) {
|
|
116
|
+
init = {};
|
|
117
|
+
}
|
|
118
|
+
if (!init.headers) {
|
|
119
|
+
init.headers = new Headers();
|
|
120
|
+
}
|
|
121
|
+
// could be tidied up but this'll do
|
|
122
|
+
const authHeader = await this.internalAuth.getAuthHeader();
|
|
123
|
+
const cookie = authHeader['Cookie'];
|
|
124
|
+
// insert the auth cookie into the headers
|
|
125
|
+
if (init.headers instanceof Headers) {
|
|
126
|
+
init.headers.set('Cookie', cookie);
|
|
127
|
+
}
|
|
128
|
+
else if (init.headers instanceof Array) {
|
|
129
|
+
init.headers.push(['Cookie', cookie]);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
init.headers = {
|
|
133
|
+
...init.headers,
|
|
134
|
+
['Cookie']: cookie,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return init;
|
|
138
|
+
}
|
|
139
|
+
create(connName) {
|
|
140
|
+
const cnxId = this.getConnectionID(connName);
|
|
141
|
+
if (!cnxId) {
|
|
142
|
+
this.log.error(`Connection ${connName} not found in configuration`);
|
|
143
|
+
return Promise.resolve(undefined);
|
|
144
|
+
}
|
|
145
|
+
const _fn = async (input, init) => {
|
|
146
|
+
const proxyInput = this.makeProxyInput(input, cnxId);
|
|
147
|
+
const proxyInit = await this.makeProxyInit(init);
|
|
148
|
+
this.log.info('proxy input and init', { input: proxyInput, init: proxyInit });
|
|
149
|
+
return globalThis.fetch(proxyInput, proxyInit);
|
|
150
|
+
};
|
|
151
|
+
return Promise.resolve(_fn);
|
|
152
|
+
}
|
|
153
|
+
createDynamic(templateName) {
|
|
154
|
+
const template = this.getTemplateID(templateName);
|
|
155
|
+
if (!template) {
|
|
156
|
+
this.log.error(`Template ${templateName} not found in configuration, could be a static connection`);
|
|
157
|
+
return Promise.resolve(undefined);
|
|
158
|
+
}
|
|
159
|
+
const _fn = async (activation, input, init) => {
|
|
160
|
+
const conn = await this.platformApiClient.getActivationConnection(template, activation.id);
|
|
161
|
+
if (!conn) {
|
|
162
|
+
this.log.error(`Connection not found for activation ${activation.id} and template ${template}, using default fetch`);
|
|
163
|
+
return globalThis.fetch(input, init);
|
|
164
|
+
}
|
|
165
|
+
const proxyInput = this.makeProxyInput(input, conn.id);
|
|
166
|
+
const proxyInit = await this.makeProxyInit(init);
|
|
167
|
+
this.log.info('proxy input and init', { input: proxyInput, init: proxyInit });
|
|
168
|
+
return globalThis.fetch(proxyInput, proxyInit);
|
|
169
|
+
};
|
|
170
|
+
return Promise.resolve(_fn);
|
|
171
|
+
}
|
|
172
|
+
credentials() {
|
|
173
|
+
return {
|
|
174
|
+
getRaw: (_name) => {
|
|
175
|
+
return Promise.reject(new Error('Not implemented, getRaw is not supported in proxy mode'));
|
|
176
|
+
},
|
|
177
|
+
getAccessToken: (_name, _forceRefresh) => {
|
|
178
|
+
return Promise.reject(new Error('Not implemented, getAccessToken is not supported in proxy mode'));
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.ProxyRoundTripper = ProxyRoundTripper;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/roundtripper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAElE,OAAO,EAGH,cAAc,EACd,mBAAmB,EAEtB,MAAM,aAAa,CAAC;AAQrB,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAG/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"roundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/roundtripper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAElE,OAAO,EAGH,cAAc,EACd,mBAAmB,EAEtB,MAAM,aAAa,CAAC;AAQrB,OAAO,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OAAO,CAAC,aAAa;YAyDP,gBAAgB;YAqChB,kBAAkB;YAmClB,aAAa;YAwEb,QAAQ;CA4BzB"}
|
|
@@ -7,6 +7,7 @@ const configloader_js_1 = require("./configloader.js");
|
|
|
7
7
|
const constants_js_1 = require("./constants.js");
|
|
8
8
|
const mod_js_2 = require("./credentials/mod.js");
|
|
9
9
|
const platformapi_js_1 = require("./platformapi.js");
|
|
10
|
+
const helpers_js_1 = require("./helpers.js");
|
|
10
11
|
/**
|
|
11
12
|
* VersoriRoundTripper is an implementation of the RoundTripperFactory interface for Versori connections.
|
|
12
13
|
* This is the intended implementation for when projects/services are hosted on Versori infrastructure.
|
|
@@ -104,7 +105,7 @@ class VersoriCredentialsFactory {
|
|
|
104
105
|
// if a valid URL object is passed, it will be returned as is
|
|
105
106
|
changeRequestInit(info, conn) {
|
|
106
107
|
if (typeof info === 'string') {
|
|
107
|
-
if (isValidURL(info)) {
|
|
108
|
+
if ((0, helpers_js_1.isValidURL)(info)) {
|
|
108
109
|
return info;
|
|
109
110
|
}
|
|
110
111
|
return this.changeBaseUrl(info, conn);
|
|
@@ -121,13 +122,13 @@ class VersoriCredentialsFactory {
|
|
|
121
122
|
changeBaseUrl(pathname, conn) {
|
|
122
123
|
const connBaseURL = conn.baseUrl;
|
|
123
124
|
// if the connection has no baseUrl set, but the pathname is a valid URL, return it as is
|
|
124
|
-
if (!connBaseURL && isValidURL(pathname)) {
|
|
125
|
+
if (!connBaseURL && (0, helpers_js_1.isValidURL)(pathname)) {
|
|
125
126
|
this.log.debug('Using given URL as is', { url: pathname });
|
|
126
127
|
return pathname;
|
|
127
128
|
}
|
|
128
129
|
const connBaseURLObj = new URL(connBaseURL);
|
|
129
130
|
let _pathname = pathname;
|
|
130
|
-
if (isValidURL(pathname)) {
|
|
131
|
+
if ((0, helpers_js_1.isValidURL)(pathname)) {
|
|
131
132
|
const pathnameObj = new URL(pathname);
|
|
132
133
|
_pathname = pathnameObj.pathname;
|
|
133
134
|
}
|
|
@@ -491,12 +492,3 @@ class VersoriCredentialsFactory {
|
|
|
491
492
|
}
|
|
492
493
|
}
|
|
493
494
|
exports.VersoriCredentialsFactory = VersoriCredentialsFactory;
|
|
494
|
-
function isValidURL(url) {
|
|
495
|
-
try {
|
|
496
|
-
new URL(url);
|
|
497
|
-
return true;
|
|
498
|
-
}
|
|
499
|
-
catch (_) {
|
|
500
|
-
return false;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"AAAA,OAAsB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAG7D,OAAO,EAA+B,UAAU,EAAM,YAAY,EAAO,MAAM,MAAM,CAAC;AACtF,OAAO,EAAE,eAAe,EAAuB,MAAM,kCAAkC,CAAC;AAExF,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"AAAA,OAAsB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAG7D,OAAO,EAA+B,UAAU,EAAM,YAAY,EAAO,MAAM,MAAM,CAAC;AACtF,OAAO,EAAE,eAAe,EAAuB,MAAM,kCAAkC,CAAC;AAExF,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAchG,OAAO,EAAE,QAAQ,E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Aa;IACpC,OAAO,CAAC,cAAc,CAAS;gBAGV,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,kBAAkB,EAC5B,eAAe,EAAE,eAAe,EAChC,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,EAAE,MAAM,EACvB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACxB,kBAAkB,EAAE,kBAAkB,EACtC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,OAAO,YAAA;WAWzB,WAAW,CAAC,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA8E5F,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,wBAAwB;IA+C/D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAoKtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAO9B"}
|
|
@@ -22,6 +22,24 @@ const MemoryKeyValueProvider_js_1 = require("../../kv/memory/MemoryKeyValueProvi
|
|
|
22
22
|
const NatsKeyValueProvider_js_1 = require("../../kv/nats/NatsKeyValueProvider.js");
|
|
23
23
|
const ConsoleLogger_js_1 = require("../../observability/logging/ConsoleLogger.js");
|
|
24
24
|
const ObservableCompiler_js_1 = require("./ObservableCompiler.js");
|
|
25
|
+
const proxyroundtripper_js_1 = require("../../dsl/http/versori/proxyroundtripper.js");
|
|
26
|
+
function getKVProvider(runLocal) {
|
|
27
|
+
if (runLocal) {
|
|
28
|
+
return Promise.resolve(new MemoryKeyValueProvider_js_1.MemoryKeyValueProvider());
|
|
29
|
+
}
|
|
30
|
+
return NatsKeyValueProvider_js_1.NatsKeyValueProvider.fromEnv();
|
|
31
|
+
}
|
|
32
|
+
function getRoundTripperFactory(log, tracer, opts) {
|
|
33
|
+
if (opts && opts.runLocal) {
|
|
34
|
+
log.info('Running in local mode, using ProxyRoundTripperFactory');
|
|
35
|
+
return proxyroundtripper_js_1.ProxyRoundTripper.fromEnv(log);
|
|
36
|
+
}
|
|
37
|
+
if (!opts || !opts.skipVersoriCredentials) {
|
|
38
|
+
return roundtripper_js_1.VersoriCredentialsFactory.fromEnv(log, tracer);
|
|
39
|
+
}
|
|
40
|
+
log.info('Running with default round tripper factory');
|
|
41
|
+
return new default_js_1.DefaultRoundTripperFactory();
|
|
42
|
+
}
|
|
25
43
|
class MemoryInterpreter {
|
|
26
44
|
constructor(log, compiler, contextProvider, roundTripperFactory, router, cronRegistry, connectionProvider, cronProvider, tracer, otelSDK) {
|
|
27
45
|
Object.defineProperty(this, "log", {
|
|
@@ -125,6 +143,7 @@ class MemoryInterpreter {
|
|
|
125
143
|
const orgSlug = Deno.env.get(constants_js_1.envVarOrgSlug) || 'development';
|
|
126
144
|
const otelTracesURL = Deno.env.get(constants_js_1.envVarOtelTracesURL);
|
|
127
145
|
let otelSDK;
|
|
146
|
+
const runLocal = Deno.env.get(constants_js_1.envVarLocalRun) === 'true';
|
|
128
147
|
// Do NOT change those attributes, they are used by the API to filter on
|
|
129
148
|
const resource = (0, resources_1.resourceFromAttributes)({
|
|
130
149
|
'service.id': serviceName,
|
|
@@ -146,17 +165,16 @@ class MemoryInterpreter {
|
|
|
146
165
|
otelSDK.start();
|
|
147
166
|
}
|
|
148
167
|
const tracer = api_1.default.trace.getTracer(serviceName, version);
|
|
149
|
-
const roundTripperFactory =
|
|
150
|
-
|
|
151
|
-
:
|
|
168
|
+
const roundTripperFactory = getRoundTripperFactory(log, tracer, {
|
|
169
|
+
skipVersoriCredentials: options.skipVersoriCredentials,
|
|
170
|
+
runLocal: runLocal,
|
|
171
|
+
});
|
|
152
172
|
if (options.contextProvider) {
|
|
153
173
|
// no need to set up a key-value provider if options.contextProvider is already
|
|
154
174
|
// initialised.
|
|
155
175
|
return new MemoryInterpreter(log, compiler, options.contextProvider, roundTripperFactory, express_1.default.Router(), new Map(), platformapi_js_1.PlatformAPIClient.fromEnv(), cronapi_js_1.CronAPIClient.fromEnv(), tracer, otelSDK);
|
|
156
176
|
}
|
|
157
|
-
const kvp = await (
|
|
158
|
-
? new MemoryKeyValueProvider_js_1.MemoryKeyValueProvider()
|
|
159
|
-
: NatsKeyValueProvider_js_1.NatsKeyValueProvider.fromEnv());
|
|
177
|
+
const kvp = await getKVProvider(runLocal);
|
|
160
178
|
return new MemoryInterpreter(log, compiler, new ContextProvider_js_1.ContextProviderImpl(log, kvp, roundTripperFactory.credentials()), roundTripperFactory, express_1.default.Router(), new Map(), platformapi_js_1.PlatformAPIClient.fromEnv(), cronapi_js_1.CronAPIClient.fromEnv(), tracer, otelSDK);
|
|
161
179
|
}
|
|
162
180
|
register(workflow, options) {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|