@shopbite-de/storefront 2.6.1 → 2.7.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/.env.example +13 -0
- package/.github/workflows/ci.yaml +2 -0
- package/CLAUDE.md +54 -30
- package/GLOSSARY.md +327 -0
- package/README.md +5 -6
- package/app/app.vue +50 -40
- package/app/components/Address/Card.vue +2 -2
- package/app/components/Address/Detail.vue +17 -45
- package/app/components/Address/Form.vue +38 -26
- package/app/components/BranchSwitch.vue +40 -0
- package/app/components/Cart/Bar.vue +9 -9
- package/app/components/Cart/Item.vue +27 -36
- package/app/components/Cart/QuickView.vue +17 -16
- package/app/components/Cart/Upsell.vue +19 -27
- package/app/components/Category/Breadcrumb.vue +3 -8
- package/app/components/Category/FilterGroup.vue +6 -6
- package/app/components/Category/Listing.vue +44 -66
- package/app/components/Checkout/DeliveryTimeSelect.vue +21 -48
- package/app/components/Checkout/OrderMessage.vue +29 -0
- package/app/components/Checkout/OrdererAddress.vue +40 -0
- package/app/components/Checkout/PaymentAndDelivery.vue +40 -35
- package/app/components/Checkout/Summary.vue +89 -74
- package/app/components/Checkout/VoucherInput.vue +8 -8
- package/app/components/Contact/Form.vue +97 -13
- package/app/components/Footer.vue +2 -2
- package/app/components/Header.vue +9 -9
- package/app/components/Home/Categories.vue +13 -17
- package/app/components/Home/Facts.vue +6 -4
- package/app/components/Home/Hero.vue +1 -1
- package/app/components/Home/Highlights.vue +8 -8
- package/app/components/Home/Restaurant.vue +2 -2
- package/app/components/Menu/BonCard.vue +21 -37
- package/app/components/Menu/CartPanel.vue +2 -2
- package/app/components/Menu/CategoryIndex.vue +8 -12
- package/app/components/Menu/OrderMode.vue +2 -2
- package/app/components/Menu/SectionHeader.vue +6 -10
- package/app/components/Navigation/MobileTop.vue +12 -20
- package/app/components/Order/Confirmation.vue +10 -10
- package/app/components/Order/Detail.vue +47 -49
- package/app/components/Product/Configurator.vue +46 -30
- package/app/components/Product/CrossSelling.vue +56 -71
- package/app/components/Product/DeselectIngredient.vue +10 -11
- package/app/components/Product/Detail.vue +62 -55
- package/app/components/Product/FoodLabels.vue +4 -9
- package/app/components/Product/QuickView.vue +22 -30
- package/app/components/User/Detail.vue +20 -43
- package/app/components/User/LoginForm.vue +11 -17
- package/app/components/User/RegistrationForm.vue +3 -3
- package/app/components/Wishlist.vue +99 -106
- package/app/components/WishlistSaveButton.vue +17 -9
- package/app/composables/useAccountAddresses.ts +89 -0
- package/app/composables/useAccountOrders.ts +35 -0
- package/app/composables/useAddToCart.ts +63 -139
- package/app/composables/useCartData.ts +55 -0
- package/app/composables/useCartMutations.ts +93 -85
- package/app/composables/useCartUpsell.ts +27 -71
- package/app/composables/useCategoryListing.ts +36 -59
- package/app/composables/useCategorySeo.ts +11 -16
- package/app/composables/useCheckoutMethodGuard.ts +22 -46
- package/app/composables/useCheckoutMethods.ts +89 -0
- package/app/composables/useCheckoutOrderMessage.ts +19 -0
- package/app/composables/useCheckoutOrderer.ts +69 -0
- package/app/composables/useCommercePrice.ts +46 -9
- package/app/composables/useContactForm.ts +25 -32
- package/app/composables/useCustomer.ts +169 -0
- package/app/composables/useDeliveryTime.ts +112 -122
- package/app/composables/useHolidays.ts +12 -62
- package/app/composables/useHomeMenuCategories.ts +5 -5
- package/app/composables/useListingSearch.ts +9 -8
- package/app/composables/useLiveShopData.ts +15 -9
- package/app/composables/useMenuRootId.ts +3 -6
- package/app/composables/useMenuSection.ts +14 -0
- package/app/composables/useMenuSectionSchema.ts +23 -30
- package/app/composables/useNavigation.ts +24 -29
- package/app/composables/useOpeningHours.ts +21 -0
- package/app/composables/useOpeningHoursData.ts +9 -9
- package/app/composables/useOrder.ts +37 -0
- package/app/composables/useOrderMode.ts +18 -16
- package/app/composables/usePlaceOrder.ts +37 -0
- package/app/composables/useProductCartQuantity.ts +6 -6
- package/app/composables/useProductDetail.ts +28 -53
- package/app/composables/useProductEvents.ts +6 -5
- package/app/composables/useProductQuickView.ts +35 -68
- package/app/composables/useRegistrationForm.ts +85 -34
- package/app/composables/useRestaurantSchema.ts +7 -7
- package/app/composables/useSearchTracking.ts +6 -6
- package/app/composables/useSectionRoute.ts +48 -0
- package/app/composables/useServiceSchedule.ts +23 -0
- package/app/composables/useShippingLeadTime.ts +8 -6
- package/app/composables/useShippingMethodChoice.ts +13 -23
- package/app/composables/useShippingMethods.ts +31 -0
- package/app/composables/useShopConfig.ts +60 -0
- package/app/composables/useShopData.ts +20 -0
- package/app/composables/useSortingSelection.ts +5 -8
- package/app/composables/useStoreStatus.ts +13 -37
- package/app/composables/useTopSellers.ts +3 -3
- package/app/composables/useTrackEvent.ts +29 -24
- package/app/composables/useVoucherCode.ts +47 -12
- package/app/composables/useWishlistEntries.ts +233 -177
- package/app/error.vue +3 -2
- package/app/layouts/account.vue +4 -3
- package/app/pages/[...all].vue +6 -16
- package/app/pages/account/recover/password/index.vue +6 -14
- package/app/pages/anmelden.vue +1 -1
- package/app/pages/bestellung/[id]/erfolg.vue +3 -3
- package/app/pages/bestellung/[id]/fehler.vue +18 -29
- package/app/pages/bestellung/kasse.vue +24 -7
- package/app/pages/konto/adressen.vue +95 -40
- package/app/pages/konto/bestellungen.vue +10 -13
- package/app/pages/konto/index.vue +12 -2
- package/app/pages/konto/profil.vue +241 -42
- package/app/pages/passwort-vergessen.vue +5 -10
- package/app/pages/registrierung/bestaetigen.vue +9 -23
- package/app/pages/registrierung/index.vue +19 -11
- package/app/pages/suche.vue +29 -29
- package/app/plugins/shopware-layer-offline.ts +38 -0
- package/app/plugins/visitor-has-session.server.ts +19 -0
- package/app/utils/accountMessages.ts +74 -0
- package/app/utils/accountReads.ts +34 -0
- package/app/utils/bffWrite.ts +89 -0
- package/app/utils/dish.ts +121 -0
- package/app/utils/leadTime.ts +25 -29
- package/app/utils/media.ts +11 -17
- package/app/utils/menuGroups.ts +22 -35
- package/app/utils/money.ts +41 -0
- package/app/utils/openingHours.ts +30 -30
- package/app/utils/orderStatus.ts +17 -0
- package/app/utils/productUrl.ts +14 -31
- package/app/utils/restaurantTime.ts +326 -0
- package/app/utils/schema.ts +39 -42
- package/app/utils/wishlist.ts +139 -0
- package/docs/adr/0001-backend-agnostic-storefront.md +409 -0
- package/eslint.config.mjs +42 -2
- package/nuxt.config.ts +28 -0
- package/package.json +1 -1
- package/server/adapters/memory/cart.ts +370 -0
- package/server/adapters/memory/catalog.ts +367 -0
- package/server/adapters/memory/contact.ts +89 -0
- package/server/adapters/memory/customer.ts +458 -0
- package/server/adapters/memory/demo-menu.json +1190 -0
- package/server/adapters/memory/demoImages.ts +13 -0
- package/server/adapters/memory/demoMenu.ts +234 -0
- package/server/adapters/memory/demoNavigation.ts +71 -0
- package/server/adapters/memory/index.ts +122 -0
- package/server/adapters/memory/navigation.ts +168 -0
- package/server/adapters/memory/ordering.ts +379 -0
- package/server/adapters/memory/seed.ts +136 -0
- package/server/adapters/memory/wishlist.ts +166 -0
- package/server/adapters/notImplemented.ts +67 -0
- package/server/adapters/registry.ts +32 -0
- package/server/adapters/runtimeConfig.ts +14 -0
- package/server/adapters/shopware/cart.ts +792 -0
- package/server/adapters/shopware/catalog.ts +850 -0
- package/server/adapters/shopware/checkout.ts +138 -0
- package/server/adapters/shopware/contact.ts +255 -0
- package/server/adapters/shopware/customer.ts +460 -0
- package/server/adapters/shopware/index.ts +165 -0
- package/server/adapters/shopware/menuRoot.ts +24 -0
- package/server/adapters/shopware/navigation.ts +426 -0
- package/server/adapters/shopware/ordering.ts +1185 -0
- package/server/adapters/shopware/request.ts +67 -0
- package/server/adapters/shopware/shop.ts +249 -0
- package/server/adapters/shopware/storeApi.ts +62 -0
- package/server/adapters/shopware/wishlist.ts +473 -0
- package/server/api/__sitemap__/urls.get.ts +10 -38
- package/server/api/account/addresses/[addressId]/default.post.ts +13 -0
- package/server/api/account/addresses/[addressId].delete.ts +14 -0
- package/server/api/account/addresses/[addressId].patch.ts +15 -0
- package/server/api/account/addresses/index.get.ts +6 -0
- package/server/api/account/addresses/index.post.ts +9 -0
- package/server/api/account/email.post.ts +10 -0
- package/server/api/account/index.delete.ts +11 -0
- package/server/api/account/index.get.ts +9 -0
- package/server/api/account/login.post.ts +14 -0
- package/server/api/account/logout.post.ts +11 -0
- package/server/api/account/orders.get.ts +13 -0
- package/server/api/account/password-reset/confirm.post.ts +13 -0
- package/server/api/account/password-reset.post.ts +16 -0
- package/server/api/account/password.post.ts +18 -0
- package/server/api/account/profile.patch.ts +6 -0
- package/server/api/account/register/confirm.post.ts +13 -0
- package/server/api/account/register.post.ts +15 -0
- package/server/api/breadcrumb/[sectionId].get.ts +33 -0
- package/server/api/cart/index.get.ts +4 -0
- package/server/api/cart/lines/[lineId].delete.ts +6 -0
- package/server/api/cart/lines/[lineId].patch.ts +10 -0
- package/server/api/cart/lines.post.ts +10 -0
- package/server/api/cart/vouchers/[code].delete.ts +9 -0
- package/server/api/cart/vouchers.post.ts +12 -0
- package/server/api/checkout/guest.post.ts +13 -0
- package/server/api/checkout/orderer/addresses/[addressId].patch.ts +16 -0
- package/server/api/checkout/orderer.get.ts +10 -0
- package/server/api/checkout/orders.post.ts +60 -0
- package/server/api/checkout/payment-methods.get.ts +9 -0
- package/server/api/checkout/selection.get.ts +10 -0
- package/server/api/checkout/selection.post.ts +14 -0
- package/server/api/checkout/shipping-methods.get.ts +9 -0
- package/server/api/contact/form.get.ts +13 -0
- package/server/api/contact/index.post.ts +24 -0
- package/server/api/listing/[sectionId].get.ts +33 -0
- package/server/api/menu/dishes/[dishId]/variant.get.ts +29 -0
- package/server/api/menu/dishes/[dishId].get.ts +19 -0
- package/server/api/menu/dishes/index.get.ts +26 -0
- package/server/api/menu/media/[name].get.ts +18 -0
- package/server/api/menu/root.get.ts +12 -0
- package/server/api/menu/sections/[sectionId].get.ts +18 -0
- package/server/api/menu/upsell.get.ts +12 -0
- package/server/api/navigation/[kind].get.ts +75 -0
- package/server/api/orders/[orderId]/payment.post.ts +24 -0
- package/server/api/orders/[orderId].get.ts +13 -0
- package/server/api/payment-methods.get.ts +11 -15
- package/server/api/resolve-path.get.ts +20 -0
- package/server/api/search.get.ts +16 -80
- package/server/api/session.post.ts +18 -0
- package/server/api/shop/branches.get.ts +9 -0
- package/server/api/shop/config.get.ts +9 -0
- package/server/api/shop/holidays.get.ts +9 -0
- package/server/api/shop/opening-hours.get.ts +9 -0
- package/server/api/top-sellers.get.ts +14 -50
- package/server/api/wishlist/entries/[entryId].delete.ts +8 -0
- package/server/api/wishlist/entries.post.ts +13 -0
- package/server/api/wishlist/index.get.ts +13 -0
- package/server/api/wishlist/merge.post.ts +12 -0
- package/server/plugins/visitor-session.ts +35 -0
- package/server/ports/CartPort.ts +48 -0
- package/server/ports/CatalogPort.ts +66 -0
- package/server/ports/CheckoutPort.ts +128 -0
- package/server/ports/ContactPort.ts +38 -0
- package/server/ports/CustomerPort.ts +154 -0
- package/server/ports/NavigationPort.ts +58 -0
- package/server/ports/OrderPort.ts +31 -0
- package/server/ports/ShopPort.ts +29 -0
- package/server/ports/WishlistPort.ts +47 -0
- package/server/ports/index.ts +42 -0
- package/server/ports/session.ts +22 -0
- package/server/routes/llms.txt.ts +28 -154
- package/server/session/forwardedFor.ts +24 -0
- package/server/session/sameOrigin.ts +47 -0
- package/server/session/seal.ts +147 -0
- package/server/session/visitorSession.ts +288 -0
- package/server/utils/accountRoutes.ts +173 -0
- package/server/utils/backend.ts +21 -0
- package/server/utils/backoff.ts +18 -5
- package/server/utils/cacheKeys.ts +11 -0
- package/server/utils/cachePurge.ts +47 -27
- package/server/utils/cartRoutes.ts +124 -0
- package/server/utils/catalogData.ts +24 -0
- package/server/utils/checkoutRoutes.ts +326 -0
- package/server/utils/contactRoutes.ts +86 -0
- package/server/utils/domainHttp.ts +73 -0
- package/server/utils/listingParams.ts +49 -20
- package/server/utils/llmsTxt.ts +64 -19
- package/server/utils/navigationData.ts +14 -0
- package/server/utils/orderPlacement.ts +322 -0
- package/server/utils/outageBreaker.ts +126 -0
- package/server/utils/pathRoutes.ts +160 -0
- package/server/utils/requestBody.ts +43 -0
- package/server/utils/shopData.ts +132 -0
- package/server/utils/sitemap.ts +14 -36
- package/server/utils/storeApi.ts +71 -23
- package/server/utils/visitorSession.ts +209 -0
- package/server/utils/wishlistRoutes.ts +55 -0
- package/shared/domain/customer/index.ts +2 -0
- package/shared/domain/customer/types.ts +88 -0
- package/shared/domain/discoverability/index.ts +4 -0
- package/shared/domain/discoverability/paths.ts +93 -0
- package/shared/domain/discoverability/route.ts +32 -0
- package/shared/domain/discoverability/types.ts +75 -0
- package/shared/domain/index.ts +11 -0
- package/shared/domain/kernel/calendar.ts +88 -0
- package/shared/domain/kernel/errors.ts +100 -0
- package/shared/domain/kernel/freeze.ts +13 -0
- package/shared/domain/kernel/ids.ts +6 -0
- package/shared/domain/kernel/index.ts +8 -0
- package/shared/domain/kernel/media.ts +17 -0
- package/shared/domain/kernel/money.ts +104 -0
- package/shared/domain/kernel/timeOfDay.ts +39 -0
- package/shared/domain/menu/dishConfiguration.ts +72 -0
- package/shared/domain/menu/index.ts +3 -0
- package/shared/domain/menu/types.ts +185 -0
- package/shared/domain/ordering/index.ts +3 -0
- package/shared/domain/ordering/time.ts +114 -0
- package/shared/domain/ordering/types.ts +195 -0
- package/shared/domain/restaurant/holiday.ts +38 -0
- package/shared/domain/restaurant/index.ts +4 -0
- package/shared/domain/restaurant/openingInterval.ts +97 -0
- package/shared/domain/restaurant/types.ts +75 -0
- package/test/a11y/presets.test.ts +49 -31
- package/test/contract/cart.contract.ts +592 -0
- package/test/contract/cart.spec.ts +5 -0
- package/test/contract/cartFixtures.ts +573 -0
- package/test/contract/catalog.contract.ts +714 -0
- package/test/contract/catalog.spec.ts +5 -0
- package/test/contract/catalogFixtures.ts +572 -0
- package/test/contract/checkout.contract.ts +123 -0
- package/test/contract/checkout.spec.ts +5 -0
- package/test/contract/contact.contract.ts +149 -0
- package/test/contract/contact.spec.ts +4 -0
- package/test/contract/contactFixtures.ts +148 -0
- package/test/contract/customer.contract.ts +831 -0
- package/test/contract/customer.spec.ts +4 -0
- package/test/contract/customerFixtures.ts +468 -0
- package/test/contract/fixtures.ts +260 -0
- package/test/contract/harness.ts +45 -0
- package/test/contract/navigation.contract.ts +336 -0
- package/test/contract/navigation.spec.ts +5 -0
- package/test/contract/navigationFixtures.ts +311 -0
- package/test/contract/ordering.contract.ts +655 -0
- package/test/contract/ordering.spec.ts +4 -0
- package/test/contract/orderingFixtures.ts +498 -0
- package/test/contract/shop.contract.ts +164 -0
- package/test/contract/shop.spec.ts +5 -0
- package/test/contract/wishlist.contract.ts +375 -0
- package/test/contract/wishlist.spec.ts +4 -0
- package/test/contract/wishlistFixtures.ts +199 -0
- package/test/nuxt/AccountPagesPreset.test.ts +320 -83
- package/test/nuxt/AuthPagesPreset.test.ts +17 -24
- package/test/nuxt/CartBar.test.ts +12 -8
- package/test/nuxt/CartCheckoutPreset.test.ts +36 -33
- package/test/nuxt/CartItem.test.ts +39 -20
- package/test/nuxt/CartQuickView.test.ts +106 -0
- package/test/nuxt/CartUpsell.test.ts +37 -39
- package/test/nuxt/CategoryBreadcrumb.test.ts +26 -0
- package/test/nuxt/CheckoutFormsPreset.test.ts +92 -13
- package/test/nuxt/CheckoutOnePage.test.ts +28 -21
- package/test/nuxt/CheckoutPageMessage.test.ts +31 -0
- package/test/nuxt/CheckoutSummary.test.ts +163 -48
- package/test/nuxt/CheckoutVoucherInput.test.ts +77 -80
- package/test/nuxt/ContactFormPreset.test.ts +97 -36
- package/test/nuxt/DeliveryTimeSelect.test.ts +72 -45
- package/test/nuxt/FooterStoreStatus.test.ts +2 -2
- package/test/nuxt/HeaderFooterPreset.test.ts +11 -19
- package/test/nuxt/HomeCategories.test.ts +47 -0
- package/test/nuxt/HomeLeadTimes.test.ts +3 -3
- package/test/nuxt/MenuBonCard.test.ts +45 -32
- package/test/nuxt/NavigationMobileTop.test.ts +30 -28
- package/test/nuxt/OrderPagesPreset.test.ts +83 -52
- package/test/nuxt/PaymentAndDelivery.test.ts +25 -26
- package/test/nuxt/ProductConfigurator.test.ts +81 -0
- package/test/nuxt/ProductCrossSelling.test.ts +23 -20
- package/test/nuxt/ProductDeselectIngredient.test.ts +6 -9
- package/test/nuxt/ProductFoodLabels.test.ts +7 -24
- package/test/nuxt/ProductSheetPreset.test.ts +24 -24
- package/test/nuxt/RegisterConfirmPage.test.ts +26 -45
- package/test/nuxt/RegistrationForm.test.ts +57 -53
- package/test/nuxt/RegistrationPage.test.ts +37 -0
- package/test/nuxt/WishlistPage.test.ts +119 -43
- package/test/nuxt/WishlistSaveButton.test.ts +39 -12
- package/test/nuxt/accountSwitch.test.ts +106 -0
- package/test/nuxt/bffWrite.test.ts +41 -0
- package/test/nuxt/liveShopData.test.ts +36 -68
- package/test/nuxt/shopwareLayerOffline.test.ts +32 -0
- package/test/nuxt/useAddToCart.test.ts +116 -174
- package/test/nuxt/useCartMutations.test.ts +165 -113
- package/test/nuxt/useCartUpsell.test.ts +36 -63
- package/test/nuxt/useCategoryListing.test.ts +75 -118
- package/test/nuxt/useCheckoutMethodGuard.test.ts +54 -105
- package/test/nuxt/useCustomer.test.ts +127 -0
- package/test/nuxt/useDeliveryTime.test.ts +169 -157
- package/test/nuxt/useNavigation.test.ts +81 -0
- package/test/nuxt/useOpeningHoursData.test.ts +18 -18
- package/test/nuxt/useOrder.test.ts +38 -0
- package/test/nuxt/usePlaceOrder.test.ts +88 -0
- package/test/nuxt/useSearchTracking.test.ts +2 -2
- package/test/nuxt/useSectionRoute.test.ts +86 -0
- package/test/nuxt/useShippingLeadTime.test.ts +17 -17
- package/test/nuxt/useShippingMethodChoice.test.ts +22 -22
- package/test/nuxt/useShippingMethods.test.ts +71 -0
- package/test/nuxt/useShopConfig.test.ts +64 -0
- package/test/nuxt/useStoreStatus.test.ts +34 -50
- package/test/nuxt/useTopSellers.test.ts +6 -5
- package/test/nuxt/useTrackEvent.test.ts +68 -6
- package/test/nuxt/useWishlistEntries.test.ts +392 -128
- package/test/support/cart.ts +43 -0
- package/test/support/dishes.ts +116 -0
- package/test/support/navigation.ts +17 -0
- package/test/unit/accountMessages.spec.ts +53 -0
- package/test/unit/accountRoutes.spec.ts +637 -0
- package/test/unit/adapters/memoryCustomer.spec.ts +67 -0
- package/test/unit/adapters/memoryDemoMenu.spec.ts +174 -0
- package/test/unit/adapters/registry.spec.ts +100 -0
- package/test/unit/adapters/shopwareCart.spec.ts +636 -0
- package/test/unit/adapters/shopwareCatalog.spec.ts +486 -0
- package/test/unit/adapters/shopwareCheckout.spec.ts +197 -0
- package/test/unit/adapters/shopwareContact.spec.ts +296 -0
- package/test/unit/adapters/shopwareCustomer.spec.ts +256 -0
- package/test/unit/adapters/shopwareNavigation.spec.ts +594 -0
- package/test/unit/adapters/shopwareOrdering.spec.ts +620 -0
- package/test/unit/adapters/shopwareShop.spec.ts +259 -0
- package/test/unit/adapters/shopwareWishlist.spec.ts +306 -0
- package/test/unit/adapters/useBackend.spec.ts +41 -0
- package/test/unit/backoff.spec.ts +47 -0
- package/test/unit/boundedCache.spec.ts +59 -59
- package/test/unit/cacheKeys.spec.ts +44 -0
- package/test/unit/cachePurge.spec.ts +44 -19
- package/test/unit/cartRoutes.spec.ts +567 -0
- package/test/unit/catalogRoutes.spec.ts +287 -0
- package/test/unit/checkoutRoutes.spec.ts +545 -0
- package/test/unit/dish.spec.ts +128 -0
- package/test/unit/domain/discoverability.spec.ts +154 -0
- package/test/unit/domain/dishConfiguration.spec.ts +85 -0
- package/test/unit/domain/money.spec.ts +102 -0
- package/test/unit/domain/time.spec.ts +336 -0
- package/test/unit/domainHttp.spec.ts +74 -0
- package/test/unit/forwardedFor.spec.ts +24 -0
- package/test/unit/layoutCacheRoutes.spec.ts +47 -471
- package/test/unit/leadTime.spec.ts +28 -23
- package/test/unit/llmsTxt.spec.ts +120 -9
- package/test/unit/media.spec.ts +25 -26
- package/test/unit/menuGroups.spec.ts +31 -21
- package/test/unit/navigationRoutes.spec.ts +648 -0
- package/test/unit/nitroStubs.ts +6 -1
- package/test/unit/openingHours.spec.ts +57 -34
- package/test/unit/orderPlacement.spec.ts +362 -0
- package/test/unit/outageBreaker.spec.ts +213 -0
- package/test/unit/productUrl.spec.ts +10 -28
- package/test/unit/requestBody.spec.ts +56 -0
- package/test/unit/restaurantTime.spec.ts +295 -0
- package/test/unit/schema.spec.ts +58 -26
- package/test/unit/session/sameOrigin.spec.ts +76 -0
- package/test/unit/session/seal.spec.ts +128 -0
- package/test/unit/session/visitorSession.spec.ts +439 -0
- package/test/unit/shopRoutes.spec.ts +257 -0
- package/test/unit/sitemap.spec.ts +11 -47
- package/test/unit/storeApiForVisitor.spec.ts +109 -0
- package/test/unit/useCategorySeo.spec.ts +57 -31
- package/test/unit/wishlistContactRoutes.spec.ts +607 -0
- package/vitest.config.ts +5 -1
- package/app/components/SalesChannelSwitch.vue +0 -73
- package/app/composables/useBusinessHours.ts +0 -192
- package/app/composables/useCategoryById.ts +0 -10
- package/app/composables/useNavigationSearch.ts +0 -45
- package/app/composables/useProductConfigurator.ts +0 -70
- package/app/composables/useProductCrossSelling.ts +0 -42
- package/app/composables/useProductVariants.ts +0 -61
- package/app/composables/useProductVariantsZwei.ts +0 -62
- package/app/composables/useSeoUrlRoute.ts +0 -124
- package/app/composables/useShopBiteConfig.ts +0 -69
- package/app/composables/useSyncWishlist.ts +0 -119
- package/app/types/Association.d.ts +0 -14
- package/app/utils/product.ts +0 -139
- package/app/utils/seoPath.ts +0 -68
- package/app/utils/time.ts +0 -20
- package/server/api/breadcrumb/[categoryId].get.ts +0 -31
- package/server/api/category/[categoryId].get.ts +0 -37
- package/server/api/listing/[categoryId].get.ts +0 -102
- package/server/api/navigation/[type].get.ts +0 -97
- package/server/api/product/[productId]/cross-selling.get.ts +0 -26
- package/server/api/product/[productId].get.ts +0 -76
- package/server/api/product/variant.get.ts +0 -98
- package/server/api/seo-url/index.get.ts +0 -17
- package/server/api/seo-url/known.get.ts +0 -33
- package/server/api/shopbite/business-hours.get.ts +0 -22
- package/server/api/shopbite/config.get.ts +0 -6
- package/server/api/shopbite/holidays.get.ts +0 -20
- package/server/utils/menuRoot.ts +0 -31
- package/server/utils/seoPaths.ts +0 -130
- package/server/utils/seoUrlCache.ts +0 -98
- package/server/utils/shopBiteConfig.ts +0 -30
- package/test/nuxt/useBusinessHours.test.ts +0 -106
- package/test/nuxt/useProductConfigurator.test.ts +0 -87
- package/test/nuxt/useProductVariants.test.ts +0 -95
- package/test/nuxt/useProductVariantsZwei.test.ts +0 -52
- package/test/nuxt/useSeoUrlRoute.test.ts +0 -176
- package/test/nuxt/useShopBiteConfig.test.ts +0 -131
- package/test/nuxt/useSyncWishlist.test.ts +0 -85
- package/test/unit/product.spec.ts +0 -160
- package/test/unit/seoPath.spec.ts +0 -161
- package/test/unit/seoPaths.spec.ts +0 -117
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: accepted
|
|
3
|
+
date: 2026-11-20
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 0001: Backend-agnostic storefront (ports and adapters behind a BFF)
|
|
7
|
+
|
|
8
|
+
## Context
|
|
9
|
+
|
|
10
|
+
The storefront is welded to Shopware. At 2.6.0 about 117 of 208 source files depend on it: `#shopware` types, the `@shopware/composables` layer and its auto-imported composables, `@shopware/api-client`, the generated `api-types`. 18 files call the Store API straight from the browser, and the server routes pass raw Shopware shapes (products, line items, SEO URLs) on to the app. A restaurant that runs another backend cannot use the storefront, and every Shopware upgrade reaches into components.
|
|
11
|
+
|
|
12
|
+
The storefront has its own rules that have nothing to do with Shopware: a dish with extras and removed ingredients is one cart line; wished times lie on a 5-minute grid within the opening hours, after the lead time of the chosen shipping method; holidays close the restaurant. Today these rules are spread over composables and depend on Shopware's data model.
|
|
13
|
+
|
|
14
|
+
## Decision
|
|
15
|
+
|
|
16
|
+
**The storefront works against any shop backend. Shopware becomes one adapter.**
|
|
17
|
+
|
|
18
|
+
### Backend for frontend
|
|
19
|
+
|
|
20
|
+
The browser talks only to the storefront's own Nitro routes (`/api/...`). No Store API call, access key or backend shape reaches the browser. The routes answer in the storefront's domain types (`shared/domain`).
|
|
21
|
+
|
|
22
|
+
The storefront keeps its own session in an HttpOnly cookie. Whatever a backend needs to recognise a visitor (Shopware's `sw-context-token`, a Sylius cart token and JWT) travels in that cookie sealed (encrypted and authenticated with the shop's password), so the browser can neither read nor change it, and is read and written only by the adapter, through `BackendSession` (`server/ports/session.ts`). Built in step 4 (see Progress).
|
|
23
|
+
|
|
24
|
+
### Ports and adapters
|
|
25
|
+
|
|
26
|
+
Ports are TypeScript interfaces in `server/ports/`, cut along ShopBite's language ([GLOSSARY.md](../../GLOSSARY.md)), not Shopware's:
|
|
27
|
+
|
|
28
|
+
| Port | Context | What it answers |
|
|
29
|
+
| ---------------- | --------------------- | ---------------------------------------------------------------------- |
|
|
30
|
+
| `CatalogPort` | Menu | menu sections, dishes, variants, extras, search, top sellers, upsell |
|
|
31
|
+
| `NavigationPort` | Discoverability | navigations, breadcrumbs, path resolution with redirects, sitemap |
|
|
32
|
+
| `CartPort` | Ordering | the cart, one line per dish configuration, vouchers |
|
|
33
|
+
| `CheckoutPort` | Ordering | shipping and payment methods, guest details, placing orders, payment |
|
|
34
|
+
| `OrderPort` | Ordering | placed orders with the storefront's own order and payment status |
|
|
35
|
+
| `CustomerPort` | Guest & Account | login, registration, profile, addresses, countries |
|
|
36
|
+
| `WishlistPort` | Guest & Account | the customer's wishlist of dish configurations |
|
|
37
|
+
| `ShopPort` | Restaurant operations | configuration, opening hours, holidays, branches |
|
|
38
|
+
| `ContactPort` | Restaurant operations | contact messages |
|
|
39
|
+
|
|
40
|
+
The ports live on the server because only the server talks to a backend and holds the session. The domain types live in `shared/domain/` so the app can type the BFF answers with them.
|
|
41
|
+
|
|
42
|
+
Two adapters in `server/adapters/`:
|
|
43
|
+
|
|
44
|
+
- `shopware`: today's behaviour over the Store API and the ShopBite plugin.
|
|
45
|
+
- `memory`: the whole backend in process memory, seeded with the quickstart's demo restaurant. It proves that the ports can be served without Shopware and backs the contract tests.
|
|
46
|
+
|
|
47
|
+
Runtime config `shopBite.backend` (`NUXT_SHOP_BITE_BACKEND`, default `shopware`) selects the adapter; server routes reach it with `useBackend(event)` (`server/utils/backend.ts`), one instance per process. Ports an adapter does not have yet reject with the domain error `not_implemented`.
|
|
48
|
+
|
|
49
|
+
Each port gets a contract suite in `test/contract/` that runs against every adapter (`runContract`). A suite describes a scenario in domain terms; each adapter fixture builds a backend holding it (the memory adapter from its seed, the Shopware adapter from a fake Store API answering Shopware JSON). Adapter-specific edge cases (what Shopware sends that the domain cannot express) are unit tests next to the adapter.
|
|
50
|
+
|
|
51
|
+
Caching, backoff and the resilient loaders stay in the server routes around the port calls, not in the adapters, so every adapter gets them and a contract test sees the adapter's own behaviour.
|
|
52
|
+
|
|
53
|
+
### Bounded contexts and context map
|
|
54
|
+
|
|
55
|
+
- **Menu**: what the restaurant offers.
|
|
56
|
+
- **Ordering**: cart, checkout, delivery or pickup, orders.
|
|
57
|
+
- **Guest & Account**: who orders; guests, customers, addresses, wishlist.
|
|
58
|
+
- **Restaurant operations**: opening hours, holidays, store status, branches, the switch that accepts orders, contact.
|
|
59
|
+
- **Discoverability**: paths, navigations, SEO, sitemap, `llms.txt`.
|
|
60
|
+
- **Shared kernel** (`shared/domain/kernel`): `Money`, `Media`, `TimeOfDay`, `CalendarDate`, `TimeZone`, `Weekday`, `Id`, `DomainError`.
|
|
61
|
+
|
|
62
|
+
```mermaid
|
|
63
|
+
flowchart LR
|
|
64
|
+
subgraph Storefront
|
|
65
|
+
R[Restaurant operations]
|
|
66
|
+
M[Menu]
|
|
67
|
+
G[Guest & Account]
|
|
68
|
+
O[Ordering]
|
|
69
|
+
D[Discoverability]
|
|
70
|
+
end
|
|
71
|
+
R -- "opening hours, holidays, accepts orders" --> O
|
|
72
|
+
M -- "dish configuration" --> O
|
|
73
|
+
M -- "dish configuration" --> G
|
|
74
|
+
G -- "address, guest details" --> O
|
|
75
|
+
M -- "section paths" --> D
|
|
76
|
+
R -- "hours, contact data" --> D
|
|
77
|
+
Storefront <-- "ports" --> ACL[Adapter = anti-corruption layer]
|
|
78
|
+
ACL <--> B[(Shop backend: Shopware, memory, …)]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Upstream contexts publish their types; downstream contexts use them as they are (customer/supplier inside one codebase). Every adapter is an anti-corruption layer: it translates the backend's model into the domain types in both directions, and no backend word passes it (the glossary lists the Shopware words that must not leak). The storefront's Markdown content pages are not a backend matter and stay outside the ports.
|
|
82
|
+
|
|
83
|
+
### Scope of DDD
|
|
84
|
+
|
|
85
|
+
- **Strategic DDD in full**: the glossary, the contexts, the context map, an anti-corruption layer per adapter.
|
|
86
|
+
- **Tactical DDD where the storefront owns the rule**: value objects as immutable types with validating constructors (`money`, `timeOfDay`, `calendarDate`, `timeZone`, `leadTime`, `wishedTime`, `openingInterval`, `holiday`, `dishConfiguration`), domain services as pure functions (e.g. `earliestWishedTime`; the ordering window and store status follow when their logic moves), domain errors with codes (`DomainError`).
|
|
87
|
+
- **Not** repositories or aggregates with persistence: the backend owns the state, ports are gateways that answer with the backend's result (a cart port returns the cart the backend calculated). **Not** domain events across contexts: the contexts share one process and call each other's pure functions.
|
|
88
|
+
|
|
89
|
+
Within this frame:
|
|
90
|
+
|
|
91
|
+
- IDs are opaque strings. Money is integer minor units with an ISO 4217 code; the number of minor digits comes from the currency (EUR 2, JPY 0, KWD 3, `Intl.NumberFormat`), decimals round half away from zero, and there is no negative zero (Sylius stores minor units; Shopware's decimals are converted at the adapter).
|
|
92
|
+
- Countries are ISO 3166-1 alpha-2 codes; the Shopware adapter maps them to country ids.
|
|
93
|
+
- **Time** belongs to the restaurant, not to the server or the browser: `ShopConfig.timeZone` (IANA). The ShopBite plugin decides in the sales channel's business time zone, else Europe/Berlin, but does not report it, so the Shopware adapter takes runtime config `shopBite.timeZone` (default `Europe/Berlin`). Dates and wall-clock times of an instant are read in that zone (`zonedDateTime`), also across DST switches.
|
|
94
|
+
- Times of day are minutes since midnight. An opening interval never crosses midnight and may close at 24:00 (1440, the end of the day); a late-night opening is two intervals. The Shopware adapter maps plugin rows by the plugin's rule: a closing time at or before the opening time runs into the next day and is split at midnight, closing at 00:00 or 24:00 is the end of the day. Rows it cannot read are logged and dropped.
|
|
95
|
+
- Holidays are whole days (`firstDay`, `lastDay`, both included) in the restaurant's time zone.
|
|
96
|
+
- A wished time is a service date plus a time on the 5-minute grid, so an order before midnight can be wished for after it. `earliestWishedTime` looks at today's and tomorrow's opening intervals and holidays, at most 24 hours ahead. It is a field of `Order` and `PlaceOrderCommand`; putting it into Shopware's customer comment ("Wunschlieferzeit: 18:40") is the Shopware adapter's job.
|
|
97
|
+
- A cart has discounts, each with the voucher code it came from or none (an automatic discount).
|
|
98
|
+
- Adapters answer frozen values and build themselves from the runtime config (`shopwareFromRuntimeConfig`, `memoryFromRuntimeConfig`); the registry only picks one by name.
|
|
99
|
+
- Building a `srcset` from `Media` is presentation and lives in app utils, not in the domain.
|
|
100
|
+
- Visitor-specific ports take a `BackendSession`; shop-wide ports (catalog, navigation, shop, contact) take none, so their answers can be cached across visitors.
|
|
101
|
+
- The app imports types only from `shared/domain` for now: a value import of `shared/` from app code broke the Nitro server bundle of shops in 2.0.1. The first step that needs a value object in the app checks it with the layer build (`pnpm nuxt build test/layer`) first.
|
|
102
|
+
|
|
103
|
+
### Migration
|
|
104
|
+
|
|
105
|
+
Each step moves one area behind its port, keeps the shop working, and ships as a 2.x minor. Within a step, the old route or composable is replaced, not duplicated.
|
|
106
|
+
|
|
107
|
+
Before and after are compared against the quickstart on every page type the step touches, the menu root included: status, redirect, the whole `<head>` (title, canonical, description, og/twitter), JSON-LD and visible text, plus a cache purge after a rename in the Admin and, from step 4 on, the normalised Store API cart. Any difference is either fixed or listed under the step's allowed behaviour changes.
|
|
108
|
+
|
|
109
|
+
| Step | Area | Release |
|
|
110
|
+
| ---- | ------------------------------------------------------------------------------------------------------------ | ------- |
|
|
111
|
+
| 0 | Glossary, this ADR, domain types and value objects, port interfaces, adapter registry, contract harness, lint guard; no behaviour change | 2.x minor |
|
|
112
|
+
| 1 | Restaurant operations: `ShopPort` (config, hours, holidays, branches) behind the BFF, live checkout switch through the BFF | 2.x minor |
|
|
113
|
+
| 2 | Menu: `CatalogPort` (sections, dishes, variants, extras, search, top sellers); memory adapter gets the demo menu | 2.x minor |
|
|
114
|
+
| 3 | Discoverability: `NavigationPort` (navigations, path resolution and redirects, sitemap, `llms.txt`) | 2.x minor |
|
|
115
|
+
| 4 | Storefront session (HttpOnly cookie, backend state sealed in it) and `CartPort` | 2.x minor |
|
|
116
|
+
| 5 | Checkout and orders: `CheckoutPort`, `OrderPort` (wished time, guest details, payment) | 2.x minor |
|
|
117
|
+
| 6 | Guest & Account: `CustomerPort` (login, registration, profile, addresses) | 2.x minor |
|
|
118
|
+
| 7 | `WishlistPort`, `ContactPort`; no browser-direct backend call left | 2.x minor |
|
|
119
|
+
| 8 | Remove `@shopware/nuxt-module`, the `@shopware/composables` layer and the Shopware helpers outside the adapter; the lint guard becomes an error | 3.0.0 |
|
|
120
|
+
|
|
121
|
+
### Progress
|
|
122
|
+
|
|
123
|
+
**Step 1 (restaurant operations), done.** `ShopPort` and `CheckoutPort.listShippingMethods` behind the BFF: `GET /api/shop/config`, `/api/shop/opening-hours`, `/api/shop/holidays`, `/api/shop/branches`, `/api/checkout/shipping-methods` answer domain types; they replace `/api/shopbite/config`, `/business-hours` and `/holidays`. Each is cached for server-side rendering and `llms.txt` (`server/utils/shopData.ts`, `swr: false`, resilient loader, emptied by every purge and by `{ "layout": true }`); `?fresh=1` asks the port directly (no cache, no last good answer) for the browser's live values and for the check of the switch that accepts orders right before an order. `DomainError`s become HTTP answers in one place (`server/utils/domainHttp.ts`). The browser asks no Store API for configuration, hours, holidays, branches, lead times or the menu root (`/api/menu/root`). Store status, opening hours displays, the wished time choice, the Restaurant schema and `llms.txt` work in the restaurant's time zone, and a late-night opening reads and counts as one span (Fri 17:00–01:30). Lint guard: 105 warnings (111 at step 0).
|
|
124
|
+
|
|
125
|
+
Deviations and open points of step 1:
|
|
126
|
+
|
|
127
|
+
- The app does not use the domain's value objects and services (`earliestWishedTime`): a value import from `shared/` is still avoided in app code. `app/utils/restaurantTime.ts` computes store status and the wished time window on the domain types; it moves onto the domain services together with the ordering window.
|
|
128
|
+
- Ordering window vs. plugin (note below): settled for now on the plugin's side. The wished time stays within today's spans plus yesterday's late-night span, never on a holiday, and no pre-order for a later service day is offered. A late-night opening that started on a holiday is not continued after midnight (the display joins the split intervals and keeps their origin day). DST slots are not treated specially (wall-clock minutes). A span up to 24:00 offers wished times up to 23:55.
|
|
129
|
+
- Lead times are loaded live once after hydration (`useLiveShopData`); only the switch that accepts orders is refreshed every 10 s in the checkout. The Shopware adapter needs two Store API requests for them (plugin config and `/shipping-method` names); concurrent reads of the plugin config share one request. A fresh request fails fast while the backend is paused after a failure. The ShopBite plugin refuses a paused order itself; the storefront's check before an order is defence in depth.
|
|
130
|
+
- The menu root still comes from the Shopware plugin config on the server (`shopbite-config`, a second cache of `/shopbite/config` next to `shop-config`) until `NavigationPort` (step 3; now the domain value `menu-root`).
|
|
131
|
+
- Behaviour changes allowed by the step: holidays are whole days in the restaurant's time zone (the Restaurant schema and `llms.txt` took the UTC date of the plugin's instants before); an interval up to the end of the day reads `24:00` instead of `00:00` (schema.org keeps `00:00`, a day open around the clock is `00:00`–`23:59`).
|
|
132
|
+
|
|
133
|
+
**Step 2 (menu), done.** `CatalogPort` in both adapters with a contract suite (sections, listings with sorting, diet filters and pages, search, every dish for `llms.txt`, the dish sheet with variants, extras and removable ingredients, a dish or variant by menu number, a variant by options, top sellers, upsell dishes). The BFF answers domain types: `GET /api/listing/[sectionId]`, `/api/search`, `/api/top-sellers` (paths kept), `/api/menu/sections/[sectionId]`, `/api/menu/dishes/[dishId]`, `/api/menu/dishes?number=`, `/api/menu/dishes/[dishId]/variant`, `/api/menu/upsell`; they replace `/api/product/*` and `/api/category/[categoryId]`, and the browser asks no Store API for dishes any more (dish sheet by number, upsell, wishlist). Every route is a cached handler keyed by the section or dish id, so the backoffice purge keeps working; a dish sheet carries its extras, so every menu purge empties all dish sheets. The memory adapter serves the quickstart's demo menu with the ids its setup gives the Shopware entities. `llms.txt` takes the menu from the port. Components and composables of the menu work on the domain types; the app still imports types only (`app/utils/money.ts` and `app/utils/dish.ts` instead of the domain's value objects). Lint guard: 55 warnings.
|
|
134
|
+
|
|
135
|
+
Domain decisions of step 2:
|
|
136
|
+
|
|
137
|
+
- `Dish.path` is the dish's link when the backend keeps one (Shopware: the product SEO URL with `?produkt=`), else null and the storefront links the dish under the section it is listed in. Section paths stay `MenuSection.path`; resolving paths is step 3.
|
|
138
|
+
- `DishDetail` is always the dish; a variant asked for by id or number answers its dish with `selectedVariantId`. Without a request for one, `selectedVariantId` is the backend's default variant (Shopware's detail route answers a parent with it). `Variant` has its own name, media and main ingredients, inherited from the dish when it has none.
|
|
139
|
+
- Main ingredients carry ids (`Ingredient`); removals are still written by name (dish sheet URL `ohne`, cart payload `without`, wishlist), as before.
|
|
140
|
+
- `Extra.available` and `Dish.listPrice`/`Variant.listPrice` are mapped; the UI does not use them yet.
|
|
141
|
+
- `findVariant` with fewer options than groups answers the first variant that has them (Shopware's `/product` filter); with one option per group exactly that variant.
|
|
142
|
+
- Food labels belong to every `Dish`, so the sheet's info button works before the sheet's own data are loaded.
|
|
143
|
+
- `MenuSection.seo` (title, description, indexable) carries what the section page's SEO needs; a section off the menu keeps its page as not indexable.
|
|
144
|
+
|
|
145
|
+
Behaviour changes allowed by the step (otherwise identical, compared on SSR HTML, JSON-LD and visible text against the quickstart):
|
|
146
|
+
|
|
147
|
+
- The removable ingredients of the dish sheet are in the order of the menu card (the sheet listed them in the backend's order of assignment before).
|
|
148
|
+
- Search results know a parent with variants: "ab" price and the choice button instead of adding the parent, which the cart silently left out.
|
|
149
|
+
- A dish sheet opened by a variant's number (deep link, wishlist) shows the dish's description, diets and food labels.
|
|
150
|
+
|
|
151
|
+
For shops that extend the layer (release notes; breaking only for overrides and own uses):
|
|
152
|
+
|
|
153
|
+
- Removed routes: `/api/product/[productId]`, `/api/product/[productId]/cross-selling`, `/api/product/variant`, `/api/category/[categoryId]`. `/api/listing/[sectionId]`, `/api/search` and `/api/top-sellers` keep their paths but answer `MenuListing`/`Dish[]`; the listing's `properties` parameter is `filters`, `manufacturer` and `query` are gone.
|
|
154
|
+
- Removed composables and utils: `useCategoryById` (now `useMenuSection`), `useProductConfigurator`, `useProductVariantsZwei`, `useProductVariants`, `useProductCrossSelling`, `app/utils/product.ts` (`getMainIngredients`, `getDiets`, `getFoodLabels`, `allergensChecked`, `productIsAvailable`, `productNeedsChoice`, `lineItemHoldsProduct`; now `Dish` fields and `app/utils/dish.ts`), `productDeepLink` (now `dishLink`), `findCategory`, `types/Association`. A shop's own `useProductConfigurator` no longer shadows a project composable; the layer's original is auto-imported again.
|
|
155
|
+
- Changed props and returns: `MenuBonCard` `product` → `dish` (emits `select` with the dish), `ProductQuickView` `product` → `dish`, `ProductDetail` `productId` → `dishId`, `ProductConfigurator` takes `dishId`, `groups`, `selectedOptionIds`, `ProductDeselectIngredient` `product` → `ingredients`, `ProductCrossSelling` `associations` → `groups`, `ProductFoodLabels` `product` → `labels`, `MenuSectionHeader` `category` → `section`, `CategoryFilterGroup` takes a `ListingFilter`; `useProductQuickView` returns `dish` instead of `product`; `useAddToCart` has `setSelectedDish`/`setSelectedExtras`/`setRemovedIngredients` (`selectedDish`, `removedIngredients`); `useCartUpsell` has `loadUpsellDishes`/`addUpsellDish`; `useCategoryListing` and `useListingSearch` return `dishes`, `sortings`, `currentSorting`, `filters`; `useProductEvents`' cart addition carries `dish`.
|
|
156
|
+
|
|
157
|
+
Open points for later steps:
|
|
158
|
+
|
|
159
|
+
- Step 3 (done): navigation trees, breadcrumbs, path resolution and the sitemap moved behind `NavigationPort`. The memory adapter's media URLs are relative (`/api/menu/media/…`).
|
|
160
|
+
- Step 4 (done): the cart moved behind `CartPort`; `DishConfiguration` names removals by ingredient id.
|
|
161
|
+
- A partial variant choice (one of two groups) silently takes the first matching variant while the other group stays unselected in the sheet, as before; the sheet could select the found variant's options or resolve locally from `DishDetail.variants`.
|
|
162
|
+
- An unavailable extra is still offered in the sheet.
|
|
163
|
+
- The wishlist loads one dish sheet per entry (cached per dish); a batch route would need a port method for several dishes.
|
|
164
|
+
|
|
165
|
+
**Step 3 (discoverability), done.** `NavigationPort` in both adapters with a contract suite (header, footer, menu and home navigation, the menu root, breadcrumbs, path resolution for sections, other spellings and former paths, unknown and hostile paths, content pages as no backend paths, sitemap entries, known paths). The BFF answers domain types: `GET /api/navigation/[kind]` (`NavigationNode[]`), `/api/breadcrumb/[sectionId]` (`BreadcrumbItem[]`), `/api/resolve-path?path=` (`{ route: ResolvedRoute | null }`), `/api/menu/root` and the sitemap source; they replace `/api/navigation/[type]`, `/api/breadcrumb/[categoryId]`, `/api/seo-url`, `/api/seo-url/known`, and the browser no longer asks the Store API for old SEO URLs. The Shopware adapter owns the SEO URLs (`seoPathInfo` and `pathInfo` lookups, technical URLs, canonical and former SEO URLs by `isCanonical` and `languageId`, the navigation roots, category types, `linkNewTab`, the icon custom field, the sitemap trees, the paged SEO paths); the memory adapter serves the quickstart's menu root, header, footer and paths, so menu root, sections, dish links, breadcrumbs, navigations, sitemap and `llms.txt` render without Shopware (cart and checkout still need it until steps 4 and 5). Caches and their guarantees are kept: navigations, breadcrumbs, path routes, known paths and the menu root are cached, purged with every target, bounded (one path route per canonical path, slash variant and technical URL, never per spelling, miss or former path), hostile and unknown paths get no lookup, outages back off. The app works on the domain types. Lint guard: 40 warnings.
|
|
166
|
+
|
|
167
|
+
Domain decisions of step 3:
|
|
168
|
+
|
|
169
|
+
- `NavigationNode.kind` has `group` for a footer column (Shopware folder, `path: null`); `external` means opens in a new tab (`linkNewTab`); `media` is filled for the home navigation only. Shopware link categories stay `link` (a link to another category, an external URL or a storefront path cannot be told apart).
|
|
170
|
+
- `NavigationPort.getMenuRootId()` is new: the menu root decides the cache key of the menu navigations, the root page's single list and `/api/menu/root`. It is strict; only the Shopware sitemap falls back to the navigation root, as before. `getNavigation(kind, menuRootId)` takes the root the BFF resolved (cached), so a key and its tree never name two roots and an outage of the plugin configuration keeps the last good root's menu.
|
|
171
|
+
- Handlers that answer domain types under the name a Shopware-shaped handler had (`listing`, `search`, `top-sellers`, `variant`, `navigation`, `breadcrumb`) carry a versioned key (`versionedKey()`, `server/utils/cacheKeys.ts`), so persistent cache storage never serves an old shape. `createResilientLoader` answers a pause as `backend_unavailable`, so every 503 of a BFF route carries `data.code`.
|
|
172
|
+
- Scanner paths: control characters and a leading `//` or `/\` are hostile; a technical URL gets one lookup; a backend path that would redirect to another host (`//host/`) is no route (`isSafeRedirectTarget`), in the adapter and again in the BFF.
|
|
173
|
+
- A redirect names its section (`ResolvedRoute.sectionId`), and every adapter answers with `routeTo()`: the BFF caches one target per lower-cased path and rebuilds the answer for the visited spelling. `toggleTrailingSlash()`, `isHostilePath()`, `pathKey()` and `mayBeKnownPath()` are pure domain rules; the collation-like `pathKey` is the loosest adapter lookup so far, which an adapter's `resolvePath` must not exceed for listed paths.
|
|
174
|
+
- `KnownPaths` is null when there are too many to list, and names `unlistedPrefixes` (Shopware's technical URLs), which resolve without being listed and are cached per entity.
|
|
175
|
+
- `SitemapEntry.image` carries the section's photo for the image sitemap.
|
|
176
|
+
- The two caches of the plugin configuration of step 1 are now two domain values: `shop-config` (`ShopConfig`) and `menu-root` (`Id`), both from the port; the raw `shopbite-config` cache is gone. Shopware still answers both from one `/shopbite/config` request each per TTL.
|
|
177
|
+
|
|
178
|
+
Behaviour, compared against the quickstart's Shopware before and after (92 paths: every section URL with case and slash variants, technical URLs, a renamed section's former URL, dish links, unknown, scanner and hostile paths, content pages, `sitemap.xml`, `robots.txt`, `llms.txt`; status, redirect target, title, canonical, meta, JSON-LD incl. `BreadcrumbList`, every navigation, home sections, dish links): identical. Changes allowed by the step: a toggled-slash spelling of a section path is cached too (one Store API lookup less per request); the breadcrumb route takes the backends' opaque ids (`idParam`) instead of 32 hex characters, so an id Shopware has no route for is a 404, not a 400; the home navigation and the menu navigation ask Shopware for the category `type` as well; client-side navigation resolves paths through the BFF like server-side rendering (the shortcut via the history state of Shopware links is gone).
|
|
179
|
+
|
|
180
|
+
For shops that extend the layer (release notes; breaking only for overrides and own uses):
|
|
181
|
+
|
|
182
|
+
- Removed routes: `/api/seo-url`, `/api/seo-url/known`; `/api/navigation/[type]` keeps its URLs (`/api/navigation/main` …) but answers `NavigationNode[]`; `/api/breadcrumb/[categoryId]` keeps its URL but answers `BreadcrumbItem[]` (`label`, `path` with the leading slash).
|
|
183
|
+
- Removed composables and utils: `useSeoUrlRoute` (now `useSectionRoute`, returns `sectionId`), `useNavigationSearch` (the layer's own composable of that name is auto-imported again), `app/utils/seoPath.ts` (`resolveSeoPath`), the Shopware media shape of `mediaSrcSet`/`mediaSize` (domain `Media` only); server utils `menuRootId`, `menuRootIdStrict`, `shopBiteConfig`, `findSeoUrl`, `knownSeoPaths`, `server/utils/seoPaths.ts`, `categoriesToSitemapUrls` (now `toSitemapUrls` of `SitemapEntry[]`).
|
|
184
|
+
- Changed returns: `useNavigation()`'s `mainNavigation`, `footerNavigation` and `menuCardNavigation` hold `NavigationNode[]` (the `…Menu` items keep their shape), `useHomeMenuCategories()` holds `NavigationNode[]` (`label`, `path`, `media`); the catch-all page no longer uses the layer's `useNavigationContext` and `useBreadcrumbs`. Cache names for purges of own tools: `path-route`, `known-paths`, `menu-root` replace `seo-url`, `seo-paths`, `shopbite-config`.
|
|
185
|
+
|
|
186
|
+
Open points of step 3:
|
|
187
|
+
|
|
188
|
+
- `menu` and `home` are two Store API navigations of the same root; `CatalogPort.getMenu()` holds the same sections (with photos). They could share one request once the media of both agree.
|
|
189
|
+
- `llms.txt` and the Restaurant schema still name `/speisekarte` as the menu's URL instead of the menu root's path.
|
|
190
|
+
- Footer links to sections are `link` nodes, also in the memory adapter, to match Shopware; a backend that knows it links a section could answer `menu-section`.
|
|
191
|
+
- `/api/payment-methods` (Restaurant schema) asks `CheckoutPort.listPaymentMethods()` (step 5, done).
|
|
192
|
+
|
|
193
|
+
**Step 4 (session and cart), done.** The storefront keeps its own session and the cart moved behind `CartPort`, in both adapters with a contract suite (empty cart without state, plain dish, merging, extras and removals as one line priced together, the same configuration merged whatever the order of its parts, configurations that differ only in their removals apart, a variant with its options, a variant named as the dish, quantity changes and 0 as removal, removal, unknown lines, dishes the menu does not offer, invalid extras, removals and quantities, vouchers applied, refused and removed, two visitors apart, frozen answers). The BFF answers the domain `Cart`: `GET /api/cart`, `POST /api/cart/lines`, `PATCH`/`DELETE /api/cart/lines/[lineId]`, `POST /api/cart/vouchers`, `DELETE /api/cart/vouchers/[code]`. The browser asks the Store API for no cart any more and holds no backend token. Lint guard: 35 warnings.
|
|
194
|
+
|
|
195
|
+
Session decisions of step 4:
|
|
196
|
+
|
|
197
|
+
- **Cookie**: `shopbite-session`, HttpOnly, SameSite=Lax, Path=/, 30 days after the last visit (extended at most once a day); on https Secure and `__Host-`-prefixed, so no subdomain can plant it.
|
|
198
|
+
- **Sealed cookie, no server-side storage** (decided after review): the cookie carries a small sealed payload, its session id, a version, the time it was sealed and one opaque state per adapter name (Shopware: the context token; memory: its cart token), so the memory backend and the Shopware bridge never read each other's state. AES-256-GCM with a key derived by HKDF-SHA256 from `visitorSession.password` (NUXT_VISITOR_SESSION_PASSWORD, at least 32 characters), versioned format `v1.<key id>.<nonce>.<data>`, the cookie's name authenticated with it; the cookie stays under 400 characters. Sessions and carts survive restarts and deploys, several instances need nothing shared, and visitors without a session cost nothing. Production refuses to start without a password (a random one would end every session with each restart); development generates one and warns. A rotation moves the old password to `previousPasswords`: a cookie it sealed is sealed again with the current password on its next visit; drop the previous password only `maxAgeDays` after the rotation. Seals from the future (beyond five minutes of clock skew) or with an absurd version are refused. A server-side storage as an option was dropped: two session designs would double what can go wrong, and the cookie holds all the state the adapters need. Consequence: there is no server-side revocation of a cookie; a backend's own logout invalidates its token (Shopware replaces the context token).
|
|
199
|
+
- **Creation**: by the first state an adapter writes. A cart read never creates a session (a visitor without one has an empty cart without a backend request). The bridge cannot tell a Store API read from a write, so a token Shopware issues to a visitor without a session is sealed into a cookie as well; it costs nothing but the cookie. An expired, foreign or malformed cookie is a new visitor.
|
|
200
|
+
- **Rotation**: every change of a state (Shopware: a new context token on login, logout or registration, also a guest's) seals a new value with a higher version; an old value, planted or leaked, carries the replaced token only (session fixation).
|
|
201
|
+
- **Concurrency**: a cookie is only set when the request changed a state (or extends the session once a day), so a request that changed nothing never overwrites a newer cookie. A small registry in the process (bounded) remembers the newest version of each session it saw and serialises a visitor's writes, the cart's and the bridge's (registration, login, logout replace the token through the bridge, so a cart write runs before them and moves with the cart, or after them and is stale): a request that still carries a cookie older than that version is stale; its writes are dropped (no cookie), and the cart routes and the bridge answer a stale write with 409 `stale_session` before they act, so it never lands in a throwaway cart. The browser has the new cookie by then; `useCartMutations` sends the write again after 150 ms, twice at most (the browser may not have stored the new cookie at once). With several instances the registry is per instance: a parallel stale write on another instance is not recognised, and the later cookie wins.
|
|
202
|
+
- **Migration**: the old layer's `sw-context-token` cookie becomes the Shopware state of a new session once (its value checked for shape) and is deleted; an existing session wins over a cookie left behind. Visitors keep their cart over the upgrade.
|
|
203
|
+
- **CSRF**: SameSite=Lax plus an origin check on every state-changing route (cart and bridge): `Origin` must be one of the storefront's origins, scheme and host (the origin of `public.storeUrl`, the request's own and those listed in `visitorSession.allowedOrigins`, NUXT_VISITOR_SESSION_ALLOWED_ORIGINS, exact origins, scheme and host, of any scheme, e.g. for a shop with several https hosts behind a TLS-terminating proxy, where the request's own origin reads `http://`; forwarded headers are not trusted), else `Sec-Fetch-Site` must be `same-origin`; 403 with `cross_site_request`. No token: every write is a `fetch` of the storefront's own pages, and both headers are sent by every browser that sends the cookie cross-site at all. A write that carries neither `Origin` nor `Sec-Fetch-Site` is accepted: that is no browser (curl, a server), which can send any cookie it holds anyway; CSRF needs a victim's browser, and browsers always send `Origin` on a cross-site `fetch` or form post.
|
|
204
|
+
- **Checkout until step 5**: the Shopware layer still ran checkout, account, wishlist and contact in the browser (since step 5: account, wishlist and contact, `BRIDGE_ROUTES`). Its API client talks to the storefront's `/api/store-api/**`, which adds access key and context token from the session (the same backend context as the cart), forwards an allowlist of headers, stores a token Shopware issues and replaces the visitor's tokens in every answer header, JSON string and key and text body (Shopware writes the token into error texts such as "Cart with token … is locked"), and the internal endpoint in routing errors. Server-side rendering reads the token from the session (read only) and keeps it out of the page payload. Transitional; it goes with the layer.
|
|
205
|
+
- **Visitor address**: the bridge and the cart send Shopware `X-Forwarded-For` as a proxy does: the incoming chain with the socket address appended (`BackendSession.forwardedFor`). Shopware's per-IP rate limits (login, contact form, password recovery, cart) see the visitor only if `TRUSTED_PROXIES` lists the storefront and the proxies in front of it, and nothing a visitor can reach directly (a storefront that reaches Shopware via `localhost` needs both `127.0.0.1` and `::1`); otherwise they count the storefront as one client. The proxy in front of the storefront must overwrite a client-sent `X-Forwarded-For` with the address it sees (nginx: `proxy_set_header X-Forwarded-For $remote_addr;`, not `$proxy_add_x_forwarded_for`; Traefik: no `forwardedHeaders.trustedIPs` for the public entry point), or drop the header: the storefront appends to the incoming chain, and when `TRUSTED_PROXIES` covers the storefront's network, Shopware takes the rightmost untrusted address, which a visitor could otherwise forge (a new address per request bypasses the per-IP limits of login, password reset and contact form).
|
|
206
|
+
|
|
207
|
+
Cart decisions of step 4:
|
|
208
|
+
|
|
209
|
+
- `DishConfiguration` names the dish and the chosen variant (`dishId`, `variantId`) and the removed ingredients by id; extras and removals keep the order the guest chose them in (the receipt lists them so) and compare as sets. `CartLine` carries number, name, the variant's options (`variant`, a structured label instead of one name string), extras with their prices, the removed ingredients' names, unit and total price (dish plus extras, gross as the backend calculated it); the cart its discounts, subtotal (lines and discounts), shipping costs, total, taxes per rate, the selected methods and messages. `ordering_closed` is a new message code.
|
|
210
|
+
- A voucher that does not apply answers the cart with a `voucher_invalid` message about the code (Shopware reports it so, with a text), not with an exception.
|
|
211
|
+
- Shopware: a plain dish stays a `product` line item with the product id; a configured dish stays the plugin's `container` with exactly the request of 2.6.1 (uuid5 of product id + sorted extra ids, plus `|without:` and the sorted, lower-cased removals; label and payload hints; the product as first child), so lines already in carts keep merging. The adapter looks up names, number, parent and main ingredients with one `/product` request and the extras a dish offers with its `/cross-selling`, and keeps both for 60 s (bounded; the cart answers need them on every request, as the currency of step 2 is kept); a visitor without a token has an empty cart without a request. Every Store API request of the cart path (the visitor's cart, the product lookup, the extras, the currency) has a deadline of 10 s (`backend_unavailable`), and the Nitro utils `storeApiGet`/`storeApiPost` time out after 10 s too, so a paused Shopware holds a visitor's next write for at most about 10 s per request in front of it (undici would wait 300 s); the bridge gives up after 10 s as well (503 `backend_unavailable`). Cart requests use the server's endpoint. Shopware's cart lock is retried once in the adapter, the browser's queue stays. Texts of cart messages and the causes of thrown errors carry no token (only status and error codes are logged).
|
|
212
|
+
- An unknown dish, a dish that needs a variant, a variant of another dish, an extra the dish does not offer or a removal the dish does not have are refused (`dish_unavailable`, `invalid_value`) instead of being dropped by Shopware without a word or added as asked.
|
|
213
|
+
|
|
214
|
+
Behaviour, compared against the quickstart's Shopware before and after (same Playwright actions on main and on the branch: a variant with an extra and a removal from the dish sheet, the same dish with another removal, the same configuration again, a plain dish from its card, a variant by its menu number, a saved wishlist configuration, a quantity change and a removal in the cart sheet, an upsell dish in the checkout; then a guest order for delivery and one for pickup, each with its wished time): the cart sheet, the cart bar on a phone, the checkout's head and text, the normalised Store API cart (line ids, types, labels, payloads, children, quantities, prices, taxes) and both orders in Shopware (line items with payload, prices, comment `Wunschlieferzeit`/`Wunschabholzeit: HH:MM`, shipping method) are identical. A visitor with a filled cart of the old layer keeps it after the upgrade. Smoke and hardening tests of the quickstart pass. Changes allowed by the step:
|
|
215
|
+
|
|
216
|
+
- A dish the menu does not offer is refused with 409 `dish_unavailable` (before: Shopware dropped it, the cart bar still said "hinzugefügt").
|
|
217
|
+
- Voucher discounts show as discount rows in the cart sheet, no longer as cart lines with a quantity stepper; automatic discounts are listed in the voucher field without a remove button.
|
|
218
|
+
- Line items of other types (a backend's own surcharges) are not listed as cart lines; the totals contain them as before.
|
|
219
|
+
- The session needs a password: NUXT_VISITOR_SESSION_PASSWORD must be set in production (the server does not start without it) and kept over deploys.
|
|
220
|
+
- The Shopware layer's requests and the cart reach Shopware from the storefront's server: Shopware sees the visitor's IP only if it trusts the storefront and its proxies (`TRUSTED_PROXIES`), otherwise its per-IP rate limits (contact form, login, cart) count the storefront as one client.
|
|
221
|
+
- The app maps removed ingredient names to their ids from the dish; a name the dish does not have is not sent (before it changed the line id while the plugin dropped it).
|
|
222
|
+
|
|
223
|
+
For shops that extend the layer (release notes; breaking only for overrides and own uses):
|
|
224
|
+
|
|
225
|
+
- The browser has no `sw-context-token` cookie any more; own code that read it or called the Store API with it from the browser gets no visitor context. The layer's `apiClient` keeps working through `/api/store-api/**`. Reverse proxies and firewalls must pass `/api/cart/**` and `/api/store-api/**` with their bodies; the cookie `shopbite-session` must reach the storefront.
|
|
226
|
+
- New: runtime config `visitorSession` (`maxAgeDays`, `password`, `previousPasswords`; NUXT_VISITOR_SESSION_PASSWORD is required in production), the domain code `stale_session` (409), the cart routes. The layer's `useCart()` no longer holds the storefront's cart: use `useCartData()` (`lines`, `count`, `subtotal`, `shippingCosts`, `total`, `discounts`, `messages`, `refresh`).
|
|
227
|
+
- Changed: `useCartMutations` has `addLine(request)`, `setQuantity(lineId, quantity)`, `removeLine(lineId)` (`addLineItems`, `removeLineItem` and `isCartLockedError` are gone); `useAddToCart().setSelectedDish(dish, dishId)` takes the dish a variant belongs to; `useVoucherCode` returns `appliedVouchers` and `removeVoucher(code)` (no `appliedPromotionCodes`, `removeItem`); `CartItem` takes `line` (a `CartLine`) instead of `cartItem`; `cartLineHoldsDish` takes a `CartLine`, `cartLineLabel` is new; `useCheckoutMethodGuard` reads the cart's messages (`getCartErrors`, `hasBlockedShippingMethod`, `hasBlockedPaymentMethod` are gone); `DishConfiguration` has `variantId` and `removedIngredientIds`.
|
|
228
|
+
|
|
229
|
+
Open points for step 5 and later:
|
|
230
|
+
|
|
231
|
+
- Step 5 (done): checkout and orders moved behind `CheckoutPort` and `OrderPort`; the bridge serves account, wishlist and contact only (`BRIDGE_ROUTES`) and goes with the layer. The layer's `useUser` still reads the Shopware cart through it after a login (unused).
|
|
232
|
+
- The access key is still in the public runtime config (the layer needs it).
|
|
233
|
+
- Writes of one visitor are serialised and checked for staleness per process; with several instances a stale write on another instance is not recognised (the later cookie wins). Two first writes of a visitor without a session (in parallel) make two sessions; the browser's cart queue serialises cart writes, bridge calls on a page without a session may still race (the later cookie wins, nothing of value is in either). A stale write through the bridge answers 409 to the Shopware layer, which shows it as a failed request. Known limits, accepted: staleness is known per process only (no shared state by design); an extra can still be ordered as a dish of its own when it is on the menu as one (as on main).
|
|
234
|
+
- Cart messages (`dish_unavailable`, `quantity_adjusted`) are not shown in the cart yet, as before.
|
|
235
|
+
- `trackOrder` reads the domain order (step 5, done).
|
|
236
|
+
|
|
237
|
+
**Step 5 (checkout and orders), done.** `CheckoutPort` and `OrderPort` in both adapters with one contract suite for the ordering context (`test/contract/ordering.contract.ts`: the shop's default methods for a new visitor without a session, selecting methods per visitor and the cart following them, unknown methods refused, payment methods with the shop's default, no orderer before the guest's details, a guest who keeps the cart, a business guest with another delivery address, changing the orderer's address and not another's, placing a cart with a configured dish, a variant, a plain dish and a voucher (lines with their dish configuration, prices, discounts, wished time, fulfillment, methods, addresses), the guest's note apart from the wished time, an empty cart, no guest, the restaurant closed (cart kept, no order), starting and switching the payment, an order readable by its session only, the session's orders newest first, frozen answers). The browser asks the Store API for no checkout, order or payment any more: the BFF answers `CheckoutSelection`, `PaymentMethod[]`, `Orderer`, `PlacedOrder` and `Order` (routes in CLAUDE.md), and the bridge forwards only what account, wishlist and contact still need (`BRIDGE_ROUTES`). Lint guard: 22 warnings.
|
|
238
|
+
|
|
239
|
+
Decisions of step 5:
|
|
240
|
+
|
|
241
|
+
- **Wished time**: the checkout sends `WishedTime` (service date and `HH:MM` on the grid; a time past midnight in a window running into the night is the next date). The BFF checks it against the ordering window of the cart's shipping method (`wishedTimeWindow`, the window the picker offers) with one grid step of grace for the browser's clock, plus the switch read fresh; the plugin stays the authority (ordering window per lead time, pause, holidays) and refuses on its own. The Shopware adapter writes it into the customer comment exactly as before, `Wunschlieferzeit: HH:MM` or `Wunschabholzeit: HH:MM` by the method's fulfillment (`PlaceOrderCommand.fulfillment`), a note on the next line; reading an order takes the time back and dates it by the order's date in the restaurant's time zone (a time more than 30 minutes before the order is the next day). Other comments are the note.
|
|
242
|
+
- **Fulfillment** of an order: the shipping method's `shopbite_fulfillment` as the order carries it (the backoffice reads the same), else delivery; a pickup has no delivery address.
|
|
243
|
+
- **Payment**: `listPaymentMethods` answers the methods the visitor can use (Shopware: `onlyAvailable`), `preferred` is the shop's default (the sales channel's), which the method guard switches to when the cart blocks the selected one. After placing, the BFF starts the payment (`/handle-payment`) as the checkout did; when that fails the order is still answered (`paymentFailed`) and the guest goes to the payment retry. `PaymentMethod.name` is the method's name (the checkout showed Shopware's distinguishable name, which differs only for methods of plugins, "PayPal | PayPal").
|
|
244
|
+
- **Guest registration** is a CheckoutPort method (`registerGuest`, with the storefront URL for the backend's e-mail links); the Shopware adapter sends the request of the 2.x form (unchanged fields, empty strings and `salutationId: ""`), lets Shopware replace the token (the cart moves with it). Guest details stay editable (`updateAddress`; a change without a salutation keeps the address's). The browser sends a domain `GuestDetails` whose addresses have no country (`AddressInput.country: null`, the form never asked for one): the Shopware adapter takes the configured country id (`public.site.countryId`, as the form sent it), a country code is resolved by ISO code. The BFF validates the details (required fields, lengths, phone, e-mail, control characters).
|
|
245
|
+
- **Logged-in customers until step 6** (done in step 6): login and creating an account in the checkout stay on the Shopware layer through the bridge. What the checkout needs of a customer is one minimal port method, `getOrderer` (customer and default addresses, for guests and customers alike), plus `updateAddress` for "Adresse bearbeiten"; the checkout reloads the orderer and the selection when the layer's login state changes. Account pages (addresses, order list, profile) stay on the layer.
|
|
246
|
+
- **Order lookup**: by the session only. `OrderPort.getOrder` answers an order of the session's guest or customer (Shopware: `/order` with the visitor's token); another visitor, a guessed id or a number are `not_found` (404). The e-mail deep link (Shopware's `/account/order/<deepLinkCode>` on the sales channel's first domain) is not served by the storefront, as before (open point).
|
|
247
|
+
- **Placing an order at most once**: one attempt id per press of the order button. The browser sends it again only after `stale_session` (that request never reached the backend), never after a failure without answer. The process remembers placed attempts per session and answers them again (also a double click's second request with an outdated cookie). The adapter sends `/checkout/order` once and waits up to 60 s for it (Shopware may still commit an order the storefront stopped waiting for; its cart lock lasts 5 s only, so it does not keep a second placement out). When the answer does not come, the attempt's session is marked unanswered (15 minutes, per process) and nothing is placed for it again: the same request, a retry and a new press look for an order the session placed since (polling for about 30 s) and answer it, or `order_status_unknown` (409), and the checkout says "Wir konnten nicht feststellen, ob deine Bestellung eingegangen ist. Bitte prüfe dein E-Mail-Postfach oder ruf uns an, bevor du erneut bestellst." A new attempt with an empty cart (another tab, a reload after the order) is `order_already_placed` with the session's order of the last 15 minutes in `details.orderId` (the checkout says "Deine Bestellung ist bereits eingegangen." and links the order; no payment is started, nothing is tracked), without one `cart_empty`. A reverse proxy in front of the storefront needs a read timeout above about 110 s for `POST /api/checkout/orders` (60 s for the order, about 30 s of looking for it, the checks around; nginx: `proxy_read_timeout 120s`), otherwise the guest sees the generic failure text while the server still keeps a second order out. Known limit: the unanswered mark is per process; a guest who presses again on another instance with a still full cart while the first order hangs could place a second one (it needs an answer to be lost for 60 s and a second press within the minutes after).
|
|
248
|
+
- **Session before the first write**: a page view still reads no session, but a new visitor gets one with `POST /api/session` right after the first page has loaded (the server render tells the app whether the request brought a session it can unseal; a malformed cookie or one of a dropped password counts as none), and every write of the app (cart, vouchers, methods, guest, addresses, order, payment) goes through one browser queue (`queuedWrite`): a write is sent after the answer, and the cookie, of the one before. So two first writes never start two sessions, and a write that a navigation cuts off still lands in the visitor's session (an add to the cart also uses `keepalive`). A checkout loaded by a full navigation while such an add is still landing reads the cart again after 1.5 and 3.5 s when it shows empty (this happened before step 5 too). Before step 5 the Shopware layer's reads through the bridge created a Shopware context per page view, which hid the race.
|
|
249
|
+
- **Selection before the cart**: `CheckoutSelection` is its own answer, since a cart without lines has no methods (Shopware's deliveries), but the menu's order mode shows the selected method from the first page view. A visitor without backend state gets the shop's defaults without a backend session.
|
|
250
|
+
- New domain values: `Orderer`, `CheckoutSelection`, `PlacedOrder`, `PaymentMethod.preferred`, `Address.department`, `GuestDetails.business`, `OrderLine.configuration`, `Order.discounts`/`taxes`/`taxIncluded`, `AddressInput`, error codes `cart_empty`, `order_status_unknown` and `order_already_placed` (409).
|
|
251
|
+
|
|
252
|
+
Behaviour, compared against the quickstart's Shopware before and after (same Playwright actions on main and on the branch: the checkout's head and text, the guest form's validation messages (empty and invalid), the time picker for delivery and pickup (label, earliest 30 / 15 minutes, latest), a delivery order with a configured pizza and a plain dish, a pickup order with a voucher, a business guest with another delivery address, ordering paused, a holiday and after hours (button and picker texts), ordering paused while the guest is on the page (the order button's message); then every order in Shopware through the Admin API (line items with payload, prices, taxes, comment, custom fields, addresses, shipping and payment method, customer, deliveries, transactions, states), the confirmation and order pages, the order mails in Mailpit): identical, but for the allowed changes below. Smoke and hardening tests of the quickstart pass, and the guest flow from the menu to the confirmation runs on the memory adapter. Changes allowed by the step:
|
|
253
|
+
|
|
254
|
+
- The order pages list the discounts after the dishes (Shopware answered the line items in no fixed order, a voucher could stand between two dishes).
|
|
255
|
+
- A new visitor's session starts with one `POST /api/session` after the first page has loaded, no longer with a Shopware context per page view; the Shopware context is created by the first write that needs it.
|
|
256
|
+
- The checkout shows the payment method's name (not Shopware's distinguishable name of plugin methods); errors of the guest form are the storefront's own ("Bitte prüfen Sie Ihre Angaben."), not Shopware's validation texts (which were English).
|
|
257
|
+
- An order whose payment could not be started goes to the payment retry instead of an error at the order button (which invited a second order). An order whose answer is lost waits up to about 90 s and then says the outcome is unknown, instead of a failure that invited a second order.
|
|
258
|
+
- The server refuses a wished time outside the ordering window (422) and a guest form the checkout would not send (400); the plugin refuses as before.
|
|
259
|
+
- Matomo gets one ecommerce item per order line (menu number, the receipt's name, price with extras) instead of one per Shopware product line item.
|
|
260
|
+
- The address of the checkout drops Shopware's second additional address line (the storefront never writes it).
|
|
261
|
+
|
|
262
|
+
For shops that extend the layer (release notes; breaking only for overrides and own uses):
|
|
263
|
+
|
|
264
|
+
- New routes: `/api/session` (POST, starts a new visitor's session), `/api/checkout/selection`, `/api/checkout/payment-methods`, `/api/checkout/orderer`, `/api/checkout/guest`, `/api/checkout/orderer/addresses/[addressId]`, `/api/checkout/orders`, `/api/orders/[orderId]`, `/api/orders/[orderId]/payment`. Reverse proxies and firewalls must pass them with their bodies, like `/api/cart/**`.
|
|
265
|
+
- The bridge `/api/store-api/**` forwards only `BRIDGE_ROUTES` (account, wishlist, contact): own code that called other Store API paths through the layer's `apiClient` in the browser (checkout, payment, cart, documents, `PATCH /context`) gets 404 and has to use the BFF.
|
|
266
|
+
- Changed: `useShippingLeadTime`, `useOrderMode`, `useCheckoutMethodGuard`, `useShippingMethodChoice` (domain `ShippingMethod[]`) no longer use the layer's `useCheckout`; `UserDetail` shows the `Orderer` (no props for addresses), `OrderDetail` takes a domain `Order` (no `status` prop), `OrderConfirmation` loads through `useOrder`; `trackOrder` takes a domain `Order`; `cartLineLabel` also takes an order line. The layer's `useCheckout`, `useOrderDetails` and `useOrderPayment` are no longer used by the storefront and do not work in the browser any more (their Store API paths are not bridged).
|
|
267
|
+
- Own code that writes to the BFF from the browser should go through `queuedWrite` (`app/utils/bffWrite.ts`), so it never starts a second session next to a write in flight. New domain codes `cart_empty`, `order_status_unknown` and `order_already_placed` (409). Reverse proxies need a read timeout above about 110 s for `POST /api/checkout/orders`.
|
|
268
|
+
- New: `useCheckoutMethods`, `useCheckoutOrderer`, `usePlaceOrder`, `useOrder`, `useDeliveryTime().wishedTimeFor`, `toGuestDetails`, `Checkout/OrdererAddress`, `Checkout/AddressForm`, `app/utils/orderStatus.ts`, `app/utils/bffWrite.ts`.
|
|
269
|
+
|
|
270
|
+
Open points for step 6 and later:
|
|
271
|
+
|
|
272
|
+
- Login, account registration, the account's addresses, order list and order page, profile and password move behind `CustomerPort` (step 6, done); the order page of the account already reads through `OrderPort`. `getOrderer` may then become `CustomerPort.getCustomer` with addresses.
|
|
273
|
+
- The e-mail deep link of an order (Shopware: `/account/order/<deepLinkCode>`, guest authentication by e-mail and postal code) is not served, as before; a port method `findOrderByDeepLink(token, email, postalCode)` and a page would serve it.
|
|
274
|
+
- `AddressForm` (account) and `Checkout/AddressForm` share the fields and rules; one form on the domain `Address` once the account moves (step 6, done).
|
|
275
|
+
- The payment retry page loads the payment methods of the visitor's context (Shopware's rules on an empty cart), as before.
|
|
276
|
+
- The memory adapter sends no order mails and accepts any payment.
|
|
277
|
+
|
|
278
|
+
**Step 6 (customer account), done.** `CustomerPort` in both adapters with a contract suite on one backend with cart, checkout and orders (`test/contract/customer.contract.ts`: no customer for a visitor or a cart, the session's guest as guest, every account method `unauthenticated` without a customer, the shop's countries; registration logs in and keeps the cart, a separate delivery address, an e-mail with an account refused, double opt-in with confirmation, a broken link and a second confirmation; login replaces the session state and the state before opens nothing, wrong password and unknown e-mail alike, failed logins limited per e-mail and visitor address, the visitor's cart merged into the customer's saved cart, logout and a replayed logged-in state; names, e-mail and password changes with the password; password reset for a known and an unknown e-mail, a used and an unknown token; addresses created, changed, made default, deleted but not a default one, another customer's address never read or written (also through the checkout); orders as a customer, listed in the account, not readable after a logout or by another customer; frozen answers). The BFF answers domain types under `/api/account/**` (routes in CLAUDE.md); the app's account (login, registration and its confirmation, password pages, header, account pages, the checkout's login and account registration) uses them. The bridge forwards only the context, the salutations, the contact form and the wishlists. Lint guard: 5 warnings.
|
|
279
|
+
|
|
280
|
+
Decisions of step 6:
|
|
281
|
+
|
|
282
|
+
- **Login, logout and registration** are port methods that replace the session's backend state; the BFF reseals the session with it (a new version: the cookie of before is stale in the process, `stale_session` for its writes) and the backend makes the old state worthless (Shopware replaces the context token on login, logout, registration, confirmation, password change and deletion; checked on the quickstart, also across a restart of the storefront, when the process no longer knows the old cookie). The session id stays the same over a login: the process's memory of placed order attempts stays with the browser, which can name an order id but not read it after a logout.
|
|
283
|
+
- **Cart merge**: exactly Shopware's: `/account/login` with the visitor's token merges the visitor's cart into the customer's saved cart (the same line adds up); logout leaves the visitor an empty cart, the customer's cart waits for the next login. The memory adapter does the same (`MemoryCart.merge`).
|
|
284
|
+
- **Registration** takes the guest's details plus a password (`Registration = GuestDetails & { password }`), the same form and request of the 2.x checkout with `guest: false`. Double opt-in: `confirmationRequired`, no login until the link is confirmed; the link's query parameters reach the adapter as they came (opaque to the BFF). Shopware 6.7 answers such a customer with `active: true`; the missing `doubleOptInConfirmDate` tells that the confirmation is pending. Shopware's confirmation URL (`core.loginRegistration.confirmationUrl`, default `/registration/confirm?em=%%HASHEDEMAIL%%&hash=%%SUBSCRIBEHASH%%`) must be `/registrierung/bestaetigen?em=%%HASHEDEMAIL%%&hash=%%SUBSCRIBEHASH%%` for double opt-in, as before. A login with the right password before the confirmation is `account_not_confirmed`. Shopware 6.7 answers a customer the shop deactivated with bad credentials (`invalid_credentials`); the code `account_inactive` is for backends and versions that tell it apart (the adapter maps `CHECKOUT__CUSTOMER_IS_INACTIVE` to it, harmless where it never comes). The answer of a registration waiting for its confirmation is the customer as entered (Shopware's answer loads no salutation or address).
|
|
285
|
+
- **Password reset** answers the same for an e-mail with and without account (204; Shopware 6.7 does too, the BFF turns a `not_found` into success anyway), also when Shopware's limit holds it back: that limit (from the fourth request within its window) is only reached by e-mails with an account, so a 429 would tell them apart; the adapter logs the limit server-side (without the e-mail) and answers 204. The link's hash is the reset token. The requests go as shop requests with the visitor's `X-Forwarded-For`, so a reset never creates a session.
|
|
286
|
+
- **Rate limits** are Shopware's (per e-mail and client IP: ten failed logins, then 10 s and growing); they see the visitor through `X-Forwarded-For` (`TRUSTED_PROXIES`, as in step 4). The answer is 429 `rate_limited` with `retryAfterSeconds`; the memory adapter has its own (ten per minute).
|
|
287
|
+
- **Password change**: Shopware 6.7 logs every session of the customer out; the adapter logs the changing session in again with the new password, so the customer stays logged in (other devices are logged out, as Shopware intends). The answer is `{ loggedIn }`: when that login fails (a limit, a timeout), the password is changed all the same and the profile asks the customer to log in again with it.
|
|
288
|
+
- **Passkeys/WebAuthn**: the storefront has none, so nothing moved.
|
|
289
|
+
- **Addresses**: one `AddressForm` on the domain `Address` for the account and the checkout (the caller saves). A new address has no country (the shop's, as the form never asked for one), a change keeps the address's country and salutation. Another customer's address is `not_found` (Shopware answers 400 `CHECKOUT__CUSTOMER_ADDRESS_NOT_FOUND`).
|
|
290
|
+
- **Orders of the account** come from `OrderPort.listOrders` (100 per page, the Store API's limit, newest first) and `getOrder`; the status is `ORDER_STATUS_LABEL`.
|
|
291
|
+
- **The header and the account state** come from `GET /api/account`, rendered on the server. The layer's context is still read during server-side rendering for the price format, with a 10 s deadline (`readLayerContext`), in parallel with the customer, and goes into the page payload without token, customer and the customer's own address (`shippingLocation.address`, with the customer's id); the bridge's `GET context` answers without them too (the layer in the browser needs neither). A visitor with a session thus costs two Store API reads per rendered page (`/context` and `/account/customer`); merging them waits for the price format in `ShopConfig`. The account's addresses and orders in the browser are forgotten when the customer changes (login, logout, deletion, a password change that ended the login), and a read of the customer, the addresses or the orders that answers after such a switch is dropped (reads in flight are aborted, `guardedAccountRead`).
|
|
292
|
+
- **Outages**: an outage breaker per process (`server/utils/outageBreaker.ts`, used by `storeApiGet`, `storeApiPost`, `storeApiForVisitor`) opens after two Store API requests without an answer (deadline or no connection) within 15 s with no answer between, and then fails every request at once with 503 (`backend_unavailable`) for up to 30 s, letting one probe through 10 s after the last one ended (never two at once; a probe without an answer keeps it open for another 30 s); the first answer of Shopware, also a refusal or a 5xx, closes it, so the shop is back within about 10–20 s of Shopware. The first page of an outage waits for two deadlines (about 20 s), the following ones for about one (main did not answer within 150 s). Right after an outage the cached routes keep their own 30 s backoff (step 1). Other errors (an unreadable answer, a programming error) never count, so one slow request never takes the shop down. The order placement and its follow-up look-ups for an unanswered order run past it (`bypassOutageBreaker`) and never open it.
|
|
293
|
+
- **The order's deadline**: the order request may take 60 s (step 5), but the transport (`storeApiForVisitor`) cut every visitor request off after its own 10 s, also on main since step 5; the request now carries its timeout (`timeoutMs`), so a placement answering after 15 s is answered without the look-ups.
|
|
294
|
+
- **Errors** are the storefront's German texts by domain code (`app/utils/accountMessages.ts`), never Shopware's; the app logs domain codes only, because a request error carries its body with the password.
|
|
295
|
+
- **The order e-mail deep link** (`/account/order/<deepLinkCode>`, guest authentication by e-mail and postal code) is still not served: it needs a port method, a Shopware lookup by deep link code and a page; left for a later step.
|
|
296
|
+
- New domain values: `Registration`, `RegistrationResult`, `ProfileChange`, `AccountAddress`; codes `account_not_confirmed` (403), `account_inactive` (403, for other backends and versions), `already_confirmed` (409), `rate_limited` (429), `address_in_use` (409).
|
|
297
|
+
- **Memory carts**: a logout keeps what another session of the customer saved before; a login of a session that belongs to another customer leaves that customer's cart with them.
|
|
298
|
+
|
|
299
|
+
Behaviour, compared against the quickstart's Shopware before and after (same Playwright actions on main and on the branch: the account pages logged out (status, head, text), registration with empty and invalid fields, a registration, logout, the same e-mail again, a wrong password, eleven wrong passwords (rate limit), a customer's saved cart and a visitor's cart merged on login, the header logged in, a logged-in checkout with the saved address and its order, the order list and order page, names, e-mail and password change, address created, changed, made the default delivery and billing address and the old one deleted, password recovery with the mail from Mailpit, the reset link and a login with the new password; then the customer, its addresses and its orders in Shopware through the Admin API): identical (heads, page texts, validation messages, cart lines after the merge, the header, the order and its line items, addresses, customer comment, order customer), but for the allowed changes below. Smoke and hardening tests of the quickstart pass; register, login, address and a logged-in order run on the memory adapter. Security, on the quickstart: a replayed cookie of before the login and a logged-in cookie after the logout (also after a restart of the storefront) open no account, read no address or order and cannot write; another customer's guessed address and order ids are 404; every account write from another origin is 403; the reset answers known and unknown e-mails alike (also when Shopware's limit holds a known one back, since the review), the login a wrong password and an unknown e-mail alike; Shopware's login limit holds one visitor address and not another; no context token in 486 answers (HTML with payload, JSON, errors, account pages) and no password in any answer or in the storefront's log. Changes allowed by the step:
|
|
300
|
+
|
|
301
|
+
- Errors of login, registration and profile are the storefront's German texts (wrong password and unknown e-mail: "Bitte überprüfen Sie Ihre Zugangsdaten."; the rate limit with the seconds to wait; an existing e-mail; an unconfirmed account), no longer Shopware's English texts.
|
|
302
|
+
- The e-mail change asks for the password and works (it sent an empty password and always failed); the profile has a password change; the address book deletes addresses that are no default after a confirmation; the order list shows each order's status (the layer did not load it).
|
|
303
|
+
- The profile form has a heading for screen readers ("Persönliche Daten").
|
|
304
|
+
- The order list is newest first (the layer listed the oldest first).
|
|
305
|
+
- A registration with double opt-in stays on the page and says that the confirmation mail is on its way (the page went to the login and the notice was lost).
|
|
306
|
+
- A password reset that Shopware's limit holds back answers like any other (the layer showed the failure, for known e-mails only).
|
|
307
|
+
- The account pages load the customer and addresses from the BFF; the layer's `/context` (page payload and bridge) no longer carries the customer or the customer's address, and its server-side read gives up after 10 s.
|
|
308
|
+
|
|
309
|
+
For shops that extend the layer (release notes; breaking only for overrides and own uses):
|
|
310
|
+
|
|
311
|
+
- New routes: `/api/account/**` (see CLAUDE.md). Reverse proxies and firewalls must pass them with their bodies, like `/api/cart/**`; they are never cacheable.
|
|
312
|
+
- The bridge `/api/store-api/**` forwards only `GET context`, `POST salutation`, `POST contact-form` and the wishlist routes: own code that called the account through the layer (`useUser`, `useAddress`, `useCustomerOrders`, `useCustomerPassword`, `apiClient` on `/account/*`, `/order`, `/country`, `GET /checkout/cart`) gets 404 and has to use `useCustomer`, `useAccountAddresses`, `useAccountOrders` or the routes.
|
|
313
|
+
- Changed: `AddressForm` takes a domain `address` and a `save` function and emits `submit-success` without a value; `AddressDetail` and `AddressCard` take a domain `Address`; `Checkout/AddressForm` is gone (the one `AddressForm`); `UserRegistrationForm` emits `registration-success` with `(data, needsConfirmation)`; `useRegistrationForm().submit` answers `needsConfirmation` without a `customer`; the layer's `useUser` no longer knows the login (its context has no customer).
|
|
314
|
+
- New: `useCustomer`, `useAccountAddresses`, `useAccountOrders`, `app/utils/accountMessages.ts`, `app/utils/layerContext.ts`, the domain codes above; `POST /api/account/password` answers `{ loggedIn }`.
|
|
315
|
+
- Reverse proxies must overwrite a client-sent `X-Forwarded-For` (see Visitor address, step 4). A shop's own composable must not be named `useCustomer`, `useAccountAddresses` or `useAccountOrders`.
|
|
316
|
+
|
|
317
|
+
Open points for step 7 and later:
|
|
318
|
+
|
|
319
|
+
- Wishlist (`WishlistPort`) and contact form (`ContactPort`) still run on the layer through the bridge (`GET context`, `salutation`, `contact-form`, wishlists); the wishlist reads the login from `useCustomer`.
|
|
320
|
+
- The order e-mail deep link (above).
|
|
321
|
+
- The memory adapter sends no mails: password reset and double opt-in cannot be completed on it.
|
|
322
|
+
- The layer's `/context` is still read during server-side rendering for the price format (currency, locale); `ShopConfig` could carry them.
|
|
323
|
+
- A password change logs the customer's other devices out (Shopware); a "log out everywhere" is not offered.
|
|
324
|
+
|
|
325
|
+
**Step 7 (wishlist and contact; no browser-direct backend call), done.** `WishlistPort` and `ContactPort` in both adapters with contract suites (`test/contract/wishlist.contract.ts`, on one backend with the account and the menu: no wishlist for a visitor or a checkout guest, empty for a new customer, a dish with extras and removals, a variant under its dish with the variant's menu number, an equal configuration once whatever the order of its parts, the same dish twice when only the removals differ, newest first, what the menu does not offer refused, removing and an unknown entry, another customer's entries never shown or removed, the wishlist kept over a logout, the state of before a logout opening nothing, the guest's configurations merged after the login (equal, unknown and duplicate ones left out, newest first), an empty merge, configurations with parts the dish no longer has left out, frozen answers; `test/contract/contact.contract.ts`: the message handed to the restaurant with the visitor's address chain, only the fields the form requires, the restaurant's own confirmation text, three messages per visitor address and then `rate_limited` while another address is not held back, a frozen answer). The BFF answers `WishlistEntry` and `{ confirmation }` (routes in CLAUDE.md); the wishlist (header count, the dish sheet's heart, the wishlist page with "Anpassen" and adding to the cart, the merge on login) and the contact form use them. The bridge `/api/store-api/**` is gone and no page reads the visitor's backend context any more: the browser sends no request to Shopware and none in Shopware's shapes. Lint guard: 0 warnings.
|
|
326
|
+
|
|
327
|
+
Decisions of step 7:
|
|
328
|
+
|
|
329
|
+
- **Where the wishlist lives**: a customer's in the backend (Shopware: the plugin's `shopbite_wishlist_item`), a guest's in the browser's local storage (`shopbite-wishlist`), as before: it outlives the session (local storage has no expiry, the cookie 30 days after the last visit) and the sealed cookie has no room for it. The storage holds domain entries now (`{ version: 2, entries, pending }`); the guest storage of 2.x (configured products with removals by name and extras by number, and the plain product ids of `sw-wishlist-items`) is converted once in the browser with the dishes' sheets (`/api/menu/dishes/<id>`): a dish off the menu (404) is dropped (its row was not shown before either), one that cannot be loaded (an outage) stays `pending` for the next visit. The app compares configurations with its own `sameConfiguration` (`app/utils/wishlist.ts`, no value import of `shared/`).
|
|
330
|
+
- **Mapping in the Shopware adapter**: the domain names dish, variant, extras and removals by id; the adapter writes the plugin's records exactly as 2.x (the ordered product: the variant, else the dish; removals by name, extras by product number, both sorted; the plugin stores the product number), so main and the branch write identical records (compared through the Admin API). Reading translates names and numbers back with one product lookup (`sw-inheritance`, so a variant has its dish's ingredients) and the cross-sellings of each dish with extras, both kept 60 s; a name or number the dish no longer has is left out (the page did the same), and an entry of a product the menu no longer has keeps the product id as its dish (the page cannot show it, as before). Adding refuses what the menu does not offer (`dish_unavailable`, `invalid_value`); the plugin only checked that the product exists.
|
|
331
|
+
- **Merge on login**: `POST /api/wishlist/merge` with the guest's configurations (at most 100, the plugin's limit) right after the login (`app.vue` watches `isLoggedIn`), equal and unknown ones left out, the guest's entries newest first ahead of the account's (the plugin dates them so); the guest storage is emptied afterwards (`pending` 2.x entries stay), a failed merge keeps it. A logout shows the guest's list again (empty after a merge).
|
|
332
|
+
- **Shopware's own wishlist** (plain products, from before the plugin's wishlist) moves into the plugin on the read in the adapter (`listEntries`), no longer from the browser; its 404 (none) and 403 (switched off) are ignored, and a failed move is logged and leaves both lists as they are.
|
|
333
|
+
- **A backend without a wishlist** answers `not_implemented` (501, Shopware: a plugin without the routes, a 404 that is no entry's); the browser then keeps the customer's entries in local storage, as before for a plugin older than its wishlist.
|
|
334
|
+
- **Contact**: `POST /api/contact`, shop-wide (no session read or created), CSRF and private like every write. The BFF checks the fields as the form does: e-mail, subject at least 3 characters, message at least 10 and at most 10 000, names and phone optional; up to 255 characters, no control characters and no line breaks outside the message (no header injection through names, e-mail or subject); a filled honeypot (`hp`) is answered like a sent message without sending. The Shopware adapter sends the request of 2.x: the salutation "not given" (`not_specified`; 2.x sent the last of Shopware's salutations, which is that one), empty strings for empty fields, the message as `comment`, with the visitor's `X-Forwarded-For` (`ContactPort.send(message, sender)`). Shopware's limit (`contact_form`: three per 30 s, then longer) answers 429 `rate_limited` with `retryAfterSeconds`, a refused field 422 `validation_failed` with the fields. The form shows the same success and error texts as 2.x (one error text for every failure). The memory adapter hands messages to a callback (the running storefront drops them) and limits three per 30 s per the nearest address of the chain.
|
|
335
|
+
- **Salutations**: no list is needed any more. The contact form asks for none, registration and addresses use the domain's three values; the Shopware adapter reads the salutation ids itself (kept 10 minutes). The bridge's `POST salutation` is gone.
|
|
336
|
+
- **Price format** in `ShopConfig` (`currency`, `locale`; Shopware: the sales channel's `/context` without a token, read once per 10 minutes and shared with the catalog's currency; memory: EUR, de-DE). `useCommercePrice` reads them from the shop configuration the server renders (`useNuxtData("shop-config")`, so server and hydration format alike); `setPriceConfig` still overrides them. `og:locale` comes from `ShopConfig.locale`. A rendered page reads no visitor context any more: a visitor with a session costs one Store API read per page (`/account/customer`) instead of two.
|
|
337
|
+
- **The Shopware layer** stays installed until step 8 but is cut off: its client gets the base URL `about:invalid` in the browser and during server-side rendering (a call fails before anything leaves the storefront) and no context token (`app/plugins/shopware-layer-offline.ts`); the visitor session plugin no longer hands the token to rendering. `forwardedFor()` moved to `server/session/forwardedFor.ts`.
|
|
338
|
+
- **After the review**:
|
|
339
|
+
- Contact messages go to Shopware's server endpoint with the visitor's address chain (the visitor transport without a token, as the removed bridge did), not the public endpoint, so the per-IP limit sees visitors also when the public endpoint has a proxy of its own. The salutation lookup takes the same transport, shop-wide without an address chain, and is kept 10 minutes. A shop without "not given" gets its first salutation.
|
|
340
|
+
- **Required contact fields** (an improvement over 2.x, whose form called first name, last name and phone optional while Shopware may require them, the quickstart does, and then refused with the generic error): `ContactPort.getForm()` answers them (`ContactForm.required`). Shopware does not expose `core.basicInformation.*FieldRequired` in the Store API; the adapter takes them from the ShopBite plugin's `/shopbite/config` when it names them (`firstNameFieldRequired`, `lastNameFieldRequired`, `phoneNumberFieldRequired`, all three booleans; a later plugin release switches over without a storefront change), else learns them from Shopware's validation of an empty message, which never sends a mail or counts towards the limit (validation runs first); reads at the same time share one probe, and when Shopware cannot tell nothing is required. The adapter keeps no copy: `GET /api/contact/form` answers the cached function `contact-form` (`config` TTL, emptied by every purge, `{ "layout": true }` included), also for `?fresh=1`, so visitors cannot multiply the probe. The form marks and checks them; `POST /api/contact` refuses them blank (400 with the field); a refusal of Shopware with fields is shown at the fields ("Bitte prüfen Sie die markierten Angaben.").
|
|
341
|
+
- `ShopConfig` survives a failing context read: the default price format (EUR, de-DE) is answered and logged, the context asked again next time (before, the whole configuration with the switch that accepts orders was 503).
|
|
342
|
+
- The wishlist read moves Shopware's own wishlist first and asks the list only when nothing moved; an empty or switched-off one is not asked again for 10 minutes (per token); two reads share one move, and `GET /api/wishlist` runs in the visitor's exclusive section (`answerVisitor`'s `exclusiveRead`). A merge looks up all products at once (100 ids per request), the extras of each dish in parallel, and remembers unknown ids for a minute; ids that are no Shopware ids are not sent.
|
|
343
|
+
- A guest keeps at most 100 entries ("Ihre Merkliste ist voll (100 Gerichte). …"); a merge sends the newest 100, the BFF takes the first 100 of up to 1000. Only a guest storage of 2.x can hold more; the older entries beyond 100 are left out of the merge without a word (they are removed from the guest storage with the rest).
|
|
344
|
+
- `/api/wishlist/**` and `/api/contact` read at most 64 KB (413 `payload_too_large`, refused before buffering).
|
|
345
|
+
- Smaller ones: a honeypot counts any value; the shortest subject and message count without the spaces around them (form and BFF); single-line fields refuse NEL and the Unicode line and paragraph separators (all BFF text fields); removing an entry the backend no longer has counts as removed; a 2.x entry the backend refuses (400) is dropped like one off the menu; a guest's change waits for a load still converting the storage; the answer of a merge is dropped when the customer switched meanwhile; the memory adapter limits contact messages by the chain's client address (its first entry; the demo trusts the chain).
|
|
346
|
+
|
|
347
|
+
Behaviour, compared against the quickstart's Shopware before and after (same Playwright actions on main and on the branch, browser time zone Europe/Berlin, a test address per run in `X-Forwarded-For`): heads and texts of `/merkliste` and `/kontakt`; as a guest a large Margherita with an extra and a removal and a plain dish saved from the dish sheet, the wishlist after a reload (rows, prices, header count), "Anpassen" (the sheet with the saved configuration, heart pressed), adding a row to the cart (the cart line), removing a row; a customer saving two entries; the guest logging in with an entry equal to one of the customer's (merge), adding and removing while logged in, the logout; the plugin's records after each of these through the Admin API; the contact form empty and invalid (messages), a message with all fields and line breaks (success text, the mail in Mailpit field by field: subject, sender, recipient, reply-to, text and HTML body), and four more messages from the same address (two sent, then the error text). Identical, but the local storage's format and the mail's MIME boundary. The browser's requests: on main 51 went through the bridge (`context`, `salutation`, `contact-form`, both wishlists), on the branch none; every request goes to the storefront's own origin and every `fetch` to its `/api/**` (plus Nuxt's build manifest). A guest storage of 2.x (a variant with an extra and a removal, a plain dish, a product off the menu, a plain id of `sw-wishlist-items`) opens as the same rows in the same order on the branch (the plain ids of `sw-wishlist-items` last, as 2.x listed them), converted once. Smoke and hardening tests of the quickstart pass; the same actions run on the memory adapter (but the mail). Security, on the quickstart: wishlist reads of a visitor 401, writes from another site (Origin, `Sec-Fetch-Site`) 403, another customer's entries neither listed nor removable (404), a cookie of before the logout reads nothing and writes nothing (409 `stale_session`, after a restart of the storefront 401), invalid bodies 400 and unknown dishes 409; contact fields with line breaks (subject, e-mail, names), control characters, a short or a 10 001-character message refused (400), another site 403, the honeypot sends nothing; Shopware's limit holds one visitor address after three messages and not another, an address forged left of the visitor's does not get past it; with Shopware paused the wishlist and the contact answer 503 `backend_unavailable` (the breaker fails the later ones at once). Changes allowed by the step:
|
|
348
|
+
|
|
349
|
+
- A guest's wishlist is stored as domain entries (`{ version: 2, … }`); the storage of 2.x is converted once, and a guest's entry of a dish off the menu is dropped then (it was not shown before).
|
|
350
|
+
- Adding a configuration the menu does not offer is refused (409 `dish_unavailable`, 400 `invalid_value`) instead of being stored.
|
|
351
|
+
- The contact form posts to `/api/contact`, which checks the fields as the form does; bodies the form never sends (line breaks in the subject, more than 10 000 characters) are refused, and a filled honeypot is ignored by the server as well.
|
|
352
|
+
- Shopware's own wishlist moves into the plugin during the server's read of the wishlist, not from the browser.
|
|
353
|
+
- A new visitor on the wishlist or contact page starts the session with `POST /api/session` (the bridge's context read gave one before).
|
|
354
|
+
- Prices are formatted in `ShopConfig.currency` and `locale` (the sales channel's; before the visitor's context, which the storefront never switches).
|
|
355
|
+
- The contact form asks for first name, last name and phone when the restaurant requires them (marked, checked, said at the field) instead of failing with the generic error; a guest wishlist holds at most 100 entries; bodies above 64 KB are refused.
|
|
356
|
+
|
|
357
|
+
For shops that extend the layer (release notes; breaking only for overrides and own uses):
|
|
358
|
+
|
|
359
|
+
- Removed route: `/api/store-api/**` (the bridge). Nothing of the layer reaches Shopware any more: the layer's composables (`useWishlist`, `useSalutations`, `useSessionContext`, …) fail in the browser at once and have no visitor context during rendering. Reverse proxies need not pass `/api/store-api/**`; they must pass `/api/wishlist/**` and `/api/contact` with their bodies (private answers) and overwrite a client-sent `X-Forwarded-For` (see Visitor address, step 4: Shopware's limit of the contact form counts per visitor address).
|
|
360
|
+
- Removed: `useSyncWishlist` (the layer's own is auto-imported again and cannot reach Shopware), `app/utils/layerContext.ts` (`readLayerContext`, `withoutAddress`), `app/plugins/store-api-session.ts` (now `shopware-layer-offline.ts`), `useContactForm().salutations`, `contactFormSchema.salutationId`, the exports `WishlistConfiguration`, `normalizeWishlistList`, `isSameConfiguration` of `useWishlistEntries`; the layer's session context is no longer seeded.
|
|
361
|
+
- Changed: `useWishlistEntries` holds domain `WishlistEntry` values (`configuration`, `dishNumber`, `addedAt`), `find(configuration)` takes a `DishConfiguration` and `add(selection)` a `WishlistSelection` (`app/utils/wishlist.ts`, with `sameConfiguration`); `WishlistSaveButton`'s `selection` and `ProductDetail`'s `selection-changed` are a `WishlistSelection`; `useCommercePrice` takes its defaults from `ShopConfig`; `ShopConfig` has `currency` and `locale`; `ContactPort.send` takes the sender.
|
|
362
|
+
- New: `/api/wishlist`, `/api/wishlist/entries`, `/api/wishlist/entries/[entryId]`, `/api/wishlist/merge`, `/api/contact`, `/api/contact/form`; `ContactPort.getForm()`, `ContactForm`; `WISHLIST_LIMIT`, `WishlistFullError` (`useWishlistEntries`); `answerVisitor`'s `exclusiveRead`; `readSmallBody` (`server/utils/requestBody.ts`).
|
|
363
|
+
|
|
364
|
+
Open points for step 8 (what is left of Shopware outside the adapter):
|
|
365
|
+
|
|
366
|
+
- `@shopware/nuxt-module` and the `@shopware/composables` layer are still installed: the module's plugin creates the (cut off) client, the public runtime config still carries `public.shopware.endpoint` and the access key (the browser no longer uses them), `shopware.d.ts`, `api-types` and the `#shopware` types stay for the adapter. Step 8 removes module, layer and `app/plugins/shopware-layer-offline.ts`, moves endpoint and access key into the adapter's private runtime config, and turns the lint guard into an error.
|
|
367
|
+
- The order e-mail deep link (above).
|
|
368
|
+
- The memory adapter sends no mails (password reset, double opt-in, contact messages).
|
|
369
|
+
- The password reset (step 6) still sends its shop request with the visitor's `X-Forwarded-For` to the public endpoint; like the contact form it should use the server endpoint.
|
|
370
|
+
- The required contact fields come from a probe of an empty `/contact-form`, which depends on Shopware validating before its limit and on its error pointers (`/firstName`, `/lastName`, `/phone`). The sturdier source is the ShopBite plugin exposing `core.basicInformation.{firstName,lastName,phoneNumber}FieldRequired` in `/store-api/shopbite/config` as `firstNameFieldRequired`, `lastNameFieldRequired`, `phoneNumberFieldRequired`; the adapter already prefers them when present, so the plugin release is all that is needed.
|
|
371
|
+
- Reading the wishlist of a logged-in customer costs the plugin's list, Shopware's own wishlist (for the move) and the product lookup and cross-sellings (kept 60 s); the move could stop once no customer has an old wishlist.
|
|
372
|
+
- The memory adapter trusts the address chain for its contact limit (a demo backend).
|
|
373
|
+
|
|
374
|
+
### Lint guard
|
|
375
|
+
|
|
376
|
+
`@typescript-eslint/no-restricted-imports` forbids `#shopware`, `@shopware/*` and the `api-types` (`~~/api-types/*`, relative paths) outside `server/adapters/shopware/**`, the generated types and `shopware.d.ts`. It warns during steps 1 to 7 (111 warnings in 103 files at step 0, the number to bring down; 22 after step 5, 5 after step 6, 0 after step 7) and becomes an error in step 8. `#shopware/*` subpaths are covered too. It sees static `import` and `export … from` only: not type queries (`typeof import("#shopware")`, `import("…").Type` in a type position), not dynamic `import()`, and not composables auto-imported from the Shopware layer (`useShopwareContext`, `useCart`, …). Those disappear with the layer in step 8, and the typecheck finds what is left.
|
|
377
|
+
|
|
378
|
+
## Consequences
|
|
379
|
+
|
|
380
|
+
- During steps 1 to 7 two paths coexist: moved areas go browser → BFF → port → adapter, the rest still uses the Shopware composables. Each step's PR says which.
|
|
381
|
+
- Cart and checkout actions get one more hop (browser → Nitro → backend); the BFF can batch and cache shop-wide answers, and the access key and context token leave the browser, which removes them from the reach of injected scripts.
|
|
382
|
+
- Values that gate an order and are cached for rendering today (the checkout switch, hours, holidays; the browser reloads them from Shopware after hydration) have to stay fresh through the BFF: an uncached or short-lived route for the browser, the cached one for SSR.
|
|
383
|
+
- Shops that override Shopware composables of the layer have to move to the ports by 3.0.0; the 2.x releases keep their overrides working.
|
|
384
|
+
- A new backend means a new folder in `server/adapters/` that passes the contract suites, plus a value of `shopBite.backend`. The memory adapter can later run e2e and a11y tests without a Shopware instance.
|
|
385
|
+
|
|
386
|
+
## Notes for later steps
|
|
387
|
+
|
|
388
|
+
Recommendations from the review of step 0, to settle when the area moves:
|
|
389
|
+
|
|
390
|
+
- **Ordering window vs. the ShopBite plugin (settle before the UI uses `earliestWishedTime`, step 1 or 4).**
|
|
391
|
+
- *Pre-orders for the next day:* at 23:30 the domain offers 11:30 of the next day, but the plugin's ordering window only looks at yesterday's and today's intervals and refuses such an order at checkout. Either the plugin accepts orders for a later service date, or the storefront limits wished times to the plugin's window.
|
|
392
|
+
- *Overnight interval after a holiday:* the plugin ignores the after-midnight part of an interval that started on a holiday; splitting rows into weekday intervals loses that origin, so the domain treats it as open. Keep the origin day of a split interval (or apply the holiday to the continuation) when this matters.
|
|
393
|
+
- *DST:* a wished time can land in the spring-forward gap or the ambiguous fall-back hour, and the 24 h search limit is wall-clock time. Decide whether to skip such slots.
|
|
394
|
+
|
|
395
|
+
- **Checkout (step 1 and 5)**: `listShippingMethods` takes an optional session (Sylius prices shipping per cart; in the port since step 1, unused by both adapters). It is implemented in step 1 already, because ShopPort's consumers (home page, `llms.txt`, the time choice) need the lead times. Guest details stay editable after `registerGuest`.
|
|
396
|
+
- **Orders (step 5)**: `OrderLine` carries its `DishConfiguration` so an order can be repeated (done). A guest opening an order by the e-mail deep link without the session is still open (see step 5).
|
|
397
|
+
|
|
398
|
+
## Sylius as a sanity check
|
|
399
|
+
|
|
400
|
+
Not built; the port shapes were checked against how Sylius (2.x, API Platform shop API) would serve them:
|
|
401
|
+
|
|
402
|
+
- **The hardest mapping: a dish with extras and removed ingredients as one cart line.** The ports model it as a `CartLine` with a `DishConfiguration` (dish or variant, extras, removed ingredients), priced as a whole, never as Shopware's `container` line item with children. Sylius has no such line: an order item is one variant, and two items with the same variant merge (`OrderItem::equals`). A Sylius adapter needs a plugin that stores the configuration on the order item, compares items by configuration, and prices extras as adjustments (or as child units). The port does not change.
|
|
403
|
+
- Menu sections are taxons, dishes are products, variants are product variants with option values (`VariantGroup` = product option), extra groups are product associations. Main ingredients, diets and allergens are product attributes.
|
|
404
|
+
- Money is already integer minor units, countries are codes, there are no salutation entities (hence nullable `Salutation`).
|
|
405
|
+
- Paths come from taxon slugs; Sylius keeps no history of old slugs, so `resolvePath` answers fewer redirects. The port allows that.
|
|
406
|
+
- The visitor's cart token and the shop user's JWT go into the storefront session as the adapter's opaque state, like Shopware's context token.
|
|
407
|
+
- Order states (`new`, `fulfilled`, `cancelled`), payment states and shipping states map onto `OrderStatus` and `PaymentStatus`.
|
|
408
|
+
- Opening hours, holidays, lead time per shipping method, the switch that accepts orders and the wished time have no Sylius counterpart; they come from a plugin (or from the storefront's own configuration). `ShopPort` and `ShippingMethod.leadTime` do not assume Shopware entities.
|
|
409
|
+
- Branches are channels; a channel per branch with its own hostname.
|
package/eslint.config.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import withNuxt from
|
|
3
|
-
import eslintConfigPrettier from
|
|
2
|
+
import withNuxt from "./.nuxt/eslint.config.mjs";
|
|
3
|
+
import eslintConfigPrettier from "eslint-config-prettier";
|
|
4
4
|
|
|
5
5
|
export default withNuxt(
|
|
6
6
|
{
|
|
@@ -10,5 +10,45 @@ export default withNuxt(
|
|
|
10
10
|
"vue/multi-word-component-names": "off",
|
|
11
11
|
},
|
|
12
12
|
},
|
|
13
|
+
{
|
|
14
|
+
// ADR 0001: only the Shopware adapter talks Shopware. A warning while
|
|
15
|
+
// the code moves to the ports (steps 1–7), an error from 3.0 (step 8).
|
|
16
|
+
name: "shopbite/backend-agnostic",
|
|
17
|
+
ignores: [
|
|
18
|
+
"server/adapters/shopware/**",
|
|
19
|
+
// generated Store API types and their module augmentation
|
|
20
|
+
"api-types/**",
|
|
21
|
+
"shopware.d.ts",
|
|
22
|
+
],
|
|
23
|
+
rules: {
|
|
24
|
+
"@typescript-eslint/no-restricted-imports": [
|
|
25
|
+
"warn",
|
|
26
|
+
{
|
|
27
|
+
// `#shopware` as a path: in the gitignore syntax of `patterns` a
|
|
28
|
+
// leading # starts a comment
|
|
29
|
+
paths: [
|
|
30
|
+
{
|
|
31
|
+
name: "#shopware",
|
|
32
|
+
message:
|
|
33
|
+
"Shopware belongs in server/adapters/shopware; use the ports and the domain types (shared/domain), see docs/adr/0001-backend-agnostic-storefront.md.",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
patterns: [
|
|
37
|
+
{
|
|
38
|
+
// `\\#` escapes the comment character for subpaths
|
|
39
|
+
group: ["\\#shopware/*", "@shopware/*"],
|
|
40
|
+
message:
|
|
41
|
+
"Shopware belongs in server/adapters/shopware; use the ports and the domain types (shared/domain), see docs/adr/0001-backend-agnostic-storefront.md.",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
group: ["~~/api-types/*", "**/api-types/*"],
|
|
45
|
+
message:
|
|
46
|
+
"The Store API types belong in server/adapters/shopware; use the domain types (shared/domain), see docs/adr/0001-backend-agnostic-storefront.md.",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
13
53
|
eslintConfigPrettier,
|
|
14
54
|
);
|