210 lines
8.9 KiB
TypeScript
210 lines
8.9 KiB
TypeScript
import { ForeignKey } from "oak-domain/lib/types/DataType";
|
|
import { Q_DateValue, Q_BooleanValue, 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 { GenericAction } from "oak-domain/lib/actions/action";
|
|
import { Decimal, Boolean } from "oak-domain/lib/types/DataType";
|
|
import * as WpAccount from "../WpAccount/Schema";
|
|
import * as Application from "../Application/Schema";
|
|
import * as ModiEntity from "../ModiEntity/Schema";
|
|
import * as OperEntity from "../OperEntity/Schema";
|
|
import * as Pay from "../Pay/Schema";
|
|
export type OpSchema = EntityShape & {
|
|
wpAccountId: ForeignKey<"wpAccount">;
|
|
type: "native" | "mp" | "jsapi" | "h5" | "app";
|
|
taxLossRatio?: Decimal<4, 2> | null;
|
|
applicationId: ForeignKey<"application">;
|
|
enabled: Boolean;
|
|
};
|
|
export type OpAttr = keyof OpSchema;
|
|
export type Schema = EntityShape & {
|
|
wpAccountId: ForeignKey<"wpAccount">;
|
|
type: "native" | "mp" | "jsapi" | "h5" | "app";
|
|
taxLossRatio?: Decimal<4, 2> | null;
|
|
applicationId: ForeignKey<"application">;
|
|
enabled: Boolean;
|
|
wpAccount: WpAccount.Schema;
|
|
application: Application.Schema;
|
|
modiEntity$entity?: Array<ModiEntity.Schema>;
|
|
modiEntity$entity$$aggr?: AggregationResult<ModiEntity.Schema>;
|
|
operEntity$entity?: Array<OperEntity.Schema>;
|
|
operEntity$entity$$aggr?: AggregationResult<OperEntity.Schema>;
|
|
pay$entity?: Array<Pay.Schema>;
|
|
pay$entity$$aggr?: AggregationResult<Pay.Schema>;
|
|
} & {
|
|
[A in ExpressionKey]?: any;
|
|
};
|
|
type AttrFilter = {
|
|
id: Q_StringValue;
|
|
$$createAt$$: Q_DateValue;
|
|
$$seq$$: Q_NumberValue;
|
|
$$updateAt$$: Q_DateValue;
|
|
wpAccountId: Q_StringValue;
|
|
wpAccount: WpAccount.Filter;
|
|
type: Q_EnumValue<"native" | "mp" | "jsapi" | "h5" | "app">;
|
|
taxLossRatio: Q_NumberValue;
|
|
applicationId: Q_StringValue;
|
|
application: Application.Filter;
|
|
enabled: Q_BooleanValue;
|
|
modiEntity$entity: ModiEntity.Filter & SubQueryPredicateMetadata;
|
|
operEntity$entity: OperEntity.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;
|
|
wpAccountId?: number;
|
|
wpAccount?: WpAccount.Projection;
|
|
type?: number;
|
|
taxLossRatio?: number;
|
|
applicationId?: number;
|
|
application?: Application.Projection;
|
|
enabled?: number;
|
|
modiEntity$entity?: ModiEntity.Selection & {
|
|
$entity: "modiEntity";
|
|
};
|
|
modiEntity$entity$$aggr?: ModiEntity.Aggregation & {
|
|
$entity: "modiEntity";
|
|
};
|
|
operEntity$entity?: OperEntity.Selection & {
|
|
$entity: "operEntity";
|
|
};
|
|
operEntity$entity$$aggr?: OperEntity.Aggregation & {
|
|
$entity: "operEntity";
|
|
};
|
|
pay$entity?: Pay.Selection & {
|
|
$entity: "pay";
|
|
};
|
|
pay$entity$$aggr?: Pay.Aggregation & {
|
|
$entity: "pay";
|
|
};
|
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
type WpProductIdProjection = OneOf<{
|
|
id: number;
|
|
}>;
|
|
type WpAccountIdProjection = OneOf<{
|
|
wpAccountId: number;
|
|
}>;
|
|
type ApplicationIdProjection = OneOf<{
|
|
applicationId: number;
|
|
}>;
|
|
export type SortAttr = {
|
|
id: number;
|
|
} | {
|
|
$$createAt$$: number;
|
|
} | {
|
|
$$seq$$: number;
|
|
} | {
|
|
$$updateAt$$: number;
|
|
} | {
|
|
wpAccountId: number;
|
|
} | {
|
|
wpAccount: WpAccount.SortAttr;
|
|
} | {
|
|
type: number;
|
|
} | {
|
|
taxLossRatio: number;
|
|
} | {
|
|
applicationId: number;
|
|
} | {
|
|
application: Application.SortAttr;
|
|
} | {
|
|
enabled: 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, "wpAccountId" | "applicationId">> & (({
|
|
wpAccountId?: never;
|
|
wpAccount: WpAccount.CreateSingleOperation;
|
|
} | {
|
|
wpAccountId: ForeignKey<"wpAccount">;
|
|
wpAccount?: WpAccount.UpdateOperation;
|
|
} | {
|
|
wpAccount?: never;
|
|
wpAccountId: ForeignKey<"wpAccount">;
|
|
}) & ({
|
|
applicationId?: never;
|
|
application: Application.CreateSingleOperation;
|
|
} | {
|
|
applicationId: ForeignKey<"application">;
|
|
application?: Application.UpdateOperation;
|
|
} | {
|
|
application?: never;
|
|
applicationId: ForeignKey<"application">;
|
|
})) & {
|
|
modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
|
|
operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
|
|
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, "wpAccountId" | "applicationId">> & (({
|
|
wpAccount?: WpAccount.CreateSingleOperation;
|
|
wpAccountId?: never;
|
|
} | {
|
|
wpAccount?: WpAccount.UpdateOperation;
|
|
wpAccountId?: never;
|
|
} | {
|
|
wpAccount?: WpAccount.RemoveOperation;
|
|
wpAccountId?: never;
|
|
} | {
|
|
wpAccount?: never;
|
|
wpAccountId?: ForeignKey<"wpAccount">;
|
|
}) & ({
|
|
application?: Application.CreateSingleOperation;
|
|
applicationId?: never;
|
|
} | {
|
|
application?: Application.UpdateOperation;
|
|
applicationId?: never;
|
|
} | {
|
|
application?: Application.RemoveOperation;
|
|
applicationId?: never;
|
|
} | {
|
|
application?: never;
|
|
applicationId?: ForeignKey<"application">;
|
|
})) & {
|
|
[k: string]: any;
|
|
modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
|
|
operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
|
|
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" | string, UpdateOperationData, Filter, Sorter>;
|
|
export type RemoveOperationData = {} & (({
|
|
wpAccount?: WpAccount.UpdateOperation | WpAccount.RemoveOperation;
|
|
}) & ({
|
|
application?: Application.UpdateOperation | Application.RemoveOperation;
|
|
}));
|
|
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
|
export type WpAccountIdSubQuery = Selection<WpAccountIdProjection>;
|
|
export type ApplicationIdSubQuery = Selection<ApplicationIdProjection>;
|
|
export type WpProductIdSubQuery = Selection<WpProductIdProjection>;
|
|
export type EntityDef = {
|
|
Schema: Schema;
|
|
OpSchema: OpSchema;
|
|
Action: OakMakeAction<GenericAction> | string;
|
|
Selection: Selection;
|
|
Aggregation: Aggregation;
|
|
Operation: Operation;
|
|
Create: CreateOperation;
|
|
Update: UpdateOperation;
|
|
Remove: RemoveOperation;
|
|
CreateSingle: CreateSingleOperation;
|
|
CreateMulti: CreateMultipleOperation;
|
|
};
|
|
export {};
|