@cloudcommerce/app-tiny-erp 0.0.109 → 0.0.111

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.
@@ -3,195 +3,197 @@ import axios from 'axios';
3
3
  import FormData from 'form-data';
4
4
  import ecomUtils from '@ecomplus/utils';
5
5
  import getEnv from '@cloudcommerce/firebase/lib/env';
6
+
6
7
  const removeAccents = (str) => str.replace(/áàãâÁÀÃÂ/g, 'a')
7
- .replace(/éêÉÊ/g, 'e')
8
- .replace(/óõôÓÕÔ/g, 'o')
9
- .replace(/íÍ/g, 'e')
10
- .replace(/úÚ/g, 'u')
11
- .replace(/çÇ/g, 'c');
8
+ .replace(/éêÉÊ/g, 'e')
9
+ .replace(/óõôÓÕÔ/g, 'o')
10
+ .replace(/íÍ/g, 'e')
11
+ .replace(/úÚ/g, 'u')
12
+ .replace(/çÇ/g, 'c');
12
13
  const tryImageUpload = (originImgUrl, product) => new Promise((resolve) => {
13
- const { storeId, apiAuth: { authenticationId, apiKey, }, } = getEnv();
14
- axios.get(originImgUrl, {
15
- responseType: 'arraybuffer',
16
- }).then(({ data }) => {
17
- const form = new FormData();
18
- form.append('file', Buffer.from(data), originImgUrl.replace(/.*\/([^/]+)$/, '$1'));
19
- return axios.post(`https://apx-storage.e-com.plus/${storeId}/api/v1/upload.json`, form, {
20
- headers: {
21
- ...form.getHeaders(),
22
- 'X-Store-ID': storeId,
23
- 'X-My-ID': authenticationId,
24
- 'X-API-Key': apiKey,
25
- },
26
- }).then(({ data, status }) => {
27
- if (data.picture) {
28
- Object.keys(data.picture).forEach((imgSize) => {
29
- if (data.picture[imgSize]) {
30
- if (!data.picture[imgSize].url) {
31
- delete data.picture[imgSize];
32
- return;
33
- }
34
- if (data.picture[imgSize].size !== undefined) {
35
- delete data.picture[imgSize].size;
36
- }
37
- data.picture[imgSize].alt = `${product.name} (${imgSize})`;
38
- }
39
- });
40
- if (Object.keys(data.picture).length) {
41
- return resolve({
42
- _id: ecomUtils.randomObjectId(),
43
- ...data.picture,
44
- });
45
- }
14
+ const { storeId, apiAuth: { authenticationId, apiKey } } = getEnv();
15
+ axios.get(originImgUrl, {
16
+ responseType: 'arraybuffer',
17
+ }).then(({ data }) => {
18
+ const form = new FormData();
19
+ form.append('file', Buffer.from(data), originImgUrl.replace(/.*\/([^/]+)$/, '$1'));
20
+ return axios.post(`https://apx-storage.e-com.plus/${storeId}/api/v1/upload.json`, form, {
21
+ headers: {
22
+ ...form.getHeaders(),
23
+ 'X-Store-ID': storeId,
24
+ 'X-My-ID': authenticationId,
25
+ 'X-API-Key': apiKey,
26
+ },
27
+ }).then(({ data, status }) => {
28
+ if (data.picture) {
29
+ Object.keys(data.picture).forEach((imgSize) => {
30
+ if (data.picture[imgSize]) {
31
+ if (!data.picture[imgSize].url) {
32
+ delete data.picture[imgSize];
33
+ return;
46
34
  }
47
- const err = new Error('Unexpected Storage API response');
48
- err.response = { data, status };
49
- throw err;
35
+ if (data.picture[imgSize].size !== undefined) {
36
+ delete data.picture[imgSize].size;
37
+ }
38
+ data.picture[imgSize].alt = `${product.name} (${imgSize})`;
39
+ }
50
40
  });
51
- })
52
- .catch((err) => {
53
- logger.error(err);
54
- resolve({
41
+ if (Object.keys(data.picture).length) {
42
+ return resolve({
55
43
  _id: ecomUtils.randomObjectId(),
56
- normal: {
57
- url: originImgUrl,
58
- alt: product.name,
59
- },
60
- });
44
+ ...data.picture,
45
+ });
46
+ }
47
+ }
48
+ const err = new Error('Unexpected Storage API response');
49
+ err.response = { data, status };
50
+ throw err;
51
+ });
52
+ })
53
+ .catch((err) => {
54
+ logger.error(err);
55
+ resolve({
56
+ _id: ecomUtils.randomObjectId(),
57
+ normal: {
58
+ url: originImgUrl,
59
+ alt: product.name,
60
+ },
61
+ });
61
62
  });
62
63
  }).then((picture) => {
63
- if (product && product.pictures) {
64
- // @ts-ignore
65
- product.pictures.push(picture);
66
- }
67
- return picture;
64
+ if (product && product.pictures) {
65
+ // @ts-ignore
66
+ product.pictures.push(picture);
67
+ }
68
+ return picture;
68
69
  });
70
+
69
71
  export default (tinyProduct, isNew = true) => new Promise((resolve) => {
70
- const sku = tinyProduct.codigo || String(tinyProduct.id);
71
- const name = (tinyProduct.nome || sku).trim();
72
- const product = {
73
- available: tinyProduct.situacao === 'A',
74
- sku,
75
- name,
76
- cost_price: tinyProduct.preco_custo,
77
- price: tinyProduct.preco_promocional || tinyProduct.preco,
78
- base_price: tinyProduct.preco,
79
- body_html: tinyProduct.descricao_complementar,
80
- };
81
- if (isNew) {
82
- product.slug = removeAccents(name.toLowerCase())
83
- .replace(/\s+/g, '-')
84
- .replace(/[^a-z0-9-_./]/g, '');
85
- if (!/[a-z0-9]/.test(product.slug.charAt(0))) {
86
- product.slug = `p-${product.slug}`;
87
- }
88
- }
89
- if (tinyProduct.garantia) {
90
- product.warranty = tinyProduct.garantia;
91
- }
92
- if (tinyProduct.unidade_por_caixa) {
93
- product.min_quantity = Number(tinyProduct.unidade_por_caixa);
72
+ const sku = tinyProduct.codigo || String(tinyProduct.id);
73
+ const name = (tinyProduct.nome || sku).trim();
74
+ const product = {
75
+ available: tinyProduct.situacao === 'A',
76
+ sku,
77
+ name,
78
+ cost_price: tinyProduct.preco_custo,
79
+ price: tinyProduct.preco_promocional || tinyProduct.preco,
80
+ base_price: tinyProduct.preco,
81
+ body_html: tinyProduct.descricao_complementar,
82
+ };
83
+ if (isNew) {
84
+ product.slug = removeAccents(name.toLowerCase())
85
+ .replace(/\s+/g, '-')
86
+ .replace(/[^a-z0-9-_./]/g, '');
87
+ if (!/[a-z0-9]/.test(product.slug.charAt(0))) {
88
+ product.slug = `p-${product.slug}`;
94
89
  }
95
- if (tinyProduct.ncm) {
96
- product.mpn = [tinyProduct.ncm];
90
+ }
91
+ if (tinyProduct.garantia) {
92
+ product.warranty = tinyProduct.garantia;
93
+ }
94
+ if (tinyProduct.unidade_por_caixa) {
95
+ product.min_quantity = Number(tinyProduct.unidade_por_caixa);
96
+ }
97
+ if (tinyProduct.ncm) {
98
+ product.mpn = [tinyProduct.ncm];
99
+ }
100
+ const validateGtin = (gtin) => {
101
+ return typeof gtin === 'string' && /^([0-9]{8}|[0-9]{12,14})$/.test(gtin);
102
+ };
103
+ if (validateGtin(tinyProduct.gtin)) {
104
+ product.gtin = [tinyProduct.gtin];
105
+ if (validateGtin(tinyProduct.gtin_embalagem)) {
106
+ product.gtin.push(tinyProduct.gtin_embalagem);
97
107
  }
98
- const validateGtin = (gtin) => {
99
- return typeof gtin === 'string' && /^([0-9]{8}|[0-9]{12,14})$/.test(gtin);
108
+ }
109
+ const weight = tinyProduct.peso_bruto || tinyProduct.peso_liquido;
110
+ if (weight > 0) {
111
+ product.weight = {
112
+ unit: 'kg',
113
+ value: parseFloat(weight),
100
114
  };
101
- if (validateGtin(tinyProduct.gtin)) {
102
- product.gtin = [tinyProduct.gtin];
103
- if (validateGtin(tinyProduct.gtin_embalagem)) {
104
- product.gtin.push(tinyProduct.gtin_embalagem);
105
- }
106
- }
107
- const weight = tinyProduct.peso_bruto || tinyProduct.peso_liquido;
108
- if (weight > 0) {
109
- product.weight = {
110
- unit: 'kg',
111
- value: parseFloat(weight),
112
- };
115
+ }
116
+ [
117
+ ['largura', 'width'],
118
+ ['altura', 'height'],
119
+ ['comprimento', 'length'],
120
+ ].forEach(([lado, side]) => {
121
+ const dimension = tinyProduct[`${lado}_embalagem`] || tinyProduct[`${lado}Embalagem`];
122
+ if (dimension > 0) {
123
+ if (!product.dimensions) {
124
+ product.dimensions = {};
125
+ }
126
+ product.dimensions[side] = {
127
+ unit: 'cm',
128
+ value: parseFloat(dimension),
129
+ };
113
130
  }
114
- [
115
- ['largura', 'width'],
116
- ['altura', 'height'],
117
- ['comprimento', 'length'],
118
- ].forEach(([lado, side]) => {
119
- const dimension = tinyProduct[`${lado}_embalagem`] || tinyProduct[`${lado}Embalagem`];
120
- if (dimension > 0) {
121
- if (!product.dimensions) {
122
- product.dimensions = {};
131
+ });
132
+ if (isNew) {
133
+ if (Array.isArray(tinyProduct.variacoes) && tinyProduct.variacoes.length) {
134
+ product.variations = [];
135
+ tinyProduct.variacoes.forEach(({ variacao }) => {
136
+ const { codigo, preco, grade } = variacao;
137
+ if (grade && typeof grade === 'object') {
138
+ const specifications = {};
139
+ const specTexts = [];
140
+ Object.keys(grade).forEach((tipo) => {
141
+ if (grade[tipo]) {
142
+ const gridId = removeAccents(tipo.toLowerCase())
143
+ .replace(/\s+/g, '_')
144
+ .replace(/[^a-z0-9_]/g, '')
145
+ .substring(0, 30)
146
+ .padStart(2, 'i');
147
+ const spec = {
148
+ text: grade[tipo],
149
+ };
150
+ specTexts.push(spec.text);
151
+ if (gridId !== 'colors') {
152
+ spec.value = removeAccents(spec.text.toLowerCase()).substring(0, 100);
153
+ }
154
+ specifications[gridId] = [spec];
123
155
  }
124
- product.dimensions[side] = {
125
- unit: 'cm',
126
- value: parseFloat(dimension),
127
- };
128
- }
129
- });
130
- if (isNew) {
131
- if (Array.isArray(tinyProduct.variacoes) && tinyProduct.variacoes.length) {
132
- product.variations = [];
133
- tinyProduct.variacoes.forEach(({ variacao }) => {
134
- const { codigo, preco, grade } = variacao;
135
- if (grade && typeof grade === 'object') {
136
- const specifications = {};
137
- const specTexts = [];
138
- Object.keys(grade).forEach((tipo) => {
139
- if (grade[tipo]) {
140
- const gridId = removeAccents(tipo.toLowerCase())
141
- .replace(/\s+/g, '_')
142
- .replace(/[^a-z0-9_]/g, '')
143
- .substring(0, 30)
144
- .padStart(2, 'i');
145
- const spec = {
146
- text: grade[tipo],
147
- };
148
- specTexts.push(spec.text);
149
- if (gridId !== 'colors') {
150
- spec.value = removeAccents(spec.text.toLowerCase()).substring(0, 100);
151
- }
152
- specifications[gridId] = [spec];
153
- }
154
- });
155
- if (specTexts.length) {
156
- product.variations?.push({
157
- _id: ecomUtils.randomObjectId(),
158
- name: `${name} / ${specTexts.join(' / ')}`.substring(0, 100),
159
- sku: codigo,
160
- specifications,
161
- price: parseFloat(preco || 0),
162
- });
163
- }
164
- }
156
+ });
157
+ if (specTexts.length) {
158
+ product.variations?.push({
159
+ _id: ecomUtils.randomObjectId(),
160
+ name: `${name} / ${specTexts.join(' / ')}`.substring(0, 100),
161
+ sku: codigo,
162
+ specifications,
163
+ price: parseFloat(preco || 0),
165
164
  });
165
+ }
166
166
  }
167
- if (Array.isArray(tinyProduct.imagens_externas)) {
168
- product.pictures = [];
169
- tinyProduct.imagens_externas.forEach((imagemExterna) => {
170
- if (imagemExterna.imagem_externa) {
171
- const { url } = imagemExterna.imagem_externa;
172
- if (url) {
173
- product.pictures?.push({
174
- normal: { url },
175
- _id: ecomUtils.randomObjectId(),
176
- });
177
- }
178
- }
167
+ });
168
+ }
169
+ if (Array.isArray(tinyProduct.imagens_externas)) {
170
+ product.pictures = [];
171
+ tinyProduct.imagens_externas.forEach((imagemExterna) => {
172
+ if (imagemExterna.imagem_externa) {
173
+ const { url } = imagemExterna.imagem_externa;
174
+ if (url) {
175
+ product.pictures?.push({
176
+ normal: { url },
177
+ _id: ecomUtils.randomObjectId(),
179
178
  });
179
+ }
180
180
  }
181
- if (tinyProduct.anexos) {
182
- if (!product.pictures) {
183
- product.pictures = [];
184
- }
185
- const promises = [];
186
- tinyProduct.anexos.forEach(({ anexo }) => {
187
- if (typeof anexo === 'string' && anexo.startsWith('http')) {
188
- promises.push(tryImageUpload(anexo, product));
189
- }
190
- });
191
- Promise.all(promises).then(() => resolve(product));
192
- return;
181
+ });
182
+ }
183
+ if (tinyProduct.anexos) {
184
+ if (!product.pictures) {
185
+ product.pictures = [];
186
+ }
187
+ const promises = [];
188
+ tinyProduct.anexos.forEach(({ anexo }) => {
189
+ if (typeof anexo === 'string' && anexo.startsWith('http')) {
190
+ promises.push(tryImageUpload(anexo, product));
193
191
  }
192
+ });
193
+ Promise.all(promises).then(() => resolve(product));
194
+ return;
194
195
  }
195
- resolve(product);
196
+ }
197
+ resolve(product);
196
198
  });
197
- //# sourceMappingURL=product-from-tiny.js.map
199
+ // # sourceMappingURL=product-from-tiny.js.map
@@ -1,133 +1,129 @@
1
1
  import ecomUtils from '@ecomplus/utils';
2
+
2
3
  export default async (product, originalTinyProduct, appData) => {
3
- const hasVariations = product.variations && product.variations.length;
4
- const tinyProduct = {
5
- sequencia: 1,
6
- origem: 0,
7
- situacao: product.available && product.visible ? 'A' : 'I',
8
- tipo: 'P',
9
- classe_produto: hasVariations ? 'V' : 'S',
10
- codigo: product.sku,
11
- nome: ecomUtils.name(product, 'pt_br').substring(0, 120),
12
- unidade: originalTinyProduct && originalTinyProduct.unidade
13
- ? originalTinyProduct.unidade
14
- : product.measurement && product.measurement.unit !== 'oz' && product.measurement.unit !== 'ct'
15
- ? product.measurement.unit.substring(0, 3).toUpperCase()
16
- : 'UN',
17
- };
18
- if (ecomUtils.onPromotion(product)) {
19
- tinyProduct.preco = product.base_price;
20
- tinyProduct.preco_promocional = ecomUtils.price(product);
21
- }
22
- else {
23
- tinyProduct.preco = product.price;
24
- }
25
- if (product.cost_price) {
26
- tinyProduct.preco_custo = product.cost_price;
27
- }
28
- if (product.min_quantity) {
29
- tinyProduct.unidade_por_caixa = product.min_quantity < 1000
30
- ? String(product.min_quantity) : '999';
31
- }
32
- if (product.short_description) {
33
- tinyProduct.descricao_complementar = product.short_description;
34
- }
35
- if (product.warranty) {
36
- tinyProduct.garantia = product.warranty.substring(0, 20);
37
- }
38
- if (product.mpn && product.mpn.length) {
39
- [tinyProduct.ncm] = product.mpn;
40
- }
41
- if (product.gtin && product.gtin.length) {
42
- [tinyProduct.gtin] = product.gtin;
43
- if (product.gtin[1]) {
44
- // eslint-disable-next-line prefer-destructuring
45
- tinyProduct.gtin_embalagem = product.gtin[1];
46
- }
47
- }
48
- if (product.weight && product.weight.value) {
49
- tinyProduct.peso_bruto = product.weight.value;
50
- if (product.weight.unit === 'mg') {
51
- tinyProduct.peso_bruto /= 1000000;
4
+ const hasVariations = product.variations && product.variations.length;
5
+ const tinyProduct = {
6
+ sequencia: 1,
7
+ origem: 0,
8
+ situacao: product.available && product.visible ? 'A' : 'I',
9
+ tipo: 'P',
10
+ classe_produto: hasVariations ? 'V' : 'S',
11
+ codigo: product.sku,
12
+ nome: ecomUtils.name(product, 'pt_br').substring(0, 120),
13
+ unidade: originalTinyProduct && originalTinyProduct.unidade
14
+ ? originalTinyProduct.unidade
15
+ : product.measurement && product.measurement.unit !== 'oz' && product.measurement.unit !== 'ct'
16
+ ? product.measurement.unit.substring(0, 3).toUpperCase()
17
+ : 'UN',
18
+ };
19
+ if (ecomUtils.onPromotion(product)) {
20
+ tinyProduct.preco = product.base_price;
21
+ tinyProduct.preco_promocional = ecomUtils.price(product);
22
+ } else {
23
+ tinyProduct.preco = product.price;
24
+ }
25
+ if (product.cost_price) {
26
+ tinyProduct.preco_custo = product.cost_price;
27
+ }
28
+ if (product.min_quantity) {
29
+ tinyProduct.unidade_por_caixa = product.min_quantity < 1000
30
+ ? String(product.min_quantity) : '999';
31
+ }
32
+ if (product.short_description) {
33
+ tinyProduct.descricao_complementar = product.short_description;
34
+ }
35
+ if (product.warranty) {
36
+ tinyProduct.garantia = product.warranty.substring(0, 20);
37
+ }
38
+ if (product.mpn && product.mpn.length) {
39
+ [tinyProduct.ncm] = product.mpn;
40
+ }
41
+ if (product.gtin && product.gtin.length) {
42
+ [tinyProduct.gtin] = product.gtin;
43
+ if (product.gtin[1]) {
44
+ // eslint-disable-next-line prefer-destructuring
45
+ tinyProduct.gtin_embalagem = product.gtin[1];
46
+ }
47
+ }
48
+ if (product.weight && product.weight.value) {
49
+ tinyProduct.peso_bruto = product.weight.value;
50
+ if (product.weight.unit === 'mg') {
51
+ tinyProduct.peso_bruto /= 1000000;
52
+ } else if (product.weight.unit === 'g') {
53
+ tinyProduct.peso_bruto /= 1000;
54
+ }
55
+ }
56
+ const { dimensions } = product;
57
+ if (dimensions) {
58
+ Object.keys(dimensions).forEach((side) => {
59
+ if (dimensions[side] && dimensions[side].value) {
60
+ let field = side === 'width' ? 'largura'
61
+ : side === 'height' ? 'altura'
62
+ : 'comprimento';
63
+ field += '_embalagem';
64
+ tinyProduct[field] = dimensions[side].value;
65
+ if (dimensions[side].unit === 'mm') {
66
+ tinyProduct[field] *= 0.1;
67
+ } else if (dimensions[side].unit === 'm') {
68
+ tinyProduct[field] *= 100;
52
69
  }
53
- else if (product.weight.unit === 'g') {
54
- tinyProduct.peso_bruto /= 1000;
55
- }
56
- }
57
- const { dimensions } = product;
58
- if (dimensions) {
59
- Object.keys(dimensions).forEach((side) => {
60
- if (dimensions[side] && dimensions[side].value) {
61
- let field = side === 'width' ? 'largura'
62
- : side === 'height' ? 'altura'
63
- : 'comprimento';
64
- field += '_embalagem';
65
- tinyProduct[field] = dimensions[side].value;
66
- if (dimensions[side].unit === 'mm') {
67
- tinyProduct[field] *= 0.1;
68
- }
69
- else if (dimensions[side].unit === 'm') {
70
- tinyProduct[field] *= 100;
71
- }
72
- }
70
+ }
71
+ });
72
+ }
73
+ if (product.brands && product.brands.length) {
74
+ tinyProduct.marca = product.brands[0].name;
75
+ }
76
+ if (product.category_tree) {
77
+ tinyProduct.categoria = product.category_tree.replace(/\s?>\s?/g, ' >> ');
78
+ } else if (product.categories && product.categories.length) {
79
+ tinyProduct.categoria = product.categories.map(({ name }) => name).join(' >> ');
80
+ }
81
+ if (product.pictures && product.pictures.length) {
82
+ tinyProduct.anexos = [];
83
+ product.pictures.forEach(({ zoom, big, normal }) => {
84
+ const img = (zoom || big || normal);
85
+ if (img) {
86
+ tinyProduct.anexos.push({
87
+ anexo: img.url,
73
88
  });
74
- }
75
- if (product.brands && product.brands.length) {
76
- tinyProduct.marca = product.brands[0].name;
77
- }
78
- if (product.category_tree) {
79
- tinyProduct.categoria = product.category_tree.replace(/\s?>\s?/g, ' >> ');
80
- }
81
- else if (product.categories && product.categories.length) {
82
- tinyProduct.categoria = product.categories.map(({ name }) => name).join(' >> ');
83
- }
84
- if (product.pictures && product.pictures.length) {
85
- tinyProduct.anexos = [];
86
- product.pictures.forEach(({ zoom, big, normal }) => {
87
- const img = (zoom || big || normal);
88
- if (img) {
89
- tinyProduct.anexos.push({
90
- anexo: img.url,
91
- });
92
- }
93
- });
94
- }
95
- if (originalTinyProduct) {
96
- tinyProduct.id = originalTinyProduct.id;
97
- if (!appData.update_price) {
98
- ['preco', 'preco_promocional', 'preco_custo'].forEach((field) => {
99
- if (typeof originalTinyProduct[field] === 'number') {
100
- tinyProduct[field] = originalTinyProduct[field];
101
- }
102
- });
89
+ }
90
+ });
91
+ }
92
+ if (originalTinyProduct) {
93
+ tinyProduct.id = originalTinyProduct.id;
94
+ if (!appData.update_price) {
95
+ ['preco', 'preco_promocional', 'preco_custo'].forEach((field) => {
96
+ if (typeof originalTinyProduct[field] === 'number') {
97
+ tinyProduct[field] = originalTinyProduct[field];
103
98
  }
104
- }
105
- else {
106
- tinyProduct.estoque_atual = product.quantity || 0;
107
- }
108
- if (hasVariations) {
109
- tinyProduct.variacoes = [];
110
- product.variations?.forEach((variation, i) => {
111
- const tinyVariation = {
112
- codigo: variation.sku || `${product.sku}-${(i + 1)}`,
113
- grade: {},
114
- };
115
- if (!originalTinyProduct) {
116
- tinyVariation.estoque_atual = variation.quantity || 0;
117
- }
118
- Object.keys(variation.specifications).forEach((gridId) => {
119
- const gridOptions = variation.specifications[gridId];
120
- if (gridOptions && gridOptions.length) {
121
- gridOptions.forEach(({ text }, i) => {
122
- tinyVariation.grade[i === 0 ? gridId : `${gridId}_${(i + 1)}`] = text;
123
- });
124
- }
125
- });
126
- tinyProduct.variacoes.push({
127
- variacao: tinyVariation,
128
- });
129
- });
130
- }
131
- return tinyProduct;
99
+ });
100
+ }
101
+ } else {
102
+ tinyProduct.estoque_atual = product.quantity || 0;
103
+ }
104
+ if (hasVariations) {
105
+ tinyProduct.variacoes = [];
106
+ product.variations?.forEach((variation, i) => {
107
+ const tinyVariation = {
108
+ codigo: variation.sku || `${product.sku}-${(i + 1)}`,
109
+ grade: {},
110
+ };
111
+ if (!originalTinyProduct) {
112
+ tinyVariation.estoque_atual = variation.quantity || 0;
113
+ }
114
+ Object.keys(variation.specifications).forEach((gridId) => {
115
+ const gridOptions = variation.specifications[gridId];
116
+ if (gridOptions && gridOptions.length) {
117
+ gridOptions.forEach(({ text }, i) => {
118
+ tinyVariation.grade[i === 0 ? gridId : `${gridId}_${(i + 1)}`] = text;
119
+ });
120
+ }
121
+ });
122
+ tinyProduct.variacoes.push({
123
+ variacao: tinyVariation,
124
+ });
125
+ });
126
+ }
127
+ return tinyProduct;
132
128
  };
133
- //# sourceMappingURL=product-to-tiny.js.map
129
+ // # sourceMappingURL=product-to-tiny.js.map