@mody-park-cha-raja/finance_common 4.1.0 → 4.1.1-beta.2
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/index.d.mts +38 -17
- package/dist/index.d.ts +38 -17
- package/dist/index.js +105 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +105 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -233,6 +233,20 @@ declare class DonationHistoryModel extends BaseEntityModel implements IDonationH
|
|
|
233
233
|
static populateFromEntity(entity: IDonationHistoryEntity): DonationHistoryModel;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
+
declare class UserModel extends BaseEntityModel implements IUserEntity {
|
|
237
|
+
id: number;
|
|
238
|
+
name: string;
|
|
239
|
+
password: string;
|
|
240
|
+
email: string;
|
|
241
|
+
phone: string;
|
|
242
|
+
createdOn: number;
|
|
243
|
+
updatedOn: number;
|
|
244
|
+
createdBy: number;
|
|
245
|
+
updatedBy: number;
|
|
246
|
+
protected constructor();
|
|
247
|
+
static populateFromEntity(entity: IUserEntity): UserModel;
|
|
248
|
+
}
|
|
249
|
+
|
|
236
250
|
declare class DonationModel extends BaseEntityModel implements IDonationEntity {
|
|
237
251
|
id: number;
|
|
238
252
|
receiptNumber: string;
|
|
@@ -246,7 +260,10 @@ declare class DonationModel extends BaseEntityModel implements IDonationEntity {
|
|
|
246
260
|
updatedOn: number;
|
|
247
261
|
createdBy: number;
|
|
248
262
|
updatedBy: number;
|
|
263
|
+
createdByUser?: UserModel;
|
|
264
|
+
updatedByUser?: UserModel;
|
|
249
265
|
protected constructor();
|
|
266
|
+
static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList>>>;
|
|
250
267
|
static populateFromEntity(entity: IDonationEntity): DonationModel;
|
|
251
268
|
static getReceiptPrefix(flatNo: string): string;
|
|
252
269
|
static generateReceiptNumber(flatNo: string, existingDonations: DonationModel[]): string;
|
|
@@ -281,7 +298,10 @@ declare class ExpenseModel extends BaseEntityModel implements IExpenseEntity {
|
|
|
281
298
|
updatedOn: number;
|
|
282
299
|
createdBy: number;
|
|
283
300
|
updatedBy: number;
|
|
301
|
+
createdByUser?: UserModel;
|
|
302
|
+
updatedByUser?: UserModel;
|
|
284
303
|
protected constructor();
|
|
304
|
+
static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList>>>;
|
|
285
305
|
static populateFromEntity(entity: IExpenseEntity): ExpenseModel;
|
|
286
306
|
}
|
|
287
307
|
|
|
@@ -313,7 +333,10 @@ declare class SponsorModel extends BaseEntityModel implements ISponsorEntity {
|
|
|
313
333
|
updatedOn: number;
|
|
314
334
|
createdBy: number;
|
|
315
335
|
updatedBy: number;
|
|
336
|
+
createdByUser?: UserModel;
|
|
337
|
+
updatedByUser?: UserModel;
|
|
316
338
|
protected constructor();
|
|
339
|
+
static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList>>>;
|
|
317
340
|
static populateFromEntity(entity: ISponsorEntity): SponsorModel;
|
|
318
341
|
}
|
|
319
342
|
|
|
@@ -345,7 +368,10 @@ declare class TransactionModel extends BaseEntityModel implements ITransactionEn
|
|
|
345
368
|
updatedOn: number;
|
|
346
369
|
createdBy: number;
|
|
347
370
|
updatedBy: number;
|
|
371
|
+
createdByUser?: UserModel;
|
|
372
|
+
updatedByUser?: UserModel;
|
|
348
373
|
protected constructor();
|
|
374
|
+
static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList>>>;
|
|
349
375
|
static populateFromEntity(entity: ITransactionEntity): TransactionModel;
|
|
350
376
|
static toCashBookEntry(tx: TransactionModel): ICashBookEntry;
|
|
351
377
|
static toCashBook(txns: TransactionModel[]): ICashBookEntry[];
|
|
@@ -365,20 +391,6 @@ declare class UserHistoryModel extends BaseEntityModel implements IUserHistoryEn
|
|
|
365
391
|
static populateFromEntity(entity: IUserHistoryEntity): UserHistoryModel;
|
|
366
392
|
}
|
|
367
393
|
|
|
368
|
-
declare class UserModel extends BaseEntityModel implements IUserEntity {
|
|
369
|
-
id: number;
|
|
370
|
-
name: string;
|
|
371
|
-
password: string;
|
|
372
|
-
email: string;
|
|
373
|
-
phone: string;
|
|
374
|
-
createdOn: number;
|
|
375
|
-
updatedOn: number;
|
|
376
|
-
createdBy: number;
|
|
377
|
-
updatedBy: number;
|
|
378
|
-
protected constructor();
|
|
379
|
-
static populateFromEntity(entity: IUserEntity): UserModel;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
394
|
declare class VendorHistoryModel extends BaseEntityModel implements IVendorHistoryEntity {
|
|
383
395
|
id: number;
|
|
384
396
|
entityId: number;
|
|
@@ -401,7 +413,10 @@ declare class VendorModel extends BaseEntityModel implements IVendorEntity {
|
|
|
401
413
|
updatedOn: number;
|
|
402
414
|
createdBy: number;
|
|
403
415
|
updatedBy: number;
|
|
416
|
+
createdByUser?: UserModel;
|
|
417
|
+
updatedByUser?: UserModel;
|
|
404
418
|
protected constructor();
|
|
419
|
+
static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList>>>;
|
|
405
420
|
static populateFromEntity(entity: IVendorEntity): VendorModel;
|
|
406
421
|
}
|
|
407
422
|
|
|
@@ -512,23 +527,29 @@ declare function definedValues<T>(arr: Array<T | undefined | null>): T[];
|
|
|
512
527
|
* @param format - Optional output format:
|
|
513
528
|
* - `'short'` — locale-specific short date (e.g. "25/12/2026")
|
|
514
529
|
* - `'long'` — locale-specific long date (e.g. "25 December 2026")
|
|
530
|
+
* - `'short-dt'` — DD/MM/YY HH:MM (e.g. "25/12/26 18:13")
|
|
515
531
|
* - `'iso'` — ISO 8601 string (default)
|
|
516
532
|
* @returns The formatted date string, or '' if epoch is invalid
|
|
517
533
|
*
|
|
518
534
|
* @example
|
|
519
535
|
* epochToReadableDate(1700000000000, 'long'); // "14 November 2023"
|
|
520
536
|
* epochToReadableDate('1700000000000', 'short'); // "14/11/2023"
|
|
537
|
+
* epochToReadableDate(1700000000000, 'short-dt'); // "14/11/23 18:13"
|
|
521
538
|
* epochToReadableDate(1700000000000); // "2023-11-14T18:13:20.000Z"
|
|
522
539
|
*/
|
|
523
|
-
declare function epochToReadableDate(epoch: number | string, format?: 'short' | 'long' | 'iso'): string;
|
|
540
|
+
declare function epochToReadableDate(epoch: number | string, format?: 'short' | 'long' | 'short-dt' | 'iso'): string;
|
|
524
541
|
|
|
525
542
|
declare enum RelationType {
|
|
526
543
|
ONE = "ONE",
|
|
527
544
|
MANY = "MANY"
|
|
528
545
|
}
|
|
546
|
+
interface IMappingPropertyEntry {
|
|
547
|
+
sourceProperty: string;
|
|
548
|
+
targetProperty: string;
|
|
549
|
+
}
|
|
529
550
|
interface IModelRelationConfig<T extends EntityList> {
|
|
530
551
|
relationType: RelationType;
|
|
531
|
-
|
|
552
|
+
mappingProperties: IMappingPropertyEntry[];
|
|
532
553
|
searchProperty: string;
|
|
533
554
|
entity: EntityList;
|
|
534
555
|
}
|
|
@@ -694,4 +715,4 @@ interface IConfigurationUpdateDto extends IEntityUpdateDto<EntityType<EntityList
|
|
|
694
715
|
interface IConfigurationSearchDto extends IEntityFilterData<EntityType<EntityList.CONFIGURATION>> {
|
|
695
716
|
}
|
|
696
717
|
|
|
697
|
-
export { BadRequestException, BaseEntityModel, ConfigurationKey, ConfigurationModel, ConfigurationType, DateCodeUtils, DateUtil, DonationHistoryModel, DonationModel, EntityFilterDataHelper, EntityHistoryOperation, EntityList, type EntityListEntityModelMap, type EntityModelType, EntityStatus, type EntityType, ExpenseHistoryModel, ExpenseModel, ExpenseType, ForbiddenException, HttpException, type IAuditColumnEntity, type IBaseHistoryEntity, type ICashBookEntry, type IConfigurationCreateDto, type IConfigurationEntity, type IConfigurationSearchDto, type IConfigurationUpdateDto, type IDonationCreateDto, type IDonationEntity, type IDonationHistoryEntity, type IDonationSearchDto, type IDonationUpdateDto, type IDtoValidationError, type IEntityCreateDto, type IEntityFilterData, type IEntityFilterSearchData, type IEntityFilterSearchDataV2, type IEntityUpdateDto, type IExpenseCreateDto, type IExpenseEntity, type IExpenseHistoryEntity, type IExpenseSearchDto, type IExpenseUpdateDto, type IModelRelationConfig, type ISearchV2Response, type ISponsorCreateDto, type ISponsorEntity, type ISponsorHistoryEntity, type ISponsorSearchDto, type ISponsorUpdateDto, type ITransactionCreateDto, type ITransactionEntity, type ITransactionHistoryEntity, type ITransactionSearchDto, type ITransactionUpdateDto, type IUserCreateDto, type IUserEntity, type IUserHistoryEntity, type IUserSearchDto, type IUserUpdateDto, type IVendorCreateDto, type IVendorEntity, type IVendorHistoryEntity, type IVendorSearchDto, type IVendorUpdateDto, NotFoundException, type Nullable, OrderByDirection, PaymentType, ReferenceIdPrefix, RelationType, SponsorFor, SponsorHistoryModel, SponsorModel, SponsorTier, TransactionHistoryModel, TransactionModel, TransactionType, UnauthorizedException, UserHistoryModel, UserModel, VendorHistoryModel, VendorModel, VendorType, definedValues, diffArrays, entityListEntityModelMap, epochToReadableDate, getObjectDiffingKeys, groupBy };
|
|
718
|
+
export { BadRequestException, BaseEntityModel, ConfigurationKey, ConfigurationModel, ConfigurationType, DateCodeUtils, DateUtil, DonationHistoryModel, DonationModel, EntityFilterDataHelper, EntityHistoryOperation, EntityList, type EntityListEntityModelMap, type EntityModelType, EntityStatus, type EntityType, ExpenseHistoryModel, ExpenseModel, ExpenseType, ForbiddenException, HttpException, type IAuditColumnEntity, type IBaseHistoryEntity, type ICashBookEntry, type IConfigurationCreateDto, type IConfigurationEntity, type IConfigurationSearchDto, type IConfigurationUpdateDto, type IDonationCreateDto, type IDonationEntity, type IDonationHistoryEntity, type IDonationSearchDto, type IDonationUpdateDto, type IDtoValidationError, type IEntityCreateDto, type IEntityFilterData, type IEntityFilterSearchData, type IEntityFilterSearchDataV2, type IEntityUpdateDto, type IExpenseCreateDto, type IExpenseEntity, type IExpenseHistoryEntity, type IExpenseSearchDto, type IExpenseUpdateDto, type IMappingPropertyEntry, type IModelRelationConfig, type ISearchV2Response, type ISponsorCreateDto, type ISponsorEntity, type ISponsorHistoryEntity, type ISponsorSearchDto, type ISponsorUpdateDto, type ITransactionCreateDto, type ITransactionEntity, type ITransactionHistoryEntity, type ITransactionSearchDto, type ITransactionUpdateDto, type IUserCreateDto, type IUserEntity, type IUserHistoryEntity, type IUserSearchDto, type IUserUpdateDto, type IVendorCreateDto, type IVendorEntity, type IVendorHistoryEntity, type IVendorSearchDto, type IVendorUpdateDto, NotFoundException, type Nullable, OrderByDirection, PaymentType, ReferenceIdPrefix, RelationType, SponsorFor, SponsorHistoryModel, SponsorModel, SponsorTier, TransactionHistoryModel, TransactionModel, TransactionType, UnauthorizedException, UserHistoryModel, UserModel, VendorHistoryModel, VendorModel, VendorType, definedValues, diffArrays, entityListEntityModelMap, epochToReadableDate, getObjectDiffingKeys, groupBy };
|
package/dist/index.d.ts
CHANGED
|
@@ -233,6 +233,20 @@ declare class DonationHistoryModel extends BaseEntityModel implements IDonationH
|
|
|
233
233
|
static populateFromEntity(entity: IDonationHistoryEntity): DonationHistoryModel;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
+
declare class UserModel extends BaseEntityModel implements IUserEntity {
|
|
237
|
+
id: number;
|
|
238
|
+
name: string;
|
|
239
|
+
password: string;
|
|
240
|
+
email: string;
|
|
241
|
+
phone: string;
|
|
242
|
+
createdOn: number;
|
|
243
|
+
updatedOn: number;
|
|
244
|
+
createdBy: number;
|
|
245
|
+
updatedBy: number;
|
|
246
|
+
protected constructor();
|
|
247
|
+
static populateFromEntity(entity: IUserEntity): UserModel;
|
|
248
|
+
}
|
|
249
|
+
|
|
236
250
|
declare class DonationModel extends BaseEntityModel implements IDonationEntity {
|
|
237
251
|
id: number;
|
|
238
252
|
receiptNumber: string;
|
|
@@ -246,7 +260,10 @@ declare class DonationModel extends BaseEntityModel implements IDonationEntity {
|
|
|
246
260
|
updatedOn: number;
|
|
247
261
|
createdBy: number;
|
|
248
262
|
updatedBy: number;
|
|
263
|
+
createdByUser?: UserModel;
|
|
264
|
+
updatedByUser?: UserModel;
|
|
249
265
|
protected constructor();
|
|
266
|
+
static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList>>>;
|
|
250
267
|
static populateFromEntity(entity: IDonationEntity): DonationModel;
|
|
251
268
|
static getReceiptPrefix(flatNo: string): string;
|
|
252
269
|
static generateReceiptNumber(flatNo: string, existingDonations: DonationModel[]): string;
|
|
@@ -281,7 +298,10 @@ declare class ExpenseModel extends BaseEntityModel implements IExpenseEntity {
|
|
|
281
298
|
updatedOn: number;
|
|
282
299
|
createdBy: number;
|
|
283
300
|
updatedBy: number;
|
|
301
|
+
createdByUser?: UserModel;
|
|
302
|
+
updatedByUser?: UserModel;
|
|
284
303
|
protected constructor();
|
|
304
|
+
static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList>>>;
|
|
285
305
|
static populateFromEntity(entity: IExpenseEntity): ExpenseModel;
|
|
286
306
|
}
|
|
287
307
|
|
|
@@ -313,7 +333,10 @@ declare class SponsorModel extends BaseEntityModel implements ISponsorEntity {
|
|
|
313
333
|
updatedOn: number;
|
|
314
334
|
createdBy: number;
|
|
315
335
|
updatedBy: number;
|
|
336
|
+
createdByUser?: UserModel;
|
|
337
|
+
updatedByUser?: UserModel;
|
|
316
338
|
protected constructor();
|
|
339
|
+
static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList>>>;
|
|
317
340
|
static populateFromEntity(entity: ISponsorEntity): SponsorModel;
|
|
318
341
|
}
|
|
319
342
|
|
|
@@ -345,7 +368,10 @@ declare class TransactionModel extends BaseEntityModel implements ITransactionEn
|
|
|
345
368
|
updatedOn: number;
|
|
346
369
|
createdBy: number;
|
|
347
370
|
updatedBy: number;
|
|
371
|
+
createdByUser?: UserModel;
|
|
372
|
+
updatedByUser?: UserModel;
|
|
348
373
|
protected constructor();
|
|
374
|
+
static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList>>>;
|
|
349
375
|
static populateFromEntity(entity: ITransactionEntity): TransactionModel;
|
|
350
376
|
static toCashBookEntry(tx: TransactionModel): ICashBookEntry;
|
|
351
377
|
static toCashBook(txns: TransactionModel[]): ICashBookEntry[];
|
|
@@ -365,20 +391,6 @@ declare class UserHistoryModel extends BaseEntityModel implements IUserHistoryEn
|
|
|
365
391
|
static populateFromEntity(entity: IUserHistoryEntity): UserHistoryModel;
|
|
366
392
|
}
|
|
367
393
|
|
|
368
|
-
declare class UserModel extends BaseEntityModel implements IUserEntity {
|
|
369
|
-
id: number;
|
|
370
|
-
name: string;
|
|
371
|
-
password: string;
|
|
372
|
-
email: string;
|
|
373
|
-
phone: string;
|
|
374
|
-
createdOn: number;
|
|
375
|
-
updatedOn: number;
|
|
376
|
-
createdBy: number;
|
|
377
|
-
updatedBy: number;
|
|
378
|
-
protected constructor();
|
|
379
|
-
static populateFromEntity(entity: IUserEntity): UserModel;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
394
|
declare class VendorHistoryModel extends BaseEntityModel implements IVendorHistoryEntity {
|
|
383
395
|
id: number;
|
|
384
396
|
entityId: number;
|
|
@@ -401,7 +413,10 @@ declare class VendorModel extends BaseEntityModel implements IVendorEntity {
|
|
|
401
413
|
updatedOn: number;
|
|
402
414
|
createdBy: number;
|
|
403
415
|
updatedBy: number;
|
|
416
|
+
createdByUser?: UserModel;
|
|
417
|
+
updatedByUser?: UserModel;
|
|
404
418
|
protected constructor();
|
|
419
|
+
static relations: Partial<Record<EntityList, IModelRelationConfig<EntityList>>>;
|
|
405
420
|
static populateFromEntity(entity: IVendorEntity): VendorModel;
|
|
406
421
|
}
|
|
407
422
|
|
|
@@ -512,23 +527,29 @@ declare function definedValues<T>(arr: Array<T | undefined | null>): T[];
|
|
|
512
527
|
* @param format - Optional output format:
|
|
513
528
|
* - `'short'` — locale-specific short date (e.g. "25/12/2026")
|
|
514
529
|
* - `'long'` — locale-specific long date (e.g. "25 December 2026")
|
|
530
|
+
* - `'short-dt'` — DD/MM/YY HH:MM (e.g. "25/12/26 18:13")
|
|
515
531
|
* - `'iso'` — ISO 8601 string (default)
|
|
516
532
|
* @returns The formatted date string, or '' if epoch is invalid
|
|
517
533
|
*
|
|
518
534
|
* @example
|
|
519
535
|
* epochToReadableDate(1700000000000, 'long'); // "14 November 2023"
|
|
520
536
|
* epochToReadableDate('1700000000000', 'short'); // "14/11/2023"
|
|
537
|
+
* epochToReadableDate(1700000000000, 'short-dt'); // "14/11/23 18:13"
|
|
521
538
|
* epochToReadableDate(1700000000000); // "2023-11-14T18:13:20.000Z"
|
|
522
539
|
*/
|
|
523
|
-
declare function epochToReadableDate(epoch: number | string, format?: 'short' | 'long' | 'iso'): string;
|
|
540
|
+
declare function epochToReadableDate(epoch: number | string, format?: 'short' | 'long' | 'short-dt' | 'iso'): string;
|
|
524
541
|
|
|
525
542
|
declare enum RelationType {
|
|
526
543
|
ONE = "ONE",
|
|
527
544
|
MANY = "MANY"
|
|
528
545
|
}
|
|
546
|
+
interface IMappingPropertyEntry {
|
|
547
|
+
sourceProperty: string;
|
|
548
|
+
targetProperty: string;
|
|
549
|
+
}
|
|
529
550
|
interface IModelRelationConfig<T extends EntityList> {
|
|
530
551
|
relationType: RelationType;
|
|
531
|
-
|
|
552
|
+
mappingProperties: IMappingPropertyEntry[];
|
|
532
553
|
searchProperty: string;
|
|
533
554
|
entity: EntityList;
|
|
534
555
|
}
|
|
@@ -694,4 +715,4 @@ interface IConfigurationUpdateDto extends IEntityUpdateDto<EntityType<EntityList
|
|
|
694
715
|
interface IConfigurationSearchDto extends IEntityFilterData<EntityType<EntityList.CONFIGURATION>> {
|
|
695
716
|
}
|
|
696
717
|
|
|
697
|
-
export { BadRequestException, BaseEntityModel, ConfigurationKey, ConfigurationModel, ConfigurationType, DateCodeUtils, DateUtil, DonationHistoryModel, DonationModel, EntityFilterDataHelper, EntityHistoryOperation, EntityList, type EntityListEntityModelMap, type EntityModelType, EntityStatus, type EntityType, ExpenseHistoryModel, ExpenseModel, ExpenseType, ForbiddenException, HttpException, type IAuditColumnEntity, type IBaseHistoryEntity, type ICashBookEntry, type IConfigurationCreateDto, type IConfigurationEntity, type IConfigurationSearchDto, type IConfigurationUpdateDto, type IDonationCreateDto, type IDonationEntity, type IDonationHistoryEntity, type IDonationSearchDto, type IDonationUpdateDto, type IDtoValidationError, type IEntityCreateDto, type IEntityFilterData, type IEntityFilterSearchData, type IEntityFilterSearchDataV2, type IEntityUpdateDto, type IExpenseCreateDto, type IExpenseEntity, type IExpenseHistoryEntity, type IExpenseSearchDto, type IExpenseUpdateDto, type IModelRelationConfig, type ISearchV2Response, type ISponsorCreateDto, type ISponsorEntity, type ISponsorHistoryEntity, type ISponsorSearchDto, type ISponsorUpdateDto, type ITransactionCreateDto, type ITransactionEntity, type ITransactionHistoryEntity, type ITransactionSearchDto, type ITransactionUpdateDto, type IUserCreateDto, type IUserEntity, type IUserHistoryEntity, type IUserSearchDto, type IUserUpdateDto, type IVendorCreateDto, type IVendorEntity, type IVendorHistoryEntity, type IVendorSearchDto, type IVendorUpdateDto, NotFoundException, type Nullable, OrderByDirection, PaymentType, ReferenceIdPrefix, RelationType, SponsorFor, SponsorHistoryModel, SponsorModel, SponsorTier, TransactionHistoryModel, TransactionModel, TransactionType, UnauthorizedException, UserHistoryModel, UserModel, VendorHistoryModel, VendorModel, VendorType, definedValues, diffArrays, entityListEntityModelMap, epochToReadableDate, getObjectDiffingKeys, groupBy };
|
|
718
|
+
export { BadRequestException, BaseEntityModel, ConfigurationKey, ConfigurationModel, ConfigurationType, DateCodeUtils, DateUtil, DonationHistoryModel, DonationModel, EntityFilterDataHelper, EntityHistoryOperation, EntityList, type EntityListEntityModelMap, type EntityModelType, EntityStatus, type EntityType, ExpenseHistoryModel, ExpenseModel, ExpenseType, ForbiddenException, HttpException, type IAuditColumnEntity, type IBaseHistoryEntity, type ICashBookEntry, type IConfigurationCreateDto, type IConfigurationEntity, type IConfigurationSearchDto, type IConfigurationUpdateDto, type IDonationCreateDto, type IDonationEntity, type IDonationHistoryEntity, type IDonationSearchDto, type IDonationUpdateDto, type IDtoValidationError, type IEntityCreateDto, type IEntityFilterData, type IEntityFilterSearchData, type IEntityFilterSearchDataV2, type IEntityUpdateDto, type IExpenseCreateDto, type IExpenseEntity, type IExpenseHistoryEntity, type IExpenseSearchDto, type IExpenseUpdateDto, type IMappingPropertyEntry, type IModelRelationConfig, type ISearchV2Response, type ISponsorCreateDto, type ISponsorEntity, type ISponsorHistoryEntity, type ISponsorSearchDto, type ISponsorUpdateDto, type ITransactionCreateDto, type ITransactionEntity, type ITransactionHistoryEntity, type ITransactionSearchDto, type ITransactionUpdateDto, type IUserCreateDto, type IUserEntity, type IUserHistoryEntity, type IUserSearchDto, type IUserUpdateDto, type IVendorCreateDto, type IVendorEntity, type IVendorHistoryEntity, type IVendorSearchDto, type IVendorUpdateDto, NotFoundException, type Nullable, OrderByDirection, PaymentType, ReferenceIdPrefix, RelationType, SponsorFor, SponsorHistoryModel, SponsorModel, SponsorTier, TransactionHistoryModel, TransactionModel, TransactionType, UnauthorizedException, UserHistoryModel, UserModel, VendorHistoryModel, VendorModel, VendorType, definedValues, diffArrays, entityListEntityModelMap, epochToReadableDate, getObjectDiffingKeys, groupBy };
|
package/dist/index.js
CHANGED
|
@@ -344,27 +344,35 @@ var BaseEntityModel = class {
|
|
|
344
344
|
if (visited.has(selfKey)) return this;
|
|
345
345
|
visited.add(selfKey);
|
|
346
346
|
const relations = this.constructor.relations;
|
|
347
|
-
for (const [
|
|
348
|
-
const { relationType,
|
|
349
|
-
const fkValue = this[mappingProperty];
|
|
347
|
+
for (const [, config] of Object.entries(relations)) {
|
|
348
|
+
const { relationType, mappingProperties, searchProperty, entity } = config;
|
|
350
349
|
const bucket = searchResponse[entity] ?? [];
|
|
351
350
|
if (!bucket.length) continue;
|
|
351
|
+
const hydrateEntity = (raw) => {
|
|
352
|
+
const hydrated = entityListEntityModelMap[entity](raw);
|
|
353
|
+
hydrated.populateRelations(searchResponse, visited);
|
|
354
|
+
return hydrated;
|
|
355
|
+
};
|
|
352
356
|
if (relationType === "ONE" /* ONE */) {
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
357
|
+
for (const { sourceProperty, targetProperty } of mappingProperties) {
|
|
358
|
+
const fkValue = this[sourceProperty];
|
|
359
|
+
if (fkValue == null) continue;
|
|
360
|
+
const match = bucket.find(
|
|
361
|
+
(e) => e[searchProperty] === fkValue
|
|
362
|
+
);
|
|
363
|
+
if (match) {
|
|
364
|
+
this[targetProperty] = hydrateEntity(match);
|
|
365
|
+
}
|
|
358
366
|
}
|
|
359
367
|
} else {
|
|
368
|
+
const fkValues = mappingProperties.map((mp) => this[mp.sourceProperty]).filter((v) => v != null);
|
|
360
369
|
const matches = bucket.filter(
|
|
361
|
-
(e) => e[searchProperty]
|
|
370
|
+
(e) => fkValues.includes(e[searchProperty])
|
|
362
371
|
);
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
});
|
|
372
|
+
const targetProperty = mappingProperties[0]?.targetProperty;
|
|
373
|
+
if (targetProperty && matches.length) {
|
|
374
|
+
this[targetProperty] = matches.map(hydrateEntity);
|
|
375
|
+
}
|
|
368
376
|
}
|
|
369
377
|
}
|
|
370
378
|
return this;
|
|
@@ -393,7 +401,7 @@ _DonationHistoryModel.relations = {};
|
|
|
393
401
|
var DonationHistoryModel = _DonationHistoryModel;
|
|
394
402
|
|
|
395
403
|
// src/models/donation.entity.model.ts
|
|
396
|
-
var
|
|
404
|
+
var _DonationModel = class _DonationModel extends BaseEntityModel {
|
|
397
405
|
constructor() {
|
|
398
406
|
super();
|
|
399
407
|
this.id = 0;
|
|
@@ -432,6 +440,18 @@ var DonationModel = class _DonationModel extends BaseEntityModel {
|
|
|
432
440
|
return digits;
|
|
433
441
|
}
|
|
434
442
|
};
|
|
443
|
+
_DonationModel.relations = {
|
|
444
|
+
["user" /* USER */]: {
|
|
445
|
+
relationType: "ONE" /* ONE */,
|
|
446
|
+
mappingProperties: [
|
|
447
|
+
{ sourceProperty: "createdBy", targetProperty: "createdByUser" },
|
|
448
|
+
{ sourceProperty: "updatedBy", targetProperty: "updatedByUser" }
|
|
449
|
+
],
|
|
450
|
+
searchProperty: "id",
|
|
451
|
+
entity: "user" /* USER */
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
var DonationModel = _DonationModel;
|
|
435
455
|
|
|
436
456
|
// src/models/expense-history.entity.model.ts
|
|
437
457
|
var _ExpenseHistoryModel = class _ExpenseHistoryModel extends BaseEntityModel {
|
|
@@ -454,7 +474,7 @@ _ExpenseHistoryModel.relations = {};
|
|
|
454
474
|
var ExpenseHistoryModel = _ExpenseHistoryModel;
|
|
455
475
|
|
|
456
476
|
// src/models/expense.entity.model.ts
|
|
457
|
-
var
|
|
477
|
+
var _ExpenseModel = class _ExpenseModel extends BaseEntityModel {
|
|
458
478
|
constructor() {
|
|
459
479
|
super();
|
|
460
480
|
this.id = 0;
|
|
@@ -475,6 +495,18 @@ var ExpenseModel = class _ExpenseModel extends BaseEntityModel {
|
|
|
475
495
|
});
|
|
476
496
|
}
|
|
477
497
|
};
|
|
498
|
+
_ExpenseModel.relations = {
|
|
499
|
+
["user" /* USER */]: {
|
|
500
|
+
relationType: "ONE" /* ONE */,
|
|
501
|
+
mappingProperties: [
|
|
502
|
+
{ sourceProperty: "createdBy", targetProperty: "createdByUser" },
|
|
503
|
+
{ sourceProperty: "updatedBy", targetProperty: "updatedByUser" }
|
|
504
|
+
],
|
|
505
|
+
searchProperty: "id",
|
|
506
|
+
entity: "user" /* USER */
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
var ExpenseModel = _ExpenseModel;
|
|
478
510
|
|
|
479
511
|
// src/models/sponsor-history.entity.model.ts
|
|
480
512
|
var _SponsorHistoryModel = class _SponsorHistoryModel extends BaseEntityModel {
|
|
@@ -497,7 +529,7 @@ _SponsorHistoryModel.relations = {};
|
|
|
497
529
|
var SponsorHistoryModel = _SponsorHistoryModel;
|
|
498
530
|
|
|
499
531
|
// src/models/sponsor.entity.model.ts
|
|
500
|
-
var
|
|
532
|
+
var _SponsorModel = class _SponsorModel extends BaseEntityModel {
|
|
501
533
|
constructor() {
|
|
502
534
|
super();
|
|
503
535
|
this.id = 0;
|
|
@@ -520,6 +552,18 @@ var SponsorModel = class _SponsorModel extends BaseEntityModel {
|
|
|
520
552
|
});
|
|
521
553
|
}
|
|
522
554
|
};
|
|
555
|
+
_SponsorModel.relations = {
|
|
556
|
+
["user" /* USER */]: {
|
|
557
|
+
relationType: "ONE" /* ONE */,
|
|
558
|
+
mappingProperties: [
|
|
559
|
+
{ sourceProperty: "createdBy", targetProperty: "createdByUser" },
|
|
560
|
+
{ sourceProperty: "updatedBy", targetProperty: "updatedByUser" }
|
|
561
|
+
],
|
|
562
|
+
searchProperty: "id",
|
|
563
|
+
entity: "user" /* USER */
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
var SponsorModel = _SponsorModel;
|
|
523
567
|
|
|
524
568
|
// src/models/transaction-history.entity.model.ts
|
|
525
569
|
var _TransactionHistoryModel = class _TransactionHistoryModel extends BaseEntityModel {
|
|
@@ -542,7 +586,7 @@ _TransactionHistoryModel.relations = {};
|
|
|
542
586
|
var TransactionHistoryModel = _TransactionHistoryModel;
|
|
543
587
|
|
|
544
588
|
// src/models/transaction.entity.model.ts
|
|
545
|
-
var
|
|
589
|
+
var _TransactionModel = class _TransactionModel extends BaseEntityModel {
|
|
546
590
|
constructor() {
|
|
547
591
|
super();
|
|
548
592
|
this.id = 0;
|
|
@@ -580,6 +624,18 @@ var TransactionModel = class _TransactionModel extends BaseEntityModel {
|
|
|
580
624
|
return txns.map(_TransactionModel.toCashBookEntry);
|
|
581
625
|
}
|
|
582
626
|
};
|
|
627
|
+
_TransactionModel.relations = {
|
|
628
|
+
["user" /* USER */]: {
|
|
629
|
+
relationType: "ONE" /* ONE */,
|
|
630
|
+
mappingProperties: [
|
|
631
|
+
{ sourceProperty: "createdBy", targetProperty: "createdByUser" },
|
|
632
|
+
{ sourceProperty: "updatedBy", targetProperty: "updatedByUser" }
|
|
633
|
+
],
|
|
634
|
+
searchProperty: "id",
|
|
635
|
+
entity: "user" /* USER */
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
var TransactionModel = _TransactionModel;
|
|
583
639
|
|
|
584
640
|
// src/models/user-history.entity.model.ts
|
|
585
641
|
var _UserHistoryModel = class _UserHistoryModel extends BaseEntityModel {
|
|
@@ -641,7 +697,7 @@ _VendorHistoryModel.relations = {};
|
|
|
641
697
|
var VendorHistoryModel = _VendorHistoryModel;
|
|
642
698
|
|
|
643
699
|
// src/models/vendor.entity.model.ts
|
|
644
|
-
var
|
|
700
|
+
var _VendorModel = class _VendorModel extends BaseEntityModel {
|
|
645
701
|
constructor() {
|
|
646
702
|
super();
|
|
647
703
|
this.id = 0;
|
|
@@ -656,6 +712,18 @@ var VendorModel = class _VendorModel extends BaseEntityModel {
|
|
|
656
712
|
return Object.assign(new _VendorModel(), entity);
|
|
657
713
|
}
|
|
658
714
|
};
|
|
715
|
+
_VendorModel.relations = {
|
|
716
|
+
["user" /* USER */]: {
|
|
717
|
+
relationType: "ONE" /* ONE */,
|
|
718
|
+
mappingProperties: [
|
|
719
|
+
{ sourceProperty: "createdBy", targetProperty: "createdByUser" },
|
|
720
|
+
{ sourceProperty: "updatedBy", targetProperty: "updatedByUser" }
|
|
721
|
+
],
|
|
722
|
+
searchProperty: "id",
|
|
723
|
+
entity: "user" /* USER */
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
var VendorModel = _VendorModel;
|
|
659
727
|
|
|
660
728
|
// src/models/configuration.entity.model.ts
|
|
661
729
|
var ConfigurationModel = class _ConfigurationModel extends BaseEntityModel {
|
|
@@ -844,6 +912,15 @@ function epochToReadableDate(epoch, format = "iso") {
|
|
|
844
912
|
month: "long",
|
|
845
913
|
day: "numeric"
|
|
846
914
|
});
|
|
915
|
+
case "short-dt": {
|
|
916
|
+
const d = date;
|
|
917
|
+
const dd = String(d.getDate()).padStart(2, "0");
|
|
918
|
+
const mm = String(d.getMonth() + 1).padStart(2, "0");
|
|
919
|
+
const yy = String(d.getFullYear()).slice(-2);
|
|
920
|
+
const hh = String(d.getHours()).padStart(2, "0");
|
|
921
|
+
const min = String(d.getMinutes()).padStart(2, "0");
|
|
922
|
+
return `${dd}/${mm}/${yy} ${hh}:${min}`;
|
|
923
|
+
}
|
|
847
924
|
case "iso":
|
|
848
925
|
default:
|
|
849
926
|
return date.toISOString();
|
|
@@ -872,15 +949,8 @@ var EntityFilterDataHelper = class {
|
|
|
872
949
|
this.entityModelsMap = this.populateEntityModelsMap();
|
|
873
950
|
}
|
|
874
951
|
getEntityFromList(name) {
|
|
875
|
-
|
|
876
|
-
const data = this.searchResponse[name] ?? [];
|
|
877
|
-
return data.map(
|
|
878
|
-
(entity) => populateFn(
|
|
879
|
-
entity
|
|
880
|
-
)
|
|
881
|
-
);
|
|
952
|
+
return this.entityModelsMap[name] ?? [];
|
|
882
953
|
}
|
|
883
|
-
// getEntityModelsMap(): EntityListEntityModelMap {
|
|
884
954
|
populateEntityModelsMap() {
|
|
885
955
|
const responseObj = {};
|
|
886
956
|
for (const key of Object.keys(this.searchResponse)) {
|
|
@@ -888,11 +958,14 @@ var EntityFilterDataHelper = class {
|
|
|
888
958
|
if (!populateFn) continue;
|
|
889
959
|
const raw = this.searchResponse[key];
|
|
890
960
|
if (!Array.isArray(raw)) continue;
|
|
891
|
-
responseObj[key] = this.searchResponse[key].map(
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
961
|
+
responseObj[key] = this.searchResponse[key].map((entity) => {
|
|
962
|
+
const model = populateFn(entity);
|
|
963
|
+
model.populateRelations(
|
|
964
|
+
this.searchResponse,
|
|
965
|
+
/* @__PURE__ */ new Set()
|
|
966
|
+
);
|
|
967
|
+
return model;
|
|
968
|
+
});
|
|
896
969
|
}
|
|
897
970
|
return responseObj;
|
|
898
971
|
}
|