@openfeature/flagd-provider 0.5.1 → 0.6.0
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.
- package/index.cjs +1 -1
- package/index.js +2 -2
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -4801,7 +4801,7 @@ class ResolveObjectResponse$Type extends MessageType{constructor(){super("schema
|
|
|
4801
4801
|
*/resolveObject(a,b){const c=this.methods[4],d=this._transport.mergeOptions(b);return stackIntercept("unary",this._transport,c,d,a)}}
|
|
4802
4802
|
|
|
4803
4803
|
const Codes={InvalidArgument:"INVALID_ARGUMENT",NotFound:"NOT_FOUND",DataLoss:"DATA_LOSS",Unavailable:"UNAVAILABLE"};class GRPCService{constructor(a,b){this.onFulfilled=a=>a,this.onRejected=a=>{// map the errors
|
|
4804
|
-
switch(null===a||void 0===a?void 0:a.code){case Codes.DataLoss:throw new jsSdk.ParseError(a.message);case Codes.InvalidArgument:throw new jsSdk.TypeMismatchError(a.message);case Codes.NotFound:throw new jsSdk.FlagNotFoundError(a.message);case Codes.Unavailable:throw new jsSdk.FlagNotFoundError(a.message);default:throw a;}};const{host:c,port:d,tls:e,socketPath:f}=a;this.client=b?b:new ServiceClient(new grpcTransport.GrpcTransport({host:f?`unix://${f}`:`${c}:${d}`,channelCredentials:e?grpc__namespace.credentials.createSsl():grpc__namespace.credentials.createInsecure()}));}resolveBoolean(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveBoolean({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);return {value:d.value,reason:d.reason,variant:d.variant}})}resolveString(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveString({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);return {value:d.value,reason:d.reason,variant:d.variant}})}resolveNumber(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveFloat({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);return {value:d.value,reason:d.reason,variant:d.variant}})}resolveObject(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveObject({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);if(d.value!==void 0)return {value:Struct.toJson(d.value),reason:d.reason,variant:d.variant};throw new jsSdk.ParseError("Object value undefined or missing.")})}convertContext(a,b){try{// stringify to remove invalid js props
|
|
4804
|
+
switch(null===a||void 0===a?void 0:a.code){case Codes.DataLoss:throw new jsSdk.ParseError(a.message);case Codes.InvalidArgument:throw new jsSdk.TypeMismatchError(a.message);case Codes.NotFound:throw new jsSdk.FlagNotFoundError(a.message);case Codes.Unavailable:throw new jsSdk.FlagNotFoundError(a.message);default:throw new jsSdk.GeneralError(a.message);}};const{host:c,port:d,tls:e,socketPath:f}=a;this.client=b?b:new ServiceClient(new grpcTransport.GrpcTransport({host:f?`unix://${f}`:`${c}:${d}`,channelCredentials:e?grpc__namespace.credentials.createSsl():grpc__namespace.credentials.createInsecure()}));}resolveBoolean(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveBoolean({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);return {value:d.value,reason:d.reason,variant:d.variant}})}resolveString(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveString({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);return {value:d.value,reason:d.reason,variant:d.variant}})}resolveNumber(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveFloat({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);return {value:d.value,reason:d.reason,variant:d.variant}})}resolveObject(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveObject({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);if(d.value!==void 0)return {value:Struct.toJson(d.value),reason:d.reason,variant:d.variant};throw new jsSdk.ParseError("Object value undefined or missing.")})}convertContext(a,b){try{// stringify to remove invalid js props
|
|
4805
4805
|
return Struct.fromJsonString(JSON.stringify(a))}catch(a){const c=a;throw b.error(`${"Error serializing context."}: ${null===c||void 0===c?void 0:c.message}`),b.error(null===c||void 0===c?void 0:c.stack),new jsSdk.ParseError("Error serializing context.")}}}
|
|
4806
4806
|
|
|
4807
4807
|
class FlagdProvider{constructor(a,b){this.metadata={name:"flagd Provider"},this.logRejected=(a,b,c)=>{throw c.error(`Error resolving flag ${b}: ${null===a||void 0===a?void 0:a.message}`),c.error(null===a||void 0===a?void 0:a.stack),a},this._service=b?b:new GRPCService(getConfig(a));}resolveBooleanEvaluation(a,b,c,d){return this._service.resolveBoolean(a,c,d).catch(b=>this.logRejected(b,a,d))}resolveStringEvaluation(a,b,c,d){return this._service.resolveString(a,c,d).catch(b=>this.logRejected(b,a,d))}resolveNumberEvaluation(a,b,c,d){return this._service.resolveNumber(a,c,d).catch(b=>this.logRejected(b,a,d))}resolveObjectEvaluation(a,b,c,d){return this._service.resolveObject(a,c,d).catch(b=>this.logRejected(b,a,d))}}
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as grpc from '@grpc/grpc-js';
|
|
2
|
-
import { FlagNotFoundError, TypeMismatchError, ParseError } from '@openfeature/js-sdk';
|
|
2
|
+
import { GeneralError, FlagNotFoundError, TypeMismatchError, ParseError } from '@openfeature/js-sdk';
|
|
3
3
|
import { GrpcTransport } from '@protobuf-ts/grpc-transport';
|
|
4
4
|
|
|
5
5
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -4777,7 +4777,7 @@ class ResolveObjectResponse$Type extends MessageType{constructor(){super("schema
|
|
|
4777
4777
|
*/resolveObject(a,b){const c=this.methods[4],d=this._transport.mergeOptions(b);return stackIntercept("unary",this._transport,c,d,a)}}
|
|
4778
4778
|
|
|
4779
4779
|
const Codes={InvalidArgument:"INVALID_ARGUMENT",NotFound:"NOT_FOUND",DataLoss:"DATA_LOSS",Unavailable:"UNAVAILABLE"};class GRPCService{constructor(a,b){this.onFulfilled=a=>a,this.onRejected=a=>{// map the errors
|
|
4780
|
-
switch(null===a||void 0===a?void 0:a.code){case Codes.DataLoss:throw new ParseError(a.message);case Codes.InvalidArgument:throw new TypeMismatchError(a.message);case Codes.NotFound:throw new FlagNotFoundError(a.message);case Codes.Unavailable:throw new FlagNotFoundError(a.message);default:throw a;}};const{host:c,port:d,tls:e,socketPath:f}=a;this.client=b?b:new ServiceClient(new GrpcTransport({host:f?`unix://${f}`:`${c}:${d}`,channelCredentials:e?grpc.credentials.createSsl():grpc.credentials.createInsecure()}));}resolveBoolean(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveBoolean({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);return {value:d.value,reason:d.reason,variant:d.variant}})}resolveString(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveString({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);return {value:d.value,reason:d.reason,variant:d.variant}})}resolveNumber(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveFloat({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);return {value:d.value,reason:d.reason,variant:d.variant}})}resolveObject(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveObject({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);if(d.value!==void 0)return {value:Struct.toJson(d.value),reason:d.reason,variant:d.variant};throw new ParseError("Object value undefined or missing.")})}convertContext(a,b){try{// stringify to remove invalid js props
|
|
4780
|
+
switch(null===a||void 0===a?void 0:a.code){case Codes.DataLoss:throw new ParseError(a.message);case Codes.InvalidArgument:throw new TypeMismatchError(a.message);case Codes.NotFound:throw new FlagNotFoundError(a.message);case Codes.Unavailable:throw new FlagNotFoundError(a.message);default:throw new GeneralError(a.message);}};const{host:c,port:d,tls:e,socketPath:f}=a;this.client=b?b:new ServiceClient(new GrpcTransport({host:f?`unix://${f}`:`${c}:${d}`,channelCredentials:e?grpc.credentials.createSsl():grpc.credentials.createInsecure()}));}resolveBoolean(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveBoolean({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);return {value:d.value,reason:d.reason,variant:d.variant}})}resolveString(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveString({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);return {value:d.value,reason:d.reason,variant:d.variant}})}resolveNumber(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveFloat({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);return {value:d.value,reason:d.reason,variant:d.variant}})}resolveObject(a,b,c){return __awaiter(this,void 0,void 0,function*(){const{response:d}=yield this.client.resolveObject({flagKey:a,context:this.convertContext(b,c)}).then(this.onFulfilled,this.onRejected);if(d.value!==void 0)return {value:Struct.toJson(d.value),reason:d.reason,variant:d.variant};throw new ParseError("Object value undefined or missing.")})}convertContext(a,b){try{// stringify to remove invalid js props
|
|
4781
4781
|
return Struct.fromJsonString(JSON.stringify(a))}catch(a){const c=a;throw b.error(`${"Error serializing context."}: ${null===c||void 0===c?void 0:c.message}`),b.error(null===c||void 0===c?void 0:c.stack),new ParseError("Error serializing context.")}}}
|
|
4782
4782
|
|
|
4783
4783
|
class FlagdProvider{constructor(a,b){this.metadata={name:"flagd Provider"},this.logRejected=(a,b,c)=>{throw c.error(`Error resolving flag ${b}: ${null===a||void 0===a?void 0:a.message}`),c.error(null===a||void 0===a?void 0:a.stack),a},this._service=b?b:new GRPCService(getConfig(a));}resolveBooleanEvaluation(a,b,c,d){return this._service.resolveBoolean(a,c,d).catch(b=>this.logRejected(b,a,d))}resolveStringEvaluation(a,b,c,d){return this._service.resolveString(a,c,d).catch(b=>this.logRejected(b,a,d))}resolveNumberEvaluation(a,b,c,d){return this._service.resolveNumber(a,c,d).catch(b=>this.logRejected(b,a,d))}resolveObjectEvaluation(a,b,c,d){return this._service.resolveObject(a,c,d).catch(b=>this.logRejected(b,a,d))}}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfeature/flagd-provider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"publish-if-not-exists": "cp $NPM_CONFIG_USERCONFIG .npmrc && if [ \"$(npm show $npm_package_name@$npm_package_version version)\" = \"$(npm run current-version -s)\" ]; then echo 'already published, skipping'; else npm publish --access public; fi",
|
|
7
7
|
"current-version": "echo $npm_package_version"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"@openfeature/js-sdk": "
|
|
10
|
+
"@openfeature/js-sdk": "~0.5.0"
|
|
11
11
|
},
|
|
12
12
|
"module": "./index.js",
|
|
13
13
|
"main": "./index.cjs",
|