import type { Schema as PbSchema, Schema_Attribute, Schema_NestedBlock, Schema_Object } from "../gen/tfplugin6.js"; import type { TfType } from "./types.js"; export type DescriptionKind = "plain" | "markdown"; export interface AttributeOptions { description?: string; descriptionKind?: DescriptionKind; required?: boolean; optional?: boolean; computed?: boolean; sensitive?: boolean; deprecated?: boolean; deprecationMessage?: string; /** Changing this attribute forces resource replacement. */ requiresReplace?: boolean; /** Default value used in plan for computed+not-set attributes. */ default?: unknown; /** Write-only attribute — value is accepted but never stored in state (Terraform ≥ 1.11). */ writeOnly?: boolean; } export declare class Attribute { readonly name: string; readonly type: TfType; readonly description: string; readonly descriptionKind: DescriptionKind; readonly required: boolean; readonly optional: boolean; readonly computed: boolean; readonly sensitive: boolean; readonly deprecated: boolean; readonly deprecationMessage: string; readonly requiresReplace: boolean; readonly default: unknown; readonly writeOnly: boolean; constructor(name: string, type: TfType, opts?: AttributeOptions); toPb(): Schema_Attribute; } export type NestMode = "single" | "list" | "set" | "map" | "group"; /** Nesting modes for an ObjectAttribute. Mirrors Schema_Object_NestingMode. */ export type ObjNestMode = "single" | "list" | "set" | "map"; /** * TfType implementation for nested object attributes (`nested_type` in the * Terraform Plugin Protocol). Used internally by ObjectAttribute. * * Handles all four nesting modes: * - "single" → a single object `{ field: value, ... }` * - "list" → an ordered list `[{ ... },` ...]` * - "set" → an unordered list `[{ ... }, ...]` (order-insensitive equality) * - "map" → a string-keyed map `{ key: { ... }, ... }` */ export declare class TfObject implements TfType { readonly fields: Attribute[]; readonly nestingMode: ObjNestMode; constructor(fields: Attribute[], nestingMode?: ObjNestMode); private fieldMap; /** Encode a single nested object's fields. */ private _encodeOne; /** Decode a single nested object's fields. */ private _decodeOne; /** Compare two single nested objects field-by-field using each field's semanticallyEqual. */ private _equalOne; encode(v: unknown): unknown; decode(v: unknown): unknown; semanticallyEqual(a: unknown, b: unknown): boolean; /** Returns empty bytes — not used in Schema_Attribute.type when nestedType is set. */ tfType(): Uint8Array; /** Build the Schema_Object proto message for use in Schema_Attribute.nestedType. */ toPbNestedType(): Schema_Object; } /** * An attribute backed by a nested object schema (Schema_Object / `nested_type`). * * Unlike a plain `Attribute` (which uses Terraform's scalar/collection type * system), an `ObjectAttribute` defines the shape of a structured object * inline on the attribute — without block HCL syntax. * * Nesting modes: * - "single" → `attr = { field = value }` * - "list" → `attr = [{ field = value }, ...]` * - "set" → same HCL, set semantics (unordered) * - "map" → `attr = { key = { field = value } }` */ export declare class ObjectAttribute extends Attribute { readonly objectType: TfObject; constructor(name: string, fields: Attribute[], nestingMode?: ObjNestMode, opts?: AttributeOptions); toPb(): Schema_Attribute; } export interface NestedBlockOptions { minItems?: number; maxItems?: number; } export declare class NestedBlock { readonly typeName: string; readonly nestingMode: NestMode; readonly block: Block; readonly minItems: number; readonly maxItems: number; constructor(typeName: string, nestingMode: NestMode, block: Block, opts?: NestedBlockOptions); toPb(): Schema_NestedBlock; encode(value: unknown): unknown; decode(value: unknown): unknown; semanticallyEqual(a: unknown, b: unknown): boolean; } export interface BlockOptions { description?: string; descriptionKind?: DescriptionKind; deprecated?: boolean; deprecationMessage?: string; computed?: boolean; } export declare class Block { readonly attributes: Attribute[]; readonly blockTypes: NestedBlock[]; readonly description: string; readonly descriptionKind: DescriptionKind; readonly deprecated: boolean; readonly deprecationMessage: string; readonly computed: boolean; constructor(attributes?: Attribute[], blockTypes?: NestedBlock[], opts?: BlockOptions); attrMap(): Record; blockMap(): Record; toPb(): PbSchema["block"]; } export declare class Schema { readonly version: number; readonly block: Block; constructor(attributes?: Attribute[], blockTypes?: NestedBlock[], version?: number, blockOpts?: BlockOptions); toPb(): PbSchema; } export type State = Record; export declare function encodeBlock(block: Block, state: State | null): State | null; /** * Like encodeBlock, but reuses the raw prior-encoded bytes for any field that * is semantically unchanged. This prevents spurious msgpack/JSON diffs when the * same logical value is serialised differently (e.g. JSON with keys in a different * order) — mirroring the behaviour of hfern/tf's `_encode_state_d`. */ export declare function encodeBlockPreserving(block: Block, state: State | null, priorRaw: State | null): State | null; export declare function decodeBlock(block: Block, raw: Record | null): State | null; //# sourceMappingURL=schema.d.ts.map