/** * Type utilities. */ import { Selectable, SelectArg, SelectExpression, Selection } from 'kysely'; /** * Type of the key tuple whose column names are given by `KA` and are * found in the table interface `T`. Supports up to 4 columns. * @typeParam T Table interface. * @typeParam KA Array of the key column names. */ export type KeyTuple & string)[]>> = KA[3] extends string ? [ Selectable[KA[0]], Selectable[KA[1]], Selectable[KA[2]], Selectable[KA[3]] ] : KA[2] extends string ? [Selectable[KA[0]], Selectable[KA[1]], Selectable[KA[2]]] : KA[1] extends string ? [Selectable[KA[0]], Selectable[KA[1]]] : KA[0] extends string ? [Selectable[KA[0]]] : never; /** * Require specified properties of a type, leaving the rest optional. * @typeParam T Type to require properties from. * @typeParam K Keys of the properties to require. */ export type RequireSome = Omit & Required>; /** * Shorthand type for a selectable column, restricted to a column name. */ export type SelectableColumn = keyof Selectable & string; /** * Selectable column name or column alias. */ export type SelectionColumn = SelectableColumn | (SelectExpression & `${SelectableColumn} as ${string}`); /** * Type of a selected row, evaluating to all columns if `S` is `['*']`. */ export type SelectedRow, S extends SelectArg | ['*']> = S extends ['*'] ? Selectable : Selection; /** * Tuple of up to four selectable columns. */ export type SelectableColumnTuple = [SelectableColumn] | [SelectableColumn, SelectableColumn] | [SelectableColumn, SelectableColumn, SelectableColumn] | [ SelectableColumn, SelectableColumn, SelectableColumn, SelectableColumn ]; //# sourceMappingURL=type-utils.d.ts.map