@versori/run 0.1.0-alpha.9 → 0.2.0-alpha.10

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 (143) hide show
  1. package/esm/_dnt.shims.d.ts +1 -5
  2. package/esm/_dnt.shims.d.ts.map +1 -1
  3. package/esm/_dnt.shims.js +1 -5
  4. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +1 -2
  5. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -1
  6. package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +6 -7
  7. package/{script/deps/jsr.io/@std/fmt/1.0.6 → esm/deps/jsr.io/@std/fmt/1.0.7}/colors.d.ts.map +1 -1
  8. package/{script/deps/jsr.io/@std/fs/1.0.16 → esm/deps/jsr.io/@std/fs/1.0.17}/exists.d.ts +1 -0
  9. package/esm/deps/jsr.io/@std/fs/1.0.17/exists.d.ts.map +1 -0
  10. package/esm/deps/jsr.io/@std/fs/{1.0.16 → 1.0.17}/exists.js +10 -12
  11. package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +0 -21
  12. package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
  13. package/esm/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
  14. package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts +2 -3
  15. package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts.map +1 -1
  16. package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.js +1 -2
  17. package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.d.ts.map +1 -1
  18. package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +7 -9
  19. package/esm/src/context/Context.d.ts +16 -4
  20. package/esm/src/context/Context.d.ts.map +1 -1
  21. package/esm/src/context/Context.js +31 -10
  22. package/esm/src/context/ContextProvider.d.ts +3 -4
  23. package/esm/src/context/ContextProvider.d.ts.map +1 -1
  24. package/esm/src/context/ContextProvider.js +5 -5
  25. package/esm/src/dsl/http/types.d.ts +13 -2
  26. package/esm/src/dsl/http/types.d.ts.map +1 -1
  27. package/esm/src/dsl/http/versori/activation.d.ts +13 -0
  28. package/esm/src/dsl/http/versori/activation.d.ts.map +1 -0
  29. package/esm/src/dsl/http/versori/activation.js +65 -0
  30. package/esm/src/dsl/http/versori/configloader.d.ts.map +1 -1
  31. package/esm/src/dsl/http/versori/configloader.js +2 -3
  32. package/esm/src/dsl/http/versori/constants.d.ts +5 -0
  33. package/esm/src/dsl/http/versori/constants.d.ts.map +1 -1
  34. package/esm/src/dsl/http/versori/constants.js +5 -0
  35. package/esm/src/dsl/http/versori/credentials/client.d.ts +1 -4
  36. package/esm/src/dsl/http/versori/credentials/client.d.ts.map +1 -1
  37. package/esm/src/dsl/http/versori/credentials/client.js +3 -16
  38. package/esm/src/dsl/http/versori/cronapi.d.ts +10 -0
  39. package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -0
  40. package/esm/src/dsl/http/versori/cronapi.js +51 -0
  41. package/esm/src/dsl/http/versori/internalauth.d.ts.map +1 -1
  42. package/esm/src/dsl/http/versori/internalauth.js +5 -6
  43. package/esm/src/dsl/http/versori/platformapi.d.ts +4 -1
  44. package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -1
  45. package/esm/src/dsl/http/versori/platformapi.js +41 -10
  46. package/esm/src/dsl/http/versori/roundtripper.d.ts +3 -2
  47. package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
  48. package/esm/src/dsl/http/versori/roundtripper.js +128 -78
  49. package/esm/src/dsl/tasks/HttpTask.d.ts +1 -1
  50. package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
  51. package/esm/src/dsl/tasks/HttpTask.js +1 -1
  52. package/esm/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
  53. package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
  54. package/esm/src/dsl/triggers/WebhookTrigger.js +10 -6
  55. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +10 -3
  56. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  57. package/esm/src/interpreter/memory/MemoryInterpreter.js +121 -13
  58. package/esm/src/interpreter/memory/ObservableCompiler.d.ts +1 -0
  59. package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
  60. package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  61. package/esm/src/interpreter/memory/compilers/schedule.js +19 -24
  62. package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  63. package/esm/src/interpreter/memory/compilers/webhook.js +132 -25
  64. package/esm/src/kv/nats/NatsKeyValueProvider.d.ts +0 -1
  65. package/esm/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
  66. package/esm/src/kv/nats/NatsKeyValueProvider.js +7 -8
  67. package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
  68. package/esm/src/observability/logging/ConsoleLogger.js +55 -10
  69. package/package.json +3 -6
  70. package/script/_dnt.shims.d.ts +1 -5
  71. package/script/_dnt.shims.d.ts.map +1 -1
  72. package/script/_dnt.shims.js +2 -7
  73. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +1 -2
  74. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -1
  75. package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +9 -33
  76. package/{esm/deps/jsr.io/@std/fmt/1.0.6 → script/deps/jsr.io/@std/fmt/1.0.7}/colors.d.ts.map +1 -1
  77. package/{esm/deps/jsr.io/@std/fs/1.0.16 → script/deps/jsr.io/@std/fs/1.0.17}/exists.d.ts +1 -0
  78. package/script/deps/jsr.io/@std/fs/1.0.17/exists.d.ts.map +1 -0
  79. package/script/deps/jsr.io/@std/fs/{1.0.16 → 1.0.17}/exists.js +10 -35
  80. package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +0 -21
  81. package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
  82. package/script/deps/jsr.io/@std/log/0.224.14/console_handler.js +1 -1
  83. package/script/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts +2 -3
  84. package/script/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts.map +1 -1
  85. package/script/deps/jsr.io/@std/log/0.224.14/file_handler.js +1 -25
  86. package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.d.ts.map +1 -1
  87. package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +7 -32
  88. package/script/src/context/Context.d.ts +16 -4
  89. package/script/src/context/Context.d.ts.map +1 -1
  90. package/script/src/context/Context.js +31 -10
  91. package/script/src/context/ContextProvider.d.ts +3 -4
  92. package/script/src/context/ContextProvider.d.ts.map +1 -1
  93. package/script/src/context/ContextProvider.js +5 -5
  94. package/script/src/dsl/http/types.d.ts +13 -2
  95. package/script/src/dsl/http/types.d.ts.map +1 -1
  96. package/script/src/dsl/http/versori/activation.d.ts +13 -0
  97. package/script/src/dsl/http/versori/activation.d.ts.map +1 -0
  98. package/script/src/dsl/http/versori/activation.js +69 -0
  99. package/script/src/dsl/http/versori/configloader.d.ts.map +1 -1
  100. package/script/src/dsl/http/versori/configloader.js +2 -26
  101. package/script/src/dsl/http/versori/constants.d.ts +5 -0
  102. package/script/src/dsl/http/versori/constants.d.ts.map +1 -1
  103. package/script/src/dsl/http/versori/constants.js +6 -1
  104. package/script/src/dsl/http/versori/credentials/client.d.ts +1 -4
  105. package/script/src/dsl/http/versori/credentials/client.d.ts.map +1 -1
  106. package/script/src/dsl/http/versori/credentials/client.js +2 -15
  107. package/script/src/dsl/http/versori/cronapi.d.ts +10 -0
  108. package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -0
  109. package/script/src/dsl/http/versori/cronapi.js +55 -0
  110. package/script/src/dsl/http/versori/internalauth.d.ts.map +1 -1
  111. package/script/src/dsl/http/versori/internalauth.js +5 -29
  112. package/script/src/dsl/http/versori/platformapi.d.ts +4 -1
  113. package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -1
  114. package/script/src/dsl/http/versori/platformapi.js +41 -33
  115. package/script/src/dsl/http/versori/roundtripper.d.ts +3 -2
  116. package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
  117. package/script/src/dsl/http/versori/roundtripper.js +128 -101
  118. package/script/src/dsl/tasks/HttpTask.d.ts +1 -1
  119. package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
  120. package/script/src/dsl/tasks/HttpTask.js +1 -1
  121. package/script/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
  122. package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
  123. package/script/src/dsl/triggers/WebhookTrigger.js +10 -6
  124. package/script/src/interpreter/memory/MemoryInterpreter.d.ts +10 -3
  125. package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  126. package/script/src/interpreter/memory/MemoryInterpreter.js +121 -36
  127. package/script/src/interpreter/memory/ObservableCompiler.d.ts +1 -0
  128. package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
  129. package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  130. package/script/src/interpreter/memory/compilers/schedule.js +19 -24
  131. package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  132. package/script/src/interpreter/memory/compilers/webhook.js +135 -25
  133. package/script/src/kv/nats/NatsKeyValueProvider.d.ts +0 -1
  134. package/script/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
  135. package/script/src/kv/nats/NatsKeyValueProvider.js +7 -31
  136. package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
  137. package/script/src/observability/logging/ConsoleLogger.js +55 -10
  138. package/esm/deps/jsr.io/@std/fs/1.0.16/exists.d.ts.map +0 -1
  139. package/script/deps/jsr.io/@std/fs/1.0.16/exists.d.ts.map +0 -1
  140. /package/esm/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.7}/colors.d.ts +0 -0
  141. /package/esm/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.7}/colors.js +0 -0
  142. /package/script/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.7}/colors.d.ts +0 -0
  143. /package/script/deps/jsr.io/@std/fmt/{1.0.6 → 1.0.7}/colors.js +0 -0
@@ -1,4 +1,3 @@
1
- import * as dntShim from "../../../_dnt.shims.js";
2
1
  import express from 'express';
3
2
  import { catchError, EMPTY, mergeMap, of, tap } from 'rxjs';
4
3
  import { ContextProviderImpl } from '../../context/ContextProvider.js';
@@ -10,8 +9,9 @@ import { MemoryKeyValueProvider } from '../../kv/memory/MemoryKeyValueProvider.j
10
9
  import { NatsKeyValueProvider } from '../../kv/nats/NatsKeyValueProvider.js';
11
10
  import { ConsoleLogger } from '../../observability/logging/ConsoleLogger.js';
12
11
  import { ObservableCompiler } from './ObservableCompiler.js';
12
+ import { CronAPIClient } from '../../dsl/http/versori/cronapi.js';
13
13
  export class MemoryInterpreter {
14
- constructor(log, compiler, contextProvider, roundTripperFactory, router, connectionProvider) {
14
+ constructor(log, compiler, contextProvider, roundTripperFactory, router, cronRegistry, connectionProvider, cronProvider) {
15
15
  Object.defineProperty(this, "log", {
16
16
  enumerable: true,
17
17
  configurable: true,
@@ -42,18 +42,53 @@ export class MemoryInterpreter {
42
42
  writable: true,
43
43
  value: router
44
44
  });
45
+ Object.defineProperty(this, "cronRegistry", {
46
+ enumerable: true,
47
+ configurable: true,
48
+ writable: true,
49
+ value: cronRegistry
50
+ });
45
51
  Object.defineProperty(this, "connectionProvider", {
46
52
  enumerable: true,
47
53
  configurable: true,
48
54
  writable: true,
49
55
  value: connectionProvider
50
56
  });
57
+ Object.defineProperty(this, "cronProvider", {
58
+ enumerable: true,
59
+ configurable: true,
60
+ writable: true,
61
+ value: cronProvider
62
+ });
51
63
  Object.defineProperty(this, "registeredWorkflows", {
52
64
  enumerable: true,
53
65
  configurable: true,
54
66
  writable: true,
55
67
  value: []
56
68
  });
69
+ Object.defineProperty(this, "server", {
70
+ enumerable: true,
71
+ configurable: true,
72
+ writable: true,
73
+ value: void 0
74
+ });
75
+ Object.defineProperty(this, "shutdownServer", {
76
+ enumerable: true,
77
+ configurable: true,
78
+ writable: true,
79
+ value: void 0
80
+ });
81
+ Object.defineProperty(this, "isShuttingDown", {
82
+ enumerable: true,
83
+ configurable: true,
84
+ writable: true,
85
+ value: false
86
+ });
87
+ if (typeof this.log === 'undefined') {
88
+ // this captures the old way of instantiating the MemoryInterpreter and provides an
89
+ // error message back to the user to let them know they should use the new way.
90
+ throw new Error('MemoryInterpreter should not be instantiated directly. Use MemoryInterpreter.newInstance() instead.');
91
+ }
57
92
  }
58
93
  static async newInstance(options = {}) {
59
94
  const log = options.logger || new ConsoleLogger('debug');
@@ -64,12 +99,12 @@ export class MemoryInterpreter {
64
99
  if (options.contextProvider) {
65
100
  // no need to set up a key-value provider if options.contextProvider is already
66
101
  // initialised.
67
- return new MemoryInterpreter(log, compiler, options.contextProvider, roundTripperFactory, express.Router(), PlatformAPIClient.fromEnv());
102
+ return new MemoryInterpreter(log, compiler, options.contextProvider, roundTripperFactory, express.Router(), new Map(), PlatformAPIClient.fromEnv(), CronAPIClient.fromEnv());
68
103
  }
69
104
  const kvp = await (options.skipVersoriCredentials
70
105
  ? new MemoryKeyValueProvider()
71
106
  : NatsKeyValueProvider.fromEnv());
72
- return new MemoryInterpreter(log, compiler, new ContextProviderImpl(log, kvp), roundTripperFactory, express.Router(), PlatformAPIClient.fromEnv());
107
+ return new MemoryInterpreter(log, compiler, new ContextProviderImpl(log, kvp), roundTripperFactory, express.Router(), new Map(), PlatformAPIClient.fromEnv(), CronAPIClient.fromEnv());
73
108
  }
74
109
  register(workflow, options) {
75
110
  const localAbortController = new AbortController();
@@ -86,6 +121,7 @@ export class MemoryInterpreter {
86
121
  contextProvider: this.contextProvider,
87
122
  roundTripperFactory: this.roundTripperFactory,
88
123
  router: this.router,
124
+ cronRegistry: this.cronRegistry,
89
125
  connectionProvider: this.connectionProvider
90
126
  };
91
127
  const trigger$ = this.compiler.compileTrigger(compilerContext, workflow.trigger, combinedSignal);
@@ -103,7 +139,7 @@ export class MemoryInterpreter {
103
139
  return registration;
104
140
  }
105
141
  async start() {
106
- const port = dntShim.Deno.env.get('PORT') || 3000;
142
+ const port = Deno.env.get('PORT') || 3000;
107
143
  const app = express();
108
144
  app.use(express.json()); // Add JSON body parser middleware
109
145
  // Add health check route
@@ -114,12 +150,22 @@ export class MemoryInterpreter {
114
150
  app.use(this.router);
115
151
  // Start all registered workflows
116
152
  for (const registration of this.registeredWorkflows) {
117
- dntShim.Deno.addSignalListener('SIGINT', registration.sigintListener);
118
- registration.trigger$
153
+ Deno.addSignalListener('SIGINT', registration.sigintListener);
154
+ registration.subscription = registration.trigger$
119
155
  .pipe(tap((ctx) => {
120
156
  ctx.log.info('MemoryInterpreter.executionStarted', { data: ctx.data });
121
- }), mergeMap((ctx) => of(ctx).pipe(registration.task$, catchError((error) => {
122
- ctx.log.error('MemoryInterpreter.executionError', { error });
157
+ }), mergeMap((ctx) => of(ctx).pipe(registration.task$, catchError((err) => {
158
+ ctx.log.error('MemoryInterpreter.executionError', { error: err instanceof Error ? err.toString() : err });
159
+ try {
160
+ ctx.options.onError?.(ctx.withData(err));
161
+ }
162
+ catch (err) {
163
+ ctx.log.error('MemoryInterpreter.onErrorError: failed to call onError handler', { error: err instanceof Error ? err.toString() : err });
164
+ ctx.options.onError?.(ctx.withData({
165
+ message: 'Internal server error',
166
+ error: err instanceof Error ? err.toString() : err,
167
+ }));
168
+ }
123
169
  return EMPTY;
124
170
  }))))
125
171
  .subscribe({
@@ -129,20 +175,82 @@ export class MemoryInterpreter {
129
175
  durationMs,
130
176
  data: ctx.data,
131
177
  });
178
+ try {
179
+ ctx.options.onSuccess?.(ctx);
180
+ }
181
+ catch (err) {
182
+ ctx.log.error('MemoryInterpreter.onSuccessError: failed to call onSuccess handler', { error: err instanceof Error ? err.toString() : err });
183
+ ctx.options.onSuccess?.(ctx.withData({
184
+ message: 'Internal server error',
185
+ error: err instanceof Error ? err.toString() : err,
186
+ }));
187
+ }
132
188
  this.contextProvider.destroy(ctx);
133
189
  },
134
190
  error: (err) => {
135
- this.log.error('MemoryInterpreter.error', { error: err });
136
- dntShim.Deno.removeSignalListener('SIGINT', registration.sigintListener);
191
+ this.log.error('MemoryInterpreter.error', { error: err instanceof Error ? err.toString() : err });
192
+ Deno.removeSignalListener('SIGINT', registration.sigintListener);
137
193
  },
138
194
  complete: () => {
139
195
  this.log.info('MemoryInterpreter.workflowCompleted');
140
- dntShim.Deno.removeSignalListener('SIGINT', registration.sigintListener);
196
+ Deno.removeSignalListener('SIGINT', registration.sigintListener);
141
197
  },
142
198
  });
199
+ registration.subscription.add(() => {
200
+ registration.subscription = undefined;
201
+ });
143
202
  }
144
- app.listen(port, () => {
203
+ try {
204
+ this.cronProvider.updateCrons(this.cronRegistry);
205
+ }
206
+ catch (err) {
207
+ this.log.error('MemoryInterpreter.updateCronsError', { error: err instanceof Error ? err.toString() : err });
208
+ throw new Error('Unable to register scheduler tasks with central cron provider');
209
+ }
210
+ this.server = app.listen(port, () => {
145
211
  this.log.info(`Express server listening on http://localhost:${port}`);
146
212
  });
213
+ this.shutdownServer = () => {
214
+ if (this.isShuttingDown) {
215
+ return;
216
+ }
217
+ this.isShuttingDown = true;
218
+ this.log.info('Shutting down server');
219
+ // Close the server
220
+ if (this.server) {
221
+ this.server.close();
222
+ }
223
+ // Remove all signal listeners
224
+ for (const registration of this.registeredWorkflows) {
225
+ Deno.removeSignalListener('SIGINT', registration.sigintListener);
226
+ // Unsubscribe from all observables
227
+ if (registration.subscription) {
228
+ registration.subscription.unsubscribe();
229
+ }
230
+ // Abort all controllers
231
+ registration.localAbortController.abort();
232
+ }
233
+ // Remove the server shutdown listener
234
+ if (this.shutdownServer) {
235
+ Deno.removeSignalListener('SIGINT', this.shutdownServer);
236
+ }
237
+ };
238
+ Deno.addSignalListener('SIGINT', this.shutdownServer);
239
+ return new Promise((resolve) => {
240
+ if (this.server) {
241
+ this.server.on('close', () => {
242
+ this.log.info('Server closed');
243
+ resolve();
244
+ });
245
+ }
246
+ else {
247
+ resolve();
248
+ }
249
+ });
250
+ }
251
+ async stop() {
252
+ if (this.shutdownServer) {
253
+ this.shutdownServer();
254
+ }
147
255
  }
148
256
  }
@@ -14,6 +14,7 @@ export type CompilerContext = {
14
14
  roundTripperFactory: RoundTripperFactory;
15
15
  connectionProvider: ConnectionProvider;
16
16
  router: Router;
17
+ cronRegistry: Map<string, string>;
17
18
  };
18
19
  export type CompilerFunc<In = any, Out = any, T extends Task<In, Out> = Task<In, Out>> = (ctx: CompilerContext, task: T) => OperatorFunction<In, Out>;
19
20
  export declare class ObservableCompiler {
@@ -1 +1 @@
1
- {"version":3,"file":"ObservableCompiler.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/ObservableCompiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,IAAI,EAAY,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAO/D,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE9F,OAAO,EAAE,OAAO,EAAe,MAAM,sBAAsB,CAAC;AAG5D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,MAAM,eAAe,GAAG;IAC1B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,GAAG,EAAE,MAA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AkB;IAC3B,OAAO,CAAC,aAAa,CAAkD;IACvE,OAAO,CAAC,gBAAgB,CAAgD;;IAgBxE,WAAW,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,KAAK,GAAG,IAAI,EACzC,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,GACpB,uBAAuB,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC;IAe1C,cAAc,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,EAC3D,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAerC,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,SAAS,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAKjF,eAAe,CAAC,GAAG,EAAE,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,eAAe,CAAC,GAAG,EAAE,CAAC,CAAC;CAIjF"}
@@ -1 +1 @@
1
- {"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA6F7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
1
+ {"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAuF7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
@@ -1,12 +1,15 @@
1
- import { CronJob } from 'cron';
2
1
  import { Observable } from 'rxjs';
3
2
  import { ScheduleTrigger } from '../../../dsl/triggers/ScheduleTrigger.js';
4
3
  function compileSchedule(ctx, trigger, signal) {
5
4
  return new Observable((subscriber) => {
5
+ // Add HTTP endpoint for manual triggering
6
+ if (!ctx.router) {
7
+ throw new Error('Router not available in compiler context');
8
+ }
6
9
  const client = ctx.connectionProvider;
7
- const job = CronJob.from({
8
- cronTime: trigger.schedule,
9
- onTick: async () => {
10
+ ctx.cronRegistry.set(trigger.id, trigger.schedule);
11
+ ctx.router.post(`/cron/${trigger.id}`, async (req, res) => {
12
+ try {
10
13
  if (trigger.activationPredicate === undefined) {
11
14
  const executionCtx = ctx.contextProvider.create({}, undefined);
12
15
  try {
@@ -15,6 +18,7 @@ function compileSchedule(ctx, trigger, signal) {
15
18
  catch (error) {
16
19
  executionCtx.log.error('execution error inside schedule', { error });
17
20
  }
21
+ res.status(200).json({ status: 'triggered', executionId: executionCtx.executionId });
18
22
  return;
19
23
  }
20
24
  const activations = await client.listActivations();
@@ -27,10 +31,11 @@ function compileSchedule(ctx, trigger, signal) {
27
31
  catch (error) {
28
32
  executionCtx.log.error('execution error inside schedule', { error });
29
33
  }
34
+ res.status(200).json({ status: 'triggered', executionId: executionCtx.executionId });
30
35
  return;
31
36
  }
32
37
  activations.forEach((activation) => {
33
- const executionCtx = ctx.contextProvider.create({}, activation);
38
+ const executionCtx = ctx.contextProvider.create({}, { activation });
34
39
  executionCtx.log.info('no activations found, continuing');
35
40
  try {
36
41
  subscriber.next(executionCtx);
@@ -39,31 +44,21 @@ function compileSchedule(ctx, trigger, signal) {
39
44
  executionCtx.log.error('execution error inside schedule', { error });
40
45
  }
41
46
  });
42
- },
43
- onComplete: () => {
44
- if (subscriber.closed) {
45
- return;
46
- }
47
- ctx.log.debug('schedule execution completed');
48
- subscriber.complete();
49
- },
50
- errorHandler: (error) => {
51
- ctx.log.error('schedule execution error', { error });
52
- subscriber.error(error);
53
- },
54
- start: true,
47
+ res.status(200).json({ status: 'triggered' });
48
+ }
49
+ catch (error) {
50
+ executionCtx.log.error('execution error inside schedule', { error });
51
+ res.status(500).json({ error: 'Failed to trigger schedule' });
52
+ }
55
53
  });
56
54
  function cleanup() {
57
- ctx.log.debug('schedule execution stopped');
58
- job.stop();
55
+ ctx.log.debug('scheduler trigger stopped');
56
+ subscriber.complete();
59
57
  }
60
58
  signal.addEventListener('abort', cleanup, { once: true });
61
59
  return () => {
62
60
  signal.removeEventListener('abort', cleanup);
63
- ctx.log.debug('schedule execution unsubscribed');
64
- // call job.stop() directly rather than using cleanup since cleanup is called when the
65
- // signal is aborted and we don't want duplicate logs when the unsubscription happens.
66
- job.stop();
61
+ ctx.log.debug('scheduler execution unsubscribed');
67
62
  };
68
63
  });
69
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAK7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CAwGxE,CAAC"}
1
+ {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAgD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CA+LxE,CAAC"}
@@ -1,71 +1,169 @@
1
1
  // In src/interpreter/memory/compilers/webhook.ts
2
+ import cors from 'cors';
2
3
  import { Observable } from 'rxjs';
4
+ import { pipeline } from 'node:stream/promises';
3
5
  import { WebhookTrigger } from '../../../dsl/triggers/WebhookTrigger.js';
6
+ const DEFAULT_SYNC_ON_SUCCESS = (ctx) => new Response(JSON.stringify(ctx.data), {
7
+ status: 200,
8
+ headers: {
9
+ 'Content-Type': 'application/json',
10
+ 'X-Execution-Id': ctx.executionId,
11
+ },
12
+ });
13
+ const DEFAULT_SYNC_ON_ERROR = (ctx) => new Response(JSON.stringify({ message: 'Internal server error', error: ctx.data }), {
14
+ status: 500,
15
+ headers: {
16
+ 'Content-Type': 'application/json',
17
+ 'X-Execution-Id': ctx.executionId,
18
+ },
19
+ });
20
+ const DEFAULT_ASYNC_ON_SUCCESS = (ctx) => new Response(JSON.stringify({
21
+ status: 'accepted',
22
+ executionId: ctx.executionId,
23
+ }), {
24
+ status: 202,
25
+ headers: {
26
+ 'Content-Type': 'application/json',
27
+ 'X-Execution-Id': ctx.executionId,
28
+ },
29
+ });
30
+ const DEFAULT_ASYNC_ON_ERROR = (ctx) => new Response(JSON.stringify({
31
+ message: 'Internal server error',
32
+ executionId: ctx.executionId,
33
+ }), {
34
+ status: 500,
35
+ headers: {
36
+ 'Content-Type': 'application/json',
37
+ 'X-Execution-Id': ctx.executionId,
38
+ },
39
+ });
4
40
  export const webhookCompiler = {
5
41
  ctor: WebhookTrigger,
6
42
  compile: (ctx, trigger, signal) => {
43
+ const { response: { mode = 'async', } = {}, cors: corsOptions, } = trigger.options;
44
+ const isSync = mode === 'sync';
45
+ const isAsync = mode === 'async';
46
+ if (!isSync && !isAsync) {
47
+ throw new Error('Invalid response mode, must be either "sync" or "async"');
48
+ }
49
+ let onSuccess = isSync ? DEFAULT_SYNC_ON_SUCCESS : DEFAULT_ASYNC_ON_SUCCESS;
50
+ let onError = isSync ? DEFAULT_SYNC_ON_ERROR : DEFAULT_ASYNC_ON_ERROR;
51
+ if (trigger.options.response?.onSuccess) {
52
+ onSuccess = trigger.options.response.onSuccess;
53
+ }
54
+ if (trigger.options.response?.onError) {
55
+ onError = trigger.options.response.onError;
56
+ }
57
+ const ctxOptionsFn = (res) => ({
58
+ onSuccess: (ctx) => {
59
+ if (isSync) {
60
+ sendResponse(res, onSuccess(ctx));
61
+ }
62
+ },
63
+ onError: (ctx) => {
64
+ if (isSync) {
65
+ sendResponse(res, onError(ctx));
66
+ }
67
+ },
68
+ });
7
69
  return new Observable((subscriber) => {
8
70
  if (!ctx.router) {
9
71
  throw new Error('Router not available in compiler context');
10
72
  }
11
73
  // add the webhook endpoint to the router
12
74
  ctx.log.info('webhook endpoint added:', { trigger });
75
+ if (corsOptions) {
76
+ if (typeof corsOptions === 'boolean') {
77
+ ctx.router.use(cors());
78
+ }
79
+ else {
80
+ ctx.router.use(cors(corsOptions));
81
+ }
82
+ }
13
83
  // endpoint for sans user because I'm not quite sure how the dynamic routing works
14
84
  ctx.router.post(`/${trigger.id}`, (req, res) => {
15
- const executionCtx = ctx.contextProvider.create(req.body, undefined);
85
+ const executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
16
86
  try {
17
87
  subscriber.next(executionCtx);
18
- res.status(200).json({ status: 'accepted' });
88
+ if (isAsync) {
89
+ sendResponse(res, onSuccess(executionCtx));
90
+ }
19
91
  }
20
92
  catch (error) {
21
- const message = error instanceof Error ? error.message : 'Unknown error';
22
- executionCtx.log.error('webhook execution error', { error });
23
- res.status(500).json({ status: 'error', message });
93
+ executionCtx.log.error('webhook execution error', {
94
+ error: JSON.stringify(error),
95
+ });
96
+ if (isAsync) {
97
+ sendResponse(res, onError(executionCtx.withData(error)));
98
+ }
24
99
  }
25
100
  });
26
101
  // this endpoint will trigger the workflow for each activation given by the external user ID
27
102
  ctx.router.post(`/${trigger.id}/users/:userId`, async (req, res) => {
28
- const userId = req.params.userId || undefined;
29
- if (!userId) {
30
- res.status(400).json({ status: 'error', message: 'User ID is required' });
31
- return;
32
- }
103
+ const userId = req.params.userId;
33
104
  const activations = await ctx.connectionProvider.getUserActivations(userId);
34
105
  if (!activations || activations.length === 0) {
35
- res.status(404).json({ status: 'error', message: `No activations found for user: ${userId}` });
106
+ res.status(404).json({
107
+ status: 'error',
108
+ message: `No activations found for user: ${userId}`,
109
+ });
36
110
  return;
37
111
  }
112
+ const executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
113
+ const errors = [];
38
114
  activations.forEach((activation) => {
39
- const executionCtx = ctx.contextProvider.create(req.body, activation);
115
+ const activationCtx = executionCtx.withActivation(activation);
40
116
  try {
41
- subscriber.next(executionCtx);
117
+ subscriber.next(activationCtx);
42
118
  }
43
119
  catch (error) {
44
- const message = error instanceof Error ? error.message : 'Unknown error';
45
- executionCtx.log.error('webhook execution error', { error });
46
- res.status(500).json({ status: 'error', message });
120
+ activationCtx.log.error('webhook execution error', {
121
+ error: JSON.stringify(error),
122
+ });
123
+ errors.push({
124
+ activationId: activation.id,
125
+ error,
126
+ });
47
127
  }
48
128
  });
49
- res.status(200).json({ status: 'accepted' });
129
+ if (isAsync) {
130
+ if (errors.length === 0) {
131
+ sendResponse(res, onSuccess(executionCtx));
132
+ }
133
+ else {
134
+ sendResponse(res, onError(executionCtx.withData(errors)));
135
+ }
136
+ }
50
137
  });
51
138
  // this endpoint will trigger the workflow only for the activation given by its ID
52
139
  ctx.router.post(`/${trigger.id}/activations/:activationId`, async (req, res) => {
53
- const activationId = req.params.activationId || undefined;
140
+ const activationId = req.params.activationId;
54
141
  const activation = await ctx.connectionProvider.getActivation(activationId);
55
142
  if (!activation) {
56
143
  // TODO report back actual errors
57
- res.status(404).json({ status: 'error', message: `No activation found for ID: ${activationId}` });
144
+ res.status(404).json({
145
+ status: 'error',
146
+ message: `No activation found for ID: ${activationId}`,
147
+ });
58
148
  return;
59
149
  }
60
- const executionCtx = ctx.contextProvider.create(req.body, activation);
150
+ const activationCtx = ctx.contextProvider.create(req.body, {
151
+ ...ctxOptionsFn(res),
152
+ activation,
153
+ });
61
154
  try {
62
- subscriber.next(executionCtx);
63
- res.status(200).json({ status: 'accepted' });
155
+ subscriber.next(activationCtx);
156
+ if (isAsync) {
157
+ sendResponse(res, onSuccess(activationCtx));
158
+ }
64
159
  }
65
160
  catch (error) {
66
- const message = error instanceof Error ? error.message : 'Unknown error';
67
- executionCtx.log.error('webhook execution error', { error });
68
- res.status(500).json({ status: 'error', message });
161
+ activationCtx.log.error('webhook execution error', {
162
+ error: JSON.stringify(error),
163
+ });
164
+ if (isAsync) {
165
+ sendResponse(res, onError(activationCtx.withData(error)));
166
+ }
69
167
  }
70
168
  });
71
169
  function cleanup() {
@@ -80,3 +178,12 @@ export const webhookCompiler = {
80
178
  });
81
179
  },
82
180
  };
181
+ function sendResponse(res, response) {
182
+ res.status(response.status);
183
+ response.headers.forEach((value, key) => {
184
+ res.setHeader(key, value);
185
+ });
186
+ if (response.body) {
187
+ pipeline(response.body, res);
188
+ }
189
+ }
@@ -19,7 +19,6 @@ 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>;
23
22
  kv(options: KVOptions): KeyValue;
24
23
  destroy(options: DestroyOptions): Promise<void>;
25
24
  private subjectPrefix;
@@ -1 +1 @@
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,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F,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,18 +1,17 @@
1
- import * as dntShim from "../../../_dnt.shims.js";
2
1
  import { JetStreamApiCodes, JetStreamApiError } from '../../../deps/jsr.io/@nats-io/jetstream/3.0.2/src/mod.js';
3
2
  import { Kvm } from '../../../deps/jsr.io/@nats-io/kv/3.0.2/src/mod.js';
4
3
  import { connect, credsAuthenticator } from '../../../deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.js';
5
4
  import { isKVOptionsExecution, } from '../KeyValue.js';
6
5
  import { NatsKeyValue } from './NatsKeyValue.js';
7
6
  function getOptionsFromEnv() {
8
- const natsTlsCaFile = dntShim.Deno.env.get('RUN_NATS_TLS_CA_FILE');
7
+ const natsTlsCaFile = Deno.env.get('RUN_NATS_TLS_CA_FILE');
9
8
  return {
10
- organizationId: dntShim.Deno.env.get('RUN_ORGANISATION_ID'),
11
- projectId: dntShim.Deno.env.get('RUN_SERVICE_ID'),
12
- environment: dntShim.Deno.env.get('RUN_ENVIRONMENT'),
9
+ organizationId: Deno.env.get('RUN_ORGANISATION_ID'),
10
+ projectId: Deno.env.get('RUN_SERVICE_ID'),
11
+ environment: Deno.env.get('RUN_ENVIRONMENT'),
13
12
  nats: {
14
- url: dntShim.Deno.env.get('RUN_NATS_URL') || 'nats://localhost:4222',
15
- credsFile: dntShim.Deno.env.get('RUN_NATS_CREDS_FILE'),
13
+ url: Deno.env.get('RUN_NATS_URL') || 'nats://localhost:4222',
14
+ credsFile: Deno.env.get('RUN_NATS_CREDS_FILE'),
16
15
  ...(natsTlsCaFile && {
17
16
  tls: {
18
17
  caFile: natsTlsCaFile,
@@ -85,7 +84,7 @@ export class NatsKeyValueProvider {
85
84
  static async newInstance(opts = {}) {
86
85
  const parsedOpts = mergeOptions(getOptionsFromEnv(), opts);
87
86
  const credsFile = parsedOpts.nats.credsFile
88
- ? await dntShim.Deno.readFile(parsedOpts.nats.credsFile)
87
+ ? await Deno.readFile(parsedOpts.nats.credsFile)
89
88
  : undefined;
90
89
  const conn = await connect({
91
90
  servers: [parsedOpts.nats.url],
@@ -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;AA+B/C;;GAEG;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,CAA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