law-common 10.28.2-beta.9 → 10.30.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.
- package/dist/src/api/interface/address-book.update.dto.interface.d.ts +2 -4
- package/dist/src/api/interface/address-book.update.dto.interface.js +7 -0
- package/dist/src/api/interface/timesheet.entity.response.interface.d.ts +1 -5
- package/dist/src/entities/index.d.ts +0 -1
- package/dist/src/entities/index.js +0 -1
- package/dist/src/entities/interface/entity.utils.interface.d.ts +2 -3
- package/dist/src/entities/interface/rate.entity.interface.d.ts +1 -2
- package/dist/src/entities/model/entity.model.interface.d.ts +3 -0
- package/dist/src/entities/model/entity.model.interface.js +9 -0
- package/dist/src/utils/object.util.d.ts +10 -0
- package/dist/src/utils/object.util.js +134 -0
- package/package.json +35 -35
- package/dist/src/entities/interface/audit-column.entity.interface.d.ts +0 -6
- package/dist/src/entities/interface/audit-column.entity.interface.js +0 -2
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAddressBookCreateDto } from "./address-book.create.dto.interface";
|
|
2
2
|
import { DeepPartialButRequired } from "./api.utils.interface";
|
|
3
|
-
export type IAddressBookUpdateDto = DeepPartialButRequired<
|
|
4
|
-
contactDetails?: DeepPartialButRequired<IAddressBookContactDetail, 'id'>[];
|
|
5
|
-
};
|
|
3
|
+
export type IAddressBookUpdateDto = DeepPartialButRequired<IAddressBookCreateDto, never>;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// export type IAddressBookUpdateDto = DeepPartialButRequired<
|
|
4
|
+
// Omit<IAddressBookCreateDto, 'contactDetails'>,
|
|
5
|
+
// never
|
|
6
|
+
// > & {
|
|
7
|
+
// contactDetails?: DeepPartialButRequired<IAddressBookContactDetail, 'id'>[]; // id required per item
|
|
8
|
+
// // address?: DeepPartial<IAddressBookAddress>;
|
|
9
|
+
// };
|
|
3
10
|
// const a: IAddressBookUpdateDto = {
|
|
4
11
|
// organizationName: "Test Name",
|
|
5
12
|
// contactDetails: [
|
|
@@ -21,6 +21,7 @@ export type ITimesheetFlowConfig = {
|
|
|
21
21
|
permissions: string[];
|
|
22
22
|
isApplicable?: (data: ITimesheetFlowContextData) => boolean;
|
|
23
23
|
next: (data: ITimesheetFlowContextData) => TimesheetStatusEnum;
|
|
24
|
+
validActionPastThreshold?: boolean;
|
|
24
25
|
};
|
|
25
26
|
};
|
|
26
27
|
};
|
|
@@ -32,8 +33,3 @@ export type ITimesheetFlowContextData = {
|
|
|
32
33
|
dto: ITimesheetEntityUpdateDto;
|
|
33
34
|
timesheetEnterThresholdValue: number;
|
|
34
35
|
};
|
|
35
|
-
export type ITimesheetFlowAfterTimesheetEnterThreshold = {
|
|
36
|
-
[key in TimesheetStatusEnum]?: {
|
|
37
|
-
validActions: TimesheetActionEnum[];
|
|
38
|
-
};
|
|
39
|
-
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from "./enums/task.entity.enum";
|
|
2
2
|
export * from "./enums/user.entity.enum";
|
|
3
3
|
export * from "./enums/organization.entity.enum";
|
|
4
|
-
export * from "./interface/audit-column.entity.interface";
|
|
5
4
|
export * from "./interface/entity.utils.interface";
|
|
6
5
|
export * from "./interface/organization.entity.interface";
|
|
7
6
|
export * from "./interface/task.entity.interface";
|
|
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./enums/task.entity.enum"), exports);
|
|
18
18
|
__exportStar(require("./enums/user.entity.enum"), exports);
|
|
19
19
|
__exportStar(require("./enums/organization.entity.enum"), exports);
|
|
20
|
-
__exportStar(require("./interface/audit-column.entity.interface"), exports);
|
|
21
20
|
__exportStar(require("./interface/entity.utils.interface"), exports);
|
|
22
21
|
__exportStar(require("./interface/organization.entity.interface"), exports);
|
|
23
22
|
__exportStar(require("./interface/task.entity.interface"), exports);
|
|
@@ -24,7 +24,6 @@ import { TaskEntityModel } from "../model/task.entity.model";
|
|
|
24
24
|
import { TimesheetEntityModel } from "../model/timesheet.entity.model";
|
|
25
25
|
import { UserEntityModel } from "../model/user.entity.model";
|
|
26
26
|
import { IAddressBookEntity } from "./address-book.entity.interface";
|
|
27
|
-
import { IAuditColumnEntity } from "./audit-column.entity.interface";
|
|
28
27
|
import { IBankEntity } from "./bank.entity.interface";
|
|
29
28
|
import { IBankHistoryEntity } from "./bank_history.entity.interface";
|
|
30
29
|
import { IBillingReimbursementExpenseEntity } from "./billing-reimbursement-expense.entity.interface";
|
|
@@ -67,8 +66,8 @@ export type IApiEntity<T> = Modify<T, {
|
|
|
67
66
|
createdOn: string;
|
|
68
67
|
updatedOn: string;
|
|
69
68
|
}>;
|
|
70
|
-
export type IEntityCreateDto<T> = Omit<T, "id" | keyof
|
|
71
|
-
export type IEntityUpdateDto<T> = Omit<Partial<T>, "id" | keyof
|
|
69
|
+
export type IEntityCreateDto<T> = Omit<T, "id" | keyof IEntityAuditColumn>;
|
|
70
|
+
export type IEntityUpdateDto<T> = Omit<Partial<T>, "id" | keyof IEntityAuditColumn>;
|
|
72
71
|
/**
|
|
73
72
|
* EntityEnum
|
|
74
73
|
*
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CurrencyEnum, TimeUnitEnum } from "../../enums";
|
|
2
2
|
import { PartialBy } from "../../misc";
|
|
3
|
-
import { IAuditColumnEntity } from "./audit-column.entity.interface";
|
|
4
3
|
import { IEntityAuditColumn } from "./entity-audit-columns.interface";
|
|
5
4
|
import { IEntityCreateDto, IEntityFilterData, IEntityUpdateDto } from "./entity.utils.interface";
|
|
6
5
|
export interface IRateEntity extends IEntityAuditColumn {
|
|
@@ -14,6 +13,6 @@ export interface IRateEntityCreateDto extends IEntityCreateDto<IRateEntity> {
|
|
|
14
13
|
}
|
|
15
14
|
export interface IRateEntityUpdateDto extends IEntityUpdateDto<IRateEntity> {
|
|
16
15
|
}
|
|
17
|
-
export interface IRateEntityUpdateByDesignationCurrencyDto extends PartialBy<Omit<IRateEntity, "id" | keyof
|
|
16
|
+
export interface IRateEntityUpdateByDesignationCurrencyDto extends PartialBy<Omit<IRateEntity, "id" | keyof IEntityAuditColumn>, "unit"> {
|
|
18
17
|
}
|
|
19
18
|
export type IRateEntityFilterData = IEntityFilterData<IRateEntity>;
|
|
@@ -36,4 +36,7 @@ export declare class EntityModelRelationHelper {
|
|
|
36
36
|
addEntity<T extends EntityEnum | VirtualEntityEnum>(entity: EnumEntityType<T>, entityEnum: T, config?: {
|
|
37
37
|
populateRelations?: boolean;
|
|
38
38
|
}): void;
|
|
39
|
+
updateEntityModel<T extends EntityEnum | VirtualEntityEnum>(entityModel: BaseEntityModel<T>, config?: {
|
|
40
|
+
populateRelations?: boolean;
|
|
41
|
+
}): void;
|
|
39
42
|
}
|
|
@@ -200,5 +200,14 @@ class EntityModelRelationHelper {
|
|
|
200
200
|
}
|
|
201
201
|
this.addEntityModel(this.fromEntityToEntityModel(entity, entityEnum), config);
|
|
202
202
|
}
|
|
203
|
+
updateEntityModel(entityModel, config = { populateRelations: false }) {
|
|
204
|
+
const entityEnum = entityModel.entityName;
|
|
205
|
+
this.entityModelIndexMap[entityEnum] = this.entityModelIndexMap[entityEnum] || {};
|
|
206
|
+
// @ts-ignore
|
|
207
|
+
this.entityModelIndexMap[entityEnum][entityModel.id] = entityModel;
|
|
208
|
+
if (config.populateRelations) {
|
|
209
|
+
this.populateRelationsByEntityModel(entityModel);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
203
212
|
}
|
|
204
213
|
exports.EntityModelRelationHelper = EntityModelRelationHelper;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
class ObjectComparator {
|
|
3
|
+
constructor(incoming, existing) {
|
|
4
|
+
this.incoming = incoming;
|
|
5
|
+
this.existing = existing;
|
|
6
|
+
}
|
|
7
|
+
compare() {
|
|
8
|
+
return this.deepDiff(this.incoming, this.existing);
|
|
9
|
+
}
|
|
10
|
+
deepDiff(a, b) {
|
|
11
|
+
// Handle null/undefined cases
|
|
12
|
+
if (a == null && b == null) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
if (a == null || b == null) {
|
|
16
|
+
return a;
|
|
17
|
+
}
|
|
18
|
+
// Handle primitives (loose equality)
|
|
19
|
+
if (typeof a !== "object") {
|
|
20
|
+
return a == b ? undefined : a;
|
|
21
|
+
}
|
|
22
|
+
// a is object or array
|
|
23
|
+
if (Array.isArray(a)) {
|
|
24
|
+
// Handle as array
|
|
25
|
+
const diffArr = new Array(a.length);
|
|
26
|
+
let hasDiff = false;
|
|
27
|
+
for (let i = 0; i < a.length; i++) {
|
|
28
|
+
const subB = Array.isArray(b) && i < b.length ? b[i] : undefined;
|
|
29
|
+
const subDiff = this.deepDiff(a[i], subB);
|
|
30
|
+
if (subDiff !== undefined) {
|
|
31
|
+
diffArr[i] = subDiff;
|
|
32
|
+
hasDiff = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return hasDiff ? diffArr : undefined;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// Handle as object
|
|
39
|
+
const diff = {};
|
|
40
|
+
let hasDiff = false;
|
|
41
|
+
for (const key of Object.keys(a)) {
|
|
42
|
+
const subDiff = this.deepDiff(a[key], b === null || b === void 0 ? void 0 : b[key]);
|
|
43
|
+
if (subDiff !== undefined) {
|
|
44
|
+
diff[key] = subDiff;
|
|
45
|
+
hasDiff = true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return hasDiff ? diff : undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// // Comprehensive Usage Examples
|
|
53
|
+
// // Example 1: Simple object with primitive differences
|
|
54
|
+
// console.log("Example 1: Simple object");
|
|
55
|
+
// const incoming1 = { name: "Alice", age: 30, city: "New York" };
|
|
56
|
+
// const existing1 = { name: "Bob", age: 30, city: "Boston" };
|
|
57
|
+
// const comparator1 = new ObjectComparator(incoming1, existing1);
|
|
58
|
+
// console.log(comparator1.compare()); // Output: { name: 'Alice', city: 'New York' }
|
|
59
|
+
// // Example 2: Nested objects
|
|
60
|
+
// console.log("Example 2: Nested objects");
|
|
61
|
+
// const incoming2 = {
|
|
62
|
+
// user: { id: 1, profile: { email: "alice@example.com", phone: "123-456" } },
|
|
63
|
+
// settings: { theme: "dark", notifications: true },
|
|
64
|
+
// };
|
|
65
|
+
// const existing2 = {
|
|
66
|
+
// user: { id: 1, profile: { email: "bob@example.com" } },
|
|
67
|
+
// settings: { theme: "light" },
|
|
68
|
+
// };
|
|
69
|
+
// const comparator2 = new ObjectComparator(incoming2, existing2);
|
|
70
|
+
// console.log(comparator2.compare());
|
|
71
|
+
// // Output: {
|
|
72
|
+
// // user: { profile: { email: 'alice@example.com', phone: '123-456' } },
|
|
73
|
+
// // settings: { theme: 'dark', notifications: true }
|
|
74
|
+
// // }
|
|
75
|
+
// // Example 3: Array of primitives
|
|
76
|
+
// console.log("Example 3: Array of primitives");
|
|
77
|
+
// const incoming3 = { scores: [95, 87, 100] };
|
|
78
|
+
// const existing3 = { scores: [80, 87, 90] };
|
|
79
|
+
// const comparator3 = new ObjectComparator(incoming3, existing3);
|
|
80
|
+
// console.log(comparator3.compare()); // Output: { scores: [95, undefined, 100] }
|
|
81
|
+
// // Example 4: Array of objects
|
|
82
|
+
// console.log("Example 4: Array of objects");
|
|
83
|
+
// const incoming4 = {
|
|
84
|
+
// items: [
|
|
85
|
+
// { id: 1, name: "Item A", price: 10 },
|
|
86
|
+
// { id: 2, name: "Item B", price: 20 },
|
|
87
|
+
// { id: 3, name: "Item C", price: 30 },
|
|
88
|
+
// ],
|
|
89
|
+
// };
|
|
90
|
+
// const existing4 = {
|
|
91
|
+
// items: [
|
|
92
|
+
// { id: 1, name: "Item A", price: 15 },
|
|
93
|
+
// { id: 2, name: "Item X", price: 20 },
|
|
94
|
+
// ],
|
|
95
|
+
// };
|
|
96
|
+
// const comparator4 = new ObjectComparator(incoming4, existing4);
|
|
97
|
+
// console.log(comparator4.compare());
|
|
98
|
+
// // Output: {
|
|
99
|
+
// // items: [
|
|
100
|
+
// // { price: 10 },
|
|
101
|
+
// // { name: 'Item B' },
|
|
102
|
+
// // { id: 3, name: 'Item C', price: 30 }
|
|
103
|
+
// // ]
|
|
104
|
+
// // }
|
|
105
|
+
// // Example 5: Mixed structure with missing properties and nulls
|
|
106
|
+
// console.log("Example 5: Mixed with nulls and missing");
|
|
107
|
+
// const incoming5 = {
|
|
108
|
+
// data: {
|
|
109
|
+
// value: null,
|
|
110
|
+
// list: [1, 2, { nested: "hello" }],
|
|
111
|
+
// extra: "new",
|
|
112
|
+
// },
|
|
113
|
+
// };
|
|
114
|
+
// const existing5 = {
|
|
115
|
+
// data: {
|
|
116
|
+
// value: 42,
|
|
117
|
+
// list: [1, 3],
|
|
118
|
+
// },
|
|
119
|
+
// };
|
|
120
|
+
// const comparator5 = new ObjectComparator(incoming5, existing5);
|
|
121
|
+
// console.log(comparator5.compare());
|
|
122
|
+
// // Output: {
|
|
123
|
+
// // data: {
|
|
124
|
+
// // value: null,
|
|
125
|
+
// // list: [undefined, 2, { nested: 'hello' }],
|
|
126
|
+
// // extra: 'new'
|
|
127
|
+
// // }
|
|
128
|
+
// // }
|
|
129
|
+
// // Example 6: No differences
|
|
130
|
+
// console.log("Example 6: No differences");
|
|
131
|
+
// const incoming6 = { a: 1, b: { c: [true] } };
|
|
132
|
+
// const existing6 = { a: 1, b: { c: [true] } };
|
|
133
|
+
// const comparator6 = new ObjectComparator(incoming6, existing6);
|
|
134
|
+
// console.log(comparator6.compare()); // Output: {}
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "law-common",
|
|
3
|
-
"version": "10.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist/**/*"
|
|
8
|
-
],
|
|
9
|
-
"scripts": {
|
|
10
|
-
"clean": "rm -rf dist",
|
|
11
|
-
"build": "npm run clean && tsc",
|
|
12
|
-
"publish:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
|
|
13
|
-
"publish:patch": "npm version patch && git push && npm run build && npm publish",
|
|
14
|
-
"publish:minor": "npm version minor && git push && npm run build && npm publish",
|
|
15
|
-
"publish:major": "npm version major && git push && npm run build && npm publish",
|
|
16
|
-
"link": "npm run build && npm link",
|
|
17
|
-
"test": "jest"
|
|
18
|
-
},
|
|
19
|
-
"keywords": [],
|
|
20
|
-
"author": "",
|
|
21
|
-
"license": "ISC",
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"@types/jest": "^29.5.13",
|
|
24
|
-
"@types/node": "^22.6.1",
|
|
25
|
-
"jest": "^29.7.0",
|
|
26
|
-
"ts-jest": "^29.2.5",
|
|
27
|
-
"ts-node": "^10.9.2",
|
|
28
|
-
"typescript": "^5.6.2"
|
|
29
|
-
},
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"@types/express": "^5.0.0",
|
|
32
|
-
"@types/multer": "^1.4.12",
|
|
33
|
-
"date-fns": "^4.1.0"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "law-common",
|
|
3
|
+
"version": "10.30.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/**/*"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": "rm -rf dist",
|
|
11
|
+
"build": "npm run clean && tsc",
|
|
12
|
+
"publish:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
|
|
13
|
+
"publish:patch": "npm version patch && git push && npm run build && npm publish",
|
|
14
|
+
"publish:minor": "npm version minor && git push && npm run build && npm publish",
|
|
15
|
+
"publish:major": "npm version major && git push && npm run build && npm publish",
|
|
16
|
+
"link": "npm run build && npm link",
|
|
17
|
+
"test": "jest"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [],
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/jest": "^29.5.13",
|
|
24
|
+
"@types/node": "^22.6.1",
|
|
25
|
+
"jest": "^29.7.0",
|
|
26
|
+
"ts-jest": "^29.2.5",
|
|
27
|
+
"ts-node": "^10.9.2",
|
|
28
|
+
"typescript": "^5.6.2"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@types/express": "^5.0.0",
|
|
32
|
+
"@types/multer": "^1.4.12",
|
|
33
|
+
"date-fns": "^4.1.0"
|
|
34
|
+
}
|
|
35
|
+
}
|