mirror of
https://github.com/sasjs/adapter.git
synced 2026-06-08 18:20:20 +00:00
feat(debug): add viya debug log parser - parse JSON from inline blob
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
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])
|
||||
}
|
||||
Reference in New Issue
Block a user