diff --git a/components/ahrefs/actions/get-backlinks-one-per-domain/get-backlinks-one-per-domain.js b/components/ahrefs/actions/get-backlinks-one-per-domain/get-backlinks-one-per-domain.js deleted file mode 100644 index 8042fdf94e651..0000000000000 --- a/components/ahrefs/actions/get-backlinks-one-per-domain/get-backlinks-one-per-domain.js +++ /dev/null @@ -1,45 +0,0 @@ -const ahrefs = require("../../ahrefs.app.js"); -const axios = require("axios"); - -module.exports = { - name: "Get Backlinks One Per Domain", - key: "ahrefs-get-backlinks-one-per-domain", - description: "Get one backlink with the highest `ahrefs_rank` per referring domain for a target URL or domain (with details for the referring pages including anchor and page title).", - version: "0.0.5", - type: "action", - props: { - ahrefs, - target: { - propDefinition: [ - ahrefs, - "target", - ], - }, - mode: { - propDefinition: [ - ahrefs, - "mode", - ], - }, - limit: { - propDefinition: [ - ahrefs, - "limit", - ], - }, - }, - async run() { - return (await axios({ - url: "https://apiv2.ahrefs.com", - params: { - token: this.ahrefs.$auth.oauth_access_token, - from: "backlinks_one_per_domain", - target: this.target, - mode: this.mode, - limit: this.limit, - order_by: "ahrefs_rank:desc", - output: "json", - }, - })).data; - }, -}; diff --git a/components/ahrefs/actions/get-backlinks-one-per-domain/get-backlinks-one-per-domain.mjs b/components/ahrefs/actions/get-backlinks-one-per-domain/get-backlinks-one-per-domain.mjs new file mode 100644 index 0000000000000..dcfd918aaa759 --- /dev/null +++ b/components/ahrefs/actions/get-backlinks-one-per-domain/get-backlinks-one-per-domain.mjs @@ -0,0 +1,55 @@ +import ahrefs from "../../ahrefs.app.mjs"; + +export default { + name: "Get Backlinks One Per Domain", + key: "ahrefs-get-backlinks-one-per-domain", + description: "Get one backlink with the highest `ahrefs_rank` per referring domain for a target URL or domain (with details for the referring pages including anchor and page title). [See the documentation](https://docs.ahrefs.com/docs/api/site-explorer/operations/list-all-backlinks)", + version: "0.0.6", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + ahrefs, + target: { + propDefinition: [ + ahrefs, + "target", + ], + }, + select: { + propDefinition: [ + ahrefs, + "select", + ], + }, + mode: { + propDefinition: [ + ahrefs, + "mode", + ], + }, + limit: { + propDefinition: [ + ahrefs, + "limit", + ], + }, + }, + async run({ $ }) { + const response = await this.ahrefs.getBacklinks({ + $, + params: { + aggregation: "1_per_domain", + target: this.target, + select: this.select.join(","), + mode: this.mode, + limit: this.limit, + }, + }); + $.export("$summary", "Successfully retrieved backlinks data"); + return response; + }, +}; diff --git a/components/ahrefs/actions/get-backlinks/get-backlinks.js b/components/ahrefs/actions/get-backlinks/get-backlinks.js deleted file mode 100644 index 3a532b95225d7..0000000000000 --- a/components/ahrefs/actions/get-backlinks/get-backlinks.js +++ /dev/null @@ -1,45 +0,0 @@ -const ahrefs = require("../../ahrefs.app.js"); -const axios = require("axios"); - -module.exports = { - name: "Get Backlinks", - key: "ahrefs-get-backlinks", - description: "Get the backlinks for a domain or URL with details for the referring pages (e.g., anchor and page title).", - version: "0.0.9", - type: "action", - props: { - ahrefs, - target: { - propDefinition: [ - ahrefs, - "target", - ], - }, - mode: { - propDefinition: [ - ahrefs, - "mode", - ], - }, - limit: { - propDefinition: [ - ahrefs, - "limit", - ], - }, - }, - async run() { - return (await axios({ - url: "https://apiv2.ahrefs.com", - params: { - token: this.ahrefs.$auth.oauth_access_token, - from: "backlinks", - target: this.target, - mode: this.mode, - limit: this.limit, - order_by: "ahrefs_rank:desc", - output: "json", - }, - })).data; - }, -}; diff --git a/components/ahrefs/actions/get-backlinks/get-backlinks.mjs b/components/ahrefs/actions/get-backlinks/get-backlinks.mjs new file mode 100644 index 0000000000000..33f918df3b39f --- /dev/null +++ b/components/ahrefs/actions/get-backlinks/get-backlinks.mjs @@ -0,0 +1,54 @@ +import ahrefs from "../../ahrefs.app.mjs"; + +export default { + name: "Get Backlinks", + key: "ahrefs-get-backlinks", + description: "Get the backlinks for a domain or URL with details for the referring pages (e.g., anchor and page title). [See the documentation](https://docs.ahrefs.com/docs/api/site-explorer/operations/list-all-backlinks)", + version: "0.0.10", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + ahrefs, + target: { + propDefinition: [ + ahrefs, + "target", + ], + }, + select: { + propDefinition: [ + ahrefs, + "select", + ], + }, + mode: { + propDefinition: [ + ahrefs, + "mode", + ], + }, + limit: { + propDefinition: [ + ahrefs, + "limit", + ], + }, + }, + async run({ $ }) { + const response = await this.ahrefs.getBacklinks({ + $, + params: { + target: this.target, + select: this.select.join(","), + mode: this.mode, + limit: this.limit, + }, + }); + $.export("$summary", "Successfully retrieved backlinks data"); + return response; + }, +}; diff --git a/components/ahrefs/actions/get-referring-domains/get-referring-domains.js b/components/ahrefs/actions/get-referring-domains/get-referring-domains.js deleted file mode 100644 index 27243197d07d7..0000000000000 --- a/components/ahrefs/actions/get-referring-domains/get-referring-domains.js +++ /dev/null @@ -1,45 +0,0 @@ -const ahrefs = require("../../ahrefs.app.js"); -const axios = require("axios"); - -module.exports = { - name: "Get Referring Domains", - description: "Get the referring domains that contain backlinks to the target URL or domain.", - key: "ahrefs-get-referring-domains", - version: "0.0.17", - type: "action", - props: { - ahrefs, - target: { - propDefinition: [ - ahrefs, - "target", - ], - }, - mode: { - propDefinition: [ - ahrefs, - "mode", - ], - }, - limit: { - propDefinition: [ - ahrefs, - "limit", - ], - }, - }, - async run() { - return (await axios({ - url: "https://apiv2.ahrefs.com", - params: { - token: this.ahrefs.$auth.oauth_access_token, - from: "refdomains", - target: this.target, - mode: this.mode, - limit: this.limit, - order_by: "domain_rating:desc", - output: "json", - }, - })).data; - }, -}; diff --git a/components/ahrefs/actions/get-referring-domains/get-referring-domains.mjs b/components/ahrefs/actions/get-referring-domains/get-referring-domains.mjs new file mode 100644 index 0000000000000..c3d6a694c6f03 --- /dev/null +++ b/components/ahrefs/actions/get-referring-domains/get-referring-domains.mjs @@ -0,0 +1,55 @@ +import ahrefs from "../../ahrefs.app.mjs"; + +export default { + name: "Get Referring Domains", + description: "Get the referring domains that contain backlinks to the target URL or domain. [See the documentation](https://docs.ahrefs.com/docs/api/site-explorer/operations/list-refdomains)", + key: "ahrefs-get-referring-domains", + version: "0.0.18", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + ahrefs, + target: { + propDefinition: [ + ahrefs, + "target", + ], + }, + select: { + propDefinition: [ + ahrefs, + "select", + ], + description: "An array of columns to return. [See response schema](https://docs.ahrefs.com/docs/api/site-explorer/operations/list-refdomains) for valid column identifiers.", + }, + mode: { + propDefinition: [ + ahrefs, + "mode", + ], + }, + limit: { + propDefinition: [ + ahrefs, + "limit", + ], + }, + }, + async run({ $ }) { + const response = await this.ahrefs.getReferringDomains({ + $, + params: { + target: this.target, + select: this.select.join(","), + mode: this.mode, + limit: this.limit, + }, + }); + $.export("$summary", "Successfully retrieved referring domains data"); + return response; + }, +}; diff --git a/components/ahrefs/ahrefs.app.js b/components/ahrefs/ahrefs.app.js deleted file mode 100644 index a9f592c8b55a8..0000000000000 --- a/components/ahrefs/ahrefs.app.js +++ /dev/null @@ -1,40 +0,0 @@ -module.exports = { - type: "app", - app: "ahrefs", - propDefinitions: { - limit: { - type: "integer", - description: "Number of results to return.", - default: 1000, - optional: true, - }, - mode: { - type: "string", - description: "Select a mode of operation (defaults to `Domain`).", - options: [ - { - label: "Exact", - value: "exact", - }, - { - label: "Domain", - value: "domain", - }, - { - label: "Subdomain", - value: "subdomains", - }, - { - label: "Prefix", - value: "prefix", - }, - ], - default: "domain", - optional: true, - }, - target: { - type: "string", - description: "Enter a domain or URL.", - }, - }, -}; diff --git a/components/ahrefs/ahrefs.app.mjs b/components/ahrefs/ahrefs.app.mjs new file mode 100644 index 0000000000000..4937b9451b522 --- /dev/null +++ b/components/ahrefs/ahrefs.app.mjs @@ -0,0 +1,78 @@ +import { axios } from "@pipedream/platform"; + +export default { + type: "app", + app: "ahrefs", + propDefinitions: { + limit: { + type: "integer", + label: "Limit", + description: "Number of results to return", + default: 1000, + optional: true, + }, + mode: { + type: "string", + label: "Mode", + description: "Select a mode of operation (defaults to `domain`)", + options: [ + { + label: "Exact", + value: "exact", + }, + { + label: "Domain", + value: "domain", + }, + { + label: "Subdomain", + value: "subdomains", + }, + { + label: "Prefix", + value: "prefix", + }, + ], + default: "domain", + optional: true, + }, + target: { + type: "string", + label: "Target", + description: "Enter a domain or URL", + }, + select: { + type: "string[]", + label: "Select", + description: "An array of columns to return. [See response schema](https://docs.ahrefs.com/docs/api/site-explorer/operations/list-all-backlinks) for valid column identifiers.", + }, + }, + methods: { + _baseUrl() { + return "https://api.ahrefs.com/v3"; + }, + _makeRequest({ + $ = this, path, ...opts + }) { + return axios($, { + url: `${this._baseUrl()}${path}`, + headers: { + Authorization: `Bearer ${this.$auth.oauth_access_token}`, + }, + ...opts, + }); + }, + getBacklinks(opts = {}) { + return this._makeRequest({ + path: "/site-explorer/all-backlinks", + ...opts, + }); + }, + getReferringDomains(opts = {}) { + return this._makeRequest({ + path: "/site-explorer/refdomains", + ...opts, + }); + }, + }, +}; diff --git a/components/ahrefs/package.json b/components/ahrefs/package.json index b86a50b48f80d..7f64dee8da0da 100644 --- a/components/ahrefs/package.json +++ b/components/ahrefs/package.json @@ -1,15 +1,17 @@ { "name": "@pipedream/ahrefs", - "version": "0.0.4", + "version": "0.1.0", "description": "Pipedream Ahrefs Components", - "main": "ahrefs.app.js", + "main": "ahrefs.app.mjs", "keywords": [ "pipedream", "ahrefs" ], "homepage": "https://pipedream.com/apps/ahrefs", "author": "Pipedream (https://pipedream.com/)", - "dependencies": {}, + "dependencies": { + "@pipedream/platform": "^3.1.1" + }, "gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535", "publishConfig": { "access": "public" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 48439aaca2aec..d857e252abedd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -564,7 +564,11 @@ importers: specifier: ^3.1.1 version: 3.1.1 - components/ahrefs: {} + components/ahrefs: + dependencies: + '@pipedream/platform': + specifier: ^3.1.1 + version: 3.1.1 components/ai_chatbot_hub: {} @@ -28835,6 +28839,7 @@ packages: node-domexception@1.0.0: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} engines: {node: '>=10.5.0'} + deprecated: Use your platform's native DOMException instead node-emoji@2.2.0: resolution: {integrity: sha512-Z3lTE9pLaJF47NyMhd4ww1yFTAP8YhYI8SleJiHzM46Fgpm5cnNzSl9XfzFNqbaz+VlJrIj3fXQ4DeN1Rjm6cw==} @@ -37153,7 +37158,7 @@ snapshots: https-proxy-agent: 7.0.6 node-fetch: 2.7.0 nopt: 8.1.0 - semver: 7.7.2 + semver: 7.7.3 tar: 7.5.2 transitivePeerDependencies: - encoding @@ -37166,7 +37171,7 @@ snapshots: https-proxy-agent: 7.0.6(supports-color@10.2.2) node-fetch: 2.7.0 nopt: 8.1.0 - semver: 7.7.2 + semver: 7.7.3 tar: 7.5.2 transitivePeerDependencies: - encoding @@ -37452,7 +37457,7 @@ snapshots: image-size: 2.0.2 js-image-generator: 1.0.4 parse-gitignore: 2.0.0 - semver: 7.7.2 + semver: 7.7.3 tmp-promise: 3.0.3 uuid: 11.1.0 write-file-atomic: 5.0.1 @@ -38022,7 +38027,7 @@ snapshots: '@opentelemetry/propagator-b3': 1.30.1(@opentelemetry/api@1.9.0) '@opentelemetry/propagator-jaeger': 1.30.1(@opentelemetry/api@1.9.0) '@opentelemetry/sdk-trace-base': 1.30.1(@opentelemetry/api@1.9.0) - semver: 7.7.2 + semver: 7.7.3 '@opentelemetry/semantic-conventions@1.28.0': {} @@ -38982,7 +38987,6 @@ snapshots: transitivePeerDependencies: - rolldown - rollup - - supports-color '@putout/operator-parens@2.0.0(rolldown@1.0.0-beta.9)(rollup@4.53.2)': dependencies: @@ -48344,7 +48348,7 @@ snapshots: make-dir@4.0.0: dependencies: - semver: 7.7.2 + semver: 7.7.3 make-error@1.3.6: {} @@ -49447,7 +49451,7 @@ snapshots: normalize-package-data@6.0.2: dependencies: hosted-git-info: 7.0.2 - semver: 7.7.2 + semver: 7.7.3 validate-npm-package-license: 3.0.4 normalize-package-data@7.0.1: @@ -49994,7 +49998,7 @@ snapshots: ky: 1.14.0 registry-auth-token: 5.1.0 registry-url: 6.0.1 - semver: 7.7.2 + semver: 7.7.3 package-lock-only@0.0.4: dependencies: @@ -54139,7 +54143,7 @@ snapshots: wide-align@1.1.5: dependencies: - string-width: 1.0.2 + string-width: 4.2.3 optional: true widest-line@3.1.0: