Skip to content

Commit

Permalink
feat(scenario): add Scenario piece with custom api call action
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamSelene committed Dec 3, 2024
1 parent 88508b5 commit 66876c8
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 1 deletion.
37 changes: 37 additions & 0 deletions packages/pieces/community/scenario/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"extends": [
"../../../../.eslintrc.json"
],
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts",
"*.tsx",
"*.js",
"*.jsx"
],
"rules": {},
"extends": [
"plugin:prettier/recommended"
],
"plugins": ["prettier"]
},
{
"files": [
"*.ts",
"*.tsx"
],
"rules": {}
},
{
"files": [
"*.js",
"*.jsx"
],
"rules": {}
}
]
}
7 changes: 7 additions & 0 deletions packages/pieces/community/scenario/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# pieces-scenario

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build pieces-scenario` to build the library.
4 changes: 4 additions & 0 deletions packages/pieces/community/scenario/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "@activepieces/piece-scenario",
"version": "0.0.1"
}
45 changes: 45 additions & 0 deletions packages/pieces/community/scenario/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "pieces-scenario",
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/pieces/community/scenario/src",
"projectType": "library",
"release": {
"version": {
"generatorOptions": {
"packageRoot": "dist/{projectRoot}",
"currentVersionResolver": "git-tag"
}
}
},
"tags": [],
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/packages/pieces/community/scenario",
"tsConfig": "packages/pieces/community/scenario/tsconfig.lib.json",
"packageJson": "packages/pieces/community/scenario/package.json",
"main": "packages/pieces/community/scenario/src/index.ts",
"assets": [
"packages/pieces/community/scenario/*.md"
],
"buildableProjectDepsInPackageJsonType": "dependencies",
"updateBuildableProjectDepsInPackageJson": true
}
},
"nx-release-publish": {
"options": {
"packageRoot": "dist/{projectRoot}"
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}"
]
}
}
}
45 changes: 45 additions & 0 deletions packages/pieces/community/scenario/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {
createPiece,
PieceAuth,
Property,
} from '@activepieces/pieces-framework';
import { createCustomApiCallAction } from '@activepieces/pieces-common';
import { BasicAuthConnectionValue } from '@activepieces/shared';

export const scenarioAuth = PieceAuth.BasicAuth({
description:
'Follow [these instructions](https://docs.scenario.com/docs/get-api-key) to get your API key',
required: true,
username: Property.ShortText({
displayName: 'API access key',
description: 'Starts with "api_"',
required: true,
}),
password: PieceAuth.SecretText({
displayName: 'API secret',
required: true,
}),
});

export const scenario = createPiece({
displayName: 'Scenario',
auth: scenarioAuth,
minimumSupportedRelease: '0.36.1',
logoUrl: 'https://cdn.activepieces.com/pieces/scenario.png',
authors: ['AdamSelene'],
actions: [
createCustomApiCallAction({
baseUrl: () => `https://api.cloud.scenario.com/v1/`,
auth: scenarioAuth,
authMapping: async (auth) => {
const { username, password } = auth as BasicAuthConnectionValue;
return {
Authorization: `Basic ${Buffer.from(
`${username}:${password}`
).toString('base64')}`,
};
},
}),
],
triggers: [],
});
19 changes: 19 additions & 0 deletions packages/pieces/community/scenario/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noPropertyAccessFromIndexSignature": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
]
}
11 changes: 11 additions & 0 deletions packages/pieces/community/scenario/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "../../../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}
5 changes: 4 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@
"@activepieces/piece-salesforce": [
"packages/pieces/community/salesforce/src/index.ts"
],
"@activepieces/piece-scenario": [
"packages/pieces/community/scenario/src/index.ts"
],
"@activepieces/piece-schedule": [
"packages/pieces/community/schedule/src/index.ts"
],
Expand Down Expand Up @@ -622,7 +625,7 @@
"@activepieces/piece-twilio": [
"packages/pieces/community/twilio/src/index.ts"
],
"@activepieces/piece-twin-labs":[
"@activepieces/piece-twin-labs": [
"packages/pieces/community/twin-labs/src/index.ts"
],
"@activepieces/piece-twitter": [
Expand Down

0 comments on commit 66876c8

Please sign in to comment.