-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - suitedash #14311
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
Merged
Merged
New Components - suitedash #14311
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
components/suitedash/actions/create-company/create-company.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import suitedash from "../../suitedash.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "suitedash-create-company", | ||
| name: "Create Company", | ||
| description: "Creates a new company in SuiteDash. [See the documentation](https://app.suitedash.com/secure-api/swagger)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| suitedash, | ||
| companyName: { | ||
| propDefinition: [ | ||
| suitedash, | ||
| "companyName", | ||
| ], | ||
| }, | ||
| companyRole: { | ||
| propDefinition: [ | ||
| suitedash, | ||
| "role", | ||
| ], | ||
| }, | ||
| firstName: { | ||
| type: "string", | ||
| label: "First Name", | ||
| description: "First name of the company's primary contact", | ||
| }, | ||
| lastName: { | ||
| type: "string", | ||
| label: "Last Name", | ||
| description: "Last name of the company's primary contact", | ||
| }, | ||
| email: { | ||
| type: "string", | ||
| label: "Email", | ||
| description: "Email address of the company's primary contact", | ||
| }, | ||
| sendWelcomeEmail: { | ||
| type: "boolean", | ||
| label: "Send Welcome Email", | ||
| description: "Send welcome email to the primary contact. Default: `false`", | ||
| optional: true, | ||
| default: false, | ||
| }, | ||
| createPrimaryContactIfNotExists: { | ||
| type: "boolean", | ||
| label: "Create Primary Contact If Not Exists", | ||
| description: "Create a Primary Contact with all provided data if the email does not exist. Default: `true`", | ||
| optional: true, | ||
| default: true, | ||
| }, | ||
| preventIndividualMode: { | ||
| type: "boolean", | ||
| label: "Prevent Individual Mode", | ||
| description: "Prevent this Primary Contact from switching into `Individual Mode`. Default: `false`", | ||
| optional: true, | ||
| default: false, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.suitedash.createCompany({ | ||
| $, | ||
| data: { | ||
| name: this.companyName, | ||
| role: this.companyRole, | ||
| primaryContact: { | ||
| first_name: this.firstName, | ||
| last_name: this.lastName, | ||
| email: this.email, | ||
| send_welcome_email: this.sendWelcomeEmail, | ||
| create_primary_contact_if_not_exists: this.createPrimaryContactIfNotExists, | ||
| prevent_individual_mode: this.preventIndividualMode, | ||
| }, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully created company ${this.companyName}`); | ||
| return response; | ||
| }, | ||
| }; |
55 changes: 55 additions & 0 deletions
55
components/suitedash/actions/create-contact/create-contact.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import suitedash from "../../suitedash.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "suitedash-create-contact", | ||
| name: "Create Contact", | ||
| description: "Creates a new contact in SuiteDash. [See the documentation](https://app.suitedash.com/secure-api/swagger)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| suitedash, | ||
| firstName: { | ||
| type: "string", | ||
| label: "Contact First Name", | ||
| description: "The first name of the new contact", | ||
| }, | ||
| lastName: { | ||
| type: "string", | ||
| label: "Contact Last Name", | ||
| description: "The last name of the new contact", | ||
| }, | ||
| email: { | ||
| type: "string", | ||
| label: "Contact Email", | ||
| description: "The email of the new contact", | ||
| }, | ||
| role: { | ||
| propDefinition: [ | ||
| suitedash, | ||
| "role", | ||
| ], | ||
| label: "Contact Role", | ||
| description: "The role of the new contact", | ||
| }, | ||
| sendWelcomeEmail: { | ||
| type: "boolean", | ||
| label: "Send Welcome Email", | ||
| description: "Whether to send a welcome email to the new contact", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.suitedash.createContact({ | ||
| $, | ||
| data: { | ||
| first_name: this.firstName, | ||
| last_name: this.lastName, | ||
| email: this.email, | ||
| role: this.role, | ||
| send_welcome_email: this.sendWelcomeEmail, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully created contact ${this.firstName} ${this.lastName}`); | ||
| return response; | ||
| }, | ||
| }; |
82 changes: 82 additions & 0 deletions
82
components/suitedash/actions/update-company/update-company.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import suitedash from "../../suitedash.app.mjs"; | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| key: "suitedash-update-company", | ||
| name: "Update Company", | ||
| description: "Updates an existing company's details in SuiteDash. [See the documentation](https://app.suitedash.com/secure-api/swagger)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| suitedash, | ||
| companyId: { | ||
| propDefinition: [ | ||
| suitedash, | ||
| "companyId", | ||
| ], | ||
| }, | ||
| companyName: { | ||
| propDefinition: [ | ||
| suitedash, | ||
| "companyName", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| website: { | ||
| type: "string", | ||
| label: "Website", | ||
| description: "The website of the company.", | ||
| optional: true, | ||
| }, | ||
| phone: { | ||
| type: "string", | ||
| label: "Phone", | ||
| description: "The phone number of the company", | ||
| optional: true, | ||
| }, | ||
| companyAddress: { | ||
| type: "string", | ||
| label: "Company Address", | ||
| description: "The full address of the company. Example: dba Staybridge Suites Mount Laurel 324 Church Road Mount Laurel, NJ 09478", | ||
| optional: true, | ||
| }, | ||
| tags: { | ||
| type: "string[]", | ||
| label: "Tags", | ||
| description: "An array of tags associated with the company", | ||
| optional: true, | ||
| }, | ||
| backgroundInfo: { | ||
| type: "string", | ||
| label: "Background Info", | ||
| description: "Background information about the company", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| if (!this.companyName | ||
| && !this.website | ||
| && !this.phone | ||
| && !this.companyAddress | ||
| && !this.tags | ||
| && !this.backgroundInfo | ||
| ) { | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| throw new ConfigurationError("Please enter at least one field to update"); | ||
| } | ||
|
|
||
| const response = await this.suitedash.updateCompany({ | ||
| $, | ||
| companyId: this.companyId, | ||
| data: { | ||
| name: this.companyName, | ||
| website: this.website, | ||
| phone: this.phone, | ||
| full_address: this.companyAddress, | ||
| tags: this.tags, | ||
| background_info: this.backgroundInfo, | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }); | ||
| $.export("$summary", `Successfully updated company ${this.companyId}`); | ||
| return response; | ||
| }, | ||
| }; | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,18 @@ | ||
| { | ||
| "name": "@pipedream/suitedash", | ||
| "version": "0.0.2", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream SuiteDash Components", | ||
| "main": "dist/app/suitedash.app.mjs", | ||
| "keywords": [ | ||
| "pipedream", | ||
| "suitedash" | ||
| ], | ||
| "files": ["dist"], | ||
| "homepage": "https://pipedream.com/apps/suitedash", | ||
| "author": "Pipedream <support@pipedream.com> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import suitedash from "../../suitedash.app.mjs"; | ||
| import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| props: { | ||
| suitedash, | ||
| db: "$.service.db", | ||
| timer: { | ||
| type: "$.interface.timer", | ||
| default: { | ||
| intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
| }, | ||
| }, | ||
| }, | ||
| hooks: { | ||
| async deploy() { | ||
| await this.processEvent(25); | ||
| }, | ||
| }, | ||
| methods: { | ||
| _getLastTs() { | ||
| return this.db.get("lastTs") || 0; | ||
| }, | ||
| _setLastTs(lastTs) { | ||
| this.db.set("lastTs", lastTs); | ||
| }, | ||
| getParams() { | ||
| return {}; | ||
| }, | ||
| getTsField() { | ||
| return "created"; | ||
| }, | ||
| generateMeta(item) { | ||
| return { | ||
| id: item.uid, | ||
| summary: this.getSummary(item), | ||
| ts: Date.parse(item[this.getTsField()]), | ||
| }; | ||
| }, | ||
| getFn() { | ||
| throw new Error("getFn is not implemented"); | ||
| }, | ||
| getSummary() { | ||
| throw new Error("getSummary is not implemented"); | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| async processEvent(max) { | ||
| const lastTs = this._getLastTs(); | ||
| let maxTs = lastTs; | ||
| let results = []; | ||
|
|
||
| const items = this.suitedash.paginate({ | ||
| fn: this.getFn(), | ||
| params: this.getParams(), | ||
| }); | ||
|
|
||
| for await (const item of items) { | ||
| const ts = Date.parse(item[this.getTsField()]); | ||
| if (ts >= lastTs) { | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| results.push(item); | ||
| maxTs = Math.max(ts, maxTs); | ||
| } | ||
| } | ||
|
|
||
| this._setLastTs(maxTs); | ||
|
|
||
| if (max) { | ||
| results = results.slice(-1 * max); | ||
| } | ||
|
|
||
| results.forEach((item) => { | ||
| const meta = this.generateMeta(item); | ||
| this.$emit(item, meta); | ||
| }); | ||
| }, | ||
| }, | ||
| async run() { | ||
| await this.processEvent(); | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import common from "../common/base.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "suitedash-new-company", | ||
| name: "New Company Created", | ||
| description: "Emit new event when a new company is created in SuiteDash", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getFn() { | ||
| return this.suitedash.listCompanies; | ||
| }, | ||
| getSummary(company) { | ||
| if (!company || typeof company !== "object") { | ||
| return "New Company: Unknown"; | ||
| } | ||
| const name = company.name || "Unnamed"; | ||
| return `New Company: ${name}`; | ||
| }, | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import common from "../common/base.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "suitedash-new-contact", | ||
| name: "New Contact Created", | ||
| description: "Emit new event when a new contact is created.", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getFn() { | ||
| return this.suitedash.listContacts; | ||
| }, | ||
| getSummary(contact) { | ||
| const firstName = contact.first_name || ""; | ||
| const lastName = contact.last_name || ""; | ||
| const fullName = [ | ||
| firstName, | ||
| lastName, | ||
| ].filter(Boolean).join(" ") || "Unknown"; | ||
| return `New Contact: ${fullName}`; | ||
| }, | ||
| }, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.