@mohasinac/appkit 4.13.0 → 4.14.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 (377) hide show
  1. package/dist/_internal/client/features/layout/DashboardLayoutClient.js +14 -5
  2. package/dist/_internal/client/features/lottery/LotteryAdminEditView.d.ts +3 -0
  3. package/dist/_internal/client/features/lottery/LotteryAdminEditView.js +6 -0
  4. package/dist/_internal/client/features/lottery/LotteryDetailView.d.ts +8 -0
  5. package/dist/_internal/client/features/lottery/LotteryDetailView.js +4 -1
  6. package/dist/_internal/client/features/lottery/LotteryListView.d.ts +7 -0
  7. package/dist/_internal/client/features/lottery/LotteryListView.js +1 -1
  8. package/dist/_internal/client/features/lottery/PrizeDrawLotteryDetailView.js +4 -1
  9. package/dist/_internal/client/features/lottery/slot-collage-items.d.ts +15 -0
  10. package/dist/_internal/client/features/lottery/slot-collage-items.js +13 -0
  11. package/dist/_internal/server/features/auctions/actions.js +6 -0
  12. package/dist/_internal/server/features/bundles/data.d.ts +16 -0
  13. package/dist/_internal/server/features/bundles/data.js +26 -0
  14. package/dist/_internal/server/features/bundles/index.d.ts +1 -1
  15. package/dist/_internal/server/features/bundles/index.js +1 -1
  16. package/dist/_internal/server/features/checkout/actions.js +6 -0
  17. package/dist/_internal/server/features/checkout/locked-lines.d.ts +38 -0
  18. package/dist/_internal/server/features/checkout/locked-lines.js +171 -0
  19. package/dist/_internal/server/features/homepage/index.d.ts +0 -1
  20. package/dist/_internal/server/features/homepage/index.js +7 -1
  21. package/dist/_internal/server/features/lottery/adapters.js +4 -0
  22. package/dist/_internal/server/features/products/data.js +15 -37
  23. package/dist/_internal/server/features/products/index.d.ts +1 -1
  24. package/dist/_internal/server/features/products/index.js +1 -1
  25. package/dist/_internal/server/features/products/list-public.d.ts +46 -20
  26. package/dist/_internal/server/features/products/list-public.js +266 -90
  27. package/dist/_internal/server/features/products/listing-tab-counts.d.ts +44 -0
  28. package/dist/_internal/server/features/products/listing-tab-counts.js +97 -0
  29. package/dist/_internal/server/features/site-settings/adapters.d.ts +51 -0
  30. package/dist/_internal/server/features/site-settings/adapters.js +75 -0
  31. package/dist/_internal/server/features/site-settings/index.d.ts +1 -0
  32. package/dist/_internal/server/features/site-settings/index.js +1 -0
  33. package/dist/_internal/server/features/stores/adapters.d.ts +56 -0
  34. package/dist/_internal/server/features/stores/adapters.js +91 -0
  35. package/dist/_internal/server/features/stores/index.d.ts +1 -0
  36. package/dist/_internal/server/features/stores/index.js +1 -0
  37. package/dist/_internal/server/jobs/core/auctionSettlement.js +56 -2
  38. package/dist/_internal/server/jobs/core/offerExpiry.js +45 -9
  39. package/dist/_internal/server/jobs/core/paymentReviewAutoApprove.d.ts +5 -0
  40. package/dist/_internal/server/jobs/core/paymentReviewAutoApprove.js +33 -1
  41. package/dist/_internal/server/jobs/handlers/messages.d.ts +7 -0
  42. package/dist/_internal/server/jobs/handlers/messages.js +10 -0
  43. package/dist/_internal/shared/actions/action-registry.js +15 -1
  44. package/dist/_internal/shared/checkout/lanes.d.ts +25 -0
  45. package/dist/_internal/shared/checkout/lanes.js +26 -0
  46. package/dist/_internal/shared/features/auctions/config.d.ts +27 -0
  47. package/dist/_internal/shared/features/auctions/config.js +27 -0
  48. package/dist/_internal/shared/features/blog/schema.d.ts +2 -2
  49. package/dist/_internal/shared/features/cart/schema.d.ts +12 -12
  50. package/dist/_internal/shared/features/categories/bundle-schemas.d.ts +32 -32
  51. package/dist/_internal/shared/features/emi/schedule.d.ts +24 -3
  52. package/dist/_internal/shared/features/emi/schedule.js +20 -5
  53. package/dist/_internal/shared/features/events/schema.d.ts +2 -2
  54. package/dist/_internal/shared/features/homepage/section-gate.d.ts +14 -0
  55. package/dist/_internal/shared/features/homepage/section-gate.js +51 -0
  56. package/dist/_internal/shared/features/offers/config.d.ts +30 -0
  57. package/dist/_internal/shared/features/offers/config.js +59 -0
  58. package/dist/_internal/shared/features/orders/schema.d.ts +8 -8
  59. package/dist/_internal/shared/features/products/schema.d.ts +32 -32
  60. package/dist/_internal/shared/features/products/to-product-item.js +6 -0
  61. package/dist/_internal/shared/features/reviews/schema.d.ts +2 -2
  62. package/dist/_internal/shared/features/site-settings/fees.d.ts +60 -0
  63. package/dist/_internal/shared/features/site-settings/fees.js +39 -0
  64. package/dist/_internal/shared/features/site-settings/types.d.ts +40 -0
  65. package/dist/_internal/shared/features/site-settings/types.js +1 -0
  66. package/dist/_internal/shared/history/history.d.ts +66 -0
  67. package/dist/_internal/shared/history/history.js +158 -0
  68. package/dist/_internal/shared/history/index.d.ts +4 -0
  69. package/dist/_internal/shared/history/index.js +2 -0
  70. package/dist/_internal/shared/history/types.d.ts +61 -0
  71. package/dist/_internal/shared/history/types.js +6 -0
  72. package/dist/_internal/shared/listing-types/_registry.d.ts +54 -1
  73. package/dist/_internal/shared/listing-types/_registry.js +67 -0
  74. package/dist/_internal/shared/listing-types/art/config.d.ts +3 -0
  75. package/dist/_internal/shared/listing-types/art/config.js +5 -0
  76. package/dist/_internal/shared/listing-types/auction/config.d.ts +13 -0
  77. package/dist/_internal/shared/listing-types/auction/config.js +21 -0
  78. package/dist/_internal/shared/listing-types/availability.d.ts +79 -0
  79. package/dist/_internal/shared/listing-types/availability.js +104 -0
  80. package/dist/_internal/shared/listing-types/capabilities.d.ts +15 -0
  81. package/dist/_internal/shared/listing-types/capabilities.js +12 -0
  82. package/dist/_internal/shared/listing-types/classified/config.d.ts +3 -0
  83. package/dist/_internal/shared/listing-types/classified/config.js +5 -0
  84. package/dist/_internal/shared/listing-types/digital-code/config.d.ts +11 -0
  85. package/dist/_internal/shared/listing-types/digital-code/config.js +22 -2
  86. package/dist/_internal/shared/listing-types/live/config.d.ts +3 -0
  87. package/dist/_internal/shared/listing-types/live/config.js +5 -0
  88. package/dist/_internal/shared/listing-types/pre-order/config.d.ts +3 -0
  89. package/dist/_internal/shared/listing-types/pre-order/config.js +19 -0
  90. package/dist/_internal/shared/listing-types/prize-draw/config.d.ts +11 -0
  91. package/dist/_internal/shared/listing-types/prize-draw/config.js +15 -0
  92. package/dist/_internal/shared/listing-types/standard/config.d.ts +3 -0
  93. package/dist/_internal/shared/listing-types/standard/config.js +5 -0
  94. package/dist/_internal/shared/listing-types/stickers/config.d.ts +3 -0
  95. package/dist/_internal/shared/listing-types/stickers/config.js +5 -0
  96. package/dist/client.d.ts +7 -5
  97. package/dist/client.js +2 -2
  98. package/dist/constants/api-endpoints.d.ts +6 -0
  99. package/dist/constants/api-endpoints.js +2 -0
  100. package/dist/constants/field-names.d.ts +49 -2
  101. package/dist/constants/field-names.js +53 -2
  102. package/dist/constants/table-keys.d.ts +17 -0
  103. package/dist/constants/table-keys.js +17 -0
  104. package/dist/errors/error-codes.d.ts +13 -1
  105. package/dist/errors/error-codes.js +13 -1
  106. package/dist/errors/error-display-map.js +12 -3
  107. package/dist/errors/messages.d.ts +10 -2
  108. package/dist/errors/messages.js +10 -2
  109. package/dist/features/about/components/AboutView.d.ts +3 -0
  110. package/dist/features/about/components/AboutView.js +3 -2
  111. package/dist/features/about/components/PolicyPageView.d.ts +2 -1
  112. package/dist/features/about/components/PolicyPageView.js +61 -23
  113. package/dist/features/about/components/PublicProfileView.js +5 -0
  114. package/dist/features/about/schemas/firestore.d.ts +3 -0
  115. package/dist/features/account/components/UserOrdersView.js +7 -0
  116. package/dist/features/account/components/index.d.ts +0 -2
  117. package/dist/features/account/components/index.js +0 -1
  118. package/dist/features/account/schemas/index.d.ts +2 -2
  119. package/dist/features/account/types/index.d.ts +21 -2
  120. package/dist/features/addresses/schemas/index.d.ts +4 -4
  121. package/dist/features/admin/components/AdminArtView.js +8 -3
  122. package/dist/features/admin/components/AdminClassifiedView.js +8 -3
  123. package/dist/features/admin/components/AdminDigitalCodesView.js +8 -3
  124. package/dist/features/admin/components/AdminFeatureFlagsView.js +1 -0
  125. package/dist/features/admin/components/AdminLiveView.js +8 -3
  126. package/dist/features/admin/components/AdminOffersView.d.ts +4 -0
  127. package/dist/features/admin/components/AdminOffersView.js +186 -0
  128. package/dist/features/admin/components/AdminOrdersView.js +10 -1
  129. package/dist/features/admin/components/AdminPrizeDrawsView.js +5 -0
  130. package/dist/features/admin/components/AdminProductsView.js +16 -29
  131. package/dist/features/admin/components/AdminSiteSettingsView.js +31 -13
  132. package/dist/features/admin/components/AdminSiteView.js +6 -2
  133. package/dist/features/admin/components/AdminStickersView.js +8 -3
  134. package/dist/features/admin/components/index.d.ts +2 -0
  135. package/dist/features/admin/components/index.js +1 -0
  136. package/dist/features/admin/constants/filter-tabs.d.ts +86 -0
  137. package/dist/features/admin/constants/filter-tabs.js +55 -0
  138. package/dist/features/admin/schemas/firestore.d.ts +122 -3
  139. package/dist/features/admin/schemas/firestore.js +1 -0
  140. package/dist/features/auctions/actions/bid-actions.d.ts +20 -5
  141. package/dist/features/auctions/actions/bid-actions.js +93 -20
  142. package/dist/features/auctions/components/AuctionDetailPageView.js +11 -6
  143. package/dist/features/auctions/components/AuctionsListView.js +5 -6
  144. package/dist/features/auctions/components/MarketplaceAuctionCard.d.ts +7 -0
  145. package/dist/features/auctions/components/MarketplaceAuctionCard.js +19 -2
  146. package/dist/features/auctions/components/PlaceBidFormClient.d.ts +1 -2
  147. package/dist/features/auctions/components/PlaceBidFormClient.js +8 -4
  148. package/dist/features/auctions/repository/bid.repository.d.ts +13 -0
  149. package/dist/features/auctions/repository/bid.repository.js +23 -0
  150. package/dist/features/auctions/schemas/firestore.d.ts +17 -0
  151. package/dist/features/auctions/schemas/index.d.ts +12 -12
  152. package/dist/features/auth/permissions/constants.d.ts +1 -1
  153. package/dist/features/auth/permissions/constants.js +10 -1
  154. package/dist/features/blog/actions/blog-actions.d.ts +7 -7
  155. package/dist/features/blog/schemas/index.d.ts +6 -6
  156. package/dist/features/cart/repository/cart.repository.js +1 -0
  157. package/dist/features/cart/schemas/firestore.d.ts +15 -0
  158. package/dist/features/catalogue/schemas/validation.d.ts +4 -4
  159. package/dist/features/categories/components/BrandDetailPageView.js +23 -40
  160. package/dist/features/categories/components/BrandDetailTabs.d.ts +7 -7
  161. package/dist/features/categories/components/BrandDetailTabs.js +8 -12
  162. package/dist/features/categories/components/BundleCollage.js +1 -1
  163. package/dist/features/categories/components/CategoryDetailPageView.js +53 -57
  164. package/dist/features/categories/components/CategoryDetailTabs.d.ts +10 -8
  165. package/dist/features/categories/components/CategoryDetailTabs.js +11 -16
  166. package/dist/features/categories/components/CategoryProductsListing.js +11 -1
  167. package/dist/features/categories/components/ConcernCard.js +7 -1
  168. package/dist/features/categories/schemas/firestore.d.ts +13 -0
  169. package/dist/features/categories/schemas/index.d.ts +26 -26
  170. package/dist/features/classified/components/ClassifiedDetailPageView.d.ts +16 -1
  171. package/dist/features/classified/components/ClassifiedDetailPageView.js +23 -3
  172. package/dist/features/events/components/AdminEventsView.js +15 -11
  173. package/dist/features/events/components/EventFilters.d.ts +9 -1
  174. package/dist/features/events/components/EventFilters.js +45 -21
  175. package/dist/features/events/components/EventsIndexListing.d.ts +6 -1
  176. package/dist/features/events/components/EventsIndexListing.js +2 -2
  177. package/dist/features/events/components/EventsListPageView.js +13 -4
  178. package/dist/features/events/repository/events.repository.d.ts +17 -0
  179. package/dist/features/events/repository/events.repository.js +27 -0
  180. package/dist/features/events/schemas/firestore.d.ts +12 -0
  181. package/dist/features/events/schemas/firestore.js +12 -0
  182. package/dist/features/events/schemas/index.d.ts +50 -50
  183. package/dist/features/events/types/index.d.ts +11 -0
  184. package/dist/features/events/types/index.js +57 -1
  185. package/dist/features/faq/actions/faq-actions.d.ts +12 -12
  186. package/dist/features/faq/schemas/index.d.ts +8 -8
  187. package/dist/features/filters/FilterFacetSection.d.ts +7 -1
  188. package/dist/features/filters/FilterFacetSection.js +11 -3
  189. package/dist/features/grouped/schemas/index.d.ts +4 -4
  190. package/dist/features/homepage/components/AnnouncementBar.d.ts +7 -1
  191. package/dist/features/homepage/components/AnnouncementBar.js +3 -3
  192. package/dist/features/homepage/components/MarketplaceHomepageView.js +20 -6
  193. package/dist/features/homepage/hooks/homepage-query.d.ts +16 -0
  194. package/dist/features/homepage/hooks/homepage-query.js +45 -0
  195. package/dist/features/homepage/hooks/useFeaturedAuctions.d.ts +10 -0
  196. package/dist/features/homepage/hooks/useFeaturedAuctions.js +28 -8
  197. package/dist/features/homepage/hooks/useFeaturedPreOrders.js +17 -8
  198. package/dist/features/homepage/hooks/useFeaturedProducts.js +15 -8
  199. package/dist/features/homepage/schemas/index.d.ts +2 -2
  200. package/dist/features/layout/AppLayoutShell.d.ts +11 -1
  201. package/dist/features/layout/AppLayoutShell.js +15 -14
  202. package/dist/features/layout/BackToTop.d.ts +9 -0
  203. package/dist/features/layout/BackToTop.js +10 -1
  204. package/dist/features/layout/BottomActions.js +28 -25
  205. package/dist/features/layout/BottomChrome.d.ts +34 -0
  206. package/dist/features/layout/BottomChrome.js +55 -0
  207. package/dist/features/layout/BottomNavLayout.d.ts +6 -0
  208. package/dist/features/layout/BottomNavLayout.js +7 -1
  209. package/dist/features/layout/BottomNavbar.js +15 -2
  210. package/dist/features/layout/FooterLayout.js +11 -1
  211. package/dist/features/layout/NavbarLayout.js +1 -1
  212. package/dist/features/layout/TitleBarLayout.d.ts +7 -0
  213. package/dist/features/layout/TitleBarLayout.js +28 -5
  214. package/dist/features/layout/index.d.ts +2 -0
  215. package/dist/features/layout/index.js +1 -0
  216. package/dist/features/lottery/types/index.d.ts +3 -0
  217. package/dist/features/media/MediaPickerModal.js +5 -1
  218. package/dist/features/messages/schemas/index.d.ts +2 -2
  219. package/dist/features/orders/components/OrderScopeTabs.d.ts +20 -0
  220. package/dist/features/orders/components/OrderScopeTabs.js +31 -0
  221. package/dist/features/orders/constants/order-scope.d.ts +48 -0
  222. package/dist/features/orders/constants/order-scope.js +111 -0
  223. package/dist/features/orders/repository/orders.repository.d.ts +54 -7
  224. package/dist/features/orders/repository/orders.repository.js +116 -22
  225. package/dist/features/orders/schemas/firestore.d.ts +117 -0
  226. package/dist/features/orders/schemas/firestore.js +30 -0
  227. package/dist/features/orders/schemas/index.d.ts +18 -18
  228. package/dist/features/pre-orders/components/PreOrdersIndexListing.js +14 -9
  229. package/dist/features/pre-orders/components/PreOrdersListView.js +6 -5
  230. package/dist/features/pre-orders/schemas/index.d.ts +1 -1
  231. package/dist/features/products/actions/product-actions.d.ts +14 -0
  232. package/dist/features/products/actions/product-actions.js +49 -11
  233. package/dist/features/products/api/route.d.ts +12 -0
  234. package/dist/features/products/api/route.js +42 -100
  235. package/dist/features/products/components/ArtStickersListView.js +2 -2
  236. package/dist/features/products/components/AuctionsIndexListing.js +13 -11
  237. package/dist/features/products/components/AvailabilityTabs.d.ts +11 -0
  238. package/dist/features/products/components/AvailabilityTabs.js +47 -0
  239. package/dist/features/products/components/MakeOfferButton.js +48 -49
  240. package/dist/features/products/components/PrizeDrawCollage.d.ts +20 -4
  241. package/dist/features/products/components/PrizeDrawCollage.js +9 -1
  242. package/dist/features/products/components/PrizeDrawsIndexListing.js +14 -12
  243. package/dist/features/products/components/PrizeDrawsListingView.js +2 -2
  244. package/dist/features/products/components/PrizeDrawsSection.d.ts +7 -1
  245. package/dist/features/products/components/PrizeDrawsSection.js +23 -18
  246. package/dist/features/products/components/ProductDetailPageView.d.ts +4 -1
  247. package/dist/features/products/components/ProductDetailPageView.js +18 -4
  248. package/dist/features/products/components/ProductForm.js +5 -2
  249. package/dist/features/products/components/ProductGrid.js +6 -1
  250. package/dist/features/products/components/ProductsIndexListing.js +22 -32
  251. package/dist/features/products/components/ProductsIndexPageView.js +6 -9
  252. package/dist/features/products/components/index.d.ts +2 -2
  253. package/dist/features/products/components/index.js +1 -1
  254. package/dist/features/products/config/listing-type-listing-config.d.ts +20 -0
  255. package/dist/features/products/config/listing-type-listing-config.js +22 -10
  256. package/dist/features/products/constants/action-defs.d.ts +2 -0
  257. package/dist/features/products/constants/action-defs.js +6 -0
  258. package/dist/features/products/hooks/useAvailabilityScope.d.ts +13 -0
  259. package/dist/features/products/hooks/useAvailabilityScope.js +19 -0
  260. package/dist/features/products/hooks/useProducts.d.ts +5 -0
  261. package/dist/features/products/hooks/useProducts.js +13 -2
  262. package/dist/features/products/repository/products.repository.d.ts +31 -2
  263. package/dist/features/products/repository/products.repository.js +53 -21
  264. package/dist/features/products/schemas/firestore.d.ts +17 -3
  265. package/dist/features/products/schemas/firestore.js +7 -2
  266. package/dist/features/products/schemas/index.d.ts +66 -66
  267. package/dist/features/products/schemas/product-features.validators.d.ts +6 -6
  268. package/dist/features/products/types/index.d.ts +16 -1
  269. package/dist/features/promotions/schemas/index.d.ts +2 -2
  270. package/dist/features/reviews/schemas/index.d.ts +16 -16
  271. package/dist/features/search/schemas/index.d.ts +4 -4
  272. package/dist/features/seller/actions/offer-actions.js +25 -2
  273. package/dist/features/seller/components/SellerArtView.js +5 -0
  274. package/dist/features/seller/components/SellerAuctionsView.js +13 -15
  275. package/dist/features/seller/components/SellerClassifiedView.js +5 -0
  276. package/dist/features/seller/components/SellerDigitalCodesView.js +5 -0
  277. package/dist/features/seller/components/SellerLiveView.js +5 -0
  278. package/dist/features/seller/components/SellerOrdersView.js +31 -9
  279. package/dist/features/seller/components/SellerPayoutSettingsView.js +19 -18
  280. package/dist/features/seller/components/SellerPreOrdersView.js +5 -0
  281. package/dist/features/seller/components/SellerPrizeDrawsView.js +14 -16
  282. package/dist/features/seller/components/SellerProductShell.js +7 -1
  283. package/dist/features/seller/components/SellerProductsView.js +11 -8
  284. package/dist/features/seller/components/SellerStickersView.js +5 -0
  285. package/dist/features/seller/components/index.d.ts +0 -2
  286. package/dist/features/seller/components/index.js +0 -1
  287. package/dist/features/seller/repository/offer.repository.d.ts +73 -16
  288. package/dist/features/seller/repository/offer.repository.js +38 -3
  289. package/dist/features/seller/schemas/index.d.ts +2 -2
  290. package/dist/features/seller/schemas/offer-forms.d.ts +25 -0
  291. package/dist/features/seller/schemas/offer-forms.js +21 -0
  292. package/dist/features/seller/server.d.ts +0 -1
  293. package/dist/features/seller/server.js +0 -1
  294. package/dist/features/shell/SectionForm.d.ts +99 -0
  295. package/dist/features/shell/SectionForm.js +128 -0
  296. package/dist/features/shell/entity-form.d.ts +109 -0
  297. package/dist/features/shell/entity-form.js +96 -0
  298. package/dist/features/shell/index.d.ts +4 -0
  299. package/dist/features/shell/index.js +2 -0
  300. package/dist/features/stores/api/[storeSlug]/route.js +2 -25
  301. package/dist/features/stores/components/StoreAuctionsListing.js +15 -1
  302. package/dist/features/stores/components/StoreClassifiedsListing.js +12 -2
  303. package/dist/features/stores/components/StoreDetailLayoutView.js +24 -71
  304. package/dist/features/stores/components/StoreDigitalCodesListing.js +12 -2
  305. package/dist/features/stores/components/StoreLiveItemsListing.js +12 -2
  306. package/dist/features/stores/components/StorePreOrdersListing.js +12 -1
  307. package/dist/features/stores/components/StoreProductsListing.js +11 -1
  308. package/dist/features/stores/repository/store.repository.js +6 -0
  309. package/dist/features/stores/schemas/index.d.ts +6 -6
  310. package/dist/features/support/schemas/index.d.ts +4 -4
  311. package/dist/features/tester/actions/checklist-item-actions.d.ts +4 -4
  312. package/dist/features/tester/seed-data/offers-tester-seed-data.js +119 -3
  313. package/dist/features/tester/seed-data/products-tester-seed-data.js +131 -1
  314. package/dist/features/tester/seed-data/tester-checklist-seed-data.js +105 -1
  315. package/dist/features/wishlist/hooks/useWishlistWithGuest.d.ts +1 -1
  316. package/dist/index.d.ts +13 -10
  317. package/dist/index.js +14 -9
  318. package/dist/next/routing/route-map.d.ts +7 -1
  319. package/dist/next/routing/route-map.js +5 -0
  320. package/dist/providers/db-firebase/base.repository.d.ts +30 -0
  321. package/dist/providers/db-firebase/base.repository.js +50 -1
  322. package/dist/providers/db-firebase/index.d.ts +1 -1
  323. package/dist/providers/db-firebase/index.js +1 -1
  324. package/dist/providers/db-firebase/sieve.d.ts +25 -0
  325. package/dist/providers/db-firebase/sieve.js +52 -18
  326. package/dist/react/hooks/useUrlTable.js +10 -1
  327. package/dist/schemas/registry.d.ts +68 -68
  328. package/dist/seed/_helpers/category-forest.d.ts +2 -0
  329. package/dist/seed/_helpers/category-forest.js +309 -0
  330. package/dist/seed/_helpers/category-tree.d.ts +27 -0
  331. package/dist/seed/_helpers/category-tree.js +103 -0
  332. package/dist/seed/catalogue-seed-data.js +12 -12
  333. package/dist/seed/categories-seed-data.js +177 -162
  334. package/dist/seed/events-seed-data.js +61 -10
  335. package/dist/seed/homepage-sections-seed-data.js +5 -1
  336. package/dist/seed/offers-seed-data.js +32 -27
  337. package/dist/seed/products-art-seed-data.js +50 -12
  338. package/dist/seed/products-auctions-seed-data.js +97 -18
  339. package/dist/seed/products-classifieds-seed-data.js +80 -16
  340. package/dist/seed/products-digital-codes-seed-data.js +66 -18
  341. package/dist/seed/products-live-items-seed-data.js +64 -13
  342. package/dist/seed/products-preorders-seed-data.d.ts +0 -1
  343. package/dist/seed/products-preorders-seed-data.js +52 -13
  344. package/dist/seed/products-prize-draws-seed-data.js +63 -14
  345. package/dist/seed/products-standard-seed-data.js +99 -26
  346. package/dist/seed/products-stickers-seed-data.js +47 -12
  347. package/dist/seed/reviews-seed-data.js +6 -1
  348. package/dist/seed/site-settings-seed-data.d.ts +1 -38
  349. package/dist/seed/site-settings-seed-data.js +38 -76
  350. package/dist/seed/stores-seed-data.js +71 -1
  351. package/dist/seed/users-seed-data.js +15 -5
  352. package/dist/server-entry.d.ts +1 -2
  353. package/dist/server-entry.js +4 -3
  354. package/dist/server.d.ts +4 -3
  355. package/dist/server.js +8 -4
  356. package/dist/styles.css +78 -12
  357. package/dist/tailwind-utilities.css +1 -1
  358. package/dist/ui/components/Button.style.css +19 -4
  359. package/dist/ui/components/CollapsibleSection.d.ts +17 -1
  360. package/dist/ui/components/CollapsibleSection.js +6 -2
  361. package/dist/ui/components/FilterChipGroup.d.ts +25 -1
  362. package/dist/ui/components/FilterChipGroup.js +21 -4
  363. package/dist/ui/components/HandMode.style.css +47 -0
  364. package/dist/ui/components/Layout.d.ts +9 -2
  365. package/dist/ui/components/Layout.js +1 -1
  366. package/dist/ui/components/ListingLayout.js +8 -8
  367. package/dist/ui/components/ListingLayout.style.css +8 -7
  368. package/dist/ui/components/StickyToolbar.d.ts +3 -1
  369. package/dist/ui/components/StickyToolbar.js +62 -20
  370. package/dist/ui/components/bottom-chrome-slot.d.ts +21 -0
  371. package/dist/ui/components/bottom-chrome-slot.js +29 -0
  372. package/dist/ui/components/index.style.css +3 -0
  373. package/dist/ui/forms/FormShell.d.ts +43 -13
  374. package/dist/ui/forms/FormShell.js +22 -11
  375. package/dist/ui/forms/index.d.ts +1 -1
  376. package/dist/ui/index.d.ts +1 -1
  377. package/package.json +2 -2
@@ -2,8 +2,27 @@ import type { DocumentReference, WriteBatch } from "firebase-admin/firestore";
2
2
  import type { FirebaseSieveResult, SieveModel } from "../../../providers/db-firebase";
3
3
  import { BaseRepository, parseSieveDateValue } from "../../../providers/db-firebase";
4
4
  import { type OrderCreateInput, type OrderDocument, type OrderRefundEvent } from "../schemas";
5
+ import { type HistoryActor, type FieldChange } from "../../../_internal/shared/history/index";
5
6
  import type { OrderStatus, PaymentStatus } from "../types";
6
7
  import { type PaymentReviewQueueMode } from "../constants/payment-window";
8
+ /**
9
+ * Who/why for a write that lands in `statusHistory`.
10
+ *
11
+ * Optional everywhere so existing callers keep compiling and record
12
+ * `system`; pass it wherever the acting user is known.
13
+ */
14
+ export interface OrderWriteContext {
15
+ actor?: HistoryActor;
16
+ /** Overrides the default trigger label with the calling function's name. */
17
+ trigger?: string;
18
+ reason?: string;
19
+ note?: string;
20
+ /**
21
+ * Changes the field diff cannot express — used by `postRefundEvent` to put
22
+ * the refund itself on the timeline rather than an array-length delta.
23
+ */
24
+ extraChanges?: Record<string, FieldChange>;
25
+ }
7
26
  declare class OrderRepository extends BaseRepository<OrderDocument> {
8
27
  constructor();
9
28
  private decryptOrder;
@@ -15,10 +34,23 @@ declare class OrderRepository extends BaseRepository<OrderDocument> {
15
34
  findByStatus(status: OrderStatus): Promise<OrderDocument[]>;
16
35
  findConfirmed(): Promise<OrderDocument[]>;
17
36
  findPending(): Promise<OrderDocument[]>;
18
- updateStatus(orderId: string, status: OrderStatus, additionalData?: Partial<OrderDocument>): Promise<OrderDocument>;
37
+ /**
38
+ * Every write primitive below routes through this so `statusHistory` is
39
+ * appended at the SEVEN places a tracked field can change, rather than at
40
+ * the ~32 call sites above them. That is what makes order history a
41
+ * contained change instead of a codebase-wide sweep — and it follows the
42
+ * precedent `postRefundEvent` already set for append-only order data.
43
+ *
44
+ * `ctx` is optional throughout: a caller that has not been updated yet
45
+ * records `system` rather than failing, so this rolls out incrementally.
46
+ * The actor is worth passing wherever it is known — a history entry that
47
+ * cannot say who cancelled an order is a much weaker record.
48
+ */
49
+ private updateWithHistory;
50
+ updateStatus(orderId: string, status: OrderStatus, additionalData?: Partial<OrderDocument>, ctx?: OrderWriteContext): Promise<OrderDocument>;
19
51
  assignWorker(orderId: string, workerId: string): Promise<OrderDocument>;
20
52
  unassignWorker(orderId: string): Promise<OrderDocument>;
21
- markPicked(orderId: string): Promise<OrderDocument>;
53
+ markPicked(orderId: string, ctx?: OrderWriteContext): Promise<OrderDocument>;
22
54
  markPacked(orderId: string): Promise<OrderDocument>;
23
55
  /**
24
56
  * Payment Detail Parity (Feature C) — the COD counterpart to the manual
@@ -27,10 +59,10 @@ declare class OrderRepository extends BaseRepository<OrderDocument> {
27
59
  * verify against, so `verifiedBy` is the acting user's uid and
28
60
  * `verificationMethod` is always "cod_collection".
29
61
  */
30
- markCodCollected(orderId: string, verifiedBy: string, note?: string): Promise<OrderDocument>;
62
+ markCodCollected(orderId: string, verifiedBy: string, note?: string, ctx?: OrderWriteContext): Promise<OrderDocument>;
31
63
  findFulfillmentQueue(storeId: string): Promise<OrderDocument[]>;
32
- updatePaymentStatus(orderId: string, paymentStatus: PaymentStatus, paymentId?: string): Promise<OrderDocument>;
33
- cancelOrder(orderId: string, reason: string, refundAmount?: number): Promise<OrderDocument>;
64
+ updatePaymentStatus(orderId: string, paymentStatus: PaymentStatus, paymentId?: string, ctx?: OrderWriteContext): Promise<OrderDocument>;
65
+ cancelOrder(orderId: string, reason: string, refundAmount?: number, ctx?: OrderWriteContext): Promise<OrderDocument>;
34
66
  findRecentByUser(userId: string): Promise<OrderDocument[]>;
35
67
  hasUserPurchased(userId: string, productId: string): Promise<boolean>;
36
68
  /**
@@ -217,7 +249,7 @@ declare class OrderRepository extends BaseRepository<OrderDocument> {
217
249
  * Append one refund event to the order and mark it non-contestable.
218
250
  * If `becomeRefunded` is true, also transitions the order status to "refunded".
219
251
  */
220
- postRefundEvent(orderId: string, event: OrderRefundEvent, becomeRefunded?: boolean): Promise<OrderDocument>;
252
+ postRefundEvent(orderId: string, event: OrderRefundEvent, becomeRefunded?: boolean, ctx?: OrderWriteContext): Promise<OrderDocument>;
221
253
  /** Fetch all orders sharing a paymentBatchId (for sibling-orders display). */
222
254
  findByPaymentBatchId(batchId: string): Promise<OrderDocument[]>;
223
255
  /**
@@ -327,8 +359,23 @@ declare class OrderRepository extends BaseRepository<OrderDocument> {
327
359
  markPayoutRequested(batch: WriteBatch, ref: DocumentReference, payoutId: string): void;
328
360
  /**
329
361
  * Cloud Functions: stage a cancellation update into a caller-owned WriteBatch.
362
+ *
363
+ * `fromStatus` is supplied by the caller because a batch write does no read
364
+ * — but the sweep that calls this already filtered on a status, so it knows
365
+ * the value. Passing it beats recording `null` for something that is
366
+ * genuinely known one stack frame up.
367
+ */
368
+ cancelInBatch(batch: WriteBatch, ref: DocumentReference, fromStatus?: OrderStatus | null): void;
369
+ /**
370
+ * History append for the two WriteBatch paths, which cannot read-then-diff.
371
+ *
372
+ * Uses `arrayUnion` so the entry lands without a prior read. The FIFO cap
373
+ * therefore is NOT applied here — it is enforced on the next ordinary
374
+ * write. That is an acceptable trade: both batch paths are terminal
375
+ * transitions (cancelled, payout-requested) that fire at most once per
376
+ * order, so they cannot be what overflows the array.
330
377
  */
331
- cancelInBatch(batch: WriteBatch, ref: DocumentReference): void;
378
+ private batchHistoryPatch;
332
379
  }
333
380
  declare const orderRepository: OrderRepository;
334
381
  export { OrderRepository, orderRepository };
@@ -2,8 +2,9 @@ import { normalizeError } from "../../../errors/normalize";
2
2
  import { DatabaseError, NotFoundError } from "../../../errors";
3
3
  import { BaseRepository, prepareForFirestore, parseSieveDateValue, } from "../../../providers/db-firebase";
4
4
  import { decryptPiiFields, encryptPiiFields, ORDER_PII_FIELDS, } from "../../../security";
5
- import { serverTimestamp } from "../../../contracts/field-ops";
6
- import { createOrderId, ORDER_COLLECTION, OrderStatusValues, } from "../schemas";
5
+ import { serverTimestamp, arrayUnion } from "../../../contracts/field-ops";
6
+ import { createOrderId, ORDER_COLLECTION, ORDER_TRACKED_FIELDS, OrderStatusValues, } from "../schemas";
7
+ import { withHistory } from "../../../_internal/shared/history/index";
7
8
  import { MANUAL_PAYMENT_METHODS, PAYMENT_REVIEW_QUEUE_SCAN_LIMIT, } from "../constants/payment-window";
8
9
  import { ORDER_FIELDS } from "../../../constants/field-names";
9
10
  /**
@@ -65,12 +66,44 @@ class OrderRepository extends BaseRepository {
65
66
  async findPending() {
66
67
  return this.findBy(ORDER_FIELDS.STATUS, "pending");
67
68
  }
68
- async updateStatus(orderId, status, additionalData) {
69
- return this.update(orderId, {
70
- status,
71
- ...additionalData,
72
- updatedAt: new Date(),
69
+ /**
70
+ * Every write primitive below routes through this so `statusHistory` is
71
+ * appended at the SEVEN places a tracked field can change, rather than at
72
+ * the ~32 call sites above them. That is what makes order history a
73
+ * contained change instead of a codebase-wide sweep — and it follows the
74
+ * precedent `postRefundEvent` already set for append-only order data.
75
+ *
76
+ * `ctx` is optional throughout: a caller that has not been updated yet
77
+ * records `system` rather than failing, so this rolls out incrementally.
78
+ * The actor is worth passing wherever it is known — a history entry that
79
+ * cannot say who cancelled an order is a much weaker record.
80
+ */
81
+ async updateWithHistory(orderId, patch, ctx, defaultTrigger,
82
+ /**
83
+ * The already-fetched document, when the caller has one. Three of the six
84
+ * write primitives (`markPicked`, `markCodCollected`, `postRefundEvent`)
85
+ * read the order before patching it — passing it through avoids a second
86
+ * read of the same document on every one of those writes, which matters
87
+ * against the Firestore daily read budget (Rule #6).
88
+ */
89
+ known) {
90
+ const current = known !== undefined ? known : await this.findById(orderId);
91
+ const withEntry = withHistory(current, patch, {
92
+ tracked: ORDER_TRACKED_FIELDS,
93
+ actor: ctx?.actor ?? { role: "system" },
94
+ trigger: ctx?.trigger ?? defaultTrigger,
95
+ reason: ctx?.reason,
96
+ note: ctx?.note,
97
+ extraChanges: ctx?.extraChanges,
98
+ historyField: "statusHistory",
99
+ truncatedField: "statusHistoryTruncated",
73
100
  });
101
+ // `null` means no tracked field actually changed — write the patch as-is
102
+ // so an untracked update never grows the array.
103
+ return this.update(orderId, (withEntry ?? patch));
104
+ }
105
+ async updateStatus(orderId, status, additionalData, ctx) {
106
+ return this.updateWithHistory(orderId, { status, ...additionalData, updatedAt: new Date() }, ctx, "orderRepository.updateStatus");
74
107
  }
75
108
  async assignWorker(orderId, workerId) {
76
109
  return this.update(orderId, { assignedWorkerId: workerId, updatedAt: new Date() });
@@ -78,12 +111,12 @@ class OrderRepository extends BaseRepository {
78
111
  async unassignWorker(orderId) {
79
112
  return this.update(orderId, { assignedWorkerId: undefined, updatedAt: new Date() });
80
113
  }
81
- async markPicked(orderId) {
114
+ async markPicked(orderId, ctx) {
82
115
  const order = await this.findById(orderId);
83
116
  if (!order)
84
117
  throw new NotFoundError(`Order ${orderId} not found`);
85
118
  const nextStatus = order.status === "confirmed" ? "processing" : order.status;
86
- return this.update(orderId, { pickedAt: new Date(), status: nextStatus, updatedAt: new Date() });
119
+ return this.updateWithHistory(orderId, { pickedAt: new Date(), status: nextStatus, updatedAt: new Date() }, ctx, "orderRepository.markPicked", order);
87
120
  }
88
121
  async markPacked(orderId) {
89
122
  return this.update(orderId, { packedAt: new Date(), updatedAt: new Date() });
@@ -95,11 +128,11 @@ class OrderRepository extends BaseRepository {
95
128
  * verify against, so `verifiedBy` is the acting user's uid and
96
129
  * `verificationMethod` is always "cod_collection".
97
130
  */
98
- async markCodCollected(orderId, verifiedBy, note) {
131
+ async markCodCollected(orderId, verifiedBy, note, ctx) {
99
132
  const order = await this.findById(orderId);
100
133
  if (!order)
101
134
  throw new NotFoundError(`Order ${orderId} not found`);
102
- return this.update(orderId, {
135
+ return this.updateWithHistory(orderId, {
103
136
  paymentStatus: "paid",
104
137
  paymentRecord: {
105
138
  method: "cod",
@@ -110,7 +143,10 @@ class OrderRepository extends BaseRepository {
110
143
  verificationMethod: "cod_collection",
111
144
  },
112
145
  updatedAt: new Date(),
113
- });
146
+ },
147
+ // `verifiedBy` is the acting user — use it unless the caller supplied a
148
+ // richer actor. Cash collection is always a person, never the system.
149
+ ctx ?? { actor: { uid: verifiedBy, role: "seller" }, note }, "orderRepository.markCodCollected", order);
114
150
  }
115
151
  async findFulfillmentQueue(storeId) {
116
152
  const snap = await this.db
@@ -122,21 +158,25 @@ class OrderRepository extends BaseRepository {
122
158
  .get();
123
159
  return snap.docs.map((doc) => this.decryptOrder({ id: doc.id, ...doc.data() }));
124
160
  }
125
- async updatePaymentStatus(orderId, paymentStatus, paymentId) {
126
- return this.update(orderId, {
161
+ async updatePaymentStatus(orderId, paymentStatus, paymentId, ctx) {
162
+ return this.updateWithHistory(orderId, {
127
163
  paymentStatus,
128
164
  ...(paymentId ? { paymentId } : {}),
129
165
  updatedAt: new Date(),
130
- });
166
+ }, ctx, "orderRepository.updatePaymentStatus");
131
167
  }
132
- async cancelOrder(orderId, reason, refundAmount) {
133
- return this.update(orderId, {
168
+ async cancelOrder(orderId, reason, refundAmount, ctx) {
169
+ return this.updateWithHistory(orderId, {
134
170
  status: "cancelled",
135
171
  cancellationDate: new Date(),
136
172
  cancellationReason: reason,
137
173
  ...(refundAmount ? { refundAmount, refundStatus: "pending" } : {}),
138
174
  updatedAt: new Date(),
139
- });
175
+ },
176
+ // The cancellation reason is already a first-class argument here — carry
177
+ // it into the history entry so the timeline can say WHY, not just that
178
+ // it was cancelled.
179
+ { ...ctx, reason: ctx?.reason ?? reason }, "orderRepository.cancelOrder");
140
180
  }
141
181
  async findRecentByUser(userId) {
142
182
  const now = new Date();
@@ -251,17 +291,38 @@ class OrderRepository extends BaseRepository {
251
291
  * Append one refund event to the order and mark it non-contestable.
252
292
  * If `becomeRefunded` is true, also transitions the order status to "refunded".
253
293
  */
254
- async postRefundEvent(orderId, event, becomeRefunded = false) {
294
+ async postRefundEvent(orderId, event, becomeRefunded = false, ctx) {
255
295
  const order = await this.findById(orderId);
256
296
  if (!order)
257
297
  throw new NotFoundError(`Order ${orderId} not found`);
258
298
  const existing = order.refunds ?? [];
259
- return this.update(orderId, {
299
+ return this.updateWithHistory(orderId, {
260
300
  refunds: [...existing, event],
261
301
  contestable: false,
262
302
  ...(becomeRefunded ? { status: "refunded" } : {}),
263
303
  updatedAt: new Date(),
264
- });
304
+ }, {
305
+ ...ctx,
306
+ // The refund is contributed explicitly rather than diffed. A raw diff
307
+ // of `refunds[]` would say "an array of 1 became an array of 2" —
308
+ // true, and useless on a timeline. PARTIAL refunds matter as much as
309
+ // full ones here: a partial changes no tracked field at all, so
310
+ // without this it would leave no trace despite being exactly the kind
311
+ // of event a buyer later asks about.
312
+ extraChanges: {
313
+ refund: {
314
+ from: null,
315
+ to: {
316
+ refundId: event.refundId,
317
+ type: event.type,
318
+ amount: event.amount,
319
+ reason: event.reason,
320
+ },
321
+ },
322
+ },
323
+ actor: ctx?.actor ?? { uid: event.refundedBy, role: "admin" },
324
+ reason: ctx?.reason ?? event.reason,
325
+ }, "orderRepository.postRefundEvent", order);
265
326
  }
266
327
  /** Fetch all orders sharing a paymentBatchId (for sibling-orders display). */
267
328
  async findByPaymentBatchId(batchId) {
@@ -469,19 +530,52 @@ class OrderRepository extends BaseRepository {
469
530
  payoutStatus: "requested",
470
531
  payoutId,
471
532
  updatedAt: serverTimestamp(),
533
+ ...this.batchHistoryPatch({
534
+ changes: { payoutStatus: { from: "eligible", to: "requested" } },
535
+ trigger: "orderRepository.markPayoutRequested",
536
+ }),
472
537
  });
473
538
  }
474
539
  /**
475
540
  * Cloud Functions: stage a cancellation update into a caller-owned WriteBatch.
541
+ *
542
+ * `fromStatus` is supplied by the caller because a batch write does no read
543
+ * — but the sweep that calls this already filtered on a status, so it knows
544
+ * the value. Passing it beats recording `null` for something that is
545
+ * genuinely known one stack frame up.
476
546
  */
477
- cancelInBatch(batch, ref) {
547
+ cancelInBatch(batch, ref, fromStatus = null) {
478
548
  batch.update(ref, {
479
549
  status: OrderStatusValues.CANCELLED,
480
550
  cancellationDate: new Date(),
481
551
  cancellationReason: "payment_timeout",
482
552
  updatedAt: serverTimestamp(),
553
+ ...this.batchHistoryPatch({
554
+ changes: { status: { from: fromStatus, to: OrderStatusValues.CANCELLED } },
555
+ reason: "payment_timeout",
556
+ trigger: "orderRepository.cancelInBatch",
557
+ }),
483
558
  });
484
559
  }
560
+ /**
561
+ * History append for the two WriteBatch paths, which cannot read-then-diff.
562
+ *
563
+ * Uses `arrayUnion` so the entry lands without a prior read. The FIFO cap
564
+ * therefore is NOT applied here — it is enforced on the next ordinary
565
+ * write. That is an acceptable trade: both batch paths are terminal
566
+ * transitions (cancelled, payout-requested) that fire at most once per
567
+ * order, so they cannot be what overflows the array.
568
+ */
569
+ batchHistoryPatch(input) {
570
+ const entry = {
571
+ at: new Date(),
572
+ actorRole: "system",
573
+ changes: input.changes,
574
+ trigger: input.trigger,
575
+ ...(input.reason ? { reason: input.reason } : {}),
576
+ };
577
+ return { statusHistory: arrayUnion(entry) };
578
+ }
485
579
  }
486
580
  OrderRepository.SELLER_SIEVE_FIELDS = {
487
581
  id: { canFilter: true, canSort: false },
@@ -5,6 +5,59 @@ import type { OrderStatus, PaymentStatus } from "../types";
5
5
  import type { OrderType } from "../utils/order-splitter";
6
6
  import type { BaseDocument } from "../../../_internal/shared/types/base-document";
7
7
  import type { ListingType } from "../../products/types";
8
+ import type { StatusChangeEntry } from "../../../_internal/shared/history/index";
9
+ export interface OrderSourceStandard {
10
+ path: "standard";
11
+ listPrice: number;
12
+ }
13
+ export interface OrderSourceAuctionWon {
14
+ path: "auction-won";
15
+ auctionId: string;
16
+ bidId: string;
17
+ winningBidAmount: number;
18
+ /** Bids placed across the whole auction — the "against N bidders" figure. */
19
+ bidCount: number;
20
+ startingBid: number;
21
+ reservePrice?: number;
22
+ reserveMet: boolean;
23
+ auctionEndedAt: Date;
24
+ /** Second-highest bid, when there was one. */
25
+ runnerUpAmount?: number;
26
+ }
27
+ export interface OrderSourceAuctionBuyNow {
28
+ path: "auction-buy-now";
29
+ auctionId: string;
30
+ buyNowPrice: number;
31
+ listPrice: number;
32
+ boughtAt: Date;
33
+ }
34
+ export interface OrderSourceOfferAccepted {
35
+ path: "offer-accepted";
36
+ offerId: string;
37
+ offeredAmount: number;
38
+ /** The asking price at the moment the offer was made. */
39
+ listPriceAtOffer: number;
40
+ counterAmount?: number;
41
+ /** How many counter rounds before agreement. 0 = accepted outright. */
42
+ counterRounds: number;
43
+ acceptedBy: string;
44
+ acceptedAt: Date;
45
+ checkoutDeadline?: Date;
46
+ }
47
+ export interface OrderSourcePreOrder {
48
+ path: "pre-order";
49
+ depositAmount: number;
50
+ balanceDue: number;
51
+ expectedDeliveryDate?: Date;
52
+ }
53
+ export interface OrderSourcePrizeDraw {
54
+ path: "prize-draw";
55
+ prizeDrawProductId: string;
56
+ pricePerEntry: number;
57
+ entryCount: number;
58
+ revealMode: "instant" | "scheduled";
59
+ }
60
+ export type OrderSourceContext = OrderSourceStandard | OrderSourceAuctionWon | OrderSourceAuctionBuyNow | OrderSourceOfferAccepted | OrderSourcePreOrder | OrderSourcePrizeDraw;
8
61
  /** Manual shipping is the only supported method — sellers enter carrier + tracking directly, no carrier API integration. */
9
62
  export type ShippingMethod = "custom";
10
63
  export type RefundType = "full" | "partial";
@@ -150,6 +203,18 @@ export interface OrderDocument extends BaseDocument {
150
203
  storeName?: string;
151
204
  items?: OrderDocumentItem[];
152
205
  orderType?: OrderType;
206
+ /**
207
+ * True when this `orderType: "auction"` order came from Buy Now rather than
208
+ * from winning the bidding.
209
+ *
210
+ * Not a new `orderType` value on purpose — the /user/orders tabs key on
211
+ * `orderType`, and a buyout IS an auction order from the buyer's point of
212
+ * view. What it changes is the ADMIN review window: a buyout is settled in a
213
+ * one-hour scramble against a still-live auction, so `paymentReviewAutoApprove`
214
+ * gives an admin a full day to verify its proof instead of the usual couple of
215
+ * hours before auto-approving.
216
+ */
217
+ isBuyout?: boolean;
153
218
  imageUrls?: string[];
154
219
  quantity: number;
155
220
  unitPrice: number;
@@ -248,6 +313,37 @@ export interface OrderDocument extends BaseDocument {
248
313
  * orders are the source of truth for invoicing, refunds, and disputes.
249
314
  */
250
315
  paymentBatchId?: string;
316
+ /**
317
+ * Append-only delta log of every tracked-field change on this order —
318
+ * who, when, from what to what, and which function did it.
319
+ *
320
+ * DELTAS, never snapshots: only `statusHistory[0]` (the creation entry)
321
+ * carries a `snapshot`, holding the provenance that cannot be re-derived
322
+ * later because its sources move on — the discounts and add-ons actually
323
+ * applied and the fee breakdown at the moment of purchase.
324
+ *
325
+ * Capped at `STATUS_HISTORY_MAX` (FIFO). An unbounded array on a document
326
+ * this hot inflates every read of it (Rule #6).
327
+ */
328
+ statusHistory?: StatusChangeEntry[];
329
+ /**
330
+ * Entries dropped off the front of `statusHistory` over this order's
331
+ * lifetime. Present so the UI can say "earlier history trimmed" instead
332
+ * of implying the order simply had no earlier history.
333
+ */
334
+ statusHistoryTruncated?: number;
335
+ /**
336
+ * How the buyer acquired the right to buy, written ONCE at creation.
337
+ *
338
+ * A discriminated union rather than optional fields, because `orderType`
339
+ * cannot distinguish an auction that was WON from one that was BOUGHT OUT
340
+ * — both are `"auction"` — and `winningBidAmount`/`bidCount` are
341
+ * meaningless on a buy-now, where there are zero bids by definition.
342
+ *
343
+ * Never recomputed: a settled auction's numbers must not move when the
344
+ * auction document is later archived or the product is re-priced.
345
+ */
346
+ sourceContext?: OrderSourceContext;
251
347
  /**
252
348
  * Append-only log of refund events on this order. Multiple partial refund
253
349
  * events are allowed until the cumulative amount equals `totalPrice`.
@@ -384,6 +480,27 @@ export declare const ORDER_INDEXED_FIELDS: readonly ["userId", "productId", "sto
384
480
  export declare const DEFAULT_ORDER_DATA: Partial<OrderDocument>;
385
481
  export declare const ORDER_PUBLIC_FIELDS: readonly ["id", "productId", "productTitle", "quantity", "unitPrice", "totalPrice", "currency", "status", "paymentStatus", "shippingAddress", "trackingNumber", "notes", "orderDate", "shippingDate", "deliveryDate", "createdAt"];
386
482
  export declare const ORDER_UPDATABLE_FIELDS: readonly ["notes", "shippingAddress"];
483
+ /**
484
+ * The fields whose changes are recorded in `statusHistory`.
485
+ *
486
+ * Deliberately minimal — the timeline answers "where is my order and what
487
+ * happened to it", nothing else.
488
+ *
489
+ * **Money is NOT tracked here.** `appliedDiscounts`, `storeAddons` and the
490
+ * fee fields hold the FINAL state on the order document, and that is the
491
+ * record. Logging every intermediate coupon/add-on change would bury the five
492
+ * transitions anyone actually reads under pricing churn, and a coupon that
493
+ * was dropped before the order existed is not part of the order's history.
494
+ *
495
+ * **Acquisition is NOT tracked here either** — how the buyer got the right to
496
+ * buy (auction won, offer accepted, bought out) is written once to
497
+ * `sourceContext` at creation. It never changes, so it is not a timeline
498
+ * event.
499
+ *
500
+ * A whole-document diff would append an entry for every `updatedAt` bump —
501
+ * which is every single write — and exhaust the FIFO cap within days.
502
+ */
503
+ export declare const ORDER_TRACKED_FIELDS: readonly ["status", "paymentStatus", "paymentReviewOutcome", "trackingNumber", "cancellationReason"];
387
504
  export type OrderCreateInput = Omit<OrderDocument, "id" | "createdAt" | "updatedAt" | "orderDate">;
388
505
  export type OrderUpdateInput = Partial<Pick<OrderDocument, (typeof ORDER_UPDATABLE_FIELDS)[number]>>;
389
506
  export type OrderAdminUpdateInput = Partial<Omit<OrderDocument, "id" | "createdAt">>;
@@ -88,6 +88,36 @@ export const ORDER_PUBLIC_FIELDS = [
88
88
  "createdAt",
89
89
  ];
90
90
  export const ORDER_UPDATABLE_FIELDS = ["notes", "shippingAddress"];
91
+ /**
92
+ * The fields whose changes are recorded in `statusHistory`.
93
+ *
94
+ * Deliberately minimal — the timeline answers "where is my order and what
95
+ * happened to it", nothing else.
96
+ *
97
+ * **Money is NOT tracked here.** `appliedDiscounts`, `storeAddons` and the
98
+ * fee fields hold the FINAL state on the order document, and that is the
99
+ * record. Logging every intermediate coupon/add-on change would bury the five
100
+ * transitions anyone actually reads under pricing churn, and a coupon that
101
+ * was dropped before the order existed is not part of the order's history.
102
+ *
103
+ * **Acquisition is NOT tracked here either** — how the buyer got the right to
104
+ * buy (auction won, offer accepted, bought out) is written once to
105
+ * `sourceContext` at creation. It never changes, so it is not a timeline
106
+ * event.
107
+ *
108
+ * A whole-document diff would append an entry for every `updatedAt` bump —
109
+ * which is every single write — and exhaust the FIFO cap within days.
110
+ */
111
+ export const ORDER_TRACKED_FIELDS = [
112
+ "status",
113
+ "paymentStatus",
114
+ /** Manual-payment review: proof verified, re-upload requested, rejected. */
115
+ "paymentReviewOutcome",
116
+ /** The substance of the "shipped" transition. */
117
+ "trackingNumber",
118
+ /** Why it was cancelled — a bare "cancelled" is not a useful entry. */
119
+ "cancellationReason",
120
+ ];
91
121
  export const orderQueryHelpers = {
92
122
  byUser: (userId) => ["userId", "==", userId],
93
123
  byStore: (storeId) => ["storeId", "==", storeId],
@@ -562,14 +562,7 @@ export declare const orderFirestoreSchema: z.ZodObject<{
562
562
  platformFee?: number | undefined;
563
563
  paymentMethod?: string | undefined;
564
564
  notes?: string | undefined;
565
- storeName?: string | undefined;
566
565
  prizeRevealMode?: "scheduled" | "instant" | undefined;
567
- physicalLocation?: {
568
- zone: string;
569
- shelf: string;
570
- bin: string;
571
- } | undefined;
572
- payoutStatus?: "paid" | "eligible" | "requested" | undefined;
573
566
  paymentId?: string | undefined;
574
567
  shippingAddress?: string | undefined;
575
568
  trackingNumber?: string | undefined;
@@ -588,6 +581,7 @@ export declare const orderFirestoreSchema: z.ZodObject<{
588
581
  depositAmount?: number | undefined;
589
582
  codRemainingAmount?: number | undefined;
590
583
  shippingFee?: number | undefined;
584
+ payoutStatus?: "paid" | "eligible" | "requested" | undefined;
591
585
  payoutId?: string | undefined;
592
586
  shippingMethod?: "custom" | undefined;
593
587
  shippingCarrier?: string | undefined;
@@ -611,9 +605,13 @@ export declare const orderFirestoreSchema: z.ZodObject<{
611
605
  }, z.ZodTypeAny, "passthrough">;
612
606
  } | undefined;
613
607
  prizeDrawProductId?: string | undefined;
608
+ storeName?: string | undefined;
614
609
  couponCode?: string | undefined;
615
- emiEnabled?: boolean | undefined;
616
- emiTenureMonths?: number | undefined;
610
+ physicalLocation?: {
611
+ zone: string;
612
+ shelf: string;
613
+ bin: string;
614
+ } | undefined;
617
615
  orderType?: string | undefined;
618
616
  imageUrls?: string[] | undefined;
619
617
  refundFeeDeducted?: number | undefined;
@@ -629,6 +627,8 @@ export declare const orderFirestoreSchema: z.ZodObject<{
629
627
  couponId?: string | undefined;
630
628
  }[] | undefined;
631
629
  codHandlingFee?: number | undefined;
630
+ emiEnabled?: boolean | undefined;
631
+ emiTenureMonths?: number | undefined;
632
632
  emiTokenAmount?: number | undefined;
633
633
  emiSurchargeAmount?: number | undefined;
634
634
  emiInstallments?: {
@@ -710,14 +710,7 @@ export declare const orderFirestoreSchema: z.ZodObject<{
710
710
  platformFee?: number | undefined;
711
711
  paymentMethod?: string | undefined;
712
712
  notes?: string | undefined;
713
- storeName?: string | undefined;
714
713
  prizeRevealMode?: "scheduled" | "instant" | undefined;
715
- physicalLocation?: {
716
- zone: string;
717
- shelf: string;
718
- bin: string;
719
- } | undefined;
720
- payoutStatus?: "paid" | "eligible" | "requested" | undefined;
721
714
  paymentId?: string | undefined;
722
715
  shippingAddress?: string | undefined;
723
716
  trackingNumber?: string | undefined;
@@ -736,6 +729,7 @@ export declare const orderFirestoreSchema: z.ZodObject<{
736
729
  depositAmount?: number | undefined;
737
730
  codRemainingAmount?: number | undefined;
738
731
  shippingFee?: number | undefined;
732
+ payoutStatus?: "paid" | "eligible" | "requested" | undefined;
739
733
  payoutId?: string | undefined;
740
734
  shippingMethod?: "custom" | undefined;
741
735
  shippingCarrier?: string | undefined;
@@ -759,9 +753,13 @@ export declare const orderFirestoreSchema: z.ZodObject<{
759
753
  }, z.ZodTypeAny, "passthrough">;
760
754
  } | undefined;
761
755
  prizeDrawProductId?: string | undefined;
756
+ storeName?: string | undefined;
762
757
  couponCode?: string | undefined;
763
- emiEnabled?: boolean | undefined;
764
- emiTenureMonths?: number | undefined;
758
+ physicalLocation?: {
759
+ zone: string;
760
+ shelf: string;
761
+ bin: string;
762
+ } | undefined;
765
763
  orderType?: string | undefined;
766
764
  imageUrls?: string[] | undefined;
767
765
  refundFeeDeducted?: number | undefined;
@@ -777,6 +775,8 @@ export declare const orderFirestoreSchema: z.ZodObject<{
777
775
  couponId?: string | undefined;
778
776
  }[] | undefined;
779
777
  codHandlingFee?: number | undefined;
778
+ emiEnabled?: boolean | undefined;
779
+ emiTenureMonths?: number | undefined;
780
780
  emiTokenAmount?: number | undefined;
781
781
  emiSurchargeAmount?: number | undefined;
782
782
  emiInstallments?: {