All files / lib/schema resource-type.ts

100% Statements 8/8
100% Branches 4/4
100% Functions 4/4
100% Lines 8/8

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                                                                        1x 170x     1x 183x     1x 13x     1x 13x    
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;
}
 
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;
}