@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
@@ -5,6 +5,7 @@ import { BaseRepository, parseSieveDateValue } from "../../../providers/db-fireb
5
5
  import { type OrderCreateInput, type OrderDocument, type OrderPlain, type OrderRefundEvent } from "../schemas";
6
6
  import { type HistoryActor, type FieldChange } from "../../../_internal/shared/history/index";
7
7
  import type { OrderStatus, PaymentStatus } from "../types";
8
+ import type { OrderType } from "../utils/order-splitter";
8
9
  import { type PaymentReviewQueueMode } from "../constants/payment-window";
9
10
  /**
10
11
  * Who/why for a write that lands in `statusHistory`.
@@ -64,7 +65,7 @@ declare class OrderRepository extends BaseRepository<OrderDocument> {
64
65
  * encryption lived in a private method only three call sites remembered to
65
66
  * call.
66
67
  */
67
- protected piiFields: readonly ["userName", "userEmail", "sellerEmail"];
68
+ protected piiFields: readonly ["userName", "userEmail", "sellerEmail", "deliveryFullName", "deliveryPhone", "deliveryAddressLine1", "deliveryAddressLine2", "deliveryLandmark", "deliveryAmendments[].fullName", "deliveryAmendments[].phone", "deliveryAmendments[].addressLine1", "deliveryAmendments[].addressLine2", "deliveryAmendments[].landmark"];
68
69
  /** Plaintext PII. **Opt-in and named** โ€” shows up in review and in a grep. */
69
70
  revealOrder(doc: OrderDocument): OrderPlain;
70
71
  /** As `revealOrder`, for a list read. */
@@ -144,6 +145,20 @@ declare class OrderRepository extends BaseRepository<OrderDocument> {
144
145
  * `order.bundleId` at creation time (SB3 / SB6-C).
145
146
  */
146
147
  countByUserAndBundle(userId: string, bundleId: string): Promise<number>;
148
+ /**
149
+ * How many orders this buyer has placed, optionally scoped to one lane.
150
+ *
151
+ * A Firestore aggregation โ€” billed at one read per 1000 index entries
152
+ * matched, not one per order โ€” so it stays flat as an account's history
153
+ * grows. That matters because the only caller is the session profile
154
+ * endpoint, which every page load hits.
155
+ *
156
+ * ๐Ÿ›‘ `orderType` may only name a NON-standard lane. The field was added
157
+ * after orders already existed, so an equality on `"standard"` would return
158
+ * zero for every legacy order while looking perfectly correct โ€” see the
159
+ * constant's own note.
160
+ */
161
+ countForUser(userId: string, orderType?: Exclude<OrderType, "standard">): Promise<number>;
147
162
  deleteByUser(userId: string): Promise<number>;
148
163
  static readonly SELLER_SIEVE_FIELDS: {
149
164
  id: {
@@ -196,6 +211,10 @@ declare class OrderRepository extends BaseRepository<OrderDocument> {
196
211
  canFilter: boolean;
197
212
  canSort: boolean;
198
213
  };
214
+ orderType: {
215
+ canFilter: boolean;
216
+ canSort: boolean;
217
+ };
199
218
  giftWrapAddon: {
200
219
  canFilter: boolean;
201
220
  canSort: boolean;
@@ -404,6 +423,32 @@ declare class OrderRepository extends BaseRepository<OrderDocument> {
404
423
  status: "failed";
405
424
  failureReason?: string;
406
425
  }, becomeRefunded?: boolean, ctx?: OrderWriteContext): Promise<OrderDocument>;
426
+ /**
427
+ * Stamp a credit-note number onto one settled refund event (Phase 7, 7c).
428
+ *
429
+ * ## ๐Ÿ›‘ Why this is a repository method and not an inline update
430
+ *
431
+ * `refunds[]` is written by re-mapping the whole array, exactly as
432
+ * `settleRefund` directly above does โ€” because a read-modify-write of
433
+ * `[...existing, event]` LOSES a concurrent event (D6), and that defect is
434
+ * just as reachable from a credit-note stamp as from a refund append.
435
+ * Letting the invoicing feature touch the array directly would reintroduce
436
+ * it one caller away from the fix.
437
+ *
438
+ * It goes through `updateWithHistory` for the same reason every other
439
+ * mutator here does: the transition guard and the status-history entry live
440
+ * there, and this is a real recorded event on the order.
441
+ *
442
+ * ๐Ÿ›‘ A missing refund event is a NO-OP, not a throw. The caller is the
443
+ * refund settle path, where money has already moved; raising here would turn
444
+ * a successful refund into a reported failure. See
445
+ * `issueCreditNoteForRefund`'s own ๐Ÿ›‘.
446
+ */
447
+ setRefundCreditNote(orderId: string, refundId: string, note: {
448
+ creditNoteNumber: string;
449
+ creditNoteIssuedAt: Date;
450
+ creditNoteStoragePath?: string;
451
+ }, ctx?: OrderWriteContext): Promise<OrderDocument | null>;
407
452
  /**
408
453
  * ๐Ÿ›‘ LEGACY โ€” prefer `reserveRefund` + `settleRefund`.
409
454
  *
@@ -442,6 +487,33 @@ declare class OrderRepository extends BaseRepository<OrderDocument> {
442
487
  * `paymentProofUrl != null` filter would silently exclude every doc where
443
488
  * the field isn't set at all โ€” the opposite of what's needed here.
444
489
  */
490
+ /**
491
+ * Orders invoiced within a window โ€” the GSTR-1 export's only query
492
+ * (Phase 7d).
493
+ *
494
+ * ## ๐Ÿ›‘ Windowed on `invoiceIssuedAt`, not on the order date
495
+ *
496
+ * A COD order placed on 30 March and paid on 2 April is invoiced in the NEW
497
+ * financial year, and that is the period its tax belongs to. Numbering
498
+ * happens at the payment transition for exactly this reason, so the invoice
499
+ * date is the only correct axis โ€” windowing on `orderDate` would file that
500
+ * order's tax in the year before it was invoiced.
501
+ *
502
+ * ## ๐Ÿ›‘ It also returns PAID orders with no invoice number, deliberately
503
+ *
504
+ * Those are the ones the export must warn about rather than omit โ€” a paid
505
+ * order silently absent from a tax return is the single error this whole
506
+ * feature exists to prevent. Firestore cannot OR across two fields, so the
507
+ * second query is a separate one and the caller merges; the alternative
508
+ * (one query on `paymentStatus`, filtered in memory) would scan every paid
509
+ * order ever placed.
510
+ *
511
+ * Unbounded `.limit(2000)`: a quarter's orders at this volume is a few
512
+ * hundred, and an export that silently truncated would understate a tax
513
+ * return. If this ever saturates, the fix is pagination with an explicit
514
+ * "more rows exist" signal in the CSV โ€” never a higher cap.
515
+ */
516
+ listInvoicedBetween(from: Date, to: Date): Promise<OrderDocument[]>;
445
517
  getExpiredPaymentDeadlines(): Promise<Array<{
446
518
  id: string;
447
519
  ref: DocumentReference;
@@ -507,6 +579,18 @@ declare class OrderRepository extends BaseRepository<OrderDocument> {
507
579
  */
508
580
  getEligibleAutomatic(cutoff: Date, opts?: {
509
581
  onWarn?: (msg: string, meta?: Record<string, JsonValue>) => void;
582
+ /**
583
+ * Stores paid at SHIPPING rather than at delivery.
584
+ *
585
+ * ๐Ÿ›‘ A faster path through the SAME query, not a second one. A `shipped`
586
+ * row is admitted only for a store in this set, and then skips the hold
587
+ * anchor โ€” being paid before delivery is the entire grant, so applying a
588
+ * post-delivery hold to it would make the flag do nothing.
589
+ *
590
+ * Omitted or empty means nobody is trusted, which is the correct default
591
+ * and reproduces the pre-existing behaviour exactly.
592
+ */
593
+ trustedStoreIds?: ReadonlySet<string>;
510
594
  }): Promise<Array<{
511
595
  id: string;
512
596
  ref: DocumentReference;
@@ -9,7 +9,7 @@ import { normalizeError } from "../../../errors/normalize.js";
9
9
  * that mix-up swallowing ~100 call sites' validation messages.
10
10
  */
11
11
  import { DatabaseError, NotFoundError, ValidationError } from "../../../errors/index.js";
12
- import { BaseRepository, prepareForFirestore, parseSieveDateValue, } from "../../../providers/db-firebase/index.js";
12
+ import { BaseRepository, prepareForFirestore, parseSieveDateValue, getFirestoreCount, } from "../../../providers/db-firebase/index.js";
13
13
  import { maskPii, revealPii, ORDER_PII_FIELDS, } from "../../../security/index.js";
14
14
  import { serverTimestamp, arrayUnion } from "../../../contracts/field-ops.js";
15
15
  import { createOrderId, ORDER_COLLECTION, ORDER_TRACKED_FIELDS, OrderStatusValues, } from "../schemas/index.js";
@@ -304,10 +304,11 @@ class OrderRepository extends BaseRepository {
304
304
  reason: ctx?.reason,
305
305
  note: ctx?.note,
306
306
  extraChanges: ctx?.extraChanges,
307
- // `encryptPiiFields` is a flat top-level loop and never descends into
308
- // arrays, so anything PII-named reaching `changes` would persist in
309
- // PLAINTEXT inside statusHistory. None of ORDER_TRACKED_FIELDS is PII
310
- // today โ€” this is defence for the next field somebody adds.
307
+ // `encryptPiiFields` covers a field only where it is NAMED, so a
308
+ // PII-named value reaching `changes` is plaintext unless somebody
309
+ // declared `statusHistory[].changes.<that key>` โ€” which nobody will.
310
+ // The scrub removes the guesswork. None of ORDER_TRACKED_FIELDS is PII
311
+ // today; this is defence for the next field somebody adds.
311
312
  piiFields: ORDER_PII_FIELDS,
312
313
  historyField: "statusHistory",
313
314
  truncatedField: "statusHistoryTruncated",
@@ -516,6 +517,26 @@ class OrderRepository extends BaseRepository {
516
517
  .get();
517
518
  return snapshot.size;
518
519
  }
520
+ /**
521
+ * How many orders this buyer has placed, optionally scoped to one lane.
522
+ *
523
+ * A Firestore aggregation โ€” billed at one read per 1000 index entries
524
+ * matched, not one per order โ€” so it stays flat as an account's history
525
+ * grows. That matters because the only caller is the session profile
526
+ * endpoint, which every page load hits.
527
+ *
528
+ * ๐Ÿ›‘ `orderType` may only name a NON-standard lane. The field was added
529
+ * after orders already existed, so an equality on `"standard"` would return
530
+ * zero for every legacy order while looking perfectly correct โ€” see the
531
+ * constant's own note.
532
+ */
533
+ async countForUser(userId, orderType) {
534
+ let query = this.getCollection().where(ORDER_FIELDS.USER_ID, "==", userId);
535
+ if (orderType) {
536
+ query = query.where(ORDER_FIELDS.ORDER_TYPE, "==", orderType);
537
+ }
538
+ return getFirestoreCount(query);
539
+ }
519
540
  async deleteByUser(userId) {
520
541
  try {
521
542
  const snapshot = await this.getCollection()
@@ -783,6 +804,52 @@ class OrderRepository extends BaseRepository {
783
804
  reason: ctx?.reason ?? target.reason,
784
805
  }, "orderRepository.settleRefund", order);
785
806
  }
807
+ /**
808
+ * Stamp a credit-note number onto one settled refund event (Phase 7, 7c).
809
+ *
810
+ * ## ๐Ÿ›‘ Why this is a repository method and not an inline update
811
+ *
812
+ * `refunds[]` is written by re-mapping the whole array, exactly as
813
+ * `settleRefund` directly above does โ€” because a read-modify-write of
814
+ * `[...existing, event]` LOSES a concurrent event (D6), and that defect is
815
+ * just as reachable from a credit-note stamp as from a refund append.
816
+ * Letting the invoicing feature touch the array directly would reintroduce
817
+ * it one caller away from the fix.
818
+ *
819
+ * It goes through `updateWithHistory` for the same reason every other
820
+ * mutator here does: the transition guard and the status-history entry live
821
+ * there, and this is a real recorded event on the order.
822
+ *
823
+ * ๐Ÿ›‘ A missing refund event is a NO-OP, not a throw. The caller is the
824
+ * refund settle path, where money has already moved; raising here would turn
825
+ * a successful refund into a reported failure. See
826
+ * `issueCreditNoteForRefund`'s own ๐Ÿ›‘.
827
+ */
828
+ async setRefundCreditNote(orderId, refundId, note, ctx) {
829
+ const order = await this.findById(orderId);
830
+ if (!order)
831
+ return null;
832
+ const existing = order.refunds ?? [];
833
+ const target = existing.find((r) => r.refundId === refundId);
834
+ if (!target)
835
+ return null;
836
+ // Already numbered โ€” never overwrite. A credit-note number is issued once,
837
+ // and a second number for one reversal is a permanent gap in the series.
838
+ if (target.creditNoteNumber)
839
+ return order;
840
+ const stamped = existing.map((r) => r.refundId === refundId ? { ...r, ...note } : r);
841
+ return this.updateWithHistory(orderId, { refunds: stamped, updatedAt: new Date() }, {
842
+ ...ctx,
843
+ extraChanges: {
844
+ creditNote: {
845
+ from: null,
846
+ to: { refundId, creditNoteNumber: note.creditNoteNumber },
847
+ },
848
+ },
849
+ actor: ctx?.actor ?? { uid: "system:invoicing", role: "system" },
850
+ reason: ctx?.reason ?? `Credit note ${note.creditNoteNumber} issued`,
851
+ }, "orderRepository.setRefundCreditNote", order);
852
+ }
786
853
  /**
787
854
  * ๐Ÿ›‘ LEGACY โ€” prefer `reserveRefund` + `settleRefund`.
788
855
  *
@@ -878,6 +945,68 @@ class OrderRepository extends BaseRepository {
878
945
  * `paymentProofUrl != null` filter would silently exclude every doc where
879
946
  * the field isn't set at all โ€” the opposite of what's needed here.
880
947
  */
948
+ /**
949
+ * Orders invoiced within a window โ€” the GSTR-1 export's only query
950
+ * (Phase 7d).
951
+ *
952
+ * ## ๐Ÿ›‘ Windowed on `invoiceIssuedAt`, not on the order date
953
+ *
954
+ * A COD order placed on 30 March and paid on 2 April is invoiced in the NEW
955
+ * financial year, and that is the period its tax belongs to. Numbering
956
+ * happens at the payment transition for exactly this reason, so the invoice
957
+ * date is the only correct axis โ€” windowing on `orderDate` would file that
958
+ * order's tax in the year before it was invoiced.
959
+ *
960
+ * ## ๐Ÿ›‘ It also returns PAID orders with no invoice number, deliberately
961
+ *
962
+ * Those are the ones the export must warn about rather than omit โ€” a paid
963
+ * order silently absent from a tax return is the single error this whole
964
+ * feature exists to prevent. Firestore cannot OR across two fields, so the
965
+ * second query is a separate one and the caller merges; the alternative
966
+ * (one query on `paymentStatus`, filtered in memory) would scan every paid
967
+ * order ever placed.
968
+ *
969
+ * Unbounded `.limit(2000)`: a quarter's orders at this volume is a few
970
+ * hundred, and an export that silently truncated would understate a tax
971
+ * return. If this ever saturates, the fix is pagination with an explicit
972
+ * "more rows exist" signal in the CSV โ€” never a higher cap.
973
+ */
974
+ async listInvoicedBetween(from, to) {
975
+ const [invoiced, paidUnnumbered] = await Promise.all([
976
+ this.db
977
+ .collection(this.collection)
978
+ .where("invoiceIssuedAt", ">=", from)
979
+ .where("invoiceIssuedAt", "<=", to)
980
+ .limit(2000)
981
+ .get(),
982
+ /*
983
+ * The exceptions. Bounded on `orderDate` because an un-invoiced order
984
+ * has no invoice date to window on โ€” which is the whole problem with it
985
+ * โ€” and because `paymentStatus == paid` alone would match every paid
986
+ * order in the collection's history.
987
+ */
988
+ this.db
989
+ .collection(this.collection)
990
+ .where(ORDER_FIELDS.PAYMENT_STATUS, "==", "paid")
991
+ .where(ORDER_FIELDS.ORDER_DATE, ">=", from)
992
+ .where(ORDER_FIELDS.ORDER_DATE, "<=", to)
993
+ .limit(2000)
994
+ .get(),
995
+ ]);
996
+ const byId = new Map();
997
+ for (const d of invoiced.docs) {
998
+ byId.set(d.id, { id: d.id, ...d.data() });
999
+ }
1000
+ for (const d of paidUnnumbered.docs) {
1001
+ const data = { id: d.id, ...d.data() };
1002
+ // Only the genuinely un-numbered ones โ€” a paid, numbered order is
1003
+ // already in the first set, and adding it again would double every one
1004
+ // of its rows in the return.
1005
+ if (!data.invoiceNumber && !byId.has(d.id))
1006
+ byId.set(d.id, data);
1007
+ }
1008
+ return [...byId.values()];
1009
+ }
881
1010
  async getExpiredPaymentDeadlines() {
882
1011
  const snap = await this.db
883
1012
  .collection(this.collection)
@@ -1031,10 +1160,23 @@ class OrderRepository extends BaseRepository {
1031
1160
  * and the anchor test is a per-row predicate below. One query, no new
1032
1161
  * composite index, and no way to silently return nothing.
1033
1162
  */
1163
+ const trusted = opts?.trustedStoreIds ?? new Set();
1034
1164
  const snap = await this.db
1035
1165
  .collection(this.collection)
1036
1166
  .where(ORDER_FIELDS.PAYOUT_STATUS, "==", "eligible")
1037
- .where(ORDER_FIELDS.STATUS, "==", OrderStatusValues.DELIVERED)
1167
+ /*
1168
+ * ๐Ÿ›‘ Widened to an `in` ONLY when some store is trusted.
1169
+ *
1170
+ * Firestore's `in` is an OR of equalities, so the existing
1171
+ * `(payoutStatus, status)` composite serves both forms and no new index
1172
+ * is needed. Keeping the plain equality when the set is empty matters
1173
+ * anyway: a deployment with no trusted sellers then runs byte-identically
1174
+ * to before, so the flag cannot change behaviour for anyone who has not
1175
+ * been granted it.
1176
+ */
1177
+ .where(ORDER_FIELDS.STATUS, ...(trusted.size > 0
1178
+ ? ["in", [OrderStatusValues.DELIVERED, OrderStatusValues.SHIPPED]]
1179
+ : ["==", OrderStatusValues.DELIVERED]))
1038
1180
  .limit(500)
1039
1181
  .get();
1040
1182
  let missingAnchor = 0;
@@ -1045,6 +1187,26 @@ class OrderRepository extends BaseRepository {
1045
1187
  data: { id: d.id, ...d.data() },
1046
1188
  }))
1047
1189
  .filter((o) => !o.data.emiEnabled || o.data.emiComplete)
1190
+ .filter((o) => {
1191
+ /*
1192
+ * ๐Ÿ›‘ A SHIPPED row is admitted only for a TRUSTED store, and then
1193
+ * bypasses the hold entirely โ€” paying at shipping is the grant.
1194
+ *
1195
+ * Tested before the anchor rather than inside it, because a shipped
1196
+ * order has no `deliveryDate` and would fall through to the
1197
+ * `updatedAt` fallback โ€” which is always LATER than delivery would
1198
+ * have been. A trusted seller would be paid more SLOWLY than an
1199
+ * untrusted one: the flag would read as working and do the opposite.
1200
+ *
1201
+ * The `in` above cannot express "shipped, but only for these stores",
1202
+ * so the store test has to live here โ€” otherwise one trusted seller
1203
+ * anywhere would widen the sweep for every seller.
1204
+ */
1205
+ if (o.data.status === OrderStatusValues.SHIPPED) {
1206
+ return typeof o.data.storeId === "string" && trusted.has(o.data.storeId);
1207
+ }
1208
+ return true;
1209
+ })
1048
1210
  .filter((o) => {
1049
1211
  /*
1050
1212
  * The anchor, with a conservative fallback. `deliveryDate` is the
@@ -1056,6 +1218,27 @@ class OrderRepository extends BaseRepository {
1056
1218
  * early. Withholding is recoverable โ€” the next sweep picks it up;
1057
1219
  * releasing early is not, because the money has gone.
1058
1220
  */
1221
+ /*
1222
+ * ๐Ÿ›‘ A BUYER'S OWN CONFIRMATION RELEASES THE PAYOUT IMMEDIATELY.
1223
+ *
1224
+ * The owner's rule: an order is CONFIRMED when it is delivered and
1225
+ * either the buyer says they received it, or 7 days pass. This filter
1226
+ * only ever implemented the second half โ€” `deliveryDate <= cutoff` โ€”
1227
+ * so a buyer who pressed "Mark complete" on day one still made their
1228
+ * seller wait out the full hold. The fast path existed and bought the
1229
+ * seller nothing.
1230
+ *
1231
+ * Safe in the direction that matters, and not by luck:
1232
+ * `markOrderCompleteAction` is the only writer of `completedAt`, and it
1233
+ * REFUSES while a return in any state, a posted refund or a buyer
1234
+ * dispute is live โ€” the same precondition the `order-complete`
1235
+ * obligation carries. So honouring it here cannot release money while
1236
+ * an issue is open; the hold is skipped only because the one party the
1237
+ * hold protects has said they are satisfied.
1238
+ */
1239
+ const completedAt = toDateOrNull(o.data.completedAt);
1240
+ if (completedAt)
1241
+ return true;
1059
1242
  const anchor = toDateOrNull(o.data.deliveryDate) ?? toDateOrNull(o.data.updatedAt);
1060
1243
  if (!o.data.deliveryDate)
1061
1244
  missingAnchor++;
@@ -1162,6 +1345,22 @@ OrderRepository.SELLER_SIEVE_FIELDS = {
1162
1345
  orderDate: { canFilter: true, canSort: true, parseValue: parseSieveDateValue },
1163
1346
  createdAt: { canFilter: true, canSort: true, parseValue: parseSieveDateValue },
1164
1347
  contestable: { canFilter: true, canSort: false },
1348
+ /*
1349
+ * Lane segregation on the SELLER's order list โ€” the same provenance axis
1350
+ * `/user/orders` has had.
1351
+ *
1352
+ * ๐Ÿ›‘ It was absent, and absence here is SILENT: `sieve.ts` sets
1353
+ * `throwExceptions: false`, so an unallowlisted field does not raise โ€”
1354
+ * `findField` returns undefined and the clause is simply dropped. A lane
1355
+ * chip emitting `orderType==auction` would therefore have returned the
1356
+ * seller's ENTIRE order list while looking exactly like a working filter
1357
+ * (Root Cause #62). Checked before wiring the chip, not after.
1358
+ *
1359
+ * ๐Ÿ›‘ Never pushed as `orderType==standard`, for the same reason the admin
1360
+ * set above carries that note: orders written before the field existed have
1361
+ * no value to match. `/api/store/orders` refines that one case in memory.
1362
+ */
1363
+ orderType: { canFilter: true, canSort: false },
1165
1364
  // Fulfilment flags. Filterable so "which of my orders need gift wrap?" is a
1166
1365
  // query against the orders themselves โ€” the whole point of recording the
1167
1366
  // add-on on the order rather than keeping a side list of who asked for what.
@@ -0,0 +1,40 @@
1
+ /**
2
+ * D55 โ€” write shapes for the pre-order balance collector.
3
+ *
4
+ * ๐Ÿ›‘ Both are `.strict()`, and that is the Root Cause #76 lesson rather than
5
+ * tidiness: the balance block carries `status`, `reviewedBy`, `reviewedAt`
6
+ * and `amount`, and a write shape that can NAME a field is a write shape that
7
+ * can destroy it. A buyer must not be able to send `status: "paid"` or
8
+ * `amount: 1`, and `z.object()` merely STRIPS unknown keys โ€” which is the
9
+ * same silent-success failure as the grouped-listings PATCH. `.strict()`
10
+ * makes it a 400 instead.
11
+ *
12
+ * Neither schema is where `amount` comes from. It is snapshotted from
13
+ * `sourceContext.balanceDue` when the seller opens collection, months before
14
+ * this, and is never re-read from the live product (D61).
15
+ */
16
+ import { z } from "zod";
17
+ /** The buyer's proof of payment. */
18
+ export declare const balanceProofSchema: z.ZodObject<{
19
+ proofUrl: z.ZodString;
20
+ transactionId: z.ZodString;
21
+ }, "strict", z.ZodTypeAny, {
22
+ transactionId: string;
23
+ proofUrl: string;
24
+ }, {
25
+ transactionId: string;
26
+ proofUrl: string;
27
+ }>;
28
+ export type BalanceProofInput = z.infer<typeof balanceProofSchema>;
29
+ /** The admin's verdict on a submitted proof. */
30
+ export declare const balanceReviewSchema: z.ZodObject<{
31
+ approve: z.ZodBoolean;
32
+ note: z.ZodOptional<z.ZodString>;
33
+ }, "strict", z.ZodTypeAny, {
34
+ approve: boolean;
35
+ note?: string | undefined;
36
+ }, {
37
+ approve: boolean;
38
+ note?: string | undefined;
39
+ }>;
40
+ export type BalanceReviewInput = z.infer<typeof balanceReviewSchema>;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * D55 โ€” write shapes for the pre-order balance collector.
3
+ *
4
+ * ๐Ÿ›‘ Both are `.strict()`, and that is the Root Cause #76 lesson rather than
5
+ * tidiness: the balance block carries `status`, `reviewedBy`, `reviewedAt`
6
+ * and `amount`, and a write shape that can NAME a field is a write shape that
7
+ * can destroy it. A buyer must not be able to send `status: "paid"` or
8
+ * `amount: 1`, and `z.object()` merely STRIPS unknown keys โ€” which is the
9
+ * same silent-success failure as the grouped-listings PATCH. `.strict()`
10
+ * makes it a 400 instead.
11
+ *
12
+ * Neither schema is where `amount` comes from. It is snapshotted from
13
+ * `sourceContext.balanceDue` when the seller opens collection, months before
14
+ * this, and is never re-read from the live product (D61).
15
+ */
16
+ import { z } from "zod";
17
+ /** The buyer's proof of payment. */
18
+ export const balanceProofSchema = z
19
+ .object({
20
+ /*
21
+ * A `/media/โ€ฆ` slug from the signed-URL upload flow โ€” bytes never reach
22
+ * this route (Rule #6's 4.5 MB payload cap, and ยง Media Architecture).
23
+ */
24
+ proofUrl: z.string().min(1, "Upload a screenshot of the payment."),
25
+ /*
26
+ * The UTR or UPI reference. Required, because it is the only thing an
27
+ * admin can check the payment against โ€” a screenshot alone is a picture.
28
+ */
29
+ transactionId: z
30
+ .string()
31
+ .min(4, "Enter the transaction reference from your bank or UPI app.")
32
+ .max(64),
33
+ })
34
+ .strict();
35
+ /** The admin's verdict on a submitted proof. */
36
+ export const balanceReviewSchema = z
37
+ .object({
38
+ approve: z.boolean(),
39
+ /*
40
+ * Optional HERE and required in `reviewBalanceProof` when `approve` is
41
+ * false. Deliberately not a `.refine()`: the rule belongs with the
42
+ * transition it guards, and duplicating it would give two places to
43
+ * disagree. An approval genuinely needs no note.
44
+ */
45
+ note: z.string().max(300).optional(),
46
+ })
47
+ .strict();