@cloudcommerce/config 0.0.126 → 0.0.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/lib/config.d.ts +4 -2
- package/lib/config.js +11 -4
- package/lib/config.js.map +1 -1
- package/lib/env.d.ts +1 -1
- package/package.json +4 -4
- package/src/config.ts +14 -5
package/.turbo/turbo-build.log
CHANGED
package/lib/config.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CmsSettings } from '@cloudcommerce/types';
|
|
2
|
+
type BaseConfig = {
|
|
2
3
|
lang: string;
|
|
3
4
|
currency: string;
|
|
4
5
|
currencySymbol: string;
|
|
5
6
|
countryCode: string;
|
|
6
7
|
storeId: number;
|
|
8
|
+
cmsSettings?: CmsSettings;
|
|
7
9
|
};
|
|
8
10
|
declare const _default: {
|
|
9
11
|
get(): BaseConfig;
|
|
10
|
-
set(config:
|
|
12
|
+
set(config: Partial<BaseConfig>): void;
|
|
11
13
|
};
|
|
12
14
|
export default _default;
|
|
13
15
|
export type { BaseConfig };
|
package/lib/config.js
CHANGED
|
@@ -29,14 +29,21 @@ export default {
|
|
|
29
29
|
};
|
|
30
30
|
},
|
|
31
31
|
set(config) {
|
|
32
|
+
const { cmsSettings } = config;
|
|
33
|
+
if (cmsSettings) {
|
|
34
|
+
config.lang = config.lang || cmsSettings.lang;
|
|
35
|
+
config.currency = config.currency || cmsSettings.currency;
|
|
36
|
+
config.currencySymbol = config.currencySymbol || cmsSettings.currency_symbol;
|
|
37
|
+
config.countryCode = config.currencySymbol || cmsSettings.country_code;
|
|
38
|
+
}
|
|
32
39
|
self.config = deepmerge(self.config, config);
|
|
33
40
|
if (config.storeId) {
|
|
34
41
|
_env.ECOM_STORE_ID = config.storeId;
|
|
35
|
-
_env.ECOM_LANG = _env.ECOM_LANG || self.config.lang;
|
|
36
|
-
_env.ECOM_CURRENCY = _env.ECOM_CURRENCY || self.config.currency;
|
|
37
|
-
_env.ECOM_CURRENCY_SYMBOL = _env.ECOM_CURRENCY_SYMBOL || self.config.currencySymbol;
|
|
38
|
-
_env.ECOM_COUNTRY_CODE = _env.ECOM_COUNTRY_CODE || self.config.countryCode;
|
|
39
42
|
}
|
|
43
|
+
_env.ECOM_LANG = _env.ECOM_LANG || self.config.lang;
|
|
44
|
+
_env.ECOM_CURRENCY = _env.ECOM_CURRENCY || self.config.currency;
|
|
45
|
+
_env.ECOM_CURRENCY_SYMBOL = _env.ECOM_CURRENCY_SYMBOL || self.config.currencySymbol;
|
|
46
|
+
_env.ECOM_COUNTRY_CODE = _env.ECOM_COUNTRY_CODE || self.config.countryCode;
|
|
40
47
|
},
|
|
41
48
|
};
|
|
42
49
|
// # sourceMappingURL=config.js.map
|
package/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAWpB,aAAa;AACb,MAAM,IAAI,GAAwB,MAAM,CAAC,IAAI,CAAC,GAAG;OAC5C,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,EAAE,GAAG,CAAC;OAC7C,UAAU,CAAC;AAEhB,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AAE9B,MAAM,IAAI,GAAG,UAAU,CAAC,eAAe,IAAI;IACzC,MAAM,EAAE,EAAE;CACX,CAAC;AACF,UAAU,CAAC,eAAe,GAAG,IAAI,CAAC;AAClC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,YAAY,CAAC;AAChD,IAAI,CAAC,aAAa,GAAG,IA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C,MAAM,CAAC,QAAQ,CAAC;QAChE,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;QACpF,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;IAC7E,CAAC;CACF,CAAC"}
|
package/lib/env.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.127",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce base config",
|
|
6
6
|
"main": "lib/config.js",
|
|
7
7
|
"exports": {
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
},
|
|
22
22
|
"homepage": "https://github.com/ecomplus/cloud-commerce/tree/main/packages/config#readme",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
24
|
+
"@fastify/deepmerge": "^1.2.0",
|
|
25
|
+
"@cloudcommerce/api": "0.0.127"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@cloudcommerce/types": "0.0.
|
|
28
|
+
"@cloudcommerce/types": "0.0.127"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "sh ../../scripts/build-lib.sh"
|
package/src/config.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CmsSettings } from '@cloudcommerce/types';
|
|
1
2
|
import Deepmerge from '@fastify/deepmerge';
|
|
2
3
|
import {
|
|
3
4
|
DEFAULT_LANG,
|
|
@@ -12,6 +13,7 @@ type BaseConfig = {
|
|
|
12
13
|
currencySymbol: string,
|
|
13
14
|
countryCode: string,
|
|
14
15
|
storeId: number,
|
|
16
|
+
cmsSettings?: CmsSettings,
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
// @ts-ignore
|
|
@@ -41,15 +43,22 @@ export default {
|
|
|
41
43
|
...self.config,
|
|
42
44
|
};
|
|
43
45
|
},
|
|
44
|
-
set(config) {
|
|
46
|
+
set(config: Partial<BaseConfig>) {
|
|
47
|
+
const { cmsSettings } = config;
|
|
48
|
+
if (cmsSettings) {
|
|
49
|
+
config.lang = config.lang || cmsSettings.lang;
|
|
50
|
+
config.currency = config.currency || cmsSettings.currency;
|
|
51
|
+
config.currencySymbol = config.currencySymbol || cmsSettings.currency_symbol;
|
|
52
|
+
config.countryCode = config.currencySymbol || cmsSettings.country_code;
|
|
53
|
+
}
|
|
45
54
|
self.config = deepmerge(self.config, config);
|
|
46
55
|
if (config.storeId) {
|
|
47
56
|
_env.ECOM_STORE_ID = config.storeId;
|
|
48
|
-
_env.ECOM_LANG = _env.ECOM_LANG || self.config.lang;
|
|
49
|
-
_env.ECOM_CURRENCY = _env.ECOM_CURRENCY || self.config.currency;
|
|
50
|
-
_env.ECOM_CURRENCY_SYMBOL = _env.ECOM_CURRENCY_SYMBOL || self.config.currencySymbol;
|
|
51
|
-
_env.ECOM_COUNTRY_CODE = _env.ECOM_COUNTRY_CODE || self.config.countryCode;
|
|
52
57
|
}
|
|
58
|
+
_env.ECOM_LANG = _env.ECOM_LANG || self.config.lang;
|
|
59
|
+
_env.ECOM_CURRENCY = _env.ECOM_CURRENCY || self.config.currency;
|
|
60
|
+
_env.ECOM_CURRENCY_SYMBOL = _env.ECOM_CURRENCY_SYMBOL || self.config.currencySymbol;
|
|
61
|
+
_env.ECOM_COUNTRY_CODE = _env.ECOM_COUNTRY_CODE || self.config.countryCode;
|
|
53
62
|
},
|
|
54
63
|
};
|
|
55
64
|
|