import type { PostgresDatabaseCreateCredentialsOpts, PostgresDatabaseCreateCredentialsResult, PostgresDatabaseDeleteCredentialResult, PostgresDatabaseRepairDefaultResult, PostgresDatabaseRotateCredentialResult, PostgresDatabaseRotateCredentialsResult } from '@heroku/types/data'; import type { ResourceCtx } from '../../../core/extend-resource.js'; import type { CredentialConnectionInfo } from '../database-credential/get-url.js'; import { type ResolvedPgDatabase } from '../internal/resolve-pg-database.js'; export type PostgresDatabaseCredentialOptions = { addonIdentity?: string; signal?: AbortSignal; }; export type CreateCredentialsResult = { addon: ResolvedPgDatabase; result: PostgresDatabaseCreateCredentialsResult; }; /** * Creates a credential on a classic-tier (Standard/Premium) Postgres * database. Throws if the resolved database is Essential-tier. */ export declare function createCredentials(ctx: Pick, appIdentity: string, body: PostgresDatabaseCreateCredentialsOpts, options?: PostgresDatabaseCredentialOptions): Promise; export type CredentialInfo = { credentials: Array<{ connections?: null | number; password: string; state: string; user: string; }>; database: string; host: string; name: string; port: number; state: string; uuid: string; }; export type ListCredentialsResult = { addon: ResolvedPgDatabase; credentials: CredentialInfo[]; }; /** * Lists all credentials on a classic-tier (Essential/Standard/Premium) * Postgres database. */ export declare function listCredentials(ctx: Pick, appIdentity: string, options?: PostgresDatabaseCredentialOptions): Promise; export type RepairDefaultOptions = PostgresDatabaseCredentialOptions & { /** * Fires before the repair request, allowing the caller to perform any * necessary pre-repair checks or UI rendering. */ beforeRepair?: (preview: { addon: ResolvedPgDatabase; }) => Promise | void; }; export type RepairDefaultResult = { addon: ResolvedPgDatabase; result: PostgresDatabaseRepairDefaultResult; }; /** * Resets a classic-tier (Standard/Premium) Postgres database's default * credential permissions. Throws if the resolved database is Essential-tier. */ export declare function repairDefault(ctx: Pick, appIdentity: string, options?: RepairDefaultOptions): Promise; export type DeleteCredentialOptions = PostgresDatabaseCredentialOptions & { /** * Fires before the delete request, allowing the caller to perform any * necessary pre-delete checks or UI rendering. */ beforeDelete?: (preview: { addon: ResolvedPgDatabase; }) => Promise | void; }; export type DeleteCredentialResult = { addon: ResolvedPgDatabase; result: PostgresDatabaseDeleteCredentialResult; }; /** * Deletes a credential on a classic-tier (Standard/Premium) Postgres database. * * Throws if the resolved database is Essential-tier, or if any app still has * this credential attached. */ export declare function deleteCredential(ctx: Pick, appIdentity: string, credName: string, options?: DeleteCredentialOptions): Promise; export type GetUrlResult = { addon: ResolvedPgDatabase; credentialConnectionInfo: CredentialConnectionInfo; }; /** * Fetches a classic-tier (Essential/Standard/Premium) Postgres credential's * active connection info and builds a ready-to-use connection URL. * * Throws if the resolved database is a legacy Essential-tier database and * `credName` isn't `'default'` (legacy Essential-tier databases don't * support named credentials), or if the credential has no active * connection info. */ export declare function getUrl(ctx: Pick, appIdentity: string, credName: string, options?: PostgresDatabaseCredentialOptions): Promise; export type RotateCredentialOpts = { /** Rotates every credential instead of a single named one. Mutually exclusive with `credName`. */ all?: boolean; /** Which credential to rotate. Defaults to `'default'`. Mutually exclusive with `all`. */ credName?: string; forced?: boolean; }; export type RotateCredentialOptions = PostgresDatabaseCredentialOptions & { /** * Runs after the database is resolved but before the rotate request * fires, with the resolved add-on. */ beforeRotate?: (preview: { addon: ResolvedPgDatabase; }) => Promise | void; }; export type RotateAllCredentialsResult = { addon: ResolvedPgDatabase; result: PostgresDatabaseRotateCredentialsResult; }; export type RotateCredentialResult = { addon: ResolvedPgDatabase; result: PostgresDatabaseRotateCredentialResult; }; /** * Rotates one or all credentials on a classic-tier (Essential/Standard/Premium) * Postgres database. * * Throws if both `all` and `credName` are set — they're mutually exclusive. * Throws if the resolved database is a legacy Essential-tier database and * `credName` isn't `'default'`. */ export declare function rotateCredential(ctx: Pick, appIdentity: string, body: RotateCredentialOpts & { all: true; }, options?: RotateCredentialOptions): Promise; export declare function rotateCredential(ctx: Pick, appIdentity: string, body?: RotateCredentialOpts, options?: RotateCredentialOptions): Promise;