diff --git a/package.json b/package.json index 4a1e326f..dfa8cf08 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@internxt/sdk", "author": "Internxt ", - "version": "1.9.22", + "version": "1.9.23", "description": "An sdk for interacting with Internxt's services", "repository": { "type": "git", diff --git a/src/drive/backups/index.ts b/src/drive/backups/index.ts index 7b602725..b5263e23 100644 --- a/src/drive/backups/index.ts +++ b/src/drive/backups/index.ts @@ -2,6 +2,7 @@ import { HttpClient } from '../../shared/http/client'; import { ApiSecurity, ApiUrl, AppDetails } from '../../shared'; import { Device, DeviceBackup } from './types'; import { headersWithToken } from '../../shared/headers'; +import { DriveFolderData } from '../storage/types'; export class Backups { private readonly client: HttpClient; @@ -18,6 +19,10 @@ export class Backups { this.apiSecurity = apiSecurity; } + /** + * @deprecated Use `getBackupDevices` instead. + * This method uses the old drive backend, while `getBackupDevices` uses the new drive backend. + */ public getAllDevices(): Promise { return this.client .get( @@ -26,6 +31,42 @@ export class Backups { ); } + /** + * Retrieves the list of backup devices associated with the user's account. + * + * @returns {Promise} A promise that resolves to an array of Devices. + */ + public getBackupDevices(): Promise { + return this.client + .get( + '/backup/devices', + this.headers() + ); + } + + /** + * Retrieves a list of all devices represented as folders. + * + * This method sends a GET request to the `/backup/deviceAsFolder` endpoint + * and returns an array of `DriveFolderData` objects, each representing a device + * as a folder in the drive. + * + * @returns {Promise} A promise that resolves to an array of DriveFolderData. + */ + public getAllDevicesAsFolder(): Promise { + return this.client + .get( + '/backup/deviceAsFolder', + this.headers() + ); + } + + /** + * Retrieves all backups associated with a specific device identified by its mac ID. + * + * @param mac - The mac ID of the device for which backups are to be retrieved. + * @returns A promise that resolves to an array of DeviceBackups. + */ public getAllBackups(mac: string): Promise { return this.client .get( @@ -34,6 +75,12 @@ export class Backups { ); } + /** + * Deletes a backup by its ID. + * + * @param backupId - The unique identifier of the backup to be deleted. + * @returns A promise that resolves when the backup is successfully deleted. + */ public deleteBackup(backupId: number): Promise { return this.client .delete( @@ -42,6 +89,10 @@ export class Backups { ); } + /** + * @deprecated Use `deleteBackupDevice` instead. + * This method uses the old drive backend, while `deleteBackupDevice` uses the new drive backend. + */ public deleteDevice(deviceId: number): Promise { return this.client .delete( @@ -50,6 +101,20 @@ export class Backups { ); } + /** + * Deletes a backup device by its ID. + * + * @param deviceId - The unique identifier of the device to be deleted. + * @returns A promise that resolves when the device is successfully deleted. + */ + public deleteBackupDevice(deviceId: number): Promise { + return this.client + .delete( + `/backup/devices/${deviceId}`, + this.headers() + ); + } + /** * Returns the needed headers for the module requests * @private diff --git a/src/drive/storage/types.ts b/src/drive/storage/types.ts index 98d845d1..a27d4d6c 100644 --- a/src/drive/storage/types.ts +++ b/src/drive/storage/types.ts @@ -13,6 +13,7 @@ export interface DriveFolderData { icon_id: number | null; name: string; plain_name: string; + plainName?: string | null; parentId: number | null; parent_id: number | null; parentUuid: string;