@versori/run 0.2.14 → 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 (151) 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/mod.d.ts +1 -0
  74. package/esm/src/interpreter/mod.d.ts.map +1 -1
  75. package/esm/src/interpreter/mod.js +1 -0
  76. package/package.json +1 -1
  77. package/script/src/context/AsyncWorkflow.d.ts +14 -0
  78. package/script/src/context/AsyncWorkflow.d.ts.map +1 -0
  79. package/script/src/context/AsyncWorkflow.js +93 -0
  80. package/script/src/context/Context.d.ts +12 -1
  81. package/script/src/context/Context.d.ts.map +1 -1
  82. package/script/src/context/Context.js +43 -4
  83. package/script/src/context/ContextProvider.d.ts +3 -1
  84. package/script/src/context/ContextProvider.d.ts.map +1 -1
  85. package/script/src/context/ContextProvider.js +9 -2
  86. package/script/src/dsl/http/versori/constants.d.ts +1 -0
  87. package/script/src/dsl/http/versori/constants.d.ts.map +1 -1
  88. package/script/src/dsl/http/versori/constants.js +2 -1
  89. package/script/src/dsl/triggers/DurableTrigger.d.ts +17 -0
  90. package/script/src/dsl/triggers/DurableTrigger.d.ts.map +1 -0
  91. package/script/src/dsl/triggers/DurableTrigger.js +41 -0
  92. package/script/src/dsl/triggers/mod.d.ts +1 -0
  93. package/script/src/dsl/triggers/mod.d.ts.map +1 -1
  94. package/script/src/dsl/triggers/mod.js +3 -1
  95. package/script/src/interpreter/durable/DurableInterpreter.d.ts +52 -0
  96. package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -0
  97. package/script/src/interpreter/durable/DurableInterpreter.js +440 -0
  98. package/script/src/interpreter/durable/ExecutionError.d.ts +6 -0
  99. package/script/src/interpreter/durable/ExecutionError.d.ts.map +1 -0
  100. package/script/src/interpreter/durable/ExecutionError.js +17 -0
  101. package/script/src/interpreter/durable/ObservableCompiler.d.ts +35 -0
  102. package/script/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -0
  103. package/script/src/interpreter/durable/ObservableCompiler.js +73 -0
  104. package/script/src/interpreter/durable/Queue.d.ts +60 -0
  105. package/script/src/interpreter/durable/Queue.d.ts.map +1 -0
  106. package/script/src/interpreter/durable/Queue.js +135 -0
  107. package/script/src/interpreter/durable/compilers/background.d.ts +4 -0
  108. package/script/src/interpreter/durable/compilers/background.d.ts.map +1 -0
  109. package/script/src/interpreter/durable/compilers/background.js +25 -0
  110. package/script/src/interpreter/durable/compilers/catch.d.ts +4 -0
  111. package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -0
  112. package/script/src/interpreter/durable/compilers/catch.js +39 -0
  113. package/script/src/interpreter/durable/compilers/chain.d.ts +3 -0
  114. package/script/src/interpreter/durable/compilers/chain.d.ts.map +1 -0
  115. package/script/src/interpreter/durable/compilers/chain.js +12 -0
  116. package/script/src/interpreter/durable/compilers/durableworkflow.d.ts +8 -0
  117. package/script/src/interpreter/durable/compilers/durableworkflow.d.ts.map +1 -0
  118. package/script/src/interpreter/durable/compilers/durableworkflow.js +58 -0
  119. package/script/src/interpreter/durable/compilers/fn.d.ts +4 -0
  120. package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -0
  121. package/script/src/interpreter/durable/compilers/fn.js +25 -0
  122. package/script/src/interpreter/durable/compilers/http.d.ts +4 -0
  123. package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -0
  124. package/script/src/interpreter/durable/compilers/http.js +47 -0
  125. package/script/src/interpreter/durable/compilers/mod.d.ts +2 -0
  126. package/script/src/interpreter/durable/compilers/mod.d.ts.map +1 -0
  127. package/script/src/interpreter/durable/compilers/mod.js +2 -0
  128. package/script/src/interpreter/durable/compilers/parallel.d.ts +4 -0
  129. package/script/src/interpreter/durable/compilers/parallel.d.ts.map +1 -0
  130. package/script/src/interpreter/durable/compilers/parallel.js +22 -0
  131. package/script/src/interpreter/durable/compilers/schedule.d.ts +4 -0
  132. package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -0
  133. package/script/src/interpreter/durable/compilers/schedule.js +97 -0
  134. package/script/src/interpreter/durable/compilers/serial.d.ts +4 -0
  135. package/script/src/interpreter/durable/compilers/serial.d.ts.map +1 -0
  136. package/script/src/interpreter/durable/compilers/serial.js +19 -0
  137. package/script/src/interpreter/durable/compilers/types.d.ts +15 -0
  138. package/script/src/interpreter/durable/compilers/types.d.ts.map +1 -0
  139. package/script/src/interpreter/durable/compilers/types.js +2 -0
  140. package/script/src/interpreter/durable/compilers/unpack.d.ts +4 -0
  141. package/script/src/interpreter/durable/compilers/unpack.d.ts.map +1 -0
  142. package/script/src/interpreter/durable/compilers/unpack.js +25 -0
  143. package/script/src/interpreter/durable/compilers/webhook.d.ts +4 -0
  144. package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -0
  145. package/script/src/interpreter/durable/compilers/webhook.js +254 -0
  146. package/script/src/interpreter/durable/mod.d.ts +5 -0
  147. package/script/src/interpreter/durable/mod.d.ts.map +1 -0
  148. package/script/src/interpreter/durable/mod.js +20 -0
  149. package/script/src/interpreter/mod.d.ts +1 -0
  150. package/script/src/interpreter/mod.d.ts.map +1 -1
  151. package/script/src/interpreter/mod.js +14 -0
@@ -0,0 +1,248 @@
1
+ import cors from 'cors';
2
+ import { pipeline } from 'node:stream/promises';
3
+ import { Observable } from 'rxjs';
4
+ import { WebhookTrigger } from '../../../dsl/triggers/WebhookTrigger.js';
5
+ import { createActIdDynamicWebhookMiddleware, createStaticWebhookMiddleware, createUserIdDynamicWebhookMiddleware } from '../../../dsl/http/versori/webhookmiddleware.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
+ });
40
+ export const webhookCompiler = {
41
+ ctor: WebhookTrigger,
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
+ });
69
+ return new Observable((subscriber) => {
70
+ if (!ctx.webhookRouter) {
71
+ throw new Error('Router not available in compiler context');
72
+ }
73
+ // add the webhook endpoint to the router
74
+ ctx.log.info('webhook endpoint added:', { trigger });
75
+ if (corsOptions) {
76
+ if (typeof corsOptions === 'boolean') {
77
+ ctx.webhookRouter.use(cors());
78
+ }
79
+ else {
80
+ ctx.webhookRouter.use(cors(corsOptions));
81
+ }
82
+ }
83
+ // endpoint for sans user because I'm not quite sure how the dynamic routing works
84
+ ctx.webhookRouter.post(`/${trigger.id}`, createStaticWebhookMiddleware({
85
+ id: trigger.id,
86
+ connName: trigger.options.connection,
87
+ credentials: ctx.roundTripperFactory.credentials(),
88
+ cnxProvider: ctx.connectionProvider,
89
+ cfgReader: ctx.configReader,
90
+ log: ctx.log,
91
+ }), async (req, res) => {
92
+ await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
93
+ span.setAttribute('task.id', trigger.id);
94
+ span.setAttribute('task.type', 'webhook');
95
+ let executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
96
+ const staticActivation = res.locals.activation;
97
+ if (staticActivation) {
98
+ executionCtx = executionCtx.withActivation(staticActivation);
99
+ }
100
+ span.setAttribute('execution.id', executionCtx.executionId);
101
+ try {
102
+ subscriber.next(executionCtx);
103
+ if (isAsync) {
104
+ sendResponse(res, onSuccess(executionCtx));
105
+ }
106
+ }
107
+ catch (error) {
108
+ executionCtx.log.error('webhook execution error', {
109
+ error: JSON.stringify(error),
110
+ });
111
+ if (isAsync) {
112
+ sendResponse(res, onError(executionCtx.withData(error)));
113
+ }
114
+ }
115
+ finally {
116
+ span.end();
117
+ }
118
+ });
119
+ });
120
+ // this endpoint will trigger the workflow for each activation given by the external user ID
121
+ ctx.webhookRouter.post(`/${trigger.id}/users/:userId`, createUserIdDynamicWebhookMiddleware({
122
+ id: trigger.id,
123
+ connName: trigger.options.connection,
124
+ credentials: ctx.roundTripperFactory.credentials(),
125
+ cnxProvider: ctx.connectionProvider,
126
+ cfgReader: ctx.configReader,
127
+ log: ctx.log,
128
+ }), async (req, res) => {
129
+ await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
130
+ span.setAttribute('task.id', trigger.id);
131
+ span.setAttribute('task.type', 'webhook');
132
+ span.setAttribute('user.id', req.params.userId);
133
+ const userId = req.params.userId;
134
+ const activation = res.locals.activation;
135
+ const activations = [activation];
136
+ // Right now we only support a user having one activation
137
+ // so this will need changing when we support multiple activations per user
138
+ // as will the middleware
139
+ if (!activations || activations.length === 0) {
140
+ res.status(404).json({
141
+ status: 'error',
142
+ message: `No activations found for user: ${userId}`,
143
+ });
144
+ span.setAttribute('error.message', `No activations found for user: ${userId}`);
145
+ span.setAttribute('http.status_code', '404');
146
+ span.end();
147
+ return;
148
+ }
149
+ const executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
150
+ span.setAttribute('execution.id', executionCtx.executionId);
151
+ const errors = [];
152
+ activations.forEach((activation) => {
153
+ const activationCtx = executionCtx.withActivation(activation);
154
+ try {
155
+ subscriber.next(activationCtx);
156
+ }
157
+ catch (error) {
158
+ activationCtx.log.error('webhook execution error', {
159
+ error: JSON.stringify(error),
160
+ });
161
+ errors.push({
162
+ activationId: activation.id,
163
+ error,
164
+ });
165
+ }
166
+ });
167
+ if (isAsync) {
168
+ if (errors.length === 0) {
169
+ sendResponse(res, onSuccess(executionCtx));
170
+ }
171
+ else {
172
+ sendResponse(res, onError(executionCtx.withData(errors)));
173
+ }
174
+ }
175
+ span.end();
176
+ });
177
+ });
178
+ // this endpoint will trigger the workflow only for the activation given by its ID
179
+ ctx.webhookRouter.post(`/${trigger.id}/activations/:activationId`, createActIdDynamicWebhookMiddleware({
180
+ id: trigger.id,
181
+ connName: trigger.options.connection,
182
+ credentials: ctx.roundTripperFactory.credentials(),
183
+ cnxProvider: ctx.connectionProvider,
184
+ cfgReader: ctx.configReader,
185
+ log: ctx.log,
186
+ }), async (req, res) => {
187
+ await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
188
+ span.setAttribute('task.id', trigger.id);
189
+ span.setAttribute('task.type', 'webhook');
190
+ span.setAttribute('activation.id', req.params.activationId);
191
+ const activation = res.locals.activation;
192
+ const activationId = activation.id || req.params.activationId;
193
+ if (!activation) {
194
+ // TODO report back actual errors
195
+ res.status(404).json({
196
+ status: 'error',
197
+ message: `No activation found for ID: ${activationId}`,
198
+ });
199
+ span.setAttribute('error.message', `No activation found for ID: ${activationId}`);
200
+ span.setAttribute('http.status_code', '404');
201
+ span.end();
202
+ return;
203
+ }
204
+ const activationCtx = ctx.contextProvider.create(req.body, {
205
+ ...ctxOptionsFn(res),
206
+ activation,
207
+ });
208
+ span.setAttribute('execution.id', activationCtx.executionId);
209
+ try {
210
+ subscriber.next(activationCtx);
211
+ if (isAsync) {
212
+ sendResponse(res, onSuccess(activationCtx));
213
+ }
214
+ }
215
+ catch (error) {
216
+ activationCtx.log.error('webhook execution error', {
217
+ error: JSON.stringify(error),
218
+ });
219
+ if (isAsync) {
220
+ sendResponse(res, onError(activationCtx.withData(error)));
221
+ }
222
+ }
223
+ finally {
224
+ span.end();
225
+ }
226
+ });
227
+ });
228
+ function cleanup() {
229
+ ctx.log.debug('webhook trigger stopped');
230
+ subscriber.complete();
231
+ }
232
+ signal.addEventListener('abort', cleanup, { once: true });
233
+ return () => {
234
+ signal.removeEventListener('abort', cleanup);
235
+ ctx.log.debug('webhook execution unsubscribed');
236
+ };
237
+ });
238
+ },
239
+ };
240
+ function sendResponse(res, response) {
241
+ res.status(response.status);
242
+ response.headers.forEach((value, key) => {
243
+ res.setHeader(key, value);
244
+ });
245
+ if (response.body) {
246
+ pipeline(response.body, res);
247
+ }
248
+ }
@@ -0,0 +1,5 @@
1
+ export * from './DurableInterpreter.js';
2
+ export * from './ObservableCompiler.js';
3
+ export * from './ExecutionError.js';
4
+ export * from './compilers/mod.js';
5
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/mod.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './DurableInterpreter.js';
2
+ export * from './ObservableCompiler.js';
3
+ export * from './ExecutionError.js';
4
+ export * from './compilers/mod.js';
@@ -1,2 +1,3 @@
1
1
  export * from './memory/mod.js';
2
+ export * as durable from './durable/mod.js';
2
3
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/interpreter/mod.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/interpreter/mod.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC"}
@@ -1 +1,2 @@
1
1
  export * from './memory/mod.js';
2
+ export * as durable from './durable/mod.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versori/run",
3
- "version": "v0.2.14",
3
+ "version": "v0.2.15",
4
4
  "description": "Versori Run",
5
5
  "homepage": "https://github.com/versori/versori-run#readme",
6
6
  "repository": {
@@ -0,0 +1,14 @@
1
+ import { QueueAPI } from '../interpreter/durable/Queue.js';
2
+ export declare class AsyncWorkflow {
3
+ private workflowId;
4
+ private queue;
5
+ private data;
6
+ private dataRaw;
7
+ private isWaiting;
8
+ private isCompleted;
9
+ constructor(queue: QueueAPI, workflowId: string);
10
+ wait(maxWait?: number): Promise<void>;
11
+ getData(): Promise<unknown | undefined>;
12
+ getDataRaw(): Promise<string | undefined>;
13
+ }
14
+ //# sourceMappingURL=AsyncWorkflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AsyncWorkflow.d.ts","sourceRoot":"","sources":["../../../src/src/context/AsyncWorkflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,qBAAa,aAAa;IACtB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,IAAI,CAAsB;IAClC,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,WAAW,CAAkB;gBAEzB,KAAK,EAAE,QAAQ,EAAC,UAAU,EAAE,MAAM;IASxC,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsCrC,OAAO,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAQvC,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAMlD"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AsyncWorkflow = void 0;
4
+ class AsyncWorkflow {
5
+ constructor(queue, workflowId) {
6
+ Object.defineProperty(this, "workflowId", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: void 0
11
+ });
12
+ Object.defineProperty(this, "queue", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: void 0
17
+ });
18
+ Object.defineProperty(this, "data", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: void 0
23
+ });
24
+ Object.defineProperty(this, "dataRaw", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: void 0
29
+ });
30
+ Object.defineProperty(this, "isWaiting", {
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true,
34
+ value: false
35
+ });
36
+ Object.defineProperty(this, "isCompleted", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: false
41
+ });
42
+ this.queue = queue;
43
+ this.workflowId = workflowId;
44
+ }
45
+ // wait will wait for the workflow to complete by polling the queue
46
+ // If maxWait is provided (in milliseconds), it will wait for that long before giving up
47
+ // If the workflow is already completed, it will return immediately.
48
+ // Throws an error if already waiting or if the wait times out.
49
+ async wait(maxWait) {
50
+ if (this.isWaiting) {
51
+ return Promise.reject(new Error('already waiting for workflow to complete'));
52
+ }
53
+ if (this.isCompleted) {
54
+ return;
55
+ }
56
+ this.isWaiting = true;
57
+ const start = Date.now();
58
+ while (true && !this.isCompleted) {
59
+ if (maxWait !== undefined && Date.now() - start >= maxWait) {
60
+ this.isWaiting = false;
61
+ throw new Error('wait timed out');
62
+ }
63
+ const workflow = await this.queue.poll(this.workflowId);
64
+ if (workflow.status === 'completed') {
65
+ // workflow is completed, parse the output and set the data and completed to true
66
+ const stringData = workflow.output;
67
+ if (stringData) {
68
+ this.data = JSON.parse(atob(stringData));
69
+ this.dataRaw = workflow.output;
70
+ }
71
+ this.isWaiting = false;
72
+ this.isCompleted = true;
73
+ return;
74
+ }
75
+ await new Promise(resolve => setTimeout(resolve, 1000));
76
+ }
77
+ }
78
+ // getData returns the data as D type, which is JSON parsed
79
+ async getData() {
80
+ if (!this.isWaiting) {
81
+ await this.wait();
82
+ }
83
+ return this.data;
84
+ }
85
+ // getDataRaw returns the raw data as base64 encoded string
86
+ async getDataRaw() {
87
+ if (!this.isWaiting) {
88
+ await this.wait();
89
+ }
90
+ return this.dataRaw;
91
+ }
92
+ }
93
+ exports.AsyncWorkflow = AsyncWorkflow;
@@ -1,14 +1,21 @@
1
1
  import { Activation } from '../dsl/http/types.js';
2
2
  import { CredentialsProvider } from '../dsl/http/versori/contextcredentials.js';
3
+ import { QueueAPI } from '../interpreter/durable/Queue.js';
3
4
  import { KeyValue, KeyValueProvider, KeyValueScope } from '../kv/KeyValue.js';
4
5
  import { Logger } from '../observability/logging/Logger.js';
6
+ import { AsyncWorkflow } from './AsyncWorkflow.js';
5
7
  export type OnSuccessFn = (ctx: Context<any>) => void;
6
8
  export type OnErrorFn = (ctx: Context<any>) => void;
7
9
  export type ContextOptions = {
8
10
  activation?: Activation;
11
+ workflowId?: string;
9
12
  onSuccess?: OnSuccessFn;
10
13
  onError?: OnErrorFn;
11
14
  };
15
+ export type WorkflowOpts = {
16
+ data?: unknown;
17
+ dataRaw?: string;
18
+ };
12
19
  export interface Context<D> {
13
20
  readonly log: Logger;
14
21
  readonly executionId: string;
@@ -20,6 +27,7 @@ export interface Context<D> {
20
27
  * @param scope
21
28
  */
22
29
  openKv(scope?: KeyValueScope): KeyValue;
30
+ start(workflowId: string, workflowOpts: WorkflowOpts): Promise<AsyncWorkflow>;
23
31
  credentials(): CredentialsProvider;
24
32
  }
25
33
  export declare class ContextImpl<D, Index = void> implements Context<D> {
@@ -30,13 +38,16 @@ export declare class ContextImpl<D, Index = void> implements Context<D> {
30
38
  readonly data: D;
31
39
  idx: Index;
32
40
  readonly kvp: KeyValueProvider;
41
+ readonly queue?: QueueAPI;
33
42
  readonly options: ContextOptions;
34
- constructor(log: Logger, kvp: KeyValueProvider, creds: CredentialsProvider, executionId: string, startTime: Date, data: D, options?: ContextOptions);
43
+ constructor(log: Logger, kvp: KeyValueProvider, creds: CredentialsProvider, executionId: string, startTime: Date, data: D, queue?: QueueAPI, options?: ContextOptions);
35
44
  get activation(): Activation | undefined;
45
+ get workflowId(): string | undefined;
36
46
  setIndex(idx: number): ContextImpl<D, number>;
37
47
  withActivation(activation: Activation): ContextImpl<D, Index>;
38
48
  withData<D2>(data: D2): ContextImpl<D2, Index>;
39
49
  openKv(scope?: KeyValueScope): KeyValue;
50
+ start(group: string, opts: WorkflowOpts): Promise<AsyncWorkflow>;
40
51
  credentials(): CredentialsProvider;
41
52
  destroy(scope: KeyValueScope): Promise<void>;
42
53
  [Symbol.toPrimitive](): Record<string, unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/src/context/Context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAE5D,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;AACtD,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;AAEpD,MAAM,MAAM,cAAc,GAAG;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,OAAO,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,MAAM,WAAW,OAAO,CAAC,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAEjB,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,QAAQ,CAAC;IAExC,WAAW,IAAI,mBAAmB,CAAC;CACtC;AAED,qB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C,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAQlD"}
@@ -13,8 +13,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  var _ContextImpl_creds;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.ContextImpl = void 0;
16
+ const AsyncWorkflow_js_1 = require("./AsyncWorkflow.js");
16
17
  class ContextImpl {
17
- constructor(log, kvp, creds, executionId, startTime, data, options = {}) {
18
+ constructor(log, kvp, creds, executionId, startTime, data, queue, options = {}) {
18
19
  Object.defineProperty(this, "log", {
19
20
  enumerable: true,
20
21
  configurable: true,
@@ -51,6 +52,12 @@ class ContextImpl {
51
52
  writable: true,
52
53
  value: void 0
53
54
  });
55
+ Object.defineProperty(this, "queue", {
56
+ enumerable: true,
57
+ configurable: true,
58
+ writable: true,
59
+ value: void 0
60
+ }); // Optional, can be used for durable workflows
54
61
  Object.defineProperty(this, "options", {
55
62
  enumerable: true,
56
63
  configurable: true,
@@ -66,17 +73,22 @@ class ContextImpl {
66
73
  this.idx = void 0;
67
74
  this.kvp = kvp;
68
75
  this.options = options;
76
+ this.queue = queue;
69
77
  // all methods on ContextImpl which are exposed via the Context interface need to be bound
70
78
  // so that destructuring the context object doesn't break the binding of the methods to the
71
79
  // correct instance.
72
80
  this.openKv = this.openKv.bind(this);
73
81
  this.credentials = this.credentials.bind(this);
82
+ this.start = this.start.bind(this);
74
83
  }
75
84
  get activation() {
76
85
  return this.options.activation;
77
86
  }
87
+ get workflowId() {
88
+ return this.options.workflowId;
89
+ }
78
90
  setIndex(idx) {
79
- const next = new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, this.data, this.options);
91
+ const next = new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, this.data, this.queue, this.options);
80
92
  next.idx = idx;
81
93
  return next;
82
94
  }
@@ -85,13 +97,13 @@ class ContextImpl {
85
97
  if (this.activation) {
86
98
  throw new Error('Activation is already set');
87
99
  }
88
- return new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, this.data, {
100
+ return new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, this.data, this.queue, {
89
101
  ...this.options,
90
102
  activation,
91
103
  });
92
104
  }
93
105
  withData(data) {
94
- return new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, data, this.options);
106
+ return new ContextImpl(this.log, this.kvp, __classPrivateFieldGet(this, _ContextImpl_creds, "f"), this.executionId, this.startTime, data, this.queue, this.options);
95
107
  }
96
108
  openKv(scope = ':project:') {
97
109
  if (scope === ':execution:') {
@@ -106,6 +118,33 @@ class ContextImpl {
106
118
  activationId: this.activation?.id,
107
119
  });
108
120
  }
121
+ async start(group, opts) {
122
+ // this makes a post request to the endpoint sending a message and schedule the workflow to run
123
+ if (!this.queue) {
124
+ throw new Error('Queue is not available for this context, cannot start workflow');
125
+ }
126
+ let payload;
127
+ if (opts.data) {
128
+ payload = opts.data ? btoa(JSON.stringify(opts.data)) : undefined;
129
+ }
130
+ else if (opts.dataRaw) {
131
+ payload = opts.dataRaw; // Assume this is already base64 encoded
132
+ }
133
+ const resp = await this.queue.submit({
134
+ workflows: [
135
+ {
136
+ group,
137
+ metadata: {
138
+ executionId: this.executionId,
139
+ activationId: this.activation?.id,
140
+ userId: this.activation?.user.externalId,
141
+ },
142
+ payload,
143
+ }
144
+ ]
145
+ });
146
+ return new AsyncWorkflow_js_1.AsyncWorkflow(this.queue, resp.workflows[0].id ?? 'unknown');
147
+ }
109
148
  credentials() {
110
149
  return {
111
150
  getRaw: (name) => __classPrivateFieldGet(this, _ContextImpl_creds, "f").getRaw(name, this.activation?.id || undefined),
@@ -2,6 +2,7 @@ import { KeyValueProvider } from '../kv/KeyValue.js';
2
2
  import { Logger } from '../observability/logging/Logger.js';
3
3
  import { Context, ContextImpl, ContextOptions } from './Context.js';
4
4
  import { CredentialsProvider } from '../dsl/http/versori/contextcredentials.js';
5
+ import { QueueAPI } from '../interpreter/durable/Queue.js';
5
6
  export interface ContextProvider {
6
7
  create<D>(data: D, options?: ContextOptions): ContextImpl<D, void>;
7
8
  destroy(ctx: Context<any>): Promise<void>;
@@ -10,7 +11,8 @@ export declare class ContextProviderImpl implements ContextProvider {
10
11
  log: Logger;
11
12
  kvp: KeyValueProvider;
12
13
  creds: CredentialsProvider;
13
- constructor(log: Logger, kvp: KeyValueProvider, creds: CredentialsProvider);
14
+ queue?: QueueAPI;
15
+ constructor(log: Logger, kvp: KeyValueProvider, creds: CredentialsProvider, queue: QueueAPI | undefined);
14
16
  create<D>(data: D, options?: ContextOptions): ContextImpl<D>;
15
17
  destroy(ctx: Context<any>): Promise<void>;
16
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ContextProvider.d.ts","sourceRoot":"","sources":["../../../src/src/context/ContextProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAEhF,MAAM,WAAW,eAAe;IAC5B,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACnE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C;AAED,qBAAa,mBAAoB,YAAW,eAAe;IACvD,GAAG,EAAE,MAAM,CAAC;IACZ,G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AOvG,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,GAAE,cAAmB,GAAG,WAAW,CAAC,CAAC,CAAC;IAehE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAM5C"}
@@ -4,7 +4,7 @@ exports.ContextProviderImpl = void 0;
4
4
  const mod_js_1 = require("../../deps/jsr.io/@std/ulid/1.0.0/mod.js");
5
5
  const Context_js_1 = require("./Context.js");
6
6
  class ContextProviderImpl {
7
- constructor(log, kvp, creds) {
7
+ constructor(log, kvp, creds, queue) {
8
8
  Object.defineProperty(this, "log", {
9
9
  enumerable: true,
10
10
  configurable: true,
@@ -23,9 +23,16 @@ class ContextProviderImpl {
23
23
  writable: true,
24
24
  value: void 0
25
25
  });
26
+ Object.defineProperty(this, "queue", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: void 0
31
+ });
26
32
  this.log = log;
27
33
  this.kvp = kvp;
28
34
  this.creds = creds;
35
+ this.queue = queue;
29
36
  }
30
37
  create(data, options = {}) {
31
38
  const executionId = (0, mod_js_1.ulid)();
@@ -36,7 +43,7 @@ class ContextProviderImpl {
36
43
  externalUserId: options.activation.user.externalId,
37
44
  });
38
45
  }
39
- return new Context_js_1.ContextImpl(logger, this.kvp, this.creds, executionId, new Date(), data, options);
46
+ return new Context_js_1.ContextImpl(logger, this.kvp, this.creds, executionId, new Date(), data, this.queue, options);
40
47
  }
41
48
  destroy(ctx) {
42
49
  return this.kvp.destroy({
@@ -5,6 +5,7 @@ export declare const envVarProjectId = "RUN_SERVICE_ID";
5
5
  export declare const envVarOrgSlug = "RUN_ORGANISATION_SLUG";
6
6
  export declare const envVarPlatformApiBaseURL = "RUN_PLATFORM_API_INTERNAL_URL";
7
7
  export declare const envVarCronApiBaseURL = "RUN_CRON_API_INTERNAL_URL";
8
+ export declare const envVarWorkflowApiBaseURL = "RUN_SDK_API_URL";
8
9
  export declare const envVarSelfRefURL = "RUN_SELF_REF_URL";
9
10
  export declare const envVarCredsBaseURL = "RUN_CREDENTIALS_SERVICE_INTERNAL_URL";
10
11
  export declare const envVarOtelTracesURL = "RUN_OTEL_TRACES_URL";
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,wBAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAChD,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AACrD,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AACxE,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,aAAa,wBAAwB,CAAC;AAEnD,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAGlD,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AACxD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AAGxD,eAAO,MAAM,cAAc,cAAc,CAAC;AAI1C,eAAO,MAAM,QAAQ,OAAO,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,wBAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAChD,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AACrD,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AACxE,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAC1D,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,aAAa,wBAAwB,CAAC;AAEnD,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAGlD,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AACxD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AAGxD,eAAO,MAAM,cAAc,cAAc,CAAC;AAI1C,eAAO,MAAM,QAAQ,OAAO,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cronPort = exports.envVarLocalRun = exports.envVarInternalToken = exports.envVarTokenEndpoint = exports.envVarClientSecret = exports.envVarClientId = exports.envVarConfigFile = exports.envVarVersion = exports.envVarOtelTracesURL = exports.envVarCredsBaseURL = exports.envVarSelfRefURL = exports.envVarCronApiBaseURL = exports.envVarPlatformApiBaseURL = exports.envVarOrgSlug = exports.envVarProjectId = exports.envVarEnvironmentName = exports.envVarEnvId = exports.envVarOrgId = void 0;
3
+ exports.cronPort = exports.envVarLocalRun = exports.envVarInternalToken = exports.envVarTokenEndpoint = exports.envVarClientSecret = exports.envVarClientId = exports.envVarConfigFile = exports.envVarVersion = exports.envVarOtelTracesURL = exports.envVarCredsBaseURL = exports.envVarSelfRefURL = exports.envVarWorkflowApiBaseURL = exports.envVarCronApiBaseURL = exports.envVarPlatformApiBaseURL = exports.envVarOrgSlug = exports.envVarProjectId = exports.envVarEnvironmentName = exports.envVarEnvId = exports.envVarOrgId = void 0;
4
4
  // This file contains constants used in the Versori DSL HTTP client.
5
5
  exports.envVarOrgId = 'RUN_ORGANISATION_ID';
6
6
  exports.envVarEnvId = 'RUN_ENVIRONMENT_ID';
@@ -9,6 +9,7 @@ exports.envVarProjectId = 'RUN_SERVICE_ID';
9
9
  exports.envVarOrgSlug = 'RUN_ORGANISATION_SLUG';
10
10
  exports.envVarPlatformApiBaseURL = 'RUN_PLATFORM_API_INTERNAL_URL';
11
11
  exports.envVarCronApiBaseURL = 'RUN_CRON_API_INTERNAL_URL';
12
+ exports.envVarWorkflowApiBaseURL = 'RUN_SDK_API_URL';
12
13
  exports.envVarSelfRefURL = 'RUN_SELF_REF_URL';
13
14
  exports.envVarCredsBaseURL = 'RUN_CREDENTIALS_SERVICE_INTERNAL_URL';
14
15
  exports.envVarOtelTracesURL = 'RUN_OTEL_TRACES_URL';