law-common 1.2.58-beta.9 → 2.0.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/index.d.ts +6 -0
- package/dist/src/api/index.js +6 -0
- package/dist/src/api/interface/billing.create.dto.interface.d.ts +1 -0
- package/dist/src/api/interface/billing.entity.response.d.ts +19 -2
- package/dist/src/api/interface/billing.flow.update.dto.d.ts +4 -0
- package/dist/src/api/interface/billing.flow.update.dto.js +2 -0
- package/dist/src/api/interface/billing.transaction.create.dto.interface.d.ts +3 -0
- package/dist/src/api/interface/billing.transaction.create.dto.interface.js +2 -0
- package/dist/src/api/interface/billing.transaction.entity.response.d.ts +8 -0
- package/dist/src/api/interface/billing.transaction.entity.response.js +2 -0
- package/dist/src/api/interface/billing.transaction.update.dto.interface.d.ts +3 -0
- package/dist/src/api/interface/billing.transaction.update.dto.interface.js +2 -0
- package/dist/src/api/interface/billing.update.dto.interface.d.ts +3 -2
- package/dist/src/api/interface/role.permission.mapping.delete.dto.interface.d.ts +3 -0
- package/dist/src/api/interface/role.permission.mapping.delete.dto.interface.js +2 -0
- package/dist/src/api/interface/role.permission.mapping.response.d.ts +5 -0
- package/dist/src/api/interface/role.permission.mapping.response.js +2 -0
- package/dist/src/entities/enums/billing.status.enum.d.ts +27 -8
- package/dist/src/entities/enums/billing.status.enum.js +31 -11
- package/dist/src/entities/enums/billing.transaction.enum.d.ts +10 -0
- package/dist/src/entities/enums/billing.transaction.enum.js +23 -0
- package/dist/src/entities/enums/user.entity.enum.d.ts +1 -0
- package/dist/src/entities/enums/user.entity.enum.js +7 -0
- package/dist/src/entities/index.d.ts +2 -0
- package/dist/src/entities/index.js +2 -0
- package/dist/src/entities/interface/billing.entity.interface.d.ts +5 -2
- package/dist/src/entities/interface/billing_transaction.entity.interface.d.ts +11 -0
- package/dist/src/entities/interface/billing_transaction.entity.interface.js +2 -0
- package/dist/src/entities/interface/user.entity.interface.d.ts +1 -0
- package/dist/src/utils/helper.fn.util.d.ts +28 -0
- package/dist/src/utils/helper.fn.util.js +80 -0
- package/package.json +35 -34
package/dist/src/api/index.d.ts
CHANGED
|
@@ -52,3 +52,9 @@ export * from "./interface/permission.entity.api";
|
|
|
52
52
|
export * from "./interface/role.permission.mapping.create.dto.interface";
|
|
53
53
|
export * from "./interface/role.permission.mapping.entity.api";
|
|
54
54
|
export * from "./interface/role.permission.mapping.update.dto.interface";
|
|
55
|
+
export * from "./interface/role.permission.mapping.response";
|
|
56
|
+
export * from "./interface/role.permission.mapping.delete.dto.interface";
|
|
57
|
+
export * from "./interface/billing.transaction.create.dto.interface";
|
|
58
|
+
export * from "./interface/billing.transaction.update.dto.interface";
|
|
59
|
+
export * from "./interface/billing.transaction.entity.response";
|
|
60
|
+
export * from "./interface/billing.flow.update.dto";
|
package/dist/src/api/index.js
CHANGED
|
@@ -68,3 +68,9 @@ __exportStar(require("./interface/permission.entity.api"), exports);
|
|
|
68
68
|
__exportStar(require("./interface/role.permission.mapping.create.dto.interface"), exports);
|
|
69
69
|
__exportStar(require("./interface/role.permission.mapping.entity.api"), exports);
|
|
70
70
|
__exportStar(require("./interface/role.permission.mapping.update.dto.interface"), exports);
|
|
71
|
+
__exportStar(require("./interface/role.permission.mapping.response"), exports);
|
|
72
|
+
__exportStar(require("./interface/role.permission.mapping.delete.dto.interface"), exports);
|
|
73
|
+
__exportStar(require("./interface/billing.transaction.create.dto.interface"), exports);
|
|
74
|
+
__exportStar(require("./interface/billing.transaction.update.dto.interface"), exports);
|
|
75
|
+
__exportStar(require("./interface/billing.transaction.entity.response"), exports);
|
|
76
|
+
__exportStar(require("./interface/billing.flow.update.dto"), exports);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAuditColumnEntity, IBillingTimesheetDetail, PaymentStatusEnum,
|
|
1
|
+
import { IAuditColumnEntity, IBillingTimesheetDetail, PaymentStatusEnum, BillingStatusEnum } from "../../entities";
|
|
2
2
|
import { IBillingApiEntity } from "./billing.entity.api";
|
|
3
3
|
import { IBillingTimesheetApiEntity } from "./billing.timesheet.entity.api";
|
|
4
4
|
export interface IBillingEntityResponse extends IAuditColumnEntity {
|
|
@@ -11,7 +11,7 @@ export interface IBillingEntityResponse extends IAuditColumnEntity {
|
|
|
11
11
|
invoiceNumber?: number;
|
|
12
12
|
paymentStatus: PaymentStatusEnum;
|
|
13
13
|
billingTimesheets: IBillingTimesheetDetail[];
|
|
14
|
-
status?:
|
|
14
|
+
status?: BillingStatusEnum;
|
|
15
15
|
writeoffAmount?: number;
|
|
16
16
|
}
|
|
17
17
|
export type IBillingEntityGet = {
|
|
@@ -19,6 +19,23 @@ export type IBillingEntityGet = {
|
|
|
19
19
|
billingTimesheets: IBillingTimesheetApiEntity[];
|
|
20
20
|
};
|
|
21
21
|
export type IBillingEntityUpdateGet = {
|
|
22
|
+
id: number;
|
|
23
|
+
startDate: string;
|
|
24
|
+
endDate: string;
|
|
25
|
+
projectId: number;
|
|
26
|
+
totalAmount: number;
|
|
27
|
+
totalMinutes: number;
|
|
28
|
+
paymentStatus: PaymentStatusEnum;
|
|
29
|
+
status: BillingStatusEnum;
|
|
30
|
+
invoiceNumber?: number;
|
|
31
|
+
writeoffAmount: number;
|
|
32
|
+
totalAmountPaid: number;
|
|
33
|
+
tdsAmount: number;
|
|
34
|
+
creditNoteAmount: number;
|
|
35
|
+
createdOn: string;
|
|
36
|
+
updatedOn: string;
|
|
37
|
+
createdBy: number;
|
|
38
|
+
updatedBy: number;
|
|
22
39
|
timesheets: IBillingTimesheetApiEntity[];
|
|
23
40
|
};
|
|
24
41
|
export type IBillingEntityGetArray = IBillingEntityGet[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IApiEntity, IBillingTransactionEntity } from "../../entities";
|
|
2
|
+
import { IBillingApiEntity } from "./billing.entity.api";
|
|
3
|
+
export type IBillingTransactionApiEntity = IApiEntity<IBillingTransactionEntity>;
|
|
4
|
+
export type IBillingTransactionApiEntityArray = IBillingTransactionApiEntity[];
|
|
5
|
+
export type IBillingTransactionEntityGet = {
|
|
6
|
+
billingTransaction: IBillingTransactionApiEntity;
|
|
7
|
+
billing: IBillingApiEntity;
|
|
8
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BillingImpactEnum, BillingTimesheetStatusEnum, IBillingEntity, IBillingTimesheetEntity, IEntityUpdateDto } from "../../entities";
|
|
1
|
+
import { BillingImpactEnum, BillingActionsEnum, BillingTimesheetStatusEnum, IBillingEntity, IBillingTimesheetEntity, IEntityUpdateDto } from "../../entities";
|
|
2
2
|
export interface IBillingUpdateDto extends IEntityUpdateDto<IBillingEntity> {
|
|
3
3
|
}
|
|
4
4
|
export interface IBillingTimesheetUpdateDto extends IEntityUpdateDto<IBillingTimesheetEntity> {
|
|
@@ -15,6 +15,7 @@ export interface IBillingTimesheetDeleteDto extends Partial<IBillingTimesheetEnt
|
|
|
15
15
|
id: number;
|
|
16
16
|
changedStatus: BillingTimesheetStatusEnum;
|
|
17
17
|
}
|
|
18
|
-
export interface IUpdateBillingDto {
|
|
18
|
+
export interface IUpdateBillingDto extends IBillingUpdateDto {
|
|
19
|
+
action?: BillingActionsEnum;
|
|
19
20
|
timesheets?: IBillingTimesheetUpdateDto[];
|
|
20
21
|
}
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
export declare enum
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
CANCELLED = "CANCELLED"
|
|
1
|
+
export declare enum BillingStatusEnum {
|
|
2
|
+
PENDING_APPROVAL = "PENDING_APPROVAL",
|
|
3
|
+
REQUEST_CHANGES = "REQUEST_CHANGES",
|
|
4
|
+
CHANGES_SAVED = "CHANGES_SAVED",
|
|
5
|
+
INTERNAL_APPROVED = "INTERNAL_APPROVED",
|
|
6
|
+
PENDING_CLIENT_REVIEW = "PENDING_CLIENT_REVIEW",
|
|
7
|
+
CLIENT_REVISION_APPROVAL = "CLIENT_REVISION_APPROVAL",
|
|
8
|
+
CANCELLED = "CANCELLED",
|
|
9
|
+
REJECT_CLIENT_REVISION = "REJECT_CLIENT_REVISION",
|
|
10
|
+
INVOICE_SENT = "INVOICE_SENT",
|
|
11
|
+
PENDING_PAYMENT = "PENDING_PAYMENT",
|
|
12
|
+
PAYMENT_DONE = "PAYMENT_DONE"
|
|
13
|
+
}
|
|
14
|
+
export declare enum BillingActionsEnum {
|
|
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"
|
|
9
28
|
}
|
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
(function (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
exports.BillingActionsEnum = exports.BillingStatusEnum = void 0;
|
|
4
|
+
var BillingStatusEnum;
|
|
5
|
+
(function (BillingStatusEnum) {
|
|
6
|
+
BillingStatusEnum["PENDING_APPROVAL"] = "PENDING_APPROVAL";
|
|
7
|
+
BillingStatusEnum["REQUEST_CHANGES"] = "REQUEST_CHANGES";
|
|
8
|
+
BillingStatusEnum["CHANGES_SAVED"] = "CHANGES_SAVED";
|
|
9
|
+
BillingStatusEnum["INTERNAL_APPROVED"] = "INTERNAL_APPROVED";
|
|
10
|
+
BillingStatusEnum["PENDING_CLIENT_REVIEW"] = "PENDING_CLIENT_REVIEW";
|
|
11
|
+
BillingStatusEnum["CLIENT_REVISION_APPROVAL"] = "CLIENT_REVISION_APPROVAL";
|
|
12
|
+
BillingStatusEnum["CANCELLED"] = "CANCELLED";
|
|
13
|
+
BillingStatusEnum["REJECT_CLIENT_REVISION"] = "REJECT_CLIENT_REVISION";
|
|
14
|
+
BillingStatusEnum["INVOICE_SENT"] = "INVOICE_SENT";
|
|
15
|
+
BillingStatusEnum["PENDING_PAYMENT"] = "PENDING_PAYMENT";
|
|
16
|
+
BillingStatusEnum["PAYMENT_DONE"] = "PAYMENT_DONE";
|
|
17
|
+
})(BillingStatusEnum || (exports.BillingStatusEnum = BillingStatusEnum = {}));
|
|
18
|
+
var BillingActionsEnum;
|
|
19
|
+
(function (BillingActionsEnum) {
|
|
20
|
+
BillingActionsEnum["APPROVE"] = "approve";
|
|
21
|
+
BillingActionsEnum["REJECT"] = "reject";
|
|
22
|
+
BillingActionsEnum["EDIT"] = "edit";
|
|
23
|
+
BillingActionsEnum["REQUEST_FOR_CHANGES"] = "requestForChanges";
|
|
24
|
+
BillingActionsEnum["SENT_FOR_APPROVAL"] = "sentForApproval";
|
|
25
|
+
BillingActionsEnum["SEND_FOR_CLIENT_REVIEW"] = "sendForClientReview";
|
|
26
|
+
BillingActionsEnum["CLIENT_REVISION"] = "clientRevision";
|
|
27
|
+
BillingActionsEnum["SEND_INVOICE"] = "sendInvoice";
|
|
28
|
+
BillingActionsEnum["APPROVAL"] = "approval";
|
|
29
|
+
BillingActionsEnum["UPDATE_PAYMENT"] = "updatePayment";
|
|
30
|
+
BillingActionsEnum["CREDIT_NOTE"] = "creditNote";
|
|
31
|
+
BillingActionsEnum["WRITE_OFF"] = "writeOff";
|
|
32
|
+
BillingActionsEnum["TDS"] = "tds";
|
|
33
|
+
})(BillingActionsEnum || (exports.BillingActionsEnum = BillingActionsEnum = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare enum BillingTransactionType {
|
|
2
|
+
TDS = "TDS",
|
|
3
|
+
WRITE_OFF = "WRITE_OFF",
|
|
4
|
+
CREDIT_NOTE = "CREDIT_NOTE",
|
|
5
|
+
PAYMENT = "PAYMENT"
|
|
6
|
+
}
|
|
7
|
+
export declare namespace BillingTransactionType {
|
|
8
|
+
function getNames(): string[];
|
|
9
|
+
function parse(value: string): BillingTransactionType;
|
|
10
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BillingTransactionType = void 0;
|
|
4
|
+
var BillingTransactionType;
|
|
5
|
+
(function (BillingTransactionType) {
|
|
6
|
+
BillingTransactionType["TDS"] = "TDS";
|
|
7
|
+
BillingTransactionType["WRITE_OFF"] = "WRITE_OFF";
|
|
8
|
+
BillingTransactionType["CREDIT_NOTE"] = "CREDIT_NOTE";
|
|
9
|
+
BillingTransactionType["PAYMENT"] = "PAYMENT";
|
|
10
|
+
})(BillingTransactionType || (exports.BillingTransactionType = BillingTransactionType = {}));
|
|
11
|
+
(function (BillingTransactionType) {
|
|
12
|
+
function getNames() {
|
|
13
|
+
return Object.values(BillingTransactionType).filter((value) => typeof value === "string");
|
|
14
|
+
}
|
|
15
|
+
BillingTransactionType.getNames = getNames;
|
|
16
|
+
function parse(value) {
|
|
17
|
+
if (Object.values(BillingTransactionType).includes(value)) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
throw new Error("Invalid Billing Transaction Type");
|
|
21
|
+
}
|
|
22
|
+
BillingTransactionType.parse = parse;
|
|
23
|
+
})(BillingTransactionType || (exports.BillingTransactionType = BillingTransactionType = {}));
|
|
@@ -22,6 +22,13 @@ var UserRoleEnum;
|
|
|
22
22
|
return Object.values(UserRoleEnum).filter((value) => typeof value === "string");
|
|
23
23
|
}
|
|
24
24
|
UserRoleEnum.getNames = getNames;
|
|
25
|
+
function parse(value) {
|
|
26
|
+
if (Object.values(UserRoleEnum).includes(value)) {
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
throw new Error("Invalid user role");
|
|
30
|
+
}
|
|
31
|
+
UserRoleEnum.parse = parse;
|
|
25
32
|
})(UserRoleEnum || (exports.UserRoleEnum = UserRoleEnum = {}));
|
|
26
33
|
(function (UserStatusEnum) {
|
|
27
34
|
function getNames() {
|
|
@@ -32,3 +32,5 @@ export * from "./interface/client_affiliate_entity.interface";
|
|
|
32
32
|
export * from "./interface/role.entity.interface";
|
|
33
33
|
export * from "./interface/permission.entity.interface";
|
|
34
34
|
export * from "./interface/role.permission.mapping.entity.interface";
|
|
35
|
+
export * from "./interface/billing_transaction.entity.interface";
|
|
36
|
+
export * from "./enums/billing.transaction.enum";
|
|
@@ -48,3 +48,5 @@ __exportStar(require("./interface/client_affiliate_entity.interface"), exports);
|
|
|
48
48
|
__exportStar(require("./interface/role.entity.interface"), exports);
|
|
49
49
|
__exportStar(require("./interface/permission.entity.interface"), exports);
|
|
50
50
|
__exportStar(require("./interface/role.permission.mapping.entity.interface"), exports);
|
|
51
|
+
__exportStar(require("./interface/billing_transaction.entity.interface"), exports);
|
|
52
|
+
__exportStar(require("./enums/billing.transaction.enum"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BillingImpactEnum } from "../enums/billing.impact.enum";
|
|
2
|
-
import {
|
|
2
|
+
import { BillingStatusEnum } from "../enums/billing.status.enum";
|
|
3
3
|
import { BillingTimesheetStatusEnum } from "../enums/billing.timesheet.change.status.enum";
|
|
4
4
|
import { PaymentStatusEnum } from "../enums/payment_status.enum";
|
|
5
5
|
import { IAuditColumnEntity } from "./audit-column.entity.interface";
|
|
@@ -13,8 +13,11 @@ export interface IBillingEntity extends IAuditColumnEntity {
|
|
|
13
13
|
totalMinutes: number;
|
|
14
14
|
invoiceNumber?: number;
|
|
15
15
|
paymentStatus: PaymentStatusEnum;
|
|
16
|
-
status:
|
|
16
|
+
status: BillingStatusEnum;
|
|
17
17
|
writeoffAmount: number;
|
|
18
|
+
totalAmountPaid: number;
|
|
19
|
+
tdsAmount: number;
|
|
20
|
+
creditNoteAmount: number;
|
|
18
21
|
}
|
|
19
22
|
export interface IBillingTimesheetEntity extends IAuditColumnEntity {
|
|
20
23
|
id: number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BillingTransactionType } from "../enums/billing.transaction.enum";
|
|
2
|
+
import { IAuditColumnEntity } from "./audit-column.entity.interface";
|
|
3
|
+
import { IEntityFilterData } from "./entity.utils.interface";
|
|
4
|
+
export interface IBillingTransactionEntity extends IAuditColumnEntity {
|
|
5
|
+
id: number;
|
|
6
|
+
billingId: number;
|
|
7
|
+
type: BillingTransactionType;
|
|
8
|
+
amount: number;
|
|
9
|
+
details: string;
|
|
10
|
+
}
|
|
11
|
+
export type IBillingTransactionEntityFilterData = IEntityFilterData<IBillingTransactionEntity>;
|
|
@@ -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,34 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "law-common",
|
|
3
|
+
"version": "2.0.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
|
+
}
|