@versori/run 0.2.1 → 0.2.2-alpha.0
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/dsl/http/default.d.ts +2 -2
- package/esm/src/dsl/http/default.d.ts.map +1 -1
- package/esm/src/dsl/http/default.js +6 -5
- package/esm/src/dsl/http/types.d.ts +2 -2
- package/esm/src/dsl/http/types.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/constants.d.ts +2 -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/contextcredentials.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/credentials/client.d.ts +1 -1
- package/esm/src/dsl/http/versori/credentials/client.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/credentials/client.js +4 -4
- package/esm/src/dsl/http/versori/roundtripper.d.ts +8 -6
- package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/roundtripper.js +123 -73
- package/esm/src/dsl/tasks/HttpTask.d.ts +1 -1
- package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/esm/src/dsl/tasks/HttpTask.js +4 -2
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +6 -2
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +68 -14
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts +2 -0
- 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 +24 -7
- package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/fn.js +12 -6
- package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/http.js +30 -6
- package/esm/src/interpreter/memory/compilers/parallel.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 +29 -3
- package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/package.json +5 -1
- package/script/src/dsl/http/default.d.ts +2 -2
- package/script/src/dsl/http/default.d.ts.map +1 -1
- package/script/src/dsl/http/default.js +6 -5
- package/script/src/dsl/http/types.d.ts +2 -2
- package/script/src/dsl/http/types.d.ts.map +1 -1
- package/script/src/dsl/http/versori/constants.d.ts +2 -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/contextcredentials.d.ts.map +1 -1
- package/script/src/dsl/http/versori/credentials/client.d.ts +1 -1
- package/script/src/dsl/http/versori/credentials/client.d.ts.map +1 -1
- package/script/src/dsl/http/versori/credentials/client.js +3 -3
- package/script/src/dsl/http/versori/roundtripper.d.ts +8 -6
- package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/script/src/dsl/http/versori/roundtripper.js +123 -73
- package/script/src/dsl/tasks/HttpTask.d.ts +1 -1
- package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/script/src/dsl/tasks/HttpTask.js +4 -2
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +6 -2
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +68 -14
- package/script/src/interpreter/memory/ObservableCompiler.d.ts +2 -0
- 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 +24 -7
- package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/fn.js +12 -6
- package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/http.js +30 -6
- package/script/src/interpreter/memory/compilers/parallel.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 +29 -3
- package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
|
@@ -18,8 +18,8 @@ export declare class DefaultRoundTripperFactory implements RoundTripperFactory {
|
|
|
18
18
|
* @param fn - The fetch function to be used. Defaults to the global fetch function.
|
|
19
19
|
* @returns A promise that resolves to the fetch function.
|
|
20
20
|
*/
|
|
21
|
-
create(connName: string
|
|
22
|
-
createDynamic(templateName: string
|
|
21
|
+
create(connName: string): Promise<typeof fetch>;
|
|
22
|
+
createDynamic(templateName: string): Promise<DynamicFetcher>;
|
|
23
23
|
credentials(): Credentials;
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=default.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/http/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/http/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D;;;;GAIG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IAClE;;OAEG;;IAIH;;;;;;;OAOG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,CAAC;IAI/C,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAMlE,WAAW,IAAI,WAAW;CAU7B"}
|
|
@@ -7,7 +7,8 @@ export class DefaultRoundTripperFactory {
|
|
|
7
7
|
/**
|
|
8
8
|
* Constructs a new instance of the DefaultRoundTripperFactory.
|
|
9
9
|
*/
|
|
10
|
-
constructor() {
|
|
10
|
+
constructor() {
|
|
11
|
+
}
|
|
11
12
|
/**
|
|
12
13
|
* Creates a round tripper function.
|
|
13
14
|
* This implementation simply returns the fetch function passed to it.
|
|
@@ -16,12 +17,12 @@ export class DefaultRoundTripperFactory {
|
|
|
16
17
|
* @param fn - The fetch function to be used. Defaults to the global fetch function.
|
|
17
18
|
* @returns A promise that resolves to the fetch function.
|
|
18
19
|
*/
|
|
19
|
-
async create(connName
|
|
20
|
-
return
|
|
20
|
+
async create(connName) {
|
|
21
|
+
return globalThis.fetch;
|
|
21
22
|
}
|
|
22
|
-
async createDynamic(templateName
|
|
23
|
+
async createDynamic(templateName) {
|
|
23
24
|
return async (activation, input, init) => {
|
|
24
|
-
return fetch(input, init);
|
|
25
|
+
return globalThis.fetch(input, init);
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
credentials() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type DynamicFetcher = (activation: Activation, input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
2
2
|
export interface RoundTripperFactory {
|
|
3
|
-
create(connName: string
|
|
4
|
-
createDynamic(templateName: string
|
|
3
|
+
create(connName: string): Promise<typeof fetch | undefined>;
|
|
4
|
+
createDynamic(templateName: string): Promise<DynamicFetcher | undefined>;
|
|
5
5
|
}
|
|
6
6
|
export declare function wrapDynamicFetcher(fetcher: DynamicFetcher, activation: Activation): typeof fetch;
|
|
7
7
|
export interface ConnectionProvider {
|
|
@@ -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,IAA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C,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC3B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC"}
|
|
@@ -7,6 +7,8 @@ export declare const envVarPlatformApiBaseURL = "RUN_PLATFORM_API_INTERNAL_URL";
|
|
|
7
7
|
export declare const envVarCronApiBaseURL = "RUN_CRON_API_INTERNAL_URL";
|
|
8
8
|
export declare const envVarSelfRefURL = "RUN_SELF_REF_URL";
|
|
9
9
|
export declare const envVarCredsBaseURL = "RUN_CREDENTIALS_SERVICE_INTERNAL_URL";
|
|
10
|
+
export declare const envVarOtelTracesURL = "RUN_OTEL_TRACES_URL";
|
|
11
|
+
export declare const envVarVersion = "RUN_SERVICE_VERSION";
|
|
10
12
|
export declare const envVarConfigFile = "RUN_CONFIG_FILE";
|
|
11
13
|
export declare const envVarClientId = "RUN_CLIENT_ID";
|
|
12
14
|
export declare const envVarClientSecret = "RUN_CLIENT_SECRET";
|
|
@@ -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;
|
|
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"}
|
|
@@ -8,6 +8,8 @@ export const envVarPlatformApiBaseURL = 'RUN_PLATFORM_API_INTERNAL_URL';
|
|
|
8
8
|
export const envVarCronApiBaseURL = 'RUN_CRON_API_INTERNAL_URL';
|
|
9
9
|
export const envVarSelfRefURL = 'RUN_SELF_REF_URL';
|
|
10
10
|
export const envVarCredsBaseURL = 'RUN_CREDENTIALS_SERVICE_INTERNAL_URL';
|
|
11
|
+
export const envVarOtelTracesURL = 'RUN_OTEL_TRACES_URL';
|
|
12
|
+
export const envVarVersion = 'RUN_SERVICE_VERSION';
|
|
11
13
|
// The following environment variables are used for the config file
|
|
12
14
|
export const envVarConfigFile = 'RUN_CONFIG_FILE';
|
|
13
15
|
// The following environment variables are used for internal authentication
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextcredentials.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/contextcredentials.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,IAAI,CAAC;CACjB,
|
|
1
|
+
{"version":3,"file":"contextcredentials.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/contextcredentials.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,WAAW;IACxB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAE1C,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CACxE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GetTokenResponse } from './tokens/v1/token_service_pb.js';
|
|
2
2
|
import { GetCredentialResponse } from './v1alpha1/credential_service_pb.js';
|
|
3
3
|
export declare class VersoriCredentialClient {
|
|
4
|
-
private
|
|
4
|
+
private tokenClient;
|
|
5
5
|
private credentialsClient;
|
|
6
6
|
constructor(credsBaseUrl: string);
|
|
7
7
|
getToken(credId: string, forceRefresh?: boolean): Promise<GetTokenResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/src/dsl/http/versori/credentials/client.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,qBAAa,uBAAuB;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/src/dsl/http/versori/credentials/client.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,qBAAa,uBAAuB;IAChC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,iBAAiB,CAAoB;gBAEjC,YAAY,EAAE,MAAM;IAKhC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,GAAE,OAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIlF,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAGzD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createCredentialsClient, createTokenClient, } from './credentials.js';
|
|
2
2
|
export class VersoriCredentialClient {
|
|
3
3
|
constructor(credsBaseUrl) {
|
|
4
|
-
Object.defineProperty(this, "
|
|
4
|
+
Object.defineProperty(this, "tokenClient", {
|
|
5
5
|
enumerable: true,
|
|
6
6
|
configurable: true,
|
|
7
7
|
writable: true,
|
|
@@ -13,11 +13,11 @@ export class VersoriCredentialClient {
|
|
|
13
13
|
writable: true,
|
|
14
14
|
value: void 0
|
|
15
15
|
});
|
|
16
|
-
this.
|
|
16
|
+
this.tokenClient = createTokenClient(credsBaseUrl);
|
|
17
17
|
this.credentialsClient = createCredentialsClient(credsBaseUrl);
|
|
18
18
|
}
|
|
19
19
|
getToken(credId, forceRefresh = false) {
|
|
20
|
-
return this.
|
|
20
|
+
return this.tokenClient.getToken({ credentialId: credId, forceRefresh });
|
|
21
21
|
}
|
|
22
22
|
getRaw(credId) {
|
|
23
23
|
return this.credentialsClient.get({ id: credId, showRedacted: true });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Tracer } from '@opentelemetry/api';
|
|
1
2
|
import { Logger } from '../../../observability/logging/Logger.js';
|
|
2
3
|
import { DynamicFetcher, RoundTripperFactory } from '../types.js';
|
|
3
4
|
import { Credentials, Token } from './contextcredentials.js';
|
|
@@ -7,7 +8,6 @@ import { PlatformAPIClient } from './platformapi.js';
|
|
|
7
8
|
* VersoriRoundTripper is an implementation of the RoundTripperFactory interface for Versori connections.
|
|
8
9
|
* This is the intended implementation for when projects/services are hosted on Versori infrastructure.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```typescript
|
|
13
13
|
* const factory = new VersoriCredentialsFactory(connectAPIClient, tokenClient);
|
|
@@ -21,14 +21,16 @@ export declare class VersoriCredentialsFactory implements RoundTripperFactory {
|
|
|
21
21
|
private platformAPIClient;
|
|
22
22
|
private versoriCfg;
|
|
23
23
|
private log;
|
|
24
|
-
|
|
25
|
-
static fromEnv(logger?: Logger): VersoriCredentialsFactory;
|
|
26
|
-
create(connName: string, fn?: typeof fetch): Promise<typeof fetch | undefined>;
|
|
27
|
-
createDynamic(templateName: string, fn?: typeof fetch): Promise<DynamicFetcher | undefined>;
|
|
28
|
-
credentials(): Credentials;
|
|
24
|
+
private tracer;
|
|
29
25
|
private readonly defaultDynamic;
|
|
26
|
+
constructor(credsClient: VersoriCredentialClient, credsBaseURL: string, platformAPIClient: PlatformAPIClient, logger: Logger, tracer: Tracer);
|
|
27
|
+
static fromEnv(logger: Logger, tracer: Tracer): VersoriCredentialsFactory;
|
|
30
28
|
private changeRequestInit;
|
|
31
29
|
private changeBaseUrl;
|
|
30
|
+
create(connName: string): Promise<typeof fetch | undefined>;
|
|
31
|
+
createDynamic(templateName: string): Promise<DynamicFetcher | undefined>;
|
|
32
|
+
private traceFetch;
|
|
33
|
+
credentials(): Credentials;
|
|
32
34
|
getTokenByName(name: string, forceRefresh?: boolean): Promise<Token>;
|
|
33
35
|
getRawByName(name: string): Promise<Uint8Array>;
|
|
34
36
|
private getCredentialIDFromName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/roundtripper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EA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AAiB;IAezB,OAAO,CAAC,aAAa;IAwBrB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,GAAG,SAAS,CAAC;IAqC3D,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAgDxE,OAAO,CAAC,UAAU;IAqClB,WAAW,IAAI,WAAW;IAOpB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,UAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;IAiBlE,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;YAoBvC,uBAAuB;IAkBrC,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,aAAa;YAyDP,gBAAgB;YAqChB,kBAAkB;YAmClB,aAAa;YAwEb,QAAQ;CA4BzB"}
|
|
@@ -8,7 +8,6 @@ import { PlatformAPIClient } from './platformapi.js';
|
|
|
8
8
|
* VersoriRoundTripper is an implementation of the RoundTripperFactory interface for Versori connections.
|
|
9
9
|
* This is the intended implementation for when projects/services are hosted on Versori infrastructure.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
11
|
* @example
|
|
13
12
|
* ```typescript
|
|
14
13
|
* const factory = new VersoriCredentialsFactory(connectAPIClient, tokenClient);
|
|
@@ -17,7 +16,7 @@ import { PlatformAPIClient } from './platformapi.js';
|
|
|
17
16
|
* ```
|
|
18
17
|
*/
|
|
19
18
|
export class VersoriCredentialsFactory {
|
|
20
|
-
constructor(credsClient, credsBaseURL, platformAPIClient, logger) {
|
|
19
|
+
constructor(credsClient, credsBaseURL, platformAPIClient, logger, tracer) {
|
|
21
20
|
Object.defineProperty(this, "tokenClient", {
|
|
22
21
|
enumerable: true,
|
|
23
22
|
configurable: true,
|
|
@@ -48,6 +47,12 @@ export class VersoriCredentialsFactory {
|
|
|
48
47
|
writable: true,
|
|
49
48
|
value: void 0
|
|
50
49
|
});
|
|
50
|
+
Object.defineProperty(this, "tracer", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true,
|
|
54
|
+
value: void 0
|
|
55
|
+
});
|
|
51
56
|
Object.defineProperty(this, "defaultDynamic", {
|
|
52
57
|
enumerable: true,
|
|
53
58
|
configurable: true,
|
|
@@ -64,9 +69,12 @@ export class VersoriCredentialsFactory {
|
|
|
64
69
|
this.platformAPIClient = platformAPIClient;
|
|
65
70
|
this.versoriCfg = LoadConfigFromFile();
|
|
66
71
|
this.log = logger;
|
|
72
|
+
this.tracer = tracer;
|
|
73
|
+
// lost 15 minutes because of this one
|
|
74
|
+
this.traceFetch = this.traceFetch.bind(this);
|
|
67
75
|
this.credentials = this.credentials.bind(this);
|
|
68
76
|
}
|
|
69
|
-
static fromEnv(logger) {
|
|
77
|
+
static fromEnv(logger, tracer) {
|
|
70
78
|
const credsBaseURL = Deno.env.get(envVarCredsBaseURL);
|
|
71
79
|
const platformApiBaseURL = Deno.env.get(envVarPlatformApiBaseURL);
|
|
72
80
|
const orgId = Deno.env.get(envVarOrgId);
|
|
@@ -86,9 +94,45 @@ export class VersoriCredentialsFactory {
|
|
|
86
94
|
const log = logger || new ConsoleLogger('debug');
|
|
87
95
|
const pAPIClient = new PlatformAPIClient(platformApiBaseURL, orgId, envId, log);
|
|
88
96
|
const tokenClient = new VersoriCredentialClient(credsBaseURL);
|
|
89
|
-
return new VersoriCredentialsFactory(tokenClient, credsBaseURL, pAPIClient, log);
|
|
97
|
+
return new VersoriCredentialsFactory(tokenClient, credsBaseURL, pAPIClient, log, tracer);
|
|
90
98
|
}
|
|
91
|
-
|
|
99
|
+
// takes the info and modifies the url using changeBaseUrl if necessary
|
|
100
|
+
// if a full valid URL is passed as a string, it will be returned as is
|
|
101
|
+
// if a valid URL object is passed, it will be returned as is
|
|
102
|
+
changeRequestInit(info, conn) {
|
|
103
|
+
if (typeof info === 'string') {
|
|
104
|
+
if (isValidURL(info)) {
|
|
105
|
+
return info;
|
|
106
|
+
}
|
|
107
|
+
return this.changeBaseUrl(info, conn);
|
|
108
|
+
}
|
|
109
|
+
else if (info instanceof URL) {
|
|
110
|
+
return info;
|
|
111
|
+
}
|
|
112
|
+
else if (info instanceof Request) {
|
|
113
|
+
const url = this.changeBaseUrl(info.url, conn);
|
|
114
|
+
return new Request(url, info);
|
|
115
|
+
}
|
|
116
|
+
return info;
|
|
117
|
+
}
|
|
118
|
+
changeBaseUrl(pathname, conn) {
|
|
119
|
+
const connBaseURL = conn.baseUrl;
|
|
120
|
+
// if the connection has no baseUrl set, but the pathname is a valid URL, return it as is
|
|
121
|
+
if (!connBaseURL && isValidURL(pathname)) {
|
|
122
|
+
this.log.debug('Using given URL as is', { url: pathname });
|
|
123
|
+
return pathname;
|
|
124
|
+
}
|
|
125
|
+
const connBaseURLObj = new URL(connBaseURL);
|
|
126
|
+
let _pathname = pathname;
|
|
127
|
+
if (isValidURL(pathname)) {
|
|
128
|
+
const pathnameObj = new URL(pathname);
|
|
129
|
+
_pathname = pathnameObj.pathname;
|
|
130
|
+
}
|
|
131
|
+
const newURL = new URL(_pathname, connBaseURLObj.origin);
|
|
132
|
+
this.log.debug('Using baseURL from connection', { url: newURL.toString() });
|
|
133
|
+
return newURL.toString();
|
|
134
|
+
}
|
|
135
|
+
create(connName) {
|
|
92
136
|
const cnxId = this.getConnectionID(connName);
|
|
93
137
|
if (!cnxId) {
|
|
94
138
|
this.log.debug('Connection not found in config, could be a dynamic connection', {
|
|
@@ -96,32 +140,31 @@ export class VersoriCredentialsFactory {
|
|
|
96
140
|
});
|
|
97
141
|
return Promise.resolve(undefined);
|
|
98
142
|
}
|
|
99
|
-
|
|
143
|
+
const _fn = async (input, init) => {
|
|
100
144
|
const conn = await this.platformAPIClient.getStaticConnection(cnxId);
|
|
101
145
|
if (!conn) {
|
|
102
146
|
this.log.error('Connection not found for user, using default fetch', {
|
|
103
147
|
connectionName: connName,
|
|
104
148
|
});
|
|
105
|
-
return
|
|
149
|
+
return this.traceFetch(input, init);
|
|
106
150
|
}
|
|
107
151
|
const _input = this.changeRequestInit(input, conn);
|
|
108
152
|
switch (conn.credentials[0].authSchemeConfig.type) {
|
|
109
153
|
case 'api-key':
|
|
110
|
-
return (await this.apiKeyFetcher(conn,
|
|
154
|
+
return (await this.apiKeyFetcher(conn, this.traceFetch))(_input, init);
|
|
111
155
|
case 'basic-auth':
|
|
112
|
-
return (await this.basicAuthFetcher(conn,
|
|
156
|
+
return (await this.basicAuthFetcher(conn, this.traceFetch))(_input, init);
|
|
113
157
|
case 'jwt-bearer':
|
|
114
|
-
return (await this.bearerTokenFetcher(conn,
|
|
158
|
+
return (await this.bearerTokenFetcher(conn, this.traceFetch))(_input, init);
|
|
115
159
|
case 'oauth2':
|
|
116
|
-
return (await this.oauth2Fetcher(conn,
|
|
160
|
+
return (await this.oauth2Fetcher(conn, this.traceFetch))(_input, init);
|
|
117
161
|
default:
|
|
118
|
-
return
|
|
162
|
+
return this.traceFetch(_input, init);
|
|
119
163
|
}
|
|
120
|
-
}
|
|
164
|
+
};
|
|
165
|
+
return Promise.resolve(_fn);
|
|
121
166
|
}
|
|
122
|
-
|
|
123
|
-
// if a full valid URL is passed as a string, it will be returned as is
|
|
124
|
-
createDynamic(templateName, fn = globalThis.fetch) {
|
|
167
|
+
createDynamic(templateName) {
|
|
125
168
|
const template = this.getTemplateID(templateName);
|
|
126
169
|
if (!template) {
|
|
127
170
|
this.log.debug('Template not found in config, could be a static connection', {
|
|
@@ -129,7 +172,7 @@ export class VersoriCredentialsFactory {
|
|
|
129
172
|
});
|
|
130
173
|
return Promise.resolve(undefined);
|
|
131
174
|
}
|
|
132
|
-
|
|
175
|
+
const _fn = async (activation, input, init) => {
|
|
133
176
|
const conn = await this.platformAPIClient.getActivationConnection(template, activation.id);
|
|
134
177
|
if (!conn) {
|
|
135
178
|
return this.defaultDynamic('Connection not found for user, using default fetch', {
|
|
@@ -141,16 +184,47 @@ export class VersoriCredentialsFactory {
|
|
|
141
184
|
const _input = this.changeRequestInit(input, conn);
|
|
142
185
|
switch (conn.credentials[0].authSchemeConfig.type) {
|
|
143
186
|
case 'api-key':
|
|
144
|
-
return (await this.apiKeyFetcher(conn,
|
|
187
|
+
return (await this.apiKeyFetcher(conn, this.traceFetch))(_input, init);
|
|
145
188
|
case 'basic-auth':
|
|
146
|
-
return (await this.basicAuthFetcher(conn,
|
|
189
|
+
return (await this.basicAuthFetcher(conn, this.traceFetch))(_input, init);
|
|
147
190
|
case 'jwt-bearer':
|
|
148
|
-
return (await this.bearerTokenFetcher(conn,
|
|
191
|
+
return (await this.bearerTokenFetcher(conn, this.traceFetch))(_input, init);
|
|
149
192
|
case 'oauth2':
|
|
150
|
-
return (await this.oauth2Fetcher(conn,
|
|
193
|
+
return (await this.oauth2Fetcher(conn, this.traceFetch))(_input, init);
|
|
151
194
|
default:
|
|
152
|
-
return
|
|
195
|
+
return this.traceFetch(_input, init);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
return Promise.resolve(_fn);
|
|
199
|
+
}
|
|
200
|
+
traceFetch(input, init) {
|
|
201
|
+
return this.tracer.startActiveSpan('fetch', async (span) => {
|
|
202
|
+
const response = await globalThis.fetch(input, init);
|
|
203
|
+
let url = new URL('http://localhost');
|
|
204
|
+
try {
|
|
205
|
+
url = new URL(input.toString());
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
this.log.error('Error parsing URL when tracing request', { error });
|
|
153
209
|
}
|
|
210
|
+
const method = input instanceof Request ? input.method : 'GET';
|
|
211
|
+
span.setAttributes({
|
|
212
|
+
// Error attributes
|
|
213
|
+
'error.type': response.status >= 400 ? 'HTTP_ERROR' : undefined,
|
|
214
|
+
// HTTP request attributes
|
|
215
|
+
'http.request.method': method,
|
|
216
|
+
'http.response.status_code': response.status,
|
|
217
|
+
// Server attributes
|
|
218
|
+
'server.address': url.hostname,
|
|
219
|
+
'server.port': url.port || (url.protocol === 'https:' ? '443' : '80'),
|
|
220
|
+
// URL attributes
|
|
221
|
+
'url.full': url.toString(),
|
|
222
|
+
'url.path': url.pathname,
|
|
223
|
+
'url.query': url.search,
|
|
224
|
+
'url.scheme': url.protocol.replace(':', ''),
|
|
225
|
+
});
|
|
226
|
+
span.end();
|
|
227
|
+
return response;
|
|
154
228
|
});
|
|
155
229
|
}
|
|
156
230
|
credentials() {
|
|
@@ -159,50 +233,18 @@ export class VersoriCredentialsFactory {
|
|
|
159
233
|
getAccessToken: this.getTokenByName.bind(this),
|
|
160
234
|
};
|
|
161
235
|
}
|
|
162
|
-
// if a valid URL object is passed, it will be returned as is
|
|
163
|
-
changeRequestInit(info, conn) {
|
|
164
|
-
if (typeof info === 'string') {
|
|
165
|
-
if (isValidURL(info)) {
|
|
166
|
-
return info;
|
|
167
|
-
}
|
|
168
|
-
return this.changeBaseUrl(info, conn);
|
|
169
|
-
}
|
|
170
|
-
else if (info instanceof URL) {
|
|
171
|
-
return info;
|
|
172
|
-
}
|
|
173
|
-
else if (info instanceof Request) {
|
|
174
|
-
const url = this.changeBaseUrl(info.url, conn);
|
|
175
|
-
return new Request(url, info);
|
|
176
|
-
}
|
|
177
|
-
return info;
|
|
178
|
-
}
|
|
179
|
-
changeBaseUrl(pathname, conn) {
|
|
180
|
-
const connBaseURL = conn.baseUrl;
|
|
181
|
-
// if the connection has no baseUrl set, but the pathname is a valid URL, return it as is
|
|
182
|
-
if (!connBaseURL && isValidURL(pathname)) {
|
|
183
|
-
this.log.debug('Using given URL as is', { url: pathname });
|
|
184
|
-
return pathname;
|
|
185
|
-
}
|
|
186
|
-
const connBaseURLObj = new URL(connBaseURL);
|
|
187
|
-
let _pathname = pathname;
|
|
188
|
-
if (isValidURL(pathname)) {
|
|
189
|
-
const pathnameObj = new URL(pathname);
|
|
190
|
-
_pathname = pathnameObj.pathname;
|
|
191
|
-
}
|
|
192
|
-
const newURL = new URL(_pathname, connBaseURLObj.origin);
|
|
193
|
-
this.log.debug('Using baseURL from connection', { url: newURL.toString() });
|
|
194
|
-
return newURL.toString();
|
|
195
|
-
}
|
|
196
236
|
async getTokenByName(name, forceRefresh = false) {
|
|
197
237
|
const credId = await this.getCredentialIDFromName(name);
|
|
198
|
-
const token = await this.tokenClient.getToken(credId
|
|
238
|
+
const token = await this.tokenClient.getToken(credId);
|
|
199
239
|
if (!token?.token) {
|
|
200
240
|
throw new Error(`Token not found for connection ${name} with credential ID ${credId}`);
|
|
201
241
|
}
|
|
202
242
|
return {
|
|
203
243
|
accessToken: token.token.accessToken,
|
|
204
244
|
tokenType: token.token.tokenType,
|
|
205
|
-
expiry: token.token.expiry
|
|
245
|
+
expiry: token.token.expiry
|
|
246
|
+
? new Date(Number(token.token.expiry.seconds) * 1000)
|
|
247
|
+
: undefined,
|
|
206
248
|
};
|
|
207
249
|
}
|
|
208
250
|
async getRawByName(name) {
|
|
@@ -211,7 +253,11 @@ export class VersoriCredentialsFactory {
|
|
|
211
253
|
if (!raw) {
|
|
212
254
|
throw new Error(`Raw data not found for connection ${name} with credential ID ${credId}`);
|
|
213
255
|
}
|
|
214
|
-
|
|
256
|
+
let buffer = raw?.credential?.data['raw'] ?? undefined;
|
|
257
|
+
if (!buffer) {
|
|
258
|
+
throw new Error(`Credential ${raw?.credential?.id} is missing raw data, please contact your administrator`);
|
|
259
|
+
}
|
|
260
|
+
return Promise.resolve(buffer);
|
|
215
261
|
}
|
|
216
262
|
async getCredentialIDFromName(name) {
|
|
217
263
|
const conId = this.getConnectionID(name);
|
|
@@ -243,7 +289,7 @@ export class VersoriCredentialsFactory {
|
|
|
243
289
|
return template.templateId;
|
|
244
290
|
}
|
|
245
291
|
apiKeyFetcher(conn, fn) {
|
|
246
|
-
|
|
292
|
+
const _fn = async (input, init) => {
|
|
247
293
|
const tokenResponse = await this.getToken(conn.credentials[0].credential.id);
|
|
248
294
|
const token = tokenResponse.token?.accessToken;
|
|
249
295
|
const asc = conn.credentials[0].authSchemeConfig.apiKey;
|
|
@@ -264,7 +310,7 @@ export class VersoriCredentialsFactory {
|
|
|
264
310
|
if (init.headers instanceof Headers) {
|
|
265
311
|
init.headers.set(asc.name, token);
|
|
266
312
|
}
|
|
267
|
-
else if (
|
|
313
|
+
else if (init.headers instanceof Array) {
|
|
268
314
|
init.headers.push([asc.name, token]);
|
|
269
315
|
}
|
|
270
316
|
else {
|
|
@@ -287,10 +333,11 @@ export class VersoriCredentialsFactory {
|
|
|
287
333
|
break;
|
|
288
334
|
}
|
|
289
335
|
return fn(input, init);
|
|
290
|
-
}
|
|
336
|
+
};
|
|
337
|
+
return Promise.resolve(_fn);
|
|
291
338
|
}
|
|
292
|
-
basicAuthFetcher(conn, fn) {
|
|
293
|
-
|
|
339
|
+
async basicAuthFetcher(conn, fn) {
|
|
340
|
+
const _fn = async (input, init) => {
|
|
294
341
|
const tokenResponse = await this.getToken(conn.credentials[0].credential.id);
|
|
295
342
|
const token = tokenResponse.token?.accessToken;
|
|
296
343
|
if (!token) {
|
|
@@ -315,11 +362,12 @@ export class VersoriCredentialsFactory {
|
|
|
315
362
|
};
|
|
316
363
|
}
|
|
317
364
|
return fn(input, init);
|
|
318
|
-
}
|
|
365
|
+
};
|
|
366
|
+
return Promise.resolve(_fn);
|
|
319
367
|
}
|
|
320
368
|
// TODO: need to make the prefix and header name configurable from authschemeconfig
|
|
321
|
-
bearerTokenFetcher(conn, fn) {
|
|
322
|
-
|
|
369
|
+
async bearerTokenFetcher(conn, fn) {
|
|
370
|
+
const _fn = async (input, init) => {
|
|
323
371
|
const tokenResponse = await this.getToken(conn.credentials[0].credential.id);
|
|
324
372
|
const token = tokenResponse.token?.accessToken;
|
|
325
373
|
if (!token) {
|
|
@@ -344,9 +392,10 @@ export class VersoriCredentialsFactory {
|
|
|
344
392
|
};
|
|
345
393
|
}
|
|
346
394
|
return fn(input, init);
|
|
347
|
-
}
|
|
395
|
+
};
|
|
396
|
+
return Promise.resolve(_fn);
|
|
348
397
|
}
|
|
349
|
-
oauth2Fetcher(conn, fn) {
|
|
398
|
+
async oauth2Fetcher(conn, fn) {
|
|
350
399
|
const refreshFn = async (input, init, forceRefresh = false) => {
|
|
351
400
|
const tokenResponse = await this.getToken(conn.credentials[0].credential.id, forceRefresh);
|
|
352
401
|
const token = tokenResponse.token?.accessToken;
|
|
@@ -387,8 +436,8 @@ export class VersoriCredentialsFactory {
|
|
|
387
436
|
}
|
|
388
437
|
return fn(input, init);
|
|
389
438
|
};
|
|
390
|
-
|
|
391
|
-
const resp = await refreshFn(input, init
|
|
439
|
+
const _fn = async (input, init) => {
|
|
440
|
+
const resp = await refreshFn(input, init);
|
|
392
441
|
if (resp.status === 401) {
|
|
393
442
|
this.log.debug('Received 401 Unauthorized response, attempting refresh', {
|
|
394
443
|
url: input,
|
|
@@ -398,7 +447,8 @@ export class VersoriCredentialsFactory {
|
|
|
398
447
|
return refreshFn(input, init, true);
|
|
399
448
|
}
|
|
400
449
|
return Promise.resolve(resp);
|
|
401
|
-
}
|
|
450
|
+
};
|
|
451
|
+
return Promise.resolve(_fn);
|
|
402
452
|
}
|
|
403
453
|
async getToken(id, forceRefresh = false) {
|
|
404
454
|
try {
|
|
@@ -407,7 +457,7 @@ export class VersoriCredentialsFactory {
|
|
|
407
457
|
catch (error) {
|
|
408
458
|
this.log.error('unable to get credential', { error });
|
|
409
459
|
if (error instanceof ConnectError) {
|
|
410
|
-
if (error.rawMessage.includes(
|
|
460
|
+
if (error.rawMessage.includes('connection error received: not a result of an error') && error.code === Code.Internal) {
|
|
411
461
|
this.log.info('Connection error received, attempting to reconnect');
|
|
412
462
|
this.tokenClient = new VersoriCredentialClient(this.credsBaseURL);
|
|
413
463
|
return await this.tokenClient.getToken(id);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, ContextImpl } from '../../context/Context.js';
|
|
2
|
-
import {
|
|
2
|
+
import { KeyValue, KeyValueScope } from '../../kv/KeyValue.js';
|
|
3
3
|
import { Logger } from '../../observability/logging/Logger.js';
|
|
4
4
|
import { Activation, DynamicFetcher } from '../http/types.js';
|
|
5
5
|
import { Credentials } from '../http/versori/contextcredentials.js';
|
|
@@ -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,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,
|
|
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,QAAQ,EAAE,aAAa,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,EAAE,MAAM,YAAY,CAAC;AAMjE,MAAM,WAAW,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAE,SAAQ,OAAO,CAAC,IAAI,CAAC;IAC5E,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACzC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvD;AAED,MAAM,MAAM,eAAe,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,IAAI,CAC/C,GAAG,EAAE,WAAW,CAAC,EAAE,EAAE,UAAU,CAAC,KAC/B,OAAO,CAAC,GAAG,CAAC,CAAC;AAElB,MAAM,MAAM,eAAe,CAAC,CAA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 export class HttpContextImpl {
|
|
|
120
120
|
}
|
|
121
121
|
get fetch() {
|
|
122
122
|
// This is maybe hard to read.
|
|
123
|
-
return __classPrivateFieldGet(this, _HttpContextImpl_dynamicFetcher, "f") && __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").activation
|
|
123
|
+
return __classPrivateFieldGet(this, _HttpContextImpl_dynamicFetcher, "f") && __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").activation
|
|
124
|
+
? wrapDynamicFetcher(__classPrivateFieldGet(this, _HttpContextImpl_dynamicFetcher, "f"), __classPrivateFieldGet(this, _HttpContextImpl_inner, "f").activation)
|
|
125
|
+
: __classPrivateFieldGet(this, _HttpContextImpl_staticFetcher, "f") ?? globalThis.fetch;
|
|
124
126
|
}
|
|
125
127
|
async nextPage(nextParams) {
|
|
126
|
-
throw new Error(
|
|
128
|
+
throw new Error('Method not implemented.');
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
131
|
_HttpContextImpl_dynamicFetcher = new WeakMap(), _HttpContextImpl_staticFetcher = new WeakMap(), _HttpContextImpl_inner = new WeakMap();
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { Tracer } from '@opentelemetry/api';
|
|
2
|
+
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
1
3
|
import { Router } from 'express';
|
|
2
4
|
import { Observable, Subscription } from 'rxjs';
|
|
3
5
|
import { ContextProvider } from '../../context/ContextProvider.js';
|
|
4
6
|
import { ConnectionProvider, CronProvider, RoundTripperFactory } from '../../dsl/http/types.js';
|
|
5
7
|
import { Workflow } from '../../dsl/Workflow.js';
|
|
8
|
+
import { ContextImpl, ContextOperatorFunction } from '../../mod.js';
|
|
6
9
|
import { Logger } from '../../observability/logging/Logger.js';
|
|
7
10
|
import { ObservableCompiler } from './ObservableCompiler.js';
|
|
8
|
-
import { ContextImpl, ContextOperatorFunction } from '../../mod.js';
|
|
9
11
|
export type MemoryInterpreterOptions = {
|
|
10
12
|
logger?: Logger;
|
|
11
13
|
compiler?: ObservableCompiler;
|
|
@@ -29,11 +31,13 @@ export declare class MemoryInterpreter {
|
|
|
29
31
|
private cronRegistry;
|
|
30
32
|
private readonly connectionProvider;
|
|
31
33
|
private readonly cronProvider;
|
|
34
|
+
private readonly tracer;
|
|
35
|
+
private readonly otelSDK?;
|
|
32
36
|
private registeredWorkflows;
|
|
33
37
|
private server?;
|
|
34
38
|
private shutdownServer?;
|
|
35
39
|
private isShuttingDown;
|
|
36
|
-
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, roundTripperFactory: RoundTripperFactory, router: Router, cronRegistry: Map<string, string>, connectionProvider: ConnectionProvider, cronProvider: CronProvider);
|
|
40
|
+
constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, roundTripperFactory: RoundTripperFactory, router: Router, cronRegistry: Map<string, string>, connectionProvider: ConnectionProvider, cronProvider: CronProvider, tracer: Tracer, otelSDK?: NodeSDK | undefined);
|
|
37
41
|
static newInstance(options?: MemoryInterpreterOptions): Promise<MemoryInterpreter>;
|
|
38
42
|
register<O>(workflow: Workflow<O>, options?: MemoryInterpreterOptions): Registration;
|
|
39
43
|
start(): Promise<void>;
|