@versori/run 0.7.0-alpha.3 → 0.7.0-alpha.6

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 (175) hide show
  1. package/esm/mod.d.ts +1 -1
  2. package/esm/mod.d.ts.map +1 -1
  3. package/esm/mod.js +1 -1
  4. package/esm/src/connection/VanillaConnectionFactory.d.ts +16 -0
  5. package/esm/src/connection/VanillaConnectionFactory.d.ts.map +1 -0
  6. package/esm/src/connection/VanillaConnectionFactory.js +23 -0
  7. package/esm/src/context/ActivationImpl.d.ts +2 -1
  8. package/esm/src/context/ActivationImpl.d.ts.map +1 -1
  9. package/esm/src/context/Context.d.ts +4 -2
  10. package/esm/src/context/Context.d.ts.map +1 -1
  11. package/esm/src/context/ContextProvider.d.ts +6 -6
  12. package/esm/src/context/ContextProvider.d.ts.map +1 -1
  13. package/esm/src/context/VanillaContext.d.ts +60 -0
  14. package/esm/src/context/VanillaContext.d.ts.map +1 -0
  15. package/esm/src/context/VanillaContext.js +296 -0
  16. package/esm/src/dsl/http/mod.d.ts +1 -1
  17. package/esm/src/dsl/http/mod.d.ts.map +1 -1
  18. package/esm/src/dsl/http/types.d.ts +19 -134
  19. package/esm/src/dsl/http/types.d.ts.map +1 -1
  20. package/esm/src/dsl/http/versori/configloader.d.ts.map +1 -1
  21. package/esm/src/dsl/http/versori/configloader.js +3 -0
  22. package/esm/src/dsl/tasks/HttpTask.d.ts +5 -5
  23. package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
  24. package/esm/src/dsl/triggers/ScheduleTrigger.d.ts +2 -2
  25. package/esm/src/dsl/triggers/ScheduleTrigger.d.ts.map +1 -1
  26. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +2 -2
  27. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  28. package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  29. package/esm/src/interpreter/mod.d.ts +1 -0
  30. package/esm/src/interpreter/mod.d.ts.map +1 -1
  31. package/esm/src/interpreter/mod.js +1 -0
  32. package/esm/src/interpreter/vanilla/ExecutionError.d.ts +27 -0
  33. package/esm/src/interpreter/vanilla/ExecutionError.d.ts.map +1 -0
  34. package/esm/src/interpreter/vanilla/ExecutionError.js +48 -0
  35. package/esm/src/interpreter/vanilla/ObservableCompiler.d.ts +38 -0
  36. package/esm/src/interpreter/vanilla/ObservableCompiler.d.ts.map +1 -0
  37. package/esm/src/interpreter/vanilla/ObservableCompiler.js +95 -0
  38. package/esm/src/interpreter/vanilla/Queue.d.ts +72 -0
  39. package/esm/src/interpreter/vanilla/Queue.d.ts.map +1 -0
  40. package/esm/src/interpreter/vanilla/Queue.js +176 -0
  41. package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts +95 -0
  42. package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -0
  43. package/esm/src/interpreter/vanilla/VanillaInterpreter.js +428 -0
  44. package/esm/src/interpreter/vanilla/compilers/background.d.ts +4 -0
  45. package/esm/src/interpreter/vanilla/compilers/background.d.ts.map +1 -0
  46. package/esm/src/interpreter/vanilla/compilers/background.js +34 -0
  47. package/esm/src/interpreter/vanilla/compilers/catch.d.ts +4 -0
  48. package/esm/src/interpreter/vanilla/compilers/catch.d.ts.map +1 -0
  49. package/esm/src/interpreter/vanilla/compilers/catch.js +75 -0
  50. package/esm/src/interpreter/vanilla/compilers/chain.d.ts +3 -0
  51. package/esm/src/interpreter/vanilla/compilers/chain.d.ts.map +1 -0
  52. package/esm/src/interpreter/vanilla/compilers/chain.js +21 -0
  53. package/esm/src/interpreter/vanilla/compilers/durableworkflow.d.ts +8 -0
  54. package/esm/src/interpreter/vanilla/compilers/durableworkflow.d.ts.map +1 -0
  55. package/esm/src/interpreter/vanilla/compilers/durableworkflow.js +90 -0
  56. package/esm/src/interpreter/vanilla/compilers/fn.d.ts +4 -0
  57. package/esm/src/interpreter/vanilla/compilers/fn.d.ts.map +1 -0
  58. package/esm/src/interpreter/vanilla/compilers/fn.js +34 -0
  59. package/esm/src/interpreter/vanilla/compilers/http.d.ts +4 -0
  60. package/esm/src/interpreter/vanilla/compilers/http.d.ts.map +1 -0
  61. package/esm/src/interpreter/vanilla/compilers/http.js +54 -0
  62. package/esm/src/interpreter/vanilla/compilers/mod.d.ts +2 -0
  63. package/esm/src/interpreter/vanilla/compilers/mod.d.ts.map +1 -0
  64. package/esm/src/interpreter/vanilla/compilers/mod.js +13 -0
  65. package/esm/src/interpreter/vanilla/compilers/parallel.d.ts +4 -0
  66. package/esm/src/interpreter/vanilla/compilers/parallel.d.ts.map +1 -0
  67. package/esm/src/interpreter/vanilla/compilers/parallel.js +31 -0
  68. package/esm/src/interpreter/vanilla/compilers/schedule.d.ts +4 -0
  69. package/esm/src/interpreter/vanilla/compilers/schedule.d.ts.map +1 -0
  70. package/esm/src/interpreter/vanilla/compilers/schedule.js +76 -0
  71. package/esm/src/interpreter/vanilla/compilers/serial.d.ts +4 -0
  72. package/esm/src/interpreter/vanilla/compilers/serial.d.ts.map +1 -0
  73. package/esm/src/interpreter/vanilla/compilers/serial.js +28 -0
  74. package/esm/src/interpreter/vanilla/compilers/types.d.ts +15 -0
  75. package/esm/src/interpreter/vanilla/compilers/types.d.ts.map +1 -0
  76. package/esm/src/interpreter/vanilla/compilers/types.js +13 -0
  77. package/esm/src/interpreter/vanilla/compilers/unpack.d.ts +4 -0
  78. package/esm/src/interpreter/vanilla/compilers/unpack.d.ts.map +1 -0
  79. package/esm/src/interpreter/vanilla/compilers/unpack.js +34 -0
  80. package/esm/src/interpreter/vanilla/compilers/webhook.d.ts +4 -0
  81. package/esm/src/interpreter/vanilla/compilers/webhook.d.ts.map +1 -0
  82. package/esm/src/interpreter/vanilla/compilers/webhook.js +259 -0
  83. package/esm/src/interpreter/vanilla/mod.d.ts +3 -0
  84. package/esm/src/interpreter/vanilla/mod.d.ts.map +1 -0
  85. package/esm/src/interpreter/vanilla/mod.js +14 -0
  86. package/esm/src/issues/Issues.d.ts +1 -18
  87. package/esm/src/issues/Issues.d.ts.map +1 -1
  88. package/package.json +1 -1
  89. package/script/mod.d.ts +1 -1
  90. package/script/mod.d.ts.map +1 -1
  91. package/script/mod.js +2 -1
  92. package/script/src/connection/VanillaConnectionFactory.d.ts +16 -0
  93. package/script/src/connection/VanillaConnectionFactory.d.ts.map +1 -0
  94. package/script/src/connection/VanillaConnectionFactory.js +28 -0
  95. package/script/src/context/ActivationImpl.d.ts +2 -1
  96. package/script/src/context/ActivationImpl.d.ts.map +1 -1
  97. package/script/src/context/Context.d.ts +4 -2
  98. package/script/src/context/Context.d.ts.map +1 -1
  99. package/script/src/context/ContextProvider.d.ts +6 -6
  100. package/script/src/context/ContextProvider.d.ts.map +1 -1
  101. package/script/src/context/VanillaContext.d.ts +60 -0
  102. package/script/src/context/VanillaContext.d.ts.map +1 -0
  103. package/script/src/context/VanillaContext.js +302 -0
  104. package/script/src/dsl/http/mod.d.ts +1 -1
  105. package/script/src/dsl/http/mod.d.ts.map +1 -1
  106. package/script/src/dsl/http/types.d.ts +19 -134
  107. package/script/src/dsl/http/types.d.ts.map +1 -1
  108. package/script/src/dsl/http/versori/configloader.d.ts.map +1 -1
  109. package/script/src/dsl/http/versori/configloader.js +3 -0
  110. package/script/src/dsl/tasks/HttpTask.d.ts +5 -5
  111. package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
  112. package/script/src/dsl/triggers/ScheduleTrigger.d.ts +2 -2
  113. package/script/src/dsl/triggers/ScheduleTrigger.d.ts.map +1 -1
  114. package/script/src/interpreter/memory/MemoryInterpreter.d.ts +2 -2
  115. package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  116. package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  117. package/script/src/interpreter/mod.d.ts +1 -0
  118. package/script/src/interpreter/mod.d.ts.map +1 -1
  119. package/script/src/interpreter/mod.js +2 -1
  120. package/script/src/interpreter/vanilla/ExecutionError.d.ts +27 -0
  121. package/script/src/interpreter/vanilla/ExecutionError.d.ts.map +1 -0
  122. package/script/src/interpreter/vanilla/ExecutionError.js +52 -0
  123. package/script/src/interpreter/vanilla/ObservableCompiler.d.ts +38 -0
  124. package/script/src/interpreter/vanilla/ObservableCompiler.d.ts.map +1 -0
  125. package/script/src/interpreter/vanilla/ObservableCompiler.js +99 -0
  126. package/script/src/interpreter/vanilla/Queue.d.ts +72 -0
  127. package/script/src/interpreter/vanilla/Queue.d.ts.map +1 -0
  128. package/script/src/interpreter/vanilla/Queue.js +181 -0
  129. package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts +95 -0
  130. package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -0
  131. package/script/src/interpreter/vanilla/VanillaInterpreter.js +435 -0
  132. package/script/src/interpreter/vanilla/compilers/background.d.ts +4 -0
  133. package/script/src/interpreter/vanilla/compilers/background.d.ts.map +1 -0
  134. package/script/src/interpreter/vanilla/compilers/background.js +37 -0
  135. package/script/src/interpreter/vanilla/compilers/catch.d.ts +4 -0
  136. package/script/src/interpreter/vanilla/compilers/catch.d.ts.map +1 -0
  137. package/script/src/interpreter/vanilla/compilers/catch.js +78 -0
  138. package/script/src/interpreter/vanilla/compilers/chain.d.ts +3 -0
  139. package/script/src/interpreter/vanilla/compilers/chain.d.ts.map +1 -0
  140. package/script/src/interpreter/vanilla/compilers/chain.js +24 -0
  141. package/script/src/interpreter/vanilla/compilers/durableworkflow.d.ts +8 -0
  142. package/script/src/interpreter/vanilla/compilers/durableworkflow.d.ts.map +1 -0
  143. package/script/src/interpreter/vanilla/compilers/durableworkflow.js +94 -0
  144. package/script/src/interpreter/vanilla/compilers/fn.d.ts +4 -0
  145. package/script/src/interpreter/vanilla/compilers/fn.d.ts.map +1 -0
  146. package/script/src/interpreter/vanilla/compilers/fn.js +37 -0
  147. package/script/src/interpreter/vanilla/compilers/http.d.ts +4 -0
  148. package/script/src/interpreter/vanilla/compilers/http.d.ts.map +1 -0
  149. package/script/src/interpreter/vanilla/compilers/http.js +57 -0
  150. package/script/src/interpreter/vanilla/compilers/mod.d.ts +2 -0
  151. package/script/src/interpreter/vanilla/compilers/mod.d.ts.map +1 -0
  152. package/script/src/interpreter/vanilla/compilers/mod.js +14 -0
  153. package/script/src/interpreter/vanilla/compilers/parallel.d.ts +4 -0
  154. package/script/src/interpreter/vanilla/compilers/parallel.d.ts.map +1 -0
  155. package/script/src/interpreter/vanilla/compilers/parallel.js +34 -0
  156. package/script/src/interpreter/vanilla/compilers/schedule.d.ts +4 -0
  157. package/script/src/interpreter/vanilla/compilers/schedule.d.ts.map +1 -0
  158. package/script/src/interpreter/vanilla/compilers/schedule.js +79 -0
  159. package/script/src/interpreter/vanilla/compilers/serial.d.ts +4 -0
  160. package/script/src/interpreter/vanilla/compilers/serial.d.ts.map +1 -0
  161. package/script/src/interpreter/vanilla/compilers/serial.js +31 -0
  162. package/script/src/interpreter/vanilla/compilers/types.d.ts +15 -0
  163. package/script/src/interpreter/vanilla/compilers/types.d.ts.map +1 -0
  164. package/script/src/interpreter/vanilla/compilers/types.js +14 -0
  165. package/script/src/interpreter/vanilla/compilers/unpack.d.ts +4 -0
  166. package/script/src/interpreter/vanilla/compilers/unpack.d.ts.map +1 -0
  167. package/script/src/interpreter/vanilla/compilers/unpack.js +37 -0
  168. package/script/src/interpreter/vanilla/compilers/webhook.d.ts +4 -0
  169. package/script/src/interpreter/vanilla/compilers/webhook.d.ts.map +1 -0
  170. package/script/src/interpreter/vanilla/compilers/webhook.js +265 -0
  171. package/script/src/interpreter/vanilla/mod.d.ts +3 -0
  172. package/script/src/interpreter/vanilla/mod.d.ts.map +1 -0
  173. package/script/src/interpreter/vanilla/mod.js +30 -0
  174. package/script/src/issues/Issues.d.ts +1 -18
  175. package/script/src/issues/Issues.d.ts.map +1 -1
@@ -0,0 +1,72 @@
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
+ environmentId?: string;
15
+ group: string;
16
+ payload?: string;
17
+ output?: string;
18
+ status?: 'available' | 'locked' | 'completed' | 'failed';
19
+ attempt?: number;
20
+ maxAttempts?: number;
21
+ timeout?: string;
22
+ createdAt?: string;
23
+ metadata?: WorkflowMsgMetadata;
24
+ };
25
+ export type CompleteWorkflowRequest = {
26
+ id: string;
27
+ output?: string;
28
+ status: 'completed' | 'failed';
29
+ };
30
+ export type FetchWorkflowsRequest = {
31
+ ttl?: number;
32
+ limit?: number;
33
+ group: string;
34
+ projectId?: string;
35
+ environmentId?: string;
36
+ };
37
+ export type RescheduleWorkflowRequest = {
38
+ id: string;
39
+ after: string;
40
+ };
41
+ export type SubmitWorkflowsRequest = {
42
+ workflows: WorkflowMsg[];
43
+ };
44
+ export interface QueueAPI {
45
+ complete(request: CompleteWorkflowRequest): Promise<void>;
46
+ submit(request: SubmitWorkflowsRequest): Promise<Workflows>;
47
+ fetchWorkflows(request: FetchWorkflowsRequest): Promise<Workflows | undefined>;
48
+ reschedule(request: RescheduleWorkflowRequest): Promise<void>;
49
+ poll(workflowId: string): Promise<WorkflowMsg>;
50
+ }
51
+ export declare class QueueImpl implements QueueAPI {
52
+ private baseUrl;
53
+ private log;
54
+ private projectId;
55
+ private environmentId;
56
+ constructor(baseUrl: string, projectId: string, environmentId: string, log: Logger);
57
+ static fromEnv(log: Logger): QueueImpl;
58
+ complete(request: CompleteWorkflowRequest): Promise<void>;
59
+ submit(request: SubmitWorkflowsRequest): Promise<Workflows>;
60
+ fetchWorkflows(request: FetchWorkflowsRequest): Promise<Workflows | undefined>;
61
+ reschedule(request: RescheduleWorkflowRequest): Promise<void>;
62
+ poll(workflowId: string): Promise<WorkflowMsg>;
63
+ }
64
+ export declare class MockQueue implements QueueAPI {
65
+ constructor();
66
+ complete(_request: CompleteWorkflowRequest): Promise<void>;
67
+ submit(_request: SubmitWorkflowsRequest): Promise<Workflows>;
68
+ fetchWorkflows(_request: FetchWorkflowsRequest): Promise<Workflows | undefined>;
69
+ reschedule(_request: RescheduleWorkflowRequest): Promise<void>;
70
+ poll(_workflowId: string): Promise<WorkflowMsg>;
71
+ }
72
+ //# sourceMappingURL=Queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/vanilla/Queue.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,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,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,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,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,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,CAA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,QAAQ,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBzD,MAAM,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC;IA2B3D,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAoC9E,UAAU,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB7D,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAevD;AAGD,qBAAa,SAAU,YAAW,QAAQ;;IAGtC,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAG1D,MAAM,CAAC,QAAQ,EAAE,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC;IAG5D,cAAc,CAAC,QAAQ,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAG/E,UAAU,CAAC,QAAQ,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAG9D,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAGlD"}
@@ -0,0 +1,176 @@
1
+ /*
2
+ * Copyright (c) 2025 Versori Group Inc
3
+ *
4
+ * Use of this software is governed by the Business Source License 1.1
5
+ * included in the LICENSE file at the root of this repository.
6
+ *
7
+ * Change Date: 2029-01-01
8
+ * Change License: Apache License, Version 2.0
9
+ *
10
+ * As of the Change Date, in accordance with the Business Source License,
11
+ * use of this software will be governed by the Apache License, Version 2.0.
12
+ */
13
+ import { envVarEnvId, envVarProjectId, envVarSDKApiBaseURL, } from '../../dsl/http/versori/constants.js';
14
+ import { ConsoleLogger } from '../../mod.js';
15
+ export class QueueImpl {
16
+ constructor(baseUrl, projectId, environmentId, log) {
17
+ Object.defineProperty(this, "baseUrl", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ Object.defineProperty(this, "log", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+ Object.defineProperty(this, "projectId", {
30
+ enumerable: true,
31
+ configurable: true,
32
+ writable: true,
33
+ value: void 0
34
+ });
35
+ Object.defineProperty(this, "environmentId", {
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true,
39
+ value: void 0
40
+ });
41
+ this.baseUrl = baseUrl;
42
+ this.log = log;
43
+ this.projectId = projectId;
44
+ this.environmentId = environmentId;
45
+ }
46
+ static fromEnv(log) {
47
+ // TODO make these environment variables configurable in constants/ts
48
+ const baseUrl = Deno.env.get(envVarSDKApiBaseURL);
49
+ const _log = log || new ConsoleLogger('debug');
50
+ const projectId = Deno.env.get(envVarProjectId) || 'default-project';
51
+ const environmentId = Deno.env.get(envVarEnvId) || 'default-environment';
52
+ if (!baseUrl) {
53
+ throw new Error('Missing required environment variables');
54
+ }
55
+ return new QueueImpl(baseUrl, projectId, environmentId, _log);
56
+ }
57
+ async complete(request) {
58
+ const resp = await fetch(`${this.baseUrl}/v1/workflows/complete`, {
59
+ method: 'POST',
60
+ body: JSON.stringify({
61
+ id: request.id,
62
+ output: request.output,
63
+ status: request.status,
64
+ }),
65
+ });
66
+ if (!resp.ok) {
67
+ this.log.error('Failed to complete workflow', {
68
+ id: request.id,
69
+ output: request.output,
70
+ status: request.status,
71
+ });
72
+ throw new Error('Failed to complete workflow');
73
+ }
74
+ return;
75
+ }
76
+ async submit(request) {
77
+ // Ensure all workflows have the projectId & environmentId set
78
+ const workflows = request.workflows.map((w) => ({
79
+ ...w,
80
+ projectId: this.projectId || w.projectId,
81
+ environmentId: this.environmentId || w.environmentId,
82
+ }));
83
+ const resp = await fetch(`${this.baseUrl}/v1/workflows/submit`, {
84
+ method: 'POST',
85
+ body: JSON.stringify({
86
+ workflows: workflows,
87
+ }),
88
+ });
89
+ if (!resp.ok) {
90
+ this.log.error('Failed to submit workflows', {
91
+ workflows: workflows,
92
+ });
93
+ throw new Error('Failed to submit workflows');
94
+ }
95
+ const result = (await resp.json());
96
+ return result;
97
+ }
98
+ async fetchWorkflows(request) {
99
+ const resp = await fetch(`${this.baseUrl}/v1/workflows/fetch`, {
100
+ method: 'POST',
101
+ body: JSON.stringify({
102
+ ttl: request.ttl,
103
+ limit: request.limit,
104
+ group: request.group,
105
+ projectId: this.projectId || request.projectId,
106
+ environmentId: this.environmentId || request.environmentId,
107
+ }),
108
+ });
109
+ if (!resp.ok) {
110
+ const errorText = (await resp.json());
111
+ this.log.error('Failed to fetch workflows', {
112
+ error: errorText.message,
113
+ ttl: request.ttl,
114
+ limit: request.limit,
115
+ group: request.group,
116
+ projectId: this.projectId || request.projectId,
117
+ });
118
+ throw new Error('failed to fetch workflows', {
119
+ cause: new Error(errorText.message),
120
+ });
121
+ }
122
+ if (resp.status === 204) {
123
+ return undefined;
124
+ }
125
+ const result = (await resp.json());
126
+ return result;
127
+ }
128
+ async reschedule(request) {
129
+ const resp = await fetch(`${this.baseUrl}/v1/workflows/reschedule`, {
130
+ method: 'POST',
131
+ body: JSON.stringify({
132
+ id: request.id,
133
+ after: request.after,
134
+ }),
135
+ });
136
+ if (!resp.ok) {
137
+ this.log.error('Failed to reschedule workflow', {
138
+ id: request.id,
139
+ after: request.after,
140
+ });
141
+ throw new Error('Failed to reschedule workflow');
142
+ }
143
+ return;
144
+ }
145
+ async poll(workflowId) {
146
+ // this endpoint returns a 404 if the workflow is not completed
147
+ const resp = await fetch(`${this.baseUrl}/v1/workflows/fetch/${workflowId}`, {
148
+ method: 'GET',
149
+ });
150
+ if (!resp.ok) {
151
+ this.log.error('Failed to poll workflow', { workflowId });
152
+ throw new Error('Failed to poll workflow');
153
+ }
154
+ const result = (await resp.json());
155
+ return result;
156
+ }
157
+ }
158
+ // MockQueue can be used for testing. Right now it throws errors for all methods because it isn't used in tests yet.
159
+ export class MockQueue {
160
+ constructor() { }
161
+ complete(_request) {
162
+ throw new Error('Method not implemented.');
163
+ }
164
+ submit(_request) {
165
+ throw new Error('Method not implemented.');
166
+ }
167
+ fetchWorkflows(_request) {
168
+ throw new Error('Method not implemented.');
169
+ }
170
+ reschedule(_request) {
171
+ throw new Error('Method not implemented.');
172
+ }
173
+ poll(_workflowId) {
174
+ throw new Error('Method not implemented.');
175
+ }
176
+ }
@@ -0,0 +1,95 @@
1
+ import { Tracer } from '@opentelemetry/api';
2
+ import { NodeSDK } from '@opentelemetry/sdk-node';
3
+ import { Router } from 'express';
4
+ import { Observable, Subscription } from 'rxjs';
5
+ import { ConfigReader, CronProvider } from '../../dsl/http/types.js';
6
+ import { Workflow } from '../../dsl/Workflow.js';
7
+ import { Logger } from '../../observability/logging/Logger.js';
8
+ import { ContextOperatorFunction } from './compilers/types.js';
9
+ import { ObservableCompiler } from './ObservableCompiler.js';
10
+ import { QueueAPI } from './Queue.js';
11
+ import { DefaultConnectionFactory } from '../../connection/VanillaConnectionFactory.js';
12
+ import { VanillaContext, VanillaContextProvider } from '../../context/VanillaContext.js';
13
+ import { ContextProvider } from '../../context/ContextProvider.js';
14
+ /**
15
+ * VanillaInterpreterOptions
16
+ * configures the behavior of the {@link VanillaInterpreter}.
17
+ */
18
+ export type VanillaInterpreterOptions = {
19
+ /**
20
+ * Custom logger instance. Defaults to ConsoleLogger.
21
+ */
22
+ logger?: Logger;
23
+ /**
24
+ * Custom compiler for workflow execution. Advanced use only.
25
+ */
26
+ compiler?: ObservableCompiler;
27
+ /**
28
+ * Custom context provider. Advanced use only.
29
+ */
30
+ contextProvider?: VanillaContextProvider;
31
+ /**
32
+ * Abort signal to cancel workflow execution.
33
+ */
34
+ signal?: AbortSignal;
35
+ /**
36
+ * Skip loading Versori credentials. Useful for local development.
37
+ */
38
+ skipVersoriCredentials?: boolean;
39
+ };
40
+ type Registration = {
41
+ trigger$: Observable<VanillaContext<any, void>>;
42
+ task$: ContextOperatorFunction<any, any, any>;
43
+ localAbortController: AbortController;
44
+ sigintListener: () => void;
45
+ subscription?: Subscription;
46
+ };
47
+ /**
48
+ * VanillaInterpreter is an interpreter for executing Versori workflows with support for durable, queue-based workflow
49
+ * execution. It supports all trigger types including the {@link workflow} trigger which allows workflows to be started
50
+ * programmatically.
51
+ *
52
+ * Unlike {@link DurableInterpreter}, this interpreter is incapable of using connections. Therefore, all fetch requests will need
53
+ * to use fully qualified URLs and authentication must be handled manually within the workflow.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * import { VanillaInterpreter, workflow, fn } from '@versori/run';
58
+ *
59
+ * const processJob = workflow('process-job', { maxAttempts: 3 })
60
+ * .then(fn('task', async (ctx) => {
61
+ * ctx.log.info('Processing job', { data: ctx.data });
62
+ * // ... long-running process
63
+ * }));
64
+ *
65
+ * const interpreter = new VanillaInterpreter();
66
+ * interpreter.register(processJob);
67
+ * await interpreter.start();
68
+ * ```
69
+ */
70
+ export declare class VanillaInterpreter {
71
+ private readonly log;
72
+ private readonly compiler;
73
+ private readonly contextProvider;
74
+ private readonly webhookRouter;
75
+ private readonly cronRouter;
76
+ private readonly cronRegistry;
77
+ private readonly cnxFetchFactory;
78
+ private readonly cronProvider;
79
+ private readonly tracer;
80
+ private readonly cfgReader;
81
+ private readonly queueProvider;
82
+ private readonly otelSDK?;
83
+ private registeredWorkflows;
84
+ private webhookServer?;
85
+ private cronServer?;
86
+ private shutdownServer?;
87
+ private isShuttingDown;
88
+ constructor(log: Logger, compiler: ObservableCompiler, contextProvider: ContextProvider, webhookRouter: Router, cronRouter: Router, cronRegistry: Map<string, string>, cnxFetchFactory: DefaultConnectionFactory, cronProvider: CronProvider, tracer: Tracer, cfgReader: ConfigReader, queueProvider: QueueAPI, otelSDK?: NodeSDK | undefined);
89
+ static newInstance(options?: VanillaInterpreterOptions): Promise<VanillaInterpreter>;
90
+ register<O>(workflow: Workflow<O>, options?: VanillaInterpreterOptions): Registration;
91
+ start(): Promise<void>;
92
+ stop(): Promise<void>;
93
+ }
94
+ export {};
95
+ //# sourceMappingURL=VanillaInterpreter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VanillaInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/vanilla/VanillaInterpreter.ts"],"names":[],"mappings":"AAaA,OAAsB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,EAA+B,UAAU,EAAM,YAAY,EAAO,MAAM,MAAM,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAarE,OAAO,EAAE,QAAQ,EAAgB,MAAM,uBAAuB,CAAC;AAM/D,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAA0B,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAa,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACpC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAE9B;;OAEG;IACH,eAAe,CAAC,EAAE,sBAAsB,CAAC;IAEzC;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,KAAK,YAAY,GAAG;IAChB,QAAQ,EAAE,UAAU,CAAC,cAAc,CAAC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