Skip to content

Commit

Permalink
Added call to check duplicated file and folder names
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramon Candel authored and Ramon Candel committed Sep 18, 2024
1 parent ffb2976 commit 21a23b0
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
30 changes: 30 additions & 0 deletions src/drive/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -658,4 +662,30 @@ export class Storage {
public getFolderTree(uuid: string): Promise<FolderTreeResponse> {
return this.client.get(`/folders/${uuid}/tree`, this.headers());
}

public checkDuplicatedFiles({
folderUuid,
filesList,
}: CheckDuplicatedFilesPayload): Promise<CheckDuplicatedFilesResponse> {
return this.client.post(
`/folders/content/${folderUuid}/files/existence`,
{
files: filesList,
},
this.headers(),
);
}

public checkDuplicatedFolders({
folderUuid,
folderNamesList,
}: CheckDuplicatedFolderPayload): Promise<CheckDuplicatedFoldersResponse> {
return this.client.post(
`/folders/content/${folderUuid}/folders/existence`,
{
plainNames: folderNamesList,
},
this.headers(),
);
}
}
23 changes: 23 additions & 0 deletions src/drive/storage/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
}

0 comments on commit 21a23b0

Please sign in to comment.