mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-18 17:40:06 +00:00
feat: add deleteFolder function
This commit is contained in:
@@ -376,6 +376,8 @@ export class SASViyaApiClient {
|
|||||||
if (!parentFolderUri && parentFolderPath) {
|
if (!parentFolderUri && parentFolderPath) {
|
||||||
parentFolderUri = await this.getFolderUri(parentFolderPath, accessToken)
|
parentFolderUri = await this.getFolderUri(parentFolderPath, accessToken)
|
||||||
if (!parentFolderUri) {
|
if (!parentFolderUri) {
|
||||||
|
if (isForced) this.isForceDeploy = true
|
||||||
|
|
||||||
console.log(`Parent folder is not present: ${parentFolderPath}`)
|
console.log(`Parent folder is not present: ${parentFolderPath}`)
|
||||||
|
|
||||||
const newParentFolderPath = parentFolderPath.substring(
|
const newParentFolderPath = parentFolderPath.substring(
|
||||||
@@ -399,17 +401,11 @@ export class SASViyaApiClient {
|
|||||||
parentFolderUri = `/folders/folders/${parentFolder.id}`
|
parentFolderUri = `/folders/folders/${parentFolder.id}`
|
||||||
} else if (isForced && accessToken && !this.isForceDeploy) {
|
} else if (isForced && accessToken && !this.isForceDeploy) {
|
||||||
this.isForceDeploy = true
|
this.isForceDeploy = true
|
||||||
const recycleBin = await this.getRecycleBin(accessToken)
|
|
||||||
const recycleBinUri = recycleBin?.id || ''
|
|
||||||
const oldFolderName = parentFolderPath?.split('/').pop() || ''
|
const oldFolderName = parentFolderPath?.split('/').pop() || ''
|
||||||
const parentFolderId = parentFolderUri?.split('/').pop() || ''
|
const parentFolderId = parentFolderUri?.split('/').pop() || ''
|
||||||
|
|
||||||
await this.moveFolder(
|
await this.deleteFolder(parentFolderId, oldFolderName, accessToken)
|
||||||
parentFolderId,
|
|
||||||
recycleBinUri,
|
|
||||||
oldFolderName,
|
|
||||||
accessToken
|
|
||||||
)
|
|
||||||
|
|
||||||
const newParentFolderPath = parentFolderPath.substring(
|
const newParentFolderPath = parentFolderPath.substring(
|
||||||
0,
|
0,
|
||||||
@@ -1179,6 +1175,24 @@ export class SASViyaApiClient {
|
|||||||
return folder
|
return folder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async deleteFolder(
|
||||||
|
folderId: string,
|
||||||
|
folderName: string,
|
||||||
|
accessToken: string
|
||||||
|
) {
|
||||||
|
const recycleBin = await this.getRecycleBin(accessToken)
|
||||||
|
const recycleBinId = recycleBin?.id as string
|
||||||
|
|
||||||
|
const movedFolder = await this.moveFolder(
|
||||||
|
folderId,
|
||||||
|
recycleBinId,
|
||||||
|
folderName,
|
||||||
|
accessToken
|
||||||
|
)
|
||||||
|
|
||||||
|
return movedFolder
|
||||||
|
}
|
||||||
|
|
||||||
setCsrfTokenLocal = (csrfToken: CsrfToken) => {
|
setCsrfTokenLocal = (csrfToken: CsrfToken) => {
|
||||||
this.csrfToken = csrfToken
|
this.csrfToken = csrfToken
|
||||||
this.setCsrfToken(csrfToken)
|
this.setCsrfToken(csrfToken)
|
||||||
|
|||||||
Reference in New Issue
Block a user