@versori/run 0.2.9 → 0.2.11
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/versori/cronapi.d.ts +1 -0
- package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/cronapi.js +9 -1
- package/esm/src/dsl/http/versori/roundtripper.d.ts +1 -0
- package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/roundtripper.js +21 -4
- package/esm/src/interpreter/memory/MemoryInterpreter.js +2 -2
- package/package.json +2 -2
- package/script/src/dsl/http/versori/cronapi.d.ts +1 -0
- package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/cronapi.js +9 -1
- package/script/src/dsl/http/versori/roundtripper.d.ts +1 -0
- package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/script/src/dsl/http/versori/roundtripper.js +21 -4
- package/script/src/interpreter/memory/MemoryInterpreter.js +2 -2
|
@@ -11,6 +11,7 @@ export declare class CronAPIClient implements CronProvider {
|
|
|
11
11
|
private runLocal;
|
|
12
12
|
constructor(baseUrl: string, envId: string, integrationUrl: string);
|
|
13
13
|
static fromEnv(): CronAPIClient;
|
|
14
|
+
static addDefaultCronPort(url: string): string;
|
|
14
15
|
updateCrons(crons: Map<string, string>): Promise<void>;
|
|
15
16
|
runLocalFn(crons: Cron[]): void;
|
|
16
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cronapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/cronapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAY3C,KAAK,IAAI,GAAG;IACR,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,aAAc,YAAW,YAAY;IAC9C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAU;gBAEd,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAOlE,MAAM,CAAC,OAAO,IAAI,aAAa;
|
|
1
|
+
{"version":3,"file":"cronapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/cronapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAY3C,KAAK,IAAI,GAAG;IACR,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,aAAc,YAAW,YAAY;IAC9C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAU;gBAEd,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAOlE,MAAM,CAAC,OAAO,IAAI,aAAa;IAoB/B,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAUxC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB5D,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE;CAoB3B"}
|
|
@@ -41,7 +41,15 @@ export class CronAPIClient {
|
|
|
41
41
|
}
|
|
42
42
|
const integrationUrl = Deno.env.get(envVarSelfRefURL) ||
|
|
43
43
|
`http://svc-${projectId.toLowerCase()}-${envName.toLowerCase()}.sb-${orgSlug.toLowerCase()}.svc.cluster.local:${cronPort}`;
|
|
44
|
-
return new CronAPIClient(baseUrl, envId, integrationUrl);
|
|
44
|
+
return new CronAPIClient(baseUrl, envId, this.addDefaultCronPort(integrationUrl));
|
|
45
|
+
}
|
|
46
|
+
// Check if the URL has a port, if not, add the default cron port.
|
|
47
|
+
static addDefaultCronPort(url) {
|
|
48
|
+
const parsedUrl = new URL(url);
|
|
49
|
+
if (parsedUrl.port === '') {
|
|
50
|
+
parsedUrl.port = cronPort.toString();
|
|
51
|
+
}
|
|
52
|
+
return parsedUrl.toString();
|
|
45
53
|
}
|
|
46
54
|
async updateCrons(crons) {
|
|
47
55
|
const cronsArray = Array.from(crons.entries()).map(([name, schedule]) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/roundtripper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAElE,OAAO,EAEH,YAAY,EAEZ,cAAc,EACd,mBAAmB,EACtB,MAAM,aAAa,CAAC;AAQrB,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"roundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/roundtripper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAElE,OAAO,EAEH,YAAY,EAEZ,cAAc,EACd,mBAAmB,EACtB,MAAM,aAAa,CAAC;AAQrB,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAM/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;;;;;GAUG;AACH,qBAAa,yBAA0B,YAAW,mBAAmB;IACjE,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,OAAO,CAAC,SAAS,CAAe;IAEhC,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAK7B;gBAGE,WAAW,EAAE,uBAAuB,EACpC,YAAY,EAAE,MAAM,EACpB,iBAAiB,EAAE,iBAAiB,EACpC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,YAAY;IAe3B,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,yBAAyB;IAoCzE,OAAO,CAAC,iBAAiB;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,mBAAmB;IAO5B,cAAc,CAChB,IAAI,EAAE,MAAM,EACZ,YAAY,UAAQ,EACpB,YAAY,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,KAAK,CAAC;IAiBX,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;YAqB9D,uBAAuB;IAoDrC,OAAO,CAAC,aAAa;YAoDP,gBAAgB;YAmChB,kBAAkB;YAiClB,aAAa;YAwEb,QAAQ;YA2BR,MAAM;CAyBvB"}
|
|
@@ -3,8 +3,8 @@ import { ConsoleLogger } from '../../../observability/mod.js';
|
|
|
3
3
|
import { VersoriConfigReader } from './configloader.js';
|
|
4
4
|
import { envVarCredsBaseURL, envVarEnvId, envVarOrgId, envVarPlatformApiBaseURL, } from './constants.js';
|
|
5
5
|
import { VersoriCredentialClient } from './credentials/mod.js';
|
|
6
|
-
import { PlatformAPIClient } from './platformapi.js';
|
|
7
6
|
import { isValidURL } from './helpers.js';
|
|
7
|
+
import { PlatformAPIClient } from './platformapi.js';
|
|
8
8
|
/**
|
|
9
9
|
* VersoriRoundTripper is an implementation of the RoundTripperFactory interface for Versori connections.
|
|
10
10
|
* This is the intended implementation for when projects/services are hosted on Versori infrastructure.
|
|
@@ -237,7 +237,7 @@ export class VersoriCredentialsFactory {
|
|
|
237
237
|
}
|
|
238
238
|
async getTokenByName(name, forceRefresh = false, activationId) {
|
|
239
239
|
const credId = await this.getCredentialIDFromName(name, activationId);
|
|
240
|
-
const token = await this.
|
|
240
|
+
const token = await this.getToken(credId, forceRefresh);
|
|
241
241
|
if (!token?.token) {
|
|
242
242
|
throw new Error(`Token not found for connection ${name} with credential ID ${credId}`);
|
|
243
243
|
}
|
|
@@ -251,7 +251,7 @@ export class VersoriCredentialsFactory {
|
|
|
251
251
|
}
|
|
252
252
|
async getRawByName(name, activationId) {
|
|
253
253
|
const credId = await this.getCredentialIDFromName(name, activationId);
|
|
254
|
-
const raw = await this.
|
|
254
|
+
const raw = await this.getRaw(credId);
|
|
255
255
|
if (!raw) {
|
|
256
256
|
throw new Error(`Raw data not found for connection ${name} with credential ID ${credId}`);
|
|
257
257
|
}
|
|
@@ -461,7 +461,7 @@ export class VersoriCredentialsFactory {
|
|
|
461
461
|
return await this.tokenClient.getToken(id, forceRefresh);
|
|
462
462
|
}
|
|
463
463
|
catch (error) {
|
|
464
|
-
this.log.error('unable to get credential', { error });
|
|
464
|
+
this.log.error('unable to get token credential', { error });
|
|
465
465
|
if (error instanceof ConnectError) {
|
|
466
466
|
if (error.rawMessage.includes('connection error received: not a result of an error') &&
|
|
467
467
|
error.code === Code.Internal) {
|
|
@@ -474,4 +474,21 @@ export class VersoriCredentialsFactory {
|
|
|
474
474
|
throw error;
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
|
+
async getRaw(id) {
|
|
478
|
+
try {
|
|
479
|
+
return await this.tokenClient.getRaw(id);
|
|
480
|
+
}
|
|
481
|
+
catch (error) {
|
|
482
|
+
this.log.error('unable to get raw credential', { error });
|
|
483
|
+
if (error instanceof ConnectError) {
|
|
484
|
+
if (error.rawMessage.includes('connection error received: not a result of an error') && error.code === Code.Internal) {
|
|
485
|
+
this.log.info('Connection error received, attempting to reconnect');
|
|
486
|
+
this.tokenClient = new VersoriCredentialClient(this.credsBaseURL);
|
|
487
|
+
return await this.tokenClient.getRaw(id);
|
|
488
|
+
}
|
|
489
|
+
throw error;
|
|
490
|
+
}
|
|
491
|
+
throw error;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
477
494
|
}
|
|
@@ -317,10 +317,10 @@ export class MemoryInterpreter {
|
|
|
317
317
|
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
318
318
|
}
|
|
319
319
|
this.webhookServer = webhookApp.listen(port, () => {
|
|
320
|
-
this.log.info(`Express server listening on
|
|
320
|
+
this.log.info(`Express server listening on port ${port}`);
|
|
321
321
|
});
|
|
322
322
|
this.cronServer = cronApp.listen(cronPort, () => {
|
|
323
|
-
this.log.info(`Cron server listening on
|
|
323
|
+
this.log.info(`Cron server listening on port ${cronPort}`);
|
|
324
324
|
});
|
|
325
325
|
this.shutdownServer = () => {
|
|
326
326
|
if (this.isShuttingDown) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versori/run",
|
|
3
|
-
"version": "v0.2.
|
|
3
|
+
"version": "v0.2.11",
|
|
4
4
|
"description": "Versori Run",
|
|
5
5
|
"homepage": "https://github.com/versori/versori-run#readme",
|
|
6
6
|
"repository": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@bufbuild/protobuf": "^2.2
|
|
26
|
+
"@bufbuild/protobuf": "^2.5.2",
|
|
27
27
|
"@connectrpc/connect": "^2.0.1",
|
|
28
28
|
"@connectrpc/connect-node": "^2.0.1",
|
|
29
29
|
"@opentelemetry/api": "^1.9.0",
|
|
@@ -11,6 +11,7 @@ export declare class CronAPIClient implements CronProvider {
|
|
|
11
11
|
private runLocal;
|
|
12
12
|
constructor(baseUrl: string, envId: string, integrationUrl: string);
|
|
13
13
|
static fromEnv(): CronAPIClient;
|
|
14
|
+
static addDefaultCronPort(url: string): string;
|
|
14
15
|
updateCrons(crons: Map<string, string>): Promise<void>;
|
|
15
16
|
runLocalFn(crons: Cron[]): void;
|
|
16
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cronapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/cronapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAY3C,KAAK,IAAI,GAAG;IACR,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,aAAc,YAAW,YAAY;IAC9C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAU;gBAEd,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAOlE,MAAM,CAAC,OAAO,IAAI,aAAa;
|
|
1
|
+
{"version":3,"file":"cronapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/cronapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAY3C,KAAK,IAAI,GAAG;IACR,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,aAAc,YAAW,YAAY;IAC9C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAU;gBAEd,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAOlE,MAAM,CAAC,OAAO,IAAI,aAAa;IAoB/B,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAUxC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB5D,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE;CAoB3B"}
|
|
@@ -44,7 +44,15 @@ class CronAPIClient {
|
|
|
44
44
|
}
|
|
45
45
|
const integrationUrl = Deno.env.get(constants_js_1.envVarSelfRefURL) ||
|
|
46
46
|
`http://svc-${projectId.toLowerCase()}-${envName.toLowerCase()}.sb-${orgSlug.toLowerCase()}.svc.cluster.local:${constants_js_1.cronPort}`;
|
|
47
|
-
return new CronAPIClient(baseUrl, envId, integrationUrl);
|
|
47
|
+
return new CronAPIClient(baseUrl, envId, this.addDefaultCronPort(integrationUrl));
|
|
48
|
+
}
|
|
49
|
+
// Check if the URL has a port, if not, add the default cron port.
|
|
50
|
+
static addDefaultCronPort(url) {
|
|
51
|
+
const parsedUrl = new URL(url);
|
|
52
|
+
if (parsedUrl.port === '') {
|
|
53
|
+
parsedUrl.port = constants_js_1.cronPort.toString();
|
|
54
|
+
}
|
|
55
|
+
return parsedUrl.toString();
|
|
48
56
|
}
|
|
49
57
|
async updateCrons(crons) {
|
|
50
58
|
const cronsArray = Array.from(crons.entries()).map(([name, schedule]) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/roundtripper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAElE,OAAO,EAEH,YAAY,EAEZ,cAAc,EACd,mBAAmB,EACtB,MAAM,aAAa,CAAC;AAQrB,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"roundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/roundtripper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAElE,OAAO,EAEH,YAAY,EAEZ,cAAc,EACd,mBAAmB,EACtB,MAAM,aAAa,CAAC;AAQrB,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAM/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;;;;;GAUG;AACH,qBAAa,yBAA0B,YAAW,mBAAmB;IACjE,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,OAAO,CAAC,SAAS,CAAe;IAEhC,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAK7B;gBAGE,WAAW,EAAE,uBAAuB,EACpC,YAAY,EAAE,MAAM,EACpB,iBAAiB,EAAE,iBAAiB,EACpC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,YAAY;IAe3B,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,yBAAyB;IAoCzE,OAAO,CAAC,iBAAiB;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,mBAAmB;IAO5B,cAAc,CAChB,IAAI,EAAE,MAAM,EACZ,YAAY,UAAQ,EACpB,YAAY,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,KAAK,CAAC;IAiBX,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;YAqB9D,uBAAuB;IAoDrC,OAAO,CAAC,aAAa;YAoDP,gBAAgB;YAmChB,kBAAkB;YAiClB,aAAa;YAwEb,QAAQ;YA2BR,MAAM;CAyBvB"}
|
|
@@ -6,8 +6,8 @@ const mod_js_1 = require("../../../observability/mod.js");
|
|
|
6
6
|
const configloader_js_1 = require("./configloader.js");
|
|
7
7
|
const constants_js_1 = require("./constants.js");
|
|
8
8
|
const mod_js_2 = require("./credentials/mod.js");
|
|
9
|
-
const platformapi_js_1 = require("./platformapi.js");
|
|
10
9
|
const helpers_js_1 = require("./helpers.js");
|
|
10
|
+
const platformapi_js_1 = require("./platformapi.js");
|
|
11
11
|
/**
|
|
12
12
|
* VersoriRoundTripper is an implementation of the RoundTripperFactory interface for Versori connections.
|
|
13
13
|
* This is the intended implementation for when projects/services are hosted on Versori infrastructure.
|
|
@@ -240,7 +240,7 @@ class VersoriCredentialsFactory {
|
|
|
240
240
|
}
|
|
241
241
|
async getTokenByName(name, forceRefresh = false, activationId) {
|
|
242
242
|
const credId = await this.getCredentialIDFromName(name, activationId);
|
|
243
|
-
const token = await this.
|
|
243
|
+
const token = await this.getToken(credId, forceRefresh);
|
|
244
244
|
if (!token?.token) {
|
|
245
245
|
throw new Error(`Token not found for connection ${name} with credential ID ${credId}`);
|
|
246
246
|
}
|
|
@@ -254,7 +254,7 @@ class VersoriCredentialsFactory {
|
|
|
254
254
|
}
|
|
255
255
|
async getRawByName(name, activationId) {
|
|
256
256
|
const credId = await this.getCredentialIDFromName(name, activationId);
|
|
257
|
-
const raw = await this.
|
|
257
|
+
const raw = await this.getRaw(credId);
|
|
258
258
|
if (!raw) {
|
|
259
259
|
throw new Error(`Raw data not found for connection ${name} with credential ID ${credId}`);
|
|
260
260
|
}
|
|
@@ -464,7 +464,7 @@ class VersoriCredentialsFactory {
|
|
|
464
464
|
return await this.tokenClient.getToken(id, forceRefresh);
|
|
465
465
|
}
|
|
466
466
|
catch (error) {
|
|
467
|
-
this.log.error('unable to get credential', { error });
|
|
467
|
+
this.log.error('unable to get token credential', { error });
|
|
468
468
|
if (error instanceof connect_1.ConnectError) {
|
|
469
469
|
if (error.rawMessage.includes('connection error received: not a result of an error') &&
|
|
470
470
|
error.code === connect_1.Code.Internal) {
|
|
@@ -477,5 +477,22 @@ class VersoriCredentialsFactory {
|
|
|
477
477
|
throw error;
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
|
+
async getRaw(id) {
|
|
481
|
+
try {
|
|
482
|
+
return await this.tokenClient.getRaw(id);
|
|
483
|
+
}
|
|
484
|
+
catch (error) {
|
|
485
|
+
this.log.error('unable to get raw credential', { error });
|
|
486
|
+
if (error instanceof connect_1.ConnectError) {
|
|
487
|
+
if (error.rawMessage.includes('connection error received: not a result of an error') && error.code === connect_1.Code.Internal) {
|
|
488
|
+
this.log.info('Connection error received, attempting to reconnect');
|
|
489
|
+
this.tokenClient = new mod_js_2.VersoriCredentialClient(this.credsBaseURL);
|
|
490
|
+
return await this.tokenClient.getRaw(id);
|
|
491
|
+
}
|
|
492
|
+
throw error;
|
|
493
|
+
}
|
|
494
|
+
throw error;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
480
497
|
}
|
|
481
498
|
exports.VersoriCredentialsFactory = VersoriCredentialsFactory;
|
|
@@ -323,10 +323,10 @@ class MemoryInterpreter {
|
|
|
323
323
|
throw new Error('Unable to register scheduler tasks with central cron provider');
|
|
324
324
|
}
|
|
325
325
|
this.webhookServer = webhookApp.listen(port, () => {
|
|
326
|
-
this.log.info(`Express server listening on
|
|
326
|
+
this.log.info(`Express server listening on port ${port}`);
|
|
327
327
|
});
|
|
328
328
|
this.cronServer = cronApp.listen(cronPort, () => {
|
|
329
|
-
this.log.info(`Cron server listening on
|
|
329
|
+
this.log.info(`Cron server listening on port ${cronPort}`);
|
|
330
330
|
});
|
|
331
331
|
this.shutdownServer = () => {
|
|
332
332
|
if (this.isShuttingDown) {
|