mirror of
https://github.com/sasjs/adapter.git
synced 2025-12-25 15:01:20 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f27444bc52 | ||
|
|
de426c9a92 | ||
|
|
a006ead205 | ||
|
|
422c2a1fd5 | ||
|
|
0c6409e402 | ||
|
|
68b864cf75 | ||
|
|
75a11cdff4 |
@@ -206,9 +206,9 @@ export class SASViyaApiClient {
|
||||
silent = false,
|
||||
data = null,
|
||||
debug = false
|
||||
) {
|
||||
): Promise<any> {
|
||||
silent = !debug;
|
||||
|
||||
try {
|
||||
const headers: any = {
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
@@ -311,11 +311,13 @@ export class SASViyaApiClient {
|
||||
{
|
||||
headers,
|
||||
}
|
||||
).then((res: any) => res.result.items.map((i: any) => i.line).join("\n"));
|
||||
).then((res: any) =>
|
||||
res.result.items.map((i: any) => i.line).join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
if (jobStatus === "failed" || jobStatus === "error") {
|
||||
return Promise.reject({error: currentJob.error, log: log});
|
||||
return Promise.reject({ error: currentJob.error, log: log });
|
||||
}
|
||||
const resultLink = `/compute/sessions/${executionSessionId}/filerefs/_webout/content`;
|
||||
|
||||
@@ -332,12 +334,21 @@ export class SASViyaApiClient {
|
||||
await this.sessionManager.clearSession(executionSessionId, accessToken);
|
||||
|
||||
return { result: jobResult?.result, log };
|
||||
// } else {
|
||||
// console.error(
|
||||
// `Unable to find execution context ${contextName}.\nPlease check the contextName in the tgtDeployVars and try again.`
|
||||
// );
|
||||
// console.error("Response from server: ", JSON.stringify(this.contexts));
|
||||
// }
|
||||
} catch (e) {
|
||||
if (e && e.status === 404) {
|
||||
return this.executeScript(
|
||||
jobName,
|
||||
linesOfCode,
|
||||
contextName,
|
||||
accessToken,
|
||||
silent,
|
||||
data,
|
||||
debug
|
||||
);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -291,7 +291,7 @@ export default class SASjs {
|
||||
public async checkSession() {
|
||||
const loginResponse = await fetch(this.loginUrl.replace(".do", ""));
|
||||
const responseText = await loginResponse.text();
|
||||
const isLoggedIn = /You have signed in./gm.test(responseText);
|
||||
const isLoggedIn = /<button.+onClick.+logout/gm.test(responseText);
|
||||
|
||||
return Promise.resolve({
|
||||
isLoggedIn,
|
||||
@@ -730,7 +730,7 @@ export default class SASjs {
|
||||
}`;
|
||||
|
||||
const requestParams = {
|
||||
...this.getRequestParamsWeb(),
|
||||
...this.getRequestParamsWeb(config),
|
||||
};
|
||||
|
||||
const formData = new FormData();
|
||||
@@ -941,14 +941,14 @@ export default class SASjs {
|
||||
this.sasjsWaitingRequests = [];
|
||||
}
|
||||
|
||||
private getRequestParamsWeb(): any {
|
||||
private getRequestParamsWeb(config: any): any {
|
||||
const requestParams: any = {};
|
||||
|
||||
if (this.csrfTokenWeb) {
|
||||
requestParams["_csrf"] = this.csrfTokenWeb.value;
|
||||
}
|
||||
|
||||
if (this.sasjsConfig.debug) {
|
||||
if (config.debug) {
|
||||
requestParams["_omittextlog"] = "false";
|
||||
requestParams["_omitsessionresults"] = "false";
|
||||
|
||||
|
||||
@@ -17,6 +17,16 @@ export class SessionManager {
|
||||
await this.createSessions(accessToken);
|
||||
this.createAndWaitForSession(accessToken);
|
||||
const session = this.sessions.pop();
|
||||
const secondsSinceSessionCreation =
|
||||
(new Date().getTime() - new Date(session!.creationTimeStamp).getTime()) /
|
||||
1000;
|
||||
if (
|
||||
secondsSinceSessionCreation >= session!.attributes.sessionInactiveTimeout
|
||||
) {
|
||||
await this.createSessions(accessToken);
|
||||
const freshSession = this.sessions.pop();
|
||||
return freshSession;
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,4 +4,8 @@ export interface Session {
|
||||
id: string;
|
||||
state: string;
|
||||
links: Link[];
|
||||
attributes: {
|
||||
sessionInactiveTimeout: number;
|
||||
};
|
||||
creationTimeStamp: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user