@unrevealed/node
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -26,3 +26,3 @@ import { UnrevealedLogger } from './Logger'; | ||
team?: Team; | ||
}): Promise<boolean>; | ||
}): boolean; | ||
getEnabledFeatures({ user, team, }?: { | ||
@@ -43,3 +43,2 @@ user?: User; | ||
private _connect; | ||
private _isFeatureEnabledSync; | ||
private _closeExistingEventSource; | ||
@@ -46,0 +45,0 @@ private _createEventSource; |
@@ -60,6 +60,17 @@ "use strict"; | ||
isFeatureEnabled(featureKey, { user, team } = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this._connectionPromise; | ||
return this._isFeatureEnabledSync(featureKey, { user, team }); | ||
}); | ||
var _a; | ||
const featureAccess = this._featureAccesses.get(featureKey); | ||
if (!featureAccess) { | ||
return (_a = this._defaults.get(featureKey)) !== null && _a !== void 0 ? _a : false; | ||
} | ||
if (featureAccess.fullAccess) { | ||
return true; | ||
} | ||
if (user && featureAccess.userAccess.indexOf(user.id) !== -1) { | ||
return true; | ||
} | ||
if (team && featureAccess.teamAccess.indexOf(team.id) !== -1) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
@@ -69,3 +80,3 @@ getEnabledFeatures({ user, team, } = {}) { | ||
yield this._connectionPromise; | ||
return this._featureKeys.filter((featureKey) => this._isFeatureEnabledSync(featureKey, { user, team })); | ||
return this._featureKeys.filter((featureKey) => this.isFeatureEnabled(featureKey, { user, team })); | ||
}); | ||
@@ -178,19 +189,2 @@ } | ||
} | ||
_isFeatureEnabledSync(featureKey, { user, team } = {}) { | ||
var _a; | ||
const featureAccess = this._featureAccesses.get(featureKey); | ||
if (!featureAccess) { | ||
return (_a = this._defaults.get(featureKey)) !== null && _a !== void 0 ? _a : false; | ||
} | ||
if (featureAccess.fullAccess) { | ||
return true; | ||
} | ||
if (user && featureAccess.userAccess.indexOf(user.id) !== -1) { | ||
return true; | ||
} | ||
if (team && featureAccess.teamAccess.indexOf(team.id) !== -1) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
_closeExistingEventSource() { | ||
@@ -197,0 +191,0 @@ var _a; |
{ | ||
"name": "@unrevealed/node", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Unrevealed SDK for Node", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is not supported yet
16674
345