@cloudcommerce/config
Advanced tools
Comparing version 0.0.126 to 0.0.127
@@ -1,2 +0,3 @@ | ||
declare type BaseConfig = { | ||
import type { CmsSettings } from '@cloudcommerce/types'; | ||
type BaseConfig = { | ||
lang: string; | ||
@@ -7,8 +8,9 @@ currency: string; | ||
storeId: number; | ||
cmsSettings?: CmsSettings; | ||
}; | ||
declare const _default: { | ||
get(): BaseConfig; | ||
set(config: any): void; | ||
set(config: Partial<BaseConfig>): void; | ||
}; | ||
export default _default; | ||
export type { BaseConfig }; |
@@ -32,12 +32,19 @@ import Deepmerge from '@fastify/deepmerge'; | ||
set(config) { | ||
const { cmsSettings } = config; | ||
if (cmsSettings) { | ||
config.lang = config.lang || cmsSettings.lang; | ||
config.currency = config.currency || cmsSettings.currency; | ||
config.currencySymbol = config.currencySymbol || cmsSettings.currency_symbol; | ||
config.countryCode = config.currencySymbol || cmsSettings.country_code; | ||
} | ||
self.config = deepmerge(self.config, config); | ||
if (config.storeId) { | ||
_env.ECOM_STORE_ID = config.storeId; | ||
_env.ECOM_LANG = _env.ECOM_LANG || self.config.lang; | ||
_env.ECOM_CURRENCY = _env.ECOM_CURRENCY || self.config.currency; | ||
_env.ECOM_CURRENCY_SYMBOL = _env.ECOM_CURRENCY_SYMBOL || self.config.currencySymbol; | ||
_env.ECOM_COUNTRY_CODE = _env.ECOM_COUNTRY_CODE || self.config.countryCode; | ||
} | ||
_env.ECOM_LANG = _env.ECOM_LANG || self.config.lang; | ||
_env.ECOM_CURRENCY = _env.ECOM_CURRENCY || self.config.currency; | ||
_env.ECOM_CURRENCY_SYMBOL = _env.ECOM_CURRENCY_SYMBOL || self.config.currencySymbol; | ||
_env.ECOM_COUNTRY_CODE = _env.ECOM_COUNTRY_CODE || self.config.countryCode; | ||
}, | ||
}; | ||
// # sourceMappingURL=config.js.map |
@@ -1,2 +0,2 @@ | ||
declare type Env = { | ||
type Env = { | ||
storeId: number; | ||
@@ -3,0 +3,0 @@ apiAuth: { |
{ | ||
"name": "@cloudcommerce/config", | ||
"type": "module", | ||
"version": "0.0.126", | ||
"version": "0.0.127", | ||
"description": "E-Com Plus Cloud Commerce base config", | ||
@@ -24,7 +24,7 @@ "main": "lib/config.js", | ||
"dependencies": { | ||
"@cloudcommerce/api": "0.0.126", | ||
"@fastify/deepmerge": "^1.1.0" | ||
"@fastify/deepmerge": "^1.2.0", | ||
"@cloudcommerce/api": "0.0.127" | ||
}, | ||
"devDependencies": { | ||
"@cloudcommerce/types": "0.0.126" | ||
"@cloudcommerce/types": "0.0.127" | ||
}, | ||
@@ -31,0 +31,0 @@ "scripts": { |
@@ -0,1 +1,2 @@ | ||
import type { CmsSettings } from '@cloudcommerce/types'; | ||
import Deepmerge from '@fastify/deepmerge'; | ||
@@ -15,2 +16,3 @@ import { | ||
storeId: number, | ||
cmsSettings?: CmsSettings, | ||
}; | ||
@@ -45,11 +47,18 @@ | ||
}, | ||
set(config) { | ||
set(config: Partial<BaseConfig>) { | ||
const { cmsSettings } = config; | ||
if (cmsSettings) { | ||
config.lang = config.lang || cmsSettings.lang; | ||
config.currency = config.currency || cmsSettings.currency; | ||
config.currencySymbol = config.currencySymbol || cmsSettings.currency_symbol; | ||
config.countryCode = config.currencySymbol || cmsSettings.country_code; | ||
} | ||
self.config = deepmerge(self.config, config); | ||
if (config.storeId) { | ||
_env.ECOM_STORE_ID = config.storeId; | ||
_env.ECOM_LANG = _env.ECOM_LANG || self.config.lang; | ||
_env.ECOM_CURRENCY = _env.ECOM_CURRENCY || self.config.currency; | ||
_env.ECOM_CURRENCY_SYMBOL = _env.ECOM_CURRENCY_SYMBOL || self.config.currencySymbol; | ||
_env.ECOM_COUNTRY_CODE = _env.ECOM_COUNTRY_CODE || self.config.countryCode; | ||
} | ||
_env.ECOM_LANG = _env.ECOM_LANG || self.config.lang; | ||
_env.ECOM_CURRENCY = _env.ECOM_CURRENCY || self.config.currency; | ||
_env.ECOM_CURRENCY_SYMBOL = _env.ECOM_CURRENCY_SYMBOL || self.config.currencySymbol; | ||
_env.ECOM_COUNTRY_CODE = _env.ECOM_COUNTRY_CODE || self.config.countryCode; | ||
}, | ||
@@ -56,0 +65,0 @@ }; |
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
23513
226
+ Added@cloudcommerce/api@0.0.127(transitive)
- Removed@cloudcommerce/api@0.0.126(transitive)
Updated@cloudcommerce/api@0.0.127
Updated@fastify/deepmerge@^1.2.0