273 lines
10 KiB
TypeScript
273 lines
10 KiB
TypeScript
import { String, Boolean, Datetime, Image, ForeignKey } from "oak-domain/lib/types/DataType";
|
|
import { Q_DateValue, Q_BooleanValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } 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, EntityShape, AggregationResult } from "oak-domain/lib/types/Entity";
|
|
import { GenericAction } from "oak-domain/lib/actions/action";
|
|
import * as User from "../User/Schema";
|
|
import * as Application from "../Application/Schema";
|
|
import * as ModiEntity from "../ModiEntity/Schema";
|
|
import * as OperEntity from "../OperEntity/Schema";
|
|
import * as Token from "../Token/Schema";
|
|
export declare type OpSchema = EntityShape & {
|
|
origin: 'mp' | 'public' | 'web';
|
|
openId?: String<32> | null;
|
|
unionId?: String<32> | null;
|
|
sessionKey?: String<64> | null;
|
|
accessToken?: String<128> | null;
|
|
refreshToken?: String<128> | null;
|
|
scope?: String<64> | null;
|
|
atExpiredAt?: Datetime | null;
|
|
rtExpiredAt?: Datetime | null;
|
|
subscribed?: Boolean | null;
|
|
subscribedAt?: Datetime | null;
|
|
unsubscribedAt?: Datetime | null;
|
|
userId?: ForeignKey<"user"> | null;
|
|
applicationId: ForeignKey<"application">;
|
|
nickname?: String<128> | null;
|
|
avatar?: Image | null;
|
|
};
|
|
export declare type OpAttr = keyof OpSchema;
|
|
export declare type Schema = EntityShape & {
|
|
origin: 'mp' | 'public' | 'web';
|
|
openId?: String<32> | null;
|
|
unionId?: String<32> | null;
|
|
sessionKey?: String<64> | null;
|
|
accessToken?: String<128> | null;
|
|
refreshToken?: String<128> | null;
|
|
scope?: String<64> | null;
|
|
atExpiredAt?: Datetime | null;
|
|
rtExpiredAt?: Datetime | null;
|
|
subscribed?: Boolean | null;
|
|
subscribedAt?: Datetime | null;
|
|
unsubscribedAt?: Datetime | null;
|
|
userId?: ForeignKey<"user"> | null;
|
|
applicationId: ForeignKey<"application">;
|
|
nickname?: String<128> | null;
|
|
avatar?: Image | null;
|
|
user?: User.Schema | null;
|
|
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>;
|
|
token$entity?: Array<Token.Schema>;
|
|
token$entity$$aggr?: AggregationResult<Token.Schema>;
|
|
} & {
|
|
[A in ExpressionKey]?: any;
|
|
};
|
|
declare type AttrFilter = {
|
|
id: Q_StringValue;
|
|
$$createAt$$: Q_DateValue;
|
|
$$seq$$: Q_StringValue;
|
|
$$updateAt$$: Q_DateValue;
|
|
origin: Q_EnumValue<'mp' | 'public' | 'web'>;
|
|
openId: Q_StringValue;
|
|
unionId: Q_StringValue;
|
|
sessionKey: Q_StringValue;
|
|
accessToken: Q_StringValue;
|
|
refreshToken: Q_StringValue;
|
|
scope: Q_StringValue;
|
|
atExpiredAt: Q_DateValue;
|
|
rtExpiredAt: Q_DateValue;
|
|
subscribed: Q_BooleanValue;
|
|
subscribedAt: Q_DateValue;
|
|
unsubscribedAt: Q_DateValue;
|
|
userId: Q_StringValue;
|
|
user: User.Filter;
|
|
applicationId: Q_StringValue;
|
|
application: Application.Filter;
|
|
nickname: Q_StringValue;
|
|
avatar: Q_StringValue;
|
|
modiEntity$entity: ModiEntity.Filter;
|
|
operEntity$entity: OperEntity.Filter;
|
|
token$entity: Token.Filter;
|
|
};
|
|
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;
|
|
origin?: number;
|
|
openId?: number;
|
|
unionId?: number;
|
|
sessionKey?: number;
|
|
accessToken?: number;
|
|
refreshToken?: number;
|
|
scope?: number;
|
|
atExpiredAt?: number;
|
|
rtExpiredAt?: number;
|
|
subscribed?: number;
|
|
subscribedAt?: number;
|
|
unsubscribedAt?: number;
|
|
userId?: number;
|
|
user?: User.Projection;
|
|
applicationId?: number;
|
|
application?: Application.Projection;
|
|
nickname?: number;
|
|
avatar?: 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";
|
|
};
|
|
token$entity?: Token.Selection & {
|
|
$entity: "token";
|
|
};
|
|
token$entity$$aggr?: Token.Aggregation & {
|
|
$entity: "token";
|
|
};
|
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
declare type WechatUserIdProjection = OneOf<{
|
|
id: number;
|
|
}>;
|
|
declare type UserIdProjection = OneOf<{
|
|
userId: number;
|
|
}>;
|
|
declare type ApplicationIdProjection = OneOf<{
|
|
applicationId: number;
|
|
}>;
|
|
export declare type SortAttr = {
|
|
id: number;
|
|
} | {
|
|
$$createAt$$: number;
|
|
} | {
|
|
$$seq$$: number;
|
|
} | {
|
|
$$updateAt$$: number;
|
|
} | {
|
|
origin: number;
|
|
} | {
|
|
openId: number;
|
|
} | {
|
|
unionId: number;
|
|
} | {
|
|
sessionKey: number;
|
|
} | {
|
|
accessToken: number;
|
|
} | {
|
|
refreshToken: number;
|
|
} | {
|
|
scope: number;
|
|
} | {
|
|
atExpiredAt: number;
|
|
} | {
|
|
rtExpiredAt: number;
|
|
} | {
|
|
subscribed: number;
|
|
} | {
|
|
subscribedAt: number;
|
|
} | {
|
|
unsubscribedAt: number;
|
|
} | {
|
|
userId: number;
|
|
} | {
|
|
user: User.SortAttr;
|
|
} | {
|
|
applicationId: number;
|
|
} | {
|
|
application: Application.SortAttr;
|
|
} | {
|
|
nickname: number;
|
|
} | {
|
|
avatar: 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> = OakSelection<"select", P, Filter, Sorter>;
|
|
export declare type Selection<P extends Object = Projection> = SelectOperation<P>;
|
|
export declare type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
|
|
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "userId" | "applicationId">> & (({
|
|
userId?: never;
|
|
user?: User.CreateSingleOperation;
|
|
} | {
|
|
userId: String<64>;
|
|
user?: User.UpdateOperation;
|
|
} | {
|
|
userId?: String<64>;
|
|
}) & ({
|
|
applicationId?: never;
|
|
application: Application.CreateSingleOperation;
|
|
} | {
|
|
applicationId: String<64>;
|
|
application?: Application.UpdateOperation;
|
|
} | {
|
|
applicationId: String<64>;
|
|
})) & {
|
|
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">>>;
|
|
token$entity?: OakOperation<Token.UpdateOperation["action"], Omit<Token.UpdateOperationData, "entity" | "entityId">, Omit<Token.Filter, "entity" | "entityId">> | OakOperation<"create", Omit<Token.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<Token.CreateOperationData, "entity" | "entityId">> | OakOperation<Token.UpdateOperation["action"], Omit<Token.UpdateOperationData, "entity" | "entityId">, Omit<Token.Filter, "entity" | "entityId">>>;
|
|
};
|
|
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, "userId" | "applicationId">> & (({
|
|
user: User.CreateSingleOperation;
|
|
userId?: never;
|
|
} | {
|
|
user: User.UpdateOperation;
|
|
userId?: never;
|
|
} | {
|
|
user: User.RemoveOperation;
|
|
userId?: never;
|
|
} | {
|
|
user?: never;
|
|
userId?: String<64> | null;
|
|
}) & ({
|
|
application: Application.CreateSingleOperation;
|
|
applicationId?: never;
|
|
} | {
|
|
application: Application.UpdateOperation;
|
|
applicationId?: never;
|
|
} | {
|
|
application: Application.RemoveOperation;
|
|
applicationId?: never;
|
|
} | {
|
|
application?: never;
|
|
applicationId?: String<64> | null;
|
|
})) & {
|
|
[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">>>;
|
|
token$entity?: OakOperation<Token.UpdateOperation["action"], Omit<Token.UpdateOperationData, "entity" | "entityId">, Omit<Token.Filter, "entity" | "entityId">> | OakOperation<Token.RemoveOperation["action"], Omit<Token.RemoveOperationData, "entity" | "entityId">, Omit<Token.Filter, "entity" | "entityId">> | OakOperation<"create", Omit<Token.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<Token.CreateOperationData, "entity" | "entityId">> | OakOperation<Token.UpdateOperation["action"], Omit<Token.UpdateOperationData, "entity" | "entityId">, Omit<Token.Filter, "entity" | "entityId">> | OakOperation<Token.RemoveOperation["action"], Omit<Token.RemoveOperationData, "entity" | "entityId">, Omit<Token.Filter, "entity" | "entityId">>>;
|
|
};
|
|
export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
|
|
export declare type RemoveOperationData = {} & (({
|
|
user?: User.UpdateOperation | User.RemoveOperation;
|
|
}) & ({
|
|
application?: Application.UpdateOperation | Application.RemoveOperation;
|
|
}));
|
|
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
|
export declare type UserIdSubQuery = Selection<UserIdProjection>;
|
|
export declare type ApplicationIdSubQuery = Selection<ApplicationIdProjection>;
|
|
export declare type WechatUserIdSubQuery = Selection<WechatUserIdProjection>;
|
|
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 {};
|