@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.
Files changed (167) hide show
  1. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts +3 -0
  2. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts.map +1 -0
  3. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.js +28 -0
  4. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +35 -0
  5. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -0
  6. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +328 -0
  7. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts +3 -0
  8. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts.map +1 -0
  9. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.js +2 -0
  10. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts +2 -0
  11. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts.map +1 -0
  12. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.js +2 -0
  13. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
  14. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
  15. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.js +2 -0
  16. package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts +21 -0
  17. package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
  18. package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.js +32 -0
  19. package/esm/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts +41 -0
  20. package/esm/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts.map +1 -0
  21. package/esm/deps/jsr.io/@std/bytes/1.0.5/copy.js +50 -0
  22. 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
  23. package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts.map +1 -1
  24. package/esm/deps/jsr.io/@std/io/0.225.2/_common.d.ts +3 -0
  25. package/esm/deps/jsr.io/@std/io/0.225.2/_common.d.ts.map +1 -0
  26. package/esm/deps/jsr.io/@std/io/0.225.2/_common.js +8 -0
  27. package/esm/deps/jsr.io/@std/io/0.225.2/_constants.d.ts +3 -0
  28. package/esm/deps/jsr.io/@std/io/0.225.2/_constants.d.ts.map +1 -0
  29. package/esm/deps/jsr.io/@std/io/0.225.2/_constants.js +4 -0
  30. package/esm/deps/jsr.io/@std/io/0.225.2/buffer.d.ts +321 -0
  31. package/esm/deps/jsr.io/@std/io/0.225.2/buffer.d.ts.map +1 -0
  32. package/esm/deps/jsr.io/@std/io/0.225.2/buffer.js +488 -0
  33. package/esm/deps/jsr.io/@std/io/0.225.2/copy.d.ts +25 -0
  34. package/esm/deps/jsr.io/@std/io/0.225.2/copy.d.ts.map +1 -0
  35. package/esm/deps/jsr.io/@std/io/0.225.2/copy.js +36 -0
  36. package/esm/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts +80 -0
  37. package/esm/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts.map +1 -0
  38. package/esm/deps/jsr.io/@std/io/0.225.2/iterate_reader.js +96 -0
  39. package/esm/deps/jsr.io/@std/io/0.225.2/mod.d.ts +25 -0
  40. package/esm/deps/jsr.io/@std/io/0.225.2/mod.d.ts.map +1 -0
  41. package/esm/deps/jsr.io/@std/io/0.225.2/mod.js +25 -0
  42. package/esm/deps/jsr.io/@std/io/0.225.2/read_all.d.ts +42 -0
  43. package/esm/deps/jsr.io/@std/io/0.225.2/read_all.d.ts.map +1 -0
  44. package/esm/deps/jsr.io/@std/io/0.225.2/read_all.js +72 -0
  45. package/esm/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts +20 -0
  46. package/esm/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts.map +1 -0
  47. package/esm/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.js +36 -0
  48. package/esm/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts +40 -0
  49. package/esm/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts.map +1 -0
  50. package/esm/deps/jsr.io/@std/io/0.225.2/to_readable_stream.js +54 -0
  51. package/esm/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts +27 -0
  52. package/esm/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts.map +1 -0
  53. package/esm/deps/jsr.io/@std/io/0.225.2/to_writable_stream.js +44 -0
  54. package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +21 -0
  55. package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
  56. package/esm/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
  57. package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +1 -1
  58. package/esm/src/context/Context.d.ts +14 -4
  59. package/esm/src/context/Context.d.ts.map +1 -1
  60. package/esm/src/context/Context.js +16 -10
  61. package/esm/src/context/ContextProvider.d.ts +3 -4
  62. package/esm/src/context/ContextProvider.d.ts.map +1 -1
  63. package/esm/src/context/ContextProvider.js +5 -5
  64. package/esm/src/dsl/http/versori/platformapi.d.ts +2 -1
  65. package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -1
  66. package/esm/src/dsl/http/versori/platformapi.js +12 -1
  67. package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
  68. package/esm/src/dsl/http/versori/roundtripper.js +32 -35
  69. package/esm/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
  70. package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
  71. package/esm/src/dsl/triggers/WebhookTrigger.js +10 -6
  72. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +6 -1
  73. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  74. package/esm/src/interpreter/memory/MemoryInterpreter.js +67 -5
  75. package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  76. package/esm/src/interpreter/memory/compilers/webhook.js +106 -32
  77. package/esm/src/kv/nats/NatsKeyValueProvider.d.ts +2 -1
  78. package/esm/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
  79. package/esm/src/kv/nats/NatsKeyValueProvider.js +1 -1
  80. package/package.json +2 -1
  81. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts +3 -0
  82. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.d.ts.map +1 -0
  83. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/connect.js +31 -0
  84. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +35 -0
  85. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -0
  86. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +333 -0
  87. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts +3 -0
  88. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.d.ts.map +1 -0
  89. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.js +20 -0
  90. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts +2 -0
  91. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.d.ts.map +1 -0
  92. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/version.js +5 -0
  93. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
  94. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
  95. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.js +3 -0
  96. package/script/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts +21 -0
  97. package/script/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
  98. package/script/deps/jsr.io/@std/bytes/1.0.5/concat.js +35 -0
  99. package/script/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts +41 -0
  100. package/script/deps/jsr.io/@std/bytes/1.0.5/copy.d.ts.map +1 -0
  101. package/script/deps/jsr.io/@std/bytes/1.0.5/copy.js +53 -0
  102. 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
  103. package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts.map +1 -1
  104. package/script/deps/jsr.io/@std/io/0.225.2/_common.d.ts +3 -0
  105. package/script/deps/jsr.io/@std/io/0.225.2/_common.d.ts.map +1 -0
  106. package/script/deps/jsr.io/@std/io/0.225.2/_common.js +11 -0
  107. package/script/deps/jsr.io/@std/io/0.225.2/_constants.d.ts +3 -0
  108. package/script/deps/jsr.io/@std/io/0.225.2/_constants.d.ts.map +1 -0
  109. package/script/deps/jsr.io/@std/io/0.225.2/_constants.js +7 -0
  110. package/script/deps/jsr.io/@std/io/0.225.2/buffer.d.ts +321 -0
  111. package/script/deps/jsr.io/@std/io/0.225.2/buffer.d.ts.map +1 -0
  112. package/script/deps/jsr.io/@std/io/0.225.2/buffer.js +492 -0
  113. package/script/deps/jsr.io/@std/io/0.225.2/copy.d.ts +25 -0
  114. package/script/deps/jsr.io/@std/io/0.225.2/copy.d.ts.map +1 -0
  115. package/script/deps/jsr.io/@std/io/0.225.2/copy.js +39 -0
  116. package/script/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts +80 -0
  117. package/script/deps/jsr.io/@std/io/0.225.2/iterate_reader.d.ts.map +1 -0
  118. package/script/deps/jsr.io/@std/io/0.225.2/iterate_reader.js +100 -0
  119. package/script/deps/jsr.io/@std/io/0.225.2/mod.d.ts +25 -0
  120. package/script/deps/jsr.io/@std/io/0.225.2/mod.d.ts.map +1 -0
  121. package/script/deps/jsr.io/@std/io/0.225.2/mod.js +41 -0
  122. package/script/deps/jsr.io/@std/io/0.225.2/read_all.d.ts +42 -0
  123. package/script/deps/jsr.io/@std/io/0.225.2/read_all.d.ts.map +1 -0
  124. package/script/deps/jsr.io/@std/io/0.225.2/read_all.js +76 -0
  125. package/script/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts +20 -0
  126. package/script/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.d.ts.map +1 -0
  127. package/script/deps/jsr.io/@std/io/0.225.2/reader_from_stream_reader.js +39 -0
  128. package/script/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts +40 -0
  129. package/script/deps/jsr.io/@std/io/0.225.2/to_readable_stream.d.ts.map +1 -0
  130. package/script/deps/jsr.io/@std/io/0.225.2/to_readable_stream.js +57 -0
  131. package/script/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts +27 -0
  132. package/script/deps/jsr.io/@std/io/0.225.2/to_writable_stream.d.ts.map +1 -0
  133. package/script/deps/jsr.io/@std/io/0.225.2/to_writable_stream.js +47 -0
  134. package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +21 -0
  135. package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
  136. package/script/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
  137. package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +1 -1
  138. package/script/src/context/Context.d.ts +14 -4
  139. package/script/src/context/Context.d.ts.map +1 -1
  140. package/script/src/context/Context.js +16 -10
  141. package/script/src/context/ContextProvider.d.ts +3 -4
  142. package/script/src/context/ContextProvider.d.ts.map +1 -1
  143. package/script/src/context/ContextProvider.js +5 -5
  144. package/script/src/dsl/http/versori/platformapi.d.ts +2 -1
  145. package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -1
  146. package/script/src/dsl/http/versori/platformapi.js +12 -1
  147. package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
  148. package/script/src/dsl/http/versori/roundtripper.js +32 -35
  149. package/script/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
  150. package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
  151. package/script/src/dsl/triggers/WebhookTrigger.js +10 -6
  152. package/script/src/interpreter/memory/MemoryInterpreter.d.ts +6 -1
  153. package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  154. package/script/src/interpreter/memory/MemoryInterpreter.js +67 -5
  155. package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  156. package/script/src/interpreter/memory/compilers/webhook.js +109 -32
  157. package/script/src/kv/nats/NatsKeyValueProvider.d.ts +2 -1
  158. package/script/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
  159. package/script/src/kv/nats/NatsKeyValueProvider.js +3 -3
  160. /package/esm/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.d.ts +0 -0
  161. /package/esm/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.js +0 -0
  162. /package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts +0 -0
  163. /package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.js +0 -0
  164. /package/script/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.d.ts +0 -0
  165. /package/script/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.5}/colors.js +0 -0
  166. /package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.11}/exists.d.ts +0 -0
  167. /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, undefined);
73
+ const executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
19
74
  try {
20
75
  subscriber.next(executionCtx);
21
- res.status(200).json({ status: 'accepted' });
76
+ if (isAsync) {
77
+ sendResponse(res, onSuccess(executionCtx));
78
+ }
22
79
  }
23
80
  catch (error) {
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 });
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 || undefined;
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
- if (!activations || activations.length === 0) {
38
- res.status(404).json({ status: 'error', message: `No activations found for user: ${userId}` });
39
- return;
40
- }
93
+ const executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
94
+ const errors = [];
41
95
  activations.forEach((activation) => {
42
- const executionCtx = ctx.contextProvider.create(req.body, activation);
96
+ const activationCtx = executionCtx.withActivation(activation);
43
97
  try {
44
- subscriber.next(executionCtx);
98
+ subscriber.next(activationCtx);
45
99
  }
46
100
  catch (error) {
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 });
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
- res.status(200).json({ status: 'accepted' });
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 || undefined;
121
+ const activationId = req.params.activationId;
57
122
  const activation = await ctx.connectionProvider.getActivation(activationId);
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);
123
+ const activationCtx = ctx.contextProvider.create(req.body, {
124
+ ...ctxOptionsFn(res),
125
+ activation,
126
+ });
64
127
  try {
65
- subscriber.next(executionCtx);
66
- res.status(200).json({ status: 'accepted' });
128
+ subscriber.next(activationCtx);
129
+ if (isAsync) {
130
+ sendResponse(res, onSuccess(activationCtx));
131
+ }
67
132
  }
68
133
  catch (error) {
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 });
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 '@nats-io/transport-deno';
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,yBAAyB,CAAC;AAClF,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;IAQ/C,EAAE,CAAC,OAAO,EAAE,SAAS,GAAG,QAAQ;IAqB1B,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBrD,OAAO,CAAC,aAAa;CAYxB"}
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 transport_deno_1 = require("@nats-io/transport-deno");
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, transport_deno_1.connect)({
92
+ const conn = await (0, mod_js_3.connect)({
93
93
  servers: [parsedOpts.nats.url],
94
- authenticator: credsFile ? (0, transport_deno_1.credsAuthenticator)(credsFile) : undefined,
94
+ authenticator: credsFile ? (0, mod_js_3.credsAuthenticator)(credsFile) : undefined,
95
95
  ...(parsedOpts.nats.tls && {
96
96
  tls: parsedOpts.nats.tls,
97
97
  }),