From fe3f6d628790b571d3b5d9a4439d311836014310 Mon Sep 17 00:00:00 2001 From: sabhas Date: Thu, 17 Feb 2022 23:39:55 +0500 Subject: [PATCH 1/3] feat(sasjs-config): add optional attribute requestHistoryLimit --- src/SASjs.ts | 3 ++- src/request/RequestClient.ts | 7 +++++-- src/types/SASjsConfig.ts | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/SASjs.ts b/src/SASjs.ts index 687e653..ce07b95 100644 --- a/src/SASjs.ts +++ b/src/SASjs.ts @@ -1034,7 +1034,8 @@ export default class SASjs { : RequestClient this.requestClient = new RequestClientClass( this.sasjsConfig.serverUrl, - this.sasjsConfig.httpsAgentOptions + this.sasjsConfig.httpsAgentOptions, + this.sasjsConfig.requestHistoryLimit ) } else { this.requestClient.setConfig( diff --git a/src/request/RequestClient.ts b/src/request/RequestClient.ts index 3e18632..208da39 100644 --- a/src/request/RequestClient.ts +++ b/src/request/RequestClient.ts @@ -56,6 +56,7 @@ export interface HttpClient { export class RequestClient implements HttpClient { private requests: SASjsRequest[] = [] + private requestsLimit: number = 10 protected csrfToken: CsrfToken = { headerName: '', value: '' } protected fileUploadCsrfToken: CsrfToken | undefined @@ -63,9 +64,11 @@ export class RequestClient implements HttpClient { constructor( protected baseUrl: string, - httpsAgentOptions?: https.AgentOptions + httpsAgentOptions?: https.AgentOptions, + requestsLimit?: number ) { this.createHttpClient(baseUrl, httpsAgentOptions) + if (requestsLimit) this.requestsLimit = requestsLimit } public setConfig(baseUrl: string, httpsAgentOptions?: https.AgentOptions) { @@ -149,7 +152,7 @@ export class RequestClient implements HttpClient { SASWORK: sasWork }) - if (this.requests.length > 20) { + if (this.requests.length > this.requestsLimit) { this.requests.splice(0, 1) } } diff --git a/src/types/SASjsConfig.ts b/src/types/SASjsConfig.ts index a40db2f..a537bf4 100644 --- a/src/types/SASjsConfig.ts +++ b/src/types/SASjsConfig.ts @@ -69,6 +69,10 @@ export class SASjsConfig { * Supported login mechanisms are - Redirected and Default */ loginMechanism: LoginMechanism = LoginMechanism.Default + /** + * Optional settings to configure limit for requests history + */ + requestHistoryLimit?: number = 10 } export enum LoginMechanism { From 842c7f9b23a73ba497ef1f0c2a97661e9876f64d Mon Sep 17 00:00:00 2001 From: Allan Bowe Date: Thu, 17 Feb 2022 20:46:09 +0000 Subject: [PATCH 2/3] chore: adding docs for requestHistoryLimit --- README.md | 1 + src/types/SASjsConfig.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 60f9f05..1df8b7d 100644 --- a/README.md +++ b/README.md @@ -254,6 +254,7 @@ Configuration on the client side involves passing an object on startup, which ca * `LoginMechanism` - either `Default` or `Redirected`. If `Redirected` then authentication occurs through the injection of an additional screen, which contains the SASLogon prompt. This allows for more complex authentication flows (such as 2FA) and avoids the need to handle passwords in the application itself. The styling of the redirect flow can also be modified. If left at "Default" then the developer must capture the username and password and use these with the `.login()` method. * `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. * `contextName` - Compute context on which the requests will be called. If missing or not provided, defaults to `Job Execution Compute context`. +* `requestHistoryLimit` - Request history limit. Increasing this limit may affect browser performance, especially with debug (logs) enabled. Default is 10. The adapter supports a number of approaches for interfacing with Viya (`serverType` is `SASVIYA`). For maximum performance, be sure to [configure your compute context](https://sasjs.io/guide-viya/#shared-account-and-server-re-use) with `reuseServerProcesses` as `true` and a system account in `runServerAs`. This functionality is available since Viya 3.5. This configuration is supported when [creating contexts using the CLI](https://sasjs.io/sasjs-cli-context/#sasjs-context-create). diff --git a/src/types/SASjsConfig.ts b/src/types/SASjsConfig.ts index a537bf4..d446065 100644 --- a/src/types/SASjsConfig.ts +++ b/src/types/SASjsConfig.ts @@ -60,7 +60,7 @@ export class SASjsConfig { */ useComputeApi: boolean | null = null /** - * Optional settings to configure HTTPS Agent. + * Optional setting to configure HTTPS Agent. * By providing `key`, `cert`, `ca` to connect with server * Other options can be set `rejectUnauthorized` and `requestCert` */ @@ -70,7 +70,8 @@ export class SASjsConfig { */ loginMechanism: LoginMechanism = LoginMechanism.Default /** - * Optional settings to configure limit for requests history + * Optional setting to configure request history limit. Increasing this limit + * may affect browser performance, especially with debug (logs) enabled. */ requestHistoryLimit?: number = 10 } From 489df783910a041b0f87dac38eedbab1b5a6b616 Mon Sep 17 00:00:00 2001 From: sabhas Date: Fri, 18 Feb 2022 15:30:24 +0500 Subject: [PATCH 3/3] chore: lint fix --- src/types/SASjsConfig.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/SASjsConfig.ts b/src/types/SASjsConfig.ts index d446065..f366713 100644 --- a/src/types/SASjsConfig.ts +++ b/src/types/SASjsConfig.ts @@ -70,7 +70,7 @@ export class SASjsConfig { */ loginMechanism: LoginMechanism = LoginMechanism.Default /** - * Optional setting to configure request history limit. Increasing this limit + * Optional setting to configure request history limit. Increasing this limit * may affect browser performance, especially with debug (logs) enabled. */ requestHistoryLimit?: number = 10