122 lines
5.0 KiB
TypeScript
122 lines
5.0 KiB
TypeScript
import { String } from "../../types/DataType";
|
|
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
|
import { OneOf } from "../../types/Polyfill";
|
|
import * as SubQuery from "../_SubQuery";
|
|
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, EntityShape, AggregationResult } from "../../types/Entity";
|
|
import { GenericAction } from "../../actions/action";
|
|
import * as ModiEntity from "../ModiEntity/Schema";
|
|
import * as OperEntity from "../OperEntity/Schema";
|
|
export declare type OpSchema = EntityShape & {
|
|
entity: String<32>;
|
|
entityId: String<64>;
|
|
relation: String<32>;
|
|
};
|
|
export declare type OpAttr = keyof OpSchema;
|
|
export declare type Schema = EntityShape & {
|
|
entity: String<32>;
|
|
entityId: String<64>;
|
|
relation: String<32>;
|
|
modiEntity$entity?: Array<ModiEntity.Schema>;
|
|
modiEntity$entity$$aggr?: AggregationResult<ModiEntity.Schema>;
|
|
operEntity$entity?: Array<OperEntity.Schema>;
|
|
operEntity$entity$$aggr?: AggregationResult<OperEntity.Schema>;
|
|
} & {
|
|
[A in ExpressionKey]?: any;
|
|
};
|
|
declare type AttrFilter = {
|
|
id: Q_StringValue | SubQuery.UserEntityGrantIdSubQuery;
|
|
$$createAt$$: Q_DateValue;
|
|
$$seq$$: Q_StringValue;
|
|
$$updateAt$$: Q_DateValue;
|
|
entity: Q_StringValue;
|
|
entityId: Q_StringValue;
|
|
relation: Q_StringValue;
|
|
};
|
|
export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
|
export declare type Projection = {
|
|
"#id"?: NodeId;
|
|
[k: string]: any;
|
|
id?: number;
|
|
$$createAt$$?: number;
|
|
$$updateAt$$?: number;
|
|
$$seq$$?: number;
|
|
entity?: number;
|
|
entityId?: number;
|
|
relation?: number;
|
|
modiEntity$entity?: ModiEntity.Selection & {
|
|
$entity: "modiEntity";
|
|
};
|
|
modiEntity$entity$$aggr?: ModiEntity.Aggregation & {
|
|
$entity: "modiEntity";
|
|
};
|
|
operEntity$entity?: OperEntity.Selection & {
|
|
$entity: "operEntity";
|
|
};
|
|
operEntity$entity$$aggr?: OperEntity.Aggregation & {
|
|
$entity: "operEntity";
|
|
};
|
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
declare type UserEntityGrantIdProjection = OneOf<{
|
|
id: number;
|
|
}>;
|
|
export declare type SortAttr = {
|
|
id: number;
|
|
} | {
|
|
$$createAt$$: number;
|
|
} | {
|
|
$$seq$$: number;
|
|
} | {
|
|
$$updateAt$$: number;
|
|
} | {
|
|
entity: number;
|
|
} | {
|
|
entityId: number;
|
|
} | {
|
|
relation: number;
|
|
} | {
|
|
[k: string]: any;
|
|
} | OneOf<ExprOp<OpAttr | string>>;
|
|
export declare type SortNode = {
|
|
$attr: SortAttr;
|
|
$direction?: "asc" | "desc";
|
|
};
|
|
export declare type Sorter = SortNode[];
|
|
export declare type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
|
|
export declare type Selection<P extends Object = Projection> = Omit<SelectOperation<P>, "action">;
|
|
export declare type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
|
|
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "entityId">> & ({
|
|
entity?: string;
|
|
entityId?: string;
|
|
[K: string]: any;
|
|
}) & {
|
|
modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
|
|
operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
|
|
};
|
|
export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
|
|
export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
|
|
export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
|
|
export declare type UpdateOperationData = FormUpdateData<OpSchema> & {
|
|
[k: string]: any;
|
|
modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
|
|
operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
|
|
};
|
|
export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
|
|
export declare type RemoveOperationData = {};
|
|
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
|
export declare type UserEntityGrantIdSubQuery = Selection<UserEntityGrantIdProjection>;
|
|
export declare type EntityDef = {
|
|
Schema: Schema;
|
|
OpSchema: OpSchema;
|
|
Action: OakMakeAction<GenericAction> | string;
|
|
Selection: Selection;
|
|
Aggregation: Aggregation;
|
|
Operation: Operation;
|
|
Create: CreateOperation;
|
|
Update: UpdateOperation;
|
|
Remove: RemoveOperation;
|
|
CreateSingle: CreateSingleOperation;
|
|
CreateMulti: CreateMultipleOperation;
|
|
};
|
|
export {};
|