263 lines
14 KiB
TypeScript
263 lines
14 KiB
TypeScript
import { ForeignKey } from "oak-domain/lib/types/DataType";
|
|
import { Q_DateValue, Q_NumberValue, Q_StringValue, Q_EnumValue, 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 { Action, ParticularAction, IState } from "./Action";
|
|
import { Price, Text } from "oak-domain/lib/types/DataType";
|
|
import * as Account from "../Account/Schema";
|
|
import * as User from "../User/Schema";
|
|
import * as Refund from "../Refund/Schema";
|
|
import * as WithdrawTransfer from "../WithdrawTransfer/Schema";
|
|
import * as ModiEntity from "../ModiEntity/Schema";
|
|
import * as OperEntity from "../OperEntity/Schema";
|
|
import * as AccountOper from "../AccountOper/Schema";
|
|
export type OpSchema = EntityShape & {
|
|
accountId: ForeignKey<"account">;
|
|
price: Price;
|
|
loss: Price;
|
|
dealPrice: Price;
|
|
dealLoss: Price;
|
|
creatorId: ForeignKey<"user">;
|
|
reason?: Text | null;
|
|
meta?: Object | null;
|
|
iState?: IState | null;
|
|
};
|
|
export type OpAttr = keyof OpSchema;
|
|
type Refund$withdrawAggr = "refund$withdraw$$aggr" | "refund$withdraw$$0$$aggr" | "refund$withdraw$$1$$aggr" | "refund$withdraw$$2$$aggr" | "refund$withdraw$$3$$aggr" | "refund$withdraw$$4$$aggr" | "refund$withdraw$$5$$aggr" | "refund$withdraw$$6$$aggr" | "refund$withdraw$$7$$aggr" | "refund$withdraw$$8$$aggr" | "refund$withdraw$$9$$aggr";
|
|
type WithdrawTransfer$withdrawAggr = "withdrawTransfer$withdraw$$aggr" | "withdrawTransfer$withdraw$$0$$aggr" | "withdrawTransfer$withdraw$$1$$aggr" | "withdrawTransfer$withdraw$$2$$aggr" | "withdrawTransfer$withdraw$$3$$aggr" | "withdrawTransfer$withdraw$$4$$aggr" | "withdrawTransfer$withdraw$$5$$aggr" | "withdrawTransfer$withdraw$$6$$aggr" | "withdrawTransfer$withdraw$$7$$aggr" | "withdrawTransfer$withdraw$$8$$aggr" | "withdrawTransfer$withdraw$$9$$aggr";
|
|
type ModiEntity$entityAggr = "modiEntity$entity$$aggr" | "modiEntity$entity$$0$$aggr" | "modiEntity$entity$$1$$aggr" | "modiEntity$entity$$2$$aggr" | "modiEntity$entity$$3$$aggr" | "modiEntity$entity$$4$$aggr" | "modiEntity$entity$$5$$aggr" | "modiEntity$entity$$6$$aggr" | "modiEntity$entity$$7$$aggr" | "modiEntity$entity$$8$$aggr" | "modiEntity$entity$$9$$aggr";
|
|
type OperEntity$entityAggr = "operEntity$entity$$aggr" | "operEntity$entity$$0$$aggr" | "operEntity$entity$$1$$aggr" | "operEntity$entity$$2$$aggr" | "operEntity$entity$$3$$aggr" | "operEntity$entity$$4$$aggr" | "operEntity$entity$$5$$aggr" | "operEntity$entity$$6$$aggr" | "operEntity$entity$$7$$aggr" | "operEntity$entity$$8$$aggr" | "operEntity$entity$$9$$aggr";
|
|
type AccountOper$entityAggr = "accountOper$entity$$aggr" | "accountOper$entity$$0$$aggr" | "accountOper$entity$$1$$aggr" | "accountOper$entity$$2$$aggr" | "accountOper$entity$$3$$aggr" | "accountOper$entity$$4$$aggr" | "accountOper$entity$$5$$aggr" | "accountOper$entity$$6$$aggr" | "accountOper$entity$$7$$aggr" | "accountOper$entity$$8$$aggr" | "accountOper$entity$$9$$aggr";
|
|
export type Schema = OpSchema & {
|
|
account: Account.Schema;
|
|
creator: User.Schema;
|
|
refund$withdraw?: Array<Refund.Schema>;
|
|
withdrawTransfer$withdraw?: Array<WithdrawTransfer.Schema>;
|
|
modiEntity$entity?: Array<ModiEntity.Schema>;
|
|
operEntity$entity?: Array<OperEntity.Schema>;
|
|
accountOper$entity?: Array<AccountOper.Schema>;
|
|
} & {
|
|
[A in ExpressionKey]?: any;
|
|
} & {
|
|
[A in Refund$withdrawAggr]?: AggregationResult<Refund.Schema>;
|
|
} & {
|
|
[A in WithdrawTransfer$withdrawAggr]?: AggregationResult<WithdrawTransfer.Schema>;
|
|
} & {
|
|
[A in ModiEntity$entityAggr]?: AggregationResult<ModiEntity.Schema>;
|
|
} & {
|
|
[A in OperEntity$entityAggr]?: AggregationResult<OperEntity.Schema>;
|
|
} & {
|
|
[A in AccountOper$entityAggr]?: AggregationResult<AccountOper.Schema>;
|
|
};
|
|
type AttrFilter = {
|
|
id: Q_StringValue;
|
|
$$createAt$$: Q_DateValue;
|
|
$$seq$$: Q_NumberValue;
|
|
$$updateAt$$: Q_DateValue;
|
|
accountId: Q_StringValue;
|
|
account: Account.Filter;
|
|
price: Q_NumberValue;
|
|
loss: Q_NumberValue;
|
|
dealPrice: Q_NumberValue;
|
|
dealLoss: Q_NumberValue;
|
|
creatorId: Q_StringValue;
|
|
creator: User.Filter;
|
|
reason: Q_StringValue;
|
|
meta: Object;
|
|
iState: Q_EnumValue<IState>;
|
|
refund$withdraw: Refund.Filter & SubQueryPredicateMetadata;
|
|
withdrawTransfer$withdraw: WithdrawTransfer.Filter & SubQueryPredicateMetadata;
|
|
modiEntity$entity: ModiEntity.Filter & SubQueryPredicateMetadata;
|
|
operEntity$entity: OperEntity.Filter & SubQueryPredicateMetadata;
|
|
accountOper$entity: AccountOper.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;
|
|
accountId?: number;
|
|
account?: Account.Projection;
|
|
price?: number;
|
|
loss?: number;
|
|
dealPrice?: number;
|
|
dealLoss?: number;
|
|
creatorId?: number;
|
|
creator?: User.Projection;
|
|
reason?: number;
|
|
meta?: number | Object;
|
|
iState?: number;
|
|
refund$withdraw?: Refund.Selection & {
|
|
$entity: "refund";
|
|
};
|
|
withdrawTransfer$withdraw?: WithdrawTransfer.Selection & {
|
|
$entity: "withdrawTransfer";
|
|
};
|
|
modiEntity$entity?: ModiEntity.Selection & {
|
|
$entity: "modiEntity";
|
|
};
|
|
operEntity$entity?: OperEntity.Selection & {
|
|
$entity: "operEntity";
|
|
};
|
|
accountOper$entity?: AccountOper.Selection & {
|
|
$entity: "accountOper";
|
|
};
|
|
} & Partial<ExprOp<OpAttr | string>> & {
|
|
[A in Refund$withdrawAggr]?: Refund.Aggregation & {
|
|
$entity: "refund";
|
|
};
|
|
} & {
|
|
[A in WithdrawTransfer$withdrawAggr]?: WithdrawTransfer.Aggregation & {
|
|
$entity: "withdrawTransfer";
|
|
};
|
|
} & {
|
|
[A in ModiEntity$entityAggr]?: ModiEntity.Aggregation & {
|
|
$entity: "modiEntity";
|
|
};
|
|
} & {
|
|
[A in OperEntity$entityAggr]?: OperEntity.Aggregation & {
|
|
$entity: "operEntity";
|
|
};
|
|
} & {
|
|
[A in AccountOper$entityAggr]?: AccountOper.Aggregation & {
|
|
$entity: "accountOper";
|
|
};
|
|
};
|
|
type WithdrawIdProjection = OneOf<{
|
|
id: number;
|
|
}>;
|
|
type AccountIdProjection = OneOf<{
|
|
accountId: number;
|
|
}>;
|
|
type UserIdProjection = OneOf<{
|
|
creatorId: number;
|
|
}>;
|
|
export type SortAttr = {
|
|
id: number;
|
|
} | {
|
|
$$createAt$$: number;
|
|
} | {
|
|
$$seq$$: number;
|
|
} | {
|
|
$$updateAt$$: number;
|
|
} | {
|
|
accountId: number;
|
|
} | {
|
|
account: Account.SortAttr;
|
|
} | {
|
|
price: number;
|
|
} | {
|
|
loss: number;
|
|
} | {
|
|
dealPrice: number;
|
|
} | {
|
|
dealLoss: number;
|
|
} | {
|
|
creatorId: number;
|
|
} | {
|
|
creator: User.SortAttr;
|
|
} | {
|
|
reason: number;
|
|
} | {
|
|
iState: 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<Omit<OpSchema, "accountId" | "creatorId">> & (({
|
|
accountId?: never;
|
|
account: Account.CreateSingleOperation;
|
|
} | {
|
|
accountId: ForeignKey<"account">;
|
|
account?: Account.UpdateOperation;
|
|
} | {
|
|
account?: never;
|
|
accountId: ForeignKey<"account">;
|
|
}) & ({
|
|
creatorId?: never;
|
|
creator: User.CreateSingleOperation;
|
|
} | {
|
|
creatorId: ForeignKey<"creator">;
|
|
creator?: User.UpdateOperation;
|
|
} | {
|
|
creator?: never;
|
|
creatorId: ForeignKey<"creator">;
|
|
})) & {
|
|
refund$withdraw?: OakOperation<Refund.UpdateOperation["action"], Omit<Refund.UpdateOperationData, "withdraw" | "withdrawId">, Omit<Refund.Filter, "withdraw" | "withdrawId">> | OakOperation<"create", Omit<Refund.CreateOperationData, "withdraw" | "withdrawId">[]> | Array<OakOperation<"create", Omit<Refund.CreateOperationData, "withdraw" | "withdrawId">> | OakOperation<Refund.UpdateOperation["action"], Omit<Refund.UpdateOperationData, "withdraw" | "withdrawId">, Omit<Refund.Filter, "withdraw" | "withdrawId">>>;
|
|
withdrawTransfer$withdraw?: OakOperation<WithdrawTransfer.UpdateOperation["action"], Omit<WithdrawTransfer.UpdateOperationData, "withdraw" | "withdrawId">, Omit<WithdrawTransfer.Filter, "withdraw" | "withdrawId">> | OakOperation<"create", Omit<WithdrawTransfer.CreateOperationData, "withdraw" | "withdrawId">[]> | Array<OakOperation<"create", Omit<WithdrawTransfer.CreateOperationData, "withdraw" | "withdrawId">> | OakOperation<WithdrawTransfer.UpdateOperation["action"], Omit<WithdrawTransfer.UpdateOperationData, "withdraw" | "withdrawId">, Omit<WithdrawTransfer.Filter, "withdraw" | "withdrawId">>>;
|
|
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">>>;
|
|
accountOper$entity?: OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">>>;
|
|
};
|
|
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
|
|
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
|
|
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
|
|
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "accountId" | "creatorId">> & (({
|
|
account?: Account.CreateSingleOperation;
|
|
accountId?: never;
|
|
} | {
|
|
account?: Account.UpdateOperation;
|
|
accountId?: never;
|
|
} | {
|
|
account?: Account.RemoveOperation;
|
|
accountId?: never;
|
|
} | {
|
|
account?: never;
|
|
accountId?: ForeignKey<"account">;
|
|
}) & ({
|
|
creator?: User.CreateSingleOperation;
|
|
creatorId?: never;
|
|
} | {
|
|
creator?: User.UpdateOperation;
|
|
creatorId?: never;
|
|
} | {
|
|
creator?: User.RemoveOperation;
|
|
creatorId?: never;
|
|
} | {
|
|
creator?: never;
|
|
creatorId?: ForeignKey<"creator">;
|
|
})) & {
|
|
[k: string]: any;
|
|
refund$withdraw?: OakOperation<Refund.UpdateOperation["action"], Omit<Refund.UpdateOperationData, "withdraw" | "withdrawId">, Omit<Refund.Filter, "withdraw" | "withdrawId">> | OakOperation<Refund.RemoveOperation["action"], Omit<Refund.RemoveOperationData, "withdraw" | "withdrawId">, Omit<Refund.Filter, "withdraw" | "withdrawId">> | OakOperation<"create", Omit<Refund.CreateOperationData, "withdraw" | "withdrawId">[]> | Array<OakOperation<"create", Omit<Refund.CreateOperationData, "withdraw" | "withdrawId">> | OakOperation<Refund.UpdateOperation["action"], Omit<Refund.UpdateOperationData, "withdraw" | "withdrawId">, Omit<Refund.Filter, "withdraw" | "withdrawId">> | OakOperation<Refund.RemoveOperation["action"], Omit<Refund.RemoveOperationData, "withdraw" | "withdrawId">, Omit<Refund.Filter, "withdraw" | "withdrawId">>>;
|
|
withdrawTransfer$withdraw?: OakOperation<WithdrawTransfer.UpdateOperation["action"], Omit<WithdrawTransfer.UpdateOperationData, "withdraw" | "withdrawId">, Omit<WithdrawTransfer.Filter, "withdraw" | "withdrawId">> | OakOperation<WithdrawTransfer.RemoveOperation["action"], Omit<WithdrawTransfer.RemoveOperationData, "withdraw" | "withdrawId">, Omit<WithdrawTransfer.Filter, "withdraw" | "withdrawId">> | OakOperation<"create", Omit<WithdrawTransfer.CreateOperationData, "withdraw" | "withdrawId">[]> | Array<OakOperation<"create", Omit<WithdrawTransfer.CreateOperationData, "withdraw" | "withdrawId">> | OakOperation<WithdrawTransfer.UpdateOperation["action"], Omit<WithdrawTransfer.UpdateOperationData, "withdraw" | "withdrawId">, Omit<WithdrawTransfer.Filter, "withdraw" | "withdrawId">> | OakOperation<WithdrawTransfer.RemoveOperation["action"], Omit<WithdrawTransfer.RemoveOperationData, "withdraw" | "withdrawId">, Omit<WithdrawTransfer.Filter, "withdraw" | "withdrawId">>>;
|
|
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">>>;
|
|
accountOper$entity?: OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">>>;
|
|
};
|
|
export type UpdateOperation = OakOperation<"update" | ParticularAction | string, UpdateOperationData, Filter, Sorter>;
|
|
export type RemoveOperationData = {} & (({
|
|
account?: Account.UpdateOperation | Account.RemoveOperation;
|
|
}) & ({
|
|
creator?: User.UpdateOperation | User.RemoveOperation;
|
|
}));
|
|
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
|
export type AccountIdSubQuery = Selection<AccountIdProjection>;
|
|
export type UserIdSubQuery = Selection<UserIdProjection>;
|
|
export type WithdrawIdSubQuery = Selection<WithdrawIdProjection>;
|
|
export type EntityDef = {
|
|
Schema: Schema;
|
|
OpSchema: OpSchema;
|
|
Action: OakMakeAction<Action> | string;
|
|
Selection: Selection;
|
|
Aggregation: Aggregation;
|
|
Operation: Operation;
|
|
Create: CreateOperation;
|
|
Update: UpdateOperation;
|
|
Remove: RemoveOperation;
|
|
CreateSingle: CreateSingleOperation;
|
|
CreateMulti: CreateMultipleOperation;
|
|
ParticularAction: ParticularAction;
|
|
};
|
|
export {};
|