@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.
- package/esm/mod.d.ts +1 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -1
- package/esm/src/connection/VanillaConnectionFactory.d.ts +16 -0
- package/esm/src/connection/VanillaConnectionFactory.d.ts.map +1 -0
- package/esm/src/connection/VanillaConnectionFactory.js +23 -0
- package/esm/src/context/ActivationImpl.d.ts +2 -1
- package/esm/src/context/ActivationImpl.d.ts.map +1 -1
- package/esm/src/context/Context.d.ts +4 -2
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.d.ts +6 -6
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/VanillaContext.d.ts +60 -0
- package/esm/src/context/VanillaContext.d.ts.map +1 -0
- package/esm/src/context/VanillaContext.js +296 -0
- package/esm/src/dsl/http/mod.d.ts +1 -1
- package/esm/src/dsl/http/mod.d.ts.map +1 -1
- package/esm/src/dsl/http/types.d.ts +19 -134
- package/esm/src/dsl/http/types.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/configloader.js +3 -0
- package/esm/src/dsl/tasks/HttpTask.d.ts +5 -5
- package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/esm/src/dsl/triggers/ScheduleTrigger.d.ts +2 -2
- package/esm/src/dsl/triggers/ScheduleTrigger.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +2 -2
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/esm/src/interpreter/mod.d.ts +1 -0
- package/esm/src/interpreter/mod.d.ts.map +1 -1
- package/esm/src/interpreter/mod.js +1 -0
- package/esm/src/interpreter/vanilla/ExecutionError.d.ts +27 -0
- package/esm/src/interpreter/vanilla/ExecutionError.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/ExecutionError.js +48 -0
- package/esm/src/interpreter/vanilla/ObservableCompiler.d.ts +38 -0
- package/esm/src/interpreter/vanilla/ObservableCompiler.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/ObservableCompiler.js +95 -0
- package/esm/src/interpreter/vanilla/Queue.d.ts +72 -0
- package/esm/src/interpreter/vanilla/Queue.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/Queue.js +176 -0
- package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts +95 -0
- package/esm/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/VanillaInterpreter.js +428 -0
- package/esm/src/interpreter/vanilla/compilers/background.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/background.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/background.js +34 -0
- package/esm/src/interpreter/vanilla/compilers/catch.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/catch.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/catch.js +75 -0
- package/esm/src/interpreter/vanilla/compilers/chain.d.ts +3 -0
- package/esm/src/interpreter/vanilla/compilers/chain.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/chain.js +21 -0
- package/esm/src/interpreter/vanilla/compilers/durableworkflow.d.ts +8 -0
- package/esm/src/interpreter/vanilla/compilers/durableworkflow.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/durableworkflow.js +90 -0
- package/esm/src/interpreter/vanilla/compilers/fn.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/fn.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/fn.js +34 -0
- package/esm/src/interpreter/vanilla/compilers/http.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/http.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/http.js +54 -0
- package/esm/src/interpreter/vanilla/compilers/mod.d.ts +2 -0
- package/esm/src/interpreter/vanilla/compilers/mod.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/mod.js +13 -0
- package/esm/src/interpreter/vanilla/compilers/parallel.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/parallel.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/parallel.js +31 -0
- package/esm/src/interpreter/vanilla/compilers/schedule.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/schedule.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/schedule.js +76 -0
- package/esm/src/interpreter/vanilla/compilers/serial.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/serial.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/serial.js +28 -0
- package/esm/src/interpreter/vanilla/compilers/types.d.ts +15 -0
- package/esm/src/interpreter/vanilla/compilers/types.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/types.js +13 -0
- package/esm/src/interpreter/vanilla/compilers/unpack.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/unpack.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/unpack.js +34 -0
- package/esm/src/interpreter/vanilla/compilers/webhook.d.ts +4 -0
- package/esm/src/interpreter/vanilla/compilers/webhook.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/compilers/webhook.js +259 -0
- package/esm/src/interpreter/vanilla/mod.d.ts +3 -0
- package/esm/src/interpreter/vanilla/mod.d.ts.map +1 -0
- package/esm/src/interpreter/vanilla/mod.js +14 -0
- package/esm/src/issues/Issues.d.ts +1 -18
- package/esm/src/issues/Issues.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/mod.d.ts +1 -1
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +2 -1
- package/script/src/connection/VanillaConnectionFactory.d.ts +16 -0
- package/script/src/connection/VanillaConnectionFactory.d.ts.map +1 -0
- package/script/src/connection/VanillaConnectionFactory.js +28 -0
- package/script/src/context/ActivationImpl.d.ts +2 -1
- package/script/src/context/ActivationImpl.d.ts.map +1 -1
- package/script/src/context/Context.d.ts +4 -2
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/ContextProvider.d.ts +6 -6
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/VanillaContext.d.ts +60 -0
- package/script/src/context/VanillaContext.d.ts.map +1 -0
- package/script/src/context/VanillaContext.js +302 -0
- package/script/src/dsl/http/mod.d.ts +1 -1
- package/script/src/dsl/http/mod.d.ts.map +1 -1
- package/script/src/dsl/http/types.d.ts +19 -134
- package/script/src/dsl/http/types.d.ts.map +1 -1
- package/script/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/script/src/dsl/http/versori/configloader.js +3 -0
- package/script/src/dsl/tasks/HttpTask.d.ts +5 -5
- package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/script/src/dsl/triggers/ScheduleTrigger.d.ts +2 -2
- package/script/src/dsl/triggers/ScheduleTrigger.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +2 -2
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
- package/script/src/interpreter/mod.d.ts +1 -0
- package/script/src/interpreter/mod.d.ts.map +1 -1
- package/script/src/interpreter/mod.js +2 -1
- package/script/src/interpreter/vanilla/ExecutionError.d.ts +27 -0
- package/script/src/interpreter/vanilla/ExecutionError.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/ExecutionError.js +52 -0
- package/script/src/interpreter/vanilla/ObservableCompiler.d.ts +38 -0
- package/script/src/interpreter/vanilla/ObservableCompiler.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/ObservableCompiler.js +99 -0
- package/script/src/interpreter/vanilla/Queue.d.ts +72 -0
- package/script/src/interpreter/vanilla/Queue.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/Queue.js +181 -0
- package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts +95 -0
- package/script/src/interpreter/vanilla/VanillaInterpreter.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/VanillaInterpreter.js +435 -0
- package/script/src/interpreter/vanilla/compilers/background.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/background.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/background.js +37 -0
- package/script/src/interpreter/vanilla/compilers/catch.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/catch.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/catch.js +78 -0
- package/script/src/interpreter/vanilla/compilers/chain.d.ts +3 -0
- package/script/src/interpreter/vanilla/compilers/chain.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/chain.js +24 -0
- package/script/src/interpreter/vanilla/compilers/durableworkflow.d.ts +8 -0
- package/script/src/interpreter/vanilla/compilers/durableworkflow.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/durableworkflow.js +94 -0
- package/script/src/interpreter/vanilla/compilers/fn.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/fn.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/fn.js +37 -0
- package/script/src/interpreter/vanilla/compilers/http.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/http.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/http.js +57 -0
- package/script/src/interpreter/vanilla/compilers/mod.d.ts +2 -0
- package/script/src/interpreter/vanilla/compilers/mod.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/mod.js +14 -0
- package/script/src/interpreter/vanilla/compilers/parallel.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/parallel.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/parallel.js +34 -0
- package/script/src/interpreter/vanilla/compilers/schedule.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/schedule.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/schedule.js +79 -0
- package/script/src/interpreter/vanilla/compilers/serial.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/serial.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/serial.js +31 -0
- package/script/src/interpreter/vanilla/compilers/types.d.ts +15 -0
- package/script/src/interpreter/vanilla/compilers/types.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/types.js +14 -0
- package/script/src/interpreter/vanilla/compilers/unpack.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/unpack.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/unpack.js +37 -0
- package/script/src/interpreter/vanilla/compilers/webhook.d.ts +4 -0
- package/script/src/interpreter/vanilla/compilers/webhook.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/compilers/webhook.js +265 -0
- package/script/src/interpreter/vanilla/mod.d.ts +3 -0
- package/script/src/interpreter/vanilla/mod.d.ts.map +1 -0
- package/script/src/interpreter/vanilla/mod.js +30 -0
- package/script/src/issues/Issues.d.ts +1 -18
- package/script/src/issues/Issues.d.ts.map +1 -1
|
@@ -0,0 +1,259 @@
|
|
|
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 cors from 'cors';
|
|
14
|
+
import express from 'express';
|
|
15
|
+
import { pipeline } from 'node:stream/promises';
|
|
16
|
+
import { Observable } from 'rxjs';
|
|
17
|
+
import { WebhookTrigger } from '../../../dsl/triggers/WebhookTrigger.js';
|
|
18
|
+
import { VanillaActivation } from '../ObservableCompiler.js';
|
|
19
|
+
import xmlparser from 'express-xml-bodyparser';
|
|
20
|
+
const xml2jsDefaults = {
|
|
21
|
+
explicitArray: false,
|
|
22
|
+
normalize: false,
|
|
23
|
+
normalizeTags: false,
|
|
24
|
+
trim: true,
|
|
25
|
+
};
|
|
26
|
+
const vanillaWebhookMiddleware = () => {
|
|
27
|
+
return async (_, res, next) => {
|
|
28
|
+
res.locals.activation = VanillaActivation;
|
|
29
|
+
next();
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const DEFAULT_SYNC_ON_SUCCESS = (ctx) => new Response(JSON.stringify(ctx.data), {
|
|
33
|
+
status: 200,
|
|
34
|
+
headers: {
|
|
35
|
+
'Content-Type': 'application/json',
|
|
36
|
+
'X-Execution-Id': ctx.executionId,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
const DEFAULT_SYNC_ON_ERROR = (ctx) => new Response(JSON.stringify({ message: 'Internal server error', error: ctx.data }), {
|
|
40
|
+
status: 500,
|
|
41
|
+
headers: {
|
|
42
|
+
'Content-Type': 'application/json',
|
|
43
|
+
'X-Execution-Id': ctx.executionId,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const DEFAULT_ASYNC_ON_SUCCESS = (ctx) => new Response(JSON.stringify({
|
|
47
|
+
status: 'accepted',
|
|
48
|
+
executionId: ctx.executionId,
|
|
49
|
+
}), {
|
|
50
|
+
status: 202,
|
|
51
|
+
headers: {
|
|
52
|
+
'Content-Type': 'application/json',
|
|
53
|
+
'X-Execution-Id': ctx.executionId,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
const DEFAULT_ASYNC_ON_ERROR = (ctx) => new Response(JSON.stringify({
|
|
57
|
+
message: 'Internal server error',
|
|
58
|
+
executionId: ctx.executionId,
|
|
59
|
+
}), {
|
|
60
|
+
status: 500,
|
|
61
|
+
headers: {
|
|
62
|
+
'Content-Type': 'application/json',
|
|
63
|
+
'X-Execution-Id': ctx.executionId,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
export const webhookCompiler = {
|
|
67
|
+
ctor: WebhookTrigger,
|
|
68
|
+
compile: (ctx, trigger, signal) => {
|
|
69
|
+
const { response: { mode = 'async' } = {}, cors: corsOptions } = trigger.options;
|
|
70
|
+
const isSync = mode === 'sync';
|
|
71
|
+
const isAsync = mode === 'async';
|
|
72
|
+
if (!isSync && !isAsync) {
|
|
73
|
+
throw new Error('Invalid response mode, must be either "sync" or "async"');
|
|
74
|
+
}
|
|
75
|
+
const method = trigger.options.method || 'post';
|
|
76
|
+
const validMethods = ['get', 'post', 'put', 'delete', 'patch', 'options', 'head'];
|
|
77
|
+
if (method !== method.toLowerCase()) {
|
|
78
|
+
throw new Error(`HTTP method must be in lowercase: ${method} on webhook ${trigger.id}`);
|
|
79
|
+
}
|
|
80
|
+
if (!validMethods.includes(method)) {
|
|
81
|
+
throw new Error(`Unsupported HTTP method: ${method} on webhook ${trigger.id}. Must be one of: ${validMethods.join(', ')}`);
|
|
82
|
+
}
|
|
83
|
+
let onSuccess = isSync ? DEFAULT_SYNC_ON_SUCCESS : DEFAULT_ASYNC_ON_SUCCESS;
|
|
84
|
+
let onError = isSync ? DEFAULT_SYNC_ON_ERROR : DEFAULT_ASYNC_ON_ERROR;
|
|
85
|
+
if (trigger.options.response?.onSuccess) {
|
|
86
|
+
onSuccess = trigger.options.response.onSuccess;
|
|
87
|
+
}
|
|
88
|
+
if (trigger.options.response?.onError) {
|
|
89
|
+
onError = trigger.options.response.onError;
|
|
90
|
+
}
|
|
91
|
+
const ctxOptionsFn = (req, res) => ({
|
|
92
|
+
onSuccess: (ctx) => {
|
|
93
|
+
if (isSync) {
|
|
94
|
+
sendResponse(res, onSuccess(ctx));
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
onError: (ctx) => {
|
|
98
|
+
if (isSync) {
|
|
99
|
+
sendResponse(res, onError(ctx));
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
request: req,
|
|
103
|
+
});
|
|
104
|
+
if (!trigger.options.request?.rawBody) {
|
|
105
|
+
ctx.webhookRouter.use(express.json({ limit: '50mb' }));
|
|
106
|
+
ctx.webhookRouter.use(xmlparser(xml2jsDefaults));
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
ctx.webhookRouter.use(express.raw({ type: '*/*', limit: '50mb' }));
|
|
110
|
+
}
|
|
111
|
+
return new Observable((subscriber) => {
|
|
112
|
+
if (!ctx.webhookRouter) {
|
|
113
|
+
throw new Error('Router not available in compiler context');
|
|
114
|
+
}
|
|
115
|
+
// add the webhook endpoint to the router
|
|
116
|
+
ctx.log.info('webhook endpoint added:', { trigger });
|
|
117
|
+
if (corsOptions) {
|
|
118
|
+
if (typeof corsOptions === 'boolean') {
|
|
119
|
+
ctx.webhookRouter.use(cors());
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
ctx.webhookRouter.use(cors(corsOptions));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// endpoint for sans user because I'm not quite sure how the dynamic routing works
|
|
126
|
+
ctx.webhookRouter[method](`/${trigger.id}`, vanillaWebhookMiddleware(), async (req, res) => {
|
|
127
|
+
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
128
|
+
span.setAttribute('task.id', trigger.id);
|
|
129
|
+
span.setAttribute('task.type', 'webhook');
|
|
130
|
+
const staticActivation = res.locals.activation;
|
|
131
|
+
const executionCtx = ctx.contextProvider.create(staticActivation, req.body, ctxOptionsFn(req, res));
|
|
132
|
+
span.setAttribute('execution.id', executionCtx.executionId);
|
|
133
|
+
try {
|
|
134
|
+
subscriber.next(executionCtx);
|
|
135
|
+
if (isAsync) {
|
|
136
|
+
sendResponse(res, onSuccess(executionCtx));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
executionCtx.log.error('webhook execution error', {
|
|
141
|
+
error: JSON.stringify(error),
|
|
142
|
+
});
|
|
143
|
+
if (isAsync) {
|
|
144
|
+
sendResponse(res, onError(executionCtx.withData(error)));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
span.end();
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
// this endpoint will trigger the workflow for each activation given by the external user ID
|
|
153
|
+
ctx.webhookRouter[method](`/${trigger.id}/users/:userId`, vanillaWebhookMiddleware(), async (req, res) => {
|
|
154
|
+
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
155
|
+
span.setAttribute('task.id', trigger.id);
|
|
156
|
+
span.setAttribute('task.type', 'webhook');
|
|
157
|
+
span.setAttribute('user.id', req.params.userId);
|
|
158
|
+
const userId = req.params.userId;
|
|
159
|
+
const activation = res.locals.activation;
|
|
160
|
+
// Right now we only support a user having one activation
|
|
161
|
+
// so this will need changing when we support multiple activations per user
|
|
162
|
+
// as will the middleware
|
|
163
|
+
if (!activation) {
|
|
164
|
+
res.status(404).json({
|
|
165
|
+
status: 'error',
|
|
166
|
+
message: `No activations found for user: ${userId}`,
|
|
167
|
+
});
|
|
168
|
+
span.setAttribute('error.message', `No activations found for user: ${userId}`);
|
|
169
|
+
span.setAttribute('http.status_code', '404');
|
|
170
|
+
span.end();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const executionCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
|
|
174
|
+
span.setAttribute('execution.id', executionCtx.executionId);
|
|
175
|
+
const errors = [];
|
|
176
|
+
try {
|
|
177
|
+
subscriber.next(executionCtx);
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
executionCtx.log.error('webhook execution error', {
|
|
181
|
+
error: JSON.stringify(error),
|
|
182
|
+
});
|
|
183
|
+
errors.push({
|
|
184
|
+
activationId: activation.id,
|
|
185
|
+
error,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (isAsync) {
|
|
189
|
+
if (errors.length === 0) {
|
|
190
|
+
sendResponse(res, onSuccess(executionCtx));
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
sendResponse(res, onError(executionCtx.withData(errors)));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
span.end();
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
// this endpoint will trigger the workflow only for the activation given by its ID
|
|
200
|
+
ctx.webhookRouter[method](`/${trigger.id}/activations/:activationId`, vanillaWebhookMiddleware(), async (req, res) => {
|
|
201
|
+
await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
|
|
202
|
+
span.setAttribute('task.id', trigger.id);
|
|
203
|
+
span.setAttribute('task.type', 'webhook');
|
|
204
|
+
span.setAttribute('activation.id', req.params.activationId);
|
|
205
|
+
const activation = res.locals.activation;
|
|
206
|
+
const activationId = activation?.id ?? req.params.activationId;
|
|
207
|
+
if (!activation) {
|
|
208
|
+
// TODO report back actual errors
|
|
209
|
+
res.status(404).json({
|
|
210
|
+
status: 'error',
|
|
211
|
+
message: `No activation found for ID: ${activationId}`,
|
|
212
|
+
});
|
|
213
|
+
span.setAttribute('error.message', `No activation found for ID: ${activationId}`);
|
|
214
|
+
span.setAttribute('http.status_code', '404');
|
|
215
|
+
span.end();
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const activationCtx = ctx.contextProvider.create(activation, req.body, ctxOptionsFn(req, res));
|
|
219
|
+
span.setAttribute('execution.id', activationCtx.executionId);
|
|
220
|
+
try {
|
|
221
|
+
subscriber.next(activationCtx);
|
|
222
|
+
if (isAsync) {
|
|
223
|
+
sendResponse(res, onSuccess(activationCtx));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
activationCtx.log.error('webhook execution error', {
|
|
228
|
+
error: JSON.stringify(error),
|
|
229
|
+
});
|
|
230
|
+
if (isAsync) {
|
|
231
|
+
sendResponse(res, onError(activationCtx.withData(error)));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
finally {
|
|
235
|
+
span.end();
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
function cleanup() {
|
|
240
|
+
ctx.log.debug('webhook trigger stopped');
|
|
241
|
+
subscriber.complete();
|
|
242
|
+
}
|
|
243
|
+
signal.addEventListener('abort', cleanup, { once: true });
|
|
244
|
+
return () => {
|
|
245
|
+
signal.removeEventListener('abort', cleanup);
|
|
246
|
+
ctx.log.debug('webhook execution unsubscribed');
|
|
247
|
+
};
|
|
248
|
+
});
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
function sendResponse(res, response) {
|
|
252
|
+
res.status(response.status);
|
|
253
|
+
response.headers.forEach((value, key) => {
|
|
254
|
+
res.setHeader(key, value);
|
|
255
|
+
});
|
|
256
|
+
if (response.body) {
|
|
257
|
+
pipeline(response.body, res);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/vanilla/mod.ts"],"names":[],"mappings":"AAaA,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
export * from './VanillaInterpreter.js';
|
|
14
|
+
export * from './ExecutionError.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Logger } from '../observability/mod.js';
|
|
2
|
+
import { Issue } from '@versori/run/services/platform';
|
|
2
3
|
export type CreateIssue = {
|
|
3
4
|
reason: 'manual' | 'error';
|
|
4
5
|
severity: 'low' | 'medium' | 'high';
|
|
@@ -7,24 +8,6 @@ export type CreateIssue = {
|
|
|
7
8
|
annotations?: Record<string, string>;
|
|
8
9
|
labels?: Record<string, string>;
|
|
9
10
|
};
|
|
10
|
-
export type Issue = {
|
|
11
|
-
id: string;
|
|
12
|
-
title: string;
|
|
13
|
-
message: string;
|
|
14
|
-
annotations: Record<string, string>;
|
|
15
|
-
labels: Record<string, string>;
|
|
16
|
-
createdAt: string;
|
|
17
|
-
lastSeenAt: string;
|
|
18
|
-
resolvedAt: string | null;
|
|
19
|
-
resolutionStatus: string | null;
|
|
20
|
-
environmentId: string;
|
|
21
|
-
organisationId: string;
|
|
22
|
-
projectId: string;
|
|
23
|
-
reason: string;
|
|
24
|
-
seenCount: number;
|
|
25
|
-
severity: string;
|
|
26
|
-
status: string;
|
|
27
|
-
};
|
|
28
11
|
export interface IssueAPI {
|
|
29
12
|
submitIssue(issue: CreateIssue): Promise<void>;
|
|
30
13
|
createIssue(issue: CreateIssue, options?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Issues.d.ts","sourceRoot":"","sources":["../../../src/src/issues/Issues.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"Issues.d.ts","sourceRoot":"","sources":["../../../src/src/issues/Issues.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAEvD,MAAM,MAAM,WAAW,GAAG;IACtB,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC3B,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MA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C,WAAW,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE;QACnC,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;KAC3B,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CAG5B"}
|
package/package.json
CHANGED
package/script/mod.d.ts
CHANGED
|
@@ -63,6 +63,6 @@
|
|
|
63
63
|
*/
|
|
64
64
|
import "./_dnt.polyfills.js";
|
|
65
65
|
export * from './src/dsl/mod.js';
|
|
66
|
-
export { durable, ExecutionError, MemoryInterpreter, type MemoryInterpreterOptions, } from './src/interpreter/mod.js';
|
|
66
|
+
export { durable, vanilla, ExecutionError, MemoryInterpreter, type MemoryInterpreterOptions, } from './src/interpreter/mod.js';
|
|
67
67
|
export * from './src/context/mod.js';
|
|
68
68
|
//# sourceMappingURL=mod.d.ts.map
|
package/script/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,OAAO,qBAAqB,CAAC;AAG7B,cAAc,kBAAkB,CAAC;AACjC,OAAO,EACH,OAAO,EACP,cAAc,EACd,iBAAiB,EACjB,KAAK,wBAAwB,GAChC,MAAM,0BAA0B,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,OAAO,qBAAqB,CAAC;AAG7B,cAAc,kBAAkB,CAAC;AACjC,OAAO,EACH,OAAO,EACP,OAAO,EACP,cAAc,EACd,iBAAiB,EACjB,KAAK,wBAAwB,GAChC,MAAM,0BAA0B,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
|
package/script/mod.js
CHANGED
|
@@ -26,7 +26,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
26
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.MemoryInterpreter = exports.ExecutionError = exports.durable = void 0;
|
|
29
|
+
exports.MemoryInterpreter = exports.ExecutionError = exports.vanilla = exports.durable = void 0;
|
|
30
30
|
/**
|
|
31
31
|
* The Versori Run SDK is the backbone of the Versori AI integration platform. It provides a set of tools and
|
|
32
32
|
* abstractions for building integrations which can run in the cloud on Versori's infrastructure.
|
|
@@ -94,6 +94,7 @@ require("./_dnt.polyfills.js");
|
|
|
94
94
|
__exportStar(require("./src/dsl/mod.js"), exports);
|
|
95
95
|
var mod_js_1 = require("./src/interpreter/mod.js");
|
|
96
96
|
Object.defineProperty(exports, "durable", { enumerable: true, get: function () { return mod_js_1.durable; } });
|
|
97
|
+
Object.defineProperty(exports, "vanilla", { enumerable: true, get: function () { return mod_js_1.vanilla; } });
|
|
97
98
|
Object.defineProperty(exports, "ExecutionError", { enumerable: true, get: function () { return mod_js_1.ExecutionError; } });
|
|
98
99
|
Object.defineProperty(exports, "MemoryInterpreter", { enumerable: true, get: function () { return mod_js_1.MemoryInterpreter; } });
|
|
99
100
|
__exportStar(require("./src/context/mod.js"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RequestHandler } from 'express';
|
|
2
|
+
import { Connection } from '../services/platform/generated/types.gen.js';
|
|
3
|
+
import { ConnectionFactory, FetchLike, RuntimeConnectionFactory } from './types.js';
|
|
4
|
+
import { Context } from '../context/Context.js';
|
|
5
|
+
export declare class DefaultConnectionFactory implements ConnectionFactory {
|
|
6
|
+
constructor();
|
|
7
|
+
handler(_: Connection): Promise<RequestHandler>;
|
|
8
|
+
fetcher(_: Connection): Promise<FetchLike>;
|
|
9
|
+
}
|
|
10
|
+
export declare class VanillaFetchFactory implements RuntimeConnectionFactory {
|
|
11
|
+
constructor();
|
|
12
|
+
fetcher(_: Context<unknown>): Promise<FetchLike>;
|
|
13
|
+
baseUrl(_: Context<unknown>): Promise<string>;
|
|
14
|
+
handler(_: Context<unknown>): Promise<RequestHandler>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=VanillaConnectionFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VanillaConnectionFactory.d.ts","sourceRoot":"","sources":["../../../src/src/connection/VanillaConnectionFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,qBAAa,wBAAyB,YAAW,iBAAiB;;IAG9D,OAAO,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC;IAI/C,OAAO,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;CAG7C;AAGD,qBAAa,mBAAoB,YAAW,wBAAwB;;IAG1D,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IAIhD,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAI7C,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;CAK9D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VanillaFetchFactory = exports.DefaultConnectionFactory = void 0;
|
|
4
|
+
class DefaultConnectionFactory {
|
|
5
|
+
constructor() { }
|
|
6
|
+
handler(_) {
|
|
7
|
+
throw new Error('Method not implemented.');
|
|
8
|
+
}
|
|
9
|
+
fetcher(_) {
|
|
10
|
+
return Promise.resolve(globalThis.fetch);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.DefaultConnectionFactory = DefaultConnectionFactory;
|
|
14
|
+
class VanillaFetchFactory {
|
|
15
|
+
constructor() { }
|
|
16
|
+
async fetcher(_) {
|
|
17
|
+
return globalThis.fetch;
|
|
18
|
+
}
|
|
19
|
+
async baseUrl(_) {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
async handler(_) {
|
|
23
|
+
return async (_req, _res, next) => {
|
|
24
|
+
next();
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.VanillaFetchFactory = VanillaFetchFactory;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { ActivationInterface } from '../dsl/http/types.js';
|
|
1
2
|
import { Logger } from '../observability/mod.js';
|
|
2
3
|
import { Activation, Connection, DynamicVariables, EndUser, PlatformApi, ProjectEnvironment } from '../services/platform/mod.js';
|
|
3
|
-
export declare class ActivationImpl implements
|
|
4
|
+
export declare class ActivationImpl implements ActivationInterface {
|
|
4
5
|
private readonly activation;
|
|
5
6
|
private readonly platformApi;
|
|
6
7
|
private readonly organisationId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActivationImpl.d.ts","sourceRoot":"","sources":["../../../src/src/context/ActivationImpl.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EACH,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,kBAAkB,EACrB,MAAM,6BAA6B,CAAC;AAErC,qBAAa,cAAe,YAAW,
|
|
1
|
+
{"version":3,"file":"ActivationImpl.d.ts","sourceRoot":"","sources":["../../../src/src/context/ActivationImpl.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EACH,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,kBAAkB,EACrB,MAAM,6BAA6B,CAAC;AAErC,qBAAa,cAAe,YAAW,mBAAmB;IAElD,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAJH,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,GAAG,EAAE,MAAM;IAGhC,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,IAAI,IAAI,IAAI,OAAO,CAElB;IAED,IAAI,WAAW,IAAI,kBAAkB,GAAG,SAAS,CAEhD;IAED,IAAI,WAAW,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,SAAS,CAE/C;IAED,IAAI,gBAAgB,IAAI,gBAAgB,GAAG,SAAS,CAEnD;IAED,WAAW,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAQ/C,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CA6BjE"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type * as express from 'express';
|
|
2
2
|
import { CredentialsProvider } from '../dsl/http/versori/contextcredentials.js';
|
|
3
3
|
import { QueueAPI } from '../interpreter/durable/Queue.js';
|
|
4
|
-
import {
|
|
4
|
+
import { IssueAPI } from '../issues/Issues.js';
|
|
5
5
|
import { KeyValue, KeyValueProvider, KeyValueScope } from '../kv/KeyValue.js';
|
|
6
6
|
import { Logger } from '../observability/logging/Logger.js';
|
|
7
7
|
import { ActivationImpl } from './ActivationImpl.js';
|
|
8
8
|
import { AsyncWorkflow } from './AsyncWorkflow.js';
|
|
9
|
+
import { ActivationInterface } from '../dsl/http/types.js';
|
|
10
|
+
import { Issue } from '@versori/run/services/platform';
|
|
9
11
|
export type OnSuccessFn = (ctx: Context<any>) => void;
|
|
10
12
|
export type OnErrorFn = (ctx: Context<any>) => void;
|
|
11
13
|
export type ContextOptions = {
|
|
@@ -65,7 +67,7 @@ export interface Context<D> {
|
|
|
65
67
|
readonly executionId: string;
|
|
66
68
|
readonly startTime: Date;
|
|
67
69
|
readonly data: D;
|
|
68
|
-
activation:
|
|
70
|
+
activation: ActivationInterface;
|
|
69
71
|
/**
|
|
70
72
|
* Opens a key value store for the given scope, defaulting to ':project:' if not provided.
|
|
71
73
|
* @param scope The scope of the key value store to open, defaulting to ':project:' if not provided.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/src/context/Context.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/src/context/Context.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAA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CAAC;IAE1B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;gBAI7B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE,mBAAmB,EAC1B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,IAAI,EACf,IAAI,EAAE,CAAC,EACP,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,QAAQ,EAChB,KAAK,CAAC,EAAE,QAAQ,EAChB,OAAO,GAAE,cAAmB;IA0BhC,IAAI,UAAU,IAAI,cAAc,CAE/B;IAED,IAAI,UAAU,IAAI,MAAM,GAAG,SAAS,CAEnC;IAED,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC;IAkB7C,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC;IAe9C,MAAM,CAAC,KAAK,GAAE,aAA2B,GAAG,QAAQ;IAepD,OAAO,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS;IAIhC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAgCtE,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAO3F,WAAW,IAAI,mBAAmB;IAUlC,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAe5C,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAQlD"}
|
|
@@ -6,18 +6,18 @@ import { Logger } from '../observability/logging/Logger.js';
|
|
|
6
6
|
import { Context, ContextImpl, ContextOptions } from './Context.js';
|
|
7
7
|
import { Activation, PlatformApi } from '../services/platform/mod.js';
|
|
8
8
|
export interface ContextProvider {
|
|
9
|
-
create<D>(activation: Activation, data: D, options?: ContextOptions):
|
|
9
|
+
create<D>(activation: Activation, data: D, options?: ContextOptions): Context<D>;
|
|
10
10
|
destroy(ctx: Context<any>): Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
export declare class ContextProviderImpl implements ContextProvider {
|
|
13
13
|
private readonly platformApi;
|
|
14
14
|
private readonly organisationId;
|
|
15
15
|
private readonly environmentId;
|
|
16
|
-
log
|
|
17
|
-
kvp
|
|
18
|
-
creds
|
|
19
|
-
issues
|
|
20
|
-
queue
|
|
16
|
+
private log;
|
|
17
|
+
private kvp;
|
|
18
|
+
private creds;
|
|
19
|
+
private issues;
|
|
20
|
+
private queue?;
|
|
21
21
|
constructor(log: Logger, kvp: KeyValueProvider, creds: CredentialsProvider, platformApi: PlatformApi, organisationId: string, environmentId: string, issues: IssueAPI, queue?: QueueAPI | undefined);
|
|
22
22
|
create<D>(activation: Activation, data: D, options?: ContextOptions): ContextImpl<D>;
|
|
23
23
|
destroy(_: Context<any>): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextProvider.d.ts","sourceRoot":"","sources":["../../../src/src/context/ContextProvider.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,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,UAAU,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAGtE,MAAM,WAAW,eAAe;IAC5B,MAAM,CAAC,CAAC,EAAE,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AE,WAAW,EACxB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACtC,MAAM,EAAE,QAAQ,EAChB,KAAK,GAAE,QAAQ,GAAG,SAAqB;IAS3C,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,GAAE,cAAmB,GAAG,WAAW,CAAC,CAAC,CAAC;IA+BxF,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAG1C"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type * as express from 'express';
|
|
2
|
+
import { Context, ContextOptions, CreateIssue, WorkflowOpts } from './Context.js';
|
|
3
|
+
import { ContextProvider } from './ContextProvider.js';
|
|
4
|
+
import { ActivationInterface } from '../dsl/http/types.js';
|
|
5
|
+
import { Activation, Connection, DynamicVariables, EndUser, Issue, ProjectEnvironment } from '@versori/run/services/platform';
|
|
6
|
+
import { IssueAPI } from '../issues/Issues.js';
|
|
7
|
+
import { QueueAPI } from '../interpreter/vanilla/Queue.js';
|
|
8
|
+
import { Logger, KeyValueProvider, CredentialsProvider, KeyValueScope, KeyValue } from '../mod.js';
|
|
9
|
+
import { AsyncWorkflow } from './AsyncWorkflow.js';
|
|
10
|
+
export declare class VanillaActivation implements ActivationInterface {
|
|
11
|
+
private readonly activation;
|
|
12
|
+
private readonly organisationId;
|
|
13
|
+
private readonly environmentId;
|
|
14
|
+
private readonly log;
|
|
15
|
+
constructor(activation: Activation, organisationId: string, environmentId: string, log: Logger);
|
|
16
|
+
get id(): string;
|
|
17
|
+
get user(): EndUser;
|
|
18
|
+
get environment(): ProjectEnvironment | undefined;
|
|
19
|
+
get connections(): Array<Connection> | undefined;
|
|
20
|
+
get dynamicVariables(): DynamicVariables | undefined;
|
|
21
|
+
getVariable<T = unknown>(name: string): T | undefined;
|
|
22
|
+
setVariable(_: string, __: unknown): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export declare class VanillaContext<D, Index = void> implements Context<D> {
|
|
25
|
+
#private;
|
|
26
|
+
readonly log: Logger;
|
|
27
|
+
readonly executionId: string;
|
|
28
|
+
readonly startTime: Date;
|
|
29
|
+
readonly data: D;
|
|
30
|
+
idx: Index;
|
|
31
|
+
readonly kvp: KeyValueProvider;
|
|
32
|
+
readonly queue?: QueueAPI;
|
|
33
|
+
readonly options: ContextOptions;
|
|
34
|
+
constructor(log: Logger, kvp: KeyValueProvider, executionId: string, startTime: Date, data: D, activation: VanillaActivation, issues: IssueAPI, queue?: QueueAPI, options?: ContextOptions);
|
|
35
|
+
get activation(): ActivationInterface;
|
|
36
|
+
get workflowId(): string | undefined;
|
|
37
|
+
setIndex(idx: number): VanillaContext<D, number>;
|
|
38
|
+
withData<D2>(data: D2): VanillaContext<D2, Index>;
|
|
39
|
+
openKv(scope?: KeyValueScope): KeyValue;
|
|
40
|
+
request(): express.Request | undefined;
|
|
41
|
+
start(group: string, opts: WorkflowOpts): Promise<AsyncWorkflow>;
|
|
42
|
+
createIssue(issue: CreateIssue, options?: {
|
|
43
|
+
deduplicate?: boolean;
|
|
44
|
+
}): Promise<Issue | null>;
|
|
45
|
+
credentials(): CredentialsProvider;
|
|
46
|
+
destroy(scope: KeyValueScope): Promise<void>;
|
|
47
|
+
[Symbol.toPrimitive](): Record<string, unknown>;
|
|
48
|
+
}
|
|
49
|
+
export declare class VanillaContextProvider implements ContextProvider {
|
|
50
|
+
private readonly organisationId;
|
|
51
|
+
private readonly environmentId;
|
|
52
|
+
log: Logger;
|
|
53
|
+
kvp: KeyValueProvider;
|
|
54
|
+
issues: IssueAPI;
|
|
55
|
+
queue?: QueueAPI;
|
|
56
|
+
constructor(log: Logger, kvp: KeyValueProvider, organisationId: string, environmentId: string, issues: IssueAPI, queue?: QueueAPI | undefined);
|
|
57
|
+
create<D>(activation: Activation, data: D, options?: ContextOptions): VanillaContext<D>;
|
|
58
|
+
destroy(_: Context<any>): Promise<void>;
|
|
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