@sasjs/adapter 4.7.0 → 4.8.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.
@@ -40,7 +40,7 @@ export declare class RequestClient implements HttpClient {
40
40
  protected csrfToken: CsrfToken;
41
41
  protected fileUploadCsrfToken: CsrfToken | undefined;
42
42
  protected httpClient: AxiosInstance;
43
- constructor(baseUrl: string, httpsAgentOptions?: https.AgentOptions, requestsLimit?: number);
43
+ constructor(baseUrl: string, httpsAgentOptions?: https.AgentOptions, requestsLimit?: number, verboseMode?: boolean);
44
44
  setConfig(baseUrl: string, httpsAgentOptions?: https.AgentOptions): void;
45
45
  saveLocalStorageToken(accessToken: string, refreshToken: string): void;
46
46
  getCsrfToken(type?: 'general' | 'file'): CsrfToken | undefined;
@@ -45,6 +45,10 @@ export declare class SASjsConfig {
45
45
  * Set to `true` to enable additional debugging.
46
46
  */
47
47
  debug: boolean;
48
+ /**
49
+ * Set to `true` to enable verbose mode that will log a summary of every HTTP response.
50
+ */
51
+ verbose?: boolean;
48
52
  /**
49
53
  * The name of the compute context to use when calling the Viya services directly.
50
54
  * Example value: 'SAS Job Execution compute context'
package/package.json CHANGED
@@ -84,5 +84,5 @@
84
84
  "https": "1.0.0",
85
85
  "tough-cookie": "4.1.3"
86
86
  },
87
- "version": "4.7.0"
87
+ "version": "4.8.0"
88
88
  }
@@ -40,7 +40,7 @@ export declare class RequestClient implements HttpClient {
40
40
  protected csrfToken: CsrfToken;
41
41
  protected fileUploadCsrfToken: CsrfToken | undefined;
42
42
  protected httpClient: AxiosInstance;
43
- constructor(baseUrl: string, httpsAgentOptions?: https.AgentOptions, requestsLimit?: number);
43
+ constructor(baseUrl: string, httpsAgentOptions?: https.AgentOptions, requestsLimit?: number, verboseMode?: boolean);
44
44
  setConfig(baseUrl: string, httpsAgentOptions?: https.AgentOptions): void;
45
45
  saveLocalStorageToken(accessToken: string, refreshToken: string): void;
46
46
  getCsrfToken(type?: 'general' | 'file'): CsrfToken | undefined;
package/src/SASjs.ts CHANGED
@@ -31,6 +31,7 @@ import {
31
31
  } from './job-execution'
32
32
  import { ErrorResponse } from './types/errors'
33
33
  import { LoginOptions, LoginResult } from './types/Login'
34
+ import { AxiosResponse } from 'axios'
34
35
 
35
36
  interface ExecuteScriptParams {
36
37
  linesOfCode: string[]
@@ -880,7 +881,7 @@ export default class SASjs {
880
881
  }
881
882
 
882
883
  if (verboseMode) this.requestClient?.enableVerboseMode()
883
- else this.requestClient?.disableVerboseMode()
884
+ else if (verboseMode === false) this.requestClient?.disableVerboseMode()
884
885
 
885
886
  return this.sasViyaApiClient?.executeComputeJob(
886
887
  sasJob,
@@ -975,7 +976,8 @@ export default class SASjs {
975
976
  this.requestClient = new RequestClientClass(
976
977
  this.sasjsConfig.serverUrl,
977
978
  this.sasjsConfig.httpsAgentOptions,
978
- this.sasjsConfig.requestHistoryLimit
979
+ this.sasjsConfig.requestHistoryLimit,
980
+ this.sasjsConfig.verbose
979
981
  )
980
982
  } else {
981
983
  this.requestClient.setConfig(
@@ -1139,4 +1141,23 @@ export default class SASjs {
1139
1141
  )
1140
1142
  }
1141
1143
  }
1144
+
1145
+ /**
1146
+ * Enables verbose mode that will log a summary of every HTTP response.
1147
+ * @param successCallBack - function that should be triggered on every HTTP response with the status 2**.
1148
+ * @param errorCallBack - function that should be triggered on every HTTP response with the status different from 2**.
1149
+ */
1150
+ public enableVerboseMode(
1151
+ successCallBack?: (response: AxiosResponse) => AxiosResponse,
1152
+ errorCallBack?: (response: AxiosResponse) => AxiosResponse
1153
+ ) {
1154
+ this.requestClient?.enableVerboseMode(successCallBack, errorCallBack)
1155
+ }
1156
+
1157
+ /**
1158
+ * Turns off verbose mode to log every HTTP response.
1159
+ */
1160
+ public disableVerboseMode() {
1161
+ this.requestClient?.disableVerboseMode()
1162
+ }
1142
1163
  }
@@ -233,7 +233,8 @@ export default class SASjs {
233
233
  this.requestClient = new RequestClient(
234
234
  this.sasjsConfig.serverUrl,
235
235
  this.sasjsConfig.httpsAgentOptions,
236
- this.sasjsConfig.requestHistoryLimit
236
+ this.sasjsConfig.requestHistoryLimit,
237
+ this.sasjsConfig.verbose
237
238
  )
238
239
  } else {
239
240
  this.requestClient.setConfig(
@@ -11,7 +11,6 @@ import {
11
11
  import { RequestClient } from '../../request/RequestClient'
12
12
  import {
13
13
  isRelativePath,
14
- parseSasViyaDebugResponse,
15
14
  appendExtraResponseAttributes,
16
15
  convertToCSV
17
16
  } from '../../utils'
@@ -69,11 +69,14 @@ export class RequestClient implements HttpClient {
69
69
  constructor(
70
70
  protected baseUrl: string,
71
71
  httpsAgentOptions?: https.AgentOptions,
72
- requestsLimit?: number
72
+ requestsLimit?: number,
73
+ verboseMode?: boolean
73
74
  ) {
74
75
  this.createHttpClient(baseUrl, httpsAgentOptions)
75
76
 
76
77
  if (requestsLimit) this.requestsLimit = requestsLimit
78
+
79
+ if (verboseMode) this.enableVerboseMode()
77
80
  }
78
81
 
79
82
  public setConfig(baseUrl: string, httpsAgentOptions?: https.AgentOptions) {
@@ -45,6 +45,10 @@ export class SASjsConfig {
45
45
  * Set to `true` to enable additional debugging.
46
46
  */
47
47
  debug: boolean = true
48
+ /**
49
+ * Set to `true` to enable verbose mode that will log a summary of every HTTP response.
50
+ */
51
+ verbose?: boolean = true
48
52
  /**
49
53
  * The name of the compute context to use when calling the Viya services directly.
50
54
  * Example value: 'SAS Job Execution compute context'
@@ -45,6 +45,10 @@ export declare class SASjsConfig {
45
45
  * Set to `true` to enable additional debugging.
46
46
  */
47
47
  debug: boolean;
48
+ /**
49
+ * Set to `true` to enable verbose mode that will log a summary of every HTTP response.
50
+ */
51
+ verbose?: boolean;
48
52
  /**
49
53
  * The name of the compute context to use when calling the Viya services directly.
50
54
  * Example value: 'SAS Job Execution compute context'