@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,218 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2026 Aglyn LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/ import { firebaseAdmin, getOrgForHost } from "@aglyn/tenant-data-admin";
|
|
18
|
+
import { storefrontTaxRow } from "./storefront-tax.js";
|
|
19
|
+
/**
|
|
20
|
+
* Writes `storefrontTaxCollected/{stripeId}` for every storefront sale that
|
|
21
|
+
* carried tax (AGL-1904) — the row that makes tax collected under Aglyn's
|
|
22
|
+
* registration visible to Aglyn's own quarterly return.
|
|
23
|
+
*
|
|
24
|
+
* ## The hole this closes
|
|
25
|
+
*
|
|
26
|
+
* AGL-1811 records one `platformRevenue` row per paid invoice and the Texas
|
|
27
|
+
* return is their sum. That collection is deliberately scoped to AGLYN's own
|
|
28
|
+
* charges: the console webhook only writes a row when the invoice's customer
|
|
29
|
+
* resolves through the `stripeCustomers` index, which `writeOrgBilling` stamps
|
|
30
|
+
* for Aglyn's billing customers and nothing else stamps. A storefront
|
|
31
|
+
* shopper's customer is never in it.
|
|
32
|
+
*
|
|
33
|
+
* That scoping is correct for what it was built for and it left a gap: a
|
|
34
|
+
* `mode: 'stripe'` storefront sale charges the shopper tax computed on
|
|
35
|
+
* AGLYN's registrations (measured — see `storefront-tax.ts`), settles it into
|
|
36
|
+
* Aglyn's platform balance, and NOTHING recorded it anywhere Aglyn's return
|
|
37
|
+
* could see. The merchant's order document carries a `totals.taxCents`, but
|
|
38
|
+
* that is the merchant's books, per host, and no return sums it.
|
|
39
|
+
*
|
|
40
|
+
* ## Why a SEPARATE collection rather than more `platformRevenue` rows
|
|
41
|
+
*
|
|
42
|
+
* Structural, and the reason must survive a future tidy-up: a
|
|
43
|
+
* `platformRevenue` row's `netCents` is Aglyn's revenue, and a storefront
|
|
44
|
+
* row's is mostly the MERCHANT's — it transfers straight out to the connected
|
|
45
|
+
* account. Merging the two would make the return's "total sales" figure silently
|
|
46
|
+
* include other companies' receipts. Keeping them in different collections
|
|
47
|
+
* means no query, sum or future refactor can accidentally add them together;
|
|
48
|
+
* the return reports the storefront figures as their own section, and what
|
|
49
|
+
* belongs on which line of a filed return stays a question for the preparer
|
|
50
|
+
* and for counsel rather than one this code answers.
|
|
51
|
+
*
|
|
52
|
+
* ## What is recorded, and what is not
|
|
53
|
+
*
|
|
54
|
+
* Recorded: cart, buy-now, reservation and draft-order sessions, plus every
|
|
55
|
+
* storefront subscription INVOICE (opening cycle and renewals both — the
|
|
56
|
+
* subscription's own `checkout.session.completed` is deliberately skipped so
|
|
57
|
+
* the opening cycle is not counted twice, the same rule AGL-1811 applies).
|
|
58
|
+
*
|
|
59
|
+
* Manual-mode sales are recorded too, with `taxMode: 'manual'`, precisely so
|
|
60
|
+
* the two modes can be told apart at read time instead of being invisible.
|
|
61
|
+
* They are NOT Aglyn-collected and the return never sums them into the
|
|
62
|
+
* Aglyn-liable figure.
|
|
63
|
+
*
|
|
64
|
+
* **Refunds are not yet reflected.** A refunded storefront sale keeps its full
|
|
65
|
+
* tax on this record, so the Aglyn-liable figure is an OVER-statement of what
|
|
66
|
+
* is owed rather than an under-statement. That direction is deliberate:
|
|
67
|
+
* over-stating what is held for the state is correctable at filing time,
|
|
68
|
+
* under-stating it is a shortfall discovered by an auditor. Stated here rather
|
|
69
|
+
* than left to be discovered.
|
|
70
|
+
*
|
|
71
|
+
* Never throws. A recording failure logs and returns — a throw here propagates
|
|
72
|
+
* through `runBillingWebhookHandlers` into a 500 that Stripe redelivers
|
|
73
|
+
* forever, which is the AGL-1743 lesson.
|
|
74
|
+
*/ /** The commerce session types that settle money on the platform account. */ const SESSION_TYPES = new Set([
|
|
75
|
+
'commerce-cart',
|
|
76
|
+
'commerce-order',
|
|
77
|
+
'commerce-reservation',
|
|
78
|
+
'commerce-draft',
|
|
79
|
+
// A paid service booking (AGL-2000). It carries no tax by a stated
|
|
80
|
+
// decision (`bookings/server.ts`), but it is a storefront sale and it was
|
|
81
|
+
// absent from this set entirely — so it was not merely untaxed, it did not
|
|
82
|
+
// appear in the record that would let anyone NOTICE it was untaxed or
|
|
83
|
+
// reconcile it later. An untaxed sale that is recorded reads
|
|
84
|
+
// `taxMode: 'none'`; an unrecorded one reads as nothing at all.
|
|
85
|
+
'booking-payment'
|
|
86
|
+
]);
|
|
87
|
+
/**
|
|
88
|
+
* Session types whose zero tax is a decision taken HERE, not by the merchant
|
|
89
|
+
* (AGL-2000). Their rows are filed even at `taxMode: 'none'`, so an untaxed
|
|
90
|
+
* service or stay is reconcilable instead of merely missing. See the note at
|
|
91
|
+
* the `taxMode === 'none'` gate below.
|
|
92
|
+
*/ const PLATFORM_UNTAXED_TYPES = new Set([
|
|
93
|
+
'booking-payment',
|
|
94
|
+
'commerce-reservation'
|
|
95
|
+
]);
|
|
96
|
+
function stripeKey() {
|
|
97
|
+
var _process_env_STRIPE_SECRET_KEY;
|
|
98
|
+
return String((_process_env_STRIPE_SECRET_KEY = process.env.STRIPE_SECRET_KEY) != null ? _process_env_STRIPE_SECRET_KEY : '');
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A Checkout Session's tax BREAKDOWN, which the webhook payload does not
|
|
102
|
+
* carry: `total_details.breakdown` is an expandable field, so the delivered
|
|
103
|
+
* object states `amount_tax` and nothing about the base it was applied to.
|
|
104
|
+
*
|
|
105
|
+
* Returns the expanded session, or null when the read cannot be made. Null is
|
|
106
|
+
* not a failure that stops the recording — the row is written from the
|
|
107
|
+
* delivered object with `taxLines: []`, and a taxed row with no stated base is
|
|
108
|
+
* COUNTED in the return's `attention` rather than dropped or zeroed.
|
|
109
|
+
*/ async function expandedSession(sessionId) {
|
|
110
|
+
const key = stripeKey();
|
|
111
|
+
if (!key || !sessionId) return null;
|
|
112
|
+
try {
|
|
113
|
+
const response = await fetch(`https://api.stripe.com/v1/checkout/sessions/${encodeURIComponent(sessionId)}?expand[]=total_details.breakdown`, {
|
|
114
|
+
headers: {
|
|
115
|
+
Authorization: `Bearer ${key}`
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
if (!response.ok) return null;
|
|
119
|
+
const body = await response.json().catch(()=>null);
|
|
120
|
+
return (body == null ? void 0 : body.id) ? body : null;
|
|
121
|
+
} catch (unused) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** The host this Stripe object belongs to, from whichever metadata bag. */ function hostIdOf(object) {
|
|
126
|
+
var _ref, _ref1, _ref2;
|
|
127
|
+
var _object_metadata, _object_subscription_details_metadata, _object_subscription_details, _object_parent_subscription_details_metadata, _object_parent_subscription_details, _object_parent;
|
|
128
|
+
return String((_ref = (_ref1 = (_ref2 = object == null ? void 0 : (_object_metadata = object.metadata) == null ? void 0 : _object_metadata.hostId) != null ? _ref2 : object == null ? void 0 : (_object_subscription_details = object.subscription_details) == null ? void 0 : (_object_subscription_details_metadata = _object_subscription_details.metadata) == null ? void 0 : _object_subscription_details_metadata.hostId) != null ? _ref1 : object == null ? void 0 : (_object_parent = object.parent) == null ? void 0 : (_object_parent_subscription_details = _object_parent.subscription_details) == null ? void 0 : (_object_parent_subscription_details_metadata = _object_parent_subscription_details.metadata) == null ? void 0 : _object_parent_subscription_details_metadata.hostId) != null ? _ref : '');
|
|
129
|
+
}
|
|
130
|
+
function metadataTypeOf(object) {
|
|
131
|
+
var _ref, _ref1, _ref2;
|
|
132
|
+
var _object_metadata, _object_subscription_details_metadata, _object_subscription_details, _object_parent_subscription_details_metadata, _object_parent_subscription_details, _object_parent;
|
|
133
|
+
return String((_ref = (_ref1 = (_ref2 = object == null ? void 0 : (_object_metadata = object.metadata) == null ? void 0 : _object_metadata.type) != null ? _ref2 : object == null ? void 0 : (_object_subscription_details = object.subscription_details) == null ? void 0 : (_object_subscription_details_metadata = _object_subscription_details.metadata) == null ? void 0 : _object_subscription_details_metadata.type) != null ? _ref1 : object == null ? void 0 : (_object_parent = object.parent) == null ? void 0 : (_object_parent_subscription_details = _object_parent.subscription_details) == null ? void 0 : (_object_parent_subscription_details_metadata = _object_parent_subscription_details.metadata) == null ? void 0 : _object_parent_subscription_details_metadata.type) != null ? _ref : '');
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Records one storefront sale's tax, or does nothing when this event is not
|
|
137
|
+
* one. Returns the row written, for the specs — never for control flow.
|
|
138
|
+
*/ export async function recordStorefrontTax(type, object) {
|
|
139
|
+
try {
|
|
140
|
+
var _ref, _ref1;
|
|
141
|
+
var _this;
|
|
142
|
+
const metadataType = metadataTypeOf(object);
|
|
143
|
+
const hostId = hostIdOf(object);
|
|
144
|
+
if (!hostId) return null;
|
|
145
|
+
let kind;
|
|
146
|
+
let taxSource = object;
|
|
147
|
+
let manualTaxCents = 0;
|
|
148
|
+
if (type === 'checkout.session.completed' && SESSION_TYPES.has(metadataType) && (object == null ? void 0 : object.payment_status) === 'paid') {
|
|
149
|
+
var _ref2, _ref3;
|
|
150
|
+
var _object_metadata, _object_total_details, _object_automatic_tax;
|
|
151
|
+
kind = 'session';
|
|
152
|
+
// The manual tax rides as an ordinary `line_items[1]` Stripe is never
|
|
153
|
+
// told is tax (AGL-1711), so the session's own metadata snapshot is the
|
|
154
|
+
// only witness to it. A cart session carries no such line at all.
|
|
155
|
+
manualTaxCents = Math.max(0, Number((_ref2 = object == null ? void 0 : (_object_metadata = object.metadata) == null ? void 0 : _object_metadata.taxCents) != null ? _ref2 : 0)) || 0;
|
|
156
|
+
// Expanded whenever Stripe COMPUTED tax on this session — which since
|
|
157
|
+
// AGL-1953 includes a `manual`-mode cart or draft order, where the tax
|
|
158
|
+
// rides a real Tax Rate and Stripe therefore states a `taxable_amount`
|
|
159
|
+
// for it. Gated on the delivered `amount_tax` rather than done
|
|
160
|
+
// unconditionally so the buy-now and POS constructions, which report 0
|
|
161
|
+
// there and answer from metadata, still cost no extra Stripe read.
|
|
162
|
+
const stripeStatedTax = Number((_ref3 = object == null ? void 0 : (_object_total_details = object.total_details) == null ? void 0 : _object_total_details.amount_tax) != null ? _ref3 : 0);
|
|
163
|
+
if ((object == null ? void 0 : (_object_automatic_tax = object.automatic_tax) == null ? void 0 : _object_automatic_tax.enabled) === true || Number.isFinite(stripeStatedTax) && stripeStatedTax > 0) {
|
|
164
|
+
var _ref4, _ref5;
|
|
165
|
+
taxSource = (_ref4 = await expandedSession(String((_ref5 = object == null ? void 0 : object.id) != null ? _ref5 : ''))) != null ? _ref4 : object;
|
|
166
|
+
}
|
|
167
|
+
} else if ((type === 'invoice.paid' || type === 'invoice.payment_succeeded') && metadataType === 'commerce-subscription') {
|
|
168
|
+
// Every cycle including the opening one. The subscription's own
|
|
169
|
+
// `checkout.session.completed` is NOT a second source — recording both
|
|
170
|
+
// would count the opening sale twice (AGL-1811's rule, same reason).
|
|
171
|
+
kind = 'invoice';
|
|
172
|
+
} else {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
const row = storefrontTaxRow(taxSource, {
|
|
176
|
+
kind,
|
|
177
|
+
hostId,
|
|
178
|
+
manualTaxCents
|
|
179
|
+
});
|
|
180
|
+
if (!row) return null;
|
|
181
|
+
// Nothing to file and nothing to explain: no tax computed, no tax charged.
|
|
182
|
+
// A `stripe-automatic` row is kept even at zero tax — that a Stripe Tax
|
|
183
|
+
// sale answered "not collecting" is itself the audit answer to why a
|
|
184
|
+
// jurisdiction is absent from the return.
|
|
185
|
+
//
|
|
186
|
+
// EXCEPT where the absence is AGLYN'S decision rather than the merchant's
|
|
187
|
+
// (AGL-2000). A zero-tax commerce sale means the merchant configured no
|
|
188
|
+
// tax — their call, their liability, nothing here to explain. A booking or
|
|
189
|
+
// a reservation is untaxed because THIS CODEBASE decided not to compute a
|
|
190
|
+
// goods rate on a service or a room (`bookings/server.ts`, `reserve.ts`),
|
|
191
|
+
// and that is exactly the kind of absence somebody has to be able to find
|
|
192
|
+
// later: it is the platform answering a tax question on a merchant's
|
|
193
|
+
// revenue. Dropping those rows made the decision invisible in the one
|
|
194
|
+
// place anyone would go looking for it.
|
|
195
|
+
if (row.taxMode === 'none' && !PLATFORM_UNTAXED_TYPES.has(metadataType)) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
const documentId = String((_ref = object == null ? void 0 : object.id) != null ? _ref : '');
|
|
199
|
+
if (!documentId) return null;
|
|
200
|
+
const orgId = (_ref1 = (_this = await getOrgForHost(hostId).catch(()=>null)) == null ? void 0 : _this.orgId) != null ? _ref1 : null;
|
|
201
|
+
await firebaseAdmin.app().firestore().collection('storefrontTaxCollected').doc(documentId).set(_extends({}, row, {
|
|
202
|
+
orgId,
|
|
203
|
+
recordedAt: firebaseAdmin.firestore.FieldValue.serverTimestamp()
|
|
204
|
+
}), // Keyed by the Stripe object id and merged, so a redelivery — and the
|
|
205
|
+
// `invoice.paid` / `invoice.payment_succeeded` pair Stripe sends for
|
|
206
|
+
// ONE payment — restamps a single document instead of duplicating a
|
|
207
|
+
// taxable sale.
|
|
208
|
+
{
|
|
209
|
+
merge: true
|
|
210
|
+
});
|
|
211
|
+
return row;
|
|
212
|
+
} catch (error) {
|
|
213
|
+
console.error('[AGL-1904] storefront tax recording failed', error);
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
//# sourceMappingURL=storefront-tax-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/server/storefront-tax-record.ts"],"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\nimport { firebaseAdmin, getOrgForHost } from '@aglyn/tenant-data-admin'\nimport { storefrontTaxRow, type StorefrontTaxRow } from './storefront-tax'\n\n/**\n * Writes `storefrontTaxCollected/{stripeId}` for every storefront sale that\n * carried tax (AGL-1904) — the row that makes tax collected under Aglyn's\n * registration visible to Aglyn's own quarterly return.\n *\n * ## The hole this closes\n *\n * AGL-1811 records one `platformRevenue` row per paid invoice and the Texas\n * return is their sum. That collection is deliberately scoped to AGLYN's own\n * charges: the console webhook only writes a row when the invoice's customer\n * resolves through the `stripeCustomers` index, which `writeOrgBilling` stamps\n * for Aglyn's billing customers and nothing else stamps. A storefront\n * shopper's customer is never in it.\n *\n * That scoping is correct for what it was built for and it left a gap: a\n * `mode: 'stripe'` storefront sale charges the shopper tax computed on\n * AGLYN's registrations (measured — see `storefront-tax.ts`), settles it into\n * Aglyn's platform balance, and NOTHING recorded it anywhere Aglyn's return\n * could see. The merchant's order document carries a `totals.taxCents`, but\n * that is the merchant's books, per host, and no return sums it.\n *\n * ## Why a SEPARATE collection rather than more `platformRevenue` rows\n *\n * Structural, and the reason must survive a future tidy-up: a\n * `platformRevenue` row's `netCents` is Aglyn's revenue, and a storefront\n * row's is mostly the MERCHANT's — it transfers straight out to the connected\n * account. Merging the two would make the return's \"total sales\" figure silently\n * include other companies' receipts. Keeping them in different collections\n * means no query, sum or future refactor can accidentally add them together;\n * the return reports the storefront figures as their own section, and what\n * belongs on which line of a filed return stays a question for the preparer\n * and for counsel rather than one this code answers.\n *\n * ## What is recorded, and what is not\n *\n * Recorded: cart, buy-now, reservation and draft-order sessions, plus every\n * storefront subscription INVOICE (opening cycle and renewals both — the\n * subscription's own `checkout.session.completed` is deliberately skipped so\n * the opening cycle is not counted twice, the same rule AGL-1811 applies).\n *\n * Manual-mode sales are recorded too, with `taxMode: 'manual'`, precisely so\n * the two modes can be told apart at read time instead of being invisible.\n * They are NOT Aglyn-collected and the return never sums them into the\n * Aglyn-liable figure.\n *\n * **Refunds are not yet reflected.** A refunded storefront sale keeps its full\n * tax on this record, so the Aglyn-liable figure is an OVER-statement of what\n * is owed rather than an under-statement. That direction is deliberate:\n * over-stating what is held for the state is correctable at filing time,\n * under-stating it is a shortfall discovered by an auditor. Stated here rather\n * than left to be discovered.\n *\n * Never throws. A recording failure logs and returns — a throw here propagates\n * through `runBillingWebhookHandlers` into a 500 that Stripe redelivers\n * forever, which is the AGL-1743 lesson.\n */\n\n/** The commerce session types that settle money on the platform account. */\nconst SESSION_TYPES = new Set([\n 'commerce-cart',\n 'commerce-order',\n 'commerce-reservation',\n 'commerce-draft',\n // A paid service booking (AGL-2000). It carries no tax by a stated\n // decision (`bookings/server.ts`), but it is a storefront sale and it was\n // absent from this set entirely — so it was not merely untaxed, it did not\n // appear in the record that would let anyone NOTICE it was untaxed or\n // reconcile it later. An untaxed sale that is recorded reads\n // `taxMode: 'none'`; an unrecorded one reads as nothing at all.\n 'booking-payment',\n])\n\n/**\n * Session types whose zero tax is a decision taken HERE, not by the merchant\n * (AGL-2000). Their rows are filed even at `taxMode: 'none'`, so an untaxed\n * service or stay is reconcilable instead of merely missing. See the note at\n * the `taxMode === 'none'` gate below.\n */\nconst PLATFORM_UNTAXED_TYPES = new Set(['booking-payment', 'commerce-reservation'])\n\nfunction stripeKey(): string {\n return String(process.env.STRIPE_SECRET_KEY ?? '')\n}\n\n/**\n * A Checkout Session's tax BREAKDOWN, which the webhook payload does not\n * carry: `total_details.breakdown` is an expandable field, so the delivered\n * object states `amount_tax` and nothing about the base it was applied to.\n *\n * Returns the expanded session, or null when the read cannot be made. Null is\n * not a failure that stops the recording — the row is written from the\n * delivered object with `taxLines: []`, and a taxed row with no stated base is\n * COUNTED in the return's `attention` rather than dropped or zeroed.\n */\nasync function expandedSession(sessionId: string): Promise<any | null> {\n const key = stripeKey()\n if (!key || !sessionId) return null\n try {\n const response = await fetch(\n `https://api.stripe.com/v1/checkout/sessions/${encodeURIComponent(\n sessionId,\n )}?expand[]=total_details.breakdown`,\n { headers: { Authorization: `Bearer ${key}` } },\n )\n if (!response.ok) return null\n const body = await response.json().catch(() => null)\n return body?.id ? body : null\n } catch {\n return null\n }\n}\n\n/** The host this Stripe object belongs to, from whichever metadata bag. */\nfunction hostIdOf(object: any): string {\n return String(\n object?.metadata?.hostId ??\n object?.subscription_details?.metadata?.hostId ??\n object?.parent?.subscription_details?.metadata?.hostId ??\n '',\n )\n}\n\nfunction metadataTypeOf(object: any): string {\n return String(\n object?.metadata?.type ??\n object?.subscription_details?.metadata?.type ??\n object?.parent?.subscription_details?.metadata?.type ??\n '',\n )\n}\n\n/**\n * Records one storefront sale's tax, or does nothing when this event is not\n * one. Returns the row written, for the specs — never for control flow.\n */\nexport async function recordStorefrontTax(\n type: string,\n object: any,\n): Promise<StorefrontTaxRow | null> {\n try {\n const metadataType = metadataTypeOf(object)\n const hostId = hostIdOf(object)\n if (!hostId) return null\n\n let kind: 'session' | 'invoice'\n let taxSource = object\n let manualTaxCents = 0\n if (\n type === 'checkout.session.completed' &&\n SESSION_TYPES.has(metadataType) &&\n object?.payment_status === 'paid'\n ) {\n kind = 'session'\n // The manual tax rides as an ordinary `line_items[1]` Stripe is never\n // told is tax (AGL-1711), so the session's own metadata snapshot is the\n // only witness to it. A cart session carries no such line at all.\n manualTaxCents = Math.max(0, Number(object?.metadata?.taxCents ?? 0)) || 0\n // Expanded whenever Stripe COMPUTED tax on this session — which since\n // AGL-1953 includes a `manual`-mode cart or draft order, where the tax\n // rides a real Tax Rate and Stripe therefore states a `taxable_amount`\n // for it. Gated on the delivered `amount_tax` rather than done\n // unconditionally so the buy-now and POS constructions, which report 0\n // there and answer from metadata, still cost no extra Stripe read.\n const stripeStatedTax = Number(\n object?.total_details?.amount_tax ?? 0,\n )\n if (\n object?.automatic_tax?.enabled === true ||\n (Number.isFinite(stripeStatedTax) && stripeStatedTax > 0)\n ) {\n taxSource = (await expandedSession(String(object?.id ?? ''))) ?? object\n }\n } else if (\n (type === 'invoice.paid' || type === 'invoice.payment_succeeded') &&\n metadataType === 'commerce-subscription'\n ) {\n // Every cycle including the opening one. The subscription's own\n // `checkout.session.completed` is NOT a second source — recording both\n // would count the opening sale twice (AGL-1811's rule, same reason).\n kind = 'invoice'\n } else {\n return null\n }\n\n const row = storefrontTaxRow(taxSource, { kind, hostId, manualTaxCents })\n if (!row) return null\n // Nothing to file and nothing to explain: no tax computed, no tax charged.\n // A `stripe-automatic` row is kept even at zero tax — that a Stripe Tax\n // sale answered \"not collecting\" is itself the audit answer to why a\n // jurisdiction is absent from the return.\n //\n // EXCEPT where the absence is AGLYN'S decision rather than the merchant's\n // (AGL-2000). A zero-tax commerce sale means the merchant configured no\n // tax — their call, their liability, nothing here to explain. A booking or\n // a reservation is untaxed because THIS CODEBASE decided not to compute a\n // goods rate on a service or a room (`bookings/server.ts`, `reserve.ts`),\n // and that is exactly the kind of absence somebody has to be able to find\n // later: it is the platform answering a tax question on a merchant's\n // revenue. Dropping those rows made the decision invisible in the one\n // place anyone would go looking for it.\n if (row.taxMode === 'none' && !PLATFORM_UNTAXED_TYPES.has(metadataType)) {\n return null\n }\n\n const documentId = String(object?.id ?? '')\n if (!documentId) return null\n const orgId = (await getOrgForHost(hostId).catch(() => null))?.orgId ?? null\n await firebaseAdmin\n .app()\n .firestore()\n .collection('storefrontTaxCollected')\n .doc(documentId)\n .set(\n {\n ...row,\n orgId,\n recordedAt: firebaseAdmin.firestore.FieldValue.serverTimestamp(),\n },\n // Keyed by the Stripe object id and merged, so a redelivery — and the\n // `invoice.paid` / `invoice.payment_succeeded` pair Stripe sends for\n // ONE payment — restamps a single document instead of duplicating a\n // taxable sale.\n { merge: true },\n )\n return row\n } catch (error) {\n console.error('[AGL-1904] storefront tax recording failed', error)\n return null\n }\n}\n"],"names":["firebaseAdmin","getOrgForHost","storefrontTaxRow","SESSION_TYPES","Set","PLATFORM_UNTAXED_TYPES","stripeKey","process","String","env","STRIPE_SECRET_KEY","expandedSession","sessionId","key","response","fetch","encodeURIComponent","headers","Authorization","ok","body","json","catch","id","hostIdOf","object","metadata","hostId","subscription_details","parent","metadataTypeOf","type","recordStorefrontTax","metadataType","kind","taxSource","manualTaxCents","has","payment_status","Math","max","Number","taxCents","stripeStatedTax","total_details","amount_tax","automatic_tax","enabled","isFinite","row","taxMode","documentId","orgId","app","firestore","collection","doc","set","recordedAt","FieldValue","serverTimestamp","merge","error","console"],"mappings":"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"}
|
|
@@ -0,0 +1,197 @@
|
|
|
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
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* What a storefront sale's TAX decomposes to (AGL-1904) — the record that
|
|
19
|
+
* makes tax collected on a merchant's sale visible to Aglyn's own return.
|
|
20
|
+
*
|
|
21
|
+
* ## The observation this module exists to record
|
|
22
|
+
*
|
|
23
|
+
* Every storefront checkout — cart, buy-now, subscription — creates its
|
|
24
|
+
* Checkout Session on the PLATFORM account: platform secret key, no
|
|
25
|
+
* `Stripe-Account` header, no `on_behalf_of`, with
|
|
26
|
+
* `payment_intent_data[transfer_data][destination]` pointing at the merchant's
|
|
27
|
+
* connected account. `cart-checkout.ts` and `checkout.ts` then set
|
|
28
|
+
* `automatic_tax[enabled]` when the store's tax mode is `stripe`.
|
|
29
|
+
*
|
|
30
|
+
* That was long suspected to mean Stripe Tax computes the shopper's tax
|
|
31
|
+
* against AGLYN's registrations rather than the merchant's. It was MEASURED on
|
|
32
|
+
* 2026-08-18, in test mode, as a two-arm experiment on exactly that session
|
|
33
|
+
* shape (a $100 line, a Texas shopper address, `transfer_data[destination]`
|
|
34
|
+
* set):
|
|
35
|
+
*
|
|
36
|
+
* - **Platform unregistered, destination connected account registered in
|
|
37
|
+
* TX** → `amount_tax: 0`, one breakdown line with
|
|
38
|
+
* `taxability_reason: "not_collecting"`, `taxable_amount: 0`.
|
|
39
|
+
* - **Platform registered in TX, everything else byte-identical** →
|
|
40
|
+
* `amount_tax: 825`, `taxability_reason: "standard_rated"`,
|
|
41
|
+
* `taxable_amount: 10000`, rate 8.25% "Texas".
|
|
42
|
+
*
|
|
43
|
+
* Both sessions reported `automatic_tax.liability: { type: "self" }` — Stripe's
|
|
44
|
+
* own word for "the account this session was created on is the one liable".
|
|
45
|
+
* `transfer_data[destination]` had no effect on tax in either arm.
|
|
46
|
+
*
|
|
47
|
+
* So on a `mode: 'stripe'` store the tax charged to the shopper is computed on
|
|
48
|
+
* Aglyn's registration footprint, lands in Aglyn's platform balance, and is
|
|
49
|
+
* Aglyn's to remit. The live platform account has held an ACTIVE Texas state
|
|
50
|
+
* sales tax registration since 2026-08-17, so this is not hypothetical.
|
|
51
|
+
*
|
|
52
|
+
* **This module describes that mechanism and records the money.** Aglyn IS a
|
|
53
|
+
* marketplace facilitator for storefront sales, and the published Terms say so
|
|
54
|
+
* at §10.7 (AGL-1956). Facilitator status still attaches by operation of
|
|
55
|
+
* law rather than by our say-so, and §10.7 is deliberately narrow — Aglyn
|
|
56
|
+
* collects and remits **where applicable law gives it an obligation**, not
|
|
57
|
+
* universally — so this module still records the mechanism per sale and does
|
|
58
|
+
* not stamp a per-merchant or per-jurisdiction verdict on any row.
|
|
59
|
+
*
|
|
60
|
+
* ## The two store modes are DIFFERENT FACTS and must never be summed
|
|
61
|
+
*
|
|
62
|
+
* `taxMode` is the whole point of this record, and it is derived from
|
|
63
|
+
* `automatic_tax.enabled` — **never** from whether tax lines are present:
|
|
64
|
+
*
|
|
65
|
+
* - **`stripe-automatic`** — Stripe Tax computed it, against whichever
|
|
66
|
+
* account `automatic_tax.liability` names. When that is `platform`, the
|
|
67
|
+
* money is held under Aglyn's registration.
|
|
68
|
+
* - **`manual`** — the merchant's own configured rate
|
|
69
|
+
* (`checkout.ts` / `pos-order.ts`), applied to the merchant's own declared
|
|
70
|
+
* origin. Aglyn's registrations never enter into it and the amount is not
|
|
71
|
+
* Aglyn's to remit.
|
|
72
|
+
*
|
|
73
|
+
* The trap that makes the `automatic_tax.enabled` discriminator load-bearing:
|
|
74
|
+
* a MANUAL-mode subscription renewal carries a real Stripe Tax Rate (AGL-1751
|
|
75
|
+
* attaches one so the tax recurs), so its invoice arrives with a populated
|
|
76
|
+
* `total_taxes[]` — indistinguishable from a Stripe Tax invoice if you look at
|
|
77
|
+
* the tax lines. Summing tax lines would silently book merchant-configured tax
|
|
78
|
+
* as Aglyn-collected. **Read the flag, not the lines.**
|
|
79
|
+
*
|
|
80
|
+
* ## The taxable base is kept, never inferred
|
|
81
|
+
*
|
|
82
|
+
* `taxable_amount` is what a return reports as "taxable sales". Deriving it as
|
|
83
|
+
* `amount ÷ rate` needs a live read to resolve the rate id and rounds wrong at
|
|
84
|
+
* the edges, so it is stored when Stripe states it and left `null` when it
|
|
85
|
+
* does not — and a row whose base cannot be read is COUNTED OUT LOUD by the
|
|
86
|
+
* return rather than treated as a zero-base sale.
|
|
87
|
+
*
|
|
88
|
+
* A Checkout Session's `total_details.breakdown` is not in the webhook payload
|
|
89
|
+
* and must be re-read with `expand[]=total_details.breakdown`; an invoice
|
|
90
|
+
* carries `total_taxes[]` inline. Both land in the same `taxLines` shape.
|
|
91
|
+
*
|
|
92
|
+
* Pure and total: unreadable input answers `null`, never throws — a recording
|
|
93
|
+
* failure must never 500 a webhook into redelivery.
|
|
94
|
+
*/
|
|
95
|
+
import { type StorefrontTaxMode } from '../model/commerce-tax-decision';
|
|
96
|
+
/**
|
|
97
|
+
* Which machinery produced the tax on this sale. See the module note.
|
|
98
|
+
*
|
|
99
|
+
* The union and its derivation live in the MODEL since AGL-2451, because the
|
|
100
|
+
* merchant's order document now carries the same fact (`HostOrder.taxMode`)
|
|
101
|
+
* and two copies of a rule that must agree are one copy too many. Re-exported
|
|
102
|
+
* here so this module stays the place the mechanism is documented.
|
|
103
|
+
*/
|
|
104
|
+
export type { StorefrontTaxMode };
|
|
105
|
+
/**
|
|
106
|
+
* Whose registrations Stripe Tax computed against, from
|
|
107
|
+
* `automatic_tax.liability.type`: `self` (the account the object lives on,
|
|
108
|
+
* i.e. Aglyn's platform) or `account` (a named connected account).
|
|
109
|
+
* Null whenever `taxMode` is not `stripe-automatic`.
|
|
110
|
+
*/
|
|
111
|
+
export type StorefrontTaxLiability = 'platform' | 'connected-account';
|
|
112
|
+
/** One entry of the stored tax breakdown. */
|
|
113
|
+
export interface StorefrontTaxLine {
|
|
114
|
+
amountCents: number;
|
|
115
|
+
/** Stripe's stated reason, e.g. `standard_rated`, `not_collecting`. */
|
|
116
|
+
taxabilityReason: string | null;
|
|
117
|
+
taxRateId: string | null;
|
|
118
|
+
/** Stripe's `taxable_amount`; null when the shape did not carry it. */
|
|
119
|
+
taxableAmountCents: number | null;
|
|
120
|
+
/** e.g. `Texas` — from the expanded rate, for the working papers. */
|
|
121
|
+
jurisdiction: string | null;
|
|
122
|
+
/** The rate's own state code, which is not the shopper's address. */
|
|
123
|
+
rateState: string | null;
|
|
124
|
+
percentage: number | null;
|
|
125
|
+
}
|
|
126
|
+
/** The per-transaction record `storefrontTaxCollected/{stripeId}` stores. */
|
|
127
|
+
export interface StorefrontTaxRow {
|
|
128
|
+
/** `session` for one-time sales, `invoice` for subscription cycles. */
|
|
129
|
+
kind: 'session' | 'invoice';
|
|
130
|
+
hostId: string;
|
|
131
|
+
/** The commerce path — `commerce-cart`, `commerce-order`, … */
|
|
132
|
+
metadataType: string | null;
|
|
133
|
+
taxMode: StorefrontTaxMode;
|
|
134
|
+
taxLiability: StorefrontTaxLiability | null;
|
|
135
|
+
/** The merchant's connected account, when the object names one. */
|
|
136
|
+
connectedAccountId: string | null;
|
|
137
|
+
/** What the shopper actually paid, tax included. */
|
|
138
|
+
grossCents: number;
|
|
139
|
+
taxCents: number;
|
|
140
|
+
/** Gross minus tax. NOT Aglyn's revenue — most of it is the merchant's. */
|
|
141
|
+
netCents: number;
|
|
142
|
+
currency: string;
|
|
143
|
+
/** The jurisdiction input — the shopper's address on the Stripe object. */
|
|
144
|
+
customerAddress: {
|
|
145
|
+
country: string | null;
|
|
146
|
+
state: string | null;
|
|
147
|
+
city: string | null;
|
|
148
|
+
postalCode: string | null;
|
|
149
|
+
} | null;
|
|
150
|
+
taxLines: StorefrontTaxLine[];
|
|
151
|
+
paidAt: Date | null;
|
|
152
|
+
}
|
|
153
|
+
export interface StorefrontTaxContext {
|
|
154
|
+
kind: 'session' | 'invoice';
|
|
155
|
+
hostId: string;
|
|
156
|
+
/**
|
|
157
|
+
* The manual-mode tax `checkout.ts` puts over as an ordinary line item.
|
|
158
|
+
* Stripe is never told it is tax, so no Stripe field carries it and the
|
|
159
|
+
* session's own `metadata[taxCents]` is the only witness (AGL-1711).
|
|
160
|
+
*/
|
|
161
|
+
manualTaxCents?: number;
|
|
162
|
+
}
|
|
163
|
+
/** What one Stripe object says about the tax it carried. */
|
|
164
|
+
export interface ResolvedStorefrontTax {
|
|
165
|
+
/** `automatic_tax.enabled` — the discriminator, never the tax lines. */
|
|
166
|
+
automatic: boolean;
|
|
167
|
+
/** Stripe's own breakdown, present only on a `stripe-automatic` sale. */
|
|
168
|
+
lines: StorefrontTaxLine[];
|
|
169
|
+
taxCents: number;
|
|
170
|
+
taxMode: StorefrontTaxMode;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Reads the tax off one paid session or invoice — the SINGLE derivation, and
|
|
174
|
+
* the reason it is its own exported function (AGL-2451).
|
|
175
|
+
*
|
|
176
|
+
* `storefrontTaxRow` builds the `storefrontTaxCollected` record from it, and
|
|
177
|
+
* the four order-writing doors in `billing-webhook.ts` stamp `HostOrder.taxMode`
|
|
178
|
+
* from it, so an order and the row filed for the same Stripe id cannot state
|
|
179
|
+
* different regimes. Re-deriving the mode beside a second reading of the same
|
|
180
|
+
* object is exactly how the two would drift.
|
|
181
|
+
*
|
|
182
|
+
* Pure and total: unreadable input answers `taxMode: 'none'`, never throws.
|
|
183
|
+
*/
|
|
184
|
+
export declare function resolveStorefrontTax(object: unknown, manualTaxCents?: number): ResolvedStorefrontTax;
|
|
185
|
+
/**
|
|
186
|
+
* Just the regime, for the order-writing doors (AGL-2451). Delegates, so this
|
|
187
|
+
* is the same answer the filed tax record gives for the same object.
|
|
188
|
+
*/
|
|
189
|
+
export declare function storefrontTaxModeOf(object: unknown, manualTaxCents?: number): StorefrontTaxMode;
|
|
190
|
+
/**
|
|
191
|
+
* Decomposes a paid storefront session or invoice into the stored row, or
|
|
192
|
+
* `null` when there is no host to attribute it to.
|
|
193
|
+
*
|
|
194
|
+
* The caller decides WHICH objects reach this — the commerce webhook
|
|
195
|
+
* self-selects on `metadata.type`, exactly as every other section does.
|
|
196
|
+
*/
|
|
197
|
+
export declare function storefrontTaxRow(object: unknown, context: StorefrontTaxContext): StorefrontTaxRow | null;
|