@mohasinac/appkit 4.62.0 → 4.63.0

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 (391) hide show
  1. package/dist/.build-stamp.json +3 -3
  2. package/dist/_internal/client/features/layout/DashboardLayoutClient.js +8 -29
  3. package/dist/_internal/client/features/layout/filterNavItems.d.ts +28 -0
  4. package/dist/_internal/client/features/layout/filterNavItems.js +35 -0
  5. package/dist/_internal/server/features/ads/booking.d.ts +118 -0
  6. package/dist/_internal/server/features/ads/booking.js +326 -0
  7. package/dist/_internal/server/features/checkout/actions.d.ts +129 -9
  8. package/dist/_internal/server/features/checkout/actions.js +850 -79
  9. package/dist/_internal/server/features/checkout/expand-order-items.d.ts +1 -2
  10. package/dist/_internal/server/features/checkout/expand-order-items.js +32 -0
  11. package/dist/_internal/server/features/checkout/freeze-parts.d.ts +50 -0
  12. package/dist/_internal/server/features/checkout/freeze-parts.js +94 -0
  13. package/dist/_internal/server/features/checkout/value-otp-gate.d.ts +55 -0
  14. package/dist/_internal/server/features/checkout/value-otp-gate.js +60 -0
  15. package/dist/_internal/server/features/dashboard/attention.d.ts +128 -0
  16. package/dist/_internal/server/features/dashboard/attention.js +183 -0
  17. package/dist/_internal/server/features/dashboard/data.d.ts +47 -0
  18. package/dist/_internal/server/features/dashboard/data.js +82 -0
  19. package/dist/_internal/server/features/inventory/reservations.d.ts +99 -0
  20. package/dist/_internal/server/features/inventory/reservations.js +273 -0
  21. package/dist/_internal/server/features/invoicing/allocate.d.ts +63 -0
  22. package/dist/_internal/server/features/invoicing/allocate.js +162 -0
  23. package/dist/_internal/server/features/invoicing/credit-note.d.ts +57 -0
  24. package/dist/_internal/server/features/invoicing/credit-note.js +126 -0
  25. package/dist/_internal/server/features/invoicing/gstr1.d.ts +74 -0
  26. package/dist/_internal/server/features/invoicing/gstr1.js +251 -0
  27. package/dist/_internal/server/features/invoicing/issue.d.ts +96 -0
  28. package/dist/_internal/server/features/invoicing/issue.js +202 -0
  29. package/dist/_internal/server/features/offers/destinations.d.ts +40 -0
  30. package/dist/_internal/server/features/offers/destinations.js +65 -0
  31. package/dist/_internal/server/features/orders/actions.d.ts +8 -1
  32. package/dist/_internal/server/features/orders/actions.js +81 -8
  33. package/dist/_internal/server/features/orders/adapters.js +54 -0
  34. package/dist/_internal/server/features/orders/amend-delivery.d.ts +56 -0
  35. package/dist/_internal/server/features/orders/amend-delivery.js +124 -0
  36. package/dist/_internal/server/features/orders/balance.d.ts +89 -0
  37. package/dist/_internal/server/features/orders/balance.js +256 -0
  38. package/dist/_internal/server/features/orders/cancellation-refund.d.ts +15 -9
  39. package/dist/_internal/server/features/orders/cancellation-refund.js +15 -9
  40. package/dist/_internal/server/features/points/award.js +46 -4
  41. package/dist/_internal/server/features/pricing/actions.d.ts +58 -0
  42. package/dist/_internal/server/features/pricing/actions.js +144 -0
  43. package/dist/_internal/server/features/refunds/actions.js +26 -0
  44. package/dist/_internal/server/features/shipping/book-split.d.ts +86 -0
  45. package/dist/_internal/server/features/shipping/book-split.js +130 -0
  46. package/dist/_internal/server/features/shipping/book.d.ts +61 -0
  47. package/dist/_internal/server/features/shipping/book.js +176 -0
  48. package/dist/_internal/server/features/shipping/courier-block.d.ts +69 -0
  49. package/dist/_internal/server/features/shipping/courier-block.js +264 -0
  50. package/dist/_internal/server/features/site-settings/adapters.d.ts +2 -2
  51. package/dist/_internal/server/features/site-settings/adapters.js +29 -0
  52. package/dist/_internal/server/features/stores/adapters.d.ts +2 -2
  53. package/dist/_internal/server/features/stores/adapters.js +65 -0
  54. package/dist/_internal/server/functions/scheduled.d.ts +2 -1
  55. package/dist/_internal/server/functions/scheduled.js +95 -2
  56. package/dist/_internal/server/jobs/core/autoPayoutEligibility.js +11 -2
  57. package/dist/_internal/server/jobs/core/dailyStatusDigest.d.ts +4 -0
  58. package/dist/_internal/server/jobs/core/dailyStatusDigest.js +19 -2
  59. package/dist/_internal/server/jobs/core/index.d.ts +2 -1
  60. package/dist/_internal/server/jobs/core/index.js +2 -1
  61. package/dist/_internal/server/jobs/core/jobRunners.js +45 -0
  62. package/dist/_internal/server/jobs/core/onJobCreated.d.ts +30 -7
  63. package/dist/_internal/server/jobs/core/onJobCreated.js +78 -45
  64. package/dist/_internal/server/jobs/core/onOrderStatusChange.d.ts +7 -0
  65. package/dist/_internal/server/jobs/core/onOrderStatusChange.js +65 -0
  66. package/dist/_internal/server/jobs/core/paymentWindowTimeout.js +33 -0
  67. package/dist/_internal/server/jobs/core/reservationExpiry.d.ts +17 -0
  68. package/dist/_internal/server/jobs/core/reservationExpiry.js +40 -0
  69. package/dist/_internal/server/jobs/core/runJobOnce.d.ts +48 -0
  70. package/dist/_internal/server/jobs/core/runJobOnce.js +195 -0
  71. package/dist/_internal/server/jobs/core/weeklyPayoutEligibility.js +25 -2
  72. package/dist/_internal/server/jobs/handlers/index.d.ts +1 -0
  73. package/dist/_internal/server/jobs/handlers/index.js +1 -0
  74. package/dist/_internal/server/jobs/handlers/onOrderStatusChange.js +17 -0
  75. package/dist/_internal/server/jobs/handlers/reservationExpiry.d.ts +2 -0
  76. package/dist/_internal/server/jobs/handlers/reservationExpiry.js +2 -0
  77. package/dist/_internal/server/notifications/channel-health.d.ts +26 -3
  78. package/dist/_internal/shared/actions/action-registry.d.ts +1 -1
  79. package/dist/_internal/shared/actions/action-registry.js +296 -0
  80. package/dist/_internal/shared/checkout/coupon-discount.d.ts +43 -1
  81. package/dist/_internal/shared/checkout/coupon-discount.js +26 -1
  82. package/dist/_internal/shared/checkout/order-math.d.ts +174 -0
  83. package/dist/_internal/shared/checkout/order-math.js +159 -0
  84. package/dist/_internal/shared/checkout/refundable-base.d.ts +25 -0
  85. package/dist/_internal/shared/checkout/refundable-base.js +13 -1
  86. package/dist/_internal/shared/checkout/rules/index.d.ts +1 -1
  87. package/dist/_internal/shared/checkout/rules/index.js +1 -1
  88. package/dist/_internal/shared/checkout/rules/payment-gate.d.ts +18 -0
  89. package/dist/_internal/shared/checkout/rules/payment-gate.js +25 -0
  90. package/dist/_internal/shared/checkout/split.d.ts +75 -0
  91. package/dist/_internal/shared/checkout/split.js +120 -0
  92. package/dist/_internal/shared/content/disclaimers.d.ts +88 -0
  93. package/dist/_internal/shared/content/disclaimers.js +217 -0
  94. package/dist/_internal/shared/content/published-values.d.ts +93 -0
  95. package/dist/_internal/shared/content/published-values.js +206 -0
  96. package/dist/_internal/shared/features/admin/integrations.d.ts +139 -0
  97. package/dist/_internal/shared/features/admin/integrations.js +263 -0
  98. package/dist/_internal/shared/features/dashboard/hub-sections.d.ts +72 -0
  99. package/dist/_internal/shared/features/dashboard/hub-sections.js +75 -0
  100. package/dist/_internal/shared/features/emi/choice.d.ts +98 -0
  101. package/dist/_internal/shared/features/emi/choice.js +69 -0
  102. package/dist/_internal/shared/features/emi/group.d.ts +84 -0
  103. package/dist/_internal/shared/features/emi/group.js +126 -0
  104. package/dist/_internal/shared/features/ledger/posting.d.ts +107 -0
  105. package/dist/_internal/shared/features/ledger/posting.js +165 -0
  106. package/dist/_internal/shared/features/ledger/reports.d.ts +76 -0
  107. package/dist/_internal/shared/features/ledger/reports.js +127 -0
  108. package/dist/_internal/shared/features/ledger/rules.d.ts +170 -0
  109. package/dist/_internal/shared/features/ledger/rules.js +221 -0
  110. package/dist/_internal/shared/features/offers/coordination.d.ts +122 -0
  111. package/dist/_internal/shared/features/offers/coordination.js +80 -0
  112. package/dist/_internal/shared/features/orders/delivery-snapshot.d.ts +114 -0
  113. package/dist/_internal/shared/features/orders/delivery-snapshot.js +116 -0
  114. package/dist/_internal/shared/features/orders/dispute-reasons.d.ts +113 -0
  115. package/dist/_internal/shared/features/orders/dispute-reasons.js +181 -0
  116. package/dist/_internal/shared/features/orders/refund-copy.d.ts +1 -1
  117. package/dist/_internal/shared/features/orders/refund-copy.js +18 -1
  118. package/dist/_internal/shared/features/payouts/pay-period.d.ts +91 -0
  119. package/dist/_internal/shared/features/payouts/pay-period.js +104 -0
  120. package/dist/_internal/shared/features/points/accepts.d.ts +29 -0
  121. package/dist/_internal/shared/features/points/accepts.js +49 -0
  122. package/dist/_internal/shared/features/pricing/rate-registry.d.ts +150 -0
  123. package/dist/_internal/shared/features/pricing/rate-registry.js +246 -0
  124. package/dist/_internal/shared/features/shipping/parcel.d.ts +123 -0
  125. package/dist/_internal/shared/features/shipping/parcel.js +139 -0
  126. package/dist/_internal/shared/features/shipping/shared-purchase.d.ts +91 -0
  127. package/dist/_internal/shared/features/shipping/shared-purchase.js +108 -0
  128. package/dist/_internal/shared/features/site-settings/fees.d.ts +16 -8
  129. package/dist/_internal/shared/features/site-settings/fees.js +12 -8
  130. package/dist/_internal/shared/features/site-settings/types.d.ts +11 -0
  131. package/dist/_internal/shared/fees/calculator.d.ts +33 -1
  132. package/dist/_internal/shared/fees/calculator.js +32 -2
  133. package/dist/_internal/shared/fees/explain.d.ts +81 -0
  134. package/dist/_internal/shared/fees/explain.js +101 -0
  135. package/dist/_internal/shared/history/index.d.ts +1 -1
  136. package/dist/_internal/shared/history/index.js +1 -1
  137. package/dist/_internal/shared/history/types.d.ts +7 -1
  138. package/dist/_internal/shared/history/types.js +25 -0
  139. package/dist/client.d.ts +21 -0
  140. package/dist/client.js +43 -0
  141. package/dist/constants/api-endpoints.d.ts +114 -0
  142. package/dist/constants/api-endpoints.js +55 -0
  143. package/dist/constants/field-names.d.ts +42 -0
  144. package/dist/constants/field-names.js +52 -0
  145. package/dist/contracts/index.d.ts +1 -1
  146. package/dist/contracts/shipping.d.ts +45 -0
  147. package/dist/contracts/shipping.js +15 -0
  148. package/dist/features/about/components/AboutView.js +1 -1
  149. package/dist/features/account/components/BuyerAuctionsGuideView.js +4 -1
  150. package/dist/features/account/components/UserOrdersView.js +47 -35
  151. package/dist/features/admin/components/AdminCouponEditorView.js +17 -0
  152. package/dist/features/admin/components/AdminIntegrationsView.d.ts +55 -0
  153. package/dist/features/admin/components/AdminIntegrationsView.js +74 -0
  154. package/dist/features/admin/components/AdminInvoicingView.d.ts +2 -0
  155. package/dist/features/admin/components/AdminInvoicingView.js +65 -0
  156. package/dist/features/admin/components/AdminOrderEditorView.d.ts +33 -1
  157. package/dist/features/admin/components/AdminOrderEditorView.js +81 -3
  158. package/dist/features/admin/components/AdminOrdersGuideView.js +23 -2
  159. package/dist/features/admin/components/AdminOrdersView.js +86 -5
  160. package/dist/features/admin/components/OwnerQuickActions.js +24 -2
  161. package/dist/features/admin/constants/filter-tabs.d.ts +6 -0
  162. package/dist/features/admin/constants/filter-tabs.js +6 -0
  163. package/dist/features/admin/constants/site-settings-tabs.d.ts +1 -1
  164. package/dist/features/admin/hooks/useAdminListingData.js +16 -0
  165. package/dist/features/admin/schemas/admin-user-form.d.ts +2 -2
  166. package/dist/features/admin/schemas/firestore.d.ts +62 -0
  167. package/dist/features/admin/schemas/firestore.js +5 -0
  168. package/dist/features/ads/schemas/booking-write.d.ts +120 -0
  169. package/dist/features/ads/schemas/booking-write.js +75 -0
  170. package/dist/features/ads/schemas/creative-form.d.ts +18 -0
  171. package/dist/features/ads/schemas/creative-form.js +51 -0
  172. package/dist/features/ads/schemas/firestore.d.ts +140 -0
  173. package/dist/features/ads/schemas/firestore.js +109 -0
  174. package/dist/features/auctions/repository/bid.repository.js +3 -1
  175. package/dist/features/audit-log/schemas/firestore.d.ts +140 -0
  176. package/dist/features/audit-log/schemas/firestore.js +89 -0
  177. package/dist/features/auth/actions/profile-actions.d.ts +69 -1
  178. package/dist/features/auth/actions/profile-actions.js +62 -1
  179. package/dist/features/auth/permissions/constants.js +13 -0
  180. package/dist/features/auth/schemas/firestore.d.ts +16 -2
  181. package/dist/features/auth/schemas/firestore.js +2 -1
  182. package/dist/features/blog/actions/blog-actions.d.ts +6 -0
  183. package/dist/features/blog/actions/blog-actions.js +17 -2
  184. package/dist/features/blog/api/route.js +4 -1
  185. package/dist/features/blog/columns/index.js +5 -0
  186. package/dist/features/blog/components/BlogIndexPageView.js +2 -1
  187. package/dist/features/blog/repository/blog.repository.d.ts +4 -0
  188. package/dist/features/blog/repository/blog.repository.js +5 -0
  189. package/dist/features/blog/schemas/blog-form.d.ts +3 -0
  190. package/dist/features/blog/schemas/blog-form.js +1 -0
  191. package/dist/features/blog/schemas/firestore.d.ts +38 -1
  192. package/dist/features/blog/schemas/firestore.js +23 -0
  193. package/dist/features/blog/schemas/index.d.ts +6 -0
  194. package/dist/features/blog/schemas/index.js +2 -0
  195. package/dist/features/blog/types/index.d.ts +2 -0
  196. package/dist/features/cart/components/CartPriceBreakdown.d.ts +25 -1
  197. package/dist/features/cart/components/CartPriceBreakdown.js +29 -6
  198. package/dist/features/cart/components/PointsTenderPicker.d.ts +61 -0
  199. package/dist/features/cart/components/PointsTenderPicker.js +15 -0
  200. package/dist/features/cart/components/StoreAddonsPicker.js +2 -1
  201. package/dist/features/cart/components/index.d.ts +2 -0
  202. package/dist/features/cart/components/index.js +1 -0
  203. package/dist/features/cart/repository/cart.repository.d.ts +33 -0
  204. package/dist/features/cart/repository/cart.repository.js +47 -0
  205. package/dist/features/cart/schemas/firestore.d.ts +116 -0
  206. package/dist/features/contact/email.d.ts +27 -10
  207. package/dist/features/contact/email.js +20 -3
  208. package/dist/features/dashboard/components/DashboardHubView.d.ts +83 -0
  209. package/dist/features/dashboard/components/DashboardHubView.js +56 -0
  210. package/dist/features/dashboard/components/DashboardSectionsClient.d.ts +23 -0
  211. package/dist/features/dashboard/components/DashboardSectionsClient.js +66 -0
  212. package/dist/features/dispute-reasons/components/AdminDisputeReasonsView.d.ts +55 -0
  213. package/dist/features/dispute-reasons/components/AdminDisputeReasonsView.js +175 -0
  214. package/dist/features/dispute-reasons/repository/dispute-reasons.repository.d.ts +62 -0
  215. package/dist/features/dispute-reasons/repository/dispute-reasons.repository.js +108 -0
  216. package/dist/features/dispute-reasons/schemas/firestore.d.ts +62 -0
  217. package/dist/features/dispute-reasons/schemas/firestore.js +40 -0
  218. package/dist/features/events/components/EventSaleBanner.js +1 -1
  219. package/dist/features/faq/components/FAQAccordion.d.ts +13 -1
  220. package/dist/features/faq/components/FAQAccordion.js +29 -4
  221. package/dist/features/faq/components/FAQPageContent.js +2 -2
  222. package/dist/features/gateway-events/schemas/index.d.ts +2 -2
  223. package/dist/features/homepage/schemas/index.d.ts +8 -8
  224. package/dist/features/inventory/schemas/stock-reservation.d.ts +114 -0
  225. package/dist/features/inventory/schemas/stock-reservation.js +103 -0
  226. package/dist/features/invoicing/schemas/firestore.d.ts +112 -0
  227. package/dist/features/invoicing/schemas/firestore.js +45 -0
  228. package/dist/features/invoicing/utils/financial-year.d.ts +43 -0
  229. package/dist/features/invoicing/utils/financial-year.js +53 -0
  230. package/dist/features/jobs/actions/enqueue-job.js +18 -1
  231. package/dist/features/jobs/repository/jobs.repository.d.ts +62 -1
  232. package/dist/features/jobs/repository/jobs.repository.js +84 -1
  233. package/dist/features/jobs/schemas/firestore.d.ts +80 -0
  234. package/dist/features/jobs/schemas/firestore.js +37 -0
  235. package/dist/features/layout/AppLayoutShell.d.ts +9 -1
  236. package/dist/features/layout/AppLayoutShell.js +12 -4
  237. package/dist/features/layout/BottomActions.js +2 -1
  238. package/dist/features/layout/BottomNavbar.d.ts +10 -2
  239. package/dist/features/layout/SideActionDock.js +52 -2
  240. package/dist/features/layout/TitleBarLayout.js +13 -4
  241. package/dist/features/layout/TitleBarLayout.style.css +59 -0
  242. package/dist/features/layout/useCtaReveal.d.ts +16 -1
  243. package/dist/features/layout/useCtaReveal.js +17 -26
  244. package/dist/features/ledger/repository/journal.repository.d.ts +110 -0
  245. package/dist/features/ledger/repository/journal.repository.js +312 -0
  246. package/dist/features/ledger/schemas/expenses.d.ts +87 -0
  247. package/dist/features/ledger/schemas/expenses.js +27 -0
  248. package/dist/features/ledger/schemas/firestore.d.ts +183 -0
  249. package/dist/features/ledger/schemas/firestore.js +69 -0
  250. package/dist/features/lottery/schemas/zod.d.ts +6 -6
  251. package/dist/features/media/MediaImage.js +22 -1
  252. package/dist/features/media/upload/ImageUpload.js +1 -1
  253. package/dist/features/obligations/constants/policies.js +24 -1
  254. package/dist/features/orders/components/BalancePaymentPanel.d.ts +12 -0
  255. package/dist/features/orders/components/BalancePaymentPanel.js +94 -0
  256. package/dist/features/orders/components/OrderPaymentSummary.js +10 -1
  257. package/dist/features/orders/components/OrderProvenanceCard.d.ts +8 -0
  258. package/dist/features/orders/components/OrderProvenanceCard.js +185 -0
  259. package/dist/features/orders/components/RaiseDisputeForm.d.ts +14 -0
  260. package/dist/features/orders/components/RaiseDisputeForm.js +119 -0
  261. package/dist/features/orders/components/RefundRequestView.js +19 -1
  262. package/dist/features/orders/components/index.d.ts +4 -0
  263. package/dist/features/orders/components/index.js +2 -0
  264. package/dist/features/orders/constants/order-lane-tabs.d.ts +69 -0
  265. package/dist/features/orders/constants/order-lane-tabs.js +88 -0
  266. package/dist/features/orders/repository/orders.repository.d.ts +85 -1
  267. package/dist/features/orders/repository/orders.repository.js +205 -6
  268. package/dist/features/orders/schemas/balance.d.ts +40 -0
  269. package/dist/features/orders/schemas/balance.js +47 -0
  270. package/dist/features/orders/schemas/firestore.d.ts +398 -1
  271. package/dist/features/orders/schemas/firestore.js +43 -0
  272. package/dist/features/orders/schemas/index.d.ts +56 -8
  273. package/dist/features/orders/schemas/index.js +12 -0
  274. package/dist/features/orders/types/index.d.ts +47 -0
  275. package/dist/features/orders/utils/courier-block.d.ts +25 -0
  276. package/dist/features/orders/utils/courier-block.js +23 -0
  277. package/dist/features/payment-cases/schemas/firestore.d.ts +26 -1
  278. package/dist/features/payment-cases/schemas/firestore.js +1 -0
  279. package/dist/features/payments/repository/payout.repository.js +3 -2
  280. package/dist/features/payments/schemas/firestore.d.ts +92 -1
  281. package/dist/features/payments/schemas/firestore.js +23 -0
  282. package/dist/features/pricing/components/AdminPricingView.d.ts +13 -0
  283. package/dist/features/pricing/components/AdminPricingView.js +157 -0
  284. package/dist/features/products/components/PrizeDrawDetailPageView.js +2 -2
  285. package/dist/features/products/components/ProductDetailPageView.d.ts +17 -1
  286. package/dist/features/products/components/ProductDetailPageView.js +2 -2
  287. package/dist/features/products/schemas/firestore.d.ts +26 -1
  288. package/dist/features/products/schemas/firestore.js +2 -0
  289. package/dist/features/products/schemas/index.d.ts +2 -2
  290. package/dist/features/products/schemas/product-features.validators.d.ts +10 -10
  291. package/dist/features/promotions/actions/coupon-stacking.d.ts +30 -3
  292. package/dist/features/promotions/actions/coupon-stacking.js +21 -2
  293. package/dist/features/promotions/components/CouponCard.js +13 -0
  294. package/dist/features/promotions/constants/coupon-help.d.ts +2 -2
  295. package/dist/features/promotions/constants/coupon-help.js +9 -1
  296. package/dist/features/promotions/schemas/firestore.d.ts +24 -0
  297. package/dist/features/promotions/schemas/firestore.js +4 -0
  298. package/dist/features/promotions/types/index.d.ts +19 -1
  299. package/dist/features/reviews/repository/reviews.repository.d.ts +14 -0
  300. package/dist/features/reviews/repository/reviews.repository.js +16 -0
  301. package/dist/features/scams/components/ScamProfileView.js +2 -2
  302. package/dist/features/scams/components/ScamRegistryView.js +2 -2
  303. package/dist/features/scams/repository/scammer.repository.js +2 -1
  304. package/dist/features/scams/schemas/firestore.d.ts +2 -1
  305. package/dist/features/scams/schemas/firestore.js +2 -1
  306. package/dist/features/search/action-index/tab-entries.js +1 -1
  307. package/dist/features/seller/actions/offer-actions.js +56 -0
  308. package/dist/features/seller/actions/seller-actions.d.ts +1 -1
  309. package/dist/features/seller/actions/seller-actions.js +37 -3
  310. package/dist/features/seller/components/DispatchForm.d.ts +11 -0
  311. package/dist/features/seller/components/DispatchForm.js +190 -0
  312. package/dist/features/seller/components/SellerOrdersView.js +221 -27
  313. package/dist/features/seller/components/index.d.ts +1 -0
  314. package/dist/features/seller/components/index.js +1 -0
  315. package/dist/features/seller/hooks/useSellerListingData.js +25 -0
  316. package/dist/features/seller/repository/offer.repository.js +4 -3
  317. package/dist/features/seller/schemas/firestore.d.ts +23 -2
  318. package/dist/features/seller/schemas/firestore.js +3 -2
  319. package/dist/features/seller/schemas/index.d.ts +4 -4
  320. package/dist/features/seller/schemas/order-forms.d.ts +61 -4
  321. package/dist/features/seller/schemas/order-forms.js +41 -8
  322. package/dist/features/shipments/schemas/firestore.d.ts +25 -0
  323. package/dist/features/shipments/schemas/validation.d.ts +4 -4
  324. package/dist/features/shipping-boxes/repository/shipping-boxes.repository.d.ts +82 -0
  325. package/dist/features/shipping-boxes/repository/shipping-boxes.repository.js +145 -0
  326. package/dist/features/shipping-boxes/schemas/firestore.d.ts +80 -0
  327. package/dist/features/shipping-boxes/schemas/firestore.js +53 -0
  328. package/dist/features/store-extensions/schemas/report-create-form.d.ts +2 -2
  329. package/dist/features/store-extensions/schemas/shipping-config-form.d.ts +2 -2
  330. package/dist/features/stores/components/StoreOrdersGuideView.js +6 -1
  331. package/dist/features/stores/repository/store.repository.d.ts +18 -0
  332. package/dist/features/stores/repository/store.repository.js +27 -1
  333. package/dist/features/stores/schemas/firestore.d.ts +112 -0
  334. package/dist/features/stores/schemas/firestore.js +20 -0
  335. package/dist/features/stores/schemas/index.d.ts +6 -6
  336. package/dist/features/stores/types/index.d.ts +19 -0
  337. package/dist/features/support/repository/support.repository.js +72 -6
  338. package/dist/features/support/schemas/firestore.d.ts +17 -0
  339. package/dist/features/support/schemas/index.d.ts +8 -8
  340. package/dist/features/wishlist/hooks/useWishlistWithGuest.d.ts +1 -1
  341. package/dist/index.d.ts +11 -1
  342. package/dist/index.js +33 -1
  343. package/dist/next/routing/route-map.d.ts +112 -0
  344. package/dist/next/routing/route-map.js +63 -0
  345. package/dist/providers/shipping-shiprocket/index.d.ts +27 -1
  346. package/dist/providers/shipping-shiprocket/index.js +84 -1
  347. package/dist/react/contexts/SessionContext.d.ts +17 -1
  348. package/dist/schemas/registry.d.ts +69 -34
  349. package/dist/schemas/sieve.d.ts +2 -2
  350. package/dist/security/pii-schemas.d.ts +1 -1
  351. package/dist/security/pii-schemas.js +45 -0
  352. package/dist/server-entry.d.ts +2 -2
  353. package/dist/server-entry.js +8 -1
  354. package/dist/server.d.ts +36 -1
  355. package/dist/server.js +183 -1
  356. package/dist/styles.css +412 -80
  357. package/dist/tailwind-utilities.css +1 -1
  358. package/dist/tokens/themes/default-dark.js +1 -0
  359. package/dist/tokens/themes/default-light.js +1 -0
  360. package/dist/tokens/themes/required.d.ts +1 -1
  361. package/dist/tokens/themes/required.js +1 -0
  362. package/dist/tokens/tokens.css +15 -0
  363. package/dist/ui/components/Button.d.ts +10 -1
  364. package/dist/ui/components/Button.js +25 -3
  365. package/dist/ui/components/Chart.d.ts +63 -0
  366. package/dist/ui/components/Chart.js +169 -0
  367. package/dist/ui/components/Chart.style.css +214 -0
  368. package/dist/ui/components/Disclaimer.d.ts +19 -0
  369. package/dist/ui/components/Disclaimer.js +83 -0
  370. package/dist/ui/components/OverflowRow.js +54 -2
  371. package/dist/ui/components/OverflowRow.style.css +38 -0
  372. package/dist/ui/components/RichTextEditor.js +99 -8
  373. package/dist/ui/components/chart-spec.d.ts +68 -0
  374. package/dist/ui/components/chart-spec.js +140 -0
  375. package/dist/ui/components/index.style.css +1 -0
  376. package/dist/ui/components/surface-tokens.d.ts +1 -1
  377. package/dist/ui/components/surface-tokens.js +9 -0
  378. package/dist/ui/components/tabs-overflow.js +64 -11
  379. package/dist/ui/components/toolbar-collapse.d.ts +13 -0
  380. package/dist/ui/components/toolbar-collapse.js +10 -1
  381. package/dist/ui/index.d.ts +8 -0
  382. package/dist/ui/index.js +9 -0
  383. package/dist/ui/rich-text/RichText.d.ts +10 -1
  384. package/dist/ui/rich-text/RichText.js +33 -2
  385. package/dist/ui/rich-text/RichText.style.css +83 -79
  386. package/dist/ui/rich-text/RichTextRenderer.d.ts +30 -1
  387. package/dist/ui/rich-text/RichTextRenderer.js +34 -2
  388. package/dist/ui/rich-text/chart-blocks.d.ts +62 -0
  389. package/dist/ui/rich-text/chart-blocks.js +87 -0
  390. package/package.json +1 -1
  391. package/scripts/seed-cli.mjs +1834 -1822
@@ -64,6 +64,73 @@ export function actionLabel(def) {
64
64
  // just establishes the shape + a few "obvious" actions that other Phase 5
65
65
  // flows can reference today.
66
66
  export const ACTIONS = {
67
+ /*
68
+ * D56 — self-serve ad bookings.
69
+ *
70
+ * 🛑 `book-ad-slot` carries a confirmation because it is a PURCHASE of a
71
+ * named month, and cancelling it does not free that month for re-sale —
72
+ * the booking document IS the availability lock and keeping it is
73
+ * deliberate. A control that spends money and cannot be undone by the
74
+ * person who clicked it is exactly what Rule #7's confirmation is for.
75
+ */
76
+ ADS: {
77
+ "book-ad-slot": {
78
+ iconKey: "create",
79
+ id: "ads.book-ad-slot",
80
+ label: "Book this slot",
81
+ ariaLabel: "Book this ad slot for the selected month",
82
+ description: "Reserves one placement for one month at the listed flat fee. The creative is reviewed by a person before it appears anywhere.",
83
+ kind: "primary",
84
+ permissions: ["user"],
85
+ confirmation: {
86
+ title: "Book this slot?",
87
+ body: "This reserves the placement for the whole month at the listed price. Cancelling later does not release the month for someone else to buy.",
88
+ confirmLabel: "Yes, book it",
89
+ },
90
+ },
91
+ "cancel-ad-booking": {
92
+ iconKey: "cancel",
93
+ id: "ads.cancel-ad-booking",
94
+ label: "Cancel booking",
95
+ ariaLabel: "Cancel this ad booking",
96
+ description: "Stops the creative running. 🛑 Does NOT free the month — the slot stays yours for the period you booked; releasing it is a separate admin act with a refund behind it.",
97
+ kind: "danger",
98
+ permissions: ["user"],
99
+ confirmation: {
100
+ title: "Cancel this booking?",
101
+ body: "Your ad stops running. The month is NOT released for another advertiser, and this does not issue a refund on its own.",
102
+ confirmLabel: "Yes, cancel",
103
+ },
104
+ },
105
+ "approve-ad-creative": {
106
+ iconKey: "verify",
107
+ id: "ads.approve-ad-creative",
108
+ label: "Approve creative",
109
+ ariaLabel: "Approve this ad creative so it can render",
110
+ description: "Clears the creative to render for its booked month. Approval is of THIS creative — an edit returns it to review.",
111
+ kind: "primary",
112
+ permissions: ["admin", "moderator"],
113
+ confirmation: {
114
+ title: "Approve this creative?",
115
+ body: "It will render on the public site for its booked month once the booking is paid.",
116
+ confirmLabel: "Yes, approve",
117
+ },
118
+ },
119
+ "reject-ad-creative": {
120
+ iconKey: "reject",
121
+ id: "ads.reject-ad-creative",
122
+ label: "Reject creative",
123
+ ariaLabel: "Reject this ad creative and tell the advertiser why",
124
+ description: "Sends it back with your note. A note is REQUIRED — without one the advertiser resubmits the same creative and you review it twice.",
125
+ kind: "danger",
126
+ permissions: ["admin", "moderator"],
127
+ confirmation: {
128
+ title: "Reject this creative?",
129
+ body: "The advertiser sees your note and can submit a new creative against the same booking. The slot stays theirs.",
130
+ confirmLabel: "Yes, reject",
131
+ },
132
+ },
133
+ },
67
134
  PRODUCT: {
68
135
  /*
69
136
  * The buyer-facing verbs below shipped long ago; the four CRUD entries
@@ -929,6 +996,36 @@ export const ACTIONS = {
929
996
  kind: "primary",
930
997
  permissions: ["seller", "admin"],
931
998
  },
999
+ "dispatch-custom": {
1000
+ iconKey: "ship",
1001
+ id: "store.dispatch-custom",
1002
+ label: "Record dispatch",
1003
+ ariaLabel: "Record a parcel you posted yourself",
1004
+ description: "Record the carrier and tracking id for a parcel the seller posted themselves.",
1005
+ kind: "primary",
1006
+ permissions: ["seller", "admin"],
1007
+ },
1008
+ "dispatch-platform": {
1009
+ iconKey: "ship",
1010
+ id: "store.dispatch-platform",
1011
+ label: "Book through the platform",
1012
+ ariaLabel: "Book this parcel through the platform's courier account",
1013
+ description: "Book a pickup on the platform's own carrier account. The tracking id comes back from the courier.",
1014
+ kind: "primary",
1015
+ permissions: ["seller", "admin"],
1016
+ /*
1017
+ * 🛑 Confirmed because it SPENDS MONEY and cannot be undone from this
1018
+ * screen. A booking debits the platform's carrier wallet and schedules
1019
+ * a real pickup; `bookShipment` then refuses a second attempt on the
1020
+ * same order, so a mis-click is not a thing the seller can take back by
1021
+ * pressing the button again.
1022
+ */
1023
+ confirmation: {
1024
+ title: "Book this parcel through the platform?",
1025
+ body: "A courier pickup will be scheduled at the address you picked and the cost charged to the platform's carrier account. This cannot be undone from here.",
1026
+ confirmLabel: "Book pickup",
1027
+ },
1028
+ },
932
1029
  "mark-installment-paid": {
933
1030
  iconKey: "confirm",
934
1031
  id: "store.mark-installment-paid",
@@ -1727,6 +1824,137 @@ export const ACTIONS = {
1727
1824
  },
1728
1825
  },
1729
1826
  ADMIN: {
1827
+ /*
1828
+ * ── Integration switches (12b) ──────────────────────────────────
1829
+ *
1830
+ * 🛑 The confirmation BODY is deliberately empty on `disable-integration`,
1831
+ * and that is not an omission.
1832
+ *
1833
+ * `INTEGRATIONS[id].offConsequence` is the real body, and it differs per
1834
+ * integration by design — "payments off" abandons in-flight payments,
1835
+ * "support off" hides a contact route, "shipping off" selects a working
1836
+ * manual path and stops nothing. A generic "are you sure?" here would
1837
+ * flatten exactly the distinction that file exists to preserve, and a COPY
1838
+ * of each consequence string would be a second place for it to drift from
1839
+ * (Root Cause #42). `AdminIntegrationsView` composes the dialog body from
1840
+ * the descriptor at render time.
1841
+ *
1842
+ * The registry still owns the label, the aria-label, the kind, and the fact
1843
+ * that a confirmation is REQUIRED — which is what Rule #7 is about.
1844
+ */
1845
+ "enable-integration": {
1846
+ iconKey: "approve",
1847
+ id: "admin.enable-integration",
1848
+ label: "Enable",
1849
+ ariaLabel: "Enable this integration",
1850
+ description: "Turn an integration on. Writes the authoritative settings field for it.",
1851
+ kind: "primary",
1852
+ permissions: ["admin"],
1853
+ },
1854
+ "update-pricing": {
1855
+ iconKey: "save",
1856
+ id: "admin.update-pricing",
1857
+ label: "Save new rate",
1858
+ ariaLabel: "Save the new rate",
1859
+ description: "Change one platform rate from now on. Orders, invoices and payouts already recorded keep the rate they were charged at — a rate change never restates history.",
1860
+ kind: "primary",
1861
+ permissions: ["admin"],
1862
+ /*
1863
+ * 🛑 A confirmation even though `kind` is "primary" rather than "danger".
1864
+ * The registry requires one for destructive actions; this one is here
1865
+ * because the act is IRREVERSIBLE IN A WAY THAT DOES NOT LOOK IT — the
1866
+ * rate moves forward only, so "undo" means a second change with a second
1867
+ * audit row, and nothing restores what was charged in between.
1868
+ */
1869
+ confirmation: {
1870
+ title: "Change this rate?",
1871
+ body: "Every checkout from now on uses the new value. Past orders, invoices and payouts are untouched and keep the rate they were charged at.",
1872
+ confirmLabel: "Change the rate",
1873
+ },
1874
+ },
1875
+ "add-dispute-reason": {
1876
+ iconKey: "create",
1877
+ id: "admin.add-dispute-reason",
1878
+ label: "Add reason",
1879
+ ariaLabel: "Add a dispute reason",
1880
+ description: "Add a reason buyers can pick when reporting a problem. The reason's KIND decides which gate it is subject to; the wording is yours.",
1881
+ kind: "primary",
1882
+ permissions: ["admin"],
1883
+ },
1884
+ "retire-dispute-reason": {
1885
+ iconKey: "reject",
1886
+ id: "admin.retire-dispute-reason",
1887
+ label: "Retire",
1888
+ ariaLabel: "Retire this dispute reason",
1889
+ description: "Take a reason out of the buyer's picker. Never a delete — past disputes name it, and the order snapshots its label so history survives either way.",
1890
+ kind: "danger",
1891
+ permissions: ["admin"],
1892
+ confirmation: {
1893
+ title: "Retire this reason?",
1894
+ /*
1895
+ * Names what retiring does NOT do, because that is the part an agent
1896
+ * is most likely to be unsure about and the reason this is not a
1897
+ * delete. A vague "are you sure" would invite exactly the hesitation
1898
+ * the schema's soft-retire design exists to remove.
1899
+ */
1900
+ body: "Buyers will stop seeing it on the dispute form. Disputes already raised under it keep their wording, and you can put it back at any time.",
1901
+ confirmLabel: "Retire it",
1902
+ confirmKind: "danger",
1903
+ },
1904
+ },
1905
+ "reactivate-dispute-reason": {
1906
+ iconKey: "approve",
1907
+ id: "admin.reactivate-dispute-reason",
1908
+ label: "Reactivate",
1909
+ ariaLabel: "Put this dispute reason back in the picker",
1910
+ description: "Offer a retired reason to buyers again. The original author is kept.",
1911
+ kind: "primary",
1912
+ permissions: ["admin"],
1913
+ },
1914
+ "disable-integration": {
1915
+ iconKey: "reject",
1916
+ id: "admin.disable-integration",
1917
+ label: "Disable",
1918
+ ariaLabel: "Disable this integration",
1919
+ description: "Turn an integration off. The consequence differs per integration and is stated on the row.",
1920
+ kind: "danger",
1921
+ permissions: ["admin"],
1922
+ confirmation: {
1923
+ title: "Switch this integration off?",
1924
+ body: "",
1925
+ confirmLabel: "Switch it off",
1926
+ confirmKind: "danger",
1927
+ },
1928
+ },
1929
+ "enable-all-integrations": {
1930
+ iconKey: "approve",
1931
+ id: "admin.enable-all-integrations",
1932
+ label: "Enable all",
1933
+ ariaLabel: "Enable every integration",
1934
+ description: "Turn every integration on in a single write.",
1935
+ kind: "secondary",
1936
+ permissions: ["admin"],
1937
+ confirmation: {
1938
+ title: "Enable every integration?",
1939
+ body: "Online payments, customer email, courier booking and the support surface will all be switched on. One write, one audit-log entry.",
1940
+ confirmLabel: "Enable everything",
1941
+ },
1942
+ },
1943
+ "disable-all-integrations": {
1944
+ iconKey: "reject",
1945
+ id: "admin.disable-all-integrations",
1946
+ label: "Disable all",
1947
+ ariaLabel: "Disable every integration",
1948
+ description: "Turn every integration off in a single write.",
1949
+ kind: "danger",
1950
+ permissions: ["admin"],
1951
+ confirmation: {
1952
+ title: "Disable every integration?",
1953
+ body: "This stops online payments, customer email and courier booking, and hides the buyer support surface. 🛑 Payments already in progress are abandoned — a buyer part-way through the gateway may be charged with no order placed. Staff email and open tickets stay workable. One write, one audit-log entry.",
1954
+ confirmLabel: "Disable everything",
1955
+ confirmKind: "danger",
1956
+ },
1957
+ },
1730
1958
  // ── Product moderation ─────────────────────────────────────────────────
1731
1959
  "approve-product": {
1732
1960
  iconKey: "approve",
@@ -1883,6 +2111,46 @@ export const ACTIONS = {
1883
2111
  confirmKind: "danger",
1884
2112
  },
1885
2113
  },
2114
+ /*
2115
+ * D55 — the pre-order BALANCE's two review verdicts.
2116
+ *
2117
+ * 🛑 Deliberately separate from `verify-payment` / `reject-payment-fraud`
2118
+ * above, which review the DEPOSIT. A pre-order's two payments are months
2119
+ * apart, and the consequences do not match: rejecting a deposit proof
2120
+ * cancels the order, restores stock and bans the account for 7 days,
2121
+ * because the order had no legitimate basis. Rejecting a BALANCE proof on
2122
+ * goods already made and allocated must do none of that — it asks for a
2123
+ * better screenshot. Reusing the deposit's action would attach a 7-day
2124
+ * ban to a blurry photo.
2125
+ */
2126
+ "verify-balance": {
2127
+ iconKey: "verify",
2128
+ id: "admin.verify-balance",
2129
+ label: "Accept Balance",
2130
+ ariaLabel: "Accept the pre-order balance payment proof",
2131
+ description: "Confirms the pre-order balance was received. The order becomes shippable. Does NOT post a ledger entry — the sale was recognised in full at order creation.",
2132
+ kind: "primary",
2133
+ permissions: ["admin", "moderator"],
2134
+ confirmation: {
2135
+ title: "Accept the balance payment?",
2136
+ body: "This records the remaining balance as received and clears the order to ship. Check the reference against your bank first.",
2137
+ confirmLabel: "Yes, accept",
2138
+ },
2139
+ },
2140
+ "reject-balance": {
2141
+ iconKey: "reject",
2142
+ id: "admin.reject-balance",
2143
+ label: "Reject Balance Proof",
2144
+ ariaLabel: "Reject the pre-order balance proof and ask the buyer to resend",
2145
+ description: "Sends the proof back with your note. The buyer can submit again — no cancellation, no stock change, no ban: the goods are already made and allocated to them.",
2146
+ kind: "secondary",
2147
+ permissions: ["admin", "moderator"],
2148
+ confirmation: {
2149
+ title: "Reject this balance proof?",
2150
+ body: "The buyer is told why and can send another. The order stays open and the item stays theirs.",
2151
+ confirmLabel: "Reject and ask again",
2152
+ },
2153
+ },
1886
2154
  "verify-vendor": {
1887
2155
  iconKey: "verify",
1888
2156
  id: "admin.verify-vendor",
@@ -3256,6 +3524,34 @@ export const ACTIONS = {
3256
3524
  confirmLabel: "Close ticket",
3257
3525
  },
3258
3526
  },
3527
+ /*
3528
+ * Raising a dispute on an order.
3529
+ *
3530
+ * Filed under SUPPORT rather than a new ORDER bucket: there is no such
3531
+ * bucket, and a dispute's destination is a support investigation. A first
3532
+ * draft of the form wrote `ACTIONS.ORDERS?.["raise-dispute"]`, where the
3533
+ * optional chain would have silently resolved to `undefined` and rendered
3534
+ * a button with no label, no aria-label and no confirmation — which is
3535
+ * precisely what Rule #7 exists to stop.
3536
+ *
3537
+ * NO `confirmation`, deliberately. It is not destructive: nothing is
3538
+ * cancelled, no money moves, and the action's own docstring says it "does
3539
+ * not itself reverse payment/order status". A confirm dialog in front of
3540
+ * "tell us something went wrong" adds friction to the one path a buyer
3541
+ * with a problem needs to be able to take.
3542
+ */
3543
+ "raise-dispute": {
3544
+ // `report`, which IS the Flag glyph (icon-registry.ts:133). `"flag"` is
3545
+ // not a registered key — and because `iconKey` is typed `IconKey` rather
3546
+ // than `string`, that would have been a compile error rather than the
3547
+ // silent no-op it used to be.
3548
+ iconKey: "report",
3549
+ id: "support.raise-dispute",
3550
+ label: "Report this",
3551
+ ariaLabel: "Report a problem with this order",
3552
+ description: "Raise a dispute on an order for support to investigate.",
3553
+ kind: "primary",
3554
+ },
3259
3555
  },
3260
3556
  TESTER: {
3261
3557
  "save-note": {
@@ -32,12 +32,54 @@ export interface GroupCouponDiscountResult {
32
32
  appliedDiscounts: {
33
33
  code: string;
34
34
  couponId?: string;
35
+ /**
36
+ * 🛑 This is NOT `CouponType`, and the two are easy to confuse now that
37
+ * both live in this file. This one records WHERE the discount came from —
38
+ * a coupon the buyer typed, a deal, or an automatic rule — and it is what
39
+ * the order document stores in `appliedDiscounts[]`.
40
+ *
41
+ * `CartAppliedCoupon.type` is the coupon's own kind (`percentage`,
42
+ * `points_earn`, …) and is what the loop below skips on. Reading one where
43
+ * the other is meant would compile cleanly and be wrong: every value of
44
+ * this union is absent from that one, so the `points_earn` skip would
45
+ * never fire and a points coupon would discount the order.
46
+ */
35
47
  type: "coupon" | "deal" | "auto";
36
48
  discountAmount: number;
37
49
  scope?: "admin" | "seller";
38
50
  storeId?: string;
39
51
  }[];
40
52
  }
53
+ /**
54
+ * What the CART-level call returns: the same totals, plus the per-group
55
+ * breakdown.
56
+ *
57
+ * 🛑 A separate interface rather than one optional field on the result above.
58
+ * `computeGroupCouponDiscount` scores ONE group, so it has no per-group list
59
+ * to report and never will — giving it an empty `perGroup` would be a value
60
+ * that type-checks and means nothing, and the capture route's points tender
61
+ * reads this array positionally. A caller that gets `[]` where it expected one
62
+ * entry per group apportions every point against group zero.
63
+ */
64
+ export interface CartCouponDiscountResult extends GroupCouponDiscountResult {
65
+ /**
66
+ * The per-group discount, in the order the groups were passed.
67
+ *
68
+ * 🛑 Surfaced rather than aggregated-and-forgotten. It was already being
69
+ * computed inside the loop below and then summed away — the same shape as
70
+ * `CheckoutPricingPreviewStore`'s per-store fees, which existed only as an
71
+ * aggregate until a seller card needed them.
72
+ *
73
+ * The caller that needs it is the capture route's points tender: the
74
+ * per-group base includes that group's own discount, and re-deriving it
75
+ * there would be a second copy of the apportionment rule (Root Cause #75) on
76
+ * the one path D37 proves gets left behind.
77
+ */
78
+ perGroup: {
79
+ storeId: string | undefined;
80
+ couponDiscount: number;
81
+ }[];
82
+ }
41
83
  /**
42
84
  * Prorates every buyer-applied coupon against one seller-group's total.
43
85
  *
@@ -70,4 +112,4 @@ export declare function computeCartCouponDiscount(appliedCoupons: CartAppliedCou
70
112
  itemId: string;
71
113
  lineTotal: number;
72
114
  }[];
73
- }[]): GroupCouponDiscountResult;
115
+ }[]): CartCouponDiscountResult;
@@ -42,6 +42,20 @@ export function computeGroupCouponDiscount(appliedCoupons, groupLines, groupTota
42
42
  let couponDiscount = 0;
43
43
  const appliedDiscounts = [];
44
44
  for (const coupon of appliedCoupons) {
45
+ /*
46
+ * 🛑 D51 — a `points_earn` coupon DISCOUNTS NOTHING. It awards points on
47
+ * the post-discount amount paid, and it carries `pointsPercent` rather than
48
+ * a discount value.
49
+ *
50
+ * Skipped here rather than relied on to carry `discountAmount: 0`. The
51
+ * apply route writes whatever `validateCouponForCart` returned, and a
52
+ * points coupon that ever came back with a non-zero `discountAmount` —
53
+ * through a mis-seeded `discount.value`, or an admin editing a coupon's
54
+ * type after creation — would silently discount the order AND award points.
55
+ * A type check cannot be bypassed by bad data; a zero cannot be relied on.
56
+ */
57
+ if (coupon.type === "points_earn")
58
+ continue;
45
59
  let couponGroupDiscount = 0;
46
60
  const isSellerScoped = coupon.scope === "seller" && coupon.storeId;
47
61
  if (isSellerScoped) {
@@ -93,11 +107,22 @@ export function computeCartCouponDiscount(appliedCoupons, groups) {
93
107
  const cartSubtotal = groups.reduce((sum, g) => sum + g.lines.reduce((s, l) => s + l.lineTotal, 0), 0);
94
108
  let couponDiscount = 0;
95
109
  const appliedDiscounts = [];
110
+ const perGroup = [];
96
111
  for (const group of groups) {
97
112
  const groupTotal = group.lines.reduce((s, l) => s + l.lineTotal, 0);
98
113
  const res = computeGroupCouponDiscount(appliedCoupons, group.lines, groupTotal, cartSubtotal, group.storeId);
99
114
  couponDiscount += res.couponDiscount;
100
115
  appliedDiscounts.push(...res.appliedDiscounts);
116
+ /*
117
+ * 🛑 NOT rounded here, and the aggregate below IS. Rounding each group
118
+ * then summing can differ from summing then rounding by a paisa per group,
119
+ * and the aggregate is what the gateway captures — so the group figures
120
+ * stay raw and the caller rounds its own composed base once, exactly as
121
+ * `createOrderForGroup` does with a single `roundRupees` on `orderTotal`
122
+ * (D42). A rounded-then-summed discount is how a total ends up a paisa
123
+ * short of its own lines.
124
+ */
125
+ perGroup.push({ storeId: group.storeId, couponDiscount: res.couponDiscount });
101
126
  }
102
- return { couponDiscount: roundRupees(couponDiscount), appliedDiscounts };
127
+ return { couponDiscount: roundRupees(couponDiscount), appliedDiscounts, perGroup };
103
128
  }
@@ -377,12 +377,186 @@ export declare function orderShippingReimbursement(order: ReimbursableOrderLike)
377
377
  export declare function orderPointsFunded(order: {
378
378
  pointsAwarded?: number;
379
379
  }): number;
380
+ /**
381
+ * Points this order CONSUMED, which the accepting store also funds (D46/D47).
382
+ *
383
+ * Decision 3's other end. The earn above is borne by the originating store;
384
+ * the redemption is absorbed by the store that agreed to accept points
385
+ * (`StoreDocument.acceptsPoints`, defaulting to NOT accepted precisely so no
386
+ * seller is enrolled in funding discounts they never agreed to). The platform
387
+ * funds neither end.
388
+ *
389
+ * Reads `pointsApplied` off the order for the same reason the earn reads
390
+ * `pointsAwarded`: it must be what was actually spent. Recomputing the cap from
391
+ * today's total would deduct a figure the buyer never received the benefit of —
392
+ * and on a partially-cancelled order the total has moved.
393
+ */
394
+ export declare function orderPointsRedeemed(order: {
395
+ pointsApplied?: number;
396
+ }): number;
380
397
  /** Sum of `orderPointsFunded` across a batch. */
381
398
  export declare function ordersPointsFunded(orders: readonly {
382
399
  pointsAwarded?: number;
383
400
  }[]): number;
401
+ /**
402
+ * Everything the store funds through the points programme, for one batch:
403
+ * points ISSUED on these orders plus points SPENT on them.
404
+ *
405
+ * ## 🛑 One figure, because they are one obligation
406
+ *
407
+ * Both ends are seller-funded (decisions 3 and 17) and both are deducted from
408
+ * the same payout at the same moment, so splitting them across two parameters
409
+ * of `computePayoutDeduction` would be two chances for a call site to pass one
410
+ * and forget the other — and a payout that deducts the earn but not the
411
+ * redemption is short by exactly the amount nobody noticed.
412
+ *
413
+ * 🛑 This helper exists because `ordersPointsFunded` had **ZERO consumers**
414
+ * from the day it was written — the earn deduction was built, documented at
415
+ * length, and never passed to the function it was built for, so every payout
416
+ * since has quietly been funded by the platform. That is the dead-field
417
+ * pattern (Rule: every declared field has both a writer and a reader) occurring
418
+ * inside the work that catalogues it. Wiring the combined figure at all four
419
+ * call sites is what closes it.
420
+ */
421
+ export declare function ordersPointsBorneByStore(orders: readonly {
422
+ pointsAwarded?: number;
423
+ pointsApplied?: number;
424
+ }[]): number;
384
425
  /** Sum of `orderShippingReimbursement` across a batch. */
385
426
  export declare function ordersShippingReimbursement(orders: readonly ReimbursableOrderLike[]): number;
427
+ /**
428
+ * How many points may be spent on ONE order group, and what is left to charge.
429
+ *
430
+ * ## 🛑 A PIPELINE STAGE, after the final rounding — never a post-order debit
431
+ *
432
+ * This is the whole lesson of D46. The deleted code redeemed points AFTER the
433
+ * orders existed and the gateway had captured `orderTotal`, so a successful
434
+ * redemption took points from a buyer who had just paid full price: nothing in
435
+ * the pipeline knew about the spend, so nothing reduced the charge.
436
+ *
437
+ * So the tender is a STAGE. `amountDue = orderTotal − pointsApplied` is
438
+ * computed here, and `amountDue` is what the gateway captures and what the
439
+ * post-capture guard compares. A sixth way for the captured amount to diverge
440
+ * from the recorded total is the D37/D38/D40 family; this is how it is avoided.
441
+ *
442
+ * ## 🛑 Applied AFTER rounding, deliberately
443
+ *
444
+ * `orderTotal` is rounded ONCE at the end of its own nine-term sum (D42).
445
+ * Folding points in before that rounding would put a discount inside the sum
446
+ * being rounded, so the figure shown to the buyer and the figure captured could
447
+ * differ by a paisa. They must be provably equal, which is why `amountDue` is
448
+ * derived here and never recomputed at the gateway.
449
+ *
450
+ * ## Per order group, because the ACCEPTING STORE absorbs it
451
+ *
452
+ * Decision 3: a redeemed point reduces THAT store's payout for THAT order. A
453
+ * cart spanning an accepting and a non-accepting store must not pool the
454
+ * discount — each group gets its own cap and its own figure. That is the same
455
+ * granularity `splitCartIntoOrderGroups` and `allocateCheckoutFees` already
456
+ * use, and its absence is what caused Root Cause #65's per-store
457
+ * multiplication bug.
458
+ *
459
+ * ## All-or-nothing, and the remainder STAYS
460
+ *
461
+ * Owner's rule: *"if use point it is all and then the balance is returned if
462
+ * excess"*. There is no requested amount — the balance is spent down as far as
463
+ * the cap allows, and whatever will not fit is simply not spent. It stays in
464
+ * the ledger for a later order; nothing is forfeited, and no caller can ask for
465
+ * a partial spend.
466
+ *
467
+ * 🛑 The 50% cap is not optional, and removing it was explicitly declined.
468
+ * `POINTS_MAX_REDEMPTION_PERCENT` exists because a ₹0 order breaks the gateway
469
+ * (a ₹0 Razorpay order is not a thing) and because a balance that can settle a
470
+ * whole purchase behaves like the stored value the points schema is written to
471
+ * avoid.
472
+ */
473
+ export declare function resolvePointsTender(input: {
474
+ /** The group's FINAL rounded total. */
475
+ orderTotal: number;
476
+ /** The buyer's live balance, in points (1 point = ₹1). */
477
+ balance: number;
478
+ /** Whether this group's store accepts points. */
479
+ accepted: boolean;
480
+ /** Whether the buyer ticked the cart's `useAllPoints`. */
481
+ optedIn: boolean;
482
+ }): {
483
+ pointsApplied: number;
484
+ amountDue: number;
485
+ };
486
+ /**
487
+ * Draw one balance down across a checkout's order groups, in group order.
488
+ *
489
+ * ## Why this exists rather than each caller looping
490
+ *
491
+ * The tender is applied PER GROUP (decision 3 — the accepting store absorbs
492
+ * its own redemption), so "how many points does this checkout use" is a
493
+ * sequential draw-down, not a single `min`. Four surfaces need the same answer
494
+ * and must not each write the loop:
495
+ *
496
+ * | surface | why it needs the total |
497
+ * |---|---|
498
+ * | `previewCheckoutPricing` | the figure shown to the buyer |
499
+ * | `POST /api/payment/create-order` | the figure CAPTURED |
500
+ * | the post-capture guard | the figure compared |
501
+ * | the two order paths | the per-group figure recorded |
502
+ *
503
+ * D37 is the record of what happens when one of those four is left out: the
504
+ * coupon discount reached three of them and not the capture route, so the
505
+ * buyer was shown one number, charged another, and the order recorded the
506
+ * first — invisible in our own data because the guard was one-sided.
507
+ *
508
+ * 🛑 The order paths deliberately do NOT call this. They apply
509
+ * `resolvePointsTender` to their own group as they create it, drawing down a
510
+ * shared remainder — which is the same function applied in the same order, so
511
+ * the sum is identical by construction. Making them call this instead would
512
+ * mean computing every group's final total before creating any of them, which
513
+ * is a restructure of two 200-line functions for an answer they already have.
514
+ *
515
+ * ## The cap is per group, and the ORDER of the groups therefore matters
516
+ *
517
+ * A balance smaller than the whole checkout's 50% allowance is consumed by the
518
+ * earliest groups. That is arbitrary but it must be *consistently* arbitrary:
519
+ * every caller iterates `orderGroups` in the order `splitCartIntoOrderGroups`
520
+ * produced, so all four agree. Sorting differently anywhere would make the
521
+ * shown and charged figures diverge on exactly the carts where the balance is
522
+ * tight.
523
+ */
524
+ /** One order group's payable total, and whether its store takes points. */
525
+ export interface PointsBase {
526
+ total: number;
527
+ accepted: boolean;
528
+ }
529
+ /** Everything one group contributes to its own payable total. */
530
+ export interface PointsBaseParts {
531
+ /** Goods subtotal for the group, before any discount. */
532
+ goods: number;
533
+ couponDiscount: number;
534
+ shippingFee: number;
535
+ /** Gift wrap + shipment protection + any other per-store add-on. */
536
+ addonFee: number;
537
+ platformFee: number;
538
+ gstOnFee: number;
539
+ acceptsPoints: boolean;
540
+ }
541
+ /**
542
+ * The payable total a points allocation is measured against.
543
+ *
544
+ * 🛑 ONE implementation, because it was two. `POST /api/payment/create-order`
545
+ * and `verifyAndPlaceRazorpayOrderAction`'s amount guard each built this sum
546
+ * by hand, in the same shape, from the same six parts — and they are the
547
+ * *shown* figure and the *charged* figure for the same cart. Two hand-written
548
+ * copies of one money rule is Root Cause #75 exactly, and the failure mode is
549
+ * the worst kind: they only disagree on carts where the arithmetic differs, so
550
+ * nothing errors and the buyer is quoted one number and charged another.
551
+ *
552
+ * The coupon is floored at zero before the fees are added, never after — a
553
+ * discount larger than the goods must not eat the shipping and platform fee.
554
+ */
555
+ export declare function pointsBaseForGroup(parts: PointsBaseParts): PointsBase;
556
+ export declare function allocatePointsAcrossGroups(groups: readonly PointsBase[], balance: number, optedIn: boolean): {
557
+ perGroup: number[];
558
+ pointsApplied: number;
559
+ };
386
560
  /**
387
561
  * P-6 — pre-order groups charge each product's own `preOrderDepositPercent`
388
562
  * (falling back to the generic COD deposit % when a product doesn't have one