@adobe/spacecat-shared-content-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 CHANGED
@@ -1,3 +1,10 @@
1
+ # [@adobe/spacecat-shared-content-client-v1.7.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-content-client-v1.6.20...@adobe/spacecat-shared-content-client-v1.7.0) (2025-05-23)
2
+
3
+
4
+ ### Features
5
+
6
+ * updateImageAltText for content client ([#724](https://github.com/adobe/spacecat-shared/issues/724)) ([b2a5628](https://github.com/adobe/spacecat-shared/commit/b2a56282f8066b9192314c23610a7e0d0abd04e6))
7
+
1
8
  # [@adobe/spacecat-shared-content-client-v1.6.20](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-content-client-v1.6.19...@adobe/spacecat-shared-content-client-v1.6.20) (2025-05-22)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-content-client",
3
- "version": "1.6.20",
3
+ "version": "1.7.0",
4
4
  "description": "Shared modules of the Spacecat Services - Content Client",
5
5
  "type": "module",
6
6
  "engines": {
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@adobe/helix-universal": "5.2.1",
38
- "@adobe/spacecat-helix-content-sdk": "1.4.8",
38
+ "@adobe/spacecat-helix-content-sdk": "1.4.9",
39
39
  "@adobe/spacecat-shared-data-access": "2.0.2",
40
40
  "@adobe/spacecat-shared-utils": "1.38.0",
41
41
  "@aws-sdk/client-secrets-manager": "3.812.0",
@@ -149,6 +149,23 @@ const validateLinks = (links, type) => {
149
149
  }
150
150
  };
151
151
 
152
+ const validateImageAltText = (imageAltText) => {
153
+ if (!Array.isArray(imageAltText)) {
154
+ throw new Error(`${imageAltText} must be an array`);
155
+ }
156
+ for (const item of imageAltText) {
157
+ if (!isObject(item)) {
158
+ throw new Error(`${item} must be an object`);
159
+ }
160
+ if (!item.imageUrl) {
161
+ throw new Error(`No imageUrl found for ${item}`);
162
+ }
163
+ if (!item.altText) {
164
+ throw new Error(`No altText found for ${item}`);
165
+ }
166
+ }
167
+ };
168
+
152
169
  const removeDuplicatedRedirects = (currentRedirects, newRedirects, log) => {
153
170
  const redirectsSet = new Set(
154
171
  currentRedirects.map(({ from, to }) => `${from}:${to}`),
@@ -432,4 +449,25 @@ export default class ContentClient {
432
449
 
433
450
  this.#logDuration('updateBrokenInternalLink', startTime);
434
451
  }
452
+
453
+ async updateImageAltText(path, imageAltText) {
454
+ const startTime = process.hrtime.bigint();
455
+
456
+ validatePath(path);
457
+ validateImageAltText(imageAltText);
458
+ await this.#initClient();
459
+
460
+ this.log.info(`Updating image alt text for ${this.site.getId()} and path ${path}`);
461
+
462
+ const docPath = this.#resolveDocPath(path);
463
+ this.log.info(`Doc path: ${docPath}`);
464
+ const document = await this.rawClient.getDocument(docPath);
465
+ this.log.info(`Document: ${document}`);
466
+ const response = await document.updateImageAltText(imageAltText);
467
+ if (response?.status !== 200) {
468
+ throw new Error(`Failed to update image alt text for path ${path}`);
469
+ }
470
+
471
+ this.#logDuration('updateImageAltText', startTime);
472
+ }
435
473
  }