import { ServicePluginDefinition } from '@wix/sdk-types'; /** Dummy entity. */ interface MainEntity { /** * Dummy ID. * @readonly * @format GUID */ _id?: string; } interface QueryDataItemsRequest { /** ID of the collection to query. */ collectionId: string; /** Query preferences. See [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language) for information about handling data queries. */ query: QueryV2; /** * Fields for which to include the full referenced items in the query's results, rather than just their IDs. * Returned items are sorted in ascending order by the creation date of the reference. * If the field being querried is a multi-reference field and the array is empty, the response does not return any items. */ includeReferencedItems?: ReferencedItemToInclude[]; /** Whether to retrieve data from the primary database instance. This decreases performance but ensures data retrieved is up-to-date even immediately after an update. Applicable if the external database is eventually consistent. */ consistentRead: boolean; /** When `true`, the query response must include the total number of items that match the query. */ returnTotalCount: boolean; } interface QueryV2 extends QueryV2PagingMethodOneOf { /** Paging options to limit and skip the number of items. Paging mode is defined when the collection is created. */ paging?: Paging; /** Cursor token pointing to a page of results. Not used in the first request. Following requests use the cursor token and not `filter` or `sort`. Paging mode is defined when the collection is created. */ cursorPaging?: CursorPaging; /** * Filter object in the following format: * `"filter" : { * "fieldName1": "value1", * "fieldName2":{"$operator":"value2"} * }` * Example of operators: `$eq`, `$ne`, `$lt`, `$lte`, `$gt`, `$gte`, `$in`, `$hasSome`, `$hasAll`, `$startsWith`, `$contains` * * **Note:** Your endpoint must properly handle requests with filtering preferences that adhere to Wix Data data types. For example, a query request that includes filtering by a field whose type is Date and Time would contain an object in the following format: `"someDateAndTimeFieldKey": { "$date": "YYYY-MM-DDTHH:mm:ss.sssZ"}`. Learn more about [data types in Wix Data](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/data-types-in-wix-data). */ filter?: Record | null; /** * Sort object in the following format: * `[{"fieldName":"sortField1","order":"ASC"},{"fieldName":"sortField2","order":"DESC"}]` */ sort?: Sorting[]; /** Array of projected fields. A list of specific field names to return. */ fields?: string[]; } /** @oneof */ interface QueryV2PagingMethodOneOf { /** Paging options to limit and skip the number of items. Paging mode is defined when the collection is created. */ paging?: Paging; /** Cursor token pointing to a page of results. Not used in the first request. Following requests use the cursor token and not `filter` or `sort`. Paging mode is defined when the collection is created. */ cursorPaging?: CursorPaging; } interface Sorting { /** Name of the field to sort by. */ fieldName?: string; /** Sort order. */ order?: SortOrder; } declare enum SortOrder { ASC = "ASC", DESC = "DESC" } interface Paging { /** Number of items to load. */ limit?: number | null; /** Number of items to skip in the current sort order. */ offset?: number | null; } interface CursorPaging { /** * Number of items to load. * @max 1000 */ limit?: number | null; /** * Pointer to the next or previous page in the list of results. * * You can get the relevant cursor token * from the `pagingMetadata` object in the previous call's response. * Not relevant for the first request. */ cursor?: string | null; } interface ReferencedItemToInclude { /** Field name in the referencing collection. */ fieldKey?: string; /** Maximum number of referenced items to return. */ limit?: number; /** Filter criteria to specify which items to include in the response. */ filter?: Record | null; } interface QueryDataItemsResponse { /** Retrieved items. */ items?: Record[] | null; /** Pagination information. */ pagingMetadata?: PagingMetadataV2; } interface PagingMetadataV2 { /** Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set. */ total?: number | null; /** Cursors to navigate through the result pages using `next` and `prev`. Returned if cursor paging is used. */ cursors?: Cursors; } interface Cursors { /** Cursor pointing to next page in the list of results. */ next?: string | null; /** Cursor pointing to previous page in the list of results. */ prev?: string | null; } interface ItemAlreadyExistsError { /** * ID of the item that already exists. * @maxLength 256 */ itemId?: string; } interface ItemNotFoundError { /** * ID of the item that was not found. * @maxLength 256 */ itemId?: string; } interface CollectionAlreadyExistsError { /** * ID of the collection that already exists. * @maxLength 256 */ collectionId?: string; } interface CollectionNotFoundError { /** * ID of the collection that was not found. * @maxLength 256 */ collectionId?: string; } interface ReferenceAlreadyExistsError { /** * ID of the referring item. * @maxLength 256 */ referringItemId?: string; /** * ID of the referenced item. * @maxLength 256 */ referencedItemId?: string; } interface ReferenceNotFoundError { /** * ID of the referring item. * @maxLength 256 */ referringItemId?: string; /** * ID of the referenced item. * @maxLength 256 */ referencedItemId?: string; } interface ValidationError { /** * Violations that caused the validation to fail. * @maxSize 100 */ violations?: ValidationViolation[]; } interface ValidationViolation { /** * Path to the invalid field that caused the violation. * @maxLength 1000 */ fieldPath?: string | null; /** * The rejected value. * @maxLength 1000 */ rejectedValue?: string | null; /** * Error message that describes the violation. * @maxLength 10000 */ message?: string; } interface CollectionChangeNotSupported { /** * Errors that caused the change to fail. Learn more about [errors](data/cloud-data-spi/proto-spi/docs/errors.md) in the External Database Connections service plugin. * @maxSize 100 */ errors?: CollectionChangeNotSupportedError[]; } interface CollectionChangeNotSupportedError { /** * Key of collection field that can't be changed. * @maxLength 250 */ fieldKey?: string | null; /** * Error message with additional details. * @maxLength 1000 */ message?: string; } interface CountDataItemsRequest { /** ID of the collection to query. */ collectionId: string; /** Filter to specify which items to count. See [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language#the-filter-section) for more information about handling data queries. */ filter: Record | null; /** Whether to retrieve data from the primary database instance. This decreases performance but ensures data retrieved is up-to-date even immediately after an update. Applicable if the external database is eventually consistent. */ consistentRead: boolean; } interface CountDataItemsResponse { /** Number of items that match the query. */ totalCount?: number; } interface AggregateDataItemsRequest extends AggregateDataItemsRequestPagingMethodOneOf { paging?: Paging; cursorPaging?: CursorPaging; /** ID of the collection on which to run the aggregation. */ collectionId: string; /** Filter to apply to the collection's data before aggregation. See [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language#the-filter-section) for more information about handling data queries. */ initialFilter?: Record | null; /** Aggregation to apply to the data. */ aggregation?: Aggregation; /** Filter to apply to the processed data after aggregation. See [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language#the-filter-section) for more information about handling data queries. */ finalFilter?: Record | null; /** Sorting configuration. */ sort?: Sorting[]; /** Whether to retrieve data from the primary database instance. This decreases performance but ensures data retrieved is up-to-date even immediately after an update. Applicable if the external database is eventually consistent. */ consistentRead: boolean; /** When `true`, the query response must include the total number of items that match the query. */ returnTotalCount: boolean; } /** @oneof */ interface AggregateDataItemsRequestPagingMethodOneOf { paging?: Paging; cursorPaging?: CursorPaging; } interface Operation extends OperationCalculateOneOf { /** Calculate the average value of a specified field for all items in the grouping. */ average?: Average; /** Calculate the minimum value of a specified field for all items in the grouping. */ min?: Min; /** Calculate the maximum value of a specified field for all items in the grouping. */ max?: Max; /** Calculate the sum of values of a specified field for all items in the grouping. */ sum?: Sum; /** Calculate the number of items in the grouping. */ itemCount?: Count; /** Name of the field that contains the results of the operation. */ resultFieldName?: string; } /** @oneof */ interface OperationCalculateOneOf { /** Calculate the average value of a specified field for all items in the grouping. */ average?: Average; /** Calculate the minimum value of a specified field for all items in the grouping. */ min?: Min; /** Calculate the maximum value of a specified field for all items in the grouping. */ max?: Max; /** Calculate the sum of values of a specified field for all items in the grouping. */ sum?: Sum; /** Calculate the number of items in the grouping. */ itemCount?: Count; } interface Average { /** Name of the field for which to calculate the average value. */ itemFieldName?: string; } interface Min { /** Name of the field for which to calculate the minimum value. */ itemFieldName?: string; } interface Max { /** Name of the field for which to calculate the maximum value. */ itemFieldName?: string; } interface Sum { /** Name of the field for which to calculate the sum. */ itemFieldName?: string; } interface Count { } interface Aggregation { /** Fields by which to group items for the aggregation, in the order they appear in the array. If empty, the aggregation must be applied to the entire collection. */ groupingFields?: string[]; /** Operations to carry out on the data in each grouping. */ operations?: Operation[]; } interface AggregateDataItemsResponse { /** Aggregation results. Each result must contain a field for each `groupingFields` value, and a field for each `operations.resultFieldName` value. */ items?: Record[] | null; /** Paging information. */ pagingMetadata?: PagingMetadataV2; } interface QueryDistinctValuesRequest extends QueryDistinctValuesRequestPagingMethodOneOf { paging?: Paging; cursorPaging?: CursorPaging; /** ID of the collection to query. */ collectionId: string; /** Filter to apply to the collection's data before aggregation. See [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language#the-filter-section) for more information about handling data queries. */ filter?: Record | null; /** Item field name for which to return all distinct values. */ fieldName: string; /** Order to by which to sort the results. Valid values are `ASC` and `DESC`. */ order?: SortOrder; /** Whether to retrieve data from the primary database instance. This decreases performance but ensures data retrieved is up-to-date even immediately after an update. Applicable if the external database is eventually consistent. */ consistentRead: boolean; /** When `true`, the query response must include the total number of items that match the query. */ returnTotalCount: boolean; } /** @oneof */ interface QueryDistinctValuesRequestPagingMethodOneOf { paging?: Paging; cursorPaging?: CursorPaging; } interface QueryDistinctValuesResponse { /** * List of distinct values contained in the field specified in `fieldName`. Values can be of any JSON type. * If the field is an array, values must be unwound, independent values. For example, if the field name contains `["a", "b", "c"]`, the result must contain `"a"`, `"b"` and `"c"` as separate values. */ distinctValues?: any[]; /** Paging information. */ pagingMetadata?: PagingMetadataV2; } interface InsertDataItemsRequest { /** ID of the collection in which to insert the items. */ collectionId: string; /** * Items to insert. * @minSize 1 */ items: Record[] | null; } interface InsertDataItemsResponse { /** Response must include either the inserted item or an error. */ results?: DataItemModificationResult[]; } interface DataItemModificationResult extends DataItemModificationResultResultOneOf { /** Item that was inserted, updated or removed. */ item?: Record | null; /** Error indicating why the operation failed for a particular item. Learn more about [error types](https://dev.wix.com/docs/rest/assets/data/external-database-spi/understanding-error-types-in-the-external-database-connections-spi) in the External Database Connections service plugin. */ error?: Error$1; } /** @oneof */ interface DataItemModificationResultResultOneOf { /** Item that was inserted, updated or removed. */ item?: Record | null; /** Error indicating why the operation failed for a particular item. Learn more about [error types](https://dev.wix.com/docs/rest/assets/data/external-database-spi/understanding-error-types-in-the-external-database-connections-spi) in the External Database Connections service plugin. */ error?: Error$1; } interface Error$1 { /** * Error code. * @minLength 3 * @maxLength 100 */ errorCode?: string; /** * Error description. * @maxLength 10000 */ errorMessage?: string | null; /** Additional error data specific to the error code. */ data?: Record | null; } interface UpdateDataItemsRequest { /** ID of the collection in which to update the items. */ collectionId: string; /** * Items to update. * @minSize 1 */ items: Record[] | null; } interface UpdateDataItemsResponse { /** Response must include either the updated item or an error. */ results?: DataItemModificationResult[]; } interface RemoveDataItemsRequest { /** ID of the collection from which to remove items. */ collectionId: string; /** * IDs of items to remove. * @minSize 1 */ itemIds: string[]; } interface RemoveDataItemsResponse { /** Response must include either the removed item or an error. */ results?: DataItemModificationResult[]; } interface TruncateDataItemsRequest { /** ID of the collection from which to remove all items. */ collectionId: string; } interface TruncateDataItemsResponse { } interface QueryReferencedDataItemsRequest extends QueryReferencedDataItemsRequestPagingMethodOneOf { /** Offset-based paging */ paging?: Paging; /** Cursor-based paging */ cursorPaging?: CursorPaging; /** ID of the collection to query. */ collectionId: string; /** * IDs of the referring items. If the array is empty, return results for all referring items. * @maxSize 1000 */ referringItemIds?: string[]; /** * IDs of the referenced items. If the array is empty, return all referenced items for the referring items. * @maxSize 1000 */ referencedItemIds?: string[]; /** Order to by which to sort the results. Valid values are `ASC` and `DESC`. */ order?: SortOrder; /** Field ID to query in the referring collection. */ referringFieldKey: string; /** Whether to retrieve data from the primary database instance. This decreases performance but ensures data retrieved is up-to-date even immediately after an update. Applicable if the external database is eventually consistent. */ consistentRead: boolean; /** Fields to return in the referenced item. If the array is empty or not provided, all fields in the referenced item are returned. */ fieldsToReturn?: string[]; /** When `true`, the response includes the total number of the items that match the query. */ returnTotalCount: boolean; /** When `true`, the response includes the full referenced items. When `false`, only the IDs of referenced items be returned. */ includeReferencedItems: boolean; } /** @oneof */ interface QueryReferencedDataItemsRequestPagingMethodOneOf { /** Offset-based paging */ paging?: Paging; /** Cursor-based paging */ cursorPaging?: CursorPaging; } interface QueryReferencedDataItemsResponse { /** Retrieved references. */ items?: ReferencedItem[]; /** Paging information. */ pagingMetadata?: PagingMetadataV2; } interface ReferencedItem { /** ID of the item in the referring collection. */ referringItemId?: string; /** ID of the item in the referenced collection. */ referencedItemId?: string; /** Item in the referenced collection. If the external database does not support returning referenced items, this field can remain empty. */ referencedItem?: Record | null; } interface InsertDataItemReferencesRequest { /** ID of the referring collection. */ collectionId: string; /** Field ID of the field in the referring collection to insert references into. */ referringFieldKey: string; /** * References to insert. * @minSize 1 */ references: ReferenceId[]; } interface ReferenceId { /** ID of the item in the referring collection. */ referringItemId?: string; /** ID of the item in the referenced collection. */ referencedItemId?: string; } interface InsertDataItemReferencesResponse { /** Response must include either the inserted reference or an error. */ results?: ReferenceModificationResult[]; } interface ReferenceModificationResult extends ReferenceModificationResultResultOneOf { /** Reference that was inserted or removed. */ reference?: ReferenceId; /** Error indicating why the operation failed for a particular item. Learn more about [error types](https://dev.wix.com/docs/rest/assets/data/external-database-spi/understanding-error-types-in-the-external-database-connections-spi) in the External Database Connections service plugin. */ error?: Error$1; } /** @oneof */ interface ReferenceModificationResultResultOneOf { /** Reference that was inserted or removed. */ reference?: ReferenceId; /** Error indicating why the operation failed for a particular item. Learn more about [error types](https://dev.wix.com/docs/rest/assets/data/external-database-spi/understanding-error-types-in-the-external-database-connections-spi) in the External Database Connections service plugin. */ error?: Error$1; } interface RemoveDataItemReferencesRequest { /** ID of the referring collection. */ collectionId: string; /** Field ID of the field in the referring collection to remove references from. */ referringFieldKey: string; /** * References to remove. * @minSize 1 */ references: ReferenceId[]; } interface RemoveDataItemReferencesResponse { /** Response must include either the removed reference or an error. */ results?: ReferenceModificationResult[]; } interface ListCollectionsRequest { /** IDs of collections to retrieve. If empty, all available collections are retrieved. */ collectionIds?: string[]; } interface ListCollectionsResponse { /** List of the retrieved collections. */ collections?: Collection[]; } interface Collection { /** * ID of the collection. * @immutable */ _id?: string; /** Collection display name as it appears in the CMS. For example, `My First Collection`. */ displayName?: string | null; /** Collection fields. */ fields?: Field[]; /** * Capabilities the collection supports. This is set by the external database, and is ignored in the body of the request. * @readonly */ capabilities?: CollectionCapabilities; /** Levels of permission for accessing and modifying data. These are defined by the lowest role needed to perform each action. */ permissions?: Permissions; /** * Whether the collection supports cursor- or offset-based paging. Each paging mode requires different configuration parameters. * @readonly */ pagingMode?: PagingMode; } interface Field extends FieldTypeOptionsOneOf { singleReferenceOptions?: SingleReferenceOptions; multiReferenceOptions?: MultiReferenceOptions; arrayOptions?: ArrayOptions; objectOptions?: ObjectOptions; /** Field identifier. */ key?: string; /** Field display name as it appears in the CMS. For example, `First Name`. */ displayName?: string | null; /** Field description. */ description?: string | null; /** Field type. */ type?: FieldType; /** * Capabilities the collection supports. This is set by the external database and is ignored in the body of the request. * @readonly */ capabilities?: FieldCapabilities; /** Whether the field value is encrypted and sent as an object. Encryption and decryption are handled by Wix. Default: `false`. */ encrypted?: boolean; } /** @oneof */ interface FieldTypeOptionsOneOf { singleReferenceOptions?: SingleReferenceOptions; multiReferenceOptions?: MultiReferenceOptions; arrayOptions?: ArrayOptions; objectOptions?: ObjectOptions; } declare enum FieldType { TEXT = "TEXT", NUMBER = "NUMBER", DATE = "DATE", DATETIME = "DATETIME", IMAGE = "IMAGE", BOOLEAN = "BOOLEAN", DOCUMENT = "DOCUMENT", URL = "URL", RICH_TEXT = "RICH_TEXT", VIDEO = "VIDEO", ANY = "ANY", ARRAY_STRING = "ARRAY_STRING", ARRAY_DOCUMENT = "ARRAY_DOCUMENT", AUDIO = "AUDIO", TIME = "TIME", LANGUAGE = "LANGUAGE", RICH_CONTENT = "RICH_CONTENT", MEDIA_GALLERY = "MEDIA_GALLERY", ADDRESS = "ADDRESS", REFERENCE = "REFERENCE", MULTI_REFERENCE = "MULTI_REFERENCE", OBJECT = "OBJECT", ARRAY = "ARRAY" } interface FieldCapabilities { /** Whether the field can be used to sort the items in a collection. Default: `false`. */ sortable?: boolean; /** Query operators that can be used for this field. */ queryOperators?: QueryOperator[]; } declare enum QueryOperator { EQ = "EQ", LT = "LT", GT = "GT", NE = "NE", LTE = "LTE", GTE = "GTE", STARTS_WITH = "STARTS_WITH", ENDS_WITH = "ENDS_WITH", CONTAINS = "CONTAINS", HAS_SOME = "HAS_SOME", HAS_ALL = "HAS_ALL", EXISTS = "EXISTS", URLIZED = "URLIZED" } interface SingleReferenceOptions { /** * ID of the referenced collection. * * When the referring field is a single-reference field, it refers to the `_id` field of the referenced collection. */ referencedCollectionId?: string; } interface MultiReferenceOptions { /** ID of the referenced collection. */ referencedCollectionId?: string; /** Field ID of the referenced field in the referenced collection. */ referencedCollectionFieldKey?: string | null; /** Field display name of the referenced field in the referenced collection. */ referencedCollectionFieldDisplayName?: string | null; } interface ArrayOptions extends ArrayOptionsTypeOptionsOneOf { singleReferenceOptions?: SingleReferenceOptions; multiReferenceOptions?: MultiReferenceOptions; arrayOptions?: ArrayOptions; objectOptions?: ObjectOptions; /** Element data type. */ elementType?: FieldType; } /** @oneof */ interface ArrayOptionsTypeOptionsOneOf { singleReferenceOptions?: SingleReferenceOptions; multiReferenceOptions?: MultiReferenceOptions; arrayOptions?: ArrayOptions; objectOptions?: ObjectOptions; } interface ObjectOptions { /** Fields within the object. */ fields?: ObjectField[]; } interface SlugOptions { /** * @minLength 1 * @maxLength 1000 */ pattern?: string; } interface ObjectField extends ObjectFieldTypeOptionsOneOf { singleReferenceOptions?: SingleReferenceOptions; multiReferenceOptions?: MultiReferenceOptions; arrayOptions?: ArrayOptions; objectOptions?: ObjectOptions; /** Field ID. */ key?: string; /** Field display name. */ displayName?: string | null; /** Field type. */ type?: FieldType; /** * Capabilities the object field supports. * @readonly */ capabilities?: FieldCapabilities; } /** @oneof */ interface ObjectFieldTypeOptionsOneOf { singleReferenceOptions?: SingleReferenceOptions; multiReferenceOptions?: MultiReferenceOptions; arrayOptions?: ArrayOptions; objectOptions?: ObjectOptions; } interface CollectionCapabilities { /** Data operations that can be performed on items in the collection. */ dataOperations?: DataOperation[]; } declare enum DataOperation { QUERY = "QUERY", COUNT = "COUNT", QUERY_REFERENCED = "QUERY_REFERENCED", AGGREGATE = "AGGREGATE", DISTINCT = "DISTINCT", INSERT = "INSERT", UPDATE = "UPDATE", REMOVE = "REMOVE", TRUNCATE = "TRUNCATE", INSERT_REFERENCES = "INSERT_REFERENCES", REMOVE_REFERENCES = "REMOVE_REFERENCES" } interface Permissions { /** Lowest role required to add a collection. */ insert?: Role; /** Lowest role required to update a collection. */ update?: Role; /** Lowest role required to remove a collection. */ remove?: Role; /** Lowest role required to read a collection. */ read?: Role; } declare enum Role { /** Site administrator. */ ADMIN = "ADMIN", /** A signed-in user who inserted content to this collection. */ SITE_MEMBER_AUTHOR = "SITE_MEMBER_AUTHOR", /** Any signed-in user. */ SITE_MEMBER = "SITE_MEMBER", /** Any site visitor. */ ANYONE = "ANYONE" } declare enum PagingMode { /** Offset-based paging. */ OFFSET = "OFFSET", /** Cursor-based paging. */ CURSOR = "CURSOR" } interface CreateCollectionRequest { /** Details of the collection to create. */ collection?: Collection; } interface CreateCollectionResponse { /** Details of the created collection. */ collection?: Collection; } interface UpdateCollectionRequest { /** Updated structure details for the specified collection. */ collection?: Collection; } interface UpdateCollectionResponse { /** Updated collection details. */ collection?: Collection; } interface DeleteCollectionRequest { /** ID of the collection to delete. */ collectionId: string; } interface DeleteCollectionResponse { } interface GetCapabilitiesRequest { } interface GetCapabilitiesResponse { /** Whether the external database supports creating new collections, updating the structure of existing collections, or deleting them. */ supportsCollectionModifications?: boolean; /** Field types the external database supports. This field only applies when `supportsCollectionModifications` is true. */ supportedFieldTypes?: FieldType[]; } interface IndexOptions { /** Whether the external database supports creating, listing and removing indexes. */ supportsIndexes?: boolean; /** Maximum number of regular (non-unique) indexes allowed for this collection. */ maxNumberOfRegularIndexesPerCollection?: number; /** Maximum number of unique indexes allowed for this collection. */ maxNumberOfUniqueIndexesPerCollection?: number; /** Maximum number of regular and unique indexes allowed for this collection. */ maxNumberOfIndexesPerCollection?: number; } interface ListIndexesRequest { /** collection to list indexes from */ collectionId: string; } interface ListIndexesResponse { /** list of indexes */ indexes?: Index[]; } interface Index { /** * Index id * @minLength 1 * @format GUID */ _id?: string; /** * Index name * @minLength 1 * @maxLength 128 */ name?: string; /** * Fields over which the index is defined * @minSize 1 * @maxSize 32 */ fields?: IndexField[]; /** * Indicates current status of index * @readonly */ status?: Status; /** If true index will enforce that values in the field are unique in scope of a collection. Default is false. */ unique?: boolean; /** If true index will be case-insensitive. Default is false. */ caseInsensitive?: boolean; /** * Contains details about failure reason when index is in *FAILED* status * @readonly */ failure?: Error$1; } /** * Order determines how values are ordered in the index. This is important when * ordering and/or range querying by indexed fields. */ declare enum Order { ASC = "ASC", DESC = "DESC" } interface IndexField { /** * Field to index. For example: title, options.price * @minLength 1 * @maxLength 128 */ path?: string; /** Order in which to keep the values. Default is ASC. */ order?: Order; } declare enum Status { /** Place holder. Never returned by the service. */ UNKNOWN = "UNKNOWN", /** Index creation is in progress. */ BUILDING = "BUILDING", /** Index has been successfully created. It can be used in queries. */ ACTIVE = "ACTIVE", /** Index is being dropped. */ DROPPING = "DROPPING", /** Index is successfully dropped. */ DROPPED = "DROPPED", /** Index creation has failed. */ FAILED = "FAILED", /** Index contains incorrectly indexed data. */ INVALID = "INVALID" } interface CreateIndexRequest { /** collection to list indexes from */ collectionId: string; /** index definition */ index: Index; } interface CreateIndexResponse { /** created index and its status */ index?: Index; } interface RemoveIndexRequest { /** collection to delete index from */ collectionId: string; /** index name */ indexName: string; } interface RemoveIndexResponse { } interface ExternalDatabaseSpiConfig { /** The URI where the service provider is deployed. */ uriConfig?: SpiBaseUri; /** The namespace of the external database. This can be used to access collections within the database, for example `namespace/collectionId`. */ namespace?: string; } /** Base URI configuration for a service plugin. Wix uses these URIs to call your service plugin methods. */ interface SpiBaseUri { /** * Base URI for your service plugin. Wix appends each method's path to this URI. * * For example, to receive requests at `https://my-app.com/v1/my-method`, set this field to `https://my-app.com/`. * @minLength 6 * @maxLength 2048 */ baseUri?: string; /** Alternative URIs for specific methods. Use these to override the default URI for individual methods. */ alternativeUris?: AlternativeUri[]; } /** Custom URI for the specified service plugin method. */ interface AlternativeUri { /** * Name of the method to call at the absolute URI, in PascalCase. For example, to call [Get Shipping Rates](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/shipping-rates/shipping-rates-integration-service-plugin/get-shipping-rates) on an alternative URI, specify `GetShippingRates`. * @minLength 3 * @maxLength 128 */ methodName?: string; /** * Absolute URI that Wix calls for this method. Wix doesn't append any path to this URI. * * The URI must begin with `https://`, such as `https://my-app.com/v1/my-custom-method`. * @minLength 6 * @maxLength 2048 */ absoluteUri?: string; } /** * this message is not directly used by any service, * it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform. * e.g. SPIs, event-handlers, etc.. * NOTE: this context object MUST be provided as the last argument in each Velo method signature. * * Example: * ```typescript * export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) { * ... * } * ``` */ interface Context { /** A unique identifier of the request. You may print this ID to your logs to help with future debugging and easier correlation with Wix's logs. */ requestId?: string | null; /** * [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code. * @format CURRENCY */ currency?: string | null; /** An object that describes the identity that triggered this request. */ identity?: IdentificationData; /** A string representing a language and region in the format of `"xx-XX"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash "-", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `"en-US"`. */ languages?: string[]; /** * The service provider app's instance ID. * @format GUID */ instanceId?: string | null; } declare enum IdentityType { UNKNOWN = "UNKNOWN", ANONYMOUS_VISITOR = "ANONYMOUS_VISITOR", MEMBER = "MEMBER", WIX_USER = "WIX_USER", APP = "APP" } 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?: IdentityType; } /** @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; } interface QueryDataItemsEnvelope { request: QueryDataItemsRequest; metadata: Context; } interface CountDataItemsEnvelope { request: CountDataItemsRequest; metadata: Context; } interface AggregateDataItemsEnvelope { request: AggregateDataItemsRequest; metadata: Context; } interface QueryDistinctValuesEnvelope { request: QueryDistinctValuesRequest; metadata: Context; } interface InsertDataItemsEnvelope { request: InsertDataItemsRequest; metadata: Context; } interface UpdateDataItemsEnvelope { request: UpdateDataItemsRequest; metadata: Context; } interface RemoveDataItemsEnvelope { request: RemoveDataItemsRequest; metadata: Context; } interface TruncateDataItemsEnvelope { request: TruncateDataItemsRequest; metadata: Context; } interface QueryReferencedDataItemsEnvelope { request: QueryReferencedDataItemsRequest; metadata: Context; } interface InsertDataItemReferencesEnvelope { request: InsertDataItemReferencesRequest; metadata: Context; } interface RemoveDataItemReferencesEnvelope { request: RemoveDataItemReferencesRequest; metadata: Context; } interface ListCollectionsEnvelope { request: ListCollectionsRequest; metadata: Context; } interface CreateCollectionEnvelope { request: CreateCollectionRequest; metadata: Context; } interface UpdateCollectionEnvelope { request: UpdateCollectionRequest; metadata: Context; } interface DeleteCollectionEnvelope { request: DeleteCollectionRequest; metadata: Context; } interface GetCapabilitiesEnvelope { request: GetCapabilitiesRequest; metadata: Context; } declare const provideHandlers: ServicePluginDefinition<{ /** * * Retrieves a list of items based on the provided filtering, sorting, and paging preferences. */ queryDataItems(payload: QueryDataItemsEnvelope): QueryDataItemsResponse | Promise; /** * Counts the number of items in the specified data collection that match the filtering preferences. */ countDataItems(payload: CountDataItemsEnvelope): CountDataItemsResponse | Promise; /** * Runs an aggregation query on the specified data collection and returns the resulting list of items. */ aggregateDataItems(payload: AggregateDataItemsEnvelope): AggregateDataItemsResponse | Promise; /** * * Retrieves a list of distinct values for a given field for all items that match the query, without duplicates. * * As with [`queryDataItems()`](/external-database/query-data-items), this function retrieves items based on the filtering, sorting, and paging preferences provided. However, this function does not return the full items that match the query. Rather, for items that match the query, it returns all unique values in the field specified in `fieldName`. If more than one item has the same value in that field, that value appears only once. */ queryDistinctValues(payload: QueryDistinctValuesEnvelope): QueryDistinctValuesResponse | Promise; /** * * Adds one or more items to a collection. * * A data item object contains the `_id` and `_owner` fields. The response array must include the same items that were inserted, and each returned item must be added the `_createdDate` and `_updatedDate` fields. * * However, data items can also be inserted without an `_id` field. In that case, it is the service provider's responsibility to generate a unique ID for each item. */ insertDataItems(payload: InsertDataItemsEnvelope): InsertDataItemsResponse | Promise; /** * * Updates one or more items in a collection. Items must be completely replaced. * * The response array must include the same items that were updated, and each returned item must be added the `_createdDate` and `_updatedDate` fields. */ updateDataItems(payload: UpdateDataItemsEnvelope): UpdateDataItemsResponse | Promise; /** * Removes one or more items from a collection. The response object must contain the removed item. */ removeDataItems(payload: RemoveDataItemsEnvelope): RemoveDataItemsResponse | Promise; /** * Removes all items from a collection. */ truncateDataItems(payload: TruncateDataItemsEnvelope): TruncateDataItemsResponse | Promise; /** * * Retrieves the items referenced in the specified field of a referring item. Reference fields refer to items that exist in different collections. Implement this function so callers can retrieve the full details of the referenced items. * * This service plugin supports item multi-references, which means that data collections can have many-to-many relationships with other collections. For example, consider a scenario where a **Movies** collection includes a multi-reference **Actors** field, which might refer to several **Actor** items in an **Actors** collection. Users can therefore query the **Movies** collection to retrieve the **Actor** items referenced in each **Movie** item. * * > **Notes:** * > - This function does not retrieve the full referenced items of referenced items. For example, the referenced **Actors** collection might itself contain a multi-reference field with references to **Award** items in an **Awards** collection. When calling this function to retrieve the referenced items of any **Movie** item, the response contains the referenced **Actor** items, but only the IDs of the **Award** items. To retrieve the full **Award** items, the user must either call this function for the **Actors** collection, or the [`queryDataItems()`](/external-database/query-data-items) function for the **Awards** collection. * > - This function might also be called when a user calls the [`isReferenced()`](https://dev.wix.com/docs/sdk/backend-modules/data/items/is-referenced-data-item) function of the Data API. */ queryReferencedDataItems(payload: QueryReferencedDataItemsEnvelope): QueryReferencedDataItemsResponse | Promise; /** * Inserts one or more item references into a referring field of the specified item. */ insertDataItemReferences(payload: InsertDataItemReferencesEnvelope): InsertDataItemReferencesResponse | Promise; /** * Removes one or more item references from a referring field of the specified item. */ removeDataItemReferences(payload: RemoveDataItemReferencesEnvelope): RemoveDataItemReferencesResponse | Promise; /** * * Retrieves a list of data collections and their details. * * When `collectionIds` is empty, all existing collections are returned. * If a specified collection does not exist, that collection can be ignored. */ listCollections(payload: ListCollectionsEnvelope): ListCollectionsResponse | Promise; /** * Creates a new data collection. */ createCollection(payload: CreateCollectionEnvelope): CreateCollectionResponse | Promise; /** * * Updates the structure of an existing data collection. * * Some parameters, such as `capabilities` and `pagingMode`, are determined by the service provider. If the collection passed in the request contains these parameters, their values must be ignored. However, these fields must be included in the response collection with relevant values. */ updateCollection(payload: UpdateCollectionEnvelope): UpdateCollectionResponse | Promise; /** * Deletes a data collection. */ deleteCollection(payload: DeleteCollectionEnvelope): DeleteCollectionResponse | Promise; /** * Lists the global capabilities the external database supports. */ getCapabilities(payload: GetCapabilitiesEnvelope): GetCapabilitiesResponse | Promise; }>; /** * There is already an item with this ID. */ declare class ItemAlreadyExistsWixError extends Error { /** @hidden */ httpCode: number; /** @hidden */ statusCode: string; /** @hidden */ applicationCode: string; /** @hidden */ name: string; /** @hidden */ errorSchemaName: string; /** @hidden */ errorType: string; /** @hidden */ spiErrorData: object; data: ItemAlreadyExistsError; constructor(data?: ItemAlreadyExistsError); /** @hidden */ static readonly __type = "wix_spi_error"; } /** * Couldn't find the item. */ declare class ItemNotFoundWixError extends Error { /** @hidden */ httpCode: number; /** @hidden */ statusCode: string; /** @hidden */ applicationCode: string; /** @hidden */ name: string; /** @hidden */ errorSchemaName: string; /** @hidden */ errorType: string; /** @hidden */ spiErrorData: object; data: ItemNotFoundError; constructor(data?: ItemNotFoundError); /** @hidden */ static readonly __type = "wix_spi_error"; } /** * There is already a collection with this ID. */ declare class CollectionAlreadyExistsWixError extends Error { /** @hidden */ httpCode: number; /** @hidden */ statusCode: string; /** @hidden */ applicationCode: string; /** @hidden */ name: string; /** @hidden */ errorSchemaName: string; /** @hidden */ errorType: string; /** @hidden */ spiErrorData: object; data: CollectionAlreadyExistsError; constructor(data?: CollectionAlreadyExistsError); /** @hidden */ static readonly __type = "wix_spi_error"; } /** * Couldn't find the collection. */ declare class CollectionNotFoundWixError extends Error { /** @hidden */ httpCode: number; /** @hidden */ statusCode: string; /** @hidden */ applicationCode: string; /** @hidden */ name: string; /** @hidden */ errorSchemaName: string; /** @hidden */ errorType: string; /** @hidden */ spiErrorData: object; data: CollectionNotFoundError; constructor(data?: CollectionNotFoundError); /** @hidden */ static readonly __type = "wix_spi_error"; } /** * There is already a reference between these items. */ declare class ReferenceAlreadyExistsWixError extends Error { /** @hidden */ httpCode: number; /** @hidden */ statusCode: string; /** @hidden */ applicationCode: string; /** @hidden */ name: string; /** @hidden */ errorSchemaName: string; /** @hidden */ errorType: string; /** @hidden */ spiErrorData: object; data: ReferenceAlreadyExistsError; constructor(data?: ReferenceAlreadyExistsError); /** @hidden */ static readonly __type = "wix_spi_error"; } /** * Couldn't find the reference. */ declare class ReferenceNotFoundWixError extends Error { /** @hidden */ httpCode: number; /** @hidden */ statusCode: string; /** @hidden */ applicationCode: string; /** @hidden */ name: string; /** @hidden */ errorSchemaName: string; /** @hidden */ errorType: string; /** @hidden */ spiErrorData: object; data: ReferenceNotFoundError; constructor(data?: ReferenceNotFoundError); /** @hidden */ static readonly __type = "wix_spi_error"; } /** * 1 or more field values are invalid. */ declare class ValidationWixError extends Error { /** @hidden */ httpCode: number; /** @hidden */ statusCode: string; /** @hidden */ applicationCode: string; /** @hidden */ name: string; /** @hidden */ errorSchemaName: string; /** @hidden */ errorType: string; /** @hidden */ spiErrorData: object; data: ValidationError; constructor(data?: ValidationError); /** @hidden */ static readonly __type = "wix_spi_error"; } /** * The collection field can't be changed. */ declare class CollectionChangeNotSupportedWixError extends Error { /** @hidden */ httpCode: number; /** @hidden */ statusCode: string; /** @hidden */ applicationCode: string; /** @hidden */ name: string; /** @hidden */ errorSchemaName: string; /** @hidden */ errorType: string; /** @hidden */ spiErrorData: object; data: CollectionChangeNotSupported; constructor(data?: CollectionChangeNotSupported); /** @hidden */ static readonly __type = "wix_spi_error"; } /** * The request is invalid. */ declare class BadRequestWixError extends Error { /** @hidden */ httpCode: number; /** @hidden */ statusCode: string; /** @hidden */ applicationCode: string; /** @hidden */ name: string; /** @hidden */ errorType: string; /** @hidden */ spiErrorData: object; constructor(); /** @hidden */ static readonly __type = "wix_spi_error"; } export { type ReferencedItem as $, type AggregateDataItemsRequest as A, type QueryDistinctValuesRequest as B, type CursorPaging as C, type QueryDistinctValuesRequestPagingMethodOneOf as D, type QueryDistinctValuesResponse as E, type InsertDataItemsRequest as F, type InsertDataItemsResponse as G, type DataItemModificationResult as H, type ItemAlreadyExistsError as I, type DataItemModificationResultResultOneOf as J, type Error$1 as K, type UpdateDataItemsResponse as L, type MainEntity as M, type RemoveDataItemsRequest as N, type Operation as O, type Paging as P, type QueryDataItemsRequest as Q, type ReferencedItemToInclude as R, type Sorting as S, type RemoveDataItemsResponse as T, type UpdateDataItemsRequest as U, type ValidationError as V, type TruncateDataItemsRequest as W, type TruncateDataItemsResponse as X, type QueryReferencedDataItemsRequest as Y, type QueryReferencedDataItemsRequestPagingMethodOneOf as Z, type QueryReferencedDataItemsResponse as _, type QueryV2 as a, type QueryDataItemsEnvelope as a$, type InsertDataItemReferencesRequest as a0, type ReferenceId as a1, type InsertDataItemReferencesResponse as a2, type ReferenceModificationResult as a3, type ReferenceModificationResultResultOneOf as a4, type RemoveDataItemReferencesRequest as a5, type RemoveDataItemReferencesResponse as a6, type ListCollectionsRequest as a7, type ListCollectionsResponse as a8, type Collection as a9, type IndexOptions as aA, type ListIndexesRequest as aB, type ListIndexesResponse as aC, type Index as aD, Order as aE, type IndexField as aF, Status as aG, type CreateIndexRequest as aH, type CreateIndexResponse as aI, type RemoveIndexRequest as aJ, type RemoveIndexResponse as aK, type ExternalDatabaseSpiConfig as aL, type SpiBaseUri as aM, type AlternativeUri as aN, type Context as aO, IdentityType as aP, type IdentificationData as aQ, type IdentificationDataIdOneOf as aR, ItemAlreadyExistsWixError as aS, ItemNotFoundWixError as aT, CollectionAlreadyExistsWixError as aU, CollectionNotFoundWixError as aV, ReferenceAlreadyExistsWixError as aW, ReferenceNotFoundWixError as aX, ValidationWixError as aY, CollectionChangeNotSupportedWixError as aZ, BadRequestWixError as a_, type Field as aa, type FieldTypeOptionsOneOf as ab, FieldType as ac, type FieldCapabilities as ad, QueryOperator as ae, type SingleReferenceOptions as af, type MultiReferenceOptions as ag, type ArrayOptions as ah, type ArrayOptionsTypeOptionsOneOf as ai, type ObjectOptions as aj, type SlugOptions as ak, type ObjectField as al, type ObjectFieldTypeOptionsOneOf as am, type CollectionCapabilities as an, DataOperation as ao, type Permissions as ap, Role as aq, PagingMode as ar, type CreateCollectionRequest as as, type CreateCollectionResponse as at, type UpdateCollectionRequest as au, type UpdateCollectionResponse as av, type DeleteCollectionRequest as aw, type DeleteCollectionResponse as ax, type GetCapabilitiesRequest as ay, type GetCapabilitiesResponse as az, type QueryV2PagingMethodOneOf as b, type CountDataItemsEnvelope as b0, type AggregateDataItemsEnvelope as b1, type QueryDistinctValuesEnvelope as b2, type InsertDataItemsEnvelope as b3, type UpdateDataItemsEnvelope as b4, type RemoveDataItemsEnvelope as b5, type TruncateDataItemsEnvelope as b6, type QueryReferencedDataItemsEnvelope as b7, type InsertDataItemReferencesEnvelope as b8, type RemoveDataItemReferencesEnvelope as b9, type ListCollectionsEnvelope as ba, type CreateCollectionEnvelope as bb, type UpdateCollectionEnvelope as bc, type DeleteCollectionEnvelope as bd, type GetCapabilitiesEnvelope as be, SortOrder as c, type QueryDataItemsResponse as d, type PagingMetadataV2 as e, type Cursors as f, type ItemNotFoundError as g, type CollectionAlreadyExistsError as h, type CollectionNotFoundError as i, type ReferenceAlreadyExistsError as j, type ReferenceNotFoundError as k, type ValidationViolation as l, type CollectionChangeNotSupported as m, type CollectionChangeNotSupportedError as n, type CountDataItemsRequest as o, provideHandlers as p, type CountDataItemsResponse as q, type AggregateDataItemsRequestPagingMethodOneOf as r, type OperationCalculateOneOf as s, type Average as t, type Min as u, type Max as v, type Sum as w, type Count as x, type Aggregation as y, type AggregateDataItemsResponse as z };