284 lines
8.8 KiB
TypeScript
284 lines
8.8 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, Datetime, Int } from "oak-domain/lib/types/DataType";
|
|
import * as Account from "../Account/Schema";
|
|
import * as Order from "../Order/Schema";
|
|
import * as Application from "../Application/Schema";
|
|
import * as AccountOper from "../AccountOper/Schema";
|
|
export type OpSchema = EntityShape & {
|
|
price: Price;
|
|
paid: Price;
|
|
refunded: Price;
|
|
channel: String<32>;
|
|
timeoutAt?: Datetime | null;
|
|
forbidRefundAt?: Datetime | null;
|
|
accountId?: ForeignKey<"account"> | null;
|
|
orderId?: ForeignKey<"order"> | null;
|
|
externalId?: String<80> | null;
|
|
meta: Object;
|
|
applicationId: ForeignKey<"application">;
|
|
phantom1?: String<32> | null;
|
|
phantom2?: String<32> | null;
|
|
phantom3?: Int<4> | null;
|
|
phantom4?: Int<8> | null;
|
|
iState?: IState | null;
|
|
};
|
|
export type OpAttr = keyof OpSchema;
|
|
export type Schema = EntityShape & {
|
|
price: Price;
|
|
paid: Price;
|
|
refunded: Price;
|
|
channel: String<32>;
|
|
timeoutAt?: Datetime | null;
|
|
forbidRefundAt?: Datetime | null;
|
|
accountId?: ForeignKey<"account"> | null;
|
|
orderId?: ForeignKey<"order"> | null;
|
|
externalId?: String<80> | null;
|
|
meta: Object;
|
|
applicationId: ForeignKey<"application">;
|
|
phantom1?: String<32> | null;
|
|
phantom2?: String<32> | null;
|
|
phantom3?: Int<4> | null;
|
|
phantom4?: Int<8> | null;
|
|
iState?: IState | null;
|
|
account?: Account.Schema | null;
|
|
order?: Order.Schema | null;
|
|
application: Application.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;
|
|
price: Q_NumberValue;
|
|
paid: Q_NumberValue;
|
|
refunded: Q_NumberValue;
|
|
channel: Q_StringValue;
|
|
timeoutAt: Q_DateValue;
|
|
forbidRefundAt: Q_DateValue;
|
|
accountId: Q_StringValue;
|
|
account: Account.Filter;
|
|
orderId: Q_StringValue;
|
|
order: Order.Filter;
|
|
externalId: Q_StringValue;
|
|
meta: Object;
|
|
applicationId: Q_StringValue;
|
|
application: Application.Filter;
|
|
phantom1: Q_StringValue;
|
|
phantom2: Q_StringValue;
|
|
phantom3: Q_NumberValue;
|
|
phantom4: Q_NumberValue;
|
|
iState: Q_EnumValue<IState>;
|
|
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;
|
|
price?: number;
|
|
paid?: number;
|
|
refunded?: number;
|
|
channel?: number;
|
|
timeoutAt?: number;
|
|
forbidRefundAt?: number;
|
|
accountId?: number;
|
|
account?: Account.Projection;
|
|
orderId?: number;
|
|
order?: Order.Projection;
|
|
externalId?: number;
|
|
meta?: number | Object;
|
|
applicationId?: number;
|
|
application?: Application.Projection;
|
|
phantom1?: number;
|
|
phantom2?: number;
|
|
phantom3?: number;
|
|
phantom4?: number;
|
|
iState?: number;
|
|
accountOper$entity?: AccountOper.Selection & {
|
|
$entity: "accountOper";
|
|
};
|
|
accountOper$entity$$aggr?: AccountOper.Aggregation & {
|
|
$entity: "accountOper";
|
|
};
|
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
type PayIdProjection = OneOf<{
|
|
id: number;
|
|
}>;
|
|
type AccountIdProjection = OneOf<{
|
|
accountId: number;
|
|
}>;
|
|
type OrderIdProjection = OneOf<{
|
|
orderId: number;
|
|
}>;
|
|
type ApplicationIdProjection = OneOf<{
|
|
applicationId: number;
|
|
}>;
|
|
export type SortAttr = {
|
|
id: number;
|
|
} | {
|
|
$$createAt$$: number;
|
|
} | {
|
|
$$seq$$: number;
|
|
} | {
|
|
$$updateAt$$: number;
|
|
} | {
|
|
price: number;
|
|
} | {
|
|
paid: number;
|
|
} | {
|
|
refunded: number;
|
|
} | {
|
|
channel: number;
|
|
} | {
|
|
timeoutAt: number;
|
|
} | {
|
|
forbidRefundAt: number;
|
|
} | {
|
|
accountId: number;
|
|
} | {
|
|
account: Account.SortAttr;
|
|
} | {
|
|
orderId: number;
|
|
} | {
|
|
order: Order.SortAttr;
|
|
} | {
|
|
externalId: number;
|
|
} | {
|
|
applicationId: number;
|
|
} | {
|
|
application: Application.SortAttr;
|
|
} | {
|
|
phantom1: number;
|
|
} | {
|
|
phantom2: number;
|
|
} | {
|
|
phantom3: number;
|
|
} | {
|
|
phantom4: 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" | "orderId" | "applicationId">> & (({
|
|
accountId?: never;
|
|
account?: Account.CreateSingleOperation;
|
|
} | {
|
|
accountId: ForeignKey<"account">;
|
|
account?: Account.UpdateOperation;
|
|
} | {
|
|
account?: never;
|
|
accountId?: ForeignKey<"account">;
|
|
}) & ({
|
|
orderId?: never;
|
|
order?: Order.CreateSingleOperation;
|
|
} | {
|
|
orderId: ForeignKey<"order">;
|
|
order?: Order.UpdateOperation;
|
|
} | {
|
|
order?: never;
|
|
orderId?: ForeignKey<"order">;
|
|
}) & ({
|
|
applicationId?: never;
|
|
application: Application.CreateSingleOperation;
|
|
} | {
|
|
applicationId: ForeignKey<"application">;
|
|
application?: Application.UpdateOperation;
|
|
} | {
|
|
application?: never;
|
|
applicationId: ForeignKey<"application">;
|
|
})) & {
|
|
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" | "orderId" | "applicationId">> & (({
|
|
account?: Account.CreateSingleOperation;
|
|
accountId?: never;
|
|
} | {
|
|
account?: Account.UpdateOperation;
|
|
accountId?: never;
|
|
} | {
|
|
account?: Account.RemoveOperation;
|
|
accountId?: never;
|
|
} | {
|
|
account?: never;
|
|
accountId?: ForeignKey<"account"> | null;
|
|
}) & ({
|
|
order?: Order.CreateSingleOperation;
|
|
orderId?: never;
|
|
} | {
|
|
order?: Order.UpdateOperation;
|
|
orderId?: never;
|
|
} | {
|
|
order?: Order.RemoveOperation;
|
|
orderId?: never;
|
|
} | {
|
|
order?: never;
|
|
orderId?: ForeignKey<"order"> | null;
|
|
}) & ({
|
|
application?: Application.CreateSingleOperation;
|
|
applicationId?: never;
|
|
} | {
|
|
application?: Application.UpdateOperation;
|
|
applicationId?: never;
|
|
} | {
|
|
application?: Application.RemoveOperation;
|
|
applicationId?: never;
|
|
} | {
|
|
application?: never;
|
|
applicationId?: ForeignKey<"application">;
|
|
})) & {
|
|
[k: string]: any;
|
|
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;
|
|
}) & ({
|
|
order?: Order.UpdateOperation | Order.RemoveOperation;
|
|
}) & ({
|
|
application?: Application.UpdateOperation | Application.RemoveOperation;
|
|
}));
|
|
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
|
export type AccountIdSubQuery = Selection<AccountIdProjection>;
|
|
export type OrderIdSubQuery = Selection<OrderIdProjection>;
|
|
export type ApplicationIdSubQuery = Selection<ApplicationIdProjection>;
|
|
export type PayIdSubQuery = Selection<PayIdProjection>;
|
|
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 {};
|