@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.
- package/dist/.build-stamp.json +3 -3
- package/dist/_internal/server/features/auth/capabilities.js +7 -5
- package/dist/_internal/server/features/checkout/actions.d.ts +22 -6
- package/dist/_internal/server/features/checkout/actions.js +96 -51
- package/dist/_internal/server/features/checkout/index.d.ts +1 -1
- package/dist/_internal/server/features/checkout/index.js +1 -1
- package/dist/_internal/server/features/checkout/supplier-identity.js +28 -6
- package/dist/_internal/server/features/orders/adapters.js +1 -3
- package/dist/_internal/server/features/products/listing-tab-counts.js +81 -25
- package/dist/_internal/server/features/search/index-build/sources.js +43 -2
- package/dist/_internal/server/features/site-settings/adapters.js +1 -1
- package/dist/_internal/server/features/stores/adapters.d.ts +1 -1
- package/dist/_internal/server/features/stores/adapters.js +0 -1
- package/dist/_internal/server/jobs/core/analyticsAlertEvaluate.js +2 -5
- package/dist/_internal/server/jobs/core/jobRunners.js +0 -10
- package/dist/_internal/server/jobs/core/onOrderCreate.js +10 -104
- package/dist/_internal/server/jobs/core/onOrderStatusChange.d.ts +0 -2
- package/dist/_internal/server/jobs/core/onOrderStatusChange.js +0 -1
- package/dist/_internal/server/jobs/core/onScamReportCreate.js +0 -1
- package/dist/_internal/server/jobs/core/onScamReportRejected.js +0 -1
- package/dist/_internal/server/jobs/core/onScamReportVerified.js +0 -1
- package/dist/_internal/server/jobs/core/paymentWindowTimeout.js +0 -1
- package/dist/_internal/server/jobs/core/pendingOrderTimeout.js +0 -1
- package/dist/_internal/server/notifications/channel-health.d.ts +7 -3
- package/dist/_internal/server/notifications/channel-health.js +2 -2
- package/dist/_internal/server/notifications/send-guard.d.ts +1 -1
- package/dist/_internal/server/notifications/send-guard.js +2 -4
- package/dist/_internal/shared/actions/action-registry.d.ts +1 -1
- package/dist/_internal/shared/actions/action-registry.js +128 -28
- package/dist/_internal/shared/checkout/order-math.d.ts +1 -1
- package/dist/_internal/shared/checkout/order-math.js +1 -1
- package/dist/_internal/shared/features/categories/bundle-copy.d.ts +1 -1
- package/dist/_internal/shared/features/checkout/config.d.ts +0 -2
- package/dist/_internal/shared/features/checkout/config.js +0 -2
- package/dist/_internal/shared/features/messaging/config.d.ts +7 -5
- package/dist/_internal/shared/features/messaging/config.js +1 -4
- package/dist/_internal/shared/features/site-settings/fees.d.ts +0 -2
- package/dist/_internal/shared/features/site-settings/fees.js +0 -2
- package/dist/_internal/shared/features/site-settings/supplier-of-record.d.ts +56 -0
- package/dist/_internal/shared/features/site-settings/supplier-of-record.js +57 -0
- package/dist/_internal/shared/fees/calculator.d.ts +0 -8
- package/dist/_internal/shared/fees/calculator.js +0 -7
- package/dist/_internal/shared/listing-types/tiers.d.ts +94 -0
- package/dist/_internal/shared/listing-types/tiers.js +150 -0
- package/dist/cli/index.js +0 -2
- package/dist/client.d.ts +25 -4
- package/dist/client.js +36 -5
- package/dist/constants/api-endpoints.d.ts +21 -15
- package/dist/constants/api-endpoints.js +7 -8
- package/dist/constants/field-names.d.ts +1 -0
- package/dist/constants/field-names.js +1 -0
- package/dist/constants/notification-types.d.ts +1 -1
- package/dist/constants/notification-types.js +1 -1
- package/dist/core/integration-keys.d.ts +5 -5
- package/dist/core/integration-keys.js +21 -10
- package/dist/features/about/components/FeesView.js +0 -6
- package/dist/features/about/components/GuidesHubView.js +15 -2
- package/dist/features/account/components/NotificationPreferencesPanel.js +3 -4
- package/dist/features/account/components/UserOrdersView.js +26 -7
- package/dist/features/account/types/index.d.ts +0 -2
- package/dist/features/addresses/utils/postal-autofill.d.ts +39 -0
- package/dist/features/addresses/utils/postal-autofill.js +54 -0
- package/dist/features/admin/actions/notification-actions.d.ts +2 -8
- package/dist/features/admin/actions/notification-actions.js +9 -104
- package/dist/features/admin/components/AdminGuideHubView.js +1 -8
- package/dist/features/admin/components/AdminOrderEditorView.d.ts +1 -1
- package/dist/features/admin/components/AdminOrdersView.js +0 -2
- package/dist/features/admin/components/AdminSectionsView.js +3 -2
- package/dist/features/admin/components/AdminSiteSettingsView.js +22 -68
- package/dist/features/admin/components/AdminStoreEditorView.js +72 -34
- package/dist/features/admin/components/OwnerQuickActions.d.ts +29 -0
- package/dist/features/admin/components/OwnerQuickActions.js +142 -0
- package/dist/features/admin/components/sections/adminSectionsTypes.js +13 -4
- package/dist/features/admin/components/sections/icon-options.d.ts +21 -0
- package/dist/features/admin/components/sections/icon-options.js +23 -0
- package/dist/features/admin/components/sections/sectionTemplates.js +4 -1
- package/dist/features/admin/constants/site-settings-tabs.d.ts +7 -12
- package/dist/features/admin/constants/site-settings-tabs.js +6 -12
- package/dist/features/admin/repository/site-settings.repository.js +1 -1
- package/dist/features/admin/schemas/admin-editor-forms.d.ts +1 -1
- package/dist/features/admin/schemas/admin-editor-forms.js +4 -1
- package/dist/features/admin/schemas/admin-user-form.d.ts +0 -61
- package/dist/features/admin/schemas/admin-user-form.js +3 -44
- package/dist/features/admin/schemas/firestore.d.ts +28 -54
- package/dist/features/admin/schemas/firestore.js +40 -18
- package/dist/features/auctions/components/AuctionDetailPageView.js +4 -3
- package/dist/features/auctions/components/MarketplaceAuctionCard.d.ts +11 -1
- package/dist/features/auctions/components/MarketplaceAuctionCard.js +9 -2
- package/dist/features/auth/checkout-value-otp.d.ts +1 -1
- package/dist/features/auth/checkout-value-otp.js +1 -1
- package/dist/features/auth/permissions/constants.d.ts +29 -2
- package/dist/features/auth/permissions/constants.js +67 -1
- package/dist/features/blog/components/BlogFeaturedCard.d.ts +11 -1
- package/dist/features/blog/components/BlogFeaturedCard.js +9 -2
- package/dist/features/cart/components/CartDrawer.js +3 -2
- package/dist/features/cart/components/CartGroupLineRow.js +2 -1
- package/dist/features/cart/components/CartPriceBreakdown.d.ts +0 -2
- package/dist/features/cart/components/CartPriceBreakdown.js +1 -1
- package/dist/features/cart/components/StoreAddonsPicker.d.ts +2 -5
- package/dist/features/cart/components/StoreAddonsPicker.js +4 -5
- package/dist/features/cart/hooks/useAddToCart.js +10 -5
- package/dist/features/cart/repository/cart.repository.js +1 -2
- package/dist/features/cart/schemas/firestore.d.ts +1 -2
- package/dist/features/cart/utils/pending-ops.d.ts +11 -1
- package/dist/features/cart/utils/pending-ops.js +14 -2
- package/dist/features/categories/components/BrandDetailPageView.js +2 -1
- package/dist/features/categories/components/BundleDetailView.js +2 -1
- package/dist/features/categories/components/CategoryDetailPageView.js +2 -1
- package/dist/features/categories/components/CategoryGrid.d.ts +11 -1
- package/dist/features/categories/components/CategoryGrid.js +9 -2
- package/dist/features/checkout/actions/checkout-value-otp-actions.d.ts +10 -5
- package/dist/features/checkout/actions/checkout-value-otp-actions.js +2 -88
- package/dist/features/classified/components/ClassifiedDetailPageView.js +2 -1
- package/dist/features/digital-codes/components/DigitalCodeDetailPageView.js +2 -1
- package/dist/features/events/components/EventCard.d.ts +11 -1
- package/dist/features/events/components/EventCard.js +9 -2
- package/dist/features/grouped/components/GroupedListingDetailView.js +3 -1
- package/dist/features/homepage/components/CTABannerSection.d.ts +3 -1
- package/dist/features/homepage/components/CTABannerSection.js +6 -3
- package/dist/features/homepage/components/HeroCarousel.js +8 -6
- package/dist/features/homepage/components/MarketplaceHomepageView.js +33 -7
- package/dist/features/homepage/components/SectionCarousel.js +13 -5
- package/dist/features/homepage/components/SecurityHighlightsSection.d.ts +8 -3
- package/dist/features/homepage/components/SecurityHighlightsSection.js +2 -2
- package/dist/features/homepage/components/StatsCounterSection.d.ts +9 -4
- package/dist/features/homepage/components/StatsCounterSection.js +2 -2
- package/dist/features/homepage/components/TestimonialsCarousel.js +1 -1
- package/dist/features/homepage/components/TrustFeaturesSection.d.ts +18 -4
- package/dist/features/homepage/components/TrustFeaturesSection.js +5 -5
- package/dist/features/homepage/components/WelcomeSection.d.ts +13 -2
- package/dist/features/homepage/components/WelcomeSection.js +3 -3
- package/dist/features/homepage/components/WhatsAppCommunitySection.d.ts +28 -0
- package/dist/features/homepage/components/WhatsAppCommunitySection.js +42 -6
- package/dist/features/homepage/components/WhatsAppGlyph.d.ts +20 -0
- package/dist/features/homepage/components/WhatsAppGlyph.js +20 -0
- package/dist/features/homepage/constants/hero-carousel-styles.d.ts +8 -6
- package/dist/features/homepage/constants/hero-carousel-styles.js +8 -6
- package/dist/features/homepage/constants/section-copy.d.ts +12 -10
- package/dist/features/homepage/constants/section-copy.js +28 -6
- package/dist/features/homepage/constants/stat-icons.d.ts +12 -0
- package/dist/features/homepage/constants/stat-icons.js +17 -0
- package/dist/features/homepage/constants/trust-icon-aliases.d.ts +8 -0
- package/dist/features/homepage/constants/trust-icon-aliases.js +75 -0
- package/dist/features/homepage/lib/section-defaults.d.ts +16 -1
- package/dist/features/homepage/lib/section-defaults.js +24 -4
- package/dist/features/homepage/lib/section-renderer.js +48 -8
- package/dist/features/homepage/schemas/firestore.d.ts +18 -1
- package/dist/features/layout/AppLayoutShell.js +2 -1
- package/dist/features/layout/BottomActions.d.ts +1 -0
- package/dist/features/layout/BottomActions.js +330 -0
- package/dist/features/layout/BottomChrome.d.ts +45 -0
- package/dist/features/layout/BottomChrome.js +5 -17
- package/dist/features/layout/SideActionDock.js +36 -13
- package/dist/features/layout/index.d.ts +2 -7
- package/dist/features/layout/index.js +7 -7
- package/dist/features/layout/useIsDesktop.d.ts +36 -0
- package/dist/features/layout/useIsDesktop.js +48 -0
- package/dist/features/live/components/LiveItemDetailPageView.js +2 -1
- package/dist/features/orders/actions/refund-actions.js +0 -1
- package/dist/features/orders/components/OrderAddonBadges.d.ts +1 -3
- package/dist/features/orders/components/OrderAddonBadges.js +3 -4
- package/dist/features/orders/components/OrderPaymentSummary.js +15 -2
- package/dist/features/orders/components/YourPurchaseStrip.d.ts +24 -0
- package/dist/features/orders/components/YourPurchaseStrip.js +77 -0
- package/dist/features/orders/components/index.d.ts +2 -1
- package/dist/features/orders/components/index.js +1 -1
- package/dist/features/orders/repository/orders.repository.d.ts +0 -8
- package/dist/features/orders/repository/orders.repository.js +0 -2
- package/dist/features/orders/schemas/firestore.d.ts +17 -9
- package/dist/features/orders/types/index.d.ts +2 -5
- package/dist/features/orders/utils/order-announcement-message.d.ts +18 -0
- package/dist/features/orders/utils/order-announcement-message.js +16 -0
- package/dist/features/orders/utils/payment-proof-message.d.ts +20 -0
- package/dist/features/orders/utils/payment-proof-message.js +17 -0
- package/dist/features/parts/components/PartDetailPageView.js +96 -1
- package/dist/features/parts/schemas/firestore.d.ts +247 -0
- package/dist/features/parts/schemas/firestore.js +6 -6
- package/dist/features/pre-orders/components/MarketplacePreorderCard.d.ts +11 -1
- package/dist/features/pre-orders/components/MarketplacePreorderCard.js +10 -3
- package/dist/features/pre-orders/components/PreOrderDetailPageView.js +4 -3
- package/dist/features/products/api/[id]/route.js +8 -1
- package/dist/features/products/api/route.js +16 -4
- package/dist/features/products/components/AvailabilityScopeHint.js +1 -1
- package/dist/features/products/components/InteractiveProductCard.d.ts +7 -1
- package/dist/features/products/components/InteractiveProductCard.js +16 -4
- package/dist/features/products/components/MarketplaceBundleCard.d.ts +11 -1
- package/dist/features/products/components/MarketplaceBundleCard.js +9 -2
- package/dist/features/products/components/MarketplacePrizeDrawCard.d.ts +11 -1
- package/dist/features/products/components/MarketplacePrizeDrawCard.js +9 -2
- package/dist/features/products/components/PrizeDrawDetailPageView.js +2 -1
- package/dist/features/products/components/ProductDetailPageView.js +27 -2
- package/dist/features/products/components/ProductGrid.d.ts +14 -1
- package/dist/features/products/components/ProductGrid.js +22 -5
- package/dist/features/products/components/ProductsIndexListing.js +2 -2
- package/dist/features/reviews/api/[id]/route.js +83 -23
- package/dist/features/reviews/components/PurchaseReviewAffordance.d.ts +6 -0
- package/dist/features/reviews/components/PurchaseReviewAffordance.js +42 -0
- package/dist/features/reviews/components/ReviewFormDrawer.d.ts +34 -0
- package/dist/features/reviews/components/ReviewFormDrawer.js +127 -0
- package/dist/features/reviews/components/index.d.ts +4 -0
- package/dist/features/reviews/components/index.js +2 -0
- package/dist/features/scams/schemas/index.d.ts +10 -10
- package/dist/features/search/action-index/settings-entries.js +0 -9
- package/dist/features/seller/actions/seller-actions.d.ts +1 -1
- package/dist/features/seller/actions/seller-actions.js +49 -3
- package/dist/features/seller/components/SellerPayoutSettingsView.js +30 -2
- package/dist/features/seller/components/SellerProductShell.d.ts +17 -1
- package/dist/features/seller/hooks/useStoreListingEntitlements.d.ts +8 -0
- package/dist/features/seller/hooks/useStoreListingEntitlements.js +70 -0
- package/dist/features/store-extensions/repository/store-extensions.repositories.d.ts +1 -6
- package/dist/features/store-extensions/repository/store-extensions.repositories.js +1 -10
- package/dist/features/store-extensions/schemas/firestore.d.ts +1 -17
- package/dist/features/store-extensions/schemas/firestore.js +0 -10
- package/dist/features/stores/components/InteractiveStoreCard.d.ts +11 -1
- package/dist/features/stores/components/InteractiveStoreCard.js +9 -2
- package/dist/features/stores/components/StoreCapabilitiesGuideView.js +0 -1
- package/dist/features/stores/components/StoreGuideHubView.js +2 -8
- package/dist/features/stores/components/StoreSettingsGuideView.js +2 -6
- package/dist/features/stores/components/index.d.ts +0 -2
- package/dist/features/stores/components/index.js +0 -1
- package/dist/features/stores/repository/store.repository.d.ts +1 -26
- package/dist/features/stores/repository/store.repository.js +5 -60
- package/dist/features/stores/schemas/firestore.d.ts +6 -25
- package/dist/features/stores/schemas/firestore.js +6 -3
- package/dist/features/stores/schemas/index.d.ts +1 -87
- package/dist/features/stores/schemas/index.js +10 -15
- package/dist/features/tester/seed-data/authored/admin__site-system.js +0 -48
- package/dist/features/tester/seed-data/authored/buying__buying-checkout.js +0 -40
- package/dist/features/tester/seed-data/authored/selling__quick-add-minimum-details.js +0 -16
- package/dist/features/tester/seed-data/authored/selling__seller-guide.js +1 -1
- package/dist/features/tester/seed-data/authored/selling__seller-marketing-extras.js +0 -79
- package/dist/features/tester/seed-data/authored/selling__seller-orders.js +1 -1
- package/dist/features/tester/seed-data/tester-checklist-seed-data.js +415 -69
- package/dist/index.d.ts +20 -32
- package/dist/index.js +34 -43
- package/dist/next/routing/route-map.d.ts +2 -8
- package/dist/next/routing/route-map.js +21 -4
- package/dist/providers/db-firebase/base.repository.d.ts +1 -1
- package/dist/providers/db-firebase/base.repository.js +1 -1
- package/dist/providers/payment-razorpay/index.d.ts +125 -0
- package/dist/providers/payment-razorpay/index.js +232 -0
- package/dist/providers/payment-razorpay/signature.d.ts +53 -0
- package/dist/providers/payment-razorpay/signature.js +71 -0
- package/dist/providers/shipping-shiprocket/index.d.ts +98 -0
- package/dist/providers/shipping-shiprocket/index.js +356 -0
- package/dist/providers.d.ts +3 -0
- package/dist/providers.js +3 -0
- package/dist/react/hooks/useCanSeePrices.d.ts +0 -27
- package/dist/react/hooks/useCanSeePrices.js +25 -0
- package/dist/repositories/index.d.ts +1 -1
- package/dist/repositories/index.js +1 -1
- package/dist/schemas/registry.d.ts +10 -115
- package/dist/schemas/registry.js +1 -2
- package/dist/security/pii-encrypt.js +1 -1
- package/dist/seed/_helpers/category-forest.js +27 -0
- package/dist/seed/_helpers/category-parts-glossary-map.js +1816 -88
- package/dist/seed/_helpers/category-parts.d.ts +1 -1
- package/dist/seed/_helpers/category-parts.js +13399 -3019
- package/dist/seed/carousel-slides-seed-data.js +47 -10
- package/dist/seed/categories-seed-data.js +48 -6
- package/dist/seed/faq-seed-data.js +2 -2
- package/dist/seed/homepage-sections-seed-data.js +286 -54
- package/dist/seed/index.d.ts +1 -1
- package/dist/seed/index.js +1 -1
- package/dist/seed/manifest.d.ts +1 -1
- package/dist/seed/manifest.js +1 -2
- package/dist/seed/model-composition-seed-data.js +6 -8
- package/dist/seed/part-glossary/chunk0.d.ts +9 -0
- package/dist/seed/part-glossary/chunk0.js +35448 -0
- package/dist/seed/part-glossary/chunk1.d.ts +9 -0
- package/dist/seed/part-glossary/chunk1.js +40494 -0
- package/dist/seed/part-glossary/chunk2.d.ts +9 -0
- package/dist/seed/part-glossary/chunk2.js +51242 -0
- package/dist/seed/part-glossary/chunk3.d.ts +9 -0
- package/dist/seed/part-glossary/chunk3.js +53337 -0
- package/dist/seed/part-glossary/chunk4.d.ts +9 -0
- package/dist/seed/part-glossary/chunk4.js +51454 -0
- package/dist/seed/part-glossary-seed-data.d.ts +1 -1
- package/dist/seed/part-glossary-seed-data.js +23 -47483
- package/dist/seed/products-catalogue-seed-data.d.ts +5 -5
- package/dist/seed/products-catalogue-seed-data.js +63936 -13803
- package/dist/seed/site-settings-seed-data.js +34 -35
- package/dist/seed/store-extensions-seed-data.d.ts +1 -2
- package/dist/seed/store-extensions-seed-data.js +1 -23
- package/dist/seed/stores-seed-data.js +0 -1
- package/dist/server-entry.d.ts +1 -1
- package/dist/server-entry.js +1 -1
- package/dist/server.d.ts +8 -10
- package/dist/server.js +16 -22
- package/dist/styles.css +392 -43
- package/dist/tailwind-utilities.css +1 -1
- package/dist/tokens/themes/default-dark.js +1 -1
- package/dist/tokens/themes/default-light.js +2 -1
- package/dist/tokens/tokens.css +6 -2
- package/dist/ui/components/Button.d.ts +11 -0
- package/dist/ui/components/Button.js +11 -0
- package/dist/ui/components/Button.style.css +29 -0
- package/dist/ui/components/CarouselNav.d.ts +57 -0
- package/dist/ui/components/CarouselNav.js +25 -0
- package/dist/ui/components/CarouselNav.style.css +265 -0
- package/dist/ui/components/GatedPrice.js +30 -3
- package/dist/ui/components/GatedPrice.style.css +43 -40
- package/dist/ui/components/HorizontalScroller.d.ts +12 -1
- package/dist/ui/components/HorizontalScroller.js +43 -3
- package/dist/ui/components/ImageMosaic.d.ts +8 -1
- package/dist/ui/components/ImageMosaic.js +3 -2
- package/dist/ui/components/ImageMosaic.style.css +22 -0
- package/dist/ui/components/Layout.style.css +6 -0
- package/dist/ui/components/Semantic.d.ts +3 -2
- package/dist/ui/components/Semantic.js +1 -0
- package/dist/ui/components/Typography.d.ts +2 -0
- package/dist/ui/components/Typography.js +2 -0
- package/dist/ui/components/Typography.style.css +19 -0
- package/dist/ui/components/index.style.css +1 -0
- package/dist/ui/index.d.ts +3 -1
- package/dist/ui/index.js +4 -0
- package/package.json +3 -2
- package/dist/_internal/server/jobs/core/whatsappCatalogImport.d.ts +0 -27
- package/dist/_internal/server/jobs/core/whatsappCatalogImport.js +0 -172
- package/dist/_internal/server/jobs/core/whatsappNotify.d.ts +0 -35
- package/dist/_internal/server/jobs/core/whatsappNotify.js +0 -140
- package/dist/features/admin/components/AdminWhatsAppGuideView.d.ts +0 -2
- package/dist/features/admin/components/AdminWhatsAppGuideView.js +0 -35
- package/dist/features/orders/components/MarketplaceOrderCard.d.ts +0 -36
- package/dist/features/orders/components/MarketplaceOrderCard.js +0 -57
- package/dist/features/stores/components/StoreWhatsAppGuideView.d.ts +0 -3
- package/dist/features/stores/components/StoreWhatsAppGuideView.js +0 -12
- package/dist/features/whatsapp-bot/api/send-status/route.d.ts +0 -12
- package/dist/features/whatsapp-bot/api/send-status/route.js +0 -38
- package/dist/features/whatsapp-bot/api/webhook/route.d.ts +0 -12
- package/dist/features/whatsapp-bot/api/webhook/route.js +0 -43
- package/dist/features/whatsapp-bot/components/SellerWhatsAppSettingsView.d.ts +0 -6
- package/dist/features/whatsapp-bot/components/SellerWhatsAppSettingsView.js +0 -270
- package/dist/features/whatsapp-bot/components/WhatsAppChatButton.d.ts +0 -9
- package/dist/features/whatsapp-bot/components/WhatsAppChatButton.js +0 -7
- package/dist/features/whatsapp-bot/components/index.d.ts +0 -3
- package/dist/features/whatsapp-bot/components/index.js +0 -2
- package/dist/features/whatsapp-bot/helpers/payment-proof-message.d.ts +0 -14
- package/dist/features/whatsapp-bot/helpers/payment-proof-message.js +0 -17
- package/dist/features/whatsapp-bot/helpers/whatsapp.d.ts +0 -52
- package/dist/features/whatsapp-bot/helpers/whatsapp.js +0 -283
- package/dist/features/whatsapp-bot/index.d.ts +0 -3
- package/dist/features/whatsapp-bot/index.js +0 -3
- package/dist/features/whatsapp-bot/manifest.d.ts +0 -2
- package/dist/features/whatsapp-bot/manifest.js +0 -13
- package/dist/features/whatsapp-bot/messages/en.json +0 -7
- package/dist/features/whatsapp-bot/server.d.ts +0 -7
- package/dist/features/whatsapp-bot/server.js +0 -7
- package/dist/features/whatsapp-bot/types/index.d.ts +0 -126
- package/dist/features/whatsapp-bot/types/index.js +0 -1
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import { normalizeError } from "../../../errors/normalize.js";
|
|
2
|
-
import { createHmac, timingSafeEqual } from "crypto";
|
|
3
|
-
import { getDefaultCurrencySymbol, getDefaultLocale, } from "../../../core/baseline-resolver.js";
|
|
4
|
-
const META_GRAPH_BASE = "https://graph.facebook.com/v20.0";
|
|
5
|
-
export function buildCheckoutMessageURL(input) {
|
|
6
|
-
const { waNumber, cart, total, address, isPreorder = false } = input;
|
|
7
|
-
const prefix = isPreorder ? "\uD83D\uDD16 *PRE-ORDER*\n\n" : "";
|
|
8
|
-
const lines = cart.map((i) => `• ${i.name} ×${i.qty} — ${getDefaultCurrencySymbol()}${(i.salePrice * i.qty).toLocaleString(getDefaultLocale())}`);
|
|
9
|
-
const body = [
|
|
10
|
-
`${prefix}Hi Hobson! I'd like to place an order:`,
|
|
11
|
-
"",
|
|
12
|
-
...lines,
|
|
13
|
-
"",
|
|
14
|
-
`*Total: ${getDefaultCurrencySymbol()}${total.toLocaleString(getDefaultLocale())}*`,
|
|
15
|
-
"",
|
|
16
|
-
`Deliver to: ${address.name}, ${address.line1}${address.line2 ? ", " + address.line2 : ""}, ${address.city} - ${address.pincode}`,
|
|
17
|
-
`Phone: ${address.phone}`,
|
|
18
|
-
"",
|
|
19
|
-
"Please share payment details.",
|
|
20
|
-
].join("\n");
|
|
21
|
-
return `https://wa.me/${waNumber}?text=${encodeURIComponent(body)}`;
|
|
22
|
-
}
|
|
23
|
-
export function buildStatusNotificationURL(input) {
|
|
24
|
-
const { userPhone, template, vars } = input;
|
|
25
|
-
const body = template.replace(/\{(\w+)\}/g, (_, key) => vars[key] ?? `{${key}}`);
|
|
26
|
-
return `https://wa.me/${userPhone}?text=${encodeURIComponent(body)}`;
|
|
27
|
-
}
|
|
28
|
-
export function verifyWebhookSignature(input) {
|
|
29
|
-
const { payload, signature, secret } = input;
|
|
30
|
-
const expected = createHmac("sha256", secret).update(payload).digest("hex");
|
|
31
|
-
const expectedBuf = Buffer.from(expected, "hex");
|
|
32
|
-
const sigBuf = Buffer.from(signature, "hex");
|
|
33
|
-
if (expectedBuf.length !== sigBuf.length)
|
|
34
|
-
return false;
|
|
35
|
-
return timingSafeEqual(expectedBuf, sigBuf);
|
|
36
|
-
}
|
|
37
|
-
export function isAdminNumber(incomingNumber, adminBotNumber) {
|
|
38
|
-
const clean = (n) => n.replace(/\D/g, "");
|
|
39
|
-
return clean(incomingNumber).endsWith(clean(adminBotNumber));
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Parse an incoming WhatsApp webhook payload (Twilio form-encoded or Wati.io JSON).
|
|
43
|
-
* Returns null if the payload cannot be parsed or is missing required fields.
|
|
44
|
-
*/
|
|
45
|
-
export function parseIncomingWebhookPayload(rawBody, contentType) {
|
|
46
|
-
try {
|
|
47
|
-
if (contentType.includes("application/x-www-form-urlencoded")) {
|
|
48
|
-
const params = new URLSearchParams(rawBody);
|
|
49
|
-
const from = params.get("From") ?? "";
|
|
50
|
-
const body = params.get("Body") ?? "";
|
|
51
|
-
if (!from || !body)
|
|
52
|
-
return null;
|
|
53
|
-
return {
|
|
54
|
-
from: from.replace(/^whatsapp:/i, "").replace(/\D/g, ""),
|
|
55
|
-
body: body.trim(),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
// JSON format (Wati.io or generic)
|
|
59
|
-
const json = JSON.parse(rawBody);
|
|
60
|
-
const from = typeof json.senderWaId === "string"
|
|
61
|
-
? json.senderWaId
|
|
62
|
-
: typeof json.from === "string"
|
|
63
|
-
? json.from
|
|
64
|
-
: "";
|
|
65
|
-
const body = typeof json.text?.body ===
|
|
66
|
-
"string"
|
|
67
|
-
? json.text.body
|
|
68
|
-
: typeof json.body === "string"
|
|
69
|
-
? json.body
|
|
70
|
-
: "";
|
|
71
|
-
if (!from || !body)
|
|
72
|
-
return null;
|
|
73
|
-
return { from: from.replace(/\D/g, ""), body: body.trim() };
|
|
74
|
-
}
|
|
75
|
-
catch (_err) {
|
|
76
|
-
void normalizeError(_err);
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
const DEFAULT_STATUS_MESSAGES = {
|
|
81
|
-
pending_payment: "🛒 Your order #{id} has been received and is awaiting payment confirmation.",
|
|
82
|
-
payment_confirmed: "✅ Payment confirmed for order #{id}! We're getting it ready.",
|
|
83
|
-
processing: "📦 Your order #{id} is being packed and prepared for dispatch.",
|
|
84
|
-
shipped: "🚚 Your order #{id} is on its way!{tracking}",
|
|
85
|
-
out_for_delivery: "🏃 Your order #{id} is out for delivery today!",
|
|
86
|
-
delivered: "🎉 Order #{id} delivered! Thank you for your order!",
|
|
87
|
-
cancelled: "❌ Your order #{id} has been cancelled. Contact us if you have any questions.",
|
|
88
|
-
refund_initiated: "💸 Refund initiated for order #{id}. It should reflect within 5–7 business days.",
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Build a human-readable status notification message for an order.
|
|
92
|
-
* Pass a custom `statusMessages` map to override the defaults.
|
|
93
|
-
*/
|
|
94
|
-
export function buildStatusMessage(input, statusMessages = DEFAULT_STATUS_MESSAGES) {
|
|
95
|
-
const { orderId, status, trackingNumber, courierName } = input;
|
|
96
|
-
const template = statusMessages[status] ??
|
|
97
|
-
`Your order #${orderId} status updated to: ${status}.`;
|
|
98
|
-
const trackingLine = trackingNumber
|
|
99
|
-
? `\nTracking: ${courierName ? courierName + " — " : ""}${trackingNumber}`
|
|
100
|
-
: "";
|
|
101
|
-
return template.replace("{id}", orderId).replace("{tracking}", trackingLine);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Send a WhatsApp message via Meta WhatsApp Business Cloud API.
|
|
105
|
-
* Distinct from the Twilio-based sendWhatsAppMessage — used for server-initiated
|
|
106
|
-
* platform announcements. Returns true on success, false on any failure.
|
|
107
|
-
*/
|
|
108
|
-
export async function sendWhatsAppBusinessMessage(input) {
|
|
109
|
-
const { toPhone, message, phoneNumberId, accessToken } = input;
|
|
110
|
-
const cleanPhone = toPhone.replace(/\D/g, "");
|
|
111
|
-
if (!cleanPhone || !phoneNumberId || !accessToken)
|
|
112
|
-
return false;
|
|
113
|
-
try {
|
|
114
|
-
const res = await fetch(`${META_GRAPH_BASE}/${phoneNumberId}/messages`, {
|
|
115
|
-
method: "POST",
|
|
116
|
-
headers: {
|
|
117
|
-
"Content-Type": "application/json",
|
|
118
|
-
Authorization: `Bearer ${accessToken}`,
|
|
119
|
-
},
|
|
120
|
-
body: JSON.stringify({
|
|
121
|
-
messaging_product: "whatsapp",
|
|
122
|
-
to: cleanPhone,
|
|
123
|
-
type: "text",
|
|
124
|
-
text: { body: message },
|
|
125
|
-
}),
|
|
126
|
-
});
|
|
127
|
-
return res.ok;
|
|
128
|
-
}
|
|
129
|
-
catch (_err) {
|
|
130
|
-
void normalizeError(_err);
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Send a pre-approved Meta message TEMPLATE via WhatsApp Business Cloud API.
|
|
136
|
-
* Required for business-initiated sends outside the 24h customer-service
|
|
137
|
-
* window (proactive order/status notifications) — Meta rejects free-form
|
|
138
|
-
* `sendWhatsAppBusinessMessage` `type: "text"` sends in that case. Returns
|
|
139
|
-
* true on success, false on any failure (including a missing/unapproved
|
|
140
|
-
* template — Meta returns a 4xx with an error body, not a network failure).
|
|
141
|
-
*/
|
|
142
|
-
export async function sendWhatsAppTemplateMessage(input) {
|
|
143
|
-
const { toPhone, phoneNumberId, accessToken, templateName, languageCode, bodyParams } = input;
|
|
144
|
-
const cleanPhone = toPhone.replace(/\D/g, "");
|
|
145
|
-
if (!cleanPhone || !phoneNumberId || !accessToken || !templateName)
|
|
146
|
-
return false;
|
|
147
|
-
try {
|
|
148
|
-
const res = await fetch(`${META_GRAPH_BASE}/${phoneNumberId}/messages`, {
|
|
149
|
-
method: "POST",
|
|
150
|
-
headers: {
|
|
151
|
-
"Content-Type": "application/json",
|
|
152
|
-
Authorization: `Bearer ${accessToken}`,
|
|
153
|
-
},
|
|
154
|
-
body: JSON.stringify({
|
|
155
|
-
messaging_product: "whatsapp",
|
|
156
|
-
to: cleanPhone,
|
|
157
|
-
type: "template",
|
|
158
|
-
template: {
|
|
159
|
-
name: templateName,
|
|
160
|
-
language: { code: languageCode },
|
|
161
|
-
...(bodyParams?.length
|
|
162
|
-
? {
|
|
163
|
-
components: [
|
|
164
|
-
{
|
|
165
|
-
type: "body",
|
|
166
|
-
parameters: bodyParams.map((text) => ({ type: "text", text })),
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
}
|
|
170
|
-
: {}),
|
|
171
|
-
},
|
|
172
|
-
}),
|
|
173
|
-
});
|
|
174
|
-
return res.ok;
|
|
175
|
-
}
|
|
176
|
-
catch (_err) {
|
|
177
|
-
void normalizeError(_err);
|
|
178
|
-
return false;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Sync a store's products to a Meta Commerce Catalog via items_batch API.
|
|
183
|
-
* Batches at 50 items per call (Meta limit). Returns aggregate results.
|
|
184
|
-
*/
|
|
185
|
-
export async function syncProductsToCatalog(input) {
|
|
186
|
-
const { catalogId, accessToken, products } = input;
|
|
187
|
-
const result = {
|
|
188
|
-
handles: [],
|
|
189
|
-
successCount: 0,
|
|
190
|
-
failureCount: 0,
|
|
191
|
-
errors: [],
|
|
192
|
-
};
|
|
193
|
-
const BATCH_SIZE = 50;
|
|
194
|
-
for (let i = 0; i < products.length; i += BATCH_SIZE) {
|
|
195
|
-
const batch = products.slice(i, i + BATCH_SIZE);
|
|
196
|
-
const requests = batch.map((p) => ({
|
|
197
|
-
method: "UPDATE",
|
|
198
|
-
retailer_id: p.id,
|
|
199
|
-
data: {
|
|
200
|
-
name: p.title,
|
|
201
|
-
description: p.description,
|
|
202
|
-
// Meta expects "<amount> <ISO_CURRENCY>" e.g. "450.00 INR"
|
|
203
|
-
price: `${p.price.toFixed(2)} ${p.currency}`,
|
|
204
|
-
image_url: p.imageUrl,
|
|
205
|
-
availability: p.availability,
|
|
206
|
-
condition: p.condition,
|
|
207
|
-
...(p.link ? { url: p.link } : {}),
|
|
208
|
-
},
|
|
209
|
-
}));
|
|
210
|
-
try {
|
|
211
|
-
const res = await fetch(`${META_GRAPH_BASE}/${catalogId}/items_batch`, {
|
|
212
|
-
method: "POST",
|
|
213
|
-
headers: {
|
|
214
|
-
"Content-Type": "application/json",
|
|
215
|
-
Authorization: `Bearer ${accessToken}`,
|
|
216
|
-
},
|
|
217
|
-
body: JSON.stringify({ requests }),
|
|
218
|
-
});
|
|
219
|
-
const json = (await res.json());
|
|
220
|
-
if (res.ok && json.handles) {
|
|
221
|
-
result.handles.push(...json.handles);
|
|
222
|
-
result.successCount += batch.length;
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
result.failureCount += batch.length;
|
|
226
|
-
result.errors.push(json.error?.message ?? `Batch ${i / BATCH_SIZE + 1} failed`);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
catch (err) {
|
|
230
|
-
void normalizeError(err);
|
|
231
|
-
result.failureCount += batch.length;
|
|
232
|
-
result.errors.push(String(err));
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return result;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Build a plain-text purchase announcement message for WhatsApp.
|
|
239
|
-
* Sent to admin numbers and store owner when a new order is placed.
|
|
240
|
-
*/
|
|
241
|
-
export function buildPurchaseAnnouncementMessage(input) {
|
|
242
|
-
const { buyerName, firstItemName, additionalItemCount, totalAmount, orderId } = input;
|
|
243
|
-
const extra = additionalItemCount > 0 ? ` + ${additionalItemCount} more item${additionalItemCount > 1 ? "s" : ""}` : "";
|
|
244
|
-
const amount = totalAmount.toLocaleString("en-IN");
|
|
245
|
-
return `🛍️ New order! ${buyerName} purchased ${firstItemName}${extra} for ₹${amount}. Order #${orderId}`;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Build a wa.me share link with a pre-filled message.
|
|
249
|
-
* Opens WhatsApp contact picker — user selects group manually.
|
|
250
|
-
* This is the only API-compliant way to target a WhatsApp group.
|
|
251
|
-
*/
|
|
252
|
-
export function buildGroupShareLink(message) {
|
|
253
|
-
return `https://wa.me/?text=${encodeURIComponent(message)}`;
|
|
254
|
-
}
|
|
255
|
-
// buildPaymentProofReviewMessage moved to ./payment-proof-message.ts (pure,
|
|
256
|
-
// no crypto import) so it can be exported client-safe. Re-exported here for
|
|
257
|
-
// backward compatibility with existing server-side importers of this file.
|
|
258
|
-
export { buildPaymentProofReviewMessage } from "./payment-proof-message.js";
|
|
259
|
-
/**
|
|
260
|
-
* Send an outbound WhatsApp message via Twilio REST API.
|
|
261
|
-
* Returns true on success, false on failure.
|
|
262
|
-
*/
|
|
263
|
-
export async function sendWhatsAppMessage(input) {
|
|
264
|
-
const { toPhone, message, accountSid, authToken, fromNumber } = input;
|
|
265
|
-
const cleanPhone = toPhone.replace(/\D/g, "");
|
|
266
|
-
if (!cleanPhone)
|
|
267
|
-
return false;
|
|
268
|
-
const url = `https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Messages.json`;
|
|
269
|
-
const body = new URLSearchParams({
|
|
270
|
-
From: fromNumber,
|
|
271
|
-
To: `whatsapp:+${cleanPhone}`,
|
|
272
|
-
Body: message,
|
|
273
|
-
});
|
|
274
|
-
const res = await fetch(url, {
|
|
275
|
-
method: "POST",
|
|
276
|
-
headers: {
|
|
277
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
278
|
-
Authorization: `Basic ${Buffer.from(`${accountSid}:${authToken}`).toString("base64")}`,
|
|
279
|
-
},
|
|
280
|
-
body: body.toString(),
|
|
281
|
-
});
|
|
282
|
-
return res.ok;
|
|
283
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const manifest = {
|
|
2
|
-
name: "whatsappBot",
|
|
3
|
-
i18nNamespace: "whatsappBot",
|
|
4
|
-
envKeys: [
|
|
5
|
-
"WHATSAPP_BOT_NUMBER",
|
|
6
|
-
"WHATSAPP_WEBHOOK_SECRET",
|
|
7
|
-
],
|
|
8
|
-
routes: [],
|
|
9
|
-
apiRoutes: [
|
|
10
|
-
{ segment: "api/whatsapp/webhook", methods: ["POST"] },
|
|
11
|
-
{ segment: "api/whatsapp/send-status", methods: ["POST"] },
|
|
12
|
-
],
|
|
13
|
-
};
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
export interface CheckoutMessageInput {
|
|
2
|
-
waNumber: string;
|
|
3
|
-
cart: Array<{
|
|
4
|
-
name: string;
|
|
5
|
-
qty: number;
|
|
6
|
-
salePrice: number;
|
|
7
|
-
}>;
|
|
8
|
-
total: number;
|
|
9
|
-
address: {
|
|
10
|
-
name: string;
|
|
11
|
-
phone: string;
|
|
12
|
-
line1: string;
|
|
13
|
-
line2?: string;
|
|
14
|
-
city: string;
|
|
15
|
-
pincode: string;
|
|
16
|
-
};
|
|
17
|
-
isPreorder?: boolean;
|
|
18
|
-
}
|
|
19
|
-
export interface StatusNotificationInput {
|
|
20
|
-
userPhone: string;
|
|
21
|
-
template: string;
|
|
22
|
-
vars: Record<string, string>;
|
|
23
|
-
}
|
|
24
|
-
export interface WebhookVerifyInput {
|
|
25
|
-
payload: string;
|
|
26
|
-
signature: string;
|
|
27
|
-
secret: string;
|
|
28
|
-
}
|
|
29
|
-
export interface IncomingWebhookPayload {
|
|
30
|
-
/** Digits-only phone number, e.g. "919876543210" */
|
|
31
|
-
from: string;
|
|
32
|
-
body: string;
|
|
33
|
-
}
|
|
34
|
-
export interface SendWhatsAppInput {
|
|
35
|
-
/** Digits-only phone number, e.g. "919876543210" */
|
|
36
|
-
toPhone: string;
|
|
37
|
-
message: string;
|
|
38
|
-
accountSid: string;
|
|
39
|
-
authToken: string;
|
|
40
|
-
/** Twilio from number, e.g. "whatsapp:+14155238886" */
|
|
41
|
-
fromNumber: string;
|
|
42
|
-
}
|
|
43
|
-
/** Input for sending a message via Meta WhatsApp Business Cloud API. */
|
|
44
|
-
export interface WaBusinessSendInput {
|
|
45
|
-
/** Digits-only phone number with country code, e.g. "919876543210" */
|
|
46
|
-
toPhone: string;
|
|
47
|
-
message: string;
|
|
48
|
-
/** Meta Phone Number ID (from Meta for Developers > App > WhatsApp > API Setup) */
|
|
49
|
-
phoneNumberId: string;
|
|
50
|
-
/** Meta system user access token */
|
|
51
|
-
accessToken: string;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Input for sending a pre-approved Meta message TEMPLATE. Required for any
|
|
55
|
-
* business-initiated WhatsApp send outside the 24h customer-service window —
|
|
56
|
-
* Meta rejects free-form `type: "text"` sends in that case.
|
|
57
|
-
*/
|
|
58
|
-
export interface WaBusinessTemplateSendInput {
|
|
59
|
-
/** Digits-only phone number with country code, e.g. "919876543210" */
|
|
60
|
-
toPhone: string;
|
|
61
|
-
/** Meta Phone Number ID (from Meta for Developers > App > WhatsApp > API Setup) */
|
|
62
|
-
phoneNumberId: string;
|
|
63
|
-
/** Meta system user access token */
|
|
64
|
-
accessToken: string;
|
|
65
|
-
/** Exact approved template name from Meta WhatsApp Manager (not the display label). */
|
|
66
|
-
templateName: string;
|
|
67
|
-
/** BCP-47 language code the template was approved in, e.g. "en" or "en_US". */
|
|
68
|
-
languageCode: string;
|
|
69
|
-
/** Positional {{1}}, {{2}}… body parameters, in order. */
|
|
70
|
-
bodyParams?: string[];
|
|
71
|
-
}
|
|
72
|
-
/** A product mapped to the Meta Commerce API catalog item format. */
|
|
73
|
-
export interface CatalogSyncProduct {
|
|
74
|
-
/** Firestore product ID — used as Meta `retailer_id` */
|
|
75
|
-
id: string;
|
|
76
|
-
title: string;
|
|
77
|
-
description: string;
|
|
78
|
-
/** Price in decimal rupees */
|
|
79
|
-
price: number;
|
|
80
|
-
currency: string;
|
|
81
|
-
/** URL of the first product image */
|
|
82
|
-
imageUrl: string;
|
|
83
|
-
availability: "in stock" | "out of stock";
|
|
84
|
-
condition: "new" | "used" | "refurbished";
|
|
85
|
-
/** Canonical product page URL, e.g. /products/{slug} */
|
|
86
|
-
link?: string;
|
|
87
|
-
}
|
|
88
|
-
export interface CatalogSyncInput {
|
|
89
|
-
catalogId: string;
|
|
90
|
-
/** Meta access token with catalog management permission */
|
|
91
|
-
accessToken: string;
|
|
92
|
-
products: CatalogSyncProduct[];
|
|
93
|
-
}
|
|
94
|
-
export interface CatalogSyncResult {
|
|
95
|
-
/** Meta batch request handles */
|
|
96
|
-
handles: string[];
|
|
97
|
-
successCount: number;
|
|
98
|
-
failureCount: number;
|
|
99
|
-
errors: string[];
|
|
100
|
-
}
|
|
101
|
-
/** Input for building a purchase announcement message. */
|
|
102
|
-
export interface PurchaseAnnouncementInput {
|
|
103
|
-
buyerName: string;
|
|
104
|
-
firstItemName: string;
|
|
105
|
-
/** 0 if only one item in the order */
|
|
106
|
-
additionalItemCount: number;
|
|
107
|
-
/** Total order amount in decimal rupees */
|
|
108
|
-
totalAmount: number;
|
|
109
|
-
orderId: string;
|
|
110
|
-
}
|
|
111
|
-
/** Tier PP — input for building the payment-proof fast-review WhatsApp message (admin push + buyer/seller share link). */
|
|
112
|
-
export interface PaymentProofReviewMessageInput {
|
|
113
|
-
orderId: string;
|
|
114
|
-
buyerName: string;
|
|
115
|
-
productTitle: string;
|
|
116
|
-
totalAmount: number;
|
|
117
|
-
reviewUrl: string;
|
|
118
|
-
}
|
|
119
|
-
/** Known order status values — extend as needed per project. */
|
|
120
|
-
export type OrderStatusKey = "pending_payment" | "payment_confirmed" | "processing" | "shipped" | "out_for_delivery" | "delivered" | "cancelled" | "refund_initiated" | string;
|
|
121
|
-
export interface StatusMessageInput {
|
|
122
|
-
orderId: string;
|
|
123
|
-
status: OrderStatusKey;
|
|
124
|
-
trackingNumber?: string;
|
|
125
|
-
courierName?: string;
|
|
126
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|