diff --git a/components/tubular/.gitignore b/components/tubular/.gitignore deleted file mode 100644 index ec761ccab7595..0000000000000 --- a/components/tubular/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.js -*.mjs -dist \ No newline at end of file diff --git a/components/tubular/actions/create-lead/create-lead.mjs b/components/tubular/actions/create-lead/create-lead.mjs new file mode 100644 index 0000000000000..d83c9eaf236f2 --- /dev/null +++ b/components/tubular/actions/create-lead/create-lead.mjs @@ -0,0 +1,62 @@ +import app from "../../tubular.app.mjs"; + +export default { + key: "tubular-create-lead", + name: "Create Lead", + description: "Create lead and return its ID. [See the documentation](https://developer.tubular.io/examples/#create-lead-and-return-its-id)", + version: "0.0.1", + type: "action", + props: { + app, + firstName: { + propDefinition: [ + app, + "firstName", + ], + }, + lastName: { + propDefinition: [ + app, + "lastName", + ], + }, + note: { + propDefinition: [ + app, + "note", + ], + }, + lead: { + propDefinition: [ + app, + "lead", + ], + }, + }, + async run({ $ }) { + const query = ` + mutation { + addContact(input: { + firstName: "${this.firstName}", + lastName: "${this.lastName}", + note: "${this.note}", + lead: ${this.lead} + }) { + contact { + id + } + } + } + `; + + const response = await this.app.post({ + $, + data: { + query, + }, + }); + + $.export("$summary", "Successfully created Lead with ID: " + response.data.addContact.contact.id); + return response; + }, +}; diff --git a/components/tubular/actions/get-deals-by-date/get-deals-by-date.mjs b/components/tubular/actions/get-deals-by-date/get-deals-by-date.mjs new file mode 100644 index 0000000000000..54f7f7ad523ea --- /dev/null +++ b/components/tubular/actions/get-deals-by-date/get-deals-by-date.mjs @@ -0,0 +1,41 @@ +import app from "../../tubular.app.mjs"; + +export default { + key: "tubular-get-deals-by-date", + name: "Get Deals By Date", + description: "Get deals ordered by date of creation. [See the documentation](https://developer.tubular.io/examples/#get-deals-ordered-by-date-of-creation)", + version: "0.0.1", + type: "action", + props: { + app, + }, + async run({ $ }) { + const query = `{ + viewer{ + pipelines(first:100){ + edges{ + node{ + deals(orderBy:CREATED_AT, direction: DESC){ + edges{ + node{ + id + name + currency + } + } + } + } + } + } + } + }`; + const response = await this.app.post({ + $, + data: { + query, + }, + }); + $.export("$summary", "Successfully fetched Deals"); + return response; + }, +}; diff --git a/components/tubular/actions/get-leads/get-leads.mjs b/components/tubular/actions/get-leads/get-leads.mjs new file mode 100644 index 0000000000000..eeb44608e9424 --- /dev/null +++ b/components/tubular/actions/get-leads/get-leads.mjs @@ -0,0 +1,36 @@ +import app from "../../tubular.app.mjs"; + +export default { + key: "tubular-get-leads", + name: "Get Leads", + description: "Get leads ordered by date of creation. [See the documentation](https://developer.tubular.io/examples/#get-first-10-leads)", + version: "0.0.1", + type: "action", + props: { + app, + }, + async run({ $ }) { + const query = `{ + viewer{ + leads(first: 100){ + edges{ + node{ + id + fullName + email + lead + } + } + } + } + }`; + const response = await this.app.post({ + $, + data: { + query, + }, + }); + $.export("$summary", "Successfully fetched Leads"); + return response; + }, +}; diff --git a/components/tubular/app/tubular.app.ts b/components/tubular/app/tubular.app.ts deleted file mode 100644 index 392856a14ac57..0000000000000 --- a/components/tubular/app/tubular.app.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { defineApp } from "@pipedream/types"; - -export default defineApp({ - type: "app", - app: "tubular", - propDefinitions: {}, - methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); - }, - }, -}); \ No newline at end of file diff --git a/components/tubular/package.json b/components/tubular/package.json index a5e6e753b4996..26d9f5b604cf1 100644 --- a/components/tubular/package.json +++ b/components/tubular/package.json @@ -1,16 +1,18 @@ { "name": "@pipedream/tubular", - "version": "0.0.2", + "version": "0.1.0", "description": "Pipedream Tubular Components", - "main": "dist/app/tubular.app.mjs", + "main": "tubular.app.mjs", "keywords": [ "pipedream", "tubular" ], - "files": ["dist"], "homepage": "https://pipedream.com/apps/tubular", "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } } diff --git a/components/tubular/tubular.app.mjs b/components/tubular/tubular.app.mjs new file mode 100644 index 0000000000000..07be3d92f9b10 --- /dev/null +++ b/components/tubular/tubular.app.mjs @@ -0,0 +1,54 @@ +import { axios } from "@pipedream/platform"; + +export default { + type: "app", + app: "tubular", + propDefinitions: { + firstName: { + type: "string", + label: "First Name", + description: "The contact's first name", + }, + lastName: { + type: "string", + label: "Last Name", + description: "The contact's last name", + }, + note: { + type: "string", + label: "Note", + description: "A note about the contact", + }, + lead: { + type: "boolean", + label: "Lead", + description: "Indicates whether the contact is a lead", + }, + }, + methods: { + _baseUrl() { + return "https://api.tubular.io/graphql"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl(), + headers: { + "Authorization": `${this.$auth.api_token}`, + ...headers, + }, + }); + }, + async post(args = {}) { + return this._makeRequest({ + method: "POST", + ...args, + }); + }, + }, +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1fa7a92823dd6..aa743930f5801 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13652,7 +13652,11 @@ importers: components/trustpilot: {} - components/tubular: {} + components/tubular: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/tuesday: {} @@ -15440,14 +15444,6 @@ importers: specifier: ^6.0.0 version: 6.2.0 - modelcontextprotocol/node_modules2/@modelcontextprotocol/sdk/dist/cjs: {} - - modelcontextprotocol/node_modules2/@modelcontextprotocol/sdk/dist/esm: {} - - modelcontextprotocol/node_modules2/zod-to-json-schema/dist/cjs: {} - - modelcontextprotocol/node_modules2/zod-to-json-schema/dist/esm: {} - packages/ai: dependencies: '@pipedream/sdk':