@aloma.io/integration-sdk 3.7.1 → 3.7.3

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.
@@ -1,4 +1,5 @@
1
1
  import RuntimeContext from "./runtime-context.mjs";
2
+ export declare const TARGET_DIR: string;
2
3
  export declare class Builder {
3
4
  private data;
4
5
  config(arg: any): Builder;
@@ -6,6 +7,5 @@ export declare class Builder {
6
7
  auth(arg: any): Builder;
7
8
  build(): Promise<RuntimeContext>;
8
9
  private checkIcon;
9
- private parsePackageJson;
10
- private loadTypes;
10
+ private loadDescriptor;
11
11
  }
@@ -3,8 +3,9 @@ import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { notEmpty } from "../internal/util/index.mjs";
5
5
  import RuntimeContext from "./runtime-context.mjs";
6
- const offset = '/../../../../../';
6
+ const DIR_OFFSET = '/../../../../../';
7
7
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
+ export const TARGET_DIR = `${__dirname}${DIR_OFFSET}`;
8
9
  export class Builder {
9
10
  data = {
10
11
  controller: "./build/.controller.json",
@@ -22,31 +23,24 @@ export class Builder {
22
23
  return this;
23
24
  }
24
25
  async build() {
25
- await this.parsePackageJson();
26
- await this.loadTypes();
26
+ await this.loadDescriptor();
27
27
  await this.checkIcon();
28
28
  // @ts-ignore
29
- const Controller = (await import(__dirname + offset + "build/controller/index.mjs")).default;
29
+ const Controller = (await import(TARGET_DIR + "build/controller/index.mjs")).default;
30
30
  return new RuntimeContext(new Controller(), this.data);
31
31
  }
32
32
  async checkIcon() {
33
33
  const data = this.data;
34
- const root = __dirname + offset;
34
+ const root = TARGET_DIR;
35
35
  data.icon = `${root}/logo.png`;
36
36
  }
37
- async parsePackageJson() {
38
- const data = this.data;
39
- const packageJson = JSON.parse(fs.readFileSync(__dirname + offset + "package.json", {
40
- encoding: "utf-8",
41
- }));
42
- notEmpty((data.id = packageJson.connectorId), "id");
43
- notEmpty((data.version = packageJson.version), "version");
44
- }
45
- async loadTypes() {
37
+ async loadDescriptor() {
46
38
  notEmpty(this.data.controller, "controller");
47
39
  const content = fs.readFileSync(this.data.controller, { encoding: 'utf-8' });
48
- const { text, methods } = JSON.parse(content);
40
+ const { text, methods, connectorId, version } = JSON.parse(content);
49
41
  this.data.types = text;
50
42
  this.data.methods = methods;
43
+ notEmpty((this.data.id = connectorId), "id");
44
+ notEmpty((this.data.version = version), "version");
51
45
  }
52
46
  }
package/build/cli.mjs CHANGED
@@ -5,6 +5,7 @@ import fs from "node:fs";
5
5
  import path from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  import util from "node:util";
8
+ import { TARGET_DIR } from "./builder/index.mjs";
8
9
  import { notEmpty } from "./internal/util/index.mjs";
9
10
  import JWE from "./internal/util/jwe/index.mjs";
10
11
  import parseTypes from "./transform/index.mjs";
@@ -89,7 +90,7 @@ program
89
90
  .command("build")
90
91
  .description("Build the current connector project")
91
92
  .action(async (str, options) => {
92
- const { stdout, stderr } = await exec(`rm -rf build; mkdir -p build`);
93
+ const { stdout, stderr } = await exec(`rm -rf build; mkdir -p build; [ -e ./logo.png ] && cp -f ./logo.png ./build/ `);
93
94
  if (stdout)
94
95
  console.log(stdout);
95
96
  new Extractor().extract('./src/controller/index.mts', './build/.controller.json');
@@ -99,7 +100,10 @@ class Extractor {
99
100
  notEmpty(source, "source");
100
101
  fs.readFileSync(source);
101
102
  const { text, methods } = await parseTypes(source);
102
- fs.writeFileSync(target, JSON.stringify({ text, methods }), { encoding: 'utf-8' });
103
+ const packageJson = JSON.parse(fs.readFileSync(TARGET_DIR + "package.json", {
104
+ encoding: "utf-8",
105
+ }));
106
+ fs.writeFileSync(target, JSON.stringify({ text, methods, connectorId: packageJson.connectorId, version: packageJson.version }), { encoding: 'utf-8' });
103
107
  }
104
108
  }
105
109
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.7.1",
3
+ "version": "3.7.3",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -4,10 +4,12 @@ import { fileURLToPath } from "node:url";
4
4
  import { notEmpty } from "../internal/util/index.mjs";
5
5
  import RuntimeContext from "./runtime-context.mjs";
6
6
 
7
- const offset = '/../../../../../';
7
+ const DIR_OFFSET = '/../../../../../';
8
8
 
9
9
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
10
 
11
+ export const TARGET_DIR = `${__dirname}${DIR_OFFSET}`;
12
+
11
13
  export class Builder {
12
14
  private data: any = {
13
15
  controller: "./build/.controller.json",
@@ -31,13 +33,12 @@ export class Builder {
31
33
  }
32
34
 
33
35
  async build(): Promise<RuntimeContext> {
34
- await this.parsePackageJson();
35
- await this.loadTypes();
36
+ await this.loadDescriptor();
36
37
  await this.checkIcon();
37
38
 
38
39
  // @ts-ignore
39
40
  const Controller = (
40
- await import(__dirname + offset + "build/controller/index.mjs")
41
+ await import(TARGET_DIR + "build/controller/index.mjs")
41
42
  ).default;
42
43
 
43
44
  return new RuntimeContext(new Controller(), this.data);
@@ -45,31 +46,21 @@ export class Builder {
45
46
 
46
47
  private async checkIcon() {
47
48
  const data = this.data;
48
- const root = __dirname + offset;
49
+ const root = TARGET_DIR;
49
50
 
50
51
  data.icon = `${root}/logo.png`;
51
52
  }
52
53
 
53
- private async parsePackageJson() {
54
- const data = this.data;
55
-
56
- const packageJson = JSON.parse(
57
- fs.readFileSync(__dirname + offset + "package.json", {
58
- encoding: "utf-8",
59
- }),
60
- );
61
-
62
- notEmpty((data.id = packageJson.connectorId), "id");
63
- notEmpty((data.version = packageJson.version), "version");
64
- }
65
-
66
- private async loadTypes() {
54
+ private async loadDescriptor() {
67
55
  notEmpty(this.data.controller, "controller");
68
56
 
69
57
  const content = fs.readFileSync(this.data.controller, {encoding: 'utf-8'});
70
- const {text, methods} = JSON.parse(content);
58
+ const {text, methods, connectorId, version} = JSON.parse(content);
71
59
 
72
60
  this.data.types = text;
73
61
  this.data.methods = methods;
62
+
63
+ notEmpty((this.data.id = connectorId), "id");
64
+ notEmpty((this.data.version = version), "version");
74
65
  }
75
- }
66
+ }
package/src/cli.mts CHANGED
@@ -6,6 +6,7 @@ import fs from "node:fs";
6
6
  import path from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import util from "node:util";
9
+ import { TARGET_DIR } from "./builder/index.mjs";
9
10
  import { notEmpty } from "./internal/util/index.mjs";
10
11
  import JWE from "./internal/util/jwe/index.mjs";
11
12
  import parseTypes from "./transform/index.mjs";
@@ -120,7 +121,7 @@ program
120
121
  .description("Build the current connector project")
121
122
  .action(async (str, options) => {
122
123
  const { stdout, stderr } = await exec(
123
- `rm -rf build; mkdir -p build`,
124
+ `rm -rf build; mkdir -p build; [ -e ./logo.png ] && cp -f ./logo.png ./build/ `,
124
125
  );
125
126
 
126
127
  if (stdout) console.log(stdout);
@@ -135,7 +136,13 @@ class Extractor {
135
136
  fs.readFileSync(source);
136
137
  const { text, methods } = await parseTypes(source);
137
138
 
138
- fs.writeFileSync(target, JSON.stringify({text, methods}), {encoding: 'utf-8'})
139
+ const packageJson = JSON.parse(
140
+ fs.readFileSync(TARGET_DIR + "package.json", {
141
+ encoding: "utf-8",
142
+ }),
143
+ );
144
+
145
+ fs.writeFileSync(target, JSON.stringify({text, methods, connectorId: packageJson.connectorId, version: packageJson.version}), {encoding: 'utf-8'})
139
146
  }
140
147
  }
141
148