@keragon/connector-cli 0.0.5 → 0.0.6
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/assets/templates/add/pollingtrigger/src/components/<%= componentName %>/<%= componentName %>.definition.json.ejs +8 -14
- package/assets/templates/add/trigger/src/components/<%= componentName %>/<%= componentName %>.definition.json.ejs +9 -17
- package/assets/templates/add/trigger/src/components/<%= componentName %>/<%= componentName %>.ts.ejs +6 -9
- package/main.js +1 -1
- package/package.json +2 -3
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
"title": "<%= title %>",
|
|
4
4
|
"description": "<%= desc %>",
|
|
5
5
|
"type": "trigger",
|
|
6
|
-
"sdkVersion": "0.0.1"
|
|
7
|
-
|
|
8
|
-
,"alerts": [{
|
|
6
|
+
"sdkVersion": "0.0.1"<% if (alert) { %>,
|
|
7
|
+
"alerts": [{
|
|
9
8
|
"type": "info",
|
|
10
|
-
"content": "
|
|
11
|
-
}]
|
|
12
|
-
<% } %>,
|
|
9
|
+
"content": "TODO: Add alert message. You can change the type to 'warning' or 'error' if needed."
|
|
10
|
+
}]<% } %>,
|
|
13
11
|
"poll": {
|
|
14
12
|
"schedule": {
|
|
15
13
|
"cron": "*/5 * * * *"
|
|
@@ -23,15 +21,12 @@
|
|
|
23
21
|
"processInputs": "${ { event: .event } }",
|
|
24
22
|
"processOutputs": "${ . | sort_by(.created_time) | reverse }"
|
|
25
23
|
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
,"inputs": {
|
|
24
|
+
}<% if (inputs) { %>,
|
|
25
|
+
"inputs": {
|
|
29
26
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
30
27
|
"type": "object",
|
|
31
28
|
"additionalProperties": false,
|
|
32
|
-
"required": [
|
|
33
|
-
"event"
|
|
34
|
-
],
|
|
29
|
+
"required": ["event"],
|
|
35
30
|
"properties": {
|
|
36
31
|
"event": {
|
|
37
32
|
"type": "string",
|
|
@@ -43,6 +38,5 @@
|
|
|
43
38
|
}
|
|
44
39
|
}
|
|
45
40
|
}
|
|
46
|
-
}
|
|
47
|
-
<% } %>
|
|
41
|
+
}<% } %>
|
|
48
42
|
}
|
|
@@ -3,29 +3,22 @@
|
|
|
3
3
|
"title": "<%= title %>",
|
|
4
4
|
"description": "<%= desc %>",
|
|
5
5
|
"type": "trigger",
|
|
6
|
-
"sdkVersion": "0.0.1"
|
|
7
|
-
|
|
8
|
-
,"alerts": [{
|
|
6
|
+
"sdkVersion": "0.0.1"<% if (alert) { %>,
|
|
7
|
+
"alerts": [{
|
|
9
8
|
"type": "info",
|
|
10
|
-
"content": "
|
|
11
|
-
}]
|
|
12
|
-
|
|
13
|
-
<% if (http) { %>
|
|
14
|
-
,"request": {
|
|
9
|
+
"content": "TODO: Add alert message. You can change the type to 'warning' or 'error' if needed."
|
|
10
|
+
}]<% } %><% if (http) { %>,
|
|
11
|
+
"request": {
|
|
15
12
|
"config": {
|
|
16
13
|
"method": "get",
|
|
17
14
|
"url": "/"
|
|
18
15
|
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
<% if (inputs) { %>
|
|
22
|
-
,"inputs": {
|
|
16
|
+
}<% } %><% if (inputs) { %>,
|
|
17
|
+
"inputs": {
|
|
23
18
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
24
19
|
"type": "object",
|
|
25
20
|
"additionalProperties": false,
|
|
26
|
-
"required": [
|
|
27
|
-
"event"
|
|
28
|
-
],
|
|
21
|
+
"required": ["event"],
|
|
29
22
|
"properties": {
|
|
30
23
|
"event": {
|
|
31
24
|
"type": "string",
|
|
@@ -37,6 +30,5 @@
|
|
|
37
30
|
}
|
|
38
31
|
}
|
|
39
32
|
}
|
|
40
|
-
}
|
|
41
|
-
<% } %>
|
|
33
|
+
}<% } %>
|
|
42
34
|
}
|
package/assets/templates/add/trigger/src/components/<%= componentName %>/<%= componentName %>.ts.ejs
CHANGED
|
@@ -8,27 +8,22 @@ import {
|
|
|
8
8
|
<%= http ? 'HttpComponent' : 'Component' %>,
|
|
9
9
|
} from '@keragon/connector-sdk';
|
|
10
10
|
|
|
11
|
-
const WEBHOOK_ID = 'webhookID';
|
|
12
|
-
const WEBHOOK_URL = 'webhookURL';
|
|
13
|
-
|
|
14
11
|
export default class <%= firstLetterUpperCase(componentName) %> extends <%- http ? 'HttpComponent<HttpApp>' : 'Component<App>' %> implements HasSampleEvents {
|
|
15
12
|
|
|
16
13
|
override async configure(inputs: Record<string, unknown> = {}, webhookURL: string, ..._rest: string[]) {
|
|
17
|
-
if (this.store.get(
|
|
14
|
+
if (this.store.get('webhookID')) {
|
|
18
15
|
await this.deactivate();
|
|
19
16
|
}
|
|
20
17
|
const configuredInputs = await super.configure(inputs);
|
|
21
18
|
const url = new URL(webhookURL);
|
|
22
19
|
url.pathname = url.pathname.replace('/v1/', '/v2/');
|
|
23
20
|
url.searchParams.set('triggerId', this.definition.id.toLowerCase());
|
|
24
|
-
this.store.set(
|
|
25
|
-
this.store.set(WEBHOOK_URL, url.toString());
|
|
21
|
+
this.store.set('webhookURL', url.toString());
|
|
26
22
|
|
|
27
23
|
const client = await this.app.getClient();
|
|
28
24
|
try {
|
|
29
25
|
const { data: { id } } = await client.post('/', {});
|
|
30
|
-
this.store.set(
|
|
31
|
-
this.store.set(WEBHOOK_ID, id);
|
|
26
|
+
this.store.set('webhookID', id);
|
|
32
27
|
return configuredInputs;
|
|
33
28
|
} catch (error) {
|
|
34
29
|
throw new Error(`Failed to configure ${this.definition.id} because ${extractErrorMessage(error)}.`);
|
|
@@ -45,7 +40,9 @@ export default class <%= firstLetterUpperCase(componentName) %> extends <%- http
|
|
|
45
40
|
|
|
46
41
|
override async deactivate() {
|
|
47
42
|
try {
|
|
48
|
-
this.store.delete(
|
|
43
|
+
this.store.delete('webhookURL');
|
|
44
|
+
this.store.delete('webhookID');
|
|
45
|
+
// TODO: delete webhook from API
|
|
49
46
|
} catch (error) {
|
|
50
47
|
throw new Error(`Failed to deactivate "${this.definition.id}" because ${extractErrorMessage(error)}`);
|
|
51
48
|
}
|