import type { AddOnAttachment, AddOnAttachmentCreateOpts } from '@heroku/types/3.sdk'; import type { PostgresCredentialListResult, PostgresDatabaseCreateCredentialsOpts } from '@heroku/types/data'; import type { ResourceCtx } from '../../../core/extend-resource.js'; import type { DeprovisioningAddOn, ResolvedAddOn } from '../../platform/add-on/types.js'; import type { ResolvedPgDatabase } from '../internal/resolve-pg-database.js'; import { type DeleteCredentialOptions, type PostgresDatabaseCredentialOptions, type RepairDefaultOptions, type RotateAllCredentialsResult, type RotateCredentialOptions, type RotateCredentialOpts, type RotateCredentialResult } from './credentials.js'; export type DeleteAttachmentOptions = { beforeDelete?: (preview: { addon: ResolvedAddOn; attachment: AddOnAttachment; }) => Promise | void; onDetached?: (attachment: AddOnAttachment) => Promise | void; signal?: AbortSignal; }; export type DeleteAttachmentResult = { addon: ResolvedAddOn; attachment: AddOnAttachment; releaseVersion?: number; }; export type PostgresCredential = PostgresCredentialListResult['items'][number]; export type ListAttachmentsOptions = { appIdentity?: string; signal?: AbortSignal; }; export type ListAttachmentsResult = { addon: ResolvedAddOn; attachments: AddOnAttachment[]; credentials: PostgresCredential[]; }; export type ListLegacyByAppOptions = { signal?: AbortSignal; }; /** * A legacy (non-Advanced) Postgres add-on visible to an app, with every name * it's attached under on that app. */ export type LegacyDatabase = ResolvedPgDatabase & { attachmentNames: string[]; }; export type CreateAttachmentBody = Omit; export type CreateAttachmentOptions = { onAttached?: (attachment: AddOnAttachment) => Promise | void; signal?: AbortSignal; }; export type CreateAttachmentResult = { addon: ResolvedAddOn; attachment: AddOnAttachment; releaseVersion?: number; }; export type DestroyOptions = { appIdentity?: string; /** * Runs after the database is resolved but before the delete request fires. * An abort (or throw) during the hook prevents the delete — use it to * confirm destruction against the resolved add-on. */ beforeDestroy?: (preview: { addon: ResolvedAddOn; }) => Promise | void; force?: boolean; onDeprovisioning?: (addon: DeprovisioningAddOn) => Promise | void; signal?: AbortSignal; wait?: boolean; waitIntervalMs?: number; }; export type DestroyResult = { addon: ResolvedAddOn; result: DeprovisioningAddOn; }; /** * Looks up a Postgres attachment by name under an app, resolves its add-on, * and deletes the attachment. * * Throws `NotAdvancedDatabaseError` (carrying the resolved add-on) if the * attachment's database isn't an Advanced-tier database. * * If provided, `beforeDelete` runs after resolution/tier-checking but before * the delete request fires (an abort during the hook prevents the delete), and * `onDetached` runs once the attachment is deleted but before the release * version fetch. The returned `releaseVersion` is the latest release created by * unsetting the attachment's config vars. */ export declare function deleteAttachment(ctx: Pick, appIdentity: string, attachmentName: string, options?: DeleteAttachmentOptions): Promise; /** * Resolves a Postgres database by add-on identity and lists its attachments * alongside its credentials, fanning the two requests out in parallel. * * Resolution is scoped by `appIdentity` when given. Throws * `NotAdvancedDatabaseError` (carrying the resolved add-on) if the database * isn't an Advanced-tier database. */ export declare function listAttachments(ctx: Pick, addonIdentity: string, options?: ListAttachmentsOptions): Promise; /** * Lists the legacy (non-Advanced) Postgres databases attached to an app. * * Includes databases owned by other apps and Essential-tier databases. * Databases attached more than once are returned once (first attachment * wins, API order kept), with all of their attachment names on * `attachmentNames`. Returns an empty array when the app has none. * * Unlike `findLegacyDatabase` (first database the app *owns*) and the * migration listing (owned databases only), this covers every legacy database * the app can see. */ export declare function listLegacyByApp(ctx: Pick, appIdentity: string, options?: ListLegacyByAppOptions): Promise; /** * Resolves a source Postgres database by add-on identity, attaches it * to an app, and fetches the latest release version. * * Throws `NotAdvancedDatabaseError` (carrying the resolved add-on) if the * database isn't an Advanced-tier database. * * If provided, `onAttached` fires once the attachment is created but before * the release version fetch. */ export declare function createAttachment(ctx: Pick, appIdentity: string, addonIdentity: string, body?: CreateAttachmentBody, options?: CreateAttachmentOptions): Promise; /** * Resolves a Postgres database by add-on identity and destroys it. * * Resolution is scoped by `appIdentity` when given. If provided, * `beforeDestroy` runs after resolution but before the delete request fires, * so callers can confirm against the resolved add-on; an abort or throw in * the hook prevents the delete. Delegates the delete (and optional * deprovisioning poll when `wait` is set) to `addOn.destroyAndWait`. */ export declare function destroy(ctx: Pick, addonIdentity: string, options?: DestroyOptions): Promise; export declare const postgresDatabaseExtensions: import("../../../core/extend-resource.js").ResourceExtension<"data", "postgresDatabase", { createAttachment: (appIdentity: string, addonIdentity: string, body?: CreateAttachmentBody, options?: CreateAttachmentOptions) => Promise; createCredentials: (appIdentity: string, body: PostgresDatabaseCreateCredentialsOpts, options?: PostgresDatabaseCredentialOptions) => Promise; deleteAttachment: (appIdentity: string, attachmentName: string, options?: DeleteAttachmentOptions) => Promise; deleteCredential: (appIdentity: string, credName: string, options?: DeleteCredentialOptions) => Promise; destroy: (addonIdentity: string, options?: DestroyOptions) => Promise; getUrl: (appIdentity: string, credName: string, options?: PostgresDatabaseCredentialOptions) => Promise; listAttachments: (addonIdentity: string, options?: ListAttachmentsOptions) => Promise; listCredentials: (appIdentity: string, options?: PostgresDatabaseCredentialOptions) => Promise; listLegacyByApp: (appIdentity: string, options?: ListLegacyByAppOptions) => Promise; repairDefault: (appIdentity: string, options?: RepairDefaultOptions) => Promise; rotateCredential: { (appIdentity: string, body: RotateCredentialOpts & { all: true; }, options?: RotateCredentialOptions): Promise; (appIdentity: string, body?: RotateCredentialOpts, options?: RotateCredentialOptions): Promise; }; }>; export { AddonAppMismatchError, AddonConfirmationRequiredError, AddonDestroyFailedError, AddonNotFoundError, } from '../../platform/add-on/errors.js'; export type { DeprovisioningAddOn, ResolvedAddOn } from '../../platform/add-on/types.js'; export { type AttachmentFactors, parseAttachmentFactors, } from '../internal/parse-attachment-factors.js'; export { EssentialDatabaseNotSupportedError, findLegacyDatabase, getPostgresServiceName, isAdvancedCredential, isAdvancedDatabase, isEssentialDatabase, isEssentialTier, isLegacyDatabase, isLegacyEssentialDatabase, isPostgresAddon, NotAdvancedDatabaseError, } from '../internal/postgres-utils.js'; export { PgDatabaseNotFoundError, type ResolvedPgDatabase } from '../internal/resolve-pg-database.js'; export type { CredentialInfo } from './credentials.js';