import { AbstractClassType, ClassType, TypeAnnotation } from '@deepkit/core'; import { TypeNumberBrand } from '@deepkit/type-spec'; import { ReceiveType, ReflectionClass } from './reflection.js'; export declare enum ReflectionVisibility { public = 0, protected = 1, private = 2 } export declare enum ReflectionKind { never = 0, any = 1, unknown = 2, void = 3, object = 4, string = 5, number = 6, boolean = 7, symbol = 8, bigint = 9, null = 10, undefined = 11, regexp = 12, literal = 13, templateLiteral = 14, property = 15, method = 16, function = 17, parameter = 18, promise = 19, /** * Uint8Array, Date, custom classes, Set, Map, etc */ class = 20, typeParameter = 21, enum = 22, union = 23, intersection = 24, array = 25, tuple = 26, tupleMember = 27, enumMember = 28, rest = 29, objectLiteral = 30, indexSignature = 31, propertySignature = 32, methodSignature = 33, infer = 34, callSignature = 35 } export type TypeDecorator = (annotations: Annotations, decorator: TypeObjectLiteral) => boolean; export type Annotations = any; /** * @reflection never */ export interface TypeAnnotations { id?: number; origin?: Type; /** * True when this type comes from an inline type, e.g. * * `type A = T;`. Type of `T` is inlined. * `type A = {}`. Type of `{}` is not inlined. * * If the type is not inlined and the result of a type function, then we assign parents of members accordingly. This is not the caee when a type was inlined. */ inlined?: true; /** * If the type was created by a type function, this contains the alias name. */ typeName?: string; /** * If the type was created by a type function, this contains the arguments passed the function. */ typeArguments?: Type[]; /** * Set for index access expressions, e.g. Config['property']. */ indexAccessOrigin?: { container: TypeClass | TypeObjectLiteral; index: Type; }; /** * type User = {id: number, user: string}; * type UserCreate = Pick; * typeOf().originTypes[0].typeName = 'Pick' * typeOf().originTypes[0].typeArguments = [User, 'user'] */ originTypes?: { typeName: string; typeArguments?: Type[]; }[]; annotations?: Annotations; decorators?: Type[]; scheduleDecorators?: TypeObjectLiteral[]; /** * A place where arbitrary jit functions and its cache data is stored. */ jit?: JitContainer; } export declare function applyScheduledAnnotations(type: Type): void; export declare function hasTypeInformation(object: ClassType | Function): boolean; /** * Object to hold runtime jit data. */ export type JitContainer = any; export declare function getTypeJitContainer(type: Type): JitContainer; export declare function clearTypeJitContainer(type: Type): void; export interface TypeNever extends TypeAnnotations { kind: ReflectionKind.never; parent?: Type; } export interface TypeAny extends TypeAnnotations { kind: ReflectionKind.any; parent?: Type; } export interface TypeUnknown extends TypeAnnotations { kind: ReflectionKind.unknown; parent?: Type; } export interface TypeVoid extends TypeAnnotations { kind: ReflectionKind.void; parent?: Type; } export interface TypeObject extends TypeAnnotations { kind: ReflectionKind.object; parent?: Type; } export interface TypeString extends TypeAnnotations { kind: ReflectionKind.string; parent?: Type; } export declare function isIntegerType(type: Type): type is TypeNumber; export interface TypeNumber extends TypeAnnotations { kind: ReflectionKind.number; brand?: TypeNumberBrand; parent?: Type; } export interface TypeBoolean extends TypeAnnotations { kind: ReflectionKind.boolean; parent?: Type; } export interface TypeBigInt extends TypeAnnotations { kind: ReflectionKind.bigint; parent?: Type; } export interface TypeSymbol extends TypeAnnotations { kind: ReflectionKind.symbol; parent?: Type; } export interface TypeNull extends TypeAnnotations { kind: ReflectionKind.null; parent?: Type; } export interface TypeUndefined extends TypeAnnotations { kind: ReflectionKind.undefined; parent?: Type; } export interface TypeLiteral extends TypeAnnotations { kind: ReflectionKind.literal; literal: symbol | string | number | boolean | bigint | RegExp; parent?: Type; } export interface TypeTemplateLiteral extends TypeAnnotations { kind: ReflectionKind.templateLiteral; types: (TypeString | TypeAny | TypeNumber | TypeLiteral | TypeInfer)[]; parent?: Type; } export interface TypeRegexp extends TypeAnnotations { kind: ReflectionKind.regexp; parent?: Type; } export interface TypeBaseMember extends TypeAnnotations { visibility: ReflectionVisibility; abstract?: true; static?: true; optional?: true; readonly?: true; } export interface TypeParameter extends TypeAnnotations { kind: ReflectionKind.parameter; name: string; type: Type; parent: TypeFunction | TypeMethod | TypeMethodSignature | TypeCallSignature; visibility?: ReflectionVisibility; readonly?: true; optional?: true; description?: string; /** * Set when the parameter has a default value aka initializer. */ default?: () => any; } export interface TypeMethod extends TypeBaseMember { kind: ReflectionKind.method; parent: TypeClass; name: number | string | symbol; description?: string; parameters: TypeParameter[]; return: Type; } export interface TypeProperty extends TypeBaseMember { kind: ReflectionKind.property; parent: TypeClass; visibility: ReflectionVisibility; name: number | string | symbol; description?: string; type: Type; /** * Set when the property has a default value aka initializer. */ default?: () => any; } export interface TypeFunction extends TypeAnnotations { kind: ReflectionKind.function; parent?: Type; name?: number | string | symbol; description?: string; function?: Function; parameters: TypeParameter[]; return: Type; } export interface TypeCallSignature extends TypeAnnotations { kind: ReflectionKind.callSignature; parent?: Type; parameters: TypeParameter[]; return: Type; } export interface TypePromise extends TypeAnnotations { kind: ReflectionKind.promise; parent?: Type; type: Type; } export interface TypeClass extends TypeAnnotations { kind: ReflectionKind.class; parent?: Type; classType: ClassType; description?: string; /** * When the class extends another class and uses on it generic type arguments, then those arguments * are in this array. * For example `class A extends B {}` then extendsArguments = [string, boolean]. * The reference to `B` is not part of TypeClass since this information is available in JavaScript runtime * by using `Object.getPrototypeOf(type.classType)`. */ extendsArguments?: Type[]; /** * When the class implements another interface/type, then those types are in this array. * * For example `class A implements B {}` then implements = [B]. */ implements?: Type[]; /** * When class has generic type arguments, e.g. MyClass, it contains * all type arguments. If no type arguments are given, it's undefined. */ arguments?: Type[]; /** * properties/methods. */ types: (TypeIndexSignature | TypeProperty | TypeMethod)[]; } export interface TypeEnum extends TypeAnnotations { kind: ReflectionKind.enum; parent?: Type; enum: { [name: string]: string | number | undefined | null; }; values: (string | number | undefined | null)[]; indexType: Type; description?: string; } export interface TypeEnumMember extends TypeAnnotations { kind: ReflectionKind.enumMember; parent: TypeEnum; name: string; default?: () => string | number; } export interface TypeTypeParameter extends TypeAnnotations { kind: ReflectionKind.typeParameter; parent?: Type; name: string; } export interface TypeUnion extends TypeAnnotations { kind: ReflectionKind.union; parent?: Type; types: Type[]; } export interface TypeIntersection extends TypeAnnotations { kind: ReflectionKind.intersection; parent?: Type; types: Type[]; } export interface TypeArray extends TypeAnnotations { kind: ReflectionKind.array; parent?: Type; type: Type; } export interface TypePropertySignature extends TypeAnnotations { kind: ReflectionKind.propertySignature; parent: TypeObjectLiteral; name: number | string | symbol; optional?: true; readonly?: true; description?: string; type: Type; } export interface TypeMethodSignature extends TypeAnnotations { kind: ReflectionKind.methodSignature; parent: TypeObjectLiteral; name: number | string | symbol; optional?: true; description?: string; parameters: TypeParameter[]; return: Type; } /** * Object literals or interfaces. */ export interface TypeObjectLiteral extends TypeAnnotations { kind: ReflectionKind.objectLiteral; parent?: Type; description?: string; types: (TypeIndexSignature | TypePropertySignature | TypeMethodSignature | TypeCallSignature)[]; /** * When the interface extends another interface/type, then those types are in this array. * * For example `interface A extends B {}` then implements = [B]. */ implements?: Type[]; } export interface TypeIndexSignature extends TypeAnnotations { kind: ReflectionKind.indexSignature; parent: TypeClass | TypeObjectLiteral; index: Type; type: Type; } export interface TypeInfer extends TypeAnnotations { kind: ReflectionKind.infer; parent?: Type; set(type: Type): void; } export interface TypeTupleMember extends TypeAnnotations { kind: ReflectionKind.tupleMember; parent: TypeTuple; type: Type; optional?: true; name?: string; } export interface TypeTuple extends TypeAnnotations { kind: ReflectionKind.tuple; parent?: Type; types: TypeTupleMember[]; } export interface TypeRest extends TypeAnnotations { kind: ReflectionKind.rest; parent: TypeTypeParameter | TypeTupleMember; type: Type; } /** * @reflection never */ export type Type = TypeNever | TypeAny | TypeUnknown | TypeVoid | TypeObject | TypeString | TypeNumber | TypeBoolean | TypeBigInt | TypeSymbol | TypeNull | TypeUndefined | TypeLiteral | TypeTemplateLiteral | TypeParameter | TypeFunction | TypeMethod | TypeProperty | TypePromise | TypeClass | TypeEnum | TypeEnumMember | TypeUnion | TypeIntersection | TypeArray | TypeObjectLiteral | TypeIndexSignature | TypePropertySignature | TypeMethodSignature | TypeTypeParameter | TypeInfer | TypeTuple | TypeTupleMember | TypeRest | TypeRegexp | TypeCallSignature; export type Widen = T extends string ? string : T extends number ? number : T extends bigint ? bigint : T extends boolean ? boolean : T extends symbol ? symbol : T; export type FindType = T extends { kind: infer K; } ? K extends LOOKUP ? T : never : never; /** * Merge dynamic runtime types with static types. In the type-system resolves as any, in runtime as the correct type. * * ```typescript * const stringType = {kind: ReflectionKind.string}; * type t = {a: InlineRuntimeType} * * const value = 34; * type t = {a: InlineRuntimeType} * ``` */ export type InlineRuntimeType | undefined | ReflectionClass | Type | number | string | boolean | bigint, R = any> = T extends ReflectionClass ? K : T extends ReceiveType ? R : T extends Type ? R : T extends undefined ? never : T; export declare function isType(entry: any): entry is Type; export declare function isBinary(type: Type): boolean; export declare function isPrimitive(type: T): boolean; export declare function isPropertyType(type: Type): type is TypePropertySignature | TypeProperty; /** * Returns true if the type is TypePropertySignature | TypeProperty and not a static member. */ export declare function isPropertyMemberType(type: Type): type is TypePropertySignature | TypeProperty; /** * Return all properties created in the constructor (via `constructor(public title: string)`) * * If a non-property parameter is in the constructor, the type is given instead, e.g. `constructor(public title: string, anotherOne:number)` => [TypeProperty, TypeNumber] */ export declare function getConstructorProperties(type: TypeClass | TypeObjectLiteral): { parameters: (TypeProperty | Type)[]; properties: TypeProperty[]; }; export type WithAnnotations = TypeAny | TypeUnknown | TypeString | TypeNumber | TypeBigInt | TypeBoolean | TypeArray | TypeTuple | TypeLiteral | TypeNull | TypeUndefined | TypeClass | TypeObjectLiteral | TypeObject | TypeTemplateLiteral | TypeRegexp | TypeSymbol; export declare function isWithAnnotations(type: ParentLessType): type is WithAnnotations; export declare function getAnnotations(type: WithAnnotations): Annotations; type StackEntry = { left: Type; right: Type; }; /** * Checks if the structure of a and b are identical. */ export declare function isSameType(a: Type, b: Type, stack?: StackEntry[]): boolean; export declare function addType(container: T, type: Type): T; export declare function isTypeIncluded(types: Type[], type: Type, stack?: StackEntry[]): boolean; /** * `true | (string | number)` => `true | string | number` */ export declare function flatten(type: T): T; /** * Flatten nested union types. */ export declare function flattenUnionTypes(types: Type[]): Type[]; /** * empty union => never * union with one member => member * otherwise the union is returned */ export declare function unboxUnion(union: TypeUnion): Type; export declare function findMember(index: string | number | symbol | TypeTemplateLiteral, types: Type[]): TypePropertySignature | TypeMethodSignature | TypeMethod | TypeProperty | TypeIndexSignature | undefined; interface CStack { iterator: Type[]; i: number; round: number; } export declare function emptyObject(type: Type): boolean; export declare class CartesianProduct { protected stack: CStack[]; private current; private next; toGroup(type: Type): Type[]; add(item: Type): void; calculate(): Type[][]; } /** * Query a container type and return the result. * * container[index] * * e.g. {a: string}['a'] => string * e.g. {a: string, b: number}[keyof T] => string | number * e.g. [string, number][0] => string * e.g. [string, number][number] => string | number */ export declare function indexAccess(container: Type, index: Type): Type; export declare function merge(types: (TypeObjectLiteral | TypeClass)[]): TypeObjectLiteral; export declare function narrowOriginalLiteral(type: Type): Type; type GetArrayElement = [T] extends [Array] ? K : never; type RemoveParent = { [P in K]: T[P] extends Type[] ? RemoveParentHomomorphic>[] : T[P] extends Type ? RemoveParentHomomorphic : T[P]; }; type RemoveParentHomomorphic = RemoveParent>; type RemoveDeepParent = T extends infer K ? RemoveParentHomomorphic : never; export type ParentLessType = RemoveDeepParent; /** * This function does not do a deep copy, only shallow. A deep copy makes it way to inefficient, so much that router.spec.ts takes up to 20-30seconds * to complete instead of barely 30ms. */ export declare function copyAndSetParent(inc: T, parent?: Type): FindType; export declare function widenLiteral(type: Type): Type; export declare function assertType(t: Type | undefined, kind: K): asserts t is FindType; export declare function getClassType(type: Type): ClassType; export declare function isMember(type: Type): type is TypePropertySignature | TypeProperty | TypeMethodSignature | TypeMethod; export declare function hasMember(type: TypeObjectLiteral | TypeClass, memberName: number | string | symbol, memberType?: Type): boolean; export declare function getMember(type: TypeObjectLiteral | TypeClass, memberName: number | string | symbol): TypeMethodSignature | TypeMethod | TypePropertySignature | TypeProperty | void; export declare function getTypeObjectLiteralFromTypeClass(type: T): T extends TypeClass ? TypeObjectLiteral : T; /** * Checks whether `undefined` is allowed as type. */ export declare function isOptional(type: Type): boolean; /** * Whether a property has an initializer/default value. */ export declare function hasDefaultValue(type: Type): boolean; /** * Checks whether `null` is allowed as type. */ export declare function isNullable(type: Type): boolean; /** * Integer */ export type integer = number; /** * Integer 8 bit. * Min value -127, max value 128 */ export type int8 = number; /** * Unsigned integer 8 bit. * Min value 0, max value 255 */ export type uint8 = number; /** * Integer 16 bit. * Min value -32768, max value 32767 */ export type int16 = number; /** * Unsigned integer 16 bit. * Min value 0, max value 65535 */ export type uint16 = number; /** * Integer 8 bit. * Min value -2147483648, max value 2147483647 */ export type int32 = number; /** * Unsigned integer 32 bit. * Min value 0, max value 4294967295 */ export type uint32 = number; /** * Float (same as number, but different semantic for databases). */ export type float = number; /** * Float 32 bit. */ export type float32 = number; /** * Float 64 bit. */ export type float64 = number; export declare class AnnotationDefinition { readonly id: string; symbol: symbol; constructor(id: string); register(annotations: Annotations, data: T): void; reset(annotations: Annotations): void; registerType(type: TType, data: T): TType; replace(annotations: Annotations, annotation: T[]): void; replaceType(type: Type, annotation: T[]): void; getAnnotations(type: Type): T[]; getFirst(type: Type): T | undefined; hasAnnotations(type: Type): boolean; } export type AnnotationType> = T extends AnnotationDefinition ? K : never; export type ReferenceActions = 'RESTRICT' | 'NO ACTION' | 'CASCADE' | 'SET NULL' | 'SET DEFAULT'; export interface ReferenceOptions { /** * Default is CASCADE. */ onDelete?: ReferenceActions; /** * Default is CASCADE. */ onUpdate?: ReferenceActions; } /** * note: if this is adjusted, make sure to adjust ReflectionClass, entityAnnotation, and type serializer accordingly. */ export interface EntityOptions { name?: string; description?: string; collection?: string; database?: string; singleTableInheritance?: boolean; indexes?: { names: string[]; options: IndexOptions; }[]; } /** * Type to decorate an interface/object literal with entity information. * * ```typescript * interface User extends Entity<{name: 'user'}> { * id: number & PrimaryKey & AutoIncrement; * username: string & Unique; * } * ``` */ export type Entity = {} & TypeAnnotation<'entity', T>; /** * Marks a property as primary key. * ```typescript * class Entity { * id: number & Primary = 0; * } * ``` */ export type PrimaryKey = TypeAnnotation<'primaryKey'>; type TypeKeyOf = T[keyof T]; export type PrimaryKeyFields = any extends T ? any : { [P in keyof T]: Required extends Required ? T[P] : never; }; export type PrimaryKeyType = any extends T ? any : TypeKeyOf>; export type ReferenceFields = { [P in keyof T]: Required extends Required | Required ? T[P] : never; }; /** * Marks a primary property key as auto-increment. * * ```typescript * class Entity { * id: number & Primary & AutoIncrement = 0; * } * ``` */ export type AutoIncrement = TypeAnnotation<'autoIncrement'>; /** * UUID v4, as string, serialized as string in JSON, and binary in database. * Use `uuid()` as handy initializer. * * ```typescript * class Entity { * id: UUID = uuid(); * } * ``` */ export type UUID = string & TypeAnnotation<'UUIDv4'>; /** * MongoDB's ObjectID type. serialized as string in JSON, ObjectID in database. */ export type MongoId = string & TypeAnnotation<'mongoId'>; /** * Same as `bigint` but serializes to unsigned binary with unlimited size (instead of 8 bytes in most databases). * Negative values will be converted to positive (abs(x)). * * ```typescript * class Entity { * id: BinaryBigInt = 0n; * } * ``` */ export type BinaryBigInt = bigint & TypeAnnotation<'binaryBigInt'>; /** * Same as `bigint` but serializes to signed binary with unlimited size (instead of 8 bytes in most databases). * The binary has an additional leading sign byte and is represented as an uint: 255 for negative, 0 for zero, or 1 for positive. * * ```typescript * class Entity { * id: SignedBinaryBigInt = 0n; * } * ``` */ export type SignedBinaryBigInt = bigint & TypeAnnotation<'signedBinaryBigInt'>; export interface BackReferenceOptions { /** * Necessary for normalised many-to-many relations. This defines the class of the pivot table/collection. */ via?: ClassType | {}; /** * A reference/backReference can define which reference on the other side * reference back. This is necessary when there are multiple outgoing references * to the same entity. */ mappedBy?: string; } export type Reference = TypeAnnotation<'reference', Options>; export type BackReference = TypeAnnotation<'backReference', Options>; export type EmbeddedMeta = TypeAnnotation<'embedded', Options>; export type Embedded = T & EmbeddedMeta; export type MapName = TypeAnnotation<'mapName', [Alias, ForSerializer]>; export declare const referenceAnnotation: AnnotationDefinition; export declare const entityAnnotation: { set(type: Type, name: K, value: EntityOptions[K]): void; get(type: Type): EntityOptions; symbol: symbol; readonly id: string; register(annotations: Annotations, data: EntityOptions): void; reset(annotations: Annotations): void; registerType(type: TType, data: EntityOptions): TType; replace(annotations: Annotations, annotation: EntityOptions[]): void; replaceType(type: Type, annotation: EntityOptions[]): void; getAnnotations(type: Type): EntityOptions[]; getFirst(type: Type): EntityOptions | undefined; hasAnnotations(type: Type): boolean; }; export declare const mapNameAnnotation: AnnotationDefinition<{ name: string; serializer?: string; }>; export declare const autoIncrementAnnotation: AnnotationDefinition; export declare const primaryKeyAnnotation: { isPrimaryKey(type: Type): boolean; symbol: symbol; readonly id: string; register(annotations: Annotations, data: true): void; reset(annotations: Annotations): void; registerType(type: TType, data: true): TType; replace(annotations: Annotations, annotation: true[]): void; replaceType(type: Type, annotation: true[]): void; getAnnotations(type: Type): true[]; getFirst(type: Type): true | undefined; hasAnnotations(type: Type): boolean; }; export interface BackReferenceOptionsResolved { /** * Necessary for normalised many-to-many relations. This defines the class of the pivot table/collection. */ via?: TypeClass | TypeObjectLiteral; /** * A reference/backReference can define which reference on the other side * reference back. This is necessary when there are multiple outgoing references * to the same entity. */ mappedBy?: string; } export declare const backReferenceAnnotation: AnnotationDefinition; export declare const validationAnnotation: AnnotationDefinition<{ name: string; args: Type[]; }>; export declare const UUIDAnnotation: AnnotationDefinition; export declare const mongoIdAnnotation: AnnotationDefinition; export declare const uuidAnnotation: AnnotationDefinition; export declare const defaultAnnotation: AnnotationDefinition; export declare function isUUIDType(type: Type): boolean; export declare function isPrimaryKeyType(type: Type): boolean; export declare function isAutoIncrementType(type: Type): boolean; export declare function isMongoIdType(type: Type): boolean; export declare function isBinaryBigIntType(type: Type): boolean; export declare function isReferenceType(type: Type): boolean; export declare function getReferenceType(type: Type): ReferenceOptions | undefined; export declare function isBackReferenceType(type: Type): boolean; export declare function resolveProperty(type: Type): Type; export declare function getBackReferenceType(type: Type): BackReferenceOptionsResolved; export declare function isDateType(type: Type): boolean; export declare function isSetType(type: Type): boolean; export declare function isMapType(type: Type): boolean; /** * Get the key type of a Map or object literal with index signatures. */ export declare function getKeyType(type: Type): Type; /** * Get the value type of a Map or object literal with index signatures. */ export declare function getValueType(type: Type): Type; export interface EmbeddedOptions { prefix?: string; } export declare const embeddedAnnotation: AnnotationDefinition; export declare function hasEmbedded(type: Type): boolean; /** * Assigns one or multiple groups to a type. * * @example * ```typescript * interface User { * username: string; * password: string & Group<'credentials'>; * } * ``` */ export type Group = TypeAnnotation<'group', Name>; /** * Excludes the type from serialization of all kind. * * @example * ```typescript * interface User { * username: string; * password: string & Excluded; * } * ``` */ export type Excluded = TypeAnnotation<'excluded', Name>; /** * Assigns arbitrary data to a type that can be read in runtime. * * @example * ```typescript * interface User { * username: string; * password: string & Data<'role', 'admin'>; * } * ``` */ export type Data = TypeAnnotation<'data', [Name, Value]>; /** * Resets an already set decorator to undefined. * * The required Name is the name of the type decorator (its first tuple entry). * * ```typescript * type Password = string & MinLength<6> & Excluded; * * interface UserCreationPayload { * password: Password & ResetAnnotation<'excluded'> * } * ``` */ export type ResetAnnotation = TypeAnnotation<'reset', Name>; export type IndexOptions = { name?: string; size?: number; unique?: boolean; spatial?: boolean; sparse?: boolean; fulltext?: boolean; where?: string; expireAfterSeconds?: number; }; export type Unique = TypeAnnotation<'index', Options & { unique: true; }>; export type Index = TypeAnnotation<'index', Options>; export interface DatabaseFieldOptions { /** * The name of the column in the database. * e.g. `userName: string & DatabaseField<{name: 'user_name'}>` * * Can alternatively also be configured by using a different NamingStrategy. */ name?: string; /** * * e.g. `field: string & MySQL<{type: 'VARCHAR(255)'}>` */ type?: string; /** * If the property is on a class, its initializer/default value is per default used. * This can be overridden using this option. * e.g. `field: string & MySQL<{default: 'abc'}>` */ default?: any; /** * e.g. `field: string & MySQL<{defaultExpr: 'NOW()'}>` */ defaultExpr?: any; /** * If true no default column value is inferred from the property initializer/default value. * e.g. `field: string & MySQL<{noDefault: true}> = ''` */ noDefault?: true; /** * Skip this property in all queries and database migration files. */ skip?: true; /** * Skip this property in database migration files. This excludes the property from the database, but * keeps it in the queries. */ skipMigration?: true; } export interface MySQLOptions extends DatabaseFieldOptions { } export interface PostgresOptions extends DatabaseFieldOptions { } export interface SqliteOptions extends DatabaseFieldOptions { } type Database = TypeAnnotation<'database', [Name, Options]>; export type MySQL = Database<'mysql', Options>; export type Postgres = Database<'postgres', Options>; export type SQLite = Database<'sqlite', Options>; export type DatabaseField = Database; export declare const enum BinaryBigIntType { unsigned = 0, signed = 1 } export declare const binaryBigIntAnnotation: AnnotationDefinition; export declare const groupAnnotation: AnnotationDefinition; export declare const excludedAnnotation: { isExcluded(type: Type, name: string): boolean; symbol: symbol; readonly id: string; register(annotations: Annotations, data: string): void; reset(annotations: Annotations): void; registerType(type: TType, data: string): TType; replace(annotations: Annotations, annotation: string[]): void; replaceType(type: Type, annotation: string[]): void; getAnnotations(type: Type): string[]; getFirst(type: Type): string | undefined; hasAnnotations(type: Type): boolean; }; export declare const dataAnnotation: { set(type: T, key: string, value: any): T; get(type: Type, key: string): any; symbol: symbol; readonly id: string; register(annotations: Annotations, data: { [name: string]: any; }): void; reset(annotations: Annotations): void; registerType(type: TType, data: { [name: string]: any; }): TType; replace(annotations: Annotations, annotation: { [name: string]: any; }[]): void; replaceType(type: Type, annotation: { [name: string]: any; }[]): void; getAnnotations(type: Type): { [name: string]: any; }[]; getFirst(type: Type): { [name: string]: any; } | undefined; hasAnnotations(type: Type): boolean; }; /** * All raw data from `TypeAnnotation` types. */ export declare const typeAnnotation: { /** * Returns the parsed Type to JS objects, e.g. `{name: string}` => `{name: 'xy'}` */ getOption(type: Type, name: string): any; /** * Returns the Type object of the annotation which can be parsed with `typeToObject`. */ getType(type: Type, name: string): Type | undefined; symbol: symbol; readonly id: string; register(annotations: Annotations, data: { name: string; options: Type; }): void; reset(annotations: Annotations): void; registerType(type: TType, data: { name: string; options: Type; }): TType; replace(annotations: Annotations, annotation: { name: string; options: Type; }[]): void; replaceType(type: Type, annotation: { name: string; options: Type; }[]): void; getAnnotations(type: Type): { name: string; options: Type; }[]; getFirst(type: Type): { name: string; options: Type; } | undefined; hasAnnotations(type: Type): boolean; }; export declare const indexAnnotation: AnnotationDefinition; export declare const databaseAnnotation: { getDatabase(type: Type, name: string): T | undefined; symbol: symbol; readonly id: string; register(annotations: Annotations, data: { name: string; options: { [name: string]: any; }; }): void; reset(annotations: Annotations): void; registerType(type: TType, data: { name: string; options: { [name: string]: any; }; }): TType; replace(annotations: Annotations, annotation: { name: string; options: { [name: string]: any; }; }[]): void; replaceType(type: Type, annotation: { name: string; options: { [name: string]: any; }; }[]): void; getAnnotations(type: Type): { name: string; options: { [name: string]: any; }; }[]; getFirst(type: Type): { name: string; options: { [name: string]: any; }; } | undefined; hasAnnotations(type: Type): boolean; }; export declare function registerTypeDecorator(decorator: TypeDecorator): void; /** * Type annotations are object literals with a single optional __meta in it * that has as type a tuple with the name of the annotation as first entry. * The tuple is intersected with the `never` type to make sure it does not * interfere with type checking. * * The processor has currently implemented to not resolve `never & x` to `never`, * so we still have the intersection type in runtime to resolve __meta correctly. * * ```typescript * type MyAnnotation1 = TypeAnnotation<'myAnnotation'> * type MyAnnotation1 = TypeAnnotation<'myAnnotation', T> * * //under the hood it is: * type lowLevel1 = { __meta?: never & ['myAnnotation'] } * type lowLevel2 = { __meta?: never & ['myAnnotation', T] } * ``` */ export declare function getAnnotationMeta(type: TypeObjectLiteral): { id: string; options: Type; } | undefined; export declare const typeDecorators: TypeDecorator[]; export declare function typeToObject(type?: Type, state?: { stack: Type[]; }): any; export declare function memberNameToString(name: number | string | symbol): string; export declare const binaryTypes: ClassType[]; /** * Returns true if the given type is Date, ArrayBuffer, Uint8Array, etc. */ export declare function isGlobalTypeClass(type: Type): type is TypeClass; /** * Returns true if the given type is TypeClass and references a custom (non-global) class. */ export declare function isCustomTypeClass(type: Type): type is TypeClass; /** * Returns a type predicate that checks if the given type is a class and is of the given classType. * If withInheritance is true, it also checks if the type is a subclass of the given classType. */ export declare function isTypeClassOf(classType: ClassType, withInheritance?: boolean): (type: Type) => boolean; /** * Returns the members of a class or object literal. */ export declare function resolveTypeMembers(type: TypeClass | TypeObjectLiteral): (TypeProperty | TypePropertySignature | TypeMethodSignature | TypeMethod | TypeIndexSignature | TypeCallSignature)[]; export declare function stringifyResolvedType(type: Type): string; export declare function stringifyShortResolvedType(type: Type, stateIn?: Partial): string; /** * Returns all (including inherited) constructor properties of a class. */ export declare function getDeepConstructorProperties(type: TypeClass): TypeParameter[]; /** * Returns the index to `type.values` if the given value is part of the enum, exactly or case-insensitive. * Returns -1 if not found. */ export declare function getEnumValueIndexMatcher(type: TypeEnum): (value: string | number | undefined | null) => number; interface StringifyTypeOptions { showNames: boolean; showFullDefinition: boolean; showDescription: boolean; defaultIsOptional: boolean; showHeritage: boolean; showDefaults: boolean; defaultValues: any; stringify?: (type: Type) => string | undefined; } export declare function stringifyType(type: Type, stateIn?: Partial): string; export declare function annotateClass(clazz: ClassType | AbstractClassType, type?: ReceiveType): void; export {}; export declare type __ΩReflectionVisibility = any[]; export declare type __ΩReflectionKind = any[]; export declare type __ΩTypeDecorator = any[]; export declare type __ΩAnnotations = any[]; export declare type __ΩJitContainer = any[]; export declare type __ΩTypeNever = any[]; export declare type __ΩTypeAny = any[]; export declare type __ΩTypeUnknown = any[]; export declare type __ΩTypeVoid = any[]; export declare type __ΩTypeObject = any[]; export declare type __ΩTypeString = any[]; export declare type __ΩTypeNumber = any[]; export declare type __ΩTypeBoolean = any[]; export declare type __ΩTypeBigInt = any[]; export declare type __ΩTypeSymbol = any[]; export declare type __ΩTypeNull = any[]; export declare type __ΩTypeUndefined = any[]; export declare type __ΩTypeLiteral = any[]; export declare type __ΩTypeTemplateLiteral = any[]; export declare type __ΩTypeRegexp = any[]; export declare type __ΩTypeBaseMember = any[]; export declare type __ΩTypeParameter = any[]; export declare type __ΩTypeMethod = any[]; export declare type __ΩTypeProperty = any[]; export declare type __ΩTypeFunction = any[]; export declare type __ΩTypeCallSignature = any[]; export declare type __ΩTypePromise = any[]; export declare type __ΩTypeClass = any[]; export declare type __ΩTypeEnum = any[]; export declare type __ΩTypeEnumMember = any[]; export declare type __ΩTypeTypeParameter = any[]; export declare type __ΩTypeUnion = any[]; export declare type __ΩTypeIntersection = any[]; export declare type __ΩTypeArray = any[]; export declare type __ΩTypePropertySignature = any[]; export declare type __ΩTypeMethodSignature = any[]; export declare type __ΩTypeObjectLiteral = any[]; export declare type __ΩTypeIndexSignature = any[]; export declare type __ΩTypeInfer = any[]; export declare type __ΩTypeTupleMember = any[]; export declare type __ΩTypeTuple = any[]; export declare type __ΩTypeRest = any[]; export declare type __ΩWiden = any[]; export declare type __ΩFindType = any[]; export declare type __ΩInlineRuntimeType = any[]; export declare type __ΩWithAnnotations = any[]; export declare type __ΩParentLessType = any[]; export declare type __Ωinteger = any[]; export declare type __Ωint8 = any[]; export declare type __Ωuint8 = any[]; export declare type __Ωint16 = any[]; export declare type __Ωuint16 = any[]; export declare type __Ωint32 = any[]; export declare type __Ωuint32 = any[]; export declare type __Ωfloat = any[]; export declare type __Ωfloat32 = any[]; export declare type __Ωfloat64 = any[]; export declare type __ΩAnnotationType = any[]; export declare type __ΩReferenceActions = any[]; export declare type __ΩReferenceOptions = any[]; export declare type __ΩEntityOptions = any[]; export declare type __ΩEntity = any[]; export declare type __ΩPrimaryKey = any[]; export declare type __ΩPrimaryKeyFields = any[]; export declare type __ΩPrimaryKeyType = any[]; export declare type __ΩReferenceFields = any[]; export declare type __ΩAutoIncrement = any[]; export declare type __ΩUUID = any[]; export declare type __ΩMongoId = any[]; export declare type __ΩBinaryBigInt = any[]; export declare type __ΩSignedBinaryBigInt = any[]; export declare type __ΩBackReferenceOptions = any[]; export declare type __ΩReference = any[]; export declare type __ΩBackReference = any[]; export declare type __ΩEmbeddedMeta = any[]; export declare type __ΩEmbedded = any[]; export declare type __ΩMapName = any[]; export declare type __ΩBackReferenceOptionsResolved = any[]; export declare type __ΩEmbeddedOptions = any[]; export declare type __ΩGroup = any[]; export declare type __ΩExcluded = any[]; export declare type __ΩData = any[]; export declare type __ΩResetAnnotation = any[]; export declare type __ΩIndexOptions = any[]; export declare type __ΩUnique = any[]; export declare type __ΩIndex = any[]; export declare type __ΩDatabaseFieldOptions = any[]; export declare type __ΩMySQLOptions = any[]; export declare type __ΩPostgresOptions = any[]; export declare type __ΩSqliteOptions = any[]; export declare type __ΩMySQL = any[]; export declare type __ΩPostgres = any[]; export declare type __ΩSQLite = any[]; export declare type __ΩDatabaseField = any[]; export declare type __ΩBinaryBigIntType = any[];