ia-common 1.1.1-beta.5 → 1.1.1-beta.7

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.
Files changed (40) hide show
  1. package/build/src/enum/user/user-role.enum.d.ts +3 -1
  2. package/build/src/enum/user/user-role.enum.js +2 -0
  3. package/build/src/interface/api/index.d.ts +1 -0
  4. package/build/src/interface/api/index.js +1 -0
  5. package/build/src/interface/api/login.interface.d.ts +0 -1
  6. package/build/src/interface/api/pricing-plan-create.dto.interface.d.ts +2 -2
  7. package/build/src/interface/api/pricing-plan-update-dto.interface.d.ts +2 -2
  8. package/build/src/interface/api/role-user-mapping-create-dto.interface.d.ts +7 -0
  9. package/build/src/interface/api/role-user-mapping-create-dto.interface.js +2 -0
  10. package/build/src/interface/api/update-pricing-plan-by-id.interface.d.ts +2 -2
  11. package/build/src/interface/entity/entity-utils.interface.d.ts +6 -3
  12. package/build/src/interface/entity/entity-utils.interface.js +1 -0
  13. package/build/src/interface/entity/index.d.ts +1 -0
  14. package/build/src/interface/entity/index.js +1 -0
  15. package/build/src/interface/entity/permission.entity.interface.d.ts +0 -1
  16. package/build/src/interface/entity/role-user-mapping-entity.interface.d.ts +8 -0
  17. package/build/src/interface/entity/role-user-mapping-entity.interface.js +2 -0
  18. package/build/src/interface/entity/role.entity.interface.d.ts +0 -1
  19. package/build/src/interface/entity/user-entity.interface.d.ts +0 -2
  20. package/build/src/model/index.d.ts +1 -0
  21. package/build/src/model/index.js +1 -0
  22. package/build/src/model/interface/entity.model.interface.js +3 -0
  23. package/build/src/model/interface/pricing-plan-model.interface.d.ts +2 -2
  24. package/build/src/model/organization-entity-model.d.ts +0 -1
  25. package/build/src/model/organization-entity-model.js +13 -13
  26. package/build/src/model/permission-entity-model.d.ts +0 -1
  27. package/build/src/model/permission-entity-model.js +0 -1
  28. package/build/src/model/pricing-plan-entity-model.d.ts +1 -1
  29. package/build/src/model/pricing-plan-entity-model.js +4 -4
  30. package/build/src/model/pricing-plan-model.d.ts +2 -2
  31. package/build/src/model/pricing-plan-model.js +4 -4
  32. package/build/src/model/role-entity-model.d.ts +0 -1
  33. package/build/src/model/role-entity-model.js +0 -1
  34. package/build/src/model/role-user-mapping-entity-model.d.ts +15 -0
  35. package/build/src/model/role-user-mapping-entity-model.js +26 -0
  36. package/build/src/model/user-entity-model.d.ts +1 -3
  37. package/build/src/model/user-entity-model.js +2 -13
  38. package/build/src/utils/helper.fn.utils.d.ts +27 -0
  39. package/build/src/utils/helper.fn.utils.js +40 -93
  40. package/package.json +1 -1
@@ -5,5 +5,7 @@ export declare enum UserRoleEnum {
5
5
  BOT_USER = "bot_user",
6
6
  PUBLIC_USER = "public_user",
7
7
  ADVISOR_CLIENT = "advisor_client",
8
- STAFF = "staff"
8
+ STAFF = "staff",
9
+ OWNER = "owner",
10
+ CLIENT = "client"
9
11
  }
@@ -10,4 +10,6 @@ var UserRoleEnum;
10
10
  UserRoleEnum["PUBLIC_USER"] = "public_user";
11
11
  UserRoleEnum["ADVISOR_CLIENT"] = "advisor_client";
12
12
  UserRoleEnum["STAFF"] = "staff";
13
+ UserRoleEnum["OWNER"] = "owner";
14
+ UserRoleEnum["CLIENT"] = "client";
13
15
  })(UserRoleEnum || (exports.UserRoleEnum = UserRoleEnum = {}));
@@ -62,3 +62,4 @@ export * from "./role.permission.mapping.create.dto.interface";
62
62
  export * from "./role.permission.mapping.delete.dto.interface";
63
63
  export * from "./role.permission.mapping.response";
64
64
  export * from "./role.permission.mapping.update.dto.interface";
65
+ export * from "./role-user-mapping-create-dto.interface";
@@ -78,3 +78,4 @@ __exportStar(require("./role.permission.mapping.create.dto.interface"), exports)
78
78
  __exportStar(require("./role.permission.mapping.delete.dto.interface"), exports);
79
79
  __exportStar(require("./role.permission.mapping.response"), exports);
80
80
  __exportStar(require("./role.permission.mapping.update.dto.interface"), exports);
81
+ __exportStar(require("./role-user-mapping-create-dto.interface"), exports);
@@ -7,7 +7,6 @@ export interface ILoginResponse {
7
7
  status: string;
8
8
  requireNewPassword: boolean;
9
9
  userId: number;
10
- role: string;
11
10
  email: string | null;
12
11
  imageUrl: string | null;
13
12
  userPermissions: string[];
@@ -1,7 +1,7 @@
1
1
  import { IEntityCreateDto, IPricingPlanEntity, Modify } from "../../@type";
2
2
  export interface ICreatePricingPlanRequest {
3
- effectiveFromDate: number;
4
- effectiveToDate?: number;
3
+ effectiveFrom: number;
4
+ effectiveTo?: number;
5
5
  basePrice: number;
6
6
  billingCycle: IBillingCycle;
7
7
  }
@@ -1,8 +1,8 @@
1
1
  import { EntityEnum, EnumEntityType, IEntityUpdateDto, IPricingPlanEntity, Modify } from "../../@type";
2
2
  import { IBillingCycle } from "./pricing-plan-create.dto.interface";
3
3
  export interface IUpdatePricingPlanRequest {
4
- effectiveFromDate?: number;
5
- effectiveToDate?: number;
4
+ effectiveFrom?: number;
5
+ effectiveTo?: number;
6
6
  basePrice?: number;
7
7
  billingCycle?: IBillingCycle;
8
8
  }
@@ -0,0 +1,7 @@
1
+ export interface IRoleUserMappingDto {
2
+ userId: number;
3
+ roleIds: number[];
4
+ }
5
+ export interface IRoleUserMappingCreateDto {
6
+ mappings: IRoleUserMappingDto[];
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -6,8 +6,8 @@ export interface IUpdatePricingPlanByIdResponse extends Modify<IPricingPlanEntit
6
6
  }> {
7
7
  }
8
8
  export interface IUpdatePricingPlanByIdRequest {
9
- effectiveFromDate?: number;
10
- effectiveToDate?: number;
9
+ effectiveFrom?: number;
10
+ effectiveTo?: number;
11
11
  basePrice?: number;
12
12
  billingCycle?: IBillingCycleDto;
13
13
  }
@@ -6,6 +6,7 @@ import { MutualFundEntityModel } from "../../model/mutual-funds-entity.model";
6
6
  import { PermissionEntityModel } from "../../model/permission-entity-model";
7
7
  import { RegistrationEntityModel } from "../../model/registration-entity-model";
8
8
  import { RoleEntityModel } from "../../model/role-entity-model";
9
+ import { RoleUserMappingEntityModel } from "../../model/role-user-mapping-entity-model";
9
10
  import { IEquityAdviceEntity } from "./advice-entity.interface";
10
11
  import { IAdvisorUserMappingEntity } from "./advisor-user-mapping-entity.interface";
11
12
  import { IBankDetailEntity } from "./bank-details-entity.interface";
@@ -22,6 +23,7 @@ import { IOrganizationEntity } from "./organization-entity.interface";
22
23
  import { IPermissionEntity } from "./permission.entity.interface";
23
24
  import { IPricingPlanEntity } from "./pricing-plan-entity.interface";
24
25
  import { IRegistrationEntity } from "./registration-entity";
26
+ import { IRoleUserMappingEntity } from "./role-user-mapping-entity.interface";
25
27
  import { IRoleEntity } from "./role.entity.interface";
26
28
  import { IRolePermissionMappingEntity } from "./role.permission.mapping.entity.interface";
27
29
  import { ISubscriptionEntity } from "./subscription-entity.interface";
@@ -135,7 +137,8 @@ export declare enum EntityEnum {
135
137
  CRON_JOBS = "cron_jobs",
136
138
  ROLE = "role",
137
139
  PERMISSION = "permissions",
138
- ROLE_PERMISSION_MAPPING = "role_permission_mapping"
140
+ ROLE_PERMISSION_MAPPING = "role_permission_mapping",
141
+ ROLE_USER_MAPPING = "role_user_mapping"
139
142
  }
140
143
  /**
141
144
  * EnumEntityType<T>
@@ -143,7 +146,7 @@ export declare enum EntityEnum {
143
146
  * Maps each EntityEnum to its corresponding Interface.
144
147
  * Ensures strict typing in services, repositories & generic functions.
145
148
  */
146
- export type EnumEntityType<T extends EntityEnum> = (T extends EntityEnum.EQUITY_ADVICE ? IEquityAdviceEntity : T extends EntityEnum.BANK_DETAIL ? IBankDetailEntity : T extends EntityEnum.PRICING_PLAN ? IPricingPlanEntity : T extends EntityEnum.SUBSCRIPTION ? ISubscriptionEntity : T extends EntityEnum.ORGANIZATION ? IOrganizationEntity : T extends EntityEnum.REGISTRATION ? IRegistrationEntity : T extends EntityEnum.USER ? IUserEntity : T extends EntityEnum.ADVISOR_USER_MAPPING ? IAdvisorUserMappingEntity : T extends EntityEnum.MUTUAL_FUNDS ? IMutualFundsEntity : T extends EntityEnum.MUTUAL_FUND_ADVICE ? IMutualFundAdviceEntity : T extends EntityEnum.NFO ? INFOEntity : T extends EntityEnum.NFO_ADVICE ? INFOAdviceEntity : T extends EntityEnum.CORPORATE_ACTIONS ? ICorporateActionsEntity : T extends EntityEnum.CORPORATE_ACTIONS_ADVICE ? ICorporateActionsAdviceEntity : T extends EntityEnum.CONFIGURATION ? IConfigurationsEntity : T extends EntityEnum.CRON_JOBS ? ICronJobsEntity : T extends EntityEnum.ROLE ? IRoleEntity : T extends EntityEnum.PERMISSION ? IPermissionEntity : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? IRolePermissionMappingEntity : never) & {
149
+ export type EnumEntityType<T extends EntityEnum> = (T extends EntityEnum.EQUITY_ADVICE ? IEquityAdviceEntity : T extends EntityEnum.BANK_DETAIL ? IBankDetailEntity : T extends EntityEnum.PRICING_PLAN ? IPricingPlanEntity : T extends EntityEnum.SUBSCRIPTION ? ISubscriptionEntity : T extends EntityEnum.ORGANIZATION ? IOrganizationEntity : T extends EntityEnum.REGISTRATION ? IRegistrationEntity : T extends EntityEnum.USER ? IUserEntity : T extends EntityEnum.ADVISOR_USER_MAPPING ? IAdvisorUserMappingEntity : T extends EntityEnum.MUTUAL_FUNDS ? IMutualFundsEntity : T extends EntityEnum.MUTUAL_FUND_ADVICE ? IMutualFundAdviceEntity : T extends EntityEnum.NFO ? INFOEntity : T extends EntityEnum.NFO_ADVICE ? INFOAdviceEntity : T extends EntityEnum.CORPORATE_ACTIONS ? ICorporateActionsEntity : T extends EntityEnum.CORPORATE_ACTIONS_ADVICE ? ICorporateActionsAdviceEntity : T extends EntityEnum.CONFIGURATION ? IConfigurationsEntity : T extends EntityEnum.CRON_JOBS ? ICronJobsEntity : T extends EntityEnum.ROLE ? IRoleEntity : T extends EntityEnum.PERMISSION ? IPermissionEntity : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? IRolePermissionMappingEntity : T extends EntityEnum.ROLE_USER_MAPPING ? IRoleUserMappingEntity : never) & {
147
150
  id: number;
148
151
  };
149
152
  export type EntityRelations = {
@@ -209,7 +212,7 @@ export type EntityModelIndexMap = {
209
212
  export type EntityMap = {
210
213
  [E in EntityEnum]?: EnumEntityType<E>[];
211
214
  };
212
- export type EnumToModel<T extends EntityEnum> = T extends EntityEnum.EQUITY_ADVICE ? EquityAdviceEntityModel : T extends EntityEnum.BANK_DETAIL ? BankDetailsEntityModel : T extends EntityEnum.PRICING_PLAN ? PricingPlanEntityModel : T extends EntityEnum.SUBSCRIPTION ? SubscriptionEntityModel : T extends EntityEnum.ORGANIZATION ? OrganizationEntityModel : T extends EntityEnum.REGISTRATION ? RegistrationEntityModel : T extends EntityEnum.USER ? UserEntityModel : T extends EntityEnum.ADVISOR_USER_MAPPING ? AdvisorUserMappingEntityModel : T extends EntityEnum.MUTUAL_FUNDS ? MutualFundEntityModel : T extends EntityEnum.MUTUAL_FUND_ADVICE ? MutualFundAdviceEntityModel : T extends EntityEnum.NFO ? NFOEntityModel : T extends EntityEnum.NFO_ADVICE ? NFOAdviceEntityModel : T extends EntityEnum.CORPORATE_ACTIONS ? CorporateActionsEntityModel : T extends EntityEnum.CORPORATE_ACTIONS_ADVICE ? CorporateActionsAdviceEntityModel : T extends EntityEnum.CONFIGURATION ? ConfigurationsEntityModel : T extends EntityEnum.CRON_JOBS ? CronJobsEntityModel : T extends EntityEnum.ROLE ? RoleEntityModel : T extends EntityEnum.PERMISSION ? PermissionEntityModel : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? RolePermissionMappingEntityModel : never;
215
+ export type EnumToModel<T extends EntityEnum> = T extends EntityEnum.EQUITY_ADVICE ? EquityAdviceEntityModel : T extends EntityEnum.BANK_DETAIL ? BankDetailsEntityModel : T extends EntityEnum.PRICING_PLAN ? PricingPlanEntityModel : T extends EntityEnum.SUBSCRIPTION ? SubscriptionEntityModel : T extends EntityEnum.ORGANIZATION ? OrganizationEntityModel : T extends EntityEnum.REGISTRATION ? RegistrationEntityModel : T extends EntityEnum.USER ? UserEntityModel : T extends EntityEnum.ADVISOR_USER_MAPPING ? AdvisorUserMappingEntityModel : T extends EntityEnum.MUTUAL_FUNDS ? MutualFundEntityModel : T extends EntityEnum.MUTUAL_FUND_ADVICE ? MutualFundAdviceEntityModel : T extends EntityEnum.NFO ? NFOEntityModel : T extends EntityEnum.NFO_ADVICE ? NFOAdviceEntityModel : T extends EntityEnum.CORPORATE_ACTIONS ? CorporateActionsEntityModel : T extends EntityEnum.CORPORATE_ACTIONS_ADVICE ? CorporateActionsAdviceEntityModel : T extends EntityEnum.CONFIGURATION ? ConfigurationsEntityModel : T extends EntityEnum.CRON_JOBS ? CronJobsEntityModel : T extends EntityEnum.ROLE ? RoleEntityModel : T extends EntityEnum.PERMISSION ? PermissionEntityModel : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? RolePermissionMappingEntityModel : T extends EntityEnum.ROLE_USER_MAPPING ? RoleUserMappingEntityModel : never;
213
216
  export type IBaseEntityApiResponse<T> = {
214
217
  baseEntities: T[];
215
218
  relatedEntities?: {
@@ -126,5 +126,6 @@ var EntityEnum;
126
126
  EntityEnum["ROLE"] = "role";
127
127
  EntityEnum["PERMISSION"] = "permissions";
128
128
  EntityEnum["ROLE_PERMISSION_MAPPING"] = "role_permission_mapping";
129
+ EntityEnum["ROLE_USER_MAPPING"] = "role_user_mapping";
129
130
  // EQUITY_ADVICE_IN_PROCESS = "equity_advice_in_process",
130
131
  })(EntityEnum || (exports.EntityEnum = EntityEnum = {}));
@@ -22,3 +22,4 @@ export * from "./relation-config.interface";
22
22
  export * from "./role.entity.interface";
23
23
  export * from "./permission.entity.interface";
24
24
  export * from "./role.permission.mapping.entity.interface";
25
+ export * from "./role-user-mapping-entity.interface";
@@ -38,3 +38,4 @@ __exportStar(require("./relation-config.interface"), exports);
38
38
  __exportStar(require("./role.entity.interface"), exports);
39
39
  __exportStar(require("./permission.entity.interface"), exports);
40
40
  __exportStar(require("./role.permission.mapping.entity.interface"), exports);
41
+ __exportStar(require("./role-user-mapping-entity.interface"), exports);
@@ -4,6 +4,5 @@ export interface IPermissionEntity extends IAuditColumnEntity {
4
4
  id: number;
5
5
  name: string;
6
6
  description?: string;
7
- organizationId: number;
8
7
  }
9
8
  export type IPermissionEntityFilterData = IEntitySearch<EntityEnum.PERMISSION>;
@@ -0,0 +1,8 @@
1
+ import { IAuditColumnEntity } from "./audit-column-entity.interface";
2
+ import { EntityEnum, IEntitySearch } from "./entity-utils.interface";
3
+ export interface IRoleUserMappingEntity extends IAuditColumnEntity {
4
+ id: number;
5
+ roleId: number;
6
+ userId: number;
7
+ }
8
+ export type IRoleUserMappingEntityFilterData = IEntitySearch<EntityEnum.ROLE_USER_MAPPING>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,6 +4,5 @@ export interface IRoleEntity extends IAuditColumnEntity {
4
4
  id: number;
5
5
  name: string;
6
6
  description?: string;
7
- organizationId: number;
8
7
  }
9
8
  export type IRoleEntityFilterData = IEntitySearch<EntityEnum.ROLE>;
@@ -1,4 +1,3 @@
1
- import { UserRoleEnum } from "../../@enum";
2
1
  import { UserStatus } from "../../enum/user/user-status.enum";
3
2
  import { IAuditColumnEntity } from "./audit-column-entity.interface";
4
3
  export interface IUserEntity extends IAuditColumnEntity {
@@ -12,7 +11,6 @@ export interface IUserEntity extends IAuditColumnEntity {
12
11
  isMobileVerified: boolean;
13
12
  isAccountVerified: boolean;
14
13
  requireNewPassword: boolean;
15
- role: UserRoleEnum;
16
14
  registrationId: number;
17
15
  organizationId: number;
18
16
  imageUrl: string | null;
@@ -31,3 +31,4 @@ export * from "./configurations-entity-model";
31
31
  export * from "./permission-entity-model";
32
32
  export * from "./role-entity-model";
33
33
  export * from "./role-permission-entity-model";
34
+ export * from "./role-user-mapping-entity-model";
@@ -51,3 +51,4 @@ __exportStar(require("./configurations-entity-model"), exports);
51
51
  __exportStar(require("./permission-entity-model"), exports);
52
52
  __exportStar(require("./role-entity-model"), exports);
53
53
  __exportStar(require("./role-permission-entity-model"), exports);
54
+ __exportStar(require("./role-user-mapping-entity-model"), exports);
@@ -20,6 +20,7 @@ const pricing_plan_entity_model_1 = require("../pricing-plan-entity-model");
20
20
  const registration_entity_model_1 = require("../registration-entity-model");
21
21
  const role_entity_model_1 = require("../role-entity-model");
22
22
  const role_permission_entity_model_1 = require("../role-permission-entity-model");
23
+ const role_user_mapping_entity_model_1 = require("../role-user-mapping-entity-model");
23
24
  const subscription_entity_model_1 = require("../subscription-entity-model");
24
25
  const user_entity_model_1 = require("../user-entity-model");
25
26
  function mapToIndex(entityMap) {
@@ -76,6 +77,7 @@ function parseEntities(json, baseEntity, entityModelMap) {
76
77
  [_type_1.EntityEnum.ROLE]: role_entity_model_1.RoleEntityModel.fromEntity,
77
78
  [_type_1.EntityEnum.PERMISSION]: permission_entity_model_1.PermissionEntityModel.fromEntity,
78
79
  [_type_1.EntityEnum.ROLE_PERMISSION_MAPPING]: role_permission_entity_model_1.RolePermissionMappingEntityModel.fromEntity,
80
+ [_type_1.EntityEnum.ROLE_USER_MAPPING]: role_user_mapping_entity_model_1.RoleUserMappingEntityModel.fromEntity,
79
81
  };
80
82
  if (!(baseEntity in entityFromJsonMappings)) {
81
83
  throw new Error(`Unknown entity: ${baseEntity}`);
@@ -114,6 +116,7 @@ exports.entityEnumToEntityModel = {
114
116
  [_type_1.EntityEnum.ROLE]: role_entity_model_1.RoleEntityModel.fromEntity,
115
117
  [_type_1.EntityEnum.PERMISSION]: permission_entity_model_1.PermissionEntityModel.fromEntity,
116
118
  [_type_1.EntityEnum.ROLE_PERMISSION_MAPPING]: role_permission_entity_model_1.RolePermissionMappingEntityModel.fromEntity,
119
+ [_type_1.EntityEnum.ROLE_USER_MAPPING]: role_user_mapping_entity_model_1.RoleUserMappingEntityModel.fromEntity,
117
120
  };
118
121
  function parseEntitiesWithoutModels(json, baseEntity, entityMap = {}) {
119
122
  var _a;
@@ -1,8 +1,8 @@
1
1
  import { IBillingCycleObj } from "../../interface/selected-billing-cycle.interface";
2
2
  export interface IPricingPlanModel {
3
3
  id: number;
4
- effectiveFromDate: number;
5
- effectiveToDate: number;
4
+ effectiveFrom: number;
5
+ effectiveTo: number;
6
6
  basePrice: number;
7
7
  billingCycle: {
8
8
  [key: string]: IBillingCycleObj;
@@ -54,7 +54,6 @@ export declare class OrganizationEntityModel extends BaseEntityModel<EntityEnum.
54
54
  * Find organization by registrationId
55
55
  */
56
56
  static findByRegistrationId(organizationEntities: IOrganizationEntity[], registrationId: number): IOrganizationEntity | undefined;
57
- validateOwnersCountByOrganizationType(): void;
58
57
  getUsersModels(): UserEntityModel[];
59
58
  static relationConfigs: RelationConfigs<[
60
59
  EntityEnum.USER
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OrganizationEntityModel = void 0;
4
4
  const _enum_1 = require("../@enum");
5
5
  const relation_type_enum_1 = require("../enum/relation-type.enum");
6
- const _model_1 = require("../@model");
7
6
  const _type_1 = require("../@type");
8
7
  const base_entity_model_1 = require("./base.entity.model");
9
8
  class OrganizationEntityModel extends base_entity_model_1.BaseEntityModel {
@@ -144,18 +143,19 @@ class OrganizationEntityModel extends base_entity_model_1.BaseEntityModel {
144
143
  // ): IOrganizationEntity {
145
144
  // return OrganizationEntityModel.fromRegistrationModel(registrationEntity);
146
145
  // }
147
- validateOwnersCountByOrganizationType() {
148
- var _a;
149
- const noOfOwners = (_a = this.users) === null || _a === void 0 ? void 0 : _a.filter((user) => user.role === _enum_1.UserRoleEnum.ADVISOR).length;
150
- if (this.type === _enum_1.OrganizationType.PARTNERSHIP && noOfOwners <= 1) {
151
- throw new _model_1.AppBadRequestException({
152
- key: "organizationType",
153
- message: [
154
- "If the organization is a partnership, it must have a minimum of two owners.",
155
- ],
156
- });
157
- }
158
- }
146
+ // validateOwnersCountByOrganizationType(): void {
147
+ // const noOfOwners = this.users?.filter(
148
+ // (user) => user.role === UserRoleEnum.ADVISOR
149
+ // ).length;
150
+ // if (this.type === OrganizationType.PARTNERSHIP && noOfOwners <= 1) {
151
+ // throw new AppBadRequestException({
152
+ // key: "organizationType",
153
+ // message: [
154
+ // "If the organization is a partnership, it must have a minimum of two owners.",
155
+ // ],
156
+ // });
157
+ // }
158
+ // }
159
159
  getUsersModels() {
160
160
  return this.users;
161
161
  }
@@ -4,7 +4,6 @@ export declare class PermissionEntityModel extends BaseEntityModel<EntityEnum.PE
4
4
  id: number;
5
5
  name: string;
6
6
  description?: string;
7
- organizationId: number;
8
7
  createdOn: number;
9
8
  updatedOn: number;
10
9
  createdBy: number;
@@ -9,7 +9,6 @@ class PermissionEntityModel extends base_entity_model_1.BaseEntityModel {
9
9
  this.id = 0;
10
10
  this.name = "";
11
11
  this.description = "";
12
- this.organizationId = 0;
13
12
  this.createdOn = 0;
14
13
  this.updatedOn = 0;
15
14
  this.createdBy = 0;
@@ -2,8 +2,8 @@ import { PricingPlanStatus } from "../@enum";
2
2
  import { EntityEnum, IBillingCycle, IGetPricingPlanByDateResponse, IPricingPlanEntity } from "../@type";
3
3
  import { BaseEntityModel } from "./base.entity.model";
4
4
  export declare class PricingPlanEntityModel extends BaseEntityModel<EntityEnum.PRICING_PLAN> implements IPricingPlanEntity {
5
- id: number;
6
5
  effectiveFrom: number;
6
+ id: number;
7
7
  effectiveTo: number;
8
8
  status: PricingPlanStatus;
9
9
  createdBy: number;
@@ -20,8 +20,8 @@ class PricingPlanEntityModel extends base_entity_model_1.BaseEntityModel {
20
20
  toObject() {
21
21
  const responseObj = {
22
22
  id: this.id,
23
- effectiveFromDate: 0,
24
- effectiveToDate: 0,
23
+ effectiveFrom: 0,
24
+ effectiveTo: 0,
25
25
  basePrice: 0,
26
26
  billingCycle: {},
27
27
  };
@@ -36,8 +36,8 @@ class PricingPlanEntityModel extends base_entity_model_1.BaseEntityModel {
36
36
  key: billingArray.slice(3).join("-").toLowerCase().replace(/ /g, "-"),
37
37
  };
38
38
  });
39
- responseObj.effectiveFromDate = this.effectiveFrom;
40
- responseObj.effectiveToDate = this.effectiveTo;
39
+ responseObj.effectiveFrom = this.effectiveFrom;
40
+ responseObj.effectiveTo = this.effectiveTo;
41
41
  responseObj.basePrice = this.basePrice;
42
42
  return responseObj;
43
43
  }
@@ -2,8 +2,8 @@ import { IGetPricingPlanByDateResponse, IPricingPlanModel, IBillingCycleObj, IPr
2
2
  import { BaseEntityModel } from "./base.entity.model";
3
3
  export declare class PricingPlanModel extends BaseEntityModel<EntityEnum.PRICING_PLAN> implements IPricingPlanModel {
4
4
  id: number;
5
- effectiveFromDate: number;
6
- effectiveToDate: number;
5
+ effectiveFrom: number;
6
+ effectiveTo: number;
7
7
  basePrice: number;
8
8
  billingCycle: {
9
9
  [key: string]: IBillingCycleObj;
@@ -9,8 +9,8 @@ class PricingPlanModel extends base_entity_model_1.BaseEntityModel {
9
9
  constructor(data) {
10
10
  super(_type_1.EntityEnum.PRICING_PLAN);
11
11
  this.id = 0;
12
- this.effectiveFromDate = 0;
13
- this.effectiveToDate = 0;
12
+ this.effectiveFrom = 0;
13
+ this.effectiveTo = 0;
14
14
  this.basePrice = 0;
15
15
  this.billingCycle = {};
16
16
  if (data)
@@ -75,8 +75,8 @@ class PricingPlanModel extends base_entity_model_1.BaseEntityModel {
75
75
  exports.PricingPlanModel = PricingPlanModel;
76
76
  // export class PricingPlanModel implements IPricingPlanModel {
77
77
  // id: number;
78
- // effectiveFromDate: number;
79
- // effectiveToDate: number;
78
+ // effectiveFrom: number;
79
+ // effectiveTo: number;
80
80
  // basePrice: number;
81
81
  // billingCycle: {
82
82
  // [key: string]: IBillingCycleObj;
@@ -5,7 +5,6 @@ export declare class RoleEntityModel extends BaseEntityModel<EntityEnum.ROLE> im
5
5
  id: number;
6
6
  name: string;
7
7
  description?: string;
8
- organizationId: number;
9
8
  createdOn: number;
10
9
  updatedOn: number;
11
10
  createdBy: number;
@@ -9,7 +9,6 @@ class RoleEntityModel extends base_entity_model_1.BaseEntityModel {
9
9
  this.id = 0;
10
10
  this.name = "";
11
11
  this.description = "";
12
- this.organizationId = 0;
13
12
  this.createdOn = 0;
14
13
  this.updatedOn = 0;
15
14
  this.createdBy = 0;
@@ -0,0 +1,15 @@
1
+ import { EntityEnum } from "../@type";
2
+ import { IRoleUserMappingEntity } from "../interface/entity/role-user-mapping-entity.interface";
3
+ import { BaseEntityModel } from "./base.entity.model";
4
+ export declare class RoleUserMappingEntityModel extends BaseEntityModel<EntityEnum.ROLE_USER_MAPPING> implements IRoleUserMappingEntity {
5
+ id: number;
6
+ roleId: number;
7
+ userId: number;
8
+ createdOn: number;
9
+ updatedOn: number;
10
+ createdBy: number;
11
+ updatedBy: number;
12
+ constructor();
13
+ static fromEntity(entity: IRoleUserMappingEntity): RoleUserMappingEntityModel;
14
+ getRelationConfigs(): any;
15
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RoleUserMappingEntityModel = void 0;
4
+ const _type_1 = require("../@type");
5
+ const base_entity_model_1 = require("./base.entity.model");
6
+ class RoleUserMappingEntityModel extends base_entity_model_1.BaseEntityModel {
7
+ constructor() {
8
+ super(_type_1.EntityEnum.ROLE_USER_MAPPING);
9
+ this.id = 0;
10
+ this.roleId = 0;
11
+ this.userId = 0;
12
+ this.createdOn = 0;
13
+ this.updatedOn = 0;
14
+ this.createdBy = 0;
15
+ this.updatedBy = 0;
16
+ }
17
+ static fromEntity(entity) {
18
+ const result = new RoleUserMappingEntityModel();
19
+ Object.assign(result, entity);
20
+ return result;
21
+ }
22
+ getRelationConfigs() {
23
+ return this.constructor.prototype.constructor.relationConfigs;
24
+ }
25
+ }
26
+ exports.RoleUserMappingEntityModel = RoleUserMappingEntityModel;
@@ -1,4 +1,4 @@
1
- import { UserRoleEnum, UserStatus } from "../@enum";
1
+ import { UserStatus } from "../@enum";
2
2
  import { EntityEnum, IOrganizationEntity, IRegistrationEntity, IUserEntity } from "../@type";
3
3
  import { BaseEntityModel } from "./base.entity.model";
4
4
  export declare class UserEntityModel extends BaseEntityModel<EntityEnum.USER> implements IUserEntity {
@@ -12,7 +12,6 @@ export declare class UserEntityModel extends BaseEntityModel<EntityEnum.USER> im
12
12
  isMobileVerified: boolean;
13
13
  isAccountVerified: boolean;
14
14
  requireNewPassword: boolean;
15
- role: UserRoleEnum;
16
15
  registrationId: number;
17
16
  organizationId: number;
18
17
  imageUrl: string | null;
@@ -28,5 +27,4 @@ export declare class UserEntityModel extends BaseEntityModel<EntityEnum.USER> im
28
27
  static filterByOrganizationId(userEntities: IUserEntity[], organizationId: number): IUserEntity[];
29
28
  static getUserEntityInstanceFromRegistrationEntityOrganizationEntity(registrationEntity: IRegistrationEntity, organizationEntity: IOrganizationEntity, hashedPassword: string): IUserEntity;
30
29
  getRelationConfigs(): any;
31
- validateUserRoleSuperAdmin(): void;
32
30
  }
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserEntityModel = void 0;
4
4
  const _enum_1 = require("../@enum");
5
- const _model_1 = require("../@model");
6
5
  const _type_1 = require("../@type");
7
6
  const base_entity_model_1 = require("./base.entity.model");
8
7
  class UserEntityModel extends base_entity_model_1.BaseEntityModel {
@@ -18,7 +17,7 @@ class UserEntityModel extends base_entity_model_1.BaseEntityModel {
18
17
  this.isMobileVerified = false;
19
18
  this.isAccountVerified = false;
20
19
  this.requireNewPassword = false;
21
- this.role = _enum_1.UserRoleEnum.ADVISOR;
20
+ // role: UserRoleEnum = UserRoleEnum.ADVISOR;
22
21
  this.registrationId = 0;
23
22
  this.organizationId = 0;
24
23
  this.imageUrl = null;
@@ -44,7 +43,7 @@ class UserEntityModel extends base_entity_model_1.BaseEntityModel {
44
43
  userEntity.isEmailVerified = false;
45
44
  userEntity.isMobileVerified = false;
46
45
  userEntity.status = _enum_1.UserStatus.REGISTRATION_APPROVED;
47
- userEntity.role = _enum_1.UserRoleEnum.ADVISOR;
46
+ // userEntity.role = UserRoleEnum.OWNER;
48
47
  userEntity.createdBy = registrationEntity.createdBy;
49
48
  userEntity.updatedBy = registrationEntity.createdBy;
50
49
  userEntity.updatedOn = Date.now();
@@ -62,16 +61,6 @@ class UserEntityModel extends base_entity_model_1.BaseEntityModel {
62
61
  getRelationConfigs() {
63
62
  return this.constructor.prototype.constructor.relationConfigs;
64
63
  }
65
- validateUserRoleSuperAdmin() {
66
- if (this.role !== _enum_1.UserRoleEnum.SUPERADMIN) {
67
- throw new _model_1.AppBadRequestException({
68
- key: "status",
69
- message: [
70
- `Only the SuperAdmin can update the status of ${_enum_1.OrganizationStatus.ACTIVE} and ${_enum_1.OrganizationStatus.ACCOUNT_SUSPENDED}.`,
71
- ],
72
- });
73
- }
74
- }
75
64
  }
76
65
  exports.UserEntityModel = UserEntityModel;
77
66
  // export class UserEntityModel implements IUserEntity {
@@ -86,3 +86,30 @@ export declare function groupByOneToOneFunction<T, K>(list: T[], keyGetter: (inp
86
86
  export declare function getPropertyFilterByPermissionFn<T extends EntityEnum>(permissionFilterConfig: {
87
87
  [key: string]: () => Promise<IEntitySearch<T>>;
88
88
  }, propertyNames: string[], userPermission: string, filterDto: IEntitySearch<T>, emptyValue?: any): Promise<IEntitySearch<T>>;
89
+ /**
90
+ * Returns the list of duplicate values from an array.
91
+ *
92
+ * @template T - The type of elements in the array.
93
+ *
94
+ * @param {T[]} arr - The array to check for duplicates.
95
+ *
96
+ * @returns {T[]} An array containing the values that appear more than once.
97
+ * Each duplicate value is included only once.
98
+ *
99
+ * @description
100
+ * This function scans the array and counts occurrences of each value using a Map.
101
+ * Any value with a count greater than 1 is considered a duplicate.
102
+ *
103
+ * @example
104
+ * getDuplicates([1, 2, 2, 3, 3, 3]);
105
+ * // Returns: [2, 3]
106
+ *
107
+ * @example
108
+ * getDuplicates(['a', 'b', 'b', 'c']);
109
+ * // Returns: ['b']
110
+ *
111
+ * @remarks
112
+ * - Works with all primitive types: number, string, boolean, undefined, null.
113
+ * - For objects, duplicates are based on **reference equality**, not deep equality.
114
+ */
115
+ export declare function getDuplicates<T>(arr: T[]): T[];
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getPropertyFilterByPermissionFn = exports.groupByOneToOneFunction = exports.deepMerge = exports.toDateFromEpoch = exports.groupByFunction = exports.transformDate = exports.getStringValues = exports.getTodayISTEpoch = void 0;
12
+ exports.getDuplicates = exports.getPropertyFilterByPermissionFn = exports.groupByOneToOneFunction = exports.deepMerge = exports.toDateFromEpoch = exports.groupByFunction = exports.transformDate = exports.getStringValues = exports.getTodayISTEpoch = void 0;
13
13
  const _type_1 = require("../@type");
14
14
  /**
15
15
  * Returns epoch time (ms) for today's date at the given local time (IST).
@@ -183,95 +183,42 @@ function getPropertyFilterByPermissionFn(permissionFilterConfig, propertyNames,
183
183
  });
184
184
  }
185
185
  exports.getPropertyFilterByPermissionFn = getPropertyFilterByPermissionFn;
186
- // export async function getPropertyFilterByPermissionFn<T extends EntityEnum>(
187
- // permissionFilterConfig: {
188
- // [key: string]: () => Promise<IEntitySearch<T>>;
189
- // },
190
- // propertyNames: (keyof EnumEntityType<T>)[],
191
- // userPermission: string,
192
- // filterDto: IEntitySearch<T>,
193
- // emptyValue: any = []
194
- // ) {
195
- // const filterData = await permissionFilterConfig[userPermission]();
196
- // const result: IEntitySearch<T> = {
197
- // name: filterDto.name,
198
- // include: {},
199
- // };
200
- // const permissionInclude = filterData.include ?? {}; // <-- FIX
201
- // for (const propertyName of propertyNames) {
202
- // const dtoFilterInclude = filterDto.include;
203
- // const dtoFilter = dtoFilterInclude![propertyName as keyof IEntitySearch<T>];
204
- // const permissionFilter =
205
- // permissionInclude[propertyName as keyof IEntitySearch<T>];
206
- // const isDtoFilterIdPresent = dtoFilter && dtoFilter.length > 0;
207
- // const isPermissionFilterIdPresent =
208
- // permissionFilter &&
209
- // Array.isArray(permissionFilter) &&
210
- // permissionFilter.length > 0;
211
- // if (!result.include) result.include = {};
212
- // result.include[propertyName as keyof IEntitySearch<T>] =
213
- // isPermissionFilterIdPresent
214
- // ? isDtoFilterIdPresent
215
- // ? arrayIntersection(permissionFilter as any[], dtoFilter).length > 0
216
- // ? arrayIntersection(permissionFilter as any[], dtoFilter)
217
- // : emptyValue
218
- // : permissionFilter
219
- // : dtoFilter ?? emptyValue;
220
- // }
221
- // return result;
222
- // }
223
- // export function getFilterByPermission<T extends EnumEntityType<EntityEnum>>(
224
- // permissionFilterConfig: {
225
- // [key: string]: IEntityFilterData<T>;
226
- // },
227
- // propertyName: keyof T,
228
- // userPermission: string,
229
- // filterDto: IEntityFilterData<T>,
230
- // emptyValue: any = []
231
- // ) {
232
- // const dtoFilter = filterDto[propertyName as keyof IEntityFilterData<T>];
233
- // const permissionFilter =
234
- // permissionFilterConfig[userPermission][
235
- // propertyName as keyof IEntityFilterData<T>
236
- // ];
237
- // const isDtoFilterIdPresent = dtoFilter && dtoFilter.length > 0;
238
- // const isPermissionFilterIdPresent =
239
- // permissionFilter && permissionFilter.length > 0;
240
- // return {
241
- // [propertyName]: isPermissionFilterIdPresent
242
- // ? isDtoFilterIdPresent
243
- // ? arrayIntersection(permissionFilter as any[], dtoFilter).length > 0
244
- // ? arrayIntersection(permissionFilter as any[], dtoFilter)
245
- // : emptyValue
246
- // : permissionFilter
247
- // : dtoFilter,
248
- // };
249
- // }
250
- // export async function getFilterByPermissionFn<
251
- // T extends EnumEntityType<EntityEnum>
252
- // >(
253
- // permissionFilterConfig: {
254
- // [key: string]: () => Promise<IEntityFilterData<T>>;
255
- // },
256
- // propertyName: keyof T,
257
- // userPermission: string,
258
- // filterDto: IEntityFilterData<T>,
259
- // emptyValue: any = []
260
- // ) {
261
- // const filterData = await permissionFilterConfig[userPermission]();
262
- // const dtoFilter = filterDto[propertyName as keyof IEntityFilterData<T>];
263
- // const permissionFilter =
264
- // filterData[propertyName as keyof IEntityFilterData<T>];
265
- // const isDtoFilterIdPresent = dtoFilter && dtoFilter.length > 0;
266
- // const isPermissionFilterIdPresent =
267
- // permissionFilter && permissionFilter.length > 0;
268
- // return {
269
- // [propertyName]: isPermissionFilterIdPresent
270
- // ? isDtoFilterIdPresent
271
- // ? arrayIntersection(permissionFilter as any[], dtoFilter).length > 0
272
- // ? arrayIntersection(permissionFilter as any[], dtoFilter)
273
- // : emptyValue
274
- // : permissionFilter
275
- // : dtoFilter,
276
- // };
277
- // }
186
+ /**
187
+ * Returns the list of duplicate values from an array.
188
+ *
189
+ * @template T - The type of elements in the array.
190
+ *
191
+ * @param {T[]} arr - The array to check for duplicates.
192
+ *
193
+ * @returns {T[]} An array containing the values that appear more than once.
194
+ * Each duplicate value is included only once.
195
+ *
196
+ * @description
197
+ * This function scans the array and counts occurrences of each value using a Map.
198
+ * Any value with a count greater than 1 is considered a duplicate.
199
+ *
200
+ * @example
201
+ * getDuplicates([1, 2, 2, 3, 3, 3]);
202
+ * // Returns: [2, 3]
203
+ *
204
+ * @example
205
+ * getDuplicates(['a', 'b', 'b', 'c']);
206
+ * // Returns: ['b']
207
+ *
208
+ * @remarks
209
+ * - Works with all primitive types: number, string, boolean, undefined, null.
210
+ * - For objects, duplicates are based on **reference equality**, not deep equality.
211
+ */
212
+ function getDuplicates(arr) {
213
+ const countMap = new Map();
214
+ for (const item of arr) {
215
+ countMap.set(item, (countMap.get(item) || 0) + 1);
216
+ }
217
+ const duplicates = [];
218
+ for (const [value, count] of countMap.entries()) {
219
+ if (count > 1)
220
+ duplicates.push(value);
221
+ }
222
+ return duplicates;
223
+ }
224
+ exports.getDuplicates = getDuplicates;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ia-common",
3
- "version": "1.1.1-beta.5",
3
+ "version": "1.1.1-beta.7",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",