@nuskin/product-components 3.6.4 → 3.6.5
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
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [3.6.5](https://code.tls.nuskin.io/ns-am/ux/product-components/compare/v3.6.4...v3.6.5) (2023-06-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Fix
|
|
5
|
+
|
|
6
|
+
* use recommended product API (CX16-9278) ([28a5f29](https://code.tls.nuskin.io/ns-am/ux/product-components/commit/28a5f296474ac0bae22de726dcd39afae9b771a0))
|
|
7
|
+
|
|
1
8
|
## [3.6.4](https://code.tls.nuskin.io/ns-am/ux/product-components/compare/v3.6.3...v3.6.4) (2023-06-06)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -118,7 +118,7 @@ import Product from "../../models/product";
|
|
|
118
118
|
import Price from "./Price.vue";
|
|
119
119
|
import get from "lodash/get";
|
|
120
120
|
import {
|
|
121
|
-
|
|
121
|
+
findProductsById,
|
|
122
122
|
getProductTranslations
|
|
123
123
|
} from "../../services/NsProductContentService";
|
|
124
124
|
|
|
@@ -340,9 +340,10 @@ export default {
|
|
|
340
340
|
this.loading = true;
|
|
341
341
|
|
|
342
342
|
try {
|
|
343
|
-
const products = await
|
|
343
|
+
const products = await findProductsById(
|
|
344
344
|
sliderProductIds,
|
|
345
|
-
this.country
|
|
345
|
+
this.country,
|
|
346
|
+
this.language
|
|
346
347
|
);
|
|
347
348
|
|
|
348
349
|
this.products = sliderProductIds
|
|
@@ -381,10 +382,7 @@ export default {
|
|
|
381
382
|
},
|
|
382
383
|
|
|
383
384
|
initProductTranslations() {
|
|
384
|
-
getProductTranslations(
|
|
385
|
-
["addToCartButton"],
|
|
386
|
-
this.country + "-" + this.language
|
|
387
|
-
)
|
|
385
|
+
getProductTranslations(["addToCartButton"], this.country, this.language)
|
|
388
386
|
.then(translations => {
|
|
389
387
|
this.translations = translations;
|
|
390
388
|
})
|
package/cyclonedx-npm-yarn.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"bomFormat": "CycloneDX",
|
|
3
3
|
"specVersion": "1.4",
|
|
4
|
-
"serialNumber": "urn:uuid:
|
|
4
|
+
"serialNumber": "urn:uuid:e2145c59-f65d-4d51-a466-361d36d2bed4",
|
|
5
5
|
"version": 1,
|
|
6
6
|
"metadata": {
|
|
7
|
-
"timestamp": "2023-06-
|
|
7
|
+
"timestamp": "2023-06-06T22:53:20Z",
|
|
8
8
|
"tools": [
|
|
9
9
|
{
|
|
10
10
|
"vendor": "GitLab",
|
package/package.json
CHANGED
|
@@ -33,52 +33,47 @@ import { RunConfigService } from "@nuskin/ns-util";
|
|
|
33
33
|
* @property {string} [status.backorderedAvailableDate]
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
query CombinedIdsProductsQuery($uids: [String!]!, $skus: [String!]!, $locale: String) {
|
|
75
|
-
productsBySku(skus: $skus, locale: $locale) {
|
|
76
|
-
${productFields}
|
|
77
|
-
}
|
|
78
|
-
productsByUid(uids: $uids, locale: $locale) {
|
|
79
|
-
${productFields}
|
|
36
|
+
const ProductsByIdQuery = `
|
|
37
|
+
query ProductsById($ids: [String!]!, $market: String, $language: String) {
|
|
38
|
+
productsById(ids: $ids, market: $market, language: $language, quantity: 1) {
|
|
39
|
+
products {
|
|
40
|
+
id
|
|
41
|
+
title
|
|
42
|
+
productImages {
|
|
43
|
+
url
|
|
44
|
+
alt
|
|
45
|
+
}
|
|
46
|
+
slug
|
|
47
|
+
salesLabel
|
|
48
|
+
variants {
|
|
49
|
+
sku
|
|
50
|
+
variantLabel
|
|
51
|
+
isExclusive
|
|
52
|
+
availableQuantity
|
|
53
|
+
productImages {
|
|
54
|
+
url
|
|
55
|
+
alt
|
|
56
|
+
}
|
|
57
|
+
pricingJson
|
|
58
|
+
price {
|
|
59
|
+
currencyCode
|
|
60
|
+
retail
|
|
61
|
+
retailSales
|
|
62
|
+
retailSubscription
|
|
63
|
+
wholesale
|
|
64
|
+
wholesaleSales
|
|
65
|
+
wholesaleSubscription
|
|
66
|
+
}
|
|
67
|
+
status {
|
|
68
|
+
status
|
|
69
|
+
isBackordered
|
|
70
|
+
backorderedAvailableDate
|
|
71
|
+
}
|
|
72
|
+
primaryBrand
|
|
73
|
+
}
|
|
80
74
|
}
|
|
81
75
|
}
|
|
76
|
+
}
|
|
82
77
|
`;
|
|
83
78
|
|
|
84
79
|
/**
|
|
@@ -86,8 +81,8 @@ const CombinedIdsProductsQuery = `
|
|
|
86
81
|
* @returns {string}
|
|
87
82
|
*/
|
|
88
83
|
const productTranslationsQuery = fields => `
|
|
89
|
-
query ProductTranslationsQuery($
|
|
90
|
-
|
|
84
|
+
query ProductTranslationsQuery($market: String, $language: String) {
|
|
85
|
+
pdpStrings(market: $market, language: $language) {
|
|
91
86
|
${fields.join("\n")}
|
|
92
87
|
}
|
|
93
88
|
}
|
|
@@ -99,55 +94,54 @@ function getProductGraphqlUrl() {
|
|
|
99
94
|
|
|
100
95
|
switch (env) {
|
|
101
96
|
case "dev":
|
|
102
|
-
return "https://
|
|
97
|
+
return "https://test.nuskin.com/product-api/graphql";
|
|
103
98
|
case "stage":
|
|
104
99
|
case "test":
|
|
105
|
-
return "https://
|
|
100
|
+
return "https://test.nuskin.com/product-api/graphql";
|
|
106
101
|
case "unknown":
|
|
107
102
|
case "prod":
|
|
108
103
|
default:
|
|
109
|
-
return "https://
|
|
104
|
+
return "https://www.nuskin.com/product-api/graphql";
|
|
110
105
|
}
|
|
111
106
|
}
|
|
112
107
|
|
|
113
108
|
/**
|
|
114
109
|
* Retrieves product data for the given SKUs and/or product UIDs
|
|
115
110
|
* @param {string[]} ids Product IDs; can be SKUs and/or UIDs
|
|
116
|
-
* @param {string}
|
|
111
|
+
* @param {string} market Market country code
|
|
112
|
+
* @param {string} language Market language code
|
|
117
113
|
* @return {Promise<ProductData[]>}
|
|
118
114
|
*/
|
|
119
|
-
export async function
|
|
115
|
+
export async function findProductsById(ids, market, language) {
|
|
120
116
|
const url = getProductGraphqlUrl();
|
|
121
117
|
|
|
122
|
-
const skus = ids.filter(id => /^\d{8}$/.test(id));
|
|
123
|
-
const uids = ids.filter(id => /^blt[0-9a-f]{16}$/.test(id));
|
|
124
|
-
|
|
125
118
|
const response = await axios.post(url, {
|
|
126
|
-
query:
|
|
127
|
-
variables: {
|
|
119
|
+
query: ProductsByIdQuery,
|
|
120
|
+
variables: { ids, market, language }
|
|
128
121
|
});
|
|
129
122
|
|
|
130
|
-
if (!response.data) return [];
|
|
131
|
-
|
|
132
|
-
const uidProducts = response.data.data.productsByUid || [];
|
|
133
|
-
const skuProducts = response.data.data.productsBySku || [];
|
|
123
|
+
if (!response.data || !response.data.data) return [];
|
|
134
124
|
|
|
135
|
-
return
|
|
125
|
+
return response.data.data.productsById.products;
|
|
136
126
|
}
|
|
137
127
|
|
|
138
128
|
/**
|
|
139
129
|
* @param {string[]} fields Product string fields to get
|
|
140
|
-
* @param {string}
|
|
130
|
+
* @param {string} market Market country code
|
|
131
|
+
* @param {string} language Market language code
|
|
141
132
|
*/
|
|
142
|
-
export async function getProductTranslations(fields,
|
|
133
|
+
export async function getProductTranslations(fields, market, language) {
|
|
134
|
+
// If no fields are specified, don't bother attempting an API query
|
|
135
|
+
if (fields.length === 0) return {};
|
|
136
|
+
|
|
143
137
|
const url = getProductGraphqlUrl();
|
|
144
138
|
const query = productTranslationsQuery(fields);
|
|
145
139
|
|
|
146
140
|
const response = await axios.post(url, {
|
|
147
141
|
query,
|
|
148
|
-
variables: {
|
|
142
|
+
variables: { market, language }
|
|
149
143
|
});
|
|
150
144
|
|
|
151
145
|
if (!response.data || !response.data.data) return {};
|
|
152
|
-
return response.data.data.
|
|
146
|
+
return response.data.data.pdpStrings || {};
|
|
153
147
|
}
|