@sasjs/adapter 4.1.6 → 4.2.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/index-dev.js +3 -0
- package/index-dev.js.LICENSE.txt +81 -0
- package/index.js +1 -2
- package/minified/sas9/SASjs.d.ts +100 -0
- package/minified/sas9/WebJobExecutor.d.ts +14 -0
- package/minified/sas9/index.d.ts +3 -0
- package/minified_sas9.js +2 -0
- package/minified_sas9.js.LICENSE.txt +15 -0
- package/node/main.js +2 -0
- package/package.json +3 -3
- package/src/SASjs.ts +1 -3
- package/src/minified/sas9/SASjs.ts +273 -0
- package/src/minified/sas9/WebJobExecutor.ts +157 -0
- package/src/minified/sas9/index.ts +3 -0
- package/node/index.js +0 -3
- /package/node/{index.js.LICENSE.txt → main.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { SASjsConfig, UploadFile } from '../../types';
|
|
2
|
+
import { AuthConfig, ExtraResponseAttributes } from '@sasjs/utils/types';
|
|
3
|
+
import { LoginOptions, LoginResult } from '../../types/Login';
|
|
4
|
+
/**
|
|
5
|
+
* SASjs is a JavaScript adapter for SAS.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export default class SASjs {
|
|
9
|
+
private sasjsConfig;
|
|
10
|
+
private jobsPath;
|
|
11
|
+
private fileUploader;
|
|
12
|
+
private authManager;
|
|
13
|
+
private requestClient;
|
|
14
|
+
private webJobExecutor;
|
|
15
|
+
constructor(config?: Partial<SASjsConfig>);
|
|
16
|
+
/**
|
|
17
|
+
* Logs into the SAS server with the supplied credentials.
|
|
18
|
+
* @param username - a string representing the username.
|
|
19
|
+
* @param password - a string representing the password.
|
|
20
|
+
* @param clientId - a string representing the client ID.
|
|
21
|
+
*/
|
|
22
|
+
logIn(username?: string, password?: string, clientId?: string, options?: LoginOptions): Promise<LoginResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Logs out of the configured SAS server.
|
|
25
|
+
*/
|
|
26
|
+
logOut(): Promise<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the current SASjs configuration.
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
getSasjsConfig(): SASjsConfig;
|
|
32
|
+
/**
|
|
33
|
+
* this method returns an array of SASjsRequest
|
|
34
|
+
* @returns SASjsRequest[]
|
|
35
|
+
*/
|
|
36
|
+
getSasRequests(): import("../../types").SASjsRequest[];
|
|
37
|
+
/**
|
|
38
|
+
* Sets the debug state. Turning this on will enable additional logging in the adapter.
|
|
39
|
+
* @param value - boolean indicating debug state (on/off).
|
|
40
|
+
*/
|
|
41
|
+
setDebugState(value: boolean): void;
|
|
42
|
+
/**
|
|
43
|
+
* Uploads a file to the given service.
|
|
44
|
+
* @param sasJob - the path to the SAS program (ultimately resolves to
|
|
45
|
+
* the SAS `_program` parameter to run a Job Definition or SAS 9 Stored
|
|
46
|
+
* Process). Is prepended at runtime with the value of `appLoc`.
|
|
47
|
+
* @param files - array of files to be uploaded, including File object and file name.
|
|
48
|
+
* @param params - request URL parameters.
|
|
49
|
+
* @param config - provide any changes to the config here, for instance to
|
|
50
|
+
* enable/disable `debug`. Any change provided will override the global config,
|
|
51
|
+
* for that particular function call.
|
|
52
|
+
* @param loginRequiredCallback - a function that is called if the
|
|
53
|
+
* user is not logged in (eg to display a login form). The request will be
|
|
54
|
+
* resubmitted after successful login.
|
|
55
|
+
*/
|
|
56
|
+
uploadFile(sasJob: string, files: UploadFile[], params: {
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
} | null, config?: {
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
}, loginRequiredCallback?: () => any): Promise<unknown>;
|
|
61
|
+
/**
|
|
62
|
+
* Makes a request to program specified in `SASjob` (could be a Viya Job, a
|
|
63
|
+
* SAS 9 Stored Process, or a SASjs Server Stored Program). The response
|
|
64
|
+
* object will always contain table names in lowercase, and column names in
|
|
65
|
+
* uppercase. Values are returned formatted by default, unformatted
|
|
66
|
+
* values can be configured as an option in the `%webout` macro.
|
|
67
|
+
*
|
|
68
|
+
* @param sasJob - the path to the SAS program (ultimately resolves to
|
|
69
|
+
* the SAS `_program` parameter to run a Job Definition or SAS 9 Stored
|
|
70
|
+
* Process). Is prepended at runtime with the value of `appLoc`.
|
|
71
|
+
* @param data - a JSON object containing one or more tables to be sent to
|
|
72
|
+
* SAS. For an example of the table structure, see the project README. This
|
|
73
|
+
* value can be `null` if no inputs are required.
|
|
74
|
+
* @param config - provide any changes to the config here, for instance to
|
|
75
|
+
* enable/disable `debug`. Any change provided will override the global config,
|
|
76
|
+
* for that particular function call.
|
|
77
|
+
* @param loginRequiredCallback - a function that is called if the
|
|
78
|
+
* user is not logged in (eg to display a login form). The request will be
|
|
79
|
+
* resubmitted after successful login.
|
|
80
|
+
* When using a `loginRequiredCallback`, the call to the request will look, for example, like so:
|
|
81
|
+
* `await request(sasJobPath, data, config, () => setIsLoggedIn(false))`
|
|
82
|
+
* If you are not passing in any data and configuration, it will look like so:
|
|
83
|
+
* `await request(sasJobPath, {}, {}, () => setIsLoggedIn(false))`
|
|
84
|
+
* @param extraResponseAttributes - a array of predefined values that are used
|
|
85
|
+
* to provide extra attributes (same names as those values) to be added in response
|
|
86
|
+
* Supported values are declared in ExtraResponseAttributes type.
|
|
87
|
+
*/
|
|
88
|
+
request(sasJob: string, data: {
|
|
89
|
+
[key: string]: any;
|
|
90
|
+
} | null, config?: {
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
}, loginRequiredCallback?: () => any, authConfig?: AuthConfig, extraResponseAttributes?: ExtraResponseAttributes[]): Promise<unknown>;
|
|
93
|
+
/**
|
|
94
|
+
* Checks whether a session is active, or login is required.
|
|
95
|
+
* @returns - a promise which resolves with an object containing two values - a boolean `isLoggedIn`, and a string `userName`.
|
|
96
|
+
*/
|
|
97
|
+
checkSession(): Promise<import("../../types/Login").LoginResultInternal>;
|
|
98
|
+
private setupConfiguration;
|
|
99
|
+
private resendWaitingRequests;
|
|
100
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AuthConfig, ExtraResponseAttributes, ServerType } from '@sasjs/utils/types';
|
|
2
|
+
import { RequestClient } from '../../request/RequestClient';
|
|
3
|
+
import { BaseJobExecutor } from '../../job-execution/JobExecutor';
|
|
4
|
+
export interface WaitingRequstPromise {
|
|
5
|
+
promise: Promise<any> | null;
|
|
6
|
+
resolve: any;
|
|
7
|
+
reject: any;
|
|
8
|
+
}
|
|
9
|
+
export declare class WebJobExecutor extends BaseJobExecutor {
|
|
10
|
+
private jobsPath;
|
|
11
|
+
private requestClient;
|
|
12
|
+
constructor(serverUrl: string, serverType: ServerType, jobsPath: string, requestClient: RequestClient);
|
|
13
|
+
execute(sasJob: string, data: any, config: any, loginRequiredCallback?: any, authConfig?: AuthConfig, extraResponseAttributes?: ExtraResponseAttributes[]): Promise<unknown>;
|
|
14
|
+
}
|