@mohasinac/appkit 2.6.3 → 2.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_internal/server/features/account/data.js +2 -2
- package/dist/_internal/server/features/bundles/data.d.ts +26 -6
- package/dist/_internal/server/features/bundles/data.js +41 -6
- package/dist/_internal/server/features/bundles/index.d.ts +3 -2
- package/dist/_internal/server/features/bundles/index.js +4 -2
- package/dist/_internal/server/features/bundles/metadata.d.ts +20 -0
- package/dist/_internal/server/features/bundles/metadata.js +46 -0
- package/dist/_internal/server/features/bundles/og.d.ts +38 -0
- package/dist/_internal/server/features/bundles/og.js +122 -0
- package/dist/_internal/server/features/checkout/actions.js +192 -133
- package/dist/_internal/server/features/checkout/bundle-expansion.d.ts +57 -0
- package/dist/_internal/server/features/checkout/bundle-expansion.js +70 -0
- package/dist/_internal/server/features/checkout/prize-bundle-gates.d.ts +5 -15
- package/dist/_internal/server/features/checkout/prize-bundle-gates.js +5 -21
- package/dist/_internal/server/features/media/contextGuards.js +15 -1
- package/dist/_internal/server/features/payouts/actions.d.ts +19 -0
- package/dist/_internal/server/features/payouts/actions.js +38 -0
- package/dist/_internal/server/features/products/data.js +1 -2
- package/dist/_internal/server/features/raffle/actions.d.ts +11 -0
- package/dist/_internal/server/features/raffle/actions.js +31 -0
- package/dist/_internal/server/features/refunds/actions.d.ts +31 -0
- package/dist/_internal/server/features/refunds/actions.js +77 -0
- package/dist/_internal/server/jobs/core/adminAnalytics.d.ts +28 -0
- package/dist/_internal/server/jobs/core/adminAnalytics.js +98 -0
- package/dist/_internal/server/jobs/core/assignSpinPrize.d.ts +19 -0
- package/dist/_internal/server/jobs/core/assignSpinPrize.js +81 -0
- package/dist/_internal/server/jobs/core/auctionSettlement.d.ts +2 -0
- package/dist/_internal/server/jobs/core/auctionSettlement.js +70 -0
- package/dist/_internal/server/jobs/core/autoPayoutEligibility.d.ts +2 -0
- package/dist/_internal/server/jobs/core/autoPayoutEligibility.js +109 -0
- package/dist/_internal/server/jobs/core/bundleStockSync.d.ts +10 -0
- package/dist/_internal/server/jobs/core/bundleStockSync.js +71 -0
- package/dist/_internal/server/jobs/core/cartPrune.d.ts +2 -0
- package/dist/_internal/server/jobs/core/cartPrune.js +13 -0
- package/dist/_internal/server/jobs/core/cleanupRtdbEvents.d.ts +2 -0
- package/dist/_internal/server/jobs/core/cleanupRtdbEvents.js +45 -0
- package/dist/_internal/server/jobs/core/countersReconcile.d.ts +2 -0
- package/dist/_internal/server/jobs/core/countersReconcile.js +107 -0
- package/dist/_internal/server/jobs/core/couponExpiry.d.ts +2 -0
- package/dist/_internal/server/jobs/core/couponExpiry.js +13 -0
- package/dist/_internal/server/jobs/core/dailyDataCleanup.d.ts +2 -0
- package/dist/_internal/server/jobs/core/dailyDataCleanup.js +20 -0
- package/dist/_internal/server/jobs/core/index.d.ts +44 -0
- package/dist/_internal/server/jobs/core/index.js +47 -0
- package/dist/_internal/server/jobs/core/listingProcessor.d.ts +30 -0
- package/dist/_internal/server/jobs/core/listingProcessor.js +138 -0
- package/dist/_internal/server/jobs/core/mediaTmpCleanup.d.ts +14 -0
- package/dist/_internal/server/jobs/core/mediaTmpCleanup.js +68 -0
- package/dist/_internal/server/jobs/core/notificationPrune.d.ts +2 -0
- package/dist/_internal/server/jobs/core/notificationPrune.js +13 -0
- package/dist/_internal/server/jobs/core/offerExpiry.d.ts +2 -0
- package/dist/_internal/server/jobs/core/offerExpiry.js +50 -0
- package/dist/_internal/server/jobs/core/onBidPlaced.d.ts +15 -0
- package/dist/_internal/server/jobs/core/onBidPlaced.js +59 -0
- package/dist/_internal/server/jobs/core/onCategoryWrite.d.ts +14 -0
- package/dist/_internal/server/jobs/core/onCategoryWrite.js +134 -0
- package/dist/_internal/server/jobs/core/onOrderCreate.d.ts +18 -0
- package/dist/_internal/server/jobs/core/onOrderCreate.js +78 -0
- package/dist/_internal/server/jobs/core/onOrderStatusChange.d.ts +19 -0
- package/dist/_internal/server/jobs/core/onOrderStatusChange.js +139 -0
- package/dist/_internal/server/jobs/core/onProductStockChange.d.ts +23 -0
- package/dist/_internal/server/jobs/core/onProductStockChange.js +130 -0
- package/dist/_internal/server/jobs/core/onProductWrite.d.ts +12 -0
- package/dist/_internal/server/jobs/core/onProductWrite.js +94 -0
- package/dist/_internal/server/jobs/core/onReviewWrite.d.ts +7 -0
- package/dist/_internal/server/jobs/core/onReviewWrite.js +49 -0
- package/dist/_internal/server/jobs/core/onStoreWrite.d.ts +12 -0
- package/dist/_internal/server/jobs/core/onStoreWrite.js +7 -0
- package/dist/_internal/server/jobs/core/payoutBatch.d.ts +8 -0
- package/dist/_internal/server/jobs/core/payoutBatch.js +102 -0
- package/dist/_internal/server/jobs/core/pendingOrderTimeout.d.ts +2 -0
- package/dist/_internal/server/jobs/core/pendingOrderTimeout.js +27 -0
- package/dist/_internal/server/jobs/core/positionsReconcile.d.ts +7 -0
- package/dist/_internal/server/jobs/core/positionsReconcile.js +87 -0
- package/dist/_internal/server/jobs/core/prizeRevealClose.d.ts +2 -0
- package/dist/_internal/server/jobs/core/prizeRevealClose.js +22 -0
- package/dist/_internal/server/jobs/core/prizeRevealExpiry.d.ts +2 -0
- package/dist/_internal/server/jobs/core/prizeRevealExpiry.js +50 -0
- package/dist/_internal/server/jobs/core/prizeRevealOpen.d.ts +2 -0
- package/dist/_internal/server/jobs/core/prizeRevealOpen.js +56 -0
- package/dist/_internal/server/jobs/core/prizeRevealReminder.d.ts +2 -0
- package/dist/_internal/server/jobs/core/prizeRevealReminder.js +38 -0
- package/dist/_internal/server/jobs/core/productStatsSync.d.ts +8 -0
- package/dist/_internal/server/jobs/core/productStatsSync.js +36 -0
- package/dist/_internal/server/jobs/core/promotions.d.ts +12 -0
- package/dist/_internal/server/jobs/core/promotions.js +43 -0
- package/dist/_internal/server/jobs/core/storeAnalytics.d.ts +30 -0
- package/dist/_internal/server/jobs/core/storeAnalytics.js +109 -0
- package/dist/_internal/server/jobs/core/triggerEventRaffle.d.ts +19 -0
- package/dist/_internal/server/jobs/core/triggerEventRaffle.js +86 -0
- package/dist/_internal/server/jobs/core/weeklyPayoutEligibility.d.ts +6 -0
- package/dist/_internal/server/jobs/core/weeklyPayoutEligibility.js +85 -0
- package/dist/_internal/server/jobs/handlers/adminAnalytics.d.ts +2 -26
- package/dist/_internal/server/jobs/handlers/adminAnalytics.js +2 -98
- package/dist/_internal/server/jobs/handlers/assignSpinPrize.d.ts +1 -22
- package/dist/_internal/server/jobs/handlers/assignSpinPrize.js +2 -86
- package/dist/_internal/server/jobs/handlers/auctionSettlement.js +2 -70
- package/dist/_internal/server/jobs/handlers/autoPayoutEligibility.js +2 -110
- package/dist/_internal/server/jobs/handlers/bundleStockSync.d.ts +0 -16
- package/dist/_internal/server/jobs/handlers/bundleStockSync.js +2 -80
- package/dist/_internal/server/jobs/handlers/cartPrune.js +2 -13
- package/dist/_internal/server/jobs/handlers/cleanupRtdbEvents.js +2 -45
- package/dist/_internal/server/jobs/handlers/countersReconcile.js +2 -109
- package/dist/_internal/server/jobs/handlers/couponExpiry.js +2 -13
- package/dist/_internal/server/jobs/handlers/dailyDataCleanup.js +2 -20
- package/dist/_internal/server/jobs/handlers/listingProcessor.d.ts +3 -28
- package/dist/_internal/server/jobs/handlers/listingProcessor.js +3 -138
- package/dist/_internal/server/jobs/handlers/mediaTmpCleanup.d.ts +0 -12
- package/dist/_internal/server/jobs/handlers/mediaTmpCleanup.js +2 -69
- package/dist/_internal/server/jobs/handlers/notificationPrune.js +2 -13
- package/dist/_internal/server/jobs/handlers/offerExpiry.js +2 -50
- package/dist/_internal/server/jobs/handlers/onBidPlaced.d.ts +1 -10
- package/dist/_internal/server/jobs/handlers/onBidPlaced.js +2 -56
- package/dist/_internal/server/jobs/handlers/onCategoryWrite.d.ts +1 -8
- package/dist/_internal/server/jobs/handlers/onCategoryWrite.js +6 -134
- package/dist/_internal/server/jobs/handlers/onOrderCreate.d.ts +1 -12
- package/dist/_internal/server/jobs/handlers/onOrderCreate.js +2 -76
- package/dist/_internal/server/jobs/handlers/onOrderStatusChange.d.ts +1 -12
- package/dist/_internal/server/jobs/handlers/onOrderStatusChange.js +2 -139
- package/dist/_internal/server/jobs/handlers/onProductStockChange.d.ts +0 -13
- package/dist/_internal/server/jobs/handlers/onProductStockChange.js +7 -134
- package/dist/_internal/server/jobs/handlers/onProductWrite.d.ts +1 -6
- package/dist/_internal/server/jobs/handlers/onProductWrite.js +6 -106
- package/dist/_internal/server/jobs/handlers/onReviewWrite.js +2 -49
- package/dist/_internal/server/jobs/handlers/onStoreWrite.d.ts +1 -8
- package/dist/_internal/server/jobs/handlers/onStoreWrite.js +7 -8
- package/dist/_internal/server/jobs/handlers/payoutBatch.d.ts +0 -9
- package/dist/_internal/server/jobs/handlers/payoutBatch.js +2 -104
- package/dist/_internal/server/jobs/handlers/pendingOrderTimeout.d.ts +0 -6
- package/dist/_internal/server/jobs/handlers/pendingOrderTimeout.js +2 -33
- package/dist/_internal/server/jobs/handlers/positionsReconcile.d.ts +0 -5
- package/dist/_internal/server/jobs/handlers/positionsReconcile.js +2 -87
- package/dist/_internal/server/jobs/handlers/prizeRevealClose.d.ts +0 -7
- package/dist/_internal/server/jobs/handlers/prizeRevealClose.js +2 -29
- package/dist/_internal/server/jobs/handlers/prizeRevealExpiry.d.ts +0 -8
- package/dist/_internal/server/jobs/handlers/prizeRevealExpiry.js +2 -58
- package/dist/_internal/server/jobs/handlers/prizeRevealOpen.d.ts +0 -8
- package/dist/_internal/server/jobs/handlers/prizeRevealOpen.js +2 -65
- package/dist/_internal/server/jobs/handlers/prizeRevealReminder.d.ts +0 -7
- package/dist/_internal/server/jobs/handlers/prizeRevealReminder.js +2 -45
- package/dist/_internal/server/jobs/handlers/productStatsSync.d.ts +0 -6
- package/dist/_internal/server/jobs/handlers/productStatsSync.js +2 -36
- package/dist/_internal/server/jobs/handlers/promotions.d.ts +2 -10
- package/dist/_internal/server/jobs/handlers/promotions.js +2 -43
- package/dist/_internal/server/jobs/handlers/storeAnalytics.d.ts +2 -28
- package/dist/_internal/server/jobs/handlers/storeAnalytics.js +2 -109
- package/dist/_internal/server/jobs/handlers/triggerEventRaffle.d.ts +1 -28
- package/dist/_internal/server/jobs/handlers/triggerEventRaffle.js +2 -94
- package/dist/_internal/server/jobs/handlers/weeklyPayoutEligibility.d.ts +0 -6
- package/dist/_internal/server/jobs/handlers/weeklyPayoutEligibility.js +2 -87
- package/dist/_internal/server/jobs/index.d.ts +1 -0
- package/dist/_internal/server/jobs/index.js +1 -0
- package/dist/_internal/server/jobs/runtime/adapters/firebase.js +21 -0
- package/dist/_internal/shared/actions/action-registry.d.ts +84 -0
- package/dist/_internal/shared/actions/action-registry.js +160 -0
- package/dist/_internal/shared/checkout/rules/_defaults.d.ts +3 -0
- package/dist/_internal/shared/checkout/rules/_defaults.js +22 -0
- package/dist/_internal/shared/checkout/rules/_limits.d.ts +19 -0
- package/dist/_internal/shared/checkout/rules/_limits.js +19 -0
- package/dist/_internal/shared/checkout/rules/_registry.d.ts +44 -0
- package/dist/_internal/shared/checkout/rules/_registry.js +87 -0
- package/dist/_internal/shared/checkout/rules/auction.rule.d.ts +2 -0
- package/dist/_internal/shared/checkout/rules/auction.rule.js +10 -0
- package/dist/_internal/shared/checkout/rules/bundle.rule.d.ts +11 -0
- package/dist/_internal/shared/checkout/rules/bundle.rule.js +6 -0
- package/dist/_internal/shared/checkout/rules/classified.rule.d.ts +9 -0
- package/dist/_internal/shared/checkout/rules/classified.rule.js +9 -0
- package/dist/_internal/shared/checkout/rules/digital-code.rule.d.ts +8 -0
- package/dist/_internal/shared/checkout/rules/digital-code.rule.js +6 -0
- package/dist/_internal/shared/checkout/rules/index.d.ts +12 -0
- package/dist/_internal/shared/checkout/rules/index.js +12 -0
- package/dist/_internal/shared/checkout/rules/live.rule.d.ts +10 -0
- package/dist/_internal/shared/checkout/rules/live.rule.js +6 -0
- package/dist/_internal/shared/checkout/rules/offer.rule.d.ts +2 -0
- package/dist/_internal/shared/checkout/rules/offer.rule.js +9 -0
- package/dist/_internal/shared/checkout/rules/preorder.rule.d.ts +2 -0
- package/dist/_internal/shared/checkout/rules/preorder.rule.js +28 -0
- package/dist/_internal/shared/checkout/rules/prize-draw.rule.d.ts +2 -0
- package/dist/_internal/shared/checkout/rules/prize-draw.rule.js +65 -0
- package/dist/_internal/shared/checkout/rules/standard.rule.d.ts +2 -0
- package/dist/_internal/shared/checkout/rules/standard.rule.js +5 -0
- package/dist/_internal/shared/checkout/rules/types.d.ts +125 -0
- package/dist/_internal/shared/checkout/rules/types.js +13 -0
- package/dist/_internal/shared/features/cart/schema.d.ts +6 -6
- package/dist/_internal/shared/features/categories/bundle-copy.d.ts +123 -0
- package/dist/_internal/shared/features/categories/bundle-copy.js +134 -0
- package/dist/_internal/shared/features/categories/bundle-schemas.d.ts +318 -0
- package/dist/_internal/shared/features/categories/bundle-schemas.js +55 -0
- package/dist/_internal/shared/features/orders/refund-copy.d.ts +36 -0
- package/dist/_internal/shared/features/orders/refund-copy.js +40 -0
- package/dist/_internal/shared/features/orders/schema.d.ts +4 -4
- package/dist/_internal/shared/features/products/schema.d.ts +8 -8
- package/dist/_internal/shared/listing-types/_registry.d.ts +27 -0
- package/dist/_internal/shared/listing-types/_registry.js +8 -0
- package/dist/_internal/shared/listing-types/action-tracker.d.ts +41 -0
- package/dist/_internal/shared/listing-types/action-tracker.js +70 -0
- package/dist/_internal/shared/listing-types/capabilities.js +25 -0
- package/dist/_internal/shared/listing-types/cart-shipping.d.ts +37 -0
- package/dist/_internal/shared/listing-types/cart-shipping.js +46 -0
- package/dist/_internal/shared/listing-types/classified/config.d.ts +7 -0
- package/dist/_internal/shared/listing-types/classified/config.js +8 -0
- package/dist/_internal/shared/listing-types/classified/ctas.d.ts +1 -0
- package/dist/_internal/shared/listing-types/classified/ctas.js +3 -0
- package/dist/_internal/shared/listing-types/classified/og.d.ts +1 -0
- package/dist/_internal/shared/listing-types/classified/og.js +1 -0
- package/dist/_internal/shared/listing-types/classified/schema.d.ts +1 -0
- package/dist/_internal/shared/listing-types/classified/schema.js +1 -0
- package/dist/_internal/shared/listing-types/classified/seed-factory.d.ts +1 -0
- package/dist/_internal/shared/listing-types/classified/seed-factory.js +1 -0
- package/dist/_internal/shared/listing-types/digital-code/config.d.ts +7 -0
- package/dist/_internal/shared/listing-types/digital-code/config.js +8 -0
- package/dist/_internal/shared/listing-types/digital-code/ctas.d.ts +1 -0
- package/dist/_internal/shared/listing-types/digital-code/ctas.js +3 -0
- package/dist/_internal/shared/listing-types/digital-code/og.d.ts +1 -0
- package/dist/_internal/shared/listing-types/digital-code/og.js +1 -0
- package/dist/_internal/shared/listing-types/digital-code/schema.d.ts +1 -0
- package/dist/_internal/shared/listing-types/digital-code/schema.js +1 -0
- package/dist/_internal/shared/listing-types/digital-code/seed-factory.d.ts +1 -0
- package/dist/_internal/shared/listing-types/digital-code/seed-factory.js +1 -0
- package/dist/_internal/shared/listing-types/feature-flags.d.ts +34 -0
- package/dist/_internal/shared/listing-types/feature-flags.js +45 -0
- package/dist/_internal/shared/listing-types/live/config.d.ts +7 -0
- package/dist/_internal/shared/listing-types/live/config.js +8 -0
- package/dist/_internal/shared/listing-types/live/ctas.d.ts +1 -0
- package/dist/_internal/shared/listing-types/live/ctas.js +3 -0
- package/dist/_internal/shared/listing-types/live/og.d.ts +1 -0
- package/dist/_internal/shared/listing-types/live/og.js +1 -0
- package/dist/_internal/shared/listing-types/live/schema.d.ts +1 -0
- package/dist/_internal/shared/listing-types/live/schema.js +1 -0
- package/dist/_internal/shared/listing-types/live/seed-factory.d.ts +1 -0
- package/dist/_internal/shared/listing-types/live/seed-factory.js +1 -0
- package/dist/_internal/shared/media/limits.js +8 -0
- package/dist/client.d.ts +6 -1
- package/dist/client.js +14 -1
- package/dist/configs/next.js +7 -0
- package/dist/constants/api-endpoints.d.ts +6 -0
- package/dist/constants/api-endpoints.js +4 -0
- package/dist/core/hooks/useSyncManager.js +13 -1
- package/dist/core/unit-of-work.d.ts +1 -1
- package/dist/core/unit-of-work.js +2 -2
- package/dist/features/account/actions/address-actions.d.ts +1 -1
- package/dist/features/account/actions/address-actions.js +15 -7
- package/dist/features/account/schemas/firestore.d.ts +8 -43
- package/dist/features/account/schemas/firestore.js +8 -54
- package/dist/features/account/schemas/index.d.ts +6 -6
- package/dist/features/account/server.d.ts +1 -1
- package/dist/features/account/server.js +3 -1
- package/dist/features/addresses/index.d.ts +2 -0
- package/dist/features/addresses/index.js +2 -0
- package/dist/features/addresses/repository/addresses.repository.d.ts +29 -0
- package/dist/features/addresses/repository/addresses.repository.js +157 -0
- package/dist/features/addresses/schemas/firestore.d.ts +53 -0
- package/dist/features/addresses/schemas/firestore.js +68 -0
- package/dist/features/{bundles → addresses}/schemas/index.d.ts +0 -1
- package/dist/features/{bundles → addresses}/schemas/index.js +0 -1
- package/dist/features/addresses/server.d.ts +2 -0
- package/dist/features/addresses/server.js +2 -0
- package/dist/features/admin/components/AdminAllEventEntriesView.js +4 -3
- package/dist/features/admin/components/AdminBidsView.js +4 -3
- package/dist/features/admin/components/AdminBlogView.js +8 -3
- package/dist/features/admin/components/AdminBundleEditorView.d.ts +9 -0
- package/dist/features/admin/components/AdminBundleEditorView.js +209 -0
- package/dist/features/admin/components/AdminBundlesView.d.ts +9 -0
- package/dist/features/admin/components/AdminBundlesView.js +59 -0
- package/dist/features/admin/components/AdminCartsView.js +13 -3
- package/dist/features/admin/components/AdminContactView.js +4 -3
- package/dist/features/admin/components/AdminCouponsView.js +32 -13
- package/dist/features/admin/components/AdminNewsletterView.js +4 -3
- package/dist/features/admin/components/AdminOrdersView.js +15 -7
- package/dist/features/admin/components/AdminPayoutsView.js +4 -3
- package/dist/features/admin/components/AdminProductsView.js +6 -5
- package/dist/features/admin/components/AdminReviewsView.js +5 -4
- package/dist/features/admin/components/AdminStoresView.js +4 -3
- package/dist/features/admin/components/AdminUsersView.js +15 -5
- package/dist/features/admin/components/AdminWishlistsView.js +10 -1
- package/dist/features/admin/components/DataTable.d.ts +5 -1
- package/dist/features/admin/components/DataTable.js +24 -20
- package/dist/features/admin/components/index.d.ts +4 -0
- package/dist/features/admin/components/index.js +3 -0
- package/dist/features/admin/constants/filter-tabs.d.ts +401 -0
- package/dist/features/admin/constants/filter-tabs.js +200 -0
- package/dist/features/admin/hooks/useAdminListingData.d.ts +1 -0
- package/dist/features/admin/hooks/useAdminListingData.js +1 -0
- package/dist/features/admin/schemas/firestore.d.ts +15 -0
- package/dist/features/admin/schemas/firestore.js +18 -0
- package/dist/features/admin/types/product.types.d.ts +2 -2
- package/dist/features/auctions/components/AuctionCard.d.ts +4 -1
- package/dist/features/auctions/components/AuctionCard.js +5 -3
- package/dist/features/auctions/components/AuctionDetailPageView.js +1 -1
- package/dist/features/auctions/components/MarketplaceAuctionCard.d.ts +2 -2
- package/dist/features/auctions/components/PlaceBidFormClient.js +12 -2
- package/dist/features/auctions/schemas/index.d.ts +2 -2
- package/dist/features/auth/index.d.ts +1 -0
- package/dist/features/auth/index.js +1 -0
- package/dist/features/auth/role-predicates.d.ts +16 -0
- package/dist/features/auth/role-predicates.js +15 -0
- package/dist/features/blog/components/BlogFeaturedCard.d.ts +4 -1
- package/dist/features/blog/components/BlogFeaturedCard.js +5 -3
- package/dist/features/cart/actions/cart-actions.d.ts +1 -0
- package/dist/features/cart/actions/cart-actions.js +16 -0
- package/dist/features/cart/components/CartView.d.ts +19 -1
- package/dist/features/cart/components/CartView.js +2 -2
- package/dist/features/cart/components/ShippingPicker.d.ts +13 -0
- package/dist/features/cart/components/ShippingPicker.js +48 -0
- package/dist/features/cart/components/index.d.ts +3 -1
- package/dist/features/cart/components/index.js +1 -0
- package/dist/features/cart/hooks/useCartCount.js +7 -1
- package/dist/features/cart/repository/cart.repository.d.ts +1 -0
- package/dist/features/cart/repository/cart.repository.js +35 -0
- package/dist/features/cart/schemas/firestore.d.ts +27 -2
- package/dist/features/categories/components/BundleAddToCartCta.d.ts +16 -0
- package/dist/features/categories/components/BundleAddToCartCta.js +54 -0
- package/dist/features/categories/components/BundleBuyNowCta.d.ts +8 -0
- package/dist/features/categories/components/BundleBuyNowCta.js +37 -0
- package/dist/features/categories/components/BundleDetailView.d.ts +22 -0
- package/dist/features/categories/components/BundleDetailView.js +31 -0
- package/dist/features/categories/components/BundleDynamicRuleEditor.d.ts +18 -0
- package/dist/features/categories/components/BundleDynamicRuleEditor.js +60 -0
- package/dist/features/categories/components/BundleItemsPicker.d.ts +26 -0
- package/dist/features/categories/components/BundleItemsPicker.js +135 -0
- package/dist/features/categories/components/BundlesListView.d.ts +13 -0
- package/dist/features/categories/components/BundlesListView.js +27 -0
- package/dist/features/categories/components/index.d.ts +12 -0
- package/dist/features/categories/components/index.js +9 -0
- package/dist/features/checkout/actions/checkout-actions.js +10 -3
- package/dist/features/events/components/AdminEventEditorView.js +108 -2
- package/dist/features/events/components/AdminEventsView.js +16 -4
- package/dist/features/events/components/EventCard.d.ts +4 -1
- package/dist/features/events/components/EventCard.js +7 -3
- package/dist/features/events/components/EventRaffleWinnerView.d.ts +21 -0
- package/dist/features/events/components/EventRaffleWinnerView.js +18 -0
- package/dist/features/events/components/SpinWheelView.d.ts +27 -0
- package/dist/features/events/components/SpinWheelView.js +64 -0
- package/dist/features/events/components/index.d.ts +4 -0
- package/dist/features/events/components/index.js +2 -0
- package/dist/features/events/schemas/firestore.d.ts +27 -1
- package/dist/features/events/schemas/firestore.js +7 -0
- package/dist/features/events/types/index.d.ts +27 -1
- package/dist/features/homepage/components/FeaturedBundlesSection.d.ts +16 -0
- package/dist/features/homepage/components/FeaturedBundlesSection.js +24 -0
- package/dist/features/homepage/components/MarketplaceHomepageView.js +4 -1
- package/dist/features/homepage/components/WhatsAppCommunitySection.js +2 -2
- package/dist/features/homepage/lib/section-renderer.d.ts +2 -0
- package/dist/features/homepage/lib/section-renderer.js +5 -5
- package/dist/features/layout/NavbarLayout.d.ts +3 -1
- package/dist/features/layout/NavbarLayout.js +32 -3
- package/dist/features/layout/TitleBarLayout.d.ts +6 -3
- package/dist/features/layout/TitleBarLayout.js +22 -7
- package/dist/features/media/upload/MediaUploadField.d.ts +15 -1
- package/dist/features/media/upload/MediaUploadField.js +22 -1
- package/dist/features/orders/components/MarketplaceOrderCard.js +4 -2
- package/dist/features/orders/components/OrderSiblingPayments.d.ts +8 -0
- package/dist/features/orders/components/OrderSiblingPayments.js +16 -0
- package/dist/features/orders/components/RefundHistoryTable.d.ts +6 -0
- package/dist/features/orders/components/RefundHistoryTable.js +23 -0
- package/dist/features/orders/components/RefundRequestView.d.ts +8 -0
- package/dist/features/orders/components/RefundRequestView.js +42 -0
- package/dist/features/orders/components/index.d.ts +6 -0
- package/dist/features/orders/components/index.js +3 -0
- package/dist/features/orders/index.d.ts +1 -0
- package/dist/features/orders/index.js +2 -0
- package/dist/features/orders/repository/orders.repository.d.ts +20 -1
- package/dist/features/orders/repository/orders.repository.js +30 -1
- package/dist/features/orders/schemas/firestore.d.ts +63 -13
- package/dist/features/orders/schemas/firestore.js +5 -5
- package/dist/features/orders/schemas/index.d.ts +4 -4
- package/dist/features/orders/types/index.d.ts +12 -2
- package/dist/features/orders/utils/bundle-grouping.d.ts +48 -0
- package/dist/features/orders/utils/bundle-grouping.js +54 -0
- package/dist/features/orders/utils/order-splitter.d.ts +9 -10
- package/dist/features/orders/utils/order-splitter.js +24 -30
- package/dist/features/payments/repository/payout.repository.d.ts +17 -1
- package/dist/features/payments/repository/payout.repository.js +47 -0
- package/dist/features/payments/schemas/firestore.d.ts +26 -0
- package/dist/features/pre-orders/components/PreorderCard.d.ts +4 -1
- package/dist/features/pre-orders/components/PreorderCard.js +8 -6
- package/dist/features/products/actions/product-actions.d.ts +1 -1
- package/dist/features/products/actions/product-actions.js +1 -1
- package/dist/features/products/components/CompareOverlay.d.ts +2 -2
- package/dist/features/products/components/CompareOverlay.js +4 -4
- package/dist/features/products/components/InteractiveProductCard.js +7 -12
- package/dist/features/products/components/NonRefundableConsentModal.d.ts +1 -1
- package/dist/features/products/components/NonRefundableConsentModal.js +0 -10
- package/dist/features/products/components/ProductGrid.js +28 -12
- package/dist/features/products/components/ShowGroupSection.js +3 -3
- package/dist/features/products/components/SublistingCarouselSection.js +2 -2
- package/dist/features/products/components/index.d.ts +0 -4
- package/dist/features/products/components/index.js +5 -2
- package/dist/features/products/index.d.ts +1 -1
- package/dist/features/products/index.js +3 -1
- package/dist/features/products/repository/products.repository.js +4 -0
- package/dist/features/products/schemas/catalog-product.d.ts +70 -0
- package/dist/features/products/schemas/catalog-product.js +50 -0
- package/dist/features/products/schemas/firestore.d.ts +110 -2
- package/dist/features/products/schemas/firestore.js +30 -0
- package/dist/features/products/schemas/index.d.ts +8 -8
- package/dist/features/products/types/index.d.ts +1 -1
- package/dist/features/products/utils/listing-type.d.ts +9 -0
- package/dist/features/products/utils/listing-type.js +4 -0
- package/dist/features/promotions/actions/coupon-actions.d.ts +2 -2
- package/dist/features/promotions/actions/coupon-actions.js +1 -1
- package/dist/features/promotions/components/CouponCard.d.ts +28 -10
- package/dist/features/promotions/components/CouponCard.js +116 -14
- package/dist/features/promotions/hooks/useCouponValidate.d.ts +1 -1
- package/dist/features/promotions/repository/coupons.repository.d.ts +1 -1
- package/dist/features/reviews/schemas/index.d.ts +2 -2
- package/dist/features/search/schemas/index.d.ts +2 -2
- package/dist/features/search/types/index.d.ts +2 -2
- package/dist/features/seller/components/SellerAuctionsView.js +4 -5
- package/dist/features/seller/components/SellerBidsView.js +5 -13
- package/dist/features/seller/components/SellerCouponsView.js +31 -67
- package/dist/features/seller/components/SellerOffersView.js +4 -5
- package/dist/features/seller/components/SellerOrdersView.js +4 -5
- package/dist/features/seller/components/SellerPayoutsView.js +4 -5
- package/dist/features/seller/components/SellerProductsView.js +4 -8
- package/dist/features/seller/schemas/index.d.ts +2 -2
- package/dist/features/stores/actions/store-address-actions.d.ts +10 -6
- package/dist/features/stores/actions/store-address-actions.js +8 -7
- package/dist/features/stores/components/InteractiveStoreCard.js +3 -10
- package/dist/features/stores/components/StoreDetailLayoutView.js +20 -5
- package/dist/features/stores/schemas/firestore.d.ts +45 -38
- package/dist/features/stores/schemas/firestore.js +2 -49
- package/dist/features/stores/server.d.ts +0 -1
- package/dist/features/stores/server.js +2 -1
- package/dist/features/wishlist/hooks/useWishlistCount.d.ts +7 -9
- package/dist/features/wishlist/hooks/useWishlistCount.js +67 -86
- package/dist/features/wishlist/types/index.d.ts +1 -1
- package/dist/index.d.ts +50 -9
- package/dist/index.js +57 -11
- package/dist/next/routing/route-map.d.ts +6 -0
- package/dist/next/routing/route-map.js +4 -0
- package/dist/providers/db-firebase/admin.d.ts +6 -2
- package/dist/providers/db-firebase/admin.js +23 -0
- package/dist/repositories/index.d.ts +1 -2
- package/dist/repositories/index.js +5 -2
- package/dist/security/authorization.d.ts +2 -1
- package/dist/security/authorization.js +3 -2
- package/dist/seed/actions/demo-seed-actions.d.ts +1 -1
- package/dist/seed/bids-seed-data.d.ts +2 -2
- package/dist/seed/bids-seed-data.js +77 -2
- package/dist/seed/cart-seed-data.d.ts +10 -10
- package/dist/seed/cart-seed-data.js +15 -15
- package/dist/seed/events-seed-data.js +77 -0
- package/dist/seed/manifest.js +16 -8
- package/dist/seed/orders-seed-data.js +41 -2
- package/dist/seed/payouts-seed-data.js +18 -2
- package/dist/seed/stores-seed-data.js +55 -0
- package/dist/server-entry.d.ts +1 -0
- package/dist/server-entry.js +2 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +8 -0
- package/dist/tailwind-utilities.css +1 -1
- package/dist/ui/components/FilterChipGroup.d.ts +39 -0
- package/dist/ui/components/FilterChipGroup.js +15 -0
- package/dist/ui/components/HorizontalScroller.js +32 -7
- package/dist/ui/components/HorizontalScroller.style.css +6 -0
- package/dist/ui/components/SiteLogo.js +1 -1
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +2 -0
- package/dist/utils/id-generators.d.ts +11 -0
- package/dist/utils/id-generators.js +16 -0
- package/package.json +1 -1
- package/dist/_internal/shared/features/bundles/config.d.ts +0 -6
- package/dist/_internal/shared/features/bundles/config.js +0 -6
- package/dist/_internal/shared/schema-versions.d.ts +0 -76
- package/dist/_internal/shared/schema-versions.js +0 -82
- package/dist/features/account/migrations.d.ts +0 -2
- package/dist/features/account/migrations.js +0 -10
- package/dist/features/admin/migrations.d.ts +0 -2
- package/dist/features/admin/migrations.js +0 -10
- package/dist/features/auctions/migrations.d.ts +0 -2
- package/dist/features/auctions/migrations.js +0 -10
- package/dist/features/auth/migrations.d.ts +0 -2
- package/dist/features/auth/migrations.js +0 -10
- package/dist/features/blog/migrations.d.ts +0 -2
- package/dist/features/blog/migrations.js +0 -10
- package/dist/features/brands/actions/brand-actions.d.ts +0 -2
- package/dist/features/brands/actions/brand-actions.js +0 -5
- package/dist/features/brands/index.d.ts +0 -3
- package/dist/features/brands/index.js +0 -3
- package/dist/features/brands/migrations.d.ts +0 -2
- package/dist/features/brands/migrations.js +0 -10
- package/dist/features/brands/repository/brands.repository.d.ts +0 -13
- package/dist/features/brands/repository/brands.repository.js +0 -60
- package/dist/features/brands/schemas/index.d.ts +0 -33
- package/dist/features/brands/schemas/index.js +0 -15
- package/dist/features/brands/server.d.ts +0 -7
- package/dist/features/brands/server.js +0 -7
- package/dist/features/bundles/components/AdminBundleEditorView.d.ts +0 -8
- package/dist/features/bundles/components/AdminBundleEditorView.js +0 -7
- package/dist/features/bundles/components/BundleDetailPageView.d.ts +0 -9
- package/dist/features/bundles/components/BundleDetailPageView.js +0 -45
- package/dist/features/bundles/components/BundleForm.d.ts +0 -12
- package/dist/features/bundles/components/BundleForm.js +0 -126
- package/dist/features/bundles/components/BundleItemsPicker.d.ts +0 -9
- package/dist/features/bundles/components/BundleItemsPicker.js +0 -77
- package/dist/features/bundles/components/BundlesByCategoryListing.d.ts +0 -6
- package/dist/features/bundles/components/BundlesByCategoryListing.js +0 -50
- package/dist/features/bundles/components/BundlesListingView.d.ts +0 -17
- package/dist/features/bundles/components/BundlesListingView.js +0 -50
- package/dist/features/bundles/components/FeaturedBundlesSection.d.ts +0 -5
- package/dist/features/bundles/components/FeaturedBundlesSection.js +0 -55
- package/dist/features/bundles/components/SellerBundleCreateView.d.ts +0 -8
- package/dist/features/bundles/components/SellerBundleCreateView.js +0 -7
- package/dist/features/bundles/components/SellerBundleEditView.d.ts +0 -9
- package/dist/features/bundles/components/SellerBundleEditView.js +0 -7
- package/dist/features/bundles/components/index.d.ts +0 -18
- package/dist/features/bundles/components/index.js +0 -9
- package/dist/features/bundles/constants/index.d.ts +0 -32
- package/dist/features/bundles/constants/index.js +0 -35
- package/dist/features/bundles/index.d.ts +0 -2
- package/dist/features/bundles/index.js +0 -2
- package/dist/features/bundles/migrations.d.ts +0 -2
- package/dist/features/bundles/migrations.js +0 -10
- package/dist/features/bundles/repository/bundles.repository.d.ts +0 -36
- package/dist/features/bundles/repository/bundles.repository.js +0 -148
- package/dist/features/bundles/repository/index.d.ts +0 -1
- package/dist/features/bundles/repository/index.js +0 -1
- package/dist/features/bundles/schemas/firestore.d.ts +0 -88
- package/dist/features/bundles/schemas/firestore.js +0 -29
- package/dist/features/bundles/schemas/zod.d.ts +0 -377
- package/dist/features/bundles/schemas/zod.js +0 -71
- package/dist/features/cart/migrations.d.ts +0 -2
- package/dist/features/cart/migrations.js +0 -10
- package/dist/features/categories/migrations.d.ts +0 -2
- package/dist/features/categories/migrations.js +0 -10
- package/dist/features/events/migrations.d.ts +0 -2
- package/dist/features/events/migrations.js +0 -10
- package/dist/features/faq/migrations.d.ts +0 -2
- package/dist/features/faq/migrations.js +0 -10
- package/dist/features/grouped/migrations.d.ts +0 -2
- package/dist/features/grouped/migrations.js +0 -10
- package/dist/features/history/migrations.d.ts +0 -2
- package/dist/features/history/migrations.js +0 -10
- package/dist/features/messages/migrations.d.ts +0 -2
- package/dist/features/messages/migrations.js +0 -10
- package/dist/features/orders/migrations.d.ts +0 -2
- package/dist/features/orders/migrations.js +0 -10
- package/dist/features/payments/migrations.d.ts +0 -2
- package/dist/features/payments/migrations.js +0 -10
- package/dist/features/products/migrations.d.ts +0 -2
- package/dist/features/products/migrations.js +0 -10
- package/dist/features/products/repository/sublisting-categories.repository.d.ts +0 -16
- package/dist/features/products/repository/sublisting-categories.repository.js +0 -126
- package/dist/features/products/schemas/sublisting-categories.d.ts +0 -45
- package/dist/features/products/schemas/sublisting-categories.js +0 -16
- package/dist/features/promotions/migrations.d.ts +0 -2
- package/dist/features/promotions/migrations.js +0 -10
- package/dist/features/reviews/migrations.d.ts +0 -2
- package/dist/features/reviews/migrations.js +0 -10
- package/dist/features/scams/migrations.d.ts +0 -2
- package/dist/features/scams/migrations.js +0 -10
- package/dist/features/seller/migrations.d.ts +0 -2
- package/dist/features/seller/migrations.js +0 -10
- package/dist/features/stores/migrations.d.ts +0 -2
- package/dist/features/stores/migrations.js +0 -10
- package/dist/features/sublisting/migrations.d.ts +0 -2
- package/dist/features/sublisting/migrations.js +0 -10
- package/dist/features/sublisting/schemas/firestore.d.ts +0 -32
- package/dist/features/sublisting/schemas/firestore.js +0 -19
- package/dist/features/support/migrations.d.ts +0 -2
- package/dist/features/support/migrations.js +0 -10
- package/dist/features/wishlist/migrations.d.ts +0 -2
- package/dist/features/wishlist/migrations.js +0 -10
- package/dist/seed/_bundle-constants.d.ts +0 -14
- package/dist/seed/_bundle-constants.js +0 -14
- package/dist/seed/anime-figures-seed-data.d.ts +0 -8
- package/dist/seed/anime-figures-seed-data.js +0 -1033
- package/dist/seed/beyblade-seed-data.d.ts +0 -7
- package/dist/seed/beyblade-seed-data.js +0 -1129
- package/dist/seed/brands-seed-data.d.ts +0 -7
- package/dist/seed/brands-seed-data.js +0 -410
- package/dist/seed/bundles-seed-data.d.ts +0 -13
- package/dist/seed/bundles-seed-data.js +0 -229
- package/dist/seed/cosplay-accessories-seed-data.d.ts +0 -8
- package/dist/seed/cosplay-accessories-seed-data.js +0 -647
- package/dist/seed/hot-wheels-seed-data.d.ts +0 -7
- package/dist/seed/hot-wheels-seed-data.js +0 -1612
- package/dist/seed/letitrip-official-seed-data.d.ts +0 -8
- package/dist/seed/letitrip-official-seed-data.js +0 -399
- package/dist/seed/pokemon-carousel-slides-seed-data.d.ts +0 -8
- package/dist/seed/pokemon-carousel-slides-seed-data.js +0 -322
- package/dist/seed/pokemon-categories-seed-data.d.ts +0 -24
- package/dist/seed/pokemon-categories-seed-data.js +0 -547
- package/dist/seed/pokemon-coupons-seed-data.d.ts +0 -6
- package/dist/seed/pokemon-coupons-seed-data.js +0 -465
- package/dist/seed/pokemon-homepage-sections-seed-data.d.ts +0 -7
- package/dist/seed/pokemon-homepage-sections-seed-data.js +0 -241
- package/dist/seed/pokemon-products-seed-data.d.ts +0 -9
- package/dist/seed/pokemon-products-seed-data.js +0 -1791
- package/dist/seed/pokemon-seed-bundle.d.ts +0 -47
- package/dist/seed/pokemon-seed-bundle.js +0 -71
- package/dist/seed/pokemon-stores-seed-data.d.ts +0 -6
- package/dist/seed/pokemon-stores-seed-data.js +0 -179
- package/dist/seed/pokemon-users-seed-data.d.ts +0 -6
- package/dist/seed/pokemon-users-seed-data.js +0 -521
- package/dist/seed/products-seed-data.d.ts +0 -6
- package/dist/seed/products-seed-data.js +0 -2530
- package/dist/seed/retro-gaming-seed-data.d.ts +0 -8
- package/dist/seed/retro-gaming-seed-data.js +0 -801
- package/dist/seed/server.d.ts +0 -2
- package/dist/seed/server.js +0 -7
- package/dist/seed/sublisting-categories-seed-data.d.ts +0 -7
- package/dist/seed/sublisting-categories-seed-data.js +0 -159
- package/dist/seed/transformers-seed-data.d.ts +0 -7
- package/dist/seed/transformers-seed-data.js +0 -530
|
@@ -1,45 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
3
|
-
const PAYMENT_STALE_MS = 15 * 60 * 1000;
|
|
4
|
-
export const cleanupRtdbEventsHandler = async (ctx) => {
|
|
5
|
-
ctx.logger.info("Starting RTDB events cleanup");
|
|
6
|
-
const rtdb = getAdminRealtimeDb();
|
|
7
|
-
const auth = getAdminAuth();
|
|
8
|
-
const now = Date.now();
|
|
9
|
-
try {
|
|
10
|
-
const authSnap = await rtdb.ref("auth_events").get();
|
|
11
|
-
if (authSnap.exists()) {
|
|
12
|
-
const allEvents = authSnap.val();
|
|
13
|
-
const staleAuthIds = Object.entries(allEvents)
|
|
14
|
-
.filter(([, node]) => (node.createdAt ?? 0) < now - AUTH_STALE_MS)
|
|
15
|
-
.map(([id]) => id);
|
|
16
|
-
if (staleAuthIds.length > 0) {
|
|
17
|
-
await Promise.all(staleAuthIds.flatMap((id) => [
|
|
18
|
-
rtdb.ref(`auth_events/${id}`).remove(),
|
|
19
|
-
auth.deleteUser(`auth_event_${id}`).catch(() => { }),
|
|
20
|
-
]));
|
|
21
|
-
ctx.logger.info("Auth events removed", { count: staleAuthIds.length });
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
catch (authErr) {
|
|
26
|
-
ctx.logger.error("Auth events cleanup failed (non-fatal)", authErr);
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
const paySnap = await rtdb.ref("payment_events").get();
|
|
30
|
-
if (paySnap.exists()) {
|
|
31
|
-
const allPayments = paySnap.val();
|
|
32
|
-
const stalePayIds = Object.entries(allPayments)
|
|
33
|
-
.filter(([, node]) => (node.createdAt ?? 0) < now - PAYMENT_STALE_MS)
|
|
34
|
-
.map(([id]) => id);
|
|
35
|
-
if (stalePayIds.length > 0) {
|
|
36
|
-
await Promise.all(stalePayIds.map((id) => rtdb.ref(`payment_events/${id}`).remove()));
|
|
37
|
-
ctx.logger.info("Payment events removed", { count: stalePayIds.length });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
catch (payErr) {
|
|
42
|
-
ctx.logger.error("Payment events cleanup failed (non-fatal)", payErr);
|
|
43
|
-
}
|
|
44
|
-
ctx.logger.info("RTDB events cleanup complete");
|
|
45
|
-
};
|
|
1
|
+
import { runCleanupRtdbEvents } from "../core/cleanupRtdbEvents";
|
|
2
|
+
export const cleanupRtdbEventsHandler = runCleanupRtdbEvents;
|
|
@@ -1,109 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { QUERY_LIMIT } from "./messages";
|
|
4
|
-
const STORES_COLLECTION = "stores";
|
|
5
|
-
const ORDERS_COLLECTION = "orders";
|
|
6
|
-
async function reconcileCategories(ctx) {
|
|
7
|
-
const snap = await ctx.db
|
|
8
|
-
.collection(PRODUCT_COLLECTION)
|
|
9
|
-
.where("status", "==", ProductStatusValues.PUBLISHED)
|
|
10
|
-
.limit(QUERY_LIMIT)
|
|
11
|
-
.get();
|
|
12
|
-
ctx.logger.info(`[categories] ${snap.size} published products found`);
|
|
13
|
-
const leafCounts = {};
|
|
14
|
-
for (const doc of snap.docs) {
|
|
15
|
-
// SB1-G — split off canonical listingType. Auctions go into auctionIds;
|
|
16
|
-
// everything else (standard, pre-order, prize-draw, bundle) into productIds.
|
|
17
|
-
const data = doc.data();
|
|
18
|
-
const catId = data.category;
|
|
19
|
-
if (!catId)
|
|
20
|
-
continue;
|
|
21
|
-
if (!leafCounts[catId])
|
|
22
|
-
leafCounts[catId] = { productIds: [], auctionIds: [] };
|
|
23
|
-
if (data.listingType === "auction")
|
|
24
|
-
leafCounts[catId].auctionIds.push(doc.id);
|
|
25
|
-
else
|
|
26
|
-
leafCounts[catId].productIds.push(doc.id);
|
|
27
|
-
}
|
|
28
|
-
const ancestorAggregates = {};
|
|
29
|
-
let leafUpdated = 0;
|
|
30
|
-
for (const [catId, { productIds, auctionIds }] of Object.entries(leafCounts)) {
|
|
31
|
-
await categoriesRepository.setMetrics(catId, productIds.length, auctionIds.length, productIds, auctionIds);
|
|
32
|
-
leafUpdated++;
|
|
33
|
-
const parentIds = (await categoriesRepository.findById(catId))?.parentIds ?? [];
|
|
34
|
-
for (const ancestorId of parentIds) {
|
|
35
|
-
if (!ancestorAggregates[ancestorId]) {
|
|
36
|
-
ancestorAggregates[ancestorId] = { productDelta: 0, auctionDelta: 0 };
|
|
37
|
-
}
|
|
38
|
-
ancestorAggregates[ancestorId].productDelta += productIds.length;
|
|
39
|
-
ancestorAggregates[ancestorId].auctionDelta += auctionIds.length;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const ancestorEntries = Object.entries(ancestorAggregates);
|
|
43
|
-
for (const [ancestorId, { productDelta, auctionDelta }] of ancestorEntries) {
|
|
44
|
-
await categoriesRepository.setMetrics(ancestorId, productDelta, auctionDelta, [], []);
|
|
45
|
-
}
|
|
46
|
-
ctx.logger.info("[categories] reconciliation complete", {
|
|
47
|
-
leafCategoriesUpdated: leafUpdated,
|
|
48
|
-
ancestorCategoriesUpdated: ancestorEntries.length,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
async function reconcileStores(ctx) {
|
|
52
|
-
const storeIds = await storeRepository.listIds();
|
|
53
|
-
ctx.logger.info(`[stores] ${storeIds.length} stores found`);
|
|
54
|
-
let processed = 0;
|
|
55
|
-
let errors = 0;
|
|
56
|
-
for (const storeId of storeIds) {
|
|
57
|
-
try {
|
|
58
|
-
const storeSnap = await ctx.db.collection(STORES_COLLECTION).doc(storeId).get();
|
|
59
|
-
if (!storeSnap.exists)
|
|
60
|
-
continue;
|
|
61
|
-
const sellerId = storeSnap.data().ownerId;
|
|
62
|
-
if (!sellerId)
|
|
63
|
-
continue;
|
|
64
|
-
const [productsSnap, ordersSnap, reviewStats] = await Promise.all([
|
|
65
|
-
ctx.db
|
|
66
|
-
.collection(PRODUCT_COLLECTION)
|
|
67
|
-
.where("sellerId", "==", sellerId)
|
|
68
|
-
.where("status", "==", ProductStatusValues.PUBLISHED)
|
|
69
|
-
.limit(QUERY_LIMIT)
|
|
70
|
-
.get(),
|
|
71
|
-
ctx.db
|
|
72
|
-
.collection(ORDERS_COLLECTION)
|
|
73
|
-
.where("sellerId", "==", sellerId)
|
|
74
|
-
.where("status", "==", "delivered")
|
|
75
|
-
.limit(QUERY_LIMIT)
|
|
76
|
-
.get(),
|
|
77
|
-
reviewRepository.getApprovedRatingAggregateByStore(storeId),
|
|
78
|
-
]);
|
|
79
|
-
await storeRepository.setStats(storeId, productsSnap.size, ordersSnap.size, reviewStats.count, reviewStats.count > 0 ? reviewStats.avgRating : null);
|
|
80
|
-
processed++;
|
|
81
|
-
}
|
|
82
|
-
catch (storeErr) {
|
|
83
|
-
errors++;
|
|
84
|
-
ctx.logger.error(`[stores] failed for store ${storeId}`, storeErr);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
ctx.logger.info("[stores] reconciliation complete", {
|
|
88
|
-
processed,
|
|
89
|
-
errors,
|
|
90
|
-
total: storeIds.length,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
export const countersReconcileHandler = async (ctx) => {
|
|
94
|
-
ctx.logger.info("Starting counters reconciliation (categories + stores)");
|
|
95
|
-
try {
|
|
96
|
-
await reconcileCategories(ctx);
|
|
97
|
-
}
|
|
98
|
-
catch (err) {
|
|
99
|
-
ctx.logger.error("Category reconciliation failed", err);
|
|
100
|
-
}
|
|
101
|
-
try {
|
|
102
|
-
await reconcileStores(ctx);
|
|
103
|
-
}
|
|
104
|
-
catch (err) {
|
|
105
|
-
ctx.logger.error("Store reconciliation failed", err);
|
|
106
|
-
throw err;
|
|
107
|
-
}
|
|
108
|
-
ctx.logger.info("Counters reconciliation complete");
|
|
109
|
-
};
|
|
1
|
+
import { runCountersReconcile } from "../core/countersReconcile";
|
|
2
|
+
export const countersReconcileHandler = runCountersReconcile;
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const couponExpiryHandler =
|
|
3
|
-
ctx.logger.info("Starting coupon expiry sweep");
|
|
4
|
-
const refs = await couponsRepository.getExpiredActiveRefs(ctx.now);
|
|
5
|
-
if (refs.length === 0) {
|
|
6
|
-
ctx.logger.info("No expired active coupons found");
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
const batch = ctx.db.batch();
|
|
10
|
-
refs.forEach((ref) => couponsRepository.deactivateInBatch(batch, ref));
|
|
11
|
-
await batch.commit();
|
|
12
|
-
ctx.logger.info("Coupon expiry complete", { deactivated: refs.length });
|
|
13
|
-
};
|
|
1
|
+
import { runCouponExpiry } from "../core/couponExpiry";
|
|
2
|
+
export const couponExpiryHandler = runCouponExpiry;
|
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export const dailyDataCleanupHandler = async (ctx) => {
|
|
4
|
-
ctx.logger.info("Starting daily data cleanup (sessions + tokens)");
|
|
5
|
-
const sessionRefs = await sessionRepository.getExpiredRefs(ctx.now);
|
|
6
|
-
const sessionsDeleted = await batchDelete(ctx, sessionRefs);
|
|
7
|
-
ctx.logger.info("Session cleanup complete", { deleted: sessionsDeleted });
|
|
8
|
-
const emailRefs = await tokenRepository.getExpiredEmailVerificationRefs(ctx.now);
|
|
9
|
-
const emailDeleted = await batchDelete(ctx, emailRefs);
|
|
10
|
-
const pwRefs = await tokenRepository.getExpiredPasswordResetRefs(ctx.now);
|
|
11
|
-
const pwDeleted = await batchDelete(ctx, pwRefs);
|
|
12
|
-
ctx.logger.info("Token cleanup complete", {
|
|
13
|
-
emailVerificationDeleted: emailDeleted,
|
|
14
|
-
passwordResetDeleted: pwDeleted,
|
|
15
|
-
});
|
|
16
|
-
ctx.logger.info("Daily data cleanup complete", {
|
|
17
|
-
sessionsDeleted,
|
|
18
|
-
tokensDeleted: emailDeleted + pwDeleted,
|
|
19
|
-
});
|
|
20
|
-
};
|
|
1
|
+
import { runDailyDataCleanup } from "../core/dailyDataCleanup";
|
|
2
|
+
export const dailyDataCleanupHandler = runDailyDataCleanup;
|
|
@@ -1,30 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTPS callable handler: server-to-server listing proxy. Every appkit
|
|
3
|
-
* repository routes its `.list()` through the same Sieve adapter, so adding
|
|
4
|
-
* a new collection is a one-line addition to `LISTERS`.
|
|
5
|
-
*
|
|
6
|
-
* Cursor: opaque base64 over `{ page }`. Callers may use either page-mode
|
|
7
|
-
* (`p` directly) or infinite-mode (forward `cursor` from previous response).
|
|
8
|
-
*/
|
|
9
1
|
import type { CallableHandler } from "../runtime/types";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
f?: string;
|
|
14
|
-
s?: string;
|
|
15
|
-
p?: number | string;
|
|
16
|
-
ps?: number | string;
|
|
17
|
-
cursor?: string;
|
|
18
|
-
baseOpts?: Record<string, unknown>;
|
|
19
|
-
}
|
|
20
|
-
export interface ListingResponseBody {
|
|
21
|
-
items: unknown[];
|
|
22
|
-
total: number;
|
|
23
|
-
page: number;
|
|
24
|
-
pageSize: number;
|
|
25
|
-
totalPages: number;
|
|
26
|
-
hasMore: boolean;
|
|
27
|
-
cursor: string | null;
|
|
28
|
-
}
|
|
2
|
+
import { supportedListingCollections, type ListingRequestBody, type ListingResponseBody } from "../core/listingProcessor";
|
|
3
|
+
export type { ListingRequestBody, ListingResponseBody };
|
|
4
|
+
export { supportedListingCollections };
|
|
29
5
|
export declare const listingProcessorHandler: CallableHandler<ListingRequestBody, ListingResponseBody>;
|
|
30
|
-
export declare const supportedListingCollections: string[];
|
|
@@ -1,138 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* a new collection is a one-line addition to `LISTERS`.
|
|
5
|
-
*
|
|
6
|
-
* Cursor: opaque base64 over `{ page }`. Callers may use either page-mode
|
|
7
|
-
* (`p` directly) or infinite-mode (forward `cursor` from previous response).
|
|
8
|
-
*/
|
|
9
|
-
import { bidRepository, blogRepository, categoriesRepository, couponsRepository, eventEntryRepository, eventRepository, faqsRepository, homepageSectionsRepository, notificationRepository, orderRepository, payoutRepository, productFeaturesRepository, productRepository, productTemplateRepository, reviewRepository, scammerRepository, storeRepository, userRepository, } from "../../../../repositories";
|
|
10
|
-
const DEFAULT_SORT = "-createdAt";
|
|
11
|
-
const DEFAULT_PAGE = 1;
|
|
12
|
-
const DEFAULT_PAGE_SIZE = 20;
|
|
13
|
-
const MAX_PAGE_SIZE = 100;
|
|
14
|
-
class ListingError extends Error {
|
|
15
|
-
constructor(status, message) {
|
|
16
|
-
super(message);
|
|
17
|
-
this.name = "ListingError";
|
|
18
|
-
this.httpStatus = status;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function requireOpt(baseOpts, key, collection) {
|
|
22
|
-
const value = baseOpts[key];
|
|
23
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
24
|
-
throw new ListingError(400, `${collection} listing requires baseOpts.${key}`);
|
|
25
|
-
}
|
|
26
|
-
return value;
|
|
27
|
-
}
|
|
28
|
-
function getBoolOpt(baseOpts, key, fallback) {
|
|
29
|
-
const value = baseOpts[key];
|
|
30
|
-
if (typeof value === "boolean")
|
|
31
|
-
return value;
|
|
32
|
-
if (value === "true")
|
|
33
|
-
return true;
|
|
34
|
-
if (value === "false")
|
|
35
|
-
return false;
|
|
36
|
-
return fallback;
|
|
37
|
-
}
|
|
38
|
-
const LISTERS = {
|
|
39
|
-
products: (m, o) => productRepository.list(m, o),
|
|
40
|
-
categories: (m) => categoriesRepository.list(m),
|
|
41
|
-
brands: (m) => categoriesRepository.list({
|
|
42
|
-
...m,
|
|
43
|
-
filters: m.filters
|
|
44
|
-
? `${m.filters},categoryType==brand`
|
|
45
|
-
: "categoryType==brand",
|
|
46
|
-
}),
|
|
47
|
-
orders: (m) => orderRepository.listAll(m),
|
|
48
|
-
reviews: (m) => reviewRepository.listAll(m),
|
|
49
|
-
coupons: (m) => couponsRepository.list(m),
|
|
50
|
-
bids: (m) => bidRepository.list(m),
|
|
51
|
-
payouts: (m) => payoutRepository.list(m),
|
|
52
|
-
blogPosts: (m) => blogRepository.listAll(m),
|
|
53
|
-
events: (m) => eventRepository.list(m),
|
|
54
|
-
faqs: (m) => faqsRepository.list(m),
|
|
55
|
-
notifications: (m) => notificationRepository.list(m),
|
|
56
|
-
scammers: (m) => scammerRepository.listAll(m),
|
|
57
|
-
sublistingCategories: (m) => categoriesRepository.list({
|
|
58
|
-
...m,
|
|
59
|
-
filters: m.filters
|
|
60
|
-
? `${m.filters},categoryType==sublisting`
|
|
61
|
-
: "categoryType==sublisting",
|
|
62
|
-
}),
|
|
63
|
-
productFeatures: (m) => productFeaturesRepository.list(m),
|
|
64
|
-
homepageSections: (m) => homepageSectionsRepository.list(m),
|
|
65
|
-
users: (m) => userRepository.list(m),
|
|
66
|
-
stores: (m, o) => storeRepository.listStores(m, getBoolOpt(o, "activeOnly", true)),
|
|
67
|
-
eventEntries: (m, o) => {
|
|
68
|
-
const eventId = requireOpt(o, "eventId", "eventEntries");
|
|
69
|
-
return eventEntryRepository.listForEvent(eventId, m);
|
|
70
|
-
},
|
|
71
|
-
productTemplates: (m, o) => {
|
|
72
|
-
const storeId = requireOpt(o, "storeId", "productTemplates");
|
|
73
|
-
return productTemplateRepository.listByStore(storeId, m);
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
const SUPPORTED_COLLECTIONS = Object.keys(LISTERS);
|
|
77
|
-
function decodeCursor(cursor) {
|
|
78
|
-
if (!cursor)
|
|
79
|
-
return null;
|
|
80
|
-
try {
|
|
81
|
-
const json = Buffer.from(cursor, "base64").toString("utf8");
|
|
82
|
-
const parsed = JSON.parse(json);
|
|
83
|
-
const page = Number(parsed.page);
|
|
84
|
-
return Number.isFinite(page) && page > 0 ? page : null;
|
|
85
|
-
}
|
|
86
|
-
catch {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function encodeCursor(page) {
|
|
91
|
-
return Buffer.from(JSON.stringify({ page }), "utf8").toString("base64");
|
|
92
|
-
}
|
|
93
|
-
function clampPageSize(raw) {
|
|
94
|
-
const n = Number(raw);
|
|
95
|
-
if (!Number.isFinite(n) || n <= 0)
|
|
96
|
-
return DEFAULT_PAGE_SIZE;
|
|
97
|
-
return Math.min(Math.floor(n), MAX_PAGE_SIZE);
|
|
98
|
-
}
|
|
99
|
-
function clampPage(raw) {
|
|
100
|
-
const n = Number(raw);
|
|
101
|
-
if (!Number.isFinite(n) || n < 1)
|
|
102
|
-
return DEFAULT_PAGE;
|
|
103
|
-
return Math.floor(n);
|
|
104
|
-
}
|
|
105
|
-
export const listingProcessorHandler = async (body, ctx) => {
|
|
106
|
-
if (!body || typeof body.collection !== "string") {
|
|
107
|
-
throw new ListingError(400, "Missing collection");
|
|
108
|
-
}
|
|
109
|
-
const lister = LISTERS[body.collection];
|
|
110
|
-
if (!lister) {
|
|
111
|
-
throw new ListingError(400, `Unsupported collection: ${body.collection}. Supported: ${SUPPORTED_COLLECTIONS.join(",")}`);
|
|
112
|
-
}
|
|
113
|
-
const cursorPage = decodeCursor(body.cursor);
|
|
114
|
-
const page = cursorPage ?? clampPage(body.p);
|
|
115
|
-
const pageSize = clampPageSize(body.ps);
|
|
116
|
-
const result = await lister({
|
|
117
|
-
filters: body.f ?? "",
|
|
118
|
-
sorts: body.s ?? DEFAULT_SORT,
|
|
119
|
-
page: String(page),
|
|
120
|
-
pageSize: String(pageSize),
|
|
121
|
-
}, body.baseOpts ?? {});
|
|
122
|
-
ctx.logger.info("listing served", {
|
|
123
|
-
collection: body.collection,
|
|
124
|
-
page: result.page,
|
|
125
|
-
pageSize: result.pageSize,
|
|
126
|
-
total: result.total,
|
|
127
|
-
});
|
|
128
|
-
return {
|
|
129
|
-
items: result.items,
|
|
130
|
-
total: result.total,
|
|
131
|
-
page: result.page,
|
|
132
|
-
pageSize: result.pageSize,
|
|
133
|
-
totalPages: result.totalPages,
|
|
134
|
-
hasMore: result.hasMore,
|
|
135
|
-
cursor: result.hasMore ? encodeCursor(result.page + 1) : null,
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
export const supportedListingCollections = SUPPORTED_COLLECTIONS;
|
|
1
|
+
import { runListingProcessor, supportedListingCollections, } from "../core/listingProcessor";
|
|
2
|
+
export { supportedListingCollections };
|
|
3
|
+
export const listingProcessorHandler = runListingProcessor;
|
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Job handler: media tmp cleanup.
|
|
3
|
-
*
|
|
4
|
-
* Sweeps Firebase Storage for stale objects under the tmp/ prefix. Layer 2 of
|
|
5
|
-
* the dual-layer scheme — Layer 1 is the form-level onAbort() DELETE call;
|
|
6
|
-
* this job mops up anything that escaped (crashes, expired sessions).
|
|
7
|
-
*
|
|
8
|
-
* Safety invariants:
|
|
9
|
-
* - Only touches objects whose name starts with `tmp/`.
|
|
10
|
-
* - Only deletes objects older than `ttlHours` (default 24).
|
|
11
|
-
* - Idempotent: 404s on delete are swallowed (Layer 1 already removed it).
|
|
12
|
-
*/
|
|
13
1
|
import type { ScheduleHandler } from "../runtime/types";
|
|
14
2
|
export declare const mediaTmpCleanupHandler: ScheduleHandler;
|
|
@@ -1,69 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Sweeps Firebase Storage for stale objects under the tmp/ prefix. Layer 2 of
|
|
5
|
-
* the dual-layer scheme — Layer 1 is the form-level onAbort() DELETE call;
|
|
6
|
-
* this job mops up anything that escaped (crashes, expired sessions).
|
|
7
|
-
*
|
|
8
|
-
* Safety invariants:
|
|
9
|
-
* - Only touches objects whose name starts with `tmp/`.
|
|
10
|
-
* - Only deletes objects older than `ttlHours` (default 24).
|
|
11
|
-
* - Idempotent: 404s on delete are swallowed (Layer 1 already removed it).
|
|
12
|
-
*/
|
|
13
|
-
import { getAdminStorageLite } from "../../../../providers/db-firebase/admin-storage-lite";
|
|
14
|
-
const TMP_PREFIX = "tmp/";
|
|
15
|
-
const DEFAULT_TTL_HOURS = 24;
|
|
16
|
-
function getBucket() {
|
|
17
|
-
const bucketName = process.env.FIREBASE_ADMIN_STORAGE_BUCKET?.trim() ??
|
|
18
|
-
process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET?.trim();
|
|
19
|
-
return bucketName ? getAdminStorageLite().bucket(bucketName) : getAdminStorageLite().bucket();
|
|
20
|
-
}
|
|
21
|
-
export const mediaTmpCleanupHandler = async (ctx) => {
|
|
22
|
-
const ttlHours = Number(ctx.env("MEDIA_TMP_TTL_HOURS") ?? DEFAULT_TTL_HOURS);
|
|
23
|
-
const cutoff = new Date(Date.now() - ttlHours * 60 * 60 * 1000);
|
|
24
|
-
ctx.logger.info("Starting media tmp cleanup", { prefix: TMP_PREFIX, ttlHours });
|
|
25
|
-
let scanned = 0;
|
|
26
|
-
let deleted = 0;
|
|
27
|
-
let skipped = 0;
|
|
28
|
-
let errors = 0;
|
|
29
|
-
try {
|
|
30
|
-
const bucket = getBucket();
|
|
31
|
-
const [files] = await bucket.getFiles({ prefix: TMP_PREFIX, autoPaginate: true });
|
|
32
|
-
scanned = files.length;
|
|
33
|
-
ctx.logger.info("Objects under tmp prefix", { count: scanned });
|
|
34
|
-
for (const file of files) {
|
|
35
|
-
try {
|
|
36
|
-
if (!file.name.startsWith(TMP_PREFIX)) {
|
|
37
|
-
skipped++;
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
const [metadata] = await file.getMetadata();
|
|
41
|
-
const updated = metadata.updated ?? metadata.timeCreated;
|
|
42
|
-
if (!updated) {
|
|
43
|
-
skipped++;
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
if (new Date(updated) >= cutoff) {
|
|
47
|
-
skipped++;
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
await file.delete();
|
|
51
|
-
deleted++;
|
|
52
|
-
}
|
|
53
|
-
catch (fileError) {
|
|
54
|
-
errors++;
|
|
55
|
-
const code = fileError?.code;
|
|
56
|
-
if (code === 404) {
|
|
57
|
-
// Already deleted by Layer 1 — ignore.
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
ctx.logger.error("Failed to delete tmp file", fileError, { name: file.name });
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch (err) {
|
|
65
|
-
ctx.logger.error("Fatal error during media tmp cleanup", err);
|
|
66
|
-
throw err;
|
|
67
|
-
}
|
|
68
|
-
ctx.logger.info("Media tmp cleanup complete", { scanned, deleted, skipped, errors });
|
|
69
|
-
};
|
|
1
|
+
import { runMediaTmpCleanup } from "../core/mediaTmpCleanup";
|
|
2
|
+
export const mediaTmpCleanupHandler = runMediaTmpCleanup;
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { batchDelete } from "./_helpers";
|
|
4
|
-
export const notificationPruneHandler = async (ctx) => {
|
|
5
|
-
ctx.logger.info(`Pruning read notifications older than ${NOTIFICATION_TTL_DAYS} days`);
|
|
6
|
-
const refs = await notificationRepository.getOldReadRefs(NOTIFICATION_TTL_DAYS);
|
|
7
|
-
if (refs.length === 0) {
|
|
8
|
-
ctx.logger.info("No stale read notifications found");
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const deleted = await batchDelete(ctx, refs);
|
|
12
|
-
ctx.logger.info("Notification prune complete", { deleted });
|
|
13
|
-
};
|
|
1
|
+
import { runNotificationPrune } from "../core/notificationPrune";
|
|
2
|
+
export const notificationPruneHandler = runNotificationPrune;
|
|
@@ -1,50 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const offerExpiryHandler =
|
|
3
|
-
ctx.logger.info("Starting offer expiry sweep");
|
|
4
|
-
let expiredOffers;
|
|
5
|
-
try {
|
|
6
|
-
expiredOffers = await offerRepository.findExpiredActive(ctx.now);
|
|
7
|
-
}
|
|
8
|
-
catch (err) {
|
|
9
|
-
ctx.logger.error("Failed to query expired offers", err);
|
|
10
|
-
throw err;
|
|
11
|
-
}
|
|
12
|
-
if (expiredOffers.length === 0) {
|
|
13
|
-
ctx.logger.info("No expired offers found");
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
ctx.logger.info(`Found ${expiredOffers.length} expired offer(s) to process`);
|
|
17
|
-
const expiredIds = [];
|
|
18
|
-
for (const offer of expiredOffers) {
|
|
19
|
-
try {
|
|
20
|
-
expiredIds.push(offer.id);
|
|
21
|
-
await notificationRepository.create({
|
|
22
|
-
userId: offer.buyerUid,
|
|
23
|
-
type: "offer_expired",
|
|
24
|
-
priority: "normal",
|
|
25
|
-
title: "Offer expired",
|
|
26
|
-
message: `Your offer on "${offer.productTitle}" expired without a response.`,
|
|
27
|
-
relatedId: offer.id,
|
|
28
|
-
relatedType: "offer",
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
ctx.logger.warn(`Failed to process expiry for offer ${offer.id}`, {
|
|
33
|
-
error: err instanceof Error ? err.message : String(err),
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (expiredIds.length > 0) {
|
|
38
|
-
try {
|
|
39
|
-
await offerRepository.expireMany(expiredIds);
|
|
40
|
-
}
|
|
41
|
-
catch (err) {
|
|
42
|
-
ctx.logger.error("Failed to batch-expire offers", err);
|
|
43
|
-
throw err;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
ctx.logger.info("Offer expiry complete", {
|
|
47
|
-
processed: expiredIds.length,
|
|
48
|
-
skipped: expiredOffers.length - expiredIds.length,
|
|
49
|
-
});
|
|
50
|
-
};
|
|
1
|
+
import { runOfferExpiry } from "../core/offerExpiry";
|
|
2
|
+
export const offerExpiryHandler = runOfferExpiry;
|
|
@@ -1,12 +1,3 @@
|
|
|
1
1
|
import type { FirestoreTriggerHandler } from "../runtime/types";
|
|
2
|
-
|
|
3
|
-
id: string;
|
|
4
|
-
productId: string;
|
|
5
|
-
productTitle: string;
|
|
6
|
-
userId: string;
|
|
7
|
-
userName: string;
|
|
8
|
-
bidAmount: number;
|
|
9
|
-
currency: string;
|
|
10
|
-
}
|
|
2
|
+
import { type NewBid } from "../core/onBidPlaced";
|
|
11
3
|
export declare const onBidPlacedHandler: FirestoreTriggerHandler<null, NewBid>;
|
|
12
|
-
export {};
|
|
@@ -1,63 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { decryptPii } from "../../../../security/index";
|
|
3
|
-
import { getAdminRealtimeDb } from "../../../../providers/db-firebase";
|
|
4
|
-
import { BID_MESSAGES } from "./messages";
|
|
5
|
-
const BIDS_COLLECTION = "bids";
|
|
1
|
+
import { handleBidPlaced } from "../core/onBidPlaced";
|
|
6
2
|
export const onBidPlacedHandler = async (event, ctx) => {
|
|
7
3
|
const newBid = event.after;
|
|
8
4
|
if (!newBid) {
|
|
9
5
|
ctx.logger.error("No snapshot data", null);
|
|
10
6
|
return;
|
|
11
7
|
}
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const prevWinning = await bidRepository.getWinningBid(newBid.productId);
|
|
15
|
-
const batch = ctx.db.batch();
|
|
16
|
-
const newBidRef = ctx.db.collection(BIDS_COLLECTION).doc(event.params.bidId);
|
|
17
|
-
bidRepository.markWinning(batch, newBidRef);
|
|
18
|
-
let outbidUserId = null;
|
|
19
|
-
if (prevWinning && prevWinning.data.userId !== newBid.userId) {
|
|
20
|
-
outbidUserId = prevWinning.data.userId;
|
|
21
|
-
bidRepository.markOutbid(batch, prevWinning.ref);
|
|
22
|
-
notificationRepository.createInBatch(batch, {
|
|
23
|
-
userId: outbidUserId,
|
|
24
|
-
type: "bid_outbid",
|
|
25
|
-
priority: "high",
|
|
26
|
-
title: BID_MESSAGES.OUTBID_TITLE,
|
|
27
|
-
message: BID_MESSAGES.OUTBID_MESSAGE(newBid.productTitle, newBid.currency, newBid.bidAmount),
|
|
28
|
-
relatedId: newBid.productId,
|
|
29
|
-
relatedType: "product",
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
productRepository.incrementBidCountInBatch(batch, newBid.productId, newBid.bidAmount);
|
|
33
|
-
await batch.commit();
|
|
34
|
-
try {
|
|
35
|
-
if (outbidUserId) {
|
|
36
|
-
await getAdminRealtimeDb()
|
|
37
|
-
.ref(`notifications/${outbidUserId}`)
|
|
38
|
-
.push({
|
|
39
|
-
type: "bid_outbid",
|
|
40
|
-
title: BID_MESSAGES.OUTBID_TITLE,
|
|
41
|
-
message: BID_MESSAGES.OUTBID_MESSAGE(newBid.productTitle, newBid.currency, newBid.bidAmount),
|
|
42
|
-
timestamp: Date.now(),
|
|
43
|
-
read: false,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
catch (rtdbError) {
|
|
48
|
-
ctx.logger.error("Realtime DB push failed (non-fatal)", rtdbError);
|
|
49
|
-
}
|
|
50
|
-
ctx.logger.info(`Bid placed on ${newBid.productId}`, {
|
|
51
|
-
bidId: event.params.bidId,
|
|
52
|
-
amount: newBid.bidAmount,
|
|
53
|
-
outbidUserId,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
ctx.logger.error("Error handling bid placement", error, {
|
|
58
|
-
bidId: event.params.bidId,
|
|
59
|
-
productId: newBid.productId,
|
|
60
|
-
});
|
|
61
|
-
throw error;
|
|
62
|
-
}
|
|
8
|
+
await handleBidPlaced({ bidId: event.params.bidId, bid: newBid }, ctx);
|
|
63
9
|
};
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Trigger handler: maintain DFS `position` + `subtreeSize` on every category
|
|
3
|
-
* write. CREATE → insert into parent's subtree + shift later siblings;
|
|
4
|
-
* DELETE → shift back; MOVE → mark `positionDirty` so the nightly reconcile
|
|
5
|
-
* job rebuilds (real-time move would require repositioning an entire subtree).
|
|
6
|
-
*/
|
|
7
1
|
import type { FirestoreTriggerHandler } from "../runtime/types";
|
|
8
|
-
type CategoryDoc
|
|
2
|
+
import { type CategoryDoc } from "../core/onCategoryWrite";
|
|
9
3
|
export declare const onCategoryWriteHandler: FirestoreTriggerHandler<CategoryDoc, CategoryDoc>;
|
|
10
|
-
export {};
|