@meeovi/layer-commerce 1.0.11 → 1.0.14
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/app/cart/useCart.ts +1 -0
- package/app/components/catalog/product/ProductAccordion/ProductAccordion.vue +39 -0
- package/app/components/catalog/product/ProductAccordion/__tests__/ProductAccordion.spec.ts +15 -0
- package/app/components/catalog/product/ProductAccordion/types.ts +5 -0
- package/app/components/catalog/product/ProductProperties/ProductProperties.vue +50 -0
- package/app/components/catalog/product/ProductProperties/__tests__/ProductProperties.spec.ts +15 -0
- package/app/components/catalog/product/ProductProperties/types.ts +5 -0
- package/app/components/catalog/product/ProductSlider/ProductSlider.vue +28 -0
- package/app/components/catalog/product/ProductSlider/__tests__/ProductSlider.spec.ts +14 -0
- package/app/components/catalog/product/ProductSlider/types.ts +7 -0
- package/app/components/catalog/product/RecommendedProducts/RecommendedProducts.vue +12 -0
- package/app/components/catalog/product/RecommendedProducts/types.ts +5 -0
- package/app/components/catalog/product/RenderContentProductSlider/RenderContentProductSlider.vue +11 -0
- package/app/components/catalog/product/add-attribute.vue +54 -0
- package/app/components/catalog/product/add-product-type.vue +54 -0
- package/app/components/catalog/product/add-product.vue +53 -0
- package/app/components/catalog/product/add-showcase.vue +52 -0
- package/app/components/catalog/product/add-station.vue +54 -0
- package/app/components/catalog/product/bestsellers.vue +57 -0
- package/app/components/catalog/product/bidding.vue +93 -0
- package/app/components/catalog/product/colorOptions.vue +58 -0
- package/app/components/catalog/product/deals.vue +46 -0
- package/app/components/catalog/product/exclusives.vue +56 -0
- package/app/components/catalog/product/featuredproducts.vue +57 -0
- package/app/components/catalog/product/giftCard.vue +63 -0
- package/app/components/catalog/product/latestproducts.vue +46 -0
- package/app/components/catalog/product/productCard.vue +105 -0
- package/app/components/catalog/product/productCompare.vue +60 -0
- package/app/components/catalog/product/productCompareTable.vue +441 -0
- package/app/components/catalog/product/productDetails.vue +126 -0
- package/app/components/catalog/product/productFaqs.vue +17 -0
- package/app/components/catalog/product/productGallery.vue +16 -0
- package/app/components/catalog/product/productQty.vue +54 -0
- package/app/components/catalog/product/productReviews.vue +56 -0
- package/app/components/catalog/product/productSpecs.vue +116 -0
- package/app/components/catalog/product/radiostation.vue +36 -0
- package/app/components/catalog/product/recentlyviewed.vue +43 -0
- package/app/components/catalog/product/relatedbrands.vue +54 -0
- package/app/components/catalog/product/relatedproducts.vue +43 -0
- package/app/components/catalog/product/relatedstations.vue +40 -0
- package/app/components/catalog/product/shippingOptions.vue +41 -0
- package/app/components/catalog/product/sizeOptions.vue +42 -0
- package/app/components/catalog/product/update-attribute-set.vue +209 -0
- package/app/components/catalog/product/update-attribute.vue +118 -0
- package/app/components/catalog/product/update-product.vue +372 -0
- package/app/components/catalog/product/update-showcase.vue +153 -0
- package/app/components/catalog/shops/relatedstores.vue +37 -0
- package/app/components/catalog/shops/restaurant.vue +66 -0
- package/app/components/catalog/shops/stores.vue +44 -0
- package/app/components/catalog/vendor/README.md +3 -0
- package/app/components/catalog/vendor/blocks/biggestcustomers.vue +33 -0
- package/app/components/catalog/vendor/blocks/lowestselling.vue +33 -0
- package/app/components/catalog/vendor/blocks/topcategories.vue +33 -0
- package/app/components/catalog/vendor/blocks/topproducts.vue +27 -0
- package/app/components/catalog/vendor/pages/attributes.vue +43 -0
- package/app/components/catalog/vendor/pages/commissions.vue +43 -0
- package/app/components/catalog/vendor/pages/crm.vue +67 -0
- package/app/components/catalog/vendor/pages/dashboard.vue +46 -0
- package/app/components/catalog/vendor/pages/emails.vue +43 -0
- package/app/components/catalog/vendor/pages/enquiries.vue +43 -0
- package/app/components/catalog/vendor/pages/invoices.vue +43 -0
- package/app/components/catalog/vendor/pages/orders.vue +68 -0
- package/app/components/catalog/vendor/pages/products.vue +55 -0
- package/app/components/catalog/vendor/pages/reviews.vue +48 -0
- package/app/components/catalog/vendor/pages/shipments.vue +43 -0
- package/app/components/catalog/vendor/pages/stores.vue +43 -0
- package/app/components/categories/chart/[id].vue +200 -0
- package/app/components/categories/chart/add-chart.vue +142 -0
- package/app/components/categories/chart/chart.vue +82 -0
- package/app/components/categories/chart/monthlyChart.vue +46 -0
- package/app/components/categories/chart/weeklyChart.vue +46 -0
- package/app/components/categories/chart/yearlyChart.vue +46 -0
- package/app/components/categories/charts.vue +118 -0
- package/app/components/categories/deals.vue +101 -0
- package/app/components/categories/eats.vue +49 -0
- package/app/components/categories/restaurants.vue +26 -0
- package/app/components/categories/station/[id].vue +72 -0
- package/app/components/categories/stations.vue +124 -0
- package/app/components/categories/time/time.vue +63 -0
- package/app/components/categories/travel.vue +75 -0
- package/app/components/categories/weather/weather.vue +44 -0
- package/app/components/content/blocks/breadcrumbs.vue +0 -0
- package/app/components/content/blocks/currencySwitcher.vue +0 -0
- package/app/components/content/blocks/languageSwitcher.vue +0 -0
- package/app/components/content/blocks/videoproduct.vue +9 -0
- package/app/components/content/pages/checkout.vue +118 -0
- package/app/components/content/pages/meeoviGlobal.vue +68 -0
- package/app/components/content/pages/pickup-locations.vue +238 -0
- package/app/components/content/pages/showcases.vue +90 -0
- package/app/components/content/pages/success.vue +60 -0
- package/app/components/marketing/add-brand.vue +54 -0
- package/app/components/marketing/add-incentive.vue +54 -0
- package/app/components/marketing/promotions/giftcards.vue +102 -0
- package/app/components/marketing/promotions/subscriptions.vue +121 -0
- package/app/components/marketing/update-incentive.vue +326 -0
- package/app/components/menus/lowernav.vue +78 -0
- package/app/components/partials/LocaleSelector.vue +24 -0
- package/app/components/partials/ShoppingCart.vue +128 -0
- package/app/components/partials/StripePayment.vue +149 -0
- package/app/components/partials/addToCartBtn.vue +40 -0
- package/app/components/partials/cartItem.vue +124 -0
- package/app/components/partials/checkoutButton.vue +44 -0
- package/app/components/partials/compareBtn.vue +68 -0
- package/app/components/partials/ratings.vue +13 -0
- package/app/components/partials/store/CurrencySelector.vue +133 -0
- package/app/components/partials/store/StoreSwitcher.vue +13 -0
- package/app/components/placeholders/Comments.vue +15 -0
- package/app/components/placeholders/CreateListBtn.vue +7 -0
- package/app/components/placeholders/Event.vue +9 -0
- package/app/components/placeholders/ListShowcases.vue +9 -0
- package/app/components/placeholders/Short.vue +9 -0
- package/app/components/placeholders/Space.vue +9 -0
- package/app/components/placeholders/Tag.vue +7 -0
- package/app/components/related/brandCard.vue +41 -0
- package/app/components/related/incentiveCard.vue +44 -0
- package/app/components/related/invoiceCard.vue +43 -0
- package/app/components/related/orderCard.vue +43 -0
- package/app/components/related/relatedproducts.vue +17 -0
- package/app/components/sales/CartPageContent/CartPageContent.vue +37 -0
- package/app/components/sales/CheckoutAddress/CheckoutAddress.vue +50 -0
- package/app/components/sales/CheckoutAddress/__tests__/CheckoutAddress.spec.ts +16 -0
- package/app/components/sales/CheckoutAddress/types.ts +16 -0
- package/app/components/sales/CheckoutPayment/CheckoutPayment.vue +68 -0
- package/app/components/sales/CheckoutPayment/__tests__/CheckoutPayment.spec.ts +14 -0
- package/app/components/sales/CheckoutPayment/types.ts +12 -0
- package/app/components/sales/OrderSummary/OrderSummary.vue +57 -0
- package/app/components/sales/OrderSummary/__tests__/ContactInformation.spec.ts +52 -0
- package/app/components/sales/OrderSummary/types.ts +5 -0
- package/app/components/sales/incentives.vue +223 -0
- package/app/components/sales/invoices.vue +107 -0
- package/app/components/sales/orders.vue +378 -0
- package/app/components/sales/shipments.vue +65 -0
- package/app/components/sales/transactions.vue +109 -0
- package/app/components/shop/add-shop.vue +54 -0
- package/app/components/shop/cart/cartItem.vue +182 -0
- package/app/components/shop/cart/checkout.vue +415 -0
- package/app/components/shop/checkout/StripeCardElement.vue +206 -0
- package/app/components/shop/checkout/StripeCheckout.vue +49 -0
- package/app/components/shop/checkout/addressBilling.vue +263 -0
- package/app/components/shop/checkout/addressShipping.vue +175 -0
- package/app/components/shop/checkout/cart/ProductItem.vue +56 -0
- package/app/components/shop/checkout/cart/PromotionItem.vue +53 -0
- package/app/composables/_types.ts +18 -0
- package/app/composables/adapters/abstract/cartAdapter.ts +0 -0
- package/app/composables/adapters/abstract/categoryAdapter.ts +0 -0
- package/app/composables/adapters/abstract/customerAdapter.ts +0 -0
- package/app/composables/adapters/abstract/inventoryAdapter.ts +0 -0
- package/app/composables/adapters/abstract/orderAdapter.ts +0 -0
- package/app/composables/adapters/abstract/productAdapter.ts +7 -0
- package/app/composables/cart/registry.ts +20 -0
- package/app/composables/cart/types.ts +18 -0
- package/app/composables/cart/useCart.ts +15 -0
- package/app/composables/config.ts +19 -0
- package/app/composables/defs/apiDefinitions.ts +55 -0
- package/app/composables/defs/extension.feature +40 -0
- package/app/composables/defs/extension.mocks.ts +39 -0
- package/app/composables/defs/extension.test.ts +280 -0
- package/app/composables/defs/extension.ts +236 -0
- package/app/composables/defs/index.ts +3 -0
- package/app/composables/defs/types.ts +136 -0
- package/app/composables/domain/cart.ts +0 -0
- package/app/composables/domain/category.ts +0 -0
- package/app/composables/domain/order.ts +0 -0
- package/app/composables/domain/price.ts +0 -0
- package/app/composables/domain/product.ts +10 -0
- package/app/composables/domain/reward.ts +0 -0
- package/app/composables/domain/transactions.ts +0 -0
- package/app/composables/featured-products.ts +20 -0
- package/app/composables/helpers/contextualizedNormalizers.feature +14 -0
- package/app/composables/helpers/contextualizedNormalizers.test.ts +85 -0
- package/app/composables/helpers/contextualizedNormalizers.ts +20 -0
- package/app/composables/helpers/index.ts +1 -0
- package/app/composables/index.ts +6 -0
- package/app/composables/methods/auth.ts +83 -0
- package/app/composables/methods/cart.ts +119 -0
- package/app/composables/methods/category.ts +27 -0
- package/app/composables/methods/checkout.ts +54 -0
- package/app/composables/methods/customer.ts +52 -0
- package/app/composables/methods/helpers.ts +5 -0
- package/app/composables/methods/index.ts +75 -0
- package/app/composables/methods/order.ts +39 -0
- package/app/composables/methods/product.ts +95 -0
- package/app/composables/methods/settings.ts +16 -0
- package/app/composables/models/cart.ts +95 -0
- package/app/composables/models/category.ts +13 -0
- package/app/composables/models/checkout.ts +17 -0
- package/app/composables/models/customer.ts +16 -0
- package/app/composables/models/facets.ts +25 -0
- package/app/composables/models/index.ts +94 -0
- package/app/composables/models/order.ts +43 -0
- package/app/composables/models/product.ts +73 -0
- package/app/composables/models/shared.ts +75 -0
- package/app/composables/orders.ts +69 -0
- package/app/composables/products/registry.ts +20 -0
- package/app/composables/products/types.ts +13 -0
- package/app/composables/products/useEvents.ts +0 -0
- package/app/composables/products/useGiftCards.ts +0 -0
- package/app/composables/products/useProducts.ts +12 -0
- package/app/composables/products/useSubscriptions.ts +0 -0
- package/app/composables/products.ts +30 -0
- package/app/composables/registry.ts +21 -0
- package/app/composables/useAuth.ts +43 -0
- package/app/composables/useBreakpoints/index.ts +1 -0
- package/app/composables/useBreakpoints/useBreakpoints.ts +28 -0
- package/app/composables/useCache.ts +38 -0
- package/app/composables/useCart/__tests__/useCart.spec.ts +11 -0
- package/app/composables/useCart/index.ts +1 -0
- package/app/composables/useCart/types.ts +17 -0
- package/app/composables/useCart/useCart.ts +46 -0
- package/app/composables/useCartShippingMethods/__tests__/useCartShippingMethods.spec.ts +11 -0
- package/app/composables/useCartShippingMethods/index.ts +1 -0
- package/app/composables/useCartShippingMethods/types.ts +17 -0
- package/app/composables/useCartShippingMethods/useCartShippingMethods.ts +47 -0
- package/app/composables/useCatalog.ts +64 -0
- package/app/composables/useContent.ts +57 -0
- package/app/composables/useCustomer/__tests__/useCustomer.spec.ts +25 -0
- package/app/composables/useCustomer/index.ts +2 -0
- package/app/composables/useCustomer/types.ts +17 -0
- package/app/composables/useCustomer/useCustomer.ts +40 -0
- package/app/composables/useCustomerAddress/__tests__/useCustomerAddress.spec.ts +11 -0
- package/app/composables/useCustomerAddress/index.ts +2 -0
- package/app/composables/useCustomerAddress/types.ts +17 -0
- package/app/composables/useCustomerAddress/useCustomerAddress.ts +55 -0
- package/app/composables/useCustomerOrder/__tests__/useCustomerOrder.spec.ts +11 -0
- package/app/composables/useCustomerOrder/adress.ts +10 -0
- package/app/composables/useCustomerOrder/index.ts +2 -0
- package/app/composables/useCustomerOrder/product.ts +37 -0
- package/app/composables/useCustomerOrder/types.ts +40 -0
- package/app/composables/useCustomerOrder/useCustomerOrder.ts +63 -0
- package/app/composables/useCustomerOrders/__tests__/useCustomerOrders.spec.ts +11 -0
- package/app/composables/useCustomerOrders/index.ts +2 -0
- package/app/composables/useCustomerOrders/types.ts +20 -0
- package/app/composables/useCustomerOrders/useCustomerOrders.ts +56 -0
- package/app/composables/useCustomerReturns/__tests__/useCustomerReturns.spec.ts +11 -0
- package/app/composables/useCustomerReturns/index.ts +2 -0
- package/app/composables/useCustomerReturns/types.ts +17 -0
- package/app/composables/useCustomerReturns/useCustomerReturns.ts +41 -0
- package/app/composables/useHandleError/index.ts +1 -0
- package/app/composables/useHandleError/types.ts +11 -0
- package/app/composables/useHandleError/useHandleError.ts +27 -0
- package/app/composables/useInventory.ts +21 -0
- package/app/composables/useLoading.ts +21 -0
- package/app/composables/useNotification.ts +21 -0
- package/app/composables/usePageTitle.ts +16 -0
- package/app/composables/useProduct/index.ts +2 -0
- package/app/composables/useProduct/types.ts +17 -0
- package/app/composables/useProduct/useProduct.ts +42 -0
- package/app/composables/useProductAttribute/__tests__/useProduct.mock.ts +31 -0
- package/app/composables/useProductAttribute/__tests__/useProductAttribute.spec.ts +14 -0
- package/app/composables/useProductAttribute/index.ts +1 -0
- package/app/composables/useProductAttribute/useProductAttribute.ts +37 -0
- package/app/composables/useProductRecommended/__tests__/useProductRecommended.spec.ts +12 -0
- package/app/composables/useProductRecommended/index.ts +1 -0
- package/app/composables/useProductRecommended/types.ts +17 -0
- package/app/composables/useProductRecommended/useProductRecommended.ts +43 -0
- package/app/composables/useProductReviews/__tests__/productReviews.mock.ts +20 -0
- package/app/composables/useProductReviews/__tests__/useProductReviews.spec.ts +22 -0
- package/app/composables/useProductReviews/index.ts +2 -0
- package/app/composables/useProductReviews/types.ts +17 -0
- package/app/composables/useProductReviews/useProductReviews.ts +46 -0
- package/app/composables/useProducts/__tests__/useProducts.spec.ts +11 -0
- package/app/composables/useProducts/types.ts +22 -0
- package/app/composables/useProducts/useProducts.ts +41 -0
- package/app/composables/useTax.ts +17 -0
- package/app/composables/validationRules/index.ts +1 -0
- package/app/composables/validationRules/password.feature +67 -0
- package/app/composables/validationRules/password.test.ts +89 -0
- package/app/composables/validationRules/password.ts +25 -0
- package/app/composables/vendors/index.ts +0 -0
- package/app/composables/vendors/registry.ts +0 -0
- package/app/composables/vendors/useAffiliates.ts +0 -0
- package/app/composables/vendors/useCommission.ts +0 -0
- package/app/modules/vue-head/composables/useHead.ts +22 -0
- package/app/pages/brand/[...slug].vue +92 -0
- package/app/pages/brands.vue +90 -0
- package/app/pages/cart.vue +142 -0
- package/app/pages/compare.vue +166 -0
- package/app/pages/departments/[...slug].vue +385 -0
- package/app/pages/departments/category/[...slug].vue +135 -0
- package/app/pages/incentive/[...id].vue +66 -0
- package/app/pages/invoice/[id].vue +309 -0
- package/app/pages/order/[id].vue +327 -0
- package/app/pages/product/[...id].vue +309 -0
- package/app/pages/product/showcases/index.vue +86 -0
- package/app/pages/shipment/[...id].vue +176 -0
- package/app/pages/shop/[...slug].vue +158 -0
- package/app/pages/shops.vue +76 -0
- package/app/pages/subscription/[...id].vue +147 -0
- package/app/pages/transaction/[...id].vue +74 -0
- package/app/services/magento.ts +49 -0
- package/app/stores/cart.ts +218 -0
- package/app/stores/cartStore.ts +316 -0
- package/app/stores/checkout.ts +19 -0
- package/app/stores/compare.ts +65 -0
- package/app/stores/currency.js +29 -0
- package/app/stores/digital-products.js +11 -0
- package/app/stores/index.js +0 -0
- package/app/stores/orders.ts +161 -0
- package/app/stores/product.ts +26 -0
- package/app/stores/productList.ts +0 -0
- package/app/stores/productListInfo.ts +0 -0
- package/app/stores/products.ts +116 -0
- package/app/stores/recentlyViewedProducts.ts +0 -0
- package/app/stores/review.ts +25 -0
- package/app/stores/storeInPickUp.ts +22 -0
- package/app/stores/user.ts +20 -0
- package/app/stores/wishlist.ts +19 -0
- package/app/types/Order.type.ts +181 -0
- package/app/types/checkout.ts +6 -0
- package/app/types/imports.d.ts +28 -0
- package/app/types/index.ts +291 -0
- package/app/types/nuxt-imports.d.ts +5 -0
- package/app/types/product-state.ts +8 -0
- package/app/types/product.ts +22 -0
- package/app/types/review-state.ts +7 -0
- package/app/types/review.ts +2 -0
- package/app/types/storeInPickUp.ts +2 -0
- package/app/types/storePickup-state.ts +5 -0
- package/app/types/vue-globals.d.ts +9 -0
- package/app/types/wishlist-state.ts +5 -0
- package/app/types/wishlist.ts +2 -0
- package/app/utils/client.ts +26 -0
- package/app/utils/countryList.ts +14 -0
- package/app/utils/currency.js +56 -0
- package/app/utils/errorHandler.ts +16 -0
- package/app/utils/glossary.ts +0 -0
- package/app/utils/importExport.ts +0 -0
- package/app/utils/index.ts +53 -0
- package/app/utils/normalizer.ts +23 -0
- package/app/utils/normalizers/magento.ts +29 -0
- package/app/utils/normalizers/shopify.ts +29 -0
- package/app/utils/print.ts +0 -0
- package/app/utils/shopThemes.ts +0 -0
- package/app/utils/statistics.ts +0 -0
- package/app/utils/stock.ts +0 -0
- package/app/utils/stripe.ts +16 -0
- package/app/utils/taxation.ts +0 -0
- package/app/utils/tellFriends.ts +0 -0
- package/composables/useAuth.ts +2 -0
- package/composables/useCache.ts +2 -0
- package/composables/useInventory.ts +2 -0
- package/composables/useLoading.ts +2 -0
- package/composables/useNotification.ts +2 -0
- package/composables/useTax.ts +2 -0
- package/graphql/queries-mutations_subscriptions/types/ProductCompare.type.ts +20 -0
- package/package.json +5 -12
- package/services/magento.ts +2 -0
- package/tsconfig.json +36 -0
- package/types/checkout.d.ts +6 -0
- package/types/checkout.ts +6 -0
- package/types/nuxt-imports.d.ts +5 -0
- package/types/product.d.ts +5 -0
- package/types/product.ts +3 -0
- package/types/review.d.ts +1 -0
- package/types/review.ts +1 -0
- package/types/storeInPickUp.d.ts +1 -0
- package/types/storeInPickUp.ts +1 -0
- package/types/wishlist.d.ts +1 -0
- package/types/wishlist.ts +1 -0
- package/utils/errorHandler.ts +2 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
declare module '#imports' {
|
|
2
|
+
export function useRuntimeConfig(): any
|
|
3
|
+
export function useNuxtApp(): any
|
|
4
|
+
export function useAppConfig(): any
|
|
5
|
+
export function useOrders(): any
|
|
6
|
+
export function useReturns(): any
|
|
7
|
+
export function useTransactions(): any
|
|
8
|
+
export function useInvoices(): any
|
|
9
|
+
export function useCreditMemos(): any
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare module 'nuxt/app' {
|
|
13
|
+
export function useAppConfig(): any
|
|
14
|
+
export function useAsyncData<T = any>(keyOrHandler: string | null | (() => Promise<T> | T), handler?: (...args: any[]) => Promise<T> | T): Promise<{ data: { value: T }, error: { value: any } }>
|
|
15
|
+
export function useState<T = any>(key: string, init?: T | (() => T)): { value: T }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Provide globals for files that call Nuxt auto-imports without module import
|
|
19
|
+
declare function useNuxtApp(): any
|
|
20
|
+
declare function useRuntimeConfig(): any
|
|
21
|
+
declare function useAppConfig(): any
|
|
22
|
+
|
|
23
|
+
// Order-related auto-imports used without explicit imports in stores
|
|
24
|
+
declare function useOrders(): any
|
|
25
|
+
declare function useReturns(): any
|
|
26
|
+
declare function useTransactions(): any
|
|
27
|
+
declare function useInvoices(): any
|
|
28
|
+
declare function useCreditMemos(): any
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
export * from '~/types/checkout'
|
|
2
|
+
export * from '~/types/product'
|
|
3
|
+
export * from '~/types/review'
|
|
4
|
+
export * from '~/types/storeInPickUp'
|
|
5
|
+
export * from '~/types/wishlist'
|
|
6
|
+
// types/index.ts - Main type definitions for commerce layer
|
|
7
|
+
|
|
8
|
+
// Re-export Order types
|
|
9
|
+
export * from './Order.type'
|
|
10
|
+
export type Money = string | number;
|
|
11
|
+
|
|
12
|
+
export interface VariationNode {
|
|
13
|
+
databaseId: number;
|
|
14
|
+
salePrice: Money;
|
|
15
|
+
regularPrice: Money;
|
|
16
|
+
stockQuantity?: number;
|
|
17
|
+
image?: { sourceUrl: string };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface Variation {
|
|
21
|
+
node: VariationNode;
|
|
22
|
+
attributes: Array<{ value: string }>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ProductNode {
|
|
26
|
+
sku: string;
|
|
27
|
+
slug: string;
|
|
28
|
+
name: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Product {
|
|
32
|
+
id: string;
|
|
33
|
+
sku?: string;
|
|
34
|
+
slug?: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
images?: Array<{ sourceUrl?: string }>;
|
|
38
|
+
price?: number;
|
|
39
|
+
regularPrice?: number;
|
|
40
|
+
salePrice?: number;
|
|
41
|
+
sale_price?: number;
|
|
42
|
+
attributes?: Array<{ name: string; value: string }>;
|
|
43
|
+
variations?: ProductVariant[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ProductVariant {
|
|
47
|
+
id: string;
|
|
48
|
+
sku?: string;
|
|
49
|
+
price?: number;
|
|
50
|
+
regularPrice?: number;
|
|
51
|
+
salePrice?: number;
|
|
52
|
+
stockQuantity?: number;
|
|
53
|
+
image?: { sourceUrl?: string };
|
|
54
|
+
attributes?: Array<{ name: string; value: string }>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface CartItemNode {
|
|
58
|
+
key: string;
|
|
59
|
+
quantity: number;
|
|
60
|
+
product: { node: ProductNode };
|
|
61
|
+
variation: Variation;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface AddToCartResponse {
|
|
65
|
+
addToCart: { cartItem: CartItemNode };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type AddBtnStatus = 'add' | 'loading' | 'added';
|
|
69
|
+
|
|
70
|
+
export type RemoveBtnStatus = 'remove' | 'loading';
|
|
71
|
+
|
|
72
|
+
// Customer types
|
|
73
|
+
export interface Customer {
|
|
74
|
+
id: string
|
|
75
|
+
first_name: string
|
|
76
|
+
last_name: string
|
|
77
|
+
email: string
|
|
78
|
+
phone?: string
|
|
79
|
+
date_of_birth?: string
|
|
80
|
+
preferred_currency?: string
|
|
81
|
+
company_id?: string
|
|
82
|
+
created_at: string
|
|
83
|
+
updated_at: string
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Company types (B2B)
|
|
87
|
+
export interface Company {
|
|
88
|
+
id: string
|
|
89
|
+
name: string
|
|
90
|
+
email: string
|
|
91
|
+
phone?: string
|
|
92
|
+
tax_id?: string
|
|
93
|
+
industry?: string
|
|
94
|
+
owner_id: string
|
|
95
|
+
status: 'active' | 'inactive' | 'pending'
|
|
96
|
+
created_at: string
|
|
97
|
+
updated_at: string
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Return types
|
|
101
|
+
export interface Refund {
|
|
102
|
+
id: string
|
|
103
|
+
refund_number?: string
|
|
104
|
+
order_id?: string
|
|
105
|
+
return_id?: string
|
|
106
|
+
transaction_id?: string
|
|
107
|
+
amount: number
|
|
108
|
+
currency: string
|
|
109
|
+
reason?: string
|
|
110
|
+
status: 'pending' | 'processed' | 'refunded' | 'failed' | 'cancelled'
|
|
111
|
+
metadata?: Record<string, any>
|
|
112
|
+
created_at: string
|
|
113
|
+
updated_at: string
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface Return {
|
|
117
|
+
id: string
|
|
118
|
+
return_number: string
|
|
119
|
+
order_id: string
|
|
120
|
+
customer_id: string
|
|
121
|
+
status: 'requested' | 'approved' | 'rejected' | 'processed' | 'refunded'
|
|
122
|
+
reason: string
|
|
123
|
+
description?: string
|
|
124
|
+
return_items: ReturnItem[]
|
|
125
|
+
refunds?: Refund[]
|
|
126
|
+
created_at: string
|
|
127
|
+
updated_at: string
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface ReturnItem {
|
|
131
|
+
id: string
|
|
132
|
+
return_id: string
|
|
133
|
+
order_item_id: string
|
|
134
|
+
product_id: string
|
|
135
|
+
quantity: number
|
|
136
|
+
reason: string
|
|
137
|
+
condition?: 'new' | 'used' | 'damaged'
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Transaction types
|
|
141
|
+
export interface Transaction {
|
|
142
|
+
id: string
|
|
143
|
+
transaction_id: string
|
|
144
|
+
order_id?: string
|
|
145
|
+
customer_id?: string
|
|
146
|
+
type: 'payment' | 'refund' | 'authorization' | 'capture'
|
|
147
|
+
amount: number
|
|
148
|
+
currency: string
|
|
149
|
+
status: 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled'
|
|
150
|
+
payment_method: string
|
|
151
|
+
gateway_response?: Record<string, any>
|
|
152
|
+
created_at: string
|
|
153
|
+
updated_at: string
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Invoice types
|
|
157
|
+
export interface Invoice {
|
|
158
|
+
id: string
|
|
159
|
+
invoice_number: string
|
|
160
|
+
order_id: string
|
|
161
|
+
customer_id: string
|
|
162
|
+
amount: number
|
|
163
|
+
tax_amount: number
|
|
164
|
+
currency: string
|
|
165
|
+
due_date: string
|
|
166
|
+
status: 'draft' | 'sent' | 'paid' | 'overdue' | 'cancelled'
|
|
167
|
+
invoice_items: InvoiceItem[]
|
|
168
|
+
payments?: Payment[]
|
|
169
|
+
created_at: string
|
|
170
|
+
updated_at: string
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface InvoiceItem {
|
|
174
|
+
id: string
|
|
175
|
+
invoice_id: string
|
|
176
|
+
product_id: string
|
|
177
|
+
description: string
|
|
178
|
+
quantity: number
|
|
179
|
+
unit_price: number
|
|
180
|
+
total: number
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface Payment {
|
|
184
|
+
id: string
|
|
185
|
+
payment_number?: string
|
|
186
|
+
invoice_id?: string
|
|
187
|
+
order_id?: string
|
|
188
|
+
customer_id?: string
|
|
189
|
+
amount: number
|
|
190
|
+
currency: string
|
|
191
|
+
method: string
|
|
192
|
+
transaction_id?: string
|
|
193
|
+
status: 'pending' | 'completed' | 'failed' | 'refunded' | 'cancelled'
|
|
194
|
+
gateway_response?: Record<string, any>
|
|
195
|
+
created_at: string
|
|
196
|
+
updated_at: string
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Credit Memo types
|
|
200
|
+
export interface CreditMemo {
|
|
201
|
+
id: string
|
|
202
|
+
memo_number: string
|
|
203
|
+
order_id: string
|
|
204
|
+
return_id?: string
|
|
205
|
+
customer_id: string
|
|
206
|
+
amount: number
|
|
207
|
+
currency: string
|
|
208
|
+
reason: string
|
|
209
|
+
status: 'pending' | 'approved' | 'processed' | 'refunded' | 'cancelled'
|
|
210
|
+
memo_items: CreditMemoItem[]
|
|
211
|
+
created_at: string
|
|
212
|
+
updated_at: string
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export interface CreditMemoItem {
|
|
216
|
+
id: string
|
|
217
|
+
memo_id: string
|
|
218
|
+
product_id: string
|
|
219
|
+
description: string
|
|
220
|
+
quantity: number
|
|
221
|
+
unit_price: number
|
|
222
|
+
total: number
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Cart types
|
|
226
|
+
export interface Cart {
|
|
227
|
+
id: string
|
|
228
|
+
customer_id?: string
|
|
229
|
+
session_id?: string
|
|
230
|
+
items: CartItem[]
|
|
231
|
+
subtotal: number
|
|
232
|
+
tax_amount: number
|
|
233
|
+
shipping_amount: number
|
|
234
|
+
discount_amount: number
|
|
235
|
+
total: number
|
|
236
|
+
currency: string
|
|
237
|
+
coupon_code?: string
|
|
238
|
+
created_at: string
|
|
239
|
+
updated_at: string
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export interface CartItem {
|
|
243
|
+
id: string
|
|
244
|
+
cart_id: string
|
|
245
|
+
product_id: string
|
|
246
|
+
variant_id?: string
|
|
247
|
+
quantity: number
|
|
248
|
+
price: number
|
|
249
|
+
total: number
|
|
250
|
+
product?: Product
|
|
251
|
+
variant?: ProductVariant
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Coupon types
|
|
255
|
+
export interface Coupon {
|
|
256
|
+
id: string
|
|
257
|
+
code: string
|
|
258
|
+
name: string
|
|
259
|
+
description?: string
|
|
260
|
+
discount_type: 'percentage' | 'fixed_amount'
|
|
261
|
+
discount_value: number
|
|
262
|
+
minimum_amount?: number
|
|
263
|
+
maximum_discount?: number
|
|
264
|
+
usage_limit?: number
|
|
265
|
+
usage_count: number
|
|
266
|
+
usage_limit_per_customer?: number
|
|
267
|
+
valid_from?: string
|
|
268
|
+
valid_until?: string
|
|
269
|
+
status: 'active' | 'inactive' | 'expired'
|
|
270
|
+
created_at: string
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Common utility types
|
|
274
|
+
export interface PaginationMeta {
|
|
275
|
+
current_page: number
|
|
276
|
+
per_page: number
|
|
277
|
+
total: number
|
|
278
|
+
total_pages: number
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface ApiResponse<T> {
|
|
282
|
+
data: T
|
|
283
|
+
meta?: PaginationMeta
|
|
284
|
+
message?: string
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface ApiError {
|
|
288
|
+
message: string
|
|
289
|
+
code?: string
|
|
290
|
+
details?: Record<string, any>
|
|
291
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface Price {
|
|
2
|
+
value: number
|
|
3
|
+
currency: string
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface ProductVariant {
|
|
7
|
+
id: string
|
|
8
|
+
sku?: string
|
|
9
|
+
price?: Price
|
|
10
|
+
attributes?: Record<string, any>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface SimpleProduct {
|
|
14
|
+
id: string
|
|
15
|
+
title?: string
|
|
16
|
+
description?: string
|
|
17
|
+
images?: string[]
|
|
18
|
+
price?: Price
|
|
19
|
+
variants?: ProductVariant[]
|
|
20
|
+
}
|
|
21
|
+
export * from './index'
|
|
22
|
+
export type { ProductState } from './product-state'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Minimal ambient declarations for Vue/Pinia globals used in the commerce layer
|
|
2
|
+
declare function ref<T = any>(value?: T): any
|
|
3
|
+
declare function computed<T = any>(fn: () => T): any
|
|
4
|
+
declare function readonly<T = any>(v: T): T
|
|
5
|
+
declare function reactive<T = any>(v: T): T
|
|
6
|
+
declare function watchEffect(fn: () => void): void
|
|
7
|
+
|
|
8
|
+
// Pinia-ish defineStore (layers may call defineStore during build time)
|
|
9
|
+
declare function defineStore(id: string, setup: any): any
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as CommercePkg from '#imports';
|
|
2
|
+
import { sdk } from '@meeovi/sdk';
|
|
3
|
+
|
|
4
|
+
const CommerceAny: any = CommercePkg as any;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns a commerce client. Prefer `@meeovi/commerce` client creation APIs
|
|
8
|
+
* when available, otherwise fall back to `sdk.commerce`.
|
|
9
|
+
*/
|
|
10
|
+
export function getCommerceClient(provider?: string, providerConfig?: any) {
|
|
11
|
+
try {
|
|
12
|
+
if (typeof CommerceAny.createClient === 'function') {
|
|
13
|
+
return CommerceAny.createClient(provider, providerConfig);
|
|
14
|
+
}
|
|
15
|
+
if (typeof CommerceAny.init === 'function') {
|
|
16
|
+
return CommerceAny.init(providerConfig);
|
|
17
|
+
}
|
|
18
|
+
} catch (e) {
|
|
19
|
+
// swallow and fallback to sdk
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// fallback: return the SDK's commerce helper (already used in many composables)
|
|
23
|
+
return sdk.commerce;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default getCommerceClient;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// ISO 3166-1 country codes and names (short sample, extend as needed)
|
|
2
|
+
export default [
|
|
3
|
+
{ code: 'US', name: 'United States' },
|
|
4
|
+
{ code: 'CA', name: 'Canada' },
|
|
5
|
+
{ code: 'GB', name: 'United Kingdom' },
|
|
6
|
+
{ code: 'DE', name: 'Germany' },
|
|
7
|
+
{ code: 'FR', name: 'France' },
|
|
8
|
+
{ code: 'IT', name: 'Italy' },
|
|
9
|
+
{ code: 'ES', name: 'Spain' },
|
|
10
|
+
{ code: 'AU', name: 'Australia' },
|
|
11
|
+
{ code: 'JP', name: 'Japan' },
|
|
12
|
+
{ code: 'CN', name: 'China' },
|
|
13
|
+
// ...add more as needed
|
|
14
|
+
];
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format a price amount according to the given currency
|
|
3
|
+
* @param {number} amount - The price amount to format
|
|
4
|
+
* @param {string} currency - The currency code (e.g., 'USD', 'EUR')
|
|
5
|
+
* @param {Object} exchangeRates - Object containing exchange rates
|
|
6
|
+
* @returns {string} Formatted price string
|
|
7
|
+
*/
|
|
8
|
+
export const formatPrice = (amount, currency, exchangeRates) => {
|
|
9
|
+
if (!amount || !currency) return ''
|
|
10
|
+
|
|
11
|
+
const rate = exchangeRates[currency] || 1
|
|
12
|
+
const convertedAmount = amount * rate
|
|
13
|
+
|
|
14
|
+
return new Intl.NumberFormat(undefined, {
|
|
15
|
+
style: 'currency',
|
|
16
|
+
currency: currency
|
|
17
|
+
}).format(convertedAmount)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Convert price from one currency to another
|
|
22
|
+
* @param {number} amount - The price amount to convert
|
|
23
|
+
* @param {string} fromCurrency - Source currency code
|
|
24
|
+
* @param {string} toCurrency - Target currency code
|
|
25
|
+
* @param {Object} exchangeRates - Object containing exchange rates
|
|
26
|
+
* @returns {number} Converted price amount
|
|
27
|
+
*/
|
|
28
|
+
export const convertPrice = (amount, fromCurrency, toCurrency, exchangeRates) => {
|
|
29
|
+
if (!amount || !fromCurrency || !toCurrency || !exchangeRates) return amount
|
|
30
|
+
|
|
31
|
+
const fromRate = exchangeRates[fromCurrency] || 1
|
|
32
|
+
const toRate = exchangeRates[toCurrency] || 1
|
|
33
|
+
|
|
34
|
+
return (amount * toRate) / fromRate
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Get currency symbol for a currency code
|
|
39
|
+
* @param {string} code - Currency code
|
|
40
|
+
* @returns {string} Currency symbol
|
|
41
|
+
*/
|
|
42
|
+
export const getCurrencySymbol = (code) => {
|
|
43
|
+
const symbols = {
|
|
44
|
+
USD: '$',
|
|
45
|
+
EUR: '€',
|
|
46
|
+
GBP: '£',
|
|
47
|
+
JPY: '¥',
|
|
48
|
+
AUD: 'A$',
|
|
49
|
+
CAD: 'C$',
|
|
50
|
+
CHF: 'CHF',
|
|
51
|
+
CNY: '¥',
|
|
52
|
+
INR: '₹',
|
|
53
|
+
// Add more currency symbols as needed
|
|
54
|
+
}
|
|
55
|
+
return symbols[code] || code
|
|
56
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const errorHandler = {
|
|
2
|
+
handle(err: unknown) {
|
|
3
|
+
// Structured handling: log and optionally rethrow
|
|
4
|
+
try {
|
|
5
|
+
if (err instanceof Error) {
|
|
6
|
+
console.error(`[Commerce][Error] ${err.name}: ${err.message}`)
|
|
7
|
+
} else {
|
|
8
|
+
console.error('[Commerce][Error]', err)
|
|
9
|
+
}
|
|
10
|
+
} catch (e) {
|
|
11
|
+
console.error('Error while handling error', e)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default errorHandler
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { NormalizerRegistry, CommerceNormalizer } from './normalizer';
|
|
2
|
+
|
|
3
|
+
// Keep imports loose because host `@meeovi/commerce` implementations may vary
|
|
4
|
+
import * as CommercePkg from '#imports';
|
|
5
|
+
const CommerceAny: any = CommercePkg as any;
|
|
6
|
+
|
|
7
|
+
export type Provider = string;
|
|
8
|
+
|
|
9
|
+
export interface CommerceLayerConfig {
|
|
10
|
+
provider: Provider;
|
|
11
|
+
providerConfig?: Record<string, any>;
|
|
12
|
+
normalizer?: CommerceNormalizer;
|
|
13
|
+
registry?: NormalizerRegistry;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function createCommerceLayer(config: CommerceLayerConfig) {
|
|
17
|
+
const registry = config.registry ?? new NormalizerRegistry();
|
|
18
|
+
const normalizer = config.normalizer ?? registry.get(config.provider);
|
|
19
|
+
|
|
20
|
+
if (!normalizer) {
|
|
21
|
+
throw new Error('No normalizer found for provider: ' + config.provider);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Create or obtain a client from `@meeovi/commerce` in a resilient way
|
|
25
|
+
const client = ((): any => {
|
|
26
|
+
try {
|
|
27
|
+
if (typeof CommerceAny.createClient === 'function') {
|
|
28
|
+
return CommerceAny.createClient(config.provider, config.providerConfig);
|
|
29
|
+
}
|
|
30
|
+
if (typeof CommerceAny.init === 'function') {
|
|
31
|
+
return CommerceAny.init(config.providerConfig);
|
|
32
|
+
}
|
|
33
|
+
return CommerceAny;
|
|
34
|
+
} catch (e) {
|
|
35
|
+
// In production, surface useful message while avoiding leaking secrets
|
|
36
|
+
throw new Error('Failed to initialize commerce client for provider: ' + config.provider);
|
|
37
|
+
}
|
|
38
|
+
})();
|
|
39
|
+
|
|
40
|
+
async function getProduct(id: string) {
|
|
41
|
+
const raw = await (client.getProduct?.(id) ?? client.fetchProduct?.(id) ?? client.product?.(id));
|
|
42
|
+
return normalizer!.normalizeProduct(raw);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
client,
|
|
47
|
+
getProduct,
|
|
48
|
+
registry,
|
|
49
|
+
normalizer,
|
|
50
|
+
} as const;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default createCommerceLayer;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface CommerceNormalizer {
|
|
2
|
+
normalizeProduct(data: any): any;
|
|
3
|
+
normalizeCategory?(data: any): any;
|
|
4
|
+
normalizeCart?(data: any): any;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export class NormalizerRegistry {
|
|
8
|
+
private registry = new Map<string, CommerceNormalizer>();
|
|
9
|
+
|
|
10
|
+
register(name: string, normalizer: CommerceNormalizer) {
|
|
11
|
+
this.registry.set(name, normalizer);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get(name: string): CommerceNormalizer | undefined {
|
|
15
|
+
return this.registry.get(name);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
list(): string[] {
|
|
19
|
+
return Array.from(this.registry.keys());
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default NormalizerRegistry;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CommerceNormalizer } from "../normalizer";
|
|
2
|
+
|
|
3
|
+
export const magentoNormalizer: CommerceNormalizer = {
|
|
4
|
+
normalizeProduct(data: any) {
|
|
5
|
+
return {
|
|
6
|
+
id: data?.id ?? data?.sku ?? data?.item_id,
|
|
7
|
+
title: data?.name ?? data?.title,
|
|
8
|
+
price:
|
|
9
|
+
data?.price ?? data?.price_range?.minimum_price?.final_price?.value,
|
|
10
|
+
description: data?.description ?? data?.short_description,
|
|
11
|
+
images: (data?.media_gallery_entries ?? []).map((m: any) => m.file || m.url),
|
|
12
|
+
raw: data,
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
normalizeCategory(data: any) {
|
|
17
|
+
return {
|
|
18
|
+
id: data?.id,
|
|
19
|
+
name: data?.name,
|
|
20
|
+
raw: data,
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
normalizeCart(data: any) {
|
|
25
|
+
return { raw: data };
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default magentoNormalizer;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CommerceNormalizer } from "../normalizer";
|
|
2
|
+
|
|
3
|
+
export const shopifyNormalizer: CommerceNormalizer = {
|
|
4
|
+
normalizeProduct(data: any) {
|
|
5
|
+
// Shopify payloads vary depending on SDK; this maps common fields
|
|
6
|
+
return {
|
|
7
|
+
id: data?.id ?? data?.variants?.[0]?.id,
|
|
8
|
+
title: data?.title ?? data?.name,
|
|
9
|
+
price: data?.variants?.[0]?.price ?? data?.price,
|
|
10
|
+
description: data?.body_html ?? data?.description,
|
|
11
|
+
images: (data?.images ?? []).map((i: any) => i?.src || i?.url),
|
|
12
|
+
raw: data,
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
normalizeCategory(data: any) {
|
|
17
|
+
return {
|
|
18
|
+
id: data?.id,
|
|
19
|
+
name: data?.title ?? data?.name,
|
|
20
|
+
raw: data,
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
normalizeCart(data: any) {
|
|
25
|
+
return { raw: data };
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default shopifyNormalizer;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// utils/stripe.ts
|
|
2
|
+
import { loadStripe, type Stripe } from '@stripe/stripe-js';
|
|
3
|
+
|
|
4
|
+
let stripePromise: Promise<Stripe | null> | null = null;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns a Stripe instance (singleton per publishable key)
|
|
8
|
+
* @param {string} publishableKey - Your Stripe publishable key
|
|
9
|
+
* @returns {Promise<Stripe | null>}
|
|
10
|
+
*/
|
|
11
|
+
export function getStripe(publishableKey: string): Promise<Stripe | null> {
|
|
12
|
+
if (!stripePromise) {
|
|
13
|
+
stripePromise = loadStripe(publishableKey);
|
|
14
|
+
}
|
|
15
|
+
return stripePromise;
|
|
16
|
+
}
|
|
File without changes
|