@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
@@ -7,6 +7,7 @@ import type { BaseDocument } from "../../../_internal/shared/types/base-document
7
7
  import type { ListingType } from "../../products/types";
8
8
  import type { StatusChangeEntry } from "../../../_internal/shared/history/index";
9
9
  import type { ReturnReason } from "../../../_internal/shared/features/orders/return-reasons";
10
+ import type { DisputeKind } from "../../../_internal/shared/features/orders/dispute-reasons";
10
11
  import type { ReturnCustodyState } from "../../../_internal/shared/features/returns/custody";
11
12
  import type { ActualShipmentCost, SelectedShippingQuote, ShippingReconciliation } from "../../../_internal/shared/shipping/quote";
12
13
  import type { Encrypted, Plaintext } from "../../../security/encrypted";
@@ -173,6 +174,68 @@ export declare const RefundStatusValues: {
173
174
  readonly REJECTED: "rejected";
174
175
  };
175
176
  /** Firestore storage shape for an order line item â€" distinct from the API display model OrderItem */
177
+ /**
178
+ * The PII inside one amendment.
179
+ *
180
+ * 🛑 BARE keys, and `ORDER_PII_FIELDS` uses the `deliveryAmendments[].…`
181
+ * form for the same five fields. Two notations, two scopes, both correct:
182
+ * the `[]` form is for the whole ORDER document, where the hook has to walk
183
+ * into the array; these bare names are for ONE amendment object, where they
184
+ * are genuinely top-level.
185
+ *
186
+ * 🛑 This list was first justified as "`encryptPiiFields` CANNOT cover an
187
+ * array" — CLAUDE.md's wording, and FALSE. `encryptInArray` has always
188
+ * handled `a[].b`, in both directions. The real rule is that the encryptor
189
+ * does not infer: a field is covered only where it is NAMED, in the notation
190
+ * matching the object the list is applied to.
191
+ */
192
+ export declare const AMENDMENT_PII_FIELDS: readonly ["fullName", "phone", "addressLine1", "addressLine2", "landmark"];
193
+ /**
194
+ * A correction to the delivery address after the order was placed.
195
+ *
196
+ * 🛑 Carries the FULL new address, not a diff. A diff would make the current
197
+ * address reconstructable only by replaying every entry in order, so one
198
+ * malformed entry in the middle makes everything after it unreadable — and
199
+ * the parcel label is produced from the current address.
200
+ *
201
+ * PII in here is the same problem as everywhere else: `encryptPiiFields` does
202
+ * not descend into arrays, so these values are NOT encrypted by that
203
+ * mechanism. `scrubAmendmentPii` is what handles them; see its header.
204
+ */
205
+ export interface DeliveryAmendment {
206
+ at: Date;
207
+ /** Who asked. `actorRole` distinguishes a buyer correction from a support fix. */
208
+ actorUid?: string;
209
+ actorRole: "buyer" | "seller" | "admin" | "system";
210
+ reason?: string;
211
+ fullName: string;
212
+ phone: string;
213
+ addressLine1: string;
214
+ addressLine2?: string;
215
+ landmark?: string;
216
+ city: string;
217
+ state: string;
218
+ pincode: string;
219
+ country: string;
220
+ }
221
+ /**
222
+ * How much seller prose a single order line carries.
223
+ *
224
+ * 🛑 A Firestore document caps at 1 MiB and `items[]` is inline on the order.
225
+ * 2,000 characters × 20 lines is ~40 KB of description — comfortable. The
226
+ * same field unbounded is a rejected write at checkout, and the checkout is
227
+ * the one operation in the system that must never fail for a reason the buyer
228
+ * cannot act on.
229
+ */
230
+ export declare const ORDER_ITEM_DESCRIPTION_MAX = 2000;
231
+ /**
232
+ * How many spec rows one order line keeps.
233
+ *
234
+ * Capped by COUNT rather than characters: a spec table is rows, and half a
235
+ * row is worse than a missing one — "Weight: 4" with the unit cut off reads
236
+ * as a fact rather than as truncation.
237
+ */
238
+ export declare const ORDER_ITEM_SPECIFICATIONS_MAX = 30;
176
239
  export interface OrderDocumentItem {
177
240
  productId: string;
178
241
  productTitle: string;
@@ -260,6 +323,37 @@ export interface OrderDocumentItem {
260
323
  /** Which kind of multi-member line produced these rows. */
261
324
  groupSource?: "bundle" | "product-group" | "grouped-listing";
262
325
  /** P-8 GST — snapshotted from the product at order time so the invoice stays accurate even if the product's HSN/rate later changes. */
326
+ /**
327
+ * The listing description as it read at purchase.
328
+ *
329
+ * 🛑 BOUNDED at `ORDER_ITEM_DESCRIPTION_MAX`, with `descriptionTruncated`
330
+ * recording that it was cut. A Firestore document caps at 1 MiB and this is
331
+ * free-form seller prose on every line of every order — an unbounded copy
332
+ * on a 20-line order is a rejected write AT CHECKOUT, which fails the one
333
+ * operation that must not fail. Truncation is recorded rather than silent
334
+ * for the same reason `statusHistoryTruncated` exists: a short description
335
+ * and a cut one must not read alike.
336
+ */
337
+ description?: string;
338
+ descriptionTruncated?: boolean;
339
+ /** The spec table as it read at purchase. */
340
+ specifications?: Array<{
341
+ name: string;
342
+ value: string;
343
+ unit?: string;
344
+ }>;
345
+ /**
346
+ * For a composed listing, the parts it was sold as containing.
347
+ *
348
+ * Ids and names only — the part CATALOGUE is a live reference work and
349
+ * copying its entries onto every order line would duplicate a research
350
+ * corpus per purchase. What matters for a dispute is which parts were
351
+ * claimed, not their current catalogue entry.
352
+ */
353
+ parts?: Array<{
354
+ code: string;
355
+ name: string;
356
+ }>;
263
357
  hsnCode?: string;
264
358
  gstRate?: 0 | 5 | 12 | 18 | 28;
265
359
  /**
@@ -352,6 +446,25 @@ export interface OrderRefundEvent {
352
446
  proofDocumentMimeType?: string;
353
447
  /** Required for Razorpay-override path ("failed auto-refund, settled manually"). */
354
448
  overrideReason?: string;
449
+ /**
450
+ * The credit note that documents this refund, e.g. `LIRCN/26-27/0001`
451
+ * (Phase 7, D12).
452
+ *
453
+ * 🛑 Per REFUND EVENT, not per order — an order can legitimately be refunded
454
+ * several times, and each reversal of tax needs its own numbered document
455
+ * referencing the original invoice. That is why the allocation claim for a
456
+ * credit note is keyed `${orderId}_${refundId}` while an invoice's is keyed
457
+ * on the order alone: keying a credit note on the order would refuse the
458
+ * second one.
459
+ *
460
+ * Only ever set on a refund that actually SETTLED. A `reserved` entry that
461
+ * failed is not a reversal of anything, and numbering it would leave a
462
+ * credit note in the series for money that never moved.
463
+ */
464
+ creditNoteNumber?: string;
465
+ creditNoteIssuedAt?: Date;
466
+ /** Private storage path — same no-public-URL rule as `invoiceStoragePath`. */
467
+ creditNoteStoragePath?: string;
355
468
  }
356
469
  /** One applied discount/coupon saved on the order for accounting and display */
357
470
  export interface AppliedOrderDiscount {
@@ -405,7 +518,64 @@ export interface OrderDocument extends BaseDocument {
405
518
  paymentStatus: PaymentStatus;
406
519
  paymentId?: string;
407
520
  paymentMethod?: string;
521
+ /**
522
+ * 🛑 LEGACY. Never written for an order created after Part 14.
523
+ *
524
+ * Flat free text with no pincode, no phone and no address id — which is why
525
+ * `placeOfSupply` had to be written separately rather than derived, and why
526
+ * parcel booking could not be built at all (`CreateShipmentInput` needs a
527
+ * structured `{name, phone, addressLine1, city, state, pincode, country}`).
528
+ *
529
+ * It is ALSO in `ORDER_UPDATABLE_FIELDS`, so it is editable after the order
530
+ * — meaning it never recorded what the buyer actually chose. And it was
531
+ * never encrypted: `ORDER_PII_FIELDS` is `userName` / `userEmail` /
532
+ * `sellerEmail`, so every delivery address on every order up to now sits in
533
+ * Firestore in plaintext, despite the docs saying otherwise.
534
+ *
535
+ * Read it only as a fallback for orders that predate `deliveryAddress*`,
536
+ * and render it labelled as legacy. Forward-only; no backfill — parsing a
537
+ * state out of free text to file a tax return is the thing the
538
+ * `placeOfSupply` comment below already refuses.
539
+ */
408
540
  shippingAddress?: string;
541
+ /** PII — encrypted. See `ORDER_PII_FIELDS`. */
542
+ deliveryFullName?: Encrypted<string>;
543
+ /** PII — encrypted. */
544
+ deliveryPhone?: Encrypted<string>;
545
+ /** PII — encrypted. */
546
+ deliveryAddressLine1?: Encrypted<string>;
547
+ /** PII — encrypted. Optional second line / apartment. */
548
+ deliveryAddressLine2?: Encrypted<string>;
549
+ /** PII — encrypted. */
550
+ deliveryLandmark?: Encrypted<string>;
551
+ deliveryCity?: string;
552
+ deliveryState?: string;
553
+ deliveryPincode?: string;
554
+ deliveryCountry?: string;
555
+ /**
556
+ * The `addresses` row this was taken from, for provenance only.
557
+ *
558
+ * 🛑 Never resolved at read time. The row can be edited or deleted after the
559
+ * order, and following it would make the invoice disagree with what the
560
+ * buyer chose — which is the entire failure a snapshot exists to prevent.
561
+ */
562
+ deliveryAddressId?: string;
563
+ /**
564
+ * Corrections after the fact, newest LAST. Append-only.
565
+ *
566
+ * 🛑 Its OWN array, not a passenger on `statusHistory`.
567
+ *
568
+ * `statusHistory` caps at 50 with FIFO eviction. Address edits riding that
569
+ * log would compete with status transitions for the same slots and evict
570
+ * the thing the timeline exists to show — and on a chatty order the
571
+ * creation entry goes first, which is precisely the value reconstruction
572
+ * depends on. The creation snapshot is a FIELD above for the same reason: a
573
+ * field cannot be truncated.
574
+ *
575
+ * Dispatch reads the latest amendment (or the snapshot when there is none).
576
+ * The invoice always reads the snapshot.
577
+ */
578
+ deliveryAmendments?: DeliveryAmendment[];
409
579
  trackingNumber?: string;
410
580
  notes?: string;
411
581
  orderDate: Date;
@@ -426,6 +596,21 @@ export interface OrderDocument extends BaseDocument {
426
596
  */
427
597
  acceptedAt?: Date;
428
598
  shippingDate?: Date;
599
+ /**
600
+ * The COURIER's estimated delivery date, captured at dispatch.
601
+ *
602
+ * 🛑 Not to be confused with `OrderSourcePreOrder.expectedDeliveryDate`,
603
+ * which is when a pre-ordered product RELEASES — a different concept that
604
+ * this field was mistaken for while planning the dispute gates.
605
+ *
606
+ * Optional, and will stay mostly empty for now: nothing platform-books yet
607
+ * (`createShipment` has zero callers), and a self-shipping seller types a
608
+ * tracking number with no estimate attached. `resolveDisputeEtd` therefore
609
+ * falls back to `shippingDate + DISPUTE_TRANSIT_WINDOW_DAYS` — without that
610
+ * fallback the `not_reached` dispute gate would be unreachable for every
611
+ * parcel currently shipped.
612
+ */
613
+ estimatedDeliveryDate?: Date;
429
614
  deliveryDate?: Date;
430
615
  /**
431
616
  * When the order was marked COMPLETE — the fact that awards points and
@@ -481,6 +666,37 @@ export interface OrderDocument extends BaseDocument {
481
666
  * figure the order may since have changed.
482
667
  */
483
668
  pointsAwarded?: number;
669
+ /**
670
+ * Points SPENT on this order as part-payment, in points (1 point = ₹1).
671
+ *
672
+ * 🛑 Distinct from `pointsAwarded` directly above, which is what the buyer
673
+ * EARNED. Both can be non-zero on one order — a buyer can pay partly with
674
+ * points and still earn on the goods value — and conflating them would make
675
+ * the ledger unexplainable in exactly the place it matters most.
676
+ *
677
+ * Written at order creation from `resolvePointsTender`, never from a request
678
+ * body. The ledger's `redemption` entry is keyed on this order, so this field
679
+ * and that entry must agree; the order carries it so a payout deduction and a
680
+ * refund can both answer "how much of this was points" without re-deriving a
681
+ * percentage of a total that may since have changed.
682
+ */
683
+ pointsApplied?: number;
684
+ /**
685
+ * What the buyer actually pays: `totalPrice − pointsApplied`.
686
+ *
687
+ * ## 🛑 THE FIGURE THE GATEWAY CAPTURES, and the one the guard compares
688
+ *
689
+ * `totalPrice` stays the full value of the order — that is what the invoice
690
+ * declares and what GST is computed against, because points are a DISCOUNT
691
+ * and not a reduction in the value of the supply (decision 5). `amountDue` is
692
+ * the cash leg.
693
+ *
694
+ * Absent means "nothing was tendered", so every order written before this
695
+ * existed reads correctly as `amountDue === totalPrice`. 🛑 Readers must use
696
+ * `amountDue ?? totalPrice` rather than defaulting to 0 — treating absence as
697
+ * zero would say every historical order was fully paid in points.
698
+ */
699
+ amountDue?: number;
484
700
  cancellationDate?: Date;
485
701
  cancellationReason?: string;
486
702
  /**
@@ -668,6 +884,25 @@ export interface OrderDocument extends BaseDocument {
668
884
  igst: number;
669
885
  gstAmount: number;
670
886
  }>;
887
+ /**
888
+ * The buyer's state — the PLACE OF SUPPLY (Phase 7).
889
+ *
890
+ * 🛑 This is the input the CGST/SGST-vs-IGST decision was made FROM, and it
891
+ * was not recorded anywhere. `isIntraStateSupply(buyerState, storeState)`
892
+ * runs at checkout and only its *result* survived, in the shape of which tax
893
+ * fields got populated — so an order could not state why it split the way it
894
+ * did, and GSTR-1 has a mandatory place-of-supply column that nothing could
895
+ * fill.
896
+ *
897
+ * `shippingAddress` is a flat STRING on this document and contains the state
898
+ * somewhere inside it; parsing a state back out of free text to file a tax
899
+ * return is not a thing to do. The value is in scope at order creation, so
900
+ * it is written there.
901
+ *
902
+ * Absent on orders placed before this, which the export reports rather than
903
+ * silently blanks.
904
+ */
905
+ placeOfSupply?: string;
671
906
  /**
672
907
  * OUR GST registration as it stood at the moment of supply — LetItRip is the
673
908
  * seller of record and invoices under its own GSTIN.
@@ -689,6 +924,58 @@ export interface OrderDocument extends BaseDocument {
689
924
  supplierGstin?: string;
690
925
  supplierLegalName?: string;
691
926
  supplierAddress?: string;
927
+ /**
928
+ * The invoice number from the gapless FY series, e.g. `LIR/26-27/0001`.
929
+ *
930
+ * 🛑 Allocated on `paymentStatus → paid`, never at order creation — a number
931
+ * burned on an abandoned COD order is a gap nobody can explain. Written once
932
+ * and never rewritten: a GST invoice is issued once, and an adjustment is a
933
+ * CREDIT NOTE, not a re-issue.
934
+ *
935
+ * Absence means "not yet invoiced", which is the correct state for a pending
936
+ * order and for every order placed before this phase.
937
+ */
938
+ invoiceNumber?: string;
939
+ /** When the number was allocated — the invoice's own date. */
940
+ invoiceIssuedAt?: Date;
941
+ /**
942
+ * Where the rendered PDF lives.
943
+ *
944
+ * 🛑 **`private/invoices/{orderId}/{uuid}.pdf`, with NO `mediaAssets` row and
945
+ * a RANDOM object name.** An invoice carries the buyer's full name, address
946
+ * and phone. `/api/media/[...slug]` applies **no authentication** over a
947
+ * bucket whose storage rule is `allow read: if true`, and the slug resolves
948
+ * through `mediaAssets` — so no row means no public URL exists at all.
949
+ *
950
+ * The random name is deliberately AGAINST the content-derived SEO-slug
951
+ * convention used everywhere else in this codebase, because guessable is the
952
+ * one property this must not have. `generateInvoiceFilename` is
953
+ * content-derived and is therefore the wrong tool here. Same reasoning as the
954
+ * digital-content decision (D103).
955
+ */
956
+ invoiceStoragePath?: string;
957
+ /**
958
+ * The arrangement's fees, SNAPSHOTTED at checkout.
959
+ *
960
+ * 🛑 Snapshotted, not re-read. A coordinator commits against a quoted total;
961
+ * if the rates were read again at settle a seller could raise them
962
+ * afterwards and the coordinator would absorb it. The precedent is exact —
963
+ * the refund path reads `finalSale` from this document rather than the live
964
+ * product, "because re-reading the live product would let a seller flip the
965
+ * switch afterwards" — and D61 generalises it to every agreement with a gap
966
+ * between terms-agreed and money-taken.
967
+ *
968
+ * Absent on every ordinary single-destination order, which is almost all of
969
+ * them.
970
+ */
971
+ sharedPurchase?: {
972
+ /** Distinct destinations, including the first. Always ≥ 2 when present. */
973
+ destinationCount: number;
974
+ /** Flat per-arrangement fee, as charged. */
975
+ handlingFee: number;
976
+ /** Extra shipping for destinations beyond the first, as charged. */
977
+ extraShippingFee: number;
978
+ };
692
979
  emiEnabled?: boolean;
693
980
  /** Number of monthly installments the buyer chose (2–6). */
694
981
  emiTenureMonths?: number;
@@ -776,6 +1063,38 @@ export interface OrderDocument extends BaseDocument {
776
1063
  * requires evidence and approval before anything is paid.
777
1064
  */
778
1065
  platformBookedShipment?: boolean;
1066
+ /**
1067
+ * We tried to book a courier for this order and could not.
1068
+ *
1069
+ * ## 🛑 ITS WHOLE PURPOSE IS TO STOP AN AUTO-CANCELLATION
1070
+ *
1071
+ * `seller-dispatch` is an `onDue: "act"` obligation on a 2-business-day
1072
+ * clock. Without this field, an order sitting on OUR empty courier wallet is
1073
+ * auto-cancelled and the buyer refunded — with the seller recorded as having
1074
+ * failed to dispatch. The buyer paid, the seller did nothing wrong, and the
1075
+ * platform's own funding state caused the cancellation.
1076
+ *
1077
+ * So every `onDue: "act"` policy anchored at or after dispatch gates its
1078
+ * `precondition` on `!hasOpenCourierBlock(order)`. The obligation engine
1079
+ * re-evaluates `precondition` at fire time and closes `superseded` when it
1080
+ * returns false, so the clock pauses and resumes with no new mechanism.
1081
+ *
1082
+ * Absent means no block — which is every order ever written, so this needs
1083
+ * no migration and changes nothing until something sets it.
1084
+ *
1085
+ * `reason` is the operator's word, not the seller's: the seller is told only
1086
+ * that we could not book a courier right now, because our balance is our
1087
+ * problem and not theirs.
1088
+ */
1089
+ courierBlock?: {
1090
+ reason: "insufficient_funds" | "provider_error" | "unserviceable";
1091
+ at: Date;
1092
+ lastAttemptAt?: Date;
1093
+ /** Attempts so far, so the digest can distinguish stuck from transient. */
1094
+ attempts: number;
1095
+ /** Upstream detail, for the admin surface only. Never shown to a seller. */
1096
+ detail?: string;
1097
+ };
779
1098
  /**
780
1099
  * The self-shipped reimbursement workflow: evidence in, approved amount out.
781
1100
  *
@@ -961,6 +1280,58 @@ export interface OrderDocument extends BaseDocument {
961
1280
  /** Buyer's required "this payment is genuine, no fraudulent tricks/chargebacks" agreement — server-validated, not just a client-side disable. */
962
1281
  buyerFraudAgreementAccepted?: boolean;
963
1282
  buyerFraudAgreementAcceptedAt?: Date;
1283
+ /**
1284
+ * ── D55: the pre-order BALANCE, which is a second payment ──────────────
1285
+ *
1286
+ * 🛑 Its own block rather than reusing the fields above, and that is the
1287
+ * decision this whole feature turns on. Every field above describes ONE
1288
+ * payment; a pre-order has two, months apart. Reusing `paymentProofUrl`
1289
+ * for the balance overwrites the deposit's proof — the evidence for the
1290
+ * payment that created the order — and `paymentReviewOutcome` then means
1291
+ * two different things depending on when you read it.
1292
+ *
1293
+ * Worse, `paymentWindowTimeout` sweeps orders that are `pending`/`pending`
1294
+ * with no `paymentProofUrl`, so clearing that field to collect a balance
1295
+ * would make the sweep cancel and restock a PAID order.
1296
+ *
1297
+ * The balance is therefore its own small state machine beside the
1298
+ * deposit's, sharing the review vocabulary but none of the storage.
1299
+ */
1300
+ balance?: {
1301
+ /**
1302
+ * 🛑 SNAPSHOTTED, not recomputed — D61, and the worst case in the
1303
+ * codebase for it: a deposit-to-balance gap is months. It is copied from
1304
+ * `sourceContext.balanceDue` at the moment the collection is opened, so
1305
+ * a price change, a tax-rate change or a re-quote in between cannot move
1306
+ * what the buyer was told they owe. Recomputing at payment time is how a
1307
+ * buyer who agreed to ₹4,000 is charged ₹4,400.
1308
+ */
1309
+ amount: number;
1310
+ /**
1311
+ * `manual` only, today, and the field exists so the absence is explicit.
1312
+ *
1313
+ * 🛑 The AUTO path is not merely unbuilt — it is blocked on things
1314
+ * outside this repo. A months-long gap cannot use authorise-then-capture
1315
+ * (capture windows are days), so it needs a real RBI-compliant mandate:
1316
+ * AFA at creation, a pre-debit notice at least 24 HOURS before every
1317
+ * debit, and a max amount fixed at registration. Razorpay must also have
1318
+ * recurring enabled, and production runs TEST keys with
1319
+ * `razorpayEnabled` defaulting false. Declaring the union now means
1320
+ * adding `auto` later is a compile-checked change rather than a new
1321
+ * field nobody wires.
1322
+ */
1323
+ method: "manual";
1324
+ status: "awaiting" | "submitted" | "paid" | "rejected";
1325
+ /** Set when the collection is opened, so the buyer has a stated window. */
1326
+ dueBy?: Date;
1327
+ proofUrl?: string;
1328
+ transactionId?: string;
1329
+ submittedAt?: Date;
1330
+ reviewedBy?: string;
1331
+ reviewedAt?: Date;
1332
+ /** Required on `rejected`, for the same reason a refund reason is. */
1333
+ reviewNote?: string;
1334
+ };
964
1335
  /** Which of the three admin review actions was taken on this order's payment proof. */
965
1336
  paymentReviewOutcome?: "approved" | "reupload_requested" | "rejected_fraud";
966
1337
  /** Admin's reason text — required for both `reupload_requested` and `rejected_fraud`. */
@@ -970,11 +1341,37 @@ export interface OrderDocument extends BaseDocument {
970
1341
  /** True when `paymentReviewAutoApprove` approved this order after 2 hours of no manual admin review. */
971
1342
  autoApproved?: boolean;
972
1343
  autoApprovedAt?: Date;
973
- /** Buyer/seller/admin dispute raised against an auto-approved order — surfaces to the admin queue, does not itself reverse payment/order status. */
1344
+ /**
1345
+ * A buyer/seller/admin dispute. Surfaces to the admin queue; does not itself
1346
+ * reverse payment or order status.
1347
+ *
1348
+ * 🛑 This used to say "against an auto-approved order", and that was the
1349
+ * whole scope: `raiseOrderDisputeAction` refused anything else, telling the
1350
+ * caller to use the return/refund flow. Disputes are now GENERAL — any
1351
+ * delivered-or-late order can be disputed, gated by `disputeKind`.
1352
+ */
974
1353
  disputeRaised?: boolean;
975
1354
  disputeRaisedBy?: string;
976
1355
  disputeRaisedAt?: Date;
1356
+ /**
1357
+ * The reason's LABEL, snapshotted at the moment the dispute was raised.
1358
+ *
1359
+ * 🛑 A snapshot, not a lookup, and that is the point: `disputeReasons` rows
1360
+ * can be retired or reworded by staff, and neither may rewrite what a buyer
1361
+ * said months ago. `disputeReasonId` below is the join key for analytics;
1362
+ * THIS is the record.
1363
+ *
1364
+ * Still a plain `string` and still the field every existing surface renders,
1365
+ * so pre-2026-10-22 disputes (free text typed by the buyer) keep displaying
1366
+ * unchanged rather than being orphaned beside a new field.
1367
+ */
977
1368
  disputeReason?: string;
1369
+ /** Which gate this dispute passed. Absent on pre-2026-10-22 disputes. */
1370
+ disputeKind?: DisputeKind;
1371
+ /** `disputeReasons/{id}`. The join key for "what are buyers reporting". */
1372
+ disputeReasonId?: string;
1373
+ /** The buyer's own words. Free text, never parsed, never gated on. */
1374
+ disputeDetail?: string;
978
1375
  disputeStatus?: "open" | "resolved";
979
1376
  /**
980
1377
  * Same-shape payment record regardless of how the buyer paid — manual
@@ -48,6 +48,49 @@ export const RefundStatusValues = {
48
48
  COMPLETED: "completed",
49
49
  REJECTED: "rejected",
50
50
  };
51
+ /** Firestore storage shape for an order line item â€" distinct from the API display model OrderItem */
52
+ /**
53
+ * The PII inside one amendment.
54
+ *
55
+ * 🛑 BARE keys, and `ORDER_PII_FIELDS` uses the `deliveryAmendments[].…`
56
+ * form for the same five fields. Two notations, two scopes, both correct:
57
+ * the `[]` form is for the whole ORDER document, where the hook has to walk
58
+ * into the array; these bare names are for ONE amendment object, where they
59
+ * are genuinely top-level.
60
+ *
61
+ * 🛑 This list was first justified as "`encryptPiiFields` CANNOT cover an
62
+ * array" — CLAUDE.md's wording, and FALSE. `encryptInArray` has always
63
+ * handled `a[].b`, in both directions. The real rule is that the encryptor
64
+ * does not infer: a field is covered only where it is NAMED, in the notation
65
+ * matching the object the list is applied to.
66
+ */
67
+ export const AMENDMENT_PII_FIELDS = [
68
+ "fullName",
69
+ "phone",
70
+ "addressLine1",
71
+ "addressLine2",
72
+ /* Encrypted on the snapshot as `deliveryLandmark`; the two must agree or the
73
+ * same datum is protected before a correction and exposed after it. */
74
+ "landmark",
75
+ ];
76
+ /**
77
+ * How much seller prose a single order line carries.
78
+ *
79
+ * 🛑 A Firestore document caps at 1 MiB and `items[]` is inline on the order.
80
+ * 2,000 characters × 20 lines is ~40 KB of description — comfortable. The
81
+ * same field unbounded is a rejected write at checkout, and the checkout is
82
+ * the one operation in the system that must never fail for a reason the buyer
83
+ * cannot act on.
84
+ */
85
+ export const ORDER_ITEM_DESCRIPTION_MAX = 2000;
86
+ /**
87
+ * How many spec rows one order line keeps.
88
+ *
89
+ * Capped by COUNT rather than characters: a spec table is rows, and half a
90
+ * row is worse than a missing one — "Weight: 4" with the unit cut off reads
91
+ * as a fact rather than as truncation.
92
+ */
93
+ export const ORDER_ITEM_SPECIFICATIONS_MAX = 30;
51
94
  export const ORDER_COLLECTION = "orders";
52
95
  /**
53
96
  * At-most-once gate for refunds. Document id = `sha256(idempotencyKey)`,