Backstage
    Preparing search index...

    A wrapper class that exposes logical methods that are conditionally fired against either a configured Elasticsearch client or a configured Opensearch client.

    This is necessary because, despite its intention to be API-compatible, the opensearch client does not support API key-based authentication. This is also the sanest way to accomplish this while making typescript happy.

    In the future, if the differences between implementations become unmaintainably divergent, we should split out the Opensearch and Elasticsearch search engine implementations.

    The Elasticsearch client calls below pass { meta: true }. As of v8 the @elastic/elasticsearch client returns the response body directly, whereas the Opensearch client (forked from the v7 Elasticsearch client) still wraps it in { body, statusCode, headers, ... }. Requesting the meta envelope keeps both clients returning the same shape, so consumers can continue to read response.body regardless of the configured provider.

    interface ElasticSearchClientWrapper {
        bulk(
            bulkOptions: {
                datasource: Readable;
                onDocument: (doc: any) => ElasticSearchIndexAction;
                refreshOnCompletion?: string | boolean;
            },
        ): BulkHelper<BulkStats>;
        createIndex(options: { index: string }): ElasticSearchClientResponsePromise;
        deleteIndex(
            options: { index: string | string[] },
        ): ElasticSearchClientResponsePromise;
        getAliases(
            options: { aliases: string[] },
        ): ElasticSearchClientResponsePromise;
        indexExists(
            options: { index: string | string[] },
        ): ElasticSearchClientResponsePromise<boolean>;
        listIndices(options: { index: string }): ElasticSearchClientResponsePromise;
        putIndexTemplate(
            template: ElasticSearchCustomIndexTemplate,
        ): ElasticSearchClientResponsePromise;
        search(
            options: { body: Object; index: string | string[] },
        ): ElasticSearchClientResponsePromise;
        updateAliases(
            options: { actions: ElasticSearchAliasAction[] },
        ): ElasticSearchClientResponsePromise;
    }
    Index