@spotify-confidence/openfeature-server-provider
Advanced tools
Comparing version 0.2.2-rc.0 to 0.2.3
@@ -8,3 +8,2 @@ import { EvaluationContext, JsonValue, Logger, Provider, ProviderMetadata, ProviderStatus, ResolutionDetails } from '@openfeature/server-sdk'; | ||
constructor(client: Confidence); | ||
private convertContext; | ||
private getFlag; | ||
@@ -11,0 +10,0 @@ private fetchFlag; |
@@ -34,8 +34,2 @@ "use strict"; | ||
} | ||
convertContext(_a) { | ||
var { targetingKey } = _a, rest = __rest(_a, ["targetingKey"]); | ||
return { | ||
openFeature: Object.assign({ targeting_key: targetingKey }, convertValue(rest)), | ||
}; | ||
} | ||
getFlag(configuration, flagKey, defaultValue, _logger) { | ||
@@ -109,6 +103,4 @@ if (!configuration) { | ||
const [flagName] = flagKey.split('.'); | ||
const configuration = yield this.confidence | ||
.withContext(this.convertContext(context)) | ||
.resolve([`flags/${flagName}`]); | ||
return this.getFlag(configuration, flagKey, defaultValue, logger); | ||
const flagResolution = yield this.confidence.withContext(convertContext(context)).resolve([`flags/${flagName}`]); | ||
return this.getFlag(flagResolution, flagKey, defaultValue, logger); | ||
}); | ||
@@ -130,2 +122,28 @@ } | ||
exports.ConfidenceServerProvider = ConfidenceServerProvider; | ||
function convertContext(_a) { | ||
var { targetingKey } = _a, context = __rest(_a, ["targetingKey"]); | ||
const targetingContext = typeof targetingKey !== 'undefined' ? { targeting_key: targetingKey } : {}; | ||
return Object.assign(Object.assign({}, targetingContext), convertStruct(context)); | ||
} | ||
function convertValue(value) { | ||
if (typeof value === 'object') { | ||
if (value === null) | ||
return undefined; | ||
if (value instanceof Date) | ||
return value.toISOString(); | ||
if (Array.isArray(value)) | ||
return value.map(convertValue); | ||
return convertStruct(value); | ||
} | ||
return value; | ||
} | ||
function convertStruct(value) { | ||
const struct = {}; | ||
for (const key of Object.keys(value)) { | ||
if (typeof value[key] === 'undefined') | ||
continue; | ||
struct[key] = convertValue(value[key]); | ||
} | ||
return struct; | ||
} | ||
function mapConfidenceReason(reason) { | ||
@@ -143,20 +161,2 @@ switch (reason) { | ||
} | ||
function convertValue(value) { | ||
if (value === null) | ||
return undefined; | ||
if (typeof value === 'object') { | ||
if (Array.isArray(value)) { | ||
return value.map(convertValue); | ||
} | ||
if (value instanceof Date) { | ||
return value.toISOString(); | ||
} | ||
const struct = {}; | ||
for (const key of Object.keys(value)) { | ||
struct[key] = convertValue(value[key]); | ||
} | ||
return struct; | ||
} | ||
return value; | ||
} | ||
//# sourceMappingURL=ConfidenceServerProvider.js.map |
@@ -8,3 +8,2 @@ import { EvaluationContext, JsonValue, Logger, Provider, ProviderMetadata, ProviderStatus, ResolutionDetails } from '@openfeature/server-sdk'; | ||
constructor(client: Confidence); | ||
private convertContext; | ||
private getFlag; | ||
@@ -11,0 +10,0 @@ private fetchFlag; |
@@ -31,8 +31,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
convertContext(_a) { | ||
var { targetingKey } = _a, rest = __rest(_a, ["targetingKey"]); | ||
return { | ||
openFeature: Object.assign({ targeting_key: targetingKey }, convertValue(rest)), | ||
}; | ||
} | ||
getFlag(configuration, flagKey, defaultValue, _logger) { | ||
@@ -106,6 +100,4 @@ if (!configuration) { | ||
const [flagName] = flagKey.split('.'); | ||
const configuration = yield this.confidence | ||
.withContext(this.convertContext(context)) | ||
.resolve([`flags/${flagName}`]); | ||
return this.getFlag(configuration, flagKey, defaultValue, logger); | ||
const flagResolution = yield this.confidence.withContext(convertContext(context)).resolve([`flags/${flagName}`]); | ||
return this.getFlag(flagResolution, flagKey, defaultValue, logger); | ||
}); | ||
@@ -126,2 +118,28 @@ } | ||
} | ||
function convertContext(_a) { | ||
var { targetingKey } = _a, context = __rest(_a, ["targetingKey"]); | ||
const targetingContext = typeof targetingKey !== 'undefined' ? { targeting_key: targetingKey } : {}; | ||
return Object.assign(Object.assign({}, targetingContext), convertStruct(context)); | ||
} | ||
function convertValue(value) { | ||
if (typeof value === 'object') { | ||
if (value === null) | ||
return undefined; | ||
if (value instanceof Date) | ||
return value.toISOString(); | ||
if (Array.isArray(value)) | ||
return value.map(convertValue); | ||
return convertStruct(value); | ||
} | ||
return value; | ||
} | ||
function convertStruct(value) { | ||
const struct = {}; | ||
for (const key of Object.keys(value)) { | ||
if (typeof value[key] === 'undefined') | ||
continue; | ||
struct[key] = convertValue(value[key]); | ||
} | ||
return struct; | ||
} | ||
function mapConfidenceReason(reason) { | ||
@@ -139,20 +157,2 @@ switch (reason) { | ||
} | ||
function convertValue(value) { | ||
if (value === null) | ||
return undefined; | ||
if (typeof value === 'object') { | ||
if (Array.isArray(value)) { | ||
return value.map(convertValue); | ||
} | ||
if (value instanceof Date) { | ||
return value.toISOString(); | ||
} | ||
const struct = {}; | ||
for (const key of Object.keys(value)) { | ||
struct[key] = convertValue(value[key]); | ||
} | ||
return struct; | ||
} | ||
return value; | ||
} | ||
//# sourceMappingURL=ConfidenceServerProvider.js.map |
@@ -8,3 +8,2 @@ import { EvaluationContext, JsonValue, Logger, Provider, ProviderMetadata, ProviderStatus, ResolutionDetails } from '@openfeature/server-sdk'; | ||
constructor(client: Confidence); | ||
private convertContext; | ||
private getFlag; | ||
@@ -11,0 +10,0 @@ private fetchFlag; |
@@ -31,8 +31,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
convertContext(_a) { | ||
var { targetingKey } = _a, rest = __rest(_a, ["targetingKey"]); | ||
return { | ||
openFeature: Object.assign({ targeting_key: targetingKey }, convertValue(rest)), | ||
}; | ||
} | ||
getFlag(configuration, flagKey, defaultValue, _logger) { | ||
@@ -106,6 +100,4 @@ if (!configuration) { | ||
const [flagName] = flagKey.split('.'); | ||
const configuration = yield this.confidence | ||
.withContext(this.convertContext(context)) | ||
.resolve([`flags/${flagName}`]); | ||
return this.getFlag(configuration, flagKey, defaultValue, logger); | ||
const flagResolution = yield this.confidence.withContext(convertContext(context)).resolve([`flags/${flagName}`]); | ||
return this.getFlag(flagResolution, flagKey, defaultValue, logger); | ||
}); | ||
@@ -126,2 +118,28 @@ } | ||
} | ||
function convertContext(_a) { | ||
var { targetingKey } = _a, context = __rest(_a, ["targetingKey"]); | ||
const targetingContext = typeof targetingKey !== 'undefined' ? { targeting_key: targetingKey } : {}; | ||
return Object.assign(Object.assign({}, targetingContext), convertStruct(context)); | ||
} | ||
function convertValue(value) { | ||
if (typeof value === 'object') { | ||
if (value === null) | ||
return undefined; | ||
if (value instanceof Date) | ||
return value.toISOString(); | ||
if (Array.isArray(value)) | ||
return value.map(convertValue); | ||
return convertStruct(value); | ||
} | ||
return value; | ||
} | ||
function convertStruct(value) { | ||
const struct = {}; | ||
for (const key of Object.keys(value)) { | ||
if (typeof value[key] === 'undefined') | ||
continue; | ||
struct[key] = convertValue(value[key]); | ||
} | ||
return struct; | ||
} | ||
function mapConfidenceReason(reason) { | ||
@@ -139,20 +157,2 @@ switch (reason) { | ||
} | ||
function convertValue(value) { | ||
if (value === null) | ||
return undefined; | ||
if (typeof value === 'object') { | ||
if (Array.isArray(value)) { | ||
return value.map(convertValue); | ||
} | ||
if (value instanceof Date) { | ||
return value.toISOString(); | ||
} | ||
const struct = {}; | ||
for (const key of Object.keys(value)) { | ||
struct[key] = convertValue(value[key]); | ||
} | ||
return struct; | ||
} | ||
return value; | ||
} | ||
//# sourceMappingURL=ConfidenceServerProvider.js.map |
@@ -15,2 +15,24 @@ # Changelog | ||
## [0.2.3](https://github.com/spotify/confidence-openfeature-provider-js/compare/openfeature-server-provider-v0.2.2-rc.0...openfeature-server-provider-v0.2.3) (2024-05-03) | ||
### โ BREAKING CHANGES | ||
* move sdk to peer dependencies ([#127](https://github.com/spotify/confidence-openfeature-provider-js/issues/127)) | ||
### โจ New Features | ||
* resolve flags on context change ([#128](https://github.com/spotify/confidence-openfeature-provider-js/issues/128)) ([184d5c5](https://github.com/spotify/confidence-openfeature-provider-js/commit/184d5c56f3ee4e428c72a1fa500197b9e7aca8d7)) | ||
### ๐ ๏ธ Build | ||
* move sdk to peer dependencies ([#127](https://github.com/spotify/confidence-openfeature-provider-js/issues/127)) ([f7858c8](https://github.com/spotify/confidence-openfeature-provider-js/commit/f7858c86940e01c0bf18f3a0a2f97fe1508377f9)) | ||
### ๐ฆ CI | ||
* drop "rc" from version: server-provider ([0d15f00](https://github.com/spotify/confidence-openfeature-provider-js/commit/0d15f002a079782ba1d3b12741e774d84e87a932)) | ||
* drop "rc" from version: web-provider ([1576712](https://github.com/spotify/confidence-openfeature-provider-js/commit/1576712ef7c20bca44da8a09b00abef13a0224e5)) | ||
## [0.2.2-rc.0](https://github.com/spotify/confidence-openfeature-provider-js/compare/openfeature-server-provider-v0.2.1-rc.0...openfeature-server-provider-v0.2.2-rc.0) (2024-04-30) | ||
@@ -17,0 +39,0 @@ |
{ | ||
"name": "@spotify-confidence/openfeature-server-provider", | ||
"license": "Apache-2.0", | ||
"version": "0.2.2-rc.0", | ||
"version": "0.2.3", | ||
"module": "build/esm/index.js", | ||
"main": "build/cjs/index.js", | ||
"types": "build/types/index.d.ts", | ||
"dependencies": { | ||
"@spotify-confidence/sdk": "0.0.4" | ||
}, | ||
"devDependencies": { | ||
@@ -16,3 +13,4 @@ "@openfeature/core": "^1.1.0", | ||
"peerDependencies": { | ||
"@openfeature/server-sdk": "^1.13.5" | ||
"@openfeature/server-sdk": "^1.13.5", | ||
"@spotify-confidence/sdk": "^0.0.4" | ||
}, | ||
@@ -28,3 +26,3 @@ "scripts": { | ||
}, | ||
"gitHead": "bf3ab8dd47e57a642759ac22ecfac8ecb9ae1d65" | ||
"gitHead": "9cc79a28acd7b00a5e7e341229081e854d0b5292" | ||
} |
@@ -35,3 +35,3 @@ # OpenFeature JS SDK JavaScript Confidence Provider | ||
client | ||
.getBooleanValue('flagname.bool', false, { | ||
.getBooleanValue('flagName.bool', false, { | ||
targetingKey: `your targeting key`, | ||
@@ -38,0 +38,0 @@ }) |
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
183316
613
- Removed@spotify-confidence/sdk@0.0.4