From 85fe814f796ca105f31358dc83cba3038fb08132 Mon Sep 17 00:00:00 2001 From: Elastic Machine Date: Wed, 4 Oct 2023 09:21:33 -0500 Subject: [PATCH 01/33] Auto-generated code for main (#2028) --- docs/reference.asciidoc | 7 +++++++ src/api/api/ml.ts | 2 +- src/api/types.ts | 1 + src/api/typesWithBodyKey.ts | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index 56d17f6db..eee72b07c 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -6302,6 +6302,13 @@ ELSER the config is not required. ** *`model_size_bytes` (Optional, number)*: The estimated memory usage in bytes to keep the trained model in memory. This property is supported only if defer_definition_decompression is true or the model definition is not supplied. +** *`platform_architecture` (Optional, string)*: The platform architecture (if applicable) of the trained mode. If the model +only works on one platform, because it is heavily optimized for a particular +processor architecture and OS combination, then this field specifies which. +The format of the string must match the platform identifiers used by Elasticsearch, +so one of, `linux-x86_64`, `linux-aarch64`, `darwin-x86_64`, `darwin-aarch64`, +or `windows-x86_64`. For portable models (those that work independent of processor +architecture or OS features), leave this field unset. ** *`tags` (Optional, string[])*: An array of tags to organize the model. ** *`defer_definition_decompression` (Optional, boolean)*: If set to `true` and a `compressed_definition` is provided, the request defers definition decompression and skips relevant validations. diff --git a/src/api/api/ml.ts b/src/api/api/ml.ts index 27ccefdb9..ffebde954 100644 --- a/src/api/api/ml.ts +++ b/src/api/api/ml.ts @@ -1821,7 +1821,7 @@ export default class Ml { async putTrainedModel (this: That, params: T.MlPutTrainedModelRequest | TB.MlPutTrainedModelRequest, options?: TransportRequestOptions): Promise async putTrainedModel (this: That, params: T.MlPutTrainedModelRequest | TB.MlPutTrainedModelRequest, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['model_id'] - const acceptedBody: string[] = ['compressed_definition', 'definition', 'description', 'inference_config', 'input', 'metadata', 'model_type', 'model_size_bytes', 'tags'] + const acceptedBody: string[] = ['compressed_definition', 'definition', 'description', 'inference_config', 'input', 'metadata', 'model_type', 'model_size_bytes', 'platform_architecture', 'tags'] const querystring: Record = {} // @ts-expect-error const userBody: any = params?.body diff --git a/src/api/types.ts b/src/api/types.ts index 7748aa7e7..c879844ca 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -13977,6 +13977,7 @@ export interface MlPutTrainedModelRequest extends RequestBase { metadata?: any model_type?: MlTrainedModelType model_size_bytes?: long + platform_architecture?: string tags?: string[] } diff --git a/src/api/typesWithBodyKey.ts b/src/api/typesWithBodyKey.ts index 8b077f0f6..619658ce9 100644 --- a/src/api/typesWithBodyKey.ts +++ b/src/api/typesWithBodyKey.ts @@ -14233,6 +14233,7 @@ export interface MlPutTrainedModelRequest extends RequestBase { metadata?: any model_type?: MlTrainedModelType model_size_bytes?: long + platform_architecture?: string tags?: string[] } } From 186692c4b62be3f65c7f1532d546008b57e788ac Mon Sep 17 00:00:00 2001 From: Elastic Machine Date: Tue, 17 Oct 2023 05:03:29 +1100 Subject: [PATCH 02/33] Auto-generated code for main (#2030) --- docs/reference.asciidoc | 4 ++-- src/api/api/logstash.ts | 9 +++++---- src/api/types.ts | 7 +++++-- src/api/typesWithBodyKey.ts | 7 +++++-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index eee72b07c..92db3bbab 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -4942,14 +4942,14 @@ Retrieves Logstash Pipelines used by Central Management {ref}/logstash-api-get-pipeline.html[Endpoint documentation] [source,ts] ---- -client.logstash.getPipeline({ id }) +client.logstash.getPipeline({ ... }) ---- [discrete] ==== Arguments * *Request (object):* -** *`id` (string | string[])*: List of pipeline identifiers. +** *`id` (Optional, string | string[])*: List of pipeline identifiers. [discrete] ==== put_pipeline diff --git a/src/api/api/logstash.ts b/src/api/api/logstash.ts index 0b85093de..9367e308a 100644 --- a/src/api/api/logstash.ts +++ b/src/api/api/logstash.ts @@ -73,14 +73,15 @@ export default class Logstash { * Retrieves Logstash Pipelines used by Central Management * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/master/logstash-api-get-pipeline.html | Elasticsearch API documentation} */ - async getPipeline (this: That, params: T.LogstashGetPipelineRequest | TB.LogstashGetPipelineRequest, options?: TransportRequestOptionsWithOutMeta): Promise - async getPipeline (this: That, params: T.LogstashGetPipelineRequest | TB.LogstashGetPipelineRequest, options?: TransportRequestOptionsWithMeta): Promise> - async getPipeline (this: That, params: T.LogstashGetPipelineRequest | TB.LogstashGetPipelineRequest, options?: TransportRequestOptions): Promise - async getPipeline (this: That, params: T.LogstashGetPipelineRequest | TB.LogstashGetPipelineRequest, options?: TransportRequestOptions): Promise { + async getPipeline (this: That, params?: T.LogstashGetPipelineRequest | TB.LogstashGetPipelineRequest, options?: TransportRequestOptionsWithOutMeta): Promise + async getPipeline (this: That, params?: T.LogstashGetPipelineRequest | TB.LogstashGetPipelineRequest, options?: TransportRequestOptionsWithMeta): Promise> + async getPipeline (this: That, params?: T.LogstashGetPipelineRequest | TB.LogstashGetPipelineRequest, options?: TransportRequestOptions): Promise + async getPipeline (this: That, params?: T.LogstashGetPipelineRequest | TB.LogstashGetPipelineRequest, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['id'] const querystring: Record = {} const body = undefined + params = params ?? {} for (const key in params) { if (acceptedPath.includes(key)) { continue diff --git a/src/api/types.ts b/src/api/types.ts index c879844ca..9cd35fef9 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -2009,6 +2009,9 @@ export interface ClusterStatistics { skipped: integer successful: integer total: integer + running: integer + partial: integer + failed: integer details?: Record } @@ -4930,7 +4933,7 @@ export interface MappingFieldNamesField { enabled: boolean } -export type MappingFieldType = 'none' | 'geo_point' | 'geo_shape' | 'ip' | 'binary' | 'keyword' | 'text' | 'search_as_you_type' | 'date' | 'date_nanos' | 'boolean' | 'completion' | 'nested' | 'object' | 'murmur3' | 'token_count' | 'percolator' | 'integer' | 'long' | 'short' | 'byte' | 'float' | 'half_float' | 'scaled_float' | 'double' | 'integer_range' | 'float_range' | 'long_range' | 'double_range' | 'date_range' | 'ip_range' | 'alias' | 'join' | 'rank_feature' | 'rank_features' | 'flattened' | 'shape' | 'histogram' | 'constant_keyword' | 'aggregate_metric_double' | 'dense_vector' | 'match_only_text' +export type MappingFieldType = 'none' | 'geo_point' | 'geo_shape' | 'ip' | 'binary' | 'keyword' | 'text' | 'search_as_you_type' | 'date' | 'date_nanos' | 'boolean' | 'completion' | 'nested' | 'object' | 'murmur3' | 'token_count' | 'percolator' | 'integer' | 'long' | 'short' | 'byte' | 'float' | 'half_float' | 'scaled_float' | 'double' | 'integer_range' | 'float_range' | 'long_range' | 'double_range' | 'date_range' | 'ip_range' | 'alias' | 'join' | 'rank_feature' | 'rank_features' | 'flattened' | 'shape' | 'histogram' | 'constant_keyword' | 'aggregate_metric_double' | 'dense_vector' | 'sparse_vector' | 'match_only_text' export interface MappingFlattenedProperty extends MappingPropertyBase { boost?: double @@ -11809,7 +11812,7 @@ export interface LogstashDeletePipelineRequest extends RequestBase { export type LogstashDeletePipelineResponse = boolean export interface LogstashGetPipelineRequest extends RequestBase { - id: Ids + id?: Ids } export type LogstashGetPipelineResponse = Record diff --git a/src/api/typesWithBodyKey.ts b/src/api/typesWithBodyKey.ts index 619658ce9..1afe734f8 100644 --- a/src/api/typesWithBodyKey.ts +++ b/src/api/typesWithBodyKey.ts @@ -2082,6 +2082,9 @@ export interface ClusterStatistics { skipped: integer successful: integer total: integer + running: integer + partial: integer + failed: integer details?: Record } @@ -5003,7 +5006,7 @@ export interface MappingFieldNamesField { enabled: boolean } -export type MappingFieldType = 'none' | 'geo_point' | 'geo_shape' | 'ip' | 'binary' | 'keyword' | 'text' | 'search_as_you_type' | 'date' | 'date_nanos' | 'boolean' | 'completion' | 'nested' | 'object' | 'murmur3' | 'token_count' | 'percolator' | 'integer' | 'long' | 'short' | 'byte' | 'float' | 'half_float' | 'scaled_float' | 'double' | 'integer_range' | 'float_range' | 'long_range' | 'double_range' | 'date_range' | 'ip_range' | 'alias' | 'join' | 'rank_feature' | 'rank_features' | 'flattened' | 'shape' | 'histogram' | 'constant_keyword' | 'aggregate_metric_double' | 'dense_vector' | 'match_only_text' +export type MappingFieldType = 'none' | 'geo_point' | 'geo_shape' | 'ip' | 'binary' | 'keyword' | 'text' | 'search_as_you_type' | 'date' | 'date_nanos' | 'boolean' | 'completion' | 'nested' | 'object' | 'murmur3' | 'token_count' | 'percolator' | 'integer' | 'long' | 'short' | 'byte' | 'float' | 'half_float' | 'scaled_float' | 'double' | 'integer_range' | 'float_range' | 'long_range' | 'double_range' | 'date_range' | 'ip_range' | 'alias' | 'join' | 'rank_feature' | 'rank_features' | 'flattened' | 'shape' | 'histogram' | 'constant_keyword' | 'aggregate_metric_double' | 'dense_vector' | 'sparse_vector' | 'match_only_text' export interface MappingFlattenedProperty extends MappingPropertyBase { boost?: double @@ -11989,7 +11992,7 @@ export interface LogstashDeletePipelineRequest extends RequestBase { export type LogstashDeletePipelineResponse = boolean export interface LogstashGetPipelineRequest extends RequestBase { - id: Ids + id?: Ids } export type LogstashGetPipelineResponse = Record From f7f1d7c52e8e820002b2dc58f6f641a5f47306e7 Mon Sep 17 00:00:00 2001 From: Elastic Machine Date: Thu, 19 Oct 2023 02:08:56 +1100 Subject: [PATCH 03/33] Auto-generated code for main (#2033) --- src/api/types.ts | 7 +++++++ src/api/typesWithBodyKey.ts | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/api/types.ts b/src/api/types.ts index 9cd35fef9..9d9176873 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -2286,6 +2286,8 @@ export type Level = 'cluster' | 'indices' | 'shards' export type LifecycleOperationMode = 'RUNNING' | 'STOPPING' | 'STOPPED' +export type ManagedBy = 'Index Lifecycle Management' | 'Data Stream Lifecycle' | 'Unmanaged' + export type MapboxVectorTiles = ArrayBuffer export interface MergesStats { @@ -9523,6 +9525,8 @@ export interface IndicesDataStream { generation: integer hidden: boolean ilm_policy?: Name + next_generation_managed_by: ManagedBy + prefer_ilm: boolean indices: IndicesDataStreamIndex[] lifecycle?: IndicesDataStreamLifecycleWithRollover name: DataStreamName @@ -9536,6 +9540,9 @@ export interface IndicesDataStream { export interface IndicesDataStreamIndex { index_name: IndexName index_uuid: Uuid + ilm_policy?: Name + managed_by: ManagedBy + prefer_ilm: boolean } export interface IndicesDataStreamLifecycle { diff --git a/src/api/typesWithBodyKey.ts b/src/api/typesWithBodyKey.ts index 1afe734f8..7016b27c3 100644 --- a/src/api/typesWithBodyKey.ts +++ b/src/api/typesWithBodyKey.ts @@ -2359,6 +2359,8 @@ export type Level = 'cluster' | 'indices' | 'shards' export type LifecycleOperationMode = 'RUNNING' | 'STOPPING' | 'STOPPED' +export type ManagedBy = 'Index Lifecycle Management' | 'Data Stream Lifecycle' | 'Unmanaged' + export type MapboxVectorTiles = ArrayBuffer export interface MergesStats { @@ -9646,6 +9648,8 @@ export interface IndicesDataStream { generation: integer hidden: boolean ilm_policy?: Name + next_generation_managed_by: ManagedBy + prefer_ilm: boolean indices: IndicesDataStreamIndex[] lifecycle?: IndicesDataStreamLifecycleWithRollover name: DataStreamName @@ -9659,6 +9663,9 @@ export interface IndicesDataStream { export interface IndicesDataStreamIndex { index_name: IndexName index_uuid: Uuid + ilm_policy?: Name + managed_by: ManagedBy + prefer_ilm: boolean } export interface IndicesDataStreamLifecycle { From 78cc262939d18195c00e229bf15854f435138e1f Mon Sep 17 00:00:00 2001 From: Elastic Machine Date: Tue, 24 Oct 2023 04:46:35 +1100 Subject: [PATCH 04/33] Auto-generated code for main (#2034) --- src/api/types.ts | 2 +- src/api/typesWithBodyKey.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/types.ts b/src/api/types.ts index 9d9176873..5f1885b02 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -2286,7 +2286,7 @@ export type Level = 'cluster' | 'indices' | 'shards' export type LifecycleOperationMode = 'RUNNING' | 'STOPPING' | 'STOPPED' -export type ManagedBy = 'Index Lifecycle Management' | 'Data Stream Lifecycle' | 'Unmanaged' +export type ManagedBy = 'Index Lifecycle Management' | 'Data stream lifecycle' | 'Unmanaged' export type MapboxVectorTiles = ArrayBuffer diff --git a/src/api/typesWithBodyKey.ts b/src/api/typesWithBodyKey.ts index 7016b27c3..993be2b15 100644 --- a/src/api/typesWithBodyKey.ts +++ b/src/api/typesWithBodyKey.ts @@ -2359,7 +2359,7 @@ export type Level = 'cluster' | 'indices' | 'shards' export type LifecycleOperationMode = 'RUNNING' | 'STOPPING' | 'STOPPED' -export type ManagedBy = 'Index Lifecycle Management' | 'Data Stream Lifecycle' | 'Unmanaged' +export type ManagedBy = 'Index Lifecycle Management' | 'Data stream lifecycle' | 'Unmanaged' export type MapboxVectorTiles = ArrayBuffer From a28a6a3654b84808786c3e031e9b4e65d4e2f8f4 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Mon, 23 Oct 2023 14:05:39 -0500 Subject: [PATCH 05/33] Improve proxy configuration docs (#2035) --- docs/connecting.asciidoc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/connecting.asciidoc b/docs/connecting.asciidoc index 239eea79e..dab9bc4c6 100644 --- a/docs/connecting.asciidoc +++ b/docs/connecting.asciidoc @@ -539,11 +539,17 @@ If you need to pass through an http(s) proxy for connecting to {es}, the client out of the box offers a handy configuration for helping you with it. Under the hood, it uses the https://github.com/delvedor/hpagent[`hpagent`] module. +In versions 8.0+ of the client, the default `Connection` type is set to `UndiciConnection`, which does not support proxy configurations. +To use a proxy, you will need to use the `HttpConnection` class from `@elastic/transport` instead. + [source,js] ---- +import { HttpConnection } from '@elastic/transport' + const client = new Client({ node: 'http://localhost:9200', - proxy: 'http://localhost:8080' + proxy: 'http://localhost:8080', + Connection: HttpConnection, }) ---- @@ -553,11 +559,12 @@ Basic authentication is supported as well: ---- const client = new Client({ node: 'http://localhost:9200', - proxy: 'http:user:pwd@//localhost:8080' + proxy: 'http:user:pwd@//localhost:8080', + Connection: HttpConnection, }) ---- -If you are connecting through a not http(s) proxy, such as a `socks5` or `pac`, +If you are connecting through a non-http(s) proxy, such as a `socks5` or `pac`, you can use the `agent` option to configure it. [source,js] @@ -567,7 +574,8 @@ const client = new Client({ node: 'http://localhost:9200', agent () { return new SocksProxyAgent('socks://127.0.0.1:1080') - } + }, + Connection: HttpConnection, }) ---- From d194a220ea1a7772b27c2f3269f90c7aa4709619 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Tue, 24 Oct 2023 12:22:31 -0500 Subject: [PATCH 06/33] Fix backport action (#2036) This should allow us to backport PRs from forks, and gets the action on a newer commit. --- .github/workflows/backport.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 906f1474b..56d4f328a 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -1,16 +1,27 @@ +--- name: Backport on: - pull_request: + pull_request_target: types: - closed - labeled jobs: backport: - runs-on: ubuntu-latest name: Backport + runs-on: ubuntu-latest + # Only react to merged PRs for security reasons. + # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target. + if: > + github.event.pull_request.merged + && ( + github.event.action == 'closed' + || ( + github.event.action == 'labeled' + && contains(github.event.label.name, 'backport') + ) + ) steps: - - name: Backport - uses: tibdex/backport@7005ef85c4562bc23b0e9b4a9940d5922f439750 + - uses: tibdex/backport@9565281eda0731b1d20c4025c43339fb0a23812e # v2.0.4 with: github_token: ${{ secrets.GITHUB_TOKEN }} From f7ed0394bfac6adfaaf8b9bd1b4d2ed67c1db554 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Tue, 24 Oct 2023 15:32:27 -0500 Subject: [PATCH 07/33] Add important flag to proxy config docs (#2040) --- docs/connecting.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/connecting.asciidoc b/docs/connecting.asciidoc index dab9bc4c6..5e1bd2366 100644 --- a/docs/connecting.asciidoc +++ b/docs/connecting.asciidoc @@ -539,7 +539,7 @@ If you need to pass through an http(s) proxy for connecting to {es}, the client out of the box offers a handy configuration for helping you with it. Under the hood, it uses the https://github.com/delvedor/hpagent[`hpagent`] module. -In versions 8.0+ of the client, the default `Connection` type is set to `UndiciConnection`, which does not support proxy configurations. +IMPORTANT: In versions 8.0+ of the client, the default `Connection` type is set to `UndiciConnection`, which does not support proxy configurations. To use a proxy, you will need to use the `HttpConnection` class from `@elastic/transport` instead. [source,js] From 84a93c2ebfd62400d9e4b479b32dff3720f11fee Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Tue, 24 Oct 2023 15:40:00 -0500 Subject: [PATCH 08/33] Skip unit tests for PRs where code did not change (#2041) --- .github/workflows/nodejs.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index ca00cb372..6443f0ee8 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -1,7 +1,19 @@ --- name: Node CI -on: [push, pull_request] +on: + push: + paths-ignore: &ignore + - '**/*.md' + - '**/*.asciidoc' + - '**/*.txt' + - 'docs/**' + - '.ci/**' + - '.buildkite/**' + - 'scripts/**' + - 'catalog-info.yaml' + pull_request: + paths-ignore: *ignore jobs: test: From dc7d603f4734f1e9cfff8882f0f462934f1de9e0 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Tue, 31 Oct 2023 11:53:22 -0500 Subject: [PATCH 09/33] Fix unit test workflow (#2045) --- .github/workflows/nodejs.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 6443f0ee8..4fe2b1236 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -3,7 +3,7 @@ name: Node CI on: push: - paths-ignore: &ignore + paths-ignore: - '**/*.md' - '**/*.asciidoc' - '**/*.txt' @@ -13,7 +13,15 @@ on: - 'scripts/**' - 'catalog-info.yaml' pull_request: - paths-ignore: *ignore + paths-ignore: + - '**/*.md' + - '**/*.asciidoc' + - '**/*.txt' + - 'docs/**' + - '.ci/**' + - '.buildkite/**' + - 'scripts/**' + - 'catalog-info.yaml' jobs: test: From a6392ebe07c3d2884a725d024c7d237dd99cbd98 Mon Sep 17 00:00:00 2001 From: Elastic Machine Date: Thu, 2 Nov 2023 03:14:57 +1100 Subject: [PATCH 10/33] Auto-generated code for main (#2047) --- docs/reference.asciidoc | 1 + src/api/api/ml.ts | 2 +- src/api/types.ts | 1 + src/api/typesWithBodyKey.ts | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index 92db3bbab..0c5563289 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -6370,6 +6370,7 @@ client.ml.putTrainedModelVocabulary({ model_id, vocabulary }) ** *`model_id` (string)*: The unique identifier of the trained model. ** *`vocabulary` (string[])*: The model vocabulary, which must not be empty. ** *`merges` (Optional, string[])*: The optional model merges if required by the tokenizer. +** *`scores` (Optional, number[])*: The optional vocabulary value scores if required by the tokenizer. [discrete] ==== reset_job diff --git a/src/api/api/ml.ts b/src/api/api/ml.ts index ffebde954..e0f57a2ad 100644 --- a/src/api/api/ml.ts +++ b/src/api/api/ml.ts @@ -1923,7 +1923,7 @@ export default class Ml { async putTrainedModelVocabulary (this: That, params: T.MlPutTrainedModelVocabularyRequest | TB.MlPutTrainedModelVocabularyRequest, options?: TransportRequestOptions): Promise async putTrainedModelVocabulary (this: That, params: T.MlPutTrainedModelVocabularyRequest | TB.MlPutTrainedModelVocabularyRequest, options?: TransportRequestOptions): Promise { const acceptedPath: string[] = ['model_id'] - const acceptedBody: string[] = ['vocabulary', 'merges'] + const acceptedBody: string[] = ['vocabulary', 'merges', 'scores'] const querystring: Record = {} // @ts-expect-error const userBody: any = params?.body diff --git a/src/api/types.ts b/src/api/types.ts index 5f1885b02..13b4c40d4 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -14051,6 +14051,7 @@ export interface MlPutTrainedModelVocabularyRequest extends RequestBase { model_id: Id vocabulary: string[] merges?: string[] + scores?: double[] } export type MlPutTrainedModelVocabularyResponse = AcknowledgedResponseBase diff --git a/src/api/typesWithBodyKey.ts b/src/api/typesWithBodyKey.ts index 993be2b15..68b792bc3 100644 --- a/src/api/typesWithBodyKey.ts +++ b/src/api/typesWithBodyKey.ts @@ -14313,6 +14313,7 @@ export interface MlPutTrainedModelVocabularyRequest extends RequestBase { body?: { vocabulary: string[] merges?: string[] + scores?: double[] } } From f1e83ae853da8743688eee0f9b3f120a0080b00b Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Thu, 2 Nov 2023 10:15:28 -0500 Subject: [PATCH 11/33] Add more docs about keep-alive connections (#2048) --- docs/connecting.asciidoc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/docs/connecting.asciidoc b/docs/connecting.asciidoc index 5e1bd2366..77c2e7d11 100644 --- a/docs/connecting.asciidoc +++ b/docs/connecting.asciidoc @@ -11,6 +11,7 @@ This page contains the information you need to connect and use the Client with * <> * <> * <> +* <> * <> [[authentication]] @@ -659,6 +660,37 @@ a|* `name` - `string` * `headers` - `object`, the response status code |=== +[[keep-alive]] +[discrete] +=== Keep-alive connections + +By default, the client uses persistent, keep-alive connections to reduce the overhead of creating a new HTTP connection for each Elasticsearch request. +If you are using the default `UndiciConnection` connection class, it maintains a pool of 256 connections with a keep-alive of 10 minutes. +If you are using the legacy `HttpConnection` connection class, it maintains a pool of 256 connections with a keep-alive of 1 minute. + +If you need to disable keep-alive connections, you can override the HTTP agent with your preferred https://nodejs.org/api/http.html#http_new_agent_options[HTTP agent options]: + +[source,js] +---- +const client = new Client({ + node: 'http://localhost:9200', + // the function takes as parameter the option + // object passed to the Connection constructor + agent: (opts) => new CustomAgent() +}) +---- + +Or you can disable the HTTP agent entirely: + +[source,js] +---- +const client = new Client({ + node: 'http://localhost:9200', + // Disable agent and keep-alive + agent: false +}) +---- + [discrete] [[product-check]] === Automatic product check From 96d0adb7155caccfa22f7c75cfcc3c390ef6dc44 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Thu, 2 Nov 2023 10:26:20 -0500 Subject: [PATCH 12/33] Action to auto-close stale issues and PRs (#2051) --- .github/workflows/stale.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 000000000..3970f1d8d --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,21 @@ +--- +name: 'Close stale issues and PRs' +on: + schedule: + - cron: '30 1 * * *' + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v8 + with: + stale-issue-label: stale + stale-pr-label: stale + days-before-stale: 90 + days-before-close: 14 + exempt-issue-labels: 'good first issue' + close-issue-label: closed-stale + close-pr-label: closed-stale + stale-issue-message: 'This issue is stale because it has been open 90 days with no activity. Remove the `stale` label, or leave a comment, or this will be closed in 14 days.' + stale-pr-message: 'This pull request is stale because it has been open 90 days with no activity. Remove the `stale` label, or leave a comment, or this will be closed in 14 days.' From 2d139e512b8aeee2233e739d0fffd47f9cab9db9 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Thu, 2 Nov 2023 11:16:39 -0500 Subject: [PATCH 13/33] Improve unit test path filtering rules (#2052) * Improve path-filtering rules on unit test action See docs about how jobs that are skipped still report "success", which is necessary for jobs that are required to succeed based on branch protection rules. https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution * Code must be checked out for paths-filter to run * Only run on default pull request events Defaults are that it will run when a PR is opened, reopened, or synchronized (new commits pushed). --- .github/workflows/nodejs.yml | 47 ++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 4fe2b1236..92d2ca72b 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -2,31 +2,36 @@ name: Node CI on: - push: - paths-ignore: - - '**/*.md' - - '**/*.asciidoc' - - '**/*.txt' - - 'docs/**' - - '.ci/**' - - '.buildkite/**' - - 'scripts/**' - - 'catalog-info.yaml' - pull_request: - paths-ignore: - - '**/*.md' - - '**/*.asciidoc' - - '**/*.txt' - - 'docs/**' - - '.ci/**' - - '.buildkite/**' - - 'scripts/**' - - 'catalog-info.yaml' + pull_request: {} jobs: + paths-filter: + name: Detect files changed + runs-on: ubuntu-latest + outputs: + skip: '${{ steps.changes.outputs.skip }}' + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter/@v2.11.1 + id: changes + with: + filters: | + skip: + - '**/*.md' + - '**/*.asciidoc' + - '**/*.txt' + - 'docs/**' + - '.ci/**' + - '.buildkite/**' + - 'scripts/**' + - 'catalog-info.yaml' + test: name: Test runs-on: ${{ matrix.os }} + needs: paths-filter + # only run if files not in `skip` filter were changed + if: needs.paths-filter.outputs.skip != 'true' strategy: fail-fast: false @@ -35,7 +40,7 @@ jobs: os: [ubuntu-latest, windows-latest, macOS-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 From 1adc8c356ab471e79a09ea581ea1df03814606e3 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Thu, 2 Nov 2023 11:48:16 -0500 Subject: [PATCH 14/33] Fix version bump script (#2054) * Fix version bump script failure It was trying to run `.replace` on a Buffer instead of a string. * Correctly set Node version in Docker --- .ci/Dockerfile | 2 +- .ci/make.mjs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.ci/Dockerfile b/.ci/Dockerfile index 1f10aed8c..cf5ff29a6 100644 --- a/.ci/Dockerfile +++ b/.ci/Dockerfile @@ -1,4 +1,4 @@ -ARG NODE_JS_VERSION=18 +ARG NODE_JS_VERSION=${NODE_JS_VERSION:-18} FROM node:${NODE_JS_VERSION} ARG BUILDER_UID=1000 diff --git a/.ci/make.mjs b/.ci/make.mjs index 305f066e2..b4b1bb7d6 100644 --- a/.ci/make.mjs +++ b/.ci/make.mjs @@ -86,10 +86,10 @@ async function bump (args) { 'utf8' ) - const pipeline = await readFile(join(import.meta.url, '..', '.buildkite', 'pipeline.yml')) + const pipeline = await readFile(join(import.meta.url, '..', '.buildkite', 'pipeline.yml'), 'utf8') await writeFile( join(import.meta.url, '..', '.buildkite', 'pipeline.yml'), - pipeline.replace(/STACK_VERSION: [0-9]+[0-9\.]*[0-9](?:\-SNAPSHOT)?/, `STACK_VERSION: ${cleanVersion}-SNAPSHOT`), // eslint-disable-line + pipeline.replace(/STACK_VERSION: [0-9]+[0-9\.]*[0-9](?:\-SNAPSHOT)?/, `STACK_VERSION: ${cleanVersion}-SNAPSHOT`), 'utf8' ) } From 9e2ff665643d0f592dec1b7a242dd5d665a1a879 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Thu, 2 Nov 2023 11:48:37 -0500 Subject: [PATCH 15/33] Set module type to commonjs (#2053) https://github.com/elastic/elasticsearch-js/issues/1281 --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 29388a7af..9ccfc0070 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "description": "The official Elasticsearch client for Node.js", "main": "index.js", "types": "index.d.ts", + "type": "commonjs", "scripts": { "test": "npm run build && npm run lint && tap test/unit/{*,**/*}.test.ts", "test:unit": "npm run build && tap test/unit/{*,**/*}.test.ts", From 3c5178c7aebaf435f127de29d57298519c6ac85a Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Thu, 2 Nov 2023 13:16:24 -0500 Subject: [PATCH 16/33] Stop supporting Node v14 and v16 (#2055) --- .buildkite/pipeline.yml | 1 - .github/workflows/nodejs.yml | 2 +- README.md | 3 ++- docs/installation.asciidoc | 6 +++++- package.json | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index d05129234..e493831a9 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -13,7 +13,6 @@ steps: - "free" - "platinum" nodejs: - - "16" - "18" - "20" command: ./.buildkite/run-tests.sh diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 92d2ca72b..8cd702425 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -36,7 +36,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [14.x, 16.x, 18.x, 20.x] + node-version: [18.x, 20.x] os: [ubuntu-latest, windows-latest, macOS-latest] steps: diff --git a/README.md b/README.md index 37e78a387..1046dc84d 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ of the getting started documentation. ### Node.js support -NOTE: The minimum supported version of Node.js is `v14`. +NOTE: The minimum supported version of Node.js is `v18`. The client versioning follows the Elastic Stack versioning, this means that major, minor, and patch releases are done following a precise schedule that @@ -53,6 +53,7 @@ of `^7.10.0`). | `10.x` | `April 2021` | `7.12` (mid 2021) | | `12.x` | `April 2022` | `8.2` (early 2022) | | `14.x` | `April 2023` | `8.8` (early 2023) | +| `16.x` | `September 2023` | `8.11` (late 2023) | ### Compatibility diff --git a/docs/installation.asciidoc b/docs/installation.asciidoc index b04a1a1cd..4fe1f78ab 100644 --- a/docs/installation.asciidoc +++ b/docs/installation.asciidoc @@ -24,7 +24,7 @@ To learn more about the supported major versions, please refer to the [[nodejs-support]] === Node.js support -NOTE: The minimum supported version of Node.js is `v14`. +NOTE: The minimum supported version of Node.js is `v18`. The client versioning follows the {stack} versioning, this means that major, minor, and patch releases are done following a precise schedule that @@ -64,6 +64,10 @@ of `^7.10.0`). |`14.x` |April 2023 |`8.8` (early 2023) + +|`16.x` +|September 2023 +|`8.11` (late 2023) |=== [discrete] diff --git a/package.json b/package.json index 9ccfc0070..48e76e34d 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ }, "homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", "engines": { - "node": ">=14" + "node": ">=18" }, "devDependencies": { "@sinonjs/fake-timers": "github:sinonjs/fake-timers#0bfffc1", From ab10e462e701e1a52415d84b466ed3b19d6a3526 Mon Sep 17 00:00:00 2001 From: Elastic Machine Date: Sat, 4 Nov 2023 02:39:04 +1100 Subject: [PATCH 17/33] Auto-generated code for main (#2058) --- docs/reference.asciidoc | 2 ++ src/api/types.ts | 1 + src/api/typesWithBodyKey.ts | 1 + 3 files changed, 4 insertions(+) diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index 0c5563289..cea62abd9 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -9065,6 +9065,8 @@ client.transform.deleteTransform({ transform_id }) ** *`transform_id` (string)*: Identifier for the transform. ** *`force` (Optional, boolean)*: If this value is false, the transform must be stopped before it can be deleted. If true, the transform is deleted regardless of its current state. +** *`delete_dest_index` (Optional, boolean)*: If this value is true, the destination index is deleted together with the transform. If false, the destination +index will not be deleted ** *`timeout` (Optional, string | -1 | 0)*: Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. [discrete] diff --git a/src/api/types.ts b/src/api/types.ts index 13b4c40d4..7854e0e4d 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -17380,6 +17380,7 @@ export interface TransformTimeSync { export interface TransformDeleteTransformRequest extends RequestBase { transform_id: Id force?: boolean + delete_dest_index?: boolean timeout?: Duration } diff --git a/src/api/typesWithBodyKey.ts b/src/api/typesWithBodyKey.ts index 68b792bc3..c08a73a00 100644 --- a/src/api/typesWithBodyKey.ts +++ b/src/api/typesWithBodyKey.ts @@ -17790,6 +17790,7 @@ export interface TransformTimeSync { export interface TransformDeleteTransformRequest extends RequestBase { transform_id: Id force?: boolean + delete_dest_index?: boolean timeout?: Duration } From 99bcff02d5edf0e9200f3a36baf6df9f32aa6bf8 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Fri, 3 Nov 2023 11:41:53 -0500 Subject: [PATCH 18/33] Path filtering improvement (#2059) * Another attempt at getting path filtering right * Improve filters --- .github/workflows/nodejs.yml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 8cd702425..f8a4165c5 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -9,29 +9,23 @@ jobs: name: Detect files changed runs-on: ubuntu-latest outputs: - skip: '${{ steps.changes.outputs.skip }}' + src-only: '${{ steps.changes.outputs.src-only }}' steps: - uses: actions/checkout@v4 - uses: dorny/paths-filter/@v2.11.1 id: changes with: filters: | - skip: - - '**/*.md' - - '**/*.asciidoc' - - '**/*.txt' - - 'docs/**' - - '.ci/**' - - '.buildkite/**' - - 'scripts/**' - - 'catalog-info.yaml' + src-only: + - '!(**/*.{md,asciidoc,txt}|*.{md,asciidoc,txt}|{docs,.ci,.buildkite,scripts}/**/*|catalog-info.yaml)' + - '.github/workflows/**' test: name: Test runs-on: ${{ matrix.os }} needs: paths-filter - # only run if files not in `skip` filter were changed - if: needs.paths-filter.outputs.skip != 'true' + # only run if code relevant to unit tests was changed + if: needs.paths-filter.outputs.src-only == 'true' strategy: fail-fast: false From 5fb65d07af8ded8a5d2a1a62e6e6178034773509 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Fri, 3 Nov 2023 15:05:37 -0500 Subject: [PATCH 19/33] Update how users/permissions are set up on CI Docker image (#2060) --- .ci/Dockerfile | 20 ++++++++++++-------- .ci/make.sh | 42 +++++++++++++++++++++++++++++------------- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/.ci/Dockerfile b/.ci/Dockerfile index cf5ff29a6..1f871d9f2 100644 --- a/.ci/Dockerfile +++ b/.ci/Dockerfile @@ -12,15 +12,19 @@ RUN apt-get clean -y && \ apt-get install -y zip # Set user permissions and directory -RUN groupadd --system -g ${BUILDER_GID} ${BUILDER_GROUP} \ - && useradd --system --shell /bin/bash -u ${BUILDER_UID} -g ${BUILDER_GROUP} -m elastic 1>/dev/null 2>/dev/null \ +RUN (id -g ${BUILDER_GID} || groupadd --system -g ${BUILDER_GID} ${BUILDER_GROUP}) \ + && (id -u ${BUILDER_UID} || useradd --system --shell /bin/bash -u ${BUILDER_UID} -g ${BUILDER_GID} -m elastic) \ && mkdir -p /usr/src/elasticsearch-js \ - && chown -R ${BUILDER_USER}:${BUILDER_GROUP} /usr/src/ + && chown -R ${BUILDER_UID}:${BUILDER_GID} /usr/src/ + WORKDIR /usr/src/elasticsearch-js -USER ${BUILDER_USER}:${BUILDER_GROUP} -# Install app dependencies -COPY --chown=$BUILDER_USER:$BUILDER_GROUP package*.json ./ -RUN npm install +# run remainder of commands as non-root user +USER ${BUILDER_UID}:${BUILDER_GID} + +# install dependencies +COPY package.json . +RUN npm install --production=false -COPY --chown=$BUILDER_USER:$BUILDER_GROUP . . +# copy project files +COPY . . diff --git a/.ci/make.sh b/.ci/make.sh index 7f890cb2b..c3d9f5b4f 100755 --- a/.ci/make.sh +++ b/.ci/make.sh @@ -144,19 +144,35 @@ docker build \ echo -e "\033[34;1mINFO: running $product container\033[0m" -docker run \ - --volume "$repo:/usr/src/elasticsearch-js" \ - --volume /usr/src/elasticsearch-js/node_modules \ - -u "$(id -u):$(id -g)" \ - --env "WORKFLOW=$WORKFLOW" \ - --name make-elasticsearch-js \ - --rm \ - $product \ - /bin/bash -c "cd /usr/src && \ - git clone https://$CLIENTS_GITHUB_TOKEN@github.com/elastic/elastic-client-generator-js.git && \ - mkdir -p /usr/src/elastic-client-generator-js/output && \ - cd /usr/src/elasticsearch-js && \ - node .ci/make.mjs --task $TASK ${TASK_ARGS[*]}" +if [[ -z "${BUILDKITE+x}" ]] && [[ -z "${CI+x}" ]] && [[ -z "${GITHUB_ACTIONS+x}" ]]; then + echo -e "\033[34;1mINFO: Running in local mode" + docker run \ + -u "$(id -u):$(id -g)" \ + --volume "$repo:/usr/src/elasticsearch-js" \ + --volume /usr/src/elasticsearch-js/node_modules \ + --volume "$(realpath $repo/../elastic-client-generator-js):/usr/src/elastic-client-generator-js" \ + --env "WORKFLOW=$WORKFLOW" \ + --name make-elasticsearch-js \ + --rm \ + $product \ + /bin/bash -c "mkdir -p /usr/src/elastic-client-generator-js/output && \ + node .ci/make.mjs --task $TASK ${TASK_ARGS[*]}" +else + echo -e "\033[34;1mINFO: Running in CI mode" + docker run \ + --volume "$repo:/usr/src/elasticsearch-js" \ + --volume /usr/src/elasticsearch-js/node_modules \ + -u "$(id -u):$(id -g)" \ + --env "WORKFLOW=$WORKFLOW" \ + --name make-elasticsearch-js \ + --rm \ + $product \ + /bin/bash -c "cd /usr/src && \ + git clone https://$CLIENTS_GITHUB_TOKEN@github.com/elastic/elastic-client-generator-js.git && \ + mkdir -p /usr/src/elastic-client-generator-js/output && \ + cd /usr/src/elasticsearch-js && \ + node .ci/make.mjs --task $TASK ${TASK_ARGS[*]}" +fi # ------------------------------------------------------- # # Post Command tasks & checks From b47747007bec45678ae5ec79fe488db6bc220862 Mon Sep 17 00:00:00 2001 From: Elastic Machine Date: Tue, 7 Nov 2023 03:59:55 +1100 Subject: [PATCH 20/33] Auto-generated code for main (#2061) --- src/api/types.ts | 6 +++--- src/api/typesWithBodyKey.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/api/types.ts b/src/api/types.ts index 7854e0e4d..0dc17efc8 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -707,7 +707,7 @@ export interface MsearchMultiSearchItem extends SearchRespo status?: integer } -export interface MsearchMultiSearchResult { +export interface MsearchMultiSearchResult> { took: long responses: MsearchResponseItem[] } @@ -780,7 +780,7 @@ export interface MsearchRequest extends RequestBase { export type MsearchRequestItem = MsearchMultisearchHeader | MsearchMultisearchBody -export type MsearchResponse> = MsearchMultiSearchResult +export type MsearchResponse> = MsearchMultiSearchResult export type MsearchResponseItem = MsearchMultiSearchItem | ErrorResponseBase @@ -796,7 +796,7 @@ export interface MsearchTemplateRequest extends RequestBase { export type MsearchTemplateRequestItem = MsearchMultisearchHeader | MsearchTemplateTemplateConfig -export type MsearchTemplateResponse> = MsearchMultiSearchResult +export type MsearchTemplateResponse> = MsearchMultiSearchResult export interface MsearchTemplateTemplateConfig { explain?: boolean diff --git a/src/api/typesWithBodyKey.ts b/src/api/typesWithBodyKey.ts index c08a73a00..5a4157ac8 100644 --- a/src/api/typesWithBodyKey.ts +++ b/src/api/typesWithBodyKey.ts @@ -735,7 +735,7 @@ export interface MsearchMultiSearchItem extends SearchRespo status?: integer } -export interface MsearchMultiSearchResult { +export interface MsearchMultiSearchResult> { took: long responses: MsearchResponseItem[] } @@ -809,7 +809,7 @@ export interface MsearchRequest extends RequestBase { export type MsearchRequestItem = MsearchMultisearchHeader | MsearchMultisearchBody -export type MsearchResponse> = MsearchMultiSearchResult +export type MsearchResponse> = MsearchMultiSearchResult export type MsearchResponseItem = MsearchMultiSearchItem | ErrorResponseBase @@ -826,7 +826,7 @@ export interface MsearchTemplateRequest extends RequestBase { export type MsearchTemplateRequestItem = MsearchMultisearchHeader | MsearchTemplateTemplateConfig -export type MsearchTemplateResponse> = MsearchMultiSearchResult +export type MsearchTemplateResponse> = MsearchMultiSearchResult export interface MsearchTemplateTemplateConfig { explain?: boolean From abd5018cfe550ee3d8e10753bdb5696e52e9fb36 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Tue, 7 Nov 2023 12:07:18 -0600 Subject: [PATCH 21/33] Bump version in main to 8.10.3 (#2066) --- .buildkite/pipeline.yml | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index e493831a9..32b37b6c6 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -6,7 +6,7 @@ steps: env: NODE_VERSION: "{{ matrix.nodejs }}" TEST_SUITE: "{{ matrix.suite }}" - STACK_VERSION: 8.8.0-SNAPSHOT + STACK_VERSION: 8.10.3-SNAPSHOT matrix: setup: suite: diff --git a/package.json b/package.json index 48e76e34d..a772f791e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@elastic/elasticsearch", - "version": "8.9.1", - "versionCanary": "8.9.1-canary.1", + "version": "8.10.3", + "versionCanary": "8.10.3-canary.1", "description": "The official Elasticsearch client for Node.js", "main": "index.js", "types": "index.d.ts", From 845ddaaf34a1d0387f0a977b9798d3cea87a4400 Mon Sep 17 00:00:00 2001 From: Elastic Machine Date: Wed, 8 Nov 2023 18:51:30 +0100 Subject: [PATCH 22/33] Auto-generated code for main (#2064) --- docs/reference.asciidoc | 1 + src/api/types.ts | 1 + src/api/typesWithBodyKey.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index cea62abd9..9e5291cbb 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -6491,6 +6491,7 @@ client.ml.startTrainedModelDeployment({ model_id }) ** *`cache_size` (Optional, number | string)*: The inference cache size (in memory outside the JVM heap) per node for the model. The default value is the same size as the `model_size_bytes`. To disable the cache, `0b` can be provided. +** *`deployment_id` (Optional, string)*: A unique identifier for the deployment of the model. ** *`number_of_allocations` (Optional, number)*: The number of model allocations on each node where the model is deployed. All allocations on a node share the same copy of the model in memory but use a separate set of threads to evaluate the model. diff --git a/src/api/types.ts b/src/api/types.ts index 0dc17efc8..707e1cc13 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -14106,6 +14106,7 @@ export interface MlStartDatafeedResponse { export interface MlStartTrainedModelDeploymentRequest extends RequestBase { model_id: Id cache_size?: ByteSize + deployment_id?: string number_of_allocations?: integer priority?: MlTrainingPriority queue_capacity?: integer diff --git a/src/api/typesWithBodyKey.ts b/src/api/typesWithBodyKey.ts index 5a4157ac8..dbbe3ea1a 100644 --- a/src/api/typesWithBodyKey.ts +++ b/src/api/typesWithBodyKey.ts @@ -14375,6 +14375,7 @@ export interface MlStartDatafeedResponse { export interface MlStartTrainedModelDeploymentRequest extends RequestBase { model_id: Id cache_size?: ByteSize + deployment_id?: string number_of_allocations?: integer priority?: MlTrainingPriority queue_capacity?: integer From b7b16d81ee3bdeafbaad393801bda4abfa30fe78 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Wed, 8 Nov 2023 13:07:55 -0600 Subject: [PATCH 23/33] Fix arg-parsing issue in codegen script (#2068) --- .ci/make.mjs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.ci/make.mjs b/.ci/make.mjs index b4b1bb7d6..511944972 100644 --- a/.ci/make.mjs +++ b/.ci/make.mjs @@ -28,6 +28,11 @@ import assert from 'assert' import { join } from 'desm' import semver from 'semver' +// xz/globals loads minimist-parsed args as a global `argv`, but it +// interprets args like '8.10' as numbers and shortens them to '8.1'. +// so we have to import and configure minimist ourselves. +import minimist from 'minimist' +const argv = minimist(process.argv.slice(2), { string: ['_', 'task'] }) assert(typeof argv.task === 'string', 'Missing task parameter') switch (argv.task) { From 426919709f43e3680a696de8880c4203be1e4dab Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Thu, 16 Nov 2023 10:14:20 -0600 Subject: [PATCH 24/33] Throw an explicit error when asStream is used with bulk helper (#2078) --- src/helpers.ts | 2 ++ test/unit/helpers/bulk.test.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/helpers.ts b/src/helpers.ts index 768ad1dc8..0bd1b1c5c 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -527,6 +527,8 @@ export default class Helpers { * @return {object} The possible operations to run with the datasource. */ bulk (options: BulkHelperOptions, reqOptions: TransportRequestOptions = {}): BulkHelper { + assert(!(reqOptions.asStream ?? false), 'bulk helper: the asStream request option is not supported') + const client = this[kClient] const { serializer } = client if (this[kMetaHeader] !== null) { diff --git a/test/unit/helpers/bulk.test.ts b/test/unit/helpers/bulk.test.ts index 732d696c4..2c3229ce9 100644 --- a/test/unit/helpers/bulk.test.ts +++ b/test/unit/helpers/bulk.test.ts @@ -18,6 +18,7 @@ */ import FakeTimers from '@sinonjs/fake-timers' +import { AssertionError } from 'assert' import { createReadStream } from 'fs' import * as http from 'http' import { join } from 'path' @@ -1336,6 +1337,37 @@ test('transport options', t => { }) }) + t.test('Should not allow asStream request option', async t => { + t.plan(2) + + const client = new Client({ + node: 'http://localhost:9200', + }) + + try { + await client.helpers.bulk({ + datasource: dataset.slice(), + flushBytes: 1, + concurrency: 1, + onDocument (doc) { + return { index: { _index: 'test' } } + }, + onDrop (doc) { + t.fail('This should never be called') + }, + refreshOnCompletion: true + }, { + headers: { + foo: 'bar' + }, + asStream: true, + }) + } catch (err: any) { + t.ok(err instanceof AssertionError) + t.equal(err.message, 'bulk helper: the asStream request option is not supported') + } + }) + t.end() }) From 06e3b050778bdeca4c44d28a0926e6c8e4f5ab4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20Zolt=C3=A1n=20Szab=C3=B3?= Date: Mon, 27 Nov 2023 17:46:53 +0100 Subject: [PATCH 25/33] [DOCS] Adds a signpost for downloading ES or signing-up for ESS (#2084) --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 1046dc84d..5d34cfa98 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,11 @@ [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://badge.buildkite.com/15e4246eb268ea78f6e10aa90bce38c1abb0a4489e79f5a0ac.svg)](https://buildkite.com/elastic/elasticsearch-javascript-client-integration-tests/builds?branch=main) [![Node CI](https://github.com/elastic/elasticsearch-js/actions/workflows/nodejs.yml/badge.svg)](https://github.com/elastic/elasticsearch-js/actions/workflows/nodejs.yml) [![codecov](https://codecov.io/gh/elastic/elasticsearch-js/branch/master/graph/badge.svg)](https://codecov.io/gh/elastic/elasticsearch-js) [![NPM downloads](https://img.shields.io/npm/dm/@elastic/elasticsearch.svg?style=flat)](https://www.npmjs.com/package/@elastic/elasticsearch) +**[Download the latest version of Elasticsearch](https://www.elastic.co/downloads/elasticsearch)** +or +**[sign-up](https://cloud.elastic.co/registration?elektra=en-ess-sign-up-page)** +**for a free trial of Elastic Cloud**. + The official Node.js client for Elasticsearch. ## Installation From c2c417a9fd84e7f77a84b0cfa079bdde40473574 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Tue, 12 Dec 2023 15:40:47 -0600 Subject: [PATCH 26/33] Bump transport to 8.4.0 (#2095) * Support for transport 8.4.0 redaction functionality * Docs for `redaction` options --- docs/advanced-config.asciidoc | 88 +++++++++++++++++++++++++++++++++++ package.json | 2 +- src/client.ts | 11 ++++- src/helpers.ts | 12 +++-- 4 files changed, 107 insertions(+), 6 deletions(-) diff --git a/docs/advanced-config.asciidoc b/docs/advanced-config.asciidoc index 638aeada4..167061dce 100644 --- a/docs/advanced-config.asciidoc +++ b/docs/advanced-config.asciidoc @@ -91,6 +91,94 @@ const client = new Client({ }) ---- +[discrete] +==== Redaction of potentially sensitive data + +When the client raises an `Error` that originated at the HTTP layer, like a `ConnectionError` or `TimeoutError`, a `meta` object is often attached to the error object that includes metadata useful for debugging, like request and response information. Because this can include potentially sensitive data, like authentication secrets in an `Authorization` header, the client takes measures to redact common sources of sensitive data when this metadata is attached and serialized. + +If your configuration requires extra headers or other configurations that may include sensitive data, you may want to adjust these settings to account for that. + +By default, the `redaction` option is set to `{ type: 'replace' }`, which recursively searches for sensitive key names, case insensitive, and replaces their values with the string `[redacted]`. + +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') + +const client = new Client({ + cloud: { id: '' }, + auth: { apiKey: 'base64EncodedKey' }, +}) + +try { + await client.indices.create({ index: 'my_index' }) +} catch (err) { + console.log(err.meta.meta.request.options.headers.authorization) // prints "[redacted]" +} +---- + +If you would like to redact additional properties, you can include additional key names to search and replace: + +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') + +const client = new Client({ + cloud: { id: '' }, + auth: { apiKey: 'base64EncodedKey' }, + headers: { 'X-My-Secret-Password': 'shhh it's a secret!' }, + redaction: { + type: "replace", + additionalKeys: ["x-my-secret-password"] + } +}) + +try { + await client.indices.create({ index: 'my_index' }) +} catch (err) { + console.log(err.meta.meta.request.options.headers['X-My-Secret-Password']) // prints "[redacted]" +} +---- + +Alternatively, if you know you're not going to use the metadata at all, setting the redaction type to `remove` will remove all optional sources of potentially sensitive data entirely, or replacing them with `null` for required properties. + +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') + +const client = new Client({ + cloud: { id: '' }, + auth: { apiKey: 'base64EncodedKey' }, + redaction: { type: "remove" } +}) + +try { + await client.indices.create({ index: 'my_index' }) +} catch (err) { + console.log(err.meta.meta.request.options.headers) // undefined +} +---- + +Finally, if you prefer to turn off redaction altogether, perhaps while debugging on a local developer environment, you can set the redaction type to `off`. This will revert the client to pre-8.11.0 behavior, where basic redaction is only performed during common serialization methods like `console.log` and `JSON.stringify`. + +WARNING: Setting `redaction.type` to `off` is not recommended in production environments. + +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') + +const client = new Client({ + cloud: { id: '' }, + auth: { apiKey: 'base64EncodedKey' }, + redaction: { type: "off" } +}) + +try { + await client.indices.create({ index: 'my_index' }) +} catch (err) { + console.log(err.meta.meta.request.options.headers.authorization) // the actual header value will be logged +} +---- + [discrete] ==== Migrate to v8 diff --git a/package.json b/package.json index a772f791e..56332e190 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "zx": "^7.2.2" }, "dependencies": { - "@elastic/transport": "^8.3.4", + "@elastic/transport": "^8.4.0", "tslib": "^2.4.0" }, "tap": { diff --git a/src/client.ts b/src/client.ts index 09118d58c..50ba4942f 100644 --- a/src/client.ts +++ b/src/client.ts @@ -43,6 +43,7 @@ import { BearerAuth, Context } from '@elastic/transport/lib/types' +import { RedactionOptions } from '@elastic/transport/lib/Transport' import BaseConnection, { prepareHeaders } from '@elastic/transport/lib/connection/BaseConnection' import SniffingTransport from './sniffingTransport' import Helpers from './helpers' @@ -113,6 +114,7 @@ export interface ClientOptions { caFingerprint?: string maxResponseSize?: number maxCompressedResponseSize?: number + redaction?: RedactionOptions } export default class Client extends API { @@ -186,7 +188,11 @@ export default class Client extends API { proxy: null, enableMetaHeader: true, maxResponseSize: null, - maxCompressedResponseSize: null + maxCompressedResponseSize: null, + redaction: { + type: 'replace', + additionalKeys: [] + } }, opts) if (options.caFingerprint != null && isHttpConnection(opts.node ?? opts.nodes)) { @@ -259,7 +265,8 @@ export default class Client extends API { jsonContentType: 'application/vnd.elasticsearch+json; compatible-with=8', ndjsonContentType: 'application/vnd.elasticsearch+x-ndjson; compatible-with=8', accept: 'application/vnd.elasticsearch+json; compatible-with=8,text/plain' - } + }, + redaction: options.redaction }) this.helpers = new Helpers({ diff --git a/src/helpers.ts b/src/helpers.ts index 0bd1b1c5c..efad8b49b 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -196,8 +196,11 @@ export default class Helpers { await sleep(wait) } assert(response !== undefined, 'The response is undefined, please file a bug report') + + const { redaction = { type: 'replace' } } = options + const errorOptions = { redaction } if (response.statusCode === 429) { - throw new ResponseError(response) + throw new ResponseError(response, errorOptions) } let scroll_id = response.body._scroll_id @@ -237,7 +240,7 @@ export default class Helpers { await sleep(wait) } if (response.statusCode === 429) { - throw new ResponseError(response) + throw new ResponseError(response, errorOptions) } } @@ -289,6 +292,9 @@ export default class Helpers { } = options reqOptions.meta = true + const { redaction = { type: 'replace' } } = reqOptions + const errorOptions = { redaction } + let stopReading = false let stopError: Error | null = null let timeoutRef = null @@ -502,7 +508,7 @@ export default class Helpers { // @ts-expect-error addDocumentsGetter(result) if (response.status != null && response.status >= 400) { - callbacks[i](new ResponseError(result), result) + callbacks[i](new ResponseError(result, errorOptions), result) } else { callbacks[i](null, result) } From 1fb789862dd36e85c211bf1d32aa90c3454c5dc2 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Tue, 12 Dec 2023 16:06:03 -0600 Subject: [PATCH 27/33] 8.11.0 changelog (#2097) * Changelog for 8.11.0 * Add redaction docs link to changelog --- docs/advanced-config.asciidoc | 1 + docs/changelog.asciidoc | 19 +++++++++++++++++++ package.json | 4 ++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/advanced-config.asciidoc b/docs/advanced-config.asciidoc index 167061dce..b3c9388a4 100644 --- a/docs/advanced-config.asciidoc +++ b/docs/advanced-config.asciidoc @@ -92,6 +92,7 @@ const client = new Client({ ---- [discrete] +[[redaction]] ==== Redaction of potentially sensitive data When the client raises an `Error` that originated at the HTTP layer, like a `ConnectionError` or `TimeoutError`, a `meta` object is often attached to the error object that includes metadata useful for debugging, like request and response information. Because this can include potentially sensitive data, like authentication secrets in an `Authorization` header, the client takes measures to redact common sources of sensitive data when this metadata is attached and serialized. diff --git a/docs/changelog.asciidoc b/docs/changelog.asciidoc index b82c397da..0d79214b2 100644 --- a/docs/changelog.asciidoc +++ b/docs/changelog.asciidoc @@ -1,6 +1,25 @@ [[changelog-client]] == Release notes +[discrete] +=== 8.11.0 + +[discrete] +=== Features + +[discrete] +===== Support for Elasticsearch `v8.11.0` + +You can find all the API changes +https://www.elastic.co/guide/en/elasticsearch/reference/8.11/release-notes-8.11.0.html[here]. + +[discrete] +===== Enhanced support for redacting potentially sensitive data https://github.com/elastic/elasticsearch-js/pull/2095[#2095] + +`@elastic/transport` https://github.com/elastic/elastic-transport-js/releases/tag/v8.4.0[version 8.4.0] introduces enhanced measures for ensuring that request metadata attached to some `Error` objects is redacted. This functionality is primarily to address custom logging solutions that don't use common serialization methods like `JSON.stringify`, `console.log`, or `util.inspect`, which were already accounted for. + +See <> for more information. + [discrete] === 8.10.0 diff --git a/package.json b/package.json index 56332e190..add6446fa 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@elastic/elasticsearch", - "version": "8.10.3", - "versionCanary": "8.10.3-canary.1", + "version": "8.11.0", + "versionCanary": "8.11.0-canary.0", "description": "The official Elasticsearch client for Node.js", "main": "index.js", "types": "index.d.ts", From 51323e769dbaedc8c584ca7ad6cbdf3a4722234b Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Wed, 13 Dec 2023 11:20:04 -0600 Subject: [PATCH 28/33] Github action for publishing to npm with provenance metadata (#2103) --- .github/workflows/npm-publish.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 000000000..73a7d36c2 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,27 @@ +name: Publish Package to npm +on: + workflow_dispatch: + inputs: + branch: + description: 'Git branch to build and publish' + required: true +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.branch }} + - uses: actions/setup-node@v3 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + - run: npm install -g npm + - run: npm install + - run: npm test + - run: npm publish --provenance --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From d3f22f1e14d292849d55eaea356d6f28ea7abfec Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Thu, 14 Dec 2023 09:46:04 -0600 Subject: [PATCH 29/33] Add doc for closing connections (#2104) --- docs/connecting.asciidoc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/connecting.asciidoc b/docs/connecting.asciidoc index 77c2e7d11..15007ceb3 100644 --- a/docs/connecting.asciidoc +++ b/docs/connecting.asciidoc @@ -12,6 +12,7 @@ This page contains the information you need to connect and use the Client with * <> * <> * <> +* <> * <> [[authentication]] @@ -691,6 +692,20 @@ const client = new Client({ }) ---- +[discrete] +[[close-connections]] +=== Closing a client's connections + +If you would like to close all open connections being managed by an instance of the client, use the `close()` function: + +[source,js] +---- +const client = new Client({ + node: 'http://localhost:9200' +}); +client.close(); +---- + [discrete] [[product-check]] === Automatic product check From 4aaf49b6ea86a0906dc7768b4d227f10b6bd8198 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Thu, 14 Dec 2023 16:35:37 -0600 Subject: [PATCH 30/33] Integration test improvements (#2109) * Improvements to integrations Borrowed largely from https://github.com/elastic/elasticsearch-serverless-js/pull/38 * Bump all the things to 8.12.0 * Split Dockerfile copy into two layers * Fix test cron names --- .buildkite/Dockerfile | 4 +- .buildkite/pipeline.yml | 2 +- .dockerignore | 2 + catalog-info.yaml | 8 +- package.json | 6 +- test/integration/index.js | 4 +- test/integration/test-runner.js | 165 ++++++++++++++++++++++---------- 7 files changed, 130 insertions(+), 61 deletions(-) diff --git a/.buildkite/Dockerfile b/.buildkite/Dockerfile index 5608747b6..6d44e2211 100644 --- a/.buildkite/Dockerfile +++ b/.buildkite/Dockerfile @@ -10,5 +10,7 @@ RUN apt-get clean -y && \ WORKDIR /usr/src/app -COPY . . +COPY package.json . RUN npm install --production=false + +COPY . . diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 32b37b6c6..1dca14548 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -6,7 +6,7 @@ steps: env: NODE_VERSION: "{{ matrix.nodejs }}" TEST_SUITE: "{{ matrix.suite }}" - STACK_VERSION: 8.10.3-SNAPSHOT + STACK_VERSION: 8.12.0-SNAPSHOT matrix: setup: suite: diff --git a/.dockerignore b/.dockerignore index 54eb2a95a..e34f9ff27 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,3 +3,5 @@ npm-debug.log test/benchmarks elasticsearch .git +lib +junit-output diff --git a/catalog-info.yaml b/catalog-info.yaml index b8bbd36ff..80c943cd8 100644 --- a/catalog-info.yaml +++ b/catalog-info.yaml @@ -42,9 +42,9 @@ spec: main_semi_daily: branch: 'main' cronline: '0 */12 * * *' - 8_9_semi_daily: - branch: '8.9' + 8_12_semi_daily: + branch: '8.12' cronline: '0 */12 * * *' - 8_8_daily: - branch: '8.8' + 8_11_daily: + branch: '8.11' cronline: '@daily' diff --git a/package.json b/package.json index add6446fa..7e3d637b0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@elastic/elasticsearch", - "version": "8.11.0", - "versionCanary": "8.11.0-canary.0", + "version": "8.12.0", + "versionCanary": "8.12.0-canary.0", "description": "The official Elasticsearch client for Node.js", "main": "index.js", "types": "index.d.ts", @@ -93,4 +93,4 @@ "coverage": false, "check-coverage": false } -} +} \ No newline at end of file diff --git a/test/integration/index.js b/test/integration/index.js index defdb400f..b07ddd2d7 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -317,7 +317,7 @@ async function start ({ client, isXPack }) { if (name === 'setup' || name === 'teardown') continue if (options.test && !name.endsWith(options.test)) continue - const junitTestCase = junitTestSuite.testcase(name, `node_${process.version}/${cleanPath}`) + const junitTestCase = junitTestSuite.testcase(name, `node_${process.version}: ${cleanPath}`) stats.total += 1 if (shouldSkip(isXPack, file, name)) { @@ -336,6 +336,7 @@ async function start ({ client, isXPack }) { junitTestSuite.end() junitTestSuites.end() generateJunitXmlReport(junit, isXPack ? 'platinum' : 'free') + err.meta = JSON.stringify(err.meta ?? {}, null, 2) console.error(err) if (options.bail) { @@ -374,6 +375,7 @@ async function start ({ client, isXPack }) { - Total: ${stats.total} - Skip: ${stats.skip} - Pass: ${stats.pass} + - Fail: ${stats.total - (stats.pass + stats.skip)} - Assertions: ${stats.assertions} `) } diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 64570945a..ce80da43e 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -593,13 +593,14 @@ function build (opts = {}) { const key = Object.keys(action.match)[0] match( // in some cases, the yaml refers to the body with an empty string - key === '$body' || key === '' + key.split('.')[0] === '$body' || key === '' ? response : delve(response, fillStashedValues(key)), - key === '$body' + key.split('.')[0] === '$body' ? action.match[key] : fillStashedValues(action.match)[key], - action.match + action.match, + response ) } @@ -608,7 +609,8 @@ function build (opts = {}) { const key = Object.keys(action.lt)[0] lt( delve(response, fillStashedValues(key)), - fillStashedValues(action.lt)[key] + fillStashedValues(action.lt)[key], + response ) } @@ -617,7 +619,8 @@ function build (opts = {}) { const key = Object.keys(action.gt)[0] gt( delve(response, fillStashedValues(key)), - fillStashedValues(action.gt)[key] + fillStashedValues(action.gt)[key], + response ) } @@ -626,7 +629,8 @@ function build (opts = {}) { const key = Object.keys(action.lte)[0] lte( delve(response, fillStashedValues(key)), - fillStashedValues(action.lte)[key] + fillStashedValues(action.lte)[key], + response ) } @@ -635,7 +639,8 @@ function build (opts = {}) { const key = Object.keys(action.gte)[0] gte( delve(response, fillStashedValues(key)), - fillStashedValues(action.gte)[key] + fillStashedValues(action.gte)[key], + response ) } @@ -648,7 +653,8 @@ function build (opts = {}) { : delve(response, fillStashedValues(key)), key === '$body' ? action.length[key] - : fillStashedValues(action.length)[key] + : fillStashedValues(action.length)[key], + response ) } @@ -657,7 +663,8 @@ function build (opts = {}) { const isTrue = fillStashedValues(action.is_true) is_true( delve(response, isTrue), - isTrue + isTrue, + response ) } @@ -666,7 +673,8 @@ function build (opts = {}) { const isFalse = fillStashedValues(action.is_false) is_false( delve(response, isFalse), - isFalse + isFalse, + response ) } } @@ -679,46 +687,67 @@ function build (opts = {}) { * Asserts that the given value is truthy * @param {any} the value to check * @param {string} an optional message + * @param {any} debugging metadata to attach to any assertion errors * @returns {TestRunner} */ -function is_true (val, msg) { - assert.ok(val, `expect truthy value: ${msg} - value: ${JSON.stringify(val)}`) +function is_true (val, msg, response) { + try { + assert.ok((typeof val === 'string' && val.toLowerCase() === 'true') || val, `expect truthy value: ${msg} - value: ${JSON.stringify(val)}`) + } catch (err) { + err.response = JSON.stringify(response) + throw err + } } /** * Asserts that the given value is falsey * @param {any} the value to check * @param {string} an optional message + * @param {any} debugging metadata to attach to any assertion errors * @returns {TestRunner} */ -function is_false (val, msg) { - assert.ok(!val, `expect falsey value: ${msg} - value: ${JSON.stringify(val)}`) +function is_false (val, msg, response) { + try { + assert.ok((typeof val === 'string' && val.toLowerCase() === 'false') || !val, `expect falsey value: ${msg} - value: ${JSON.stringify(val)}`) + } catch (err) { + err.response = JSON.stringify(response) + throw err + } } /** * Asserts that two values are the same * @param {any} the first value * @param {any} the second value + * @param {any} debugging metadata to attach to any assertion errors * @returns {TestRunner} */ -function match (val1, val2, action) { - // both values are objects - if (typeof val1 === 'object' && typeof val2 === 'object') { - assert.deepEqual(val1, val2, typeof action === 'object' ? JSON.stringify(action) : action) - // the first value is the body as string and the second a pattern string - } else if ( - typeof val1 === 'string' && typeof val2 === 'string' && - val2.startsWith('/') && (val2.endsWith('/\n') || val2.endsWith('/')) - ) { - const regStr = val2 - .replace(/(^|[^\\])#.*/g, '$1') - .replace(/(^|[^\\])\s+/g, '$1') - .slice(1, -1) - // 'm' adds the support for multiline regex - assert.match(val1, new RegExp(regStr, 'm'), `should match pattern provided: ${val2}, but got: ${val1}`) - // everything else - } else { - assert.equal(val1, val2, `should be equal: ${val1} - ${val2}, action: ${JSON.stringify(action)}`) +function match (val1, val2, action, response) { + try { + // both values are objects + if (typeof val1 === 'object' && typeof val2 === 'object') { + assert.deepEqual(val1, val2, typeof action === 'object' ? JSON.stringify(action) : action) + // the first value is the body as string and the second a pattern string + } else if ( + typeof val1 === 'string' && typeof val2 === 'string' && + val2.startsWith('/') && (val2.endsWith('/\n') || val2.endsWith('/')) + ) { + const regStr = val2 + .replace(/(^|[^\\])#.*/g, '$1') + .replace(/(^|[^\\])\s+/g, '$1') + .slice(1, -1) + // 'm' adds the support for multiline regex + assert.match(val1, new RegExp(regStr, 'm'), `should match pattern provided: ${val2}, but got: ${val1}: ${JSON.stringify(action)}`) + } else if (typeof val1 === 'string' && typeof val2 === 'string') { + // string comparison + assert.include(val1, val2, `should include pattern provided: ${val2}, but got: ${val1}: ${JSON.stringify(action)}`) + } else { + // everything else + assert.equal(val1, val2, `should be equal: ${val1} - ${val2}, action: ${JSON.stringify(action)}`) + } + } catch (err) { + err.response = JSON.stringify(response) + throw err } } @@ -727,11 +756,17 @@ function match (val1, val2, action) { * It also verifies that the two values are numbers * @param {any} the first value * @param {any} the second value + * @param {any} debugging metadata to attach to any assertion errors * @returns {TestRunner} */ -function lt (val1, val2) { - ;[val1, val2] = getNumbers(val1, val2) - assert.ok(val1 < val2) +function lt (val1, val2, response) { + try { + ;[val1, val2] = getNumbers(val1, val2) + assert.ok(val1 < val2) + } catch (err) { + err.response = JSON.stringify(response) + throw err + } } /** @@ -739,11 +774,17 @@ function lt (val1, val2) { * It also verifies that the two values are numbers * @param {any} the first value * @param {any} the second value + * @param {any} debugging metadata to attach to any assertion errors * @returns {TestRunner} */ -function gt (val1, val2) { - ;[val1, val2] = getNumbers(val1, val2) - assert.ok(val1 > val2) +function gt (val1, val2, response) { + try { + ;[val1, val2] = getNumbers(val1, val2) + assert.ok(val1 > val2) + } catch (err) { + err.response = JSON.stringify(response) + throw err + } } /** @@ -751,11 +792,17 @@ function gt (val1, val2) { * It also verifies that the two values are numbers * @param {any} the first value * @param {any} the second value + * @param {any} debugging metadata to attach to any assertion errors * @returns {TestRunner} */ -function lte (val1, val2) { - ;[val1, val2] = getNumbers(val1, val2) - assert.ok(val1 <= val2) +function lte (val1, val2, response) { + try { + ;[val1, val2] = getNumbers(val1, val2) + assert.ok(val1 <= val2) + } catch (err) { + err.response = JSON.stringify(response) + throw err + } } /** @@ -763,26 +810,38 @@ function lte (val1, val2) { * It also verifies that the two values are numbers * @param {any} the first value * @param {any} the second value + * @param {any} debugging metadata to attach to any assertion errors * @returns {TestRunner} */ -function gte (val1, val2) { - ;[val1, val2] = getNumbers(val1, val2) - assert.ok(val1 >= val2) +function gte (val1, val2, response) { + try { + ;[val1, val2] = getNumbers(val1, val2) + assert.ok(val1 >= val2) + } catch (err) { + err.response = JSON.stringify(response) + throw err + } } /** * Asserts that the given value has the specified length * @param {string|object|array} the object to check * @param {number} the expected length + * @param {any} debugging metadata to attach to any assertion errors * @returns {TestRunner} */ -function length (val, len) { - if (typeof val === 'string' || Array.isArray(val)) { - assert.equal(val.length, len) - } else if (typeof val === 'object' && val !== null) { - assert.equal(Object.keys(val).length, len) - } else { - assert.fail(`length: the given value is invalid: ${val}`) +function length (val, len, response) { + try { + if (typeof val === 'string' || Array.isArray(val)) { + assert.equal(val.length, len) + } else if (typeof val === 'object' && val !== null) { + assert.equal(Object.keys(val).length, len) + } else { + assert.fail(`length: the given value is invalid: ${val}`) + } + } catch (err) { + err.response = JSON.stringify(response) + throw err } } @@ -813,6 +872,10 @@ function length (val, len) { */ function parseDo (action) { action = JSON.parse(JSON.stringify(action)) + + if (typeof action === 'string') action = {[action]: {}} + if (Array.isArray(action)) action = action[0] + return Object.keys(action).reduce((acc, val) => { switch (val) { case 'catch': From 5413eb5f35d0f3cbda483b5800475d9a3da59038 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Thu, 14 Dec 2023 17:19:20 -0600 Subject: [PATCH 31/33] Add missing snippets (#2113) For https://github.com/elastic/clients-team/issues/728 --- .../36b86b97feedcf5632824eefc251d6ed.asciidoc | 12 ++++++ .../8575c966b004fb124c7afd6bb5827b50.asciidoc | 13 ++++++ .../bcc75fc01b45e482638c65b8fbdf09fa.asciidoc | 7 +++ .../d04f0c8c44e8b4fb55f2e7d9d05977e7.asciidoc | 43 +++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 docs/doc_examples/36b86b97feedcf5632824eefc251d6ed.asciidoc create mode 100644 docs/doc_examples/8575c966b004fb124c7afd6bb5827b50.asciidoc create mode 100644 docs/doc_examples/bcc75fc01b45e482638c65b8fbdf09fa.asciidoc create mode 100644 docs/doc_examples/d04f0c8c44e8b4fb55f2e7d9d05977e7.asciidoc diff --git a/docs/doc_examples/36b86b97feedcf5632824eefc251d6ed.asciidoc b/docs/doc_examples/36b86b97feedcf5632824eefc251d6ed.asciidoc new file mode 100644 index 000000000..408ce2f71 --- /dev/null +++ b/docs/doc_examples/36b86b97feedcf5632824eefc251d6ed.asciidoc @@ -0,0 +1,12 @@ +[source,js] +---- +const response = await client.search({ + index: 'books', + query: { + match: { + name: 'brave' + } + } +}) +console.log(response) +---- diff --git a/docs/doc_examples/8575c966b004fb124c7afd6bb5827b50.asciidoc b/docs/doc_examples/8575c966b004fb124c7afd6bb5827b50.asciidoc new file mode 100644 index 000000000..d99bd96dc --- /dev/null +++ b/docs/doc_examples/8575c966b004fb124c7afd6bb5827b50.asciidoc @@ -0,0 +1,13 @@ +[source,js] +---- +const response = await client.index({ + index: 'books', + document: { + name: 'Snow Crash', + author: 'Neal Stephenson', + release_date: '1992-06-01', + page_count: 470, + } +}) +console.log(response) +---- diff --git a/docs/doc_examples/bcc75fc01b45e482638c65b8fbdf09fa.asciidoc b/docs/doc_examples/bcc75fc01b45e482638c65b8fbdf09fa.asciidoc new file mode 100644 index 000000000..1708d0956 --- /dev/null +++ b/docs/doc_examples/bcc75fc01b45e482638c65b8fbdf09fa.asciidoc @@ -0,0 +1,7 @@ +[source,js] +---- +const response = await client.search({ + index: 'books' +}) +console.log(response) +---- diff --git a/docs/doc_examples/d04f0c8c44e8b4fb55f2e7d9d05977e7.asciidoc b/docs/doc_examples/d04f0c8c44e8b4fb55f2e7d9d05977e7.asciidoc new file mode 100644 index 000000000..e5ce437b2 --- /dev/null +++ b/docs/doc_examples/d04f0c8c44e8b4fb55f2e7d9d05977e7.asciidoc @@ -0,0 +1,43 @@ +[source,js] +---- +const response = await client.bulk({ + operations: [ + { index: { _index: 'books' } }, + { + name: 'Revelation Space', + author: 'Alastair Reynolds', + release_date: '2000-03-15', + page_count: 585, + }, + { index: { _index: 'books' } }, + { + name: '1984', + author: 'George Orwell', + release_date: '1985-06-01', + page_count: 328, + }, + { index: { _index: 'books' } }, + { + name: 'Fahrenheit 451', + author: 'Ray Bradbury', + release_date: '1953-10-15', + page_count: 227, + }, + { index: { _index: 'books' } }, + { + name: 'Brave New World', + author: 'Aldous Huxley', + release_date: '1932-06-01', + page_count: 268, + }, + { index: { _index: 'books' } }, + { + name: 'The Handmaids Tale', + author: 'Margaret Atwood', + release_date: '1985-06-01', + page_count: 311, + } + ] +}) +console.log(response) +---- From 6eabf37097c5dc32a618e47fdc0c968377ced314 Mon Sep 17 00:00:00 2001 From: Enrico Zimuel Date: Thu, 4 Jan 2024 13:13:26 +0100 Subject: [PATCH 32/33] Improved the body BC break description in request/response for 8.x documentation (#2117) * Improved the body bc break in 8.x documentation * Removed just in the sentence --- docs/changelog.asciidoc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/changelog.asciidoc b/docs/changelog.asciidoc index 0d79214b2..1b7e68c5a 100644 --- a/docs/changelog.asciidoc +++ b/docs/changelog.asciidoc @@ -361,6 +361,9 @@ The client API leaks HTTP-related notions in many places, and removing them woul This could be a rather big breaking change, so a double solution could be used during the 8.x lifecycle. (accepting body keys without them being wrapped in the body as well as the current solution). +To convert code from 7.x, you need to remove the `body` parameter in all the endpoints request. +For instance, this is an example for the `search` endpoint: + [source,js] ---- // from @@ -399,6 +402,12 @@ If you weren't extending the internals of the client, this won't be a breaking c The client API leaks HTTP-related notions in many places, and removing them would definitely improve the DX. The client will expose a new request-specific option to still get the full response details. +The new behaviour returns the `body` value directly as response. +If you want to have the 7.x response format, you need to add `meta : true` in the request. +This will return all the HTTP meta information, including the `body`. + +For instance, this is an example for the `search` endpoint: + [source,js] ---- // from From 57ee5cf6c257289557e7ed9e15da66995aae4240 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 31 Jan 2024 13:37:05 +0400 Subject: [PATCH 33/33] 8.12.0 changelog (#2125) --- docs/changelog.asciidoc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/changelog.asciidoc b/docs/changelog.asciidoc index 1b7e68c5a..4dbf11907 100644 --- a/docs/changelog.asciidoc +++ b/docs/changelog.asciidoc @@ -1,6 +1,18 @@ [[changelog-client]] == Release notes +[discrete] +=== 8.12.0 + +[discrete] +=== Features + +[discrete] +===== Support for Elasticsearch `v8.12.0` + +You can find all the API changes +https://www.elastic.co/guide/en/elasticsearch/reference/8.12/release-notes-8.12.0.html[here]. + [discrete] === 8.11.0