@versori/run 0.3.0-veta.2 → 0.4.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/src/connection/DirectConnectionFactory.d.ts +1 -1
- package/esm/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/DirectConnectionFactory.js +6 -9
- package/esm/src/connection/StaticFetchFactory.d.ts.map +1 -1
- package/esm/src/connection/internal/CredentialHolder.d.ts.map +1 -1
- package/esm/src/connection/internal/CredentialHolder.js +11 -2
- package/esm/src/connection/internal/FetchBuilder.d.ts +3 -2
- package/esm/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/esm/src/connection/internal/FetchBuilder.js +103 -4
- package/esm/src/connection/internal/OutboundConnectionFactory.d.ts +1 -1
- package/esm/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/internal/OutboundConnectionFactory.js +2 -3
- package/esm/src/context/AsyncWorkflow.js +1 -1
- package/esm/src/context/Context.d.ts +7 -6
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +3 -13
- package/esm/src/context/ContextProvider.d.ts +1 -3
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +3 -6
- package/esm/src/dsl/Workflow.d.ts.map +1 -1
- package/esm/src/dsl/Workflow.js +2 -0
- package/esm/src/dsl/http/versori/configloader.js +1 -1
- package/esm/src/dsl/http/versori/cronapi.d.ts +2 -3
- package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/cronapi.js +14 -14
- package/esm/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.d.ts +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.js +24 -19
- package/esm/src/dsl/tasks/HttpTask.d.ts +1 -2
- package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/esm/src/dsl/tasks/HttpTask.js +0 -3
- package/esm/src/dsl/triggers/DurableTrigger.d.ts +1 -0
- package/esm/src/dsl/triggers/DurableTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.js +3 -1
- package/esm/src/internal/constants.d.ts +3 -1
- package/esm/src/internal/constants.d.ts.map +1 -1
- package/esm/src/internal/constants.js +4 -1
- package/esm/src/internal/supervisor.d.ts +21 -0
- package/esm/src/internal/supervisor.d.ts.map +1 -0
- package/esm/src/internal/supervisor.js +122 -0
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/durable/DurableInterpreter.js +62 -22
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/durable/Queue.d.ts +16 -24
- package/esm/src/interpreter/durable/Queue.d.ts.map +1 -1
- package/esm/src/interpreter/durable/Queue.js +5 -4
- package/esm/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/catch.js +3 -2
- package/esm/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/durableworkflow.js +19 -19
- package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/fn.js +17 -4
- package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/http.js +8 -2
- package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/schedule.js +2 -1
- package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/webhook.js +4 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +8 -2
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +46 -18
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.js +3 -2
- package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/fn.js +17 -4
- package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/http.js +33 -3
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.js +2 -1
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +5 -1
- package/esm/src/issues/Issues.js +1 -1
- package/esm/src/kv/sdk/SDKKeyValue.d.ts.map +1 -1
- package/esm/src/kv/sdk/SDKKeyValue.js +3 -9
- package/esm/src/services/createConnectRpcClient.d.ts +16 -0
- package/esm/src/services/createConnectRpcClient.d.ts.map +1 -0
- package/esm/src/services/createConnectRpcClient.js +63 -0
- package/package.json +3 -1
- package/script/src/connection/DirectConnectionFactory.d.ts +1 -1
- package/script/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/DirectConnectionFactory.js +5 -8
- package/script/src/connection/StaticFetchFactory.d.ts.map +1 -1
- package/script/src/connection/internal/CredentialHolder.d.ts.map +1 -1
- package/script/src/connection/internal/CredentialHolder.js +11 -2
- package/script/src/connection/internal/FetchBuilder.d.ts +3 -2
- package/script/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/script/src/connection/internal/FetchBuilder.js +126 -4
- package/script/src/connection/internal/OutboundConnectionFactory.d.ts +1 -1
- package/script/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/internal/OutboundConnectionFactory.js +2 -3
- package/script/src/context/AsyncWorkflow.js +1 -1
- package/script/src/context/Context.d.ts +7 -6
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +3 -13
- package/script/src/context/ContextProvider.d.ts +1 -3
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +3 -6
- package/script/src/dsl/Workflow.d.ts.map +1 -1
- package/script/src/dsl/Workflow.js +2 -0
- package/script/src/dsl/http/versori/configloader.js +1 -1
- package/script/src/dsl/http/versori/cronapi.d.ts +2 -3
- package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/cronapi.js +14 -14
- package/script/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.d.ts +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.js +24 -19
- package/script/src/dsl/tasks/HttpTask.d.ts +1 -2
- package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/script/src/dsl/tasks/HttpTask.js +0 -3
- package/script/src/dsl/triggers/DurableTrigger.d.ts +1 -0
- package/script/src/dsl/triggers/DurableTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.js +3 -1
- package/script/src/internal/constants.d.ts +3 -1
- package/script/src/internal/constants.d.ts.map +1 -1
- package/script/src/internal/constants.js +5 -2
- package/script/src/internal/supervisor.d.ts +21 -0
- package/script/src/internal/supervisor.d.ts.map +1 -0
- package/script/src/internal/supervisor.js +129 -0
- package/script/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
- package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/durable/DurableInterpreter.js +62 -22
- package/script/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
- package/script/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/durable/Queue.d.ts +16 -24
- package/script/src/interpreter/durable/Queue.d.ts.map +1 -1
- package/script/src/interpreter/durable/Queue.js +5 -4
- package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/catch.js +3 -2
- package/script/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/durableworkflow.js +19 -19
- package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/fn.js +17 -4
- package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/http.js +8 -2
- package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/schedule.js +2 -1
- package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/webhook.js +4 -1
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +8 -2
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +46 -18
- package/script/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
- package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.js +3 -2
- package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/fn.js +17 -4
- package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/http.js +33 -3
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.js +2 -1
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +5 -1
- package/script/src/issues/Issues.js +1 -1
- package/script/src/kv/sdk/SDKKeyValue.d.ts.map +1 -1
- package/script/src/kv/sdk/SDKKeyValue.js +3 -9
- package/script/src/services/createConnectRpcClient.d.ts +16 -0
- package/script/src/services/createConnectRpcClient.d.ts.map +1 -0
- package/script/src/services/createConnectRpcClient.js +66 -0
- package/esm/src/context/WorkflowClient.d.ts +0 -29
- package/esm/src/context/WorkflowClient.d.ts.map +0 -1
- package/esm/src/context/WorkflowClient.js +0 -95
- package/esm/src/dsl/http/versori/activation.d.ts +0 -13
- package/esm/src/dsl/http/versori/activation.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/activation.js +0 -65
- package/esm/src/dsl/http/versori/cli.d.ts +0 -2
- package/esm/src/dsl/http/versori/cli.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/cli.js +0 -20
- package/esm/src/dsl/http/versori/constants.d.ts +0 -20
- package/esm/src/dsl/http/versori/constants.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/constants.js +0 -25
- package/esm/src/dsl/http/versori/internalauth.d.ts +0 -15
- package/esm/src/dsl/http/versori/internalauth.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/internalauth.js +0 -90
- package/esm/src/dsl/http/versori/platformapi.d.ts +0 -19
- package/esm/src/dsl/http/versori/platformapi.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/platformapi.js +0 -148
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/proxyroundtripper.js +0 -196
- package/script/src/context/WorkflowClient.d.ts +0 -29
- package/script/src/context/WorkflowClient.d.ts.map +0 -1
- package/script/src/context/WorkflowClient.js +0 -99
- package/script/src/dsl/http/versori/activation.d.ts +0 -13
- package/script/src/dsl/http/versori/activation.d.ts.map +0 -1
- package/script/src/dsl/http/versori/activation.js +0 -69
- package/script/src/dsl/http/versori/cli.d.ts +0 -2
- package/script/src/dsl/http/versori/cli.d.ts.map +0 -1
- package/script/src/dsl/http/versori/cli.js +0 -23
- package/script/src/dsl/http/versori/constants.d.ts +0 -20
- package/script/src/dsl/http/versori/constants.d.ts.map +0 -1
- package/script/src/dsl/http/versori/constants.js +0 -28
- package/script/src/dsl/http/versori/internalauth.d.ts +0 -15
- package/script/src/dsl/http/versori/internalauth.d.ts.map +0 -1
- package/script/src/dsl/http/versori/internalauth.js +0 -94
- package/script/src/dsl/http/versori/platformapi.d.ts +0 -19
- package/script/src/dsl/http/versori/platformapi.d.ts.map +0 -1
- package/script/src/dsl/http/versori/platformapi.js +0 -152
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
- package/script/src/dsl/http/versori/proxyroundtripper.js +0 -200
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare const envVarOrgId = "RUN_ORGANISATION_ID";
|
|
2
|
-
export declare const envVarEnvId = "RUN_ENVIRONMENT_ID";
|
|
3
|
-
export declare const envVarEnvironmentName = "RUN_ENVIRONMENT";
|
|
4
|
-
export declare const envVarProjectId = "RUN_SERVICE_ID";
|
|
5
|
-
export declare const envVarOrgSlug = "RUN_ORGANISATION_SLUG";
|
|
6
|
-
export declare const envVarPlatformApiBaseURL = "RUN_PLATFORM_API_INTERNAL_URL";
|
|
7
|
-
export declare const envVarCronApiBaseURL = "RUN_CRON_API_INTERNAL_URL";
|
|
8
|
-
export declare const envVarSDKApiBaseURL = "RUN_SDK_API_URL";
|
|
9
|
-
export declare const envVarSelfRefURL = "RUN_SELF_REF_URL";
|
|
10
|
-
export declare const envVarCredsBaseURL = "RUN_CREDENTIALS_SERVICE_INTERNAL_URL";
|
|
11
|
-
export declare const envVarOtelTracesURL = "RUN_OTEL_TRACES_URL";
|
|
12
|
-
export declare const envVarVersion = "RUN_SERVICE_VERSION";
|
|
13
|
-
export declare const envVarConfigFile = "RUN_CONFIG_FILE";
|
|
14
|
-
export declare const envVarClientId = "RUN_CLIENT_ID";
|
|
15
|
-
export declare const envVarClientSecret = "RUN_CLIENT_SECRET";
|
|
16
|
-
export declare const envVarTokenEndpoint = "RUN_TOKEN_ENDPOINT";
|
|
17
|
-
export declare const envVarInternalToken = "RUN_INTERNAL_TOKEN";
|
|
18
|
-
export declare const envVarLocalRun = "RUN_LOCAL";
|
|
19
|
-
export declare const cronPort = 3001;
|
|
20
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/constants.ts"],"names":[],"mappings":"AAGA,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,mBAAmB,oBAAoB,CAAC;AACrD,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;AAG1C,eAAO,MAAM,QAAQ,OAAO,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//TODO(@teo): remove this file, it is implemented in the src/internal/constants.ts directory now.
|
|
2
|
-
// This file contains constants used in the Versori DSL HTTP client.
|
|
3
|
-
export const envVarOrgId = 'RUN_ORGANISATION_ID';
|
|
4
|
-
export const envVarEnvId = 'RUN_ENVIRONMENT_ID';
|
|
5
|
-
export const envVarEnvironmentName = 'RUN_ENVIRONMENT';
|
|
6
|
-
export const envVarProjectId = 'RUN_SERVICE_ID';
|
|
7
|
-
export const envVarOrgSlug = 'RUN_ORGANISATION_SLUG';
|
|
8
|
-
export const envVarPlatformApiBaseURL = 'RUN_PLATFORM_API_INTERNAL_URL';
|
|
9
|
-
export const envVarCronApiBaseURL = 'RUN_CRON_API_INTERNAL_URL';
|
|
10
|
-
export const envVarSDKApiBaseURL = 'RUN_SDK_API_URL';
|
|
11
|
-
export const envVarSelfRefURL = 'RUN_SELF_REF_URL';
|
|
12
|
-
export const envVarCredsBaseURL = 'RUN_CREDENTIALS_SERVICE_INTERNAL_URL';
|
|
13
|
-
export const envVarOtelTracesURL = 'RUN_OTEL_TRACES_URL';
|
|
14
|
-
export const envVarVersion = 'RUN_SERVICE_VERSION';
|
|
15
|
-
// The following environment variables are used for the config file
|
|
16
|
-
export const envVarConfigFile = 'RUN_CONFIG_FILE';
|
|
17
|
-
// The following environment variables are used for internal authentication
|
|
18
|
-
export const envVarClientId = 'RUN_CLIENT_ID';
|
|
19
|
-
export const envVarClientSecret = 'RUN_CLIENT_SECRET';
|
|
20
|
-
export const envVarTokenEndpoint = 'RUN_TOKEN_ENDPOINT';
|
|
21
|
-
export const envVarInternalToken = 'RUN_INTERNAL_TOKEN';
|
|
22
|
-
// The following are for running locally
|
|
23
|
-
export const envVarLocalRun = 'RUN_LOCAL';
|
|
24
|
-
// please no changerino
|
|
25
|
-
export const cronPort = 3001; // The port on which the cron API communicates with the service
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type internalAuthHeader = {
|
|
2
|
-
[key: string]: string;
|
|
3
|
-
};
|
|
4
|
-
export declare class InternalAuth {
|
|
5
|
-
private clientId;
|
|
6
|
-
private clientSecret;
|
|
7
|
-
private tokenEndpoint;
|
|
8
|
-
private runLocal;
|
|
9
|
-
private accessToken;
|
|
10
|
-
private expiresAt;
|
|
11
|
-
constructor();
|
|
12
|
-
getAuthHeader(): Promise<internalAuthHeader>;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=internalauth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,90 +0,0 @@
|
|
|
1
|
-
import { getVersoriCookie } from './cli.js';
|
|
2
|
-
import { envVarClientId, envVarClientSecret, envVarInternalToken, envVarLocalRun, envVarTokenEndpoint, } from './constants.js';
|
|
3
|
-
export class InternalAuth {
|
|
4
|
-
constructor() {
|
|
5
|
-
Object.defineProperty(this, "clientId", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
configurable: true,
|
|
8
|
-
writable: true,
|
|
9
|
-
value: void 0
|
|
10
|
-
});
|
|
11
|
-
Object.defineProperty(this, "clientSecret", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
configurable: true,
|
|
14
|
-
writable: true,
|
|
15
|
-
value: void 0
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(this, "tokenEndpoint", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
configurable: true,
|
|
20
|
-
writable: true,
|
|
21
|
-
value: void 0
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(this, "runLocal", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true,
|
|
27
|
-
value: void 0
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(this, "accessToken", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true,
|
|
33
|
-
value: void 0
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(this, "expiresAt", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
configurable: true,
|
|
38
|
-
writable: true,
|
|
39
|
-
value: void 0
|
|
40
|
-
});
|
|
41
|
-
this.clientId = Deno.env.get(envVarClientId) || '';
|
|
42
|
-
this.clientSecret = Deno.env.get(envVarClientSecret) || '';
|
|
43
|
-
this.tokenEndpoint = Deno.env.get(envVarTokenEndpoint) || '';
|
|
44
|
-
this.accessToken = '';
|
|
45
|
-
this.expiresAt = 0;
|
|
46
|
-
this.runLocal = Deno.env.get(envVarLocalRun) === 'true';
|
|
47
|
-
if (Deno.env.get(envVarInternalToken)) {
|
|
48
|
-
this.accessToken = Deno.env.get(envVarInternalToken) || '';
|
|
49
|
-
this.expiresAt = Date.now() + 365 * 24 * 60 * 60 * 1000; // expires in 1 year
|
|
50
|
-
console.log(`Using static token provided by ${envVarInternalToken}`);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (this.runLocal) {
|
|
54
|
-
console.info('Running in local mode using cookie for authentication');
|
|
55
|
-
this.accessToken = getVersoriCookie();
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (!this.clientId || !this.clientSecret || !this.tokenEndpoint) {
|
|
59
|
-
const missingVars = [];
|
|
60
|
-
if (!this.clientId)
|
|
61
|
-
missingVars.push(envVarClientId);
|
|
62
|
-
if (!this.clientSecret)
|
|
63
|
-
missingVars.push(envVarClientSecret);
|
|
64
|
-
if (!this.tokenEndpoint)
|
|
65
|
-
missingVars.push(envVarTokenEndpoint);
|
|
66
|
-
throw new Error(`Missing environment variables: ${missingVars.join(', ')}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
async getAuthHeader() {
|
|
70
|
-
if (this.runLocal) {
|
|
71
|
-
return { 'Cookie': this.accessToken };
|
|
72
|
-
}
|
|
73
|
-
if (this.accessToken && this.expiresAt > Date.now()) {
|
|
74
|
-
return { 'X-Versori-Internal-Token': this.accessToken };
|
|
75
|
-
}
|
|
76
|
-
const encoded = btoa(`${this.clientId}:${this.clientSecret}`);
|
|
77
|
-
const response = await fetch(this.tokenEndpoint, {
|
|
78
|
-
method: 'POST',
|
|
79
|
-
headers: {
|
|
80
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
81
|
-
Authorization: `Basic ${encoded}`,
|
|
82
|
-
},
|
|
83
|
-
body: `grant_type=client_credentials`,
|
|
84
|
-
});
|
|
85
|
-
const data = await response.json();
|
|
86
|
-
this.accessToken = data.access_token;
|
|
87
|
-
this.expiresAt = Date.now() + data.expires_in * 1000 - 2 * 60 * 1000; // 2 minutes before expiration
|
|
88
|
-
return { 'X-Versori-Internal-Token': this.accessToken };
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Logger } from '../../../observability/mod.js';
|
|
2
|
-
import { Activation, Connection, ConnectionProvider } from '../types.js';
|
|
3
|
-
export declare class PlatformAPIClient implements ConnectionProvider {
|
|
4
|
-
private baseUrl;
|
|
5
|
-
private orgId;
|
|
6
|
-
private envId;
|
|
7
|
-
private internalAuth;
|
|
8
|
-
private log;
|
|
9
|
-
constructor(baseUrl: string, orgId: string, envId: string, log: Logger);
|
|
10
|
-
static fromEnv(): PlatformAPIClient;
|
|
11
|
-
getStaticConnection(cnxId: string): Promise<Connection | undefined>;
|
|
12
|
-
getUserActivations(userId: string): Promise<Activation[]>;
|
|
13
|
-
getStaticActivation(): Promise<Activation | undefined>;
|
|
14
|
-
getActivation(activationId: string): Promise<Activation | undefined>;
|
|
15
|
-
getActivationConnection(templateId: string, activationId: string): Promise<Connection | undefined>;
|
|
16
|
-
listActivations(): Promise<Activation[]>;
|
|
17
|
-
updateDynamicVariable(activationId: string, name: string, value: unknown): Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=platformapi.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platformapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/platformapi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAqBzE,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,CAAC,UAAU,GAAG,SAAS,CAAC;IAgBnE,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAuBzD,mBAAmB,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAgCtD,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"}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { ConsoleLogger } from '../../../mod.js';
|
|
2
|
-
import { ActivationImpl } from './activation.js';
|
|
3
|
-
import { envVarEnvId, envVarOrgId, envVarPlatformApiBaseURL } from './constants.js';
|
|
4
|
-
import { InternalAuth } from './internalauth.js';
|
|
5
|
-
export class PlatformAPIClient {
|
|
6
|
-
constructor(baseUrl, orgId, envId, log) {
|
|
7
|
-
Object.defineProperty(this, "baseUrl", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true,
|
|
11
|
-
value: void 0
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(this, "orgId", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value: void 0
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(this, "envId", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true,
|
|
23
|
-
value: void 0
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(this, "internalAuth", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
value: void 0
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(this, "log", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
configurable: true,
|
|
34
|
-
writable: true,
|
|
35
|
-
value: void 0
|
|
36
|
-
});
|
|
37
|
-
this.baseUrl = baseUrl;
|
|
38
|
-
this.orgId = orgId;
|
|
39
|
-
this.envId = envId;
|
|
40
|
-
this.internalAuth = new InternalAuth();
|
|
41
|
-
this.log = log;
|
|
42
|
-
}
|
|
43
|
-
static fromEnv() {
|
|
44
|
-
const baseUrl = Deno.env.get(envVarPlatformApiBaseURL);
|
|
45
|
-
const orgId = Deno.env.get(envVarOrgId);
|
|
46
|
-
const envId = Deno.env.get(envVarEnvId);
|
|
47
|
-
const log = new ConsoleLogger('debug');
|
|
48
|
-
if (!baseUrl || !orgId || !envId) {
|
|
49
|
-
throw new Error('Missing required environment variables');
|
|
50
|
-
}
|
|
51
|
-
return new PlatformAPIClient(baseUrl, orgId, envId, log);
|
|
52
|
-
}
|
|
53
|
-
async getStaticConnection(cnxId) {
|
|
54
|
-
const authHeader = await this.internalAuth.getAuthHeader();
|
|
55
|
-
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/connections/${cnxId}`, {
|
|
56
|
-
headers: authHeader,
|
|
57
|
-
});
|
|
58
|
-
if (!resp.ok) {
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
const result = (await resp.json());
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
async getUserActivations(userId) {
|
|
65
|
-
const authHeader = await this.internalAuth.getAuthHeader();
|
|
66
|
-
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environment/${this.envId}/users/${userId}/activations`, {
|
|
67
|
-
headers: authHeader,
|
|
68
|
-
});
|
|
69
|
-
if (!resp.ok) {
|
|
70
|
-
return [];
|
|
71
|
-
}
|
|
72
|
-
const activations = (await resp.json());
|
|
73
|
-
const result = activations.map((act) => {
|
|
74
|
-
return new ActivationImpl(act.id, act.user, this, this.log, act.dynamicVariables);
|
|
75
|
-
});
|
|
76
|
-
return result;
|
|
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 activations = (await resp.json());
|
|
87
|
-
if (!activations) {
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
if (activations.length === 0) {
|
|
91
|
-
return undefined;
|
|
92
|
-
}
|
|
93
|
-
return new ActivationImpl(activations[0].id, activations[0].user, this, this.log, activations[0].dynamicVariables);
|
|
94
|
-
}
|
|
95
|
-
async getActivation(activationId) {
|
|
96
|
-
const authHeader = await this.internalAuth.getAuthHeader();
|
|
97
|
-
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environments/${this.envId}/activations/${activationId}`, {
|
|
98
|
-
headers: authHeader,
|
|
99
|
-
});
|
|
100
|
-
if (!resp.ok) {
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
|
-
const act = (await resp.json());
|
|
104
|
-
return new ActivationImpl(act.id, act.user, this, this.log, act.dynamicVariables);
|
|
105
|
-
}
|
|
106
|
-
async getActivationConnection(templateId, activationId) {
|
|
107
|
-
const authHeader = await this.internalAuth.getAuthHeader();
|
|
108
|
-
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environment-systems/${templateId}/activations/${activationId}`, {
|
|
109
|
-
headers: authHeader,
|
|
110
|
-
});
|
|
111
|
-
if (!resp.ok) {
|
|
112
|
-
return undefined;
|
|
113
|
-
}
|
|
114
|
-
const result = (await resp.json());
|
|
115
|
-
return result;
|
|
116
|
-
}
|
|
117
|
-
async listActivations() {
|
|
118
|
-
const authHeader = await this.internalAuth.getAuthHeader();
|
|
119
|
-
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environments/${this.envId}/activations`, {
|
|
120
|
-
headers: authHeader,
|
|
121
|
-
});
|
|
122
|
-
if (!resp.ok) {
|
|
123
|
-
return [];
|
|
124
|
-
}
|
|
125
|
-
const activations = (await resp.json());
|
|
126
|
-
const result = activations.map((act) => {
|
|
127
|
-
return new ActivationImpl(act.id, act.user, this, this.log, act.dynamicVariables);
|
|
128
|
-
});
|
|
129
|
-
return result;
|
|
130
|
-
}
|
|
131
|
-
async updateDynamicVariable(activationId, name, value) {
|
|
132
|
-
this.log.debug(`value is ${JSON.stringify(value)}`);
|
|
133
|
-
const authHeader = await this.internalAuth.getAuthHeader();
|
|
134
|
-
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environments/${this.envId}/activations/${activationId}/variables/${name}`, {
|
|
135
|
-
method: 'PUT',
|
|
136
|
-
headers: {
|
|
137
|
-
...authHeader,
|
|
138
|
-
'Content-Type': 'application/json',
|
|
139
|
-
},
|
|
140
|
-
body: JSON.stringify({
|
|
141
|
-
value,
|
|
142
|
-
}),
|
|
143
|
-
});
|
|
144
|
-
if (!resp.ok) {
|
|
145
|
-
throw new Error(`Failed to update dynamic variable ${name}`);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Logger } from '../../../observability/mod.js';
|
|
2
|
-
import { PlatformApi } from '../../../services/platform/mod.js';
|
|
3
|
-
import { BaseUrlFetcher, ConfigReader, DynamicFetcher, RoundTripperFactory } from '../types.js';
|
|
4
|
-
import { CredentialsProvider } from './contextcredentials.js';
|
|
5
|
-
export declare class ProxyRoundTripper implements RoundTripperFactory {
|
|
6
|
-
private platformApiBaseUrl;
|
|
7
|
-
private cfgReader;
|
|
8
|
-
private platformApi;
|
|
9
|
-
private internalAuth;
|
|
10
|
-
private log;
|
|
11
|
-
private organisationId;
|
|
12
|
-
private envId;
|
|
13
|
-
constructor(log: Logger, platformApiBaseUrl: string, platformApi: PlatformApi, cfgReader: ConfigReader, orgId: string, envId: string);
|
|
14
|
-
static fromEnv(log: Logger): ProxyRoundTripper;
|
|
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(): CredentialsProvider;
|
|
21
|
-
baseUrlFetcher(_templateName: string): BaseUrlFetcher;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=proxyroundtripper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proxyroundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/proxyroundtripper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAmB,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAc,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAG5G,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAU9D,qBAAa,iBAAkB,YAAW,mBAAmB;IACzD,OAAO,CAAC,kBAAkB,CAAS;IAEnC,OAAO,CAAC,SAAS,CAAe;IAEhC,OAAO,CAAC,WAAW,CAAc;IAEjC,OAAO,CAAC,YAAY,CAAe;IAEnC,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,KAAK,CAAS;gBAGlB,GAAG,EAAE,MAAM,EACX,kBAAkB,EAAE,MAAM,EAC1B,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,YAAY,EACvB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM;IAWjB,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB;IA4B9C,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;IAwCxE,WAAW,IAAI,mBAAmB;IAoBlC,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc;CAKxD"}
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { PlatformApiImpl } from '../../../services/platform/mod.js';
|
|
2
|
-
import { VersoriConfigReader } from './configloader.js';
|
|
3
|
-
import { envVarEnvId, envVarOrgId, envVarPlatformApiBaseURL } from './constants.js';
|
|
4
|
-
import { isValidURL } from './helpers.js';
|
|
5
|
-
import { InternalAuth } from './internalauth.js';
|
|
6
|
-
// TODO(@teo): there's a stub implementation of this at src/connection/ProxyConnectionFactory.ts, it may be worth
|
|
7
|
-
// skipping this for getting performance tests over the line, and implement this next week when things calm down. We
|
|
8
|
-
// can sort out running locally another day.
|
|
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
|
-
export class ProxyRoundTripper {
|
|
12
|
-
constructor(log, platformApiBaseUrl, platformApi, cfgReader, orgId, envId) {
|
|
13
|
-
Object.defineProperty(this, "platformApiBaseUrl", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value: void 0
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(this, "cfgReader", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true,
|
|
23
|
-
value: void 0
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(this, "platformApi", {
|
|
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
|
-
Object.defineProperty(this, "organisationId", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
configurable: true,
|
|
46
|
-
writable: true,
|
|
47
|
-
value: void 0
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(this, "envId", {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
configurable: true,
|
|
52
|
-
writable: true,
|
|
53
|
-
value: void 0
|
|
54
|
-
});
|
|
55
|
-
this.cfgReader = cfgReader;
|
|
56
|
-
this.log = log;
|
|
57
|
-
this.platformApiBaseUrl = platformApiBaseUrl;
|
|
58
|
-
this.platformApi = platformApi;
|
|
59
|
-
this.internalAuth = new InternalAuth();
|
|
60
|
-
this.organisationId = orgId;
|
|
61
|
-
this.envId = envId;
|
|
62
|
-
}
|
|
63
|
-
static fromEnv(log) {
|
|
64
|
-
const baseUrl = Deno.env.get(envVarPlatformApiBaseURL);
|
|
65
|
-
const orgId = Deno.env.get(envVarOrgId);
|
|
66
|
-
const envId = Deno.env.get(envVarEnvId);
|
|
67
|
-
const cfgReader = VersoriConfigReader.fromEnv(log);
|
|
68
|
-
if (!baseUrl || !orgId || !envId) {
|
|
69
|
-
const missingVars = [];
|
|
70
|
-
if (!baseUrl)
|
|
71
|
-
missingVars.push(envVarPlatformApiBaseURL);
|
|
72
|
-
if (!orgId)
|
|
73
|
-
missingVars.push(envVarOrgId);
|
|
74
|
-
if (!envId)
|
|
75
|
-
missingVars.push(envVarEnvId);
|
|
76
|
-
log.error(`Missing required environment variables: ${missingVars.join(', ')}`);
|
|
77
|
-
throw new Error('Missing required environment variables: ' + missingVars.join(', '));
|
|
78
|
-
}
|
|
79
|
-
return new ProxyRoundTripper(log, baseUrl, PlatformApiImpl.create(baseUrl), cfgReader, orgId, envId);
|
|
80
|
-
}
|
|
81
|
-
makeProxyUrlString(url, cnxId) {
|
|
82
|
-
if (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.cfgReader.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.cfgReader.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 { data: conn } = await this.platformApi.getActivationConnection({
|
|
161
|
-
path: {
|
|
162
|
-
organisation_id: this.organisationId,
|
|
163
|
-
env_system_id: template,
|
|
164
|
-
activation_id: activation.id,
|
|
165
|
-
},
|
|
166
|
-
});
|
|
167
|
-
if (!conn) {
|
|
168
|
-
this.log.error(`Connection not found for activation ${activation.id} and template ${template}, using default fetch`);
|
|
169
|
-
return globalThis.fetch(input, init);
|
|
170
|
-
}
|
|
171
|
-
const proxyInput = this.makeProxyInput(input, conn.id);
|
|
172
|
-
const proxyInit = await this.makeProxyInit(init);
|
|
173
|
-
this.log.info('proxy input and init', { input: proxyInput, init: proxyInit });
|
|
174
|
-
return globalThis.fetch(proxyInput, proxyInit);
|
|
175
|
-
};
|
|
176
|
-
return Promise.resolve(_fn);
|
|
177
|
-
}
|
|
178
|
-
credentials() {
|
|
179
|
-
return {
|
|
180
|
-
getRaw: (_name, _actId) => {
|
|
181
|
-
return Promise.reject(new Error('Not implemented, getRaw is not supported in proxy mode'));
|
|
182
|
-
},
|
|
183
|
-
getAccessToken: (_name, _forceRefresh, _actId) => {
|
|
184
|
-
return Promise.reject(new Error('Not implemented, getAccessToken is not supported in proxy mode'));
|
|
185
|
-
},
|
|
186
|
-
getOAuth1Metadata: (_name, _actId) => {
|
|
187
|
-
return Promise.reject(new Error('Not implemented, getOAuth1Metadata is not supported in proxy mode'));
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
baseUrlFetcher(_templateName) {
|
|
192
|
-
return async (_activationId) => {
|
|
193
|
-
return Promise.resolve("do not use this here");
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { QueueAPI } from '../interpreter/durable/Queue.js';
|
|
2
|
-
import { Workflow } from '../interpreter/durable/Queue.js';
|
|
3
|
-
import { ActivationImpl } from './ActivationImpl.js';
|
|
4
|
-
export type WorkflowOpts = {
|
|
5
|
-
maxAttempts?: number;
|
|
6
|
-
data?: unknown;
|
|
7
|
-
dataRaw?: string;
|
|
8
|
-
};
|
|
9
|
-
export interface WorkflowInterface {
|
|
10
|
-
startWorkflow(group: string, opts: WorkflowOpts): Promise<Workflow>;
|
|
11
|
-
getWorkflow(wfs: Workflow): Promise<Workflow>;
|
|
12
|
-
getWorkflowById(id: string): Promise<Workflow>;
|
|
13
|
-
waitForCompletion(wf: Workflow): Promise<Workflow>;
|
|
14
|
-
rescheduleWorkflow(wf: Workflow, after: string): Promise<void>;
|
|
15
|
-
completeWorkflow(wf: Workflow, status: 'completed' | 'failed', output?: any): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
export declare class WorkflowImpl implements WorkflowInterface {
|
|
18
|
-
private queue;
|
|
19
|
-
private executionId;
|
|
20
|
-
private activation;
|
|
21
|
-
constructor(queue: QueueAPI, executionId: string, activation: ActivationImpl);
|
|
22
|
-
startWorkflow(group: string, opts: WorkflowOpts): Promise<Workflow>;
|
|
23
|
-
getWorkflow(wf: Workflow): Promise<Workflow>;
|
|
24
|
-
getWorkflowById(id: string): Promise<Workflow>;
|
|
25
|
-
waitForCompletion(wf: Workflow): Promise<Workflow>;
|
|
26
|
-
rescheduleWorkflow(wf: Workflow, after: string): Promise<void>;
|
|
27
|
-
completeWorkflow(wf: Workflow, status: 'completed' | 'failed', output?: any): Promise<void>;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=WorkflowClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WorkflowClient.d.ts","sourceRoot":"","sources":["../../../src/src/context/WorkflowClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAKrD,MAAM,MAAM,YAAY,GAAG;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAC9B,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpE,WAAW,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9C,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/C,iBAAiB,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnD,kBAAkB,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,gBAAgB,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,GAAG,QAAQ,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/F;AAED,qBAAa,YAAa,YAAW,iBAAiB;IAClD,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,UAAU,CAAiB;gBAEvB,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc;IActE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC;IAmBnE,WAAW,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI5C,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI9C,iBAAiB,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IASlD,kBAAkB,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA0B9D,gBAAgB,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,GAAG,QAAQ,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAYpG"}
|