mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-07 04:20:05 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a52bbe560 | ||
|
|
a5c725e677 | ||
|
|
f5e1907e28 | ||
|
|
f7a9b0cbb6 |
@@ -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,28 +295,33 @@ 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}`,
|
||||||
{ headers },
|
{ headers },
|
||||||
"text"
|
"text"
|
||||||
);
|
).catch((e) => ({
|
||||||
|
result: JSON.stringify(e),
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (true && logLink) {
|
if (true && logLink) {
|
||||||
log = await this.request<any>(
|
log = await this.request<any>(
|
||||||
`${this.serverUrl}${logLink.href}/content`,
|
`${this.serverUrl}${logLink.href}/content?limit=10000`,
|
||||||
{
|
{
|
||||||
headers,
|
headers,
|
||||||
}
|
}
|
||||||
@@ -706,11 +718,12 @@ export class SASViyaApiClient {
|
|||||||
`The job ${sasJob} was not found in ${this.rootFolderName}`
|
`The job ${sasJob} was not found in ${this.rootFolderName}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let files: any[] = [];
|
let files: any[] = [];
|
||||||
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("/", ""));
|
||||||
@@ -1005,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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1109,6 +1109,10 @@ export default class SASjs {
|
|||||||
return sortedRequests;
|
return sortedRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public clearSasRequests() {
|
||||||
|
this.sasjsRequests = [];
|
||||||
|
}
|
||||||
|
|
||||||
private setupConfiguration() {
|
private setupConfiguration() {
|
||||||
if (
|
if (
|
||||||
this.sasjsConfig.serverUrl === undefined ||
|
this.sasjsConfig.serverUrl === undefined ||
|
||||||
|
|||||||
@@ -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