All files / lib/schema resource-type.ts

100% Statements 11/11
100% Branches 6/6
100% Functions 5/5
100% Lines 11/11

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                                                                                  1x 181x     1x 194x     1x 13x     1x 13x               1x       1x         1x    
import { Documented, PrimitiveType } from './base-types';
import { Property } 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;
}
 
export type Attribute = PrimitiveAttribute | ListAttribute;
 
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 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 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;
}
 
/**
 * 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'
}