/** * Query Services API * Fetches single or multiple services with pagination and sorting. * * `queryServices` is the single entry point. It decides which underlying endpoint * to call based on the request: when an `availabilityFilter` is present it queries * the catalog-search `QueryServicesByAvailability` endpoint (cursor paging, each * service enriched with an `available` flag); otherwise it uses the services * `queryServices` endpoint (offset paging). Callers always get the same * `{ services, pagingMetadata }` shape. */ import { type Service, type Paging, type Sorting } from '@wix/auto_sdk_bookings_services'; import { LocationType as AvailabilityLocationType, type AvailabilityFilter, type Attribute, type Location as AvailabilityLocation } from '@wix/auto_sdk_bookings_catalog-search'; import type { FilterValue as Filter } from '@wix/headless-components/react'; /** * Synthetic location ID constants for non-business locations */ export declare const SYNTHETIC_CUSTOM_ID = "custom"; export declare const SYNTHETIC_CUSTOMER_ID = "customer"; /** * Re-exported availability filter types so consumers can build availability UIs * without importing the ambassador package directly. */ export { AvailabilityLocationType, type AvailabilityFilter, type Attribute, type AvailabilityLocation, }; /** * A service, optionally enriched with a bookable-availability flag. * `available` is only populated when the query runs in availability mode. */ export type ServiceWithAvailabilityItem = Service & { /** Whether the service has bookable slots in the requested window. */ available?: boolean; }; /** * Paging metadata from a query response. Extends the SDK's Paging type with a * `hasNext` flag and an opaque `cursor` (used in availability/cursor mode). */ export type PagingMetadata = Paging & { /** Number of items returned in the current page */ count?: number; /** Whether there are more services available to load */ hasNext?: boolean; /** Opaque cursor for the next page (availability/cursor mode only). Undefined in offset mode. */ cursor?: string; }; /** * Query services request options. * When `availabilityFilter` is present, services are queried by real bookable * availability; `pagingMetadata.cursor` then drives pagination instead of `offset`. */ export interface QueryServicesRequest { appId: string; filter?: Filter; pagingMetadata?: PagingMetadata; sort?: Sorting[]; availabilityFilter?: AvailabilityFilter; } /** * Result shape shared by both query modes. */ export interface QueryServicesResult { services: ServiceWithAvailabilityItem[]; pagingMetadata: PagingMetadata; } /** * Fetches a service by its ID * @param id - The service ID * @param appId - Optional app ID, defaults to booking app ID * @returns Object containing the service or null if not found */ export declare const getServiceById: (id: string, appId?: string) => Promise<{ service: Service | null; }>; /** * Fetches a service by its slug * @param slug - The service slug * @param appId - Optional app ID, defaults to booking app ID * @returns Object containing the service or null if not found */ export declare const getServiceBySlug: (slug: string, appId?: string) => Promise<{ service: Service | null; }>; /** * Converts a platform Filter object to the API filter format expected by the Bookings services API. * Handles special cases like location filtering where synthetic locations need to be converted * to location types. * * @param platformFilter - Platform Filter object with standard operators ($in, $hasSome, $eq, etc.) * @returns API filter object ready for the Bookings query API * * @example * ```ts * // Input (Platform Filter) * { * 'category.id': { $in: ['cat1', 'cat2'] }, * 'locations.business.id': { $hasSome: ['loc1', 'custom'] } * } * * // Output (API Filter) * { * 'category.id': { $in: ['cat1', 'cat2'] }, * 'locations.business.id': { $hasSome: ['loc1'] }, * 'locations.type': { $hasSome: ['CUSTOM'] } * } * ``` */ export declare function convertPlatformFilterToApiFilter(platformFilter: Filter): Record; /** * Whether an availability filter carries a real bookable constraint that warrants * routing to the availability endpoint. Modifiers that don't define a query on their * own (`timeZone`, `exactMatch`, `includeUnavailable`) are ignored: only a complete * date window (both `localStartDate` and `localEndDate`) or a resource constraint * (`locations`/`attributes`/`resourceTypes`) counts. * * This is the single source of truth shared by the API dispatch and the service's * `hasAvailabilityFilterSignal`. */ export declare function hasActiveAvailabilityFilter(availabilityFilter?: AvailabilityFilter): boolean; /** * Query services with pagination and sorting. * Picks the underlying endpoint by request: availability filter present → catalog-search * (cursor paging, `available` flag); otherwise the offset services query. * * @param request - Query parameters including appId, filter (platform Filter type), paging * metadata, sort options, and an optional availability filter * @returns Promise that resolves to services array and paging metadata with hasNext flag * * @example * ```ts * // Offset query * const { services, pagingMetadata } = await queryServices({ * appId: '13d21c63-b5ec-5912-8397-c3a5ddb27a97', * filter: { '_id': { $in: ['service1', 'service2'] } }, * pagingMetadata: { limit: 20, offset: 0 }, * }); * * // Availability-aware query (cursor paging + `available` flag) * const availability = await queryServices({ * appId: '13d21c63-b5ec-5912-8397-c3a5ddb27a97', * availabilityFilter: { localStartDate: '...', localEndDate: '...', timeZone: '...' }, * pagingMetadata: { limit: 20 }, * }); * ``` */ export declare function queryServices(request: QueryServicesRequest): Promise;