From 21a23b024d07e58a211594509f165b6e5a188872 Mon Sep 17 00:00:00 2001 From: Ramon Candel Date: Wed, 18 Sep 2024 09:15:57 +0200 Subject: [PATCH 1/2] Added call to check duplicated file and folder names --- package.json | 2 +- src/drive/storage/index.ts | 30 ++++++++++++++++++++++++++++++ src/drive/storage/types.ts | 23 +++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) 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..ce40550 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,30 @@ export class Storage { public getFolderTree(uuid: string): Promise { return this.client.get(`/folders/${uuid}/tree`, this.headers()); } + + public checkDuplicatedFiles({ + folderUuid, + filesList, + }: CheckDuplicatedFilesPayload): Promise { + return this.client.post( + `/folders/content/${folderUuid}/files/existence`, + { + files: filesList, + }, + this.headers(), + ); + } + + 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[]; +} From b3191de7acdb51e73ffdf5bed1493ae6a2d63120 Mon Sep 17 00:00:00 2001 From: Ramon Candel Date: Wed, 18 Sep 2024 09:20:22 +0200 Subject: [PATCH 2/2] Added jsdoc --- src/drive/storage/index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/drive/storage/index.ts b/src/drive/storage/index.ts index ce40550..5273d11 100644 --- a/src/drive/storage/index.ts +++ b/src/drive/storage/index.ts @@ -663,6 +663,12 @@ export class Storage { 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, @@ -676,6 +682,12 @@ export class Storage { ); } + /** + * 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,