@spotify-confidence/openfeature-web-provider
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -101,3 +101,3 @@ "use strict"; | ||
try { | ||
const flag = this.configuration.flags[`flags/${flagName}`]; | ||
const flag = this.configuration.flags[flagName]; | ||
if (!flag) { | ||
@@ -111,12 +111,7 @@ logger.warn('Flag "%s" was not found', flagName); | ||
} | ||
if (flag.reason !== client_http_1.Configuration.ResolveReason.Match) { | ||
logger.info('No variant match for flag "%s"', flagName); | ||
return { | ||
errorCode: web_sdk_1.ErrorCode.GENERAL, | ||
value: defaultValue, | ||
reason: flag.reason, | ||
}; | ||
let flagValue; | ||
try { | ||
flagValue = client_http_1.Configuration.FlagValue.traverse(flag, pathParts.join('.')); | ||
} | ||
const flagValue = flag.getValue(...pathParts); | ||
if (flagValue === null) { | ||
catch (e) { | ||
logger.warn('Value with path "%s" was not found in flag "%s"', pathParts.join('.'), flagName); | ||
@@ -129,15 +124,14 @@ return { | ||
} | ||
if (!flagValue.match(defaultValue)) { | ||
logger.warn('Value for "%s" is of incorrect type', flagKey); | ||
if (flagValue.value === null) { | ||
return { | ||
errorCode: web_sdk_1.ErrorCode.TYPE_MISMATCH, | ||
value: defaultValue, | ||
reason: 'ERROR', | ||
reason: mapConfidenceReason(flag.reason), | ||
}; | ||
} | ||
if (flagValue.value === null) { | ||
logger.info('Value for "%s" is default', flagKey); | ||
if (!client_http_1.Configuration.FlagValue.matches(flagValue, defaultValue)) { | ||
logger.warn('Value for "%s" is of incorrect type', flagKey); | ||
return { | ||
errorCode: web_sdk_1.ErrorCode.TYPE_MISMATCH, | ||
value: defaultValue, | ||
reason: flag.reason, | ||
reason: 'ERROR', | ||
}; | ||
@@ -149,3 +143,3 @@ } | ||
value: flagValue.value, | ||
reason: 'TARGETING_MATCH', | ||
reason: mapConfidenceReason(flag.reason), | ||
variant: flag.variant, | ||
@@ -180,2 +174,14 @@ flagMetadata: { | ||
exports.ConfidenceWebProvider = ConfidenceWebProvider; | ||
function mapConfidenceReason(reason) { | ||
switch (reason) { | ||
case client_http_1.Configuration.ResolveReason.Archived: | ||
return 'DISABLED'; | ||
case client_http_1.Configuration.ResolveReason.Unspecified: | ||
return 'UNKNOWN'; | ||
case client_http_1.Configuration.ResolveReason.Match: | ||
return 'TARGETING_MATCH'; | ||
default: | ||
return 'DEFAULT'; | ||
} | ||
} | ||
//# sourceMappingURL=ConfidenceWebProvider.js.map |
@@ -95,3 +95,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
try { | ||
const flag = this.configuration.flags[`flags/${flagName}`]; | ||
const flag = this.configuration.flags[flagName]; | ||
if (!flag) { | ||
@@ -105,12 +105,7 @@ logger.warn('Flag "%s" was not found', flagName); | ||
} | ||
if (flag.reason !== Configuration.ResolveReason.Match) { | ||
logger.info('No variant match for flag "%s"', flagName); | ||
return { | ||
errorCode: ErrorCode.GENERAL, | ||
value: defaultValue, | ||
reason: flag.reason, | ||
}; | ||
let flagValue; | ||
try { | ||
flagValue = Configuration.FlagValue.traverse(flag, pathParts.join('.')); | ||
} | ||
const flagValue = flag.getValue(...pathParts); | ||
if (flagValue === null) { | ||
catch (e) { | ||
logger.warn('Value with path "%s" was not found in flag "%s"', pathParts.join('.'), flagName); | ||
@@ -123,15 +118,14 @@ return { | ||
} | ||
if (!flagValue.match(defaultValue)) { | ||
logger.warn('Value for "%s" is of incorrect type', flagKey); | ||
if (flagValue.value === null) { | ||
return { | ||
errorCode: ErrorCode.TYPE_MISMATCH, | ||
value: defaultValue, | ||
reason: 'ERROR', | ||
reason: mapConfidenceReason(flag.reason), | ||
}; | ||
} | ||
if (flagValue.value === null) { | ||
logger.info('Value for "%s" is default', flagKey); | ||
if (!Configuration.FlagValue.matches(flagValue, defaultValue)) { | ||
logger.warn('Value for "%s" is of incorrect type', flagKey); | ||
return { | ||
errorCode: ErrorCode.TYPE_MISMATCH, | ||
value: defaultValue, | ||
reason: flag.reason, | ||
reason: 'ERROR', | ||
}; | ||
@@ -143,3 +137,3 @@ } | ||
value: flagValue.value, | ||
reason: 'TARGETING_MATCH', | ||
reason: mapConfidenceReason(flag.reason), | ||
variant: flag.variant, | ||
@@ -173,2 +167,14 @@ flagMetadata: { | ||
} | ||
function mapConfidenceReason(reason) { | ||
switch (reason) { | ||
case Configuration.ResolveReason.Archived: | ||
return 'DISABLED'; | ||
case Configuration.ResolveReason.Unspecified: | ||
return 'UNKNOWN'; | ||
case Configuration.ResolveReason.Match: | ||
return 'TARGETING_MATCH'; | ||
default: | ||
return 'DEFAULT'; | ||
} | ||
} | ||
//# sourceMappingURL=ConfidenceWebProvider.js.map |
@@ -95,3 +95,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
try { | ||
const flag = this.configuration.flags[`flags/${flagName}`]; | ||
const flag = this.configuration.flags[flagName]; | ||
if (!flag) { | ||
@@ -105,12 +105,7 @@ logger.warn('Flag "%s" was not found', flagName); | ||
} | ||
if (flag.reason !== Configuration.ResolveReason.Match) { | ||
logger.info('No variant match for flag "%s"', flagName); | ||
return { | ||
errorCode: ErrorCode.GENERAL, | ||
value: defaultValue, | ||
reason: flag.reason, | ||
}; | ||
let flagValue; | ||
try { | ||
flagValue = Configuration.FlagValue.traverse(flag, pathParts.join('.')); | ||
} | ||
const flagValue = flag.getValue(...pathParts); | ||
if (flagValue === null) { | ||
catch (e) { | ||
logger.warn('Value with path "%s" was not found in flag "%s"', pathParts.join('.'), flagName); | ||
@@ -123,15 +118,14 @@ return { | ||
} | ||
if (!flagValue.match(defaultValue)) { | ||
logger.warn('Value for "%s" is of incorrect type', flagKey); | ||
if (flagValue.value === null) { | ||
return { | ||
errorCode: ErrorCode.TYPE_MISMATCH, | ||
value: defaultValue, | ||
reason: 'ERROR', | ||
reason: mapConfidenceReason(flag.reason), | ||
}; | ||
} | ||
if (flagValue.value === null) { | ||
logger.info('Value for "%s" is default', flagKey); | ||
if (!Configuration.FlagValue.matches(flagValue, defaultValue)) { | ||
logger.warn('Value for "%s" is of incorrect type', flagKey); | ||
return { | ||
errorCode: ErrorCode.TYPE_MISMATCH, | ||
value: defaultValue, | ||
reason: flag.reason, | ||
reason: 'ERROR', | ||
}; | ||
@@ -143,3 +137,3 @@ } | ||
value: flagValue.value, | ||
reason: 'TARGETING_MATCH', | ||
reason: mapConfidenceReason(flag.reason), | ||
variant: flag.variant, | ||
@@ -173,2 +167,14 @@ flagMetadata: { | ||
} | ||
function mapConfidenceReason(reason) { | ||
switch (reason) { | ||
case Configuration.ResolveReason.Archived: | ||
return 'DISABLED'; | ||
case Configuration.ResolveReason.Unspecified: | ||
return 'UNKNOWN'; | ||
case Configuration.ResolveReason.Match: | ||
return 'TARGETING_MATCH'; | ||
default: | ||
return 'DEFAULT'; | ||
} | ||
} | ||
//# sourceMappingURL=ConfidenceWebProvider.js.map |
@@ -1,3 +0,12 @@ | ||
# Change Log | ||
# Changelog | ||
## [0.0.4](https://github.com/spotify/confidence-openfeature-provider-js/compare/openfeature-web-provider-v0.0.3...openfeature-web-provider-v0.0.4) (2023-10-26) | ||
### 🔄 Refactoring | ||
* **client-http,web,server:** use a serializable and more simple configuration object ([fc2093f](https://github.com/spotify/confidence-openfeature-provider-js/commit/fc2093ff51d9525ca866854384751daa9148c6f6)) | ||
## Change Log (Old) | ||
All notable changes to this project will be documented in this file. | ||
@@ -4,0 +13,0 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. |
{ | ||
"name": "@spotify-confidence/openfeature-web-provider", | ||
"license": "Apache-2.0", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"module": "build/esm/index.js", | ||
@@ -9,3 +9,3 @@ "main": "build/cjs/index.js", | ||
"dependencies": { | ||
"@spotify-confidence/client-http": "^0.0.2", | ||
"@spotify-confidence/client-http": "^0.0.3", | ||
"fast-deep-equal": "^3.1.3" | ||
@@ -25,3 +25,3 @@ }, | ||
}, | ||
"gitHead": "c377e3d6611011820bd7799860f96aa1f5fcbe0b" | ||
"gitHead": "6066377a115fb694a7af12ee1a7dc60f73b2fee3" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
178160
706
+ Added@spotify-confidence/client-http@0.0.3(transitive)
- Removed@spotify-confidence/client-http@0.0.2(transitive)