@versori/run 0.2.13 → 0.2.15

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 (153) hide show
  1. package/esm/src/context/AsyncWorkflow.d.ts +14 -0
  2. package/esm/src/context/AsyncWorkflow.d.ts.map +1 -0
  3. package/esm/src/context/AsyncWorkflow.js +89 -0
  4. package/esm/src/context/Context.d.ts +12 -1
  5. package/esm/src/context/Context.d.ts.map +1 -1
  6. package/esm/src/context/Context.js +43 -4
  7. package/esm/src/context/ContextProvider.d.ts +3 -1
  8. package/esm/src/context/ContextProvider.d.ts.map +1 -1
  9. package/esm/src/context/ContextProvider.js +9 -2
  10. package/esm/src/dsl/http/versori/constants.d.ts +1 -0
  11. package/esm/src/dsl/http/versori/constants.d.ts.map +1 -1
  12. package/esm/src/dsl/http/versori/constants.js +1 -0
  13. package/esm/src/dsl/triggers/DurableTrigger.d.ts +17 -0
  14. package/esm/src/dsl/triggers/DurableTrigger.d.ts.map +1 -0
  15. package/esm/src/dsl/triggers/DurableTrigger.js +36 -0
  16. package/esm/src/dsl/triggers/mod.d.ts +1 -0
  17. package/esm/src/dsl/triggers/mod.d.ts.map +1 -1
  18. package/esm/src/dsl/triggers/mod.js +1 -0
  19. package/esm/src/interpreter/durable/DurableInterpreter.d.ts +52 -0
  20. package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -0
  21. package/esm/src/interpreter/durable/DurableInterpreter.js +433 -0
  22. package/esm/src/interpreter/durable/ExecutionError.d.ts +6 -0
  23. package/esm/src/interpreter/durable/ExecutionError.d.ts.map +1 -0
  24. package/esm/src/interpreter/durable/ExecutionError.js +13 -0
  25. package/esm/src/interpreter/durable/ObservableCompiler.d.ts +35 -0
  26. package/esm/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -0
  27. package/esm/src/interpreter/durable/ObservableCompiler.js +69 -0
  28. package/esm/src/interpreter/durable/Queue.d.ts +60 -0
  29. package/esm/src/interpreter/durable/Queue.d.ts.map +1 -0
  30. package/esm/src/interpreter/durable/Queue.js +131 -0
  31. package/esm/src/interpreter/durable/compilers/background.d.ts +4 -0
  32. package/esm/src/interpreter/durable/compilers/background.d.ts.map +1 -0
  33. package/esm/src/interpreter/durable/compilers/background.js +22 -0
  34. package/esm/src/interpreter/durable/compilers/catch.d.ts +4 -0
  35. package/esm/src/interpreter/durable/compilers/catch.d.ts.map +1 -0
  36. package/esm/src/interpreter/durable/compilers/catch.js +36 -0
  37. package/esm/src/interpreter/durable/compilers/chain.d.ts +3 -0
  38. package/esm/src/interpreter/durable/compilers/chain.d.ts.map +1 -0
  39. package/esm/src/interpreter/durable/compilers/chain.js +9 -0
  40. package/esm/src/interpreter/durable/compilers/durableworkflow.d.ts +8 -0
  41. package/esm/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -0
  42. package/esm/src/interpreter/durable/compilers/durableworkflow.js +54 -0
  43. package/esm/src/interpreter/durable/compilers/fn.d.ts +4 -0
  44. package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -0
  45. package/esm/src/interpreter/durable/compilers/fn.js +22 -0
  46. package/esm/src/interpreter/durable/compilers/http.d.ts +4 -0
  47. package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -0
  48. package/esm/src/interpreter/durable/compilers/http.js +44 -0
  49. package/esm/src/interpreter/durable/compilers/mod.d.ts +2 -0
  50. package/esm/src/interpreter/durable/compilers/mod.d.ts.map +1 -0
  51. package/esm/src/interpreter/durable/compilers/mod.js +1 -0
  52. package/esm/src/interpreter/durable/compilers/parallel.d.ts +4 -0
  53. package/esm/src/interpreter/durable/compilers/parallel.d.ts.map +1 -0
  54. package/esm/src/interpreter/durable/compilers/parallel.js +19 -0
  55. package/esm/src/interpreter/durable/compilers/schedule.d.ts +4 -0
  56. package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -0
  57. package/esm/src/interpreter/durable/compilers/schedule.js +94 -0
  58. package/esm/src/interpreter/durable/compilers/serial.d.ts +4 -0
  59. package/esm/src/interpreter/durable/compilers/serial.d.ts.map +1 -0
  60. package/esm/src/interpreter/durable/compilers/serial.js +16 -0
  61. package/esm/src/interpreter/durable/compilers/types.d.ts +15 -0
  62. package/esm/src/interpreter/durable/compilers/types.d.ts.map +1 -0
  63. package/esm/src/interpreter/durable/compilers/types.js +1 -0
  64. package/esm/src/interpreter/durable/compilers/unpack.d.ts +4 -0
  65. package/esm/src/interpreter/durable/compilers/unpack.d.ts.map +1 -0
  66. package/esm/src/interpreter/durable/compilers/unpack.js +22 -0
  67. package/esm/src/interpreter/durable/compilers/webhook.d.ts +4 -0
  68. package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -0
  69. package/esm/src/interpreter/durable/compilers/webhook.js +248 -0
  70. package/esm/src/interpreter/durable/mod.d.ts +5 -0
  71. package/esm/src/interpreter/durable/mod.d.ts.map +1 -0
  72. package/esm/src/interpreter/durable/mod.js +4 -0
  73. package/esm/src/interpreter/memory/MemoryInterpreter.js +1 -1
  74. package/esm/src/interpreter/mod.d.ts +1 -0
  75. package/esm/src/interpreter/mod.d.ts.map +1 -1
  76. package/esm/src/interpreter/mod.js +1 -0
  77. package/package.json +1 -1
  78. package/script/src/context/AsyncWorkflow.d.ts +14 -0
  79. package/script/src/context/AsyncWorkflow.d.ts.map +1 -0
  80. package/script/src/context/AsyncWorkflow.js +93 -0
  81. package/script/src/context/Context.d.ts +12 -1
  82. package/script/src/context/Context.d.ts.map +1 -1
  83. package/script/src/context/Context.js +43 -4
  84. package/script/src/context/ContextProvider.d.ts +3 -1
  85. package/script/src/context/ContextProvider.d.ts.map +1 -1
  86. package/script/src/context/ContextProvider.js +9 -2
  87. package/script/src/dsl/http/versori/constants.d.ts +1 -0
  88. package/script/src/dsl/http/versori/constants.d.ts.map +1 -1
  89. package/script/src/dsl/http/versori/constants.js +2 -1
  90. package/script/src/dsl/triggers/DurableTrigger.d.ts +17 -0
  91. package/script/src/dsl/triggers/DurableTrigger.d.ts.map +1 -0
  92. package/script/src/dsl/triggers/DurableTrigger.js +41 -0
  93. package/script/src/dsl/triggers/mod.d.ts +1 -0
  94. package/script/src/dsl/triggers/mod.d.ts.map +1 -1
  95. package/script/src/dsl/triggers/mod.js +3 -1
  96. package/script/src/interpreter/durable/DurableInterpreter.d.ts +52 -0
  97. package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -0
  98. package/script/src/interpreter/durable/DurableInterpreter.js +440 -0
  99. package/script/src/interpreter/durable/ExecutionError.d.ts +6 -0
  100. package/script/src/interpreter/durable/ExecutionError.d.ts.map +1 -0
  101. package/script/src/interpreter/durable/ExecutionError.js +17 -0
  102. package/script/src/interpreter/durable/ObservableCompiler.d.ts +35 -0
  103. package/script/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -0
  104. package/script/src/interpreter/durable/ObservableCompiler.js +73 -0
  105. package/script/src/interpreter/durable/Queue.d.ts +60 -0
  106. package/script/src/interpreter/durable/Queue.d.ts.map +1 -0
  107. package/script/src/interpreter/durable/Queue.js +135 -0
  108. package/script/src/interpreter/durable/compilers/background.d.ts +4 -0
  109. package/script/src/interpreter/durable/compilers/background.d.ts.map +1 -0
  110. package/script/src/interpreter/durable/compilers/background.js +25 -0
  111. package/script/src/interpreter/durable/compilers/catch.d.ts +4 -0
  112. package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -0
  113. package/script/src/interpreter/durable/compilers/catch.js +39 -0
  114. package/script/src/interpreter/durable/compilers/chain.d.ts +3 -0
  115. package/script/src/interpreter/durable/compilers/chain.d.ts.map +1 -0
  116. package/script/src/interpreter/durable/compilers/chain.js +12 -0
  117. package/script/src/interpreter/durable/compilers/durableworkflow.d.ts +8 -0
  118. package/script/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -0
  119. package/script/src/interpreter/durable/compilers/durableworkflow.js +58 -0
  120. package/script/src/interpreter/durable/compilers/fn.d.ts +4 -0
  121. package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -0
  122. package/script/src/interpreter/durable/compilers/fn.js +25 -0
  123. package/script/src/interpreter/durable/compilers/http.d.ts +4 -0
  124. package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -0
  125. package/script/src/interpreter/durable/compilers/http.js +47 -0
  126. package/script/src/interpreter/durable/compilers/mod.d.ts +2 -0
  127. package/script/src/interpreter/durable/compilers/mod.d.ts.map +1 -0
  128. package/script/src/interpreter/durable/compilers/mod.js +2 -0
  129. package/script/src/interpreter/durable/compilers/parallel.d.ts +4 -0
  130. package/script/src/interpreter/durable/compilers/parallel.d.ts.map +1 -0
  131. package/script/src/interpreter/durable/compilers/parallel.js +22 -0
  132. package/script/src/interpreter/durable/compilers/schedule.d.ts +4 -0
  133. package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -0
  134. package/script/src/interpreter/durable/compilers/schedule.js +97 -0
  135. package/script/src/interpreter/durable/compilers/serial.d.ts +4 -0
  136. package/script/src/interpreter/durable/compilers/serial.d.ts.map +1 -0
  137. package/script/src/interpreter/durable/compilers/serial.js +19 -0
  138. package/script/src/interpreter/durable/compilers/types.d.ts +15 -0
  139. package/script/src/interpreter/durable/compilers/types.d.ts.map +1 -0
  140. package/script/src/interpreter/durable/compilers/types.js +2 -0
  141. package/script/src/interpreter/durable/compilers/unpack.d.ts +4 -0
  142. package/script/src/interpreter/durable/compilers/unpack.d.ts.map +1 -0
  143. package/script/src/interpreter/durable/compilers/unpack.js +25 -0
  144. package/script/src/interpreter/durable/compilers/webhook.d.ts +4 -0
  145. package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -0
  146. package/script/src/interpreter/durable/compilers/webhook.js +254 -0
  147. package/script/src/interpreter/durable/mod.d.ts +5 -0
  148. package/script/src/interpreter/durable/mod.d.ts.map +1 -0
  149. package/script/src/interpreter/durable/mod.js +20 -0
  150. package/script/src/interpreter/memory/MemoryInterpreter.js +1 -1
  151. package/script/src/interpreter/mod.d.ts +1 -0
  152. package/script/src/interpreter/mod.d.ts.map +1 -1
  153. package/script/src/interpreter/mod.js +14 -0
@@ -0,0 +1,35 @@
1
+ import { Observable, OperatorFunction } from 'rxjs';
2
+ import { Task } from '../../dsl/Task.js';
3
+ import { Logger } from '../../observability/logging/Logger.js';
4
+ import { ContextOperatorFunction, TaskCompiler, TriggerCompiler } from './compilers/types.js';
5
+ import { Trigger } from '../../dsl/Trigger.js';
6
+ import { ContextProvider } from '../../context/ContextProvider.js';
7
+ import { ContextImpl } from '../../context/Context.js';
8
+ import { ConfigReader, ConnectionProvider, RoundTripperFactory } from '../../dsl/http/types.js';
9
+ import { Router } from 'express';
10
+ import { Tracer } from '@opentelemetry/api';
11
+ import { QueueAPI } from './Queue.js';
12
+ export type DurableCompilerContext = {
13
+ compiler: ObservableCompiler;
14
+ log: Logger;
15
+ tracer: Tracer;
16
+ contextProvider: ContextProvider;
17
+ roundTripperFactory: RoundTripperFactory;
18
+ connectionProvider: ConnectionProvider;
19
+ queueProvider: QueueAPI;
20
+ webhookRouter: Router;
21
+ cronRouter: Router;
22
+ configReader: ConfigReader;
23
+ cronRegistry: Map<string, string>;
24
+ };
25
+ export type CompilerFunc<In = any, Out = any, T extends Task<In, Out> = Task<In, Out>> = (ctx: DurableCompilerContext, task: T) => OperatorFunction<In, Out>;
26
+ export declare class ObservableCompiler {
27
+ private taskCompilers;
28
+ private triggerCompilers;
29
+ constructor();
30
+ compileTask<In = any, Out = any, Index = void>(ctx: DurableCompilerContext, task: Task<In, Out>): ContextOperatorFunction<In, Out, Index>;
31
+ compileTrigger<Out = any, T extends Trigger<Out> = Trigger<Out>>(ctx: DurableCompilerContext, trigger: T, signal: AbortSignal): Observable<ContextImpl<Out, void>>;
32
+ registerTask<In, Out, T extends Task<In, Out>>(compiler: TaskCompiler<In, Out, T>): void;
33
+ registerTrigger<Out, T extends Trigger<Out>>(compiler: TriggerCompiler<Out, T>): void;
34
+ }
35
+ //# sourceMappingURL=ObservableCompiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObservableCompiler.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/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,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAChG,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,MAAM,sBAAsB,GAAG;IACjC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,eAAe,CAAC;IACjC,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,aAAa,EAAE,QAAQ,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC,SAAS,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,CACrF,GAAG,EAAE,sBAAsB,EAC3B,IAAI,EAAE,CAAC,KACN,gBAAgB,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAE/B,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,aAAa,CAAkD;IACvE,OAAO,CAAC,gBAAgB,CAAgD;;IAkBxE,WAAW,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,KAAK,GAAG,IAAI,EACzC,GAAG,EAAE,sBAAsB,EAC3B,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,sBAAsB,EAC3B,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAgBrC,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"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ObservableCompiler = void 0;
4
+ const Task_js_1 = require("../../dsl/Task.js");
5
+ const background_js_1 = require("./compilers/background.js");
6
+ const catch_js_1 = require("./compilers/catch.js");
7
+ const chain_js_1 = require("./compilers/chain.js");
8
+ const fn_js_1 = require("./compilers/fn.js");
9
+ const parallel_js_1 = require("./compilers/parallel.js");
10
+ const serial_js_1 = require("./compilers/serial.js");
11
+ const unpack_js_1 = require("./compilers/unpack.js");
12
+ const Trigger_js_1 = require("../../dsl/Trigger.js");
13
+ const schedule_js_1 = require("./compilers/schedule.js");
14
+ const webhook_js_1 = require("./compilers/webhook.js");
15
+ const http_js_1 = require("./compilers/http.js");
16
+ const durableworkflow_js_1 = require("./compilers/durableworkflow.js");
17
+ class ObservableCompiler {
18
+ constructor() {
19
+ Object.defineProperty(this, "taskCompilers", {
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true,
23
+ value: new Map()
24
+ });
25
+ Object.defineProperty(this, "triggerCompilers", {
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true,
29
+ value: new Map()
30
+ });
31
+ // Register all available compilers
32
+ this.registerTask(parallel_js_1.parallelCompiler);
33
+ this.registerTask(serial_js_1.serialCompiler);
34
+ this.registerTask(catch_js_1.catchCompiler);
35
+ this.registerTask(chain_js_1.chainCompiler);
36
+ this.registerTask(fn_js_1.fnCompiler);
37
+ this.registerTask(background_js_1.backgroundCompiler);
38
+ this.registerTask(unpack_js_1.unpackCompiler);
39
+ this.registerTask(http_js_1.httpCompiler);
40
+ this.registerTrigger(schedule_js_1.scheduleCompiler);
41
+ this.registerTrigger(webhook_js_1.webhookCompiler);
42
+ this.registerTrigger(durableworkflow_js_1.durableWorkflowCompiler);
43
+ }
44
+ compileTask(ctx, task) {
45
+ const compiler = this.taskCompilers.get(task[Task_js_1.TaskType]);
46
+ if (!compiler) {
47
+ throw new Error(`No compiler registered for task type: ${task[Task_js_1.TaskType]}`);
48
+ }
49
+ if (!(task instanceof compiler.ctor)) {
50
+ throw new Error(`Task type mismatch: expected ${compiler.ctor.name}, got ${task.constructor.name}`);
51
+ }
52
+ return compiler.compile(ctx, task);
53
+ }
54
+ compileTrigger(ctx, trigger, signal) {
55
+ const compiler = this.triggerCompilers.get(trigger[Trigger_js_1.TriggerType]);
56
+ if (!compiler) {
57
+ throw new Error(`No compiler registered for trigger type: ${trigger[Trigger_js_1.TriggerType]}`);
58
+ }
59
+ if (!(trigger instanceof compiler.ctor)) {
60
+ throw new Error(`Trigger type mismatch: expected ${compiler.ctor.name}, got ${trigger.constructor.name}`);
61
+ }
62
+ return compiler.compile(ctx, trigger, signal);
63
+ }
64
+ registerTask(compiler) {
65
+ const task = new compiler.ctor();
66
+ this.taskCompilers.set(task[Task_js_1.TaskType], compiler);
67
+ }
68
+ registerTrigger(compiler) {
69
+ const trigger = new compiler.ctor();
70
+ this.triggerCompilers.set(trigger[Trigger_js_1.TriggerType], compiler);
71
+ }
72
+ }
73
+ exports.ObservableCompiler = ObservableCompiler;
@@ -0,0 +1,60 @@
1
+ import { Logger } from '../../observability/mod.js';
2
+ export type WorkflowMsgMetadata = {
3
+ parentWorkflowId?: string;
4
+ executionId?: string;
5
+ activationId?: string;
6
+ userId?: string;
7
+ };
8
+ export type Workflows = {
9
+ workflows: WorkflowMsg[];
10
+ };
11
+ export type WorkflowMsg = {
12
+ id?: string;
13
+ projectId?: string;
14
+ group: string;
15
+ payload?: string;
16
+ output?: string;
17
+ status?: 'available' | 'locked' | 'completed' | 'failed';
18
+ attempt?: number;
19
+ timeout?: string;
20
+ createdAt?: string;
21
+ metadata?: WorkflowMsgMetadata;
22
+ };
23
+ export type CompleteWorkflowRequest = {
24
+ id: string;
25
+ output?: string;
26
+ status: 'completed' | 'failed';
27
+ };
28
+ export type FetchWorkflowsRequest = {
29
+ ttl?: number;
30
+ limit?: number;
31
+ group: string;
32
+ projectId?: string;
33
+ };
34
+ export type RescheduleWorkflowRequest = {
35
+ id: string;
36
+ after: string;
37
+ };
38
+ export type SubmitWorkflowsRequest = {
39
+ workflows: WorkflowMsg[];
40
+ };
41
+ export interface QueueAPI {
42
+ complete(request: CompleteWorkflowRequest): Promise<void>;
43
+ submit(request: SubmitWorkflowsRequest): Promise<Workflows>;
44
+ fetchWorkflows(request: FetchWorkflowsRequest): Promise<Workflows | undefined>;
45
+ reschedule(request: RescheduleWorkflowRequest): Promise<void>;
46
+ poll(workflowId: string): Promise<WorkflowMsg>;
47
+ }
48
+ export declare class QueueImpl implements QueueAPI {
49
+ private baseUrl;
50
+ private log;
51
+ private projectId;
52
+ constructor(baseUrl: string, projectId: string, log: Logger);
53
+ static fromEnv(log: Logger): QueueImpl;
54
+ complete(request: CompleteWorkflowRequest): Promise<void>;
55
+ submit(request: SubmitWorkflowsRequest): Promise<Workflows>;
56
+ fetchWorkflows(request: FetchWorkflowsRequest): Promise<Workflows | undefined>;
57
+ reschedule(request: RescheduleWorkflowRequest): Promise<void>;
58
+ poll(workflowId: string): Promise<WorkflowMsg>;
59
+ }
60
+ //# sourceMappingURL=Queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/Queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAIpD,MAAM,MAAM,mBAAmB,GAAG;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACpB,SAAS,EAAE,WAAW,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,mBAAmB,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACjC,SAAS,EAAE,WAAW,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,MAAM,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5D,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IAC/E,UAAU,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAClD;AAED,qBAAa,SAAU,YAAW,QAAQ;IACtC,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,SAAS,CAAS;gBAEd,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAM3D,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS;IAchC,QAAQ,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBzD,MAAM,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC;IA0B3D,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IA8B9E,UAAU,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB7D,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAevD"}
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QueueImpl = void 0;
4
+ const mod_js_1 = require("../../mod.js");
5
+ const constants_js_1 = require("../../dsl/http/versori/constants.js");
6
+ class QueueImpl {
7
+ constructor(baseUrl, projectId, log) {
8
+ Object.defineProperty(this, "baseUrl", {
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true,
12
+ value: void 0
13
+ });
14
+ Object.defineProperty(this, "log", {
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true,
18
+ value: void 0
19
+ });
20
+ Object.defineProperty(this, "projectId", {
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true,
24
+ value: void 0
25
+ });
26
+ this.baseUrl = baseUrl;
27
+ this.log = log;
28
+ this.projectId = projectId;
29
+ }
30
+ static fromEnv(log) {
31
+ // TODO make these environment variables configurable in constants/ts
32
+ const baseUrl = Deno.env.get(constants_js_1.envVarWorkflowApiBaseURL);
33
+ const _log = log || new mod_js_1.ConsoleLogger('debug');
34
+ const projectId = Deno.env.get(constants_js_1.envVarProjectId) || 'default-project';
35
+ if (!baseUrl) {
36
+ throw new Error('Missing required environment variables');
37
+ }
38
+ return new QueueImpl(baseUrl, projectId, _log);
39
+ }
40
+ async complete(request) {
41
+ const resp = await fetch(`${this.baseUrl}/v1/workflows/complete`, {
42
+ method: 'POST',
43
+ body: JSON.stringify({
44
+ id: request.id,
45
+ output: request.output,
46
+ status: request.status,
47
+ }),
48
+ });
49
+ if (!resp.ok) {
50
+ this.log.error('Failed to complete workflow', {
51
+ id: request.id,
52
+ output: request.output,
53
+ status: request.status,
54
+ });
55
+ throw new Error('Failed to complete workflow');
56
+ }
57
+ return;
58
+ }
59
+ async submit(request) {
60
+ // Ensure all workflows have the projectId set
61
+ const workflows = request.workflows.map((w) => ({
62
+ ...w,
63
+ projectId: this.projectId || w.projectId,
64
+ }));
65
+ const resp = await fetch(`${this.baseUrl}/v1/workflows/submit`, {
66
+ method: 'POST',
67
+ body: JSON.stringify({
68
+ workflows: workflows,
69
+ }),
70
+ });
71
+ if (!resp.ok) {
72
+ this.log.error('Failed to submit workflows', {
73
+ workflows: workflows,
74
+ });
75
+ throw new Error('Failed to submit workflows');
76
+ }
77
+ const result = (await resp.json());
78
+ return result;
79
+ }
80
+ async fetchWorkflows(request) {
81
+ const resp = await fetch(`${this.baseUrl}/v1/workflows/fetch`, {
82
+ method: 'POST',
83
+ body: JSON.stringify({
84
+ ttl: request.ttl,
85
+ limit: request.limit,
86
+ group: request.group,
87
+ projectId: this.projectId || request.projectId,
88
+ }),
89
+ });
90
+ if (!resp.ok) {
91
+ this.log.error('Failed to fetch workflows', {
92
+ ttl: request.ttl,
93
+ limit: request.limit,
94
+ group: request.group,
95
+ projectId: this.projectId || request.projectId,
96
+ });
97
+ throw new Error('Failed to fetch workflows');
98
+ }
99
+ if (resp.status === 204) {
100
+ return undefined;
101
+ }
102
+ const result = (await resp.json());
103
+ return result;
104
+ }
105
+ async reschedule(request) {
106
+ const resp = await fetch(`${this.baseUrl}/v1/workflows/reschedule`, {
107
+ method: 'POST',
108
+ body: JSON.stringify({
109
+ id: request.id,
110
+ after: request.after,
111
+ }),
112
+ });
113
+ if (!resp.ok) {
114
+ this.log.error('Failed to reschedule workflow', {
115
+ id: request.id,
116
+ after: request.after,
117
+ });
118
+ throw new Error('Failed to reschedule workflow');
119
+ }
120
+ return;
121
+ }
122
+ async poll(workflowId) {
123
+ // this endpoint returns a 404 if the workflow is not completed
124
+ const resp = await fetch(`${this.baseUrl}/v1/workflows/fetch/${workflowId}`, {
125
+ method: 'GET',
126
+ });
127
+ if (!resp.ok) {
128
+ this.log.error('Failed to poll workflow', { workflowId });
129
+ throw new Error('Failed to poll workflow');
130
+ }
131
+ const result = (await resp.json());
132
+ return result;
133
+ }
134
+ }
135
+ exports.QueueImpl = QueueImpl;
@@ -0,0 +1,4 @@
1
+ import { BackgroundTask } from '../../../dsl/tasks/BackgroundTask.js';
2
+ import { TaskCompiler } from './types.js';
3
+ export declare const backgroundCompiler: TaskCompiler<any, any, BackgroundTask<any, any>>;
4
+ //# sourceMappingURL=background.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"background.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/background.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA0CnE,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/E,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.backgroundCompiler = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const BackgroundTask_js_1 = require("../../../dsl/tasks/BackgroundTask.js");
6
+ function compileBackground(ctx, task) {
7
+ const base = ctx.compiler.compileTask(ctx, task._base);
8
+ return (src) => src.pipe((0, rxjs_1.connect)((shared$) => (0, rxjs_1.merge)(shared$.pipe((0, rxjs_1.mergeMap)((ctx) => base((0, rxjs_1.of)(ctx)).pipe((0, rxjs_1.subscribeOn)(rxjs_1.asyncScheduler), (0, rxjs_1.tap)({
9
+ next: (ctx) => ctx.log.debug('Background task emitted a value', {
10
+ data: ctx.data,
11
+ }),
12
+ complete: () => ctx.log.debug('Background task completed'),
13
+ }), (0, rxjs_1.catchError)((error) => {
14
+ ctx.log.error('Error in background task', {
15
+ error,
16
+ inputData: ctx.data,
17
+ executionId: ctx.executionId,
18
+ });
19
+ return rxjs_1.EMPTY;
20
+ }), (0, rxjs_1.ignoreElements)()))), shared$.pipe((0, rxjs_1.map)((ctx) => ctx.withData(void 0))))));
21
+ }
22
+ exports.backgroundCompiler = {
23
+ ctor: BackgroundTask_js_1.BackgroundTask,
24
+ compile: compileBackground,
25
+ };
@@ -0,0 +1,4 @@
1
+ import { CatchTask } from '../../../dsl/tasks/CatchTask.js';
2
+ import { TaskCompiler } from './types.js';
3
+ export declare const catchCompiler: TaskCompiler<any, any, CatchTask<any, any>>;
4
+ //# sourceMappingURL=catch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catch.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/catch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAmDnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAGrE,CAAC"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.catchCompiler = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const CatchTask_js_1 = require("../../../dsl/tasks/CatchTask.js");
6
+ const ExecutionError_js_1 = require("../ExecutionError.js");
7
+ function compileCatch(compilerCtx, task) {
8
+ const baseOperator = compilerCtx.compiler.compileTask(compilerCtx, task._base);
9
+ const errorOperator = compilerCtx.compiler.compileTask(compilerCtx, task._errorHandler);
10
+ return (src) => src.pipe((0, rxjs_1.mergeMap)((ctx) => {
11
+ return baseOperator((0, rxjs_1.of)(ctx)).pipe((0, rxjs_1.catchError)((error) => {
12
+ return compilerCtx.tracer.startActiveSpan(`catch`, (span) => {
13
+ span.setAttribute('execution.id', ctx.executionId);
14
+ span.setAttribute('task.type', 'catch');
15
+ if (error instanceof Error) {
16
+ span.recordException(error);
17
+ span.setAttribute('error.message', error.message);
18
+ span.setAttribute('error.stack', error.stack ?? '');
19
+ span.end();
20
+ ctx.log.error('execution has encountered an error', {
21
+ error: error.message,
22
+ stack: error.stack,
23
+ });
24
+ return errorOperator((0, rxjs_1.of)(ctx.withData(new ExecutionError_js_1.ExecutionError(ctx, error.message, { cause: error }))));
25
+ }
26
+ ctx.log.error('execution has encountered an error', {
27
+ error: error,
28
+ });
29
+ span.setAttribute('error', `${error}`);
30
+ span.end();
31
+ return errorOperator((0, rxjs_1.of)(ctx.withData(new ExecutionError_js_1.ExecutionError(ctx, `${error}`, { cause: error }))));
32
+ });
33
+ }));
34
+ }));
35
+ }
36
+ exports.catchCompiler = {
37
+ ctor: CatchTask_js_1.CatchTask,
38
+ compile: compileCatch,
39
+ };
@@ -0,0 +1,3 @@
1
+ import { TaskCompiler } from './types.js';
2
+ export declare const chainCompiler: TaskCompiler<any, any, any>;
3
+ //# sourceMappingURL=chain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/chain.ts"],"names":[],"mappings":"AAIA,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAYnE,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAGrD,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chainCompiler = void 0;
4
+ const ChainTask_js_1 = require("../../../dsl/tasks/ChainTask.js");
5
+ function compileChain(ctx, task) {
6
+ const operators = task.tasks.map((t) => ctx.compiler.compileTask(ctx, t));
7
+ return (src) => operators.reduce((acc, curr) => curr(acc), src);
8
+ }
9
+ exports.chainCompiler = {
10
+ ctor: ChainTask_js_1.ChainTask,
11
+ compile: compileChain,
12
+ };
@@ -0,0 +1,8 @@
1
+ import { Observable } from 'rxjs';
2
+ import { DurableCompilerContext } from '../mod.js';
3
+ import { ContextImpl } from '../../../mod.js';
4
+ import { DurableWorkflowData, DurableWorkflowTrigger } from '../../../dsl/triggers/DurableTrigger.js';
5
+ import { TriggerCompiler } from './mod.js';
6
+ export declare function compileDurableWorkflow(ctx: DurableCompilerContext, trigger: DurableWorkflowTrigger, signal: AbortSignal): Observable<ContextImpl<DurableWorkflowData>>;
7
+ export declare const durableWorkflowCompiler: TriggerCompiler<DurableWorkflowData, DurableWorkflowTrigger>;
8
+ //# sourceMappingURL=durableworkflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durableworkflow.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/durableworkflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACzB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,wBAAgB,sBAAsB,CAClC,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,WAAW,GACpB,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAwD9C;AAED,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,mBAAmB,EAAE,sBAAsB,CAI5F,CAAC"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.durableWorkflowCompiler = void 0;
4
+ exports.compileDurableWorkflow = compileDurableWorkflow;
5
+ const rxjs_1 = require("rxjs");
6
+ const DurableTrigger_js_1 = require("../../../dsl/triggers/DurableTrigger.js");
7
+ function compileDurableWorkflow(ctx, trigger, signal) {
8
+ return new rxjs_1.Observable((subscriber) => {
9
+ function cleanup() {
10
+ ctx.log.debug('webhook trigger stopped');
11
+ subscriber.complete();
12
+ }
13
+ signal.addEventListener('abort', cleanup, { once: true });
14
+ (async () => {
15
+ while (true) {
16
+ if (signal.aborted) {
17
+ cleanup();
18
+ break;
19
+ }
20
+ try {
21
+ // Right now the API itself will hang for a period of time if no workflows are available.
22
+ // so we don't need to add a delay here.
23
+ const wfs = await ctx.queueProvider.fetchWorkflows({
24
+ group: trigger.id,
25
+ ttl: trigger.options.ttl,
26
+ limit: trigger.options.limit,
27
+ });
28
+ if (!wfs) {
29
+ continue; // No workflows found, continue polling
30
+ }
31
+ for (const wf of wfs.workflows) {
32
+ const data = JSON.parse(atob(wf.payload ?? "{}"));
33
+ let activation;
34
+ if (wf.metadata?.activationId) {
35
+ activation = await ctx.connectionProvider.getActivation(wf.metadata.activationId);
36
+ }
37
+ const newContext = ctx.contextProvider.create(data, {
38
+ activation: activation,
39
+ workflowId: wf.id,
40
+ });
41
+ subscriber.next(newContext);
42
+ }
43
+ }
44
+ catch (error) {
45
+ ctx.log.error('Error fetching workflows', { error });
46
+ }
47
+ }
48
+ })();
49
+ return () => {
50
+ signal.removeEventListener('abort', cleanup);
51
+ ctx.log.debug('durable workflow cleanup');
52
+ };
53
+ });
54
+ }
55
+ exports.durableWorkflowCompiler = {
56
+ ctor: DurableTrigger_js_1.DurableWorkflowTrigger,
57
+ compile: compileDurableWorkflow,
58
+ };
@@ -0,0 +1,4 @@
1
+ import { FnTask } from '../../../dsl/tasks/FnTask.js';
2
+ import { TaskCompiler } from './types.js';
3
+ export declare const fnCompiler: TaskCompiler<any, any, FnTask<any, any>>;
4
+ //# sourceMappingURL=fn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/fn.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AA4BnE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAG/D,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fnCompiler = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const FnTask_js_1 = require("../../../dsl/tasks/FnTask.js");
6
+ function compileFn(compilerCtx, task) {
7
+ return (src) => src.pipe((0, rxjs_1.tap)({
8
+ complete: () => compilerCtx.log.debug('fn.complete')
9
+ }), (0, rxjs_1.mergeMap)(async (ctx) => {
10
+ return await compilerCtx.tracer.startActiveSpan(`fn-${task.id}`, async (span) => {
11
+ span.setAttribute('task.id', task.id);
12
+ span.setAttribute('execution.id', ctx.executionId);
13
+ if (typeof ctx.idx === 'number') {
14
+ span.end();
15
+ return ctx.withData(await task._fn(ctx, ctx.idx));
16
+ }
17
+ span.end();
18
+ return ctx.withData(await task._fn(ctx));
19
+ });
20
+ }));
21
+ }
22
+ exports.fnCompiler = {
23
+ ctor: FnTask_js_1.FnTask,
24
+ compile: compileFn,
25
+ };
@@ -0,0 +1,4 @@
1
+ import { HttpTaskImpl } from '../../../dsl/tasks/HttpTask.js';
2
+ import { TaskCompiler } from './types.js';
3
+ export declare const httpCompiler: TaskCompiler<any, any, HttpTaskImpl<any, any, any>>;
4
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/http.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAyDnE,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAG5E,CAAC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.httpCompiler = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const HttpTask_js_1 = require("../../../dsl/tasks/HttpTask.js");
7
+ function compileHttp(compilerCtx, task) {
8
+ const roundtripper = compilerCtx.roundTripperFactory.create(task.opts.connection);
9
+ const dynamicFetcher = compilerCtx.roundTripperFactory.createDynamic(task.opts.connection);
10
+ async function http(ctx) {
11
+ const _fetch = await roundtripper;
12
+ const _dynamicFetcher = await dynamicFetcher;
13
+ const httpContext = new HttpTask_js_1.HttpContextImpl(ctx, {}, _fetch, _dynamicFetcher);
14
+ const result = await task.fn(httpContext);
15
+ return ctx.withData(result);
16
+ }
17
+ return (src) => src.pipe((0, operators_1.tap)({
18
+ complete: () => compilerCtx.log.debug('http.complete'),
19
+ }), (0, rxjs_1.mergeMap)(async (ctx) => {
20
+ return compilerCtx.tracer.startActiveSpan(`http-${task.id}`, async (span) => {
21
+ span.setAttribute('task.id', task.id);
22
+ span.setAttribute('task.type', 'http');
23
+ span.setAttribute('execution.id', ctx.executionId);
24
+ span.setAttribute('connection.name', task.opts.connection);
25
+ try {
26
+ let result = await http(ctx);
27
+ return result;
28
+ }
29
+ catch (error) {
30
+ if (error instanceof Error) {
31
+ span.recordException(error);
32
+ }
33
+ else {
34
+ span.recordException(new Error(String(error)));
35
+ }
36
+ throw error;
37
+ }
38
+ finally {
39
+ span.end();
40
+ }
41
+ });
42
+ }));
43
+ }
44
+ exports.httpCompiler = {
45
+ ctor: HttpTask_js_1.HttpTaskImpl,
46
+ compile: compileHttp,
47
+ };
@@ -0,0 +1,2 @@
1
+ export type * from './types.js';
2
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/mod.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ import { ParallelTask } from '../../../dsl/tasks/ParallelTask.js';
2
+ import { TaskCompiler } from './types.js';
3
+ export declare const parallelCompiler: TaskCompiler<any, any, ParallelTask<any, any, any, any>>;
4
+ //# sourceMappingURL=parallel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parallel.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/durable/compilers/parallel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAA2B,YAAY,EAAE,MAAM,YAAY,CAAC;AAqCnE,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAGrF,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parallelCompiler = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const ParallelTask_js_1 = require("../../../dsl/tasks/ParallelTask.js");
6
+ function compileParallel(ctx, task) {
7
+ const baseOperator = ctx.compiler.compileTask(ctx, task._base);
8
+ const eachOperator = ctx.compiler.compileTask(ctx, task._each);
9
+ return (src) => src.pipe(baseOperator, (0, rxjs_1.mergeMap)((ctx) => {
10
+ return (0, rxjs_1.from)(ctx.data).pipe((0, rxjs_1.map)((data, idx) => ctx.withData(data).setIndex(idx)),
11
+ // Process items in parallel using mergeMap
12
+ (0, rxjs_1.mergeMap)((item) => eachOperator((0, rxjs_1.of)(item)).pipe((0, rxjs_1.map)((result) => result.setIndex(item.idx)))), (0, rxjs_1.toArray)(), (0, rxjs_1.map)((results) => {
13
+ // Sort by original index to maintain order
14
+ results.sort((a, b) => a.idx - b.idx);
15
+ return ctx.withData(results.map((r) => r.data));
16
+ }));
17
+ }));
18
+ }
19
+ exports.parallelCompiler = {
20
+ ctor: ParallelTask_js_1.ParallelTask,
21
+ compile: compileParallel,
22
+ };
@@ -0,0 +1,4 @@
1
+ import { ScheduleData, ScheduleTrigger } from '../../../dsl/triggers/ScheduleTrigger.js';
2
+ import { TriggerCompiler } from './types.js';
3
+ export declare const scheduleCompiler: TriggerCompiler<ScheduleData, ScheduleTrigger>;
4
+ //# sourceMappingURL=schedule.d.ts.map