@mohasinac/appkit 4.53.2 → 4.54.1

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 (350) hide show
  1. package/dist/.build-stamp.json +3 -3
  2. package/dist/_internal/server/features/auth/capabilities.js +7 -5
  3. package/dist/_internal/server/features/checkout/actions.d.ts +22 -6
  4. package/dist/_internal/server/features/checkout/actions.js +96 -51
  5. package/dist/_internal/server/features/checkout/index.d.ts +1 -1
  6. package/dist/_internal/server/features/checkout/index.js +1 -1
  7. package/dist/_internal/server/features/checkout/supplier-identity.js +28 -6
  8. package/dist/_internal/server/features/orders/adapters.js +1 -3
  9. package/dist/_internal/server/features/products/listing-tab-counts.js +81 -25
  10. package/dist/_internal/server/features/search/index-build/sources.js +43 -2
  11. package/dist/_internal/server/features/site-settings/adapters.js +1 -1
  12. package/dist/_internal/server/features/stores/adapters.d.ts +1 -1
  13. package/dist/_internal/server/features/stores/adapters.js +0 -1
  14. package/dist/_internal/server/jobs/core/analyticsAlertEvaluate.js +2 -5
  15. package/dist/_internal/server/jobs/core/jobRunners.js +0 -10
  16. package/dist/_internal/server/jobs/core/onOrderCreate.js +10 -104
  17. package/dist/_internal/server/jobs/core/onOrderStatusChange.d.ts +0 -2
  18. package/dist/_internal/server/jobs/core/onOrderStatusChange.js +0 -1
  19. package/dist/_internal/server/jobs/core/onScamReportCreate.js +0 -1
  20. package/dist/_internal/server/jobs/core/onScamReportRejected.js +0 -1
  21. package/dist/_internal/server/jobs/core/onScamReportVerified.js +0 -1
  22. package/dist/_internal/server/jobs/core/paymentWindowTimeout.js +0 -1
  23. package/dist/_internal/server/jobs/core/pendingOrderTimeout.js +0 -1
  24. package/dist/_internal/server/notifications/channel-health.d.ts +7 -3
  25. package/dist/_internal/server/notifications/channel-health.js +2 -2
  26. package/dist/_internal/server/notifications/send-guard.d.ts +1 -1
  27. package/dist/_internal/server/notifications/send-guard.js +2 -4
  28. package/dist/_internal/shared/actions/action-registry.d.ts +1 -1
  29. package/dist/_internal/shared/actions/action-registry.js +128 -28
  30. package/dist/_internal/shared/checkout/order-math.d.ts +1 -1
  31. package/dist/_internal/shared/checkout/order-math.js +1 -1
  32. package/dist/_internal/shared/features/categories/bundle-copy.d.ts +1 -1
  33. package/dist/_internal/shared/features/checkout/config.d.ts +0 -2
  34. package/dist/_internal/shared/features/checkout/config.js +0 -2
  35. package/dist/_internal/shared/features/messaging/config.d.ts +7 -5
  36. package/dist/_internal/shared/features/messaging/config.js +1 -4
  37. package/dist/_internal/shared/features/site-settings/fees.d.ts +0 -2
  38. package/dist/_internal/shared/features/site-settings/fees.js +0 -2
  39. package/dist/_internal/shared/features/site-settings/supplier-of-record.d.ts +56 -0
  40. package/dist/_internal/shared/features/site-settings/supplier-of-record.js +57 -0
  41. package/dist/_internal/shared/fees/calculator.d.ts +0 -8
  42. package/dist/_internal/shared/fees/calculator.js +0 -7
  43. package/dist/_internal/shared/listing-types/tiers.d.ts +94 -0
  44. package/dist/_internal/shared/listing-types/tiers.js +150 -0
  45. package/dist/cli/index.js +0 -2
  46. package/dist/client.d.ts +25 -4
  47. package/dist/client.js +36 -5
  48. package/dist/constants/api-endpoints.d.ts +21 -15
  49. package/dist/constants/api-endpoints.js +7 -8
  50. package/dist/constants/field-names.d.ts +1 -0
  51. package/dist/constants/field-names.js +1 -0
  52. package/dist/constants/notification-types.d.ts +1 -1
  53. package/dist/constants/notification-types.js +1 -1
  54. package/dist/core/integration-keys.d.ts +5 -5
  55. package/dist/core/integration-keys.js +21 -10
  56. package/dist/features/about/components/FeesView.js +0 -6
  57. package/dist/features/about/components/GuidesHubView.js +15 -2
  58. package/dist/features/account/components/NotificationPreferencesPanel.js +3 -4
  59. package/dist/features/account/components/UserOrdersView.js +26 -7
  60. package/dist/features/account/types/index.d.ts +0 -2
  61. package/dist/features/addresses/utils/postal-autofill.d.ts +39 -0
  62. package/dist/features/addresses/utils/postal-autofill.js +54 -0
  63. package/dist/features/admin/actions/notification-actions.d.ts +2 -8
  64. package/dist/features/admin/actions/notification-actions.js +9 -104
  65. package/dist/features/admin/components/AdminGuideHubView.js +1 -8
  66. package/dist/features/admin/components/AdminOrderEditorView.d.ts +1 -1
  67. package/dist/features/admin/components/AdminOrdersView.js +0 -2
  68. package/dist/features/admin/components/AdminSectionsView.js +3 -2
  69. package/dist/features/admin/components/AdminSiteSettingsView.js +22 -68
  70. package/dist/features/admin/components/AdminStoreEditorView.js +72 -34
  71. package/dist/features/admin/components/OwnerQuickActions.d.ts +29 -0
  72. package/dist/features/admin/components/OwnerQuickActions.js +142 -0
  73. package/dist/features/admin/components/sections/adminSectionsTypes.js +13 -4
  74. package/dist/features/admin/components/sections/icon-options.d.ts +21 -0
  75. package/dist/features/admin/components/sections/icon-options.js +23 -0
  76. package/dist/features/admin/components/sections/sectionTemplates.js +4 -1
  77. package/dist/features/admin/constants/site-settings-tabs.d.ts +7 -12
  78. package/dist/features/admin/constants/site-settings-tabs.js +6 -12
  79. package/dist/features/admin/repository/site-settings.repository.js +1 -1
  80. package/dist/features/admin/schemas/admin-editor-forms.d.ts +1 -1
  81. package/dist/features/admin/schemas/admin-editor-forms.js +4 -1
  82. package/dist/features/admin/schemas/admin-user-form.d.ts +0 -61
  83. package/dist/features/admin/schemas/admin-user-form.js +3 -44
  84. package/dist/features/admin/schemas/firestore.d.ts +28 -54
  85. package/dist/features/admin/schemas/firestore.js +40 -18
  86. package/dist/features/auctions/components/AuctionDetailPageView.js +4 -3
  87. package/dist/features/auctions/components/MarketplaceAuctionCard.d.ts +11 -1
  88. package/dist/features/auctions/components/MarketplaceAuctionCard.js +9 -2
  89. package/dist/features/auth/checkout-value-otp.d.ts +1 -1
  90. package/dist/features/auth/checkout-value-otp.js +1 -1
  91. package/dist/features/auth/permissions/constants.d.ts +29 -2
  92. package/dist/features/auth/permissions/constants.js +67 -1
  93. package/dist/features/blog/components/BlogFeaturedCard.d.ts +11 -1
  94. package/dist/features/blog/components/BlogFeaturedCard.js +9 -2
  95. package/dist/features/cart/components/CartDrawer.js +3 -2
  96. package/dist/features/cart/components/CartGroupLineRow.js +2 -1
  97. package/dist/features/cart/components/CartPriceBreakdown.d.ts +0 -2
  98. package/dist/features/cart/components/CartPriceBreakdown.js +1 -1
  99. package/dist/features/cart/components/StoreAddonsPicker.d.ts +2 -5
  100. package/dist/features/cart/components/StoreAddonsPicker.js +4 -5
  101. package/dist/features/cart/hooks/useAddToCart.js +10 -5
  102. package/dist/features/cart/repository/cart.repository.js +1 -2
  103. package/dist/features/cart/schemas/firestore.d.ts +1 -2
  104. package/dist/features/cart/utils/pending-ops.d.ts +11 -1
  105. package/dist/features/cart/utils/pending-ops.js +14 -2
  106. package/dist/features/categories/components/BrandDetailPageView.js +2 -1
  107. package/dist/features/categories/components/BundleDetailView.js +2 -1
  108. package/dist/features/categories/components/CategoryDetailPageView.js +2 -1
  109. package/dist/features/categories/components/CategoryGrid.d.ts +11 -1
  110. package/dist/features/categories/components/CategoryGrid.js +9 -2
  111. package/dist/features/checkout/actions/checkout-value-otp-actions.d.ts +10 -5
  112. package/dist/features/checkout/actions/checkout-value-otp-actions.js +2 -88
  113. package/dist/features/classified/components/ClassifiedDetailPageView.js +2 -1
  114. package/dist/features/digital-codes/components/DigitalCodeDetailPageView.js +2 -1
  115. package/dist/features/events/components/EventCard.d.ts +11 -1
  116. package/dist/features/events/components/EventCard.js +9 -2
  117. package/dist/features/grouped/components/GroupedListingDetailView.js +3 -1
  118. package/dist/features/homepage/components/CTABannerSection.d.ts +3 -1
  119. package/dist/features/homepage/components/CTABannerSection.js +6 -3
  120. package/dist/features/homepage/components/HeroCarousel.js +8 -6
  121. package/dist/features/homepage/components/MarketplaceHomepageView.js +33 -7
  122. package/dist/features/homepage/components/SectionCarousel.js +13 -5
  123. package/dist/features/homepage/components/SecurityHighlightsSection.d.ts +8 -3
  124. package/dist/features/homepage/components/SecurityHighlightsSection.js +2 -2
  125. package/dist/features/homepage/components/StatsCounterSection.d.ts +9 -4
  126. package/dist/features/homepage/components/StatsCounterSection.js +2 -2
  127. package/dist/features/homepage/components/TestimonialsCarousel.js +1 -1
  128. package/dist/features/homepage/components/TrustFeaturesSection.d.ts +18 -4
  129. package/dist/features/homepage/components/TrustFeaturesSection.js +5 -5
  130. package/dist/features/homepage/components/WelcomeSection.d.ts +13 -2
  131. package/dist/features/homepage/components/WelcomeSection.js +3 -3
  132. package/dist/features/homepage/components/WhatsAppCommunitySection.d.ts +28 -0
  133. package/dist/features/homepage/components/WhatsAppCommunitySection.js +42 -6
  134. package/dist/features/homepage/components/WhatsAppGlyph.d.ts +20 -0
  135. package/dist/features/homepage/components/WhatsAppGlyph.js +20 -0
  136. package/dist/features/homepage/constants/hero-carousel-styles.d.ts +8 -6
  137. package/dist/features/homepage/constants/hero-carousel-styles.js +8 -6
  138. package/dist/features/homepage/constants/section-copy.d.ts +12 -10
  139. package/dist/features/homepage/constants/section-copy.js +28 -6
  140. package/dist/features/homepage/constants/stat-icons.d.ts +12 -0
  141. package/dist/features/homepage/constants/stat-icons.js +17 -0
  142. package/dist/features/homepage/constants/trust-icon-aliases.d.ts +8 -0
  143. package/dist/features/homepage/constants/trust-icon-aliases.js +75 -0
  144. package/dist/features/homepage/lib/section-defaults.d.ts +16 -1
  145. package/dist/features/homepage/lib/section-defaults.js +24 -4
  146. package/dist/features/homepage/lib/section-renderer.js +48 -8
  147. package/dist/features/homepage/schemas/firestore.d.ts +18 -1
  148. package/dist/features/layout/AppLayoutShell.js +2 -1
  149. package/dist/features/layout/BottomActions.d.ts +1 -0
  150. package/dist/features/layout/BottomActions.js +330 -0
  151. package/dist/features/layout/BottomChrome.d.ts +45 -0
  152. package/dist/features/layout/BottomChrome.js +5 -17
  153. package/dist/features/layout/SideActionDock.js +36 -13
  154. package/dist/features/layout/index.d.ts +2 -7
  155. package/dist/features/layout/index.js +7 -7
  156. package/dist/features/layout/useIsDesktop.d.ts +36 -0
  157. package/dist/features/layout/useIsDesktop.js +48 -0
  158. package/dist/features/live/components/LiveItemDetailPageView.js +2 -1
  159. package/dist/features/orders/actions/refund-actions.js +0 -1
  160. package/dist/features/orders/components/OrderAddonBadges.d.ts +1 -3
  161. package/dist/features/orders/components/OrderAddonBadges.js +3 -4
  162. package/dist/features/orders/components/OrderPaymentSummary.js +15 -2
  163. package/dist/features/orders/components/YourPurchaseStrip.d.ts +24 -0
  164. package/dist/features/orders/components/YourPurchaseStrip.js +77 -0
  165. package/dist/features/orders/components/index.d.ts +2 -1
  166. package/dist/features/orders/components/index.js +1 -1
  167. package/dist/features/orders/repository/orders.repository.d.ts +0 -8
  168. package/dist/features/orders/repository/orders.repository.js +0 -2
  169. package/dist/features/orders/schemas/firestore.d.ts +17 -9
  170. package/dist/features/orders/types/index.d.ts +2 -5
  171. package/dist/features/orders/utils/order-announcement-message.d.ts +18 -0
  172. package/dist/features/orders/utils/order-announcement-message.js +16 -0
  173. package/dist/features/orders/utils/payment-proof-message.d.ts +20 -0
  174. package/dist/features/orders/utils/payment-proof-message.js +17 -0
  175. package/dist/features/parts/components/PartDetailPageView.js +96 -1
  176. package/dist/features/parts/schemas/firestore.d.ts +247 -0
  177. package/dist/features/parts/schemas/firestore.js +6 -6
  178. package/dist/features/pre-orders/components/MarketplacePreorderCard.d.ts +11 -1
  179. package/dist/features/pre-orders/components/MarketplacePreorderCard.js +10 -3
  180. package/dist/features/pre-orders/components/PreOrderDetailPageView.js +4 -3
  181. package/dist/features/products/api/[id]/route.js +8 -1
  182. package/dist/features/products/api/route.js +16 -4
  183. package/dist/features/products/components/AvailabilityScopeHint.js +1 -1
  184. package/dist/features/products/components/InteractiveProductCard.d.ts +7 -1
  185. package/dist/features/products/components/InteractiveProductCard.js +16 -4
  186. package/dist/features/products/components/MarketplaceBundleCard.d.ts +11 -1
  187. package/dist/features/products/components/MarketplaceBundleCard.js +9 -2
  188. package/dist/features/products/components/MarketplacePrizeDrawCard.d.ts +11 -1
  189. package/dist/features/products/components/MarketplacePrizeDrawCard.js +9 -2
  190. package/dist/features/products/components/PrizeDrawDetailPageView.js +2 -1
  191. package/dist/features/products/components/ProductDetailPageView.js +27 -2
  192. package/dist/features/products/components/ProductGrid.d.ts +14 -1
  193. package/dist/features/products/components/ProductGrid.js +22 -5
  194. package/dist/features/products/components/ProductsIndexListing.js +2 -2
  195. package/dist/features/reviews/api/[id]/route.js +83 -23
  196. package/dist/features/reviews/components/PurchaseReviewAffordance.d.ts +6 -0
  197. package/dist/features/reviews/components/PurchaseReviewAffordance.js +42 -0
  198. package/dist/features/reviews/components/ReviewFormDrawer.d.ts +34 -0
  199. package/dist/features/reviews/components/ReviewFormDrawer.js +127 -0
  200. package/dist/features/reviews/components/index.d.ts +4 -0
  201. package/dist/features/reviews/components/index.js +2 -0
  202. package/dist/features/scams/schemas/index.d.ts +10 -10
  203. package/dist/features/search/action-index/settings-entries.js +0 -9
  204. package/dist/features/seller/actions/seller-actions.d.ts +1 -1
  205. package/dist/features/seller/actions/seller-actions.js +49 -3
  206. package/dist/features/seller/components/SellerPayoutSettingsView.js +30 -2
  207. package/dist/features/seller/components/SellerProductShell.d.ts +17 -1
  208. package/dist/features/seller/hooks/useStoreListingEntitlements.d.ts +8 -0
  209. package/dist/features/seller/hooks/useStoreListingEntitlements.js +70 -0
  210. package/dist/features/store-extensions/repository/store-extensions.repositories.d.ts +1 -6
  211. package/dist/features/store-extensions/repository/store-extensions.repositories.js +1 -10
  212. package/dist/features/store-extensions/schemas/firestore.d.ts +1 -17
  213. package/dist/features/store-extensions/schemas/firestore.js +0 -10
  214. package/dist/features/stores/components/InteractiveStoreCard.d.ts +11 -1
  215. package/dist/features/stores/components/InteractiveStoreCard.js +9 -2
  216. package/dist/features/stores/components/StoreCapabilitiesGuideView.js +0 -1
  217. package/dist/features/stores/components/StoreGuideHubView.js +2 -8
  218. package/dist/features/stores/components/StoreSettingsGuideView.js +2 -6
  219. package/dist/features/stores/components/index.d.ts +0 -2
  220. package/dist/features/stores/components/index.js +0 -1
  221. package/dist/features/stores/repository/store.repository.d.ts +1 -26
  222. package/dist/features/stores/repository/store.repository.js +5 -60
  223. package/dist/features/stores/schemas/firestore.d.ts +6 -25
  224. package/dist/features/stores/schemas/firestore.js +6 -3
  225. package/dist/features/stores/schemas/index.d.ts +1 -87
  226. package/dist/features/stores/schemas/index.js +10 -15
  227. package/dist/features/tester/seed-data/authored/admin__site-system.js +0 -48
  228. package/dist/features/tester/seed-data/authored/buying__buying-checkout.js +0 -40
  229. package/dist/features/tester/seed-data/authored/selling__quick-add-minimum-details.js +0 -16
  230. package/dist/features/tester/seed-data/authored/selling__seller-guide.js +1 -1
  231. package/dist/features/tester/seed-data/authored/selling__seller-marketing-extras.js +0 -79
  232. package/dist/features/tester/seed-data/authored/selling__seller-orders.js +1 -1
  233. package/dist/features/tester/seed-data/tester-checklist-seed-data.js +415 -69
  234. package/dist/index.d.ts +20 -32
  235. package/dist/index.js +34 -43
  236. package/dist/next/routing/route-map.d.ts +2 -8
  237. package/dist/next/routing/route-map.js +21 -4
  238. package/dist/providers/db-firebase/base.repository.d.ts +1 -1
  239. package/dist/providers/db-firebase/base.repository.js +1 -1
  240. package/dist/providers/payment-razorpay/index.d.ts +125 -0
  241. package/dist/providers/payment-razorpay/index.js +232 -0
  242. package/dist/providers/payment-razorpay/signature.d.ts +53 -0
  243. package/dist/providers/payment-razorpay/signature.js +71 -0
  244. package/dist/providers/shipping-shiprocket/index.d.ts +98 -0
  245. package/dist/providers/shipping-shiprocket/index.js +356 -0
  246. package/dist/providers.d.ts +3 -0
  247. package/dist/providers.js +3 -0
  248. package/dist/react/hooks/useCanSeePrices.d.ts +0 -27
  249. package/dist/react/hooks/useCanSeePrices.js +25 -0
  250. package/dist/repositories/index.d.ts +1 -1
  251. package/dist/repositories/index.js +1 -1
  252. package/dist/schemas/registry.d.ts +10 -115
  253. package/dist/schemas/registry.js +1 -2
  254. package/dist/security/pii-encrypt.js +1 -1
  255. package/dist/seed/_helpers/category-forest.js +27 -0
  256. package/dist/seed/_helpers/category-parts-glossary-map.js +1816 -88
  257. package/dist/seed/_helpers/category-parts.d.ts +1 -1
  258. package/dist/seed/_helpers/category-parts.js +13399 -3019
  259. package/dist/seed/carousel-slides-seed-data.js +47 -10
  260. package/dist/seed/categories-seed-data.js +48 -6
  261. package/dist/seed/faq-seed-data.js +2 -2
  262. package/dist/seed/homepage-sections-seed-data.js +286 -54
  263. package/dist/seed/index.d.ts +1 -1
  264. package/dist/seed/index.js +1 -1
  265. package/dist/seed/manifest.d.ts +1 -1
  266. package/dist/seed/manifest.js +1 -2
  267. package/dist/seed/model-composition-seed-data.js +6 -8
  268. package/dist/seed/part-glossary/chunk0.d.ts +9 -0
  269. package/dist/seed/part-glossary/chunk0.js +35448 -0
  270. package/dist/seed/part-glossary/chunk1.d.ts +9 -0
  271. package/dist/seed/part-glossary/chunk1.js +40494 -0
  272. package/dist/seed/part-glossary/chunk2.d.ts +9 -0
  273. package/dist/seed/part-glossary/chunk2.js +51242 -0
  274. package/dist/seed/part-glossary/chunk3.d.ts +9 -0
  275. package/dist/seed/part-glossary/chunk3.js +53337 -0
  276. package/dist/seed/part-glossary/chunk4.d.ts +9 -0
  277. package/dist/seed/part-glossary/chunk4.js +51454 -0
  278. package/dist/seed/part-glossary-seed-data.d.ts +1 -1
  279. package/dist/seed/part-glossary-seed-data.js +23 -47483
  280. package/dist/seed/products-catalogue-seed-data.d.ts +5 -5
  281. package/dist/seed/products-catalogue-seed-data.js +63936 -13803
  282. package/dist/seed/site-settings-seed-data.js +34 -35
  283. package/dist/seed/store-extensions-seed-data.d.ts +1 -2
  284. package/dist/seed/store-extensions-seed-data.js +1 -23
  285. package/dist/seed/stores-seed-data.js +0 -1
  286. package/dist/server-entry.d.ts +1 -1
  287. package/dist/server-entry.js +1 -1
  288. package/dist/server.d.ts +8 -10
  289. package/dist/server.js +16 -22
  290. package/dist/styles.css +392 -43
  291. package/dist/tailwind-utilities.css +1 -1
  292. package/dist/tokens/themes/default-dark.js +1 -1
  293. package/dist/tokens/themes/default-light.js +2 -1
  294. package/dist/tokens/tokens.css +6 -2
  295. package/dist/ui/components/Button.d.ts +11 -0
  296. package/dist/ui/components/Button.js +11 -0
  297. package/dist/ui/components/Button.style.css +29 -0
  298. package/dist/ui/components/CarouselNav.d.ts +57 -0
  299. package/dist/ui/components/CarouselNav.js +25 -0
  300. package/dist/ui/components/CarouselNav.style.css +265 -0
  301. package/dist/ui/components/GatedPrice.js +30 -3
  302. package/dist/ui/components/GatedPrice.style.css +43 -40
  303. package/dist/ui/components/HorizontalScroller.d.ts +12 -1
  304. package/dist/ui/components/HorizontalScroller.js +43 -3
  305. package/dist/ui/components/ImageMosaic.d.ts +8 -1
  306. package/dist/ui/components/ImageMosaic.js +3 -2
  307. package/dist/ui/components/ImageMosaic.style.css +22 -0
  308. package/dist/ui/components/Layout.style.css +6 -0
  309. package/dist/ui/components/Semantic.d.ts +3 -2
  310. package/dist/ui/components/Semantic.js +1 -0
  311. package/dist/ui/components/Typography.d.ts +2 -0
  312. package/dist/ui/components/Typography.js +2 -0
  313. package/dist/ui/components/Typography.style.css +19 -0
  314. package/dist/ui/components/index.style.css +1 -0
  315. package/dist/ui/index.d.ts +3 -1
  316. package/dist/ui/index.js +4 -0
  317. package/package.json +3 -2
  318. package/dist/_internal/server/jobs/core/whatsappCatalogImport.d.ts +0 -27
  319. package/dist/_internal/server/jobs/core/whatsappCatalogImport.js +0 -172
  320. package/dist/_internal/server/jobs/core/whatsappNotify.d.ts +0 -35
  321. package/dist/_internal/server/jobs/core/whatsappNotify.js +0 -140
  322. package/dist/features/admin/components/AdminWhatsAppGuideView.d.ts +0 -2
  323. package/dist/features/admin/components/AdminWhatsAppGuideView.js +0 -35
  324. package/dist/features/orders/components/MarketplaceOrderCard.d.ts +0 -36
  325. package/dist/features/orders/components/MarketplaceOrderCard.js +0 -57
  326. package/dist/features/stores/components/StoreWhatsAppGuideView.d.ts +0 -3
  327. package/dist/features/stores/components/StoreWhatsAppGuideView.js +0 -12
  328. package/dist/features/whatsapp-bot/api/send-status/route.d.ts +0 -12
  329. package/dist/features/whatsapp-bot/api/send-status/route.js +0 -38
  330. package/dist/features/whatsapp-bot/api/webhook/route.d.ts +0 -12
  331. package/dist/features/whatsapp-bot/api/webhook/route.js +0 -43
  332. package/dist/features/whatsapp-bot/components/SellerWhatsAppSettingsView.d.ts +0 -6
  333. package/dist/features/whatsapp-bot/components/SellerWhatsAppSettingsView.js +0 -270
  334. package/dist/features/whatsapp-bot/components/WhatsAppChatButton.d.ts +0 -9
  335. package/dist/features/whatsapp-bot/components/WhatsAppChatButton.js +0 -7
  336. package/dist/features/whatsapp-bot/components/index.d.ts +0 -3
  337. package/dist/features/whatsapp-bot/components/index.js +0 -2
  338. package/dist/features/whatsapp-bot/helpers/payment-proof-message.d.ts +0 -14
  339. package/dist/features/whatsapp-bot/helpers/payment-proof-message.js +0 -17
  340. package/dist/features/whatsapp-bot/helpers/whatsapp.d.ts +0 -52
  341. package/dist/features/whatsapp-bot/helpers/whatsapp.js +0 -283
  342. package/dist/features/whatsapp-bot/index.d.ts +0 -3
  343. package/dist/features/whatsapp-bot/index.js +0 -3
  344. package/dist/features/whatsapp-bot/manifest.d.ts +0 -2
  345. package/dist/features/whatsapp-bot/manifest.js +0 -13
  346. package/dist/features/whatsapp-bot/messages/en.json +0 -7
  347. package/dist/features/whatsapp-bot/server.d.ts +0 -7
  348. package/dist/features/whatsapp-bot/server.js +0 -7
  349. package/dist/features/whatsapp-bot/types/index.d.ts +0 -126
  350. package/dist/features/whatsapp-bot/types/index.js +0 -1
@@ -0,0 +1,127 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ /**
4
+ * Write or edit a review.
5
+ *
6
+ * ── This is the first review form the application has ever had ────────────
7
+ *
8
+ * 🛑 Measured before building: `useCreateReview` had ZERO component consumers,
9
+ * `ReviewForm` did not exist, `ViewReviewModal` is read-only, `/user/reviews`
10
+ * was index-only with no detail or edit route, and the ACTIONS registry had no
11
+ * REVIEW bucket. The repo already knew — a tester case records
12
+ * "createReviewAction, useCreateReview and the UI_TEXT.WRITE_REVIEW string all
13
+ * exist, but no .tsx consumes any of them". So there was a complete write path
14
+ * with nothing able to reach it.
15
+ *
16
+ * ── Field names, because the obvious guesses are all wrong ────────────────
17
+ *
18
+ * body → `comment` (NOT `body`)
19
+ * owner → `userId` (NOT `buyerId`)
20
+ * verified → `verified` (there is no `isVerifiedPurchase`)
21
+ * reply → `sellerReply`
22
+ *
23
+ * `REVIEW_UPDATABLE_FIELDS` is already `["rating","title","comment","images"]`,
24
+ * so that is exactly what this form owns — and exactly what the PATCH route
25
+ * accepts now that it is `.strict()`.
26
+ *
27
+ * 🛑 Images are deliberately NOT edited here. The PATCH route does not finalise
28
+ * staged media, so a URL submitted through it would persist as a `tmp/`
29
+ * reference; `updateReview` owns review media. Rather than ship a picker whose
30
+ * uploads silently rot, this form edits the text and the rating.
31
+ *
32
+ * @tag domain:reviews
33
+ * @tag layer:components
34
+ * @tag access:client
35
+ */
36
+ import { useEffect, useState } from "react";
37
+ import { z } from "zod";
38
+ import { apiClient } from "../../../http/index.js";
39
+ import { ACTIONS } from "../../../_internal/shared/actions/action-registry.js";
40
+ import { REVIEW_ENDPOINTS } from "../../../constants/api-endpoints.js";
41
+ import { Button, FieldInput, FieldTextarea, Form, Row, SideDrawer, Stack, Text, } from "../../../ui/index.js";
42
+ import { FormErrorSummary } from "../../../ui/forms/FormErrorSummary.js";
43
+ // Keys errors by the FULL dotted path, so a nested issue cannot collapse onto
44
+ // one map entry and lose all but the last.
45
+ import { applyZodIssues } from "../../../ui/forms/apply-zod-issues.js";
46
+ import { Icon } from "../../../ui/components/Icon.js";
47
+ import { IconButton } from "../../../ui/components/IconButton.js";
48
+ import { normalizeError } from "../../../errors/normalize.js";
49
+ import { toUserMessage } from "../../../errors/error-display-map.js";
50
+ /**
51
+ * Mirrors the PATCH route's schema, which is `.strict()`. A field this form can
52
+ * send that the route does not accept is a 400 naming it — which is the point:
53
+ * the two were allowed to disagree before, and the route silently accepted
54
+ * anything.
55
+ */
56
+ export const reviewFormSchema = z.object({
57
+ rating: z
58
+ .number()
59
+ .int()
60
+ .min(1, "Pick a rating from 1 to 5")
61
+ .max(5, "Pick a rating from 1 to 5"),
62
+ title: z.string().trim().min(1, "Give your review a title").max(100),
63
+ comment: z
64
+ .string()
65
+ .trim()
66
+ .min(1, "Say something about the item")
67
+ .max(2000, "Keep it under 2000 characters"),
68
+ });
69
+ const EMPTY = { rating: 0, title: "", comment: "" };
70
+ export function ReviewFormDrawer({ isOpen, onClose, reviewId, productId, storeId, initialValues, onSaved, }) {
71
+ const editing = Boolean(reviewId);
72
+ const [values, setValues] = useState({
73
+ ...EMPTY,
74
+ ...initialValues,
75
+ });
76
+ const [busy, setBusy] = useState(false);
77
+ const [formError, setFormError] = useState(null);
78
+ /*
79
+ * Re-seed when the drawer is reopened for a DIFFERENT review. Without this
80
+ * the second review a buyer edits in one session shows the first one's text
81
+ * — the component stays mounted, so initial state alone is not enough.
82
+ */
83
+ useEffect(() => {
84
+ if (isOpen)
85
+ setValues({ ...EMPTY, ...initialValues });
86
+ // eslint-disable-next-line react-hooks/exhaustive-deps
87
+ }, [isOpen, reviewId]);
88
+ async function submit({ setFieldError, clearErrors, markSubmitAttempted, }) {
89
+ clearErrors();
90
+ setFormError(null);
91
+ markSubmitAttempted?.();
92
+ const parsed = reviewFormSchema.safeParse(values);
93
+ if (!parsed.success) {
94
+ applyZodIssues(parsed.error.issues, setFieldError);
95
+ return;
96
+ }
97
+ setBusy(true);
98
+ try {
99
+ if (reviewId) {
100
+ await apiClient.patch(REVIEW_ENDPOINTS.BY_ID(reviewId), parsed.data);
101
+ }
102
+ else {
103
+ await apiClient.post(REVIEW_ENDPOINTS.LIST, {
104
+ ...parsed.data,
105
+ productId,
106
+ storeId,
107
+ });
108
+ }
109
+ onSaved?.();
110
+ onClose();
111
+ }
112
+ catch (err) {
113
+ const normalized = normalizeError(err);
114
+ /*
115
+ * 🛑 toUserMessage, never the server's own message. A raw `?? error`
116
+ * fallback is what rendered a Node MODULE_NOT_FOUND with a require
117
+ * stack inside a bid modal (Root Cause #86); this resolves through
118
+ * errors.codes.* and terminates at UNKNOWN.
119
+ */
120
+ setFormError(toUserMessage(normalized.code ?? "UNKNOWN"));
121
+ }
122
+ finally {
123
+ setBusy(false);
124
+ }
125
+ }
126
+ return (_jsx(SideDrawer, { isOpen: isOpen, onClose: onClose, title: editing ? "Edit your review" : "Write a review", children: _jsx(Form, { schema: reviewFormSchema, onSubmit: (e) => e.preventDefault(), className: "space-y-4", children: ({ setFieldError, clearErrors, markSubmitAttempted }) => (_jsxs(Stack, { gap: "md", children: [_jsx(FormErrorSummary, {}), _jsxs(Stack, { gap: "xs", children: [_jsx(Text, { size: "sm", weight: "medium", children: "Rating" }), _jsx(Row, { gap: "xs", align: "center", children: [1, 2, 3, 4, 5].map((n) => (_jsx(IconButton, { "aria-label": `${n} star${n === 1 ? "" : "s"}`, "aria-pressed": values.rating === n, size: "md", variant: "ghost", icon: _jsx(Icon, { name: "review", size: "lg", filled: n <= values.rating, tone: n <= values.rating ? "warning" : "faint" }), onClick: () => setValues((v) => ({ ...v, rating: n })) }, n))) })] }), _jsx(FieldInput, { name: "title", label: "Title", required: true, value: values.title, onChange: (title) => setValues((v) => ({ ...v, title })) }), _jsx(FieldTextarea, { name: "comment", label: "Your review", required: true, rows: 6, value: values.comment, onChange: (comment) => setValues((v) => ({ ...v, comment })) }), formError && (_jsx(Text, { size: "sm", color: "error", role: "alert", children: formError })), _jsx(Button, { type: "submit", isLoading: busy, action: editing ? ACTIONS.REVIEW.edit : ACTIONS.REVIEW.write, onClick: () => void submit({ setFieldError, clearErrors, markSubmitAttempted }) })] })) }) }));
127
+ }
@@ -11,3 +11,7 @@ export type { ReviewsIndexListingProps } from "./ReviewsIndexListing";
11
11
  export { ReviewsListingPanel } from "./ReviewsListingPanel";
12
12
  export type { ReviewsListingPanelProps, ReviewsSource } from "./ReviewsListingPanel";
13
13
  export type { ReviewDetailPageViewProps } from "./ReviewDetailPageView";
14
+ export { ReviewFormDrawer, reviewFormSchema } from "./ReviewFormDrawer";
15
+ export type { ReviewFormDrawerProps, ReviewFormValues } from "./ReviewFormDrawer";
16
+ export { PurchaseReviewAffordance } from "./PurchaseReviewAffordance";
17
+ export type { PurchaseReviewAffordanceProps } from "./PurchaseReviewAffordance";
@@ -4,3 +4,5 @@ export { ReviewSummary } from "./ReviewSummary.js";
4
4
  export { ViewReviewModal } from "./ReviewModal.js";
5
5
  export { ReviewsIndexListing } from "./ReviewsIndexListing.js";
6
6
  export { ReviewsListingPanel } from "./ReviewsListingPanel.js";
7
+ export { ReviewFormDrawer, reviewFormSchema } from "./ReviewFormDrawer.js";
8
+ export { PurchaseReviewAffordance } from "./PurchaseReviewAffordance.js";
@@ -10,11 +10,11 @@ export declare const scammerSocialMediaSchema: z.ZodObject<{
10
10
  handle: z.ZodString;
11
11
  url: z.ZodOptional<z.ZodString>;
12
12
  }, "strip", z.ZodTypeAny, {
13
- platform: "other" | "youtube" | "instagram" | "facebook" | "whatsapp" | "telegram" | "twitter" | "olx" | "linkedin";
13
+ platform: "other" | "youtube" | "whatsapp" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
14
14
  handle: string;
15
15
  url?: string | undefined;
16
16
  }, {
17
- platform: "other" | "youtube" | "instagram" | "facebook" | "whatsapp" | "telegram" | "twitter" | "olx" | "linkedin";
17
+ platform: "other" | "youtube" | "whatsapp" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
18
18
  handle: string;
19
19
  url?: string | undefined;
20
20
  }>;
@@ -44,11 +44,11 @@ export declare const scammerFirestoreSchema: z.ZodObject<{
44
44
  handle: z.ZodString;
45
45
  url: z.ZodOptional<z.ZodString>;
46
46
  }, "strip", z.ZodTypeAny, {
47
- platform: "other" | "youtube" | "instagram" | "facebook" | "whatsapp" | "telegram" | "twitter" | "olx" | "linkedin";
47
+ platform: "other" | "youtube" | "whatsapp" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
48
48
  handle: string;
49
49
  url?: string | undefined;
50
50
  }, {
51
- platform: "other" | "youtube" | "instagram" | "facebook" | "whatsapp" | "telegram" | "twitter" | "olx" | "linkedin";
51
+ platform: "other" | "youtube" | "whatsapp" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
52
52
  handle: string;
53
53
  url?: string | undefined;
54
54
  }>, "many">;
@@ -93,7 +93,7 @@ export declare const scammerFirestoreSchema: z.ZodObject<{
93
93
  scamType: string;
94
94
  reportedBy: string;
95
95
  reportedByAnon: boolean;
96
- scamPlatform: "other" | "letitrip" | "instagram" | "facebook" | "whatsapp" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
96
+ scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
97
97
  evidence: string[];
98
98
  phones: string[];
99
99
  upiIds: string[];
@@ -102,7 +102,7 @@ export declare const scammerFirestoreSchema: z.ZodObject<{
102
102
  incidentCount: number;
103
103
  seoSlug: string;
104
104
  socialMedia: {
105
- platform: "other" | "youtube" | "instagram" | "facebook" | "whatsapp" | "telegram" | "twitter" | "olx" | "linkedin";
105
+ platform: "other" | "youtube" | "whatsapp" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
106
106
  handle: string;
107
107
  url?: string | undefined;
108
108
  }[];
@@ -133,7 +133,7 @@ export declare const scammerFirestoreSchema: z.ZodObject<{
133
133
  scamType: string;
134
134
  reportedBy: string;
135
135
  reportedByAnon: boolean;
136
- scamPlatform: "other" | "letitrip" | "instagram" | "facebook" | "whatsapp" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
136
+ scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
137
137
  evidence: string[];
138
138
  phones: string[];
139
139
  upiIds: string[];
@@ -142,7 +142,7 @@ export declare const scammerFirestoreSchema: z.ZodObject<{
142
142
  incidentCount: number;
143
143
  seoSlug: string;
144
144
  socialMedia: {
145
- platform: "other" | "youtube" | "instagram" | "facebook" | "whatsapp" | "telegram" | "twitter" | "olx" | "linkedin";
145
+ platform: "other" | "youtube" | "whatsapp" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "linkedin";
146
146
  handle: string;
147
147
  url?: string | undefined;
148
148
  }[];
@@ -201,7 +201,7 @@ export declare const scammerIncidentFirestoreSchema: z.ZodObject<{
201
201
  reportedBy: string;
202
202
  scammerId: string;
203
203
  reportedByAnon: boolean;
204
- scamPlatform: "other" | "letitrip" | "instagram" | "facebook" | "whatsapp" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
204
+ scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
205
205
  evidence: string[];
206
206
  verifiedBy?: string | undefined;
207
207
  amountLost?: number | undefined;
@@ -224,7 +224,7 @@ export declare const scammerIncidentFirestoreSchema: z.ZodObject<{
224
224
  reportedBy: string;
225
225
  scammerId: string;
226
226
  reportedByAnon: boolean;
227
- scamPlatform: "other" | "letitrip" | "instagram" | "facebook" | "whatsapp" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
227
+ scamPlatform: "other" | "whatsapp" | "letitrip" | "instagram" | "facebook" | "telegram" | "twitter" | "olx" | "facebook_marketplace" | "in_person" | "phone_call";
228
228
  evidence: string[];
229
229
  verifiedBy?: string | undefined;
230
230
  amountLost?: number | undefined;
@@ -169,15 +169,6 @@ export const SITE_SETTINGS_ENTRIES = [
169
169
  tab: "notifications",
170
170
  kind: "toggle",
171
171
  },
172
- {
173
- slug: "whatsapp-notifications",
174
- anchored: true,
175
- label: "WhatsApp notifications",
176
- description: "Send order updates over WhatsApp.",
177
- keywords: ["whatsapp", "order updates", "meta"],
178
- tab: "notifications",
179
- kind: "toggle",
180
- },
181
172
  {
182
173
  slug: "daily-digest",
183
174
  anchored: true,
@@ -130,7 +130,7 @@ export declare function bulkSellerOrder(userId: string, userRole: string, userDi
130
130
  * only safe shape — a caller-supplied `storeId` would let a seller file a
131
131
  * listing under someone else's store.
132
132
  */
133
- export declare function createSellerProduct(userId: string, userName: string, userEmail: string, input: Record<string, JsonValue>): Promise<void>;
133
+ export declare function createSellerProduct(userId: string, userName: string, userEmail: string, input: Record<string, JsonValue>, userRole?: string): Promise<void>;
134
134
  export declare function getSellerStore(userId: string): Promise<StoreDocument | null>;
135
135
  export declare function getSellerShipping(userId: string): Promise<import("../../auth").SellerShippingConfig | null>;
136
136
  export declare function getSellerPayoutSettings(userId: string): Promise<SellerPayoutDetails | {
@@ -13,6 +13,7 @@ import { normalizeError } from "../../../errors/normalize.js";
13
13
  import { enqueueJob } from "../../jobs/actions/enqueue-job.js";
14
14
  import { isAdminUser, isStrictSellerUser, isTesterUser } from "../../auth/role-predicates.js";
15
15
  import { ApiError, AuthorizationError, NotFoundError, ValidationError, } from "../../../errors/index.js";
16
+ import { assertListingTypeAllowed } from "../../../_internal/shared/listing-types/tiers.js";
16
17
  import { userRepository } from "../../auth/repository/user.repository.js";
17
18
  import { storeRepository } from "../../stores/repository/store.repository.js";
18
19
  import { productRepository } from "../../products/repository/products.repository.js";
@@ -427,7 +428,13 @@ export async function bulkSellerOrder(userId, userRole, userDisplayName, userEma
427
428
  * only safe shape — a caller-supplied `storeId` would let a seller file a
428
429
  * listing under someone else's store.
429
430
  */
430
- export async function createSellerProduct(userId, userName, userEmail, input) {
431
+ export async function createSellerProduct(userId, userName, userEmail, input,
432
+ /*
433
+ * 🛑 Defaults to `"seller"`, which FAILS CLOSED. A caller that forgets to
434
+ * pass a role gets the gate, not a bypass — the opposite default would make
435
+ * every un-updated call site an admin.
436
+ */
437
+ userRole = "seller") {
431
438
  const store = await storeRepository.findByOwnerId(userId);
432
439
  // Refuse rather than write an orphan. A listing with no store is invisible on
433
440
  // its own storefront, forms no order group at checkout, and cannot be paid
@@ -436,6 +443,19 @@ export async function createSellerProduct(userId, userName, userEmail, input) {
436
443
  if (!store) {
437
444
  throw new NotFoundError("No store found for this account. Create your store first.");
438
445
  }
446
+ /*
447
+ * The advanced-listing-type gate, at the choke point every create funnels
448
+ * through.
449
+ *
450
+ * It lives HERE rather than only in the consumer action because this is the
451
+ * one place all creates meet, and because the store document is already in
452
+ * scope — so the check costs no extra Firestore read (Rule #6). The caller's
453
+ * own gate is a nicety; this one is the guarantee.
454
+ */
455
+ assertListingTypeAllowed(input.listingType, {
456
+ isPrivileged: userRole === "admin",
457
+ capabilities: store.capabilities,
458
+ });
439
459
  const finalizedData = await finalizeProductMediaReferences(input);
440
460
  await productRepository.create({
441
461
  ...finalizedData,
@@ -592,11 +612,37 @@ export async function sellerUpdateProduct(userId, userRole, productId, input) {
592
612
  if (!existing)
593
613
  throw new NotFoundError("Product not found");
594
614
  // existing.storeId is the store slug, not the seller's Firebase UID.
595
- if (userRole !== "admin") {
596
- const store = await storeRepository.findByOwnerId(userId);
615
+ const isPrivileged = userRole === "admin";
616
+ let store = null;
617
+ if (!isPrivileged) {
618
+ store = await storeRepository.findByOwnerId(userId);
597
619
  if (!store || existing.storeId !== store.id)
598
620
  throw new AuthorizationError("You do not own this product");
599
621
  }
622
+ /*
623
+ * 🛑 The UPDATE path had no listing-type gate at all, which made the
624
+ * create-time one bypassable in a single request: create a `standard`
625
+ * listing, then PATCH `listingType: "auction"` onto it and the type stuck.
626
+ * Gating only creates is gating nothing.
627
+ *
628
+ * 🛑 But it fires only on a CHANGE of type, and that is load-bearing. Every
629
+ * per-type edit page spreads its own literal into the payload
630
+ * (`store/art/[id]/edit` sends `listingType: "art"`), so gating on the
631
+ * submitted value alone would lock a seller out of editing listings they
632
+ * already own the moment the capability was turned off — or an admin revoked
633
+ * it. The rule is "you may not create or convert INTO an advanced type",
634
+ * never "you may not touch one".
635
+ *
636
+ * Reuses the store already loaded for the ownership check above, so a
637
+ * non-admin update pays no extra read. An admin skips both.
638
+ */
639
+ if (typeof input.listingType === "string" &&
640
+ input.listingType !== existing.listingType) {
641
+ assertListingTypeAllowed(input.listingType, {
642
+ isPrivileged,
643
+ capabilities: store?.capabilities,
644
+ });
645
+ }
600
646
  if (typeof input.status === "string" &&
601
647
  input.status !== "published" &&
602
648
  existing.status === "published") {
@@ -88,6 +88,23 @@ const payoutSettingsDraftSchema = z.object({
88
88
  */
89
89
  supportsShippingProtection: annotate(z.boolean(), { section: "preferences", order: 5, row: "quarter" }),
90
90
  supportsSaleProtection: annotate(z.boolean(), { section: "preferences", order: 6, row: "quarter" }),
91
+ /*
92
+ * Advanced listing types — pre-orders, prize draws, classifieds, digital
93
+ * codes, live items, art and stickers. Everyone can already list
94
+ * `standard`, `spares` and `auction`.
95
+ *
96
+ * 🛑 Alongside payout settings for the same reason the protections are:
97
+ * each of these carries an obligation, not just a form. A pre-order takes
98
+ * money for stock that does not exist yet, a prize draw is a regulated
99
+ * promotion, a classified happens off-platform with no escrow, a
100
+ * digital-code listing must be delivered from a pool the seller has to keep
101
+ * stocked, and a live listing is an animal. A new seller should meet those
102
+ * deliberately rather than by discovering a nav item.
103
+ *
104
+ * OFF by default, and the copy has to say what enabling ACCEPTS — the same
105
+ * reason the protection toggles say what declining costs.
106
+ */
107
+ advancedListingTypesEnabled: annotate(z.boolean(), { section: "preferences", order: 7, row: "quarter" }),
91
108
  }).superRefine((v, ctx) => {
92
109
  if (v.method === "upi") {
93
110
  if (!v.upiId.trim()) {
@@ -128,6 +145,13 @@ const DEFAULT_DRAFT = {
128
145
  // OFF by default — matches StoreDocument, and absence must read as declined.
129
146
  supportsShippingProtection: false,
130
147
  supportsSaleProtection: false,
148
+ /*
149
+ * OFF by default, which is also the direction the server gate fails. A
150
+ * default of `true` here would be worse than cosmetic: this draft is what
151
+ * gets PATCHed, so it would silently GRANT the capability on the next
152
+ * unrelated save of this form.
153
+ */
154
+ advancedListingTypesEnabled: false,
131
155
  };
132
156
  export function SellerPayoutSettingsView({ apiBase = SELLER_ENDPOINTS.PAYOUT_SETTINGS }) {
133
157
  const [draft, setDraft] = useState(DEFAULT_DRAFT);
@@ -175,6 +199,9 @@ export function SellerPayoutSettingsView({ apiBase = SELLER_ENDPOINTS.PAYOUT_SET
175
199
  pricesIncludeGst: res?.data?.pricesIncludeGst ?? true,
176
200
  supportsShippingProtection: res?.data?.supportsShippingProtection ?? false,
177
201
  supportsSaleProtection: res?.data?.supportsSaleProtection ?? false,
202
+ // Absent means NOT entitled. Defaulting this to `true` would be a
203
+ // silent GRANT on the next save, since this draft is what gets sent.
204
+ advancedListingTypesEnabled: res?.data?.advancedListingTypesEnabled ?? false,
178
205
  });
179
206
  })
180
207
  .catch(console.error)
@@ -205,6 +232,7 @@ export function SellerPayoutSettingsView({ apiBase = SELLER_ENDPOINTS.PAYOUT_SET
205
232
  pricesIncludeGst: draft.pricesIncludeGst,
206
233
  supportsShippingProtection: draft.supportsShippingProtection,
207
234
  supportsSaleProtection: draft.supportsSaleProtection,
235
+ advancedListingTypesEnabled: draft.advancedListingTypesEnabled,
208
236
  // Flat, matching the route's schema. A nested `taxInfo` object was
209
237
  // stripped by `z.object()` and never reached Firestore.
210
238
  gstin: draft.gstin.trim(),
@@ -271,8 +299,8 @@ export function SellerPayoutSettingsView({ apiBase = SELLER_ENDPOINTS.PAYOUT_SET
271
299
  {
272
300
  id: "preferences",
273
301
  label: "Preferences",
274
- fields: ["autoPayout", "minimumThreshold", "emiEnabled", "pricesIncludeGst", "supportsShippingProtection", "supportsSaleProtection"],
275
- render: ({ values, onChange }) => (_jsxs(Stack, { gap: "md", children: [_jsx(Heading, { level: 3, className: "mb-2", children: "Payout Preferences" }), _jsx(Toggle, { checked: values.autoPayout, onChange: (checked) => onChange({ autoPayout: checked }), label: "Enable auto-payout \u2014 automatically transfer earnings on schedule", disabled: busy }), _jsx(FormField, { name: "minimumThreshold", label: "Minimum Payout Threshold (\u20B9)", type: "number", value: values.minimumThreshold, onChange: (v) => onChange({ minimumThreshold: v }), placeholder: "e.g. 500", helpText: "Payouts are held until your balance exceeds this amount. Leave blank for no minimum.", disabled: busy }), _jsxs(Div, { className: `${__P.p3} bg-[var(--appkit-color-surface-alt)] border border-[var(--appkit-color-border)]`, rounded: "lg", children: [_jsx(Text, { className: "mb-1", size: "sm", weight: "medium", children: "Payout Schedule" }), _jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: "Auto-payouts run every Monday for the previous week's settled orders. Manual payouts can be requested from the Payouts page at any time." })] }), _jsx(Toggle, { checked: values.emiEnabled, onChange: (checked) => onChange({ emiEnabled: checked }), label: "Offer EMI financing on eligible orders", disabled: busy }), _jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: "Only shown to buyers when platform-wide EMI is also enabled and their cart subtotal from your store exceeds the site's minimum order value. Orders on an EMI plan hold your payout until every installment is paid, unless you mark the item \"ship before EMI completes\"." }), _jsx(Toggle, { checked: values.pricesIncludeGst, onChange: (checked) => onChange({ pricesIncludeGst: checked }), label: "The prices I enter already include GST", disabled: busy }), _jsxs(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: ["Buyers always see a tax-inclusive price, so this only changes how your own entry is read. Leave it", " ", _jsx(Span, { weight: "semibold", children: "on" }), " and a \u20B9999 listing at 5% GST means the buyer pays \u20B9999 and you earn \u20B9951.43 \u2014 the \u20B947.57 is GST we collect and remit for you. Turn it", " ", _jsx(Span, { weight: "semibold", children: "off" }), " and \u20B9999 is treated as your ex-GST price: the listing is shown at \u20B91,048.95 and you earn \u20B9999."] }), _jsx(Heading, { level: 3, className: "mb-2 mt-4", children: "Buyer Protections" }), _jsxs(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: ["Two separate covers a buyer can pay for at checkout. Supporting one earns a safety badge on your listings;", " ", _jsx(Span, { weight: "semibold", children: "declining shows buyers a risk notice instead" }), " \u2014 there is no neutral option, because a buyer who is told nothing cannot tell a seller who declined from one who was never asked."] }), _jsx(Toggle, { checked: values.supportsShippingProtection, onChange: (checked) => onChange({ supportsShippingProtection: checked }), label: "Offer shipment protection \u2014 loss or damage in transit", disabled: busy }), _jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: "The parcel never arrived or arrived damaged. We pursue the courier, not you, and the buyer is refunded from the funds we hold \u2014 so a genuine transit loss costs you the item, not an argument." }), _jsx(Toggle, { checked: values.supportsSaleProtection, onChange: (checked) => onChange({ supportsSaleProtection: checked }), label: "Offer sale protection \u2014 item not as described", disabled: busy }), _jsxs(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: ["A no-questions-asked refund on the item itself. Be clear about what this means:", " ", _jsx(Span, { weight: "semibold", children: "a claim we inspect and find genuine is charged back to you" }), " ", "\u2014 that is the cover. A claim we find to be a change of mind is absorbed by us, which is what the buyer's fee pays for. Not offered on your final-sale listings, since \"no returns\" and \"no questions asked\" cannot both be true."] }), _jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: "Changing this does not re-price listings you have already published. It applies to products you save from now on." })] })),
302
+ fields: ["autoPayout", "minimumThreshold", "emiEnabled", "pricesIncludeGst", "supportsShippingProtection", "supportsSaleProtection", "advancedListingTypesEnabled"],
303
+ render: ({ values, onChange }) => (_jsxs(Stack, { gap: "md", children: [_jsx(Heading, { level: 3, className: "mb-2", children: "Payout Preferences" }), _jsx(Toggle, { checked: values.autoPayout, onChange: (checked) => onChange({ autoPayout: checked }), label: "Enable auto-payout \u2014 automatically transfer earnings on schedule", disabled: busy }), _jsx(FormField, { name: "minimumThreshold", label: "Minimum Payout Threshold (\u20B9)", type: "number", value: values.minimumThreshold, onChange: (v) => onChange({ minimumThreshold: v }), placeholder: "e.g. 500", helpText: "Payouts are held until your balance exceeds this amount. Leave blank for no minimum.", disabled: busy }), _jsxs(Div, { className: `${__P.p3} bg-[var(--appkit-color-surface-alt)] border border-[var(--appkit-color-border)]`, rounded: "lg", children: [_jsx(Text, { className: "mb-1", size: "sm", weight: "medium", children: "Payout Schedule" }), _jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: "Auto-payouts run every Monday for the previous week's settled orders. Manual payouts can be requested from the Payouts page at any time." })] }), _jsx(Toggle, { checked: values.emiEnabled, onChange: (checked) => onChange({ emiEnabled: checked }), label: "Offer EMI financing on eligible orders", disabled: busy }), _jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: "Only shown to buyers when platform-wide EMI is also enabled and their cart subtotal from your store exceeds the site's minimum order value. Orders on an EMI plan hold your payout until every installment is paid, unless you mark the item \"ship before EMI completes\"." }), _jsx(Toggle, { checked: values.pricesIncludeGst, onChange: (checked) => onChange({ pricesIncludeGst: checked }), label: "The prices I enter already include GST", disabled: busy }), _jsxs(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: ["Buyers always see a tax-inclusive price, so this only changes how your own entry is read. Leave it", " ", _jsx(Span, { weight: "semibold", children: "on" }), " and a \u20B9999 listing at 5% GST means the buyer pays \u20B9999 and you earn \u20B9951.43 \u2014 the \u20B947.57 is GST we collect and remit for you. Turn it", " ", _jsx(Span, { weight: "semibold", children: "off" }), " and \u20B9999 is treated as your ex-GST price: the listing is shown at \u20B91,048.95 and you earn \u20B9999."] }), _jsx(Heading, { level: 3, className: "mb-2 mt-4", children: "Buyer Protections" }), _jsxs(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: ["Two separate covers a buyer can pay for at checkout. Supporting one earns a safety badge on your listings;", " ", _jsx(Span, { weight: "semibold", children: "declining shows buyers a risk notice instead" }), " \u2014 there is no neutral option, because a buyer who is told nothing cannot tell a seller who declined from one who was never asked."] }), _jsx(Toggle, { checked: values.supportsShippingProtection, onChange: (checked) => onChange({ supportsShippingProtection: checked }), label: "Offer shipment protection \u2014 loss or damage in transit", disabled: busy }), _jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: "The parcel never arrived or arrived damaged. We pursue the courier, not you, and the buyer is refunded from the funds we hold \u2014 so a genuine transit loss costs you the item, not an argument." }), _jsx(Toggle, { checked: values.supportsSaleProtection, onChange: (checked) => onChange({ supportsSaleProtection: checked }), label: "Offer sale protection \u2014 item not as described", disabled: busy }), _jsxs(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: ["A no-questions-asked refund on the item itself. Be clear about what this means:", " ", _jsx(Span, { weight: "semibold", children: "a claim we inspect and find genuine is charged back to you" }), " ", "\u2014 that is the cover. A claim we find to be a change of mind is absorbed by us, which is what the buyer's fee pays for. Not offered on your final-sale listings, since \"no returns\" and \"no questions asked\" cannot both be true."] }), _jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: "Changing this does not re-price listings you have already published. It applies to products you save from now on." }), _jsx(Toggle, { checked: values.advancedListingTypesEnabled, onChange: (checked) => onChange({ advancedListingTypesEnabled: checked }), label: "Enable advanced listing types", disabled: busy }), _jsxs(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: ["Adds pre-orders, prize draws, classifieds, digital codes, live items, art and stickers alongside the products, spares and auctions you can already list. Each carries its own obligation:", " ", _jsx(Span, { weight: "semibold", children: "a pre-order takes payment for stock you do not have yet, a prize draw is a regulated promotion, a classified happens off-platform with no escrow protection, a digital code must be delivered from a pool you keep stocked, and a live listing is an animal." }), " ", "Turning this off later does not unpublish listings you have already created \u2014 it only stops you making new ones."] })] })),
276
304
  },
277
305
  ], [busy, current]);
278
306
  const { openIds, setOpenIds, goToSection, fieldToSectionIndex, sectionMeta } = useSectionFormNav(sections, draft);
@@ -1,6 +1,22 @@
1
1
  import React from "react";
2
2
  import type { MediaField } from "../../media/types";
3
- export type ProductListingMode = "standard" | "auction" | "pre-order" | "prize-draw" | "bundle" | "classified" | "digital-code" | "live" | "art" | "stickers" | "spares";
3
+ import type { ListingType } from "../../products/types/index";
4
+ /**
5
+ * What this shell is editing: any listing type, or a bundle.
6
+ *
7
+ * 🛑 DERIVED from `ListingType`, not restated. This was a hand-written copy of
8
+ * the union plus `"bundle"` — the eleventh such copy in the codebase — and the
9
+ * whole point of `ALL_LISTING_TYPES_MAP` being a `Record<ListingType, true>`
10
+ * is that a new member cannot be silently omitted from a list like this one.
11
+ * Root Cause #61.
12
+ *
13
+ * `"bundle"` is a deliberate EXTRA, not an oversight: bundles stopped being a
14
+ * `listingType` in SB-UNI-D (they are a `categoryType` on `categories` now),
15
+ * but this shell still edits them, which is what `pluginForMode`'s
16
+ * `BUNDLE_PLUGIN_FALLBACK` is for. Spelling it as a union with one added
17
+ * literal says that, where a twelve-item list said nothing.
18
+ */
19
+ export type ProductListingMode = ListingType | "bundle";
4
20
  export interface SellerProductDraft {
5
21
  title?: string;
6
22
  slug?: string;
@@ -0,0 +1,8 @@
1
+ import type { ListingType } from "../../products/types/index";
2
+ export interface StoreListingEntitlements {
3
+ /** Types this store may create. Never empty — basics are always included. */
4
+ allowed: Set<ListingType>;
5
+ advancedEnabled: boolean;
6
+ isLoading: boolean;
7
+ }
8
+ export declare function useStoreListingEntitlements(): StoreListingEntitlements;
@@ -0,0 +1,70 @@
1
+ "use client";
2
+ /**
3
+ * Which listing types the signed-in seller's own store may create.
4
+ *
5
+ * ── Why this needs a fetch at all ─────────────────────────────────────────
6
+ *
7
+ * 🛑 `StoreDocument.capabilities` is listed in `PRIVATE_STORE_FIELDS` —
8
+ * "internal feature gating; server-enforced, never client-read" — so it is
9
+ * absent from every public store payload and from the session user. A client
10
+ * component genuinely cannot derive this locally, and the alternative a
11
+ * previous draft reached for (publish the capability array to the browser)
12
+ * would ship `lower_commission_rate`, `priority_support` and fifteen more
13
+ * admin-granted entitlements to anyone who opened devtools. Root Cause #70.
14
+ *
15
+ * So the server sends a PROJECTION: `allowedListingTypes`, already resolved by
16
+ * `listingTypesAllowedFor` on the same capability array the write-path gate
17
+ * uses. Client and server therefore agree by construction rather than by two
18
+ * copies of one rule (Root Cause #30).
19
+ *
20
+ * ── Why the loading state is not "denied" ─────────────────────────────────
21
+ *
22
+ * `isLoading` is returned and callers must respect it. The three-state rule
23
+ * from `useCanSeePrices`: "not known yet" rendering as "no" shows an entitled
24
+ * seller a refusal on every page load. The server refuses authoritatively in
25
+ * `createSellerProduct` / `sellerUpdateProduct`, so an optimistic render while
26
+ * the fetch is in flight costs nothing worse than a late refusal.
27
+ *
28
+ * @tag domain:seller
29
+ * @tag layer:hooks
30
+ * @tag access:client
31
+ */
32
+ import { useMemo } from "react";
33
+ import { useApiQuery } from "../../../client/api/useApiQuery.js";
34
+ import { apiClient } from "../../../http/index.js";
35
+ import { SELLER_ENDPOINTS } from "../../../constants/api-endpoints.js";
36
+ import { BASIC_LISTING_TYPES } from "../../../_internal/shared/listing-types/tiers.js";
37
+ export function useStoreListingEntitlements() {
38
+ const query = useApiQuery({
39
+ queryKey: ["store", "listing-entitlements"],
40
+ queryFn: async () => {
41
+ const res = await apiClient.get(SELLER_ENDPOINTS.PAYOUT_SETTINGS);
42
+ return res?.data ?? {};
43
+ },
44
+ /*
45
+ * The answer changes only when an admin or the seller flips a capability,
46
+ * so a short window is pointless churn — but it must not be `Infinity`,
47
+ * because a seller who has just ticked the box in another tab should not
48
+ * have to hard-reload to see the nav and forms open up.
49
+ */
50
+ staleTime: 60000,
51
+ silentBackgroundFailures: true,
52
+ });
53
+ return useMemo(() => {
54
+ /*
55
+ * 🛑 Falls back to the BASIC types, not to everything and not to nothing.
56
+ *
57
+ * Everything would offer a form that the server then refuses — the exact
58
+ * "filled in a long wizard and got rejected at publish" experience this
59
+ * hook exists to prevent. Nothing would lock a seller out of `standard`
60
+ * on a transient network blip, which is the one type every store has.
61
+ */
62
+ const list = query.data?.allowedListingTypes;
63
+ const allowed = new Set(Array.isArray(list) && list.length > 0 ? list : BASIC_LISTING_TYPES);
64
+ return {
65
+ allowed,
66
+ advancedEnabled: query.data?.advancedListingTypesEnabled === true,
67
+ isLoading: query.isLoading,
68
+ };
69
+ }, [query.data, query.isLoading]);
70
+ }
@@ -14,7 +14,7 @@
14
14
  */
15
15
  import { BaseRepository } from "../../../providers/db-firebase";
16
16
  import type { DocumentSnapshot } from "firebase-admin/firestore";
17
- import { type AnalyticsAlertDocument, type AnalyticsCardDocument, type ItemRequestDocument, type ItemRequestReply, type ListingTemplateDocument, type ModerationQueueDocument, type PayoutMethodDocument, type ReportDocument, type ShippingConfigDocument, type StoreCategoryDocument, type StoreGoogleConfigDocument, type StoreWhatsAppConfigDocument } from "../schemas/firestore";
17
+ import { type AnalyticsAlertDocument, type AnalyticsCardDocument, type ItemRequestDocument, type ItemRequestReply, type ListingTemplateDocument, type ModerationQueueDocument, type PayoutMethodDocument, type ReportDocument, type ShippingConfigDocument, type StoreCategoryDocument, type StoreGoogleConfigDocument } from "../schemas/firestore";
18
18
  export declare class PayoutMethodsRepository extends BaseRepository<PayoutMethodDocument> {
19
19
  /**
20
20
  * Bank/UPI details, encrypted at rest by BaseRepository's write hooks.
@@ -103,10 +103,6 @@ export declare class ItemRequestsRepository extends BaseRepository<ItemRequestDo
103
103
  */
104
104
  appendReply(id: string, reply: ItemRequestReply): Promise<void>;
105
105
  }
106
- export declare class StoreWhatsAppConfigRepository extends BaseRepository<StoreWhatsAppConfigDocument> {
107
- constructor();
108
- getByStore(storeId: string): Promise<StoreWhatsAppConfigDocument | null>;
109
- }
110
106
  export declare class StoreGoogleConfigRepository extends BaseRepository<StoreGoogleConfigDocument> {
111
107
  constructor();
112
108
  getByStore(storeId: string): Promise<StoreGoogleConfigDocument | null>;
@@ -120,5 +116,4 @@ export declare const listingTemplatesRepository: ListingTemplatesRepository;
120
116
  export declare const moderationQueueRepository: ModerationQueueRepository;
121
117
  export declare const reportsRepository: ReportsRepository;
122
118
  export declare const itemRequestsRepository: ItemRequestsRepository;
123
- export declare const storeWhatsAppConfigRepository: StoreWhatsAppConfigRepository;
124
119
  export declare const storeGoogleConfigRepository: StoreGoogleConfigRepository;
@@ -15,7 +15,7 @@
15
15
  import { BaseRepository } from "../../../providers/db-firebase/index.js";
16
16
  import { arrayUnion, increment } from "../../../contracts/field-ops.js";
17
17
  import { decryptPiiFields } from "../../../security/pii-encrypt.js";
18
- import { ANALYTICS_ALERTS_COLLECTION, ANALYTICS_CARDS_COLLECTION, ITEM_REQUESTS_COLLECTION, LISTING_TEMPLATES_COLLECTION, MODERATION_QUEUE_COLLECTION, PAYOUT_METHODS_COLLECTION, REPORTS_COLLECTION, SHIPPING_CONFIGS_COLLECTION, STORE_CATEGORIES_COLLECTION, STORE_GOOGLE_CONFIG_COLLECTION, STORE_WHATSAPP_CONFIG_COLLECTION, } from "../schemas/firestore.js";
18
+ import { ANALYTICS_ALERTS_COLLECTION, ANALYTICS_CARDS_COLLECTION, ITEM_REQUESTS_COLLECTION, LISTING_TEMPLATES_COLLECTION, MODERATION_QUEUE_COLLECTION, PAYOUT_METHODS_COLLECTION, REPORTS_COLLECTION, SHIPPING_CONFIGS_COLLECTION, STORE_CATEGORIES_COLLECTION, STORE_GOOGLE_CONFIG_COLLECTION, } from "../schemas/firestore.js";
19
19
  export class PayoutMethodsRepository extends BaseRepository {
20
20
  constructor() {
21
21
  super(PAYOUT_METHODS_COLLECTION);
@@ -149,14 +149,6 @@ export class ItemRequestsRepository extends BaseRepository {
149
149
  });
150
150
  }
151
151
  }
152
- export class StoreWhatsAppConfigRepository extends BaseRepository {
153
- constructor() {
154
- super(STORE_WHATSAPP_CONFIG_COLLECTION);
155
- }
156
- async getByStore(storeId) {
157
- return this.findOneBy("storeId", storeId);
158
- }
159
- }
160
152
  export class StoreGoogleConfigRepository extends BaseRepository {
161
153
  constructor() {
162
154
  super(STORE_GOOGLE_CONFIG_COLLECTION);
@@ -174,5 +166,4 @@ export const listingTemplatesRepository = new ListingTemplatesRepository();
174
166
  export const moderationQueueRepository = new ModerationQueueRepository();
175
167
  export const reportsRepository = new ReportsRepository();
176
168
  export const itemRequestsRepository = new ItemRequestsRepository();
177
- export const storeWhatsAppConfigRepository = new StoreWhatsAppConfigRepository();
178
169
  export const storeGoogleConfigRepository = new StoreGoogleConfigRepository();
@@ -18,7 +18,6 @@ import type { BaseDocument } from "../../../_internal/shared/types/base-document
18
18
  * 7. moderationQueue — video / media moderation queue items
19
19
  * 8. reports — buyer-submitted reports against listings/stores
20
20
  * 9. itemRequests — community item request bulletin board
21
- * 10. storeWhatsAppConfig — per-store WhatsApp business catalogue + auto-replies
22
21
  * 11. storeGoogleConfig — per-store Google Business reviews integration
23
22
  */
24
23
  export type PayoutMethodType = "upi" | "bank" | "card" | "other";
@@ -89,7 +88,7 @@ export interface AnalyticsAlertDocument extends BaseDocument {
89
88
  threshold: number;
90
89
  windowHours: number;
91
90
  isActive: boolean;
92
- notifyChannels: Array<"in-app" | "email" | "whatsapp">;
91
+ notifyChannels: Array<"in-app" | "email">;
93
92
  /**
94
93
  * When this alert last fired.
95
94
  *
@@ -221,21 +220,6 @@ export interface ItemRequestDocument extends BaseDocument {
221
220
  export declare const ITEM_REQUESTS_COLLECTION: "itemRequests";
222
221
  export declare const ITEM_REQUEST_INDEXED_FIELDS: readonly ["opUserId", "status", "category", "createdAt"];
223
222
  export declare const DEFAULT_ITEM_REQUEST_DATA: Partial<ItemRequestDocument>;
224
- export interface StoreWhatsAppConfigDocument extends BaseDocument {
225
- storeId: string;
226
- isConnected: boolean;
227
- isPaid: boolean;
228
- phoneNumber?: string;
229
- businessProfileName?: string;
230
- catalogUrl?: string;
231
- autoReply?: string;
232
- welcomeMessage?: string;
233
- /** Status of pending WhatsApp Business onboarding (Meta Cloud API). */
234
- onboardingStatus?: "pending" | "approved" | "rejected";
235
- }
236
- export declare const STORE_WHATSAPP_CONFIG_COLLECTION: "storeWhatsAppConfig";
237
- export declare const STORE_WHATSAPP_CONFIG_INDEXED_FIELDS: readonly ["storeId", "isConnected", "isPaid"];
238
- export declare const DEFAULT_STORE_WHATSAPP_CONFIG_DATA: Partial<StoreWhatsAppConfigDocument>;
239
223
  export interface StoreGoogleConfigDocument extends BaseDocument {
240
224
  storeId: string;
241
225
  isConnected: boolean;