Skip to content

Commit

Permalink
Merge pull request #195 from internxt/feat/PB-1336-move-file-folders-…
Browse files Browse the repository at this point in the history
…by-uuid

[PB-1336]: Feat/Move items by UUID
  • Loading branch information
larry-internxt authored Mar 21, 2024
2 parents 7f4d8f8 + b405e1c commit c892197
Show file tree
Hide file tree
Showing 3 changed files with 41 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.4.73",
"version": "1.4.74",
"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 @@ -24,6 +24,8 @@ import {
ReplaceFile,
FetchPaginatedFilesContent,
FetchPaginatedFoldersContent,
MoveFolderUuidPayload,
MoveFileUuidPayload,
} from './types';
import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
import { headersWithToken, addResourcesTokenToHeaders } from '../../shared/headers';
Expand Down Expand Up @@ -80,6 +82,20 @@ export class Storage {
);
}

/**
* Moves a specific folder to a new location
* @param payload
*/
public async moveFolderByUuid(payload: MoveFolderUuidPayload): Promise<FolderMeta> {
return this.client.patch(
`/folders/${payload.folderUuid}`,
{
destinationFolder: payload.destinationFolderUuid,
},
this.headers(),
);
}

/**
* Updates the metadata of a folder
* @param payload
Expand Down Expand Up @@ -346,6 +362,20 @@ export class Storage {
);
}

/**
* Moves a specific file to a new location
* @param payload
*/
public async moveFileByUuid(payload: MoveFileUuidPayload): Promise<FileMeta> {
return this.client.patch(
`/files/${payload.fileUuid}`,
{
destinationFolder: payload.destinationFolderUuid,
},
this.headers(),
);
}

/**
* Returns a list of the n most recent files
* @param limit
Expand Down
10 changes: 10 additions & 0 deletions src/drive/storage/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ export interface MoveFolderPayload {
destinationFolderId: number;
}

export interface MoveFolderUuidPayload {
folderUuid: string;
destinationFolderUuid: string;
}

export interface MoveFolderResponse {
item: DriveFolderData;
destination: number;
Expand Down Expand Up @@ -328,6 +333,11 @@ export interface MoveFilePayload {
bucketId: string;
}

export interface MoveFileUuidPayload {
fileUuid: string;
destinationFolderUuid: string;
}

export interface MoveFileResponse {
item: DriveFileData;
destination: number;
Expand Down

0 comments on commit c892197

Please sign in to comment.