import type { BackendRequest, QueryIndexCreateSettings, QueryIndexKeyspace, QueryIndexManagementBackend } from '../backends'; import { QueryIndex } from '../queryindexmanager'; import type { _couchbase_admin_query_v1_GetAllIndexesResponse_Index__Output as ListedIndexPb } from './generated/couchbase/admin/query/v1/GetAllIndexesResponse'; import type { QueryAdminServiceClient } from './generated/couchbase/admin/query/v1/QueryAdminService'; import type { Couchbase2Channel, Couchbase2Op } from './requestcontext'; /** * @internal */ export declare const QUERY_INDEX_CREATE: Couchbase2Op; /** * @internal */ export declare const QUERY_INDEX_DROP: Couchbase2Op; /** * @internal */ export declare const QUERY_INDEX_GET_ALL: Couchbase2Op; /** * @internal */ export declare const QUERY_INDEX_BUILD_DEFERRED: Couchbase2Op; /** * One wait within a watch. It changes nothing, so it may be sent any number * of times. * * @internal */ export declare const QUERY_INDEX_WAIT_FOR_ONLINE: Couchbase2Op; /** * How long a watch waits before asking again about an index that has not * been built, in milliseconds. * * @internal */ export declare const WATCH_POLL_MS = 1000; /** * The keyspace fields every request of the service carries. * * @internal */ export interface KeyspacePb { /** * The bucket. */ bucket_name: string; /** * The scope, left out for the whole bucket. */ scope_name?: string; /** * The collection, left out for the whole bucket. */ collection_name?: string; } /** * The keyspace fields of a request. An empty scope or collection is left * out: the gateway reads an absent one as the whole bucket, and an empty * one as a name, which it refuses. * * @internal */ export declare function keyspaceToProto(keyspace: QueryIndexKeyspace): KeyspacePb; /** * One index key as the gateway is sent it. A key wrapped in backticks is * taken as already escaped, which lets a nested path like `` `a`.`b` `` through, * and is sent as written, as on a classic connection. Any other key is quoted * as one identifier, so that it cannot close its own quoting. * * @internal */ export declare function escapeIndexKey(key: string): string; /** * One listed index. The gateway's scope and collection names have no * presence, so an empty one is an index on the bucket itself; the condition * and partition do. * * @internal */ export declare function queryIndexFromProto(index: ListedIndexPb): QueryIndex; /** * Query index management over the gateway's `QueryAdminService`. The * gateway builds each statement itself, so a request carries no statement * text but the index keys. * * @internal */ export declare class Couchbase2QueryIndexes implements QueryIndexManagementBackend { private readonly _channel; private readonly _client; constructor(channel: Couchbase2Channel, client: QueryAdminServiceClient); /** * Creates a secondary index with `QueryAdminService.CreateIndex`, each * key escaped to one identifier. */ createIndex(keyspace: QueryIndexKeyspace, indexName: string, keys: string[], settings: QueryIndexCreateSettings, req: BackendRequest): Promise; /** * Creates a primary index with `QueryAdminService.CreatePrimaryIndex`. An * index created without a name is given the server's own, `#primary`. */ createPrimaryIndex(keyspace: QueryIndexKeyspace, indexName: string | undefined, settings: QueryIndexCreateSettings, req: BackendRequest): Promise; /** * Drops a secondary index with `QueryAdminService.DropIndex`. */ dropIndex(keyspace: QueryIndexKeyspace, indexName: string, ignoreIfNotExists: boolean, req: BackendRequest): Promise; /** * Drops a primary index with `QueryAdminService.DropPrimaryIndex`, which * takes a name, so a named primary index needs no secondary drop. */ dropPrimaryIndex(keyspace: QueryIndexKeyspace, indexName: string | undefined, ignoreIfNotExists: boolean, req: BackendRequest): Promise; /** * Lists the keyspace's indexes with `QueryAdminService.GetAllIndexes`. */ getAllIndexes(keyspace: QueryIndexKeyspace, req: BackendRequest): Promise; /** * Builds the keyspace's deferred indexes with * `QueryAdminService.BuildDeferredIndexes`, returning the name of each * index the gateway says it will build. */ buildDeferredIndexes(keyspace: QueryIndexKeyspace, req: BackendRequest): Promise; /** * Waits on each index in turn with `QueryAdminService.WaitForIndexOnline`, * all within `timeout`. The gateway refuses to wait on an index that has * not been built yet, so a refused wait is retried every * {@link WATCH_POLL_MS}. */ watchIndexes(keyspace: QueryIndexKeyspace, indexNames: string[], watchPrimary: boolean, timeout: number, req: BackendRequest): Promise; /** * Whether the index came online before `deadline`; false when it has not * been built. Each wait is an operation of its own under the watch's span, * with its call under it. */ private _waitForOnline; }