law-common 10.28.2-beta.4 → 10.28.2-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -25,6 +25,7 @@ export declare class EntityModelRelationHelper {
|
|
|
25
25
|
constructor(entityMap: EntityMap);
|
|
26
26
|
private init;
|
|
27
27
|
private toEntityModelMap;
|
|
28
|
+
private fromEntityToEntityModel;
|
|
28
29
|
private toEntityModelIndexMap;
|
|
29
30
|
populateRelationsByEntityEnums(entityEnums: EntityEnum[]): EntityModelRelationHelper;
|
|
30
31
|
populateRelationsByEntityEnum(entityEnum: EntityEnum): void;
|
|
@@ -32,4 +33,7 @@ export declare class EntityModelRelationHelper {
|
|
|
32
33
|
addEntityModel<T extends EntityEnum | VirtualEntityEnum>(entityModel: BaseEntityModel<T>, config?: {
|
|
33
34
|
populateRelations?: boolean;
|
|
34
35
|
}): void;
|
|
36
|
+
addEntity<T extends EntityEnum | VirtualEntityEnum>(entity: EnumEntityType<T>, entityEnum: T, config?: {
|
|
37
|
+
populateRelations?: boolean;
|
|
38
|
+
}): void;
|
|
35
39
|
}
|
|
@@ -153,6 +153,12 @@ class EntityModelRelationHelper {
|
|
|
153
153
|
}
|
|
154
154
|
return this;
|
|
155
155
|
}
|
|
156
|
+
fromEntityToEntityModel(entity, entityEnum) {
|
|
157
|
+
if (!(entityEnum in exports.entityEnumToEntityModel)) {
|
|
158
|
+
throw new Error(`Unknown entity: ${entityEnum}`);
|
|
159
|
+
}
|
|
160
|
+
return exports.entityEnumToEntityModel[entityEnum](entity);
|
|
161
|
+
}
|
|
156
162
|
toEntityModelIndexMap() {
|
|
157
163
|
this.entityModelIndexMap = Object.keys(this.entityModelMap).reduce((acc, key) => {
|
|
158
164
|
// @ts-ignore
|
|
@@ -188,5 +194,11 @@ class EntityModelRelationHelper {
|
|
|
188
194
|
this.populateRelationsByEntityModel(entityModel);
|
|
189
195
|
}
|
|
190
196
|
}
|
|
197
|
+
addEntity(entity, entityEnum, config = { populateRelations: false }) {
|
|
198
|
+
if (!(entityEnum in exports.entityEnumToEntityModel)) {
|
|
199
|
+
throw new Error(`Unknown entity: ${entityEnum}`);
|
|
200
|
+
}
|
|
201
|
+
this.addEntityModel(this.fromEntityToEntityModel(entity, entityEnum), config);
|
|
202
|
+
}
|
|
191
203
|
}
|
|
192
204
|
exports.EntityModelRelationHelper = EntityModelRelationHelper;
|