UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

51 lines (50 loc) 1.72 kB
import type { IConstruct, IMixin } from 'constructs'; import { CfnResource } from '../cfn-resource'; import type { IMergeStrategy } from '../mixins/property-merge-strategy'; /** * Options for CfnPropsMixin */ export interface CfnPropsMixinOptions { /** * Strategy for merging properties * * @default - PropertyMergeStrategy.combine() */ readonly strategy?: IMergeStrategy; } /** * Recursively makes all properties optional. */ type DeepPartial<T> = T extends object ? { [K in keyof T]?: DeepPartial<T[K]>; } : T; /** * Extract writable, non-function own properties from a CfnResource subclass. * Excludes inherited CfnResource/CfnElement/CfnRefElement members and readonly attributes. */ type CfnWritableProps<T extends CfnResource> = { [K in keyof T as K extends keyof CfnResource ? never : T[K] extends Function ? never : K extends `attr${string}` ? never : K extends 'cdkTagManager' ? never : K]: T[K]; }; /** * A generic, type-safe mixin for applying L1 CloudFormation properties. * * Usage: * ```ts * new s3.Bucket(this, 'Bucket') * .with(new CfnPropsMixin(s3.CfnBucket, { * versioningConfiguration: { status: 'Enabled' }, * })); * ``` */ export declare class CfnPropsMixin<T extends CfnResource> implements IMixin { private readonly cfnResourceType; private readonly props; private readonly propertyKeys; private readonly strategy; constructor(resourceClass: (abstract new (...args: any[]) => T) & { readonly CFN_RESOURCE_TYPE_NAME: string; }, props: DeepPartial<CfnWritableProps<T>>, options?: CfnPropsMixinOptions); supports(construct: IConstruct): boolean; applyTo(construct: IConstruct): void; } export {};