oak-domain/lib/base-app-domain/ModiEntity/Schema.d.ts

163 lines
5.1 KiB
TypeScript

import { String, ForeignKey } from "../../types/DataType";
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
import { OneOf } from "../../types/Polyfill";
import * as SubQuery from "../_SubQuery";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
import { AppendOnlyAction } from "../../actions/action";
import * as Modi from "../Modi/Schema";
import * as User from "../User/Schema";
export declare type OpSchema = EntityShape & {
modiId: ForeignKey<"modi">;
entity: "user" | string;
entityId: String<64>;
};
export declare type OpAttr = keyof OpSchema;
export declare type Schema = EntityShape & {
modiId: ForeignKey<"modi">;
entity: "user" | string;
entityId: String<64>;
modi: Modi.Schema;
user?: User.Schema;
} & {
[A in ExpressionKey]?: any;
};
declare type AttrFilter<E> = {
id: Q_StringValue | SubQuery.ModiEntityIdSubQuery;
$$createAt$$: Q_DateValue;
$$seq$$: Q_StringValue;
$$updateAt$$: Q_DateValue;
modiId: Q_StringValue | SubQuery.ModiIdSubQuery;
modi: Modi.Filter;
entity: E;
entityId: Q_StringValue;
user: User.Filter;
};
export declare type Filter<E = Q_EnumValue<"user" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>;
export declare type Projection = {
"#id"?: NodeId;
[k: string]: any;
id?: number;
$$createAt$$?: number;
$$updateAt$$?: number;
$$seq$$?: number;
modiId?: number;
modi?: Modi.Projection;
entity?: number;
entityId?: number;
user?: User.Projection;
} & Partial<ExprOp<OpAttr | string>>;
declare type ModiEntityIdProjection = OneOf<{
id: number;
}>;
declare type ModiIdProjection = OneOf<{
modiId: number;
}>;
declare type UserIdProjection = OneOf<{
entityId: number;
}>;
export declare type SortAttr = {
id: number;
} | {
$$createAt$$: number;
} | {
$$seq$$: number;
} | {
$$updateAt$$: number;
} | {
modiId: number;
} | {
modi: Modi.SortAttr;
} | {
entity: number;
} | {
entityId: number;
} | {
user: User.SortAttr;
} | {
[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> = Omit<SelectOperation<P>, "action">;
export declare type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "entityId" | "modiId">> & (({
modiId?: never;
modi: Modi.CreateSingleOperation;
} | {
modiId: String<64>;
modi?: Modi.UpdateOperation;
} | {
modiId: String<64>;
})) & ({
entity?: never;
entityId?: never;
user: User.CreateSingleOperation;
} | {
entity: "user";
entityId: String<64>;
user: User.UpdateOperation;
} | {
entity: "user";
entityId: String<64>;
} | {
entity?: string;
entityId?: string;
[K: string]: any;
});
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, "entity" | "entityId" | "modiId">> & (({
modi: Modi.CreateSingleOperation;
modiId?: never;
} | {
modi: Modi.UpdateOperation;
modiId?: never;
} | {
modi: Modi.RemoveOperation;
modiId?: never;
} | {
modi?: never;
modiId?: String<64> | null;
})) & ({
user?: User.CreateSingleOperation | User.UpdateOperation | User.RemoveOperation;
entityId?: never;
entity?: never;
} | {
entity?: ("user" | string) | null;
entityId?: String<64> | null;
}) & {
[k: string]: any;
};
export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {} & (({
modi?: Modi.UpdateOperation | Modi.RemoveOperation;
})) & ({
user?: User.UpdateOperation | User.RemoveOperation;
} | {
[k: string]: any;
});
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation;
export declare type ModiIdSubQuery = Selection<ModiIdProjection>;
export declare type UserIdSubQuery = Selection<UserIdProjection>;
export declare type ModiEntityIdSubQuery = Selection<ModiEntityIdProjection>;
export declare type EntityDef = {
Schema: Schema;
OpSchema: OpSchema;
Action: OakMakeAction<AppendOnlyAction> | string;
Selection: Selection;
Aggregation: Aggregation;
Operation: Operation;
Create: CreateOperation;
Update: UpdateOperation;
Remove: RemoveOperation;
CreateSingle: CreateSingleOperation;
CreateMulti: CreateMultipleOperation;
};
export {};