diff --git a/package.json b/package.json index 662dd09..7572863 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@internxt/sdk", - "version": "1.5.15", + "version": "1.5.16", "description": "An sdk for interacting with Internxt's services", "repository": { "type": "git", diff --git a/src/drive/storage/index.ts b/src/drive/storage/index.ts index 813511f..5273d11 100644 --- a/src/drive/storage/index.ts +++ b/src/drive/storage/index.ts @@ -5,6 +5,10 @@ import { HttpClient, RequestCanceler } from '../../shared/http/client'; import { UUID } from '../../shared/types/userSettings'; import { AddItemsToTrashPayload, + CheckDuplicatedFilesPayload, + CheckDuplicatedFilesResponse, + CheckDuplicatedFolderPayload, + CheckDuplicatedFoldersResponse, CreateFolderByUuidPayload, CreateFolderPayload, CreateFolderResponse, @@ -658,4 +662,42 @@ export class Storage { public getFolderTree(uuid: string): Promise { return this.client.get(`/folders/${uuid}/tree`, this.headers()); } + + /** + * Checks if the given files already exist in the given folder. + * + * @param {CheckDuplicatedFilesPayload} payload - Payload containing the folder UUID and the list of files to check. + * @return {Promise} - Promise that contains the duplicated files in a list. + */ + public checkDuplicatedFiles({ + folderUuid, + filesList, + }: CheckDuplicatedFilesPayload): Promise { + return this.client.post( + `/folders/content/${folderUuid}/files/existence`, + { + files: filesList, + }, + this.headers(), + ); + } + + /** + * Checks if the given folders names already exist in the given folder + * + * @param {CheckDuplicatedFolderPayload} payload - Payload containing the folder UUID and the list of folders to check. + * @return {Promise} - Promise that contains the duplicated folders in a list. + */ + public checkDuplicatedFolders({ + folderUuid, + folderNamesList, + }: CheckDuplicatedFolderPayload): Promise { + return this.client.post( + `/folders/content/${folderUuid}/folders/existence`, + { + plainNames: folderNamesList, + }, + this.headers(), + ); + } } diff --git a/src/drive/storage/types.ts b/src/drive/storage/types.ts index e8b87dc..eacf670 100644 --- a/src/drive/storage/types.ts +++ b/src/drive/storage/types.ts @@ -473,3 +473,26 @@ export interface FolderTree { export interface FolderTreeResponse { tree: FolderTree; } + +export interface CheckDuplicatedFilesPayload { + folderUuid: string; + filesList: FileStructure[]; +} + +export interface FileStructure { + plainName: string; + type: string; +} + +export interface CheckDuplicatedFilesResponse { + existentFiles: DriveFileData[]; +} + +export interface CheckDuplicatedFolderPayload { + folderUuid: string; + folderNamesList: string[]; +} + +export interface CheckDuplicatedFoldersResponse { + existentFolders: DriveFolderData[]; +}