@backstage/plugin-search-backend-module-elasticsearch 2.0.1 → 2.0.2-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @backstage/plugin-search-backend-module-elasticsearch
2
2
 
3
+ ## 2.0.2-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/integration-aws-node@0.2.4-next.0
9
+
10
+ ## 2.0.2-next.0
11
+
12
+ ### Patch Changes
13
+
14
+ - 8da9c23: Internal changes for TypeScript 7 compatibility. There are no changes to behavior or the public API.
15
+ - Updated dependencies
16
+ - @backstage/plugin-search-backend-node@1.4.10-next.0
17
+ - @backstage/backend-plugin-api@1.11.1-next.0
18
+
3
19
  ## 2.0.1
4
20
 
5
21
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"ElasticSearchClientWrapper.cjs.js","sources":["../../src/engines/ElasticSearchClientWrapper.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Client as ElasticSearchClient,\n ClientOptions as ElasticSearchClientLibOptions,\n} from '@elastic/elasticsearch';\nimport { Client as OpenSearchClient } from '@opensearch-project/opensearch';\nimport { Readable } from 'node:stream';\nimport {\n ElasticSearchClientOptions,\n isOpenSearchCompatible,\n} from './ElasticSearchClientOptions';\nimport { ElasticSearchCustomIndexTemplate } from './types';\n\n/**\n * @public\n */\nexport type ElasticSearchAliasAction =\n | {\n remove: { index: any; alias: any };\n add?: undefined;\n }\n | {\n add: { indices: any; alias: any; index?: undefined };\n remove?: undefined;\n }\n | {\n add: { index: any; alias: any; indices?: undefined };\n remove?: undefined;\n }\n | undefined;\n\n/**\n * @public\n */\nexport type ElasticSearchIndexAction = {\n index: {\n _index: string;\n [key: string]: any;\n };\n};\n\n/**\n * The normalized response shape returned by the wrapped client methods.\n *\n * Both the Elasticsearch and Opensearch clients expose the response payload\n * under a `body` property together with the HTTP status code, the response\n * headers and any deprecation warnings, so consumers can read these regardless\n * of the configured provider. The client specific `meta` envelope is not part\n * of this type because its shape differs between the two clients.\n *\n * @public\n */\nexport type ElasticSearchClientResponse<TBody = any> = {\n body: TBody;\n headers: Record<string, any> | null;\n statusCode: number | null;\n warnings: string[] | null;\n};\n\n/**\n * The promise returned by the wrapped client methods.\n *\n * The Opensearch client returns a promise that additionally exposes an\n * `abort` method, whereas the Elasticsearch v8 client returns a plain\n * promise, so `abort` is only present when the Opensearch client is\n * configured.\n *\n * @public\n */\nexport type ElasticSearchClientResponsePromise<TBody = any> = Promise<\n ElasticSearchClientResponse<TBody>\n> & {\n abort?: () => void;\n};\n\n/**\n * Adapts the provider-agnostic client options to the shape expected by the\n * `@elastic/elasticsearch` v8 client.\n *\n * The v8 client reads TLS configuration from a `tls` property; the `ssl`\n * property used by the Opensearch client (and by earlier Elasticsearch client\n * versions) is no longer recognized. Map it across so that TLS settings keep\n * being honored.\n */\nfunction toElasticSearchClientOptions(\n options: ElasticSearchClientOptions,\n): ElasticSearchClientLibOptions {\n const { ssl, ...rest } = options;\n return {\n ...rest,\n ...(ssl ? { tls: ssl } : {}),\n } as ElasticSearchClientLibOptions;\n}\n\n/**\n * A wrapper class that exposes logical methods that are conditionally fired\n * against either a configured Elasticsearch client or a configured Opensearch\n * client.\n *\n * This is necessary because, despite its intention to be API-compatible, the\n * opensearch client does not support API key-based authentication. This is\n * also the sanest way to accomplish this while making typescript happy.\n *\n * In the future, if the differences between implementations become\n * unmaintainably divergent, we should split out the Opensearch and\n * Elasticsearch search engine implementations.\n *\n * The Elasticsearch client calls below pass `{ meta: true }`. As of v8 the\n * `@elastic/elasticsearch` client returns the response body directly, whereas\n * the Opensearch client (forked from the v7 Elasticsearch client) still wraps\n * it in `{ body, statusCode, headers, ... }`. Requesting the meta envelope\n * keeps both clients returning the same shape, so consumers can continue to\n * read `response.body` regardless of the configured provider.\n *\n * @public\n */\nexport class ElasticSearchClientWrapper {\n private readonly elasticSearchClient: ElasticSearchClient | undefined;\n private readonly openSearchClient: OpenSearchClient | undefined;\n\n private constructor(options: {\n openSearchClient?: OpenSearchClient;\n elasticSearchClient?: ElasticSearchClient;\n }) {\n this.openSearchClient = options.openSearchClient;\n this.elasticSearchClient = options.elasticSearchClient;\n }\n\n static fromClientOptions(options: ElasticSearchClientOptions) {\n if (isOpenSearchCompatible(options)) {\n return new ElasticSearchClientWrapper({\n openSearchClient: new OpenSearchClient(options),\n });\n }\n\n return new ElasticSearchClientWrapper({\n elasticSearchClient: new ElasticSearchClient(\n toElasticSearchClientOptions(options),\n ),\n });\n }\n\n search(options: {\n index: string | string[];\n body: Object;\n }): ElasticSearchClientResponsePromise {\n const searchOptions = {\n ignore_unavailable: true,\n allow_no_indices: true,\n };\n\n if (this.openSearchClient) {\n return this.openSearchClient.search({\n ...options,\n ...searchOptions,\n });\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.search(\n {\n ...options,\n ...searchOptions,\n },\n { meta: true },\n );\n }\n\n throw new Error('No client defined');\n }\n\n bulk(bulkOptions: {\n datasource: Readable;\n onDocument: (doc: any) => ElasticSearchIndexAction;\n refreshOnCompletion?: string | boolean;\n }) {\n if (this.openSearchClient) {\n return this.openSearchClient.helpers.bulk(bulkOptions);\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.helpers.bulk(bulkOptions);\n }\n\n throw new Error('No client defined');\n }\n\n putIndexTemplate(\n template: ElasticSearchCustomIndexTemplate,\n ): ElasticSearchClientResponsePromise {\n if (this.openSearchClient) {\n return this.openSearchClient.indices.putIndexTemplate(template);\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.indices.putIndexTemplate(template, {\n meta: true,\n });\n }\n\n throw new Error('No client defined');\n }\n\n listIndices(options: { index: string }): ElasticSearchClientResponsePromise {\n if (this.openSearchClient) {\n return this.openSearchClient.indices.get(options);\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.indices.get(options, { meta: true });\n }\n\n throw new Error('No client defined');\n }\n\n indexExists(options: {\n index: string | string[];\n }): ElasticSearchClientResponsePromise<boolean> {\n if (this.openSearchClient) {\n return this.openSearchClient.indices.exists(options);\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.indices.exists(options, { meta: true });\n }\n\n throw new Error('No client defined');\n }\n\n deleteIndex(options: {\n index: string | string[];\n }): ElasticSearchClientResponsePromise {\n if (this.openSearchClient) {\n return this.openSearchClient.indices.delete(options);\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.indices.delete(options, { meta: true });\n }\n\n throw new Error('No client defined');\n }\n\n /**\n * @deprecated unused by the ElasticSearch Engine, will be removed in the future\n */\n getAliases(options: {\n aliases: string[];\n }): ElasticSearchClientResponsePromise {\n const { aliases } = options;\n\n if (this.openSearchClient) {\n return this.openSearchClient.cat.aliases({\n format: 'json',\n name: aliases,\n });\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.cat.aliases(\n {\n format: 'json',\n name: aliases,\n },\n { meta: true },\n );\n }\n\n throw new Error('No client defined');\n }\n\n createIndex(options: { index: string }): ElasticSearchClientResponsePromise {\n if (this.openSearchClient) {\n return this.openSearchClient.indices.create(options);\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.indices.create(options, { meta: true });\n }\n\n throw new Error('No client defined');\n }\n\n updateAliases(options: {\n actions: ElasticSearchAliasAction[];\n }): ElasticSearchClientResponsePromise {\n const filteredActions = options.actions.filter(Boolean);\n\n if (this.openSearchClient) {\n return this.openSearchClient.indices.updateAliases({\n body: {\n actions: filteredActions,\n },\n });\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.indices.updateAliases(\n {\n body: {\n actions: filteredActions as any[],\n },\n },\n { meta: true },\n );\n }\n\n throw new Error('No client defined');\n }\n}\n"],"names":["isOpenSearchCompatible","OpenSearchClient","ElasticSearchClient"],"mappings":";;;;;;AAmGA,SAAS,6BACP,OAAA,EAC+B;AAC/B,EAAA,MAAM,EAAE,GAAA,EAAK,GAAG,IAAA,EAAK,GAAI,OAAA;AACzB,EAAA,OAAO;AAAA,IACL,GAAG,IAAA;AAAA,IACH,GAAI,GAAA,GAAM,EAAE,GAAA,EAAK,GAAA,KAAQ;AAAC,GAC5B;AACF;AAwBO,MAAM,0BAAA,CAA2B;AAAA,EACrB,mBAAA;AAAA,EACA,gBAAA;AAAA,EAET,YAAY,OAAA,EAGjB;AACD,IAAA,IAAA,CAAK,mBAAmB,OAAA,CAAQ,gBAAA;AAChC,IAAA,IAAA,CAAK,sBAAsB,OAAA,CAAQ,mBAAA;AAAA,EACrC;AAAA,EAEA,OAAO,kBAAkB,OAAA,EAAqC;AAC5D,IAAA,IAAIA,iDAAA,CAAuB,OAAO,CAAA,EAAG;AACnC,MAAA,OAAO,IAAI,0BAAA,CAA2B;AAAA,QACpC,gBAAA,EAAkB,IAAIC,iBAAA,CAAiB,OAAO;AAAA,OAC/C,CAAA;AAAA,IACH;AAEA,IAAA,OAAO,IAAI,0BAAA,CAA2B;AAAA,MACpC,qBAAqB,IAAIC,oBAAA;AAAA,QACvB,6BAA6B,OAAO;AAAA;AACtC,KACD,CAAA;AAAA,EACH;AAAA,EAEA,OAAO,OAAA,EAGgC;AACrC,IAAA,MAAM,aAAA,GAAgB;AAAA,MACpB,kBAAA,EAAoB,IAAA;AAAA,MACpB,gBAAA,EAAkB;AAAA,KACpB;AAEA,IAAA,IAAI,KAAK,gBAAA,EAAkB;AACzB,MAAA,OAAO,IAAA,CAAK,iBAAiB,MAAA,CAAO;AAAA,QAClC,GAAG,OAA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"}
1
+ {"version":3,"file":"ElasticSearchClientWrapper.cjs.js","sources":["../../src/engines/ElasticSearchClientWrapper.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Client as ElasticSearchClient,\n ClientOptions as ElasticSearchClientLibOptions,\n} from '@elastic/elasticsearch';\nimport { Client as OpenSearchClient } from '@opensearch-project/opensearch';\nimport type {\n BulkHelper,\n BulkStats,\n} from '@opensearch-project/opensearch/lib/Helpers.js';\nimport { Readable } from 'node:stream';\nimport {\n ElasticSearchClientOptions,\n isOpenSearchCompatible,\n} from './ElasticSearchClientOptions';\nimport { ElasticSearchCustomIndexTemplate } from './types';\n\n/**\n * @public\n */\nexport type ElasticSearchAliasAction =\n | {\n remove: { index: any; alias: any };\n add?: undefined;\n }\n | {\n add: { indices: any; alias: any; index?: undefined };\n remove?: undefined;\n }\n | {\n add: { index: any; alias: any; indices?: undefined };\n remove?: undefined;\n }\n | undefined;\n\n/**\n * @public\n */\nexport type ElasticSearchIndexAction = {\n index: {\n _index: string;\n [key: string]: any;\n };\n};\n\n/**\n * The normalized response shape returned by the wrapped client methods.\n *\n * Both the Elasticsearch and Opensearch clients expose the response payload\n * under a `body` property together with the HTTP status code, the response\n * headers and any deprecation warnings, so consumers can read these regardless\n * of the configured provider. The client specific `meta` envelope is not part\n * of this type because its shape differs between the two clients.\n *\n * @public\n */\nexport type ElasticSearchClientResponse<TBody = any> = {\n body: TBody;\n headers: Record<string, any> | null;\n statusCode: number | null;\n warnings: string[] | null;\n};\n\n/**\n * The promise returned by the wrapped client methods.\n *\n * The Opensearch client returns a promise that additionally exposes an\n * `abort` method, whereas the Elasticsearch v8 client returns a plain\n * promise, so `abort` is only present when the Opensearch client is\n * configured.\n *\n * @public\n */\nexport type ElasticSearchClientResponsePromise<TBody = any> = Promise<\n ElasticSearchClientResponse<TBody>\n> & {\n abort?: () => void;\n};\n\n/**\n * Adapts the provider-agnostic client options to the shape expected by the\n * `@elastic/elasticsearch` v8 client.\n *\n * The v8 client reads TLS configuration from a `tls` property; the `ssl`\n * property used by the Opensearch client (and by earlier Elasticsearch client\n * versions) is no longer recognized. Map it across so that TLS settings keep\n * being honored.\n */\nfunction toElasticSearchClientOptions(\n options: ElasticSearchClientOptions,\n): ElasticSearchClientLibOptions {\n const { ssl, ...rest } = options;\n return {\n ...rest,\n ...(ssl ? { tls: ssl } : {}),\n } as ElasticSearchClientLibOptions;\n}\n\n/**\n * A wrapper class that exposes logical methods that are conditionally fired\n * against either a configured Elasticsearch client or a configured Opensearch\n * client.\n *\n * This is necessary because, despite its intention to be API-compatible, the\n * opensearch client does not support API key-based authentication. This is\n * also the sanest way to accomplish this while making typescript happy.\n *\n * In the future, if the differences between implementations become\n * unmaintainably divergent, we should split out the Opensearch and\n * Elasticsearch search engine implementations.\n *\n * The Elasticsearch client calls below pass `{ meta: true }`. As of v8 the\n * `@elastic/elasticsearch` client returns the response body directly, whereas\n * the Opensearch client (forked from the v7 Elasticsearch client) still wraps\n * it in `{ body, statusCode, headers, ... }`. Requesting the meta envelope\n * keeps both clients returning the same shape, so consumers can continue to\n * read `response.body` regardless of the configured provider.\n *\n * @public\n */\nexport class ElasticSearchClientWrapper {\n private readonly elasticSearchClient: ElasticSearchClient | undefined;\n private readonly openSearchClient: OpenSearchClient | undefined;\n\n private constructor(options: {\n openSearchClient?: OpenSearchClient;\n elasticSearchClient?: ElasticSearchClient;\n }) {\n this.openSearchClient = options.openSearchClient;\n this.elasticSearchClient = options.elasticSearchClient;\n }\n\n static fromClientOptions(options: ElasticSearchClientOptions) {\n if (isOpenSearchCompatible(options)) {\n return new ElasticSearchClientWrapper({\n openSearchClient: new OpenSearchClient(options),\n });\n }\n\n return new ElasticSearchClientWrapper({\n elasticSearchClient: new ElasticSearchClient(\n toElasticSearchClientOptions(options),\n ),\n });\n }\n\n search(options: {\n index: string | string[];\n body: Object;\n }): ElasticSearchClientResponsePromise {\n const searchOptions = {\n ignore_unavailable: true,\n allow_no_indices: true,\n };\n\n if (this.openSearchClient) {\n return this.openSearchClient.search({\n ...options,\n ...searchOptions,\n });\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.search(\n {\n ...options,\n ...searchOptions,\n },\n { meta: true },\n );\n }\n\n throw new Error('No client defined');\n }\n\n bulk(bulkOptions: {\n datasource: Readable;\n onDocument: (doc: any) => ElasticSearchIndexAction;\n refreshOnCompletion?: string | boolean;\n }): BulkHelper<BulkStats> {\n if (this.openSearchClient) {\n return this.openSearchClient.helpers.bulk(bulkOptions);\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.helpers.bulk(bulkOptions);\n }\n\n throw new Error('No client defined');\n }\n\n putIndexTemplate(\n template: ElasticSearchCustomIndexTemplate,\n ): ElasticSearchClientResponsePromise {\n if (this.openSearchClient) {\n return this.openSearchClient.indices.putIndexTemplate(template);\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.indices.putIndexTemplate(template, {\n meta: true,\n });\n }\n\n throw new Error('No client defined');\n }\n\n listIndices(options: { index: string }): ElasticSearchClientResponsePromise {\n if (this.openSearchClient) {\n return this.openSearchClient.indices.get(options);\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.indices.get(options, { meta: true });\n }\n\n throw new Error('No client defined');\n }\n\n indexExists(options: {\n index: string | string[];\n }): ElasticSearchClientResponsePromise<boolean> {\n if (this.openSearchClient) {\n return this.openSearchClient.indices.exists(options);\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.indices.exists(options, { meta: true });\n }\n\n throw new Error('No client defined');\n }\n\n deleteIndex(options: {\n index: string | string[];\n }): ElasticSearchClientResponsePromise {\n if (this.openSearchClient) {\n return this.openSearchClient.indices.delete(options);\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.indices.delete(options, { meta: true });\n }\n\n throw new Error('No client defined');\n }\n\n /**\n * @deprecated unused by the ElasticSearch Engine, will be removed in the future\n */\n getAliases(options: {\n aliases: string[];\n }): ElasticSearchClientResponsePromise {\n const { aliases } = options;\n\n if (this.openSearchClient) {\n return this.openSearchClient.cat.aliases({\n format: 'json',\n name: aliases,\n });\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.cat.aliases(\n {\n format: 'json',\n name: aliases,\n },\n { meta: true },\n );\n }\n\n throw new Error('No client defined');\n }\n\n createIndex(options: { index: string }): ElasticSearchClientResponsePromise {\n if (this.openSearchClient) {\n return this.openSearchClient.indices.create(options);\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.indices.create(options, { meta: true });\n }\n\n throw new Error('No client defined');\n }\n\n updateAliases(options: {\n actions: ElasticSearchAliasAction[];\n }): ElasticSearchClientResponsePromise {\n const filteredActions = options.actions.filter(Boolean);\n\n if (this.openSearchClient) {\n return this.openSearchClient.indices.updateAliases({\n body: {\n actions: filteredActions,\n },\n });\n }\n\n if (this.elasticSearchClient) {\n return this.elasticSearchClient.indices.updateAliases(\n {\n body: {\n actions: filteredActions as any[],\n },\n },\n { meta: true },\n );\n }\n\n throw new Error('No client defined');\n }\n}\n"],"names":["isOpenSearchCompatible","OpenSearchClient","ElasticSearchClient"],"mappings":";;;;;;AAuGA,SAAS,6BACP,OAAA,EAC+B;AAC/B,EAAA,MAAM,EAAE,GAAA,EAAK,GAAG,IAAA,EAAK,GAAI,OAAA;AACzB,EAAA,OAAO;AAAA,IACL,GAAG,IAAA;AAAA,IACH,GAAI,GAAA,GAAM,EAAE,GAAA,EAAK,GAAA,KAAQ;AAAC,GAC5B;AACF;AAwBO,MAAM,0BAAA,CAA2B;AAAA,EACrB,mBAAA;AAAA,E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B,MAAA,OAAO,IAAA,CAAK,oBAAoB,OAAA,CAAQ,MAAA,CAAO,SAAS,EAAE,IAAA,EAAM,MAAM,CAAA;AAAA,IACxE;AAEA,IAAA,MAAM,IAAI,MAAM,mBAAmB,CAAA;AAAA,EACrC;AAAA,EAEA,cAAc,OAAA,EAEyB;AACrC,IAAA,MAAM,eAAA,GAAkB,OAAA,CAAQ,OAAA,CAAQ,MAAA,CAAO,OAAO,CAAA;AAEtD,IAAA,IAAI,KAAK,gBAAA,EAAkB;AACzB,MAAA,OAAO,IAAA,CAAK,gBAAA,CAAiB,OAAA,CAAQ,aAAA,CAAc;AAAA,QACjD,IAAA,EAAM;AAAA,UACJ,OAAA,EAAS;AAAA;AACX,OACD,CAAA;AAAA,IACH;AAEA,IAAA,IAAI,KAAK,mBAAA,EAAqB;AAC5B,MAAA,OAAO,IAAA,CAAK,oBAAoB,OAAA,CAAQ,aAAA;AAAA,QACtC;AAAA,UACE,IAAA,EAAM;AAAA,YACJ,OAAA,EAAS;AAAA;AACX,SACF;AAAA,QACA,EAAE,MAAM,IAAA;AAAK,OACf;AAAA,IACF;AAEA,IAAA,MAAM,IAAI,MAAM,mBAAmB,CAAA;AAAA,EACrC;AACF;;"}
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { IndexableDocument, SearchQuery, IndexableResultSet } from '@backstage/p
4
4
  import { BatchSearchEngineIndexer, SearchEngine } from '@backstage/plugin-search-backend-node';
5
5
  import { Config } from '@backstage/config';
6
6
  import { ConnectionOptions } from 'node:tls';
7
- import * as _opensearch_project_opensearch_lib_Helpers_js from '@opensearch-project/opensearch/lib/Helpers.js';
7
+ import { BulkHelper, BulkStats } from '@opensearch-project/opensearch/lib/Helpers.js';
8
8
  import { Readable } from 'node:stream';
9
9
 
10
10
  /**
@@ -318,7 +318,7 @@ declare class ElasticSearchClientWrapper {
318
318
  datasource: Readable;
319
319
  onDocument: (doc: any) => ElasticSearchIndexAction;
320
320
  refreshOnCompletion?: string | boolean;
321
- }): _opensearch_project_opensearch_lib_Helpers_js.BulkHelper<_opensearch_project_opensearch_lib_Helpers_js.BulkStats>;
321
+ }): BulkHelper<BulkStats>;
322
322
  putIndexTemplate(template: ElasticSearchCustomIndexTemplate): ElasticSearchClientResponsePromise;
323
323
  listIndices(options: {
324
324
  index: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-search-backend-module-elasticsearch",
3
- "version": "2.0.1",
3
+ "version": "2.0.2-next.1",
4
4
  "description": "A module for the search backend that implements search using ElasticSearch",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -62,11 +62,11 @@
62
62
  "test": "backstage-cli package test"
63
63
  },
64
64
  "dependencies": {
65
- "@backstage/backend-plugin-api": "^1.11.0",
66
- "@backstage/config": "^1.3.10",
67
- "@backstage/integration-aws-node": "^0.2.3",
68
- "@backstage/plugin-search-backend-node": "^1.4.9",
69
- "@backstage/plugin-search-common": "^1.2.26",
65
+ "@backstage/backend-plugin-api": "1.11.1-next.0",
66
+ "@backstage/config": "1.3.10",
67
+ "@backstage/integration-aws-node": "0.2.4-next.0",
68
+ "@backstage/plugin-search-backend-node": "1.4.10-next.0",
69
+ "@backstage/plugin-search-common": "1.2.26",
70
70
  "@elastic/elasticsearch": "^8.19.0",
71
71
  "@opensearch-project/opensearch": "^2.2.1",
72
72
  "aws4": "^1.12.0",
@@ -74,8 +74,8 @@
74
74
  "lodash": "^4.17.21"
75
75
  },
76
76
  "devDependencies": {
77
- "@backstage/backend-test-utils": "^1.11.8",
78
- "@backstage/cli": "^0.36.7",
77
+ "@backstage/backend-test-utils": "1.11.9-next.1",
78
+ "@backstage/cli": "0.36.8-next.1",
79
79
  "@elastic/elasticsearch-mock": "^2.0.0",
80
80
  "@short.io/opensearch-mock": "^0.4.0",
81
81
  "@types/aws4": "^1.5.1"