@@ -2,37 +2,37 @@ import type { RESTPostAPISnapshotResult } from "@squarecloud/api-types/v2";
22
33import { Routes } from "@/lib/routes" ;
44import { type BaseApplication , SquareCloudAPIError } from "@/structures" ;
5- import { Backup } from "@/structures/backup " ;
5+ import { Snapshot } from "@/structures/snapshot " ;
66
7- export class BackupsModule {
7+ export class SnapshotsModule {
88 constructor ( public readonly application : BaseApplication ) { }
99
1010 /**
11- * Gets the list of generated backups ( snapshots) for this application
11+ * Gets the list of generated snapshots for this application
1212 */
13- async list ( ) : Promise < Backup [ ] > {
13+ async list ( ) : Promise < Snapshot [ ] > {
1414 const data = await this . application . client . api . request (
1515 Routes . apps . snapshots ( this . application . id ) ,
1616 ) ;
1717
18- const backups = data . response . map (
19- ( backup ) => new Backup ( this . application , backup ) ,
18+ const snapshots = data . response . map (
19+ ( snapshot ) => new Snapshot ( this . application , snapshot ) ,
2020 ) ;
2121
2222 this . application . client . emit (
23- "backupsUpdate " ,
23+ "snapshotsUpdate " ,
2424 this . application ,
25- this . application . cache . backups ,
26- backups ,
25+ this . application . cache . snapshots ,
26+ snapshots ,
2727 ) ;
28- this . application . cache . set ( "backups " , backups ) ;
28+ this . application . cache . set ( "snapshots " , snapshots ) ;
2929
30- return backups ;
30+ return snapshots ;
3131 }
3232
3333 /**
34- * Generates a new backup
35- * @returns The generated backup URL and key
34+ * Generates a new snapshot
35+ * @returns The generated snapshot URL and key
3636 */
3737 async create ( ) : Promise < RESTPostAPISnapshotResult > {
3838 const data = await this . application . client . api . request (
@@ -44,18 +44,18 @@ export class BackupsModule {
4444 }
4545
4646 /**
47- * Generates a new backup and downloads it
48- * @returns The downloaded backup bufer
47+ * Generates a new snapshot and downloads it
48+ * @returns The downloaded snapshot buffer
4949 */
5050 async download ( ) : Promise < Buffer > {
51- const backup = await this . create ( ) ;
51+ const snapshot = await this . create ( ) ;
5252
53- const res = await fetch ( backup . url )
53+ const res = await fetch ( snapshot . url )
5454 . then ( ( res ) => res . arrayBuffer ( ) )
5555 . catch ( ( ) => undefined ) ;
5656
5757 if ( ! res ) {
58- throw new SquareCloudAPIError ( "BACKUP_DOWNLOAD_FAILED " ) ;
58+ throw new SquareCloudAPIError ( "SNAPSHOT_DOWNLOAD_FAILED " ) ;
5959 }
6060
6161 return Buffer . from ( res ) ;
0 commit comments