@launchdarkly/js-server-sdk-common
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -5,2 +5,9 @@ # Changelog | ||
## [2.1.1](https://github.com/launchdarkly/js-core/compare/js-server-sdk-common-v2.1.0...js-server-sdk-common-v2.1.1) (2023-12-04) | ||
### Bug Fixes | ||
* Increment version for changing flagValues ([#317](https://github.com/launchdarkly/js-core/issues/317)) ([e8e07ef](https://github.com/launchdarkly/js-core/commit/e8e07ef66966f1a248fa0da8b8c63b703dfbae99)) | ||
## [2.1.0](https://github.com/launchdarkly/js-core/compare/js-server-sdk-common-v2.0.2...js-server-sdk-common-v2.1.0) (2023-11-14) | ||
@@ -7,0 +14,0 @@ |
@@ -6,3 +6,3 @@ "use strict"; | ||
const FileLoader_1 = require("./FileLoader"); | ||
function makeFlagWithValue(key, value) { | ||
function makeFlagWithValue(key, value, version) { | ||
return { | ||
@@ -13,3 +13,3 @@ key, | ||
variations: [value], | ||
version: 1, | ||
version, | ||
}; | ||
@@ -79,2 +79,3 @@ } | ||
// Clear any existing data before re-populating it. | ||
const oldData = this.allData; | ||
this.allData = {}; | ||
@@ -95,3 +96,3 @@ // We let the parsers throw, and the caller can handle the rejection. | ||
} | ||
this.processParsedData(parsed); | ||
this.processParsedData(parsed, oldData); | ||
}); | ||
@@ -105,3 +106,3 @@ this.featureStore.init(this.allData, () => { | ||
} | ||
processParsedData(parsed) { | ||
processParsedData(parsed, oldData) { | ||
Object.keys(parsed.flags || {}).forEach((key) => { | ||
@@ -112,3 +113,11 @@ (0, serialization_1.processFlag)(parsed.flags[key]); | ||
Object.keys(parsed.flagValues || {}).forEach((key) => { | ||
const flag = makeFlagWithValue(key, parsed.flagValues[key]); | ||
var _a, _b; | ||
const previousInstance = (_a = oldData[VersionedDataKinds_1.default.Features.namespace]) === null || _a === void 0 ? void 0 : _a[key]; | ||
let { version } = previousInstance !== null && previousInstance !== void 0 ? previousInstance : { version: 1 }; | ||
// If the data is different, then we want to increment the version. | ||
if (previousInstance && | ||
JSON.stringify(parsed.flagValues[key]) !== JSON.stringify((_b = previousInstance === null || previousInstance === void 0 ? void 0 : previousInstance.variations) === null || _b === void 0 ? void 0 : _b[0])) { | ||
version += 1; | ||
} | ||
const flag = makeFlagWithValue(key, parsed.flagValues[key], version); | ||
(0, serialization_1.processFlag)(flag); | ||
@@ -115,0 +124,0 @@ this.addItem(VersionedDataKinds_1.default.Features, flag); |
{ | ||
"name": "@launchdarkly/js-server-sdk-common", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"type": "commonjs", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
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
586248
8272