import { type Declarable } from "./declarable.js"; /** * Marker symbol for Composite type identification. */ export declare const COMPOSITE_MARKER: unique symbol; /** * A record of named members produced by a composite factory. * * What a consumer reads off `instance.members`. Deliberately narrow: every * value here is a real Declarable, so `.entityType` and friends resolve without * narrowing. What a factory may RETURN is wider — see * {@link CompositeFactoryMembers}. */ export type CompositeMembers = Record; /** * What a factory is allowed to RETURN — {@link CompositeMembers} plus * `undefined`, used only as the generic constraint. * * A member produced by a conditional spread (`...(cond ? { policy } : {})`) is * typed optional, and an optional property is not assignable to a * required-value record. Widening the constraint lets such a factory typecheck; * widening `CompositeMembers` itself would make every member possibly-undefined * for everyone reading `instance.members`, which is a worse trade. * * The key is absent at runtime rather than present-and-undefined, so nothing * reaches the validation in `Composite` below. */ export type CompositeFactoryMembers = Record | undefined> | CompositeInstance; /** * The result of instantiating a composite — contains the marker and expanded members. */ export interface CompositeInstance { readonly [COMPOSITE_MARKER]: true; readonly members: M; readonly _definition: CompositeDefinition; } /** * A composite definition: a callable that produces a CompositeInstance. */ export interface CompositeDefinition { (props: P): CompositeInstance & M; readonly compositeName: string; readonly _id: symbol; } /** * Type guard: is this value a CompositeInstance? */ export declare function isCompositeInstance(value: unknown): value is CompositeInstance; /** * Global registry of composite definitions. */ export declare class CompositeRegistry { private static definitions; static register(definition: CompositeDefinition): void; static getAll(): CompositeDefinition[]; static clear(): void; static get size(): number; } /** * Creates a composite definition from a factory closure. * * Usage: * ```ts * const SecureStorage = Composite<{ name: string }>((props) => { * const bucket = new Bucket({ bucketName: props.name }); * const role = new Role({ policies: [{ resource: bucket.arn }] }); * return { bucket, role }; * }); * export const storage = SecureStorage({ name: "data" }); * ``` */ export declare function Composite(factory: (props: P) => M, name?: string): CompositeDefinition; /** * Expands a CompositeInstance into a flat Map of prefixed entity names to Declarables. * Handles nested composites recursively. */ export declare function expandComposite(prefix: string, instance: CompositeInstance): Map; /** * Type helpers for withDefaults. */ type PartialByDefault> = Omit & Partial>; type Simplify = { [K in keyof T]: T[K]; }; /** * Wraps a CompositeDefinition with pre-applied default values. * Props that have defaults become optional in the returned type. * * ```ts * const SecureApi = withDefaults(LambdaApi, { runtime: "nodejs20.x", timeout: 10 }); * const api = SecureApi({ name: "myApi", code: "./dist" }); // runtime and timeout are optional * ``` */ export declare function withDefaults>(definition: CompositeDefinition, defaults: D | ((props: Partial

) => D)): CompositeDefinition>, M>; /** * Symbol key for shared props attached by propagate(). */ export declare const SHARED_PROPS: unique symbol; /** * Symbol key stashing a member's original (pre-merge) props, so expandComposite() * is idempotent across repeated expansions of the same singleton instance (#1032). */ export declare const ORIGINAL_PROPS: unique symbol; /** * Attaches shared properties to a composite instance. * During expandComposite(), shared props are merged into every member's props. * * Merge semantics: * - Scalars: member-specific value wins * - Arrays (e.g. tags): concatenate shared + member-specific * - undefined values in shared props are stripped * * ```ts * export const storage = propagate( * SecureStorage({ name: "data" }), * { tags: [{ key: "env", value: "prod" }] }, * ); * ``` */ export declare function propagate(instance: CompositeInstance & M, sharedProps: Record): CompositeInstance & M; /** * Marker function for resource declarations within composites. * At runtime, simply calls `new Type(props)` and returns the result. * Exists so lint tooling can validate composite member construction (EVL005). */ export declare function resource(Type: new (props: P, attributes?: Record) => T, props: P, attributes?: Record): T; /** * Shallow-merges override values into a base props object. * * Merge semantics: * - `undefined` values in overrides are skipped * - Arrays: concatenated (base + overrides), matching `propagate()` semantics * - Scalars / objects: override wins * * No deep merge — too dangerous with IaC props where nested objects * (e.g. policy documents) should be replaced wholesale. */ export declare function mergeDefaults>(base: T, overrides?: Partial): T; export {}; //# sourceMappingURL=composite.d.ts.map