@sasjs/adapter 2.11.0 → 2.11.4
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 +9 -7
- package/SASViyaApiClient.d.ts +7 -0
- package/SASjs.d.ts +15 -2
- package/index.js +2 -2
- package/job-execution/FileUploader.d.ts +9 -0
- package/job-execution/JobExecutor.d.ts +0 -7
- package/job-execution/index.d.ts +1 -0
- package/node/SASViyaApiClient.d.ts +7 -0
- package/node/SASjs.d.ts +15 -2
- package/node/index.js +2 -2
- package/node/job-execution/FileUploader.d.ts +9 -0
- package/node/job-execution/JobExecutor.d.ts +0 -7
- package/node/job-execution/index.d.ts +1 -0
- package/node/request/RequestClient.d.ts +20 -0
- package/package.json +6 -6
- package/request/RequestClient.d.ts +20 -0
- package/src/SASViyaApiClient.ts +10 -0
- package/src/SASjs.ts +44 -29
- package/src/job-execution/ComputeJobExecutor.ts +4 -5
- package/src/job-execution/FileUploader.ts +143 -0
- package/src/job-execution/JesJobExecutor.ts +4 -4
- package/src/job-execution/JobExecutor.ts +1 -52
- package/src/job-execution/Sas9JobExecutor.ts +1 -1
- package/src/job-execution/WebJobExecutor.ts +35 -7
- package/src/job-execution/index.ts +1 -0
- package/src/request/RequestClient.ts +95 -20
- package/src/utils/getValidJson.ts +2 -0
- package/src/utils/loginPrompt/index.ts +21 -11
- package/src/utils/parseViyaDebugResponse.ts +1 -1
- package/FileUploader.d.ts +0 -10
- package/node/FileUploader.d.ts +0 -10
- package/src/FileUploader.ts +0 -98
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ Ok ok. Deploy this [example.html](https://raw.githubusercontent.com/sasjs/adapte
|
|
|
36
36
|
|
|
37
37
|
The backend part can be deployed as follows:
|
|
38
38
|
|
|
39
|
-
```
|
|
39
|
+
```sas
|
|
40
40
|
%let appLoc=/Public/app/readme; /* Metadata or Viya Folder per SASjs config */
|
|
41
41
|
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
|
|
42
42
|
%inc mc; /* compile macros (can also be downloaded & compiled seperately) */
|
|
@@ -85,11 +85,11 @@ let sasJs = new SASjs.default(
|
|
|
85
85
|
);
|
|
86
86
|
```
|
|
87
87
|
If you've installed it via NPM, you can import it as a default import like so:
|
|
88
|
-
```
|
|
88
|
+
```js
|
|
89
89
|
import SASjs from '@sasjs/adapter';
|
|
90
90
|
```
|
|
91
91
|
You can then instantiate it with:
|
|
92
|
-
```
|
|
92
|
+
```js
|
|
93
93
|
const sasJs = new SASjs({your config})
|
|
94
94
|
```
|
|
95
95
|
|
|
@@ -119,6 +119,7 @@ sasJs.request("/path/to/my/service", dataObject)
|
|
|
119
119
|
console.log(response.tablewith2cols1row[0].COL1.value)
|
|
120
120
|
})
|
|
121
121
|
```
|
|
122
|
+
|
|
122
123
|
We supply the path to the SAS service, and a data object. The data object can be null (for services with no input), or can contain one or more tables in the following format:
|
|
123
124
|
|
|
124
125
|
```javascript
|
|
@@ -146,6 +147,7 @@ The adapter will also cache the logs (if debug enabled) and even the work tables
|
|
|
146
147
|
The SAS side is handled by a number of macros in the [macro core](https://github.com/sasjs/core) library.
|
|
147
148
|
|
|
148
149
|
The following snippet shows the process of SAS tables arriving / leaving:
|
|
150
|
+
|
|
149
151
|
```sas
|
|
150
152
|
/* fetch all input tables sent from frontend - they arrive as work tables */
|
|
151
153
|
%webout(FETCH)
|
|
@@ -161,7 +163,6 @@ run;
|
|
|
161
163
|
%webout(OBJ,tables,fmt=N) /* unformatted (raw) data */
|
|
162
164
|
%webout(OBJ,tables,label=newtable) /* rename tables on export */
|
|
163
165
|
%webout(CLOSE) /* close the JSON and send some extra useful variables too */
|
|
164
|
-
|
|
165
166
|
```
|
|
166
167
|
|
|
167
168
|
## Configuration
|
|
@@ -172,6 +173,7 @@ Configuration on the client side involves passing an object on startup, which ca
|
|
|
172
173
|
* `serverType` - either `SAS9` or `SASVIYA`.
|
|
173
174
|
* `serverUrl` - the location (including http protocol and port) of the SAS Server. Can be omitted, eg if serving directly from the SAS Web Server, or in streaming mode.
|
|
174
175
|
* `debug` - if `true` then SAS Logs and extra debug information is returned.
|
|
176
|
+
* `LoginMechanism` - either `Default` or `Redirected`. If `Redirected` then authentication occurs through the injection of an additional screen, which contains the SASLogon prompt. This allows for more complex authentication flows (such as 2FA) and avoids the need to handle passwords in the application itself. The styling of the redirect flow can also be modified. If left at "Default" then the developer must capture the username and password and use these with the `.login()` method.
|
|
175
177
|
* `useComputeApi` - Only relevant when the serverType is `SASVIYA`. If `true` the [Compute API](#using-the-compute-api) is used. If `false` the [JES API](#using-the-jes-api) is used. If `null` or `undefined` the [Web](#using-jes-web-app) approach is used.
|
|
176
178
|
* `contextName` - Compute context on which the requests will be called. If missing or not provided, defaults to `Job Execution Compute context`.
|
|
177
179
|
|
|
@@ -196,7 +198,7 @@ Here we are running Jobs using the Job Execution Service except this time we are
|
|
|
196
198
|
|
|
197
199
|
This approach (`useComputeApi: false`) also ensures that jobs are displayed in Environment Manager.
|
|
198
200
|
|
|
199
|
-
```
|
|
201
|
+
```json
|
|
200
202
|
{
|
|
201
203
|
appLoc:"/Your/Path",
|
|
202
204
|
serverType:"SASVIYA",
|
|
@@ -210,12 +212,12 @@ This approach is by far the fastest, as a result of the optimisations we have bu
|
|
|
210
212
|
|
|
211
213
|
With this approach (`useComputeApi: true`), the requests/logs will _not_ appear in the list in Environment manager.
|
|
212
214
|
|
|
213
|
-
```
|
|
215
|
+
```json
|
|
214
216
|
{
|
|
215
217
|
appLoc:"/Your/Path",
|
|
216
218
|
serverType:"SASVIYA",
|
|
217
219
|
useComputeApi: true,
|
|
218
|
-
contextName:
|
|
220
|
+
contextName: "yourComputeContext"
|
|
219
221
|
}
|
|
220
222
|
```
|
|
221
223
|
|
package/SASViyaApiClient.d.ts
CHANGED
|
@@ -16,6 +16,13 @@ export declare class SASViyaApiClient {
|
|
|
16
16
|
private sessionManager;
|
|
17
17
|
private contextManager;
|
|
18
18
|
private folderMap;
|
|
19
|
+
/**
|
|
20
|
+
* A helper method used to call appendRequest method of RequestClient
|
|
21
|
+
* @param response - response from sasjs request
|
|
22
|
+
* @param program - name of program
|
|
23
|
+
* @param debug - a boolean that indicates whether debug was enabled or not
|
|
24
|
+
*/
|
|
25
|
+
appendRequest(response: any, program: string, debug: boolean): void;
|
|
19
26
|
get debug(): boolean;
|
|
20
27
|
set debug(value: boolean);
|
|
21
28
|
/**
|
package/SASjs.d.ts
CHANGED
|
@@ -219,9 +219,18 @@ export default class SASjs {
|
|
|
219
219
|
* Process). Is prepended at runtime with the value of `appLoc`.
|
|
220
220
|
* @param files - array of files to be uploaded, including File object and file name.
|
|
221
221
|
* @param params - request URL parameters.
|
|
222
|
-
* @param
|
|
222
|
+
* @param config - provide any changes to the config here, for instance to
|
|
223
|
+
* enable/disable `debug`. Any change provided will override the global config,
|
|
224
|
+
* for that particular function call.
|
|
225
|
+
* @param loginRequiredCallback - a function that is called if the
|
|
226
|
+
* user is not logged in (eg to display a login form). The request will be
|
|
227
|
+
* resubmitted after successful login.
|
|
223
228
|
*/
|
|
224
|
-
uploadFile(sasJob: string, files: UploadFile[], params:
|
|
229
|
+
uploadFile(sasJob: string, files: UploadFile[], params: {
|
|
230
|
+
[key: string]: any;
|
|
231
|
+
} | null, config?: {
|
|
232
|
+
[key: string]: any;
|
|
233
|
+
}, loginRequiredCallback?: () => any): Promise<unknown>;
|
|
225
234
|
/**
|
|
226
235
|
* Makes a request to the SAS Service specified in `SASjob`. The response
|
|
227
236
|
* object will always contain table names in lowercase, and column names in
|
|
@@ -304,6 +313,10 @@ export default class SASjs {
|
|
|
304
313
|
* @param accessToken - an access token for an authorized user.
|
|
305
314
|
*/
|
|
306
315
|
fetchLogFileContent(logUrl: string, accessToken?: string): Promise<string>;
|
|
316
|
+
/**
|
|
317
|
+
* this method returns an array of SASjsRequest
|
|
318
|
+
* @returns SASjsRequest[]
|
|
319
|
+
*/
|
|
307
320
|
getSasRequests(): import("./types").SASjsRequest[];
|
|
308
321
|
clearSasRequests(): void;
|
|
309
322
|
private setupConfiguration;
|