还是恢复了oper和modi的entity指针

This commit is contained in:
Xu Chang 2023-03-30 19:29:23 +08:00
parent faabf34d12
commit 759f09dcae
16 changed files with 248 additions and 66 deletions

View File

@ -1,35 +1,41 @@
import { String, ForeignKey } from "../../types/DataType"; import { String, ForeignKey } from "../../types/DataType";
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand"; import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
import { OneOf } from "../../types/Polyfill"; import { OneOf } from "../../types/Polyfill";
import * as SubQuery from "../_SubQuery"; import * as SubQuery from "../_SubQuery";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity"; import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
import { AppendOnlyAction } from "../../actions/action"; import { AppendOnlyAction } from "../../actions/action";
import * as Modi from "../Modi/Schema"; import * as Modi from "../Modi/Schema";
import * as User from "../User/Schema";
import * as UserEntityGrant from "../UserEntityGrant/Schema";
export declare type OpSchema = EntityShape & { export declare type OpSchema = EntityShape & {
modiId: ForeignKey<"modi">; modiId: ForeignKey<"modi">;
entity: String<32>; entity: "user" | "userEntityGrant" | string;
entityId: String<64>; entityId: String<64>;
}; };
export declare type OpAttr = keyof OpSchema; export declare type OpAttr = keyof OpSchema;
export declare type Schema = EntityShape & { export declare type Schema = EntityShape & {
modiId: ForeignKey<"modi">; modiId: ForeignKey<"modi">;
entity: String<32>; entity: "user" | "userEntityGrant" | string;
entityId: String<64>; entityId: String<64>;
modi: Modi.Schema; modi: Modi.Schema;
user?: User.Schema;
userEntityGrant?: UserEntityGrant.Schema;
} & { } & {
[A in ExpressionKey]?: any; [A in ExpressionKey]?: any;
}; };
declare type AttrFilter = { declare type AttrFilter<E> = {
id: Q_StringValue | SubQuery.ModiEntityIdSubQuery; id: Q_StringValue | SubQuery.ModiEntityIdSubQuery;
$$createAt$$: Q_DateValue; $$createAt$$: Q_DateValue;
$$seq$$: Q_StringValue; $$seq$$: Q_StringValue;
$$updateAt$$: Q_DateValue; $$updateAt$$: Q_DateValue;
modiId: Q_StringValue | SubQuery.ModiIdSubQuery; modiId: Q_StringValue | SubQuery.ModiIdSubQuery;
modi: Modi.Filter; modi: Modi.Filter;
entity: Q_StringValue; entity: E;
entityId: Q_StringValue; entityId: Q_StringValue;
user: User.Filter;
userEntityGrant: UserEntityGrant.Filter;
}; };
export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>; export declare type Filter<E = Q_EnumValue<"user" | "userEntityGrant" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>;
export declare type Projection = { export declare type Projection = {
"#id"?: NodeId; "#id"?: NodeId;
[k: string]: any; [k: string]: any;
@ -41,6 +47,8 @@ export declare type Projection = {
modi?: Modi.Projection; modi?: Modi.Projection;
entity?: number; entity?: number;
entityId?: number; entityId?: number;
user?: User.Projection;
userEntityGrant?: UserEntityGrant.Projection;
} & Partial<ExprOp<OpAttr | string>>; } & Partial<ExprOp<OpAttr | string>>;
declare type ModiEntityIdProjection = OneOf<{ declare type ModiEntityIdProjection = OneOf<{
id: number; id: number;
@ -48,6 +56,12 @@ declare type ModiEntityIdProjection = OneOf<{
declare type ModiIdProjection = OneOf<{ declare type ModiIdProjection = OneOf<{
modiId: number; modiId: number;
}>; }>;
declare type UserIdProjection = OneOf<{
entityId: number;
}>;
declare type UserEntityGrantIdProjection = OneOf<{
entityId: number;
}>;
export declare type SortAttr = { export declare type SortAttr = {
id: number; id: number;
} | { } | {
@ -64,6 +78,10 @@ export declare type SortAttr = {
entity: number; entity: number;
} | { } | {
entityId: number; entityId: number;
} | {
user: User.SortAttr;
} | {
userEntityGrant: UserEntityGrant.SortAttr;
} | { } | {
[k: string]: any; [k: string]: any;
} | OneOf<ExprOp<OpAttr | string>>; } | OneOf<ExprOp<OpAttr | string>>;
@ -84,6 +102,28 @@ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity"
} | { } | {
modiId: String<64>; modiId: String<64>;
})) & ({ })) & ({
entity?: never;
entityId?: never;
user: User.CreateSingleOperation;
} | {
entity: "user";
entityId: String<64>;
user: User.UpdateOperation;
} | {
entity: "user";
entityId: String<64>;
} | {
entity?: never;
entityId?: never;
userEntityGrant: UserEntityGrant.CreateSingleOperation;
} | {
entity: "userEntityGrant";
entityId: String<64>;
userEntityGrant: UserEntityGrant.UpdateOperation;
} | {
entity: "userEntityGrant";
entityId: String<64>;
} | {
entity?: string; entity?: string;
entityId?: string; entityId?: string;
[K: string]: any; [K: string]: any;
@ -91,7 +131,7 @@ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity"
export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>; export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>; export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation; export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "modiId">> & (({ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity" | "entityId" | "modiId">> & (({
modi: Modi.CreateSingleOperation; modi: Modi.CreateSingleOperation;
modiId?: never; modiId?: never;
} | { } | {
@ -103,16 +143,35 @@ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "modiId"
} | { } | {
modi?: never; modi?: never;
modiId?: String<64> | null; modiId?: String<64> | null;
})) & { })) & ({
user?: User.CreateSingleOperation | User.UpdateOperation | User.RemoveOperation;
entityId?: never;
entity?: never;
} | {
userEntityGrant?: UserEntityGrant.CreateSingleOperation | UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation;
entityId?: never;
entity?: never;
} | {
entity?: ("user" | "userEntityGrant" | string) | null;
entityId?: String<64> | null;
}) & {
[k: string]: any; [k: string]: any;
}; };
export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>; export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {} & (({ export declare type RemoveOperationData = {} & (({
modi?: Modi.UpdateOperation | Modi.RemoveOperation; modi?: Modi.UpdateOperation | Modi.RemoveOperation;
})); })) & ({
user?: User.UpdateOperation | User.RemoveOperation;
} | {
userEntityGrant?: UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation;
} | {
[k: string]: any;
});
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>; export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation; export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation;
export declare type ModiIdSubQuery = Selection<ModiIdProjection>; export declare type ModiIdSubQuery = Selection<ModiIdProjection>;
export declare type UserIdSubQuery = Selection<UserIdProjection>;
export declare type UserEntityGrantIdSubQuery = Selection<UserEntityGrantIdProjection>;
export declare type ModiEntityIdSubQuery = Selection<ModiEntityIdProjection>; export declare type ModiEntityIdSubQuery = Selection<ModiEntityIdProjection>;
export declare type EntityDef = { export declare type EntityDef = {
Schema: Schema; Schema: Schema;

View File

@ -12,7 +12,8 @@ exports.desc = {
type: "varchar", type: "varchar",
params: { params: {
length: 32 length: 32
} },
ref: ["user", "userEntityGrant"]
}, },
entityId: { entityId: {
type: "varchar", type: "varchar",

View File

@ -1,32 +1,41 @@
import { String, ForeignKey } from "../../types/DataType"; import { String, ForeignKey } from "../../types/DataType";
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand"; import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
import { OneOf } from "../../types/Polyfill"; import { OneOf } from "../../types/Polyfill";
import * as SubQuery from "../_SubQuery"; import * as SubQuery from "../_SubQuery";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity"; import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
import { AppendOnlyAction } from "../../actions/action"; import { AppendOnlyAction } from "../../actions/action";
import * as Oper from "../Oper/Schema"; import * as Oper from "../Oper/Schema";
import * as User from "../User/Schema";
import * as UserEntityGrant from "../UserEntityGrant/Schema";
export declare type OpSchema = EntityShape & { export declare type OpSchema = EntityShape & {
operId: ForeignKey<"oper">; operId: ForeignKey<"oper">;
targetEntityId: String<64>; entity: "user" | "userEntityGrant" | string;
entityId: String<64>;
}; };
export declare type OpAttr = keyof OpSchema; export declare type OpAttr = keyof OpSchema;
export declare type Schema = EntityShape & { export declare type Schema = EntityShape & {
operId: ForeignKey<"oper">; operId: ForeignKey<"oper">;
targetEntityId: String<64>; entity: "user" | "userEntityGrant" | string;
entityId: String<64>;
oper: Oper.Schema; oper: Oper.Schema;
user?: User.Schema;
userEntityGrant?: UserEntityGrant.Schema;
} & { } & {
[A in ExpressionKey]?: any; [A in ExpressionKey]?: any;
}; };
declare type AttrFilter = { declare type AttrFilter<E> = {
id: Q_StringValue | SubQuery.OperEntityIdSubQuery; id: Q_StringValue | SubQuery.OperEntityIdSubQuery;
$$createAt$$: Q_DateValue; $$createAt$$: Q_DateValue;
$$seq$$: Q_StringValue; $$seq$$: Q_StringValue;
$$updateAt$$: Q_DateValue; $$updateAt$$: Q_DateValue;
operId: Q_StringValue | SubQuery.OperIdSubQuery; operId: Q_StringValue | SubQuery.OperIdSubQuery;
oper: Oper.Filter; oper: Oper.Filter;
targetEntityId: Q_StringValue; entity: E;
entityId: Q_StringValue;
user: User.Filter;
userEntityGrant: UserEntityGrant.Filter;
}; };
export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>; export declare type Filter<E = Q_EnumValue<"user" | "userEntityGrant" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>;
export declare type Projection = { export declare type Projection = {
"#id"?: NodeId; "#id"?: NodeId;
[k: string]: any; [k: string]: any;
@ -36,7 +45,10 @@ export declare type Projection = {
$$seq$$?: number; $$seq$$?: number;
operId?: number; operId?: number;
oper?: Oper.Projection; oper?: Oper.Projection;
targetEntityId?: number; entity?: number;
entityId?: number;
user?: User.Projection;
userEntityGrant?: UserEntityGrant.Projection;
} & Partial<ExprOp<OpAttr | string>>; } & Partial<ExprOp<OpAttr | string>>;
declare type OperEntityIdProjection = OneOf<{ declare type OperEntityIdProjection = OneOf<{
id: number; id: number;
@ -44,6 +56,12 @@ declare type OperEntityIdProjection = OneOf<{
declare type OperIdProjection = OneOf<{ declare type OperIdProjection = OneOf<{
operId: number; operId: number;
}>; }>;
declare type UserIdProjection = OneOf<{
entityId: number;
}>;
declare type UserEntityGrantIdProjection = OneOf<{
entityId: number;
}>;
export declare type SortAttr = { export declare type SortAttr = {
id: number; id: number;
} | { } | {
@ -57,7 +75,13 @@ export declare type SortAttr = {
} | { } | {
oper: Oper.SortAttr; oper: Oper.SortAttr;
} | { } | {
targetEntityId: number; entity: number;
} | {
entityId: number;
} | {
user: User.SortAttr;
} | {
userEntityGrant: UserEntityGrant.SortAttr;
} | { } | {
[k: string]: any; [k: string]: any;
} | OneOf<ExprOp<OpAttr | string>>; } | OneOf<ExprOp<OpAttr | string>>;
@ -69,29 +93,74 @@ export declare type Sorter = SortNode[];
export declare type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>; 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 Selection<P extends Object = Projection> = Omit<SelectOperation<P>, "action">;
export declare type Aggregation = DeduceAggregation<Projection, Filter, Sorter>; export declare type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "operId">> & (({ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "entityId" | "operId">> & (({
operId?: never; operId?: never;
oper: Oper.CreateSingleOperation; oper: Oper.CreateSingleOperation;
} | { } | {
operId: String<64>; operId: String<64>;
})); })) & ({
entity?: never;
entityId?: never;
user: User.CreateSingleOperation;
} | {
entity: "user";
entityId: String<64>;
user: User.UpdateOperation;
} | {
entity: "user";
entityId: String<64>;
} | {
entity?: never;
entityId?: never;
userEntityGrant: UserEntityGrant.CreateSingleOperation;
} | {
entity: "userEntityGrant";
entityId: String<64>;
userEntityGrant: UserEntityGrant.UpdateOperation;
} | {
entity: "userEntityGrant";
entityId: String<64>;
} | {
entity?: string;
entityId?: string;
[K: string]: any;
});
export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>; export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>; export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation; export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "operId">> & (({ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity" | "entityId" | "operId">> & (({
oper: Oper.CreateSingleOperation; oper: Oper.CreateSingleOperation;
operId?: never; operId?: never;
} | { } | {
oper?: never; oper?: never;
operId?: String<64> | null; operId?: String<64> | null;
})) & { })) & ({
user?: User.CreateSingleOperation | User.UpdateOperation | User.RemoveOperation;
entityId?: never;
entity?: never;
} | {
userEntityGrant?: UserEntityGrant.CreateSingleOperation | UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation;
entityId?: never;
entity?: never;
} | {
entity?: ("user" | "userEntityGrant" | string) | null;
entityId?: String<64> | null;
}) & {
[k: string]: any; [k: string]: any;
}; };
export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>; export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {}; export declare type RemoveOperationData = {} & ({
user?: User.UpdateOperation | User.RemoveOperation;
} | {
userEntityGrant?: UserEntityGrant.UpdateOperation | UserEntityGrant.RemoveOperation;
} | {
[k: string]: any;
});
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>; export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation; export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation;
export declare type OperIdSubQuery = Selection<OperIdProjection>; export declare type OperIdSubQuery = Selection<OperIdProjection>;
export declare type UserIdSubQuery = Selection<UserIdProjection>;
export declare type UserEntityGrantIdSubQuery = Selection<UserEntityGrantIdProjection>;
export declare type OperEntityIdSubQuery = Selection<OperEntityIdProjection>; export declare type OperEntityIdSubQuery = Selection<OperEntityIdProjection>;
export declare type EntityDef = { export declare type EntityDef = {
Schema: Schema; Schema: Schema;

View File

@ -8,7 +8,14 @@ exports.desc = {
type: "ref", type: "ref",
ref: "oper" ref: "oper"
}, },
targetEntityId: { entity: {
type: "varchar",
params: {
length: 32
},
ref: ["user", "userEntityGrant"]
},
entityId: {
type: "varchar", type: "varchar",
params: { params: {
length: 64 length: 64

View File

@ -6,6 +6,8 @@ import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOper
import { Action, ParticularAction, UserState } from "./Action"; import { Action, ParticularAction, UserState } from "./Action";
import { RelationAction } from "../../actions/action"; import { RelationAction } from "../../actions/action";
import * as Oper from "../Oper/Schema"; import * as Oper from "../Oper/Schema";
import * as ModiEntity from "../ModiEntity/Schema";
import * as OperEntity from "../OperEntity/Schema";
export declare type OpSchema = EntityShape & { export declare type OpSchema = EntityShape & {
name?: String<16> | null; name?: String<16> | null;
nickname?: String<64> | null; nickname?: String<64> | null;
@ -25,6 +27,10 @@ export declare type Schema = EntityShape & {
oper$operator$$aggr?: AggregationResult<Oper.Schema>; oper$operator$$aggr?: AggregationResult<Oper.Schema>;
user$ref?: Array<Schema>; user$ref?: Array<Schema>;
user$ref$$aggr?: AggregationResult<Schema>; user$ref$$aggr?: AggregationResult<Schema>;
modiEntity$entity?: Array<ModiEntity.Schema>;
modiEntity$entity$$aggr?: AggregationResult<ModiEntity.Schema>;
operEntity$entity?: Array<OperEntity.Schema>;
operEntity$entity$$aggr?: AggregationResult<OperEntity.Schema>;
} & { } & {
[A in ExpressionKey]?: any; [A in ExpressionKey]?: any;
}; };
@ -66,6 +72,18 @@ export declare type Projection = {
user$ref$$aggr?: Aggregation & { user$ref$$aggr?: Aggregation & {
$entity: "user"; $entity: "user";
}; };
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";
};
} & Partial<ExprOp<OpAttr | string>>; } & Partial<ExprOp<OpAttr | string>>;
declare type UserIdProjection = OneOf<{ declare type UserIdProjection = OneOf<{
id: number; id: number;
@ -113,6 +131,8 @@ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "refId">
})) & { })) & {
oper$operator?: OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">[]> | Array<OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">>>; oper$operator?: OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">[]> | Array<OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">>>;
user$ref?: OakOperation<UpdateOperation["action"], Omit<UpdateOperationData, "ref" | "refId">, Filter> | OakOperation<"create", Omit<CreateOperationData, "ref" | "refId">[]> | Array<OakOperation<"create", Omit<CreateOperationData, "ref" | "refId">> | OakOperation<UpdateOperation["action"], Omit<UpdateOperationData, "ref" | "refId">, Filter>>; user$ref?: OakOperation<UpdateOperation["action"], Omit<UpdateOperationData, "ref" | "refId">, Filter> | OakOperation<"create", Omit<CreateOperationData, "ref" | "refId">[]> | Array<OakOperation<"create", Omit<CreateOperationData, "ref" | "refId">> | OakOperation<UpdateOperation["action"], Omit<UpdateOperationData, "ref" | "refId">, Filter>>;
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">>>;
}; };
export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>; export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>; export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
@ -133,6 +153,8 @@ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "refId">
[k: string]: any; [k: string]: any;
oper$operator?: OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">[]> | Array<OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">>>; oper$operator?: OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">[]> | Array<OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">>>;
user$ref?: UpdateOperation | RemoveOperation | OakOperation<"create", Omit<CreateOperationData, "ref" | "refId">[]> | Array<OakOperation<"create", Omit<CreateOperationData, "ref" | "refId">> | UpdateOperation | RemoveOperation>; user$ref?: UpdateOperation | RemoveOperation | OakOperation<"create", Omit<CreateOperationData, "ref" | "refId">[]> | Array<OakOperation<"create", Omit<CreateOperationData, "ref" | "refId">> | UpdateOperation | RemoveOperation>;
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">>>;
}; };
export declare type UpdateOperation = OakOperation<"update" | ParticularAction | RelationAction | string, UpdateOperationData, Filter, Sorter>; export declare type UpdateOperation = OakOperation<"update" | ParticularAction | RelationAction | string, UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {} & (({ export declare type RemoveOperationData = {} & (({

View File

@ -2,8 +2,10 @@ import { String } from "../../types/DataType";
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand"; import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
import { OneOf } from "../../types/Polyfill"; import { OneOf } from "../../types/Polyfill";
import * as SubQuery from "../_SubQuery"; import * as SubQuery from "../_SubQuery";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity"; import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, EntityShape, AggregationResult } from "../../types/Entity";
import { GenericAction } from "../../actions/action"; import { GenericAction } from "../../actions/action";
import * as ModiEntity from "../ModiEntity/Schema";
import * as OperEntity from "../OperEntity/Schema";
export declare type OpSchema = EntityShape & { export declare type OpSchema = EntityShape & {
entity: String<32>; entity: String<32>;
entityId: String<64>; entityId: String<64>;
@ -14,6 +16,10 @@ export declare type Schema = EntityShape & {
entity: String<32>; entity: String<32>;
entityId: String<64>; entityId: String<64>;
relation: String<32>; relation: String<32>;
modiEntity$entity?: Array<ModiEntity.Schema>;
modiEntity$entity$$aggr?: AggregationResult<ModiEntity.Schema>;
operEntity$entity?: Array<OperEntity.Schema>;
operEntity$entity$$aggr?: AggregationResult<OperEntity.Schema>;
} & { } & {
[A in ExpressionKey]?: any; [A in ExpressionKey]?: any;
}; };
@ -37,6 +43,18 @@ export declare type Projection = {
entity?: number; entity?: number;
entityId?: number; entityId?: number;
relation?: number; relation?: 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";
};
} & Partial<ExprOp<OpAttr | string>>; } & Partial<ExprOp<OpAttr | string>>;
declare type UserEntityGrantIdProjection = OneOf<{ declare type UserEntityGrantIdProjection = OneOf<{
id: number; id: number;
@ -70,12 +88,17 @@ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity"
entity?: string; entity?: string;
entityId?: string; entityId?: string;
[K: string]: any; [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">>>;
};
export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>; export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>; export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation; export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export declare type UpdateOperationData = FormUpdateData<OpSchema> & { export declare type UpdateOperationData = FormUpdateData<OpSchema> & {
[k: string]: any; [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">>>;
}; };
export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>; export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {}; export declare type RemoveOperationData = {};

View File

@ -385,7 +385,7 @@ function analyzeEntity(filename, path, program, relativePath) {
// let relationHierarchy: ts.ObjectLiteralExpression | undefined = undefined; // let relationHierarchy: ts.ObjectLiteralExpression | undefined = undefined;
// let reverseCascadeRelationHierarchy: ts.ObjectLiteralExpression | undefined = undefined; // let reverseCascadeRelationHierarchy: ts.ObjectLiteralExpression | undefined = undefined;
ts.forEachChild(sourceFile, function (node) { ts.forEachChild(sourceFile, function (node) {
var _a, _b, _c; var _a, _b, _c, _d, _e;
if (ts.isImportDeclaration(node)) { if (ts.isImportDeclaration(node)) {
var entityImported = getEntityImported(node); var entityImported = getEntityImported(node);
if (entityImported) { if (entityImported) {
@ -535,29 +535,24 @@ function analyzeEntity(filename, path, program, relativePath) {
} }
beforeSchema = false; beforeSchema = false;
// 对于不是Modi和Oper的对象全部建立和ModiEntity的反指关系 // 对于不是Modi和Oper的对象全部建立和ModiEntity的反指关系
// 也不用再建立了,不可能有这样的查询操作 by Xc 20230330 if (!['Modi', 'Oper', 'OperEntity', 'ModiEntity'].includes(moduleName) && !toModi) {
/* if (!['Modi', 'Oper', 'OperEntity', 'ModiEntity'].includes(moduleName) && !toModi) {
if (ReversePointerRelations['ModiEntity'] && !ReversePointerRelations['ModiEntity'].includes(moduleName)) { if (ReversePointerRelations['ModiEntity'] && !ReversePointerRelations['ModiEntity'].includes(moduleName)) {
ReversePointerRelations['ModiEntity'].push(moduleName); ReversePointerRelations['ModiEntity'].push(moduleName);
} }
else { else {
assign(ReversePointerRelations, { (0, lodash_1.assign)(ReversePointerRelations, (_b = {},
['ModiEntity']: [moduleName], _b['ModiEntity'] = [moduleName],
}); _b));
} }
} */
// 对于不是Oper的对象全部建立和OperEntity的反指关系
// 不再建立了 by Xc 20230330
/* if (!['Oper', 'OperEntity', 'ModiEntity'].includes(moduleName)) {
if (ReversePointerRelations['OperEntity'] && !ReversePointerRelations['OperEntity'].includes(moduleName)) { if (ReversePointerRelations['OperEntity'] && !ReversePointerRelations['OperEntity'].includes(moduleName)) {
ReversePointerRelations['OperEntity'].push(moduleName); ReversePointerRelations['OperEntity'].push(moduleName);
} }
else { else {
assign(ReversePointerRelations, { (0, lodash_1.assign)(ReversePointerRelations, (_c = {},
['OperEntity']: [moduleName], _c['OperEntity'] = [moduleName],
}); _c));
} }
}*/ }
} }
else if (beforeSchema) { else if (beforeSchema) {
// 本地规定的一些形状定义,直接使用 // 本地规定的一些形状定义,直接使用
@ -609,8 +604,8 @@ function analyzeEntity(filename, path, program, relativePath) {
factory.createPropertySignature(undefined, factory.createIdentifier(entityLc), undefined, factory.createTypeReferenceNode(factory.createIdentifier(moduleName), undefined)), factory.createPropertySignature(undefined, factory.createIdentifier(entityLc), undefined, factory.createTypeReferenceNode(factory.createIdentifier(moduleName), undefined)),
factory.createPropertySignature(undefined, factory.createIdentifier('relation'), undefined, factory.createTypeReferenceNode(factory.createIdentifier("Relation"), undefined)), factory.createPropertySignature(undefined, factory.createIdentifier('relation'), undefined, factory.createTypeReferenceNode(factory.createIdentifier("Relation"), undefined)),
]; ];
(0, lodash_1.assign)(Schema, (_b = {}, (0, lodash_1.assign)(Schema, (_d = {},
_b[relationEntityName] = { _d[relationEntityName] = {
schemaAttrs: relationSchemaAttrs, schemaAttrs: relationSchemaAttrs,
sourceFile: sourceFile, sourceFile: sourceFile,
enumAttributes: { enumAttributes: {
@ -621,7 +616,7 @@ function analyzeEntity(filename, path, program, relativePath) {
factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, undefined, factory.createIdentifier("Relation"))])), factory.createStringLiteral("../".concat(moduleName, "/Schema")), undefined) factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, undefined, factory.createIdentifier("Relation"))])), factory.createStringLiteral("../".concat(moduleName, "/Schema")), undefined)
], ],
}, },
_b)); _d));
addRelationship(relationEntityName, 'User', 'user', true); addRelationship(relationEntityName, 'User', 'user', true);
addRelationship(relationEntityName, moduleName, entityLc, true); addRelationship(relationEntityName, moduleName, entityLc, true);
// 对UserEntityGrant对象建立相应的反指关系 // 对UserEntityGrant对象建立相应的反指关系
@ -631,9 +626,9 @@ function analyzeEntity(filename, path, program, relativePath) {
} }
} }
else { else {
(0, lodash_1.assign)(ReversePointerRelations, (_c = {}, (0, lodash_1.assign)(ReversePointerRelations, (_e = {},
_c['UserEntityGrant'] = [moduleName], _e['UserEntityGrant'] = [moduleName],
_c)); _e));
} }
hasRelationDef = node; hasRelationDef = node;
} }

View File

@ -3,5 +3,6 @@ import { EntityShape } from '../types/Entity';
import { Schema as Oper } from './Oper'; import { Schema as Oper } from './Oper';
export interface Schema extends EntityShape { export interface Schema extends EntityShape {
oper: Oper; oper: Oper;
targetEntityId: String<64>; entity: String<32>;
entityId: String<64>;
} }

View File

@ -9,7 +9,8 @@ var locale = {
name: '操作对象连接', name: '操作对象连接',
attr: { attr: {
oper: '操作', oper: '操作',
targetEntityId: '关联对象id', entity: '关联对象',
entityId: '关联对象id',
}, },
}, },
}; };

View File

@ -956,7 +956,8 @@ var CascadeStore = /** @class */ (function (_super) {
_a = {}; _a = {};
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()]; return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
case 1: return [2 /*return*/, (_a.id = _b.sent(), case 1: return [2 /*return*/, (_a.id = _b.sent(),
_a.targetEntityId = ele.id, _a.entityId = ele.id,
_a.entity = entity,
_a)]; _a)];
} }
}); });
@ -1138,7 +1139,8 @@ var CascadeStore = /** @class */ (function (_super) {
_a = {}; _a = {};
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()]; return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
case 1: return [2 /*return*/, (_a.id = _b.sent(), case 1: return [2 /*return*/, (_a.id = _b.sent(),
_a.targetEntityId = ele, _a.entityId = ele,
_a.entity = entity,
_a)]; _a)];
} }
}); });

View File

@ -13,6 +13,7 @@ declare type VaccumOption<ED extends EntityDict & BaseEntityDict> = {
}; };
/** /**
* *
*
* @param option * @param option
*/ */
export declare function vaccumEntities<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>>(option: VaccumOption<ED>, context: Cxt): Promise<void>; export declare function vaccumEntities<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>>(option: VaccumOption<ED>, context: Cxt): Promise<void>;

View File

@ -10,6 +10,7 @@ var stream_1 = require("stream");
var uuid_1 = require("../utils/uuid"); var uuid_1 = require("../utils/uuid");
/** /**
* 删除数据库中的部分数据减少体积 * 删除数据库中的部分数据减少体积
* 一般只删除日志类数据
* @param option * @param option
*/ */
function vaccumEntities(option, context) { function vaccumEntities(option, context) {

View File

@ -730,8 +730,7 @@ function analyzeEntity(filename: string, path: string, program: ts.Program, rela
beforeSchema = false; beforeSchema = false;
// 对于不是Modi和Oper的对象全部建立和ModiEntity的反指关系 // 对于不是Modi和Oper的对象全部建立和ModiEntity的反指关系
// 也不用再建立了,不可能有这样的查询操作 by Xc 20230330 if (!['Modi', 'Oper', 'OperEntity', 'ModiEntity'].includes(moduleName) && !toModi) {
/* if (!['Modi', 'Oper', 'OperEntity', 'ModiEntity'].includes(moduleName) && !toModi) {
if (ReversePointerRelations['ModiEntity'] && !ReversePointerRelations['ModiEntity'].includes(moduleName)) { if (ReversePointerRelations['ModiEntity'] && !ReversePointerRelations['ModiEntity'].includes(moduleName)) {
ReversePointerRelations['ModiEntity'].push(moduleName); ReversePointerRelations['ModiEntity'].push(moduleName);
} }
@ -740,11 +739,7 @@ function analyzeEntity(filename: string, path: string, program: ts.Program, rela
['ModiEntity']: [moduleName], ['ModiEntity']: [moduleName],
}); });
} }
} */
// 对于不是Oper的对象全部建立和OperEntity的反指关系
// 不再建立了 by Xc 20230330
/* if (!['Oper', 'OperEntity', 'ModiEntity'].includes(moduleName)) {
if (ReversePointerRelations['OperEntity'] && !ReversePointerRelations['OperEntity'].includes(moduleName)) { if (ReversePointerRelations['OperEntity'] && !ReversePointerRelations['OperEntity'].includes(moduleName)) {
ReversePointerRelations['OperEntity'].push(moduleName); ReversePointerRelations['OperEntity'].push(moduleName);
} }
@ -752,8 +747,9 @@ function analyzeEntity(filename: string, path: string, program: ts.Program, rela
assign(ReversePointerRelations, { assign(ReversePointerRelations, {
['OperEntity']: [moduleName], ['OperEntity']: [moduleName],
}); });
} }
}*/ }
} }
else if (beforeSchema) { else if (beforeSchema) {
// 本地规定的一些形状定义,直接使用 // 本地规定的一些形状定义,直接使用
@ -5475,7 +5471,7 @@ function constructAttributes(entity: string): ts.PropertyAssignment[] {
factory.createArrayLiteralExpression( factory.createArrayLiteralExpression(
enumAttributes[(<ts.Identifier>name).text].map( enumAttributes[(<ts.Identifier>name).text].map(
ele => factory.createStringLiteral(ele) ele => factory.createStringLiteral(ele)
) )
) )
) )
); );
@ -5501,7 +5497,7 @@ function constructAttributes(entity: string): ts.PropertyAssignment[] {
if (ts.isUnionTypeNode(type!)) { if (ts.isUnionTypeNode(type!)) {
if (ts.isLiteralTypeNode(type.types[0])) { if (ts.isLiteralTypeNode(type.types[0])) {
if (ts.isStringLiteral(type.types[0].literal)) { if (ts.isStringLiteral(type.types[0].literal)) {
assert (enumAttributes && enumAttributes[(<ts.Identifier>name).text]); assert(enumAttributes && enumAttributes[(<ts.Identifier>name).text]);
attrAssignments.push( attrAssignments.push(
factory.createPropertyAssignment( factory.createPropertyAssignment(
'type', 'type',
@ -5512,7 +5508,7 @@ function constructAttributes(entity: string): ts.PropertyAssignment[] {
factory.createArrayLiteralExpression( factory.createArrayLiteralExpression(
enumAttributes[(<ts.Identifier>name).text].map( enumAttributes[(<ts.Identifier>name).text].map(
ele => factory.createStringLiteral(ele) ele => factory.createStringLiteral(ele)
) )
) )
) )
); );

View File

@ -5,7 +5,8 @@ import { Schema as Oper } from './Oper';
export interface Schema extends EntityShape { export interface Schema extends EntityShape {
oper: Oper, oper: Oper,
targetEntityId: String<64>; entity: String<32>;
entityId: String<64>;
}; };
const config: Configuration = { const config: Configuration = {
@ -17,7 +18,8 @@ const locale: LocaleDef<Schema, '', '', {}> = {
name: '操作对象连接', name: '操作对象连接',
attr: { attr: {
oper: '操作', oper: '操作',
targetEntityId: '关联对象id', entity: '关联对象',
entityId: '关联对象id',
}, },
}, },
}; };

View File

@ -1056,7 +1056,8 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
data.map( data.map(
async (ele) => ({ async (ele) => ({
id: await generateNewIdAsync(), id: await generateNewIdAsync(),
targetEntityId: ele.id, entityId: ele.id,
entity: entity as string,
}) })
) )
), ),
@ -1204,7 +1205,8 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
ids.map( ids.map(
async (ele) => ({ async (ele) => ({
id: await generateNewIdAsync(), id: await generateNewIdAsync(),
targetEntityId: ele, entityId: ele,
entity: entity as string,
}) })
) )
) )

View File

@ -1,6 +1,5 @@
import dayJs from 'dayjs'; import dayJs from 'dayjs';
import { appendFileSync, existsSync, openSync, rmSync, closeSync, createReadStream, createWriteStream } from 'fs'; import { appendFileSync, existsSync, openSync, rmSync, closeSync, createReadStream, createWriteStream } from 'fs';
import assert from 'assert';
import { EntityDict } from '../types/Entity'; import { EntityDict } from '../types/Entity';
import { EntityDict as BaseEntityDict } from '../base-app-domain'; import { EntityDict as BaseEntityDict } from '../base-app-domain';
import { AsyncContext } from '../store/AsyncRowStore'; import { AsyncContext } from '../store/AsyncRowStore';
@ -23,6 +22,7 @@ type VaccumOption<ED extends EntityDict & BaseEntityDict> = {
/** /**
* *
*
* @param option * @param option
*/ */
export async function vaccumEntities<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>>(option: VaccumOption<ED>, context: Cxt) { export async function vaccumEntities<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>>(option: VaccumOption<ED>, context: Cxt) {