还是恢复了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 { 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<E> = {
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<AttrFilter & ExprOp<OpAttr | string>>;
export declare type Filter<E = Q_EnumValue<"user" | "userEntityGrant" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>;
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<ExprOp<OpAttr | string>>;
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<ExprOp<OpAttr | string>>;
@ -84,6 +102,28 @@ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity"
} | {
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;
entityId?: string;
[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 CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
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;
modiId?: never;
} | {
@ -103,16 +143,35 @@ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "modiId"
} | {
modi?: never;
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;
};
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<ModiIdProjection>;
export declare type UserIdSubQuery = Selection<UserIdProjection>;
export declare type UserEntityGrantIdSubQuery = Selection<UserEntityGrantIdProjection>;
export declare type ModiEntityIdSubQuery = Selection<ModiEntityIdProjection>;
export declare type EntityDef = {
Schema: Schema;

View File

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

View File

@ -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<E> = {
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<AttrFilter & ExprOp<OpAttr | string>>;
export declare type Filter<E = Q_EnumValue<"user" | "userEntityGrant" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>;
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<ExprOp<OpAttr | string>>;
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<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 Selection<P extends Object = Projection> = Omit<SelectOperation<P>, "action">;
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;
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<CreateOperationData>>;
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;
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<OperIdProjection>;
export declare type UserIdSubQuery = Selection<UserIdProjection>;
export declare type UserEntityGrantIdSubQuery = Selection<UserEntityGrantIdProjection>;
export declare type OperEntityIdSubQuery = Selection<OperEntityIdProjection>;
export declare type EntityDef = {
Schema: Schema;

View File

@ -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

View File

@ -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<Oper.Schema>;
user$ref?: Array<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;
};
@ -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<ExprOp<OpAttr | string>>;
declare type UserIdProjection = OneOf<{
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">>>;
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 CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
@ -133,6 +153,8 @@ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "refId">
[k: string]: any;
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>;
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 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 { 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.Schema>;
modiEntity$entity$$aggr?: AggregationResult<ModiEntity.Schema>;
operEntity$entity?: Array<OperEntity.Schema>;
operEntity$entity$$aggr?: AggregationResult<OperEntity.Schema>;
} & {
[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<ExprOp<OpAttr | string>>;
declare type UserEntityGrantIdProjection = OneOf<{
id: number;
@ -70,12 +88,17 @@ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity"
entity?: string;
entityId?: string;
[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 CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export declare type UpdateOperationData = FormUpdateData<OpSchema> & {
[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 RemoveOperationData = {};

View File

@ -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;
}

View File

@ -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>;
}

View File

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

View File

@ -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)];
}
});

View File

@ -13,6 +13,7 @@ declare type VaccumOption<ED extends EntityDict & BaseEntityDict> = {
};
/**
*
*
* @param option
*/
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");
/**
* 删除数据库中的部分数据减少体积
* 一般只删除日志类数据
* @param option
*/
function vaccumEntities(option, context) {

View File

@ -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[(<ts.Identifier>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[(<ts.Identifier>name).text]);
assert(enumAttributes && enumAttributes[(<ts.Identifier>name).text]);
attrAssignments.push(
factory.createPropertyAssignment(
'type',
@ -5512,7 +5508,7 @@ function constructAttributes(entity: string): ts.PropertyAssignment[] {
factory.createArrayLiteralExpression(
enumAttributes[(<ts.Identifier>name).text].map(
ele => factory.createStringLiteral(ele)
)
)
)
)
);

View File

@ -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<Schema, '', '', {}> = {
name: '操作对象连接',
attr: {
oper: '操作',
targetEntityId: '关联对象id',
entity: '关联对象',
entityId: '关联对象id',
},
},
};

View File

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

View File

@ -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<ED extends EntityDict & BaseEntityDict> = {
/**
*
*
* @param option
*/
export async function vaccumEntities<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>>(option: VaccumOption<ED>, context: Cxt) {