mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-07 04:20:05 +00:00
fix: move parseSasViyaDebugResponse method to utils folder
This commit is contained in:
@@ -13,3 +13,4 @@ export * from './splitChunks'
|
||||
export * from './parseWeboutResponse'
|
||||
export * from './fetchLogByChunks'
|
||||
export * from './isValidJson'
|
||||
export * from './parseViyaDebugResponse'
|
||||
|
||||
29
src/utils/parseViyaDebugResponse.ts
Normal file
29
src/utils/parseViyaDebugResponse.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { RequestClient } from '../request/RequestClient'
|
||||
|
||||
/**
|
||||
* When querying a Viya job using the Web approach (as opposed to using the APIs) with _DEBUG enabled,
|
||||
* the first response contains the log with the content in an iframe. Therefore when debug is enabled,
|
||||
* and the serverType is VIYA, and useComputeApi is null (WEB), we call this function to extract the
|
||||
* (_webout) content from the iframe.
|
||||
* @param response - first response from viya job
|
||||
* @param requestClient
|
||||
* @param serverUrl
|
||||
* @returns
|
||||
*/
|
||||
export const parseSasViyaDebugResponse = async (
|
||||
response: string,
|
||||
requestClient: RequestClient,
|
||||
serverUrl: 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 requestClient
|
||||
.get(serverUrl + jsonUrl, undefined)
|
||||
.then((res) => res.result)
|
||||
}
|
||||
Reference in New Issue
Block a user