@mohasinac/appkit 3.8.2 → 3.9.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 (479) hide show
  1. package/dist/_internal/client/features/live/LiveItemDetailView.js +2 -2
  2. package/dist/_internal/client/features/lottery/LotteryAdminEditView.d.ts +4 -4
  3. package/dist/_internal/client/features/lottery/LotteryAdminEditView.js +8 -8
  4. package/dist/_internal/client/features/lottery/LotteryAdminSlotView.d.ts +1 -1
  5. package/dist/_internal/client/features/lottery/LotteryAdminSlotView.js +2 -2
  6. package/dist/_internal/server/features/bundles/actions.js +2 -2
  7. package/dist/_internal/server/features/bundles/og.d.ts +1 -1
  8. package/dist/_internal/server/features/bundles/og.js +4 -5
  9. package/dist/_internal/server/features/checkout/actions.js +57 -21
  10. package/dist/_internal/server/features/checkout/stock-restore.d.ts +19 -0
  11. package/dist/_internal/server/features/checkout/stock-restore.js +80 -0
  12. package/dist/_internal/server/features/checkout/upi-resolution.d.ts +11 -0
  13. package/dist/_internal/server/features/checkout/upi-resolution.js +28 -0
  14. package/dist/_internal/server/features/classified/og.js +1 -1
  15. package/dist/_internal/server/features/digital-code/og.js +1 -1
  16. package/dist/_internal/server/features/item-requests/og.d.ts +2 -2
  17. package/dist/_internal/server/features/item-requests/og.js +4 -5
  18. package/dist/_internal/server/features/live/og.js +1 -1
  19. package/dist/_internal/server/features/lottery/adapters.d.ts +2 -2
  20. package/dist/_internal/server/features/lottery/adapters.js +1 -1
  21. package/dist/_internal/server/features/orders/actions.d.ts +28 -0
  22. package/dist/_internal/server/features/orders/actions.js +239 -4
  23. package/dist/_internal/server/features/orders/adapters.js +3 -0
  24. package/dist/_internal/server/features/payments/data.js +3 -2
  25. package/dist/_internal/server/features/payouts/actions.d.ts +2 -2
  26. package/dist/_internal/server/features/payouts/actions.js +4 -3
  27. package/dist/_internal/server/features/pre-orders/service.d.ts +1 -1
  28. package/dist/_internal/server/features/pre-orders/service.js +3 -2
  29. package/dist/_internal/server/features/prize-draws/og.js +5 -5
  30. package/dist/_internal/server/features/products/og.js +1 -1
  31. package/dist/_internal/server/features/promotions/service.js +3 -1
  32. package/dist/_internal/server/features/refunds/actions.d.ts +2 -2
  33. package/dist/_internal/server/features/refunds/actions.js +7 -6
  34. package/dist/_internal/server/functions/firestore.js +1 -1
  35. package/dist/_internal/server/functions/scheduled.d.ts +4 -1
  36. package/dist/_internal/server/functions/scheduled.js +26 -2
  37. package/dist/_internal/server/jobs/core/emiInstallmentReminder.js +1 -1
  38. package/dist/_internal/server/jobs/core/hardBanCascade.d.ts +4 -0
  39. package/dist/_internal/server/jobs/core/hardBanCascade.js +15 -4
  40. package/dist/_internal/server/jobs/core/hardBanReinstatement.d.ts +16 -0
  41. package/dist/_internal/server/jobs/core/hardBanReinstatement.js +63 -0
  42. package/dist/_internal/server/jobs/core/jobRunners.js +3 -1
  43. package/dist/_internal/server/jobs/core/onScamReportCreate.js +1 -1
  44. package/dist/_internal/server/jobs/core/paymentReviewAutoApprove.d.ts +10 -0
  45. package/dist/_internal/server/jobs/core/paymentReviewAutoApprove.js +60 -0
  46. package/dist/_internal/server/jobs/core/paymentWindowTimeout.d.ts +15 -0
  47. package/dist/_internal/server/jobs/core/paymentWindowTimeout.js +59 -0
  48. package/dist/_internal/server/jobs/core/pendingOrderTimeout.d.ts +7 -0
  49. package/dist/_internal/server/jobs/core/pendingOrderTimeout.js +32 -6
  50. package/dist/_internal/server/jobs/handlers/hardBanReinstatement.d.ts +2 -0
  51. package/dist/_internal/server/jobs/handlers/hardBanReinstatement.js +2 -0
  52. package/dist/_internal/server/jobs/handlers/index.d.ts +3 -0
  53. package/dist/_internal/server/jobs/handlers/index.js +3 -0
  54. package/dist/_internal/server/jobs/handlers/messages.d.ts +4 -0
  55. package/dist/_internal/server/jobs/handlers/messages.js +4 -0
  56. package/dist/_internal/server/jobs/handlers/onShipmentAllocationSync.d.ts +3 -3
  57. package/dist/_internal/server/jobs/handlers/onShipmentAllocationSync.js +12 -12
  58. package/dist/_internal/server/jobs/handlers/onShipmentItemWrite.d.ts +1 -1
  59. package/dist/_internal/server/jobs/handlers/onShipmentItemWrite.js +5 -5
  60. package/dist/_internal/server/jobs/handlers/paymentReviewAutoApprove.d.ts +2 -0
  61. package/dist/_internal/server/jobs/handlers/paymentReviewAutoApprove.js +2 -0
  62. package/dist/_internal/server/jobs/handlers/paymentWindowTimeout.d.ts +2 -0
  63. package/dist/_internal/server/jobs/handlers/paymentWindowTimeout.js +2 -0
  64. package/dist/_internal/shared/actions/action-registry.js +27 -0
  65. package/dist/_internal/shared/checkout/order-math.js +3 -2
  66. package/dist/_internal/shared/checkout/rules/_defaults.js +1 -0
  67. package/dist/_internal/shared/checkout/rules/preorder.rule.js +7 -0
  68. package/dist/_internal/shared/checkout/rules/prize-draw.rule.js +7 -0
  69. package/dist/_internal/shared/checkout/rules/types.d.ts +11 -0
  70. package/dist/_internal/shared/features/auctions/errors.js +1 -1
  71. package/dist/_internal/shared/features/categories/bundle-copy.d.ts +0 -1
  72. package/dist/_internal/shared/features/categories/bundle-copy.js +0 -1
  73. package/dist/_internal/shared/features/categories/bundle-schemas.d.ts +6 -6
  74. package/dist/_internal/shared/features/categories/bundle-schemas.js +2 -2
  75. package/dist/_internal/shared/features/checkout/config.d.ts +3 -3
  76. package/dist/_internal/shared/features/checkout/config.js +3 -3
  77. package/dist/_internal/shared/features/emi/schedule.d.ts +6 -6
  78. package/dist/_internal/shared/features/emi/schedule.js +10 -9
  79. package/dist/_internal/shared/features/promotions/errors.js +1 -1
  80. package/dist/_internal/shared/fees/calculator.d.ts +5 -5
  81. package/dist/_internal/shared/fees/calculator.js +19 -19
  82. package/dist/client.d.ts +1 -1
  83. package/dist/client.js +1 -1
  84. package/dist/constants/api-endpoints.d.ts +9 -0
  85. package/dist/constants/api-endpoints.js +3 -0
  86. package/dist/constants/field-names.d.ts +4 -0
  87. package/dist/constants/field-names.js +4 -0
  88. package/dist/features/admin/components/AdminArtView.js +2 -2
  89. package/dist/features/admin/components/AdminBidsView.js +2 -2
  90. package/dist/features/admin/components/AdminBundleEditorView.d.ts +1 -1
  91. package/dist/features/admin/components/AdminBundleEditorView.js +8 -8
  92. package/dist/features/admin/components/AdminBundlesView.js +6 -6
  93. package/dist/features/admin/components/AdminClassifiedView.js +2 -2
  94. package/dist/features/admin/components/AdminDigitalCodesView.js +2 -2
  95. package/dist/features/admin/components/AdminLiveView.js +2 -2
  96. package/dist/features/admin/components/AdminOrderEditorView.d.ts +6 -1
  97. package/dist/features/admin/components/AdminOrderEditorView.js +45 -5
  98. package/dist/features/admin/components/AdminOrdersView.js +8 -3
  99. package/dist/features/admin/components/AdminPayoutsView.js +2 -2
  100. package/dist/features/admin/components/AdminPrizeDrawsView.js +2 -2
  101. package/dist/features/admin/components/AdminReturnRequestsView.js +2 -2
  102. package/dist/features/admin/components/AdminSiteSettingsView.js +11 -11
  103. package/dist/features/admin/components/AdminStickersView.js +2 -2
  104. package/dist/features/admin/components/AdminSupportTicketDetailView.js +1 -1
  105. package/dist/features/admin/hooks/useAdminListingData.d.ts +1 -1
  106. package/dist/features/admin/hooks/useAdminListingData.js +3 -2
  107. package/dist/features/admin/schemas/firestore.d.ts +9 -7
  108. package/dist/features/admin/schemas/firestore.js +4 -3
  109. package/dist/features/auctions/components/AuctionBidsTable.js +3 -3
  110. package/dist/features/auth/checkout-value-otp.d.ts +46 -0
  111. package/dist/features/auth/checkout-value-otp.js +73 -0
  112. package/dist/features/auth/repository/user.repository.d.ts +6 -0
  113. package/dist/features/auth/repository/user.repository.js +19 -0
  114. package/dist/features/auth/schemas/firestore.d.ts +10 -0
  115. package/dist/features/auth/schemas/firestore.js +2 -0
  116. package/dist/features/cart/actions/cart-actions.d.ts +1 -1
  117. package/dist/features/cart/actions/cart-actions.js +4 -4
  118. package/dist/features/cart/components/CartView.d.ts +2 -2
  119. package/dist/features/cart/components/ShippingPicker.d.ts +4 -4
  120. package/dist/features/cart/components/ShippingPicker.js +11 -11
  121. package/dist/features/cart/repository/cart.repository.d.ts +1 -1
  122. package/dist/features/cart/repository/cart.repository.js +2 -2
  123. package/dist/features/cart/schemas/firestore.d.ts +2 -2
  124. package/dist/features/catalogue/components/CatalogueItemEditorView.js +3 -3
  125. package/dist/features/catalogue/components/PublicCatalogueView.js +2 -2
  126. package/dist/features/catalogue/schemas/validation.js +1 -1
  127. package/dist/features/categories/components/BundleCollage.js +2 -2
  128. package/dist/features/categories/components/BundleDetailView.js +2 -2
  129. package/dist/features/categories/components/BundleItemsPicker.d.ts +1 -1
  130. package/dist/features/categories/components/BundleItemsPicker.js +2 -2
  131. package/dist/features/categories/components/CategoryBundlesListing.js +2 -2
  132. package/dist/features/categories/schemas/firestore.d.ts +1 -1
  133. package/dist/features/categories/schemas/index.d.ts +3 -3
  134. package/dist/features/categories/schemas/index.js +2 -2
  135. package/dist/features/checkout/actions/checkout-value-otp-actions.d.ts +16 -0
  136. package/dist/features/checkout/actions/checkout-value-otp-actions.js +83 -0
  137. package/dist/features/checkout/actions/index.d.ts +1 -0
  138. package/dist/features/checkout/actions/index.js +1 -0
  139. package/dist/features/checkout/schemas/firestore.d.ts +1 -1
  140. package/dist/features/classified/components/index.d.ts +0 -4
  141. package/dist/features/classified/components/index.js +0 -2
  142. package/dist/features/digital-codes/components/index.d.ts +0 -4
  143. package/dist/features/digital-codes/components/index.js +0 -2
  144. package/dist/features/events/schemas/index.d.ts +1 -1
  145. package/dist/features/events/schemas/index.js +1 -1
  146. package/dist/features/homepage/components/FeaturedBundlesSection.js +2 -2
  147. package/dist/features/live/components/index.d.ts +0 -4
  148. package/dist/features/live/components/index.js +0 -2
  149. package/dist/features/lottery/types/index.d.ts +3 -3
  150. package/dist/features/lottery/types/index.js +5 -5
  151. package/dist/features/orders/components/OrderPaymentSummary.js +2 -2
  152. package/dist/features/orders/components/OrderSiblingPayments.js +1 -1
  153. package/dist/features/orders/components/RefundHistoryTable.js +1 -1
  154. package/dist/features/orders/components/RefundRequestView.js +1 -1
  155. package/dist/features/orders/constants/payment-window.d.ts +10 -0
  156. package/dist/features/orders/constants/payment-window.js +10 -0
  157. package/dist/features/orders/repository/orders.repository.d.ts +25 -0
  158. package/dist/features/orders/repository/orders.repository.js +50 -1
  159. package/dist/features/orders/schemas/firestore.d.ts +50 -2
  160. package/dist/features/orders/schemas/index.d.ts +24 -24
  161. package/dist/features/orders/schemas/index.js +20 -20
  162. package/dist/features/orders/types/index.d.ts +4 -0
  163. package/dist/features/orders/utils/bundle-grouping.d.ts +1 -1
  164. package/dist/features/orders/utils/bundle-grouping.js +1 -1
  165. package/dist/features/payments/schemas/index.d.ts +10 -10
  166. package/dist/features/payments/schemas/index.js +9 -9
  167. package/dist/features/pre-orders/components/PreOrderDetailPageView.js +2 -2
  168. package/dist/features/products/components/ArtStickersListView.d.ts +7 -0
  169. package/dist/features/products/components/ArtStickersListView.js +57 -0
  170. package/dist/features/products/components/GroupSettingsPanel.js +1 -1
  171. package/dist/features/products/components/MakeOfferButton.js +3 -3
  172. package/dist/features/products/components/MarketplaceBundleCard.d.ts +1 -1
  173. package/dist/features/products/components/MarketplaceBundleCard.js +2 -2
  174. package/dist/features/products/components/PrizeDrawCollage.js +2 -2
  175. package/dist/features/products/components/PrizeDrawItemsEditor.js +2 -2
  176. package/dist/features/products/components/PrizeRevealModal.js +1 -1
  177. package/dist/features/products/components/ProductDetailPageView.js +2 -9
  178. package/dist/features/products/components/ProductForm.js +2 -2
  179. package/dist/features/products/components/ProductGrid.js +2 -2
  180. package/dist/features/products/components/ProductsIndexListing.d.ts +13 -1
  181. package/dist/features/products/components/ProductsIndexListing.js +7 -5
  182. package/dist/features/products/components/ProductsIndexPageView.js +6 -1
  183. package/dist/features/products/constants/listing-tabs.d.ts +42 -17
  184. package/dist/features/products/constants/listing-tabs.js +25 -6
  185. package/dist/features/products/schemas/catalog-product.d.ts +5 -5
  186. package/dist/features/products/schemas/catalog-product.js +1 -1
  187. package/dist/features/products/schemas/firestore.d.ts +5 -5
  188. package/dist/features/products/schemas/firestore.js +2 -2
  189. package/dist/features/products/types/index.d.ts +5 -2
  190. package/dist/features/promotions/components/CouponCard.js +2 -2
  191. package/dist/features/promotions/schemas/firestore.d.ts +2 -0
  192. package/dist/features/promotions/schemas/firestore.js +1 -0
  193. package/dist/features/promotions/schemas/index.d.ts +14 -14
  194. package/dist/features/promotions/schemas/index.js +6 -6
  195. package/dist/features/scams/components/ScamProfileView.js +3 -7
  196. package/dist/features/scams/components/ScamRegistryView.js +2 -6
  197. package/dist/features/scams/schemas/firestore.d.ts +1 -1
  198. package/dist/features/search/components/Search.d.ts +1 -1
  199. package/dist/features/seller/actions/offer-actions.js +1 -1
  200. package/dist/features/seller/components/PrintCenterView.js +2 -2
  201. package/dist/features/seller/components/QuickProductForm.js +5 -5
  202. package/dist/features/seller/components/SellerArtView.js +2 -2
  203. package/dist/features/seller/components/SellerAuctionsView.js +2 -2
  204. package/dist/features/seller/components/SellerBidsView.js +2 -2
  205. package/dist/features/seller/components/SellerBundlesView.js +6 -6
  206. package/dist/features/seller/components/SellerClassifiedView.js +2 -2
  207. package/dist/features/seller/components/SellerDigitalCodesView.js +2 -2
  208. package/dist/features/seller/components/SellerLiveView.js +2 -2
  209. package/dist/features/seller/components/SellerOffersView.js +2 -2
  210. package/dist/features/seller/components/SellerOrdersView.js +3 -3
  211. package/dist/features/seller/components/SellerPayoutRequestView.js +2 -2
  212. package/dist/features/seller/components/SellerPayoutSettingsView.js +2 -2
  213. package/dist/features/seller/components/SellerPayoutsView.js +2 -2
  214. package/dist/features/seller/components/SellerPreOrdersView.js +2 -2
  215. package/dist/features/seller/components/SellerPrizeDrawsView.js +2 -2
  216. package/dist/features/seller/components/SellerProductShell.js +8 -8
  217. package/dist/features/seller/components/SellerProductsView.js +1 -1
  218. package/dist/features/seller/components/SellerShippingView.js +6 -6
  219. package/dist/features/seller/components/SellerStickersView.js +2 -2
  220. package/dist/features/seller/hooks/useSellerListingData.d.ts +1 -1
  221. package/dist/features/seller/hooks/useSellerListingData.js +3 -2
  222. package/dist/features/shipments/components/AdminShipmentEditorView.js +10 -10
  223. package/dist/features/shipments/components/AdminShipmentLotItemsView.js +4 -4
  224. package/dist/features/shipments/components/AdminShipmentProjectionsView.js +5 -5
  225. package/dist/features/shipments/components/AdminShipmentsView.js +4 -4
  226. package/dist/features/shipments/repository/shipment-lots.repository.d.ts +2 -2
  227. package/dist/features/shipments/repository/shipment-lots.repository.js +8 -8
  228. package/dist/features/shipments/schemas/firestore.d.ts +21 -21
  229. package/dist/features/shipments/schemas/firestore.js +9 -9
  230. package/dist/features/shipments/schemas/validation.d.ts +30 -30
  231. package/dist/features/shipments/schemas/validation.js +6 -6
  232. package/dist/features/shipments/utils/cost-allocation.d.ts +5 -5
  233. package/dist/features/shipments/utils/cost-allocation.js +39 -38
  234. package/dist/features/store-extensions/schemas/firestore.d.ts +5 -5
  235. package/dist/features/stores/components/StoreDetailLayoutView.js +9 -13
  236. package/dist/features/stores/schemas/firestore.d.ts +7 -7
  237. package/dist/features/stores/schemas/index.d.ts +84 -84
  238. package/dist/features/stores/schemas/index.js +5 -5
  239. package/dist/features/tester/seed-data/categories-tester-seed-data.js +1 -1
  240. package/dist/features/tester/seed-data/products-tester-seed-data.js +6 -6
  241. package/dist/features/tester/seed-data/tester-checklist-seed-data.js +9 -2
  242. package/dist/features/whatsapp-bot/helpers/whatsapp.d.ts +8 -1
  243. package/dist/features/whatsapp-bot/helpers/whatsapp.js +13 -2
  244. package/dist/features/whatsapp-bot/types/index.d.ts +9 -1
  245. package/dist/index.d.ts +3 -7
  246. package/dist/index.js +7 -5
  247. package/dist/next/routing/route-map.d.ts +2 -0
  248. package/dist/next/routing/route-map.js +6 -0
  249. package/dist/schemas/firestore-helpers.d.ts +2 -2
  250. package/dist/schemas/firestore-helpers.js +2 -2
  251. package/dist/schemas/registry.d.ts +73 -73
  252. package/dist/seed/bids-seed-data.js +6 -6
  253. package/dist/seed/blog-posts-seed-data.js +1 -0
  254. package/dist/seed/cart-seed-data.js +13 -13
  255. package/dist/seed/catalogue-seed-data.js +6 -6
  256. package/dist/seed/categories-seed-data.js +5 -5
  257. package/dist/seed/claimed-coupons-seed-data.js +3 -3
  258. package/dist/seed/coupons-seed-data.js +20 -20
  259. package/dist/seed/events-seed-data.js +27 -27
  260. package/dist/seed/factories/bid.factory.js +1 -1
  261. package/dist/seed/faq-seed-data.js +20 -1
  262. package/dist/seed/grouped-listings-seed-data.d.ts +2 -2
  263. package/dist/seed/grouped-listings-seed-data.js +3 -3
  264. package/dist/seed/offers-seed-data.js +19 -19
  265. package/dist/seed/orders-seed-data.js +29 -29
  266. package/dist/seed/payouts-seed-data.js +7 -7
  267. package/dist/seed/products-auctions-seed-data.js +6 -6
  268. package/dist/seed/products-preorders-seed-data.d.ts +2 -2
  269. package/dist/seed/products-preorders-seed-data.js +1 -1
  270. package/dist/seed/products-standard-seed-data.js +8 -8
  271. package/dist/seed/scammers-seed-data.js +2 -2
  272. package/dist/seed/shipments-seed-data.js +29 -29
  273. package/dist/seed/site-settings-seed-data.js +3 -2
  274. package/dist/seed/store-extensions-seed-data.js +8 -8
  275. package/dist/seed/stores-seed-data.js +37 -8
  276. package/dist/seed/users-seed-data.js +38 -1
  277. package/dist/server-entry.d.ts +1 -3
  278. package/dist/server-entry.js +1 -3
  279. package/dist/server.d.ts +2 -1
  280. package/dist/server.js +3 -1
  281. package/dist/ui/components/PriceDisplay.js +3 -12
  282. package/dist/utils/number.formatter.d.ts +2 -7
  283. package/dist/utils/number.formatter.js +3 -8
  284. package/package.json +1 -1
  285. package/scripts/seed-cli.mjs +8 -3
  286. package/dist/_internal/client/scaffolds/DashboardScaffold.d.ts +0 -34
  287. package/dist/_internal/client/scaffolds/DashboardScaffold.js +0 -26
  288. package/dist/_internal/client/theme/__tests__/ThemeProvider.test.d.ts +0 -1
  289. package/dist/_internal/client/theme/__tests__/ThemeProvider.test.js +0 -109
  290. package/dist/_internal/server/features/auctions/__tests__/service.test.d.ts +0 -1
  291. package/dist/_internal/server/features/auctions/__tests__/service.test.js +0 -140
  292. package/dist/_internal/server/features/checkout/__tests__/actions.test.d.ts +0 -1
  293. package/dist/_internal/server/features/checkout/__tests__/actions.test.js +0 -600
  294. package/dist/_internal/server/features/refunds/__tests__/actions.test.d.ts +0 -1
  295. package/dist/_internal/server/features/refunds/__tests__/actions.test.js +0 -263
  296. package/dist/_internal/server/jobs/core/__tests__/auctionSettlement.test.d.ts +0 -1
  297. package/dist/_internal/server/jobs/core/__tests__/auctionSettlement.test.js +0 -249
  298. package/dist/_internal/server/jobs/core/__tests__/couponExpiry.test.d.ts +0 -1
  299. package/dist/_internal/server/jobs/core/__tests__/couponExpiry.test.js +0 -65
  300. package/dist/_internal/server/jobs/core/__tests__/listingProcessor.test.d.ts +0 -1
  301. package/dist/_internal/server/jobs/core/__tests__/listingProcessor.test.js +0 -163
  302. package/dist/_internal/server/jobs/core/__tests__/mediaTmpCleanup.test.d.ts +0 -1
  303. package/dist/_internal/server/jobs/core/__tests__/mediaTmpCleanup.test.js +0 -115
  304. package/dist/_internal/server/jobs/core/__tests__/onBidPlaced.test.d.ts +0 -1
  305. package/dist/_internal/server/jobs/core/__tests__/onBidPlaced.test.js +0 -201
  306. package/dist/_internal/server/jobs/core/__tests__/onOrderCreate.test.d.ts +0 -1
  307. package/dist/_internal/server/jobs/core/__tests__/onOrderCreate.test.js +0 -169
  308. package/dist/_internal/server/jobs/core/__tests__/onOrderStatusChange.test.d.ts +0 -1
  309. package/dist/_internal/server/jobs/core/__tests__/onOrderStatusChange.test.js +0 -148
  310. package/dist/_internal/server/jobs/core/__tests__/onProductStockChange.test.d.ts +0 -1
  311. package/dist/_internal/server/jobs/core/__tests__/onProductStockChange.test.js +0 -210
  312. package/dist/_internal/server/jobs/core/__tests__/onReviewWrite.test.d.ts +0 -1
  313. package/dist/_internal/server/jobs/core/__tests__/onReviewWrite.test.js +0 -190
  314. package/dist/_internal/server/jobs/core/__tests__/onUserBanChange.test.d.ts +0 -1
  315. package/dist/_internal/server/jobs/core/__tests__/onUserBanChange.test.js +0 -161
  316. package/dist/_internal/server/jobs/core/__tests__/payoutBatch.test.d.ts +0 -1
  317. package/dist/_internal/server/jobs/core/__tests__/payoutBatch.test.js +0 -302
  318. package/dist/_internal/server/jobs/core/__tests__/pendingOrderTimeout.test.d.ts +0 -1
  319. package/dist/_internal/server/jobs/core/__tests__/pendingOrderTimeout.test.js +0 -96
  320. package/dist/_internal/server/jobs/core/__tests__/triggerEventRaffle.test.d.ts +0 -1
  321. package/dist/_internal/server/jobs/core/__tests__/triggerEventRaffle.test.js +0 -252
  322. package/dist/_internal/server/jobs/core/__tests__/wrapJobHandler.test.d.ts +0 -1
  323. package/dist/_internal/server/jobs/core/__tests__/wrapJobHandler.test.js +0 -129
  324. package/dist/_internal/server/jobs/core/onCatalogueSubmittedForApproval.d.ts +0 -15
  325. package/dist/_internal/server/jobs/core/onCatalogueSubmittedForApproval.js +0 -38
  326. package/dist/_internal/server/providers/index.d.ts +0 -11
  327. package/dist/_internal/server/providers/index.js +0 -11
  328. package/dist/_internal/server/providers/payment/razorpay-mock.d.ts +0 -52
  329. package/dist/_internal/server/providers/payment/razorpay-mock.js +0 -118
  330. package/dist/_internal/server/providers/resolve.d.ts +0 -36
  331. package/dist/_internal/server/providers/resolve.js +0 -31
  332. package/dist/_internal/server/providers/shipping/shiprocket-mock.d.ts +0 -29
  333. package/dist/_internal/server/providers/shipping/shiprocket-mock.js +0 -152
  334. package/dist/_internal/shared/types/__tests__/action-result.test.d.ts +0 -1
  335. package/dist/_internal/shared/types/__tests__/action-result.test.js +0 -65
  336. package/dist/errors/__tests__/error-mapping.test.d.ts +0 -1
  337. package/dist/errors/__tests__/error-mapping.test.js +0 -122
  338. package/dist/errors/__tests__/safe-read.test.d.ts +0 -1
  339. package/dist/errors/__tests__/safe-read.test.js +0 -39
  340. package/dist/features/addresses/repository/__tests__/addresses.repository.test.d.ts +0 -1
  341. package/dist/features/addresses/repository/__tests__/addresses.repository.test.js +0 -386
  342. package/dist/features/admin/components/AdminListingScaffold.d.ts +0 -41
  343. package/dist/features/admin/components/AdminListingScaffold.js +0 -68
  344. package/dist/features/admin/components/QuickActionsPanel.d.ts +0 -15
  345. package/dist/features/admin/components/QuickActionsPanel.js +0 -5
  346. package/dist/features/admin/repository/__tests__/notification.repository.test.d.ts +0 -1
  347. package/dist/features/admin/repository/__tests__/notification.repository.test.js +0 -356
  348. package/dist/features/admin/repository/__tests__/site-settings.repository.test.d.ts +0 -1
  349. package/dist/features/admin/repository/__tests__/site-settings.repository.test.js +0 -298
  350. package/dist/features/auctions/repository/__tests__/bid.repository.test.d.ts +0 -1
  351. package/dist/features/auctions/repository/__tests__/bid.repository.test.js +0 -290
  352. package/dist/features/auctions/repository/auctions.repository.d.ts +0 -12
  353. package/dist/features/auctions/repository/auctions.repository.js +0 -42
  354. package/dist/features/auth/repository/__tests__/session.repository.test.d.ts +0 -1
  355. package/dist/features/auth/repository/__tests__/session.repository.test.js +0 -310
  356. package/dist/features/auth/repository/__tests__/session.test.d.ts +0 -1
  357. package/dist/features/auth/repository/__tests__/session.test.js +0 -146
  358. package/dist/features/auth/repository/__tests__/sms-counter.repository.test.d.ts +0 -1
  359. package/dist/features/auth/repository/__tests__/sms-counter.repository.test.js +0 -171
  360. package/dist/features/auth/repository/__tests__/sms-counter.test.d.ts +0 -1
  361. package/dist/features/auth/repository/__tests__/sms-counter.test.js +0 -88
  362. package/dist/features/auth/repository/__tests__/token.repository.test.d.ts +0 -1
  363. package/dist/features/auth/repository/__tests__/token.repository.test.js +0 -260
  364. package/dist/features/auth/repository/__tests__/token.test.d.ts +0 -1
  365. package/dist/features/auth/repository/__tests__/token.test.js +0 -140
  366. package/dist/features/auth/repository/__tests__/user.repository.test.d.ts +0 -1
  367. package/dist/features/auth/repository/__tests__/user.repository.test.js +0 -352
  368. package/dist/features/auth/repository/__tests__/user.test.d.ts +0 -1
  369. package/dist/features/auth/repository/__tests__/user.test.js +0 -226
  370. package/dist/features/before-after/repository/before-after.repository.d.ts +0 -13
  371. package/dist/features/before-after/repository/before-after.repository.js +0 -36
  372. package/dist/features/before-after/server.d.ts +0 -6
  373. package/dist/features/before-after/server.js +0 -6
  374. package/dist/features/cart/repository/__tests__/cart.repository.test.d.ts +0 -1
  375. package/dist/features/cart/repository/__tests__/cart.repository.test.js +0 -371
  376. package/dist/features/categories/repository/__tests__/categories.repository.test.d.ts +0 -1
  377. package/dist/features/categories/repository/__tests__/categories.repository.test.js +0 -813
  378. package/dist/features/collections/repository/collections.repository.d.ts +0 -8
  379. package/dist/features/collections/repository/collections.repository.js +0 -16
  380. package/dist/features/collections/server.d.ts +0 -6
  381. package/dist/features/collections/server.js +0 -6
  382. package/dist/features/events/repository/__tests__/event.repository.test.d.ts +0 -1
  383. package/dist/features/events/repository/__tests__/event.repository.test.js +0 -299
  384. package/dist/features/faq/repository/__tests__/faqs.repository.test.d.ts +0 -1
  385. package/dist/features/faq/repository/__tests__/faqs.repository.test.js +0 -311
  386. package/dist/features/forms/Form.d.ts +0 -25
  387. package/dist/features/forms/Form.js +0 -37
  388. package/dist/features/history/repository/__tests__/user-history.repository.test.d.ts +0 -1
  389. package/dist/features/history/repository/__tests__/user-history.repository.test.js +0 -180
  390. package/dist/features/homepage/repository/__tests__/carousel.repository.test.d.ts +0 -1
  391. package/dist/features/homepage/repository/__tests__/carousel.repository.test.js +0 -182
  392. package/dist/features/homepage/repository/__tests__/homepage-sections.repository.test.d.ts +0 -1
  393. package/dist/features/homepage/repository/__tests__/homepage-sections.repository.test.js +0 -185
  394. package/dist/features/layout/ListingLayout.d.ts +0 -34
  395. package/dist/features/layout/ListingLayout.js +0 -103
  396. package/dist/features/messages/repository/__tests__/conversations.repository.test.d.ts +0 -1
  397. package/dist/features/messages/repository/__tests__/conversations.repository.test.js +0 -257
  398. package/dist/features/orders/repository/__tests__/orders.repository.test.d.ts +0 -1
  399. package/dist/features/orders/repository/__tests__/orders.repository.test.js +0 -211
  400. package/dist/features/payments/repository/__tests__/payout.repository.test.d.ts +0 -1
  401. package/dist/features/payments/repository/__tests__/payout.repository.test.js +0 -292
  402. package/dist/features/pre-orders/repository/preorders.repository.d.ts +0 -8
  403. package/dist/features/pre-orders/repository/preorders.repository.js +0 -25
  404. package/dist/features/products/repository/__tests__/product-features.repository.test.d.ts +0 -1
  405. package/dist/features/products/repository/__tests__/product-features.repository.test.js +0 -329
  406. package/dist/features/products/repository/__tests__/products.repository.test.d.ts +0 -1
  407. package/dist/features/products/repository/__tests__/products.repository.test.js +0 -607
  408. package/dist/features/promotions/repository/__tests__/claimed-coupons.repository.test.d.ts +0 -1
  409. package/dist/features/promotions/repository/__tests__/claimed-coupons.repository.test.js +0 -219
  410. package/dist/features/promotions/repository/__tests__/coupons.repository.test.d.ts +0 -1
  411. package/dist/features/promotions/repository/__tests__/coupons.repository.test.js +0 -480
  412. package/dist/features/promotions/repository/promotions.repository.d.ts +0 -14
  413. package/dist/features/promotions/repository/promotions.repository.js +0 -43
  414. package/dist/features/reviews/repository/__tests__/reviews.repository.test.d.ts +0 -1
  415. package/dist/features/reviews/repository/__tests__/reviews.repository.test.js +0 -327
  416. package/dist/features/scams/repository/__tests__/scammer.repository.test.d.ts +0 -1
  417. package/dist/features/scams/repository/__tests__/scammer.repository.test.js +0 -385
  418. package/dist/features/search/repository/__tests__/search.repository.test.d.ts +0 -1
  419. package/dist/features/search/repository/__tests__/search.repository.test.js +0 -369
  420. package/dist/features/seller/components/SellerStatCard.d.ts +0 -14
  421. package/dist/features/seller/components/SellerStatCard.js +0 -6
  422. package/dist/features/seller/components/seller-products-styles.d.ts +0 -7
  423. package/dist/features/seller/components/seller-products-styles.js +0 -14
  424. package/dist/features/seller/repository/__tests__/offer.repository.test.d.ts +0 -1
  425. package/dist/features/seller/repository/__tests__/offer.repository.test.js +0 -458
  426. package/dist/features/seller/repository/seller.repository.d.ts +0 -22
  427. package/dist/features/seller/repository/seller.repository.js +0 -72
  428. package/dist/features/site-settings/components/__tests__/ThemeManagerView.test.d.ts +0 -1
  429. package/dist/features/site-settings/components/__tests__/ThemeManagerView.test.js +0 -37
  430. package/dist/features/stores/repository/__tests__/store.repository.test.d.ts +0 -1
  431. package/dist/features/stores/repository/__tests__/store.repository.test.js +0 -261
  432. package/dist/features/stores/repository/stores.repository.d.ts +0 -11
  433. package/dist/features/stores/repository/stores.repository.js +0 -37
  434. package/dist/features/support/repository/__tests__/support.repository.test.d.ts +0 -1
  435. package/dist/features/support/repository/__tests__/support.repository.test.js +0 -312
  436. package/dist/features/wishlist/repository/__tests__/user-wishlist.repository.test.d.ts +0 -1
  437. package/dist/features/wishlist/repository/__tests__/user-wishlist.repository.test.js +0 -139
  438. package/dist/features/wishlist/repository/wishlist.repository.d.ts +0 -13
  439. package/dist/features/wishlist/repository/wishlist.repository.js +0 -31
  440. package/dist/providers/db-firebase/__tests__/filter-aliases.test.d.ts +0 -1
  441. package/dist/providers/db-firebase/__tests__/filter-aliases.test.js +0 -93
  442. package/dist/providers/shipping-shiprocket/index.d.ts +0 -297
  443. package/dist/providers/shipping-shiprocket/index.js +0 -194
  444. package/dist/providers/shipping-shiprocket/shiprocket-provider.d.ts +0 -45
  445. package/dist/providers/shipping-shiprocket/shiprocket-provider.js +0 -168
  446. package/dist/react/contexts/ThemeContext.d.ts +0 -13
  447. package/dist/react/contexts/ThemeContext.js +0 -64
  448. package/dist/schemas/webhooks/shiprocket.d.ts +0 -30
  449. package/dist/schemas/webhooks/shiprocket.js +0 -22
  450. package/dist/seed/actions/demo-seed-actions.d.ts +0 -42
  451. package/dist/seed/actions/demo-seed-actions.js +0 -36
  452. package/dist/seed/actions/index.d.ts +0 -1
  453. package/dist/seed/actions/index.js +0 -1
  454. package/dist/seed/sub-listings-seed-data.d.ts +0 -123
  455. package/dist/seed/sub-listings-seed-data.js +0 -447
  456. package/dist/seed/tester-checklist-seed-data.d.ts +0 -2
  457. package/dist/seed/tester-checklist-seed-data.js +0 -248
  458. package/dist/ui/components/DashboardStatsCard.d.ts +0 -15
  459. package/dist/ui/components/DashboardStatsCard.js +0 -27
  460. package/dist/ui/components/DashboardStatsCard.style.css +0 -68
  461. package/dist/ui/components/DynamicSelect.d.ts +0 -23
  462. package/dist/ui/components/DynamicSelect.js +0 -77
  463. package/dist/ui/components/DynamicSelect.style.css +0 -101
  464. package/dist/ui/components/InlineCreateSelect.d.ts +0 -48
  465. package/dist/ui/components/InlineCreateSelect.js +0 -75
  466. package/dist/ui/components/ListingViewShell.d.ts +0 -37
  467. package/dist/ui/components/ListingViewShell.js +0 -9
  468. package/dist/ui/components/PaginatedMultiSelect.d.ts +0 -28
  469. package/dist/ui/components/PaginatedMultiSelect.js +0 -141
  470. package/dist/ui/components/PaginatedMultiSelect.style.css +0 -272
  471. package/dist/ui/components/SectionTabs.d.ts +0 -19
  472. package/dist/ui/components/SectionTabs.js +0 -66
  473. package/dist/ui/components/SectionTabs.style.css +0 -164
  474. package/dist/ui/components/__tests__/BulkActionBar.test.d.ts +0 -1
  475. package/dist/ui/components/__tests__/BulkActionBar.test.js +0 -96
  476. package/dist/ui/components/__tests__/ListingToolbar.test.d.ts +0 -1
  477. package/dist/ui/components/__tests__/ListingToolbar.test.js +0 -125
  478. package/dist/ui/components/__tests__/new-primitives.test.d.ts +0 -1
  479. package/dist/ui/components/__tests__/new-primitives.test.js +0 -187
@@ -1,263 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- // vi.hoisted: these must be declared before vi.mock factories reference them
3
- const { mockOrderFindById, mockPostRefundEvent, mockPaymentRefund, mockApplyRefundDeduction, mockCodesGet, } = vi.hoisted(() => {
4
- const mockCodesQuery = {
5
- where: vi.fn(),
6
- limit: vi.fn(),
7
- get: vi.fn(),
8
- };
9
- mockCodesQuery.where.mockReturnValue(mockCodesQuery);
10
- mockCodesQuery.limit.mockReturnValue(mockCodesQuery);
11
- return {
12
- mockOrderFindById: vi.fn(),
13
- mockPostRefundEvent: vi.fn(),
14
- mockPaymentRefund: vi.fn(),
15
- mockApplyRefundDeduction: vi.fn(),
16
- mockCodesGet: mockCodesQuery.get,
17
- _mockCodesQuery: mockCodesQuery,
18
- };
19
- });
20
- // Mock appkit/server BEFORE other imports to avoid loading broken dist/client.js
21
- vi.mock("@mohasinac/appkit/server", () => ({
22
- wrapAction: async (fn) => {
23
- try {
24
- const data = await fn();
25
- return { ok: true, data };
26
- }
27
- catch (err) {
28
- const msg = err instanceof Error ? err.message : String(err);
29
- return { ok: false, error: msg };
30
- }
31
- },
32
- isSoftBanned: vi.fn(() => false),
33
- }));
34
- vi.mock("../../../../../", () => ({
35
- orderRepository: {
36
- findById: mockOrderFindById,
37
- postRefundEvent: mockPostRefundEvent,
38
- },
39
- }));
40
- vi.mock("../../../../../contracts/registry", () => ({
41
- getProviders: vi.fn(() => ({
42
- payment: { refund: mockPaymentRefund },
43
- })),
44
- }));
45
- // Mock the firebase-admin sub-module that provides getAdminDb
46
- // Chain: db.collection(PRODUCTS).doc(productId).collection(CODES).where("orderId","==",orderId).limit(1).get()
47
- vi.mock("../../../../../providers/db-firebase/admin", () => {
48
- const mockCodesQuery = { where: vi.fn(), limit: vi.fn(), get: mockCodesGet };
49
- mockCodesQuery.where.mockReturnValue(mockCodesQuery);
50
- mockCodesQuery.limit.mockReturnValue(mockCodesQuery);
51
- const mockCodesCollection = { where: vi.fn() };
52
- mockCodesCollection.where.mockReturnValue(mockCodesQuery);
53
- const mockDoc = { collection: vi.fn(() => mockCodesCollection) };
54
- const mockTopCollection = { doc: vi.fn(() => mockDoc) };
55
- const mockDb = { collection: vi.fn(() => mockTopCollection) };
56
- return { getAdminDb: () => mockDb, getAdminAuth: vi.fn(), getAdminStorage: vi.fn() };
57
- });
58
- vi.mock("../../payouts/actions", () => ({
59
- applyRefundDeductionAction: mockApplyRefundDeduction,
60
- }));
61
- vi.mock("../../../../../errors/normalize", () => ({ normalizeError: vi.fn() }));
62
- vi.mock("../../../../../monitoring", () => ({
63
- serverLogger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() },
64
- }));
65
- import { processRefundAction } from "../actions";
66
- // ─── Helpers ────────────────────────────────────────────────────────────────
67
- function makeOrder(overrides = {}) {
68
- return {
69
- id: "order-1",
70
- storeId: "store-A",
71
- totalPrice: 10000,
72
- paymentMethod: "razorpay",
73
- paymentId: "pay_abc123",
74
- isNonRefundable: false,
75
- items: [],
76
- ...overrides,
77
- };
78
- }
79
- function refundInput(overrides = {}) {
80
- return {
81
- orderId: "order-1",
82
- type: "partial",
83
- amountInPaise: 5000,
84
- reason: "damaged item",
85
- confirmIrrevocable: true,
86
- refundedBy: "admin-uid",
87
- method: "manual",
88
- ...overrides,
89
- };
90
- }
91
- beforeEach(() => {
92
- vi.clearAllMocks();
93
- mockOrderFindById.mockResolvedValue(makeOrder());
94
- mockPostRefundEvent.mockResolvedValue(undefined);
95
- mockPaymentRefund.mockResolvedValue({ id: "rfnd_123" });
96
- mockApplyRefundDeduction.mockResolvedValue(undefined);
97
- mockCodesGet.mockResolvedValue({ empty: true, docs: [] });
98
- });
99
- // ─── Tests ──────────────────────────────────────────────────────────────────
100
- describe("processRefundAction — validation guards", () => {
101
- it("order not found → ok: false", async () => {
102
- mockOrderFindById.mockResolvedValue(null);
103
- const result = await processRefundAction(refundInput());
104
- expect(result.ok).toBe(false);
105
- expect(result.error).toMatch(/not found/i);
106
- });
107
- it("amount <= 0 → ok: false (validation)", async () => {
108
- const result = await processRefundAction(refundInput({ amountInPaise: 0 }));
109
- expect(result.ok).toBe(false);
110
- });
111
- it("negative amount → ok: false (validation)", async () => {
112
- const result = await processRefundAction(refundInput({ amountInPaise: -100 }));
113
- expect(result.ok).toBe(false);
114
- });
115
- it("amount > order.totalPrice → ok: false", async () => {
116
- const result = await processRefundAction(refundInput({ amountInPaise: 10001 }));
117
- expect(result.ok).toBe(false);
118
- expect(result.error).toMatch(/exceeds/i);
119
- });
120
- it("amount === order.totalPrice → ok: true (full refund, not exceeds)", async () => {
121
- const result = await processRefundAction(refundInput({ amountInPaise: 10000 }));
122
- expect(result.ok).toBe(true);
123
- });
124
- it("isNonRefundable: true → ok: false", async () => {
125
- mockOrderFindById.mockResolvedValue(makeOrder({ isNonRefundable: true }));
126
- const result = await processRefundAction(refundInput());
127
- expect(result.ok).toBe(false);
128
- expect(result.error).toMatch(/non-refundable/i);
129
- });
130
- });
131
- describe("processRefundAction — digital code guard", () => {
132
- it("digital code already claimed → ok: false", async () => {
133
- mockOrderFindById.mockResolvedValue(makeOrder({
134
- items: [{ productId: "digital-prod-1", listingType: "digital-code" }],
135
- }));
136
- mockCodesGet.mockResolvedValue({
137
- empty: false,
138
- docs: [{ data: () => ({ status: "claimed" }) }],
139
- });
140
- const result = await processRefundAction(refundInput());
141
- expect(result.ok).toBe(false);
142
- expect(result.error).toMatch(/digital code|revealed/i);
143
- });
144
- it("digital code with status 'available' → refund allowed", async () => {
145
- mockOrderFindById.mockResolvedValue(makeOrder({
146
- items: [{ productId: "digital-prod-1", listingType: "digital-code" }],
147
- }));
148
- mockCodesGet.mockResolvedValue({
149
- empty: false,
150
- docs: [{ data: () => ({ status: "available" }) }],
151
- });
152
- const result = await processRefundAction(refundInput());
153
- expect(result.ok).toBe(true);
154
- });
155
- it("no digital code items → digital code check is skipped", async () => {
156
- mockOrderFindById.mockResolvedValue(makeOrder({ items: [] }));
157
- const result = await processRefundAction(refundInput());
158
- expect(result.ok).toBe(true);
159
- expect(mockCodesGet).not.toHaveBeenCalled();
160
- });
161
- it("digital code collection query returns empty → refund allowed", async () => {
162
- mockOrderFindById.mockResolvedValue(makeOrder({
163
- items: [{ productId: "digital-prod-1", listingType: "digital-code" }],
164
- }));
165
- mockCodesGet.mockResolvedValue({ empty: true, docs: [] });
166
- const result = await processRefundAction(refundInput());
167
- expect(result.ok).toBe(true);
168
- });
169
- });
170
- describe("processRefundAction — Razorpay path", () => {
171
- it("calls payment.refund with correct paymentId and amount", async () => {
172
- const result = await processRefundAction(refundInput({
173
- method: "razorpay",
174
- razorpayPaymentId: "pay_abc123",
175
- amountInPaise: 5000,
176
- }));
177
- expect(result.ok).toBe(true);
178
- expect(mockPaymentRefund).toHaveBeenCalledWith("pay_abc123", 5000);
179
- });
180
- it("Razorpay refund API failure → ok: false, postRefundEvent NOT called", async () => {
181
- mockPaymentRefund.mockRejectedValue(new Error("Razorpay API error"));
182
- const result = await processRefundAction(refundInput({
183
- method: "razorpay",
184
- razorpayPaymentId: "pay_abc123",
185
- }));
186
- expect(result.ok).toBe(false);
187
- expect(mockPostRefundEvent).not.toHaveBeenCalled();
188
- });
189
- it("razorpayRefundId from provider is stored in event", async () => {
190
- mockPaymentRefund.mockResolvedValue({ id: "rfnd_xyz789" });
191
- await processRefundAction(refundInput({
192
- method: "razorpay",
193
- razorpayPaymentId: "pay_abc123",
194
- }));
195
- expect(mockPostRefundEvent).toHaveBeenCalledWith("order-1", expect.objectContaining({ razorpayRefundId: "rfnd_xyz789" }), expect.any(Boolean));
196
- });
197
- });
198
- describe("processRefundAction — manual path", () => {
199
- it("does NOT call payment.refund for manual refunds", async () => {
200
- await processRefundAction(refundInput({ method: "manual" }));
201
- expect(mockPaymentRefund).not.toHaveBeenCalled();
202
- });
203
- it("calls postRefundEvent without razorpayRefundId", async () => {
204
- await processRefundAction(refundInput({ method: "manual" }));
205
- const event = mockPostRefundEvent.mock.calls[0][1];
206
- expect(event.razorpayRefundId).toBeUndefined();
207
- });
208
- it("stores manualTransactionId when provided", async () => {
209
- await processRefundAction(refundInput({ method: "manual", manualTransactionId: "TXN123" }));
210
- const event = mockPostRefundEvent.mock.calls[0][1];
211
- expect(event.manualTransactionId).toBe("TXN123");
212
- });
213
- });
214
- describe("processRefundAction — success path", () => {
215
- it("calls orderRepository.postRefundEvent with correct orderId", async () => {
216
- await processRefundAction(refundInput());
217
- expect(mockPostRefundEvent).toHaveBeenCalledWith("order-1", expect.any(Object), expect.any(Boolean));
218
- });
219
- it("partial amount: isFull = false passed to postRefundEvent", async () => {
220
- await processRefundAction(refundInput({ amountInPaise: 5000 }));
221
- const isFull = mockPostRefundEvent.mock.calls[0][2];
222
- expect(isFull).toBe(false);
223
- });
224
- it("full amount: isFull = true passed to postRefundEvent", async () => {
225
- await processRefundAction(refundInput({ amountInPaise: 10000 }));
226
- const isFull = mockPostRefundEvent.mock.calls[0][2];
227
- expect(isFull).toBe(true);
228
- });
229
- it("returns ok: true with success: true and a refundId UUID", async () => {
230
- const result = await processRefundAction(refundInput());
231
- expect(result.ok).toBe(true);
232
- const data = result.data;
233
- expect(data.success).toBe(true);
234
- expect(data.refundId).toMatch(/^[0-9a-f-]{36}$/i);
235
- });
236
- it("event contains reason, refundedBy, and refundedAt", async () => {
237
- await processRefundAction(refundInput({ reason: "broken product", refundedBy: "admin-1" }));
238
- const event = mockPostRefundEvent.mock.calls[0][1];
239
- expect(event.reason).toBe("broken product");
240
- expect(event.refundedBy).toBe("admin-1");
241
- expect(event.refundedAt).toBeInstanceOf(Date);
242
- });
243
- });
244
- describe("processRefundAction — payout deduction", () => {
245
- it("triggers applyRefundDeductionAction when order has storeId", async () => {
246
- await processRefundAction(refundInput({ amountInPaise: 5000 }));
247
- expect(mockApplyRefundDeduction).toHaveBeenCalledWith(expect.objectContaining({
248
- storeId: "store-A",
249
- orderId: "order-1",
250
- refundedAmountInPaise: 5000,
251
- }));
252
- });
253
- it("does NOT call applyRefundDeductionAction when order has no storeId", async () => {
254
- mockOrderFindById.mockResolvedValue(makeOrder({ storeId: undefined }));
255
- await processRefundAction(refundInput());
256
- expect(mockApplyRefundDeduction).not.toHaveBeenCalled();
257
- });
258
- it("deduction failure does NOT fail the refund (fire-and-forget)", async () => {
259
- mockApplyRefundDeduction.mockRejectedValue(new Error("Payout service unavailable"));
260
- const result = await processRefundAction(refundInput());
261
- expect(result.ok).toBe(true);
262
- });
263
- });
@@ -1,249 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- const { mockGetExpiredAuctions, mockGetActiveByProduct, mockUpdateStatusInBatch, mockMarkWon, mockMarkLost, mockCreateFromAuction, mockBatchUpdate, mockBatchCommit, mockSendNotification, } = vi.hoisted(() => ({
3
- mockGetExpiredAuctions: vi.fn(),
4
- mockGetActiveByProduct: vi.fn(),
5
- mockUpdateStatusInBatch: vi.fn(),
6
- mockMarkWon: vi.fn(),
7
- mockMarkLost: vi.fn(),
8
- mockCreateFromAuction: vi.fn(),
9
- mockBatchUpdate: vi.fn(),
10
- mockBatchCommit: vi.fn().mockResolvedValue(undefined),
11
- mockSendNotification: vi.fn().mockResolvedValue(undefined),
12
- }));
13
- vi.mock("../../../../../repositories", () => ({
14
- productRepository: {
15
- getExpiredAuctions: mockGetExpiredAuctions,
16
- updateStatusInBatch: mockUpdateStatusInBatch,
17
- },
18
- bidRepository: {
19
- getActiveByProduct: mockGetActiveByProduct,
20
- markWon: mockMarkWon,
21
- markLost: mockMarkLost,
22
- },
23
- orderRepository: {
24
- createFromAuction: mockCreateFromAuction,
25
- },
26
- }));
27
- vi.mock("../../../../../features/admin/actions/notification-actions", () => ({
28
- sendNotification: mockSendNotification,
29
- }));
30
- import { runAuctionSettlement } from "../auctionSettlement";
31
- // ── Helpers ─────────────────────────────────────────────────────────────────
32
- function makeCtx(overrides = {}) {
33
- const mockDoc = vi.fn().mockReturnValue({ id: "products/auction-1" });
34
- const mockCollection = vi.fn().mockReturnValue({ doc: mockDoc });
35
- const batch = {
36
- update: mockBatchUpdate,
37
- commit: mockBatchCommit,
38
- set: vi.fn(),
39
- delete: vi.fn(),
40
- };
41
- return {
42
- db: {
43
- collection: mockCollection,
44
- batch: vi.fn().mockReturnValue(batch),
45
- },
46
- now: new Date(),
47
- logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },
48
- ...overrides,
49
- };
50
- }
51
- function makeAuction(overrides = {}) {
52
- return {
53
- id: "auction-pokemon-charizard",
54
- title: "Pokemon Charizard",
55
- storeId: "store-A",
56
- listingType: "auction",
57
- availableQuantity: 1,
58
- ...overrides,
59
- };
60
- }
61
- function makeBid(overrides = {}) {
62
- return {
63
- ref: { id: "bid-ref-1" },
64
- data: {
65
- userId: "user-ravi",
66
- userName: "Ravi Kumar",
67
- userEmail: "ravi@example.com",
68
- bidAmount: 25000,
69
- currency: "INR",
70
- ...overrides,
71
- },
72
- };
73
- }
74
- beforeEach(() => {
75
- vi.clearAllMocks();
76
- mockBatchCommit.mockResolvedValue(undefined);
77
- mockSendNotification.mockResolvedValue(undefined);
78
- mockCreateFromAuction.mockReturnValue({ id: "order-1" });
79
- });
80
- describe("runAuctionSettlement — no expired auctions", () => {
81
- it("returns early when no expired auctions exist", async () => {
82
- mockGetExpiredAuctions.mockResolvedValue([]);
83
- const ctx = makeCtx();
84
- await runAuctionSettlement(ctx);
85
- expect(mockGetActiveByProduct).not.toHaveBeenCalled();
86
- });
87
- it("logs 'No expired auctions found' when list is empty", async () => {
88
- mockGetExpiredAuctions.mockResolvedValue([]);
89
- const ctx = makeCtx();
90
- await runAuctionSettlement(ctx);
91
- expect(ctx.logger.info).toHaveBeenCalledWith(expect.stringMatching(/No expired auctions/i));
92
- });
93
- });
94
- describe("runAuctionSettlement — auction with no bids", () => {
95
- it("archives product when no active bids", async () => {
96
- const auction = makeAuction();
97
- mockGetExpiredAuctions.mockResolvedValue([{ data: auction }]);
98
- mockGetActiveByProduct.mockResolvedValue([]);
99
- const ctx = makeCtx();
100
- await runAuctionSettlement(ctx);
101
- expect(mockUpdateStatusInBatch).toHaveBeenCalledWith(expect.any(Object), // batch
102
- auction.id, "archived");
103
- expect(mockBatchCommit).toHaveBeenCalled();
104
- });
105
- it("does NOT call createFromAuction when no bids", async () => {
106
- mockGetExpiredAuctions.mockResolvedValue([{ data: makeAuction() }]);
107
- mockGetActiveByProduct.mockResolvedValue([]);
108
- await runAuctionSettlement(makeCtx());
109
- expect(mockCreateFromAuction).not.toHaveBeenCalled();
110
- });
111
- it("does NOT send win/loss notifications when no bids", async () => {
112
- mockGetExpiredAuctions.mockResolvedValue([{ data: makeAuction() }]);
113
- mockGetActiveByProduct.mockResolvedValue([]);
114
- await runAuctionSettlement(makeCtx());
115
- expect(mockSendNotification).not.toHaveBeenCalled();
116
- });
117
- });
118
- describe("runAuctionSettlement — auction with bids", () => {
119
- it("marks the highest bid as won", async () => {
120
- const winner = makeBid({ bidAmount: 30000 });
121
- const loser = makeBid({ bidAmount: 20000, userId: "user-ankit" });
122
- mockGetExpiredAuctions.mockResolvedValue([{ data: makeAuction() }]);
123
- mockGetActiveByProduct.mockResolvedValue([winner, loser]);
124
- await runAuctionSettlement(makeCtx());
125
- expect(mockMarkWon).toHaveBeenCalledWith(expect.any(Object), winner.ref);
126
- });
127
- it("marks all other bids as lost", async () => {
128
- const winner = makeBid({ bidAmount: 30000 });
129
- const loser1 = makeBid({ userId: "user-ankit", bidAmount: 20000 });
130
- const loser2 = makeBid({ userId: "user-priya", bidAmount: 15000 });
131
- mockGetExpiredAuctions.mockResolvedValue([{ data: makeAuction() }]);
132
- mockGetActiveByProduct.mockResolvedValue([winner, loser1, loser2]);
133
- await runAuctionSettlement(makeCtx());
134
- expect(mockMarkLost).toHaveBeenCalledTimes(2);
135
- expect(mockMarkLost).toHaveBeenCalledWith(expect.any(Object), loser1.ref);
136
- expect(mockMarkLost).toHaveBeenCalledWith(expect.any(Object), loser2.ref);
137
- });
138
- it("creates an order from auction data (winner becomes buyer)", async () => {
139
- const winner = makeBid({ bidAmount: 25000, userId: "user-ravi" });
140
- const auction = makeAuction({ id: "auction-1", title: "Charizard", storeId: "store-B" });
141
- mockGetExpiredAuctions.mockResolvedValue([{ data: auction }]);
142
- mockGetActiveByProduct.mockResolvedValue([winner]);
143
- await runAuctionSettlement(makeCtx());
144
- expect(mockCreateFromAuction).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({
145
- productId: "auction-1",
146
- productTitle: "Charizard",
147
- userId: "user-ravi",
148
- storeId: "store-B",
149
- amount: 25000,
150
- }));
151
- });
152
- it("sets isSold=true and availableQuantity=0 on product", async () => {
153
- const winner = makeBid();
154
- mockGetExpiredAuctions.mockResolvedValue([{ data: makeAuction() }]);
155
- mockGetActiveByProduct.mockResolvedValue([winner]);
156
- await runAuctionSettlement(makeCtx());
157
- expect(mockBatchUpdate).toHaveBeenCalledWith(expect.any(Object), // doc ref
158
- expect.objectContaining({ isSold: true, availableQuantity: 0 }));
159
- });
160
- it("commits the batch before sending notifications", async () => {
161
- const winner = makeBid();
162
- mockGetExpiredAuctions.mockResolvedValue([{ data: makeAuction() }]);
163
- mockGetActiveByProduct.mockResolvedValue([winner]);
164
- const callOrder = [];
165
- mockBatchCommit.mockImplementation(async () => { callOrder.push("commit"); });
166
- mockSendNotification.mockImplementation(async () => { callOrder.push("notify"); });
167
- await runAuctionSettlement(makeCtx());
168
- const commitIdx = callOrder.indexOf("commit");
169
- const notifyIdx = callOrder.indexOf("notify");
170
- expect(commitIdx).toBeLessThan(notifyIdx);
171
- });
172
- it("sends bid_won notification to the winning bidder", async () => {
173
- const winner = makeBid({ userId: "user-ravi", bidAmount: 25000, currency: "INR" });
174
- mockGetExpiredAuctions.mockResolvedValue([{ data: makeAuction({ title: "Charizard" }) }]);
175
- mockGetActiveByProduct.mockResolvedValue([winner]);
176
- await runAuctionSettlement(makeCtx());
177
- expect(mockSendNotification).toHaveBeenCalledWith(expect.objectContaining({ userId: "user-ravi", type: "bid_won" }));
178
- });
179
- it("sends bid_lost notification to each losing bidder", async () => {
180
- const winner = makeBid({ userId: "user-ravi" });
181
- const loser1 = makeBid({ userId: "user-ankit" });
182
- const loser2 = makeBid({ userId: "user-priya" });
183
- mockGetExpiredAuctions.mockResolvedValue([{ data: makeAuction() }]);
184
- mockGetActiveByProduct.mockResolvedValue([winner, loser1, loser2]);
185
- await runAuctionSettlement(makeCtx());
186
- expect(mockSendNotification).toHaveBeenCalledWith(expect.objectContaining({ userId: "user-ankit", type: "bid_lost" }));
187
- expect(mockSendNotification).toHaveBeenCalledWith(expect.objectContaining({ userId: "user-priya", type: "bid_lost" }));
188
- });
189
- it("notification failure for one loser does NOT abort others (allSettled)", async () => {
190
- const winner = makeBid({ userId: "user-ravi" });
191
- const loser1 = makeBid({ userId: "user-ankit" });
192
- const loser2 = makeBid({ userId: "user-priya" });
193
- mockGetExpiredAuctions.mockResolvedValue([{ data: makeAuction() }]);
194
- mockGetActiveByProduct.mockResolvedValue([winner, loser1, loser2]);
195
- let callCount = 0;
196
- mockSendNotification.mockImplementation(async ({ type, userId }) => {
197
- callCount++;
198
- if (type === "bid_lost" && userId === "user-ankit") {
199
- throw new Error("Notification service down");
200
- }
201
- });
202
- // Should not throw
203
- await expect(runAuctionSettlement(makeCtx())).resolves.toBeUndefined();
204
- // loser2 still got notified
205
- expect(callCount).toBeGreaterThanOrEqual(2);
206
- });
207
- });
208
- describe("runAuctionSettlement — multiple expired auctions", () => {
209
- it("settles each auction independently", async () => {
210
- const auction1 = makeAuction({ id: "auction-1" });
211
- const auction2 = makeAuction({ id: "auction-2" });
212
- mockGetExpiredAuctions.mockResolvedValue([
213
- { data: auction1 },
214
- { data: auction2 },
215
- ]);
216
- mockGetActiveByProduct.mockResolvedValue([]);
217
- await runAuctionSettlement(makeCtx());
218
- expect(mockGetActiveByProduct).toHaveBeenCalledTimes(2);
219
- expect(mockGetActiveByProduct).toHaveBeenCalledWith("auction-1");
220
- expect(mockGetActiveByProduct).toHaveBeenCalledWith("auction-2");
221
- });
222
- it("one auction error does NOT abort others (allSettled)", async () => {
223
- const auction1 = makeAuction({ id: "auction-1" });
224
- const auction2 = makeAuction({ id: "auction-2" });
225
- mockGetExpiredAuctions.mockResolvedValue([
226
- { data: auction1 },
227
- { data: auction2 },
228
- ]);
229
- // auction-1 throws, auction-2 succeeds
230
- mockGetActiveByProduct
231
- .mockRejectedValueOnce(new Error("Firestore query failed"))
232
- .mockResolvedValueOnce([]);
233
- await expect(runAuctionSettlement(makeCtx())).resolves.toBeUndefined();
234
- // auction-2 was still processed (batch committed)
235
- expect(mockBatchCommit).toHaveBeenCalledTimes(1);
236
- });
237
- it("logs the count of failed settlements when some fail", async () => {
238
- mockGetExpiredAuctions.mockResolvedValue([
239
- { data: makeAuction({ id: "auction-1" }) },
240
- { data: makeAuction({ id: "auction-2" }) },
241
- ]);
242
- mockGetActiveByProduct
243
- .mockRejectedValueOnce(new Error("DB error"))
244
- .mockResolvedValueOnce([]);
245
- const ctx = makeCtx();
246
- await runAuctionSettlement(ctx);
247
- expect(ctx.logger.error).toHaveBeenCalledWith(expect.stringMatching(/1 auction\(s\) failed/i), expect.any(Array));
248
- });
249
- });
@@ -1,65 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- vi.mock("../../../../../repositories", () => ({
3
- couponsRepository: {
4
- getExpiredActiveRefs: vi.fn(),
5
- deactivateInBatch: vi.fn(),
6
- },
7
- }));
8
- import { runCouponExpiry } from "../couponExpiry";
9
- import { couponsRepository } from "../../../../../repositories";
10
- function makeBatch() {
11
- return { commit: vi.fn().mockResolvedValue(undefined) };
12
- }
13
- function makeCtx(batchOverride) {
14
- const batch = batchOverride ?? makeBatch();
15
- return {
16
- job: "coupon-expiry",
17
- db: { batch: vi.fn(() => batch) },
18
- logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },
19
- env: vi.fn(),
20
- now: new Date("2026-01-15T12:00:00Z"),
21
- };
22
- }
23
- beforeEach(() => {
24
- vi.clearAllMocks();
25
- });
26
- describe("runCouponExpiry", () => {
27
- it("returns early and does not commit when no expired coupons", async () => {
28
- couponsRepository.getExpiredActiveRefs.mockResolvedValue([]);
29
- const ctx = makeCtx();
30
- await runCouponExpiry(ctx);
31
- expect(ctx.db.batch).not.toHaveBeenCalled();
32
- });
33
- it("calls getExpiredActiveRefs with ctx.now", async () => {
34
- couponsRepository.getExpiredActiveRefs.mockResolvedValue([]);
35
- const ctx = makeCtx();
36
- await runCouponExpiry(ctx);
37
- expect(couponsRepository.getExpiredActiveRefs).toHaveBeenCalledWith(ctx.now);
38
- });
39
- it("deactivates each expired coupon in the batch", async () => {
40
- const refs = [{ id: "coupon-1" }, { id: "coupon-2" }];
41
- couponsRepository.getExpiredActiveRefs.mockResolvedValue(refs);
42
- const batch = makeBatch();
43
- const ctx = makeCtx(batch);
44
- await runCouponExpiry(ctx);
45
- expect(couponsRepository.deactivateInBatch).toHaveBeenCalledTimes(2);
46
- expect(couponsRepository.deactivateInBatch).toHaveBeenCalledWith(batch, refs[0]);
47
- expect(couponsRepository.deactivateInBatch).toHaveBeenCalledWith(batch, refs[1]);
48
- });
49
- it("commits the batch when there are expired coupons", async () => {
50
- const refs = [{ id: "coupon-1" }];
51
- couponsRepository.getExpiredActiveRefs.mockResolvedValue(refs);
52
- const batch = makeBatch();
53
- const ctx = makeCtx(batch);
54
- await runCouponExpiry(ctx);
55
- expect(batch.commit).toHaveBeenCalledOnce();
56
- });
57
- it("does not deactivate or commit when refs is empty", async () => {
58
- couponsRepository.getExpiredActiveRefs.mockResolvedValue([]);
59
- const batch = makeBatch();
60
- const ctx = makeCtx(batch);
61
- await runCouponExpiry(ctx);
62
- expect(couponsRepository.deactivateInBatch).not.toHaveBeenCalled();
63
- expect(batch.commit).not.toHaveBeenCalled();
64
- });
65
- });