law-common 10.18.2-beta.5 → 10.19.1-beta.0

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.
Files changed (41) hide show
  1. package/dist/src/api/interface/billing.create.dto.interface.d.ts +2 -2
  2. package/dist/src/api/interface/billing.update.dto.interface.d.ts +5 -3
  3. package/dist/src/constants/entity_constants.d.ts +1 -0
  4. package/dist/src/constants/entity_constants.js +5 -1
  5. package/dist/src/entities/index.d.ts +2 -1
  6. package/dist/src/entities/index.js +2 -1
  7. package/dist/src/entities/interface/billing_timesheet.entity.interface.d.ts +2 -2
  8. package/dist/src/entities/interface/entity.utils.interface.d.ts +9 -6
  9. package/dist/src/entities/model/bank.entity.model.d.ts +4 -1
  10. package/dist/src/entities/model/bank.entity.model.js +8 -2
  11. package/dist/src/entities/model/base.entity.model.d.ts +2 -8
  12. package/dist/src/entities/model/base.entity.model.js +35 -43
  13. package/dist/src/entities/model/billing-timesheet.entity.model.d.ts +26 -0
  14. package/dist/src/entities/model/billing-timesheet.entity.model.js +36 -0
  15. package/dist/src/entities/model/billing.entity.model.d.ts +7 -1
  16. package/dist/src/entities/model/billing.entity.model.js +18 -0
  17. package/dist/src/entities/model/client-affiliate.entity.model.d.ts +19 -0
  18. package/dist/src/entities/model/client-affiliate.entity.model.js +30 -0
  19. package/dist/src/entities/model/designation.entity.model.d.ts +4 -1
  20. package/dist/src/entities/model/designation.entity.model.js +8 -2
  21. package/dist/src/entities/model/entity.model.interface.d.ts +2 -2
  22. package/dist/src/entities/model/entity.model.interface.js +12 -7
  23. package/dist/src/entities/model/holiday.entity.model.d.ts +1 -14
  24. package/dist/src/entities/model/holiday.entity.model.js +42 -25
  25. package/dist/src/entities/model/leave.entity.model.d.ts +3 -50
  26. package/dist/src/entities/model/leave.entity.model.js +21 -154
  27. package/dist/src/entities/model/task.entity.model.d.ts +4 -1
  28. package/dist/src/entities/model/task.entity.model.js +8 -2
  29. package/dist/src/entities/model/timesheet.entity.model.d.ts +4 -1
  30. package/dist/src/entities/model/timesheet.entity.model.js +8 -2
  31. package/dist/src/entities/model/user.entity.model.d.ts +4 -1
  32. package/dist/src/entities/model/user.entity.model.js +8 -2
  33. package/dist/src/utils/helper.fn.util.d.ts +28 -0
  34. package/dist/src/utils/helper.fn.util.js +47 -2
  35. package/dist/src/utils/index.d.ts +0 -1
  36. package/dist/src/utils/index.js +0 -1
  37. package/dist/src/utils/string.util.d.ts +0 -1
  38. package/dist/src/utils/string.util.js +0 -14
  39. package/package.json +33 -33
  40. package/dist/src/entities/model/leave_count.entity.model.d.ts +0 -19
  41. package/dist/src/entities/model/leave_count.entity.model.js +0 -60
@@ -1,27 +1,44 @@
1
1
  "use strict";
2
+ // import { DateCodeModel } from "../../utils";
3
+ // import { IAuditColumnEntity } from "../interface/audit-column.entity.interface";
4
+ // import { IHolidayEntity } from "../interface/holiday.entity.interface";
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HolidayEntityModel = void 0;
4
- const entity_utils_interface_1 = require("../interface/entity.utils.interface");
5
- const base_entity_model_1 = require("./base.entity.model");
6
- // import { IHolidayApiEntity } from "law-common/dist/src/api";
7
- class HolidayEntityModel extends base_entity_model_1.BaseEntityModel {
8
- constructor() {
9
- super(...arguments);
10
- this.id = 0;
11
- this.holidayListId = 0;
12
- this.dateCode = "";
13
- this.createdBy = 0;
14
- this.updatedBy = 0;
15
- this.createdOn = "";
16
- this.updatedOn = "";
17
- }
18
- getRelationConfigs() {
19
- return [];
20
- }
21
- static fromApiEntity(apiEntity) {
22
- const entity = new HolidayEntityModel(entity_utils_interface_1.EntityEnum.HOLIDAY);
23
- Object.assign(entity, apiEntity);
24
- return entity;
25
- }
26
- }
27
- exports.HolidayEntityModel = HolidayEntityModel;
6
+ exports.toBeDeleted = void 0;
7
+ // export class BaseEntityModelV1<T extends IAuditColumnEntity> {
8
+ // createdOn: Date;
9
+ // updatedOn: Date;
10
+ // createdBy: number;
11
+ // updatedBy: number;
12
+ // constructor(data: T) {
13
+ // this.createdOn = data.createdOn;
14
+ // this.updatedOn = data.updatedOn;
15
+ // this.createdBy = data.createdBy;
16
+ // this.updatedBy = data.updatedBy;
17
+ // }
18
+ // }
19
+ // export class HolidayEntityModel
20
+ // extends BaseEntityModelV1<IHolidayEntity>
21
+ // implements IHolidayEntity
22
+ // {
23
+ // id: number;
24
+ // holidayListId: number;
25
+ // dateCode: string;
26
+ // private constructor(data: IHolidayEntity) {
27
+ // super(data);
28
+ // this.id = data.id;
29
+ // this.holidayListId = data.holidayListId;
30
+ // this.dateCode = data.dateCode;
31
+ // }
32
+ // getDateCodeModel(): DateCodeModel {
33
+ // return new DateCodeModel(this.dateCode);
34
+ // }
35
+ // static fromEntity(data: IHolidayEntity): HolidayEntityModel {
36
+ // return new HolidayEntityModel(data);
37
+ // }
38
+ // static getDateCodeModelFromDate(
39
+ // models: HolidayEntityModel[]
40
+ // ): DateCodeModel[] {
41
+ // return models.map((model) => model.getDateCodeModel());
42
+ // }
43
+ // }
44
+ exports.toBeDeleted = "holiday";
@@ -3,12 +3,7 @@ import { DateCodeModel, Weekday } from "../../utils";
3
3
  import { DurationTypeEnum } from "../enums/duration-type.enum";
4
4
  import { LeaveTypeEnum } from "../enums/leave-type.enum";
5
5
  import { LeaveStatusEnum } from "../enums/leave.status.enum";
6
- import { RelationType } from "../enums/relation-type.enum";
7
- import { EntityEnum, VirtualEntityEnum } from "../interface/entity.utils.interface";
8
- import { BaseEntityModel } from "./base.entity.model";
9
- import { LeaveCountVirtualEntityModel } from "./leave_count.entity.model";
10
- import { UserEntityModel } from "./user.entity.model";
11
- export declare class LeaveEntityModel extends BaseEntityModel<EntityEnum.LEAVE> implements ILeaveApiEntity {
6
+ export declare class LeaveEntityModel implements ILeaveApiEntity {
12
7
  id: number;
13
8
  employeeId: number;
14
9
  fromDate: string;
@@ -22,55 +17,13 @@ export declare class LeaveEntityModel extends BaseEntityModel<EntityEnum.LEAVE>
22
17
  updatedOn: string;
23
18
  createdBy: number;
24
19
  updatedBy: number;
25
- leaveCount?: LeaveCountVirtualEntityModel;
26
- createdByUser?: UserEntityModel;
27
- updatedByUser?: UserEntityModel;
28
- user?: UserEntityModel;
20
+ private constructor();
29
21
  static fromEntity(data: ILeaveApiEntity): LeaveEntityModel;
22
+ isMoreThanOneDayLeave(): boolean;
30
23
  getLeaveDuration(excludeWeekdays?: Weekday[], excludeDates?: DateCodeModel[]): number;
31
24
  static getLeaveDuration(leaves: LeaveEntityModel[], excludeWeekdays?: Weekday[], excludeDates?: DateCodeModel[], leaveStatusEnum?: LeaveStatusEnum[]): number;
32
25
  getDateCodeModels(dateCodeIncludePredicates?: ((dateModel: DateCodeModel) => boolean)[], dateCodeExcludePredicates?: ((dateModel: DateCodeModel) => boolean)[]): DateCodeModel[];
33
26
  static getLeaveApprovePredicate(): (leave: LeaveEntityModel) => boolean;
34
27
  static getLeavePendingPredicate(): (leave: LeaveEntityModel) => boolean;
35
28
  static getLeavesByPredicates(leaves: LeaveEntityModel[], includePredicates?: ((leave: LeaveEntityModel) => boolean)[], excludePredicates?: ((leave: LeaveEntityModel) => boolean)[]): LeaveEntityModel[];
36
- static orderByFromDateAsc(leaves: LeaveEntityModel[]): LeaveEntityModel[];
37
- isWeekendSucceeds(): boolean;
38
- isWeekendPrecedes(): boolean;
39
- isHolidaySucceeds(holidays: DateCodeModel[]): boolean;
40
- isHolidayPrecedes(holidays: DateCodeModel[]): boolean;
41
- getRelationConfigs(): any[];
42
- static relationConfigs: ({
43
- name: VirtualEntityEnum;
44
- relation: RelationType;
45
- key: string;
46
- mapKeyConfig: {
47
- relationKey: string;
48
- key: string;
49
- };
50
- } | {
51
- name: EntityEnum;
52
- relation: RelationType;
53
- key: string;
54
- mapKeyConfig: {
55
- relationKey: string;
56
- key: string;
57
- };
58
- })[];
59
- static fromApiEntity(apiEntity: ILeaveApiEntity): LeaveEntityModel;
60
- static getPendingApprovalStatuses(): LeaveStatusEnum[];
61
- getStatusLabel(): string;
62
- getTypeLabel(): string;
63
- getLeaveCount(): number;
64
- static getLeaveCount(leaveEntities: LeaveEntityModel[]): number;
65
- isMoreThanOneDayLeave(): boolean;
66
- getFromDateLabel(): string;
67
- getToDateLabel(): string;
68
- getDateDurationLabel(): string;
69
- static getLeaveStatusPriority(): {
70
- pending_approval: number;
71
- edit_approval: number;
72
- delete_approval: number;
73
- approved: number;
74
- rejected: number;
75
- };
76
29
  }
@@ -2,33 +2,33 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LeaveEntityModel = void 0;
4
4
  const utils_1 = require("../../utils");
5
- const string_util_1 = require("../../utils/string.util");
6
5
  const duration_type_enum_1 = require("../enums/duration-type.enum");
7
- const leave_type_enum_1 = require("../enums/leave-type.enum");
8
6
  const leave_status_enum_1 = require("../enums/leave.status.enum");
9
- const relation_type_enum_1 = require("../enums/relation-type.enum");
10
- const entity_utils_interface_1 = require("../interface/entity.utils.interface");
11
- const base_entity_model_1 = require("./base.entity.model");
12
- class LeaveEntityModel extends base_entity_model_1.BaseEntityModel {
13
- constructor() {
14
- super(...arguments);
15
- this.id = 0;
16
- this.employeeId = 0;
17
- this.fromDate = "";
18
- this.toDate = "";
19
- this.reason = "";
20
- this.durationType = duration_type_enum_1.DurationTypeEnum.FULL;
21
- this.status = leave_status_enum_1.LeaveStatusEnum.DELETED;
22
- this.type = leave_type_enum_1.LeaveTypeEnum.SICK;
7
+ class LeaveEntityModel {
8
+ constructor(data) {
23
9
  this.createdOn = "";
24
10
  this.updatedOn = "";
25
- this.createdBy = 0;
26
- this.updatedBy = 0;
11
+ this.id = data.id;
12
+ this.employeeId = data.employeeId;
13
+ this.fromDate = data.fromDate;
14
+ this.toDate = data.toDate;
15
+ this.reason = data.reason;
16
+ this.durationType = data.durationType;
17
+ this.status = data.status;
18
+ this.remark = data.remark;
19
+ this.type = data.type;
20
+ this.createdOn = data.createdOn;
21
+ this.updatedOn = data.updatedOn;
22
+ this.createdBy = data.createdBy;
23
+ this.updatedBy = data.updatedBy;
27
24
  }
28
25
  static fromEntity(data) {
29
- const entity = new LeaveEntityModel(entity_utils_interface_1.EntityEnum.LEAVE);
30
- Object.assign(entity, data);
31
- return entity;
26
+ return new LeaveEntityModel(data);
27
+ }
28
+ isMoreThanOneDayLeave() {
29
+ const fromDate = new utils_1.DateCodeModel(this.fromDate);
30
+ const toDate = new utils_1.DateCodeModel(this.toDate);
31
+ return fromDate.diffInDays(toDate) > 1;
32
32
  }
33
33
  getLeaveDuration(excludeWeekdays = [], excludeDates = []) {
34
34
  if (!this.isMoreThanOneDayLeave()) {
@@ -80,138 +80,5 @@ class LeaveEntityModel extends base_entity_model_1.BaseEntityModel {
80
80
  return leaves.filter((leave) => includePredicates.every((predicate) => predicate(leave)) &&
81
81
  excludePredicates.every((predicate) => !predicate(leave)));
82
82
  }
83
- static orderByFromDateAsc(leaves) {
84
- return leaves.sort((a, b) => {
85
- const dateA = new Date(a.fromDate);
86
- const dateB = new Date(b.fromDate);
87
- return dateA.getTime() - dateB.getTime();
88
- });
89
- }
90
- isWeekendSucceeds() {
91
- const toDate = new utils_1.DateCodeModel(this.toDate);
92
- const nextDate = toDate.getByOffset(1);
93
- return nextDate.isDayPresent([utils_1.Weekday.Saturday, utils_1.Weekday.Sunday]);
94
- }
95
- isWeekendPrecedes() {
96
- const fromDate = new utils_1.DateCodeModel(this.fromDate);
97
- const prevDate = fromDate.getByOffset(-1);
98
- return prevDate.isDayPresent([utils_1.Weekday.Saturday, utils_1.Weekday.Sunday]);
99
- }
100
- isHolidaySucceeds(holidays) {
101
- const toDate = new utils_1.DateCodeModel(this.toDate);
102
- const nextDate = toDate.getByOffset(1);
103
- return holidays.some((holiday) => holiday.isSame(nextDate));
104
- }
105
- isHolidayPrecedes(holidays) {
106
- const fromDate = new utils_1.DateCodeModel(this.fromDate);
107
- const prevDate = fromDate.getByOffset(-1);
108
- return holidays.some((holiday) => holiday.isSame(prevDate));
109
- }
110
- getRelationConfigs() {
111
- return this.constructor.prototype.constructor.relationConfigs;
112
- }
113
- static fromApiEntity(apiEntity) {
114
- return LeaveEntityModel.fromEntity(apiEntity);
115
- }
116
- static getPendingApprovalStatuses() {
117
- return [
118
- leave_status_enum_1.LeaveStatusEnum.PENDING_APPROVAL,
119
- leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL,
120
- leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL,
121
- ];
122
- }
123
- getStatusLabel() {
124
- const pendingStatuses = LeaveEntityModel.getPendingApprovalStatuses();
125
- let statusLabel = '';
126
- if (pendingStatuses.includes(this.status)) {
127
- statusLabel = 'PENDING_APPROVAL';
128
- }
129
- else if (this.status === leave_status_enum_1.LeaveStatusEnum.RESOLVE_REJECTED) {
130
- statusLabel = 'CHANGES_REJECTED';
131
- }
132
- else {
133
- statusLabel = this.status.toString();
134
- }
135
- return (0, string_util_1.formatString)(statusLabel);
136
- }
137
- getTypeLabel() {
138
- return (0, string_util_1.formatString)(this.type.toString());
139
- }
140
- getLeaveCount() {
141
- var _a;
142
- return ((_a = this.leaveCount) === null || _a === void 0 ? void 0 : _a.count) || 0;
143
- }
144
- static getLeaveCount(leaveEntities) {
145
- return leaveEntities.reduce((acc, leave) => acc + leave.getLeaveCount(), 0);
146
- }
147
- isMoreThanOneDayLeave() {
148
- const fromDate = new utils_1.DateCodeModel(this.fromDate);
149
- const toDate = new utils_1.DateCodeModel(this.toDate);
150
- return fromDate.diffInDays(toDate) > 1;
151
- }
152
- getFromDateLabel() {
153
- const statues = [duration_type_enum_1.DurationTypeEnum.SECOND, duration_type_enum_1.DurationTypeEnum.SECOND_FULL, duration_type_enum_1.DurationTypeEnum.SECOND_FIRST];
154
- if (statues.includes(this.durationType)) {
155
- return 'Second Half';
156
- }
157
- return 'Full Day';
158
- }
159
- getToDateLabel() {
160
- const statues = [duration_type_enum_1.DurationTypeEnum.FIRST, duration_type_enum_1.DurationTypeEnum.FULL_FIRST, duration_type_enum_1.DurationTypeEnum.SECOND_FIRST];
161
- if (statues.includes(this.durationType)) {
162
- return 'First Half';
163
- }
164
- return 'Full Day';
165
- }
166
- getDateDurationLabel() {
167
- if (!this.isMoreThanOneDayLeave()) {
168
- return `${new utils_1.DateCodeModel(this.fromDate).getFormattedDateWithMonthName()} ${this.durationType === duration_type_enum_1.DurationTypeEnum.FULL ? '(Full Day)' : this.durationType === duration_type_enum_1.DurationTypeEnum.FIRST ? '(First Half)' : '(Second Half)'}`;
169
- }
170
- return `${new utils_1.DateCodeModel(this.fromDate).getFormattedDateWithMonthName()} (${this.getFromDateLabel()}) - ${new utils_1.DateCodeModel(this.toDate).getFormattedDateWithMonthName()} (${this.getToDateLabel()})`;
171
- }
172
- static getLeaveStatusPriority() {
173
- return {
174
- [leave_status_enum_1.LeaveStatusEnum.PENDING_APPROVAL]: 1,
175
- [leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL]: 2,
176
- [leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL]: 3,
177
- [leave_status_enum_1.LeaveStatusEnum.APPROVED]: 4,
178
- [leave_status_enum_1.LeaveStatusEnum.REJECTED]: 5,
179
- };
180
- }
181
83
  }
182
84
  exports.LeaveEntityModel = LeaveEntityModel;
183
- LeaveEntityModel.relationConfigs = [
184
- {
185
- name: entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT,
186
- relation: relation_type_enum_1.RelationType.ONE,
187
- key: 'leaveCount',
188
- mapKeyConfig: {
189
- relationKey: 'leaveId',
190
- key: 'id',
191
- },
192
- }, {
193
- name: entity_utils_interface_1.EntityEnum.USER,
194
- relation: relation_type_enum_1.RelationType.ONE,
195
- key: 'createdByUser',
196
- mapKeyConfig: {
197
- relationKey: 'id',
198
- key: 'createdBy',
199
- },
200
- }, {
201
- name: entity_utils_interface_1.EntityEnum.USER,
202
- relation: relation_type_enum_1.RelationType.ONE,
203
- key: 'updatedByUser',
204
- mapKeyConfig: {
205
- relationKey: 'id',
206
- key: 'updatedBy',
207
- },
208
- }, {
209
- name: entity_utils_interface_1.EntityEnum.USER,
210
- relation: relation_type_enum_1.RelationType.ONE,
211
- key: 'user',
212
- mapKeyConfig: {
213
- relationKey: 'id',
214
- key: 'employeeId',
215
- },
216
- }
217
- ];
@@ -1,6 +1,8 @@
1
1
  import { ITaskApiEntity } from "../../api";
2
2
  import { TaskStatusEnum, TaskTypeEnum } from "../enums/task.entity.enum";
3
- export declare class TaskEntityModel implements ITaskApiEntity {
3
+ import { EntityEnum } from "../interface/entity.utils.interface";
4
+ import { BaseEntityModel } from "./base.entity.model";
5
+ export declare class TaskEntityModel extends BaseEntityModel<EntityEnum.TASK> implements ITaskApiEntity {
4
6
  id: number;
5
7
  name: string;
6
8
  description: string;
@@ -11,4 +13,5 @@ export declare class TaskEntityModel implements ITaskApiEntity {
11
13
  createdOn: string;
12
14
  updatedOn: string;
13
15
  static fromApiEntity(apiEntity: ITaskApiEntity): TaskEntityModel;
16
+ getRelationConfigs(): any[];
14
17
  }
@@ -2,8 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TaskEntityModel = void 0;
4
4
  const task_entity_enum_1 = require("../enums/task.entity.enum");
5
- class TaskEntityModel {
5
+ const entity_utils_interface_1 = require("../interface/entity.utils.interface");
6
+ const base_entity_model_1 = require("./base.entity.model");
7
+ class TaskEntityModel extends base_entity_model_1.BaseEntityModel {
6
8
  constructor() {
9
+ super(...arguments);
7
10
  this.id = 0;
8
11
  this.name = "";
9
12
  this.description = "";
@@ -15,9 +18,12 @@ class TaskEntityModel {
15
18
  this.updatedOn = "";
16
19
  }
17
20
  static fromApiEntity(apiEntity) {
18
- const entity = new TaskEntityModel();
21
+ const entity = new TaskEntityModel(entity_utils_interface_1.EntityEnum.TASK);
19
22
  Object.assign(entity, apiEntity);
20
23
  return entity;
21
24
  }
25
+ getRelationConfigs() {
26
+ return this.constructor.prototype.constructor.relationConfigs || [];
27
+ }
22
28
  }
23
29
  exports.TaskEntityModel = TaskEntityModel;
@@ -1,6 +1,8 @@
1
1
  import { ITimesheetApiEntity } from "../../api";
2
2
  import { TimesheetStatusEnum } from "../enums/timesheet.status.enum";
3
- export declare class TimesheetEntityModel implements ITimesheetApiEntity {
3
+ import { EntityEnum } from "../interface/entity.utils.interface";
4
+ import { BaseEntityModel } from "./base.entity.model";
5
+ export declare class TimesheetEntityModel extends BaseEntityModel<EntityEnum.TIMESHEET> implements ITimesheetApiEntity {
4
6
  id: number;
5
7
  userId: number;
6
8
  projectId: number;
@@ -15,4 +17,5 @@ export declare class TimesheetEntityModel implements ITimesheetApiEntity {
15
17
  createdOn: string;
16
18
  updatedOn: string;
17
19
  static fromApiEntity(apiEntity: ITimesheetApiEntity): TimesheetEntityModel;
20
+ getRelationConfigs(): any[];
18
21
  }
@@ -2,8 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TimesheetEntityModel = void 0;
4
4
  const timesheet_status_enum_1 = require("../enums/timesheet.status.enum");
5
- class TimesheetEntityModel {
5
+ const entity_utils_interface_1 = require("../interface/entity.utils.interface");
6
+ const base_entity_model_1 = require("./base.entity.model");
7
+ class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
6
8
  constructor() {
9
+ super(...arguments);
7
10
  this.id = 0;
8
11
  this.userId = 0;
9
12
  this.projectId = 0;
@@ -17,9 +20,12 @@ class TimesheetEntityModel {
17
20
  this.updatedOn = "";
18
21
  }
19
22
  static fromApiEntity(apiEntity) {
20
- const entity = new TimesheetEntityModel();
23
+ const entity = new TimesheetEntityModel(entity_utils_interface_1.EntityEnum.TIMESHEET);
21
24
  Object.assign(entity, apiEntity);
22
25
  return entity;
23
26
  }
27
+ getRelationConfigs() {
28
+ return this.constructor.prototype.constructor.relationConfigs || [];
29
+ }
24
30
  }
25
31
  exports.TimesheetEntityModel = TimesheetEntityModel;
@@ -1,6 +1,8 @@
1
1
  import { IUserApiEntity } from "../../api";
2
2
  import { UserRoleEnum, UserStatusEnum } from "../enums/user.entity.enum";
3
- export declare class UserEntityModel implements IUserApiEntity {
3
+ import { EntityEnum } from "../interface/entity.utils.interface";
4
+ import { BaseEntityModel } from "./base.entity.model";
5
+ export declare class UserEntityModel extends BaseEntityModel<EntityEnum.USER> implements IUserApiEntity {
4
6
  id: number;
5
7
  name: string;
6
8
  email: string;
@@ -39,5 +41,6 @@ export declare class UserEntityModel implements IUserApiEntity {
39
41
  updatedBy: number;
40
42
  createdOn: string;
41
43
  updatedOn: string;
44
+ getRelationConfigs(): any[];
42
45
  static fromApiEntity(apiEntity: IUserApiEntity): UserEntityModel;
43
46
  }
@@ -2,8 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserEntityModel = void 0;
4
4
  const user_entity_enum_1 = require("../enums/user.entity.enum");
5
- class UserEntityModel {
5
+ const entity_utils_interface_1 = require("../interface/entity.utils.interface");
6
+ const base_entity_model_1 = require("./base.entity.model");
7
+ class UserEntityModel extends base_entity_model_1.BaseEntityModel {
6
8
  constructor() {
9
+ super(...arguments);
7
10
  this.id = 0;
8
11
  this.name = "";
9
12
  this.email = "";
@@ -21,8 +24,11 @@ class UserEntityModel {
21
24
  this.createdOn = "";
22
25
  this.updatedOn = "";
23
26
  }
27
+ getRelationConfigs() {
28
+ return this.constructor.prototype.constructor.relationConfigs || [];
29
+ }
24
30
  static fromApiEntity(apiEntity) {
25
- const entity = new UserEntityModel();
31
+ const entity = new UserEntityModel(entity_utils_interface_1.EntityEnum.USER);
26
32
  Object.assign(entity, apiEntity);
27
33
  return entity;
28
34
  }
@@ -211,6 +211,20 @@ export declare function areDecimalNumbersEqual(firstValue: number, secondValue:
211
211
  */
212
212
  export declare function formatIndianNumber(amount: number | string): string;
213
213
  export declare function findDuplicateIds(ids: number[]): number[];
214
+ /**
215
+ * Converts a string or number into a number with fixed decimal precision.
216
+ *
217
+ * @param value - The input value to convert. Can be a numeric string or a number.
218
+ * @param placesAfterDecimal - Number of digits to keep after the decimal point (default: 2).
219
+ * @returns The numeric value rounded to the specified number of decimal places.
220
+ * @throws {Error} If the input cannot be converted to a valid number.
221
+ *
222
+ * @example
223
+ * getDecimalNumberFromString("42.5678"); // 42.57
224
+ * getDecimalNumberFromString(42.5678, 3); // 42.568
225
+ * getDecimalNumberFromString("100"); // 100
226
+ * getDecimalNumberFromString("abc"); // throws Error("Invalid number: abc")
227
+ */
214
228
  export declare function getDecimalNumberFromString(value: string | number, placesAfterDecimal?: number): number;
215
229
  /**
216
230
  * Recursively checks if a specified property exists in an object or its nested objects.
@@ -241,3 +255,17 @@ export declare function getDecimalNumberFromString(value: string | number, place
241
255
  * ```
242
256
  */
243
257
  export declare function hasProperty<T extends object>(obj: T | null | undefined, propName: string): boolean;
258
+ /**
259
+ * Safely converts a given value (string or number) to a number.
260
+ *
261
+ * @template T - The input type, constrained to `string | number`.
262
+ * @param value - The value to convert. Can be a number or a numeric string.
263
+ * @returns The numeric representation of the input.
264
+ * @throws {Error} If the input cannot be converted to a valid number.
265
+ *
266
+ * @example
267
+ * convertToNumberType("42"); // 42
268
+ * convertToNumberType(3.14); // 3.14
269
+ * convertToNumberType("abc"); // throws Error("Invalid number: abc")
270
+ */
271
+ export declare function convertToNumberType<T extends string | number>(value: T): number;
@@ -38,6 +38,7 @@ exports.formatIndianNumber = formatIndianNumber;
38
38
  exports.findDuplicateIds = findDuplicateIds;
39
39
  exports.getDecimalNumberFromString = getDecimalNumberFromString;
40
40
  exports.hasProperty = hasProperty;
41
+ exports.convertToNumberType = convertToNumberType;
41
42
  const util_constants_1 = require("../constants/util.constants");
42
43
  const error_key_enum_1 = require("../enums/error.key.enum");
43
44
  const exceptions_1 = require("../exceptions");
@@ -464,9 +465,30 @@ function findDuplicateIds(ids) {
464
465
  }
465
466
  return Array.from(duplicates);
466
467
  }
468
+ /**
469
+ * Converts a string or number into a number with fixed decimal precision.
470
+ *
471
+ * @param value - The input value to convert. Can be a numeric string or a number.
472
+ * @param placesAfterDecimal - Number of digits to keep after the decimal point (default: 2).
473
+ * @returns The numeric value rounded to the specified number of decimal places.
474
+ * @throws {Error} If the input cannot be converted to a valid number.
475
+ *
476
+ * @example
477
+ * getDecimalNumberFromString("42.5678"); // 42.57
478
+ * getDecimalNumberFromString(42.5678, 3); // 42.568
479
+ * getDecimalNumberFromString("100"); // 100
480
+ * getDecimalNumberFromString("abc"); // throws Error("Invalid number: abc")
481
+ */
467
482
  function getDecimalNumberFromString(value, placesAfterDecimal = 2) {
468
- // this method should internally handle if the value is number or string
469
- return Number(Number(value).toFixed(placesAfterDecimal));
483
+ if (typeof value === "number") {
484
+ // Already a number, just round it
485
+ return Number(value.toFixed(placesAfterDecimal));
486
+ }
487
+ const num = Number(value);
488
+ if (Number.isNaN(num)) {
489
+ throw new Error(`Invalid number: ${value}`);
490
+ }
491
+ return Number(num.toFixed(placesAfterDecimal));
470
492
  }
471
493
  /**
472
494
  * Recursively checks if a specified property exists in an object or its nested objects.
@@ -519,3 +541,26 @@ function hasProperty(obj, propName) {
519
541
  }
520
542
  return false;
521
543
  }
544
+ /**
545
+ * Safely converts a given value (string or number) to a number.
546
+ *
547
+ * @template T - The input type, constrained to `string | number`.
548
+ * @param value - The value to convert. Can be a number or a numeric string.
549
+ * @returns The numeric representation of the input.
550
+ * @throws {Error} If the input cannot be converted to a valid number.
551
+ *
552
+ * @example
553
+ * convertToNumberType("42"); // 42
554
+ * convertToNumberType(3.14); // 3.14
555
+ * convertToNumberType("abc"); // throws Error("Invalid number: abc")
556
+ */
557
+ function convertToNumberType(value) {
558
+ if (typeof value === "number") {
559
+ return value;
560
+ }
561
+ const num = Number(value);
562
+ if (Number.isNaN(num)) {
563
+ throw new Error(`Invalid number: ${value}`);
564
+ }
565
+ return num;
566
+ }
@@ -1,4 +1,3 @@
1
1
  export * from "./date.util";
2
2
  export * from "./helper.fn.util";
3
3
  export * from "./models/date-code.model.util";
4
- export * from "./string.util";
@@ -17,4 +17,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./date.util"), exports);
18
18
  __exportStar(require("./helper.fn.util"), exports);
19
19
  __exportStar(require("./models/date-code.model.util"), exports);
20
- __exportStar(require("./string.util"), exports);
@@ -1 +0,0 @@
1
- export declare function formatString(input: string): string;
@@ -1,15 +1 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatString = formatString;
4
- function formatString(input) {
5
- if (input.includes('_')) {
6
- return input
7
- .split('_')
8
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
9
- .join(' ');
10
- }
11
- else {
12
- // For single-word strings, capitalize the first letter
13
- return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase();
14
- }
15
- }