law-common 1.2.58-beta.13 → 1.2.58-beta.15

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.
@@ -57,3 +57,4 @@ export * from "./interface/role.permission.mapping.delete.dto.interface";
57
57
  export * from "./interface/billing.transaction.create.dto.interface";
58
58
  export * from "./interface/billing.transaction.update.dto.interface";
59
59
  export * from "./interface/billing.transaction.entity.response";
60
+ export * from "./interface/billing.flow.update.dto";
@@ -73,3 +73,4 @@ __exportStar(require("./interface/role.permission.mapping.delete.dto.interface")
73
73
  __exportStar(require("./interface/billing.transaction.create.dto.interface"), exports);
74
74
  __exportStar(require("./interface/billing.transaction.update.dto.interface"), exports);
75
75
  __exportStar(require("./interface/billing.transaction.entity.response"), exports);
76
+ __exportStar(require("./interface/billing.flow.update.dto"), exports);
@@ -0,0 +1,4 @@
1
+ import { BillingStatusActions } from "../../entities";
2
+ export interface IBillingFlowUpdateDto {
3
+ action: BillingStatusActions;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -11,3 +11,18 @@ export declare enum StatusEnum {
11
11
  PENDING_PAYMENT = "PENDING_PAYMENT",
12
12
  PAYMENT_DONE = "PAYMENT_DONE"
13
13
  }
14
+ export declare enum BillingStatusActions {
15
+ APPROVE = "approve",
16
+ REJECT = "reject",
17
+ EDIT = "edit",
18
+ REQUEST_FOR_CHANGES = "requestForChanges",
19
+ SENT_FOR_APPROVAL = "sentForApproval",
20
+ SEND_FOR_CLIENT_REVIEW = "sendForClientReview",
21
+ CLIENT_REVISION = "clientRevision",
22
+ SEND_INVOICE = "sendInvoice",
23
+ APPROVAL = "approval",
24
+ UPDATE_PAYMENT = "updatePayment",
25
+ CREDIT_NOTE = "creditNote",
26
+ WRITE_OFF = "writeOff",
27
+ TDS = "tds"
28
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StatusEnum = void 0;
3
+ exports.BillingStatusActions = exports.StatusEnum = void 0;
4
4
  var StatusEnum;
5
5
  (function (StatusEnum) {
6
6
  StatusEnum["PENDING_APPROVAL"] = "PENDING_APPROVAL";
@@ -15,3 +15,19 @@ var StatusEnum;
15
15
  StatusEnum["PENDING_PAYMENT"] = "PENDING_PAYMENT";
16
16
  StatusEnum["PAYMENT_DONE"] = "PAYMENT_DONE";
17
17
  })(StatusEnum || (exports.StatusEnum = StatusEnum = {}));
18
+ var BillingStatusActions;
19
+ (function (BillingStatusActions) {
20
+ BillingStatusActions["APPROVE"] = "approve";
21
+ BillingStatusActions["REJECT"] = "reject";
22
+ BillingStatusActions["EDIT"] = "edit";
23
+ BillingStatusActions["REQUEST_FOR_CHANGES"] = "requestForChanges";
24
+ BillingStatusActions["SENT_FOR_APPROVAL"] = "sentForApproval";
25
+ BillingStatusActions["SEND_FOR_CLIENT_REVIEW"] = "sendForClientReview";
26
+ BillingStatusActions["CLIENT_REVISION"] = "clientRevision";
27
+ BillingStatusActions["SEND_INVOICE"] = "sendInvoice";
28
+ BillingStatusActions["APPROVAL"] = "approval";
29
+ BillingStatusActions["UPDATE_PAYMENT"] = "updatePayment";
30
+ BillingStatusActions["CREDIT_NOTE"] = "creditNote";
31
+ BillingStatusActions["WRITE_OFF"] = "writeOff";
32
+ BillingStatusActions["TDS"] = "tds";
33
+ })(BillingStatusActions || (exports.BillingStatusActions = BillingStatusActions = {}));
@@ -36,5 +36,6 @@ export interface IUserEntity extends IAuditColumnEntity {
36
36
  secondEmergencyContactName?: string;
37
37
  secondaryEmergencyContactNo?: string;
38
38
  secondaryEmergencyContactRelation?: string;
39
+ permissions?: string[];
39
40
  }
40
41
  export type IUserEntityFilterData = IEntityFilterData<IUserEntity>;
@@ -1,3 +1,4 @@
1
+ import { IEntityFilterData } from "../entities";
1
2
  export declare function groupByFunction<T, K>(list: T[], keyGetter: (input: T) => K): Map<K, T[]>;
2
3
  export declare function groupByOneToOneFunction<T, K>(list: T[], keyGetter: (input: T) => K): Map<K, T>;
3
4
  export declare function convertMapToObject<K, T>(map: Map<K, T>): {
@@ -81,9 +82,36 @@ export declare function arrayIntersectionWith<T>(source: T[], target: T[], compa
81
82
  */
82
83
  export declare function arrayUnion<T>(source: T[], target: T[]): T[];
83
84
  export declare function sumArray<T>(array: T[], key: keyof T): number;
85
+ /**
86
+ * Compares existing and incoming arrays and returns the added, deleted, and present elements.
87
+ *
88
+ * @template T - The type of elements in the arrays.
89
+ * @param {T[]} existing - The existing array.
90
+ * @param {T[]} incoming - The incoming array.
91
+ * @returns {{ added: T[]; deleted: T[]; present: T[] }} An object containing arrays of added, deleted, and present elements.
92
+ *
93
+ * @example
94
+ * const existing = [1, 2, 3];
95
+ * const incoming = [2, 3, 4];
96
+ * const result = newRemoved(existing, incoming);
97
+ * console.log(result); // Output: { added: [4], deleted: [1], present: [2, 3, 4] }
98
+ */
84
99
  export declare function newRemoved<T>(existing: T[], incoming: T[]): {
85
100
  added: T[];
86
101
  deleted: T[];
87
102
  present: T[];
88
103
  };
89
104
  export declare function getEnumNames(enumType: object): string[];
105
+ export declare function getFilterByPermission<T>(permissionFilterConfig: {
106
+ [key: string]: IEntityFilterData<T>;
107
+ }, propertyName: keyof T, userPermission: string, filterDto: IEntityFilterData<T>, emptyValue?: any): {
108
+ [x: string]: any;
109
+ };
110
+ export declare function getFilterByPermissionFn<T>(permissionFilterConfig: {
111
+ [key: string]: () => Promise<IEntityFilterData<T>>;
112
+ }, propertyName: keyof T, userPermission: string, filterDto: IEntityFilterData<T>, emptyValue?: any): Promise<{
113
+ [x: string]: any;
114
+ }>;
115
+ export declare function getPropertyFilterByPermissionFn<T>(permissionFilterConfig: {
116
+ [key: string]: () => Promise<IEntityFilterData<T>>;
117
+ }, propertyNames: (keyof T)[], userPermission: string, filterDto: IEntityFilterData<T>, emptyValue?: any): Promise<IEntityFilterData<T>>;
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.groupByFunction = groupByFunction;
4
13
  exports.groupByOneToOneFunction = groupByOneToOneFunction;
@@ -12,6 +21,9 @@ exports.arrayUnion = arrayUnion;
12
21
  exports.sumArray = sumArray;
13
22
  exports.newRemoved = newRemoved;
14
23
  exports.getEnumNames = getEnumNames;
24
+ exports.getFilterByPermission = getFilterByPermission;
25
+ exports.getFilterByPermissionFn = getFilterByPermissionFn;
26
+ exports.getPropertyFilterByPermissionFn = getPropertyFilterByPermissionFn;
15
27
  function groupByFunction(list, keyGetter) {
16
28
  const map = new Map();
17
29
  list.forEach((item) => {
@@ -138,6 +150,20 @@ function arrayUnion(source, target) {
138
150
  function sumArray(array, key) {
139
151
  return array.reduce((acc, item) => acc + Number(item[key]), 0);
140
152
  }
153
+ /**
154
+ * Compares existing and incoming arrays and returns the added, deleted, and present elements.
155
+ *
156
+ * @template T - The type of elements in the arrays.
157
+ * @param {T[]} existing - The existing array.
158
+ * @param {T[]} incoming - The incoming array.
159
+ * @returns {{ added: T[]; deleted: T[]; present: T[] }} An object containing arrays of added, deleted, and present elements.
160
+ *
161
+ * @example
162
+ * const existing = [1, 2, 3];
163
+ * const incoming = [2, 3, 4];
164
+ * const result = newRemoved(existing, incoming);
165
+ * console.log(result); // Output: { added: [4], deleted: [1], present: [2, 3, 4] }
166
+ */
141
167
  function newRemoved(existing, incoming) {
142
168
  existing = existing || [];
143
169
  incoming = incoming || [];
@@ -149,3 +175,57 @@ function newRemoved(existing, incoming) {
149
175
  function getEnumNames(enumType) {
150
176
  return Object.values(enumType).filter((value) => typeof value === "string");
151
177
  }
178
+ function getFilterByPermission(permissionFilterConfig, propertyName, userPermission, filterDto, emptyValue = []) {
179
+ const dtoFilter = filterDto[propertyName];
180
+ const permissionFilter = permissionFilterConfig[userPermission][propertyName];
181
+ const isDtoFilterIdPresent = dtoFilter && dtoFilter.length > 0;
182
+ const isPermissionFilterIdPresent = permissionFilter && permissionFilter.length > 0;
183
+ return {
184
+ [propertyName]: isPermissionFilterIdPresent
185
+ ? isDtoFilterIdPresent
186
+ ? arrayIntersection(permissionFilter, dtoFilter).length > 0
187
+ ? arrayIntersection(permissionFilter, dtoFilter)
188
+ : emptyValue
189
+ : permissionFilter
190
+ : dtoFilter,
191
+ };
192
+ }
193
+ function getFilterByPermissionFn(permissionFilterConfig_1, propertyName_1, userPermission_1, filterDto_1) {
194
+ return __awaiter(this, arguments, void 0, function* (permissionFilterConfig, propertyName, userPermission, filterDto, emptyValue = []) {
195
+ const filterData = yield permissionFilterConfig[userPermission]();
196
+ const dtoFilter = filterDto[propertyName];
197
+ const permissionFilter = filterData[propertyName];
198
+ const isDtoFilterIdPresent = dtoFilter && dtoFilter.length > 0;
199
+ const isPermissionFilterIdPresent = permissionFilter && permissionFilter.length > 0;
200
+ return {
201
+ [propertyName]: isPermissionFilterIdPresent
202
+ ? isDtoFilterIdPresent
203
+ ? arrayIntersection(permissionFilter, dtoFilter).length > 0
204
+ ? arrayIntersection(permissionFilter, dtoFilter)
205
+ : emptyValue
206
+ : permissionFilter
207
+ : dtoFilter,
208
+ };
209
+ });
210
+ }
211
+ function getPropertyFilterByPermissionFn(permissionFilterConfig_1, propertyNames_1, userPermission_1, filterDto_1) {
212
+ return __awaiter(this, arguments, void 0, function* (permissionFilterConfig, propertyNames, userPermission, filterDto, emptyValue = []) {
213
+ const filterData = yield permissionFilterConfig[userPermission]();
214
+ const result = {};
215
+ for (const propertyName of propertyNames) {
216
+ const dtoFilter = filterDto[propertyName];
217
+ const permissionFilter = filterData[propertyName];
218
+ const isDtoFilterIdPresent = dtoFilter && dtoFilter.length > 0;
219
+ const isPermissionFilterIdPresent = permissionFilter && permissionFilter.length > 0;
220
+ result[propertyName] =
221
+ isPermissionFilterIdPresent
222
+ ? isDtoFilterIdPresent
223
+ ? arrayIntersection(permissionFilter, dtoFilter).length > 0
224
+ ? arrayIntersection(permissionFilter, dtoFilter)
225
+ : emptyValue
226
+ : permissionFilter
227
+ : dtoFilter;
228
+ }
229
+ return result;
230
+ });
231
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "1.2.58-beta.13",
3
+ "version": "1.2.58-beta.15",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [