mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-19 18:10:06 +00:00
fix: move command improved
This commit is contained in:
@@ -5,7 +5,6 @@ import {
|
|||||||
ContextAllAttributes
|
ContextAllAttributes
|
||||||
} from './types'
|
} from './types'
|
||||||
import { makeRequest, isUrl } from './utils'
|
import { makeRequest, isUrl } from './utils'
|
||||||
import { SASViyaApiClient } from './SASViyaApiClient'
|
|
||||||
import { prefixMessage } from '@sasjs/utils/error'
|
import { prefixMessage } from '@sasjs/utils/error'
|
||||||
|
|
||||||
export class ContextManager {
|
export class ContextManager {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { SessionManager } from './SessionManager'
|
|||||||
import { ContextManager } from './ContextManager'
|
import { ContextManager } from './ContextManager'
|
||||||
import { timestampToYYYYMMDDHHMMSS } from '@sasjs/utils/time'
|
import { timestampToYYYYMMDDHHMMSS } from '@sasjs/utils/time'
|
||||||
import { Logger, LogLevel } from '@sasjs/utils/logger'
|
import { Logger, LogLevel } from '@sasjs/utils/logger'
|
||||||
|
import { prefixMessage } from '@sasjs/utils/error'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A client for interfacing with the SAS Viya REST API.
|
* A client for interfacing with the SAS Viya REST API.
|
||||||
@@ -1308,7 +1309,7 @@ export class SASViyaApiClient {
|
|||||||
* @param sourceFolder - the full path (eg `/Public/example/myFolder`) or URI of the source folder listed. Providing URI instead of path will save one extra request.
|
* @param sourceFolder - the full path (eg `/Public/example/myFolder`) or URI of the source folder listed. Providing URI instead of path will save one extra request.
|
||||||
* @param accessToken - an access token for authorizing the request.
|
* @param accessToken - an access token for authorizing the request.
|
||||||
*/
|
*/
|
||||||
public async listFolder(sourceFolder: string, accessToken?: string) {
|
public async listFolder(sourceFolder: string, accessToken?: string, limit: number = 20) {
|
||||||
// checks if 'sourceFolder' is already a URI
|
// checks if 'sourceFolder' is already a URI
|
||||||
const sourceFolderUri = isUri(sourceFolder)
|
const sourceFolderUri = isUri(sourceFolder)
|
||||||
? sourceFolder
|
? sourceFolder
|
||||||
@@ -1322,10 +1323,8 @@ export class SASViyaApiClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = sourceFolderUri
|
|
||||||
|
|
||||||
const { result: members } = await this.request<{ items: any[] }>(
|
const { result: members } = await this.request<{ items: any[] }>(
|
||||||
`${this.serverUrl}${url}/members`,
|
`${this.serverUrl}${sourceFolderUri}/members?limit=${limit}`,
|
||||||
requestInfo
|
requestInfo
|
||||||
).catch((err) => {
|
).catch((err) => {
|
||||||
if (err.code && err.code === 'ENOTFOUND') {
|
if (err.code && err.code === 'ENOTFOUND') {
|
||||||
@@ -1338,7 +1337,7 @@ export class SASViyaApiClient {
|
|||||||
throw notFoundError
|
throw notFoundError
|
||||||
}
|
}
|
||||||
|
|
||||||
throw err
|
throw prefixMessage(err, 'There was an error while fetching folder children')
|
||||||
})
|
})
|
||||||
|
|
||||||
return members.items.map((item: any) => item.name)
|
return members.items.map((item: any) => item.name)
|
||||||
@@ -1357,6 +1356,11 @@ export class SASViyaApiClient {
|
|||||||
targetFolderName: string,
|
targetFolderName: string,
|
||||||
accessToken: string
|
accessToken: string
|
||||||
) {
|
) {
|
||||||
|
// If target path is existing folder, than keep source folder name, othervise rename it with given target folder name
|
||||||
|
const sourceFolderName = sourceFolder.split('/').pop() as string
|
||||||
|
let targetFolderDetails = await this.getFolderDetails(targetParentFolder, accessToken)
|
||||||
|
targetFolderName = targetFolderDetails ? sourceFolderName : targetFolderName
|
||||||
|
|
||||||
// checks if 'sourceFolder' is already a URI
|
// checks if 'sourceFolder' is already a URI
|
||||||
const sourceFolderUri = isUri(sourceFolder)
|
const sourceFolderUri = isUri(sourceFolder)
|
||||||
? sourceFolder
|
? sourceFolder
|
||||||
|
|||||||
@@ -335,10 +335,10 @@ export default class SASjs {
|
|||||||
* @param sourceFolder - the full path (eg `/Public/example/myFolder`) or URI of the source folder listed. Providing URI instead of path will save one extra request.
|
* @param sourceFolder - the full path (eg `/Public/example/myFolder`) or URI of the source folder listed. Providing URI instead of path will save one extra request.
|
||||||
* @param accessToken - an access token for authorizing the request.
|
* @param accessToken - an access token for authorizing the request.
|
||||||
*/
|
*/
|
||||||
public async listFolder(sourceFolder: string, accessToken?: string) {
|
public async listFolder(sourceFolder: string, accessToken?: string, limit?: number) {
|
||||||
this.isMethodSupported('listFolder', ServerType.SASViya)
|
this.isMethodSupported('listFolder', ServerType.SASViya)
|
||||||
|
|
||||||
return await this.sasViyaApiClient?.listFolder(sourceFolder, accessToken)
|
return await this.sasViyaApiClient?.listFolder(sourceFolder, accessToken, limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user