oak-pay-business/lib/oak-app-domain/AccountOper/Schema.d.ts

344 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 * as Account from "../Account/Schema";
import * as Deposit from "../Deposit/Schema";
import * as Order from "../Order/Schema";
import * as Pay from "../Pay/Schema";
import * as Refund from "../Refund/Schema";
import * as Withdraw from "../Withdraw/Schema";
import * as WithdrawTransfer from "../WithdrawTransfer/Schema";
type Type = "deposit" | "withdraw" | "consume" | "consumeBack" | "loan" | "repay" | "withdrawBack" | "earn" | "encash" | "cutoffRefundable" | "tax" | "taxRefund" | "refund" | "refundFailure";
export type OpSchema = EntityShape & {
accountId: ForeignKey<"account">;
type: Type;
totalPlus: Price;
availPlus: Price;
refundablePlus?: Price | null;
total: Price;
avail: Price;
refundable: Price;
entity: "deposit" | "order" | "pay" | "refund" | "withdraw" | "withdrawTransfer" | string;
entityId: String<64>;
};
export type OpAttr = keyof OpSchema;
export type Schema = OpSchema & {
account: Account.Schema;
deposit?: Deposit.Schema;
order?: Order.Schema;
pay?: Pay.Schema;
refund?: Refund.Schema;
withdraw?: Withdraw.Schema;
withdrawTransfer?: WithdrawTransfer.Schema;
} & {
[A in ExpressionKey]?: any;
};
type AttrFilter = {
id: Q_StringValue;
$$createAt$$: Q_DateValue;
$$seq$$: Q_NumberValue;
$$updateAt$$: Q_DateValue;
accountId: Q_StringValue;
account: Account.Filter;
type: Q_EnumValue<Type>;
totalPlus: Q_NumberValue;
availPlus: Q_NumberValue;
refundablePlus: Q_NumberValue;
total: Q_NumberValue;
avail: Q_NumberValue;
refundable: Q_NumberValue;
entity: Q_EnumValue<"deposit" | "order" | "pay" | "refund" | "withdraw" | "withdrawTransfer" | string>;
entityId: Q_StringValue;
deposit: Deposit.Filter;
order: Order.Filter;
pay: Pay.Filter;
refund: Refund.Filter;
withdraw: Withdraw.Filter;
withdrawTransfer: WithdrawTransfer.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;
accountId?: number;
account?: Account.Projection;
type?: number;
totalPlus?: number;
availPlus?: number;
refundablePlus?: number;
total?: number;
avail?: number;
refundable?: number;
entity?: number;
entityId?: number;
deposit?: Deposit.Projection;
order?: Order.Projection;
pay?: Pay.Projection;
refund?: Refund.Projection;
withdraw?: Withdraw.Projection;
withdrawTransfer?: WithdrawTransfer.Projection;
} & Partial<ExprOp<OpAttr | string>>;
type AccountOperIdProjection = OneOf<{
id: number;
}>;
type AccountIdProjection = OneOf<{
accountId: number;
}>;
type DepositIdProjection = OneOf<{
entityId: number;
}>;
type OrderIdProjection = OneOf<{
entityId: number;
}>;
type PayIdProjection = OneOf<{
entityId: number;
}>;
type RefundIdProjection = OneOf<{
entityId: number;
}>;
type WithdrawIdProjection = OneOf<{
entityId: number;
}>;
type WithdrawTransferIdProjection = OneOf<{
entityId: number;
}>;
export type SortAttr = {
id: number;
} | {
$$createAt$$: number;
} | {
$$seq$$: number;
} | {
$$updateAt$$: number;
} | {
accountId: number;
} | {
account: Account.SortAttr;
} | {
type: number;
} | {
totalPlus: number;
} | {
availPlus: number;
} | {
refundablePlus: number;
} | {
total: number;
} | {
avail: number;
} | {
refundable: number;
} | {
entity: number;
} | {
entityId: number;
} | {
deposit: Deposit.SortAttr;
} | {
order: Order.SortAttr;
} | {
pay: Pay.SortAttr;
} | {
refund: Refund.SortAttr;
} | {
withdraw: Withdraw.SortAttr;
} | {
withdrawTransfer: WithdrawTransfer.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" | "accountId">> & (({
accountId?: never;
account: Account.CreateSingleOperation;
} | {
accountId: ForeignKey<"account">;
account?: Account.UpdateOperation;
} | {
account?: never;
accountId: ForeignKey<"account">;
})) & ({
entity?: never;
entityId?: never;
deposit: Deposit.CreateSingleOperation;
} | {
entity: "deposit";
entityId: ForeignKey<"Deposit">;
deposit?: Deposit.UpdateOperation;
} | {
entity: "deposit";
entityId: ForeignKey<"Deposit">;
deposit?: never;
} | {
entity?: never;
entityId?: never;
order: Order.CreateSingleOperation;
} | {
entity: "order";
entityId: ForeignKey<"Order">;
order?: Order.UpdateOperation;
} | {
entity: "order";
entityId: ForeignKey<"Order">;
order?: never;
} | {
entity?: never;
entityId?: never;
pay: Pay.CreateSingleOperation;
} | {
entity: "pay";
entityId: ForeignKey<"Pay">;
pay?: Pay.UpdateOperation;
} | {
entity: "pay";
entityId: ForeignKey<"Pay">;
pay?: never;
} | {
entity?: never;
entityId?: never;
refund: Refund.CreateSingleOperation;
} | {
entity: "refund";
entityId: ForeignKey<"Refund">;
refund?: Refund.UpdateOperation;
} | {
entity: "refund";
entityId: ForeignKey<"Refund">;
refund?: never;
} | {
entity?: never;
entityId?: never;
withdraw: Withdraw.CreateSingleOperation;
} | {
entity: "withdraw";
entityId: ForeignKey<"Withdraw">;
withdraw?: Withdraw.UpdateOperation;
} | {
entity: "withdraw";
entityId: ForeignKey<"Withdraw">;
withdraw?: never;
} | {
entity?: never;
entityId?: never;
withdrawTransfer: WithdrawTransfer.CreateSingleOperation;
} | {
entity: "withdrawTransfer";
entityId: ForeignKey<"WithdrawTransfer">;
withdrawTransfer?: WithdrawTransfer.UpdateOperation;
} | {
entity: "withdrawTransfer";
entityId: ForeignKey<"WithdrawTransfer">;
withdrawTransfer?: 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" | "accountId">> & (({
account?: Account.CreateSingleOperation;
accountId?: never;
} | {
account?: Account.UpdateOperation;
accountId?: never;
} | {
account?: Account.RemoveOperation;
accountId?: never;
} | {
account?: never;
accountId?: ForeignKey<"account">;
})) & ({
deposit?: Deposit.CreateSingleOperation | Deposit.UpdateOperation | Deposit.RemoveOperation;
entityId?: never;
entity?: never;
} | {
order?: Order.CreateSingleOperation | Order.UpdateOperation | Order.RemoveOperation;
entityId?: never;
entity?: never;
} | {
pay?: Pay.CreateSingleOperation | Pay.UpdateOperation | Pay.RemoveOperation;
entityId?: never;
entity?: never;
} | {
refund?: Refund.CreateSingleOperation | Refund.UpdateOperation | Refund.RemoveOperation;
entityId?: never;
entity?: never;
} | {
withdraw?: Withdraw.CreateSingleOperation | Withdraw.UpdateOperation | Withdraw.RemoveOperation;
entityId?: never;
entity?: never;
} | {
withdrawTransfer?: WithdrawTransfer.CreateSingleOperation | WithdrawTransfer.UpdateOperation | WithdrawTransfer.RemoveOperation;
entityId?: never;
entity?: never;
} | {
entity?: ("deposit" | "order" | "pay" | "refund" | "withdraw" | "withdrawTransfer" | string) | null;
entityId?: ForeignKey<"Deposit" | "Order" | "Pay" | "Refund" | "Withdraw" | "WithdrawTransfer"> | null;
deposit?: never;
order?: never;
pay?: never;
refund?: never;
withdraw?: never;
withdrawTransfer?: never;
}) & {
[k: string]: any;
};
export type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export type RemoveOperationData = {} & (({
account?: Account.UpdateOperation | Account.RemoveOperation;
})) & ({
deposit?: Deposit.UpdateOperation | Deposit.RemoveOperation;
} | {
order?: Order.UpdateOperation | Order.RemoveOperation;
} | {
pay?: Pay.UpdateOperation | Pay.RemoveOperation;
} | {
refund?: Refund.UpdateOperation | Refund.RemoveOperation;
} | {
withdraw?: Withdraw.UpdateOperation | Withdraw.RemoveOperation;
} | {
withdrawTransfer?: WithdrawTransfer.UpdateOperation | WithdrawTransfer.RemoveOperation;
} | {
[k: string]: any;
});
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
export type AccountIdSubQuery = Selection<AccountIdProjection>;
export type DepositIdSubQuery = Selection<DepositIdProjection>;
export type OrderIdSubQuery = Selection<OrderIdProjection>;
export type PayIdSubQuery = Selection<PayIdProjection>;
export type RefundIdSubQuery = Selection<RefundIdProjection>;
export type WithdrawIdSubQuery = Selection<WithdrawIdProjection>;
export type WithdrawTransferIdSubQuery = Selection<WithdrawTransferIdProjection>;
export type AccountOperIdSubQuery = Selection<AccountOperIdProjection>;
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 {};