@versori/run 0.4.4 → 0.5.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/DirectConnectionFactory.js +2 -2
- package/esm/src/connection/internal/CredentialHolder.d.ts.map +1 -1
- package/esm/src/connection/internal/CredentialHolder.js +1 -1
- package/esm/src/connection/internal/FetchBuilder.d.ts +9 -2
- package/esm/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/esm/src/connection/internal/FetchBuilder.js +120 -4
- package/esm/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/internal/OutboundConnectionFactory.js +2 -2
- package/esm/src/context/Context.d.ts +1 -0
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +3 -0
- package/esm/src/context/ContextProvider.d.ts +1 -1
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +1 -1
- package/esm/src/dsl/Workflow.d.ts.map +1 -1
- package/esm/src/dsl/Workflow.js +2 -0
- package/esm/src/dsl/http/types.d.ts +2 -0
- package/esm/src/dsl/http/types.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/configloader.js +1 -1
- package/esm/src/dsl/http/versori/cronapi.d.ts +2 -3
- package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/cronapi.js +14 -15
- package/esm/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/webhookmiddleware.js +69 -38
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.js +3 -1
- package/esm/src/internal/InternalAuth.d.ts +0 -1
- package/esm/src/internal/InternalAuth.d.ts.map +1 -1
- package/esm/src/internal/InternalAuth.js +1 -14
- package/esm/src/internal/constants.d.ts +3 -1
- package/esm/src/internal/constants.d.ts.map +1 -1
- package/esm/src/internal/constants.js +4 -1
- package/esm/src/internal/supervisor.d.ts +25 -0
- package/esm/src/internal/supervisor.d.ts.map +1 -0
- package/esm/src/internal/supervisor.js +156 -0
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/durable/DurableInterpreter.js +79 -27
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
- package/esm/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/durable/Queue.js +1 -1
- package/esm/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/catch.js +1 -0
- package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/fn.js +19 -4
- package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/http.js +40 -7
- package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/schedule.js +2 -1
- package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/durable/compilers/webhook.js +14 -4
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +7 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +78 -18
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
- package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/catch.js +1 -0
- package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/fn.js +19 -16
- package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/http.js +39 -6
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.js +2 -1
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +15 -4
- package/esm/src/issues/Issues.js +1 -1
- package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/package.json +3 -1
- package/script/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/DirectConnectionFactory.js +2 -2
- package/script/src/connection/internal/CredentialHolder.d.ts.map +1 -1
- package/script/src/connection/internal/CredentialHolder.js +1 -1
- package/script/src/connection/internal/FetchBuilder.d.ts +9 -2
- package/script/src/connection/internal/FetchBuilder.d.ts.map +1 -1
- package/script/src/connection/internal/FetchBuilder.js +143 -4
- package/script/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/internal/OutboundConnectionFactory.js +2 -2
- package/script/src/context/Context.d.ts +1 -0
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +3 -0
- package/script/src/context/ContextProvider.d.ts +1 -1
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +1 -1
- package/script/src/dsl/Workflow.d.ts.map +1 -1
- package/script/src/dsl/Workflow.js +2 -0
- package/script/src/dsl/http/types.d.ts +2 -0
- package/script/src/dsl/http/types.d.ts.map +1 -1
- package/script/src/dsl/http/versori/configloader.js +1 -1
- package/script/src/dsl/http/versori/cronapi.d.ts +2 -3
- package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/cronapi.js +14 -15
- package/script/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
- package/script/src/dsl/http/versori/webhookmiddleware.js +69 -38
- package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.js +3 -1
- package/script/src/internal/InternalAuth.d.ts +0 -1
- package/script/src/internal/InternalAuth.d.ts.map +1 -1
- package/script/src/internal/InternalAuth.js +0 -13
- package/script/src/internal/constants.d.ts +3 -1
- package/script/src/internal/constants.d.ts.map +1 -1
- package/script/src/internal/constants.js +5 -2
- package/script/src/internal/supervisor.d.ts +25 -0
- package/script/src/internal/supervisor.d.ts.map +1 -0
- package/script/src/internal/supervisor.js +163 -0
- package/script/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
- package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/durable/DurableInterpreter.js +84 -32
- package/script/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
- package/script/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/durable/Queue.js +1 -1
- package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/catch.js +1 -0
- package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/fn.js +19 -4
- package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/http.js +40 -7
- package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/schedule.js +2 -1
- package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/durable/compilers/webhook.js +14 -4
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +7 -1
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +78 -18
- package/script/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
- package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/catch.js +1 -0
- package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/fn.js +19 -16
- package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/http.js +39 -6
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.js +2 -1
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +15 -4
- package/script/src/issues/Issues.js +1 -1
- package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
- package/esm/src/dsl/http/default.d.ts +0 -26
- package/esm/src/dsl/http/default.d.ts.map +0 -1
- package/esm/src/dsl/http/default.js +0 -56
- package/esm/src/dsl/http/versori/cli.d.ts +0 -2
- package/esm/src/dsl/http/versori/cli.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/cli.js +0 -32
- package/esm/src/dsl/http/versori/constants.d.ts +0 -20
- package/esm/src/dsl/http/versori/constants.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/constants.js +0 -37
- package/esm/src/dsl/http/versori/internalauth.d.ts +0 -15
- package/esm/src/dsl/http/versori/internalauth.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/internalauth.js +0 -102
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/proxyroundtripper.js +0 -208
- package/esm/src/internal/cli.d.ts +0 -2
- package/esm/src/internal/cli.d.ts.map +0 -1
- package/esm/src/internal/cli.js +0 -32
- package/script/src/dsl/http/default.d.ts +0 -26
- package/script/src/dsl/http/default.d.ts.map +0 -1
- package/script/src/dsl/http/default.js +0 -60
- package/script/src/dsl/http/versori/cli.d.ts +0 -2
- package/script/src/dsl/http/versori/cli.d.ts.map +0 -1
- package/script/src/dsl/http/versori/cli.js +0 -35
- package/script/src/dsl/http/versori/constants.d.ts +0 -20
- package/script/src/dsl/http/versori/constants.d.ts.map +0 -1
- package/script/src/dsl/http/versori/constants.js +0 -40
- package/script/src/dsl/http/versori/internalauth.d.ts +0 -15
- package/script/src/dsl/http/versori/internalauth.d.ts.map +0 -1
- package/script/src/dsl/http/versori/internalauth.js +0 -106
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
- package/script/src/dsl/http/versori/proxyroundtripper.js +0 -212
- package/script/src/internal/cli.d.ts +0 -2
- package/script/src/internal/cli.d.ts.map +0 -1
- package/script/src/internal/cli.js +0 -35
|
@@ -16,17 +16,31 @@ exports.httpCompiler = void 0;
|
|
|
16
16
|
const rxjs_1 = require("rxjs");
|
|
17
17
|
const operators_1 = require("rxjs/operators");
|
|
18
18
|
const DynamicFetchFactory_js_1 = require("../../../connection/DynamicFetchFactory.js");
|
|
19
|
+
const FetchBuilder_js_1 = require("../../../connection/internal/FetchBuilder.js");
|
|
19
20
|
const StaticFetchFactory_js_1 = require("../../../connection/StaticFetchFactory.js");
|
|
20
21
|
const HttpTask_js_1 = require("../../../dsl/tasks/HttpTask.js");
|
|
22
|
+
const supervisor_js_1 = require("../../../internal/supervisor.js");
|
|
21
23
|
function compileHttp(compilerCtx, task) {
|
|
22
24
|
const cnxMap = compilerCtx.configReader.getCnxMapping(task.opts.connection);
|
|
23
25
|
let fetchFactory;
|
|
24
26
|
if (!cnxMap) {
|
|
25
|
-
compilerCtx.log.
|
|
26
|
-
|
|
27
|
+
compilerCtx.log.warn(`Connection ${task.opts.connection} not found, using default fetch with no credentials`);
|
|
28
|
+
if (supervisor_js_1.enabled) {
|
|
29
|
+
// missing connection map and we are in supervised mode, so we use the fake fetcher
|
|
30
|
+
fetchFactory = Promise.resolve(new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// missing connection map and not in supervised mode, so we use global fetch
|
|
34
|
+
fetchFactory = Promise.resolve(new StaticFetchFactory_js_1.StaticFetchFactory(globalThis.fetch));
|
|
35
|
+
}
|
|
27
36
|
}
|
|
28
37
|
else if (cnxMap.dynamic) {
|
|
29
|
-
|
|
38
|
+
if (cnxMap.mockWithAI) {
|
|
39
|
+
fetchFactory = Promise.resolve(new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, { name: task.opts.connection }).buildSupervisedFetch()));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
fetchFactory = Promise.resolve(new DynamicFetchFactory_js_1.DynamicFetchFactory(compilerCtx.cnxFactory, compilerCtx.platformApi, compilerCtx.organisationId, cnxMap.templateId));
|
|
43
|
+
}
|
|
30
44
|
}
|
|
31
45
|
else {
|
|
32
46
|
fetchFactory = compilerCtx.platformApi.getConnection({
|
|
@@ -36,8 +50,21 @@ function compileHttp(compilerCtx, task) {
|
|
|
36
50
|
},
|
|
37
51
|
throwOnError: true,
|
|
38
52
|
})
|
|
39
|
-
.then(({ data }) =>
|
|
40
|
-
.
|
|
53
|
+
.then(({ data }) => {
|
|
54
|
+
if (cnxMap.mockWithAI) {
|
|
55
|
+
// use the fake fetcher that calls the supervisor to generate a mock reponse
|
|
56
|
+
return new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, data).buildSupervisedFetch());
|
|
57
|
+
}
|
|
58
|
+
return Promise.all([compilerCtx.cnxFactory.fetcher(data), data.baseUrl ?? ''])
|
|
59
|
+
.then(([fetcher, baseUrl]) => new StaticFetchFactory_js_1.StaticFetchFactory(fetcher, baseUrl));
|
|
60
|
+
})
|
|
61
|
+
.catch((err) => {
|
|
62
|
+
compilerCtx.log.error(`Failed to get connection ${task.opts.connection}`, err);
|
|
63
|
+
if (supervisor_js_1.enabled) {
|
|
64
|
+
return new StaticFetchFactory_js_1.StaticFetchFactory(new FetchBuilder_js_1.FetchBuilder(globalThis.fetch, { name: task.opts.connection }).build());
|
|
65
|
+
}
|
|
66
|
+
throw err;
|
|
67
|
+
});
|
|
41
68
|
}
|
|
42
69
|
async function http(ctx) {
|
|
43
70
|
const [fetch, baseUrl] = await fetchFactory.then((ff) => Promise.all([ff.fetcher(ctx), ff.baseUrl(ctx)]));
|
|
@@ -51,10 +78,16 @@ function compileHttp(compilerCtx, task) {
|
|
|
51
78
|
return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
|
|
52
79
|
span.setAttribute('task.id', task.id);
|
|
53
80
|
span.setAttribute('task.type', 'http');
|
|
81
|
+
span.setAttribute('type', 'task');
|
|
54
82
|
span.setAttribute('execution.id', ctx.executionId);
|
|
55
83
|
span.setAttribute('connection.name', task.opts.connection);
|
|
84
|
+
const spanContext = span.spanContext();
|
|
56
85
|
try {
|
|
57
|
-
|
|
86
|
+
const newCtx = await http(ctx.withLogger(ctx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId })));
|
|
87
|
+
if (supervisor_js_1.enabled) {
|
|
88
|
+
span.setAttribute('response.body', JSON.stringify(newCtx.data));
|
|
89
|
+
}
|
|
90
|
+
return newCtx;
|
|
58
91
|
}
|
|
59
92
|
catch (error) {
|
|
60
93
|
if (error instanceof Error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAQzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAyI7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.scheduleCompiler = void 0;
|
|
16
16
|
const rxjs_1 = require("rxjs");
|
|
17
|
-
const constants_js_1 = require("../../../dsl/http/versori/constants.js");
|
|
18
17
|
const ScheduleTrigger_js_1 = require("../../../dsl/triggers/ScheduleTrigger.js");
|
|
18
|
+
const constants_js_1 = require("../../../internal/constants.js");
|
|
19
19
|
function compileSchedule(ctx, trigger, signal) {
|
|
20
20
|
return new rxjs_1.Observable((subscriber) => {
|
|
21
21
|
// Add HTTP endpoint for manual triggering
|
|
@@ -99,6 +99,7 @@ function compileSchedule(ctx, trigger, signal) {
|
|
|
99
99
|
await ctx.tracer.startActiveSpan(`schedule-${trigger.id}`, async (span) => {
|
|
100
100
|
span.setAttribute('task.id', trigger.id);
|
|
101
101
|
span.setAttribute('task.type', 'schedule');
|
|
102
|
+
span.setAttribute('type', 'task');
|
|
102
103
|
span.setAttribute('schedule', trigger.schedule);
|
|
103
104
|
span.setAttribute('project.id', projectId);
|
|
104
105
|
span.setAttribute('environment.id', environmentId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CA4TxE,CAAC"}
|
|
@@ -18,12 +18,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.webhookCompiler = void 0;
|
|
19
19
|
const cors_1 = __importDefault(require("cors"));
|
|
20
20
|
const express_1 = __importDefault(require("express"));
|
|
21
|
+
const express_xml_bodyparser_1 = __importDefault(require("express-xml-bodyparser"));
|
|
21
22
|
const promises_1 = require("node:stream/promises");
|
|
22
23
|
const rxjs_1 = require("rxjs");
|
|
23
24
|
const webhookmiddleware_js_1 = require("../../../dsl/http/versori/webhookmiddleware.js");
|
|
24
25
|
const WebhookTrigger_js_1 = require("../../../dsl/triggers/WebhookTrigger.js");
|
|
25
26
|
const constants_js_1 = require("../../../internal/constants.js");
|
|
26
|
-
const express_xml_bodyparser_1 = __importDefault(require("express-xml-bodyparser"));
|
|
27
27
|
const xml2jsDefaults = {
|
|
28
28
|
explicitArray: false,
|
|
29
29
|
normalize: false,
|
|
@@ -123,6 +123,7 @@ exports.webhookCompiler = {
|
|
|
123
123
|
ctx.webhookRouter.use((0, cors_1.default)(corsOptions));
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
+
ctx.webhookRegistry.set(trigger.id, { method, path: `/${trigger.id}`, options: trigger.options });
|
|
126
127
|
// endpoint for sans user because I'm not quite sure how the dynamic routing works
|
|
127
128
|
ctx.webhookRouter[method](`/${trigger.id}`, (0, webhookmiddleware_js_1.createStaticWebhookMiddleware)({
|
|
128
129
|
id: trigger.id,
|
|
@@ -137,8 +138,12 @@ exports.webhookCompiler = {
|
|
|
137
138
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
138
139
|
span.setAttribute('task.id', trigger.id);
|
|
139
140
|
span.setAttribute('task.type', 'webhook');
|
|
141
|
+
span.setAttribute('type', 'task');
|
|
140
142
|
const staticActivation = res.locals.activation;
|
|
141
|
-
|
|
143
|
+
let executionCtx = ctx.contextProvider.create(staticActivation, req.body, ctxOptionsFn(req, res));
|
|
144
|
+
const spanContext = span.spanContext();
|
|
145
|
+
executionCtx = executionCtx.withLogger(executionCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
146
|
+
executionCtx.log.info("stack", { stack: new Error().stack });
|
|
142
147
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
143
148
|
try {
|
|
144
149
|
subscriber.next(executionCtx);
|
|
@@ -173,6 +178,7 @@ exports.webhookCompiler = {
|
|
|
173
178
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
174
179
|
span.setAttribute('task.id', trigger.id);
|
|
175
180
|
span.setAttribute('task.type', 'webhook');
|
|
181
|
+
span.setAttribute('type', 'task');
|
|
176
182
|
span.setAttribute('user.id', req.params.userId);
|
|
177
183
|
const userId = req.params.userId;
|
|
178
184
|
// Right now we only support a user having one activation
|
|
@@ -189,7 +195,9 @@ exports.webhookCompiler = {
|
|
|
189
195
|
span.end();
|
|
190
196
|
return;
|
|
191
197
|
}
|
|
192
|
-
|
|
198
|
+
let executionCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
|
|
199
|
+
const spanContext = span.spanContext();
|
|
200
|
+
executionCtx = executionCtx.withLogger(executionCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
193
201
|
span.setAttribute('execution.id', executionCtx.executionId);
|
|
194
202
|
const errors = [];
|
|
195
203
|
try {
|
|
@@ -229,6 +237,7 @@ exports.webhookCompiler = {
|
|
|
229
237
|
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
230
238
|
span.setAttribute('task.id', trigger.id);
|
|
231
239
|
span.setAttribute('task.type', 'webhook');
|
|
240
|
+
span.setAttribute('type', 'task');
|
|
232
241
|
span.setAttribute('activation.id', req.params.activationId);
|
|
233
242
|
const activation = res.locals.activation;
|
|
234
243
|
const activationId = activation?.id ?? req.params.activationId;
|
|
@@ -243,7 +252,9 @@ exports.webhookCompiler = {
|
|
|
243
252
|
span.end();
|
|
244
253
|
return;
|
|
245
254
|
}
|
|
246
|
-
|
|
255
|
+
let activationCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
|
|
256
|
+
const spanContext = span.spanContext();
|
|
257
|
+
activationCtx = activationCtx.withLogger(activationCtx.log.child({ spanId: spanContext.spanId, traceId: spanContext.traceId }));
|
|
247
258
|
span.setAttribute('execution.id', activationCtx.executionId);
|
|
248
259
|
try {
|
|
249
260
|
subscriber.next(activationCtx);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.MockIssues = exports.IssueImpl = void 0;
|
|
16
16
|
const node_crypto_1 = require("node:crypto");
|
|
17
|
-
const constants_js_1 = require("../
|
|
17
|
+
const constants_js_1 = require("../internal/constants.js");
|
|
18
18
|
class IssueImpl {
|
|
19
19
|
constructor(log) {
|
|
20
20
|
Object.defineProperty(this, "baseUrl", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsoleLogger.d.ts","sourceRoot":"","sources":["../../../../src/src/observability/logging/ConsoleLogger.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,GAAG,MAAM,+CAA+C,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ConsoleLogger.d.ts","sourceRoot":"","sources":["../../../../src/src/observability/logging/ConsoleLogger.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,GAAG,MAAM,+CAA+C,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAqM/C;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,MAAM;IACxC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC;IAEhB,KAAK,EAAE,QAAQ,CAAC;IAEhB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAEpB,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAOjE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO9D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO7D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO7D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAC3E,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAsB9D,KAAK,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,aAAa;IAOvD,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;CAGlC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { DynamicFetcher, RoundTripperFactory } from './types.js';
|
|
2
|
-
import { CredentialsProvider } from './versori/contextcredentials.js';
|
|
3
|
-
/**
|
|
4
|
-
* A factory class for creating a default round tripper.
|
|
5
|
-
* This class is used to provide a default implementation for initializing
|
|
6
|
-
* if no round tripper factory is given.
|
|
7
|
-
*/
|
|
8
|
-
export declare class DefaultRoundTripperFactory implements RoundTripperFactory {
|
|
9
|
-
/**
|
|
10
|
-
* Constructs a new instance of the DefaultRoundTripperFactory.
|
|
11
|
-
*/
|
|
12
|
-
constructor();
|
|
13
|
-
/**
|
|
14
|
-
* Creates a round tripper function.
|
|
15
|
-
* This implementation simply returns the fetch function passed to it.
|
|
16
|
-
*
|
|
17
|
-
* @param connName - The name of the connection.
|
|
18
|
-
* @param fn - The fetch function to be used. Defaults to the global fetch function.
|
|
19
|
-
* @returns A promise that resolves to the fetch function.
|
|
20
|
-
*/
|
|
21
|
-
create(_connName: string): Promise<typeof fetch>;
|
|
22
|
-
createDynamic(_templateName: string): Promise<DynamicFetcher>;
|
|
23
|
-
credentials(): CredentialsProvider;
|
|
24
|
-
baseUrlFetcher(_connName: string): (activationId: string) => Promise<string>;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=default.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/http/default.ts"],"names":[],"mappings":"AAcA,OAAO,EAAc,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE;;;;GAIG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IAClE;;OAEG;;IAIH;;;;;;;OAOG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,CAAC;IAIhD,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAU7D,WAAW,IAAI,mBAAmB;IAclC,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC;CAG/E"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 Versori Group Inc
|
|
3
|
-
*
|
|
4
|
-
* Use of this software is governed by the Business Source License 1.1
|
|
5
|
-
* included in the LICENSE file at the root of this repository.
|
|
6
|
-
*
|
|
7
|
-
* Change Date: 2029-01-01
|
|
8
|
-
* Change License: Apache License, Version 2.0
|
|
9
|
-
*
|
|
10
|
-
* As of the Change Date, in accordance with the Business Source License,
|
|
11
|
-
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
|
-
*/
|
|
13
|
-
import { create } from '@bufbuild/protobuf';
|
|
14
|
-
import { oauth1v1 } from '../../services/credentials/mod.js';
|
|
15
|
-
/**
|
|
16
|
-
* A factory class for creating a default round tripper.
|
|
17
|
-
* This class is used to provide a default implementation for initializing
|
|
18
|
-
* if no round tripper factory is given.
|
|
19
|
-
*/
|
|
20
|
-
export class DefaultRoundTripperFactory {
|
|
21
|
-
/**
|
|
22
|
-
* Constructs a new instance of the DefaultRoundTripperFactory.
|
|
23
|
-
*/
|
|
24
|
-
constructor() {
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Creates a round tripper function.
|
|
28
|
-
* This implementation simply returns the fetch function passed to it.
|
|
29
|
-
*
|
|
30
|
-
* @param connName - The name of the connection.
|
|
31
|
-
* @param fn - The fetch function to be used. Defaults to the global fetch function.
|
|
32
|
-
* @returns A promise that resolves to the fetch function.
|
|
33
|
-
*/
|
|
34
|
-
create(_connName) {
|
|
35
|
-
return Promise.resolve(globalThis.fetch);
|
|
36
|
-
}
|
|
37
|
-
createDynamic(_templateName) {
|
|
38
|
-
return Promise.resolve((_activation, input, init) => {
|
|
39
|
-
return globalThis.fetch(input, init);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
credentials() {
|
|
43
|
-
return {
|
|
44
|
-
getRaw: () => Promise.resolve(new Uint8Array(0)),
|
|
45
|
-
getAccessToken: () => Promise.resolve({
|
|
46
|
-
accessToken: '',
|
|
47
|
-
tokenType: '',
|
|
48
|
-
expiry: undefined,
|
|
49
|
-
}),
|
|
50
|
-
getOAuth1Metadata: () => Promise.resolve(create(oauth1v1.GetAuthorizationMetadataResponseSchema)), // Create empty response
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
baseUrlFetcher(_connName) {
|
|
54
|
-
return (_activationId) => Promise.resolve('');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/cli.ts"],"names":[],"mappings":"AA8BA,wBAAgB,gBAAgB,IAAI,MAAM,CAmBzC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 Versori Group Inc
|
|
3
|
-
*
|
|
4
|
-
* Use of this software is governed by the Business Source License 1.1
|
|
5
|
-
* included in the LICENSE file at the root of this repository.
|
|
6
|
-
*
|
|
7
|
-
* Change Date: 2029-01-01
|
|
8
|
-
* Change License: Apache License, Version 2.0
|
|
9
|
-
*
|
|
10
|
-
* As of the Change Date, in accordance with the Business Source License,
|
|
11
|
-
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
|
-
*/
|
|
13
|
-
// This file contains functions that can read stuff generated by the Versori CLI. This is used when running locally.
|
|
14
|
-
import { homedir } from 'node:os';
|
|
15
|
-
const cookiesFileName = 'cookies.json';
|
|
16
|
-
const versoriCookieName = 'versori_sess';
|
|
17
|
-
export function getVersoriCookie() {
|
|
18
|
-
const cookiesFilePath = `${homedir()}/.config/versori/${cookiesFileName}`;
|
|
19
|
-
let cookiesFile;
|
|
20
|
-
try {
|
|
21
|
-
cookiesFile = JSON.parse(Deno.readTextFileSync(cookiesFilePath));
|
|
22
|
-
}
|
|
23
|
-
catch (e) {
|
|
24
|
-
console.error('Error reading file, have you run the Versori CLI to log in?');
|
|
25
|
-
throw new Error(`Failed to read or parse cookies file at ${cookiesFilePath}: ${e}`);
|
|
26
|
-
}
|
|
27
|
-
const versoriCookie = cookiesFile.cookies.find((cookie) => cookie.Name === versoriCookieName);
|
|
28
|
-
if (!versoriCookie) {
|
|
29
|
-
throw new Error(`Cookie 'versori_sess' not found in ${cookiesFilePath}`);
|
|
30
|
-
}
|
|
31
|
-
return `${versoriCookieName}=${versoriCookie.Value}`;
|
|
32
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare const envVarOrgId = "RUN_ORGANISATION_ID";
|
|
2
|
-
export declare const envVarEnvId = "RUN_ENVIRONMENT_ID";
|
|
3
|
-
export declare const envVarEnvironmentName = "RUN_ENVIRONMENT";
|
|
4
|
-
export declare const envVarProjectId = "RUN_SERVICE_ID";
|
|
5
|
-
export declare const envVarOrgSlug = "RUN_ORGANISATION_SLUG";
|
|
6
|
-
export declare const envVarPlatformApiBaseURL = "RUN_PLATFORM_API_INTERNAL_URL";
|
|
7
|
-
export declare const envVarCronApiBaseURL = "RUN_CRON_API_INTERNAL_URL";
|
|
8
|
-
export declare const envVarSDKApiBaseURL = "RUN_SDK_API_URL";
|
|
9
|
-
export declare const envVarSelfRefURL = "RUN_SELF_REF_URL";
|
|
10
|
-
export declare const envVarCredsBaseURL = "RUN_CREDENTIALS_SERVICE_INTERNAL_URL";
|
|
11
|
-
export declare const envVarOtelTracesURL = "RUN_OTEL_TRACES_URL";
|
|
12
|
-
export declare const envVarVersion = "RUN_SERVICE_VERSION";
|
|
13
|
-
export declare const envVarConfigFile = "RUN_CONFIG_FILE";
|
|
14
|
-
export declare const envVarClientId = "RUN_CLIENT_ID";
|
|
15
|
-
export declare const envVarClientSecret = "RUN_CLIENT_SECRET";
|
|
16
|
-
export declare const envVarTokenEndpoint = "RUN_TOKEN_ENDPOINT";
|
|
17
|
-
export declare const envVarInternalToken = "RUN_INTERNAL_TOKEN";
|
|
18
|
-
export declare const envVarLocalRun = "RUN_LOCAL";
|
|
19
|
-
export declare const cronPort = 3001;
|
|
20
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/constants.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,WAAW,wBAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAChD,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AACrD,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AACxE,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AACrD,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,aAAa,wBAAwB,CAAC;AAEnD,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAGlD,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AACxD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AAGxD,eAAO,MAAM,cAAc,cAAc,CAAC;AAG1C,eAAO,MAAM,QAAQ,OAAO,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 Versori Group Inc
|
|
3
|
-
*
|
|
4
|
-
* Use of this software is governed by the Business Source License 1.1
|
|
5
|
-
* included in the LICENSE file at the root of this repository.
|
|
6
|
-
*
|
|
7
|
-
* Change Date: 2029-01-01
|
|
8
|
-
* Change License: Apache License, Version 2.0
|
|
9
|
-
*
|
|
10
|
-
* As of the Change Date, in accordance with the Business Source License,
|
|
11
|
-
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
|
-
*/
|
|
13
|
-
//TODO(@teo): remove this file, it is implemented in the src/internal/constants.ts directory now.
|
|
14
|
-
// This file contains constants used in the Versori DSL HTTP client.
|
|
15
|
-
export const envVarOrgId = 'RUN_ORGANISATION_ID';
|
|
16
|
-
export const envVarEnvId = 'RUN_ENVIRONMENT_ID';
|
|
17
|
-
export const envVarEnvironmentName = 'RUN_ENVIRONMENT';
|
|
18
|
-
export const envVarProjectId = 'RUN_SERVICE_ID';
|
|
19
|
-
export const envVarOrgSlug = 'RUN_ORGANISATION_SLUG';
|
|
20
|
-
export const envVarPlatformApiBaseURL = 'RUN_PLATFORM_API_INTERNAL_URL';
|
|
21
|
-
export const envVarCronApiBaseURL = 'RUN_CRON_API_INTERNAL_URL';
|
|
22
|
-
export const envVarSDKApiBaseURL = 'RUN_SDK_API_URL';
|
|
23
|
-
export const envVarSelfRefURL = 'RUN_SELF_REF_URL';
|
|
24
|
-
export const envVarCredsBaseURL = 'RUN_CREDENTIALS_SERVICE_INTERNAL_URL';
|
|
25
|
-
export const envVarOtelTracesURL = 'RUN_OTEL_TRACES_URL';
|
|
26
|
-
export const envVarVersion = 'RUN_SERVICE_VERSION';
|
|
27
|
-
// The following environment variables are used for the config file
|
|
28
|
-
export const envVarConfigFile = 'RUN_CONFIG_FILE';
|
|
29
|
-
// The following environment variables are used for internal authentication
|
|
30
|
-
export const envVarClientId = 'RUN_CLIENT_ID';
|
|
31
|
-
export const envVarClientSecret = 'RUN_CLIENT_SECRET';
|
|
32
|
-
export const envVarTokenEndpoint = 'RUN_TOKEN_ENDPOINT';
|
|
33
|
-
export const envVarInternalToken = 'RUN_INTERNAL_TOKEN';
|
|
34
|
-
// The following are for running locally
|
|
35
|
-
export const envVarLocalRun = 'RUN_LOCAL';
|
|
36
|
-
// please no changerino
|
|
37
|
-
export const cronPort = 3001; // The port on which the cron API communicates with the service
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type internalAuthHeader = {
|
|
2
|
-
[key: string]: string;
|
|
3
|
-
};
|
|
4
|
-
export declare class InternalAuth {
|
|
5
|
-
private clientId;
|
|
6
|
-
private clientSecret;
|
|
7
|
-
private tokenEndpoint;
|
|
8
|
-
private runLocal;
|
|
9
|
-
private accessToken;
|
|
10
|
-
private expiresAt;
|
|
11
|
-
constructor();
|
|
12
|
-
getAuthHeader(): Promise<internalAuthHeader>;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=internalauth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internalauth.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/internalauth.ts"],"names":[],"mappings":"AAsBA,KAAK,kBAAkB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEpD,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAU;IAE1B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;;IAkCpB,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC;CA0BrD"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 Versori Group Inc
|
|
3
|
-
*
|
|
4
|
-
* Use of this software is governed by the Business Source License 1.1
|
|
5
|
-
* included in the LICENSE file at the root of this repository.
|
|
6
|
-
*
|
|
7
|
-
* Change Date: 2029-01-01
|
|
8
|
-
* Change License: Apache License, Version 2.0
|
|
9
|
-
*
|
|
10
|
-
* As of the Change Date, in accordance with the Business Source License,
|
|
11
|
-
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
|
-
*/
|
|
13
|
-
import { getVersoriCookie } from './cli.js';
|
|
14
|
-
import { envVarClientId, envVarClientSecret, envVarInternalToken, envVarLocalRun, envVarTokenEndpoint, } from './constants.js';
|
|
15
|
-
export class InternalAuth {
|
|
16
|
-
constructor() {
|
|
17
|
-
Object.defineProperty(this, "clientId", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
configurable: true,
|
|
20
|
-
writable: true,
|
|
21
|
-
value: void 0
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(this, "clientSecret", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true,
|
|
27
|
-
value: void 0
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(this, "tokenEndpoint", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true,
|
|
33
|
-
value: void 0
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(this, "runLocal", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
configurable: true,
|
|
38
|
-
writable: true,
|
|
39
|
-
value: void 0
|
|
40
|
-
});
|
|
41
|
-
Object.defineProperty(this, "accessToken", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
configurable: true,
|
|
44
|
-
writable: true,
|
|
45
|
-
value: void 0
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(this, "expiresAt", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
configurable: true,
|
|
50
|
-
writable: true,
|
|
51
|
-
value: void 0
|
|
52
|
-
});
|
|
53
|
-
this.clientId = Deno.env.get(envVarClientId) || '';
|
|
54
|
-
this.clientSecret = Deno.env.get(envVarClientSecret) || '';
|
|
55
|
-
this.tokenEndpoint = Deno.env.get(envVarTokenEndpoint) || '';
|
|
56
|
-
this.accessToken = '';
|
|
57
|
-
this.expiresAt = 0;
|
|
58
|
-
this.runLocal = Deno.env.get(envVarLocalRun) === 'true';
|
|
59
|
-
if (Deno.env.get(envVarInternalToken)) {
|
|
60
|
-
this.accessToken = Deno.env.get(envVarInternalToken) || '';
|
|
61
|
-
this.expiresAt = Date.now() + 365 * 24 * 60 * 60 * 1000; // expires in 1 year
|
|
62
|
-
console.log(`Using static token provided by ${envVarInternalToken}`);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (this.runLocal) {
|
|
66
|
-
console.info('Running in local mode using cookie for authentication');
|
|
67
|
-
this.accessToken = getVersoriCookie();
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (!this.clientId || !this.clientSecret || !this.tokenEndpoint) {
|
|
71
|
-
const missingVars = [];
|
|
72
|
-
if (!this.clientId)
|
|
73
|
-
missingVars.push(envVarClientId);
|
|
74
|
-
if (!this.clientSecret)
|
|
75
|
-
missingVars.push(envVarClientSecret);
|
|
76
|
-
if (!this.tokenEndpoint)
|
|
77
|
-
missingVars.push(envVarTokenEndpoint);
|
|
78
|
-
throw new Error(`Missing environment variables: ${missingVars.join(', ')}`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
async getAuthHeader() {
|
|
82
|
-
if (this.runLocal) {
|
|
83
|
-
return { 'Cookie': this.accessToken };
|
|
84
|
-
}
|
|
85
|
-
if (this.accessToken && this.expiresAt > Date.now()) {
|
|
86
|
-
return { 'X-Versori-Internal-Token': this.accessToken };
|
|
87
|
-
}
|
|
88
|
-
const encoded = btoa(`${this.clientId}:${this.clientSecret}`);
|
|
89
|
-
const response = await fetch(this.tokenEndpoint, {
|
|
90
|
-
method: 'POST',
|
|
91
|
-
headers: {
|
|
92
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
93
|
-
Authorization: `Basic ${encoded}`,
|
|
94
|
-
},
|
|
95
|
-
body: `grant_type=client_credentials`,
|
|
96
|
-
});
|
|
97
|
-
const data = await response.json();
|
|
98
|
-
this.accessToken = data.access_token;
|
|
99
|
-
this.expiresAt = Date.now() + data.expires_in * 1000 - 2 * 60 * 1000; // 2 minutes before expiration
|
|
100
|
-
return { 'X-Versori-Internal-Token': this.accessToken };
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Logger } from '../../../observability/mod.js';
|
|
2
|
-
import { PlatformApi } from '../../../services/platform/mod.js';
|
|
3
|
-
import { BaseUrlFetcher, ConfigReader, DynamicFetcher, RoundTripperFactory } from '../types.js';
|
|
4
|
-
import { CredentialsProvider } from './contextcredentials.js';
|
|
5
|
-
export declare class ProxyRoundTripper implements RoundTripperFactory {
|
|
6
|
-
private platformApiBaseUrl;
|
|
7
|
-
private cfgReader;
|
|
8
|
-
private platformApi;
|
|
9
|
-
private internalAuth;
|
|
10
|
-
private log;
|
|
11
|
-
private organisationId;
|
|
12
|
-
private envId;
|
|
13
|
-
constructor(log: Logger, platformApiBaseUrl: string, platformApi: PlatformApi, cfgReader: ConfigReader, orgId: string, envId: string);
|
|
14
|
-
static fromEnv(log: Logger): ProxyRoundTripper;
|
|
15
|
-
private makeProxyUrlString;
|
|
16
|
-
private makeProxyInput;
|
|
17
|
-
private makeProxyInit;
|
|
18
|
-
create(connName: string): Promise<typeof fetch | undefined>;
|
|
19
|
-
createDynamic(templateName: string): Promise<DynamicFetcher | undefined>;
|
|
20
|
-
credentials(): CredentialsProvider;
|
|
21
|
-
baseUrlFetcher(_templateName: string): BaseUrlFetcher;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=proxyroundtripper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proxyroundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/proxyroundtripper.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAmB,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAEH,cAAc,EACd,YAAY,EACZ,cAAc,EACd,mBAAmB,EACtB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAU9D,qBAAa,iBAAkB,YAAW,mBAAmB;IACzD,OAAO,CAAC,kBAAkB,CAAS;IAEnC,OAAO,CAAC,SAAS,CAAe;IAEhC,OAAO,CAAC,WAAW,CAAc;IAEjC,OAAO,CAAC,YAAY,CAAe;IAEnC,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,KAAK,CAAS;gBAGlB,GAAG,EAAE,MAAM,EACX,kBAAkB,EAAE,MAAM,EAC1B,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,YAAY,EACvB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM;IAWjB,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB;IA2B9C,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,cAAc;YA6BR,aAAa;IA4B3B,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,GAAG,SAAS,CAAC;IAoB3D,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAwCxE,WAAW,IAAI,mBAAmB;IAoBlC,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc;CAKxD"}
|