@sasjs/adapter 3.10.3 → 3.10.6

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.3"
90
+ "version": "3.10.6"
91
91
  }
@@ -23,7 +23,7 @@ export class AuthManager {
23
23
  ? '/SASLogon/logout?'
24
24
  : this.serverType === ServerType.SasViya
25
25
  ? '/SASLogon/logout.do?'
26
- : '/SASjsApi/auth/logout'
26
+ : '/SASLogon/logout'
27
27
  }
28
28
 
29
29
  /**
@@ -334,19 +334,9 @@ export class AuthManager {
334
334
 
335
335
  /**
336
336
  * Logs out of the configured SAS server.
337
- * @param accessToken - an optional access token is required for SASjs server type.
337
+ *
338
338
  */
339
339
  public async logOut() {
340
- if (this.serverType === ServerType.Sasjs) {
341
- return this.requestClient
342
- .delete(this.logoutUrl)
343
- .catch(() => true)
344
- .finally(() => {
345
- this.requestClient.clearLocalStorageTokens()
346
- return true
347
- })
348
- }
349
-
350
340
  this.requestClient.clearCsrfTokens()
351
341
 
352
342
  return this.requestClient.get(this.logoutUrl, undefined).then(() => true)
@@ -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
 
@@ -703,7 +703,14 @@ const parseError = (data: string) => {
703
703
  } catch (_) {}
704
704
 
705
705
  try {
706
+ // There are some edge cases in which the SAS mp_abort macro
707
+ // (https://core.sasjs.io/mp__abort_8sas.html) is unable to
708
+ // provide a clean exit. In this case the JSON response will
709
+ // be wrapped in >>weboutBEGIN<< and >>weboutEND<< strings.
710
+ // Therefore, if the first string exists, we won't throw an
711
+ // error just yet (the parser may yet throw one instead)
706
712
  const hasError =
713
+ !data?.match(/>>weboutBEGIN<</) &&
707
714
  !!data?.match(/Stored Process Error/i) &&
708
715
  !!data?.match(/This request completed with errors./i)
709
716
  if (hasError) {
@@ -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;