@coasy/piece-coasy 0.0.1
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/.eslintrc.json +33 -0
- package/README.md +7 -0
- package/package.json +4 -0
- package/project.json +38 -0
- package/src/coasyClient.ts +37 -0
- package/src/index.ts +34 -0
- package/src/lib/actions/createFunnelParticipant.ts +50 -0
- package/tsconfig.json +19 -0
- package/tsconfig.lib.json +11 -0
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": [
|
|
3
|
+
"../../../../.eslintrc.base.json"
|
|
4
|
+
],
|
|
5
|
+
"ignorePatterns": [
|
|
6
|
+
"!**/*"
|
|
7
|
+
],
|
|
8
|
+
"overrides": [
|
|
9
|
+
{
|
|
10
|
+
"files": [
|
|
11
|
+
"*.ts",
|
|
12
|
+
"*.tsx",
|
|
13
|
+
"*.js",
|
|
14
|
+
"*.jsx"
|
|
15
|
+
],
|
|
16
|
+
"rules": {}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"files": [
|
|
20
|
+
"*.ts",
|
|
21
|
+
"*.tsx"
|
|
22
|
+
],
|
|
23
|
+
"rules": {}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"files": [
|
|
27
|
+
"*.js",
|
|
28
|
+
"*.jsx"
|
|
29
|
+
],
|
|
30
|
+
"rules": {}
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
package/README.md
ADDED
package/package.json
ADDED
package/project.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pieces-coasy",
|
|
3
|
+
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "packages/pieces/community/coasy/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"targets": {
|
|
7
|
+
"build": {
|
|
8
|
+
"executor": "@nx/js:tsc",
|
|
9
|
+
"outputs": [
|
|
10
|
+
"{options.outputPath}"
|
|
11
|
+
],
|
|
12
|
+
"options": {
|
|
13
|
+
"outputPath": "dist/packages/pieces/community/coasy",
|
|
14
|
+
"tsConfig": "packages/pieces/community/coasy/tsconfig.lib.json",
|
|
15
|
+
"packageJson": "packages/pieces/community/coasy/package.json",
|
|
16
|
+
"main": "packages/pieces/community/coasy/src/index.ts",
|
|
17
|
+
"assets": [
|
|
18
|
+
"packages/pieces/community/coasy/*.md"
|
|
19
|
+
],
|
|
20
|
+
"buildableProjectDepsInPackageJsonType": "dependencies",
|
|
21
|
+
"updateBuildableProjectDepsInPackageJson": true
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"publish": {
|
|
25
|
+
"command": "node tools/scripts/publish.mjs pieces-coasy {args.ver} {args.tag}",
|
|
26
|
+
"dependsOn": [
|
|
27
|
+
"build"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"lint": {
|
|
31
|
+
"executor": "@nx/eslint:lint",
|
|
32
|
+
"outputs": [
|
|
33
|
+
"{options.outputFile}"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"tags": []
|
|
38
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AuthenticationType, httpClient, HttpMethod, HttpRequest } from '@activepieces/pieces-common';
|
|
2
|
+
|
|
3
|
+
export class CoasyClient {
|
|
4
|
+
private baseUrl: string;
|
|
5
|
+
private apiKey: string;
|
|
6
|
+
|
|
7
|
+
constructor(baseUrl: string, apiKey: string) {
|
|
8
|
+
this.baseUrl = baseUrl;
|
|
9
|
+
this.apiKey = apiKey;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
async action(actionName: string, request: any) {
|
|
14
|
+
return this.request(`/apps/actions/${actionName}`, request);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async request(path: string, requestBody: any) {
|
|
18
|
+
const request: HttpRequest<string> = {
|
|
19
|
+
method: HttpMethod.POST,
|
|
20
|
+
url: `${this.baseUrl}${path}`,
|
|
21
|
+
body: JSON.stringify(requestBody),
|
|
22
|
+
authentication: {
|
|
23
|
+
type: AuthenticationType.BEARER_TOKEN,
|
|
24
|
+
token: this.apiKey
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const response = await httpClient.sendRequest(request);
|
|
29
|
+
|
|
30
|
+
if (response.status !== 200) {
|
|
31
|
+
throw new Error(`Failed to communicate with Mailjet`);
|
|
32
|
+
} else {
|
|
33
|
+
return response.body;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createPiece, PieceAuth, Property } from '@activepieces/pieces-framework';
|
|
2
|
+
import { createFunnelParticipant } from './lib/actions/createFunnelParticipant';
|
|
3
|
+
|
|
4
|
+
export const coasyAuth = PieceAuth.CustomAuth({
|
|
5
|
+
required: true,
|
|
6
|
+
description: 'Enter coasy authentication details',
|
|
7
|
+
props: {
|
|
8
|
+
baseUrl: Property.ShortText({
|
|
9
|
+
displayName: 'Base URL',
|
|
10
|
+
description: 'Enter the base URL',
|
|
11
|
+
required: true,
|
|
12
|
+
}),
|
|
13
|
+
apiKey: PieceAuth.SecretText({
|
|
14
|
+
displayName: 'API Key',
|
|
15
|
+
description: 'Enter the api key',
|
|
16
|
+
required: true
|
|
17
|
+
})
|
|
18
|
+
},
|
|
19
|
+
validate: async ({ auth }) => {
|
|
20
|
+
return { valid: true };
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
export const coasy = createPiece({
|
|
26
|
+
displayName: 'Coasy',
|
|
27
|
+
auth: coasyAuth,
|
|
28
|
+
description: 'Communicate with Coasy',
|
|
29
|
+
minimumSupportedRelease: '0.20.0',
|
|
30
|
+
logoUrl: 'https://console.achtsamkeitsakademie.de/favicon/apple-icon.png',
|
|
31
|
+
authors: ["christian-schab"],
|
|
32
|
+
actions: [createFunnelParticipant],
|
|
33
|
+
triggers: []
|
|
34
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createAction, Property } from '@activepieces/pieces-framework';
|
|
2
|
+
import { coasyAuth } from '../../index';
|
|
3
|
+
import { CoasyClient } from '../../coasyClient';
|
|
4
|
+
|
|
5
|
+
export const createFunnelParticipant = createAction({
|
|
6
|
+
auth: coasyAuth,
|
|
7
|
+
name: 'createFunnelParticipant',
|
|
8
|
+
displayName: 'Create Funnel Participant',
|
|
9
|
+
description: 'Create a new funnel participant',
|
|
10
|
+
props: {
|
|
11
|
+
funnelId: Property.ShortText({
|
|
12
|
+
displayName: 'Funnel ID',
|
|
13
|
+
description: 'ID of funnel',
|
|
14
|
+
required: true
|
|
15
|
+
}),
|
|
16
|
+
firstName: Property.ShortText({
|
|
17
|
+
displayName: 'First name',
|
|
18
|
+
description: 'first name of participant',
|
|
19
|
+
required: true
|
|
20
|
+
}),
|
|
21
|
+
lastName: Property.ShortText({
|
|
22
|
+
displayName: 'Last name',
|
|
23
|
+
description: 'last name of participant',
|
|
24
|
+
required: false
|
|
25
|
+
}),
|
|
26
|
+
email: Property.ShortText({
|
|
27
|
+
displayName: 'Email',
|
|
28
|
+
description: 'email address of partipant',
|
|
29
|
+
required: true
|
|
30
|
+
})
|
|
31
|
+
},
|
|
32
|
+
async run(configValue) {
|
|
33
|
+
console.log(`Run createFunnelParticipant`);
|
|
34
|
+
|
|
35
|
+
const { propsValue, auth } = configValue;
|
|
36
|
+
console.log(`Loaded PropsValue and Auth`);
|
|
37
|
+
|
|
38
|
+
const client = new CoasyClient(auth.baseUrl, auth.apiKey);
|
|
39
|
+
console.log(`Built client`);
|
|
40
|
+
|
|
41
|
+
const request = {
|
|
42
|
+
email: propsValue.email,
|
|
43
|
+
firstName: propsValue.firstName,
|
|
44
|
+
funnelId: propsValue.funnelId
|
|
45
|
+
};
|
|
46
|
+
console.log(`Built request`, request);
|
|
47
|
+
|
|
48
|
+
return client.action('createFunnelParticipant', request);
|
|
49
|
+
}
|
|
50
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"forceConsistentCasingInFileNames": true,
|
|
6
|
+
"strict": true,
|
|
7
|
+
"noImplicitOverride": true,
|
|
8
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
9
|
+
"noImplicitReturns": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true
|
|
11
|
+
},
|
|
12
|
+
"files": [],
|
|
13
|
+
"include": [],
|
|
14
|
+
"references": [
|
|
15
|
+
{
|
|
16
|
+
"path": "./tsconfig.lib.json"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"outDir": "../../../../dist/out-tsc",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"types": ["node"]
|
|
8
|
+
},
|
|
9
|
+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
|
|
10
|
+
"include": ["src/**/*.ts"]
|
|
11
|
+
}
|