@aloma.io/integration-sdk 3.0.0-4 → 3.0.0-5

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.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # nodejs - Aloma Integration SDK
2
+
3
+ ## Prerequisites
4
+
5
+ * You can find the `REGISTRATION_TOKEN` in your aloma workspace in the integration section.
6
+
7
+ ## Integration Examples
8
+
9
+ See `examples` directory.
@@ -0,0 +1,17 @@
1
+ FROM node:16-alpine3.18
2
+
3
+ ENV NODE_ENV production
4
+
5
+ WORKDIR /connector/
6
+
7
+ COPY ./package.json ./
8
+ COPY ./entrypoint.sh ./
9
+ COPY ./src ./src
10
+
11
+ RUN set -e; adduser -S -u 1111 connector
12
+
13
+ RUN set -e; apk add --no-cache git; yarn config set --home enableTelemetry 0; chmod 755 /connector/entrypoint.sh; cd /connector/; yarn install; rm -rf package.json; rm -rf yarn.lock;
14
+
15
+ USER connector
16
+
17
+ ENTRYPOINT ["/connector/entrypoint.sh"]
@@ -0,0 +1,5 @@
1
+ #!/bin/sh -e
2
+
3
+ cd /connector/
4
+
5
+ exec node src/index.js $@
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "hello-world",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "author": "aloma.io",
6
+ "license": "Apache-2.0",
7
+ "scripts": {},
8
+ "dependencies": {
9
+ "@aloma.io/integration-sdk": "^3"
10
+ }
11
+ }
@@ -0,0 +1,14 @@
1
+ class Controller
2
+ {
3
+ setConfig({newTask, config})
4
+ {
5
+ // blank
6
+ }
7
+
8
+ async hello(args)
9
+ {
10
+ return "world";
11
+ }
12
+ }
13
+
14
+ module.exports = {Controller}
@@ -0,0 +1,29 @@
1
+ const {Connector} = require('@aloma-io/integration-sdk');
2
+ const {Controller} = require('./controller');
3
+
4
+ const connector = new Connector({id: 'TODO your connector id', version: '1.0.0'});
5
+ const controller = new Controller();
6
+
7
+ connector.configure()
8
+ // types are the calls available in the step, these are typescript definitions
9
+ .types
10
+ (`
11
+ declare function hello(arg: {}): any;
12
+ `)
13
+ // resolvers hold the calls
14
+ .resolvers
15
+ ({
16
+ hello: async (args) =>
17
+ {
18
+ return controller.hello(args);
19
+ },
20
+ })
21
+ // main will be called once the connector is connected
22
+ .main(({newTask, config}) =>
23
+ {
24
+ // the config might have changed, so the connector should be able to deal with multiple setConfigs over it's lifetime
25
+ controller.setConfig({newTask, config});
26
+ });
27
+
28
+ // start the connector
29
+ connector.run();
@@ -0,0 +1,26 @@
1
+ const {Connector} = require('@aloma-io/integration-sdk');
2
+
3
+ const connector = new Connector({id: 'TODO your connector id', version: '1.0.0'});
4
+
5
+ connector.configure()
6
+ // types are the calls available in the step, these are typescript definitions
7
+ .types
8
+ (`
9
+ declare function hello(arg: {}): any;
10
+ `)
11
+ // resolvers hold the calls
12
+ .resolvers
13
+ ({
14
+ hello: async (args) =>
15
+ {
16
+ return "world";
17
+ },
18
+ })
19
+ // main will be called once the connector is connected
20
+ .main(({newTask, config}) =>
21
+ {
22
+ // the config might have changed, so the connector should be able to deal with multiple setConfigs over it's lifetime
23
+ });
24
+
25
+ // start the connector
26
+ connector.run();
@@ -0,0 +1,54 @@
1
+ const {Connector} = require('@aloma-io/integration-sdk');
2
+
3
+ const connector = new Connector({id: 'TODO your connector id', version: '1.0.0'});
4
+
5
+ connector.configure()
6
+ // these config fields can be configured from the aloma ui. these require a private and a public key which the connector will generate on start
7
+ .config({fields:
8
+ {
9
+ // this is then available from config.type
10
+ type: {
11
+ // name and placeholder for ui configuration
12
+ name: 'Database Type',
13
+ placeholder: 'e.g. mysql, pg, tedious',
14
+ // type
15
+ type: 'line',
16
+ // this is an unencrypted value, by default everything is encrypted
17
+ plain: true
18
+ },
19
+ user: {
20
+ name: 'User',
21
+ placeholder: 'e.g. john',
22
+ type: 'line',
23
+ plain: true,
24
+ // this is marked as optional in the ui, so does not have to be provided, everything else is mandatory
25
+ optional: true
26
+ },
27
+ // this is encrypted in the ui via public key, can only be decrypted by the connector having the private key
28
+ password: {
29
+ name: 'Password',
30
+ placeholder: 'e.g. x3gsadg',
31
+ type: 'line',
32
+ optional: true
33
+ },
34
+
35
+ }})
36
+ .types
37
+ (`
38
+ declare function hello(arg: {}): any;
39
+ `)
40
+ .resolvers
41
+ ({
42
+ hello: async (args) =>
43
+ {
44
+ return "world";
45
+ },
46
+ })
47
+ .main(({newTask, config}) =>
48
+ {
49
+ console.log(config.type)
50
+ console.log(config.password)
51
+ console.log(config.user)
52
+ });
53
+
54
+ connector.run();
@@ -0,0 +1,36 @@
1
+ const {Connector} = require('@aloma-io/integration-sdk');
2
+
3
+ const connector = new Connector({id: 'TODO your connector id', version: '1.0.0'});
4
+
5
+ connector.configure()
6
+ // these require a private and a public key which the connector will generate on start
7
+ // after a connector is added to a workspace it can be connected from the aloma ui
8
+ .oauth
9
+ ({
10
+ // the authorization url, the placeholders {{clientId}}, {{redirectURI}}, {{scope}} will be filled in by aloma
11
+ authorizationURL: 'https://github.com/login/oauth/authorize?client_id={{clientId}}&redirect_uri={{redirectURI}}&scope={{scope}}&allow_signup=false',
12
+ tokenURL: 'https://github.com/login/oauth/access_token',
13
+ clientId: 'clientId',
14
+ clientSecret: 'clientSecret',
15
+ scope: 'repo, user:email'
16
+ })
17
+ .types
18
+ (`
19
+ declare function hello(arg: {}): any;
20
+ `)
21
+ .resolvers
22
+ ({
23
+ hello: async (args) =>
24
+ {
25
+ return "world";
26
+ },
27
+ })
28
+ .main(({newTask, config, oauth}) =>
29
+ {
30
+ // one can access oauth.accessToken()
31
+ // one can get a fetch client: oauth.getClient()
32
+ // the client supports retries and will also do an automatic token refresh if a refresh_token is provided
33
+ // oauth.getClient().fetch({url, options = {method: 'POST', headers: {}, body: ''})
34
+ });
35
+
36
+ connector.run();
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ const {Connector} = require('./src/')
2
+
3
+ module.exports = {Connector}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.0.0-4",
3
+ "version": "3.0.0-5",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",