@versori/run 0.1.0-alpha.13 → 0.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/_dnt.shims.d.ts +5 -1
- package/esm/_dnt.shims.d.ts.map +1 -1
- package/esm/_dnt.shims.js +5 -1
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +2 -1
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -1
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +7 -6
- package/{script/deps/jsr.io/@std/fmt/1.0.5 → esm/deps/jsr.io/@std/fmt/1.0.6}/colors.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/fs/1.0.11 → esm/deps/jsr.io/@std/fs/1.0.16}/exists.d.ts +0 -1
- package/esm/deps/jsr.io/@std/fs/1.0.16/exists.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/{1.0.11 → 1.0.16}/exists.js +12 -10
- package/esm/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts +3 -2
- package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.js +2 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +9 -7
- package/esm/src/context/Context.d.ts +4 -14
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +10 -16
- package/esm/src/context/ContextProvider.d.ts +4 -3
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +5 -5
- package/esm/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/configloader.js +3 -2
- package/esm/src/dsl/http/versori/internalauth.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/internalauth.js +6 -5
- package/esm/src/dsl/http/versori/platformapi.d.ts +1 -2
- package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/platformapi.js +5 -15
- package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/roundtripper.js +40 -36
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts +3 -45
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.js +6 -10
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +1 -6
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +7 -71
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +32 -106
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.js +8 -7
- package/package.json +6 -3
- package/script/_dnt.shims.d.ts +5 -1
- package/script/_dnt.shims.d.ts.map +1 -1
- package/script/_dnt.shims.js +7 -2
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +2 -1
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -1
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +33 -9
- package/{esm/deps/jsr.io/@std/fmt/1.0.5 → script/deps/jsr.io/@std/fmt/1.0.6}/colors.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/fs/1.0.11 → script/deps/jsr.io/@std/fs/1.0.16}/exists.d.ts +0 -1
- package/script/deps/jsr.io/@std/fs/1.0.16/exists.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/{1.0.11 → 1.0.16}/exists.js +35 -10
- package/script/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts +3 -2
- package/script/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/file_handler.js +25 -1
- package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +32 -7
- package/script/src/context/Context.d.ts +4 -14
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +10 -16
- package/script/src/context/ContextProvider.d.ts +4 -3
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +5 -5
- package/script/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/script/src/dsl/http/versori/configloader.js +26 -2
- package/script/src/dsl/http/versori/internalauth.d.ts.map +1 -1
- package/script/src/dsl/http/versori/internalauth.js +29 -5
- package/script/src/dsl/http/versori/platformapi.d.ts +1 -2
- package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/platformapi.js +28 -15
- package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/script/src/dsl/http/versori/roundtripper.js +63 -36
- package/script/src/dsl/triggers/WebhookTrigger.d.ts +3 -45
- package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.js +6 -10
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +1 -6
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +30 -71
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +32 -109
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/script/src/kv/nats/NatsKeyValueProvider.js +31 -7
- package/esm/deps/jsr.io/@std/fs/1.0.11/exists.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/fs/1.0.11/exists.d.ts.map +0 -1
- /package/esm/deps/jsr.io/@std/fmt/{1.0.5 → 1.0.6}/colors.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/fmt/{1.0.5 → 1.0.6}/colors.js +0 -0
- /package/script/deps/jsr.io/@std/fmt/{1.0.5 → 1.0.6}/colors.d.ts +0 -0
- /package/script/deps/jsr.io/@std/fmt/{1.0.5 → 1.0.6}/colors.js +0 -0
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.MemoryInterpreter = void 0;
|
|
30
|
+
const dntShim = __importStar(require("../../../_dnt.shims.js"));
|
|
7
31
|
const express_1 = __importDefault(require("express"));
|
|
8
32
|
const rxjs_1 = require("rxjs");
|
|
9
33
|
const ContextProvider_js_1 = require("../../context/ContextProvider.js");
|
|
@@ -59,24 +83,6 @@ class MemoryInterpreter {
|
|
|
59
83
|
writable: true,
|
|
60
84
|
value: []
|
|
61
85
|
});
|
|
62
|
-
Object.defineProperty(this, "server", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
configurable: true,
|
|
65
|
-
writable: true,
|
|
66
|
-
value: void 0
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(this, "shutdownServer", {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
configurable: true,
|
|
71
|
-
writable: true,
|
|
72
|
-
value: void 0
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(this, "isShuttingDown", {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
configurable: true,
|
|
77
|
-
writable: true,
|
|
78
|
-
value: false
|
|
79
|
-
});
|
|
80
86
|
}
|
|
81
87
|
static async newInstance(options = {}) {
|
|
82
88
|
const log = options.logger || new ConsoleLogger_js_1.ConsoleLogger('debug');
|
|
@@ -126,7 +132,7 @@ class MemoryInterpreter {
|
|
|
126
132
|
return registration;
|
|
127
133
|
}
|
|
128
134
|
async start() {
|
|
129
|
-
const port = Deno.env.get('PORT') || 3000;
|
|
135
|
+
const port = dntShim.Deno.env.get('PORT') || 3000;
|
|
130
136
|
const app = (0, express_1.default)();
|
|
131
137
|
app.use(express_1.default.json()); // Add JSON body parser middleware
|
|
132
138
|
// Add health check route
|
|
@@ -137,13 +143,12 @@ class MemoryInterpreter {
|
|
|
137
143
|
app.use(this.router);
|
|
138
144
|
// Start all registered workflows
|
|
139
145
|
for (const registration of this.registeredWorkflows) {
|
|
140
|
-
Deno.addSignalListener('SIGINT', registration.sigintListener);
|
|
141
|
-
registration.
|
|
146
|
+
dntShim.Deno.addSignalListener('SIGINT', registration.sigintListener);
|
|
147
|
+
registration.trigger$
|
|
142
148
|
.pipe((0, rxjs_1.tap)((ctx) => {
|
|
143
149
|
ctx.log.info('MemoryInterpreter.executionStarted', { data: ctx.data });
|
|
144
150
|
}), (0, rxjs_1.mergeMap)((ctx) => (0, rxjs_1.of)(ctx).pipe(registration.task$, (0, rxjs_1.catchError)((error) => {
|
|
145
151
|
ctx.log.error('MemoryInterpreter.executionError', { error });
|
|
146
|
-
ctx.options.onError?.(ctx.withData(error));
|
|
147
152
|
return rxjs_1.EMPTY;
|
|
148
153
|
}))))
|
|
149
154
|
.subscribe({
|
|
@@ -153,67 +158,21 @@ class MemoryInterpreter {
|
|
|
153
158
|
durationMs,
|
|
154
159
|
data: ctx.data,
|
|
155
160
|
});
|
|
156
|
-
ctx.options.onSuccess?.(ctx);
|
|
157
161
|
this.contextProvider.destroy(ctx);
|
|
158
162
|
},
|
|
159
163
|
error: (err) => {
|
|
160
164
|
this.log.error('MemoryInterpreter.error', { error: err });
|
|
161
|
-
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
165
|
+
dntShim.Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
162
166
|
},
|
|
163
167
|
complete: () => {
|
|
164
168
|
this.log.info('MemoryInterpreter.workflowCompleted');
|
|
165
|
-
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
169
|
+
dntShim.Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
166
170
|
},
|
|
167
171
|
});
|
|
168
|
-
registration.subscription.add(() => {
|
|
169
|
-
registration.subscription = undefined;
|
|
170
|
-
});
|
|
171
172
|
}
|
|
172
|
-
|
|
173
|
+
app.listen(port, () => {
|
|
173
174
|
this.log.info(`Express server listening on http://localhost:${port}`);
|
|
174
175
|
});
|
|
175
|
-
this.shutdownServer = () => {
|
|
176
|
-
if (this.isShuttingDown) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
this.isShuttingDown = true;
|
|
180
|
-
this.log.info('Shutting down server');
|
|
181
|
-
// Close the server
|
|
182
|
-
if (this.server) {
|
|
183
|
-
this.server.close();
|
|
184
|
-
}
|
|
185
|
-
// Remove all signal listeners
|
|
186
|
-
for (const registration of this.registeredWorkflows) {
|
|
187
|
-
Deno.removeSignalListener('SIGINT', registration.sigintListener);
|
|
188
|
-
// Unsubscribe from all observables
|
|
189
|
-
if (registration.subscription) {
|
|
190
|
-
registration.subscription.unsubscribe();
|
|
191
|
-
}
|
|
192
|
-
// Abort all controllers
|
|
193
|
-
registration.localAbortController.abort();
|
|
194
|
-
}
|
|
195
|
-
// Remove the server shutdown listener
|
|
196
|
-
if (this.shutdownServer) {
|
|
197
|
-
Deno.removeSignalListener('SIGINT', this.shutdownServer);
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
Deno.addSignalListener('SIGINT', this.shutdownServer);
|
|
201
|
-
return new Promise((resolve) => {
|
|
202
|
-
if (this.server) {
|
|
203
|
-
this.server.on('close', () => {
|
|
204
|
-
this.log.info('Server closed');
|
|
205
|
-
resolve();
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
resolve();
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
async stop() {
|
|
214
|
-
if (this.shutdownServer) {
|
|
215
|
-
this.shutdownServer();
|
|
216
|
-
}
|
|
217
176
|
}
|
|
218
177
|
}
|
|
219
178
|
exports.MemoryInterpreter = MemoryInterpreter;
|
|
@@ -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":"AAEA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAK7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CAwGxE,CAAC"}
|
|
@@ -1,142 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.webhookCompiler = void 0;
|
|
7
4
|
// In src/interpreter/memory/compilers/webhook.ts
|
|
8
|
-
const cors_1 = __importDefault(require("cors"));
|
|
9
5
|
const rxjs_1 = require("rxjs");
|
|
10
|
-
const promises_1 = require("node:stream/promises");
|
|
11
6
|
const WebhookTrigger_js_1 = require("../../../dsl/triggers/WebhookTrigger.js");
|
|
12
|
-
const DEFAULT_SYNC_ON_SUCCESS = (ctx) => new Response(JSON.stringify(ctx.data), { status: 200 });
|
|
13
|
-
const DEFAULT_SYNC_ON_ERROR = (ctx) => new Response(JSON.stringify({ message: 'Internal server error', error: ctx.data }), {
|
|
14
|
-
status: 500,
|
|
15
|
-
});
|
|
16
|
-
const DEFAULT_ASYNC_ON_SUCCESS = (ctx) => new Response(JSON.stringify({
|
|
17
|
-
status: 'accepted',
|
|
18
|
-
executionId: ctx.executionId,
|
|
19
|
-
startTime: ctx.startTime,
|
|
20
|
-
}), { status: 202 });
|
|
21
|
-
const DEFAULT_ASYNC_ON_ERROR = (ctx) => new Response(JSON.stringify({
|
|
22
|
-
message: 'Internal server error',
|
|
23
|
-
executionId: ctx.executionId,
|
|
24
|
-
startTime: ctx.startTime,
|
|
25
|
-
}), {
|
|
26
|
-
status: 500,
|
|
27
|
-
});
|
|
28
7
|
exports.webhookCompiler = {
|
|
29
8
|
ctor: WebhookTrigger_js_1.WebhookTrigger,
|
|
30
9
|
compile: (ctx, trigger, signal) => {
|
|
31
|
-
const { response: { mode = 'async', } = {}, cors: corsOptions, } = trigger.options;
|
|
32
|
-
const isSync = mode === 'sync';
|
|
33
|
-
const isAsync = mode === 'async';
|
|
34
|
-
if (!isSync && !isAsync) {
|
|
35
|
-
throw new Error('Invalid response mode, must be either "sync" or "async"');
|
|
36
|
-
}
|
|
37
|
-
let onSuccess = isSync ? DEFAULT_SYNC_ON_SUCCESS : DEFAULT_ASYNC_ON_SUCCESS;
|
|
38
|
-
let onError = isSync ? DEFAULT_SYNC_ON_ERROR : DEFAULT_ASYNC_ON_ERROR;
|
|
39
|
-
if (trigger.options.response?.onSuccess) {
|
|
40
|
-
onSuccess = trigger.options.response.onSuccess;
|
|
41
|
-
}
|
|
42
|
-
if (trigger.options.response?.onError) {
|
|
43
|
-
onError = trigger.options.response.onError;
|
|
44
|
-
}
|
|
45
|
-
const ctxOptionsFn = (res) => ({
|
|
46
|
-
onSuccess: (ctx) => {
|
|
47
|
-
if (isSync) {
|
|
48
|
-
sendResponse(res, onSuccess(ctx));
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
onError: (ctx) => {
|
|
52
|
-
if (isSync) {
|
|
53
|
-
sendResponse(res, onError(ctx));
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
10
|
return new rxjs_1.Observable((subscriber) => {
|
|
58
11
|
if (!ctx.router) {
|
|
59
12
|
throw new Error('Router not available in compiler context');
|
|
60
13
|
}
|
|
61
14
|
// add the webhook endpoint to the router
|
|
62
15
|
ctx.log.info('webhook endpoint added:', { trigger });
|
|
63
|
-
if (corsOptions) {
|
|
64
|
-
if (typeof corsOptions === 'boolean') {
|
|
65
|
-
ctx.router.use((0, cors_1.default)());
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
ctx.router.use((0, cors_1.default)(corsOptions));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
16
|
// endpoint for sans user because I'm not quite sure how the dynamic routing works
|
|
72
17
|
ctx.router.post(`/${trigger.id}`, (req, res) => {
|
|
73
|
-
const executionCtx = ctx.contextProvider.create(req.body,
|
|
18
|
+
const executionCtx = ctx.contextProvider.create(req.body, undefined);
|
|
74
19
|
try {
|
|
75
20
|
subscriber.next(executionCtx);
|
|
76
|
-
|
|
77
|
-
sendResponse(res, onSuccess(executionCtx));
|
|
78
|
-
}
|
|
21
|
+
res.status(200).json({ status: 'accepted' });
|
|
79
22
|
}
|
|
80
23
|
catch (error) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
});
|
|
84
|
-
if (isAsync) {
|
|
85
|
-
sendResponse(res, onError(executionCtx.withData(error)));
|
|
86
|
-
}
|
|
24
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
25
|
+
executionCtx.log.error('webhook execution error', { error });
|
|
26
|
+
res.status(500).json({ status: 'error', message });
|
|
87
27
|
}
|
|
88
28
|
});
|
|
89
29
|
// this endpoint will trigger the workflow for each activation given by the external user ID
|
|
90
30
|
ctx.router.post(`/${trigger.id}/users/:userId`, async (req, res) => {
|
|
91
|
-
const userId = req.params.userId;
|
|
31
|
+
const userId = req.params.userId || undefined;
|
|
32
|
+
if (!userId) {
|
|
33
|
+
res.status(400).json({ status: 'error', message: 'User ID is required' });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
92
36
|
const activations = await ctx.connectionProvider.getUserActivations(userId);
|
|
93
|
-
|
|
94
|
-
|
|
37
|
+
if (!activations || activations.length === 0) {
|
|
38
|
+
res.status(404).json({ status: 'error', message: `No activations found for user: ${userId}` });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
95
41
|
activations.forEach((activation) => {
|
|
96
|
-
const
|
|
42
|
+
const executionCtx = ctx.contextProvider.create(req.body, activation);
|
|
97
43
|
try {
|
|
98
|
-
subscriber.next(
|
|
44
|
+
subscriber.next(executionCtx);
|
|
99
45
|
}
|
|
100
46
|
catch (error) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
});
|
|
104
|
-
errors.push({
|
|
105
|
-
activationId: activation.id,
|
|
106
|
-
error,
|
|
107
|
-
});
|
|
47
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
48
|
+
executionCtx.log.error('webhook execution error', { error });
|
|
49
|
+
res.status(500).json({ status: 'error', message });
|
|
108
50
|
}
|
|
109
51
|
});
|
|
110
|
-
|
|
111
|
-
if (errors.length === 0) {
|
|
112
|
-
sendResponse(res, onSuccess(executionCtx));
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
sendResponse(res, onError(executionCtx.withData(errors)));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
52
|
+
res.status(200).json({ status: 'accepted' });
|
|
118
53
|
});
|
|
119
54
|
// this endpoint will trigger the workflow only for the activation given by its ID
|
|
120
55
|
ctx.router.post(`/${trigger.id}/activations/:activationId`, async (req, res) => {
|
|
121
|
-
const activationId = req.params.activationId;
|
|
56
|
+
const activationId = req.params.activationId || undefined;
|
|
122
57
|
const activation = await ctx.connectionProvider.getActivation(activationId);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
activation
|
|
126
|
-
|
|
58
|
+
if (!activation) {
|
|
59
|
+
// TODO report back actual errors
|
|
60
|
+
res.status(404).json({ status: 'error', message: `No activation found for ID: ${activationId}` });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const executionCtx = ctx.contextProvider.create(req.body, activation);
|
|
127
64
|
try {
|
|
128
|
-
subscriber.next(
|
|
129
|
-
|
|
130
|
-
sendResponse(res, onSuccess(activationCtx));
|
|
131
|
-
}
|
|
65
|
+
subscriber.next(executionCtx);
|
|
66
|
+
res.status(200).json({ status: 'accepted' });
|
|
132
67
|
}
|
|
133
68
|
catch (error) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
});
|
|
137
|
-
if (isAsync) {
|
|
138
|
-
sendResponse(res, onError(activationCtx.withData(error)));
|
|
139
|
-
}
|
|
69
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
70
|
+
executionCtx.log.error('webhook execution error', { error });
|
|
71
|
+
res.status(500).json({ status: 'error', message });
|
|
140
72
|
}
|
|
141
73
|
});
|
|
142
74
|
function cleanup() {
|
|
@@ -151,12 +83,3 @@ exports.webhookCompiler = {
|
|
|
151
83
|
});
|
|
152
84
|
},
|
|
153
85
|
};
|
|
154
|
-
function sendResponse(res, response) {
|
|
155
|
-
res.status(response.status);
|
|
156
|
-
response.headers.forEach((value, key) => {
|
|
157
|
-
res.setHeader(key, value);
|
|
158
|
-
});
|
|
159
|
-
if (response.body) {
|
|
160
|
-
(0, promises_1.pipeline)(response.body, res);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NatsKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/nats/NatsKeyValueProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NatsKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/nats/NatsKeyValueProvider.ts"],"names":[],"mappings":"AAGA,OAAO,EAA+B,UAAU,EAAE,MAAM,+DAA+D,CAAC;AACxH,OAAO,EACH,cAAc,EAEd,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACZ,MAAM,gBAAgB,CAAC;AA4CxB,MAAM,MAAM,2BAA2B,GAAG;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE;QACF,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,GAAG,CAAC,EAAE,UAAU,CAAC;KACpB,CAAC;CACL,CAAC;AAuBF,qBAAa,oBAAqB,YAAW,gBAAgB,EAAE,eAAe;IAEtE,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI;IALzB,OAAO;WAQM,WAAW,CACpB,IAAI,GAAE,OAAO,CAAC,2BAA2B,CAAM,GAChD,OAAO,CAAC,oBAAoB,CAAC;IA0BhC,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI/C,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC;IAI1C,EAAE,CAAC,OAAO,EAAE,SAAS,GAAG,QAAQ;IAqB1B,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBrD,OAAO,CAAC,aAAa;CAYxB"}
|
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.NatsKeyValueProvider = void 0;
|
|
27
|
+
const dntShim = __importStar(require("../../../_dnt.shims.js"));
|
|
4
28
|
const mod_js_1 = require("../../../deps/jsr.io/@nats-io/jetstream/3.0.2/src/mod.js");
|
|
5
29
|
const mod_js_2 = require("../../../deps/jsr.io/@nats-io/kv/3.0.2/src/mod.js");
|
|
6
30
|
const mod_js_3 = require("../../../deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.js");
|
|
7
31
|
const KeyValue_js_1 = require("../KeyValue.js");
|
|
8
32
|
const NatsKeyValue_js_1 = require("./NatsKeyValue.js");
|
|
9
33
|
function getOptionsFromEnv() {
|
|
10
|
-
const natsTlsCaFile = Deno.env.get('RUN_NATS_TLS_CA_FILE');
|
|
34
|
+
const natsTlsCaFile = dntShim.Deno.env.get('RUN_NATS_TLS_CA_FILE');
|
|
11
35
|
return {
|
|
12
|
-
organizationId: Deno.env.get('RUN_ORGANISATION_ID'),
|
|
13
|
-
projectId: Deno.env.get('RUN_SERVICE_ID'),
|
|
14
|
-
environment: Deno.env.get('RUN_ENVIRONMENT'),
|
|
36
|
+
organizationId: dntShim.Deno.env.get('RUN_ORGANISATION_ID'),
|
|
37
|
+
projectId: dntShim.Deno.env.get('RUN_SERVICE_ID'),
|
|
38
|
+
environment: dntShim.Deno.env.get('RUN_ENVIRONMENT'),
|
|
15
39
|
nats: {
|
|
16
|
-
url: Deno.env.get('RUN_NATS_URL') || 'nats://localhost:4222',
|
|
17
|
-
credsFile: Deno.env.get('RUN_NATS_CREDS_FILE'),
|
|
40
|
+
url: dntShim.Deno.env.get('RUN_NATS_URL') || 'nats://localhost:4222',
|
|
41
|
+
credsFile: dntShim.Deno.env.get('RUN_NATS_CREDS_FILE'),
|
|
18
42
|
...(natsTlsCaFile && {
|
|
19
43
|
tls: {
|
|
20
44
|
caFile: natsTlsCaFile,
|
|
@@ -87,7 +111,7 @@ class NatsKeyValueProvider {
|
|
|
87
111
|
static async newInstance(opts = {}) {
|
|
88
112
|
const parsedOpts = mergeOptions(getOptionsFromEnv(), opts);
|
|
89
113
|
const credsFile = parsedOpts.nats.credsFile
|
|
90
|
-
? await Deno.readFile(parsedOpts.nats.credsFile)
|
|
114
|
+
? await dntShim.Deno.readFile(parsedOpts.nats.credsFile)
|
|
91
115
|
: undefined;
|
|
92
116
|
const conn = await (0, mod_js_3.connect)({
|
|
93
117
|
servers: [parsedOpts.nats.url],
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exists.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/fs/1.0.11/exists.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,OAAO,CAAC,CAsClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+FG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAqCT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exists.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/fs/1.0.11/exists.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,OAAO,CAAC,CAsClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+FG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAqCT"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|