From 31c13a786aede8f785ba6869e442204d803ac1f5 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Mon, 30 Dec 2024 11:27:26 -0300 Subject: [PATCH 1/4] callerapi init --- .../get-phone-number-information.mjs | 26 ++++++++++++++ .../get-phone-number-picture.mjs | 26 ++++++++++++++ components/callerapi/callerapi.app.mjs | 36 +++++++++++++++++++ components/callerapi/package.json | 2 +- 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 components/callerapi/actions/get-phone-number-information/get-phone-number-information.mjs create mode 100644 components/callerapi/actions/get-phone-number-picture/get-phone-number-picture.mjs diff --git a/components/callerapi/actions/get-phone-number-information/get-phone-number-information.mjs b/components/callerapi/actions/get-phone-number-information/get-phone-number-information.mjs new file mode 100644 index 0000000000000..3fefee5a80df1 --- /dev/null +++ b/components/callerapi/actions/get-phone-number-information/get-phone-number-information.mjs @@ -0,0 +1,26 @@ +import callerapi from "../../callerapi.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "callerapi-get-phone-number-information", + name: "Get Phone Number Information", + description: "Retrieve detailed information about a specific phone number, including name, location, and carrier. [See the documentation](https://github.com/dimondevceo/caller-id-api)", + version: "0.0.{{ts}}", + type: "action", + props: { + callerapi: { + type: "app", + app: "callerapi", + }, + phoneNumber: { + type: "string", + label: "Phone Number", + description: "The phone number to retrieve information for (E.164 format, e.g., +18006927753)", + }, + }, + async run({ $ }) { + const response = await this.callerapi.getPhoneInfo(this.phoneNumber); + $.export("$summary", `Retrieved information for phone number ${this.phoneNumber}`); + return response; + }, +}; diff --git a/components/callerapi/actions/get-phone-number-picture/get-phone-number-picture.mjs b/components/callerapi/actions/get-phone-number-picture/get-phone-number-picture.mjs new file mode 100644 index 0000000000000..ecc9a72b7996a --- /dev/null +++ b/components/callerapi/actions/get-phone-number-picture/get-phone-number-picture.mjs @@ -0,0 +1,26 @@ +import callerapi from "../../callerapi.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "callerapi-get-phone-number-picture", + name: "Get Phone Number Picture", + description: "Retrieve the profile picture associated with a phone number. [See the documentation]()", + version: "0.0.{{ts}}", + type: "action", + props: { + callerapi: { + type: "app", + app: "callerapi", + }, + phoneNumber: { + type: "string", + label: "Phone Number", + description: "The phone number to retrieve the profile picture for, in E.164 format (e.g., +18006927753)", + }, + }, + async run({ $ }) { + const response = await this.callerapi.getPhonePicture(this.phoneNumber); + $.export("$summary", `Retrieved profile picture for ${this.phoneNumber}`); + return response; + }, +}; diff --git a/components/callerapi/callerapi.app.mjs b/components/callerapi/callerapi.app.mjs index 8fa151ce9331b..2ce8cf1c2e07b 100644 --- a/components/callerapi/callerapi.app.mjs +++ b/components/callerapi/callerapi.app.mjs @@ -1,11 +1,47 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "callerapi", + version: "0.0.1", propDefinitions: {}, methods: { // this.$auth contains connected account data authKeys() { console.log(Object.keys(this.$auth)); }, + _baseUrl() { + return "https://callerapi.com/api"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, method = "GET", path = "/", headers, ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + method, + url: this._baseUrl() + path, + headers: { + ...headers, + "X-Auth": this.$auth.api_key, + }, + }); + }, + async getPhoneInfo(phoneNumber, opts = {}) { + const phone = phoneNumber.replace(/^\+/, ""); + return this._makeRequest({ + method: "GET", + path: `/phone/info/${phone}`, + ...opts, + }); + }, + async getPhonePicture(phoneNumber, opts = {}) { + const phone = phoneNumber.replace(/^\+/, ""); + return this._makeRequest({ + method: "GET", + path: `/phone/pic/${phone}`, + ...opts, + }); + }, }, }; diff --git a/components/callerapi/package.json b/components/callerapi/package.json index 6153acac036ca..58d093c85dce5 100644 --- a/components/callerapi/package.json +++ b/components/callerapi/package.json @@ -12,4 +12,4 @@ "publishConfig": { "access": "public" } -} \ No newline at end of file +} From 127a079c444209de4baa75238a1f7f0df46f087e Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Mon, 30 Dec 2024 12:46:54 -0300 Subject: [PATCH 2/4] [Components] callerapi #14969 Actions - Get Phone Number Information - Get Phone Number Picture --- .../get-phone-number-information.mjs | 22 ++++---- .../get-phone-number-picture.mjs | 37 ++++++++----- components/callerapi/callerapi.app.mjs | 54 ++++++++++--------- components/callerapi/package.json | 5 +- 4 files changed, 68 insertions(+), 50 deletions(-) diff --git a/components/callerapi/actions/get-phone-number-information/get-phone-number-information.mjs b/components/callerapi/actions/get-phone-number-information/get-phone-number-information.mjs index 3fefee5a80df1..d508482bc5d59 100644 --- a/components/callerapi/actions/get-phone-number-information/get-phone-number-information.mjs +++ b/components/callerapi/actions/get-phone-number-information/get-phone-number-information.mjs @@ -1,25 +1,25 @@ import callerapi from "../../callerapi.app.mjs"; -import { axios } from "@pipedream/platform"; export default { key: "callerapi-get-phone-number-information", name: "Get Phone Number Information", - description: "Retrieve detailed information about a specific phone number, including name, location, and carrier. [See the documentation](https://github.com/dimondevceo/caller-id-api)", - version: "0.0.{{ts}}", + description: "Retrieve detailed information about a specific phone number, including name, location, and carrier. [See the documentation](https://callerapi.com/documentation)", + version: "0.0.1", type: "action", props: { - callerapi: { - type: "app", - app: "callerapi", - }, + callerapi, phoneNumber: { - type: "string", - label: "Phone Number", - description: "The phone number to retrieve information for (E.164 format, e.g., +18006927753)", + propDefinition: [ + callerapi, + "phoneNumber", + ], }, }, async run({ $ }) { - const response = await this.callerapi.getPhoneInfo(this.phoneNumber); + const response = await this.callerapi.getPhoneInfo({ + $, + phoneNumber: this.phoneNumber, + }); $.export("$summary", `Retrieved information for phone number ${this.phoneNumber}`); return response; }, diff --git a/components/callerapi/actions/get-phone-number-picture/get-phone-number-picture.mjs b/components/callerapi/actions/get-phone-number-picture/get-phone-number-picture.mjs index ecc9a72b7996a..d46ec5b7c1d9d 100644 --- a/components/callerapi/actions/get-phone-number-picture/get-phone-number-picture.mjs +++ b/components/callerapi/actions/get-phone-number-picture/get-phone-number-picture.mjs @@ -1,26 +1,39 @@ +import { ConfigurationError } from "@pipedream/platform"; +import fs from "fs"; import callerapi from "../../callerapi.app.mjs"; -import { axios } from "@pipedream/platform"; export default { key: "callerapi-get-phone-number-picture", name: "Get Phone Number Picture", - description: "Retrieve the profile picture associated with a phone number. [See the documentation]()", - version: "0.0.{{ts}}", + description: "Retrieve the profile picture associated with a phone number. [See the documentation](https://callerapi.com/documentation)", + version: "0.0.1", type: "action", props: { - callerapi: { - type: "app", - app: "callerapi", - }, + callerapi, phoneNumber: { - type: "string", - label: "Phone Number", + propDefinition: [ + callerapi, + "phoneNumber", + ], description: "The phone number to retrieve the profile picture for, in E.164 format (e.g., +18006927753)", }, }, async run({ $ }) { - const response = await this.callerapi.getPhonePicture(this.phoneNumber); - $.export("$summary", `Retrieved profile picture for ${this.phoneNumber}`); - return response; + try { + const response = await this.callerapi.getPhonePicture({ + $, + phoneNumber: this.phoneNumber, + }); + const fileName = `CallerAPI-Pictgure-${Date.parse(new Date())}.png`; + const buf = Buffer.from(response, "base64"); + fs.writeFileSync(`/tmp/${fileName}`, buf); + + $.export("$summary", `The profile picture for ${this.phoneNumber} has been successfully retrieved and saved to the /tmp directory.`); + return { + path: `/tmp/${fileName}`, + }; + } catch (e) { + throw new ConfigurationError(e?.response?.data || e); + } }, }; diff --git a/components/callerapi/callerapi.app.mjs b/components/callerapi/callerapi.app.mjs index 2ce8cf1c2e07b..4820ef3912edc 100644 --- a/components/callerapi/callerapi.app.mjs +++ b/components/callerapi/callerapi.app.mjs @@ -3,44 +3,46 @@ import { axios } from "@pipedream/platform"; export default { type: "app", app: "callerapi", - version: "0.0.1", - propDefinitions: {}, - methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + propDefinitions: { + phoneNumber: { + type: "string", + label: "Phone Number", + description: "The phone number to retrieve information for (E.164 format, e.g., +18006927753)", }, + }, + methods: { _baseUrl() { - return "https://callerapi.com/api"; + return "https://callerapi.com/api/phone"; + }, + _headers() { + return { + "x-auth": this.$auth.api_key, + }; }, - async _makeRequest(opts = {}) { - const { - $ = this, method = "GET", path = "/", headers, ...otherOpts - } = opts; + _makeRequest({ + $ = this, method, path = "/", ...opts + }) { return axios($, { - ...otherOpts, + ...opts, method, url: this._baseUrl() + path, - headers: { - ...headers, - "X-Auth": this.$auth.api_key, - }, + headers: this._headers(), }); }, - async getPhoneInfo(phoneNumber, opts = {}) { - const phone = phoneNumber.replace(/^\+/, ""); + getPhoneInfo({ + $, phoneNumber, + }) { return this._makeRequest({ - method: "GET", - path: `/phone/info/${phone}`, - ...opts, + $, + path: `/info/${phoneNumber}`, }); }, - async getPhonePicture(phoneNumber, opts = {}) { - const phone = phoneNumber.replace(/^\+/, ""); + getPhonePicture({ + $, phoneNumber, + }) { return this._makeRequest({ - method: "GET", - path: `/phone/pic/${phone}`, - ...opts, + $, + path: `/pic/${phoneNumber}`, }); }, }, diff --git a/components/callerapi/package.json b/components/callerapi/package.json index 58d093c85dce5..8b4dcc7f8f74c 100644 --- a/components/callerapi/package.json +++ b/components/callerapi/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/callerapi", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream CallerAPI Components", "main": "callerapi.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } } From 69dc28cf6410360cc0f0406553bffbef43d7b914 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Mon, 30 Dec 2024 12:50:59 -0300 Subject: [PATCH 3/4] pnpm update --- pnpm-lock.yaml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ba1ffcc7d34fb..f10a8586c8b2a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1334,8 +1334,7 @@ importers: components/braze: {} - components/breathe: - specifiers: {} + components/breathe: {} components/brevo: dependencies: @@ -1504,7 +1503,11 @@ importers: components/call_fire: {} - components/callerapi: {} + components/callerapi: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/callhub: dependencies: @@ -1625,8 +1628,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/change_photos: - specifiers: {} + components/change_photos: {} components/changenow: {} @@ -5395,8 +5397,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/kafka: - specifiers: {} + components/kafka: {} components/kajabi: {} @@ -8945,8 +8946,7 @@ importers: specifier: ^1.4.1 version: 1.6.6 - components/scrapegraphai: - specifiers: {} + components/scrapegraphai: {} components/scrapein_: {} @@ -10235,8 +10235,7 @@ importers: components/taggun: {} - components/taleez: - specifiers: {} + components/taleez: {} components/talend: {} From 0473b05942ae606eb5416389e8f27ee53a11e371 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 2 Jan 2025 11:41:14 -0300 Subject: [PATCH 4/4] pnpm update --- pnpm-lock.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 17168b0438da5..21581c92b5adb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1339,7 +1339,6 @@ importers: components/braze: {} - components/breathe: {} components/breathe: {} components/brevo: @@ -24657,22 +24656,22 @@ packages: superagent@3.8.1: resolution: {integrity: sha512-VMBFLYgFuRdfeNQSMLbxGSLfmXL/xc+OO+BZp41Za/NRDBet/BNbkRJrYzCUu0u4GU0i/ml2dtT8b9qgkw9z6Q==} engines: {node: '>= 4.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@4.1.0: resolution: {integrity: sha512-FT3QLMasz0YyCd4uIi5HNe+3t/onxMyEho7C3PSqmti3Twgy2rXT4fmkTz6wRL6bTF4uzPcfkUCa8u4JWHw8Ag==} engines: {node: '>= 6.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@5.3.1: resolution: {integrity: sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==} engines: {node: '>= 7.0.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@7.1.6: resolution: {integrity: sha512-gZkVCQR1gy/oUXr+kxJMLDjla434KmSOKbx5iGD30Ql+AkJQ/YlPKECJy2nhqOsHLjGHzoDTXNSjhnvWhzKk7g==} engines: {node: '>=6.4.0 <13 || >=14'} - deprecated: Please downgrade to v7.1.5 if you need IE/ActiveXObject support OR upgrade to v8.0.0 as we no longer support IE and published an incorrect patch version (see https://github.com/visionmedia/superagent/issues/1731) + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net supports-color@2.0.0: resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==} @@ -30864,6 +30863,8 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) + transitivePeerDependencies: + - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: