import type { Platform } from '../platforms' ; import type { Constructor , EntityProperty } from '../typings' ; export abstract class Type < JSType = string , DBType = JSType > { private static readonly types = new Map ( ) ; /**
     * Converts a value from its JS representation to its database representation of this type.
     */ convertToDatabaseValue ( value , platform , fromQuery ? ) { return value as DBType ; } /**
     * Converts a value from its database representation to its JS representation of this type.
     */ convertToJSValue ( value , platform ) { return value as JSType ; } /**
     * Converts a value from its JS representation to its database representation of this type.
     */ convertToDatabaseValueSQL ? ( key , platform ) ; /**
     * Modifies the SQL expression (identifier, parameter) to convert to a JS value.
     */ convertToJSValueSQL ? ( key , platform ) ; /**
     * How should the raw database values be compared? Used in `EntityComparator`.
     * Possible values: string | number | boolean | date | any | buffer | array
     */ compareAsType ( ) { return 'any' ; } /**
     * Converts a value from its JS representation to its serialized JSON form of this type.
     * By default uses the runtime value.
     */ toJSON ( value , platform ) { return value ; } /**
     * Gets the SQL declaration snippet for a field of this type.
     */ getColumnType ( prop , platform ) { return prop . columnTypes ?. [ 0 ] ?? platform . getTextTypeDeclarationSQL ( prop ) ; } static getType < JSType , DBType = JSType > ( cls ) { const key = cls . name ; if ( ! Type . types . has ( key ) ) { Type . types . set ( key , new cls ( ) ) ; } return Type . types . get ( key ) ; } }