@versori/run 0.0.1-alpha.7 → 0.1.0-alpha.8
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/context/Context.d.ts +6 -1
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +17 -3
- package/esm/src/context/ContextProvider.d.ts +3 -2
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +2 -2
- package/esm/src/dsl/http/default.d.ts.map +1 -1
- package/esm/src/dsl/http/default.js +3 -1
- package/esm/src/dsl/http/types.d.ts +122 -16
- package/esm/src/dsl/http/types.d.ts.map +1 -1
- package/esm/src/dsl/http/types.js +6 -2
- package/esm/src/dsl/http/versori/configloader.d.ts +2 -2
- package/esm/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/configloader.js +9 -3
- package/esm/src/dsl/http/versori/constants.d.ts +10 -0
- package/esm/src/dsl/http/versori/constants.d.ts.map +1 -0
- package/esm/src/dsl/http/versori/constants.js +12 -0
- package/esm/src/dsl/http/versori/internalauth.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/internalauth.js +10 -9
- package/esm/src/dsl/http/versori/platformapi.d.ts +14 -0
- package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -0
- package/esm/src/dsl/http/versori/platformapi.js +91 -0
- package/esm/src/dsl/http/versori/roundtripper.d.ts +13 -6
- package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/roundtripper.js +171 -54
- package/esm/src/dsl/tasks/HttpTask.d.ts +18 -2
- package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/esm/src/dsl/tasks/HttpTask.js +82 -0
- package/esm/src/dsl/triggers/ScheduleTrigger.d.ts +6 -2
- package/esm/src/dsl/triggers/ScheduleTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/ScheduleTrigger.js +10 -3
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +1 -0
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +12 -3
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts +2 -1
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/background.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/background.js +4 -2
- package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/http.js +6 -12
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.js +32 -6
- package/esm/src/interpreter/memory/compilers/serial.js +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +20 -4
- package/package.json +2 -1
- package/script/src/context/Context.d.ts +6 -1
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +17 -3
- package/script/src/context/ContextProvider.d.ts +3 -2
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +2 -2
- package/script/src/dsl/http/default.d.ts.map +1 -1
- package/script/src/dsl/http/default.js +3 -1
- package/script/src/dsl/http/types.d.ts +122 -16
- package/script/src/dsl/http/types.d.ts.map +1 -1
- package/script/src/dsl/http/types.js +7 -1
- package/script/src/dsl/http/versori/configloader.d.ts +2 -2
- package/script/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/script/src/dsl/http/versori/configloader.js +10 -4
- package/script/src/dsl/http/versori/constants.d.ts +10 -0
- package/script/src/dsl/http/versori/constants.d.ts.map +1 -0
- package/script/src/dsl/http/versori/constants.js +15 -0
- package/script/src/dsl/http/versori/internalauth.d.ts.map +1 -1
- package/script/src/dsl/http/versori/internalauth.js +10 -9
- package/script/src/dsl/http/versori/platformapi.d.ts +14 -0
- package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -0
- package/script/src/dsl/http/versori/platformapi.js +118 -0
- package/script/src/dsl/http/versori/roundtripper.d.ts +13 -6
- package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/script/src/dsl/http/versori/roundtripper.js +170 -54
- package/script/src/dsl/tasks/HttpTask.d.ts +18 -2
- package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/script/src/dsl/tasks/HttpTask.js +84 -1
- package/script/src/dsl/triggers/ScheduleTrigger.d.ts +6 -2
- package/script/src/dsl/triggers/ScheduleTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/ScheduleTrigger.js +10 -3
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +1 -0
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +12 -3
- package/script/src/interpreter/memory/ObservableCompiler.d.ts +2 -1
- package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/background.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/background.js +3 -1
- package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/http.js +5 -11
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.js +32 -6
- package/script/src/interpreter/memory/compilers/serial.js +1 -1
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +20 -4
- package/esm/src/dsl/http/versori/connectapi.d.ts +0 -11
- package/esm/src/dsl/http/versori/connectapi.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/connectapi.js +0 -57
- package/script/src/dsl/http/versori/connectapi.d.ts +0 -11
- package/script/src/dsl/http/versori/connectapi.d.ts.map +0 -1
- package/script/src/dsl/http/versori/connectapi.js +0 -61
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/http.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/http.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAkCnE,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import { mergeMap } from 'rxjs';
|
|
2
2
|
import { tap } from 'rxjs/operators';
|
|
3
|
-
import { HttpTaskImpl } from '../../../dsl/tasks/HttpTask.js';
|
|
3
|
+
import { HttpContextImpl, HttpTaskImpl } from '../../../dsl/tasks/HttpTask.js';
|
|
4
4
|
function compileHttp(ctx, task) {
|
|
5
|
-
const roundtripper = ctx.roundTripperFactory.create(task.opts.connection, fetch);
|
|
5
|
+
const roundtripper = ctx.roundTripperFactory.create(task.opts.connection, globalThis.fetch);
|
|
6
|
+
const dynamicFetcher = ctx.roundTripperFactory.createDynamic(task.opts.connection, globalThis.fetch);
|
|
6
7
|
return (src) => src.pipe(tap({
|
|
7
|
-
complete: () => ctx.log.debug('http.complete')
|
|
8
|
+
complete: () => ctx.log.debug('http.complete'),
|
|
8
9
|
}), mergeMap(async (ctx) => {
|
|
9
10
|
const _fetch = await roundtripper;
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
fetch: _fetch,
|
|
13
|
-
connectionVariables: {}, // TODO: Implement connection variables
|
|
14
|
-
pageParams: undefined,
|
|
15
|
-
nextPage: () => {
|
|
16
|
-
throw new Error('Pagination not yet implemented');
|
|
17
|
-
},
|
|
18
|
-
};
|
|
11
|
+
const _dynamicFetcher = await dynamicFetcher;
|
|
12
|
+
const httpContext = new HttpContextImpl(ctx, {}, _fetch, _dynamicFetcher);
|
|
19
13
|
const result = await task.fn(httpContext);
|
|
20
14
|
return ctx.withData(result);
|
|
21
15
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA6F7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
|
|
@@ -3,16 +3,42 @@ import { Observable } from 'rxjs';
|
|
|
3
3
|
import { ScheduleTrigger } from '../../../dsl/triggers/ScheduleTrigger.js';
|
|
4
4
|
function compileSchedule(ctx, trigger, signal) {
|
|
5
5
|
return new Observable((subscriber) => {
|
|
6
|
+
const client = ctx.connectionProvider;
|
|
6
7
|
const job = CronJob.from({
|
|
7
8
|
cronTime: trigger.schedule,
|
|
8
|
-
onTick: () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
onTick: async () => {
|
|
10
|
+
if (trigger.activationPredicate === undefined) {
|
|
11
|
+
const executionCtx = ctx.contextProvider.create({}, undefined);
|
|
12
|
+
try {
|
|
13
|
+
subscriber.next(executionCtx);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
executionCtx.log.error('execution error inside schedule', { error });
|
|
17
|
+
}
|
|
18
|
+
return;
|
|
12
19
|
}
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
const activations = await client.listActivations();
|
|
21
|
+
if (!activations || activations.length === 0) {
|
|
22
|
+
const executionCtx = ctx.contextProvider.create({}, undefined);
|
|
23
|
+
executionCtx.log.info('no activations found, continuing');
|
|
24
|
+
try {
|
|
25
|
+
subscriber.next(executionCtx);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
executionCtx.log.error('execution error inside schedule', { error });
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
15
31
|
}
|
|
32
|
+
activations.forEach((activation) => {
|
|
33
|
+
const executionCtx = ctx.contextProvider.create({}, activation);
|
|
34
|
+
executionCtx.log.info('no activations found, continuing');
|
|
35
|
+
try {
|
|
36
|
+
subscriber.next(executionCtx);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
executionCtx.log.error('execution error inside schedule', { error });
|
|
40
|
+
}
|
|
41
|
+
});
|
|
16
42
|
},
|
|
17
43
|
onComplete: () => {
|
|
18
44
|
if (subscriber.closed) {
|
|
@@ -4,7 +4,7 @@ function compileSerial(ctx, task) {
|
|
|
4
4
|
const baseOperator = ctx.compiler.compileTask(ctx, task._base);
|
|
5
5
|
const eachOperator = ctx.compiler.compileTask(ctx, task._each);
|
|
6
6
|
return (src) => src.pipe(tap({
|
|
7
|
-
complete: () => ctx.log.debug('serial.complete')
|
|
7
|
+
complete: () => ctx.log.debug('serial.complete'),
|
|
8
8
|
}), baseOperator, mergeMap((ctx) => {
|
|
9
9
|
const tasks = ctx.data.map((d, idx) => eachOperator(of(ctx.withData(d).setIndex(idx))));
|
|
10
10
|
return concat(...tasks).pipe(map((result) => result.data), toArray(), map((results) => ctx.withData(results)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAM7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CA6DxE,CAAC"}
|
|
@@ -10,10 +10,26 @@ export const webhookCompiler = {
|
|
|
10
10
|
}
|
|
11
11
|
// add the webhook endpoint to the router
|
|
12
12
|
ctx.log.info('webhook endpoint added:', { trigger });
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
ctx.
|
|
16
|
-
|
|
13
|
+
// endpoint for sans user because I'm not quite sure how the dynamic routing works
|
|
14
|
+
ctx.router.post(`/${trigger.id}`, (req, res) => {
|
|
15
|
+
const executionCtx = ctx.contextProvider.create(req.body, undefined);
|
|
16
|
+
try {
|
|
17
|
+
subscriber.next(executionCtx);
|
|
18
|
+
res.status(200).json({ status: "accepted" });
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
22
|
+
executionCtx.log.error('webhook execution error', { error });
|
|
23
|
+
res.status(500).json({ status: "error", message });
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
ctx.router.post(`/${trigger.id}/:activationId`, (req, res) => {
|
|
27
|
+
const activationId = req.params.activationId || undefined;
|
|
28
|
+
let activation = undefined;
|
|
29
|
+
if (activationId) {
|
|
30
|
+
activation = { id: activationId };
|
|
31
|
+
}
|
|
32
|
+
const executionCtx = ctx.contextProvider.create(req.body, activation);
|
|
17
33
|
try {
|
|
18
34
|
subscriber.next(executionCtx);
|
|
19
35
|
res.status(200).json({ status: "accepted" });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versori/run",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "v0.1.0-alpha.8",
|
|
4
4
|
"description": "Versori Run",
|
|
5
5
|
"homepage": "https://github.com/versori/versori-run#readme",
|
|
6
6
|
"repository": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"@connectrpc/connect-node": "^2.0.1",
|
|
29
29
|
"cron": "3.5.0",
|
|
30
30
|
"express": "^4.18.3",
|
|
31
|
+
"lru-cache": "^11.0.2",
|
|
31
32
|
"rxjs": "^7.8.1",
|
|
32
33
|
"@deno/shim-deno": "~0.18.0"
|
|
33
34
|
},
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import { Activation } from '../dsl/http/types.js';
|
|
1
2
|
import { Logger } from '../observability/logging/Logger.js';
|
|
2
3
|
export interface Context<D> {
|
|
3
4
|
log: Logger;
|
|
4
5
|
executionId: string;
|
|
5
6
|
startTime: Date;
|
|
7
|
+
activation?: Activation;
|
|
6
8
|
data: D;
|
|
7
9
|
}
|
|
8
10
|
export interface InternalContext<D, Index = void> extends Context<D> {
|
|
9
11
|
withData<D2>(data: D2): InternalContext<D2, Index>;
|
|
12
|
+
withActivation(activation: Activation | undefined): InternalContext<D, Index>;
|
|
10
13
|
setIndex(idx: number): InternalContext<D, number>;
|
|
11
14
|
idx: Index;
|
|
12
15
|
}
|
|
@@ -14,10 +17,12 @@ export declare class ContextImpl<D, Index = void> implements InternalContext<D,
|
|
|
14
17
|
log: Logger;
|
|
15
18
|
executionId: string;
|
|
16
19
|
startTime: Date;
|
|
20
|
+
activation?: Activation | undefined;
|
|
17
21
|
data: D;
|
|
18
22
|
idx: Index;
|
|
19
|
-
constructor(log: Logger, executionId: string, startTime: Date, data: D);
|
|
23
|
+
constructor(log: Logger, executionId: string, startTime: Date, data: D, activation?: Activation | undefined);
|
|
20
24
|
setIndex(idx: number): InternalContext<D, number>;
|
|
25
|
+
withActivation(activation: Activation | undefined): InternalContext<D, Index>;
|
|
21
26
|
withData<D2>(data: D2): InternalContext<D2, Index>;
|
|
22
27
|
}
|
|
23
28
|
//# sourceMappingURL=Context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/src/context/Context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAE5D,MAAM,WAAW,OAAO,CAAC,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,EAAE,CAAC,CAAC;CACX;AAED,MAAM,WAAW,eAAe,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IAChE,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,eAAe,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACnD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAClD,GAAG,EAAE,KAAK,CAAC;CACd;AAED,qBAAa,WAAW,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAE,YAAW,eAAe,CAAC,CAAC,EAAE,KAAK,CAAC;IAC1E,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,EAAE,CAAC,CAAC;IAER,GAAG,EAAE,KAAK,CAAC;gBAEC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/src/context/Context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,M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AE,KAAK,CAAC;IAS7E,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,eAAe,CAAC,EAAE,EAAE,KAAK,CAAC;CAGrD"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ContextImpl = void 0;
|
|
4
4
|
class ContextImpl {
|
|
5
|
-
constructor(log, executionId, startTime, data) {
|
|
5
|
+
constructor(log, executionId, startTime, data, activation = undefined) {
|
|
6
6
|
Object.defineProperty(this, "log", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
configurable: true,
|
|
@@ -21,6 +21,12 @@ class ContextImpl {
|
|
|
21
21
|
writable: true,
|
|
22
22
|
value: void 0
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(this, "activation", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
24
30
|
Object.defineProperty(this, "data", {
|
|
25
31
|
enumerable: true,
|
|
26
32
|
configurable: true,
|
|
@@ -36,16 +42,24 @@ class ContextImpl {
|
|
|
36
42
|
this.log = log;
|
|
37
43
|
this.executionId = executionId;
|
|
38
44
|
this.startTime = startTime;
|
|
45
|
+
this.activation = activation;
|
|
39
46
|
this.data = data;
|
|
40
47
|
this.idx = void 0;
|
|
41
48
|
}
|
|
42
49
|
setIndex(idx) {
|
|
43
|
-
const next = new ContextImpl(this.log, this.executionId, this.startTime, this.data);
|
|
50
|
+
const next = new ContextImpl(this.log, this.executionId, this.startTime, this.data, this.activation);
|
|
44
51
|
next.idx = idx;
|
|
45
52
|
return next;
|
|
46
53
|
}
|
|
54
|
+
withActivation(activation) {
|
|
55
|
+
// Essentially makes activation immutable once set
|
|
56
|
+
if (this.activation) {
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
return new ContextImpl(this.log, this.executionId, this.startTime, this.data, activation);
|
|
60
|
+
}
|
|
47
61
|
withData(data) {
|
|
48
|
-
return new ContextImpl(this.log, this.executionId, this.startTime, data);
|
|
62
|
+
return new ContextImpl(this.log, this.executionId, this.startTime, data, this.activation);
|
|
49
63
|
}
|
|
50
64
|
}
|
|
51
65
|
exports.ContextImpl = ContextImpl;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Logger } from '../observability/logging/Logger.js';
|
|
2
2
|
import { InternalContext } from './Context.js';
|
|
3
|
+
import { Activation } from '../dsl/http/types.js';
|
|
3
4
|
export interface ContextProvider {
|
|
4
|
-
create<D>(data: D): InternalContext<D, void>;
|
|
5
|
+
create<D>(data: D, activation: Activation | undefined): InternalContext<D, void>;
|
|
5
6
|
}
|
|
6
7
|
export declare class ContextProviderImpl implements ContextProvider {
|
|
7
8
|
log: Logger;
|
|
8
9
|
constructor(log: Logger);
|
|
9
|
-
create<D>(data: D): InternalContext<D, void>;
|
|
10
|
+
create<D>(data: D, activation?: Activation | undefined): InternalContext<D, void>;
|
|
10
11
|
}
|
|
11
12
|
//# sourceMappingURL=ContextProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextProvider.d.ts","sourceRoot":"","sources":["../../../src/src/context/ContextProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAe,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"ContextProvider.d.ts","sourceRoot":"","sources":["../../../src/src/context/ContextProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAe,eAAe,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,WAAW,eAAe;IAC5B,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;CACpF;AAED,qBAAa,mBAAoB,YAAW,eAAe;IACvD,GAAG,EAAE,MAAM,CAAC;gBAEA,GAAG,EAAE,MAAM;IAIvB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,UAAU,GAAE,UAAU,GAAG,SAAqB,GAAG,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC;CAK/F"}
|
|
@@ -13,9 +13,9 @@ class ContextProviderImpl {
|
|
|
13
13
|
});
|
|
14
14
|
this.log = log;
|
|
15
15
|
}
|
|
16
|
-
create(data) {
|
|
16
|
+
create(data, activation = undefined) {
|
|
17
17
|
const executionId = (0, mod_js_1.ulid)();
|
|
18
|
-
return new Context_js_1.ContextImpl(this.log.child({ executionId }), executionId, new Date(), data);
|
|
18
|
+
return new Context_js_1.ContextImpl(this.log.child({ executionId }), executionId, new Date(), data, activation);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
exports.ContextProviderImpl = ContextProviderImpl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/http/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjE;;;;GAIG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IAClE;;OAEG;;IAGH;;;;;;;OAOG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAE,OAAO,KAAa,GAAG,OAAO,CAAC,OAAO,KAAK,CAAC;IAIzE,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/http/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjE;;;;GAIG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IAClE;;OAEG;;IAGH;;;;;;;OAOG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAE,OAAO,KAAa,GAAG,OAAO,CAAC,OAAO,KAAK,CAAC;IAIzE,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC;CAKvF"}
|
|
@@ -23,7 +23,9 @@ class DefaultRoundTripperFactory {
|
|
|
23
23
|
return fn;
|
|
24
24
|
}
|
|
25
25
|
async createDynamic(templateName, fn) {
|
|
26
|
-
|
|
26
|
+
return async (userId, input, init) => {
|
|
27
|
+
return fetch(input, init);
|
|
28
|
+
};
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
exports.DefaultRoundTripperFactory = DefaultRoundTripperFactory;
|
|
@@ -1,14 +1,120 @@
|
|
|
1
|
-
export
|
|
2
|
-
getUserId(): string | undefined;
|
|
3
|
-
}
|
|
4
|
-
export type DynamicFetcher = (ctx: DynamicContext, input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
1
|
+
export type DynamicFetcher = (userId: string, input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
5
2
|
export interface RoundTripperFactory {
|
|
6
3
|
create(connName: string, fn: typeof fetch): Promise<typeof fetch>;
|
|
7
4
|
createDynamic(templateName: string, fn: typeof fetch): Promise<DynamicFetcher>;
|
|
8
5
|
}
|
|
6
|
+
export declare function wrapDynamicFetcher(fetcher: DynamicFetcher, userId: string): typeof fetch;
|
|
7
|
+
export interface ConnectionProvider {
|
|
8
|
+
getStaticConnection(cnxId: string): Promise<Connection | undefined>;
|
|
9
|
+
getEndUserConnection(templateId: string, userId: string): Promise<Connection | undefined>;
|
|
10
|
+
listActivations(): Promise<Activation[]>;
|
|
11
|
+
}
|
|
12
|
+
export type User = {
|
|
13
|
+
id: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
displayName: string;
|
|
17
|
+
externalId: string;
|
|
18
|
+
organisationId: string;
|
|
19
|
+
};
|
|
20
|
+
export type Activation = {
|
|
21
|
+
id: string;
|
|
22
|
+
user: User;
|
|
23
|
+
};
|
|
24
|
+
export type AuthSchemeType = 'none' | 'api-key' | 'basic-auth' | 'oauth2' | 'hmac' | 'jwt-bearer' | 'custom-function' | 'certificate' | 'oauth1';
|
|
9
25
|
export type AuthSchemeConfig = {
|
|
10
|
-
|
|
11
|
-
|
|
26
|
+
type: AuthSchemeType;
|
|
27
|
+
none?: AuthSchemeConfigNone;
|
|
28
|
+
apiKey?: AuthSchemeConfigApiKey;
|
|
29
|
+
basicAuth?: AuthSchemeConfigBasicAuth;
|
|
30
|
+
oauth2?: AuthSchemeConfigOAuth2;
|
|
31
|
+
oauth1?: AuthSchemeConfigOAuth1;
|
|
32
|
+
hmac?: AuthSchemeConfigHMAC;
|
|
33
|
+
certificate?: AuthSchemeConfigCertificate;
|
|
34
|
+
};
|
|
35
|
+
type AuthSchemeConfigBase = {
|
|
36
|
+
id: string;
|
|
37
|
+
description: string;
|
|
38
|
+
};
|
|
39
|
+
export type AuthSchemeConfigNone = AuthSchemeConfigBase & {
|
|
40
|
+
schemeType: 'none';
|
|
41
|
+
};
|
|
42
|
+
export type AuthSchemeConfigBasicAuth = AuthSchemeConfigBase & {
|
|
43
|
+
schemeType: 'basic-auth';
|
|
44
|
+
};
|
|
45
|
+
export type AuthSchemeConfigApiKey = AuthSchemeConfigBase & {
|
|
46
|
+
schemeType: 'api-key';
|
|
47
|
+
in: 'query' | 'header' | 'cookie';
|
|
48
|
+
name: string;
|
|
49
|
+
};
|
|
50
|
+
type OAuth2Scope = {
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
type OAuth2GrantAuthCode = {
|
|
55
|
+
credentialId: string;
|
|
56
|
+
organisationId: string;
|
|
57
|
+
clientId: string;
|
|
58
|
+
clientSecret: string;
|
|
59
|
+
};
|
|
60
|
+
type OAuth2GrantClientCredentials = {};
|
|
61
|
+
type OAuth2GrantPassword = {
|
|
62
|
+
credentialId: string;
|
|
63
|
+
organisationId: string;
|
|
64
|
+
clientId: string;
|
|
65
|
+
clientSecret: string;
|
|
66
|
+
};
|
|
67
|
+
type OAuth2Grant = {
|
|
68
|
+
type: 'authorizationCode' | 'clientCredentials' | 'password';
|
|
69
|
+
authorizationCode?: OAuth2GrantAuthCode;
|
|
70
|
+
clientCredentials?: OAuth2GrantClientCredentials;
|
|
71
|
+
password?: OAuth2GrantPassword;
|
|
72
|
+
};
|
|
73
|
+
export type AuthSchemeConfigOAuth2 = AuthSchemeConfigBase & {
|
|
74
|
+
schemeType: 'oauth2';
|
|
75
|
+
authorizeUrl: string;
|
|
76
|
+
tokenUrl: string;
|
|
77
|
+
scopes: OAuth2Scope[];
|
|
78
|
+
defaultScopes: string[];
|
|
79
|
+
additionalAuthorizeParams: string;
|
|
80
|
+
additionalTokenParams: string;
|
|
81
|
+
mltsEnabled: boolean;
|
|
82
|
+
mltsCredentialId: string;
|
|
83
|
+
grant: OAuth2Grant;
|
|
84
|
+
};
|
|
85
|
+
export type DigestInput = 'body' | 'url';
|
|
86
|
+
export type AuthSchemeConfigHMAC = AuthSchemeConfigBase & {
|
|
87
|
+
schemeType: 'hmac';
|
|
88
|
+
name: string;
|
|
89
|
+
in: 'query' | 'header' | 'cookie';
|
|
90
|
+
algorithm: 'sha1' | 'sha256' | 'sha512';
|
|
91
|
+
digestInputs: DigestInput[];
|
|
92
|
+
};
|
|
93
|
+
type ParameterConfig = {
|
|
94
|
+
parameterName: string;
|
|
95
|
+
targetName: string;
|
|
96
|
+
location: 'LOCATION_IGNORE' | 'LOCATION_QUERY' | 'LOCATION_HEADER' | 'LOCATION_BODY' | 'LOCATION_ENDPOINT' | 'LOCAITON_HEADER_PARAMETER';
|
|
97
|
+
usages: 'USAGE_UNKNOWN' | 'USAGE_TEMP_CREDENTIAL_ENDPOINT' | 'USAGE_TOKEN_REQUEST_ENDPOINT';
|
|
98
|
+
required: boolean;
|
|
99
|
+
modifiable: boolean;
|
|
100
|
+
};
|
|
101
|
+
type Endpoint = {
|
|
102
|
+
url: string;
|
|
103
|
+
additionalParamConfigs: ParameterConfig[];
|
|
104
|
+
parameterTransmission: 'AUTH_STYLE_AUTHORIZATION_HEADER' | 'AUTH_STYLE_QUERY' | 'AUTH_STYLE_FORM';
|
|
105
|
+
};
|
|
106
|
+
export type AuthSchemeConfigOAuth1 = AuthSchemeConfigBase & {
|
|
107
|
+
consumerKey: string;
|
|
108
|
+
consumerSecret: string;
|
|
109
|
+
schemeType: 'oauth1';
|
|
110
|
+
tempCredentialEndpoint: Endpoint;
|
|
111
|
+
resourceOwnerAuthorizationEndpoint: Endpoint;
|
|
112
|
+
tokenEndpoint: Endpoint;
|
|
113
|
+
signatureMethod: string;
|
|
114
|
+
credentialId: string;
|
|
115
|
+
};
|
|
116
|
+
export type AuthSchemeConfigCertificate = AuthSchemeConfigBase & {
|
|
117
|
+
schemeType: 'certificate';
|
|
12
118
|
};
|
|
13
119
|
export type Credential = {
|
|
14
120
|
data: Record<string, string>;
|
|
@@ -24,14 +130,13 @@ export type ConnectionCredential = {
|
|
|
24
130
|
};
|
|
25
131
|
export type Connection = {
|
|
26
132
|
createdAt: string;
|
|
27
|
-
credentials:
|
|
28
|
-
action: ConnectionCredential[];
|
|
29
|
-
trigger: ConnectionCredential[];
|
|
30
|
-
};
|
|
133
|
+
credentials: ConnectionCredential[];
|
|
31
134
|
id: string;
|
|
32
135
|
name: string;
|
|
136
|
+
templateId: string;
|
|
137
|
+
dynamic: boolean;
|
|
33
138
|
updatedAt: string;
|
|
34
|
-
|
|
139
|
+
baseUrl: string;
|
|
35
140
|
};
|
|
36
141
|
export type System = {
|
|
37
142
|
documentationUrl: string;
|
|
@@ -41,13 +146,14 @@ export type System = {
|
|
|
41
146
|
[key: string]: any;
|
|
42
147
|
};
|
|
43
148
|
};
|
|
44
|
-
export type
|
|
45
|
-
|
|
149
|
+
export type CnxMap = {
|
|
150
|
+
templateId?: string;
|
|
151
|
+
connId?: string;
|
|
152
|
+
dynamic?: boolean;
|
|
46
153
|
name: string;
|
|
47
|
-
authSchemeConfig: AuthSchemeConfig;
|
|
48
154
|
};
|
|
49
155
|
export type VersoriSDKConfig = {
|
|
50
|
-
|
|
51
|
-
connections: Connection[];
|
|
156
|
+
mappings: CnxMap[];
|
|
52
157
|
};
|
|
158
|
+
export {};
|
|
53
159
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/http/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/http/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEjH,MAAM,WAAW,mBAAmB;IAChC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,KAAK,GAAG,OAAO,CAAC,OAAO,KAAK,CAAC,CAAC;IAClE,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAClF;AAGD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,KAAK,CAIxF;AAED,MAAM,WAAW,kBAAkB;IAC/B,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IACpE,oBAAoB,CAAC,UA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apDynamicFetcher = wrapDynamicFetcher;
|
|
4
|
+
// this function might be better being a method on DynamicFetcher or something like that
|
|
5
|
+
function wrapDynamicFetcher(fetcher, userId) {
|
|
6
|
+
return (input, init) => {
|
|
7
|
+
return fetcher(userId, input, init);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -2,11 +2,11 @@ import { VersoriSDKConfig } from '../types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Loads the Versori SDK configuration from a JSON file.
|
|
4
4
|
*
|
|
5
|
-
* This function reads the
|
|
5
|
+
* This function reads the config file synchronously and parses its content
|
|
6
6
|
* into a `VersoriSDKConfig` object. This assumes the config file is in the root where
|
|
7
7
|
* the application is run.
|
|
8
8
|
*
|
|
9
9
|
* @returns {VersoriSDKConfig} The parsed configuration object.
|
|
10
10
|
*/
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function LoadConfigFromFile(): VersoriSDKConfig;
|
|
12
12
|
//# sourceMappingURL=configloader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configloader.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/configloader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"configloader.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/configloader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/C;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,IAAI,gBAAgB,CAUrD"}
|
|
@@ -23,18 +23,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.LoadConfigFromFile = LoadConfigFromFile;
|
|
27
27
|
const dntShim = __importStar(require("../../../../_dnt.shims.js"));
|
|
28
|
+
const constants_js_1 = require("./constants.js");
|
|
28
29
|
/**
|
|
29
30
|
* Loads the Versori SDK configuration from a JSON file.
|
|
30
31
|
*
|
|
31
|
-
* This function reads the
|
|
32
|
+
* This function reads the config file synchronously and parses its content
|
|
32
33
|
* into a `VersoriSDKConfig` object. This assumes the config file is in the root where
|
|
33
34
|
* the application is run.
|
|
34
35
|
*
|
|
35
36
|
* @returns {VersoriSDKConfig} The parsed configuration object.
|
|
36
37
|
*/
|
|
37
|
-
function
|
|
38
|
-
|
|
38
|
+
function LoadConfigFromFile() {
|
|
39
|
+
// Get the config file name from the environment variable
|
|
40
|
+
const configFileName = dntShim.Deno.env.get(constants_js_1.envVarConfigFile);
|
|
41
|
+
if (!configFileName) {
|
|
42
|
+
throw new Error(`Environment variable ${constants_js_1.envVarConfigFile} is not set`);
|
|
43
|
+
}
|
|
44
|
+
const cfg = JSON.parse(dntShim.Deno.readTextFileSync(configFileName));
|
|
39
45
|
return cfg;
|
|
40
46
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const envVarOrgId = "RUN_ORGANISATION_ID";
|
|
2
|
+
export declare const envVarEnvId = "RUN_ENVIRONMENT_ID";
|
|
3
|
+
export declare const envVarPlatformApiBaseURL = "RUN_PLATFORM_API_INTERNAL_URL";
|
|
4
|
+
export declare const envVarCredsBaseURL = "RUN_CREDENTIALS_SERVICE_INTERNAL_URL";
|
|
5
|
+
export declare const envVarConfigFile = "RUN_CONFIG_FILE";
|
|
6
|
+
export declare const envVarClientId = "RUN_CLIENT_ID";
|
|
7
|
+
export declare const envVarClientSecret = "RUN_CLIENT_SECRET";
|
|
8
|
+
export declare const envVarTokenEndpoint = "RUN_TOKEN_ENDPOINT";
|
|
9
|
+
export declare const envVarInternalToken = "RUN_INTERNAL_TOKEN";
|
|
10
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +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,wBAAwB,kCAAkC,CAAC;AACxE,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AAGzE,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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.envVarInternalToken = exports.envVarTokenEndpoint = exports.envVarClientSecret = exports.envVarClientId = exports.envVarConfigFile = exports.envVarCredsBaseURL = exports.envVarPlatformApiBaseURL = exports.envVarEnvId = exports.envVarOrgId = void 0;
|
|
4
|
+
// This file contains constants used in the Versori DSL HTTP client.
|
|
5
|
+
exports.envVarOrgId = 'RUN_ORGANISATION_ID';
|
|
6
|
+
exports.envVarEnvId = 'RUN_ENVIRONMENT_ID';
|
|
7
|
+
exports.envVarPlatformApiBaseURL = 'RUN_PLATFORM_API_INTERNAL_URL';
|
|
8
|
+
exports.envVarCredsBaseURL = 'RUN_CREDENTIALS_SERVICE_INTERNAL_URL';
|
|
9
|
+
// The following environment variables are used for the config file
|
|
10
|
+
exports.envVarConfigFile = 'RUN_CONFIG_FILE';
|
|
11
|
+
// The following environment variables are used for internal authentication
|
|
12
|
+
exports.envVarClientId = 'RUN_CLIENT_ID';
|
|
13
|
+
exports.envVarClientSecret = 'RUN_CLIENT_SECRET';
|
|
14
|
+
exports.envVarTokenEndpoint = 'RUN_TOKEN_ENDPOINT';
|
|
15
|
+
exports.envVarInternalToken = 'RUN_INTERNAL_TOKEN';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalauth.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/internalauth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"internalauth.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/internalauth.ts"],"names":[],"mappings":"AAGA,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;;IA2BpB,QAAQ;CAsBjB"}
|
|
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.InternalAuth = void 0;
|
|
27
27
|
const dntShim = __importStar(require("../../../../_dnt.shims.js"));
|
|
28
|
+
const constants_js_1 = require("./constants.js");
|
|
28
29
|
class InternalAuth {
|
|
29
30
|
constructor() {
|
|
30
31
|
Object.defineProperty(this, "clientId", {
|
|
@@ -57,25 +58,25 @@ class InternalAuth {
|
|
|
57
58
|
writable: true,
|
|
58
59
|
value: void 0
|
|
59
60
|
});
|
|
60
|
-
this.clientId = dntShim.Deno.env.get(
|
|
61
|
-
this.clientSecret = dntShim.Deno.env.get(
|
|
62
|
-
this.tokenEndpoint = dntShim.Deno.env.get(
|
|
61
|
+
this.clientId = dntShim.Deno.env.get(constants_js_1.envVarClientId) || '';
|
|
62
|
+
this.clientSecret = dntShim.Deno.env.get(constants_js_1.envVarClientSecret) || '';
|
|
63
|
+
this.tokenEndpoint = dntShim.Deno.env.get(constants_js_1.envVarTokenEndpoint) || '';
|
|
63
64
|
this.accessToken = '';
|
|
64
65
|
this.expiresAt = 0;
|
|
65
|
-
if (dntShim.Deno.env.get(
|
|
66
|
-
this.accessToken = dntShim.Deno.env.get(
|
|
66
|
+
if (dntShim.Deno.env.get(constants_js_1.envVarInternalToken)) {
|
|
67
|
+
this.accessToken = dntShim.Deno.env.get(constants_js_1.envVarInternalToken) || '';
|
|
67
68
|
this.expiresAt = Date.now() + 365 * 24 * 60 * 60 * 1000; // expires in 1 year
|
|
68
|
-
console.log(
|
|
69
|
+
console.log(`Using static token provided by ${constants_js_1.envVarInternalToken}`);
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
72
|
if (!this.clientId || !this.clientSecret || !this.tokenEndpoint) {
|
|
72
73
|
const missingVars = [];
|
|
73
74
|
if (!this.clientId)
|
|
74
|
-
missingVars.push(
|
|
75
|
+
missingVars.push(constants_js_1.envVarClientId);
|
|
75
76
|
if (!this.clientSecret)
|
|
76
|
-
missingVars.push(
|
|
77
|
+
missingVars.push(constants_js_1.envVarClientSecret);
|
|
77
78
|
if (!this.tokenEndpoint)
|
|
78
|
-
missingVars.push(
|
|
79
|
+
missingVars.push(constants_js_1.envVarTokenEndpoint);
|
|
79
80
|
throw new Error(`Missing environment variables: ${missingVars.join(', ')}`);
|
|
80
81
|
}
|
|
81
82
|
}
|