@unrevealed/node
Advanced tools
Comparing version 0.3.4 to 0.3.5
@@ -16,2 +16,5 @@ export interface UserTraits { | ||
export type FeatureKey = keyof Features extends never ? string : keyof Features; | ||
export interface Stages { | ||
} | ||
export type StageKey = keyof Stages extends never ? string : keyof Stages; | ||
export interface FeatureAccess { | ||
@@ -18,0 +21,0 @@ fullAccess: boolean; |
import { UnrevealedLogger } from './Logger'; | ||
import { FeatureAccess, FeatureAccessUpdate, FeatureKey, Team, User } from './types'; | ||
import { FeatureAccess, FeatureAccessUpdate, FeatureKey, StageKey, Team, User } from './types'; | ||
export type ReadyState = 'UNINITIALIZED' | 'CONNECTING' | 'READY' | 'CLOSED'; | ||
@@ -37,2 +37,3 @@ export interface UnrevealedClientOptions { | ||
updateFeatureAccess(featureKey: FeatureKey, access: FeatureAccessUpdate): Promise<FeatureAccess>; | ||
updateFeatureStage(featureKey: FeatureKey, access: StageKey): Promise<FeatureAccess>; | ||
private _normalizeKey; | ||
@@ -39,0 +40,0 @@ private _track; |
@@ -152,2 +152,27 @@ "use strict"; | ||
} | ||
updateFeatureStage(featureKey, access) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const fetch = (0, fetch_1.getFetch)(); | ||
try { | ||
const response = yield fetch(`${this._apiUrl}/api/update-feature-access`, { | ||
method: 'post', | ||
headers: { | ||
Authorization: `Bearer ${this._apiKey}`, | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ key: featureKey, access }), | ||
}); | ||
const featureAccess = yield response.json(); | ||
this._featureAccesses.set(featureKey, featureAccess); | ||
return featureAccess; | ||
} | ||
catch (err) { | ||
let message = 'Error updating feature access'; | ||
if (err instanceof Error) { | ||
message = `${message}: ${err.message}`; | ||
} | ||
throw new Error(message); | ||
} | ||
}); | ||
} | ||
_normalizeKey(key) { | ||
@@ -154,0 +179,0 @@ const hash = crypto_1.default.createHash('sha1'); |
{ | ||
"name": "@unrevealed/node", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "Unrevealed SDK for Node", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
28412
492
3