mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-07 04:20:05 +00:00
fix(*): expose CSRF token, add getFolder API
This commit is contained in:
@@ -495,6 +495,17 @@ export class SASViyaApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a folder. Path to the folder is required.
|
||||
* @param folderPath - the absolute path to the folder.
|
||||
* @param accessToken - an access token for authorizing the request.
|
||||
*/
|
||||
public async getFolder(folderPath: string, accessToken?: string) {
|
||||
return await this.requestClient
|
||||
.get(`/folders/folders/@item?path=${folderPath}`, accessToken)
|
||||
.then((res) => res.result)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a folder. Path to or URI of the parent folder is required.
|
||||
* @param folderName - the name of the new folder.
|
||||
|
||||
14
src/SASjs.ts
14
src/SASjs.ts
@@ -50,6 +50,10 @@ export default class SASjs {
|
||||
this.setupConfiguration()
|
||||
}
|
||||
|
||||
public getCsrfToken(type: 'general' | 'file' = 'general') {
|
||||
return this.requestClient?.getCsrfToken(type)
|
||||
}
|
||||
|
||||
public async executeScriptSAS9(
|
||||
linesOfCode: string[],
|
||||
serverName: string,
|
||||
@@ -292,6 +296,16 @@ export default class SASjs {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a folder from the SAS file system.
|
||||
* @param folderPath - path of the folder to be fetched.
|
||||
* @param accessToken - the access token to authorize the request.
|
||||
*/
|
||||
public async getFolder(folderPath: string, accessToken?: string) {
|
||||
this.isMethodSupported('getFolder', ServerType.SasViya)
|
||||
return await this.sasViyaApiClient!.getFolder(folderPath, accessToken)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -60,13 +60,7 @@ export class AuthManager {
|
||||
}
|
||||
)
|
||||
|
||||
let loggedIn
|
||||
|
||||
if (isAuthorizeFormRequired(loginResponse)) {
|
||||
await this.requestClient.authorize(loginResponse)
|
||||
} else {
|
||||
loggedIn = isLogInSuccess(loginResponse)
|
||||
}
|
||||
let loggedIn = isLogInSuccess(loginResponse)
|
||||
|
||||
if (!loggedIn) {
|
||||
const currentSession = await this.checkSession()
|
||||
|
||||
Reference in New Issue
Block a user