mirror of
https://github.com/sasjs/adapter.git
synced 2026-06-08 18:20:20 +00:00
19 lines
666 B
TypeScript
19 lines
666 B
TypeScript
import { getValidJson } from './getValidJson'
|
|
|
|
/**
|
|
* When querying a Viya job using the Web approach with _DEBUG=log (used when
|
|
* runAsTask is true), the webout JSON is inlined into the response via:
|
|
* var blob = new Blob([`{...}`], {type: 'application/json'});
|
|
* No follow-up request is needed — extract and parse the JSON directly.
|
|
*/
|
|
export const parseSasViyaLogDebugResponse = async (response: string) => {
|
|
const blobMatch = response.match(
|
|
/new Blob\(\[`([\s\S]*?)`\],\s*\{type:\s*'application\/json'\}\)/
|
|
)
|
|
if (!blobMatch) {
|
|
throw new Error('Unable to find webout blob in debug log response.')
|
|
}
|
|
|
|
return getValidJson(blobMatch[1])
|
|
}
|