import type { Context } from "../context.js"; import { Resource } from "../resource.js"; import type { Secret } from "../secret.js"; import { type CloudflareApiOptions } from "./api.js"; /** * Origin configuration for a PostgreSQL database connection */ export interface HyperdriveOrigin { /** * Database name */ database: string; /** * Database host */ host: string; /** * Database password * Use alchemy.secret() to securely store this value */ password: Secret; /** * Database port * @default 5432 */ port?: number; /** * Connection scheme * @default "postgres" */ scheme?: "postgres"; /** * Database user */ user: string; } /** * Origin configuration for a database connection with access tokens */ export interface HyperdriveOriginWithAccess { /** * Access client ID */ access_client_id: string; /** * Access client secret * Use alchemy.secret() to securely store this value */ access_client_secret: Secret; /** * Database host */ host: string; /** * Database name */ database: string; /** * Database port * @default 5432 */ port?: number; /** * Connection scheme * @default "postgres" */ scheme?: "postgres"; /** * Database user */ user: string; } /** * Caching configuration for Hyperdrive */ export interface HyperdriveCaching { /** * Whether caching is disabled * @default false */ disabled?: boolean; } /** * mTLS configuration for Hyperdrive */ export interface HyperdriveMtls { /** * CA certificate ID */ ca_certificate_id?: string; /** * mTLS certificate ID */ mtls_certificate_id?: string; /** * SSL mode * @default "verify-full" */ sslmode?: "verify-ca" | "verify-full"; } /** * Properties for creating or updating a Cloudflare Hyperdrive. */ export interface HyperdriveProps extends CloudflareApiOptions { /** * Name of the Hyperdrive configuration */ name: string; /** * Database connection origin configuration */ origin: HyperdriveOrigin | HyperdriveOriginWithAccess; /** * Caching configuration */ caching?: HyperdriveCaching; /** * mTLS configuration */ mtls?: HyperdriveMtls; /** * UUID of the hyperdrive (only used for update/delete operations) * This is provided by Cloudflare and is different from the resource ID * @internal */ hyperdriveId?: string; } /** * Output returned after Cloudflare Hyperdrive creation/update. * IMPORTANT: The interface name MUST match the exported resource name. */ export interface Hyperdrive extends Resource<"cloudflare::Hyperdrive">, Omit { /** * The ID of the resource */ id: string; /** * The Cloudflare-generated UUID of the hyperdrive */ hyperdriveId: string; /** * Database connection origin configuration */ origin: HyperdriveOrigin | HyperdriveOriginWithAccess; /** * Resource type identifier for binding. * @internal */ type: "hyperdrive"; } /** * Represents a Cloudflare Hyperdrive configuration. * * @example * // Create a basic Hyperdrive connection to a PostgreSQL database * const basicHyperdrive = await Hyperdrive("my-postgres-db", { * name: "my-postgres-db", * origin: { * database: "postgres", * host: "database.example.com", * password: alchemy.secret("your-password"), * port: 5432, * user: "postgres" * } * }); * * @example * // Create a Hyperdrive with caching disabled * const noCacheHyperdrive = await Hyperdrive("no-cache-db", { * name: "no-cache-db", * origin: { * database: "postgres", * host: "database.example.com", * password: alchemy.secret(process.env.DB_PASSWORD), * port: 5432, * user: "postgres" * }, * caching: { * disabled: true * } * }); * * @example * // Create a Hyperdrive with mTLS configuration * const mtlsHyperdrive = await Hyperdrive("secure-db", { * name: "secure-db", * origin: { * database: "postgres", * host: "database.example.com", * password: alchemy.secret(process.env.DB_PASSWORD), * port: 5432, * user: "postgres" * }, * mtls: { * ca_certificate_id: "00000000-0000-0000-0000-0000000000", * mtls_certificate_id: "00000000-0000-0000-0000-0000000000", * sslmode: "verify-full" * } * }); * * @example * // Create a Hyperdrive with access client credentials * const accessHyperdrive = await Hyperdrive("access-db", { * name: "access-db", * origin: { * database: "postgres", * host: "database.example.com", * access_client_id: "client-id", * access_client_secret: alchemy.secret(process.env.ACCESS_CLIENT_SECRET), * port: 5432, * user: "postgres" * } * }); */ export declare const Hyperdrive: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context, id: string, props: HyperdriveProps) => Promise); //# sourceMappingURL=hyperdrive.d.ts.map