@aloma.io/integration-sdk 3.8.2 → 3.8.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,17 +1,70 @@
1
1
  import "dotenv/config";
2
2
  import RuntimeContext from "./runtime-context.mjs";
3
3
  export declare const TARGET_DIR: string;
4
+ /**
5
+ * a configuration field
6
+ */
4
7
  export type ConfigField = {
8
+ /**
9
+ * the name of the field
10
+ */
5
11
  name: string;
12
+ /**
13
+ * a description about the field
14
+ *
15
+ * supports markdown
16
+ */
6
17
  description?: string;
18
+ /**
19
+ * a placeholder for the field
20
+ */
7
21
  placeholder?: string;
8
- type: "multiline" | "text" | "number" | "boolean";
22
+ /**
23
+ * the type of the field
24
+ */
25
+ type:
26
+ /**
27
+ * a multiline text field
28
+ */
29
+ "multiline"
30
+ /**
31
+ * a single line text field
32
+ */
33
+ | "text"
34
+ /**
35
+ * a number field
36
+ */
37
+ | "number"
38
+ /**
39
+ * a boolean text field
40
+ */
41
+ | "boolean";
42
+ /**
43
+ * if true, the field is optional, otherwise a value is required
44
+ */
9
45
  optional?: boolean;
46
+ /**
47
+ * if true, the field will NOT be encrypted
48
+ */
10
49
  plain?: boolean;
11
50
  } | undefined;
51
+ /**
52
+ * connector configuration
53
+ */
12
54
  declare type Config = {
55
+ /**
56
+ * a short summary about the connector
57
+ */
13
58
  summary?: string;
59
+ /**
60
+ * a longer description about the connector, including further reference or setup instructions
61
+ *
62
+ * supports markdown
63
+ */
14
64
  description?: string;
65
+ /**
66
+ * fields that can be configured by the user in the ui
67
+ */
15
68
  fields?: {
16
69
  authorizationURL?: ConfigField;
17
70
  tokenURL?: ConfigField;
@@ -21,40 +74,105 @@ declare type Config = {
21
74
  [key: string]: ConfigField;
22
75
  };
23
76
  };
77
+ /**
78
+ * connector options
79
+ */
24
80
  declare type Options = {
81
+ /**
82
+ * if an endpoint is enabled for sending data to the connector
83
+ */
25
84
  endpoint?: {
85
+ /**
86
+ * if the endpoint is enabled
87
+ */
26
88
  enabled: boolean;
89
+ /**
90
+ * if true, the endpoint is required to operate the connector and not visible in the ui
91
+ */
27
92
  required?: boolean;
28
93
  };
29
94
  };
95
+ /**
96
+ * OAuth configuration
97
+ *
98
+ * @see https://oauth.net/2/
99
+ */
30
100
  declare type OAuth = {
31
101
  /**
32
- * preferred via process.env.OAUTH_CLIENT_ID
102
+ * oauth2 client id
103
+ *
104
+ * NOTE: preferred via process.env.OAUTH_CLIENT_ID
33
105
  */
34
106
  clientId?: string;
35
107
  /**
36
- * preferred via process.env.OAUTH_CLIENT_SECRET
108
+ * oauth2 client secret
109
+ *
110
+ * NOTE: preferred via process.env.OAUTH_CLIENT_SECRET
37
111
  */
38
112
  clientSecret?: string;
39
113
  /**
40
114
  * @example https://example.com/oauth2/v2/auth?client_id={{clientId}}&redirect_uri={{redirectURI}}&scope={{scope}}&response_type=code
41
115
  */
42
116
  authorizationURL?: string;
117
+ /**
118
+ * oauth2 token url
119
+ * @example https://example.com/oauth2/v2/token
120
+ */
43
121
  tokenURL?: string;
122
+ /**
123
+ * oauth2 scope
124
+ * @example openid offline_access
125
+ */
44
126
  scope?: string;
127
+ /**
128
+ * milliseconds to automatically refresh the token, if a refresh_token is available
129
+ *
130
+ * @default 4 * 60 * 60 * 1000 // 4 hours
131
+ */
45
132
  tokenRefreshPeriod?: number;
133
+ /**
134
+ * if true, the clientId and clientSecret are sent to the tokenURL as basic auth header
135
+ */
46
136
  useAuthHeader?: boolean;
137
+ /**
138
+ * additional token arguments
139
+ */
47
140
  additionalTokenArgs?: {
141
+ /**
142
+ * oauth2 grant type
143
+ */
48
144
  grant_type?: string;
49
145
  };
50
146
  };
147
+ /**
148
+ * a builder for creating a connector
149
+ */
51
150
  export declare class Builder {
52
151
  private data;
152
+ /**
153
+ * configure properties of the connector
154
+ * @param arg
155
+ * @returns
156
+ */
53
157
  config(arg: Config): Builder;
158
+ /**
159
+ * configure additional options of the connector
160
+ * @param arg
161
+ * @returns
162
+ */
54
163
  options(arg: Options): Builder;
164
+ /**
165
+ * configure the authentication of the connector
166
+ * @param arg
167
+ * @returns
168
+ */
55
169
  auth(arg: {
56
170
  oauth?: OAuth;
57
171
  }): Builder;
172
+ /**
173
+ * build the connector
174
+ * @returns
175
+ */
58
176
  build(): Promise<RuntimeContext>;
59
177
  private checkIcon;
60
178
  private loadDescriptor;
@@ -7,22 +7,44 @@ import RuntimeContext from "./runtime-context.mjs";
7
7
  const DIR_OFFSET = "/../../../../../";
8
8
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
9
  export const TARGET_DIR = `${__dirname}${DIR_OFFSET}`;
10
+ /**
11
+ * a builder for creating a connector
12
+ */
10
13
  export class Builder {
11
14
  data = {
12
15
  controller: "./build/.controller.json",
13
16
  };
17
+ /**
18
+ * configure properties of the connector
19
+ * @param arg
20
+ * @returns
21
+ */
14
22
  config(arg) {
15
23
  this.data.config = arg;
16
24
  return this;
17
25
  }
26
+ /**
27
+ * configure additional options of the connector
28
+ * @param arg
29
+ * @returns
30
+ */
18
31
  options(arg) {
19
32
  this.data.options = arg;
20
33
  return this;
21
34
  }
35
+ /**
36
+ * configure the authentication of the connector
37
+ * @param arg
38
+ * @returns
39
+ */
22
40
  auth(arg) {
23
41
  this.data.auth = arg;
24
42
  return this;
25
43
  }
44
+ /**
45
+ * build the connector
46
+ * @returns
47
+ */
26
48
  async build() {
27
49
  await this.loadDescriptor();
28
50
  await this.checkIcon();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.8.2",
3
+ "version": "3.8.3",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -11,18 +11,72 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
11
 
12
12
  export const TARGET_DIR = `${__dirname}${DIR_OFFSET}`;
13
13
 
14
+ /**
15
+ * a configuration field
16
+ */
14
17
  export type ConfigField = {
18
+ /**
19
+ * the name of the field
20
+ */
15
21
  name: string;
22
+ /**
23
+ * a description about the field
24
+ *
25
+ * supports markdown
26
+ */
16
27
  description?: string;
28
+ /**
29
+ * a placeholder for the field
30
+ */
17
31
  placeholder?: string;
18
- type: "multiline" | "text" | "number" | "boolean";
32
+ /**
33
+ * the type of the field
34
+ */
35
+ type:
36
+ /**
37
+ * a multiline text field
38
+ */
39
+ "multiline"
40
+ /**
41
+ * a single line text field
42
+ */
43
+ | "text"
44
+ /**
45
+ * a number field
46
+ */
47
+ | "number"
48
+ /**
49
+ * a boolean text field
50
+ */
51
+ | "boolean";
52
+ /**
53
+ * if true, the field is optional, otherwise a value is required
54
+ */
19
55
  optional?: boolean;
56
+ /**
57
+ * if true, the field will NOT be encrypted
58
+ */
20
59
  plain?: boolean;
21
60
  } | undefined;
22
61
 
62
+ /**
63
+ * connector configuration
64
+ */
23
65
  declare type Config = {
66
+ /**
67
+ * a short summary about the connector
68
+ */
24
69
  summary?: string;
70
+ /**
71
+ * a longer description about the connector, including further reference or setup instructions
72
+ *
73
+ * supports markdown
74
+ */
25
75
  description?: string;
76
+
77
+ /**
78
+ * fields that can be configured by the user in the ui
79
+ */
26
80
  fields?: {
27
81
  authorizationURL?: ConfigField;
28
82
  tokenURL?: ConfigField;
@@ -33,17 +87,42 @@ declare type Config = {
33
87
  };
34
88
  };
35
89
 
90
+ /**
91
+ * connector options
92
+ */
36
93
  declare type Options = {
37
- endpoint?: {enabled: boolean, required?: boolean};
94
+ /**
95
+ * if an endpoint is enabled for sending data to the connector
96
+ */
97
+ endpoint?: {
98
+ /**
99
+ * if the endpoint is enabled
100
+ */
101
+ enabled: boolean,
102
+ /**
103
+ * if true, the endpoint is required to operate the connector and not visible in the ui
104
+ */
105
+ required?: boolean
106
+ };
38
107
  };
39
108
 
109
+ /**
110
+ * OAuth configuration
111
+ *
112
+ * @see https://oauth.net/2/
113
+ */
40
114
  declare type OAuth = {
41
115
  /**
42
- * preferred via process.env.OAUTH_CLIENT_ID
116
+ * oauth2 client id
117
+ *
118
+ * NOTE: preferred via process.env.OAUTH_CLIENT_ID
43
119
  */
44
120
  clientId?: string;
121
+
45
122
  /**
46
- * preferred via process.env.OAUTH_CLIENT_SECRET
123
+ * oauth2 client secret
124
+ *
125
+ * NOTE: preferred via process.env.OAUTH_CLIENT_SECRET
47
126
  */
48
127
  clientSecret?: string;
49
128
 
@@ -51,35 +130,85 @@ declare type OAuth = {
51
130
  * @example https://example.com/oauth2/v2/auth?client_id={{clientId}}&redirect_uri={{redirectURI}}&scope={{scope}}&response_type=code
52
131
  */
53
132
  authorizationURL?: string;
133
+
134
+ /**
135
+ * oauth2 token url
136
+ * @example https://example.com/oauth2/v2/token
137
+ */
54
138
  tokenURL?: string;
139
+ /**
140
+ * oauth2 scope
141
+ * @example openid offline_access
142
+ */
55
143
  scope?: string;
144
+
145
+ /**
146
+ * milliseconds to automatically refresh the token, if a refresh_token is available
147
+ *
148
+ * @default 4 * 60 * 60 * 1000 // 4 hours
149
+ */
56
150
  tokenRefreshPeriod?: number;
151
+
152
+ /**
153
+ * if true, the clientId and clientSecret are sent to the tokenURL as basic auth header
154
+ */
57
155
  useAuthHeader?: boolean;
58
- additionalTokenArgs?: {grant_type?: string}
156
+
157
+ /**
158
+ * additional token arguments
159
+ */
160
+ additionalTokenArgs?: {
161
+ /**
162
+ * oauth2 grant type
163
+ */
164
+ grant_type?: string
165
+ }
59
166
  };
60
167
 
168
+ /**
169
+ * a builder for creating a connector
170
+ */
61
171
  export class Builder {
62
172
  private data: any = {
63
173
  controller: "./build/.controller.json",
64
174
  };
65
175
 
176
+ /**
177
+ * configure properties of the connector
178
+ * @param arg
179
+ * @returns
180
+ */
66
181
  config(arg: Config): Builder {
67
182
  this.data.config = arg;
68
183
 
69
184
  return this;
70
185
  }
71
186
 
187
+ /**
188
+ * configure additional options of the connector
189
+ * @param arg
190
+ * @returns
191
+ */
72
192
  options(arg: Options): Builder {
73
193
  this.data.options = arg;
74
194
 
75
195
  return this;
76
196
  }
77
197
 
198
+ /**
199
+ * configure the authentication of the connector
200
+ * @param arg
201
+ * @returns
202
+ */
78
203
  auth(arg: {oauth?: OAuth}): Builder {
79
204
  this.data.auth = arg;
80
205
  return this;
81
206
  }
82
207
 
208
+ /**
209
+ * build the connector
210
+ * @returns
211
+ */
83
212
  async build(): Promise<RuntimeContext> {
84
213
  await this.loadDescriptor();
85
214
  await this.checkIcon();