@aloma.io/integration-sdk 3.8.16 → 3.8.17
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.
@@ -31,7 +31,7 @@ export default class RuntimeContext {
|
|
31
31
|
});
|
32
32
|
const configuration = connector.configure().config(data.config || {});
|
33
33
|
const resolvers = {};
|
34
|
-
const methods = [...data.methods, '__autocomplete', '__endpoint', '
|
34
|
+
const methods = [...data.methods, '__autocomplete', '__endpoint', '__default'];
|
35
35
|
methods.forEach((method) => {
|
36
36
|
resolvers[method] = async (args) => {
|
37
37
|
if (!methods.includes(method))
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { ConfigField } from '../index.mjs';
|
1
2
|
import Fetcher from '../internal/fetcher/fetcher.mjs';
|
2
3
|
import { OAuth } from '../internal/fetcher/oauth-fetcher.mjs';
|
3
4
|
export declare abstract class AbstractController {
|
@@ -24,7 +25,6 @@ export declare abstract class AbstractController {
|
|
24
25
|
* @param isShutdown true if the controller is stopped due to shutdown
|
25
26
|
*/
|
26
27
|
protected stop(isShutdown?: boolean): Promise<void>;
|
27
|
-
protected configQuery(arg: any): Promise<any>;
|
28
28
|
/**
|
29
29
|
* autocomplete configuration options
|
30
30
|
*
|
@@ -96,12 +96,18 @@ export declare abstract class AbstractController {
|
|
96
96
|
*
|
97
97
|
* @param configSchema the schema of the config
|
98
98
|
*/
|
99
|
-
protected configCheck(configSchema:
|
99
|
+
protected configCheck(configSchema: {
|
100
|
+
[key: string]: ConfigField;
|
101
|
+
}): Promise<void>;
|
100
102
|
__endpoint(arg: any): Promise<any | null>;
|
101
|
-
__configQuery(arg: any): Promise<any | null>;
|
102
103
|
__autocomplete(arg: any): Promise<any | null>;
|
103
104
|
__default(arg: any): Promise<any | null>;
|
104
|
-
__healthCheck(configSchema:
|
105
|
+
__healthCheck(configSchema: {
|
106
|
+
[key: string]: ConfigField;
|
107
|
+
}): Promise<void>;
|
108
|
+
defaultConfigCheck(configSchema: {
|
109
|
+
[key: string]: ConfigField;
|
110
|
+
}): Promise<void>;
|
105
111
|
_doStart(config: any, oauth: any, newTask: any, updateTask: any, getClient: any, getBlob: any, getBlobContent: any, createBlob: any): Promise<void>;
|
106
112
|
_doStop(isShutdown?: boolean): Promise<void>;
|
107
113
|
}
|
@@ -20,9 +20,6 @@ export class AbstractController {
|
|
20
20
|
* @param isShutdown true if the controller is stopped due to shutdown
|
21
21
|
*/
|
22
22
|
async stop(isShutdown = false) { }
|
23
|
-
configQuery(arg) {
|
24
|
-
return Promise.resolve({});
|
25
|
-
}
|
26
23
|
/**
|
27
24
|
* autocomplete configuration options
|
28
25
|
*
|
@@ -103,9 +100,6 @@ export class AbstractController {
|
|
103
100
|
async __endpoint(arg) {
|
104
101
|
return this.endpoint(arg);
|
105
102
|
}
|
106
|
-
async __configQuery(arg) {
|
107
|
-
return this.configQuery(arg);
|
108
|
-
}
|
109
103
|
async __autocomplete(arg) {
|
110
104
|
return this.autocomplete(arg);
|
111
105
|
}
|
@@ -113,8 +107,43 @@ export class AbstractController {
|
|
113
107
|
return this.fallback(arg);
|
114
108
|
}
|
115
109
|
async __healthCheck(configSchema) {
|
116
|
-
|
117
|
-
|
110
|
+
const errors = [];
|
111
|
+
try {
|
112
|
+
await this.healthCheck();
|
113
|
+
}
|
114
|
+
catch (e) {
|
115
|
+
errors.push(e.message);
|
116
|
+
}
|
117
|
+
try {
|
118
|
+
await this.defaultConfigCheck(configSchema);
|
119
|
+
}
|
120
|
+
catch (e) {
|
121
|
+
errors.push(e.message);
|
122
|
+
}
|
123
|
+
try {
|
124
|
+
await this.configCheck(configSchema);
|
125
|
+
}
|
126
|
+
catch (e) {
|
127
|
+
errors.push(e.message);
|
128
|
+
}
|
129
|
+
if (errors.length) {
|
130
|
+
throw new Error(errors.join('\n'));
|
131
|
+
}
|
132
|
+
}
|
133
|
+
async defaultConfigCheck(configSchema) {
|
134
|
+
const config = this.config;
|
135
|
+
const missing = Object.entries(configSchema)
|
136
|
+
.map(([key, field]) => {
|
137
|
+
if (!field)
|
138
|
+
return;
|
139
|
+
if (!field.optional && config[key] == null) {
|
140
|
+
return `${field.name} is required`;
|
141
|
+
}
|
142
|
+
})
|
143
|
+
.filter((what) => !!what);
|
144
|
+
if (missing.length) {
|
145
|
+
throw new Error(missing.join('\n'));
|
146
|
+
}
|
118
147
|
}
|
119
148
|
async _doStart(config, oauth, newTask, updateTask, getClient, getBlob, getBlobContent, createBlob) {
|
120
149
|
this.config = config;
|
package/package.json
CHANGED
@@ -37,7 +37,7 @@ export default class RuntimeContext {
|
|
37
37
|
const configuration = connector.configure().config(data.config || {});
|
38
38
|
|
39
39
|
const resolvers: any = {};
|
40
|
-
const methods: string[] = [...data.methods, '__autocomplete', '__endpoint', '
|
40
|
+
const methods: string[] = [...data.methods, '__autocomplete', '__endpoint', '__default'];
|
41
41
|
|
42
42
|
methods.forEach((method) => {
|
43
43
|
resolvers[method] = async (args) => {
|
package/src/controller/index.mts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import {ConfigField} from '../index.mjs';
|
1
2
|
import Fetcher from '../internal/fetcher/fetcher.mjs';
|
2
3
|
import {OAuth} from '../internal/fetcher/oauth-fetcher.mjs';
|
3
4
|
|
@@ -28,10 +29,6 @@ export abstract class AbstractController {
|
|
28
29
|
*/
|
29
30
|
protected async stop(isShutdown: boolean = false): Promise<void> {}
|
30
31
|
|
31
|
-
protected configQuery(arg: any): Promise<any> {
|
32
|
-
return Promise.resolve({});
|
33
|
-
}
|
34
|
-
|
35
32
|
/**
|
36
33
|
* autocomplete configuration options
|
37
34
|
*
|
@@ -144,7 +141,7 @@ export abstract class AbstractController {
|
|
144
141
|
*
|
145
142
|
* @param configSchema the schema of the config
|
146
143
|
*/
|
147
|
-
protected async configCheck(configSchema:
|
144
|
+
protected async configCheck(configSchema: {[key: string]: ConfigField}): Promise<void> {
|
148
145
|
// blank, throw an error if the config is not valid
|
149
146
|
}
|
150
147
|
|
@@ -152,10 +149,6 @@ export abstract class AbstractController {
|
|
152
149
|
return this.endpoint(arg);
|
153
150
|
}
|
154
151
|
|
155
|
-
async __configQuery(arg: any): Promise<any | null> {
|
156
|
-
return this.configQuery(arg);
|
157
|
-
}
|
158
|
-
|
159
152
|
async __autocomplete(arg: any): Promise<any | null> {
|
160
153
|
return this.autocomplete(arg);
|
161
154
|
}
|
@@ -164,9 +157,48 @@ export abstract class AbstractController {
|
|
164
157
|
return this.fallback(arg);
|
165
158
|
}
|
166
159
|
|
167
|
-
async __healthCheck(configSchema:
|
168
|
-
|
169
|
-
|
160
|
+
async __healthCheck(configSchema: {[key: string]: ConfigField}): Promise<void> {
|
161
|
+
const errors: string[] = [];
|
162
|
+
|
163
|
+
try {
|
164
|
+
await this.healthCheck();
|
165
|
+
} catch (e: any) {
|
166
|
+
errors.push(e.message);
|
167
|
+
}
|
168
|
+
|
169
|
+
try {
|
170
|
+
await this.defaultConfigCheck(configSchema);
|
171
|
+
} catch (e: any) {
|
172
|
+
errors.push(e.message);
|
173
|
+
}
|
174
|
+
|
175
|
+
try {
|
176
|
+
await this.configCheck(configSchema);
|
177
|
+
} catch (e: any) {
|
178
|
+
errors.push(e.message);
|
179
|
+
}
|
180
|
+
|
181
|
+
if (errors.length) {
|
182
|
+
throw new Error(errors.join('\n'));
|
183
|
+
}
|
184
|
+
}
|
185
|
+
|
186
|
+
async defaultConfigCheck(configSchema: {[key: string]: ConfigField}): Promise<void> {
|
187
|
+
const config = this.config;
|
188
|
+
|
189
|
+
const missing = Object.entries(configSchema)
|
190
|
+
.map(([key, field]) => {
|
191
|
+
if (!field) return;
|
192
|
+
|
193
|
+
if (!field.optional && config[key] == null) {
|
194
|
+
return `${field.name} is required`;
|
195
|
+
}
|
196
|
+
})
|
197
|
+
.filter((what) => !!what);
|
198
|
+
|
199
|
+
if (missing.length) {
|
200
|
+
throw new Error(missing.join('\n'));
|
201
|
+
}
|
170
202
|
}
|
171
203
|
|
172
204
|
async _doStart(
|