260 lines
8.5 KiB
TypeScript
260 lines
8.5 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, String, Text, Datetime } from "oak-domain/lib/types/DataType";
|
|
import * as Withdraw from "../Withdraw/Schema";
|
|
import * as Pay from "../Pay/Schema";
|
|
import * as User from "../User/Schema";
|
|
import * as SysAccountOper from "../SysAccountOper/Schema";
|
|
import * as AccountOper from "../AccountOper/Schema";
|
|
export type OpSchema = EntityShape & {
|
|
withdrawId?: ForeignKey<"withdraw"> | null;
|
|
loss: Price;
|
|
payId: ForeignKey<"pay">;
|
|
meta?: Object | null;
|
|
externalId?: String<128> | null;
|
|
price: Price;
|
|
creatorId: ForeignKey<"user">;
|
|
reason?: Text | null;
|
|
successAt?: Datetime | null;
|
|
iState?: IState | null;
|
|
};
|
|
export type OpAttr = keyof OpSchema;
|
|
export type Schema = EntityShape & {
|
|
withdrawId?: ForeignKey<"withdraw"> | null;
|
|
loss: Price;
|
|
payId: ForeignKey<"pay">;
|
|
meta?: Object | null;
|
|
externalId?: String<128> | null;
|
|
price: Price;
|
|
creatorId: ForeignKey<"user">;
|
|
reason?: Text | null;
|
|
successAt?: Datetime | null;
|
|
iState?: IState | null;
|
|
withdraw?: Withdraw.Schema | null;
|
|
pay: Pay.Schema;
|
|
creator: User.Schema;
|
|
sysAccountOper$refund?: Array<SysAccountOper.Schema>;
|
|
sysAccountOper$refund$$aggr?: AggregationResult<SysAccountOper.Schema>;
|
|
accountOper$entity?: Array<AccountOper.Schema>;
|
|
accountOper$entity$$aggr?: AggregationResult<AccountOper.Schema>;
|
|
} & {
|
|
[A in ExpressionKey]?: any;
|
|
};
|
|
type AttrFilter = {
|
|
id: Q_StringValue;
|
|
$$createAt$$: Q_DateValue;
|
|
$$seq$$: Q_NumberValue;
|
|
$$updateAt$$: Q_DateValue;
|
|
withdrawId: Q_StringValue;
|
|
withdraw: Withdraw.Filter;
|
|
loss: Q_NumberValue;
|
|
payId: Q_StringValue;
|
|
pay: Pay.Filter;
|
|
meta: Object;
|
|
externalId: Q_StringValue;
|
|
price: Q_NumberValue;
|
|
creatorId: Q_StringValue;
|
|
creator: User.Filter;
|
|
reason: Q_StringValue;
|
|
successAt: Q_DateValue;
|
|
iState: Q_EnumValue<IState>;
|
|
sysAccountOper$refund: SysAccountOper.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;
|
|
withdrawId?: number;
|
|
withdraw?: Withdraw.Projection;
|
|
loss?: number;
|
|
payId?: number;
|
|
pay?: Pay.Projection;
|
|
meta?: number | Object;
|
|
externalId?: number;
|
|
price?: number;
|
|
creatorId?: number;
|
|
creator?: User.Projection;
|
|
reason?: number;
|
|
successAt?: number;
|
|
iState?: number;
|
|
sysAccountOper$refund?: SysAccountOper.Selection & {
|
|
$entity: "sysAccountOper";
|
|
};
|
|
sysAccountOper$refund$$aggr?: SysAccountOper.Aggregation & {
|
|
$entity: "sysAccountOper";
|
|
};
|
|
accountOper$entity?: AccountOper.Selection & {
|
|
$entity: "accountOper";
|
|
};
|
|
accountOper$entity$$aggr?: AccountOper.Aggregation & {
|
|
$entity: "accountOper";
|
|
};
|
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
type RefundIdProjection = OneOf<{
|
|
id: number;
|
|
}>;
|
|
type WithdrawIdProjection = OneOf<{
|
|
withdrawId: number;
|
|
}>;
|
|
type PayIdProjection = OneOf<{
|
|
payId: number;
|
|
}>;
|
|
type UserIdProjection = OneOf<{
|
|
creatorId: number;
|
|
}>;
|
|
export type SortAttr = {
|
|
id: number;
|
|
} | {
|
|
$$createAt$$: number;
|
|
} | {
|
|
$$seq$$: number;
|
|
} | {
|
|
$$updateAt$$: number;
|
|
} | {
|
|
withdrawId: number;
|
|
} | {
|
|
withdraw: Withdraw.SortAttr;
|
|
} | {
|
|
loss: number;
|
|
} | {
|
|
payId: number;
|
|
} | {
|
|
pay: Pay.SortAttr;
|
|
} | {
|
|
externalId: number;
|
|
} | {
|
|
price: number;
|
|
} | {
|
|
creatorId: number;
|
|
} | {
|
|
creator: User.SortAttr;
|
|
} | {
|
|
reason: number;
|
|
} | {
|
|
successAt: 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, "withdrawId" | "payId" | "creatorId">> & (({
|
|
withdrawId?: never;
|
|
withdraw?: Withdraw.CreateSingleOperation;
|
|
} | {
|
|
withdrawId: ForeignKey<"withdraw">;
|
|
withdraw?: Withdraw.UpdateOperation;
|
|
} | {
|
|
withdraw?: never;
|
|
withdrawId?: ForeignKey<"withdraw">;
|
|
}) & ({
|
|
payId?: never;
|
|
pay: Pay.CreateSingleOperation;
|
|
} | {
|
|
payId: ForeignKey<"pay">;
|
|
pay?: Pay.UpdateOperation;
|
|
} | {
|
|
pay?: never;
|
|
payId: ForeignKey<"pay">;
|
|
}) & ({
|
|
creatorId?: never;
|
|
creator: User.CreateSingleOperation;
|
|
} | {
|
|
creatorId: ForeignKey<"creator">;
|
|
creator?: User.UpdateOperation;
|
|
} | {
|
|
creator?: never;
|
|
creatorId: ForeignKey<"creator">;
|
|
})) & {
|
|
sysAccountOper$refund?: OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "refund" | "refundId">[]> | Array<OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "refund" | "refundId">>>;
|
|
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, "withdrawId" | "payId" | "creatorId">> & (({
|
|
withdraw?: Withdraw.CreateSingleOperation;
|
|
withdrawId?: never;
|
|
} | {
|
|
withdraw?: Withdraw.UpdateOperation;
|
|
withdrawId?: never;
|
|
} | {
|
|
withdraw?: Withdraw.RemoveOperation;
|
|
withdrawId?: never;
|
|
} | {
|
|
withdraw?: never;
|
|
withdrawId?: ForeignKey<"withdraw"> | null;
|
|
}) & ({
|
|
pay?: Pay.CreateSingleOperation;
|
|
payId?: never;
|
|
} | {
|
|
pay?: Pay.UpdateOperation;
|
|
payId?: never;
|
|
} | {
|
|
pay?: Pay.RemoveOperation;
|
|
payId?: never;
|
|
} | {
|
|
pay?: never;
|
|
payId?: ForeignKey<"pay">;
|
|
}) & ({
|
|
creator?: User.CreateSingleOperation;
|
|
creatorId?: never;
|
|
} | {
|
|
creator?: User.UpdateOperation;
|
|
creatorId?: never;
|
|
} | {
|
|
creator?: User.RemoveOperation;
|
|
creatorId?: never;
|
|
} | {
|
|
creator?: never;
|
|
creatorId?: ForeignKey<"creator">;
|
|
})) & {
|
|
[k: string]: any;
|
|
sysAccountOper$refund?: OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "refund" | "refundId">[]> | Array<OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "refund" | "refundId">>>;
|
|
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 = {} & (({
|
|
withdraw?: Withdraw.UpdateOperation | Withdraw.RemoveOperation;
|
|
}) & ({
|
|
pay?: Pay.UpdateOperation | Pay.RemoveOperation;
|
|
}) & ({
|
|
creator?: User.UpdateOperation | User.RemoveOperation;
|
|
}));
|
|
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
|
export type WithdrawIdSubQuery = Selection<WithdrawIdProjection>;
|
|
export type PayIdSubQuery = Selection<PayIdProjection>;
|
|
export type UserIdSubQuery = Selection<UserIdProjection>;
|
|
export type RefundIdSubQuery = Selection<RefundIdProjection>;
|
|
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 {};
|