@frontegg/rest-api 3.0.110 → 3.0.112

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.
@@ -1,4 +1,4 @@
1
- export interface ISettingsResponse {
1
+ export interface ISettingsResponse extends IPublicSettingsResponse {
2
2
  address?: string;
3
3
  timezone?: string;
4
4
  dateFormat?: string;
package/constants.d.ts CHANGED
@@ -127,6 +127,7 @@ export declare const urls: {
127
127
  parents: {
128
128
  v1: string;
129
129
  };
130
+ v2: string;
130
131
  };
131
132
  subTenants: {
132
133
  v1: string;
package/constants.js CHANGED
@@ -126,7 +126,8 @@ export const urls = {
126
126
  },
127
127
  parents: {
128
128
  v1: '/tenants/resources/hierarchy/v1/parents'
129
- }
129
+ },
130
+ v2: '/tenants/resources/hierarchy/v2'
130
131
  },
131
132
  subTenants: {
132
133
  v1: '/tenants/resources/sub-tenants/v1'
package/fetch.js CHANGED
@@ -133,6 +133,34 @@ async function getAdditionalHeaders(context) {
133
133
  return output;
134
134
  }
135
135
 
136
+ const handleError = async (response, context) => {
137
+ var _errorMessage, _context$logLevel, _context$logLevel2;
138
+
139
+ if (response.status === 413) {
140
+ throw new FronteggApiError('Error request is too large', response.status);
141
+ }
142
+
143
+ let errorMessage;
144
+
145
+ try {
146
+ errorMessage = await response.text();
147
+ errorMessage = JSON.parse(errorMessage);
148
+ } catch (e) {
149
+ errorMessage = undefined;
150
+ }
151
+
152
+ const contentType = response.headers.get("content-type");
153
+
154
+ if ((_errorMessage = errorMessage) != null && _errorMessage.errors) {
155
+ errorMessage = errorMessage.errors.join(', ');
156
+ } else if (typeof errorMessage !== 'string' || !(contentType != null && contentType.includes("application/json"))) {
157
+ errorMessage = `Error ${response.status} - ${response.statusText}`;
158
+ }
159
+
160
+ 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);
161
+ throw new FronteggApiError(errorMessage, response.status);
162
+ };
163
+
136
164
  const sendRequest = async opts => {
137
165
  var _opts$method, _ref, _opts$credentials;
138
166
 
@@ -152,27 +180,7 @@ const sendRequest = async opts => {
152
180
  }
153
181
 
154
182
  if (!response.ok) {
155
- var _context$logLevel, _context$logLevel2;
156
-
157
- if (response.status === 413) {
158
- throw new FronteggApiError('Error request is too large', response.status);
159
- }
160
-
161
- let errorMessage;
162
-
163
- try {
164
- errorMessage = await response.text();
165
- errorMessage = JSON.parse(errorMessage);
166
- } catch (e) {}
167
-
168
- if (errorMessage.errors) {
169
- errorMessage = errorMessage.errors.join(', ');
170
- } else if (typeof errorMessage !== 'string') {
171
- errorMessage = `Error ${response.status} - ${response.statusText}`;
172
- }
173
-
174
- 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);
175
- throw new FronteggApiError(errorMessage, response.status);
183
+ handleError(response, context);
176
184
  }
177
185
 
178
186
  if (!opts.responseType || opts.responseType === 'json') {
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v3.0.110
1
+ /** @license Frontegg v3.0.112
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/interfaces.d.ts CHANGED
@@ -90,3 +90,7 @@ export interface RedirectOptions {
90
90
  export interface UserJwtOptions {
91
91
  jwt?: string;
92
92
  }
93
+ export declare enum PaginationOrderEnum {
94
+ ASC = "ASC",
95
+ DESC = "DESC"
96
+ }
package/interfaces.js CHANGED
@@ -22,4 +22,11 @@ export let FronteggFrameworks;
22
22
  FronteggFrameworks["Ios"] = "ios";
23
23
  FronteggFrameworks["Android"] = "android";
24
24
  FronteggFrameworks["Vanillajs"] = "vanillajs";
25
- })(FronteggFrameworks || (FronteggFrameworks = {}));
25
+ })(FronteggFrameworks || (FronteggFrameworks = {}));
26
+
27
+ export let PaginationOrderEnum;
28
+
29
+ (function (PaginationOrderEnum) {
30
+ PaginationOrderEnum["ASC"] = "ASC";
31
+ PaginationOrderEnum["DESC"] = "DESC";
32
+ })(PaginationOrderEnum || (PaginationOrderEnum = {}));
package/node/constants.js CHANGED
@@ -132,7 +132,8 @@ const urls = {
132
132
  },
133
133
  parents: {
134
134
  v1: '/tenants/resources/hierarchy/v1/parents'
135
- }
135
+ },
136
+ v2: '/tenants/resources/hierarchy/v2'
136
137
  },
137
138
  subTenants: {
138
139
  v1: '/tenants/resources/sub-tenants/v1'
package/node/fetch.js CHANGED
@@ -149,6 +149,34 @@ async function getAdditionalHeaders(context) {
149
149
  return output;
150
150
  }
151
151
 
152
+ const handleError = async (response, context) => {
153
+ var _errorMessage, _context$logLevel, _context$logLevel2;
154
+
155
+ if (response.status === 413) {
156
+ throw new _error.FronteggApiError('Error request is too large', response.status);
157
+ }
158
+
159
+ let errorMessage;
160
+
161
+ try {
162
+ errorMessage = await response.text();
163
+ errorMessage = JSON.parse(errorMessage);
164
+ } catch (e) {
165
+ errorMessage = undefined;
166
+ }
167
+
168
+ const contentType = response.headers.get("content-type");
169
+
170
+ if ((_errorMessage = errorMessage) != null && _errorMessage.errors) {
171
+ errorMessage = errorMessage.errors.join(', ');
172
+ } else if (typeof errorMessage !== 'string' || !(contentType != null && contentType.includes("application/json"))) {
173
+ errorMessage = `Error ${response.status} - ${response.statusText}`;
174
+ }
175
+
176
+ 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);
177
+ throw new _error.FronteggApiError(errorMessage, response.status);
178
+ };
179
+
152
180
  const sendRequest = async opts => {
153
181
  var _opts$method, _ref, _opts$credentials;
154
182
 
@@ -169,27 +197,7 @@ const sendRequest = async opts => {
169
197
  }
170
198
 
171
199
  if (!response.ok) {
172
- var _context$logLevel, _context$logLevel2;
173
-
174
- if (response.status === 413) {
175
- throw new _error.FronteggApiError('Error request is too large', response.status);
176
- }
177
-
178
- let errorMessage;
179
-
180
- try {
181
- errorMessage = await response.text();
182
- errorMessage = JSON.parse(errorMessage);
183
- } catch (e) {}
184
-
185
- if (errorMessage.errors) {
186
- errorMessage = errorMessage.errors.join(', ');
187
- } else if (typeof errorMessage !== 'string') {
188
- errorMessage = `Error ${response.status} - ${response.statusText}`;
189
- }
190
-
191
- 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);
192
- throw new _error.FronteggApiError(errorMessage, response.status);
200
+ handleError(response, context);
193
201
  }
194
202
 
195
203
  if (!opts.responseType || opts.responseType === 'json') {
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v3.0.110
1
+ /** @license Frontegg v3.0.112
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.fronteggHeaders = exports.RequestSource = exports.FronteggFrameworks = void 0;
6
+ exports.fronteggHeaders = exports.RequestSource = exports.PaginationOrderEnum = exports.FronteggFrameworks = void 0;
7
7
  const fronteggHeaders = {
8
8
  frameWork: 'x-frontegg-framework',
9
9
  fronteggSdkVersion: 'x-frontegg-sdk',
@@ -31,4 +31,12 @@ exports.FronteggFrameworks = FronteggFrameworks;
31
31
  FronteggFrameworks["Ios"] = "ios";
32
32
  FronteggFrameworks["Android"] = "android";
33
33
  FronteggFrameworks["Vanillajs"] = "vanillajs";
34
- })(FronteggFrameworks || (exports.FronteggFrameworks = FronteggFrameworks = {}));
34
+ })(FronteggFrameworks || (exports.FronteggFrameworks = FronteggFrameworks = {}));
35
+
36
+ let PaginationOrderEnum;
37
+ exports.PaginationOrderEnum = PaginationOrderEnum;
38
+
39
+ (function (PaginationOrderEnum) {
40
+ PaginationOrderEnum["ASC"] = "ASC";
41
+ PaginationOrderEnum["DESC"] = "DESC";
42
+ })(PaginationOrderEnum || (exports.PaginationOrderEnum = PaginationOrderEnum = {}));
@@ -13,6 +13,7 @@ exports.removeUserFromTenantAndSubTenants = removeUserFromTenantAndSubTenants;
13
13
  exports.removeUserRolesFromSubTenants = removeUserRolesFromSubTenants;
14
14
  exports.setUserRolesForSubTenants = setUserRolesForSubTenants;
15
15
  exports.updateSubAccountAccess = updateSubAccountAccess;
16
+ exports.updateSubTenant = updateSubTenant;
16
17
 
17
18
  var _fetch = require("../fetch");
18
19
 
@@ -62,6 +63,14 @@ async function deleteSubTenant(tenantId, options) {
62
63
  });
63
64
  }
64
65
 
66
+ async function updateSubTenant({
67
+ tenantId
68
+ }, body, options) {
69
+ return (0, _fetch.Patch)(`${_constants.urls.tenants.subTenants.v1}/${tenantId}`, body, {
70
+ headers: (0, _fetch.extractHeadersFromOptions)(options)
71
+ });
72
+ }
73
+
65
74
  async function updateSubAccountAccess(userId, body, options) {
66
75
  return (0, _fetch.Put)(`${_constants.urls.identity.subTenants.v1}/${userId}/access`, body, {
67
76
  headers: (0, _fetch.extractHeadersFromOptions)(options)
@@ -8,6 +8,7 @@ exports.getSubTenants = getSubTenants;
8
8
  exports.getSubTenantsAsTree = getSubTenantsAsTree;
9
9
  exports.getTenants = getTenants;
10
10
  exports.getTenantsUsersCount = getTenantsUsersCount;
11
+ exports.searchSubTenants = searchSubTenants;
11
12
  exports.switchTenant = switchTenant;
12
13
 
13
14
  var _fetch = require("../fetch");
@@ -44,4 +45,10 @@ async function getTenantsUsersCount(body, options) {
44
45
  return (0, _fetch.Post)(`${_constants.urls.identity.tenants.users.v1}/count`, body, {
45
46
  headers: (0, _fetch.extractHeadersFromOptions)(options)
46
47
  });
48
+ }
49
+
50
+ async function searchSubTenants(params, options) {
51
+ return (0, _fetch.Get)(_constants.urls.tenants.hierarchy.v2, params, {
52
+ headers: (0, _fetch.extractHeadersFromOptions)(options)
53
+ });
47
54
  }
@@ -3,7 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TenantType = void 0;
6
+ exports.TenantType = exports.TenantSortByEnum = void 0;
7
+ let TenantSortByEnum;
8
+ exports.TenantSortByEnum = TenantSortByEnum;
9
+
10
+ (function (TenantSortByEnum) {
11
+ TenantSortByEnum["createdAt"] = "createdAt";
12
+ TenantSortByEnum["name"] = "name";
13
+ TenantSortByEnum["tenantId"] = "tenantId";
14
+ })(TenantSortByEnum || (exports.TenantSortByEnum = TenantSortByEnum = {}));
15
+
7
16
  let TenantType;
8
17
  exports.TenantType = TenantType;
9
18
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SortByEnum = exports.PaginationOrderEnum = void 0;
6
+ exports.SortByEnum = void 0;
7
7
  let SortByEnum;
8
8
  exports.SortByEnum = SortByEnum;
9
9
 
@@ -16,12 +16,4 @@ exports.SortByEnum = SortByEnum;
16
16
  SortByEnum["isLocked"] = "isLocked";
17
17
  SortByEnum["provider"] = "provider";
18
18
  SortByEnum["tenantId"] = "tenantId";
19
- })(SortByEnum || (exports.SortByEnum = SortByEnum = {}));
20
-
21
- let PaginationOrderEnum;
22
- exports.PaginationOrderEnum = PaginationOrderEnum;
23
-
24
- (function (PaginationOrderEnum) {
25
- PaginationOrderEnum["ASC"] = "ASC";
26
- PaginationOrderEnum["DESC"] = "DESC";
27
- })(PaginationOrderEnum || (exports.PaginationOrderEnum = PaginationOrderEnum = {}));
19
+ })(SortByEnum || (exports.SortByEnum = SortByEnum = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontegg/rest-api",
3
- "version": "3.0.110",
3
+ "version": "3.0.112",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -1,5 +1,5 @@
1
1
  import { PaginationResult, UserJwtOptions } from "../interfaces";
2
- import { AddUsersToSubTenantRequest, AddUserToSubTenantsRequest, CreateSubTenantRequest, CreateSubTenantResponse, ILoadAllUsers, ISubTenantUser, RemoveUserFromSubTenantsRequest, UpdateSubAccountAccessRequestDto, UpdateUserRolesForSubTenantsRequestDto } from "./interfaces";
2
+ import { AddUsersToSubTenantRequest, AddUserToSubTenantsRequest, CreateSubTenantRequest, CreateSubTenantResponse, ILoadAllUsers, ISubTenantUser, RemoveUserFromSubTenantsRequest, UpdateSubAccountAccessRequestDto, UpdateSubTenantRequest, UpdateSubTenantRequestParams, UpdateUserRolesForSubTenantsRequestDto } from "./interfaces";
3
3
  export declare function loadAllUsers(params: ILoadAllUsers): Promise<PaginationResult<ISubTenantUser>>;
4
4
  export declare function addUserToTenantAndSubTenants(body: AddUserToSubTenantsRequest): Promise<void>;
5
5
  export declare function removeUserFromTenantAndSubTenants(body: RemoveUserFromSubTenantsRequest, options?: UserJwtOptions): Promise<void>;
@@ -8,5 +8,6 @@ export declare function removeUserRolesFromSubTenants(userId: string, body: Upda
8
8
  export declare function setUserRolesForSubTenants(userId: string, body: UpdateUserRolesForSubTenantsRequestDto, options?: UserJwtOptions): Promise<void>;
9
9
  export declare function createSubTenant(body: CreateSubTenantRequest, options?: UserJwtOptions): Promise<CreateSubTenantResponse>;
10
10
  export declare function deleteSubTenant(tenantId: string, options?: UserJwtOptions): Promise<void>;
11
+ export declare function updateSubTenant({ tenantId }: UpdateSubTenantRequestParams, body: UpdateSubTenantRequest, options?: UserJwtOptions): Promise<void>;
11
12
  export declare function updateSubAccountAccess(userId: string, body: UpdateSubAccountAccessRequestDto, options?: UserJwtOptions): Promise<void>;
12
13
  export declare function addUsersToSubTenant(body: AddUsersToSubTenantRequest, options?: UserJwtOptions): Promise<void>;
@@ -36,6 +36,13 @@ export async function deleteSubTenant(tenantId, options) {
36
36
  headers: extractHeadersFromOptions(options)
37
37
  });
38
38
  }
39
+ export async function updateSubTenant({
40
+ tenantId
41
+ }, body, options) {
42
+ return Patch(`${urls.tenants.subTenants.v1}/${tenantId}`, body, {
43
+ headers: extractHeadersFromOptions(options)
44
+ });
45
+ }
39
46
  export async function updateSubAccountAccess(userId, body, options) {
40
47
  return Put(`${urls.identity.subTenants.v1}/${userId}/access`, body, {
41
48
  headers: extractHeadersFromOptions(options)
@@ -127,3 +127,9 @@ export interface AddUsersToSubTenantRequest {
127
127
  roleIds?: string[];
128
128
  allowSubAccountAccess?: boolean;
129
129
  }
130
+ export interface UpdateSubTenantRequestParams {
131
+ tenantId: string;
132
+ }
133
+ export interface UpdateSubTenantRequest {
134
+ name: string;
135
+ }
@@ -1,5 +1,5 @@
1
- import { IGetTenantsUserCountRequest, IGetTenantsUserCountResponse, IParentTenant, ISubTenant, ISubTenantTree, ISwitchTenant, ITenantsResponse } from "./interfaces";
2
- import { UserJwtOptions } from "../interfaces";
1
+ import { IGetTenantsUserCountRequest, IGetTenantsUserCountResponse, IParentTenant, ISubTenant, ISubTenantTree, ISwitchTenant, ITenantsResponse, SearchSubTenantsParams, SearchSubTenantsResponse } from "./interfaces";
2
+ import { FronteggPaginationWrapper, UserJwtOptions } from "../interfaces";
3
3
  /**
4
4
  * switch logged in user to specific tenant by providing tenantId.
5
5
  *
@@ -32,3 +32,4 @@ export declare function getSubTenantsAsTree(options?: UserJwtOptions): Promise<I
32
32
  */
33
33
  export declare function getParentTenants(options?: UserJwtOptions): Promise<IParentTenant[]>;
34
34
  export declare function getTenantsUsersCount(body: IGetTenantsUserCountRequest, options?: UserJwtOptions): Promise<IGetTenantsUserCountResponse[]>;
35
+ export declare function searchSubTenants(params: SearchSubTenantsParams, options?: UserJwtOptions): Promise<FronteggPaginationWrapper<SearchSubTenantsResponse>>;
package/tenants/index.js CHANGED
@@ -25,4 +25,9 @@ export async function getTenantsUsersCount(body, options) {
25
25
  return Post(`${urls.identity.tenants.users.v1}/count`, body, {
26
26
  headers: extractHeadersFromOptions(options)
27
27
  });
28
+ }
29
+ export async function searchSubTenants(params, options) {
30
+ return Get(urls.tenants.hierarchy.v2, params, {
31
+ headers: extractHeadersFromOptions(options)
32
+ });
28
33
  }
@@ -1,3 +1,9 @@
1
+ import { PaginationOrderEnum } from '../interfaces';
2
+ export declare enum TenantSortByEnum {
3
+ createdAt = "createdAt",
4
+ name = "name",
5
+ tenantId = "tenantId"
6
+ }
1
7
  export interface ISwitchTenant {
2
8
  tenantId: string;
3
9
  }
@@ -79,3 +85,16 @@ export interface IGetTenantsUserCountResponse {
79
85
  totalUsers: number;
80
86
  totalAccessAllowedUsers: number;
81
87
  }
88
+ export interface SearchSubTenantsParams {
89
+ _limit?: number;
90
+ _offset?: number;
91
+ _filter?: string;
92
+ _subTenantId?: string;
93
+ _sortBy?: TenantSortByEnum;
94
+ _order?: PaginationOrderEnum;
95
+ }
96
+ export interface SearchSubTenantsResponse {
97
+ tenantId: string;
98
+ name: string;
99
+ createdAt: Date;
100
+ }
@@ -1,3 +1,11 @@
1
+ export let TenantSortByEnum;
2
+
3
+ (function (TenantSortByEnum) {
4
+ TenantSortByEnum["createdAt"] = "createdAt";
5
+ TenantSortByEnum["name"] = "name";
6
+ TenantSortByEnum["tenantId"] = "tenantId";
7
+ })(TenantSortByEnum || (TenantSortByEnum = {}));
8
+
1
9
  export let TenantType;
2
10
 
3
11
  (function (TenantType) {
@@ -1,3 +1,4 @@
1
+ import { PaginationOrderEnum } from '../interfaces';
1
2
  export declare enum SortByEnum {
2
3
  createdAt = "createdAt",
3
4
  name = "name",
@@ -8,10 +9,6 @@ export declare enum SortByEnum {
8
9
  provider = "provider",
9
10
  tenantId = "tenantId"
10
11
  }
11
- export declare enum PaginationOrderEnum {
12
- ASC = "ASC",
13
- DESC = "DESC"
14
- }
15
12
  export interface GetUserJwtRequestDto {
16
13
  tenantId: string;
17
14
  }
@@ -9,11 +9,4 @@ export let SortByEnum;
9
9
  SortByEnum["isLocked"] = "isLocked";
10
10
  SortByEnum["provider"] = "provider";
11
11
  SortByEnum["tenantId"] = "tenantId";
12
- })(SortByEnum || (SortByEnum = {}));
13
-
14
- export let PaginationOrderEnum;
15
-
16
- (function (PaginationOrderEnum) {
17
- PaginationOrderEnum["ASC"] = "ASC";
18
- PaginationOrderEnum["DESC"] = "DESC";
19
- })(PaginationOrderEnum || (PaginationOrderEnum = {}));
12
+ })(SortByEnum || (SortByEnum = {}));