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

chore(*): clean up, handle debug responses

This commit is contained in:
Krishna Acondy
2021-02-04 09:42:39 +00:00
parent 8edb00f869
commit 613cc6b9ef
6 changed files with 125 additions and 169 deletions

View File

@@ -82,6 +82,13 @@ export class WebJobExecutor extends BaseJobExecutor {
return this.requestClient!.post(apiUrl, formData, undefined)
.then(async (res) => {
if (this.serverType === ServerType.SasViya && config.debug) {
const jsonResponse = await this.parseSasViyaDebugResponse(
res.result as string
)
this.appendRequest(res, sasJob, config.debug)
return jsonResponse
}
this.appendRequest(res, sasJob, config.debug)
return res.result
})
@@ -99,6 +106,20 @@ export class WebJobExecutor extends BaseJobExecutor {
})
}
private parseSasViyaDebugResponse = async (response: string) => {
const iframeStart = response.split(
'<iframe style="width: 99%; height: 500px" src="'
)[1]
const jsonUrl = iframeStart ? iframeStart.split('"></iframe>')[0] : null
if (!jsonUrl) {
throw new Error('Unable to find webout file URL.')
}
return this.requestClient
.get(this.serverUrl + jsonUrl, undefined)
.then((res) => res.result)
}
private async getJobUri(sasJob: string) {
if (!this.sasViyaApiClient) return ''
let uri = ''