/** * Target derivation — shared across CLI, webapp, and deploy-core. * * A "target" is a deployment destination: an account + region combination * with a canonical name derived from org config at runtime. */ import { type AccountTier } from "./environments.js"; /** Structural interface for the region fields on OrgConfig. */ export interface OrgConfigRegions { primaryRegion?: string; secondaryRegions?: string[]; disasterRecoveryRegion?: string; } /** * Collect all configured regions from an org config into a flat array. * Includes primary, secondary, and disaster recovery regions. */ export declare function deriveRegionsFromOrgConfig(config: OrgConfigRegions): string[]; export interface TargetAccount { name: string; id: string; /** Workload STAGE — null for structural accounts; read tier from `tier`. */ environment: string | null; tier?: AccountTier; } /** * The account and region a deployment target names. * * Split out from `DerivedTarget` because it is the half that carries meaning: * the name is a derived encoding of this pair, and the encoding is not * reversible in general (account names contain hyphens; two regions abbreviated * to one code until 2026-09-04). Code that has resolved the pair passes it * along as this type rather than composing a name for a callee to take apart. */ export interface ResolvedTargetAccount { accountName: string; accountId: string; environment: string; region: string; } export interface DerivedTarget extends ResolvedTargetAccount { name: string; } /** * Canonical stage-or-tier fallback. Structural accounts carry a null workload * stage, so display/naming/OU derivation fall back to the structural tier to * stay non-null. Single source for every `environment ?? tier` consumer. */ export declare function environmentOrTier(account: { environment?: string | null; tier?: AccountTier | null; }): string; /** * Generate a canonical target name from account name and region. * e.g. ("Production-US", "us-east-1") → "production-us-use1" */ export declare function generateTargetName(accountName: string, region: string): string; /** * The refusal for a target name whose region code Fjall no longer emits, or * `undefined` when the name carries no retired code. * * Every guard that turns a target name back into an account and region consumes * this before searching, so a stale name is refused with the same explanation * wherever it is typed. Without it the searches fail open in the worst * direction: they scan every AWS region for a name match, so a retired code * either finds nothing (a bare "not found" that teaches the operator nothing * about why a name that worked last week does not now) or — for the codes that * were ambiguous — finds the wrong region and deploys there. */ export declare function explainRetiredTargetName(targetName: string): string | undefined; /** * Derive all deployment targets from org config accounts and regions. * Excludes root accounts (organisation management accounts). * Sorted by environment, then account name, then region. */ export declare function deriveTargets(accounts: TargetAccount[], regions: string[]): DerivedTarget[]; /** * Derive all deployment targets from an org config object. * Convenience wrapper combining deriveRegionsFromOrgConfig + deriveTargets. */ export declare function deriveAllTargets(orgConfig: OrgConfigRegions & { providerAccounts: TargetAccount[]; }): DerivedTarget[]; /** * Merge secondaryRegions from the local config file into an API-sourced OrgConfig. * Local config is the source of truth for secondaryRegions; the API provides * primaryRegion and disasterRecoveryRegion. Deduplicates to avoid overlap. */ export declare function mergeSecondaryRegions(orgConfig: T, localSecondaryRegions: string[]): T; /** * Find a target by its canonical name. */ export declare function findTarget(targets: DerivedTarget[], targetName: string): DerivedTarget | undefined;