1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 09:24:35 +00:00

Compare commits

...

14 Commits

Author SHA1 Message Date
Krishna Acondy
fa531b34fd Merge pull request #120 from sasjs/session-manager-debug
fix(debug): propagate debug value from SASjs config
2020-10-03 17:41:35 +01:00
Krishna Acondy
354443c98b fix(debug): propagate debug value from SASjs config 2020-10-03 16:53:00 +01:00
Krishna Acondy
ee30ab195f Merge pull request #115 from sasjs/issue-114
chore(error-message): updated error message for forbidden request
2020-10-01 09:10:35 +01:00
Yury Shkoda
02c1712d22 chore(error-message): updated error message for forbidden request 2020-10-01 09:49:24 +03:00
Krishna Acondy
37def7a956 Merge pull request #111 from sasjs/dependabot/npm_and_yarn/isomorphic-fetch-3.0.0
chore(deps): bump isomorphic-fetch from 2.2.1 to 3.0.0
2020-09-29 20:03:06 +01:00
Krishna Acondy
653e3d05e0 Merge branch 'master' into dependabot/npm_and_yarn/isomorphic-fetch-3.0.0 2020-09-29 19:55:08 +01:00
Yury Shkoda
d8467c24b1 Merge pull request #112 from sasjs/cli-issue-73
feat(folder-management): made folder related methods public
2020-09-28 15:16:33 +03:00
Yury Shkoda
fc9056c1ac chore(folder-management): made 'moveFolder' method public and fixed 'createFolder' method 2020-09-28 14:59:27 +03:00
Yury Shkoda
9b1d295b82 feat(folder): made 'deleteFolder' method public 2020-09-26 11:41:18 +03:00
dependabot-preview[bot]
e2ea3f4ddc chore(deps): bump isomorphic-fetch from 2.2.1 to 3.0.0
Bumps [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch) from 2.2.1 to 3.0.0.
- [Release notes](https://github.com/matthew-andrews/isomorphic-fetch/releases)
- [Commits](https://github.com/matthew-andrews/isomorphic-fetch/compare/v2.2.1...v3.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-25 23:51:17 +00:00
Allan Bowe
99d0b01a24 Update example.html 2020-09-24 23:00:37 +02:00
Yury Shkoda
131c672020 Merge pull request #110 from sasjs/cli-issue-105
fix(context): fixed 'ContextAllAttributes' interface
2020-09-24 17:10:14 +03:00
Yury Shkoda
338f2fb2dd Merge branch 'master' into cli-issue-105 2020-09-24 17:08:04 +03:00
Yury Shkoda
4552a9a856 fix(context): fixed 'ContextAllAttributes' interface 2020-09-24 16:51:50 +03:00
18 changed files with 4023 additions and 163 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -76,7 +76,7 @@
<section class="tsd-index-section ">
<h3>Modules</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-module tsd-is-not-exported"><a href="modules/reflection-759.html" class="tsd-kind-icon"><em>Module</em></a></li>
<li class="tsd-kind-module tsd-is-not-exported"><a href="modules/reflection-762.html" class="tsd-kind-icon"><em>Module</em></a></li>
<li class="tsd-kind-module"><a href="modules/types.html" class="tsd-kind-icon">types</a></li>
<li class="tsd-kind-module"><a href="modules/utils.html" class="tsd-kind-icon">utils</a></li>
</ul>

View File

@@ -93,6 +93,7 @@
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.contextallattributes.html#attributes" class="tsd-kind-icon">attributes</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.contextallattributes.html#createdby" class="tsd-kind-icon">createdBy</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.contextallattributes.html#creationtimestamp" class="tsd-kind-icon">creationTimeStamp</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.contextallattributes.html#environment" class="tsd-kind-icon">environment</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.contextallattributes.html#id" class="tsd-kind-icon">id</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.contextallattributes.html#launchcontext" class="tsd-kind-icon">launchContext</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.contextallattributes.html#launchtype" class="tsd-kind-icon">launchType</a></li>
@@ -160,6 +161,28 @@
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="environment" class="tsd-anchor"></a>
<h3>environment</h3>
<div class="tsd-signature tsd-kind-icon">environment<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">object</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in
<a href="https://github.com/sasjs/adapter/blob/master/src/types/Context.ts#L29">
types/Context.ts:29
</a>
</li>
</ul>
</aside>
<div class="tsd-type-declaration">
<h4>Type declaration</h4>
<ul class="tsd-parameters">
<li class="tsd-parameter">
<h5>auto<wbr>Exec<wbr>Lines<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">]</span></h5>
</li>
</ul>
</div>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="id" class="tsd-anchor"></a>
<h3>id</h3>
@@ -167,8 +190,8 @@
<aside class="tsd-sources">
<ul>
<li>Defined in
<a href="https://github.com/sasjs/adapter/blob/master/src/types/Context.ts#L33">
types/Context.ts:33
<a href="https://github.com/sasjs/adapter/blob/master/src/types/Context.ts#L36">
types/Context.ts:36
</a>
</li>
</ul>
@@ -181,8 +204,8 @@
<aside class="tsd-sources">
<ul>
<li>Defined in
<a href="https://github.com/sasjs/adapter/blob/master/src/types/Context.ts#L29">
types/Context.ts:29
<a href="https://github.com/sasjs/adapter/blob/master/src/types/Context.ts#L32">
types/Context.ts:32
</a>
</li>
</ul>
@@ -217,8 +240,8 @@
<aside class="tsd-sources">
<ul>
<li>Defined in
<a href="https://github.com/sasjs/adapter/blob/master/src/types/Context.ts#L32">
types/Context.ts:32
<a href="https://github.com/sasjs/adapter/blob/master/src/types/Context.ts#L35">
types/Context.ts:35
</a>
</li>
</ul>
@@ -245,8 +268,8 @@
<aside class="tsd-sources">
<ul>
<li>Defined in
<a href="https://github.com/sasjs/adapter/blob/master/src/types/Context.ts#L35">
types/Context.ts:35
<a href="https://github.com/sasjs/adapter/blob/master/src/types/Context.ts#L38">
types/Context.ts:38
</a>
</li>
</ul>
@@ -259,8 +282,8 @@
<aside class="tsd-sources">
<ul>
<li>Defined in
<a href="https://github.com/sasjs/adapter/blob/master/src/types/Context.ts#L34">
types/Context.ts:34
<a href="https://github.com/sasjs/adapter/blob/master/src/types/Context.ts#L37">
types/Context.ts:37
</a>
</li>
</ul>
@@ -298,6 +321,9 @@
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="types.contextallattributes.html#creationtimestamp" class="tsd-kind-icon">creation<wbr>Time<wbr>Stamp</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="types.contextallattributes.html#environment" class="tsd-kind-icon">environment</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="types.contextallattributes.html#id" class="tsd-kind-icon">id</a>
</li>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -30,8 +30,8 @@
$('#chart-container').append('<canvas id="myChart" style="display: none;"></canvas>')
// make a request to a SAS service
var type = $("#cars")[0].options[$("#cars")[0].selectedIndex].value;
// request data from an endpoint under your appLoc
sasJs.request("/common/getdata", {
// request data from an endpoint under your appLoc (missing opening slash implies relative path)
sasJs.request("common/getdata", {
// send data as an array of objects - each object is one row
fromjs: [{ type: type }]
}).then((response) => {

45
package-lock.json generated
View File

@@ -3703,14 +3703,6 @@
"integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==",
"dev": true
},
"encoding": {
"version": "0.1.12",
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
"integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=",
"requires": {
"iconv-lite": "~0.4.13"
}
},
"end-of-stream": {
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
@@ -4967,6 +4959,7 @@
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"dev": true,
"requires": {
"safer-buffer": ">= 2.1.2 < 3"
}
@@ -5256,7 +5249,8 @@
"is-stream": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ="
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=",
"dev": true
},
"is-text-path": {
"version": "1.0.1",
@@ -5304,23 +5298,12 @@
"dev": true
},
"isomorphic-fetch": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz",
"integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-3.0.0.tgz",
"integrity": "sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA==",
"requires": {
"node-fetch": "^1.0.1",
"whatwg-fetch": ">=0.10.0"
},
"dependencies": {
"node-fetch": {
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
"integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==",
"requires": {
"encoding": "^0.1.11",
"is-stream": "^1.0.1"
}
}
"node-fetch": "^2.6.1",
"whatwg-fetch": "^3.4.1"
}
},
"isstream": {
@@ -8475,8 +8458,7 @@
"node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
"dev": true
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
},
"node-int64": {
"version": "0.4.0",
@@ -13577,7 +13559,8 @@
"safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"dev": true
},
"sane": {
"version": "4.1.0",
@@ -16070,9 +16053,9 @@
}
},
"whatwg-fetch": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz",
"integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q=="
"version": "3.4.1",
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.4.1.tgz",
"integrity": "sha512-sofZVzE1wKwO+EYPbWfiwzaKovWiZXf4coEzjGP9b2GBVgQRLQUZ2QcuPpQExGDAW5GItpEm6Tl4OU5mywnAoQ=="
},
"whatwg-mimetype": {
"version": "2.3.0",

View File

@@ -59,6 +59,6 @@
"dependencies": {
"es6-promise": "^4.2.8",
"form-data": "^3.0.0",
"isomorphic-fetch": "^2.2.1"
"isomorphic-fetch": "^3.0.0"
}
}

View File

@@ -38,14 +38,23 @@ export class SASViyaApiClient {
private csrfToken: CsrfToken | null = null
private fileUploadCsrfToken: CsrfToken | null = null
private _debug = false
private sessionManager = new SessionManager(
this.serverUrl,
this.contextName,
this.setCsrfToken
)
private isForceDeploy: boolean = false
private folderMap = new Map<string, Job[]>()
public get debug() {
return this._debug
}
public set debug(value: boolean) {
this._debug = value
this.sessionManager.debug = value
}
/**
* Returns a list of jobs in the currently set root folder.
*/
@@ -141,7 +150,6 @@ export class SASViyaApiClient {
linesOfCode,
context.name,
accessToken,
false,
null,
true
).catch(() => null)
@@ -405,7 +413,6 @@ export class SASViyaApiClient {
* @param contextName - the context to execute the code in.
* @param accessToken - an access token for an authorized user.
* @param sessionId - optional session ID to reuse.
* @param silent - optional flag to disable logging.
* @param data - execution data.
* @param debug - when set to true, the log will be returned.
* @param expectWebout - when set to true, the automatic _webout fileref will be checked for content, and that content returned. This fileref is used when the Job contains a SASjs web request (as opposed to executing arbitrary SAS code).
@@ -415,12 +422,9 @@ export class SASViyaApiClient {
linesOfCode: string[],
contextName: string,
accessToken?: string,
silent = false,
data = null,
debug = false,
expectWebout = false
): Promise<any> {
silent = !debug
try {
const headers: any = {
'Content-Type': 'application/json'
@@ -443,7 +447,7 @@ export class SASViyaApiClient {
_OMITTEXTLOG: true
}
if (debug) {
if (this.debug) {
jobArguments['_OMITTEXTLOG'] = false
jobArguments['_OMITSESSIONRESULTS'] = false
jobArguments['_DEBUG'] = 131
@@ -503,7 +507,7 @@ export class SASViyaApiClient {
postJobRequest
)
if (!silent) {
if (this.debug) {
console.log(`Job has been submitted for '${fileName}'.`)
console.log(
`You can monitor the job progress at '${this.serverUrl}${
@@ -512,12 +516,7 @@ export class SASViyaApiClient {
)
}
const jobStatus = await this.pollJobState(
postedJob,
etag,
accessToken,
silent
)
const jobStatus = await this.pollJobState(postedJob, etag, accessToken)
const { result: currentJob } = await this.request<Job>(
`${this.serverUrl}/compute/sessions/${executionSessionId}/jobs/${postedJob.id}`,
@@ -529,7 +528,7 @@ export class SASViyaApiClient {
const logLink = currentJob.links.find((l) => l.rel === 'log')
if (debug && logLink) {
if (this.debug && logLink) {
log = await this.request<any>(
`${this.serverUrl}${logLink.href}/content?limit=10000`,
{
@@ -591,9 +590,7 @@ export class SASViyaApiClient {
linesOfCode,
contextName,
accessToken,
silent,
data,
debug
data
)
} else {
throw e
@@ -625,8 +622,6 @@ export class SASViyaApiClient {
if (!parentFolderUri && parentFolderPath) {
parentFolderUri = await this.getFolderUri(parentFolderPath, accessToken)
if (!parentFolderUri) {
if (isForced) this.isForceDeploy = true
console.log(
`Parent folder at path '${parentFolderPath}' is not present.`
)
@@ -652,37 +647,16 @@ export class SASViyaApiClient {
`Parent folder '${newFolderName}' has been successfully created.`
)
parentFolderUri = `/folders/folders/${parentFolder.id}`
} else if (isForced && accessToken && !this.isForceDeploy) {
this.isForceDeploy = true
} else if (isForced && accessToken) {
const folderPath = parentFolderPath + '/' + folderName
const folderUri = await this.getFolderUri(folderPath, accessToken)
await this.deleteFolder(parentFolderPath, accessToken)
const newParentFolderPath = parentFolderPath.substring(
0,
parentFolderPath.lastIndexOf('/')
)
const newFolderName = `${parentFolderPath.split('/').pop()}`
if (newParentFolderPath === '') {
throw new Error(`Root folder has to be present on the server.`)
if (folderUri) {
await this.deleteFolder(
parentFolderPath + '/' + folderName,
accessToken
)
}
console.log(
`Creating parent folder:\n'${newFolderName}' in '${newParentFolderPath}'`
)
const parentFolder = await this.createFolder(
newFolderName,
newParentFolderPath,
undefined,
accessToken
)
console.log(
`Parent folder '${newFolderName}' has been successfully created.`
)
parentFolderUri = `/folders/folders/${parentFolder.id}`
}
}
@@ -1015,9 +989,7 @@ export class SASViyaApiClient {
linesToExecute,
contextName,
accessToken,
true,
data,
debug,
true
)
}
@@ -1149,12 +1121,7 @@ export class SASViyaApiClient {
`${this.serverUrl}/jobExecution/jobs?_action=wait`,
postJobRequest
)
const jobStatus = await this.pollJobState(
postedJob,
etag,
accessToken,
true
)
const jobStatus = await this.pollJobState(postedJob, etag, accessToken)
const { result: currentJob } = await this.request<Job>(
`${this.serverUrl}/jobExecution/jobs/${postedJob.id}`,
{ headers }
@@ -1219,8 +1186,7 @@ export class SASViyaApiClient {
private async pollJobState(
postedJob: any,
etag: string | null,
accessToken?: string,
silent = false
accessToken?: string
) {
const MAX_POLL_COUNT = 1000
const POLL_INTERVAL = 100
@@ -1259,7 +1225,7 @@ export class SASViyaApiClient {
postedJobState === 'pending'
) {
if (stateLink) {
if (!silent) {
if (this.debug) {
console.log('Polling job status... \n')
}
const { result: jobState } = await this.request<string>(
@@ -1271,7 +1237,7 @@ export class SASViyaApiClient {
)
postedJobState = jobState.trim()
if (!silent) {
if (this.debug) {
console.log(`Current state: ${postedJobState}\n`)
}
pollCount++
@@ -1287,49 +1253,6 @@ export class SASViyaApiClient {
})
}
private async waitForSession(
session: Session,
etag: string | null,
accessToken?: string,
silent = false
) {
let sessionState = session.state
let pollCount = 0
const headers: any = {
'Content-Type': 'application/json',
'If-None-Match': etag
}
if (accessToken) {
headers.Authorization = `Bearer ${accessToken}`
}
const stateLink = session.links.find((l: any) => l.rel === 'state')
return new Promise(async (resolve, _) => {
if (sessionState === 'pending') {
if (stateLink) {
if (!silent) {
console.log('Polling session status... \n')
}
const { result: state } = await this.request<string>(
`${this.serverUrl}${stateLink.href}?wait=30`,
{
headers
},
'text'
)
sessionState = state.trim()
if (!silent) {
console.log(`Current state: ${sessionState}\n`)
}
pollCount++
resolve(sessionState)
}
} else {
resolve(sessionState)
}
})
}
private async uploadTables(data: any, accessToken?: string) {
const uploadedFiles = []
const headers: any = {
@@ -1508,6 +1431,16 @@ export class SASViyaApiClient {
`${this.serverUrl}${url}`,
requestInfo
).catch((err) => {
if (err.code && err.code === 'ENOTFOUND') {
const notFoundError = {
body: JSON.stringify({
message: `Folder '${sourceFolder.split('/').pop()}' was not found.`
})
}
throw notFoundError
}
throw err
})

View File

@@ -209,9 +209,7 @@ export default class SASjs {
fileName: string,
linesOfCode: string[],
contextName: string,
accessToken?: string,
sessionId = '',
silent = false
accessToken?: string
) {
this.isMethodSupported('executeScriptSASViya', ServerType.SASViya)
@@ -220,9 +218,7 @@ export default class SASjs {
linesOfCode,
contextName,
accessToken,
silent,
null,
this.sasjsConfig.debug
null
)
}
@@ -243,8 +239,6 @@ export default class SASjs {
sasApiClient?: SASViyaApiClient,
isForced?: boolean
) {
this.isMethodSupported('createFolder', ServerType.SASViya)
if (sasApiClient)
return await sasApiClient.createFolder(
folderName,
@@ -261,6 +255,40 @@ export default class SASjs {
)
}
/**
* For performance (and in case of accidental error) the `deleteFolder` function does not actually delete the folder (and all its content and subfolder content). Instead the folder is simply moved to the recycle bin. Deletion time will be added to the folder name.
* @param folderPath - the full path (eg `/Public/example/deleteThis`) of the folder to be deleted.
* @param accessToken - an access token for authorizing the request.
*/
public async deleteFolder(folderPath: string, accessToken: string) {
this.isMethodSupported('deleteFolder', ServerType.SASViya)
return await this.sasViyaApiClient?.deleteFolder(folderPath, accessToken)
}
/**
* Moves folder to a new location. The folder may be renamed at the same time.
* @param sourceFolder - the full path (eg `/Public/example/myFolder`) or URI of the source folder to be moved. Providing URI instead of path will save one extra request.
* @param targetParentFolder - the full path or URI of the _parent_ folder to which the `sourceFolder` will be moved (eg `/Public/newDestination`). To move a folder, a user has to have write permissions in targetParentFolder. Providing URI instead of path will save one extra request.
* @param targetFolderName - the name of the "moved" folder. If left blank, the original folder name will be used (eg `myFolder` in `/Public/newDestination/myFolder` for the example above). Optional field.
* @param accessToken - an access token for authorizing the request.
*/
public async moveFolder(
sourceFolder: string,
targetParentFolder: string,
targetFolderName: string,
accessToken: string
) {
this.isMethodSupported('moveFolder', ServerType.SASViya)
return await this.sasViyaApiClient?.moveFolder(
sourceFolder,
targetParentFolder,
targetFolderName,
accessToken
)
}
public async createJobDefinition(
jobName: string,
code: string,
@@ -378,6 +406,9 @@ export default class SASjs {
*/
public setDebugState(value: boolean) {
this.sasjsConfig.debug = value
if (this.sasViyaApiClient) {
this.sasViyaApiClient.debug = value
}
}
/**
@@ -603,6 +634,7 @@ export default class SASjs {
this.sasjsConfig.contextName,
this.setCsrfTokenApi
)
sasApiClient.debug = this.sasjsConfig.debug
} else if (this.sasjsConfig.serverType === ServerType.SAS9) {
sasApiClient = new SAS9ApiClient(serverUrl)
}
@@ -1320,6 +1352,8 @@ export default class SASjs {
this.sasjsConfig.contextName,
this.setCsrfTokenApi
)
this.sasViyaApiClient.debug = this.sasjsConfig.debug
}
if (this.sasjsConfig.serverType === ServerType.SAS9) {
if (this.sas9ApiClient)

View File

@@ -15,6 +15,15 @@ export class SessionManager {
private sessions: Session[] = []
private currentContext: Context | null = null
private csrfToken: CsrfToken | null = null
private _debug: boolean = false
public get debug() {
return this._debug
}
public set debug(value: boolean) {
this._debug = value
}
async getSession(accessToken?: string) {
await this.createSessions(accessToken)
@@ -115,8 +124,7 @@ export class SessionManager {
private async waitForSession(
session: Session,
etag: string | null,
accessToken?: string,
silent = false
accessToken?: string
) {
let sessionState = session.state
const headers: any = {
@@ -127,7 +135,7 @@ export class SessionManager {
return new Promise(async (resolve, _) => {
if (sessionState === 'pending') {
if (stateLink) {
if (!silent) {
if (this.debug) {
console.log('Polling session status... \n') // ?
}
const { result: state } = await this.request<string>(
@@ -139,7 +147,7 @@ export class SessionManager {
)
sessionState = state.trim()
if (!silent) {
if (this.debug) {
console.log(`Current state is '${sessionState}'\n`)
}
resolve(sessionState)

View File

@@ -26,6 +26,9 @@ export interface ContextAllAttributes {
createdBy: string
creationTimeStamp: string
launchType: string
environment: {
autoExecLines: [string]
}
launchContext: {
contextName: string
}

View File

@@ -48,7 +48,7 @@ export async function makeRequest<T>(
try {
body = JSON.parse(body)
body.message = `Forbidden. Check your permissions and user groups. ${
body.message = `Forbidden. Check your permissions and user groups, and also the scopes granted when registering your CLIENT_ID. ${
body.message || ''
}`