@sasjs/adapter 3.10.4 → 3.10.5

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.
@@ -5,3 +5,8 @@
5
5
  export declare const convertToCSV: (data: {
6
6
  [key: string]: any;
7
7
  }, tableName: string) => string;
8
+ /**
9
+ * Checks if table is table of formats (table name should start from '$' character).
10
+ * @param tableName - table name.
11
+ */
12
+ export declare const isFormatsTable: (tableName: string) => boolean;
package/package.json CHANGED
@@ -64,7 +64,7 @@
64
64
  "prettier": "2.7.1",
65
65
  "process": "0.11.10",
66
66
  "rimraf": "3.0.2",
67
- "semantic-release": "18.0.0",
67
+ "semantic-release": "19.0.3",
68
68
  "terser-webpack-plugin": "5.3.1",
69
69
  "ts-jest": "27.1.3",
70
70
  "ts-loader": "9.2.6",
@@ -87,5 +87,5 @@
87
87
  "https": "1.0.0",
88
88
  "tough-cookie": "4.0.0"
89
89
  },
90
- "version": "3.10.4"
90
+ "version": "3.10.5"
91
91
  }
@@ -1,5 +1,5 @@
1
1
  import * as NodeFormData from 'form-data'
2
- import { convertToCSV } from '../utils/convertToCsv'
2
+ import { convertToCSV, isFormatsTable } from '../utils/convertToCsv'
3
3
  import { splitChunks } from '../utils/splitChunks'
4
4
 
5
5
  export const generateTableUploadForm = (
@@ -13,7 +13,8 @@ export const generateTableUploadForm = (
13
13
  for (const tableName in data) {
14
14
  tableCounter++
15
15
 
16
- sasjsTables.push(tableName)
16
+ // Formats table should not be sent as part of 'sasjs_tables'
17
+ if (!isFormatsTable(tableName)) sasjsTables.push(tableName)
17
18
 
18
19
  const csv = convertToCSV(data, tableName)
19
20
 
@@ -1,4 +1,5 @@
1
1
  import { isSpecialMissing } from '@sasjs/utils/input/validators'
2
+ import { prefixMessage } from '@sasjs/utils/error'
2
3
 
3
4
  /**
4
5
  * Converts the given JSON object array to a CSV string.
@@ -9,7 +10,10 @@ export const convertToCSV = (
9
10
  tableName: string
10
11
  ) => {
11
12
  if (!data[tableName]) {
12
- throw new Error('No table provided to be converted to CSV')
13
+ throw prefixMessage(
14
+ 'No table provided to be converted to CSV.',
15
+ 'Error while converting to CSV. '
16
+ )
13
17
  }
14
18
 
15
19
  const table = data[tableName]
@@ -170,6 +174,12 @@ export const convertToCSV = (
170
174
  return finalCSV
171
175
  }
172
176
 
177
+ /**
178
+ * Checks if table is table of formats (table name should start from '$' character).
179
+ * @param tableName - table name.
180
+ */
181
+ export const isFormatsTable = (tableName: string) => /^\$.*/.test(tableName)
182
+
173
183
  const getByteSize = (str: string) => {
174
184
  let byteSize = str.length
175
185
  for (let i = str.length - 1; i >= 0; i--) {
@@ -1,4 +1,4 @@
1
- import { convertToCSV } from './convertToCsv'
1
+ import { convertToCSV, isFormatsTable } from './convertToCsv'
2
2
  import { splitChunks } from './splitChunks'
3
3
 
4
4
  export const formatDataForRequest = (data: any) => {
@@ -8,7 +8,7 @@ export const formatDataForRequest = (data: any) => {
8
8
 
9
9
  for (const tableName in data) {
10
10
  if (
11
- tableName.match(/^\$.*/) &&
11
+ isFormatsTable(tableName) &&
12
12
  Object.keys(data).includes(tableName.replace(/^\$/, ''))
13
13
  ) {
14
14
  continue
@@ -16,7 +16,8 @@ export const formatDataForRequest = (data: any) => {
16
16
 
17
17
  tableCounter++
18
18
 
19
- sasjsTables.push(tableName)
19
+ // Formats table should not be sent as part of 'sasjs_tables'
20
+ if (!isFormatsTable(tableName)) sasjsTables.push(tableName)
20
21
 
21
22
  const csv = convertToCSV(data, tableName)
22
23
 
@@ -5,3 +5,8 @@
5
5
  export declare const convertToCSV: (data: {
6
6
  [key: string]: any;
7
7
  }, tableName: string) => string;
8
+ /**
9
+ * Checks if table is table of formats (table name should start from '$' character).
10
+ * @param tableName - table name.
11
+ */
12
+ export declare const isFormatsTable: (tableName: string) => boolean;