@versori/run 0.1.0-alpha.11 → 0.1.0-alpha.13
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/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts +3 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts.map +1 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.js +28 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +35 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +328 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts +3 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.js +2 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts +2 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts.map +1 -0
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.js +2 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.js +2 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts +21 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.js +32 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts +41 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/bytes/1.0.5/copy.js +50 -0
- package/{script/deps/jsr.io/@std/fmt/1.0.6 → esm/deps/jsr.io/@std/fmt/1.0.5}/colors.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/io/0.225.2/_common.d.ts +3 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/_common.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/_common.js +8 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/_constants.d.ts +3 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/_constants.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/_constants.js +4 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/buffer.d.ts +321 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/buffer.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/buffer.js +488 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/copy.d.ts +25 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/copy.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/copy.js +36 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts +80 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/iterate_reader.js +96 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/mod.d.ts +25 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/mod.js +25 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/read_all.d.ts +42 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/read_all.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/read_all.js +72 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts +20 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.js +36 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts +40 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_readable_stream.js +54 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts +27 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.2/to_writable_stream.js +44 -0
- package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +21 -0
- package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
- 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/rotating_file_handler.js +1 -1
- package/esm/src/context/Context.d.ts +14 -4
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +16 -10
- package/esm/src/context/ContextProvider.d.ts +3 -4
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +5 -5
- package/esm/src/dsl/http/versori/platformapi.d.ts +2 -1
- package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/platformapi.js +12 -1
- package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/roundtripper.js +32 -35
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.js +10 -6
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +6 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +67 -5
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +106 -32
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts +2 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.js +1 -1
- package/package.json +2 -1
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts +3 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts.map +1 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.js +31 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +35 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +333 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts +3 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.js +20 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts +2 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts.map +1 -0
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.js +5 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/_types.js +3 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts +21 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/concat.js +35 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts +41 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/bytes/1.0.5/copy.js +53 -0
- package/{esm/deps/jsr.io/@std/fmt/1.0.6 → script/deps/jsr.io/@std/fmt/1.0.5}/colors.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/io/0.225.2/_common.d.ts +3 -0
- package/script/deps/jsr.io/@std/io/0.225.2/_common.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/_common.js +11 -0
- package/script/deps/jsr.io/@std/io/0.225.2/_constants.d.ts +3 -0
- package/script/deps/jsr.io/@std/io/0.225.2/_constants.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/_constants.js +7 -0
- package/script/deps/jsr.io/@std/io/0.225.2/buffer.d.ts +321 -0
- package/script/deps/jsr.io/@std/io/0.225.2/buffer.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/buffer.js +492 -0
- package/script/deps/jsr.io/@std/io/0.225.2/copy.d.ts +25 -0
- package/script/deps/jsr.io/@std/io/0.225.2/copy.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/copy.js +39 -0
- package/script/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts +80 -0
- package/script/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/iterate_reader.js +100 -0
- package/script/deps/jsr.io/@std/io/0.225.2/mod.d.ts +25 -0
- package/script/deps/jsr.io/@std/io/0.225.2/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/mod.js +41 -0
- package/script/deps/jsr.io/@std/io/0.225.2/read_all.d.ts +42 -0
- package/script/deps/jsr.io/@std/io/0.225.2/read_all.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/read_all.js +76 -0
- package/script/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts +20 -0
- package/script/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.js +39 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts +40 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_readable_stream.js +57 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts +27 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.2/to_writable_stream.js +47 -0
- package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +21 -0
- package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
- 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/rotating_file_handler.js +1 -1
- package/script/src/context/Context.d.ts +14 -4
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +16 -10
- package/script/src/context/ContextProvider.d.ts +3 -4
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +5 -5
- package/script/src/dsl/http/versori/platformapi.d.ts +2 -1
- package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/platformapi.js +12 -1
- package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/script/src/dsl/http/versori/roundtripper.js +32 -35
- package/script/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
- package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.js +10 -6
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +6 -1
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +67 -5
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +109 -32
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts +2 -1
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/script/src/kv/nats/NatsKeyValueProvider.js +3 -3
- /package/esm/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.js +0 -0
- /package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.js +0 -0
- /package/script/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.d.ts +0 -0
- /package/script/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.js +0 -0
- /package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts +0 -0
- /package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.js +0 -0
|
@@ -1,74 +1,142 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.webhookCompiler = void 0;
|
|
4
7
|
// In src/interpreter/memory/compilers/webhook.ts
|
|
8
|
+
const cors_1 = __importDefault(require("cors"));
|
|
5
9
|
const rxjs_1 = require("rxjs");
|
|
10
|
+
const promises_1 = require("node:stream/promises");
|
|
6
11
|
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
|
+
});
|
|
7
28
|
exports.webhookCompiler = {
|
|
8
29
|
ctor: WebhookTrigger_js_1.WebhookTrigger,
|
|
9
30
|
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
|
+
});
|
|
10
57
|
return new rxjs_1.Observable((subscriber) => {
|
|
11
58
|
if (!ctx.router) {
|
|
12
59
|
throw new Error('Router not available in compiler context');
|
|
13
60
|
}
|
|
14
61
|
// add the webhook endpoint to the router
|
|
15
62
|
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
|
+
}
|
|
16
71
|
// endpoint for sans user because I'm not quite sure how the dynamic routing works
|
|
17
72
|
ctx.router.post(`/${trigger.id}`, (req, res) => {
|
|
18
|
-
const executionCtx = ctx.contextProvider.create(req.body,
|
|
73
|
+
const executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
|
|
19
74
|
try {
|
|
20
75
|
subscriber.next(executionCtx);
|
|
21
|
-
|
|
76
|
+
if (isAsync) {
|
|
77
|
+
sendResponse(res, onSuccess(executionCtx));
|
|
78
|
+
}
|
|
22
79
|
}
|
|
23
80
|
catch (error) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
81
|
+
executionCtx.log.error('webhook execution error', {
|
|
82
|
+
error: JSON.stringify(error),
|
|
83
|
+
});
|
|
84
|
+
if (isAsync) {
|
|
85
|
+
sendResponse(res, onError(executionCtx.withData(error)));
|
|
86
|
+
}
|
|
27
87
|
}
|
|
28
88
|
});
|
|
29
89
|
// this endpoint will trigger the workflow for each activation given by the external user ID
|
|
30
90
|
ctx.router.post(`/${trigger.id}/users/:userId`, async (req, res) => {
|
|
31
|
-
const userId = req.params.userId
|
|
32
|
-
if (!userId) {
|
|
33
|
-
res.status(400).json({ status: 'error', message: 'User ID is required' });
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
91
|
+
const userId = req.params.userId;
|
|
36
92
|
const activations = await ctx.connectionProvider.getUserActivations(userId);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
93
|
+
const executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
|
|
94
|
+
const errors = [];
|
|
41
95
|
activations.forEach((activation) => {
|
|
42
|
-
const
|
|
96
|
+
const activationCtx = executionCtx.withActivation(activation);
|
|
43
97
|
try {
|
|
44
|
-
subscriber.next(
|
|
98
|
+
subscriber.next(activationCtx);
|
|
45
99
|
}
|
|
46
100
|
catch (error) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
101
|
+
activationCtx.log.error('webhook execution error', {
|
|
102
|
+
error: JSON.stringify(error),
|
|
103
|
+
});
|
|
104
|
+
errors.push({
|
|
105
|
+
activationId: activation.id,
|
|
106
|
+
error,
|
|
107
|
+
});
|
|
50
108
|
}
|
|
51
109
|
});
|
|
52
|
-
|
|
110
|
+
if (isAsync) {
|
|
111
|
+
if (errors.length === 0) {
|
|
112
|
+
sendResponse(res, onSuccess(executionCtx));
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
sendResponse(res, onError(executionCtx.withData(errors)));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
53
118
|
});
|
|
54
119
|
// this endpoint will trigger the workflow only for the activation given by its ID
|
|
55
120
|
ctx.router.post(`/${trigger.id}/activations/:activationId`, async (req, res) => {
|
|
56
|
-
const activationId = req.params.activationId
|
|
121
|
+
const activationId = req.params.activationId;
|
|
57
122
|
const activation = await ctx.connectionProvider.getActivation(activationId);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
const executionCtx = ctx.contextProvider.create(req.body, activation);
|
|
123
|
+
const activationCtx = ctx.contextProvider.create(req.body, {
|
|
124
|
+
...ctxOptionsFn(res),
|
|
125
|
+
activation,
|
|
126
|
+
});
|
|
64
127
|
try {
|
|
65
|
-
subscriber.next(
|
|
66
|
-
|
|
128
|
+
subscriber.next(activationCtx);
|
|
129
|
+
if (isAsync) {
|
|
130
|
+
sendResponse(res, onSuccess(activationCtx));
|
|
131
|
+
}
|
|
67
132
|
}
|
|
68
133
|
catch (error) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
134
|
+
activationCtx.log.error('webhook execution error', {
|
|
135
|
+
error: JSON.stringify(error),
|
|
136
|
+
});
|
|
137
|
+
if (isAsync) {
|
|
138
|
+
sendResponse(res, onError(activationCtx.withData(error)));
|
|
139
|
+
}
|
|
72
140
|
}
|
|
73
141
|
});
|
|
74
142
|
function cleanup() {
|
|
@@ -83,3 +151,12 @@ exports.webhookCompiler = {
|
|
|
83
151
|
});
|
|
84
152
|
},
|
|
85
153
|
};
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import { TlsOptions } from '
|
|
1
|
+
import { TlsOptions } from '../../../deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.js';
|
|
2
2
|
import { DestroyOptions, KeyValue, KeyValueProvider, KVOptions } from '../KeyValue.js';
|
|
3
3
|
export type NatsKeyValueProviderOptions = {
|
|
4
4
|
organizationId: string;
|
|
@@ -19,6 +19,7 @@ export declare class NatsKeyValueProvider implements KeyValueProvider, AsyncDisp
|
|
|
19
19
|
private constructor();
|
|
20
20
|
static newInstance(opts?: Partial<NatsKeyValueProviderOptions>): Promise<NatsKeyValueProvider>;
|
|
21
21
|
static fromEnv(): Promise<NatsKeyValueProvider>;
|
|
22
|
+
[Symbol.asyncDispose](): PromiseLike<void>;
|
|
22
23
|
kv(options: KVOptions): KeyValue;
|
|
23
24
|
destroy(options: DestroyOptions): Promise<void>;
|
|
24
25
|
private subjectPrefix;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NatsKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/nats/NatsKeyValueProvider.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+B,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"NatsKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/nats/NatsKeyValueProvider.ts"],"names":[],"mappings":"AAEA,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"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NatsKeyValueProvider = void 0;
|
|
4
4
|
const mod_js_1 = require("../../../deps/jsr.io/@nats-io/jetstream/3.0.2/src/mod.js");
|
|
5
5
|
const mod_js_2 = require("../../../deps/jsr.io/@nats-io/kv/3.0.2/src/mod.js");
|
|
6
|
-
const
|
|
6
|
+
const mod_js_3 = require("../../../deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.js");
|
|
7
7
|
const KeyValue_js_1 = require("../KeyValue.js");
|
|
8
8
|
const NatsKeyValue_js_1 = require("./NatsKeyValue.js");
|
|
9
9
|
function getOptionsFromEnv() {
|
|
@@ -89,9 +89,9 @@ class NatsKeyValueProvider {
|
|
|
89
89
|
const credsFile = parsedOpts.nats.credsFile
|
|
90
90
|
? await Deno.readFile(parsedOpts.nats.credsFile)
|
|
91
91
|
: undefined;
|
|
92
|
-
const conn = await (0,
|
|
92
|
+
const conn = await (0, mod_js_3.connect)({
|
|
93
93
|
servers: [parsedOpts.nats.url],
|
|
94
|
-
authenticator: credsFile ? (0,
|
|
94
|
+
authenticator: credsFile ? (0, mod_js_3.credsAuthenticator)(credsFile) : undefined,
|
|
95
95
|
...(parsedOpts.nats.tls && {
|
|
96
96
|
tls: parsedOpts.nats.tls,
|
|
97
97
|
}),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|