@keragon/connector-cli 0.0.5 → 0.0.8

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.
@@ -0,0 +1,28 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Local Server</title>
8
+ <style>
9
+ body,
10
+ html {
11
+ margin: 0;
12
+ padding: 0;
13
+ height: 100%;
14
+ overflow: hidden;
15
+ }
16
+
17
+ iframe {
18
+ width: 100%;
19
+ height: 100%;
20
+ border: none;
21
+ }
22
+ </style>
23
+ </head>
24
+
25
+ <body>
26
+ <iframe id="preview-component-iframe" src="<%= iframeHost %>/preview-component?endpoint=http://localhost:<%= localServerPort %>"></iframe>
27
+ </body>
28
+ </html>
@@ -22,8 +22,8 @@
22
22
  if (http) {
23
23
  obj.request = {
24
24
  config: {
25
- method: "get",
26
- url: "/"
25
+ method: (typeof method === 'string' && method) ? method.toLowerCase() : "get",
26
+ url: (typeof url === 'string' && url) ? url : "/"
27
27
  },
28
28
  };
29
29
  }
@@ -96,8 +96,8 @@
96
96
  if (outputs) {
97
97
  obj.outputs = {
98
98
  "$schema": "https://json-schema.org/draft/2020-12/schema",
99
- type: "array",
100
- title: "Items",
99
+ type: "object",
100
+ title: "Item",
101
101
  properties: {
102
102
  id: {
103
103
  type: "string",
@@ -110,5 +110,4 @@
110
110
  }
111
111
  };
112
112
  }
113
- %>
114
- <%- JSON.stringify(obj, null, 2) %>
113
+ %><%- JSON.stringify(obj, null, 2) %>
@@ -3,13 +3,11 @@
3
3
  "title": "<%= title %>",
4
4
  "description": "<%= desc %>",
5
5
  "type": "trigger",
6
- "sdkVersion": "0.0.1"
7
- <% if (alert) { %>
8
- ,"alerts": [{
6
+ "sdkVersion": "0.0.1"<% if (alert) { %>,
7
+ "alerts": [{
9
8
  "type": "info",
10
- "content": "Due to vendor limitations you can have only one polling trigger"
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
- <% if (inputs) { %>
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
- <% if (alert) { %>
8
- ,"alerts": [{
6
+ "sdkVersion": "0.0.1"<% if (alert) { %>,
7
+ "alerts": [{
9
8
  "type": "info",
10
- "content": "Please follow the [article](https://go.keragon.com/<%= componentName %>) to set up the trigger"
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
  }
@@ -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(WEBHOOK_ID)) {
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(WEBHOOK_URL, url.toString());
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(WEBHOOK_URL, webhookURL);
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(WEBHOOK_URL);
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
  }
@@ -1,3 +1,3 @@
1
1
  {
2
2
  "name": "<%= name %>"
3
- }
3
+ }
@@ -6,5 +6,14 @@
6
6
  "description": "<%= desc %>",
7
7
  "version": "0.0.1",
8
8
  "environments": [
9
+ {
10
+ "id": "com.keragon.<%= name %>.environments.prod",
11
+ "title": "Production",
12
+ "description": "Production environment"<% if (http) { %>,
13
+ "requestDefaults": {
14
+ "baseURL": "<%= baseUrl ? baseUrl : '<Replace with base URL>' %>"
15
+ },
16
+ "supportedAuthSchemes": []<% } %>
17
+ }
9
18
  ]
10
19
  }