import { DatabaseId, UserId, ISODateString, APIPayload, RuntimeStatsListItem } from '../../common/v2.js'; import { APIApplicationStatus } from './status.js'; import '../../utils.js'; /** * Database engine slug. * @see https://docs.squarecloud.app/en/api-reference/endpoint/databases/info */ type DatabaseType = "mongo" | "mysql" | "redis" | "postgres"; declare const DatabaseType: { readonly Mongo: "mongo"; readonly MySQL: "mysql"; readonly Redis: "redis"; readonly Postgres: "postgres"; }; /** * @see https://docs.squarecloud.app/en/api-reference/endpoint/databases/info */ interface APIDatabase { id: DatabaseId; name: string; owner: UserId; cluster: string; ram: number; type: DatabaseType; port: number; created_at: ISODateString; } type APIDatabasePayload = APIPayload; /** * Compact database descriptor returned under `response.databases` of * `/v2/users/me`. `type` is the engine slug as a plain string. * @see https://docs.squarecloud.app/en/api-reference/endpoint/users/me */ interface APIDatabaseSummary { id: DatabaseId; name: string; ram: number; type: string; cluster: string; created_at: ISODateString; } /** * Response of `POST /v2/databases`. `password` (and `certificate` when * applicable) are returned only at creation and cannot be recovered later. * @see https://docs.squarecloud.app/en/api-reference/endpoint/databases/create */ interface APIDatabaseCreated { id: DatabaseId; name: string; /** Allocated memory in MB. */ memory: number; /** Allocated CPU shares. */ cpu: number; type: DatabaseType; /** One-time database password. Shown only at creation. */ password: string; /** Base64-encoded PEM TLS certificate. Returned only when applicable. */ certificate?: string; /** Ready-to-use connection string with the password embedded. */ connection_url: string; cluster: string; } type APIDatabaseCreatedPayload = APIPayload; /** * Runtime stats for a single database (`GET /v2/databases/{databaseId}/status`). * Shares the `RuntimeStats` shape with `APIApplicationStatus`. * @see https://docs.squarecloud.app/en/api-reference/endpoint/databases/status */ type APIDatabaseStatus = APIApplicationStatus; type APIDatabaseStatusPayload = APIPayload>; /** * Compact runtime stats entry for `/v2/databases/status`. Same shape as the * application list item, branded with `DatabaseId`. * @see https://docs.squarecloud.app/en/api-reference/endpoint/databases/status-all */ type APIDatabaseStatusListItem = RuntimeStatsListItem; type APIDatabaseStatusListPayload = APIPayload; /** * Response of `GET /v2/databases/{databaseId}/credentials/certificate`. * @see https://docs.squarecloud.app/en/api-reference/endpoint/databases/credentials/certificate */ interface APIDatabaseCertificate { /** Base64-encoded PEM certificate. */ certificate: string; } type APIDatabaseCertificatePayload = APIPayload; /** * Which credential to rotate via `POST /credentials/reset`. * @see https://docs.squarecloud.app/en/api-reference/endpoint/databases/credentials/reset */ type DatabaseResetType = "password" | "certificate"; declare const DatabaseResetType: { readonly Password: "password"; readonly Certificate: "certificate"; }; /** * Response body present when `reset: "password"`. Absent for * `reset: "certificate"`, which returns a status-only payload. * @see https://docs.squarecloud.app/en/api-reference/endpoint/databases/credentials/reset */ interface APIDatabaseCredentialsResetPasswordResponse { /** Shown only once for password resets. */ password: string; } type APIDatabaseCredentialsResetPasswordPayload = APIPayload; export { type APIDatabase, type APIDatabaseCertificate, type APIDatabaseCertificatePayload, type APIDatabaseCreated, type APIDatabaseCreatedPayload, type APIDatabaseCredentialsResetPasswordPayload, type APIDatabaseCredentialsResetPasswordResponse, type APIDatabasePayload, type APIDatabaseStatus, type APIDatabaseStatusListItem, type APIDatabaseStatusListPayload, type APIDatabaseStatusPayload, type APIDatabaseSummary, DatabaseResetType, DatabaseType };