@mohasinac/appkit 2.7.26 → 2.7.30
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.
- package/dist/_internal/client/features/classified/ClassifiedDetailView.js +2 -2
- package/dist/_internal/client/features/digital-code/CodeRevealPanel.js +2 -2
- package/dist/_internal/client/features/layout/DashboardLayoutClient.js +1 -1
- package/dist/_internal/server/features/checkout/actions.js +42 -35
- package/dist/_internal/server/features/classified/adapters.d.ts +21 -0
- package/dist/_internal/server/features/classified/adapters.js +24 -0
- package/dist/_internal/server/features/classified/index.d.ts +3 -0
- package/dist/_internal/server/features/classified/index.js +3 -0
- package/dist/_internal/server/features/classified/metadata.d.ts +8 -0
- package/dist/_internal/server/features/classified/metadata.js +43 -0
- package/dist/_internal/server/features/classified/og.d.ts +30 -0
- package/dist/_internal/server/features/classified/og.js +76 -0
- package/dist/_internal/server/features/digital-code/adapters.d.ts +21 -0
- package/dist/_internal/server/features/digital-code/adapters.js +29 -0
- package/dist/_internal/server/features/digital-code/index.d.ts +3 -0
- package/dist/_internal/server/features/digital-code/index.js +3 -0
- package/dist/_internal/server/features/digital-code/metadata.d.ts +8 -0
- package/dist/_internal/server/features/digital-code/metadata.js +36 -0
- package/dist/_internal/server/features/digital-code/og.d.ts +27 -0
- package/dist/_internal/server/features/digital-code/og.js +77 -0
- package/dist/_internal/server/features/live/adapters.d.ts +21 -0
- package/dist/_internal/server/features/live/adapters.js +34 -0
- package/dist/_internal/server/features/live/index.d.ts +3 -0
- package/dist/_internal/server/features/live/index.js +3 -0
- package/dist/_internal/server/features/live/metadata.d.ts +8 -0
- package/dist/_internal/server/features/live/metadata.js +39 -0
- package/dist/_internal/server/features/live/og.d.ts +27 -0
- package/dist/_internal/server/features/live/og.js +72 -0
- package/dist/_internal/server/features/promotions/actions.js +4 -3
- package/dist/_internal/server/jobs/core/onOrderCreate.js +19 -16
- package/dist/_internal/server/jobs/core/onOrderStatusChange.js +25 -22
- package/dist/_internal/server/jobs/core/onProductWrite.js +48 -58
- package/dist/_internal/shared/actions/action-registry.js +310 -8
- package/dist/_internal/shared/features/blog/schema.d.ts +4 -4
- package/dist/_internal/shared/features/brands/schema.d.ts +5 -5
- package/dist/_internal/shared/features/cart/schema.d.ts +18 -18
- package/dist/_internal/shared/features/categories/bundle-copy.d.ts +1 -1
- package/dist/_internal/shared/features/categories/bundle-schemas.d.ts +38 -38
- package/dist/_internal/shared/features/events/schema.d.ts +8 -8
- package/dist/_internal/shared/features/orders/schema.d.ts +8 -8
- package/dist/_internal/shared/features/products/schema.d.ts +42 -42
- package/dist/_internal/shared/features/promotions/schema.d.ts +4 -4
- package/dist/_internal/shared/features/reviews/schema.d.ts +1 -1
- package/dist/_internal/shared/media/limits.js +4 -3
- package/dist/client.d.ts +2 -0
- package/dist/client.js +1 -0
- package/dist/configs/next.js +4 -0
- package/dist/constants/table-keys.d.ts +6 -0
- package/dist/constants/table-keys.js +9 -0
- package/dist/core/hooks/useSyncManager.js +9 -8
- package/dist/features/about/components/FeesView.js +10 -7
- package/dist/features/about/components/HelpPageView.js +10 -1
- package/dist/features/about/components/HowAuctionsWorkView.js +10 -1
- package/dist/features/about/components/HowCheckoutWorksView.js +10 -1
- package/dist/features/about/components/HowOffersWorkView.js +10 -1
- package/dist/features/about/components/HowOrdersWorkView.js +10 -1
- package/dist/features/about/components/HowPayoutsWorkView.js +10 -1
- package/dist/features/about/components/HowPreOrdersWorkView.js +10 -1
- package/dist/features/about/components/HowReviewsWorkView.js +10 -1
- package/dist/features/about/components/PublicProfileView.js +44 -14
- package/dist/features/about/components/SecurityPrivacyView.js +7 -1
- package/dist/features/account/components/AddressesIndexListing.js +2 -2
- package/dist/features/account/components/NotificationBell.js +27 -16
- package/dist/features/account/components/NotificationPreferencesPanel.d.ts +9 -0
- package/dist/features/account/components/NotificationPreferencesPanel.js +91 -0
- package/dist/features/account/components/UserSidebar.js +4 -4
- package/dist/features/account/components/UserSupportView.js +16 -6
- package/dist/features/account/components/index.d.ts +2 -0
- package/dist/features/account/components/index.js +1 -0
- package/dist/features/account/schemas/index.d.ts +4 -4
- package/dist/features/account/types/index.d.ts +34 -0
- package/dist/features/admin/actions/admin-actions.js +4 -3
- package/dist/features/admin/actions/notification-actions.d.ts +24 -22
- package/dist/features/admin/actions/notification-actions.js +122 -22
- package/dist/features/admin/components/AdminAdEditorView.js +29 -15
- package/dist/features/admin/components/AdminAdsView.js +22 -28
- package/dist/features/admin/components/AdminAllEventEntriesView.js +6 -1
- package/dist/features/admin/components/AdminBidsView.js +10 -3
- package/dist/features/admin/components/AdminBlogEditorView.js +2 -2
- package/dist/features/admin/components/AdminBlogView.js +8 -3
- package/dist/features/admin/components/AdminBrandsView.js +7 -2
- package/dist/features/admin/components/AdminBundleEditorView.js +5 -2
- package/dist/features/admin/components/AdminCarouselEditorView.js +6 -3
- package/dist/features/admin/components/AdminCarouselView.js +13 -7
- package/dist/features/admin/components/AdminCategoriesView.js +8 -3
- package/dist/features/admin/components/AdminCategoryEditorView.js +2 -2
- package/dist/features/admin/components/AdminContactView.js +6 -1
- package/dist/features/admin/components/AdminCouponEditorView.js +8 -2
- package/dist/features/admin/components/AdminCouponsView.js +6 -1
- package/dist/features/admin/components/AdminEmployeeEditorView.js +12 -9
- package/dist/features/admin/components/AdminFaqEditorView.js +2 -2
- package/dist/features/admin/components/AdminFaqsView.js +7 -2
- package/dist/features/admin/components/AdminFeaturesView.js +4 -3
- package/dist/features/admin/components/AdminMediaView.js +9 -8
- package/dist/features/admin/components/AdminNavigationView.js +10 -17
- package/dist/features/admin/components/AdminNewsletterView.js +6 -1
- package/dist/features/admin/components/AdminNotificationsView.js +11 -3
- package/dist/features/admin/components/AdminOrdersView.js +6 -1
- package/dist/features/admin/components/AdminPayoutsView.js +10 -3
- package/dist/features/admin/components/AdminPrizeDrawsView.js +10 -3
- package/dist/features/admin/components/AdminProductsView.js +18 -12
- package/dist/features/admin/components/AdminReviewsView.js +33 -24
- package/dist/features/admin/components/AdminScammerEditorView.js +3 -2
- package/dist/features/admin/components/AdminScammersView.js +28 -26
- package/dist/features/admin/components/AdminSectionsView.js +112 -99
- package/dist/features/admin/components/AdminSessionsView.js +10 -3
- package/dist/features/admin/components/AdminSidebar.js +4 -4
- package/dist/features/admin/components/AdminSiteSettingsView.js +45 -4
- package/dist/features/admin/components/AdminStoresView.js +6 -1
- package/dist/features/admin/components/AdminSublistingCategoriesView.js +0 -1
- package/dist/features/admin/components/AdminSupportTicketDetailView.js +1 -1
- package/dist/features/admin/components/AdminSupportTicketsView.js +32 -34
- package/dist/features/admin/components/AdminTeamView.js +6 -1
- package/dist/features/admin/components/AdminUserEditorView.js +8 -15
- package/dist/features/admin/components/AdminUsersView.js +6 -1
- package/dist/features/admin/components/AdminViewCards.js +4 -3
- package/dist/features/admin/components/DashboardStats.js +2 -2
- package/dist/features/admin/components/DataTable.js +2 -2
- package/dist/features/admin/components/sections/adminSectionsTypes.js +4 -3
- package/dist/features/admin/repository/chat.repository.js +8 -8
- package/dist/features/admin/repository/site-settings.repository.d.ts +1 -0
- package/dist/features/admin/repository/site-settings.repository.js +11 -9
- package/dist/features/admin/schemas/firestore.d.ts +38 -0
- package/dist/features/admin/schemas/firestore.js +15 -0
- package/dist/features/auctions/components/AuctionDetailPageView.js +13 -19
- package/dist/features/auctions/components/MarketplaceAuctionCard.js +18 -9
- package/dist/features/auctions/components/MarketplaceAuctionGrid.js +3 -2
- package/dist/features/auctions/components/index.d.ts +0 -1
- package/dist/features/auctions/components/index.js +0 -1
- package/dist/features/auctions/schemas/index.d.ts +14 -14
- package/dist/features/auth/actions/realtime-token-actions.js +19 -4
- package/dist/features/auth/components/RegisterForm.js +8 -4
- package/dist/features/auth/consent-otp.d.ts +2 -0
- package/dist/features/auth/consent-otp.js +8 -0
- package/dist/features/auth/schemas/firestore.d.ts +2 -0
- package/dist/features/auth/schemas/firestore.js +18 -25
- package/dist/features/auth/schemas/index.d.ts +2 -2
- package/dist/features/before-after/api/[id]/route.js +8 -6
- package/dist/features/before-after/schemas/index.d.ts +2 -2
- package/dist/features/blog/actions/blog-actions.d.ts +3 -3
- package/dist/features/blog/components/BlogIndexListing.js +21 -2
- package/dist/features/blog/components/BlogPostForm.js +11 -5
- package/dist/features/blog/components/BlogPostView.js +10 -2
- package/dist/features/blog/schemas/index.d.ts +18 -18
- package/dist/features/cart/components/CartDrawer.js +3 -2
- package/dist/features/cart/repository/cart.repository.js +4 -3
- package/dist/features/cart/utils/pending-ops.d.ts +1 -1
- package/dist/features/categories/api/[id]/route.js +4 -3
- package/dist/features/categories/api/route.js +4 -3
- package/dist/features/categories/components/BrandDetailPageView.js +2 -2
- package/dist/features/categories/components/BrandDetailTabs.js +2 -2
- package/dist/features/categories/components/BundleCollage.d.ts +8 -0
- package/dist/features/categories/components/BundleCollage.js +50 -0
- package/dist/features/categories/components/BundleDetailView.js +2 -10
- package/dist/features/categories/components/BundleItemsPicker.js +20 -13
- package/dist/features/categories/components/CategoriesIndexListing.js +28 -9
- package/dist/features/categories/components/CategoryDetailPageView.js +2 -2
- package/dist/features/categories/components/CategoryDetailTabs.js +2 -2
- package/dist/features/categories/components/CategoryProductsListing.js +52 -13
- package/dist/features/categories/components/index.d.ts +2 -0
- package/dist/features/categories/components/index.js +1 -0
- package/dist/features/categories/schemas/index.d.ts +6 -6
- package/dist/features/checkout/actions/checkout-actions.js +4 -3
- package/dist/features/checkout/hooks/usePaymentCheckout.js +31 -22
- package/dist/features/classified/components/ClassifiedFilters.d.ts +8 -0
- package/dist/features/classified/components/ClassifiedFilters.js +19 -0
- package/dist/features/classified/components/ClassifiedIndexListing.d.ts +4 -0
- package/dist/features/classified/components/ClassifiedIndexListing.js +110 -0
- package/dist/features/classified/components/ClassifiedListView.d.ts +6 -0
- package/dist/features/classified/components/ClassifiedListView.js +43 -0
- package/dist/features/classified/components/index.d.ts +6 -0
- package/dist/features/classified/components/index.js +3 -0
- package/dist/features/collections/api/[slug]/route.js +16 -12
- package/dist/features/collections/schemas/index.d.ts +5 -5
- package/dist/features/consultation/api/[id]/route.js +12 -9
- package/dist/features/consultation/components/ConsultationForm.js +3 -2
- package/dist/features/consultation/schemas/index.d.ts +6 -6
- package/dist/features/contact/email.js +77 -116
- package/dist/features/copilot/components/AdminCopilotView.js +12 -2
- package/dist/features/corporate/api/[id]/route.js +12 -9
- package/dist/features/corporate/components/CorporateInquiryForm.js +2 -1
- package/dist/features/digital-codes/components/DigitalCodeFilters.d.ts +8 -0
- package/dist/features/digital-codes/components/DigitalCodeFilters.js +16 -0
- package/dist/features/digital-codes/components/DigitalCodesIndexListing.d.ts +4 -0
- package/dist/features/digital-codes/components/DigitalCodesIndexListing.js +107 -0
- package/dist/features/digital-codes/components/DigitalCodesListView.d.ts +6 -0
- package/dist/features/digital-codes/components/DigitalCodesListView.js +37 -0
- package/dist/features/digital-codes/components/index.d.ts +6 -0
- package/dist/features/digital-codes/components/index.js +3 -0
- package/dist/features/events/actions/event-actions.js +4 -3
- package/dist/features/events/components/AdminEventEditorView.js +3 -2
- package/dist/features/events/components/AdminEventsView.js +4 -2
- package/dist/features/events/components/EventPollWidget.js +5 -5
- package/dist/features/events/components/EventsIndexListing.js +2 -2
- package/dist/features/events/schemas/index.d.ts +20 -20
- package/dist/features/faq/actions/faq-actions.d.ts +8 -8
- package/dist/features/faq/components/ContactCTA.js +3 -1
- package/dist/features/faq/components/FAQAccordion.js +1 -1
- package/dist/features/faq/schemas/index.d.ts +4 -4
- package/dist/features/filters/AsyncFacetSection.d.ts +18 -0
- package/dist/features/filters/AsyncFacetSection.js +65 -0
- package/dist/features/forms/Checkbox.js +2 -2
- package/dist/features/forms/Input.js +2 -2
- package/dist/features/forms/Radio.js +5 -5
- package/dist/features/forms/Select.js +2 -2
- package/dist/features/forms/Slider.js +2 -2
- package/dist/features/forms/Textarea.js +2 -2
- package/dist/features/homepage/api/[id]/route.js +4 -3
- package/dist/features/homepage/api/sections/[id]/route.js +12 -9
- package/dist/features/homepage/components/AdSlot.js +2 -1
- package/dist/features/homepage/components/AdvertisementBanner.js +5 -3
- package/dist/features/homepage/components/BrandsSection.js +2 -2
- package/dist/features/homepage/components/CTABannerSection.js +2 -2
- package/dist/features/homepage/components/CharacterHotspot.d.ts +2 -2
- package/dist/features/homepage/components/CharacterHotspot.js +119 -157
- package/dist/features/homepage/components/CharacterHotspotForm.js +25 -20
- package/dist/features/homepage/components/CustomCardsSection.js +8 -6
- package/dist/features/homepage/components/FeaturedProductsSection.js +2 -2
- package/dist/features/homepage/components/GoogleReviewsSection.js +3 -3
- package/dist/features/homepage/components/HeroBanner.js +5 -4
- package/dist/features/homepage/components/HeroCarousel.js +13 -26
- package/dist/features/homepage/components/HowItWorksSection.js +4 -2
- package/dist/features/homepage/components/SocialFeedSection.js +2 -2
- package/dist/features/homepage/components/SocialPostCard.js +3 -2
- package/dist/features/homepage/lib/social-feed-fetcher.js +6 -3
- package/dist/features/layout/AppLayoutShell.d.ts +8 -2
- package/dist/features/layout/AppLayoutShell.js +55 -84
- package/dist/features/layout/BottomActions.js +43 -48
- package/dist/features/layout/NavbarWithSettings.d.ts +6 -0
- package/dist/features/layout/NavbarWithSettings.js +11 -0
- package/dist/features/live/components/LiveItemFilters.d.ts +8 -0
- package/dist/features/live/components/LiveItemFilters.js +23 -0
- package/dist/features/live/components/LiveItemsIndexListing.d.ts +4 -0
- package/dist/features/live/components/LiveItemsIndexListing.js +108 -0
- package/dist/features/live/components/LiveItemsListView.d.ts +6 -0
- package/dist/features/live/components/LiveItemsListView.js +43 -0
- package/dist/features/live/components/index.d.ts +6 -0
- package/dist/features/live/components/index.js +3 -0
- package/dist/features/media/MediaLightbox.js +8 -14
- package/dist/features/media/types/index.d.ts +2 -2
- package/dist/features/media/upload/CameraCapture.js +2 -2
- package/dist/features/media/upload/ImageUpload.js +4 -2
- package/dist/features/media/upload/MediaUploadField.js +24 -8
- package/dist/features/media/upload/MediaUploadList.js +1 -1
- package/dist/features/orders/actions/order-actions.js +4 -3
- package/dist/features/orders/components/MarketplaceOrderCard.js +2 -1
- package/dist/features/orders/components/OrderFilters.js +12 -9
- package/dist/features/orders/schemas/index.d.ts +6 -6
- package/dist/features/pre-orders/api/[id]/route.js +12 -9
- package/dist/features/pre-orders/components/MarketplacePreorderCard.js +5 -4
- package/dist/features/pre-orders/components/PreOrderDetailPageView.js +27 -20
- package/dist/features/pre-orders/components/PreOrdersIndexListing.js +17 -52
- package/dist/features/pre-orders/components/PreorderCard.d.ts +0 -9
- package/dist/features/pre-orders/components/PreorderCard.js +2 -13
- package/dist/features/pre-orders/components/index.d.ts +1 -1
- package/dist/features/pre-orders/components/index.js +1 -1
- package/dist/features/pre-orders/schemas/index.d.ts +10 -10
- package/dist/features/products/api/[id]/route.js +9 -7
- package/dist/features/products/api/route.js +1 -1
- package/dist/features/products/columns/productTableColumns.js +2 -2
- package/dist/features/products/components/AuctionsIndexListing.js +15 -51
- package/dist/features/products/components/BidHistory.js +2 -2
- package/dist/features/products/components/CompareOverlay.js +3 -2
- package/dist/features/products/components/MakeOfferButton.js +20 -14
- package/dist/features/products/components/MarketplacePrizeDrawCard.js +2 -1
- package/dist/features/products/components/PrizeDrawCollage.d.ts +1 -15
- package/dist/features/products/components/PrizeDrawCollage.js +54 -14
- package/dist/features/products/components/PrizeDrawDetailPageView.js +2 -1
- package/dist/features/products/components/PrizeDrawEntryActions.js +2 -1
- package/dist/features/products/components/PrizeDrawItemsEditor.js +9 -7
- package/dist/features/products/components/PrizeDrawsIndexListing.js +18 -51
- package/dist/features/products/components/PrizeRevealModal.js +24 -14
- package/dist/features/products/components/ProductDetailPageView.js +2 -1
- package/dist/features/products/components/ProductFilters.js +8 -6
- package/dist/features/products/components/ProductForm.js +12 -10
- package/dist/features/products/components/ProductGalleryClient.js +2 -1
- package/dist/features/products/components/ProductGrid.js +11 -14
- package/dist/features/products/components/ProductsIndexListing.js +16 -52
- package/dist/features/products/components/ProductsIndexPageView.js +2 -2
- package/dist/features/products/schemas/index.d.ts +56 -56
- package/dist/features/products/schemas/product-features.validators.d.ts +14 -14
- package/dist/features/promotions/components/CouponsIndexListing.js +1 -1
- package/dist/features/promotions/schemas/index.d.ts +6 -6
- package/dist/features/reviews/actions/review-actions.js +6 -5
- package/dist/features/reviews/api/[id]/route.js +4 -3
- package/dist/features/reviews/components/ReviewDetailPageView.js +2 -2
- package/dist/features/reviews/components/ReviewDetailShell.js +6 -3
- package/dist/features/reviews/components/ReviewsIndexListing.js +2 -2
- package/dist/features/reviews/schemas/index.d.ts +6 -6
- package/dist/features/scams/components/ScamProfileView.js +19 -10
- package/dist/features/scams/components/ScamRegistryView.js +2 -1
- package/dist/features/search/components/Search.d.ts +1 -1
- package/dist/features/search/components/Search.js +56 -49
- package/dist/features/search/schemas/index.d.ts +5 -5
- package/dist/features/seller/actions/offer-actions.js +11 -9
- package/dist/features/seller/components/SellerAddressesView.js +6 -4
- package/dist/features/seller/components/SellerBidsView.js +2 -2
- package/dist/features/seller/components/SellerCouponsView.js +1 -1
- package/dist/features/seller/components/SellerOffersPanel.js +6 -1
- package/dist/features/seller/components/SellerOrdersView.js +1 -1
- package/dist/features/seller/components/SellerPayoutSettingsView.js +3 -3
- package/dist/features/seller/components/SellerPreOrdersView.js +5 -4
- package/dist/features/seller/components/SellerPrizeDrawsView.js +5 -4
- package/dist/features/seller/components/SellerProductShell.d.ts +19 -1
- package/dist/features/seller/components/SellerProductShell.js +75 -9
- package/dist/features/seller/components/SellerProductsView.js +10 -11
- package/dist/features/seller/components/SellerShippingView.js +3 -3
- package/dist/features/seller/components/SellerSidebar.js +10 -7
- package/dist/features/seller/components/SellerStorefrontView.js +3 -3
- package/dist/features/seller/schemas/index.d.ts +4 -4
- package/dist/features/shell/FormShell.js +2 -1
- package/dist/features/shell/QuickFormDrawer.js +4 -3
- package/dist/features/shell/StepForm.js +4 -3
- package/dist/features/stores/actions/store-query-actions.js +4 -3
- package/dist/features/stores/components/StoreAboutView.js +2 -1
- package/dist/features/stores/components/StoreAuctionsListing.js +43 -64
- package/dist/features/stores/components/StoreDetailLayoutView.js +2 -2
- package/dist/features/stores/components/StorePreOrdersListing.js +33 -57
- package/dist/features/stores/components/StoreProductsListing.js +16 -49
- package/dist/features/stores/components/StoresIndexListing.js +2 -2
- package/dist/features/stores/schemas/index.d.ts +2 -2
- package/dist/features/whatsapp-bot/components/SellerWhatsAppSettingsView.js +8 -7
- package/dist/features/wishlist/hooks/useGuestWishlist.d.ts +5 -5
- package/dist/features/wishlist/hooks/useWishlistWithGuest.d.ts +6 -6
- package/dist/features/wishlist/utils/guest-wishlist.d.ts +5 -5
- package/dist/index.d.ts +21 -3
- package/dist/index.js +1737 -1725
- package/dist/monitoring/server-logger.js +5 -9
- package/dist/next/api/apiHandler.js +56 -37
- package/dist/next/components/GlobalError.js +2 -1
- package/dist/next/routing/route-map.d.ts +27 -0
- package/dist/next/routing/route-map.js +10 -0
- package/dist/react/ErrorBoundary.js +2 -1
- package/dist/react/contexts/SessionContext.js +38 -28
- package/dist/react/hooks/useCamera.d.ts +1 -1
- package/dist/react/hooks/useCamera.js +8 -7
- package/dist/seed/site-settings-seed-data.js +6 -0
- package/dist/server-entry.d.ts +3 -0
- package/dist/server-entry.js +3 -0
- package/dist/server.d.ts +12 -0
- package/dist/server.js +15 -0
- package/dist/tailwind-utilities.css +1 -1
- package/dist/ui/DataTable.js +28 -7
- package/dist/ui/components/Button.d.ts +8 -1
- package/dist/ui/components/Button.js +47 -8
- package/dist/ui/components/CollageLightbox.d.ts +18 -0
- package/dist/ui/components/CollageLightbox.js +41 -0
- package/dist/ui/components/Dropdown.js +7 -6
- package/dist/ui/components/ImageLightbox.d.ts +7 -1
- package/dist/ui/components/ImageLightbox.js +15 -5
- package/dist/ui/components/PageLoader.js +4 -3
- package/dist/ui/components/PaginatedMultiSelect.d.ts +28 -0
- package/dist/ui/components/PaginatedMultiSelect.js +141 -0
- package/dist/ui/components/PaginatedMultiSelect.style.css +272 -0
- package/dist/ui/components/Semantic.js +1 -1
- package/dist/ui/components/SideDrawer.js +17 -15
- package/dist/ui/components/index.style.css +1 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +1 -0
- package/dist/utils/number.formatter.js +5 -13
- package/dist/utils/string.formatter.js +21 -18
- package/dist/validation/schemas.d.ts +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { formatCurrency } from "../../../../utils/number.formatter";
|
|
2
|
+
/** Maps a raw `ProductDocument` to the client-safe live-item shape. Strips vendorVerified (admin-only). */
|
|
3
|
+
export function toClientLiveItem(doc) {
|
|
4
|
+
const li = doc.liveItem ?? null;
|
|
5
|
+
return {
|
|
6
|
+
id: doc.id,
|
|
7
|
+
title: doc.title,
|
|
8
|
+
description: doc.description,
|
|
9
|
+
price: doc.price,
|
|
10
|
+
priceLabel: formatCurrency(doc.price, doc.currency ?? "INR"),
|
|
11
|
+
currency: doc.currency ?? "INR",
|
|
12
|
+
mainImage: doc.mainImage || doc.images?.[0] || null,
|
|
13
|
+
images: doc.images ?? [],
|
|
14
|
+
storeId: doc.storeId,
|
|
15
|
+
storeName: doc.storeName ?? null,
|
|
16
|
+
category: doc.category,
|
|
17
|
+
tags: doc.tags ?? [],
|
|
18
|
+
liveItem: li
|
|
19
|
+
? {
|
|
20
|
+
species: li.species,
|
|
21
|
+
ageMonths: li.ageMonths,
|
|
22
|
+
sex: li.sex,
|
|
23
|
+
careInfo: li.careInfo,
|
|
24
|
+
transport: li.transport,
|
|
25
|
+
jurisdictionAllowed: li.jurisdictionAllowed,
|
|
26
|
+
cites: li.cites,
|
|
27
|
+
}
|
|
28
|
+
: null,
|
|
29
|
+
status: doc.status,
|
|
30
|
+
createdAt: doc.createdAt instanceof Date
|
|
31
|
+
? doc.createdAt.toISOString()
|
|
32
|
+
: String(doc.createdAt),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
2
|
+
import type { ProductDocument } from "../../../../features/products/schemas/firestore";
|
|
3
|
+
export interface LiveItemMetadataOptions {
|
|
4
|
+
siteName?: string;
|
|
5
|
+
siteUrl?: string;
|
|
6
|
+
ogImageUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function buildLiveItemMetadata(product: ProductDocument | null, opts?: LiveItemMetadataOptions): Metadata;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export function buildLiveItemMetadata(product, opts) {
|
|
2
|
+
const siteName = opts?.siteName?.trim() || "";
|
|
3
|
+
const suffix = siteName ? ` — ${siteName}` : "";
|
|
4
|
+
if (!product) {
|
|
5
|
+
return {
|
|
6
|
+
title: `Live listing not found${suffix}`,
|
|
7
|
+
description: "This live listing is unavailable or has been removed.",
|
|
8
|
+
robots: { index: false },
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const species = product.liveItem?.species
|
|
12
|
+
? ` (${product.liveItem.species})`
|
|
13
|
+
: "";
|
|
14
|
+
const title = `${product.title}${species}${suffix}`;
|
|
15
|
+
const description = product.seoDescription?.trim()
|
|
16
|
+
? product.seoDescription.trim()
|
|
17
|
+
: product.description?.slice(0, 160) ?? "";
|
|
18
|
+
const image = opts?.ogImageUrl ?? (product.mainImage || product.images?.[0] || null);
|
|
19
|
+
const siteUrl = opts?.siteUrl?.replace(/\/+$/, "");
|
|
20
|
+
const canonical = siteUrl ? `${siteUrl}/live/${product.id}` : undefined;
|
|
21
|
+
return {
|
|
22
|
+
title,
|
|
23
|
+
description,
|
|
24
|
+
alternates: canonical ? { canonical } : undefined,
|
|
25
|
+
openGraph: {
|
|
26
|
+
title,
|
|
27
|
+
description,
|
|
28
|
+
url: canonical,
|
|
29
|
+
type: "website",
|
|
30
|
+
images: image ? [{ url: image }] : undefined,
|
|
31
|
+
},
|
|
32
|
+
twitter: {
|
|
33
|
+
card: image ? "summary_large_image" : "summary",
|
|
34
|
+
title,
|
|
35
|
+
description,
|
|
36
|
+
images: image ? [image] : undefined,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { ProductDocument } from "../../../../features/products/schemas/firestore";
|
|
3
|
+
export interface LiveItemOgData {
|
|
4
|
+
title: string;
|
|
5
|
+
species?: string | null;
|
|
6
|
+
priceLabel?: string | null;
|
|
7
|
+
imageUrl?: string | null;
|
|
8
|
+
}
|
|
9
|
+
interface LiveItemDocLike {
|
|
10
|
+
title?: string | null;
|
|
11
|
+
price?: number | null;
|
|
12
|
+
currency?: string | null;
|
|
13
|
+
mainImage?: string | null;
|
|
14
|
+
images?: (string | null | undefined)[] | null;
|
|
15
|
+
liveItem?: {
|
|
16
|
+
species?: string;
|
|
17
|
+
} | null;
|
|
18
|
+
}
|
|
19
|
+
export declare function renderLiveItemOg(doc: LiveItemDocLike | null | undefined, opts: {
|
|
20
|
+
siteName: string;
|
|
21
|
+
}): ReactElement;
|
|
22
|
+
export declare function renderLiveItemOgImage(data: LiveItemOgData, siteName: string): ReactElement;
|
|
23
|
+
/** Type-safe overload that accepts the full ProductDocument. */
|
|
24
|
+
export declare function renderLiveItemOgFromDoc(doc: ProductDocument | null | undefined, opts: {
|
|
25
|
+
siteName: string;
|
|
26
|
+
}): ReactElement;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function renderLiveItemOg(doc, opts) {
|
|
3
|
+
const priceLabel = doc?.price != null
|
|
4
|
+
? new Intl.NumberFormat("en-IN", {
|
|
5
|
+
style: "currency",
|
|
6
|
+
currency: doc.currency ?? "INR",
|
|
7
|
+
maximumFractionDigits: 0,
|
|
8
|
+
}).format(doc.price / 100)
|
|
9
|
+
: null;
|
|
10
|
+
return renderLiveItemOgImage({
|
|
11
|
+
title: doc?.title ?? "Live Listing",
|
|
12
|
+
species: doc?.liveItem?.species ?? null,
|
|
13
|
+
priceLabel,
|
|
14
|
+
imageUrl: doc?.mainImage || doc?.images?.[0] || null,
|
|
15
|
+
}, opts.siteName);
|
|
16
|
+
}
|
|
17
|
+
export function renderLiveItemOgImage(data, siteName) {
|
|
18
|
+
const { title, species, priceLabel, imageUrl } = data;
|
|
19
|
+
return (_jsxs("div", { style: {
|
|
20
|
+
display: "flex",
|
|
21
|
+
width: "100%",
|
|
22
|
+
height: "100%",
|
|
23
|
+
background: "#052e16",
|
|
24
|
+
fontFamily: "sans-serif",
|
|
25
|
+
position: "relative",
|
|
26
|
+
overflow: "hidden",
|
|
27
|
+
}, children: [imageUrl && (_jsx("img", { src: imageUrl, alt: "", style: {
|
|
28
|
+
position: "absolute",
|
|
29
|
+
inset: 0,
|
|
30
|
+
width: "100%",
|
|
31
|
+
height: "100%",
|
|
32
|
+
objectFit: "cover",
|
|
33
|
+
opacity: 0.15,
|
|
34
|
+
} })), _jsx("div", { style: {
|
|
35
|
+
position: "absolute",
|
|
36
|
+
inset: 0,
|
|
37
|
+
background: "linear-gradient(135deg, rgba(5,46,22,0.96) 0%, rgba(5,46,22,0.82) 100%)",
|
|
38
|
+
} }), _jsxs("div", { style: {
|
|
39
|
+
position: "relative",
|
|
40
|
+
display: "flex",
|
|
41
|
+
width: "100%",
|
|
42
|
+
height: "100%",
|
|
43
|
+
padding: "60px",
|
|
44
|
+
gap: "48px",
|
|
45
|
+
alignItems: "center",
|
|
46
|
+
}, children: [imageUrl && (_jsx("img", { src: imageUrl, alt: title, style: {
|
|
47
|
+
width: 400,
|
|
48
|
+
height: 400,
|
|
49
|
+
objectFit: "contain",
|
|
50
|
+
borderRadius: 16,
|
|
51
|
+
flexShrink: 0,
|
|
52
|
+
} })), _jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 20, flex: 1 }, children: [_jsxs("div", { style: {
|
|
53
|
+
fontSize: 18,
|
|
54
|
+
color: "#86efac",
|
|
55
|
+
fontWeight: 600,
|
|
56
|
+
letterSpacing: 2,
|
|
57
|
+
textTransform: "uppercase",
|
|
58
|
+
}, children: [siteName, " \u00B7 Live Listing"] }), _jsx("div", { style: {
|
|
59
|
+
fontSize: imageUrl ? 44 : 56,
|
|
60
|
+
fontWeight: 700,
|
|
61
|
+
color: "#f1f5f9",
|
|
62
|
+
lineHeight: 1.2,
|
|
63
|
+
display: "-webkit-box",
|
|
64
|
+
WebkitLineClamp: 3,
|
|
65
|
+
WebkitBoxOrient: "vertical",
|
|
66
|
+
overflow: "hidden",
|
|
67
|
+
}, children: title }), species && (_jsx("div", { style: { fontSize: 24, color: "#86efac", fontStyle: "italic" }, children: species })), priceLabel && (_jsx("div", { style: { fontSize: 32, fontWeight: 700, color: "#4ade80" }, children: priceLabel }))] })] })] }));
|
|
68
|
+
}
|
|
69
|
+
/** Type-safe overload that accepts the full ProductDocument. */
|
|
70
|
+
export function renderLiveItemOgFromDoc(doc, opts) {
|
|
71
|
+
return renderLiveItemOg(doc, opts);
|
|
72
|
+
}
|
|
@@ -5,11 +5,12 @@ import { applyCouponSchema, createCouponSchema, updateCouponSchema, } from "../.
|
|
|
5
5
|
import { validateCoupon, computeDiscount } from "./service";
|
|
6
6
|
import { CouponNotFoundError } from "../../../shared/features/promotions/errors";
|
|
7
7
|
import { ValidationError } from "../../../shared/errors/index";
|
|
8
|
+
const ERR_INVALID_COUPON_INPUT = "Invalid coupon input";
|
|
8
9
|
export async function applyCouponAction(input) {
|
|
9
10
|
const user = await requireRoleUser(["buyer", "seller", "admin"]);
|
|
10
11
|
const parsed = applyCouponSchema.safeParse(input);
|
|
11
12
|
if (!parsed.success)
|
|
12
|
-
throw new ValidationError(parsed.error.issues[0]?.message ??
|
|
13
|
+
throw new ValidationError(parsed.error.issues[0]?.message ?? ERR_INVALID_COUPON_INPUT);
|
|
13
14
|
const coupon = await validateCoupon(parsed.data, user.uid);
|
|
14
15
|
const discount = computeDiscount(coupon, parsed.data.cartTotal);
|
|
15
16
|
await couponsRepository.applyCoupon(coupon.id, coupon.code, user.uid, [], discount);
|
|
@@ -19,7 +20,7 @@ export async function createCouponAction(input) {
|
|
|
19
20
|
const user = await requireRoleUser(["admin", "seller"]);
|
|
20
21
|
const parsed = createCouponSchema.safeParse(input);
|
|
21
22
|
if (!parsed.success)
|
|
22
|
-
throw new ValidationError(parsed.error.issues[0]?.message ??
|
|
23
|
+
throw new ValidationError(parsed.error.issues[0]?.message ?? ERR_INVALID_COUPON_INPUT);
|
|
23
24
|
return couponsRepository.createWithId(`coupon-${parsed.data.code.toLowerCase()}`, { ...parsed.data, createdBy: user.uid, usage: { ...parsed.data.usage, currentUsage: 0 } });
|
|
24
25
|
}
|
|
25
26
|
export async function updateCouponAction(couponId, input) {
|
|
@@ -29,7 +30,7 @@ export async function updateCouponAction(couponId, input) {
|
|
|
29
30
|
throw new CouponNotFoundError(couponId);
|
|
30
31
|
const parsed = updateCouponSchema.safeParse(input);
|
|
31
32
|
if (!parsed.success)
|
|
32
|
-
throw new ValidationError(parsed.error.issues[0]?.message ??
|
|
33
|
+
throw new ValidationError(parsed.error.issues[0]?.message ?? ERR_INVALID_COUPON_INPUT);
|
|
33
34
|
return couponsRepository.update(couponId, parsed.data);
|
|
34
35
|
}
|
|
35
36
|
export async function deactivateCouponAction(couponId) {
|
|
@@ -23,6 +23,24 @@ async function sendAnnouncement(ctx, toPhone, message, phoneNumberId, accessToke
|
|
|
23
23
|
ctx.logger.error(`Announcement send threw for ${label} (non-fatal)`, err, { orderId });
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
async function notifyStoreOwner(ctx, storeId, message, phoneNumberId, accessToken, orderId) {
|
|
27
|
+
try {
|
|
28
|
+
const store = await storeRepository.findBySlug(storeId);
|
|
29
|
+
if (!store?.ownerId)
|
|
30
|
+
return;
|
|
31
|
+
const owner = await userRepository.findById(store.ownerId);
|
|
32
|
+
const encryptedPhone = owner?.phoneNumber;
|
|
33
|
+
if (!encryptedPhone)
|
|
34
|
+
return;
|
|
35
|
+
const ownerPhone = decryptPii(encryptedPhone);
|
|
36
|
+
if (ownerPhone) {
|
|
37
|
+
await sendAnnouncement(ctx, ownerPhone, message, phoneNumberId, accessToken, "store-owner", orderId);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
ctx.logger.error("Store owner lookup failed (non-fatal)", err, { orderId, storeId });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
26
44
|
export async function handleOrderCreate(input, ctx) {
|
|
27
45
|
const { orderId, order } = input;
|
|
28
46
|
const phoneNumberId = ctx.env("WHATSAPP_PHONE_NUMBER_ID") ?? "";
|
|
@@ -53,22 +71,7 @@ export async function handleOrderCreate(input, ctx) {
|
|
|
53
71
|
}
|
|
54
72
|
const storeId = order.storeId;
|
|
55
73
|
if (storeId) {
|
|
56
|
-
|
|
57
|
-
const store = await storeRepository.findBySlug(storeId);
|
|
58
|
-
if (store?.ownerId) {
|
|
59
|
-
const owner = await userRepository.findById(store.ownerId);
|
|
60
|
-
const encryptedPhone = owner?.phoneNumber;
|
|
61
|
-
if (encryptedPhone) {
|
|
62
|
-
const ownerPhone = decryptPii(encryptedPhone);
|
|
63
|
-
if (ownerPhone) {
|
|
64
|
-
await sendAnnouncement(ctx, ownerPhone, message, phoneNumberId, accessToken, "store-owner", orderId);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch (err) {
|
|
70
|
-
ctx.logger.error("Store owner lookup failed (non-fatal)", err, { orderId, storeId });
|
|
71
|
-
}
|
|
74
|
+
await notifyStoreOwner(ctx, storeId, message, phoneNumberId, accessToken, orderId);
|
|
72
75
|
}
|
|
73
76
|
ctx.logger.info(`Order announcement complete`, {
|
|
74
77
|
orderId,
|
|
@@ -58,6 +58,30 @@ async function sendResendEmail(params) {
|
|
|
58
58
|
throw new Error(JOB_ERROR_MESSAGES.RESEND_API_ERROR(response.status, body));
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
+
async function sendStatusChangeEmail(ctx, userEmail, newStatus, orderId, after, apiKey) {
|
|
62
|
+
try {
|
|
63
|
+
const fromAddress = ctx.env("ORDER_EMAIL_FROM") ?? ctx.env("RESEND_FROM_ADDRESS") ?? "";
|
|
64
|
+
const brandName = ctx.env("APPKIT_BRAND_NAME") ?? "";
|
|
65
|
+
if (!fromAddress || !brandName) {
|
|
66
|
+
ctx.logger.error("ORDER_EMAIL_FROM / APPKIT_BRAND_NAME not configured — skipping order status email", null, { orderId });
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
await sendResendEmail({
|
|
70
|
+
to: userEmail,
|
|
71
|
+
status: newStatus,
|
|
72
|
+
orderId,
|
|
73
|
+
productTitle: after.productTitle,
|
|
74
|
+
trackingNumber: after.trackingNumber,
|
|
75
|
+
apiKey,
|
|
76
|
+
fromAddress,
|
|
77
|
+
brandName,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (emailError) {
|
|
82
|
+
ctx.logger.error("Email send failed (non-fatal)", emailError, { orderId });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
61
85
|
export async function handleOrderStatusChange(input, ctx) {
|
|
62
86
|
const { orderId, before, after } = input;
|
|
63
87
|
if (!before || !after)
|
|
@@ -103,28 +127,7 @@ export async function handleOrderStatusChange(input, ctx) {
|
|
|
103
127
|
ctx.logger.error(JOB_ERROR_MESSAGES.RESEND_KEY_MISSING, null);
|
|
104
128
|
}
|
|
105
129
|
else {
|
|
106
|
-
|
|
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
|
-
}
|
|
130
|
+
await sendStatusChangeEmail(ctx, userEmail, newStatus, orderId, after, apiKey);
|
|
128
131
|
}
|
|
129
132
|
}
|
|
130
133
|
ctx.logger.info(`Order ${orderId} status → ${newStatus}`, {
|
|
@@ -16,6 +16,50 @@ async function getParentIds(categoryId) {
|
|
|
16
16
|
return [];
|
|
17
17
|
return (await categoriesRepository.findById(categoryId))?.parentIds ?? [];
|
|
18
18
|
}
|
|
19
|
+
async function dispatchProductWriteEvent(p) {
|
|
20
|
+
const { productId, beforeCategory, afterCategory, beforeStoreId, afterStoreId, isAuction, beforeIsAuction, wasPublished, isPublished, isDelete, ctx } = p;
|
|
21
|
+
if (isDelete && wasPublished && beforeCategory) {
|
|
22
|
+
const parentIds = await getParentIds(beforeCategory);
|
|
23
|
+
const batch = ctx.db.batch();
|
|
24
|
+
categoriesRepository.updateMetricsInBatch(batch, beforeCategory, parentIds, beforeIsAuction ? 0 : -1, beforeIsAuction ? -1 : 0, productId);
|
|
25
|
+
await batch.commit();
|
|
26
|
+
if (beforeStoreId)
|
|
27
|
+
await storeRepository.incrementTotalProducts(beforeStoreId, -1);
|
|
28
|
+
ctx.logger.info("Decremented counters on hard-delete", { productId, category: beforeCategory, storeId: beforeStoreId });
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!wasPublished && isPublished && afterCategory) {
|
|
32
|
+
const parentIds = await getParentIds(afterCategory);
|
|
33
|
+
const batch = ctx.db.batch();
|
|
34
|
+
categoriesRepository.updateMetricsInBatch(batch, afterCategory, parentIds, isAuction ? 0 : 1, isAuction ? 1 : 0, productId);
|
|
35
|
+
await batch.commit();
|
|
36
|
+
if (afterStoreId)
|
|
37
|
+
await storeRepository.incrementTotalProducts(afterStoreId, 1);
|
|
38
|
+
ctx.logger.info("Incremented counters on publish", { productId, category: afterCategory, storeId: afterStoreId });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (wasPublished && !isPublished && beforeCategory) {
|
|
42
|
+
const parentIds = await getParentIds(beforeCategory);
|
|
43
|
+
const batch = ctx.db.batch();
|
|
44
|
+
categoriesRepository.updateMetricsInBatch(batch, beforeCategory, parentIds, beforeIsAuction ? 0 : -1, beforeIsAuction ? -1 : 0, productId);
|
|
45
|
+
await batch.commit();
|
|
46
|
+
if (beforeStoreId)
|
|
47
|
+
await storeRepository.incrementTotalProducts(beforeStoreId, -1);
|
|
48
|
+
ctx.logger.info("Decremented counters on unpublish", { productId, category: beforeCategory, storeId: beforeStoreId });
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (wasPublished && isPublished && beforeCategory && afterCategory && beforeCategory !== afterCategory) {
|
|
52
|
+
const [beforeParents, afterParents] = await Promise.all([
|
|
53
|
+
getParentIds(beforeCategory),
|
|
54
|
+
getParentIds(afterCategory),
|
|
55
|
+
]);
|
|
56
|
+
const batch = ctx.db.batch();
|
|
57
|
+
categoriesRepository.updateMetricsInBatch(batch, beforeCategory, beforeParents, beforeIsAuction ? 0 : -1, beforeIsAuction ? -1 : 0, productId);
|
|
58
|
+
categoriesRepository.updateMetricsInBatch(batch, afterCategory, afterParents, isAuction ? 0 : 1, isAuction ? 1 : 0, productId);
|
|
59
|
+
await batch.commit();
|
|
60
|
+
ctx.logger.info("Moved product between categories", { productId, from: beforeCategory, to: afterCategory });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
19
63
|
export async function handleProductWrite(input, ctx) {
|
|
20
64
|
const { productId, before, after } = input;
|
|
21
65
|
const beforeStatus = before?.status ?? null;
|
|
@@ -30,64 +74,10 @@ export async function handleProductWrite(input, ctx) {
|
|
|
30
74
|
const isPublished = afterStatus === ProductStatusValues.PUBLISHED;
|
|
31
75
|
const isDelete = !after;
|
|
32
76
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
await batch.commit();
|
|
38
|
-
if (beforeStoreId)
|
|
39
|
-
await storeRepository.incrementTotalProducts(beforeStoreId, -1);
|
|
40
|
-
ctx.logger.info("Decremented counters on hard-delete", {
|
|
41
|
-
productId,
|
|
42
|
-
category: beforeCategory,
|
|
43
|
-
storeId: beforeStoreId,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
else if (!wasPublished && isPublished && afterCategory) {
|
|
47
|
-
const parentIds = await getParentIds(afterCategory);
|
|
48
|
-
const batch = ctx.db.batch();
|
|
49
|
-
categoriesRepository.updateMetricsInBatch(batch, afterCategory, parentIds, isAuction ? 0 : 1, isAuction ? 1 : 0, productId);
|
|
50
|
-
await batch.commit();
|
|
51
|
-
if (afterStoreId)
|
|
52
|
-
await storeRepository.incrementTotalProducts(afterStoreId, 1);
|
|
53
|
-
ctx.logger.info("Incremented counters on publish", {
|
|
54
|
-
productId,
|
|
55
|
-
category: afterCategory,
|
|
56
|
-
storeId: afterStoreId,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
else if (wasPublished && !isPublished && beforeCategory) {
|
|
60
|
-
const parentIds = await getParentIds(beforeCategory);
|
|
61
|
-
const batch = ctx.db.batch();
|
|
62
|
-
categoriesRepository.updateMetricsInBatch(batch, beforeCategory, parentIds, beforeIsAuction ? 0 : -1, beforeIsAuction ? -1 : 0, productId);
|
|
63
|
-
await batch.commit();
|
|
64
|
-
if (beforeStoreId)
|
|
65
|
-
await storeRepository.incrementTotalProducts(beforeStoreId, -1);
|
|
66
|
-
ctx.logger.info("Decremented counters on unpublish", {
|
|
67
|
-
productId,
|
|
68
|
-
category: beforeCategory,
|
|
69
|
-
storeId: beforeStoreId,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
else if (wasPublished &&
|
|
73
|
-
isPublished &&
|
|
74
|
-
beforeCategory &&
|
|
75
|
-
afterCategory &&
|
|
76
|
-
beforeCategory !== afterCategory) {
|
|
77
|
-
const [beforeParents, afterParents] = await Promise.all([
|
|
78
|
-
getParentIds(beforeCategory),
|
|
79
|
-
getParentIds(afterCategory),
|
|
80
|
-
]);
|
|
81
|
-
const batch = ctx.db.batch();
|
|
82
|
-
categoriesRepository.updateMetricsInBatch(batch, beforeCategory, beforeParents, beforeIsAuction ? 0 : -1, beforeIsAuction ? -1 : 0, productId);
|
|
83
|
-
categoriesRepository.updateMetricsInBatch(batch, afterCategory, afterParents, isAuction ? 0 : 1, isAuction ? 1 : 0, productId);
|
|
84
|
-
await batch.commit();
|
|
85
|
-
ctx.logger.info("Moved product between categories", {
|
|
86
|
-
productId,
|
|
87
|
-
from: beforeCategory,
|
|
88
|
-
to: afterCategory,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
77
|
+
await dispatchProductWriteEvent({
|
|
78
|
+
productId, beforeCategory, afterCategory, beforeStoreId, afterStoreId,
|
|
79
|
+
isAuction, beforeIsAuction, wasPublished, isPublished, isDelete, ctx,
|
|
80
|
+
});
|
|
91
81
|
}
|
|
92
82
|
catch (err) {
|
|
93
83
|
ctx.logger.error("Counter update failed (non-fatal)", err, { productId });
|