179 lines
5.9 KiB
TypeScript
179 lines
5.9 KiB
TypeScript
import { String, ForeignKey } from "../../types/DataType";
|
|
import { Q_DateValue, Q_StringValue, Q_EnumValue, 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 } from "../../types/Entity";
|
|
import { AppendOnlyAction } from "../../actions/action";
|
|
import * as Oper from "../Oper/Schema";
|
|
import * as User from "../User/Schema";
|
|
import * as UserEntityGrant from "../UserEntityGrant/Schema";
|
|
export declare type OpSchema = EntityShape & {
|
|
operId: ForeignKey<"oper">;
|
|
entity: "user" | "userEntityGrant" | string;
|
|
entityId: String<64>;
|
|
};
|
|
export declare type OpAttr = keyof OpSchema;
|
|
export declare type Schema = EntityShape & {
|
|
operId: ForeignKey<"oper">;
|
|
entity: "user" | "userEntityGrant" | string;
|
|
entityId: String<64>;
|
|
oper: Oper.Schema;
|
|
user?: User.Schema;
|
|
userEntityGrant?: UserEntityGrant.Schema;
|
|
} & {
|
|
[A in ExpressionKey]?: any;
|
|
};
|
|
declare type AttrFilter<E> = {
|
|
id: Q_StringValue | SubQuery.OperEntityIdSubQuery;
|
|
$$createAt$$: Q_DateValue;
|
|
$$seq$$: Q_StringValue;
|
|
$$updateAt$$: Q_DateValue;
|
|
operId: Q_StringValue | SubQuery.OperIdSubQuery;
|
|
oper: Oper.Filter;
|
|
entity: E;
|
|
entityId: Q_StringValue;
|
|
user: User.Filter;
|
|
userEntityGrant: UserEntityGrant.Filter;
|
|
};
|
|
export declare type Filter<E = Q_EnumValue<"user" | "userEntityGrant" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>;
|
|
export declare type Projection = {
|
|
"#id"?: NodeId;
|
|
[k: string]: any;
|
|
id?: number;
|
|
$$createAt$$?: number;
|
|
$$updateAt$$?: number;
|
|
$$seq$$?: number;
|
|
operId?: number;
|
|
oper?: Oper.Projection;
|
|
entity?: number;
|
|
entityId?: number;
|
|
user?: User.Projection;
|
|
userEntityGrant?: UserEntityGrant.Projection;
|
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
declare type OperEntityIdProjection = OneOf<{
|
|
id: number;
|
|
}>;
|
|
declare type OperIdProjection = OneOf<{
|
|
operId: number;
|
|
}>;
|
|
declare type UserIdProjection = OneOf<{
|
|
entityId: number;
|
|
}>;
|
|
declare type UserEntityGrantIdProjection = OneOf<{
|
|
entityId: number;
|
|
}>;
|
|
export declare type SortAttr = {
|
|
id: number;
|
|
} | {
|
|
$$createAt$$: number;
|
|
} | {
|
|
$$seq$$: number;
|
|
} | {
|
|
$$updateAt$$: number;
|
|
} | {
|
|
operId: number;
|
|
} | {
|
|
oper: Oper.SortAttr;
|
|
} | {
|
|
entity: number;
|
|
} | {
|
|
entityId: number;
|
|
} | {
|
|
user: User.SortAttr;
|
|
} | {
|
|
userEntityGrant: UserEntityGrant.SortAttr;
|
|
} | {
|
|
[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" | "operId">> & (({
|
|
operId?: never;
|
|
oper: Oper.CreateSingleOperation;
|
|
} | {
|
|
operId: String<64>;
|
|
})) & ({
|
|
entity?: never;
|
|
entityId?: never;
|
|
user: User.CreateSingleOperation;
|
|
} | {
|
|
entity: "user";
|
|
entityId: String<64>;
|
|
user: User.UpdateOperation;
|
|
} | {
|
|
entity: "user";
|
|
entityId: String<64>;
|
|
} | {
|
|
entity?: never;
|
|
entityId?: never;
|
|
userEntityGrant: UserEntityGrant.CreateSingleOperation;
|
|
} | {
|
|
entity: "userEntityGrant";
|
|
entityId: String<64>;
|
|
userEntityGrant: UserEntityGrant.UpdateOperation;
|
|
} | {
|
|
entity: "userEntityGrant";
|
|
entityId: String<64>;
|
|
} | {
|
|
entity?: string;
|
|
entityId?: string;
|
|
[K: string]: any;
|
|
});
|
|
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<Omit<OpSchema, "entity" | "entityId" | "operId">> & (({
|
|
oper: Oper.CreateSingleOperation;
|
|
operId?: never;
|
|
} | {
|
|
oper?: never;
|
|
operId?: String<64> | null;
|
|
})) & ({
|
|
user?: User.CreateSingleOperation | User.UpdateOperation | User.RemoveOperation;
|
|
entityId?: never;
|
|
entity?: never;
|
|
} | {
|
|
userEntityGrant?: UserEntityGrant.CreateSingleOperation | UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation;
|
|
entityId?: never;
|
|
entity?: never;
|
|
} | {
|
|
entity?: ("user" | "userEntityGrant" | string) | null;
|
|
entityId?: String<64> | null;
|
|
}) & {
|
|
[k: string]: any;
|
|
};
|
|
export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
|
|
export declare type RemoveOperationData = {} & ({
|
|
user?: User.UpdateOperation | User.RemoveOperation;
|
|
} | {
|
|
userEntityGrant?: UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation;
|
|
} | {
|
|
[k: string]: any;
|
|
});
|
|
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
|
export declare type OperIdSubQuery = Selection<OperIdProjection>;
|
|
export declare type UserIdSubQuery = Selection<UserIdProjection>;
|
|
export declare type UserEntityGrantIdSubQuery = Selection<UserEntityGrantIdProjection>;
|
|
export declare type OperEntityIdSubQuery = Selection<OperEntityIdProjection>;
|
|
export declare type EntityDef = {
|
|
Schema: Schema;
|
|
OpSchema: OpSchema;
|
|
Action: OakMakeAction<AppendOnlyAction> | string;
|
|
Selection: Selection;
|
|
Aggregation: Aggregation;
|
|
Operation: Operation;
|
|
Create: CreateOperation;
|
|
Update: UpdateOperation;
|
|
Remove: RemoveOperation;
|
|
CreateSingle: CreateSingleOperation;
|
|
CreateMulti: CreateMultipleOperation;
|
|
};
|
|
export {};
|