@aloma.io/integration-sdk 3.8.33 → 3.8.35
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,7 +1,13 @@
|
|
1
1
|
import { AbstractController } from '../controller/index.mjs';
|
2
|
+
/**
|
3
|
+
* Runtime context to manage the lifecycle of the connector
|
4
|
+
*/
|
2
5
|
export default class RuntimeContext {
|
3
6
|
private controller;
|
4
7
|
private data;
|
5
8
|
constructor(controller: AbstractController, data: any);
|
9
|
+
/**
|
10
|
+
* start the connector
|
11
|
+
*/
|
6
12
|
start(): Promise<void>;
|
7
13
|
}
|
@@ -1,6 +1,9 @@
|
|
1
1
|
import fs from 'node:fs';
|
2
2
|
import { AbstractController } from '../controller/index.mjs';
|
3
3
|
import { Connector } from '../internal/index.mjs';
|
4
|
+
/**
|
5
|
+
* Runtime context to manage the lifecycle of the connector
|
6
|
+
*/
|
4
7
|
export default class RuntimeContext {
|
5
8
|
controller;
|
6
9
|
data;
|
@@ -8,6 +11,9 @@ export default class RuntimeContext {
|
|
8
11
|
this.controller = controller;
|
9
12
|
this.data = data;
|
10
13
|
}
|
14
|
+
/**
|
15
|
+
* start the connector
|
16
|
+
*/
|
11
17
|
async start() {
|
12
18
|
const controller = this.controller;
|
13
19
|
if (!(controller instanceof AbstractController)) {
|
@@ -1,6 +1,10 @@
|
|
1
1
|
import { ConfigField } from '../index.mjs';
|
2
2
|
import Fetcher from '../internal/fetcher/fetcher.mjs';
|
3
3
|
import { OAuth } from '../internal/fetcher/oauth-fetcher.mjs';
|
4
|
+
/**
|
5
|
+
* Abstract controller class
|
6
|
+
* this needs to be used in a connector
|
7
|
+
*/
|
4
8
|
export declare abstract class AbstractController {
|
5
9
|
/**
|
6
10
|
* connector configuration
|
@@ -42,6 +46,11 @@ export declare abstract class AbstractController {
|
|
42
46
|
* @param arg
|
43
47
|
*/
|
44
48
|
protected fallback(arg: any): Promise<any>;
|
49
|
+
/**
|
50
|
+
* will be invoked, when the connector has an endpoint enabled
|
51
|
+
* will receive the data and can e.g. create a new task from it
|
52
|
+
* @param arg
|
53
|
+
*/
|
45
54
|
protected endpoint(arg: any): Promise<any>;
|
46
55
|
/**
|
47
56
|
* create a new task
|
@@ -49,6 +58,12 @@ export declare abstract class AbstractController {
|
|
49
58
|
* @param data data of the task
|
50
59
|
*/
|
51
60
|
protected newTask(name: string, data: any): Promise<string>;
|
61
|
+
/**
|
62
|
+
* get a client to make requests
|
63
|
+
* @param baseUrl base url of the client
|
64
|
+
* @param onResponse callback to be invoked on response
|
65
|
+
* @param customize callback to customize the request
|
66
|
+
*/
|
52
67
|
protected getClient({ baseUrl, onResponse, customize, }: {
|
53
68
|
baseUrl?: string;
|
54
69
|
onResponse?: (response: any) => void;
|
@@ -61,6 +76,15 @@ export declare abstract class AbstractController {
|
|
61
76
|
* @returns taskId
|
62
77
|
*/
|
63
78
|
protected updateTask(name: string, data: any): Promise<string>;
|
79
|
+
/**
|
80
|
+
* create a blob
|
81
|
+
* @param content content of the blob in base64
|
82
|
+
* @param name name of the blob
|
83
|
+
* @param size size of the blob
|
84
|
+
* @param mimetype mimetype of the blob
|
85
|
+
* @param meta meta data of the blob
|
86
|
+
* @param taskId id of the task
|
87
|
+
*/
|
64
88
|
protected createBlob({ content, name, size, mimetype, meta, taskId, }: {
|
65
89
|
content: string;
|
66
90
|
name?: string;
|
@@ -99,13 +123,34 @@ export declare abstract class AbstractController {
|
|
99
123
|
protected configCheck(configSchema: {
|
100
124
|
[key: string]: ConfigField;
|
101
125
|
}): Promise<void>;
|
126
|
+
/**
|
127
|
+
* @ignore
|
128
|
+
**/
|
102
129
|
__endpoint(arg: any): Promise<any | null>;
|
130
|
+
/**
|
131
|
+
* @ignore
|
132
|
+
**/
|
103
133
|
__autocomplete(arg: any): Promise<any | null>;
|
134
|
+
/**
|
135
|
+
* @ignore
|
136
|
+
**/
|
104
137
|
__default(arg: any): Promise<any | null>;
|
138
|
+
/**
|
139
|
+
* @ignore
|
140
|
+
**/
|
105
141
|
__healthCheck(configSchema: () => {
|
106
142
|
[key: string]: ConfigField;
|
107
143
|
}): Promise<void>;
|
144
|
+
/**
|
145
|
+
* @ignore
|
146
|
+
**/
|
108
147
|
private defaultConfigCheck;
|
148
|
+
/**
|
149
|
+
* @ignore
|
150
|
+
**/
|
109
151
|
_doStart(config: any, oauth: any, newTask: any, updateTask: any, getClient: any, getBlob: any, getBlobContent: any, createBlob: any): Promise<void>;
|
152
|
+
/**
|
153
|
+
* @ignore
|
154
|
+
**/
|
110
155
|
_doStop(isShutdown?: boolean): Promise<void>;
|
111
156
|
}
|
@@ -1,3 +1,7 @@
|
|
1
|
+
/**
|
2
|
+
* Abstract controller class
|
3
|
+
* this needs to be used in a connector
|
4
|
+
*/
|
1
5
|
export class AbstractController {
|
2
6
|
/**
|
3
7
|
* connector configuration
|
@@ -31,7 +35,7 @@ export class AbstractController {
|
|
31
35
|
* @param arg
|
32
36
|
* @returns
|
33
37
|
*/
|
34
|
-
autocomplete(arg) {
|
38
|
+
async autocomplete(arg) {
|
35
39
|
return Promise.resolve({});
|
36
40
|
}
|
37
41
|
/**
|
@@ -41,6 +45,11 @@ export class AbstractController {
|
|
41
45
|
fallback(arg) {
|
42
46
|
throw new Error('method not found');
|
43
47
|
}
|
48
|
+
/**
|
49
|
+
* will be invoked, when the connector has an endpoint enabled
|
50
|
+
* will receive the data and can e.g. create a new task from it
|
51
|
+
* @param arg
|
52
|
+
*/
|
44
53
|
async endpoint(arg) {
|
45
54
|
throw new Error('method not found');
|
46
55
|
}
|
@@ -52,6 +61,12 @@ export class AbstractController {
|
|
52
61
|
async newTask(name, data) {
|
53
62
|
throw new Error('not implemented');
|
54
63
|
}
|
64
|
+
/**
|
65
|
+
* get a client to make requests
|
66
|
+
* @param baseUrl base url of the client
|
67
|
+
* @param onResponse callback to be invoked on response
|
68
|
+
* @param customize callback to customize the request
|
69
|
+
*/
|
55
70
|
getClient({ baseUrl, onResponse, customize, }) {
|
56
71
|
throw new Error('not implemented');
|
57
72
|
}
|
@@ -64,6 +79,15 @@ export class AbstractController {
|
|
64
79
|
async updateTask(name, data) {
|
65
80
|
throw new Error('not implemented');
|
66
81
|
}
|
82
|
+
/**
|
83
|
+
* create a blob
|
84
|
+
* @param content content of the blob in base64
|
85
|
+
* @param name name of the blob
|
86
|
+
* @param size size of the blob
|
87
|
+
* @param mimetype mimetype of the blob
|
88
|
+
* @param meta meta data of the blob
|
89
|
+
* @param taskId id of the task
|
90
|
+
*/
|
67
91
|
async createBlob({ content, name, size, mimetype, meta, taskId, }) {
|
68
92
|
throw new Error('not implemented');
|
69
93
|
}
|
@@ -97,15 +121,27 @@ export class AbstractController {
|
|
97
121
|
async configCheck(configSchema) {
|
98
122
|
// blank, throw an error if the config is not valid
|
99
123
|
}
|
124
|
+
/**
|
125
|
+
* @ignore
|
126
|
+
**/
|
100
127
|
async __endpoint(arg) {
|
101
128
|
return this.endpoint(arg);
|
102
129
|
}
|
130
|
+
/**
|
131
|
+
* @ignore
|
132
|
+
**/
|
103
133
|
async __autocomplete(arg) {
|
104
134
|
return this.autocomplete(arg);
|
105
135
|
}
|
136
|
+
/**
|
137
|
+
* @ignore
|
138
|
+
**/
|
106
139
|
async __default(arg) {
|
107
140
|
return this.fallback(arg);
|
108
141
|
}
|
142
|
+
/**
|
143
|
+
* @ignore
|
144
|
+
**/
|
109
145
|
async __healthCheck(configSchema) {
|
110
146
|
const errors = [];
|
111
147
|
const schema = configSchema();
|
@@ -132,6 +168,9 @@ export class AbstractController {
|
|
132
168
|
throw new Error(errors.join('\n'));
|
133
169
|
}
|
134
170
|
}
|
171
|
+
/**
|
172
|
+
* @ignore
|
173
|
+
**/
|
135
174
|
async defaultConfigCheck(configSchema) {
|
136
175
|
const config = this.config;
|
137
176
|
const missing = Object.entries(configSchema)
|
@@ -147,6 +186,9 @@ export class AbstractController {
|
|
147
186
|
throw new Error(missing.join('\n'));
|
148
187
|
}
|
149
188
|
}
|
189
|
+
/**
|
190
|
+
* @ignore
|
191
|
+
**/
|
150
192
|
async _doStart(config, oauth, newTask, updateTask, getClient, getBlob, getBlobContent, createBlob) {
|
151
193
|
this.config = config;
|
152
194
|
this.client = oauth;
|
@@ -159,6 +201,9 @@ export class AbstractController {
|
|
159
201
|
this.getBlobContent = getBlobContent;
|
160
202
|
await this.start();
|
161
203
|
}
|
204
|
+
/**
|
205
|
+
* @ignore
|
206
|
+
**/
|
162
207
|
async _doStop(isShutdown = false) {
|
163
208
|
await this.stop(isShutdown);
|
164
209
|
}
|
package/package.json
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
import fs from 'node:fs';
|
2
|
-
import {AbstractController} from '../controller/index.mjs';
|
3
|
-
import {Connector} from '../internal/index.mjs';
|
2
|
+
import { AbstractController } from '../controller/index.mjs';
|
3
|
+
import { Connector } from '../internal/index.mjs';
|
4
4
|
|
5
|
+
/**
|
6
|
+
* Runtime context to manage the lifecycle of the connector
|
7
|
+
*/
|
5
8
|
export default class RuntimeContext {
|
6
9
|
constructor(
|
7
10
|
private controller: AbstractController,
|
8
11
|
private data: any
|
9
12
|
) {}
|
10
13
|
|
14
|
+
/**
|
15
|
+
* start the connector
|
16
|
+
*/
|
11
17
|
async start(): Promise<void> {
|
12
18
|
const controller = this.controller;
|
13
19
|
|
package/src/controller/index.mts
CHANGED
@@ -2,6 +2,10 @@ import { ConfigField } from '../index.mjs';
|
|
2
2
|
import Fetcher from '../internal/fetcher/fetcher.mjs';
|
3
3
|
import { OAuth } from '../internal/fetcher/oauth-fetcher.mjs';
|
4
4
|
|
5
|
+
/**
|
6
|
+
* Abstract controller class
|
7
|
+
* this needs to be used in a connector
|
8
|
+
*/
|
5
9
|
export abstract class AbstractController {
|
6
10
|
/**
|
7
11
|
* connector configuration
|
@@ -40,7 +44,7 @@ export abstract class AbstractController {
|
|
40
44
|
* @param arg
|
41
45
|
* @returns
|
42
46
|
*/
|
43
|
-
protected autocomplete(arg: any): Promise<any> {
|
47
|
+
protected async autocomplete(arg: any): Promise<any> {
|
44
48
|
return Promise.resolve({});
|
45
49
|
}
|
46
50
|
|
@@ -52,6 +56,11 @@ export abstract class AbstractController {
|
|
52
56
|
throw new Error('method not found');
|
53
57
|
}
|
54
58
|
|
59
|
+
/**
|
60
|
+
* will be invoked, when the connector has an endpoint enabled
|
61
|
+
* will receive the data and can e.g. create a new task from it
|
62
|
+
* @param arg
|
63
|
+
*/
|
55
64
|
protected async endpoint(arg: any): Promise<any> {
|
56
65
|
throw new Error('method not found');
|
57
66
|
}
|
@@ -65,6 +74,12 @@ export abstract class AbstractController {
|
|
65
74
|
throw new Error('not implemented');
|
66
75
|
}
|
67
76
|
|
77
|
+
/**
|
78
|
+
* get a client to make requests
|
79
|
+
* @param baseUrl base url of the client
|
80
|
+
* @param onResponse callback to be invoked on response
|
81
|
+
* @param customize callback to customize the request
|
82
|
+
*/
|
68
83
|
protected getClient({
|
69
84
|
baseUrl,
|
70
85
|
onResponse,
|
@@ -87,6 +102,15 @@ export abstract class AbstractController {
|
|
87
102
|
throw new Error('not implemented');
|
88
103
|
}
|
89
104
|
|
105
|
+
/**
|
106
|
+
* create a blob
|
107
|
+
* @param content content of the blob in base64
|
108
|
+
* @param name name of the blob
|
109
|
+
* @param size size of the blob
|
110
|
+
* @param mimetype mimetype of the blob
|
111
|
+
* @param meta meta data of the blob
|
112
|
+
* @param taskId id of the task
|
113
|
+
*/
|
90
114
|
protected async createBlob({
|
91
115
|
content,
|
92
116
|
name,
|
@@ -145,18 +169,30 @@ export abstract class AbstractController {
|
|
145
169
|
// blank, throw an error if the config is not valid
|
146
170
|
}
|
147
171
|
|
172
|
+
/**
|
173
|
+
* @ignore
|
174
|
+
**/
|
148
175
|
async __endpoint(arg: any): Promise<any | null> {
|
149
176
|
return this.endpoint(arg);
|
150
177
|
}
|
151
178
|
|
179
|
+
/**
|
180
|
+
* @ignore
|
181
|
+
**/
|
152
182
|
async __autocomplete(arg: any): Promise<any | null> {
|
153
183
|
return this.autocomplete(arg);
|
154
184
|
}
|
155
185
|
|
186
|
+
/**
|
187
|
+
* @ignore
|
188
|
+
**/
|
156
189
|
async __default(arg: any): Promise<any | null> {
|
157
190
|
return this.fallback(arg);
|
158
191
|
}
|
159
192
|
|
193
|
+
/**
|
194
|
+
* @ignore
|
195
|
+
**/
|
160
196
|
async __healthCheck(configSchema: () => {[key: string]: ConfigField}): Promise<void> {
|
161
197
|
const errors: string[] = [];
|
162
198
|
const schema = configSchema();
|
@@ -185,6 +221,9 @@ export abstract class AbstractController {
|
|
185
221
|
}
|
186
222
|
}
|
187
223
|
|
224
|
+
/**
|
225
|
+
* @ignore
|
226
|
+
**/
|
188
227
|
private async defaultConfigCheck(configSchema: {[key: string]: ConfigField}): Promise<void> {
|
189
228
|
const config = this.config;
|
190
229
|
|
@@ -203,6 +242,9 @@ export abstract class AbstractController {
|
|
203
242
|
}
|
204
243
|
}
|
205
244
|
|
245
|
+
/**
|
246
|
+
* @ignore
|
247
|
+
**/
|
206
248
|
async _doStart(
|
207
249
|
config: any,
|
208
250
|
oauth: any,
|
@@ -226,6 +268,9 @@ export abstract class AbstractController {
|
|
226
268
|
await this.start();
|
227
269
|
}
|
228
270
|
|
271
|
+
/**
|
272
|
+
* @ignore
|
273
|
+
**/
|
229
274
|
async _doStop(isShutdown: boolean = false): Promise<void> {
|
230
275
|
await this.stop(isShutdown);
|
231
276
|
}
|