@sasjs/adapter 3.10.2 → 3.10.5
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 +18 -12
- package/SASjs.d.ts +1 -4
- package/auth/AuthManager.d.ts +2 -5
- package/index.js +2 -2
- package/node/SASjs.d.ts +1 -4
- package/node/auth/AuthManager.d.ts +2 -5
- package/node/index.js +2 -2
- package/node/utils/convertToCsv.d.ts +5 -0
- package/package.json +7 -6
- package/src/api/viya/executeScript.ts +2 -2
- package/src/api/viya/writeStream.ts +1 -1
- package/src/auth/AuthManager.ts +2 -12
- package/src/file/generateTableUploadForm.ts +3 -2
- package/src/job-execution/WebJobExecutor.ts +17 -9
- package/src/request/RequestClient.ts +5 -5
- package/src/request/Sas9RequestClient.ts +2 -2
- package/src/utils/convertToCsv.ts +11 -1
- package/src/utils/formatDataForRequest.ts +4 -3
- package/src/utils/getValidJson.ts +1 -1
- package/src/utils/parseSasViyaLog.ts +1 -1
- package/src/utils/parseWeboutResponse.ts +1 -1
- package/utils/convertToCsv.d.ts +5 -0
package/README.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
[![npm package][npm-image]][npm-url]
|
|
4
4
|
[![Github Workflow][githubworkflow-image]][githubworkflow-url]
|
|
5
|
-
[![Dependency Status][dependency-image]][dependency-url]
|
|
6
5
|
[]()
|
|
7
6
|

|
|
8
7
|
[](/LICENSE)
|
|
@@ -16,7 +15,6 @@
|
|
|
16
15
|
[githubworkflow-image]:https://github.com/sasjs/adapter/actions/workflows/build.yml/badge.svg
|
|
17
16
|
[githubworkflow-url]:https://github.com/sasjs/adapter/blob/main/.github/workflows/build.yml
|
|
18
17
|
[dependency-image]:https://david-dm.org/sasjs/adapter.svg
|
|
19
|
-
[dependency-url]:https://github.com/sasjs/adapter/blob/main/package.json
|
|
20
18
|
|
|
21
19
|
SASjs is a open-source framework for building Web Apps on SAS® platforms. You can use as much or as little of it as you like. This repository contains the JS adapter, the part that handles the to/from SAS communication on the client side. There are 3 ways to install it:
|
|
22
20
|
|
|
@@ -32,7 +30,7 @@ For more information on building web apps with SAS, check out [sasjs.io](https:/
|
|
|
32
30
|
|
|
33
31
|
## None of this makes sense. How do I build an app with it?
|
|
34
32
|
|
|
35
|
-
Ok ok. Deploy this [example.html](https://raw.githubusercontent.com/sasjs/adapter/master/example.html) file to your web server, and update `servertype` to `SAS9` or `
|
|
33
|
+
Ok ok. Deploy this [example.html](https://raw.githubusercontent.com/sasjs/adapter/master/example.html) file to your web server, and update `servertype` to `SAS9`, `SASVIYA`, or `SASJS` depending on your backend.
|
|
36
34
|
|
|
37
35
|
The backend part can be deployed as follows:
|
|
38
36
|
|
|
@@ -52,7 +50,7 @@ parmcards4;
|
|
|
52
50
|
%webout(OBJ,areas)
|
|
53
51
|
%webout(CLOSE)
|
|
54
52
|
;;;;
|
|
55
|
-
%
|
|
53
|
+
%mx_createwebservice(path=&appLoc/common,name=getdata)
|
|
56
54
|
```
|
|
57
55
|
|
|
58
56
|
You now have a simple web app with a backend service!
|
|
@@ -96,10 +94,10 @@ const sasJs = new SASjs({your config})
|
|
|
96
94
|
More on the config later.
|
|
97
95
|
|
|
98
96
|
### SAS Logon
|
|
99
|
-
All authentication from the adapter is done against SASLogon. There are two approaches that can be taken, which are configured using the `
|
|
97
|
+
All authentication from the adapter is done against SASLogon. There are two approaches that can be taken, which are configured using the `loginMechanism` attribute of the sasJs config object (above):
|
|
100
98
|
|
|
101
|
-
* `
|
|
102
|
-
* `
|
|
99
|
+
* `loginMechanism:'Redirected'` - this approach enables authentication through a SASLogon window, supporting complex authentication flows (such as 2FA) and avoids the need to handle passwords in the application itself. The styling of the window can be modified using CSS.
|
|
100
|
+
* `loginMechanism:'Default'` - this approach requires that the username and password are captured, and used within the `.login()` method. This can be helpful for development, or automated testing.
|
|
103
101
|
|
|
104
102
|
Sample code for logging in with the `Default` approach:
|
|
105
103
|
|
|
@@ -127,7 +125,11 @@ sasJs.request("/path/to/my/service", dataObject)
|
|
|
127
125
|
})
|
|
128
126
|
```
|
|
129
127
|
|
|
130
|
-
We supply the path to the SAS service, and a data object.
|
|
128
|
+
We supply the path to the SAS service, and a data object.
|
|
129
|
+
|
|
130
|
+
If the path starts with a `/` then it should be a full path to the service. If there is no leading `/` then it is relative to the `appLoc`.
|
|
131
|
+
|
|
132
|
+
The data object can be null (for services with no input), or can contain one or more "tables" in the following format:
|
|
131
133
|
|
|
132
134
|
```javascript
|
|
133
135
|
let dataObject={
|
|
@@ -143,7 +145,9 @@ let dataObject={
|
|
|
143
145
|
};
|
|
144
146
|
```
|
|
145
147
|
|
|
146
|
-
|
|
148
|
+
These tables (`tablewith2cols1row` and `tablewith1col2rows`) will be created in SAS WORK after running `%webout(FETCH)` in your SAS service.
|
|
149
|
+
|
|
150
|
+
The `request()` method also has optional parameters such as a config object and a callback login function.
|
|
147
151
|
|
|
148
152
|
The response object will contain returned tables and columns. Table names are always lowercase, and column names uppercase.
|
|
149
153
|
|
|
@@ -221,7 +225,7 @@ The SAS side is handled by a number of macros in the [macro core](https://github
|
|
|
221
225
|
The following snippet shows the process of SAS tables arriving / leaving:
|
|
222
226
|
|
|
223
227
|
```sas
|
|
224
|
-
/*
|
|
228
|
+
/* convert frontend input tables from into SASWORK datasets */
|
|
225
229
|
%webout(FETCH)
|
|
226
230
|
|
|
227
231
|
/* some sas code */
|
|
@@ -250,6 +254,8 @@ Where an entire column is made up of special missing numerics, there would be no
|
|
|
250
254
|
%webout(OBJ,a,missing=STRING,showmeta=YES)
|
|
251
255
|
```
|
|
252
256
|
|
|
257
|
+
The `%webout()` macro itself is just a wrapper for the [mp_jsonout](https://core.sasjs.io/mp__jsonout_8sas.html) macro.
|
|
258
|
+
|
|
253
259
|
## Configuration
|
|
254
260
|
|
|
255
261
|
Configuration on the client side involves passing an object on startup, which can also be passed with each request. Technical documentation on the SASjsConfig class is available [here](https://adapter.sasjs.io/classes/types.sasjsconfig.html). The main config items are:
|
|
@@ -258,7 +264,7 @@ Configuration on the client side involves passing an object on startup, which ca
|
|
|
258
264
|
* `serverType` - either `SAS9`, `SASVIYA` or `SASJS`. The `SASJS` server type is for use with [sasjs/server](https://github.com/sasjs/server).
|
|
259
265
|
* `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.
|
|
260
266
|
* `debug` - if `true` then SAS Logs and extra debug information is returned.
|
|
261
|
-
* `
|
|
267
|
+
* `loginMechanism` - either `Default` or `Redirected`. See [SAS Logon](#sas-logon) section.
|
|
262
268
|
* `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.
|
|
263
269
|
* `contextName` - Compute context on which the requests will be called. If missing or not provided, defaults to `Job Execution Compute context`.
|
|
264
270
|
* `requestHistoryLimit` - Request history limit. Increasing this limit may affect browser performance, especially with debug (logs) enabled. Default is 10.
|
|
@@ -314,7 +320,7 @@ For more information and examples specific to this adapter you can check out the
|
|
|
314
320
|
|
|
315
321
|
For more information on building web apps in general, check out these [resources](https://sasjs.io/training/resources/) or contact the [author](https://www.linkedin.com/in/allanbowe/) directly.
|
|
316
322
|
|
|
317
|
-
|
|
323
|
+
As a SAS customer you can also request a copy of [Data Controller](https://datacontroller.io) - free for up to 5 users, this tool makes use of all parts of the SASjs framework.
|
|
318
324
|
|
|
319
325
|
|
|
320
326
|
## Star Gazing
|
package/SASjs.d.ts
CHANGED
|
@@ -233,10 +233,7 @@ export default class SASjs {
|
|
|
233
233
|
/**
|
|
234
234
|
* Logs out of the configured SAS server.
|
|
235
235
|
*/
|
|
236
|
-
logOut(): Promise<boolean
|
|
237
|
-
result: unknown;
|
|
238
|
-
etag: string;
|
|
239
|
-
}>;
|
|
236
|
+
logOut(): Promise<boolean>;
|
|
240
237
|
/**
|
|
241
238
|
* Uploads a file to the given service.
|
|
242
239
|
* @param sasJob - the path to the SAS program (ultimately resolves to
|
package/auth/AuthManager.d.ts
CHANGED
|
@@ -44,10 +44,7 @@ export declare class AuthManager {
|
|
|
44
44
|
private setLoginUrl;
|
|
45
45
|
/**
|
|
46
46
|
* Logs out of the configured SAS server.
|
|
47
|
-
*
|
|
47
|
+
*
|
|
48
48
|
*/
|
|
49
|
-
logOut(): Promise<boolean
|
|
50
|
-
result: unknown;
|
|
51
|
-
etag: string;
|
|
52
|
-
}>;
|
|
49
|
+
logOut(): Promise<boolean>;
|
|
53
50
|
}
|