lakutata
Version:
An IoC-based universal application framework.
272 lines (262 loc) • 9.88 kB
TypeScript
/**
* Column types used for @PrimaryGeneratedColumn() decorator.
*/
type PrimaryGeneratedColumnType = "int" | "int2" | "int4" | "int8" | "integer" | "tinyint" | "smallint" | "mediumint" | "bigint" | "dec" | "decimal" | "smalldecimal" | "fixed" | "numeric" | "number";
/**
* Column types where spatial properties are used.
*/
type SpatialColumnType = "geometry" | "geography" | "st_geometry" | "st_point";
/**
* Column types where precision and scale properties are used.
*/
type WithPrecisionColumnType = "float" | "double" | "dec" | "decimal" | "smalldecimal" | "fixed" | "numeric" | "real" | "double precision" | "number" | "datetime" | "datetime2" | "datetimeoffset" | "time" | "time with time zone" | "time without time zone" | "timestamp" | "timestamp without time zone" | "timestamp with time zone" | "timestamp with local time zone";
/**
* Column types where column length is used.
*/
type WithLengthColumnType = "character varying" | "varying character" | "char varying" | "nvarchar" | "national varchar" | "character" | "native character" | "varchar" | "char" | "nchar" | "national char" | "varchar2" | "nvarchar2" | "alphanum" | "shorttext" | "raw" | "binary" | "varbinary" | "string";
type WithWidthColumnType = "tinyint" | "smallint" | "mediumint" | "int" | "bigint";
/**
* All other regular column types.
*/
type SimpleColumnType = "simple-array" | "simple-json" | "simple-enum" | "int2" | "integer" | "int4" | "int8" | "int64" | "unsigned big int" | "float" | "float4" | "float8" | "float64" | "smallmoney" | "money" | "boolean" | "bool" | "tinyblob" | "tinytext" | "mediumblob" | "mediumtext" | "blob" | "text" | "ntext" | "citext" | "hstore" | "longblob" | "longtext" | "alphanum" | "shorttext" | "bytes" | "bytea" | "long" | "raw" | "long raw" | "bfile" | "clob" | "nclob" | "image" | "timetz" | "timestamptz" | "timestamp with local time zone" | "smalldatetime" | "date" | "interval year to month" | "interval day to second" | "interval" | "year" | "seconddate" | "point" | "line" | "lseg" | "box" | "circle" | "path" | "polygon" | "geography" | "geometry" | "linestring" | "multipoint" | "multilinestring" | "multipolygon" | "geometrycollection" | "st_geometry" | "st_point" | "int4range" | "int8range" | "numrange" | "tsrange" | "tstzrange" | "daterange" | "int4multirange" | "int8multirange" | "nummultirange" | "tsmultirange" | "tstzmultirange" | "datemultirange" | "enum" | "set" | "cidr" | "inet" | "inet4" | "inet6" | "macaddr" | "macaddr8" | "bit" | "bit varying" | "varbit" | "tsvector" | "tsquery" | "uuid" | "xml" | "json" | "jsonb" | "varbinary" | "hierarchyid" | "sql_variant" | "rowid" | "urowid" | "uniqueidentifier" | "rowversion" | "array" | "cube" | "ltree";
/**
* Any column type column can be.
*/
type ColumnType = WithPrecisionColumnType | WithLengthColumnType | WithWidthColumnType | SpatialColumnType | SimpleColumnType | BooleanConstructor | DateConstructor | NumberConstructor | StringConstructor;
interface CteCapabilities {
/**
* Are CTEs supported at all?
*/
enabled: boolean;
/**
* Are RETURNING clauses supported in CTEs?
*/
writable?: boolean;
/**
* Is RECURSIVE clause required for recursive CTEs?
*/
requiresRecursiveHint?: boolean;
/**
* Is MATERIALIZED clause supported?
*/
materializedHint?: boolean;
}
/**
* Orm has special columns and we need to know what database column types should be for those types.
* Column types are driver dependant.
*/
interface MappedColumnTypes {
/**
* Column type for the create date column.
*/
createDate: ColumnType;
/**
* Precision of datetime column. Used in MySql to define milliseconds.
*/
createDatePrecision?: number;
/**
* Default value should be used by a database for "created date" column.
*/
createDateDefault: string;
/**
* Column type for the update date column.
*/
updateDate: ColumnType;
/**
* Precision of datetime column. Used in MySql to define milliseconds.
*/
updateDatePrecision?: number;
/**
* Default value should be used by a database for "updated date" column.
*/
updateDateDefault: string;
/**
* Column type for the delete date column.
*/
deleteDate: ColumnType;
/**
* Precision of datetime column. Used in MySql to define milliseconds.
*/
deleteDatePrecision?: number;
/**
* Nullable value should be used by a database for "deleted date" column.
*/
deleteDateNullable: boolean;
/**
* Column type for the version column.
*/
version: ColumnType;
/**
* Column type for the tree level column.
*/
treeLevel: ColumnType;
/**
* Column type of id column used for migrations table.
*/
migrationId: ColumnType;
/**
* Column type of timestamp column used for migrations table.
*/
migrationTimestamp: ColumnType;
/**
* Column type for migration name column used for migrations table.
*/
migrationName: ColumnType;
/**
* Column type for identifier column in query result cache table.
*/
cacheId: ColumnType;
/**
* Column type for identifier column in query result cache table.
*/
cacheIdentifier: ColumnType;
/**
* Column type for time column in query result cache table.
*/
cacheTime: ColumnType;
/**
* Column type for duration column in query result cache table.
*/
cacheDuration: ColumnType;
/**
* Column type for query column in query result cache table.
*/
cacheQuery: ColumnType;
/**
* Column type for result column in query result cache table.
*/
cacheResult: ColumnType;
/**
* Column type for metadata type column in typeorm metadata table.
* Stores type of metadata. E.g. 'VIEW' or 'CHECK'
*/
metadataType: ColumnType;
/**
* Column type for metadata database name column in typeorm metadata table.
*/
metadataDatabase: ColumnType;
/**
* Column type for metadata schema name column in typeorm metadata table.
*/
metadataSchema: ColumnType;
/**
* Column type for metadata table name column in typeorm metadata table.
*/
metadataTable: ColumnType;
/**
* Column type for metadata name column in typeorm metadata table.
*/
metadataName: ColumnType;
/**
* Column type for metadata value column in typeorm metadata table.
*/
metadataValue: ColumnType;
}
interface DataTypeDefaults {
[type: string]: {
length?: number;
width?: number;
precision?: number;
scale?: number;
};
}
/**
* Position object.
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.1
*/
type Position = number[];
/**
* Point geometry object.
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.2
*/
type Point = {
type: "Point";
coordinates: Position;
};
/**
* LineString geometry object.
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.4
*/
type LineString = {
type: "LineString";
coordinates: Position[];
};
/**
* Polygon geometry object.
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.6
*/
type Polygon = {
type: "Polygon";
coordinates: Position[][];
};
/**
* MultiPoint geometry object.
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.3
*/
type MultiPoint = {
type: "MultiPoint";
coordinates: Position[];
};
/**
* MultiLineString geometry object.
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.5
*/
type MultiLineString = {
type: "MultiLineString";
coordinates: Position[][];
};
/**
* MultiPolygon geometry object.
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.7
*/
type MultiPolygon = {
type: "MultiPolygon";
coordinates: Position[][][];
};
/**
* Geometry Collection
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.8
*/
type GeometryCollection = {
type: "GeometryCollection";
geometries: (Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon)[];
};
/**
* Union of Geometry objects.
*/
type Geometry = Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon | GeometryCollection;
type Geography = Geometry;
/**
* A feature object which contains a geometry and associated properties.
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.2
*/
type Feature = {
type: "Feature";
geometry: Geometry;
id?: string | number;
bbox?: number[];
properties: {
[name: string]: any;
} | null;
};
/**
* A collection of feature objects.
* https://datatracker.ietf.org/doc/html/rfc7946#section-3.3
*/
type FeatureCollection = {
type: "FeatureCollection";
bbox?: number[];
features: Feature[];
};
/**
* Union of GeoJSON objects.
*/
type GeoJSON = Geometry | Feature | FeatureCollection;
/**
* Database type.
*/
type DatabaseType = "mysql" | "postgres" | "cockroachdb" | "sap" | "mariadb" | "sqlite" | "cordova" | "react-native" | "nativescript" | "sqljs" | "oracle" | "mssql" | "mongodb" | "aurora-mysql" | "aurora-postgres" | "expo" | "better-sqlite3" | "capacitor" | "spanner";
type ReplicationMode = "master" | "slave";
type UpsertType = "on-conflict-do-update" | "on-duplicate-key-update" | "primary-key";
type IsolationLevel = "READ UNCOMMITTED" | "READ COMMITTED" | "REPEATABLE READ" | "SERIALIZABLE";
export type { ColumnType, CteCapabilities, DataTypeDefaults, DatabaseType, Feature, FeatureCollection, GeoJSON, Geography, Geometry, GeometryCollection, IsolationLevel, LineString, MappedColumnTypes, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon, Position, PrimaryGeneratedColumnType, ReplicationMode, SimpleColumnType, SpatialColumnType, UpsertType, WithLengthColumnType, WithPrecisionColumnType, WithWidthColumnType };