314 lines
10 KiB
TypeScript
314 lines
10 KiB
TypeScript
import { ForeignKey } from "oak-domain/lib/types/DataType";
|
|
import { Q_DateValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } 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, EntityShape } from "oak-domain/lib/types/Entity";
|
|
import { AppendOnlyAction } from "oak-domain/lib/actions/action";
|
|
import { Price, String } from "oak-domain/lib/types/DataType";
|
|
import { SysAccountOperType } from "../../types/sysAccountOper";
|
|
import * as Pay from "../Pay/Schema";
|
|
import * as Refund from "../Refund/Schema";
|
|
import * as WithdrawTransfer from "../WithdrawTransfer/Schema";
|
|
import * as SysAccountMove from "../SysAccountMove/Schema";
|
|
import * as OfflineAccount from "../OfflineAccount/Schema";
|
|
import * as WpAccount from "../WpAccount/Schema";
|
|
export type OpSchema = EntityShape & {
|
|
delta: Price;
|
|
type: SysAccountOperType;
|
|
entity: "offlineAccount" | "wpAccount" | string;
|
|
entityId: String<64>;
|
|
payId?: ForeignKey<"pay"> | null;
|
|
refundId?: ForeignKey<"refund"> | null;
|
|
withdrawTransferId?: ForeignKey<"withdrawTransfer"> | null;
|
|
sysAccountMoveId?: ForeignKey<"sysAccountMove"> | null;
|
|
};
|
|
export type OpAttr = keyof OpSchema;
|
|
export type Schema = EntityShape & {
|
|
delta: Price;
|
|
type: SysAccountOperType;
|
|
entity: "offlineAccount" | "wpAccount" | string;
|
|
entityId: String<64>;
|
|
payId?: ForeignKey<"pay"> | null;
|
|
refundId?: ForeignKey<"refund"> | null;
|
|
withdrawTransferId?: ForeignKey<"withdrawTransfer"> | null;
|
|
sysAccountMoveId?: ForeignKey<"sysAccountMove"> | null;
|
|
pay?: Pay.Schema | null;
|
|
refund?: Refund.Schema | null;
|
|
withdrawTransfer?: WithdrawTransfer.Schema | null;
|
|
sysAccountMove?: SysAccountMove.Schema | null;
|
|
offlineAccount?: OfflineAccount.Schema;
|
|
wpAccount?: WpAccount.Schema;
|
|
} & {
|
|
[A in ExpressionKey]?: any;
|
|
};
|
|
type AttrFilter = {
|
|
id: Q_StringValue;
|
|
$$createAt$$: Q_DateValue;
|
|
$$seq$$: Q_NumberValue;
|
|
$$updateAt$$: Q_DateValue;
|
|
delta: Q_NumberValue;
|
|
type: Q_EnumValue<SysAccountOperType>;
|
|
entity: Q_EnumValue<"offlineAccount" | "wpAccount" | string>;
|
|
entityId: Q_StringValue;
|
|
payId: Q_StringValue;
|
|
pay: Pay.Filter;
|
|
refundId: Q_StringValue;
|
|
refund: Refund.Filter;
|
|
withdrawTransferId: Q_StringValue;
|
|
withdrawTransfer: WithdrawTransfer.Filter;
|
|
sysAccountMoveId: Q_StringValue;
|
|
sysAccountMove: SysAccountMove.Filter;
|
|
offlineAccount: OfflineAccount.Filter;
|
|
wpAccount: WpAccount.Filter;
|
|
};
|
|
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
|
export type Projection = {
|
|
"#id"?: NodeId;
|
|
[k: string]: any;
|
|
id?: number;
|
|
$$createAt$$?: number;
|
|
$$updateAt$$?: number;
|
|
$$seq$$?: number;
|
|
delta?: number;
|
|
type?: number;
|
|
entity?: number;
|
|
entityId?: number;
|
|
payId?: number;
|
|
pay?: Pay.Projection;
|
|
refundId?: number;
|
|
refund?: Refund.Projection;
|
|
withdrawTransferId?: number;
|
|
withdrawTransfer?: WithdrawTransfer.Projection;
|
|
sysAccountMoveId?: number;
|
|
sysAccountMove?: SysAccountMove.Projection;
|
|
offlineAccount?: OfflineAccount.Projection;
|
|
wpAccount?: WpAccount.Projection;
|
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
type SysAccountOperIdProjection = OneOf<{
|
|
id: number;
|
|
}>;
|
|
type PayIdProjection = OneOf<{
|
|
payId: number;
|
|
}>;
|
|
type RefundIdProjection = OneOf<{
|
|
refundId: number;
|
|
}>;
|
|
type WithdrawTransferIdProjection = OneOf<{
|
|
withdrawTransferId: number;
|
|
}>;
|
|
type SysAccountMoveIdProjection = OneOf<{
|
|
sysAccountMoveId: number;
|
|
}>;
|
|
type OfflineAccountIdProjection = OneOf<{
|
|
entityId: number;
|
|
}>;
|
|
type WpAccountIdProjection = OneOf<{
|
|
entityId: number;
|
|
}>;
|
|
export type SortAttr = {
|
|
id: number;
|
|
} | {
|
|
$$createAt$$: number;
|
|
} | {
|
|
$$seq$$: number;
|
|
} | {
|
|
$$updateAt$$: number;
|
|
} | {
|
|
delta: number;
|
|
} | {
|
|
type: number;
|
|
} | {
|
|
entity: number;
|
|
} | {
|
|
entityId: number;
|
|
} | {
|
|
payId: number;
|
|
} | {
|
|
pay: Pay.SortAttr;
|
|
} | {
|
|
refundId: number;
|
|
} | {
|
|
refund: Refund.SortAttr;
|
|
} | {
|
|
withdrawTransferId: number;
|
|
} | {
|
|
withdrawTransfer: WithdrawTransfer.SortAttr;
|
|
} | {
|
|
sysAccountMoveId: number;
|
|
} | {
|
|
sysAccountMove: SysAccountMove.SortAttr;
|
|
} | {
|
|
offlineAccount: OfflineAccount.SortAttr;
|
|
} | {
|
|
wpAccount: WpAccount.SortAttr;
|
|
} | {
|
|
[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, "entity" | "entityId" | "payId" | "refundId" | "withdrawTransferId" | "sysAccountMoveId">> & (({
|
|
payId?: never;
|
|
pay?: Pay.CreateSingleOperation;
|
|
} | {
|
|
payId: ForeignKey<"pay">;
|
|
pay?: Pay.UpdateOperation;
|
|
} | {
|
|
pay?: never;
|
|
payId?: ForeignKey<"pay">;
|
|
}) & ({
|
|
refundId?: never;
|
|
refund?: Refund.CreateSingleOperation;
|
|
} | {
|
|
refundId: ForeignKey<"refund">;
|
|
refund?: Refund.UpdateOperation;
|
|
} | {
|
|
refund?: never;
|
|
refundId?: ForeignKey<"refund">;
|
|
}) & ({
|
|
withdrawTransferId?: never;
|
|
withdrawTransfer?: WithdrawTransfer.CreateSingleOperation;
|
|
} | {
|
|
withdrawTransferId: ForeignKey<"withdrawTransfer">;
|
|
withdrawTransfer?: WithdrawTransfer.UpdateOperation;
|
|
} | {
|
|
withdrawTransfer?: never;
|
|
withdrawTransferId?: ForeignKey<"withdrawTransfer">;
|
|
}) & ({
|
|
sysAccountMoveId?: never;
|
|
sysAccountMove?: SysAccountMove.CreateSingleOperation;
|
|
} | {
|
|
sysAccountMove?: never;
|
|
sysAccountMoveId?: ForeignKey<"sysAccountMove">;
|
|
})) & ({
|
|
entity?: never;
|
|
entityId?: never;
|
|
offlineAccount: OfflineAccount.CreateSingleOperation;
|
|
} | {
|
|
entity: "offlineAccount";
|
|
entityId: ForeignKey<"OfflineAccount">;
|
|
offlineAccount?: OfflineAccount.UpdateOperation;
|
|
} | {
|
|
entity: "offlineAccount";
|
|
entityId: ForeignKey<"OfflineAccount">;
|
|
offlineAccount?: never;
|
|
} | {
|
|
entity?: never;
|
|
entityId?: never;
|
|
wpAccount: WpAccount.CreateSingleOperation;
|
|
} | {
|
|
entity: "wpAccount";
|
|
entityId: ForeignKey<"WpAccount">;
|
|
wpAccount?: WpAccount.UpdateOperation;
|
|
} | {
|
|
entity: "wpAccount";
|
|
entityId: ForeignKey<"WpAccount">;
|
|
wpAccount?: never;
|
|
} | {
|
|
entity?: string;
|
|
entityId?: string;
|
|
[K: string]: any;
|
|
});
|
|
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
|
|
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
|
|
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
|
|
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity" | "entityId" | "payId" | "refundId" | "withdrawTransferId" | "sysAccountMoveId">> & (({
|
|
pay?: Pay.CreateSingleOperation;
|
|
payId?: never;
|
|
} | {
|
|
pay?: Pay.UpdateOperation;
|
|
payId?: never;
|
|
} | {
|
|
pay?: Pay.RemoveOperation;
|
|
payId?: never;
|
|
} | {
|
|
pay?: never;
|
|
payId?: ForeignKey<"pay"> | null;
|
|
}) & ({
|
|
refund?: Refund.CreateSingleOperation;
|
|
refundId?: never;
|
|
} | {
|
|
refund?: Refund.UpdateOperation;
|
|
refundId?: never;
|
|
} | {
|
|
refund?: Refund.RemoveOperation;
|
|
refundId?: never;
|
|
} | {
|
|
refund?: never;
|
|
refundId?: ForeignKey<"refund"> | null;
|
|
}) & ({
|
|
withdrawTransfer?: WithdrawTransfer.CreateSingleOperation;
|
|
withdrawTransferId?: never;
|
|
} | {
|
|
withdrawTransfer?: WithdrawTransfer.UpdateOperation;
|
|
withdrawTransferId?: never;
|
|
} | {
|
|
withdrawTransfer?: WithdrawTransfer.RemoveOperation;
|
|
withdrawTransferId?: never;
|
|
} | {
|
|
withdrawTransfer?: never;
|
|
withdrawTransferId?: ForeignKey<"withdrawTransfer"> | null;
|
|
}) & ({
|
|
sysAccountMove?: SysAccountMove.CreateSingleOperation;
|
|
sysAccountMoveId?: never;
|
|
} | {
|
|
sysAccountMove?: never;
|
|
sysAccountMoveId?: ForeignKey<"sysAccountMove"> | null;
|
|
})) & ({
|
|
offlineAccount?: OfflineAccount.CreateSingleOperation | OfflineAccount.UpdateOperation | OfflineAccount.RemoveOperation;
|
|
entityId?: never;
|
|
entity?: never;
|
|
} | {
|
|
wpAccount?: WpAccount.CreateSingleOperation | WpAccount.UpdateOperation | WpAccount.RemoveOperation;
|
|
entityId?: never;
|
|
entity?: never;
|
|
} | {
|
|
entity?: ("offlineAccount" | "wpAccount" | string) | null;
|
|
entityId?: ForeignKey<"OfflineAccount" | "WpAccount"> | null;
|
|
offlineAccount?: never;
|
|
wpAccount?: never;
|
|
}) & {
|
|
[k: string]: any;
|
|
};
|
|
export type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
|
|
export type RemoveOperationData = {} & (({
|
|
pay?: Pay.UpdateOperation | Pay.RemoveOperation;
|
|
}) & ({
|
|
refund?: Refund.UpdateOperation | Refund.RemoveOperation;
|
|
}) & ({
|
|
withdrawTransfer?: WithdrawTransfer.UpdateOperation | WithdrawTransfer.RemoveOperation;
|
|
})) & ({
|
|
offlineAccount?: OfflineAccount.UpdateOperation | OfflineAccount.RemoveOperation;
|
|
} | {
|
|
wpAccount?: WpAccount.UpdateOperation | WpAccount.RemoveOperation;
|
|
} | {
|
|
[k: string]: any;
|
|
});
|
|
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
|
export type PayIdSubQuery = Selection<PayIdProjection>;
|
|
export type RefundIdSubQuery = Selection<RefundIdProjection>;
|
|
export type WithdrawTransferIdSubQuery = Selection<WithdrawTransferIdProjection>;
|
|
export type SysAccountMoveIdSubQuery = Selection<SysAccountMoveIdProjection>;
|
|
export type OfflineAccountIdSubQuery = Selection<OfflineAccountIdProjection>;
|
|
export type WpAccountIdSubQuery = Selection<WpAccountIdProjection>;
|
|
export type SysAccountOperIdSubQuery = Selection<SysAccountOperIdProjection>;
|
|
export 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 {};
|