import { CommonTypeCombinatorFields } from './CloudFormationRegistrySchema'; export declare namespace jsonschema { type Schema = SingletonSchema | OneOf | AnyOf | AllOf; type SingletonSchema = Reference | ConcreteSingletonSchema; type ConcreteSchema = ConcreteSingletonSchema | OneOf | AnyOf | AllOf; type ConcreteSingletonSchema = Object | String | SchemaArray | Boolean | Number | Null | AnyType; type AnyType = true | EmptyObject; type EmptyObject = Record; function isAnyType(x: Schema | CommonTypeCombinatorFields): x is AnyType; interface Annotatable { readonly $comment?: string; readonly description?: string; readonly title?: string; } interface Reference extends Annotatable { readonly type?: 'object'; readonly $ref: string; } type CombiningSchema = UnionSchema | AllOf; type UnionSchema = AnyOf | OneOf; function isUnionSchema(x: jsonschema.Schema): x is UnionSchema; function isUnionSchema(x: jsonschema.ConcreteSchema): x is UnionSchema; function isCombining(x: ConcreteSchema): x is CombiningSchema; function isConcreteSingleton(x: ConcreteSchema): x is ConcreteSingletonSchema; function isObject(x: ConcreteSchema): x is Object; type Object = MapLikeObject | RecordLikeObject; interface AnyOf extends Annotatable { readonly anyOf: Array; } /** * Determines whether or not the provided schema represents an `anyOf` type operator. */ function isAnyOf(x: Schema | CommonTypeCombinatorFields): x is AnyOf; interface OneOf extends Annotatable { readonly oneOf: Array; } function innerSchemas(x: CombiningSchema): E[]; /** * Determines whether or not the provided schema represents a `oneOf` type operator. */ function isOneOf(x: Schema | CommonTypeCombinatorFields): x is OneOf; interface AllOf extends Annotatable { readonly allOf: Array; } /** * Determines whether or not the provided schema represents an `allOf` type operator. */ function isAllOf(x: Schema): x is AllOf; interface MapLikeObject extends Annotatable { readonly type: 'object'; /** * additionalProperties validates all keys that aren't otherwise validated by properties or patternProperties * * @default true */ readonly additionalProperties?: false | Schema; readonly patternProperties?: Record; readonly minProperties?: number; readonly maxProperties?: number; /** * Required keys in a map * * Doesn't really make a whole lot of sense, but this is used to support mixed map/record types. */ readonly required?: string[]; } interface Null extends Annotatable { readonly type: 'null'; } type ObjectProperties = Record; interface RecordLikeObject extends Annotatable { readonly type: 'object'; readonly properties: ObjectProperties; readonly required?: string[]; readonly oneOf?: (CommonTypeCombinatorFields | RecordLikeObject)[]; readonly anyOf?: (CommonTypeCombinatorFields | RecordLikeObject)[]; /** * FIXME: should be required but some service teams have omitted it. */ readonly additionalProperties?: false; /** * FIXME: these are weird but oh hey? */ readonly minProperties?: number; readonly maxProperties?: number; } function isRecordLikeObject(x: Object): x is RecordLikeObject; function isMapLikeObject(x: Object): x is MapLikeObject; /** * Relationship as defined in the CloudFormation Registry Schema. * Represents how resource property relationships are specified in the source schema files. */ interface RelationshipRefSchema { /** The cloudFormationType (e.g. 'AWS::S3::Bucket') */ readonly typeName: string; /** The property path (e.g. '/properties/BucketName') */ readonly propertyPath: string; } /** * Determines if a schema is a relationshipRef */ function isRelationshipRef(x: any): x is RelationshipRefSchema; /** * Determines if a schema contains a relationshipRef * This function handles the two following cases: * { type: 'string', relationshipRef: {...} } -> occurs when there a single relationship for a property * { relationshipRef: {...} } -> occurs when there are multiple relationships as the source data looks like this: * { type: 'string', anyOf: [ { relationshipRef: {...} }, ...]} (the type is not present along relationshipRef) */ function containsRelationship(x: any): boolean; interface String extends Annotatable { readonly type: 'string'; readonly default?: string; readonly minLength?: number; readonly maxLength?: number; readonly pattern?: string; readonly const?: string; readonly enum?: string[]; readonly format?: 'date-time' | 'uri' | 'timestamp'; readonly examples?: string[]; readonly relationshipRef?: RelationshipRefSchema; } function isString(x: ConcreteSchema): x is String; interface Number extends Annotatable { readonly type: 'number' | 'integer'; readonly default?: number; readonly enum?: number[]; readonly minimum?: number; readonly maximum?: number; readonly format?: 'int64' | 'double'; readonly multipleOf?: number; } interface SchemaArray extends Annotatable { readonly type: 'array'; readonly items?: Schema; readonly uniqueItems?: boolean; /** * Whether to treat the order as significant * * In other words, does this array model a "sequence" or a "multiset". * * - `true` (default): order is significant, the array is a sequence. * - `false`: order is insignificant, the array is a set. */ readonly insertionOrder?: boolean; readonly maxItems?: number; readonly minItems?: number; readonly default?: any[]; readonly examples?: any[]; /** * Does this array describe full reality? * * - If `Standard`, real elements must be exactly equal to the given array. * - If `AttributeList`, the real array may be a superset of the given array. * * @see https://github.com/aws-cloudformation/cloudformation-resource-schema#arraytype */ readonly arrayType?: 'AttributeList' | 'Standard'; } function isArray(x: ConcreteSchema): x is SchemaArray; interface Boolean extends Annotatable { readonly type: 'boolean'; readonly default?: boolean; } const RESOLVED_REFERENCE_SYMBOL: unique symbol; type IsResolved = { /** * If the sub-schema was resolved from a reference, the full reference is in here */ readonly [RESOLVED_REFERENCE_SYMBOL]: string | undefined; }; type ResolvedSchema = (Exclude & IsResolved) | AnyType; function isResolvedSchema(x: Schema): x is ResolvedSchema; /** * Returns the full reference if the given sub-schema was resolved from a reference */ function setResolvedReference(x: ConcreteSchema, ref?: string | undefined): ResolvedSchema; /** * Returns the full reference if the given sub-schema was resolved from a reference */ function resolvedReference(x: jsonschema.Schema): string | undefined; /** * Returns the reference name (the last part of it), if the given sub-schema was resolved from a reference */ function resolvedReferenceName(x: jsonschema.Schema): string | undefined; /** * Make a resolver function that will resolve `$ref` entries with respect to the given document root. */ function makeResolver(root: any): (ref: Schema) => ResolvedSchema; /** * The type of a resolver function */ type Resolver = ReturnType; function isReference(x: Schema | CommonTypeCombinatorFields): x is Reference; interface TopLevelFields { readonly $id?: string; /** * Reusable schema type definitions used in this schema. */ readonly definitions?: Record; } type SchemaFile = jsonschema.RecordLikeObject & jsonschema.TopLevelFields; }