@nuskin/configuration-sdk
"The configuration sdk gets market configuration from content stack. You can get the full configuration for a list of config maps or get partial configuration using graphql. The sdk caches the configurations for 2 minutes in memory. The sdk also allows for configuraitons to be overridden. Override configurations for runtime shopping context configurations. Or use the function for testing purposes to override configuration in the browser on the fly.",
Installing
Usng npm:
npm add @nuskin/configuration-sdk
Usng yarn:
yarn add @nuskin/configuration-sdk
Example usage
const {
overrideConfigurationProperty,
clearConfigurationOverrides,
overrideConfiguration,
getConfiguration,
getPartialConfig,
getCachedConfigurations,
getCachedConfiguration,
getCachedConfigField
} = require('@nuskin/configuration-sdk');
overrideConfigurationProperty({configMap: 'Ordering', configMapProperty: 'testing', value: true, country: 'US', shoppingContext: 'personal_offer'});
overrideConfiguration({configMap: ''});
window.nuskin.overrideConfiguration = overrideConfiguration;
const partialConfig = await getPartialConfig(
queryFields = {
Ordering: ['spendingRestrictionsEnabled', 'inventoryCheckEnabled'],
Cart: ['minAdrPsv']
},
options = {
country: 'US',
environment: 'test',
clientId: 'Client id for you application'
}
);
const config = await getConfiguration(
configMapNames = ['Ordering', 'Cart'],
options = {
country: 'US',
clientId: 'clientId',
shoppingContext: 'storefront'
}
);
const configs = getCachedConfigurations(
configNames = [],
country = null
)
const config = getCachedConfiguration(
configNames = [],
country = null
)
const configFieldValue = getCachedConfigField(
configField,
country = null
)
Resources
License
MIT