@versori/run 0.2.4-alpha.1 → 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 +3 -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 +1 -0
- package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/platformapi.js +24 -16
- 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/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 +7 -3
- 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 +3 -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 +1 -0
- package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/platformapi.js +24 -16
- 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/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 +7 -3
- /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
package/{script/deps/jsr.io/@std/fs/1.0.17 → esm/deps/jsr.io/@std/fs/1.0.18}/exists.d.ts.map
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exists.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/fs/1.0.
|
|
1
|
+
{"version":3,"file":"exists.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/fs/1.0.18/exists.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,OAAO,CAAC,CAsClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+FG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAqCT"}
|
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _RotatingFileHandler_maxBytes, _RotatingFileHandler_maxBackupCount, _RotatingFileHandler_currentFileSize;
|
|
13
|
-
import { existsSync } from "../../fs/1.0.
|
|
13
|
+
import { existsSync } from "../../fs/1.0.18/exists.js";
|
|
14
14
|
import { FileHandler } from "./file_handler.js";
|
|
15
15
|
import { encoderSymbol, filenameSymbol, fileSymbol, modeSymbol, openOptionsSymbol, } from "./_file_handler_symbols.js";
|
|
16
16
|
/**
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { Credentials } from './versori/contextcredentials.js';
|
|
1
2
|
export type DynamicFetcher = (activation: Activation, input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
2
3
|
export interface RoundTripperFactory {
|
|
3
4
|
create(connName: string): Promise<typeof fetch | undefined>;
|
|
4
5
|
createDynamic(templateName: string): Promise<DynamicFetcher | undefined>;
|
|
6
|
+
credentials(): Credentials;
|
|
5
7
|
}
|
|
6
8
|
export declare function wrapDynamicFetcher(fetcher: DynamicFetcher, activation: Activation): typeof fetch;
|
|
7
9
|
export interface ConnectionProvider {
|
|
@@ -9,6 +11,7 @@ export interface ConnectionProvider {
|
|
|
9
11
|
getUserActivations(userId: string): Promise<Activation[]>;
|
|
10
12
|
getActivationConnection(templateId: string, activationId: string): Promise<Connection | undefined>;
|
|
11
13
|
getActivation(activationId: string): Promise<Activation | undefined>;
|
|
14
|
+
getStaticActivation(): Promise<Activation | undefined>;
|
|
12
15
|
listActivations(): Promise<Activation[]>;
|
|
13
16
|
updateDynamicVariable(activationId: string, name: string, value: unknown): Promise<void>;
|
|
14
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/http/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEzH,MAAM,WAAW,mBAAmB;IAChC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,GAAG,SAAS,CAAC,CAAC;IAC5D,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/http/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,MAAM,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEzH,MAAM,WAAW,mBAAmB;IAChC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,GAAG,SAAS,CAAC,CAAC;IAC5D,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IACzE,WAAW,IAAI,WAAW,CAAC;CAC9B;AAGD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,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AAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,oBAAoB,EAAE,CAAC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE;QACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACtB,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC3B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/cli.ts"],"names":[],"mappings":"AAiBA,wBAAgB,gBAAgB,IAAI,MAAM,CAoBzC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// This file contains functions that can read stuff generated by the Versori CLI. This is used when running locally.
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
const cookiesFileName = 'cookies.json';
|
|
4
|
+
const versoriCookieName = 'versori_sess';
|
|
5
|
+
export function getVersoriCookie() {
|
|
6
|
+
const cookiesFilePath = `${homedir()}/.config/versori/${cookiesFileName}`;
|
|
7
|
+
let cookiesFile;
|
|
8
|
+
try {
|
|
9
|
+
cookiesFile = JSON.parse(Deno.readTextFileSync(cookiesFilePath));
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
console.error('Error reading file, have you run the Versori CLI to log in?');
|
|
13
|
+
throw new Error(`Failed to read or parse cookies file at ${cookiesFilePath}: ${e}`);
|
|
14
|
+
}
|
|
15
|
+
const versoriCookie = cookiesFile.cookies.find(cookie => cookie.Name === versoriCookieName);
|
|
16
|
+
if (!versoriCookie) {
|
|
17
|
+
throw new Error(`Cookie 'versori_sess' not found in ${cookiesFilePath}`);
|
|
18
|
+
}
|
|
19
|
+
return `${versoriCookieName}=${versoriCookie.Value}`;
|
|
20
|
+
}
|
|
@@ -14,4 +14,5 @@ export declare const envVarClientId = "RUN_CLIENT_ID";
|
|
|
14
14
|
export declare const envVarClientSecret = "RUN_CLIENT_SECRET";
|
|
15
15
|
export declare const envVarTokenEndpoint = "RUN_TOKEN_ENDPOINT";
|
|
16
16
|
export declare const envVarInternalToken = "RUN_INTERNAL_TOKEN";
|
|
17
|
+
export declare const envVarLocalRun = "RUN_LOCAL";
|
|
17
18
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,wBAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAChD,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AACrD,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AACxE,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,aAAa,wBAAwB,CAAC;AAEnD,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAGlD,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AACxD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,wBAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAChD,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AACrD,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AACxE,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,aAAa,wBAAwB,CAAC;AAEnD,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAGlD,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AACxD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AAGxD,eAAO,MAAM,cAAc,cAAc,CAAC"}
|
|
@@ -17,3 +17,5 @@ export const envVarClientId = 'RUN_CLIENT_ID';
|
|
|
17
17
|
export const envVarClientSecret = 'RUN_CLIENT_SECRET';
|
|
18
18
|
export const envVarTokenEndpoint = 'RUN_TOKEN_ENDPOINT';
|
|
19
19
|
export const envVarInternalToken = 'RUN_INTERNAL_TOKEN';
|
|
20
|
+
// The following are for running locally
|
|
21
|
+
export const envVarLocalRun = 'RUN_LOCAL';
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { CronProvider } from '../types.js';
|
|
2
|
+
type Cron = {
|
|
3
|
+
name: string;
|
|
4
|
+
schedule: string;
|
|
5
|
+
url: string;
|
|
6
|
+
};
|
|
2
7
|
export declare class CronAPIClient implements CronProvider {
|
|
3
8
|
private baseUrl;
|
|
4
9
|
private envId;
|
|
5
10
|
private integrationUrl;
|
|
11
|
+
private runLocal;
|
|
6
12
|
constructor(baseUrl: string, envId: string, integrationUrl: string);
|
|
7
13
|
static fromEnv(): CronAPIClient;
|
|
8
14
|
updateCrons(crons: Map<string, string>): Promise<void>;
|
|
15
|
+
runLocalFn(crons: Cron[]): void;
|
|
9
16
|
}
|
|
17
|
+
export {};
|
|
10
18
|
//# sourceMappingURL=cronapi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cronapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/cronapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"cronapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/cronapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAW3C,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,CAAS;IACxB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAU;gBAEd,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAOlE,MAAM,CAAC,OAAO,IAAI,aAAa;IAmBzB,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB5D,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE;CAoB3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { envVarEnvId, envVarCronApiBaseURL, envVarProjectId, envVarOrgSlug, envVarEnvironmentName, envVarSelfRefURL } from './constants.js';
|
|
1
|
+
import { envVarEnvId, envVarCronApiBaseURL, envVarProjectId, envVarOrgSlug, envVarEnvironmentName, envVarSelfRefURL, envVarLocalRun, } from './constants.js';
|
|
2
2
|
export class CronAPIClient {
|
|
3
3
|
constructor(baseUrl, envId, integrationUrl) {
|
|
4
4
|
Object.defineProperty(this, "baseUrl", {
|
|
@@ -19,9 +19,16 @@ export class CronAPIClient {
|
|
|
19
19
|
writable: true,
|
|
20
20
|
value: void 0
|
|
21
21
|
});
|
|
22
|
+
Object.defineProperty(this, "runLocal", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
22
28
|
this.baseUrl = baseUrl;
|
|
23
29
|
this.envId = envId;
|
|
24
30
|
this.integrationUrl = integrationUrl;
|
|
31
|
+
this.runLocal = Deno.env.get(envVarLocalRun) === 'true';
|
|
25
32
|
}
|
|
26
33
|
static fromEnv() {
|
|
27
34
|
const baseUrl = Deno.env.get(envVarCronApiBaseURL) || 'http://cron-api.platform.svc.cluster.local';
|
|
@@ -32,11 +39,20 @@ export class CronAPIClient {
|
|
|
32
39
|
if (!baseUrl || !envId || !projectId || !orgSlug || !envName) {
|
|
33
40
|
throw new Error('Missing required environment variables');
|
|
34
41
|
}
|
|
35
|
-
const integrationUrl = Deno.env.get(envVarSelfRefURL) ||
|
|
42
|
+
const integrationUrl = Deno.env.get(envVarSelfRefURL) ||
|
|
43
|
+
`http://svc-${projectId.toLowerCase()}-${envName.toLowerCase()}.sb-${orgSlug.toLowerCase()}.svc.cluster.local`;
|
|
36
44
|
return new CronAPIClient(baseUrl, envId, integrationUrl);
|
|
37
45
|
}
|
|
38
46
|
async updateCrons(crons) {
|
|
39
|
-
const cronsArray = Array.from(crons.entries()).map(([name, schedule]) => ({
|
|
47
|
+
const cronsArray = Array.from(crons.entries()).map(([name, schedule]) => ({
|
|
48
|
+
name,
|
|
49
|
+
schedule,
|
|
50
|
+
url: `${this.integrationUrl}/cron/${name}`,
|
|
51
|
+
}));
|
|
52
|
+
if (this.runLocal) {
|
|
53
|
+
this.runLocalFn(cronsArray);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
40
56
|
const resp = await fetch(`${this.baseUrl}/cron/environments/${this.envId}`, {
|
|
41
57
|
method: 'PUT',
|
|
42
58
|
headers: {
|
|
@@ -48,4 +64,20 @@ export class CronAPIClient {
|
|
|
48
64
|
throw new Error(`Failed to update crons: ${resp.statusText}`);
|
|
49
65
|
}
|
|
50
66
|
}
|
|
67
|
+
runLocalFn(crons) {
|
|
68
|
+
if (crons.length === 0) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
console.log('----------------------------------------');
|
|
72
|
+
console.log('Running in local mode, your scheduler workflows will not trigger automatically.');
|
|
73
|
+
console.log('Instead you can trigger them by sending a request to the following URLs:');
|
|
74
|
+
crons.forEach((cron) => {
|
|
75
|
+
const url = new URL(cron.url);
|
|
76
|
+
url.protocol = 'http';
|
|
77
|
+
url.port = '3000';
|
|
78
|
+
url.hostname = 'localhost';
|
|
79
|
+
console.log(`- ${cron.name}: POST ${url.toString()} (Schedule: ${cron.schedule})`);
|
|
80
|
+
});
|
|
81
|
+
console.log('----------------------------------------');
|
|
82
|
+
}
|
|
51
83
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAO/C"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
type internalAuthHeader = {
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
};
|
|
1
4
|
export declare class InternalAuth {
|
|
2
5
|
private clientId;
|
|
3
6
|
private clientSecret;
|
|
4
7
|
private tokenEndpoint;
|
|
8
|
+
private runLocal;
|
|
5
9
|
private accessToken;
|
|
6
10
|
private expiresAt;
|
|
7
11
|
constructor();
|
|
8
|
-
|
|
12
|
+
getAuthHeader(): Promise<internalAuthHeader>;
|
|
9
13
|
}
|
|
14
|
+
export {};
|
|
10
15
|
//# sourceMappingURL=internalauth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalauth.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/internalauth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"internalauth.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/internalauth.ts"],"names":[],"mappings":"AASA,KAAK,kBAAkB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEpD,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAU;IAE1B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;;IAkCpB,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC;CA0BrD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getVersoriCookie } from './cli.js';
|
|
2
|
+
import { envVarClientId, envVarClientSecret, envVarInternalToken, envVarTokenEndpoint, envVarLocalRun, } from './constants.js';
|
|
2
3
|
export class InternalAuth {
|
|
3
4
|
constructor() {
|
|
4
5
|
Object.defineProperty(this, "clientId", {
|
|
@@ -19,6 +20,12 @@ export class InternalAuth {
|
|
|
19
20
|
writable: true,
|
|
20
21
|
value: void 0
|
|
21
22
|
});
|
|
23
|
+
Object.defineProperty(this, "runLocal", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: void 0
|
|
28
|
+
});
|
|
22
29
|
Object.defineProperty(this, "accessToken", {
|
|
23
30
|
enumerable: true,
|
|
24
31
|
configurable: true,
|
|
@@ -36,6 +43,12 @@ export class InternalAuth {
|
|
|
36
43
|
this.tokenEndpoint = Deno.env.get(envVarTokenEndpoint) || '';
|
|
37
44
|
this.accessToken = '';
|
|
38
45
|
this.expiresAt = 0;
|
|
46
|
+
this.runLocal = Deno.env.get(envVarLocalRun) === 'true';
|
|
47
|
+
if (this.runLocal) {
|
|
48
|
+
console.info('Running in local mode using cookie for authentication');
|
|
49
|
+
this.accessToken = getVersoriCookie();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
39
52
|
if (Deno.env.get(envVarInternalToken)) {
|
|
40
53
|
this.accessToken = Deno.env.get(envVarInternalToken) || '';
|
|
41
54
|
this.expiresAt = Date.now() + 365 * 24 * 60 * 60 * 1000; // expires in 1 year
|
|
@@ -53,9 +66,12 @@ export class InternalAuth {
|
|
|
53
66
|
throw new Error(`Missing environment variables: ${missingVars.join(', ')}`);
|
|
54
67
|
}
|
|
55
68
|
}
|
|
56
|
-
async
|
|
69
|
+
async getAuthHeader() {
|
|
70
|
+
if (this.runLocal) {
|
|
71
|
+
return { 'Cookie': this.accessToken };
|
|
72
|
+
}
|
|
57
73
|
if (this.accessToken && this.expiresAt > Date.now()) {
|
|
58
|
-
return this.accessToken;
|
|
74
|
+
return { 'X-Versori-Internal-Token': this.accessToken };
|
|
59
75
|
}
|
|
60
76
|
const encoded = btoa(`${this.clientId}:${this.clientSecret}`);
|
|
61
77
|
const response = await fetch(this.tokenEndpoint, {
|
|
@@ -69,6 +85,6 @@ export class InternalAuth {
|
|
|
69
85
|
const data = await response.json();
|
|
70
86
|
this.accessToken = data.access_token;
|
|
71
87
|
this.expiresAt = Date.now() + data.expires_in * 1000 - 2 * 60 * 1000; // 2 minutes before expiration
|
|
72
|
-
return this.accessToken;
|
|
88
|
+
return { 'X-Versori-Internal-Token': this.accessToken };
|
|
73
89
|
}
|
|
74
90
|
}
|
|
@@ -10,6 +10,7 @@ export declare class PlatformAPIClient implements ConnectionProvider {
|
|
|
10
10
|
static fromEnv(): PlatformAPIClient;
|
|
11
11
|
getStaticConnection(cnxId: string): Promise<Connection | undefined>;
|
|
12
12
|
getUserActivations(userId: string): Promise<Activation[]>;
|
|
13
|
+
getStaticActivation(): Promise<Activation | undefined>;
|
|
13
14
|
getActivation(activationId: string): Promise<Activation | undefined>;
|
|
14
15
|
getActivationConnection(templateId: string, activationId: string): Promise<Connection | undefined>;
|
|
15
16
|
listActivations(): Promise<Activation[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platformapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/platformapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAmBzE,qBAAa,iBAAkB,YAAW,kBAAkB;IACxD,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,KAAK,CAAS;IAEtB,OAAO,CAAC,KAAK,CAAS;IAEtB,OAAO,CAAC,YAAY,CAAe;IAEnC,OAAO,CAAC,GAAG,CAAS;gBAER,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAQtE,MAAM,CAAC,OAAO,IAAI,iBAAiB;IAa7B,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,C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;IAoBtD,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAmBpE,uBAAuB,CACzB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACrB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAmB5B,eAAe,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAuBxC,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAuBjG"}
|
|
@@ -51,10 +51,9 @@ export class PlatformAPIClient {
|
|
|
51
51
|
return new PlatformAPIClient(baseUrl, orgId, envId, log);
|
|
52
52
|
}
|
|
53
53
|
async getStaticConnection(cnxId) {
|
|
54
|
+
const authHeader = await this.internalAuth.getAuthHeader();
|
|
54
55
|
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/connections/${cnxId}`, {
|
|
55
|
-
headers:
|
|
56
|
-
'x-versori-internal-token': await this.internalAuth.getToken(),
|
|
57
|
-
},
|
|
56
|
+
headers: authHeader,
|
|
58
57
|
});
|
|
59
58
|
if (!resp.ok) {
|
|
60
59
|
return undefined;
|
|
@@ -63,10 +62,9 @@ export class PlatformAPIClient {
|
|
|
63
62
|
return result;
|
|
64
63
|
}
|
|
65
64
|
async getUserActivations(userId) {
|
|
65
|
+
const authHeader = await this.internalAuth.getAuthHeader();
|
|
66
66
|
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environment/${this.envId}/users/${userId}/activations`, {
|
|
67
|
-
headers:
|
|
68
|
-
'x-versori-internal-token': await this.internalAuth.getToken(),
|
|
69
|
-
},
|
|
67
|
+
headers: authHeader,
|
|
70
68
|
});
|
|
71
69
|
if (!resp.ok) {
|
|
72
70
|
return [];
|
|
@@ -77,11 +75,22 @@ export class PlatformAPIClient {
|
|
|
77
75
|
});
|
|
78
76
|
return result;
|
|
79
77
|
}
|
|
78
|
+
async getStaticActivation() {
|
|
79
|
+
const authHeader = await this.internalAuth.getAuthHeader();
|
|
80
|
+
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environments/${this.envId}/activations?static=true`, {
|
|
81
|
+
headers: authHeader,
|
|
82
|
+
});
|
|
83
|
+
if (!resp.ok) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
const _acts = (await resp.json());
|
|
87
|
+
const act = _acts[0];
|
|
88
|
+
return new ActivationImpl(act.id, act.user, this, this.log, act.dynamicVariables);
|
|
89
|
+
}
|
|
80
90
|
async getActivation(activationId) {
|
|
91
|
+
const authHeader = await this.internalAuth.getAuthHeader();
|
|
81
92
|
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environments/${this.envId}/activations/${activationId}`, {
|
|
82
|
-
headers:
|
|
83
|
-
'x-versori-internal-token': await this.internalAuth.getToken(),
|
|
84
|
-
},
|
|
93
|
+
headers: authHeader,
|
|
85
94
|
});
|
|
86
95
|
if (!resp.ok) {
|
|
87
96
|
return undefined;
|
|
@@ -90,10 +99,9 @@ export class PlatformAPIClient {
|
|
|
90
99
|
return new ActivationImpl(act.id, act.user, this, this.log, act.dynamicVariables);
|
|
91
100
|
}
|
|
92
101
|
async getActivationConnection(templateId, activationId) {
|
|
102
|
+
const authHeader = await this.internalAuth.getAuthHeader();
|
|
93
103
|
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environment-systems/${templateId}/activations/${activationId}`, {
|
|
94
|
-
headers:
|
|
95
|
-
'x-versori-internal-token': await this.internalAuth.getToken(),
|
|
96
|
-
},
|
|
104
|
+
headers: authHeader,
|
|
97
105
|
});
|
|
98
106
|
if (!resp.ok) {
|
|
99
107
|
return undefined;
|
|
@@ -102,10 +110,9 @@ export class PlatformAPIClient {
|
|
|
102
110
|
return result;
|
|
103
111
|
}
|
|
104
112
|
async listActivations() {
|
|
113
|
+
const authHeader = await this.internalAuth.getAuthHeader();
|
|
105
114
|
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environments/${this.envId}/activations`, {
|
|
106
|
-
headers:
|
|
107
|
-
'x-versori-internal-token': await this.internalAuth.getToken(),
|
|
108
|
-
},
|
|
115
|
+
headers: authHeader,
|
|
109
116
|
});
|
|
110
117
|
if (!resp.ok) {
|
|
111
118
|
return [];
|
|
@@ -118,10 +125,11 @@ export class PlatformAPIClient {
|
|
|
118
125
|
}
|
|
119
126
|
async updateDynamicVariable(activationId, name, value) {
|
|
120
127
|
this.log.debug(`value is ${JSON.stringify(value)}`);
|
|
128
|
+
const authHeader = await this.internalAuth.getAuthHeader();
|
|
121
129
|
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environments/${this.envId}/activations/${activationId}/variables/${name}`, {
|
|
122
130
|
method: 'PUT',
|
|
123
131
|
headers: {
|
|
124
|
-
|
|
132
|
+
...authHeader,
|
|
125
133
|
'Content-Type': 'application/json',
|
|
126
134
|
},
|
|
127
135
|
body: JSON.stringify({
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DynamicFetcher, RoundTripperFactory } from '../types.js';
|
|
2
|
+
import { PlatformAPIClient } from './platformapi.js';
|
|
3
|
+
import { Logger } from '../../../observability/mod.js';
|
|
4
|
+
import { Credentials } from './contextcredentials.js';
|
|
5
|
+
export declare class ProxyRoundTripper implements RoundTripperFactory {
|
|
6
|
+
private platformApiBaseUrl;
|
|
7
|
+
private versoriCfg;
|
|
8
|
+
private platformApiClient;
|
|
9
|
+
private internalAuth;
|
|
10
|
+
private log;
|
|
11
|
+
constructor(log: Logger, platformApiBaseUrl: string, platformApiClient: PlatformAPIClient);
|
|
12
|
+
static fromEnv(log: Logger): ProxyRoundTripper;
|
|
13
|
+
private getConnectionID;
|
|
14
|
+
private getTemplateID;
|
|
15
|
+
private makeProxyUrlString;
|
|
16
|
+
private makeProxyInput;
|
|
17
|
+
private makeProxyInit;
|
|
18
|
+
create(connName: string): Promise<typeof fetch | undefined>;
|
|
19
|
+
createDynamic(templateName: string): Promise<DynamicFetcher | undefined>;
|
|
20
|
+
credentials(): Credentials;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=proxyroundtripper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxyroundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/proxyroundtripper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,cAAc,EAAE,mBAAmB,EAAoB,MAAM,aAAa,CAAC;AAEhG,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAGvD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAKtD,qBAAa,iBAAkB,YAAW,mBAAmB;IACzD,OAAO,CAAC,kBAAkB,CAAS;IAEnC,OAAO,CAAC,UAAU,CAAmB;IAErC,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,OAAO,CAAC,YAAY,CAAe;IAEnC,OAAO,CAAC,GAAG,CAAS;gBAGhB,GAAG,EAAE,MAAM,EACX,kBAAkB,EAAE,MAAM,EAC1B,iBAAiB,EAAE,iBAAiB;IASxC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB;IAwB9C,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,cAAc;YA6BR,aAAa;IA4B3B,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,GAAG,SAAS,CAAC;IAoB3D,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAqCxE,WAAW,IAAI,WAAW;CAc7B"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { LoadConfigFromFile } from './configloader.js';
|
|
2
|
+
import { PlatformAPIClient } from './platformapi.js';
|
|
3
|
+
import { envVarEnvId, envVarOrgId, envVarPlatformApiBaseURL } from './constants.js';
|
|
4
|
+
import { isValidURL } from './helpers.js';
|
|
5
|
+
import { InternalAuth } from './internalauth.js';
|
|
6
|
+
// ProxyRoundTripper is a factory for creating roundtrippers that use the Versori Platform API proxy endpoints.
|
|
7
|
+
// this should allow code from the platform to be run locally.
|
|
8
|
+
export class ProxyRoundTripper {
|
|
9
|
+
constructor(log, platformApiBaseUrl, platformApiClient) {
|
|
10
|
+
Object.defineProperty(this, "platformApiBaseUrl", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: void 0
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(this, "versoriCfg", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: void 0
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(this, "platformApiClient", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(this, "internalAuth", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: void 0
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(this, "log", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: void 0
|
|
39
|
+
});
|
|
40
|
+
this.versoriCfg = LoadConfigFromFile();
|
|
41
|
+
this.log = log;
|
|
42
|
+
this.platformApiBaseUrl = platformApiBaseUrl;
|
|
43
|
+
this.platformApiClient = platformApiClient;
|
|
44
|
+
this.internalAuth = new InternalAuth();
|
|
45
|
+
}
|
|
46
|
+
static fromEnv(log) {
|
|
47
|
+
const baseUrl = Deno.env.get(envVarPlatformApiBaseURL);
|
|
48
|
+
const orgId = Deno.env.get(envVarOrgId);
|
|
49
|
+
const envId = Deno.env.get(envVarEnvId);
|
|
50
|
+
if (!baseUrl || !orgId || !envId) {
|
|
51
|
+
const missingVars = [];
|
|
52
|
+
if (!baseUrl)
|
|
53
|
+
missingVars.push(envVarPlatformApiBaseURL);
|
|
54
|
+
if (!orgId)
|
|
55
|
+
missingVars.push(envVarOrgId);
|
|
56
|
+
if (!envId)
|
|
57
|
+
missingVars.push(envVarEnvId);
|
|
58
|
+
log.error(`Missing required environment variables: ${missingVars.join(', ')}`);
|
|
59
|
+
throw new Error('Missing required environment variables: ' + missingVars.join(', '));
|
|
60
|
+
}
|
|
61
|
+
return new ProxyRoundTripper(log, baseUrl, new PlatformAPIClient(baseUrl, orgId, envId, log));
|
|
62
|
+
}
|
|
63
|
+
getConnectionID(connName) {
|
|
64
|
+
const conn = this.versoriCfg.mappings.find((c) => (c.dynamic === undefined || c.dynamic === false) &&
|
|
65
|
+
c.name.toLowerCase() === connName.toLowerCase());
|
|
66
|
+
if (!conn || !conn.connId) {
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
return conn.connId;
|
|
70
|
+
}
|
|
71
|
+
getTemplateID(templateName) {
|
|
72
|
+
const template = this.versoriCfg.mappings.find((c) => c.dynamic && c.name.toLowerCase() === templateName.toLowerCase());
|
|
73
|
+
if (!template || !template.templateId) {
|
|
74
|
+
return '';
|
|
75
|
+
}
|
|
76
|
+
return template.templateId;
|
|
77
|
+
}
|
|
78
|
+
makeProxyUrlString(url, cnxId) {
|
|
79
|
+
if (isValidURL(url)) {
|
|
80
|
+
const _url = new URL(url);
|
|
81
|
+
const proxyUrl = `${this.platformApiBaseUrl}/proxy/${cnxId}${_url.pathname}${_url.search}`;
|
|
82
|
+
return proxyUrl;
|
|
83
|
+
}
|
|
84
|
+
// here we assume we just have the path and query string
|
|
85
|
+
// although we could have a leading slash
|
|
86
|
+
const proxyPath = url.startsWith('/') ? url : `/${url}`;
|
|
87
|
+
return `${this.platformApiBaseUrl}/proxy/${cnxId}${proxyPath}`;
|
|
88
|
+
}
|
|
89
|
+
makeProxyInput(input, cnxId) {
|
|
90
|
+
if (typeof input === 'string') {
|
|
91
|
+
return this.makeProxyUrlString(input, cnxId);
|
|
92
|
+
}
|
|
93
|
+
if (input instanceof URL) {
|
|
94
|
+
const proxyUrl = new URL(input);
|
|
95
|
+
proxyUrl.hostname = this.platformApiBaseUrl.replace(/^https?:\/\//, '');
|
|
96
|
+
proxyUrl.pathname = `/proxy/${cnxId}${input.pathname}`;
|
|
97
|
+
return proxyUrl;
|
|
98
|
+
}
|
|
99
|
+
if (input instanceof Request) {
|
|
100
|
+
const requestUrl = this.makeProxyUrlString(input.url, cnxId);
|
|
101
|
+
// not actually sure if these headers overwrite whatever is in init but I have never seen
|
|
102
|
+
// the AI use the Request type
|
|
103
|
+
const proxyRequest = new Request(requestUrl, {
|
|
104
|
+
...input,
|
|
105
|
+
headers: new Headers(input.headers),
|
|
106
|
+
});
|
|
107
|
+
return proxyRequest;
|
|
108
|
+
}
|
|
109
|
+
return input;
|
|
110
|
+
}
|
|
111
|
+
async makeProxyInit(init) {
|
|
112
|
+
if (!init) {
|
|
113
|
+
init = {};
|
|
114
|
+
}
|
|
115
|
+
if (!init.headers) {
|
|
116
|
+
init.headers = new Headers();
|
|
117
|
+
}
|
|
118
|
+
// could be tidied up but this'll do
|
|
119
|
+
const authHeader = await this.internalAuth.getAuthHeader();
|
|
120
|
+
const cookie = authHeader['Cookie'];
|
|
121
|
+
// insert the auth cookie into the headers
|
|
122
|
+
if (init.headers instanceof Headers) {
|
|
123
|
+
init.headers.set('Cookie', cookie);
|
|
124
|
+
}
|
|
125
|
+
else if (init.headers instanceof Array) {
|
|
126
|
+
init.headers.push(['Cookie', cookie]);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
init.headers = {
|
|
130
|
+
...init.headers,
|
|
131
|
+
['Cookie']: cookie,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return init;
|
|
135
|
+
}
|
|
136
|
+
create(connName) {
|
|
137
|
+
const cnxId = this.getConnectionID(connName);
|
|
138
|
+
if (!cnxId) {
|
|
139
|
+
this.log.error(`Connection ${connName} not found in configuration`);
|
|
140
|
+
return Promise.resolve(undefined);
|
|
141
|
+
}
|
|
142
|
+
const _fn = async (input, init) => {
|
|
143
|
+
const proxyInput = this.makeProxyInput(input, cnxId);
|
|
144
|
+
const proxyInit = await this.makeProxyInit(init);
|
|
145
|
+
this.log.info('proxy input and init', { input: proxyInput, init: proxyInit });
|
|
146
|
+
return globalThis.fetch(proxyInput, proxyInit);
|
|
147
|
+
};
|
|
148
|
+
return Promise.resolve(_fn);
|
|
149
|
+
}
|
|
150
|
+
createDynamic(templateName) {
|
|
151
|
+
const template = this.getTemplateID(templateName);
|
|
152
|
+
if (!template) {
|
|
153
|
+
this.log.error(`Template ${templateName} not found in configuration, could be a static connection`);
|
|
154
|
+
return Promise.resolve(undefined);
|
|
155
|
+
}
|
|
156
|
+
const _fn = async (activation, input, init) => {
|
|
157
|
+
const conn = await this.platformApiClient.getActivationConnection(template, activation.id);
|
|
158
|
+
if (!conn) {
|
|
159
|
+
this.log.error(`Connection not found for activation ${activation.id} and template ${template}, using default fetch`);
|
|
160
|
+
return globalThis.fetch(input, init);
|
|
161
|
+
}
|
|
162
|
+
const proxyInput = this.makeProxyInput(input, conn.id);
|
|
163
|
+
const proxyInit = await this.makeProxyInit(init);
|
|
164
|
+
this.log.info('proxy input and init', { input: proxyInput, init: proxyInit });
|
|
165
|
+
return globalThis.fetch(proxyInput, proxyInit);
|
|
166
|
+
};
|
|
167
|
+
return Promise.resolve(_fn);
|
|
168
|
+
}
|
|
169
|
+
credentials() {
|
|
170
|
+
return {
|
|
171
|
+
getRaw: (_name) => {
|
|
172
|
+
return Promise.reject(new Error('Not implemented, getRaw is not supported in proxy mode'));
|
|
173
|
+
},
|
|
174
|
+
getAccessToken: (_name, _forceRefresh) => {
|
|
175
|
+
return Promise.reject(new Error('Not implemented, getAccessToken is not supported in proxy mode'));
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -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,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;AAGrD;;;;;;;;;;GAUG;AACH,qBAAa,yBAA0B,YAAW,mBAAmB;IACjE,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,OAAO,CAAC,UAAU,CAAmB;IAErC,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,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