/** An index is a map of a collection's data, organized according to specific fields to increase query speed. */ export interface Index { /** Name of the index. */ name?: string; /** * Fields for which the index is defined. * * Max: 3 fields (for a unique index: 1 field) */ fields?: Field[]; /** * Current status of the index. * @readonly */ status?: Status; /** * Contains details about the reasons for failure when `status` is `FAILED`. * @readonly */ failure?: Failure; /** * Whether the index enforces uniqueness of values in the field for which it is defined. * If `true`, the index can have only one field. * * Default: `false` */ unique?: boolean; /** * Whether the index ignores case. * * Default: `false` */ caseInsensitive?: boolean; } /** * Order determines how values are ordered in the index. This is important when * ordering and/or range querying by indexed fields. */ export declare enum Order { ASC = "ASC", DESC = "DESC" } export interface Field { /** Path of the field to index. For example: `title` or `options.price`. */ path?: string; /** * Sort order for the index. Base on how the data is regularly queried. * * Default: `ASC` */ order?: Order; } export declare enum Status { /** Place holder. Never returned by the service. */ UNKNOWN = "UNKNOWN", /** Index creation is in progress. */ BUILDING = "BUILDING", /** Index has been successfully created and can be used in queries. */ ACTIVE = "ACTIVE", /** Index is in the process of being dropped. */ DROPPING = "DROPPING", /** Index has been dropped successfully. */ DROPPED = "DROPPED", /** Index creation has failed. */ FAILED = "FAILED", /** Index contains incorrectly indexed data. */ INVALID = "INVALID" } export interface Failure { /** * Error code. * - `WDE0112`: Unknown error while building collection index. * - `WDE0113`: Duplicate key error while building collection index. * - `WDE0114`: Document too large while building collection index. */ code?: string; /** Description of the failure. */ description?: string; /** * ID of the data item that caused the failure. * For example, if `unique` is `true`, the ID of an item containing a duplicate value. */ itemId?: string | null; } export interface CreateIndexRequest { /** Details of the index to be created. */ index: Index; /** ID of the data collection for which to generate the index. */ dataCollectionId: string; } export declare enum Environment { LIVE = "LIVE", SANDBOX = "SANDBOX", SANDBOX_PREFERRED = "SANDBOX_PREFERRED" } export interface CreateIndexResponse { /** Details of the index being generated. */ index?: Index; } export interface DropIndexRequest { /** Name of the index to drop. */ indexName: string; /** ID of the data collection for which the index to be dropped is defined. */ dataCollectionId: string; } export interface DropIndexResponse { } export interface ListIndexesRequest { /** ID of the data collection for which to list indexes. */ dataCollectionId: string; /** Paging options to limit and skip the number of items. */ paging?: Paging; } export interface Paging { /** Number of items to load. */ limit?: number | null; /** Number of items to skip in the current sort order. */ offset?: number | null; } export interface ListIndexesResponse { /** List of all indexes for the requested data collection. */ indexes?: Index[]; /** Paging metadata. */ pagingMetadata?: PagingMetadata; } export interface PagingMetadata { /** 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. */ total?: number | null; /** Flag that indicates the server failed to calculate the `total` field. */ tooManyToCount?: boolean | null; } export interface ListAvailableIndexesRequest { /** Data collection to show available indexes for */ dataCollectionId?: string; } export interface ListAvailableIndexesResponse { /** * limit of regular single-field indexes, even if 0 1-field indices may be created using * 3-field quota (if available) */ regular1Field?: number; /** limit of regular indexes up to 3-fields (in addition to 1-field indexes quota) */ regular3Field?: number; /** limit of unique indexes */ unique1Field?: number; /** Overall index limit, missing value means there's no overall limit */ total?: number | null; } interface FieldNonNullableFields { path: string; order: Order; } interface FailureNonNullableFields { code: string; broadCode: string; description: string; } export interface IndexNonNullableFields { name: string; fields: FieldNonNullableFields[]; status: Status; failure?: FailureNonNullableFields; unique: boolean; caseInsensitive: boolean; } export interface CreateIndexResponseNonNullableFields { index?: IndexNonNullableFields; } export interface ListIndexesResponseNonNullableFields { indexes: IndexNonNullableFields[]; } /** * Creates an index for a data collection. * * The index can't be used immediately, as the process of generating the index takes time. * You can check whether an index is ready by calling List Indexes. * * Note that when an index fails to create, the failed index still occupies a slot. * To remove the failed index and free up the slot for a new index, call Drop Index. * @param dataCollectionId - ID of the data collection for which to generate the index. * @param index - Details of the index to be created. * @public * @requiredField dataCollectionId * @requiredField index * @requiredField index.fields * @requiredField index.fields.path * @requiredField index.name * @param options - Options for creating an index. * @permissionId WIX_DATA.CREATE_INDEX * @permissionScope Manage Data Indexes * @permissionScopeId SCOPE.DC-DATA.INDEXES-MANAGE * @applicableIdentity APP * @returns Details of the index being generated. * @fqn com.wixpress.cloud.data.api.index.IndexService.CreateIndex */ export declare function createIndex(dataCollectionId: string, index: Index): Promise; /** * Removes an index from a data collection. * * The process of dropping an index from a collection takes time. * You can check whether an index has been dropped by calling List Indexes. * @param dataCollectionId - ID of the data collection for which the index to be dropped is defined. * @param indexName - Name of the index to drop. * @public * @requiredField dataCollectionId * @requiredField indexName * @param options - Options for dropping an index. * @permissionId WIX_DATA.DROP_INDEX * @permissionScope Manage Data Indexes * @permissionScopeId SCOPE.DC-DATA.INDEXES-MANAGE * @applicableIdentity APP * @fqn com.wixpress.cloud.data.api.index.IndexService.DropIndex */ export declare function dropIndex(dataCollectionId: string, indexName: string): Promise; /** * Lists all indexes defined for a data collection. * * When an index's status is `ACTIVE`, it is ready to use. * While it is still being created, its status is `BUILDING`. * * When an index's status is `DROPPED`, it has been dropped successfully. * While it is still in the process of being removed, its status is `DROPPING`. * @param dataCollectionId - ID of the data collection for which to list indexes. * @public * @requiredField dataCollectionId * @param options - Options for retrieving a list of indexes. * @permissionId WIX_DATA.LIST_INDEXES * @permissionScope Manage Data Indexes * @permissionScopeId SCOPE.DC-DATA.INDEXES-MANAGE * @applicableIdentity APP * @fqn com.wixpress.cloud.data.api.index.IndexService.ListIndexes */ export declare function listIndexes(dataCollectionId: string, options?: ListIndexesOptions): Promise; export interface ListIndexesOptions { /** Paging options to limit and skip the number of items. */ paging?: Paging; } export {};