141 lines
6.1 KiB
TypeScript
141 lines
6.1 KiB
TypeScript
import { ForeignKey } from "oak-domain/lib/types/DataType";
|
|
import { Q_DateValue, Q_NumberValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey, 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 { String, Text } from "oak-domain/lib/types/DataType";
|
|
import * as ArticleMenu from "../ArticleMenu/Schema";
|
|
import * as ExtraFile from "../ExtraFile/Schema";
|
|
export type OpSchema = EntityShape & {
|
|
name: String<32>;
|
|
content: Text;
|
|
articleMenuId: ForeignKey<"articleMenu">;
|
|
};
|
|
export type OpAttr = keyof OpSchema;
|
|
export type Schema = EntityShape & {
|
|
name: String<32>;
|
|
content: Text;
|
|
articleMenuId: ForeignKey<"articleMenu">;
|
|
articleMenu: ArticleMenu.Schema;
|
|
extraFile$entity?: Array<ExtraFile.Schema>;
|
|
extraFile$entity$$aggr?: AggregationResult<ExtraFile.Schema>;
|
|
} & {
|
|
[A in ExpressionKey]?: any;
|
|
};
|
|
type AttrFilter = {
|
|
id: Q_StringValue;
|
|
$$createAt$$: Q_DateValue;
|
|
$$seq$$: Q_NumberValue;
|
|
$$updateAt$$: Q_DateValue;
|
|
name: Q_StringValue;
|
|
content: Q_StringValue;
|
|
articleMenuId: Q_StringValue;
|
|
articleMenu: ArticleMenu.Filter;
|
|
extraFile$entity: ExtraFile.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;
|
|
name?: number;
|
|
content?: number;
|
|
articleMenuId?: number;
|
|
articleMenu?: ArticleMenu.Projection;
|
|
extraFile$entity?: ExtraFile.Selection & {
|
|
$entity: "extraFile";
|
|
};
|
|
extraFile$entity$$aggr?: ExtraFile.Aggregation & {
|
|
$entity: "extraFile";
|
|
};
|
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
type ArticleIdProjection = OneOf<{
|
|
id: number;
|
|
}>;
|
|
type ArticleMenuIdProjection = OneOf<{
|
|
articleMenuId: number;
|
|
}>;
|
|
export type SortAttr = {
|
|
id: number;
|
|
} | {
|
|
$$createAt$$: number;
|
|
} | {
|
|
$$seq$$: number;
|
|
} | {
|
|
$$updateAt$$: number;
|
|
} | {
|
|
name: number;
|
|
} | {
|
|
content: number;
|
|
} | {
|
|
articleMenuId: number;
|
|
} | {
|
|
articleMenu: ArticleMenu.SortAttr;
|
|
} | {
|
|
[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, "articleMenuId">> & (({
|
|
articleMenuId?: never;
|
|
articleMenu: ArticleMenu.CreateSingleOperation;
|
|
} | {
|
|
articleMenuId: ForeignKey<"articleMenu">;
|
|
articleMenu?: ArticleMenu.UpdateOperation;
|
|
} | {
|
|
articleMenu?: never;
|
|
articleMenuId: ForeignKey<"articleMenu">;
|
|
})) & {
|
|
extraFile$entity?: OakOperation<ExtraFile.UpdateOperation["action"], Omit<ExtraFile.UpdateOperationData, "entity" | "entityId">, Omit<ExtraFile.Filter, "entity" | "entityId">> | OakOperation<"create", Omit<ExtraFile.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ExtraFile.CreateOperationData, "entity" | "entityId">> | OakOperation<ExtraFile.UpdateOperation["action"], Omit<ExtraFile.UpdateOperationData, "entity" | "entityId">, Omit<ExtraFile.Filter, "entity" | "entityId">>>;
|
|
};
|
|
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
|
|
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
|
|
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
|
|
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "articleMenuId">> & (({
|
|
articleMenu?: ArticleMenu.CreateSingleOperation;
|
|
articleMenuId?: never;
|
|
} | {
|
|
articleMenu?: ArticleMenu.UpdateOperation;
|
|
articleMenuId?: never;
|
|
} | {
|
|
articleMenu?: ArticleMenu.RemoveOperation;
|
|
articleMenuId?: never;
|
|
} | {
|
|
articleMenu?: never;
|
|
articleMenuId?: ForeignKey<"articleMenu">;
|
|
})) & {
|
|
[k: string]: any;
|
|
extraFile$entity?: OakOperation<ExtraFile.UpdateOperation["action"], Omit<ExtraFile.UpdateOperationData, "entity" | "entityId">, Omit<ExtraFile.Filter, "entity" | "entityId">> | OakOperation<ExtraFile.RemoveOperation["action"], Omit<ExtraFile.RemoveOperationData, "entity" | "entityId">, Omit<ExtraFile.Filter, "entity" | "entityId">> | OakOperation<"create", Omit<ExtraFile.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ExtraFile.CreateOperationData, "entity" | "entityId">> | OakOperation<ExtraFile.UpdateOperation["action"], Omit<ExtraFile.UpdateOperationData, "entity" | "entityId">, Omit<ExtraFile.Filter, "entity" | "entityId">> | OakOperation<ExtraFile.RemoveOperation["action"], Omit<ExtraFile.RemoveOperationData, "entity" | "entityId">, Omit<ExtraFile.Filter, "entity" | "entityId">>>;
|
|
};
|
|
export type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
|
|
export type RemoveOperationData = {} & (({
|
|
articleMenu?: ArticleMenu.UpdateOperation | ArticleMenu.RemoveOperation;
|
|
}));
|
|
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
|
export type ArticleMenuIdSubQuery = Selection<ArticleMenuIdProjection>;
|
|
export type ArticleIdSubQuery = Selection<ArticleIdProjection>;
|
|
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 {};
|