@versori/run 0.2.4-alpha.1 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/{script/deps/jsr.io/@std/fs/1.0.17 → esm/deps/jsr.io/@std/fs/1.0.18}/exists.d.ts.map +1 -1
  2. package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +1 -1
  3. package/esm/src/dsl/http/types.d.ts +3 -0
  4. package/esm/src/dsl/http/types.d.ts.map +1 -1
  5. package/esm/src/dsl/http/versori/cli.d.ts +2 -0
  6. package/esm/src/dsl/http/versori/cli.d.ts.map +1 -0
  7. package/esm/src/dsl/http/versori/cli.js +20 -0
  8. package/esm/src/dsl/http/versori/constants.d.ts +1 -0
  9. package/esm/src/dsl/http/versori/constants.d.ts.map +1 -1
  10. package/esm/src/dsl/http/versori/constants.js +2 -0
  11. package/esm/src/dsl/http/versori/cronapi.d.ts +8 -0
  12. package/esm/src/dsl/http/versori/cronapi.d.ts.map +1 -1
  13. package/esm/src/dsl/http/versori/cronapi.js +35 -3
  14. package/esm/src/dsl/http/versori/helpers.d.ts +2 -0
  15. package/esm/src/dsl/http/versori/helpers.d.ts.map +1 -0
  16. package/esm/src/dsl/http/versori/helpers.js +9 -0
  17. package/esm/src/dsl/http/versori/internalauth.d.ts +6 -1
  18. package/esm/src/dsl/http/versori/internalauth.d.ts.map +1 -1
  19. package/esm/src/dsl/http/versori/internalauth.js +20 -4
  20. package/esm/src/dsl/http/versori/platformapi.d.ts +1 -0
  21. package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -1
  22. package/esm/src/dsl/http/versori/platformapi.js +24 -16
  23. package/esm/src/dsl/http/versori/proxyroundtripper.d.ts +22 -0
  24. package/esm/src/dsl/http/versori/proxyroundtripper.d.ts.map +1 -0
  25. package/esm/src/dsl/http/versori/proxyroundtripper.js +179 -0
  26. package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
  27. package/esm/src/dsl/http/versori/roundtripper.js +1 -9
  28. package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  29. package/esm/src/interpreter/memory/MemoryInterpreter.js +25 -7
  30. package/esm/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  31. package/esm/src/interpreter/memory/compilers/schedule.js +2 -1
  32. package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  33. package/esm/src/interpreter/memory/compilers/webhook.js +7 -3
  34. package/package.json +1 -1
  35. package/{esm/deps/jsr.io/@std/fs/1.0.17 → script/deps/jsr.io/@std/fs/1.0.18}/exists.d.ts.map +1 -1
  36. package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +1 -1
  37. package/script/src/dsl/http/types.d.ts +3 -0
  38. package/script/src/dsl/http/types.d.ts.map +1 -1
  39. package/script/src/dsl/http/versori/cli.d.ts +2 -0
  40. package/script/src/dsl/http/versori/cli.d.ts.map +1 -0
  41. package/script/src/dsl/http/versori/cli.js +23 -0
  42. package/script/src/dsl/http/versori/constants.d.ts +1 -0
  43. package/script/src/dsl/http/versori/constants.d.ts.map +1 -1
  44. package/script/src/dsl/http/versori/constants.js +3 -1
  45. package/script/src/dsl/http/versori/cronapi.d.ts +8 -0
  46. package/script/src/dsl/http/versori/cronapi.d.ts.map +1 -1
  47. package/script/src/dsl/http/versori/cronapi.js +34 -2
  48. package/script/src/dsl/http/versori/helpers.d.ts +2 -0
  49. package/script/src/dsl/http/versori/helpers.d.ts.map +1 -0
  50. package/script/src/dsl/http/versori/helpers.js +12 -0
  51. package/script/src/dsl/http/versori/internalauth.d.ts +6 -1
  52. package/script/src/dsl/http/versori/internalauth.d.ts.map +1 -1
  53. package/script/src/dsl/http/versori/internalauth.js +19 -3
  54. package/script/src/dsl/http/versori/platformapi.d.ts +1 -0
  55. package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -1
  56. package/script/src/dsl/http/versori/platformapi.js +24 -16
  57. package/script/src/dsl/http/versori/proxyroundtripper.d.ts +22 -0
  58. package/script/src/dsl/http/versori/proxyroundtripper.d.ts.map +1 -0
  59. package/script/src/dsl/http/versori/proxyroundtripper.js +183 -0
  60. package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
  61. package/script/src/dsl/http/versori/roundtripper.js +4 -12
  62. package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
  63. package/script/src/interpreter/memory/MemoryInterpreter.js +24 -6
  64. package/script/src/interpreter/memory/compilers/schedule.d.ts.map +1 -1
  65. package/script/src/interpreter/memory/compilers/schedule.js +2 -1
  66. package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
  67. package/script/src/interpreter/memory/compilers/webhook.js +7 -3
  68. /package/esm/deps/jsr.io/@std/fs/{1.0.17 → 1.0.18}/exists.d.ts +0 -0
  69. /package/esm/deps/jsr.io/@std/fs/{1.0.17 → 1.0.18}/exists.js +0 -0
  70. /package/script/deps/jsr.io/@std/fs/{1.0.17 → 1.0.18}/exists.d.ts +0 -0
  71. /package/script/deps/jsr.io/@std/fs/{1.0.17 → 1.0.18}/exists.js +0 -0
@@ -4,6 +4,7 @@ import { LoadConfigFromFile } from './configloader.js';
4
4
  import { envVarCredsBaseURL, envVarEnvId, envVarOrgId, envVarPlatformApiBaseURL, } from './constants.js';
5
5
  import { VersoriCredentialClient } from './credentials/mod.js';
6
6
  import { PlatformAPIClient } from './platformapi.js';
7
+ import { isValidURL } from './helpers.js';
7
8
  /**
8
9
  * VersoriRoundTripper is an implementation of the RoundTripperFactory interface for Versori connections.
9
10
  * This is the intended implementation for when projects/services are hosted on Versori infrastructure.
@@ -487,12 +488,3 @@ export class VersoriCredentialsFactory {
487
488
  }
488
489
  }
489
490
  }
490
- function isValidURL(url) {
491
- try {
492
- new URL(url);
493
- return true;
494
- }
495
- catch (_) {
496
- return false;
497
- }
498
- }
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryIn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QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IAf7B,OAAO,CAAC,mBAAmB,CAA2B;IACtD,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,cAAc,CAAC,CAAa;IACpC,OAAO,CAAC,cAAc,CAAS;gBAGV,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,kBAAkB,EAC5B,eAAe,EAAE,eAAe,EAChC,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,EAAE,MAAM,EACvB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACxB,kBAAkB,EAAE,kBAAkB,EACtC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,OAAO,YAAA;WAWzB,WAAW,CAAC,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA8E5F,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,wBAAwB;IA+C/D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAoKtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAO9B"}
@@ -7,7 +7,7 @@ import xmlparser from 'express-xml-bodyparser';
7
7
  import { catchError, EMPTY, mergeMap, of, tap } from 'rxjs';
8
8
  import { ContextProviderImpl } from '../../context/ContextProvider.js';
9
9
  import { DefaultRoundTripperFactory } from '../../dsl/http/default.js';
10
- import { envVarEnvId, envVarEnvironmentName, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion, } from '../../dsl/http/versori/constants.js';
10
+ import { envVarEnvId, envVarEnvironmentName, envVarLocalRun, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion, } from '../../dsl/http/versori/constants.js';
11
11
  import { CronAPIClient } from '../../dsl/http/versori/cronapi.js';
12
12
  import { PlatformAPIClient } from '../../dsl/http/versori/platformapi.js';
13
13
  import { VersoriCredentialsFactory } from '../../dsl/http/versori/roundtripper.js';
@@ -16,6 +16,24 @@ import { MemoryKeyValueProvider } from '../../kv/memory/MemoryKeyValueProvider.j
16
16
  import { NatsKeyValueProvider } from '../../kv/nats/NatsKeyValueProvider.js';
17
17
  import { ConsoleLogger } from '../../observability/logging/ConsoleLogger.js';
18
18
  import { ObservableCompiler } from './ObservableCompiler.js';
19
+ import { ProxyRoundTripper } from '../../dsl/http/versori/proxyroundtripper.js';
20
+ function getKVProvider(runLocal) {
21
+ if (runLocal) {
22
+ return Promise.resolve(new MemoryKeyValueProvider());
23
+ }
24
+ return NatsKeyValueProvider.fromEnv();
25
+ }
26
+ function getRoundTripperFactory(log, tracer, opts) {
27
+ if (opts && opts.runLocal) {
28
+ log.info('Running in local mode, using ProxyRoundTripperFactory');
29
+ return ProxyRoundTripper.fromEnv(log);
30
+ }
31
+ if (!opts || !opts.skipVersoriCredentials) {
32
+ return VersoriCredentialsFactory.fromEnv(log, tracer);
33
+ }
34
+ log.info('Running with default round tripper factory');
35
+ return new DefaultRoundTripperFactory();
36
+ }
19
37
  export class MemoryInterpreter {
20
38
  constructor(log, compiler, contextProvider, roundTripperFactory, router, cronRegistry, connectionProvider, cronProvider, tracer, otelSDK) {
21
39
  Object.defineProperty(this, "log", {
@@ -119,6 +137,7 @@ export class MemoryInterpreter {
119
137
  const orgSlug = Deno.env.get(envVarOrgSlug) || 'development';
120
138
  const otelTracesURL = Deno.env.get(envVarOtelTracesURL);
121
139
  let otelSDK;
140
+ const runLocal = Deno.env.get(envVarLocalRun) === 'true';
122
141
  // Do NOT change those attributes, they are used by the API to filter on
123
142
  const resource = resourceFromAttributes({
124
143
  'service.id': serviceName,
@@ -140,17 +159,16 @@ export class MemoryInterpreter {
140
159
  otelSDK.start();
141
160
  }
142
161
  const tracer = opentelemetry.trace.getTracer(serviceName, version);
143
- const roundTripperFactory = options.skipVersoriCredentials
144
- ? new DefaultRoundTripperFactory()
145
- : VersoriCredentialsFactory.fromEnv(log, tracer);
162
+ const roundTripperFactory = getRoundTripperFactory(log, tracer, {
163
+ skipVersoriCredentials: options.skipVersoriCredentials,
164
+ runLocal: runLocal,
165
+ });
146
166
  if (options.contextProvider) {
147
167
  // no need to set up a key-value provider if options.contextProvider is already
148
168
  // initialised.
149
169
  return new MemoryInterpreter(log, compiler, options.contextProvider, roundTripperFactory, express.Router(), new Map(), PlatformAPIClient.fromEnv(), CronAPIClient.fromEnv(), tracer, otelSDK);
150
170
  }
151
- const kvp = await (options.skipVersoriCredentials
152
- ? new MemoryKeyValueProvider()
153
- : NatsKeyValueProvider.fromEnv());
171
+ const kvp = await getKVProvider(runLocal);
154
172
  return new MemoryInterpreter(log, compiler, new ContextProviderImpl(log, kvp, roundTripperFactory.credentials()), roundTripperFactory, express.Router(), new Map(), PlatformAPIClient.fromEnv(), CronAPIClient.fromEnv(), tracer, otelSDK);
155
173
  }
156
174
  register(workflow, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA0H7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
1
+ {"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/schedule.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA4H7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,YAAY,EAAE,eAAe,CAG3E,CAAC"}
@@ -16,7 +16,8 @@ function compileSchedule(ctx, trigger, signal) {
16
16
  async function handleSchedule(req, res, span) {
17
17
  try {
18
18
  if (trigger.activationPredicate === undefined) {
19
- const executionCtx = ctx.contextProvider.create({}, undefined);
19
+ const activation = await client.getStaticActivation();
20
+ const executionCtx = ctx.contextProvider.create({}, { activation });
20
21
  span.setAttribute('execution.id', executionCtx.executionId);
21
22
  try {
22
23
  subscriber.next(executionCtx);
@@ -1 +1 @@
1
- {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAgD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CAyPxE,CAAC"}
1
+ {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../../src/src/interpreter/memory/compilers/webhook.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAgD7C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,WAAW,EAAE,cAAc,CA+PxE,CAAC"}
@@ -80,11 +80,15 @@ export const webhookCompiler = {
80
80
  }
81
81
  }
82
82
  // endpoint for sans user because I'm not quite sure how the dynamic routing works
83
- ctx.router.post(`/${trigger.id}`, (req, res) => {
84
- ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, (span) => {
83
+ ctx.router.post(`/${trigger.id}`, async (req, res) => {
84
+ await ctx.tracer.startActiveSpan(`webhook-${trigger.id}`, async (span) => {
85
85
  span.setAttribute('task.id', trigger.id);
86
86
  span.setAttribute('task.type', 'webhook');
87
- const executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
87
+ let executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
88
+ const activation = await ctx.connectionProvider.getStaticActivation();
89
+ if (activation) {
90
+ executionCtx = executionCtx.withActivation(activation);
91
+ }
88
92
  span.setAttribute('execution.id', executionCtx.executionId);
89
93
  try {
90
94
  subscriber.next(executionCtx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versori/run",
3
- "version": "v0.2.4-alpha.1",
3
+ "version": "v0.2.6",
4
4
  "description": "Versori Run",
5
5
  "homepage": "https://github.com/versori/versori-run#readme",
6
6
  "repository": {
@@ -1 +1 @@
1
- {"version":3,"file":"exists.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/fs/1.0.17/exists.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,OAAO,CAAC,CAsClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+FG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAqCT"}
1
+ {"version":3,"file":"exists.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/fs/1.0.18/exists.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,OAAO,CAAC,CAsClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+FG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAqCT"}
@@ -13,7 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  var _RotatingFileHandler_maxBytes, _RotatingFileHandler_maxBackupCount, _RotatingFileHandler_currentFileSize;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.RotatingFileHandler = void 0;
16
- const exists_js_1 = require("../../fs/1.0.17/exists.js");
16
+ const exists_js_1 = require("../../fs/1.0.18/exists.js");
17
17
  const file_handler_js_1 = require("./file_handler.js");
18
18
  const _file_handler_symbols_js_1 = require("./_file_handler_symbols.js");
19
19
  /**
@@ -1,7 +1,9 @@
1
+ import { Credentials } from './versori/contextcredentials.js';
1
2
  export type DynamicFetcher = (activation: Activation, input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
2
3
  export interface RoundTripperFactory {
3
4
  create(connName: string): Promise<typeof fetch | undefined>;
4
5
  createDynamic(templateName: string): Promise<DynamicFetcher | undefined>;
6
+ credentials(): Credentials;
5
7
  }
6
8
  export declare function wrapDynamicFetcher(fetcher: DynamicFetcher, activation: Activation): typeof fetch;
7
9
  export interface ConnectionProvider {
@@ -9,6 +11,7 @@ export interface ConnectionProvider {
9
11
  getUserActivations(userId: string): Promise<Activation[]>;
10
12
  getActivationConnection(templateId: string, activationId: string): Promise<Connection | undefined>;
11
13
  getActivation(activationId: string): Promise<Activation | undefined>;
14
+ getStaticActivation(): Promise<Activation | undefined>;
12
15
  listActivations(): Promise<Activation[]>;
13
16
  updateDynamicVariable(activationId: string, name: string, value: unknown): Promise<void>;
14
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/src/dsl/http/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEzH,MAAM,WAAW,mBAAmB;IAChC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,GAAG,SAAS,CAAC,CAAC;IAC5D,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;CAC5E;AAGD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,KAAK,CAIhG;AAED,MAAM,WAAW,kBAAkB;IAC/B,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IACpE,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1D,uBAAuB,CAAC,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E,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE;QACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACtB,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC3B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function getVersoriCookie(): string;
2
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/cli.ts"],"names":[],"mappings":"AAiBA,wBAAgB,gBAAgB,IAAI,MAAM,CAoBzC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ // This file contains functions that can read stuff generated by the Versori CLI. This is used when running locally.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getVersoriCookie = getVersoriCookie;
5
+ const node_os_1 = require("node:os");
6
+ const cookiesFileName = 'cookies.json';
7
+ const versoriCookieName = 'versori_sess';
8
+ function getVersoriCookie() {
9
+ const cookiesFilePath = `${(0, node_os_1.homedir)()}/.config/versori/${cookiesFileName}`;
10
+ let cookiesFile;
11
+ try {
12
+ cookiesFile = JSON.parse(Deno.readTextFileSync(cookiesFilePath));
13
+ }
14
+ catch (e) {
15
+ console.error('Error reading file, have you run the Versori CLI to log in?');
16
+ throw new Error(`Failed to read or parse cookies file at ${cookiesFilePath}: ${e}`);
17
+ }
18
+ const versoriCookie = cookiesFile.cookies.find(cookie => cookie.Name === versoriCookieName);
19
+ if (!versoriCookie) {
20
+ throw new Error(`Cookie 'versori_sess' not found in ${cookiesFilePath}`);
21
+ }
22
+ return `${versoriCookieName}=${versoriCookie.Value}`;
23
+ }
@@ -14,4 +14,5 @@ export declare const envVarClientId = "RUN_CLIENT_ID";
14
14
  export declare const envVarClientSecret = "RUN_CLIENT_SECRET";
15
15
  export declare const envVarTokenEndpoint = "RUN_TOKEN_ENDPOINT";
16
16
  export declare const envVarInternalToken = "RUN_INTERNAL_TOKEN";
17
+ export declare const envVarLocalRun = "RUN_LOCAL";
17
18
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,wBAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAChD,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AACrD,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AACxE,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,aAAa,wBAAwB,CAAC;AAEnD,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAGlD,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AACxD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,wBAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAChD,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AACrD,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AACxE,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AACzE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,aAAa,wBAAwB,CAAC;AAEnD,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAGlD,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AACxD,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AAGxD,eAAO,MAAM,cAAc,cAAc,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.envVarInternalToken = exports.envVarTokenEndpoint = exports.envVarClientSecret = exports.envVarClientId = exports.envVarConfigFile = exports.envVarVersion = exports.envVarOtelTracesURL = exports.envVarCredsBaseURL = exports.envVarSelfRefURL = exports.envVarCronApiBaseURL = exports.envVarPlatformApiBaseURL = exports.envVarOrgSlug = exports.envVarProjectId = exports.envVarEnvironmentName = exports.envVarEnvId = exports.envVarOrgId = void 0;
3
+ exports.envVarLocalRun = exports.envVarInternalToken = exports.envVarTokenEndpoint = exports.envVarClientSecret = exports.envVarClientId = exports.envVarConfigFile = exports.envVarVersion = exports.envVarOtelTracesURL = exports.envVarCredsBaseURL = exports.envVarSelfRefURL = exports.envVarCronApiBaseURL = exports.envVarPlatformApiBaseURL = exports.envVarOrgSlug = exports.envVarProjectId = exports.envVarEnvironmentName = exports.envVarEnvId = exports.envVarOrgId = void 0;
4
4
  // This file contains constants used in the Versori DSL HTTP client.
5
5
  exports.envVarOrgId = 'RUN_ORGANISATION_ID';
6
6
  exports.envVarEnvId = 'RUN_ENVIRONMENT_ID';
@@ -20,3 +20,5 @@ exports.envVarClientId = 'RUN_CLIENT_ID';
20
20
  exports.envVarClientSecret = 'RUN_CLIENT_SECRET';
21
21
  exports.envVarTokenEndpoint = 'RUN_TOKEN_ENDPOINT';
22
22
  exports.envVarInternalToken = 'RUN_INTERNAL_TOKEN';
23
+ // The following are for running locally
24
+ exports.envVarLocalRun = 'RUN_LOCAL';
@@ -1,10 +1,18 @@
1
1
  import { CronProvider } from '../types.js';
2
+ type Cron = {
3
+ name: string;
4
+ schedule: string;
5
+ url: string;
6
+ };
2
7
  export declare class CronAPIClient implements CronProvider {
3
8
  private baseUrl;
4
9
  private envId;
5
10
  private integrationUrl;
11
+ private runLocal;
6
12
  constructor(baseUrl: string, envId: string, integrationUrl: string);
7
13
  static fromEnv(): CronAPIClient;
8
14
  updateCrons(crons: Map<string, string>): Promise<void>;
15
+ runLocalFn(crons: Cron[]): void;
9
16
  }
17
+ export {};
10
18
  //# sourceMappingURL=cronapi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cronapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/cronapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,qBAAa,aAAc,YAAW,YAAY;IAC9C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,cAAc,CAAS;gBAG3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM;IAO1B,MAAM,CAAC,OAAO,IAAI,aAAa;IAgBzB,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAe/D"}
1
+ {"version":3,"file":"cronapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/cronapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAW3C,KAAK,IAAI,GAAG;IACR,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,aAAc,YAAW,YAAY;IAC9C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAU;gBAEd,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAOlE,MAAM,CAAC,OAAO,IAAI,aAAa;IAmBzB,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB5D,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE;CAoB3B"}
@@ -22,9 +22,16 @@ class CronAPIClient {
22
22
  writable: true,
23
23
  value: void 0
24
24
  });
25
+ Object.defineProperty(this, "runLocal", {
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true,
29
+ value: void 0
30
+ });
25
31
  this.baseUrl = baseUrl;
26
32
  this.envId = envId;
27
33
  this.integrationUrl = integrationUrl;
34
+ this.runLocal = Deno.env.get(constants_js_1.envVarLocalRun) === 'true';
28
35
  }
29
36
  static fromEnv() {
30
37
  const baseUrl = Deno.env.get(constants_js_1.envVarCronApiBaseURL) || 'http://cron-api.platform.svc.cluster.local';
@@ -35,11 +42,20 @@ class CronAPIClient {
35
42
  if (!baseUrl || !envId || !projectId || !orgSlug || !envName) {
36
43
  throw new Error('Missing required environment variables');
37
44
  }
38
- const integrationUrl = Deno.env.get(constants_js_1.envVarSelfRefURL) || `http://svc-${projectId.toLowerCase()}-${envName.toLowerCase()}.sb-${orgSlug.toLowerCase()}.svc.cluster.local`;
45
+ const integrationUrl = Deno.env.get(constants_js_1.envVarSelfRefURL) ||
46
+ `http://svc-${projectId.toLowerCase()}-${envName.toLowerCase()}.sb-${orgSlug.toLowerCase()}.svc.cluster.local`;
39
47
  return new CronAPIClient(baseUrl, envId, integrationUrl);
40
48
  }
41
49
  async updateCrons(crons) {
42
- const cronsArray = Array.from(crons.entries()).map(([name, schedule]) => ({ name, schedule, url: `${this.integrationUrl}/cron/${name}` }));
50
+ const cronsArray = Array.from(crons.entries()).map(([name, schedule]) => ({
51
+ name,
52
+ schedule,
53
+ url: `${this.integrationUrl}/cron/${name}`,
54
+ }));
55
+ if (this.runLocal) {
56
+ this.runLocalFn(cronsArray);
57
+ return;
58
+ }
43
59
  const resp = await fetch(`${this.baseUrl}/cron/environments/${this.envId}`, {
44
60
  method: 'PUT',
45
61
  headers: {
@@ -51,5 +67,21 @@ class CronAPIClient {
51
67
  throw new Error(`Failed to update crons: ${resp.statusText}`);
52
68
  }
53
69
  }
70
+ runLocalFn(crons) {
71
+ if (crons.length === 0) {
72
+ return;
73
+ }
74
+ console.log('----------------------------------------');
75
+ console.log('Running in local mode, your scheduler workflows will not trigger automatically.');
76
+ console.log('Instead you can trigger them by sending a request to the following URLs:');
77
+ crons.forEach((cron) => {
78
+ const url = new URL(cron.url);
79
+ url.protocol = 'http';
80
+ url.port = '3000';
81
+ url.hostname = 'localhost';
82
+ console.log(`- ${cron.name}: POST ${url.toString()} (Schedule: ${cron.schedule})`);
83
+ });
84
+ console.log('----------------------------------------');
85
+ }
54
86
  }
55
87
  exports.CronAPIClient = CronAPIClient;
@@ -0,0 +1,2 @@
1
+ export declare function isValidURL(url: string): boolean;
2
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAO/C"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidURL = isValidURL;
4
+ function isValidURL(url) {
5
+ try {
6
+ new URL(url);
7
+ return true;
8
+ }
9
+ catch (_) {
10
+ return false;
11
+ }
12
+ }
@@ -1,10 +1,15 @@
1
+ type internalAuthHeader = {
2
+ [key: string]: string;
3
+ };
1
4
  export declare class InternalAuth {
2
5
  private clientId;
3
6
  private clientSecret;
4
7
  private tokenEndpoint;
8
+ private runLocal;
5
9
  private accessToken;
6
10
  private expiresAt;
7
11
  constructor();
8
- getToken(): Promise<string>;
12
+ getAuthHeader(): Promise<internalAuthHeader>;
9
13
  }
14
+ export {};
10
15
  //# sourceMappingURL=internalauth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"internalauth.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/internalauth.ts"],"names":[],"mappings":"AAEA,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;;IA2BpB,QAAQ;CAsBjB"}
1
+ {"version":3,"file":"internalauth.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/internalauth.ts"],"names":[],"mappings":"AASA,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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InternalAuth = void 0;
4
+ const cli_js_1 = require("./cli.js");
4
5
  const constants_js_1 = require("./constants.js");
5
6
  class InternalAuth {
6
7
  constructor() {
@@ -22,6 +23,12 @@ class InternalAuth {
22
23
  writable: true,
23
24
  value: void 0
24
25
  });
26
+ Object.defineProperty(this, "runLocal", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: void 0
31
+ });
25
32
  Object.defineProperty(this, "accessToken", {
26
33
  enumerable: true,
27
34
  configurable: true,
@@ -39,6 +46,12 @@ class InternalAuth {
39
46
  this.tokenEndpoint = Deno.env.get(constants_js_1.envVarTokenEndpoint) || '';
40
47
  this.accessToken = '';
41
48
  this.expiresAt = 0;
49
+ this.runLocal = Deno.env.get(constants_js_1.envVarLocalRun) === 'true';
50
+ if (this.runLocal) {
51
+ console.info('Running in local mode using cookie for authentication');
52
+ this.accessToken = (0, cli_js_1.getVersoriCookie)();
53
+ return;
54
+ }
42
55
  if (Deno.env.get(constants_js_1.envVarInternalToken)) {
43
56
  this.accessToken = Deno.env.get(constants_js_1.envVarInternalToken) || '';
44
57
  this.expiresAt = Date.now() + 365 * 24 * 60 * 60 * 1000; // expires in 1 year
@@ -56,9 +69,12 @@ class InternalAuth {
56
69
  throw new Error(`Missing environment variables: ${missingVars.join(', ')}`);
57
70
  }
58
71
  }
59
- async getToken() {
72
+ async getAuthHeader() {
73
+ if (this.runLocal) {
74
+ return { 'Cookie': this.accessToken };
75
+ }
60
76
  if (this.accessToken && this.expiresAt > Date.now()) {
61
- return this.accessToken;
77
+ return { 'X-Versori-Internal-Token': this.accessToken };
62
78
  }
63
79
  const encoded = btoa(`${this.clientId}:${this.clientSecret}`);
64
80
  const response = await fetch(this.tokenEndpoint, {
@@ -72,7 +88,7 @@ class InternalAuth {
72
88
  const data = await response.json();
73
89
  this.accessToken = data.access_token;
74
90
  this.expiresAt = Date.now() + data.expires_in * 1000 - 2 * 60 * 1000; // 2 minutes before expiration
75
- return this.accessToken;
91
+ return { 'X-Versori-Internal-Token': this.accessToken };
76
92
  }
77
93
  }
78
94
  exports.InternalAuth = InternalAuth;
@@ -10,6 +10,7 @@ export declare class PlatformAPIClient implements ConnectionProvider {
10
10
  static fromEnv(): PlatformAPIClient;
11
11
  getStaticConnection(cnxId: string): Promise<Connection | undefined>;
12
12
  getUserActivations(userId: string): Promise<Activation[]>;
13
+ getStaticActivation(): Promise<Activation | undefined>;
13
14
  getActivation(activationId: string): Promise<Activation | undefined>;
14
15
  getActivationConnection(templateId: string, activationId: string): Promise<Connection | undefined>;
15
16
  listActivations(): Promise<Activation[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"platformapi.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/platformapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAmBzE,qBAAa,iBAAkB,YAAW,kBAAkB;IACxD,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,KAAK,CAAS;IAEtB,OAAO,CAAC,KAAK,CAAS;IAEtB,OAAO,CAAC,YAAY,CAAe;IAEnC,OAAO,CAAC,GAAG,CAAS;gBAER,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAQtE,MAAM,CAAC,OAAO,IAAI,iBAAiB;IAa7B,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BAAmB,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAoBtD,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAmBpE,uBAAuB,CACzB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACrB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAmB5B,eAAe,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAuBxC,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAuBjG"}
@@ -54,10 +54,9 @@ class PlatformAPIClient {
54
54
  return new PlatformAPIClient(baseUrl, orgId, envId, log);
55
55
  }
56
56
  async getStaticConnection(cnxId) {
57
+ const authHeader = await this.internalAuth.getAuthHeader();
57
58
  const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/connections/${cnxId}`, {
58
- headers: {
59
- 'x-versori-internal-token': await this.internalAuth.getToken(),
60
- },
59
+ headers: authHeader,
61
60
  });
62
61
  if (!resp.ok) {
63
62
  return undefined;
@@ -66,10 +65,9 @@ class PlatformAPIClient {
66
65
  return result;
67
66
  }
68
67
  async getUserActivations(userId) {
68
+ const authHeader = await this.internalAuth.getAuthHeader();
69
69
  const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environment/${this.envId}/users/${userId}/activations`, {
70
- headers: {
71
- 'x-versori-internal-token': await this.internalAuth.getToken(),
72
- },
70
+ headers: authHeader,
73
71
  });
74
72
  if (!resp.ok) {
75
73
  return [];
@@ -80,11 +78,22 @@ class PlatformAPIClient {
80
78
  });
81
79
  return result;
82
80
  }
81
+ async getStaticActivation() {
82
+ const authHeader = await this.internalAuth.getAuthHeader();
83
+ const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environments/${this.envId}/activations?static=true`, {
84
+ headers: authHeader,
85
+ });
86
+ if (!resp.ok) {
87
+ return undefined;
88
+ }
89
+ const _acts = (await resp.json());
90
+ const act = _acts[0];
91
+ return new activation_js_1.ActivationImpl(act.id, act.user, this, this.log, act.dynamicVariables);
92
+ }
83
93
  async getActivation(activationId) {
94
+ const authHeader = await this.internalAuth.getAuthHeader();
84
95
  const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environments/${this.envId}/activations/${activationId}`, {
85
- headers: {
86
- 'x-versori-internal-token': await this.internalAuth.getToken(),
87
- },
96
+ headers: authHeader,
88
97
  });
89
98
  if (!resp.ok) {
90
99
  return undefined;
@@ -93,10 +102,9 @@ class PlatformAPIClient {
93
102
  return new activation_js_1.ActivationImpl(act.id, act.user, this, this.log, act.dynamicVariables);
94
103
  }
95
104
  async getActivationConnection(templateId, activationId) {
105
+ const authHeader = await this.internalAuth.getAuthHeader();
96
106
  const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environment-systems/${templateId}/activations/${activationId}`, {
97
- headers: {
98
- 'x-versori-internal-token': await this.internalAuth.getToken(),
99
- },
107
+ headers: authHeader,
100
108
  });
101
109
  if (!resp.ok) {
102
110
  return undefined;
@@ -105,10 +113,9 @@ class PlatformAPIClient {
105
113
  return result;
106
114
  }
107
115
  async listActivations() {
116
+ const authHeader = await this.internalAuth.getAuthHeader();
108
117
  const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environments/${this.envId}/activations`, {
109
- headers: {
110
- 'x-versori-internal-token': await this.internalAuth.getToken(),
111
- },
118
+ headers: authHeader,
112
119
  });
113
120
  if (!resp.ok) {
114
121
  return [];
@@ -121,10 +128,11 @@ class PlatformAPIClient {
121
128
  }
122
129
  async updateDynamicVariable(activationId, name, value) {
123
130
  this.log.debug(`value is ${JSON.stringify(value)}`);
131
+ const authHeader = await this.internalAuth.getAuthHeader();
124
132
  const resp = await fetch(`${this.baseUrl}/o/${this.orgId}/environments/${this.envId}/activations/${activationId}/variables/${name}`, {
125
133
  method: 'PUT',
126
134
  headers: {
127
- 'x-versori-internal-token': await this.internalAuth.getToken(),
135
+ ...authHeader,
128
136
  'Content-Type': 'application/json',
129
137
  },
130
138
  body: JSON.stringify({
@@ -0,0 +1,22 @@
1
+ import { DynamicFetcher, RoundTripperFactory } from '../types.js';
2
+ import { PlatformAPIClient } from './platformapi.js';
3
+ import { Logger } from '../../../observability/mod.js';
4
+ import { Credentials } from './contextcredentials.js';
5
+ export declare class ProxyRoundTripper implements RoundTripperFactory {
6
+ private platformApiBaseUrl;
7
+ private versoriCfg;
8
+ private platformApiClient;
9
+ private internalAuth;
10
+ private log;
11
+ constructor(log: Logger, platformApiBaseUrl: string, platformApiClient: PlatformAPIClient);
12
+ static fromEnv(log: Logger): ProxyRoundTripper;
13
+ private getConnectionID;
14
+ private getTemplateID;
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(): Credentials;
21
+ }
22
+ //# sourceMappingURL=proxyroundtripper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxyroundtripper.d.ts","sourceRoot":"","sources":["../../../../../src/src/dsl/http/versori/proxyroundtripper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,cAAc,EAAE,mBAAmB,EAAoB,MAAM,aAAa,CAAC;AAEhG,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAGvD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAKtD,qBAAa,iBAAkB,YAAW,mBAAmB;IACzD,OAAO,CAAC,kBAAkB,CAAS;IAEnC,OAAO,CAAC,UAAU,CAAmB;IAErC,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,OAAO,CAAC,YAAY,CAAe;IAEnC,OAAO,CAAC,GAAG,CAAS;gBAGhB,GAAG,EAAE,MAAM,EACX,kBAAkB,EAAE,MAAM,EAC1B,iBAAiB,EAAE,iBAAiB;IASxC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB;IAwB9C,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,kBAAkB;IAY1B,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;IAqCxE,WAAW,IAAI,WAAW;CAc7B"}