diff --git a/lib/base-app-domain/ModiEntity/Schema.d.ts b/lib/base-app-domain/ModiEntity/Schema.d.ts index 1e6460f..d7ec3fc 100644 --- a/lib/base-app-domain/ModiEntity/Schema.d.ts +++ b/lib/base-app-domain/ModiEntity/Schema.d.ts @@ -1,35 +1,41 @@ 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 * 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"; +import * as UserEntityGrant from "../UserEntityGrant/Schema"; export declare type OpSchema = EntityShape & { modiId: ForeignKey<"modi">; - entity: String<32>; + entity: "user" | "userEntityGrant" | string; entityId: String<64>; }; export declare type OpAttr = keyof OpSchema; export declare type Schema = EntityShape & { modiId: ForeignKey<"modi">; - entity: String<32>; + entity: "user" | "userEntityGrant" | string; entityId: String<64>; modi: Modi.Schema; + user?: User.Schema; + userEntityGrant?: UserEntityGrant.Schema; } & { [A in ExpressionKey]?: any; }; -declare type AttrFilter = { +declare type AttrFilter = { id: Q_StringValue | SubQuery.ModiEntityIdSubQuery; $$createAt$$: Q_DateValue; $$seq$$: Q_StringValue; $$updateAt$$: Q_DateValue; modiId: Q_StringValue | SubQuery.ModiIdSubQuery; modi: Modi.Filter; - entity: Q_StringValue; + entity: E; entityId: Q_StringValue; + user: User.Filter; + userEntityGrant: UserEntityGrant.Filter; }; -export declare type Filter = MakeFilter>; +export declare type Filter> = MakeFilter & ExprOp>; export declare type Projection = { "#id"?: NodeId; [k: string]: any; @@ -41,6 +47,8 @@ export declare type Projection = { modi?: Modi.Projection; entity?: number; entityId?: number; + user?: User.Projection; + userEntityGrant?: UserEntityGrant.Projection; } & Partial>; declare type ModiEntityIdProjection = OneOf<{ id: number; @@ -48,6 +56,12 @@ declare type ModiEntityIdProjection = OneOf<{ declare type ModiIdProjection = OneOf<{ modiId: number; }>; +declare type UserIdProjection = OneOf<{ + entityId: number; +}>; +declare type UserEntityGrantIdProjection = OneOf<{ + entityId: number; +}>; export declare type SortAttr = { id: number; } | { @@ -64,6 +78,10 @@ export declare type SortAttr = { entity: number; } | { entityId: number; +} | { + user: User.SortAttr; +} | { + userEntityGrant: UserEntityGrant.SortAttr; } | { [k: string]: any; } | OneOf>; @@ -84,6 +102,28 @@ export declare type CreateOperationData = FormCreateData; })) & ({ + 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; @@ -91,7 +131,7 @@ export declare type CreateOperationData = FormCreateData; export declare type CreateMultipleOperation = OakOperation<"create", Array>; export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation; -export declare type UpdateOperationData = FormUpdateData> & (({ +export declare type UpdateOperationData = FormUpdateData> & (({ modi: Modi.CreateSingleOperation; modiId?: never; } | { @@ -103,16 +143,35 @@ export declare type UpdateOperationData = FormUpdateData | 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; }; export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>; export declare type RemoveOperationData = {} & (({ 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 Operation = CreateOperation | UpdateOperation | RemoveOperation; export declare type ModiIdSubQuery = Selection; +export declare type UserIdSubQuery = Selection; +export declare type UserEntityGrantIdSubQuery = Selection; export declare type ModiEntityIdSubQuery = Selection; export declare type EntityDef = { Schema: Schema; diff --git a/lib/base-app-domain/ModiEntity/Storage.js b/lib/base-app-domain/ModiEntity/Storage.js index 5cc06a0..7b8a078 100644 --- a/lib/base-app-domain/ModiEntity/Storage.js +++ b/lib/base-app-domain/ModiEntity/Storage.js @@ -12,7 +12,8 @@ exports.desc = { type: "varchar", params: { length: 32 - } + }, + ref: ["user", "userEntityGrant"] }, entityId: { type: "varchar", diff --git a/lib/base-app-domain/OperEntity/Schema.d.ts b/lib/base-app-domain/OperEntity/Schema.d.ts index 2735692..45e8505 100644 --- a/lib/base-app-domain/OperEntity/Schema.d.ts +++ b/lib/base-app-domain/OperEntity/Schema.d.ts @@ -1,32 +1,41 @@ 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 * 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 Oper from "../Oper/Schema"; +import * as User from "../User/Schema"; +import * as UserEntityGrant from "../UserEntityGrant/Schema"; export declare type OpSchema = EntityShape & { operId: ForeignKey<"oper">; - targetEntityId: String<64>; + entity: "user" | "userEntityGrant" | string; + entityId: String<64>; }; export declare type OpAttr = keyof OpSchema; export declare type Schema = EntityShape & { operId: ForeignKey<"oper">; - targetEntityId: String<64>; + entity: "user" | "userEntityGrant" | string; + entityId: String<64>; oper: Oper.Schema; + user?: User.Schema; + userEntityGrant?: UserEntityGrant.Schema; } & { [A in ExpressionKey]?: any; }; -declare type AttrFilter = { +declare type AttrFilter = { id: Q_StringValue | SubQuery.OperEntityIdSubQuery; $$createAt$$: Q_DateValue; $$seq$$: Q_StringValue; $$updateAt$$: Q_DateValue; operId: Q_StringValue | SubQuery.OperIdSubQuery; oper: Oper.Filter; - targetEntityId: Q_StringValue; + entity: E; + entityId: Q_StringValue; + user: User.Filter; + userEntityGrant: UserEntityGrant.Filter; }; -export declare type Filter = MakeFilter>; +export declare type Filter> = MakeFilter & ExprOp>; export declare type Projection = { "#id"?: NodeId; [k: string]: any; @@ -36,7 +45,10 @@ export declare type Projection = { $$seq$$?: number; operId?: number; oper?: Oper.Projection; - targetEntityId?: number; + entity?: number; + entityId?: number; + user?: User.Projection; + userEntityGrant?: UserEntityGrant.Projection; } & Partial>; declare type OperEntityIdProjection = OneOf<{ id: number; @@ -44,6 +56,12 @@ declare type OperEntityIdProjection = OneOf<{ declare type OperIdProjection = OneOf<{ operId: number; }>; +declare type UserIdProjection = OneOf<{ + entityId: number; +}>; +declare type UserEntityGrantIdProjection = OneOf<{ + entityId: number; +}>; export declare type SortAttr = { id: number; } | { @@ -57,7 +75,13 @@ export declare type SortAttr = { } | { oper: Oper.SortAttr; } | { - targetEntityId: number; + entity: number; +} | { + entityId: number; +} | { + user: User.SortAttr; +} | { + userEntityGrant: UserEntityGrant.SortAttr; } | { [k: string]: any; } | OneOf>; @@ -69,29 +93,74 @@ export declare type Sorter = SortNode[]; export declare type SelectOperation

= OakSelection<"select", P, Filter, Sorter>; export declare type Selection

= Omit, "action">; export declare type Aggregation = DeduceAggregation; -export declare type CreateOperationData = FormCreateData> & (({ +export declare type CreateOperationData = FormCreateData> & (({ operId?: never; oper: Oper.CreateSingleOperation; } | { 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 CreateMultipleOperation = OakOperation<"create", Array>; export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation; -export declare type UpdateOperationData = FormUpdateData> & (({ +export declare type UpdateOperationData = FormUpdateData> & (({ oper: Oper.CreateSingleOperation; operId?: never; } | { oper?: never; 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; }; 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 Operation = CreateOperation | UpdateOperation | RemoveOperation; export declare type OperIdSubQuery = Selection; +export declare type UserIdSubQuery = Selection; +export declare type UserEntityGrantIdSubQuery = Selection; export declare type OperEntityIdSubQuery = Selection; export declare type EntityDef = { Schema: Schema; diff --git a/lib/base-app-domain/OperEntity/Storage.js b/lib/base-app-domain/OperEntity/Storage.js index 3d50275..2ee6a26 100644 --- a/lib/base-app-domain/OperEntity/Storage.js +++ b/lib/base-app-domain/OperEntity/Storage.js @@ -8,7 +8,14 @@ exports.desc = { type: "ref", ref: "oper" }, - targetEntityId: { + entity: { + type: "varchar", + params: { + length: 32 + }, + ref: ["user", "userEntityGrant"] + }, + entityId: { type: "varchar", params: { length: 64 diff --git a/lib/base-app-domain/User/Schema.d.ts b/lib/base-app-domain/User/Schema.d.ts index 1ab23ae..74435ac 100644 --- a/lib/base-app-domain/User/Schema.d.ts +++ b/lib/base-app-domain/User/Schema.d.ts @@ -6,6 +6,8 @@ import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOper import { Action, ParticularAction, UserState } from "./Action"; import { RelationAction } from "../../actions/action"; import * as Oper from "../Oper/Schema"; +import * as ModiEntity from "../ModiEntity/Schema"; +import * as OperEntity from "../OperEntity/Schema"; export declare type OpSchema = EntityShape & { name?: String<16> | null; nickname?: String<64> | null; @@ -25,6 +27,10 @@ export declare type Schema = EntityShape & { oper$operator$$aggr?: AggregationResult; user$ref?: Array; user$ref$$aggr?: AggregationResult; + modiEntity$entity?: Array; + modiEntity$entity$$aggr?: AggregationResult; + operEntity$entity?: Array; + operEntity$entity$$aggr?: AggregationResult; } & { [A in ExpressionKey]?: any; }; @@ -66,6 +72,18 @@ export declare type Projection = { user$ref$$aggr?: Aggregation & { $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>; declare type UserIdProjection = OneOf<{ id: number; @@ -113,6 +131,8 @@ export declare type CreateOperationData = FormCreateData })) & { oper$operator?: OakOperation<"create", Omit[]> | Array>>; user$ref?: OakOperation, Filter> | OakOperation<"create", Omit[]> | Array> | OakOperation, Filter>>; + modiEntity$entity?: OakOperation<"create", Omit[]> | Array>>; + operEntity$entity?: OakOperation<"create", Omit[]> | Array>>; }; export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>; export declare type CreateMultipleOperation = OakOperation<"create", Array>; @@ -133,6 +153,8 @@ export declare type UpdateOperationData = FormUpdateData [k: string]: any; oper$operator?: OakOperation<"create", Omit[]> | Array>>; user$ref?: UpdateOperation | RemoveOperation | OakOperation<"create", Omit[]> | Array> | UpdateOperation | RemoveOperation>; + modiEntity$entity?: OakOperation<"create", Omit[]> | Array>>; + operEntity$entity?: OakOperation<"create", Omit[]> | Array>>; }; export declare type UpdateOperation = OakOperation<"update" | ParticularAction | RelationAction | string, UpdateOperationData, Filter, Sorter>; export declare type RemoveOperationData = {} & (({ diff --git a/lib/base-app-domain/UserEntityGrant/Schema.d.ts b/lib/base-app-domain/UserEntityGrant/Schema.d.ts index df08bd9..6334c2e 100644 --- a/lib/base-app-domain/UserEntityGrant/Schema.d.ts +++ b/lib/base-app-domain/UserEntityGrant/Schema.d.ts @@ -2,8 +2,10 @@ import { String } from "../../types/DataType"; import { Q_DateValue, Q_StringValue, 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 { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, EntityShape, AggregationResult } from "../../types/Entity"; import { GenericAction } from "../../actions/action"; +import * as ModiEntity from "../ModiEntity/Schema"; +import * as OperEntity from "../OperEntity/Schema"; export declare type OpSchema = EntityShape & { entity: String<32>; entityId: String<64>; @@ -14,6 +16,10 @@ export declare type Schema = EntityShape & { entity: String<32>; entityId: String<64>; relation: String<32>; + modiEntity$entity?: Array; + modiEntity$entity$$aggr?: AggregationResult; + operEntity$entity?: Array; + operEntity$entity$$aggr?: AggregationResult; } & { [A in ExpressionKey]?: any; }; @@ -37,6 +43,18 @@ export declare type Projection = { entity?: number; entityId?: 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>; declare type UserEntityGrantIdProjection = OneOf<{ id: number; @@ -70,12 +88,17 @@ export declare type CreateOperationData = FormCreateData[]> | Array>>; + operEntity$entity?: OakOperation<"create", Omit[]> | Array>>; +}; export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>; export declare type CreateMultipleOperation = OakOperation<"create", Array>; export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation; export declare type UpdateOperationData = FormUpdateData & { [k: string]: any; + modiEntity$entity?: OakOperation<"create", Omit[]> | Array>>; + operEntity$entity?: OakOperation<"create", Omit[]> | Array>>; }; export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>; export declare type RemoveOperationData = {}; diff --git a/lib/compiler/schemalBuilder.js b/lib/compiler/schemalBuilder.js index 0329d83..2ce4d2d 100644 --- a/lib/compiler/schemalBuilder.js +++ b/lib/compiler/schemalBuilder.js @@ -385,7 +385,7 @@ function analyzeEntity(filename, path, program, relativePath) { // let relationHierarchy: ts.ObjectLiteralExpression | undefined = undefined; // let reverseCascadeRelationHierarchy: ts.ObjectLiteralExpression | undefined = undefined; ts.forEachChild(sourceFile, function (node) { - var _a, _b, _c; + var _a, _b, _c, _d, _e; if (ts.isImportDeclaration(node)) { var entityImported = getEntityImported(node); if (entityImported) { @@ -535,29 +535,24 @@ function analyzeEntity(filename, path, program, relativePath) { } beforeSchema = false; // 对于不是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)) { ReversePointerRelations['ModiEntity'].push(moduleName); } else { - assign(ReversePointerRelations, { - ['ModiEntity']: [moduleName], - }); + (0, lodash_1.assign)(ReversePointerRelations, (_b = {}, + _b['ModiEntity'] = [moduleName], + _b)); } - } */ - // 对于不是Oper的对象,全部建立和OperEntity的反指关系 - // 不再建立了 by Xc 20230330 - /* if (!['Oper', 'OperEntity', 'ModiEntity'].includes(moduleName)) { if (ReversePointerRelations['OperEntity'] && !ReversePointerRelations['OperEntity'].includes(moduleName)) { ReversePointerRelations['OperEntity'].push(moduleName); } else { - assign(ReversePointerRelations, { - ['OperEntity']: [moduleName], - }); + (0, lodash_1.assign)(ReversePointerRelations, (_c = {}, + _c['OperEntity'] = [moduleName], + _c)); } - }*/ + } } 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('relation'), undefined, factory.createTypeReferenceNode(factory.createIdentifier("Relation"), undefined)), ]; - (0, lodash_1.assign)(Schema, (_b = {}, - _b[relationEntityName] = { + (0, lodash_1.assign)(Schema, (_d = {}, + _d[relationEntityName] = { schemaAttrs: relationSchemaAttrs, sourceFile: sourceFile, 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) ], }, - _b)); + _d)); addRelationship(relationEntityName, 'User', 'user', true); addRelationship(relationEntityName, moduleName, entityLc, true); // 对UserEntityGrant对象,建立相应的反指关系 @@ -631,9 +626,9 @@ function analyzeEntity(filename, path, program, relativePath) { } } else { - (0, lodash_1.assign)(ReversePointerRelations, (_c = {}, - _c['UserEntityGrant'] = [moduleName], - _c)); + (0, lodash_1.assign)(ReversePointerRelations, (_e = {}, + _e['UserEntityGrant'] = [moduleName], + _e)); } hasRelationDef = node; } diff --git a/lib/entities/OperEntity.d.ts b/lib/entities/OperEntity.d.ts index f2079b9..f4d1890 100644 --- a/lib/entities/OperEntity.d.ts +++ b/lib/entities/OperEntity.d.ts @@ -3,5 +3,6 @@ import { EntityShape } from '../types/Entity'; import { Schema as Oper } from './Oper'; export interface Schema extends EntityShape { oper: Oper; - targetEntityId: String<64>; + entity: String<32>; + entityId: String<64>; } diff --git a/lib/entities/OperEntity.js b/lib/entities/OperEntity.js index 1294144..6ee0190 100644 --- a/lib/entities/OperEntity.js +++ b/lib/entities/OperEntity.js @@ -9,7 +9,8 @@ var locale = { name: '操作对象连接', attr: { oper: '操作', - targetEntityId: '关联对象id', + entity: '关联对象', + entityId: '关联对象id', }, }, }; diff --git a/lib/store/CascadeStore.js b/lib/store/CascadeStore.js index d6e2d5c..37dcd99 100644 --- a/lib/store/CascadeStore.js +++ b/lib/store/CascadeStore.js @@ -956,7 +956,8 @@ var CascadeStore = /** @class */ (function (_super) { _a = {}; return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()]; case 1: return [2 /*return*/, (_a.id = _b.sent(), - _a.targetEntityId = ele.id, + _a.entityId = ele.id, + _a.entity = entity, _a)]; } }); @@ -1138,7 +1139,8 @@ var CascadeStore = /** @class */ (function (_super) { _a = {}; return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()]; case 1: return [2 /*return*/, (_a.id = _b.sent(), - _a.targetEntityId = ele, + _a.entityId = ele, + _a.entity = entity, _a)]; } }); diff --git a/lib/timers/vaccum.d.ts b/lib/timers/vaccum.d.ts index a390f7c..bd3ef80 100644 --- a/lib/timers/vaccum.d.ts +++ b/lib/timers/vaccum.d.ts @@ -13,6 +13,7 @@ declare type VaccumOption = { }; /** * 删除数据库中的部分数据,减少体积 + * 一般只删除日志类数据 * @param option */ export declare function vaccumEntities>(option: VaccumOption, context: Cxt): Promise; diff --git a/lib/timers/vaccum.js b/lib/timers/vaccum.js index 0887e49..8d68731 100644 --- a/lib/timers/vaccum.js +++ b/lib/timers/vaccum.js @@ -10,6 +10,7 @@ var stream_1 = require("stream"); var uuid_1 = require("../utils/uuid"); /** * 删除数据库中的部分数据,减少体积 + * 一般只删除日志类数据 * @param option */ function vaccumEntities(option, context) { diff --git a/src/compiler/schemalBuilder.ts b/src/compiler/schemalBuilder.ts index 34c5cd9..94db06f 100644 --- a/src/compiler/schemalBuilder.ts +++ b/src/compiler/schemalBuilder.ts @@ -730,8 +730,7 @@ function analyzeEntity(filename: string, path: string, program: ts.Program, rela beforeSchema = false; // 对于不是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)) { ReversePointerRelations['ModiEntity'].push(moduleName); } @@ -740,11 +739,7 @@ function analyzeEntity(filename: string, path: string, program: ts.Program, rela ['ModiEntity']: [moduleName], }); } - } */ - // 对于不是Oper的对象,全部建立和OperEntity的反指关系 - // 不再建立了 by Xc 20230330 - /* if (!['Oper', 'OperEntity', 'ModiEntity'].includes(moduleName)) { if (ReversePointerRelations['OperEntity'] && !ReversePointerRelations['OperEntity'].includes(moduleName)) { ReversePointerRelations['OperEntity'].push(moduleName); } @@ -752,8 +747,9 @@ function analyzeEntity(filename: string, path: string, program: ts.Program, rela assign(ReversePointerRelations, { ['OperEntity']: [moduleName], }); - } - }*/ + } + } + } else if (beforeSchema) { // 本地规定的一些形状定义,直接使用 @@ -5475,7 +5471,7 @@ function constructAttributes(entity: string): ts.PropertyAssignment[] { factory.createArrayLiteralExpression( enumAttributes[(name).text].map( ele => factory.createStringLiteral(ele) - ) + ) ) ) ); @@ -5501,7 +5497,7 @@ function constructAttributes(entity: string): ts.PropertyAssignment[] { if (ts.isUnionTypeNode(type!)) { if (ts.isLiteralTypeNode(type.types[0])) { if (ts.isStringLiteral(type.types[0].literal)) { - assert (enumAttributes && enumAttributes[(name).text]); + assert(enumAttributes && enumAttributes[(name).text]); attrAssignments.push( factory.createPropertyAssignment( 'type', @@ -5512,7 +5508,7 @@ function constructAttributes(entity: string): ts.PropertyAssignment[] { factory.createArrayLiteralExpression( enumAttributes[(name).text].map( ele => factory.createStringLiteral(ele) - ) + ) ) ) ); diff --git a/src/entities/OperEntity.ts b/src/entities/OperEntity.ts index ea3ddb8..e2a4065 100644 --- a/src/entities/OperEntity.ts +++ b/src/entities/OperEntity.ts @@ -5,7 +5,8 @@ import { Schema as Oper } from './Oper'; export interface Schema extends EntityShape { oper: Oper, - targetEntityId: String<64>; + entity: String<32>; + entityId: String<64>; }; const config: Configuration = { @@ -17,7 +18,8 @@ const locale: LocaleDef = { name: '操作对象连接', attr: { oper: '操作', - targetEntityId: '关联对象id', + entity: '关联对象', + entityId: '关联对象id', }, }, }; diff --git a/src/store/CascadeStore.ts b/src/store/CascadeStore.ts index e54b296..364d656 100644 --- a/src/store/CascadeStore.ts +++ b/src/store/CascadeStore.ts @@ -1056,7 +1056,8 @@ export abstract class CascadeStore exten data.map( async (ele) => ({ id: await generateNewIdAsync(), - targetEntityId: ele.id, + entityId: ele.id, + entity: entity as string, }) ) ), @@ -1204,7 +1205,8 @@ export abstract class CascadeStore exten ids.map( async (ele) => ({ id: await generateNewIdAsync(), - targetEntityId: ele, + entityId: ele, + entity: entity as string, }) ) ) diff --git a/src/timers/vaccum.ts b/src/timers/vaccum.ts index d7755f3..cac0f6e 100644 --- a/src/timers/vaccum.ts +++ b/src/timers/vaccum.ts @@ -1,6 +1,5 @@ import dayJs from 'dayjs'; import { appendFileSync, existsSync, openSync, rmSync, closeSync, createReadStream, createWriteStream } from 'fs'; -import assert from 'assert'; import { EntityDict } from '../types/Entity'; import { EntityDict as BaseEntityDict } from '../base-app-domain'; import { AsyncContext } from '../store/AsyncRowStore'; @@ -23,6 +22,7 @@ type VaccumOption = { /** * 删除数据库中的部分数据,减少体积 + * 一般只删除日志类数据 * @param option */ export async function vaccumEntities>(option: VaccumOption, context: Cxt) {