import { Connection } from '@salesforce/core'; export type OrgType = 'Production' | 'Sandbox'; export type ExistingStageEnvironment = { environmentId: string; environmentName?: string; }; /** * Returns the environment currently associated with a pipeline stage, if any. * * A stage references its environment via DevopsPipelineStage.DevOpsEnvironmentId. Adding a new * environment re-points that lookup, so callers must check for an existing environment first to * avoid orphaning the old DevopsEnvironment record. */ export declare function getStageEnvironment(connection: Connection, stageId: string): Promise; /** * Deletes a DevopsEnvironment record only when no pipeline stage still references it. * Returns true when the record was deleted, false when it is still referenced (left intact). * * Used to clean up the environment a stage was re-pointed away from during a --force replace, so the * old record isn't orphaned in the org. The reference check keeps an environment shared by another * stage safe. */ export declare function deleteOrphanedEnvironment(connection: Connection, environmentId: string): Promise; export declare const POLL_INTERVAL_MS = 3000; export declare const POLL_TIMEOUT_MS: number; export type AddStageEnvironmentParams = { connection: Connection; pipelineId: string; stageId: string; environmentName: string; orgType: OrgType; }; export type AddStageEnvironmentResult = { success: boolean; stageId: string; environmentId?: string; environmentName?: string; orgType?: OrgType; pipelineId?: string; redirectUrl?: string; namedCredential?: string; organizationId?: string; error?: string; }; type EnvironmentCreateResponse = { id: string; name: string; redirectUrl: string; namedCredential: string; externalCredential: string; pipelineId?: string; }; export type EnvironmentGetResponse = { id: string; name: string; organizationId?: string; orgType?: string; namedCredential?: string; redirectUrl?: string; }; type EnvironmentValidateResponse = { id: string; name: string; organizationId?: string; orgType?: string; namedCredential?: string; }; /** * Creates an environment and associates it with a pipeline stage via the Connect API. * POST /services/data/v{version}/connect/devops/environment */ export declare function createEnvironment(connection: Connection, params: { pipelineId: string; stageId: string; environmentName: string; orgType: OrgType; }): Promise; /** * Fetches the current state of an environment. * GET /services/data/v{version}/connect/devops/environment/{environmentId} */ export declare function getEnvironment(connection: Connection, environmentId: string): Promise; /** * Validates an authenticated environment by triggering server-side org extraction. * PATCH /services/data/v{version}/connect/devops/environment/{environmentId} */ export declare function validateEnvironment(connection: Connection, environmentId: string): Promise; /** * Polls until authentication is complete by attempting PATCH validation. * The PATCH call triggers server-side org extraction; if the user has * completed OAuth, it returns a response with organizationId populated. * If auth isn't done yet, the PATCH throws — we catch and retry. * Falls back to GET polling as a secondary check. * Throws on timeout. */ export declare function pollForAuthentication(connection: Connection, environmentId: string, timeoutMs?: number, intervalMs?: number): Promise; /** * Full orchestration: create environment -> poll for auth -> validate. * Returns the final result including organizationId. * * The caller is responsible for opening the browser at the returned redirectUrl * and displaying progress to the user. Use `onCreated` to receive the redirect URL * before polling begins. */ export declare function addStageEnvironment(params: AddStageEnvironmentParams & { onCreated?: (data: { environmentId: string; redirectUrl: string; }) => void; pollTimeoutMs?: number; pollIntervalMs?: number; }): Promise; export {};