@sasjs/adapter 3.4.1 → 3.4.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/SASjs.d.ts +11 -12
- package/SASjsApiClient.d.ts +3 -2
- package/api/viya/spec/writeStream.spec.d.ts +1 -1
- package/index.js +2 -2
- package/jest.config.js +1 -1
- package/node/SASjs.d.ts +11 -12
- package/node/SASjsApiClient.d.ts +3 -2
- package/node/index.js +2 -2
- package/node/utils/createAxiosInstance.d.ts +0 -1
- package/package.json +10 -10
- package/src/SASjs.ts +18 -5
- package/src/SASjsApiClient.ts +17 -3
- package/src/api/viya/executeScript.ts +8 -2
- package/src/api/viya/writeStream.ts +5 -9
- package/src/request/Sas9RequestClient.ts +2 -2
- package/src/types/system/global.d.ts +1 -0
- package/tsconfig.json +2 -1
- package/utils/createAxiosInstance.d.ts +0 -1
package/package.json
CHANGED
|
@@ -51,34 +51,34 @@
|
|
|
51
51
|
"cp": "0.2.0",
|
|
52
52
|
"dotenv": "10.0.0",
|
|
53
53
|
"express": "4.17.1",
|
|
54
|
-
"jest": "27.
|
|
55
|
-
"jest-extended": "0.
|
|
54
|
+
"jest": "27.4.7",
|
|
55
|
+
"jest-extended": "2.0.0",
|
|
56
56
|
"node-polyfill-webpack-plugin": "1.1.4",
|
|
57
57
|
"path": "0.12.7",
|
|
58
58
|
"pem": "1.14.4",
|
|
59
59
|
"process": "0.11.10",
|
|
60
60
|
"rimraf": "3.0.2",
|
|
61
61
|
"semantic-release": "18.0.0",
|
|
62
|
-
"terser-webpack-plugin": "5.
|
|
63
|
-
"ts-jest": "27.
|
|
62
|
+
"terser-webpack-plugin": "5.3.0",
|
|
63
|
+
"ts-jest": "27.1.3",
|
|
64
64
|
"ts-loader": "9.2.6",
|
|
65
65
|
"tslint": "6.1.3",
|
|
66
66
|
"tslint-config-prettier": "1.18.0",
|
|
67
|
-
"typedoc": "0.
|
|
67
|
+
"typedoc": "0.22.11",
|
|
68
68
|
"typedoc-neo-theme": "1.1.1",
|
|
69
69
|
"typedoc-plugin-external-module-name": "4.0.6",
|
|
70
|
-
"typescript": "4.
|
|
71
|
-
"webpack": "5.
|
|
70
|
+
"typescript": "4.5.4",
|
|
71
|
+
"webpack": "5.66.0",
|
|
72
72
|
"webpack-cli": "4.7.2"
|
|
73
73
|
},
|
|
74
74
|
"main": "index.js",
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@sasjs/utils": "2.
|
|
76
|
+
"@sasjs/utils": "2.35.0",
|
|
77
77
|
"axios": "0.25.0",
|
|
78
|
-
"axios-cookiejar-support": "
|
|
78
|
+
"axios-cookiejar-support": "2.0.3",
|
|
79
79
|
"form-data": "4.0.0",
|
|
80
80
|
"https": "1.0.0",
|
|
81
81
|
"tough-cookie": "4.0.0"
|
|
82
82
|
},
|
|
83
|
-
"version": "3.4.
|
|
83
|
+
"version": "3.4.2"
|
|
84
84
|
}
|
package/src/SASjs.ts
CHANGED
|
@@ -5,9 +5,8 @@ import {
|
|
|
5
5
|
EditContextInput,
|
|
6
6
|
PollOptions,
|
|
7
7
|
LoginMechanism,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ExecutionQuery
|
|
8
|
+
ExecutionQuery,
|
|
9
|
+
FileTree
|
|
11
10
|
} from './types'
|
|
12
11
|
import { SASViyaApiClient } from './SASViyaApiClient'
|
|
13
12
|
import { SAS9ApiClient } from './SAS9ApiClient'
|
|
@@ -865,8 +864,22 @@ export default class SASjs {
|
|
|
865
864
|
)
|
|
866
865
|
}
|
|
867
866
|
|
|
868
|
-
|
|
869
|
-
|
|
867
|
+
/**
|
|
868
|
+
* Creates the folders and services at the given location `appLoc` on the given server `serverUrl`.
|
|
869
|
+
* @param members - the JSON specifying the folders and services to be created.
|
|
870
|
+
* @param appLoc - the base folder in which to create the new folders and
|
|
871
|
+
* services. If not provided, is taken from SASjsConfig.
|
|
872
|
+
* @param authConfig - a valid client, secret, refresh and access tokens that are authorised to execute compute jobs.
|
|
873
|
+
*/
|
|
874
|
+
public async deployToSASjs(
|
|
875
|
+
members: FileTree,
|
|
876
|
+
appLoc?: string,
|
|
877
|
+
authConfig?: AuthConfig
|
|
878
|
+
) {
|
|
879
|
+
if (!appLoc) {
|
|
880
|
+
appLoc = this.sasjsConfig.appLoc
|
|
881
|
+
}
|
|
882
|
+
return await this.sasJSApiClient?.deploy(members, appLoc, authConfig)
|
|
870
883
|
}
|
|
871
884
|
|
|
872
885
|
public async executeJobSASjs(query: ExecutionQuery) {
|
package/src/SASjsApiClient.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AuthConfig, ServerType } from '@sasjs/utils/types'
|
|
2
|
+
import { FileTree, ExecutionQuery } from './types'
|
|
2
3
|
import { RequestClient } from './request/RequestClient'
|
|
3
4
|
import { getAccessTokenForSasjs } from './auth/getAccessTokenForSasjs'
|
|
4
5
|
import { refreshTokensForSasjs } from './auth/refreshTokensForSasjs'
|
|
5
6
|
import { getAuthCodeForSasjs } from './auth/getAuthCodeForSasjs'
|
|
7
|
+
import { getTokens } from './auth/getTokens'
|
|
6
8
|
|
|
7
9
|
export class SASjsApiClient {
|
|
8
10
|
constructor(
|
|
@@ -14,7 +16,19 @@ export class SASjsApiClient {
|
|
|
14
16
|
if (serverUrl) this.serverUrl = serverUrl
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
public async deploy(
|
|
19
|
+
public async deploy(
|
|
20
|
+
members: FileTree,
|
|
21
|
+
appLoc: string,
|
|
22
|
+
authConfig?: AuthConfig
|
|
23
|
+
) {
|
|
24
|
+
let access_token = (authConfig || {}).access_token
|
|
25
|
+
if (authConfig) {
|
|
26
|
+
;({ access_token } = await getTokens(
|
|
27
|
+
this.requestClient,
|
|
28
|
+
authConfig,
|
|
29
|
+
ServerType.Sasjs
|
|
30
|
+
))
|
|
31
|
+
}
|
|
18
32
|
const { result } = await this.requestClient.post<{
|
|
19
33
|
status: string
|
|
20
34
|
message: string
|
|
@@ -22,7 +36,7 @@ export class SASjsApiClient {
|
|
|
22
36
|
}>(
|
|
23
37
|
'SASjsApi/drive/deploy',
|
|
24
38
|
{ fileTree: members, appLoc: appLoc },
|
|
25
|
-
|
|
39
|
+
access_token
|
|
26
40
|
)
|
|
27
41
|
|
|
28
42
|
return Promise.resolve(result)
|
|
@@ -272,7 +272,13 @@ export async function executeScript(
|
|
|
272
272
|
|
|
273
273
|
return { result: jobResult?.result, log }
|
|
274
274
|
} catch (e) {
|
|
275
|
-
|
|
275
|
+
interface HttpError {
|
|
276
|
+
status: number
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const error = e as HttpError
|
|
280
|
+
|
|
281
|
+
if (error.status === 404) {
|
|
276
282
|
return executeScript(
|
|
277
283
|
requestClient,
|
|
278
284
|
sessionManager,
|
|
@@ -287,7 +293,7 @@ export async function executeScript(
|
|
|
287
293
|
true
|
|
288
294
|
)
|
|
289
295
|
} else {
|
|
290
|
-
throw prefixMessage(e, 'Error while executing script. ')
|
|
296
|
+
throw prefixMessage(e as Error, 'Error while executing script. ')
|
|
291
297
|
}
|
|
292
298
|
}
|
|
293
299
|
}
|
|
@@ -3,13 +3,9 @@ import { WriteStream } from '../../types'
|
|
|
3
3
|
export const writeStream = async (
|
|
4
4
|
stream: WriteStream,
|
|
5
5
|
content: string
|
|
6
|
-
): Promise<void> =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return resolve()
|
|
13
|
-
})
|
|
6
|
+
): Promise<void> =>
|
|
7
|
+
stream.write(content + '\n', (e) => {
|
|
8
|
+
if (e) return Promise.reject(e)
|
|
9
|
+
|
|
10
|
+
return Promise.resolve()
|
|
14
11
|
})
|
|
15
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as https from 'https'
|
|
2
2
|
import { AxiosRequestConfig } from 'axios'
|
|
3
|
-
import axiosCookieJarSupport from 'axios-cookiejar-support'
|
|
3
|
+
import * as axiosCookieJarSupport from 'axios-cookiejar-support'
|
|
4
4
|
import * as tough from 'tough-cookie'
|
|
5
5
|
import { prefixMessage } from '@sasjs/utils/error'
|
|
6
6
|
import { RequestClient, throwIfError } from './RequestClient'
|
|
@@ -17,7 +17,7 @@ export class Sas9RequestClient extends RequestClient {
|
|
|
17
17
|
status >= 200 && status < 303
|
|
18
18
|
|
|
19
19
|
if (axiosCookieJarSupport) {
|
|
20
|
-
axiosCookieJarSupport(this.httpClient)
|
|
20
|
+
axiosCookieJarSupport.wrapper(this.httpClient)
|
|
21
21
|
this.httpClient.defaults.jar = new tough.CookieJar()
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'jest-extended'
|
package/tsconfig.json
CHANGED