law-common 10.19.1-beta.11 → 10.19.1-beta.13

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.
@@ -1,4 +1,4 @@
1
- import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, IBaseEntityApiResponse } from "../interface/entity.utils.interface";
1
+ import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, EnumToModel, IApiEntity, IBaseEntityApiResponse, VirtualEntityEnum } from "../interface/entity.utils.interface";
2
2
  export declare function mapToIndex(entityMap: EntityMap): EntityIndexMap;
3
3
  export declare function getEntityIndexMap<T extends EntityEnum>(data: IBaseEntityApiResponse<EnumEntityType<T>>, baseEntity: T, reusedConfig?: {
4
4
  existingEntityIndexMap: EntityIndexMap;
@@ -6,3 +6,11 @@ export declare function getEntityIndexMap<T extends EntityEnum>(data: IBaseEntit
6
6
  }): EntityIndexMap;
7
7
  export declare function populateRelationsFor(entityIndexMap: EntityIndexMap, enumEntities: EntityEnum[]): void;
8
8
  export declare function parseEntities<T extends EnumEntityType<EntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum, entityMap: EntityMap): EntityMap;
9
+ export declare const entityEnumToEntityModel: {
10
+ [E in EntityEnum | VirtualEntityEnum]?: (json: IApiEntity<EnumEntityType<E>>) => EnumToModel<E>;
11
+ };
12
+ export declare function parseEntitiesWithoutModels<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum | VirtualEntityEnum, entityMap?: {
13
+ [E in EntityEnum | VirtualEntityEnum]?: IApiEntity<EnumEntityType<E>>[];
14
+ }): {
15
+ [E in EntityEnum | VirtualEntityEnum]?: IApiEntity<EnumEntityType<E>>[];
16
+ };
@@ -1,18 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.entityEnumToEntityModel = void 0;
3
4
  exports.mapToIndex = mapToIndex;
4
5
  exports.getEntityIndexMap = getEntityIndexMap;
5
6
  exports.populateRelationsFor = populateRelationsFor;
6
7
  exports.parseEntities = parseEntities;
8
+ exports.parseEntitiesWithoutModels = parseEntitiesWithoutModels;
7
9
  const entity_utils_interface_1 = require("../interface/entity.utils.interface");
8
10
  const bank_entity_model_1 = require("./bank.entity.model");
9
11
  const base_entity_model_1 = require("./base.entity.model");
10
12
  const billing_reimbursement_expense_entity_model_1 = require("./billing-reimbursement-expense.entity.model");
11
13
  const billing_timesheet_entity_model_1 = require("./billing-timesheet.entity.model");
14
+ const billing_transaction_model_1 = require("./billing-transaction.model");
12
15
  const billing_entity_model_1 = require("./billing.entity.model");
13
16
  const client_affiliate_entity_model_1 = require("./client-affiliate.entity.model");
14
17
  const client_entity_model_1 = require("./client.entity.model");
15
18
  const configuration_model_1 = require("./configuration.model");
19
+ const holiday_entity_model_1 = require("./holiday.entity.model");
20
+ const leave_entity_model_1 = require("./leave.entity.model");
21
+ const leave_count_entity_model_1 = require("./leave_count.entity.model");
16
22
  const project_user_mapping_entity_model_1 = require("./project-user-mapping.entity.model");
17
23
  const project_entity_model_1 = require("./project.entity.model");
18
24
  const reimbursement_expense_entity_model_1 = require("./reimbursement-expense.entity.model");
@@ -64,6 +70,7 @@ function parseEntities(json, baseEntity, entityMap) {
64
70
  [entity_utils_interface_1.EntityEnum.TASK]: task_entity_model_1.TaskEntityModel.fromApiEntity,
65
71
  [entity_utils_interface_1.EntityEnum.BILLING_TIMESHEET]: billing_timesheet_entity_model_1.BillingTimesheetEntityModel.fromApiEntity,
66
72
  [entity_utils_interface_1.EntityEnum.TIMESHEET]: timesheet_entity_model_1.TimesheetEntityModel.fromApiEntity,
73
+ [entity_utils_interface_1.EntityEnum.BILLING_TRANSACTION]: billing_transaction_model_1.BillingTransactionEntityModel.fromApiEntity,
67
74
  };
68
75
  if (!(baseEntity in entityFromJsonMappings)) {
69
76
  throw new Error(`Unknown entity: ${baseEntity}`);
@@ -79,3 +86,40 @@ function parseEntities(json, baseEntity, entityMap) {
79
86
  }
80
87
  return entityMap;
81
88
  }
89
+ exports.entityEnumToEntityModel = {
90
+ [entity_utils_interface_1.EntityEnum.PROJECT]: project_entity_model_1.ProjectEntityModel.fromApiEntity,
91
+ [entity_utils_interface_1.EntityEnum.CLIENT]: client_entity_model_1.ClientEntityModel.fromApiEntity,
92
+ [entity_utils_interface_1.EntityEnum.BILLING]: billing_entity_model_1.BillingEntityModel.fromApiEntity,
93
+ [entity_utils_interface_1.EntityEnum.USER]: user_entity_model_1.UserEntityModel.fromApiEntity,
94
+ [entity_utils_interface_1.EntityEnum.PROJECT_USER_MAPPING]: project_user_mapping_entity_model_1.ProjectUserMappingEntityModel.fromApiEntity,
95
+ [entity_utils_interface_1.EntityEnum.REIMBURSEMENT]: reimbursement_entity_model_1.ReimbursementEntityModel.fromApiEntity,
96
+ [entity_utils_interface_1.EntityEnum.REIMBURSEMENT_EXPENSE]: reimbursement_expense_entity_model_1.ReimbursementExpenseEntityModel.fromApiEntity,
97
+ [entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE]: billing_reimbursement_expense_entity_model_1.BillingReimbursementExpneseEntityModel.fromApiEntity,
98
+ [entity_utils_interface_1.EntityEnum.HOLIDAY]: holiday_entity_model_1.HolidayEntityModel.fromApiEntity,
99
+ [entity_utils_interface_1.EntityEnum.LEAVE]: leave_entity_model_1.LeaveEntityModel.fromApiEntity,
100
+ [entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT]: leave_count_entity_model_1.LeaveCountVirtualEntityModel.fromApiEntity,
101
+ // Add other entities here as needed
102
+ [entity_utils_interface_1.EntityEnum.CLIENT_AFFILIATE]: client_affiliate_entity_model_1.ClientAffiliateEntityModel.fromApiEntity,
103
+ [entity_utils_interface_1.EntityEnum.BANK]: bank_entity_model_1.BankEntityModel.fromApiEntity,
104
+ [entity_utils_interface_1.EntityEnum.CONFIGURATION]: configuration_model_1.ConfigurationEntityModel.fromApiEntity,
105
+ [entity_utils_interface_1.EntityEnum.TASK]: task_entity_model_1.TaskEntityModel.fromApiEntity,
106
+ [entity_utils_interface_1.EntityEnum.BILLING_TIMESHEET]: billing_timesheet_entity_model_1.BillingTimesheetEntityModel.fromApiEntity,
107
+ [entity_utils_interface_1.EntityEnum.TIMESHEET]: timesheet_entity_model_1.TimesheetEntityModel.fromApiEntity,
108
+ [entity_utils_interface_1.EntityEnum.BILLING_TRANSACTION]: billing_transaction_model_1.BillingTransactionEntityModel.fromApiEntity,
109
+ };
110
+ function parseEntitiesWithoutModels(json, baseEntity, entityMap = {}) {
111
+ var _a;
112
+ if (!(baseEntity in exports.entityEnumToEntityModel)) {
113
+ throw new Error(`Unknown entity: ${baseEntity}`);
114
+ }
115
+ entityMap[baseEntity] = ((_a = json["baseEntities"]) !== null && _a !== void 0 ? _a : []);
116
+ if (json["relatedEntities"]) {
117
+ const relatedEntities = json["relatedEntities"];
118
+ for (const entityName in relatedEntities) {
119
+ parseEntitiesWithoutModels(
120
+ // @ts-ignore
121
+ relatedEntities[entityName], entityName, entityMap);
122
+ }
123
+ }
124
+ return entityMap;
125
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "10.19.1-beta.11",
3
+ "version": "10.19.1-beta.13",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [