import type { QueryRequest as SDKQueryRequest, QuerySpec } from '@wix/sdk-types'; import type { SortOrder, BulkActionMetadata, ItemMetadata } from '../types/data-item-types'; import { WixDataFilter } from './WixDataFilter'; export interface BaseOptions { /** * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). * * Default: `false`. */ suppressHooks?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. */ showDrafts?: boolean; } export interface WithAppOptions { /** * Options for [querying Wix app collections](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/querying-wix-app-collections). */ appOptions?: Record; } /** * Options for including referenced items in results. */ export interface IncludeReferencesOptions { /** * Reference fields to resolve in the results. When specified, the referenced items * are included in the response for the given fields. * * Each entry identifies a reference `field` by name and an optional `limit` that caps the number * of referenced items returned per queried item (relevant for multi-reference fields). */ includeReferences?: { field: string; limit?: number; }[]; } export interface WixDataUnpublishDataItemOptions { /** * When `true`, creates a draft copy of the item when unpublishing. * * Default: `false`. */ copyToDraft?: boolean; } export interface WixDataBulkCreateDataItemDraftsOptions { /** Whether to return the created draft items. Default: `false`. */ returnEntity?: boolean; } export interface WixDataBulkPublishDataItemDraftsOptions { /** Whether to return the published items. Default: `false`. */ returnEntity?: boolean; } export interface WixDataBulkUnpublishDataItemsOptions { /** Whether to create draft copies of the unpublished items. Default: `true`. */ copyToDraft?: boolean; /** Whether to return the resulting draft items. Default: `false`. */ returnEntity?: boolean; } export interface WixDataBulkDraftResult { /** Per-item results, in request order. */ results?: { itemMetadata?: ItemMetadata; dataItem?: WixDataItem; }[]; /** Aggregate success and failure counts. */ bulkActionMetadata?: BulkActionMetadata; } export interface WixDataRemoveOptions { /** * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). * * Default: `false`. */ suppressHooks?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. * @internal */ showDrafts?: boolean; /** * If provided, item will be updated only if condition is met. */ condition?: WixDataFilterInput; } export interface WixDataOptions extends BaseOptions, WithAppOptions { } export interface WixDataReadOptions extends WixDataOptions, WithAppOptions { /** * Language to translate result text into, in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. * If provided, the result text is returned in the specified language. If not provided, the result text is not translated. * * > **Note:** Translation for the specified language must be enabled for the collection in [Wix Multilingual](https://www.wix.com/app-market/wix-multilingual). * */ language?: string; /** * When `true`, reads data from the primary database instance. This decreases performance but ensures data retrieved is * up-to-date even immediately after an update. Learn more about [Wix Data and eventual consistency](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency). */ consistentRead?: boolean; } export interface WixDataIsReferencedOptions { /** * When `true`, reads data from the primary database instance. This decreases performance but ensures data retrieved is * up-to-date even immediately after an update. Learn more about [Wix Data and eventual consistency](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency). */ consistentRead?: boolean; } /** * Options for standalone count queries. * @internal */ export interface WixDataCountOptions { /** * Filter object. Supports operators like `$eq`, `$ne`, `$lt`, `$lte`, `$gt`, `$gte`, * `$in`, `$hasSome`, `$hasAll`, `$startsWith`, `$contains`. * * Example: * ```js * { status: 'active', age: { $gt: 25 } } * ``` */ filter?: Record; /** * When `true`, reads data from the primary database instance. This decreases performance but ensures data retrieved is * up-to-date even immediately after an update. Learn more about [Wix Data and eventual consistency](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency). */ consistentRead?: boolean; /** * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). * * Default: `false`. */ suppressHooks?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. * @internal */ showDrafts?: boolean; /** * Options for [querying Wix app collections](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/querying-wix-app-collections). */ appOptions?: Record; /** * Language to translate result text into, in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. * If provided, the result text is returned in the specified language. If not provided, the result text is not translated. * * > **Note:** Translation for the specified language must be enabled for the collection in [Wix Multilingual](https://www.wix.com/app-market/wix-multilingual). * */ language?: string; } export interface WixDataReadWithProjectionOptions extends WixDataReadOptions, ProjectionOptions, IncludeReferencesOptions { } export interface WithIncludeFieldGroupsOption { /** * Requests conditional fields. Currently used in App Collections. * Please refer to app collection documentation for a list of valid values. */ includeFieldGroups?: string[]; } export interface WixDataGetOptions { /** * Lists of fields to return in a result. */ fields?: string[]; /** * Reference fields to resolve in the results. When specified, the referenced items * are included in the response for the given fields. * * Each entry identifies a reference `field` by name and an optional `limit` that caps the number * of referenced items returned per queried item (relevant for multi-reference fields). */ includeReferences?: { field: string; limit?: number; }[]; /** * Requests conditional fields. Currently used in App Collections. * Please refer to app collection documentation for a list of valid values. */ includeFieldGroups?: string[]; /** * Language to translate result text into, in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. * If provided, the result text is returned in the specified language. If not provided, the result text is not translated. * * > **Note:** Translation for the specified language must be enabled for the collection in [Wix Multilingual](https://www.wix.com/app-market/wix-multilingual). * */ language?: string; /** * When `true`, reads data from the primary database instance. This decreases performance but ensures data retrieved is * up-to-date even immediately after an update. Learn more about [Wix Data and eventual consistency](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency). */ consistentRead?: boolean; /** * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). * * Default: `false`. */ suppressHooks?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. */ showDrafts?: boolean; /** * Options for [querying Wix app collections](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/querying-wix-app-collections). */ appOptions?: Record; } export interface WixDataSaveOptions { /** * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). * * Default: `false`. */ suppressHooks?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. * @internal */ showDrafts?: boolean; /** * If true, referenced items are included. * @internal */ includeReferences?: boolean; /** Whether to save references from the data item to other items in the collection. */ saveReferences?: boolean; } export interface WixDataInsertOptions { /** * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). * * Default: `false`. */ suppressHooks?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. * @internal */ showDrafts?: boolean; /** * If true, referenced items are included. * @internal */ includeReferences?: boolean; /** Whether to save references from the data item to other items in the collection. */ saveReferences?: boolean; } export interface WixDataUpdateOptions { /** * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). * * Default: `false`. */ suppressHooks?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. * @internal */ showDrafts?: boolean; /** * If true, referenced items are included. * @internal */ includeReferences?: boolean; /** Whether to save references from the data item to other items in the collection. */ saveReferences?: boolean; /** * If provided, item will be updated only if condition is met. */ condition?: WixDataFilterInput; } export interface WixDataBulkUpdateOptions { /** * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). * * Default: `false`. */ suppressHooks?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. * @internal */ showDrafts?: boolean; /** Whether to save references from the data items to other items in the collection. */ saveReferences?: boolean; /** * If provided, only items matching condition will be updated. */ condition?: WixDataFilterInput; } export interface WixDataBulkInsertOptions { /** * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). * * Default: `false`. */ suppressHooks?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. * @internal */ showDrafts?: boolean; /** Whether to save references from the data items to other items in the collection. */ saveReferences?: boolean; /** * Whether to update existing items with the same ID. * @internal */ overrideExisting?: boolean; } export interface WixDataBulkSaveOptions { /** * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). * * Default: `false`. */ suppressHooks?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. * @internal */ showDrafts?: boolean; /** Whether to save references from the data items to other items in the collection. */ saveReferences?: boolean; } export interface WixDataBulkRemoveOptions { /** * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). * * Default: `false`. */ suppressHooks?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. * @internal */ showDrafts?: boolean; /** * If provided, only items matching condition will be removed. */ condition?: WixDataFilterInput; } export interface WixDataAsyncByFilterOptions extends BaseOptions { } export interface WixDataAsyncRemoveByFilterOptions { /** * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). * * Default: `false`. */ suppressHooks?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. * @internal */ showDrafts?: boolean; } export interface WixDataAsyncPatchByFilterOptions { /** * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). * * Default: `false`. */ suppressHooks?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. * @internal */ showDrafts?: boolean; } export type WixDataFilterInput = WixDataFilter | Record; export interface WixDataAsyncJob { /** Job ID for tracking the async operation. */ jobId: string; } export interface WixDataAsyncRemoveByFilterResponse { /** Job ID for tracking the async operation. */ jobId: string; } export interface WixDataAsyncPatchByFilterResponse { /** Job ID for tracking the async operation. */ jobId: string; } export type WixDataAsyncJobStatusValue = 'UNKNOWN_STATUS' | 'INITIALIZED' | 'PROCESSING' | 'SUCCEEDED' | 'FAILED'; export interface WixDataAsyncJobStatus { /** Current status of the async operation. */ status?: WixDataAsyncJobStatusValue; /** Number of items successfully processed so far. */ successCount?: number; } export interface WixDataAggregateOptions { /** * Language to translate result text into, in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. * If provided, the result text is returned in the specified language. If not provided, the result text is not translated. * * > **Note:** Translation for the specified language must be enabled for the collection in [Wix Multilingual](https://www.wix.com/app-market/wix-multilingual). * */ language?: string; /** * When `true`, reads data from the primary database instance. This decreases performance but ensures data retrieved is * up-to-date even immediately after an update. Learn more about [Wix Data and eventual consistency](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency). */ consistentRead?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. * @internal */ showDrafts?: boolean; /** * When `true`, the query results include a `totalCount` and `totalPages` properties containing the totals of items * matching query. Requesting total count slows down the query. * * Default: `false` */ returnTotalCount?: boolean; } /** * Options for standalone distinct field value queries. * @internal */ export interface WixDataDistinctOptions { /** * Filter object. Supports operators like `$eq`, `$ne`, `$lt`, `$lte`, `$gt`, `$gte`, * `$in`, `$hasSome`, `$hasAll`, `$startsWith`, `$contains`. * * Example: * ```js * { status: 'active', age: { $gt: 25 } } * ``` */ filter?: Record; /** * Language to translate result text into, in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. * If provided, the result text is returned in the specified language. If not provided, the result text is not translated. * * > **Note:** Translation for the specified language must be enabled for the collection in [Wix Multilingual](https://www.wix.com/app-market/wix-multilingual). * */ language?: string; /** * When `true`, reads data from the primary database instance. This decreases performance but ensures data retrieved is * up-to-date even immediately after an update. Learn more about [Wix Data and eventual consistency](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency). */ consistentRead?: boolean; /** * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). * * Default: `false`. */ suppressHooks?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. * @internal */ showDrafts?: boolean; /** * Options for [querying Wix app collections](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/querying-wix-app-collections). */ appOptions?: Record; /** * When `true`, the response includes the total number of distinct values for the requested field that match the filter. * Requesting a total count may slow down the query. * * Default: `false` */ returnTotalCount?: boolean; /** * Sort order for the returned distinct values. * * Default: `ASC`. */ order?: SortOrder; /** * Offset-based paging settings for the returned distinct values. */ paging?: { /** Maximum number of distinct values to return. */ limit?: number; /** Number of distinct values to skip before returning results. */ offset?: number; }; /** * Cursor-based paging settings for the returned distinct values. * Use this as an alternative to offset-based paging. */ cursorPaging?: { /** Cursor token that points to the next page of distinct values. */ cursor?: string; /** Maximum number of distinct values to return. */ limit?: number; }; } /** * WixData query specification. * Since WixData collections are dynamic, we allow any string field. * @internal */ export interface WixDataQuerySpec extends QuerySpec { wql: [ { fields: string[]; sort: 'BOTH'; } ]; paging: 'offset'; } /** * Request object for direct query execution. * Extends the SDK's QueryRequest with WixData-specific fields. * Use this with `wixData.query(collectionName, queryRequest)` for one-shot queries. * @internal */ export interface WixDataQueryRequest extends Omit, 'filter'> { /** * Filter object. Supports operators like `$eq`, `$ne`, `$lt`, `$lte`, `$gt`, `$gte`, * `$in`, `$hasSome`, `$hasAll`, `$startsWith`, `$contains`. * * Example: * ```js * { status: 'active', age: { $gt: 25 } } * ``` */ filter?: Record; /** * Cursor-based paging. Use this as an alternative to offset paging. * * Example: * ```js * { limit: 10, cursor: 'abc123' } * ``` */ cursorPaging?: { /** Maximum number of items to return. */ limit?: number; /** Cursor token pointing to a page of results. */ cursor?: string; }; } export interface WixDataQueryOptions { /** * Reference fields to resolve in the results. When specified, the referenced items * are included in the response for the given fields. * * Each entry identifies a reference `field` by name and an optional `limit` that caps the number * of referenced items returned per queried item (relevant for multi-reference fields). */ includeReferences?: { field: string; limit?: number; }[]; /** * Language to translate result text into, in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. * If provided, the result text is returned in the specified language. If not provided, the result text is not translated. * * > **Note:** Translation for the specified language must be enabled for the collection in [Wix Multilingual](https://www.wix.com/app-market/wix-multilingual). * */ language?: string; /** * When `true`, reads data from the primary database instance. This decreases performance but ensures data retrieved is * up-to-date even immediately after an update. Learn more about [Wix Data and eventual consistency](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency). */ consistentRead?: boolean; /** * Prevents hooks from running for the operation. Can only be used in the [backend code of a Wix site](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/backend-code/about-the-site-backend). * * Default: `false`. */ suppressHooks?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. * @inline */ showDrafts?: boolean; /** * Options for [querying Wix app collections](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/querying-wix-app-collections). */ appOptions?: Record; /** * When `true`, the query results include a total count property containing the totals of items * matching query. Requesting total count slows down the query. * * Default: `false` */ returnTotalCount?: boolean; /** * Requests conditional fields. Currently used in App Collections. * Please refer to app collection documentation for a list of valid values. */ includeFieldGroups?: string[]; } /** * Request object for direct search execution. * Matches the shape produced by `SearchBuilder().build()` so it can be passed directly. * Use this with `wixData.search(collectionName, searchRequest)` for direct search execution. * @internal */ export interface WixDataSearchRequest { /** Search parameters. */ search?: { /** Search text expression. */ expression?: string | null; /** Whether to enable fuzzy matching. */ fuzzy?: boolean | null; /** Search mode: 'OR' (any term) or 'AND' (all terms). */ mode?: 'OR' | 'AND' | null; }; /** Filter object. */ filter?: Record; /** Sort array. */ sort?: { fieldName: string; order?: 'ASC' | 'DESC'; }[]; /** Fields to return in results. */ fields?: string[]; /** Paging options. */ paging?: { limit?: number; offset?: number; }; /** Cursor-based paging. */ cursorPaging?: { cursor?: string; limit?: number; }; } /** * Options for direct search execution. * @internal */ export interface WixDataSearchOptions { /** * Reference fields to resolve in the results. When specified, the referenced items * are included in the response for the given fields. * * Each entry identifies a reference `field` by name and an optional `limit` that caps the number * of referenced items returned per queried item (relevant for multi-reference fields). */ includeReferences?: { field: string; limit?: number; }[]; /** * Language to translate result text into, in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. * If provided, the result text is returned in the specified language. If not provided, the result text is not translated. * * > **Note:** Translation for the specified language must be enabled for the collection in [Wix Multilingual](https://www.wix.com/app-market/wix-multilingual). * */ language?: string; } export interface WixDataQueryReferencedOptions extends WixDataQueryOptions, ProjectionOptions { /** * Order of the returned referenced items. Sorted by the date each item was referenced. * * Default: `asc` */ order?: 'asc' | 'desc'; /** * Number of items to skip in the current sort order. * * Default: `0` */ skip?: number; /** * Number of items to load. * * Default: `50` */ limit?: number; } export interface WixDataQueryReferencedItemsOptions { /** * Language to translate result text into, in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. * If provided, the result text is returned in the specified language. If not provided, the result text is not translated. * * > **Note:** Translation for the specified language must be enabled for the collection in [Wix Multilingual](https://www.wix.com/app-market/wix-multilingual). * */ language?: string; /** * When `true`, reads data from the primary database instance. This decreases performance but ensures data retrieved is * up-to-date even immediately after an update. Learn more about [Wix Data and eventual consistency](https://dev.wix.com/docs/sdk/backend-modules/data/eventual-consistency). */ consistentRead?: boolean; /** * When `true`, operations include draft items. Read operations include draft items in their response, and write operations modify draft items. * * Default: `false`. * @inline */ showDrafts?: boolean; /** * Options for [querying Wix app collections](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/querying-wix-app-collections). */ appOptions?: Record; /** * When `true`, the query results include a total count property containing the totals of items * matching query. Requesting total count slows down the query. * * Default: `false` */ returnTotalCount?: boolean; /** * Lists of fields to return in a result. */ fields?: string[]; /** * Order of the returned referenced items. Sorted by the date each item was referenced. */ order?: SortOrder; /** * Offset-based paging settings for the returned referenced items. */ paging?: { /** Maximum number of items to return. */ limit?: number; /** Number of items to skip before returning results. */ offset?: number; }; /** * Cursor-based paging settings for the returned distinct values. * Use this as an alternative to offset-based paging. */ cursorPaging?: { /** Cursor token that points to the next page of items. */ cursor?: string; /** Maximum number of items to return. */ limit?: number; }; } interface ProjectionOptions { /** * Lists of fields to return in a result. */ fields?: string[]; } export interface WithId { /** * Data item ID. */ _id: string; } export interface WixDataItem extends WithId { /** * Date and time the item was added to the collection. * @readonly */ _createdDate?: Date; /** * Date and time the item was last modified. When the item is first inserted, `_createdDate` and `_updatedDate` have * the same value. * @readonly */ _updatedDate?: Date; /** * ID of the user who created the item. Can be modified with site owner permissions. */ _owner?: string; /** * Data item contents. */ [key: string]: any; } export type WixDataItemOrId = Item | string; export type Comparable = string | number | Date; export interface WixDataReference { relationshipName: string; left: WixDataItemOrId; right: WixDataItemOrId; } export interface Provider { get(): T | Promise; } export interface WixDataBulkError extends Error { /** * Description of the error. */ message: string; /** * Error code. */ code: string; /** * Index of the item within the request array. Allows for correlation between request and response items. */ originalIndex: number; /** * Failed item (or ID in case of `bulkRemove()`). */ item: WixDataItem | string; } export interface WixDataBulkResult { /** * Number of inserted items. */ inserted: number; /** * Number of updated items. */ updated: number; /** * Number of removed items. */ removed: number; /** * Number of skipped items. */ skipped: number; /** * List of errors. */ errors: WixDataBulkError[]; /** * List of IDs of inserted items. */ insertedItemIds: string[]; /** * List of IDs of updated items. */ updatedItemIds: string[]; /** * List of IDs of removed items. */ removedItemIds: string[]; } export {}; //# sourceMappingURL=types.d.ts.map