law-common 10.72.9 → 10.72.10
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/entities/interface/aggregation.utils.d.ts +39 -0
- package/dist/src/entities/interface/aggregation.utils.js +16 -0
- package/dist/src/entities/interface/entity.utils.interface.d.ts +13 -0
- package/dist/src/entities/model/entity.model.interface.d.ts +2 -6
- package/dist/src/entities/model/entity.model.interface.js +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IEntityServiceResponse } from "./entity.utils.interface";
|
|
2
|
+
export declare enum AggregationOperation {
|
|
3
|
+
SUM = "sum",
|
|
4
|
+
MAX = "max",
|
|
5
|
+
MIN = "min",
|
|
6
|
+
COUNT = "count",
|
|
7
|
+
AVG = "avg"
|
|
8
|
+
}
|
|
9
|
+
export declare enum RetainEntities {
|
|
10
|
+
YES = "yes",
|
|
11
|
+
NO = "no"
|
|
12
|
+
}
|
|
13
|
+
export type NumericKeys<T> = {
|
|
14
|
+
[K in keyof T]: T[K] extends number ? K : never;
|
|
15
|
+
}[keyof T];
|
|
16
|
+
export type AggregationFields<T> = {
|
|
17
|
+
[K in NumericKeys<T> as `sum_${string & K}`]?: number;
|
|
18
|
+
} & {
|
|
19
|
+
[K in NumericKeys<T> as `avg_${string & K}`]?: number;
|
|
20
|
+
} & {
|
|
21
|
+
[K in keyof T as `max_${string & K}`]?: number;
|
|
22
|
+
} & {
|
|
23
|
+
[K in keyof T as `min_${string & K}`]?: number;
|
|
24
|
+
} & {
|
|
25
|
+
[K in keyof T as `count_${string & K}`]?: number;
|
|
26
|
+
};
|
|
27
|
+
export interface IEntityAggregationConfig<T> {
|
|
28
|
+
retainEntities: boolean;
|
|
29
|
+
groupingBy: (keyof T)[];
|
|
30
|
+
sum?: NumericKeys<T>[];
|
|
31
|
+
max?: (keyof T)[];
|
|
32
|
+
min?: (keyof T)[];
|
|
33
|
+
count?: (keyof T)[];
|
|
34
|
+
avg?: NumericKeys<T>[];
|
|
35
|
+
}
|
|
36
|
+
export interface IBaseEntityServiceResponseWithAggregation<T> {
|
|
37
|
+
baseEntities: (T & AggregationFields<T>)[] | T[];
|
|
38
|
+
relatedEntities?: IEntityServiceResponse;
|
|
39
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RetainEntities = exports.AggregationOperation = void 0;
|
|
4
|
+
var AggregationOperation;
|
|
5
|
+
(function (AggregationOperation) {
|
|
6
|
+
AggregationOperation["SUM"] = "sum";
|
|
7
|
+
AggregationOperation["MAX"] = "max";
|
|
8
|
+
AggregationOperation["MIN"] = "min";
|
|
9
|
+
AggregationOperation["COUNT"] = "count";
|
|
10
|
+
AggregationOperation["AVG"] = "avg";
|
|
11
|
+
})(AggregationOperation || (exports.AggregationOperation = AggregationOperation = {}));
|
|
12
|
+
var RetainEntities;
|
|
13
|
+
(function (RetainEntities) {
|
|
14
|
+
RetainEntities["YES"] = "yes";
|
|
15
|
+
RetainEntities["NO"] = "no";
|
|
16
|
+
})(RetainEntities || (exports.RetainEntities = RetainEntities = {}));
|
|
@@ -71,6 +71,7 @@ import { WebsiteNewsletterSubscriptionEntityModel } from "../model/website_newsl
|
|
|
71
71
|
import { WorkFromHomeEntityModel } from "../model/work-from-home.entity.model";
|
|
72
72
|
import { WorkFromHomeHistoryEntityModel } from "../model/work_from_home_history.entity.model";
|
|
73
73
|
import { IAddressBookEntity } from "./address-book.entity.interface";
|
|
74
|
+
import { AggregationFields, IEntityAggregationConfig } from "./aggregation.utils";
|
|
74
75
|
import { IBankEntity } from "./bank.entity.interface";
|
|
75
76
|
import { IBankHistoryEntity } from "./bank_history.entity.interface";
|
|
76
77
|
import { IBillingReimbursementExpenseHistoryEntity } from "./billing-reimbursement-expense-history.entity.interface";
|
|
@@ -248,12 +249,18 @@ export type IBaseEntityServiceResponse<T> = {
|
|
|
248
249
|
baseEntities: T[];
|
|
249
250
|
relatedEntities?: IEntityServiceResponse;
|
|
250
251
|
virtualEntities?: IEntityServiceResponse;
|
|
252
|
+
aggregateEntities?: {
|
|
253
|
+
[key in EntityEnum | VirtualEntityEnum]?: any[];
|
|
254
|
+
};
|
|
251
255
|
};
|
|
252
256
|
export type IBaseEntityApiResponse<T> = {
|
|
253
257
|
baseEntities: T[];
|
|
254
258
|
relatedEntities?: {
|
|
255
259
|
[K in EntityEnum | VirtualEntityEnum]?: IBaseEntityApiResponse<EnumEntityType<K>>;
|
|
256
260
|
};
|
|
261
|
+
aggregateEntities?: {
|
|
262
|
+
[key in EntityEnum | VirtualEntityEnum]?: AggregationFields<EnumToModel<key>>[];
|
|
263
|
+
};
|
|
257
264
|
};
|
|
258
265
|
export type EnumEntityType<T extends EntityEnum | VirtualEntityEnum> = (T extends EntityEnum.BILLING ? IBillingEntity : T extends EntityEnum.BILLING_HISTORY ? IBillingHistoryEntity : T extends EntityEnum.BILLING_TIMESHEET ? IBillingTimesheetEntity : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? IBillingReimbursementExpenseEntity : T extends EntityEnum.BILLING_TIMESHEET_HISTORY ? IBillingTimesheetHistoryEntity : T extends EntityEnum.BILLING_REIMBURESMENT_EXPENSE_HISTORY ? IBillingReimbursementExpenseHistoryEntity : T extends EntityEnum.TIMESHEET ? ITimesheetEntity : T extends EntityEnum.USER ? IUserEntity : T extends EntityEnum.PROJECT ? IProjectEntity : T extends EntityEnum.CLIENT ? IClientEntity : T extends EntityEnum.LEAVE ? ILeaveEntity : T extends EntityEnum.BANK ? IBankEntity : T extends EntityEnum.BILLING_TRANSACTION ? IBillingTransactionEntity : T extends EntityEnum.BILLING_TRANSACTION_HISTORY ? IBillingTransactionHistoryEntity : T extends EntityEnum.CLIENT_AFFILIATE ? IClientAffiliateEntity : T extends EntityEnum.CONFIGURATION ? IConfigurationEntity : T extends EntityEnum.HOLIDAY ? IHolidayEntity : T extends EntityEnum.HOLIDAY_LIST ? IHolidayListEntity : T extends EntityEnum.COUNTRY ? ICountryEntity : T extends EntityEnum.EXPENSE_TYPE ? IExpenseTypeEntity : T extends EntityEnum.INDUSTRY ? IIndustryEntity : T extends EntityEnum.INTERMEDIARY_BANK ? IIntermediaryBankEntity : T extends EntityEnum.OFFICE_LOCATION ? IOfficeLocationEntity : T extends EntityEnum.PERMISSION ? IPermissionEntity : T extends EntityEnum.ROLE ? IRoleEntity : T extends EntityEnum.TASK ? ITaskEntity : T extends EntityEnum.DESIGNATION ? IDesignationEntity : T extends EntityEnum.RATE ? IRateEntity : T extends EntityEnum.REIMBURSEMENT ? IReimbursementEntity : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? IReimbursementExpenseEntity : T extends EntityEnum.REIMBURSEMENT_HISTORY ? IReimbursementHistoryEntity : T extends EntityEnum.WORK_FROM_HOME ? IWorkFromHomeEntity : T extends EntityEnum.ORGANIZATION ? IOrganizationEntity : T extends EntityEnum.PROJECT_USER_MAPPING ? IProjectUserMappingEntity : T extends EntityEnum.CLIENT_USER_MAPPING ? IClientUserMappingEntity : T extends EntityEnum.CLIENT_INTRODUCING_MAPPING ? IClientIntroducingMappingEntity : T extends EntityEnum.TO_DO_LIST ? IToDoListEntity : T extends EntityEnum.CRON_JOBS ? ICronJobsEntity : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? IRolePermissionMappingEntity : T extends EntityEnum.BANK_HISTORY ? IBankHistoryEntity : T extends VirtualEntityEnum.LEAVE_COUNT ? ILeaveCountVirtualEntity : T extends EntityEnum.LEAVE_HISTORY ? ILeaveHistoryEntity : T extends EntityEnum.WORK_FROM_HOME_HISTORY ? IWorkFromHomeHistoryEntity : T extends EntityEnum.TIMESHEET_HISTORY ? ITimesheetHistoryEntity : T extends EntityEnum.ADDRESS_BOOK ? IAddressBookEntity : T extends EntityEnum.STATE ? IStateEntity : T extends EntityEnum.GST_RATE ? IGstRateEntity : T extends EntityEnum.ORGANIZATION_TYPE ? IOrganizationTypeEntity : T extends EntityEnum.TDS_RATE ? ITdsRateEntity : T extends EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING ? IOrganizationTypeTdsRateMappingEntity : T extends EntityEnum.VOUCHER_TYPE ? IVoucherTypeEntity : T extends EntityEnum.TDS_RATE_VOUCHER_TYPE_MAPPING ? ITdsRateVoucherTypeMappingEntity : T extends EntityEnum.EXPENSE_HEAD ? IExpenseHeadEntity : T extends EntityEnum.DOCUMENT_UPLOAD ? IDocumentUploadEntity : T extends EntityEnum.VENDOR ? IVendorEntity : T extends EntityEnum.VENDOR_INVOICE ? IVendorInvoiceEntity : T extends EntityEnum.VENDOR_INVOICE_HISTORY ? IVendorInvoiceHistoryEntity : T extends EntityEnum.VENDOR_INVOICE_HISTORY ? IVendorInvoiceHistoryEntity : T extends EntityEnum.VENDOR_INVOICE_ITEM ? IVendorInvoiceItemEntity : T extends EntityEnum.VENDOR_INVOICE_ITEM_HISTORY ? IVendorInvoiceItemHistoryEntity : T extends EntityEnum.VENDOR_HISTORY ? IVendorHistoryEntity : T extends EntityEnum.WEBSITE_LEAD ? IWebsiteLeadEntity : T extends EntityEnum.WEBSITE_NEWSLETTER_SUBSCRIPTION ? IWebsiteNewsletterSubscriptionEntity : T extends EntityEnum.CLIENT_QUOTE ? IClientQuoteEntity : T extends EntityEnum.CLIENT_QUOTE_RATE ? IClientQuoteRateEntity : T extends EntityEnum.BILLING_PROFILE ? IBillingProfileEntity : T extends EntityEnum.PROJECT_REVENUE_SPLIT_MAPPING ? IProjectRevenueSplitMappingEntity : T extends EntityEnum.VENDOR_INVOICE_ITEM_HISTORY ? IVendorInvoiceItemHistoryEntity : T extends EntityEnum.VENDOR_HISTORY ? IVendorHistoryEntity : T extends EntityEnum.WEBSITE_LEAD ? IWebsiteLeadEntity : T extends EntityEnum.WEBSITE_NEWSLETTER_SUBSCRIPTION ? IWebsiteNewsletterSubscriptionEntity : T extends EntityEnum.CLIENT_QUOTE ? IClientQuoteEntity : T extends EntityEnum.CLIENT_QUOTE_RATE ? IClientQuoteRateEntity : never) & {
|
|
259
266
|
id: number;
|
|
@@ -299,6 +306,7 @@ export type IEntityFilterData<T extends EnumEntityType<EntityEnum | VirtualEntit
|
|
|
299
306
|
virtualRelations?: ISearchIncludeEntity<VirtualEntityEnum>[];
|
|
300
307
|
orderBy?: Partial<Record<keyof T, ColumnOrderBy>>;
|
|
301
308
|
limit?: number;
|
|
309
|
+
aggregation?: IEntityAggregationConfig<T>;
|
|
302
310
|
};
|
|
303
311
|
export type ISearchIncludeEntity<T extends EntityEnum | VirtualEntityEnum> = {
|
|
304
312
|
id?: number[];
|
|
@@ -332,6 +340,7 @@ export type ISearchIncludeEntity<T extends EntityEnum | VirtualEntityEnum> = {
|
|
|
332
340
|
virtualRelations?: ISearchIncludeEntity<EntityRelations[VirtualEntityEnum]>[];
|
|
333
341
|
orderBy?: Partial<Record<keyof EnumEntityType<T>, ColumnOrderBy>>;
|
|
334
342
|
limit?: number;
|
|
343
|
+
aggregation?: IEntityAggregationConfig<EnumEntityType<T>>;
|
|
335
344
|
};
|
|
336
345
|
export type IEntityHistoryParsed = {
|
|
337
346
|
parsedData: any;
|
|
@@ -382,6 +391,10 @@ export type IHistoryConstraintSearchServiceResponse<T> = IHistoryEntitySearchByC
|
|
|
382
391
|
export type EnumToModel<T extends EntityEnum | VirtualEntityEnum> = T extends EntityEnum.BILLING ? BillingEntityModel : T extends EntityEnum.BILLING_HISTORY ? BillingHistoryEntityModel : T extends EntityEnum.CLIENT ? ClientEntityModel : T extends EntityEnum.INTERMEDIARY_BANK ? IntermediaryBankEntityModel : T extends EntityEnum.PROJECT ? ProjectEntityModel : T extends EntityEnum.PROJECT_USER_MAPPING ? ProjectUserMappingEntityModel : T extends EntityEnum.REIMBURSEMENT ? ReimbursementEntityModel : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? ReimbursementExpenseEntityModel : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? BillingReimbursementExpneseEntityModel : T extends EntityEnum.BILLING_REIMBURESMENT_EXPENSE_HISTORY ? BillingReimbursementExpenseHistoryEntityModel : T extends EntityEnum.LEAVE ? LeaveEntityModel : T extends EntityEnum.WORK_FROM_HOME ? WorkFromHomeEntityModel : T extends EntityEnum.HOLIDAY ? HolidayEntityModel : T extends VirtualEntityEnum.LEAVE_COUNT ? LeaveCountVirtualEntityModel : T extends EntityEnum.CLIENT_AFFILIATE ? ClientAffiliateEntityModel : T extends EntityEnum.BANK ? BankEntityModel : T extends EntityEnum.CONFIGURATION ? ConfigurationEntityModel : T extends EntityEnum.TASK ? TaskEntityModel : T extends EntityEnum.BILLING_TIMESHEET ? BillingTimesheetEntityModel : T extends EntityEnum.BILLING_TIMESHEET_HISTORY ? BillingTimesheetHistoryEntityModel : T extends EntityEnum.TIMESHEET ? TimesheetEntityModel : T extends EntityEnum.TIMESHEET_HISTORY ? TimesheetHistoryEntityModel : T extends EntityEnum.COUNTRY ? CountryEntityModel : T extends EntityEnum.BILLING_TRANSACTION ? BillingTransactionEntityModel : T extends EntityEnum.BILLING_TRANSACTION_HISTORY ? BillingTransactionHistoryEntityModel : T extends EntityEnum.ADDRESS_BOOK ? AddressBookEntityModel : T extends EntityEnum.STATE ? StateEntityModel : T extends EntityEnum.GST_RATE ? GstRateEntityModel : T extends EntityEnum.ORGANIZATION_TYPE ? OrganizationTypeEntityModel : T extends EntityEnum.TDS_RATE ? TdsRateEntityModel : T extends EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING ? OrganizationTypeTdsRateMappingEntityModel : T extends EntityEnum.VOUCHER_TYPE ? VoucherTypeEntityModel : T extends EntityEnum.TDS_RATE_VOUCHER_TYPE_MAPPING ? TdsRateVoucherTypeMappingEntityModel : T extends EntityEnum.ORGANIZATION ? OrganizationEntityModel : T extends EntityEnum.INDUSTRY ? IndustryEntityModel : T extends EntityEnum.EXPENSE_TYPE ? ExpenseTypeEntityModel : T extends EntityEnum.DESIGNATION ? DesignationEntityModel : T extends EntityEnum.RATE ? RateEntityModel : T extends EntityEnum.ROLE ? RoleEntityModel : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? RolePermissionMappingEntityModel : T extends EntityEnum.PERMISSION ? PermissionEntityModel : T extends EntityEnum.EXPENSE_HEAD ? ExpenseHeadEntityModel : T extends EntityEnum.DOCUMENT_UPLOAD ? DocumentUploadEntityModel : T extends EntityEnum.VENDOR ? VendorEntityModel : T extends EntityEnum.VENDOR_INVOICE ? VendorInvoiceEntityModel : T extends EntityEnum.VENDOR_INVOICE_HISTORY ? VendorInvoiceHistoryEntityModel : T extends EntityEnum.OFFICE_LOCATION ? OfficeLocationEntityModel : T extends EntityEnum.VENDOR_INVOICE_ITEM ? VendorInvoiceItemEntityModel : T extends EntityEnum.VENDOR_INVOICE_ITEM_HISTORY ? VendorInvoiceItemHistoryEntityModel : T extends EntityEnum.VENDOR_HISTORY ? VendorHistoryEntityModel : T extends EntityEnum.WEBSITE_LEAD ? WebsiteLeadEntityModel : T extends EntityEnum.WEBSITE_NEWSLETTER_SUBSCRIPTION ? WebsiteNewsletterSubscriptionEntityModel : T extends EntityEnum.WORK_FROM_HOME_HISTORY ? WorkFromHomeHistoryEntityModel : T extends EntityEnum.LEAVE_HISTORY ? LeaveHistoryEntityModel : T extends EntityEnum.BANK_HISTORY ? BankHistoryEntityModel : T extends EntityEnum.REIMBURSEMENT_HISTORY ? ReimbursementHistoryEntityModel : T extends EntityEnum.CLIENT_USER_MAPPING ? ClientUserMappingEntityModel : T extends EntityEnum.CLIENT_INTRODUCING_MAPPING ? ClientIntroducingMappingEntityModel : T extends EntityEnum.HOLIDAY_LIST ? HolidayListEntityModel : T extends EntityEnum.CRON_JOBS ? CronJobsEntityModel : T extends EntityEnum.TO_DO_LIST ? ToDoListEntityModel : T extends EntityEnum.CLIENT_QUOTE ? ClientQuoteEntityModel : T extends EntityEnum.CLIENT_QUOTE_RATE ? ClientQuoteRateEntityModel : T extends EntityEnum.BILLING_PROFILE ? BillingProfileEntityModel : T extends EntityEnum.PROJECT_REVENUE_SPLIT_MAPPING ? ProjectRevenueSplitMappingEntityModel : T extends EntityEnum.WEBSITE_LEAD ? WebsiteLeadEntityModel : T extends EntityEnum.WEBSITE_NEWSLETTER_SUBSCRIPTION ? WebsiteNewsletterSubscriptionEntityModel : T extends EntityEnum.CLIENT_QUOTE ? ClientQuoteEntityModel : T extends EntityEnum.CLIENT_QUOTE_RATE ? ClientQuoteRateEntityModel : T extends EntityEnum.DESIGNATION ? DesignationEntityModel : T extends EntityEnum.RATE ? RateEntityModel : UserEntityModel;
|
|
383
392
|
export type EntityMap = {
|
|
384
393
|
[key in EntityEnum | VirtualEntityEnum]: EnumToModel<key>[];
|
|
394
|
+
} & {
|
|
395
|
+
aggregateEntities?: {
|
|
396
|
+
[key in EntityEnum | VirtualEntityEnum]: AggregationFields<EnumToModel<key>>[];
|
|
397
|
+
};
|
|
385
398
|
};
|
|
386
399
|
export type EntityIndexMap = {
|
|
387
400
|
[key in EntityEnum | VirtualEntityEnum]: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, EnumToModel,
|
|
1
|
+
import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, EnumToModel, IBaseEntityApiResponse, VirtualEntityEnum } from "../interface/entity.utils.interface";
|
|
2
2
|
import { BaseEntityModel } from "./base.entity.model";
|
|
3
3
|
export declare function mapToIndex(entityMap: EntityMap): EntityIndexMap;
|
|
4
4
|
export declare function getEntityIndexMap<T extends EntityEnum>(data: IBaseEntityApiResponse<EnumEntityType<T>>, baseEntity: T, reusedConfig?: {
|
|
@@ -12,11 +12,7 @@ export declare const entityEnumToEntityModel: {
|
|
|
12
12
|
export declare function entityMapToModels(entityMap: EntityMap): void;
|
|
13
13
|
export declare function parseEntities<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum | VirtualEntityEnum, entityMap: EntityMap): EntityMap;
|
|
14
14
|
export declare function entityMapToEntityIndexMap(entityMap: EntityMap, entityRelationsFor: EntityEnum[]): EntityIndexMap;
|
|
15
|
-
export declare function parseEntitiesWithoutModels<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum | VirtualEntityEnum, entityMap?:
|
|
16
|
-
[E in EntityEnum | VirtualEntityEnum]?: IApiEntity<EnumEntityType<E>>[];
|
|
17
|
-
}): {
|
|
18
|
-
[E in EntityEnum | VirtualEntityEnum]?: IApiEntity<EnumEntityType<E>>[];
|
|
19
|
-
};
|
|
15
|
+
export declare function parseEntitiesWithoutModels<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum | VirtualEntityEnum, entityMap?: EntityMap): EntityMap;
|
|
20
16
|
export declare function removeEntityById(entityIndexMap: EntityIndexMap, entity: EntityEnum, id: number): void;
|
|
21
17
|
export declare class EntityModelRelationHelper {
|
|
22
18
|
private entityMap;
|
|
@@ -217,6 +217,14 @@ function parseEntitiesWithoutModels(json, baseEntity, entityMap = {}) {
|
|
|
217
217
|
relatedEntities[entityName], entityName, entityMap);
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
+
if (json["aggregateEntities"]) {
|
|
221
|
+
if (!entityMap["aggregateEntities"]) {
|
|
222
|
+
entityMap["aggregateEntities"] = {};
|
|
223
|
+
}
|
|
224
|
+
for (const entityName in json["aggregateEntities"]) {
|
|
225
|
+
entityMap["aggregateEntities"][entityName] = json["aggregateEntities"][entityName];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
220
228
|
return entityMap;
|
|
221
229
|
}
|
|
222
230
|
function removeEntityById(entityIndexMap, entity, id) {
|