Skip to content

Commit 5a39642

Browse files
committed
refactor: drop using enums and add type for enterprise plans sizes
1 parent 3bfd7c6 commit 5a39642

File tree

9 files changed

+105
-63
lines changed

9 files changed

+105
-63
lines changed

.changeset/modern-books-add.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@squarecloud/api-types": minor
3+
---
4+
5+
Add enterprise plan sizes type

.changeset/unlucky-wolves-smell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@squarecloud/api-types": minor
3+
---
4+
5+
Drop using enums.

package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,7 @@
4444
"repository": {
4545
"type": "git",
4646
"url": "git+https://github.com/squarecloudofc/api-types.git"
47-
},
48-
"keywords": [
49-
"square",
50-
"squarecloud",
51-
"api",
52-
"squarecloud api",
53-
"types"
54-
],
47+
}, "keywords": ["square", "squarecloud", "api", "squarecloud api", "types"],
5548
"author": "João Tonaco <[email protected]>",
5649
"license": "MIT",
5750
"bugs": {

payloads/v2/application.ts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,29 @@ import type { APIPayload, ApplicationId } from "../../common/v2";
44
* APIApplication#language
55
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/info
66
*/
7-
export enum ApplicationLanguage {
8-
JavaScript = "javascript",
9-
TypeScript = "typescript",
10-
Python = "python",
11-
Java = "java",
12-
Elixir = "elixir",
13-
Go = "go",
14-
Rust = "rust",
15-
PHP = "php",
16-
Dotnet = "dotnet",
17-
Static = "static",
18-
}
7+
export type ApplicationLanguage =
8+
| "javascript"
9+
| "typescript"
10+
| "python"
11+
| "java"
12+
| "elixir"
13+
| "go"
14+
| "rust"
15+
| "php"
16+
| "dotnet"
17+
| "static";
18+
export const ApplicationLanguage = {
19+
JavaScript: "javascript",
20+
TypeScript: "typescript",
21+
Python: "python",
22+
Java: "java",
23+
Elixir: "elixir",
24+
Go: "go",
25+
Rust: "rust",
26+
PHP: "php",
27+
Dotnet: "dotnet",
28+
Static: "static",
29+
} as const;
1930

2031
/**
2132
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/info

payloads/v2/deploy.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import type { APIPayload, ISODateString } from "../../common/v2";
44
* APIDeploy#state
55
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/deploy/list
66
*/
7-
export enum DeploymentState {
8-
Pending = "pending",
9-
Clone = "clone",
10-
Success = "success",
11-
Error = "error",
12-
}
7+
export type DeploymentState = "pending" | "clone" | "success" | "error";
8+
export const DeploymentState = {
9+
Pending: "pending",
10+
Clone: "clone",
11+
Success: "success",
12+
Error: "error",
13+
} as const;
1314

1415
/**
1516
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/deploy/list

payloads/v2/files.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import type { APIPayload } from "../../common/v2";
44
* APIListedFile#type
55
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/filemanager/list
66
*/
7-
export enum FileType {
8-
File = "file",
9-
Directory = "directory",
10-
}
7+
export type FileType = "file" | "directory";
8+
export const FileType = {
9+
File: "file",
10+
Directory: "directory",
11+
} as const;
1112

1213
/**
1314
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/filemanager/list

payloads/v2/network.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ export type APINetworkAnalyticsPayload = APIPayload<APINetworkAnalytics>;
3232
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/network/dns
3333
*/
3434
export type APINetworkDNSStatus = "pending" | "pending_validation" | "active";
35+
export const APINetworkDNSStatus = {
36+
Pending: "pending",
37+
PendingValidation: "pending_validation",
38+
Active: "active",
39+
};
3540

3641
/**
3742
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/network/dns

payloads/v2/status.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ import type { APIPayload, ApplicationId } from "../../common/v2";
44
* APIApplicationStatus#status
55
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/status
66
*/
7-
export enum ApplicationStatus {
8-
Exited = "exited",
9-
Created = "created",
10-
Starting = "starting",
11-
Restarting = "restarting",
12-
Deleting = "deleting",
13-
Running = "running",
14-
}
7+
export type ApplicationStatus =
8+
| "exited"
9+
| "created"
10+
| "starting"
11+
| "restarting"
12+
| "deleting"
13+
| "running";
14+
export const ApplicationStatus = {
15+
Exited: "exited",
16+
Created: "created",
17+
Starting: "starting",
18+
Restarting: "restarting",
19+
Deleting: "deleting",
20+
Running: "running",
21+
};
1522

1623
/**
1724
* APIApplicationStatus#network

payloads/v2/user.ts

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,45 @@ import type { ApplicationLanguage } from "./application";
55
* APIUserPlan#name
66
* @see https://docs.squarecloud.app/api-reference/endpoint/users/me
77
*/
8-
export enum UserPlanName {
9-
Free = "free",
10-
Student = "student",
11-
Hobby = "hobby",
12-
Standard = "standard",
13-
Pro = "pro",
14-
Enterprise16 = "enterprise-16",
15-
Enterprise32 = "enterprise-32",
16-
Enterprise48 = "enterprise-48",
17-
Enterprise64 = "enterprise-64",
18-
Enterprise96 = "enterprise-96",
19-
Enterprise128 = "enterprise-128",
20-
Enterprise160 = "enterprise-160",
21-
Enterprise192 = "enterprise-192",
22-
Enterprise224 = "enterprise-224",
23-
Enterprise256 = "enterprise-256",
24-
Enterprise288 = "enterprise-288",
25-
Enterprise320 = "enterprise-320",
26-
Enterprise384 = "enterprise-384",
27-
Enterprise448 = "enterprise-448",
28-
Enterprise512 = "enterprise-512",
29-
Enterprise640 = "enterprise-640",
30-
Enterprise768 = "enterprise-768",
31-
Enterprise1024 = "enterprise-1024",
32-
}
8+
export type EnterprisePlanSizes =
9+
| 16
10+
| 32
11+
| 48
12+
| 64
13+
| 96
14+
| 128
15+
| 160
16+
| 192
17+
| 224
18+
| 256
19+
| 288
20+
| 320
21+
| 384
22+
| 448
23+
| 512
24+
| 640
25+
| 768
26+
| 1024;
27+
28+
/**
29+
* APIUserPlan#name
30+
* @see https://docs.squarecloud.app/api-reference/endpoint/users/me
31+
*/
32+
type UserPlanName =
33+
| "free"
34+
| "student"
35+
| "hobby"
36+
| "standard"
37+
| "pro"
38+
| `enterprise-${EnterprisePlanSizes}`;
39+
export const UserPlanName = {
40+
Free: "free",
41+
Student: "student",
42+
Hobby: "hobby",
43+
Standard: "standard",
44+
Pro: "pro",
45+
Enterprise: (size: EnterprisePlanSizes) => `enterprise-${size}`,
46+
};
3347

3448
/**
3549
* APIUserPlan#memory

0 commit comments

Comments
 (0)