127 lines
4.9 KiB
TypeScript
127 lines
4.9 KiB
TypeScript
import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey, SubQueryPredicateMetadata } from "oak-domain/lib/types/Demand";
|
|
import { OneOf } from "oak-domain/lib/types/Polyfill";
|
|
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, AggregationResult, EntityShape } from "oak-domain/lib/types/Entity";
|
|
import { GenericAction } from "oak-domain/lib/actions/action";
|
|
import { String, Boolean } from "oak-domain/lib/types/DataType";
|
|
import * as ActionAuth from "../ActionAuth/Schema";
|
|
import * as RelationAuth from "../RelationAuth/Schema";
|
|
export type OpSchema = EntityShape & {
|
|
destEntity: String<32>;
|
|
value: String<256>;
|
|
recursive: Boolean;
|
|
sourceEntity: String<32>;
|
|
desc?: String<256> | null;
|
|
};
|
|
export type OpAttr = keyof OpSchema;
|
|
type ActionAuth$pathAggr = "actionAuth$path$$aggr" | "actionAuth$path$$0$$aggr" | "actionAuth$path$$1$$aggr" | "actionAuth$path$$2$$aggr" | "actionAuth$path$$3$$aggr" | "actionAuth$path$$4$$aggr" | "actionAuth$path$$5$$aggr" | "actionAuth$path$$6$$aggr" | "actionAuth$path$$7$$aggr" | "actionAuth$path$$8$$aggr" | "actionAuth$path$$9$$aggr";
|
|
type RelationAuth$pathAggr = "relationAuth$path$$aggr" | "relationAuth$path$$0$$aggr" | "relationAuth$path$$1$$aggr" | "relationAuth$path$$2$$aggr" | "relationAuth$path$$3$$aggr" | "relationAuth$path$$4$$aggr" | "relationAuth$path$$5$$aggr" | "relationAuth$path$$6$$aggr" | "relationAuth$path$$7$$aggr" | "relationAuth$path$$8$$aggr" | "relationAuth$path$$9$$aggr";
|
|
export type Schema = OpSchema & {
|
|
actionAuth$path?: Array<ActionAuth.Schema>;
|
|
relationAuth$path?: Array<RelationAuth.Schema>;
|
|
} & {
|
|
[A in ExpressionKey]?: any;
|
|
} & {
|
|
[A in ActionAuth$pathAggr]?: AggregationResult<ActionAuth.Schema>;
|
|
} & {
|
|
[A in RelationAuth$pathAggr]?: AggregationResult<RelationAuth.Schema>;
|
|
};
|
|
type AttrFilter = {
|
|
id: Q_StringValue;
|
|
$$createAt$$: Q_DateValue;
|
|
$$seq$$: Q_NumberValue;
|
|
$$updateAt$$: Q_DateValue;
|
|
destEntity: Q_StringValue;
|
|
value: Q_StringValue;
|
|
recursive: Q_BooleanValue;
|
|
sourceEntity: Q_StringValue;
|
|
desc: Q_StringValue;
|
|
actionAuth$path: ActionAuth.Filter & SubQueryPredicateMetadata;
|
|
relationAuth$path: RelationAuth.Filter & SubQueryPredicateMetadata;
|
|
};
|
|
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
|
export type Projection = {
|
|
"#id"?: NodeId;
|
|
[k: string]: any;
|
|
id?: number;
|
|
$$createAt$$?: number;
|
|
$$updateAt$$?: number;
|
|
$$seq$$?: number;
|
|
destEntity?: number;
|
|
value?: number;
|
|
recursive?: number;
|
|
sourceEntity?: number;
|
|
desc?: number;
|
|
actionAuth$path?: ActionAuth.Selection & {
|
|
$entity: "actionAuth";
|
|
};
|
|
relationAuth$path?: RelationAuth.Selection & {
|
|
$entity: "relationAuth";
|
|
};
|
|
} & Partial<ExprOp<OpAttr | string>> & {
|
|
[A in ActionAuth$pathAggr]?: ActionAuth.Aggregation & {
|
|
$entity: "actionAuth";
|
|
};
|
|
} & {
|
|
[A in RelationAuth$pathAggr]?: RelationAuth.Aggregation & {
|
|
$entity: "relationAuth";
|
|
};
|
|
};
|
|
type PathIdProjection = OneOf<{
|
|
id: number;
|
|
}>;
|
|
export type SortAttr = {
|
|
id: number;
|
|
} | {
|
|
$$createAt$$: number;
|
|
} | {
|
|
$$seq$$: number;
|
|
} | {
|
|
$$updateAt$$: number;
|
|
} | {
|
|
destEntity: number;
|
|
} | {
|
|
value: number;
|
|
} | {
|
|
recursive: number;
|
|
} | {
|
|
sourceEntity: number;
|
|
} | {
|
|
desc: number;
|
|
} | {
|
|
[k: string]: any;
|
|
} | OneOf<ExprOp<OpAttr | string>>;
|
|
export type SortNode = {
|
|
$attr: SortAttr;
|
|
$direction?: "asc" | "desc";
|
|
};
|
|
export type Sorter = SortNode[];
|
|
export type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
|
|
export type Selection<P extends Object = Projection> = SelectOperation<P>;
|
|
export type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
|
|
export type CreateOperationData = FormCreateData<OpSchema>;
|
|
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
|
|
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
|
|
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
|
|
export type UpdateOperationData = FormUpdateData<OpSchema> & {
|
|
[k: string]: any;
|
|
};
|
|
export type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
|
|
export type RemoveOperationData = {};
|
|
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
|
export type PathIdSubQuery = Selection<PathIdProjection>;
|
|
export 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 {};
|