@sasjs/adapter 3.8.5 → 3.9.0
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 +7 -1
- package/SASjsApiClient.d.ts +6 -0
- package/index.js +2 -2
- package/node/SASjs.d.ts +7 -1
- package/node/SASjsApiClient.d.ts +6 -0
- package/node/index.js +2 -2
- package/package.json +1 -1
- package/src/SASjs.ts +12 -1
- package/src/SASjsApiClient.ts +22 -0
package/package.json
CHANGED
package/src/SASjs.ts
CHANGED
|
@@ -77,7 +77,7 @@ export default class SASjs {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
|
-
* Executes code
|
|
80
|
+
* Executes SAS code on a SAS 9 server. Requires a runner to be present in
|
|
81
81
|
* the users home directory in metadata.
|
|
82
82
|
* @param linesOfCode - lines of sas code from the file to run.
|
|
83
83
|
* @param username - a string representing the username.
|
|
@@ -97,6 +97,17 @@ export default class SASjs {
|
|
|
97
97
|
)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Executes SAS code on a SASJS server
|
|
102
|
+
* @param code - a string of code from the file to run.
|
|
103
|
+
* @param authConfig - (optional) a valid client, secret, refresh and access tokens that are authorised to execute scripts.
|
|
104
|
+
*/
|
|
105
|
+
public async executeScriptSASjs(code: string, authConfig?: AuthConfig) {
|
|
106
|
+
this.isMethodSupported('executeScriptSASJS', [ServerType.Sasjs])
|
|
107
|
+
|
|
108
|
+
return await this.sasJSApiClient?.executeScript(code, authConfig)
|
|
109
|
+
}
|
|
110
|
+
|
|
100
111
|
/**
|
|
101
112
|
* Executes sas code in a SAS Viya compute session.
|
|
102
113
|
* @param fileName - name of the file to run. It will be converted to path to the file being submitted for execution.
|
package/src/SASjsApiClient.ts
CHANGED
|
@@ -60,6 +60,28 @@ export class SASjsApiClient {
|
|
|
60
60
|
return Promise.resolve(result)
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Executes code on a SASJS server.
|
|
65
|
+
* @param serverUrl - a server url to execute code.
|
|
66
|
+
* @param code - a string of code to execute.
|
|
67
|
+
*/
|
|
68
|
+
public async executeScript(code: string, authConfig?: AuthConfig) {
|
|
69
|
+
let access_token = (authConfig || {}).access_token
|
|
70
|
+
if (authConfig) {
|
|
71
|
+
;({ access_token } = await getTokens(
|
|
72
|
+
this.requestClient,
|
|
73
|
+
authConfig,
|
|
74
|
+
ServerType.Sasjs
|
|
75
|
+
))
|
|
76
|
+
}
|
|
77
|
+
const response = await this.requestClient.post(
|
|
78
|
+
'SASjsApi/code/execute',
|
|
79
|
+
{ code },
|
|
80
|
+
access_token
|
|
81
|
+
)
|
|
82
|
+
return response.result as string
|
|
83
|
+
}
|
|
84
|
+
|
|
63
85
|
/**
|
|
64
86
|
* Exchanges the auth code for an access token for the given client.
|
|
65
87
|
* @param clientId - the client ID to authenticate with.
|