typed-aws
Version:
Helps you write AWS CloudFormation in TypeScript
93 lines (92 loc) • 2.67 kB
TypeScript
export declare type SchemaRegistry = Record<string, Schema>;
export declare type Schema<T extends TypeDefinition = TypeDefinition> = {
id: string;
root?: boolean;
namespace: string;
module: string;
resource: string;
name: string;
} & BaseTypeDefinition & T;
export declare type PropertyRef = string;
export declare type BaseTypeDefinition = {
description?: string;
originalType?: string;
} & (ConditionalTypes | {});
export declare type ConditionalTypes = AnyOfType | OneOfType | AllOfType;
export declare type AnyOfType = {
anyOf: TypeDefinition[];
};
export declare type OneOfType = {
oneOf: TypeDefinition[];
};
export declare type AllOfType = {
allOf: TypeDefinition[];
};
export declare type TypeDefinition = BaseTypeDefinition & (StringType | ArrayType | ObjectType | RefType | NumberType | BooleanType);
export declare type Properties = Record<string, TypeDefinition>;
export declare type ObjectType = {
type: 'object';
required?: string[];
properties?: Properties;
patternProperties?: Properties;
minProperties?: number;
maxProperties?: number;
additionalProperties?: boolean;
readOnlyProperties?: PropertyRef[];
writeOnlyProperties?: PropertyRef[];
createOnlyProperties?: PropertyRef[];
primaryIdentifier?: PropertyRef[];
deprecatedProperties?: PropertyRef[];
handlers?: unknown;
};
export declare type StringType = {
type: 'string';
format?: string | 'int64' | 'date-time' | 'double' | 'string';
examples?: string[];
enum?: string[];
default?: string;
minLength?: number;
maxLength?: number;
pattern?: string;
};
export declare type ArrayType = {
type: 'array';
items: TypeDefinition;
default?: unknown[];
examples?: unknown[];
uniqueItems?: boolean;
minItems?: number;
maxItems?: number;
};
export declare type BooleanType = {
type: 'boolean';
default?: boolean;
};
export declare type NumberType = {
type: 'number';
multipleOf?: number;
default?: number;
minimum?: number;
maximum?: number;
};
export declare type LiteralType = 'object' | 'string' | 'array' | 'boolean' | 'number' | 'reference';
export declare type RefType = {
type?: LiteralType;
$ref: string;
};
export declare type ResourceFile = {
module: string;
resource: string;
fileName: string;
};
export declare type ModuleFile = {
module: string;
fileName: string;
};
export declare type IndexFile = {
fileName: string;
};
export declare type FileData = {
source: string;
};
export declare type Writer = (directory: string, fileName: string, source: string) => Promise<void>;