@sasjs/adapter 3.10.10 → 3.10.13
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/README.md +2 -1
- package/SASjs.d.ts +2 -1
- package/SASjsApiClient.d.ts +2 -1
- package/index.js +2 -2
- package/job-execution/JobExecutor.d.ts +1 -0
- package/job-execution/Sas9JobExecutor.d.ts +1 -1
- package/job-execution/SasjsJobExecutor.d.ts +9 -0
- package/job-execution/WebJobExecutor.d.ts +0 -2
- package/job-execution/index.d.ts +1 -0
- package/node/SASjs.d.ts +2 -1
- package/node/SASjsApiClient.d.ts +2 -1
- package/node/index.js +2 -2
- package/node/job-execution/JobExecutor.d.ts +1 -0
- package/node/job-execution/Sas9JobExecutor.d.ts +1 -1
- package/node/job-execution/SasjsJobExecutor.d.ts +9 -0
- package/node/job-execution/WebJobExecutor.d.ts +0 -2
- package/node/job-execution/index.d.ts +1 -0
- package/node/request/SasjsRequestClient.d.ts +7 -0
- package/node/types/errors/InvalidSASjsCsrfError.d.ts +3 -0
- package/node/utils/constants.d.ts +1 -0
- package/node/utils/index.d.ts +1 -0
- package/package.json +1 -1
- package/request/SasjsRequestClient.d.ts +7 -0
- package/src/SASjs.ts +15 -3
- package/src/SASjsApiClient.ts +9 -8
- package/src/auth/AuthManager.ts +10 -2
- package/src/job-execution/FileUploader.ts +3 -15
- package/src/job-execution/JobExecutor.ts +14 -1
- package/src/job-execution/Sas9JobExecutor.ts +1 -1
- package/src/job-execution/SasjsJobExecutor.ts +141 -0
- package/src/job-execution/WebJobExecutor.ts +4 -78
- package/src/job-execution/index.ts +1 -0
- package/src/request/RequestClient.ts +17 -25
- package/src/request/SasjsRequestClient.ts +31 -0
- package/src/types/errors/InvalidSASjsCsrfError.ts +9 -0
- package/src/utils/constants.ts +2 -0
- package/src/utils/index.ts +1 -0
- package/types/errors/InvalidSASjsCsrfError.d.ts +3 -0
- package/utils/constants.d.ts +1 -0
- package/utils/index.d.ts +1 -0
- package/node/types/errors/InvalidCsrfError.d.ts +0 -3
- package/src/types/errors/InvalidCsrfError.ts +0 -9
- package/types/errors/InvalidCsrfError.d.ts +0 -3
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { RequestClient } from './RequestClient'
|
|
2
|
+
import { AxiosResponse } from 'axios'
|
|
3
|
+
import { SASJS_LOGS_SEPARATOR, getValidJson } from '../utils'
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Specific request client for SASJS.
|
|
5
7
|
* Append tokens in headers.
|
|
6
8
|
*/
|
|
9
|
+
|
|
7
10
|
export class SasjsRequestClient extends RequestClient {
|
|
8
11
|
getHeaders = (accessToken: string | undefined, contentType: string) => {
|
|
9
12
|
const headers: any = {}
|
|
@@ -20,4 +23,32 @@ export class SasjsRequestClient extends RequestClient {
|
|
|
20
23
|
|
|
21
24
|
return headers
|
|
22
25
|
}
|
|
26
|
+
|
|
27
|
+
protected parseResponse<T>(response: AxiosResponse<any>) {
|
|
28
|
+
const etag = response?.headers ? response.headers['etag'] : ''
|
|
29
|
+
let parsedResponse
|
|
30
|
+
let log
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
if (typeof response.data === 'string') {
|
|
34
|
+
parsedResponse = JSON.parse(response.data)
|
|
35
|
+
} else {
|
|
36
|
+
parsedResponse = response.data
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
if (response.data.includes(SASJS_LOGS_SEPARATOR)) {
|
|
40
|
+
parsedResponse = getValidJson(
|
|
41
|
+
response.data.split(SASJS_LOGS_SEPARATOR)[0]
|
|
42
|
+
)
|
|
43
|
+
log = response.data.split(SASJS_LOGS_SEPARATOR)[1]
|
|
44
|
+
} else parsedResponse = response.data
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
result: parsedResponse as T,
|
|
49
|
+
log,
|
|
50
|
+
etag,
|
|
51
|
+
status: response.status
|
|
52
|
+
}
|
|
53
|
+
}
|
|
23
54
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './appendExtraResponseAttributes'
|
|
|
2
2
|
export * from './asyncForEach'
|
|
3
3
|
export * from './compareTimestamps'
|
|
4
4
|
export * from './convertToCsv'
|
|
5
|
+
export * from './constants'
|
|
5
6
|
export * from './createAxiosInstance'
|
|
6
7
|
export * from './delay'
|
|
7
8
|
export * from './fetchLogByChunks'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SASJS_LOGS_SEPARATOR = "SASJS_LOGS_SEPARATOR_163ee17b6ff24f028928972d80a26784";
|
package/utils/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './appendExtraResponseAttributes';
|
|
|
2
2
|
export * from './asyncForEach';
|
|
3
3
|
export * from './compareTimestamps';
|
|
4
4
|
export * from './convertToCsv';
|
|
5
|
+
export * from './constants';
|
|
5
6
|
export * from './createAxiosInstance';
|
|
6
7
|
export * from './delay';
|
|
7
8
|
export * from './fetchLogByChunks';
|