mirror of
https://github.com/sasjs/adapter.git
synced 2025-12-11 01:14:36 +00:00
Compare commits
1 Commits
v4.1.2
...
debug-sasj
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c6198ae25 |
30314
sasjs-tests/package-lock.json
generated
30314
sasjs-tests/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,7 @@
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject",
|
||||
"update:adapter": "cd .. && npm run package:lib && cd sasjs-tests && npm i ../build/sasjs-adapter-5.0.0.tgz",
|
||||
"deploy:tests": "rsync -avhe ssh ./build/* --delete $SSH_ACCOUNT:$DEPLOY_PATH || npm run deploy:tests-win",
|
||||
"deploy:tests": "rsync -avhe ssh ./build/* --delete sabhas@sas.analytium.co.uk:/var/www/html/sabhas/sasjs-test || npm run deploy:tests-win",
|
||||
"deploy:tests-win": "scp %DEPLOY_PATH% ./build/*",
|
||||
"deploy": "npm run update:adapter && npm run build && npm run deploy:tests"
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"userName": "",
|
||||
"password": "",
|
||||
"sasJsConfig": {
|
||||
"serverUrl": "",
|
||||
"serverUrl": "https://sas.analytium.co.uk/",
|
||||
"appLoc": "/Public/app",
|
||||
"serverType": "SASVIYA",
|
||||
"debug": false,
|
||||
|
||||
@@ -14,16 +14,16 @@ const App = (): ReactElement<{}> => {
|
||||
useEffect(() => {
|
||||
if (adapter) {
|
||||
const testSuites = [
|
||||
basicTests(adapter, config.userName, config.password),
|
||||
sendArrTests(adapter),
|
||||
sendObjTests(adapter),
|
||||
specialCaseTests(adapter),
|
||||
// basicTests(adapter, config.userName, config.password),
|
||||
// sendArrTests(adapter),
|
||||
// sendObjTests(adapter),
|
||||
// specialCaseTests(adapter),
|
||||
sasjsRequestTests(adapter)
|
||||
]
|
||||
|
||||
if (adapter.getSasjsConfig().serverType === 'SASVIYA') {
|
||||
testSuites.push(computeTests(adapter))
|
||||
}
|
||||
// if (adapter.getSasjsConfig().serverType === 'SASVIYA') {
|
||||
// testSuites.push(computeTests(adapter))
|
||||
// }
|
||||
|
||||
setTestSuites(testSuites)
|
||||
}
|
||||
|
||||
@@ -64,9 +64,17 @@ export class FileUploader {
|
||||
// currently only web approach is supported for file upload
|
||||
// therefore log is part of response with debug enabled and must be parsed
|
||||
return this.requestClient
|
||||
.post(uploadUrl, formData, undefined, 'application/json', headers)
|
||||
.post(
|
||||
uploadUrl,
|
||||
formData,
|
||||
undefined,
|
||||
'application/json',
|
||||
headers,
|
||||
this.sasjsConfig.debug,
|
||||
true,
|
||||
sasJob
|
||||
)
|
||||
.then(async (res) => {
|
||||
this.requestClient!.appendRequest(res, sasJob, this.sasjsConfig.debug)
|
||||
if (
|
||||
this.sasjsConfig.serverType === ServerType.SasViya &&
|
||||
this.sasjsConfig.debug
|
||||
|
||||
@@ -51,16 +51,6 @@ export class SASViyaApiClient {
|
||||
)
|
||||
private folderMap = new Map<string, Job[]>()
|
||||
|
||||
/**
|
||||
* A helper method used to call appendRequest method of RequestClient
|
||||
* @param response - response from sasjs request
|
||||
* @param program - name of program
|
||||
* @param debug - a boolean that indicates whether debug was enabled or not
|
||||
*/
|
||||
public appendRequest(response: any, program: string, debug: boolean) {
|
||||
this.requestClient!.appendRequest(response, program, debug)
|
||||
}
|
||||
|
||||
public get debug() {
|
||||
return this._debug
|
||||
}
|
||||
@@ -792,12 +782,24 @@ export class SASViyaApiClient {
|
||||
jobResult = await this.requestClient.get<any>(
|
||||
`${this.serverUrl}${resultLink}/content`,
|
||||
access_token,
|
||||
'text/plain'
|
||||
'text/plain',
|
||||
{},
|
||||
debug,
|
||||
true,
|
||||
sasJob
|
||||
)
|
||||
}
|
||||
if (debug && logLink) {
|
||||
log = await this.requestClient
|
||||
.get<any>(`${this.serverUrl}${logLink.href}/content`, access_token)
|
||||
.get<any>(
|
||||
`${this.serverUrl}${logLink.href}/content`,
|
||||
access_token,
|
||||
'application/json',
|
||||
{},
|
||||
debug,
|
||||
true,
|
||||
sasJob
|
||||
)
|
||||
.then((res: any) => res.result.items.map((i: any) => i.line).join('\n'))
|
||||
}
|
||||
if (jobStatus === 'failed') {
|
||||
|
||||
@@ -50,6 +50,7 @@ export default class SASjs {
|
||||
private sas9JobExecutor: JobExecutor | null = null
|
||||
|
||||
constructor(config?: any) {
|
||||
console.log('from SASjs constructor')
|
||||
this.sasjsConfig = {
|
||||
...defaultConfig,
|
||||
...config
|
||||
@@ -611,6 +612,7 @@ export default class SASjs {
|
||||
config.useComputeApi !== null
|
||||
) {
|
||||
if (config.useComputeApi) {
|
||||
console.log(615)
|
||||
return await this.computeJobExecutor!.execute(
|
||||
sasJob,
|
||||
data,
|
||||
@@ -883,8 +885,10 @@ export default class SASjs {
|
||||
* @returns SASjsRequest[]
|
||||
*/
|
||||
public getSasRequests() {
|
||||
const requests = [...this.requestClient!.getRequests()]
|
||||
console.log('from getSASRequests')
|
||||
const requests = this.requestClient!.getRequests()
|
||||
const sortedRequests = requests.sort(compareTimestamps)
|
||||
console.log('sortedRequests', sortedRequests)
|
||||
return sortedRequests
|
||||
}
|
||||
|
||||
|
||||
@@ -239,7 +239,15 @@ export async function executeScript(
|
||||
const resultLink = `/compute/sessions/${executionSessionId}/filerefs/_webout/content`
|
||||
|
||||
jobResult = await requestClient
|
||||
.get<any>(resultLink, access_token, 'text/plain')
|
||||
.get<any>(
|
||||
resultLink,
|
||||
access_token,
|
||||
'text/plain',
|
||||
{},
|
||||
debug,
|
||||
true,
|
||||
jobPath
|
||||
)
|
||||
.catch(async (e) => {
|
||||
if (e instanceof NotFoundError) {
|
||||
if (logLink) {
|
||||
|
||||
@@ -35,12 +35,11 @@ export class ComputeJobExecutor extends BaseJobExecutor {
|
||||
expectWebout
|
||||
)
|
||||
.then((response) => {
|
||||
this.sasViyaApiClient.appendRequest(response, sasJob, config.debug)
|
||||
console.log('then block of compute job executor')
|
||||
resolve(response.result)
|
||||
})
|
||||
.catch(async (e: Error) => {
|
||||
if (e instanceof ComputeJobExecutionError) {
|
||||
this.sasViyaApiClient.appendRequest(e, sasJob, config.debug)
|
||||
reject(new ErrorResponse(e?.message, e))
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,6 @@ export class JesJobExecutor extends BaseJobExecutor {
|
||||
this.sasViyaApiClient
|
||||
?.executeJob(sasJob, config.contextName, config.debug, data, authConfig)
|
||||
.then((response: any) => {
|
||||
this.sasViyaApiClient.appendRequest(response, sasJob, config.debug)
|
||||
|
||||
let responseObject = {}
|
||||
|
||||
if (extraResponseAttributes && extraResponseAttributes.length > 0) {
|
||||
@@ -49,8 +47,6 @@ export class JesJobExecutor extends BaseJobExecutor {
|
||||
})
|
||||
.catch(async (e: Error) => {
|
||||
if (e instanceof JobExecutionError) {
|
||||
this.sasViyaApiClient.appendRequest(e, sasJob, config.debug)
|
||||
|
||||
reject(new ErrorResponse(e?.message, e))
|
||||
}
|
||||
|
||||
|
||||
@@ -111,9 +111,17 @@ export class WebJobExecutor extends BaseJobExecutor {
|
||||
}
|
||||
|
||||
const requestPromise = new Promise((resolve, reject) => {
|
||||
this.requestClient!.post(apiUrl, formData, undefined)
|
||||
this.requestClient!.post(
|
||||
apiUrl,
|
||||
formData,
|
||||
undefined,
|
||||
'application/json',
|
||||
{},
|
||||
config.debug,
|
||||
true,
|
||||
sasJob
|
||||
)
|
||||
.then(async (res: any) => {
|
||||
this.requestClient!.appendRequest(res, sasJob, config.debug)
|
||||
if (this.serverType === ServerType.SasViya && config.debug) {
|
||||
const jsonResponse = await parseSasViyaDebugResponse(
|
||||
res.result,
|
||||
@@ -135,7 +143,6 @@ export class WebJobExecutor extends BaseJobExecutor {
|
||||
})
|
||||
.catch(async (e: Error) => {
|
||||
if (e instanceof JobExecutionError) {
|
||||
this.requestClient!.appendRequest(e, sasJob, config.debug)
|
||||
reject(new ErrorResponse(e?.message, e))
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,8 @@ export class RequestClient implements HttpClient {
|
||||
* @param program - name of program
|
||||
* @param debug - a boolean that indicates whether debug was enabled or not
|
||||
*/
|
||||
public appendRequest(response: any, program: string, debug: boolean) {
|
||||
public appendRequest = (response: any, program: string, debug: boolean) => {
|
||||
console.log('from appendRequest')
|
||||
let sourceCode = ''
|
||||
let generatedCode = ''
|
||||
let sasWork = null
|
||||
@@ -151,7 +152,9 @@ export class RequestClient implements HttpClient {
|
||||
accessToken: string | undefined,
|
||||
contentType: string = 'application/json',
|
||||
overrideHeaders: { [key: string]: string | number } = {},
|
||||
debug: boolean = false
|
||||
debug: boolean = false,
|
||||
captureRequest: boolean = false,
|
||||
sasJob: string = ''
|
||||
): Promise<{ result: T; etag: string; status: number }> {
|
||||
const headers = {
|
||||
...this.getHeaders(accessToken, contentType),
|
||||
@@ -171,8 +174,11 @@ export class RequestClient implements HttpClient {
|
||||
.get<T>(url, requestConfig)
|
||||
.then((response) => {
|
||||
throwIfError(response)
|
||||
|
||||
return this.parseResponse<T>(response)
|
||||
const responseToReturn = this.parseResponse<T>(response)
|
||||
if (captureRequest) {
|
||||
this.appendRequest(responseToReturn, sasJob, debug)
|
||||
}
|
||||
return responseToReturn
|
||||
})
|
||||
.catch(async (e) => {
|
||||
return await this.handleError(
|
||||
@@ -198,7 +204,10 @@ export class RequestClient implements HttpClient {
|
||||
data: any,
|
||||
accessToken: string | undefined,
|
||||
contentType = 'application/json',
|
||||
overrideHeaders: { [key: string]: string | number } = {}
|
||||
overrideHeaders: { [key: string]: string | number } = {},
|
||||
debug: boolean = false,
|
||||
captureRequest: boolean = false,
|
||||
sasJob: string = ''
|
||||
): Promise<{ result: T; etag: string }> {
|
||||
const headers = {
|
||||
...this.getHeaders(accessToken, contentType),
|
||||
@@ -209,7 +218,11 @@ export class RequestClient implements HttpClient {
|
||||
.post<T>(url, data, { headers, withCredentials: true })
|
||||
.then((response) => {
|
||||
throwIfError(response)
|
||||
return this.parseResponse<T>(response)
|
||||
const responseToReturn = this.parseResponse<T>(response)
|
||||
if (captureRequest) {
|
||||
this.appendRequest(responseToReturn, sasJob, debug)
|
||||
}
|
||||
return responseToReturn
|
||||
})
|
||||
.catch(async (e) => {
|
||||
return await this.handleError(e, () =>
|
||||
|
||||
Reference in New Issue
Block a user