1
0
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:
mulahasanovic
2026-05-13 14:09:47 +02:00
parent a691500910
commit 4cae9b5472
4 changed files with 69 additions and 5 deletions
+18
View File
@@ -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])
}