@mohasinac/appkit 3.0.4 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_internal/client/features/lottery/LotteryAdminEditView.d.ts +42 -0
- package/dist/_internal/client/features/lottery/LotteryAdminEditView.js +86 -0
- package/dist/_internal/client/features/lottery/LotteryAdminSlotView.d.ts +14 -0
- package/dist/_internal/client/features/lottery/LotteryAdminSlotView.js +46 -0
- package/dist/_internal/client/features/lottery/LotteryDetailView.d.ts +28 -0
- package/dist/_internal/client/features/lottery/LotteryDetailView.js +17 -0
- package/dist/_internal/client/features/lottery/LotteryEntriesView.d.ts +23 -0
- package/dist/_internal/client/features/lottery/LotteryEntriesView.js +58 -0
- package/dist/_internal/client/features/lottery/LotteryListView.d.ts +21 -0
- package/dist/_internal/client/features/lottery/LotteryListView.js +25 -0
- package/dist/_internal/client/features/lottery/LotteryPullForm.d.ts +19 -0
- package/dist/_internal/client/features/lottery/LotteryPullForm.js +65 -0
- package/dist/_internal/client/features/lottery/LotterySlotGrid.d.ts +13 -0
- package/dist/_internal/client/features/lottery/LotterySlotGrid.js +21 -0
- package/dist/_internal/client/features/lottery/PrizeDrawLotteryDetailView.d.ts +28 -0
- package/dist/_internal/client/features/lottery/PrizeDrawLotteryDetailView.js +18 -0
- package/dist/_internal/server/features/auctions/__tests__/service.test.d.ts +1 -0
- package/dist/_internal/server/features/auctions/__tests__/service.test.js +140 -0
- package/dist/_internal/server/features/auctions/data.d.ts +2 -4
- package/dist/_internal/server/features/auctions/data.js +3 -9
- package/dist/_internal/server/features/checkout/__tests__/actions.test.d.ts +1 -0
- package/dist/_internal/server/features/checkout/__tests__/actions.test.js +600 -0
- package/dist/_internal/server/features/classified/adapters.d.ts +2 -15
- package/dist/_internal/server/features/classified/adapters.js +2 -17
- package/dist/_internal/server/features/classified/data.d.ts +1 -6
- package/dist/_internal/server/features/classified/data.js +2 -10
- package/dist/_internal/server/features/digital-code/adapters.d.ts +2 -15
- package/dist/_internal/server/features/digital-code/adapters.js +2 -17
- package/dist/_internal/server/features/digital-code/data.d.ts +1 -6
- package/dist/_internal/server/features/digital-code/data.js +2 -10
- package/dist/_internal/server/features/live/adapters.d.ts +2 -15
- package/dist/_internal/server/features/live/adapters.js +2 -17
- package/dist/_internal/server/features/live/data.d.ts +1 -6
- package/dist/_internal/server/features/live/data.js +2 -10
- package/dist/_internal/server/features/lottery/actions.d.ts +43 -0
- package/dist/_internal/server/features/lottery/actions.js +243 -0
- package/dist/_internal/server/features/lottery/adapters.d.ts +9 -0
- package/dist/_internal/server/features/lottery/adapters.js +21 -0
- package/dist/_internal/server/features/lottery/data.d.ts +20 -0
- package/dist/_internal/server/features/lottery/data.js +41 -0
- package/dist/_internal/server/features/lottery/metadata.d.ts +6 -0
- package/dist/_internal/server/features/lottery/metadata.js +31 -0
- package/dist/_internal/server/features/pre-orders/data.d.ts +2 -4
- package/dist/_internal/server/features/pre-orders/data.js +3 -9
- package/dist/_internal/server/features/prize-draws/actions.d.ts +2 -0
- package/dist/_internal/server/features/prize-draws/actions.js +22 -0
- package/dist/_internal/server/features/prize-draws/data.d.ts +1 -17
- package/dist/_internal/server/features/prize-draws/data.js +2 -20
- package/dist/_internal/server/features/prize-draws/index.d.ts +3 -1
- package/dist/_internal/server/features/prize-draws/index.js +2 -0
- package/dist/_internal/server/features/prize-draws/service.d.ts +3 -0
- package/dist/_internal/server/features/prize-draws/service.js +19 -0
- package/dist/_internal/server/features/refunds/__tests__/actions.test.d.ts +1 -0
- package/dist/_internal/server/features/refunds/__tests__/actions.test.js +263 -0
- package/dist/_internal/server/features/shared/listing-adapters.d.ts +19 -0
- package/dist/_internal/server/features/shared/listing-adapters.js +20 -0
- package/dist/_internal/server/features/shared/listing-data-factory.d.ts +9 -0
- package/dist/_internal/server/features/shared/listing-data-factory.js +33 -0
- package/dist/_internal/server/features/stores/data.d.ts +3 -14
- package/dist/_internal/server/features/stores/data.js +6 -44
- package/dist/_internal/server/jobs/core/__tests__/auctionSettlement.test.d.ts +1 -0
- package/dist/_internal/server/jobs/core/__tests__/auctionSettlement.test.js +249 -0
- package/dist/_internal/server/jobs/core/__tests__/onBidPlaced.test.d.ts +1 -0
- package/dist/_internal/server/jobs/core/__tests__/onBidPlaced.test.js +201 -0
- package/dist/_internal/server/jobs/core/__tests__/onOrderCreate.test.d.ts +1 -0
- package/dist/_internal/server/jobs/core/__tests__/onOrderCreate.test.js +169 -0
- package/dist/_internal/server/jobs/core/__tests__/onOrderStatusChange.test.d.ts +1 -0
- package/dist/_internal/server/jobs/core/__tests__/onOrderStatusChange.test.js +148 -0
- package/dist/_internal/server/jobs/core/__tests__/onProductStockChange.test.d.ts +1 -0
- package/dist/_internal/server/jobs/core/__tests__/onProductStockChange.test.js +210 -0
- package/dist/_internal/server/jobs/core/__tests__/onReviewWrite.test.d.ts +1 -0
- package/dist/_internal/server/jobs/core/__tests__/onReviewWrite.test.js +190 -0
- package/dist/_internal/server/jobs/core/__tests__/onUserBanChange.test.d.ts +1 -0
- package/dist/_internal/server/jobs/core/__tests__/onUserBanChange.test.js +161 -0
- package/dist/_internal/server/jobs/core/__tests__/payoutBatch.test.d.ts +1 -0
- package/dist/_internal/server/jobs/core/__tests__/payoutBatch.test.js +302 -0
- package/dist/_internal/server/jobs/core/__tests__/triggerEventRaffle.test.d.ts +1 -0
- package/dist/_internal/server/jobs/core/__tests__/triggerEventRaffle.test.js +252 -0
- package/dist/_internal/server/jobs/core/__tests__/wrapJobHandler.test.d.ts +1 -0
- package/dist/_internal/server/jobs/core/__tests__/wrapJobHandler.test.js +129 -0
- package/dist/_internal/shared/actions/action-registry.d.ts +1 -1
- package/dist/_internal/shared/actions/action-registry.js +46 -0
- package/dist/_internal/shared/features/cart/schema.d.ts +8 -8
- package/dist/_internal/shared/features/cart/schema.js +3 -0
- package/dist/_internal/shared/features/products/schema.d.ts +8 -8
- package/dist/_internal/shared/listing-types/_registry.js +2 -0
- package/dist/_internal/shared/listing-types/auction/schema.d.ts +3 -1
- package/dist/_internal/shared/listing-types/auction/schema.js +7 -1
- package/dist/_internal/shared/listing-types/classified/schema.d.ts +2 -1
- package/dist/_internal/shared/listing-types/classified/schema.js +3 -1
- package/dist/_internal/shared/listing-types/digital-code/schema.d.ts +3 -1
- package/dist/_internal/shared/listing-types/digital-code/schema.js +7 -1
- package/dist/_internal/shared/listing-types/live/schema.d.ts +2 -1
- package/dist/_internal/shared/listing-types/live/schema.js +3 -1
- package/dist/_internal/shared/listing-types/pre-order/schema.d.ts +3 -1
- package/dist/_internal/shared/listing-types/pre-order/schema.js +7 -1
- package/dist/_internal/shared/listing-types/prize-draw/schema.d.ts +3 -1
- package/dist/_internal/shared/listing-types/prize-draw/schema.js +13 -1
- package/dist/_internal/shared/listing-types/standard/schema.d.ts +2 -1
- package/dist/_internal/shared/listing-types/standard/schema.js +4 -1
- package/dist/_internal/shared/types/base-document.d.ts +15 -0
- package/dist/_internal/shared/types/base-document.js +1 -0
- package/dist/_internal/shared/types/index.d.ts +2 -0
- package/dist/_internal/shared/types/index.js +1 -0
- package/dist/client.d.ts +13 -4
- package/dist/client.js +11 -2
- package/dist/constants/api-endpoints.d.ts +12 -0
- package/dist/constants/api-endpoints.js +4 -0
- package/dist/constants/field-names.d.ts +5 -1
- package/dist/constants/field-names.js +5 -1
- package/dist/features/addresses/repository/__tests__/addresses.repository.test.d.ts +1 -0
- package/dist/features/addresses/repository/__tests__/addresses.repository.test.js +386 -0
- package/dist/features/addresses/schemas/firestore.d.ts +2 -4
- package/dist/features/admin/api/bids/route.d.ts +2 -2
- package/dist/features/admin/api/coupons/route.d.ts +2 -2
- package/dist/features/admin/api/products/route.d.ts +2 -2
- package/dist/features/admin/api/reviews/route.d.ts +2 -2
- package/dist/features/admin/components/AdminFulfillmentView.d.ts +6 -0
- package/dist/features/admin/components/AdminFulfillmentView.js +107 -0
- package/dist/features/admin/components/AdminProductEditorView.js +21 -9
- package/dist/features/admin/components/AdminProductsView.js +3 -0
- package/dist/features/admin/components/DataListingView.d.ts +1 -0
- package/dist/features/admin/components/index.d.ts +2 -0
- package/dist/features/admin/components/index.js +1 -0
- package/dist/features/admin/repository/__tests__/notification.repository.test.d.ts +1 -0
- package/dist/features/admin/repository/__tests__/notification.repository.test.js +356 -0
- package/dist/features/admin/repository/__tests__/site-settings.repository.test.d.ts +1 -0
- package/dist/features/admin/repository/__tests__/site-settings.repository.test.js +298 -0
- package/dist/features/admin/schemas/firestore.d.ts +3 -8
- package/dist/features/auctions/repository/__tests__/bid.repository.test.d.ts +1 -0
- package/dist/features/auctions/repository/__tests__/bid.repository.test.js +290 -0
- package/dist/features/auctions/schemas/firestore.d.ts +2 -4
- package/dist/features/auctions/schemas/index.d.ts +2 -2
- package/dist/features/auth/api/route.d.ts +2 -2
- package/dist/features/auth/repository/__tests__/session.repository.test.d.ts +1 -0
- package/dist/features/auth/repository/__tests__/session.repository.test.js +310 -0
- package/dist/features/auth/repository/__tests__/session.test.d.ts +1 -0
- package/dist/features/auth/repository/__tests__/session.test.js +146 -0
- package/dist/features/auth/repository/__tests__/sms-counter.repository.test.d.ts +1 -0
- package/dist/features/auth/repository/__tests__/sms-counter.repository.test.js +171 -0
- package/dist/features/auth/repository/__tests__/sms-counter.test.d.ts +1 -0
- package/dist/features/auth/repository/__tests__/sms-counter.test.js +88 -0
- package/dist/features/auth/repository/__tests__/token.repository.test.d.ts +1 -0
- package/dist/features/auth/repository/__tests__/token.repository.test.js +260 -0
- package/dist/features/auth/repository/__tests__/token.test.d.ts +1 -0
- package/dist/features/auth/repository/__tests__/token.test.js +140 -0
- package/dist/features/auth/repository/__tests__/user.repository.test.d.ts +1 -0
- package/dist/features/auth/repository/__tests__/user.repository.test.js +352 -0
- package/dist/features/auth/repository/__tests__/user.test.d.ts +1 -0
- package/dist/features/auth/repository/__tests__/user.test.js +226 -0
- package/dist/features/auth/repository/session.repository.js +10 -1
- package/dist/features/before-after/schemas/index.d.ts +2 -2
- package/dist/features/blog/schemas/firestore.d.ts +2 -4
- package/dist/features/blog/schemas/index.d.ts +4 -4
- package/dist/features/cart/repository/__tests__/cart.repository.test.d.ts +1 -0
- package/dist/features/cart/repository/__tests__/cart.repository.test.js +371 -0
- package/dist/features/cart/repository/cart.repository.js +2 -2
- package/dist/features/cart/schemas/firestore.d.ts +2 -4
- package/dist/features/categories/api/[id]/route.d.ts +4 -4
- package/dist/features/categories/api/route.d.ts +2 -2
- package/dist/features/categories/repository/__tests__/categories.repository.test.d.ts +1 -0
- package/dist/features/categories/repository/__tests__/categories.repository.test.js +813 -0
- package/dist/features/categories/schemas/firestore.d.ts +2 -4
- package/dist/features/categories/schemas/index.d.ts +4 -4
- package/dist/features/events/components/EventCard.js +1 -0
- package/dist/features/events/repository/__tests__/event.repository.test.d.ts +1 -0
- package/dist/features/events/repository/__tests__/event.repository.test.js +299 -0
- package/dist/features/events/schemas/firestore.d.ts +5 -4
- package/dist/features/events/schemas/index.d.ts +836 -16
- package/dist/features/events/schemas/index.js +80 -1
- package/dist/features/events/types/index.d.ts +4 -1
- package/dist/features/faq/repository/__tests__/faqs.repository.test.d.ts +1 -0
- package/dist/features/faq/repository/__tests__/faqs.repository.test.js +311 -0
- package/dist/features/faq/schemas/firestore.d.ts +2 -4
- package/dist/features/faq/schemas/index.d.ts +2 -2
- package/dist/features/grouped/schemas/index.d.ts +2 -2
- package/dist/features/history/repository/__tests__/user-history.repository.test.d.ts +1 -0
- package/dist/features/history/repository/__tests__/user-history.repository.test.js +180 -0
- package/dist/features/homepage/api/[id]/route.d.ts +4 -4
- package/dist/features/homepage/api/carousel/[id]/route.d.ts +4 -4
- package/dist/features/homepage/api/carousel/route.d.ts +2 -2
- package/dist/features/homepage/api/route.d.ts +2 -2
- package/dist/features/homepage/repository/__tests__/carousel.repository.test.d.ts +1 -0
- package/dist/features/homepage/repository/__tests__/carousel.repository.test.js +182 -0
- package/dist/features/homepage/repository/__tests__/homepage-sections.repository.test.d.ts +1 -0
- package/dist/features/homepage/repository/__tests__/homepage-sections.repository.test.js +185 -0
- package/dist/features/homepage/schemas/firestore.d.ts +4 -12
- package/dist/features/homepage/schemas/index.d.ts +2 -2
- package/dist/features/lottery/repository/lottery-entry.repository.d.ts +33 -0
- package/dist/features/lottery/repository/lottery-entry.repository.js +130 -0
- package/dist/features/lottery/schemas/firestore.d.ts +49 -0
- package/dist/features/lottery/schemas/firestore.js +25 -0
- package/dist/features/lottery/schemas/zod.d.ts +113 -0
- package/dist/features/lottery/schemas/zod.js +39 -0
- package/dist/features/lottery/types/index.d.ts +67 -0
- package/dist/features/lottery/types/index.js +55 -0
- package/dist/features/messages/repository/__tests__/conversations.repository.test.d.ts +1 -0
- package/dist/features/messages/repository/__tests__/conversations.repository.test.js +257 -0
- package/dist/features/messages/schemas/firestore.d.ts +2 -4
- package/dist/features/messages/schemas/index.d.ts +2 -2
- package/dist/features/orders/repository/__tests__/orders.repository.test.d.ts +1 -0
- package/dist/features/orders/repository/__tests__/orders.repository.test.js +211 -0
- package/dist/features/orders/repository/orders.repository.d.ts +5 -0
- package/dist/features/orders/repository/orders.repository.js +26 -0
- package/dist/features/orders/schemas/firestore.d.ts +9 -5
- package/dist/features/orders/schemas/firestore.js +3 -0
- package/dist/features/payments/repository/__tests__/payout.repository.test.d.ts +1 -0
- package/dist/features/payments/repository/__tests__/payout.repository.test.js +292 -0
- package/dist/features/payments/schemas/firestore.d.ts +2 -4
- package/dist/features/pre-orders/schemas/index.d.ts +2 -2
- package/dist/features/products/api/[id]/route.d.ts +4 -4
- package/dist/features/products/api/route.d.ts +2 -2
- package/dist/features/products/constants/action-defs.d.ts +16 -0
- package/dist/features/products/constants/action-defs.js +16 -0
- package/dist/features/products/constants/listing-tabs.d.ts +48 -0
- package/dist/features/products/constants/listing-tabs.js +12 -0
- package/dist/features/products/repository/__tests__/product-features.repository.test.d.ts +1 -0
- package/dist/features/products/repository/__tests__/product-features.repository.test.js +329 -0
- package/dist/features/products/repository/__tests__/products.repository.test.d.ts +1 -0
- package/dist/features/products/repository/__tests__/products.repository.test.js +607 -0
- package/dist/features/products/repository/products.repository.d.ts +37 -0
- package/dist/features/products/repository/products.repository.js +28 -1
- package/dist/features/products/schemas/firestore.d.ts +23 -7
- package/dist/features/products/schemas/firestore.js +2 -0
- package/dist/features/products/schemas/index.d.ts +18 -18
- package/dist/features/products/schemas/index.js +4 -2
- package/dist/features/products/types/index.d.ts +3 -1
- package/dist/features/promotions/repository/__tests__/claimed-coupons.repository.test.d.ts +1 -0
- package/dist/features/promotions/repository/__tests__/claimed-coupons.repository.test.js +219 -0
- package/dist/features/promotions/repository/__tests__/coupons.repository.test.d.ts +1 -0
- package/dist/features/promotions/repository/__tests__/coupons.repository.test.js +480 -0
- package/dist/features/promotions/schemas/firestore.d.ts +2 -4
- package/dist/features/promotions/schemas/index.d.ts +4 -4
- package/dist/features/reviews/api/[id]/route.d.ts +4 -4
- package/dist/features/reviews/api/route.d.ts +2 -2
- package/dist/features/reviews/repository/__tests__/reviews.repository.test.d.ts +1 -0
- package/dist/features/reviews/repository/__tests__/reviews.repository.test.js +327 -0
- package/dist/features/reviews/schemas/firestore.d.ts +2 -4
- package/dist/features/reviews/schemas/index.d.ts +2 -2
- package/dist/features/scams/repository/__tests__/scammer.repository.test.d.ts +1 -0
- package/dist/features/scams/repository/__tests__/scammer.repository.test.js +385 -0
- package/dist/features/scams/schemas/firestore.d.ts +2 -4
- package/dist/features/scams/schemas/index.d.ts +4 -4
- package/dist/features/search/repository/__tests__/search.repository.test.d.ts +1 -0
- package/dist/features/search/repository/__tests__/search.repository.test.js +369 -0
- package/dist/features/search/schemas/index.d.ts +2 -2
- package/dist/features/seller/api/coupons/route.d.ts +2 -2
- package/dist/features/seller/api/offers/route.d.ts +2 -2
- package/dist/features/seller/api/products/route.d.ts +2 -2
- package/dist/features/seller/api/store/route.d.ts +2 -2
- package/dist/features/seller/components/BarcodeField.d.ts +17 -0
- package/dist/features/seller/components/BarcodeField.js +30 -0
- package/dist/features/seller/components/FulfillmentView.d.ts +5 -0
- package/dist/features/seller/components/FulfillmentView.js +120 -0
- package/dist/features/seller/components/PrintCenterView.d.ts +3 -1
- package/dist/features/seller/components/PrintCenterView.js +52 -4
- package/dist/features/seller/components/SellerProductShell.d.ts +2 -0
- package/dist/features/seller/components/SellerProductShell.js +2 -1
- package/dist/features/seller/components/index.d.ts +4 -0
- package/dist/features/seller/components/index.js +2 -0
- package/dist/features/seller/repository/__tests__/offer.repository.test.d.ts +1 -0
- package/dist/features/seller/repository/__tests__/offer.repository.test.js +458 -0
- package/dist/features/seller/schemas/index.d.ts +2 -2
- package/dist/features/store-extensions/schemas/firestore.d.ts +12 -44
- package/dist/features/stores/components/StoreClassifiedsListing.d.ts +5 -0
- package/dist/features/stores/components/StoreClassifiedsListing.js +48 -0
- package/dist/features/stores/components/StoreClassifiedsPageView.d.ts +4 -0
- package/dist/features/stores/components/StoreClassifiedsPageView.js +20 -0
- package/dist/features/stores/components/StoreDetailLayoutView.js +23 -2
- package/dist/features/stores/components/StoreDigitalCodesListing.d.ts +5 -0
- package/dist/features/stores/components/StoreDigitalCodesListing.js +48 -0
- package/dist/features/stores/components/StoreDigitalCodesPageView.d.ts +4 -0
- package/dist/features/stores/components/StoreDigitalCodesPageView.js +20 -0
- package/dist/features/stores/components/StoreLiveItemsListing.d.ts +5 -0
- package/dist/features/stores/components/StoreLiveItemsListing.js +48 -0
- package/dist/features/stores/components/StoreLiveItemsPageView.d.ts +4 -0
- package/dist/features/stores/components/StoreLiveItemsPageView.js +20 -0
- package/dist/features/stores/components/index.d.ts +9 -0
- package/dist/features/stores/components/index.js +3 -0
- package/dist/features/stores/repository/__tests__/store.repository.test.d.ts +1 -0
- package/dist/features/stores/repository/__tests__/store.repository.test.js +261 -0
- package/dist/features/stores/schemas/firestore.d.ts +2 -4
- package/dist/features/stores/schemas/index.d.ts +4 -4
- package/dist/features/support/repository/__tests__/support.repository.test.d.ts +1 -0
- package/dist/features/support/repository/__tests__/support.repository.test.js +312 -0
- package/dist/features/support/schemas/firestore.d.ts +2 -4
- package/dist/features/support/schemas/index.d.ts +2 -2
- package/dist/features/wishlist/repository/__tests__/user-wishlist.repository.test.d.ts +1 -0
- package/dist/features/wishlist/repository/__tests__/user-wishlist.repository.test.js +139 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +17 -0
- package/dist/next/api/routeHandler.d.ts +1 -1
- package/dist/next/routing/route-map.d.ts +24 -0
- package/dist/next/routing/route-map.js +11 -0
- package/dist/repositories/index.d.ts +1 -0
- package/dist/repositories/index.js +2 -0
- package/dist/schemas/registry.d.ts +24 -24
- package/dist/security/index.d.ts +1 -1
- package/dist/security/index.js +1 -1
- package/dist/security/pii-schemas.d.ts +2 -0
- package/dist/security/pii-schemas.js +6 -0
- package/dist/seed/actions/demo-seed-actions.d.ts +1 -1
- package/dist/seed/events-seed-data.js +85 -2
- package/dist/seed/grouped-listings-seed-data.d.ts +5 -2
- package/dist/seed/index.d.ts +1 -0
- package/dist/seed/index.js +1 -0
- package/dist/seed/lottery-entries-seed-data.d.ts +2 -0
- package/dist/seed/lottery-entries-seed-data.js +108 -0
- package/dist/seed/manifest.js +1 -0
- package/dist/seed/products-preorders-seed-data.d.ts +5 -2
- package/dist/seed/products-standard-seed-data.js +8 -0
- package/dist/server-entry.d.ts +3 -0
- package/dist/server-entry.js +3 -0
- package/dist/server.d.ts +10 -4
- package/dist/server.js +6 -0
- package/dist/styles.css +1 -1
- package/dist/tailwind-utilities.css +1 -1
- package/dist/utils/id-generators.d.ts +8 -0
- package/dist/utils/id-generators.js +14 -0
- package/package.json +2 -1
|
@@ -19,8 +19,11 @@ export const eventTypeSchema = z.enum([
|
|
|
19
19
|
"poll",
|
|
20
20
|
"survey",
|
|
21
21
|
"feedback",
|
|
22
|
+
"raffle",
|
|
23
|
+
"spin_wheel",
|
|
24
|
+
"lottery",
|
|
22
25
|
]);
|
|
23
|
-
export const eventStatusSchema = z.enum(["draft", "active", "paused", "ended"]);
|
|
26
|
+
export const eventStatusSchema = z.enum(["draft", "active", "paused", "ended", "cancelled"]);
|
|
24
27
|
export const saleConfigSchema = z.object({
|
|
25
28
|
discountPercent: z.number(),
|
|
26
29
|
bannerText: z.string().optional(),
|
|
@@ -36,6 +39,60 @@ export const pollConfigSchema = z.object({
|
|
|
36
39
|
allowComment: z.boolean(),
|
|
37
40
|
options: z.array(z.object({ id: z.string(), label: z.string() })),
|
|
38
41
|
resultsVisibility: z.enum(["always", "after_vote", "after_end"]),
|
|
42
|
+
requireLogin: z.boolean().optional(),
|
|
43
|
+
});
|
|
44
|
+
export const surveyFormFieldSchema = z.object({
|
|
45
|
+
id: z.string(),
|
|
46
|
+
type: z.enum(["text", "textarea", "email", "phone", "number", "select", "multiselect", "checkbox", "radio", "date", "rating", "file"]),
|
|
47
|
+
label: z.string(),
|
|
48
|
+
placeholder: z.string().optional(),
|
|
49
|
+
required: z.boolean(),
|
|
50
|
+
options: z.array(z.string()).optional(),
|
|
51
|
+
validation: z.object({
|
|
52
|
+
minLength: z.number().optional(),
|
|
53
|
+
maxLength: z.number().optional(),
|
|
54
|
+
min: z.number().optional(),
|
|
55
|
+
max: z.number().optional(),
|
|
56
|
+
pattern: z.string().optional(),
|
|
57
|
+
}).optional(),
|
|
58
|
+
order: z.number(),
|
|
59
|
+
});
|
|
60
|
+
export const surveyConfigSchema = z.object({
|
|
61
|
+
requireLogin: z.boolean(),
|
|
62
|
+
maxEntriesPerUser: z.number(),
|
|
63
|
+
hasLeaderboard: z.boolean(),
|
|
64
|
+
hasPointSystem: z.boolean(),
|
|
65
|
+
pointsLabel: z.string().optional(),
|
|
66
|
+
entryReviewRequired: z.boolean(),
|
|
67
|
+
formFields: z.array(surveyFormFieldSchema),
|
|
68
|
+
});
|
|
69
|
+
export const feedbackConfigSchema = z.object({
|
|
70
|
+
formFields: z.array(surveyFormFieldSchema),
|
|
71
|
+
anonymous: z.boolean(),
|
|
72
|
+
});
|
|
73
|
+
export const spinPrizeSchema = z.object({
|
|
74
|
+
id: z.string(),
|
|
75
|
+
label: z.string(),
|
|
76
|
+
couponId: z.string().optional(),
|
|
77
|
+
weight: z.number(),
|
|
78
|
+
isActive: z.boolean(),
|
|
79
|
+
});
|
|
80
|
+
/** Lottery slot schema — client-safe shape (no priceInPaise/weight sent to clients). */
|
|
81
|
+
export const lotterySlotClientSchema = z.object({
|
|
82
|
+
slotNumber: z.number().int().min(1),
|
|
83
|
+
name: z.string(),
|
|
84
|
+
isBooked: z.boolean(),
|
|
85
|
+
bookedByUserLotteryNumber: z.number().optional(),
|
|
86
|
+
bookedByDisplayName: z.string().optional(),
|
|
87
|
+
});
|
|
88
|
+
/** Client-safe lottery config schema — price/weight fields stripped server-side. */
|
|
89
|
+
export const lotteryConfigClientSchema = z.object({
|
|
90
|
+
slots: z.array(lotterySlotClientSchema),
|
|
91
|
+
totalSlots: z.number().int().min(1).max(200),
|
|
92
|
+
pricingMode: z.enum(["uniform", "variable"]),
|
|
93
|
+
drawWindowDurationMinutes: z.number(),
|
|
94
|
+
maxPullsPerTransaction: z.number().int().min(1),
|
|
95
|
+
maxPullsPerUser: z.number().int().min(1),
|
|
39
96
|
});
|
|
40
97
|
// --- Base item schema ---------------------------------------------------------
|
|
41
98
|
/**
|
|
@@ -53,6 +110,7 @@ export const pollConfigSchema = z.object({
|
|
|
53
110
|
*/
|
|
54
111
|
export const eventItemSchema = z.object({
|
|
55
112
|
id: z.string(),
|
|
113
|
+
slug: z.string().optional(),
|
|
56
114
|
type: eventTypeSchema,
|
|
57
115
|
title: z.string(),
|
|
58
116
|
description: z.string(),
|
|
@@ -67,6 +125,27 @@ export const eventItemSchema = z.object({
|
|
|
67
125
|
saleConfig: saleConfigSchema.optional(),
|
|
68
126
|
offerConfig: offerConfigSchema.optional(),
|
|
69
127
|
pollConfig: pollConfigSchema.optional(),
|
|
128
|
+
surveyConfig: surveyConfigSchema.optional(),
|
|
129
|
+
feedbackConfig: feedbackConfigSchema.optional(),
|
|
130
|
+
// Raffle fields
|
|
131
|
+
hasRaffle: z.boolean().optional(),
|
|
132
|
+
raffleType: z.enum(["top_n_scorers", "top_n_participants", "open_raffle", "spin_wheel"]).optional(),
|
|
133
|
+
raffleTopN: z.number().optional(),
|
|
134
|
+
rafflePrize: z.string().optional(),
|
|
135
|
+
rafflePrizeCouponId: z.string().optional(),
|
|
136
|
+
rafflePrizeProductIds: z.array(z.string()).optional(),
|
|
137
|
+
raffleGithubFunctionUrl: z.string().optional(),
|
|
138
|
+
raffleWinnerUserId: z.string().optional(),
|
|
139
|
+
raffleWinnerDisplayName: z.string().optional(),
|
|
140
|
+
raffleTriggeredAt: z.string().optional(),
|
|
141
|
+
raffleEntryCount: z.number().optional(),
|
|
142
|
+
// Spin wheel fields
|
|
143
|
+
spinPrizes: z.array(spinPrizeSchema).optional(),
|
|
144
|
+
spinMaxPerUser: z.number().optional(),
|
|
145
|
+
spinWindowStart: z.string().optional(),
|
|
146
|
+
spinWindowEnd: z.string().optional(),
|
|
147
|
+
// Lottery config (new) — client-safe shape (price/weight stripped by adapter)
|
|
148
|
+
lotteryConfig: lotteryConfigClientSchema.optional(),
|
|
70
149
|
stats: z.object({
|
|
71
150
|
totalEntries: z.number(),
|
|
72
151
|
approvedEntries: z.number(),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { MediaField } from "../../media/types/index";
|
|
2
2
|
import type { JsonValue } from "@mohasinac/appkit";
|
|
3
|
-
|
|
3
|
+
import type { ClientLotteryConfig } from "../../lottery/types";
|
|
4
|
+
export type EventType = "sale" | "offer" | "poll" | "survey" | "feedback" | "raffle" | "spin_wheel" | "lottery";
|
|
4
5
|
export type RaffleType = "top_n_scorers" | "top_n_participants" | "open_raffle" | "spin_wheel";
|
|
5
6
|
export interface SpinPrize {
|
|
6
7
|
id: string;
|
|
@@ -96,6 +97,8 @@ export interface EventItem {
|
|
|
96
97
|
spinMaxPerUser?: number;
|
|
97
98
|
spinWindowStart?: string;
|
|
98
99
|
spinWindowEnd?: string;
|
|
100
|
+
/** Lottery config — slots have price/weight stripped for client consumption. */
|
|
101
|
+
lotteryConfig?: ClientLotteryConfig;
|
|
99
102
|
stats: {
|
|
100
103
|
totalEntries: number;
|
|
101
104
|
approvedEntries: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { makeMockDb, makeSnap, makeQuerySnap } from "../../../../../tests/helpers/mock-firestore";
|
|
3
|
+
const { db, mockDocRef, mockCollection, mockQuery } = makeMockDb();
|
|
4
|
+
vi.mock("../../../../providers/db-firebase/admin", () => ({
|
|
5
|
+
getAdminDb: () => db,
|
|
6
|
+
}));
|
|
7
|
+
vi.mock("../../../../providers/db-firebase", async (importOriginal) => {
|
|
8
|
+
const actual = await importOriginal();
|
|
9
|
+
return {
|
|
10
|
+
...actual,
|
|
11
|
+
prepareForFirestore: (d) => d,
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
vi.mock("../../../../errors/normalize", () => ({
|
|
15
|
+
normalizeError: vi.fn(),
|
|
16
|
+
}));
|
|
17
|
+
import { FirebaseFAQsRepository } from "../faqs.repository";
|
|
18
|
+
const repo = new FirebaseFAQsRepository();
|
|
19
|
+
function makeFaqDoc(overrides = {}) {
|
|
20
|
+
return {
|
|
21
|
+
id: "faq-how-does-bidding-work",
|
|
22
|
+
question: "How does bidding work?",
|
|
23
|
+
answer: { text: "You place a bid above the current price.", format: "plain" },
|
|
24
|
+
category: "Auctions",
|
|
25
|
+
tags: ["bidding", "auctions"],
|
|
26
|
+
searchTokens: ["how", "does", "bidding", "work"],
|
|
27
|
+
relatedFAQs: [],
|
|
28
|
+
seo: { slug: "how-does-bidding-work" },
|
|
29
|
+
isActive: true,
|
|
30
|
+
showOnHomepage: false,
|
|
31
|
+
showInFooter: false,
|
|
32
|
+
isPinned: false,
|
|
33
|
+
priority: 0,
|
|
34
|
+
order: 0,
|
|
35
|
+
useSiteSettings: false,
|
|
36
|
+
createdBy: "admin-1",
|
|
37
|
+
stats: { views: 0, helpful: 0, notHelpful: 0 },
|
|
38
|
+
createdAt: new Date(),
|
|
39
|
+
updatedAt: new Date(),
|
|
40
|
+
...overrides,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
vi.clearAllMocks();
|
|
45
|
+
db.collection.mockReturnValue(mockCollection);
|
|
46
|
+
mockCollection.doc.mockReturnValue(mockDocRef);
|
|
47
|
+
mockCollection.where.mockReturnValue(mockQuery);
|
|
48
|
+
mockQuery.where.mockReturnValue(mockQuery);
|
|
49
|
+
mockQuery.orderBy.mockReturnValue(mockQuery);
|
|
50
|
+
mockQuery.limit.mockReturnValue(mockQuery);
|
|
51
|
+
mockQuery.get.mockResolvedValue(makeQuerySnap([]));
|
|
52
|
+
mockDocRef.get.mockResolvedValue(makeSnap(null));
|
|
53
|
+
mockDocRef.set.mockResolvedValue(undefined);
|
|
54
|
+
mockDocRef.update.mockResolvedValue(undefined);
|
|
55
|
+
});
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
// createWithSlug
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
describe("FirebaseFAQsRepository.createWithSlug", () => {
|
|
60
|
+
it("uses seo.slug from input when provided", async () => {
|
|
61
|
+
const input = {
|
|
62
|
+
question: "How does bidding work?",
|
|
63
|
+
answer: { text: "You bid above the current price.", format: "plain" },
|
|
64
|
+
category: "Auctions",
|
|
65
|
+
tags: ["bidding"],
|
|
66
|
+
seo: { slug: "custom-slug" },
|
|
67
|
+
isActive: true,
|
|
68
|
+
};
|
|
69
|
+
const result = await repo.createWithSlug(input);
|
|
70
|
+
expect(result.seo.slug).toBe("custom-slug");
|
|
71
|
+
});
|
|
72
|
+
it("generates seo.slug from question when seo.slug not provided", async () => {
|
|
73
|
+
const input = {
|
|
74
|
+
question: "How does bidding work?",
|
|
75
|
+
answer: { text: "Details here.", format: "plain" },
|
|
76
|
+
category: "Auctions",
|
|
77
|
+
tags: [],
|
|
78
|
+
isActive: true,
|
|
79
|
+
};
|
|
80
|
+
const result = await repo.createWithSlug(input);
|
|
81
|
+
expect(result.seo.slug).toMatch(/bidding/i);
|
|
82
|
+
});
|
|
83
|
+
it("builds searchTokens from question, answer, category, and tags", async () => {
|
|
84
|
+
const input = {
|
|
85
|
+
question: "What is a reserve price?",
|
|
86
|
+
answer: { text: "Reserve is the minimum.", format: "plain" },
|
|
87
|
+
category: "Auctions",
|
|
88
|
+
tags: ["reserve", "price"],
|
|
89
|
+
seo: { slug: "what-is-reserve-price" },
|
|
90
|
+
isActive: true,
|
|
91
|
+
};
|
|
92
|
+
const result = await repo.createWithSlug(input);
|
|
93
|
+
expect(result.searchTokens).toContain("reserve");
|
|
94
|
+
expect(result.searchTokens).toContain("price");
|
|
95
|
+
expect(result.searchTokens).toContain("what");
|
|
96
|
+
});
|
|
97
|
+
it("sets stats.views=0, stats.helpful=0, stats.notHelpful=0", async () => {
|
|
98
|
+
const input = {
|
|
99
|
+
question: "New question?",
|
|
100
|
+
answer: { text: "Answer.", format: "plain" },
|
|
101
|
+
category: "General",
|
|
102
|
+
tags: [],
|
|
103
|
+
isActive: true,
|
|
104
|
+
};
|
|
105
|
+
const result = await repo.createWithSlug(input);
|
|
106
|
+
expect(result.stats).toEqual({ views: 0, helpful: 0, notHelpful: 0 });
|
|
107
|
+
});
|
|
108
|
+
it("persists the FAQ to Firestore", async () => {
|
|
109
|
+
const input = {
|
|
110
|
+
question: "Question?",
|
|
111
|
+
answer: { text: "Answer.", format: "plain" },
|
|
112
|
+
category: "General",
|
|
113
|
+
tags: [],
|
|
114
|
+
seo: { slug: "question" },
|
|
115
|
+
isActive: true,
|
|
116
|
+
};
|
|
117
|
+
await repo.createWithSlug(input);
|
|
118
|
+
expect(mockDocRef.set).toHaveBeenCalledOnce();
|
|
119
|
+
});
|
|
120
|
+
it("searchTokens deduplicated and lowercased", async () => {
|
|
121
|
+
const input = {
|
|
122
|
+
question: "What what what?",
|
|
123
|
+
answer: { text: "Answer.", format: "plain" },
|
|
124
|
+
category: "General",
|
|
125
|
+
tags: [],
|
|
126
|
+
isActive: true,
|
|
127
|
+
};
|
|
128
|
+
const result = await repo.createWithSlug(input);
|
|
129
|
+
const whatCount = result.searchTokens.filter((t) => t === "what").length;
|
|
130
|
+
expect(whatCount).toBe(1);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
// ---------------------------------------------------------------------------
|
|
134
|
+
// interpolateVariables
|
|
135
|
+
// ---------------------------------------------------------------------------
|
|
136
|
+
describe("FirebaseFAQsRepository.interpolateVariables", () => {
|
|
137
|
+
it("replaces {{variable}} placeholders with provided values", async () => {
|
|
138
|
+
const faq = makeFaqDoc({
|
|
139
|
+
answer: { text: "Your order {{orderId}} will arrive in {{days}} days.", format: "plain" },
|
|
140
|
+
});
|
|
141
|
+
const result = await repo.interpolateVariables(faq, { orderId: "ORD-123", days: 3 });
|
|
142
|
+
expect(result.answer.interpolated).toBe("Your order ORD-123 will arrive in 3 days.");
|
|
143
|
+
});
|
|
144
|
+
it("falls back to faq.variables when runtime variable not provided", async () => {
|
|
145
|
+
const faq = makeFaqDoc({
|
|
146
|
+
answer: { text: "Contact us at {{supportEmail}}.", format: "plain" },
|
|
147
|
+
variables: { supportEmail: "support@letitrip.in" },
|
|
148
|
+
});
|
|
149
|
+
const result = await repo.interpolateVariables(faq);
|
|
150
|
+
expect(result.answer.interpolated).toBe("Contact us at support@letitrip.in.");
|
|
151
|
+
});
|
|
152
|
+
it("leaves unknown placeholders as-is", async () => {
|
|
153
|
+
const faq = makeFaqDoc({
|
|
154
|
+
answer: { text: "Hello {{unknownVar}}!", format: "plain" },
|
|
155
|
+
});
|
|
156
|
+
const result = await repo.interpolateVariables(faq, {});
|
|
157
|
+
expect(result.answer.interpolated).toBe("Hello {{unknownVar}}!");
|
|
158
|
+
});
|
|
159
|
+
it("returns unchanged interpolated when no placeholders present", async () => {
|
|
160
|
+
const faq = makeFaqDoc({
|
|
161
|
+
answer: { text: "No variables here.", format: "plain" },
|
|
162
|
+
});
|
|
163
|
+
const result = await repo.interpolateVariables(faq, { irrelevant: "x" });
|
|
164
|
+
expect(result.answer.interpolated).toBe("No variables here.");
|
|
165
|
+
});
|
|
166
|
+
it("replaces multiple occurrences of the same placeholder", async () => {
|
|
167
|
+
const faq = makeFaqDoc({
|
|
168
|
+
answer: { text: "{{name}} is {{name}}.", format: "plain" },
|
|
169
|
+
});
|
|
170
|
+
const result = await repo.interpolateVariables(faq, { name: "LetItRip" });
|
|
171
|
+
expect(result.answer.interpolated).toBe("LetItRip is LetItRip.");
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
// ---------------------------------------------------------------------------
|
|
175
|
+
// markHelpful
|
|
176
|
+
// ---------------------------------------------------------------------------
|
|
177
|
+
describe("FirebaseFAQsRepository.markHelpful", () => {
|
|
178
|
+
it("increments stats.helpful on the FAQ document", async () => {
|
|
179
|
+
await repo.markHelpful("faq-1");
|
|
180
|
+
expect(mockDocRef.update).toHaveBeenCalledWith(expect.objectContaining({ "stats.helpful": expect.anything() }));
|
|
181
|
+
});
|
|
182
|
+
it("does not modify other stats fields", async () => {
|
|
183
|
+
await repo.markHelpful("faq-1");
|
|
184
|
+
const updateArg = mockDocRef.update.mock.calls[0][0];
|
|
185
|
+
expect(Object.keys(updateArg)).not.toContain("stats.views");
|
|
186
|
+
expect(Object.keys(updateArg)).not.toContain("stats.notHelpful");
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
// ---------------------------------------------------------------------------
|
|
190
|
+
// markNotHelpful
|
|
191
|
+
// ---------------------------------------------------------------------------
|
|
192
|
+
describe("FirebaseFAQsRepository.markNotHelpful", () => {
|
|
193
|
+
it("increments stats.notHelpful on the FAQ document", async () => {
|
|
194
|
+
await repo.markNotHelpful("faq-1");
|
|
195
|
+
expect(mockDocRef.update).toHaveBeenCalledWith(expect.objectContaining({ "stats.notHelpful": expect.anything() }));
|
|
196
|
+
});
|
|
197
|
+
it("does not modify stats.helpful", async () => {
|
|
198
|
+
await repo.markNotHelpful("faq-1");
|
|
199
|
+
const updateArg = mockDocRef.update.mock.calls[0][0];
|
|
200
|
+
expect(Object.keys(updateArg)).not.toContain("stats.helpful");
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
// ---------------------------------------------------------------------------
|
|
204
|
+
// incrementViews
|
|
205
|
+
// ---------------------------------------------------------------------------
|
|
206
|
+
describe("FirebaseFAQsRepository.incrementViews", () => {
|
|
207
|
+
it("increments stats.views by 1", async () => {
|
|
208
|
+
await repo.incrementViews("faq-1");
|
|
209
|
+
expect(mockDocRef.update).toHaveBeenCalledWith(expect.objectContaining({ "stats.views": expect.anything() }));
|
|
210
|
+
});
|
|
211
|
+
it("sets stats.lastViewed timestamp", async () => {
|
|
212
|
+
await repo.incrementViews("faq-1");
|
|
213
|
+
expect(mockDocRef.update).toHaveBeenCalledWith(expect.objectContaining({ "stats.lastViewed": expect.any(Date) }));
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
// ---------------------------------------------------------------------------
|
|
217
|
+
// getHomepageFAQs
|
|
218
|
+
// ---------------------------------------------------------------------------
|
|
219
|
+
describe("FirebaseFAQsRepository.getHomepageFAQs", () => {
|
|
220
|
+
it("queries showOnHomepage=true AND isActive=true", async () => {
|
|
221
|
+
mockQuery.get.mockResolvedValue(makeQuerySnap([]));
|
|
222
|
+
await repo.getHomepageFAQs();
|
|
223
|
+
expect(mockCollection.where).toHaveBeenCalledWith(expect.stringContaining("showOnHomepage"), "==", true);
|
|
224
|
+
expect(mockQuery.where).toHaveBeenCalledWith(expect.stringContaining("isActive"), "==", true);
|
|
225
|
+
});
|
|
226
|
+
it("orders results by priority descending", async () => {
|
|
227
|
+
mockQuery.get.mockResolvedValue(makeQuerySnap([]));
|
|
228
|
+
await repo.getHomepageFAQs();
|
|
229
|
+
expect(mockQuery.orderBy).toHaveBeenCalledWith(expect.stringContaining("priority"), "desc");
|
|
230
|
+
});
|
|
231
|
+
it("returns matching FAQs", async () => {
|
|
232
|
+
const faq = makeFaqDoc({ showOnHomepage: true });
|
|
233
|
+
mockQuery.get.mockResolvedValue(makeQuerySnap([{ id: faq.id, data: faq }]));
|
|
234
|
+
const results = await repo.getHomepageFAQs();
|
|
235
|
+
expect(results).toHaveLength(1);
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
// ---------------------------------------------------------------------------
|
|
239
|
+
// searchByTag
|
|
240
|
+
// ---------------------------------------------------------------------------
|
|
241
|
+
describe("FirebaseFAQsRepository.searchByTag", () => {
|
|
242
|
+
it("filters by array-contains on the tags field", async () => {
|
|
243
|
+
mockQuery.get.mockResolvedValue(makeQuerySnap([]));
|
|
244
|
+
await repo.searchByTag("grading");
|
|
245
|
+
expect(mockCollection.where).toHaveBeenCalledWith(expect.stringContaining("tags"), "array-contains", "grading");
|
|
246
|
+
});
|
|
247
|
+
it("also filters isActive=true", async () => {
|
|
248
|
+
mockQuery.get.mockResolvedValue(makeQuerySnap([]));
|
|
249
|
+
await repo.searchByTag("returns");
|
|
250
|
+
expect(mockQuery.where).toHaveBeenCalledWith(expect.stringContaining("isActive"), "==", true);
|
|
251
|
+
});
|
|
252
|
+
it("returns matching FAQs", async () => {
|
|
253
|
+
const faq = makeFaqDoc({ tags: ["grading"] });
|
|
254
|
+
mockQuery.get.mockResolvedValue(makeQuerySnap([{ id: faq.id, data: faq }]));
|
|
255
|
+
const results = await repo.searchByTag("grading");
|
|
256
|
+
expect(results).toHaveLength(1);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
// ---------------------------------------------------------------------------
|
|
260
|
+
// getPinnedFAQs
|
|
261
|
+
// ---------------------------------------------------------------------------
|
|
262
|
+
describe("FirebaseFAQsRepository.getPinnedFAQs", () => {
|
|
263
|
+
it("queries isPinned=true AND isActive=true", async () => {
|
|
264
|
+
mockQuery.get.mockResolvedValue(makeQuerySnap([]));
|
|
265
|
+
await repo.getPinnedFAQs();
|
|
266
|
+
expect(mockCollection.where).toHaveBeenCalledWith(expect.stringContaining("isPinned"), "==", true);
|
|
267
|
+
expect(mockQuery.where).toHaveBeenCalledWith(expect.stringContaining("isActive"), "==", true);
|
|
268
|
+
});
|
|
269
|
+
it("orders by order field ascending", async () => {
|
|
270
|
+
mockQuery.get.mockResolvedValue(makeQuerySnap([]));
|
|
271
|
+
await repo.getPinnedFAQs();
|
|
272
|
+
expect(mockQuery.orderBy).toHaveBeenCalledWith(expect.stringContaining("order"), "asc");
|
|
273
|
+
});
|
|
274
|
+
it("filters by category when provided", async () => {
|
|
275
|
+
mockQuery.get.mockResolvedValue(makeQuerySnap([]));
|
|
276
|
+
await repo.getPinnedFAQs("Shipping");
|
|
277
|
+
expect(mockQuery.where).toHaveBeenCalledWith(expect.stringContaining("category"), "==", "Shipping");
|
|
278
|
+
});
|
|
279
|
+
it("no category filter applied when category not provided", async () => {
|
|
280
|
+
mockQuery.get.mockResolvedValue(makeQuerySnap([]));
|
|
281
|
+
await repo.getPinnedFAQs();
|
|
282
|
+
const whereCalls = mockQuery.where.mock.calls;
|
|
283
|
+
const categoryFilter = whereCalls.find((c) => c[0].includes("category"));
|
|
284
|
+
expect(categoryFilter).toBeUndefined();
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
// ---------------------------------------------------------------------------
|
|
288
|
+
// getMostHelpful
|
|
289
|
+
// ---------------------------------------------------------------------------
|
|
290
|
+
describe("FirebaseFAQsRepository.getMostHelpful", () => {
|
|
291
|
+
it("filters by isActive=true", async () => {
|
|
292
|
+
mockQuery.get.mockResolvedValue(makeQuerySnap([]));
|
|
293
|
+
await repo.getMostHelpful();
|
|
294
|
+
expect(mockCollection.where).toHaveBeenCalledWith(expect.stringContaining("isActive"), "==", true);
|
|
295
|
+
});
|
|
296
|
+
it("orders by stats.helpful descending", async () => {
|
|
297
|
+
mockQuery.get.mockResolvedValue(makeQuerySnap([]));
|
|
298
|
+
await repo.getMostHelpful();
|
|
299
|
+
expect(mockQuery.orderBy).toHaveBeenCalledWith("stats.helpful", "desc");
|
|
300
|
+
});
|
|
301
|
+
it("applies default limit of 10", async () => {
|
|
302
|
+
mockQuery.get.mockResolvedValue(makeQuerySnap([]));
|
|
303
|
+
await repo.getMostHelpful();
|
|
304
|
+
expect(mockQuery.limit).toHaveBeenCalledWith(10);
|
|
305
|
+
});
|
|
306
|
+
it("applies custom limit when provided", async () => {
|
|
307
|
+
mockQuery.get.mockResolvedValue(makeQuerySnap([]));
|
|
308
|
+
await repo.getMostHelpful(5);
|
|
309
|
+
expect(mockQuery.limit).toHaveBeenCalledWith(5);
|
|
310
|
+
});
|
|
311
|
+
});
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { FAQCategory, FAQAnswer, FAQStats } from "../types";
|
|
5
5
|
export type { FAQCategory, FAQAnswer, FAQStats } from "../types";
|
|
6
|
+
import type { BaseDocument } from "../../../_internal/shared/types/base-document";
|
|
6
7
|
export interface FAQSEO {
|
|
7
8
|
slug: string;
|
|
8
9
|
metaTitle?: string;
|
|
9
10
|
metaDescription?: string;
|
|
10
11
|
}
|
|
11
|
-
export interface FAQDocument {
|
|
12
|
-
id: string;
|
|
12
|
+
export interface FAQDocument extends BaseDocument {
|
|
13
13
|
question: string;
|
|
14
14
|
answer: FAQAnswer;
|
|
15
15
|
category: FAQCategory;
|
|
@@ -29,8 +29,6 @@ export interface FAQDocument {
|
|
|
29
29
|
seo: FAQSEO;
|
|
30
30
|
isActive: boolean;
|
|
31
31
|
createdBy: string;
|
|
32
|
-
createdAt: Date;
|
|
33
|
-
updatedAt: Date;
|
|
34
32
|
}
|
|
35
33
|
export declare const FAQS_COLLECTION: "faqs";
|
|
36
34
|
export declare const FAQS_INDEXED_FIELDS: readonly ["slug", "seo.slug", "category", "order", "showOnHomepage", "showInFooter", "isPinned", "priority", "tags", "searchTokens", "isActive", "stats.helpful", "createdBy", "createdAt"];
|
|
@@ -278,8 +278,8 @@ export declare const faqFirestoreSchema: z.ZodObject<{
|
|
|
278
278
|
createdAt: string | Date | z.objectOutputType<{
|
|
279
279
|
toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
|
|
280
280
|
}, z.ZodTypeAny, "passthrough">;
|
|
281
|
-
id: string;
|
|
282
281
|
tags: string[];
|
|
282
|
+
id: string;
|
|
283
283
|
updatedAt: string | Date | z.objectOutputType<{
|
|
284
284
|
toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
|
|
285
285
|
}, z.ZodTypeAny, "passthrough">;
|
|
@@ -317,8 +317,8 @@ export declare const faqFirestoreSchema: z.ZodObject<{
|
|
|
317
317
|
createdAt: string | Date | z.objectInputType<{
|
|
318
318
|
toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
|
|
319
319
|
}, z.ZodTypeAny, "passthrough">;
|
|
320
|
-
id: string;
|
|
321
320
|
tags: string[];
|
|
321
|
+
id: string;
|
|
322
322
|
updatedAt: string | Date | z.objectInputType<{
|
|
323
323
|
toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
|
|
324
324
|
}, z.ZodTypeAny, "passthrough">;
|
|
@@ -37,9 +37,9 @@ export declare const groupedListingFirestoreSchema: z.ZodObject<{
|
|
|
37
37
|
createdAt: string | Date | z.objectOutputType<{
|
|
38
38
|
toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
|
|
39
39
|
}, z.ZodTypeAny, "passthrough">;
|
|
40
|
-
id: string;
|
|
41
40
|
title: string;
|
|
42
41
|
slug: string;
|
|
42
|
+
id: string;
|
|
43
43
|
updatedAt: string | Date | z.objectOutputType<{
|
|
44
44
|
toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
|
|
45
45
|
}, z.ZodTypeAny, "passthrough">;
|
|
@@ -60,9 +60,9 @@ export declare const groupedListingFirestoreSchema: z.ZodObject<{
|
|
|
60
60
|
createdAt: string | Date | z.objectInputType<{
|
|
61
61
|
toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
|
|
62
62
|
}, z.ZodTypeAny, "passthrough">;
|
|
63
|
-
id: string;
|
|
64
63
|
title: string;
|
|
65
64
|
slug: string;
|
|
65
|
+
id: string;
|
|
66
66
|
updatedAt: string | Date | z.objectInputType<{
|
|
67
67
|
toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
|
|
68
68
|
}, z.ZodTypeAny, "passthrough">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|