import { type Signal } from '@wix/services-definitions/core-services/signals'; import { items } from '@wix/data'; import type { DataCollection } from '@wix/auto_sdk_data_collections'; import type { SortValue, FilterValue as Filter } from '@wix/headless-components/react'; export type WixDataItem = items.WixDataItem; export type WixDataQueryResult = items.WixDataResult; /** * Parameters for linking an item to another item */ export interface LinkItemParams { referenceFieldId: string; itemId: string; referencedItemIds: string | string[]; } /** * Service definition for the CMS Collection service. */ export declare const CmsCollectionServiceDefinition: string & { __api: { /** Reactive signal indicating if items are currently being loaded for the first time (no data exists yet) */ loadingSignal: Signal; /** Reactive signal indicating if any fetch operation is currently in progress */ fetchingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; /** Reactive signal containing the current query result with pagination data */ queryResultSignal: Signal; /** Reactive signal containing the current sort value */ sortSignal: Signal; /** Reactive signal containing the current filter value */ filterSignal: Signal; /** Function to explicitly invalidate and reload items */ invalidate: () => Promise; /** Function to load items with optional query options */ loadItems: (options?: CmsQueryOptions) => Promise; /** Function to navigate to the next page of results */ nextPage: () => Promise; /** Function to navigate to the previous page of results */ prevPage: () => Promise; /** Function to create a new item in the collection */ createItem: (itemData: Partial) => Promise; /** Function to insert a reference between items */ linkItem: (params: LinkItemParams) => Promise; /** Function to update an existing item in the collection */ updateItem: (itemId: string, itemData: Partial) => Promise; /** Function to delete an item from the collection */ deleteItem: (itemId: string) => Promise; /** Function to remove a reference between items */ unlinkItem: (params: LinkItemParams) => Promise; /** Function to fetch options for a field (referenced items or distinct values) */ fetchFieldOptions: (fieldId: string) => Promise; /** Function to create a new item in a referenced collection */ createReferencedCollectionItem: (referenceFieldId: string, itemData: Partial) => Promise; /** Function to update the sort value */ setSort: (sort: SortValue) => void; /** Function to update the filter value (merges with existing filters) */ setFilter: (filter: Filter) => void; /** Function to reset all filters */ resetFilter: () => void; /** Function to reset a specific filter field */ resetFilterField: (fieldName: string) => void; /** Function to check if filters are applied */ isFiltered: () => boolean; /** The collection ID */ collectionId: string; }; __config: {}; isServiceDefinition?: boolean; } & { /** Reactive signal indicating if items are currently being loaded for the first time (no data exists yet) */ loadingSignal: Signal; /** Reactive signal indicating if any fetch operation is currently in progress */ fetchingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; /** Reactive signal containing the current query result with pagination data */ queryResultSignal: Signal; /** Reactive signal containing the current sort value */ sortSignal: Signal; /** Reactive signal containing the current filter value */ filterSignal: Signal; /** Function to explicitly invalidate and reload items */ invalidate: () => Promise; /** Function to load items with optional query options */ loadItems: (options?: CmsQueryOptions) => Promise; /** Function to navigate to the next page of results */ nextPage: () => Promise; /** Function to navigate to the previous page of results */ prevPage: () => Promise; /** Function to create a new item in the collection */ createItem: (itemData: Partial) => Promise; /** Function to insert a reference between items */ linkItem: (params: LinkItemParams) => Promise; /** Function to update an existing item in the collection */ updateItem: (itemId: string, itemData: Partial) => Promise; /** Function to delete an item from the collection */ deleteItem: (itemId: string) => Promise; /** Function to remove a reference between items */ unlinkItem: (params: LinkItemParams) => Promise; /** Function to fetch options for a field (referenced items or distinct values) */ fetchFieldOptions: (fieldId: string) => Promise; /** Function to create a new item in a referenced collection */ createReferencedCollectionItem: (referenceFieldId: string, itemData: Partial) => Promise; /** Function to update the sort value */ setSort: (sort: SortValue) => void; /** Function to update the filter value (merges with existing filters) */ setFilter: (filter: Filter) => void; /** Function to reset all filters */ resetFilter: () => void; /** Function to reset a specific filter field */ resetFilterField: (fieldName: string) => void; /** Function to check if filters are applied */ isFiltered: () => boolean; /** The collection ID */ collectionId: string; }; /** * Interface for initial query options */ export interface CmsQueryOptions { /** Number of items per page */ limit?: number; /** Number of items to skip */ skip?: number; /** Whether to return the total count of items */ returnTotalCount?: boolean; } /** * Configuration interface required to initialize the CmsCollectionService. */ export interface CmsCollectionServiceConfig { /** The collection ID to load items from */ collectionId: string; /** Optional initial query result to initialize the service with. * If provided, items and pagination info will be extracted from this result. * If not provided, service will load initial data automatically. */ queryResult?: WixDataQueryResult; queryOptions?: CmsQueryOptions; /** Optional initial sort value */ initialSort?: SortValue; /** Optional initial filter value */ initialFilter?: Filter | null; /** Default filters that are always applied (set by site owner). * These filters are combined with user-applied filters using AND logic. */ defaultFilter?: Filter | null; /** List of field IDs for single reference fields to include */ singleRefFieldIds?: string[]; /** List of field IDs for multi reference fields to include */ multiRefFieldIds?: string[]; /** Optional collection schema for field transformation. * If provided, field transformations will use schema information. * If not provided, schema will be fetched during service initialization. */ collectionSchema?: DataCollection | null; } /** * Implementation of the CMS Collection service that manages reactive collection data. */ export declare const CmsCollectionServiceImplementation: import("@wix/services-definitions").ServiceFactory; /** Reactive signal indicating if any fetch operation is currently in progress */ fetchingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; /** Reactive signal containing the current query result with pagination data */ queryResultSignal: Signal; /** Reactive signal containing the current sort value */ sortSignal: Signal; /** Reactive signal containing the current filter value */ filterSignal: Signal; /** Function to explicitly invalidate and reload items */ invalidate: () => Promise; /** Function to load items with optional query options */ loadItems: (options?: CmsQueryOptions) => Promise; /** Function to navigate to the next page of results */ nextPage: () => Promise; /** Function to navigate to the previous page of results */ prevPage: () => Promise; /** Function to create a new item in the collection */ createItem: (itemData: Partial) => Promise; /** Function to insert a reference between items */ linkItem: (params: LinkItemParams) => Promise; /** Function to update an existing item in the collection */ updateItem: (itemId: string, itemData: Partial) => Promise; /** Function to delete an item from the collection */ deleteItem: (itemId: string) => Promise; /** Function to remove a reference between items */ unlinkItem: (params: LinkItemParams) => Promise; /** Function to fetch options for a field (referenced items or distinct values) */ fetchFieldOptions: (fieldId: string) => Promise; /** Function to create a new item in a referenced collection */ createReferencedCollectionItem: (referenceFieldId: string, itemData: Partial) => Promise; /** Function to update the sort value */ setSort: (sort: SortValue) => void; /** Function to update the filter value (merges with existing filters) */ setFilter: (filter: Filter) => void; /** Function to reset all filters */ resetFilter: () => void; /** Function to reset a specific filter field */ resetFilterField: (fieldName: string) => void; /** Function to check if filters are applied */ isFiltered: () => boolean; /** The collection ID */ collectionId: string; }; __config: {}; isServiceDefinition?: boolean; } & { /** Reactive signal indicating if items are currently being loaded for the first time (no data exists yet) */ loadingSignal: Signal; /** Reactive signal indicating if any fetch operation is currently in progress */ fetchingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; /** Reactive signal containing the current query result with pagination data */ queryResultSignal: Signal; /** Reactive signal containing the current sort value */ sortSignal: Signal; /** Reactive signal containing the current filter value */ filterSignal: Signal; /** Function to explicitly invalidate and reload items */ invalidate: () => Promise; /** Function to load items with optional query options */ loadItems: (options?: CmsQueryOptions) => Promise; /** Function to navigate to the next page of results */ nextPage: () => Promise; /** Function to navigate to the previous page of results */ prevPage: () => Promise; /** Function to create a new item in the collection */ createItem: (itemData: Partial) => Promise; /** Function to insert a reference between items */ linkItem: (params: LinkItemParams) => Promise; /** Function to update an existing item in the collection */ updateItem: (itemId: string, itemData: Partial) => Promise; /** Function to delete an item from the collection */ deleteItem: (itemId: string) => Promise; /** Function to remove a reference between items */ unlinkItem: (params: LinkItemParams) => Promise; /** Function to fetch options for a field (referenced items or distinct values) */ fetchFieldOptions: (fieldId: string) => Promise; /** Function to create a new item in a referenced collection */ createReferencedCollectionItem: (referenceFieldId: string, itemData: Partial) => Promise; /** Function to update the sort value */ setSort: (sort: SortValue) => void; /** Function to update the filter value (merges with existing filters) */ setFilter: (filter: Filter) => void; /** Function to reset all filters */ resetFilter: () => void; /** Function to reset a specific filter field */ resetFilterField: (fieldName: string) => void; /** Function to check if filters are applied */ isFiltered: () => boolean; /** The collection ID */ collectionId: string; }, CmsCollectionServiceConfig>; /** * Result type for loading CMS collection service configuration. */ export type CmsCollectionServiceConfigResult = {}; /** * Loads initial data for the CMS Collection service with pagination support. * * @param collectionId - The collection ID to load data from * @param options - Query options for pagination and filtering * @param sort - Optional sort value * @param filter - Optional filter value * @param defaultFilter - Optional default filter that's always applied * @param singleRefFieldIds - List of field IDs for single reference fields to include * @param multiRefFieldIds - List of field IDs for multi reference fields to include * @returns Promise resolving to service configuration with queryResult containing all data * * @example * ```tsx * // In Astro frontmatter or server action * const cmsConfig = await loadCmsCollectionServiceInitialData( * 'MyCollection', * { limit: 10, skip: 0 }, * undefined, * { status: { $eq: 'published' } }, * { color: { $hasSome: ['yellow', 'red'] } }, * ['author', 'category'], * ['tags', 'relatedItems'] * ); * * // Pass to React component * * ``` */ export declare const loadCmsCollectionServiceInitialData: (collectionId: string, options?: CmsQueryOptions, sort?: SortValue, filter?: Filter | null, defaultFilter?: Filter | null, singleRefFieldIds?: string[], multiRefFieldIds?: string[]) => Promise; /** * Service binding helper that bundles everything together for the service manager. */ export declare const cmsCollectionServiceBinding: >[typeof CmsCollectionServiceDefinition]; }>(servicesConfigs: T) => readonly [string & { __api: { /** Reactive signal indicating if items are currently being loaded for the first time (no data exists yet) */ loadingSignal: Signal; /** Reactive signal indicating if any fetch operation is currently in progress */ fetchingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; /** Reactive signal containing the current query result with pagination data */ queryResultSignal: Signal; /** Reactive signal containing the current sort value */ sortSignal: Signal; /** Reactive signal containing the current filter value */ filterSignal: Signal; /** Function to explicitly invalidate and reload items */ invalidate: () => Promise; /** Function to load items with optional query options */ loadItems: (options?: CmsQueryOptions) => Promise; /** Function to navigate to the next page of results */ nextPage: () => Promise; /** Function to navigate to the previous page of results */ prevPage: () => Promise; /** Function to create a new item in the collection */ createItem: (itemData: Partial) => Promise; /** Function to insert a reference between items */ linkItem: (params: LinkItemParams) => Promise; /** Function to update an existing item in the collection */ updateItem: (itemId: string, itemData: Partial) => Promise; /** Function to delete an item from the collection */ deleteItem: (itemId: string) => Promise; /** Function to remove a reference between items */ unlinkItem: (params: LinkItemParams) => Promise; /** Function to fetch options for a field (referenced items or distinct values) */ fetchFieldOptions: (fieldId: string) => Promise; /** Function to create a new item in a referenced collection */ createReferencedCollectionItem: (referenceFieldId: string, itemData: Partial) => Promise; /** Function to update the sort value */ setSort: (sort: SortValue) => void; /** Function to update the filter value (merges with existing filters) */ setFilter: (filter: Filter) => void; /** Function to reset all filters */ resetFilter: () => void; /** Function to reset a specific filter field */ resetFilterField: (fieldName: string) => void; /** Function to check if filters are applied */ isFiltered: () => boolean; /** The collection ID */ collectionId: string; }; __config: {}; isServiceDefinition?: boolean; } & { /** Reactive signal indicating if items are currently being loaded for the first time (no data exists yet) */ loadingSignal: Signal; /** Reactive signal indicating if any fetch operation is currently in progress */ fetchingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; /** Reactive signal containing the current query result with pagination data */ queryResultSignal: Signal; /** Reactive signal containing the current sort value */ sortSignal: Signal; /** Reactive signal containing the current filter value */ filterSignal: Signal; /** Function to explicitly invalidate and reload items */ invalidate: () => Promise; /** Function to load items with optional query options */ loadItems: (options?: CmsQueryOptions) => Promise; /** Function to navigate to the next page of results */ nextPage: () => Promise; /** Function to navigate to the previous page of results */ prevPage: () => Promise; /** Function to create a new item in the collection */ createItem: (itemData: Partial) => Promise; /** Function to insert a reference between items */ linkItem: (params: LinkItemParams) => Promise; /** Function to update an existing item in the collection */ updateItem: (itemId: string, itemData: Partial) => Promise; /** Function to delete an item from the collection */ deleteItem: (itemId: string) => Promise; /** Function to remove a reference between items */ unlinkItem: (params: LinkItemParams) => Promise; /** Function to fetch options for a field (referenced items or distinct values) */ fetchFieldOptions: (fieldId: string) => Promise; /** Function to create a new item in a referenced collection */ createReferencedCollectionItem: (referenceFieldId: string, itemData: Partial) => Promise; /** Function to update the sort value */ setSort: (sort: SortValue) => void; /** Function to update the filter value (merges with existing filters) */ setFilter: (filter: Filter) => void; /** Function to reset all filters */ resetFilter: () => void; /** Function to reset a specific filter field */ resetFilterField: (fieldName: string) => void; /** Function to check if filters are applied */ isFiltered: () => boolean; /** The collection ID */ collectionId: string; }, import("@wix/services-definitions").ServiceFactory; /** Reactive signal indicating if any fetch operation is currently in progress */ fetchingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; /** Reactive signal containing the current query result with pagination data */ queryResultSignal: Signal; /** Reactive signal containing the current sort value */ sortSignal: Signal; /** Reactive signal containing the current filter value */ filterSignal: Signal; /** Function to explicitly invalidate and reload items */ invalidate: () => Promise; /** Function to load items with optional query options */ loadItems: (options?: CmsQueryOptions) => Promise; /** Function to navigate to the next page of results */ nextPage: () => Promise; /** Function to navigate to the previous page of results */ prevPage: () => Promise; /** Function to create a new item in the collection */ createItem: (itemData: Partial) => Promise; /** Function to insert a reference between items */ linkItem: (params: LinkItemParams) => Promise; /** Function to update an existing item in the collection */ updateItem: (itemId: string, itemData: Partial) => Promise; /** Function to delete an item from the collection */ deleteItem: (itemId: string) => Promise; /** Function to remove a reference between items */ unlinkItem: (params: LinkItemParams) => Promise; /** Function to fetch options for a field (referenced items or distinct values) */ fetchFieldOptions: (fieldId: string) => Promise; /** Function to create a new item in a referenced collection */ createReferencedCollectionItem: (referenceFieldId: string, itemData: Partial) => Promise; /** Function to update the sort value */ setSort: (sort: SortValue) => void; /** Function to update the filter value (merges with existing filters) */ setFilter: (filter: Filter) => void; /** Function to reset all filters */ resetFilter: () => void; /** Function to reset a specific filter field */ resetFilterField: (fieldName: string) => void; /** Function to check if filters are applied */ isFiltered: () => boolean; /** The collection ID */ collectionId: string; }; __config: {}; isServiceDefinition?: boolean; } & { /** Reactive signal indicating if items are currently being loaded for the first time (no data exists yet) */ loadingSignal: Signal; /** Reactive signal indicating if any fetch operation is currently in progress */ fetchingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; /** Reactive signal containing the current query result with pagination data */ queryResultSignal: Signal; /** Reactive signal containing the current sort value */ sortSignal: Signal; /** Reactive signal containing the current filter value */ filterSignal: Signal; /** Function to explicitly invalidate and reload items */ invalidate: () => Promise; /** Function to load items with optional query options */ loadItems: (options?: CmsQueryOptions) => Promise; /** Function to navigate to the next page of results */ nextPage: () => Promise; /** Function to navigate to the previous page of results */ prevPage: () => Promise; /** Function to create a new item in the collection */ createItem: (itemData: Partial) => Promise; /** Function to insert a reference between items */ linkItem: (params: LinkItemParams) => Promise; /** Function to update an existing item in the collection */ updateItem: (itemId: string, itemData: Partial) => Promise; /** Function to delete an item from the collection */ deleteItem: (itemId: string) => Promise; /** Function to remove a reference between items */ unlinkItem: (params: LinkItemParams) => Promise; /** Function to fetch options for a field (referenced items or distinct values) */ fetchFieldOptions: (fieldId: string) => Promise; /** Function to create a new item in a referenced collection */ createReferencedCollectionItem: (referenceFieldId: string, itemData: Partial) => Promise; /** Function to update the sort value */ setSort: (sort: SortValue) => void; /** Function to update the filter value (merges with existing filters) */ setFilter: (filter: Filter) => void; /** Function to reset all filters */ resetFilter: () => void; /** Function to reset a specific filter field */ resetFilterField: (fieldName: string) => void; /** Function to check if filters are applied */ isFiltered: () => boolean; /** The collection ID */ collectionId: string; }, CmsCollectionServiceConfig>, CmsCollectionServiceConfig | undefined];