@sasjs/adapter 4.7.0 → 4.9.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/README.md CHANGED
@@ -151,7 +151,11 @@ The `request()` method also has optional parameters such as a config object and
151
151
 
152
152
  The response object will contain returned tables and columns. Table names are always lowercase, and column names uppercase.
153
153
 
154
- The adapter will also cache the logs (if debug enabled) and even the work tables. For performance, it is best to keep debug mode off.
154
+ The adapter will also cache the logs (if debug enabled) and even the work tables. For performance, it is best to keep debug mode off.
155
+
156
+ ### Verbose Mode
157
+
158
+ Set `verbose` to `true` to enable verbose mode that logs a summary of every HTTP response. Verbose mode can be disabled by calling `disableVerboseMode` method or enabled by `enableVerboseMode` method. Verbose mode also supports `bleached` mode that disables extra colors in req/res summary. To enable `bleached` verbose mode, pass `verbose` equal to `bleached` while instantiating an instance of `RequestClient` or to `setVerboseMode` method. Verbose mode can also be enabled/disabled by `startComputeJob` method.
155
159
 
156
160
  ### Session Manager
157
161
 
@@ -273,6 +277,7 @@ Configuration on the client side involves passing an object on startup, which ca
273
277
  * `serverType` - either `SAS9`, `SASVIYA` or `SASJS`. The `SASJS` server type is for use with [sasjs/server](https://github.com/sasjs/server).
274
278
  * `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.
275
279
  * `debug` - if `true` then SAS Logs and extra debug information is returned.
280
+ * `verbose` - optional, if `true` then a summary of every HTTP response is logged.
276
281
  * `loginMechanism` - either `Default` or `Redirected`. See [SAS Logon](#sas-logon) section.
277
282
  * `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.
278
283
  * `contextName` - Compute context on which the requests will be called. If missing or not provided, defaults to `Job Execution Compute context`.
package/SASjs.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /// <reference types="node" />
2
- import { SASjsConfig, UploadFile, EditContextInput, PollOptions } from './types';
2
+ import { SASjsConfig, UploadFile, EditContextInput, PollOptions, VerboseMode, LoginOptions, LoginResult, ExecutionQuery } from './types';
3
3
  import { SASViyaApiClient } from './SASViyaApiClient';
4
4
  import { SASjsAuthResponse } from './SASjsApiClient';
5
5
  import { MacroVar, AuthConfig, ExtraResponseAttributes, SasAuthResponse, AuthConfigSas9 } from '@sasjs/utils/types';
6
- import { LoginOptions, LoginResult } from './types/Login';
6
+ import { AxiosResponse } from 'axios';
7
7
  interface ExecuteScriptParams {
8
8
  linesOfCode: string[];
9
9
  fileName?: string;
@@ -44,6 +44,17 @@ export default class SASjs {
44
44
  * @param debug - (optional) if true, global debug config will be overriden
45
45
  */
46
46
  executeScript({ linesOfCode, fileName, contextName, runTime, authConfig, authConfigSas9, debug }: ExecuteScriptParams): Promise<any>;
47
+ /**
48
+ * Executes job on SASJS server.
49
+ * @param query - an object containing job path and debug level.
50
+ * @param appLoc - an application path.
51
+ * @param authConfig - an object for authentication.
52
+ * @returns a promise that resolves into job execution result and log.
53
+ */
54
+ executeJob(query: ExecutionQuery, appLoc: string, authConfig?: AuthConfig): Promise<{
55
+ result: any;
56
+ log: any;
57
+ } | undefined>;
47
58
  /**
48
59
  * Gets compute contexts.
49
60
  * @param accessToken - an access token for an authorised user.
@@ -216,7 +227,7 @@ export default class SASjs {
216
227
  * Checks whether a session is active, or login is required.
217
228
  * @returns - a promise which resolves with an object containing two values - a boolean `isLoggedIn`, and a string `userName`.
218
229
  */
219
- checkSession(): Promise<import("./types/Login").LoginResultInternal>;
230
+ checkSession(): Promise<import("./types").LoginResultInternal>;
220
231
  /**
221
232
  * Logs into the SAS server with the supplied credentials.
222
233
  * @param username - a string representing the username.
@@ -308,9 +319,9 @@ export default class SASjs {
308
319
  * @param pollOptions - an object that represents poll interval(milliseconds) and maximum amount of attempts. Object example: { maxPollCount: 24 * 60 * 60, pollInterval: 1000 }. More information available at src/api/viya/pollJobState.ts.
309
320
  * @param printPid - a boolean that indicates whether the function should print (PID) of the started job.
310
321
  * @param variables - an object that represents macro variables.
311
- * @param verboseMode - boolean to enable verbose mode (log every HTTP response).
322
+ * @param verboseMode - boolean or a string equal to 'bleached' to enable verbose mode (log every HTTP response).
312
323
  */
313
- startComputeJob(sasJob: string, data: any, config?: any, authConfig?: AuthConfig, waitForResult?: boolean, pollOptions?: PollOptions, printPid?: boolean, variables?: MacroVar, verboseMode?: boolean): Promise<any>;
324
+ startComputeJob(sasJob: string, data: any, config?: any, authConfig?: AuthConfig, waitForResult?: boolean, pollOptions?: PollOptions, printPid?: boolean, variables?: MacroVar, verboseMode?: VerboseMode): Promise<any>;
314
325
  private resendWaitingRequests;
315
326
  /**
316
327
  * Fetches content of the log file
@@ -327,5 +338,20 @@ export default class SASjs {
327
338
  private setupConfiguration;
328
339
  private createFoldersAndServices;
329
340
  private isMethodSupported;
341
+ /**
342
+ * Enables verbose mode that will log a summary of every HTTP response.
343
+ * @param successCallBack - function that should be triggered on every HTTP response with the status 2**.
344
+ * @param errorCallBack - function that should be triggered on every HTTP response with the status different from 2**.
345
+ */
346
+ enableVerboseMode(successCallBack?: (response: AxiosResponse) => AxiosResponse, errorCallBack?: (response: AxiosResponse) => AxiosResponse): void;
347
+ /**
348
+ * Turns off verbose mode to log every HTTP response.
349
+ */
350
+ disableVerboseMode(): void;
351
+ /**
352
+ * Sets verbose mode.
353
+ * @param verboseMode - value of the verbose mode, can be true, false or bleached(without extra colors).
354
+ */
355
+ setVerboseMode: (verboseMode: VerboseMode) => void;
330
356
  }
331
357
  export {};