@frontegg/rest-api 3.0.82 → 3.0.84

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,2 +1,11 @@
1
- import { IFeatureFlagsAttributes } from "./interfaces";
1
+ import { FronteggFeatureFlags, IFeatureFlagsAttributes } from "./interfaces";
2
+ export declare class FeatureFlags {
3
+ private _flags;
4
+ private static _instances;
5
+ static getInstance(name?: string): any;
6
+ static set(featureFlags?: FronteggFeatureFlags, name?: string): FeatureFlags;
7
+ static getFeatureFlags(flags: string[]): boolean[];
8
+ get flags(): Required<FronteggFeatureFlags>["flags"];
9
+ set(featureFlags?: FronteggFeatureFlags): void;
10
+ }
2
11
  export declare function loadFeatureFlags(): Promise<IFeatureFlagsAttributes>;
@@ -1,5 +1,44 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import { urls } from "../constants";
2
3
  import { Get } from "../fetch";
4
+ const defaultFeatureFlags = {
5
+ flags: {}
6
+ };
7
+ export class FeatureFlags {
8
+ constructor() {
9
+ this._flags = defaultFeatureFlags.flags;
10
+ }
11
+
12
+ static getInstance(name = "default") {
13
+ return this._instances[name];
14
+ }
15
+
16
+ static set(featureFlags, name = "default") {
17
+ const featureFlagsInstance = new FeatureFlags();
18
+ featureFlagsInstance.set(featureFlags);
19
+ FeatureFlags._instances[name] = featureFlagsInstance;
20
+ return featureFlagsInstance;
21
+ }
22
+
23
+ static getFeatureFlags(flags) {
24
+ const featureFlagsInstance = this.getInstance();
25
+ return flags.map(flag => (featureFlagsInstance == null ? void 0 : featureFlagsInstance._flags[flag]) === "on");
26
+ }
27
+
28
+ get flags() {
29
+ var _this$flags;
30
+
31
+ return (_this$flags = this.flags) != null ? _this$flags : {};
32
+ }
33
+
34
+ set(featureFlags) {
35
+ var _defaultFeatureFlags$, _featureFlags$flags;
36
+
37
+ this._flags = _extends({}, (_defaultFeatureFlags$ = defaultFeatureFlags == null ? void 0 : defaultFeatureFlags.flags) != null ? _defaultFeatureFlags$ : {}, (_featureFlags$flags = featureFlags == null ? void 0 : featureFlags.flags) != null ? _featureFlags$flags : {});
38
+ }
39
+
40
+ }
41
+ FeatureFlags._instances = {};
3
42
  export async function loadFeatureFlags() {
4
43
  return Get(urls.featureFlags.v1);
5
44
  }
@@ -1,2 +1,5 @@
1
1
  export declare type IFeatureFlagsAttribute = 'on' | 'off';
2
2
  export declare type IFeatureFlagsAttributes = Record<string, IFeatureFlagsAttribute>;
3
+ export declare type FronteggFeatureFlags = {
4
+ flags?: IFeatureFlagsAttributes;
5
+ };
package/groups/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { ICreateGroup, ICreateGroupResponse, IGetGroup, IGetGroupQueryOptions, I
2
2
  /**
3
3
  * Get group by given id
4
4
  */
5
- export declare function getGroupById({ groupId, }: IGetGroup, query?: IGetGroupQueryOptions): Promise<IGroupResponse>;
5
+ export declare function getGroupById({ groupId }: IGetGroup, query?: IGetGroupQueryOptions): Promise<IGroupResponse>;
6
6
  /**
7
7
  * Get all tenant groups
8
8
  */
package/groups/index.js CHANGED
@@ -26,16 +26,16 @@ export async function deleteGroup(groupId) {
26
26
  return Delete(`${urls.identity.groups.v1}/${groupId}`);
27
27
  }
28
28
  export async function addRolesToGroup(groupId, body) {
29
- return Post(`${urls.identity.groups.v1}/${groupId}/${urls.identity.groups.roles}`, body);
29
+ return Post(`${urls.identity.groups.v1}/${groupId}${urls.identity.groups.roles}`, body);
30
30
  }
31
31
  export async function deleteRolesFromGroup(groupId, body) {
32
- return Delete(`${urls.identity.groups.v1}/${groupId}/${urls.identity.groups.roles}`, body);
32
+ return Delete(`${urls.identity.groups.v1}/${groupId}${urls.identity.groups.roles}`, body);
33
33
  }
34
34
  export async function addUsersToGroup(groupId, body) {
35
- return Post(`${urls.identity.groups.v1}/${groupId}/${urls.identity.groups.users}`, body);
35
+ return Post(`${urls.identity.groups.v1}/${groupId}${urls.identity.groups.users}`, body);
36
36
  }
37
37
  export async function deleteUsersFromGroup(groupId, body) {
38
- return Delete(`${urls.identity.groups.v1}/${groupId}/${urls.identity.groups.users}`, body);
38
+ return Delete(`${urls.identity.groups.v1}/${groupId}${urls.identity.groups.users}`, body);
39
39
  }
40
40
  export async function getGroupConfiguration() {
41
41
  return Get(`${urls.identity.groups.configurations.v1}`);
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v3.0.82
1
+ /** @license Frontegg v3.0.84
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.
@@ -1,14 +1,61 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
8
+ exports.FeatureFlags = void 0;
6
9
  exports.loadFeatureFlags = loadFeatureFlags;
7
10
 
11
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
+
8
13
  var _constants = require("../constants");
9
14
 
10
15
  var _fetch = require("../fetch");
11
16
 
17
+ const defaultFeatureFlags = {
18
+ flags: {}
19
+ };
20
+
21
+ class FeatureFlags {
22
+ constructor() {
23
+ this._flags = defaultFeatureFlags.flags;
24
+ }
25
+
26
+ static getInstance(name = "default") {
27
+ return this._instances[name];
28
+ }
29
+
30
+ static set(featureFlags, name = "default") {
31
+ const featureFlagsInstance = new FeatureFlags();
32
+ featureFlagsInstance.set(featureFlags);
33
+ FeatureFlags._instances[name] = featureFlagsInstance;
34
+ return featureFlagsInstance;
35
+ }
36
+
37
+ static getFeatureFlags(flags) {
38
+ const featureFlagsInstance = this.getInstance();
39
+ return flags.map(flag => (featureFlagsInstance == null ? void 0 : featureFlagsInstance._flags[flag]) === "on");
40
+ }
41
+
42
+ get flags() {
43
+ var _this$flags;
44
+
45
+ return (_this$flags = this.flags) != null ? _this$flags : {};
46
+ }
47
+
48
+ set(featureFlags) {
49
+ var _defaultFeatureFlags$, _featureFlags$flags;
50
+
51
+ this._flags = (0, _extends2.default)({}, (_defaultFeatureFlags$ = defaultFeatureFlags == null ? void 0 : defaultFeatureFlags.flags) != null ? _defaultFeatureFlags$ : {}, (_featureFlags$flags = featureFlags == null ? void 0 : featureFlags.flags) != null ? _featureFlags$flags : {});
52
+ }
53
+
54
+ }
55
+
56
+ exports.FeatureFlags = FeatureFlags;
57
+ FeatureFlags._instances = {};
58
+
12
59
  async function loadFeatureFlags() {
13
60
  return (0, _fetch.Get)(_constants.urls.featureFlags.v1);
14
61
  }
@@ -54,19 +54,19 @@ async function deleteGroup(groupId) {
54
54
  }
55
55
 
56
56
  async function addRolesToGroup(groupId, body) {
57
- return (0, _fetch.Post)(`${_constants.urls.identity.groups.v1}/${groupId}/${_constants.urls.identity.groups.roles}`, body);
57
+ return (0, _fetch.Post)(`${_constants.urls.identity.groups.v1}/${groupId}${_constants.urls.identity.groups.roles}`, body);
58
58
  }
59
59
 
60
60
  async function deleteRolesFromGroup(groupId, body) {
61
- return (0, _fetch.Delete)(`${_constants.urls.identity.groups.v1}/${groupId}/${_constants.urls.identity.groups.roles}`, body);
61
+ return (0, _fetch.Delete)(`${_constants.urls.identity.groups.v1}/${groupId}${_constants.urls.identity.groups.roles}`, body);
62
62
  }
63
63
 
64
64
  async function addUsersToGroup(groupId, body) {
65
- return (0, _fetch.Post)(`${_constants.urls.identity.groups.v1}/${groupId}/${_constants.urls.identity.groups.users}`, body);
65
+ return (0, _fetch.Post)(`${_constants.urls.identity.groups.v1}/${groupId}${_constants.urls.identity.groups.users}`, body);
66
66
  }
67
67
 
68
68
  async function deleteUsersFromGroup(groupId, body) {
69
- return (0, _fetch.Delete)(`${_constants.urls.identity.groups.v1}/${groupId}/${_constants.urls.identity.groups.users}`, body);
69
+ return (0, _fetch.Delete)(`${_constants.urls.identity.groups.v1}/${groupId}${_constants.urls.identity.groups.users}`, body);
70
70
  }
71
71
 
72
72
  async function getGroupConfiguration() {
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v3.0.82
1
+ /** @license Frontegg v3.0.84
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontegg/rest-api",
3
- "version": "3.0.82",
3
+ "version": "3.0.84",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {