@versori/run 0.4.4 → 0.5.0-alpha.1

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 (177) hide show
  1. package/esm/src/connection/DirectConnectionFactory.d.ts.map +1 -1
  2. package/esm/src/connection/DirectConnectionFactory.js +2 -2
  3. package/esm/src/connection/internal/CredentialHolder.d.ts.map +1 -1
  4. package/esm/src/connection/internal/CredentialHolder.js +1 -1
  5. package/esm/src/connection/internal/FetchBuilder.d.ts +9 -2
  6. package/esm/src/connection/internal/FetchBuilder.d.ts.map +1 -1
  7. package/esm/src/connection/internal/FetchBuilder.js +120 -4
  8. package/esm/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
  9. package/esm/src/connection/internal/OutboundConnectionFactory.js +2 -2
  10. package/esm/src/context/Context.d.ts +1 -0
  11. package/esm/src/context/Context.d.ts.map +1 -1
  12. package/esm/src/context/Context.js +3 -0
  13. package/esm/src/context/ContextProvider.d.ts +1 -1
  14. package/esm/src/context/ContextProvider.d.ts.map +1 -1
  15. package/esm/src/context/ContextProvider.js +1 -1
  16. package/esm/src/dsl/Workflow.d.ts.map +1 -1
  17. package/esm/src/dsl/Workflow.js +2 -0
  18. package/esm/src/dsl/http/types.d.ts +2 -0
  19. package/esm/src/dsl/http/types.d.ts.map +1 -1
  20. package/esm/src/dsl/http/versori/configloader.js +1 -1
  21. package/esm/src/dsl/http/versori/cronapi.d.ts +2 -3
  22. package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -1
  23. package/esm/src/dsl/http/versori/cronapi.js +14 -15
  24. package/esm/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
  25. package/esm/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
  26. package/esm/src/dsl/http/versori/webhookmiddleware.js +69 -38
  27. package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
  28. package/esm/src/dsl/triggers/WebhookTrigger.js +3 -1
  29. package/esm/src/internal/InternalAuth.d.ts +0 -1
  30. package/esm/src/internal/InternalAuth.d.ts.map +1 -1
  31. package/esm/src/internal/InternalAuth.js +1 -14
  32. package/esm/src/internal/constants.d.ts +3 -1
  33. package/esm/src/internal/constants.d.ts.map +1 -1
  34. package/esm/src/internal/constants.js +4 -1
  35. package/esm/src/internal/supervisor.d.ts +25 -0
  36. package/esm/src/internal/supervisor.d.ts.map +1 -0
  37. package/esm/src/internal/supervisor.js +156 -0
  38. package/esm/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
  39. package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
  40. package/esm/src/interpreter/durable/DurableInterpreter.js +79 -27
  41. package/esm/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
  42. package/esm/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
  43. package/esm/src/interpreter/durable/Queue.js +1 -1
  44. package/esm/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
  45. package/esm/src/interpreter/durable/compilers/catch.js +1 -0
  46. package/esm/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
  47. package/esm/src/interpreter/durable/compilers/fn.js +19 -4
  48. package/esm/src/interpreter/durable/compilers/http.d.ts.map +1 -1
  49. package/esm/src/interpreter/durable/compilers/http.js +40 -7
  50. package/esm/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
  51. package/esm/src/interpreter/durable/compilers/schedule.js +2 -1
  52. package/esm/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
  53. package/esm/src/interpreter/durable/compilers/webhook.js +14 -4
  54. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +7 -1
  55. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  56. package/esm/src/interpreter/memory/MemoryInterpreter.js +78 -18
  57. package/esm/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
  58. package/esm/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
  59. package/esm/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
  60. package/esm/src/interpreter/memory/compilers/catch.js +1 -0
  61. package/esm/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
  62. package/esm/src/interpreter/memory/compilers/fn.js +19 -16
  63. package/esm/src/interpreter/memory/compilers/http.d.ts.map +1 -1
  64. package/esm/src/interpreter/memory/compilers/http.js +39 -6
  65. package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  66. package/esm/src/interpreter/memory/compilers/schedule.js +2 -1
  67. package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  68. package/esm/src/interpreter/memory/compilers/webhook.js +15 -4
  69. package/esm/src/issues/Issues.js +1 -1
  70. package/esm/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
  71. package/package.json +3 -1
  72. package/script/src/connection/DirectConnectionFactory.d.ts.map +1 -1
  73. package/script/src/connection/DirectConnectionFactory.js +2 -2
  74. package/script/src/connection/internal/CredentialHolder.d.ts.map +1 -1
  75. package/script/src/connection/internal/CredentialHolder.js +1 -1
  76. package/script/src/connection/internal/FetchBuilder.d.ts +9 -2
  77. package/script/src/connection/internal/FetchBuilder.d.ts.map +1 -1
  78. package/script/src/connection/internal/FetchBuilder.js +143 -4
  79. package/script/src/connection/internal/OutboundConnectionFactory.d.ts.map +1 -1
  80. package/script/src/connection/internal/OutboundConnectionFactory.js +2 -2
  81. package/script/src/context/Context.d.ts +1 -0
  82. package/script/src/context/Context.d.ts.map +1 -1
  83. package/script/src/context/Context.js +3 -0
  84. package/script/src/context/ContextProvider.d.ts +1 -1
  85. package/script/src/context/ContextProvider.d.ts.map +1 -1
  86. package/script/src/context/ContextProvider.js +1 -1
  87. package/script/src/dsl/Workflow.d.ts.map +1 -1
  88. package/script/src/dsl/Workflow.js +2 -0
  89. package/script/src/dsl/http/types.d.ts +2 -0
  90. package/script/src/dsl/http/types.d.ts.map +1 -1
  91. package/script/src/dsl/http/versori/configloader.js +1 -1
  92. package/script/src/dsl/http/versori/cronapi.d.ts +2 -3
  93. package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -1
  94. package/script/src/dsl/http/versori/cronapi.js +14 -15
  95. package/script/src/dsl/http/versori/kvapi/core/OpenAPI.js +1 -1
  96. package/script/src/dsl/http/versori/webhookmiddleware.d.ts.map +1 -1
  97. package/script/src/dsl/http/versori/webhookmiddleware.js +69 -38
  98. package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
  99. package/script/src/dsl/triggers/WebhookTrigger.js +3 -1
  100. package/script/src/internal/InternalAuth.d.ts +0 -1
  101. package/script/src/internal/InternalAuth.d.ts.map +1 -1
  102. package/script/src/internal/InternalAuth.js +0 -13
  103. package/script/src/internal/constants.d.ts +3 -1
  104. package/script/src/internal/constants.d.ts.map +1 -1
  105. package/script/src/internal/constants.js +5 -2
  106. package/script/src/internal/supervisor.d.ts +25 -0
  107. package/script/src/internal/supervisor.d.ts.map +1 -0
  108. package/script/src/internal/supervisor.js +163 -0
  109. package/script/src/interpreter/durable/DurableInterpreter.d.ts +8 -2
  110. package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
  111. package/script/src/interpreter/durable/DurableInterpreter.js +84 -32
  112. package/script/src/interpreter/durable/ObservableCompiler.d.ts +6 -1
  113. package/script/src/interpreter/durable/ObservableCompiler.d.ts.map +1 -1
  114. package/script/src/interpreter/durable/Queue.js +1 -1
  115. package/script/src/interpreter/durable/compilers/catch.d.ts.map +1 -1
  116. package/script/src/interpreter/durable/compilers/catch.js +1 -0
  117. package/script/src/interpreter/durable/compilers/fn.d.ts.map +1 -1
  118. package/script/src/interpreter/durable/compilers/fn.js +19 -4
  119. package/script/src/interpreter/durable/compilers/http.d.ts.map +1 -1
  120. package/script/src/interpreter/durable/compilers/http.js +40 -7
  121. package/script/src/interpreter/durable/compilers/schedule.d.ts.map +1 -1
  122. package/script/src/interpreter/durable/compilers/schedule.js +2 -1
  123. package/script/src/interpreter/durable/compilers/webhook.d.ts.map +1 -1
  124. package/script/src/interpreter/durable/compilers/webhook.js +14 -4
  125. package/script/src/interpreter/memory/MemoryInterpreter.d.ts +7 -1
  126. package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  127. package/script/src/interpreter/memory/MemoryInterpreter.js +78 -18
  128. package/script/src/interpreter/memory/ObservableCompiler.d.ts +6 -1
  129. package/script/src/interpreter/memory/ObservableCompiler.d.ts.map +1 -1
  130. package/script/src/interpreter/memory/compilers/catch.d.ts.map +1 -1
  131. package/script/src/interpreter/memory/compilers/catch.js +1 -0
  132. package/script/src/interpreter/memory/compilers/fn.d.ts.map +1 -1
  133. package/script/src/interpreter/memory/compilers/fn.js +19 -16
  134. package/script/src/interpreter/memory/compilers/http.d.ts.map +1 -1
  135. package/script/src/interpreter/memory/compilers/http.js +39 -6
  136. package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  137. package/script/src/interpreter/memory/compilers/schedule.js +2 -1
  138. package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  139. package/script/src/interpreter/memory/compilers/webhook.js +15 -4
  140. package/script/src/issues/Issues.js +1 -1
  141. package/script/src/observability/logging/ConsoleLogger.d.ts.map +1 -1
  142. package/esm/src/dsl/http/default.d.ts +0 -26
  143. package/esm/src/dsl/http/default.d.ts.map +0 -1
  144. package/esm/src/dsl/http/default.js +0 -56
  145. package/esm/src/dsl/http/versori/cli.d.ts +0 -2
  146. package/esm/src/dsl/http/versori/cli.d.ts.map +0 -1
  147. package/esm/src/dsl/http/versori/cli.js +0 -32
  148. package/esm/src/dsl/http/versori/constants.d.ts +0 -20
  149. package/esm/src/dsl/http/versori/constants.d.ts.map +0 -1
  150. package/esm/src/dsl/http/versori/constants.js +0 -37
  151. package/esm/src/dsl/http/versori/internalauth.d.ts +0 -15
  152. package/esm/src/dsl/http/versori/internalauth.d.ts.map +0 -1
  153. package/esm/src/dsl/http/versori/internalauth.js +0 -102
  154. package/esm/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
  155. package/esm/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
  156. package/esm/src/dsl/http/versori/proxyroundtripper.js +0 -208
  157. package/esm/src/internal/cli.d.ts +0 -2
  158. package/esm/src/internal/cli.d.ts.map +0 -1
  159. package/esm/src/internal/cli.js +0 -32
  160. package/script/src/dsl/http/default.d.ts +0 -26
  161. package/script/src/dsl/http/default.d.ts.map +0 -1
  162. package/script/src/dsl/http/default.js +0 -60
  163. package/script/src/dsl/http/versori/cli.d.ts +0 -2
  164. package/script/src/dsl/http/versori/cli.d.ts.map +0 -1
  165. package/script/src/dsl/http/versori/cli.js +0 -35
  166. package/script/src/dsl/http/versori/constants.d.ts +0 -20
  167. package/script/src/dsl/http/versori/constants.d.ts.map +0 -1
  168. package/script/src/dsl/http/versori/constants.js +0 -40
  169. package/script/src/dsl/http/versori/internalauth.d.ts +0 -15
  170. package/script/src/dsl/http/versori/internalauth.d.ts.map +0 -1
  171. package/script/src/dsl/http/versori/internalauth.js +0 -106
  172. package/script/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
  173. package/script/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
  174. package/script/src/dsl/http/versori/proxyroundtripper.js +0 -212
  175. package/script/src/internal/cli.d.ts +0 -2
  176. package/script/src/internal/cli.d.ts.map +0 -1
  177. package/script/src/internal/cli.js +0 -35
@@ -1,212 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025 Versori Group Inc
4
- *
5
- * Use of this software is governed by the Business Source License 1.1
6
- * included in the LICENSE file at the root of this repository.
7
- *
8
- * Change Date: 2029-01-01
9
- * Change License: Apache License, Version 2.0
10
- *
11
- * As of the Change Date, in accordance with the Business Source License,
12
- * use of this software will be governed by the Apache License, Version 2.0.
13
- */
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.ProxyRoundTripper = void 0;
16
- const mod_js_1 = require("../../../services/platform/mod.js");
17
- const configloader_js_1 = require("./configloader.js");
18
- const constants_js_1 = require("./constants.js");
19
- const helpers_js_1 = require("./helpers.js");
20
- const internalauth_js_1 = require("./internalauth.js");
21
- // TODO(@teo): there's a stub implementation of this at src/connection/ProxyConnectionFactory.ts, it may be worth
22
- // skipping this for getting performance tests over the line, and implement this next week when things calm down. We
23
- // can sort out running locally another day.
24
- // ProxyRoundTripper is a factory for creating roundtrippers that use the Versori Platform API proxy endpoints.
25
- // this should allow code from the platform to be run locally.
26
- class ProxyRoundTripper {
27
- constructor(log, platformApiBaseUrl, platformApi, cfgReader, orgId, envId) {
28
- Object.defineProperty(this, "platformApiBaseUrl", {
29
- enumerable: true,
30
- configurable: true,
31
- writable: true,
32
- value: void 0
33
- });
34
- Object.defineProperty(this, "cfgReader", {
35
- enumerable: true,
36
- configurable: true,
37
- writable: true,
38
- value: void 0
39
- });
40
- Object.defineProperty(this, "platformApi", {
41
- enumerable: true,
42
- configurable: true,
43
- writable: true,
44
- value: void 0
45
- });
46
- Object.defineProperty(this, "internalAuth", {
47
- enumerable: true,
48
- configurable: true,
49
- writable: true,
50
- value: void 0
51
- });
52
- Object.defineProperty(this, "log", {
53
- enumerable: true,
54
- configurable: true,
55
- writable: true,
56
- value: void 0
57
- });
58
- Object.defineProperty(this, "organisationId", {
59
- enumerable: true,
60
- configurable: true,
61
- writable: true,
62
- value: void 0
63
- });
64
- Object.defineProperty(this, "envId", {
65
- enumerable: true,
66
- configurable: true,
67
- writable: true,
68
- value: void 0
69
- });
70
- this.cfgReader = cfgReader;
71
- this.log = log;
72
- this.platformApiBaseUrl = platformApiBaseUrl;
73
- this.platformApi = platformApi;
74
- this.internalAuth = new internalauth_js_1.InternalAuth();
75
- this.organisationId = orgId;
76
- this.envId = envId;
77
- }
78
- static fromEnv(log) {
79
- const baseUrl = Deno.env.get(constants_js_1.envVarPlatformApiBaseURL);
80
- const orgId = Deno.env.get(constants_js_1.envVarOrgId);
81
- const envId = Deno.env.get(constants_js_1.envVarEnvId);
82
- const cfgReader = configloader_js_1.VersoriConfigReader.fromEnv(log);
83
- if (!baseUrl || !orgId || !envId) {
84
- const missingVars = [];
85
- if (!baseUrl)
86
- missingVars.push(constants_js_1.envVarPlatformApiBaseURL);
87
- if (!orgId)
88
- missingVars.push(constants_js_1.envVarOrgId);
89
- if (!envId)
90
- missingVars.push(constants_js_1.envVarEnvId);
91
- log.error(`Missing required environment variables: ${missingVars.join(', ')}`);
92
- throw new Error('Missing required environment variables: ' + missingVars.join(', '));
93
- }
94
- return new ProxyRoundTripper(log, baseUrl, mod_js_1.PlatformApiImpl.create(baseUrl), cfgReader, orgId, envId);
95
- }
96
- makeProxyUrlString(url, cnxId) {
97
- if ((0, helpers_js_1.isValidURL)(url)) {
98
- const _url = new URL(url);
99
- const proxyUrl = `${this.platformApiBaseUrl}/proxy/${cnxId}${_url.pathname}${_url.search}`;
100
- return proxyUrl;
101
- }
102
- // here we assume we just have the path and query string
103
- // although we could have a leading slash
104
- const proxyPath = url.startsWith('/') ? url : `/${url}`;
105
- return `${this.platformApiBaseUrl}/proxy/${cnxId}${proxyPath}`;
106
- }
107
- makeProxyInput(input, cnxId) {
108
- if (typeof input === 'string') {
109
- return this.makeProxyUrlString(input, cnxId);
110
- }
111
- if (input instanceof URL) {
112
- const proxyUrl = new URL(input);
113
- proxyUrl.hostname = this.platformApiBaseUrl.replace(/^https?:\/\//, '');
114
- proxyUrl.pathname = `/proxy/${cnxId}${input.pathname}`;
115
- return proxyUrl;
116
- }
117
- if (input instanceof Request) {
118
- const requestUrl = this.makeProxyUrlString(input.url, cnxId);
119
- // not actually sure if these headers overwrite whatever is in init but I have never seen
120
- // the AI use the Request type
121
- const proxyRequest = new Request(requestUrl, {
122
- ...input,
123
- headers: new Headers(input.headers),
124
- });
125
- return proxyRequest;
126
- }
127
- return input;
128
- }
129
- async makeProxyInit(init) {
130
- if (!init) {
131
- init = {};
132
- }
133
- if (!init.headers) {
134
- init.headers = new Headers();
135
- }
136
- // could be tidied up but this'll do
137
- const authHeader = await this.internalAuth.getAuthHeader();
138
- const cookie = authHeader['Cookie'];
139
- // insert the auth cookie into the headers
140
- if (init.headers instanceof Headers) {
141
- init.headers.set('Cookie', cookie);
142
- }
143
- else if (init.headers instanceof Array) {
144
- init.headers.push(['Cookie', cookie]);
145
- }
146
- else {
147
- init.headers = {
148
- ...init.headers,
149
- ['Cookie']: cookie,
150
- };
151
- }
152
- return init;
153
- }
154
- create(connName) {
155
- const cnxId = this.cfgReader.getConnectionID(connName);
156
- if (!cnxId) {
157
- this.log.error(`Connection ${connName} not found in configuration`);
158
- return Promise.resolve(undefined);
159
- }
160
- const _fn = async (input, init) => {
161
- const proxyInput = this.makeProxyInput(input, cnxId);
162
- const proxyInit = await this.makeProxyInit(init);
163
- this.log.info('proxy input and init', { input: proxyInput, init: proxyInit });
164
- return globalThis.fetch(proxyInput, proxyInit);
165
- };
166
- return Promise.resolve(_fn);
167
- }
168
- createDynamic(templateName) {
169
- const template = this.cfgReader.getTemplateID(templateName);
170
- if (!template) {
171
- this.log.error(`Template ${templateName} not found in configuration, could be a static connection`);
172
- return Promise.resolve(undefined);
173
- }
174
- const _fn = async (activation, input, init) => {
175
- const { data: conn } = await this.platformApi.getActivationConnection({
176
- path: {
177
- organisation_id: this.organisationId,
178
- env_system_id: template,
179
- activation_id: activation.id,
180
- },
181
- });
182
- if (!conn) {
183
- this.log.error(`Connection not found for activation ${activation.id} and template ${template}, using default fetch`);
184
- return globalThis.fetch(input, init);
185
- }
186
- const proxyInput = this.makeProxyInput(input, conn.id);
187
- const proxyInit = await this.makeProxyInit(init);
188
- this.log.info('proxy input and init', { input: proxyInput, init: proxyInit });
189
- return globalThis.fetch(proxyInput, proxyInit);
190
- };
191
- return Promise.resolve(_fn);
192
- }
193
- credentials() {
194
- return {
195
- getRaw: (_name, _actId) => {
196
- return Promise.reject(new Error('Not implemented, getRaw is not supported in proxy mode'));
197
- },
198
- getAccessToken: (_name, _forceRefresh, _actId) => {
199
- return Promise.reject(new Error('Not implemented, getAccessToken is not supported in proxy mode'));
200
- },
201
- getOAuth1Metadata: (_name, _actId) => {
202
- return Promise.reject(new Error('Not implemented, getOAuth1Metadata is not supported in proxy mode'));
203
- },
204
- };
205
- }
206
- baseUrlFetcher(_templateName) {
207
- return (_activationId) => {
208
- return Promise.resolve('do not use this here');
209
- };
210
- }
211
- }
212
- exports.ProxyRoundTripper = ProxyRoundTripper;
@@ -1,2 +0,0 @@
1
- export declare function getVersoriCookie(): string;
2
- //# sourceMappingURL=cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/src/internal/cli.ts"],"names":[],"mappings":"AA8BA,wBAAgB,gBAAgB,IAAI,MAAM,CAmBzC"}
@@ -1,35 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025 Versori Group Inc
4
- *
5
- * Use of this software is governed by the Business Source License 1.1
6
- * included in the LICENSE file at the root of this repository.
7
- *
8
- * Change Date: 2029-01-01
9
- * Change License: Apache License, Version 2.0
10
- *
11
- * As of the Change Date, in accordance with the Business Source License,
12
- * use of this software will be governed by the Apache License, Version 2.0.
13
- */
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getVersoriCookie = getVersoriCookie;
16
- // This file contains functions that can read stuff generated by the Versori CLI. This is used when running locally.
17
- const node_os_1 = require("node:os");
18
- const cookiesFileName = 'cookies.json';
19
- const versoriCookieName = 'versori_sess';
20
- function getVersoriCookie() {
21
- const cookiesFilePath = `${(0, node_os_1.homedir)()}/.config/versori/${cookiesFileName}`;
22
- let cookiesFile;
23
- try {
24
- cookiesFile = JSON.parse(Deno.readTextFileSync(cookiesFilePath));
25
- }
26
- catch (e) {
27
- console.error('Error reading file, have you run the Versori CLI to log in?');
28
- throw new Error(`Failed to read or parse cookies file at ${cookiesFilePath}: ${e}`);
29
- }
30
- const versoriCookie = cookiesFile.cookies.find((cookie) => cookie.Name === versoriCookieName);
31
- if (!versoriCookie) {
32
- throw new Error(`Cookie 'versori_sess' not found in ${cookiesFilePath}`);
33
- }
34
- return `${versoriCookieName}=${versoriCookie.Value}`;
35
- }