@adobe/spacecat-shared-utils 1.14.5 → 1.15.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 +22 -0
- package/package.json +7 -9
- package/src/helpers.js +26 -9
- package/src/index.d.ts +19 -2
- package/src/index.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-utils-v1.15.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.14.6...@adobe/spacecat-shared-utils-v1.15.0) (2024-05-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* convert spacecat-data-access to a regular dependency for utils ([486933c](https://github.com/adobe/spacecat-shared/commit/486933c6a8aeeb3fc5249ad21d92cb8bfedad059))
|
|
7
|
+
* **deps:** update external fixes ([#221](https://github.com/adobe/spacecat-shared/issues/221)) ([13e72c3](https://github.com/adobe/spacecat-shared/commit/13e72c36433dd62058275475acb46a03bd307f91))
|
|
8
|
+
* **deps:** update external fixes ([#225](https://github.com/adobe/spacecat-shared/issues/225)) ([ffb3e3d](https://github.com/adobe/spacecat-shared/commit/ffb3e3d216dd05bafaa7ab26f83ae1c3f0c4d391))
|
|
9
|
+
* **deps:** update external fixes ([#228](https://github.com/adobe/spacecat-shared/issues/228)) ([ef2ab41](https://github.com/adobe/spacecat-shared/commit/ef2ab41a9175ec5ba8ec7e2830898e9db01fb2b6))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* resolve customer secret names ([#229](https://github.com/adobe/spacecat-shared/issues/229)) ([cbf6e1d](https://github.com/adobe/spacecat-shared/commit/cbf6e1db1a2f938a8287b27dd8bde509c1282088))
|
|
15
|
+
|
|
16
|
+
# [@adobe/spacecat-shared-utils-v1.14.6](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.14.5...@adobe/spacecat-shared-utils-v1.14.6) (2024-04-25)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* **deps:** update external fixes ([#215](https://github.com/adobe/spacecat-shared/issues/215)) ([4227263](https://github.com/adobe/spacecat-shared/commit/4227263b6bc917982d361cd621c7001c4ee1fa56))
|
|
22
|
+
|
|
1
23
|
# [@adobe/spacecat-shared-utils-v1.14.5](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.14.4...@adobe/spacecat-shared-utils-v1.14.5) (2024-04-16)
|
|
2
24
|
|
|
3
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/spacecat-shared-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "Shared modules of the Spacecat Services - utils",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -30,21 +30,19 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@adobe/helix-shared-wrap": "2.0.
|
|
33
|
+
"@adobe/helix-shared-wrap": "2.0.2",
|
|
34
34
|
"chai": "4.4.1",
|
|
35
|
-
"chai-as-promised": "7.1.
|
|
35
|
+
"chai-as-promised": "7.1.2",
|
|
36
36
|
"husky": "9.0.11",
|
|
37
37
|
"nock": "13.5.4",
|
|
38
|
-
"sinon": "17.0.
|
|
38
|
+
"sinon": "17.0.2",
|
|
39
39
|
"sinon-chai": "3.7.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@adobe/fetch": "4.1.2",
|
|
43
|
-
"@
|
|
44
|
-
"@aws-sdk/client-
|
|
43
|
+
"@adobe/spacecat-shared-data-access": "^1.2",
|
|
44
|
+
"@aws-sdk/client-s3": "3.574.0",
|
|
45
|
+
"@aws-sdk/client-sqs": "3.574.0",
|
|
45
46
|
"@json2csv/plainjs": "7.0.6"
|
|
46
|
-
},
|
|
47
|
-
"peerDependencies": {
|
|
48
|
-
"@adobe/spacecat-shared-data-access": "1.x"
|
|
49
47
|
}
|
|
50
48
|
}
|
package/src/helpers.js
CHANGED
|
@@ -36,6 +36,23 @@ export function resolveSecretsName(opts, ctx, defaultPath) {
|
|
|
36
36
|
return `${defaultPath}/${funcVersion}`;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Resolves the name of the customer secrets based on the baseURL.
|
|
41
|
+
* @param {string} baseURL - The base URL to resolve the customer secrets name from.
|
|
42
|
+
* @param {Object} ctx - The context object containing the function version.
|
|
43
|
+
* @returns {string} - The resolved secret name.
|
|
44
|
+
*/
|
|
45
|
+
export function resolveCustomerSecretsName(baseURL, ctx) {
|
|
46
|
+
const basePath = '/helix-deploy/spacecat-services/customer-secrets';
|
|
47
|
+
let customer;
|
|
48
|
+
try {
|
|
49
|
+
customer = new URL(baseURL).host.replace(/[^a-zA-Z0-9]/g, '_').toLowerCase();
|
|
50
|
+
} catch (e) {
|
|
51
|
+
throw new Error('Invalid baseURL: must be a valid URL');
|
|
52
|
+
}
|
|
53
|
+
return resolveSecretsName({}, ctx, `${basePath}/${customer}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
39
56
|
export function isAuditsDisabled(site, organization, auditType) {
|
|
40
57
|
// return early if all audits are disabled for the organization
|
|
41
58
|
if (organization.getAuditConfig().auditsDisabled()) {
|
|
@@ -58,15 +75,15 @@ export function isAuditsDisabled(site, organization, auditType) {
|
|
|
58
75
|
}
|
|
59
76
|
|
|
60
77
|
/**
|
|
61
|
-
* Generates a CSV file from the provided JSON data.
|
|
62
|
-
*
|
|
63
|
-
* Each key-value pair in the JSON objects
|
|
64
|
-
* corresponds to a column and its value in the CSV. The output is a UTF-8
|
|
65
|
-
* encoded Buffer that represents the CSV file content.
|
|
66
|
-
*
|
|
67
|
-
* @param {Object[]} data - An array of JSON objects to be converted into CSV format.
|
|
68
|
-
* @returns {Buffer} A Buffer containing the CSV formatted data, encoded in UTF-8.
|
|
69
|
-
*/
|
|
78
|
+
* Generates a CSV file from the provided JSON data.
|
|
79
|
+
*
|
|
80
|
+
* Each key-value pair in the JSON objects
|
|
81
|
+
* corresponds to a column and its value in the CSV. The output is a UTF-8
|
|
82
|
+
* encoded Buffer that represents the CSV file content.
|
|
83
|
+
*
|
|
84
|
+
* @param {Object[]} data - An array of JSON objects to be converted into CSV format.
|
|
85
|
+
* @returns {Buffer} A Buffer containing the CSV formatted data, encoded in UTF-8.
|
|
86
|
+
*/
|
|
70
87
|
export function generateCSVFile(data) {
|
|
71
88
|
const json2csvParser = new Parser();
|
|
72
89
|
return Buffer.from(json2csvParser.parse(data), 'utf-8');
|
package/src/index.d.ts
CHANGED
|
@@ -38,10 +38,10 @@ export function isValidUrl(urlString: string): boolean;
|
|
|
38
38
|
export function dateAfterDays(days: number, dateString: string): Date;
|
|
39
39
|
|
|
40
40
|
export function sqsWrapper(fn: (message: object, context: object) => Promise<Response>):
|
|
41
|
-
|
|
41
|
+
(request: object, context: object) => Promise<Response>;
|
|
42
42
|
|
|
43
43
|
export function sqsEventAdapter(fn: (message: object, context: object) => Promise<Response>):
|
|
44
|
-
|
|
44
|
+
(request: object, context: object) => Promise<Response>;
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Prepends 'https://' schema to the URL if it's not already present.
|
|
@@ -109,6 +109,23 @@ declare function composeAuditURL(url: string): Promise<string>;
|
|
|
109
109
|
*/
|
|
110
110
|
declare function isAuditsDisabled(site: object, organization: object, auditType?: string): boolean
|
|
111
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Resolves the name of the secret based on the function version.
|
|
114
|
+
* @param {Object} opts - The options object, not used in this implementation.
|
|
115
|
+
* @param {Object} ctx - The context object containing the function version.
|
|
116
|
+
* @param {string} defaultPath - The default path for the secret.
|
|
117
|
+
* @returns {string} - The resolved secret name.
|
|
118
|
+
*/
|
|
119
|
+
declare function resolveSecretsName(opts: object, ctx: object, defaultPath: string): string;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Resolves the name of the customer secrets based on the baseURL.
|
|
123
|
+
* @param {string} baseURL - The base URL to resolve the customer secrets name from.
|
|
124
|
+
* @param {Object} ctx - The context object containing the function version.
|
|
125
|
+
* @returns {string} - The resolved secret name.
|
|
126
|
+
*/
|
|
127
|
+
declare function resolveCustomerSecretsName(baseURL: string, ctx: object): string;
|
|
128
|
+
|
|
112
129
|
/**
|
|
113
130
|
* Generates a CSV file from the provided JSON data.
|
|
114
131
|
*
|