@aloma.io/integration-sdk 3.0.0-8 → 3.0.0

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 (50) hide show
  1. package/README.md +1 -1
  2. package/build/builder/index.d.mts +10 -0
  3. package/build/builder/index.mjs +46 -0
  4. package/build/builder/runtime-context.d.mts +7 -0
  5. package/build/builder/runtime-context.mjs +50 -0
  6. package/build/builder/transform/index.d.mts +5 -0
  7. package/build/builder/transform/index.mjs +71 -0
  8. package/build/controller/index.d.mts +19 -0
  9. package/build/controller/index.mjs +44 -0
  10. package/build/index.d.mts +2 -0
  11. package/build/index.mjs +2 -0
  12. package/build/internal/dispatcher/index.cjs +150 -0
  13. package/build/internal/dispatcher/index.d.cts +32 -0
  14. package/build/internal/index.cjs +461 -0
  15. package/build/internal/index.d.cts +14 -0
  16. package/build/internal/util/jwe/cli.cjs +13 -0
  17. package/build/internal/util/jwe/cli.d.cts +1 -0
  18. package/build/internal/util/jwe/index.cjs +57 -0
  19. package/build/internal/util/jwe/index.d.cts +32 -0
  20. package/build/internal/websocket/config.cjs +79 -0
  21. package/build/internal/websocket/config.d.cts +41 -0
  22. package/build/internal/websocket/connection/constants.cjs +21 -0
  23. package/build/internal/websocket/connection/constants.d.cts +2 -0
  24. package/build/internal/websocket/connection/index.cjs +53 -0
  25. package/build/internal/websocket/connection/index.d.cts +11 -0
  26. package/build/internal/websocket/connection/registration.cjs +31 -0
  27. package/build/internal/websocket/connection/registration.d.cts +5 -0
  28. package/build/internal/websocket/index.cjs +41 -0
  29. package/build/internal/websocket/index.d.cts +16 -0
  30. package/build/internal/websocket/transport/durable.cjs +61 -0
  31. package/build/internal/websocket/transport/durable.d.cts +20 -0
  32. package/build/internal/websocket/transport/index.cjs +148 -0
  33. package/build/internal/websocket/transport/index.d.cts +37 -0
  34. package/build/internal/websocket/transport/packet.cjs +44 -0
  35. package/build/internal/websocket/transport/packet.d.cts +16 -0
  36. package/build/internal/websocket/transport/processor.cjs +58 -0
  37. package/build/internal/websocket/transport/processor.d.cts +11 -0
  38. package/examples/hello-world/Containerfile +1 -1
  39. package/examples/hello-world/package.json +16 -1
  40. package/examples/hello-world/src/controller/index.mts +13 -0
  41. package/examples/hello-world/src/index.mts +6 -0
  42. package/examples/hello-world/tsconfig.json +27 -0
  43. package/package.json +2 -2
  44. package/src/builder/runtime-context.mts +6 -3
  45. package/src/internal/dispatcher/index.cjs +0 -1
  46. package/examples/hello-world/src/controller/index.js +0 -14
  47. package/examples/hello-world/src/index.js +0 -29
  48. package/examples/kitchen-sink/01-hello-world.js +0 -26
  49. package/examples/kitchen-sink/02-config.js +0 -54
  50. package/examples/kitchen-sink/03-oauth.js +0 -36
@@ -0,0 +1,6 @@
1
+ import {Builder} from '@aloma.io/integration-sdk';
2
+
3
+ const builder = new Builder();
4
+ const runtime = await builder.build();
5
+
6
+ await runtime.start();
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2022",
4
+ "skipLibCheck": true,
5
+ "module": "node16",
6
+ "moduleResolution": "node16",
7
+ "lib": ["es2015", "es6", "esnext"],
8
+ "declaration": true,
9
+ "allowJs": true,
10
+ "outDir": "build",
11
+ "rootDir": "src/",
12
+ "strict": true,
13
+ "noImplicitAny": false,
14
+ "esModuleInterop": true,
15
+ "resolveJsonModule": true,
16
+ "experimentalDecorators": true,
17
+ "emitDecoratorMetadata": true,
18
+ "allowSyntheticDefaultImports": true
19
+ },
20
+ "include": [
21
+ "src/**/*"
22
+ ],
23
+ "exclude": [
24
+ "node_modules/**/*",
25
+ "dist/**/*"
26
+ ]
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.0.0-8",
3
+ "version": "3.0.0",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -23,6 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@paralleldrive/cuid2": "^2",
26
+ "@ts-ast-parser/core": "^0",
26
27
  "dotenv": "*",
27
28
  "express": "^4",
28
29
  "jose": "^4",
@@ -35,7 +36,6 @@
35
36
  "utf-8-validate": "^6"
36
37
  },
37
38
  "devDependencies": {
38
- "@ts-ast-parser/core": "^0",
39
39
  "@types/node": "^18",
40
40
  "mocha": "^10",
41
41
  "prettier": "^2",
@@ -16,7 +16,7 @@ export default class RuntimeContext {
16
16
  name: `${data.id}/${data.version}`,
17
17
  });
18
18
 
19
- const configuration = connector.configure();
19
+ const configuration = connector.configure().config(data.config || {});
20
20
 
21
21
  const resolvers: any = {};
22
22
  const methods: string[] = [...data.methods, '__endpoint', '__configQuery', '__default'];
@@ -30,15 +30,18 @@ export default class RuntimeContext {
30
30
  });
31
31
 
32
32
  configuration
33
- .config(data.config || {})
34
33
  .types(data.types)
35
34
  .resolvers(resolvers);
36
35
 
37
-
38
36
  if (data.options?.endpoint?.enabled)
39
37
  {
40
38
  configuration.endpoint((arg) => controller.__endpoint(arg));
41
39
  }
40
+
41
+ if (data.auth?.oauth)
42
+ {
43
+ configuration.oauth(data.auth?.oauth);
44
+ }
42
45
 
43
46
  configuration.main(async ({newTask, updateTask, config, oauth, getClient}) => {
44
47
  try {
@@ -139,7 +139,6 @@ class Dispatcher {
139
139
  .slice(0, 20);
140
140
 
141
141
  const method = resolveMethod(query);
142
- console.log('found method', query, method);
143
142
  if (!method && !_resolvers.__default) throw new Error(`${query} not found`);
144
143
 
145
144
  return method ? method(variables) : _resolvers.__default(variables ? {...variables, __method: query} : variables);
@@ -1,14 +0,0 @@
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}
@@ -1,29 +0,0 @@
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();
@@ -1,26 +0,0 @@
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();
@@ -1,54 +0,0 @@
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();
@@ -1,36 +0,0 @@
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();