UNPKG

@squarecloud/api

Version:
1 lines 3.81 kB
{"version":3,"sources":["../../src/types/api.ts"],"sourcesContent":["import type {\n\tAPIApplication,\n\tAPIApplicationBackup,\n\tAPIApplicationLogs,\n\tAPIApplicationStatus,\n\tAPIApplicationStatusAll,\n\tAPIDeployment,\n\tAPIDeploymentCurrent,\n\tAPIListedFile,\n\tAPINetworkAnalytics,\n\tAPINetworkDNS,\n\tAPIPayload,\n\tAPIReadFile,\n\tAPIServiceStatus,\n\tAPIUserInfo,\n\tRESTDeleteAPIFileDeleteQuery,\n\tRESTGetAPIFileContentQuery,\n\tRESTGetAPIFilesListQuery,\n\tRESTPatchAPIFileMoveJSONBody,\n\tRESTPostAPIApplicationBackupResult,\n\tRESTPostAPIApplicationUploadResult,\n\tRESTPostAPIGithubWebhookJSONBody,\n\tRESTPostAPIGithubWebhookResult,\n\tRESTPostAPINetworkCustomDomainJSONBody,\n\tRESTPutAPIFileUpsertJSONBody,\n} from \"@squarecloud/api-types/v2\";\n\nimport type { Route } from \"@/lib/routes\";\n\nexport interface APIEndpoints {\n\tuser: {\n\t\tresponse: APIUserInfo;\n\t};\n\t\"service/status\": {\n\t\tresponse: APIServiceStatus;\n\t};\n\t\"apps/upload\": {\n\t\tmethod: \"POST\";\n\t\tbody: FormData;\n\t\tresponse: RESTPostAPIApplicationUploadResult;\n\t};\n\t\"apps/status-all\": {\n\t\tresponse: APIApplicationStatusAll[];\n\t};\n\t\"apps/info\": {\n\t\tresponse: APIApplication;\n\t};\n\t\"apps/status\": {\n\t\tresponse: APIApplicationStatus;\n\t};\n\t\"apps/logs\": {\n\t\tresponse: APIApplicationLogs;\n\t};\n\t\"apps/snapshots\": {\n\t\tresponse: APIApplicationBackup[];\n\t};\n\t\"apps/generate-snapshot\": {\n\t\tmethod: \"POST\";\n\t\tresponse: RESTPostAPIApplicationBackupResult;\n\t};\n\t\"apps/start\": {\n\t\tmethod: \"POST\";\n\t\tresponse: undefined;\n\t};\n\t\"apps/restart\": {\n\t\tmethod: \"POST\";\n\t\tresponse: undefined;\n\t};\n\t\"apps/stop\": {\n\t\tmethod: \"POST\";\n\t\tresponse: undefined;\n\t};\n\t\"apps/delete\": {\n\t\tmethod: \"DELETE\";\n\t\tresponse: undefined;\n\t};\n\t\"apps/commit\": {\n\t\tmethod: \"POST\";\n\t\tbody: FormData;\n\t\tresponse: undefined;\n\t};\n\t\"apps/files/read\": {\n\t\tquery: RESTGetAPIFileContentQuery;\n\t\tresponse: APIReadFile;\n\t};\n\t\"apps/files/list\": {\n\t\tquery: RESTGetAPIFilesListQuery;\n\t\tresponse: APIListedFile[];\n\t};\n\t\"apps/files/upsert\": {\n\t\tmethod: \"PUT\";\n\t\tbody: RESTPutAPIFileUpsertJSONBody;\n\t\tresponse: undefined;\n\t};\n\t\"apps/files/move\": {\n\t\tmethod: \"PATCH\";\n\t\tbody: RESTPatchAPIFileMoveJSONBody;\n\t\tresponse: undefined;\n\t};\n\t\"apps/files/delete\": {\n\t\tmethod: \"DELETE\";\n\t\tbody: RESTDeleteAPIFileDeleteQuery;\n\t\tresponse: undefined;\n\t};\n\t\"apps/deployments/list\": {\n\t\tresponse: APIDeployment[];\n\t};\n\t\"apps/deployments/current\": {\n\t\tresponse: APIDeploymentCurrent;\n\t};\n\t\"apps/deployments/webhook\": {\n\t\tmethod: \"POST\";\n\t\tbody: RESTPostAPIGithubWebhookJSONBody;\n\t\tresponse: RESTPostAPIGithubWebhookResult;\n\t};\n\t\"apps/network/dns\": {\n\t\tresponse: APINetworkDNS[];\n\t};\n\t\"apps/network/analytics\": {\n\t\tresponse: APINetworkAnalytics;\n\t};\n\t\"apps/network/custom\": {\n\t\tmethod: \"POST\";\n\t\tbody: RESTPostAPINetworkCustomDomainJSONBody;\n\t\tresponse: undefined;\n\t};\n}\n\nexport type APIEndpoint = keyof APIEndpoints;\n\nexport type APIMethod = \"GET\" | \"POST\" | \"PATCH\" | \"PUT\" | \"DELETE\";\n\nexport type APIRequestOptions<T extends APIEndpoint> = {\n\theaders?: HeadersInit;\n} & Omit<APIEndpoints[T], \"response\">;\n\nexport type APIResponse<T extends APIEndpoint> = APIPayload<\n\tAPIEndpoints[T][\"response\"]\n>;\n\nexport type QueryOrBody =\n\t| { query: any }\n\t| { body: any }\n\t| { method: APIMethod };\n\nexport type APIRequestArgs<\n\tT extends APIEndpoint,\n\tU extends APIRequestOptions<T> = APIRequestOptions<T>,\n> = U extends QueryOrBody\n\t? [path: Route<T>, options: U]\n\t: [path: Route<T>, options?: U];\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}