import { DependencyTree } from "../runtime/runtimeTypes"; export declare type DbIdType = number; export declare type RelationNameType = string; export declare type ColumnNameType = string; export declare type LogicalTimestep = number; export declare type ToBeFilled = T | undefined; export declare type HasDefault = T | undefined; export declare type Optional = T | undefined; export declare type NotNeededForCompiledAst = T | undefined; export declare type ExpressionValue = DielAst | OriginalRelation | DerivedRelation | ColumnSelection | ColumnSelection[] | Column | Column[] | OrderByAst | OrderByAst[] | CompositeSelectionUnit | RelationSelection | RelationConstraints | Command[] | DropClause | DeleteClause | string | string[] | RawValues | ProgramsParserIr | JoinAst | GroupByAst | ExprValAst | ExprStarAst | ExprAst | ExprAst[] | RelationReferenceDirect | RelationReferenceSubquery | SelectionUnit | InsertionClause | UdfType | TemplateVariableAssignmentUnit | null; export interface DielTemplate { variables: string[]; ast: JoinAst | RelationSelection; } export declare type TemplateVariableAssignments = Map; export interface TemplateVariableAssignmentUnit { variable: string; assignment: string; } export declare enum DielDataType { Void = "Void", String = "String", Number = "Number", TimeStamp = "TimeStamp", Boolean = "Boolean", Relation = "Relation" } export declare const enum RelationType { View = "View", Output = "Output", Table = "Table", EventTable = "EventTable", EventView = "EventView", DerivedTable = "DerivedTable", ExistingAndImmutable = "ExistingAndImmutable" } export declare enum StaticRelationType { Local = "Local", WebWorker = "WebWorker", Server = "Server" } export declare enum ProgramType { Udf = "Udf", Insert = "Insert" } export declare enum LoggingLevels { Verbose = "Verbose", Succinct = "Succinct" } export interface TransferInfo { depViews: string; location: string; } export interface UdfType { udf: string; type: DielDataType; } interface BuiltInColumnType { column: string; type: DielDataType; } export declare const BuiltInColumnTyppes: BuiltInColumnType[]; export declare const BuiltInUdfTypes: UdfType[]; export declare enum RelationOrigin { User = "User", DerivedFromCaching = "DerivedFromCaching", DerivedFromMaterialization = "DerivedFromMaterialization" } interface RelationBase { rName: string; origin?: HasDefault; replaces?: Optional; isReplaced?: HasDefault; constraints?: Optional; relationType: RelationType; } export interface DerivedRelation extends RelationBase { selection: RelationSelection; cachable?: HasDefault; } export interface OriginalRelation extends RelationBase { columns: Column[]; copyFrom?: string; } export declare type Relation = DerivedRelation | OriginalRelation; export declare type Command = RelationSelection | InsertionClause | DropClause | DeleteClause; export declare type ForeignKey = { sourceColumn: string; targetRelation: string; targetColumn: string; }; export interface RelationConstraints { relationNotNull?: HasDefault; relationHasOneRow?: HasDefault; primaryKey?: Optional; notNull?: Optional; uniques?: Optional; exprChecks?: Optional; foreignKeys?: Optional; } export declare function NewRelationConstraints(): RelationConstraints; /** * If input is not specified, i.e. "", it's over all inputs. */ export declare type ProgramsIr = Map; export interface DielConfig { name?: string; existingDbPath?: string; loggingLevel?: string; } export interface DielContext { program?: { isGeneral: boolean; name?: string; }; } export interface DielAst { relations: Relation[]; replacedRelations: Relation[]; commands: Command[]; programs: ProgramsIr; udfTypes: UdfType[]; depTree?: ToBeFilled; } export declare function createEmptyDielAst(): DielAst; export declare type ProgramsParserIr = { events: RelationNameType[]; queries: Command[]; }; export interface Column { cName: string; dataType?: ToBeFilled; constraints?: Optional; defaultValue?: Optional; } export interface ColumnConstraints { notNull: boolean; autoincrement: boolean; unique: boolean; primaryKey: boolean; } export declare enum JoinType { LeftOuter = "LeftOuter", Inner = "Inner", Natural = "Natural", CROSS = "Cross" } /** * NA is used fort he first relation */ export declare enum SetOperator { NA = "NA", UNION = "UNION", INTERSECT = "INTERSECT" } export declare enum AstType { Drop = "Drop", Delete = "Delete", Insert = "Insert", Join = "Join", RelationSelection = "RelationSelection" } interface AstBase { astType: AstType; } export interface CompositeSelectionUnit { op: SetOperator; relation: SelectionUnit; } export declare type CompositeSelection = CompositeSelectionUnit[]; export interface RelationSelection extends AstBase { templateSpec?: TemplateVariableAssignments; compositeSelections: CompositeSelection; } /** * a recursive data structure that is the meat of DIEL IR * derivedColumnSelections contains normalized selections * - all selections have specified source relations * - no more stars * - then it's filled by the type inference pass */ export interface SelectionUnit { isDistinct?: HasDefault; columnSelections?: NotNeededForCompiledAst; derivedColumnSelections?: ToBeFilled; baseRelation?: Optional; joinClauses?: Optional; whereClause?: Optional; groupByClause?: Optional; orderByClause?: Optional; limitClause?: Optional; } export interface ColumnSelection { expr: ExprAst; alias?: ToBeFilled; } export declare enum RelationReferenceType { Direct = "Direct", Subquery = "Subquery" } export declare type RelationReference = RelationReferenceDirect | RelationReferenceSubquery; export interface RelationReferenceBase { relationReferenceType: RelationReferenceType; alias?: ToBeFilled; } export interface RelationReferenceDirect extends RelationReferenceBase { relationName: ToBeFilled; isLatest?: HasDefault; } export interface RelationReferenceSubquery extends RelationReferenceBase { alias: string; subquery: RelationSelection; wasFromLatest?: HasDefault; } export interface JoinAst extends AstBase { templateSpec?: TemplateVariableAssignments; joinType: JoinType; relation: RelationReference; predicate?: Optional; } export declare type RawValues = (string | number | boolean)[]; /** * Insertion clause is either direct insertion of values * or derived another view */ export interface InsertionClause extends AstBase { relation: string; columns: string[]; selection?: RelationSelection; values?: RawValues; } export declare enum Order { ASC = "ASC", DESC = "DESC" } export interface GroupByAst { selections: ExprAst[]; predicate?: ExprAst; } export interface OrderByAst { order: Order; selection: ExprAst; } export declare enum DropType { Table = "Table", View = "View", Trigger = "Trigger", Constraint = "Constraint", Index = "Index" } export interface DropClause extends AstBase { dropType: DropType; dropName: string; } export interface DeleteClause extends AstBase { relationName: string; predicate?: ExprAst; } /** * Notes * - expression has to be a recursive dataype * - we allow for sets in the Expr to make the set-oriented functions expressible. */ export declare enum ExprType { Func = "Func", Val = "Val", Column = "Column", Star = "Star", Relation = "Relation", Parenthesis = "Parenthesis" } /** * note that the string names here are used directly to generate the SQL queries * so change the names carefully.. * must be all caps for some laziness reasons */ export declare enum BuiltInFunc { In = "IN", DateTime = "DATETIME", JulianDay = "JULIANDAY", Coalesce = "COALESCE", ValueIsNull = "IS NULL", ValueIsNotNull = "NOT NULL", SetEmpty = "NOT EXIST", SetNotEmpty = "EXIST", IfThisThen = "IFTHISTHEN", ConcatStrings = "CONCATSTRINGS" } export declare enum FunctionType { Math = "Math", Compare = "Compare", Logic = "Logic", BuiltIn = "BuiltIn", Custom = "Custom" } export declare type ExprAst = ExprFunAst | ExprStarAst | ExprValAst | ExprColumnAst | ExprRelationAst | ExprParen; export interface ExprBase { exprType: ExprType; dataType?: ToBeFilled; } export interface ExprParen extends ExprBase { content: ExprAst; } export interface ExprRelationAst extends ExprBase { selection: RelationSelection; } export interface ExprFunAst extends ExprBase { functionType: FunctionType; functionReference: string; args: ExprAst[]; } export interface ExprStarAst extends ExprBase { relationName?: Optional; } export interface ExprColumnAst extends ExprBase { columnName: string; relationName?: ToBeFilled; } export interface ExprValAst extends ExprBase { dataType: DielDataType; value: string | number | boolean; } export interface CustomFunc { name: string; } export declare type SimpleColumn = { cName: string; dataType: DielDataType; }; export declare enum BuiltInColumn { TIMESTEP = "TIMESTEP", TIMESTAMP = "TIMESTAMP", REQUEST_TIMESTEP = "REQUEST_TIMESTEP" } export declare const BuiltInColumnDataTypes: Map; export {}; //# sourceMappingURL=dielAstTypes.d.ts.map