/** * query-interface.ts * * The "medium stage" for converting from an SQL ast to what the actual typescript types are. * Everything that can be processed, that does **not** require access to the database is done. * Also a plan of what to load exactly from the database is generated, so that the loading can be done efficiently later by [load.ts](./load.ts) */ import { AstTag, ReturningListItemTag, SelectListItemTag, TableTag, Tag } from './grammar.types'; import { pgTypes } from './postgres-types-map'; import { Param, Source, QueryInterface, Type, TypeContext, OperatorVariantPart, OperatorVariant } from './query-interface.types'; /** * A {@link Tag} used to determine results of {@link QueryInterface} */ declare type ResultTag = SelectListItemTag | ReturningListItemTag; /** * Get the type from a part of a binary operator expression {@link BinaryExpressionTag} * First attempt to get an exact match * Otherwise check variants if at least one part matches. * * If there are multiple variants that match, return "unknown" */ export declare const toConstantBinaryOperatorVariant: (variants: OperatorVariant[], left: Type, right: Type, part: OperatorVariantPart) => Type; /** * Convert a string of a postgres native type into a predefined type of {@link pgTypes} * The type in postgres is defined with various underscore prefixes or quoted, with various cases. */ export declare const toAliasedPgType: (type?: string) => keyof typeof pgTypes; /** * Convert postgres type into a potygen {@link TypeConstant} */ export declare const toPgTypeConstant: (type?: string) => Type | undefined; /** * Get the "from" table of a query */ export declare const toQueryFrom: (sql: AstTag) => TableTag | undefined; /** * Get the {@link ResultTag} for for {@link QueryInterface} from {@link AstTag} */ export declare const toQueryResults: (sql: AstTag) => Array; /** * Get all {@link Param} of an sql query or any sql tag. Works recursively */ export declare const toParams: (context: TypeContext) => (sql: Tag) => Param[]; /** * Get all the {@link Source} of a SQL query. */ export declare const toSources: (sql: AstTag) => Source[]; /** * Get the {@link QueryInterface} of an sql query. * * Nested sub-queries have access to more sources than just what's available inside it. */ export declare const toQueryInterface: (sql: AstTag, parentSources?: Source[]) => QueryInterface; export {};