168 lines
7.2 KiB
TypeScript
168 lines
7.2 KiB
TypeScript
import { ForeignKey, JsonProjection } from "oak-domain/lib/types/DataType";
|
|
import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey, JsonFilter, 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 { Boolean } from "oak-domain/lib/types/DataType";
|
|
import * as System from "../System/Schema";
|
|
import * as ApplicationPassport from "../ApplicationPassport/Schema";
|
|
export type Type = "password" | "sms" | "email" | "wechatWeb" | "wechatMp" | "wechatPublic" | "wechatPublicForWeb" | "wechatMpForWeb";
|
|
export type SmsConfig = {
|
|
mockSend?: boolean;
|
|
defaultOrigin?: "ali" | "tencent" | "ctyun";
|
|
templateName?: string;
|
|
codeDuration?: number;
|
|
digit?: number;
|
|
};
|
|
export type EmailConfig = {
|
|
mockSend?: boolean;
|
|
account: string;
|
|
subject: string;
|
|
text?: string;
|
|
html?: string;
|
|
codeDuration?: number;
|
|
digit?: number;
|
|
};
|
|
export type PfwConfig = {
|
|
appId: string;
|
|
};
|
|
export type MfwConfig = {
|
|
appId: string;
|
|
};
|
|
export type OpSchema = EntityShape & {
|
|
systemId: ForeignKey<"system">;
|
|
type: Type;
|
|
config?: (SmsConfig | EmailConfig | PfwConfig | MfwConfig) | null;
|
|
enabled: Boolean;
|
|
};
|
|
export type OpAttr = keyof OpSchema;
|
|
export type Schema = EntityShape & {
|
|
systemId: ForeignKey<"system">;
|
|
type: Type;
|
|
config?: (SmsConfig | EmailConfig | PfwConfig | MfwConfig) | null;
|
|
enabled: Boolean;
|
|
system: System.Schema;
|
|
applicationPassport$passport?: Array<ApplicationPassport.Schema>;
|
|
applicationPassport$passport$$aggr?: AggregationResult<ApplicationPassport.Schema>;
|
|
} & {
|
|
[A in ExpressionKey]?: any;
|
|
};
|
|
type AttrFilter = {
|
|
id: Q_StringValue;
|
|
$$createAt$$: Q_DateValue;
|
|
$$seq$$: Q_NumberValue;
|
|
$$updateAt$$: Q_DateValue;
|
|
systemId: Q_StringValue;
|
|
system: System.Filter;
|
|
type: Q_EnumValue<Type>;
|
|
config: JsonFilter<SmsConfig | EmailConfig | PfwConfig | MfwConfig>;
|
|
enabled: Q_BooleanValue;
|
|
applicationPassport$passport: ApplicationPassport.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;
|
|
systemId?: number;
|
|
system?: System.Projection;
|
|
type?: number;
|
|
config?: number | JsonProjection<SmsConfig | EmailConfig | PfwConfig | MfwConfig>;
|
|
enabled?: number;
|
|
applicationPassport$passport?: ApplicationPassport.Selection & {
|
|
$entity: "applicationPassport";
|
|
};
|
|
applicationPassport$passport$$aggr?: ApplicationPassport.Aggregation & {
|
|
$entity: "applicationPassport";
|
|
};
|
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
type PassportIdProjection = OneOf<{
|
|
id: number;
|
|
}>;
|
|
type SystemIdProjection = OneOf<{
|
|
systemId: number;
|
|
}>;
|
|
export type SortAttr = {
|
|
id: number;
|
|
} | {
|
|
$$createAt$$: number;
|
|
} | {
|
|
$$seq$$: number;
|
|
} | {
|
|
$$updateAt$$: number;
|
|
} | {
|
|
systemId: number;
|
|
} | {
|
|
system: System.SortAttr;
|
|
} | {
|
|
type: number;
|
|
} | {
|
|
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, "systemId">> & (({
|
|
systemId?: never;
|
|
system: System.CreateSingleOperation;
|
|
} | {
|
|
systemId: ForeignKey<"system">;
|
|
system?: System.UpdateOperation;
|
|
} | {
|
|
system?: never;
|
|
systemId: ForeignKey<"system">;
|
|
})) & {
|
|
applicationPassport$passport?: OakOperation<ApplicationPassport.UpdateOperation["action"], Omit<ApplicationPassport.UpdateOperationData, "passport" | "passportId">, Omit<ApplicationPassport.Filter, "passport" | "passportId">> | OakOperation<"create", Omit<ApplicationPassport.CreateOperationData, "passport" | "passportId">[]> | Array<OakOperation<"create", Omit<ApplicationPassport.CreateOperationData, "passport" | "passportId">> | OakOperation<ApplicationPassport.UpdateOperation["action"], Omit<ApplicationPassport.UpdateOperationData, "passport" | "passportId">, Omit<ApplicationPassport.Filter, "passport" | "passportId">>>;
|
|
};
|
|
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
|
|
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
|
|
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
|
|
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "systemId">> & (({
|
|
system?: System.CreateSingleOperation;
|
|
systemId?: never;
|
|
} | {
|
|
system?: System.UpdateOperation;
|
|
systemId?: never;
|
|
} | {
|
|
system?: System.RemoveOperation;
|
|
systemId?: never;
|
|
} | {
|
|
system?: never;
|
|
systemId?: ForeignKey<"system">;
|
|
})) & {
|
|
[k: string]: any;
|
|
applicationPassport$passport?: OakOperation<ApplicationPassport.UpdateOperation["action"], Omit<ApplicationPassport.UpdateOperationData, "passport" | "passportId">, Omit<ApplicationPassport.Filter, "passport" | "passportId">> | OakOperation<ApplicationPassport.RemoveOperation["action"], Omit<ApplicationPassport.RemoveOperationData, "passport" | "passportId">, Omit<ApplicationPassport.Filter, "passport" | "passportId">> | OakOperation<"create", Omit<ApplicationPassport.CreateOperationData, "passport" | "passportId">[]> | Array<OakOperation<"create", Omit<ApplicationPassport.CreateOperationData, "passport" | "passportId">> | OakOperation<ApplicationPassport.UpdateOperation["action"], Omit<ApplicationPassport.UpdateOperationData, "passport" | "passportId">, Omit<ApplicationPassport.Filter, "passport" | "passportId">> | OakOperation<ApplicationPassport.RemoveOperation["action"], Omit<ApplicationPassport.RemoveOperationData, "passport" | "passportId">, Omit<ApplicationPassport.Filter, "passport" | "passportId">>>;
|
|
};
|
|
export type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
|
|
export type RemoveOperationData = {} & (({
|
|
system?: System.UpdateOperation | System.RemoveOperation;
|
|
}));
|
|
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
|
export type SystemIdSubQuery = Selection<SystemIdProjection>;
|
|
export type PassportIdSubQuery = Selection<PassportIdProjection>;
|
|
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 {};
|