158 lines
4.9 KiB
TypeScript
158 lines
4.9 KiB
TypeScript
import { String, Boolean, Text, Datetime, PrimaryKey, ForeignKey } from "oak-domain/lib/types/DataType";
|
|
import { Q_DateValue, Q_BooleanValue, Q_StringValue, 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, Operation as OakOperation, MakeAction as OakMakeAction } from "oak-domain/lib/types/Entity";
|
|
import { GenericAction } from "oak-domain/lib/actions/action";
|
|
import * as Area from "../Area/Schema";
|
|
export declare type OpSchema = {
|
|
id: PrimaryKey;
|
|
$$createAt$$: Datetime;
|
|
$$updateAt$$: Datetime;
|
|
$$deleteAt$$?: Datetime | null;
|
|
detail: String<32>;
|
|
areaId: ForeignKey<"area">;
|
|
phone: String<12>;
|
|
name: String<32>;
|
|
default: Boolean;
|
|
remark: Text;
|
|
};
|
|
export declare type OpAttr = keyof OpSchema;
|
|
export declare type Schema = {
|
|
id: PrimaryKey;
|
|
$$createAt$$: Datetime;
|
|
$$updateAt$$: Datetime;
|
|
$$deleteAt$$?: Datetime | null;
|
|
detail: String<32>;
|
|
areaId: ForeignKey<"area">;
|
|
phone: String<12>;
|
|
name: String<32>;
|
|
default: Boolean;
|
|
remark: Text;
|
|
area: Area.Schema;
|
|
} & {
|
|
[A in ExpressionKey]?: any;
|
|
};
|
|
declare type AttrFilter = {
|
|
id: Q_StringValue | SubQuery.AddressIdSubQuery;
|
|
$$createAt$$: Q_DateValue;
|
|
$$updateAt$$: Q_DateValue;
|
|
detail: Q_StringValue;
|
|
areaId: Q_StringValue | SubQuery.AreaIdSubQuery;
|
|
area: Area.Filter;
|
|
phone: Q_StringValue;
|
|
name: Q_StringValue;
|
|
default: Q_BooleanValue;
|
|
remark: Q_StringValue;
|
|
};
|
|
export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
|
export declare type Projection = {
|
|
"#id"?: NodeId;
|
|
[k: string]: any;
|
|
id: 1;
|
|
$$createAt$$?: 1;
|
|
$$updateAt$$?: 1;
|
|
detail?: 1;
|
|
areaId?: 1;
|
|
area?: Area.Projection;
|
|
phone?: 1;
|
|
name?: 1;
|
|
default?: 1;
|
|
remark?: 1;
|
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
export declare type ExportProjection = {
|
|
"#id"?: NodeId;
|
|
[k: string]: any;
|
|
id?: string;
|
|
$$createAt$$?: string;
|
|
$$updateAt$$?: string;
|
|
detail?: string;
|
|
areaId?: string;
|
|
area?: Area.ExportProjection;
|
|
phone?: string;
|
|
name?: string;
|
|
default?: string;
|
|
remark?: string;
|
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
declare type AddressIdProjection = OneOf<{
|
|
id: 1;
|
|
}>;
|
|
declare type AreaIdProjection = OneOf<{
|
|
areaId: 1;
|
|
}>;
|
|
export declare type SortAttr = {
|
|
id: 1;
|
|
} | {
|
|
$$createAt$$: 1;
|
|
} | {
|
|
$$updateAt$$: 1;
|
|
} | {
|
|
detail: 1;
|
|
} | {
|
|
areaId: 1;
|
|
} | {
|
|
area: Area.SortAttr;
|
|
} | {
|
|
phone: 1;
|
|
} | {
|
|
name: 1;
|
|
} | {
|
|
default: 1;
|
|
} | {
|
|
remark: 1;
|
|
} | {
|
|
[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 = Projection> = Omit<OakOperation<"select", P, Filter, Sorter>, "id">;
|
|
export declare type Selection<P = Projection> = Omit<SelectOperation<P>, "action">;
|
|
export declare type Exportation = OakOperation<"export", ExportProjection, Filter, Sorter>;
|
|
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "areaId">> & (({
|
|
areaId?: never | null;
|
|
area: Area.CreateSingleOperation;
|
|
} | {
|
|
areaId: String<64>;
|
|
area?: Area.UpdateOperation;
|
|
}));
|
|
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, "areaId">> & (({
|
|
area?: Area.CreateSingleOperation | Area.UpdateOperation | Area.RemoveOperation;
|
|
areaId?: undefined;
|
|
} | {
|
|
area?: undefined;
|
|
areaId?: String<64> | null;
|
|
})) & {
|
|
[k: string]: any;
|
|
};
|
|
export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
|
|
export declare type RemoveOperationData = {} & (({
|
|
area?: Area.UpdateOperation;
|
|
} | {
|
|
area?: Area.RemoveOperation;
|
|
}));
|
|
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation | SelectOperation;
|
|
export declare type AreaIdSubQuery = Selection<AreaIdProjection>;
|
|
export declare type AddressIdSubQuery = Selection<AddressIdProjection>;
|
|
export declare type NativeAttr = OpAttr | `area.${Area.NativeAttr}`;
|
|
export declare type FullAttr = NativeAttr;
|
|
export declare type EntityDef = {
|
|
Schema: Schema;
|
|
OpSchema: OpSchema;
|
|
Action: OakMakeAction<GenericAction> | string;
|
|
Selection: Selection;
|
|
Operation: Operation;
|
|
Create: CreateOperation;
|
|
Update: UpdateOperation;
|
|
Remove: RemoveOperation;
|
|
CreateSingle: CreateSingleOperation;
|
|
CreateMulti: CreateMultipleOperation;
|
|
};
|
|
export {};
|