Skip to content

Commit 2dd2a93

Browse files
committed
chore: jsdocs
1 parent 6f302d8 commit 2dd2a93

File tree

11 files changed

+106
-37
lines changed

11 files changed

+106
-37
lines changed

src/modules/applications.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class ApplicationsModule {
5252
* Uploads an application
5353
*
5454
* @param file - The zip file path or Buffer
55+
*
5556
* @returns The uploaded application data
5657
*/
5758
async create(
@@ -76,7 +77,7 @@ export class ApplicationsModule {
7677
}
7778

7879
/**
79-
* Returns the status for all your applications
80+
* Gets the summary status for all your applications
8081
*/
8182
async statusAll(): Promise<SimpleApplicationStatus[]> {
8283
const data = await this.client.api.request(Routes.apps.statusAll());

src/modules/backups.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import { Backup } from "@/structures/backup";
77
export class BackupsModule {
88
constructor(public readonly application: BaseApplication) {}
99

10-
/** @returns The list of backups (snapshots) */
10+
/**
11+
* Gets the list of generated backups (snapshots) for this application
12+
*/
1113
async list(): Promise<Backup[]> {
1214
const data = await this.application.client.api.request(
1315
Routes.apps.backups(this.application.id),
@@ -26,7 +28,10 @@ export class BackupsModule {
2628
return backups.map((backup) => new Backup(this.application, backup));
2729
}
2830

29-
/** @returns The generated backup URL and key */
31+
/**
32+
* Generates a new backup
33+
* @returns The generated backup URL and key
34+
*/
3035
async create(): Promise<RESTPostAPIApplicationBackupResult> {
3136
const data = await this.application.client.api.request(
3237
Routes.apps.generateBackup(this.application.id),
@@ -36,7 +41,10 @@ export class BackupsModule {
3641
return data.response;
3742
}
3843

39-
/** @returns The generated backup buffer */
44+
/**
45+
* Generates a new backup and downloads it
46+
* @returns The downloaded backup bufer
47+
*/
4048
async download(): Promise<Buffer> {
4149
const backup = await this.create();
4250

src/modules/network.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class NetworkModule {
99
* Integrates your website with a custom domain
1010
* - Requires [Senior plan](https://squarecloud.app/plans) or higher
1111
*
12-
* @param domain - The custom domain you want to use (e.g. yoursite.com)
12+
* @param custom - The custom domain you want to use (e.g. yoursite.com)
1313
*/
1414
async setCustomDomain(custom: string) {
1515
assertString(custom, "CUSTOM_DOMAIN");

src/modules/user.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ export class UserModule {
66
constructor(public readonly client: SquareCloudAPI) {}
77

88
/**
9-
* Gets a user's informations
10-
*
11-
* @param userId - The user ID, if not provided it will get your own information
9+
* Gets the authenticated user information
1210
*/
1311
async get(): Promise<User> {
1412
const { response } = await this.client.api.request(Routes.user());

src/structures/application/application.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ import type { WebsiteApplication } from "./website";
77

88
/**
99
* Represents a Square Cloud application
10-
*
11-
* @constructor
12-
* @param client - The client for this application
13-
* @param data - The data from this application
1410
*/
1511
export class Application extends BaseApplication {
12+
/**
13+
* Represents a Square Cloud application
14+
*
15+
* @constructor
16+
* @param client - The client for this application
17+
* @param data - The data from this application
18+
*/
1619
constructor(
1720
public readonly client: SquareCloudAPI,
1821
data: APIApplication,

src/structures/application/base.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ import type { Application } from "./application";
1515

1616
/**
1717
* Represents the base application from the user endpoint
18-
*
19-
* @constructor
20-
* @param client - The client for this application
21-
* @param data - The data from this application
2218
*/
2319
export class BaseApplication {
2420
/** The application ID */
@@ -57,6 +53,13 @@ export class BaseApplication {
5753
/** Deploys module for this application */
5854
deploys = new DeploysModule(this);
5955

56+
/**
57+
* Represents the base application from the user endpoint
58+
*
59+
* @constructor
60+
* @param client - The client for this application
61+
* @param data - The data from this application
62+
*/
6063
constructor(
6164
public readonly client: SquareCloudAPI,
6265
data: APIUserApplication,
@@ -80,11 +83,16 @@ export class BaseApplication {
8083
return this.backups;
8184
}
8285

86+
/**
87+
* Fetches this application for full information
88+
*/
8389
async fetch(): Promise<Application> {
8490
return this.client.applications.fetch(this.id);
8591
}
8692

87-
/** @returns The application current status information */
93+
/**
94+
* Gets the application current status information
95+
*/
8896
async getStatus(): Promise<ApplicationStatus> {
8997
const data = await this.client.api.request(Routes.apps.status(this.id));
9098
const status = new ApplicationStatus(this.client, data.response, this.id);
@@ -95,7 +103,9 @@ export class BaseApplication {
95103
return status;
96104
}
97105

98-
/** @returns The application logs */
106+
/**
107+
* Gets the application current logs
108+
*/
99109
async getLogs(): Promise<string> {
100110
const data = await this.client.api.request(Routes.apps.logs(this.id));
101111
const { logs } = data.response;
@@ -108,7 +118,7 @@ export class BaseApplication {
108118

109119
/**
110120
* Starts up the application
111-
* @returns `true` for success or `false` for fail
121+
* @returns `boolean` for success or fail
112122
*/
113123
async start(): Promise<boolean> {
114124
const data = await this.client.api.request(Routes.apps.start(this.id), {
@@ -120,7 +130,7 @@ export class BaseApplication {
120130

121131
/**
122132
* Stops the application
123-
* @returns `true` for success or `false` for fail
133+
* @returns `boolean` for success or fail
124134
*/
125135
async stop(): Promise<boolean> {
126136
const data = await this.client.api.request(Routes.apps.stop(this.id), {
@@ -132,7 +142,7 @@ export class BaseApplication {
132142

133143
/**
134144
* Restarts the application
135-
* @returns `true` for success or `false` for fail
145+
* @returns `boolean` for success or fail
136146
*/
137147
async restart(): Promise<boolean> {
138148
const data = await this.client.api.request(Routes.apps.restart(this.id), {
@@ -144,9 +154,9 @@ export class BaseApplication {
144154

145155
/**
146156
* Deletes your whole application
147-
*
148157
* - This action is irreversible.
149-
* @returns `true` for success or `false` for fail
158+
*
159+
* @returns `boolean` for success or fail
150160
*/
151161
async delete(): Promise<boolean> {
152162
const data = await this.client.api.request(Routes.apps.delete(this.id), {
@@ -165,7 +175,7 @@ export class BaseApplication {
165175
* ```ts
166176
* require('path').join(__dirname, 'fileName')
167177
* ```
168-
* - Tip2: use a zip file to commit more than one archive
178+
* - Tip 2: use a zip file to commit more than one archive
169179
*
170180
* @param file - Buffer or absolute path to the file
171181
* @param fileName - The file name (e.g.: "index.js")

src/structures/application/website.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ import { Application } from "./application";
77

88
/**
99
* Represents a Square Cloud application
10-
*
11-
* @constructor
12-
* @param client - The client for this application
13-
* @param data - The data from this application
1410
*/
1511
export class WebsiteApplication extends Application {
1612
/** The application default domain (e.g. example.squareweb.app) */
@@ -20,6 +16,13 @@ export class WebsiteApplication extends Application {
2016
/** Network module for this application */
2117
network = new NetworkModule(this);
2218

19+
/**
20+
* Represents a Square Cloud application
21+
*
22+
* @constructor
23+
* @param client - The client for this application
24+
* @param data - The data from this application
25+
*/
2326
constructor(
2427
public readonly client: SquareCloudAPI,
2528
data: APIWebsiteApplication,

src/structures/backup.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import type { APIApplicationBackup } from "@squarecloud/api-types/v2";
33
import { assertBackup } from "@/assertions/backup";
44
import type { BaseApplication } from "./application/base";
55

6+
/**
7+
* Represents an application backup (snapshot)
8+
*/
69
export class Backup {
7-
/** The ID of the application from which you fetched the backups. */
8-
applicationId: string;
9-
1010
/** Size of the backup in bytes. */
1111
size: number;
1212

@@ -22,6 +22,13 @@ export class Backup {
2222
/** The URL for downloading this backup */
2323
url: string;
2424

25+
/**
26+
* Represents an application backup (snapshot)
27+
*
28+
* @constructor
29+
* @param application - The application from which you fetched the backups
30+
* @param data - The data from this backup
31+
*/
2532
constructor(
2633
public readonly application: BaseApplication,
2734
data: APIApplicationBackup,
@@ -30,15 +37,17 @@ export class Backup {
3037
const { name, size, modified, key } = data;
3138
const { userId } = application.client.api;
3239

33-
this.applicationId = name;
3440
this.size = size;
3541
this.modifiedAt = new Date(modified);
3642
this.modifiedTimestamp = this.modifiedAt.getTime();
3743
this.key = key;
3844
this.url = `https://backups.squarecloud.app/${userId}_${name}.zip?${key}`;
3945
}
4046

41-
/** @returns The downloaded backup buffer */
47+
/**
48+
* Downloads this backup
49+
* @returns The downloaded backup bufer
50+
*/
4251
async download(): Promise<Buffer> {
4352
const res = await fetch(this.url)
4453
.then((res) => res.arrayBuffer())

src/structures/deploy.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import type { APIDeployment, DeploymentState } from "@squarecloud/api-types/v2";
33
import { assertDeployment } from "@/assertions/deploy";
44
import type { BaseApplication } from "./application/base";
55

6+
/**
7+
* Represents an application deployment
8+
*/
69
export class Deployment {
710
/** The ID of the deploy. */
811
id: `git-${string}`;
@@ -16,6 +19,13 @@ export class Deployment {
1619
/** The date the deploy was created in millisseconds. */
1720
createdTimestamp: number;
1821

22+
/**
23+
* Represents an application deployment
24+
*
25+
* @constructor
26+
* @param application - The application from which you fetched the deployment
27+
* @param data - The data from this deployment
28+
*/
1929
constructor(
2030
public readonly application: BaseApplication,
2131
data: APIDeployment,

src/structures/status.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import { Routes } from "@/lib/routes";
99
import type { ApplicationStatusUsage } from "@/types/application";
1010
import type { SquareCloudAPI } from "..";
1111

12+
/**
13+
* Represents an application status fetched from status all endpoint
14+
*/
1215
export class SimpleApplicationStatus<R extends boolean = boolean> {
1316
/** The application's ID this status came from */
1417
applicationId: string;
@@ -19,6 +22,13 @@ export class SimpleApplicationStatus<R extends boolean = boolean> {
1922
/** Whether the application is running or not */
2023
running: R;
2124

25+
/**
26+
* Represents an application status fetched from status all endpoint
27+
*
28+
* @constructor
29+
* @param client - The client for this status
30+
* @param data - The data from this status
31+
*/
2232
constructor(
2333
public readonly client: SquareCloudAPI,
2434
data: APIApplicationStatusAll,
@@ -39,6 +49,9 @@ export class SimpleApplicationStatus<R extends boolean = boolean> {
3949
}
4050
}
4151

52+
/**
53+
* Fetches the full application status
54+
*/
4255
async fetch() {
4356
const data = await this.client.api.request(
4457
Routes.apps.status(this.applicationId),
@@ -52,6 +65,9 @@ export class SimpleApplicationStatus<R extends boolean = boolean> {
5265
}
5366
}
5467

68+
/**
69+
* Represents an application status
70+
*/
5571
export class ApplicationStatus {
5672
/** The application's ID this status came from */
5773
applicationId: string;
@@ -77,6 +93,14 @@ export class ApplicationStatus {
7793
/** For how long the app is running */
7894
uptime?: Date;
7995

96+
/**
97+
* Represents an application status
98+
*
99+
* @constructor
100+
* @param client - The client for this status
101+
* @param data - The data from this status
102+
* @param applicationId - The application ID this status came from
103+
*/
80104
constructor(
81105
public readonly client: SquareCloudAPI,
82106
data: APIApplicationStatus,

0 commit comments

Comments
 (0)