/** * ServiceList Service - Reactive service list data management * Handles querying and pagination of services list (NO selection management). * * Availability is just part of the query: when the query options carry an * `availabilityFilter`, the API layer queries services by real bookable * availability (and each service gets an `available` flag); otherwise it runs the * plain offset query. The service does not know or care which endpoint is used — * that decision lives in {@link queryServices}. */ import { type Signal, type ReadOnlySignal } from '@wix/services-definitions/core-services/signals'; import type { Sorting } from '@wix/auto_sdk_bookings_services'; import type { QueryServicesRequest, PagingMetadata, ServiceWithAvailabilityItem, AvailabilityFilter } from '../../api/query-services/index.js'; import { type Category } from '../../api/query-categories/index.js'; import type { FilterOption, FilterValue as Filter } from '@wix/headless-components/react'; /** * Query options without paging metadata (user-controlled request params). * Includes `filter` (category/location) and `availabilityFilter`; the effect * subscribes to changes in this signal to trigger re-fetches. */ export type QueryOptions = Omit; /** * Configuration for the ServiceList service */ export interface ServiceListServiceConfig { services?: ServiceWithAvailabilityItem[]; categories?: Category[]; options?: QueryServicesRequest; } /** * Actions object for service list operations */ export interface ServiceListActions { loadMore: (count?: number) => Promise; setQueryOptions: (options: QueryOptions) => void; setFilter: (filter: Filter) => void; resetFilter: () => void; resetFilterField: (fieldName: string) => void; } /** * API interface for the ServiceList service */ export interface ServiceListServiceAPI { /** Reactive signal containing the list of services */ servicesSignal: Signal; /** Reactive signal containing current query options (appId, filter, availabilityFilter, sort) - changes trigger re-fetch */ queryOptionsSignal: Signal; /** Reactive signal containing pagination metadata (limit, offset/cursor, count, hasNext) - updated after fetches */ pagingMetadataSignal: Signal; /** Reactive signal indicating if services are currently being loaded */ isLoadingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; /** Reactive signal containing available categories for filtering */ categoriesSignal: Signal; /** Computed signal containing filter options derived from categories */ filterOptionsSignal: ReadOnlySignal; /** Computed signal indicating if any filters are active (from queryOptionsSignal.filter) */ isFilteredSignal: ReadOnlySignal; /** Computed signal indicating whether an availability filter is currently applied */ hasAvailabilityFilterSignal: ReadOnlySignal; /** Computed signal containing effective filter (queryOptions.filter + location from BookingService) */ effectiveFilterSignal: ReadOnlySignal; /** Actions object containing query actions */ actions: ServiceListActions; /** Reactive signal indicating if there are more services to load */ hasMoreServicesSignal: ReadOnlySignal; } /** * Service definition for the ServiceList service */ export declare const ServiceListServiceDefinition: string & { __api: ServiceListServiceAPI; __config: ServiceListServiceConfig; isServiceDefinition?: boolean; } & ServiceListServiceAPI; /** * Implementation of the ServiceList service that manages reactive services list data. * This service provides signals for services data, query options, pagination metadata * (including hasNext flag), loading state, and error handling. * It automatically re-fetches services when query options change. * * @example * ```tsx * import { ServiceListService, ServiceListServiceDefinition } from '@wix/bookings/services'; * import { useService } from '@wix/services-manager-react'; * * function ServicesComponent({ serviceListConfig }) { * return ( * * * * ); * } * * function ServicesDisplay() { * const serviceListService = useService(ServiceListServiceDefinition); * const services = serviceListService.servicesSignal.get(); * const isLoading = serviceListService.isLoadingSignal.get(); * const error = serviceListService.errorSignal.get(); * const hasMore = serviceListService.hasMoreServicesSignal.get(); * * if (isLoading) return
Loading services...
; * if (error) return
Error: {error}
; * * return ( *
* {services.map(service => ( *
*

{service.name}

*

{service.description}

*
* ))} * {hasMore && ( * * )} *
* ); * } * ``` */ export declare const ServiceListService: import("@wix/services-definitions").ServiceFactory; /** * Result types for service list loading operations */ export type SuccessServiceListServiceConfigResult = { type: 'success'; config: ServiceListServiceConfig; }; export type ErrorServiceListServiceConfigResult = { type: 'error'; error: Error; }; /** * Options for {@link loadServiceListServiceInitialData}. * Pass an `availabilityFilter` to load availability-aware services. */ export interface LoadServiceListServiceOptions { appId?: string; filter?: Filter; pagingMetadata?: PagingMetadata; sort?: Sorting[]; availabilityFilter?: AvailabilityFilter; } /** * Loads service list configuration for SSR, pre-fetching services and categories. * Pass an `availabilityFilter` to query availability-aware services. * * @param options - Query options. * @returns A success result with the config, or an error result. * * @example * ```ts * // Plain offset query * const result = await loadServiceListServiceInitialData({ * appId: '13d21c63-b5ec-5912-8397-c3a5ddb27a97', * pagingMetadata: { limit: 20, offset: 0 }, * }); * * // Availability-aware query (cursor paging + `available` flag) * const availabilityResult = await loadServiceListServiceInitialData({ * availabilityFilter: { * localStartDate: '2026-06-01T09:00:00', * localEndDate: '2026-06-07T17:00:00', * timeZone: 'America/New_York', * }, * pagingMetadata: { limit: 20 }, * }); * ``` */ export declare function loadServiceListServiceInitialData(options: LoadServiceListServiceOptions): Promise;