1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-08 13:00:05 +00:00

fix: handled updated sasjs response

This commit is contained in:
2022-08-19 16:10:05 +05:00
parent 92be5a2dca
commit 4a319f1aef
7 changed files with 61 additions and 75 deletions

View File

@@ -1,7 +1,8 @@
import {
getValidJson,
parseSasViyaDebugResponse,
parseWeboutResponse
parseWeboutResponse,
SASJS_LOGS_SEPARATOR
} from '../utils'
import { UploadFile } from '../types/UploadFile'
import {
@@ -80,9 +81,29 @@ export class FileUploader extends BaseJobExecutor {
this.requestClient
.post(uploadUrl, formData, undefined, 'application/json', headers)
.then(async (res: any) => {
this.requestClient.appendRequest(res, sasJob, config.debug)
const parsedSasjsLog =
this.serverType === ServerType.Sasjs
? res.log?.split(SASJS_LOGS_SEPARATOR)[1]
: res.result.log
let jsonResponse = res.result
const parsedSasjsServerWebout =
this.serverType === ServerType.Sasjs
? typeof res.result === 'string'
? getValidJson(res.log?.split(SASJS_LOGS_SEPARATOR)[0])
: res.result
: undefined
const resObj =
this.serverType === ServerType.Sasjs
? {
result: parsedSasjsServerWebout,
log: parsedSasjsLog
}
: res
this.requestClient.appendRequest(resObj, sasJob, config.debug)
let jsonResponse = resObj.result
if (config.debug) {
switch (this.serverType) {
@@ -99,25 +120,7 @@ export class FileUploader extends BaseJobExecutor {
? parseWeboutResponse(res.result, uploadUrl)
: res.result
break
case ServerType.Sasjs:
if (typeof res.result._webout === 'object') {
jsonResponse = res.result._webout
} else {
const webout = parseWeboutResponse(
res.result._webout,
uploadUrl
)
jsonResponse = getValidJson(webout)
}
break
}
} else if (this.serverType === ServerType.Sasjs) {
jsonResponse = getValidJson(res.result._webout)
} else {
jsonResponse =
typeof res.result === 'string'
? getValidJson(res.result)
: res.result
}
resolve(jsonResponse)