@adobe/spacecat-shared-utils 1.66.0 → 1.67.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,17 @@
1
+ # [@adobe/spacecat-shared-utils-v1.67.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.66.1...@adobe/spacecat-shared-utils-v1.67.0) (2025-10-29)
2
+
3
+
4
+ ### Features
5
+
6
+ * added a11y-assistive type to extractor ([#1067](https://github.com/adobe/spacecat-shared/issues/1067)) ([79d0326](https://github.com/adobe/spacecat-shared/commit/79d0326fef06341d6243f3979659ccc904f59d14))
7
+
8
+ # [@adobe/spacecat-shared-utils-v1.66.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.66.0...@adobe/spacecat-shared-utils-v1.66.1) (2025-10-28)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * remove cyclic deps in shared ([#1053](https://github.com/adobe/spacecat-shared/issues/1053)) ([acbbc93](https://github.com/adobe/spacecat-shared/commit/acbbc93f8c961fdef55edb5e7947958456538586))
14
+
1
15
  # [@adobe/spacecat-shared-utils-v1.66.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.65.0...@adobe/spacecat-shared-utils-v1.66.0) (2025-10-28)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-utils",
3
- "version": "1.66.0",
3
+ "version": "1.67.0",
4
4
  "description": "Shared modules of the Spacecat Services - utils",
5
5
  "type": "module",
6
6
  "exports": {
@@ -53,9 +53,7 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@adobe/fetch": "4.2.3",
56
- "@adobe/spacecat-shared-ims-client": "1.8.3",
57
56
  "@aws-sdk/client-s3": "3.917.0",
58
- "@aws-sdk/client-secrets-manager": "3.917.0",
59
57
  "@aws-sdk/client-sqs": "3.917.0",
60
58
  "@json2csv/plainjs": "7.0.6",
61
59
  "aws-xray-sdk": "3.11.0",
package/src/index.d.ts CHANGED
@@ -13,6 +13,8 @@
13
13
  import { Request, RequestOptions, Response } from '@adobe/fetch';
14
14
  import type { ISOCalendarWeek } from './calendar-week-helper.js';
15
15
 
16
+ export { AUTHORING_TYPES, DELIVERY_TYPES } from './aem.js';
17
+
16
18
  /** UTILITY FUNCTIONS */
17
19
  export function arrayEquals<T>(a: T[], b: T[]): boolean;
18
20
 
@@ -67,42 +69,42 @@ export function sqsEventAdapter(fn: (message: object, context: object) => Promis
67
69
  * @param url - The URL to modify.
68
70
  * @returns The URL with 'https://' schema prepended.
69
71
  */
70
- declare function prependSchema(url: string): string;
72
+ export declare function prependSchema(url: string): string;
71
73
 
72
74
  /**
73
75
  * Strips the port number from the end of the URL.
74
76
  * @param url - The URL to modify.
75
77
  * @returns The URL with the port removed.
76
78
  */
77
- declare function stripPort(url: string): string;
79
+ export declare function stripPort(url: string): string;
78
80
 
79
81
  /**
80
82
  * Strips the trailing dot from the end of the URL.
81
83
  * @param url - The URL to modify.
82
84
  * @returns The URL with the trailing dot removed.
83
85
  */
84
- declare function stripTrailingDot(url: string): string;
86
+ export declare function stripTrailingDot(url: string): string;
85
87
 
86
88
  /**
87
89
  * Strips the trailing slash from the end of the URL.
88
90
  * @param url - The URL to modify.
89
91
  * @returns The URL with the trailing slash removed.
90
92
  */
91
- declare function stripTrailingSlash(url: string): string;
93
+ export declare function stripTrailingSlash(url: string): string;
92
94
 
93
95
  /**
94
96
  * Strips 'www.' from the beginning of the URL if present.
95
97
  * @param url - The URL to modify.
96
98
  * @returns The URL with 'www.' removed.
97
99
  */
98
- declare function stripWWW(url: string): string;
100
+ export declare function stripWWW(url: string): string;
99
101
 
100
102
  /**
101
103
  * Composes a base URL by applying a series of transformations to the given domain.
102
104
  * @param domain - The domain to compose the base URL from.
103
105
  * @returns The composed base URL.
104
106
  */
105
- declare function composeBaseURL(domain: string): string;
107
+ export declare function composeBaseURL(domain: string): string;
106
108
 
107
109
  /**
108
110
  * Composes an audit URL by applying a series of transformations to the given url.
@@ -110,7 +112,7 @@ declare function composeBaseURL(domain: string): string;
110
112
  * @param {string} [userAgent] - Optional user agent to use in the audit URL.
111
113
  * @returns a promise that resolves the composed audit URL.
112
114
  */
113
- declare function composeAuditURL(url: string, userAgent?: string): Promise<string>;
115
+ export declare function composeAuditURL(url: string, userAgent?: string): Promise<string>;
114
116
 
115
117
  /**
116
118
  * Resolves the name of the secret based on the function version.
@@ -119,7 +121,7 @@ declare function composeAuditURL(url: string, userAgent?: string): Promise<strin
119
121
  * @param {string} defaultPath - The default path for the secret.
120
122
  * @returns {string} - The resolved secret name.
121
123
  */
122
- declare function resolveSecretsName(opts: object, ctx: object, defaultPath: string): string;
124
+ export declare function resolveSecretsName(opts: object, ctx: object, defaultPath: string): string;
123
125
 
124
126
  /**
125
127
  * Resolves the name of the customer secrets based on the baseURL.
@@ -127,7 +129,7 @@ declare function resolveSecretsName(opts: object, ctx: object, defaultPath: stri
127
129
  * @param {Object} ctx - The context object containing the function version.
128
130
  * @returns {string} - The resolved secret name.
129
131
  */
130
- declare function resolveCustomerSecretsName(baseURL: string, ctx: object): string;
132
+ export declare function resolveCustomerSecretsName(baseURL: string, ctx: object): string;
131
133
 
132
134
  /**
133
135
  * Retrieves the RUM domain key for the specified base URL from the customer secrets.
@@ -137,7 +139,7 @@ declare function resolveCustomerSecretsName(baseURL: string, ctx: object): strin
137
139
  * @returns {Promise<string>} - A promise that resolves to the RUM domain key.
138
140
  * @throws {Error} Throws an error if no domain key is found for the specified base URL.
139
141
  */
140
- declare function getRUMDomainKey(baseURL: string, ctx: object): Promise<string>;
142
+ export declare function getRUMDomainKey(baseURL: string, ctx: object): Promise<string>;
141
143
 
142
144
  /**
143
145
  * Generates a CSV file from the provided JSON data.
@@ -149,7 +151,7 @@ declare function getRUMDomainKey(baseURL: string, ctx: object): Promise<string>;
149
151
  * @param {Object[]} data - An array of JSON objects to be converted into CSV format.
150
152
  * @returns {Buffer} A Buffer containing the CSV formatted data, encoded in UTF-8.
151
153
  */
152
- declare function generateCSVFile(data: object[]): Buffer;
154
+ export declare function generateCSVFile(data: object[]): Buffer;
153
155
 
154
156
  /**
155
157
  * Replaces placeholders in the prompt content with their corresponding values.
@@ -158,7 +160,7 @@ declare function generateCSVFile(data: object[]): Buffer;
158
160
  * @param {Object} placeholders - The placeholders and their values.
159
161
  * @returns {string} - The content with placeholders replaced.
160
162
  */
161
- declare function replacePlaceholders(content: string, placeholders: object): string;
163
+ export declare function replacePlaceholders(content: string, placeholders: object): string;
162
164
 
163
165
  /**
164
166
  * Function to support reading static file
@@ -168,7 +170,7 @@ declare function replacePlaceholders(content: string, placeholders: object): str
168
170
  * @param {String} filename - The path of the prompt file.
169
171
  * @returns {Promise<string|null>} - A promise that resolves to a string with the prompt content.
170
172
  */
171
- declare function getStaticContent(placeholders: object, filename: string):
173
+ export declare function getStaticContent(placeholders: object, filename: string):
172
174
  Promise<string | null>;
173
175
 
174
176
  /**
@@ -181,7 +183,7 @@ declare function getStaticContent(placeholders: object, filename: string):
181
183
  * @returns {Promise<string|null>} - A promise that resolves to a string with the prompt content,
182
184
  * or null if an error occurs.
183
185
  */
184
- declare function getPrompt(placeholders: object, filename: string, log: object):
186
+ export declare function getPrompt(placeholders: object, filename: string, log: object):
185
187
  Promise<string | null>;
186
188
 
187
189
  /**
@@ -194,7 +196,7 @@ declare function getPrompt(placeholders: object, filename: string, log: object):
194
196
  * @returns {Promise<string|null>} - A promise that resolves to a string with the query content,
195
197
  * or null if an error occurs.
196
198
  */
197
- declare function getQuery(placeholders: object, filename: string, log: object):
199
+ export declare function getQuery(placeholders: object, filename: string, log: object):
198
200
  Promise<string | null>;
199
201
 
200
202
  /**
@@ -202,7 +204,7 @@ declare function getQuery(placeholders: object, filename: string, log: object):
202
204
  * @param {Object[]} formVitals - An array of form vitals.
203
205
  * @returns {Object[]} - An array of high-form-view-low-form-conversion metrics.
204
206
  */
205
- declare function getHighFormViewsLowConversionMetrics(formVitals: object[]):
207
+ export declare function getHighFormViewsLowConversionMetrics(formVitals: object[]):
206
208
  object[];
207
209
 
208
210
  /**
@@ -210,7 +212,7 @@ declare function getHighFormViewsLowConversionMetrics(formVitals: object[]):
210
212
  * @param {Object[]} formVitals - An array of form vitals.
211
213
  * @returns {Object[]} - An array of high-page-view-low-form-view metrics.
212
214
  */
213
- declare function getHighPageViewsLowFormViewsMetrics(formVitals: object[]):
215
+ export declare function getHighPageViewsLowFormViewsMetrics(formVitals: object[]):
214
216
  object[];
215
217
 
216
218
  /**
@@ -218,7 +220,7 @@ declare function getHighPageViewsLowFormViewsMetrics(formVitals: object[]):
218
220
  * @param {Object[]} formVitals - An array of form vitals.
219
221
  * @returns {Object[]} - An array of high-page-view-low-form-ctr metrics.
220
222
  */
221
- declare function getHighPageViewsLowFormCtrMetrics(formVitals: object[]):
223
+ export declare function getHighPageViewsLowFormCtrMetrics(formVitals: object[]):
222
224
  object[];
223
225
 
224
226
  /**
@@ -262,8 +264,6 @@ export function tracingFetch(url: string | Request, options?: RequestOptions): P
262
264
 
263
265
  export const SPACECAT_USER_AGENT: string;
264
266
 
265
- export function retrievePageAuthentication(site: object, context: object): Promise<string>;
266
-
267
267
  export function prettifyLogForwardingConfig(payload: object): object;
268
268
 
269
269
  export function isoCalendarWeek(date: Date): ISOCalendarWeek;
package/src/index.js CHANGED
@@ -86,8 +86,6 @@ export {
86
86
  FORMS_AUDIT_INTERVAL,
87
87
  } from './formcalc.js';
88
88
 
89
- export { retrievePageAuthentication, getAccessToken } from './auth.js';
90
-
91
89
  export {
92
90
  getDateRanges,
93
91
  getLastNumberOfWeeks,
@@ -41,6 +41,7 @@ function extractUrlsFromSuggestion(opts) {
41
41
  }
42
42
  }
43
43
  break;
44
+ case OPPORTUNITY_TYPES.A11Y_ASSISTIVE:
44
45
  case OPPORTUNITY_TYPES.ACCESSIBILITY:
45
46
  case OPPORTUNITY_TYPES.COLOR_CONTRAST:
46
47
  case OPPORTUNITY_TYPES.STRUCTURED_DATA:
package/src/auth.js DELETED
@@ -1,80 +0,0 @@
1
- /*
2
- * Copyright 2025 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import AWSXray from 'aws-xray-sdk';
14
- import { GetSecretValueCommand, SecretsManagerClient } from '@aws-sdk/client-secrets-manager';
15
- import { ImsPromiseClient } from '@adobe/spacecat-shared-ims-client';
16
- import { isString } from './functions.js';
17
- import { resolveCustomerSecretsName } from './helpers.js';
18
- import { AUTHORING_TYPES, DELIVERY_TYPES } from './aem.js';
19
-
20
- /**
21
- * @import {type Site} from "@adobe/spacecat-shared-data-access/src/models/site/index.js"
22
- */
23
-
24
- /**
25
- * Get an access token by exchanging a promise token using IMS Promise Client.
26
- * @param {object} context - The context object containing environment variables.
27
- * @param {string} promiseToken - The promise token to exchange for an access token.
28
- * @return {Promise<object>} - A promise that resolves to the access token response.
29
- */
30
- export async function getAccessToken(context, promiseToken) {
31
- const imsClient = ImsPromiseClient.createFrom(
32
- context,
33
- ImsPromiseClient.CLIENT_TYPE.CONSUMER,
34
- );
35
-
36
- const token = await imsClient.exchangeToken(
37
- promiseToken,
38
- !!context.env?.AUTOFIX_CRYPT_SECRET && !!context.env?.AUTOFIX_CRYPT_SALT,
39
- );
40
-
41
- return token.access_token;
42
- }
43
-
44
- /**
45
- * Retrieves the page authentication token for a given site.
46
- *
47
- * @param {Site} site - The site to retrieve authentication for
48
- * @param {object} context - The context object
49
- * @param {object} authOptions - The authentication options
50
- * @returns {Promise<string>} - The authentication token or access token
51
- * @throws {Error} - If secret is not found or token is missing
52
- */
53
- export async function retrievePageAuthentication(site, context, authOptions = {}) {
54
- const CS_TYPES = [AUTHORING_TYPES.CS, AUTHORING_TYPES.CS_CW];
55
- if (site
56
- && (CS_TYPES.includes(site.getAuthoringType())
57
- || site.getDeliveryType() === DELIVERY_TYPES.AEM_CS)
58
- && authOptions.promiseToken) {
59
- return getAccessToken(context, authOptions.promiseToken.promise_token);
60
- }
61
-
62
- const baseURL = site.getBaseURL();
63
- const customerSecret = resolveCustomerSecretsName(baseURL, context);
64
- const secretsManagerClient = new SecretsManagerClient({});
65
- const secretsClient = AWSXray.captureAWSv3Client(secretsManagerClient);
66
- const command = new GetSecretValueCommand({ SecretId: customerSecret });
67
-
68
- const response = await secretsClient.send(command);
69
- if (!response.SecretString) {
70
- throw new Error(`No secret string found for ${customerSecret}`);
71
- }
72
-
73
- const secrets = JSON.parse(response.SecretString);
74
-
75
- if (!isString(secrets.PAGE_AUTH_TOKEN)) {
76
- throw new Error(`Missing 'PAGE_AUTH_TOKEN' in secrets for ${customerSecret}`);
77
- }
78
-
79
- return secrets.PAGE_AUTH_TOKEN;
80
- }