mirror of
https://github.com/sasjs/adapter.git
synced 2025-12-11 01:14:36 +00:00
fix: remove serverurl argument from createFolder method and move decode token to utils project
This commit is contained in:
@@ -28,10 +28,16 @@ import { ContextManager } from './ContextManager'
|
||||
import { timestampToYYYYMMDDHHMMSS } from '@sasjs/utils/time'
|
||||
import {
|
||||
isAccessTokenExpiring,
|
||||
isRefreshTokenExpiring
|
||||
isRefreshTokenExpiring,
|
||||
decodeToken
|
||||
} from '@sasjs/utils/auth'
|
||||
import { Logger, LogLevel } from '@sasjs/utils/logger'
|
||||
import { SasAuthResponse, MacroVar, AuthConfig } from '@sasjs/utils/types'
|
||||
import {
|
||||
SasAuthResponse,
|
||||
MacroVar,
|
||||
AuthConfig,
|
||||
DecodedToken
|
||||
} from '@sasjs/utils/types'
|
||||
import { isAuthorizeFormRequired } from './auth/isAuthorizeFormRequired'
|
||||
import { RequestClient } from './request/RequestClient'
|
||||
import { prefixMessage } from '@sasjs/utils/error'
|
||||
@@ -611,8 +617,7 @@ export class SASViyaApiClient {
|
||||
parentFolderPath?: string,
|
||||
parentFolderUri?: string,
|
||||
accessToken?: string,
|
||||
isForced?: boolean,
|
||||
serverUrl?: string
|
||||
isForced?: boolean
|
||||
): Promise<Folder> {
|
||||
const logger = process.logger || console
|
||||
if (!parentFolderPath && !parentFolderUri) {
|
||||
@@ -632,10 +637,11 @@ export class SASViyaApiClient {
|
||||
)
|
||||
const newFolderName = `${parentFolderPath.split('/').pop()}`
|
||||
if (newParentFolderPath === '') {
|
||||
let error: string = `Root folder ${parentFolderPath} was not found\nPlease check ${serverUrl}/SASDrive\nIf folder DOES exist then it is likely a permission problem\n`
|
||||
let error: string = `Root folder ${parentFolderPath} was not found\nPlease check ${this.serverUrl}/SASDrive\nIf folder DOES exist then it is likely a permission problem\n`
|
||||
if (accessToken) {
|
||||
const tokenResponse: any = jwtDecode(accessToken)
|
||||
const scope = tokenResponse.scope
|
||||
const decodedToken: DecodedToken = decodeToken(accessToken)
|
||||
console.log(decodedToken)
|
||||
const scope = decodedToken.scope
|
||||
error =
|
||||
error + `The following scopes are contained in client/secret:\n`
|
||||
scope.forEach((element: any) => {
|
||||
@@ -651,9 +657,7 @@ export class SASViyaApiClient {
|
||||
newFolderName,
|
||||
newParentFolderPath,
|
||||
undefined,
|
||||
accessToken,
|
||||
isForced,
|
||||
serverUrl
|
||||
accessToken
|
||||
)
|
||||
logger.info(
|
||||
`Parent folder '${newFolderName}' has been successfully created.`
|
||||
|
||||
22
src/SASjs.ts
22
src/SASjs.ts
@@ -282,25 +282,21 @@ export default class SASjs {
|
||||
parentFolderUri?: string,
|
||||
accessToken?: string,
|
||||
sasApiClient?: SASViyaApiClient,
|
||||
isForced?: boolean,
|
||||
serverUrl?: string
|
||||
isForced?: boolean
|
||||
) {
|
||||
if (sasApiClient)
|
||||
return await sasApiClient.createFolder(
|
||||
folderName,
|
||||
parentFolderPath,
|
||||
parentFolderUri,
|
||||
accessToken,
|
||||
isForced,
|
||||
serverUrl
|
||||
accessToken
|
||||
)
|
||||
return await this.sasViyaApiClient!.createFolder(
|
||||
folderName,
|
||||
parentFolderPath,
|
||||
parentFolderUri,
|
||||
accessToken,
|
||||
isForced,
|
||||
serverUrl
|
||||
isForced
|
||||
)
|
||||
}
|
||||
|
||||
@@ -765,8 +761,7 @@ export default class SASjs {
|
||||
members,
|
||||
accessToken,
|
||||
sasApiClient,
|
||||
isForced,
|
||||
serverUrl
|
||||
isForced
|
||||
)
|
||||
}
|
||||
|
||||
@@ -974,8 +969,7 @@ export default class SASjs {
|
||||
membersJson: any[],
|
||||
accessToken?: string,
|
||||
sasApiClient?: SASViyaApiClient,
|
||||
isForced?: boolean,
|
||||
serverUrl?: string
|
||||
isForced?: boolean
|
||||
) {
|
||||
await asyncForEach(membersJson, async (member: any) => {
|
||||
switch (member.type) {
|
||||
@@ -986,8 +980,7 @@ export default class SASjs {
|
||||
undefined,
|
||||
accessToken,
|
||||
sasApiClient,
|
||||
isForced,
|
||||
serverUrl
|
||||
isForced
|
||||
)
|
||||
break
|
||||
case 'file':
|
||||
@@ -1019,8 +1012,7 @@ export default class SASjs {
|
||||
member.members,
|
||||
accessToken,
|
||||
sasApiClient,
|
||||
isForced,
|
||||
serverUrl
|
||||
isForced
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user