@sasjs/adapter 3.0.1 → 3.0.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.
@@ -2,6 +2,7 @@
2
2
  import * as https from 'https';
3
3
  import { ServerType } from '@sasjs/utils/types';
4
4
  import { BaseJobExecutor } from './JobExecutor';
5
+ import { RequestClient } from '../request/RequestClient';
5
6
  /**
6
7
  * Job executor for SAS9 servers for use in Node.js environments.
7
8
  * Initiates login with the provided username and password from the config
@@ -11,10 +12,8 @@ import { BaseJobExecutor } from './JobExecutor';
11
12
  export declare class Sas9JobExecutor extends BaseJobExecutor {
12
13
  private jobsPath;
13
14
  private requestClient;
14
- constructor(serverUrl: string, serverType: ServerType, jobsPath: string, httpsAgentOptions?: https.AgentOptions);
15
- execute(sasJob: string, data: any, config: any): Promise<{
16
- result: unknown;
17
- etag: string;
18
- }>;
15
+ private sas9RequestClient;
16
+ constructor(serverUrl: string, serverType: ServerType, jobsPath: string, requestClient: RequestClient, httpsAgentOptions?: https.AgentOptions);
17
+ execute(sasJob: string, data: any, config: any): Promise<any>;
19
18
  private getRequestParams;
20
19
  }
package/package.json CHANGED
@@ -64,7 +64,7 @@
64
64
  "ts-loader": "^9.2.6",
65
65
  "tslint": "^6.1.3",
66
66
  "tslint-config-prettier": "^1.18.0",
67
- "typedoc": "^0.22.4",
67
+ "typedoc": "0.19.2",
68
68
  "typedoc-neo-theme": "^1.1.1",
69
69
  "typedoc-plugin-external-module-name": "^4.0.6",
70
70
  "typescript": "4.3.5",
@@ -80,5 +80,5 @@
80
80
  "https": "^1.0.0",
81
81
  "tough-cookie": "^4.0.0"
82
82
  },
83
- "version": "3.0.1"
83
+ "version": "3.0.2"
84
84
  }
package/src/SASjs.ts CHANGED
@@ -1044,6 +1044,7 @@ export default class SASjs {
1044
1044
  this.sasjsConfig.serverUrl,
1045
1045
  this.sasjsConfig.serverType!,
1046
1046
  this.jobsPath,
1047
+ this.requestClient,
1047
1048
  this.sasjsConfig.httpsAgentOptions
1048
1049
  )
1049
1050
 
@@ -5,6 +5,7 @@ import { ErrorResponse } from '../types/errors'
5
5
  import { convertToCSV, isRelativePath } from '../utils'
6
6
  import { BaseJobExecutor } from './JobExecutor'
7
7
  import { Sas9RequestClient } from '../request/Sas9RequestClient'
8
+ import { RequestClient } from '../request/RequestClient'
8
9
 
9
10
  /**
10
11
  * Job executor for SAS9 servers for use in Node.js environments.
@@ -13,15 +14,16 @@ import { Sas9RequestClient } from '../request/Sas9RequestClient'
13
14
  * job execution requests.
14
15
  */
15
16
  export class Sas9JobExecutor extends BaseJobExecutor {
16
- private requestClient: Sas9RequestClient
17
+ private sas9RequestClient: Sas9RequestClient
17
18
  constructor(
18
19
  serverUrl: string,
19
20
  serverType: ServerType,
20
21
  private jobsPath: string,
22
+ private requestClient: RequestClient,
21
23
  httpsAgentOptions?: https.AgentOptions
22
24
  ) {
23
25
  super(serverUrl, serverType)
24
- this.requestClient = new Sas9RequestClient(serverUrl, httpsAgentOptions)
26
+ this.sas9RequestClient = new Sas9RequestClient(serverUrl, httpsAgentOptions)
25
27
  }
26
28
 
27
29
  async execute(sasJob: string, data: any, config: any) {
@@ -37,6 +39,8 @@ export class Sas9JobExecutor extends BaseJobExecutor {
37
39
  : ''
38
40
  }`
39
41
 
42
+ apiUrl = `${apiUrl}${config.debug ? '&_debug=131' : ''}`
43
+
40
44
  let requestParams = {
41
45
  ...this.getRequestParams(config)
42
46
  }
@@ -49,6 +53,8 @@ export class Sas9JobExecutor extends BaseJobExecutor {
49
53
  } catch (e: any) {
50
54
  return Promise.reject(new ErrorResponse(e?.message, e))
51
55
  }
56
+ } else {
57
+ data = ''
52
58
  }
53
59
 
54
60
  for (const key in requestParams) {
@@ -57,16 +63,18 @@ export class Sas9JobExecutor extends BaseJobExecutor {
57
63
  }
58
64
  }
59
65
 
60
- await this.requestClient.login(
66
+ await this.sas9RequestClient.login(
61
67
  config.username,
62
68
  config.password,
63
69
  this.jobsPath
64
70
  )
71
+
65
72
  const contentType =
66
73
  data && Object.keys(data).length
67
74
  ? 'multipart/form-data; boundary=' + (formData as any)._boundary
68
75
  : 'text/plain'
69
- return await this.requestClient!.post(
76
+
77
+ return await this.sas9RequestClient!.post(
70
78
  apiUrl,
71
79
  formData,
72
80
  undefined,
@@ -76,6 +84,28 @@ export class Sas9JobExecutor extends BaseJobExecutor {
76
84
  Connection: 'Keep-Alive'
77
85
  }
78
86
  )
87
+ .then((res: any) => {
88
+ let resString = res
89
+
90
+ if (typeof res === 'object') {
91
+ resString = JSON.stringify(res)
92
+ }
93
+
94
+ this.requestClient!.appendRequest(resString, sasJob, config.debug)
95
+
96
+ return res
97
+ })
98
+ .catch((err: any) => {
99
+ let errString = err
100
+
101
+ if (typeof err === 'object') {
102
+ errString = JSON.stringify(errString)
103
+ }
104
+
105
+ this.requestClient!.appendRequest(errString, sasJob, config.debug)
106
+
107
+ return err
108
+ })
79
109
  }
80
110
 
81
111
  private getRequestParams(config: any): any {
package/CHANGELOG.md DELETED
@@ -1,213 +0,0 @@
1
- # Change Log
2
-
3
- Since March 2020 the changelog is managed by github releases - see [https://github.com/sasjs/adapter/releases](https://github.com/sasjs/adapter/releases).
4
-
5
- ## Changes up to 5th March 2020
6
-
7
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
8
-
9
- <a name="1.9.0"></a>
10
- # [1.9.0](https://github.com/macropeople/sasjs/compare/v1.8.0...v1.9.0) (2020-03-05)
11
-
12
-
13
- ### Bug Fixes
14
-
15
- * special chars regex, csv function improvements ([5c8e3fe](https://github.com/macropeople/sasjs/commit/5c8e3fe))
16
- * splitting tests in different files ([95e1d8b](https://github.com/macropeople/sasjs/commit/95e1d8b))
17
- * switching crlfs to lfs in values ([277cf3f](https://github.com/macropeople/sasjs/commit/277cf3f))
18
-
19
-
20
- ### Features
21
-
22
- * fixing tests to fit adapter behaviour ([6146189](https://github.com/macropeople/sasjs/commit/6146189))
23
-
24
-
25
-
26
- <a name="1.8.0"></a>
27
- # [1.8.0](https://github.com/macropeople/sasjs/compare/v1.7.2...v1.8.0) (2020-03-03)
28
-
29
-
30
- ### Bug Fixes
31
-
32
- * parsing error from response ([ff5fa1b](https://github.com/macropeople/sasjs/commit/ff5fa1b))
33
-
34
-
35
- ### Features
36
-
37
- * update SASjs configuration after initializaton ([ee1255c](https://github.com/macropeople/sasjs/commit/ee1255c))
38
-
39
-
40
-
41
- <a name="1.7.2"></a>
42
- ## [1.7.2](https://github.com/macropeople/sasjs/compare/v1.7.1...v1.7.2) (2020-03-02)
43
-
44
-
45
-
46
- <a name="1.7.1"></a>
47
- ## [1.7.1](https://github.com/macropeople/sasjs/compare/v1.7.0...v1.7.1) (2020-03-02)
48
-
49
-
50
- ### Bug Fixes
51
-
52
- * header data types, empty numerics ([c95c9fc](https://github.com/macropeople/sasjs/commit/c95c9fc))
53
-
54
-
55
-
56
- <a name="1.7.0"></a>
57
- # [1.7.0](https://github.com/macropeople/sasjs/compare/v1.6.5...v1.7.0) (2020-03-01)
58
-
59
-
60
- ### Bug Fixes
61
-
62
- * adapter upgrade ([7c221dc](https://github.com/macropeople/sasjs/commit/7c221dc))
63
- * failing test ([12b29b0](https://github.com/macropeople/sasjs/commit/12b29b0))
64
- * retry on redirect only with SAS9 ([69d08e5](https://github.com/macropeople/sasjs/commit/69d08e5))
65
- * test rewrite ([aeb636b](https://github.com/macropeople/sasjs/commit/aeb636b))
66
-
67
-
68
- ### Features
69
-
70
- * tests for sasjs, also bumping cypress version and setting cypress tsconfig to ES6 (we'll be using cypress browsers) ([e8193c1](https://github.com/macropeople/sasjs/commit/e8193c1))
71
- * tests for sasjs, also bumping cypress version and setting cypress tsconfig to ES6 (we'll be using cypress browsers) ([a197344](https://github.com/macropeople/sasjs/commit/a197344))
72
-
73
-
74
-
75
- <a name="1.6.5"></a>
76
- ## [1.6.5](https://github.com/macropeople/sasjs/compare/v1.6.4...v1.6.5) (2020-03-01)
77
-
78
-
79
-
80
- <a name="1.6.4"></a>
81
- ## [1.6.4](https://github.com/macropeople/sasjs/compare/v1.6.3...v1.6.4) (2020-03-01)
82
-
83
-
84
-
85
- <a name="1.6.3"></a>
86
- ## [1.6.3](https://github.com/macropeople/sasjs/compare/v1.6.2...v1.6.3) (2020-02-26)
87
-
88
-
89
- ### Bug Fixes
90
-
91
- * always check session before trying to log in ([6f256ac](https://github.com/macropeople/sasjs/commit/6f256ac))
92
-
93
-
94
-
95
- <a name="1.6.2"></a>
96
- ## [1.6.2](https://github.com/macropeople/sasjs/compare/v1.6.1...v1.6.2) (2020-02-26)
97
-
98
-
99
- ### Bug Fixes
100
-
101
- * SAS9 response fix ([4917d38](https://github.com/macropeople/sasjs/commit/4917d38))
102
-
103
-
104
-
105
- <a name="1.6.1"></a>
106
- ## [1.6.1](https://github.com/macropeople/sasjs/compare/v1.6.0...v1.6.1) (2020-02-23)
107
-
108
-
109
-
110
- <a name="1.6.0"></a>
111
- # [1.6.0](https://github.com/macropeople/sasjs/compare/v1.5.4...v1.6.0) (2020-02-23)
112
-
113
-
114
- ### Features
115
-
116
- * adding sasjs JS file in dist folder ([a4d7e87](https://github.com/macropeople/sasjs/commit/a4d7e87))
117
-
118
-
119
-
120
- <a name="1.5.4"></a>
121
- ## [1.5.4](https://github.com/macropeople/sasjs/compare/v1.5.3...v1.5.4) (2020-02-22)
122
-
123
-
124
- ### Bug Fixes
125
-
126
- * splice log only if there is a log in Viya ([d72a987](https://github.com/macropeople/sasjs/commit/d72a987))
127
-
128
-
129
-
130
- <a name="1.5.3"></a>
131
- ## [1.5.3](https://github.com/macropeople/sasjs/compare/v1.5.2...v1.5.3) (2020-02-22)
132
-
133
-
134
- ### Bug Fixes
135
-
136
- * capturing and parsing program code in Viya, plus replacement of console logs with console errors ([f4d6ac7](https://github.com/macropeople/sasjs/commit/f4d6ac7))
137
-
138
-
139
-
140
- <a name="1.5.2"></a>
141
- ## [1.5.2](https://github.com/macropeople/sasjs/compare/v1.5.1...v1.5.2) (2020-02-22)
142
-
143
-
144
-
145
- <a name="1.5.1"></a>
146
- ## [1.5.1](https://github.com/macropeople/sasjs/compare/v1.5.0...v1.5.1) (2020-02-21)
147
-
148
-
149
- ### Bug Fixes
150
-
151
- * parse code only when log is available ([92fadff](https://github.com/macropeople/sasjs/commit/92fadff))
152
-
153
-
154
-
155
- <a name="1.5.0"></a>
156
- # [1.5.0](https://github.com/macropeople/sasjs/compare/v1.4.2...v1.5.0) (2020-02-21)
157
-
158
-
159
- ### Bug Fixes
160
-
161
- * fetch login form data if not available ([d7e7b2f](https://github.com/macropeople/sasjs/commit/d7e7b2f))
162
- * revert unnecessary change ([34ed2a0](https://github.com/macropeople/sasjs/commit/34ed2a0))
163
-
164
-
165
- ### Features
166
-
167
- * add checkSession API ([dc170fe](https://github.com/macropeople/sasjs/commit/dc170fe))
168
-
169
-
170
-
171
- <a name="1.4.2"></a>
172
- ## [1.4.2](https://github.com/macropeople/sasjs/compare/v1.4.0...v1.4.2) (2020-02-20)
173
-
174
-
175
- ### Bug Fixes
176
-
177
- * premature assignment of loginLink ([0c8a967](https://github.com/macropeople/sasjs/commit/0c8a967))
178
-
179
-
180
-
181
- <a name="1.4.0"></a>
182
- # [1.4.0](https://github.com/macropeople/sasjs/compare/v1.3.0...v1.4.0) (2020-02-20)
183
-
184
-
185
- ### Bug Fixes
186
-
187
- * putting param export in right place ([6372ea2](https://github.com/macropeople/sasjs/commit/6372ea2))
188
-
189
-
190
- ### Features
191
-
192
- * switching from file based upload to params for Viya. Fixes [#13](https://github.com/macropeople/sasjs/issues/13) ([2aeba78](https://github.com/macropeople/sasjs/commit/2aeba78))
193
-
194
-
195
-
196
- <a name="1.3.0"></a>
197
- # 1.3.0 (2020-02-17)
198
-
199
-
200
- ### Bug Fixes
201
-
202
- * closes #issue6 ([efe1510](https://github.com/macropeople/sasjs/commit/efe1510)), closes [#issue6](https://github.com/macropeople/sasjs/issues/issue6)
203
- * add setter for debug state ([10945a6](https://github.com/macropeople/sasjs/commit/10945a6))
204
- * config renaming ([f8ace78](https://github.com/macropeople/sasjs/commit/f8ace78))
205
-
206
-
207
- ### Features
208
-
209
- * adding MIT license ([ef19e2a](https://github.com/macropeople/sasjs/commit/ef19e2a))
210
- * add parsing of source and generated code from response ([892122a](https://github.com/macropeople/sasjs/commit/892122a))
211
- * add support for SAS9 responses ([96c31c8](https://github.com/macropeople/sasjs/commit/96c31c8))
212
- * code of conduct ([cf31ce6](https://github.com/macropeople/sasjs/commit/cf31ce6))
213
- * initial commit ([6957dac](https://github.com/macropeople/sasjs/commit/6957dac))