ia-common 1.1.1-beta.4 → 1.1.1-beta.5
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/build/src/@enum.d.ts +2 -1
- package/build/src/@enum.js +2 -1
- package/build/src/enum/error.key.enum.d.ts +3 -0
- package/build/src/enum/error.key.enum.js +7 -0
- package/build/src/enum/user/{user-type.enum.d.ts → user-role.enum.d.ts} +1 -1
- package/build/src/enum/user/user-role.enum.js +13 -0
- package/build/src/interface/api/create-user-dto.interface.d.ts +2 -2
- package/build/src/interface/api/index.d.ts +10 -2
- package/build/src/interface/api/index.js +10 -2
- package/build/src/interface/api/permission.create.dto.interface.d.ts +3 -0
- package/build/src/interface/api/permission.create.dto.interface.js +2 -0
- package/build/src/interface/api/permission.update.dto.interface.d.ts +3 -0
- package/build/src/interface/api/permission.update.dto.interface.js +2 -0
- package/build/src/interface/api/role-create-dto.interface.d.ts +3 -0
- package/build/src/interface/api/role-create-dto.interface.js +2 -0
- package/build/src/interface/api/role-update-dto.interface.d.ts +3 -0
- package/build/src/interface/api/role-update-dto.interface.js +2 -0
- package/build/src/interface/api/role.permission.mapping.create.dto.interface.d.ts +5 -0
- package/build/src/interface/api/role.permission.mapping.create.dto.interface.js +2 -0
- package/build/src/interface/api/role.permission.mapping.delete.dto.interface.d.ts +3 -0
- package/build/src/interface/api/role.permission.mapping.delete.dto.interface.js +2 -0
- package/build/src/interface/api/role.permission.mapping.response.d.ts +5 -0
- package/build/src/interface/api/role.permission.mapping.response.js +2 -0
- package/build/src/interface/api/role.permission.mapping.update.dto.interface.d.ts +3 -0
- package/build/src/interface/api/role.permission.mapping.update.dto.interface.js +2 -0
- package/build/src/interface/entity/entity-utils.interface.d.ts +13 -5
- package/build/src/interface/entity/entity-utils.interface.js +4 -1
- package/build/src/interface/entity/index.d.ts +3 -0
- package/build/src/interface/entity/index.js +3 -0
- package/build/src/interface/entity/permission.entity.interface.d.ts +9 -0
- package/build/src/interface/entity/permission.entity.interface.js +2 -0
- package/build/src/interface/entity/role.entity.interface.d.ts +9 -0
- package/build/src/interface/entity/role.entity.interface.js +2 -0
- package/build/src/interface/entity/role.permission.mapping.entity.interface.d.ts +8 -0
- package/build/src/interface/entity/role.permission.mapping.entity.interface.js +2 -0
- package/build/src/interface/entity/user-entity.interface.d.ts +3 -2
- package/build/src/model/equity-advice-entity-model.js +46 -46
- package/build/src/model/index.d.ts +13 -10
- package/build/src/model/index.js +13 -10
- package/build/src/model/interface/entity.model.interface.js +9 -0
- package/build/src/model/organization-entity-model.js +1 -1
- package/build/src/model/permission-entity-model.d.ts +18 -0
- package/build/src/model/permission-entity-model.js +30 -0
- package/build/src/model/role-entity-model.d.ts +15 -0
- package/build/src/model/role-entity-model.js +27 -0
- package/build/src/model/role-permission-entity-model.d.ts +15 -0
- package/build/src/model/role-permission-entity-model.js +26 -0
- package/build/src/model/user-entity-model.d.ts +4 -3
- package/build/src/model/user-entity-model.js +4 -4
- package/build/src/red-black-tree/js-cols.d.ts +2 -0
- package/build/src/red-black-tree/js-cols.js +12 -0
- package/build/src/utils/helper.fn.utils.d.ts +5 -1
- package/build/src/utils/helper.fn.utils.js +152 -1
- package/package.json +1 -1
- package/build/src/enum/user/user-type.enum.js +0 -13
package/build/src/@enum.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./enum/organization/organization-status.enum";
|
|
2
2
|
export * from "./enum/organization/organization-type.enum";
|
|
3
3
|
export * from "./enum/user/user-status.enum";
|
|
4
|
-
export * from "./enum/user/user-
|
|
4
|
+
export * from "./enum/user/user-role.enum";
|
|
5
5
|
export * from "./enum/user/registration-status.enum";
|
|
6
6
|
export * from "./enum/organization/pricing-plan-status.enum";
|
|
7
7
|
export * from "./enum/organization/subscription-status.enum";
|
|
@@ -30,3 +30,4 @@ export * from "./enum/configuration.enum";
|
|
|
30
30
|
export * from "./enum/cron-job.enum";
|
|
31
31
|
export * from "./enum/time-zone.enum";
|
|
32
32
|
export * from "./enum/relation-type.enum";
|
|
33
|
+
export * from "./enum/error.key.enum";
|
package/build/src/@enum.js
CHANGED
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./enum/organization/organization-status.enum"), exports);
|
|
18
18
|
__exportStar(require("./enum/organization/organization-type.enum"), exports);
|
|
19
19
|
__exportStar(require("./enum/user/user-status.enum"), exports);
|
|
20
|
-
__exportStar(require("./enum/user/user-
|
|
20
|
+
__exportStar(require("./enum/user/user-role.enum"), exports);
|
|
21
21
|
__exportStar(require("./enum/user/registration-status.enum"), exports);
|
|
22
22
|
__exportStar(require("./enum/organization/pricing-plan-status.enum"), exports);
|
|
23
23
|
__exportStar(require("./enum/organization/subscription-status.enum"), exports);
|
|
@@ -46,3 +46,4 @@ __exportStar(require("./enum/configuration.enum"), exports);
|
|
|
46
46
|
__exportStar(require("./enum/cron-job.enum"), exports);
|
|
47
47
|
__exportStar(require("./enum/time-zone.enum"), exports);
|
|
48
48
|
__exportStar(require("./enum/relation-type.enum"), exports);
|
|
49
|
+
__exportStar(require("./enum/error.key.enum"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorKeyEnum = void 0;
|
|
4
|
+
var ErrorKeyEnum;
|
|
5
|
+
(function (ErrorKeyEnum) {
|
|
6
|
+
ErrorKeyEnum["USER_ROLE"] = "USER_ROLE";
|
|
7
|
+
})(ErrorKeyEnum || (exports.ErrorKeyEnum = ErrorKeyEnum = {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserRoleEnum = void 0;
|
|
4
|
+
var UserRoleEnum;
|
|
5
|
+
(function (UserRoleEnum) {
|
|
6
|
+
UserRoleEnum["USER"] = "user";
|
|
7
|
+
UserRoleEnum["ADVISOR"] = "advisor";
|
|
8
|
+
UserRoleEnum["SUPERADMIN"] = "superadmin";
|
|
9
|
+
UserRoleEnum["BOT_USER"] = "bot_user";
|
|
10
|
+
UserRoleEnum["PUBLIC_USER"] = "public_user";
|
|
11
|
+
UserRoleEnum["ADVISOR_CLIENT"] = "advisor_client";
|
|
12
|
+
UserRoleEnum["STAFF"] = "staff";
|
|
13
|
+
})(UserRoleEnum || (exports.UserRoleEnum = UserRoleEnum = {}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UserStatus,
|
|
1
|
+
import { UserStatus, UserRoleEnum } from "../../@enum";
|
|
2
2
|
import { IEntityCreateDto, IUserEntity } from "../entity";
|
|
3
3
|
export type IUserCreateDtoExclude = "status" | "isEmailVerified" | "isMobileVerified" | "isAccountVerified" | "requireNewPassword" | "type" | "registrationId" | "organizationId" | "imageUrl" | "documentUrls" | "password" | "panNo";
|
|
4
4
|
export interface IUserCreateDto extends IEntityCreateDto<Omit<IUserEntity, IUserCreateDtoExclude>> {
|
|
@@ -7,7 +7,7 @@ export interface IUserCreateDto extends IEntityCreateDto<Omit<IUserEntity, IUser
|
|
|
7
7
|
isMobileVerified?: boolean;
|
|
8
8
|
isAccountVerified?: boolean;
|
|
9
9
|
requireNewPassword?: boolean;
|
|
10
|
-
|
|
10
|
+
role: UserRoleEnum;
|
|
11
11
|
registrationId?: number;
|
|
12
12
|
organizationId?: number;
|
|
13
13
|
panNo?: string;
|
|
@@ -27,8 +27,8 @@ export * from "./mutual-fund-advice-create-dto.interface";
|
|
|
27
27
|
export * from "../entity/advisor-user-mapping-entity.interface";
|
|
28
28
|
export * from "../corporate-actions/base-corporate-actions.interface";
|
|
29
29
|
export * from "./get-corporate-actions.interface";
|
|
30
|
-
export * from "./advior-user-interface";
|
|
31
30
|
export * from "../corporate-actions/create-bonus-stock.interface";
|
|
31
|
+
export * from "./advior-user-interface";
|
|
32
32
|
export * from "./create-bulk-advice-using-csv.interface";
|
|
33
33
|
export * from "./create-corporate-action-advice.interface";
|
|
34
34
|
export * from "./get-configuration.interface";
|
|
@@ -50,7 +50,15 @@ export * from "./update-corporate-action.interface";
|
|
|
50
50
|
export * from "./create-user-dto.interface";
|
|
51
51
|
export * from "./update-user-dto.interface";
|
|
52
52
|
export * from "./mutual-fund-advice-update-dto.interface";
|
|
53
|
+
export * from "./configurations-create-dto.interface";
|
|
53
54
|
export * from "./corporate-actions-create.dto";
|
|
54
55
|
export * from "./corporate-actions-update.dto";
|
|
55
|
-
export * from "./configurations-create-dto.interface";
|
|
56
56
|
export * from "./configuration-update-dto.interface";
|
|
57
|
+
export * from "./permission.create.dto.interface";
|
|
58
|
+
export * from "./permission.update.dto.interface";
|
|
59
|
+
export * from "./role-create-dto.interface";
|
|
60
|
+
export * from "./role-update-dto.interface";
|
|
61
|
+
export * from "./role.permission.mapping.create.dto.interface";
|
|
62
|
+
export * from "./role.permission.mapping.delete.dto.interface";
|
|
63
|
+
export * from "./role.permission.mapping.response";
|
|
64
|
+
export * from "./role.permission.mapping.update.dto.interface";
|
|
@@ -43,8 +43,8 @@ __exportStar(require("./mutual-fund-advice-create-dto.interface"), exports);
|
|
|
43
43
|
__exportStar(require("../entity/advisor-user-mapping-entity.interface"), exports);
|
|
44
44
|
__exportStar(require("../corporate-actions/base-corporate-actions.interface"), exports);
|
|
45
45
|
__exportStar(require("./get-corporate-actions.interface"), exports);
|
|
46
|
-
__exportStar(require("./advior-user-interface"), exports);
|
|
47
46
|
__exportStar(require("../corporate-actions/create-bonus-stock.interface"), exports);
|
|
47
|
+
__exportStar(require("./advior-user-interface"), exports);
|
|
48
48
|
__exportStar(require("./create-bulk-advice-using-csv.interface"), exports);
|
|
49
49
|
__exportStar(require("./create-corporate-action-advice.interface"), exports);
|
|
50
50
|
__exportStar(require("./get-configuration.interface"), exports);
|
|
@@ -66,7 +66,15 @@ __exportStar(require("./update-corporate-action.interface"), exports);
|
|
|
66
66
|
__exportStar(require("./create-user-dto.interface"), exports);
|
|
67
67
|
__exportStar(require("./update-user-dto.interface"), exports);
|
|
68
68
|
__exportStar(require("./mutual-fund-advice-update-dto.interface"), exports);
|
|
69
|
+
__exportStar(require("./configurations-create-dto.interface"), exports);
|
|
69
70
|
__exportStar(require("./corporate-actions-create.dto"), exports);
|
|
70
71
|
__exportStar(require("./corporate-actions-update.dto"), exports);
|
|
71
|
-
__exportStar(require("./configurations-create-dto.interface"), exports);
|
|
72
72
|
__exportStar(require("./configuration-update-dto.interface"), exports);
|
|
73
|
+
__exportStar(require("./permission.create.dto.interface"), exports);
|
|
74
|
+
__exportStar(require("./permission.update.dto.interface"), exports);
|
|
75
|
+
__exportStar(require("./role-create-dto.interface"), exports);
|
|
76
|
+
__exportStar(require("./role-update-dto.interface"), exports);
|
|
77
|
+
__exportStar(require("./role.permission.mapping.create.dto.interface"), exports);
|
|
78
|
+
__exportStar(require("./role.permission.mapping.delete.dto.interface"), exports);
|
|
79
|
+
__exportStar(require("./role.permission.mapping.response"), exports);
|
|
80
|
+
__exportStar(require("./role.permission.mapping.update.dto.interface"), exports);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { BankDetailsEntityModel, ConfigurationsEntityModel, CorporateActionsEntityModel, EquityAdviceEntityModel, MutualFundAdviceEntityModel, NFOAdviceEntityModel, NFOEntityModel, OrganizationEntityModel, PricingPlanEntityModel, SubscriptionEntityModel, UserEntityModel } from "../../model";
|
|
1
|
+
import { BankDetailsEntityModel, ConfigurationsEntityModel, CorporateActionsEntityModel, EquityAdviceEntityModel, MutualFundAdviceEntityModel, NFOAdviceEntityModel, NFOEntityModel, OrganizationEntityModel, PricingPlanEntityModel, RolePermissionMappingEntityModel, SubscriptionEntityModel, UserEntityModel } from "../../model";
|
|
2
2
|
import { AdvisorUserMappingEntityModel } from "../../model/advisor-user-mapping-entity-model";
|
|
3
3
|
import { CorporateActionsAdviceEntityModel } from "../../model/corporate-actions/corporate-actions-advice-model";
|
|
4
4
|
import { CronJobsEntityModel } from "../../model/cron-jobs-entity-model";
|
|
5
5
|
import { MutualFundEntityModel } from "../../model/mutual-funds-entity.model";
|
|
6
|
+
import { PermissionEntityModel } from "../../model/permission-entity-model";
|
|
6
7
|
import { RegistrationEntityModel } from "../../model/registration-entity-model";
|
|
8
|
+
import { RoleEntityModel } from "../../model/role-entity-model";
|
|
7
9
|
import { IEquityAdviceEntity } from "./advice-entity.interface";
|
|
8
10
|
import { IAdvisorUserMappingEntity } from "./advisor-user-mapping-entity.interface";
|
|
9
11
|
import { IBankDetailEntity } from "./bank-details-entity.interface";
|
|
@@ -17,8 +19,11 @@ import { IMutualFundsEntity } from "./mutual-funds-entity.interface";
|
|
|
17
19
|
import { INFOAdviceEntity } from "./nfo-advice-entity.interface";
|
|
18
20
|
import { INFOEntity } from "./nfo-entity.interface";
|
|
19
21
|
import { IOrganizationEntity } from "./organization-entity.interface";
|
|
22
|
+
import { IPermissionEntity } from "./permission.entity.interface";
|
|
20
23
|
import { IPricingPlanEntity } from "./pricing-plan-entity.interface";
|
|
21
24
|
import { IRegistrationEntity } from "./registration-entity";
|
|
25
|
+
import { IRoleEntity } from "./role.entity.interface";
|
|
26
|
+
import { IRolePermissionMappingEntity } from "./role.permission.mapping.entity.interface";
|
|
22
27
|
import { ISubscriptionEntity } from "./subscription-entity.interface";
|
|
23
28
|
import { IUserEntity } from "./user-entity.interface";
|
|
24
29
|
/**
|
|
@@ -77,7 +82,7 @@ export declare function arrayIntersection<T>(source: T[], target: T[]): T[];
|
|
|
77
82
|
* @example
|
|
78
83
|
* const existing = [1, 2, 3];
|
|
79
84
|
* const incoming = [2, 3, 4];
|
|
80
|
-
* const result =
|
|
85
|
+
* const result = getArrayChangeSet(existing, incoming);
|
|
81
86
|
* console.log(result); // Output: { added: [4], deleted: [1], present: [2, 3, 4] }
|
|
82
87
|
*/
|
|
83
88
|
export declare function getArrayChangeSet<T>(existing: T[], incoming: T[]): {
|
|
@@ -127,7 +132,10 @@ export declare enum EntityEnum {
|
|
|
127
132
|
CORPORATE_ACTIONS = "corporate_actions",
|
|
128
133
|
CORPORATE_ACTIONS_ADVICE = "corporate_actions_advice",
|
|
129
134
|
CONFIGURATION = "configuration",
|
|
130
|
-
CRON_JOBS = "cron_jobs"
|
|
135
|
+
CRON_JOBS = "cron_jobs",
|
|
136
|
+
ROLE = "role",
|
|
137
|
+
PERMISSION = "permissions",
|
|
138
|
+
ROLE_PERMISSION_MAPPING = "role_permission_mapping"
|
|
131
139
|
}
|
|
132
140
|
/**
|
|
133
141
|
* EnumEntityType<T>
|
|
@@ -135,7 +143,7 @@ export declare enum EntityEnum {
|
|
|
135
143
|
* Maps each EntityEnum to its corresponding Interface.
|
|
136
144
|
* Ensures strict typing in services, repositories & generic functions.
|
|
137
145
|
*/
|
|
138
|
-
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 : never) & {
|
|
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) & {
|
|
139
147
|
id: number;
|
|
140
148
|
};
|
|
141
149
|
export type EntityRelations = {
|
|
@@ -201,7 +209,7 @@ export type EntityModelIndexMap = {
|
|
|
201
209
|
export type EntityMap = {
|
|
202
210
|
[E in EntityEnum]?: EnumEntityType<E>[];
|
|
203
211
|
};
|
|
204
|
-
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 : never;
|
|
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;
|
|
205
213
|
export type IBaseEntityApiResponse<T> = {
|
|
206
214
|
baseEntities: T[];
|
|
207
215
|
relatedEntities?: {
|
|
@@ -66,7 +66,7 @@ exports.arrayIntersection = arrayIntersection;
|
|
|
66
66
|
* @example
|
|
67
67
|
* const existing = [1, 2, 3];
|
|
68
68
|
* const incoming = [2, 3, 4];
|
|
69
|
-
* const result =
|
|
69
|
+
* const result = getArrayChangeSet(existing, incoming);
|
|
70
70
|
* console.log(result); // Output: { added: [4], deleted: [1], present: [2, 3, 4] }
|
|
71
71
|
*/
|
|
72
72
|
function getArrayChangeSet(existing, incoming) {
|
|
@@ -123,5 +123,8 @@ var EntityEnum;
|
|
|
123
123
|
EntityEnum["CORPORATE_ACTIONS_ADVICE"] = "corporate_actions_advice";
|
|
124
124
|
EntityEnum["CONFIGURATION"] = "configuration";
|
|
125
125
|
EntityEnum["CRON_JOBS"] = "cron_jobs";
|
|
126
|
+
EntityEnum["ROLE"] = "role";
|
|
127
|
+
EntityEnum["PERMISSION"] = "permissions";
|
|
128
|
+
EntityEnum["ROLE_PERMISSION_MAPPING"] = "role_permission_mapping";
|
|
126
129
|
// EQUITY_ADVICE_IN_PROCESS = "equity_advice_in_process",
|
|
127
130
|
})(EntityEnum || (exports.EntityEnum = EntityEnum = {}));
|
|
@@ -19,3 +19,6 @@ export * from "./cron-job-entity.interface";
|
|
|
19
19
|
export * from "./entity-utils.interface";
|
|
20
20
|
export * from "./audit-column-entity.interface";
|
|
21
21
|
export * from "./relation-config.interface";
|
|
22
|
+
export * from "./role.entity.interface";
|
|
23
|
+
export * from "./permission.entity.interface";
|
|
24
|
+
export * from "./role.permission.mapping.entity.interface";
|
|
@@ -35,3 +35,6 @@ __exportStar(require("./cron-job-entity.interface"), exports);
|
|
|
35
35
|
__exportStar(require("./entity-utils.interface"), exports);
|
|
36
36
|
__exportStar(require("./audit-column-entity.interface"), exports);
|
|
37
37
|
__exportStar(require("./relation-config.interface"), exports);
|
|
38
|
+
__exportStar(require("./role.entity.interface"), exports);
|
|
39
|
+
__exportStar(require("./permission.entity.interface"), exports);
|
|
40
|
+
__exportStar(require("./role.permission.mapping.entity.interface"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IAuditColumnEntity } from "./audit-column-entity.interface";
|
|
2
|
+
import { EntityEnum, IEntitySearch } from "./entity-utils.interface";
|
|
3
|
+
export interface IPermissionEntity extends IAuditColumnEntity {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
organizationId: number;
|
|
8
|
+
}
|
|
9
|
+
export type IPermissionEntityFilterData = IEntitySearch<EntityEnum.PERMISSION>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IAuditColumnEntity } from "./audit-column-entity.interface";
|
|
2
|
+
import { EntityEnum, IEntitySearch } from "./entity-utils.interface";
|
|
3
|
+
export interface IRoleEntity extends IAuditColumnEntity {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
organizationId: number;
|
|
8
|
+
}
|
|
9
|
+
export type IRoleEntityFilterData = IEntitySearch<EntityEnum.ROLE>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IAuditColumnEntity } from "./audit-column-entity.interface";
|
|
2
|
+
import { EntityEnum, IEntitySearch } from "./entity-utils.interface";
|
|
3
|
+
export interface IRolePermissionMappingEntity extends IAuditColumnEntity {
|
|
4
|
+
id: number;
|
|
5
|
+
roleId: number;
|
|
6
|
+
permissionId: number;
|
|
7
|
+
}
|
|
8
|
+
export type IRolePermissionMappingEntityFilterData = IEntitySearch<EntityEnum.ROLE_PERMISSION_MAPPING>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { UserRoleEnum } from "../../@enum";
|
|
1
2
|
import { UserStatus } from "../../enum/user/user-status.enum";
|
|
2
|
-
import { UserType } from "../../enum/user/user-type.enum";
|
|
3
3
|
import { IAuditColumnEntity } from "./audit-column-entity.interface";
|
|
4
4
|
export interface IUserEntity extends IAuditColumnEntity {
|
|
5
5
|
id: number;
|
|
@@ -12,9 +12,10 @@ export interface IUserEntity extends IAuditColumnEntity {
|
|
|
12
12
|
isMobileVerified: boolean;
|
|
13
13
|
isAccountVerified: boolean;
|
|
14
14
|
requireNewPassword: boolean;
|
|
15
|
-
|
|
15
|
+
role: UserRoleEnum;
|
|
16
16
|
registrationId: number;
|
|
17
17
|
organizationId: number;
|
|
18
18
|
imageUrl: string | null;
|
|
19
19
|
documentUrls: string | null;
|
|
20
|
+
permissions?: string[];
|
|
20
21
|
}
|
|
@@ -5,52 +5,6 @@ const _enum_1 = require("../@enum");
|
|
|
5
5
|
const _type_1 = require("../@type");
|
|
6
6
|
const _utils_1 = require("../@utils");
|
|
7
7
|
const base_entity_model_1 = require("./base.entity.model");
|
|
8
|
-
// export class EquityAdviceEntityModel implements IAdviceEntity {
|
|
9
|
-
// id: number;
|
|
10
|
-
// type: AdviceType;
|
|
11
|
-
// advisorOrgId: number;
|
|
12
|
-
// stockName: string;
|
|
13
|
-
// cmp: number;
|
|
14
|
-
// targetPrice: number;
|
|
15
|
-
// stopLoss: number;
|
|
16
|
-
// investmentDurationType: InvestDurationType;
|
|
17
|
-
// transactionType: AdviceTransactionType;
|
|
18
|
-
// fromDate: number;
|
|
19
|
-
// toDate: number;
|
|
20
|
-
// noteDocumentUrl: string | null;
|
|
21
|
-
// videoUrl: string | null;
|
|
22
|
-
// voiceUrl: string | null;
|
|
23
|
-
// status: AdviceStatus;
|
|
24
|
-
// rationale: string | null;
|
|
25
|
-
// targetHitOn: Date | null;
|
|
26
|
-
// targetHitCMP: number | null;
|
|
27
|
-
// gainLoss: number | null;
|
|
28
|
-
// createdOn: number;
|
|
29
|
-
// updatedOn: number;
|
|
30
|
-
// createdBy: number;
|
|
31
|
-
// updatedBy: number;
|
|
32
|
-
// constructor(data: IAdviceEntity) {
|
|
33
|
-
// Object.assign(this, data);
|
|
34
|
-
// }
|
|
35
|
-
// getRandomHigh() {
|
|
36
|
-
// let randomHigh = 0;
|
|
37
|
-
// if (this.transactionType !== AdviceTransactionType.SELL) {
|
|
38
|
-
// randomHigh = mathUtils.randomNumber(this.stopLoss, this.targetPrice);
|
|
39
|
-
// } else {
|
|
40
|
-
// randomHigh = mathUtils.randomNumber(this.targetPrice, this.stopLoss);
|
|
41
|
-
// }
|
|
42
|
-
// return randomHigh;
|
|
43
|
-
// }
|
|
44
|
-
// getGainLoss(randomHigh?: number) {
|
|
45
|
-
// return parseFloat(
|
|
46
|
-
// (
|
|
47
|
-
// ((randomHigh ?? this.getRandomHigh() - this.cmp) /
|
|
48
|
-
// (this.targetPrice - this.cmp)) *
|
|
49
|
-
// 100
|
|
50
|
-
// ).toFixed(2)
|
|
51
|
-
// );
|
|
52
|
-
// }
|
|
53
|
-
// }
|
|
54
8
|
class EquityAdviceEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
55
9
|
constructor() {
|
|
56
10
|
super(...arguments);
|
|
@@ -103,3 +57,49 @@ class EquityAdviceEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
103
57
|
}
|
|
104
58
|
}
|
|
105
59
|
exports.EquityAdviceEntityModel = EquityAdviceEntityModel;
|
|
60
|
+
// export class EquityAdviceEntityModel implements IAdviceEntity {
|
|
61
|
+
// id: number;
|
|
62
|
+
// type: AdviceType;
|
|
63
|
+
// advisorOrgId: number;
|
|
64
|
+
// stockName: string;
|
|
65
|
+
// cmp: number;
|
|
66
|
+
// targetPrice: number;
|
|
67
|
+
// stopLoss: number;
|
|
68
|
+
// investmentDurationType: InvestDurationType;
|
|
69
|
+
// transactionType: AdviceTransactionType;
|
|
70
|
+
// fromDate: number;
|
|
71
|
+
// toDate: number;
|
|
72
|
+
// noteDocumentUrl: string | null;
|
|
73
|
+
// videoUrl: string | null;
|
|
74
|
+
// voiceUrl: string | null;
|
|
75
|
+
// status: AdviceStatus;
|
|
76
|
+
// rationale: string | null;
|
|
77
|
+
// targetHitOn: Date | null;
|
|
78
|
+
// targetHitCMP: number | null;
|
|
79
|
+
// gainLoss: number | null;
|
|
80
|
+
// createdOn: number;
|
|
81
|
+
// updatedOn: number;
|
|
82
|
+
// createdBy: number;
|
|
83
|
+
// updatedBy: number;
|
|
84
|
+
// constructor(data: IAdviceEntity) {
|
|
85
|
+
// Object.assign(this, data);
|
|
86
|
+
// }
|
|
87
|
+
// getRandomHigh() {
|
|
88
|
+
// let randomHigh = 0;
|
|
89
|
+
// if (this.transactionType !== AdviceTransactionType.SELL) {
|
|
90
|
+
// randomHigh = mathUtils.randomNumber(this.stopLoss, this.targetPrice);
|
|
91
|
+
// } else {
|
|
92
|
+
// randomHigh = mathUtils.randomNumber(this.targetPrice, this.stopLoss);
|
|
93
|
+
// }
|
|
94
|
+
// return randomHigh;
|
|
95
|
+
// }
|
|
96
|
+
// getGainLoss(randomHigh?: number) {
|
|
97
|
+
// return parseFloat(
|
|
98
|
+
// (
|
|
99
|
+
// ((randomHigh ?? this.getRandomHigh() - this.cmp) /
|
|
100
|
+
// (this.targetPrice - this.cmp)) *
|
|
101
|
+
// 100
|
|
102
|
+
// ).toFixed(2)
|
|
103
|
+
// );
|
|
104
|
+
// }
|
|
105
|
+
// }
|
|
@@ -4,27 +4,30 @@ export * from "./subscribed-pricing-plan-model";
|
|
|
4
4
|
export * from "../exception/app-badrequest.exception";
|
|
5
5
|
export * from "./organization-entity-model";
|
|
6
6
|
export * from "./user-entity-model";
|
|
7
|
-
export * from "./subscription-entity-model";
|
|
8
7
|
export * from "./bank-details-entity-model";
|
|
8
|
+
export * from "./subscription-entity-model";
|
|
9
9
|
export * from "./corporate-actions/bonus-corporate-action-model";
|
|
10
|
-
export * from "./corporate-actions/fpo-corporate-action-model";
|
|
11
10
|
export * from "./corporate-actions/dividend-corporate-action-model";
|
|
12
|
-
export * from "./corporate-actions/
|
|
11
|
+
export * from "./corporate-actions/fpo-corporate-action-model";
|
|
12
|
+
export * from "./corporate-actions/buy-back-corporate-action-model";
|
|
13
13
|
export * from "./corporate-actions/delisting-corporate-action-model";
|
|
14
14
|
export * from "./corporate-actions/open-offer-corporate-action-model";
|
|
15
|
-
export * from "./corporate-actions/
|
|
16
|
-
export * from "./corporate-actions/split-corporate-action-model";
|
|
17
|
-
export * from "./corporate-actions/ipo-corporate-action-model";
|
|
15
|
+
export * from "./corporate-actions/right-issue-corporate-action-model";
|
|
18
16
|
export * from "./corporate-actions/corporate-action-model";
|
|
19
|
-
export * from "./corporate-actions/
|
|
20
|
-
export * from "./corporate-actions/
|
|
17
|
+
export * from "./corporate-actions/ipo-corporate-action-model";
|
|
18
|
+
export * from "./corporate-actions/split-corporate-action-model";
|
|
21
19
|
export * from "./configurations-entity-model";
|
|
20
|
+
export * from "./corporate-actions/ofs-corporate-action-model";
|
|
21
|
+
export * from "./corporate-actions/split-bonus-corporate-action-model";
|
|
22
22
|
export * from "./equity-advice-entity-model";
|
|
23
23
|
export * from "./interface/entity.model.interface";
|
|
24
24
|
export * from "./pricing-plan-model";
|
|
25
25
|
export * from "./registration-entity-model";
|
|
26
|
-
export * from "./mutual-funds-entity.model";
|
|
27
26
|
export * from "./mutual-fund-advice-entity.model";
|
|
28
|
-
export * from "./
|
|
27
|
+
export * from "./mutual-funds-entity.model";
|
|
29
28
|
export * from "./nfo-advice-entity.model";
|
|
29
|
+
export * from "./nfo-entity.model";
|
|
30
30
|
export * from "./configurations-entity-model";
|
|
31
|
+
export * from "./permission-entity-model";
|
|
32
|
+
export * from "./role-entity-model";
|
|
33
|
+
export * from "./role-permission-entity-model";
|
package/build/src/model/index.js
CHANGED
|
@@ -24,27 +24,30 @@ __exportStar(require("../exception/app-badrequest.exception"), exports);
|
|
|
24
24
|
__exportStar(require("./organization-entity-model"), exports);
|
|
25
25
|
// export * from "./model/user-entity-model";
|
|
26
26
|
__exportStar(require("./user-entity-model"), exports);
|
|
27
|
-
__exportStar(require("./subscription-entity-model"), exports);
|
|
28
27
|
__exportStar(require("./bank-details-entity-model"), exports);
|
|
28
|
+
__exportStar(require("./subscription-entity-model"), exports);
|
|
29
29
|
__exportStar(require("./corporate-actions/bonus-corporate-action-model"), exports);
|
|
30
|
-
__exportStar(require("./corporate-actions/fpo-corporate-action-model"), exports);
|
|
31
30
|
__exportStar(require("./corporate-actions/dividend-corporate-action-model"), exports);
|
|
32
|
-
__exportStar(require("./corporate-actions/
|
|
31
|
+
__exportStar(require("./corporate-actions/fpo-corporate-action-model"), exports);
|
|
32
|
+
__exportStar(require("./corporate-actions/buy-back-corporate-action-model"), exports);
|
|
33
33
|
__exportStar(require("./corporate-actions/delisting-corporate-action-model"), exports);
|
|
34
34
|
__exportStar(require("./corporate-actions/open-offer-corporate-action-model"), exports);
|
|
35
|
-
__exportStar(require("./corporate-actions/
|
|
36
|
-
__exportStar(require("./corporate-actions/split-corporate-action-model"), exports);
|
|
37
|
-
__exportStar(require("./corporate-actions/ipo-corporate-action-model"), exports);
|
|
35
|
+
__exportStar(require("./corporate-actions/right-issue-corporate-action-model"), exports);
|
|
38
36
|
__exportStar(require("./corporate-actions/corporate-action-model"), exports);
|
|
39
|
-
__exportStar(require("./corporate-actions/
|
|
40
|
-
__exportStar(require("./corporate-actions/
|
|
37
|
+
__exportStar(require("./corporate-actions/ipo-corporate-action-model"), exports);
|
|
38
|
+
__exportStar(require("./corporate-actions/split-corporate-action-model"), exports);
|
|
41
39
|
__exportStar(require("./configurations-entity-model"), exports);
|
|
40
|
+
__exportStar(require("./corporate-actions/ofs-corporate-action-model"), exports);
|
|
41
|
+
__exportStar(require("./corporate-actions/split-bonus-corporate-action-model"), exports);
|
|
42
42
|
__exportStar(require("./equity-advice-entity-model"), exports);
|
|
43
43
|
__exportStar(require("./interface/entity.model.interface"), exports);
|
|
44
44
|
__exportStar(require("./pricing-plan-model"), exports);
|
|
45
45
|
__exportStar(require("./registration-entity-model"), exports);
|
|
46
|
-
__exportStar(require("./mutual-funds-entity.model"), exports);
|
|
47
46
|
__exportStar(require("./mutual-fund-advice-entity.model"), exports);
|
|
48
|
-
__exportStar(require("./
|
|
47
|
+
__exportStar(require("./mutual-funds-entity.model"), exports);
|
|
49
48
|
__exportStar(require("./nfo-advice-entity.model"), exports);
|
|
49
|
+
__exportStar(require("./nfo-entity.model"), exports);
|
|
50
50
|
__exportStar(require("./configurations-entity-model"), exports);
|
|
51
|
+
__exportStar(require("./permission-entity-model"), exports);
|
|
52
|
+
__exportStar(require("./role-entity-model"), exports);
|
|
53
|
+
__exportStar(require("./role-permission-entity-model"), exports);
|
|
@@ -15,8 +15,11 @@ const mutual_funds_entity_model_1 = require("../mutual-funds-entity.model");
|
|
|
15
15
|
const nfo_advice_entity_model_1 = require("../nfo-advice-entity.model");
|
|
16
16
|
const nfo_entity_model_1 = require("../nfo-entity.model");
|
|
17
17
|
const organization_entity_model_1 = require("../organization-entity-model");
|
|
18
|
+
const permission_entity_model_1 = require("../permission-entity-model");
|
|
18
19
|
const pricing_plan_entity_model_1 = require("../pricing-plan-entity-model");
|
|
19
20
|
const registration_entity_model_1 = require("../registration-entity-model");
|
|
21
|
+
const role_entity_model_1 = require("../role-entity-model");
|
|
22
|
+
const role_permission_entity_model_1 = require("../role-permission-entity-model");
|
|
20
23
|
const subscription_entity_model_1 = require("../subscription-entity-model");
|
|
21
24
|
const user_entity_model_1 = require("../user-entity-model");
|
|
22
25
|
function mapToIndex(entityMap) {
|
|
@@ -70,6 +73,9 @@ function parseEntities(json, baseEntity, entityModelMap) {
|
|
|
70
73
|
[_type_1.EntityEnum.CORPORATE_ACTIONS_ADVICE]: corporate_actions_advice_model_1.CorporateActionsAdviceEntityModel.fromEntity,
|
|
71
74
|
[_type_1.EntityEnum.CONFIGURATION]: configurations_entity_model_1.ConfigurationsEntityModel.fromEntity,
|
|
72
75
|
[_type_1.EntityEnum.CRON_JOBS]: cron_jobs_entity_model_1.CronJobsEntityModel.fromEntity,
|
|
76
|
+
[_type_1.EntityEnum.ROLE]: role_entity_model_1.RoleEntityModel.fromEntity,
|
|
77
|
+
[_type_1.EntityEnum.PERMISSION]: permission_entity_model_1.PermissionEntityModel.fromEntity,
|
|
78
|
+
[_type_1.EntityEnum.ROLE_PERMISSION_MAPPING]: role_permission_entity_model_1.RolePermissionMappingEntityModel.fromEntity,
|
|
73
79
|
};
|
|
74
80
|
if (!(baseEntity in entityFromJsonMappings)) {
|
|
75
81
|
throw new Error(`Unknown entity: ${baseEntity}`);
|
|
@@ -105,6 +111,9 @@ exports.entityEnumToEntityModel = {
|
|
|
105
111
|
[_type_1.EntityEnum.CORPORATE_ACTIONS_ADVICE]: corporate_actions_advice_model_1.CorporateActionsAdviceEntityModel.fromEntity,
|
|
106
112
|
[_type_1.EntityEnum.CONFIGURATION]: configurations_entity_model_1.ConfigurationsEntityModel.fromEntity,
|
|
107
113
|
[_type_1.EntityEnum.CRON_JOBS]: cron_jobs_entity_model_1.CronJobsEntityModel.fromEntity,
|
|
114
|
+
[_type_1.EntityEnum.ROLE]: role_entity_model_1.RoleEntityModel.fromEntity,
|
|
115
|
+
[_type_1.EntityEnum.PERMISSION]: permission_entity_model_1.PermissionEntityModel.fromEntity,
|
|
116
|
+
[_type_1.EntityEnum.ROLE_PERMISSION_MAPPING]: role_permission_entity_model_1.RolePermissionMappingEntityModel.fromEntity,
|
|
108
117
|
};
|
|
109
118
|
function parseEntitiesWithoutModels(json, baseEntity, entityMap = {}) {
|
|
110
119
|
var _a;
|
|
@@ -146,7 +146,7 @@ class OrganizationEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
146
146
|
// }
|
|
147
147
|
validateOwnersCountByOrganizationType() {
|
|
148
148
|
var _a;
|
|
149
|
-
const noOfOwners = (_a = this.users) === null || _a === void 0 ? void 0 : _a.filter((user) => user.
|
|
149
|
+
const noOfOwners = (_a = this.users) === null || _a === void 0 ? void 0 : _a.filter((user) => user.role === _enum_1.UserRoleEnum.ADVISOR).length;
|
|
150
150
|
if (this.type === _enum_1.OrganizationType.PARTNERSHIP && noOfOwners <= 1) {
|
|
151
151
|
throw new _model_1.AppBadRequestException({
|
|
152
152
|
key: "organizationType",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EntityEnum, IPermissionEntity } from "../@type";
|
|
2
|
+
import { BaseEntityModel } from "./base.entity.model";
|
|
3
|
+
export declare class PermissionEntityModel extends BaseEntityModel<EntityEnum.PERMISSION> implements IPermissionEntity {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
organizationId: number;
|
|
8
|
+
createdOn: number;
|
|
9
|
+
updatedOn: number;
|
|
10
|
+
createdBy: number;
|
|
11
|
+
updatedBy: number;
|
|
12
|
+
constructor();
|
|
13
|
+
static fromEntity(entity: IPermissionEntity): PermissionEntityModel;
|
|
14
|
+
/**
|
|
15
|
+
* Return relation configs (if any)
|
|
16
|
+
*/
|
|
17
|
+
getRelationConfigs(): any;
|
|
18
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PermissionEntityModel = void 0;
|
|
4
|
+
const _type_1 = require("../@type");
|
|
5
|
+
const base_entity_model_1 = require("./base.entity.model");
|
|
6
|
+
class PermissionEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(_type_1.EntityEnum.PERMISSION);
|
|
9
|
+
this.id = 0;
|
|
10
|
+
this.name = "";
|
|
11
|
+
this.description = "";
|
|
12
|
+
this.organizationId = 0;
|
|
13
|
+
this.createdOn = 0;
|
|
14
|
+
this.updatedOn = 0;
|
|
15
|
+
this.createdBy = 0;
|
|
16
|
+
this.updatedBy = 0;
|
|
17
|
+
}
|
|
18
|
+
static fromEntity(entity) {
|
|
19
|
+
const result = new PermissionEntityModel();
|
|
20
|
+
Object.assign(result, entity);
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Return relation configs (if any)
|
|
25
|
+
*/
|
|
26
|
+
getRelationConfigs() {
|
|
27
|
+
return this.constructor.prototype.constructor.relationConfigs;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.PermissionEntityModel = PermissionEntityModel;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EntityEnum } from "../@type";
|
|
2
|
+
import { IRoleEntity } from "../interface/entity/role.entity.interface";
|
|
3
|
+
import { BaseEntityModel } from "./base.entity.model";
|
|
4
|
+
export declare class RoleEntityModel extends BaseEntityModel<EntityEnum.ROLE> implements IRoleEntity {
|
|
5
|
+
id: number;
|
|
6
|
+
name: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
organizationId: number;
|
|
9
|
+
createdOn: number;
|
|
10
|
+
updatedOn: number;
|
|
11
|
+
createdBy: number;
|
|
12
|
+
updatedBy: number;
|
|
13
|
+
getRelationConfigs(): any;
|
|
14
|
+
static fromEntity(entity: IRoleEntity): RoleEntityModel;
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RoleEntityModel = void 0;
|
|
4
|
+
const _type_1 = require("../@type");
|
|
5
|
+
const base_entity_model_1 = require("./base.entity.model");
|
|
6
|
+
class RoleEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.id = 0;
|
|
10
|
+
this.name = "";
|
|
11
|
+
this.description = "";
|
|
12
|
+
this.organizationId = 0;
|
|
13
|
+
this.createdOn = 0;
|
|
14
|
+
this.updatedOn = 0;
|
|
15
|
+
this.createdBy = 0;
|
|
16
|
+
this.updatedBy = 0;
|
|
17
|
+
}
|
|
18
|
+
getRelationConfigs() {
|
|
19
|
+
return this.constructor.prototype.constructor.relationConfigs;
|
|
20
|
+
}
|
|
21
|
+
static fromEntity(entity) {
|
|
22
|
+
const result = new RoleEntityModel(_type_1.EntityEnum.ROLE);
|
|
23
|
+
Object.assign(result, entity);
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.RoleEntityModel = RoleEntityModel;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EntityEnum } from "../@type";
|
|
2
|
+
import { IRolePermissionMappingEntity } from "../interface/entity/role.permission.mapping.entity.interface";
|
|
3
|
+
import { BaseEntityModel } from "./base.entity.model";
|
|
4
|
+
export declare class RolePermissionMappingEntityModel extends BaseEntityModel<EntityEnum.ROLE_PERMISSION_MAPPING> implements IRolePermissionMappingEntity {
|
|
5
|
+
id: number;
|
|
6
|
+
roleId: number;
|
|
7
|
+
permissionId: number;
|
|
8
|
+
createdOn: number;
|
|
9
|
+
updatedOn: number;
|
|
10
|
+
createdBy: number;
|
|
11
|
+
updatedBy: number;
|
|
12
|
+
constructor();
|
|
13
|
+
static fromEntity(entity: IRolePermissionMappingEntity): RolePermissionMappingEntityModel;
|
|
14
|
+
getRelationConfigs(): any;
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RolePermissionMappingEntityModel = void 0;
|
|
4
|
+
const _type_1 = require("../@type");
|
|
5
|
+
const base_entity_model_1 = require("./base.entity.model");
|
|
6
|
+
class RolePermissionMappingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(_type_1.EntityEnum.ROLE_PERMISSION_MAPPING);
|
|
9
|
+
this.id = 0;
|
|
10
|
+
this.roleId = 0;
|
|
11
|
+
this.permissionId = 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 RolePermissionMappingEntityModel();
|
|
19
|
+
Object.assign(result, entity);
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
getRelationConfigs() {
|
|
23
|
+
return this.constructor.prototype.constructor.relationConfigs;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.RolePermissionMappingEntityModel = RolePermissionMappingEntityModel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UserRoleEnum, 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,11 +12,12 @@ export declare class UserEntityModel extends BaseEntityModel<EntityEnum.USER> im
|
|
|
12
12
|
isMobileVerified: boolean;
|
|
13
13
|
isAccountVerified: boolean;
|
|
14
14
|
requireNewPassword: boolean;
|
|
15
|
-
|
|
15
|
+
role: UserRoleEnum;
|
|
16
16
|
registrationId: number;
|
|
17
17
|
organizationId: number;
|
|
18
18
|
imageUrl: string | null;
|
|
19
19
|
documentUrls: string | null;
|
|
20
|
+
permissions?: string[];
|
|
20
21
|
createdOn: number;
|
|
21
22
|
updatedOn: number;
|
|
22
23
|
createdBy: number;
|
|
@@ -27,5 +28,5 @@ export declare class UserEntityModel extends BaseEntityModel<EntityEnum.USER> im
|
|
|
27
28
|
static filterByOrganizationId(userEntities: IUserEntity[], organizationId: number): IUserEntity[];
|
|
28
29
|
static getUserEntityInstanceFromRegistrationEntityOrganizationEntity(registrationEntity: IRegistrationEntity, organizationEntity: IOrganizationEntity, hashedPassword: string): IUserEntity;
|
|
29
30
|
getRelationConfigs(): any;
|
|
30
|
-
|
|
31
|
+
validateUserRoleSuperAdmin(): void;
|
|
31
32
|
}
|
|
@@ -18,7 +18,7 @@ class UserEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
18
18
|
this.isMobileVerified = false;
|
|
19
19
|
this.isAccountVerified = false;
|
|
20
20
|
this.requireNewPassword = false;
|
|
21
|
-
this.
|
|
21
|
+
this.role = _enum_1.UserRoleEnum.ADVISOR;
|
|
22
22
|
this.registrationId = 0;
|
|
23
23
|
this.organizationId = 0;
|
|
24
24
|
this.imageUrl = null;
|
|
@@ -44,7 +44,7 @@ class UserEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
44
44
|
userEntity.isEmailVerified = false;
|
|
45
45
|
userEntity.isMobileVerified = false;
|
|
46
46
|
userEntity.status = _enum_1.UserStatus.REGISTRATION_APPROVED;
|
|
47
|
-
userEntity.
|
|
47
|
+
userEntity.role = _enum_1.UserRoleEnum.ADVISOR;
|
|
48
48
|
userEntity.createdBy = registrationEntity.createdBy;
|
|
49
49
|
userEntity.updatedBy = registrationEntity.createdBy;
|
|
50
50
|
userEntity.updatedOn = Date.now();
|
|
@@ -62,8 +62,8 @@ class UserEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
62
62
|
getRelationConfigs() {
|
|
63
63
|
return this.constructor.prototype.constructor.relationConfigs;
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
if (this.
|
|
65
|
+
validateUserRoleSuperAdmin() {
|
|
66
|
+
if (this.role !== _enum_1.UserRoleEnum.SUPERADMIN) {
|
|
67
67
|
throw new _model_1.AppBadRequestException({
|
|
68
68
|
key: "status",
|
|
69
69
|
message: [
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
+
// create a safe global reference
|
|
3
|
+
var __js_cols_global = typeof globalThis !== "undefined"
|
|
4
|
+
? globalThis
|
|
5
|
+
: typeof window !== "undefined"
|
|
6
|
+
? window
|
|
7
|
+
: typeof global !== "undefined"
|
|
8
|
+
? global
|
|
9
|
+
: this;
|
|
10
|
+
// reuse an existing global js_cols if present, otherwise create it
|
|
11
|
+
var js_cols = __js_cols_global.js_cols || {};
|
|
12
|
+
// Optionally set back the global for scripts that expect it
|
|
13
|
+
__js_cols_global.js_cols = js_cols;
|
|
2
14
|
//Copyright 2010 Thomas Stjernegaard Jeppesen. All Rights Reserved.
|
|
3
15
|
//Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
16
|
//you may not use this file except in compliance with the License.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Modify } from "../@type";
|
|
1
|
+
import { EntityEnum, IEntitySearch, Modify } from "../@type";
|
|
2
2
|
/**
|
|
3
3
|
* Returns epoch time (ms) for today's date at the given local time (IST).
|
|
4
4
|
*/
|
|
@@ -82,3 +82,7 @@ export declare function toDateFromEpoch(epoch: number): Date;
|
|
|
82
82
|
* `{...old, ...new}` which only performs shallow merge.
|
|
83
83
|
*/
|
|
84
84
|
export declare function deepMerge(existing: any, incoming: any): any;
|
|
85
|
+
export declare function groupByOneToOneFunction<T, K>(list: T[], keyGetter: (input: T) => K): Map<K, T>;
|
|
86
|
+
export declare function getPropertyFilterByPermissionFn<T extends EntityEnum>(permissionFilterConfig: {
|
|
87
|
+
[key: string]: () => Promise<IEntitySearch<T>>;
|
|
88
|
+
}, propertyNames: string[], userPermission: string, filterDto: IEntitySearch<T>, emptyValue?: any): Promise<IEntitySearch<T>>;
|
|
@@ -1,6 +1,16 @@
|
|
|
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
|
-
exports.deepMerge = exports.toDateFromEpoch = exports.groupByFunction = exports.transformDate = exports.getStringValues = exports.getTodayISTEpoch = void 0;
|
|
12
|
+
exports.getPropertyFilterByPermissionFn = exports.groupByOneToOneFunction = exports.deepMerge = exports.toDateFromEpoch = exports.groupByFunction = exports.transformDate = exports.getStringValues = exports.getTodayISTEpoch = void 0;
|
|
13
|
+
const _type_1 = require("../@type");
|
|
4
14
|
/**
|
|
5
15
|
* Returns epoch time (ms) for today's date at the given local time (IST).
|
|
6
16
|
*/
|
|
@@ -124,3 +134,144 @@ function deepMerge(existing, incoming) {
|
|
|
124
134
|
return existing;
|
|
125
135
|
}
|
|
126
136
|
exports.deepMerge = deepMerge;
|
|
137
|
+
function groupByOneToOneFunction(list, keyGetter) {
|
|
138
|
+
const map = new Map();
|
|
139
|
+
list.forEach((item) => {
|
|
140
|
+
const key = keyGetter(item);
|
|
141
|
+
map.set(key, item);
|
|
142
|
+
});
|
|
143
|
+
return map;
|
|
144
|
+
}
|
|
145
|
+
exports.groupByOneToOneFunction = groupByOneToOneFunction;
|
|
146
|
+
function getPropertyFilterByPermissionFn(permissionFilterConfig, propertyNames, userPermission, filterDto, emptyValue = []) {
|
|
147
|
+
var _a, _b;
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
const permissionFilterData = yield permissionFilterConfig[userPermission]();
|
|
150
|
+
const result = {
|
|
151
|
+
name: filterDto.name,
|
|
152
|
+
include: {},
|
|
153
|
+
};
|
|
154
|
+
for (const propertyName of propertyNames) {
|
|
155
|
+
const dtoInclude = (_a = filterDto.include) !== null && _a !== void 0 ? _a : {};
|
|
156
|
+
const dtoFilter = dtoInclude[propertyName];
|
|
157
|
+
const permissionInclude = (_b = permissionFilterData.include) !== null && _b !== void 0 ? _b : {};
|
|
158
|
+
const permissionFilter = permissionInclude[propertyName];
|
|
159
|
+
const isDtoPresent = Array.isArray(dtoFilter) && dtoFilter.length > 0;
|
|
160
|
+
const isPermissionPresent = Array.isArray(permissionFilter) && permissionFilter.length > 0;
|
|
161
|
+
// --------- CASE 1: Permission says allow all ([]) ----------
|
|
162
|
+
if (Array.isArray(permissionFilter) && permissionFilter.length === 0) {
|
|
163
|
+
result.include[propertyName] = dtoFilter !== null && dtoFilter !== void 0 ? dtoFilter : []; // allow everything
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
// --------- CASE 2: Permission has restriction ----------
|
|
167
|
+
if (isPermissionPresent) {
|
|
168
|
+
if (isDtoPresent) {
|
|
169
|
+
const intersection = (0, _type_1.arrayIntersection)(permissionFilter, dtoFilter);
|
|
170
|
+
result.include[propertyName] =
|
|
171
|
+
intersection.length > 0 ? intersection : emptyValue;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
// no dto filter → use full permission filter
|
|
175
|
+
result.include[propertyName] = permissionFilter;
|
|
176
|
+
}
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
// --------- CASE 3: No permission restriction → use dto filter ----------
|
|
180
|
+
result.include[propertyName] = dtoFilter;
|
|
181
|
+
}
|
|
182
|
+
return result;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
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
|
+
// }
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserType = void 0;
|
|
4
|
-
var UserType;
|
|
5
|
-
(function (UserType) {
|
|
6
|
-
UserType["USER"] = "user";
|
|
7
|
-
UserType["ADVISOR"] = "advisor";
|
|
8
|
-
UserType["SUPERADMIN"] = "superadmin";
|
|
9
|
-
UserType["BOT_USER"] = "bot_user";
|
|
10
|
-
UserType["PUBLIC_USER"] = "public_user";
|
|
11
|
-
UserType["ADVISOR_CLIENT"] = "advisor_client";
|
|
12
|
-
UserType["STAFF"] = "staff";
|
|
13
|
-
})(UserType || (exports.UserType = UserType = {}));
|