@frontegg/rest-api 3.1.74 → 3.1.76-alpha.9502349697

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 (123) hide show
  1. package/BaseApiClient.d.ts +16 -0
  2. package/BaseApiClient.js +39 -0
  3. package/ContextHolder/index.d.ts +108 -27
  4. package/ContextHolder/index.js +155 -50
  5. package/FetchClient.d.ts +42 -0
  6. package/FetchClient.js +308 -0
  7. package/account-settings/index.d.ts +19 -7
  8. package/account-settings/index.js +23 -13
  9. package/applications/index.d.ts +49 -44
  10. package/applications/index.js +51 -37
  11. package/audits/index.d.ts +27 -15
  12. package/audits/index.js +27 -17
  13. package/auth/index.d.ts +817 -768
  14. package/auth/index.js +902 -721
  15. package/auth/secutiry-poilicy/index.d.ts +58 -102
  16. package/auth/secutiry-poilicy/index.js +122 -90
  17. package/auth/utils.d.ts +2 -2
  18. package/auth/utils.js +9 -8
  19. package/connectivity/index.d.ts +126 -27
  20. package/connectivity/index.js +147 -114
  21. package/directory/index.d.ts +31 -22
  22. package/directory/index.js +27 -15
  23. package/entitlements/index.d.ts +14 -8
  24. package/entitlements/index.js +12 -4
  25. package/feature-flags/index.d.ts +8 -2
  26. package/feature-flags/index.js +16 -8
  27. package/groups/index.d.ts +73 -49
  28. package/groups/index.js +64 -45
  29. package/impersonate/index.d.ts +15 -6
  30. package/impersonate/index.js +13 -5
  31. package/index.d.ts +154 -108
  32. package/index.js +109 -78
  33. package/interfaces.d.ts +10 -0
  34. package/metadata/index.d.ts +67 -7
  35. package/metadata/index.js +52 -32
  36. package/node/BaseApiClient.js +49 -0
  37. package/node/ContextHolder/index.js +155 -50
  38. package/node/FetchClient.js +326 -0
  39. package/node/account-settings/index.js +27 -16
  40. package/node/applications/index.js +51 -44
  41. package/node/audits/index.js +31 -20
  42. package/node/auth/index.js +768 -1035
  43. package/node/auth/secutiry-poilicy/index.js +125 -136
  44. package/node/auth/utils.js +9 -7
  45. package/node/connectivity/index.js +148 -187
  46. package/node/directory/index.js +29 -20
  47. package/node/entitlements/index.js +18 -5
  48. package/node/feature-flags/index.js +21 -9
  49. package/node/groups/index.js +65 -63
  50. package/node/impersonate/index.js +18 -5
  51. package/node/index.js +116 -71
  52. package/node/metadata/index.js +61 -52
  53. package/node/notifications/index.js +37 -27
  54. package/node/reports/index.js +78 -70
  55. package/node/roles/index.js +56 -51
  56. package/node/security-center/index.js +21 -9
  57. package/node/sub-tenants/index.js +90 -89
  58. package/node/subscriptions/index.js +69 -107
  59. package/node/subscriptions/invoices.js +25 -17
  60. package/node/subscriptions/managedSubscriptions.js +32 -27
  61. package/node/subscriptions/paymentMethods.js +27 -20
  62. package/node/subscriptions/paymentProviders.js +15 -6
  63. package/node/subscriptions/plans.js +17 -9
  64. package/node/subscriptions/providers/stripe/index.js +26 -21
  65. package/node/subscriptions/subscriptions.js +32 -27
  66. package/node/subscriptions/summaries.js +15 -6
  67. package/node/subscriptions/tenantConfiguration.js +17 -9
  68. package/node/subscriptions/vendorPublicConfigurations.js +15 -6
  69. package/node/teams/index.js +130 -138
  70. package/node/tenants/index.js +65 -60
  71. package/node/user-phone-numbers/index.js +32 -24
  72. package/node/users/index.js +58 -53
  73. package/node/vendor/index.js +17 -6
  74. package/notifications/index.d.ts +22 -16
  75. package/notifications/index.js +33 -22
  76. package/package.json +1 -1
  77. package/reports/index.d.ts +50 -44
  78. package/reports/index.js +75 -62
  79. package/roles/index.d.ts +44 -38
  80. package/roles/index.js +57 -41
  81. package/security-center/index.d.ts +14 -2
  82. package/security-center/index.js +15 -6
  83. package/sub-tenants/index.d.ts +57 -15
  84. package/sub-tenants/index.js +88 -68
  85. package/subscriptions/index.d.ts +56 -11
  86. package/subscriptions/index.js +58 -11
  87. package/subscriptions/invoices.d.ts +16 -13
  88. package/subscriptions/invoices.js +24 -14
  89. package/subscriptions/managedSubscriptions.d.ts +18 -15
  90. package/subscriptions/managedSubscriptions.js +33 -22
  91. package/subscriptions/paymentMethods.d.ts +16 -13
  92. package/subscriptions/paymentMethods.js +26 -17
  93. package/subscriptions/paymentProviders.d.ts +8 -5
  94. package/subscriptions/paymentProviders.js +11 -4
  95. package/subscriptions/plans.d.ts +11 -8
  96. package/subscriptions/plans.js +14 -6
  97. package/subscriptions/providers/stripe/index.d.ts +24 -21
  98. package/subscriptions/providers/stripe/index.js +27 -16
  99. package/subscriptions/subscriptions.d.ts +24 -21
  100. package/subscriptions/subscriptions.js +33 -22
  101. package/subscriptions/summaries.d.ts +7 -4
  102. package/subscriptions/summaries.js +10 -3
  103. package/subscriptions/tenantConfiguration.d.ts +6 -3
  104. package/subscriptions/tenantConfiguration.js +15 -7
  105. package/subscriptions/vendorPublicConfigurations.d.ts +5 -2
  106. package/subscriptions/vendorPublicConfigurations.js +11 -4
  107. package/teams/index.d.ts +35 -131
  108. package/teams/index.js +122 -93
  109. package/tenants/index.d.ts +25 -37
  110. package/tenants/index.js +62 -46
  111. package/tenants/interfaces.d.ts +2 -0
  112. package/user-phone-numbers/index.d.ts +32 -26
  113. package/user-phone-numbers/index.js +32 -19
  114. package/users/index.d.ts +21 -15
  115. package/users/index.js +60 -44
  116. package/vendor/index.d.ts +12 -6
  117. package/vendor/index.js +11 -4
  118. package/fetch.d.ts +0 -24
  119. package/fetch.js +0 -265
  120. package/node/fetch.js +0 -306
  121. package/node/subscriptions/providers/index.js +0 -18
  122. package/subscriptions/providers/index.d.ts +0 -1
  123. package/subscriptions/providers/index.js +0 -1
package/teams/index.d.ts CHANGED
@@ -1,133 +1,37 @@
1
1
  import { IAddUser, IChangePassword, ILoadUsers, IResendActivationLink, ITeamUserRole, ITeamStats, ITeamUser, IUpdateProfile, IUpdateUser, IDeleteUser, ITeamUserPermission, IResendInvitationLink, IInviteUserLinkResponse, ICreateOrUpdateInviteUserLink, IInviteLinkConfiguration, IUpdateUserExpiration, ITemporaryUserConfiguration } from './interfaces';
2
2
  import { PaginationResult } from '../interfaces';
3
- import { IUserProfile } from "../users/interfaces";
4
- /****************************************s*
5
- * Profile Api
6
- *****************************************/
7
- /**
8
- * change user password by providing current password and the new password.
9
- *
10
- * @throws exception if the current password incorrect or new password validation failed.
11
- * ``authorized user``
12
- */
13
- export declare function getProfile(params?: object): Promise<IUserProfile>;
14
- /**
15
- * update user profile by providing updated fields.
16
- * ``authorized user``
17
- * @deprecated
18
- * use updateUserProfileV2 from users
19
- */
20
- export declare function updateProfile(body: Partial<IUpdateProfile>): Promise<IUserProfile>;
21
- /**
22
- * update user profile image
23
- * ``authorized user``
24
- */
25
- export declare function updateProfileImage(body: FormData): Promise<string>;
26
- /**
27
- * change user password by providing current password and the new password.
28
- *
29
- * @throws exception if the current password incorrect or new password validation failed.
30
- * ``authorized user``
31
- */
32
- export declare function changePassword(body: IChangePassword): Promise<void>;
33
- /*****************************************
34
- * Team Api
35
- *****************************************/
36
- /**
37
- * load users from team-management-service
38
- *
39
- * ``authorized user``
40
- */
41
- export declare function loadUsers(params: ILoadUsers): Promise<PaginationResult<ITeamUser>>;
42
- /**
43
- * add user to team, invitation link will be sent to the added user.
44
- *
45
- * ``authorized user``
46
- */
47
- export declare function addUser(body: IAddUser): Promise<ITeamUser>;
48
- /**
49
- * delete user from team, user will be deleted.
50
- *
51
- * ``authorized user``
52
- */
53
- export declare function deleteUser(body: IDeleteUser): Promise<ITeamUser>;
54
- /**
55
- * edit user roles in team
56
- *
57
- * ``authorized user``
58
- */
59
- export declare function updateUser(body: IUpdateUser): Promise<ITeamUser>;
60
- /**
61
- * update user expiration time
62
- *
63
- * ``authorized user``
64
- */
65
- export declare function updateUserExpirationTime(body: IUpdateUserExpiration): Promise<void>;
66
- /**
67
- * set user as permanent
68
- */
69
- export declare function setPermanentUser(userId: string): Promise<void>;
70
- /**
71
- * get temporary user configuration
72
- */
73
- export declare function getTemporaryUserConfiguration(): Promise<ITemporaryUserConfiguration>;
74
- /**
75
- * create link to invite user
76
- *
77
- * ``authorized user``
78
- */
79
- export declare function createInviteUserLink(body: ICreateOrUpdateInviteUserLink): Promise<IInviteUserLinkResponse>;
80
- /**
81
- * update link to invite user
82
- *
83
- * ``authorized user``
84
- */
85
- export declare function updateInviteUserLink(body: ICreateOrUpdateInviteUserLink): Promise<IInviteUserLinkResponse>;
86
- /**
87
- * delete link to invite user
88
- *
89
- * ``authorized user``
90
- */
91
- export declare function deleteInviteUserLink(): Promise<void>;
92
- /**
93
- * get link to invite user
94
- *
95
- * ``authorized user``
96
- */
97
- export declare function getInviteUserLink(): Promise<IInviteUserLinkResponse>;
98
- /**
99
- * get invite link configuration
100
- *
101
- */
102
- export declare function getInviteLinkConfiguration(): Promise<IInviteLinkConfiguration>;
103
- /**
104
- * load available roles that can be assigned to team users from team-management-service
105
- *
106
- * ``authorized user``
107
- */
108
- export declare function loadAvailableRoles(): Promise<ITeamUserRole[]>;
109
- export declare function loadAvailablePermissions(): Promise<ITeamUserPermission[]>;
110
- /**
111
- * load users stats from team-management-service
112
- *
113
- * ``authorized user``
114
- */
115
- export declare function loadStats(): Promise<ITeamStats>;
116
- /**
117
- * resend activation link to specific user
118
- *
119
- * ``authorized user``
120
- */
121
- export declare function resendActivationLink(body: IResendActivationLink): Promise<void>;
122
- /**
123
- * resend accept join tenant invitation link to specific user
124
- *
125
- * ``authorized user``
126
- */
127
- export declare function resendInvitationLink(body: IResendInvitationLink): Promise<void>;
128
- /**
129
- * resend accept join all pending tenant for current hierarchy invitation link to specific user
130
- *
131
- * ``authorized user``
132
- */
133
- export declare function resendInvitationLinkToAllTenants(body: IResendInvitationLink): Promise<void>;
3
+ import { IUserProfile } from '../users/interfaces';
4
+ import { BaseApiClient } from '../BaseApiClient';
5
+ export declare class TeamsApi extends BaseApiClient {
6
+ constructor(appName: string);
7
+ getProfile: (params?: object | undefined) => Promise<IUserProfile>;
8
+ updateProfile: (body: Partial<IUpdateProfile>) => Promise<IUserProfile>;
9
+ updateProfileImage: (body: FormData) => Promise<string>;
10
+ /**
11
+ * change user password by providing current password and the new password.
12
+ *
13
+ * @throws exception if the current password incorrect or new password validation failed.
14
+ * ``authorized user``
15
+ */
16
+ changePassword: (body: IChangePassword) => Promise<void>;
17
+ loadUsers: (params: ILoadUsers) => Promise<PaginationResult<ITeamUser>>;
18
+ addUser: (body: IAddUser) => Promise<ITeamUser>;
19
+ deleteUser: (body: IDeleteUser) => Promise<ITeamUser>;
20
+ updateUser: (body: IUpdateUser) => Promise<ITeamUser>;
21
+ updateUserExpirationTime: (body: IUpdateUserExpiration) => Promise<void>;
22
+ setPermanentUser: (userId: string) => Promise<void>;
23
+ getTemporaryUserConfiguration: () => Promise<ITemporaryUserConfiguration>;
24
+ createInviteUserLink: (body: ICreateOrUpdateInviteUserLink) => Promise<IInviteUserLinkResponse>;
25
+ updateInviteUserLink: (body: ICreateOrUpdateInviteUserLink) => Promise<IInviteUserLinkResponse>;
26
+ deleteInviteUserLink: () => Promise<void>;
27
+ getInviteUserLink: () => Promise<IInviteUserLinkResponse>;
28
+ getInviteLinkConfiguration: () => Promise<IInviteLinkConfiguration>;
29
+ loadAvailableRoles: () => Promise<ITeamUserRole[]>;
30
+ loadAvailablePermissions: () => Promise<ITeamUserPermission[]>;
31
+ loadStats: () => Promise<ITeamStats>;
32
+ resendActivationLink: (body: IResendActivationLink) => Promise<void>;
33
+ resendInvitationLink: (body: IResendInvitationLink) => Promise<void>;
34
+ resendInvitationLinkToAllTenants: (body: IResendInvitationLink) => Promise<void>;
35
+ }
36
+ declare const _default: TeamsApi;
37
+ export default _default;
package/teams/index.js CHANGED
@@ -1,96 +1,125 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { Get, Post, Put, Delete, Patch } from '../fetch';
3
2
  import { urls } from '../constants';
4
- export async function getProfile(params) {
5
- return Get(`${urls.identity.users.v2}/me`, params != null ? params : {
6
- addRoles: true
7
- });
8
- }
9
- export async function updateProfile(body) {
10
- return Put(`${urls.identity.users.v2}/me`, body);
11
- }
12
- export async function updateProfileImage(body) {
13
- return Put(`${urls.team.profile.v1}/me/image/v1`, body, {
14
- responseType: 'plain',
15
- contentType: undefined
16
- });
17
- }
18
- export async function changePassword(body) {
19
- return Post(`${urls.identity.users.v1}/passwords/change`, body);
20
- }
21
- export async function loadUsers(params) {
22
- var _params$sort, _params$sort$0$id, _params$sort2, _params$sort2$, _params$sort3, _params$sort3$;
23
-
24
- const filters = (params.filter || []).reduce((p, n) => _extends({}, p, {
25
- [n.id]: n.value
26
- }), {});
27
- const sorts = (_params$sort = params.sort) != null && _params$sort.length ? {
28
- sortBy: (_params$sort$0$id = (_params$sort2 = params.sort) == null ? void 0 : (_params$sort2$ = _params$sort2[0]) == null ? void 0 : _params$sort2$.id) != null ? _params$sort$0$id : 'name',
29
- sortDirection: (_params$sort3 = params.sort) != null && (_params$sort3$ = _params$sort3[0]) != null && _params$sort3$.desc ? 'desc' : 'asc'
30
- } : null;
31
- return Get(urls.team.members.v1, _extends({
32
- pageOffset: params.pageOffset,
33
- pageSize: params.pageSize
34
- }, filters, sorts));
35
- }
36
- export async function addUser(body) {
37
- return Post(urls.identity.users.v2, _extends({}, body, {
38
- provider: 'local'
39
- }));
40
- }
41
- export async function deleteUser(body) {
42
- return Delete(`${urls.team.members.v1}/${body.userId}`);
43
- }
44
- export async function updateUser(body) {
45
- return Put(urls.team.members.v1, body);
46
- }
47
- export async function updateUserExpirationTime(body) {
48
- const {
49
- userId,
50
- expirationInSeconds
51
- } = body;
52
- return Put(`${urls.identity.users.temporary.v1}/${userId}`, {
53
- expirationInSeconds
54
- });
55
- }
56
- export async function setPermanentUser(userId) {
57
- return Delete(`${urls.identity.users.temporary.v1}/${userId}`);
58
- }
59
- export async function getTemporaryUserConfiguration() {
60
- return Get(urls.identity.users.temporary.configuration.v1);
61
- }
62
- export async function createInviteUserLink(body) {
63
- return Post(urls.identity.tenants.invites.user.v1, _extends({}, body));
64
- }
65
- export async function updateInviteUserLink(body) {
66
- return Patch(urls.identity.tenants.invites.user.v1, _extends({}, body));
67
- }
68
- export async function deleteInviteUserLink() {
69
- return Delete(urls.identity.tenants.invites.user.v1);
70
- }
71
- export async function getInviteUserLink() {
72
- return Get(urls.identity.tenants.invites.user.v1);
73
- }
74
- export async function getInviteLinkConfiguration() {
75
- return Get(urls.identity.tenants.invites.configuration.v1);
76
- }
77
- export async function loadAvailableRoles() {
78
- return Get(urls.team.roles.v1);
79
- }
80
- export async function loadAvailablePermissions() {
81
- return Get(urls.identity.permissions.v1);
82
- }
83
- export async function loadStats() {
84
- return Get(`${urls.team.stats.v1}/members`);
85
- }
86
- export async function resendActivationLink(body) {
87
- return Post(`${urls.team.members.v1}/${body.userId}/resendActivationEmail`, {});
88
- }
89
- export async function resendInvitationLink(body) {
90
- return Post(urls.identity.users.v2, _extends({}, body, {
91
- provider: 'local'
92
- }));
3
+ import { BaseApiClient } from '../BaseApiClient';
4
+ export class TeamsApi extends BaseApiClient {
5
+ constructor(appName) {
6
+ super(appName);
7
+
8
+ this.getProfile = async params => {
9
+ return this.get(`${urls.identity.users.v2}/me`, params != null ? params : {
10
+ addRoles: true
11
+ });
12
+ };
13
+
14
+ this.updateProfile = async body => {
15
+ return this.put(`${urls.identity.users.v2}/me`, body);
16
+ };
17
+
18
+ this.updateProfileImage = async body => {
19
+ return this.put(`${urls.team.profile.v1}/me/image/v1`, body, {
20
+ responseType: 'plain',
21
+ contentType: undefined
22
+ });
23
+ };
24
+
25
+ this.changePassword = async body => {
26
+ return this.post(`${urls.identity.users.v1}/passwords/change`, body);
27
+ };
28
+
29
+ this.loadUsers = async params => {
30
+ var _params$sort, _params$sort$0$id, _params$sort2, _params$sort2$, _params$sort3, _params$sort3$;
31
+
32
+ const filters = (params.filter || []).reduce((p, n) => _extends({}, p, {
33
+ [n.id]: n.value
34
+ }), {});
35
+ const sorts = (_params$sort = params.sort) != null && _params$sort.length ? {
36
+ sortBy: (_params$sort$0$id = (_params$sort2 = params.sort) == null ? void 0 : (_params$sort2$ = _params$sort2[0]) == null ? void 0 : _params$sort2$.id) != null ? _params$sort$0$id : 'name',
37
+ sortDirection: (_params$sort3 = params.sort) != null && (_params$sort3$ = _params$sort3[0]) != null && _params$sort3$.desc ? 'desc' : 'asc'
38
+ } : null;
39
+ return this.get(urls.team.members.v1, _extends({
40
+ pageOffset: params.pageOffset,
41
+ pageSize: params.pageSize
42
+ }, filters, sorts));
43
+ };
44
+
45
+ this.addUser = async body => {
46
+ return this.post(urls.identity.users.v2, _extends({}, body, {
47
+ provider: 'local'
48
+ }));
49
+ };
50
+
51
+ this.deleteUser = async body => {
52
+ return this.delete(`${urls.team.members.v1}/${body.userId}`);
53
+ };
54
+
55
+ this.updateUser = async body => {
56
+ return this.put(urls.team.members.v1, body);
57
+ };
58
+
59
+ this.updateUserExpirationTime = async body => {
60
+ const {
61
+ userId,
62
+ expirationInSeconds
63
+ } = body;
64
+ return this.put(`${urls.identity.users.temporary.v1}/${userId}`, {
65
+ expirationInSeconds
66
+ });
67
+ };
68
+
69
+ this.setPermanentUser = async userId => {
70
+ return this.delete(`${urls.identity.users.temporary.v1}/${userId}`);
71
+ };
72
+
73
+ this.getTemporaryUserConfiguration = async () => {
74
+ return this.get(urls.identity.users.temporary.configuration.v1);
75
+ };
76
+
77
+ this.createInviteUserLink = async body => {
78
+ return this.post(urls.identity.tenants.invites.user.v1, _extends({}, body));
79
+ };
80
+
81
+ this.updateInviteUserLink = async body => {
82
+ return this.patch(urls.identity.tenants.invites.user.v1, _extends({}, body));
83
+ };
84
+
85
+ this.deleteInviteUserLink = async () => {
86
+ return this.delete(urls.identity.tenants.invites.user.v1);
87
+ };
88
+
89
+ this.getInviteUserLink = async () => {
90
+ return this.get(urls.identity.tenants.invites.user.v1);
91
+ };
92
+
93
+ this.getInviteLinkConfiguration = async () => {
94
+ return this.get(urls.identity.tenants.invites.configuration.v1);
95
+ };
96
+
97
+ this.loadAvailableRoles = async () => {
98
+ return this.get(urls.team.roles.v1);
99
+ };
100
+
101
+ this.loadAvailablePermissions = async () => {
102
+ return this.get(urls.identity.permissions.v1);
103
+ };
104
+
105
+ this.loadStats = async () => {
106
+ return this.get(`${urls.team.stats.v1}/members`);
107
+ };
108
+
109
+ this.resendActivationLink = async body => {
110
+ return this.post(`${urls.team.members.v1}/${body.userId}/resendActivationEmail`, {});
111
+ };
112
+
113
+ this.resendInvitationLink = async body => {
114
+ return this.post(urls.identity.users.v2, _extends({}, body, {
115
+ provider: 'local'
116
+ }));
117
+ };
118
+
119
+ this.resendInvitationLinkToAllTenants = async body => {
120
+ return this.post(urls.identity.users.invitation.resendAll.v1, _extends({}, body));
121
+ };
122
+ }
123
+
93
124
  }
94
- export async function resendInvitationLinkToAllTenants(body) {
95
- return Post(urls.identity.users.invitation.resendAll.v1, _extends({}, body));
96
- }
125
+ export default new TeamsApi('default');
@@ -1,37 +1,25 @@
1
- import { GetHierarchyMetadataParams, GetHierarchyMetadataResponse, IGetTenantsUserCountRequest, IGetTenantsUserCountResponse, IParentTenant, ISubTenant, ISubTenantTree, ISwitchTenant, ITenantsResponse, SearchSubTenantsParams, SearchSubTenantsResponse } from "./interfaces";
2
- import { FronteggPaginationWrapper, UserJwtOptions } from "../interfaces";
3
- /**
4
- * switch logged in user to specific tenant by providing tenantId.
5
- *
6
- * @throws exception if invalid tenantId.
7
- * ``authorized user``
8
- */
9
- export declare function switchTenant(body: ISwitchTenant): Promise<void>;
10
- /**
11
- * retrieve logged in user's available tenants.
12
- *
13
- * ``authorized user``
14
- */
15
- export declare function getTenants(): Promise<ITenantsResponse[]>;
16
- /**
17
- * retrieve logged in user's available sub tenants.
18
- *
19
- * ``authorized user``
20
- */
21
- export declare function getSubTenants(options?: UserJwtOptions): Promise<ISubTenant>;
22
- /**
23
- * retrieve logged in user's available sub tenants as a tree.
24
- *
25
- * ``authorized user``
26
- */
27
- export declare function getSubTenantsAsTree(options?: UserJwtOptions): Promise<ISubTenantTree>;
28
- /**
29
- * retrieve logged in user's available parent tenants.
30
- *
31
- * ``authorized user``
32
- */
33
- export declare function getParentTenants(options?: UserJwtOptions): Promise<IParentTenant[]>;
34
- export declare function getParentTenantsById(tenantId: string, options?: UserJwtOptions): Promise<IParentTenant[]>;
35
- export declare function getTenantsUsersCount(body: IGetTenantsUserCountRequest, options?: UserJwtOptions): Promise<IGetTenantsUserCountResponse[]>;
36
- export declare function searchSubTenants(params: SearchSubTenantsParams, options?: UserJwtOptions): Promise<FronteggPaginationWrapper<SearchSubTenantsResponse>>;
37
- export declare function getHierarchyMetadata(params: GetHierarchyMetadataParams, options?: UserJwtOptions): Promise<GetHierarchyMetadataResponse[]>;
1
+ import { GetHierarchyMetadataParams, GetHierarchyMetadataResponse, IGetTenantsUserCountRequest, IGetTenantsUserCountResponse, IParentTenant, ISubTenant, ISubTenantTree, ISwitchTenant, ITenantsResponse, SearchSubTenantsParams, SearchSubTenantsResponse } from './interfaces';
2
+ import { FronteggPaginationWrapper, UserJwtOptions } from '../interfaces';
3
+ import { BaseApiClient } from '../BaseApiClient';
4
+ export declare class TenantsApi extends BaseApiClient {
5
+ constructor(appName: string);
6
+ /**
7
+ * Switch logged in user to specific tenant by providing tenantId.
8
+ * @throws exception if invalid tenantId.
9
+ */
10
+ switchTenant: (body: ISwitchTenant) => Promise<void>;
11
+ /** Retrieve logged in user's available tenants. */
12
+ getTenants: () => Promise<ITenantsResponse[]>;
13
+ /** Retrieve logged in user's available sub tenants. */
14
+ getSubTenants: (options?: UserJwtOptions | undefined) => Promise<ISubTenant>;
15
+ /** Retrieve logged in user's available sub tenants as a tree. */
16
+ getSubTenantsAsTree: (options?: UserJwtOptions | undefined) => Promise<ISubTenantTree>;
17
+ /** Retrieve logged in user's available parent tenants. */
18
+ getParentTenants: (options?: UserJwtOptions | undefined) => Promise<IParentTenant[]>;
19
+ getParentTenantsById: (tenantId: string, options?: UserJwtOptions | undefined) => Promise<IParentTenant[]>;
20
+ getTenantsUsersCount: (body: IGetTenantsUserCountRequest, options?: UserJwtOptions | undefined) => Promise<IGetTenantsUserCountResponse[]>;
21
+ searchSubTenants: (params: SearchSubTenantsParams, options?: UserJwtOptions | undefined) => Promise<FronteggPaginationWrapper<SearchSubTenantsResponse>>;
22
+ getHierarchyMetadata: (params: GetHierarchyMetadataParams, options?: UserJwtOptions | undefined) => Promise<GetHierarchyMetadataResponse[]>;
23
+ }
24
+ declare const _default: TenantsApi;
25
+ export default _default;
package/tenants/index.js CHANGED
@@ -1,52 +1,68 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { extractHeadersFromOptions, Get, Post, Put } from "../fetch";
3
- import { urls } from "../constants";
2
+ import { urls } from '../constants';
4
3
  import { setTabTenantInSessionStorage } from '../auth/utils';
5
4
  import { ContextHolder } from '../ContextHolder';
6
- export async function switchTenant(body) {
7
- if (ContextHolder.isSessionPerTenantEnabled()) {
8
- setTabTenantInSessionStorage(body.tenantId);
5
+ import { BaseApiClient } from '../BaseApiClient';
6
+ export class TenantsApi extends BaseApiClient {
7
+ constructor(appName) {
8
+ super(appName);
9
+
10
+ this.switchTenant = async body => {
11
+ if (ContextHolder.for(this.appName).isSessionPerTenantEnabled()) {
12
+ setTabTenantInSessionStorage(body.tenantId);
13
+ }
14
+
15
+ return this.put(`${urls.identity.users.v1}/tenant`, body);
16
+ };
17
+
18
+ this.getTenants = async () => {
19
+ return this.get(`${urls.identity.users.v2}/me/tenants`);
20
+ };
21
+
22
+ this.getSubTenants = async options => {
23
+ return this.get(urls.tenants.hierarchy.v1, undefined, {
24
+ headers: this.extractHeadersFromOptions(options)
25
+ });
26
+ };
27
+
28
+ this.getSubTenantsAsTree = async options => {
29
+ return this.get(urls.tenants.hierarchy.tree.v1, undefined, {
30
+ headers: this.extractHeadersFromOptions(options)
31
+ });
32
+ };
33
+
34
+ this.getParentTenants = async options => {
35
+ return this.get(urls.tenants.hierarchy.parents.v1, undefined, {
36
+ headers: this.extractHeadersFromOptions(options)
37
+ });
38
+ };
39
+
40
+ this.getParentTenantsById = async (tenantId, options) => {
41
+ return this.get(`${urls.tenants.hierarchy.parents.v1}/${tenantId}`, undefined, {
42
+ headers: this.extractHeadersFromOptions(options)
43
+ });
44
+ };
45
+
46
+ this.getTenantsUsersCount = async (body, options) => {
47
+ return this.post(`${urls.identity.tenants.users.v1}/count`, body, {
48
+ headers: this.extractHeadersFromOptions(options)
49
+ });
50
+ };
51
+
52
+ this.searchSubTenants = async (params, options) => {
53
+ return this.get(urls.tenants.hierarchy.v2, params, {
54
+ headers: this.extractHeadersFromOptions(options)
55
+ });
56
+ };
57
+
58
+ this.getHierarchyMetadata = async (params, options) => {
59
+ return this.get(urls.tenants.hierarchy.metadata.v2, _extends({}, params, {
60
+ _tenantIds: params._tenantIds.join(',')
61
+ }), {
62
+ headers: this.extractHeadersFromOptions(options)
63
+ });
64
+ };
9
65
  }
10
66
 
11
- return Put(`${urls.identity.users.v1}/tenant`, body);
12
- }
13
- export async function getTenants() {
14
- return Get(`${urls.identity.users.v2}/me/tenants`);
15
- }
16
- export async function getSubTenants(options) {
17
- return Get(urls.tenants.hierarchy.v1, undefined, {
18
- headers: extractHeadersFromOptions(options)
19
- });
20
- }
21
- export async function getSubTenantsAsTree(options) {
22
- return Get(urls.tenants.hierarchy.tree.v1, undefined, {
23
- headers: extractHeadersFromOptions(options)
24
- });
25
- }
26
- export async function getParentTenants(options) {
27
- return Get(urls.tenants.hierarchy.parents.v1, undefined, {
28
- headers: extractHeadersFromOptions(options)
29
- });
30
- }
31
- export async function getParentTenantsById(tenantId, options) {
32
- return Get(`${urls.tenants.hierarchy.parents.v1}/${tenantId}`, undefined, {
33
- headers: extractHeadersFromOptions(options)
34
- });
35
- }
36
- export async function getTenantsUsersCount(body, options) {
37
- return Post(`${urls.identity.tenants.users.v1}/count`, body, {
38
- headers: extractHeadersFromOptions(options)
39
- });
40
- }
41
- export async function searchSubTenants(params, options) {
42
- return Get(urls.tenants.hierarchy.v2, params, {
43
- headers: extractHeadersFromOptions(options)
44
- });
45
67
  }
46
- export async function getHierarchyMetadata(params, options) {
47
- return Get(urls.tenants.hierarchy.metadata.v2, _extends({}, params, {
48
- _tenantIds: params._tenantIds.join(',')
49
- }), {
50
- headers: extractHeadersFromOptions(options)
51
- });
52
- }
68
+ export default new TenantsApi('default');
@@ -1,4 +1,5 @@
1
1
  import { PaginationOrderEnum } from "../interfaces";
2
+ import { SubAccountAccessTypeEnum } from "../sub-tenants/interfaces";
2
3
  export declare enum TenantSortByEnum {
3
4
  createdAt = "createdAt",
4
5
  name = "name",
@@ -102,6 +103,7 @@ export interface SearchSubTenantsResponse {
102
103
  createdAt: Date;
103
104
  metadata: SearchSubTenantMetadata;
104
105
  isReseller?: boolean;
106
+ subAccountAccessType?: SubAccountAccessTypeEnum;
105
107
  }
106
108
  export interface GetHierarchyMetadataParams {
107
109
  _tenantIds: string[];
@@ -1,26 +1,32 @@
1
- import { FronteggPaginationWrapper } from "../interfaces";
2
- import { ICreatePhoneNumberResponse, IDeletePhoneNumberResponse, IGetPhoneNumbersQueryParams, IPhoneNumber, IPreVerifyPhoneNumber, IPreVerifyPhoneNumberResponse, IUpdatePhoneNumber, IVerifyPhoneNumber } from "./interfaces";
3
- /**
4
- * Get phone numbers of user
5
- */
6
- export declare function getUserPhoneNumbers(queryParams: IGetPhoneNumbersQueryParams): Promise<FronteggPaginationWrapper<IPhoneNumber>>;
7
- /**
8
- * Create new phone number for user, by default otc will be sent with this request
9
- */
10
- export declare function createPhoneNumber(body: IUpdatePhoneNumber): Promise<ICreatePhoneNumberResponse>;
11
- /**
12
- * Delete existing phone number for user
13
- */
14
- export declare function deletePhoneNumber(phoneId: string): Promise<IDeletePhoneNumberResponse>;
15
- /**
16
- * Pre verify phone number, used before verify to send OTC to user
17
- */
18
- export declare function preVerifyPhoneNumber(body: IPreVerifyPhoneNumber): Promise<IPreVerifyPhoneNumberResponse>;
19
- /**
20
- * Verify phone number
21
- */
22
- export declare function verifyPhoneNumber(body: IVerifyPhoneNumber): Promise<void>;
23
- /**
24
- * Verify delete phone number
25
- */
26
- export declare function verifyDeletePhoneNumber(phoneId: string, body: IVerifyPhoneNumber): Promise<void>;
1
+ import { FronteggPaginationWrapper } from '../interfaces';
2
+ import { ICreatePhoneNumberResponse, IDeletePhoneNumberResponse, IGetPhoneNumbersQueryParams, IPhoneNumber, IPreVerifyPhoneNumber, IPreVerifyPhoneNumberResponse, IUpdatePhoneNumber, IVerifyPhoneNumber } from './interfaces';
3
+ import { BaseApiClient } from '../BaseApiClient';
4
+ export declare class PhoneNumbersApi extends BaseApiClient {
5
+ constructor(appName: string);
6
+ /**
7
+ * Get phone numbers of user
8
+ */
9
+ getUserPhoneNumbers: (queryParams: IGetPhoneNumbersQueryParams) => Promise<FronteggPaginationWrapper<IPhoneNumber>>;
10
+ /**
11
+ * Create new phone number for user, by default OTC will be sent with this request
12
+ */
13
+ createPhoneNumber: (body: IUpdatePhoneNumber) => Promise<ICreatePhoneNumberResponse>;
14
+ /**
15
+ * Delete existing phone number for user
16
+ */
17
+ deletePhoneNumber: (phoneId: string) => Promise<IDeletePhoneNumberResponse>;
18
+ /**
19
+ * Pre verify phone number, used before verify to send OTC to user
20
+ */
21
+ preVerifyPhoneNumber: (body: IPreVerifyPhoneNumber) => Promise<IPreVerifyPhoneNumberResponse>;
22
+ /**
23
+ * Verify phone number
24
+ */
25
+ verifyPhoneNumber: (body: IVerifyPhoneNumber) => Promise<void>;
26
+ /**
27
+ * Verify delete phone number
28
+ */
29
+ verifyDeletePhoneNumber: (phoneId: string, body: IVerifyPhoneNumber) => Promise<void>;
30
+ }
31
+ declare const _default: PhoneNumbersApi;
32
+ export default _default;