refdb/domain.d.ts

95 lines
1.6 KiB
TypeScript
Raw Permalink Normal View History

2024-01-07 01:17:23 +00:00
type NodeValueType = {
Number: "number",
String: "string",
Map: "map",
Expression: "expression"
};
type ExpressionType = {
Count: "count",
Filter: "filter",
};
type Filter =
{
value: number,
predicate: "greatThat"
| "greatThatEqual"
| "lessThat"
| "lessThatEqual"
| "equal"
}
| {
value: string,
predicate: "include"
| "equal"
}
type CountWithExpression = {
type: ExpressionType["Count"],
expression: BaseNode["uuid"],
};
type CountWithSet = {
type: ExpressionType["Count"],
set: string,
};
type FilterWithExpression = {
type: ExpressionType["Filter"],
expression: BaseNode["uuid"],
filter: Filter,
};
type FilterWithSet = {
type: ExpressionType["Filter"],
set: string,
filter: Filter,
2024-01-07 18:01:58 +00:00
field: string,
2024-01-07 01:17:23 +00:00
};
type Expression =
CountWithExpression
| CountWithSet
| FilterWithExpression
| FilterWithSet;
type NumberNode = BaseNode & {
valueType: NodeValueType["Number"];
value: number;
};
type StringNode = BaseNode & {
valueType: NodeValueType["String"];
value: string;
};
2024-01-07 18:01:58 +00:00
type MapNode = BaseNode & {
2024-01-07 01:17:23 +00:00
valueType: NodeValueType["Map"];
2024-01-07 18:01:58 +00:00
value: { [key: string]: BaseNode["uuid"]; };
2024-01-07 01:17:23 +00:00
};
type ExpressionNode = BaseNode & {
valueType: NodeValueType["Expression"];
value: Expression;
id: string;
};
type BaseNode = {
uuid: string;
set: string;
};
type PrimitiveValue = string | number;
type MapValue = {
[key: string]: PrimitiveValue | MapValue;
}
type ExpressionResult = PrimitiveValue | MapValue | Array<PrimitiveValue | MapValue> | null;
type AddNodeParams = Omit<AnyNode, "uuid">;
type AnyNode = NumberNode | StringNode | MapNode | ExpressionNode;