@aglyn/plugins-commerce 1.0.0-beta.143
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/LICENSE +201 -0
- package/README.md +10 -0
- package/package.json +57 -0
- package/src/index.d.ts +38 -0
- package/src/index.js +38 -0
- package/src/index.js.map +1 -0
- package/src/lib/components/account.d.ts +31 -0
- package/src/lib/components/account.js +645 -0
- package/src/lib/components/account.js.map +1 -0
- package/src/lib/components/cart.d.ts +38 -0
- package/src/lib/components/cart.js +851 -0
- package/src/lib/components/cart.js.map +1 -0
- package/src/lib/components/commerce-console-page.d.ts +32 -0
- package/src/lib/components/commerce-console-page.js +296 -0
- package/src/lib/components/commerce-console-page.js.map +1 -0
- package/src/lib/components/commerce-console-sections.d.ts +34 -0
- package/src/lib/components/commerce-console-sections.js +62 -0
- package/src/lib/components/commerce-console-sections.js.map +1 -0
- package/src/lib/components/console/catalog-organization-card.component.d.ts +14 -0
- package/src/lib/components/console/catalog-organization-card.component.js +1087 -0
- package/src/lib/components/console/catalog-organization-card.component.js.map +1 -0
- package/src/lib/components/console/commerce-analytics-card.component.d.ts +27 -0
- package/src/lib/components/console/commerce-analytics-card.component.js +310 -0
- package/src/lib/components/console/commerce-analytics-card.component.js.map +1 -0
- package/src/lib/components/console/commerce-glance-card.component.d.ts +20 -0
- package/src/lib/components/console/commerce-glance-card.component.js +340 -0
- package/src/lib/components/console/commerce-glance-card.component.js.map +1 -0
- package/src/lib/components/console/commerce-stat-tile.component.d.ts +37 -0
- package/src/lib/components/console/commerce-stat-tile.component.js +72 -0
- package/src/lib/components/console/commerce-stat-tile.component.js.map +1 -0
- package/src/lib/components/console/discounts-card.component.d.ts +14 -0
- package/src/lib/components/console/discounts-card.component.js +443 -0
- package/src/lib/components/console/discounts-card.component.js.map +1 -0
- package/src/lib/components/console/entitlement-gate.component.d.ts +76 -0
- package/src/lib/components/console/entitlement-gate.component.js +115 -0
- package/src/lib/components/console/entitlement-gate.component.js.map +1 -0
- package/src/lib/components/console/gift-cards-card.component.d.ts +29 -0
- package/src/lib/components/console/gift-cards-card.component.js +379 -0
- package/src/lib/components/console/gift-cards-card.component.js.map +1 -0
- package/src/lib/components/console/host-coupons-card.component.d.ts +14 -0
- package/src/lib/components/console/host-coupons-card.component.js +252 -0
- package/src/lib/components/console/host-coupons-card.component.js.map +1 -0
- package/src/lib/components/console/host-orders-card.component.d.ts +13 -0
- package/src/lib/components/console/host-orders-card.component.js +861 -0
- package/src/lib/components/console/host-orders-card.component.js.map +1 -0
- package/src/lib/components/console/locations-card.component.d.ts +14 -0
- package/src/lib/components/console/locations-card.component.js +256 -0
- package/src/lib/components/console/locations-card.component.js.map +1 -0
- package/src/lib/components/console/member-posts-card.component.d.ts +8 -0
- package/src/lib/components/console/member-posts-card.component.js +283 -0
- package/src/lib/components/console/member-posts-card.component.js.map +1 -0
- package/src/lib/components/console/newest-site-users-card.component.d.ts +36 -0
- package/src/lib/components/console/newest-site-users-card.component.js +126 -0
- package/src/lib/components/console/newest-site-users-card.component.js.map +1 -0
- package/src/lib/components/console/order-detail-dialog.component.d.ts +28 -0
- package/src/lib/components/console/order-detail-dialog.component.js +976 -0
- package/src/lib/components/console/order-detail-dialog.component.js.map +1 -0
- package/src/lib/components/console/paid-media.d.ts +127 -0
- package/src/lib/components/console/paid-media.js +397 -0
- package/src/lib/components/console/paid-media.js.map +1 -0
- package/src/lib/components/console/payments-settings-card.component.d.ts +13 -0
- package/src/lib/components/console/payments-settings-card.component.js +295 -0
- package/src/lib/components/console/payments-settings-card.component.js.map +1 -0
- package/src/lib/components/console/pos-page.component.d.ts +13 -0
- package/src/lib/components/console/pos-page.component.js +916 -0
- package/src/lib/components/console/pos-page.component.js.map +1 -0
- package/src/lib/components/console/product-editor-dialog.component.d.ts +32 -0
- package/src/lib/components/console/product-editor-dialog.component.js +1374 -0
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -0
- package/src/lib/components/console/products-hub-card.component.d.ts +16 -0
- package/src/lib/components/console/products-hub-card.component.js +1280 -0
- package/src/lib/components/console/products-hub-card.component.js.map +1 -0
- package/src/lib/components/console/products-hub-zone.component.d.ts +50 -0
- package/src/lib/components/console/products-hub-zone.component.js +200 -0
- package/src/lib/components/console/products-hub-zone.component.js.map +1 -0
- package/src/lib/components/console/recovery-queue-card.component.d.ts +39 -0
- package/src/lib/components/console/recovery-queue-card.component.js +262 -0
- package/src/lib/components/console/recovery-queue-card.component.js.map +1 -0
- package/src/lib/components/console/registers-card.component.d.ts +21 -0
- package/src/lib/components/console/registers-card.component.js +296 -0
- package/src/lib/components/console/registers-card.component.js.map +1 -0
- package/src/lib/components/console/reservations-card.component.d.ts +14 -0
- package/src/lib/components/console/reservations-card.component.js +650 -0
- package/src/lib/components/console/reservations-card.component.js.map +1 -0
- package/src/lib/components/console/reviews-moderation-card.component.d.ts +8 -0
- package/src/lib/components/console/reviews-moderation-card.component.js +235 -0
- package/src/lib/components/console/reviews-moderation-card.component.js.map +1 -0
- package/src/lib/components/console/shipping-settings-card.component.d.ts +38 -0
- package/src/lib/components/console/shipping-settings-card.component.js +560 -0
- package/src/lib/components/console/shipping-settings-card.component.js.map +1 -0
- package/src/lib/components/console/stock-movements-card.component.d.ts +31 -0
- package/src/lib/components/console/stock-movements-card.component.js +333 -0
- package/src/lib/components/console/stock-movements-card.component.js.map +1 -0
- package/src/lib/components/console/store-settings-card.component.d.ts +14 -0
- package/src/lib/components/console/store-settings-card.component.js +300 -0
- package/src/lib/components/console/store-settings-card.component.js.map +1 -0
- package/src/lib/components/console/storefront-tax-summary-card.component.d.ts +73 -0
- package/src/lib/components/console/storefront-tax-summary-card.component.js +408 -0
- package/src/lib/components/console/storefront-tax-summary-card.component.js.map +1 -0
- package/src/lib/components/console/suppliers-card.component.d.ts +8 -0
- package/src/lib/components/console/suppliers-card.component.js +328 -0
- package/src/lib/components/console/suppliers-card.component.js.map +1 -0
- package/src/lib/components/console/tax-settings-card.component.d.ts +14 -0
- package/src/lib/components/console/tax-settings-card.component.js +473 -0
- package/src/lib/components/console/tax-settings-card.component.js.map +1 -0
- package/src/lib/components/gate.d.ts +39 -0
- package/src/lib/components/gate.js +202 -0
- package/src/lib/components/gate.js.map +1 -0
- package/src/lib/components/gated-video.d.ts +40 -0
- package/src/lib/components/gated-video.js +366 -0
- package/src/lib/components/gated-video.js.map +1 -0
- package/src/lib/components/member-feed.d.ts +32 -0
- package/src/lib/components/member-feed.js +198 -0
- package/src/lib/components/member-feed.js.map +1 -0
- package/src/lib/components/member-recovery.d.ts +35 -0
- package/src/lib/components/member-recovery.js +313 -0
- package/src/lib/components/member-recovery.js.map +1 -0
- package/src/lib/components/member-signin.d.ts +35 -0
- package/src/lib/components/member-signin.js +257 -0
- package/src/lib/components/member-signin.js.map +1 -0
- package/src/lib/components/member-signup.d.ts +34 -0
- package/src/lib/components/member-signup.js +287 -0
- package/src/lib/components/member-signup.js.map +1 -0
- package/src/lib/components/newsletter-signup.d.ts +39 -0
- package/src/lib/components/newsletter-signup.js +229 -0
- package/src/lib/components/newsletter-signup.js.map +1 -0
- package/src/lib/components/product-detail.d.ts +38 -0
- package/src/lib/components/product-detail.js +1022 -0
- package/src/lib/components/product-detail.js.map +1 -0
- package/src/lib/components/product-grid.d.ts +67 -0
- package/src/lib/components/product-grid.js +909 -0
- package/src/lib/components/product-grid.js.map +1 -0
- package/src/lib/components/product-reviews.d.ts +32 -0
- package/src/lib/components/product-reviews.js +349 -0
- package/src/lib/components/product-reviews.js.map +1 -0
- package/src/lib/components/related-products.d.ts +33 -0
- package/src/lib/components/related-products.js +232 -0
- package/src/lib/components/related-products.js.map +1 -0
- package/src/lib/components/reservation-widget.d.ts +33 -0
- package/src/lib/components/reservation-widget.js +418 -0
- package/src/lib/components/reservation-widget.js.map +1 -0
- package/src/lib/components/storefront-payment-element-fallback.d.ts +18 -0
- package/src/lib/components/storefront-payment-element-fallback.js +51 -0
- package/src/lib/components/storefront-payment-element-fallback.js.map +1 -0
- package/src/lib/components/storefront-payment-element.d.ts +78 -0
- package/src/lib/components/storefront-payment-element.js +156 -0
- package/src/lib/components/storefront-payment-element.js.map +1 -0
- package/src/lib/components/wishlist.d.ts +46 -0
- package/src/lib/components/wishlist.js +304 -0
- package/src/lib/components/wishlist.js.map +1 -0
- package/src/lib/constants/bundle-common.d.ts +18 -0
- package/src/lib/constants/bundle-common.js +18 -0
- package/src/lib/constants/bundle-common.js.map +1 -0
- package/src/lib/constants/product-filters.d.ts +35 -0
- package/src/lib/constants/product-filters.js +109 -0
- package/src/lib/constants/product-filters.js.map +1 -0
- package/src/lib/model/commerce-cart.d.ts +52 -0
- package/src/lib/model/commerce-cart.js +102 -0
- package/src/lib/model/commerce-cart.js.map +1 -0
- package/src/lib/model/commerce-connect-transfer.d.ts +243 -0
- package/src/lib/model/commerce-connect-transfer.js +231 -0
- package/src/lib/model/commerce-connect-transfer.js.map +1 -0
- package/src/lib/model/commerce-discounts.d.ts +164 -0
- package/src/lib/model/commerce-discounts.js +231 -0
- package/src/lib/model/commerce-discounts.js.map +1 -0
- package/src/lib/model/commerce-dispute.d.ts +124 -0
- package/src/lib/model/commerce-dispute.js +225 -0
- package/src/lib/model/commerce-dispute.js.map +1 -0
- package/src/lib/model/commerce-gift-cards.d.ts +107 -0
- package/src/lib/model/commerce-gift-cards.js +121 -0
- package/src/lib/model/commerce-gift-cards.js.map +1 -0
- package/src/lib/model/commerce-io.d.ts +36 -0
- package/src/lib/model/commerce-io.js +245 -0
- package/src/lib/model/commerce-io.js.map +1 -0
- package/src/lib/model/commerce-orders.d.ts +1040 -0
- package/src/lib/model/commerce-orders.js +1022 -0
- package/src/lib/model/commerce-orders.js.map +1 -0
- package/src/lib/model/commerce-promotions.d.ts +188 -0
- package/src/lib/model/commerce-promotions.js +199 -0
- package/src/lib/model/commerce-promotions.js.map +1 -0
- package/src/lib/model/commerce-reservations.d.ts +175 -0
- package/src/lib/model/commerce-reservations.js +157 -0
- package/src/lib/model/commerce-reservations.js.map +1 -0
- package/src/lib/model/commerce-shipping.d.ts +316 -0
- package/src/lib/model/commerce-shipping.js +484 -0
- package/src/lib/model/commerce-shipping.js.map +1 -0
- package/src/lib/model/commerce-stock-holds.d.ts +199 -0
- package/src/lib/model/commerce-stock-holds.js +190 -0
- package/src/lib/model/commerce-stock-holds.js.map +1 -0
- package/src/lib/model/commerce-subscription-status.d.ts +67 -0
- package/src/lib/model/commerce-subscription-status.js +76 -0
- package/src/lib/model/commerce-subscription-status.js.map +1 -0
- package/src/lib/model/commerce-tax-decision.d.ts +222 -0
- package/src/lib/model/commerce-tax-decision.js +165 -0
- package/src/lib/model/commerce-tax-decision.js.map +1 -0
- package/src/lib/model/commerce-tax.d.ts +176 -0
- package/src/lib/model/commerce-tax.js +92 -0
- package/src/lib/model/commerce-tax.js.map +1 -0
- package/src/lib/model/commerce.d.ts +551 -0
- package/src/lib/model/commerce.js +739 -0
- package/src/lib/model/commerce.js.map +1 -0
- package/src/lib/model/index.d.ts +40 -0
- package/src/lib/model/index.js +40 -0
- package/src/lib/model/index.js.map +1 -0
- package/src/lib/model/order-figures.d.ts +48 -0
- package/src/lib/model/order-figures.js +74 -0
- package/src/lib/model/order-figures.js.map +1 -0
- package/src/lib/model/plugin-permissions.d.ts +23 -0
- package/src/lib/model/plugin-permissions.js +34 -0
- package/src/lib/model/plugin-permissions.js.map +1 -0
- package/src/lib/model/purchase-analytics.d.ts +186 -0
- package/src/lib/model/purchase-analytics.js +216 -0
- package/src/lib/model/purchase-analytics.js.map +1 -0
- package/src/lib/plugin-config.d.ts +62 -0
- package/src/lib/plugin-config.js +78 -0
- package/src/lib/plugin-config.js.map +1 -0
- package/src/lib/plugin.d.ts +28 -0
- package/src/lib/plugin.js +147 -0
- package/src/lib/plugin.js.map +1 -0
- package/src/lib/server/billing-webhook.d.ts +26 -0
- package/src/lib/server/billing-webhook.js +4011 -0
- package/src/lib/server/billing-webhook.js.map +1 -0
- package/src/lib/server/cancel-order.d.ts +87 -0
- package/src/lib/server/cancel-order.js +368 -0
- package/src/lib/server/cancel-order.js.map +1 -0
- package/src/lib/server/cart-checkout.d.ts +25 -0
- package/src/lib/server/cart-checkout.js +976 -0
- package/src/lib/server/cart-checkout.js.map +1 -0
- package/src/lib/server/cart-cookie.d.ts +32 -0
- package/src/lib/server/cart-cookie.js +77 -0
- package/src/lib/server/cart-cookie.js.map +1 -0
- package/src/lib/server/cart.d.ts +34 -0
- package/src/lib/server/cart.js +181 -0
- package/src/lib/server/cart.js.map +1 -0
- package/src/lib/server/catalog.d.ts +127 -0
- package/src/lib/server/catalog.js +277 -0
- package/src/lib/server/catalog.js.map +1 -0
- package/src/lib/server/checkout.d.ts +36 -0
- package/src/lib/server/checkout.js +915 -0
- package/src/lib/server/checkout.js.map +1 -0
- package/src/lib/server/connect.d.ts +26 -0
- package/src/lib/server/connect.js +238 -0
- package/src/lib/server/connect.js.map +1 -0
- package/src/lib/server/contact-refund.d.ts +117 -0
- package/src/lib/server/contact-refund.js +196 -0
- package/src/lib/server/contact-refund.js.map +1 -0
- package/src/lib/server/download.d.ts +39 -0
- package/src/lib/server/download.js +206 -0
- package/src/lib/server/download.js.map +1 -0
- package/src/lib/server/draft-order.d.ts +26 -0
- package/src/lib/server/draft-order.js +706 -0
- package/src/lib/server/draft-order.js.map +1 -0
- package/src/lib/server/feed.d.ts +24 -0
- package/src/lib/server/feed.js +59 -0
- package/src/lib/server/feed.js.map +1 -0
- package/src/lib/server/fulfill-order.d.ts +97 -0
- package/src/lib/server/fulfill-order.js +235 -0
- package/src/lib/server/fulfill-order.js.map +1 -0
- package/src/lib/server/gate.d.ts +36 -0
- package/src/lib/server/gate.js +112 -0
- package/src/lib/server/gate.js.map +1 -0
- package/src/lib/server/gift-cards.d.ts +42 -0
- package/src/lib/server/gift-cards.js +219 -0
- package/src/lib/server/gift-cards.js.map +1 -0
- package/src/lib/server/low-stock.d.ts +49 -0
- package/src/lib/server/low-stock.js +60 -0
- package/src/lib/server/low-stock.js.map +1 -0
- package/src/lib/server/manual-tax-rate.d.ts +82 -0
- package/src/lib/server/manual-tax-rate.js +113 -0
- package/src/lib/server/manual-tax-rate.js.map +1 -0
- package/src/lib/server/member-feed.d.ts +24 -0
- package/src/lib/server/member-feed.js +72 -0
- package/src/lib/server/member-feed.js.map +1 -0
- package/src/lib/server/member-name-search.d.ts +37 -0
- package/src/lib/server/member-name-search.js +42 -0
- package/src/lib/server/member-name-search.js.map +1 -0
- package/src/lib/server/member-post.d.ts +23 -0
- package/src/lib/server/member-post.js +166 -0
- package/src/lib/server/member-post.js.map +1 -0
- package/src/lib/server/membership-account.d.ts +37 -0
- package/src/lib/server/membership-account.js +148 -0
- package/src/lib/server/membership-account.js.map +1 -0
- package/src/lib/server/membership-admin-password.d.ts +33 -0
- package/src/lib/server/membership-admin-password.js +202 -0
- package/src/lib/server/membership-admin-password.js.map +1 -0
- package/src/lib/server/membership-content.d.ts +23 -0
- package/src/lib/server/membership-content.js +105 -0
- package/src/lib/server/membership-content.js.map +1 -0
- package/src/lib/server/membership-login.d.ts +19 -0
- package/src/lib/server/membership-login.js +137 -0
- package/src/lib/server/membership-login.js.map +1 -0
- package/src/lib/server/membership-logout.d.ts +19 -0
- package/src/lib/server/membership-logout.js +35 -0
- package/src/lib/server/membership-logout.js.map +1 -0
- package/src/lib/server/membership-recover.d.ts +60 -0
- package/src/lib/server/membership-recover.js +244 -0
- package/src/lib/server/membership-recover.js.map +1 -0
- package/src/lib/server/membership-register.d.ts +22 -0
- package/src/lib/server/membership-register.js +241 -0
- package/src/lib/server/membership-register.js.map +1 -0
- package/src/lib/server/membership-reset.d.ts +26 -0
- package/src/lib/server/membership-reset.js +88 -0
- package/src/lib/server/membership-reset.js.map +1 -0
- package/src/lib/server/membership-wishlist.d.ts +23 -0
- package/src/lib/server/membership-wishlist.js +89 -0
- package/src/lib/server/membership-wishlist.js.map +1 -0
- package/src/lib/server/membership.d.ts +96 -0
- package/src/lib/server/membership.js +222 -0
- package/src/lib/server/membership.js.map +1 -0
- package/src/lib/server/native-checkout.d.ts +170 -0
- package/src/lib/server/native-checkout.js +193 -0
- package/src/lib/server/native-checkout.js.map +1 -0
- package/src/lib/server/newsletter.d.ts +23 -0
- package/src/lib/server/newsletter.js +323 -0
- package/src/lib/server/newsletter.js.map +1 -0
- package/src/lib/server/notify-restock.d.ts +22 -0
- package/src/lib/server/notify-restock.js +84 -0
- package/src/lib/server/notify-restock.js.map +1 -0
- package/src/lib/server/order-analytics.d.ts +134 -0
- package/src/lib/server/order-analytics.js +263 -0
- package/src/lib/server/order-analytics.js.map +1 -0
- package/src/lib/server/order-figures.d.ts +33 -0
- package/src/lib/server/order-figures.js +220 -0
- package/src/lib/server/order-figures.js.map +1 -0
- package/src/lib/server/paid-media-delivery.d.ts +173 -0
- package/src/lib/server/paid-media-delivery.js +212 -0
- package/src/lib/server/paid-media-delivery.js.map +1 -0
- package/src/lib/server/pos-order.d.ts +54 -0
- package/src/lib/server/pos-order.js +1137 -0
- package/src/lib/server/pos-order.js.map +1 -0
- package/src/lib/server/process-abandoned.d.ts +54 -0
- package/src/lib/server/process-abandoned.js +222 -0
- package/src/lib/server/process-abandoned.js.map +1 -0
- package/src/lib/server/process-restock.d.ts +42 -0
- package/src/lib/server/process-restock.js +219 -0
- package/src/lib/server/process-restock.js.map +1 -0
- package/src/lib/server/product-card.d.ts +29 -0
- package/src/lib/server/product-card.js +54 -0
- package/src/lib/server/product-card.js.map +1 -0
- package/src/lib/server/product.d.ts +70 -0
- package/src/lib/server/product.js +105 -0
- package/src/lib/server/product.js.map +1 -0
- package/src/lib/server/promotion-hold.d.ts +144 -0
- package/src/lib/server/promotion-hold.js +174 -0
- package/src/lib/server/promotion-hold.js.map +1 -0
- package/src/lib/server/reconcile-stock.d.ts +106 -0
- package/src/lib/server/reconcile-stock.js +349 -0
- package/src/lib/server/reconcile-stock.js.map +1 -0
- package/src/lib/server/refund.d.ts +45 -0
- package/src/lib/server/refund.js +607 -0
- package/src/lib/server/refund.js.map +1 -0
- package/src/lib/server/related.d.ts +24 -0
- package/src/lib/server/related.js +104 -0
- package/src/lib/server/related.js.map +1 -0
- package/src/lib/server/reservation-availability.d.ts +23 -0
- package/src/lib/server/reservation-availability.js +111 -0
- package/src/lib/server/reservation-availability.js.map +1 -0
- package/src/lib/server/reserve-stock.d.ts +156 -0
- package/src/lib/server/reserve-stock.js +146 -0
- package/src/lib/server/reserve-stock.js.map +1 -0
- package/src/lib/server/reserve.d.ts +25 -0
- package/src/lib/server/reserve.js +426 -0
- package/src/lib/server/reserve.js.map +1 -0
- package/src/lib/server/restock-flag.d.ts +202 -0
- package/src/lib/server/restock-flag.js +449 -0
- package/src/lib/server/restock-flag.js.map +1 -0
- package/src/lib/server/reviews.d.ts +51 -0
- package/src/lib/server/reviews.js +132 -0
- package/src/lib/server/reviews.js.map +1 -0
- package/src/lib/server/site-page-enricher.d.ts +42 -0
- package/src/lib/server/site-page-enricher.js +149 -0
- package/src/lib/server/site-page-enricher.js.map +1 -0
- package/src/lib/server/site-page-resolver.d.ts +26 -0
- package/src/lib/server/site-page-resolver.js +223 -0
- package/src/lib/server/site-page-resolver.js.map +1 -0
- package/src/lib/server/stock-hold.d.ts +127 -0
- package/src/lib/server/stock-hold.js +258 -0
- package/src/lib/server/stock-hold.js.map +1 -0
- package/src/lib/server/storefront-tax-record.d.ts +22 -0
- package/src/lib/server/storefront-tax-record.js +218 -0
- package/src/lib/server/storefront-tax-record.js.map +1 -0
- package/src/lib/server/storefront-tax.d.ts +197 -0
- package/src/lib/server/storefront-tax.js +245 -0
- package/src/lib/server/storefront-tax.js.map +1 -0
- package/src/lib/server/stream.d.ts +25 -0
- package/src/lib/server/stream.js +191 -0
- package/src/lib/server/stream.js.map +1 -0
- package/src/lib/server/subscription-portal.d.ts +24 -0
- package/src/lib/server/subscription-portal.js +91 -0
- package/src/lib/server/subscription-portal.js.map +1 -0
- package/src/lib/server/supplier-outbox.d.ts +190 -0
- package/src/lib/server/supplier-outbox.js +342 -0
- package/src/lib/server/supplier-outbox.js.map +1 -0
- package/src/lib/server/supplier-update.d.ts +23 -0
- package/src/lib/server/supplier-update.js +289 -0
- package/src/lib/server/supplier-update.js.map +1 -0
- package/src/lib/server/tax-profile.d.ts +29 -0
- package/src/lib/server/tax-profile.js +40 -0
- package/src/lib/server/tax-profile.js.map +1 -0
- package/src/lib/server.d.ts +32 -0
- package/src/lib/server.js +311 -0
- package/src/lib/server.js.map +1 -0
- package/src/lib/site.d.ts +27 -0
- package/src/lib/site.js +134 -0
- package/src/lib/site.js.map +1 -0
- package/src/lib/utils/escape-html.d.ts +41 -0
- package/src/lib/utils/escape-html.js +41 -0
- package/src/lib/utils/escape-html.js.map +1 -0
- package/src/lib/utils/generate-preset-id.d.ts +19 -0
- package/src/lib/utils/generate-preset-id.js +25 -0
- package/src/lib/utils/generate-preset-id.js.map +1 -0
- package/src/lib/utils/member-continue.d.ts +45 -0
- package/src/lib/utils/member-continue.js +49 -0
- package/src/lib/utils/member-continue.js.map +1 -0
- package/src/lib/utils/use-storefront-purchase-event.d.ts +60 -0
- package/src/lib/utils/use-storefront-purchase-event.js +142 -0
- package/src/lib/utils/use-storefront-purchase-event.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/catalog-organization-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport * as CommerceModel from '../../model'\nimport { CardDisplay, useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { Timestamp } from '@aglyn/shared-util-timestamp'\nimport {\n Alert,\n Autocomplete,\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Divider,\n MenuItem,\n Stack,\n Switch,\n TextField,\n Typography,\n} from '@mui/material'\nimport { collection, deleteDoc, doc, setDoc } from 'firebase/firestore'\nimport { useCallback, useMemo, useState } from 'react'\nimport { useFirestore, useUser } from '@aglyn/tenant-feature-instance'\nimport {\n ceilingedWindow,\n collectionCeiling,\n useFirestoreCollection,\n writeGuardedBySeed,\n} from '@aglyn/tenant-feature-instance'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { TABLE_PAGE_SIZE_DEFAULT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\n\n/**\n * How many category documents the card reads.\n *\n * A CEILING, not a page size — the walk below is a TREE and cannot be sliced\n * by document without orphaning children from parents on another page.\n */\nconst CATEGORY_CEILING = 250\n/** The same, for collections: the slug check needs every row to be correct. */\nconst COLLECTION_CEILING = 250\n/**\n * The catalog the match counts are computed over.\n *\n * Neither a page size nor a promise: it is how much of the catalog this card\n * is willing to read, and the counts below say \"at least\" once the probe finds\n * a product past it.\n */\nconst PRODUCT_CEILING = 500\n\nexport interface CatalogOrganizationCardProps {\n hostId: string\n}\n\ntype CategoryRow = CommerceModel.ProductCategory & { $id: string }\ntype CollectionRow = CommerceModel.HostCollection & { $id: string }\ntype ProductRow = CommerceModel.HostProduct & { $id: string }\n\nconst RULE_FIELDS: Array<{ value: CommerceModel.CollectionRuleField; label: string }> = [\n { value: 'tag', label: 'Tag' },\n { value: 'categoryId', label: 'Category' },\n { value: 'priceUsd', label: 'Price' },\n { value: 'name', label: 'Name' },\n { value: 'type', label: 'Type' },\n]\nconst RULE_OPS: Array<{ value: CommerceModel.CollectionRuleOp; label: string }> = [\n { value: 'eq', label: 'is' },\n { value: 'neq', label: 'is not' },\n { value: 'lt', label: 'below' },\n { value: 'gt', label: 'above' },\n { value: 'contains', label: 'contains' },\n]\n\n/**\n * Categories & collections manager (AGL-280): category tree (parentId)\n * at `hosts/{hostId}/productCategories`, manual + smart collections at\n * `hosts/{hostId}/collections` with a live matched-product preview from\n * the same `matchesCollection` matcher the storefront uses.\n */\nexport function CatalogOrganizationCard(props: CatalogOrganizationCardProps) {\n const { hostId } = props\n const firestore = useFirestore()\n const { enqueueSnackbar } = useSnackbar()\n const { confirm } = useConfirmationContext()\n const { data: user } = useUser()\n\n const {\n data: categoryDocs,\n status: categoriesStatus,\n /**\n * The category rows are unconfirmed by the server (AGL-1358). Two writes\n * are seeded from them: the editor carries `parentId` off the row whether\n * or not the author touched it, and the delete REPARENTS every child of\n * the deleted category — a set computed entirely from this cached read,\n * so a stale snapshot can miss children that should have been moved.\n * (The reparent write itself is narrow since AGL-1374; what remains\n * cache-dependent is WHICH rows it runs on.)\n */\n fromCache: categoriesFromCache,\n } = useFirestoreCollection<any>(\n /*\n * ORDERED AND CEILINGED, deliberately not paged by the query (AGL-2501).\n *\n * `limit(250)` alone is answered in DOCUMENT-ID order and the ids are\n * `createResourceUid()`, so the window was a pseudo-random sample. Naming\n * the order does not change WHICH 250 come back; what it changes is that\n * the obvious next edit is caught — `orderBy('name')` would HIDE every\n * category saved without one, and `orderBy('order')` is worse still, since\n * the walk below already treats a missing `order` as 0.\n *\n * The QUERY is not paged because this is a TREE. The walk puts parents\n * before children and collects orphans by scanning the whole set, so a\n * page boundary would separate a child from the parent that positions it\n * and re-label as an orphan every category whose parent is on another\n * page. The parent PICKER in the dialog reads the same rows for the same\n * reason.\n */\n () =>\n collectionCeiling(\n collection(firestore, 'hosts', hostId, 'productCategories'),\n CATEGORY_CEILING,\n ),\n [firestore, hostId],\n { idField: '$id' },\n )\n const { rows: readCategories, truncated: categoriesTruncated } =\n ceilingedWindow<any>(categoryDocs, CATEGORY_CEILING)\n const {\n data: collectionDocs,\n status: collectionsStatus,\n /**\n * The collection rows are unconfirmed by the server (AGL-1358). The\n * editor copies a whole stored row and the save posts all of it — the\n * transport is the AGL-978 route rather than a client `setDoc`, but the\n * shape is identical, and so is the damage: `productIds` is the manual\n * membership, so a cached seed drops every product added since that\n * snapshot and the storefront blocks pointing at the collection go empty.\n */\n fromCache: collectionsFromCache,\n } = useFirestoreCollection<any>(\n /*\n * ORDERED AND CEILINGED, deliberately not paged (AGL-2501).\n *\n * The slug check below tests a draft against these rows — two catalog\n * collections answering `/collections/{slug}` is a storefront route that\n * resolves to whichever the server reaches first — so a ten-row server\n * page would compare a new collection against a tenth of the catalog and\n * create the collision the check exists to prevent.\n *\n * The rows are also filtered after reading: content collections (AGL-81)\n * share this subcollection and are classified out below, so a page of ten\n * documents arrives holding anywhere from zero to ten catalog collections.\n */\n () =>\n collectionCeiling(\n collection(firestore, 'hosts', hostId, 'collections'),\n COLLECTION_CEILING,\n ),\n [firestore, hostId],\n { idField: '$id' },\n )\n const { rows: readCollections, truncated: collectionsTruncated } =\n ceilingedWindow<any>(collectionDocs, COLLECTION_CEILING)\n const { data: productDocs } = useFirestoreCollection<any>(\n /*\n * The catalog behind the MATCH COUNTS, ceilinged with a probe (AGL-2501).\n *\n * `collectionCount` and the smart-collection preview both count this array\n * and print the result as a number of products. It was a bare `limit(500)`,\n * so on a three-thousand-product catalog \"Matches 47 products\" meant \"47 of\n * the five hundred I read\" — a count that is a window length, on the\n * control that decides what a collection contains.\n *\n * It stays a window, because the honest alternative is reading the whole\n * catalog on every mount of this card. What changes is that the probe makes\n * the shortfall a FACT, and the counts say \"at least\" when it bit rather\n * than stating a total they cannot know.\n */\n () =>\n collectionCeiling(\n collection(firestore, 'hosts', hostId, 'products'),\n PRODUCT_CEILING,\n ),\n [firestore, hostId],\n { idField: '$id' },\n )\n const { rows: readProducts, truncated: productsTruncated } =\n ceilingedWindow<any>(productDocs, PRODUCT_CEILING)\n const products: ProductRow[] = useMemo(\n () =>\n [...readProducts]\n .filter((product: any) => !product.deletedAt)\n .map((product: any) => ({\n ...CommerceModel.liftLegacyProduct(product),\n $id: product.$id,\n })),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [productDocs],\n )\n // Content collections (AGL-81) live in the same `hosts/{hostId}/collections`\n // subcollection. This used to keep them out by requiring a non-empty\n // `name`, which held only because the Content page happens to write\n // `displayName` — a content doc that ever acquired a `name` (an import, a\n // hand edit) would land in this list, and its Delete reached the\n // recursiveDelete route (AGL-947). The shared classifier is the real\n // check (AGL-954); the route re-checks it, and AGL-1324 now refuses any\n // collection with entries besides.\n const commerceCollections: CollectionRow[] = useMemo(\n () => readCollections.filter(Aglyn.isHostCollectionKind('catalog')),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [collectionDocs],\n )\n\n // Categories ordered as a walked tree: parents before children.\n const categories: Array<CategoryRow & { depth: number }> = useMemo(() => {\n const rows = [...readCategories] as CategoryRow[]\n rows.sort(\n (a, b) => (a.order ?? 0) - (b.order ?? 0) || a.name.localeCompare(b.name),\n )\n const byParent = new Map<string | null, CategoryRow[]>()\n for (const row of rows) {\n const key = row.parentId ?? null\n byParent.set(key, [...(byParent.get(key) ?? []), row])\n }\n const walked: Array<CategoryRow & { depth: number }> = []\n const walk = (parentId: string | null, depth: number) => {\n for (const row of byParent.get(parentId) ?? []) {\n walked.push({ ...row, depth })\n if (depth < 4) walk(row.$id, depth + 1)\n }\n }\n walk(null, 0)\n // Orphans (parent deleted) still show, at the root.\n for (const row of rows) {\n if (!walked.some((item) => item.$id === row.$id)) {\n walked.push({ ...row, depth: 0 })\n }\n }\n return walked\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [categoryDocs])\n\n /*\n * Both pages are SLICES: the rows are already in hand, and the tree walk,\n * the parent picker and the slug check all need every one of them.\n */\n const [categoryPage, setCategoryPage] = useState(0)\n const [categoryPageSize, setCategoryPageSize] = useState(\n TABLE_PAGE_SIZE_DEFAULT,\n )\n const visibleCategories = useMemo(\n () =>\n categories.slice(\n categoryPage * categoryPageSize,\n categoryPage * categoryPageSize + categoryPageSize,\n ),\n [categories, categoryPage, categoryPageSize],\n )\n const [collectionPage, setCollectionPage] = useState(0)\n const [collectionPageSize, setCollectionPageSize] = useState(\n TABLE_PAGE_SIZE_DEFAULT,\n )\n const visibleCollections = useMemo(\n () =>\n commerceCollections.slice(\n collectionPage * collectionPageSize,\n collectionPage * collectionPageSize + collectionPageSize,\n ),\n [commerceCollections, collectionPage, collectionPageSize],\n )\n\n const [categoryDraft, setCategoryDraft] = useState<{\n id: string | null\n name: string\n parentId: string\n } | null>(null)\n const [collectionDraft, setCollectionDraft] = useState<\n (CommerceModel.HostCollection & { id: string | null }) | null\n >(null)\n\n const handleCategorySave = useCallback(async () => {\n if (!categoryDraft?.name.trim()) return\n const id = categoryDraft.id ?? Aglyn.createResourceUid()\n /**\n * Refuse an EDIT whose seed the server never confirmed (AGL-1358).\n *\n * The payload is narrower than most sites in this issue, but `parentId`\n * is carried off the seeded row on every save whether or not the author\n * opened the parent picker — so renaming a category against a cached read\n * can move it, and the whole subtree under it, back to a parent someone\n * had already reorganised away from.\n *\n * Only the edit path. A NEW category is built from blanks at a fresh uid\n * and can overwrite nothing, and the first snapshot of any listener is\n * `fromCache: true`, so guarding a create would refuse a save that was\n * never unsafe.\n *\n * The guard WRAPS the write — an early return is a shape you can keep\n * while losing the protection.\n */\n const verdict = await writeGuardedBySeed(\n {\n subject: 'category',\n unreadable: Boolean(categoryDraft.id) && categoriesStatus === 'error',\n fromCache: Boolean(categoryDraft.id) && categoriesFromCache,\n },\n async () => {\n /**\n * `merge: true`, because this payload is NARROWER than the document\n * (AGL-1372). A replacing write deletes every stored key the form\n * does not send, and this form sends four:\n *\n * - `order` — the tree position. Both sorts read it (the walk above,\n * and `queryPublicCatalog`'s facet chips), and nothing in this card\n * can set it, so it is not the form's to send: a rename dropped it\n * and the category fell back to `?? 0`, reordering the storefront's\n * filter chips.\n * - `createdAt` — written at creation by the seeder, never by this\n * card, so a rename erased it too.\n *\n * Carrying `order` in the payload would have fixed the field we\n * happened to notice and left `createdAt`, plus whatever the document\n * grows next. Merging fixes the shape. Nothing here needs delete\n * semantics — `parentId` clears to an explicit `null`, which merges.\n */\n await setDoc(\n doc(firestore, 'hosts', hostId, 'productCategories', id),\n {\n name: categoryDraft.name.trim().slice(0, 80),\n slug: CommerceModel.commerceSlug(categoryDraft.name),\n parentId: categoryDraft.parentId || null,\n updatedAt: Timestamp.now(),\n },\n { merge: true },\n )\n },\n )\n // Before `setCategoryDraft(null)`, so a refusal keeps the dialog open\n // with what was typed.\n if (!verdict.ok) {\n return void enqueueSnackbar(verdict.message, {\n variant: 'warning',\n persist: false,\n })\n }\n setCategoryDraft(null)\n enqueueSnackbar('Category saved', { variant: 'success', persist: false })\n }, [\n categoryDraft,\n firestore,\n hostId,\n enqueueSnackbar,\n categoriesStatus,\n categoriesFromCache,\n ])\n\n const handleCategoryDelete = useCallback(\n (category: CategoryRow) => async () => {\n const confirmed = await confirm({\n title: 'Delete this category?',\n description:\n `Products keep their other categories; children of ` +\n `\"${category.name}\" move to the top level.`,\n confirmationText: 'Delete',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n /**\n * Refuse the whole sequence when the rows it reads were never confirmed\n * by the server (AGL-1358).\n *\n * The reparent is this issue's shape at its least visible: the author\n * opened no editor, so there is nothing on screen to look stale, and\n * `children` is read straight out of the cache. The write itself is\n * now narrow (see below), so a stale row can no longer be copied back\n * over a child — but WHICH rows are children is still a cached answer.\n *\n * The guard encloses the DELETE as well, for the reason the site\n * details rename did: `children` is computed from the same seed, so a\n * cached read can miss children entirely, and deleting the parent\n * without reparenting them leaves them pointing at a category that no\n * longer exists. Half of this sequence is worse than none of it.\n */\n const verdict = await writeGuardedBySeed(\n {\n subject: 'categories',\n unreadable: categoriesStatus === 'error',\n fromCache: categoriesFromCache,\n },\n async () => {\n // Reparent children to root, then remove.\n const children = (categoryDocs ?? []).filter(\n (row: any) => row.parentId === category.$id,\n )\n /**\n * Write only the field the reparent changes (AGL-1374).\n *\n * `{...child}` spread the listener row, and that row carries a\n * SYNTHETIC `$id` — `idField: '$id'` stamps the document id onto\n * the in-memory object, where nothing persists it. Spreading it\n * into the payload persisted it: every delete-with-children added\n * a real `$id` key to each child, permanently, and a child\n * reparented twice could end up carrying one that no longer\n * matched its own document id. Nothing reads it, so nothing broke\n * — it is the listener's bookkeeping leaking into storage, and\n * once there no reader can tell it from a real field.\n *\n * `{ parentId: null }` with `{ merge: true }` is what the reparent\n * actually means, and it is the stronger fix than stripping `$id`\n * off a full spread: the old write had no options argument, so it\n * was also a whole-document REPLACE of a cached row — the AGL-1358\n * hazard in miniature (and AGL-1372's, one collection over). A\n * narrow merge cannot carry a synthetic key it never names, and\n * cannot rewrite a field the delete has no business touching.\n *\n * `null` is a value, not a deletion, so it merges: the child ends\n * up at the top level, which is what the confirmation promised.\n */\n for (const child of children) {\n await setDoc(\n doc(firestore, 'hosts', hostId, 'productCategories', child.$id),\n { parentId: null },\n { merge: true },\n )\n }\n await deleteDoc(\n doc(firestore, 'hosts', hostId, 'productCategories', category.$id),\n )\n },\n )\n // This path had no report of its own. A delete that silently does\n // nothing after the user confirmed it reads as a delete that worked.\n if (!verdict.ok) {\n enqueueSnackbar(verdict.message, {\n variant: 'warning',\n persist: false,\n })\n }\n },\n [\n confirm,\n categoryDocs,\n firestore,\n hostId,\n enqueueSnackbar,\n categoriesStatus,\n categoriesFromCache,\n ],\n )\n\n const draftSlug = collectionDraft\n ? collectionDraft.slug || CommerceModel.commerceSlug(collectionDraft.name)\n : ''\n // The slug is the collection's public address at /collections/{slug} and\n // nothing enforced uniqueness (AGL-957) — a second one at the same slug\n // made the first unreachable with no error anywhere. Checked against the\n // catalog collections only; content collections have their own namespace.\n const slugTaken =\n collectionDraft !== null &&\n Aglyn.isCollectionSlugTaken(\n draftSlug,\n 'catalog',\n commerceCollections,\n collectionDraft.id,\n )\n const collectionError = collectionDraft\n ? collectionDraft.name\n ? (CommerceModel.validateCollection({\n ...collectionDraft,\n slug: draftSlug,\n }) ??\n (slugTaken\n ? `Another collection already serves /collections/${draftSlug}`\n : null))\n : null\n : null\n\n const previewMatches = useMemo(() => {\n if (!collectionDraft) return []\n const candidate: CommerceModel.HostCollection = {\n ...collectionDraft,\n slug: collectionDraft.slug || CommerceModel.commerceSlug(collectionDraft.name),\n }\n return products.filter((product) =>\n CommerceModel.matchesCollection(product, candidate, product.$id),\n )\n }, [collectionDraft, products])\n\n const handleCollectionSave = useCallback(async () => {\n if (!collectionDraft?.name.trim() || collectionError) return\n const { id: draftId, ...data } = collectionDraft\n // Both create and rename go through the route (AGL-978): this save writes\n // the whole document including `slug`, which is the collection's public\n // address and is claimed transactionally there. Rules deny a client\n // create, and freeze `slug`/`kind` on update.\n /**\n * Refuse an UPDATE whose seed the server never confirmed (AGL-1358).\n *\n * The transport is the route rather than a client `setDoc`, but the shape\n * is the one this issue is about: `data` is the whole stored row copied\n * out of the listener, and the route writes what it is sent. `productIds`\n * is the manual membership, so a cached seed drops every product added\n * since that snapshot and the storefront blocks pointing at the\n * collection go empty; `rules` and `matchAll` do the same for a smart\n * collection. That the write leaves the browser over HTTP changes who\n * performs it, not what it destroys.\n *\n * Only the update path. A CREATE is built from blanks, and the route\n * claims a fresh slug transactionally, so it can overwrite nothing.\n *\n * The guard WRAPS the request — an early return is a shape you can keep\n * while losing the protection.\n */\n let verdict: Awaited<ReturnType<typeof writeGuardedBySeed>>\n try {\n verdict = await writeGuardedBySeed(\n {\n subject: 'collection',\n unreadable: Boolean(draftId) && collectionsStatus === 'error',\n fromCache: Boolean(draftId) && collectionsFromCache,\n },\n async () => {\n const response = await authorizedFetch(\n user,\n '/api/hosts/collections',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n hostId,\n action: draftId ? 'update' : 'create',\n kind: 'catalog',\n ...(draftId ? { id: draftId } : {}),\n data: {\n ...data,\n name: collectionDraft.name.trim().slice(0, 80),\n slug: draftSlug,\n },\n }),\n },\n )\n const result = await response.json().catch(() => ({}))\n if (!response.ok) {\n throw new Error(result?.error ?? 'Collection save failed')\n }\n },\n )\n } catch (error: any) {\n return void enqueueSnackbar(error?.message ?? 'Collection save failed', {\n variant: 'error',\n })\n }\n // Before `setCollectionDraft(null)`, so a refusal keeps the dialog open\n // with the membership that was picked.\n if (!verdict.ok) {\n return void enqueueSnackbar(verdict.message, {\n variant: 'warning',\n persist: false,\n })\n }\n setCollectionDraft(null)\n enqueueSnackbar('Collection saved', { variant: 'success', persist: false })\n }, [\n collectionDraft,\n collectionError,\n draftSlug,\n user,\n hostId,\n enqueueSnackbar,\n collectionsStatus,\n collectionsFromCache,\n ])\n\n const handleCollectionDelete = useCallback(\n (row: CollectionRow) => async () => {\n const confirmed = await confirm({\n title: 'Delete this collection?',\n // NOT a cascade any more (AGL-1324/AGL-1336): the route REFUSES a\n // collection anything still depends on. Promising to take the\n // entries with it was the opposite of what happens, and the two\n // blockers are the whole point of the feature — say them before the\n // button is armed, not in a 409 afterwards.\n description:\n `Storefront blocks pointing at \"${row.name}\" go empty. The delete ` +\n 'is refused while the collection still has entries, or while a ' +\n 'screen uses it as a list or entry template — empty it and detach ' +\n 'those screens first. It also takes the site admin role.',\n confirmationText: 'Delete',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n // A collection owns an `entries` subcollection (the Content page's\n // published entries) and Firestore doesn't cascade, so deleting the\n // doc from here stranded them — still editor-writable through the\n // host catch-all rule, just unreachable. recursiveDelete is\n // Admin-SDK-only, hence the route (AGL-947). Since AGL-1324 the route\n // also refuses rather than cascading; the 409's message names the\n // blockers and is surfaced by the catch below.\n try {\n const response = await authorizedFetch(user, '/api/resources/erase', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n scope: 'hosts',\n scopeId: hostId,\n kind: 'collections',\n id: row.$id,\n // The route re-checks this server-side (AGL-954): a stale client\n // must not be able to recursiveDelete a content collection's\n // entries through the catalog card.\n collectionKind: 'catalog',\n }),\n })\n const result = await response.json().catch(() => ({}))\n if (!response.ok) {\n throw new Error(result?.error ?? 'Collection delete failed')\n }\n } catch (error: any) {\n return void enqueueSnackbar(error?.message ?? 'Collection delete failed', {\n variant: 'error',\n })\n }\n enqueueSnackbar('Collection deleted', { variant: 'success', persist: false })\n },\n [confirm, user, hostId, enqueueSnackbar],\n )\n\n /**\n * How many products a collection holds — over the CATALOG WINDOW.\n *\n * Rendered with \"at least\" when the probe found a product past the ceiling,\n * because past that point this is a lower bound and printing it as a total\n * is the count-that-is-a-window-length defect. The number itself is honest\n * either way; only the claim around it changes.\n */\n const collectionCount = (row: CollectionRow) =>\n products.filter((product) =>\n CommerceModel.matchesCollection(product, row, product.$id),\n ).length\n /*\n * \"at least\", or nothing at all.\n *\n * Every count on this card is computed over `products`, which is the catalog\n * WINDOW rather than the catalog. While the probe finds a product past the\n * ceiling those counts are lower bounds, and printing one as a total is the\n * count-that-is-a-window-length defect this ceiling exists to make visible.\n *\n * Keyed on the probe rather than on `products.length >= PRODUCT_CEILING`,\n * because a catalog of exactly the ceiling is complete: nothing is missing,\n * and a comparison would put \"at least\" on a number that is exact.\n */\n const countPrefix = productsTruncated ? 'at least ' : ''\n\n const updateRule = (\n index: number,\n patch: Partial<CommerceModel.CollectionRule> | null,\n ) => {\n if (!collectionDraft) return\n const rules = [...(collectionDraft.rules ?? [])]\n if (patch === null) rules.splice(index, 1)\n else\n rules[index] = {\n field: 'tag',\n op: 'eq',\n value: '',\n ...rules[index],\n ...patch,\n }\n setCollectionDraft({ ...collectionDraft, rules })\n }\n\n return (\n <CardDisplay\n header={'Categories & collections'}\n help={pluginDocsHelp('catalog', { anchor: '#categories-and-tags' })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1}>\n <Typography variant=\"subtitle2\">{'Categories'}</Typography>\n {categories.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Group products into a browsable tree (e.g. Brakes → Pads).'}\n </Typography>\n ) : (\n visibleCategories.map((category) => (\n <Stack\n key={category.$id}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center', pl: category.depth * 2 }}\n >\n <Typography variant=\"body2\" sx={{ flex: 1 }} noWrap>\n {category.name}\n <Typography\n component=\"span\"\n variant=\"caption\"\n color=\"text.secondary\"\n >\n {` /${category.slug}`}\n </Typography>\n </Typography>\n <Button\n size=\"small\"\n onClick={() =>\n setCategoryDraft({\n id: category.$id,\n name: category.name,\n parentId: category.parentId ?? '',\n })\n }\n >\n {'Edit'}\n </Button>\n <Button\n size=\"small\"\n color=\"error\"\n onClick={handleCategoryDelete(category)}\n >\n {'Delete'}\n </Button>\n </Stack>\n ))\n )}\n {categories.length === 0 ? null : (\n <ListPagination\n page={categoryPage}\n pageSize={categoryPageSize}\n rowCount={visibleCategories.length}\n // The categories the card HOLDS — a client slice of rows already\n // read, so the total is known exactly.\n count={categories.length}\n onPageChange={setCategoryPage}\n onPageSizeChange={setCategoryPageSize}\n />\n )}\n {categoriesTruncated ? (\n <Alert severity=\"info\">\n {`Showing ${CATEGORY_CEILING} categories, ordered by id. This ` +\n 'catalog has more — a category whose parent is past that ' +\n 'boundary is drawn at the top level here rather than under it.'}\n </Alert>\n ) : null}\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n onClick={() => setCategoryDraft({ id: null, name: '', parentId: '' })}\n >\n {'Add category'}\n </Button>\n\n <Divider sx={{ my: 1 }} />\n <Typography variant=\"subtitle2\">{'Collections'}</Typography>\n {visibleCollections.map((row) => (\n <Stack\n key={row.$id}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <Typography variant=\"body2\" sx={{ flex: 1 }} noWrap>\n {row.name}\n <Typography\n component=\"span\"\n variant=\"caption\"\n color=\"text.secondary\"\n >\n {` · ${row.mode ?? 'manual'} · ${countPrefix}${collectionCount(\n row,\n )} products`}\n </Typography>\n </Typography>\n <Button\n size=\"small\"\n onClick={() =>\n setCollectionDraft({\n id: row.$id,\n name: row.name,\n slug: row.slug ?? '',\n mode: row.mode ?? 'manual',\n productIds: row.productIds ?? [],\n rules: row.rules ?? [],\n matchAll: row.matchAll !== false,\n })\n }\n >\n {'Edit'}\n </Button>\n <Button size=\"small\" color=\"error\" onClick={handleCollectionDelete(row)}>\n {'Delete'}\n </Button>\n </Stack>\n ))}\n {commerceCollections.length === 0 ? null : (\n <ListPagination\n page={collectionPage}\n pageSize={collectionPageSize}\n rowCount={visibleCollections.length}\n // The CATALOG collections, which is what this list is. Not the\n // window's length: content collections share the subcollection\n // and are classified out before this count is taken.\n count={commerceCollections.length}\n onPageChange={setCollectionPage}\n onPageSizeChange={setCollectionPageSize}\n />\n )}\n {collectionsTruncated ? (\n <Alert severity=\"info\">\n {`Showing ${COLLECTION_CEILING} collections, ordered by id. This ` +\n 'site has more — the slug check below only covers the ones ' +\n 'listed here, so an address may already be taken by one that ' +\n 'is not.'}\n </Alert>\n ) : null}\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n onClick={() =>\n setCollectionDraft({\n id: null,\n name: '',\n slug: '',\n mode: 'manual',\n productIds: [],\n rules: [],\n matchAll: true,\n })\n }\n >\n {'Add collection'}\n </Button>\n </Stack>\n\n <Dialog\n open={Boolean(categoryDraft)}\n onClose={() => setCategoryDraft(null)}\n maxWidth=\"xs\"\n fullWidth\n >\n <DialogTitle>\n {categoryDraft?.id ? 'Edit category' : 'New category'}\n </DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <TextField\n label=\"Name\"\n value={categoryDraft?.name ?? ''}\n onChange={(event) =>\n setCategoryDraft((prev) =>\n prev ? { ...prev, name: event.target.value } : prev,\n )\n }\n size=\"small\"\n autoFocus\n sx={{ mt: 1 }}\n />\n <TextField\n label=\"Parent category\"\n value={categoryDraft?.parentId ?? ''}\n onChange={(event) =>\n setCategoryDraft((prev) =>\n prev ? { ...prev, parentId: event.target.value } : prev,\n )\n }\n size=\"small\"\n select\n >\n <MenuItem value=\"\">{'None (top level)'}</MenuItem>\n {/* The whole set, not `visibleCategories` — a parent picker\n that offered only the current page could not reparent a\n category under one two pages away. */}\n {categories\n .filter((category) => category.$id !== categoryDraft?.id)\n .map((category) => (\n <MenuItem key={category.$id} value={category.$id}>\n {`${'— '.repeat(category.depth)}${category.name}`}\n </MenuItem>\n ))}\n </TextField>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setCategoryDraft(null)}>{'Cancel'}</Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={!categoryDraft?.name.trim()}\n onClick={handleCategorySave}\n >\n {'Save'}\n </Button>\n </DialogActions>\n </Dialog>\n\n <Dialog\n open={Boolean(collectionDraft)}\n onClose={() => setCollectionDraft(null)}\n maxWidth=\"sm\"\n fullWidth\n >\n <DialogTitle>\n {collectionDraft?.id ? 'Edit collection' : 'New collection'}\n </DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n <TextField\n label=\"Name\"\n value={collectionDraft?.name ?? ''}\n onChange={(event) =>\n setCollectionDraft((prev) =>\n prev ? { ...prev, name: event.target.value } : prev,\n )\n }\n size=\"small\"\n autoFocus\n sx={{ mt: 1 }}\n error={slugTaken}\n helperText={\n collectionDraft?.name ? `/collections/${draftSlug}` : undefined\n }\n />\n <TextField\n label=\"Mode\"\n value={collectionDraft?.mode ?? 'manual'}\n onChange={(event) =>\n setCollectionDraft((prev) =>\n prev\n ? { ...prev, mode: event.target.value as 'manual' | 'smart' }\n : prev,\n )\n }\n size=\"small\"\n select\n >\n <MenuItem value=\"manual\">{'Manual — pick products'}</MenuItem>\n <MenuItem value=\"smart\">{'Smart — rule based'}</MenuItem>\n </TextField>\n {collectionDraft?.mode === 'manual' ? (\n <Autocomplete\n multiple\n options={products}\n getOptionLabel={(product) => product.name}\n isOptionEqualToValue={(option, value) => option.$id === value.$id}\n value={products.filter((product) =>\n (collectionDraft.productIds ?? []).includes(product.$id),\n )}\n onChange={(_event, picked) =>\n setCollectionDraft((prev) =>\n prev\n ? { ...prev, productIds: picked.map((item) => item.$id) }\n : prev,\n )\n }\n renderInput={(params) => (\n <TextField {...params} label=\"Products\" size=\"small\" />\n )}\n />\n ) : (\n <>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\">{'Match'}</Typography>\n <Switch\n size=\"small\"\n checked={collectionDraft?.matchAll !== false}\n onChange={(event) =>\n setCollectionDraft((prev) =>\n prev ? { ...prev, matchAll: event.target.checked } : prev,\n )\n }\n />\n <Typography variant=\"body2\">\n {collectionDraft?.matchAll !== false\n ? 'all rules'\n : 'any rule'}\n </Typography>\n </Stack>\n {(collectionDraft?.rules ?? []).map((rule, index) => (\n <Stack key={index} direction=\"row\" spacing={1}>\n <TextField\n value={rule.field}\n onChange={(event) =>\n updateRule(index, {\n field: event.target.value as CommerceModel.CollectionRuleField,\n })\n }\n size=\"small\"\n select\n sx={{ width: 130 }}\n >\n {RULE_FIELDS.map((field) => (\n <MenuItem key={field.value} value={field.value}>\n {field.label}\n </MenuItem>\n ))}\n </TextField>\n <TextField\n value={rule.op}\n onChange={(event) =>\n updateRule(index, {\n op: event.target.value as CommerceModel.CollectionRuleOp,\n })\n }\n size=\"small\"\n select\n sx={{ width: 110 }}\n >\n {RULE_OPS.map((op) => (\n <MenuItem key={op.value} value={op.value}>\n {op.label}\n </MenuItem>\n ))}\n </TextField>\n {rule.field === 'categoryId' ? (\n <TextField\n value={rule.value}\n onChange={(event) =>\n updateRule(index, { value: event.target.value })\n }\n size=\"small\"\n select\n sx={{ flex: 1 }}\n >\n {categories.map((category) => (\n <MenuItem key={category.$id} value={category.$id}>\n {category.name}\n </MenuItem>\n ))}\n </TextField>\n ) : (\n <TextField\n value={rule.value}\n onChange={(event) =>\n updateRule(index, {\n value:\n rule.field === 'priceUsd'\n ? Number(event.target.value)\n : event.target.value,\n })\n }\n size=\"small\"\n sx={{ flex: 1 }}\n placeholder={rule.field === 'type' ? 'physical' : 'Value'}\n />\n )}\n <Button\n size=\"small\"\n color=\"error\"\n onClick={() => updateRule(index, null)}\n >\n {'✕'}\n </Button>\n </Stack>\n ))}\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n onClick={() =>\n updateRule(collectionDraft?.rules?.length ?? 0, {})\n }\n >\n {'Add rule'}\n </Button>\n </>\n )}\n {collectionError ? (\n <Alert severity=\"warning\">{collectionError}</Alert>\n ) : null}\n {collectionDraft ? (\n <Stack direction=\"row\" spacing={0.5} sx={{ flexWrap: 'wrap' }}>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Matches ${countPrefix}${previewMatches.length} products: `}\n </Typography>\n {previewMatches.slice(0, 6).map((product) => (\n <Chip key={product.$id} label={product.name} size=\"small\" />\n ))}\n {previewMatches.length > 6 ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`+${previewMatches.length - 6} more`}\n </Typography>\n ) : null}\n </Stack>\n ) : null}\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setCollectionDraft(null)}>{'Cancel'}</Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={!collectionDraft?.name.trim() || Boolean(collectionError)}\n onClick={handleCollectionSave}\n >\n {'Save'}\n </Button>\n </DialogActions>\n </Dialog>\n </CardDisplay>\n )\n}\nCatalogOrganizationCard.displayName = 'CatalogOrganizationCard'\n\nexport default CatalogOrganizationCard\n"],"names":["Aglyn","CommerceModel","CardDisplay","useConfirmationContext","useSnackbar","Timestamp","Alert","Autocomplete","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","Divider","MenuItem","Stack","Switch","TextField","Typography","collection","deleteDoc","doc","setDoc","useCallback","useMemo","useState","useFirestore","useUser","ceilingedWindow","collectionCeiling","useFirestoreCollection","writeGuardedBySeed","ListPagination","TABLE_PAGE_SIZE_DEFAULT","pluginDocsHelp","authorizedFetch","CATEGORY_CEILING","COLLECTION_CEILING","PRODUCT_CEILING","RULE_FIELDS","value","label","RULE_OPS","CatalogOrganizationCard","props","hostId","firestore","enqueueSnackbar","confirm","data","user","categoryDocs","status","categoriesStatus","fromCache","categoriesFromCache","idField","rows","readCategories","truncated","categoriesTruncated","collectionDocs","collectionsStatus","collectionsFromCache","readCollections","collectionsTruncated","productDocs","readProducts","productsTruncated","products","filter","product","deletedAt","map","liftLegacyProduct","$id","commerceCollections","isHostCollectionKind","categories","sort","a","b","order","name","localeCompare","byParent","Map","row","key","parentId","set","get","walked","walk","depth","push","some","item","categoryPage","setCategoryPage","categoryPageSize","setCategoryPageSize","visibleCategories","slice","collectionPage","setCollectionPage","collectionPageSize","setCollectionPageSize","visibleCollections","categoryDraft","setCategoryDraft","collectionDraft","setCollectionDraft","handleCategorySave","trim","id","createResourceUid","verdict","subject","unreadable","Boolean","slug","commerceSlug","updatedAt","now","merge","ok","message","variant","persist","handleCategoryDelete","category","confirmed","title","description","confirmationText","confirmationButtonProps","color","then","catch","children","child","draftSlug","slugTaken","isCollectionSlugTaken","collectionError","validateCollection","previewMatches","candidate","matchesCollection","handleCollectionSave","draftId","response","method","headers","body","JSON","stringify","action","kind","result","json","Error","error","handleCollectionDelete","scope","scopeId","collectionKind","collectionCount","length","countPrefix","updateRule","index","patch","rules","splice","field","op","header","help","anchor","contentGutterX","contentGutterY","spacing","direction","sx","alignItems","pl","flex","noWrap","component","size","onClick","page","pageSize","rowCount","count","onPageChange","onPageSizeChange","severity","alignSelf","my","mode","productIds","matchAll","open","onClose","maxWidth","fullWidth","display","flexDirection","gap","onChange","event","prev","target","autoFocus","mt","select","repeat","disabled","helperText","undefined","multiple","options","getOptionLabel","isOptionEqualToValue","option","includes","_event","picked","renderInput","params","checked","rule","width","Number","placeholder","flexWrap","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;;AAEA,YAAYA,WAAW,eAAc;AACrC,YAAYC,mBAAmB,uBAAa;AAC5C,SAASC,WAAW,EAAEC,sBAAs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/**
|
|
5
|
+
* Commerce analytics (AGL-327): revenue trend (14 days), order count,
|
|
6
|
+
* AOV, channel split, and top products computed from the loaded order
|
|
7
|
+
* window; storefront GA4 events mirror the funnel into the site's own
|
|
8
|
+
* Google Analytics.
|
|
9
|
+
*
|
|
10
|
+
* Gated on `commerceAnalytics` since AGL-2056. AGL-1938 made that flag
|
|
11
|
+
* non-inert by gating `CommerceGlanceCard` — the dashboard WIDGET — and
|
|
12
|
+
* stopped there, leaving this, the actual Analytics tab, open to every
|
|
13
|
+
* plan. `commerce` is true from Starter; `commerceAnalytics` is false
|
|
14
|
+
* until Pro, so a Starter org read the widget's upgrade prompt and then
|
|
15
|
+
* found the whole paid surface one tab over.
|
|
16
|
+
*
|
|
17
|
+
* The gate is client-side because it has to be: the numbers are derived
|
|
18
|
+
* from `hosts/{hostId}/orders`, which this org may legitimately read, so
|
|
19
|
+
* there is no server boundary to put it behind. That makes it a packaging
|
|
20
|
+
* claim rather than a security one — which is exactly why it has to be
|
|
21
|
+
* applied at EVERY surface or the claim is simply untrue.
|
|
22
|
+
*/
|
|
23
|
+
export declare function CommerceAnalyticsCard(props: CommerceAnalyticsCardProps): import("react").JSX.Element;
|
|
24
|
+
export declare namespace CommerceAnalyticsCard {
|
|
25
|
+
var displayName: string;
|
|
26
|
+
}
|
|
27
|
+
export default CommerceAnalyticsCard;
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
import * as CommerceModel from "../../model/index.js";
|
|
20
|
+
import { checkEntitlement, pluginDocsHelp } from "@aglyn/aglyn";
|
|
21
|
+
import { AppLink, CardDisplay } from "@aglyn/shared-ui-jsx";
|
|
22
|
+
import { Alert, Box, Stack, Typography } from "@mui/material";
|
|
23
|
+
import { collection, limit, orderBy, query, where } from "firebase/firestore";
|
|
24
|
+
import { useMemo } from "react";
|
|
25
|
+
import { ceilingedWindow, useConsoleHostRoute, useFirestore, useOrgPlan } from "@aglyn/tenant-feature-instance";
|
|
26
|
+
import { useFirestoreCollection } from "@aglyn/tenant-feature-instance";
|
|
27
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
28
|
+
/**
|
|
29
|
+
* The widest span any figure on this card is computed over. The trend is
|
|
30
|
+
* fourteen days and the totals are thirty, so thirty is what the query asks
|
|
31
|
+
* for — the card reads the period it reports rather than a fixed slab of
|
|
32
|
+
* all-time orders that may or may not overlap it.
|
|
33
|
+
*/ const ANALYTICS_WINDOW_MS = 30 * DAY_MS;
|
|
34
|
+
/**
|
|
35
|
+
* The safety bound on that window, for a store selling more in a month than
|
|
36
|
+
* any of these figures can usefully be read from.
|
|
37
|
+
*
|
|
38
|
+
* Every tile here is an aggregate, so a truncated read understates rather than
|
|
39
|
+
* shortens — a sum over part of a period is not a smaller list, it is a wrong
|
|
40
|
+
* number. That is why the probe drives a rendered disclosure instead of a
|
|
41
|
+
* silent slice.
|
|
42
|
+
*/ const ANALYTICS_ORDER_CEILING = 500;
|
|
43
|
+
const usd = (cents)=>`$${(cents / 100).toFixed(2)}`;
|
|
44
|
+
/**
|
|
45
|
+
* Commerce analytics (AGL-327): revenue trend (14 days), order count,
|
|
46
|
+
* AOV, channel split, and top products computed from the loaded order
|
|
47
|
+
* window; storefront GA4 events mirror the funnel into the site's own
|
|
48
|
+
* Google Analytics.
|
|
49
|
+
*
|
|
50
|
+
* Gated on `commerceAnalytics` since AGL-2056. AGL-1938 made that flag
|
|
51
|
+
* non-inert by gating `CommerceGlanceCard` — the dashboard WIDGET — and
|
|
52
|
+
* stopped there, leaving this, the actual Analytics tab, open to every
|
|
53
|
+
* plan. `commerce` is true from Starter; `commerceAnalytics` is false
|
|
54
|
+
* until Pro, so a Starter org read the widget's upgrade prompt and then
|
|
55
|
+
* found the whole paid surface one tab over.
|
|
56
|
+
*
|
|
57
|
+
* The gate is client-side because it has to be: the numbers are derived
|
|
58
|
+
* from `hosts/{hostId}/orders`, which this org may legitimately read, so
|
|
59
|
+
* there is no server boundary to put it behind. That makes it a packaging
|
|
60
|
+
* claim rather than a security one — which is exactly why it has to be
|
|
61
|
+
* applied at EVERY surface or the claim is simply untrue.
|
|
62
|
+
*/ export function CommerceAnalyticsCard(props) {
|
|
63
|
+
const { hostId } = props;
|
|
64
|
+
// Console routes are /[orgSlug]/hosts/[subdomain]/… (AGL-673); this
|
|
65
|
+
// component only has a host doc id.
|
|
66
|
+
const consoleRoute = useConsoleHostRoute(hostId);
|
|
67
|
+
const { org, ready: orgReady } = useOrgPlan(hostId);
|
|
68
|
+
const entitled = checkEntitlement(org, 'commerceAnalytics');
|
|
69
|
+
const firestore = useFirestore();
|
|
70
|
+
/*
|
|
71
|
+
* Anchored once per mount so the query identity is stable; recomputing it
|
|
72
|
+
* per render would rebuild the listener and re-read the window each pass.
|
|
73
|
+
*/ const since = useMemo(()=>Date.now() - ANALYTICS_WINDOW_MS, []);
|
|
74
|
+
/**
|
|
75
|
+
* `createdAtMs` is the field every order writer in the plugin stamps, and
|
|
76
|
+
* the one `reconcile-stock` already walks the collection by. `createdAt` is
|
|
77
|
+
* not interchangeable: the orders collection group is indexed on
|
|
78
|
+
* `createdAtMs` alone, and a range on a field a document lacks drops that
|
|
79
|
+
* document rather than mis-placing it.
|
|
80
|
+
*
|
|
81
|
+
* Range and order are the same field, so no composite index is needed beyond
|
|
82
|
+
* the `createdAtMs` override already declared.
|
|
83
|
+
*/ const { data: orderDocs } = useFirestoreCollection(()=>query(collection(firestore, 'hosts', hostId, 'orders'), where('createdAtMs', '>=', since), orderBy('createdAtMs', 'desc'), limit(ANALYTICS_ORDER_CEILING + 1)), [
|
|
84
|
+
firestore,
|
|
85
|
+
hostId,
|
|
86
|
+
since
|
|
87
|
+
], {
|
|
88
|
+
idField: '$id'
|
|
89
|
+
});
|
|
90
|
+
const orderWindow = useMemo(()=>ceilingedWindow(orderDocs != null ? orderDocs : undefined, ANALYTICS_ORDER_CEILING), [
|
|
91
|
+
orderDocs
|
|
92
|
+
]);
|
|
93
|
+
const stats = useMemo(()=>{
|
|
94
|
+
const now = Date.now();
|
|
95
|
+
// The range predicate admits only documents that carry `createdAtMs`, so
|
|
96
|
+
// the figures below read it directly.
|
|
97
|
+
// What counts as a sale, and what one brought in, are the model's rules
|
|
98
|
+
// (`order-figures.ts`), which the insight readers sum by too: a pending or
|
|
99
|
+
// canceled order is not money, a rehearsal checkout is not revenue, and a
|
|
100
|
+
// refund comes off.
|
|
101
|
+
const orders = orderWindow.rows.filter((order)=>CommerceModel.orderCountsAsSale(order)).map((order)=>_extends({}, CommerceModel.liftLegacyOrder(order), {
|
|
102
|
+
createdAtMs: order.createdAtMs
|
|
103
|
+
}));
|
|
104
|
+
const paidCents = (order)=>CommerceModel.orderPaidCents(order);
|
|
105
|
+
const window30 = orders.filter((order)=>now - order.createdAtMs < 30 * DAY_MS);
|
|
106
|
+
const revenue30 = window30.reduce((sum, order)=>sum + paidCents(order), 0);
|
|
107
|
+
const days = Array.from({
|
|
108
|
+
length: 14
|
|
109
|
+
}, (_item, index)=>{
|
|
110
|
+
const dayStart = now - (13 - index) * DAY_MS;
|
|
111
|
+
const cents = orders.filter((order)=>order.createdAtMs >= dayStart - dayStart % DAY_MS && order.createdAtMs < dayStart - dayStart % DAY_MS + DAY_MS).reduce((sum, order)=>sum + paidCents(order), 0);
|
|
112
|
+
return cents;
|
|
113
|
+
});
|
|
114
|
+
const channels = {};
|
|
115
|
+
for (const order of window30){
|
|
116
|
+
var _order_channel, _channels_channel;
|
|
117
|
+
const channel = (_order_channel = order.channel) != null ? _order_channel : 'online';
|
|
118
|
+
channels[channel] = ((_channels_channel = channels[channel]) != null ? _channels_channel : 0) + paidCents(order);
|
|
119
|
+
}
|
|
120
|
+
const productCents = new Map();
|
|
121
|
+
for (const order of window30){
|
|
122
|
+
var _order_lineItems;
|
|
123
|
+
for (const line of (_order_lineItems = order.lineItems) != null ? _order_lineItems : []){
|
|
124
|
+
var _productCents_get;
|
|
125
|
+
const entry = (_productCents_get = productCents.get(line.productId)) != null ? _productCents_get : {
|
|
126
|
+
name: line.name,
|
|
127
|
+
cents: 0
|
|
128
|
+
};
|
|
129
|
+
entry.cents += line.unitAmountCents * line.quantity;
|
|
130
|
+
productCents.set(line.productId, entry);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const topProducts = [
|
|
134
|
+
...productCents.values()
|
|
135
|
+
].sort((a, b)=>b.cents - a.cents).slice(0, 5);
|
|
136
|
+
return {
|
|
137
|
+
revenue30,
|
|
138
|
+
orders30: window30.length,
|
|
139
|
+
aov: window30.length ? Math.round(revenue30 / window30.length) : 0,
|
|
140
|
+
days,
|
|
141
|
+
channels,
|
|
142
|
+
topProducts
|
|
143
|
+
};
|
|
144
|
+
}, [
|
|
145
|
+
orderWindow
|
|
146
|
+
]);
|
|
147
|
+
const maxDay = Math.max(1, ...stats.days);
|
|
148
|
+
if (!orgReady) {
|
|
149
|
+
// `checkEntitlement(undefined)` resolves the FREE tier rather than
|
|
150
|
+
// "unknown" (see `useOrgPlan`), and this card's "no" is an upsell —
|
|
151
|
+
// never accuse a paying org of being unentitled while the plan doc is
|
|
152
|
+
// still in flight. Same three-state shape as `CommerceGlanceCard`.
|
|
153
|
+
return /*#__PURE__*/ _jsx(CardDisplay, {
|
|
154
|
+
header: 'Commerce analytics (30 days)',
|
|
155
|
+
help: pluginDocsHelp('commerce', {
|
|
156
|
+
anchor: '#orders',
|
|
157
|
+
excerpt: 'Revenue, orders and average order value over the last 30 days, ' + 'each against the 30 days before it. Pending and canceled orders ' + 'are left out — neither is money.'
|
|
158
|
+
}),
|
|
159
|
+
contentGutterX: true,
|
|
160
|
+
contentGutterY: true,
|
|
161
|
+
children: /*#__PURE__*/ _jsx(Typography, {
|
|
162
|
+
variant: "body2",
|
|
163
|
+
color: "text.secondary",
|
|
164
|
+
children: 'Checking your plan…'
|
|
165
|
+
})
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
if (!entitled) {
|
|
169
|
+
return /*#__PURE__*/ _jsx(CardDisplay, {
|
|
170
|
+
header: 'Commerce analytics (30 days)',
|
|
171
|
+
help: pluginDocsHelp('commerce', {
|
|
172
|
+
anchor: '#orders',
|
|
173
|
+
excerpt: 'Revenue, orders and average order value over the last 30 days, ' + 'each against the 30 days before it. Pending and canceled orders ' + 'are left out — neither is money.'
|
|
174
|
+
}),
|
|
175
|
+
contentGutterX: true,
|
|
176
|
+
contentGutterY: true,
|
|
177
|
+
children: /*#__PURE__*/ _jsx(Alert, {
|
|
178
|
+
severity: "info",
|
|
179
|
+
action: consoleRoute.orgSlug ? /*#__PURE__*/ _jsx(AppLink, {
|
|
180
|
+
componentVariant: "button",
|
|
181
|
+
color: "inherit",
|
|
182
|
+
size: "small",
|
|
183
|
+
href: `/${consoleRoute.orgSlug}/billing`,
|
|
184
|
+
children: 'Upgrade'
|
|
185
|
+
}) : undefined,
|
|
186
|
+
children: 'Commerce analytics — revenue trend, orders, average order ' + 'value, channel split and top products — is a Pro feature. ' + 'Every order is still being recorded, so the numbers are ' + 'waiting the moment you upgrade.'
|
|
187
|
+
})
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
return /*#__PURE__*/ _jsx(CardDisplay, {
|
|
191
|
+
header: 'Commerce analytics (30 days)',
|
|
192
|
+
help: pluginDocsHelp('commerce', {
|
|
193
|
+
anchor: '#orders',
|
|
194
|
+
excerpt: 'Revenue, orders and average order value over the last 30 days, ' + 'each against the 30 days before it. Pending and canceled orders ' + 'are left out — neither is money.'
|
|
195
|
+
}),
|
|
196
|
+
contentGutterX: true,
|
|
197
|
+
contentGutterY: true,
|
|
198
|
+
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
199
|
+
spacing: 2,
|
|
200
|
+
children: [
|
|
201
|
+
/*#__PURE__*/ _jsx(Stack, {
|
|
202
|
+
direction: "row",
|
|
203
|
+
spacing: 3,
|
|
204
|
+
children: [
|
|
205
|
+
[
|
|
206
|
+
'Revenue',
|
|
207
|
+
usd(stats.revenue30)
|
|
208
|
+
],
|
|
209
|
+
[
|
|
210
|
+
'Orders',
|
|
211
|
+
String(stats.orders30)
|
|
212
|
+
],
|
|
213
|
+
[
|
|
214
|
+
'Avg order',
|
|
215
|
+
usd(stats.aov)
|
|
216
|
+
]
|
|
217
|
+
].map(([label, value])=>/*#__PURE__*/ _jsxs(Box, {
|
|
218
|
+
children: [
|
|
219
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
220
|
+
variant: "caption",
|
|
221
|
+
color: "text.secondary",
|
|
222
|
+
children: label
|
|
223
|
+
}),
|
|
224
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
225
|
+
variant: "h6",
|
|
226
|
+
children: value
|
|
227
|
+
})
|
|
228
|
+
]
|
|
229
|
+
}, label))
|
|
230
|
+
}),
|
|
231
|
+
orderWindow.truncated ? /*#__PURE__*/ _jsx(Alert, {
|
|
232
|
+
severity: "info",
|
|
233
|
+
children: `This store took more than ${ANALYTICS_ORDER_CEILING} orders in the last 30 days. Every figure here is computed from the ${ANALYTICS_ORDER_CEILING} most recent of them, so each one reads low.`
|
|
234
|
+
}) : null,
|
|
235
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
236
|
+
children: [
|
|
237
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
238
|
+
variant: "caption",
|
|
239
|
+
color: "text.secondary",
|
|
240
|
+
children: 'Last 14 days'
|
|
241
|
+
}),
|
|
242
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
243
|
+
sx: {
|
|
244
|
+
display: 'flex',
|
|
245
|
+
gap: 0.5,
|
|
246
|
+
alignItems: 'flex-end',
|
|
247
|
+
height: 56
|
|
248
|
+
},
|
|
249
|
+
children: stats.days.map((cents, index)=>/*#__PURE__*/ _jsx(Box, {
|
|
250
|
+
title: usd(cents),
|
|
251
|
+
sx: {
|
|
252
|
+
flex: 1,
|
|
253
|
+
bgcolor: 'primary.main',
|
|
254
|
+
opacity: cents ? 0.9 : 0.25,
|
|
255
|
+
borderRadius: 0.5,
|
|
256
|
+
height: `${Math.max(6, Math.round(cents / maxDay * 100))}%`
|
|
257
|
+
}
|
|
258
|
+
}, index))
|
|
259
|
+
})
|
|
260
|
+
]
|
|
261
|
+
}),
|
|
262
|
+
/*#__PURE__*/ _jsx(Stack, {
|
|
263
|
+
direction: "row",
|
|
264
|
+
spacing: 2,
|
|
265
|
+
children: Object.entries(stats.channels).map(([channel, cents])=>/*#__PURE__*/ _jsx(Typography, {
|
|
266
|
+
variant: "body2",
|
|
267
|
+
color: "text.secondary",
|
|
268
|
+
children: `${channel}: ${usd(cents)}`
|
|
269
|
+
}, channel))
|
|
270
|
+
}),
|
|
271
|
+
stats.topProducts.length ? /*#__PURE__*/ _jsxs(Box, {
|
|
272
|
+
children: [
|
|
273
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
274
|
+
variant: "caption",
|
|
275
|
+
color: "text.secondary",
|
|
276
|
+
children: 'Top products'
|
|
277
|
+
}),
|
|
278
|
+
stats.topProducts.map((product)=>/*#__PURE__*/ _jsxs(Stack, {
|
|
279
|
+
direction: "row",
|
|
280
|
+
spacing: 1,
|
|
281
|
+
children: [
|
|
282
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
283
|
+
variant: "body2",
|
|
284
|
+
sx: {
|
|
285
|
+
flex: 1
|
|
286
|
+
},
|
|
287
|
+
noWrap: true,
|
|
288
|
+
children: product.name
|
|
289
|
+
}),
|
|
290
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
291
|
+
variant: "body2",
|
|
292
|
+
children: usd(product.cents)
|
|
293
|
+
})
|
|
294
|
+
]
|
|
295
|
+
}, product.name))
|
|
296
|
+
]
|
|
297
|
+
}) : null,
|
|
298
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
299
|
+
variant: "caption",
|
|
300
|
+
color: "text.secondary",
|
|
301
|
+
children: 'Storefront funnel events (view_item, add_to_cart, ' + 'begin_checkout, purchase) also mirror into your Google ' + 'Analytics when connected.'
|
|
302
|
+
})
|
|
303
|
+
]
|
|
304
|
+
})
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
CommerceAnalyticsCard.displayName = 'CommerceAnalyticsCard';
|
|
308
|
+
export default CommerceAnalyticsCard;
|
|
309
|
+
|
|
310
|
+
//# sourceMappingURL=commerce-analytics-card.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/commerce-analytics-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport * as CommerceModel from '../../model'\nimport { checkEntitlement, pluginDocsHelp } from '@aglyn/aglyn'\nimport { AppLink, CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { Alert, Box, Stack, Typography } from '@mui/material'\nimport { collection, limit, orderBy, query, where } from 'firebase/firestore'\nimport { useMemo } from 'react'\nimport {\n ceilingedWindow,\n useConsoleHostRoute,\n useFirestore,\n useOrgPlan,\n} from '@aglyn/tenant-feature-instance'\nimport { useFirestoreCollection } from '@aglyn/tenant-feature-instance'\n\nexport interface CommerceAnalyticsCardProps {\n hostId: string\n}\n\nconst DAY_MS = 24 * 60 * 60 * 1000\n\n/**\n * The widest span any figure on this card is computed over. The trend is\n * fourteen days and the totals are thirty, so thirty is what the query asks\n * for — the card reads the period it reports rather than a fixed slab of\n * all-time orders that may or may not overlap it.\n */\nconst ANALYTICS_WINDOW_MS = 30 * DAY_MS\n\n/**\n * The safety bound on that window, for a store selling more in a month than\n * any of these figures can usefully be read from.\n *\n * Every tile here is an aggregate, so a truncated read understates rather than\n * shortens — a sum over part of a period is not a smaller list, it is a wrong\n * number. That is why the probe drives a rendered disclosure instead of a\n * silent slice.\n */\nconst ANALYTICS_ORDER_CEILING = 500\nconst usd = (cents: number) => `$${(cents / 100).toFixed(2)}`\n\n/**\n * Commerce analytics (AGL-327): revenue trend (14 days), order count,\n * AOV, channel split, and top products computed from the loaded order\n * window; storefront GA4 events mirror the funnel into the site's own\n * Google Analytics.\n *\n * Gated on `commerceAnalytics` since AGL-2056. AGL-1938 made that flag\n * non-inert by gating `CommerceGlanceCard` — the dashboard WIDGET — and\n * stopped there, leaving this, the actual Analytics tab, open to every\n * plan. `commerce` is true from Starter; `commerceAnalytics` is false\n * until Pro, so a Starter org read the widget's upgrade prompt and then\n * found the whole paid surface one tab over.\n *\n * The gate is client-side because it has to be: the numbers are derived\n * from `hosts/{hostId}/orders`, which this org may legitimately read, so\n * there is no server boundary to put it behind. That makes it a packaging\n * claim rather than a security one — which is exactly why it has to be\n * applied at EVERY surface or the claim is simply untrue.\n */\nexport function CommerceAnalyticsCard(props: CommerceAnalyticsCardProps) {\n const { hostId } = props\n // Console routes are /[orgSlug]/hosts/[subdomain]/… (AGL-673); this\n // component only has a host doc id.\n const consoleRoute = useConsoleHostRoute(hostId)\n const { org, ready: orgReady } = useOrgPlan(hostId)\n const entitled = checkEntitlement(org as never, 'commerceAnalytics')\n const firestore = useFirestore()\n /*\n * Anchored once per mount so the query identity is stable; recomputing it\n * per render would rebuild the listener and re-read the window each pass.\n */\n const since = useMemo(() => Date.now() - ANALYTICS_WINDOW_MS, [])\n /**\n * `createdAtMs` is the field every order writer in the plugin stamps, and\n * the one `reconcile-stock` already walks the collection by. `createdAt` is\n * not interchangeable: the orders collection group is indexed on\n * `createdAtMs` alone, and a range on a field a document lacks drops that\n * document rather than mis-placing it.\n *\n * Range and order are the same field, so no composite index is needed beyond\n * the `createdAtMs` override already declared.\n */\n const { data: orderDocs } = useFirestoreCollection<any>(\n () =>\n query(\n collection(firestore, 'hosts', hostId, 'orders'),\n where('createdAtMs', '>=', since),\n orderBy('createdAtMs', 'desc'),\n limit(ANALYTICS_ORDER_CEILING + 1),\n ),\n [firestore, hostId, since],\n { idField: '$id' },\n )\n const orderWindow = useMemo(\n () => ceilingedWindow<any>(orderDocs ?? undefined, ANALYTICS_ORDER_CEILING),\n [orderDocs],\n )\n\n const stats = useMemo(() => {\n const now = Date.now()\n // The range predicate admits only documents that carry `createdAtMs`, so\n // the figures below read it directly.\n // What counts as a sale, and what one brought in, are the model's rules\n // (`order-figures.ts`), which the insight readers sum by too: a pending or\n // canceled order is not money, a rehearsal checkout is not revenue, and a\n // refund comes off.\n const orders = orderWindow.rows\n .filter((order: any) => CommerceModel.orderCountsAsSale(order))\n .map((order: any) => ({\n ...CommerceModel.liftLegacyOrder(order),\n createdAtMs: order.createdAtMs,\n }))\n const paidCents = (order: any) => CommerceModel.orderPaidCents(order)\n const window30 = orders.filter(\n (order: any) => now - order.createdAtMs < 30 * DAY_MS,\n )\n const revenue30 = window30.reduce(\n (sum: number, order: any) => sum + paidCents(order),\n 0,\n )\n const days = Array.from({ length: 14 }, (_item, index) => {\n const dayStart = now - (13 - index) * DAY_MS\n const cents = orders\n .filter(\n (order: any) =>\n order.createdAtMs >= dayStart - (dayStart % DAY_MS) &&\n order.createdAtMs < dayStart - (dayStart % DAY_MS) + DAY_MS,\n )\n .reduce((sum: number, order: any) => sum + paidCents(order), 0)\n return cents\n })\n const channels: Record<string, number> = {}\n for (const order of window30) {\n const channel = order.channel ?? 'online'\n channels[channel] = (channels[channel] ?? 0) + paidCents(order)\n }\n const productCents = new Map<string, { name: string; cents: number }>()\n for (const order of window30) {\n for (const line of order.lineItems ?? []) {\n const entry = productCents.get(line.productId) ?? {\n name: line.name,\n cents: 0,\n }\n entry.cents += line.unitAmountCents * line.quantity\n productCents.set(line.productId, entry)\n }\n }\n const topProducts = [...productCents.values()]\n .sort((a, b) => b.cents - a.cents)\n .slice(0, 5)\n return {\n revenue30,\n orders30: window30.length,\n aov: window30.length ? Math.round(revenue30 / window30.length) : 0,\n days,\n channels,\n topProducts,\n }\n }, [orderWindow])\n\n const maxDay = Math.max(1, ...stats.days)\n\n if (!orgReady) {\n // `checkEntitlement(undefined)` resolves the FREE tier rather than\n // \"unknown\" (see `useOrgPlan`), and this card's \"no\" is an upsell —\n // never accuse a paying org of being unentitled while the plan doc is\n // still in flight. Same three-state shape as `CommerceGlanceCard`.\n return (\n <CardDisplay\n header={'Commerce analytics (30 days)'}\n help={pluginDocsHelp('commerce', {\n anchor: '#orders',\n excerpt:\n 'Revenue, orders and average order value over the last 30 days, ' +\n 'each against the 30 days before it. Pending and canceled orders ' +\n 'are left out — neither is money.',\n })}\n contentGutterX\n contentGutterY\n >\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Checking your plan…'}\n </Typography>\n </CardDisplay>\n )\n }\n\n if (!entitled) {\n return (\n <CardDisplay\n header={'Commerce analytics (30 days)'}\n help={pluginDocsHelp('commerce', {\n anchor: '#orders',\n excerpt:\n 'Revenue, orders and average order value over the last 30 days, ' +\n 'each against the 30 days before it. Pending and canceled orders ' +\n 'are left out — neither is money.',\n })}\n contentGutterX\n contentGutterY\n >\n <Alert\n severity=\"info\"\n action={\n consoleRoute.orgSlug ? (\n <AppLink\n componentVariant=\"button\"\n color=\"inherit\"\n size=\"small\"\n href={`/${consoleRoute.orgSlug}/billing`}\n >\n {'Upgrade'}\n </AppLink>\n ) : undefined\n }\n >\n {'Commerce analytics — revenue trend, orders, average order ' +\n 'value, channel split and top products — is a Pro feature. ' +\n 'Every order is still being recorded, so the numbers are ' +\n 'waiting the moment you upgrade.'}\n </Alert>\n </CardDisplay>\n )\n }\n\n return (\n <CardDisplay\n header={'Commerce analytics (30 days)'}\n help={pluginDocsHelp('commerce', {\n anchor: '#orders',\n excerpt:\n 'Revenue, orders and average order value over the last 30 days, ' +\n 'each against the 30 days before it. Pending and canceled orders ' +\n 'are left out — neither is money.',\n })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2}>\n <Stack direction=\"row\" spacing={3}>\n {[\n ['Revenue', usd(stats.revenue30)],\n ['Orders', String(stats.orders30)],\n ['Avg order', usd(stats.aov)],\n ].map(([label, value]) => (\n <Box key={label}>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {label}\n </Typography>\n <Typography variant=\"h6\">{value}</Typography>\n </Box>\n ))}\n </Stack>\n {orderWindow.truncated ? (\n <Alert severity=\"info\">\n {`This store took more than ${ANALYTICS_ORDER_CEILING} orders in the last 30 days. Every figure here is computed from the ${ANALYTICS_ORDER_CEILING} most recent of them, so each one reads low.`}\n </Alert>\n ) : null}\n <Box>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Last 14 days'}\n </Typography>\n <Box sx={{ display: 'flex', gap: 0.5, alignItems: 'flex-end', height: 56 }}>\n {stats.days.map((cents, index) => (\n <Box\n key={index}\n title={usd(cents)}\n sx={{\n flex: 1,\n bgcolor: 'primary.main',\n opacity: cents ? 0.9 : 0.25,\n borderRadius: 0.5,\n height: `${Math.max(6, Math.round((cents / maxDay) * 100))}%`,\n }}\n />\n ))}\n </Box>\n </Box>\n <Stack direction=\"row\" spacing={2}>\n {Object.entries(stats.channels).map(([channel, cents]) => (\n <Typography key={channel} variant=\"body2\" color=\"text.secondary\">\n {`${channel}: ${usd(cents)}`}\n </Typography>\n ))}\n </Stack>\n {stats.topProducts.length ? (\n <Box>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Top products'}\n </Typography>\n {stats.topProducts.map((product) => (\n <Stack key={product.name} direction=\"row\" spacing={1}>\n <Typography variant=\"body2\" sx={{ flex: 1 }} noWrap>\n {product.name}\n </Typography>\n <Typography variant=\"body2\">{usd(product.cents)}</Typography>\n </Stack>\n ))}\n </Box>\n ) : null}\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Storefront funnel events (view_item, add_to_cart, ' +\n 'begin_checkout, purchase) also mirror into your Google ' +\n 'Analytics when connected.'}\n </Typography>\n </Stack>\n </CardDisplay>\n )\n}\nCommerceAnalyticsCard.displayName = 'CommerceAnalyticsCard'\n\nexport default CommerceAnalyticsCard\n"],"names":["CommerceModel","checkEntitlement","pluginDocsHelp","AppLink","CardDisplay","Alert","Box","Stack","Typography","collection","limit","orderBy","query","where","useMemo","ceilingedWindow","useConsoleHostRoute","useFirestore","useOrgPlan","useFirestoreCollection","DAY_MS","ANALYTICS_WINDOW_MS","ANALYTICS_ORDER_CEILING","usd","cents","toFixed","CommerceAnalyticsCard","props","hostId","consoleRoute","org","ready","orgReady","entitled","firestore","since","Date","now","data","orderDocs","idField","orderWindow","undefined","stats","orders","rows","filter","order","orderCountsAsSale","map","liftLegacyOrder","createdAtMs","paidCents","orderPaidCents","window30","revenue30","reduce","sum","days","Array","from","length","_item","index","dayStart","channels","channel","productCents","Map","line","lineItems","entry","get","productId","name","unitAmountCents","quantity","set","topProducts","values","sort","a","b","slice","orders30","aov","Math","round","maxDay","max","header","help","anchor","excerpt","contentGutterX","contentGutterY","variant","color","severity","action","orgSlug","componentVariant","size","href","spacing","direction","String","label","value","truncated","sx","display","gap","alignItems","height","title","flex","bgcolor","opacity","borderRadius","Object","entries","product","noWrap","displayName"],"mappings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othing for hosts without a
|
|
4
|
+
* catalog so non-commerce dashboards stay clean.
|
|
5
|
+
*
|
|
6
|
+
* The figures are the `commerceAnalytics` entitlement — `/pricing` sells
|
|
7
|
+
* "Commerce analytics" as Pro-and-up, and `/product/commerce` calls it "a
|
|
8
|
+
* built-in commerce analytics dashboard". Until AGL-1938 the flag was
|
|
9
|
+
* inert: its ONLY occurrence outside `plan-entitlements.ts` was its own
|
|
10
|
+
* type declaration, and this card carried no check, so every commerce org
|
|
11
|
+
* — Starter included — got the Pro surface for free. The store link and
|
|
12
|
+
* card shell stay ungated; only the measured numbers are the paid part.
|
|
13
|
+
*/
|
|
14
|
+
export declare function CommerceGlanceCard(props: {
|
|
15
|
+
hostId: string;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
export declare namespace CommerceGlanceCard {
|
|
18
|
+
var displayName: string;
|
|
19
|
+
}
|
|
20
|
+
export default CommerceGlanceCard;
|