1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 09:24:35 +00:00

Compare commits

...

9 Commits

Author SHA1 Message Date
Muhammad Saad
35f37ac796 Merge pull request #650 from sasjs/sasjs-server-webout
fix: no need to parse if webout is an object
2022-02-21 15:54:12 +04:00
Saad Jutt
d7ad0288b9 fix: no need to parse if webout is an object 2022-02-21 16:45:41 +05:00
Allan Bowe
9c98cabe6c Merge pull request #649 from sasjs/sasjs-server-log-parsing
fix: adopted new log structure of SASJS server
2022-02-20 23:27:36 +02:00
Saad Jutt
a6f6897543 fix: adopted new log structure of SASJS server 2022-02-20 20:50:38 +05:00
Allan Bowe
2ea3925977 Merge pull request #647 from sasjs/issue-623
feat(sasjs-config): add optional attribute requestHistoryLimit
2022-02-18 16:25:49 +02:00
489df78391 chore: lint fix 2022-02-18 15:30:24 +05:00
Allan Bowe
842c7f9b23 chore: adding docs for requestHistoryLimit 2022-02-17 20:46:09 +00:00
fe3f6d6287 feat(sasjs-config): add optional attribute requestHistoryLimit 2022-02-17 23:39:55 +05:00
munja
9728ebd98d chore: reducing dependabot limit to 2 per month 2022-02-17 11:07:03 +00:00
7 changed files with 38 additions and 11 deletions

View File

@@ -4,4 +4,4 @@ updates:
directory: '/'
schedule:
interval: monthly
open-pull-requests-limit: 10
open-pull-requests-limit: 2

View File

@@ -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).

View File

@@ -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(

View File

@@ -52,17 +52,25 @@ export class SasJsJobExecutor extends BaseJobExecutor {
authConfig?.access_token
)
.then(async (res: any) => {
const parsedSasjsServerLog = res.result.log
.map((logLine: any) => logLine.line)
.join('\n')
const resObj = {
result: res.result._webout,
log: res.result.log
log: parsedSasjsServerLog
}
this.requestClient!.appendRequest(resObj, sasJob, config.debug)
let jsonResponse = res.result
if (config.debug) {
const webout = parseWeboutResponse(res.result._webout, apiUrl)
jsonResponse = getValidJson(webout)
if (typeof res.result._webout === 'object') {
jsonResponse = res.result._webout
} else {
const webout = parseWeboutResponse(res.result._webout, apiUrl)
jsonResponse = getValidJson(webout)
}
} else {
jsonResponse = getValidJson(res.result._webout)
}

View File

@@ -146,11 +146,16 @@ export class WebJobExecutor extends BaseJobExecutor {
const requestPromise = new Promise((resolve, reject) => {
this.requestClient!.post(apiUrl, formData, authConfig?.access_token)
.then(async (res: any) => {
const parsedSasjsServerLog =
this.serverType === ServerType.Sasjs
? res.result.log.map((logLine: any) => logLine.line).join('\n')
: res.result.log
const resObj =
this.serverType === ServerType.Sasjs
? {
result: res.result._webout,
log: res.result.log
log: parsedSasjsServerLog
}
: res
this.requestClient!.appendRequest(resObj, sasJob, config.debug)
@@ -173,8 +178,12 @@ export class WebJobExecutor extends BaseJobExecutor {
: res.result
break
case ServerType.Sasjs:
const webout = parseWeboutResponse(res.result._webout, apiUrl)
jsonResponse = getValidJson(webout)
if (typeof res.result._webout === 'object') {
jsonResponse = res.result._webout
} else {
const webout = parseWeboutResponse(res.result._webout, apiUrl)
jsonResponse = getValidJson(webout)
}
break
}
} else if (this.serverType === ServerType.Sasjs) {

View File

@@ -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)
}
}

View File

@@ -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`
*/
@@ -69,6 +69,11 @@ export class SASjsConfig {
* Supported login mechanisms are - Redirected and Default
*/
loginMechanism: LoginMechanism = LoginMechanism.Default
/**
* Optional setting to configure request history limit. Increasing this limit
* may affect browser performance, especially with debug (logs) enabled.
*/
requestHistoryLimit?: number = 10
}
export enum LoginMechanism {