# All files / lib/schema specification.ts

100% Statements 2/2
100% Branches 0/0
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57

    8x
    2963x

     import { Documented } from './base-types';
    import { Property } from './property';
    import { ResourceType } from './resource-type';

    /**
     * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification-format.html
     */
    export interface Specification {
      /**
       * A fingerprint of the template, that can be used to determine whether the template has changed.
       */
      Fingerprint: string;
      /**
       * For resources that have properties within a property (also known as subproperties), a list of subproperty
       * specifications, such as which properties are required, the type of allowed value for each property, and their
       * update behavior.
       */
      PropertyTypes: { [name: string]: PropertyType };
      /**
       * The list of resources and information about each resource's properties, such as it's property names, which
       * properties are required, and their update behavior.
       */
      ResourceTypes: { [name: string]: ResourceType };
    }

    /**
     * Describing a user-defined property type
     *
     * Even though looks weird, the CloudFormation spec does not make a distinction between properties and
     * property TYPES: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification-format.html
     *
     * That means that a "type" comes with fields such as "Required", "UpdateType Mutable", etc
     * (even though those only make sense for a particular PROPERTY of that type). They only seem to occur
     * on non-Record properties though.
     *
     * In practice, even though aliases for Primitive properties are allowed, only RecordProperties
     * and CollectionProperties seem to actually occur in the spec in the "types" section.
     */
    export type PropertyType = RecordProperty | Property;

    /**
     * The specifications of a property object type.
     */
    export interface RecordProperty extends Documented {
      /**
       * The properties of the Property type.
       */
      Properties: { [name: string]: Property };
    }

    /**
     * Whether the given type definition is a Record property
     */
    export function isRecordType(propertyType: PropertyType): propertyType is RecordProperty {
      return 'Properties' in propertyType;
    }