@versori/run 0.2.10 → 0.2.12

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.
@@ -11,6 +11,8 @@ export declare class CronAPIClient implements CronProvider {
11
11
  private runLocal;
12
12
  constructor(baseUrl: string, envId: string, integrationUrl: string);
13
13
  static fromEnv(): CronAPIClient;
14
+ static addDefaultCronPort(url: string): string;
15
+ makeCronPath(name: string): string;
14
16
  updateCrons(crons: Map<string, string>): Promise<void>;
15
17
  runLocalFn(crons: Cron[]): void;
16
18
  }
@@ -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;AAY3C,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"}
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;AAY3C,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;IAoB/B,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAU9C,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAM5B,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB5D,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE;CAoB3B"}
@@ -41,13 +41,26 @@ export class CronAPIClient {
41
41
  }
42
42
  const integrationUrl = Deno.env.get(envVarSelfRefURL) ||
43
43
  `http://svc-${projectId.toLowerCase()}-${envName.toLowerCase()}.sb-${orgSlug.toLowerCase()}.svc.cluster.local:${cronPort}`;
44
- return new CronAPIClient(baseUrl, envId, integrationUrl);
44
+ return new CronAPIClient(baseUrl, envId, this.addDefaultCronPort(integrationUrl));
45
+ }
46
+ // Check if the URL has a port, if not, add the default cron port.
47
+ static addDefaultCronPort(url) {
48
+ const parsedUrl = new URL(url);
49
+ if (parsedUrl.port === '') {
50
+ parsedUrl.port = cronPort.toString();
51
+ }
52
+ return parsedUrl.toString();
53
+ }
54
+ makeCronPath(name) {
55
+ const url = new URL(this.integrationUrl);
56
+ url.pathname = `/cron/${name}`;
57
+ return url.toString();
45
58
  }
46
59
  async updateCrons(crons) {
47
60
  const cronsArray = Array.from(crons.entries()).map(([name, schedule]) => ({
48
61
  name,
49
62
  schedule,
50
- url: `${this.integrationUrl}/cron/${name}`,
63
+ url: this.makeCronPath(name),
51
64
  }));
52
65
  if (this.runLocal) {
53
66
  this.runLocalFn(cronsArray);
@@ -317,10 +317,10 @@ export class MemoryInterpreter {
317
317
  throw new Error('Unable to register scheduler tasks with central cron provider');
318
318
  }
319
319
  this.webhookServer = webhookApp.listen(port, () => {
320
- this.log.info(`Express server listening on http://localhost:${port}`);
320
+ this.log.info(`Express server listening on port ${port}`);
321
321
  });
322
322
  this.cronServer = cronApp.listen(cronPort, () => {
323
- this.log.info(`Cron server listening on http://localhost:${cronPort}`);
323
+ this.log.info(`Cron server listening on port ${cronPort}`);
324
324
  });
325
325
  this.shutdownServer = () => {
326
326
  if (this.isShuttingDown) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versori/run",
3
- "version": "v0.2.10",
3
+ "version": "v0.2.12",
4
4
  "description": "Versori Run",
5
5
  "homepage": "https://github.com/versori/versori-run#readme",
6
6
  "repository": {
@@ -23,7 +23,7 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@bufbuild/protobuf": "^2.2.3",
26
+ "@bufbuild/protobuf": "^2.5.2",
27
27
  "@connectrpc/connect": "^2.0.1",
28
28
  "@connectrpc/connect-node": "^2.0.1",
29
29
  "@opentelemetry/api": "^1.9.0",
@@ -11,6 +11,8 @@ export declare class CronAPIClient implements CronProvider {
11
11
  private runLocal;
12
12
  constructor(baseUrl: string, envId: string, integrationUrl: string);
13
13
  static fromEnv(): CronAPIClient;
14
+ static addDefaultCronPort(url: string): string;
15
+ makeCronPath(name: string): string;
14
16
  updateCrons(crons: Map<string, string>): Promise<void>;
15
17
  runLocalFn(crons: Cron[]): void;
16
18
  }
@@ -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;AAY3C,KAAK,IAAI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CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB5D,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE;CAoB3B"}
@@ -44,13 +44,26 @@ class CronAPIClient {
44
44
  }
45
45
  const integrationUrl = Deno.env.get(constants_js_1.envVarSelfRefURL) ||
46
46
  `http://svc-${projectId.toLowerCase()}-${envName.toLowerCase()}.sb-${orgSlug.toLowerCase()}.svc.cluster.local:${constants_js_1.cronPort}`;
47
- return new CronAPIClient(baseUrl, envId, integrationUrl);
47
+ return new CronAPIClient(baseUrl, envId, this.addDefaultCronPort(integrationUrl));
48
+ }
49
+ // Check if the URL has a port, if not, add the default cron port.
50
+ static addDefaultCronPort(url) {
51
+ const parsedUrl = new URL(url);
52
+ if (parsedUrl.port === '') {
53
+ parsedUrl.port = constants_js_1.cronPort.toString();
54
+ }
55
+ return parsedUrl.toString();
56
+ }
57
+ makeCronPath(name) {
58
+ const url = new URL(this.integrationUrl);
59
+ url.pathname = `/cron/${name}`;
60
+ return url.toString();
48
61
  }
49
62
  async updateCrons(crons) {
50
63
  const cronsArray = Array.from(crons.entries()).map(([name, schedule]) => ({
51
64
  name,
52
65
  schedule,
53
- url: `${this.integrationUrl}/cron/${name}`,
66
+ url: this.makeCronPath(name),
54
67
  }));
55
68
  if (this.runLocal) {
56
69
  this.runLocalFn(cronsArray);
@@ -323,10 +323,10 @@ class MemoryInterpreter {
323
323
  throw new Error('Unable to register scheduler tasks with central cron provider');
324
324
  }
325
325
  this.webhookServer = webhookApp.listen(port, () => {
326
- this.log.info(`Express server listening on http://localhost:${port}`);
326
+ this.log.info(`Express server listening on port ${port}`);
327
327
  });
328
328
  this.cronServer = cronApp.listen(cronPort, () => {
329
- this.log.info(`Cron server listening on http://localhost:${cronPort}`);
329
+ this.log.info(`Cron server listening on port ${cronPort}`);
330
330
  });
331
331
  this.shutdownServer = () => {
332
332
  if (this.isShuttingDown) {