diff --git a/components/whoisfreaks/actions/domain-lookup/domain-lookup.mjs b/components/whoisfreaks/actions/domain-lookup/domain-lookup.mjs new file mode 100644 index 0000000000000..b1ae422b07809 --- /dev/null +++ b/components/whoisfreaks/actions/domain-lookup/domain-lookup.mjs @@ -0,0 +1,45 @@ +import whoisfreaks from "../../whoisfreaks.app.mjs"; + +export default { + key: "whoisfreaks-domain-lookup", + name: "Domain Lookup", + description: "Retrieve details about a domain name. [See the documentation](https://whoisfreaks.com/products/whois-api#live_lookup)", + version: "0.0.1", + type: "action", + props: { + whoisfreaks, + domainName: { + propDefinition: [ + whoisfreaks, + "domainName", + ], + }, + lookupType: { + type: "string", + label: "Lookup Type", + description: "Whether to perform a `live` or `historical` lookup", + options: [ + "live", + "historical", + ], + }, + format: { + propDefinition: [ + whoisfreaks, + "format", + ], + }, + }, + async run({ $ }) { + const response = await this.whoisfreaks.domainLookup({ + $, + params: { + domainName: this.domainName, + whois: this.lookupType, + format: this.format, + }, + }); + $.export("$summary", `Successfully performed lookup for domain ${this.domainName}`); + return response; + }, +}; diff --git a/components/whoisfreaks/actions/ip-lookup/ip-lookup.mjs b/components/whoisfreaks/actions/ip-lookup/ip-lookup.mjs new file mode 100644 index 0000000000000..1ddf8a5d085eb --- /dev/null +++ b/components/whoisfreaks/actions/ip-lookup/ip-lookup.mjs @@ -0,0 +1,34 @@ +import whoisfreaks from "../../whoisfreaks.app.mjs"; + +export default { + key: "whoisfreaks-ip-lookup", + name: "IP Lookup", + description: "Retrieve information about an IP address. [See the documentation](https://whoisfreaks.com/products/whois-api#ip_lookup)", + version: "0.0.1", + type: "action", + props: { + whoisfreaks, + ip: { + type: "string", + label: "IP", + description: "IPv4 or IPv6 address for the requested whois", + }, + format: { + propDefinition: [ + whoisfreaks, + "format", + ], + }, + }, + async run({ $ }) { + const response = await this.whoisfreaks.ipLookup({ + $, + params: { + ip: this.ip, + format: this.format, + }, + }); + $.export("$summary", `Successfully performed lookup for IP ${this.ip}`); + return response; + }, +}; diff --git a/components/whoisfreaks/actions/reverse-lookup/reverse-lookup.mjs b/components/whoisfreaks/actions/reverse-lookup/reverse-lookup.mjs new file mode 100644 index 0000000000000..631b81e25030d --- /dev/null +++ b/components/whoisfreaks/actions/reverse-lookup/reverse-lookup.mjs @@ -0,0 +1,76 @@ +import whoisfreaks from "../../whoisfreaks.app.mjs"; +import { ConfigurationError } from "@pipedream/platform"; + +export default { + key: "whoisfreaks-reverse-lookup", + name: "Reverse Lookup", + description: "Retrieve details about a domain by keyword, email, registrant name or company. [See the documentation](https://whoisfreaks.com/products/whois-api#reverse_lookup)", + version: "0.0.1", + type: "action", + props: { + whoisfreaks, + keyword: { + type: "string", + label: "Keyword", + description: "Keyword search utilizes case-insensitive Pattern Matching search technique to search in our historical database. For example, `whoisfreaks` matches with any keyword that have the searched pattern like `mywhoisfreaks` and `whoisfreakscom`.", + optional: true, + }, + email: { + type: "string", + label: "Email", + description: "Email search uses case-insensitive exact matching technique to search in our historical database. For example, `support@whoisfreaks.com` matches only with `support@whoisfreaks.com`.", + optional: true, + }, + owner: { + type: "string", + label: "Owner", + description: "The owner name for requested whois", + optional: true, + }, + company: { + type: "string", + label: "Company", + description: "Registrant name or Company search use full-text search technique to search in our historical database. For example, `whoisfreaks` matched with `whoisfreaks`, `whoisfreak`, `whois`, `mywhoisfreaks` and `whoisfreakscom`.", + optional: true, + }, + format: { + propDefinition: [ + whoisfreaks, + "format", + ], + }, + page: { + type: "integer", + label: "Page", + description: "For getting next or desired page of whois info. Default: `1`", + default: 1, + optional: true, + }, + }, + async run({ $ }) { + if ([ + this.keyword, + this.email, + this.owner, + this.company, + ].filter((v) => v !== undefined).length !== 1) { + throw new ConfigurationError("Must enter one and only one of `keyword`, `email`, `owner`, or `company`"); + } + + const response = await this.whoisfreaks.domainLookup({ + $, + params: { + keyword: this.keyword, + email: this.email, + owner: this.owner, + company: this.company, + whois: "reverse", + format: this.format, + page: this.page, + }, + }); + + $.export("$summary", "Successfully performed reverse lookup"); + return response; + }, +}; diff --git a/components/whoisfreaks/package.json b/components/whoisfreaks/package.json index bfbc689f8c30f..db1a590a2491b 100644 --- a/components/whoisfreaks/package.json +++ b/components/whoisfreaks/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/whoisfreaks", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream WhoisFreaks Components", "main": "whoisfreaks.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/components/whoisfreaks/whoisfreaks.app.mjs b/components/whoisfreaks/whoisfreaks.app.mjs index e366e8ee49206..14e41129ac779 100644 --- a/components/whoisfreaks/whoisfreaks.app.mjs +++ b/components/whoisfreaks/whoisfreaks.app.mjs @@ -1,11 +1,55 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "whoisfreaks", - propDefinitions: {}, + propDefinitions: { + domainName: { + type: "string", + label: "Domain Name", + description: "The domain name to lookup", + }, + format: { + type: "string", + label: "Format", + description: "Two formats are available JSON, XML. If you don't specify the 'format' parameter, the default format will be JSON.", + options: [ + "JSON", + "XML", + ], + optional: true, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.whoisfreaks.com/v1.0"; + }, + _makeRequest({ + $ = this, + path, + params, + ...opts + }) { + return axios($, { + url: `${this._baseUrl()}${path}`, + params: { + ...params, + apiKey: this.$auth.api_key, + }, + ...opts, + }); + }, + domainLookup(opts = {}) { + return this._makeRequest({ + path: "/whois", + ...opts, + }); + }, + ipLookup(opts = {}) { + return this._makeRequest({ + path: "/ip-whois", + ...opts, + }); }, }, -}; \ No newline at end of file +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 49c273bf6ce0f..9356c43761dcb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -292,8 +292,7 @@ importers: specifier: ^3.0.1 version: 3.0.3 - components/adobe_document_generation_api: - specifiers: {} + components/adobe_document_generation_api: {} components/adobe_pdf_services: dependencies: @@ -10501,8 +10500,7 @@ importers: components/syncro: {} - components/synthflow: - specifiers: {} + components/synthflow: {} components/t2m_url_shortener: {} @@ -11823,7 +11821,11 @@ importers: specifier: ^2.3.0 version: 2.3.0 - components/whoisfreaks: {} + components/whoisfreaks: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/whop: dependencies: