@sasjs/adapter 3.7.5 → 3.7.8

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
@@ -80,5 +80,5 @@
80
80
  "https": "1.0.0",
81
81
  "tough-cookie": "4.0.0"
82
82
  },
83
- "version": "3.7.5"
83
+ "version": "3.7.8"
84
84
  }
@@ -1,6 +1,5 @@
1
1
  import { SasAuthResponse } from '@sasjs/utils/types'
2
2
  import { prefixMessage } from '@sasjs/utils/error'
3
- import * as NodeFormData from 'form-data'
4
3
  import { RequestClient } from '../request/RequestClient'
5
4
 
6
5
  /**
@@ -24,26 +23,17 @@ export async function getAccessTokenForViya(
24
23
  token = Buffer.from(clientId + ':' + clientSecret).toString('base64')
25
24
  }
26
25
  const headers = {
27
- Authorization: 'Basic ' + token
26
+ Authorization: 'Basic ' + token,
27
+ Accept: 'application/json'
28
28
  }
29
29
 
30
- let formData
31
- if (typeof FormData === 'undefined') {
32
- formData = new NodeFormData()
33
- } else {
34
- formData = new FormData()
35
- }
36
- formData.append('grant_type', 'authorization_code')
37
- formData.append('code', authCode)
30
+ const data = new URLSearchParams({
31
+ grant_type: 'authorization_code',
32
+ code: authCode
33
+ })
38
34
 
39
35
  const authResponse = await requestClient
40
- .post(
41
- url,
42
- formData,
43
- undefined,
44
- 'multipart/form-data; boundary=' + (formData as any)._boundary,
45
- headers
46
- )
36
+ .post(url, data, undefined, 'application/x-www-form-urlencoded', headers)
47
37
  .then((res) => res.result as SasAuthResponse)
48
38
  .catch((err) => {
49
39
  throw prefixMessage(err, 'Error while getting access token. ')
@@ -208,7 +208,7 @@ export class WebJobExecutor extends BaseJobExecutor {
208
208
  }
209
209
 
210
210
  const responseObject = appendExtraResponseAttributes(
211
- { result: jsonResponse },
211
+ { result: jsonResponse, log: parsedSasjsServerLog },
212
212
  extraResponseAttributes
213
213
  )
214
214
  resolve(responseObject)
@@ -635,7 +635,7 @@ const parseError = (data: string) => {
635
635
  if (parts.length > 1) {
636
636
  const storedProcessPath = parts[1].split('<i>')[1].split('</i>')[0]
637
637
  const message = `Stored process not found: ${storedProcessPath}`
638
- return new JobExecutionError(404, message, '')
638
+ return new JobExecutionError(500, message, '')
639
639
  }
640
640
  }
641
641
  } catch (_) {}
@@ -649,7 +649,7 @@ const parseError = (data: string) => {
649
649
  if (parts.length > 1) {
650
650
  const log = parts[1].split('<pre>')[1].split('</pre>')[0]
651
651
  const message = `This request completed with errors.`
652
- return new JobExecutionError(404, message, log)
652
+ return new JobExecutionError(500, message, log)
653
653
  }
654
654
  }
655
655
  } catch (_) {}