mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-03 10:40:06 +00:00
Merge pull request #594 from sasjs/issue-588
fix: sas9JobExecutor issues
This commit is contained in:
@@ -1044,6 +1044,7 @@ export default class SASjs {
|
|||||||
this.sasjsConfig.serverUrl,
|
this.sasjsConfig.serverUrl,
|
||||||
this.sasjsConfig.serverType!,
|
this.sasjsConfig.serverType!,
|
||||||
this.jobsPath,
|
this.jobsPath,
|
||||||
|
this.requestClient,
|
||||||
this.sasjsConfig.httpsAgentOptions
|
this.sasjsConfig.httpsAgentOptions
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { ErrorResponse } from '../types/errors'
|
|||||||
import { convertToCSV, isRelativePath } from '../utils'
|
import { convertToCSV, isRelativePath } from '../utils'
|
||||||
import { BaseJobExecutor } from './JobExecutor'
|
import { BaseJobExecutor } from './JobExecutor'
|
||||||
import { Sas9RequestClient } from '../request/Sas9RequestClient'
|
import { Sas9RequestClient } from '../request/Sas9RequestClient'
|
||||||
|
import { RequestClient } from '../request/RequestClient'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Job executor for SAS9 servers for use in Node.js environments.
|
* Job executor for SAS9 servers for use in Node.js environments.
|
||||||
@@ -13,15 +14,16 @@ import { Sas9RequestClient } from '../request/Sas9RequestClient'
|
|||||||
* job execution requests.
|
* job execution requests.
|
||||||
*/
|
*/
|
||||||
export class Sas9JobExecutor extends BaseJobExecutor {
|
export class Sas9JobExecutor extends BaseJobExecutor {
|
||||||
private requestClient: Sas9RequestClient
|
private sas9RequestClient: Sas9RequestClient
|
||||||
constructor(
|
constructor(
|
||||||
serverUrl: string,
|
serverUrl: string,
|
||||||
serverType: ServerType,
|
serverType: ServerType,
|
||||||
private jobsPath: string,
|
private jobsPath: string,
|
||||||
|
private requestClient: RequestClient,
|
||||||
httpsAgentOptions?: https.AgentOptions
|
httpsAgentOptions?: https.AgentOptions
|
||||||
) {
|
) {
|
||||||
super(serverUrl, serverType)
|
super(serverUrl, serverType)
|
||||||
this.requestClient = new Sas9RequestClient(serverUrl, httpsAgentOptions)
|
this.sas9RequestClient = new Sas9RequestClient(serverUrl, httpsAgentOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(sasJob: string, data: any, config: any) {
|
async execute(sasJob: string, data: any, config: any) {
|
||||||
@@ -37,6 +39,8 @@ export class Sas9JobExecutor extends BaseJobExecutor {
|
|||||||
: ''
|
: ''
|
||||||
}`
|
}`
|
||||||
|
|
||||||
|
apiUrl = `${apiUrl}${config.debug ? '&_debug=131' : ''}`
|
||||||
|
|
||||||
let requestParams = {
|
let requestParams = {
|
||||||
...this.getRequestParams(config)
|
...this.getRequestParams(config)
|
||||||
}
|
}
|
||||||
@@ -49,6 +53,8 @@ export class Sas9JobExecutor extends BaseJobExecutor {
|
|||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
return Promise.reject(new ErrorResponse(e?.message, e))
|
return Promise.reject(new ErrorResponse(e?.message, e))
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
data = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const key in requestParams) {
|
for (const key in requestParams) {
|
||||||
@@ -57,16 +63,18 @@ export class Sas9JobExecutor extends BaseJobExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.requestClient.login(
|
await this.sas9RequestClient.login(
|
||||||
config.username,
|
config.username,
|
||||||
config.password,
|
config.password,
|
||||||
this.jobsPath
|
this.jobsPath
|
||||||
)
|
)
|
||||||
|
|
||||||
const contentType =
|
const contentType =
|
||||||
data && Object.keys(data).length
|
data && Object.keys(data).length
|
||||||
? 'multipart/form-data; boundary=' + (formData as any)._boundary
|
? 'multipart/form-data; boundary=' + (formData as any)._boundary
|
||||||
: 'text/plain'
|
: 'text/plain'
|
||||||
return await this.requestClient!.post(
|
|
||||||
|
return await this.sas9RequestClient!.post(
|
||||||
apiUrl,
|
apiUrl,
|
||||||
formData,
|
formData,
|
||||||
undefined,
|
undefined,
|
||||||
@@ -76,6 +84,28 @@ export class Sas9JobExecutor extends BaseJobExecutor {
|
|||||||
Connection: 'Keep-Alive'
|
Connection: 'Keep-Alive'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
.then((res: any) => {
|
||||||
|
let resString = res
|
||||||
|
|
||||||
|
if (typeof res === 'object') {
|
||||||
|
resString = JSON.stringify(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.requestClient!.appendRequest(resString, sasJob, config.debug)
|
||||||
|
|
||||||
|
return res
|
||||||
|
})
|
||||||
|
.catch((err: any) => {
|
||||||
|
let errString = err
|
||||||
|
|
||||||
|
if (typeof err === 'object') {
|
||||||
|
errString = JSON.stringify(errString)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.requestClient!.appendRequest(errString, sasJob, config.debug)
|
||||||
|
|
||||||
|
return err
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private getRequestParams(config: any): any {
|
private getRequestParams(config: any): any {
|
||||||
|
|||||||
Reference in New Issue
Block a user