-
Notifications
You must be signed in to change notification settings - Fork 5.6k
TheMagicDrip new components #14265
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
TheMagicDrip new components #14265
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d704991
Initial AI-generated code (w/ eslint fixes)
GTFalcao 8ff38e2
Package/app adjustments
GTFalcao 338ca03
pnpm
GTFalcao b6e8582
Adjustments
GTFalcao e680eef
Adjustments
GTFalcao 1725dec
Adjustments
GTFalcao 459134e
Adjustments
GTFalcao 7e28250
Renaming sources
GTFalcao e0db198
Adjusting Sources
GTFalcao 04ea7c7
Merge branch 'master' into issue-14196
GTFalcao 149a733
Package version bump
GTFalcao 3f27778
Merge branch 'issue-14196' of https://github.com/PipedreamHQ/pipedrea…
GTFalcao 0e71af9
Adjusting filenames and versions
GTFalcao 013fb3a
Removing console log
GTFalcao a712830
component key adjustmnet
GTFalcao 911930b
Merge branch 'master' into issue-14196
GTFalcao d708fbb
Merge branch 'master' into issue-14196
GTFalcao 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
72 changes: 72 additions & 0 deletions
72
components/the_magic_drip/actions/add-lead-to-campaign/add-lead-to-campaign.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,72 @@ | ||
| import app from "../../the_magic_drip.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "the_magic_drip-add-lead-to-campaign", | ||
| name: "Add Lead to Campaign", | ||
| description: "Add a lead to a campaign. [See the documentation](https://docs.themagicdrip.com/api-reference/endpoint/post-v1campaignleads)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| campaignId: { | ||
| propDefinition: [ | ||
| app, | ||
| "campaignId", | ||
| ], | ||
| }, | ||
| firstName: { | ||
| type: "string", | ||
| label: "First Name", | ||
| description: "First name of the lead", | ||
| optional: true, | ||
| }, | ||
| lastName: { | ||
| type: "string", | ||
| label: "Last Name", | ||
| description: "Last name of the lead", | ||
| }, | ||
| linkedInPublicUrl: { | ||
| type: "string", | ||
| label: "LinkedIn Public URL", | ||
| description: "LinkedIn public URL of the lead", | ||
| optional: true, | ||
| }, | ||
| company: { | ||
| type: "string", | ||
| label: "Company", | ||
| description: "Company of the lead", | ||
| optional: true, | ||
| }, | ||
| companyLinkedInUrl: { | ||
| type: "string", | ||
| label: "Company LinkedIn URL", | ||
| description: "LinkedIn URL of the company", | ||
| optional: true, | ||
| }, | ||
| customVariables: { | ||
| type: "object", | ||
| label: "Custom Variables", | ||
| description: "More information about the lead", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| app, campaignId, ...lead | ||
| } = this; | ||
| const response = await app.addLeadToCampaign({ | ||
| $, | ||
| campaignId, | ||
| data: { | ||
| leadsWithCustomVariables: [ | ||
| lead, | ||
| ], | ||
| }, | ||
| }); | ||
| $.export( | ||
| "$summary", | ||
| `Successfully added lead "${lead.lastName}" to campaign`, | ||
| ); | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return response; | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
19 changes: 19 additions & 0 deletions
19
components/the_magic_drip/actions/list-campaigns/list-campaigns.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,19 @@ | ||
| import app from "../../the_magic_drip.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "the_magic_drip-list-campaigns", | ||
| name: "List Campaigns", | ||
| description: "Retrieve all available campaigns. [See the documentation](https://docs.themagicdrip.com/api-reference/endpoint/get-v1campaign)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| }, | ||
| async run({ $ }) { | ||
| const { campaigns } = await this.app.listCampaigns({ | ||
| $, | ||
| }); | ||
| $.export("$summary", `Sucessfully retrieved ${campaigns?.length ?? 0} campaigns`); | ||
| return campaigns; | ||
| }, | ||
| }; |
19 changes: 19 additions & 0 deletions
19
components/the_magic_drip/actions/list-templates/list-templates.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,19 @@ | ||
| import app from "../../the_magic_drip.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "the_magic_drip-list-templates", | ||
| name: "List Templates", | ||
| description: "Retrieve all available templates. [See the documentation](https://docs.themagicdrip.com/api-reference/endpoint/get-v1templates)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| }, | ||
| async run({ $ }) { | ||
| const { templates } = await this.app.listTemplates({ | ||
| $, | ||
| }); | ||
| $.export("$summary", `Sucessfully retrieved ${templates?.length ?? 0} templates`); | ||
| return templates; | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
39 changes: 39 additions & 0 deletions
39
..._magic_drip/actions/mark-campaign-active-or-inactive/mark-campaign-active-or-inactive.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,39 @@ | ||
| import app from "../../the_magic_drip.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "the_magic_drip-mark-campaign-active-inactive", | ||
| name: "Mark Campaign Active or Inactive", | ||
| description: "Marks a campaign as active or inactive. [See the documentation](https://docs.themagicdrip.com/api-reference/endpoint/post-v1campaign-active)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| campaignId: { | ||
| propDefinition: [ | ||
| app, | ||
| "campaignId", | ||
| ], | ||
| }, | ||
| activate: { | ||
| type: "boolean", | ||
| label: "Activate", | ||
| description: "Set to `true` to activate, or `false` to deactivate the campaign", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| campaignId, activate, | ||
| } = this; | ||
| const response = await this.app.markCampaignActiveInactive({ | ||
| $, | ||
| campaignId, | ||
| activate, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully ${activate | ||
| ? "" | ||
| : "de"}activated campaign`); | ||
|
|
||
| return response; | ||
| }, | ||
| }; |
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
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,56 @@ | ||
| import app from "../the_magic_drip.app.mjs"; | ||
| import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| props: { | ||
| app, | ||
| timer: { | ||
| type: "$.interface.timer", | ||
| default: { | ||
| intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
| }, | ||
| }, | ||
| db: "$.service.db", | ||
| }, | ||
| methods: { | ||
| _getSavedIds() { | ||
| return this.db.get("savedIds") || []; | ||
| }, | ||
| _setSavedIds(value) { | ||
| this.db.set("savedIds", value); | ||
| }, | ||
| getItemId(item) { | ||
| return item.id; | ||
| }, | ||
| getItemMetadata() { | ||
| return { | ||
| summary: "New event", | ||
| ts: Date.now(), | ||
| }; | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| async getAndProcessData(maxEmits = 0) { | ||
| const savedIds = this._getSavedIds(); | ||
| const items = await this.getItems(); | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| items?.filter?.((item) => !savedIds.includes(this.getItemId(item))).forEach((item, index) => { | ||
| if ((!maxEmits) || (index < maxEmits)) { | ||
| this.$emit(item, { | ||
| id: this.getItemId(item), | ||
| ...this.getItemMetadata(item), | ||
| }); | ||
| } | ||
| savedIds.push(this.getItemId(item)); | ||
| }); | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| this._setSavedIds(savedIds); | ||
| }, | ||
| }, | ||
| hooks: { | ||
| async deploy() { | ||
| await this.getAndProcessData(5); | ||
| }, | ||
| }, | ||
| async run() { | ||
| await this.getAndProcessData(); | ||
| }, | ||
| }; | ||
27 changes: 27 additions & 0 deletions
27
components/the_magic_drip/sources/new-campaign-created/new-campaign-created.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,27 @@ | ||
| import common from "../common.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "the_magic_drip-new-campaign-created", | ||
| name: "New Campaign Created", | ||
| description: "Emit new event when a campaign is created. [See the documentation](https://docs.themagicdrip.com/api-reference/endpoint/get-v1campaign)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| async getItems() { | ||
| const { campaigns } = await this.app.listCampaigns(); | ||
| return campaigns; | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| getItemId(item) { | ||
| return item.workflowId; | ||
| }, | ||
| getItemMetadata(item) { | ||
| return { | ||
| summary: `New Campaign: ${item.name}`, | ||
| ts: item.createdAt, | ||
| }; | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }; | ||
27 changes: 27 additions & 0 deletions
27
components/the_magic_drip/sources/new-template-created/new-template-created.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,27 @@ | ||
| import common from "../common.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "the_magic_drip-new-template-created", | ||
| name: "New Template Created", | ||
| description: "Emit new event when a template is created. [See the documentation](https://docs.themagicdrip.com/api-reference/endpoint/get-v1templates)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| async getItems() { | ||
| const { templates } = await this.app.listTemplates(); | ||
| return templates; | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| getItemId(item) { | ||
| return item.templateId; | ||
| }, | ||
| getItemMetadata(item) { | ||
| return { | ||
| summary: `New Template: ${item.name}`, | ||
| ts: item.createdAt, | ||
| }; | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }; | ||
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,11 +1,80 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "the_magic_drip", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| campaignId: { | ||
| type: "string", | ||
| label: "Campaign ID", | ||
| description: "Select a campaign", | ||
| async options() { | ||
| const { campaigns } = await this.listCampaigns(); | ||
| return campaigns?.map((campaign) => ({ | ||
| label: campaign.name, | ||
| value: campaign.workflowId, | ||
| })); | ||
| }, | ||
| }, | ||
| linkedinUrl: { | ||
| type: "string", | ||
| label: "LinkedIn URL", | ||
| description: "The LinkedIn URL of the lead", | ||
| optional: true, | ||
| }, | ||
| desiredState: { | ||
| type: "boolean", | ||
| label: "Desired State", | ||
| description: "Set to true to activate, false to deactivate the campaign", | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://api.themagicdrip.com/v1"; | ||
| }, | ||
| async _makeRequest({ | ||
| $, path, headers, ...otherOpts | ||
| } = {}) { | ||
| return axios($, { | ||
| ...otherOpts, | ||
| url: this._baseUrl() + path, | ||
| headers: { | ||
| ...headers, | ||
| "x-api-key": this.$auth.api_key, | ||
| }, | ||
| }); | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| async listCampaigns(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/campaign", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| async addLeadToCampaign({ | ||
| campaignId, ...opts | ||
| }) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: `/campaign/leads/${campaignId}`, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| async markCampaignActiveInactive({ | ||
| campaignId, activate, ...opts | ||
| }) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: `/campaign/${campaignId}/${activate | ||
| ? "active" | ||
| : "inactive"}`, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| async listTemplates(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/templates", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.