@launchdarkly/js-sdk-common
Advanced tools
Comparing version 2.5.0 to 2.6.0
@@ -5,2 +5,9 @@ # Changelog | ||
## [2.6.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.5.0...js-sdk-common-v2.6.0) (2024-08-12) | ||
### Features | ||
* refactors the implementation of context caching. You can now s… ([#531](https://github.com/launchdarkly/js-core/issues/531)) ([8ab2ee4](https://github.com/launchdarkly/js-core/commit/8ab2ee425a35350a4f1c50e608c39fa3527da513)) | ||
## [2.5.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.4.2...js-sdk-common-v2.5.0) (2024-06-04) | ||
@@ -7,0 +14,0 @@ |
@@ -0,1 +1,23 @@ | ||
/** | ||
* Interface for a data store that holds feature flag data and other SDK | ||
* properties in a serialized form. | ||
* | ||
* This interface should be used for platform-specific integrations that store | ||
* data somewhere other than in memory. Each data item is uniquely identified by | ||
* a string typically constructed following a namespacing structure that | ||
* is then encoded. | ||
* | ||
* Implementations may not throw exceptions. | ||
* | ||
* The SDK assumes that the persistence is only being used by a single instance | ||
* of the SDK per SDK key (two different SDK instances, with 2 different SDK | ||
* keys could use the same persistence instance). | ||
* | ||
* The SDK, with correct usage, will not have overlapping writes to the same | ||
* key. | ||
* | ||
* This interface does not depend on the ability to list the contents of the | ||
* store or namespaces. This is to maintain the simplicity of implementing a | ||
* key-value store on many platforms. | ||
*/ | ||
export interface Storage { | ||
@@ -2,0 +24,0 @@ get: (key: string) => Promise<string | null>; |
@@ -45,2 +45,8 @@ import type { LDContext, LDContextCommon } from './api'; | ||
/** | ||
* Creates a {@link LDContext} from a {@link Context}. | ||
* @param context to be converted | ||
* @returns an {@link LDContext} if input was valid, otherwise undefined | ||
*/ | ||
static toLDContext(context: Context): LDContext | undefined; | ||
/** | ||
* Attempt to get a value for the given context kind using the given reference. | ||
@@ -47,0 +53,0 @@ * @param reference The reference to the value to get. |
@@ -112,2 +112,7 @@ "use strict"; | ||
} | ||
if (user.privateAttributeNames !== null && user.privateAttributeNames !== undefined) { | ||
singleKindContext._meta = { | ||
privateAttributes: user.privateAttributeNames, | ||
}; | ||
} | ||
// We are not pulling private attributes over because we will serialize | ||
@@ -265,2 +270,25 @@ // those from attribute references for events. | ||
/** | ||
* Creates a {@link LDContext} from a {@link Context}. | ||
* @param context to be converted | ||
* @returns an {@link LDContext} if input was valid, otherwise undefined | ||
*/ | ||
static toLDContext(context) { | ||
if (!context.valid) { | ||
return undefined; | ||
} | ||
const contexts = context.getContexts(); | ||
if (!context.isMulti) { | ||
return contexts[0][1]; | ||
} | ||
const result = { | ||
kind: 'multi', | ||
}; | ||
contexts.forEach((kindAndContext) => { | ||
const kind = kindAndContext[0]; | ||
const nestedContext = kindAndContext[1]; | ||
result[kind] = nestedContext; | ||
}); | ||
return result; | ||
} | ||
/** | ||
* Attempt to get a value for the given context kind using the given reference. | ||
@@ -267,0 +295,0 @@ * @param reference The reference to the value to get. |
{ | ||
"name": "@launchdarkly/js-sdk-common", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"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
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
317152
4692
4