2023-01-23 21:19:18 +01:00
|
|
|
import { Attribute } from "./db";
|
|
|
|
import { Handler } from "./defaultHandler";
|
|
|
|
import { allModifierInput, primaryData, serializeReturn } from "./types";
|
|
|
|
|
2023-01-24 10:40:16 +01:00
|
|
|
export class Datatype{
|
|
|
|
type: string;
|
|
|
|
args: primaryData[];
|
|
|
|
constructor(type:string, args: primaryData[]){
|
|
|
|
this.type = type;
|
|
|
|
this.args = args;
|
|
|
|
}
|
|
|
|
serialize(handler = Handler): serializeReturn{
|
|
|
|
return handler.datatypes[this.type as keyof typeof handler.datatypes](this.args);
|
|
|
|
}
|
|
|
|
}
|
2023-01-23 21:19:18 +01:00
|
|
|
|
|
|
|
export abstract class Modifier {
|
2023-01-23 22:10:33 +01:00
|
|
|
t: string;
|
|
|
|
a: Array<allModifierInput>;
|
2023-01-23 21:19:18 +01:00
|
|
|
constructor(type: string, args: (allModifierInput)[]) {
|
|
|
|
this.t = type;
|
|
|
|
this.a = args;
|
|
|
|
}
|
2023-01-23 22:10:33 +01:00
|
|
|
serialize(handler = Handler): serializeReturn {
|
2023-01-23 21:19:18 +01:00
|
|
|
return handler.modifiers[this.t as keyof typeof handler.modifiers](this.a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-23 22:10:33 +01:00
|
|
|
export class BooleanModifier extends Modifier { }
|
|
|
|
export class NumberModifier extends Modifier { }
|
|
|
|
export class StringModifier extends Modifier { }
|
2023-01-23 21:19:18 +01:00
|
|
|
|
2023-01-23 22:10:33 +01:00
|
|
|
export class Aggregation {
|
|
|
|
t: string;
|
|
|
|
a: Attribute;
|
2023-01-23 21:19:18 +01:00
|
|
|
constructor(type: string, args: Attribute) {
|
|
|
|
this.t = type;
|
|
|
|
this.a = args;
|
|
|
|
}
|
2023-01-23 22:10:33 +01:00
|
|
|
serialize(handler = Handler): serializeReturn {
|
2023-01-23 21:19:18 +01:00
|
|
|
return handler.aggregations[this.t as keyof typeof handler.aggregations](this.a);
|
|
|
|
}
|
|
|
|
}
|
2023-01-23 22:10:33 +01:00
|
|
|
export class Joins {
|
2023-01-23 21:19:18 +01:00
|
|
|
|
2023-01-23 22:10:33 +01:00
|
|
|
serialize(handler = Handler): serializeReturn {
|
|
|
|
return ["", []];
|
2023-01-23 21:19:18 +01:00
|
|
|
}
|
|
|
|
}
|