@versori/run 0.2.0-alpha.8 → 0.2.0-alpha.9
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/types.d.ts +5 -2
- package/esm/src/dsl/http/types.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/activation.d.ts +13 -0
- package/esm/src/dsl/http/versori/activation.d.ts.map +1 -0
- package/esm/src/dsl/http/versori/activation.js +65 -0
- package/esm/src/dsl/http/versori/platformapi.d.ts +4 -1
- package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/platformapi.js +38 -6
- package/esm/src/dsl/http/versori/roundtripper.js +2 -2
- package/package.json +1 -1
- package/script/src/dsl/http/types.d.ts +5 -2
- package/script/src/dsl/http/types.d.ts.map +1 -1
- package/script/src/dsl/http/versori/activation.d.ts +13 -0
- package/script/src/dsl/http/versori/activation.d.ts.map +1 -0
- package/script/src/dsl/http/versori/activation.js +69 -0
- package/script/src/dsl/http/versori/platformapi.d.ts +4 -1
- package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/platformapi.js +38 -6
- package/script/src/dsl/http/versori/roundtripper.js +2 -2
|
@@ -10,6 +10,7 @@ export interface ConnectionProvider {
|
|
|
10
10
|
getActivationConnection(templateId: string, activationId: string): Promise<Connection | undefined>;
|
|
11
11
|
getActivation(activationId: string): Promise<Activation | undefined>;
|
|
12
12
|
listActivations(): Promise<Activation[]>;
|
|
13
|
+
updateDynamicVariable(activationId: string, name: string, value: unknown): Promise<void>;
|
|
13
14
|
}
|
|
14
15
|
export type CronConfig = {
|
|
15
16
|
name: string;
|
|
@@ -27,10 +28,12 @@ export type User = {
|
|
|
27
28
|
externalId: string;
|
|
28
29
|
organisationId: string;
|
|
29
30
|
};
|
|
30
|
-
export
|
|
31
|
+
export interface Activation {
|
|
31
32
|
id: string;
|
|
32
33
|
user: User;
|
|
33
|
-
|
|
34
|
+
getVariable(name: string): unknown;
|
|
35
|
+
setVariable(name: string, value: unknown): Promise<void>;
|
|
36
|
+
}
|
|
34
37
|
export type AuthSchemeType = 'none' | 'api-key' | 'basic-auth' | 'oauth2' | 'hmac' | 'jwt-bearer' | 'custom-function' | 'certificate' | 'oauth1';
|
|
35
38
|
export type AuthSchemeConfig = {
|
|
36
39
|
type: AuthSchemeType;
|
|
@@ -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,EAAE,EAAE,EAAE,OAAO,KAAK,GAAG,OAAO,CAAC,OAAO,KAAK,GAAG,SAAS,CAAC,CAAC;IAC9E,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,KAAK,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;CAC9F;AAGD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,KAAK,CAIhG;AAED,MAAM,WAAW,kBAAkB;IAC/B,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IACpE,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1D,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IACnG,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,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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,13 @@
|
|
|
1
|
+
import { Logger } from '../../../observability/logging/Logger.js';
|
|
2
|
+
import { Activation, ConnectionProvider, User } from '../types.js';
|
|
3
|
+
export declare class ActivationImpl implements Activation {
|
|
4
|
+
id: string;
|
|
5
|
+
user: User;
|
|
6
|
+
private variables?;
|
|
7
|
+
private connectionProvider;
|
|
8
|
+
private log;
|
|
9
|
+
constructor(id: string, user: User, connectionProvider: ConnectionProvider, log: Logger, variables: Record<string, unknown>);
|
|
10
|
+
getVariable(name: string): unknown;
|
|
11
|
+
setVariable(name: string, value: unknown): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=activation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activation.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/activation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnE,qBAAa,cAAe,YAAW,UAAU;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IAElB,OAAO,CAAC,SAAS,CAAC,CAA0B;IAC5C,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,GAAG,CAAS;gBAGhB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,IAAI,EACV,kBAAkB,EAAE,kBAAkB,EACtC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAWtC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQ5B,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBjE"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export class ActivationImpl {
|
|
2
|
+
constructor(id, user, connectionProvider, log, variables) {
|
|
3
|
+
Object.defineProperty(this, "id", {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
configurable: true,
|
|
6
|
+
writable: true,
|
|
7
|
+
value: void 0
|
|
8
|
+
});
|
|
9
|
+
Object.defineProperty(this, "user", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true,
|
|
13
|
+
value: void 0
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(this, "variables", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: void 0
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(this, "connectionProvider", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: void 0
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(this, "log", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true,
|
|
30
|
+
writable: true,
|
|
31
|
+
value: void 0
|
|
32
|
+
});
|
|
33
|
+
this.id = id;
|
|
34
|
+
this.user = user;
|
|
35
|
+
this.connectionProvider = connectionProvider;
|
|
36
|
+
this.variables = variables;
|
|
37
|
+
this.log = log.child({
|
|
38
|
+
activationId: id,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
getVariable(name) {
|
|
42
|
+
if (!this.variables) {
|
|
43
|
+
this.log.error(`No variables found for activation`);
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return this.variables[name];
|
|
47
|
+
}
|
|
48
|
+
async setVariable(name, value) {
|
|
49
|
+
if (!this.variables) {
|
|
50
|
+
this.log.error(`No variables found for activation`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
await this.connectionProvider.updateDynamicVariable(this.id, name, value);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
this.log.error(`Failed to set variable`, {
|
|
58
|
+
error: err,
|
|
59
|
+
variableName: name,
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.variables[name] = value;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import { Logger } from '../../../observability/mod.js';
|
|
1
2
|
import { Activation, Connection, ConnectionProvider } from '../types.js';
|
|
2
3
|
export declare class PlatformAPIClient implements ConnectionProvider {
|
|
3
4
|
private baseUrl;
|
|
4
5
|
private orgId;
|
|
5
6
|
private envId;
|
|
6
7
|
private internalAuth;
|
|
7
|
-
|
|
8
|
+
private log;
|
|
9
|
+
constructor(baseUrl: string, orgId: string, envId: string, log: Logger);
|
|
8
10
|
static fromEnv(): PlatformAPIClient;
|
|
9
11
|
getStaticConnection(cnxId: string): Promise<Connection | undefined>;
|
|
10
12
|
getUserActivations(userId: string): Promise<Activation[]>;
|
|
11
13
|
getActivation(activationId: string): Promise<Activation | undefined>;
|
|
12
14
|
getActivationConnection(templateId: string, activationId: string): Promise<Connection | undefined>;
|
|
13
15
|
listActivations(): Promise<Activation[]>;
|
|
16
|
+
updateDynamicVariable(activationId: string, name: string, value: unknown): Promise<void>;
|
|
14
17
|
}
|
|
15
18
|
//# sourceMappingURL=platformapi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platformapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/platformapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
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,CAAC,UAAU,GAAG,SAAS,CAAC;IAgBnE,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAuBzD,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;CAqBjG"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { envVarEnvId, envVarOrgId, envVarPlatformApiBaseURL } from './constants.js';
|
|
2
2
|
import { InternalAuth } from './internalauth.js';
|
|
3
|
+
import { ConsoleLogger } from '../../../mod.js';
|
|
4
|
+
import { ActivationImpl } from './activation.js';
|
|
3
5
|
export class PlatformAPIClient {
|
|
4
|
-
constructor(baseUrl, orgId, envId) {
|
|
6
|
+
constructor(baseUrl, orgId, envId, log) {
|
|
5
7
|
Object.defineProperty(this, "baseUrl", {
|
|
6
8
|
enumerable: true,
|
|
7
9
|
configurable: true,
|
|
@@ -26,19 +28,27 @@ export class PlatformAPIClient {
|
|
|
26
28
|
writable: true,
|
|
27
29
|
value: void 0
|
|
28
30
|
});
|
|
31
|
+
Object.defineProperty(this, "log", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
29
37
|
this.baseUrl = baseUrl;
|
|
30
38
|
this.orgId = orgId;
|
|
31
39
|
this.envId = envId;
|
|
32
40
|
this.internalAuth = new InternalAuth();
|
|
41
|
+
this.log = log;
|
|
33
42
|
}
|
|
34
43
|
static fromEnv() {
|
|
35
44
|
const baseUrl = Deno.env.get(envVarPlatformApiBaseURL);
|
|
36
45
|
const orgId = Deno.env.get(envVarOrgId);
|
|
37
46
|
const envId = Deno.env.get(envVarEnvId);
|
|
47
|
+
const log = new ConsoleLogger('debug');
|
|
38
48
|
if (!baseUrl || !orgId || !envId) {
|
|
39
49
|
throw new Error('Missing required environment variables');
|
|
40
50
|
}
|
|
41
|
-
return new PlatformAPIClient(baseUrl, orgId, envId);
|
|
51
|
+
return new PlatformAPIClient(baseUrl, orgId, envId, log);
|
|
42
52
|
}
|
|
43
53
|
async getStaticConnection(cnxId) {
|
|
44
54
|
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/connections/${cnxId}`, {
|
|
@@ -61,7 +71,10 @@ export class PlatformAPIClient {
|
|
|
61
71
|
if (!resp.ok) {
|
|
62
72
|
return [];
|
|
63
73
|
}
|
|
64
|
-
const
|
|
74
|
+
const activations = (await resp.json());
|
|
75
|
+
const result = activations.map((act) => {
|
|
76
|
+
return new ActivationImpl(act.id, act.user, this, this.log, act.dynamicVariables);
|
|
77
|
+
});
|
|
65
78
|
return result;
|
|
66
79
|
}
|
|
67
80
|
async getActivation(activationId) {
|
|
@@ -73,8 +86,8 @@ export class PlatformAPIClient {
|
|
|
73
86
|
if (!resp.ok) {
|
|
74
87
|
return undefined;
|
|
75
88
|
}
|
|
76
|
-
const
|
|
77
|
-
return
|
|
89
|
+
const act = (await resp.json());
|
|
90
|
+
return new ActivationImpl(act.id, act.user, this, this.log, act.dynamicVariables);
|
|
78
91
|
}
|
|
79
92
|
async getActivationConnection(templateId, activationId) {
|
|
80
93
|
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environment-systems/${templateId}/activations/${activationId}`, {
|
|
@@ -97,7 +110,26 @@ export class PlatformAPIClient {
|
|
|
97
110
|
if (!resp.ok) {
|
|
98
111
|
return [];
|
|
99
112
|
}
|
|
100
|
-
const
|
|
113
|
+
const activations = (await resp.json());
|
|
114
|
+
const result = activations.map((act) => {
|
|
115
|
+
return new ActivationImpl(act.id, act.user, this, this.log, act.dynamicVariables);
|
|
116
|
+
});
|
|
101
117
|
return result;
|
|
102
118
|
}
|
|
119
|
+
async updateDynamicVariable(activationId, name, value) {
|
|
120
|
+
this.log.debug(`value is ${JSON.stringify(value)}`);
|
|
121
|
+
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environments/${this.envId}/activations/${activationId}/variables/${name}`, {
|
|
122
|
+
method: 'PUT',
|
|
123
|
+
headers: {
|
|
124
|
+
'x-versori-internal-token': await this.internalAuth.getToken(),
|
|
125
|
+
'Content-Type': 'application/json',
|
|
126
|
+
},
|
|
127
|
+
body: JSON.stringify({
|
|
128
|
+
value,
|
|
129
|
+
}),
|
|
130
|
+
});
|
|
131
|
+
if (!resp.ok) {
|
|
132
|
+
throw new Error(`Failed to update dynamic variable ${name}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
103
135
|
}
|
|
@@ -74,9 +74,9 @@ export class VersoriRoundTripperFactory {
|
|
|
74
74
|
missingVars.push(envVarCredsBaseURL);
|
|
75
75
|
throw new Error(`Missing environment variables: ${missingVars.join(', ')}`);
|
|
76
76
|
}
|
|
77
|
-
const pAPIClient = new PlatformAPIClient(platformApiBaseURL, orgId, envId);
|
|
78
|
-
const tokenClient = new VersoriCredentialClient(credsBaseURL);
|
|
79
77
|
const log = logger || new ConsoleLogger('debug');
|
|
78
|
+
const pAPIClient = new PlatformAPIClient(platformApiBaseURL, orgId, envId, log);
|
|
79
|
+
const tokenClient = new VersoriCredentialClient(credsBaseURL);
|
|
80
80
|
return new VersoriRoundTripperFactory(tokenClient, pAPIClient, log);
|
|
81
81
|
}
|
|
82
82
|
// takes the info and modifies the url using changeBaseUrl if necessary
|
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ export interface ConnectionProvider {
|
|
|
10
10
|
getActivationConnection(templateId: string, activationId: string): Promise<Connection | undefined>;
|
|
11
11
|
getActivation(activationId: string): Promise<Activation | undefined>;
|
|
12
12
|
listActivations(): Promise<Activation[]>;
|
|
13
|
+
updateDynamicVariable(activationId: string, name: string, value: unknown): Promise<void>;
|
|
13
14
|
}
|
|
14
15
|
export type CronConfig = {
|
|
15
16
|
name: string;
|
|
@@ -27,10 +28,12 @@ export type User = {
|
|
|
27
28
|
externalId: string;
|
|
28
29
|
organisationId: string;
|
|
29
30
|
};
|
|
30
|
-
export
|
|
31
|
+
export interface Activation {
|
|
31
32
|
id: string;
|
|
32
33
|
user: User;
|
|
33
|
-
|
|
34
|
+
getVariable(name: string): unknown;
|
|
35
|
+
setVariable(name: string, value: unknown): Promise<void>;
|
|
36
|
+
}
|
|
34
37
|
export type AuthSchemeType = 'none' | 'api-key' | 'basic-auth' | 'oauth2' | 'hmac' | 'jwt-bearer' | 'custom-function' | 'certificate' | 'oauth1';
|
|
35
38
|
export type AuthSchemeConfig = {
|
|
36
39
|
type: AuthSchemeType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/http/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc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7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAC/B,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,UAAU,EAAE,UAAU,CAAC;IACvB,EAAE,EAAE,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,13 @@
|
|
|
1
|
+
import { Logger } from '../../../observability/logging/Logger.js';
|
|
2
|
+
import { Activation, ConnectionProvider, User } from '../types.js';
|
|
3
|
+
export declare class ActivationImpl implements Activation {
|
|
4
|
+
id: string;
|
|
5
|
+
user: User;
|
|
6
|
+
private variables?;
|
|
7
|
+
private connectionProvider;
|
|
8
|
+
private log;
|
|
9
|
+
constructor(id: string, user: User, connectionProvider: ConnectionProvider, log: Logger, variables: Record<string, unknown>);
|
|
10
|
+
getVariable(name: string): unknown;
|
|
11
|
+
setVariable(name: string, value: unknown): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=activation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activation.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/activation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnE,qBAAa,cAAe,YAAW,UAAU;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IAElB,OAAO,CAAC,SAAS,CAAC,CAA0B;IAC5C,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,GAAG,CAAS;gBAGhB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,IAAI,EACV,kBAAkB,EAAE,kBAAkB,EACtC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAWtC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQ5B,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBjE"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActivationImpl = void 0;
|
|
4
|
+
class ActivationImpl {
|
|
5
|
+
constructor(id, user, connectionProvider, log, variables) {
|
|
6
|
+
Object.defineProperty(this, "id", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: void 0
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(this, "user", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: void 0
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(this, "variables", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: void 0
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(this, "connectionProvider", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(this, "log", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: void 0
|
|
35
|
+
});
|
|
36
|
+
this.id = id;
|
|
37
|
+
this.user = user;
|
|
38
|
+
this.connectionProvider = connectionProvider;
|
|
39
|
+
this.variables = variables;
|
|
40
|
+
this.log = log.child({
|
|
41
|
+
activationId: id,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
getVariable(name) {
|
|
45
|
+
if (!this.variables) {
|
|
46
|
+
this.log.error(`No variables found for activation`);
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
return this.variables[name];
|
|
50
|
+
}
|
|
51
|
+
async setVariable(name, value) {
|
|
52
|
+
if (!this.variables) {
|
|
53
|
+
this.log.error(`No variables found for activation`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
await this.connectionProvider.updateDynamicVariable(this.id, name, value);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
this.log.error(`Failed to set variable`, {
|
|
61
|
+
error: err,
|
|
62
|
+
variableName: name,
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
this.variables[name] = value;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.ActivationImpl = ActivationImpl;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import { Logger } from '../../../observability/mod.js';
|
|
1
2
|
import { Activation, Connection, ConnectionProvider } from '../types.js';
|
|
2
3
|
export declare class PlatformAPIClient implements ConnectionProvider {
|
|
3
4
|
private baseUrl;
|
|
4
5
|
private orgId;
|
|
5
6
|
private envId;
|
|
6
7
|
private internalAuth;
|
|
7
|
-
|
|
8
|
+
private log;
|
|
9
|
+
constructor(baseUrl: string, orgId: string, envId: string, log: Logger);
|
|
8
10
|
static fromEnv(): PlatformAPIClient;
|
|
9
11
|
getStaticConnection(cnxId: string): Promise<Connection | undefined>;
|
|
10
12
|
getUserActivations(userId: string): Promise<Activation[]>;
|
|
11
13
|
getActivation(activationId: string): Promise<Activation | undefined>;
|
|
12
14
|
getActivationConnection(templateId: string, activationId: string): Promise<Connection | undefined>;
|
|
13
15
|
listActivations(): Promise<Activation[]>;
|
|
16
|
+
updateDynamicVariable(activationId: string, name: string, value: unknown): Promise<void>;
|
|
14
17
|
}
|
|
15
18
|
//# sourceMappingURL=platformapi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platformapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/platformapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
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,CAAC,UAAU,GAAG,SAAS,CAAC;IAgBnE,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAuBzD,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;CAqBjG"}
|
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PlatformAPIClient = void 0;
|
|
4
4
|
const constants_js_1 = require("./constants.js");
|
|
5
5
|
const internalauth_js_1 = require("./internalauth.js");
|
|
6
|
+
const mod_js_1 = require("../../../mod.js");
|
|
7
|
+
const activation_js_1 = require("./activation.js");
|
|
6
8
|
class PlatformAPIClient {
|
|
7
|
-
constructor(baseUrl, orgId, envId) {
|
|
9
|
+
constructor(baseUrl, orgId, envId, log) {
|
|
8
10
|
Object.defineProperty(this, "baseUrl", {
|
|
9
11
|
enumerable: true,
|
|
10
12
|
configurable: true,
|
|
@@ -29,19 +31,27 @@ class PlatformAPIClient {
|
|
|
29
31
|
writable: true,
|
|
30
32
|
value: void 0
|
|
31
33
|
});
|
|
34
|
+
Object.defineProperty(this, "log", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: void 0
|
|
39
|
+
});
|
|
32
40
|
this.baseUrl = baseUrl;
|
|
33
41
|
this.orgId = orgId;
|
|
34
42
|
this.envId = envId;
|
|
35
43
|
this.internalAuth = new internalauth_js_1.InternalAuth();
|
|
44
|
+
this.log = log;
|
|
36
45
|
}
|
|
37
46
|
static fromEnv() {
|
|
38
47
|
const baseUrl = Deno.env.get(constants_js_1.envVarPlatformApiBaseURL);
|
|
39
48
|
const orgId = Deno.env.get(constants_js_1.envVarOrgId);
|
|
40
49
|
const envId = Deno.env.get(constants_js_1.envVarEnvId);
|
|
50
|
+
const log = new mod_js_1.ConsoleLogger('debug');
|
|
41
51
|
if (!baseUrl || !orgId || !envId) {
|
|
42
52
|
throw new Error('Missing required environment variables');
|
|
43
53
|
}
|
|
44
|
-
return new PlatformAPIClient(baseUrl, orgId, envId);
|
|
54
|
+
return new PlatformAPIClient(baseUrl, orgId, envId, log);
|
|
45
55
|
}
|
|
46
56
|
async getStaticConnection(cnxId) {
|
|
47
57
|
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/connections/${cnxId}`, {
|
|
@@ -64,7 +74,10 @@ class PlatformAPIClient {
|
|
|
64
74
|
if (!resp.ok) {
|
|
65
75
|
return [];
|
|
66
76
|
}
|
|
67
|
-
const
|
|
77
|
+
const activations = (await resp.json());
|
|
78
|
+
const result = activations.map((act) => {
|
|
79
|
+
return new activation_js_1.ActivationImpl(act.id, act.user, this, this.log, act.dynamicVariables);
|
|
80
|
+
});
|
|
68
81
|
return result;
|
|
69
82
|
}
|
|
70
83
|
async getActivation(activationId) {
|
|
@@ -76,8 +89,8 @@ class PlatformAPIClient {
|
|
|
76
89
|
if (!resp.ok) {
|
|
77
90
|
return undefined;
|
|
78
91
|
}
|
|
79
|
-
const
|
|
80
|
-
return
|
|
92
|
+
const act = (await resp.json());
|
|
93
|
+
return new activation_js_1.ActivationImpl(act.id, act.user, this, this.log, act.dynamicVariables);
|
|
81
94
|
}
|
|
82
95
|
async getActivationConnection(templateId, activationId) {
|
|
83
96
|
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environment-systems/${templateId}/activations/${activationId}`, {
|
|
@@ -100,8 +113,27 @@ class PlatformAPIClient {
|
|
|
100
113
|
if (!resp.ok) {
|
|
101
114
|
return [];
|
|
102
115
|
}
|
|
103
|
-
const
|
|
116
|
+
const activations = (await resp.json());
|
|
117
|
+
const result = activations.map((act) => {
|
|
118
|
+
return new activation_js_1.ActivationImpl(act.id, act.user, this, this.log, act.dynamicVariables);
|
|
119
|
+
});
|
|
104
120
|
return result;
|
|
105
121
|
}
|
|
122
|
+
async updateDynamicVariable(activationId, name, value) {
|
|
123
|
+
this.log.debug(`value is ${JSON.stringify(value)}`);
|
|
124
|
+
const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environments/${this.envId}/activations/${activationId}/variables/${name}`, {
|
|
125
|
+
method: 'PUT',
|
|
126
|
+
headers: {
|
|
127
|
+
'x-versori-internal-token': await this.internalAuth.getToken(),
|
|
128
|
+
'Content-Type': 'application/json',
|
|
129
|
+
},
|
|
130
|
+
body: JSON.stringify({
|
|
131
|
+
value,
|
|
132
|
+
}),
|
|
133
|
+
});
|
|
134
|
+
if (!resp.ok) {
|
|
135
|
+
throw new Error(`Failed to update dynamic variable ${name}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
106
138
|
}
|
|
107
139
|
exports.PlatformAPIClient = PlatformAPIClient;
|
|
@@ -77,9 +77,9 @@ class VersoriRoundTripperFactory {
|
|
|
77
77
|
missingVars.push(constants_js_1.envVarCredsBaseURL);
|
|
78
78
|
throw new Error(`Missing environment variables: ${missingVars.join(', ')}`);
|
|
79
79
|
}
|
|
80
|
-
const pAPIClient = new platformapi_js_1.PlatformAPIClient(platformApiBaseURL, orgId, envId);
|
|
81
|
-
const tokenClient = new mod_js_1.VersoriCredentialClient(credsBaseURL);
|
|
82
80
|
const log = logger || new mod_js_2.ConsoleLogger('debug');
|
|
81
|
+
const pAPIClient = new platformapi_js_1.PlatformAPIClient(platformApiBaseURL, orgId, envId, log);
|
|
82
|
+
const tokenClient = new mod_js_1.VersoriCredentialClient(credsBaseURL);
|
|
83
83
|
return new VersoriRoundTripperFactory(tokenClient, pAPIClient, log);
|
|
84
84
|
}
|
|
85
85
|
// takes the info and modifies the url using changeBaseUrl if necessary
|