@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,19 @@
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
+ import type { ComponentId } from '@aglyn/aglyn';
18
+ export declare const generatePresetId: (componentId: ComponentId, ...other: string[]) => ComponentId;
19
+ export default generatePresetId;
@@ -0,0 +1,25 @@
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
+ */ import { BUNDLE_ID } from "../constants/bundle-common.js";
17
+ export const generatePresetId = (componentId, ...other)=>{
18
+ return `${BUNDLE_ID}:${[
19
+ componentId,
20
+ ...other
21
+ ].join('.')}`;
22
+ };
23
+ export default generatePresetId;
24
+
25
+ //# sourceMappingURL=generate-preset-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/utils/generate-preset-id.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 { ComponentId } from '@aglyn/aglyn'\nimport { BUNDLE_ID } from '../constants/bundle-common'\n\nexport const generatePresetId = (\n componentId: ComponentId,\n ...other: string[]\n): ComponentId => {\n return `${BUNDLE_ID}:${[componentId, ...other].join('.')}`\n}\n\nexport default generatePresetId\n"],"names":["BUNDLE_ID","generatePresetId","componentId","other","join"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,SAASA,SAAS,QAAQ,gCAA4B;AAEtD,OAAO,MAAMC,mBAAmB,CAC9BC,aACA,GAAGC;IAEH,OAAO,GAAGH,UAAU,CAAC,EAAE;QAACE;WAAgBC;KAAM,CAACC,IAAI,CAAC,MAAM;AAC5D,EAAC;AAED,eAAeH,iBAAgB"}
@@ -0,0 +1,45 @@
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
+ * Post-auth redirect target (AGL-553): the sign-in/up blocks honor a
19
+ * `continue` query parameter so gated pages can send visitors back where
20
+ * they came from. Open-redirect hardened — only same-origin RELATIVE paths
21
+ * pass.
22
+ *
23
+ * Delegates to {@link safeSameOriginPath} rather than testing the string's
24
+ * shape (AGL-1881). The character checks this used to carry — `//`, then `\`
25
+ * — were each correct and each incomplete: the URL parser strips tab, LF and
26
+ * CR before parsing, so `/<TAB>/evil.com` contains neither and still resolves
27
+ * off-site. The shared predicate resolves and compares origins, so it catches
28
+ * the forms nobody has enumerated yet.
29
+ */
30
+ export declare function safeContinuePath(raw: string | null | undefined, fallback?: string): string;
31
+ /** Reads + validates the `continue` param from the current location. */
32
+ export declare function continuePathFromLocation(fallback?: string): string;
33
+ /**
34
+ * Navigation seam for the member account doors.
35
+ *
36
+ * jsdom's `window.location` is not patchable, so a test that drives one of
37
+ * these forms cannot stub the redirect — it gets "Not implemented" thrown out
38
+ * of the handler instead, which aborts it partway and takes the analytics
39
+ * call above it with it. Every member block navigates through here so the
40
+ * destination stays assertable, and so the one place that leaves the site is
41
+ * the one place that resolves where to.
42
+ */
43
+ export declare const memberNavigation: {
44
+ assign: (url: string) => void;
45
+ };
@@ -0,0 +1,49 @@
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
+ */ import { safeSameOriginPath } from "@aglyn/shared-util-http/safe-redirect";
17
+ /**
18
+ * Post-auth redirect target (AGL-553): the sign-in/up blocks honor a
19
+ * `continue` query parameter so gated pages can send visitors back where
20
+ * they came from. Open-redirect hardened — only same-origin RELATIVE paths
21
+ * pass.
22
+ *
23
+ * Delegates to {@link safeSameOriginPath} rather than testing the string's
24
+ * shape (AGL-1881). The character checks this used to carry — `//`, then `\`
25
+ * — were each correct and each incomplete: the URL parser strips tab, LF and
26
+ * CR before parsing, so `/<TAB>/evil.com` contains neither and still resolves
27
+ * off-site. The shared predicate resolves and compares origins, so it catches
28
+ * the forms nobody has enumerated yet.
29
+ */ export function safeContinuePath(raw, fallback = '/') {
30
+ return safeSameOriginPath(raw, fallback);
31
+ }
32
+ /** Reads + validates the `continue` param from the current location. */ export function continuePathFromLocation(fallback = '/') {
33
+ if (typeof window === 'undefined') return fallback;
34
+ return safeContinuePath(new URLSearchParams(window.location.search).get('continue'), fallback);
35
+ }
36
+ /**
37
+ * Navigation seam for the member account doors.
38
+ *
39
+ * jsdom's `window.location` is not patchable, so a test that drives one of
40
+ * these forms cannot stub the redirect — it gets "Not implemented" thrown out
41
+ * of the handler instead, which aborts it partway and takes the analytics
42
+ * call above it with it. Every member block navigates through here so the
43
+ * destination stays assertable, and so the one place that leaves the site is
44
+ * the one place that resolves where to.
45
+ */ export const memberNavigation = {
46
+ assign: (url)=>window.location.assign(url)
47
+ };
48
+
49
+ //# sourceMappingURL=member-continue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/utils/member-continue.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 { safeSameOriginPath } from '@aglyn/shared-util-http/safe-redirect'\n\n/**\n * Post-auth redirect target (AGL-553): the sign-in/up blocks honor a\n * `continue` query parameter so gated pages can send visitors back where\n * they came from. Open-redirect hardened — only same-origin RELATIVE paths\n * pass.\n *\n * Delegates to {@link safeSameOriginPath} rather than testing the string's\n * shape (AGL-1881). The character checks this used to carry — `//`, then `\\`\n * — were each correct and each incomplete: the URL parser strips tab, LF and\n * CR before parsing, so `/<TAB>/evil.com` contains neither and still resolves\n * off-site. The shared predicate resolves and compares origins, so it catches\n * the forms nobody has enumerated yet.\n */\nexport function safeContinuePath(\n raw: string | null | undefined,\n fallback = '/',\n): string {\n return safeSameOriginPath(raw, fallback)\n}\n\n/** Reads + validates the `continue` param from the current location. */\nexport function continuePathFromLocation(fallback = '/'): string {\n if (typeof window === 'undefined') return fallback\n return safeContinuePath(\n new URLSearchParams(window.location.search).get('continue'),\n fallback,\n )\n}\n\n/**\n * Navigation seam for the member account doors.\n *\n * jsdom's `window.location` is not patchable, so a test that drives one of\n * these forms cannot stub the redirect — it gets \"Not implemented\" thrown out\n * of the handler instead, which aborts it partway and takes the analytics\n * call above it with it. Every member block navigates through here so the\n * destination stays assertable, and so the one place that leaves the site is\n * the one place that resolves where to.\n */\nexport const memberNavigation = {\n assign: (url: string) => window.location.assign(url),\n}\n"],"names":["safeSameOriginPath","safeContinuePath","raw","fallback","continuePathFromLocation","window","URLSearchParams","location","search","get","memberNavigation","assign","url"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,kBAAkB,QAAQ,wCAAuC;AAE1E;;;;;;;;;;;;CAYC,GACD,OAAO,SAASC,iBACdC,GAA8B,EAC9BC,WAAW,GAAG;IAEd,OAAOH,mBAAmBE,KAAKC;AACjC;AAEA,sEAAsE,GACtE,OAAO,SAASC,yBAAyBD,WAAW,GAAG;IACrD,IAAI,OAAOE,WAAW,aAAa,OAAOF;IAC1C,OAAOF,iBACL,IAAIK,gBAAgBD,OAAOE,QAAQ,CAACC,MAAM,EAAEC,GAAG,CAAC,aAChDN;AAEJ;AAEA;;;;;;;;;CASC,GACD,OAAO,MAAMO,mBAAmB;IAC9BC,QAAQ,CAACC,MAAgBP,OAAOE,QAAQ,CAACI,MAAM,CAACC;AAClD,EAAC"}
@@ -0,0 +1,60 @@
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
+ * Report a completed storefront order to the MERCHANT's GA4 property
19
+ * (AGL-1641).
20
+ *
21
+ * ## Why this exists at all
22
+ *
23
+ * The commerce plugin instrumented `view_item`, `add_to_cart` and
24
+ * `begin_checkout` and then stopped. GA4's built-in ecommerce reports and the
25
+ * shopping-behaviour funnel are all terminated by `purchase`, so without it a
26
+ * merchant's property did not merely lack one number — it rendered an
27
+ * authoritative-looking 0% conversion rate and zero revenue. The console's own
28
+ * commerce analytics card meanwhile promised merchants that `purchase` already
29
+ * mirrored into their Google Analytics.
30
+ *
31
+ * ## Client-side, deliberately — the opposite of the call made for OUR revenue
32
+ *
33
+ * Aglyn's own `purchase` is sent server-side over the Measurement Protocol,
34
+ * because a lost hit there is lost revenue reporting on our books. This one is
35
+ * client-side, and the reasoning inverts with the consequence: server-side
36
+ * would require collecting, encrypting and supporting a per-host Measurement
37
+ * Protocol API secret we have nowhere to store, to buy accuracy against
38
+ * closed tabs and ad blockers that every storefront on the internet already
39
+ * accepts. For a merchant's product analytics that is the industry norm; for
40
+ * our revenue it would not have been.
41
+ *
42
+ * ## Where it fires
43
+ *
44
+ * On the page Stripe returns the shopper to, which is the page they left —
45
+ * there is no order-confirmation surface on a tenant storefront. That is the
46
+ * Cart for a cart checkout and the ProductDetail for a single-product buy,
47
+ * which is exactly why both call this hook.
48
+ *
49
+ * ## The two waits
50
+ *
51
+ * The order is written by the webhook, which can land AFTER the shopper is
52
+ * back, so the lookup retries. And `window.gtag` only exists once the visitor
53
+ * has granted analytics consent and the consent-gated script has loaded
54
+ * post-hydration, so the send waits for it — otherwise the event would be
55
+ * built correctly and dropped on the floor. Both waits are bounded; an
56
+ * ungranted visitor simply times out, which is the consent gate working.
57
+ */
58
+ export declare function useStorefrontPurchaseEvent(hostId: string,
59
+ /** `Aglyn.useSiteFetch()`. A GET, so preview mode passes it straight through. */
60
+ siteFetch?: typeof fetch): void;
@@ -0,0 +1,142 @@
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
+ */ import { trackEvent } from "@aglyn/aglyn/app-utils/analytics-events";
17
+ import { useEffect } from "react";
18
+ import { buildStorefrontPurchaseParams } from "../model/purchase-analytics.js";
19
+ /** How long to wait out the `checkout.session.completed` webhook. */ const MAX_ATTEMPTS = 8;
20
+ const RETRY_MS = 1500;
21
+ /** How long to wait for the consent-gated gtag script to exist. */ const GTAG_ATTEMPTS = 20;
22
+ const GTAG_MS = 250;
23
+ /**
24
+ * Once per browser session per order, across both mount points. `sessionStorage`
25
+ * survives the reload; the in-memory set covers a page carrying BOTH a Cart and
26
+ * a ProductDetail, which would otherwise race before either had written.
27
+ */ const reported = new Set();
28
+ const STORAGE_PREFIX = 'aglyn:purchase-reported:';
29
+ function alreadyReported(sessionId) {
30
+ if (reported.has(sessionId)) return true;
31
+ try {
32
+ return window.sessionStorage.getItem(STORAGE_PREFIX + sessionId) === '1';
33
+ } catch (unused) {
34
+ // Private mode / storage disabled. GA4's own de-duplication on
35
+ // `transaction_id` is the real guarantee; this is only the cheap half.
36
+ return false;
37
+ }
38
+ }
39
+ function markReported(sessionId) {
40
+ reported.add(sessionId);
41
+ try {
42
+ window.sessionStorage.setItem(STORAGE_PREFIX + sessionId, '1');
43
+ } catch (unused) {
44
+ /* see above */ }
45
+ }
46
+ const sleep = (ms)=>new Promise((resolve)=>setTimeout(resolve, ms));
47
+ /**
48
+ * Report a completed storefront order to the MERCHANT's GA4 property
49
+ * (AGL-1641).
50
+ *
51
+ * ## Why this exists at all
52
+ *
53
+ * The commerce plugin instrumented `view_item`, `add_to_cart` and
54
+ * `begin_checkout` and then stopped. GA4's built-in ecommerce reports and the
55
+ * shopping-behaviour funnel are all terminated by `purchase`, so without it a
56
+ * merchant's property did not merely lack one number — it rendered an
57
+ * authoritative-looking 0% conversion rate and zero revenue. The console's own
58
+ * commerce analytics card meanwhile promised merchants that `purchase` already
59
+ * mirrored into their Google Analytics.
60
+ *
61
+ * ## Client-side, deliberately — the opposite of the call made for OUR revenue
62
+ *
63
+ * Aglyn's own `purchase` is sent server-side over the Measurement Protocol,
64
+ * because a lost hit there is lost revenue reporting on our books. This one is
65
+ * client-side, and the reasoning inverts with the consequence: server-side
66
+ * would require collecting, encrypting and supporting a per-host Measurement
67
+ * Protocol API secret we have nowhere to store, to buy accuracy against
68
+ * closed tabs and ad blockers that every storefront on the internet already
69
+ * accepts. For a merchant's product analytics that is the industry norm; for
70
+ * our revenue it would not have been.
71
+ *
72
+ * ## Where it fires
73
+ *
74
+ * On the page Stripe returns the shopper to, which is the page they left —
75
+ * there is no order-confirmation surface on a tenant storefront. That is the
76
+ * Cart for a cart checkout and the ProductDetail for a single-product buy,
77
+ * which is exactly why both call this hook.
78
+ *
79
+ * ## The two waits
80
+ *
81
+ * The order is written by the webhook, which can land AFTER the shopper is
82
+ * back, so the lookup retries. And `window.gtag` only exists once the visitor
83
+ * has granted analytics consent and the consent-gated script has loaded
84
+ * post-hydration, so the send waits for it — otherwise the event would be
85
+ * built correctly and dropped on the floor. Both waits are bounded; an
86
+ * ungranted visitor simply times out, which is the consent gate working.
87
+ */ export function useStorefrontPurchaseEvent(hostId, /** `Aglyn.useSiteFetch()`. A GET, so preview mode passes it straight through. */ siteFetch = fetch) {
88
+ useEffect(()=>{
89
+ var _params_get;
90
+ if (typeof window === 'undefined' || !hostId) return;
91
+ const params = new URLSearchParams(window.location.search);
92
+ if (params.get('order') !== 'success') return;
93
+ const sessionId = (_params_get = params.get('session_id')) != null ? _params_get : '';
94
+ if (!sessionId || alreadyReported(sessionId)) return;
95
+ let active = true;
96
+ // Claimed up front so a sibling mount in the same document cannot start a
97
+ // second poll for the same order. Persisted only once the hit is sent.
98
+ reported.add(sessionId);
99
+ void (async ()=>{
100
+ let source = null;
101
+ for(let attempt = 0; attempt < MAX_ATTEMPTS && active; attempt += 1){
102
+ try {
103
+ const response = await siteFetch(`/api/commerce/order-analytics?hostId=${encodeURIComponent(hostId)}&sessionId=${encodeURIComponent(sessionId)}`);
104
+ if (response.ok) {
105
+ source = await response.json();
106
+ break;
107
+ }
108
+ // 404 means the webhook has not written the order yet; anything
109
+ // else is terminal and retrying it would only add load.
110
+ if (response.status !== 404) return;
111
+ } catch (unused) {
112
+ // Network blip — treated like the race and retried.
113
+ }
114
+ await sleep(RETRY_MS);
115
+ }
116
+ if (!active || !source) return;
117
+ const purchase = buildStorefrontPurchaseParams(source);
118
+ if (!purchase) return;
119
+ // `trackEvent` no-ops when `window.gtag` is absent and never queues, so
120
+ // waiting for the tag IS the delivery mechanism here.
121
+ for(let attempt = 0; attempt < GTAG_ATTEMPTS && active; attempt += 1){
122
+ if (typeof window.gtag === 'function') {
123
+ trackEvent('purchase', purchase);
124
+ markReported(sessionId);
125
+ return;
126
+ }
127
+ await sleep(GTAG_MS);
128
+ }
129
+ })();
130
+ return ()=>{
131
+ active = false;
132
+ };
133
+ // `siteFetch` is deliberately out of the dep list: it is a `useCallback`
134
+ // that changes identity on a preview toggle, and re-running this effect
135
+ // would restart a poll that has already claimed its session id.
136
+ // eslint-disable-next-line react-hooks/exhaustive-deps
137
+ }, [
138
+ hostId
139
+ ]);
140
+ }
141
+
142
+ //# sourceMappingURL=use-storefront-purchase-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/utils/use-storefront-purchase-event.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 { trackEvent } from '@aglyn/aglyn/app-utils/analytics-events'\nimport { useEffect } from 'react'\nimport { buildStorefrontPurchaseParams } from '../model/purchase-analytics'\n\n/** How long to wait out the `checkout.session.completed` webhook. */\nconst MAX_ATTEMPTS = 8\nconst RETRY_MS = 1_500\n/** How long to wait for the consent-gated gtag script to exist. */\nconst GTAG_ATTEMPTS = 20\nconst GTAG_MS = 250\n\n/**\n * Once per browser session per order, across both mount points. `sessionStorage`\n * survives the reload; the in-memory set covers a page carrying BOTH a Cart and\n * a ProductDetail, which would otherwise race before either had written.\n */\nconst reported = new Set<string>()\nconst STORAGE_PREFIX = 'aglyn:purchase-reported:'\n\nfunction alreadyReported(sessionId: string): boolean {\n if (reported.has(sessionId)) return true\n try {\n return window.sessionStorage.getItem(STORAGE_PREFIX + sessionId) === '1'\n } catch {\n // Private mode / storage disabled. GA4's own de-duplication on\n // `transaction_id` is the real guarantee; this is only the cheap half.\n return false\n }\n}\n\nfunction markReported(sessionId: string): void {\n reported.add(sessionId)\n try {\n window.sessionStorage.setItem(STORAGE_PREFIX + sessionId, '1')\n } catch {\n /* see above */\n }\n}\n\nconst sleep = (ms: number) =>\n new Promise<void>((resolve) => setTimeout(resolve, ms))\n\n/**\n * Report a completed storefront order to the MERCHANT's GA4 property\n * (AGL-1641).\n *\n * ## Why this exists at all\n *\n * The commerce plugin instrumented `view_item`, `add_to_cart` and\n * `begin_checkout` and then stopped. GA4's built-in ecommerce reports and the\n * shopping-behaviour funnel are all terminated by `purchase`, so without it a\n * merchant's property did not merely lack one number — it rendered an\n * authoritative-looking 0% conversion rate and zero revenue. The console's own\n * commerce analytics card meanwhile promised merchants that `purchase` already\n * mirrored into their Google Analytics.\n *\n * ## Client-side, deliberately — the opposite of the call made for OUR revenue\n *\n * Aglyn's own `purchase` is sent server-side over the Measurement Protocol,\n * because a lost hit there is lost revenue reporting on our books. This one is\n * client-side, and the reasoning inverts with the consequence: server-side\n * would require collecting, encrypting and supporting a per-host Measurement\n * Protocol API secret we have nowhere to store, to buy accuracy against\n * closed tabs and ad blockers that every storefront on the internet already\n * accepts. For a merchant's product analytics that is the industry norm; for\n * our revenue it would not have been.\n *\n * ## Where it fires\n *\n * On the page Stripe returns the shopper to, which is the page they left —\n * there is no order-confirmation surface on a tenant storefront. That is the\n * Cart for a cart checkout and the ProductDetail for a single-product buy,\n * which is exactly why both call this hook.\n *\n * ## The two waits\n *\n * The order is written by the webhook, which can land AFTER the shopper is\n * back, so the lookup retries. And `window.gtag` only exists once the visitor\n * has granted analytics consent and the consent-gated script has loaded\n * post-hydration, so the send waits for it — otherwise the event would be\n * built correctly and dropped on the floor. Both waits are bounded; an\n * ungranted visitor simply times out, which is the consent gate working.\n */\nexport function useStorefrontPurchaseEvent(\n hostId: string,\n /** `Aglyn.useSiteFetch()`. A GET, so preview mode passes it straight through. */\n siteFetch: typeof fetch = fetch,\n): void {\n useEffect(() => {\n if (typeof window === 'undefined' || !hostId) return\n\n const params = new URLSearchParams(window.location.search)\n if (params.get('order') !== 'success') return\n const sessionId = params.get('session_id') ?? ''\n if (!sessionId || alreadyReported(sessionId)) return\n\n let active = true\n // Claimed up front so a sibling mount in the same document cannot start a\n // second poll for the same order. Persisted only once the hit is sent.\n reported.add(sessionId)\n\n void (async () => {\n let source: Parameters<typeof buildStorefrontPurchaseParams>[0] | null =\n null\n for (let attempt = 0; attempt < MAX_ATTEMPTS && active; attempt += 1) {\n try {\n const response = await siteFetch(\n `/api/commerce/order-analytics?hostId=${encodeURIComponent(\n hostId,\n )}&sessionId=${encodeURIComponent(sessionId)}`,\n )\n if (response.ok) {\n source = await response.json()\n break\n }\n // 404 means the webhook has not written the order yet; anything\n // else is terminal and retrying it would only add load.\n if (response.status !== 404) return\n } catch {\n // Network blip — treated like the race and retried.\n }\n await sleep(RETRY_MS)\n }\n if (!active || !source) return\n\n const purchase = buildStorefrontPurchaseParams(source)\n if (!purchase) return\n\n // `trackEvent` no-ops when `window.gtag` is absent and never queues, so\n // waiting for the tag IS the delivery mechanism here.\n for (let attempt = 0; attempt < GTAG_ATTEMPTS && active; attempt += 1) {\n if (typeof (window as any).gtag === 'function') {\n trackEvent('purchase', purchase)\n markReported(sessionId)\n return\n }\n await sleep(GTAG_MS)\n }\n })()\n\n return () => {\n active = false\n }\n // `siteFetch` is deliberately out of the dep list: it is a `useCallback`\n // that changes identity on a preview toggle, and re-running this effect\n // would restart a poll that has already claimed its session id.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [hostId])\n}\n"],"names":["trackEvent","useEffect","buildStorefrontPurchaseParams","MAX_ATTEMPTS","RETRY_MS","GTAG_ATTEMPTS","GTAG_MS","reported","Set","STORAGE_PREFIX","alreadyReported","sessionId","has","window","sessionStorage","getItem","markReported","add","setItem","sleep","ms","Promise","resolve","setTimeout","useStorefrontPurchaseEvent","hostId","siteFetch","fetch","params","URLSearchParams","location","search","get","active","source","attempt","response","encodeURIComponent","ok","json","status","purchase","gtag"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,UAAU,QAAQ,0CAAyC;AACpE,SAASC,SAAS,QAAQ,QAAO;AACjC,SAASC,6BAA6B,QAAQ,iCAA6B;AAE3E,mEAAmE,GACnE,MAAMC,eAAe;AACrB,MAAMC,WAAW;AACjB,iEAAiE,GACjE,MAAMC,gBAAgB;AACtB,MAAMC,UAAU;AAEhB;;;;CAIC,GACD,MAAMC,WAAW,IAAIC;AACrB,MAAMC,iBAAiB;AAEvB,SAASC,gBAAgBC,SAAiB;IACxC,IAAIJ,SAASK,GAAG,CAACD,YAAY,OAAO;IACpC,IAAI;QACF,OAAOE,OAAOC,cAAc,CAACC,OAAO,CAACN,iBAAiBE,eAAe;IACvE,EAAE,eAAM;QACN,+DAA+D;QAC/D,uEAAuE;QACvE,OAAO;IACT;AACF;AAEA,SAASK,aAAaL,SAAiB;IACrCJ,SAASU,GAAG,CAACN;IACb,IAAI;QACFE,OAAOC,cAAc,CAACI,OAAO,CAACT,iBAAiBE,WAAW;IAC5D,EAAE,eAAM;IACN,aAAa,GACf;AACF;AAEA,MAAMQ,QAAQ,CAACC,KACb,IAAIC,QAAc,CAACC,UAAYC,WAAWD,SAASF;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCC,GACD,OAAO,SAASI,2BACdC,MAAc,EACd,+EAA+E,GAC/EC,YAA0BC,KAAK;IAE/B1B,UAAU;YAKU2B;QAJlB,IAAI,OAAOf,WAAW,eAAe,CAACY,QAAQ;QAE9C,MAAMG,SAAS,IAAIC,gBAAgBhB,OAAOiB,QAAQ,CAACC,MAAM;QACzD,IAAIH,OAAOI,GAAG,CAAC,aAAa,WAAW;QACvC,MAAMrB,aAAYiB,cAAAA,OAAOI,GAAG,CAAC,yBAAXJ,cAA4B;QAC9C,IAAI,CAACjB,aAAaD,gBAAgBC,YAAY;QAE9C,IAAIsB,SAAS;QACb,0EAA0E;QAC1E,uEAAuE;QACvE1B,SAASU,GAAG,CAACN;QAEb,KAAK,AAAC,CAAA;YACJ,IAAIuB,SACF;YACF,IAAK,IAAIC,UAAU,GAAGA,UAAUhC,gBAAgB8B,QAAQE,WAAW,EAAG;gBACpE,IAAI;oBACF,MAAMC,WAAW,MAAMV,UACrB,CAAC,qCAAqC,EAAEW,mBACtCZ,QACA,WAAW,EAAEY,mBAAmB1B,YAAY;oBAEhD,IAAIyB,SAASE,EAAE,EAAE;wBACfJ,SAAS,MAAME,SAASG,IAAI;wBAC5B;oBACF;oBACA,gEAAgE;oBAChE,wDAAwD;oBACxD,IAAIH,SAASI,MAAM,KAAK,KAAK;gBAC/B,EAAE,eAAM;gBACN,oDAAoD;gBACtD;gBACA,MAAMrB,MAAMf;YACd;YACA,IAAI,CAAC6B,UAAU,CAACC,QAAQ;YAExB,MAAMO,WAAWvC,8BAA8BgC;YAC/C,IAAI,CAACO,UAAU;YAEf,wEAAwE;YACxE,sDAAsD;YACtD,IAAK,IAAIN,UAAU,GAAGA,UAAU9B,iBAAiB4B,QAAQE,WAAW,EAAG;gBACrE,IAAI,OAAO,AAACtB,OAAe6B,IAAI,KAAK,YAAY;oBAC9C1C,WAAW,YAAYyC;oBACvBzB,aAAaL;oBACb;gBACF;gBACA,MAAMQ,MAAMb;YACd;QACF,CAAA;QAEA,OAAO;YACL2B,SAAS;QACX;IACA,yEAAyE;IACzE,wEAAwE;IACxE,gEAAgE;IAChE,uDAAuD;IACzD,GAAG;QAACR;KAAO;AACb"}