Skip to content

Commit

Permalink
refactor: drop using enums and add type for enterprise plans sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
joaotonaco committed Dec 4, 2024
1 parent 3bfd7c6 commit 5a39642
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 63 deletions.
5 changes: 5 additions & 0 deletions .changeset/modern-books-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@squarecloud/api-types": minor
---

Add enterprise plan sizes type
5 changes: 5 additions & 0 deletions .changeset/unlucky-wolves-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@squarecloud/api-types": minor
---

Drop using enums.
9 changes: 1 addition & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@
"repository": {
"type": "git",
"url": "git+https://github.com/squarecloudofc/api-types.git"
},
"keywords": [
"square",
"squarecloud",
"api",
"squarecloud api",
"types"
],
}, "keywords": ["square", "squarecloud", "api", "squarecloud api", "types"],
"author": "João Tonaco <joaotonaco@squarecloud.app>",
"license": "MIT",
"bugs": {
Expand Down
35 changes: 23 additions & 12 deletions payloads/v2/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,29 @@ import type { APIPayload, ApplicationId } from "../../common/v2";
* APIApplication#language
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/info
*/
export enum ApplicationLanguage {
JavaScript = "javascript",
TypeScript = "typescript",
Python = "python",
Java = "java",
Elixir = "elixir",
Go = "go",
Rust = "rust",
PHP = "php",
Dotnet = "dotnet",
Static = "static",
}
export type ApplicationLanguage =
| "javascript"
| "typescript"
| "python"
| "java"
| "elixir"
| "go"
| "rust"
| "php"
| "dotnet"
| "static";
export const ApplicationLanguage = {
JavaScript: "javascript",
TypeScript: "typescript",
Python: "python",
Java: "java",
Elixir: "elixir",
Go: "go",
Rust: "rust",
PHP: "php",
Dotnet: "dotnet",
Static: "static",
} as const;

/**
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/info
Expand Down
13 changes: 7 additions & 6 deletions payloads/v2/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import type { APIPayload, ISODateString } from "../../common/v2";
* APIDeploy#state
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/deploy/list
*/
export enum DeploymentState {
Pending = "pending",
Clone = "clone",
Success = "success",
Error = "error",
}
export type DeploymentState = "pending" | "clone" | "success" | "error";
export const DeploymentState = {
Pending: "pending",
Clone: "clone",
Success: "success",
Error: "error",
} as const;

/**
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/deploy/list
Expand Down
9 changes: 5 additions & 4 deletions payloads/v2/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import type { APIPayload } from "../../common/v2";
* APIListedFile#type
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/filemanager/list
*/
export enum FileType {
File = "file",
Directory = "directory",
}
export type FileType = "file" | "directory";
export const FileType = {
File: "file",
Directory: "directory",
} as const;

/**
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/filemanager/list
Expand Down
5 changes: 5 additions & 0 deletions payloads/v2/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export type APINetworkAnalyticsPayload = APIPayload<APINetworkAnalytics>;
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/network/dns
*/
export type APINetworkDNSStatus = "pending" | "pending_validation" | "active";
export const APINetworkDNSStatus = {
Pending: "pending",
PendingValidation: "pending_validation",
Active: "active",
};

/**
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/network/dns
Expand Down
23 changes: 15 additions & 8 deletions payloads/v2/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@ import type { APIPayload, ApplicationId } from "../../common/v2";
* APIApplicationStatus#status
* @see https://docs.squarecloud.app/api-reference/endpoint/apps/status
*/
export enum ApplicationStatus {
Exited = "exited",
Created = "created",
Starting = "starting",
Restarting = "restarting",
Deleting = "deleting",
Running = "running",
}
export type ApplicationStatus =
| "exited"
| "created"
| "starting"
| "restarting"
| "deleting"
| "running";
export const ApplicationStatus = {
Exited: "exited",
Created: "created",
Starting: "starting",
Restarting: "restarting",
Deleting: "deleting",
Running: "running",
};

/**
* APIApplicationStatus#network
Expand Down
64 changes: 39 additions & 25 deletions payloads/v2/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,45 @@ import type { ApplicationLanguage } from "./application";
* APIUserPlan#name
* @see https://docs.squarecloud.app/api-reference/endpoint/users/me
*/
export enum UserPlanName {
Free = "free",
Student = "student",
Hobby = "hobby",
Standard = "standard",
Pro = "pro",
Enterprise16 = "enterprise-16",
Enterprise32 = "enterprise-32",
Enterprise48 = "enterprise-48",
Enterprise64 = "enterprise-64",
Enterprise96 = "enterprise-96",
Enterprise128 = "enterprise-128",
Enterprise160 = "enterprise-160",
Enterprise192 = "enterprise-192",
Enterprise224 = "enterprise-224",
Enterprise256 = "enterprise-256",
Enterprise288 = "enterprise-288",
Enterprise320 = "enterprise-320",
Enterprise384 = "enterprise-384",
Enterprise448 = "enterprise-448",
Enterprise512 = "enterprise-512",
Enterprise640 = "enterprise-640",
Enterprise768 = "enterprise-768",
Enterprise1024 = "enterprise-1024",
}
export type EnterprisePlanSizes =
| 16
| 32
| 48
| 64
| 96
| 128
| 160
| 192
| 224
| 256
| 288
| 320
| 384
| 448
| 512
| 640
| 768
| 1024;

/**
* APIUserPlan#name
* @see https://docs.squarecloud.app/api-reference/endpoint/users/me
*/
type UserPlanName =
| "free"
| "student"
| "hobby"
| "standard"
| "pro"
| `enterprise-${EnterprisePlanSizes}`;
export const UserPlanName = {
Free: "free",
Student: "student",
Hobby: "hobby",
Standard: "standard",
Pro: "pro",
Enterprise: (size: EnterprisePlanSizes) => `enterprise-${size}`,
};

/**
* APIUserPlan#memory
Expand Down

0 comments on commit 5a39642

Please sign in to comment.