@aloma.io/integration-sdk 3.3.17 → 3.3.19

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.
@@ -5,6 +5,7 @@ export declare class Builder {
5
5
  options(arg: any): Builder;
6
6
  auth(arg: any): Builder;
7
7
  build(): Promise<RuntimeContext>;
8
+ private checkLogo;
8
9
  private parsePackageJson;
9
10
  private discoverTypes;
10
11
  }
@@ -28,10 +28,25 @@ export class Builder {
28
28
  async build() {
29
29
  await this.parsePackageJson();
30
30
  await this.discoverTypes();
31
+ await this.checkLogo();
31
32
  // @ts-ignore
32
33
  const Controller = (await import(__dirname + "/../../../../../build/controller/index.mjs")).default;
33
34
  return new RuntimeContext(new Controller(), this.data);
34
35
  }
36
+ async checkLogo() {
37
+ const data = this.data;
38
+ const root = __dirname + "/../../../../../";
39
+ const logo = ['logo.png'].find((name) => {
40
+ try {
41
+ fs.readFileSync(`${root}/${name}`);
42
+ return `${root}/${name}`;
43
+ }
44
+ catch (e) {
45
+ // blank
46
+ }
47
+ });
48
+ data.logo = logo;
49
+ }
35
50
  async parsePackageJson() {
36
51
  const data = this.data;
37
52
  const packageJson = JSON.parse(fs.readFileSync(__dirname + "/../../../../../package.json", {
@@ -16,6 +16,7 @@ export default class RuntimeContext {
16
16
  id: data.id,
17
17
  version: data.version,
18
18
  name: `${data.id}/${data.version}`,
19
+ icon: data.icon
19
20
  });
20
21
  const configuration = connector.configure().config(data.config || {});
21
22
  const resolvers = {};
package/build/cli.mjs CHANGED
@@ -37,7 +37,8 @@ const extract = ({ target, name, connectorId }) => {
37
37
  fs.writeFileSync(`${target}/.gitignore`, `.DS_Store
38
38
  node_modules
39
39
  build
40
- .env`);
40
+ .env
41
+ yarn-error.log`);
41
42
  };
42
43
  const generateKeys = async ({ target }) => {
43
44
  const jwe = new JWE({});
@@ -1,12 +1,14 @@
1
1
  export class Connector {
2
- constructor({ version, id, name }: {
2
+ constructor({ version, id, name, icon }: {
3
3
  version: any;
4
4
  id: any;
5
5
  name: any;
6
+ icon: any;
6
7
  });
7
8
  id: any;
8
9
  version: any;
9
10
  name: any;
11
+ icon: any;
10
12
  configure(): Dispatcher;
11
13
  dispatcher: Dispatcher | undefined;
12
14
  run(): Promise<void>;
@@ -184,10 +184,11 @@ class OAuth {
184
184
  }
185
185
  }
186
186
  class Connector {
187
- constructor({ version, id, name }) {
187
+ constructor({ version, id, name, icon }) {
188
188
  this.id = id;
189
189
  this.version = version;
190
190
  this.name = name;
191
+ this.icon = icon;
191
192
  }
192
193
  configure() {
193
194
  return (this.dispatcher = new Dispatcher());
@@ -229,6 +230,7 @@ class Connector {
229
230
  publicKey: process.env.PUBLIC_KEY,
230
231
  introspect,
231
232
  configSchema,
233
+ icon: this.icon
232
234
  });
233
235
  if (Object.keys(configSchema().fields).length) {
234
236
  try {
@@ -1,5 +1,5 @@
1
1
  export class Config {
2
- constructor({ registrationToken, version, name, id, endpoint, wsEndpoint, privateKey, publicKey, introspect, configSchema, }: {
2
+ constructor({ registrationToken, version, name, id, endpoint, wsEndpoint, privateKey, publicKey, introspect, configSchema, icon }: {
3
3
  registrationToken: any;
4
4
  version: any;
5
5
  name: any;
@@ -10,6 +10,7 @@ export class Config {
10
10
  publicKey: any;
11
11
  introspect: any;
12
12
  configSchema: any;
13
+ icon: any;
13
14
  });
14
15
  _token: any;
15
16
  _registrationToken: any;
@@ -24,6 +25,7 @@ export class Config {
24
25
  _jwe: JWE;
25
26
  _introspect: any;
26
27
  _configSchema: any;
28
+ _icon: any;
27
29
  validateKeys(algorithm: any): Promise<JWE>;
28
30
  data(what: any): {};
29
31
  introspect(): any;
@@ -36,6 +38,7 @@ export class Config {
36
38
  wsUrl(): any;
37
39
  registrationToken(): any;
38
40
  token(): any;
41
+ icon(): any;
39
42
  setToken(what: any): void;
40
43
  }
41
44
  import JWE from "../util/jwe/index.mjs";
@@ -1,7 +1,7 @@
1
1
  import C from "./connection/constants.mjs";
2
2
  import JWE from "../util/jwe/index.mjs";
3
3
  class Config {
4
- constructor({ registrationToken, version, name, id, endpoint, wsEndpoint, privateKey, publicKey, introspect, configSchema, }) {
4
+ constructor({ registrationToken, version, name, id, endpoint, wsEndpoint, privateKey, publicKey, introspect, configSchema, icon }) {
5
5
  this._token = null;
6
6
  this._registrationToken = registrationToken;
7
7
  this._version = version;
@@ -15,6 +15,7 @@ class Config {
15
15
  this._jwe = new JWE({});
16
16
  this._introspect = introspect;
17
17
  this._configSchema = configSchema;
18
+ this._icon = icon;
18
19
  if (!registrationToken)
19
20
  throw new Error("empty registration token (set env.REGISTRATION_TOKEN)");
20
21
  if (!endpoint)
@@ -70,6 +71,9 @@ class Config {
70
71
  token() {
71
72
  return this._token;
72
73
  }
74
+ icon() {
75
+ return this._icon;
76
+ }
73
77
  setToken(what) {
74
78
  this._token = what;
75
79
  }
@@ -9,6 +9,7 @@ class Registration {
9
9
  const config = this.config;
10
10
  const configSchema = config.configSchema();
11
11
  const intro = await config.introspect();
12
+ const icon = config.icon();
12
13
  const response = await fetch(config.url() + "register", C.augmentRegistration({
13
14
  method: "POST",
14
15
  body: JSON.stringify({
@@ -18,6 +19,7 @@ class Registration {
18
19
  id: config.id(),
19
20
  publicKey: config.publicKey(),
20
21
  schema: { configSchema, introspect: intro },
22
+ icon
21
23
  }),
22
24
  headers: { "Content-Type": "application/json" },
23
25
  }, config));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.3.17",
3
+ "version": "3.3.19",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -37,7 +37,8 @@ export class Builder {
37
37
  async build(): Promise<RuntimeContext> {
38
38
  await this.parsePackageJson();
39
39
  await this.discoverTypes();
40
-
40
+ await this.checkLogo();
41
+
41
42
  // @ts-ignore
42
43
  const Controller = (
43
44
  await import(__dirname + "/../../../../../build/controller/index.mjs")
@@ -45,6 +46,24 @@ export class Builder {
45
46
 
46
47
  return new RuntimeContext(new Controller(), this.data);
47
48
  }
49
+
50
+ private async checkLogo() {
51
+ const data = this.data;
52
+ const root = __dirname + "/../../../../../"
53
+
54
+ const logo = ['logo.png'].find((name) =>
55
+ {
56
+ try
57
+ {
58
+ fs.readFileSync(`${root}/${name}`);
59
+ return `${root}/${name}`;
60
+ } catch(e) {
61
+ // blank
62
+ }
63
+ })
64
+
65
+ data.logo = logo;
66
+ }
48
67
 
49
68
  private async parsePackageJson() {
50
69
  const data = this.data;
@@ -18,6 +18,7 @@ export default class RuntimeContext {
18
18
  id: data.id,
19
19
  version: data.version,
20
20
  name: `${data.id}/${data.version}`,
21
+ icon: data.icon
21
22
  });
22
23
 
23
24
  const configuration = connector.configure().config(data.config || {});
package/src/cli.mts CHANGED
@@ -52,7 +52,8 @@ const extract = ({ target, name, connectorId }) => {
52
52
  `.DS_Store
53
53
  node_modules
54
54
  build
55
- .env`,
55
+ .env
56
+ yarn-error.log`,
56
57
  );
57
58
  };
58
59
 
@@ -235,10 +235,11 @@ class OAuth {
235
235
  }
236
236
 
237
237
  class Connector {
238
- constructor({ version, id, name }) {
238
+ constructor({ version, id, name, icon }) {
239
239
  this.id = id;
240
240
  this.version = version;
241
241
  this.name = name;
242
+ this.icon = icon;
242
243
  }
243
244
 
244
245
  configure() {
@@ -293,6 +294,7 @@ class Connector {
293
294
  publicKey: process.env.PUBLIC_KEY,
294
295
  introspect,
295
296
  configSchema,
297
+ icon: this.icon
296
298
  });
297
299
 
298
300
  if (Object.keys(configSchema().fields).length) {
@@ -13,6 +13,7 @@ class Config {
13
13
  publicKey,
14
14
  introspect,
15
15
  configSchema,
16
+ icon
16
17
  }) {
17
18
  this._token = null;
18
19
  this._registrationToken = registrationToken;
@@ -27,6 +28,7 @@ class Config {
27
28
  this._jwe = new JWE({});
28
29
  this._introspect = introspect;
29
30
  this._configSchema = configSchema;
31
+ this._icon = icon;
30
32
 
31
33
  if (!registrationToken)
32
34
  throw new Error("empty registration token (set env.REGISTRATION_TOKEN)");
@@ -98,6 +100,10 @@ class Config {
98
100
  token() {
99
101
  return this._token;
100
102
  }
103
+
104
+ icon() {
105
+ return this._icon;
106
+ }
101
107
 
102
108
  setToken(what) {
103
109
  this._token = what;
@@ -11,6 +11,7 @@ class Registration {
11
11
  const config = this.config;
12
12
  const configSchema = config.configSchema();
13
13
  const intro = await config.introspect();
14
+ const icon = config.icon();
14
15
 
15
16
  const response = await fetch(
16
17
  config.url() + "register",
@@ -24,6 +25,7 @@ class Registration {
24
25
  id: config.id(),
25
26
  publicKey: config.publicKey(),
26
27
  schema: { configSchema, introspect: intro },
28
+ icon
27
29
  }),
28
30
  headers: { "Content-Type": "application/json" },
29
31
  },