@openfeature/flagd-web-provider
Advanced tools
Comparing version 0.3.3 to 0.3.4
20
index.js
@@ -1,2 +0,3 @@ | ||
import { createConnectTransport, createPromiseClient, createCallbackClient } from '@bufbuild/connect-web'; | ||
import { createPromiseClient, createCallbackClient } from '@bufbuild/connect'; | ||
import { createConnectTransport } from '@bufbuild/connect-web'; | ||
import { proto3, Struct, MethodKind } from '@bufbuild/protobuf'; | ||
@@ -364,2 +365,7 @@ import { OpenFeatureEventEmitter, FlagNotFoundError, TypeMismatchError, StandardResolutionReasons, OpenFeature, ProviderEvents } from '@openfeature/web-sdk'; | ||
} | ||
onClose() { | ||
var _a; | ||
// close the stream using the saved cancel function | ||
return Promise.resolve((_a = this._cancelFunction) === null || _a === void 0 ? void 0 : _a.call(this)); | ||
} | ||
evaluate(flagKey, type) { | ||
@@ -374,2 +380,3 @@ const resolved = this._flags[flagKey]; | ||
return { | ||
// return reason=CACHED if we're disconnected since we can't guarantee things are up to date | ||
reason: this._connected ? resolved.reason : StandardResolutionReasons.CACHED, | ||
@@ -384,3 +391,3 @@ variant: resolved.variant, | ||
return new Promise((resolve) => { | ||
this._callbackClient.eventStream({}, (message) => { | ||
this._cancelFunction = this._callbackClient.eventStream({}, (message) => { | ||
var _a; | ||
@@ -404,5 +411,6 @@ // get the context at the time of the message | ||
} | ||
}, () => { | ||
var _a, _b; | ||
(_a = this._logger) === null || _a === void 0 ? void 0 : _a.error(`${FlagdWebProvider.name}: could not establish connection to flagd`); | ||
}, (err) => { | ||
var _a, _b, _c; | ||
(_a = this._logger) === null || _a === void 0 ? void 0 : _a.error(`${FlagdWebProvider.name}: could not establish connection to flagd, ${err === null || err === void 0 ? void 0 : err.message}`); | ||
(_b = this._logger) === null || _b === void 0 ? void 0 : _b.debug(err === null || err === void 0 ? void 0 : err.stack); | ||
if (this._retry < this._maxRetries) { | ||
@@ -413,3 +421,3 @@ this._retry++; | ||
else { | ||
(_b = this._logger) === null || _b === void 0 ? void 0 : _b.warn(`${FlagdWebProvider.name}: max retries reached`); | ||
(_c = this._logger) === null || _c === void 0 ? void 0 : _c.warn(`${FlagdWebProvider.name}: max retries reached`); | ||
this.events.emit(ProviderEvents.Error); | ||
@@ -416,0 +424,0 @@ } |
{ | ||
"name": "@openfeature/flagd-web-provider", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"type": "module", | ||
@@ -23,5 +23,6 @@ "scripts": { | ||
"dependencies": { | ||
"@bufbuild/connect-web": "0.8.4", | ||
"@bufbuild/connect": "0.8.5", | ||
"@bufbuild/connect-web": "0.8.5", | ||
"@bufbuild/protobuf": "1.2.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { CallbackClient, PromiseClient } from '@bufbuild/connect-web'; | ||
import { CallbackClient, PromiseClient } from '@bufbuild/connect'; | ||
import { EvaluationContext, JsonValue, Logger, OpenFeatureEventEmitter, Provider, ResolutionDetails } from '@openfeature/web-sdk'; | ||
@@ -19,2 +19,3 @@ import { Service } from '../proto/ts/schema/v1/schema_connectweb'; | ||
private _flags; | ||
private _cancelFunction; | ||
constructor(options: FlagdProviderOptions, logger?: Logger, promiseClient?: PromiseClient<typeof Service>, callbackClient?: CallbackClient<typeof Service>); | ||
@@ -28,2 +29,3 @@ events: OpenFeatureEventEmitter; | ||
resolveObjectEvaluation<U extends JsonValue>(flagKey: string, _: U): ResolutionDetails<U>; | ||
onClose(): Promise<void>; | ||
private evaluate; | ||
@@ -30,0 +32,0 @@ private retryConnect; |
Sorry, the diff of this file is not supported yet
56536
1040
4
+ Added@bufbuild/connect@0.8.5
+ Added@bufbuild/connect@0.8.5(transitive)
+ Added@bufbuild/connect-web@0.8.5(transitive)
- Removed@bufbuild/connect@0.8.4(transitive)
- Removed@bufbuild/connect-web@0.8.4(transitive)
Updated@bufbuild/connect-web@0.8.5