mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-15 08:00:05 +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 { timestampToYYYYMMDDHHMMSS } from '@sasjs/utils/time'
|
||||||
import {
|
import {
|
||||||
isAccessTokenExpiring,
|
isAccessTokenExpiring,
|
||||||
isRefreshTokenExpiring
|
isRefreshTokenExpiring,
|
||||||
|
decodeToken
|
||||||
} from '@sasjs/utils/auth'
|
} from '@sasjs/utils/auth'
|
||||||
import { Logger, LogLevel } from '@sasjs/utils/logger'
|
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 { isAuthorizeFormRequired } from './auth/isAuthorizeFormRequired'
|
||||||
import { RequestClient } from './request/RequestClient'
|
import { RequestClient } from './request/RequestClient'
|
||||||
import { prefixMessage } from '@sasjs/utils/error'
|
import { prefixMessage } from '@sasjs/utils/error'
|
||||||
@@ -611,8 +617,7 @@ export class SASViyaApiClient {
|
|||||||
parentFolderPath?: string,
|
parentFolderPath?: string,
|
||||||
parentFolderUri?: string,
|
parentFolderUri?: string,
|
||||||
accessToken?: string,
|
accessToken?: string,
|
||||||
isForced?: boolean,
|
isForced?: boolean
|
||||||
serverUrl?: string
|
|
||||||
): Promise<Folder> {
|
): Promise<Folder> {
|
||||||
const logger = process.logger || console
|
const logger = process.logger || console
|
||||||
if (!parentFolderPath && !parentFolderUri) {
|
if (!parentFolderPath && !parentFolderUri) {
|
||||||
@@ -632,10 +637,11 @@ export class SASViyaApiClient {
|
|||||||
)
|
)
|
||||||
const newFolderName = `${parentFolderPath.split('/').pop()}`
|
const newFolderName = `${parentFolderPath.split('/').pop()}`
|
||||||
if (newParentFolderPath === '') {
|
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) {
|
if (accessToken) {
|
||||||
const tokenResponse: any = jwtDecode(accessToken)
|
const decodedToken: DecodedToken = decodeToken(accessToken)
|
||||||
const scope = tokenResponse.scope
|
console.log(decodedToken)
|
||||||
|
const scope = decodedToken.scope
|
||||||
error =
|
error =
|
||||||
error + `The following scopes are contained in client/secret:\n`
|
error + `The following scopes are contained in client/secret:\n`
|
||||||
scope.forEach((element: any) => {
|
scope.forEach((element: any) => {
|
||||||
@@ -651,9 +657,7 @@ export class SASViyaApiClient {
|
|||||||
newFolderName,
|
newFolderName,
|
||||||
newParentFolderPath,
|
newParentFolderPath,
|
||||||
undefined,
|
undefined,
|
||||||
accessToken,
|
accessToken
|
||||||
isForced,
|
|
||||||
serverUrl
|
|
||||||
)
|
)
|
||||||
logger.info(
|
logger.info(
|
||||||
`Parent folder '${newFolderName}' has been successfully created.`
|
`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,
|
parentFolderUri?: string,
|
||||||
accessToken?: string,
|
accessToken?: string,
|
||||||
sasApiClient?: SASViyaApiClient,
|
sasApiClient?: SASViyaApiClient,
|
||||||
isForced?: boolean,
|
isForced?: boolean
|
||||||
serverUrl?: string
|
|
||||||
) {
|
) {
|
||||||
if (sasApiClient)
|
if (sasApiClient)
|
||||||
return await sasApiClient.createFolder(
|
return await sasApiClient.createFolder(
|
||||||
folderName,
|
folderName,
|
||||||
parentFolderPath,
|
parentFolderPath,
|
||||||
parentFolderUri,
|
parentFolderUri,
|
||||||
accessToken,
|
accessToken
|
||||||
isForced,
|
|
||||||
serverUrl
|
|
||||||
)
|
)
|
||||||
return await this.sasViyaApiClient!.createFolder(
|
return await this.sasViyaApiClient!.createFolder(
|
||||||
folderName,
|
folderName,
|
||||||
parentFolderPath,
|
parentFolderPath,
|
||||||
parentFolderUri,
|
parentFolderUri,
|
||||||
accessToken,
|
accessToken,
|
||||||
isForced,
|
isForced
|
||||||
serverUrl
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -765,8 +761,7 @@ export default class SASjs {
|
|||||||
members,
|
members,
|
||||||
accessToken,
|
accessToken,
|
||||||
sasApiClient,
|
sasApiClient,
|
||||||
isForced,
|
isForced
|
||||||
serverUrl
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -974,8 +969,7 @@ export default class SASjs {
|
|||||||
membersJson: any[],
|
membersJson: any[],
|
||||||
accessToken?: string,
|
accessToken?: string,
|
||||||
sasApiClient?: SASViyaApiClient,
|
sasApiClient?: SASViyaApiClient,
|
||||||
isForced?: boolean,
|
isForced?: boolean
|
||||||
serverUrl?: string
|
|
||||||
) {
|
) {
|
||||||
await asyncForEach(membersJson, async (member: any) => {
|
await asyncForEach(membersJson, async (member: any) => {
|
||||||
switch (member.type) {
|
switch (member.type) {
|
||||||
@@ -986,8 +980,7 @@ export default class SASjs {
|
|||||||
undefined,
|
undefined,
|
||||||
accessToken,
|
accessToken,
|
||||||
sasApiClient,
|
sasApiClient,
|
||||||
isForced,
|
isForced
|
||||||
serverUrl
|
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
case 'file':
|
case 'file':
|
||||||
@@ -1019,8 +1012,7 @@ export default class SASjs {
|
|||||||
member.members,
|
member.members,
|
||||||
accessToken,
|
accessToken,
|
||||||
sasApiClient,
|
sasApiClient,
|
||||||
isForced,
|
isForced
|
||||||
serverUrl
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user