From d704991d4b8463d9cec6a6460e86720780f0d962 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 8 Oct 2024 00:58:25 -0300 Subject: [PATCH 01/13] Initial AI-generated code (w/ eslint fixes) --- .../add_lead_to_campaign.mjs | 44 +++++++ .../actions/list_campaigns/list_campaigns.mjs | 17 +++ .../actions/list_templates/list_templates.mjs | 17 +++ .../mark_campaign_active_or_inactive.mjs | 35 ++++++ components/the_magic_drip/package.json | 2 +- .../new_campaign_created.mjs | 79 ++++++++++++ .../new_template_created.mjs | 79 ++++++++++++ .../the_magic_drip/the_magic_drip.app.mjs | 112 +++++++++++++++++- 8 files changed, 381 insertions(+), 4 deletions(-) create mode 100644 components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs create mode 100644 components/the_magic_drip/actions/list_campaigns/list_campaigns.mjs create mode 100644 components/the_magic_drip/actions/list_templates/list_templates.mjs create mode 100644 components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs create mode 100644 components/the_magic_drip/sources/new campaign created/new_campaign_created.mjs create mode 100644 components/the_magic_drip/sources/new template created/new_template_created.mjs diff --git a/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs b/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs new file mode 100644 index 0000000000000..9f7f454d8177a --- /dev/null +++ b/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs @@ -0,0 +1,44 @@ +import the_magic_drip from "../../the_magic_drip.app.mjs"; + +export default { + key: "the_magic_drip-add-lead-to-campaign", + name: "Add Lead to Campaign", + description: "Adds a single lead to a campaign. [See the documentation]()", + version: "0.0.{{ts}}", + type: "action", + props: { + the_magic_drip, + campaignId: { + propDefinition: [ + the_magic_drip, + "campaignId", + ], + }, + company: { + propDefinition: [ + the_magic_drip, + "company", + ], + optional: true, + }, + linkedinUrl: { + propDefinition: [ + the_magic_drip, + "linkedinUrl", + ], + optional: true, + }, + }, + async run({ $ }) { + const response = await this.the_magic_drip.addLeadToCampaign({ + campaignId: this.campaignId, + company: this.company, + linkedinUrl: this.linkedinUrl, + }); + $.export( + "$summary", + `Added ${response.totalLeadsAddedToWorkflow} lead(s) to campaign ${this.campaignId}`, + ); + return response; + }, +}; diff --git a/components/the_magic_drip/actions/list_campaigns/list_campaigns.mjs b/components/the_magic_drip/actions/list_campaigns/list_campaigns.mjs new file mode 100644 index 0000000000000..aff7f6d447a65 --- /dev/null +++ b/components/the_magic_drip/actions/list_campaigns/list_campaigns.mjs @@ -0,0 +1,17 @@ +import the_magic_drip from "../../the_magic_drip.app.mjs"; + +export default { + key: "the_magic_drip-list-campaigns", + name: "List Campaigns", + description: "Lists all available campaigns. [See the documentation](https://docs.themagicdrip.com/api-reference/introduction)", + version: "0.0.{{ts}}", + type: "action", + props: { + the_magic_drip, + }, + async run({ $ }) { + const response = await this.the_magic_drip.listCampaigns(); + $.export("$summary", `Listed ${response.campaigns.length} campaigns`); + return response.campaigns; + }, +}; diff --git a/components/the_magic_drip/actions/list_templates/list_templates.mjs b/components/the_magic_drip/actions/list_templates/list_templates.mjs new file mode 100644 index 0000000000000..fba6bc4c06549 --- /dev/null +++ b/components/the_magic_drip/actions/list_templates/list_templates.mjs @@ -0,0 +1,17 @@ +import the_magic_drip from "../../the_magic_drip.app.mjs"; + +export default { + key: "the_magic_drip-list-templates", + name: "List Templates", + description: "Lists all available templates. [See the documentation]()", + version: "0.0.{{ts}}", + type: "action", + props: { + the_magic_drip, + }, + async run({ $ }) { + const templates = await this.the_magic_drip.listTemplates(); + $.export("$summary", `Listed ${templates.templates.length} templates`); + return templates; + }, +}; diff --git a/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs b/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs new file mode 100644 index 0000000000000..8eaae18d9c1c7 --- /dev/null +++ b/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs @@ -0,0 +1,35 @@ +import the_magic_drip from "../../the_magic_drip.app.mjs"; + +export default { + key: "the_magic_drip-mark-campaign-active-inactive", + name: "Mark Campaign Active/Inactive", + description: "Marks a campaign as active or inactive. [See the documentation]()", + version: "0.0.{{ts}}", + type: "action", + props: { + the_magic_drip, + campaignId: { + propDefinition: [ + the_magic_drip, + "campaignId", + ], + }, + desiredState: { + type: "boolean", + label: "Desired State", + description: "Set to true to activate, false to deactivate the campaign", + }, + }, + async run({ $ }) { + const response = await this.the_magic_drip.markCampaignActiveInactive({ + campaignId: this.campaignId, + desiredState: this.desiredState, + }); + + $.export("$summary", `Marked campaign ${this.campaignId} as ${this.desiredState + ? "active" + : "inactive"}.`); + + return response; + }, +}; diff --git a/components/the_magic_drip/package.json b/components/the_magic_drip/package.json index fe5597612c26b..8103b21a6a897 100644 --- a/components/the_magic_drip/package.json +++ b/components/the_magic_drip/package.json @@ -12,4 +12,4 @@ "publishConfig": { "access": "public" } -} \ No newline at end of file +} diff --git a/components/the_magic_drip/sources/new campaign created/new_campaign_created.mjs b/components/the_magic_drip/sources/new campaign created/new_campaign_created.mjs new file mode 100644 index 0000000000000..d83e6ec820a6e --- /dev/null +++ b/components/the_magic_drip/sources/new campaign created/new_campaign_created.mjs @@ -0,0 +1,79 @@ +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; +import the_magic_drip from "../../the_magic_drip.app.mjs"; + +export default { + key: "the_magic_drip-new-campaign-created", + name: "New Campaign Created", + description: "Emit new event when a campaign is created. [See the documentation]()", + version: "0.0.{{ts}}", + type: "source", + dedupe: "unique", + props: { + the_magic_drip, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + }, + hooks: { + async deploy() { + const lastRunAt = new Date(0).toISOString(); + const newCampaigns = await this.the_magic_drip.pollNewCampaigns(lastRunAt); + const sortedCampaigns = newCampaigns.sort( + (a, b) => new Date(b.createdAt) - new Date(a.createdAt), + ).slice(0, 50); + + for (const campaign of sortedCampaigns) { + this.$emit( + campaign, + { + id: campaign.id || campaign.createdAt, + summary: `New Campaign: ${campaign.name}`, + ts: Date.parse(campaign.createdAt), + }, + ); + } + + const latestCreatedAt = sortedCampaigns.length + ? sortedCampaigns[0].createdAt + : lastRunAt; + await this.db.set("lastRunAt", latestCreatedAt); + }, + async activate() { + // No action needed on activate for polling source + }, + async deactivate() { + // No action needed on deactivate for polling source + }, + }, + async run() { + const lastRunAt = (await this.db.get("lastRunAt")) || new Date(0).toISOString(); + const newCampaigns = await this.the_magic_drip.pollNewCampaigns(lastRunAt); + const sortedCampaigns = newCampaigns.sort( + (a, b) => new Date(b.createdAt) - new Date(a.createdAt), + ); + + for (const campaign of sortedCampaigns) { + this.$emit( + campaign, + { + id: campaign.id || campaign.createdAt, + summary: `New Campaign: ${campaign.name}`, + ts: Date.parse(campaign.createdAt), + }, + ); + } + + if (newCampaigns.length) { + const latestCreatedAt = newCampaigns.reduce((latest, campaign) => { + return new Date(campaign.createdAt) > new Date(latest) + ? campaign.createdAt + : latest; + }, lastRunAt); + await this.db.set("lastRunAt", latestCreatedAt); + } + }, +}; diff --git a/components/the_magic_drip/sources/new template created/new_template_created.mjs b/components/the_magic_drip/sources/new template created/new_template_created.mjs new file mode 100644 index 0000000000000..faa340f8addf5 --- /dev/null +++ b/components/the_magic_drip/sources/new template created/new_template_created.mjs @@ -0,0 +1,79 @@ +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; +import the_magic_drip from "../../the_magic_drip.app.mjs"; + +export default { + key: "the_magic_drip-new-template-created", + name: "New Template Created", + description: "Emits a new event when a template is created. [See the documentation]()", + version: "0.0.{{ts}}", + type: "source", + dedupe: "unique", + props: { + the_magic_drip, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + }, + methods: { + _getLastRunAt() { + return this.db.get("lastRunAt") || new Date(0).toISOString(); + }, + _setLastRunAt(timestamp) { + return this.db.set("lastRunAt", timestamp); + }, + }, + hooks: { + async deploy() { + const lastRunAt = new Date(0).toISOString(); + const newTemplates = await this.the_magic_drip.pollNewTemplates(lastRunAt); + const sortedTemplates = newTemplates.sort( + (a, b) => new Date(b.createdAt) - new Date(a.createdAt), + ); + const latest50Templates = sortedTemplates.slice(0, 50); + for (const template of latest50Templates) { + this.$emit(template, { + id: template.templateId || template.createdAt, + summary: `New Template: ${template.name}`, + ts: Date.parse(template.createdAt) || Date.now(), + }); + } + const newLastRunAt = + latest50Templates.length > 0 + ? latest50Templates[0].createdAt + : lastRunAt; + await this._setLastRunAt(newLastRunAt); + }, + async activate() { + // No webhook setup required + }, + async deactivate() { + // No webhook teardown required + }, + }, + async run() { + const lastRunAt = await this._getLastRunAt(); + const newTemplates = await this.the_magic_drip.pollNewTemplates(lastRunAt); + const sortedNewTemplates = newTemplates.sort( + (a, b) => new Date(a.createdAt) - new Date(b.createdAt), + ); + for (const template of sortedNewTemplates) { + this.$emit(template, { + id: template.templateId || template.createdAt, + summary: `New Template: ${template.name}`, + ts: Date.parse(template.createdAt) || Date.now(), + }); + } + if (newTemplates.length > 0) { + const latestCreatedAt = newTemplates.reduce((max, t) => + new Date(t.createdAt) > new Date(max) + ? t.createdAt + : max, + lastRunAt); + await this._setLastRunAt(latestCreatedAt); + } + }, +}; diff --git a/components/the_magic_drip/the_magic_drip.app.mjs b/components/the_magic_drip/the_magic_drip.app.mjs index 34e2097efbef1..4a199d61a4d26 100644 --- a/components/the_magic_drip/the_magic_drip.app.mjs +++ b/components/the_magic_drip/the_magic_drip.app.mjs @@ -1,11 +1,117 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "the_magic_drip", - propDefinitions: {}, + version: "0.0.{{ts}}", + 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.id, + })); + }, + }, + company: { + type: "string", + label: "Company", + description: "The company of the lead", + optional: true, + }, + 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(opts = {}) { + const { + $, method = "GET", path = "/", headers = {}, ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + method, + url: this._baseUrl() + path, + headers: { + ...headers, + "Content-Type": "application/json", + "x-api-key": this.$auth.api_key, + }, + }); + }, + async listCampaigns(opts = {}) { + return this._makeRequest({ + method: "GET", + path: "/campaign", + ...opts, + }); + }, + async addLeadToCampaign({ + campaignId, company, linkedinUrl, + }, opts = {}) { + const leadData = {}; + if (company) leadData.company = company; + if (linkedinUrl) leadData.linkedinUrl = linkedinUrl; + + return this._makeRequest({ + method: "POST", + path: `/campaign/leads/${campaignId}`, + data: { + leadsWithCustomVariables: [ + leadData, + ], + }, + ...opts, + }); + }, + async markCampaignActiveInactive({ + campaignId, desiredState, + }, opts = {}) { + const path = desiredState + ? `/campaign/${campaignId}/active` + : `/campaign/${campaignId}/inactive`; + return this._makeRequest({ + method: "POST", + path, + ...opts, + }); + }, + async listTemplates(opts = {}) { + return this._makeRequest({ + method: "GET", + path: "/templates", + ...opts, + }); + }, + async pollNewCampaigns(lastRunAt) { + const campaigns = await this.listCampaigns(); + return campaigns.filter( + (campaign) => new Date(campaign.createdAt) > new Date(lastRunAt), + ); + }, + async pollNewTemplates(lastRunAt) { + const templates = await this.listTemplates(); + return templates.filter( + (template) => new Date(template.createdAt) > new Date(lastRunAt), + ); + }, }, -}; \ No newline at end of file +}; From 8ff38e273bbbcdb88c8489b633288f15ec6f71b3 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 9 Oct 2024 23:59:51 -0300 Subject: [PATCH 02/13] Package/app adjustments --- components/the_magic_drip/package.json | 3 +++ components/the_magic_drip/the_magic_drip.app.mjs | 14 +++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/components/the_magic_drip/package.json b/components/the_magic_drip/package.json index 8103b21a6a897..6ed06eaa191df 100644 --- a/components/the_magic_drip/package.json +++ b/components/the_magic_drip/package.json @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } } diff --git a/components/the_magic_drip/the_magic_drip.app.mjs b/components/the_magic_drip/the_magic_drip.app.mjs index 4a199d61a4d26..5b78c11f30874 100644 --- a/components/the_magic_drip/the_magic_drip.app.mjs +++ b/components/the_magic_drip/the_magic_drip.app.mjs @@ -36,30 +36,23 @@ export default { }, }, methods: { - authKeys() { - console.log(Object.keys(this.$auth)); - }, _baseUrl() { return "https://api.themagicdrip.com/v1"; }, - async _makeRequest(opts = {}) { - const { - $, method = "GET", path = "/", headers = {}, ...otherOpts - } = opts; + async _makeRequest({ + $, path, headers, ...otherOpts + } = {}) { return axios($, { ...otherOpts, - method, url: this._baseUrl() + path, headers: { ...headers, - "Content-Type": "application/json", "x-api-key": this.$auth.api_key, }, }); }, async listCampaigns(opts = {}) { return this._makeRequest({ - method: "GET", path: "/campaign", ...opts, }); @@ -96,7 +89,6 @@ export default { }, async listTemplates(opts = {}) { return this._makeRequest({ - method: "GET", path: "/templates", ...opts, }); From 338ca03ff4f034fac190fc749786ab11f79a9b2b Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 10 Oct 2024 00:00:31 -0300 Subject: [PATCH 03/13] pnpm --- pnpm-lock.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 863b9b55b7643..9d450d2dafb8a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9983,7 +9983,10 @@ importers: '@pipedream/platform': 3.0.3 components/the_magic_drip: - specifiers: {} + specifiers: + '@pipedream/platform': ^3.0.3 + dependencies: + '@pipedream/platform': 3.0.3 components/the_odds_api: specifiers: From b6e8582b31e02029ae2c7bcf0f029ded64905da6 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 10 Oct 2024 00:16:53 -0300 Subject: [PATCH 04/13] Adjustments --- .../add_lead_to_campaign/add_lead_to_campaign.mjs | 12 ++++++------ .../actions/list_campaigns/list_campaigns.mjs | 14 +++++++------- .../actions/list_templates/list_templates.mjs | 12 ++++++------ .../mark_campaign_active_or_inactive.mjs | 8 ++++---- .../new campaign created/new_campaign_created.mjs | 8 ++++---- .../new template created/new_template_created.mjs | 8 ++++---- components/the_magic_drip/the_magic_drip.app.mjs | 1 - 7 files changed, 31 insertions(+), 32 deletions(-) diff --git a/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs b/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs index 9f7f454d8177a..428d9715b552d 100644 --- a/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs +++ b/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs @@ -1,4 +1,4 @@ -import the_magic_drip from "../../the_magic_drip.app.mjs"; +import app from "../../the_magic_drip.app.mjs"; export default { key: "the_magic_drip-add-lead-to-campaign", @@ -7,30 +7,30 @@ export default { version: "0.0.{{ts}}", type: "action", props: { - the_magic_drip, + app, campaignId: { propDefinition: [ - the_magic_drip, + app, "campaignId", ], }, company: { propDefinition: [ - the_magic_drip, + app, "company", ], optional: true, }, linkedinUrl: { propDefinition: [ - the_magic_drip, + app, "linkedinUrl", ], optional: true, }, }, async run({ $ }) { - const response = await this.the_magic_drip.addLeadToCampaign({ + const response = await this.app.addLeadToCampaign({ campaignId: this.campaignId, company: this.company, linkedinUrl: this.linkedinUrl, diff --git a/components/the_magic_drip/actions/list_campaigns/list_campaigns.mjs b/components/the_magic_drip/actions/list_campaigns/list_campaigns.mjs index aff7f6d447a65..a5102c24457e3 100644 --- a/components/the_magic_drip/actions/list_campaigns/list_campaigns.mjs +++ b/components/the_magic_drip/actions/list_campaigns/list_campaigns.mjs @@ -1,17 +1,17 @@ -import the_magic_drip from "../../the_magic_drip.app.mjs"; +import app from "../../the_magic_drip.app.mjs"; export default { key: "the_magic_drip-list-campaigns", name: "List Campaigns", - description: "Lists all available campaigns. [See the documentation](https://docs.themagicdrip.com/api-reference/introduction)", - version: "0.0.{{ts}}", + description: "Retrieve all available campaigns. [See the documentation](https://docs.themagicdrip.com/api-reference/endpoint/get-v1campaign)", + version: "0.0.1", type: "action", props: { - the_magic_drip, + app, }, async run({ $ }) { - const response = await this.the_magic_drip.listCampaigns(); - $.export("$summary", `Listed ${response.campaigns.length} campaigns`); - return response.campaigns; + const { campaigns } = await this.app.listCampaigns(); + $.export("$summary", `Sucessfully retrieved ${campaigns?.length ?? 0} campaigns`); + return campaigns; }, }; diff --git a/components/the_magic_drip/actions/list_templates/list_templates.mjs b/components/the_magic_drip/actions/list_templates/list_templates.mjs index fba6bc4c06549..a4be1523ac5f0 100644 --- a/components/the_magic_drip/actions/list_templates/list_templates.mjs +++ b/components/the_magic_drip/actions/list_templates/list_templates.mjs @@ -1,17 +1,17 @@ -import the_magic_drip from "../../the_magic_drip.app.mjs"; +import app from "../../the_magic_drip.app.mjs"; export default { key: "the_magic_drip-list-templates", name: "List Templates", - description: "Lists all available templates. [See the documentation]()", - version: "0.0.{{ts}}", + description: "Retrieve all available templates. [See the documentation](https://docs.themagicdrip.com/api-reference/endpoint/get-v1templates)", + version: "0.0.1", type: "action", props: { - the_magic_drip, + app, }, async run({ $ }) { - const templates = await this.the_magic_drip.listTemplates(); - $.export("$summary", `Listed ${templates.templates.length} templates`); + const { templates } = await this.app.listTemplates(); + $.export("$summary", `Sucessfully retrieved ${templates?.length ?? 0} templates`); return templates; }, }; diff --git a/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs b/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs index 8eaae18d9c1c7..1e64b2eadfe5b 100644 --- a/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs +++ b/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs @@ -1,4 +1,4 @@ -import the_magic_drip from "../../the_magic_drip.app.mjs"; +import app from "../../the_magic_drip.app.mjs"; export default { key: "the_magic_drip-mark-campaign-active-inactive", @@ -7,10 +7,10 @@ export default { version: "0.0.{{ts}}", type: "action", props: { - the_magic_drip, + app, campaignId: { propDefinition: [ - the_magic_drip, + app, "campaignId", ], }, @@ -21,7 +21,7 @@ export default { }, }, async run({ $ }) { - const response = await this.the_magic_drip.markCampaignActiveInactive({ + const response = await this.app.markCampaignActiveInactive({ campaignId: this.campaignId, desiredState: this.desiredState, }); diff --git a/components/the_magic_drip/sources/new campaign created/new_campaign_created.mjs b/components/the_magic_drip/sources/new campaign created/new_campaign_created.mjs index d83e6ec820a6e..b45c2f23c8b11 100644 --- a/components/the_magic_drip/sources/new campaign created/new_campaign_created.mjs +++ b/components/the_magic_drip/sources/new campaign created/new_campaign_created.mjs @@ -1,5 +1,5 @@ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; -import the_magic_drip from "../../the_magic_drip.app.mjs"; +import app from "../../the_magic_drip.app.mjs"; export default { key: "the_magic_drip-new-campaign-created", @@ -9,7 +9,7 @@ export default { type: "source", dedupe: "unique", props: { - the_magic_drip, + app, db: "$.service.db", timer: { type: "$.interface.timer", @@ -21,7 +21,7 @@ export default { hooks: { async deploy() { const lastRunAt = new Date(0).toISOString(); - const newCampaigns = await this.the_magic_drip.pollNewCampaigns(lastRunAt); + const newCampaigns = await this.app.pollNewCampaigns(lastRunAt); const sortedCampaigns = newCampaigns.sort( (a, b) => new Date(b.createdAt) - new Date(a.createdAt), ).slice(0, 50); @@ -51,7 +51,7 @@ export default { }, async run() { const lastRunAt = (await this.db.get("lastRunAt")) || new Date(0).toISOString(); - const newCampaigns = await this.the_magic_drip.pollNewCampaigns(lastRunAt); + const newCampaigns = await this.app.pollNewCampaigns(lastRunAt); const sortedCampaigns = newCampaigns.sort( (a, b) => new Date(b.createdAt) - new Date(a.createdAt), ); diff --git a/components/the_magic_drip/sources/new template created/new_template_created.mjs b/components/the_magic_drip/sources/new template created/new_template_created.mjs index faa340f8addf5..293e05442d31b 100644 --- a/components/the_magic_drip/sources/new template created/new_template_created.mjs +++ b/components/the_magic_drip/sources/new template created/new_template_created.mjs @@ -1,5 +1,5 @@ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; -import the_magic_drip from "../../the_magic_drip.app.mjs"; +import app from "../../the_magic_drip.app.mjs"; export default { key: "the_magic_drip-new-template-created", @@ -9,7 +9,7 @@ export default { type: "source", dedupe: "unique", props: { - the_magic_drip, + app, db: "$.service.db", timer: { type: "$.interface.timer", @@ -29,7 +29,7 @@ export default { hooks: { async deploy() { const lastRunAt = new Date(0).toISOString(); - const newTemplates = await this.the_magic_drip.pollNewTemplates(lastRunAt); + const newTemplates = await this.app.pollNewTemplates(lastRunAt); const sortedTemplates = newTemplates.sort( (a, b) => new Date(b.createdAt) - new Date(a.createdAt), ); @@ -56,7 +56,7 @@ export default { }, async run() { const lastRunAt = await this._getLastRunAt(); - const newTemplates = await this.the_magic_drip.pollNewTemplates(lastRunAt); + const newTemplates = await this.app.pollNewTemplates(lastRunAt); const sortedNewTemplates = newTemplates.sort( (a, b) => new Date(a.createdAt) - new Date(b.createdAt), ); diff --git a/components/the_magic_drip/the_magic_drip.app.mjs b/components/the_magic_drip/the_magic_drip.app.mjs index 5b78c11f30874..a17c4e3674917 100644 --- a/components/the_magic_drip/the_magic_drip.app.mjs +++ b/components/the_magic_drip/the_magic_drip.app.mjs @@ -3,7 +3,6 @@ import { axios } from "@pipedream/platform"; export default { type: "app", app: "the_magic_drip", - version: "0.0.{{ts}}", propDefinitions: { campaignId: { type: "string", From e680eeffe42c09a7db137f1e7bb8e58b9bb67c13 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 10 Oct 2024 00:26:29 -0300 Subject: [PATCH 05/13] Adjustments --- .../actions/list_campaigns/list_campaigns.mjs | 4 +++- .../actions/list_templates/list_templates.mjs | 4 +++- .../mark_campaign_active_or_inactive.mjs | 24 +++++++++++-------- .../the_magic_drip/the_magic_drip.app.mjs | 11 ++++----- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/components/the_magic_drip/actions/list_campaigns/list_campaigns.mjs b/components/the_magic_drip/actions/list_campaigns/list_campaigns.mjs index a5102c24457e3..ce20a7e7bd5cb 100644 --- a/components/the_magic_drip/actions/list_campaigns/list_campaigns.mjs +++ b/components/the_magic_drip/actions/list_campaigns/list_campaigns.mjs @@ -10,7 +10,9 @@ export default { app, }, async run({ $ }) { - const { campaigns } = await this.app.listCampaigns(); + const { campaigns } = await this.app.listCampaigns({ + $, + }); $.export("$summary", `Sucessfully retrieved ${campaigns?.length ?? 0} campaigns`); return campaigns; }, diff --git a/components/the_magic_drip/actions/list_templates/list_templates.mjs b/components/the_magic_drip/actions/list_templates/list_templates.mjs index a4be1523ac5f0..d99ab2b4a44c0 100644 --- a/components/the_magic_drip/actions/list_templates/list_templates.mjs +++ b/components/the_magic_drip/actions/list_templates/list_templates.mjs @@ -10,7 +10,9 @@ export default { app, }, async run({ $ }) { - const { templates } = await this.app.listTemplates(); + const { templates } = await this.app.listTemplates({ + $, + }); $.export("$summary", `Sucessfully retrieved ${templates?.length ?? 0} templates`); return templates; }, diff --git a/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs b/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs index 1e64b2eadfe5b..7415e5336df78 100644 --- a/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs +++ b/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs @@ -2,8 +2,8 @@ import app from "../../the_magic_drip.app.mjs"; export default { key: "the_magic_drip-mark-campaign-active-inactive", - name: "Mark Campaign Active/Inactive", - description: "Marks a campaign as active or inactive. [See the documentation]()", + 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.{{ts}}", type: "action", props: { @@ -14,21 +14,25 @@ export default { "campaignId", ], }, - desiredState: { + activate: { type: "boolean", - label: "Desired State", - description: "Set to true to activate, false to deactivate the campaign", + 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: this.campaignId, - desiredState: this.desiredState, + $, + campaignId, + activate, }); - $.export("$summary", `Marked campaign ${this.campaignId} as ${this.desiredState - ? "active" - : "inactive"}.`); + $.export("$summary", `Successfully ${activate + ? "" + : "de"}activated campaign ${campaignId}`); return response; }, diff --git a/components/the_magic_drip/the_magic_drip.app.mjs b/components/the_magic_drip/the_magic_drip.app.mjs index a17c4e3674917..36dc22b8f452d 100644 --- a/components/the_magic_drip/the_magic_drip.app.mjs +++ b/components/the_magic_drip/the_magic_drip.app.mjs @@ -75,14 +75,13 @@ export default { }); }, async markCampaignActiveInactive({ - campaignId, desiredState, - }, opts = {}) { - const path = desiredState - ? `/campaign/${campaignId}/active` - : `/campaign/${campaignId}/inactive`; + campaignId, activate, ...opts + }) { return this._makeRequest({ method: "POST", - path, + path: `/campaign/${campaignId}/${activate + ? "active" + : "inactive"}`, ...opts, }); }, From 1725dec5355e58dccd7417db2a890bc435491079 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 10 Oct 2024 00:35:30 -0300 Subject: [PATCH 06/13] Adjustments --- .../add_lead_to_campaign.mjs | 52 +++++++++++++------ .../the_magic_drip/the_magic_drip.app.mjs | 19 +------ 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs b/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs index 428d9715b552d..13fcf4ce00db7 100644 --- a/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs +++ b/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs @@ -3,7 +3,7 @@ import app from "../../the_magic_drip.app.mjs"; export default { key: "the_magic_drip-add-lead-to-campaign", name: "Add Lead to Campaign", - description: "Adds a single lead to a campaign. [See the documentation]()", + description: "Add a lead to a campaign. [See the documentation](https://docs.themagicdrip.com/api-reference/endpoint/post-v1campaignleads)", version: "0.0.{{ts}}", type: "action", props: { @@ -14,30 +14,52 @@ export default { "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: { - propDefinition: [ - app, - "company", - ], + type: "string", + label: "Company", + description: "Company of the lead", optional: true, }, - linkedinUrl: { - propDefinition: [ - app, - "linkedinUrl", - ], + companyLinkedInUrl: { + type: "string", + label: "Company LinkedIn URL", + description: "LinkedIn URL of the company", optional: true, }, }, async run({ $ }) { - const response = await this.app.addLeadToCampaign({ - campaignId: this.campaignId, - company: this.company, - linkedinUrl: this.linkedinUrl, + const { + app, campaignId, ...lead + } = this; + const response = await app.addLeadToCampaign({ + $, + campaignId, + data: { + leadsWithCustomVariables: [ + lead, + ], + }, }); $.export( "$summary", - `Added ${response.totalLeadsAddedToWorkflow} lead(s) to campaign ${this.campaignId}`, + `Successfully added lead "${lead.lastName}" to campaign ${campaignId}`, ); return response; }, diff --git a/components/the_magic_drip/the_magic_drip.app.mjs b/components/the_magic_drip/the_magic_drip.app.mjs index 36dc22b8f452d..9657c4d557077 100644 --- a/components/the_magic_drip/the_magic_drip.app.mjs +++ b/components/the_magic_drip/the_magic_drip.app.mjs @@ -16,12 +16,6 @@ export default { })); }, }, - company: { - type: "string", - label: "Company", - description: "The company of the lead", - optional: true, - }, linkedinUrl: { type: "string", label: "LinkedIn URL", @@ -57,20 +51,11 @@ export default { }); }, async addLeadToCampaign({ - campaignId, company, linkedinUrl, - }, opts = {}) { - const leadData = {}; - if (company) leadData.company = company; - if (linkedinUrl) leadData.linkedinUrl = linkedinUrl; - + campaignId, ...opts + }) { return this._makeRequest({ method: "POST", path: `/campaign/leads/${campaignId}`, - data: { - leadsWithCustomVariables: [ - leadData, - ], - }, ...opts, }); }, From 459134e6efe9e537a95b2e6ca64ece0b94636d85 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 10 Oct 2024 00:50:32 -0300 Subject: [PATCH 07/13] Adjustments --- .../add_lead_to_campaign.mjs | 8 +++++++- .../mark_campaign_active_or_inactive.mjs | 2 +- .../the_magic_drip/the_magic_drip.app.mjs | 19 ++++--------------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs b/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs index 13fcf4ce00db7..5cd6dba68e7f9 100644 --- a/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs +++ b/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs @@ -43,6 +43,12 @@ export default { 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 { @@ -59,7 +65,7 @@ export default { }); $.export( "$summary", - `Successfully added lead "${lead.lastName}" to campaign ${campaignId}`, + `Successfully added lead "${lead.lastName}" to campaign`, ); return response; }, diff --git a/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs b/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs index 7415e5336df78..89f4f64a92f5e 100644 --- a/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs +++ b/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs @@ -32,7 +32,7 @@ export default { $.export("$summary", `Successfully ${activate ? "" - : "de"}activated campaign ${campaignId}`); + : "de"}activated campaign`); return response; }, diff --git a/components/the_magic_drip/the_magic_drip.app.mjs b/components/the_magic_drip/the_magic_drip.app.mjs index 9657c4d557077..da2137b51a1ef 100644 --- a/components/the_magic_drip/the_magic_drip.app.mjs +++ b/components/the_magic_drip/the_magic_drip.app.mjs @@ -9,10 +9,11 @@ export default { label: "Campaign ID", description: "Select a campaign", async options() { - const campaigns = await this.listCampaigns(); - return campaigns.map((campaign) => ({ + const { campaigns } = await this.listCampaigns(); + console.log(campaigns); + return campaigns?.map((campaign) => ({ label: campaign.name, - value: campaign.id, + value: campaign.workflowId, })); }, }, @@ -76,17 +77,5 @@ export default { ...opts, }); }, - async pollNewCampaigns(lastRunAt) { - const campaigns = await this.listCampaigns(); - return campaigns.filter( - (campaign) => new Date(campaign.createdAt) > new Date(lastRunAt), - ); - }, - async pollNewTemplates(lastRunAt) { - const templates = await this.listTemplates(); - return templates.filter( - (template) => new Date(template.createdAt) > new Date(lastRunAt), - ); - }, }, }; From 7e28250aa74c143ea01727c9973fe11cba67f8b4 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 10 Oct 2024 00:51:20 -0300 Subject: [PATCH 08/13] Renaming sources --- .../new_campaign_created.mjs | 0 .../new_template_created.mjs | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename components/the_magic_drip/sources/{new campaign created => new_campaign_created}/new_campaign_created.mjs (100%) rename components/the_magic_drip/sources/{new template created => new_template_created}/new_template_created.mjs (100%) diff --git a/components/the_magic_drip/sources/new campaign created/new_campaign_created.mjs b/components/the_magic_drip/sources/new_campaign_created/new_campaign_created.mjs similarity index 100% rename from components/the_magic_drip/sources/new campaign created/new_campaign_created.mjs rename to components/the_magic_drip/sources/new_campaign_created/new_campaign_created.mjs diff --git a/components/the_magic_drip/sources/new template created/new_template_created.mjs b/components/the_magic_drip/sources/new_template_created/new_template_created.mjs similarity index 100% rename from components/the_magic_drip/sources/new template created/new_template_created.mjs rename to components/the_magic_drip/sources/new_template_created/new_template_created.mjs From e0db198c96d7ad9493711d9b20036a2765d9f215 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 10 Oct 2024 01:02:58 -0300 Subject: [PATCH 09/13] Adjusting Sources --- components/the_magic_drip/sources/common.mjs | 56 +++++++++++++ .../new_campaign_created.mjs | 84 ++++--------------- .../new_template_created.mjs | 82 ++++-------------- 3 files changed, 87 insertions(+), 135 deletions(-) create mode 100644 components/the_magic_drip/sources/common.mjs diff --git a/components/the_magic_drip/sources/common.mjs b/components/the_magic_drip/sources/common.mjs new file mode 100644 index 0000000000000..1d3b3ab59a27e --- /dev/null +++ b/components/the_magic_drip/sources/common.mjs @@ -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(), + }; + }, + async getAndProcessData(maxEmits = 0) { + const savedIds = this._getSavedIds(); + const items = await this.getItems(); + + 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)); + }); + + this._setSavedIds(savedIds); + }, + }, + hooks: { + async deploy() { + await this.getAndProcessData(5); + }, + }, + async run() { + await this.getAndProcessData(); + }, +}; diff --git a/components/the_magic_drip/sources/new_campaign_created/new_campaign_created.mjs b/components/the_magic_drip/sources/new_campaign_created/new_campaign_created.mjs index b45c2f23c8b11..deb1c88ac56ac 100644 --- a/components/the_magic_drip/sources/new_campaign_created/new_campaign_created.mjs +++ b/components/the_magic_drip/sources/new_campaign_created/new_campaign_created.mjs @@ -1,79 +1,27 @@ -import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; -import app from "../../the_magic_drip.app.mjs"; +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]()", - version: "0.0.{{ts}}", + 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", - props: { - app, - db: "$.service.db", - timer: { - type: "$.interface.timer", - default: { - intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, - }, + methods: { + ...common.methods, + async getItems() { + const { campaigns } = await this.app.listCampaigns(); + return campaigns; }, - }, - hooks: { - async deploy() { - const lastRunAt = new Date(0).toISOString(); - const newCampaigns = await this.app.pollNewCampaigns(lastRunAt); - const sortedCampaigns = newCampaigns.sort( - (a, b) => new Date(b.createdAt) - new Date(a.createdAt), - ).slice(0, 50); - - for (const campaign of sortedCampaigns) { - this.$emit( - campaign, - { - id: campaign.id || campaign.createdAt, - summary: `New Campaign: ${campaign.name}`, - ts: Date.parse(campaign.createdAt), - }, - ); - } - - const latestCreatedAt = sortedCampaigns.length - ? sortedCampaigns[0].createdAt - : lastRunAt; - await this.db.set("lastRunAt", latestCreatedAt); - }, - async activate() { - // No action needed on activate for polling source + getItemId(item) { + return item.workflowId; }, - async deactivate() { - // No action needed on deactivate for polling source + getItemMetadata(item) { + return { + summary: `New Campaign: ${item.name}`, + ts: item.createdAt, + }; }, }, - async run() { - const lastRunAt = (await this.db.get("lastRunAt")) || new Date(0).toISOString(); - const newCampaigns = await this.app.pollNewCampaigns(lastRunAt); - const sortedCampaigns = newCampaigns.sort( - (a, b) => new Date(b.createdAt) - new Date(a.createdAt), - ); - - for (const campaign of sortedCampaigns) { - this.$emit( - campaign, - { - id: campaign.id || campaign.createdAt, - summary: `New Campaign: ${campaign.name}`, - ts: Date.parse(campaign.createdAt), - }, - ); - } - - if (newCampaigns.length) { - const latestCreatedAt = newCampaigns.reduce((latest, campaign) => { - return new Date(campaign.createdAt) > new Date(latest) - ? campaign.createdAt - : latest; - }, lastRunAt); - await this.db.set("lastRunAt", latestCreatedAt); - } - }, }; diff --git a/components/the_magic_drip/sources/new_template_created/new_template_created.mjs b/components/the_magic_drip/sources/new_template_created/new_template_created.mjs index 293e05442d31b..9f7fa98c5d68f 100644 --- a/components/the_magic_drip/sources/new_template_created/new_template_created.mjs +++ b/components/the_magic_drip/sources/new_template_created/new_template_created.mjs @@ -1,79 +1,27 @@ -import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; -import app from "../../the_magic_drip.app.mjs"; +import common from "../common.mjs"; export default { + ...common, key: "the_magic_drip-new-template-created", name: "New Template Created", - description: "Emits a new event when a template is created. [See the documentation]()", - version: "0.0.{{ts}}", + 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", - props: { - app, - db: "$.service.db", - timer: { - type: "$.interface.timer", - default: { - intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, - }, - }, - }, methods: { - _getLastRunAt() { - return this.db.get("lastRunAt") || new Date(0).toISOString(); - }, - _setLastRunAt(timestamp) { - return this.db.set("lastRunAt", timestamp); + ...common.methods, + async getItems() { + const { templates } = await this.app.listTemplates(); + return templates; }, - }, - hooks: { - async deploy() { - const lastRunAt = new Date(0).toISOString(); - const newTemplates = await this.app.pollNewTemplates(lastRunAt); - const sortedTemplates = newTemplates.sort( - (a, b) => new Date(b.createdAt) - new Date(a.createdAt), - ); - const latest50Templates = sortedTemplates.slice(0, 50); - for (const template of latest50Templates) { - this.$emit(template, { - id: template.templateId || template.createdAt, - summary: `New Template: ${template.name}`, - ts: Date.parse(template.createdAt) || Date.now(), - }); - } - const newLastRunAt = - latest50Templates.length > 0 - ? latest50Templates[0].createdAt - : lastRunAt; - await this._setLastRunAt(newLastRunAt); - }, - async activate() { - // No webhook setup required + getItemId(item) { + return item.templateId; }, - async deactivate() { - // No webhook teardown required + getItemMetadata(item) { + return { + summary: `New Template: ${item.name}`, + ts: item.createdAt, + }; }, }, - async run() { - const lastRunAt = await this._getLastRunAt(); - const newTemplates = await this.app.pollNewTemplates(lastRunAt); - const sortedNewTemplates = newTemplates.sort( - (a, b) => new Date(a.createdAt) - new Date(b.createdAt), - ); - for (const template of sortedNewTemplates) { - this.$emit(template, { - id: template.templateId || template.createdAt, - summary: `New Template: ${template.name}`, - ts: Date.parse(template.createdAt) || Date.now(), - }); - } - if (newTemplates.length > 0) { - const latestCreatedAt = newTemplates.reduce((max, t) => - new Date(t.createdAt) > new Date(max) - ? t.createdAt - : max, - lastRunAt); - await this._setLastRunAt(latestCreatedAt); - } - }, }; From 149a733dc16f15d98f50a1456044ac1f6c5f573f Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 10 Oct 2024 01:07:04 -0300 Subject: [PATCH 10/13] Package version bump --- components/the_magic_drip/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/the_magic_drip/package.json b/components/the_magic_drip/package.json index 6ed06eaa191df..b082e1ca3a97f 100644 --- a/components/the_magic_drip/package.json +++ b/components/the_magic_drip/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/the_magic_drip", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream The Magic Drip Components", "main": "the_magic_drip.app.mjs", "keywords": [ From 0e71af91b25c4a887f54630c84dc2f48fb46be65 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 10 Oct 2024 16:15:27 -0300 Subject: [PATCH 11/13] Adjusting filenames and versions --- .../add-lead-to-campaign.mjs} | 2 +- .../list_campaigns.mjs => list-campaigns/list-campaigns.mjs} | 0 .../list_templates.mjs => list-templates/list-templates.mjs} | 0 .../mark-campaign-active-or-inactive.mjs} | 2 +- .../new-campaign-created.mjs} | 0 .../new-template-created.mjs} | 0 6 files changed, 2 insertions(+), 2 deletions(-) rename components/the_magic_drip/actions/{add_lead_to_campaign/add_lead_to_campaign.mjs => add-lead-to-campaign/add-lead-to-campaign.mjs} (98%) rename components/the_magic_drip/actions/{list_campaigns/list_campaigns.mjs => list-campaigns/list-campaigns.mjs} (100%) rename components/the_magic_drip/actions/{list_templates/list_templates.mjs => list-templates/list-templates.mjs} (100%) rename components/the_magic_drip/actions/{mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs => mark-campaign-active-or-inactive/mark-campaign-active-or-inactive.mjs} (97%) rename components/the_magic_drip/sources/{new_campaign_created/new_campaign_created.mjs => new-campaign-created/new-campaign-created.mjs} (100%) rename components/the_magic_drip/sources/{new_template_created/new_template_created.mjs => new-template-created/new-template-created.mjs} (100%) diff --git a/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs b/components/the_magic_drip/actions/add-lead-to-campaign/add-lead-to-campaign.mjs similarity index 98% rename from components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs rename to components/the_magic_drip/actions/add-lead-to-campaign/add-lead-to-campaign.mjs index 5cd6dba68e7f9..f27a8ff603700 100644 --- a/components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs +++ b/components/the_magic_drip/actions/add-lead-to-campaign/add-lead-to-campaign.mjs @@ -4,7 +4,7 @@ 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.{{ts}}", + version: "0.0.1", type: "action", props: { app, diff --git a/components/the_magic_drip/actions/list_campaigns/list_campaigns.mjs b/components/the_magic_drip/actions/list-campaigns/list-campaigns.mjs similarity index 100% rename from components/the_magic_drip/actions/list_campaigns/list_campaigns.mjs rename to components/the_magic_drip/actions/list-campaigns/list-campaigns.mjs diff --git a/components/the_magic_drip/actions/list_templates/list_templates.mjs b/components/the_magic_drip/actions/list-templates/list-templates.mjs similarity index 100% rename from components/the_magic_drip/actions/list_templates/list_templates.mjs rename to components/the_magic_drip/actions/list-templates/list-templates.mjs diff --git a/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs b/components/the_magic_drip/actions/mark-campaign-active-or-inactive/mark-campaign-active-or-inactive.mjs similarity index 97% rename from components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs rename to components/the_magic_drip/actions/mark-campaign-active-or-inactive/mark-campaign-active-or-inactive.mjs index 89f4f64a92f5e..5d159160765fc 100644 --- a/components/the_magic_drip/actions/mark_campaign_active_or_inactive/mark_campaign_active_or_inactive.mjs +++ b/components/the_magic_drip/actions/mark-campaign-active-or-inactive/mark-campaign-active-or-inactive.mjs @@ -4,7 +4,7 @@ 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.{{ts}}", + version: "0.0.1", type: "action", props: { app, diff --git a/components/the_magic_drip/sources/new_campaign_created/new_campaign_created.mjs b/components/the_magic_drip/sources/new-campaign-created/new-campaign-created.mjs similarity index 100% rename from components/the_magic_drip/sources/new_campaign_created/new_campaign_created.mjs rename to components/the_magic_drip/sources/new-campaign-created/new-campaign-created.mjs diff --git a/components/the_magic_drip/sources/new_template_created/new_template_created.mjs b/components/the_magic_drip/sources/new-template-created/new-template-created.mjs similarity index 100% rename from components/the_magic_drip/sources/new_template_created/new_template_created.mjs rename to components/the_magic_drip/sources/new-template-created/new-template-created.mjs From 013fb3a966510e8ffdd50df2d45b7742e14a1898 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 10 Oct 2024 16:16:39 -0300 Subject: [PATCH 12/13] Removing console log --- components/the_magic_drip/the_magic_drip.app.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/components/the_magic_drip/the_magic_drip.app.mjs b/components/the_magic_drip/the_magic_drip.app.mjs index da2137b51a1ef..e233f9101d9b4 100644 --- a/components/the_magic_drip/the_magic_drip.app.mjs +++ b/components/the_magic_drip/the_magic_drip.app.mjs @@ -10,7 +10,6 @@ export default { description: "Select a campaign", async options() { const { campaigns } = await this.listCampaigns(); - console.log(campaigns); return campaigns?.map((campaign) => ({ label: campaign.name, value: campaign.workflowId, From a712830693dae623d2ac532fbbfa5cacffcff113 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 10 Oct 2024 16:43:56 -0300 Subject: [PATCH 13/13] component key adjustmnet --- .../mark-campaign-active-or-inactive.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/the_magic_drip/actions/mark-campaign-active-or-inactive/mark-campaign-active-or-inactive.mjs b/components/the_magic_drip/actions/mark-campaign-active-or-inactive/mark-campaign-active-or-inactive.mjs index 5d159160765fc..a2ac55e62d25f 100644 --- a/components/the_magic_drip/actions/mark-campaign-active-or-inactive/mark-campaign-active-or-inactive.mjs +++ b/components/the_magic_drip/actions/mark-campaign-active-or-inactive/mark-campaign-active-or-inactive.mjs @@ -1,7 +1,7 @@ import app from "../../the_magic_drip.app.mjs"; export default { - key: "the_magic_drip-mark-campaign-active-inactive", + key: "the_magic_drip-mark-campaign-active-or-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",