Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(flowlu): all actions related to task / opportunity / contact #3605

Merged
merged 11 commits into from
Jan 11, 2024
33 changes: 33 additions & 0 deletions packages/pieces/flowlu/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"extends": [
"../../../.eslintrc.json"
],
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts",
"*.tsx",
"*.js",
"*.jsx"
],
"rules": {}
},
{
"files": [
"*.ts",
"*.tsx"
],
"rules": {}
},
{
"files": [
"*.js",
"*.jsx"
],
"rules": {}
}
]
}
7 changes: 7 additions & 0 deletions packages/pieces/flowlu/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# pieces-flowlu

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

## Building

Run `nx build pieces-flowlu` to build the library.
4 changes: 4 additions & 0 deletions packages/pieces/flowlu/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "@activepieces/piece-flowlu",
"version": "0.0.1"
}
43 changes: 43 additions & 0 deletions packages/pieces/flowlu/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "pieces-flowlu",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/pieces/flowlu/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/packages/pieces/flowlu",
"tsConfig": "packages/pieces/flowlu/tsconfig.lib.json",
"packageJson": "packages/pieces/flowlu/package.json",
"main": "packages/pieces/flowlu/src/index.ts",
"assets": [
"packages/pieces/flowlu/*.md"
],
"buildableProjectDepsInPackageJsonType": "dependencies",
"updateBuildableProjectDepsInPackageJson": true
}
},
"publish": {
"command": "node tools/scripts/publish.mjs pieces-flowlu {args.ver} {args.tag}",
"dependsOn": [
"build"
]
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}"
],
"options": {
"lintFilePatterns": [
"packages/pieces/flowlu/**/*.ts"
]
}
}
},
"tags": []
}
59 changes: 59 additions & 0 deletions packages/pieces/flowlu/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import {
createPiece,
PieceAuth,
Property,
} from '@activepieces/pieces-framework';
import { createContactAction } from './lib/actions/accounts/create-contact';
import { createOrganizationAction } from './lib/actions/accounts/create-organization';
import { deleteContactAction } from './lib/actions/accounts/delete-contact';
import { updateContactAction } from './lib/actions/accounts/update-contact';
import { createOpportunityAction } from './lib/actions/opportunities/create-opportunity';
import { deleteOpportunityAction } from './lib/actions/opportunities/delete-opportunity';
import { updateOpportunityAction } from './lib/actions/opportunities/update-opportunity';
import { createTaskAction } from './lib/actions/tasks/create-task';
import { deleteTaskAction } from './lib/actions/tasks/delete-task';
import { getTaskAction } from './lib/actions/tasks/get-task';
import { updateTaskAction } from './lib/actions/tasks/update-task';

export const flowluAuth = PieceAuth.CustomAuth({
required: true,
description: `
1. Log in to your flowlu account.
2. Click on your profile-pic(top-right) and navigate to **Portal Settings->API Settings**.
3. Create new API key with any name and appropriate scope.
4. Copy API Key to your clipboard and paste it in **API Key** field
5. In the Domain field, enter your company from your account URL address. For example, if your account URL address is https://example.flowlu.com, then your domain is **example**.
`,
props: {
domain: Property.ShortText({
displayName: 'Domain',
required: true,
}),
apiKey: PieceAuth.SecretText({
displayName: 'API Key',
required: true,
}),
},
});

export const flowlu = createPiece({
displayName: 'Flowlu',
auth: flowluAuth,
minimumSupportedRelease: '0.9.0',
logoUrl: 'https://cdn.activepieces.com/pieces/flowlu.png',
authors: ['kishanprmr'],
actions: [
createContactAction,
updateContactAction,
deleteContactAction,
createOrganizationAction,
createOpportunityAction,
updateOpportunityAction,
deleteOpportunityAction,
createTaskAction,
updateTaskAction,
getTaskAction,
deleteTaskAction,
],
triggers: [],
});
37 changes: 37 additions & 0 deletions packages/pieces/flowlu/src/lib/actions/accounts/create-contact.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
PiecePropValueSchema,
Property,
createAction,
} from '@activepieces/pieces-framework';
import { flowluAuth } from '../../..';
import { flowluCommon, makeClient } from '../../common';
import { flowluProps } from '../../common/props';

export const createContactAction = createAction({
auth: flowluAuth,
name: 'flowlu_create_contact',
displayName: 'Create CRM Account(Contact)',
description: 'Creates a new contact in CRM.',
props: {
honorific_title_id: flowluCommon.honorific_title_id(false),
first_name: Property.ShortText({
displayName: 'First Name',
required: true,
}),
middle_name: Property.ShortText({
displayName: 'Middle Name',
required: false,
}),
last_name: Property.ShortText({
displayName: 'Last Name',
required: false,
}),
...flowluProps.account,
},
async run(context) {
const client = makeClient(
context.auth as PiecePropValueSchema<typeof flowluAuth>
);
return await client.createAccount({ type: 2, ...context.propsValue });
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
PiecePropValueSchema,
Property,
createAction,
} from '@activepieces/pieces-framework';
import { flowluAuth } from '../../..';
import { makeClient } from '../../common';
import { flowluProps } from '../../common/props';

export const createOrganizationAction = createAction({
auth: flowluAuth,
name: 'flowlu_create_organization',
displayName: 'Create CRM Account(Organization)',
description: 'Creates a new organization in CRM.',
props: {
name: Property.ShortText({
displayName: 'Organization Name',
required: true,
}),
name_legal_full: Property.ShortText({
displayName: 'Full legal name for Organization',
required: false,
}),
...flowluProps.account,
},
async run(context) {
const client = makeClient(
context.auth as PiecePropValueSchema<typeof flowluAuth>
);
return await client.createAccount({ type: 1, ...context.propsValue });
},
});
28 changes: 28 additions & 0 deletions packages/pieces/flowlu/src/lib/actions/accounts/delete-contact.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {
createAction,
PiecePropValueSchema,
} from '@activepieces/pieces-framework';
import { flowluAuth } from '../../..';
import { flowluCommon, makeClient } from '../../common';
import { FlowluEntity, FlowluModule } from '../../common/constants';

export const deleteContactAction = createAction({
auth: flowluAuth,
name: 'flowlu_delete_contact',
displayName: 'Delete CRM Account(Contact)',
description: 'Deletes an existing contact in CRM.',
props: {
id: flowluCommon.contact_id(true),
},
async run(context) {
const id = context.propsValue.id!;
const client = makeClient(
context.auth as PiecePropValueSchema<typeof flowluAuth>
);
return await client.deleteAction(
FlowluModule.CRM,
FlowluEntity.ACCOUNT,
id
);
},
});
39 changes: 39 additions & 0 deletions packages/pieces/flowlu/src/lib/actions/accounts/update-contact.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {
PiecePropValueSchema,
Property,
createAction,
} from '@activepieces/pieces-framework';
import { flowluAuth } from '../../..';
import { flowluCommon, makeClient } from '../../common';
import { flowluProps } from '../../common/props';

export const updateContactAction = createAction({
auth: flowluAuth,
name: 'flowlu_update_contact',
displayName: 'Update CRM Account(Contact)',
description: 'Updates an existing contact in CRM.',
props: {
id: flowluCommon.contact_id(true),
honorific_title_id: flowluCommon.honorific_title_id(false),
first_name: Property.ShortText({
displayName: 'First Name',
required: true,
}),
middle_name: Property.ShortText({
displayName: 'Middle Name',
required: false,
}),
last_name: Property.ShortText({
displayName: 'Last Name',
required: false,
}),
...flowluProps.account,
},
async run(context) {
const id = context.propsValue.id!;
const client = makeClient(
context.auth as PiecePropValueSchema<typeof flowluAuth>
);
return await client.updateContact(id, { type: 2, ...context.propsValue });
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {
createAction,
PiecePropValueSchema,
} from '@activepieces/pieces-framework';
import { flowluAuth } from '../../../';
import { makeClient } from '../../common';
import { flowluProps } from '../../common/props';

export const createOpportunityAction = createAction({
auth: flowluAuth,
name: 'flowlu_create_opportunity',
displayName: 'Create Opportunity',
description: 'Creates a new opportunity.',
props: {
...flowluProps.opportunity,
},
async run(context) {
const client = makeClient(
context.auth as PiecePropValueSchema<typeof flowluAuth>
);
return await client.createOpportunity(context.propsValue);
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {
createAction,
PiecePropValueSchema,
} from '@activepieces/pieces-framework';
import { flowluAuth } from '../../../';
import { flowluCommon, makeClient } from '../../common';
import { FlowluEntity, FlowluModule } from '../../common/constants';

export const deleteOpportunityAction = createAction({
auth: flowluAuth,
name: 'flowlu_delete_opportunity',
displayName: 'Delete Opportunity',
description: 'Deletes an existing opportunity.',
props: {
id: flowluCommon.opportunity_id(true),
},
async run(context) {
const id = context.propsValue.id!;
const client = makeClient(
context.auth as PiecePropValueSchema<typeof flowluAuth>
);
return await client.deleteAction(
FlowluModule.CRM,
FlowluEntity.OPPORTUNITY,
id
);
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
createAction,
PiecePropValueSchema,
} from '@activepieces/pieces-framework';
import { flowluAuth } from '../../../';
import { flowluCommon, makeClient } from '../../common';
import { flowluProps } from '../../common/props';

export const updateOpportunityAction = createAction({
auth: flowluAuth,
name: 'flowlu_update_opportunity',
displayName: 'Update Opportunity',
description: 'Updates an existing opportunity.',
props: {
id: flowluCommon.opportunity_id(true),
...flowluProps.opportunity,
},
async run(context) {
const id = context.propsValue.id!;
const client = makeClient(
context.auth as PiecePropValueSchema<typeof flowluAuth>
);
return await client.updateOpportunity(id, context.propsValue);
},
});