@adobe/spacecat-shared-utils 1.23.7 → 1.24.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.24.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.23.8...@adobe/spacecat-shared-utils-v1.24.0) (2024-12-20)
2
+
3
+
4
+ ### Features
5
+
6
+ * support site metrics overview ([99a7c66](https://github.com/adobe/spacecat-shared/commit/99a7c66f18ff1ba869ffdb07b17b9505d1f00069))
7
+
8
+ # [@adobe/spacecat-shared-utils-v1.23.8](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.23.7...@adobe/spacecat-shared-utils-v1.23.8) (2024-12-14)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update external fixes ([#492](https://github.com/adobe/spacecat-shared/issues/492)) ([d4daba5](https://github.com/adobe/spacecat-shared/commit/d4daba5686c856f9f0029d805fb2b9f1b9baf777))
14
+
1
15
  # [@adobe/spacecat-shared-utils-v1.23.7](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.23.6...@adobe/spacecat-shared-utils-v1.23.7) (2024-12-13)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-utils",
3
- "version": "1.23.7",
3
+ "version": "1.24.0",
4
4
  "description": "Shared modules of the Spacecat Services - utils",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=20.0.0 <23.0.0",
8
- "npm": ">=10.0.0 <11.0.0"
8
+ "npm": ">=10.0.0 <12.0.0"
9
9
  },
10
10
  "main": "src/index.js",
11
11
  "types": "src/index.d.ts",
@@ -45,8 +45,9 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@adobe/fetch": "4.1.11",
48
- "@aws-sdk/client-s3": "3.705.0",
49
- "@aws-sdk/client-sqs": "3.699.0",
48
+ "@aws-sdk/client-s3": "3.712.0",
49
+ "@aws-sdk/client-secrets-manager": "3.699.0",
50
+ "@aws-sdk/client-sqs": "3.712.0",
50
51
  "@json2csv/plainjs": "7.0.6",
51
52
  "aws-xray-sdk": "3.10.2"
52
53
  }
package/src/helpers.js CHANGED
@@ -11,6 +11,7 @@
11
11
  */
12
12
 
13
13
  import { Parser } from '@json2csv/plainjs';
14
+ import { GetSecretValueCommand, SecretsManagerClient } from '@aws-sdk/client-secrets-manager';
14
15
  import { isString } from './functions.js';
15
16
 
16
17
  /**
@@ -53,6 +54,30 @@ export function resolveCustomerSecretsName(baseURL, ctx) {
53
54
  return resolveSecretsName({}, ctx, `${basePath}/${customer}`);
54
55
  }
55
56
 
57
+ /**
58
+ * Retrieves the RUM domain key for the specified base URL from the customer secrets.
59
+ *
60
+ * @param {string} baseURL - The base URL for which the RUM domain key is to be retrieved.
61
+ * @param {UniversalContext} context - Helix Universal Context. See https://github.com/adobe/helix-universal/blob/main/src/adapter.d.ts#L120
62
+ * @returns {Promise<string>} - A promise that resolves to the RUM domain key.
63
+ * @throws {Error} Throws an error if no domain key is found for the specified base URL.
64
+ */
65
+ export async function getRUMDomainKey(baseURL, context) {
66
+ const customerSecretName = resolveCustomerSecretsName(baseURL, context);
67
+ const { runtime } = context;
68
+
69
+ try {
70
+ const client = new SecretsManagerClient({ region: runtime.region });
71
+ const command = new GetSecretValueCommand({
72
+ SecretId: customerSecretName,
73
+ });
74
+ const response = await client.send(command);
75
+ return JSON.parse(response.SecretString)?.RUM_DOMAIN_KEY;
76
+ } catch (error) {
77
+ throw new Error(`Error retrieving the domain key for ${baseURL}. Error: ${error.message}`);
78
+ }
79
+ }
80
+
56
81
  /**
57
82
  * Generates a CSV file from the provided JSON data.
58
83
  *
package/src/index.d.ts CHANGED
@@ -115,6 +115,16 @@ declare function resolveSecretsName(opts: object, ctx: object, defaultPath: stri
115
115
  */
116
116
  declare function resolveCustomerSecretsName(baseURL: string, ctx: object): string;
117
117
 
118
+ /**
119
+ * Retrieves the RUM domain key for the specified base URL from the customer secrets.
120
+ *
121
+ * @param {string} baseURL - The base URL for which the RUM domain key is to be retrieved.
122
+ * @param {object} ctx - Helix Universal Context. See https://github.com/adobe/helix-universal/blob/main/src/adapter.d.ts#L120
123
+ * @returns {Promise<string>} - A promise that resolves to the RUM domain key.
124
+ * @throws {Error} Throws an error if no domain key is found for the specified base URL.
125
+ */
126
+ declare function getRUMDomainKey(baseURL: string, ctx: object): Promise<string>;
127
+
118
128
  /**
119
129
  * Generates a CSV file from the provided JSON data.
120
130
  *
package/src/index.js CHANGED
@@ -32,6 +32,7 @@ export {
32
32
  export {
33
33
  resolveSecretsName,
34
34
  resolveCustomerSecretsName,
35
+ getRUMDomainKey,
35
36
  generateCSVFile,
36
37
  } from './helpers.js';
37
38