@webitel/ui-sdk 26.4.2 → 26.4.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "26.4.2",
3
+ "version": "26.4.3",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "make-all": "npm version patch --git-tag-version false && npm run build && (npm run build:types || true) && (npm run biome:format:all || true) && npm run publish-lib",
@@ -2,12 +2,40 @@ import { parse } from 'csv-parse/browser/esm';
2
2
 
3
3
  const parseCSV = (csvStr, options = {}) =>
4
4
  new Promise((resolve, reject) => {
5
- const callback = (err, output) => {
6
- if (output) resolve(output, err);
7
- reject(err);
8
- };
5
+ parse(
6
+ csvStr,
7
+ {
8
+ columns: true,
9
+ cast: (value, context) => {
10
+ if (typeof value !== 'string') return value;
9
11
 
10
- parse(csvStr, options, callback);
12
+ const trimmed = value.trim();
13
+
14
+ // boolean
15
+ if (trimmed === 'true') return true;
16
+ if (trimmed === 'false') return false;
17
+
18
+ // array / object (JSON)
19
+ if (
20
+ (trimmed.startsWith('[') && trimmed.endsWith(']')) ||
21
+ (trimmed.startsWith('{') && trimmed.endsWith('}'))
22
+ ) {
23
+ try {
24
+ return JSON.parse(trimmed);
25
+ } catch {
26
+ return value;
27
+ }
28
+ }
29
+
30
+ return value;
31
+ },
32
+ ...options,
33
+ },
34
+ (err, output) => {
35
+ if (err) reject(err);
36
+ else resolve(output);
37
+ },
38
+ );
11
39
  });
12
40
 
13
41
  export default parseCSV;