mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-19 10:00:06 +00:00
Merge branch 'api-execution' of https://github.com/sasjs/adapter into issue17
This commit is contained in:
File diff suppressed because one or more lines are too long
294
docs/classes/reflection-560.reflection-1.sas9apiclient.html
Normal file
294
docs/classes/reflection-560.reflection-1.sas9apiclient.html
Normal file
File diff suppressed because one or more lines are too long
934
docs/classes/reflection-560.reflection-1.sasjs.html
Normal file
934
docs/classes/reflection-560.reflection-1.sasjs.html
Normal file
File diff suppressed because one or more lines are too long
892
docs/classes/reflection-560.reflection-1.sasviyaapiclient.html
Normal file
892
docs/classes/reflection-560.reflection-1.sasviyaapiclient.html
Normal file
File diff suppressed because one or more lines are too long
206
docs/classes/reflection-560.reflection-1.sessionmanager.html
Normal file
206
docs/classes/reflection-560.reflection-1.sessionmanager.html
Normal file
File diff suppressed because one or more lines are too long
@@ -319,7 +319,7 @@
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in SASjs.ts:465</li>
|
||||
<li>Defined in SASjs.ts:473</li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography tsd-comment-shorttext">
|
||||
@@ -587,7 +587,7 @@
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in SASjs.ts:1071</li>
|
||||
<li>Defined in SASjs.ts:1065</li>
|
||||
</ul>
|
||||
</aside>
|
||||
<h4 class="tsd-returns-title">Returns <a href="../interfaces/types.sasjsrequest.html" class="tsd-signature-type">SASjsRequest</a><span class="tsd-signature-symbol">[]</span></h4>
|
||||
@@ -730,13 +730,13 @@
|
||||
<a name="request" class="tsd-anchor"></a>
|
||||
<h3>request</h3>
|
||||
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
|
||||
<li class="tsd-signature tsd-kind-icon">request<span class="tsd-signature-symbol">(</span>sasJob<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, params<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span>, loginRequiredCallback<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span>, accessToken<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></li>
|
||||
<li class="tsd-signature tsd-kind-icon">request<span class="tsd-signature-symbol">(</span>sasJob<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, data<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, config<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span>, loginRequiredCallback<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span>, accessToken<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></li>
|
||||
</ul>
|
||||
<ul class="tsd-descriptions">
|
||||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in SASjs.ts:415</li>
|
||||
<li>Defined in SASjs.ts:416</li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography tsd-comment-shorttext">
|
||||
@@ -765,10 +765,11 @@
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<h5><span class="tsd-flag ts-flagOptional">Optional</span> params: <span class="tsd-signature-type">any</span></h5>
|
||||
<h5><span class="tsd-flag ts-flagDefault value">Default value</span> config: <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> = {}</span></h5>
|
||||
<div class="tsd-comment tsd-typography tsd-comment-text">
|
||||
<p>Provide any changes to the config here, for instance to
|
||||
enable / disable <code>debug</code>.</p>
|
||||
enable / disable <code>debug</code>. Any change provided will override the global config,
|
||||
for that particular function call.</p>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@@ -96,8 +96,8 @@
|
||||
<h3>Properties</h3>
|
||||
<ul class="tsd-index-list">
|
||||
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.sasjswaitingrequest.html#sasjob" class="tsd-kind-icon">SASjob</a></li>
|
||||
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.sasjswaitingrequest.html#config" class="tsd-kind-icon">config</a></li>
|
||||
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.sasjswaitingrequest.html#data" class="tsd-kind-icon">data</a></li>
|
||||
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.sasjswaitingrequest.html#params" class="tsd-kind-icon">params</a></li>
|
||||
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.sasjswaitingrequest.html#requestpromise" class="tsd-kind-icon">requestPromise</a></li>
|
||||
</ul>
|
||||
</section>
|
||||
@@ -116,6 +116,16 @@
|
||||
</ul>
|
||||
</aside>
|
||||
</section>
|
||||
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
|
||||
<a name="config" class="tsd-anchor"></a>
|
||||
<h3><span class="tsd-flag ts-flagOptional">Optional</span> config</h3>
|
||||
<div class="tsd-signature tsd-kind-icon">config<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in types/SASjsWaitingRequest.ts:13</li>
|
||||
</ul>
|
||||
</aside>
|
||||
</section>
|
||||
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
|
||||
<a name="data" class="tsd-anchor"></a>
|
||||
<h3>data</h3>
|
||||
@@ -126,16 +136,6 @@
|
||||
</ul>
|
||||
</aside>
|
||||
</section>
|
||||
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
|
||||
<a name="params" class="tsd-anchor"></a>
|
||||
<h3><span class="tsd-flag ts-flagOptional">Optional</span> params</h3>
|
||||
<div class="tsd-signature tsd-kind-icon">params<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in types/SASjsWaitingRequest.ts:13</li>
|
||||
</ul>
|
||||
</aside>
|
||||
</section>
|
||||
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
|
||||
<a name="requestpromise" class="tsd-anchor"></a>
|
||||
<h3>request<wbr>Promise</h3>
|
||||
@@ -205,10 +205,10 @@
|
||||
<a href="types.sasjswaitingrequest.html#sasjob" class="tsd-kind-icon">SASjob</a>
|
||||
</li>
|
||||
<li class=" tsd-kind-property tsd-parent-kind-interface">
|
||||
<a href="types.sasjswaitingrequest.html#data" class="tsd-kind-icon">data</a>
|
||||
<a href="types.sasjswaitingrequest.html#config" class="tsd-kind-icon">config</a>
|
||||
</li>
|
||||
<li class=" tsd-kind-property tsd-parent-kind-interface">
|
||||
<a href="types.sasjswaitingrequest.html#params" class="tsd-kind-icon">params</a>
|
||||
<a href="types.sasjswaitingrequest.html#data" class="tsd-kind-icon">data</a>
|
||||
</li>
|
||||
<li class=" tsd-kind-property tsd-parent-kind-interface">
|
||||
<a href="types.sasjswaitingrequest.html#requestpromise" class="tsd-kind-icon">request<wbr>Promise</a>
|
||||
|
||||
107
docs/modules/reflection-560.html
Normal file
107
docs/modules/reflection-560.html
Normal file
File diff suppressed because one or more lines are too long
125
docs/modules/reflection-560.reflection-1.html
Normal file
125
docs/modules/reflection-560.reflection-1.html
Normal file
File diff suppressed because one or more lines are too long
@@ -24,7 +24,7 @@
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject",
|
||||
"deploy": "npm run build && rsync -avhe ssh ./build/* --delete kriaco@sas.analytium.co.uk:/var/www/html/kriaco/sasjs-tests"
|
||||
"deploy": "cd .. && npm run package:lib && cd sasjs-tests && npm i ../build/sasjs-adapter-5.0.0.tgz && npm run build && rsync -avhe ssh ./build/* --delete kriaco@sas.analytium.co.uk:/var/www/html/kriaco/sasjs-tests"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "react-app"
|
||||
|
||||
100
src/SASjs.ts
100
src/SASjs.ts
@@ -44,7 +44,7 @@ const requestRetryLimit = 5;
|
||||
*
|
||||
*/
|
||||
export default class SASjs {
|
||||
private sasjsConfig = new SASjsConfig();
|
||||
private sasjsConfig: SASjsConfig = new SASjsConfig();
|
||||
private jobsPath: string = "";
|
||||
private logoutUrl: string = "";
|
||||
private loginUrl: string = "";
|
||||
@@ -406,8 +406,9 @@ export default class SASjs {
|
||||
* Process.) Is prepended at runtime with the value of `appLoc`.
|
||||
* @param data - A JSON object containing one or more tables to be sent to
|
||||
* SAS. Can be `null` if no inputs required.
|
||||
* @param params - Provide any changes to the config here, for instance to
|
||||
* enable / disable `debug`.
|
||||
* @param config - Provide any changes to the config here, for instance to
|
||||
* enable / disable `debug`. Any change provided will override the global config,
|
||||
* for that particular function call.
|
||||
* @param loginRequiredCallback - provide a function here to be called if the
|
||||
* user is not logged in (eg to display a login form). The request will be
|
||||
* resubmitted after logon.
|
||||
@@ -415,40 +416,47 @@ export default class SASjs {
|
||||
public async request(
|
||||
sasJob: string,
|
||||
data: any,
|
||||
params?: any,
|
||||
config: any = {},
|
||||
loginRequiredCallback?: any,
|
||||
accessToken?: string
|
||||
) {
|
||||
let requestResponse;
|
||||
|
||||
config = {
|
||||
...this.sasjsConfig,
|
||||
...config,
|
||||
};
|
||||
|
||||
sasJob = sasJob.startsWith("/") ? sasJob.replace("/", "") : sasJob;
|
||||
if (
|
||||
this.sasjsConfig.serverType === ServerType.SASViya &&
|
||||
this.sasjsConfig.contextName
|
||||
) {
|
||||
if (this.sasjsConfig.useComputeApi) {
|
||||
return await this.executeJobViaComputeApi(
|
||||
|
||||
if (config.serverType === ServerType.SASViya && config.contextName) {
|
||||
if (config.useComputeApi) {
|
||||
requestResponse = await this.executeJobViaComputeApi(
|
||||
sasJob,
|
||||
data,
|
||||
params,
|
||||
config,
|
||||
loginRequiredCallback,
|
||||
accessToken
|
||||
);
|
||||
} else {
|
||||
return await this.executeJobViaJesApi(
|
||||
requestResponse = await this.executeJobViaJesApi(
|
||||
sasJob,
|
||||
data,
|
||||
params,
|
||||
config,
|
||||
loginRequiredCallback,
|
||||
accessToken
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return await this.executeJobViaJes(
|
||||
requestResponse = await this.executeJobViaWeb(
|
||||
sasJob,
|
||||
data,
|
||||
params,
|
||||
config,
|
||||
loginRequiredCallback
|
||||
);
|
||||
}
|
||||
|
||||
return requestResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -515,7 +523,7 @@ export default class SASjs {
|
||||
private async executeJobViaComputeApi(
|
||||
sasJob: string,
|
||||
data: any,
|
||||
params?: any,
|
||||
config: any,
|
||||
loginRequiredCallback?: any,
|
||||
accessToken?: string
|
||||
) {
|
||||
@@ -527,7 +535,6 @@ export default class SASjs {
|
||||
},
|
||||
SASjob: sasJob,
|
||||
data,
|
||||
params,
|
||||
};
|
||||
|
||||
sasjsWaitingRequest.requestPromise.promise = new Promise(
|
||||
@@ -536,13 +543,13 @@ export default class SASjs {
|
||||
await this.sasViyaApiClient
|
||||
?.executeComputeJob(
|
||||
sasJob,
|
||||
this.sasjsConfig.contextName,
|
||||
this.sasjsConfig.debug,
|
||||
config.contextName,
|
||||
config.debug,
|
||||
data,
|
||||
accessToken
|
||||
)
|
||||
.then((response) => {
|
||||
if (!this.sasjsConfig.debug) {
|
||||
if (!config.debug) {
|
||||
this.appendSasjsRequest(null, sasJob, null);
|
||||
} else {
|
||||
this.appendSasjsRequest(response, sasJob, null);
|
||||
@@ -554,6 +561,7 @@ export default class SASjs {
|
||||
if (loginRequiredCallback) loginRequiredCallback(true);
|
||||
sasjsWaitingRequest.requestPromise.resolve = resolve;
|
||||
sasjsWaitingRequest.requestPromise.reject = reject;
|
||||
sasjsWaitingRequest.config = config;
|
||||
this.sasjsWaitingRequests.push(sasjsWaitingRequest);
|
||||
} else {
|
||||
reject({ MESSAGE: e || "Job execution failed" });
|
||||
@@ -568,7 +576,7 @@ export default class SASjs {
|
||||
private async executeJobViaJesApi(
|
||||
sasJob: string,
|
||||
data: any,
|
||||
params?: any,
|
||||
config: any,
|
||||
loginRequiredCallback?: any,
|
||||
accessToken?: string
|
||||
) {
|
||||
@@ -580,7 +588,6 @@ export default class SASjs {
|
||||
},
|
||||
SASjob: sasJob,
|
||||
data,
|
||||
params,
|
||||
};
|
||||
|
||||
sasjsWaitingRequest.requestPromise.promise = new Promise(
|
||||
@@ -591,19 +598,20 @@ export default class SASjs {
|
||||
if (loginRequiredCallback) loginRequiredCallback(true);
|
||||
sasjsWaitingRequest.requestPromise.resolve = resolve;
|
||||
sasjsWaitingRequest.requestPromise.reject = reject;
|
||||
sasjsWaitingRequest.config = config;
|
||||
this.sasjsWaitingRequests.push(sasjsWaitingRequest);
|
||||
} else {
|
||||
resolve(
|
||||
await this.sasViyaApiClient
|
||||
?.executeJob(
|
||||
sasJob,
|
||||
this.sasjsConfig.contextName,
|
||||
this.sasjsConfig.debug,
|
||||
config.contextName,
|
||||
config.debug,
|
||||
data,
|
||||
accessToken
|
||||
)
|
||||
.then((response) => {
|
||||
if (!this.sasjsConfig.debug) {
|
||||
if (!config.debug) {
|
||||
this.appendSasjsRequest(null, sasJob, null);
|
||||
} else {
|
||||
this.appendSasjsRequest(response, sasJob, null);
|
||||
@@ -620,10 +628,10 @@ export default class SASjs {
|
||||
return sasjsWaitingRequest.requestPromise.promise;
|
||||
}
|
||||
|
||||
private async executeJobViaJes(
|
||||
private async executeJobViaWeb(
|
||||
sasJob: string,
|
||||
data: any,
|
||||
params?: any,
|
||||
config: any,
|
||||
loginRequiredCallback?: any
|
||||
) {
|
||||
const sasjsWaitingRequest: SASjsWaitingRequest = {
|
||||
@@ -634,24 +642,19 @@ export default class SASjs {
|
||||
},
|
||||
SASjob: sasJob,
|
||||
data,
|
||||
params,
|
||||
};
|
||||
const program = this.sasjsConfig.appLoc
|
||||
? this.sasjsConfig.appLoc.replace(/\/?$/, "/") + sasJob.replace(/^\//, "")
|
||||
const program = config.appLoc
|
||||
? config.appLoc.replace(/\/?$/, "/") + sasJob.replace(/^\//, "")
|
||||
: sasJob;
|
||||
const jobUri =
|
||||
this.sasjsConfig.serverType === "SASVIYA"
|
||||
? await this.getJobUri(sasJob)
|
||||
: "";
|
||||
const apiUrl = `${this.sasjsConfig.serverUrl}${this.jobsPath}/?${
|
||||
config.serverType === "SASVIYA" ? await this.getJobUri(sasJob) : "";
|
||||
const apiUrl = `${config.serverUrl}${this.jobsPath}/?${
|
||||
jobUri.length > 0
|
||||
? "__program=" + program + "&_job=" + jobUri
|
||||
: "_program=" + program
|
||||
}`;
|
||||
|
||||
const inputParams = params ? params : {};
|
||||
const requestParams = {
|
||||
...inputParams,
|
||||
...this.getRequestParamsWeb(),
|
||||
};
|
||||
|
||||
@@ -663,7 +666,7 @@ export default class SASjs {
|
||||
if (data) {
|
||||
const stringifiedData = JSON.stringify(data);
|
||||
if (
|
||||
this.sasjsConfig.serverType === ServerType.SAS9 ||
|
||||
config.serverType === ServerType.SAS9 ||
|
||||
stringifiedData.length > 500000 ||
|
||||
stringifiedData.includes(";")
|
||||
) {
|
||||
@@ -755,10 +758,7 @@ export default class SASjs {
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
response.redirected &&
|
||||
this.sasjsConfig.serverType === ServerType.SAS9
|
||||
) {
|
||||
if (response.redirected && config.serverType === ServerType.SAS9) {
|
||||
isRedirected = true;
|
||||
}
|
||||
|
||||
@@ -771,7 +771,7 @@ export default class SASjs {
|
||||
) {
|
||||
if (this.retryCountRequest < requestRetryLimit) {
|
||||
this.retryCountRequest++;
|
||||
this.request(sasJob, data, params).then(
|
||||
this.request(sasJob, data).then(
|
||||
(res: any) => resolve(res),
|
||||
(err: any) => reject(err)
|
||||
);
|
||||
@@ -787,12 +787,10 @@ export default class SASjs {
|
||||
if (loginRequiredCallback) loginRequiredCallback(true);
|
||||
sasjsWaitingRequest.requestPromise.resolve = resolve;
|
||||
sasjsWaitingRequest.requestPromise.reject = reject;
|
||||
sasjsWaitingRequest.config = config;
|
||||
this.sasjsWaitingRequests.push(sasjsWaitingRequest);
|
||||
} else {
|
||||
if (
|
||||
this.sasjsConfig.serverType === ServerType.SAS9 &&
|
||||
this.sasjsConfig.debug
|
||||
) {
|
||||
if (config.serverType === ServerType.SAS9 && config.debug) {
|
||||
this.updateUsername(responseText);
|
||||
const jsonResponseText = this.parseSAS9Response(responseText);
|
||||
|
||||
@@ -804,8 +802,8 @@ export default class SASjs {
|
||||
});
|
||||
}
|
||||
} else if (
|
||||
this.sasjsConfig.serverType === ServerType.SASViya &&
|
||||
this.sasjsConfig.debug
|
||||
config.serverType === ServerType.SASViya &&
|
||||
config.debug
|
||||
) {
|
||||
try {
|
||||
this.parseSASVIYADebugResponse(responseText).then(
|
||||
@@ -851,11 +849,7 @@ export default class SASjs {
|
||||
|
||||
private async resendWaitingRequests() {
|
||||
for (const sasjsWaitingRequest of this.sasjsWaitingRequests) {
|
||||
this.request(
|
||||
sasjsWaitingRequest.SASjob,
|
||||
sasjsWaitingRequest.data,
|
||||
sasjsWaitingRequest.params
|
||||
).then(
|
||||
this.request(sasjsWaitingRequest.SASjob, sasjsWaitingRequest.data).then(
|
||||
(res: any) => {
|
||||
sasjsWaitingRequest.requestPromise.resolve(res);
|
||||
},
|
||||
|
||||
@@ -10,5 +10,5 @@ export interface SASjsWaitingRequest {
|
||||
};
|
||||
SASjob: string;
|
||||
data: any;
|
||||
params?: any;
|
||||
config?: any;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user