law-common 10.45.3-beta.1 → 10.45.3-beta.2

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.
@@ -31,7 +31,9 @@ class BaseEntityModel {
31
31
  console.warn(`[populateRelationsByIndex] Missing child key "${childKey}" in parent "${parentKey}" on entity "${this.entityName}". Parent value:`, this[parentKey]);
32
32
  continue;
33
33
  }
34
- foundRelatedEntities = [relatedEntitiesIndex[this[parentKey][childKey]]];
34
+ foundRelatedEntities = [
35
+ relatedEntitiesIndex[this[parentKey][childKey]],
36
+ ];
35
37
  }
36
38
  else {
37
39
  // foundRelatedEntities = relatedEntities[this[thisKey]] ? [relatedEntities[this[thisKey]]] : [];
@@ -10,30 +10,30 @@ exports.entityMapToEntityIndexMap = entityMapToEntityIndexMap;
10
10
  exports.parseEntitiesWithoutModels = parseEntitiesWithoutModels;
11
11
  exports.removeEntityById = removeEntityById;
12
12
  const entity_utils_interface_1 = require("../interface/entity.utils.interface");
13
+ const address_book_model_1 = require("./address_book.model");
13
14
  const bank_entity_model_1 = require("./bank.entity.model");
14
15
  const base_entity_model_1 = require("./base.entity.model");
15
16
  const billing_reimbursement_expense_entity_model_1 = require("./billing-reimbursement-expense.entity.model");
16
17
  const billing_timesheet_entity_model_1 = require("./billing-timesheet.entity.model");
18
+ const billing_transaction_model_1 = require("./billing-transaction.model");
17
19
  const billing_entity_model_1 = require("./billing.entity.model");
18
20
  const client_affiliate_entity_model_1 = require("./client-affiliate.entity.model");
19
21
  const client_entity_model_1 = require("./client.entity.model");
22
+ const configuration_model_1 = require("./configuration.model");
23
+ const country_entity_model_1 = require("./country.entity.model");
24
+ const gst_rate_entity_model_1 = require("./gst_rate.entity.model");
20
25
  const holiday_entity_model_1 = require("./holiday.entity.model");
21
26
  const leave_entity_model_1 = require("./leave.entity.model");
22
27
  const leave_count_entity_model_1 = require("./leave_count.entity.model");
23
- const configuration_model_1 = require("./configuration.model");
28
+ const organization_type_entity_model_1 = require("./organization_type.entity.model");
24
29
  const project_user_mapping_entity_model_1 = require("./project-user-mapping.entity.model");
25
30
  const project_entity_model_1 = require("./project.entity.model");
26
31
  const reimbursement_expense_entity_model_1 = require("./reimbursement-expense.entity.model");
27
32
  const reimbursement_entity_model_1 = require("./reimbursement.entity.model");
33
+ const state_entity_model_1 = require("./state.entity.model");
28
34
  const task_entity_model_1 = require("./task.entity.model");
29
35
  const timesheet_entity_model_1 = require("./timesheet.entity.model");
30
36
  const user_entity_model_1 = require("./user.entity.model");
31
- const country_entity_model_1 = require("./country.entity.model");
32
- const address_book_model_1 = require("./address_book.model");
33
- const billing_transaction_model_1 = require("./billing-transaction.model");
34
- const state_entity_model_1 = require("./state.entity.model");
35
- const gst_rate_entity_model_1 = require("./gst_rate.entity.model");
36
- const organization_type_entity_model_1 = require("./organization_type.entity.model");
37
37
  function mapToIndex(entityMap) {
38
38
  return Object.keys(entityMap).reduce((acc, key) => {
39
39
  // @ts-ignore
@@ -92,19 +92,22 @@ function entityMapToModels(entityMap) {
92
92
  if (!(entityName in exports.entityEnumToEntityModel)) {
93
93
  throw new Error(`Unknown entity: ${entityName}`);
94
94
  }
95
- entityMap[entityName] = entityMap[entityName].map((entity) =>
95
+ entityMap[entityName] = entityMap[entityName].map((entity) => exports.entityEnumToEntityModel[entityName](
96
96
  // @ts-ignore
97
- exports.entityEnumToEntityModel[entityName](entity));
97
+ entity));
98
98
  }
99
99
  }
100
100
  function parseEntities(json, baseEntity, entityMap) {
101
- var _a;
102
101
  if (!(baseEntity in exports.entityEnumToEntityModel)) {
103
102
  throw new Error(`Unknown entity: ${baseEntity}`);
104
103
  }
105
- entityMap[baseEntity] = ((_a = json["baseEntities"]) !== null && _a !== void 0 ? _a : []).map(
104
+ console.log("entityMap 1", entityMap);
105
+ entityMap[baseEntity] = (entityMap[baseEntity].length > 0
106
+ ? [...entityMap[baseEntity], ...json["baseEntities"]]
107
+ : []).map(
106
108
  // @ts-ignore
107
109
  (e) => exports.entityEnumToEntityModel[baseEntity](e));
110
+ console.log("entityMap 2", entityMap);
108
111
  if (json["relatedEntities"]) {
109
112
  const relatedEntities = json["relatedEntities"];
110
113
  for (const entityName in relatedEntities) {
@@ -162,9 +165,10 @@ class EntityModelRelationHelper {
162
165
  if (!(entityName in exports.entityEnumToEntityModel)) {
163
166
  throw new Error(`Unknown entity: ${entityName}`);
164
167
  }
165
- this.entityModelMap[entityName] = this.entityMap[entityName].map((entity) =>
166
- // @ts-ignore
167
- exports.entityEnumToEntityModel[entityName](entity));
168
+ this.entityModelMap[entityName] =
169
+ this.entityMap[entityName].map((entity) => exports.entityEnumToEntityModel[entityName
170
+ // @ts-ignore
171
+ ](entity));
168
172
  }
169
173
  return this;
170
174
  }
@@ -193,7 +197,8 @@ class EntityModelRelationHelper {
193
197
  }
194
198
  populateRelationsByEntityEnum(entityEnum) {
195
199
  for (const key of Object.keys(this.entityModelIndexMap[entityEnum] || {})) {
196
- const entityModel = this.entityModelIndexMap[entityEnum][key];
200
+ const entityModel = this
201
+ .entityModelIndexMap[entityEnum][key];
197
202
  entityModel.populateRelationsByIndex(this.entityModelIndexMap);
198
203
  }
199
204
  }
@@ -202,9 +207,12 @@ class EntityModelRelationHelper {
202
207
  }
203
208
  addEntityModel(entityModel, config = { populateRelations: false }) {
204
209
  const entityEnum = entityModel.entityName;
205
- this.entityModelIndexMap[entityEnum] = this.entityModelIndexMap[entityEnum] || {};
210
+ this.entityModelIndexMap[entityEnum] =
211
+ this.entityModelIndexMap[entityEnum] || {};
206
212
  // @ts-ignore
207
- this.entityModelIndexMap[entityEnum][entityModel.id] = entityModel;
213
+ this.entityModelIndexMap[entityEnum][entityModel.id] =
214
+ // @ts-ignore
215
+ entityModel;
208
216
  if (config.populateRelations) {
209
217
  this.populateRelationsByEntityModel(entityModel);
210
218
  }
@@ -219,9 +227,12 @@ class EntityModelRelationHelper {
219
227
  }
220
228
  updateEntityModel(entityModel, config = { populateRelations: false }) {
221
229
  const entityEnum = entityModel.entityName;
222
- this.entityModelIndexMap[entityEnum] = this.entityModelIndexMap[entityEnum] || {};
230
+ this.entityModelIndexMap[entityEnum] =
231
+ this.entityModelIndexMap[entityEnum] || {};
223
232
  // @ts-ignore
224
- this.entityModelIndexMap[entityEnum][entityModel.id] = entityModel;
233
+ this.entityModelIndexMap[entityEnum][entityModel.id] =
234
+ // @ts-ignore
235
+ entityModel;
225
236
  if (config.populateRelations) {
226
237
  this.populateRelationsByEntityModel(entityModel);
227
238
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "10.45.3-beta.1",
3
+ "version": "10.45.3-beta.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [