@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.
Files changed (417) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +10 -0
  3. package/package.json +57 -0
  4. package/src/index.d.ts +38 -0
  5. package/src/index.js +38 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/components/account.d.ts +31 -0
  8. package/src/lib/components/account.js +645 -0
  9. package/src/lib/components/account.js.map +1 -0
  10. package/src/lib/components/cart.d.ts +38 -0
  11. package/src/lib/components/cart.js +851 -0
  12. package/src/lib/components/cart.js.map +1 -0
  13. package/src/lib/components/commerce-console-page.d.ts +32 -0
  14. package/src/lib/components/commerce-console-page.js +296 -0
  15. package/src/lib/components/commerce-console-page.js.map +1 -0
  16. package/src/lib/components/commerce-console-sections.d.ts +34 -0
  17. package/src/lib/components/commerce-console-sections.js +62 -0
  18. package/src/lib/components/commerce-console-sections.js.map +1 -0
  19. package/src/lib/components/console/catalog-organization-card.component.d.ts +14 -0
  20. package/src/lib/components/console/catalog-organization-card.component.js +1087 -0
  21. package/src/lib/components/console/catalog-organization-card.component.js.map +1 -0
  22. package/src/lib/components/console/commerce-analytics-card.component.d.ts +27 -0
  23. package/src/lib/components/console/commerce-analytics-card.component.js +310 -0
  24. package/src/lib/components/console/commerce-analytics-card.component.js.map +1 -0
  25. package/src/lib/components/console/commerce-glance-card.component.d.ts +20 -0
  26. package/src/lib/components/console/commerce-glance-card.component.js +340 -0
  27. package/src/lib/components/console/commerce-glance-card.component.js.map +1 -0
  28. package/src/lib/components/console/commerce-stat-tile.component.d.ts +37 -0
  29. package/src/lib/components/console/commerce-stat-tile.component.js +72 -0
  30. package/src/lib/components/console/commerce-stat-tile.component.js.map +1 -0
  31. package/src/lib/components/console/discounts-card.component.d.ts +14 -0
  32. package/src/lib/components/console/discounts-card.component.js +443 -0
  33. package/src/lib/components/console/discounts-card.component.js.map +1 -0
  34. package/src/lib/components/console/entitlement-gate.component.d.ts +76 -0
  35. package/src/lib/components/console/entitlement-gate.component.js +115 -0
  36. package/src/lib/components/console/entitlement-gate.component.js.map +1 -0
  37. package/src/lib/components/console/gift-cards-card.component.d.ts +29 -0
  38. package/src/lib/components/console/gift-cards-card.component.js +379 -0
  39. package/src/lib/components/console/gift-cards-card.component.js.map +1 -0
  40. package/src/lib/components/console/host-coupons-card.component.d.ts +14 -0
  41. package/src/lib/components/console/host-coupons-card.component.js +252 -0
  42. package/src/lib/components/console/host-coupons-card.component.js.map +1 -0
  43. package/src/lib/components/console/host-orders-card.component.d.ts +13 -0
  44. package/src/lib/components/console/host-orders-card.component.js +861 -0
  45. package/src/lib/components/console/host-orders-card.component.js.map +1 -0
  46. package/src/lib/components/console/locations-card.component.d.ts +14 -0
  47. package/src/lib/components/console/locations-card.component.js +256 -0
  48. package/src/lib/components/console/locations-card.component.js.map +1 -0
  49. package/src/lib/components/console/member-posts-card.component.d.ts +8 -0
  50. package/src/lib/components/console/member-posts-card.component.js +283 -0
  51. package/src/lib/components/console/member-posts-card.component.js.map +1 -0
  52. package/src/lib/components/console/newest-site-users-card.component.d.ts +36 -0
  53. package/src/lib/components/console/newest-site-users-card.component.js +126 -0
  54. package/src/lib/components/console/newest-site-users-card.component.js.map +1 -0
  55. package/src/lib/components/console/order-detail-dialog.component.d.ts +28 -0
  56. package/src/lib/components/console/order-detail-dialog.component.js +976 -0
  57. package/src/lib/components/console/order-detail-dialog.component.js.map +1 -0
  58. package/src/lib/components/console/paid-media.d.ts +127 -0
  59. package/src/lib/components/console/paid-media.js +397 -0
  60. package/src/lib/components/console/paid-media.js.map +1 -0
  61. package/src/lib/components/console/payments-settings-card.component.d.ts +13 -0
  62. package/src/lib/components/console/payments-settings-card.component.js +295 -0
  63. package/src/lib/components/console/payments-settings-card.component.js.map +1 -0
  64. package/src/lib/components/console/pos-page.component.d.ts +13 -0
  65. package/src/lib/components/console/pos-page.component.js +916 -0
  66. package/src/lib/components/console/pos-page.component.js.map +1 -0
  67. package/src/lib/components/console/product-editor-dialog.component.d.ts +32 -0
  68. package/src/lib/components/console/product-editor-dialog.component.js +1374 -0
  69. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -0
  70. package/src/lib/components/console/products-hub-card.component.d.ts +16 -0
  71. package/src/lib/components/console/products-hub-card.component.js +1280 -0
  72. package/src/lib/components/console/products-hub-card.component.js.map +1 -0
  73. package/src/lib/components/console/products-hub-zone.component.d.ts +50 -0
  74. package/src/lib/components/console/products-hub-zone.component.js +200 -0
  75. package/src/lib/components/console/products-hub-zone.component.js.map +1 -0
  76. package/src/lib/components/console/recovery-queue-card.component.d.ts +39 -0
  77. package/src/lib/components/console/recovery-queue-card.component.js +262 -0
  78. package/src/lib/components/console/recovery-queue-card.component.js.map +1 -0
  79. package/src/lib/components/console/registers-card.component.d.ts +21 -0
  80. package/src/lib/components/console/registers-card.component.js +296 -0
  81. package/src/lib/components/console/registers-card.component.js.map +1 -0
  82. package/src/lib/components/console/reservations-card.component.d.ts +14 -0
  83. package/src/lib/components/console/reservations-card.component.js +650 -0
  84. package/src/lib/components/console/reservations-card.component.js.map +1 -0
  85. package/src/lib/components/console/reviews-moderation-card.component.d.ts +8 -0
  86. package/src/lib/components/console/reviews-moderation-card.component.js +235 -0
  87. package/src/lib/components/console/reviews-moderation-card.component.js.map +1 -0
  88. package/src/lib/components/console/shipping-settings-card.component.d.ts +38 -0
  89. package/src/lib/components/console/shipping-settings-card.component.js +560 -0
  90. package/src/lib/components/console/shipping-settings-card.component.js.map +1 -0
  91. package/src/lib/components/console/stock-movements-card.component.d.ts +31 -0
  92. package/src/lib/components/console/stock-movements-card.component.js +333 -0
  93. package/src/lib/components/console/stock-movements-card.component.js.map +1 -0
  94. package/src/lib/components/console/store-settings-card.component.d.ts +14 -0
  95. package/src/lib/components/console/store-settings-card.component.js +300 -0
  96. package/src/lib/components/console/store-settings-card.component.js.map +1 -0
  97. package/src/lib/components/console/storefront-tax-summary-card.component.d.ts +73 -0
  98. package/src/lib/components/console/storefront-tax-summary-card.component.js +408 -0
  99. package/src/lib/components/console/storefront-tax-summary-card.component.js.map +1 -0
  100. package/src/lib/components/console/suppliers-card.component.d.ts +8 -0
  101. package/src/lib/components/console/suppliers-card.component.js +328 -0
  102. package/src/lib/components/console/suppliers-card.component.js.map +1 -0
  103. package/src/lib/components/console/tax-settings-card.component.d.ts +14 -0
  104. package/src/lib/components/console/tax-settings-card.component.js +473 -0
  105. package/src/lib/components/console/tax-settings-card.component.js.map +1 -0
  106. package/src/lib/components/gate.d.ts +39 -0
  107. package/src/lib/components/gate.js +202 -0
  108. package/src/lib/components/gate.js.map +1 -0
  109. package/src/lib/components/gated-video.d.ts +40 -0
  110. package/src/lib/components/gated-video.js +366 -0
  111. package/src/lib/components/gated-video.js.map +1 -0
  112. package/src/lib/components/member-feed.d.ts +32 -0
  113. package/src/lib/components/member-feed.js +198 -0
  114. package/src/lib/components/member-feed.js.map +1 -0
  115. package/src/lib/components/member-recovery.d.ts +35 -0
  116. package/src/lib/components/member-recovery.js +313 -0
  117. package/src/lib/components/member-recovery.js.map +1 -0
  118. package/src/lib/components/member-signin.d.ts +35 -0
  119. package/src/lib/components/member-signin.js +257 -0
  120. package/src/lib/components/member-signin.js.map +1 -0
  121. package/src/lib/components/member-signup.d.ts +34 -0
  122. package/src/lib/components/member-signup.js +287 -0
  123. package/src/lib/components/member-signup.js.map +1 -0
  124. package/src/lib/components/newsletter-signup.d.ts +39 -0
  125. package/src/lib/components/newsletter-signup.js +229 -0
  126. package/src/lib/components/newsletter-signup.js.map +1 -0
  127. package/src/lib/components/product-detail.d.ts +38 -0
  128. package/src/lib/components/product-detail.js +1022 -0
  129. package/src/lib/components/product-detail.js.map +1 -0
  130. package/src/lib/components/product-grid.d.ts +67 -0
  131. package/src/lib/components/product-grid.js +909 -0
  132. package/src/lib/components/product-grid.js.map +1 -0
  133. package/src/lib/components/product-reviews.d.ts +32 -0
  134. package/src/lib/components/product-reviews.js +349 -0
  135. package/src/lib/components/product-reviews.js.map +1 -0
  136. package/src/lib/components/related-products.d.ts +33 -0
  137. package/src/lib/components/related-products.js +232 -0
  138. package/src/lib/components/related-products.js.map +1 -0
  139. package/src/lib/components/reservation-widget.d.ts +33 -0
  140. package/src/lib/components/reservation-widget.js +418 -0
  141. package/src/lib/components/reservation-widget.js.map +1 -0
  142. package/src/lib/components/storefront-payment-element-fallback.d.ts +18 -0
  143. package/src/lib/components/storefront-payment-element-fallback.js +51 -0
  144. package/src/lib/components/storefront-payment-element-fallback.js.map +1 -0
  145. package/src/lib/components/storefront-payment-element.d.ts +78 -0
  146. package/src/lib/components/storefront-payment-element.js +156 -0
  147. package/src/lib/components/storefront-payment-element.js.map +1 -0
  148. package/src/lib/components/wishlist.d.ts +46 -0
  149. package/src/lib/components/wishlist.js +304 -0
  150. package/src/lib/components/wishlist.js.map +1 -0
  151. package/src/lib/constants/bundle-common.d.ts +18 -0
  152. package/src/lib/constants/bundle-common.js +18 -0
  153. package/src/lib/constants/bundle-common.js.map +1 -0
  154. package/src/lib/constants/product-filters.d.ts +35 -0
  155. package/src/lib/constants/product-filters.js +109 -0
  156. package/src/lib/constants/product-filters.js.map +1 -0
  157. package/src/lib/model/commerce-cart.d.ts +52 -0
  158. package/src/lib/model/commerce-cart.js +102 -0
  159. package/src/lib/model/commerce-cart.js.map +1 -0
  160. package/src/lib/model/commerce-connect-transfer.d.ts +243 -0
  161. package/src/lib/model/commerce-connect-transfer.js +231 -0
  162. package/src/lib/model/commerce-connect-transfer.js.map +1 -0
  163. package/src/lib/model/commerce-discounts.d.ts +164 -0
  164. package/src/lib/model/commerce-discounts.js +231 -0
  165. package/src/lib/model/commerce-discounts.js.map +1 -0
  166. package/src/lib/model/commerce-dispute.d.ts +124 -0
  167. package/src/lib/model/commerce-dispute.js +225 -0
  168. package/src/lib/model/commerce-dispute.js.map +1 -0
  169. package/src/lib/model/commerce-gift-cards.d.ts +107 -0
  170. package/src/lib/model/commerce-gift-cards.js +121 -0
  171. package/src/lib/model/commerce-gift-cards.js.map +1 -0
  172. package/src/lib/model/commerce-io.d.ts +36 -0
  173. package/src/lib/model/commerce-io.js +245 -0
  174. package/src/lib/model/commerce-io.js.map +1 -0
  175. package/src/lib/model/commerce-orders.d.ts +1040 -0
  176. package/src/lib/model/commerce-orders.js +1022 -0
  177. package/src/lib/model/commerce-orders.js.map +1 -0
  178. package/src/lib/model/commerce-promotions.d.ts +188 -0
  179. package/src/lib/model/commerce-promotions.js +199 -0
  180. package/src/lib/model/commerce-promotions.js.map +1 -0
  181. package/src/lib/model/commerce-reservations.d.ts +175 -0
  182. package/src/lib/model/commerce-reservations.js +157 -0
  183. package/src/lib/model/commerce-reservations.js.map +1 -0
  184. package/src/lib/model/commerce-shipping.d.ts +316 -0
  185. package/src/lib/model/commerce-shipping.js +484 -0
  186. package/src/lib/model/commerce-shipping.js.map +1 -0
  187. package/src/lib/model/commerce-stock-holds.d.ts +199 -0
  188. package/src/lib/model/commerce-stock-holds.js +190 -0
  189. package/src/lib/model/commerce-stock-holds.js.map +1 -0
  190. package/src/lib/model/commerce-subscription-status.d.ts +67 -0
  191. package/src/lib/model/commerce-subscription-status.js +76 -0
  192. package/src/lib/model/commerce-subscription-status.js.map +1 -0
  193. package/src/lib/model/commerce-tax-decision.d.ts +222 -0
  194. package/src/lib/model/commerce-tax-decision.js +165 -0
  195. package/src/lib/model/commerce-tax-decision.js.map +1 -0
  196. package/src/lib/model/commerce-tax.d.ts +176 -0
  197. package/src/lib/model/commerce-tax.js +92 -0
  198. package/src/lib/model/commerce-tax.js.map +1 -0
  199. package/src/lib/model/commerce.d.ts +551 -0
  200. package/src/lib/model/commerce.js +739 -0
  201. package/src/lib/model/commerce.js.map +1 -0
  202. package/src/lib/model/index.d.ts +40 -0
  203. package/src/lib/model/index.js +40 -0
  204. package/src/lib/model/index.js.map +1 -0
  205. package/src/lib/model/order-figures.d.ts +48 -0
  206. package/src/lib/model/order-figures.js +74 -0
  207. package/src/lib/model/order-figures.js.map +1 -0
  208. package/src/lib/model/plugin-permissions.d.ts +23 -0
  209. package/src/lib/model/plugin-permissions.js +34 -0
  210. package/src/lib/model/plugin-permissions.js.map +1 -0
  211. package/src/lib/model/purchase-analytics.d.ts +186 -0
  212. package/src/lib/model/purchase-analytics.js +216 -0
  213. package/src/lib/model/purchase-analytics.js.map +1 -0
  214. package/src/lib/plugin-config.d.ts +62 -0
  215. package/src/lib/plugin-config.js +78 -0
  216. package/src/lib/plugin-config.js.map +1 -0
  217. package/src/lib/plugin.d.ts +28 -0
  218. package/src/lib/plugin.js +147 -0
  219. package/src/lib/plugin.js.map +1 -0
  220. package/src/lib/server/billing-webhook.d.ts +26 -0
  221. package/src/lib/server/billing-webhook.js +4011 -0
  222. package/src/lib/server/billing-webhook.js.map +1 -0
  223. package/src/lib/server/cancel-order.d.ts +87 -0
  224. package/src/lib/server/cancel-order.js +368 -0
  225. package/src/lib/server/cancel-order.js.map +1 -0
  226. package/src/lib/server/cart-checkout.d.ts +25 -0
  227. package/src/lib/server/cart-checkout.js +976 -0
  228. package/src/lib/server/cart-checkout.js.map +1 -0
  229. package/src/lib/server/cart-cookie.d.ts +32 -0
  230. package/src/lib/server/cart-cookie.js +77 -0
  231. package/src/lib/server/cart-cookie.js.map +1 -0
  232. package/src/lib/server/cart.d.ts +34 -0
  233. package/src/lib/server/cart.js +181 -0
  234. package/src/lib/server/cart.js.map +1 -0
  235. package/src/lib/server/catalog.d.ts +127 -0
  236. package/src/lib/server/catalog.js +277 -0
  237. package/src/lib/server/catalog.js.map +1 -0
  238. package/src/lib/server/checkout.d.ts +36 -0
  239. package/src/lib/server/checkout.js +915 -0
  240. package/src/lib/server/checkout.js.map +1 -0
  241. package/src/lib/server/connect.d.ts +26 -0
  242. package/src/lib/server/connect.js +238 -0
  243. package/src/lib/server/connect.js.map +1 -0
  244. package/src/lib/server/contact-refund.d.ts +117 -0
  245. package/src/lib/server/contact-refund.js +196 -0
  246. package/src/lib/server/contact-refund.js.map +1 -0
  247. package/src/lib/server/download.d.ts +39 -0
  248. package/src/lib/server/download.js +206 -0
  249. package/src/lib/server/download.js.map +1 -0
  250. package/src/lib/server/draft-order.d.ts +26 -0
  251. package/src/lib/server/draft-order.js +706 -0
  252. package/src/lib/server/draft-order.js.map +1 -0
  253. package/src/lib/server/feed.d.ts +24 -0
  254. package/src/lib/server/feed.js +59 -0
  255. package/src/lib/server/feed.js.map +1 -0
  256. package/src/lib/server/fulfill-order.d.ts +97 -0
  257. package/src/lib/server/fulfill-order.js +235 -0
  258. package/src/lib/server/fulfill-order.js.map +1 -0
  259. package/src/lib/server/gate.d.ts +36 -0
  260. package/src/lib/server/gate.js +112 -0
  261. package/src/lib/server/gate.js.map +1 -0
  262. package/src/lib/server/gift-cards.d.ts +42 -0
  263. package/src/lib/server/gift-cards.js +219 -0
  264. package/src/lib/server/gift-cards.js.map +1 -0
  265. package/src/lib/server/low-stock.d.ts +49 -0
  266. package/src/lib/server/low-stock.js +60 -0
  267. package/src/lib/server/low-stock.js.map +1 -0
  268. package/src/lib/server/manual-tax-rate.d.ts +82 -0
  269. package/src/lib/server/manual-tax-rate.js +113 -0
  270. package/src/lib/server/manual-tax-rate.js.map +1 -0
  271. package/src/lib/server/member-feed.d.ts +24 -0
  272. package/src/lib/server/member-feed.js +72 -0
  273. package/src/lib/server/member-feed.js.map +1 -0
  274. package/src/lib/server/member-name-search.d.ts +37 -0
  275. package/src/lib/server/member-name-search.js +42 -0
  276. package/src/lib/server/member-name-search.js.map +1 -0
  277. package/src/lib/server/member-post.d.ts +23 -0
  278. package/src/lib/server/member-post.js +166 -0
  279. package/src/lib/server/member-post.js.map +1 -0
  280. package/src/lib/server/membership-account.d.ts +37 -0
  281. package/src/lib/server/membership-account.js +148 -0
  282. package/src/lib/server/membership-account.js.map +1 -0
  283. package/src/lib/server/membership-admin-password.d.ts +33 -0
  284. package/src/lib/server/membership-admin-password.js +202 -0
  285. package/src/lib/server/membership-admin-password.js.map +1 -0
  286. package/src/lib/server/membership-content.d.ts +23 -0
  287. package/src/lib/server/membership-content.js +105 -0
  288. package/src/lib/server/membership-content.js.map +1 -0
  289. package/src/lib/server/membership-login.d.ts +19 -0
  290. package/src/lib/server/membership-login.js +137 -0
  291. package/src/lib/server/membership-login.js.map +1 -0
  292. package/src/lib/server/membership-logout.d.ts +19 -0
  293. package/src/lib/server/membership-logout.js +35 -0
  294. package/src/lib/server/membership-logout.js.map +1 -0
  295. package/src/lib/server/membership-recover.d.ts +60 -0
  296. package/src/lib/server/membership-recover.js +244 -0
  297. package/src/lib/server/membership-recover.js.map +1 -0
  298. package/src/lib/server/membership-register.d.ts +22 -0
  299. package/src/lib/server/membership-register.js +241 -0
  300. package/src/lib/server/membership-register.js.map +1 -0
  301. package/src/lib/server/membership-reset.d.ts +26 -0
  302. package/src/lib/server/membership-reset.js +88 -0
  303. package/src/lib/server/membership-reset.js.map +1 -0
  304. package/src/lib/server/membership-wishlist.d.ts +23 -0
  305. package/src/lib/server/membership-wishlist.js +89 -0
  306. package/src/lib/server/membership-wishlist.js.map +1 -0
  307. package/src/lib/server/membership.d.ts +96 -0
  308. package/src/lib/server/membership.js +222 -0
  309. package/src/lib/server/membership.js.map +1 -0
  310. package/src/lib/server/native-checkout.d.ts +170 -0
  311. package/src/lib/server/native-checkout.js +193 -0
  312. package/src/lib/server/native-checkout.js.map +1 -0
  313. package/src/lib/server/newsletter.d.ts +23 -0
  314. package/src/lib/server/newsletter.js +323 -0
  315. package/src/lib/server/newsletter.js.map +1 -0
  316. package/src/lib/server/notify-restock.d.ts +22 -0
  317. package/src/lib/server/notify-restock.js +84 -0
  318. package/src/lib/server/notify-restock.js.map +1 -0
  319. package/src/lib/server/order-analytics.d.ts +134 -0
  320. package/src/lib/server/order-analytics.js +263 -0
  321. package/src/lib/server/order-analytics.js.map +1 -0
  322. package/src/lib/server/order-figures.d.ts +33 -0
  323. package/src/lib/server/order-figures.js +220 -0
  324. package/src/lib/server/order-figures.js.map +1 -0
  325. package/src/lib/server/paid-media-delivery.d.ts +173 -0
  326. package/src/lib/server/paid-media-delivery.js +212 -0
  327. package/src/lib/server/paid-media-delivery.js.map +1 -0
  328. package/src/lib/server/pos-order.d.ts +54 -0
  329. package/src/lib/server/pos-order.js +1137 -0
  330. package/src/lib/server/pos-order.js.map +1 -0
  331. package/src/lib/server/process-abandoned.d.ts +54 -0
  332. package/src/lib/server/process-abandoned.js +222 -0
  333. package/src/lib/server/process-abandoned.js.map +1 -0
  334. package/src/lib/server/process-restock.d.ts +42 -0
  335. package/src/lib/server/process-restock.js +219 -0
  336. package/src/lib/server/process-restock.js.map +1 -0
  337. package/src/lib/server/product-card.d.ts +29 -0
  338. package/src/lib/server/product-card.js +54 -0
  339. package/src/lib/server/product-card.js.map +1 -0
  340. package/src/lib/server/product.d.ts +70 -0
  341. package/src/lib/server/product.js +105 -0
  342. package/src/lib/server/product.js.map +1 -0
  343. package/src/lib/server/promotion-hold.d.ts +144 -0
  344. package/src/lib/server/promotion-hold.js +174 -0
  345. package/src/lib/server/promotion-hold.js.map +1 -0
  346. package/src/lib/server/reconcile-stock.d.ts +106 -0
  347. package/src/lib/server/reconcile-stock.js +349 -0
  348. package/src/lib/server/reconcile-stock.js.map +1 -0
  349. package/src/lib/server/refund.d.ts +45 -0
  350. package/src/lib/server/refund.js +607 -0
  351. package/src/lib/server/refund.js.map +1 -0
  352. package/src/lib/server/related.d.ts +24 -0
  353. package/src/lib/server/related.js +104 -0
  354. package/src/lib/server/related.js.map +1 -0
  355. package/src/lib/server/reservation-availability.d.ts +23 -0
  356. package/src/lib/server/reservation-availability.js +111 -0
  357. package/src/lib/server/reservation-availability.js.map +1 -0
  358. package/src/lib/server/reserve-stock.d.ts +156 -0
  359. package/src/lib/server/reserve-stock.js +146 -0
  360. package/src/lib/server/reserve-stock.js.map +1 -0
  361. package/src/lib/server/reserve.d.ts +25 -0
  362. package/src/lib/server/reserve.js +426 -0
  363. package/src/lib/server/reserve.js.map +1 -0
  364. package/src/lib/server/restock-flag.d.ts +202 -0
  365. package/src/lib/server/restock-flag.js +449 -0
  366. package/src/lib/server/restock-flag.js.map +1 -0
  367. package/src/lib/server/reviews.d.ts +51 -0
  368. package/src/lib/server/reviews.js +132 -0
  369. package/src/lib/server/reviews.js.map +1 -0
  370. package/src/lib/server/site-page-enricher.d.ts +42 -0
  371. package/src/lib/server/site-page-enricher.js +149 -0
  372. package/src/lib/server/site-page-enricher.js.map +1 -0
  373. package/src/lib/server/site-page-resolver.d.ts +26 -0
  374. package/src/lib/server/site-page-resolver.js +223 -0
  375. package/src/lib/server/site-page-resolver.js.map +1 -0
  376. package/src/lib/server/stock-hold.d.ts +127 -0
  377. package/src/lib/server/stock-hold.js +258 -0
  378. package/src/lib/server/stock-hold.js.map +1 -0
  379. package/src/lib/server/storefront-tax-record.d.ts +22 -0
  380. package/src/lib/server/storefront-tax-record.js +218 -0
  381. package/src/lib/server/storefront-tax-record.js.map +1 -0
  382. package/src/lib/server/storefront-tax.d.ts +197 -0
  383. package/src/lib/server/storefront-tax.js +245 -0
  384. package/src/lib/server/storefront-tax.js.map +1 -0
  385. package/src/lib/server/stream.d.ts +25 -0
  386. package/src/lib/server/stream.js +191 -0
  387. package/src/lib/server/stream.js.map +1 -0
  388. package/src/lib/server/subscription-portal.d.ts +24 -0
  389. package/src/lib/server/subscription-portal.js +91 -0
  390. package/src/lib/server/subscription-portal.js.map +1 -0
  391. package/src/lib/server/supplier-outbox.d.ts +190 -0
  392. package/src/lib/server/supplier-outbox.js +342 -0
  393. package/src/lib/server/supplier-outbox.js.map +1 -0
  394. package/src/lib/server/supplier-update.d.ts +23 -0
  395. package/src/lib/server/supplier-update.js +289 -0
  396. package/src/lib/server/supplier-update.js.map +1 -0
  397. package/src/lib/server/tax-profile.d.ts +29 -0
  398. package/src/lib/server/tax-profile.js +40 -0
  399. package/src/lib/server/tax-profile.js.map +1 -0
  400. package/src/lib/server.d.ts +32 -0
  401. package/src/lib/server.js +311 -0
  402. package/src/lib/server.js.map +1 -0
  403. package/src/lib/site.d.ts +27 -0
  404. package/src/lib/site.js +134 -0
  405. package/src/lib/site.js.map +1 -0
  406. package/src/lib/utils/escape-html.d.ts +41 -0
  407. package/src/lib/utils/escape-html.js +41 -0
  408. package/src/lib/utils/escape-html.js.map +1 -0
  409. package/src/lib/utils/generate-preset-id.d.ts +19 -0
  410. package/src/lib/utils/generate-preset-id.js +25 -0
  411. package/src/lib/utils/generate-preset-id.js.map +1 -0
  412. package/src/lib/utils/member-continue.d.ts +45 -0
  413. package/src/lib/utils/member-continue.js +49 -0
  414. package/src/lib/utils/member-continue.js.map +1 -0
  415. package/src/lib/utils/use-storefront-purchase-event.d.ts +60 -0
  416. package/src/lib/utils/use-storefront-purchase-event.js +142 -0
  417. package/src/lib/utils/use-storefront-purchase-event.js.map +1 -0
@@ -0,0 +1,109 @@
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
+ * Products (`hosts/{hostId}/products`).
18
+ *
19
+ * The card's listener is `limit(500)` and stays that way — a 25,000-product
20
+ * catalog does not belong in a table, and the head-count has been a server
21
+ * aggregate since AGL-1716. What that cap must NOT decide is what a search can
22
+ * find, and it did: the search compared the rows already fetched, so a product
23
+ * past the window answered "no products match".
24
+ *
25
+ * ⛔ A SKU is matched WHOLE, not as a substring. It lived inside `variants`, an
26
+ * array of objects, and Firestore cannot look inside one — so the write path
27
+ * flattens them into `skus` and this is an `array-contains`. A SKU is a value
28
+ * somebody copies rather than half-remembers, which is why that trade is the
29
+ * right way round.
30
+ */ export const PRODUCT_LIST_FILTER_FIELDS = [
31
+ {
32
+ column: 'name',
33
+ kind: 'text',
34
+ path: 'name',
35
+ lowerPath: 'nameLower',
36
+ tokensPath: 'nameTokens',
37
+ reversedPath: 'nameReversed'
38
+ },
39
+ {
40
+ // Slugs are lower-case by construction (`commerceSlug`), so the stored
41
+ // value is its own normalized key.
42
+ column: 'slug',
43
+ kind: 'text',
44
+ path: 'slug',
45
+ lowerPath: 'slug'
46
+ },
47
+ {
48
+ column: 'skus',
49
+ kind: 'text',
50
+ path: 'skus',
51
+ tokensPath: 'skus',
52
+ // Ordered by the field the card already sorts on rather than by the array
53
+ // an `array-contains` is matching.
54
+ containsOrderBy: 'name',
55
+ operators: [
56
+ 'contains',
57
+ 'isNotEmpty'
58
+ ]
59
+ },
60
+ {
61
+ // The register's scan path. Exact and whole, which is what a scanner
62
+ // produces — and it must reach the entire catalog, not a window of it.
63
+ column: 'barcodes',
64
+ kind: 'text',
65
+ path: 'barcodes',
66
+ tokensPath: 'barcodes',
67
+ containsOrderBy: 'name',
68
+ operators: [
69
+ 'contains',
70
+ 'isNotEmpty'
71
+ ]
72
+ },
73
+ {
74
+ column: 'status',
75
+ kind: 'exact',
76
+ path: 'status'
77
+ },
78
+ {
79
+ column: 'type',
80
+ kind: 'exact',
81
+ path: 'type'
82
+ },
83
+ {
84
+ column: 'priceUsd',
85
+ kind: 'number',
86
+ path: 'priceUsd'
87
+ },
88
+ {
89
+ column: 'createdAt',
90
+ kind: 'date',
91
+ path: 'createdAt'
92
+ },
93
+ {
94
+ column: 'updatedAt',
95
+ kind: 'date',
96
+ path: 'updatedAt'
97
+ }
98
+ ];
99
+ /** Headers for product fields that are filterable without being columns. */ export const PRODUCT_LIST_FILTER_HEADERS = {
100
+ slug: 'Slug',
101
+ skus: 'SKU',
102
+ barcodes: 'Barcode',
103
+ type: 'Type',
104
+ priceUsd: 'Price (USD)',
105
+ createdAt: 'Created',
106
+ updatedAt: 'Updated'
107
+ };
108
+
109
+ //# sourceMappingURL=product-filters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/constants/product-filters.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 type { ListFilterField } from '@aglyn/shared-ui-jsx/const/list-filter'\n\n/**\n * Products (`hosts/{hostId}/products`).\n *\n * The card's listener is `limit(500)` and stays that way — a 25,000-product\n * catalog does not belong in a table, and the head-count has been a server\n * aggregate since AGL-1716. What that cap must NOT decide is what a search can\n * find, and it did: the search compared the rows already fetched, so a product\n * past the window answered \"no products match\".\n *\n * ⛔ A SKU is matched WHOLE, not as a substring. It lived inside `variants`, an\n * array of objects, and Firestore cannot look inside one — so the write path\n * flattens them into `skus` and this is an `array-contains`. A SKU is a value\n * somebody copies rather than half-remembers, which is why that trade is the\n * right way round.\n */\nexport const PRODUCT_LIST_FILTER_FIELDS: readonly ListFilterField[] = [\n {\n column: 'name',\n kind: 'text',\n path: 'name',\n lowerPath: 'nameLower',\n tokensPath: 'nameTokens',\n reversedPath: 'nameReversed',\n },\n {\n // Slugs are lower-case by construction (`commerceSlug`), so the stored\n // value is its own normalized key.\n column: 'slug',\n kind: 'text',\n path: 'slug',\n lowerPath: 'slug',\n },\n {\n column: 'skus',\n kind: 'text',\n path: 'skus',\n tokensPath: 'skus',\n // Ordered by the field the card already sorts on rather than by the array\n // an `array-contains` is matching.\n containsOrderBy: 'name',\n operators: ['contains', 'isNotEmpty'],\n },\n {\n // The register's scan path. Exact and whole, which is what a scanner\n // produces — and it must reach the entire catalog, not a window of it.\n column: 'barcodes',\n kind: 'text',\n path: 'barcodes',\n tokensPath: 'barcodes',\n containsOrderBy: 'name',\n operators: ['contains', 'isNotEmpty'],\n },\n { column: 'status', kind: 'exact', path: 'status' },\n { column: 'type', kind: 'exact', path: 'type' },\n { column: 'priceUsd', kind: 'number', path: 'priceUsd' },\n { column: 'createdAt', kind: 'date', path: 'createdAt' },\n { column: 'updatedAt', kind: 'date', path: 'updatedAt' },\n]\n\n/** Headers for product fields that are filterable without being columns. */\nexport const PRODUCT_LIST_FILTER_HEADERS: Readonly<Record<string, string>> = {\n slug: 'Slug',\n skus: 'SKU',\n barcodes: 'Barcode',\n type: 'Type',\n priceUsd: 'Price (USD)',\n createdAt: 'Created',\n updatedAt: 'Updated',\n}\n"],"names":["PRODUCT_LIST_FILTER_FIELDS","column","kind","path","lowerPath","tokensPath","reversedPath","containsOrderBy","operators","PRODUCT_LIST_FILTER_HEADERS","slug","skus","barcodes","type","priceUsd","createdAt","updatedAt"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID;;;;;;;;;;;;;;CAcC,GACD,OAAO,MAAMA,6BAAyD;IACpE;QACEC,QAAQ;QACRC,MAAM;QACNC,MAAM;QACNC,WAAW;QACXC,YAAY;QACZC,cAAc;IAChB;IACA;QACE,uEAAuE;QACvE,mCAAmC;QACnCL,QAAQ;QACRC,MAAM;QACNC,MAAM;QACNC,WAAW;IACb;IACA;QACEH,QAAQ;QACRC,MAAM;QACNC,MAAM;QACNE,YAAY;QACZ,0EAA0E;QAC1E,mCAAmC;QACnCE,iBAAiB;QACjBC,WAAW;YAAC;YAAY;SAAa;IACvC;IACA;QACE,qEAAqE;QACrE,uEAAuE;QACvEP,QAAQ;QACRC,MAAM;QACNC,MAAM;QACNE,YAAY;QACZE,iBAAiB;QACjBC,WAAW;YAAC;YAAY;SAAa;IACvC;IACA;QAAEP,QAAQ;QAAUC,MAAM;QAASC,MAAM;IAAS;IAClD;QAAEF,QAAQ;QAAQC,MAAM;QAASC,MAAM;IAAO;IAC9C;QAAEF,QAAQ;QAAYC,MAAM;QAAUC,MAAM;IAAW;IACvD;QAAEF,QAAQ;QAAaC,MAAM;QAAQC,MAAM;IAAY;IACvD;QAAEF,QAAQ;QAAaC,MAAM;QAAQC,MAAM;IAAY;CACxD,CAAA;AAED,0EAA0E,GAC1E,OAAO,MAAMM,8BAAgE;IAC3EC,MAAM;IACNC,MAAM;IACNC,UAAU;IACVC,MAAM;IACNC,UAAU;IACVC,WAAW;IACXC,WAAW;AACb,EAAC"}
@@ -0,0 +1,52 @@
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
+ * Cart v1 (AGL-293): a server-backed cart doc at
19
+ * `hosts/{hostId}/carts/{cartId}`, keyed by an httpOnly cookie. Lines
20
+ * store only ids + quantity — display data and prices resolve from the
21
+ * product docs at read/checkout time, so a stale cart can never charge
22
+ * a stale price. Pure helpers; the cart API owns I/O.
23
+ */
24
+ export interface CartLine {
25
+ productId: string;
26
+ /** Absent = the product's default variant. */
27
+ variantId?: string;
28
+ quantity: number;
29
+ }
30
+ /** `hosts/{hostId}/carts/{cartId}` doc. */
31
+ export interface HostCart {
32
+ lines: CartLine[];
33
+ /** Storefront customer once signed in (AGL-294 merge). */
34
+ customerId?: string;
35
+ updatedAtMs?: number;
36
+ createdAtMs?: number;
37
+ }
38
+ export declare const CART_MAX_LINES = 50;
39
+ export declare const CART_MAX_QUANTITY = 99;
40
+ /**
41
+ * Adds/merges a line (quantities accumulate), clamped to per-line and
42
+ * line-count caps. Quantity ≤ 0 removes the line.
43
+ */
44
+ export declare function upsertCartLine(cart: Pick<HostCart, 'lines'>, line: CartLine, mode?: 'add' | 'set'): CartLine[];
45
+ export declare function removeCartLine(cart: Pick<HostCart, 'lines'>, line: Pick<CartLine, 'productId' | 'variantId'>): CartLine[];
46
+ /** Total units across lines (the mini-cart badge). */
47
+ export declare function cartCount(cart: Pick<HostCart, 'lines'> | undefined): number;
48
+ /**
49
+ * Merges a guest cart into a customer cart on sign-in (AGL-294):
50
+ * quantities accumulate per line, capped as usual.
51
+ */
52
+ export declare function mergeCarts(customerCart: Pick<HostCart, 'lines'>, guestCart: Pick<HostCart, 'lines'>): CartLine[];
@@ -0,0 +1,102 @@
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
+ * Cart v1 (AGL-293): a server-backed cart doc at
18
+ * `hosts/{hostId}/carts/{cartId}`, keyed by an httpOnly cookie. Lines
19
+ * store only ids + quantity — display data and prices resolve from the
20
+ * product docs at read/checkout time, so a stale cart can never charge
21
+ * a stale price. Pure helpers; the cart API owns I/O.
22
+ */ import { _ as _extends } from "@swc/helpers/_/_extends";
23
+ export const CART_MAX_LINES = 50;
24
+ export const CART_MAX_QUANTITY = 99;
25
+ function lineKey(line) {
26
+ var _line_variantId;
27
+ return `${line.productId}:${(_line_variantId = line.variantId) != null ? _line_variantId : ''}`;
28
+ }
29
+ /**
30
+ * A line quantity, coerced to a whole finite number (AGL-2285).
31
+ *
32
+ * `Math.round(line.quantity)` was the whole sanitiser, and `Math.round(NaN)` is
33
+ * `NaN` — which then walked past the guard below, because `NaN <= 0` is
34
+ * `false`. A cart line with `quantity: NaN` (a legal Firestore double) was
35
+ * stored, and from there `cartCount` reported `NaN` in the mini-cart badge and
36
+ * `cart-checkout.ts` computed `itemsCents`, the platform fee and the Stripe
37
+ * `line_items[n][quantity]` as `NaN` too — so Stripe 400s and the shopper
38
+ * cannot check out AT ALL until they find the poisoned line and remove it.
39
+ *
40
+ * Answering 0 is what makes the existing `<= 0` guard do its job: an
41
+ * unusable quantity removes the line (or refuses to add one) rather than
42
+ * writing a value nothing downstream can compare against. The same lesson as
43
+ * AGL-2229 one collection over — `Math.max`/`Math.min`/`Math.round` propagate
44
+ * `NaN`, they do not discard it.
45
+ */ function wholeQuantity(value) {
46
+ const quantity = Math.round(Number(value != null ? value : 0));
47
+ return Number.isFinite(quantity) ? quantity : 0;
48
+ }
49
+ /**
50
+ * Adds/merges a line (quantities accumulate), clamped to per-line and
51
+ * line-count caps. Quantity ≤ 0 removes the line.
52
+ */ export function upsertCartLine(cart, line, mode = 'add') {
53
+ const quantity = wholeQuantity(line.quantity);
54
+ const key = lineKey(line);
55
+ const existing = cart.lines.find((item)=>lineKey(item) === key);
56
+ if (!existing) {
57
+ if (quantity <= 0) return cart.lines;
58
+ if (cart.lines.length >= CART_MAX_LINES) return cart.lines;
59
+ return [
60
+ ...cart.lines,
61
+ _extends({}, line, {
62
+ quantity: Math.min(CART_MAX_QUANTITY, quantity)
63
+ })
64
+ ];
65
+ }
66
+ // The STORED side is coerced too (AGL-2285): a line written before this
67
+ // guard, or by any other writer, can still hold a non-finite quantity, and
68
+ // adding to it would carry that forward forever.
69
+ const nextQuantity = mode === 'add' ? wholeQuantity(existing.quantity) + quantity : quantity;
70
+ if (nextQuantity <= 0) {
71
+ return cart.lines.filter((item)=>lineKey(item) !== key);
72
+ }
73
+ return cart.lines.map((item)=>lineKey(item) === key ? _extends({}, item, {
74
+ quantity: Math.min(CART_MAX_QUANTITY, nextQuantity)
75
+ }) : item);
76
+ }
77
+ export function removeCartLine(cart, line) {
78
+ const key = lineKey(line);
79
+ return cart.lines.filter((item)=>lineKey(item) !== key);
80
+ }
81
+ /** Total units across lines (the mini-cart badge). */ export function cartCount(cart) {
82
+ var _ref;
83
+ // Coerced per line (AGL-2285) so one stored `NaN` cannot make the badge read
84
+ // `NaN` for a cart that otherwise has real items in it.
85
+ return ((_ref = cart == null ? void 0 : cart.lines) != null ? _ref : []).reduce((sum, line)=>sum + wholeQuantity(line == null ? void 0 : line.quantity), 0);
86
+ }
87
+ /**
88
+ * Merges a guest cart into a customer cart on sign-in (AGL-294):
89
+ * quantities accumulate per line, capped as usual.
90
+ */ export function mergeCarts(customerCart, guestCart) {
91
+ let lines = [
92
+ ...customerCart.lines
93
+ ];
94
+ for (const line of guestCart.lines){
95
+ lines = upsertCartLine({
96
+ lines
97
+ }, line, 'add');
98
+ }
99
+ return lines;
100
+ }
101
+
102
+ //# sourceMappingURL=commerce-cart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/commerce-cart.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\n/**\n * Cart v1 (AGL-293): a server-backed cart doc at\n * `hosts/{hostId}/carts/{cartId}`, keyed by an httpOnly cookie. Lines\n * store only ids + quantity — display data and prices resolve from the\n * product docs at read/checkout time, so a stale cart can never charge\n * a stale price. Pure helpers; the cart API owns I/O.\n */\n\nexport interface CartLine {\n productId: string\n /** Absent = the product's default variant. */\n variantId?: string\n quantity: number\n}\n\n/** `hosts/{hostId}/carts/{cartId}` doc. */\nexport interface HostCart {\n lines: CartLine[]\n /** Storefront customer once signed in (AGL-294 merge). */\n customerId?: string\n updatedAtMs?: number\n createdAtMs?: number\n}\n\nexport const CART_MAX_LINES = 50\nexport const CART_MAX_QUANTITY = 99\n\nfunction lineKey(line: Pick<CartLine, 'productId' | 'variantId'>): string {\n return `${line.productId}:${line.variantId ?? ''}`\n}\n\n/**\n * A line quantity, coerced to a whole finite number (AGL-2285).\n *\n * `Math.round(line.quantity)` was the whole sanitiser, and `Math.round(NaN)` is\n * `NaN` — which then walked past the guard below, because `NaN <= 0` is\n * `false`. A cart line with `quantity: NaN` (a legal Firestore double) was\n * stored, and from there `cartCount` reported `NaN` in the mini-cart badge and\n * `cart-checkout.ts` computed `itemsCents`, the platform fee and the Stripe\n * `line_items[n][quantity]` as `NaN` too — so Stripe 400s and the shopper\n * cannot check out AT ALL until they find the poisoned line and remove it.\n *\n * Answering 0 is what makes the existing `<= 0` guard do its job: an\n * unusable quantity removes the line (or refuses to add one) rather than\n * writing a value nothing downstream can compare against. The same lesson as\n * AGL-2229 one collection over — `Math.max`/`Math.min`/`Math.round` propagate\n * `NaN`, they do not discard it.\n */\nfunction wholeQuantity(value: unknown): number {\n const quantity = Math.round(Number(value ?? 0))\n return Number.isFinite(quantity) ? quantity : 0\n}\n\n/**\n * Adds/merges a line (quantities accumulate), clamped to per-line and\n * line-count caps. Quantity ≤ 0 removes the line.\n */\nexport function upsertCartLine(\n cart: Pick<HostCart, 'lines'>,\n line: CartLine,\n mode: 'add' | 'set' = 'add',\n): CartLine[] {\n const quantity = wholeQuantity(line.quantity)\n const key = lineKey(line)\n const existing = cart.lines.find((item) => lineKey(item) === key)\n if (!existing) {\n if (quantity <= 0) return cart.lines\n if (cart.lines.length >= CART_MAX_LINES) return cart.lines\n return [\n ...cart.lines,\n { ...line, quantity: Math.min(CART_MAX_QUANTITY, quantity) },\n ]\n }\n // The STORED side is coerced too (AGL-2285): a line written before this\n // guard, or by any other writer, can still hold a non-finite quantity, and\n // adding to it would carry that forward forever.\n const nextQuantity =\n mode === 'add' ? wholeQuantity(existing.quantity) + quantity : quantity\n if (nextQuantity <= 0) {\n return cart.lines.filter((item) => lineKey(item) !== key)\n }\n return cart.lines.map((item) =>\n lineKey(item) === key\n ? { ...item, quantity: Math.min(CART_MAX_QUANTITY, nextQuantity) }\n : item,\n )\n}\n\nexport function removeCartLine(\n cart: Pick<HostCart, 'lines'>,\n line: Pick<CartLine, 'productId' | 'variantId'>,\n): CartLine[] {\n const key = lineKey(line)\n return cart.lines.filter((item) => lineKey(item) !== key)\n}\n\n/** Total units across lines (the mini-cart badge). */\nexport function cartCount(cart: Pick<HostCart, 'lines'> | undefined): number {\n // Coerced per line (AGL-2285) so one stored `NaN` cannot make the badge read\n // `NaN` for a cart that otherwise has real items in it.\n return (cart?.lines ?? []).reduce(\n (sum, line) => sum + wholeQuantity(line?.quantity),\n 0,\n )\n}\n\n/**\n * Merges a guest cart into a customer cart on sign-in (AGL-294):\n * quantities accumulate per line, capped as usual.\n */\nexport function mergeCarts(\n customerCart: Pick<HostCart, 'lines'>,\n guestCart: Pick<HostCart, 'lines'>,\n): CartLine[] {\n let lines = [...customerCart.lines]\n for (const line of guestCart.lines) {\n lines = upsertCartLine({ lines }, line, 'add')\n }\n return lines\n}\n"],"names":["CART_MAX_LINES","CART_MAX_QUANTITY","lineKey","line","productId","variantId","wholeQuantity","value","quantity","Math","round","Number","isFinite","upsertCartLine","cart","mode","key","existing","lines","find","item","length","min","nextQuantity","filter","map","removeCartLine","cartCount","reduce","sum","mergeCarts","customerCart","guestCart"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;CAMC;AAkBD,OAAO,MAAMA,iBAAiB,GAAE;AAChC,OAAO,MAAMC,oBAAoB,GAAE;AAEnC,SAASC,QAAQC,IAA+C;QAClCA;IAA5B,OAAO,GAAGA,KAAKC,SAAS,CAAC,CAAC,GAAED,kBAAAA,KAAKE,SAAS,YAAdF,kBAAkB,IAAI;AACpD;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,SAASG,cAAcC,KAAc;IACnC,MAAMC,WAAWC,KAAKC,KAAK,CAACC,OAAOJ,gBAAAA,QAAS;IAC5C,OAAOI,OAAOC,QAAQ,CAACJ,YAAYA,WAAW;AAChD;AAEA;;;CAGC,GACD,OAAO,SAASK,eACdC,IAA6B,EAC7BX,IAAc,EACdY,OAAsB,KAAK;IAE3B,MAAMP,WAAWF,cAAcH,KAAKK,QAAQ;IAC5C,MAAMQ,MAAMd,QAAQC;IACpB,MAAMc,WAAWH,KAAKI,KAAK,CAACC,IAAI,CAAC,CAACC,OAASlB,QAAQkB,UAAUJ;IAC7D,IAAI,CAACC,UAAU;QACb,IAAIT,YAAY,GAAG,OAAOM,KAAKI,KAAK;QACpC,IAAIJ,KAAKI,KAAK,CAACG,MAAM,IAAIrB,gBAAgB,OAAOc,KAAKI,KAAK;QAC1D,OAAO;eACFJ,KAAKI,KAAK;YACb,aAAKf;gBAAMK,UAAUC,KAAKa,GAAG,CAACrB,mBAAmBO;;SAClD;IACH;IACA,wEAAwE;IACxE,2EAA2E;IAC3E,iDAAiD;IACjD,MAAMe,eACJR,SAAS,QAAQT,cAAcW,SAAST,QAAQ,IAAIA,WAAWA;IACjE,IAAIe,gBAAgB,GAAG;QACrB,OAAOT,KAAKI,KAAK,CAACM,MAAM,CAAC,CAACJ,OAASlB,QAAQkB,UAAUJ;IACvD;IACA,OAAOF,KAAKI,KAAK,CAACO,GAAG,CAAC,CAACL,OACrBlB,QAAQkB,UAAUJ,MACd,aAAKI;YAAMZ,UAAUC,KAAKa,GAAG,CAACrB,mBAAmBsB;aACjDH;AAER;AAEA,OAAO,SAASM,eACdZ,IAA6B,EAC7BX,IAA+C;IAE/C,MAAMa,MAAMd,QAAQC;IACpB,OAAOW,KAAKI,KAAK,CAACM,MAAM,CAAC,CAACJ,OAASlB,QAAQkB,UAAUJ;AACvD;AAEA,oDAAoD,GACpD,OAAO,SAASW,UAAUb,IAAyC;;IACjE,6EAA6E;IAC7E,wDAAwD;IACxD,OAAO,SAACA,wBAAAA,KAAMI,KAAK,mBAAI,EAAE,EAAEU,MAAM,CAC/B,CAACC,KAAK1B,OAAS0B,MAAMvB,cAAcH,wBAAAA,KAAMK,QAAQ,GACjD;AAEJ;AAEA;;;CAGC,GACD,OAAO,SAASsB,WACdC,YAAqC,EACrCC,SAAkC;IAElC,IAAId,QAAQ;WAAIa,aAAab,KAAK;KAAC;IACnC,KAAK,MAAMf,QAAQ6B,UAAUd,KAAK,CAAE;QAClCA,QAAQL,eAAe;YAAEK;QAAM,GAAGf,MAAM;IAC1C;IACA,OAAOe;AACT"}
@@ -0,0 +1,243 @@
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
+ * How a storefront destination charge splits between Aglyn and the merchant —
19
+ * and, when Stripe Tax is on, why the split cannot be expressed as a fee
20
+ * (AGL-1956).
21
+ *
22
+ * ## The defect this module exists to close
23
+ *
24
+ * Every storefront checkout is a DESTINATION charge created on AGLYN's
25
+ * platform account: platform secret key, no `Stripe-Account` header, no
26
+ * `on_behalf_of`, with `payment_intent_data[transfer_data][destination]`
27
+ * naming the merchant's connected account. On a `mode: 'stripe'` store the
28
+ * session also carries `automatic_tax[enabled]`, and AGL-1904 MEASURED what
29
+ * that means: the tax is computed against **Aglyn's** registrations, reported
30
+ * as `automatic_tax.liability: { type: "self" }`, and is **Aglyn's to remit**.
31
+ * See `../server/storefront-tax.ts` for the two-arm experiment.
32
+ *
33
+ * The sessions then set `payment_intent_data[application_fee_amount]`. On a
34
+ * destination charge that form means Stripe transfers the **whole charge** to
35
+ * the connected account and debits the fee at the destination — measured, and
36
+ * recorded at `billing-webhook.ts` (the AGL-1794 note: "`transfer.amount`
37
+ * equals `charge.amount`"). `amount_total` INCLUDES the Stripe Tax.
38
+ *
39
+ * So on every taxed storefront sale the sales tax Aglyn owes the state was
40
+ * transferred to the merchant, and only the commission came back. Aglyn was
41
+ * left holding the liability and none of the money. This is the same trap the
42
+ * marketplace plugin found and closed in AGL-1544, and the fix here is the
43
+ * same one: **a fixed `transfer_data[amount]`, and no `application_fee_amount`
44
+ * at all** — because the fee form makes Stripe do the arithmetic on a total
45
+ * that has the tax inside it.
46
+ *
47
+ * ## Only ONE of the two knobs may do the arithmetic
48
+ *
49
+ * `application_fee_amount` says "give the merchant everything except this".
50
+ * `transfer_data[amount]` says "give the merchant exactly this". They are two
51
+ * spellings of the same split and Stripe rejects a PaymentIntent carrying
52
+ * both, so the emitter below is written as a single choice with no path that
53
+ * can emit the pair. Which one is correct depends entirely on WHICH SIDE of
54
+ * the split holds the unknown:
55
+ *
56
+ * - **Merchant owes the tax** (`manual` mode, or no tax at all). The
57
+ * variable part — the merchant's tax line — is the merchant's own money.
58
+ * Fixing the FEE is exact: Aglyn keeps its commission and every cent of
59
+ * variance stays where it belongs.
60
+ * - **Aglyn owes the tax** (`stripe` mode). The variable part is now
61
+ * AGLYN's money, and a fixed fee hands all of it to the merchant. Fixing
62
+ * the TRANSFER is what keeps it.
63
+ *
64
+ * ## The residual, stated out loud: shopper-chosen shipping
65
+ *
66
+ * Neither knob can be exact on a Stripe Tax sale that also offers a CHOICE of
67
+ * shipping rates, because at session-creation time two numbers are unknown —
68
+ * the tax (Aglyn's) and which shipping option the shopper will pick (the
69
+ * merchant's) — and there is only one knob left to fix. Whichever is fixed,
70
+ * the other side's variance lands on the wrong party:
71
+ *
72
+ * - Fixing the FEE misallocates the ENTIRE tax, on EVERY taxed sale,
73
+ * unbounded. That is the defect above.
74
+ * - Fixing the TRANSFER misallocates at most `dearest − cheapest` shipping,
75
+ * and only on a store that offers more than one rate.
76
+ *
77
+ * The transfer is therefore fixed at the CHEAPEST option, never the dearest.
78
+ * Not a preference — the dearest is unsafe: a transfer of
79
+ * `goods + dearest − fee` can EXCEED a charge where the shopper picked the
80
+ * cheapest, and Stripe rejects a transfer larger than its charge, which would
81
+ * fail the payment outright rather than mis-split it. The cheapest is always
82
+ * payable, because the shopper's actual shipping can only be higher.
83
+ *
84
+ * The bounded remainder — a shopper who upgraded shipping on a Stripe Tax
85
+ * store — is money owed to the MERCHANT that Aglyn is holding. It is recorded
86
+ * on the session as `metadata[transferCents]` and
87
+ * `metadata[transferShippingCents]` so it is derivable per order rather than
88
+ * lost, and closing it needs a top-up transfer at
89
+ * `checkout.session.completed`, which is a new outbound money path and is
90
+ * deliberately NOT bundled with this fix. Tracked on AGL-1956.
91
+ *
92
+ * Pure and total: integer cents in, integer cents out, no clamping surprises
93
+ * except the documented floor at zero.
94
+ */
95
+ /** Which party's registrations the tax on this sale was computed against. */
96
+ export type StorefrontTaxOwner = 'platform' | 'merchant';
97
+ export interface DestinationChargeSplit {
98
+ /** The merchant's connected account id. */
99
+ accountId: string;
100
+ /**
101
+ * Aglyn's take in cents — the advertised platform fee plus the passed-through
102
+ * card cost (`resolveTransactionFeeCents`). Never negative.
103
+ */
104
+ feeCents: number;
105
+ /**
106
+ * `platform` when the session carries `automatic_tax[enabled]` and Stripe
107
+ * Tax computes against Aglyn's registrations (AGL-1904). `merchant` for a
108
+ * `manual` rate the merchant set and owes, and for an untaxed sale.
109
+ */
110
+ taxOwner: StorefrontTaxOwner;
111
+ /**
112
+ * What Stripe will charge for the GOODS — after any coupon is priced in, and
113
+ * excluding shipping and every tax line. The merchant's money.
114
+ */
115
+ merchantGoodsCents: number;
116
+ /**
117
+ * The CHEAPEST shipping option offered on this session, or 0 when the
118
+ * merchant offers none. See the module note on why this is the cheapest and
119
+ * not the dearest.
120
+ */
121
+ shippingFloorCents?: number;
122
+ }
123
+ /**
124
+ * What the merchant is paid, in cents, when AGLYN owes the tax.
125
+ *
126
+ * `goods + cheapest shipping − fee`, floored at zero. The floor is a real
127
+ * case, not defensive padding: `resolveTransactionFeeCents` adds Stripe's
128
+ * fixed 30¢ card cost, so a sub-dollar order can carry a fee worth more than
129
+ * the goods. The merchant is paid nothing on such an order, which is the
130
+ * honest outcome — Aglyn is out of pocket on it either way — and it must
131
+ * never be expressed as a NEGATIVE transfer, which Stripe rejects.
132
+ */
133
+ export declare function platformLiableTransferCents(split: Pick<DestinationChargeSplit, 'feeCents' | 'merchantGoodsCents' | 'shippingFloorCents'>): number;
134
+ /**
135
+ * What a paid SUBSCRIPTION invoice says about the tax on it, and therefore
136
+ * whether the platform has to pull that tax back out of the transfer
137
+ * (AGL-1956).
138
+ *
139
+ * ## Why the recurring path needs a different instrument entirely
140
+ *
141
+ * Everything above is about a knob set when the charge is CREATED. A Stripe
142
+ * Subscription has neither knob: it accepts no `transfer_data[amount]`, only
143
+ * `application_fee_percent`. On a destination charge that means Stripe
144
+ * transfers the WHOLE charge to the connected account and debits the fee at
145
+ * the destination, and the charge has the Stripe Tax inside it — so the
146
+ * merchant is handed the state's money on every taxed cycle. `checkout.ts`
147
+ * therefore excludes subscriptions from `destinationChargeParams` and leaves
148
+ * them on the fee form.
149
+ *
150
+ * AGL-2317 makes that strictly worse, not better. It refunds the part of the
151
+ * application fee that was taken on tax and shipping BACK to the connected
152
+ * account, which is right on its own terms (Aglyn's advertised cut is a cut of
153
+ * sales) but means the merchant ends the cycle holding **one hundred percent**
154
+ * of a tax Aglyn is the one registered to remit.
155
+ *
156
+ * ## The money is already at the merchant, so the correction is a REVERSAL
157
+ *
158
+ * Worth stating explicitly, because the sign is easy to get backwards and this
159
+ * module documents a residual that runs the OTHER way. The shipping residual
160
+ * above is a case where the transfer was FIXED too low and the merchant is
161
+ * owed more — that one needs a top-up. This is the opposite: the fee form
162
+ * OVER-transfers, the tax is physically sitting in the connected account's
163
+ * balance, and the only instrument that moves it back to the platform is a
164
+ * transfer reversal. A top-up here would pay the merchant the tax twice.
165
+ *
166
+ * ## Three answers, never two
167
+ *
168
+ * The whole point of the three-state is that **a missing tax field must not
169
+ * read as "no tax"**. Stripe removed the scalar `invoice.tax` in favour of
170
+ * `total_taxes[]`, and which spelling an endpoint receives is dashboard
171
+ * configuration this repo cannot see. A reader that reached for one field and
172
+ * defaulted the miss to `0` would answer "no reversal" on every invoice after
173
+ * a Stripe version bump nobody here can observe — a swallowed read rendering
174
+ * as a measured zero, with the money going the wrong way and nothing looking
175
+ * wrong. So an invoice that claims automatic tax while stating NO tax field at
176
+ * all is `unreadable`, and the caller is required to make noise about it.
177
+ *
178
+ * A `tax: 0`, or a present-but-empty `total_taxes: []`, is a real answer and
179
+ * is `skip`. That is also what a $0 or fully-discounted invoice produces, which
180
+ * is why the no-op costs nothing.
181
+ *
182
+ * Pure and total: no throw, no clamping beyond the documented floor at zero.
183
+ */
184
+ export type SubscriptionTaxReversalDecision =
185
+ /** Aglyn owes this tax and the merchant is holding it. Pull back exactly this. */
186
+ {
187
+ kind: 'reverse';
188
+ taxCents: number;
189
+ }
190
+ /** Nothing to do, and nothing wrong. No network call is warranted. */
191
+ | {
192
+ kind: 'skip';
193
+ reason: 'merchant-tax' | 'no-tax';
194
+ }
195
+ /** The invoice claims tax it will not state. LOUD, never silent. */
196
+ | {
197
+ kind: 'unreadable';
198
+ reason: string;
199
+ };
200
+ /**
201
+ * Which party's registrations a subscription invoice's tax was computed
202
+ * against — the same `taxOwner` distinction `destinationChargeParams` makes,
203
+ * read off the invoice instead of off the store's settings.
204
+ *
205
+ * `automatic_tax.enabled` is THE discriminator and the tax lines are never it,
206
+ * for the reason `storefront-tax.ts` states at length: a MANUAL-rate
207
+ * subscription carries a real Stripe Tax Rate on its line (AGL-1751), so every
208
+ * cycle it bills arrives with a populated `total_taxes[]` that is
209
+ * indistinguishable from a Stripe Tax one by shape. Reading the lines would
210
+ * reverse the merchant's OWN tax out of their payout on every cycle — the
211
+ * failure that steals from the merchant rather than from the state.
212
+ *
213
+ * `liability.type === 'account'` means Stripe computed against the CONNECTED
214
+ * account's registrations, so the tax is theirs and stays with them. `self`,
215
+ * and an absent liability (older API versions omit the field, where the only
216
+ * account a platform-created invoice could be liable under is the platform),
217
+ * mean Aglyn. This mirrors `storefrontTaxRow` exactly, deliberately: the filed
218
+ * tax record and the reversal must not be able to disagree about who owed it.
219
+ */
220
+ export declare function subscriptionInvoiceTaxOwner(invoice: unknown): StorefrontTaxOwner;
221
+ /** See `SubscriptionTaxReversalDecision`. */
222
+ export declare function subscriptionInvoiceTaxReversal(invoice: unknown): SubscriptionTaxReversalDecision;
223
+ /**
224
+ * The cheapest rate on a resolved shipping plan, in cents. `0` for a plan with
225
+ * no options, which is also the right transfer contribution for a store that
226
+ * charges no shipping.
227
+ */
228
+ export declare function shippingFloorCents(options?: readonly {
229
+ amountCents?: unknown;
230
+ }[]): number;
231
+ /**
232
+ * The Connect keys for a storefront destination charge — the destination, and
233
+ * EXACTLY ONE of `application_fee_amount` / `transfer_data[amount]`.
234
+ *
235
+ * Emitted from one place so no checkout path can pick the wrong knob on its
236
+ * own, and so the pair can never both appear (Stripe rejects that, and the two
237
+ * would be contradicting each other about the same split).
238
+ *
239
+ * The `metadata[transferCents]` companion is deliberately NOT emitted here —
240
+ * each caller owns its own metadata block, and the value is
241
+ * `platformLiableTransferCents(split)`.
242
+ */
243
+ export declare function destinationChargeParams(split: DestinationChargeSplit): Record<string, string>;