@adobe/spacecat-shared-ahrefs-client 1.6.21 → 1.7.1

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 CHANGED
@@ -1,3 +1,17 @@
1
+ # [@adobe/spacecat-shared-ahrefs-client-v1.7.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-ahrefs-client-v1.7.0...@adobe/spacecat-shared-ahrefs-client-v1.7.1) (2025-05-31)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update external fixes ([#779](https://github.com/adobe/spacecat-shared/issues/779)) ([07f8cce](https://github.com/adobe/spacecat-shared/commit/07f8cce73e33bfb9c61fe14f2ef28012b872437d))
7
+
8
+ # [@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)
9
+
10
+
11
+ ### Features
12
+
13
+ * 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))
14
+
1
15
  # [@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)
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.6.21",
3
+ "version": "1.7.1",
4
4
  "description": "Shared modules of the Spacecat Services - Ahrefs Client",
5
5
  "type": "module",
6
6
  "engines": {
@@ -41,7 +41,7 @@
41
41
  "devDependencies": {
42
42
  "chai": "5.2.0",
43
43
  "chai-as-promised": "8.0.1",
44
- "nock": "14.0.4",
44
+ "nock": "14.0.5",
45
45
  "sinon": "20.0.0",
46
46
  "sinon-chai": "4.0.0",
47
47
  "typescript": "5.8.3"
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(url: string, country?: string, keywordFilter?: string[],
83
- limit?: number, mode?: string):
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, country = 'us', keywordFilter = [], limit = 10, mode = 'prefix') {
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}`);