@mohasinac/appkit 4.13.1 → 4.15.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/layout/DashboardLayoutClient.js +14 -5
- package/dist/_internal/client/features/lottery/LotteryAdminEditView.d.ts +3 -0
- package/dist/_internal/client/features/lottery/LotteryAdminEditView.js +6 -0
- package/dist/_internal/client/features/lottery/LotteryDetailView.d.ts +8 -0
- package/dist/_internal/client/features/lottery/LotteryDetailView.js +4 -1
- package/dist/_internal/client/features/lottery/LotteryListView.d.ts +7 -0
- package/dist/_internal/client/features/lottery/LotteryListView.js +1 -1
- package/dist/_internal/client/features/lottery/PrizeDrawLotteryDetailView.js +4 -1
- package/dist/_internal/client/features/lottery/slot-collage-items.d.ts +15 -0
- package/dist/_internal/client/features/lottery/slot-collage-items.js +13 -0
- package/dist/_internal/server/features/auctions/actions.js +8 -2
- package/dist/_internal/server/features/bundles/data.d.ts +16 -0
- package/dist/_internal/server/features/bundles/data.js +26 -0
- package/dist/_internal/server/features/bundles/index.d.ts +1 -1
- package/dist/_internal/server/features/bundles/index.js +1 -1
- package/dist/_internal/server/features/cart/service.d.ts +3 -3
- package/dist/_internal/server/features/checkout/actions.js +25 -0
- package/dist/_internal/server/features/checkout/locked-lines.d.ts +38 -0
- package/dist/_internal/server/features/checkout/locked-lines.js +171 -0
- package/dist/_internal/server/features/checkout/source-context.d.ts +5 -0
- package/dist/_internal/server/features/checkout/source-context.js +157 -0
- package/dist/_internal/server/features/homepage/index.d.ts +0 -1
- package/dist/_internal/server/features/homepage/index.js +7 -1
- package/dist/_internal/server/features/lottery/adapters.js +4 -0
- package/dist/_internal/server/features/offers/adapters.d.ts +103 -0
- package/dist/_internal/server/features/offers/adapters.js +88 -0
- package/dist/_internal/server/features/offers/index.d.ts +2 -0
- package/dist/_internal/server/features/offers/index.js +1 -0
- package/dist/_internal/server/features/orders/adapters.js +24 -0
- package/dist/_internal/server/features/products/data.js +15 -37
- package/dist/_internal/server/features/products/index.d.ts +1 -1
- package/dist/_internal/server/features/products/index.js +1 -1
- package/dist/_internal/server/features/products/list-public.d.ts +46 -20
- package/dist/_internal/server/features/products/list-public.js +266 -90
- package/dist/_internal/server/features/products/listing-tab-counts.d.ts +44 -0
- package/dist/_internal/server/features/products/listing-tab-counts.js +97 -0
- package/dist/_internal/server/features/site-settings/adapters.d.ts +51 -0
- package/dist/_internal/server/features/site-settings/adapters.js +75 -0
- package/dist/_internal/server/features/site-settings/index.d.ts +1 -0
- package/dist/_internal/server/features/site-settings/index.js +1 -0
- package/dist/_internal/server/features/stores/adapters.d.ts +56 -0
- package/dist/_internal/server/features/stores/adapters.js +91 -0
- package/dist/_internal/server/features/stores/index.d.ts +1 -0
- package/dist/_internal/server/features/stores/index.js +1 -0
- package/dist/_internal/server/jobs/core/auctionSettlement.js +56 -2
- package/dist/_internal/server/jobs/core/offerExpiry.js +55 -19
- package/dist/_internal/server/jobs/core/paymentReviewAutoApprove.d.ts +5 -0
- package/dist/_internal/server/jobs/core/paymentReviewAutoApprove.js +33 -1
- package/dist/_internal/server/jobs/handlers/messages.d.ts +7 -0
- package/dist/_internal/server/jobs/handlers/messages.js +10 -0
- package/dist/_internal/shared/actions/action-registry.js +17 -1
- package/dist/_internal/shared/checkout/lanes.d.ts +25 -0
- package/dist/_internal/shared/checkout/lanes.js +26 -0
- package/dist/_internal/shared/features/auctions/config.d.ts +27 -0
- package/dist/_internal/shared/features/auctions/config.js +27 -0
- package/dist/_internal/shared/features/auctions/schema.d.ts +14 -2
- package/dist/_internal/shared/features/auctions/schema.js +13 -1
- package/dist/_internal/shared/features/blog/schema.d.ts +2 -2
- package/dist/_internal/shared/features/cart/schema.d.ts +20 -15
- package/dist/_internal/shared/features/cart/schema.js +15 -0
- package/dist/_internal/shared/features/categories/bundle-schemas.d.ts +32 -32
- package/dist/_internal/shared/features/emi/schedule.d.ts +24 -3
- package/dist/_internal/shared/features/emi/schedule.js +20 -5
- package/dist/_internal/shared/features/events/schema.d.ts +2 -2
- package/dist/_internal/shared/features/homepage/section-gate.d.ts +14 -0
- package/dist/_internal/shared/features/homepage/section-gate.js +51 -0
- package/dist/_internal/shared/features/offers/config.d.ts +30 -0
- package/dist/_internal/shared/features/offers/config.js +59 -0
- package/dist/_internal/shared/features/orders/schema.d.ts +8 -8
- package/dist/_internal/shared/features/products/schema.d.ts +30 -30
- package/dist/_internal/shared/features/products/to-product-item.js +6 -0
- package/dist/_internal/shared/features/reviews/schema.d.ts +2 -2
- package/dist/_internal/shared/features/site-settings/fees.d.ts +60 -0
- package/dist/_internal/shared/features/site-settings/fees.js +39 -0
- package/dist/_internal/shared/features/site-settings/types.d.ts +40 -0
- package/dist/_internal/shared/features/site-settings/types.js +1 -0
- package/dist/_internal/shared/history/history.d.ts +88 -0
- package/dist/_internal/shared/history/history.js +198 -0
- package/dist/_internal/shared/history/index.d.ts +4 -0
- package/dist/_internal/shared/history/index.js +2 -0
- package/dist/_internal/shared/history/types.d.ts +61 -0
- package/dist/_internal/shared/history/types.js +6 -0
- package/dist/_internal/shared/listing-types/_registry.d.ts +54 -1
- package/dist/_internal/shared/listing-types/_registry.js +67 -0
- package/dist/_internal/shared/listing-types/art/config.d.ts +3 -0
- package/dist/_internal/shared/listing-types/art/config.js +5 -0
- package/dist/_internal/shared/listing-types/auction/config.d.ts +13 -0
- package/dist/_internal/shared/listing-types/auction/config.js +21 -0
- package/dist/_internal/shared/listing-types/availability.d.ts +79 -0
- package/dist/_internal/shared/listing-types/availability.js +104 -0
- package/dist/_internal/shared/listing-types/capabilities.d.ts +15 -0
- package/dist/_internal/shared/listing-types/capabilities.js +12 -0
- package/dist/_internal/shared/listing-types/classified/config.d.ts +3 -0
- package/dist/_internal/shared/listing-types/classified/config.js +5 -0
- package/dist/_internal/shared/listing-types/digital-code/config.d.ts +11 -0
- package/dist/_internal/shared/listing-types/digital-code/config.js +22 -2
- package/dist/_internal/shared/listing-types/live/config.d.ts +3 -0
- package/dist/_internal/shared/listing-types/live/config.js +5 -0
- package/dist/_internal/shared/listing-types/pre-order/config.d.ts +3 -0
- package/dist/_internal/shared/listing-types/pre-order/config.js +19 -0
- package/dist/_internal/shared/listing-types/prize-draw/config.d.ts +11 -0
- package/dist/_internal/shared/listing-types/prize-draw/config.js +15 -0
- package/dist/_internal/shared/listing-types/standard/config.d.ts +3 -0
- package/dist/_internal/shared/listing-types/standard/config.js +5 -0
- package/dist/_internal/shared/listing-types/stickers/config.d.ts +3 -0
- package/dist/_internal/shared/listing-types/stickers/config.js +5 -0
- package/dist/client.d.ts +20 -7
- package/dist/client.js +22 -4
- package/dist/constants/api-endpoints.d.ts +6 -0
- package/dist/constants/api-endpoints.js +2 -0
- package/dist/constants/field-names.d.ts +57 -8
- package/dist/constants/field-names.js +101 -8
- package/dist/constants/table-keys.d.ts +17 -0
- package/dist/constants/table-keys.js +17 -0
- package/dist/errors/error-codes.d.ts +13 -1
- package/dist/errors/error-codes.js +13 -1
- package/dist/errors/error-display-map.js +12 -3
- package/dist/errors/messages.d.ts +10 -2
- package/dist/errors/messages.js +10 -2
- package/dist/features/about/components/AboutView.d.ts +3 -0
- package/dist/features/about/components/AboutView.js +3 -2
- package/dist/features/about/components/PolicyPageView.d.ts +2 -1
- package/dist/features/about/components/PolicyPageView.js +61 -23
- package/dist/features/about/components/PublicProfileView.js +5 -0
- package/dist/features/about/schemas/firestore.d.ts +3 -0
- package/dist/features/account/components/UserBidsView.js +12 -4
- package/dist/features/account/components/UserOrdersView.js +7 -0
- package/dist/features/account/components/UserReturnsView.d.ts +3 -0
- package/dist/features/account/components/UserReturnsView.js +17 -1
- package/dist/features/account/components/index.d.ts +0 -2
- package/dist/features/account/components/index.js +0 -1
- package/dist/features/account/schemas/index.d.ts +2 -2
- package/dist/features/account/types/index.d.ts +21 -2
- package/dist/features/addresses/schemas/index.d.ts +4 -4
- package/dist/features/admin/components/AdminArtView.js +8 -3
- package/dist/features/admin/components/AdminAuditLogView.js +1 -0
- package/dist/features/admin/components/AdminBidsView.js +15 -2
- package/dist/features/admin/components/AdminBlogEditorView.js +65 -33
- package/dist/features/admin/components/AdminClassifiedView.js +8 -3
- package/dist/features/admin/components/AdminDigitalCodesView.js +8 -3
- package/dist/features/admin/components/AdminFeatureEditorView.js +35 -6
- package/dist/features/admin/components/AdminFeatureFlagsView.js +1 -0
- package/dist/features/admin/components/AdminLiveView.js +8 -3
- package/dist/features/admin/components/AdminNavEditorView.js +15 -5
- package/dist/features/admin/components/AdminNewsletterView.js +18 -2
- package/dist/features/admin/components/AdminOffersView.d.ts +4 -0
- package/dist/features/admin/components/AdminOffersView.js +230 -0
- package/dist/features/admin/components/AdminOrdersView.js +10 -1
- package/dist/features/admin/components/AdminPaymentMethodsView.js +24 -4
- package/dist/features/admin/components/AdminPrizeDrawsView.js +5 -0
- package/dist/features/admin/components/AdminProductsView.js +16 -29
- package/dist/features/admin/components/AdminScammerEditorView.d.ts +2 -1
- package/dist/features/admin/components/AdminScammerEditorView.js +3 -13
- package/dist/features/admin/components/AdminScammersView.js +3 -8
- package/dist/features/admin/components/AdminSectionsView.js +32 -23
- package/dist/features/admin/components/AdminSessionsView.js +17 -2
- package/dist/features/admin/components/AdminSiteSettingsView.js +31 -13
- package/dist/features/admin/components/AdminSiteView.js +6 -2
- package/dist/features/admin/components/AdminStickersView.js +8 -3
- package/dist/features/admin/components/ViewAuditLogEntryModal.js +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/components/sections/adminSectionsTypes.d.ts +4 -2
- package/dist/features/admin/components/sections/adminSectionsTypes.js +45 -27
- package/dist/features/admin/constants/filter-tabs.d.ts +89 -0
- package/dist/features/admin/constants/filter-tabs.js +56 -0
- package/dist/features/admin/schemas/firestore.d.ts +122 -3
- package/dist/features/admin/schemas/firestore.js +1 -0
- package/dist/features/admin/schemas/homepage-section-form.d.ts +22 -0
- package/dist/features/admin/schemas/homepage-section-form.js +68 -0
- package/dist/features/admin/schemas/nav-item-form.d.ts +74 -0
- package/dist/features/admin/schemas/nav-item-form.js +72 -0
- package/dist/features/auctions/actions/bid-actions.d.ts +20 -5
- package/dist/features/auctions/actions/bid-actions.js +93 -20
- package/dist/features/auctions/components/AuctionBidsTable.d.ts +10 -1
- package/dist/features/auctions/components/AuctionBidsTable.js +22 -4
- package/dist/features/auctions/components/AuctionDetailPageView.js +11 -6
- package/dist/features/auctions/components/AuctionsListView.js +5 -6
- package/dist/features/auctions/components/MarketplaceAuctionCard.d.ts +7 -0
- package/dist/features/auctions/components/MarketplaceAuctionCard.js +19 -2
- package/dist/features/auctions/components/PlaceBidFormClient.d.ts +1 -2
- package/dist/features/auctions/components/PlaceBidFormClient.js +8 -4
- package/dist/features/auctions/components/bid-detail-fields.d.ts +29 -0
- package/dist/features/auctions/components/bid-detail-fields.js +103 -0
- package/dist/features/auctions/repository/bid.repository.d.ts +13 -0
- package/dist/features/auctions/repository/bid.repository.js +23 -0
- package/dist/features/auctions/schemas/firestore.d.ts +17 -0
- package/dist/features/auctions/schemas/index.d.ts +12 -12
- package/dist/features/audit-log/schemas/firestore.d.ts +14 -0
- package/dist/features/audit-log/schemas/firestore.js +7 -0
- package/dist/features/auth/permissions/constants.d.ts +1 -1
- package/dist/features/auth/permissions/constants.js +10 -1
- package/dist/features/blog/actions/blog-actions.d.ts +7 -7
- package/dist/features/blog/schemas/blog-form.d.ts +80 -0
- package/dist/features/blog/schemas/blog-form.js +100 -0
- package/dist/features/blog/schemas/index.d.ts +6 -6
- package/dist/features/cart/repository/cart.repository.js +1 -0
- package/dist/features/cart/schemas/firestore.d.ts +15 -0
- package/dist/features/catalogue/schemas/validation.d.ts +4 -4
- package/dist/features/categories/components/BrandDetailPageView.js +23 -40
- package/dist/features/categories/components/BrandDetailTabs.d.ts +7 -7
- package/dist/features/categories/components/BrandDetailTabs.js +8 -12
- package/dist/features/categories/components/BundleCollage.js +1 -1
- package/dist/features/categories/components/CategoryDetailPageView.js +53 -57
- package/dist/features/categories/components/CategoryDetailTabs.d.ts +10 -8
- package/dist/features/categories/components/CategoryDetailTabs.js +11 -16
- package/dist/features/categories/components/CategoryProductsListing.js +11 -1
- package/dist/features/categories/components/ConcernCard.js +7 -1
- package/dist/features/categories/schemas/firestore.d.ts +13 -0
- package/dist/features/categories/schemas/index.d.ts +26 -26
- package/dist/features/classified/components/ClassifiedDetailPageView.d.ts +16 -1
- package/dist/features/classified/components/ClassifiedDetailPageView.js +23 -3
- package/dist/features/events/components/AdminEventEditorView.js +32 -54
- package/dist/features/events/components/AdminEventEntriesView.js +22 -3
- package/dist/features/events/components/AdminEventsView.js +15 -11
- package/dist/features/events/components/EventFilters.d.ts +9 -1
- package/dist/features/events/components/EventFilters.js +45 -21
- package/dist/features/events/components/EventsIndexListing.d.ts +6 -1
- package/dist/features/events/components/EventsIndexListing.js +2 -2
- package/dist/features/events/components/EventsListPageView.js +13 -4
- package/dist/features/events/repository/events.repository.d.ts +17 -0
- package/dist/features/events/repository/events.repository.js +27 -0
- package/dist/features/events/schemas/event-form.d.ts +113 -0
- package/dist/features/events/schemas/event-form.js +82 -0
- package/dist/features/events/schemas/firestore.d.ts +12 -0
- package/dist/features/events/schemas/firestore.js +12 -0
- package/dist/features/events/schemas/index.d.ts +50 -50
- package/dist/features/events/types/index.d.ts +11 -0
- package/dist/features/events/types/index.js +57 -1
- package/dist/features/faq/actions/faq-actions.d.ts +12 -12
- package/dist/features/faq/schemas/index.d.ts +8 -8
- package/dist/features/filters/FilterFacetSection.d.ts +7 -1
- package/dist/features/filters/FilterFacetSection.js +11 -3
- package/dist/features/grouped/schemas/grouped-listing-form.d.ts +101 -0
- package/dist/features/grouped/schemas/grouped-listing-form.js +89 -0
- package/dist/features/grouped/schemas/index.d.ts +4 -4
- package/dist/features/homepage/actions/homepage-section-actions.d.ts +11 -3
- package/dist/features/homepage/actions/homepage-section-actions.js +33 -1
- package/dist/features/homepage/components/AnnouncementBar.d.ts +7 -1
- package/dist/features/homepage/components/AnnouncementBar.js +3 -3
- package/dist/features/homepage/components/MarketplaceHomepageView.js +20 -6
- package/dist/features/homepage/hooks/homepage-query.d.ts +16 -0
- package/dist/features/homepage/hooks/homepage-query.js +45 -0
- package/dist/features/homepage/hooks/useFeaturedAuctions.d.ts +10 -0
- package/dist/features/homepage/hooks/useFeaturedAuctions.js +28 -8
- package/dist/features/homepage/hooks/useFeaturedPreOrders.js +17 -8
- package/dist/features/homepage/hooks/useFeaturedProducts.js +15 -8
- package/dist/features/homepage/schemas/index.d.ts +33 -2
- package/dist/features/homepage/schemas/index.js +24 -0
- package/dist/features/layout/AppLayoutShell.d.ts +11 -1
- package/dist/features/layout/AppLayoutShell.js +15 -14
- package/dist/features/layout/BackToTop.d.ts +9 -0
- package/dist/features/layout/BackToTop.js +10 -1
- package/dist/features/layout/BottomActions.js +28 -25
- package/dist/features/layout/BottomChrome.d.ts +34 -0
- package/dist/features/layout/BottomChrome.js +55 -0
- package/dist/features/layout/BottomNavLayout.d.ts +6 -0
- package/dist/features/layout/BottomNavLayout.js +7 -1
- package/dist/features/layout/BottomNavbar.js +15 -2
- package/dist/features/layout/FooterLayout.js +11 -1
- package/dist/features/layout/NavbarLayout.js +1 -1
- package/dist/features/layout/TitleBarLayout.d.ts +7 -0
- package/dist/features/layout/TitleBarLayout.js +28 -5
- package/dist/features/layout/index.d.ts +2 -0
- package/dist/features/layout/index.js +1 -0
- package/dist/features/lottery/types/index.d.ts +3 -0
- package/dist/features/media/MediaPickerModal.js +5 -1
- package/dist/features/messages/schemas/index.d.ts +2 -2
- package/dist/features/orders/components/OrderScopeTabs.d.ts +20 -0
- package/dist/features/orders/components/OrderScopeTabs.js +31 -0
- package/dist/features/orders/components/OrderStatusTimeline.d.ts +5 -1
- package/dist/features/orders/components/OrderStatusTimeline.js +39 -20
- package/dist/features/orders/constants/order-scope.d.ts +48 -0
- package/dist/features/orders/constants/order-scope.js +111 -0
- package/dist/features/orders/repository/orders.repository.d.ts +54 -7
- package/dist/features/orders/repository/orders.repository.js +121 -22
- package/dist/features/orders/schemas/firestore.d.ts +152 -0
- package/dist/features/orders/schemas/firestore.js +30 -0
- package/dist/features/orders/schemas/index.d.ts +18 -18
- package/dist/features/orders/types/index.d.ts +35 -7
- package/dist/features/pre-orders/components/PreOrdersIndexListing.js +14 -9
- package/dist/features/pre-orders/components/PreOrdersListView.js +6 -5
- package/dist/features/pre-orders/schemas/index.d.ts +1 -1
- package/dist/features/products/actions/product-actions.d.ts +14 -0
- package/dist/features/products/actions/product-actions.js +49 -11
- package/dist/features/products/api/route.d.ts +12 -0
- package/dist/features/products/api/route.js +42 -100
- package/dist/features/products/components/ArtStickersListView.js +2 -2
- package/dist/features/products/components/AuctionsIndexListing.js +13 -11
- package/dist/features/products/components/AvailabilityTabs.d.ts +11 -0
- package/dist/features/products/components/AvailabilityTabs.js +47 -0
- package/dist/features/products/components/GroupSettingsPanel.js +5 -1
- package/dist/features/products/components/MakeOfferButton.js +48 -49
- package/dist/features/products/components/PrizeDrawCollage.d.ts +20 -4
- package/dist/features/products/components/PrizeDrawCollage.js +9 -1
- package/dist/features/products/components/PrizeDrawsIndexListing.js +14 -12
- package/dist/features/products/components/PrizeDrawsListingView.js +2 -2
- package/dist/features/products/components/PrizeDrawsSection.d.ts +7 -1
- package/dist/features/products/components/PrizeDrawsSection.js +23 -18
- package/dist/features/products/components/ProductDetailPageView.d.ts +4 -1
- package/dist/features/products/components/ProductDetailPageView.js +18 -4
- package/dist/features/products/components/ProductForm.js +5 -2
- package/dist/features/products/components/ProductGrid.js +6 -1
- package/dist/features/products/components/ProductsIndexListing.js +22 -32
- package/dist/features/products/components/ProductsIndexPageView.js +6 -9
- package/dist/features/products/components/index.d.ts +2 -2
- package/dist/features/products/components/index.js +1 -1
- package/dist/features/products/config/listing-type-listing-config.d.ts +20 -0
- package/dist/features/products/config/listing-type-listing-config.js +22 -10
- package/dist/features/products/constants/action-defs.d.ts +2 -0
- package/dist/features/products/constants/action-defs.js +6 -0
- package/dist/features/products/hooks/useAvailabilityScope.d.ts +13 -0
- package/dist/features/products/hooks/useAvailabilityScope.js +19 -0
- package/dist/features/products/hooks/useProducts.d.ts +5 -0
- package/dist/features/products/hooks/useProducts.js +13 -2
- package/dist/features/products/repository/products.repository.d.ts +31 -2
- package/dist/features/products/repository/products.repository.js +53 -21
- package/dist/features/products/schemas/firestore.d.ts +17 -3
- package/dist/features/products/schemas/firestore.js +7 -2
- package/dist/features/products/schemas/index.d.ts +64 -64
- package/dist/features/products/schemas/product-features.validators.d.ts +79 -6
- package/dist/features/products/schemas/product-features.validators.js +63 -0
- package/dist/features/products/types/index.d.ts +16 -1
- package/dist/features/promotions/schemas/index.d.ts +2 -2
- package/dist/features/reviews/schemas/index.d.ts +16 -16
- package/dist/features/scams/constants/scammer-status-display.d.ts +28 -0
- package/dist/features/scams/constants/scammer-status-display.js +79 -0
- package/dist/features/search/schemas/index.d.ts +4 -4
- package/dist/features/seller/actions/offer-actions.js +57 -4
- package/dist/features/seller/components/OfferPhaseTimeline.d.ts +59 -0
- package/dist/features/seller/components/OfferPhaseTimeline.js +107 -0
- package/dist/features/seller/components/SellerArtView.js +5 -0
- package/dist/features/seller/components/SellerAuctionsView.js +13 -15
- package/dist/features/seller/components/SellerBidsView.js +11 -4
- package/dist/features/seller/components/SellerClassifiedView.js +5 -0
- package/dist/features/seller/components/SellerCouponEditorView.js +17 -17
- package/dist/features/seller/components/SellerDigitalCodesView.js +5 -0
- package/dist/features/seller/components/SellerLiveView.js +5 -0
- package/dist/features/seller/components/SellerOffersView.js +2 -1
- package/dist/features/seller/components/SellerOrdersView.js +31 -9
- package/dist/features/seller/components/SellerPayoutSettingsView.js +56 -31
- package/dist/features/seller/components/SellerPreOrdersView.js +5 -0
- package/dist/features/seller/components/SellerPrizeDrawsView.js +14 -16
- package/dist/features/seller/components/SellerProductShell.js +7 -1
- package/dist/features/seller/components/SellerProductsView.js +11 -8
- package/dist/features/seller/components/SellerStickersView.js +5 -0
- package/dist/features/seller/components/index.d.ts +0 -2
- package/dist/features/seller/components/index.js +0 -1
- package/dist/features/seller/repository/offer.repository.d.ts +142 -24
- package/dist/features/seller/repository/offer.repository.js +165 -26
- package/dist/features/seller/schemas/coupon-form.d.ts +72 -0
- package/dist/features/seller/schemas/coupon-form.js +116 -0
- package/dist/features/seller/schemas/firestore.d.ts +56 -2
- package/dist/features/seller/schemas/firestore.js +27 -0
- package/dist/features/seller/schemas/index.d.ts +2 -2
- package/dist/features/seller/schemas/offer-forms.d.ts +46 -0
- package/dist/features/seller/schemas/offer-forms.js +42 -0
- package/dist/features/seller/server.d.ts +0 -1
- package/dist/features/seller/server.js +0 -1
- package/dist/features/shell/SectionForm.d.ts +99 -0
- package/dist/features/shell/SectionForm.js +128 -0
- package/dist/features/shell/build-sections.d.ts +63 -0
- package/dist/features/shell/build-sections.js +207 -0
- package/dist/features/shell/entity-form.d.ts +109 -0
- package/dist/features/shell/entity-form.js +96 -0
- package/dist/features/shell/field-ui-meta.d.ts +115 -0
- package/dist/features/shell/field-ui-meta.js +324 -0
- package/dist/features/shell/index.d.ts +8 -0
- package/dist/features/shell/index.js +4 -0
- package/dist/features/status-history/components/StatusTimeline.d.ts +74 -0
- package/dist/features/status-history/components/StatusTimeline.js +46 -0
- package/dist/features/status-history/index.d.ts +11 -0
- package/dist/features/status-history/index.js +10 -0
- package/dist/features/store-extensions/components/ReviewDecisionModal.d.ts +27 -0
- package/dist/features/store-extensions/components/ReviewDecisionModal.js +82 -0
- package/dist/features/store-extensions/index.d.ts +12 -0
- package/dist/features/store-extensions/index.js +12 -0
- package/dist/features/store-extensions/schemas/admin-notification-form.d.ts +36 -0
- package/dist/features/store-extensions/schemas/admin-notification-form.js +114 -0
- package/dist/features/store-extensions/schemas/analytics-forms.d.ts +57 -0
- package/dist/features/store-extensions/schemas/analytics-forms.js +158 -0
- package/dist/features/store-extensions/schemas/custom-role-form.d.ts +85 -0
- package/dist/features/store-extensions/schemas/custom-role-form.js +118 -0
- package/dist/features/store-extensions/schemas/firestore.d.ts +21 -1
- package/dist/features/store-extensions/schemas/firestore.js +60 -0
- package/dist/features/store-extensions/schemas/google-config-form.d.ts +53 -0
- package/dist/features/store-extensions/schemas/google-config-form.js +105 -0
- package/dist/features/store-extensions/schemas/item-request-create-form.d.ts +28 -0
- package/dist/features/store-extensions/schemas/item-request-create-form.js +80 -0
- package/dist/features/store-extensions/schemas/listing-template-form.d.ts +78 -0
- package/dist/features/store-extensions/schemas/listing-template-form.js +87 -0
- package/dist/features/store-extensions/schemas/moderation-review-form.d.ts +49 -0
- package/dist/features/store-extensions/schemas/moderation-review-form.js +101 -0
- package/dist/features/store-extensions/schemas/payout-method-form.d.ts +153 -0
- package/dist/features/store-extensions/schemas/payout-method-form.js +155 -0
- package/dist/features/store-extensions/schemas/report-create-form.d.ts +25 -0
- package/dist/features/store-extensions/schemas/report-create-form.js +79 -0
- package/dist/features/store-extensions/schemas/report-review-form.d.ts +47 -0
- package/dist/features/store-extensions/schemas/report-review-form.js +111 -0
- package/dist/features/store-extensions/schemas/shipping-config-form.d.ts +148 -0
- package/dist/features/store-extensions/schemas/shipping-config-form.js +104 -0
- package/dist/features/store-extensions/schemas/store-category-form.d.ts +54 -0
- package/dist/features/store-extensions/schemas/store-category-form.js +73 -0
- package/dist/features/stores/api/[storeSlug]/route.js +2 -25
- package/dist/features/stores/components/StoreAuctionsListing.js +15 -1
- package/dist/features/stores/components/StoreClassifiedsListing.js +12 -2
- package/dist/features/stores/components/StoreDetailLayoutView.js +24 -71
- package/dist/features/stores/components/StoreDigitalCodesListing.js +12 -2
- package/dist/features/stores/components/StoreLiveItemsListing.js +12 -2
- package/dist/features/stores/components/StorePreOrdersListing.js +12 -1
- package/dist/features/stores/components/StoreProductsListing.js +11 -1
- package/dist/features/stores/repository/store.repository.js +6 -0
- package/dist/features/stores/schemas/index.d.ts +6 -6
- package/dist/features/support/schemas/index.d.ts +4 -4
- package/dist/features/tester/actions/checklist-item-actions.d.ts +4 -4
- package/dist/features/tester/seed-data/offers-tester-seed-data.js +119 -3
- package/dist/features/tester/seed-data/products-tester-seed-data.js +131 -1
- package/dist/features/tester/seed-data/tester-checklist-seed-data.js +431 -1
- package/dist/features/wishlist/hooks/useWishlistWithGuest.d.ts +1 -1
- package/dist/index.d.ts +25 -12
- package/dist/index.js +26 -11
- package/dist/next/routing/route-map.d.ts +23 -3
- package/dist/next/routing/route-map.js +14 -2
- package/dist/providers/db-firebase/base.repository.d.ts +30 -0
- package/dist/providers/db-firebase/base.repository.js +50 -1
- package/dist/providers/db-firebase/index.d.ts +1 -1
- package/dist/providers/db-firebase/index.js +1 -1
- package/dist/providers/db-firebase/sieve.d.ts +25 -0
- package/dist/providers/db-firebase/sieve.js +52 -18
- package/dist/react/hooks/useUrlTable.js +10 -1
- package/dist/schemas/firestore-value.d.ts +8 -0
- package/dist/schemas/firestore-value.js +44 -0
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/index.js +1 -1
- package/dist/schemas/registry.d.ts +702 -69
- package/dist/schemas/registry.js +64 -1
- package/dist/seed/_helpers/category-forest.d.ts +2 -0
- package/dist/seed/_helpers/category-forest.js +309 -0
- package/dist/seed/_helpers/category-tree.d.ts +27 -0
- package/dist/seed/_helpers/category-tree.js +103 -0
- package/dist/seed/bids-seed-data.js +30 -0
- package/dist/seed/catalogue-seed-data.js +12 -12
- package/dist/seed/categories-seed-data.js +177 -162
- package/dist/seed/events-seed-data.js +61 -10
- package/dist/seed/homepage-sections-seed-data.js +5 -1
- package/dist/seed/offers-seed-data.js +244 -34
- package/dist/seed/orders-seed-data.js +336 -1
- package/dist/seed/products-art-seed-data.js +50 -12
- package/dist/seed/products-auctions-seed-data.js +138 -18
- package/dist/seed/products-classifieds-seed-data.js +80 -16
- package/dist/seed/products-digital-codes-seed-data.js +66 -18
- package/dist/seed/products-live-items-seed-data.js +64 -13
- package/dist/seed/products-preorders-seed-data.d.ts +0 -1
- package/dist/seed/products-preorders-seed-data.js +52 -13
- package/dist/seed/products-prize-draws-seed-data.js +63 -14
- package/dist/seed/products-standard-seed-data.js +99 -26
- package/dist/seed/products-stickers-seed-data.js +47 -12
- package/dist/seed/reviews-seed-data.js +6 -1
- package/dist/seed/site-settings-seed-data.d.ts +1 -38
- package/dist/seed/site-settings-seed-data.js +38 -76
- package/dist/seed/stores-seed-data.js +71 -1
- package/dist/seed/users-seed-data.js +15 -5
- package/dist/server-entry.d.ts +1 -2
- package/dist/server-entry.js +4 -3
- package/dist/server.d.ts +6 -3
- package/dist/server.js +13 -4
- package/dist/styles.css +78 -12
- package/dist/tailwind-utilities.css +1 -1
- package/dist/ui/components/Button.style.css +19 -4
- package/dist/ui/components/CollapsibleSection.d.ts +17 -1
- package/dist/ui/components/CollapsibleSection.js +6 -2
- package/dist/ui/components/FilterChipGroup.d.ts +25 -1
- package/dist/ui/components/FilterChipGroup.js +21 -4
- package/dist/ui/components/HandMode.style.css +47 -0
- package/dist/ui/components/Layout.d.ts +9 -2
- package/dist/ui/components/Layout.js +1 -1
- package/dist/ui/components/ListingLayout.js +8 -8
- package/dist/ui/components/ListingLayout.style.css +8 -7
- package/dist/ui/components/RecordDetailModal.d.ts +10 -1
- package/dist/ui/components/RecordDetailModal.js +2 -2
- package/dist/ui/components/StickyToolbar.d.ts +3 -1
- package/dist/ui/components/StickyToolbar.js +62 -20
- package/dist/ui/components/bottom-chrome-slot.d.ts +21 -0
- package/dist/ui/components/bottom-chrome-slot.js +29 -0
- package/dist/ui/components/index.style.css +3 -0
- package/dist/ui/forms/FormShell.d.ts +43 -13
- package/dist/ui/forms/FormShell.js +22 -11
- package/dist/ui/forms/index.d.ts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/package.json +2 -1
- package/scripts/node-esm-loader.mjs +65 -0
- package/scripts/seed-cli-loader.mjs +6 -49
- package/scripts/seed-cli.mjs +1 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
/*
|
|
4
|
+
* WHY: A `SectionDef[]` written by hand is a second source of truth that has to
|
|
5
|
+
* stay aligned with the schema that validates it. Nothing enforces the
|
|
6
|
+
* alignment, so a field added to the schema renders nowhere, and a field
|
|
7
|
+
* removed from the schema keeps rendering into a key that is stripped on
|
|
8
|
+
* save. `audit-form-field-roundtrip` exists to catch exactly that — this
|
|
9
|
+
* file removes the opportunity instead.
|
|
10
|
+
* WHAT: `buildSectionsFromSchema` — walk a schema's shape, group by
|
|
11
|
+
* `FieldUiMeta.section`, pack consecutive fields into `<FormGroup>` rows
|
|
12
|
+
* by their `row` span, and pick each control from its `kind`.
|
|
13
|
+
*
|
|
14
|
+
* Sections become DERIVED, exactly as quick mode already is. Adding a field to
|
|
15
|
+
* the schema puts it in the right section, in the right row, in the right mode,
|
|
16
|
+
* with one edit rather than three.
|
|
17
|
+
*
|
|
18
|
+
* ## The escape hatch is per field, not per form
|
|
19
|
+
*
|
|
20
|
+
* `renderers` overrides a single field's JSX while everything around it stays
|
|
21
|
+
* derived. That matters: a form with one bespoke control should not have to
|
|
22
|
+
* hand-write its other twelve fields, which is what an all-or-nothing escape
|
|
23
|
+
* hatch would force and is how hand-written section arrays got normalised in
|
|
24
|
+
* the first place.
|
|
25
|
+
*
|
|
26
|
+
* EXPORTS:
|
|
27
|
+
* buildSectionsFromSchema, groupFieldsBySection, packRows,
|
|
28
|
+
* type FieldRenderer, type BuildSectionsOptions
|
|
29
|
+
*
|
|
30
|
+
* @tag domain:forms
|
|
31
|
+
* @tag layer:shared
|
|
32
|
+
* @tag pattern:slot-shell
|
|
33
|
+
* @tag access:client
|
|
34
|
+
* @tag consumers:SectionForm callsites
|
|
35
|
+
* @tag sideEffects:none
|
|
36
|
+
*/
|
|
37
|
+
import { Fragment } from "react";
|
|
38
|
+
import { FormGroup } from "../../ui/components/Form";
|
|
39
|
+
import { FieldInput } from "../../ui/forms/FieldInput";
|
|
40
|
+
import { FieldSelect } from "../../ui/forms/FieldSelect";
|
|
41
|
+
import { FieldTextarea } from "../../ui/forms/FieldTextarea";
|
|
42
|
+
import { FieldCheckbox } from "../../ui/forms/FieldCheckbox";
|
|
43
|
+
import { humaniseFieldName } from "./entity-form";
|
|
44
|
+
import { ROW_COLUMNS, inferFieldUiMeta, objectShape, schemaEnumOptions, schemaIsOptional, ui, } from "./field-ui-meta";
|
|
45
|
+
/**
|
|
46
|
+
* Enum members as `<FieldSelect>` options.
|
|
47
|
+
*
|
|
48
|
+
* Both the zod-version handling and the optional/required test live in
|
|
49
|
+
* `field-ui-meta.ts` — this file must not grow a second copy, which is how the
|
|
50
|
+
* two majors' differing `_def` shapes would come to be handled inconsistently.
|
|
51
|
+
*/
|
|
52
|
+
function selectOptions(schema) {
|
|
53
|
+
const options = schemaEnumOptions(schema);
|
|
54
|
+
return options ? options.map((o) => ({ value: o, label: humaniseFieldName(o) })) : null;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resolve every field in a schema's shape.
|
|
58
|
+
*
|
|
59
|
+
* Fields with no registration are still returned, carrying inferred metadata
|
|
60
|
+
* and a `section` of `""`. Dropping them silently would hide the exact defect
|
|
61
|
+
* `audit-field-ui-meta` is meant to report — an unregistered field, or one
|
|
62
|
+
* whose `.register()` was not the last call in the chain and was therefore
|
|
63
|
+
* discarded by a subsequent `.optional()`.
|
|
64
|
+
*/
|
|
65
|
+
export function resolveFields(schema) {
|
|
66
|
+
const shape = objectShape(schema);
|
|
67
|
+
if (!shape)
|
|
68
|
+
return [];
|
|
69
|
+
return Object.entries(shape).map(([name, fieldSchema]) => {
|
|
70
|
+
const explicit = ui.get(fieldSchema);
|
|
71
|
+
const meta = {
|
|
72
|
+
section: "",
|
|
73
|
+
...inferFieldUiMeta(name, fieldSchema),
|
|
74
|
+
...(explicit ?? {}),
|
|
75
|
+
};
|
|
76
|
+
return { name, schema: fieldSchema, meta, required: !schemaIsOptional(fieldSchema) };
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/** Group resolved fields by section, preserving declaration order within each. */
|
|
80
|
+
export function groupFieldsBySection(fields) {
|
|
81
|
+
const bySection = new Map();
|
|
82
|
+
for (const field of fields) {
|
|
83
|
+
if (field.meta.derived)
|
|
84
|
+
continue; // server-owned — never an input
|
|
85
|
+
const key = field.meta.section || "advanced";
|
|
86
|
+
const bucket = bySection.get(key);
|
|
87
|
+
if (bucket)
|
|
88
|
+
bucket.push(field);
|
|
89
|
+
else
|
|
90
|
+
bySection.set(key, [field]);
|
|
91
|
+
}
|
|
92
|
+
for (const bucket of bySection.values()) {
|
|
93
|
+
bucket.sort((a, b) => (a.meta.order ?? Number.MAX_SAFE_INTEGER) - (b.meta.order ?? Number.MAX_SAFE_INTEGER));
|
|
94
|
+
}
|
|
95
|
+
return bySection;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Pack consecutive fields into rows by their span.
|
|
99
|
+
*
|
|
100
|
+
* A `full` field always breaks the current row — that is what stops a media
|
|
101
|
+
* upload or a textarea being squeezed alongside a short input. Mixed spans
|
|
102
|
+
* start a new row too, rather than being crammed together: two `pair` fields
|
|
103
|
+
* make a clean 2-up, a `pair` next to a `quarter` makes neither.
|
|
104
|
+
*/
|
|
105
|
+
export function packRows(fields) {
|
|
106
|
+
const rows = [];
|
|
107
|
+
let current = [];
|
|
108
|
+
let currentSpan = null;
|
|
109
|
+
const flush = () => {
|
|
110
|
+
if (current.length > 0)
|
|
111
|
+
rows.push(current);
|
|
112
|
+
current = [];
|
|
113
|
+
currentSpan = null;
|
|
114
|
+
};
|
|
115
|
+
for (const field of fields) {
|
|
116
|
+
const span = field.meta.row ?? "pair";
|
|
117
|
+
if (span === "full") {
|
|
118
|
+
flush();
|
|
119
|
+
rows.push([field]);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (currentSpan !== null && (span !== currentSpan || current.length >= ROW_COLUMNS[span])) {
|
|
123
|
+
flush();
|
|
124
|
+
}
|
|
125
|
+
current.push(field);
|
|
126
|
+
currentSpan = span;
|
|
127
|
+
}
|
|
128
|
+
flush();
|
|
129
|
+
return rows;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Build the `SectionDef[]` a `<SectionForm>` renders.
|
|
133
|
+
*
|
|
134
|
+
* Section order: `sectionRequired` first (there is normally exactly one — the
|
|
135
|
+
* fields without which the record cannot be saved), then `sectionOrder`, then
|
|
136
|
+
* first-declaration order.
|
|
137
|
+
*/
|
|
138
|
+
export function buildSectionsFromSchema(schema, opts = {}) {
|
|
139
|
+
const fields = resolveFields(schema);
|
|
140
|
+
const bySection = groupFieldsBySection(fields);
|
|
141
|
+
const declarationOrder = [...bySection.keys()];
|
|
142
|
+
const explicitOrder = opts.sectionOrder ?? [];
|
|
143
|
+
const rank = (id) => {
|
|
144
|
+
const bucket = bySection.get(id) ?? [];
|
|
145
|
+
if (bucket.some((f) => f.meta.sectionRequired))
|
|
146
|
+
return -1;
|
|
147
|
+
const i = explicitOrder.indexOf(id);
|
|
148
|
+
return i === -1 ? explicitOrder.length + declarationOrder.indexOf(id) : i;
|
|
149
|
+
};
|
|
150
|
+
return declarationOrder
|
|
151
|
+
.slice()
|
|
152
|
+
.sort((a, b) => rank(a) - rank(b))
|
|
153
|
+
.map((sectionId) => {
|
|
154
|
+
const sectionFields = bySection.get(sectionId) ?? [];
|
|
155
|
+
const label = sectionFields.find((f) => f.meta.sectionLabel)?.meta.sectionLabel ??
|
|
156
|
+
opts.sectionLabels?.[sectionId] ??
|
|
157
|
+
humaniseFieldName(sectionId);
|
|
158
|
+
return {
|
|
159
|
+
id: sectionId,
|
|
160
|
+
label,
|
|
161
|
+
required: sectionFields.some((f) => f.meta.sectionRequired),
|
|
162
|
+
quick: sectionFields.some((f) => f.meta.quick),
|
|
163
|
+
// Any section holding uncommitted state must stay mounted while
|
|
164
|
+
// collapsed — `<Collapse>` unmounts children, which would discard an
|
|
165
|
+
// in-flight media upload. Inference sets this for every media field.
|
|
166
|
+
keepMounted: sectionFields.some((f) => f.meta.sectionKeepMounted),
|
|
167
|
+
fields: sectionFields.map((f) => f.name),
|
|
168
|
+
render: ({ values, onChange, errors }) => (_jsx(_Fragment, { children: packRows(sectionFields).map((row, i) => (_jsx(FormGroup, { columns: ROW_COLUMNS[row[0].meta.row ?? "pair"], children: row.map((field) => renderField(field, { values, onChange, errors }, opts)) }, `${sectionId}-row-${i}`))) })),
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function renderField(field, ctx, opts) {
|
|
173
|
+
const override = opts.renderers?.[field.name];
|
|
174
|
+
// A keyed Fragment, not a wrapper element: an override may legitimately
|
|
175
|
+
// return a block-level control (a media uploader, a repeatable list editor),
|
|
176
|
+
// and wrapping that in a <span> would put block content inside an inline box.
|
|
177
|
+
if (override)
|
|
178
|
+
return _jsx(Fragment, { children: override({ field, ...ctx }) }, field.name);
|
|
179
|
+
const { name, meta, required } = field;
|
|
180
|
+
const label = meta.label ?? humaniseFieldName(name);
|
|
181
|
+
const value = ctx.values[name];
|
|
182
|
+
const set = (v) => ctx.onChange({ [name]: v });
|
|
183
|
+
switch (meta.kind) {
|
|
184
|
+
case "toggle":
|
|
185
|
+
return (_jsx(FieldCheckbox, { name: name, label: label, hint: meta.help, checked: Boolean(value), onChange: set }, name));
|
|
186
|
+
case "textarea":
|
|
187
|
+
return (_jsx(FieldTextarea, { name: name, label: label, hint: meta.help, required: required, value: typeof value === "string" ? value : "", onChange: set }, name));
|
|
188
|
+
case "select": {
|
|
189
|
+
const options = opts.options?.[name] ?? selectOptions(field.schema) ?? [];
|
|
190
|
+
return (_jsx(FieldSelect, { name: name, label: label, hint: meta.help === "paginated" ? undefined : meta.help, required: required, value: typeof value === "string" ? value : "", options: options, onChange: set }, name));
|
|
191
|
+
}
|
|
192
|
+
case "number":
|
|
193
|
+
return (_jsx(FieldInput, { name: name, type: "number", label: label, hint: meta.help, required: required, value: value == null ? "" : String(value), onChange: (v) => set(v === "" ? undefined : Number(v)) }, name));
|
|
194
|
+
case "date":
|
|
195
|
+
return (_jsx(FieldInput, { name: name, type: "date", label: label, hint: meta.help, required: required, value: typeof value === "string" ? value.slice(0, 10) : "", onChange: set }, name));
|
|
196
|
+
// `media` and `list` have no derived control on purpose. A MediaUploadField
|
|
197
|
+
// needs an upload context, a staging path and a finalize call that only the
|
|
198
|
+
// owning feature can supply, and a list editor needs to know what an item
|
|
199
|
+
// looks like. Deriving a placeholder for either would render a control that
|
|
200
|
+
// silently fails to save — worse than requiring an explicit renderer.
|
|
201
|
+
case "media":
|
|
202
|
+
case "list":
|
|
203
|
+
return (_jsx(FieldInput, { name: name, label: label, hint: meta.help ?? `Provide a renderer for "${name}" — this field needs a custom control.`, required: required, disabled: true, value: "" }, name));
|
|
204
|
+
default:
|
|
205
|
+
return (_jsx(FieldInput, { name: name, label: label, hint: meta.help, required: required, value: typeof value === "string" ? value : value == null ? "" : String(value), onChange: set }, name));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { JsonValue } from "@mohasinac/appkit/client";
|
|
2
|
+
import type { ZodTypeAny } from "zod";
|
|
3
|
+
import type { SectionDef } from "./SectionForm";
|
|
4
|
+
import type { QuickFieldDef, QuickFieldType } from "./QuickFormDrawer";
|
|
5
|
+
/**
|
|
6
|
+
* One definition per entity, two rendered modes.
|
|
7
|
+
*
|
|
8
|
+
* The point of this type is that quick mode is DERIVED from `sections`, never
|
|
9
|
+
* declared alongside them — two hand-maintained field lists for one entity is
|
|
10
|
+
* the drift this codebase already has too much of.
|
|
11
|
+
*
|
|
12
|
+
* ## Quick mode is self-submitting
|
|
13
|
+
*
|
|
14
|
+
* Saving from the quick drawer must produce a complete, valid, publishable
|
|
15
|
+
* record. It is not step one of the full form; "open full form" is an optional
|
|
16
|
+
* secondary path. That gives a mechanical rule for what belongs in it:
|
|
17
|
+
*
|
|
18
|
+
* quickFields = schema.required − derive()'s outputs
|
|
19
|
+
*
|
|
20
|
+
* If the resulting `quickSchema` cannot satisfy the server's create schema,
|
|
21
|
+
* the definition is wrong — the missing field either joins the quick set or
|
|
22
|
+
* gets a `derive()` default. Nothing may be left "for the user to finish
|
|
23
|
+
* later": that is exactly how `/store/products/new` came to POST without a
|
|
24
|
+
* `listingType` at all.
|
|
25
|
+
*/
|
|
26
|
+
export interface EntityFormDefinition<T extends object = Record<string, JsonValue>> {
|
|
27
|
+
/** Stable key — also the `SCHEMAS.forms` registry key. */
|
|
28
|
+
entity: string;
|
|
29
|
+
/** Full-mode schema. Satisfies `audit-form-schema`. */
|
|
30
|
+
schema: ZodTypeAny;
|
|
31
|
+
/**
|
|
32
|
+
* Create-mode schema for the quick drawer. Defaults to `schema` when
|
|
33
|
+
* omitted, but should normally be `schema.pick(quickFields)`.
|
|
34
|
+
*
|
|
35
|
+
* CREATE ONLY. A quick schema is a strict subset by construction, so
|
|
36
|
+
* sending it to a PATCH would strip every field outside the quick set.
|
|
37
|
+
*/
|
|
38
|
+
quickSchema?: ZodTypeAny;
|
|
39
|
+
/** THE single source of truth for this entity's fields. */
|
|
40
|
+
sections: SectionDef<T>[];
|
|
41
|
+
/**
|
|
42
|
+
* Auto-compute fields from earlier ones — slug and SEO from a title, totals
|
|
43
|
+
* from line items, counts from an array.
|
|
44
|
+
*
|
|
45
|
+
* Two rules, both enforced rather than documented:
|
|
46
|
+
* - a `derive()` output may NEVER also be a quick field (asserted by
|
|
47
|
+
* `assertNoDeriveCollision`) — that would ask the user for something the
|
|
48
|
+
* definition already computes;
|
|
49
|
+
* - it must fill only when the target is empty or its source actually
|
|
50
|
+
* changed, never overwrite a value the user typed.
|
|
51
|
+
*/
|
|
52
|
+
derive?: (partial: Partial<T>, prev: T, ctx: {
|
|
53
|
+
mode: "create" | "edit";
|
|
54
|
+
}) => Partial<T>;
|
|
55
|
+
/** Field names `derive` can produce. Used to subtract them from the quick set. */
|
|
56
|
+
derivedFields?: readonly string[];
|
|
57
|
+
/** Input types for quick-mode fields. Anything absent defaults to `"text"`. */
|
|
58
|
+
quickFieldTypes?: Readonly<Record<string, QuickFieldType>>;
|
|
59
|
+
/** Labels for quick-mode fields. Falls back to a humanised field name. */
|
|
60
|
+
quickFieldLabels?: Readonly<Record<string, string>>;
|
|
61
|
+
/** Field names that are required in quick mode (drives the `required` flag). */
|
|
62
|
+
requiredFields?: readonly string[];
|
|
63
|
+
routes: {
|
|
64
|
+
list: string;
|
|
65
|
+
new: string;
|
|
66
|
+
edit: (id: string) => string;
|
|
67
|
+
view?: (id: string) => string;
|
|
68
|
+
};
|
|
69
|
+
labels: {
|
|
70
|
+
singular: string;
|
|
71
|
+
plural: string;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** `"storeName"` / `"store_name"` / `"store.name"` -> `"Store name"`. */
|
|
75
|
+
export declare function humaniseFieldName(name: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* The quick-mode field set: every field owned by a `quick: true` section,
|
|
78
|
+
* minus anything `derive()` produces.
|
|
79
|
+
*
|
|
80
|
+
* Derived, never declared — so quick and full modes cannot drift apart.
|
|
81
|
+
*/
|
|
82
|
+
export declare function deriveQuickFieldNames<T extends object>(def: EntityFormDefinition<T>): string[];
|
|
83
|
+
/** Quick-mode field descriptors — feed straight into QuickFormDrawer's `fields` prop. */
|
|
84
|
+
export declare function deriveQuickFields<T extends object>(def: EntityFormDefinition<T>): QuickFieldDef[];
|
|
85
|
+
/**
|
|
86
|
+
* Throws when a `derive()` output is also offered as a quick field.
|
|
87
|
+
*
|
|
88
|
+
* That combination means the form asks the user to type something the
|
|
89
|
+
* definition computes for them, and whichever runs last silently wins. Call
|
|
90
|
+
* this once per definition — it is cheap and catches the mistake at the point
|
|
91
|
+
* the definition is written rather than at the point data is lost.
|
|
92
|
+
*/
|
|
93
|
+
export declare function assertNoDeriveCollision<T extends object>(def: EntityFormDefinition<T>): void;
|
|
94
|
+
/**
|
|
95
|
+
* Every field name the definition can reach — the union of all section fields
|
|
96
|
+
* plus everything `derive()` produces.
|
|
97
|
+
*
|
|
98
|
+
* This is what a schema must be a superset of. A document field missing from
|
|
99
|
+
* this set is unreachable in the UI; a schema field missing from it can never
|
|
100
|
+
* be populated. `audit-form-field-roundtrip` checks both directions.
|
|
101
|
+
*/
|
|
102
|
+
export declare function allDefinitionFields<T extends object>(def: EntityFormDefinition<T>): string[];
|
|
103
|
+
/**
|
|
104
|
+
* Apply `derive()` to a pending change, without clobbering user input.
|
|
105
|
+
*
|
|
106
|
+
* Returns the partial to merge: the caller's own change plus whatever the
|
|
107
|
+
* definition computed from it.
|
|
108
|
+
*/
|
|
109
|
+
export declare function applyDerive<T extends object>(def: EntityFormDefinition<T>, partial: Partial<T>, prev: T, mode: "create" | "edit"): Partial<T>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/** `"storeName"` / `"store_name"` / `"store.name"` -> `"Store name"`. */
|
|
2
|
+
export function humaniseFieldName(name) {
|
|
3
|
+
const leaf = name.includes(".") ? name.slice(name.lastIndexOf(".") + 1) : name;
|
|
4
|
+
const spaced = leaf
|
|
5
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
6
|
+
.replace(/[_-]+/g, " ")
|
|
7
|
+
.trim();
|
|
8
|
+
return spaced.charAt(0).toUpperCase() + spaced.slice(1);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The quick-mode field set: every field owned by a `quick: true` section,
|
|
12
|
+
* minus anything `derive()` produces.
|
|
13
|
+
*
|
|
14
|
+
* Derived, never declared — so quick and full modes cannot drift apart.
|
|
15
|
+
*/
|
|
16
|
+
export function deriveQuickFieldNames(def) {
|
|
17
|
+
const derived = new Set(def.derivedFields ?? []);
|
|
18
|
+
const seen = new Set();
|
|
19
|
+
const out = [];
|
|
20
|
+
for (const section of def.sections) {
|
|
21
|
+
if (!section.quick)
|
|
22
|
+
continue;
|
|
23
|
+
for (const field of section.fields ?? []) {
|
|
24
|
+
if (derived.has(field) || seen.has(field))
|
|
25
|
+
continue;
|
|
26
|
+
seen.add(field);
|
|
27
|
+
out.push(field);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
/** Quick-mode field descriptors — feed straight into QuickFormDrawer's `fields` prop. */
|
|
33
|
+
export function deriveQuickFields(def) {
|
|
34
|
+
const required = new Set(def.requiredFields ?? []);
|
|
35
|
+
return deriveQuickFieldNames(def).map((name) => ({
|
|
36
|
+
name,
|
|
37
|
+
label: def.quickFieldLabels?.[name] ?? humaniseFieldName(name),
|
|
38
|
+
type: def.quickFieldTypes?.[name] ?? "text",
|
|
39
|
+
required: required.has(name),
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Throws when a `derive()` output is also offered as a quick field.
|
|
44
|
+
*
|
|
45
|
+
* That combination means the form asks the user to type something the
|
|
46
|
+
* definition computes for them, and whichever runs last silently wins. Call
|
|
47
|
+
* this once per definition — it is cheap and catches the mistake at the point
|
|
48
|
+
* the definition is written rather than at the point data is lost.
|
|
49
|
+
*/
|
|
50
|
+
export function assertNoDeriveCollision(def) {
|
|
51
|
+
const derived = new Set(def.derivedFields ?? []);
|
|
52
|
+
if (derived.size === 0)
|
|
53
|
+
return;
|
|
54
|
+
const collisions = [];
|
|
55
|
+
for (const section of def.sections) {
|
|
56
|
+
if (!section.quick)
|
|
57
|
+
continue;
|
|
58
|
+
for (const field of section.fields ?? []) {
|
|
59
|
+
if (derived.has(field))
|
|
60
|
+
collisions.push(field);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (collisions.length > 0) {
|
|
64
|
+
throw new Error(`EntityFormDefinition("${def.entity}"): ${collisions.join(", ")} ` +
|
|
65
|
+
`${collisions.length === 1 ? "is" : "are"} produced by derive() and also ` +
|
|
66
|
+
`marked as quick field(s). A derived field must not be asked of the user — ` +
|
|
67
|
+
`drop it from the quick section's \`fields\`, or stop deriving it.`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Every field name the definition can reach — the union of all section fields
|
|
72
|
+
* plus everything `derive()` produces.
|
|
73
|
+
*
|
|
74
|
+
* This is what a schema must be a superset of. A document field missing from
|
|
75
|
+
* this set is unreachable in the UI; a schema field missing from it can never
|
|
76
|
+
* be populated. `audit-form-field-roundtrip` checks both directions.
|
|
77
|
+
*/
|
|
78
|
+
export function allDefinitionFields(def) {
|
|
79
|
+
const out = new Set(def.derivedFields ?? []);
|
|
80
|
+
for (const section of def.sections) {
|
|
81
|
+
for (const field of section.fields ?? [])
|
|
82
|
+
out.add(field);
|
|
83
|
+
}
|
|
84
|
+
return [...out];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Apply `derive()` to a pending change, without clobbering user input.
|
|
88
|
+
*
|
|
89
|
+
* Returns the partial to merge: the caller's own change plus whatever the
|
|
90
|
+
* definition computed from it.
|
|
91
|
+
*/
|
|
92
|
+
export function applyDerive(def, partial, prev, mode) {
|
|
93
|
+
if (!def.derive)
|
|
94
|
+
return partial;
|
|
95
|
+
return { ...partial, ...def.derive(partial, prev, { mode }) };
|
|
96
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { ZodTypeAny } from "zod";
|
|
2
|
+
/** How much of a row a field claims on desktop. Everything is 1-up on mobile. */
|
|
3
|
+
export type FieldRow = "full" | "pair" | "third" | "quarter";
|
|
4
|
+
/** Which input primitive renders the field, and its default row span. */
|
|
5
|
+
export type FieldKind = "text" | "number" | "date" | "select" | "toggle" | "textarea" | "media" | "list";
|
|
6
|
+
/**
|
|
7
|
+
* Which tier owns a value that is not typed by the user.
|
|
8
|
+
* T1 client `derive()` · T2 server-on-write · T3 mirror · T4 background job.
|
|
9
|
+
* The tier decides the correctness rule — see the calculated-field dictionary.
|
|
10
|
+
*/
|
|
11
|
+
export type CalculatedTier = "t1-derive" | "t2-server" | "t3-mirror" | "t4-aggregate";
|
|
12
|
+
export interface FieldUiMeta {
|
|
13
|
+
/**
|
|
14
|
+
* Section id this field belongs to — the grouping key, and the ONE key that
|
|
15
|
+
* cannot be inferred. Whether `gstin` belongs under "Tax" or "Business
|
|
16
|
+
* details" is a product decision, and a wrong section renders perfectly
|
|
17
|
+
* fine in the wrong place with nothing failing. Deliberately NOT inferred
|
|
18
|
+
* from a name prefix (`billing_city` → "billing"): that would work for a
|
|
19
|
+
* handful of schemas and quietly mis-group the rest.
|
|
20
|
+
*/
|
|
21
|
+
section: string;
|
|
22
|
+
/** Human label for the section. The first field to declare it wins. */
|
|
23
|
+
sectionLabel?: string;
|
|
24
|
+
/** Marks its section required-first, open on mount, non-collapsible. */
|
|
25
|
+
sectionRequired?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Section keeps its panel mounted while collapsed. Mandatory for any
|
|
28
|
+
* section holding uncommitted state — `<Collapse>` unmounts its children,
|
|
29
|
+
* which discards an in-flight media upload.
|
|
30
|
+
*/
|
|
31
|
+
sectionKeepMounted?: boolean;
|
|
32
|
+
/** Row span. Drives the `<FormGroup columns>` packing. */
|
|
33
|
+
row?: FieldRow;
|
|
34
|
+
/** Control kind. Picks the primitive and the default row span. */
|
|
35
|
+
kind?: FieldKind;
|
|
36
|
+
/** Sort order within the section. Unset sorts after ordered fields. */
|
|
37
|
+
order?: number;
|
|
38
|
+
/** Belongs in the self-submitting quick drawer. */
|
|
39
|
+
quick?: boolean;
|
|
40
|
+
/** Produced by `derive()` or the server — never rendered as a bare input. */
|
|
41
|
+
derived?: boolean;
|
|
42
|
+
/** Which calculated-field tier owns it, when it is not user-entered. */
|
|
43
|
+
tier?: CalculatedTier;
|
|
44
|
+
label?: string;
|
|
45
|
+
help?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const ui: {
|
|
48
|
+
/** Attach metadata to a schema instance. Returns the SAME instance. */
|
|
49
|
+
add<S extends ZodTypeAny>(schema: S, meta: FieldUiMeta): S;
|
|
50
|
+
get(schema: ZodTypeAny): FieldUiMeta | undefined;
|
|
51
|
+
has(schema: ZodTypeAny): boolean;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Annotate a field. **Must be the outermost call in the chain** — see the
|
|
55
|
+
* ordering trap in the header.
|
|
56
|
+
*
|
|
57
|
+
* name: annotate(z.string().min(1), { section: "basics", quick: true }),
|
|
58
|
+
* photo: annotate(z.string().optional(), { section: "media" }),
|
|
59
|
+
*
|
|
60
|
+
* Wrapping the call rather than chaining off it (`.register()`-style) is
|
|
61
|
+
* deliberate: it puts the schema visually INSIDE the annotation, so appending
|
|
62
|
+
* `.optional()` afterwards looks as wrong as it is.
|
|
63
|
+
*/
|
|
64
|
+
export declare function annotate<S extends ZodTypeAny>(schema: S, meta: FieldUiMeta): S;
|
|
65
|
+
/** `row` → the `<FormGroup columns>` value it packs into. */
|
|
66
|
+
export declare const ROW_COLUMNS: Record<FieldRow, 1 | 2 | 3 | 4>;
|
|
67
|
+
/**
|
|
68
|
+
* Strip `.optional()` / `.nullable()` / `.default()` / `.catch()` to reach the
|
|
69
|
+
* type that actually decides the control. Returns the innermost schema and its
|
|
70
|
+
* normalised type discriminator.
|
|
71
|
+
*
|
|
72
|
+
* Reads `_def` because zod exposes no public accessor for this, on either
|
|
73
|
+
* major. Depth-bounded rather than trusting the shape: `_def` is internal, and
|
|
74
|
+
* this must degrade to "text" rather than loop if a future zod reshapes it.
|
|
75
|
+
*/
|
|
76
|
+
export declare function unwrapSchema(schema: ZodTypeAny): {
|
|
77
|
+
schema: ZodTypeAny;
|
|
78
|
+
type: string;
|
|
79
|
+
};
|
|
80
|
+
/** Public: the option list for a select-shaped field, or null. */
|
|
81
|
+
export declare function schemaEnumOptions(schema: ZodTypeAny): string[] | null;
|
|
82
|
+
/** Public: whether a field's type is optional-wrapped (i.e. not required). */
|
|
83
|
+
export declare function schemaIsOptional(schema: ZodTypeAny): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The `.shape` of an object schema, seeing through effects wrappers.
|
|
86
|
+
*
|
|
87
|
+
* `.superRefine()` / `.refine()` / `.transform()` return a wrapper that does
|
|
88
|
+
* NOT expose `.shape` — verified: `z.object({...}).superRefine(fn)` has
|
|
89
|
+
* `_def.typeName === "ZodEffects"`, `.shape === undefined`, and the real object
|
|
90
|
+
* on `_def.schema`. Reading `.shape` directly therefore returns nothing for any
|
|
91
|
+
* schema with a cross-field rule, which is most of the interesting ones (the
|
|
92
|
+
* payout form's UPI-vs-bank branch is exactly this shape).
|
|
93
|
+
*
|
|
94
|
+
* Failing to unwrap would not error — it would silently derive a form with
|
|
95
|
+
* ZERO sections, which is the quiet-wrong-answer failure mode this whole wave
|
|
96
|
+
* exists to eliminate.
|
|
97
|
+
*/
|
|
98
|
+
export declare function objectShape(schema: ZodTypeAny): Record<string, ZodTypeAny> | null;
|
|
99
|
+
/**
|
|
100
|
+
* Everything about a field's layout that can be derived from its name and its
|
|
101
|
+
* Zod type. `section` is never inferred, so the return type is a Partial —
|
|
102
|
+
* `resolveFieldUiMeta` is what merges it with the explicit registration.
|
|
103
|
+
*
|
|
104
|
+
* This is what makes annotation cheap: a 13-field form is 13 short
|
|
105
|
+
* `.register(ui, { section: "…" })` calls, not 13 full metadata objects.
|
|
106
|
+
*/
|
|
107
|
+
export declare function inferFieldUiMeta(name: string, schema: ZodTypeAny): Partial<FieldUiMeta>;
|
|
108
|
+
/**
|
|
109
|
+
* The field's final metadata: inference first, explicit registration on top.
|
|
110
|
+
*
|
|
111
|
+
* Returns `null` when the field has no registration at all — the caller
|
|
112
|
+
* decides whether that is a hard error (a registered form schema, where
|
|
113
|
+
* `section` is mandatory) or a fallback (an ad-hoc schema being previewed).
|
|
114
|
+
*/
|
|
115
|
+
export declare function resolveFieldUiMeta(name: string, schema: ZodTypeAny): FieldUiMeta | null;
|