@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,208 +0,0 @@
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 { PlatformApiImpl } from '../../../services/platform/mod.js';
14
- import { VersoriConfigReader } from './configloader.js';
15
- import { envVarEnvId, envVarOrgId, envVarPlatformApiBaseURL } from './constants.js';
16
- import { isValidURL } from './helpers.js';
17
- import { InternalAuth } from './internalauth.js';
18
- // TODO(@teo): there's a stub implementation of this at src/connection/ProxyConnectionFactory.ts, it may be worth
19
- // skipping this for getting performance tests over the line, and implement this next week when things calm down. We
20
- // can sort out running locally another day.
21
- // ProxyRoundTripper is a factory for creating roundtrippers that use the Versori Platform API proxy endpoints.
22
- // this should allow code from the platform to be run locally.
23
- export class ProxyRoundTripper {
24
- constructor(log, platformApiBaseUrl, platformApi, cfgReader, orgId, envId) {
25
- Object.defineProperty(this, "platformApiBaseUrl", {
26
- enumerable: true,
27
- configurable: true,
28
- writable: true,
29
- value: void 0
30
- });
31
- Object.defineProperty(this, "cfgReader", {
32
- enumerable: true,
33
- configurable: true,
34
- writable: true,
35
- value: void 0
36
- });
37
- Object.defineProperty(this, "platformApi", {
38
- enumerable: true,
39
- configurable: true,
40
- writable: true,
41
- value: void 0
42
- });
43
- Object.defineProperty(this, "internalAuth", {
44
- enumerable: true,
45
- configurable: true,
46
- writable: true,
47
- value: void 0
48
- });
49
- Object.defineProperty(this, "log", {
50
- enumerable: true,
51
- configurable: true,
52
- writable: true,
53
- value: void 0
54
- });
55
- Object.defineProperty(this, "organisationId", {
56
- enumerable: true,
57
- configurable: true,
58
- writable: true,
59
- value: void 0
60
- });
61
- Object.defineProperty(this, "envId", {
62
- enumerable: true,
63
- configurable: true,
64
- writable: true,
65
- value: void 0
66
- });
67
- this.cfgReader = cfgReader;
68
- this.log = log;
69
- this.platformApiBaseUrl = platformApiBaseUrl;
70
- this.platformApi = platformApi;
71
- this.internalAuth = new InternalAuth();
72
- this.organisationId = orgId;
73
- this.envId = envId;
74
- }
75
- static fromEnv(log) {
76
- const baseUrl = Deno.env.get(envVarPlatformApiBaseURL);
77
- const orgId = Deno.env.get(envVarOrgId);
78
- const envId = Deno.env.get(envVarEnvId);
79
- const cfgReader = VersoriConfigReader.fromEnv(log);
80
- if (!baseUrl || !orgId || !envId) {
81
- const missingVars = [];
82
- if (!baseUrl)
83
- missingVars.push(envVarPlatformApiBaseURL);
84
- if (!orgId)
85
- missingVars.push(envVarOrgId);
86
- if (!envId)
87
- missingVars.push(envVarEnvId);
88
- log.error(`Missing required environment variables: ${missingVars.join(', ')}`);
89
- throw new Error('Missing required environment variables: ' + missingVars.join(', '));
90
- }
91
- return new ProxyRoundTripper(log, baseUrl, PlatformApiImpl.create(baseUrl), cfgReader, orgId, envId);
92
- }
93
- makeProxyUrlString(url, cnxId) {
94
- if (isValidURL(url)) {
95
- const _url = new URL(url);
96
- const proxyUrl = `${this.platformApiBaseUrl}/proxy/${cnxId}${_url.pathname}${_url.search}`;
97
- return proxyUrl;
98
- }
99
- // here we assume we just have the path and query string
100
- // although we could have a leading slash
101
- const proxyPath = url.startsWith('/') ? url : `/${url}`;
102
- return `${this.platformApiBaseUrl}/proxy/${cnxId}${proxyPath}`;
103
- }
104
- makeProxyInput(input, cnxId) {
105
- if (typeof input === 'string') {
106
- return this.makeProxyUrlString(input, cnxId);
107
- }
108
- if (input instanceof URL) {
109
- const proxyUrl = new URL(input);
110
- proxyUrl.hostname = this.platformApiBaseUrl.replace(/^https?:\/\//, '');
111
- proxyUrl.pathname = `/proxy/${cnxId}${input.pathname}`;
112
- return proxyUrl;
113
- }
114
- if (input instanceof Request) {
115
- const requestUrl = this.makeProxyUrlString(input.url, cnxId);
116
- // not actually sure if these headers overwrite whatever is in init but I have never seen
117
- // the AI use the Request type
118
- const proxyRequest = new Request(requestUrl, {
119
- ...input,
120
- headers: new Headers(input.headers),
121
- });
122
- return proxyRequest;
123
- }
124
- return input;
125
- }
126
- async makeProxyInit(init) {
127
- if (!init) {
128
- init = {};
129
- }
130
- if (!init.headers) {
131
- init.headers = new Headers();
132
- }
133
- // could be tidied up but this'll do
134
- const authHeader = await this.internalAuth.getAuthHeader();
135
- const cookie = authHeader['Cookie'];
136
- // insert the auth cookie into the headers
137
- if (init.headers instanceof Headers) {
138
- init.headers.set('Cookie', cookie);
139
- }
140
- else if (init.headers instanceof Array) {
141
- init.headers.push(['Cookie', cookie]);
142
- }
143
- else {
144
- init.headers = {
145
- ...init.headers,
146
- ['Cookie']: cookie,
147
- };
148
- }
149
- return init;
150
- }
151
- create(connName) {
152
- const cnxId = this.cfgReader.getConnectionID(connName);
153
- if (!cnxId) {
154
- this.log.error(`Connection ${connName} not found in configuration`);
155
- return Promise.resolve(undefined);
156
- }
157
- const _fn = async (input, init) => {
158
- const proxyInput = this.makeProxyInput(input, cnxId);
159
- const proxyInit = await this.makeProxyInit(init);
160
- this.log.info('proxy input and init', { input: proxyInput, init: proxyInit });
161
- return globalThis.fetch(proxyInput, proxyInit);
162
- };
163
- return Promise.resolve(_fn);
164
- }
165
- createDynamic(templateName) {
166
- const template = this.cfgReader.getTemplateID(templateName);
167
- if (!template) {
168
- this.log.error(`Template ${templateName} not found in configuration, could be a static connection`);
169
- return Promise.resolve(undefined);
170
- }
171
- const _fn = async (activation, input, init) => {
172
- const { data: conn } = await this.platformApi.getActivationConnection({
173
- path: {
174
- organisation_id: this.organisationId,
175
- env_system_id: template,
176
- activation_id: activation.id,
177
- },
178
- });
179
- if (!conn) {
180
- this.log.error(`Connection not found for activation ${activation.id} and template ${template}, using default fetch`);
181
- return globalThis.fetch(input, init);
182
- }
183
- const proxyInput = this.makeProxyInput(input, conn.id);
184
- const proxyInit = await this.makeProxyInit(init);
185
- this.log.info('proxy input and init', { input: proxyInput, init: proxyInit });
186
- return globalThis.fetch(proxyInput, proxyInit);
187
- };
188
- return Promise.resolve(_fn);
189
- }
190
- credentials() {
191
- return {
192
- getRaw: (_name, _actId) => {
193
- return Promise.reject(new Error('Not implemented, getRaw is not supported in proxy mode'));
194
- },
195
- getAccessToken: (_name, _forceRefresh, _actId) => {
196
- return Promise.reject(new Error('Not implemented, getAccessToken is not supported in proxy mode'));
197
- },
198
- getOAuth1Metadata: (_name, _actId) => {
199
- return Promise.reject(new Error('Not implemented, getOAuth1Metadata is not supported in proxy mode'));
200
- },
201
- };
202
- }
203
- baseUrlFetcher(_templateName) {
204
- return (_activationId) => {
205
- return Promise.resolve('do not use this here');
206
- };
207
- }
208
- }
@@ -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,32 +0,0 @@
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
- // This file contains functions that can read stuff generated by the Versori CLI. This is used when running locally.
14
- import { homedir } from 'node:os';
15
- const cookiesFileName = 'cookies.json';
16
- const versoriCookieName = 'versori_sess';
17
- export function getVersoriCookie() {
18
- const cookiesFilePath = `${homedir()}/.config/versori/${cookiesFileName}`;
19
- let cookiesFile;
20
- try {
21
- cookiesFile = JSON.parse(Deno.readTextFileSync(cookiesFilePath));
22
- }
23
- catch (e) {
24
- console.error('Error reading file, have you run the Versori CLI to log in?');
25
- throw new Error(`Failed to read or parse cookies file at ${cookiesFilePath}: ${e}`);
26
- }
27
- const versoriCookie = cookiesFile.cookies.find((cookie) => cookie.Name === versoriCookieName);
28
- if (!versoriCookie) {
29
- throw new Error(`Cookie 'versori_sess' not found in ${cookiesFilePath}`);
30
- }
31
- return `${versoriCookieName}=${versoriCookie.Value}`;
32
- }
@@ -1,26 +0,0 @@
1
- import { DynamicFetcher, RoundTripperFactory } from './types.js';
2
- import { CredentialsProvider } from './versori/contextcredentials.js';
3
- /**
4
- * A factory class for creating a default round tripper.
5
- * This class is used to provide a default implementation for initializing
6
- * if no round tripper factory is given.
7
- */
8
- export declare class DefaultRoundTripperFactory implements RoundTripperFactory {
9
- /**
10
- * Constructs a new instance of the DefaultRoundTripperFactory.
11
- */
12
- constructor();
13
- /**
14
- * Creates a round tripper function.
15
- * This implementation simply returns the fetch function passed to it.
16
- *
17
- * @param connName - The name of the connection.
18
- * @param fn - The fetch function to be used. Defaults to the global fetch function.
19
- * @returns A promise that resolves to the fetch function.
20
- */
21
- create(_connName: string): Promise<typeof fetch>;
22
- createDynamic(_templateName: string): Promise<DynamicFetcher>;
23
- credentials(): CredentialsProvider;
24
- baseUrlFetcher(_connName: string): (activationId: string) => Promise<string>;
25
- }
26
- //# sourceMappingURL=default.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/http/default.ts"],"names":[],"mappings":"AAcA,OAAO,EAAc,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE;;;;GAIG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IAClE;;OAEG;;IAIH;;;;;;;OAOG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,CAAC;IAIhD,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAU7D,WAAW,IAAI,mBAAmB;IAclC,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC;CAG/E"}
@@ -1,60 +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.DefaultRoundTripperFactory = void 0;
16
- const protobuf_1 = require("@bufbuild/protobuf");
17
- const mod_js_1 = require("../../services/credentials/mod.js");
18
- /**
19
- * A factory class for creating a default round tripper.
20
- * This class is used to provide a default implementation for initializing
21
- * if no round tripper factory is given.
22
- */
23
- class DefaultRoundTripperFactory {
24
- /**
25
- * Constructs a new instance of the DefaultRoundTripperFactory.
26
- */
27
- constructor() {
28
- }
29
- /**
30
- * Creates a round tripper function.
31
- * This implementation simply returns the fetch function passed to it.
32
- *
33
- * @param connName - The name of the connection.
34
- * @param fn - The fetch function to be used. Defaults to the global fetch function.
35
- * @returns A promise that resolves to the fetch function.
36
- */
37
- create(_connName) {
38
- return Promise.resolve(globalThis.fetch);
39
- }
40
- createDynamic(_templateName) {
41
- return Promise.resolve((_activation, input, init) => {
42
- return globalThis.fetch(input, init);
43
- });
44
- }
45
- credentials() {
46
- return {
47
- getRaw: () => Promise.resolve(new Uint8Array(0)),
48
- getAccessToken: () => Promise.resolve({
49
- accessToken: '',
50
- tokenType: '',
51
- expiry: undefined,
52
- }),
53
- getOAuth1Metadata: () => Promise.resolve((0, protobuf_1.create)(mod_js_1.oauth1v1.GetAuthorizationMetadataResponseSchema)), // Create empty response
54
- };
55
- }
56
- baseUrlFetcher(_connName) {
57
- return (_activationId) => Promise.resolve('');
58
- }
59
- }
60
- exports.DefaultRoundTripperFactory = DefaultRoundTripperFactory;
@@ -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/dsl/http/versori/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
- }
@@ -1,20 +0,0 @@
1
- export declare const envVarOrgId = "RUN_ORGANISATION_ID";
2
- export declare const envVarEnvId = "RUN_ENVIRONMENT_ID";
3
- export declare const envVarEnvironmentName = "RUN_ENVIRONMENT";
4
- export declare const envVarProjectId = "RUN_SERVICE_ID";
5
- export declare const envVarOrgSlug = "RUN_ORGANISATION_SLUG";
6
- export declare const envVarPlatformApiBaseURL = "RUN_PLATFORM_API_INTERNAL_URL";
7
- export declare const envVarCronApiBaseURL = "RUN_CRON_API_INTERNAL_URL";
8
- export declare const envVarSDKApiBaseURL = "RUN_SDK_API_URL";
9
- export declare const envVarSelfRefURL = "RUN_SELF_REF_URL";
10
- export declare const envVarCredsBaseURL = "RUN_CREDENTIALS_SERVICE_INTERNAL_URL";
11
- export declare const envVarOtelTracesURL = "RUN_OTEL_TRACES_URL";
12
- export declare const envVarVersion = "RUN_SERVICE_VERSION";
13
- export declare const envVarConfigFile = "RUN_CONFIG_FILE";
14
- export declare const envVarClientId = "RUN_CLIENT_ID";
15
- export declare const envVarClientSecret = "RUN_CLIENT_SECRET";
16
- export declare const envVarTokenEndpoint = "RUN_TOKEN_ENDPOINT";
17
- export declare const envVarInternalToken = "RUN_INTERNAL_TOKEN";
18
- export declare const envVarLocalRun = "RUN_LOCAL";
19
- export declare const cronPort = 3001;
20
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/constants.ts"],"names":[],"mappings":"AAgBA,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,mBAAmB,oBAAoB,CAAC;AACrD,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;AAG1C,eAAO,MAAM,QAAQ,OAAO,CAAC"}
@@ -1,40 +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.cronPort = exports.envVarLocalRun = exports.envVarInternalToken = exports.envVarTokenEndpoint = exports.envVarClientSecret = exports.envVarClientId = exports.envVarConfigFile = exports.envVarVersion = exports.envVarOtelTracesURL = exports.envVarCredsBaseURL = exports.envVarSelfRefURL = exports.envVarSDKApiBaseURL = exports.envVarCronApiBaseURL = exports.envVarPlatformApiBaseURL = exports.envVarOrgSlug = exports.envVarProjectId = exports.envVarEnvironmentName = exports.envVarEnvId = exports.envVarOrgId = void 0;
16
- //TODO(@teo): remove this file, it is implemented in the src/internal/constants.ts directory now.
17
- // This file contains constants used in the Versori DSL HTTP client.
18
- exports.envVarOrgId = 'RUN_ORGANISATION_ID';
19
- exports.envVarEnvId = 'RUN_ENVIRONMENT_ID';
20
- exports.envVarEnvironmentName = 'RUN_ENVIRONMENT';
21
- exports.envVarProjectId = 'RUN_SERVICE_ID';
22
- exports.envVarOrgSlug = 'RUN_ORGANISATION_SLUG';
23
- exports.envVarPlatformApiBaseURL = 'RUN_PLATFORM_API_INTERNAL_URL';
24
- exports.envVarCronApiBaseURL = 'RUN_CRON_API_INTERNAL_URL';
25
- exports.envVarSDKApiBaseURL = 'RUN_SDK_API_URL';
26
- exports.envVarSelfRefURL = 'RUN_SELF_REF_URL';
27
- exports.envVarCredsBaseURL = 'RUN_CREDENTIALS_SERVICE_INTERNAL_URL';
28
- exports.envVarOtelTracesURL = 'RUN_OTEL_TRACES_URL';
29
- exports.envVarVersion = 'RUN_SERVICE_VERSION';
30
- // The following environment variables are used for the config file
31
- exports.envVarConfigFile = 'RUN_CONFIG_FILE';
32
- // The following environment variables are used for internal authentication
33
- exports.envVarClientId = 'RUN_CLIENT_ID';
34
- exports.envVarClientSecret = 'RUN_CLIENT_SECRET';
35
- exports.envVarTokenEndpoint = 'RUN_TOKEN_ENDPOINT';
36
- exports.envVarInternalToken = 'RUN_INTERNAL_TOKEN';
37
- // The following are for running locally
38
- exports.envVarLocalRun = 'RUN_LOCAL';
39
- // please no changerino
40
- exports.cronPort = 3001; // The port on which the cron API communicates with the service
@@ -1,15 +0,0 @@
1
- type internalAuthHeader = {
2
- [key: string]: string;
3
- };
4
- export declare class InternalAuth {
5
- private clientId;
6
- private clientSecret;
7
- private tokenEndpoint;
8
- private runLocal;
9
- private accessToken;
10
- private expiresAt;
11
- constructor();
12
- getAuthHeader(): Promise<internalAuthHeader>;
13
- }
14
- export {};
15
- //# sourceMappingURL=internalauth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internalauth.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/internalauth.ts"],"names":[],"mappings":"AAsBA,KAAK,kBAAkB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEpD,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAU;IAE1B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;;IAkCpB,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC;CA0BrD"}
@@ -1,106 +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.InternalAuth = void 0;
16
- const cli_js_1 = require("./cli.js");
17
- const constants_js_1 = require("./constants.js");
18
- class InternalAuth {
19
- constructor() {
20
- Object.defineProperty(this, "clientId", {
21
- enumerable: true,
22
- configurable: true,
23
- writable: true,
24
- value: void 0
25
- });
26
- Object.defineProperty(this, "clientSecret", {
27
- enumerable: true,
28
- configurable: true,
29
- writable: true,
30
- value: void 0
31
- });
32
- Object.defineProperty(this, "tokenEndpoint", {
33
- enumerable: true,
34
- configurable: true,
35
- writable: true,
36
- value: void 0
37
- });
38
- Object.defineProperty(this, "runLocal", {
39
- enumerable: true,
40
- configurable: true,
41
- writable: true,
42
- value: void 0
43
- });
44
- Object.defineProperty(this, "accessToken", {
45
- enumerable: true,
46
- configurable: true,
47
- writable: true,
48
- value: void 0
49
- });
50
- Object.defineProperty(this, "expiresAt", {
51
- enumerable: true,
52
- configurable: true,
53
- writable: true,
54
- value: void 0
55
- });
56
- this.clientId = Deno.env.get(constants_js_1.envVarClientId) || '';
57
- this.clientSecret = Deno.env.get(constants_js_1.envVarClientSecret) || '';
58
- this.tokenEndpoint = Deno.env.get(constants_js_1.envVarTokenEndpoint) || '';
59
- this.accessToken = '';
60
- this.expiresAt = 0;
61
- this.runLocal = Deno.env.get(constants_js_1.envVarLocalRun) === 'true';
62
- if (Deno.env.get(constants_js_1.envVarInternalToken)) {
63
- this.accessToken = Deno.env.get(constants_js_1.envVarInternalToken) || '';
64
- this.expiresAt = Date.now() + 365 * 24 * 60 * 60 * 1000; // expires in 1 year
65
- console.log(`Using static token provided by ${constants_js_1.envVarInternalToken}`);
66
- return;
67
- }
68
- if (this.runLocal) {
69
- console.info('Running in local mode using cookie for authentication');
70
- this.accessToken = (0, cli_js_1.getVersoriCookie)();
71
- return;
72
- }
73
- if (!this.clientId || !this.clientSecret || !this.tokenEndpoint) {
74
- const missingVars = [];
75
- if (!this.clientId)
76
- missingVars.push(constants_js_1.envVarClientId);
77
- if (!this.clientSecret)
78
- missingVars.push(constants_js_1.envVarClientSecret);
79
- if (!this.tokenEndpoint)
80
- missingVars.push(constants_js_1.envVarTokenEndpoint);
81
- throw new Error(`Missing environment variables: ${missingVars.join(', ')}`);
82
- }
83
- }
84
- async getAuthHeader() {
85
- if (this.runLocal) {
86
- return { 'Cookie': this.accessToken };
87
- }
88
- if (this.accessToken && this.expiresAt > Date.now()) {
89
- return { 'X-Versori-Internal-Token': this.accessToken };
90
- }
91
- const encoded = btoa(`${this.clientId}:${this.clientSecret}`);
92
- const response = await fetch(this.tokenEndpoint, {
93
- method: 'POST',
94
- headers: {
95
- 'Content-Type': 'application/x-www-form-urlencoded',
96
- Authorization: `Basic ${encoded}`,
97
- },
98
- body: `grant_type=client_credentials`,
99
- });
100
- const data = await response.json();
101
- this.accessToken = data.access_token;
102
- this.expiresAt = Date.now() + data.expires_in * 1000 - 2 * 60 * 1000; // 2 minutes before expiration
103
- return { 'X-Versori-Internal-Token': this.accessToken };
104
- }
105
- }
106
- exports.InternalAuth = InternalAuth;
@@ -1,23 +0,0 @@
1
- import { Logger } from '../../../observability/mod.js';
2
- import { PlatformApi } from '../../../services/platform/mod.js';
3
- import { BaseUrlFetcher, ConfigReader, DynamicFetcher, RoundTripperFactory } from '../types.js';
4
- import { CredentialsProvider } from './contextcredentials.js';
5
- export declare class ProxyRoundTripper implements RoundTripperFactory {
6
- private platformApiBaseUrl;
7
- private cfgReader;
8
- private platformApi;
9
- private internalAuth;
10
- private log;
11
- private organisationId;
12
- private envId;
13
- constructor(log: Logger, platformApiBaseUrl: string, platformApi: PlatformApi, cfgReader: ConfigReader, orgId: string, envId: string);
14
- static fromEnv(log: Logger): ProxyRoundTripper;
15
- private makeProxyUrlString;
16
- private makeProxyInput;
17
- private makeProxyInit;
18
- create(connName: string): Promise<typeof fetch | undefined>;
19
- createDynamic(templateName: string): Promise<DynamicFetcher | undefined>;
20
- credentials(): CredentialsProvider;
21
- baseUrlFetcher(_templateName: string): BaseUrlFetcher;
22
- }
23
- //# sourceMappingURL=proxyroundtripper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"proxyroundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/proxyroundtripper.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAmB,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAEH,cAAc,EACd,YAAY,EACZ,cAAc,EACd,mBAAmB,EACtB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAU9D,qBAAa,iBAAkB,YAAW,mBAAmB;IACzD,OAAO,CAAC,kBAAkB,CAAS;IAEnC,OAAO,CAAC,SAAS,CAAe;IAEhC,OAAO,CAAC,WAAW,CAAc;IAEjC,OAAO,CAAC,YAAY,CAAe;IAEnC,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,KAAK,CAAS;gBAGlB,GAAG,EAAE,MAAM,EACX,kBAAkB,EAAE,MAAM,EAC1B,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,YAAY,EACvB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM;IAWjB,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB;IA2B9C,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,cAAc;YA6BR,aAAa;IA4B3B,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,GAAG,SAAS,CAAC;IAoB3D,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAwCxE,WAAW,IAAI,mBAAmB;IAoBlC,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc;CAKxD"}