@nuskin/ns-product-lib 2.7.0-cx24-3702.6 → 2.7.0-cx24-3702.7
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/CHANGELOG.md +42 -0
- package/package.json +1 -1
- package/src/equinox-helpers/childSKU.js +1 -1
- package/src/equinox-helpers/index.js +173 -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 +48 -0
- package/src/product.js +20 -0
- package/src/productData.js +20 -1
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,45 @@
|
|
1
|
+
# [2.7.0-cx24-3702.7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3702.6...v2.7.0-cx24-3702.7) (2023-04-03)
|
2
|
+
|
3
|
+
|
4
|
+
### New
|
5
|
+
|
6
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([d1094e0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/d1094e0dbaf0f64f34650500094d952255b9979b)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
7
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([9024499](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9024499db81b4d73f0c013404d57bbd58c05ce9f)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
8
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([e1f51c4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/e1f51c4b427c3f2b82de92c355c41f5d2bbcc4ba)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
9
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([4d58678](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/4d58678e861447d24a87693a3f3b979943e0b656)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
10
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([a424d30](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a424d3087d331dd83b3445ac1083b6529992cea9)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
11
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([58e4cee](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/58e4cee8f68939b838f0609f85bf40eff29d6971)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
12
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([bb7a0ce](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/bb7a0ce35c4d3c3ad3f9426ca44df1f3ce682b21)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
13
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([eccd473](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/eccd473d3f5d4197f8ebefa40c4c117f1875abe9)), 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 ([abb1dc8](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/abb1dc857554593de9ff47a3b13b9616211e6624)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
15
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([9a676d9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9a676d94f52622035f78e1f508bfa006b28911a8)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
16
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([6eefd88](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6eefd88adb1c039b6864d1c19606e42c47b4cb94)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
17
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([1d733f9](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/1d733f9f2c4b59e4d851836a4c544c4445b75c83)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
18
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([ae00507](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ae00507b78872a8585b73fe8b3123b8271f95f01)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
19
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([73fdf79](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/73fdf79edf1c2aab894d5572409c77c02e89455d)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
20
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([9f78445](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9f78445c414a84d031de2cdc17cbeefef3a7d9ee)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
21
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([451729a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/451729a2293af27f4c82094fa723ed93ae53f2e2)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
22
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([34db83a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/34db83a117e111ef8da046e2caa976093ba4fe3b)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
23
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([3842d97](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3842d97115374ca66ca6078bd5926f8490bb4df3)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
24
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([e10b59e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/e10b59e07a31e3003af780ac1743880fb318b8f9)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
25
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([9f877d6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9f877d6952782346ffe064aa204a3af916bd0be9)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
26
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([6e86abd](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6e86abd352d363b63508c46484974f0180813b67)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
27
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([ec62b77](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ec62b779549effda493f23aada23d4be3bc0e4e0)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
28
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([30aa6d4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/30aa6d4dcef2c35e643184fe9bff3ce9c3d667d0)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
29
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([260338f](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/260338f51daedbd19c1b4ed9b45b60e6a3b01651)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
30
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([0f2f90c](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/0f2f90ceb309bb26fcd5ca177d9c984cf78d2f2e)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
31
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([6e249e5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/6e249e522ef1222fcbf57e1f03aca7cac7463c19)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
32
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([ce1ff2d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ce1ff2d5f06a68f7321f97f75b5604bcff5727b5)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
33
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([8dda5f5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8dda5f531a06d549563b5c13855e8ceadddebfd7)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
34
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([138d119](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/138d1198ed24367702f80579e64b76754cb5e633)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
35
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([f002b19](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/f002b1933941fc58e6be2b729064cc39e6c6fc1f)), 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 ([9ad765d](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/9ad765de73518c3f8369959921156c71faa050b1)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
37
|
+
* MySite product cards show blank data when users have setup AEM Base SKU's(55) in Admin #CX24-3682 ([67ab153](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/67ab153d076e20820800bec0e608e4e41652d743)), closes [#CX24-3682](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-3682)
|
38
|
+
|
39
|
+
### Update
|
40
|
+
|
41
|
+
* Merge CX24-3682 into CX24-3702 ([3421235](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/342123505aceb09de5645fbf638ee93cf62c1c7f))
|
42
|
+
|
1
43
|
# [2.7.0-cx24-3702.6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.7.0-cx24-3702.5...v2.7.0-cx24-3702.6) (2023-04-03)
|
2
44
|
|
3
45
|
|
package/package.json
CHANGED
@@ -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,183 @@
|
|
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
|
+
* @property {boolean} [exists] indicates whethere the SKU exists or not (HTTP 404) e.g., false
|
52
|
+
*/
|
53
|
+
|
54
|
+
/**
|
55
|
+
* @description EquinoxKitProduct represents an equinox Kit product type.
|
56
|
+
* @typedef EquinoxKitProduct
|
57
|
+
* @type {object}
|
58
|
+
* @property {"kit"|"bundle"} [type] available only when product is type of kit.
|
59
|
+
*/
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @typedef {(
|
63
|
+
* EquinoxProductCommonProperties & EquinoxNormalProductProperties
|
64
|
+
* )} EquinoxProductProperties
|
65
|
+
*/
|
66
|
+
|
67
|
+
/**
|
68
|
+
* @description These are the properties unique to Normal product type.
|
69
|
+
* @typedef EquinoxNormalProductProperties
|
70
|
+
* @type {object}
|
71
|
+
* @property {string} [ingredients]
|
72
|
+
* @property {string} [benefits]
|
73
|
+
* @property {string} [usage]
|
74
|
+
* @property {string} [resources]
|
75
|
+
* @property {string} [scanQualifiedCount] e.g., "0"
|
76
|
+
* @property {string} [status] e.g., "active"
|
77
|
+
* @property {string} [size] e.g., "30 mL / 1 fl.oz"
|
78
|
+
* @property {string} [productDetailsDescription] e.g., "[]"
|
79
|
+
*/
|
80
|
+
|
81
|
+
/**
|
82
|
+
* @description These are the properties unique to Kit product type.
|
83
|
+
* @typedef EquinoxKitProductProperties
|
84
|
+
* @type {object}
|
85
|
+
* @property {string} [skukits] e.g., "02002145~1,02002146~1,02002147~1,02002148~1,02002142~1,02002143~1"
|
86
|
+
* @property {string} [productStatus] e.g., "Sellable"
|
87
|
+
* @property {string} [availableChannels] e.g., "subscription,arsPhone,kiosk,mobile,web"
|
88
|
+
* @property {string} [market] e.g., "CA"
|
89
|
+
*/
|
90
|
+
|
91
|
+
/**
|
92
|
+
* @description These are the common properties between Normal and Kit product types
|
93
|
+
* @typedef EquinoxProductCommonProperties
|
94
|
+
* @type {object}
|
95
|
+
* @property {string} [name] e.g., "180° Cell Renewal Fluid"
|
96
|
+
* @property {string} [imageURL] e.g., "https://nuskin.com/content/dam/global/...ule-refreshed.jpg"
|
97
|
+
* @property {string} [description] e.g., "180° Ampoule"
|
98
|
+
* @property {string} [customerTypes] e.g., "BrandAffiliate,Preferred,Retail"
|
99
|
+
* @property {string} [division] e.g., "Nu Skin"
|
100
|
+
*/
|
101
|
+
|
102
|
+
/**
|
103
|
+
* @typedef EquinoxProductVariant
|
104
|
+
* @type {object}
|
105
|
+
* @property {string} [identifier] e.g., "02002145"
|
106
|
+
* @property {string} [inventory] e.g., "IN STOCK"
|
107
|
+
* @property {EquinoxProductVariantProperties} [properties]
|
108
|
+
* @property {any[]} [promotion] e.g., ???
|
109
|
+
* @property {EquinoxProductPriceFacets} [priceFacets]
|
110
|
+
* @property {EquinoxProductInventoryProperties} [inventoryProperties]
|
111
|
+
* @property {EquinxProductTotalValue} [totalValue]
|
112
|
+
* @property {boolean} [default] For multi-variant products, this indicates that this is the searched SKU
|
113
|
+
* when using catalogs/search endpoint.
|
114
|
+
*/
|
115
|
+
|
116
|
+
/**
|
117
|
+
* @description This does not contain the full list of properties from the response.
|
118
|
+
* @typedef EquinoxProductVariantProperties
|
119
|
+
* @type {object}
|
120
|
+
* @property {string} [availableChannels] e.g., "subscription,arsPhone,kiosk,mobile,web"
|
121
|
+
* @property {string} [imageURL] e.g., "https://nuskin.com/cont...21/ca-180-Ampoule-refreshed.jpg"
|
122
|
+
* @property {string} [name] e.g., "180° Cell Renewal Fluid"
|
123
|
+
* @property {string} [market] e.g., "CA"
|
124
|
+
* @property {string} [description] e.g., "180° Ampoule"
|
125
|
+
* @property {string} [ingredients]
|
126
|
+
* @property {string} [benefits]
|
127
|
+
* @property {string} [usage]
|
128
|
+
* @property {string} [resources]
|
129
|
+
* @property {string} [scanQualifiedCount] e.g., "0"
|
130
|
+
* @property {string} [customerTypes] e.g., "BrandAffiliate,Preferred,Retail"
|
131
|
+
* @property {string} [division] e.g., "Nu Skin"
|
132
|
+
* @property {string} [status] e.g., "active"
|
133
|
+
* @property {string} [size] e.g., "30 mL / 1 fl.oz"
|
134
|
+
* @property {string} [globalProductId]
|
135
|
+
* @property {string} [excludeFromSearch]
|
136
|
+
* @property {string} [chargeShipping]
|
137
|
+
* @property {string} [title]
|
138
|
+
* @property {string} [productStatus] e.g., "Sellable"
|
139
|
+
* @property {string} [variantLabel]
|
140
|
+
* @property {string} [isExclusive] e.g., "false" - Why is this a string??
|
141
|
+
*/
|
142
|
+
|
143
|
+
/**
|
144
|
+
* @description Why are properties not camelCase and type of string instead of number? Super weird!
|
145
|
+
* @typedef EquinoxProductPriceFacets
|
146
|
+
* @type {object}
|
147
|
+
* @property {string} CV e.g., "76.0"
|
148
|
+
* @property {string} Regular Price e.g., "76.0"
|
149
|
+
* @property {string} PV e.g., "54.15"
|
150
|
+
* @property {string} Wholesale Price e.g., "88.0"
|
151
|
+
* @property {string} SB e.g., "4.25"
|
152
|
+
*/
|
153
|
+
|
154
|
+
/**
|
155
|
+
* @description
|
156
|
+
* @typedef EquinoxProductInventoryProperties
|
157
|
+
* @type {object}
|
158
|
+
* @property {boolean} [available] e.g., true
|
159
|
+
* @property {boolean} [lowStock] e.g., false
|
160
|
+
* @property {string} [binName] e.g., "1046_CA01"
|
161
|
+
* @property {boolean} [backOrdered] e.g., false
|
162
|
+
* @property {number} [expectedBackOrderAvailabilityDate] e.g., 0
|
163
|
+
* @property {boolean} [preOrdered] e.g., false
|
164
|
+
* @property {number} [expectedPreOrderAvailabilityDate] e.g., 0
|
165
|
+
* @property {number} [atpQty] e.g., 49882
|
166
|
+
* @property {number} [preOrderedQty] e.g., 0
|
167
|
+
* @property {number} [backOrderedQty] e.g., 0
|
168
|
+
* @property {number|null} [lowStockThreshold] e.g., null
|
169
|
+
* @property {number|null} [outOfStockThreshold] e.g., null
|
170
|
+
*/
|
171
|
+
|
172
|
+
/**
|
173
|
+
* @description
|
174
|
+
* @typedef EquinxProductTotalValue
|
175
|
+
* @type {object}
|
176
|
+
* @property {number} priceAfterDiscount e.g., 2
|
177
|
+
* @property {number} originalPrice e.g., 2
|
178
|
+
* @property {number} totaldiscount e.g., 0
|
179
|
+
* @property {{
|
180
|
+
* CV: { CV: number },
|
181
|
+
* "Regular Price": {
|
182
|
+
* "Regular Price": number
|
183
|
+
* },
|
184
|
+
* PV: { PV: number },
|
185
|
+
* "Wholesale Price": {
|
186
|
+
* "Wholesale Price": number
|
187
|
+
* },
|
188
|
+
* SB: { SB: number },
|
189
|
+
* }} priceFacets
|
190
|
+
*/
|
191
|
+
|
192
|
+
/**
|
50
193
|
* Standalone types. These are types not related to Product
|
51
194
|
* and Equinox Product models.
|
52
|
-
*
|
53
195
|
* @typedef KitSKUQuantity
|
54
196
|
* @type {object}
|
55
197
|
* @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, exists: false }, 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;
|
@@ -0,0 +1,169 @@
|
|
1
|
+
// @ts-check
|
2
|
+
/**
|
3
|
+
* mapProperties maps the properties of a product.
|
4
|
+
* @param {import('../').EquinoxProductProperties} props
|
5
|
+
*/
|
6
|
+
function mapProperties(props = {}) {
|
7
|
+
/** @type {import('../').EquinoxProductProperties} */
|
8
|
+
const properties = {};
|
9
|
+
properties.name = mapName(props.name);
|
10
|
+
properties.description = mapDescription(props.description);
|
11
|
+
properties.productDetailsDescription = mapProductDetailsDescription(props.productDetailsDescription);
|
12
|
+
properties.ingredients = mapIngredients(props.ingredients);
|
13
|
+
properties.benefits = mapBenefits(props.benefits);
|
14
|
+
properties.usage = mapUsage(props.usage);
|
15
|
+
properties.scanQualifiedCount = mapScanQualifiedCount(props.scanQualifiedCount);
|
16
|
+
properties.division = mapDivision(props.division);
|
17
|
+
properties.imageURL = mapImageURL(props.imageURL);
|
18
|
+
properties.resources = mapResources(props.resources);
|
19
|
+
properties.customerTypes = mapCustomerTypes(props.customerTypes);
|
20
|
+
properties.size = mapSize(props.size);
|
21
|
+
|
22
|
+
return properties;
|
23
|
+
}
|
24
|
+
|
25
|
+
/**
|
26
|
+
* @param {string|undefined} name
|
27
|
+
* @returns {string}
|
28
|
+
*/
|
29
|
+
function mapName(name) {
|
30
|
+
if (name) {
|
31
|
+
return name;
|
32
|
+
}
|
33
|
+
|
34
|
+
return '';
|
35
|
+
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
* @param {string|undefined} description
|
39
|
+
* @returns {string}
|
40
|
+
*/
|
41
|
+
function mapDescription(description) {
|
42
|
+
if (description) {
|
43
|
+
return description;
|
44
|
+
}
|
45
|
+
|
46
|
+
return '';
|
47
|
+
}
|
48
|
+
|
49
|
+
/**
|
50
|
+
* @param {string|undefined} productDetailsDescription
|
51
|
+
* @returns {string}
|
52
|
+
*/
|
53
|
+
function mapProductDetailsDescription(productDetailsDescription) {
|
54
|
+
if (productDetailsDescription) {
|
55
|
+
return productDetailsDescription;
|
56
|
+
}
|
57
|
+
|
58
|
+
return '';
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @param {string|undefined} ingredients
|
63
|
+
* @returns {string}
|
64
|
+
*/
|
65
|
+
function mapIngredients(ingredients) {
|
66
|
+
if (ingredients) {
|
67
|
+
return ingredients;
|
68
|
+
}
|
69
|
+
|
70
|
+
return '';
|
71
|
+
}
|
72
|
+
|
73
|
+
/**
|
74
|
+
* @param {string|undefined} benefits
|
75
|
+
* @returns {string}
|
76
|
+
*/
|
77
|
+
function mapBenefits(benefits) {
|
78
|
+
if (benefits) {
|
79
|
+
return benefits;
|
80
|
+
}
|
81
|
+
|
82
|
+
return '';
|
83
|
+
}
|
84
|
+
|
85
|
+
/**
|
86
|
+
* @param {string|undefined} usage
|
87
|
+
* @returns {string}
|
88
|
+
*/
|
89
|
+
function mapUsage(usage) {
|
90
|
+
if (usage) {
|
91
|
+
return usage;
|
92
|
+
}
|
93
|
+
|
94
|
+
return '';
|
95
|
+
}
|
96
|
+
|
97
|
+
/**
|
98
|
+
* @param {string|undefined} scanQualifiedCount
|
99
|
+
* @returns {string}
|
100
|
+
*/
|
101
|
+
function mapScanQualifiedCount(scanQualifiedCount) {
|
102
|
+
if (scanQualifiedCount) {
|
103
|
+
return scanQualifiedCount;
|
104
|
+
}
|
105
|
+
|
106
|
+
return '';
|
107
|
+
}
|
108
|
+
|
109
|
+
/**
|
110
|
+
* @param {string|undefined} division
|
111
|
+
* @returns {string}
|
112
|
+
*/
|
113
|
+
function mapDivision(division) {
|
114
|
+
if (division) {
|
115
|
+
return division;
|
116
|
+
}
|
117
|
+
|
118
|
+
return '';
|
119
|
+
}
|
120
|
+
|
121
|
+
/**
|
122
|
+
* @param {string|undefined} imageURL
|
123
|
+
* @returns {string}
|
124
|
+
*/
|
125
|
+
function mapImageURL(imageURL) {
|
126
|
+
if (imageURL) {
|
127
|
+
return imageURL;
|
128
|
+
}
|
129
|
+
|
130
|
+
return '';
|
131
|
+
}
|
132
|
+
|
133
|
+
/**
|
134
|
+
* @param {string|undefined} resources
|
135
|
+
* @returns {string}
|
136
|
+
*/
|
137
|
+
function mapResources(resources) {
|
138
|
+
if (resources) {
|
139
|
+
return resources;
|
140
|
+
}
|
141
|
+
|
142
|
+
return '';
|
143
|
+
}
|
144
|
+
|
145
|
+
/**
|
146
|
+
* @param {string|undefined} customerTypes
|
147
|
+
* @returns {string}
|
148
|
+
*/
|
149
|
+
function mapCustomerTypes(customerTypes) {
|
150
|
+
if (customerTypes) {
|
151
|
+
return customerTypes;
|
152
|
+
}
|
153
|
+
|
154
|
+
return '';
|
155
|
+
}
|
156
|
+
|
157
|
+
/**
|
158
|
+
* @param {string|undefined} size
|
159
|
+
* @returns {string}
|
160
|
+
*/
|
161
|
+
function mapSize(size) {
|
162
|
+
if (size) {
|
163
|
+
return size;
|
164
|
+
}
|
165
|
+
|
166
|
+
return '';
|
167
|
+
}
|
168
|
+
|
169
|
+
module.exports = mapProperties;
|
@@ -0,0 +1,51 @@
|
|
1
|
+
// @ts-check
|
2
|
+
const mapIdentifier = require('./identifier');
|
3
|
+
const mapInventoryProperties = require('./inventoryProperties');
|
4
|
+
const mapVariantProperties = require('./variantProperties');
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @param {import('../').EquinoxProductVariant} variant
|
8
|
+
*/
|
9
|
+
function mapVariant(variant) {
|
10
|
+
/** @type {import('../').EquinoxProductVariant} */
|
11
|
+
const model = {
|
12
|
+
identifier: mapIdentifier(variant.identifier),
|
13
|
+
inventory: '',
|
14
|
+
properties: mapVariantProperties(variant.properties),
|
15
|
+
promotion: [],
|
16
|
+
priceFacets: {
|
17
|
+
CV: '',
|
18
|
+
PV: '',
|
19
|
+
SB: '',
|
20
|
+
'Wholesale Price': '',
|
21
|
+
'Regular Price': ''
|
22
|
+
},
|
23
|
+
inventoryProperties: mapInventoryProperties(variant.inventoryProperties),
|
24
|
+
totalValue: {
|
25
|
+
originalPrice: 0,
|
26
|
+
priceAfterDiscount: 0,
|
27
|
+
priceFacets: {
|
28
|
+
CV: {
|
29
|
+
CV: 36
|
30
|
+
},
|
31
|
+
'Regular Price': {
|
32
|
+
'Regular Price': 52
|
33
|
+
},
|
34
|
+
PV: {
|
35
|
+
PV: 25.65
|
36
|
+
},
|
37
|
+
'Wholesale Price': {
|
38
|
+
'Wholesale Price': 42
|
39
|
+
},
|
40
|
+
SB: {
|
41
|
+
SB: 2
|
42
|
+
}
|
43
|
+
},
|
44
|
+
totaldiscount: 0
|
45
|
+
}
|
46
|
+
};
|
47
|
+
|
48
|
+
return model;
|
49
|
+
}
|
50
|
+
|
51
|
+
module.exports = mapVariant;
|
@@ -0,0 +1,273 @@
|
|
1
|
+
// @ts-check
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @param {import('../').EquinoxProductVariantProperties} properties
|
5
|
+
*/
|
6
|
+
function mapVariantProperties(properties = {}) {
|
7
|
+
/** @type {import('../').EquinoxProductVariantProperties} */
|
8
|
+
const model = {};
|
9
|
+
model.benefits = mapBenefits(properties.benefits);
|
10
|
+
model.excludeFromSearch = mapExcludeFromSearch(properties.excludeFromSearch);
|
11
|
+
model.usage = mapUsage(properties.usage);
|
12
|
+
model.description = mapDescription(properties.description);
|
13
|
+
model.chargeShipping = mapChargeShipping(properties.chargeShipping);
|
14
|
+
model.globalProductId = mapGlobalProductId(properties.globalProductId);
|
15
|
+
model.title = mapTitle(properties.title);
|
16
|
+
model.scanQualifiedCount = mapScanQualifiedCount(properties.scanQualifiedCount);
|
17
|
+
model.division = mapDivision(properties.division);
|
18
|
+
model.isExclusive = mapIsExclusive('false',);
|
19
|
+
model.imageURL = mapImageURL(properties.imageURL);
|
20
|
+
model.customerTypes = mapCustomerTypes(properties.customerTypes);
|
21
|
+
model.ingredients = mapIngredients(properties.ingredients);
|
22
|
+
model.availableChannels = mapAvailableChannels(properties.availableChannels);
|
23
|
+
model.resources = mapResources(properties.resources);
|
24
|
+
model.market = mapMarket(properties.market);
|
25
|
+
model.size = mapSize(properties.size);
|
26
|
+
model.name = mapName(properties.name);
|
27
|
+
model.status = mapStatus(properties.status);
|
28
|
+
model.productStatus = mapProductStatus(properties.productStatus);
|
29
|
+
|
30
|
+
return model;
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* @param {string|undefined} benefits
|
35
|
+
* @returns {string}
|
36
|
+
*/
|
37
|
+
function mapBenefits(benefits) {
|
38
|
+
if (benefits) {
|
39
|
+
return benefits;
|
40
|
+
}
|
41
|
+
|
42
|
+
return '';
|
43
|
+
}
|
44
|
+
|
45
|
+
/**
|
46
|
+
* @param {string|undefined} excludeFromSearch
|
47
|
+
* @returns {string}
|
48
|
+
*/
|
49
|
+
function mapExcludeFromSearch(excludeFromSearch) {
|
50
|
+
if (excludeFromSearch) {
|
51
|
+
return excludeFromSearch;
|
52
|
+
}
|
53
|
+
|
54
|
+
return '';
|
55
|
+
}
|
56
|
+
|
57
|
+
/**
|
58
|
+
* @param {string|undefined} usage
|
59
|
+
* @returns {string}
|
60
|
+
*/
|
61
|
+
function mapUsage(usage) {
|
62
|
+
if (usage) {
|
63
|
+
return usage;
|
64
|
+
}
|
65
|
+
|
66
|
+
return '';
|
67
|
+
}
|
68
|
+
|
69
|
+
/**
|
70
|
+
* @param {string|undefined} description
|
71
|
+
* @returns {string}
|
72
|
+
*/
|
73
|
+
function mapDescription(description) {
|
74
|
+
if (description) {
|
75
|
+
return description;
|
76
|
+
}
|
77
|
+
|
78
|
+
return '';
|
79
|
+
}
|
80
|
+
|
81
|
+
/**
|
82
|
+
* @param {string|undefined} chargeShipping
|
83
|
+
* @returns {string}
|
84
|
+
*/
|
85
|
+
function mapChargeShipping(chargeShipping) {
|
86
|
+
if (chargeShipping) {
|
87
|
+
return chargeShipping;
|
88
|
+
}
|
89
|
+
|
90
|
+
return '';
|
91
|
+
}
|
92
|
+
|
93
|
+
/**
|
94
|
+
* @param {string|undefined} globalProductId
|
95
|
+
* @returns {string}
|
96
|
+
*/
|
97
|
+
function mapGlobalProductId(globalProductId) {
|
98
|
+
if (globalProductId) {
|
99
|
+
return globalProductId;
|
100
|
+
}
|
101
|
+
|
102
|
+
return '';
|
103
|
+
}
|
104
|
+
|
105
|
+
/**
|
106
|
+
* @param {string|undefined} title
|
107
|
+
* @returns {string}
|
108
|
+
*/
|
109
|
+
function mapTitle(title) {
|
110
|
+
if (title) {
|
111
|
+
return title;
|
112
|
+
}
|
113
|
+
|
114
|
+
return '';
|
115
|
+
}
|
116
|
+
|
117
|
+
/**
|
118
|
+
* @param {string|undefined} scanQualifiedCount
|
119
|
+
* @returns {string}
|
120
|
+
*/
|
121
|
+
function mapScanQualifiedCount(scanQualifiedCount) {
|
122
|
+
if (scanQualifiedCount) {
|
123
|
+
return scanQualifiedCount;
|
124
|
+
}
|
125
|
+
|
126
|
+
return '';
|
127
|
+
}
|
128
|
+
|
129
|
+
/**
|
130
|
+
* @param {string|undefined} division
|
131
|
+
* @returns {string}
|
132
|
+
*/
|
133
|
+
function mapDivision(division) {
|
134
|
+
if (division) {
|
135
|
+
return division;
|
136
|
+
}
|
137
|
+
|
138
|
+
return '';
|
139
|
+
}
|
140
|
+
|
141
|
+
/**
|
142
|
+
* @param {string|undefined} isExclusive
|
143
|
+
* @returns {string}
|
144
|
+
*/
|
145
|
+
function mapIsExclusive(isExclusive) {
|
146
|
+
if (isExclusive) {
|
147
|
+
return isExclusive;
|
148
|
+
}
|
149
|
+
|
150
|
+
return '';
|
151
|
+
}
|
152
|
+
|
153
|
+
/**
|
154
|
+
* @param {string|undefined} imageURL
|
155
|
+
* @returns {string}
|
156
|
+
*/
|
157
|
+
function mapImageURL(imageURL) {
|
158
|
+
if (imageURL) {
|
159
|
+
return imageURL;
|
160
|
+
}
|
161
|
+
|
162
|
+
return '';
|
163
|
+
}
|
164
|
+
|
165
|
+
/**
|
166
|
+
* @param {string|undefined} customerTypes
|
167
|
+
* @returns {string}
|
168
|
+
*/
|
169
|
+
function mapCustomerTypes(customerTypes) {
|
170
|
+
if (customerTypes) {
|
171
|
+
return customerTypes;
|
172
|
+
}
|
173
|
+
|
174
|
+
return '';
|
175
|
+
}
|
176
|
+
|
177
|
+
/**
|
178
|
+
* @param {string|undefined} ingredients
|
179
|
+
* @returns {string}
|
180
|
+
*/
|
181
|
+
function mapIngredients(ingredients) {
|
182
|
+
if (ingredients) {
|
183
|
+
return ingredients;
|
184
|
+
}
|
185
|
+
|
186
|
+
return '';
|
187
|
+
}
|
188
|
+
|
189
|
+
/**
|
190
|
+
* @param {string|undefined} availableChannels
|
191
|
+
* @returns {string}
|
192
|
+
*/
|
193
|
+
function mapAvailableChannels(availableChannels) {
|
194
|
+
if (availableChannels) {
|
195
|
+
return availableChannels;
|
196
|
+
}
|
197
|
+
|
198
|
+
return '';
|
199
|
+
}
|
200
|
+
|
201
|
+
/**
|
202
|
+
* @param {string|undefined} resources
|
203
|
+
* @returns {string}
|
204
|
+
*/
|
205
|
+
function mapResources(resources) {
|
206
|
+
if (resources) {
|
207
|
+
return resources;
|
208
|
+
}
|
209
|
+
|
210
|
+
return '';
|
211
|
+
}
|
212
|
+
|
213
|
+
/**
|
214
|
+
* @param {string|undefined} market
|
215
|
+
* @returns {string}
|
216
|
+
*/
|
217
|
+
function mapMarket(market) {
|
218
|
+
if (market) {
|
219
|
+
return market;
|
220
|
+
}
|
221
|
+
|
222
|
+
return '';
|
223
|
+
}
|
224
|
+
|
225
|
+
/**
|
226
|
+
* @param {string|undefined} size
|
227
|
+
* @returns {string}
|
228
|
+
*/
|
229
|
+
function mapSize(size) {
|
230
|
+
if (size) {
|
231
|
+
return size;
|
232
|
+
}
|
233
|
+
|
234
|
+
return '';
|
235
|
+
}
|
236
|
+
|
237
|
+
/**
|
238
|
+
* @param {string|undefined} name
|
239
|
+
* @returns {string}
|
240
|
+
*/
|
241
|
+
function mapName(name) {
|
242
|
+
if (name) {
|
243
|
+
return name;
|
244
|
+
}
|
245
|
+
|
246
|
+
return '';
|
247
|
+
}
|
248
|
+
|
249
|
+
/**
|
250
|
+
* @param {string|undefined} status
|
251
|
+
* @returns {string}
|
252
|
+
*/
|
253
|
+
function mapStatus(status) {
|
254
|
+
if (status) {
|
255
|
+
return status;
|
256
|
+
}
|
257
|
+
|
258
|
+
return '';
|
259
|
+
}
|
260
|
+
|
261
|
+
/**
|
262
|
+
* @param {string|undefined} productStatus
|
263
|
+
* @returns {string}
|
264
|
+
*/
|
265
|
+
function mapProductStatus(productStatus) {
|
266
|
+
if (productStatus) {
|
267
|
+
return productStatus;
|
268
|
+
}
|
269
|
+
|
270
|
+
return '';
|
271
|
+
}
|
272
|
+
|
273
|
+
module.exports = mapVariantProperties;
|
@@ -0,0 +1,48 @@
|
|
1
|
+
// @ts-check
|
2
|
+
const { mapIdentifier, mapProperties, mapVariant } = require('../mappers');
|
3
|
+
|
4
|
+
/**
|
5
|
+
* @param {import('../').EquinoxNormalProduct} product
|
6
|
+
* @param {string} market
|
7
|
+
* @returns {import('../').EquinoxNormalProduct}
|
8
|
+
*/
|
9
|
+
function productNotFound(product, market) {
|
10
|
+
/** @type {import('../').EquinoxNormalProduct} */
|
11
|
+
const model = {};
|
12
|
+
model.identifier = mapIdentifier(` ${product.identifier}`);
|
13
|
+
model.properties = mapProperties();
|
14
|
+
model.exists = mapExists(product.exists);
|
15
|
+
model.sku = [mapVariant({
|
16
|
+
// adding a whitespace allows us to display an SKU with 55
|
17
|
+
// without initializing the variant selector of ns-product-small
|
18
|
+
identifier: ` ${product.identifier}`,
|
19
|
+
properties: {
|
20
|
+
availableChannels: 'subscription,arsPhone,kiosk,mobile,web',
|
21
|
+
customerTypes: 'BrandAffiliate,Preferred,Retail',
|
22
|
+
description: 'not-found',
|
23
|
+
imageURL: 'https://nuskin.com/content/dam/global/images/products/01102730-nu-skin-tri-phasic-white-essence.png',
|
24
|
+
isExclusive: 'false',
|
25
|
+
market,
|
26
|
+
name: ` ${product.identifier}`,
|
27
|
+
productStatus: 'stopped',
|
28
|
+
scanQualifiedCount: '0',
|
29
|
+
status: 'active',
|
30
|
+
title: ` ${product.identifier}`
|
31
|
+
}
|
32
|
+
})];
|
33
|
+
|
34
|
+
return model;
|
35
|
+
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
* @param {boolean|undefined} exists
|
39
|
+
*/
|
40
|
+
function mapExists(exists) {
|
41
|
+
if (exists === undefined) {
|
42
|
+
return true;
|
43
|
+
}
|
44
|
+
|
45
|
+
return exists;
|
46
|
+
}
|
47
|
+
|
48
|
+
module.exports = productNotFound;
|
package/src/product.js
CHANGED
@@ -75,8 +75,15 @@ const Product = function (productData) {
|
|
75
75
|
//equinox inventory / stock label
|
76
76
|
//@example "IN STOCK"
|
77
77
|
this.inventory = "";
|
78
|
+
|
79
|
+
// equinox specific properties
|
78
80
|
this.equinoxProductId = "";
|
79
81
|
this.properties = {};
|
82
|
+
this.equinox = {
|
83
|
+
sku: {
|
84
|
+
exists: true
|
85
|
+
}
|
86
|
+
};
|
80
87
|
|
81
88
|
this.setMarketAttributes = function (productStatus) {
|
82
89
|
if (productStatus.marketAttributes) {
|
@@ -540,6 +547,11 @@ const Product = function (productData) {
|
|
540
547
|
retData.inventory = this.inventory;
|
541
548
|
retData.equinoxProductId = this.equinoxProductId;
|
542
549
|
retData.properties = this.properties;
|
550
|
+
retData.equinox = {
|
551
|
+
sku: {
|
552
|
+
exists: this.equinox.sku.exists
|
553
|
+
}
|
554
|
+
};
|
543
555
|
|
544
556
|
return retData;
|
545
557
|
};
|
@@ -682,6 +694,14 @@ const Product = function (productData) {
|
|
682
694
|
|
683
695
|
this.equinoxProductId = data.equinoxProductId;
|
684
696
|
this.properties = data.properties;
|
697
|
+
|
698
|
+
if (data.equinox && data.equinox.sku) {
|
699
|
+
this.equinox = {
|
700
|
+
sku: {
|
701
|
+
exists: data.equinox.sku.exists
|
702
|
+
}
|
703
|
+
};
|
704
|
+
}
|
685
705
|
}
|
686
706
|
};
|
687
707
|
|
package/src/productData.js
CHANGED
@@ -6,6 +6,7 @@ const Product = require("./product");
|
|
6
6
|
const CustomerTypes = require('./models/customerTypes');
|
7
7
|
const ProductStatus = require("./models/productStatus");
|
8
8
|
const { mapAvailableQuantity, mapChildSKU } = require('./equinox-helpers');
|
9
|
+
const { productNotFoundInterceptor } = require('./equinox-helpers/interceptors');
|
9
10
|
|
10
11
|
const productTypes = {
|
11
12
|
kit: 'kit'
|
@@ -69,6 +70,7 @@ const ProductData = {
|
|
69
70
|
|
70
71
|
const url = `${config.API_Base_URLs}/orchestrationservices/storefront/catalogs/search/`;
|
71
72
|
const href = `${url}?filter='\\\\''${encodeURI(filter)}'\\''`;
|
73
|
+
axios.interceptors.response.use((res) => res, productNotFoundInterceptor);
|
72
74
|
const response = await axios.request({
|
73
75
|
method: 'get',
|
74
76
|
url: href,
|
@@ -81,6 +83,7 @@ const ProductData = {
|
|
81
83
|
withCredentials: true
|
82
84
|
});
|
83
85
|
|
86
|
+
axios.interceptors.response.eject(productNotFoundInterceptor);
|
84
87
|
return response;
|
85
88
|
},
|
86
89
|
|
@@ -478,7 +481,12 @@ const ProductData = {
|
|
478
481
|
"addOns": [],
|
479
482
|
"inventory": product.inventory || "", //inventory label
|
480
483
|
"equinoxProductId": productData.identifier,
|
481
|
-
"properties": product.properties
|
484
|
+
"properties": product.properties,
|
485
|
+
equinox: {
|
486
|
+
sku: {
|
487
|
+
exists: this.mapEquinoxSKUExists(productData.exists)
|
488
|
+
}
|
489
|
+
}
|
482
490
|
};
|
483
491
|
|
484
492
|
products.push(new Product(product));
|
@@ -502,6 +510,17 @@ const ProductData = {
|
|
502
510
|
};
|
503
511
|
},
|
504
512
|
|
513
|
+
mapEquinoxSKUExists: function(exists) {
|
514
|
+
// this could be avoided if only we are using response mapper
|
515
|
+
// for equinox products that exists.
|
516
|
+
// @todo: clean-up
|
517
|
+
if (exists === undefined) {
|
518
|
+
return true;
|
519
|
+
}
|
520
|
+
|
521
|
+
return exists;
|
522
|
+
},
|
523
|
+
|
505
524
|
/**
|
506
525
|
* fetchChildSkus make requests to Equinox to get the SKUs of a kit.
|
507
526
|
* @param {*} product
|