mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-08 21:10:05 +00:00
fix: makeRequest incositent response structure
This commit is contained in:
@@ -208,12 +208,15 @@ export class SASViyaApiClient {
|
|||||||
debug = false
|
debug = false
|
||||||
) {
|
) {
|
||||||
silent = !debug;
|
silent = !debug;
|
||||||
|
|
||||||
const headers: any = {
|
const headers: any = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
};
|
};
|
||||||
|
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
headers.Authorization = `Bearer ${accessToken}`;
|
headers.Authorization = `Bearer ${accessToken}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let executionSessionId: string;
|
let executionSessionId: string;
|
||||||
const session = await this.sessionManager.getSession(accessToken);
|
const session = await this.sessionManager.getSession(accessToken);
|
||||||
executionSessionId = session!.id;
|
executionSessionId = session!.id;
|
||||||
@@ -241,7 +244,9 @@ export class SASViyaApiClient {
|
|||||||
SYS_JES_JOB_URI: "",
|
SYS_JES_JOB_URI: "",
|
||||||
_program: this.rootFolderName + "/" + jobName,
|
_program: this.rootFolderName + "/" + jobName,
|
||||||
};
|
};
|
||||||
|
|
||||||
let files: any[] = [];
|
let files: any[] = [];
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
if (JSON.stringify(data).includes(";")) {
|
if (JSON.stringify(data).includes(";")) {
|
||||||
files = await this.uploadTables(data, accessToken);
|
files = await this.uploadTables(data, accessToken);
|
||||||
@@ -269,10 +274,12 @@ export class SASViyaApiClient {
|
|||||||
arguments: jobArguments,
|
arguments: jobArguments,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
const { result: postedJob, etag } = await this.request<Job>(
|
const { result: postedJob, etag } = await this.request<Job>(
|
||||||
`${this.serverUrl}/compute/sessions/${executionSessionId}/jobs`,
|
`${this.serverUrl}/compute/sessions/${executionSessionId}/jobs`,
|
||||||
postJobRequest
|
postJobRequest
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
console.log(`Job has been submitted for ${fileName}`);
|
console.log(`Job has been submitted for ${fileName}`);
|
||||||
console.log(
|
console.log(
|
||||||
@@ -288,17 +295,20 @@ export class SASViyaApiClient {
|
|||||||
accessToken,
|
accessToken,
|
||||||
silent
|
silent
|
||||||
);
|
);
|
||||||
|
|
||||||
const { result: currentJob } = await this.request<Job>(
|
const { result: currentJob } = await this.request<Job>(
|
||||||
`${this.serverUrl}/compute/sessions/${executionSessionId}/jobs/${postedJob.id}`,
|
`${this.serverUrl}/compute/sessions/${executionSessionId}/jobs/${postedJob.id}`,
|
||||||
{ headers }
|
{ headers }
|
||||||
);
|
);
|
||||||
|
|
||||||
let jobResult, log;
|
let jobResult, log;
|
||||||
|
|
||||||
if (jobStatus === "failed" || jobStatus === "error") {
|
if (jobStatus === "failed" || jobStatus === "error") {
|
||||||
return Promise.reject(currentJob.error);
|
return Promise.reject(currentJob.error);
|
||||||
}
|
}
|
||||||
const resultLink = `/compute/sessions/${executionSessionId}/filerefs/_webout/content`;
|
const resultLink = `/compute/sessions/${executionSessionId}/filerefs/_webout/content`;
|
||||||
const logLink = currentJob.links.find((l) => l.rel === "log");
|
const logLink = currentJob.links.find((l) => l.rel === "log");
|
||||||
|
|
||||||
if (resultLink) {
|
if (resultLink) {
|
||||||
jobResult = await this.request<any>(
|
jobResult = await this.request<any>(
|
||||||
`${this.serverUrl}${resultLink}`,
|
`${this.serverUrl}${resultLink}`,
|
||||||
@@ -713,6 +723,7 @@ export class SASViyaApiClient {
|
|||||||
if (data && Object.keys(data).length) {
|
if (data && Object.keys(data).length) {
|
||||||
files = await this.uploadTables(data, accessToken);
|
files = await this.uploadTables(data, accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
const jobName = path.basename(sasJob);
|
const jobName = path.basename(sasJob);
|
||||||
const jobFolder = sasJob.replace(`/${jobName}`, "");
|
const jobFolder = sasJob.replace(`/${jobName}`, "");
|
||||||
const allJobsInFolder = this.rootFolderMap.get(jobFolder.replace("/", ""));
|
const allJobsInFolder = this.rootFolderMap.get(jobFolder.replace("/", ""));
|
||||||
@@ -1007,12 +1018,12 @@ export class SASViyaApiClient {
|
|||||||
headers,
|
headers,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { result: file } = await this.request<any>(
|
const uploadResponse = await this.request<any>(
|
||||||
`${this.serverUrl}/files/files#rawUpload`,
|
`${this.serverUrl}/files/files#rawUpload`,
|
||||||
createFileRequest
|
createFileRequest
|
||||||
);
|
);
|
||||||
|
|
||||||
uploadedFiles.push({ tableName, file });
|
uploadedFiles.push({ tableName, file: uploadResponse.result });
|
||||||
}
|
}
|
||||||
return uploadedFiles;
|
return uploadedFiles;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ export async function makeRequest<T>(
|
|||||||
);
|
);
|
||||||
retryCount = 0;
|
retryCount = 0;
|
||||||
|
|
||||||
return retryResponse;
|
etag = retryResponse.etag;
|
||||||
|
return retryResponse.result;
|
||||||
} else {
|
} else {
|
||||||
retryCount = 0;
|
retryCount = 0;
|
||||||
|
|
||||||
@@ -89,7 +90,8 @@ export async function makeRequest<T>(
|
|||||||
);
|
);
|
||||||
retryCount = 0;
|
retryCount = 0;
|
||||||
|
|
||||||
return retryResponse;
|
etag = retryResponse.etag;
|
||||||
|
return retryResponse.result;
|
||||||
} else {
|
} else {
|
||||||
retryCount = 0;
|
retryCount = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user