cloudcommerce 2.12.1 → 2.13.0
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/.github/workflows/test-apps.yml +2 -2
- package/CHANGELOG.md +24 -0
- package/action.yml +10 -10
- package/ecomplus-stores/barradoce/.github/workflows/build-and-deploy.yml +4 -4
- package/ecomplus-stores/barradoce/functions/many/package.json +3 -3
- package/ecomplus-stores/barradoce/functions/ssr/package.json +6 -6
- package/ecomplus-stores/barradoce/functions/ssr/public/assets/cvv.png +0 -0
- package/ecomplus-stores/barradoce/functions/ssr/public/assets/payments.png +0 -0
- package/ecomplus-stores/barradoce/functions/ssr/src/components/AccountPage.vue +1 -1
- package/ecomplus-stores/barradoce/functions/ssr/src/pages/app/account.astro +1 -1
- package/ecomplus-stores/barradoce/functions/with-apps/package.json +3 -3
- package/ecomplus-stores/barradoce/package.json +2 -2
- package/package.json +8 -8
- package/packages/api/package.json +1 -1
- package/packages/api/types.d.ts +1 -1
- package/packages/apps/affiliate-program/package.json +2 -2
- package/packages/apps/correios/package.json +2 -2
- package/packages/apps/custom-payment/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/datafrete/package.json +2 -2
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/emails/lib/functios-lib/handle-orders.js +5 -6
- package/packages/apps/emails/lib/functios-lib/handle-orders.js.map +1 -1
- package/packages/apps/emails/lib/functios-lib/utils.js +2 -3
- package/packages/apps/emails/lib/functios-lib/utils.js.map +1 -1
- package/packages/apps/emails/package.json +2 -2
- package/packages/apps/emails/src/functios-lib/handle-orders.ts +5 -14
- package/packages/apps/emails/src/functios-lib/utils.ts +2 -5
- package/packages/apps/fb-conversions/package.json +2 -2
- package/packages/apps/flash-courier/package.json +2 -2
- package/packages/apps/frenet/package.json +2 -2
- package/packages/apps/galaxpay/package.json +2 -2
- package/packages/apps/google-analytics/package.json +2 -2
- package/packages/apps/jadlog/package.json +1 -1
- package/packages/apps/loyalty-points/package.json +1 -1
- package/packages/apps/mandae/package.json +2 -2
- package/packages/apps/melhor-envio/package.json +2 -2
- package/packages/apps/mercadopago/package.json +2 -2
- package/packages/apps/pagaleve/package.json +2 -2
- package/packages/apps/pagarme/package.json +3 -3
- package/packages/apps/pagarme-v5/package.json +2 -2
- package/packages/apps/paghiper/package.json +2 -2
- package/packages/apps/pix/package.json +2 -2
- package/packages/apps/tiny-erp/package.json +2 -2
- package/packages/apps/webhooks/package.json +2 -2
- package/packages/cli/package.json +2 -2
- package/packages/config/package.json +1 -1
- package/packages/emails/package.json +2 -2
- package/packages/eslint/package.json +4 -4
- package/packages/events/package.json +2 -2
- package/packages/feeds/lib/firebase/serve-feeds.js +344 -3
- package/packages/feeds/lib/firebase/serve-feeds.js.map +1 -1
- package/packages/feeds/package.json +1 -1
- package/packages/feeds/src/firebase/serve-feeds.ts +367 -3
- package/packages/firebase/lib/helpers/pubsub.js +3 -1
- package/packages/firebase/lib/helpers/pubsub.js.map +1 -1
- package/packages/firebase/package.json +2 -2
- package/packages/firebase/src/handlers/check-store-events.ts +1 -1
- package/packages/firebase/src/helpers/pubsub.ts +3 -1
- package/packages/i18n/package.json +1 -1
- package/packages/modules/package.json +2 -2
- package/packages/passport/package.json +2 -2
- package/packages/ssr/package.json +3 -3
- package/packages/storefront/package.json +4 -4
- package/packages/storefront/src/lib/scripts/vbeta-app.ts +1 -1
- package/packages/storefront/src/lib/state/customer-session.ts +8 -9
- package/packages/test-base/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/ecomplus-stores/barradoce/functions/ssr/public/assets/.gitkeep +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/app-mandae",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.13.0",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce app to integrate Mandaê shipping intermediator",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"files": [
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@cloudcommerce/api": "workspace:*",
|
|
29
29
|
"@ecomplus/utils": "1.5.0-rc.6",
|
|
30
30
|
"axios": "^1.6.8",
|
|
31
|
-
"firebase-functions": "^4.
|
|
31
|
+
"firebase-functions": "^4.9.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@cloudcommerce/test-base": "workspace:*",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/app-melhor-envio",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.13.0",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce app to integrate Melhor Envio",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@cloudcommerce/firebase": "workspace:*",
|
|
34
34
|
"axios": "^1.6.8",
|
|
35
35
|
"firebase-admin": "^12.0.0",
|
|
36
|
-
"firebase-functions": "^4.
|
|
36
|
+
"firebase-functions": "^4.9.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@cloudcommerce/types": "workspace:*",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/app-mercadopago",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.13.0",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce app to integrate Mercado Pago",
|
|
6
6
|
"main": "lib/mercadopago.js",
|
|
7
7
|
"exports": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@cloudcommerce/firebase": "workspace:*",
|
|
36
36
|
"axios": "^1.6.8",
|
|
37
37
|
"firebase-admin": "^12.0.0",
|
|
38
|
-
"firebase-functions": "^4.
|
|
38
|
+
"firebase-functions": "^4.9.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@cloudcommerce/test-base": "workspace:*",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/app-pagaleve",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.13.0",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce app to integrate Pagaleve",
|
|
6
6
|
"main": "lib/pagaleve.js",
|
|
7
7
|
"exports": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@ecomplus/utils": "1.5.0-rc.6",
|
|
36
36
|
"axios": "^1.6.8",
|
|
37
37
|
"firebase-admin": "^12.0.0",
|
|
38
|
-
"firebase-functions": "^4.
|
|
38
|
+
"firebase-functions": "^4.9.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@cloudcommerce/types": "workspace:*"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/app-pagarme",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.13.0",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce app to integrate Pagar.me",
|
|
6
6
|
"main": "lib/pagarme.js",
|
|
7
7
|
"exports": {
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"@cloudcommerce/firebase": "workspace:*",
|
|
35
35
|
"axios": "^1.6.8",
|
|
36
36
|
"firebase-admin": "^12.0.0",
|
|
37
|
-
"firebase-functions": "^4.
|
|
37
|
+
"firebase-functions": "^4.9.0",
|
|
38
38
|
"pagarme": "^4.34.1",
|
|
39
|
-
"qs": "^6.12.
|
|
39
|
+
"qs": "^6.12.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@cloudcommerce/types": "workspace:*",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/app-pagarme-v5",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.13.0",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce app to integrate Pagar.me API v5 with recurring payments",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@ecomplus/utils": "1.5.0-rc.6",
|
|
37
37
|
"axios": "^1.6.8",
|
|
38
38
|
"firebase-admin": "^12.0.0",
|
|
39
|
-
"firebase-functions": "^4.
|
|
39
|
+
"firebase-functions": "^4.9.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@cloudcommerce/test-base": "workspace:*",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/app-paghiper",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.13.0",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce app to integrate PagHiper",
|
|
6
6
|
"main": "lib/paghiper.js",
|
|
7
7
|
"exports": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@cloudcommerce/firebase": "workspace:*",
|
|
34
34
|
"axios": "^1.6.8",
|
|
35
35
|
"firebase-admin": "^12.0.0",
|
|
36
|
-
"firebase-functions": "^4.
|
|
36
|
+
"firebase-functions": "^4.9.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@cloudcommerce/types": "workspace:*",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/app-pix",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.13.0",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce app to integrate Pix API (Bacen)",
|
|
6
6
|
"main": "lib/pix.js",
|
|
7
7
|
"exports": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@cloudcommerce/firebase": "workspace:*",
|
|
34
34
|
"axios": "^1.6.8",
|
|
35
35
|
"firebase-admin": "^12.0.0",
|
|
36
|
-
"firebase-functions": "^4.
|
|
36
|
+
"firebase-functions": "^4.9.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@cloudcommerce/types": "workspace:*",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/app-tiny-erp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.13.0",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce app for Tiny ERP",
|
|
6
6
|
"main": "lib/tiny-erp.js",
|
|
7
7
|
"files": [
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@ecomplus/utils": "1.5.0-rc.6",
|
|
31
31
|
"axios": "^1.6.8",
|
|
32
32
|
"firebase-admin": "^12.0.0",
|
|
33
|
-
"firebase-functions": "^4.
|
|
33
|
+
"firebase-functions": "^4.9.0",
|
|
34
34
|
"form-data": "4.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/app-webhooks",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.13.0",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce app for general order webhooks",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"files": [
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@cloudcommerce/firebase": "workspace:*",
|
|
30
30
|
"axios": "^1.6.8",
|
|
31
31
|
"firebase-admin": "^12.0.0",
|
|
32
|
-
"firebase-functions": "^4.
|
|
32
|
+
"firebase-functions": "^4.9.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@cloudcommerce/types": "workspace:*",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.13.0",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce CLI tools",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cloudcommerce": "./bin/run.mjs"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dotenv": "^16.4.5",
|
|
39
39
|
"libsodium-wrappers": "^0.7.13",
|
|
40
40
|
"md5": "^2.3.0",
|
|
41
|
-
"typescript": "~5.4.
|
|
41
|
+
"typescript": "~5.4.5",
|
|
42
42
|
"zx": "^7.2.3"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/emails",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.13.0",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce email sender",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@cloudcommerce/firebase": "workspace:*",
|
|
31
31
|
"axios": "^1.6.8",
|
|
32
|
-
"ejs": "^3.1.
|
|
32
|
+
"ejs": "^3.1.10",
|
|
33
33
|
"nodemailer": "^6.9.13"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/eslint",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.13.0",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce ESLint config",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"files": [
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"build": "echo '@ecomplus/eslint'"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
26
|
-
"@typescript-eslint/parser": "^7.
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^7.6.0",
|
|
26
|
+
"@typescript-eslint/parser": "^7.6.0",
|
|
27
27
|
"eslint": "^8.57.0",
|
|
28
28
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
29
29
|
"eslint-plugin-astro": "^0.33.1",
|
|
30
30
|
"eslint-plugin-import": "^2.29.1",
|
|
31
31
|
"eslint-plugin-tailwindcss": "3.15.1",
|
|
32
|
-
"eslint-plugin-vue": "^9.
|
|
32
|
+
"eslint-plugin-vue": "^9.25.0"
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/events",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.13.0",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce app events",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@cloudcommerce/firebase": "workspace:*",
|
|
51
51
|
"@cloudcommerce/ssr": "workspace:*",
|
|
52
52
|
"firebase-admin": "^12.0.0",
|
|
53
|
-
"firebase-functions": "^4.
|
|
53
|
+
"firebase-functions": "^4.9.0",
|
|
54
54
|
"source-map-support": "^0.5.21"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
@@ -1,9 +1,350 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { error } from 'firebase-functions/logger';
|
|
2
|
+
import api from '@cloudcommerce/api';
|
|
3
|
+
import config from '@cloudcommerce/firebase/lib/config';
|
|
4
|
+
|
|
5
|
+
const fetchProducts = async (page = 1) => {
|
|
6
|
+
const limit = 300;
|
|
7
|
+
const offset = limit * (page - 1);
|
|
8
|
+
const { data: { result: products, meta: { count } } } = await api.get('products', {
|
|
9
|
+
limit,
|
|
10
|
+
offset,
|
|
11
|
+
count: true,
|
|
12
|
+
params: {
|
|
13
|
+
available: true,
|
|
14
|
+
visible: true,
|
|
15
|
+
},
|
|
16
|
+
fields: [
|
|
17
|
+
'_id',
|
|
18
|
+
'name',
|
|
19
|
+
'sku',
|
|
20
|
+
'slug',
|
|
21
|
+
'quantity',
|
|
22
|
+
'min_quantity',
|
|
23
|
+
'production_time',
|
|
24
|
+
'pictures',
|
|
25
|
+
'currency_id',
|
|
26
|
+
'price',
|
|
27
|
+
'base_price',
|
|
28
|
+
'category_tree',
|
|
29
|
+
'categories.0.name',
|
|
30
|
+
'brands.0.name',
|
|
31
|
+
'google_product_category_id',
|
|
32
|
+
'gtin',
|
|
33
|
+
'mpn',
|
|
34
|
+
'adult',
|
|
35
|
+
'condition',
|
|
36
|
+
'weight',
|
|
37
|
+
'dimensions',
|
|
38
|
+
'specifications',
|
|
39
|
+
'variations',
|
|
40
|
+
'short_description',
|
|
41
|
+
'body_html',
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
products,
|
|
46
|
+
nextPage: (count && count > offset + limit) ? page + 1 : null,
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const products = [];
|
|
50
|
+
const fetchAllProducts = async () => {
|
|
51
|
+
let page = 1;
|
|
52
|
+
while (page) {
|
|
53
|
+
const {
|
|
54
|
+
products: _products, nextPage,
|
|
55
|
+
// eslint-disable-next-line no-await-in-loop
|
|
56
|
+
} = await fetchProducts(page);
|
|
57
|
+
page = nextPage;
|
|
58
|
+
_products.forEach((product) => products.push(product));
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const fetching = new Promise((resolve, reject) => {
|
|
62
|
+
fetchAllProducts().then(resolve).catch(reject);
|
|
63
|
+
});
|
|
64
|
+
const serveFeeds = async (req, res) => {
|
|
65
|
+
const { method, url } = req;
|
|
3
66
|
if (method !== 'GET') {
|
|
4
67
|
res.sendStatus(405);
|
|
5
68
|
return;
|
|
6
69
|
}
|
|
7
|
-
|
|
70
|
+
if (url !== '/_feeds/catalog' && url !== '/catalog') {
|
|
71
|
+
res.sendStatus(404);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
await fetching;
|
|
76
|
+
} catch (err) {
|
|
77
|
+
error(err);
|
|
78
|
+
res.sendStatus(500);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const { storeId, settingsContent: { domain, name } } = config.get();
|
|
82
|
+
const title = `Products feed - ${name}`;
|
|
83
|
+
const isSkipVariations = !!req.query.skip_variations;
|
|
84
|
+
const discount = Number(req.query.discount) || 0;
|
|
85
|
+
let querystring = String(req.query.qs) || '?_=feed';
|
|
86
|
+
if (querystring.charAt(0) !== '?') {
|
|
87
|
+
querystring = `?${querystring}`;
|
|
88
|
+
}
|
|
89
|
+
let propsSet = {};
|
|
90
|
+
if (typeof req.query.set_properties === 'string') {
|
|
91
|
+
try {
|
|
92
|
+
propsSet = JSON.parse(req.query.set_properties);
|
|
93
|
+
if (typeof propsSet !== 'object' || !propsSet) {
|
|
94
|
+
throw new Error('Invalid');
|
|
95
|
+
}
|
|
96
|
+
} catch {
|
|
97
|
+
res.sendStatus(400);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const isFacebook = (req.get('User-Agent') || '').includes('facebook');
|
|
102
|
+
let xml = `
|
|
103
|
+
<?xml version="1.0"?>
|
|
104
|
+
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:g="http://base.google.com/ns/1.0">
|
|
105
|
+
<title><![CDATA[${title}]]></title>
|
|
106
|
+
<link href="https://${domain}/" rel="alternate" type="text/html"/>
|
|
107
|
+
<updated>${new Date().toISOString()}</updated>
|
|
108
|
+
<id><![CDATA[#${storeId},${Math.random()}]]></id>
|
|
109
|
+
<author>
|
|
110
|
+
<name>e-com.plus Cloud Commerce</name>
|
|
111
|
+
</author>`;
|
|
112
|
+
const convertProduct = (p, groupId) => {
|
|
113
|
+
if (p.name) {
|
|
114
|
+
const entry = {
|
|
115
|
+
id: p.sku || p._id,
|
|
116
|
+
title: p.name,
|
|
117
|
+
item_group_id: groupId,
|
|
118
|
+
google_product_category: p.google_product_category_id,
|
|
119
|
+
};
|
|
120
|
+
if (p.short_description) {
|
|
121
|
+
entry.description = p.short_description;
|
|
122
|
+
} else if (p.body_html) {
|
|
123
|
+
entry.description = p.body_html
|
|
124
|
+
.replace(/<style\b[^>]*>.*?<\/style>/isg, '')
|
|
125
|
+
.replace(/<[^>]+>/g, '')
|
|
126
|
+
.replace(/ /g, '');
|
|
127
|
+
} else {
|
|
128
|
+
entry.description = p.name;
|
|
129
|
+
}
|
|
130
|
+
if (p.slug) {
|
|
131
|
+
entry.link = `https://${domain}/${p.slug}${querystring}`;
|
|
132
|
+
if (groupId) entry.link += `&var=${p._id}`;
|
|
133
|
+
if (discount > 0) entry.link += `&discount=${discount}`;
|
|
134
|
+
}
|
|
135
|
+
if ((p.quantity === undefined || p.quantity)
|
|
136
|
+
&& (!p.min_quantity || p.quantity >= p.min_quantity)) {
|
|
137
|
+
entry.availability = 'in stock';
|
|
138
|
+
} else {
|
|
139
|
+
entry.availability = 'out of stock';
|
|
140
|
+
}
|
|
141
|
+
if (p.production_time?.days) {
|
|
142
|
+
entry.min_handling_time = p.production_time.days;
|
|
143
|
+
if (p.production_time.max_time) {
|
|
144
|
+
entry.max_handling_time = p.production_time.max_time;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (p.pictures?.length) {
|
|
148
|
+
const additionalImages = [];
|
|
149
|
+
for (let i = 0; i < p.pictures.length && i < 10; i++) {
|
|
150
|
+
const picture = p.pictures[i];
|
|
151
|
+
let img = picture.zoom?.url || picture.big?.url || picture.normal?.url;
|
|
152
|
+
if (img) {
|
|
153
|
+
img = img.replace(/(\w+\.)?(ecoms\d)\.com/i, '$2-nyc3.nyc3.cdn.digitaloceanspaces.com');
|
|
154
|
+
if (!entry.image_link) {
|
|
155
|
+
entry.image_link = img;
|
|
156
|
+
} else {
|
|
157
|
+
additionalImages.push(img);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (additionalImages.length) {
|
|
162
|
+
entry.additional_image_link = additionalImages;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (p.price) {
|
|
166
|
+
if (p.base_price && p.base_price > p.price) {
|
|
167
|
+
entry.price = `${p.base_price} ${p.currency_id}`;
|
|
168
|
+
entry.sale_price = (p.price * (1 - discount)).toFixed(2) + ` ${p.currency_id}`;
|
|
169
|
+
} else {
|
|
170
|
+
entry.price = (p.price * (1 - discount)).toFixed(2) + ` ${p.currency_id}`;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (p.category_tree) {
|
|
174
|
+
entry.product_type = p.category_tree;
|
|
175
|
+
} else if (p.categories?.length) {
|
|
176
|
+
entry.product_type = p.categories[0].name;
|
|
177
|
+
}
|
|
178
|
+
let isIdentifierExists = false;
|
|
179
|
+
if (p.brands?.length) {
|
|
180
|
+
isIdentifierExists = true;
|
|
181
|
+
entry.brand = p.brands[0].name;
|
|
182
|
+
}
|
|
183
|
+
['gtin', 'mpn'].forEach((field) => {
|
|
184
|
+
const codes = p[field];
|
|
185
|
+
if (Array.isArray(codes) && codes.length) {
|
|
186
|
+
entry[field] = codes[0];
|
|
187
|
+
isIdentifierExists = true;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
entry.identifier_exists = isIdentifierExists ? 'yes' : 'no';
|
|
191
|
+
if (p.adult) {
|
|
192
|
+
entry.adult = 'yes';
|
|
193
|
+
}
|
|
194
|
+
if (p.condition) {
|
|
195
|
+
entry.condition = p.condition !== 'not_specified' ? p.condition : 'new';
|
|
196
|
+
}
|
|
197
|
+
if (p.weight) {
|
|
198
|
+
entry.shipping_weight = `${p.weight.value} ${p.weight.unit || ''}`;
|
|
199
|
+
}
|
|
200
|
+
if (p.dimensions && !isFacebook) {
|
|
201
|
+
['length', 'width', 'height'].forEach((side) => {
|
|
202
|
+
const dimension = p.dimensions[side];
|
|
203
|
+
if (dimension) {
|
|
204
|
+
entry[`shipping_${side}`] = `${dimension.value} ${dimension.unit || ''}`;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
if (p.specifications) {
|
|
209
|
+
let customLabel = 0;
|
|
210
|
+
Object.keys(p.specifications).forEach((spec) => {
|
|
211
|
+
const values = p.specifications[spec];
|
|
212
|
+
if (!values.length) return;
|
|
213
|
+
const [val] = values;
|
|
214
|
+
/* eslint-disable no-case-declarations */
|
|
215
|
+
switch (spec) {
|
|
216
|
+
case 'energy_efficiency_class':
|
|
217
|
+
case 'age_group':
|
|
218
|
+
case 'gender':
|
|
219
|
+
case 'size_type':
|
|
220
|
+
case 'size_system':
|
|
221
|
+
entry[spec] = val.value || val.text;
|
|
222
|
+
break;
|
|
223
|
+
case 'size':
|
|
224
|
+
case 'pattern':
|
|
225
|
+
case 'material':
|
|
226
|
+
entry[spec] = val.text;
|
|
227
|
+
break;
|
|
228
|
+
case 'colors':
|
|
229
|
+
case 'color':
|
|
230
|
+
case 'cor':
|
|
231
|
+
case 'cores':
|
|
232
|
+
let colors = val.text.replace(/[/]/g, ' ');
|
|
233
|
+
for (let i = 1; i < values.length; i++) {
|
|
234
|
+
colors += `/${values[i].text.replace(/[/]/g, ' ')}`;
|
|
235
|
+
}
|
|
236
|
+
entry.color = colors;
|
|
237
|
+
break;
|
|
238
|
+
default:
|
|
239
|
+
let commonSpec = null;
|
|
240
|
+
let fixedText = val.value || val.text;
|
|
241
|
+
switch (fixedText.toLowerCase()) {
|
|
242
|
+
case 'm':
|
|
243
|
+
case 'l':
|
|
244
|
+
case 'g':
|
|
245
|
+
case 's':
|
|
246
|
+
case 'p':
|
|
247
|
+
case 'xs':
|
|
248
|
+
case 'pp':
|
|
249
|
+
case 'xl':
|
|
250
|
+
case 'gg':
|
|
251
|
+
case 'xxl':
|
|
252
|
+
case 'xg':
|
|
253
|
+
case 'u':
|
|
254
|
+
case 'Único':
|
|
255
|
+
case 'unico':
|
|
256
|
+
commonSpec = 'size';
|
|
257
|
+
break;
|
|
258
|
+
case 'adult':
|
|
259
|
+
case 'adulto':
|
|
260
|
+
case 'kids':
|
|
261
|
+
case 'criança':
|
|
262
|
+
case 'infant':
|
|
263
|
+
case 'infantil':
|
|
264
|
+
case 'newborn':
|
|
265
|
+
case 'recém-nascido':
|
|
266
|
+
case 'toddler':
|
|
267
|
+
commonSpec = 'age_group';
|
|
268
|
+
break;
|
|
269
|
+
case 'male':
|
|
270
|
+
case 'masculino':
|
|
271
|
+
case 'female':
|
|
272
|
+
case 'feminino':
|
|
273
|
+
case 'unisex':
|
|
274
|
+
commonSpec = 'gender';
|
|
275
|
+
break;
|
|
276
|
+
case 'homem':
|
|
277
|
+
commonSpec = 'gender';
|
|
278
|
+
fixedText = 'male';
|
|
279
|
+
break;
|
|
280
|
+
case 'mulher':
|
|
281
|
+
commonSpec = 'gender';
|
|
282
|
+
fixedText = 'female';
|
|
283
|
+
break;
|
|
284
|
+
default:
|
|
285
|
+
if (customLabel < 5) {
|
|
286
|
+
entry[`custom_label_${customLabel}`] = val.text;
|
|
287
|
+
customLabel += 1;
|
|
288
|
+
}
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
if (commonSpec !== null && !entry[commonSpec]) {
|
|
292
|
+
entry[commonSpec] = fixedText;
|
|
293
|
+
}
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
Object.keys(propsSet).forEach((key) => {
|
|
299
|
+
entry[key] = propsSet[key];
|
|
300
|
+
});
|
|
301
|
+
xml += `
|
|
302
|
+
<entry>`;
|
|
303
|
+
Object.keys(entry).forEach((key) => {
|
|
304
|
+
const val = entry[key];
|
|
305
|
+
if (val === undefined || val === null) return;
|
|
306
|
+
if (typeof val === 'object' && val) {
|
|
307
|
+
Object.keys(entry).forEach((nKey) => {
|
|
308
|
+
const nested = val[nKey];
|
|
309
|
+
xml += `<g:${key}><![CDATA[${nested}]]></g:${key}>`;
|
|
310
|
+
});
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (key === 'link') {
|
|
314
|
+
xml += `<g:${key}><!--${p._id}-->${val}</g:${key}>`;
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
xml += `<g:${key}><![CDATA[${val}]]></g:${key}>`;
|
|
318
|
+
});
|
|
319
|
+
xml += `
|
|
320
|
+
</entry>`;
|
|
321
|
+
if (p.variations && !isSkipVariations) {
|
|
322
|
+
p.variations.forEach((variation) => {
|
|
323
|
+
const mergedItem = { ...p, ...variation };
|
|
324
|
+
if (p.specifications) {
|
|
325
|
+
mergedItem.specifications = {
|
|
326
|
+
...p.specifications,
|
|
327
|
+
...variation.specifications,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
if (!variation.sku && p.sku) {
|
|
331
|
+
mergedItem.sku = `${p.sku}-${Math.ceil(Math.random() * 1000)}`;
|
|
332
|
+
}
|
|
333
|
+
if (variation.picture_id && p.pictures) {
|
|
334
|
+
const picture = p.pictures.find(({ _id }) => _id === variation.picture_id);
|
|
335
|
+
if (picture) mergedItem.pictures = [picture];
|
|
336
|
+
}
|
|
337
|
+
delete mergedItem.variations;
|
|
338
|
+
convertProduct(mergedItem, entry.id);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
products.forEach((p) => convertProduct(p));
|
|
344
|
+
xml += `
|
|
345
|
+
</feed>`;
|
|
346
|
+
res.send(xml);
|
|
8
347
|
};
|
|
348
|
+
|
|
349
|
+
export default serveFeeds;
|
|
9
350
|
// # sourceMappingURL=serve-feeds.js.map
|