@mohasinac/appkit 2.6.3 → 2.6.4

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 (606) hide show
  1. package/dist/_internal/server/features/account/data.js +2 -2
  2. package/dist/_internal/server/features/bundles/data.d.ts +26 -6
  3. package/dist/_internal/server/features/bundles/data.js +41 -6
  4. package/dist/_internal/server/features/bundles/index.d.ts +3 -2
  5. package/dist/_internal/server/features/bundles/index.js +4 -2
  6. package/dist/_internal/server/features/bundles/metadata.d.ts +20 -0
  7. package/dist/_internal/server/features/bundles/metadata.js +46 -0
  8. package/dist/_internal/server/features/bundles/og.d.ts +38 -0
  9. package/dist/_internal/server/features/bundles/og.js +122 -0
  10. package/dist/_internal/server/features/checkout/actions.js +192 -133
  11. package/dist/_internal/server/features/checkout/bundle-expansion.d.ts +57 -0
  12. package/dist/_internal/server/features/checkout/bundle-expansion.js +70 -0
  13. package/dist/_internal/server/features/checkout/prize-bundle-gates.d.ts +5 -15
  14. package/dist/_internal/server/features/checkout/prize-bundle-gates.js +5 -21
  15. package/dist/_internal/server/features/media/contextGuards.js +15 -1
  16. package/dist/_internal/server/features/payouts/actions.d.ts +19 -0
  17. package/dist/_internal/server/features/payouts/actions.js +38 -0
  18. package/dist/_internal/server/features/products/data.js +1 -2
  19. package/dist/_internal/server/features/raffle/actions.d.ts +11 -0
  20. package/dist/_internal/server/features/raffle/actions.js +31 -0
  21. package/dist/_internal/server/features/refunds/actions.d.ts +31 -0
  22. package/dist/_internal/server/features/refunds/actions.js +77 -0
  23. package/dist/_internal/server/jobs/core/adminAnalytics.d.ts +28 -0
  24. package/dist/_internal/server/jobs/core/adminAnalytics.js +98 -0
  25. package/dist/_internal/server/jobs/core/assignSpinPrize.d.ts +19 -0
  26. package/dist/_internal/server/jobs/core/assignSpinPrize.js +81 -0
  27. package/dist/_internal/server/jobs/core/auctionSettlement.d.ts +2 -0
  28. package/dist/_internal/server/jobs/core/auctionSettlement.js +70 -0
  29. package/dist/_internal/server/jobs/core/autoPayoutEligibility.d.ts +2 -0
  30. package/dist/_internal/server/jobs/core/autoPayoutEligibility.js +109 -0
  31. package/dist/_internal/server/jobs/core/bundleStockSync.d.ts +10 -0
  32. package/dist/_internal/server/jobs/core/bundleStockSync.js +71 -0
  33. package/dist/_internal/server/jobs/core/cartPrune.d.ts +2 -0
  34. package/dist/_internal/server/jobs/core/cartPrune.js +13 -0
  35. package/dist/_internal/server/jobs/core/cleanupRtdbEvents.d.ts +2 -0
  36. package/dist/_internal/server/jobs/core/cleanupRtdbEvents.js +45 -0
  37. package/dist/_internal/server/jobs/core/countersReconcile.d.ts +2 -0
  38. package/dist/_internal/server/jobs/core/countersReconcile.js +107 -0
  39. package/dist/_internal/server/jobs/core/couponExpiry.d.ts +2 -0
  40. package/dist/_internal/server/jobs/core/couponExpiry.js +13 -0
  41. package/dist/_internal/server/jobs/core/dailyDataCleanup.d.ts +2 -0
  42. package/dist/_internal/server/jobs/core/dailyDataCleanup.js +20 -0
  43. package/dist/_internal/server/jobs/core/index.d.ts +44 -0
  44. package/dist/_internal/server/jobs/core/index.js +47 -0
  45. package/dist/_internal/server/jobs/core/listingProcessor.d.ts +30 -0
  46. package/dist/_internal/server/jobs/core/listingProcessor.js +138 -0
  47. package/dist/_internal/server/jobs/core/mediaTmpCleanup.d.ts +14 -0
  48. package/dist/_internal/server/jobs/core/mediaTmpCleanup.js +68 -0
  49. package/dist/_internal/server/jobs/core/notificationPrune.d.ts +2 -0
  50. package/dist/_internal/server/jobs/core/notificationPrune.js +13 -0
  51. package/dist/_internal/server/jobs/core/offerExpiry.d.ts +2 -0
  52. package/dist/_internal/server/jobs/core/offerExpiry.js +50 -0
  53. package/dist/_internal/server/jobs/core/onBidPlaced.d.ts +15 -0
  54. package/dist/_internal/server/jobs/core/onBidPlaced.js +59 -0
  55. package/dist/_internal/server/jobs/core/onCategoryWrite.d.ts +14 -0
  56. package/dist/_internal/server/jobs/core/onCategoryWrite.js +134 -0
  57. package/dist/_internal/server/jobs/core/onOrderCreate.d.ts +18 -0
  58. package/dist/_internal/server/jobs/core/onOrderCreate.js +78 -0
  59. package/dist/_internal/server/jobs/core/onOrderStatusChange.d.ts +19 -0
  60. package/dist/_internal/server/jobs/core/onOrderStatusChange.js +139 -0
  61. package/dist/_internal/server/jobs/core/onProductStockChange.d.ts +23 -0
  62. package/dist/_internal/server/jobs/core/onProductStockChange.js +130 -0
  63. package/dist/_internal/server/jobs/core/onProductWrite.d.ts +12 -0
  64. package/dist/_internal/server/jobs/core/onProductWrite.js +94 -0
  65. package/dist/_internal/server/jobs/core/onReviewWrite.d.ts +7 -0
  66. package/dist/_internal/server/jobs/core/onReviewWrite.js +49 -0
  67. package/dist/_internal/server/jobs/core/onStoreWrite.d.ts +12 -0
  68. package/dist/_internal/server/jobs/core/onStoreWrite.js +7 -0
  69. package/dist/_internal/server/jobs/core/payoutBatch.d.ts +8 -0
  70. package/dist/_internal/server/jobs/core/payoutBatch.js +102 -0
  71. package/dist/_internal/server/jobs/core/pendingOrderTimeout.d.ts +2 -0
  72. package/dist/_internal/server/jobs/core/pendingOrderTimeout.js +27 -0
  73. package/dist/_internal/server/jobs/core/positionsReconcile.d.ts +7 -0
  74. package/dist/_internal/server/jobs/core/positionsReconcile.js +87 -0
  75. package/dist/_internal/server/jobs/core/prizeRevealClose.d.ts +2 -0
  76. package/dist/_internal/server/jobs/core/prizeRevealClose.js +22 -0
  77. package/dist/_internal/server/jobs/core/prizeRevealExpiry.d.ts +2 -0
  78. package/dist/_internal/server/jobs/core/prizeRevealExpiry.js +50 -0
  79. package/dist/_internal/server/jobs/core/prizeRevealOpen.d.ts +2 -0
  80. package/dist/_internal/server/jobs/core/prizeRevealOpen.js +56 -0
  81. package/dist/_internal/server/jobs/core/prizeRevealReminder.d.ts +2 -0
  82. package/dist/_internal/server/jobs/core/prizeRevealReminder.js +38 -0
  83. package/dist/_internal/server/jobs/core/productStatsSync.d.ts +8 -0
  84. package/dist/_internal/server/jobs/core/productStatsSync.js +36 -0
  85. package/dist/_internal/server/jobs/core/promotions.d.ts +12 -0
  86. package/dist/_internal/server/jobs/core/promotions.js +43 -0
  87. package/dist/_internal/server/jobs/core/storeAnalytics.d.ts +30 -0
  88. package/dist/_internal/server/jobs/core/storeAnalytics.js +109 -0
  89. package/dist/_internal/server/jobs/core/triggerEventRaffle.d.ts +19 -0
  90. package/dist/_internal/server/jobs/core/triggerEventRaffle.js +86 -0
  91. package/dist/_internal/server/jobs/core/weeklyPayoutEligibility.d.ts +6 -0
  92. package/dist/_internal/server/jobs/core/weeklyPayoutEligibility.js +85 -0
  93. package/dist/_internal/server/jobs/handlers/adminAnalytics.d.ts +2 -26
  94. package/dist/_internal/server/jobs/handlers/adminAnalytics.js +2 -98
  95. package/dist/_internal/server/jobs/handlers/assignSpinPrize.d.ts +1 -22
  96. package/dist/_internal/server/jobs/handlers/assignSpinPrize.js +2 -86
  97. package/dist/_internal/server/jobs/handlers/auctionSettlement.js +2 -70
  98. package/dist/_internal/server/jobs/handlers/autoPayoutEligibility.js +2 -110
  99. package/dist/_internal/server/jobs/handlers/bundleStockSync.d.ts +0 -16
  100. package/dist/_internal/server/jobs/handlers/bundleStockSync.js +2 -80
  101. package/dist/_internal/server/jobs/handlers/cartPrune.js +2 -13
  102. package/dist/_internal/server/jobs/handlers/cleanupRtdbEvents.js +2 -45
  103. package/dist/_internal/server/jobs/handlers/countersReconcile.js +2 -109
  104. package/dist/_internal/server/jobs/handlers/couponExpiry.js +2 -13
  105. package/dist/_internal/server/jobs/handlers/dailyDataCleanup.js +2 -20
  106. package/dist/_internal/server/jobs/handlers/listingProcessor.d.ts +3 -28
  107. package/dist/_internal/server/jobs/handlers/listingProcessor.js +3 -138
  108. package/dist/_internal/server/jobs/handlers/mediaTmpCleanup.d.ts +0 -12
  109. package/dist/_internal/server/jobs/handlers/mediaTmpCleanup.js +2 -69
  110. package/dist/_internal/server/jobs/handlers/notificationPrune.js +2 -13
  111. package/dist/_internal/server/jobs/handlers/offerExpiry.js +2 -50
  112. package/dist/_internal/server/jobs/handlers/onBidPlaced.d.ts +1 -10
  113. package/dist/_internal/server/jobs/handlers/onBidPlaced.js +2 -56
  114. package/dist/_internal/server/jobs/handlers/onCategoryWrite.d.ts +1 -8
  115. package/dist/_internal/server/jobs/handlers/onCategoryWrite.js +6 -134
  116. package/dist/_internal/server/jobs/handlers/onOrderCreate.d.ts +1 -12
  117. package/dist/_internal/server/jobs/handlers/onOrderCreate.js +2 -76
  118. package/dist/_internal/server/jobs/handlers/onOrderStatusChange.d.ts +1 -12
  119. package/dist/_internal/server/jobs/handlers/onOrderStatusChange.js +2 -139
  120. package/dist/_internal/server/jobs/handlers/onProductStockChange.d.ts +0 -13
  121. package/dist/_internal/server/jobs/handlers/onProductStockChange.js +7 -134
  122. package/dist/_internal/server/jobs/handlers/onProductWrite.d.ts +1 -6
  123. package/dist/_internal/server/jobs/handlers/onProductWrite.js +6 -106
  124. package/dist/_internal/server/jobs/handlers/onReviewWrite.js +2 -49
  125. package/dist/_internal/server/jobs/handlers/onStoreWrite.d.ts +1 -8
  126. package/dist/_internal/server/jobs/handlers/onStoreWrite.js +7 -8
  127. package/dist/_internal/server/jobs/handlers/payoutBatch.d.ts +0 -9
  128. package/dist/_internal/server/jobs/handlers/payoutBatch.js +2 -104
  129. package/dist/_internal/server/jobs/handlers/pendingOrderTimeout.d.ts +0 -6
  130. package/dist/_internal/server/jobs/handlers/pendingOrderTimeout.js +2 -33
  131. package/dist/_internal/server/jobs/handlers/positionsReconcile.d.ts +0 -5
  132. package/dist/_internal/server/jobs/handlers/positionsReconcile.js +2 -87
  133. package/dist/_internal/server/jobs/handlers/prizeRevealClose.d.ts +0 -7
  134. package/dist/_internal/server/jobs/handlers/prizeRevealClose.js +2 -29
  135. package/dist/_internal/server/jobs/handlers/prizeRevealExpiry.d.ts +0 -8
  136. package/dist/_internal/server/jobs/handlers/prizeRevealExpiry.js +2 -58
  137. package/dist/_internal/server/jobs/handlers/prizeRevealOpen.d.ts +0 -8
  138. package/dist/_internal/server/jobs/handlers/prizeRevealOpen.js +2 -65
  139. package/dist/_internal/server/jobs/handlers/prizeRevealReminder.d.ts +0 -7
  140. package/dist/_internal/server/jobs/handlers/prizeRevealReminder.js +2 -45
  141. package/dist/_internal/server/jobs/handlers/productStatsSync.d.ts +0 -6
  142. package/dist/_internal/server/jobs/handlers/productStatsSync.js +2 -36
  143. package/dist/_internal/server/jobs/handlers/promotions.d.ts +2 -10
  144. package/dist/_internal/server/jobs/handlers/promotions.js +2 -43
  145. package/dist/_internal/server/jobs/handlers/storeAnalytics.d.ts +2 -28
  146. package/dist/_internal/server/jobs/handlers/storeAnalytics.js +2 -109
  147. package/dist/_internal/server/jobs/handlers/triggerEventRaffle.d.ts +1 -28
  148. package/dist/_internal/server/jobs/handlers/triggerEventRaffle.js +2 -94
  149. package/dist/_internal/server/jobs/handlers/weeklyPayoutEligibility.d.ts +0 -6
  150. package/dist/_internal/server/jobs/handlers/weeklyPayoutEligibility.js +2 -87
  151. package/dist/_internal/server/jobs/index.d.ts +1 -0
  152. package/dist/_internal/server/jobs/index.js +1 -0
  153. package/dist/_internal/server/jobs/runtime/adapters/firebase.js +21 -0
  154. package/dist/_internal/shared/actions/action-registry.d.ts +84 -0
  155. package/dist/_internal/shared/actions/action-registry.js +160 -0
  156. package/dist/_internal/shared/checkout/rules/_defaults.d.ts +3 -0
  157. package/dist/_internal/shared/checkout/rules/_defaults.js +22 -0
  158. package/dist/_internal/shared/checkout/rules/_limits.d.ts +19 -0
  159. package/dist/_internal/shared/checkout/rules/_limits.js +19 -0
  160. package/dist/_internal/shared/checkout/rules/_registry.d.ts +44 -0
  161. package/dist/_internal/shared/checkout/rules/_registry.js +87 -0
  162. package/dist/_internal/shared/checkout/rules/auction.rule.d.ts +2 -0
  163. package/dist/_internal/shared/checkout/rules/auction.rule.js +10 -0
  164. package/dist/_internal/shared/checkout/rules/bundle.rule.d.ts +11 -0
  165. package/dist/_internal/shared/checkout/rules/bundle.rule.js +6 -0
  166. package/dist/_internal/shared/checkout/rules/classified.rule.d.ts +9 -0
  167. package/dist/_internal/shared/checkout/rules/classified.rule.js +9 -0
  168. package/dist/_internal/shared/checkout/rules/digital-code.rule.d.ts +8 -0
  169. package/dist/_internal/shared/checkout/rules/digital-code.rule.js +6 -0
  170. package/dist/_internal/shared/checkout/rules/index.d.ts +12 -0
  171. package/dist/_internal/shared/checkout/rules/index.js +12 -0
  172. package/dist/_internal/shared/checkout/rules/live.rule.d.ts +10 -0
  173. package/dist/_internal/shared/checkout/rules/live.rule.js +6 -0
  174. package/dist/_internal/shared/checkout/rules/offer.rule.d.ts +2 -0
  175. package/dist/_internal/shared/checkout/rules/offer.rule.js +9 -0
  176. package/dist/_internal/shared/checkout/rules/preorder.rule.d.ts +2 -0
  177. package/dist/_internal/shared/checkout/rules/preorder.rule.js +28 -0
  178. package/dist/_internal/shared/checkout/rules/prize-draw.rule.d.ts +2 -0
  179. package/dist/_internal/shared/checkout/rules/prize-draw.rule.js +65 -0
  180. package/dist/_internal/shared/checkout/rules/standard.rule.d.ts +2 -0
  181. package/dist/_internal/shared/checkout/rules/standard.rule.js +5 -0
  182. package/dist/_internal/shared/checkout/rules/types.d.ts +125 -0
  183. package/dist/_internal/shared/checkout/rules/types.js +13 -0
  184. package/dist/_internal/shared/features/cart/schema.d.ts +6 -6
  185. package/dist/_internal/shared/features/categories/bundle-copy.d.ts +123 -0
  186. package/dist/_internal/shared/features/categories/bundle-copy.js +134 -0
  187. package/dist/_internal/shared/features/categories/bundle-schemas.d.ts +318 -0
  188. package/dist/_internal/shared/features/categories/bundle-schemas.js +55 -0
  189. package/dist/_internal/shared/features/orders/refund-copy.d.ts +36 -0
  190. package/dist/_internal/shared/features/orders/refund-copy.js +40 -0
  191. package/dist/_internal/shared/features/orders/schema.d.ts +4 -4
  192. package/dist/_internal/shared/features/products/schema.d.ts +8 -8
  193. package/dist/_internal/shared/listing-types/_registry.d.ts +27 -0
  194. package/dist/_internal/shared/listing-types/_registry.js +8 -0
  195. package/dist/_internal/shared/listing-types/action-tracker.d.ts +41 -0
  196. package/dist/_internal/shared/listing-types/action-tracker.js +70 -0
  197. package/dist/_internal/shared/listing-types/capabilities.js +25 -0
  198. package/dist/_internal/shared/listing-types/cart-shipping.d.ts +37 -0
  199. package/dist/_internal/shared/listing-types/cart-shipping.js +46 -0
  200. package/dist/_internal/shared/listing-types/classified/config.d.ts +7 -0
  201. package/dist/_internal/shared/listing-types/classified/config.js +8 -0
  202. package/dist/_internal/shared/listing-types/classified/ctas.d.ts +1 -0
  203. package/dist/_internal/shared/listing-types/classified/ctas.js +3 -0
  204. package/dist/_internal/shared/listing-types/classified/og.d.ts +1 -0
  205. package/dist/_internal/shared/listing-types/classified/og.js +1 -0
  206. package/dist/_internal/shared/listing-types/classified/schema.d.ts +1 -0
  207. package/dist/_internal/shared/listing-types/classified/schema.js +1 -0
  208. package/dist/_internal/shared/listing-types/classified/seed-factory.d.ts +1 -0
  209. package/dist/_internal/shared/listing-types/classified/seed-factory.js +1 -0
  210. package/dist/_internal/shared/listing-types/digital-code/config.d.ts +7 -0
  211. package/dist/_internal/shared/listing-types/digital-code/config.js +8 -0
  212. package/dist/_internal/shared/listing-types/digital-code/ctas.d.ts +1 -0
  213. package/dist/_internal/shared/listing-types/digital-code/ctas.js +3 -0
  214. package/dist/_internal/shared/listing-types/digital-code/og.d.ts +1 -0
  215. package/dist/_internal/shared/listing-types/digital-code/og.js +1 -0
  216. package/dist/_internal/shared/listing-types/digital-code/schema.d.ts +1 -0
  217. package/dist/_internal/shared/listing-types/digital-code/schema.js +1 -0
  218. package/dist/_internal/shared/listing-types/digital-code/seed-factory.d.ts +1 -0
  219. package/dist/_internal/shared/listing-types/digital-code/seed-factory.js +1 -0
  220. package/dist/_internal/shared/listing-types/feature-flags.d.ts +34 -0
  221. package/dist/_internal/shared/listing-types/feature-flags.js +45 -0
  222. package/dist/_internal/shared/listing-types/live/config.d.ts +7 -0
  223. package/dist/_internal/shared/listing-types/live/config.js +8 -0
  224. package/dist/_internal/shared/listing-types/live/ctas.d.ts +1 -0
  225. package/dist/_internal/shared/listing-types/live/ctas.js +3 -0
  226. package/dist/_internal/shared/listing-types/live/og.d.ts +1 -0
  227. package/dist/_internal/shared/listing-types/live/og.js +1 -0
  228. package/dist/_internal/shared/listing-types/live/schema.d.ts +1 -0
  229. package/dist/_internal/shared/listing-types/live/schema.js +1 -0
  230. package/dist/_internal/shared/listing-types/live/seed-factory.d.ts +1 -0
  231. package/dist/_internal/shared/listing-types/live/seed-factory.js +1 -0
  232. package/dist/_internal/shared/media/limits.js +8 -0
  233. package/dist/client.d.ts +6 -1
  234. package/dist/client.js +14 -1
  235. package/dist/configs/next.js +7 -0
  236. package/dist/constants/api-endpoints.d.ts +6 -0
  237. package/dist/constants/api-endpoints.js +4 -0
  238. package/dist/core/hooks/useSyncManager.js +13 -1
  239. package/dist/core/unit-of-work.d.ts +1 -1
  240. package/dist/core/unit-of-work.js +2 -2
  241. package/dist/features/account/actions/address-actions.d.ts +1 -1
  242. package/dist/features/account/actions/address-actions.js +15 -7
  243. package/dist/features/account/schemas/firestore.d.ts +8 -43
  244. package/dist/features/account/schemas/firestore.js +8 -54
  245. package/dist/features/account/schemas/index.d.ts +6 -6
  246. package/dist/features/account/server.d.ts +1 -1
  247. package/dist/features/account/server.js +3 -1
  248. package/dist/features/addresses/index.d.ts +2 -0
  249. package/dist/features/addresses/index.js +2 -0
  250. package/dist/features/addresses/repository/addresses.repository.d.ts +29 -0
  251. package/dist/features/addresses/repository/addresses.repository.js +157 -0
  252. package/dist/features/addresses/schemas/firestore.d.ts +53 -0
  253. package/dist/features/addresses/schemas/firestore.js +68 -0
  254. package/dist/features/{bundles → addresses}/schemas/index.d.ts +0 -1
  255. package/dist/features/{bundles → addresses}/schemas/index.js +0 -1
  256. package/dist/features/addresses/server.d.ts +2 -0
  257. package/dist/features/addresses/server.js +2 -0
  258. package/dist/features/admin/components/AdminAllEventEntriesView.js +4 -3
  259. package/dist/features/admin/components/AdminBidsView.js +4 -3
  260. package/dist/features/admin/components/AdminBlogView.js +8 -3
  261. package/dist/features/admin/components/AdminBundleEditorView.d.ts +9 -0
  262. package/dist/features/admin/components/AdminBundleEditorView.js +209 -0
  263. package/dist/features/admin/components/AdminBundlesView.d.ts +9 -0
  264. package/dist/features/admin/components/AdminBundlesView.js +59 -0
  265. package/dist/features/admin/components/AdminCartsView.js +13 -3
  266. package/dist/features/admin/components/AdminContactView.js +4 -3
  267. package/dist/features/admin/components/AdminCouponsView.js +32 -13
  268. package/dist/features/admin/components/AdminNewsletterView.js +4 -3
  269. package/dist/features/admin/components/AdminOrdersView.js +15 -7
  270. package/dist/features/admin/components/AdminPayoutsView.js +4 -3
  271. package/dist/features/admin/components/AdminProductsView.js +6 -5
  272. package/dist/features/admin/components/AdminReviewsView.js +5 -4
  273. package/dist/features/admin/components/AdminStoresView.js +4 -3
  274. package/dist/features/admin/components/AdminUsersView.js +15 -5
  275. package/dist/features/admin/components/AdminWishlistsView.js +10 -1
  276. package/dist/features/admin/components/DataTable.d.ts +5 -1
  277. package/dist/features/admin/components/DataTable.js +24 -20
  278. package/dist/features/admin/components/index.d.ts +4 -0
  279. package/dist/features/admin/components/index.js +3 -0
  280. package/dist/features/admin/constants/filter-tabs.d.ts +401 -0
  281. package/dist/features/admin/constants/filter-tabs.js +200 -0
  282. package/dist/features/admin/hooks/useAdminListingData.d.ts +1 -0
  283. package/dist/features/admin/hooks/useAdminListingData.js +1 -0
  284. package/dist/features/admin/schemas/firestore.d.ts +15 -0
  285. package/dist/features/admin/schemas/firestore.js +18 -0
  286. package/dist/features/admin/types/product.types.d.ts +2 -2
  287. package/dist/features/auctions/components/AuctionCard.d.ts +4 -1
  288. package/dist/features/auctions/components/AuctionCard.js +5 -3
  289. package/dist/features/auctions/components/AuctionDetailPageView.js +1 -1
  290. package/dist/features/auctions/components/MarketplaceAuctionCard.d.ts +2 -2
  291. package/dist/features/auctions/components/PlaceBidFormClient.js +12 -2
  292. package/dist/features/auctions/schemas/index.d.ts +2 -2
  293. package/dist/features/auth/index.d.ts +1 -0
  294. package/dist/features/auth/index.js +1 -0
  295. package/dist/features/auth/role-predicates.d.ts +16 -0
  296. package/dist/features/auth/role-predicates.js +15 -0
  297. package/dist/features/blog/components/BlogFeaturedCard.d.ts +4 -1
  298. package/dist/features/blog/components/BlogFeaturedCard.js +5 -3
  299. package/dist/features/cart/actions/cart-actions.d.ts +1 -0
  300. package/dist/features/cart/actions/cart-actions.js +16 -0
  301. package/dist/features/cart/components/CartView.d.ts +19 -1
  302. package/dist/features/cart/components/CartView.js +2 -2
  303. package/dist/features/cart/components/ShippingPicker.d.ts +13 -0
  304. package/dist/features/cart/components/ShippingPicker.js +48 -0
  305. package/dist/features/cart/components/index.d.ts +3 -1
  306. package/dist/features/cart/components/index.js +1 -0
  307. package/dist/features/cart/hooks/useCartCount.js +7 -1
  308. package/dist/features/cart/repository/cart.repository.d.ts +1 -0
  309. package/dist/features/cart/repository/cart.repository.js +35 -0
  310. package/dist/features/cart/schemas/firestore.d.ts +27 -2
  311. package/dist/features/categories/components/BundleAddToCartCta.d.ts +16 -0
  312. package/dist/features/categories/components/BundleAddToCartCta.js +54 -0
  313. package/dist/features/categories/components/BundleBuyNowCta.d.ts +8 -0
  314. package/dist/features/categories/components/BundleBuyNowCta.js +37 -0
  315. package/dist/features/categories/components/BundleDetailView.d.ts +22 -0
  316. package/dist/features/categories/components/BundleDetailView.js +31 -0
  317. package/dist/features/categories/components/BundleDynamicRuleEditor.d.ts +18 -0
  318. package/dist/features/categories/components/BundleDynamicRuleEditor.js +60 -0
  319. package/dist/features/categories/components/BundleItemsPicker.d.ts +26 -0
  320. package/dist/features/categories/components/BundleItemsPicker.js +135 -0
  321. package/dist/features/categories/components/BundlesListView.d.ts +13 -0
  322. package/dist/features/categories/components/BundlesListView.js +27 -0
  323. package/dist/features/categories/components/index.d.ts +12 -0
  324. package/dist/features/categories/components/index.js +9 -0
  325. package/dist/features/checkout/actions/checkout-actions.js +10 -3
  326. package/dist/features/events/components/AdminEventEditorView.js +108 -2
  327. package/dist/features/events/components/AdminEventsView.js +16 -4
  328. package/dist/features/events/components/EventCard.d.ts +4 -1
  329. package/dist/features/events/components/EventCard.js +7 -3
  330. package/dist/features/events/components/EventRaffleWinnerView.d.ts +21 -0
  331. package/dist/features/events/components/EventRaffleWinnerView.js +18 -0
  332. package/dist/features/events/components/SpinWheelView.d.ts +27 -0
  333. package/dist/features/events/components/SpinWheelView.js +64 -0
  334. package/dist/features/events/components/index.d.ts +4 -0
  335. package/dist/features/events/components/index.js +2 -0
  336. package/dist/features/events/schemas/firestore.d.ts +27 -1
  337. package/dist/features/events/schemas/firestore.js +7 -0
  338. package/dist/features/events/types/index.d.ts +27 -1
  339. package/dist/features/homepage/components/FeaturedBundlesSection.d.ts +16 -0
  340. package/dist/features/homepage/components/FeaturedBundlesSection.js +24 -0
  341. package/dist/features/homepage/components/MarketplaceHomepageView.js +4 -1
  342. package/dist/features/homepage/components/WhatsAppCommunitySection.js +2 -2
  343. package/dist/features/homepage/lib/section-renderer.d.ts +2 -0
  344. package/dist/features/homepage/lib/section-renderer.js +5 -5
  345. package/dist/features/layout/NavbarLayout.d.ts +3 -1
  346. package/dist/features/layout/NavbarLayout.js +32 -3
  347. package/dist/features/layout/TitleBarLayout.d.ts +6 -3
  348. package/dist/features/layout/TitleBarLayout.js +22 -7
  349. package/dist/features/media/upload/MediaUploadField.d.ts +15 -1
  350. package/dist/features/media/upload/MediaUploadField.js +22 -1
  351. package/dist/features/orders/components/MarketplaceOrderCard.js +4 -2
  352. package/dist/features/orders/components/OrderSiblingPayments.d.ts +8 -0
  353. package/dist/features/orders/components/OrderSiblingPayments.js +16 -0
  354. package/dist/features/orders/components/RefundHistoryTable.d.ts +6 -0
  355. package/dist/features/orders/components/RefundHistoryTable.js +23 -0
  356. package/dist/features/orders/components/RefundRequestView.d.ts +8 -0
  357. package/dist/features/orders/components/RefundRequestView.js +42 -0
  358. package/dist/features/orders/components/index.d.ts +6 -0
  359. package/dist/features/orders/components/index.js +3 -0
  360. package/dist/features/orders/index.d.ts +1 -0
  361. package/dist/features/orders/index.js +2 -0
  362. package/dist/features/orders/repository/orders.repository.d.ts +20 -1
  363. package/dist/features/orders/repository/orders.repository.js +30 -1
  364. package/dist/features/orders/schemas/firestore.d.ts +63 -13
  365. package/dist/features/orders/schemas/firestore.js +5 -5
  366. package/dist/features/orders/schemas/index.d.ts +4 -4
  367. package/dist/features/orders/types/index.d.ts +12 -2
  368. package/dist/features/orders/utils/bundle-grouping.d.ts +48 -0
  369. package/dist/features/orders/utils/bundle-grouping.js +54 -0
  370. package/dist/features/orders/utils/order-splitter.d.ts +9 -10
  371. package/dist/features/orders/utils/order-splitter.js +24 -30
  372. package/dist/features/payments/repository/payout.repository.d.ts +17 -1
  373. package/dist/features/payments/repository/payout.repository.js +47 -0
  374. package/dist/features/payments/schemas/firestore.d.ts +26 -0
  375. package/dist/features/pre-orders/components/PreorderCard.d.ts +4 -1
  376. package/dist/features/pre-orders/components/PreorderCard.js +8 -6
  377. package/dist/features/products/actions/product-actions.d.ts +1 -1
  378. package/dist/features/products/actions/product-actions.js +1 -1
  379. package/dist/features/products/components/CompareOverlay.d.ts +2 -2
  380. package/dist/features/products/components/CompareOverlay.js +4 -4
  381. package/dist/features/products/components/InteractiveProductCard.js +7 -12
  382. package/dist/features/products/components/NonRefundableConsentModal.d.ts +1 -1
  383. package/dist/features/products/components/NonRefundableConsentModal.js +0 -10
  384. package/dist/features/products/components/ProductGrid.js +28 -12
  385. package/dist/features/products/components/ShowGroupSection.js +3 -3
  386. package/dist/features/products/components/SublistingCarouselSection.js +2 -2
  387. package/dist/features/products/components/index.d.ts +0 -4
  388. package/dist/features/products/components/index.js +5 -2
  389. package/dist/features/products/index.d.ts +1 -1
  390. package/dist/features/products/index.js +3 -1
  391. package/dist/features/products/repository/products.repository.js +4 -0
  392. package/dist/features/products/schemas/catalog-product.d.ts +70 -0
  393. package/dist/features/products/schemas/catalog-product.js +50 -0
  394. package/dist/features/products/schemas/firestore.d.ts +110 -2
  395. package/dist/features/products/schemas/firestore.js +30 -0
  396. package/dist/features/products/schemas/index.d.ts +8 -8
  397. package/dist/features/products/types/index.d.ts +1 -1
  398. package/dist/features/products/utils/listing-type.d.ts +9 -0
  399. package/dist/features/products/utils/listing-type.js +4 -0
  400. package/dist/features/promotions/actions/coupon-actions.d.ts +2 -2
  401. package/dist/features/promotions/actions/coupon-actions.js +1 -1
  402. package/dist/features/promotions/components/CouponCard.d.ts +28 -10
  403. package/dist/features/promotions/components/CouponCard.js +116 -14
  404. package/dist/features/promotions/hooks/useCouponValidate.d.ts +1 -1
  405. package/dist/features/promotions/repository/coupons.repository.d.ts +1 -1
  406. package/dist/features/reviews/schemas/index.d.ts +2 -2
  407. package/dist/features/search/schemas/index.d.ts +2 -2
  408. package/dist/features/search/types/index.d.ts +2 -2
  409. package/dist/features/seller/components/SellerAuctionsView.js +4 -5
  410. package/dist/features/seller/components/SellerBidsView.js +5 -13
  411. package/dist/features/seller/components/SellerCouponsView.js +31 -67
  412. package/dist/features/seller/components/SellerOffersView.js +4 -5
  413. package/dist/features/seller/components/SellerOrdersView.js +4 -5
  414. package/dist/features/seller/components/SellerPayoutsView.js +4 -5
  415. package/dist/features/seller/components/SellerProductsView.js +4 -8
  416. package/dist/features/seller/schemas/index.d.ts +2 -2
  417. package/dist/features/stores/actions/store-address-actions.d.ts +10 -6
  418. package/dist/features/stores/actions/store-address-actions.js +8 -7
  419. package/dist/features/stores/components/InteractiveStoreCard.js +3 -10
  420. package/dist/features/stores/components/StoreDetailLayoutView.js +20 -5
  421. package/dist/features/stores/schemas/firestore.d.ts +45 -38
  422. package/dist/features/stores/schemas/firestore.js +2 -49
  423. package/dist/features/stores/server.d.ts +0 -1
  424. package/dist/features/stores/server.js +2 -1
  425. package/dist/features/wishlist/hooks/useWishlistCount.d.ts +7 -9
  426. package/dist/features/wishlist/hooks/useWishlistCount.js +67 -86
  427. package/dist/features/wishlist/types/index.d.ts +1 -1
  428. package/dist/index.d.ts +50 -9
  429. package/dist/index.js +57 -11
  430. package/dist/next/routing/route-map.d.ts +6 -0
  431. package/dist/next/routing/route-map.js +4 -0
  432. package/dist/providers/db-firebase/admin.d.ts +6 -2
  433. package/dist/providers/db-firebase/admin.js +23 -0
  434. package/dist/repositories/index.d.ts +1 -2
  435. package/dist/repositories/index.js +5 -2
  436. package/dist/security/authorization.d.ts +2 -1
  437. package/dist/security/authorization.js +3 -2
  438. package/dist/seed/actions/demo-seed-actions.d.ts +1 -1
  439. package/dist/seed/bids-seed-data.d.ts +2 -2
  440. package/dist/seed/bids-seed-data.js +77 -2
  441. package/dist/seed/cart-seed-data.d.ts +10 -10
  442. package/dist/seed/cart-seed-data.js +15 -15
  443. package/dist/seed/events-seed-data.js +77 -0
  444. package/dist/seed/manifest.js +16 -8
  445. package/dist/seed/orders-seed-data.js +41 -2
  446. package/dist/seed/payouts-seed-data.js +18 -2
  447. package/dist/seed/stores-seed-data.js +55 -0
  448. package/dist/server-entry.d.ts +1 -0
  449. package/dist/server-entry.js +2 -0
  450. package/dist/server.d.ts +4 -0
  451. package/dist/server.js +8 -0
  452. package/dist/tailwind-utilities.css +1 -1
  453. package/dist/ui/components/FilterChipGroup.d.ts +39 -0
  454. package/dist/ui/components/FilterChipGroup.js +15 -0
  455. package/dist/ui/components/HorizontalScroller.js +32 -7
  456. package/dist/ui/components/HorizontalScroller.style.css +6 -0
  457. package/dist/ui/components/SiteLogo.js +1 -1
  458. package/dist/ui/index.d.ts +2 -0
  459. package/dist/ui/index.js +2 -0
  460. package/dist/utils/id-generators.d.ts +11 -0
  461. package/dist/utils/id-generators.js +16 -0
  462. package/package.json +1 -1
  463. package/dist/_internal/shared/features/bundles/config.d.ts +0 -6
  464. package/dist/_internal/shared/features/bundles/config.js +0 -6
  465. package/dist/_internal/shared/schema-versions.d.ts +0 -76
  466. package/dist/_internal/shared/schema-versions.js +0 -82
  467. package/dist/features/account/migrations.d.ts +0 -2
  468. package/dist/features/account/migrations.js +0 -10
  469. package/dist/features/admin/migrations.d.ts +0 -2
  470. package/dist/features/admin/migrations.js +0 -10
  471. package/dist/features/auctions/migrations.d.ts +0 -2
  472. package/dist/features/auctions/migrations.js +0 -10
  473. package/dist/features/auth/migrations.d.ts +0 -2
  474. package/dist/features/auth/migrations.js +0 -10
  475. package/dist/features/blog/migrations.d.ts +0 -2
  476. package/dist/features/blog/migrations.js +0 -10
  477. package/dist/features/brands/actions/brand-actions.d.ts +0 -2
  478. package/dist/features/brands/actions/brand-actions.js +0 -5
  479. package/dist/features/brands/index.d.ts +0 -3
  480. package/dist/features/brands/index.js +0 -3
  481. package/dist/features/brands/migrations.d.ts +0 -2
  482. package/dist/features/brands/migrations.js +0 -10
  483. package/dist/features/brands/repository/brands.repository.d.ts +0 -13
  484. package/dist/features/brands/repository/brands.repository.js +0 -60
  485. package/dist/features/brands/schemas/index.d.ts +0 -33
  486. package/dist/features/brands/schemas/index.js +0 -15
  487. package/dist/features/brands/server.d.ts +0 -7
  488. package/dist/features/brands/server.js +0 -7
  489. package/dist/features/bundles/components/AdminBundleEditorView.d.ts +0 -8
  490. package/dist/features/bundles/components/AdminBundleEditorView.js +0 -7
  491. package/dist/features/bundles/components/BundleDetailPageView.d.ts +0 -9
  492. package/dist/features/bundles/components/BundleDetailPageView.js +0 -45
  493. package/dist/features/bundles/components/BundleForm.d.ts +0 -12
  494. package/dist/features/bundles/components/BundleForm.js +0 -126
  495. package/dist/features/bundles/components/BundleItemsPicker.d.ts +0 -9
  496. package/dist/features/bundles/components/BundleItemsPicker.js +0 -77
  497. package/dist/features/bundles/components/BundlesByCategoryListing.d.ts +0 -6
  498. package/dist/features/bundles/components/BundlesByCategoryListing.js +0 -50
  499. package/dist/features/bundles/components/BundlesListingView.d.ts +0 -17
  500. package/dist/features/bundles/components/BundlesListingView.js +0 -50
  501. package/dist/features/bundles/components/FeaturedBundlesSection.d.ts +0 -5
  502. package/dist/features/bundles/components/FeaturedBundlesSection.js +0 -55
  503. package/dist/features/bundles/components/SellerBundleCreateView.d.ts +0 -8
  504. package/dist/features/bundles/components/SellerBundleCreateView.js +0 -7
  505. package/dist/features/bundles/components/SellerBundleEditView.d.ts +0 -9
  506. package/dist/features/bundles/components/SellerBundleEditView.js +0 -7
  507. package/dist/features/bundles/components/index.d.ts +0 -18
  508. package/dist/features/bundles/components/index.js +0 -9
  509. package/dist/features/bundles/constants/index.d.ts +0 -32
  510. package/dist/features/bundles/constants/index.js +0 -35
  511. package/dist/features/bundles/index.d.ts +0 -2
  512. package/dist/features/bundles/index.js +0 -2
  513. package/dist/features/bundles/migrations.d.ts +0 -2
  514. package/dist/features/bundles/migrations.js +0 -10
  515. package/dist/features/bundles/repository/bundles.repository.d.ts +0 -36
  516. package/dist/features/bundles/repository/bundles.repository.js +0 -148
  517. package/dist/features/bundles/repository/index.d.ts +0 -1
  518. package/dist/features/bundles/repository/index.js +0 -1
  519. package/dist/features/bundles/schemas/firestore.d.ts +0 -88
  520. package/dist/features/bundles/schemas/firestore.js +0 -29
  521. package/dist/features/bundles/schemas/zod.d.ts +0 -377
  522. package/dist/features/bundles/schemas/zod.js +0 -71
  523. package/dist/features/cart/migrations.d.ts +0 -2
  524. package/dist/features/cart/migrations.js +0 -10
  525. package/dist/features/categories/migrations.d.ts +0 -2
  526. package/dist/features/categories/migrations.js +0 -10
  527. package/dist/features/events/migrations.d.ts +0 -2
  528. package/dist/features/events/migrations.js +0 -10
  529. package/dist/features/faq/migrations.d.ts +0 -2
  530. package/dist/features/faq/migrations.js +0 -10
  531. package/dist/features/grouped/migrations.d.ts +0 -2
  532. package/dist/features/grouped/migrations.js +0 -10
  533. package/dist/features/history/migrations.d.ts +0 -2
  534. package/dist/features/history/migrations.js +0 -10
  535. package/dist/features/messages/migrations.d.ts +0 -2
  536. package/dist/features/messages/migrations.js +0 -10
  537. package/dist/features/orders/migrations.d.ts +0 -2
  538. package/dist/features/orders/migrations.js +0 -10
  539. package/dist/features/payments/migrations.d.ts +0 -2
  540. package/dist/features/payments/migrations.js +0 -10
  541. package/dist/features/products/migrations.d.ts +0 -2
  542. package/dist/features/products/migrations.js +0 -10
  543. package/dist/features/products/repository/sublisting-categories.repository.d.ts +0 -16
  544. package/dist/features/products/repository/sublisting-categories.repository.js +0 -126
  545. package/dist/features/products/schemas/sublisting-categories.d.ts +0 -45
  546. package/dist/features/products/schemas/sublisting-categories.js +0 -16
  547. package/dist/features/promotions/migrations.d.ts +0 -2
  548. package/dist/features/promotions/migrations.js +0 -10
  549. package/dist/features/reviews/migrations.d.ts +0 -2
  550. package/dist/features/reviews/migrations.js +0 -10
  551. package/dist/features/scams/migrations.d.ts +0 -2
  552. package/dist/features/scams/migrations.js +0 -10
  553. package/dist/features/seller/migrations.d.ts +0 -2
  554. package/dist/features/seller/migrations.js +0 -10
  555. package/dist/features/stores/migrations.d.ts +0 -2
  556. package/dist/features/stores/migrations.js +0 -10
  557. package/dist/features/sublisting/migrations.d.ts +0 -2
  558. package/dist/features/sublisting/migrations.js +0 -10
  559. package/dist/features/sublisting/schemas/firestore.d.ts +0 -32
  560. package/dist/features/sublisting/schemas/firestore.js +0 -19
  561. package/dist/features/support/migrations.d.ts +0 -2
  562. package/dist/features/support/migrations.js +0 -10
  563. package/dist/features/wishlist/migrations.d.ts +0 -2
  564. package/dist/features/wishlist/migrations.js +0 -10
  565. package/dist/seed/_bundle-constants.d.ts +0 -14
  566. package/dist/seed/_bundle-constants.js +0 -14
  567. package/dist/seed/anime-figures-seed-data.d.ts +0 -8
  568. package/dist/seed/anime-figures-seed-data.js +0 -1033
  569. package/dist/seed/beyblade-seed-data.d.ts +0 -7
  570. package/dist/seed/beyblade-seed-data.js +0 -1129
  571. package/dist/seed/brands-seed-data.d.ts +0 -7
  572. package/dist/seed/brands-seed-data.js +0 -410
  573. package/dist/seed/bundles-seed-data.d.ts +0 -13
  574. package/dist/seed/bundles-seed-data.js +0 -229
  575. package/dist/seed/cosplay-accessories-seed-data.d.ts +0 -8
  576. package/dist/seed/cosplay-accessories-seed-data.js +0 -647
  577. package/dist/seed/hot-wheels-seed-data.d.ts +0 -7
  578. package/dist/seed/hot-wheels-seed-data.js +0 -1612
  579. package/dist/seed/letitrip-official-seed-data.d.ts +0 -8
  580. package/dist/seed/letitrip-official-seed-data.js +0 -399
  581. package/dist/seed/pokemon-carousel-slides-seed-data.d.ts +0 -8
  582. package/dist/seed/pokemon-carousel-slides-seed-data.js +0 -322
  583. package/dist/seed/pokemon-categories-seed-data.d.ts +0 -24
  584. package/dist/seed/pokemon-categories-seed-data.js +0 -547
  585. package/dist/seed/pokemon-coupons-seed-data.d.ts +0 -6
  586. package/dist/seed/pokemon-coupons-seed-data.js +0 -465
  587. package/dist/seed/pokemon-homepage-sections-seed-data.d.ts +0 -7
  588. package/dist/seed/pokemon-homepage-sections-seed-data.js +0 -241
  589. package/dist/seed/pokemon-products-seed-data.d.ts +0 -9
  590. package/dist/seed/pokemon-products-seed-data.js +0 -1791
  591. package/dist/seed/pokemon-seed-bundle.d.ts +0 -47
  592. package/dist/seed/pokemon-seed-bundle.js +0 -71
  593. package/dist/seed/pokemon-stores-seed-data.d.ts +0 -6
  594. package/dist/seed/pokemon-stores-seed-data.js +0 -179
  595. package/dist/seed/pokemon-users-seed-data.d.ts +0 -6
  596. package/dist/seed/pokemon-users-seed-data.js +0 -521
  597. package/dist/seed/products-seed-data.d.ts +0 -6
  598. package/dist/seed/products-seed-data.js +0 -2530
  599. package/dist/seed/retro-gaming-seed-data.d.ts +0 -8
  600. package/dist/seed/retro-gaming-seed-data.js +0 -801
  601. package/dist/seed/server.d.ts +0 -2
  602. package/dist/seed/server.js +0 -7
  603. package/dist/seed/sublisting-categories-seed-data.d.ts +0 -7
  604. package/dist/seed/sublisting-categories-seed-data.js +0 -159
  605. package/dist/seed/transformers-seed-data.d.ts +0 -7
  606. package/dist/seed/transformers-seed-data.js +0 -530
@@ -0,0 +1,139 @@
1
+ import { notificationRepository } from "../../../../repositories";
2
+ import { decryptPii } from "../../../../security/index";
3
+ import { getAdminRealtimeDb } from "../../../../providers/db-firebase";
4
+ import { ORDER_MESSAGES, EMAIL_SUBJECTS, JOB_ERROR_MESSAGES } from "../handlers/messages";
5
+ const STATUS_CONFIG = {
6
+ confirmed: {
7
+ type: "order_confirmed",
8
+ title: ORDER_MESSAGES.CONFIRMED_TITLE,
9
+ message: (o) => ORDER_MESSAGES.CONFIRMED_MESSAGE(o.productTitle),
10
+ priority: "normal",
11
+ sendEmail: true,
12
+ },
13
+ shipped: {
14
+ type: "order_shipped",
15
+ title: ORDER_MESSAGES.SHIPPED_TITLE,
16
+ message: (o) => ORDER_MESSAGES.SHIPPED_MESSAGE(o.productTitle, o.trackingNumber),
17
+ priority: "high",
18
+ sendEmail: true,
19
+ },
20
+ delivered: {
21
+ type: "order_delivered",
22
+ title: ORDER_MESSAGES.DELIVERED_TITLE,
23
+ message: (o) => ORDER_MESSAGES.DELIVERED_MESSAGE(o.productTitle),
24
+ priority: "normal",
25
+ sendEmail: true,
26
+ },
27
+ cancelled: {
28
+ type: "order_cancelled",
29
+ title: ORDER_MESSAGES.CANCELLED_TITLE,
30
+ message: (o) => `Your order for "${o.productTitle}" has been cancelled.`,
31
+ priority: "normal",
32
+ sendEmail: false,
33
+ },
34
+ };
35
+ async function sendResendEmail(params) {
36
+ const subject = params.status === "confirmed"
37
+ ? EMAIL_SUBJECTS.ORDER_CONFIRMED(params.productTitle)
38
+ : params.status === "shipped"
39
+ ? EMAIL_SUBJECTS.ORDER_SHIPPED(params.productTitle)
40
+ : params.status === "delivered"
41
+ ? EMAIL_SUBJECTS.ORDER_DELIVERED(params.productTitle)
42
+ : EMAIL_SUBJECTS.ORDER_UPDATE_FALLBACK(params.productTitle);
43
+ const response = await fetch("https://api.resend.com/emails", {
44
+ method: "POST",
45
+ headers: {
46
+ Authorization: `Bearer ${params.apiKey}`,
47
+ "Content-Type": "application/json",
48
+ },
49
+ body: JSON.stringify({
50
+ from: params.fromAddress,
51
+ to: [params.to],
52
+ subject,
53
+ html: `<p>Hi,</p><p>Your order for <strong>${params.productTitle}</strong> is now <strong>${params.status}</strong>.</p>${params.trackingNumber ? `<p>Tracking number: ${params.trackingNumber}</p>` : ""}<p>Thanks,<br/>${params.brandName} Team</p>`,
54
+ }),
55
+ });
56
+ if (!response.ok) {
57
+ const body = await response.text();
58
+ throw new Error(JOB_ERROR_MESSAGES.RESEND_API_ERROR(response.status, body));
59
+ }
60
+ }
61
+ export async function handleOrderStatusChange(input, ctx) {
62
+ const { orderId, before, after } = input;
63
+ if (!before || !after)
64
+ return;
65
+ if (before.status === after.status)
66
+ return;
67
+ const newStatus = after.status;
68
+ const config = STATUS_CONFIG[newStatus];
69
+ if (!config) {
70
+ ctx.logger.info(`No handler for status transition → ${newStatus}`, { orderId });
71
+ return;
72
+ }
73
+ const userEmail = decryptPii(after.userEmail);
74
+ try {
75
+ const messageText = config.message({
76
+ productTitle: after.productTitle,
77
+ trackingNumber: after.trackingNumber,
78
+ });
79
+ await notificationRepository.create({
80
+ userId: after.userId,
81
+ type: config.type,
82
+ priority: config.priority,
83
+ title: config.title,
84
+ message: messageText,
85
+ relatedId: orderId,
86
+ relatedType: "order",
87
+ });
88
+ try {
89
+ await getAdminRealtimeDb().ref(`notifications/${after.userId}`).push({
90
+ type: config.type,
91
+ title: config.title,
92
+ message: messageText,
93
+ timestamp: Date.now(),
94
+ read: false,
95
+ });
96
+ }
97
+ catch (rtdbError) {
98
+ ctx.logger.error("Realtime DB push failed (non-fatal)", rtdbError);
99
+ }
100
+ if (config.sendEmail) {
101
+ const apiKey = ctx.env("RESEND_API_KEY") ?? "";
102
+ if (!apiKey) {
103
+ ctx.logger.error(JOB_ERROR_MESSAGES.RESEND_KEY_MISSING, null);
104
+ }
105
+ else {
106
+ try {
107
+ const fromAddress = ctx.env("ORDER_EMAIL_FROM") ?? ctx.env("RESEND_FROM_ADDRESS") ?? "";
108
+ const brandName = ctx.env("APPKIT_BRAND_NAME") ?? "";
109
+ if (!fromAddress || !brandName) {
110
+ ctx.logger.error("ORDER_EMAIL_FROM / APPKIT_BRAND_NAME not configured — skipping order status email", null, { orderId });
111
+ }
112
+ else {
113
+ await sendResendEmail({
114
+ to: userEmail,
115
+ status: newStatus,
116
+ orderId,
117
+ productTitle: after.productTitle,
118
+ trackingNumber: after.trackingNumber,
119
+ apiKey,
120
+ fromAddress,
121
+ brandName,
122
+ });
123
+ }
124
+ }
125
+ catch (emailError) {
126
+ ctx.logger.error("Email send failed (non-fatal)", emailError, { orderId });
127
+ }
128
+ }
129
+ }
130
+ ctx.logger.info(`Order ${orderId} status → ${newStatus}`, {
131
+ userId: after.userId,
132
+ emailSent: config.sendEmail,
133
+ });
134
+ }
135
+ catch (error) {
136
+ ctx.logger.error("Error handling order status change", error, { orderId });
137
+ throw error;
138
+ }
139
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Core: SB-UNI-V product stock-change reaction.
3
+ *
4
+ * Looks up every bundle category (categoryType:"bundle") that lists the
5
+ * product in `bundleProductIds[]` and recomputes its `bundleStockStatus`.
6
+ * Also updates every grouped listing that lists the product in `productIds[]`
7
+ * — bumps `activeMemberCount` and `visibilityStatus`.
8
+ *
9
+ * Cheap: each affected bundle/group reads its `bundleProductIds.length`
10
+ * member products (≤16 typically). Caller should skip when the product's
11
+ * status didn't transition between "available" and "unavailable".
12
+ */
13
+ import type { JobContext } from "../runtime/types";
14
+ export declare function isAvailable(status?: string | null): boolean;
15
+ export declare function syncBundlesForProduct(productId: string, ctx: JobContext): Promise<number>;
16
+ export declare function syncGroupedListingsForProduct(productId: string, ctx: JobContext): Promise<number>;
17
+ export interface HandleProductStockChangeInput {
18
+ productId: string;
19
+ beforeStatus: string | null;
20
+ afterStatus: string | null;
21
+ isDelete: boolean;
22
+ }
23
+ export declare function handleProductStockChange(input: HandleProductStockChangeInput, ctx: JobContext): Promise<void>;
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Core: SB-UNI-V product stock-change reaction.
3
+ *
4
+ * Looks up every bundle category (categoryType:"bundle") that lists the
5
+ * product in `bundleProductIds[]` and recomputes its `bundleStockStatus`.
6
+ * Also updates every grouped listing that lists the product in `productIds[]`
7
+ * — bumps `activeMemberCount` and `visibilityStatus`.
8
+ *
9
+ * Cheap: each affected bundle/group reads its `bundleProductIds.length`
10
+ * member products (≤16 typically). Caller should skip when the product's
11
+ * status didn't transition between "available" and "unavailable".
12
+ */
13
+ const CATEGORIES_COLLECTION = "categories";
14
+ const GROUPED_LISTINGS_COLLECTION = "groupedListings";
15
+ const PRODUCT_COLLECTION = "products";
16
+ const UNAVAILABLE_STATUSES = new Set(["sold", "out_of_stock", "discontinued"]);
17
+ const MIN_ACTIVE_DEFAULT = 2;
18
+ export function isAvailable(status) {
19
+ if (!status)
20
+ return false;
21
+ return !UNAVAILABLE_STATUSES.has(status);
22
+ }
23
+ async function recomputeBundleStatus(productIds, minActive, ctx) {
24
+ if (productIds.length === 0)
25
+ return "out_of_stock";
26
+ let unavailable = 0;
27
+ for (let i = 0; i < productIds.length; i += 30) {
28
+ const chunk = productIds.slice(i, i + 30);
29
+ const snap = await ctx.db
30
+ .collection(PRODUCT_COLLECTION)
31
+ .where("__name__", "in", chunk)
32
+ .get();
33
+ for (const doc of snap.docs) {
34
+ const status = doc.data().status;
35
+ if (!isAvailable(status))
36
+ unavailable++;
37
+ }
38
+ if (snap.size < chunk.length)
39
+ unavailable += chunk.length - snap.size;
40
+ }
41
+ const active = productIds.length - unavailable;
42
+ if (unavailable === 0)
43
+ return "in_stock";
44
+ if (active < minActive)
45
+ return "out_of_stock";
46
+ return "partial";
47
+ }
48
+ export async function syncBundlesForProduct(productId, ctx) {
49
+ const snap = await ctx.db
50
+ .collection(CATEGORIES_COLLECTION)
51
+ .where("categoryType", "==", "bundle")
52
+ .where("bundleProductIds", "array-contains", productId)
53
+ .get();
54
+ let updated = 0;
55
+ for (const bundleDoc of snap.docs) {
56
+ const data = bundleDoc.data();
57
+ const ids = data.bundleProductIds ?? [];
58
+ const minActive = data.minActiveMembers ?? 1;
59
+ const next = await recomputeBundleStatus(ids, minActive, ctx);
60
+ if (next !== data.bundleStockStatus) {
61
+ await bundleDoc.ref.update({
62
+ bundleStockStatus: next,
63
+ bundleQueryResolvedAt: ctx.now,
64
+ updatedAt: ctx.now,
65
+ });
66
+ updated++;
67
+ }
68
+ }
69
+ return updated;
70
+ }
71
+ export async function syncGroupedListingsForProduct(productId, ctx) {
72
+ const snap = await ctx.db
73
+ .collection(GROUPED_LISTINGS_COLLECTION)
74
+ .where("productIds", "array-contains", productId)
75
+ .get();
76
+ let updated = 0;
77
+ for (const groupDoc of snap.docs) {
78
+ const data = groupDoc.data();
79
+ const productIds = data.productIds ?? [];
80
+ if (productIds.length === 0)
81
+ continue;
82
+ const minActive = data.minActiveMembers ?? MIN_ACTIVE_DEFAULT;
83
+ let activeCount = 0;
84
+ for (let i = 0; i < productIds.length; i += 30) {
85
+ const chunk = productIds.slice(i, i + 30);
86
+ const productSnap = await ctx.db
87
+ .collection(PRODUCT_COLLECTION)
88
+ .where("__name__", "in", chunk)
89
+ .get();
90
+ for (const doc of productSnap.docs) {
91
+ const status = doc.data().status;
92
+ if (isAvailable(status))
93
+ activeCount++;
94
+ }
95
+ }
96
+ const nextVisibility = activeCount >= minActive ? "visible" : "hidden";
97
+ if (activeCount !== data.activeMemberCount ||
98
+ nextVisibility !== data.visibilityStatus) {
99
+ await groupDoc.ref.update({
100
+ activeMemberCount: activeCount,
101
+ visibilityStatus: nextVisibility,
102
+ updatedAt: ctx.now,
103
+ });
104
+ updated++;
105
+ }
106
+ }
107
+ return updated;
108
+ }
109
+ export async function handleProductStockChange(input, ctx) {
110
+ const { productId, beforeStatus, afterStatus, isDelete } = input;
111
+ const beforeAvailable = isAvailable(beforeStatus);
112
+ const afterAvailable = isAvailable(afterStatus);
113
+ const stateFlipped = beforeAvailable !== afterAvailable;
114
+ if (!isDelete && !stateFlipped) {
115
+ return;
116
+ }
117
+ try {
118
+ const bundlesUpdated = await syncBundlesForProduct(productId, ctx);
119
+ const groupsUpdated = await syncGroupedListingsForProduct(productId, ctx);
120
+ ctx.logger.info("onProductStockChange synced", {
121
+ productId,
122
+ bundlesUpdated,
123
+ groupsUpdated,
124
+ isDelete,
125
+ });
126
+ }
127
+ catch (err) {
128
+ ctx.logger.error("onProductStockChange sync failed (non-fatal)", err, { productId });
129
+ }
130
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Core: keep category metrics + store stats in sync when a product document
3
+ * is written. Only published products count.
4
+ */
5
+ import type { JobContext } from "../runtime/types";
6
+ export type ProductDoc = Record<string, unknown>;
7
+ export interface HandleProductWriteInput {
8
+ productId: string;
9
+ before: ProductDoc | null;
10
+ after: ProductDoc | null;
11
+ }
12
+ export declare function handleProductWrite(input: HandleProductWriteInput, ctx: JobContext): Promise<void>;
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Core: keep category metrics + store stats in sync when a product document
3
+ * is written. Only published products count.
4
+ */
5
+ import { categoriesRepository, storeRepository, } from "../../../../repositories";
6
+ import { ProductStatusValues } from "../../../../features/products/schemas/firestore";
7
+ const UNAVAILABLE_PRODUCT_STATUSES = new Set([
8
+ ProductStatusValues.SOLD,
9
+ ProductStatusValues.OUT_OF_STOCK,
10
+ ProductStatusValues.DISCONTINUED,
11
+ ]);
12
+ void UNAVAILABLE_PRODUCT_STATUSES;
13
+ async function getParentIds(categoryId) {
14
+ if (!categoryId)
15
+ return [];
16
+ return (await categoriesRepository.findById(categoryId))?.parentIds ?? [];
17
+ }
18
+ export async function handleProductWrite(input, ctx) {
19
+ const { productId, before, after } = input;
20
+ const beforeStatus = before?.status ?? null;
21
+ const afterStatus = after?.status ?? null;
22
+ const beforeCategory = before?.category ?? null;
23
+ const afterCategory = after?.category ?? null;
24
+ const beforeStoreId = (before?.storeId || before?.sellerId) ?? null;
25
+ const afterStoreId = (after?.storeId || after?.sellerId) ?? null;
26
+ const isAuction = after?.listingType === "auction";
27
+ const beforeIsAuction = before?.listingType === "auction";
28
+ const wasPublished = beforeStatus === ProductStatusValues.PUBLISHED;
29
+ const isPublished = afterStatus === ProductStatusValues.PUBLISHED;
30
+ const isDelete = !after;
31
+ try {
32
+ if (isDelete && wasPublished && beforeCategory) {
33
+ const parentIds = await getParentIds(beforeCategory);
34
+ const batch = ctx.db.batch();
35
+ categoriesRepository.updateMetricsInBatch(batch, beforeCategory, parentIds, beforeIsAuction ? 0 : -1, beforeIsAuction ? -1 : 0, productId);
36
+ await batch.commit();
37
+ if (beforeStoreId)
38
+ await storeRepository.incrementTotalProducts(beforeStoreId, -1);
39
+ ctx.logger.info("Decremented counters on hard-delete", {
40
+ productId,
41
+ category: beforeCategory,
42
+ storeId: beforeStoreId,
43
+ });
44
+ }
45
+ else if (!wasPublished && isPublished && afterCategory) {
46
+ const parentIds = await getParentIds(afterCategory);
47
+ const batch = ctx.db.batch();
48
+ categoriesRepository.updateMetricsInBatch(batch, afterCategory, parentIds, isAuction ? 0 : 1, isAuction ? 1 : 0, productId);
49
+ await batch.commit();
50
+ if (afterStoreId)
51
+ await storeRepository.incrementTotalProducts(afterStoreId, 1);
52
+ ctx.logger.info("Incremented counters on publish", {
53
+ productId,
54
+ category: afterCategory,
55
+ storeId: afterStoreId,
56
+ });
57
+ }
58
+ else if (wasPublished && !isPublished && beforeCategory) {
59
+ const parentIds = await getParentIds(beforeCategory);
60
+ const batch = ctx.db.batch();
61
+ categoriesRepository.updateMetricsInBatch(batch, beforeCategory, parentIds, beforeIsAuction ? 0 : -1, beforeIsAuction ? -1 : 0, productId);
62
+ await batch.commit();
63
+ if (beforeStoreId)
64
+ await storeRepository.incrementTotalProducts(beforeStoreId, -1);
65
+ ctx.logger.info("Decremented counters on unpublish", {
66
+ productId,
67
+ category: beforeCategory,
68
+ storeId: beforeStoreId,
69
+ });
70
+ }
71
+ else if (wasPublished &&
72
+ isPublished &&
73
+ beforeCategory &&
74
+ afterCategory &&
75
+ beforeCategory !== afterCategory) {
76
+ const [beforeParents, afterParents] = await Promise.all([
77
+ getParentIds(beforeCategory),
78
+ getParentIds(afterCategory),
79
+ ]);
80
+ const batch = ctx.db.batch();
81
+ categoriesRepository.updateMetricsInBatch(batch, beforeCategory, beforeParents, beforeIsAuction ? 0 : -1, beforeIsAuction ? -1 : 0, productId);
82
+ categoriesRepository.updateMetricsInBatch(batch, afterCategory, afterParents, isAuction ? 0 : 1, isAuction ? 1 : 0, productId);
83
+ await batch.commit();
84
+ ctx.logger.info("Moved product between categories", {
85
+ productId,
86
+ from: beforeCategory,
87
+ to: afterCategory,
88
+ });
89
+ }
90
+ }
91
+ catch (err) {
92
+ ctx.logger.error("Counter update failed (non-fatal)", err, { productId });
93
+ }
94
+ }
@@ -0,0 +1,7 @@
1
+ import type { JobContext } from "../runtime/types";
2
+ export interface HandleReviewWriteInput {
3
+ reviewId: string;
4
+ before: Record<string, unknown> | null;
5
+ after: Record<string, unknown> | null;
6
+ }
7
+ export declare function handleReviewWrite(input: HandleReviewWriteInput, ctx: JobContext): Promise<void>;
@@ -0,0 +1,49 @@
1
+ import { reviewRepository, storeRepository } from "../../../../repositories";
2
+ import { ReviewStatusValues } from "../../../../features/reviews/schemas/firestore";
3
+ import { PRODUCT_COLLECTION } from "../../../../features/products/schemas/firestore";
4
+ export async function handleReviewWrite(input, ctx) {
5
+ const { reviewId, before: beforeData, after: afterData } = input;
6
+ const beforeStatus = beforeData?.status ?? null;
7
+ const afterStatus = afterData?.status ?? null;
8
+ const wasApproved = beforeStatus === ReviewStatusValues.APPROVED;
9
+ const isApproved = afterStatus === ReviewStatusValues.APPROVED;
10
+ if (!wasApproved && !isApproved)
11
+ return;
12
+ const data = afterData ?? beforeData;
13
+ if (!data)
14
+ return;
15
+ const productId = data.productId ?? null;
16
+ const storeId = data.storeId ?? null;
17
+ if (!productId) {
18
+ ctx.logger.error("Review has no productId — skipping", null, { reviewId });
19
+ return;
20
+ }
21
+ try {
22
+ const { count, avgRating } = await reviewRepository.getApprovedRatingAggregate(productId);
23
+ await ctx.db.collection(PRODUCT_COLLECTION).doc(productId).update({
24
+ avgRating,
25
+ reviewCount: count,
26
+ updatedAt: new Date(),
27
+ });
28
+ ctx.logger.info("Updated product rating stats", {
29
+ reviewId,
30
+ productId,
31
+ count,
32
+ avgRating,
33
+ });
34
+ if (storeId) {
35
+ const storeStats = await reviewRepository.getApprovedRatingAggregateByStore(storeId);
36
+ await storeRepository.updateReviewStats(storeId, storeStats.count, storeStats.avgRating);
37
+ ctx.logger.info("Updated store review stats", {
38
+ reviewId,
39
+ storeId,
40
+ count: storeStats.count,
41
+ avgRating: storeStats.avgRating,
42
+ });
43
+ }
44
+ }
45
+ catch (err) {
46
+ ctx.logger.error("Failed to update rating stats", err, { reviewId, productId, storeId });
47
+ throw err;
48
+ }
49
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Core: stores/{id} onWrite — currently a no-op. Previous implementation
3
+ * synced an external search index that has since been removed.
4
+ */
5
+ import type { JobContext } from "../runtime/types";
6
+ export type StoreDoc = Record<string, unknown>;
7
+ export interface HandleStoreWriteInput {
8
+ storeId: string;
9
+ before: StoreDoc | null;
10
+ after: StoreDoc | null;
11
+ }
12
+ export declare function handleStoreWrite(_input: HandleStoreWriteInput, _ctx: JobContext): Promise<void>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Core: stores/{id} onWrite — currently a no-op. Previous implementation
3
+ * synced an external search index that has since been removed.
4
+ */
5
+ export async function handleStoreWrite(_input, _ctx) {
6
+ // Intentionally empty — search provider removed; Firestore queries handle search now.
7
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Core: dispatch pending payouts via Razorpay Payouts API.
3
+ *
4
+ * Reads RAZORPAY_KEY_ID / RAZORPAY_KEY_SECRET / RAZORPAY_ACCOUNT_NUMBER from
5
+ * env (via `ctx.env`). On 3rd consecutive failure the record is marked failed.
6
+ */
7
+ import type { JobContext } from "../runtime/types";
8
+ export declare function runPayoutBatch(ctx: JobContext): Promise<void>;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Core: dispatch pending payouts via Razorpay Payouts API.
3
+ *
4
+ * Reads RAZORPAY_KEY_ID / RAZORPAY_KEY_SECRET / RAZORPAY_ACCOUNT_NUMBER from
5
+ * env (via `ctx.env`). On 3rd consecutive failure the record is marked failed.
6
+ */
7
+ import { payoutRepository } from "../../../../repositories";
8
+ const MAX_FAILURES = 3;
9
+ async function dispatch(ctx, entry) {
10
+ const { ref, data: payout } = entry;
11
+ await payoutRepository.markProcessing(ref);
12
+ try {
13
+ const keyId = ctx.env("RAZORPAY_KEY_ID") ?? "";
14
+ const keySecret = ctx.env("RAZORPAY_KEY_SECRET") ?? "";
15
+ const accountNumber = ctx.env("RAZORPAY_ACCOUNT_NUMBER") ?? "";
16
+ const apiBaseUrl = ctx.env("RAZORPAY_API_BASE_URL") ?? "https://api.razorpay.com/v1";
17
+ const brandName = ctx.env("APP_BRAND_NAME") ?? "";
18
+ if (!keyId || !keySecret || !accountNumber) {
19
+ throw new Error("Razorpay credentials not configured");
20
+ }
21
+ const basicAuth = Buffer.from(`${keyId}:${keySecret}`).toString("base64");
22
+ let fundAccount;
23
+ if (payout.paymentMethod === "upi" && payout.upiId) {
24
+ fundAccount = { account_type: "vpa", vpa: { address: payout.upiId } };
25
+ }
26
+ else if (payout.bankAccount) {
27
+ fundAccount = {
28
+ account_type: "bank_account",
29
+ bank_account: {
30
+ name: payout.bankAccount.accountHolderName,
31
+ ifsc: payout.bankAccount.ifscCode,
32
+ account_number: payout.bankAccount.accountNumberMasked,
33
+ },
34
+ };
35
+ }
36
+ else {
37
+ throw new Error("Payout has no fund account configured");
38
+ }
39
+ const payload = {
40
+ account_number: accountNumber,
41
+ fund_account: {
42
+ ...fundAccount,
43
+ contact: { name: payout.sellerEmail, type: "vendor", email: payout.sellerEmail },
44
+ },
45
+ // Use netAmount when refund deductions have been applied, otherwise gross amount.
46
+ amount: Math.round((payout.netAmount ?? payout.amount) * 100),
47
+ currency: payout.currency.toUpperCase(),
48
+ mode: payout.paymentMethod === "upi" ? "UPI" : "NEFT",
49
+ purpose: "payout",
50
+ reference_id: payout.id,
51
+ narration: brandName
52
+ ? `${brandName} payout for seller ${payout.storeId}`
53
+ : `Payout for seller ${payout.storeId}`,
54
+ };
55
+ const response = await fetch(`${apiBaseUrl}/payouts`, {
56
+ method: "POST",
57
+ headers: {
58
+ Authorization: `Basic ${basicAuth}`,
59
+ "Content-Type": "application/json",
60
+ "X-Payout-Idempotency": payout.id,
61
+ },
62
+ body: JSON.stringify(payload),
63
+ });
64
+ if (!response.ok) {
65
+ const errBody = await response.text();
66
+ throw new Error(`Razorpay ${response.status}: ${errBody}`);
67
+ }
68
+ const result = (await response.json());
69
+ await payoutRepository.recordSuccess(ref, result.id, result.status);
70
+ ctx.logger.info(`Payout ${payout.id} dispatched`, { razorpayId: result.id, razorpayStatus: result.status });
71
+ }
72
+ catch (error) {
73
+ const failureCount = (payout.failureCount ?? 0) + 1;
74
+ const isFinal = failureCount >= MAX_FAILURES;
75
+ const reason = error instanceof Error ? error.message : String(error);
76
+ await payoutRepository.recordFailure(ref, failureCount, reason, isFinal);
77
+ if (isFinal) {
78
+ ctx.logger.error(`Payout ${payout.id} permanently failed after ${MAX_FAILURES} attempts`, error, {
79
+ sellerId: payout.storeId,
80
+ });
81
+ }
82
+ else {
83
+ ctx.logger.warn(`Payout ${payout.id} failed (attempt ${failureCount})`, { error: reason });
84
+ }
85
+ }
86
+ }
87
+ export async function runPayoutBatch(ctx) {
88
+ ctx.logger.info("Starting payout batch sweep");
89
+ const pending = await payoutRepository.getPending();
90
+ if (pending.length === 0) {
91
+ ctx.logger.info("No pending payouts to process");
92
+ return;
93
+ }
94
+ ctx.logger.info(`Dispatching ${pending.length} payout(s)`);
95
+ const results = await Promise.allSettled(pending.map((entry) => dispatch(ctx, entry)));
96
+ const failed = results.filter((r) => r.status === "rejected").length;
97
+ ctx.logger.info("Payout batch complete", {
98
+ total: pending.length,
99
+ succeeded: pending.length - failed,
100
+ failed,
101
+ });
102
+ }
@@ -0,0 +1,2 @@
1
+ import type { JobContext } from "../runtime/types";
2
+ export declare function runPendingOrderTimeout(ctx: JobContext): Promise<void>;
@@ -0,0 +1,27 @@
1
+ import { notificationRepository, orderRepository } from "../../../../repositories";
2
+ import { ORDER_MESSAGES } from "../handlers/messages";
3
+ const DEFAULT_TIMEOUT_HOURS = 24;
4
+ export async function runPendingOrderTimeout(ctx) {
5
+ const timeoutHours = Number(ctx.env("ORDER_TIMEOUT_HOURS") ?? DEFAULT_TIMEOUT_HOURS);
6
+ ctx.logger.info(`Scanning orders unpaid > ${timeoutHours}h`);
7
+ const timedOut = await orderRepository.getTimedOutPending(timeoutHours);
8
+ if (timedOut.length === 0) {
9
+ ctx.logger.info("No timed-out pending orders found");
10
+ return;
11
+ }
12
+ const batch = ctx.db.batch();
13
+ for (const entry of timedOut) {
14
+ orderRepository.cancelInBatch(batch, entry.ref);
15
+ notificationRepository.createInBatch(batch, {
16
+ userId: entry.data.userId,
17
+ type: "order_cancelled",
18
+ priority: "normal",
19
+ title: ORDER_MESSAGES.CANCELLED_TITLE,
20
+ message: ORDER_MESSAGES.CANCELLED_TIMEOUT_MESSAGE(entry.data.productTitle, timeoutHours),
21
+ relatedId: entry.data.id,
22
+ relatedType: "order",
23
+ });
24
+ }
25
+ await batch.commit();
26
+ ctx.logger.info("Pending order timeout complete", { cancelled: timedOut.length });
27
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Core: rebuild `position` + `subtreeSize` for every category via
3
+ * DFS pre-order from the roots. Heals drift left by the trigger's
4
+ * `positionDirty` flag and any failed real-time updates.
5
+ */
6
+ import type { JobContext } from "../runtime/types";
7
+ export declare function runPositionsReconcile(ctx: JobContext): Promise<void>;