export interface QUERY { WHERE: FILTER | {}; //{} is empty OPTIONS: OPTIONS; TRANSFORMATIONS?: TRANSFORMATIONS; } export type FILTER = LOGICCOMPARISON | MCOMPARISON | SCOMPARISON | NEGATION; export type LOGICCOMPARISON = { [l in LOGIC]: FILTER[]; }; export type MCOMPARISON = { [c in MCOMPARATOR]: { [m in Mkey]: number; }; }; export interface SCOMPARISON { IS: { [s in Skey]: Inputstring; //[*]? inputstring [*]? }; } export type NEGATION = { NOT: FILTER; }; export interface OPTIONS { COLUMNS: AnyKey[]; ORDER?: ORDER; } export type ORDER = AnyKey | SORT; export interface SORT { dir: DIRECTION; keys: AnyKey[]; } export type DIRECTION = "UP" | "DOWN"; export interface TRANSFORMATIONS { GROUP: Key[]; APPLY: APPLYRULE[]; } export type APPLYRULE = { [a in Applykey]: { [ap in APPLYTOKEN]: Key; }; }; export type APPLYTOKEN = "MAX" | "MIN" | "AVG" | "COUNT" | "SUM"; export type LOGIC = "AND" | "OR"; export type MCOMPARATOR = "LT" | "GT" | "EQ"; export type AnyKey = Key | Applykey; export type Key = Mkey | Skey; export type Mkey = `${Idstring}_${Mfield}`; export type Skey = `${Idstring}_${Sfield}`; export type Mfield = "avg" | "pass" | "fail" | "audit" | "year" | "lat" | "lon" | "seats"; export type Sfield = | "dept" | "id" | "instructor" | "title" | "uuid" | "fullname" | "shortname" | "number" | "name" | "address" | "type" | "furniture" | "href"; export type Idstring = string; //[^_]+ One or more of any character, except underscore. export type Inputstring = string; //[^*]* Zero or more of any character, except asterisk. export type Applykey = string; //[^_]+ One or more of any character, except underscore.