@nuskin/ns-product-lib 2.7.0-cx24-3702.3 → 2.7.0-cx24-3682.15
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +82 -15
- package/package.json +2 -2
- package/src/equinox-helpers/childSKU.js +1 -1
- package/src/equinox-helpers/index.js +172 -31
- package/src/equinox-helpers/interceptors/index.js +5 -0
- package/src/equinox-helpers/interceptors/productNotFound.js +72 -0
- package/src/equinox-helpers/mappers/identifier.js +13 -0
- package/src/equinox-helpers/mappers/index.js +13 -0
- package/src/equinox-helpers/mappers/inventoryProperties.js +173 -0
- package/src/equinox-helpers/mappers/properties.js +169 -0
- package/src/equinox-helpers/mappers/variant.js +51 -0
- package/src/equinox-helpers/mappers/variantProperties.js +273 -0
- package/src/equinox-helpers/models/index.js +5 -0
- package/src/equinox-helpers/models/productNotFound.js +32 -0
- package/src/product.js +62 -65
- package/src/productData.js +27 -43
package/CHANGELOG.md
CHANGED
@@ -1,44 +1,111 @@
|
|
1
|
-
# [2.7.0-cx24-
|
1
|
+
# [2.7.0-cx24-3682.15](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.14...v2.7.0-cx24-3682.15) (2023-03-28)
|
2
2
|
|
3
3
|
|
4
4
|
### New
|
5
5
|
|
6
|
-
*
|
6
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([e461718](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/e4617184a156b4c3827c084aca68506fe18df072)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
7
7
|
|
8
|
-
# [2.7.0-cx24-
|
8
|
+
# [2.7.0-cx24-3682.14](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.13...v2.7.0-cx24-3682.14) (2023-03-28)
|
9
9
|
|
10
10
|
|
11
11
|
### New
|
12
12
|
|
13
|
-
*
|
13
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([aae3544](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/aae35440a744d4740a680471f57c7350fc6b9714)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
14
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([6124e9b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6124e9b4fa30f976dbe52ea88c2fcb588b2187cf)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
14
15
|
|
15
|
-
# [2.7.0-cx24-
|
16
|
+
# [2.7.0-cx24-3682.13](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.12...v2.7.0-cx24-3682.13) (2023-03-27)
|
16
17
|
|
17
18
|
|
18
19
|
### New
|
19
20
|
|
20
|
-
*
|
21
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([daa2a72](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/daa2a72a71914c8730826ca2048b30614f7da83a)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
21
22
|
|
22
|
-
|
23
|
+
# [2.7.0-cx24-3682.12](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.11...v2.7.0-cx24-3682.12) (2023-03-27)
|
23
24
|
|
24
25
|
|
25
|
-
###
|
26
|
+
### New
|
26
27
|
|
27
|
-
*
|
28
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([5e90c00](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/5e90c0053045c6a27847264b0112f6033189e421)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
28
29
|
|
29
|
-
# [2.7.0-cx24-
|
30
|
+
# [2.7.0-cx24-3682.11](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.10...v2.7.0-cx24-3682.11) (2023-03-27)
|
30
31
|
|
31
32
|
|
32
|
-
###
|
33
|
+
### New
|
33
34
|
|
34
|
-
*
|
35
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([140f1f0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/140f1f06c14b940851481ab8d4111728e760caad)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
36
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([a9c1b38](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a9c1b380ecb1e98a496be4628f6e4e4f32ff2a98)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
35
37
|
|
36
|
-
|
38
|
+
# [2.7.0-cx24-3682.10](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.9...v2.7.0-cx24-3682.10) (2023-03-27)
|
37
39
|
|
38
40
|
|
39
|
-
###
|
41
|
+
### New
|
42
|
+
|
43
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([249f3b7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/249f3b79b30a774c45e90886f01d8bd4d4874b4b)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
44
|
+
|
45
|
+
# [2.7.0-cx24-3682.9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.8...v2.7.0-cx24-3682.9) (2023-03-26)
|
46
|
+
|
47
|
+
|
48
|
+
### New
|
49
|
+
|
50
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([66c977b](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/66c977b3114e0cd7517d6eaa19174b0a3a13d1ed)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
51
|
+
|
52
|
+
# [2.7.0-cx24-3682.8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.7...v2.7.0-cx24-3682.8) (2023-03-26)
|
53
|
+
|
54
|
+
|
55
|
+
### New
|
56
|
+
|
57
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([3d69bbe](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3d69bbe486f13f4ae2a9fe4c07f53c4d27932177)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
58
|
+
|
59
|
+
# [2.7.0-cx24-3682.7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.6...v2.7.0-cx24-3682.7) (2023-03-25)
|
60
|
+
|
61
|
+
|
62
|
+
### New
|
63
|
+
|
64
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([a8f0331](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a8f0331970ed4631ceba029d48e246b83627a046)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
65
|
+
|
66
|
+
# [2.7.0-cx24-3682.6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.5...v2.7.0-cx24-3682.6) (2023-03-25)
|
67
|
+
|
68
|
+
|
69
|
+
### New
|
70
|
+
|
71
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([13f2b76](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/13f2b76990dd2e4f4226367332212dcc7bd19977)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
72
|
+
|
73
|
+
# [2.7.0-cx24-3682.5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.4...v2.7.0-cx24-3682.5) (2023-03-25)
|
74
|
+
|
75
|
+
|
76
|
+
### New
|
77
|
+
|
78
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([588161d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/588161d54fa2e97f6bee2fe33523f3f1bdcb1ed2)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
79
|
+
|
80
|
+
# [2.7.0-cx24-3682.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.3...v2.7.0-cx24-3682.4) (2023-03-24)
|
81
|
+
|
82
|
+
|
83
|
+
### New
|
84
|
+
|
85
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([f55854a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/f55854ad4abb17dbd373fe5e36a38deb2bb8fc53)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
86
|
+
|
87
|
+
# [2.7.0-cx24-3682.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.2...v2.7.0-cx24-3682.3) (2023-03-24)
|
88
|
+
|
89
|
+
|
90
|
+
### New
|
91
|
+
|
92
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([3ce010e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3ce010e162034d2cc49619f553baf7b8b7fcd4e0)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
93
|
+
|
94
|
+
# [2.7.0-cx24-3682.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3682.1...v2.7.0-cx24-3682.2) (2023-03-24)
|
95
|
+
|
96
|
+
|
97
|
+
### New
|
98
|
+
|
99
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([219fbd5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/219fbd59b96ed9cbbc3ea94a24d886f0e8ca563f)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
100
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([b86a1d2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/b86a1d2610892564c643bd851d873e507efedd49)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
101
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([60d61cc](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/60d61ccd38e9b971b7ac53cf4224a9897a63fef4)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
102
|
+
|
103
|
+
# [2.7.0-cx24-3682.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.1...v2.7.0-cx24-3682.1) (2023-03-24)
|
104
|
+
|
105
|
+
|
106
|
+
### New
|
40
107
|
|
41
|
-
*
|
108
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([99cc11a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/99cc11a7a274d97c03efc0a4bcdd0e03eb7b552a)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
42
109
|
|
43
110
|
## [2.6.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.6.0...v2.6.1) (2023-03-16)
|
44
111
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nuskin/ns-product-lib",
|
3
|
-
"version": "2.7.0-cx24-
|
3
|
+
"version": "2.7.0-cx24-3682.15",
|
4
4
|
"description": "This project contains shared Product models and code between the backend and frontend.",
|
5
5
|
"main": "src/index.js",
|
6
6
|
"scripts": {
|
@@ -33,7 +33,7 @@
|
|
33
33
|
"dependencies": {
|
34
34
|
"@nuskin/configuration-sdk": "2.2.3",
|
35
35
|
"@nuskin/ns-common-lib": "1.4.5",
|
36
|
-
"@nuskin/ns-util": "4.2.
|
36
|
+
"@nuskin/ns-util": "4.2.5",
|
37
37
|
"axios": "0.27.2",
|
38
38
|
"qs": "6.11.0"
|
39
39
|
},
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* childSKU maps a product variant. Used mainly in subscription.
|
3
3
|
*
|
4
4
|
* @param {import('.').KitSKUQuantity[]} kits
|
5
|
-
* @param {import('.').
|
5
|
+
* @param {import('.').EquinoxNormalProduct} product
|
6
6
|
*/
|
7
7
|
function childSKU(kits, product) {
|
8
8
|
const sku = product.sku.filter(sku => sku.default)[0];
|
@@ -4,7 +4,9 @@
|
|
4
4
|
* @type {object}
|
5
5
|
* @property {ProductChildSku[]} childSkus
|
6
6
|
* @property {Inventory} [inventoryProperties]
|
7
|
-
|
7
|
+
*/
|
8
|
+
|
9
|
+
/**
|
8
10
|
* @typedef ProductChildSku
|
9
11
|
* @type {object}
|
10
12
|
* @property {string} productId
|
@@ -13,43 +15,182 @@
|
|
13
15
|
* @property {number} skuQuantity
|
14
16
|
* @property {string} availableChannels
|
15
17
|
* @property {Inventory} [inventory]
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
* @description This model represents a product within an Equinox response.
|
20
|
-
* @typedef EquinoxProduct
|
21
|
-
* @type {object}
|
22
|
-
* @property {string} identifier
|
23
|
-
* @property {EquinoxProductSKU[]} sku
|
24
|
-
* @property {"kit"|"bundle"} [type]
|
25
|
-
*
|
26
|
-
* @typedef EquinoxProductSKU
|
27
|
-
* @type {object}
|
28
|
-
* @property {boolean} default
|
29
|
-
* For multi-variant products, this indicates that this is the searched SKU
|
30
|
-
* when using catalogs/search endpoint.
|
31
|
-
* @property {string} identifier
|
32
|
-
* @property {Inventory} inventoryProperties
|
33
|
-
* @property {EquinoxProductProperties} properties
|
34
|
-
*
|
35
|
-
* @typedef EquinoxProductProperties
|
36
|
-
* @type {object}
|
37
|
-
* @property {string} availableChannels
|
38
|
-
*
|
39
|
-
* ---
|
40
|
-
*
|
18
|
+
*/
|
19
|
+
|
20
|
+
/**
|
41
21
|
* Types common to Product model and Equinox Product model
|
42
|
-
*
|
43
22
|
* @typedef Inventory
|
44
23
|
* @type {object}
|
45
24
|
* @property {number} atpQty
|
46
25
|
* @property {boolean} backOrdered
|
47
|
-
|
48
|
-
|
49
|
-
|
26
|
+
*/
|
27
|
+
|
28
|
+
/**
|
29
|
+
* @description This model represents the error response.
|
30
|
+
* @typedef EquinoxErrorResponse
|
31
|
+
* @type {object}
|
32
|
+
* @property {string} code e.g., SFOSER002
|
33
|
+
* @property {string} message e.g., No Results Found dot Search Term null
|
34
|
+
* @property {number} timestamp e.g., 1679715447962
|
35
|
+
*/
|
36
|
+
|
37
|
+
/**
|
38
|
+
* @description This model represents the response.
|
39
|
+
* @typedef EquinoxResponse
|
40
|
+
* @type {object}
|
41
|
+
* @property {EquinoxNormalProduct[]} product
|
42
|
+
*/
|
43
|
+
|
44
|
+
/**
|
45
|
+
* @description EquinoxNormalProduct represents an equinox Normal product type.
|
46
|
+
* @typedef EquinoxNormalProduct
|
47
|
+
* @type {object}
|
48
|
+
* @property {string} identifier e.g., Normal - "blt8b757df6dcaa199c" | Kit - "02001076"
|
49
|
+
* @property {EquinoxProductProperties} properties
|
50
|
+
* @property {EquinoxProductVariant[]} sku or varaints - available only when product is a normal product.
|
51
|
+
*/
|
52
|
+
|
53
|
+
/**
|
54
|
+
* @description EquinoxKitProduct represents an equinox Kit product type.
|
55
|
+
* @typedef EquinoxKitProduct
|
56
|
+
* @type {object}
|
57
|
+
* @property {"kit"|"bundle"} [type] available only when product is type of kit.
|
58
|
+
*/
|
59
|
+
|
60
|
+
/**
|
61
|
+
* @typedef {(
|
62
|
+
* EquinoxProductCommonProperties & EquinoxNormalProductProperties
|
63
|
+
* )} EquinoxProductProperties
|
64
|
+
*/
|
65
|
+
|
66
|
+
/**
|
67
|
+
* @description These are the properties unique to Normal product type.
|
68
|
+
* @typedef EquinoxNormalProductProperties
|
69
|
+
* @type {object}
|
70
|
+
* @property {string} [ingredients]
|
71
|
+
* @property {string} [benefits]
|
72
|
+
* @property {string} [usage]
|
73
|
+
* @property {string} [resources]
|
74
|
+
* @property {string} [scanQualifiedCount] e.g., "0"
|
75
|
+
* @property {string} [status] e.g., "active"
|
76
|
+
* @property {string} [size] e.g., "30 mL / 1 fl.oz"
|
77
|
+
* @property {string} [productDetailsDescription] e.g., "[]"
|
78
|
+
*/
|
79
|
+
|
80
|
+
/**
|
81
|
+
* @description These are the properties unique to Kit product type.
|
82
|
+
* @typedef EquinoxKitProductProperties
|
83
|
+
* @type {object}
|
84
|
+
* @property {string} [skukits] e.g., "02002145~1,02002146~1,02002147~1,02002148~1,02002142~1,02002143~1"
|
85
|
+
* @property {string} [productStatus] e.g., "Sellable"
|
86
|
+
* @property {string} [availableChannels] e.g., "subscription,arsPhone,kiosk,mobile,web"
|
87
|
+
* @property {string} [market] e.g., "CA"
|
88
|
+
*/
|
89
|
+
|
90
|
+
/**
|
91
|
+
* @description These are the common properties between Normal and Kit product types
|
92
|
+
* @typedef EquinoxProductCommonProperties
|
93
|
+
* @type {object}
|
94
|
+
* @property {string} [name] e.g., "180° Cell Renewal Fluid"
|
95
|
+
* @property {string} [imageURL] e.g., "https://nuskin.com/content/dam/global/...ule-refreshed.jpg"
|
96
|
+
* @property {string} [description] e.g., "180° Ampoule"
|
97
|
+
* @property {string} [customerTypes] e.g., "BrandAffiliate,Preferred,Retail"
|
98
|
+
* @property {string} [division] e.g., "Nu Skin"
|
99
|
+
*/
|
100
|
+
|
101
|
+
/**
|
102
|
+
* @typedef EquinoxProductVariant
|
103
|
+
* @type {object}
|
104
|
+
* @property {string} [identifier] e.g., "02002145"
|
105
|
+
* @property {string} [inventory] e.g., "IN STOCK"
|
106
|
+
* @property {EquinoxProductVariantProperties} [properties]
|
107
|
+
* @property {any[]} [promotion] e.g., ???
|
108
|
+
* @property {EquinoxProductPriceFacets} [priceFacets]
|
109
|
+
* @property {EquinoxProductInventoryProperties} [inventoryProperties]
|
110
|
+
* @property {EquinxProductTotalValue} [totalValue]
|
111
|
+
* @property {boolean} [default] For multi-variant products, this indicates that this is the searched SKU
|
112
|
+
* when using catalogs/search endpoint.
|
113
|
+
*/
|
114
|
+
|
115
|
+
/**
|
116
|
+
* @description This does not contain the full list of properties from the response.
|
117
|
+
* @typedef EquinoxProductVariantProperties
|
118
|
+
* @type {object}
|
119
|
+
* @property {string} [availableChannels] e.g., "subscription,arsPhone,kiosk,mobile,web"
|
120
|
+
* @property {string} [imageURL] e.g., "https://nuskin.com/cont...21/ca-180-Ampoule-refreshed.jpg"
|
121
|
+
* @property {string} [name] e.g., "180° Cell Renewal Fluid"
|
122
|
+
* @property {string} [market] e.g., "CA"
|
123
|
+
* @property {string} [description] e.g., "180° Ampoule"
|
124
|
+
* @property {string} [ingredients]
|
125
|
+
* @property {string} [benefits]
|
126
|
+
* @property {string} [usage]
|
127
|
+
* @property {string} [resources]
|
128
|
+
* @property {string} [scanQualifiedCount] e.g., "0"
|
129
|
+
* @property {string} [customerTypes] e.g., "BrandAffiliate,Preferred,Retail"
|
130
|
+
* @property {string} [division] e.g., "Nu Skin"
|
131
|
+
* @property {string} [status] e.g., "active"
|
132
|
+
* @property {string} [size] e.g., "30 mL / 1 fl.oz"
|
133
|
+
* @property {string} [globalProductId]
|
134
|
+
* @property {string} [excludeFromSearch]
|
135
|
+
* @property {string} [chargeShipping]
|
136
|
+
* @property {string} [title]
|
137
|
+
* @property {string} [productStatus] e.g., "Sellable"
|
138
|
+
* @property {string} [variantLabel]
|
139
|
+
* @property {string} [isExclusive] e.g., "false" - Why is this a string??
|
140
|
+
*/
|
141
|
+
|
142
|
+
/**
|
143
|
+
* @description Why are properties not camelCase and type of string instead of number? Super weird!
|
144
|
+
* @typedef EquinoxProductPriceFacets
|
145
|
+
* @type {object}
|
146
|
+
* @property {string} CV e.g., "76.0"
|
147
|
+
* @property {string} Regular Price e.g., "76.0"
|
148
|
+
* @property {string} PV e.g., "54.15"
|
149
|
+
* @property {string} Wholesale Price e.g., "88.0"
|
150
|
+
* @property {string} SB e.g., "4.25"
|
151
|
+
*/
|
152
|
+
|
153
|
+
/**
|
154
|
+
* @description
|
155
|
+
* @typedef EquinoxProductInventoryProperties
|
156
|
+
* @type {object}
|
157
|
+
* @property {boolean} [available] e.g., true
|
158
|
+
* @property {boolean} [lowStock] e.g., false
|
159
|
+
* @property {string} [binName] e.g., "1046_CA01"
|
160
|
+
* @property {boolean} [backOrdered] e.g., false
|
161
|
+
* @property {number} [expectedBackOrderAvailabilityDate] e.g., 0
|
162
|
+
* @property {boolean} [preOrdered] e.g., false
|
163
|
+
* @property {number} [expectedPreOrderAvailabilityDate] e.g., 0
|
164
|
+
* @property {number} [atpQty] e.g., 49882
|
165
|
+
* @property {number} [preOrderedQty] e.g., 0
|
166
|
+
* @property {number} [backOrderedQty] e.g., 0
|
167
|
+
* @property {number|null} [lowStockThreshold] e.g., null
|
168
|
+
* @property {number|null} [outOfStockThreshold] e.g., null
|
169
|
+
*/
|
170
|
+
|
171
|
+
/**
|
172
|
+
* @description
|
173
|
+
* @typedef EquinxProductTotalValue
|
174
|
+
* @type {object}
|
175
|
+
* @property {number} priceAfterDiscount e.g., 2
|
176
|
+
* @property {number} originalPrice e.g., 2
|
177
|
+
* @property {number} totaldiscount e.g., 0
|
178
|
+
* @property {{
|
179
|
+
* CV: { CV: number },
|
180
|
+
* "Regular Price": {
|
181
|
+
* "Regular Price": number
|
182
|
+
* },
|
183
|
+
* PV: { PV: number },
|
184
|
+
* "Wholesale Price": {
|
185
|
+
* "Wholesale Price": number
|
186
|
+
* },
|
187
|
+
* SB: { SB: number },
|
188
|
+
* }} priceFacets
|
189
|
+
*/
|
190
|
+
|
191
|
+
/**
|
50
192
|
* Standalone types. These are types not related to Product
|
51
193
|
* and Equinox Product models.
|
52
|
-
*
|
53
194
|
* @typedef KitSKUQuantity
|
54
195
|
* @type {object}
|
55
196
|
* @property {string} sku
|
@@ -0,0 +1,72 @@
|
|
1
|
+
const { getCachedConfiguration } = require('@nuskin/configuration-sdk');
|
2
|
+
const { productNotFound } = require('../models');
|
3
|
+
|
4
|
+
// httpStatus codes
|
5
|
+
const httpStatus = { notFound: 404 };
|
6
|
+
|
7
|
+
/**
|
8
|
+
* productNotFoundInterceptor returns a model "ProductNotFound" when the status code is Not Found.
|
9
|
+
* Note: Do not polute this file. Create a new file for new interceptor.
|
10
|
+
*
|
11
|
+
* @param {import('axios').AxiosError} error
|
12
|
+
* @returns {import('axios').AxiosResponse<import('../').EquinoxResponse>}
|
13
|
+
*/
|
14
|
+
function productNotFoundInterceptor(error) {
|
15
|
+
const segments = 'catalogs/search';
|
16
|
+
const { config, response } = error;
|
17
|
+
|
18
|
+
if (response.status === httpStatus.notFound && config.url.includes(segments)) {
|
19
|
+
const params = new URLSearchParams(config.url);
|
20
|
+
const filterParam = Array.from(params.values())[0];
|
21
|
+
const sku = getSKU(filterParam);
|
22
|
+
|
23
|
+
if (sku !== null) {
|
24
|
+
const market = getCachedConfiguration('Equinox_Markets').country_code;
|
25
|
+
const response = {
|
26
|
+
...error.response,
|
27
|
+
data: {
|
28
|
+
product: [
|
29
|
+
productNotFound({ identifier: sku }, market)
|
30
|
+
]
|
31
|
+
},
|
32
|
+
statusText: getStatusText(error.response)
|
33
|
+
};
|
34
|
+
|
35
|
+
return response;
|
36
|
+
}
|
37
|
+
|
38
|
+
console.error('Unable to detect SKU from the given parameter', filterParam);
|
39
|
+
}
|
40
|
+
|
41
|
+
return Promise.reject(error);
|
42
|
+
}
|
43
|
+
|
44
|
+
/**
|
45
|
+
* getSKU returns the SKU from the given parameter.
|
46
|
+
* @param {string} param '\\''index_key_productId="02010489" OR index_key_skuId="02010489"'''
|
47
|
+
* @returns {string|null} SKU
|
48
|
+
*/
|
49
|
+
function getSKU(param) {
|
50
|
+
const result = param.match(/\d{8}/);
|
51
|
+
|
52
|
+
if (result === null) {
|
53
|
+
return null;
|
54
|
+
}
|
55
|
+
|
56
|
+
return result[0];
|
57
|
+
}
|
58
|
+
|
59
|
+
/**
|
60
|
+
* @param {import('axios').AxiosResponse<import('../').EquinoxErrorResponse>} [response]
|
61
|
+
* @returns {string}
|
62
|
+
*/
|
63
|
+
function getStatusText(response) {
|
64
|
+
if (response) {
|
65
|
+
const { code, message, timestamp } = response.data;
|
66
|
+
return `Floating product found -- ${timestamp} ${code}: ${message}`;
|
67
|
+
}
|
68
|
+
|
69
|
+
return '';
|
70
|
+
}
|
71
|
+
|
72
|
+
module.exports = productNotFoundInterceptor;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
const mapIdentifier = require('./identifier');
|
2
|
+
const mapInventoryProperties = require('./inventoryProperties');
|
3
|
+
const mapProperties = require('./properties');
|
4
|
+
const mapVariant = require('./variant');
|
5
|
+
const mapVariantProperties = require('./variantProperties');
|
6
|
+
|
7
|
+
module.exports = {
|
8
|
+
mapIdentifier,
|
9
|
+
mapInventoryProperties,
|
10
|
+
mapProperties,
|
11
|
+
mapVariant,
|
12
|
+
mapVariantProperties
|
13
|
+
};
|
@@ -0,0 +1,173 @@
|
|
1
|
+
// @ts-check
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @param {import('../').EquinoxProductInventoryProperties} inventoryProperties
|
5
|
+
*/
|
6
|
+
function mapInventoryProperties(inventoryProperties = {}) {
|
7
|
+
/** @type {import('../').EquinoxProductInventoryProperties} */
|
8
|
+
const model = {};
|
9
|
+
model.available = mapAvailable(inventoryProperties.available);
|
10
|
+
model.lowStock = mapLowStock(inventoryProperties.lowStock);
|
11
|
+
model.binName = mapBinName(inventoryProperties.binName);
|
12
|
+
model.backOrdered = mapBackOrdered(inventoryProperties.backOrdered);
|
13
|
+
model.expectedBackOrderAvailabilityDate = mapExpectedBackOrderAvailabilityDate(
|
14
|
+
inventoryProperties.expectedBackOrderAvailabilityDate
|
15
|
+
);
|
16
|
+
model.preOrdered = mapPreOrdered(inventoryProperties.preOrdered);
|
17
|
+
model.expectedPreOrderAvailabilityDate = mapExpectedPreOrderAvailabilityDate(
|
18
|
+
inventoryProperties.expectedPreOrderAvailabilityDate
|
19
|
+
);
|
20
|
+
model.atpQty = mapAtpQty(inventoryProperties.atpQty);
|
21
|
+
model.preOrderedQty = mapPreOrderedQty(inventoryProperties.preOrderedQty);
|
22
|
+
model.backOrderedQty = mapBackOrderedQty(inventoryProperties.backOrderedQty);
|
23
|
+
model.lowStockThreshold = mapLowStockThreshold(inventoryProperties.lowStockThreshold);
|
24
|
+
model.outOfStockThreshold = mapOutOfStockThreshold(inventoryProperties.outOfStockThreshold);
|
25
|
+
|
26
|
+
return model;
|
27
|
+
}
|
28
|
+
|
29
|
+
/**
|
30
|
+
* @param {boolean|undefined} available
|
31
|
+
* @returns {boolean}
|
32
|
+
*/
|
33
|
+
function mapAvailable(available) {
|
34
|
+
if (available) {
|
35
|
+
return available;
|
36
|
+
}
|
37
|
+
|
38
|
+
return false;
|
39
|
+
}
|
40
|
+
|
41
|
+
/**
|
42
|
+
* @param {boolean|undefined} lowStock
|
43
|
+
* @returns {boolean}
|
44
|
+
*/
|
45
|
+
function mapLowStock(lowStock) {
|
46
|
+
if (lowStock) {
|
47
|
+
return lowStock;
|
48
|
+
}
|
49
|
+
|
50
|
+
return false;
|
51
|
+
}
|
52
|
+
|
53
|
+
/**
|
54
|
+
* @param {string|undefined} binName
|
55
|
+
* @returns {string}
|
56
|
+
*/
|
57
|
+
function mapBinName(binName) {
|
58
|
+
if (binName) {
|
59
|
+
return binName;
|
60
|
+
}
|
61
|
+
|
62
|
+
return '';
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* @param {boolean|undefined} backOrdered
|
67
|
+
* @returns {boolean}
|
68
|
+
*/
|
69
|
+
function mapBackOrdered(backOrdered) {
|
70
|
+
if (backOrdered) {
|
71
|
+
return backOrdered;
|
72
|
+
}
|
73
|
+
|
74
|
+
return false;
|
75
|
+
}
|
76
|
+
|
77
|
+
/**
|
78
|
+
* @param {number|undefined} expectedBackOrderAvailabilityDate
|
79
|
+
* @returns {number}
|
80
|
+
*/
|
81
|
+
function mapExpectedBackOrderAvailabilityDate(expectedBackOrderAvailabilityDate) {
|
82
|
+
if (expectedBackOrderAvailabilityDate) {
|
83
|
+
return expectedBackOrderAvailabilityDate;
|
84
|
+
}
|
85
|
+
|
86
|
+
return 0;
|
87
|
+
}
|
88
|
+
|
89
|
+
/**
|
90
|
+
* @param {boolean|undefined} preOrdered
|
91
|
+
* @returns {boolean}
|
92
|
+
*/
|
93
|
+
function mapPreOrdered(preOrdered) {
|
94
|
+
if (preOrdered) {
|
95
|
+
return preOrdered;
|
96
|
+
}
|
97
|
+
|
98
|
+
return false;
|
99
|
+
}
|
100
|
+
|
101
|
+
/**
|
102
|
+
* @param {number|undefined} expectedPreOrderAvailabilityDate
|
103
|
+
* @returns {number}
|
104
|
+
*/
|
105
|
+
function mapExpectedPreOrderAvailabilityDate(expectedPreOrderAvailabilityDate) {
|
106
|
+
if (expectedPreOrderAvailabilityDate) {
|
107
|
+
return expectedPreOrderAvailabilityDate;
|
108
|
+
}
|
109
|
+
|
110
|
+
return 0;
|
111
|
+
}
|
112
|
+
|
113
|
+
/**
|
114
|
+
* @param {number|undefined} atpQty
|
115
|
+
* @returns {number}
|
116
|
+
*/
|
117
|
+
function mapAtpQty(atpQty) {
|
118
|
+
if (atpQty) {
|
119
|
+
return atpQty;
|
120
|
+
}
|
121
|
+
|
122
|
+
return 0;
|
123
|
+
}
|
124
|
+
|
125
|
+
/**
|
126
|
+
* @param {number|undefined} preOrderedQty
|
127
|
+
* @returns {number}
|
128
|
+
*/
|
129
|
+
function mapPreOrderedQty(preOrderedQty) {
|
130
|
+
if (preOrderedQty) {
|
131
|
+
return preOrderedQty;
|
132
|
+
}
|
133
|
+
|
134
|
+
return 0;
|
135
|
+
}
|
136
|
+
|
137
|
+
/**
|
138
|
+
* @param {number|undefined} backOrderedQty
|
139
|
+
* @returns {number}
|
140
|
+
*/
|
141
|
+
function mapBackOrderedQty(backOrderedQty) {
|
142
|
+
if (backOrderedQty) {
|
143
|
+
return backOrderedQty;
|
144
|
+
}
|
145
|
+
|
146
|
+
return 0;
|
147
|
+
}
|
148
|
+
|
149
|
+
/**
|
150
|
+
* @param {number|null|undefined} lowStockThreshold
|
151
|
+
* @returns {number|null}
|
152
|
+
*/
|
153
|
+
function mapLowStockThreshold(lowStockThreshold) {
|
154
|
+
if (lowStockThreshold) {
|
155
|
+
return lowStockThreshold;
|
156
|
+
}
|
157
|
+
|
158
|
+
return null;
|
159
|
+
}
|
160
|
+
|
161
|
+
/**
|
162
|
+
* @param {number|null|undefined} outOfStockThreshold
|
163
|
+
* @returns {number|null}
|
164
|
+
*/
|
165
|
+
function mapOutOfStockThreshold(outOfStockThreshold) {
|
166
|
+
if (outOfStockThreshold) {
|
167
|
+
return outOfStockThreshold;
|
168
|
+
}
|
169
|
+
|
170
|
+
return null;
|
171
|
+
}
|
172
|
+
|
173
|
+
module.exports = mapInventoryProperties;
|