import { type, Type } from '../' import { Expression } from '../../expressions' import { ConstraintConfig } from '../../functions' import { IntegralExpression } from './integral' import { NumberExpression } from './number' export * from './integral' export * from './number' export const SMALLINT = () => type`SMALLINT` as SmallintType export const SMALLSERIAL = () => type`SMALLSERIAL` as SmallintType export type SmallintArg = SmallintType['argument'] export interface SmallintType extends Type<'SMALLINT', R> { expression: IntegralExpression> argument: Expression | this['input'] required(conf?: ConstraintConfig): SmallintType } export const INTEGER = () => type`INTEGER` as IntegerType export const SERIAL = () => type`SERIAL` as IntegerType export type IntegerArg = IntegerType['argument'] export interface IntegerType extends Type<'INTEGER', R> { expression: IntegralExpression> argument: Expression | this['input'] | Expression required(conf?: ConstraintConfig): IntegerType } export const BIGINT = () => type`BIGINT` as BigintType export const BIGSERIAL = () => type`SERIAL` as BigintType export type BigintArg = BigintType['argument'] export interface BigintType extends Type<'BIGINT', R> { expression: IntegralExpression> argument: Expression | this['input'] | Expression | Expression required(conf?: ConstraintConfig): BigintType } export const NUMERIC = () => type`NUMERIC` as NumericType export type NumericArg = NumericType['argument'] export interface NumericType extends Type<'NUMERIC', R> { expression: NumberExpression> argument: Expression | this['input'] | Expression | Expression | Expression required(conf?: ConstraintConfig): NumericType } export const REAL = () => type`REAL` as RealType export type RealArg = RealType['argument'] export interface RealType extends Type<'REAL', R> { expression: NumberExpression> argument: Expression | this['input'] | Expression | Expression | Expression | Expression required(conf?: ConstraintConfig): RealType } export const DOUBLE = () => type`DOUBLE PRECISION` as DoubleType export type DoubleArg = DoubleType['argument'] export interface DoubleType extends Type<'DOUBLE', R> { expression: NumberExpression> argument: Expression | this['input'] | Expression | Expression | Expression | Expression | Expression required(conf?: ConstraintConfig): DoubleType } export type MathTypesPrec = [SmallintType, IntegerType, BigintType, NumericType, RealType, DoubleType] export type InferMathTypePrec> = T extends [...infer R, infer L] ? L extends X ? X : L extends Y ? Y : InferMathTypePrec : never export type ToMathExpression = T extends MathExpression ? T : Expression export type MathType = SmallintType | IntegerType | BigintType | NumericType | RealType | DoubleType export type MathExpression = MathType['expression'] export type MathLiteral = MathType['input'] export type MathArg = MathType['argument'] export type IntegralType = SmallintType | IntegerType | BigintType export type IntegralLiteral = IntegralType['input'] export type IntegralArg = IntegralType['argument']