import { NonNullablePaths } from '@wix/sdk-types'; /** Background task job that processes data items in bulk. */ interface Task extends TaskOptionsOneOf { /** * Options for tasks of the type `DELETE_BY_QUERY`. * @immutable */ deleteByQueryOptions?: DeleteByQueryOptions; /** * Options for tasks of the type `COPY_FIELD_DATA`. * @immutable */ copyFieldDataOptions?: CopyFieldDataOptions; /** * Options for tasks of the type `EDIT_FIELD_DATA`. * @immutable */ editFieldDataOptions?: EditFieldDataOptions; /** * Options for tasks of the type `UPDATE_PUBLISH_STATUS`. * @immutable */ updatePublishStatusOptions?: UpdatePublishStatusOptions; /** * Task ID. * @format GUID * @readonly */ _id?: string; /** * Task type. * @immutable */ type?: TypeWithLiterals; /** * Task status. * @readonly */ status?: StatusWithLiterals; /** * Task start time. Empty if the task status is `NEW`. * @readonly */ startedAt?: Date | null; /** * Task finish time. Empty until the task status updates to `COMPLETED` or `FAILED`. * @readonly */ finishedAt?: Date | null; /** * Number of items whose processing failed. * @readonly */ itemsFailed?: number; /** * List of errors generated during the task. * * Learn more about [Wix Data error codes](https://dev.wix.com/docs/sdk/backend-modules/data/wix-data-error-codes). * @maxSize 100 * @readonly */ failures?: ApplicationError[]; /** * Estimated number of items affected by the task. * @readonly */ estimatedItemCount?: number; /** * Number of items successfully processed so far. * @readonly */ itemsSucceeded?: number; } /** @oneof */ interface TaskOptionsOneOf { /** * Options for tasks of the type `DELETE_BY_QUERY`. * @immutable */ deleteByQueryOptions?: DeleteByQueryOptions; /** * Options for tasks of the type `COPY_FIELD_DATA`. * @immutable */ copyFieldDataOptions?: CopyFieldDataOptions; /** * Options for tasks of the type `EDIT_FIELD_DATA`. * @immutable */ editFieldDataOptions?: EditFieldDataOptions; /** * Options for tasks of the type `UPDATE_PUBLISH_STATUS`. * @immutable */ updatePublishStatusOptions?: UpdatePublishStatusOptions; } declare enum Type { /** Deletes all items that match the specified filter. */ DELETE_BY_QUERY = "DELETE_BY_QUERY", /** Copies data from one field to another for all items in the collection. */ COPY_FIELD_DATA = "COPY_FIELD_DATA", /** Updates field data for items that match the specified filter. */ EDIT_FIELD_DATA = "EDIT_FIELD_DATA", /** In collections that have the Publish plugin, updates the publish status of items that match the specified filter. */ UPDATE_PUBLISH_STATUS = "UPDATE_PUBLISH_STATUS" } /** @enumType */ type TypeWithLiterals = Type | 'DELETE_BY_QUERY' | 'COPY_FIELD_DATA' | 'EDIT_FIELD_DATA' | 'UPDATE_PUBLISH_STATUS'; declare enum Status { /** Task was created but has not started. */ NEW = "NEW", /** Task is currently running. */ RUNNING = "RUNNING", /** Task has completed. Partial errors are listed in `failures`. */ COMPLETED = "COMPLETED", /** * Task has failed. Tasks can fail due to errors or because they were cancelled. * * Failures are listed in `failures`. Cancelled tasks have a failure `code` value of `CANCELLED`, and no associated failure `data`. */ FAILED = "FAILED" } /** @enumType */ type StatusWithLiterals = Status | 'NEW' | 'RUNNING' | 'COMPLETED' | 'FAILED'; interface ApplicationError { /** Error code. */ code?: string; /** Description of the error. */ description?: string; /** Data related to the error. */ data?: Record | null; } interface DeleteByQueryOptions { /** * ID of the collection from which to delete the items that match the filter. * @maxLength 255 */ dataCollectionId?: string; /** * [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing) from which to delete item. * * Default: `LIVE`. */ environment?: EnvironmentWithLiterals; /** * Query filter. If not specified, all items are deleted. * * Learn about working with [API query language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language). */ filter?: Record | null; /** * Additional options specific to the [Wix app collection](https://support.wix.com/en/article/cms-formerly-content-manager-working-with-wix-app-collections) you are querying. * * Learn more about [querying Wix app collections](https://dev.wix.com/docs/develop-websites/articles/wix-apps/wix-app-collections/querying-wix-app-collections). */ appOptions?: Record | null; /** * Options for the [Publish plugin](https://support.wix.com/en/article/cms-controlling-live-site-item-visibility-from-your-collection). * * This plugin allows items in a [data collection](https://dev.wix.com/docs/rest/business-solutions/cms/data-collections/data-collection-object) to be marked as draft or published. Published items are visible to site visitors, while draft items are not. */ publishPluginOptions?: PublishPluginOptions; } declare enum Environment { /** Collection [sandbox environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections). */ SANDBOX = "SANDBOX", /** If the [collection's sandbox environment is enabled](https://support.wix.com/en/article/cms-accessing-and-syncing-your-sandbox-and-live-collections#enabling-sandbox-collections), run the task in the collection's sandbox environment. If not, run the task in the collection's live environment. */ SANDBOX_PREFERRED = "SANDBOX_PREFERRED", /** Collection [live environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#live-collections). */ LIVE = "LIVE" } /** @enumType */ type EnvironmentWithLiterals = Environment | 'SANDBOX' | 'SANDBOX_PREFERRED' | 'LIVE'; interface PublishPluginOptions { /** * Whether to include draft items. * * When `true`, both published and draft items are affected. Default: `false`. */ includeDraftItems?: boolean; } interface CopyFieldDataOptions { /** * ID of the collection in which to copy and write item field data. * @maxLength 255 */ dataCollectionId?: string; /** * [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections) in which to copy and write field data. * * Default: `LIVE`. */ environment?: EnvironmentWithLiterals; /** * ID of the field to copy data from. * @maxLength 255 */ sourceFieldKey?: string; /** * ID of the field to copy data to. * @maxLength 255 */ targetFieldKey?: string; } interface EditFieldDataOptions { /** * ID of the collection in which to edit the specified field. * @maxLength 255 */ dataCollectionId?: string; /** * [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections) in which to edit the specified field. * * Default: `LIVE`. */ environment?: EnvironmentWithLiterals; /** * Query filter. Only items that match the filter are edited. * * Learn about working with [API query language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language). */ filter?: Record | null; /** * ID of the field to update. * @maxLength 255 */ fieldKey?: string; /** Operations to perform on the specified field. */ operations?: Operations; } interface Replace { /** Value or array element to replace. */ from?: any; /** Value or array element to replace with. */ to?: any; } interface Operations { /** * Add elements to a field of type Array. * * Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type). * @maxSize 64 */ addItems?: any[]; /** * Remove elements from a field of type Array. * * Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type). * @maxSize 64 */ removeItems?: any[]; /** * In a field of type Array, replace all matching elements. In a field of another type, replace all matching values. * * Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type). * @maxSize 64 */ replaceItems?: Replace[]; /** * In a field of type Array, remove duplicate elements. Default: `false`. * * Learn more about [field types](https://support.wix.com/en/article/cms-formerly-content-manager-about-your-collection-fields#field-type). */ removeDuplicates?: boolean; } interface UpdatePublishStatusOptions extends UpdatePublishStatusOptionsOptionsOneOf { /** In a `SCHEDULE_DRAFT_STATUS` operation, options for scheduling the status update to `DRAFT`. */ scheduleDraftStatusOptions?: ScheduleOperation; /** In a `SCHEDULE_PUBLISHED_STATUS` operation, options for scheduling the status update to `PUBLISHED`. */ schedulePublishedStatusOptions?: ScheduleOperation; /** * ID of the collection whose items' publish status is to be updated. * @maxLength 255 */ dataCollectionId?: string; /** * [Collection environment](https://support.wix.com/en/article/cms-about-sandbox-and-live-collections-and-syncing#sandbox-collections) in which to update the publish status of the items. * * Default: `LIVE`. */ environment?: EnvironmentWithLiterals; /** * Query filter. If not specified, the publish status of all items is updated. * * Learn about working with [API query language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language). */ filter?: Record | null; /** Publish status update operation. */ operation?: OperationWithLiterals; } /** @oneof */ interface UpdatePublishStatusOptionsOptionsOneOf { /** In a `SCHEDULE_DRAFT_STATUS` operation, options for scheduling the status update to `DRAFT`. */ scheduleDraftStatusOptions?: ScheduleOperation; /** In a `SCHEDULE_PUBLISHED_STATUS` operation, options for scheduling the status update to `PUBLISHED`. */ schedulePublishedStatusOptions?: ScheduleOperation; } declare enum Operation { /** Update the publish status of all items that match the filter to `PUBLISHED`. */ SET_PUBLISHED_STATUS = "SET_PUBLISHED_STATUS", /** Update the publish status of all items that match the filter to `DRAFT`. */ SET_DRAFT_STATUS = "SET_DRAFT_STATUS", /** Schedule when to update the publish status of all items that match the filter to `PUBLISHED`. */ SCHEDULE_PUBLISHED_STATUS = "SCHEDULE_PUBLISHED_STATUS", /** Schedule when to update the publish status of all items that match the filter to `DRAFT`. */ SCHEDULE_DRAFT_STATUS = "SCHEDULE_DRAFT_STATUS", /** Cancel all scheduled status updates. */ CANCEL_SCHEDULING = "CANCEL_SCHEDULING" } /** @enumType */ type OperationWithLiterals = Operation | 'SET_PUBLISHED_STATUS' | 'SET_DRAFT_STATUS' | 'SCHEDULE_PUBLISHED_STATUS' | 'SCHEDULE_DRAFT_STATUS' | 'CANCEL_SCHEDULING'; interface ScheduleOperation { /** When to update the item's publish status. */ date?: Date | null; } interface CreateTaskRequest { /** Task to create and run. */ task: Task; } interface CreateTaskResponse { /** Created task. */ task?: Task; } interface ListTasksRequest { /** * Paginating information. This has the following default values: * - `limit`: 30 * - `offset`: 0 */ paging?: Paging; } interface Paging { /** Number of items to load. */ limit?: number | null; /** Number of items to skip in the current sort order. */ offset?: number | null; } interface ListTasksResponse { /** Retrieved tasks. */ tasks?: Task[]; /** Paging metadata. */ metadata?: PagingMetadataV2; } interface PagingMetadataV2 { /** Number of items returned in the response. */ count?: number | null; /** Offset that was requested. */ offset?: number | null; /** Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set. */ total?: number | null; /** Flag that indicates the server failed to calculate the `total` field. */ tooManyToCount?: boolean | null; /** Cursors to navigate through the result pages using `next` and `prev`. Returned if cursor paging is used. */ cursors?: Cursors; } interface Cursors { /** * Cursor string pointing to the next page in the list of results. * @maxLength 16000 */ next?: string | null; /** * Cursor pointing to the previous page in the list of results. * @maxLength 16000 */ prev?: string | null; } interface GetTaskRequest { /** * Task ID. * @format GUID */ taskId: string; } interface GetTaskResponse { /** Retrieved task. */ task?: Task; } interface CancelTaskRequest { /** * Task ID. * @format GUID */ taskId: string; } interface CancelTaskResponse { /** Cancelled task. */ task?: Task; } interface DomainEvent extends DomainEventBodyOneOf { createdEvent?: EntityCreatedEvent; updatedEvent?: EntityUpdatedEvent; deletedEvent?: EntityDeletedEvent; actionEvent?: ActionEvent; /** Event ID. With this ID you can easily spot duplicated events and ignore them. */ _id?: string; /** * Fully Qualified Domain Name of an entity. This is a unique identifier assigned to the API main business entities. * For example, `wix.stores.catalog.product`, `wix.bookings.session`, `wix.payments.transaction`. */ entityFqdn?: string; /** * Event action name, placed at the top level to make it easier for users to dispatch messages. * For example: `created`/`updated`/`deleted`/`started`/`completed`/`email_opened`. */ slug?: string; /** ID of the entity associated with the event. */ entityId?: string; /** Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example, `2020-04-26T13:57:50.699Z`. */ eventTime?: Date | null; /** * Whether the event was triggered as a result of a privacy regulation application * (for example, GDPR). */ triggeredByAnonymizeRequest?: boolean | null; /** If present, indicates the action that triggered the event. */ originatedFrom?: string | null; /** * A sequence number that indicates the order of updates to an entity. For example, if an entity was updated at 16:00 and then again at 16:01, the second update will always have a higher sequence number. * You can use this number to make sure you're handling updates in the right order. Just save the latest sequence number on your end and compare it to the one in each new message. If the new message has an older (lower) number, you can safely ignore it. */ entityEventSequence?: string | null; } /** @oneof */ interface DomainEventBodyOneOf { createdEvent?: EntityCreatedEvent; updatedEvent?: EntityUpdatedEvent; deletedEvent?: EntityDeletedEvent; actionEvent?: ActionEvent; } interface EntityCreatedEvent { entity?: string; } interface RestoreInfo { deletedDate?: Date | null; } interface EntityUpdatedEvent { /** * Since platformized APIs only expose PATCH and not PUT we can't assume that the fields sent from the client are the actual diff. * This means that to generate a list of changed fields (as opposed to sent fields) one needs to traverse both objects. * We don't want to impose this on all developers and so we leave this traversal to the notification recipients which need it. */ currentEntity?: string; } interface EntityDeletedEvent { /** Entity that was deleted. */ deletedEntity?: string | null; } interface ActionEvent { body?: string; } interface MessageEnvelope { /** * App instance ID. * @format GUID */ instanceId?: string | null; /** * Event type. * @maxLength 150 */ eventType?: string; /** The identification type and identity data. */ identity?: IdentificationData; /** Stringify payload. */ data?: string; /** Details related to the account */ accountInfo?: AccountInfo; } interface IdentificationData extends IdentificationDataIdOneOf { /** * ID of a site visitor that has not logged in to the site. * @format GUID */ anonymousVisitorId?: string; /** * ID of a site visitor that has logged in to the site. * @format GUID */ memberId?: string; /** * ID of a Wix user (site owner, contributor, etc.). * @format GUID */ wixUserId?: string; /** * ID of an app. * @format GUID */ appId?: string; /** @readonly */ identityType?: WebhookIdentityTypeWithLiterals; } /** @oneof */ interface IdentificationDataIdOneOf { /** * ID of a site visitor that has not logged in to the site. * @format GUID */ anonymousVisitorId?: string; /** * ID of a site visitor that has logged in to the site. * @format GUID */ memberId?: string; /** * ID of a Wix user (site owner, contributor, etc.). * @format GUID */ wixUserId?: string; /** * ID of an app. * @format GUID */ appId?: string; } declare enum WebhookIdentityType { UNKNOWN = "UNKNOWN", ANONYMOUS_VISITOR = "ANONYMOUS_VISITOR", MEMBER = "MEMBER", WIX_USER = "WIX_USER", APP = "APP" } /** @enumType */ type WebhookIdentityTypeWithLiterals = WebhookIdentityType | 'UNKNOWN' | 'ANONYMOUS_VISITOR' | 'MEMBER' | 'WIX_USER' | 'APP'; interface AccountInfo { /** * ID of the Wix account associated with the event. * @format GUID */ accountId?: string | null; /** * ID of the parent Wix account. Only included when accountId belongs to a child account. * @format GUID */ parentAccountId?: string | null; /** * ID of the Wix site associated with the event. Only included when the event is tied to a specific site. * @format GUID */ siteId?: string | null; } /** * Creates and runs a new background task. * @param task - Task to create and run. * @public * @requiredField task * @requiredField task.options * @requiredField task.options.copyFieldDataOptions.dataCollectionId * @requiredField task.options.copyFieldDataOptions.sourceFieldKey * @requiredField task.options.copyFieldDataOptions.targetFieldKey * @requiredField task.options.editFieldDataOptions.dataCollectionId * @requiredField task.options.editFieldDataOptions.fieldKey * @requiredField task.options.updatePublishStatusOptions.dataCollectionId * @requiredField task.options.updatePublishStatusOptions.operation * @requiredField task.type * @permissionId AUTOCMS.TASK_CREATE * @permissionId AUTOCMS.TASK_DELETE_BY_QUERY * @permissionId AUTOCMS.TASK_UPDATE_DRAFT_PUBLISH * @permissionId AUTOCMS.TASK_COPY_FIELD_DATA * @permissionId AUTOCMS.TASK_EDIT_FIELD_DATA * @applicableIdentity APP * @returns Created task. * @fqn wix.cloud.autocms.tasks.v1.TaskService.CreateTask */ declare function createTask(task: NonNullablePaths): Promise>; /** * Lists all existing tasks. * @public * @permissionId AUTOCMS.TASK_READ * @applicableIdentity APP * @fqn wix.cloud.autocms.tasks.v1.TaskService.ListTasks */ declare function listTasks(options?: ListTasksOptions): Promise>; interface ListTasksOptions { /** * Paginating information. This has the following default values: * - `limit`: 30 * - `offset`: 0 */ paging?: Paging; } /** * Retrieves the specified task. * @param taskId - Task ID. * @public * @requiredField taskId * @permissionId AUTOCMS.TASK_READ * @applicableIdentity APP * @returns Retrieved task. * @fqn wix.cloud.autocms.tasks.v1.TaskService.GetTask */ declare function getTask(taskId: string): Promise>; /** * Cancels an existing task. * @param taskId - Task ID. * @public * @requiredField taskId * @permissionId AUTOCMS.TASK_CANCEL * @applicableIdentity APP * @fqn wix.cloud.autocms.tasks.v1.TaskService.CancelTask */ declare function cancelTask(taskId: string): Promise>; export { type AccountInfo, type ActionEvent, type ApplicationError, type CancelTaskRequest, type CancelTaskResponse, type CopyFieldDataOptions, type CreateTaskRequest, type CreateTaskResponse, type Cursors, type DeleteByQueryOptions, type DomainEvent, type DomainEventBodyOneOf, type EditFieldDataOptions, type EntityCreatedEvent, type EntityDeletedEvent, type EntityUpdatedEvent, Environment, type EnvironmentWithLiterals, type GetTaskRequest, type GetTaskResponse, type IdentificationData, type IdentificationDataIdOneOf, type ListTasksOptions, type ListTasksRequest, type ListTasksResponse, type MessageEnvelope, Operation, type OperationWithLiterals, type Operations, type Paging, type PagingMetadataV2, type PublishPluginOptions, type Replace, type RestoreInfo, type ScheduleOperation, Status, type StatusWithLiterals, type Task, type TaskOptionsOneOf, Type, type TypeWithLiterals, type UpdatePublishStatusOptions, type UpdatePublishStatusOptionsOptionsOneOf, WebhookIdentityType, type WebhookIdentityTypeWithLiterals, cancelTask, createTask, getTask, listTasks };