204 lines
9.3 KiB
TypeScript
204 lines
9.3 KiB
TypeScript
import { String, Text, ForeignKey } from "oak-domain/lib/types/DataType";
|
|
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand";
|
|
import { OneOf } from "oak-domain/lib/types/Polyfill";
|
|
import * as SubQuery from "../_SubQuery";
|
|
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape, AggregationResult } from "oak-domain/lib/types/Entity";
|
|
import { GenericAction } from "oak-domain/lib/actions/action";
|
|
import { Style } from "../../types/Style";
|
|
import * as System from "../System/Schema";
|
|
import * as Token from "../Token/Schema";
|
|
import * as WechatQrCode from "../WechatQrCode/Schema";
|
|
import * as WechatUser from "../WechatUser/Schema";
|
|
export declare type Passport = 'email' | 'mobile' | 'wechat';
|
|
export declare type AppType = 'web' | 'wechatMp' | 'wechatPublic';
|
|
export declare type WechatMpConfig = {
|
|
type: 'wechatMp';
|
|
appId: string;
|
|
appSecret: string;
|
|
qrCodePrefix?: string;
|
|
};
|
|
export declare type WebConfig = {
|
|
type: 'web';
|
|
wechat?: {
|
|
appId: string;
|
|
appSecret: string;
|
|
domain?: string;
|
|
};
|
|
passport: Passport[];
|
|
};
|
|
export declare type WechatPublicTemplateMsgsConfig = Record<string, string>;
|
|
export declare type WechatPublicConfig = {
|
|
type: 'wechatPublic';
|
|
isService: boolean;
|
|
appId: string;
|
|
appSecret: string;
|
|
templateMsgs?: WechatPublicTemplateMsgsConfig;
|
|
};
|
|
export declare type OpSchema = EntityShape & {
|
|
name: String<32>;
|
|
description: Text;
|
|
type: AppType;
|
|
systemId: ForeignKey<"system">;
|
|
config: WebConfig | WechatMpConfig | WechatPublicConfig;
|
|
style?: Style | null;
|
|
};
|
|
export declare type OpAttr = keyof OpSchema;
|
|
export declare type Schema = EntityShape & {
|
|
name: String<32>;
|
|
description: Text;
|
|
type: AppType;
|
|
systemId: ForeignKey<"system">;
|
|
config: WebConfig | WechatMpConfig | WechatPublicConfig;
|
|
style?: Style | null;
|
|
system: System.Schema;
|
|
token$application?: Array<Token.Schema>;
|
|
token$application$$aggr?: AggregationResult<Token.Schema>;
|
|
wechatQrCode$application?: Array<WechatQrCode.Schema>;
|
|
wechatQrCode$application$$aggr?: AggregationResult<WechatQrCode.Schema>;
|
|
wechatUser$application?: Array<WechatUser.Schema>;
|
|
wechatUser$application$$aggr?: AggregationResult<WechatUser.Schema>;
|
|
} & {
|
|
[A in ExpressionKey]?: any;
|
|
};
|
|
declare type AttrFilter = {
|
|
id: Q_StringValue | SubQuery.ApplicationIdSubQuery;
|
|
$$createAt$$: Q_DateValue;
|
|
$$seq$$: Q_StringValue;
|
|
$$updateAt$$: Q_DateValue;
|
|
name: Q_StringValue;
|
|
description: Q_StringValue;
|
|
type: Q_EnumValue<AppType>;
|
|
systemId: Q_StringValue | SubQuery.SystemIdSubQuery;
|
|
system: System.Filter;
|
|
style: Q_EnumValue<Style>;
|
|
};
|
|
export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
|
export declare type Projection = {
|
|
"#id"?: NodeId;
|
|
[k: string]: any;
|
|
id?: number;
|
|
$$createAt$$?: number;
|
|
$$updateAt$$?: number;
|
|
$$seq$$?: number;
|
|
name?: number;
|
|
description?: number;
|
|
type?: number;
|
|
systemId?: number;
|
|
system?: System.Projection;
|
|
config?: number;
|
|
style?: number;
|
|
token$application?: Token.Selection & {
|
|
$entity: "token";
|
|
};
|
|
token$application$$aggr?: Token.Aggregation & {
|
|
$entity: "token";
|
|
};
|
|
wechatQrCode$application?: WechatQrCode.Selection & {
|
|
$entity: "wechatQrCode";
|
|
};
|
|
wechatQrCode$application$$aggr?: WechatQrCode.Aggregation & {
|
|
$entity: "wechatQrCode";
|
|
};
|
|
wechatUser$application?: WechatUser.Selection & {
|
|
$entity: "wechatUser";
|
|
};
|
|
wechatUser$application$$aggr?: WechatUser.Aggregation & {
|
|
$entity: "wechatUser";
|
|
};
|
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
declare type ApplicationIdProjection = OneOf<{
|
|
id: number;
|
|
}>;
|
|
declare type SystemIdProjection = OneOf<{
|
|
systemId: number;
|
|
}>;
|
|
export declare type SortAttr = {
|
|
id: number;
|
|
} | {
|
|
$$createAt$$: number;
|
|
} | {
|
|
$$seq$$: number;
|
|
} | {
|
|
$$updateAt$$: number;
|
|
} | {
|
|
name: number;
|
|
} | {
|
|
description: number;
|
|
} | {
|
|
type: number;
|
|
} | {
|
|
systemId: number;
|
|
} | {
|
|
system: System.SortAttr;
|
|
} | {
|
|
style: number;
|
|
} | {
|
|
[k: string]: any;
|
|
} | OneOf<ExprOp<OpAttr | string>>;
|
|
export declare type SortNode = {
|
|
$attr: SortAttr;
|
|
$direction?: "asc" | "desc";
|
|
};
|
|
export declare type Sorter = SortNode[];
|
|
export declare type SelectOperation<P extends Object = Projection> = Omit<OakOperation<"select", P, Filter, Sorter>, "id">;
|
|
export declare type Selection<P extends Object = Projection> = Omit<SelectOperation<P>, "action">;
|
|
export declare type Aggregation = Omit<DeduceAggregation<Schema, Projection, Filter, Sorter>, "id">;
|
|
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "systemId">> & (({
|
|
systemId?: never;
|
|
system: System.CreateSingleOperation;
|
|
} | {
|
|
systemId: String<64>;
|
|
system?: System.UpdateOperation;
|
|
} | {
|
|
systemId: String<64>;
|
|
})) & {
|
|
token$application?: OakOperation<Token.UpdateOperation["action"], Omit<Token.UpdateOperationData, "application" | "applicationId">, Token.Filter> | OakOperation<"create", Omit<Token.CreateOperationData, "application" | "applicationId">[]> | Array<OakOperation<"create", Omit<Token.CreateOperationData, "application" | "applicationId">> | OakOperation<Token.UpdateOperation["action"], Omit<Token.UpdateOperationData, "application" | "applicationId">, Token.Filter>>;
|
|
wechatQrCode$application?: OakOperation<WechatQrCode.UpdateOperation["action"], Omit<WechatQrCode.UpdateOperationData, "application" | "applicationId">, WechatQrCode.Filter> | OakOperation<"create", Omit<WechatQrCode.CreateOperationData, "application" | "applicationId">[]> | Array<OakOperation<"create", Omit<WechatQrCode.CreateOperationData, "application" | "applicationId">> | OakOperation<WechatQrCode.UpdateOperation["action"], Omit<WechatQrCode.UpdateOperationData, "application" | "applicationId">, WechatQrCode.Filter>>;
|
|
wechatUser$application?: OakOperation<WechatUser.UpdateOperation["action"], Omit<WechatUser.UpdateOperationData, "application" | "applicationId">, WechatUser.Filter> | OakOperation<"create", Omit<WechatUser.CreateOperationData, "application" | "applicationId">[]> | Array<OakOperation<"create", Omit<WechatUser.CreateOperationData, "application" | "applicationId">> | OakOperation<WechatUser.UpdateOperation["action"], Omit<WechatUser.UpdateOperationData, "application" | "applicationId">, WechatUser.Filter>>;
|
|
};
|
|
export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
|
|
export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
|
|
export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
|
|
export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "systemId">> & (({
|
|
system: System.CreateSingleOperation;
|
|
systemId?: never;
|
|
} | {
|
|
system: System.UpdateOperation;
|
|
systemId?: never;
|
|
} | {
|
|
system: System.RemoveOperation;
|
|
systemId?: never;
|
|
} | {
|
|
system?: never;
|
|
systemId?: String<64> | null;
|
|
})) & {
|
|
[k: string]: any;
|
|
tokens$application?: Token.UpdateOperation | Token.RemoveOperation | OakOperation<"create", Omit<Token.CreateOperationData, "application" | "applicationId">[]> | Array<OakOperation<"create", Omit<Token.CreateOperationData, "application" | "applicationId">> | Token.UpdateOperation | Token.RemoveOperation>;
|
|
wechatQrCodes$application?: WechatQrCode.UpdateOperation | WechatQrCode.RemoveOperation | OakOperation<"create", Omit<WechatQrCode.CreateOperationData, "application" | "applicationId">[]> | Array<OakOperation<"create", Omit<WechatQrCode.CreateOperationData, "application" | "applicationId">> | WechatQrCode.UpdateOperation | WechatQrCode.RemoveOperation>;
|
|
wechatUsers$application?: WechatUser.UpdateOperation | WechatUser.RemoveOperation | OakOperation<"create", Omit<WechatUser.CreateOperationData, "application" | "applicationId">[]> | Array<OakOperation<"create", Omit<WechatUser.CreateOperationData, "application" | "applicationId">> | WechatUser.UpdateOperation | WechatUser.RemoveOperation>;
|
|
};
|
|
export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
|
|
export declare type RemoveOperationData = {} & (({
|
|
system?: System.UpdateOperation | System.RemoveOperation;
|
|
}));
|
|
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation | SelectOperation;
|
|
export declare type SystemIdSubQuery = Selection<SystemIdProjection>;
|
|
export declare type ApplicationIdSubQuery = Selection<ApplicationIdProjection>;
|
|
export declare type NativeAttr = OpAttr | `system.${System.NativeAttr}`;
|
|
export declare type FullAttr = NativeAttr | `tokens$${number}.${Token.NativeAttr}` | `wechatQrCodes$${number}.${WechatQrCode.NativeAttr}` | `wechatUsers$${number}.${WechatUser.NativeAttr}`;
|
|
export declare 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 {};
|