import type { FunctionParameterDef, TypeDesc, Expr, FunctionParamTypeDesc, BasicExpressionType, FunctionReturnTypeDesc, FunctionParameterTypeDef, ExpressionType, EvalSpace, FunctionGenericTypeDef } from '../../model/malloy_types'; import type { SQLExprElement } from '../../model/utils'; export interface DialectFunctionOverloadDef { returnType: FunctionReturnTypeDesc; params: FunctionParameterDef[]; genericTypes?: { name: string; acceptibleTypes: FunctionGenericTypeDef[]; }[]; e: Expr; needsWindowOrderBy?: boolean; isSymmetric?: boolean; supportsOrderBy?: boolean | 'only_default'; defaultOrderByArgIndex?: number; supportsLimit?: boolean; between: { preceding: number | string; following: number | string; } | undefined; } export declare function arg(name: string): Expr; export declare function spread(e: Expr, prefix?: string | undefined, suffix?: string | undefined): Expr; export declare function sql(strings: TemplateStringsArray, ...subExprs: SQLExprElement[]): Expr; export declare function constant(type: T): T & TypeDescExtras; export declare function output(type: T): T & TypeDescExtras; export declare function literal(type: T): T & TypeDescExtras; export declare function variadicParam(name: string, ...allowedTypes: FunctionParamTypeDesc[]): FunctionParameterDef; /** * Prefer `makeParam` for future function definitions */ export declare function param(name: string, ...allowedTypes: FunctionParamTypeDesc[]): FunctionParameterDef; export declare function makeParam(name: string, ...allowedTypes: FunctionParamTypeDesc[]): { param: FunctionParameterDef; arg: Expr; }; export declare function maxScalar(type: T): T & TypeDescExtras; export declare function maxAggregate(type: T): T & TypeDescExtras; export declare function anyExprType(type: T): T & TypeDescExtras; export declare function maxUngroupedAggregate(type: FunctionParameterTypeDef): FunctionParamTypeDesc; type TypeDescExtras = { expressionType: ExpressionType | undefined; evalSpace: EvalSpace; }; export declare function maxAnalytic(type: T): T & TypeDescExtras; export declare function minScalar(type: T): T & TypeDescExtras; export declare function minAggregate(type: T): T & TypeDescExtras; export declare function minAnalytic(type: T): T & TypeDescExtras; export declare function overload(returnType: TypeDesc, params: FunctionParameterDef[], e: Expr, options?: { needsWindowOrderBy?: boolean; between?: { preceding: number | string; following: number | string; }; isSymmetric?: boolean; supportsLimit?: boolean; defaultOrderByArgIndex?: number; supportsOrderBy?: boolean | 'only_default'; }): DialectFunctionOverloadDef; export interface ArrayBlueprint { array: TypeDescElementBlueprintOrNamedGeneric; } export type TypeDescElementBlueprintOrNamedGeneric = TypeDescElementBlueprint | NamedGeneric; export interface RecordBlueprint { record: Record; } export interface SQLNativeTypeBlueprint { sql_native: string; } export type LeafPlusType = BasicExpressionType | 'any'; export type TypeDescElementBlueprint = LeafPlusType | ArrayBlueprint | RecordBlueprint | SQLNativeTypeBlueprint; export type NamedGeneric = { generic: string; }; export type TypeDescBlueprint = TypeDescElementBlueprintOrNamedGeneric | { literal: TypeDescElementBlueprintOrNamedGeneric; } | { constant: TypeDescElementBlueprintOrNamedGeneric; } | { dimension: TypeDescElementBlueprintOrNamedGeneric; } | { measure: TypeDescElementBlueprintOrNamedGeneric; } | { calculation: TypeDescElementBlueprintOrNamedGeneric; }; type ParamTypeBlueprint = TypeDescBlueprint | TypeDescBlueprint[] | { variadic: TypeDescBlueprint | TypeDescBlueprint[]; }; export interface SignatureBlueprint { generic?: { [name: string]: TypeDescElementBlueprintOrNamedGeneric[]; }; takes: { [name: string]: ParamTypeBlueprint; }; returns: TypeDescBlueprint; supportsOrderBy?: boolean | 'only_default'; supportsLimit?: boolean; isSymmetric?: boolean; } interface ImplementationBlueprintBase { needsWindowOrderBy?: boolean; between?: { preceding: number | string; following: number | string; }; defaultOrderByArgIndex?: number; } interface ImplementationBlueprintSql extends ImplementationBlueprintBase { sql: string; } interface ImplementationBlueprintExpr extends ImplementationBlueprintBase { expr: Expr; } interface ImplementationBlueprintFunction extends ImplementationBlueprintBase { function: string; } export type ImplementationBlueprint = ImplementationBlueprintSql | ImplementationBlueprintExpr | ImplementationBlueprintFunction; export interface DefinitionBlueprint extends SignatureBlueprint { impl: ImplementationBlueprint; } export type OverloadedDefinitionBlueprint = { [signatureName: string]: DefinitionBlueprint; }; export type DefinitionBlueprintMap = { [name: string]: DefinitionBlueprint | OverloadedDefinitionBlueprint; }; export type OverloadedImplementationBlueprint = { [signatureName: string]: ImplementationBlueprint; }; export type OverrideMap = { [name: string]: ImplementationBlueprint | OverloadedImplementationBlueprint; }; export declare function expandBlueprintMap(blueprints: DefinitionBlueprintMap): { [name: string]: DialectFunctionOverloadDef[]; }; export declare function expandOverrideMapFromBase(base: DefinitionBlueprintMap, overrides: OverrideMap): { [name: string]: DialectFunctionOverloadDef[]; }; /** * Shortcut for non overloaded functions definitions. Default implementation * will be the function name turned to upper case. Default type for * any generics encountered will be `['any']`. Both of these can be over-ridden * in the `options` parameter. * * The two implict defaults (which can be over-ridden) are that the * impl: will be the upper case version of the function name, and that * any generic reference will be of type 'any'. * * USAGE: * * ...def('func_name', {'arg0': 'type0', 'arg1': 'type1'}, 'return-type') * * @param name name of function * @param takes Record * @param returns Return Blueprint * @param options Everything from a `DefinitionBlueprint` except `takes` and `returns` * @returns dot dot dot able blueprint definition */ export declare function def(name: string, takes: Record, returns: TypeDescBlueprint, options?: Partial>): { [name]: DefinitionBlueprint; }; export {};