@adobe/spacecat-shared-utils 1.13.2 → 1.14.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,15 @@
1
+ # [@adobe/spacecat-shared-utils-v1.14.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.13.2...@adobe/spacecat-shared-utils-v1.14.0) (2024-03-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update external fixes ([#183](https://github.com/adobe/spacecat-shared/issues/183)) ([0c292e5](https://github.com/adobe/spacecat-shared/commit/0c292e5cff5647e1947f4095ff8f28b3a0155ed6))
7
+
8
+
9
+ ### Features
10
+
11
+ * add json to csv helper function ([#185](https://github.com/adobe/spacecat-shared/issues/185)) ([ebeab43](https://github.com/adobe/spacecat-shared/commit/ebeab436d1964af4daa3d048e3821c30c732b714))
12
+
1
13
  # [@adobe/spacecat-shared-utils-v1.13.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.13.1...@adobe/spacecat-shared-utils-v1.13.2) (2024-03-09)
2
14
 
3
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-utils",
3
- "version": "1.13.2",
3
+ "version": "1.14.0",
4
4
  "description": "Shared modules of the Spacecat Services - utils",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -40,8 +40,9 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@adobe/fetch": "4.1.1",
43
- "@aws-sdk/client-s3": "3.529.1",
44
- "@aws-sdk/client-sqs": "3.529.1"
43
+ "@aws-sdk/client-s3": "3.535.0",
44
+ "@aws-sdk/client-sqs": "3.535.0",
45
+ "@json2csv/plainjs": "7.0.6"
45
46
  },
46
47
  "peerDependencies": {
47
48
  "@adobe/spacecat-shared-data-access": "1.x"
package/src/helpers.js CHANGED
@@ -10,6 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
+ import { Parser } from '@json2csv/plainjs';
13
14
  import { hasText, isString } from './functions.js';
14
15
 
15
16
  /**
@@ -55,3 +56,13 @@ export function isAuditsDisabled(site, organization, auditType) {
55
56
 
56
57
  return false;
57
58
  }
59
+
60
+ /**
61
+ * Generates a CSV file from the provided json data.
62
+ * @param {Array} data - Array of JSON objects to be converted to CSV.
63
+ * @returns {Buffer} - The CSV formatted data as a buffer.
64
+ */
65
+ export function generateCSVFile(data) {
66
+ const json2csvParser = new Parser();
67
+ return Buffer.from(json2csvParser.parse(data), 'utf-8');
68
+ }