cloudcommerce 0.38.0 → 0.39.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/ecomplus-stores/barra-doce/functions/many/package.json +3 -3
  3. package/ecomplus-stores/barra-doce/functions/ssr/package.json +6 -6
  4. package/ecomplus-stores/barra-doce/functions/ssr/src/layouts/PageHeader.astro +3 -6
  5. package/ecomplus-stores/barra-doce/functions/with-apps/package.json +3 -3
  6. package/ecomplus-stores/barra-doce/package.json +2 -2
  7. package/package.json +2 -2
  8. package/packages/api/package.json +1 -1
  9. package/packages/apps/affilate-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/package.json +1 -1
  43. package/packages/storefront/package.json +1 -1
  44. package/packages/storefront/src/lib/components/SharedData.astro +2 -2
  45. package/packages/storefront/src/lib/composables/use-breadcrumbs.ts +1 -1
  46. package/packages/storefront/src/lib/composables/{use-search-container.ts → use-search-showcase.ts} +10 -3
  47. package/packages/storefront/src/lib/composables/use-shared-data.ts +10 -5
  48. package/packages/storefront/src/lib/layouts/use-page-header.ts +6 -3
  49. package/packages/storefront/src/lib/layouts/use-page-main.ts +37 -8
  50. package/packages/storefront/src/lib/state/search-engine.ts +4 -3
  51. package/packages/test-base/package.json +1 -1
  52. package/packages/types/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,34 @@
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
+ ## [0.39.0](https://github.com/ecomplus/cloud-commerce/compare/v0.38.0...v0.39.0) (2023-12-15)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * **storefront:** Section "search-container" no more working, renamed to "search-showcase", composable renamed to `useSearchShowcase`
11
+ * **storefront:** Updaing `usePageHeader` props removing `categories` to enforce usage from `useSharedData` instead
12
+ * **storefront:** Editing `useSharedData` return, replacing `inlineClientJs` with `getInlineClientJs` function for just-in-case execution
13
+
14
+ Minor fixing prop value and return value typedef
15
+
16
+ ### Features
17
+
18
+ * **storefront:** Better types (generic) for `useSharedData` with categories/brands ([035c518](https://github.com/ecomplus/cloud-commerce/commit/035c5182e8ff8ad116823fbc18d696a062685db0))
19
+ * **storefront:** Setting up new section type `context-showcase` also with search container ([3dde5d6](https://github.com/ecomplus/cloud-commerce/commit/3dde5d6747d71bd6f3dbebebefe4825eacf5e673))
20
+ * **storefront:** Updating `useSearchContainer` with new optional props `params` ([f407f30](https://github.com/ecomplus/cloud-commerce/commit/f407f3006542a46ce52e028fcd36547194a553be))
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * **storefront:** Preset `SearchEngine` term as null ([a2eb4ee](https://github.com/ecomplus/cloud-commerce/commit/a2eb4eead313a97ada8d4331510e7149aeb2a2c3))
26
+ * **storefront:** Set `SearchEngine.params` as reactive (not shallow) ([6d0c19f](https://github.com/ecomplus/cloud-commerce/commit/6d0c19f3bfa16a7b7f0011747388e4f2dea449e7))
27
+
28
+
29
+ * **storefront:** Ensure early set _categories_ shared data from on page header layout composable ([7ce5838](https://github.com/ecomplus/cloud-commerce/commit/7ce58381dd7ffaed3bc6162bb2adb37fdce2db50))
30
+ * **storefront:** Renaming `useSearchContainer` to `useSearchShowcase` ([f915c05](https://github.com/ecomplus/cloud-commerce/commit/f915c05bf7c9a7833a1fe1304a6badecdaf67e61))
31
+ * **storefront:** Update `useSharedData` preventing unecessary stringify ([b0cffcd](https://github.com/ecomplus/cloud-commerce/commit/b0cffcd93a4b4722f3a4c15dddf195d315738fb6))
32
+
5
33
  ## [0.38.0](https://github.com/ecomplus/cloud-commerce/compare/v0.37.1...v0.38.0) (2023-12-13)
6
34
 
7
35
 
@@ -15,8 +15,8 @@
15
15
  },
16
16
  "main": "index.js",
17
17
  "dependencies": {
18
- "@cloudcommerce/feeds": "^0.37.1",
19
- "@cloudcommerce/firebase": "^0.37.1",
20
- "@cloudcommerce/passport": "^0.37.1"
18
+ "@cloudcommerce/feeds": "^0.38.0",
19
+ "@cloudcommerce/firebase": "^0.38.0",
20
+ "@cloudcommerce/passport": "^0.38.0"
21
21
  }
22
22
  }
@@ -17,15 +17,15 @@
17
17
  },
18
18
  "main": "index.js",
19
19
  "dependencies": {
20
- "@cloudcommerce/api": "^0.37.1",
21
- "@cloudcommerce/firebase": "^0.37.1",
22
- "@cloudcommerce/ssr": "^0.37.1",
20
+ "@cloudcommerce/api": "^0.38.0",
21
+ "@cloudcommerce/firebase": "^0.38.0",
22
+ "@cloudcommerce/ssr": "^0.38.0",
23
23
  "@headlessui/vue": "^1.7.16"
24
24
  },
25
25
  "devDependencies": {
26
- "@cloudcommerce/i18n": "^0.37.1",
27
- "@cloudcommerce/storefront": "^0.37.1",
28
- "@cloudcommerce/types": "^0.37.1",
26
+ "@cloudcommerce/i18n": "^0.38.0",
27
+ "@cloudcommerce/storefront": "^0.38.0",
28
+ "@cloudcommerce/types": "^0.38.0",
29
29
  "@fontsource/croissant-one": "^5.0.17",
30
30
  "@iconify-json/mingcute": "^1.1.11",
31
31
  "photoswipe": "^5.4.2"
@@ -10,19 +10,16 @@ const { settings, isHomepage } = routeContext;
10
10
  const LogoHeading = isHomepage ? 'h1' : 'h2';
11
11
  const {
12
12
  pitchBar,
13
- shopHeader: { categories, ...shopHeader },
13
+ shopHeader,
14
14
  } = await usePageHeader({ routeContext });
15
- const { inlineClientJS } = await useSharedData({
16
- field: 'categories',
17
- value: categories?.map(({ _id, ...c }) => c),
18
- });
15
+ const { getInlineClientJS } = await useSharedData({ field: 'categories' });
19
16
  ---
20
17
 
21
18
  <slot name="pitch-bar">
22
19
  {pitchBar.slides.length > 1 && <PitchBar {...pitchBar} client:idle />}
23
20
  {pitchBar.slides.length === 1 && <PitchBar {...pitchBar} />}
24
21
  </slot>
25
- <script is:inline set:html={inlineClientJS} />
22
+ <script is:inline set:html={getInlineClientJS()} />
26
23
  <ShopHeader {...shopHeader} client:context>
27
24
  <Fragment slot="logo">
28
25
  <a href="/" class="inline-block">
@@ -15,8 +15,8 @@
15
15
  },
16
16
  "main": "index.js",
17
17
  "dependencies": {
18
- "@cloudcommerce/events": "^0.37.1",
19
- "@cloudcommerce/firebase": "^0.37.1",
20
- "@cloudcommerce/modules": "^0.37.1"
18
+ "@cloudcommerce/events": "^0.38.0",
19
+ "@cloudcommerce/firebase": "^0.38.0",
20
+ "@cloudcommerce/modules": "^0.38.0"
21
21
  }
22
22
  }
@@ -23,9 +23,9 @@
23
23
  "url": "https://github.com/ecomplus/cloud-commerce/issues"
24
24
  },
25
25
  "dependencies": {
26
- "@cloudcommerce/cli": "^0.37.1"
26
+ "@cloudcommerce/cli": "^0.38.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@cloudcommerce/eslint": "^0.37.1"
29
+ "@cloudcommerce/eslint": "^0.38.0"
30
30
  }
31
31
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloudcommerce",
3
3
  "type": "module",
4
- "version": "0.38.0",
4
+ "version": "0.39.0",
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>",
@@ -30,7 +30,7 @@
30
30
  "vite": "^5.0.8",
31
31
  "vitest": "^1.0.4",
32
32
  "zx": "^7.2.3",
33
- "@cloudcommerce/eslint": "0.38.0"
33
+ "@cloudcommerce/eslint": "0.39.0"
34
34
  },
35
35
  "scripts": {
36
36
  "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": "0.38.0",
4
+ "version": "0.39.0",
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-affilate-program",
3
3
  "type": "module",
4
- "version": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.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": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-paghiper",
3
3
  "type": "module",
4
- "version": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
5
5
  "description": "E-Com Plus Cloud Commerce customers authentication (passport) API",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/ssr",
3
3
  "type": "module",
4
- "version": "0.38.0",
4
+ "version": "0.39.0",
5
5
  "description": "E-Com Plus Cloud Commerce storefront SSR",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/storefront",
3
3
  "type": "module",
4
- "version": "0.38.0",
4
+ "version": "0.39.0",
5
5
  "description": "E-Com Plus Cloud Commerce storefront with Astro",
6
6
  "bin": {
7
7
  "storefront": "./scripts/build-prod.sh"
@@ -6,7 +6,7 @@ import {
6
6
 
7
7
  export interface Props extends UseSharedDataProps {}
8
8
 
9
- const { inlineClientJS } = await useSharedData(Astro.props);
9
+ const { getInlineClientJS } = await useSharedData(Astro.props);
10
10
  ---
11
11
 
12
- <script is:inline set:html={inlineClientJS} />
12
+ <script is:inline set:html={getInlineClientJS()} />
@@ -22,7 +22,7 @@ const useBreadcrumbs = async (props: Props = {}) => {
22
22
  apiDoc = apiContext?.doc,
23
23
  domain = settings.domain,
24
24
  } = props;
25
- let categories: Props['categories'] = props.categories || data.categories;
25
+ let categories: Props['categories'] | null = props.categories || data.categories;
26
26
  if (!categories) {
27
27
  categories = (await useSharedData({ field: 'categories' })).value;
28
28
  }
@@ -5,12 +5,13 @@ import { SearchEngine } from '@@sf/state/search-engine';
5
5
  export interface Props {
6
6
  searchEngine?: InstanceType<typeof SearchEngine>;
7
7
  term?: string | null;
8
+ params?: Record<string, any>;
8
9
  sort?: '-sales' | '-created_at' | 'price' | '-price' | '-price_discount' | string;
9
10
  products?: SearchItem[];
10
11
  ssrError?: string | null;
11
12
  }
12
13
 
13
- const useSearchContainer = (props: Props) => {
14
+ const useSearchShowcase = (props: Props) => {
14
15
  let { term, searchEngine } = props;
15
16
  if (props.ssrError && !import.meta.env.SSR) {
16
17
  console.error(new Error(`SSR search error: ${props.ssrError}`));
@@ -27,6 +28,12 @@ const useSearchContainer = (props: Props) => {
27
28
  if (term !== undefined) {
28
29
  searchEngine.term.value = term;
29
30
  }
31
+ if (props.params) {
32
+ Object.assign(searchEngine.params, props.params);
33
+ }
34
+ if (props.sort) {
35
+ searchEngine.params.sort = props.sort;
36
+ }
30
37
  }
31
38
  if (!searchEngine.wasFetched.value && !props.products) {
32
39
  searchEngine.fetch().catch(console.error);
@@ -43,6 +50,6 @@ const useSearchContainer = (props: Props) => {
43
50
  };
44
51
  };
45
52
 
46
- export default useSearchContainer;
53
+ export default useSearchShowcase;
47
54
 
48
- export { useSearchContainer };
55
+ export { useSearchShowcase };
@@ -1,14 +1,19 @@
1
+ import type { Categories, Brands } from '@cloudcommerce/api/types';
1
2
  import { EventEmitter } from 'node:events';
2
3
 
3
- export interface Props {
4
- field: string;
5
- value?: any;
4
+ export type Props<T extends string = string> = {
5
+ field: T;
6
+ value?: T extends 'categories' ? Partial<Categories>[]
7
+ : T extends 'brands' ? Partial<Brands>[]
8
+ : any;
6
9
  timeout?: number;
7
10
  }
8
11
 
9
12
  const emitter = new EventEmitter();
10
13
 
11
- const useSharedData = async ({ field, value, timeout = 1000 }: Props) => {
14
+ const useSharedData = async <T extends string = string>(props: Props<T>) => {
15
+ const { field, timeout = 1000 } = props;
16
+ let value: typeof props.value | null = props.value;
12
17
  const $data = global.$storefront.data;
13
18
  if (value) {
14
19
  $data[field] = value;
@@ -32,7 +37,7 @@ const useSharedData = async ({ field, value, timeout = 1000 }: Props) => {
32
37
  }
33
38
  return {
34
39
  value,
35
- inlineClientJS: `
40
+ getInlineClientJS: () => `
36
41
  window.$storefront.data['${field}'] = ${JSON.stringify(value)};`,
37
42
  };
38
43
  };
@@ -1,9 +1,10 @@
1
1
  import type { RouteContext } from '@@sf/ssr-context';
2
2
  import type { Props as UseShopHeaderProps } from '@@sf/composables/use-shop-header';
3
3
  import api from '@cloudcommerce/api';
4
+ import { useSharedData } from '@@sf/composables/use-shared-data';
4
5
  import { parseLayoutContent } from '@@sf/composables/use-pitch-bar';
5
6
 
6
- type ShopHeaderProps = Omit<UseShopHeaderProps, 'header'>;
7
+ type ShopHeaderProps = Omit<UseShopHeaderProps, 'header' | 'categories'>;
7
8
 
8
9
  export interface Props {
9
10
  routeContext: RouteContext;
@@ -21,7 +22,7 @@ const usePageHeader = async ({ routeContext, listedCategoryFields }: Props) => {
21
22
  } = layoutContent;
22
23
  const pitchBar = parseLayoutContent(layoutContent);
23
24
  let { categories } = apiState;
24
- if (!categories && listedCategoryFields !== null) {
25
+ if (listedCategoryFields !== null) {
25
26
  try {
26
27
  categories = (await api.get('categories', {
27
28
  fields: listedCategoryFields || ([
@@ -39,8 +40,10 @@ const usePageHeader = async ({ routeContext, listedCategoryFields }: Props) => {
39
40
  console.error(err);
40
41
  }
41
42
  }
43
+ if (categories) {
44
+ useSharedData({ field: 'categories', value: categories });
45
+ }
42
46
  const shopHeader: ShopHeaderProps = {
43
- categories,
44
47
  menuCategorySlugs: inlineMenuCategories?.featured,
45
48
  menuRandomCategories: inlineMenuCategories?.random,
46
49
  isAlphabeticalSortSubmenu,
@@ -1,11 +1,12 @@
1
- import type { ResourceId } from '@cloudcommerce/types';
1
+ import type { ResourceId, Collections } from '@cloudcommerce/types';
2
2
  import type { PageContent } from '@@sf/content';
3
3
  import type { RouteContext } from '@@sf/ssr-context';
4
4
  import type { Props as UseBannerProps } from '@@sf/composables/use-banner';
5
5
  import type { Props as UseProductShelfProps } from '@@sf/composables/use-product-shelf';
6
- import type { Props as UseSearchContainerProps } from '@@sf/composables/use-search-container';
6
+ import type { Props as UseSearchShowcaseProps } from '@@sf/composables/use-search-showcase';
7
+ import { useSharedData } from '@@sf/composables/use-shared-data';
7
8
  import { useProductShelf } from '@@sf/composables/use-product-shelf';
8
- import { useSearchContainer } from '@@sf/composables/use-search-container';
9
+ import { useSearchShowcase } from '@@sf/composables/use-search-showcase';
9
10
 
10
11
  export interface Props {
11
12
  routeContext: RouteContext;
@@ -58,7 +59,7 @@ export const usePageSections = async <T extends CustomSection = CustomSection>
58
59
  | { type: 'related-products', props: {} }
59
60
  | { type: 'doc-description', props: {} }
60
61
  | { type: 'product-specifications', props: {} }
61
- | { type: 'search-container', props: UseSearchContainerProps }
62
+ | { type: 'search-showcase' | 'context-showcase', props: UseSearchShowcaseProps }
62
63
  > = [];
63
64
  if (sectionsContent) {
64
65
  await Promise.all(sectionsContent.map(async ({ type, ...sectionContent }, index) => {
@@ -125,11 +126,38 @@ export const usePageSections = async <T extends CustomSection = CustomSection>
125
126
  return;
126
127
  }
127
128
 
128
- if (type === 'search-container') {
129
- const props: UseSearchContainerProps = { ...sectionContent };
130
- if (routeContext.searchPageTerm !== undefined) {
129
+ if (type === 'search-showcase' || type === 'context-showcase') {
130
+ const props: UseSearchShowcaseProps = { ...sectionContent };
131
+ if (type === 'context-showcase') {
132
+ if (routeContext.fetchingApiContext) {
133
+ await routeContext.fetchingApiContext;
134
+ }
135
+ const { resource, doc } = routeContext.apiContext;
136
+ if (resource === 'categories' || resource === 'brands') {
137
+ const params = { [`${resource}.slug`]: [doc!.slug] };
138
+ if (resource === 'categories') {
139
+ const { value: categories } = await useSharedData({ field: 'categories' });
140
+ categories?.forEach(({ slug, parent }) => {
141
+ if (
142
+ slug && parent
143
+ && (parent._id === doc!._id || parent.slug === doc!.slug)
144
+ ) {
145
+ params[`categories.slug`].push(slug);
146
+ }
147
+ });
148
+ }
149
+ props.params = params;
150
+ } else if (resource === 'collections') {
151
+ const { products } = (doc as Collections);
152
+ if (products?.length) {
153
+ props.params = { _id: products };
154
+ }
155
+ }
156
+ } else if (routeContext.searchPageTerm !== undefined) {
131
157
  props.term = routeContext.searchPageTerm || null;
132
- const { searchEngine, fetching } = useSearchContainer(props);
158
+ }
159
+ if (props.term !== undefined || props.params) {
160
+ const { searchEngine, fetching } = useSearchShowcase(props);
133
161
  await fetching;
134
162
  props.products = searchEngine.products;
135
163
  props.ssrError = searchEngine.fetchError.value?.message;
@@ -137,6 +165,7 @@ export const usePageSections = async <T extends CustomSection = CustomSection>
137
165
  sections[index] = { type, props };
138
166
  return;
139
167
  }
168
+
140
169
  if (type === 'banners-grid') {
141
170
  sections[index] = {
142
171
  type,
@@ -2,6 +2,7 @@ import type { SearchItem, SearchResult } from '@cloudcommerce/types';
2
2
  import {
3
3
  ref,
4
4
  computed,
5
+ reactive,
5
6
  watch,
6
7
  shallowReactive,
7
8
  } from 'vue';
@@ -69,10 +70,10 @@ export const search = async ({
69
70
 
70
71
  export class SearchEngine {
71
72
  fields?: readonly string[];
72
- term = ref<string | null>('');
73
+ term = ref<string | null>(null);
73
74
  isWithCount = ref(true);
74
75
  isWithBuckets = ref(true);
75
- params = shallowReactive<Record<string, any>>({});
76
+ params = reactive<Record<string, any>>({});
76
77
  pageSize = ref(24);
77
78
  pageNumber = ref(1);
78
79
  #isFetching = ref(false);
@@ -114,7 +115,7 @@ export class SearchEngine {
114
115
  }
115
116
 
116
117
  async fetch(term?: string) {
117
- if (term && term !== this.term.value) {
118
+ if (term !== undefined && term !== this.term.value) {
118
119
  this.term.value = term;
119
120
  this.pageNumber.value = 1;
120
121
  }
@@ -2,7 +2,7 @@
2
2
  "name": "@cloudcommerce/test-base",
3
3
  "private": true,
4
4
  "type": "module",
5
- "version": "0.38.0",
5
+ "version": "0.39.0",
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": "0.38.0",
4
+ "version": "0.39.0",
5
5
  "description": "E-Com Plus Cloud Commerce reusable type definitions",
6
6
  "main": "index.ts",
7
7
  "repository": {