271 lines
13 KiB
TypeScript
271 lines
13 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 } from "./Action";
|
|
import { AbleState } from "oak-domain/lib/actions/action";
|
|
import { Price, String } from "oak-domain/lib/types/DataType";
|
|
import * as System from "../System/Schema";
|
|
import * as User from "../User/Schema";
|
|
import * as AccountOper from "../AccountOper/Schema";
|
|
import * as Deposit from "../Deposit/Schema";
|
|
import * as Withdraw from "../Withdraw/Schema";
|
|
import * as Pay from "../Pay/Schema";
|
|
export type OpSchema = EntityShape & {
|
|
total: Price;
|
|
avail: Price;
|
|
refundable: Price;
|
|
ofSystemId: ForeignKey<"system">;
|
|
entity: "system" | "user" | string;
|
|
entityId: String<64>;
|
|
ableState?: AbleState | null;
|
|
};
|
|
export type OpAttr = keyof OpSchema;
|
|
type AccountOper$accountAggr = "accountOper$account$$aggr" | "accountOper$account$$0$$aggr" | "accountOper$account$$1$$aggr" | "accountOper$account$$2$$aggr" | "accountOper$account$$3$$aggr" | "accountOper$account$$4$$aggr" | "accountOper$account$$5$$aggr" | "accountOper$account$$6$$aggr" | "accountOper$account$$7$$aggr" | "accountOper$account$$8$$aggr" | "accountOper$account$$9$$aggr";
|
|
type Deposit$accountAggr = "deposit$account$$aggr" | "deposit$account$$0$$aggr" | "deposit$account$$1$$aggr" | "deposit$account$$2$$aggr" | "deposit$account$$3$$aggr" | "deposit$account$$4$$aggr" | "deposit$account$$5$$aggr" | "deposit$account$$6$$aggr" | "deposit$account$$7$$aggr" | "deposit$account$$8$$aggr" | "deposit$account$$9$$aggr";
|
|
type Withdraw$accountAggr = "withdraw$account$$aggr" | "withdraw$account$$0$$aggr" | "withdraw$account$$1$$aggr" | "withdraw$account$$2$$aggr" | "withdraw$account$$3$$aggr" | "withdraw$account$$4$$aggr" | "withdraw$account$$5$$aggr" | "withdraw$account$$6$$aggr" | "withdraw$account$$7$$aggr" | "withdraw$account$$8$$aggr" | "withdraw$account$$9$$aggr";
|
|
type Pay$entityAggr = "pay$entity$$aggr" | "pay$entity$$0$$aggr" | "pay$entity$$1$$aggr" | "pay$entity$$2$$aggr" | "pay$entity$$3$$aggr" | "pay$entity$$4$$aggr" | "pay$entity$$5$$aggr" | "pay$entity$$6$$aggr" | "pay$entity$$7$$aggr" | "pay$entity$$8$$aggr" | "pay$entity$$9$$aggr";
|
|
export type Schema = OpSchema & {
|
|
ofSystem: System.Schema;
|
|
system?: System.Schema;
|
|
user?: User.Schema;
|
|
accountOper$account?: Array<AccountOper.Schema>;
|
|
deposit$account?: Array<Deposit.Schema>;
|
|
withdraw$account?: Array<Withdraw.Schema>;
|
|
pay$entity?: Array<Pay.Schema>;
|
|
} & {
|
|
[A in ExpressionKey]?: any;
|
|
} & {
|
|
[A in AccountOper$accountAggr]?: AggregationResult<AccountOper.Schema>;
|
|
} & {
|
|
[A in Deposit$accountAggr]?: AggregationResult<Deposit.Schema>;
|
|
} & {
|
|
[A in Withdraw$accountAggr]?: AggregationResult<Withdraw.Schema>;
|
|
} & {
|
|
[A in Pay$entityAggr]?: AggregationResult<Pay.Schema>;
|
|
};
|
|
type AttrFilter = {
|
|
id: Q_StringValue;
|
|
$$createAt$$: Q_DateValue;
|
|
$$seq$$: Q_NumberValue;
|
|
$$updateAt$$: Q_DateValue;
|
|
total: Q_NumberValue;
|
|
avail: Q_NumberValue;
|
|
refundable: Q_NumberValue;
|
|
ofSystemId: Q_StringValue;
|
|
ofSystem: System.Filter;
|
|
entity: Q_EnumValue<"system" | "user" | string>;
|
|
entityId: Q_StringValue;
|
|
ableState: Q_EnumValue<AbleState>;
|
|
system: System.Filter;
|
|
user: User.Filter;
|
|
accountOper$account: AccountOper.Filter & SubQueryPredicateMetadata;
|
|
deposit$account: Deposit.Filter & SubQueryPredicateMetadata;
|
|
withdraw$account: Withdraw.Filter & SubQueryPredicateMetadata;
|
|
pay$entity: Pay.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;
|
|
total?: number;
|
|
avail?: number;
|
|
refundable?: number;
|
|
ofSystemId?: number;
|
|
ofSystem?: System.Projection;
|
|
entity?: number;
|
|
entityId?: number;
|
|
ableState?: number;
|
|
system?: System.Projection;
|
|
user?: User.Projection;
|
|
accountOper$account?: AccountOper.Selection & {
|
|
$entity: "accountOper";
|
|
};
|
|
deposit$account?: Deposit.Selection & {
|
|
$entity: "deposit";
|
|
};
|
|
withdraw$account?: Withdraw.Selection & {
|
|
$entity: "withdraw";
|
|
};
|
|
pay$entity?: Pay.Selection & {
|
|
$entity: "pay";
|
|
};
|
|
} & Partial<ExprOp<OpAttr | string>> & {
|
|
[A in AccountOper$accountAggr]?: AccountOper.Aggregation & {
|
|
$entity: "accountOper";
|
|
};
|
|
} & {
|
|
[A in Deposit$accountAggr]?: Deposit.Aggregation & {
|
|
$entity: "deposit";
|
|
};
|
|
} & {
|
|
[A in Withdraw$accountAggr]?: Withdraw.Aggregation & {
|
|
$entity: "withdraw";
|
|
};
|
|
} & {
|
|
[A in Pay$entityAggr]?: Pay.Aggregation & {
|
|
$entity: "pay";
|
|
};
|
|
};
|
|
type AccountIdProjection = OneOf<{
|
|
id: number;
|
|
}>;
|
|
type SystemIdProjection = OneOf<{
|
|
ofSystemId: number;
|
|
entityId: number;
|
|
}>;
|
|
type UserIdProjection = OneOf<{
|
|
entityId: number;
|
|
}>;
|
|
export type SortAttr = {
|
|
id: number;
|
|
} | {
|
|
$$createAt$$: number;
|
|
} | {
|
|
$$seq$$: number;
|
|
} | {
|
|
$$updateAt$$: number;
|
|
} | {
|
|
total: number;
|
|
} | {
|
|
avail: number;
|
|
} | {
|
|
refundable: number;
|
|
} | {
|
|
ofSystemId: number;
|
|
} | {
|
|
ofSystem: System.SortAttr;
|
|
} | {
|
|
entity: number;
|
|
} | {
|
|
entityId: number;
|
|
} | {
|
|
ableState: number;
|
|
} | {
|
|
system: System.SortAttr;
|
|
} | {
|
|
user: User.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" | "ofSystemId">> & (({
|
|
ofSystemId?: never;
|
|
ofSystem: System.CreateSingleOperation;
|
|
} | {
|
|
ofSystemId: ForeignKey<"ofSystem">;
|
|
ofSystem?: System.UpdateOperation;
|
|
} | {
|
|
ofSystem?: never;
|
|
ofSystemId: ForeignKey<"ofSystem">;
|
|
})) & ({
|
|
entity?: never;
|
|
entityId?: never;
|
|
system: System.CreateSingleOperation;
|
|
} | {
|
|
entity: "system";
|
|
entityId: ForeignKey<"System">;
|
|
system?: System.UpdateOperation;
|
|
} | {
|
|
entity: "system";
|
|
entityId: ForeignKey<"System">;
|
|
system?: never;
|
|
} | {
|
|
entity?: never;
|
|
entityId?: never;
|
|
user: User.CreateSingleOperation;
|
|
} | {
|
|
entity: "user";
|
|
entityId: ForeignKey<"User">;
|
|
user?: User.UpdateOperation;
|
|
} | {
|
|
entity: "user";
|
|
entityId: ForeignKey<"User">;
|
|
user?: never;
|
|
} | {
|
|
entity?: string;
|
|
entityId?: string;
|
|
[K: string]: any;
|
|
}) & {
|
|
accountOper$account?: OakOperation<"create", Omit<AccountOper.CreateOperationData, "account" | "accountId">[]> | Array<OakOperation<"create", Omit<AccountOper.CreateOperationData, "account" | "accountId">>>;
|
|
deposit$account?: OakOperation<Deposit.UpdateOperation["action"], Omit<Deposit.UpdateOperationData, "account" | "accountId">, Omit<Deposit.Filter, "account" | "accountId">> | OakOperation<"create", Omit<Deposit.CreateOperationData, "account" | "accountId">[]> | Array<OakOperation<"create", Omit<Deposit.CreateOperationData, "account" | "accountId">> | OakOperation<Deposit.UpdateOperation["action"], Omit<Deposit.UpdateOperationData, "account" | "accountId">, Omit<Deposit.Filter, "account" | "accountId">>>;
|
|
withdraw$account?: OakOperation<Withdraw.UpdateOperation["action"], Omit<Withdraw.UpdateOperationData, "account" | "accountId">, Omit<Withdraw.Filter, "account" | "accountId">> | OakOperation<"create", Omit<Withdraw.CreateOperationData, "account" | "accountId">[]> | Array<OakOperation<"create", Omit<Withdraw.CreateOperationData, "account" | "accountId">> | OakOperation<Withdraw.UpdateOperation["action"], Omit<Withdraw.UpdateOperationData, "account" | "accountId">, Omit<Withdraw.Filter, "account" | "accountId">>>;
|
|
pay$entity?: OakOperation<Pay.UpdateOperation["action"], Omit<Pay.UpdateOperationData, "entity" | "entityId">, Omit<Pay.Filter, "entity" | "entityId">> | OakOperation<"create", Omit<Pay.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<Pay.CreateOperationData, "entity" | "entityId">> | OakOperation<Pay.UpdateOperation["action"], Omit<Pay.UpdateOperationData, "entity" | "entityId">, Omit<Pay.Filter, "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, "entity" | "entityId" | "ofSystemId">> & (({
|
|
ofSystem?: System.CreateSingleOperation;
|
|
ofSystemId?: never;
|
|
} | {
|
|
ofSystem?: System.UpdateOperation;
|
|
ofSystemId?: never;
|
|
} | {
|
|
ofSystem?: System.RemoveOperation;
|
|
ofSystemId?: never;
|
|
} | {
|
|
ofSystem?: never;
|
|
ofSystemId?: ForeignKey<"ofSystem">;
|
|
})) & ({
|
|
system?: System.CreateSingleOperation | System.UpdateOperation | System.RemoveOperation;
|
|
entityId?: never;
|
|
entity?: never;
|
|
} | {
|
|
user?: User.CreateSingleOperation | User.UpdateOperation | User.RemoveOperation;
|
|
entityId?: never;
|
|
entity?: never;
|
|
} | {
|
|
entity?: ("system" | "user" | string) | null;
|
|
entityId?: ForeignKey<"System" | "User"> | null;
|
|
system?: never;
|
|
user?: never;
|
|
}) & {
|
|
[k: string]: any;
|
|
accountOper$account?: OakOperation<"create", Omit<AccountOper.CreateOperationData, "account" | "accountId">[]> | Array<OakOperation<"create", Omit<AccountOper.CreateOperationData, "account" | "accountId">>>;
|
|
deposit$account?: OakOperation<Deposit.UpdateOperation["action"], Omit<Deposit.UpdateOperationData, "account" | "accountId">, Omit<Deposit.Filter, "account" | "accountId">> | OakOperation<Deposit.RemoveOperation["action"], Omit<Deposit.RemoveOperationData, "account" | "accountId">, Omit<Deposit.Filter, "account" | "accountId">> | OakOperation<"create", Omit<Deposit.CreateOperationData, "account" | "accountId">[]> | Array<OakOperation<"create", Omit<Deposit.CreateOperationData, "account" | "accountId">> | OakOperation<Deposit.UpdateOperation["action"], Omit<Deposit.UpdateOperationData, "account" | "accountId">, Omit<Deposit.Filter, "account" | "accountId">> | OakOperation<Deposit.RemoveOperation["action"], Omit<Deposit.RemoveOperationData, "account" | "accountId">, Omit<Deposit.Filter, "account" | "accountId">>>;
|
|
withdraw$account?: OakOperation<Withdraw.UpdateOperation["action"], Omit<Withdraw.UpdateOperationData, "account" | "accountId">, Omit<Withdraw.Filter, "account" | "accountId">> | OakOperation<Withdraw.RemoveOperation["action"], Omit<Withdraw.RemoveOperationData, "account" | "accountId">, Omit<Withdraw.Filter, "account" | "accountId">> | OakOperation<"create", Omit<Withdraw.CreateOperationData, "account" | "accountId">[]> | Array<OakOperation<"create", Omit<Withdraw.CreateOperationData, "account" | "accountId">> | OakOperation<Withdraw.UpdateOperation["action"], Omit<Withdraw.UpdateOperationData, "account" | "accountId">, Omit<Withdraw.Filter, "account" | "accountId">> | OakOperation<Withdraw.RemoveOperation["action"], Omit<Withdraw.RemoveOperationData, "account" | "accountId">, Omit<Withdraw.Filter, "account" | "accountId">>>;
|
|
pay$entity?: OakOperation<Pay.UpdateOperation["action"], Omit<Pay.UpdateOperationData, "entity" | "entityId">, Omit<Pay.Filter, "entity" | "entityId">> | OakOperation<Pay.RemoveOperation["action"], Omit<Pay.RemoveOperationData, "entity" | "entityId">, Omit<Pay.Filter, "entity" | "entityId">> | OakOperation<"create", Omit<Pay.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<Pay.CreateOperationData, "entity" | "entityId">> | OakOperation<Pay.UpdateOperation["action"], Omit<Pay.UpdateOperationData, "entity" | "entityId">, Omit<Pay.Filter, "entity" | "entityId">> | OakOperation<Pay.RemoveOperation["action"], Omit<Pay.RemoveOperationData, "entity" | "entityId">, Omit<Pay.Filter, "entity" | "entityId">>>;
|
|
};
|
|
export type UpdateOperation = OakOperation<"update" | ParticularAction | string, UpdateOperationData, Filter, Sorter>;
|
|
export type RemoveOperationData = {} & (({
|
|
ofSystem?: System.UpdateOperation | System.RemoveOperation;
|
|
})) & ({
|
|
system?: System.UpdateOperation | System.RemoveOperation;
|
|
} | {
|
|
user?: User.UpdateOperation | User.RemoveOperation;
|
|
} | {
|
|
[k: string]: any;
|
|
});
|
|
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
|
export type SystemIdSubQuery = Selection<SystemIdProjection>;
|
|
export type UserIdSubQuery = Selection<UserIdProjection>;
|
|
export type AccountIdSubQuery = Selection<AccountIdProjection>;
|
|
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 {};
|