mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-16 16:40:06 +00:00
fix: sasjs server type - request and job execution auth fix
This commit is contained in:
@@ -916,8 +916,8 @@ export default class SASjs {
|
|||||||
return await this.sasJSApiClient?.deploy(dataJson, appLoc, authConfig)
|
return await this.sasJSApiClient?.deploy(dataJson, appLoc, authConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async executeJobSASjs(query: ExecutionQuery) {
|
public async executeJobSASjs(query: ExecutionQuery, authConfig?: AuthConfig) {
|
||||||
return await this.sasJSApiClient?.executeJob(query)
|
return await this.sasJSApiClient?.executeJob(query, authConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -43,7 +43,9 @@ export class SASjsApiClient {
|
|||||||
return Promise.resolve(result)
|
return Promise.resolve(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async executeJob(query: ExecutionQuery) {
|
public async executeJob(query: ExecutionQuery, authConfig?: AuthConfig) {
|
||||||
|
const access_token = authConfig ? authConfig.access_token : undefined
|
||||||
|
|
||||||
const { result } = await this.requestClient.post<{
|
const { result } = await this.requestClient.post<{
|
||||||
status: string
|
status: string
|
||||||
message: string
|
message: string
|
||||||
@@ -51,7 +53,7 @@ export class SASjsApiClient {
|
|||||||
logPath?: string
|
logPath?: string
|
||||||
error?: {}
|
error?: {}
|
||||||
_webout?: string
|
_webout?: string
|
||||||
}>('SASjsApi/stp/execute', query, undefined)
|
}>('SASjsApi/stp/execute', query, access_token)
|
||||||
|
|
||||||
if (Object.keys(result).includes('_webout')) {
|
if (Object.keys(result).includes('_webout')) {
|
||||||
result._webout = parseWeboutResponse(result._webout!)
|
result._webout = parseWeboutResponse(result._webout!)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
} from '../utils'
|
} from '../utils'
|
||||||
import { BaseJobExecutor } from './JobExecutor'
|
import { BaseJobExecutor } from './JobExecutor'
|
||||||
import { parseWeboutResponse } from '../utils/parseWeboutResponse'
|
import { parseWeboutResponse } from '../utils/parseWeboutResponse'
|
||||||
|
import { Server } from 'https'
|
||||||
|
|
||||||
export interface WaitingRequstPromise {
|
export interface WaitingRequstPromise {
|
||||||
promise: Promise<any> | null
|
promise: Promise<any> | null
|
||||||
@@ -220,25 +221,36 @@ export class WebJobExecutor extends BaseJobExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (e instanceof LoginRequiredError) {
|
if (e instanceof LoginRequiredError) {
|
||||||
this.appendWaitingRequest(() => {
|
switch (this.serverType) {
|
||||||
return this.execute(
|
case ServerType.Sasjs:
|
||||||
sasJob,
|
reject(
|
||||||
data,
|
new ErrorResponse(
|
||||||
config,
|
'Request is not authenticated. Make sure .env file exists with valid credentials.',
|
||||||
loginRequiredCallback,
|
e
|
||||||
authConfig,
|
)
|
||||||
extraResponseAttributes
|
)
|
||||||
).then(
|
break
|
||||||
(res: any) => {
|
default:
|
||||||
resolve(res)
|
this.appendWaitingRequest(() => {
|
||||||
},
|
return this.execute(
|
||||||
(err: any) => {
|
sasJob,
|
||||||
reject(err)
|
data,
|
||||||
}
|
config,
|
||||||
)
|
loginRequiredCallback,
|
||||||
})
|
authConfig,
|
||||||
|
extraResponseAttributes
|
||||||
|
).then(
|
||||||
|
(res: any) => {
|
||||||
|
resolve(res)
|
||||||
|
},
|
||||||
|
(err: any) => {
|
||||||
|
reject(err)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
await loginCallback()
|
await loginCallback()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
reject(new ErrorResponse(e?.message, e))
|
reject(new ErrorResponse(e?.message, e))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user