# All files / lib/schema resource-type.ts

81.25% Statements 26/32
71.42% Branches 10/14
90% Functions 9/10
81.25% Lines 26/32

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
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    8x

    8x

    8x
    1393x

    8x
    1448x

    8x
    1x

    8x
    55x

    8x
    55x

    8x
    1x

    8x

    8x

    8x

    8x

    8x

    8x

    8x

    8x

    8x

    8x

    8x
    16x

     import { Documented, PrimitiveType } from './base-types';
    import { isTagProperty, isTagPropertyName, Property, TagProperty } from './property';

    export interface ResourceType extends Documented {
      /**
       * The attributes exposed by the resource type, if any.
       */
      Attributes?: { [name: string]: Attribute };
      /**
       * The properties accepted by the resource type, if any.
       */
      Properties?: { [name: string]: Property };
      /**
       * The ``Transform`` required by the resource type, if any.
       */
      RequiredTransform?: string;

      /**
       * What kind of value the 'Ref' operator refers to, if any.
       */
      RefKind?: string;

      /**
       * During a stack update, what kind of additional scrutiny changes to this resource should be subjected to
       *
       * @default None
       */
      ScrutinyType?: ResourceScrutinyType;
    }

    export interface TaggableResource extends ResourceType {
      Properties: {
        FileSystemTags: TagProperty;
        HostedZoneTags: TagProperty;
        Tags: TagProperty;
        UserPoolTags: TagProperty;
        [name: string]: Property;
      }
    }

    export type Attribute = PrimitiveAttribute | ListAttribute | MapAttribute;

    export interface PrimitiveAttribute {
      PrimitiveType: PrimitiveType;
    }

    export type ListAttribute = PrimitiveListAttribute | ComplexListAttribute;

    export interface PrimitiveListAttribute {
      Type: 'List';
      PrimitiveItemType: PrimitiveType;
    }

    export interface ComplexListAttribute {
      Type: 'List';
      ItemType: string;
    }

    export type MapAttribute = PrimitiveMapAttribute;

    export interface PrimitiveMapAttribute {
      Type: 'Map';
      PrimitiveItemType: PrimitiveType;
    }

    /**
     * Determine if the resource supports tags
     *
     * This function combined with isTagProperty determines if the `cdk.TagManager`
     * and `cdk.TaggableResource` can process these tags. If not, standard code
     * generation of properties will be used.
     */
    export function isTaggableResource(spec: ResourceType): spec is TaggableResource {
      Iif (spec.Properties === undefined) {
        return false;
      }
      for (const key of Object.keys(spec.Properties)) {
        Iif (isTagPropertyName(key) && isTagProperty(spec.Properties[key])) {
          return true;
        }
      }
      return false;
    }

    export function isPrimitiveAttribute(spec: Attribute): spec is PrimitiveAttribute {
      return !!(spec as PrimitiveAttribute).PrimitiveType;
    }

    export function isListAttribute(spec: Attribute): spec is ListAttribute {
      return (spec as ListAttribute).Type === 'List';
    }

    export function isMapAttribute(spec: Attribute): spec is MapAttribute {
      return (spec as MapAttribute).Type === 'Map';
    }

    export function isPrimitiveListAttribute(spec: Attribute): spec is PrimitiveListAttribute {
      return isListAttribute(spec) && !!(spec as PrimitiveListAttribute).PrimitiveItemType;
    }

    export function isComplexListAttribute(spec: Attribute): spec is ComplexListAttribute {
      return isListAttribute(spec) && !!(spec as ComplexListAttribute).ItemType;
    }

    export function isPrimitiveMapAttribute(spec: Attribute): spec is PrimitiveMapAttribute {
      return isMapAttribute(spec) && !!(spec as PrimitiveMapAttribute).PrimitiveItemType;
    }

    /**
     * Type declaration for special values of the "Ref" attribute represents.
     *
     * The attribute can take on more values than these, but these are treated specially.
     */
    export enum SpecialRefKind {
      /**
       * No '.ref' member is generated for this type, because it doesn't have a meaningful value.
       */
      None = 'None',

      /**
       * The generated class will inherit from the built-in 'Arn' type.
       */
      Arn = 'Arn'
    }

    export enum ResourceScrutinyType {
      /**
       * No additional scrutiny
       */
      None = 'None',

      /**
       * An externally attached policy document to a resource
       *
       * (Common for SQS, SNS, S3, ...)
       */
      ResourcePolicyResource = 'ResourcePolicyResource',

      /**
       * This is an IAM policy on an identity resource
       *
       * (Basically saying: this is AWS::IAM::Policy)
       */
      IdentityPolicyResource = 'IdentityPolicyResource',

      /**
       * This is a Lambda Permission policy
       */
      LambdaPermission = 'LambdaPermission',

      /**
       * An ingress rule object
       */
      IngressRuleResource = 'IngressRuleResource',

      /**
       * A set of egress rules
       */
      EgressRuleResource = 'EgressRuleResource',
    }

    export function isResourceScrutinyType(str: string): str is ResourceScrutinyType {
      return (ResourceScrutinyType as any)[str] !== undefined;
    }