cloudcommerce 2.6.1 → 2.6.3

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/ecomplus-stores/barradoce/functions/many/package.json +3 -3
  3. package/ecomplus-stores/barradoce/functions/ssr/package.json +6 -6
  4. package/ecomplus-stores/barradoce/functions/ssr/src/components/ProductDetails.vue +2 -1
  5. package/ecomplus-stores/barradoce/functions/with-apps/package.json +3 -3
  6. package/ecomplus-stores/barradoce/package.json +2 -2
  7. package/package.json +2 -2
  8. package/packages/api/package.json +1 -1
  9. package/packages/apps/affiliate-program/package.json +1 -1
  10. package/packages/apps/correios/package.json +1 -1
  11. package/packages/apps/custom-payment/package.json +1 -1
  12. package/packages/apps/custom-shipping/package.json +1 -1
  13. package/packages/apps/datafrete/package.json +1 -1
  14. package/packages/apps/discounts/package.json +1 -1
  15. package/packages/apps/emails/package.json +1 -1
  16. package/packages/apps/fb-conversions/package.json +1 -1
  17. package/packages/apps/flash-courier/package.json +1 -1
  18. package/packages/apps/frenet/package.json +1 -1
  19. package/packages/apps/galaxpay/package.json +1 -1
  20. package/packages/apps/google-analytics/package.json +1 -1
  21. package/packages/apps/jadlog/package.json +1 -1
  22. package/packages/apps/loyalty-points/package.json +1 -1
  23. package/packages/apps/mandae/package.json +1 -1
  24. package/packages/apps/melhor-envio/package.json +1 -1
  25. package/packages/apps/mercadopago/package.json +1 -1
  26. package/packages/apps/pagarme/package.json +1 -1
  27. package/packages/apps/pagarme-v5/package.json +1 -1
  28. package/packages/apps/paghiper/package.json +1 -1
  29. package/packages/apps/pix/package.json +1 -1
  30. package/packages/apps/tiny-erp/package.json +1 -1
  31. package/packages/apps/webhooks/package.json +1 -1
  32. package/packages/cli/package.json +1 -1
  33. package/packages/config/package.json +1 -1
  34. package/packages/emails/package.json +1 -1
  35. package/packages/eslint/package.json +1 -1
  36. package/packages/events/package.json +1 -1
  37. package/packages/feeds/package.json +1 -1
  38. package/packages/firebase/package.json +1 -1
  39. package/packages/i18n/package.json +1 -1
  40. package/packages/modules/package.json +1 -1
  41. package/packages/passport/package.json +1 -1
  42. package/packages/ssr/lib/lib/cron-ssr-save-views.js +64 -55
  43. package/packages/ssr/lib/lib/cron-ssr-save-views.js.map +1 -1
  44. package/packages/ssr/package.json +3 -3
  45. package/packages/ssr/src/lib/cron-ssr-save-views.ts +79 -66
  46. package/packages/storefront/package.json +3 -3
  47. package/packages/storefront/src/lib/composables/use-breadcrumbs.ts +2 -1
  48. package/packages/storefront/src/lib/composables/use-search-showcase.ts +2 -1
  49. package/packages/test-base/package.json +1 -1
  50. package/packages/types/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [2.6.3](https://github.com/ecomplus/cloud-commerce/compare/v2.6.2...v2.6.3) (2024-02-24)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **ssr:** Update (PUT) bunny.net perma cache with fresh HTML instead of delete and further get ([46a69eb](https://github.com/ecomplus/cloud-commerce/commit/46a69ebd3808884be74eeaebad0796be7da2e342))
11
+ * **storefront:** Bump Astro to latest v4.4.4 ([7943c78](https://github.com/ecomplus/cloud-commerce/commit/7943c786bcdd2788ac7d29e9e9fb3b06c5422ba9))
12
+ * **storefront:** Prevent warnings with undeclared `cmsPreview` prop on composables for sections ([2b6eec4](https://github.com/ecomplus/cloud-commerce/commit/2b6eec4ad101c252a131de30dbc9fcd9d97dc1d7))
13
+
14
+ ### [2.6.2](https://github.com/ecomplus/cloud-commerce/compare/v2.6.1...v2.6.2) (2024-02-24)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **ssr:** Ensure cache refresh req is sent after CDN cache purge on cron save views ([943f001](https://github.com/ecomplus/cloud-commerce/commit/943f00128e618354b84fd203db071b6245351281))
20
+
5
21
  ### [2.6.1](https://github.com/ecomplus/cloud-commerce/compare/v2.6.0...v2.6.1) (2024-02-24)
6
22
 
7
23
 
@@ -15,8 +15,8 @@
15
15
  },
16
16
  "main": "index.js",
17
17
  "dependencies": {
18
- "@cloudcommerce/feeds": "^2.6.0",
19
- "@cloudcommerce/firebase": "^2.6.0",
20
- "@cloudcommerce/passport": "^2.6.0"
18
+ "@cloudcommerce/feeds": "^2.6.2",
19
+ "@cloudcommerce/firebase": "^2.6.2",
20
+ "@cloudcommerce/passport": "^2.6.2"
21
21
  }
22
22
  }
@@ -19,16 +19,16 @@
19
19
  },
20
20
  "main": "index.js",
21
21
  "dependencies": {
22
- "@cloudcommerce/api": "^2.6.0",
23
- "@cloudcommerce/firebase": "^2.6.0",
24
- "@cloudcommerce/ssr": "^2.6.0",
22
+ "@cloudcommerce/api": "^2.6.2",
23
+ "@cloudcommerce/firebase": "^2.6.2",
24
+ "@cloudcommerce/ssr": "^2.6.2",
25
25
  "@headlessui/vue": "^1.7.18",
26
26
  "micromark": "^4.0.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@cloudcommerce/i18n": "^2.6.0",
30
- "@cloudcommerce/storefront": "^2.6.0",
31
- "@cloudcommerce/types": "^2.6.0",
29
+ "@cloudcommerce/i18n": "^2.6.2",
30
+ "@cloudcommerce/storefront": "^2.6.2",
31
+ "@cloudcommerce/types": "^2.6.2",
32
32
  "@iconify-json/mingcute": "^1.1.16",
33
33
  "photoswipe": "^5.4.3"
34
34
  }
@@ -83,6 +83,7 @@
83
83
 
84
84
  <script setup lang="ts">
85
85
  import type { ResourceId, Products } from '@cloudcommerce/api/types';
86
+ import type { SectionPreviewProps } from '@@sf/state/use-cms-preview';
86
87
  import { useUrlSearchParams } from '@vueuse/core';
87
88
  import { addProductToCart } from '@@sf/state/shopping-cart';
88
89
  import { useProductCard } from '@@sf/composables/use-product-card';
@@ -93,7 +94,7 @@ import ImagesGallery from '~/components/ImagesGallery.vue';
93
94
  import SkuSelector from '~/components/SkuSelector.vue';
94
95
  import ShippingCalculator from '~/components/ShippingCalculator.vue';
95
96
 
96
- export interface Props {
97
+ export interface Props extends Partial<SectionPreviewProps> {
97
98
  product?: Products;
98
99
  }
99
100
 
@@ -15,8 +15,8 @@
15
15
  },
16
16
  "main": "index.js",
17
17
  "dependencies": {
18
- "@cloudcommerce/events": "^2.6.0",
19
- "@cloudcommerce/firebase": "^2.6.0",
20
- "@cloudcommerce/modules": "^2.6.0"
18
+ "@cloudcommerce/events": "^2.6.2",
19
+ "@cloudcommerce/firebase": "^2.6.2",
20
+ "@cloudcommerce/modules": "^2.6.2"
21
21
  }
22
22
  }
@@ -26,10 +26,10 @@
26
26
  "url": "https://github.com/ecomplus/cloud-commerce/issues"
27
27
  },
28
28
  "dependencies": {
29
- "@cloudcommerce/cli": "^2.6.0"
29
+ "@cloudcommerce/cli": "^2.6.2"
30
30
  },
31
31
  "devDependencies": {
32
- "@cloudcommerce/eslint": "^2.6.0",
32
+ "@cloudcommerce/eslint": "^2.6.2",
33
33
  "husky": "^9.0.10",
34
34
  "lint-staged": "^15.2.2"
35
35
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloudcommerce",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "Open fair-code headless commerce platform: API-first, microservices based, event driven and cloud native",
6
6
  "main": "packages/api/lib/index.js",
7
7
  "author": "E-Com Club Softwares para E-commerce <ti@e-com.club>",
@@ -36,7 +36,7 @@
36
36
  "vite": "^5.0.11",
37
37
  "vitest": "^1.3.0",
38
38
  "zx": "^7.2.3",
39
- "@cloudcommerce/eslint": "2.6.1"
39
+ "@cloudcommerce/eslint": "2.6.3"
40
40
  },
41
41
  "scripts": {
42
42
  "fix-install": "bash scripts/pre-install.sh && pnpm i",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/api",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce APIs client/adapter",
6
6
  "main": "lib/api.js",
7
7
  "types": "lib/api.d.ts",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-affiliate-program",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app for simple affiliate program",
6
6
  "main": "lib/index.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-correios",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app for Correios shipping calculation",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-custom-payment",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app for simple custom payment methods",
6
6
  "main": "lib/index.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-custom-shipping",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app for custom shipping methods",
6
6
  "main": "lib/custom-shipping.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-datafrete",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app to integrate Datafrete shipping gateway ",
6
6
  "main": "lib/datafrete.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-discounts",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app for complex discount rules",
6
6
  "main": "lib/discounts.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-emails",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce default transactional email app",
6
6
  "main": "lib/index.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-fb-conversions",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app to send carts/orders to Facebook Conversions API",
6
6
  "main": "lib/index.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-flash-courier",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app to integrate Flash Courier",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-frenet",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app for Frenet shipping calculation",
6
6
  "main": "lib/frenet.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-galaxpay",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app to integrate Galax Pay for recurring payments",
6
6
  "main": "lib/galaxpay.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-google-analytics",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app to send carts/orders events to GA Measurement Protocol",
6
6
  "main": "lib/index.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-jadlog",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app for Jadlog shipping calculation",
6
6
  "main": "lib/index.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-loyalty-points",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app to handle simple loyalty points programs",
6
6
  "main": "lib/loyalty-points.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-mandae",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app to integrate Mandaê shipping intermediator",
6
6
  "main": "lib/index.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-melhor-envio",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app to integrate Melhor Envio",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-mercadopago",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app to integrate Mercado Pago",
6
6
  "main": "lib/mercadopago.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-pagarme",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app to integrate Pagar.me",
6
6
  "main": "lib/pagarme.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-pagarme-v5",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
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": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-paghiper",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app to integrate PagHiper",
6
6
  "main": "lib/paghiper.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-pix",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app to integrate Pix API (Bacen)",
6
6
  "main": "lib/pix.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-tiny-erp",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app for Tiny ERP",
6
6
  "main": "lib/tiny-erp.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-webhooks",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app for general order webhooks",
6
6
  "main": "lib/index.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/cli",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce CLI tools",
6
6
  "bin": {
7
7
  "cloudcommerce": "./bin/run.mjs"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/config",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce base config",
6
6
  "main": "lib/config.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/emails",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce email sender",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/eslint",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce ESLint config",
6
6
  "main": "lib/index.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/events",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce app events",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/feeds",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce catalog feeds",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/firebase",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce on Firebase",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/i18n",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce i18n",
6
6
  "main": "lib/all.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/modules",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce modules API",
6
6
  "main": "lib/index.cjs",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/passport",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce customers authentication (passport) API",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -7,7 +7,7 @@ import { deleteQueryBatch } from '@cloudcommerce/firebase/lib/helpers/firestore'
7
7
 
8
8
  const saveViews = async () => {
9
9
  const deployRand = process.env.DEPLOY_RAND || '_';
10
- /* eslint-disable no-await-in-loop */
10
+ const projectId = process.env.GCLOUD_PROJECT;
11
11
  const db = getFirestore();
12
12
  const productViewsSnapshot = await db.collection('ssrProductViews')
13
13
  .limit(500).get();
@@ -17,7 +17,9 @@ const saveViews = async () => {
17
17
  if (countUnsaved > 0) {
18
18
  const productId = doc.id;
19
19
  try {
20
+ // eslint-disable-next-line no-await-in-loop
20
21
  const { views } = (await api.get(`products/${productId}`)).data;
22
+ // eslint-disable-next-line no-await-in-loop
21
23
  await api.patch(`products/${productId}`, {
22
24
  views: countUnsaved + (views || 0),
23
25
  });
@@ -41,27 +43,28 @@ const saveViews = async () => {
41
43
  },
42
44
  });
43
45
  try {
46
+ const storageAuthReqs = [];
44
47
  if (!bunnyStorageName || !bunnyStoragePass) {
45
- const { data } = await bunnyAxios.get('/storagezone');
46
- for (let i = 0; i < data.length; i++) {
47
- const bunnyStorage = data[i];
48
- if (bunnyStorageName) {
49
- if (bunnyStorage.Name === bunnyStorageName) {
48
+ storageAuthReqs.push(bunnyAxios.get('/storagezone').then(({ data }) => {
49
+ for (let i = 0; i < data.length; i++) {
50
+ const bunnyStorage = data[i];
51
+ if (bunnyStorageName) {
52
+ if (bunnyStorage.Name === bunnyStorageName) {
53
+ bunnyStoragePass = bunnyStorage.Password;
54
+ break;
55
+ }
56
+ continue;
57
+ }
58
+ if (bunnyStorage.Name.startsWith('storefront-isr-')) {
59
+ bunnyStorageName = bunnyStorage.Name;
50
60
  bunnyStoragePass = bunnyStorage.Password;
51
61
  break;
52
62
  }
53
- continue;
54
- }
55
- if (bunnyStorage.Name.startsWith('storefront-isr-')) {
56
- bunnyStorageName = bunnyStorage.Name;
57
- bunnyStoragePass = bunnyStorage.Password;
58
- break;
59
63
  }
60
- }
64
+ }));
61
65
  }
62
- if (bunnyStorageName && bunnyStoragePass) {
63
- if (!bunnyZoneName) {
64
- const { data } = await bunnyAxios.get('/pullzone');
66
+ if (!bunnyZoneName) {
67
+ storageAuthReqs.push(bunnyAxios.get('/pullzone').then(({ data }) => {
65
68
  for (let i = 0; i < data.length; i++) {
66
69
  const pullZone = data[i];
67
70
  if (pullZone.Hostnames.find(({ Value }) => Value === domain)) {
@@ -69,20 +72,21 @@ const saveViews = async () => {
69
72
  break;
70
73
  }
71
74
  }
72
- }
73
- if (bunnyZoneName) {
74
- const { data } = await axios({
75
- url: `https://storage.bunnycdn.com/${bunnyStorageName}/__bcdn_perma_cache__/`,
76
- headers: {
77
- AccessKey: bunnyStoragePass,
78
- },
79
- });
80
- for (let i = 0; i < data.length; i++) {
81
- const { ObjectName } = data[i];
82
- if (ObjectName.startsWith(`pullzone__${bunnyZoneName}__`)
83
- && (!permaCacheZoneFolder || permaCacheZoneFolder < ObjectName)) {
84
- permaCacheZoneFolder = ObjectName;
85
- }
75
+ }));
76
+ }
77
+ await Promise.all(storageAuthReqs);
78
+ if (bunnyStorageName && bunnyStoragePass && bunnyZoneName) {
79
+ const { data } = await axios({
80
+ url: `https://storage.bunnycdn.com/${bunnyStorageName}/__bcdn_perma_cache__/`,
81
+ headers: {
82
+ AccessKey: bunnyStoragePass,
83
+ },
84
+ });
85
+ for (let i = 0; i < data.length; i++) {
86
+ const { ObjectName } = data[i];
87
+ if (ObjectName.startsWith(`pullzone__${bunnyZoneName}__`)
88
+ && (!permaCacheZoneFolder || permaCacheZoneFolder < ObjectName)) {
89
+ permaCacheZoneFolder = ObjectName;
86
90
  }
87
91
  }
88
92
  }
@@ -92,6 +96,7 @@ const saveViews = async () => {
92
96
  .where('at', '<', new Date(Date.now() - 1000 * sMaxAge))
93
97
  .get();
94
98
  const purgedUrls = [];
99
+ const purgeReqs = [];
95
100
  for (let i = 0; i < pageViewsSnapshot.docs.length; i++) {
96
101
  const doc = pageViewsSnapshot.docs[i];
97
102
  const data = doc.data();
@@ -101,42 +106,46 @@ const saveViews = async () => {
101
106
  const url = data.url.replace(/\?.*$/, '');
102
107
  doc.ref.update({ isCachePurged: true });
103
108
  if (url?.startsWith(`https://${domain}`) && !purgedUrls.includes(url)) {
104
- await bunnyAxios('/purge', {
109
+ purgeReqs.push(bunnyAxios('/purge', {
105
110
  method: 'POST',
106
111
  params: {
107
112
  async: 'false',
108
113
  url,
109
114
  },
110
- });
115
+ }));
111
116
  purgedUrls.push(url);
112
117
  if (permaCacheZoneFolder) {
113
118
  let pathname = url.replace(`https://${domain}`, '');
114
- if (pathname.charAt(0) === '/') {
115
- pathname = pathname.slice(1);
116
- }
117
- const paths = pathname.split('/');
118
- const filename = paths.pop() || '';
119
- let folderpath = paths.join('/');
120
- if (folderpath) folderpath += '/';
121
- // https://support.bunny.net/hc/en-us/articles/360017048720-Perma-Cache-Folder-Structure-Explained
122
- const permaCachePath = `__bcdn_perma_cache__/${permaCacheZoneFolder}`
123
- + `/${folderpath}___${filename}___/___file___`;
124
- await axios({
125
- method: 'DELETE',
126
- url: `https://storage.bunnycdn.com/${bunnyStorageName}/${permaCachePath}`,
127
- headers: {
128
- AccessKey: bunnyStoragePass,
129
- },
130
- })
131
- .then(() => {
132
- axios.get(`${url}?__isrV=${deployRand}`).catch(error);
133
- })
134
- .catch((err) => {
135
- if (err.response?.status !== 404) throw err;
136
- });
119
+ const freshHtmlUrl = `https://${projectId}.web.app${pathname}?__isrV=${deployRand}`;
120
+ purgeReqs.push(
121
+ // eslint-disable-next-line no-loop-func
122
+ axios.get(freshHtmlUrl).then(({ data: freshHtml }) => {
123
+ if (pathname.charAt(0) === '/') {
124
+ pathname = pathname.slice(1);
125
+ }
126
+ const paths = pathname.split('/');
127
+ const filename = paths.pop() || '';
128
+ let folderpath = paths.join('/');
129
+ if (folderpath) folderpath += '/';
130
+ // https://support.bunny.net/hc/en-us/articles/360017048720-Perma-Cache-Folder-Structure-Explained
131
+ const permaCachePath = `__bcdn_perma_cache__/${permaCacheZoneFolder}`
132
+ + `/${folderpath}___${filename}___/___file___`;
133
+ axios({
134
+ method: 'PUT',
135
+ url: `https://storage.bunnycdn.com/${bunnyStorageName}/${permaCachePath}`,
136
+ headers: {
137
+ 'Content-Type': 'application/octet-stream',
138
+ Accept: 'application/json',
139
+ AccessKey: bunnyStoragePass,
140
+ },
141
+ data: freshHtml,
142
+ });
143
+ }),
144
+ );
137
145
  }
138
146
  }
139
147
  }
148
+ await Promise.all(purgeReqs);
140
149
  } catch (err) {
141
150
  if (err.response) {
142
151
  const _err = new Error('Cant purge bunny.net cache');
@@ -1 +1 @@
1
- {"version":3,"file":"cron-ssr-save-views.js","sourceRoot":"","sources":["../../src/lib/cron-ssr-save-views.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,MAAM,MAAM,oCAAoC,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AAEjF,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;IAC3B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC;IAClD,qCAAqC;IACrC,MAAM,EAAE,GAAG,YAAY,EAAE,CAAC;IAC1B,MAAM,oBAAoB,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC;SAChE,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,oBAAoB,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACzD,MAAM,G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,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACrE,MAAM,gBAAgB,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/ssr",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce storefront SSR",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -26,13 +26,13 @@
26
26
  "build:workers": "npx tsc -p src/cloudflare --outDir cloudflare && npx eslint --ext .js cloudflare --fix"
27
27
  },
28
28
  "dependencies": {
29
- "@astrojs/node": "8.2.0",
29
+ "@astrojs/node": "8.2.1",
30
30
  "@cloudcommerce/api": "workspace:*",
31
31
  "@cloudcommerce/firebase": "workspace:*",
32
32
  "@cloudcommerce/i18n": "workspace:*",
33
33
  "@ecomplus/utils": "1.5.0-rc.6",
34
34
  "@vueuse/core": "10.8.0",
35
- "astro": "4.4.1",
35
+ "astro": "4.4.4",
36
36
  "astro-capo": "^0.0.1",
37
37
  "axios": "^1.6.7",
38
38
  "firebase-admin": "^12.0.0",
@@ -7,7 +7,7 @@ import { deleteQueryBatch } from '@cloudcommerce/firebase/lib/helpers/firestore'
7
7
 
8
8
  const saveViews = async () => {
9
9
  const deployRand = process.env.DEPLOY_RAND || '_';
10
- /* eslint-disable no-await-in-loop */
10
+ const projectId = process.env.GCLOUD_PROJECT as string;
11
11
  const db = getFirestore();
12
12
  const productViewsSnapshot = await db.collection('ssrProductViews')
13
13
  .limit(500).get();
@@ -17,7 +17,9 @@ const saveViews = async () => {
17
17
  if (countUnsaved > 0) {
18
18
  const productId = doc.id as string & { length: 24 };
19
19
  try {
20
+ // eslint-disable-next-line no-await-in-loop
20
21
  const { views } = (await api.get(`products/${productId}`)).data;
22
+ // eslint-disable-next-line no-await-in-loop
21
23
  await api.patch(`products/${productId}`, {
22
24
  views: countUnsaved + (views || 0),
23
25
  });
@@ -41,50 +43,56 @@ const saveViews = async () => {
41
43
  },
42
44
  });
43
45
  try {
46
+ const storageAuthReqs: Promise<any>[] = [];
44
47
  if (!bunnyStorageName || !bunnyStoragePass) {
45
- const { data } = await bunnyAxios.get('/storagezone');
46
- for (let i = 0; i < data.length; i++) {
47
- const bunnyStorage = data[i];
48
- if (bunnyStorageName) {
49
- if (bunnyStorage.Name === bunnyStorageName) {
50
- bunnyStoragePass = bunnyStorage.Password;
51
- break;
48
+ storageAuthReqs.push(
49
+ bunnyAxios.get('/storagezone').then(({ data }) => {
50
+ for (let i = 0; i < data.length; i++) {
51
+ const bunnyStorage = data[i];
52
+ if (bunnyStorageName) {
53
+ if (bunnyStorage.Name === bunnyStorageName) {
54
+ bunnyStoragePass = bunnyStorage.Password;
55
+ break;
56
+ }
57
+ continue;
58
+ }
59
+ if (bunnyStorage.Name.startsWith('storefront-isr-')) {
60
+ bunnyStorageName = bunnyStorage.Name;
61
+ bunnyStoragePass = bunnyStorage.Password;
62
+ break;
63
+ }
52
64
  }
53
- continue;
54
- }
55
- if (bunnyStorage.Name.startsWith('storefront-isr-')) {
56
- bunnyStorageName = bunnyStorage.Name;
57
- bunnyStoragePass = bunnyStorage.Password;
58
- break;
59
- }
60
- }
65
+ }),
66
+ );
61
67
  }
62
- if (bunnyStorageName && bunnyStoragePass) {
63
- if (!bunnyZoneName) {
64
- const { data } = await bunnyAxios.get('/pullzone');
65
- for (let i = 0; i < data.length; i++) {
66
- const pullZone = data[i];
67
- if (pullZone.Hostnames.find(({ Value }) => Value === domain)) {
68
- bunnyZoneName = pullZone.Name;
69
- break;
70
- }
71
- }
72
- }
73
- if (bunnyZoneName) {
74
- const { data } = await axios({
75
- url: `https://storage.bunnycdn.com/${bunnyStorageName}/__bcdn_perma_cache__/`,
76
- headers: {
77
- AccessKey: bunnyStoragePass,
78
- },
79
- });
80
- for (let i = 0; i < data.length; i++) {
81
- const { ObjectName } = data[i];
82
- if (
83
- ObjectName.startsWith(`pullzone__${bunnyZoneName}__`)
84
- && (!permaCacheZoneFolder || permaCacheZoneFolder < ObjectName)
85
- ) {
86
- permaCacheZoneFolder = ObjectName;
68
+ if (!bunnyZoneName) {
69
+ storageAuthReqs.push(
70
+ bunnyAxios.get('/pullzone').then(({ data }) => {
71
+ for (let i = 0; i < data.length; i++) {
72
+ const pullZone = data[i];
73
+ if (pullZone.Hostnames.find(({ Value }) => Value === domain)) {
74
+ bunnyZoneName = pullZone.Name;
75
+ break;
76
+ }
87
77
  }
78
+ }),
79
+ );
80
+ }
81
+ await Promise.all(storageAuthReqs);
82
+ if (bunnyStorageName && bunnyStoragePass && bunnyZoneName) {
83
+ const { data } = await axios({
84
+ url: `https://storage.bunnycdn.com/${bunnyStorageName}/__bcdn_perma_cache__/`,
85
+ headers: {
86
+ AccessKey: bunnyStoragePass,
87
+ },
88
+ });
89
+ for (let i = 0; i < data.length; i++) {
90
+ const { ObjectName } = data[i];
91
+ if (
92
+ ObjectName.startsWith(`pullzone__${bunnyZoneName}__`)
93
+ && (!permaCacheZoneFolder || permaCacheZoneFolder < ObjectName)
94
+ ) {
95
+ permaCacheZoneFolder = ObjectName;
88
96
  }
89
97
  }
90
98
  }
@@ -94,6 +102,7 @@ const saveViews = async () => {
94
102
  .where('at', '<', new Date(Date.now() - 1000 * sMaxAge))
95
103
  .get();
96
104
  const purgedUrls: string[] = [];
105
+ const purgeReqs: Promise<any>[] = [];
97
106
  for (let i = 0; i < pageViewsSnapshot.docs.length; i++) {
98
107
  const doc = pageViewsSnapshot.docs[i];
99
108
  const data = doc.data() as { url: string, isCachePurged?: true };
@@ -103,42 +112,46 @@ const saveViews = async () => {
103
112
  const url = data.url.replace(/\?.*$/, '');
104
113
  doc.ref.update({ isCachePurged: true });
105
114
  if (url?.startsWith(`https://${domain}`) && !purgedUrls.includes(url)) {
106
- await bunnyAxios('/purge', {
115
+ purgeReqs.push(bunnyAxios('/purge', {
107
116
  method: 'POST',
108
117
  params: {
109
118
  async: 'false',
110
119
  url,
111
120
  },
112
- });
121
+ }));
113
122
  purgedUrls.push(url);
114
123
  if (permaCacheZoneFolder) {
115
124
  let pathname = url.replace(`https://${domain}`, '');
116
- if (pathname.charAt(0) === '/') {
117
- pathname = pathname.slice(1);
118
- }
119
- const paths = pathname.split('/');
120
- const filename = paths.pop() || '';
121
- let folderpath = paths.join('/');
122
- if (folderpath) folderpath += '/';
123
- // https://support.bunny.net/hc/en-us/articles/360017048720-Perma-Cache-Folder-Structure-Explained
124
- const permaCachePath = `__bcdn_perma_cache__/${permaCacheZoneFolder}`
125
- + `/${folderpath}___${filename}___/___file___`;
126
- await axios({
127
- method: 'DELETE',
128
- url: `https://storage.bunnycdn.com/${bunnyStorageName}/${permaCachePath}`,
129
- headers: {
130
- AccessKey: bunnyStoragePass,
131
- },
132
- })
133
- .then(() => {
134
- axios.get(`${url}?__isrV=${deployRand}`).catch(error);
135
- })
136
- .catch((err) => {
137
- if (err.response?.status !== 404) throw err;
138
- });
125
+ const freshHtmlUrl = `https://${projectId}.web.app${pathname}?__isrV=${deployRand}`;
126
+ purgeReqs.push(
127
+ // eslint-disable-next-line no-loop-func
128
+ axios.get(freshHtmlUrl).then(({ data: freshHtml }: { data: string }) => {
129
+ if (pathname.charAt(0) === '/') {
130
+ pathname = pathname.slice(1);
131
+ }
132
+ const paths = pathname.split('/');
133
+ const filename = paths.pop() || '';
134
+ let folderpath = paths.join('/');
135
+ if (folderpath) folderpath += '/';
136
+ // https://support.bunny.net/hc/en-us/articles/360017048720-Perma-Cache-Folder-Structure-Explained
137
+ const permaCachePath = `__bcdn_perma_cache__/${permaCacheZoneFolder}`
138
+ + `/${folderpath}___${filename}___/___file___`;
139
+ axios({
140
+ method: 'PUT',
141
+ url: `https://storage.bunnycdn.com/${bunnyStorageName}/${permaCachePath}`,
142
+ headers: {
143
+ 'Content-Type': 'application/octet-stream',
144
+ Accept: 'application/json',
145
+ AccessKey: bunnyStoragePass,
146
+ },
147
+ data: freshHtml,
148
+ });
149
+ }),
150
+ );
139
151
  }
140
152
  }
141
153
  }
154
+ await Promise.all(purgeReqs);
142
155
  } catch (err: any) {
143
156
  if (err.response) {
144
157
  const _err: any = new Error('Cant purge bunny.net cache');
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/storefront",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce storefront with Astro",
6
6
  "bin": {
7
7
  "storefront": "./scripts/build-prod.sh"
@@ -30,7 +30,7 @@
30
30
  "lint:fix": "eslint -c ../eslint/storefront.staged.eslintrc.cjs src/lib/**/*.{ts,vue,astro} --fix"
31
31
  },
32
32
  "dependencies": {
33
- "@astrojs/node": "8.2.0",
33
+ "@astrojs/node": "8.2.1",
34
34
  "@astrojs/vue": "4.0.8",
35
35
  "@cloudcommerce/api": "workspace:*",
36
36
  "@cloudcommerce/config": "workspace:*",
@@ -44,7 +44,7 @@
44
44
  "@vite-pwa/astro": "^0.3.0",
45
45
  "@vueuse/core": "10.8.0",
46
46
  "@webcontainer/api": "^1.1.9",
47
- "astro": "4.4.1",
47
+ "astro": "4.4.4",
48
48
  "astro-capo": "^0.0.1",
49
49
  "chroma-js": "^2.4.2",
50
50
  "dotenv": "^16.4.4",
@@ -4,13 +4,14 @@ import type {
4
4
  Brands,
5
5
  Collections,
6
6
  } from '@cloudcommerce/api/types';
7
+ import type { SectionPreviewProps } from '@@sf/state/use-cms-preview';
7
8
  import {
8
9
  name as getName,
9
10
  categoriesList as getCategoriesList,
10
11
  } from '@ecomplus/utils';
11
12
  import useSharedData from '@@sf/composables/use-shared-data';
12
13
 
13
- export interface Props {
14
+ export interface Props extends Partial<SectionPreviewProps> {
14
15
  apiDoc?: Partial<Products | Categories | Brands | Collections>;
15
16
  categories?: Partial<Categories>[];
16
17
  domain?: string;
@@ -1,6 +1,7 @@
1
1
  import type { Ref } from 'vue';
2
2
  import type { SearchItem } from '@cloudcommerce/types';
3
3
  import type { SearchEngineInstance } from '@@sf/state/search-engine';
4
+ import type { SectionPreviewProps } from '@@sf/state/use-cms-preview';
4
5
  import {
5
6
  ref,
6
7
  computed,
@@ -21,7 +22,7 @@ import {
21
22
  import { SearchEngine } from '@@sf/state/search-engine';
22
23
  import { useSearchActiveFilters } from '@@sf/composables/use-search-filters';
23
24
 
24
- export interface Props {
25
+ export interface Props extends Partial<SectionPreviewProps> {
25
26
  term?: string | null;
26
27
  pageSize?: number;
27
28
  fixedParams?: SearchEngineInstance['params'];
@@ -2,7 +2,7 @@
2
2
  "name": "@cloudcommerce/test-base",
3
3
  "private": true,
4
4
  "type": "module",
5
- "version": "2.6.1",
5
+ "version": "2.6.3",
6
6
  "description": "E-Com Plus Cloud Commerce basic setup for testing",
7
7
  "main": "lib/index.js",
8
8
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/types",
3
3
  "type": "module",
4
- "version": "2.6.1",
4
+ "version": "2.6.3",
5
5
  "description": "E-Com Plus Cloud Commerce reusable type definitions",
6
6
  "main": "index.ts",
7
7
  "repository": {