import { PgLiteral, PgLiteralValue } from "../utils/PgLiteral.js"; //#region src/operations/generalTypes.d.ts /** * Type that provides auto-suggestions but also any string. * * @see https://github.com/microsoft/TypeScript/issues/29729#issuecomment-471566609 */ type LiteralUnion = TSuggested | (TBase & { zz_IGNORE_ME?: never; }); type PublicPart = { [K in keyof T]: T[K] }; type Nullable = { [P in keyof T]: T[P] | null }; type Value = null | boolean | string | number | PgLiteral | PgLiteralValue | Value[]; type Type = string | { type: string; }; type Name = string | { schema?: string; name: string; } | PgLiteralValue; /** * Type guard for the object form of {@link Name}. * * Note: This only checks shape (presence of a "name" property). It intentionally * does not validate contents. */ declare function isNameObject(val: unknown): val is Exclude; /** * Type guard for schema-qualified {@link Name} objects. */ declare function isSchemaNameObject(val: unknown): val is { schema: string; name: string; }; interface IfNotExistsOption { ifNotExists?: boolean; } interface IfExistsOption { ifExists?: boolean; } interface CascadeOption { cascade?: boolean; } type DropOptions = IfExistsOption & CascadeOption; /** * A function that returns a normal SQL statement or an array of SQL statements. * * The array is useful for operations that need to return multiple SQL statements like an additional `COMMENT`. */ type OperationFn = (...args: any[]) => string | string[]; /** * A function that returns a normal SQL statement or an array of SQL statements. * * The array is useful for operations that need to return multiple SQL statements like an additional `COMMENT`. * * The `reverse` property is a function that takes the same arguments and try to infer the reverse SQL statement with that. */ type Operation = OperationFn & { /** * Reverse the operation if provided. */ reverse?: OperationFn; }; /** * A function that returns a normal SQL statement or an array of SQL statements. * * The array is useful for operations that need to return multiple SQL statements like an additional `COMMENT`. * * The `reverse` property is a function that takes the same arguments and try to infer the reverse SQL statement with that. */ type Reversible string | string[]> = TFunction & { /** * Reverse the operation. * * Needs to be the same function definition, because it takes the same * arguments and try to infer the reverse SQL statement with that. */ reverse: TFunction; }; //#endregion export { CascadeOption, DropOptions, IfExistsOption, IfNotExistsOption, LiteralUnion, Name, Nullable, Operation, OperationFn, PublicPart, Reversible, Type, Value, isNameObject, isSchemaNameObject };