@atomic-solutions/woocommerce-react 0.2.3 → 0.2.5

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/dist/index.d.cts CHANGED
@@ -2,10 +2,10 @@ import * as react from 'react';
2
2
  import react__default from 'react';
3
3
  import { WooCommerceClient } from '@atomic-solutions/woocommerce-api-client';
4
4
  export { Address, BillingAddress, Cart, CartHeadersAdapter, CartItem, Checkout, Product, ProductCategory, ProductImage, ProductParams, StoreApiOrder, addressSchema, checkoutSchema } from '@atomic-solutions/woocommerce-api-client';
5
- import { Q as QueryKeys, W as WooCommerceEventHandler, S as StoreLocale, a as StoreValidationResult, R as RateLimitConfig } from './types-BDwpAWoN.cjs';
6
- export { C as CartCouponAppliedEvent, b as CartCouponRemovedEvent, c as CartCustomerUpdatedEvent, d as CartItemAddedEvent, e as CartItemRemovedEvent, f as CartItemUpdatedEvent, g as CartShippingSelectedEvent, h as CheckoutProcessedEvent, D as DEFAULT_STORE_CONFIG, O as OrderFetchedEvent, i as StoreConfig, j as StoreContextValue, k as StoreFeatures, l as StoreGuardrails, m as StoreTheme, n as WooCommerceEvent, o as WooCommerceEventType, p as createQueryKeys } from './types-BDwpAWoN.cjs';
5
+ import { Q as QueryKeys, W as WooCommerceEventHandler, S as StoreLocale, a as StoreValidationResult, R as RateLimitConfig, b as WooCommerceEventType } from './types-D7dDI9Lr.cjs';
6
+ export { C as CartCouponAppliedEvent, c as CartCouponRemovedEvent, d as CartCustomerUpdatedEvent, e as CartItemAddedEvent, f as CartItemRemovedEvent, g as CartItemUpdatedEvent, h as CartShippingSelectedEvent, i as CheckoutProcessedEvent, D as DEFAULT_STORE_CONFIG, O as OrderFetchedEvent, j as StoreConfig, k as StoreContextValue, l as StoreFeatures, m as StoreGuardrails, n as StoreTheme, o as WooCommerceEvent, p as createQueryKeys } from './types-D7dDI9Lr.cjs';
7
7
  export { WooCommerceStoreContext, WooCommerceStoreProvider, WooCommerceStoreProviderProps } from './provider/index.cjs';
8
- export { A as AppliedCoupon, C as CartTotals, I as ImageSize, P as PLACEHOLDER_IMAGE_URL, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedProduct, e as ProcessedProductDetails, f as ProductCartState, g as ProductCategoryTreeNode, S as ShippingRate, U as UseCartViewOptions, h as UseCartViewReturn, i as UseProductViewOptions, j as UseProductViewReturn, k as UseProductsFeedOptions, l as UseProductsFeedReturn, m as getAllImageUrls, n as getImageUrl, o as getImageUrlOrPlaceholder, p as getPrimaryImage, q as getSizedImageUrl, r as preloadImage, s as preloadImages, u as useAddToCart, t as useApplyCoupon, v as useCart, w as useCartView, x as useCheckout, y as useInfiniteProducts, z as useOrder, B as useProcessCheckout, D as useProduct, E as useProductCategories, F as useProductCategoryTree, G as useProductView, H as useProducts, J as useProductsFeed, K as useRemoveCoupon, L as useRemoveFromCart, M as useSelectShippingRate, N as useStore, O as useStoreFeatures, Q as useStoreLocale, R as useStoreTheme, T as useUpdateCartItem, V as useUpdateCustomer, W as useWooCommerceClient, X as useWooCommerceQueryKeys } from './index-CPpVyoLQ.cjs';
8
+ export { A as AppliedCoupon, C as CartTotals, I as ImageSize, P as PLACEHOLDER_IMAGE_URL, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedProduct, e as ProcessedProductDetails, f as ProductCartState, g as ProductCategoryTreeNode, S as ShippingRate, U as UseCartViewOptions, h as UseCartViewReturn, i as UseProductViewOptions, j as UseProductViewReturn, k as UseProductsFeedOptions, l as UseProductsFeedReturn, m as getAllImageUrls, n as getImageUrl, o as getImageUrlOrPlaceholder, p as getPrimaryImage, q as getSizedImageUrl, r as preloadImage, s as preloadImages, u as useAddToCart, t as useApplyCoupon, v as useCart, w as useCartView, x as useCheckout, y as useInfiniteProducts, z as useOrder, B as useProcessCheckout, D as useProduct, E as useProductCategories, F as useProductCategoryTree, G as useProductView, H as useProducts, J as useProductsFeed, K as useRemoveCoupon, L as useRemoveFromCart, M as useSelectShippingRate, N as useStore, O as useStoreFeatures, Q as useStoreLocale, R as useStoreTheme, T as useUpdateCartItem, V as useUpdateCustomer, W as useWooCommerceClient, X as useWooCommerceQueryKeys } from './index-BP5iXDIj.cjs';
9
9
  import 'react/jsx-runtime';
10
10
  import '@tanstack/react-query';
11
11
 
@@ -77,4 +77,19 @@ declare function getGlobalRateLimiter(config?: RateLimitConfig): RateLimiter;
77
77
  declare function configureGlobalRateLimiter(config: RateLimitConfig): void;
78
78
  declare function resetGlobalRateLimiter(): void;
79
79
 
80
- export { QueryKeys, RateLimitConfig, RateLimiter, type StockDisplayConfig, type StockStatus, StoreLocale, StoreValidationResult, WooCommerceContext, type WooCommerceContextValue, WooCommerceEventHandler, WooCommerceProvider, type WooCommerceProviderProps, calculateDiscount, configureGlobalRateLimiter, formatDiscountBadge, formatPrice, formatPriceRange, formatStoreApiPrice, formatStoreApiPriceIntl, getBaseUrl, getCurrencySymbol, getGlobalRateLimiter, getMaxAddToCartQuantity, getStockSeverity, getStockStatusText, isLowStock, isPurchasable, isValidStoreUrlFormat, normalizeStoreUrl, parseWooCommercePrice, resetGlobalRateLimiter, validateWooCommerceStore };
80
+ declare function composeHandlers(...handlers: WooCommerceEventHandler[]): WooCommerceEventHandler;
81
+
82
+ interface AnalyticsProvider {
83
+ log(eventName: string, params?: Record<string, unknown>): void;
84
+ }
85
+ type AnalyticsEventMap = {
86
+ [K in WooCommerceEventType]?: {
87
+ eventName: string;
88
+ params: Record<string, unknown>;
89
+ };
90
+ };
91
+ type AnalyticsEventName = 'add_to_cart' | 'remove_from_cart' | 'update_cart_quantity' | 'apply_coupon' | 'remove_coupon' | 'purchase';
92
+
93
+ declare function createAnalyticsHandler(provider: AnalyticsProvider): WooCommerceEventHandler;
94
+
95
+ export { type AnalyticsEventMap, type AnalyticsEventName, type AnalyticsProvider, QueryKeys, RateLimitConfig, RateLimiter, type StockDisplayConfig, type StockStatus, StoreLocale, StoreValidationResult, WooCommerceContext, type WooCommerceContextValue, WooCommerceEventHandler, WooCommerceEventType, WooCommerceProvider, type WooCommerceProviderProps, calculateDiscount, composeHandlers, configureGlobalRateLimiter, createAnalyticsHandler, formatDiscountBadge, formatPrice, formatPriceRange, formatStoreApiPrice, formatStoreApiPriceIntl, getBaseUrl, getCurrencySymbol, getGlobalRateLimiter, getMaxAddToCartQuantity, getStockSeverity, getStockStatusText, isLowStock, isPurchasable, isValidStoreUrlFormat, normalizeStoreUrl, parseWooCommercePrice, resetGlobalRateLimiter, validateWooCommerceStore };
package/dist/index.d.ts CHANGED
@@ -2,10 +2,10 @@ import * as react from 'react';
2
2
  import react__default from 'react';
3
3
  import { WooCommerceClient } from '@atomic-solutions/woocommerce-api-client';
4
4
  export { Address, BillingAddress, Cart, CartHeadersAdapter, CartItem, Checkout, Product, ProductCategory, ProductImage, ProductParams, StoreApiOrder, addressSchema, checkoutSchema } from '@atomic-solutions/woocommerce-api-client';
5
- import { Q as QueryKeys, W as WooCommerceEventHandler, S as StoreLocale, a as StoreValidationResult, R as RateLimitConfig } from './types-BDwpAWoN.js';
6
- export { C as CartCouponAppliedEvent, b as CartCouponRemovedEvent, c as CartCustomerUpdatedEvent, d as CartItemAddedEvent, e as CartItemRemovedEvent, f as CartItemUpdatedEvent, g as CartShippingSelectedEvent, h as CheckoutProcessedEvent, D as DEFAULT_STORE_CONFIG, O as OrderFetchedEvent, i as StoreConfig, j as StoreContextValue, k as StoreFeatures, l as StoreGuardrails, m as StoreTheme, n as WooCommerceEvent, o as WooCommerceEventType, p as createQueryKeys } from './types-BDwpAWoN.js';
5
+ import { Q as QueryKeys, W as WooCommerceEventHandler, S as StoreLocale, a as StoreValidationResult, R as RateLimitConfig, b as WooCommerceEventType } from './types-D7dDI9Lr.js';
6
+ export { C as CartCouponAppliedEvent, c as CartCouponRemovedEvent, d as CartCustomerUpdatedEvent, e as CartItemAddedEvent, f as CartItemRemovedEvent, g as CartItemUpdatedEvent, h as CartShippingSelectedEvent, i as CheckoutProcessedEvent, D as DEFAULT_STORE_CONFIG, O as OrderFetchedEvent, j as StoreConfig, k as StoreContextValue, l as StoreFeatures, m as StoreGuardrails, n as StoreTheme, o as WooCommerceEvent, p as createQueryKeys } from './types-D7dDI9Lr.js';
7
7
  export { WooCommerceStoreContext, WooCommerceStoreProvider, WooCommerceStoreProviderProps } from './provider/index.js';
8
- export { A as AppliedCoupon, C as CartTotals, I as ImageSize, P as PLACEHOLDER_IMAGE_URL, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedProduct, e as ProcessedProductDetails, f as ProductCartState, g as ProductCategoryTreeNode, S as ShippingRate, U as UseCartViewOptions, h as UseCartViewReturn, i as UseProductViewOptions, j as UseProductViewReturn, k as UseProductsFeedOptions, l as UseProductsFeedReturn, m as getAllImageUrls, n as getImageUrl, o as getImageUrlOrPlaceholder, p as getPrimaryImage, q as getSizedImageUrl, r as preloadImage, s as preloadImages, u as useAddToCart, t as useApplyCoupon, v as useCart, w as useCartView, x as useCheckout, y as useInfiniteProducts, z as useOrder, B as useProcessCheckout, D as useProduct, E as useProductCategories, F as useProductCategoryTree, G as useProductView, H as useProducts, J as useProductsFeed, K as useRemoveCoupon, L as useRemoveFromCart, M as useSelectShippingRate, N as useStore, O as useStoreFeatures, Q as useStoreLocale, R as useStoreTheme, T as useUpdateCartItem, V as useUpdateCustomer, W as useWooCommerceClient, X as useWooCommerceQueryKeys } from './index-BCMhB3fU.js';
8
+ export { A as AppliedCoupon, C as CartTotals, I as ImageSize, P as PLACEHOLDER_IMAGE_URL, a as PaymentMethod, b as ProcessedCartItem, c as ProcessedCategory, d as ProcessedProduct, e as ProcessedProductDetails, f as ProductCartState, g as ProductCategoryTreeNode, S as ShippingRate, U as UseCartViewOptions, h as UseCartViewReturn, i as UseProductViewOptions, j as UseProductViewReturn, k as UseProductsFeedOptions, l as UseProductsFeedReturn, m as getAllImageUrls, n as getImageUrl, o as getImageUrlOrPlaceholder, p as getPrimaryImage, q as getSizedImageUrl, r as preloadImage, s as preloadImages, u as useAddToCart, t as useApplyCoupon, v as useCart, w as useCartView, x as useCheckout, y as useInfiniteProducts, z as useOrder, B as useProcessCheckout, D as useProduct, E as useProductCategories, F as useProductCategoryTree, G as useProductView, H as useProducts, J as useProductsFeed, K as useRemoveCoupon, L as useRemoveFromCart, M as useSelectShippingRate, N as useStore, O as useStoreFeatures, Q as useStoreLocale, R as useStoreTheme, T as useUpdateCartItem, V as useUpdateCustomer, W as useWooCommerceClient, X as useWooCommerceQueryKeys } from './index-BPa3-Cyt.js';
9
9
  import 'react/jsx-runtime';
10
10
  import '@tanstack/react-query';
11
11
 
@@ -77,4 +77,19 @@ declare function getGlobalRateLimiter(config?: RateLimitConfig): RateLimiter;
77
77
  declare function configureGlobalRateLimiter(config: RateLimitConfig): void;
78
78
  declare function resetGlobalRateLimiter(): void;
79
79
 
80
- export { QueryKeys, RateLimitConfig, RateLimiter, type StockDisplayConfig, type StockStatus, StoreLocale, StoreValidationResult, WooCommerceContext, type WooCommerceContextValue, WooCommerceEventHandler, WooCommerceProvider, type WooCommerceProviderProps, calculateDiscount, configureGlobalRateLimiter, formatDiscountBadge, formatPrice, formatPriceRange, formatStoreApiPrice, formatStoreApiPriceIntl, getBaseUrl, getCurrencySymbol, getGlobalRateLimiter, getMaxAddToCartQuantity, getStockSeverity, getStockStatusText, isLowStock, isPurchasable, isValidStoreUrlFormat, normalizeStoreUrl, parseWooCommercePrice, resetGlobalRateLimiter, validateWooCommerceStore };
80
+ declare function composeHandlers(...handlers: WooCommerceEventHandler[]): WooCommerceEventHandler;
81
+
82
+ interface AnalyticsProvider {
83
+ log(eventName: string, params?: Record<string, unknown>): void;
84
+ }
85
+ type AnalyticsEventMap = {
86
+ [K in WooCommerceEventType]?: {
87
+ eventName: string;
88
+ params: Record<string, unknown>;
89
+ };
90
+ };
91
+ type AnalyticsEventName = 'add_to_cart' | 'remove_from_cart' | 'update_cart_quantity' | 'apply_coupon' | 'remove_coupon' | 'purchase';
92
+
93
+ declare function createAnalyticsHandler(provider: AnalyticsProvider): WooCommerceEventHandler;
94
+
95
+ export { type AnalyticsEventMap, type AnalyticsEventName, type AnalyticsProvider, QueryKeys, RateLimitConfig, RateLimiter, type StockDisplayConfig, type StockStatus, StoreLocale, StoreValidationResult, WooCommerceContext, type WooCommerceContextValue, WooCommerceEventHandler, WooCommerceEventType, WooCommerceProvider, type WooCommerceProviderProps, calculateDiscount, composeHandlers, configureGlobalRateLimiter, createAnalyticsHandler, formatDiscountBadge, formatPrice, formatPriceRange, formatStoreApiPrice, formatStoreApiPriceIntl, getBaseUrl, getCurrencySymbol, getGlobalRateLimiter, getMaxAddToCartQuantity, getStockSeverity, getStockStatusText, isLowStock, isPurchasable, isValidStoreUrlFormat, normalizeStoreUrl, parseWooCommercePrice, resetGlobalRateLimiter, validateWooCommerceStore };
package/dist/index.js CHANGED
@@ -1645,6 +1645,68 @@ function useCartView(options = {}) {
1645
1645
  };
1646
1646
  }
1647
1647
 
1648
- export { DEFAULT_STORE_CONFIG, PLACEHOLDER_IMAGE_URL, RateLimiter, WooCommerceContext, WooCommerceProvider, WooCommerceStoreContext, WooCommerceStoreProvider, calculateDiscount, configureGlobalRateLimiter, createQueryKeys, formatDiscountBadge, formatPrice, formatPriceRange, formatStoreApiPrice, formatStoreApiPriceIntl, getAllImageUrls, getBaseUrl, getCurrencySymbol, getGlobalRateLimiter, getImageUrl, getImageUrlOrPlaceholder, getMaxAddToCartQuantity, getPrimaryImage, getSizedImageUrl, getStockSeverity, getStockStatusText, isLowStock, isPurchasable, isValidStoreUrlFormat, normalizeStoreUrl, parseWooCommercePrice, preloadImage, preloadImages, resetGlobalRateLimiter, useAddToCart, useApplyCoupon, useCart, useCartView, useCheckout, useInfiniteProducts, useOrder, useProcessCheckout, useProduct, useProductCategories, useProductCategoryTree, useProductView, useProducts, useProductsFeed, useRemoveCoupon, useRemoveFromCart, useSelectShippingRate, useStore, useStoreFeatures, useStoreLocale, useStoreTheme, useUpdateCartItem, useUpdateCustomer, useWooCommerceClient, useWooCommerceQueryKeys, validateWooCommerceStore };
1648
+ // src/events/composeHandlers.ts
1649
+ function composeHandlers(...handlers) {
1650
+ return (event) => {
1651
+ for (const handler of handlers) {
1652
+ handler(event);
1653
+ }
1654
+ };
1655
+ }
1656
+
1657
+ // src/analytics/analyticsAdapter.ts
1658
+ function createAnalyticsHandler(provider) {
1659
+ return (event) => {
1660
+ if (event.status !== "success") {
1661
+ return;
1662
+ }
1663
+ switch (event.type) {
1664
+ case "cart:item_added":
1665
+ provider.log("add_to_cart", {
1666
+ product_id: event.data.item.id,
1667
+ product_name: event.data.item.name,
1668
+ quantity: event.data.item.quantity,
1669
+ price: event.data.item.prices.price
1670
+ });
1671
+ break;
1672
+ case "cart:item_removed": {
1673
+ const removedItem = event.data.cart.items.find(
1674
+ (i) => i.key === event.data.itemKey
1675
+ );
1676
+ provider.log("remove_from_cart", {
1677
+ product_id: removedItem?.id,
1678
+ product_name: removedItem?.name,
1679
+ quantity: removedItem?.quantity
1680
+ });
1681
+ break;
1682
+ }
1683
+ case "cart:item_updated":
1684
+ provider.log("update_cart_quantity", {
1685
+ product_id: event.data.item.id,
1686
+ quantity: event.data.item.quantity
1687
+ });
1688
+ break;
1689
+ case "cart:coupon_applied":
1690
+ provider.log("apply_coupon", {
1691
+ coupon_code: event.data.code,
1692
+ success: true
1693
+ });
1694
+ break;
1695
+ case "cart:coupon_removed":
1696
+ provider.log("remove_coupon", {
1697
+ coupon_code: event.data.code
1698
+ });
1699
+ break;
1700
+ case "checkout:processed":
1701
+ provider.log("purchase", {
1702
+ order_id: event.data.checkout.order_id,
1703
+ payment_method: event.data.checkout.payment_method
1704
+ });
1705
+ break;
1706
+ }
1707
+ };
1708
+ }
1709
+
1710
+ export { DEFAULT_STORE_CONFIG, PLACEHOLDER_IMAGE_URL, RateLimiter, WooCommerceContext, WooCommerceProvider, WooCommerceStoreContext, WooCommerceStoreProvider, calculateDiscount, composeHandlers, configureGlobalRateLimiter, createAnalyticsHandler, createQueryKeys, formatDiscountBadge, formatPrice, formatPriceRange, formatStoreApiPrice, formatStoreApiPriceIntl, getAllImageUrls, getBaseUrl, getCurrencySymbol, getGlobalRateLimiter, getImageUrl, getImageUrlOrPlaceholder, getMaxAddToCartQuantity, getPrimaryImage, getSizedImageUrl, getStockSeverity, getStockStatusText, isLowStock, isPurchasable, isValidStoreUrlFormat, normalizeStoreUrl, parseWooCommercePrice, preloadImage, preloadImages, resetGlobalRateLimiter, useAddToCart, useApplyCoupon, useCart, useCartView, useCheckout, useInfiniteProducts, useOrder, useProcessCheckout, useProduct, useProductCategories, useProductCategoryTree, useProductView, useProducts, useProductsFeed, useRemoveCoupon, useRemoveFromCart, useSelectShippingRate, useStore, useStoreFeatures, useStoreLocale, useStoreTheme, useUpdateCartItem, useUpdateCustomer, useWooCommerceClient, useWooCommerceQueryKeys, validateWooCommerceStore };
1649
1711
  //# sourceMappingURL=index.js.map
1650
1712
  //# sourceMappingURL=index.js.map