@keragon/connector-cli 0.0.1 → 0.0.3

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 ADDED
@@ -0,0 +1,91 @@
1
+ # Keragon monorepo
2
+
3
+ Welcome to Keragon's monorepo! Please read below for more info and instructions on how to use.
4
+
5
+ - [Local development setup guide](https://www.notion.so/keragon/Keragon-Local-Development-Guide-160d9e88eb8e46bdad51d8b33a865f3d)
6
+ - [App configuration setup](https://www.notion.so/App-Config-b7f62c2df4324b329cf9e41412b2f3de)
7
+
8
+ ## Nx
9
+
10
+ Keragon uses [Nx](https://nx.dev/) to build, maintain and grow our codebase.
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`.
81
+
82
+ ## Usage
83
+
84
+ To use the script, you may specify one or more services you wish to start. If no services are specified, all available services will be started by default.
85
+
86
+ `./start-services.sh [options] [services...]`
87
+
88
+ ### Options
89
+
90
+ - `-h`, `--help`: Display the help message and exit.
91
+
@@ -7,19 +7,19 @@
7
7
  const obj = {
8
8
  id: componentId,
9
9
  title: formatComponentTitle(componentName),
10
- description: desc,
10
+ description: desc ?? "",
11
11
  type: "action",
12
12
  sdkVersion: "0.0.1"
13
13
  };
14
14
 
15
- if (typeof alert !== 'undefined') {
15
+ if (alert) {
16
16
  obj.alerts = [{
17
17
  type: "info",
18
18
  content: `More info in [article](https://go.keragon.com/${componentName})`
19
19
  }];
20
20
  }
21
21
 
22
- if (typeof http !== 'undefined') {
22
+ if (http) {
23
23
  obj.request = {
24
24
  config: {
25
25
  method: "get",
@@ -28,7 +28,7 @@
28
28
  };
29
29
  }
30
30
 
31
- if (typeof pagination !== 'undefined') {
31
+ if (pagination) {
32
32
  obj.pagination = {
33
33
  strategy: pagination,
34
34
  maxItems: "${ .inputs.maxItems // 250 }"
@@ -54,7 +54,7 @@
54
54
  }
55
55
  }
56
56
 
57
- if (typeof errorHandler !== 'undefined') {
57
+ if (errorHandler) {
58
58
  obj.response = {
59
59
  errorHandlers: [{
60
60
  condition: "${ .response.status != 200 }",
@@ -64,7 +64,7 @@
64
64
  };
65
65
  }
66
66
 
67
- if (typeof inputs !== 'undefined') {
67
+ if (inputs) {
68
68
  obj.inputs = {
69
69
  "$schema": "https://json-schema.org/draft/2020-12/schema",
70
70
  type: "object",
@@ -74,6 +74,7 @@
74
74
  id: {
75
75
  type: "string",
76
76
  title: "ID",
77
+ description: "ID of the item to retrieve",
77
78
  dynamicEnum: {
78
79
  componentId: `${connectorId}.get`,
79
80
  processInputs: "${ }",
@@ -83,7 +84,7 @@
83
84
  }
84
85
  };
85
86
 
86
- if (typeof pagination !== 'undefined') {
87
+ if (pagination) {
87
88
  obj.inputs.properties.maxItems = {
88
89
  type: "number",
89
90
  title: "Max items",
@@ -92,7 +93,7 @@
92
93
  }
93
94
  }
94
95
 
95
- if (typeof outputs !== 'undefined') {
96
+ if (outputs) {
96
97
  obj.outputs = {
97
98
  "$schema": "https://json-schema.org/draft/2020-12/schema",
98
99
  type: "array",
@@ -0,0 +1,36 @@
1
+ import {
2
+ Credentials
3
+ } from '@keragon/connector-sdk';
4
+ import app from '../src';
5
+ import <%= className %> from '../src/components/<%= name %>/<%= name %>';
6
+ const { definition, ctor: <%= firstLetterUpperCase(connectorName) %> } = app;
7
+
8
+ const setupTest = ({
9
+ credentials = {
10
+ authScheme: {
11
+ id: 'com.keragon.<%= connectorName %>.environments.prod.authSchemes.custom',
12
+ },
13
+ }
14
+ }: {
15
+ credentials?: Credentials
16
+ }) => {
17
+ const <%= connectorName %> = new <%= firstLetterUpperCase(connectorName) %>({
18
+ definition, credentials,
19
+ });
20
+ const component = <%= connectorName %>.constructComponent({ componentId: 'com.keragon.<%= connectorName %>.<%= name %>' }) as <%= className %>;
21
+
22
+ return { <%= connectorName %>, component, credentials }
23
+ };
24
+
25
+ describe('Component: <%= className %> should', () => {
26
+ it('implement run', async () => {
27
+ // Arrange
28
+ const { component } = setupTest({});
29
+
30
+ // Act
31
+ const outputs = await component.run({});
32
+
33
+ // Assert
34
+ expect(outputs).toBe({});
35
+ });
36
+ });
@@ -0,0 +1,34 @@
1
+ import {
2
+ <%= isHttp ? 'HttpApp, HttpComponent,' : 'App, Component,' %>
3
+ RunFunctionArgs,
4
+ RunFunctionReturnType,
5
+ } from "@keragon/connector-sdk";
6
+ <%- isHttp ? "import { AxiosRequestConfig } from 'axios';" : '' %>
7
+
8
+ export default class <%= className %> extends <%= isHttp ? 'HttpComponent' : 'Component' %><<%= isHttp ? 'HttpApp' : 'App' %>> {
9
+ <%_ if (isHttp) { _%>
10
+ override async onRequest({
11
+ requestConfig,
12
+ }: {
13
+ requestConfig: AxiosRequestConfig;
14
+ }): Promise<AxiosRequestConfig> {
15
+ const { method, url, headers, data: inputData } = await super.onRequest({ requestConfig });
16
+
17
+ throw new Error('Change default implementation of onRequest() method');
18
+
19
+ return {
20
+ method,
21
+ url,
22
+ headers,
23
+ data: {
24
+ ...inputData,
25
+ },
26
+ };
27
+ }
28
+ <%_ } else { _%>
29
+ override async run({ inputs }: RunFunctionArgs): Promise<RunFunctionReturnType> {
30
+ if (!inputs) throw new Error(`Component ${this.definition.id} run() received no inputs`);
31
+ throw new Error('Change default implementation of run() method');
32
+ }
33
+ <%_ } _%>
34
+ }
@@ -4,7 +4,7 @@
4
4
  "description": "<%= desc %>",
5
5
  "type": "trigger",
6
6
  "sdkVersion": "0.0.1"
7
- <% if (typeof alert !== 'undefined') { %>
7
+ <% if (alert) { %>
8
8
  ,"alerts": [{
9
9
  "type": "info",
10
10
  "content": "Due to vendor limitations you can have only one polling trigger"
@@ -24,7 +24,7 @@
24
24
  "processOutputs": "${ . | sort_by(.created_time) | reverse }"
25
25
  }
26
26
  }
27
- <% if (typeof inputs !== 'undefined') { %>
27
+ <% if (inputs) { %>
28
28
  ,"inputs": {
29
29
  "$schema": "https://json-schema.org/draft/2020-12/schema",
30
30
  "type": "object",
@@ -4,13 +4,13 @@
4
4
  "description": "<%= desc %>",
5
5
  "type": "trigger",
6
6
  "sdkVersion": "0.0.1"
7
- <% if (typeof alert !== 'undefined') { %>
7
+ <% if (alert) { %>
8
8
  ,"alerts": [{
9
9
  "type": "info",
10
10
  "content": "Please follow the [article](https://go.keragon.com/<%= componentName %>) to set up the trigger"
11
11
  }]
12
12
  <% } %>
13
- <% if (typeof http !== 'undefined') { %>
13
+ <% if (http) { %>
14
14
  ,"request": {
15
15
  "config": {
16
16
  "method": "get",
@@ -18,7 +18,7 @@
18
18
  }
19
19
  }
20
20
  <% } %>
21
- <% if (typeof inputs !== 'undefined') { %>
21
+ <% if (inputs) { %>
22
22
  ,"inputs": {
23
23
  "$schema": "https://json-schema.org/draft/2020-12/schema",
24
24
  "type": "object",