@sasjs/adapter 3.9.1 → 3.9.2
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/index.js +2 -2
- package/node/index.js +2 -2
- package/package.json +2 -2
- package/src/utils/convertToCsv.ts +5 -4
package/package.json
CHANGED
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
},
|
|
73
73
|
"main": "index.js",
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@sasjs/utils": "2.
|
|
75
|
+
"@sasjs/utils": "2.44.0",
|
|
76
76
|
"axios": "0.26.0",
|
|
77
77
|
"axios-cookiejar-support": "1.0.1",
|
|
78
78
|
"form-data": "4.0.0",
|
|
79
79
|
"https": "1.0.0",
|
|
80
80
|
"tough-cookie": "4.0.0"
|
|
81
81
|
},
|
|
82
|
-
"version": "3.9.
|
|
82
|
+
"version": "3.9.2"
|
|
83
83
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isSpecialMissing } from '@sasjs/utils'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Converts the given JSON object array to a CSV string.
|
|
3
5
|
* @param data - the array of JSON objects to convert.
|
|
@@ -18,7 +20,6 @@ export const convertToCSV = (
|
|
|
18
20
|
let headers: string[] = []
|
|
19
21
|
let csvTest
|
|
20
22
|
let invalidString = false
|
|
21
|
-
const specialMissingValueRegExp = /^[a-z_]{1}$/i
|
|
22
23
|
|
|
23
24
|
if (formats) {
|
|
24
25
|
headers = Object.keys(formats).map((key) => `${key}:${formats![key]}`)
|
|
@@ -36,7 +37,7 @@ export const convertToCSV = (
|
|
|
36
37
|
hasNullOrNumber = true
|
|
37
38
|
} else if (
|
|
38
39
|
typeof row[field] === 'string' &&
|
|
39
|
-
|
|
40
|
+
isSpecialMissing(row[field])
|
|
40
41
|
) {
|
|
41
42
|
hasSpecialMissingString = true
|
|
42
43
|
}
|
|
@@ -130,10 +131,10 @@ export const convertToCSV = (
|
|
|
130
131
|
value = currentCell === null ? '' : currentCell
|
|
131
132
|
|
|
132
133
|
if (formats && formats[fieldName] === 'best.') {
|
|
133
|
-
if (value && !
|
|
134
|
+
if (value && !isSpecialMissing(value)) {
|
|
134
135
|
console.log(`🤖[value]🤖`, value)
|
|
135
136
|
throw new Error(
|
|
136
|
-
|
|
137
|
+
`A Special missing value can only be a single character from 'A' to 'Z', '_', '.[a-z]', '._'`
|
|
137
138
|
)
|
|
138
139
|
}
|
|
139
140
|
|