@adobe/spacecat-shared-ahrefs-client 1.6.5 → 1.6.7

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.6.7](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-ahrefs-client-v1.6.6...@adobe/spacecat-shared-ahrefs-client-v1.6.7) (2025-02-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update external fixes ([#603](https://github.com/adobe/spacecat-shared/issues/603)) ([b58d4c7](https://github.com/adobe/spacecat-shared/commit/b58d4c7237fb2522bba9b722e9eed7b0ae9e5f70))
7
+
8
+ # [@adobe/spacecat-shared-ahrefs-client-v1.6.6](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-ahrefs-client-v1.6.5...@adobe/spacecat-shared-ahrefs-client-v1.6.6) (2025-02-12)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **ahrefs-client:** enhance organic keywords query to use in HOTLCTR opportunity ([#589](https://github.com/adobe/spacecat-shared/issues/589)) ([23aef2e](https://github.com/adobe/spacecat-shared/commit/23aef2eef7a2e44b3d68ec8ba64378e8d4a3b605))
14
+
1
15
  # [@adobe/spacecat-shared-ahrefs-client-v1.6.5](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-ahrefs-client-v1.6.4...@adobe/spacecat-shared-ahrefs-client-v1.6.5) (2025-02-08)
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.5",
3
+ "version": "1.6.7",
4
4
  "description": "Shared modules of the Spacecat Services - Ahrefs Client",
5
5
  "type": "module",
6
6
  "engines": {
@@ -39,7 +39,7 @@
39
39
  "@adobe/spacecat-shared-utils": "1.26.4"
40
40
  },
41
41
  "devDependencies": {
42
- "chai": "5.1.2",
42
+ "chai": "5.2.0",
43
43
  "chai-as-promised": "8.0.1",
44
44
  "nock": "14.0.1",
45
45
  "sinon": "19.0.2",
package/src/index.d.ts CHANGED
@@ -73,7 +73,13 @@ 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
76
81
  */
77
- getOrganicKeywords(url: string, country?: string, keywordFilter?: string[], limit?: number):
82
+ getOrganicKeywords(url: string, country?: string, keywordFilter?: string[],
83
+ limit?: number, mode?: string):
78
84
  Promise<{ result: object, fullAuditRef: string }>;
79
85
  }
package/src/index.js CHANGED
@@ -172,7 +172,7 @@ export default class AhrefsAPIClient {
172
172
  return this.sendRequest('/site-explorer/metrics-history', queryParams);
173
173
  }
174
174
 
175
- async getOrganicKeywords(url, country = 'us', keywordFilter = [], limit = 200) {
175
+ async getOrganicKeywords(url, country = 'us', keywordFilter = [], limit = 10, mode = 'prefix') {
176
176
  if (!hasText(url)) {
177
177
  throw new Error(`Invalid URL: ${url}`);
178
178
  }
@@ -185,18 +185,25 @@ export default class AhrefsAPIClient {
185
185
  if (!Number.isInteger(limit) || limit < 1) {
186
186
  throw new Error(`Invalid limit: ${limit}`);
187
187
  }
188
+ if (!['prefix', 'exact'].includes(mode)) {
189
+ throw new Error(`Invalid mode: ${mode}`);
190
+ }
191
+
188
192
  const queryParams = {
189
193
  country,
190
194
  date: new Date().toISOString().split('T')[0],
191
195
  select: [
192
196
  'keyword',
193
197
  'sum_traffic',
194
- 'best_position_url',
198
+ 'volume',
199
+ 'best_position',
200
+ 'cpc',
201
+ 'is_branded',
195
202
  ].join(','),
196
203
  order_by: 'sum_traffic:desc',
197
204
  target: url,
198
- limit: getLimit(limit, 2000),
199
- mode: 'prefix',
205
+ limit: getLimit(limit, 100),
206
+ mode,
200
207
  output: 'json',
201
208
  };
202
209
  if (keywordFilter.length > 0) {