@adobe/spacecat-shared-ahrefs-client 1.6.20 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +2 -2
- package/src/index.d.ts +9 -7
- package/src/index.js +22 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-ahrefs-client-v1.7.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-ahrefs-client-v1.6.21...@adobe/spacecat-shared-ahrefs-client-v1.7.0) (2025-05-26)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Support fetching only unbranded keywords from ahrefs ([#765](https://github.com/adobe/spacecat-shared/issues/765)) ([1fb300b](https://github.com/adobe/spacecat-shared/commit/1fb300bf22e200a31b03c2df50e18d76ed9d882e))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-ahrefs-client-v1.6.21](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-ahrefs-client-v1.6.20...@adobe/spacecat-shared-ahrefs-client-v1.6.21) (2025-05-26)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update adobe fixes ([#763](https://github.com/adobe/spacecat-shared/issues/763)) ([643b396](https://github.com/adobe/spacecat-shared/commit/643b396130e9144f87099935204927b5522aff68))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-ahrefs-client-v1.6.20](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-ahrefs-client-v1.6.19...@adobe/spacecat-shared-ahrefs-client-v1.6.20) (2025-05-19)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/spacecat-shared-ahrefs-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Shared modules of the Spacecat Services - Ahrefs Client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@adobe/fetch": "4.2.2",
|
|
38
|
-
"@adobe/helix-universal": "5.2.
|
|
38
|
+
"@adobe/helix-universal": "5.2.2",
|
|
39
39
|
"@adobe/spacecat-shared-utils": "1.26.4"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
package/src/index.d.ts
CHANGED
|
@@ -73,13 +73,15 @@ export default class AhrefsAPIClient {
|
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Asynchronous method to get organic keywords.
|
|
76
|
-
* @param url
|
|
77
|
-
* @param country
|
|
78
|
-
* @param keywordFilter
|
|
79
|
-
* @param limit
|
|
80
|
-
* @param mode
|
|
81
76
|
*/
|
|
82
|
-
getOrganicKeywords(
|
|
83
|
-
|
|
77
|
+
getOrganicKeywords(
|
|
78
|
+
url: string,
|
|
79
|
+
options?: {
|
|
80
|
+
country?: string,
|
|
81
|
+
keywordFilter?: string[],
|
|
82
|
+
limit?: number,
|
|
83
|
+
mode?: 'exact' | 'prefix',
|
|
84
|
+
excludeBranded?: boolean,
|
|
85
|
+
}):
|
|
84
86
|
Promise<{ result: object, fullAuditRef: string }>;
|
|
85
87
|
}
|
package/src/index.js
CHANGED
|
@@ -181,7 +181,13 @@ export default class AhrefsAPIClient {
|
|
|
181
181
|
return this.sendRequest('/site-explorer/metrics-history', queryParams);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
async getOrganicKeywords(url,
|
|
184
|
+
async getOrganicKeywords(url, {
|
|
185
|
+
country = 'us',
|
|
186
|
+
keywordFilter = [],
|
|
187
|
+
limit = 10,
|
|
188
|
+
mode = 'prefix',
|
|
189
|
+
excludeBranded = false,
|
|
190
|
+
} = {}) {
|
|
185
191
|
if (!hasText(url)) {
|
|
186
192
|
throw new Error(`Invalid URL: ${url}`);
|
|
187
193
|
}
|
|
@@ -215,11 +221,23 @@ export default class AhrefsAPIClient {
|
|
|
215
221
|
mode,
|
|
216
222
|
output: 'json',
|
|
217
223
|
};
|
|
224
|
+
let where;
|
|
218
225
|
if (keywordFilter.length > 0) {
|
|
226
|
+
where = {
|
|
227
|
+
or: keywordFilter.map((keyword) => ({ field: 'keyword', is: ['iphrase_match', keyword] })),
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
if (excludeBranded) {
|
|
231
|
+
const nonBrandedWhere = { field: 'is_branded', is: ['eq', 0] };
|
|
232
|
+
if (where) {
|
|
233
|
+
where = { and: [nonBrandedWhere, where] };
|
|
234
|
+
} else {
|
|
235
|
+
where = nonBrandedWhere;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (where != null) {
|
|
219
239
|
try {
|
|
220
|
-
queryParams.where = JSON.stringify(
|
|
221
|
-
or: keywordFilter.map((keyword) => ({ field: 'keyword', is: ['iphrase_match', keyword] })),
|
|
222
|
-
});
|
|
240
|
+
queryParams.where = JSON.stringify(where);
|
|
223
241
|
} catch (e) {
|
|
224
242
|
this.log.error(`Error parsing keyword filter: ${e.message}`);
|
|
225
243
|
throw new Error(`Error parsing keyword filter: ${e.message}`);
|