@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/FetchClient.js ADDED
@@ -0,0 +1,308 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { ContextHolder } from './ContextHolder';
3
+ import { FronteggApiError } from './error';
4
+ import { GENERIC_ERROR_MESSAGE } from './constants';
5
+ import { fronteggHeaders } from './interfaces';
6
+ export class FetchClient {
7
+ constructor(appName) {
8
+ this.appName = void 0;
9
+
10
+ this.getFronteggContext = () => {
11
+ return ContextHolder.for(this.appName);
12
+ };
13
+
14
+ this.prepareUrl = async (url, params) => {
15
+ const context = this.getFronteggContext().getContext();
16
+ const baseUrl = this.getContextBaseUrl(url);
17
+ const paramsToSend = await this.buildQueryParams(context, params);
18
+ let finalUrl = url.startsWith('http') ? url : `${baseUrl}${url}`;
19
+ const hasKeys = Object.keys(paramsToSend).length > 0;
20
+
21
+ if (paramsToSend && hasKeys) {
22
+ const urlParams = new URLSearchParams(paramsToSend);
23
+ finalUrl += `?${urlParams}`;
24
+ }
25
+
26
+ return finalUrl;
27
+ };
28
+
29
+ this.buildQueryParams = async (context, params) => {
30
+ if (!params) {
31
+ params = {};
32
+ }
33
+
34
+ const additionalQueryParams = await this.getAdditionalQueryParams(context);
35
+
36
+ for (const queryParam of additionalQueryParams) {
37
+ params[queryParam.key] = queryParam.value;
38
+ }
39
+
40
+ const keys = Object.keys(params);
41
+
42
+ for (const key of keys) {
43
+ const value = params[key];
44
+ params[key] = typeof value === 'object' ? JSON.stringify(value) : value;
45
+ }
46
+
47
+ return params;
48
+ };
49
+
50
+ this.getAdditionalQueryParams = async context => {
51
+ let output = [];
52
+
53
+ if (context.additionalQueryParamsResolver) {
54
+ output = await context.additionalQueryParamsResolver();
55
+ }
56
+
57
+ return output;
58
+ };
59
+
60
+ this.getAdditionalHeaders = async context => {
61
+ let output = [];
62
+
63
+ if (context.additionalHeadersResolver) {
64
+ output = await context.additionalHeadersResolver();
65
+ }
66
+
67
+ if (context.tenantResolver) {
68
+ const resolvedTenantResult = await context.tenantResolver();
69
+
70
+ if (!!(resolvedTenantResult != null && resolvedTenantResult.tenant)) {
71
+ output.push({
72
+ key: 'frontegg-login-alias',
73
+ value: resolvedTenantResult.tenant
74
+ });
75
+ }
76
+ }
77
+
78
+ if (context.appId) {
79
+ output.push({
80
+ key: 'frontegg-requested-application-id',
81
+ value: context.appId
82
+ });
83
+ }
84
+
85
+ return output;
86
+ };
87
+
88
+ this.buildRequestHeaders = async contentType => {
89
+ var _context$tokenResolve;
90
+
91
+ const fronteggContext = this.getFronteggContext();
92
+ const context = fronteggContext.getContext();
93
+ const headers = FetchClient.getMetadataHeaders(context);
94
+ const authToken = await ((_context$tokenResolve = context == null ? void 0 : context.tokenResolver) != null ? _context$tokenResolve : fronteggContext.getAccessToken)();
95
+ const requestSource = fronteggContext.getRequestSource();
96
+ const scopedTenant = FetchClient.getScopedTenant();
97
+
98
+ if (contentType) {
99
+ headers[fronteggHeaders.contentType] = contentType;
100
+ }
101
+
102
+ if (requestSource) {
103
+ headers[fronteggHeaders.source] = requestSource;
104
+ }
105
+
106
+ if (authToken) {
107
+ headers.Authorization = `Bearer ${authToken}`;
108
+ }
109
+
110
+ if (scopedTenant) {
111
+ headers[fronteggHeaders.scopedTenant] = scopedTenant;
112
+ }
113
+
114
+ for (const additionalHeader of await this.getAdditionalHeaders(context)) {
115
+ headers[`${additionalHeader.key}`] = `${additionalHeader.value}`;
116
+ }
117
+
118
+ return headers;
119
+ };
120
+
121
+ this.sendRequest = async opts => {
122
+ var _opts$method, _ref, _opts$credentials;
123
+
124
+ const context = this.getFronteggContext().getContext();
125
+ const headers = await this.buildRequestHeaders(opts.contentType);
126
+ const url = await this.prepareUrl(opts.url, opts.params);
127
+ const response = await fetch(url, {
128
+ body: opts.body ? opts.contentType === 'application/json' ? JSON.stringify(opts.body) : opts.body : null,
129
+ method: (_opts$method = opts.method) != null ? _opts$method : 'GET',
130
+ headers: _extends({}, headers, opts.headers),
131
+ credentials: (_ref = (_opts$credentials = opts.credentials) != null ? _opts$credentials : context.requestCredentials) != null ? _ref : 'same-origin'
132
+ });
133
+
134
+ if (response.status === 302) {
135
+ window.location.href = await response.text();
136
+ return new Promise(() => {});
137
+ }
138
+
139
+ if (!response.ok) {
140
+ var _context$logLevel, _context$logLevel2;
141
+
142
+ if (response.status === 413) {
143
+ throw new FronteggApiError('Error request is too large', response.status);
144
+ }
145
+
146
+ let errorMessage;
147
+ let isJsonResponse = true;
148
+
149
+ try {
150
+ errorMessage = await response.text();
151
+ errorMessage = JSON.parse(errorMessage);
152
+ } catch (e) {
153
+ isJsonResponse = false;
154
+ }
155
+
156
+ if (errorMessage.errors) {
157
+ errorMessage = errorMessage.errors.join(', ');
158
+ } else if (typeof errorMessage !== 'string') {
159
+ errorMessage = `Error ${response.status} - ${response.statusText}`;
160
+ }
161
+
162
+ if (response.status >= 400 && response.status < 500 && ['warn'].includes((_context$logLevel = context.logLevel) != null ? _context$logLevel : '')) console.warn(errorMessage);else if (response.status === 500 && ['warn', 'error'].includes((_context$logLevel2 = context.logLevel) != null ? _context$logLevel2 : '')) console.error(errorMessage);
163
+ throw new FronteggApiError(isJsonResponse ? errorMessage : GENERIC_ERROR_MESSAGE, response.status);
164
+ }
165
+
166
+ if (!opts.responseType || opts.responseType === 'json') {
167
+ try {
168
+ return await response.json();
169
+ } catch (e) {
170
+ return {};
171
+ }
172
+ } else if (opts.responseType === 'blob') {
173
+ const {
174
+ outputFileName
175
+ } = opts.params;
176
+ return await response.blob().then(blob => URL.createObjectURL(blob)).then(url => {
177
+ const tempLink = document.createElement('a');
178
+ tempLink.href = url;
179
+ tempLink.setAttribute('download', outputFileName || 'output');
180
+ tempLink.click();
181
+ });
182
+ } else {
183
+ return await response.text();
184
+ }
185
+ };
186
+
187
+ this.get = async (url, params, opts) => this.sendRequest(_extends({
188
+ url,
189
+ method: 'GET',
190
+ contentType: 'application/json',
191
+ params
192
+ }, opts));
193
+
194
+ this.post = async (url, body, opts) => this.sendRequest(_extends({
195
+ url,
196
+ method: 'POST',
197
+ contentType: 'application/json',
198
+ body
199
+ }, opts));
200
+
201
+ this.patch = async (url, body, opts) => this.sendRequest(_extends({
202
+ url,
203
+ method: 'PATCH',
204
+ contentType: 'application/json',
205
+ body
206
+ }, opts));
207
+
208
+ this.put = async (url, body, opts) => this.sendRequest(_extends({
209
+ url,
210
+ method: 'PUT',
211
+ contentType: 'application/json',
212
+ body
213
+ }, opts));
214
+
215
+ this.delete = async (url, body, opts) => this.sendRequest(_extends({
216
+ url,
217
+ method: 'DELETE',
218
+ contentType: 'application/json',
219
+ body
220
+ }, opts));
221
+
222
+ this.postDownload = async (url, body, params, opts) => this.sendRequest(_extends({
223
+ url,
224
+ method: 'POST',
225
+ contentType: 'application/json',
226
+ responseType: 'blob',
227
+ body,
228
+ params
229
+ }, opts));
230
+
231
+ this.extractHeadersFromOptions = (options = {}) => _extends({}, options.jwt ? {
232
+ Authorization: options.jwt
233
+ } : {});
234
+
235
+ this.getBaseUrl = (context, url, withFronteggPrefix = true) => {
236
+ return FetchClient.getBaseUrl(context, url, withFronteggPrefix);
237
+ };
238
+
239
+ this.getContextBaseUrl = (url, withFronteggPrefix = true) => {
240
+ const context = this.getFronteggContext().getContext();
241
+ return this.getBaseUrl(context, url, withFronteggPrefix);
242
+ };
243
+
244
+ this.getMetadataHeaders = context => {
245
+ return FetchClient.getMetadataHeaders(context);
246
+ };
247
+
248
+ this.getContextMetadataHeaders = () => {
249
+ const context = this.getFronteggContext().getContext();
250
+ return FetchClient.getMetadataHeaders(context);
251
+ };
252
+
253
+ this.appName = appName;
254
+ }
255
+
256
+ }
257
+
258
+ FetchClient.getBaseUrl = (context, url, withFronteggPrefix = true) => {
259
+ let baseUrl;
260
+
261
+ if (typeof context.baseUrl === 'function') {
262
+ baseUrl = context.baseUrl(url);
263
+ } else {
264
+ baseUrl = context.baseUrl;
265
+ }
266
+
267
+ const prefix = context.urlPrefix || 'frontegg';
268
+ const removePrefix = prefix === 'frontegg' && !withFronteggPrefix;
269
+
270
+ if (!baseUrl.endsWith('/')) {
271
+ baseUrl += '/';
272
+ }
273
+
274
+ if (!baseUrl.endsWith(prefix) && !removePrefix) {
275
+ baseUrl += prefix;
276
+ }
277
+
278
+ return baseUrl;
279
+ };
280
+
281
+ FetchClient.getMetadataHeaders = context => {
282
+ var _context$metadataHead, _context$metadataHead2;
283
+
284
+ const headers = {};
285
+
286
+ if (context != null && (_context$metadataHead = context.metadataHeaders) != null && _context$metadataHead.fronteggSdkVersion) {
287
+ headers[fronteggHeaders.fronteggSdkVersion] = context.metadataHeaders.fronteggSdkVersion;
288
+ }
289
+
290
+ if (context != null && (_context$metadataHead2 = context.metadataHeaders) != null && _context$metadataHead2.framework) {
291
+ headers[fronteggHeaders.frameWork] = context.metadataHeaders.framework;
292
+ }
293
+
294
+ return headers;
295
+ };
296
+
297
+ FetchClient.getScopedTenant = () => {
298
+ const urlParams = new URLSearchParams(window.location.search);
299
+ const scopedTenant = urlParams.get('tenantId');
300
+
301
+ if (scopedTenant) {
302
+ return scopedTenant;
303
+ }
304
+
305
+ return null;
306
+ };
307
+
308
+ export default new FetchClient('default');
@@ -1,9 +1,21 @@
1
1
  import { IPublicSettingsResponse, ISettingsResponse, IUpdateSettings } from "./interfaces";
2
2
  import { UserJwtOptions } from "../interfaces";
3
- /*** update account settings for tenant.
4
- * tenantId is caclulated in the backend from context
5
- * ``authorized user``
6
- */
7
- export declare function updateSettings(body: IUpdateSettings, options?: UserJwtOptions): Promise<ISettingsResponse>;
8
- export declare function getSettings(options?: UserJwtOptions): Promise<ISettingsResponse>;
9
- export declare function getPublicSettings(): Promise<IPublicSettingsResponse>;
3
+ import { BaseApiClient } from '../BaseApiClient';
4
+ export declare class AccountSettingsApi extends BaseApiClient {
5
+ constructor(appName: string);
6
+ /**
7
+ * Update account settings for a tenant.
8
+ * TenantId is calculated in the backend from context of the `authorized user`.
9
+ */
10
+ updateSettings: (body: IUpdateSettings, options?: UserJwtOptions | undefined) => Promise<ISettingsResponse>;
11
+ /**
12
+ * Get account settings for a tenant.
13
+ */
14
+ getSettings: (options?: UserJwtOptions | undefined) => Promise<ISettingsResponse>;
15
+ /**
16
+ * Get public account settings.
17
+ */
18
+ getPublicSettings: () => Promise<IPublicSettingsResponse>;
19
+ }
20
+ declare const _default: AccountSettingsApi;
21
+ export default _default;
@@ -1,15 +1,25 @@
1
1
  import { urls } from "../constants";
2
- import { extractHeadersFromOptions, Get, Put } from "../fetch";
3
- export async function updateSettings(body, options) {
4
- return Put(urls.tenants.accountSettings.v1, body, {
5
- headers: extractHeadersFromOptions(options)
6
- });
2
+ import { BaseApiClient } from '../BaseApiClient';
3
+ export class AccountSettingsApi extends BaseApiClient {
4
+ constructor(appName) {
5
+ super(appName);
6
+
7
+ this.updateSettings = async (body, options) => {
8
+ return this.put(urls.tenants.accountSettings.v1, body, {
9
+ headers: this.extractHeadersFromOptions(options)
10
+ });
11
+ };
12
+
13
+ this.getSettings = async options => {
14
+ return this.get(urls.tenants.accountSettings.v1, undefined, {
15
+ headers: this.extractHeadersFromOptions(options)
16
+ });
17
+ };
18
+
19
+ this.getPublicSettings = async () => {
20
+ return this.get(`${urls.tenants.accountSettings.v1}/public`);
21
+ };
22
+ }
23
+
7
24
  }
8
- export async function getSettings(options) {
9
- return Get(urls.tenants.accountSettings.v1, undefined, {
10
- headers: extractHeadersFromOptions(options)
11
- });
12
- }
13
- export async function getPublicSettings() {
14
- return Get(`${urls.tenants.accountSettings.v1}/public`);
15
- }
25
+ export default new AccountSettingsApi('default');
@@ -1,46 +1,51 @@
1
- import { IUserApplicationsIdPayload, IUserApplicationsDataPayload, IApplicationsResponse, IAssignUserToApplicationsBody, IUsersApplicationsIdPayload, IUsersOfApplicationsResponse, ITenantApplicationsResponse, IGetUsersOfApplicationsQuery, IUsersApplicationsIdsResponse } from "./interfaces";
1
+ import { BaseApiClient } from '../BaseApiClient';
2
+ import { IUserApplicationsIdPayload, IUserApplicationsDataPayload, IApplicationsResponse, IAssignUserToApplicationsBody, IUsersApplicationsIdPayload, IUsersOfApplicationsResponse, ITenantApplicationsResponse, IGetUsersOfApplicationsQuery, IUsersApplicationsIdsResponse } from './interfaces';
2
3
  /**
3
- * Get applications id array for single user by user id
4
- * @param userId - user id to find his applications id array
5
- * @returns all app ids as string[]
4
+ * UsersApplicationsApi class for handling applications-related operations.
6
5
  */
7
- export declare function getUserApplicationsId({ userId }: IUserApplicationsIdPayload): Promise<string[]>;
8
- /**
9
- * Get applications id array for multiple users by user id array
10
- * @param userIds - array of all user id's
11
- * @returns object that maps every user id to his applications id array
12
- */
13
- export declare function getUsersApplicationsId({ userIds }: IUsersApplicationsIdPayload): Promise<IUsersApplicationsIdsResponse[]>;
14
- /**
15
- * Get applications data array for specific tenant
16
- * @returns array of object with tenant id and his applications id array
17
- */
18
- export declare function getTenantsApplications(): Promise<ITenantApplicationsResponse[]>;
19
- /**
20
- * Get applications data by array of application ids
21
- * @param appIds - array of application ids
22
- * @returns array of application data
23
- */
24
- export declare function getApplicationsData({ appIds, includeFreeAccess }: IUserApplicationsDataPayload): Promise<IApplicationsResponse[]>;
25
- /**
26
- * Assign user to multiple applications
27
- * @param appIds - string[]
28
- * @param tenantId - string
29
- * @param userId - string
30
- * @returns void
31
- */
32
- export declare function assignUserToApplications(body: IAssignUserToApplicationsBody): Promise<void>;
33
- /**
34
- * Unassign user from multiple applications
35
- * @param appIds - string[]
36
- * @param tenantId - string
37
- * @param userId - string
38
- * @returns void
39
- */
40
- export declare function unassignUserFromApplications(body: IAssignUserToApplicationsBody): Promise<void>;
41
- /**
42
- * Get users array for each application for array of applications
43
- * @param appIds - array of applications
44
- * @returns array of objects with application id and his users array
45
- */
46
- export declare function getUsersOfApplications({ appIds }: IGetUsersOfApplicationsQuery): Promise<IUsersOfApplicationsResponse[]>;
6
+ export declare class ApplicationsApi extends BaseApiClient {
7
+ constructor(appName: string);
8
+ /**
9
+ * Get applications id array for a single user by user id.
10
+ * @param {IUserApplicationsIdPayload} param0 - user id to find their applications id array.
11
+ * @returns {Promise<string[]>} all app ids as string[].
12
+ */
13
+ getUserApplicationsId: ({ userId }: IUserApplicationsIdPayload) => Promise<string[]>;
14
+ /**
15
+ * Get applications id array for multiple users by user id array.
16
+ * @param {IUsersApplicationsIdPayload} param0 - array of all user ids.
17
+ * @returns {Promise<IUsersApplicationsIdsResponse[]>} object that maps every user id to its applications id array.
18
+ */
19
+ getUsersApplicationsId: ({ userIds }: IUsersApplicationsIdPayload) => Promise<IUsersApplicationsIdsResponse[]>;
20
+ /**
21
+ * Get applications data array for a specific tenant.
22
+ * @returns {Promise<ITenantApplicationsResponse[]>} array of objects with tenant id and its applications id array.
23
+ */
24
+ getTenantsApplications: () => Promise<ITenantApplicationsResponse[]>;
25
+ /**
26
+ * Get applications data by array of application ids.
27
+ * @param {IUserApplicationsDataPayload} param0 - array of application ids.
28
+ * @returns {Promise<IApplicationsResponse[]>} array of application data.
29
+ */
30
+ getApplicationsData: ({ appIds, includeFreeAccess }: IUserApplicationsDataPayload) => Promise<IApplicationsResponse[]>;
31
+ /**
32
+ * Assign user to multiple applications.
33
+ * @param {IAssignUserToApplicationsBody} body - assignment details.
34
+ * @returns {Promise<void>}
35
+ */
36
+ assignUserToApplications: (body: IAssignUserToApplicationsBody) => Promise<void>;
37
+ /**
38
+ * Unassign user from multiple applications.
39
+ * @param {IAssignUserToApplicationsBody} body - unassignment details.
40
+ * @returns {Promise<void>}
41
+ */
42
+ unassignUserFromApplications: (body: IAssignUserToApplicationsBody) => Promise<void>;
43
+ /**
44
+ * Get users array for each application for an array of applications.
45
+ * @param {IGetUsersOfApplicationsQuery} param0 - array of applications.
46
+ * @returns {Promise<IUsersOfApplicationsResponse[]>} array of objects with application id and its users array.
47
+ */
48
+ getUsersOfApplications: ({ appIds }: IGetUsersOfApplicationsQuery) => Promise<IUsersOfApplicationsResponse[]>;
49
+ }
50
+ declare const _default: ApplicationsApi;
51
+ export default _default;
@@ -1,39 +1,53 @@
1
1
  import { urls } from "../constants";
2
- import { Post, Get, Delete } from "../fetch";
3
- export async function getUserApplicationsId({
4
- userId
5
- }) {
6
- return Get(`${urls.identity.applications.v1}/${userId}/apps`);
2
+ import { BaseApiClient } from '../BaseApiClient';
3
+ export class ApplicationsApi extends BaseApiClient {
4
+ constructor(appName) {
5
+ super(appName);
6
+
7
+ this.getUserApplicationsId = async ({
8
+ userId
9
+ }) => {
10
+ return this.get(`${urls.identity.applications.v1}/${userId}/apps`);
11
+ };
12
+
13
+ this.getUsersApplicationsId = async ({
14
+ userIds
15
+ }) => {
16
+ return this.get(`${urls.identity.applications.v1}/users-apps`, {
17
+ userIds: userIds.join(',')
18
+ });
19
+ };
20
+
21
+ this.getTenantsApplications = async () => {
22
+ return this.get(urls.applications.tenant.v1);
23
+ };
24
+
25
+ this.getApplicationsData = async ({
26
+ appIds,
27
+ includeFreeAccess = true
28
+ }) => {
29
+ return this.get(urls.applications.v1, {
30
+ ids: appIds.join(','),
31
+ _includeFreeAccess: includeFreeAccess
32
+ });
33
+ };
34
+
35
+ this.assignUserToApplications = async body => {
36
+ return this.post(`${urls.identity.applications.v1}/apps-user`, body);
37
+ };
38
+
39
+ this.unassignUserFromApplications = async body => {
40
+ return this.delete(`${urls.identity.applications.v1}/user-apps`, body);
41
+ };
42
+
43
+ this.getUsersOfApplications = async ({
44
+ appIds
45
+ }) => {
46
+ return this.get(`${urls.identity.applications.v1}/apps-users`, {
47
+ appIds: appIds.join(',')
48
+ });
49
+ };
50
+ }
51
+
7
52
  }
8
- export async function getUsersApplicationsId({
9
- userIds
10
- }) {
11
- return Get(`${urls.identity.applications.v1}/users-apps`, {
12
- userIds: userIds.join(',')
13
- });
14
- }
15
- export async function getTenantsApplications() {
16
- return Get(urls.applications.tenant.v1);
17
- }
18
- export async function getApplicationsData({
19
- appIds,
20
- includeFreeAccess = true
21
- }) {
22
- return Get(urls.applications.v1, {
23
- ids: appIds.join(','),
24
- _includeFreeAccess: includeFreeAccess
25
- });
26
- }
27
- export async function assignUserToApplications(body) {
28
- return Post(`${urls.identity.applications.v1}/apps-user`, body);
29
- }
30
- export async function unassignUserFromApplications(body) {
31
- return Delete(`${urls.identity.applications.v1}/user-apps`, body);
32
- }
33
- export async function getUsersOfApplications({
34
- appIds
35
- }) {
36
- return Get(`${urls.identity.applications.v1}/apps-users`, {
37
- appIds: appIds.join(',')
38
- });
39
- }
53
+ export default new ApplicationsApi('default');
package/audits/index.d.ts CHANGED
@@ -1,16 +1,28 @@
1
1
  import { IAudits, IAuditsStats, IGetAuditsParams, IGetAuditsStatsParams, IExportAudits } from './interfaces';
2
- /*****************************************
3
- * Audits Api
4
- *****************************************/
5
- /**
6
- * get Audits
7
- */
8
- export declare function getAudits(params: IGetAuditsParams): Promise<IAudits>;
9
- /**
10
- * get Audits Stats
11
- */
12
- export declare function getAuditsStats(params: IGetAuditsStatsParams): Promise<IAuditsStats>;
13
- /**
14
- * export Audits
15
- */
16
- export declare function exportAudits(params: IExportAudits): Promise<any>;
2
+ import { BaseApiClient } from '../BaseApiClient';
3
+ export declare class AuditsApi extends BaseApiClient {
4
+ constructor(appName: string);
5
+ /**
6
+ * Fetches audit logs based on the provided parameters.
7
+ *
8
+ * @param params - Parameters to filter and paginate audits.
9
+ * @returns A promise that resolves to the list of audits.
10
+ */
11
+ getAudits: (params: IGetAuditsParams) => Promise<IAudits>;
12
+ /**
13
+ * Retrieves audit statistics based on the provided parameters.
14
+ *
15
+ * @param params - Parameters to filter and define the scope of the stats.
16
+ * @returns A promise that resolves to the audits statistics.
17
+ */
18
+ getAuditsStats: (params: IGetAuditsStatsParams) => Promise<IAuditsStats>;
19
+ /**
20
+ * Exports audit logs based on the provided parameters.
21
+ *
22
+ * @param params - Parameters including endpoint, header properties, and other request specifics.
23
+ * @returns A promise that initiates a download for the exported audits.
24
+ */
25
+ exportAudits: (params: IExportAudits) => Promise<void>;
26
+ }
27
+ declare const _default: AuditsApi;
28
+ export default _default;
package/audits/index.js CHANGED
@@ -1,21 +1,31 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  const _excluded = ["endpoint", "headerProps"];
3
- import { Get, PostDownload } from '../fetch';
4
3
  import { urls } from '../constants';
5
- export async function getAudits(params) {
6
- return Get(urls.audits.v1, params);
7
- }
8
- export async function getAuditsStats(params) {
9
- return Get(`${urls.audits.v1}/stats`, params);
10
- }
11
- export async function exportAudits(params) {
12
- const {
13
- endpoint,
14
- headerProps
15
- } = params,
16
- restParams = _objectWithoutPropertiesLoose(params, _excluded);
4
+ import { BaseApiClient } from '../BaseApiClient';
5
+ export class AuditsApi extends BaseApiClient {
6
+ constructor(appName) {
7
+ super(appName);
8
+
9
+ this.getAudits = async params => {
10
+ return this.get(urls.audits.v1, params);
11
+ };
12
+
13
+ this.getAuditsStats = async params => {
14
+ return this.get(`${urls.audits.v1}/stats`, params);
15
+ };
17
16
 
18
- return PostDownload(`${urls.audits.v1}/export/${endpoint}`, {
19
- properties: headerProps
20
- }, restParams);
21
- }
17
+ this.exportAudits = async params => {
18
+ const {
19
+ endpoint,
20
+ headerProps
21
+ } = params,
22
+ restParams = _objectWithoutPropertiesLoose(params, _excluded);
23
+
24
+ return this.postDownload(`${urls.audits.v1}/export/${endpoint}`, {
25
+ properties: headerProps
26
+ }, restParams);
27
+ };
28
+ }
29
+
30
+ }
31
+ export default new AuditsApi('default');