@keragon/connector-cli 0.0.4 → 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/README.md +14 -82
- 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 +3 -3
package/README.md
CHANGED
|
@@ -1,91 +1,23 @@
|
|
|
1
|
-
# Keragon
|
|
1
|
+
# Keragon Connector CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The official command-line interface (CLI) for building, testing, and managing connectors on the Keragon platform.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- [App configuration setup](https://www.notion.so/App-Config-b7f62c2df4324b329cf9e41412b2f3de)
|
|
5
|
+
## Installation
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
**Why Nx?**
|
|
13
|
-
|
|
14
|
-
- Code generation / scaffolding — generators generate applications, components, standard pieces of code (like cookie-cutters) — they also help you migrate across versions. This helps to maintain consistency as we grow.
|
|
15
|
-
- Dependency graph and code change analysis — only build/test/lint projects that are affected by a code change — Nx understands your workspace, and makes optimizations — it also visualizes the dependencies with the dependency graph
|
|
16
|
-
- Speed — computation caching will ensure that when you rerun the same command, the results will be fetched from the cache — together with the affected command and distributed task execution and Nx Cloud you never build/test/lint the same code twice
|
|
17
|
-
- Nx CLI — Integrated environment with consistent syntax for executing commands.
|
|
18
|
-
- Plugins — for modern web technologies and tools include their own executors and generators which will help you develop projects using the tools you like
|
|
19
|
-
- IDE integration — Nx Editor Plugins give you access to all that the Nx CLI can do, but from a GUI.
|
|
20
|
-
|
|
21
|
-
[Source](https://blog.nrwl.io/build-your-design-system-with-storybook-nx-e3bde4087ad8)
|
|
22
|
-
|
|
23
|
-
## Packages
|
|
24
|
-
|
|
25
|
-
This monorepo contains the following packages:
|
|
26
|
-
|
|
27
|
-
| Subfolder | Description |
|
|
28
|
-
|------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|
|
|
29
|
-
| [`apps/api/`](apps/api/) | This package hosts Keragon's API
|
|
30
|
-
| [`apps/billing`](apps/billing/) | Billing service (temporal worker billing)
|
|
31
|
-
| [`apps/dashboard/`](apps/dashboard) | A web app for building workflows visually |
|
|
32
|
-
| [`apps/dsl-runtime/`](apps/dsl-runtime) | This package is used to run workflows and manage their runtime |
|
|
33
|
-
| [`packages/catalog-client`](packages/catalog-client) | Connector catalog client as source of truth for available connectors in Keragon
|
|
34
|
-
| [`packages/dsl-sdk/`](packages/dsl-sdk) | The DSL SDK is used to build and manipulate Keragon's workflow DSL |
|
|
35
|
-
| [`packages/authentications/`](packages/authentications) | This package manages 3rd party app authorizations |
|
|
36
|
-
| [`packages/connector-sdk/`](packages/connector-sdk/) | This is the SDK for building new connectors.
|
|
37
|
-
| [`packages/connectors/`](packages/connectors/) | This package hosts all the Keragon built-in connectors.
|
|
38
|
-
| [`packages/copilot`](packages/copilot/) | A Langgraph implementation of our Copilot
|
|
39
|
-
| [`packages/fixtures/`](packages/fixtures/) | This package hosts fixtures reused in tests across Keragon. This is the central place with the latest DSL configuration too.
|
|
40
|
-
| [`packages/secrets-manager/`](packages/secrets-manager/) | A wrapper around AWS Secrets Manager and KMS clients to be reused across the monorepo.
|
|
41
|
-
| [`packages/jq-parser/`](packages/jq-parser/) | Parses JQ expressions into easily parsable structures.
|
|
42
|
-
| [`packages/dashboard-auth/`](packages/dashboard-auth/) | React components related to the auth flow in the dashboard.
|
|
43
|
-
| [`packages/shared/ui/`](packages/shared/ui/) | Keragon's reusable React components.
|
|
44
|
-
| [`packages/shared/util-credentials/`](packages/shared/util-credentials/) | Credentials related utility methods that are reused across the monorepo.
|
|
45
|
-
| [`packages/shared/types/`](packages/shared/types/) | Typescript types/interfaces/classes that are reused across the monorepo.
|
|
46
|
-
| [`packages/shared/util-dsl/`](packages/shared/util-dsl/) | Utilities to work with the specific way we use the Serverless DSL in Keragon.
|
|
47
|
-
| [`packages/shared/util-jsonschema`](packages/shared/util-jsonschema/) | Utilities to work with json schema that are not available out there eg. `evalSchema`
|
|
48
|
-
|
|
49
|
-
## Main commands
|
|
50
|
-
|
|
51
|
-
### Installing dependencies in workspaces
|
|
52
|
-
|
|
53
|
-
`npm install <dep-name> -w @keragon/<package-name>`
|
|
54
|
-
|
|
55
|
-
### Building packages
|
|
56
|
-
|
|
57
|
-
- `nx run-many --target=build` (build all)
|
|
58
|
-
- `nx run <prohect-name:>build` (build only the specified package)
|
|
59
|
-
|
|
60
|
-
### Running tests
|
|
61
|
-
|
|
62
|
-
- `nx run-many --target=test` (build all)
|
|
63
|
-
|
|
64
|
-
### Running eslint
|
|
65
|
-
|
|
66
|
-
- `nx run-many --target=lint`
|
|
67
|
-
|
|
68
|
-
### Bootstraping packages
|
|
69
|
-
|
|
70
|
-
`npm install`
|
|
71
|
-
|
|
72
|
-
## How to create a new package
|
|
73
|
-
|
|
74
|
-
Use an Nx app or library generator. See [docs](https://nx.dev/packages/workspace/generators/new)
|
|
75
|
-
|
|
76
|
-
You can install Nx Console in your editor (if suppported) to run these commands from the UI.
|
|
77
|
-
|
|
78
|
-
# Service Starter Script
|
|
79
|
-
|
|
80
|
-
This script is designed to simplify the process of starting various services in a development environment, including an `ngrok` tunnel and services like `api`, `processor`, `dsl-runtime`, `dashboard`, and `lambda`.
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @keragon/connector-cli
|
|
9
|
+
```
|
|
81
10
|
|
|
82
11
|
## Usage
|
|
83
12
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
`./start-services.sh [options] [services...]`
|
|
13
|
+
Run the following command to display a list of all available commands:
|
|
87
14
|
|
|
88
|
-
|
|
15
|
+
```bash
|
|
16
|
+
kc --help
|
|
17
|
+
```
|
|
89
18
|
|
|
90
|
-
|
|
19
|
+
Each command supports its own help flag for detailed usage information. For example:
|
|
91
20
|
|
|
21
|
+
```bash
|
|
22
|
+
kc login --help
|
|
23
|
+
```
|
|
@@ -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
|
}
|