/** * Parser for Terraform variable blocks. * Extracts variable declarations with type constraints, defaults, and validations. */ import { HclBlock, TypeConstraint, VariableBlock } from '../types/blocks'; /** * Parser for Terraform variable definition blocks. * * @example * ```hcl * variable "instance_type" { * type = string * default = "t2.micro" * description = "EC2 instance type" * sensitive = false * * validation { * condition = can(regex("^t[23]\\.", var.instance_type)) * error_message = "Must be a t2 or t3 instance type." * } * } * ``` */ export declare class VariableParser { /** * Parses a variable block into a structured VariableBlock. * @param block - The raw HCL block to parse * @returns Parsed VariableBlock with all extracted fields */ parse(block: HclBlock): VariableBlock; /** * Extracts validation rules from nested validation blocks. * @param blocks - Nested blocks from the variable body * @returns VariableValidation if a validation block exists */ private extractValidation; } /** * Parses a Terraform type constraint expression into a structured TypeConstraint. * * Supports: * - Primitive types: string, number, bool, any * - Collection types: list(T), set(T), map(T) * - Structural types: object({ attr = type, ... }), tuple([type, ...]) * - Optional attributes: optional(type) * * @param raw - The raw type expression string * @returns Parsed TypeConstraint * * @example * ```typescript * parseTypeConstraint('string') * // { base: 'string', raw: 'string' } * * parseTypeConstraint('list(string)') * // { base: 'list', element: { base: 'string', raw: 'string' }, raw: 'list(string)' } * * parseTypeConstraint('object({ name = string, age = optional(number) })') * // { base: 'object', attributes: { name: {...}, age: {...} }, raw: '...' } * ``` */ export declare function parseTypeConstraint(raw: string): TypeConstraint;