@versori/run 0.2.0 → 0.2.1-alpha.1
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/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +21 -0
- package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
- package/esm/src/context/Context.d.ts +13 -24
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +19 -15
- package/esm/src/context/ContextProvider.d.ts +3 -3
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/dsl/http/default.js +1 -1
- package/esm/src/dsl/http/versori/contextcredentials.d.ts +2 -2
- package/esm/src/dsl/http/versori/contextcredentials.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/credentials/credentials.d.ts +4 -3
- package/esm/src/dsl/http/versori/credentials/credentials.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/credentials/credentials.js +0 -1
- package/esm/src/dsl/http/versori/roundtripper.d.ts +7 -7
- package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/roundtripper.js +59 -66
- package/esm/src/dsl/tasks/HttpTask.d.ts +13 -4
- package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/esm/src/dsl/tasks/HttpTask.js +42 -21
- package/esm/src/interpreter/memory/MemoryInterpreter.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 +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +1 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts +1 -0
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/package.json +2 -2
- package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +21 -0
- package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
- package/script/src/context/Context.d.ts +13 -24
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +19 -15
- package/script/src/context/ContextProvider.d.ts +3 -3
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/dsl/http/default.js +1 -1
- package/script/src/dsl/http/versori/contextcredentials.d.ts +2 -2
- package/script/src/dsl/http/versori/contextcredentials.d.ts.map +1 -1
- package/script/src/dsl/http/versori/credentials/credentials.d.ts +4 -3
- package/script/src/dsl/http/versori/credentials/credentials.d.ts.map +1 -1
- package/script/src/dsl/http/versori/credentials/credentials.js +0 -1
- package/script/src/dsl/http/versori/roundtripper.d.ts +7 -7
- package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/script/src/dsl/http/versori/roundtripper.js +63 -70
- package/script/src/dsl/tasks/HttpTask.d.ts +13 -4
- package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/script/src/dsl/tasks/HttpTask.js +42 -21
- package/script/src/interpreter/memory/MemoryInterpreter.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 +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +1 -1
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts +1 -0
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VersoriCredentialsFactory = void 0;
|
|
4
|
+
const connect_1 = require("@connectrpc/connect");
|
|
5
|
+
const mod_js_1 = require("../../../observability/mod.js");
|
|
4
6
|
const configloader_js_1 = require("./configloader.js");
|
|
5
|
-
const mod_js_1 = require("./credentials/mod.js");
|
|
6
|
-
const platformapi_js_1 = require("./platformapi.js");
|
|
7
|
-
const mod_js_2 = require("../../../observability/mod.js");
|
|
8
7
|
const constants_js_1 = require("./constants.js");
|
|
9
|
-
const
|
|
8
|
+
const mod_js_2 = require("./credentials/mod.js");
|
|
9
|
+
const platformapi_js_1 = require("./platformapi.js");
|
|
10
10
|
/**
|
|
11
11
|
* VersoriRoundTripper is an implementation of the RoundTripperFactory interface for Versori connections.
|
|
12
12
|
* This is the intended implementation for when projects/services are hosted on Versori infrastructure.
|
|
@@ -86,56 +86,20 @@ class VersoriCredentialsFactory {
|
|
|
86
86
|
missingVars.push(constants_js_1.envVarCredsBaseURL);
|
|
87
87
|
throw new Error(`Missing environment variables: ${missingVars.join(', ')}`);
|
|
88
88
|
}
|
|
89
|
-
const log = logger || new
|
|
89
|
+
const log = logger || new mod_js_1.ConsoleLogger('debug');
|
|
90
90
|
const pAPIClient = new platformapi_js_1.PlatformAPIClient(platformApiBaseURL, orgId, envId, log);
|
|
91
|
-
const tokenClient = new
|
|
91
|
+
const tokenClient = new mod_js_2.VersoriCredentialClient(credsBaseURL);
|
|
92
92
|
return new VersoriCredentialsFactory(tokenClient, credsBaseURL, pAPIClient, log);
|
|
93
93
|
}
|
|
94
|
-
// takes the info and modifies the url using changeBaseUrl if necessary
|
|
95
|
-
// if a full valid URL is passed as a string, it will be returned as is
|
|
96
|
-
// if a valid URL object is passed, it will be returned as is
|
|
97
|
-
changeRequestInit(info, conn) {
|
|
98
|
-
if (typeof info === 'string') {
|
|
99
|
-
if (isValidURL(info)) {
|
|
100
|
-
return info;
|
|
101
|
-
}
|
|
102
|
-
return this.changeBaseUrl(info, conn);
|
|
103
|
-
}
|
|
104
|
-
else if (info instanceof URL) {
|
|
105
|
-
return info;
|
|
106
|
-
}
|
|
107
|
-
else if (info instanceof Request) {
|
|
108
|
-
const url = this.changeBaseUrl(info.url, conn);
|
|
109
|
-
return new Request(url, info);
|
|
110
|
-
}
|
|
111
|
-
return info;
|
|
112
|
-
}
|
|
113
|
-
changeBaseUrl(pathname, conn) {
|
|
114
|
-
const connBaseURL = conn.baseUrl;
|
|
115
|
-
// if the connection has no baseUrl set, but the pathname is a valid URL, return it as is
|
|
116
|
-
if (!connBaseURL && isValidURL(pathname)) {
|
|
117
|
-
this.log.debug('Using given URL as is', { url: pathname });
|
|
118
|
-
return pathname;
|
|
119
|
-
}
|
|
120
|
-
const connBaseURLObj = new URL(connBaseURL);
|
|
121
|
-
let _pathname = pathname;
|
|
122
|
-
if (isValidURL(pathname)) {
|
|
123
|
-
const pathnameObj = new URL(pathname);
|
|
124
|
-
_pathname = pathnameObj.pathname;
|
|
125
|
-
}
|
|
126
|
-
const newURL = new URL(_pathname, connBaseURLObj.origin);
|
|
127
|
-
this.log.debug('Using baseURL from connection', { url: newURL.toString() });
|
|
128
|
-
return newURL.toString();
|
|
129
|
-
}
|
|
130
94
|
create(connName, fn = globalThis.fetch) {
|
|
131
95
|
const cnxId = this.getConnectionID(connName);
|
|
132
96
|
if (!cnxId) {
|
|
133
97
|
this.log.debug('Connection not found in config, could be a dynamic connection', {
|
|
134
98
|
connectionName: connName,
|
|
135
99
|
});
|
|
136
|
-
return undefined;
|
|
100
|
+
return Promise.resolve(undefined);
|
|
137
101
|
}
|
|
138
|
-
|
|
102
|
+
return Promise.resolve(async (input, init) => {
|
|
139
103
|
const conn = await this.platformAPIClient.getStaticConnection(cnxId);
|
|
140
104
|
if (!conn) {
|
|
141
105
|
this.log.error('Connection not found for user, using default fetch', {
|
|
@@ -156,18 +120,19 @@ class VersoriCredentialsFactory {
|
|
|
156
120
|
default:
|
|
157
121
|
return fn(_input, init);
|
|
158
122
|
}
|
|
159
|
-
};
|
|
160
|
-
return _fn;
|
|
123
|
+
});
|
|
161
124
|
}
|
|
125
|
+
// takes the info and modifies the url using changeBaseUrl if necessary
|
|
126
|
+
// if a full valid URL is passed as a string, it will be returned as is
|
|
162
127
|
createDynamic(templateName, fn = globalThis.fetch) {
|
|
163
128
|
const template = this.getTemplateID(templateName);
|
|
164
129
|
if (!template) {
|
|
165
130
|
this.log.debug('Template not found in config, could be a static connection', {
|
|
166
131
|
templateName: templateName,
|
|
167
132
|
});
|
|
168
|
-
return undefined;
|
|
133
|
+
return Promise.resolve(undefined);
|
|
169
134
|
}
|
|
170
|
-
|
|
135
|
+
return Promise.resolve(async (activation, input, init) => {
|
|
171
136
|
const conn = await this.platformAPIClient.getActivationConnection(template, activation.id);
|
|
172
137
|
if (!conn) {
|
|
173
138
|
return this.defaultDynamic('Connection not found for user, using default fetch', {
|
|
@@ -189,8 +154,7 @@ class VersoriCredentialsFactory {
|
|
|
189
154
|
default:
|
|
190
155
|
return fn(_input, init);
|
|
191
156
|
}
|
|
192
|
-
};
|
|
193
|
-
return _fn;
|
|
157
|
+
});
|
|
194
158
|
}
|
|
195
159
|
credentials() {
|
|
196
160
|
return {
|
|
@@ -198,9 +162,43 @@ class VersoriCredentialsFactory {
|
|
|
198
162
|
getAccessToken: this.getTokenByName.bind(this),
|
|
199
163
|
};
|
|
200
164
|
}
|
|
201
|
-
|
|
165
|
+
// if a valid URL object is passed, it will be returned as is
|
|
166
|
+
changeRequestInit(info, conn) {
|
|
167
|
+
if (typeof info === 'string') {
|
|
168
|
+
if (isValidURL(info)) {
|
|
169
|
+
return info;
|
|
170
|
+
}
|
|
171
|
+
return this.changeBaseUrl(info, conn);
|
|
172
|
+
}
|
|
173
|
+
else if (info instanceof URL) {
|
|
174
|
+
return info;
|
|
175
|
+
}
|
|
176
|
+
else if (info instanceof Request) {
|
|
177
|
+
const url = this.changeBaseUrl(info.url, conn);
|
|
178
|
+
return new Request(url, info);
|
|
179
|
+
}
|
|
180
|
+
return info;
|
|
181
|
+
}
|
|
182
|
+
changeBaseUrl(pathname, conn) {
|
|
183
|
+
const connBaseURL = conn.baseUrl;
|
|
184
|
+
// if the connection has no baseUrl set, but the pathname is a valid URL, return it as is
|
|
185
|
+
if (!connBaseURL && isValidURL(pathname)) {
|
|
186
|
+
this.log.debug('Using given URL as is', { url: pathname });
|
|
187
|
+
return pathname;
|
|
188
|
+
}
|
|
189
|
+
const connBaseURLObj = new URL(connBaseURL);
|
|
190
|
+
let _pathname = pathname;
|
|
191
|
+
if (isValidURL(pathname)) {
|
|
192
|
+
const pathnameObj = new URL(pathname);
|
|
193
|
+
_pathname = pathnameObj.pathname;
|
|
194
|
+
}
|
|
195
|
+
const newURL = new URL(_pathname, connBaseURLObj.origin);
|
|
196
|
+
this.log.debug('Using baseURL from connection', { url: newURL.toString() });
|
|
197
|
+
return newURL.toString();
|
|
198
|
+
}
|
|
199
|
+
async getTokenByName(name, forceRefresh = false) {
|
|
202
200
|
const credId = await this.getCredentialIDFromName(name);
|
|
203
|
-
const token = await this.tokenClient.getToken(credId);
|
|
201
|
+
const token = await this.tokenClient.getToken(credId, forceRefresh);
|
|
204
202
|
if (!token?.token) {
|
|
205
203
|
throw new Error(`Token not found for connection ${name} with credential ID ${credId}`);
|
|
206
204
|
}
|
|
@@ -216,8 +214,7 @@ class VersoriCredentialsFactory {
|
|
|
216
214
|
if (!raw) {
|
|
217
215
|
throw new Error(`Raw data not found for connection ${name} with credential ID ${credId}`);
|
|
218
216
|
}
|
|
219
|
-
|
|
220
|
-
return buffer;
|
|
217
|
+
return raw?.credential?.data['raw'] ?? new Uint8Array(0);
|
|
221
218
|
}
|
|
222
219
|
async getCredentialIDFromName(name) {
|
|
223
220
|
const conId = this.getConnectionID(name);
|
|
@@ -249,7 +246,7 @@ class VersoriCredentialsFactory {
|
|
|
249
246
|
return template.templateId;
|
|
250
247
|
}
|
|
251
248
|
apiKeyFetcher(conn, fn) {
|
|
252
|
-
|
|
249
|
+
return Promise.resolve(async (input, init) => {
|
|
253
250
|
const tokenResponse = await this.getToken(conn.credentials[0].credential.id);
|
|
254
251
|
const token = tokenResponse.token?.accessToken;
|
|
255
252
|
const asc = conn.credentials[0].authSchemeConfig.apiKey;
|
|
@@ -270,7 +267,7 @@ class VersoriCredentialsFactory {
|
|
|
270
267
|
if (init.headers instanceof Headers) {
|
|
271
268
|
init.headers.set(asc.name, token);
|
|
272
269
|
}
|
|
273
|
-
else if (init.headers
|
|
270
|
+
else if (Array.isArray(init.headers)) {
|
|
274
271
|
init.headers.push([asc.name, token]);
|
|
275
272
|
}
|
|
276
273
|
else {
|
|
@@ -293,11 +290,10 @@ class VersoriCredentialsFactory {
|
|
|
293
290
|
break;
|
|
294
291
|
}
|
|
295
292
|
return fn(input, init);
|
|
296
|
-
};
|
|
297
|
-
return _fn;
|
|
293
|
+
});
|
|
298
294
|
}
|
|
299
295
|
basicAuthFetcher(conn, fn) {
|
|
300
|
-
|
|
296
|
+
return Promise.resolve(async (input, init) => {
|
|
301
297
|
const tokenResponse = await this.getToken(conn.credentials[0].credential.id);
|
|
302
298
|
const token = tokenResponse.token?.accessToken;
|
|
303
299
|
if (!token) {
|
|
@@ -322,12 +318,11 @@ class VersoriCredentialsFactory {
|
|
|
322
318
|
};
|
|
323
319
|
}
|
|
324
320
|
return fn(input, init);
|
|
325
|
-
};
|
|
326
|
-
return _fn;
|
|
321
|
+
});
|
|
327
322
|
}
|
|
328
323
|
// TODO: need to make the prefix and header name configurable from authschemeconfig
|
|
329
324
|
bearerTokenFetcher(conn, fn) {
|
|
330
|
-
|
|
325
|
+
return Promise.resolve(async (input, init) => {
|
|
331
326
|
const tokenResponse = await this.getToken(conn.credentials[0].credential.id);
|
|
332
327
|
const token = tokenResponse.token?.accessToken;
|
|
333
328
|
if (!token) {
|
|
@@ -352,8 +347,7 @@ class VersoriCredentialsFactory {
|
|
|
352
347
|
};
|
|
353
348
|
}
|
|
354
349
|
return fn(input, init);
|
|
355
|
-
};
|
|
356
|
-
return _fn;
|
|
350
|
+
});
|
|
357
351
|
}
|
|
358
352
|
oauth2Fetcher(conn, fn) {
|
|
359
353
|
const refreshFn = async (input, init, forceRefresh = false) => {
|
|
@@ -396,7 +390,7 @@ class VersoriCredentialsFactory {
|
|
|
396
390
|
}
|
|
397
391
|
return fn(input, init);
|
|
398
392
|
};
|
|
399
|
-
|
|
393
|
+
return Promise.resolve(async (input, init) => {
|
|
400
394
|
const resp = await refreshFn(input, init, false);
|
|
401
395
|
if (resp.status === 401) {
|
|
402
396
|
this.log.debug('Received 401 Unauthorized response, attempting refresh', {
|
|
@@ -407,19 +401,18 @@ class VersoriCredentialsFactory {
|
|
|
407
401
|
return refreshFn(input, init, true);
|
|
408
402
|
}
|
|
409
403
|
return Promise.resolve(resp);
|
|
410
|
-
};
|
|
411
|
-
return _fn;
|
|
404
|
+
});
|
|
412
405
|
}
|
|
413
|
-
async getToken(id) {
|
|
406
|
+
async getToken(id, forceRefresh = false) {
|
|
414
407
|
try {
|
|
415
|
-
return await this.tokenClient.getToken(id);
|
|
408
|
+
return await this.tokenClient.getToken(id, forceRefresh);
|
|
416
409
|
}
|
|
417
410
|
catch (error) {
|
|
418
411
|
this.log.error('unable to get credential', { error });
|
|
419
412
|
if (error instanceof connect_1.ConnectError) {
|
|
420
413
|
if (error.rawMessage.includes("connection error received: not a result of an error") && error.code === connect_1.Code.Internal) {
|
|
421
414
|
this.log.info('Connection error received, attempting to reconnect');
|
|
422
|
-
this.tokenClient = new
|
|
415
|
+
this.tokenClient = new mod_js_2.VersoriCredentialClient(this.credsBaseURL);
|
|
423
416
|
return await this.tokenClient.getToken(id);
|
|
424
417
|
}
|
|
425
418
|
throw error;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Context, ContextImpl } from '../../context/Context.js';
|
|
2
|
-
import {
|
|
2
|
+
import { KeyValueScope, KeyValue } from '../../kv/KeyValue.js';
|
|
3
|
+
import { Logger } from '../../observability/logging/Logger.js';
|
|
4
|
+
import { Activation, DynamicFetcher } from '../http/types.js';
|
|
5
|
+
import { Credentials } from '../http/versori/contextcredentials.js';
|
|
3
6
|
import { ArrayTask, Task, Taskable, TaskType } from '../Task.js';
|
|
4
7
|
export interface HttpContext<Data, PageParams = undefined> extends Context<Data> {
|
|
5
8
|
fetch: typeof fetch;
|
|
@@ -28,12 +31,18 @@ export declare class HttpTaskImpl<In, Out, PageParams> implements Task<In, Out>
|
|
|
28
31
|
unpack<NextOut>(mapper: (data: Out) => NextOut[]): ArrayTask<In, NextOut>;
|
|
29
32
|
clone(): Task<In, Out>;
|
|
30
33
|
}
|
|
31
|
-
export declare class HttpContextImpl<D, PageParams>
|
|
34
|
+
export declare class HttpContextImpl<D, PageParams> implements HttpContext<D, PageParams> {
|
|
35
|
+
#private;
|
|
32
36
|
connectionVariables: Record<string, any>;
|
|
33
37
|
pageParams?: PageParams;
|
|
34
|
-
private dynamicFetcher?;
|
|
35
|
-
private staticFetcher?;
|
|
36
38
|
constructor(ctx: ContextImpl<D, any>, connectionVars: Record<string, any>, staticFetcher?: typeof globalThis.fetch, dynamicFetcher?: DynamicFetcher, pageParams?: PageParams);
|
|
39
|
+
get log(): Logger;
|
|
40
|
+
get executionId(): string;
|
|
41
|
+
get startTime(): Date;
|
|
42
|
+
get activation(): Activation | undefined;
|
|
43
|
+
get data(): D;
|
|
44
|
+
openKv(scope?: KeyValueScope): KeyValue;
|
|
45
|
+
credentials(): Credentials;
|
|
37
46
|
get fetch(): typeof globalThis.fetch;
|
|
38
47
|
nextPage(nextParams: PageParams): Promise<void>;
|
|
39
48
|
}
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"HttpTask.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/tasks/HttpTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,cAAc,EAAsB,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ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EZ;IAED,MAAM,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,QAAQ;IAIvC,WAAW,IAAI,WAAW;IAI1B,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"}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
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
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _a, _HttpContextImpl_dynamicFetcher, _HttpContextImpl_staticFetcher, _HttpContextImpl_inner;
|
|
3
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
15
|
exports.HttpContextImpl = exports.HttpTaskImpl = void 0;
|
|
5
16
|
exports.http = http;
|
|
6
|
-
const Context_js_1 = require("../../context/Context.js");
|
|
7
17
|
const ensureTask_js_1 = require("../ensureTask.js");
|
|
8
18
|
const types_js_1 = require("../http/types.js");
|
|
9
19
|
const Task_js_1 = require("../Task.js");
|
|
@@ -62,11 +72,8 @@ class HttpTaskImpl {
|
|
|
62
72
|
}
|
|
63
73
|
exports.HttpTaskImpl = HttpTaskImpl;
|
|
64
74
|
_a = Task_js_1.TaskType;
|
|
65
|
-
class HttpContextImpl
|
|
75
|
+
class HttpContextImpl {
|
|
66
76
|
constructor(ctx, connectionVars, staticFetcher, dynamicFetcher, pageParams) {
|
|
67
|
-
// We need to cast ctx to InternalContext to access kvp
|
|
68
|
-
const internalCtx = ctx;
|
|
69
|
-
super(ctx.log, internalCtx.kvp, ctx.creds, ctx.executionId, ctx.startTime, ctx.data, ctx.options);
|
|
70
77
|
Object.defineProperty(this, "connectionVariables", {
|
|
71
78
|
enumerable: true,
|
|
72
79
|
configurable: true,
|
|
@@ -80,32 +87,46 @@ class HttpContextImpl extends Context_js_1.ContextImpl {
|
|
|
80
87
|
value: void 0
|
|
81
88
|
});
|
|
82
89
|
// ideally only one of these should be set to a value
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
value: void 0
|
|
88
|
-
});
|
|
89
|
-
Object.defineProperty(this, "staticFetcher", {
|
|
90
|
-
enumerable: true,
|
|
91
|
-
configurable: true,
|
|
92
|
-
writable: true,
|
|
93
|
-
value: void 0
|
|
94
|
-
});
|
|
90
|
+
_HttpContextImpl_dynamicFetcher.set(this, void 0);
|
|
91
|
+
_HttpContextImpl_staticFetcher.set(this, void 0);
|
|
92
|
+
_HttpContextImpl_inner.set(this, void 0);
|
|
93
|
+
__classPrivateFieldSet(this, _HttpContextImpl_inner, ctx, "f");
|
|
95
94
|
this.pageParams = pageParams;
|
|
96
95
|
this.connectionVariables = connectionVars;
|
|
97
|
-
this
|
|
98
|
-
this
|
|
96
|
+
__classPrivateFieldSet(this, _HttpContextImpl_dynamicFetcher, dynamicFetcher, "f");
|
|
97
|
+
__classPrivateFieldSet(this, _HttpContextImpl_staticFetcher, staticFetcher, "f");
|
|
98
|
+
}
|
|
99
|
+
get log() {
|
|
100
|
+
return __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").log;
|
|
101
|
+
}
|
|
102
|
+
get executionId() {
|
|
103
|
+
return __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").executionId;
|
|
104
|
+
}
|
|
105
|
+
get startTime() {
|
|
106
|
+
return __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").startTime;
|
|
107
|
+
}
|
|
108
|
+
get activation() {
|
|
109
|
+
return __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").activation;
|
|
110
|
+
}
|
|
111
|
+
get data() {
|
|
112
|
+
return __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").data;
|
|
113
|
+
}
|
|
114
|
+
openKv(scope) {
|
|
115
|
+
return __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").openKv(scope);
|
|
116
|
+
}
|
|
117
|
+
credentials() {
|
|
118
|
+
return __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").credentials();
|
|
99
119
|
}
|
|
100
120
|
get fetch() {
|
|
101
121
|
// This is maybe hard to read.
|
|
102
|
-
return this
|
|
122
|
+
return __classPrivateFieldGet(this, _HttpContextImpl_dynamicFetcher, "f") && __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").activation ? (0, types_js_1.wrapDynamicFetcher)(__classPrivateFieldGet(this, _HttpContextImpl_dynamicFetcher, "f"), __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").activation) : __classPrivateFieldGet(this, _HttpContextImpl_staticFetcher, "f") ?? globalThis.fetch;
|
|
103
123
|
}
|
|
104
124
|
async nextPage(nextParams) {
|
|
105
125
|
throw new Error("Method not implemented.");
|
|
106
126
|
}
|
|
107
127
|
}
|
|
108
128
|
exports.HttpContextImpl = HttpContextImpl;
|
|
129
|
+
_HttpContextImpl_dynamicFetcher = new WeakMap(), _HttpContextImpl_staticFetcher = new WeakMap(), _HttpContextImpl_inner = new WeakMap();
|
|
109
130
|
function http(taskId, opts, fn) {
|
|
110
131
|
return new HttpTaskImpl(taskId, opts, fn);
|
|
111
132
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"AACA,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,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"AACA,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,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GV,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;WASlC,WAAW,CAAC,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAwC5F,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,wBAAwB;IA8C/D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAoJtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAsF7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
|
|
@@ -50,7 +50,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
50
50
|
res.status(200).json({ status: 'triggered' });
|
|
51
51
|
}
|
|
52
52
|
catch (error) {
|
|
53
|
-
|
|
53
|
+
ctx.log.error('execution error inside schedule', { error });
|
|
54
54
|
res.status(500).json({ error: 'Failed to trigger schedule' });
|
|
55
55
|
}
|
|
56
56
|
});
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.webhookCompiler = void 0;
|
|
7
7
|
// In src/interpreter/memory/compilers/webhook.ts
|
|
8
8
|
const cors_1 = __importDefault(require("cors"));
|
|
9
|
-
const rxjs_1 = require("rxjs");
|
|
10
9
|
const promises_1 = require("node:stream/promises");
|
|
10
|
+
const rxjs_1 = require("rxjs");
|
|
11
11
|
const WebhookTrigger_js_1 = require("../../../dsl/triggers/WebhookTrigger.js");
|
|
12
12
|
const DEFAULT_SYNC_ON_SUCCESS = (ctx) => new Response(JSON.stringify(ctx.data), {
|
|
13
13
|
status: 200,
|
|
@@ -19,6 +19,7 @@ export declare class NatsKeyValueProvider implements KeyValueProvider, AsyncDisp
|
|
|
19
19
|
private constructor();
|
|
20
20
|
static newInstance(opts?: Partial<NatsKeyValueProviderOptions>): Promise<NatsKeyValueProvider>;
|
|
21
21
|
static fromEnv(): Promise<NatsKeyValueProvider>;
|
|
22
|
+
[Symbol.asyncDispose](): PromiseLike<void>;
|
|
22
23
|
kv(options: KVOptions): KeyValue;
|
|
23
24
|
destroy(options: DestroyOptions): Promise<void>;
|
|
24
25
|
private subjectPrefix;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NatsKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/nats/NatsKeyValueProvider.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+B,UAAU,EAAE,MAAM,+DAA+D,CAAC;AACxH,OAAO,EACH,cAAc,EAEd,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACZ,MAAM,gBAAgB,CAAC;AA4CxB,MAAM,MAAM,2BAA2B,GAAG;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE;QACF,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,GAAG,CAAC,EAAE,UAAU,CAAC;KACpB,CAAC;CACL,CAAC;AAuBF,qBAAa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