Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 537b5b0de9 | |||
| d24fff058e | |||
| bd7b38b24e | |||
| bd8892c37d | |||
| 360fe7b442 | |||
| 59203811dd | |||
| 457c30eb89 | |||
| 8c1646a662 | |||
| 9d747121e8 | |||
| 2907a84334 | |||
| d966a06a62 | |||
| 4bca80bafc | |||
| 080c3af904 | |||
| 14536d6855 | |||
| 11b4cea493 | |||
| 3673255959 | |||
| e0fc57766d | |||
| 9c2ec755d3 | |||
| a221a84a58 | |||
| 7d78dceed5 | |||
| c3832dc081 | |||
| af5c978131 |
@ -7,14 +7,13 @@
|
||||
# Export the TEST_SUITE variable, eg. 'oss' or 'xpack' defaults to 'oss'.
|
||||
# Export the NUMBER_OF_NODES variable to start more than 1 node
|
||||
|
||||
# Version 1.2.0
|
||||
# Version 1.1.0
|
||||
# - Initial version of the run-elasticsearch.sh script
|
||||
# - Deleting the volume should not dependent on the container still running
|
||||
# - Fixed `ES_JAVA_OPTS` config
|
||||
# - Moved to STACK_VERSION and TEST_VERSION
|
||||
# - Refactored into functions and imports
|
||||
# - Support NUMBER_OF_NODES
|
||||
# - Added 5 retries on docker pull for fixing transient network errors
|
||||
|
||||
script_path=$(dirname $(realpath -s $0))
|
||||
source $script_path/functions/imports.sh
|
||||
@ -68,17 +67,6 @@ if [[ "$TEST_SUITE" == "xpack" ]]; then
|
||||
cert_validation_flags="--insecure --cacert /usr/share/elasticsearch/config/certs/ca.crt --resolve ${es_node_name}:443:127.0.0.1"
|
||||
fi
|
||||
|
||||
# Pull the container, retry on failures up to 5 times with
|
||||
# short delays between each attempt. Fixes most transient network errors.
|
||||
docker_pull_attempts=0
|
||||
until [ "$docker_pull_attempts" -ge 5 ]
|
||||
do
|
||||
docker pull docker.elastic.co/elasticsearch/"$elasticsearch_container" && break
|
||||
docker_pull_attempts=$((docker_pull_attempts+1))
|
||||
echo "Failed to pull image, retrying in 10 seconds (retry $docker_pull_attempts/5)..."
|
||||
sleep 10
|
||||
done
|
||||
|
||||
NUMBER_OF_NODES=${NUMBER_OF_NODES-1}
|
||||
http_port=9200
|
||||
for (( i=0; i<$NUMBER_OF_NODES; i++, http_port++ )); do
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
STACK_VERSION:
|
||||
- 7.10.0-SNAPSHOT
|
||||
- 7.9.0-SNAPSHOT
|
||||
|
||||
NODE_JS_VERSION:
|
||||
- 14
|
||||
|
||||
4
.github/workflows/nodejs.yml
vendored
4
.github/workflows/nodejs.yml
vendored
@ -9,7 +9,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [10.x, 12.x, 14.x, 15.x]
|
||||
node-version: [10.x, 12.x, 14.x]
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
|
||||
steps:
|
||||
@ -86,7 +86,7 @@ jobs:
|
||||
- name: Runs Elasticsearch
|
||||
uses: elastic/elastic-github-actions/elasticsearch@master
|
||||
with:
|
||||
stack-version: 7.10.0-SNAPSHOT
|
||||
stack-version: 7.9.0-SNAPSHOT
|
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
|
||||
28
README.md
28
README.md
@ -26,34 +26,10 @@ The official Node.js client for Elasticsearch.
|
||||
npm install @elastic/elasticsearch
|
||||
```
|
||||
|
||||
### Node.js support
|
||||
|
||||
NOTE: The minimum supported version of Node.js is `v8`.
|
||||
|
||||
The client versioning follows the Elastc Stack versioning, this means that
|
||||
major, minor, and patch releases are done following a precise schedule that
|
||||
often does not coincide with the [Node.js release](https://nodejs.org/en/about/releases/) times.
|
||||
|
||||
To avoid support insecure and unsupported versions of Node.js, the
|
||||
client **will drop the support of EOL versions of Node.js between minor releases**.
|
||||
Typically, as soon as a Node.js version goes into EOL, the client will continue
|
||||
to support that version for at least another minor release. If you are using the client
|
||||
with a version of Node.js that will be unsupported soon, you will see a warning
|
||||
in your logs (the client will start logging the warning with two minors in advance).
|
||||
|
||||
Unless you are **always** using a supported version of Node.js,
|
||||
we recommend defining the client dependency in your
|
||||
`package.json` with the `~` instead of `^`. In this way, you will lock the
|
||||
dependency on the minor release and not the major. (for example, `~7.10.0` instead
|
||||
of `^7.10.0`).
|
||||
|
||||
| Node.js Version | Node.js EOL date | End of support |
|
||||
| --------------- |------------------| ---------------------- |
|
||||
| `8.x` | `December 2019` | `7.11` (early 2021) |
|
||||
| `10.x` | `Apri 2021` | `7.12` (mid 2021) |
|
||||
|
||||
### Compatibility
|
||||
|
||||
The minimum supported version of Node.js is `v8`.
|
||||
|
||||
The library is compatible with all Elasticsearch versions since 5.x, and you should use the same major version of the Elasticsearch instance that you are using.
|
||||
|
||||
| Elasticsearch Version | Client Version |
|
||||
|
||||
@ -23,8 +23,8 @@
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
|
||||
const acceptedQuerystring = ['wait_for_active_shards', 'refresh', 'routing', 'timeout', 'type', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'pipeline', 'require_alias', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
|
||||
const snakeCase = { waitForActiveShards: 'wait_for_active_shards', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', requireAlias: 'require_alias', errorTrace: 'error_trace', filterPath: 'filter_path' }
|
||||
const acceptedQuerystring = ['wait_for_active_shards', 'refresh', 'routing', 'timeout', 'type', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'pipeline', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
|
||||
const snakeCase = { waitForActiveShards: 'wait_for_active_shards', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', errorTrace: 'error_trace', filterPath: 'filter_path' }
|
||||
|
||||
function bulkApi (params, options, callback) {
|
||||
;[params, options, callback] = normalizeArguments(params, options, callback)
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
|
||||
const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path']
|
||||
const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' }
|
||||
|
||||
function closePointInTimeApi (params, options, callback) {
|
||||
;[params, options, callback] = normalizeArguments(params, options, callback)
|
||||
|
||||
var { method, body, ...querystring } = params
|
||||
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
|
||||
|
||||
var path = ''
|
||||
if (method == null) method = 'DELETE'
|
||||
path = '/' + '_pit'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
return this.transport.request(request, options, callback)
|
||||
}
|
||||
|
||||
module.exports = closePointInTimeApi
|
||||
@ -23,8 +23,8 @@
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
|
||||
const acceptedQuerystring = ['wait_for_active_shards', 'op_type', 'refresh', 'routing', 'timeout', 'version', 'version_type', 'if_seq_no', 'if_primary_term', 'pipeline', 'require_alias', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
|
||||
const snakeCase = { waitForActiveShards: 'wait_for_active_shards', opType: 'op_type', versionType: 'version_type', ifSeqNo: 'if_seq_no', ifPrimaryTerm: 'if_primary_term', requireAlias: 'require_alias', errorTrace: 'error_trace', filterPath: 'filter_path' }
|
||||
const acceptedQuerystring = ['wait_for_active_shards', 'op_type', 'refresh', 'routing', 'timeout', 'version', 'version_type', 'if_seq_no', 'if_primary_term', 'pipeline', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
|
||||
const snakeCase = { waitForActiveShards: 'wait_for_active_shards', opType: 'op_type', versionType: 'version_type', ifSeqNo: 'if_seq_no', ifPrimaryTerm: 'if_primary_term', errorTrace: 'error_trace', filterPath: 'filter_path' }
|
||||
|
||||
function indexApi (params, options, callback) {
|
||||
;[params, options, callback] = normalizeArguments(params, options, callback)
|
||||
|
||||
@ -517,8 +517,13 @@ IndicesApi.prototype.flushSynced = function indicesFlushSyncedApi (params, optio
|
||||
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
|
||||
|
||||
var path = ''
|
||||
if (method == null) method = body == null ? 'GET' : 'POST'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_flush' + '/' + 'synced'
|
||||
if ((index) != null) {
|
||||
if (method == null) method = body == null ? 'GET' : 'POST'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_flush' + '/' + 'synced'
|
||||
} else {
|
||||
if (method == null) method = body == null ? 'GET' : 'POST'
|
||||
path = '/' + '_flush' + '/' + 'synced'
|
||||
}
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
|
||||
@ -23,8 +23,8 @@
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
|
||||
const acceptedQuerystring = ['allow_no_match', 'allow_no_jobs', 'force', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'requests_per_second', 'allow_no_forecasts', 'wait_for_completion', 'lines_to_sample', 'line_merge_size_limit', 'charset', 'format', 'has_header_row', 'column_names', 'delimiter', 'quote', 'should_trim_fields', 'grok_pattern', 'timestamp_field', 'timestamp_format', 'explain', 'calc_interim', 'start', 'end', 'advance_time', 'skip_time', 'duration', 'expires_in', 'max_model_memory', 'expand', 'exclude_interim', 'from', 'size', 'anomaly_score', 'sort', 'desc', 'job_id', 'partition_field_value', 'verbose', 'allow_no_datafeeds', 'influencer_score', 'top_n', 'bucket_span', 'overall_score', 'record_score', 'include', 'include_model_definition', 'decompress_definition', 'tags', 'for_export', 'reset_start', 'reset_end', 'ignore_unavailable', 'allow_no_indices', 'ignore_throttled', 'expand_wildcards', 'delete_intervening_results', 'enabled']
|
||||
const snakeCase = { allowNoMatch: 'allow_no_match', allowNoJobs: 'allow_no_jobs', errorTrace: 'error_trace', filterPath: 'filter_path', requestsPerSecond: 'requests_per_second', allowNoForecasts: 'allow_no_forecasts', waitForCompletion: 'wait_for_completion', linesToSample: 'lines_to_sample', lineMergeSizeLimit: 'line_merge_size_limit', hasHeaderRow: 'has_header_row', columnNames: 'column_names', shouldTrimFields: 'should_trim_fields', grokPattern: 'grok_pattern', timestampField: 'timestamp_field', timestampFormat: 'timestamp_format', calcInterim: 'calc_interim', advanceTime: 'advance_time', skipTime: 'skip_time', expiresIn: 'expires_in', maxModelMemory: 'max_model_memory', excludeInterim: 'exclude_interim', anomalyScore: 'anomaly_score', jobId: 'job_id', partitionFieldValue: 'partition_field_value', allowNoDatafeeds: 'allow_no_datafeeds', influencerScore: 'influencer_score', topN: 'top_n', bucketSpan: 'bucket_span', overallScore: 'overall_score', recordScore: 'record_score', includeModelDefinition: 'include_model_definition', decompressDefinition: 'decompress_definition', forExport: 'for_export', resetStart: 'reset_start', resetEnd: 'reset_end', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', ignoreThrottled: 'ignore_throttled', expandWildcards: 'expand_wildcards', deleteInterveningResults: 'delete_intervening_results' }
|
||||
const acceptedQuerystring = ['allow_no_jobs', 'force', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'requests_per_second', 'allow_no_forecasts', 'wait_for_completion', 'lines_to_sample', 'line_merge_size_limit', 'charset', 'format', 'has_header_row', 'column_names', 'delimiter', 'quote', 'should_trim_fields', 'grok_pattern', 'timestamp_field', 'timestamp_format', 'explain', 'calc_interim', 'start', 'end', 'advance_time', 'skip_time', 'duration', 'expires_in', 'max_model_memory', 'expand', 'exclude_interim', 'from', 'size', 'anomaly_score', 'sort', 'desc', 'job_id', 'partition_field_value', 'allow_no_match', 'allow_no_datafeeds', 'influencer_score', 'top_n', 'bucket_span', 'overall_score', 'record_score', 'include_model_definition', 'decompress_definition', 'tags', 'for_export', 'reset_start', 'reset_end', 'ignore_unavailable', 'allow_no_indices', 'ignore_throttled', 'expand_wildcards', 'delete_intervening_results', 'enabled']
|
||||
const snakeCase = { allowNoJobs: 'allow_no_jobs', errorTrace: 'error_trace', filterPath: 'filter_path', requestsPerSecond: 'requests_per_second', allowNoForecasts: 'allow_no_forecasts', waitForCompletion: 'wait_for_completion', linesToSample: 'lines_to_sample', lineMergeSizeLimit: 'line_merge_size_limit', hasHeaderRow: 'has_header_row', columnNames: 'column_names', shouldTrimFields: 'should_trim_fields', grokPattern: 'grok_pattern', timestampField: 'timestamp_field', timestampFormat: 'timestamp_format', calcInterim: 'calc_interim', advanceTime: 'advance_time', skipTime: 'skip_time', expiresIn: 'expires_in', maxModelMemory: 'max_model_memory', excludeInterim: 'exclude_interim', anomalyScore: 'anomaly_score', jobId: 'job_id', partitionFieldValue: 'partition_field_value', allowNoMatch: 'allow_no_match', allowNoDatafeeds: 'allow_no_datafeeds', influencerScore: 'influencer_score', topN: 'top_n', bucketSpan: 'bucket_span', overallScore: 'overall_score', recordScore: 'record_score', includeModelDefinition: 'include_model_definition', decompressDefinition: 'decompress_definition', forExport: 'for_export', resetStart: 'reset_start', resetEnd: 'reset_end', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', ignoreThrottled: 'ignore_throttled', expandWildcards: 'expand_wildcards', deleteInterveningResults: 'delete_intervening_results' }
|
||||
|
||||
function MlApi (transport, ConfigurationError) {
|
||||
this.transport = transport
|
||||
@ -382,7 +382,7 @@ MlApi.prototype.deleteTrainedModel = function mlDeleteTrainedModelApi (params, o
|
||||
|
||||
var path = ''
|
||||
if (method == null) method = 'DELETE'
|
||||
path = '/' + '_ml' + '/' + 'trained_models' + '/' + encodeURIComponent(model_id || modelId)
|
||||
path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
@ -995,10 +995,10 @@ MlApi.prototype.getTrainedModels = function mlGetTrainedModelsApi (params, optio
|
||||
var path = ''
|
||||
if ((model_id || modelId) != null) {
|
||||
if (method == null) method = 'GET'
|
||||
path = '/' + '_ml' + '/' + 'trained_models' + '/' + encodeURIComponent(model_id || modelId)
|
||||
path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId)
|
||||
} else {
|
||||
if (method == null) method = 'GET'
|
||||
path = '/' + '_ml' + '/' + 'trained_models'
|
||||
path = '/' + '_ml' + '/' + 'inference'
|
||||
}
|
||||
|
||||
// build request object
|
||||
@ -1021,10 +1021,10 @@ MlApi.prototype.getTrainedModelsStats = function mlGetTrainedModelsStatsApi (par
|
||||
var path = ''
|
||||
if ((model_id || modelId) != null) {
|
||||
if (method == null) method = 'GET'
|
||||
path = '/' + '_ml' + '/' + 'trained_models' + '/' + encodeURIComponent(model_id || modelId) + '/' + '_stats'
|
||||
path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId) + '/' + '_stats'
|
||||
} else {
|
||||
if (method == null) method = 'GET'
|
||||
path = '/' + '_ml' + '/' + 'trained_models' + '/' + '_stats'
|
||||
path = '/' + '_ml' + '/' + 'inference' + '/' + '_stats'
|
||||
}
|
||||
|
||||
// build request object
|
||||
@ -1381,7 +1381,7 @@ MlApi.prototype.putTrainedModel = function mlPutTrainedModelApi (params, options
|
||||
|
||||
var path = ''
|
||||
if (method == null) method = 'PUT'
|
||||
path = '/' + '_ml' + '/' + 'trained_models' + '/' + encodeURIComponent(model_id || modelId)
|
||||
path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
|
||||
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
|
||||
const acceptedQuerystring = ['preference', 'routing', 'ignore_unavailable', 'expand_wildcards', 'keep_alive', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
|
||||
const snakeCase = { ignoreUnavailable: 'ignore_unavailable', expandWildcards: 'expand_wildcards', keepAlive: 'keep_alive', errorTrace: 'error_trace', filterPath: 'filter_path' }
|
||||
|
||||
function openPointInTimeApi (params, options, callback) {
|
||||
;[params, options, callback] = normalizeArguments(params, options, callback)
|
||||
|
||||
var { method, body, index, ...querystring } = params
|
||||
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
|
||||
|
||||
var path = ''
|
||||
if ((index) != null) {
|
||||
if (method == null) method = 'POST'
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_pit'
|
||||
} else {
|
||||
if (method == null) method = 'POST'
|
||||
path = '/' + '_pit'
|
||||
}
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
return this.transport.request(request, options, callback)
|
||||
}
|
||||
|
||||
module.exports = openPointInTimeApi
|
||||
@ -84,33 +84,6 @@ SecurityApi.prototype.changePassword = function securityChangePasswordApi (param
|
||||
return this.transport.request(request, options, callback)
|
||||
}
|
||||
|
||||
SecurityApi.prototype.clearApiKeyCache = function securityClearApiKeyCacheApi (params, options, callback) {
|
||||
;[params, options, callback] = normalizeArguments(params, options, callback)
|
||||
|
||||
// check required parameters
|
||||
if (params['ids'] == null) {
|
||||
const err = new this[kConfigurationError]('Missing required parameter: ids')
|
||||
return handleError(err, callback)
|
||||
}
|
||||
|
||||
var { method, body, ids, ...querystring } = params
|
||||
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
|
||||
|
||||
var path = ''
|
||||
if (method == null) method = 'POST'
|
||||
path = '/' + '_security' + '/' + 'api_key' + '/' + encodeURIComponent(ids) + '/' + '_clear_cache'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
return this.transport.request(request, options, callback)
|
||||
}
|
||||
|
||||
SecurityApi.prototype.clearCachedPrivileges = function securityClearCachedPrivilegesApi (params, options, callback) {
|
||||
;[params, options, callback] = normalizeArguments(params, options, callback)
|
||||
|
||||
@ -594,33 +567,6 @@ SecurityApi.prototype.getUserPrivileges = function securityGetUserPrivilegesApi
|
||||
return this.transport.request(request, options, callback)
|
||||
}
|
||||
|
||||
SecurityApi.prototype.grantApiKey = function securityGrantApiKeyApi (params, options, callback) {
|
||||
;[params, options, callback] = normalizeArguments(params, options, callback)
|
||||
|
||||
// check required parameters
|
||||
if (params['body'] == null) {
|
||||
const err = new this[kConfigurationError]('Missing required parameter: body')
|
||||
return handleError(err, callback)
|
||||
}
|
||||
|
||||
var { method, body, ...querystring } = params
|
||||
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
|
||||
|
||||
var path = ''
|
||||
if (method == null) method = 'POST'
|
||||
path = '/' + '_security' + '/' + 'api_key' + '/' + 'grant'
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
return this.transport.request(request, options, callback)
|
||||
}
|
||||
|
||||
SecurityApi.prototype.hasPrivileges = function securityHasPrivilegesApi (params, options, callback) {
|
||||
;[params, options, callback] = normalizeArguments(params, options, callback)
|
||||
|
||||
@ -829,7 +775,6 @@ SecurityApi.prototype.putUser = function securityPutUserApi (params, options, ca
|
||||
|
||||
Object.defineProperties(SecurityApi.prototype, {
|
||||
change_password: { get () { return this.changePassword } },
|
||||
clear_api_key_cache: { get () { return this.clearApiKeyCache } },
|
||||
clear_cached_privileges: { get () { return this.clearCachedPrivileges } },
|
||||
clear_cached_realms: { get () { return this.clearCachedRealms } },
|
||||
clear_cached_roles: { get () { return this.clearCachedRoles } },
|
||||
@ -848,7 +793,6 @@ Object.defineProperties(SecurityApi.prototype, {
|
||||
get_token: { get () { return this.getToken } },
|
||||
get_user: { get () { return this.getUser } },
|
||||
get_user_privileges: { get () { return this.getUserPrivileges } },
|
||||
grant_api_key: { get () { return this.grantApiKey } },
|
||||
has_privileges: { get () { return this.hasPrivileges } },
|
||||
invalidate_api_key: { get () { return this.invalidateApiKey } },
|
||||
invalidate_token: { get () { return this.invalidateToken } },
|
||||
|
||||
@ -58,54 +58,6 @@ SnapshotApi.prototype.cleanupRepository = function snapshotCleanupRepositoryApi
|
||||
return this.transport.request(request, options, callback)
|
||||
}
|
||||
|
||||
SnapshotApi.prototype.clone = function snapshotCloneApi (params, options, callback) {
|
||||
;[params, options, callback] = normalizeArguments(params, options, callback)
|
||||
|
||||
// check required parameters
|
||||
if (params['repository'] == null) {
|
||||
const err = new this[kConfigurationError]('Missing required parameter: repository')
|
||||
return handleError(err, callback)
|
||||
}
|
||||
if (params['snapshot'] == null) {
|
||||
const err = new this[kConfigurationError]('Missing required parameter: snapshot')
|
||||
return handleError(err, callback)
|
||||
}
|
||||
if (params['target_snapshot'] == null && params['targetSnapshot'] == null) {
|
||||
const err = new this[kConfigurationError]('Missing required parameter: target_snapshot or targetSnapshot')
|
||||
return handleError(err, callback)
|
||||
}
|
||||
if (params['body'] == null) {
|
||||
const err = new this[kConfigurationError]('Missing required parameter: body')
|
||||
return handleError(err, callback)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if ((params['target_snapshot'] != null || params['targetSnapshot'] != null) && (params['snapshot'] == null || params['repository'] == null)) {
|
||||
const err = new this[kConfigurationError]('Missing required parameter of the url: snapshot, repository')
|
||||
return handleError(err, callback)
|
||||
} else if (params['snapshot'] != null && (params['repository'] == null)) {
|
||||
const err = new this[kConfigurationError]('Missing required parameter of the url: repository')
|
||||
return handleError(err, callback)
|
||||
}
|
||||
|
||||
var { method, body, repository, snapshot, targetSnapshot, target_snapshot, ...querystring } = params
|
||||
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
|
||||
|
||||
var path = ''
|
||||
if (method == null) method = 'PUT'
|
||||
path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + '/' + '_clone' + '/' + encodeURIComponent(target_snapshot || targetSnapshot)
|
||||
|
||||
// build request object
|
||||
const request = {
|
||||
method,
|
||||
path,
|
||||
body: body || '',
|
||||
querystring
|
||||
}
|
||||
|
||||
return this.transport.request(request, options, callback)
|
||||
}
|
||||
|
||||
SnapshotApi.prototype.create = function snapshotCreateApi (params, options, callback) {
|
||||
;[params, options, callback] = normalizeArguments(params, options, callback)
|
||||
|
||||
|
||||
@ -23,8 +23,8 @@
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
|
||||
const acceptedQuerystring = ['wait_for_active_shards', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'lang', 'refresh', 'retry_on_conflict', 'routing', 'timeout', 'if_seq_no', 'if_primary_term', 'require_alias', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
|
||||
const snakeCase = { waitForActiveShards: 'wait_for_active_shards', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', retryOnConflict: 'retry_on_conflict', ifSeqNo: 'if_seq_no', ifPrimaryTerm: 'if_primary_term', requireAlias: 'require_alias', errorTrace: 'error_trace', filterPath: 'filter_path' }
|
||||
const acceptedQuerystring = ['wait_for_active_shards', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'lang', 'refresh', 'retry_on_conflict', 'routing', 'timeout', 'if_seq_no', 'if_primary_term', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
|
||||
const snakeCase = { waitForActiveShards: 'wait_for_active_shards', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', retryOnConflict: 'retry_on_conflict', ifSeqNo: 'if_seq_no', ifPrimaryTerm: 'if_primary_term', errorTrace: 'error_trace', filterPath: 'filter_path' }
|
||||
|
||||
function updateApi (params, options, callback) {
|
||||
;[params, options, callback] = normalizeArguments(params, options, callback)
|
||||
|
||||
27
api/index.js
27
api/index.js
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
@ -68,7 +53,6 @@ const updateByQueryRethrottleApi = require('./api/update_by_query_rethrottle')
|
||||
const AsyncSearchApi = require('./api/async_search')
|
||||
const AutoscalingApi = require('./api/autoscaling')
|
||||
const CcrApi = require('./api/ccr')
|
||||
const closePointInTimeApi = require('./api/close_point_in_time')
|
||||
const EnrichApi = require('./api/enrich')
|
||||
const EqlApi = require('./api/eql')
|
||||
const GraphApi = require('./api/graph')
|
||||
@ -77,7 +61,6 @@ const LicenseApi = require('./api/license')
|
||||
const MigrationApi = require('./api/migration')
|
||||
const MlApi = require('./api/ml')
|
||||
const MonitoringApi = require('./api/monitoring')
|
||||
const openPointInTimeApi = require('./api/open_point_in_time')
|
||||
const RollupApi = require('./api/rollup')
|
||||
const SearchableSnapshotsApi = require('./api/searchable_snapshots')
|
||||
const SecurityApi = require('./api/security')
|
||||
@ -188,8 +171,6 @@ ESAPI.prototype.termvectors = termvectorsApi
|
||||
ESAPI.prototype.update = updateApi
|
||||
ESAPI.prototype.updateByQuery = updateByQueryApi
|
||||
ESAPI.prototype.updateByQueryRethrottle = updateByQueryRethrottleApi
|
||||
ESAPI.prototype.closePointInTime = closePointInTimeApi
|
||||
ESAPI.prototype.openPointInTime = openPointInTimeApi
|
||||
|
||||
Object.defineProperties(ESAPI.prototype, {
|
||||
cat: {
|
||||
@ -302,7 +283,6 @@ Object.defineProperties(ESAPI.prototype, {
|
||||
return this[kCcr]
|
||||
}
|
||||
},
|
||||
close_point_in_time: { get () { return this.closePointInTime } },
|
||||
enrich: {
|
||||
get () {
|
||||
if (this[kEnrich] === null) {
|
||||
@ -367,7 +347,6 @@ Object.defineProperties(ESAPI.prototype, {
|
||||
return this[kMonitoring]
|
||||
}
|
||||
},
|
||||
open_point_in_time: { get () { return this.openPointInTime } },
|
||||
rollup: {
|
||||
get () {
|
||||
if (this[kRollup] === null) {
|
||||
|
||||
28
api/kibana.d.ts
vendored
28
api/kibana.d.ts
vendored
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
@ -130,7 +115,6 @@ interface KibanaClient {
|
||||
unfollow<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.CcrUnfollow, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
}
|
||||
clearScroll<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.ClearScroll<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
closePointInTime<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.ClosePointInTime<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
cluster: {
|
||||
allocationExplain<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.ClusterAllocationExplain<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
deleteComponentTemplate<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.ClusterDeleteComponentTemplate, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
@ -325,7 +309,7 @@ interface KibanaClient {
|
||||
startDataFrameAnalytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlStartDataFrameAnalytics<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
startDatafeed<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlStartDatafeed<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
stopDataFrameAnalytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlStopDataFrameAnalytics<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
stopDatafeed<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlStopDatafeed<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
stopDatafeed<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.MlStopDatafeed, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
updateDataFrameAnalytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlUpdateDataFrameAnalytics<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
updateDatafeed<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlUpdateDatafeed<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
updateFilter<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlUpdateFilter<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
@ -347,7 +331,6 @@ interface KibanaClient {
|
||||
stats<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.NodesStats, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
usage<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.NodesUsage, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
}
|
||||
openPointInTime<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.OpenPointInTime, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
ping<TResponse = boolean, TContext = Context>(params?: RequestParams.Ping, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
putScript<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.PutScript<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
rankEval<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.RankEval<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
@ -378,7 +361,6 @@ interface KibanaClient {
|
||||
security: {
|
||||
authenticate<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityAuthenticate, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
changePassword<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityChangePassword<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
clearApiKeyCache<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityClearApiKeyCache, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
clearCachedPrivileges<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityClearCachedPrivileges, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
clearCachedRealms<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityClearCachedRealms, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
clearCachedRoles<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityClearCachedRoles, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
@ -397,7 +379,6 @@ interface KibanaClient {
|
||||
getToken<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityGetToken<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
getUser<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityGetUser, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
getUserPrivileges<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityGetUserPrivileges, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
grantApiKey<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityGrantApiKey<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
hasPrivileges<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityHasPrivileges<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
invalidateApiKey<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityInvalidateApiKey<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
invalidateToken<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityInvalidateToken<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
@ -419,7 +400,6 @@ interface KibanaClient {
|
||||
}
|
||||
snapshot: {
|
||||
cleanupRepository<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotCleanupRepository, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
clone<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotClone<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
create<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotCreate<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
createRepository<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotCreateRepository<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
delete<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotDelete, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
|
||||
72
api/requestParams.d.ts
vendored
72
api/requestParams.d.ts
vendored
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { RequestBody, RequestNDBody } from '../lib/Transport'
|
||||
|
||||
@ -116,7 +101,6 @@ export interface Bulk<T = RequestNDBody> extends Generic {
|
||||
_source_excludes?: string | string[];
|
||||
_source_includes?: string | string[];
|
||||
pipeline?: string;
|
||||
require_alias?: boolean;
|
||||
body: T;
|
||||
}
|
||||
|
||||
@ -218,7 +202,6 @@ export interface CatMlDataFrameAnalytics extends Generic {
|
||||
|
||||
export interface CatMlDatafeeds extends Generic {
|
||||
datafeed_id?: string;
|
||||
allow_no_match?: boolean;
|
||||
allow_no_datafeeds?: boolean;
|
||||
format?: string;
|
||||
h?: string | string[];
|
||||
@ -230,7 +213,6 @@ export interface CatMlDatafeeds extends Generic {
|
||||
|
||||
export interface CatMlJobs extends Generic {
|
||||
job_id?: string;
|
||||
allow_no_match?: boolean;
|
||||
allow_no_jobs?: boolean;
|
||||
bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb';
|
||||
format?: string;
|
||||
@ -467,10 +449,6 @@ export interface ClearScroll<T = RequestBody> extends Generic {
|
||||
body?: T;
|
||||
}
|
||||
|
||||
export interface ClosePointInTime<T = RequestBody> extends Generic {
|
||||
body?: T;
|
||||
}
|
||||
|
||||
export interface ClusterAllocationExplain<T = RequestBody> extends Generic {
|
||||
include_yes_decisions?: boolean;
|
||||
include_disk_info?: boolean;
|
||||
@ -910,7 +888,6 @@ export interface Index<T = RequestBody> extends Generic {
|
||||
if_seq_no?: number;
|
||||
if_primary_term?: number;
|
||||
pipeline?: string;
|
||||
require_alias?: boolean;
|
||||
body: T;
|
||||
}
|
||||
|
||||
@ -1454,7 +1431,6 @@ export interface MigrationDeprecations extends Generic {
|
||||
|
||||
export interface MlCloseJob<T = RequestBody> extends Generic {
|
||||
job_id: string;
|
||||
allow_no_match?: boolean;
|
||||
allow_no_jobs?: boolean;
|
||||
force?: boolean;
|
||||
timeout?: string;
|
||||
@ -1619,18 +1595,15 @@ export interface MlGetDataFrameAnalyticsStats extends Generic {
|
||||
allow_no_match?: boolean;
|
||||
from?: number;
|
||||
size?: number;
|
||||
verbose?: boolean;
|
||||
}
|
||||
|
||||
export interface MlGetDatafeedStats extends Generic {
|
||||
datafeed_id?: string;
|
||||
allow_no_match?: boolean;
|
||||
allow_no_datafeeds?: boolean;
|
||||
}
|
||||
|
||||
export interface MlGetDatafeeds extends Generic {
|
||||
datafeed_id?: string;
|
||||
allow_no_match?: boolean;
|
||||
allow_no_datafeeds?: boolean;
|
||||
}
|
||||
|
||||
@ -1655,13 +1628,11 @@ export interface MlGetInfluencers<T = RequestBody> extends Generic {
|
||||
|
||||
export interface MlGetJobStats extends Generic {
|
||||
job_id?: string;
|
||||
allow_no_match?: boolean;
|
||||
allow_no_jobs?: boolean;
|
||||
}
|
||||
|
||||
export interface MlGetJobs extends Generic {
|
||||
job_id?: string;
|
||||
allow_no_match?: boolean;
|
||||
allow_no_jobs?: boolean;
|
||||
}
|
||||
|
||||
@ -1685,7 +1656,6 @@ export interface MlGetOverallBuckets<T = RequestBody> extends Generic {
|
||||
exclude_interim?: boolean;
|
||||
start?: string;
|
||||
end?: string;
|
||||
allow_no_match?: boolean;
|
||||
allow_no_jobs?: boolean;
|
||||
body?: T;
|
||||
}
|
||||
@ -1706,7 +1676,6 @@ export interface MlGetRecords<T = RequestBody> extends Generic {
|
||||
export interface MlGetTrainedModels extends Generic {
|
||||
model_id?: string;
|
||||
allow_no_match?: boolean;
|
||||
include?: string;
|
||||
include_model_definition?: boolean;
|
||||
decompress_definition?: boolean;
|
||||
from?: number;
|
||||
@ -1818,13 +1787,11 @@ export interface MlStopDataFrameAnalytics<T = RequestBody> extends Generic {
|
||||
body?: T;
|
||||
}
|
||||
|
||||
export interface MlStopDatafeed<T = RequestBody> extends Generic {
|
||||
export interface MlStopDatafeed extends Generic {
|
||||
datafeed_id: string;
|
||||
allow_no_match?: boolean;
|
||||
allow_no_datafeeds?: boolean;
|
||||
force?: boolean;
|
||||
timeout?: string;
|
||||
body?: T;
|
||||
}
|
||||
|
||||
export interface MlUpdateDataFrameAnalytics<T = RequestBody> extends Generic {
|
||||
@ -1958,15 +1925,6 @@ export interface NodesUsage extends Generic {
|
||||
timeout?: string;
|
||||
}
|
||||
|
||||
export interface OpenPointInTime extends Generic {
|
||||
index?: string | string[];
|
||||
preference?: string;
|
||||
routing?: string;
|
||||
ignore_unavailable?: boolean;
|
||||
expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all';
|
||||
keep_alive?: string;
|
||||
}
|
||||
|
||||
export interface Ping extends Generic {
|
||||
}
|
||||
|
||||
@ -2170,10 +2128,6 @@ export interface SecurityChangePassword<T = RequestBody> extends Generic {
|
||||
body: T;
|
||||
}
|
||||
|
||||
export interface SecurityClearApiKeyCache extends Generic {
|
||||
ids: string | string[];
|
||||
}
|
||||
|
||||
export interface SecurityClearCachedPrivileges extends Generic {
|
||||
application: string | string[];
|
||||
}
|
||||
@ -2240,11 +2194,11 @@ export interface SecurityGetPrivileges extends Generic {
|
||||
}
|
||||
|
||||
export interface SecurityGetRole extends Generic {
|
||||
name?: string | string[];
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface SecurityGetRoleMapping extends Generic {
|
||||
name?: string | string[];
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface SecurityGetToken<T = RequestBody> extends Generic {
|
||||
@ -2258,11 +2212,6 @@ export interface SecurityGetUser extends Generic {
|
||||
export interface SecurityGetUserPrivileges extends Generic {
|
||||
}
|
||||
|
||||
export interface SecurityGrantApiKey<T = RequestBody> extends Generic {
|
||||
refresh?: 'wait_for' | boolean;
|
||||
body: T;
|
||||
}
|
||||
|
||||
export interface SecurityHasPrivileges<T = RequestBody> extends Generic {
|
||||
user?: string;
|
||||
body: T;
|
||||
@ -2337,14 +2286,6 @@ export interface SnapshotCleanupRepository extends Generic {
|
||||
timeout?: string;
|
||||
}
|
||||
|
||||
export interface SnapshotClone<T = RequestBody> extends Generic {
|
||||
repository: string;
|
||||
snapshot: string;
|
||||
target_snapshot: string;
|
||||
master_timeout?: string;
|
||||
body: T;
|
||||
}
|
||||
|
||||
export interface SnapshotCreate<T = RequestBody> extends Generic {
|
||||
repository: string;
|
||||
snapshot: string;
|
||||
@ -2532,7 +2473,6 @@ export interface Update<T = RequestBody> extends Generic {
|
||||
timeout?: string;
|
||||
if_seq_no?: number;
|
||||
if_primary_term?: number;
|
||||
require_alias?: boolean;
|
||||
body: T;
|
||||
}
|
||||
|
||||
|
||||
129
docs/authentication.asciidoc
Normal file
129
docs/authentication.asciidoc
Normal file
@ -0,0 +1,129 @@
|
||||
[[auth-reference]]
|
||||
== Authentication
|
||||
|
||||
This document contains code snippets to show you how to connect to various {es}
|
||||
providers.
|
||||
|
||||
|
||||
=== Elastic Cloud
|
||||
|
||||
If you are using https://www.elastic.co/cloud[Elastic Cloud], the client offers
|
||||
an easy way to connect to it via the `cloud` option. You must pass the Cloud ID
|
||||
that you can find in the cloud console, then your username and password inside
|
||||
the `auth` option.
|
||||
|
||||
NOTE: When connecting to Elastic Cloud, the client will automatically enable
|
||||
both request and response compression by default, since it yields significant
|
||||
throughput improvements. Moreover, the client will also set the ssl option
|
||||
`secureProtocol` to `TLSv1_2_method` unless specified otherwise. You can still
|
||||
override this option by configuring them.
|
||||
|
||||
IMPORTANT: Do not enable sniffing when using Elastic Cloud, since the nodes are
|
||||
behind a load balancer, Elastic Cloud will take care of everything for you.
|
||||
Take a look https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how[here]
|
||||
to know more.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
cloud: {
|
||||
id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==',
|
||||
},
|
||||
auth: {
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
=== Basic authentication
|
||||
|
||||
You can provide your credentials by passing the `username` and `password`
|
||||
parameters via the `auth` option.
|
||||
|
||||
NOTE: If you provide both basic authentication credentials and the Api Key configuration, the Api Key will take precedence.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
auth: {
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
Otherwise, you can provide your credentials in the node(s) URL.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://username:password@localhost:9200'
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
=== ApiKey authentication
|
||||
|
||||
You can use the
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/7.x/security-api-create-api-key.html[ApiKey]
|
||||
authentication by passing the `apiKey` parameter via the `auth` option. The
|
||||
`apiKey` parameter can be either a base64 encoded string or an object with the
|
||||
values that you can obtain from the
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/7.x/security-api-create-api-key.html[create api key endpoint].
|
||||
|
||||
NOTE: If you provide both basic authentication credentials and the Api Key configuration, the Api Key will take precedence.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
auth: {
|
||||
apiKey: 'base64EncodedKey'
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
auth: {
|
||||
apiKey: {
|
||||
id: 'foo',
|
||||
api_key: 'bar'
|
||||
}
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
=== SSL configuration
|
||||
|
||||
Without any additional configuration you can specify `https://` node urls, and
|
||||
the certificates used to sign these requests will be verified. To turn off certificate verification, you must specify an `ssl` object in the top level config and set `rejectUnauthorized: false`. The default `ssl` values are the same that Node.js's https://nodejs.org/api/tls.html#tls_tls_connect_options_callback[`tls.connect()`]
|
||||
uses.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
auth: {
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
},
|
||||
ssl: {
|
||||
ca: fs.readFileSync('./cacert.pem'),
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
})
|
||||
----
|
||||
@ -6,7 +6,6 @@ to install with `npm install elasticsearch` – you will encounter some breaking
|
||||
changes.
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Don’t panic!
|
||||
|
||||
Every breaking change was carefully weighed, and each is justified. Furthermore,
|
||||
@ -14,7 +13,6 @@ the new codebase has been rewritten with modern JavaScript and has been
|
||||
carefully designed to be easy to maintain.
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Breaking changes
|
||||
|
||||
* Minimum supported version of Node.js is `v8`.
|
||||
@ -211,7 +209,6 @@ client.transport.request({
|
||||
})
|
||||
----
|
||||
|
||||
[discrete]
|
||||
=== Talk is cheap. Show me the code.
|
||||
|
||||
You can find a code snippet with the old client below followed by the same code
|
||||
|
||||
@ -1,136 +1,6 @@
|
||||
[[changelog-client]]
|
||||
== Changelog
|
||||
|
||||
=== 7.9.1
|
||||
|
||||
==== Fixes
|
||||
|
||||
===== Improve child performances https://github.com/elastic/elasticsearch-js/pull/1314[#1314]
|
||||
|
||||
The client code has been refactored to speed up the performances of the child method.
|
||||
Before this pr, creating many children per second would have caused a high memory consumption and a spike in CPU usage.
|
||||
This pr changes the way the client is created by refactoring the code generation, now the clients methods are no longer added to the instance with a for loop but via prototypal inheritance. Thus, the overall performances are way better, now creating a child is ~5 times faster, and it consumes ~70% less memory.
|
||||
|
||||
This change should not cause any breaking change unless you were mocking the client methods. In such case you should refactor it, or use https://github.com/elastic/elasticsearch-js-mock[elasticsearch-js-mock].
|
||||
|
||||
Finally, this change should also fix once and of all the bundlers support.
|
||||
|
||||
===== Throw all errors asynchronously https://github.com/elastic/elasticsearch-js/pull/1295[#1295]
|
||||
|
||||
Some validation errors were thrown synchronously, causing the callback to be called in th same tick.
|
||||
This issue is known as _"The release fo Zalgo"_ (see https://blog.izs.me/2013/08/designing-apis-for-asynchrony[here]).
|
||||
|
||||
===== Fix `maxRetries` request option handling https://github.com/elastic/elasticsearch-js/pull/1296[#1296]
|
||||
|
||||
The `maxRetries` parameter can be configured on a per requets basis, if set to zero it was defaulting to the client default. Now the client is honoring the request specific configuration.
|
||||
|
||||
|
||||
===== Fix RequestOptions.body type to include null https://github.com/elastic/elasticsearch-js/pull/1300[#1300]
|
||||
|
||||
The Connection requets option types were not accepting `null` as valid value.
|
||||
|
||||
===== Fixed `size` and `maxRetries` parameters in helpers https://github.com/elastic/elasticsearch-js/pull/1284[#1284]
|
||||
|
||||
The `size` parameter was being passed too the scroll request, which was causing an error.
|
||||
`maxRetries` setted to 0 was resulting in no request at all.
|
||||
|
||||
=== 7.9.0
|
||||
|
||||
==== Features
|
||||
|
||||
===== Add ability to disable the http agent https://github.com/elastic/elasticsearch-js/pull/1251[#1251]
|
||||
|
||||
If needed, the http agent can be disabled by setting it to `false`
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200'.
|
||||
agent: false
|
||||
})
|
||||
----
|
||||
|
||||
===== Add support for a global context option https://github.com/elastic/elasticsearch-js/pull/1256[#1256]
|
||||
|
||||
Before this, you could set a `context` option in each request, but there was no way of setting it globally.
|
||||
Now you can by configuring the `context` object in the global configuration, that will be merged with the local one.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200'.
|
||||
context: { meta: 'data' }
|
||||
})
|
||||
----
|
||||
|
||||
===== ESM support https://github.com/elastic/elasticsearch-js/pull/1235[#1235]
|
||||
|
||||
If you are using ES Modules, now you can easily import the client!
|
||||
|
||||
[source,js]
|
||||
----
|
||||
import { Client } from '@elastic/elasticsearch'
|
||||
----
|
||||
|
||||
==== Fixes
|
||||
|
||||
===== Allow the client name to be a symbol https://github.com/elastic/elasticsearch-js/pull/1254[#1254]
|
||||
|
||||
It was possible in plain JavaScript, but not in TypeScript, now you can do it in TypeScript as well.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
name: Symbol('unique')
|
||||
})
|
||||
----
|
||||
|
||||
===== Fixed transport.request querystring type https://github.com/elastic/elasticsearch-js/pull/1240[#1240]
|
||||
|
||||
Only `Record<string, any>` was allowed. Now `string` is allowed as well.
|
||||
|
||||
===== Fixed type definitions https://github.com/elastic/elasticsearch-js/pull/1263[#1263]
|
||||
|
||||
* The `transport.request` defintion was incorrect, it was returning a `Promise<T>` instead of `TransportRequestPromise<T>`.
|
||||
* The `refresh` parameter of most APIs was declared as `'true' | 'false' | 'wait_for'`, which was clunky. Now is `'wait_for' | boolean`.
|
||||
|
||||
===== Generate response type as boolean if the request is HEAD only https://github.com/elastic/elasticsearch-js/pull/1275[#1275]
|
||||
|
||||
All HEAD request will have the body casted to a boolean value, `true` in case of a 200 response, `false` in case of
|
||||
a 404 response. The type definitions were not reflecting this behavior.
|
||||
|
||||
[source,ts]
|
||||
----
|
||||
import { Client } from '@elastic/elasticsearch'
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200'
|
||||
})
|
||||
|
||||
const { body } = await client.exist({ index: 'my-index', id: 'my-id' })
|
||||
console.log(body) // either `true` or `false`
|
||||
----
|
||||
|
||||
==== Internals
|
||||
|
||||
===== Updated default http agent configuration https://github.com/elastic/elasticsearch-js/pull/1242[#1242]
|
||||
|
||||
Added the scheduling: 'lifo' option to the default HTTP agent configuration to avoid maximizing the open sockets
|
||||
against Elasticsearch and lowering the risk of encountering socket timeouts.
|
||||
This feature is only available from Node v14.5+, but it should be backported to v10 and v12. (https://github.com/nodejs/node/pull/33278[nodejs/node#33278])
|
||||
|
||||
===== Improve child API https://github.com/elastic/elasticsearch-js/pull/1245[#1245]
|
||||
|
||||
This pr introduce two changes which should not impact the surface API:
|
||||
|
||||
* Refactored the `client.child` API to allocate fewer objects, this change improves memory consumption over time
|
||||
and improves the child creation performances by ~12%.
|
||||
* The client no longer inherits from the EventEmitter class, but instead has an internal event emitter and exposes
|
||||
only the API useful for the users, namely `emit, `on`, `once`, and `off`. The type definitions have been updated accordingly.
|
||||
|
||||
=== 7.8.0
|
||||
|
||||
==== Features
|
||||
|
||||
@ -17,7 +17,7 @@ const client = new Client({
|
||||
})
|
||||
----
|
||||
|
||||
[discrete]
|
||||
|
||||
=== Basic options
|
||||
|
||||
[cols=2*]
|
||||
@ -117,24 +117,6 @@ _Default:_ `false`
|
||||
|`http.SecureContextOptions` - ssl https://nodejs.org/api/tls.html[configuraton]. +
|
||||
_Default:_ `null`
|
||||
|
||||
|`proxy`
|
||||
a|`string, URL` - If you are using an http(s) proxy, you can put its url here.
|
||||
The client will automatically handle the connection to it. +
|
||||
_Default:_ `null`
|
||||
[source,js]
|
||||
----
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
proxy: 'http://localhost:8080'
|
||||
})
|
||||
|
||||
// Proxy with basic authentication
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
proxy: 'http://user:pwd@localhost:8080'
|
||||
})
|
||||
----
|
||||
|
||||
|`agent`
|
||||
a|`http.AgentOptions, function` - http agent https://nodejs.org/api/http.html#http_new_agent_options[options],
|
||||
or a function that returns an actual http agent instance. If you want to disable the http agent use entirely
|
||||
@ -149,9 +131,7 @@ const client = new Client({
|
||||
|
||||
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()
|
||||
agent: () => new CustomAgent()
|
||||
})
|
||||
|
||||
const client = new Client({
|
||||
@ -205,7 +185,7 @@ function generateRequestId (params, options) {
|
||||
----
|
||||
|
||||
|`name`
|
||||
|`string, symbol` - The name to identify the client instance in the events. +
|
||||
|`string | symbol` - The name to identify the client instance in the events. +
|
||||
_Default:_ `elasticsearch-js`
|
||||
|
||||
|`opaqueIdPrefix`
|
||||
@ -244,7 +224,6 @@ const client = new Client({
|
||||
|===
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Advanced configuration
|
||||
|
||||
If you need to customize the client behavior heavily, you are in the right
|
||||
@ -256,7 +235,6 @@ place! The client allows you to customize the following internals:
|
||||
* `Serializer` class
|
||||
|
||||
|
||||
[discrete]
|
||||
=== `Transport`
|
||||
|
||||
This class is responsible for performing the request to {es} and handling
|
||||
@ -291,7 +269,6 @@ class MyTransport extends Transport {
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
=== `ConnectionPool`
|
||||
|
||||
This class is responsible for keeping in memory all the {es} Connection that we
|
||||
@ -315,7 +292,6 @@ const client = new Client({
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
=== `Connection`
|
||||
|
||||
This class represents a single node, it holds every information we have on the
|
||||
@ -339,7 +315,6 @@ const client = new Client({
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
=== `Serializer`
|
||||
|
||||
This class is responsible for the serialization of every request, it offers the
|
||||
|
||||
@ -6,16 +6,12 @@ The client comes with an handy collection of helpers to give you a more comforta
|
||||
CAUTION: The client helpers are experimental, and the API may change in the next minor releases.
|
||||
The helpers will not work in any Node.js version lower than 10.
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Bulk Helper
|
||||
|
||||
~Added~ ~in~ ~`v7.7.0`~
|
||||
|
||||
Running Bulk requests can be complex due to the shape of the API, this helper aims to provide a nicer developer experience around the Bulk API.
|
||||
|
||||
|
||||
[discrete]
|
||||
==== Usage
|
||||
[source,js]
|
||||
----
|
||||
@ -154,12 +150,8 @@ const b = client.helpers.bulk({
|
||||
|
||||
|===
|
||||
|
||||
|
||||
[discrete]
|
||||
==== Supported operations
|
||||
|
||||
|
||||
[discrete]
|
||||
===== Index
|
||||
[source,js]
|
||||
----
|
||||
@ -173,8 +165,6 @@ client.helpers.bulk({
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
===== Create
|
||||
[source,js]
|
||||
----
|
||||
@ -188,17 +178,14 @@ client.helpers.bulk({
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
===== Update
|
||||
|
||||
[source,js]
|
||||
----
|
||||
client.helpers.bulk({
|
||||
datasource: myDatasource,
|
||||
onDocument (doc) {
|
||||
// Note that the update operation requires you to return
|
||||
// an array, where the first element is the action, while
|
||||
// an array, where the first element is the actio, while
|
||||
// the second are the document option
|
||||
return [
|
||||
{ update: { _index: 'my-index', _id: doc.id } },
|
||||
@ -208,10 +195,7 @@ client.helpers.bulk({
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
===== Delete
|
||||
|
||||
[source,js]
|
||||
----
|
||||
client.helpers.bulk({
|
||||
@ -224,10 +208,7 @@ client.helpers.bulk({
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
==== Abort a bulk operation
|
||||
|
||||
If needed, you can abort a bulk operation at any time. The bulk helper returns a https://promisesaplus.com/[thenable], which has an `abort` method.
|
||||
|
||||
NOTE: The abort method will stop the execution of the bulk operation, but if you are using a concurrency higher than one, the operations that are already running will not be stopped.
|
||||
@ -254,10 +235,7 @@ const b = client.helpers.bulk({
|
||||
console.log(await b)
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
==== Passing custom options to the Bulk API
|
||||
|
||||
You can pass any option supported by the link:{ref}/docs-bulk.html#docs-bulk-api-query-params[Bulk API] to the helper, and the helper will use those options in conjuction with the Bulk
|
||||
API call.
|
||||
|
||||
@ -274,8 +252,6 @@ const result = await client.helpers.bulk({
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
==== Usage with an async generator
|
||||
|
||||
[source,js]
|
||||
@ -306,8 +282,6 @@ const result = await client.helpers.bulk({
|
||||
console.log(result)
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Multi Search Helper
|
||||
|
||||
~Added~ ~in~ ~`v7.8.0`~
|
||||
@ -316,10 +290,7 @@ If you are sending search request at a high rate, this helper might be useful fo
|
||||
It will use the mutli search API under the hood to batch the requests and improve the overall performances of your application. +
|
||||
The `result` exposes a `documents` property as well, which allows you to access directly the hits sources.
|
||||
|
||||
|
||||
[discrete]
|
||||
==== Usage
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
@ -401,10 +372,7 @@ const m = client.helpers.msearch({
|
||||
|
||||
|===
|
||||
|
||||
|
||||
[discrete]
|
||||
==== Stopping the Msearch Helper
|
||||
|
||||
If needed, you can stop a msearch processor at any time. The msearch helper returns a https://promisesaplus.com/[thenable], which has an `stop` method.
|
||||
|
||||
If you are creating multiple msearch helpers instances and using them for a limitied period of time, remember to always use the `stop` method once you have finished using them, otherwise your application will start leaking memory.
|
||||
@ -437,8 +405,6 @@ m.search(
|
||||
setImmediate(() => m.stop())
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Search Helper
|
||||
|
||||
~Added~ ~in~ ~`v7.7.0`~
|
||||
@ -464,8 +430,6 @@ for (const doc of documents) {
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Scroll Search Helper
|
||||
|
||||
~Added~ ~in~ ~`v7.7.0`~
|
||||
@ -491,8 +455,6 @@ for await (const result of scrollSearch) {
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
==== Clear a scroll search
|
||||
|
||||
If needed, you can clear a scroll search by calling `result.clear()`:
|
||||
@ -506,8 +468,6 @@ for await (const result of scrollSearch) {
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
==== Quickly getting the documents
|
||||
|
||||
If you only need the documents from the result of a scroll search, you can access them via `result.documents`:
|
||||
@ -519,8 +479,6 @@ for await (const result of scrollSearch) {
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Scroll Documents Helper
|
||||
|
||||
~Added~ ~in~ ~`v7.7.0`~
|
||||
|
||||
@ -4,12 +4,12 @@
|
||||
include::{asciidoc-dir}/../../shared/attributes.asciidoc[]
|
||||
|
||||
include::introduction.asciidoc[]
|
||||
include::installation.asciidoc[]
|
||||
include::connecting.asciidoc[]
|
||||
include::changelog.asciidoc[]
|
||||
include::usage.asciidoc[]
|
||||
include::configuration.asciidoc[]
|
||||
include::reference.asciidoc[]
|
||||
include::breaking-changes.asciidoc[]
|
||||
include::authentication.asciidoc[]
|
||||
include::observability.asciidoc[]
|
||||
include::child.asciidoc[]
|
||||
include::extend.asciidoc[]
|
||||
@ -17,4 +17,3 @@ include::helpers.asciidoc[]
|
||||
include::typescript.asciidoc[]
|
||||
include::testing.asciidoc[]
|
||||
include::examples/index.asciidoc[]
|
||||
include::redirects.asciidoc[]
|
||||
|
||||
@ -1,93 +0,0 @@
|
||||
[[installation]]
|
||||
== Installation
|
||||
|
||||
This page guides you through the installation process of the client.
|
||||
|
||||
To install the latest version of the client, run the following command:
|
||||
|
||||
[source,sh]
|
||||
----
|
||||
npm install @elastic/elasticsearch
|
||||
----
|
||||
|
||||
To install a specific major version of the client, run the following command:
|
||||
|
||||
[source,sh]
|
||||
----
|
||||
npm install @elastic/elasticsearch@<major>
|
||||
----
|
||||
|
||||
To learn more about the supported major versions, please refer to the
|
||||
<<js-compatibility-matrix>>.
|
||||
|
||||
[discrete]
|
||||
[[nodejs-support]]
|
||||
=== Node.js support
|
||||
|
||||
NOTE: The minimum supported version of Node.js is `v8`.
|
||||
|
||||
The client versioning follows the {stack} versioning, this means that
|
||||
major, minor, and patch releases are done following a precise schedule that
|
||||
often does not coincide with the https://nodejs.org/en/about/releases/[Node.js release] times.
|
||||
|
||||
To avoid support insecure and unsupported versions of Node.js, the
|
||||
client *will drop the support of EOL versions of Node.js between minor releases*.
|
||||
Typically, as soon as a Node.js version goes into EOL, the client will continue
|
||||
to support that version for at least another minor release. If you are using the client
|
||||
with a version of Node.js that will be unsupported soon, you will see a warning
|
||||
in your logs (the client will start logging the warning with two minors in advance).
|
||||
|
||||
Unless you are *always* using a supported version of Node.js,
|
||||
we recommend defining the client dependency in your
|
||||
`package.json` with the `~` instead of `^`. In this way, you will lock the
|
||||
dependency on the minor release and not the major. (for example, `~7.10.0` instead
|
||||
of `^7.10.0`).
|
||||
|
||||
[%header,cols=3*]
|
||||
|===
|
||||
|Node.js Version
|
||||
|Node.js EOL date
|
||||
|End of support
|
||||
|
||||
|`8.x`
|
||||
|December 2019
|
||||
|`7.11` (early 2021)
|
||||
|
||||
|`10.x`
|
||||
|April 2021
|
||||
|`7.12` (mid 2021)
|
||||
|===
|
||||
|
||||
[discrete]
|
||||
[[js-compatibility-matrix]]
|
||||
=== Compatibility matrix
|
||||
|
||||
The library is compatible with all {es} versions since 5.x. We recommend you to
|
||||
use the same major version of the client as the {es} instance that you are
|
||||
using.
|
||||
|
||||
[%header,cols=2*]
|
||||
|===
|
||||
|{es} Version
|
||||
|Client Version
|
||||
|
||||
|`master`
|
||||
|`master`
|
||||
|
||||
|`7.x`
|
||||
|`7.x`
|
||||
|
||||
|`6.x`
|
||||
|`6.x`
|
||||
|
||||
|`5.x`
|
||||
|`5.x`
|
||||
|===
|
||||
|
||||
|
||||
[discrete]
|
||||
==== Browser
|
||||
|
||||
WARNING: There is no official support for the browser environment. It exposes
|
||||
your {es} instance to everyone, which could lead to security issues. We
|
||||
recommend you to write a lightweight proxy that uses this client instead.
|
||||
@ -1,11 +1,9 @@
|
||||
[[introduction]]
|
||||
== Introduction
|
||||
|
||||
This is the official Node.js client for {es}. This page gives a quick overview
|
||||
about the features of the client.
|
||||
The official Node.js client for {es}.
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Features
|
||||
|
||||
* One-to-one mapping with REST API.
|
||||
@ -17,7 +15,55 @@ about the features of the client.
|
||||
* TypeScript support out of the box.
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Install
|
||||
|
||||
[source,sh]
|
||||
----
|
||||
npm install @elastic/elasticsearch
|
||||
----
|
||||
|
||||
|
||||
=== Compatibility
|
||||
|
||||
The minimum supported version of Node.js is `v8`.
|
||||
|
||||
The library is compatible with all {es} versions since 5.x. We recommend you to
|
||||
use the same major version of the client as the {es} instance that you are
|
||||
using.
|
||||
|
||||
|
||||
[%header,cols=2*]
|
||||
|===
|
||||
|{es} Version
|
||||
|Client Version
|
||||
|
||||
|`master`
|
||||
|`master`
|
||||
|
||||
|`7.x`
|
||||
|`7.x`
|
||||
|
||||
|`6.x`
|
||||
|`6.x`
|
||||
|
||||
|`5.x`
|
||||
|`5.x`
|
||||
|===
|
||||
|
||||
To install a specific major version of the client, run the following command:
|
||||
|
||||
----
|
||||
npm install @elastic/elasticsearch@<major>
|
||||
----
|
||||
|
||||
|
||||
==== Browser
|
||||
|
||||
WARNING: There is no official support for the browser environment. It exposes
|
||||
your {es} instance to everyone, which could lead to security issues. We
|
||||
recommend you to write a lightweight proxy that uses this client instead.
|
||||
|
||||
|
||||
=== Quick start
|
||||
|
||||
First of all, require, then initialize the client:
|
||||
@ -130,7 +176,7 @@ async function run () {
|
||||
run().catch(console.log)
|
||||
----
|
||||
|
||||
[discrete]
|
||||
|
||||
==== Install multiple versions
|
||||
|
||||
If you are using multiple versions of {es}, you need to use multiple versions of
|
||||
|
||||
@ -11,8 +11,6 @@ a large codebase with many events happening at the same time.
|
||||
To help you with this, the client offers you a correlation id system and other
|
||||
features. Let's see them in action.
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Events
|
||||
|
||||
The client is an event emitter, this means that you can listen for its event and
|
||||
@ -128,7 +126,6 @@ request: {
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Correlation id
|
||||
|
||||
Correlating events can be quite hard, especially if there are many events at the
|
||||
@ -196,7 +193,6 @@ client.search({
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Context object
|
||||
|
||||
Sometimes, you might need to make some custom data available in your events, you
|
||||
@ -272,7 +268,6 @@ client.search({
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
=== Client name
|
||||
|
||||
If you are using multiple instances of the client or if you are using multiple
|
||||
@ -326,7 +321,6 @@ child.search({
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
=== X-Opaque-Id support
|
||||
|
||||
To improve the overall observability, the client offers an easy way to configure
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
"appendix",role="exclude",id="redirects"]
|
||||
= Deleted pages
|
||||
|
||||
The following pages have moved or been deleted.
|
||||
|
||||
[role="exclude",id="auth-reference"]
|
||||
== Authentication
|
||||
|
||||
This page has moved. See <<authentication>>.
|
||||
File diff suppressed because it is too large
Load Diff
@ -33,8 +33,6 @@ the `Connection` component since it has very few responsibilities and
|
||||
it does not interact with other internal components other than getting
|
||||
requests and returning responses.
|
||||
|
||||
|
||||
[discrete]
|
||||
=== `@elastic/elasticsearch-mock`
|
||||
|
||||
Writing each time a mock for your test can be annoying and error-prone,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
[[typescript]]
|
||||
|
||||
== TypeScript support
|
||||
|
||||
The client offers a first-class support for TypeScript, since it ships the type
|
||||
@ -38,7 +39,6 @@ console.log(response.body)
|
||||
You don't have to specify all the generics, but the order must be respected.
|
||||
|
||||
|
||||
[discrete]
|
||||
=== A complete example
|
||||
|
||||
[source,ts]
|
||||
|
||||
@ -1,164 +1,5 @@
|
||||
[[client-connecting]]
|
||||
== Connecting
|
||||
|
||||
This page contains the information you need to connect and use the Client with
|
||||
{es}.
|
||||
|
||||
**On this page**
|
||||
|
||||
* <<auth-reference, Authentication options>>
|
||||
* <<client-usage, Using the client>>
|
||||
* <<client-connect-proxy, Connecting through a proxy>>
|
||||
* <<client-error-handling, Handling errors>>
|
||||
|
||||
[discrete]
|
||||
[[authentication]]
|
||||
=== Authentication
|
||||
|
||||
This document contains code snippets to show you how to connect to various {es}
|
||||
providers.
|
||||
|
||||
|
||||
[discrete]
|
||||
[[auth-ec]]
|
||||
==== Elastic Cloud
|
||||
|
||||
If you are using https://www.elastic.co/cloud[Elastic Cloud], the client offers
|
||||
an easy way to connect to it via the `cloud` option. You must pass the Cloud ID
|
||||
that you can find in the cloud console, then your username and password inside
|
||||
the `auth` option.
|
||||
|
||||
NOTE: When connecting to Elastic Cloud, the client will automatically enable
|
||||
both request and response compression by default, since it yields significant
|
||||
throughput improvements. Moreover, the client will also set the ssl option
|
||||
`secureProtocol` to `TLSv1_2_method` unless specified otherwise. You can still
|
||||
override this option by configuring them.
|
||||
|
||||
IMPORTANT: Do not enable sniffing when using Elastic Cloud, since the nodes are
|
||||
behind a load balancer, Elastic Cloud will take care of everything for you.
|
||||
Take a look https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how[here]
|
||||
to know more.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
cloud: {
|
||||
id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==',
|
||||
},
|
||||
auth: {
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
[[auth-apikey]]
|
||||
==== ApiKey authentication
|
||||
|
||||
You can use the
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/7.x/security-api-create-api-key.html[ApiKey]
|
||||
authentication by passing the `apiKey` parameter via the `auth` option. The
|
||||
`apiKey` parameter can be either a base64 encoded string or an object with the
|
||||
values that you can obtain from the
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/7.x/security-api-create-api-key.html[create api key endpoint].
|
||||
|
||||
NOTE: If you provide both basic authentication credentials and the ApiKey
|
||||
configuration, the ApiKey takes precedence.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
auth: {
|
||||
apiKey: 'base64EncodedKey'
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
auth: {
|
||||
apiKey: {
|
||||
id: 'foo',
|
||||
api_key: 'bar'
|
||||
}
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
[[auth-basic]]
|
||||
==== Basic authentication
|
||||
|
||||
You can provide your credentials by passing the `username` and `password`
|
||||
parameters via the `auth` option.
|
||||
|
||||
NOTE: If you provide both basic authentication credentials and the Api Key
|
||||
configuration, the Api Key will take precedence.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
auth: {
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
Otherwise, you can provide your credentials in the node(s) URL.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://username:password@localhost:9200'
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
[[auth-ssl]]
|
||||
==== SSL configuration
|
||||
|
||||
Without any additional configuration you can specify `https://` node urls, and
|
||||
the certificates used to sign these requests will be verified. To turn off
|
||||
certificate verification, you must specify an `ssl` object in the top level
|
||||
config and set `rejectUnauthorized: false`. The default `ssl` values are the
|
||||
same that Node.js's
|
||||
https://nodejs.org/api/tls.html#tls_tls_connect_options_callback[`tls.connect()`]
|
||||
uses.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
auth: {
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
},
|
||||
ssl: {
|
||||
ca: fs.readFileSync('./cacert.pem'),
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
[discrete]
|
||||
[[client-usage]]
|
||||
=== Usage
|
||||
== Usage
|
||||
|
||||
Using the client is straightforward, it supports all the public APIs of {es},
|
||||
and every method exposes the same signature.
|
||||
@ -192,7 +33,7 @@ client.search({
|
||||
})
|
||||
----
|
||||
|
||||
The returned value of every API call is designed as follows:
|
||||
The returned value of every API call is formed as follows:
|
||||
|
||||
[source,ts]
|
||||
----
|
||||
@ -240,14 +81,11 @@ client.search({
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
==== Aborting a request
|
||||
=== Aborting a request
|
||||
|
||||
If needed, you can abort a running request by calling the `request.abort()`
|
||||
method returned by the API.
|
||||
If needed, you can abort a running request by calling the `request.abort()` method returned by the API.
|
||||
|
||||
CAUTION: If you abort a request, the request will fail with a
|
||||
`RequestAbortedError`.
|
||||
CAUTION: If you abort a request, the request will fail with a `RequestAbortedError`.
|
||||
|
||||
|
||||
[source,js]
|
||||
@ -274,7 +112,6 @@ request.abort()
|
||||
----
|
||||
|
||||
The same behavior is valid for the promise style API as well.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const request = client.search({
|
||||
@ -297,9 +134,7 @@ request.abort()
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
==== Request specific options
|
||||
|
||||
=== Request specific options
|
||||
If needed you can pass request specific options in a second object:
|
||||
|
||||
[source,js]
|
||||
@ -376,51 +211,6 @@ _Default:_ `null`
|
||||
|===
|
||||
|
||||
|
||||
[discrete]
|
||||
[[client-connect-proxy]]
|
||||
=== Connecting through a proxy
|
||||
|
||||
~Added~ ~in~ ~`v7.10.0`~
|
||||
|
||||
If you need to pass through an http(s) proxy for connecting to {es}, the client
|
||||
offers out of the box a handy configuration for helping you with it. Under the
|
||||
hood, it uses the https://github.com/delvedor/hpagent[`hpagent`] module.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
proxy: 'http://localhost:8080'
|
||||
})
|
||||
----
|
||||
|
||||
Basic authentication is supported as well:
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
proxy: 'http:user:pwd@//localhost:8080'
|
||||
})
|
||||
----
|
||||
|
||||
If you are connecting through a not http(s) proxy, such as a `socks5` or `pac`,
|
||||
you can use the `agent` option to configure it.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const SocksProxyAgent = require('socks-proxy-agent')
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
agent () {
|
||||
return new SocksProxyAgent('socks://127.0.0.1:1080')
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
[[client-error-handling]]
|
||||
=== Error handling
|
||||
|
||||
The client exposes a variety of error objects that you can use to enhance your
|
||||
74
index.d.ts
vendored
74
index.d.ts
vendored
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
@ -107,7 +92,6 @@ interface ClientOptions {
|
||||
name?: string | symbol;
|
||||
auth?: BasicAuth | ApiKeyAuth;
|
||||
context?: Context;
|
||||
proxy?: string | URL;
|
||||
cloud?: {
|
||||
id: string;
|
||||
// TODO: remove username and password here in 8
|
||||
@ -433,14 +417,6 @@ declare class Client {
|
||||
clearScroll<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
clearScroll<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.ClearScroll<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
clearScroll<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.ClearScroll<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
close_point_in_time<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.ClosePointInTime<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
close_point_in_time<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
close_point_in_time<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.ClosePointInTime<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
close_point_in_time<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.ClosePointInTime<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
closePointInTime<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.ClosePointInTime<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
closePointInTime<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
closePointInTime<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.ClosePointInTime<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
closePointInTime<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.ClosePointInTime<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
cluster: {
|
||||
allocation_explain<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.ClusterAllocationExplain<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
allocation_explain<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
@ -1680,14 +1656,14 @@ declare class Client {
|
||||
stopDataFrameAnalytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
stopDataFrameAnalytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.MlStopDataFrameAnalytics<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
stopDataFrameAnalytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.MlStopDataFrameAnalytics<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
stop_datafeed<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlStopDatafeed<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
stop_datafeed<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
stop_datafeed<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.MlStopDatafeed<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
stop_datafeed<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.MlStopDatafeed<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
stopDatafeed<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlStopDatafeed<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
stopDatafeed<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
stopDatafeed<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.MlStopDatafeed<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
stopDatafeed<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.MlStopDatafeed<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
stop_datafeed<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.MlStopDatafeed, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
stop_datafeed<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
stop_datafeed<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.MlStopDatafeed, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
stop_datafeed<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.MlStopDatafeed, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
stopDatafeed<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.MlStopDatafeed, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
stopDatafeed<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
stopDatafeed<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.MlStopDatafeed, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
stopDatafeed<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.MlStopDatafeed, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
update_data_frame_analytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.MlUpdateDataFrameAnalytics<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
update_data_frame_analytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
update_data_frame_analytics<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.MlUpdateDataFrameAnalytics<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
@ -1793,14 +1769,6 @@ declare class Client {
|
||||
usage<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.NodesUsage, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
usage<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.NodesUsage, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
}
|
||||
open_point_in_time<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.OpenPointInTime, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
open_point_in_time<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
open_point_in_time<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.OpenPointInTime, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
open_point_in_time<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.OpenPointInTime, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
openPointInTime<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.OpenPointInTime, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
openPointInTime<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
openPointInTime<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.OpenPointInTime, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
openPointInTime<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.OpenPointInTime, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
ping<TResponse = boolean, TContext = Context>(params?: RequestParams.Ping, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
ping<TResponse = boolean, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
ping<TResponse = boolean, TContext = Context>(params: RequestParams.Ping, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
@ -2004,14 +1972,6 @@ declare class Client {
|
||||
changePassword<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
changePassword<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SecurityChangePassword<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
changePassword<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SecurityChangePassword<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
clear_api_key_cache<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityClearApiKeyCache, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
clear_api_key_cache<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
clear_api_key_cache<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SecurityClearApiKeyCache, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
clear_api_key_cache<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SecurityClearApiKeyCache, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
clearApiKeyCache<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityClearApiKeyCache, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
clearApiKeyCache<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
clearApiKeyCache<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SecurityClearApiKeyCache, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
clearApiKeyCache<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SecurityClearApiKeyCache, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
clear_cached_privileges<TResponse = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityClearCachedPrivileges, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
clear_cached_privileges<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
clear_cached_privileges<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SecurityClearCachedPrivileges, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
@ -2156,14 +2116,6 @@ declare class Client {
|
||||
getUserPrivileges<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
getUserPrivileges<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SecurityGetUserPrivileges, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
getUserPrivileges<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SecurityGetUserPrivileges, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
grant_api_key<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityGrantApiKey<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
grant_api_key<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
grant_api_key<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SecurityGrantApiKey<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
grant_api_key<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SecurityGrantApiKey<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
grantApiKey<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityGrantApiKey<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
grantApiKey<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
grantApiKey<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SecurityGrantApiKey<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
grantApiKey<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SecurityGrantApiKey<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
has_privileges<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SecurityHasPrivileges<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
has_privileges<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
has_privileges<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SecurityHasPrivileges<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
@ -2296,10 +2248,6 @@ declare class Client {
|
||||
cleanupRepository<TResponse = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
cleanupRepository<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SnapshotCleanupRepository, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
cleanupRepository<TResponse = Record<string, any>, TContext = Context>(params: RequestParams.SnapshotCleanupRepository, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
clone<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotClone<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
clone<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
clone<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SnapshotClone<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
clone<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SnapshotClone<TRequestBody>, options: TransportRequestOptions, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
create<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params?: RequestParams.SnapshotCreate<TRequestBody>, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>
|
||||
create<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
create<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: RequestParams.SnapshotCreate<TRequestBody>, callback: callbackFn<TResponse, TContext>): TransportRequestCallback
|
||||
|
||||
43
index.js
43
index.js
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
@ -41,24 +26,6 @@ const kEventEmitter = Symbol('elasticsearchjs-event-emitter')
|
||||
|
||||
const ESAPI = require('./api')
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (nodeMajor < 10) {
|
||||
process.emitWarning('You are using a version of Node.js that is currently in EOL. ' +
|
||||
'The support for this version will be dropped in 7.12. ' +
|
||||
'Please refer to https://ela.st/nodejs-support for additional information.',
|
||||
'DeprecationWarning'
|
||||
)
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (nodeMajor >= 10 && nodeMajor < 12) {
|
||||
process.emitWarning('You are using a version of Node.js that will reach EOL in April 2021. ' +
|
||||
'The support for this version will be dropped in 7.13. ' +
|
||||
'Please refer to https://ela.st/nodejs-support for additional information.',
|
||||
'DeprecationWarning'
|
||||
)
|
||||
}
|
||||
|
||||
class Client extends ESAPI {
|
||||
constructor (opts = {}) {
|
||||
super({ ConfigurationError })
|
||||
@ -124,8 +91,7 @@ class Client extends ESAPI {
|
||||
name: 'elasticsearch-js',
|
||||
auth: null,
|
||||
opaqueIdPrefix: null,
|
||||
context: null,
|
||||
proxy: null
|
||||
context: null
|
||||
}, opts)
|
||||
|
||||
this[kInitialOptions] = options
|
||||
@ -144,7 +110,6 @@ class Client extends ESAPI {
|
||||
resurrectStrategy: options.resurrectStrategy,
|
||||
ssl: options.ssl,
|
||||
agent: options.agent,
|
||||
proxy: options.proxy,
|
||||
Connection: options.Connection,
|
||||
auth: options.auth,
|
||||
emit: this[kEventEmitter].emit.bind(this[kEventEmitter]),
|
||||
|
||||
19
index.mjs
19
index.mjs
@ -1,22 +1,3 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import mod from './index.js'
|
||||
|
||||
export default mod
|
||||
|
||||
30
lib/Connection.d.ts
vendored
30
lib/Connection.d.ts
vendored
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
@ -24,13 +9,11 @@ import { inspect, InspectOptions } from 'util'
|
||||
import { Readable as ReadableStream } from 'stream';
|
||||
import { ApiKeyAuth, BasicAuth } from './pool'
|
||||
import * as http from 'http'
|
||||
import * as https from 'https'
|
||||
import * as hpagent from 'hpagent'
|
||||
import { ConnectionOptions as TlsConnectionOptions } from 'tls'
|
||||
|
||||
export declare type agentFn = (opts: ConnectionOptions) => any;
|
||||
export declare type agentFn = () => any;
|
||||
|
||||
export interface ConnectionOptions {
|
||||
interface ConnectionOptions {
|
||||
url: URL;
|
||||
ssl?: TlsConnectionOptions;
|
||||
id?: string;
|
||||
@ -39,7 +22,6 @@ export interface ConnectionOptions {
|
||||
status?: string;
|
||||
roles?: ConnectionRoles;
|
||||
auth?: BasicAuth | ApiKeyAuth;
|
||||
proxy?: string | URL;
|
||||
}
|
||||
|
||||
interface ConnectionRoles {
|
||||
@ -84,7 +66,7 @@ export default class Connection {
|
||||
makeRequest: any
|
||||
_openRequests: number
|
||||
_status: string
|
||||
_agent: http.Agent | https.Agent | hpagent.HttpProxyAgent | hpagent.HttpsProxyAgent
|
||||
_agent: http.Agent
|
||||
constructor(opts?: ConnectionOptions)
|
||||
request(params: RequestOptions, callback: (err: Error | null, response: http.IncomingMessage | null) => void): http.ClientRequest
|
||||
close(): Connection
|
||||
|
||||
@ -1,30 +1,15 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
const assert = require('assert')
|
||||
const { inspect } = require('util')
|
||||
const hpagent = require('hpagent')
|
||||
const http = require('http')
|
||||
const https = require('https')
|
||||
const debug = require('debug')('elasticsearch')
|
||||
const decompressResponse = require('decompress-response')
|
||||
const pump = require('pump')
|
||||
const INVALID_PATH_REGEX = /[^\u0021-\u00ff]/
|
||||
const {
|
||||
@ -52,7 +37,7 @@ class Connection {
|
||||
}
|
||||
|
||||
if (typeof opts.agent === 'function') {
|
||||
this.agent = opts.agent(opts)
|
||||
this.agent = opts.agent()
|
||||
} else if (opts.agent === false) {
|
||||
this.agent = undefined
|
||||
} else {
|
||||
@ -63,16 +48,9 @@ class Connection {
|
||||
maxFreeSockets: 256,
|
||||
scheduling: 'lifo'
|
||||
}, opts.agent)
|
||||
if (opts.proxy) {
|
||||
agentOptions.proxy = opts.proxy
|
||||
this.agent = this.url.protocol === 'http:'
|
||||
? new hpagent.HttpProxyAgent(agentOptions)
|
||||
: new hpagent.HttpsProxyAgent(Object.assign({}, agentOptions, this.ssl))
|
||||
} else {
|
||||
this.agent = this.url.protocol === 'http:'
|
||||
? new http.Agent(agentOptions)
|
||||
: new https.Agent(Object.assign({}, agentOptions, this.ssl))
|
||||
}
|
||||
this.agent = this.url.protocol === 'http:'
|
||||
? new http.Agent(agentOptions)
|
||||
: new https.Agent(Object.assign({}, agentOptions, this.ssl))
|
||||
}
|
||||
|
||||
this.makeRequest = this.url.protocol === 'http:'
|
||||
@ -82,6 +60,7 @@ class Connection {
|
||||
|
||||
request (params, callback) {
|
||||
this._openRequests++
|
||||
var ended = false
|
||||
|
||||
const requestParams = this.buildRequestObject(params)
|
||||
// https://github.com/nodejs/node/commit/b961d9fd83
|
||||
@ -94,38 +73,53 @@ class Connection {
|
||||
debug('Starting a new request', params)
|
||||
const request = this.makeRequest(requestParams)
|
||||
|
||||
const onResponse = response => {
|
||||
cleanListeners()
|
||||
this._openRequests--
|
||||
callback(null, response)
|
||||
}
|
||||
// listen for the response event
|
||||
// TODO: handle redirects?
|
||||
request.on('response', response => {
|
||||
/* istanbul ignore else */
|
||||
if (ended === false) {
|
||||
ended = true
|
||||
this._openRequests--
|
||||
|
||||
const onTimeout = () => {
|
||||
cleanListeners()
|
||||
this._openRequests--
|
||||
request.once('error', () => {}) // we need to catch the request aborted error
|
||||
request.abort()
|
||||
callback(new TimeoutError('Request timed out', params), null)
|
||||
}
|
||||
if (params.asStream === true) {
|
||||
callback(null, response)
|
||||
} else {
|
||||
callback(null, decompressResponse(response))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const onError = err => {
|
||||
cleanListeners()
|
||||
this._openRequests--
|
||||
callback(new ConnectionError(err.message), null)
|
||||
}
|
||||
// handles request timeout
|
||||
request.on('timeout', () => {
|
||||
/* istanbul ignore else */
|
||||
if (ended === false) {
|
||||
ended = true
|
||||
this._openRequests--
|
||||
request.abort()
|
||||
callback(new TimeoutError('Request timed out', params), null)
|
||||
}
|
||||
})
|
||||
|
||||
const onAbort = () => {
|
||||
cleanListeners()
|
||||
request.once('error', () => {}) // we need to catch the request aborted error
|
||||
// handles request error
|
||||
request.on('error', err => {
|
||||
/* istanbul ignore else */
|
||||
if (ended === false) {
|
||||
ended = true
|
||||
this._openRequests--
|
||||
callback(new ConnectionError(err.message), null)
|
||||
}
|
||||
})
|
||||
|
||||
// updates the ended state
|
||||
request.on('abort', () => {
|
||||
debug('Request aborted', params)
|
||||
this._openRequests--
|
||||
callback(new RequestAbortedError(), null)
|
||||
}
|
||||
|
||||
request.on('response', onResponse)
|
||||
request.on('timeout', onTimeout)
|
||||
request.on('error', onError)
|
||||
request.on('abort', onAbort)
|
||||
/* istanbul ignore else */
|
||||
if (ended === false) {
|
||||
ended = true
|
||||
this._openRequests--
|
||||
callback(new RequestAbortedError(), null)
|
||||
}
|
||||
})
|
||||
|
||||
// Disables the Nagle algorithm
|
||||
request.setNoDelay(true)
|
||||
@ -134,8 +128,8 @@ class Connection {
|
||||
if (isStream(params.body) === true) {
|
||||
pump(params.body, request, err => {
|
||||
/* istanbul ignore if */
|
||||
if (err != null) {
|
||||
cleanListeners()
|
||||
if (err != null && /* istanbul ignore next */ ended === false) {
|
||||
ended = true
|
||||
this._openRequests--
|
||||
callback(err, null)
|
||||
}
|
||||
@ -145,13 +139,6 @@ class Connection {
|
||||
}
|
||||
|
||||
return request
|
||||
|
||||
function cleanListeners () {
|
||||
request.removeListener('response', onResponse)
|
||||
request.removeListener('timeout', onTimeout)
|
||||
request.removeListener('error', onError)
|
||||
request.removeListener('abort', onAbort)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: write a better closing logic
|
||||
|
||||
21
lib/Helpers.d.ts
vendored
21
lib/Helpers.d.ts
vendored
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { Readable as ReadableStream } from 'stream'
|
||||
import { TransportRequestOptions, ApiError, ApiResponse, RequestBody, Context } from './Transport'
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
@ -104,15 +89,13 @@ class Helpers {
|
||||
}
|
||||
|
||||
while (response.body.hits && response.body.hits.hits.length > 0) {
|
||||
// scroll id is always present in the response, but it might
|
||||
// change over time based on the number of shards
|
||||
scroll_id = response.body._scroll_id
|
||||
response.clear = clear
|
||||
addDocumentsGetter(response)
|
||||
|
||||
yield response
|
||||
|
||||
if (stop === true) {
|
||||
if (!scroll_id || stop === true) {
|
||||
break
|
||||
}
|
||||
|
||||
@ -129,10 +112,6 @@ class Helpers {
|
||||
throw new ResponseError(response)
|
||||
}
|
||||
}
|
||||
|
||||
if (stop === false) {
|
||||
await clear()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
21
lib/Serializer.d.ts
vendored
21
lib/Serializer.d.ts
vendored
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
export default class Serializer {
|
||||
serialize(object: any): string;
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
21
lib/Transport.d.ts
vendored
21
lib/Transport.d.ts
vendored
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { Readable as ReadableStream } from 'stream';
|
||||
import { ConnectionPool, CloudConnectionPool } from './pool';
|
||||
|
||||
245
lib/Transport.js
245
lib/Transport.js
@ -1,27 +1,12 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
const debug = require('debug')('elasticsearch')
|
||||
const os = require('os')
|
||||
const { gzip, unzip, createGzip } = require('zlib')
|
||||
const { gzip, createGzip } = require('zlib')
|
||||
const ms = require('ms')
|
||||
const {
|
||||
ConnectionError,
|
||||
@ -174,40 +159,37 @@ class Transport {
|
||||
request = meta.connection.request(params, onResponse)
|
||||
}
|
||||
|
||||
const onConnectionError = (err) => {
|
||||
if (err.name !== 'RequestAbortedError') {
|
||||
// if there is an error in the connection
|
||||
// let's mark the connection as dead
|
||||
this.connectionPool.markDead(meta.connection)
|
||||
|
||||
if (this.sniffOnConnectionFault === true) {
|
||||
this.sniff({
|
||||
reason: Transport.sniffReasons.SNIFF_ON_CONNECTION_FAULT,
|
||||
requestId: meta.request.id
|
||||
})
|
||||
}
|
||||
|
||||
// retry logic
|
||||
if (meta.attempts < maxRetries) {
|
||||
meta.attempts++
|
||||
debug(`Retrying request, there are still ${maxRetries - meta.attempts} attempts`, params)
|
||||
makeRequest()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
err.meta = result
|
||||
this.emit('response', err, result)
|
||||
return callback(err, result)
|
||||
}
|
||||
|
||||
const onResponse = (err, response) => {
|
||||
if (err !== null) {
|
||||
return onConnectionError(err)
|
||||
if (err.name !== 'RequestAbortedError') {
|
||||
// if there is an error in the connection
|
||||
// let's mark the connection as dead
|
||||
this.connectionPool.markDead(meta.connection)
|
||||
|
||||
if (this.sniffOnConnectionFault === true) {
|
||||
this.sniff({
|
||||
reason: Transport.sniffReasons.SNIFF_ON_CONNECTION_FAULT,
|
||||
requestId: meta.request.id
|
||||
})
|
||||
}
|
||||
|
||||
// retry logic
|
||||
if (meta.attempts < maxRetries) {
|
||||
meta.attempts++
|
||||
debug(`Retrying request, there are still ${maxRetries - meta.attempts} attempts`, params)
|
||||
makeRequest()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
err.meta = result
|
||||
this.emit('response', err, result)
|
||||
return callback(err, result)
|
||||
}
|
||||
|
||||
result.statusCode = response.statusCode
|
||||
result.headers = response.headers
|
||||
const { statusCode, headers } = response
|
||||
result.statusCode = statusCode
|
||||
result.headers = headers
|
||||
|
||||
if (options.asStream === true) {
|
||||
result.body = response
|
||||
@ -216,109 +198,74 @@ class Transport {
|
||||
return
|
||||
}
|
||||
|
||||
const contentEncoding = (result.headers['content-encoding'] || '').toLowerCase()
|
||||
const isCompressed = contentEncoding.indexOf('gzip') > -1 || contentEncoding.indexOf('deflate') > -1
|
||||
// if the response is compressed, we must handle it
|
||||
// as buffer for allowing decompression later
|
||||
let payload = isCompressed ? [] : ''
|
||||
const onData = isCompressed
|
||||
? chunk => { payload.push(chunk) }
|
||||
: chunk => { payload += chunk }
|
||||
const onEnd = err => {
|
||||
response.removeListener('data', onData)
|
||||
response.removeListener('end', onEnd)
|
||||
response.removeListener('error', onEnd)
|
||||
response.removeListener('aborted', onAbort)
|
||||
|
||||
if (err) {
|
||||
return onConnectionError(new ConnectionError(err.message))
|
||||
}
|
||||
|
||||
if (isCompressed) {
|
||||
unzip(Buffer.concat(payload), onBody)
|
||||
} else {
|
||||
onBody(null, payload)
|
||||
}
|
||||
}
|
||||
|
||||
const onAbort = () => {
|
||||
response.destroy()
|
||||
onEnd(new Error('Response aborted while reading the body'))
|
||||
}
|
||||
|
||||
if (!isCompressed) {
|
||||
response.setEncoding('utf8')
|
||||
}
|
||||
response.on('data', onData)
|
||||
response.on('error', onEnd)
|
||||
response.on('end', onEnd)
|
||||
response.on('aborted', onAbort)
|
||||
}
|
||||
|
||||
const onBody = (err, payload) => {
|
||||
if (err) {
|
||||
this.emit('response', err, result)
|
||||
return callback(err, result)
|
||||
}
|
||||
if (Buffer.isBuffer(payload)) {
|
||||
payload = payload.toString()
|
||||
}
|
||||
const isHead = params.method === 'HEAD'
|
||||
// we should attempt the payload deserialization only if:
|
||||
// - a `content-type` is defined and is equal to `application/json`
|
||||
// - the request is not a HEAD request
|
||||
// - the payload is not an empty string
|
||||
if (result.headers['content-type'] !== undefined &&
|
||||
result.headers['content-type'].indexOf('application/json') > -1 &&
|
||||
isHead === false &&
|
||||
payload !== ''
|
||||
) {
|
||||
try {
|
||||
result.body = this.serializer.deserialize(payload)
|
||||
} catch (err) {
|
||||
this.emit('response', err, result)
|
||||
return callback(err, result)
|
||||
}
|
||||
} else {
|
||||
// cast to boolean if the request method was HEAD
|
||||
result.body = isHead === true ? true : payload
|
||||
}
|
||||
|
||||
// we should ignore the statusCode if the user has configured the `ignore` field with
|
||||
// the statusCode we just got or if the request method is HEAD and the statusCode is 404
|
||||
const ignoreStatusCode = (Array.isArray(options.ignore) && options.ignore.indexOf(result.statusCode) > -1) ||
|
||||
(isHead === true && result.statusCode === 404)
|
||||
|
||||
if (ignoreStatusCode === false &&
|
||||
(result.statusCode === 502 || result.statusCode === 503 || result.statusCode === 504)) {
|
||||
// if the statusCode is 502/3/4 we should run our retry strategy
|
||||
// and mark the connection as dead
|
||||
this.connectionPool.markDead(meta.connection)
|
||||
// retry logic (we shoukd not retry on "429 - Too Many Requests")
|
||||
if (meta.attempts < maxRetries && result.statusCode !== 429) {
|
||||
meta.attempts++
|
||||
debug(`Retrying request, there are still ${maxRetries - meta.attempts} attempts`, params)
|
||||
makeRequest()
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// everything has worked as expected, let's mark
|
||||
// the connection as alive (or confirm it)
|
||||
this.connectionPool.markAlive(meta.connection)
|
||||
}
|
||||
|
||||
if (ignoreStatusCode === false && result.statusCode >= 400) {
|
||||
const error = new ResponseError(result)
|
||||
var payload = ''
|
||||
// collect the payload
|
||||
response.setEncoding('utf8')
|
||||
response.on('data', chunk => { payload += chunk })
|
||||
/* istanbul ignore next */
|
||||
response.on('error', err => {
|
||||
const error = new ConnectionError(err.message, result)
|
||||
this.emit('response', error, result)
|
||||
callback(error, result)
|
||||
} else {
|
||||
// cast to boolean if the request method was HEAD
|
||||
if (isHead === true && result.statusCode === 404) {
|
||||
result.body = false
|
||||
})
|
||||
response.on('end', () => {
|
||||
const isHead = params.method === 'HEAD'
|
||||
// we should attempt the payload deserialization only if:
|
||||
// - a `content-type` is defined and is equal to `application/json`
|
||||
// - the request is not a HEAD request
|
||||
// - the payload is not an empty string
|
||||
if (headers['content-type'] !== undefined &&
|
||||
headers['content-type'].indexOf('application/json') > -1 &&
|
||||
isHead === false &&
|
||||
payload !== ''
|
||||
) {
|
||||
try {
|
||||
result.body = this.serializer.deserialize(payload)
|
||||
} catch (err) {
|
||||
this.emit('response', err, result)
|
||||
return callback(err, result)
|
||||
}
|
||||
} else {
|
||||
// cast to boolean if the request method was HEAD
|
||||
result.body = isHead === true ? true : payload
|
||||
}
|
||||
this.emit('response', null, result)
|
||||
callback(null, result)
|
||||
}
|
||||
|
||||
// we should ignore the statusCode if the user has configured the `ignore` field with
|
||||
// the statusCode we just got or if the request method is HEAD and the statusCode is 404
|
||||
const ignoreStatusCode = (Array.isArray(options.ignore) && options.ignore.indexOf(statusCode) > -1) ||
|
||||
(isHead === true && statusCode === 404)
|
||||
|
||||
if (ignoreStatusCode === false &&
|
||||
(statusCode === 502 || statusCode === 503 || statusCode === 504)) {
|
||||
// if the statusCode is 502/3/4 we should run our retry strategy
|
||||
// and mark the connection as dead
|
||||
this.connectionPool.markDead(meta.connection)
|
||||
// retry logic (we shoukd not retry on "429 - Too Many Requests")
|
||||
if (meta.attempts < maxRetries && statusCode !== 429) {
|
||||
meta.attempts++
|
||||
debug(`Retrying request, there are still ${maxRetries - meta.attempts} attempts`, params)
|
||||
makeRequest()
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// everything has worked as expected, let's mark
|
||||
// the connection as alive (or confirm it)
|
||||
this.connectionPool.markAlive(meta.connection)
|
||||
}
|
||||
|
||||
if (ignoreStatusCode === false && statusCode >= 400) {
|
||||
const error = new ResponseError(result)
|
||||
this.emit('response', error, result)
|
||||
callback(error, result)
|
||||
} else {
|
||||
// cast to boolean if the request method was HEAD
|
||||
if (isHead === true && statusCode === 404) {
|
||||
result.body = false
|
||||
}
|
||||
this.emit('response', null, result)
|
||||
callback(null, result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const headers = Object.assign({}, this.headers, lowerCaseHeaders(options.headers))
|
||||
|
||||
21
lib/errors.d.ts
vendored
21
lib/errors.d.ts
vendored
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { ApiResponse, Context } from './Transport'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
@ -35,7 +20,6 @@ class BaseConnectionPool {
|
||||
this.auth = opts.auth || null
|
||||
this._ssl = opts.ssl
|
||||
this._agent = opts.agent
|
||||
this._proxy = opts.proxy || null
|
||||
}
|
||||
|
||||
getConnection () {
|
||||
@ -70,8 +54,6 @@ class BaseConnectionPool {
|
||||
if (opts.ssl == null) opts.ssl = this._ssl
|
||||
/* istanbul ignore else */
|
||||
if (opts.agent == null) opts.agent = this._agent
|
||||
/* istanbul ignore else */
|
||||
if (opts.proxy == null) opts.proxy = this._proxy
|
||||
|
||||
const connection = new this.Connection(opts)
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
23
lib/pool/index.d.ts
vendored
23
lib/pool/index.d.ts
vendored
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
@ -27,7 +12,6 @@ import { nodeFilterFn, nodeSelectorFn } from '../Transport';
|
||||
interface BaseConnectionPoolOptions {
|
||||
ssl?: SecureContextOptions;
|
||||
agent?: AgentOptions;
|
||||
proxy?: string | URL;
|
||||
auth?: BasicAuth | ApiKeyAuth;
|
||||
emit: (event: string | symbol, ...args: any[]) => boolean;
|
||||
Connection: typeof Connection;
|
||||
@ -84,7 +68,6 @@ declare class BaseConnectionPool {
|
||||
emit: (event: string | symbol, ...args: any[]) => boolean;
|
||||
_ssl: SecureContextOptions | null;
|
||||
_agent: AgentOptions | null;
|
||||
_proxy: string | URL;
|
||||
auth: BasicAuth | ApiKeyAuth;
|
||||
Connection: typeof Connection;
|
||||
constructor(opts?: BaseConnectionPoolOptions);
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
"./": "./"
|
||||
},
|
||||
"homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html",
|
||||
"version": "7.10.0",
|
||||
"version": "7.9.1",
|
||||
"keywords": [
|
||||
"elasticsearch",
|
||||
"elastic",
|
||||
@ -60,7 +60,6 @@
|
||||
"minimist": "^1.2.0",
|
||||
"ora": "^3.4.0",
|
||||
"pretty-hrtime": "^1.0.3",
|
||||
"proxy": "^1.0.2",
|
||||
"rimraf": "^2.6.3",
|
||||
"semver": "^6.0.0",
|
||||
"simple-git": "^1.110.0",
|
||||
@ -75,7 +74,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "^4.1.1",
|
||||
"hpagent": "^0.1.1",
|
||||
"decompress-response": "^4.2.0",
|
||||
"ms": "^2.1.1",
|
||||
"pump": "^3.0.0",
|
||||
"secure-json-parse": "^2.1.0"
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
|
||||
@ -456,9 +441,9 @@ function genBody (api, methods, body) {
|
||||
return 'bulkBody: body,'
|
||||
}
|
||||
if (body === null && bodyMethod) {
|
||||
return 'body: \'\','
|
||||
return `body: '',`
|
||||
} else if (bodyMethod) {
|
||||
return 'body: body || \'\','
|
||||
return `body: body || '',`
|
||||
} else {
|
||||
return 'body: null,'
|
||||
}
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
@ -111,7 +96,6 @@ function generateDocs (common, spec) {
|
||||
|
||||
function commonParameters (spec) {
|
||||
var doc = dedent`
|
||||
[discrete]
|
||||
=== Common parameters
|
||||
Parameters that are accepted by all API endpoints.
|
||||
|
||||
@ -211,7 +195,6 @@ function generateApiDoc (spec) {
|
||||
: `*Stability:* ${spec[name].stability}`
|
||||
|
||||
var doc = dedent`
|
||||
[discrete]
|
||||
=== ${camelify(name)}
|
||||
${stability}
|
||||
[source,ts]
|
||||
@ -239,7 +222,7 @@ function generateApiDoc (spec) {
|
||||
acc += ` +\n_Default:_ ${'`' + val.default + '`'}`
|
||||
}
|
||||
if (val.deprecated) {
|
||||
acc += ' +\n\nWARNING: This parameter has been deprecated.'
|
||||
acc += ` +\n\nWARNING: This parameter has been deprecated.`
|
||||
}
|
||||
return acc + '\n\n'
|
||||
}, '')
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
/* eslint-disable no-template-curly-in-string */
|
||||
|
||||
@ -173,24 +158,9 @@ function genFactory (folder, paths, namespaces) {
|
||||
}
|
||||
|
||||
const fn = dedent`
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
@ -33,24 +18,9 @@ const ndjsonApiKey = ndjsonApi
|
||||
|
||||
function generate (version, api) {
|
||||
const release = semver.valid(version) ? semver.major(version) : version
|
||||
var types = `/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
var types = `// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { RequestBody, RequestNDBody } from '../lib/Transport'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,149 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
// We are using self-signed certificates
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0
|
||||
|
||||
const { test } = require('tap')
|
||||
const { Client } = require('../../index')
|
||||
const {
|
||||
buildProxy: {
|
||||
createProxy,
|
||||
createSecureProxy,
|
||||
createServer,
|
||||
createSecureServer
|
||||
}
|
||||
} = require('../utils')
|
||||
|
||||
test('http-http proxy support', async t => {
|
||||
const server = await createServer()
|
||||
const proxy = await createProxy()
|
||||
server.on('request', (req, res) => {
|
||||
t.strictEqual(req.url, '/_cluster/health')
|
||||
res.setHeader('content-type', 'application/json')
|
||||
res.end(JSON.stringify({ hello: 'world' }))
|
||||
})
|
||||
|
||||
const client = new Client({
|
||||
node: `http://${server.address().address}:${server.address().port}`,
|
||||
proxy: `http://${proxy.address().address}:${proxy.address().port}`
|
||||
})
|
||||
|
||||
const response = await client.cluster.health()
|
||||
t.deepEqual(response.body, { hello: 'world' })
|
||||
|
||||
server.close()
|
||||
proxy.close()
|
||||
})
|
||||
|
||||
test('http-https proxy support', async t => {
|
||||
const server = await createSecureServer()
|
||||
const proxy = await createProxy()
|
||||
server.on('request', (req, res) => {
|
||||
t.strictEqual(req.url, '/_cluster/health')
|
||||
res.setHeader('content-type', 'application/json')
|
||||
res.end(JSON.stringify({ hello: 'world' }))
|
||||
})
|
||||
|
||||
const client = new Client({
|
||||
node: `https://${server.address().address}:${server.address().port}`,
|
||||
proxy: `http://${proxy.address().address}:${proxy.address().port}`
|
||||
})
|
||||
|
||||
const response = await client.cluster.health()
|
||||
t.deepEqual(response.body, { hello: 'world' })
|
||||
|
||||
server.close()
|
||||
proxy.close()
|
||||
})
|
||||
|
||||
test('https-http proxy support', async t => {
|
||||
const server = await createServer()
|
||||
const proxy = await createSecureProxy()
|
||||
server.on('request', (req, res) => {
|
||||
t.strictEqual(req.url, '/_cluster/health')
|
||||
res.setHeader('content-type', 'application/json')
|
||||
res.end(JSON.stringify({ hello: 'world' }))
|
||||
})
|
||||
|
||||
const client = new Client({
|
||||
node: `http://${server.address().address}:${server.address().port}`,
|
||||
proxy: `https://${proxy.address().address}:${proxy.address().port}`
|
||||
})
|
||||
|
||||
const response = await client.cluster.health()
|
||||
t.deepEqual(response.body, { hello: 'world' })
|
||||
|
||||
server.close()
|
||||
proxy.close()
|
||||
})
|
||||
|
||||
test('https-https proxy support', async t => {
|
||||
const server = await createSecureServer()
|
||||
const proxy = await createSecureProxy()
|
||||
server.on('request', (req, res) => {
|
||||
t.strictEqual(req.url, '/_cluster/health')
|
||||
res.setHeader('content-type', 'application/json')
|
||||
res.end(JSON.stringify({ hello: 'world' }))
|
||||
})
|
||||
|
||||
const client = new Client({
|
||||
node: `https://${server.address().address}:${server.address().port}`,
|
||||
proxy: `https://${proxy.address().address}:${proxy.address().port}`
|
||||
})
|
||||
|
||||
const response = await client.cluster.health()
|
||||
t.deepEqual(response.body, { hello: 'world' })
|
||||
|
||||
server.close()
|
||||
proxy.close()
|
||||
})
|
||||
|
||||
test('http basic authentication', async t => {
|
||||
const server = await createServer()
|
||||
const proxy = await createProxy()
|
||||
server.on('request', (req, res) => {
|
||||
t.strictEqual(req.url, '/_cluster/health')
|
||||
res.setHeader('content-type', 'application/json')
|
||||
res.end(JSON.stringify({ hello: 'world' }))
|
||||
})
|
||||
|
||||
proxy.authenticate = function (req, fn) {
|
||||
fn(null, req.headers['proxy-authorization'] === `Basic ${Buffer.from('hello:world').toString('base64')}`)
|
||||
}
|
||||
|
||||
const client = new Client({
|
||||
node: `http://${server.address().address}:${server.address().port}`,
|
||||
proxy: `http://hello:world@${proxy.address().address}:${proxy.address().port}`
|
||||
})
|
||||
|
||||
const response = await client.cluster.health()
|
||||
t.deepEqual(response.body, { hello: 'world' })
|
||||
|
||||
server.close()
|
||||
proxy.close()
|
||||
})
|
||||
|
||||
test('https basic authentication', async t => {
|
||||
const server = await createSecureServer()
|
||||
const proxy = await createProxy()
|
||||
server.on('request', (req, res) => {
|
||||
t.strictEqual(req.url, '/_cluster/health')
|
||||
res.setHeader('content-type', 'application/json')
|
||||
res.end(JSON.stringify({ hello: 'world' }))
|
||||
})
|
||||
|
||||
proxy.authenticate = function (req, fn) {
|
||||
fn(null, req.headers['proxy-authorization'] === `Basic ${Buffer.from('hello:world').toString('base64')}`)
|
||||
}
|
||||
|
||||
const client = new Client({
|
||||
node: `https://${server.address().address}:${server.address().port}`,
|
||||
proxy: `http://hello:world@${proxy.address().address}:${proxy.address().port}`
|
||||
})
|
||||
|
||||
const response = await client.cluster.health()
|
||||
t.deepEqual(response.body, { hello: 'world' })
|
||||
|
||||
server.close()
|
||||
proxy.close()
|
||||
})
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
@ -84,8 +69,7 @@ test('Should update the connection pool', t => {
|
||||
ml: false
|
||||
},
|
||||
ssl: null,
|
||||
agent: null,
|
||||
proxy: null
|
||||
agent: null
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,29 +1,9 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
process.on('unhandledRejection', function (err) {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
const { writeFileSync, readFileSync, accessSync, mkdirSync, readdirSync, statSync } = require('fs')
|
||||
const { join, sep } = require('path')
|
||||
const yaml = require('js-yaml')
|
||||
@ -103,12 +83,6 @@ const xPackBlackList = {
|
||||
'transforms_stats.yml': ['*'],
|
||||
'transforms_stats_continuous.yml': ['*'],
|
||||
'transforms_update.yml': ['*'],
|
||||
// js does not support ulongs
|
||||
'unsigned_long/10_basic.yml': ['*'],
|
||||
'unsigned_long/20_null_value.yml': ['*'],
|
||||
'unsigned_long/30_multi_fields.yml': ['*'],
|
||||
'unsigned_long/40_different_numeric.yml': ['*'],
|
||||
'unsigned_long/50_script_values.yml': ['*'],
|
||||
// docker issue?
|
||||
'watcher/execute_watch/60_http_input.yml': ['*'],
|
||||
// the checks are correct, but for some reason the test is failing on js side
|
||||
@ -208,11 +182,8 @@ async function start ({ client, isXPack }) {
|
||||
const tests = data
|
||||
.split('\n---\n')
|
||||
.map(s => s.trim())
|
||||
// empty strings
|
||||
.filter(Boolean)
|
||||
.map(parse)
|
||||
// null values
|
||||
.filter(Boolean)
|
||||
|
||||
// get setup and teardown if present
|
||||
var setupTest = null
|
||||
@ -296,9 +267,8 @@ function now () {
|
||||
}
|
||||
|
||||
function parse (data) {
|
||||
const schema = yaml.Schema.create(yaml.CORE_SCHEMA, [])
|
||||
try {
|
||||
var doc = yaml.safeLoad(data, { schema })
|
||||
var doc = yaml.safeLoad(data)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
return
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
@ -279,26 +264,20 @@ function build (opts = {}) {
|
||||
// eg: 'Basic ${auth}' we search the stahed value 'auth'
|
||||
// and the resulting value will be 'Basic valueOfAuth'
|
||||
if (typeof val === 'string' && val.includes('${')) {
|
||||
while (obj[key].includes('${')) {
|
||||
const val = obj[key]
|
||||
const start = val.indexOf('${')
|
||||
const end = val.indexOf('}', val.indexOf('${'))
|
||||
const stashedKey = val.slice(start + 2, end)
|
||||
const stashed = stash.get(stashedKey)
|
||||
obj[key] = val.slice(0, start) + stashed + val.slice(end + 1)
|
||||
}
|
||||
const start = val.indexOf('${')
|
||||
const end = val.indexOf('}', val.indexOf('${'))
|
||||
const stashedKey = val.slice(start + 2, end)
|
||||
const stashed = stash.get(stashedKey)
|
||||
obj[key] = val.slice(0, start) + stashed + val.slice(end + 1)
|
||||
continue
|
||||
}
|
||||
// handle json strings, eg: '{"hello":"$world"}'
|
||||
if (typeof val === 'string' && val.includes('"$')) {
|
||||
while (obj[key].includes('"$')) {
|
||||
const val = obj[key]
|
||||
const start = val.indexOf('"$')
|
||||
const end = val.indexOf('"', start + 1)
|
||||
const stashedKey = val.slice(start + 2, end)
|
||||
const stashed = '"' + stash.get(stashedKey) + '"'
|
||||
obj[key] = val.slice(0, start) + stashed + val.slice(end + 1)
|
||||
}
|
||||
const start = val.indexOf('"$')
|
||||
const end = val.indexOf('"', start + 1)
|
||||
const stashedKey = val.slice(start + 2, end)
|
||||
const stashed = '"' + stash.get(stashedKey) + '"'
|
||||
obj[key] = val.slice(0, start) + stashed + val.slice(end + 1)
|
||||
continue
|
||||
}
|
||||
// if the key value is a string, and the string includes '$'
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { expectType, expectError } from 'tsd'
|
||||
import { Readable as ReadableStream } from 'stream';
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { expectType } from 'tsd'
|
||||
import { TransportRequestCallback, Context } from '../../lib/Transport'
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { URL } from 'url'
|
||||
import { expectType, expectError } from 'tsd'
|
||||
@ -692,28 +677,3 @@ expectError<errors.ConfigurationError>(
|
||||
context: 'hello world'
|
||||
})
|
||||
)
|
||||
|
||||
/**
|
||||
* `proxy` option
|
||||
*/
|
||||
expectType<Client>(
|
||||
new Client({
|
||||
node: 'http://localhost:9200',
|
||||
proxy: 'http://localhost:8080'
|
||||
})
|
||||
)
|
||||
|
||||
expectType<Client>(
|
||||
new Client({
|
||||
node: 'http://localhost:9200',
|
||||
proxy: new URL('http://localhost:8080')
|
||||
})
|
||||
)
|
||||
|
||||
expectError<errors.ConfigurationError>(
|
||||
// @ts-expect-error
|
||||
new Client({
|
||||
node: 'http://localhost:9200',
|
||||
proxy: 42
|
||||
})
|
||||
)
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { expectType } from 'tsd'
|
||||
import { Client, ApiError, ApiResponse, RequestEvent, ResurrectEvent } from '../../'
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { expectType, expectAssignable } from 'tsd'
|
||||
import { URL } from 'url'
|
||||
|
||||
@ -1,54 +1,26 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { expectType } from 'tsd'
|
||||
import { URL } from 'url'
|
||||
import { Connection } from '../../'
|
||||
import { ConnectionOptions } from '../../lib/Connection'
|
||||
|
||||
{
|
||||
const conn = new Connection({
|
||||
url: new URL('http://localhost:9200'),
|
||||
ssl: { ca: 'string' },
|
||||
id: 'id',
|
||||
headers: {},
|
||||
agent: { keepAlive: false },
|
||||
status: 'alive',
|
||||
roles: { master: true },
|
||||
auth: { username: 'username', password: 'password' }
|
||||
})
|
||||
const conn = new Connection({
|
||||
url: new URL('http://localhost:9200'),
|
||||
ssl: { ca: 'string' },
|
||||
id: 'id',
|
||||
headers: {},
|
||||
agent: { keepAlive: false },
|
||||
status: 'alive',
|
||||
roles: { master: true },
|
||||
auth: { username: 'username', password: 'password' }
|
||||
})
|
||||
|
||||
expectType<Connection>(conn)
|
||||
expectType<URL>(conn.url)
|
||||
expectType<string>(conn.id)
|
||||
expectType<Record<string, any>>(conn.headers)
|
||||
expectType<number>(conn.deadCount)
|
||||
expectType<number>(conn.resurrectTimeout)
|
||||
expectType<string>(conn.status)
|
||||
}
|
||||
|
||||
{
|
||||
const conn = new Connection({
|
||||
url: new URL('http://localhost:9200'),
|
||||
agent (opts) {
|
||||
expectType<ConnectionOptions>(opts)
|
||||
return 'the agent'
|
||||
}
|
||||
})
|
||||
}
|
||||
expectType<Connection>(conn)
|
||||
expectType<URL>(conn.url)
|
||||
expectType<string>(conn.id)
|
||||
expectType<Record<string, any>>(conn.headers)
|
||||
expectType<number>(conn.deadCount)
|
||||
expectType<number>(conn.resurrectTimeout)
|
||||
expectType<string>(conn.status)
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { expectType } from 'tsd'
|
||||
import { errors, ApiResponse, Connection } from '../../'
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { expectType, expectError, expectAssignable } from 'tsd'
|
||||
import { Client } from '../../'
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { expectType, expectNotType, expectError } from 'tsd'
|
||||
import { Client, RequestEvent, ResurrectEvent, ApiError, ApiResponse } from '../../'
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { expectType } from 'tsd'
|
||||
import { Serializer } from '../../'
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
import { Readable as ReadableStream } from 'stream';
|
||||
import { expectType, expectAssignable, expectError } from 'tsd'
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,27 +1,12 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
const { test } = require('tap')
|
||||
const { URL } = require('url')
|
||||
const { Client, ConnectionPool, Transport, errors } = require('../../index')
|
||||
const { Client, ConnectionPool, Transport } = require('../../index')
|
||||
const { CloudConnectionPool } = require('../../lib/pool')
|
||||
const { buildServer } = require('../utils')
|
||||
|
||||
@ -861,41 +846,6 @@ test('Elastic cloud config', t => {
|
||||
t.deepEqual(pool._ssl, { secureProtocol: 'TLSv1_2_method' })
|
||||
})
|
||||
|
||||
t.test('Without kibana component', t => {
|
||||
t.plan(5)
|
||||
const client = new Client({
|
||||
cloud: {
|
||||
// 'localhost$abcd$'
|
||||
id: 'name:bG9jYWxob3N0JGFiY2Qk',
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
}
|
||||
})
|
||||
|
||||
const pool = client.connectionPool
|
||||
t.ok(pool instanceof CloudConnectionPool)
|
||||
t.match(pool.connections.find(c => c.id === 'https://abcd.localhost/'), {
|
||||
url: new URL('https://elastic:changeme@abcd.localhost'),
|
||||
id: 'https://abcd.localhost/',
|
||||
headers: {
|
||||
authorization: 'Basic ' + Buffer.from('elastic:changeme').toString('base64')
|
||||
},
|
||||
ssl: { secureProtocol: 'TLSv1_2_method' },
|
||||
deadCount: 0,
|
||||
resurrectTimeout: 0,
|
||||
roles: {
|
||||
master: true,
|
||||
data: true,
|
||||
ingest: true,
|
||||
ml: false
|
||||
}
|
||||
})
|
||||
|
||||
t.strictEqual(client.transport.compression, 'gzip')
|
||||
t.strictEqual(client.transport.suggestCompression, true)
|
||||
t.deepEqual(pool._ssl, { secureProtocol: 'TLSv1_2_method' })
|
||||
})
|
||||
|
||||
t.test('Auth as separate option', t => {
|
||||
t.plan(5)
|
||||
const client = new Client({
|
||||
@ -1084,8 +1034,8 @@ test('Correctly handles the same header cased differently', t => {
|
||||
t.plan(4)
|
||||
|
||||
function handler (req, res) {
|
||||
t.strictEqual(req.headers.authorization, 'Basic foobar')
|
||||
t.strictEqual(req.headers.foo, 'baz')
|
||||
t.strictEqual(req.headers['authorization'], 'Basic foobar')
|
||||
t.strictEqual(req.headers['foo'], 'baz')
|
||||
res.setHeader('Content-Type', 'application/json;utf=8')
|
||||
res.end(JSON.stringify({ hello: 'world' }))
|
||||
}
|
||||
@ -1191,55 +1141,3 @@ test('name property as symbol', t => {
|
||||
|
||||
t.strictEqual(client.name, symbol)
|
||||
})
|
||||
|
||||
// The nodejs http agent will try to wait for the whole
|
||||
// body to arrive before closing the request, so this
|
||||
// test might take some time.
|
||||
test('Bad content length', t => {
|
||||
t.plan(3)
|
||||
|
||||
let count = 0
|
||||
function handler (req, res) {
|
||||
count += 1
|
||||
const body = JSON.stringify({ hello: 'world' })
|
||||
res.setHeader('Content-Type', 'application/json;utf=8')
|
||||
res.setHeader('Content-Length', body.length + '')
|
||||
res.end(body.slice(0, -5))
|
||||
}
|
||||
|
||||
buildServer(handler, ({ port }, server) => {
|
||||
const client = new Client({ node: `http://localhost:${port}`, maxRetries: 1 })
|
||||
client.info((err, { body }) => {
|
||||
t.ok(err instanceof errors.ConnectionError)
|
||||
t.is(err.message, 'Response aborted while reading the body')
|
||||
t.strictEqual(count, 2)
|
||||
server.stop()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('Socket destryed while reading the body', t => {
|
||||
t.plan(3)
|
||||
|
||||
let count = 0
|
||||
function handler (req, res) {
|
||||
count += 1
|
||||
const body = JSON.stringify({ hello: 'world' })
|
||||
res.setHeader('Content-Type', 'application/json;utf=8')
|
||||
res.setHeader('Content-Length', body.length + '')
|
||||
res.write(body.slice(0, -5))
|
||||
setTimeout(() => {
|
||||
res.socket.destroy()
|
||||
}, 500)
|
||||
}
|
||||
|
||||
buildServer(handler, ({ port }, server) => {
|
||||
const client = new Client({ node: `http://localhost:${port}`, maxRetries: 1 })
|
||||
client.info((err, { body }) => {
|
||||
t.ok(err instanceof errors.ConnectionError)
|
||||
t.is(err.message, 'Response aborted while reading the body')
|
||||
t.strictEqual(count, 2)
|
||||
server.stop()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,29 +1,14 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
const { test } = require('tap')
|
||||
const { inspect } = require('util')
|
||||
const { createGzip, createDeflate } = require('zlib')
|
||||
const { URL } = require('url')
|
||||
const { Agent } = require('http')
|
||||
const hpagent = require('hpagent')
|
||||
const intoStream = require('into-stream')
|
||||
const { buildServer } = require('../utils')
|
||||
const Connection = require('../../lib/Connection')
|
||||
@ -151,7 +136,7 @@ test('Basic (https with ssl agent)', t => {
|
||||
})
|
||||
|
||||
test('Custom http agent', t => {
|
||||
t.plan(6)
|
||||
t.plan(5)
|
||||
|
||||
function handler (req, res) {
|
||||
t.match(req.headers, {
|
||||
@ -171,12 +156,7 @@ test('Custom http agent', t => {
|
||||
agent.custom = true
|
||||
const connection = new Connection({
|
||||
url: new URL(`http://localhost:${port}`),
|
||||
agent: opts => {
|
||||
t.match(opts, {
|
||||
url: new URL(`http://localhost:${port}`)
|
||||
})
|
||||
return agent
|
||||
}
|
||||
agent: () => agent
|
||||
})
|
||||
t.true(connection.agent.custom)
|
||||
connection.request({
|
||||
@ -399,6 +379,90 @@ test('Send body as stream', t => {
|
||||
})
|
||||
})
|
||||
|
||||
test('Should handle compression', t => {
|
||||
t.test('gzip', t => {
|
||||
t.plan(3)
|
||||
|
||||
function handler (req, res) {
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'application/json;utf=8',
|
||||
'Content-Encoding': 'gzip'
|
||||
})
|
||||
intoStream(JSON.stringify({ hello: 'world' }))
|
||||
.pipe(createGzip())
|
||||
.pipe(res)
|
||||
}
|
||||
|
||||
buildServer(handler, ({ port }, server) => {
|
||||
const connection = new Connection({
|
||||
url: new URL(`http://localhost:${port}`)
|
||||
})
|
||||
connection.request({
|
||||
path: '/hello',
|
||||
method: 'GET'
|
||||
}, (err, res) => {
|
||||
t.error(err)
|
||||
|
||||
t.match(res.headers, {
|
||||
'content-type': 'application/json;utf=8',
|
||||
'content-encoding': 'gzip'
|
||||
})
|
||||
|
||||
var payload = ''
|
||||
res.setEncoding('utf8')
|
||||
res.on('data', chunk => { payload += chunk })
|
||||
res.on('error', err => t.fail(err))
|
||||
res.on('end', () => {
|
||||
t.deepEqual(JSON.parse(payload), { hello: 'world' })
|
||||
server.stop()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
t.test('deflate', t => {
|
||||
t.plan(3)
|
||||
|
||||
function handler (req, res) {
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'application/json;utf=8',
|
||||
'Content-Encoding': 'deflate'
|
||||
})
|
||||
intoStream(JSON.stringify({ hello: 'world' }))
|
||||
.pipe(createDeflate())
|
||||
.pipe(res)
|
||||
}
|
||||
|
||||
buildServer(handler, ({ port }, server) => {
|
||||
const connection = new Connection({
|
||||
url: new URL(`http://localhost:${port}`)
|
||||
})
|
||||
connection.request({
|
||||
path: '/hello',
|
||||
method: 'GET'
|
||||
}, (err, res) => {
|
||||
t.error(err)
|
||||
|
||||
t.match(res.headers, {
|
||||
'content-type': 'application/json;utf=8',
|
||||
'content-encoding': 'deflate'
|
||||
})
|
||||
|
||||
var payload = ''
|
||||
res.setEncoding('utf8')
|
||||
res.on('data', chunk => { payload += chunk })
|
||||
res.on('error', err => t.fail(err))
|
||||
res.on('end', () => {
|
||||
t.deepEqual(JSON.parse(payload), { hello: 'world' })
|
||||
server.stop()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Should not close a connection if there are open requests', t => {
|
||||
t.plan(4)
|
||||
|
||||
@ -886,7 +950,7 @@ test('Should correctly resolve request pathname', t => {
|
||||
t.plan(1)
|
||||
|
||||
const connection = new Connection({
|
||||
url: new URL('http://localhost:80/test')
|
||||
url: new URL(`http://localhost:80/test`)
|
||||
})
|
||||
|
||||
t.strictEqual(
|
||||
@ -896,25 +960,3 @@ test('Should correctly resolve request pathname', t => {
|
||||
'/test/hello'
|
||||
)
|
||||
})
|
||||
|
||||
test('Proxy agent (http)', t => {
|
||||
t.plan(1)
|
||||
|
||||
const connection = new Connection({
|
||||
url: new URL('http://localhost:9200'),
|
||||
proxy: 'http://localhost:8080'
|
||||
})
|
||||
|
||||
t.true(connection.agent instanceof hpagent.HttpProxyAgent)
|
||||
})
|
||||
|
||||
test('Proxy agent (https)', t => {
|
||||
t.plan(1)
|
||||
|
||||
const connection = new Connection({
|
||||
url: new URL('https://localhost:9200'),
|
||||
proxy: 'http://localhost:8080'
|
||||
})
|
||||
|
||||
t.true(connection.agent instanceof hpagent.HttpsProxyAgent)
|
||||
})
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
@ -655,7 +640,7 @@ test('bulk index', t => {
|
||||
})
|
||||
.catch(err => {
|
||||
t.true(err instanceof errors.ConfigurationError)
|
||||
t.is(err.message, 'Bulk helper invalid action: \'foo\'')
|
||||
t.is(err.message, `Bulk helper invalid action: 'foo'`)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
@ -27,26 +12,17 @@ test('Scroll search', async t => {
|
||||
var count = 0
|
||||
const MockConnection = connection.buildMockConnection({
|
||||
onRequest (params) {
|
||||
count += 1
|
||||
if (params.method === 'POST') {
|
||||
t.strictEqual(params.querystring, 'scroll=1m')
|
||||
}
|
||||
if (count === 4) {
|
||||
// final automated clear
|
||||
t.strictEqual(params.method, 'DELETE')
|
||||
}
|
||||
t.strictEqual(params.querystring, 'scroll=1m')
|
||||
return {
|
||||
body: {
|
||||
_scroll_id: 'id',
|
||||
_scroll_id: count === 3 ? undefined : 'id',
|
||||
count,
|
||||
hits: {
|
||||
hits: count === 3
|
||||
? []
|
||||
: [
|
||||
{ _source: { one: 'one' } },
|
||||
{ _source: { two: 'two' } },
|
||||
{ _source: { three: 'three' } }
|
||||
]
|
||||
hits: [
|
||||
{ _source: { one: 'one' } },
|
||||
{ _source: { two: 'two' } },
|
||||
{ _source: { three: 'three' } }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -65,7 +41,12 @@ test('Scroll search', async t => {
|
||||
|
||||
for await (const result of scrollSearch) {
|
||||
t.strictEqual(result.body.count, count)
|
||||
t.strictEqual(result.body._scroll_id, 'id')
|
||||
if (count < 3) {
|
||||
t.strictEqual(result.body._scroll_id, 'id')
|
||||
} else {
|
||||
t.strictEqual(result.body._scroll_id, undefined)
|
||||
}
|
||||
count += 1
|
||||
}
|
||||
})
|
||||
|
||||
@ -119,27 +100,21 @@ test('Scroll search (retry)', async t => {
|
||||
var count = 0
|
||||
const MockConnection = connection.buildMockConnection({
|
||||
onRequest (params) {
|
||||
count += 1
|
||||
if (count === 1) {
|
||||
count += 1
|
||||
return { body: {}, statusCode: 429 }
|
||||
}
|
||||
if (count === 5) {
|
||||
// final automated clear
|
||||
t.strictEqual(params.method, 'DELETE')
|
||||
}
|
||||
return {
|
||||
statusCode: 200,
|
||||
body: {
|
||||
_scroll_id: 'id',
|
||||
_scroll_id: count === 4 ? undefined : 'id',
|
||||
count,
|
||||
hits: {
|
||||
hits: count === 4
|
||||
? []
|
||||
: [
|
||||
{ _source: { one: 'one' } },
|
||||
{ _source: { two: 'two' } },
|
||||
{ _source: { three: 'three' } }
|
||||
]
|
||||
hits: [
|
||||
{ _source: { one: 'one' } },
|
||||
{ _source: { two: 'two' } },
|
||||
{ _source: { three: 'three' } }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -161,7 +136,12 @@ test('Scroll search (retry)', async t => {
|
||||
for await (const result of scrollSearch) {
|
||||
t.strictEqual(result.body.count, count)
|
||||
t.notStrictEqual(result.body.count, 1)
|
||||
t.strictEqual(result.body._scroll_id, 'id')
|
||||
if (count < 4) {
|
||||
t.strictEqual(result.body._scroll_id, 'id')
|
||||
} else {
|
||||
t.strictEqual(result.body._scroll_id, undefined)
|
||||
}
|
||||
count += 1
|
||||
}
|
||||
})
|
||||
|
||||
@ -203,20 +183,20 @@ test('Scroll search (retry throws and maxRetries)', async t => {
|
||||
|
||||
test('Scroll search (retry throws later)', async t => {
|
||||
const maxRetries = 5
|
||||
const expectedAttempts = maxRetries + 2
|
||||
const expectedAttempts = maxRetries + 1
|
||||
var count = 0
|
||||
const MockConnection = connection.buildMockConnection({
|
||||
onRequest (params) {
|
||||
count += 1
|
||||
// filter_path should not be added if is not already present
|
||||
// filter_path should not be added if is not already present
|
||||
t.strictEqual(params.querystring, 'scroll=1m')
|
||||
if (count > 1) {
|
||||
count += 1
|
||||
return { body: {}, statusCode: 429 }
|
||||
}
|
||||
return {
|
||||
statusCode: 200,
|
||||
body: {
|
||||
_scroll_id: 'id',
|
||||
_scroll_id: count === 4 ? undefined : 'id',
|
||||
count,
|
||||
hits: {
|
||||
hits: [
|
||||
@ -232,8 +212,7 @@ test('Scroll search (retry throws later)', async t => {
|
||||
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
Connection: MockConnection,
|
||||
maxRetries
|
||||
Connection: MockConnection
|
||||
})
|
||||
|
||||
const scrollSearch = client.helpers.scrollSearch({
|
||||
@ -246,6 +225,7 @@ test('Scroll search (retry throws later)', async t => {
|
||||
try {
|
||||
for await (const result of scrollSearch) { // eslint-disable-line
|
||||
t.strictEqual(result.body.count, count)
|
||||
count += 1
|
||||
}
|
||||
} catch (err) {
|
||||
t.true(err instanceof errors.ResponseError)
|
||||
@ -261,23 +241,19 @@ test('Scroll search documents', async t => {
|
||||
if (count === 0) {
|
||||
t.strictEqual(params.querystring, 'filter_path=hits.hits._source%2C_scroll_id&scroll=1m')
|
||||
} else {
|
||||
if (params.method !== 'DELETE') {
|
||||
t.strictEqual(params.querystring, 'scroll=1m')
|
||||
t.strictEqual(params.body, '{"scroll_id":"id"}')
|
||||
}
|
||||
t.strictEqual(params.querystring, 'scroll=1m')
|
||||
t.strictEqual(params.body, '{"scroll_id":"id"}')
|
||||
}
|
||||
return {
|
||||
body: {
|
||||
_scroll_id: 'id',
|
||||
_scroll_id: count === 3 ? undefined : 'id',
|
||||
count,
|
||||
hits: {
|
||||
hits: count === 3
|
||||
? []
|
||||
: [
|
||||
{ _source: { val: 1 * count } },
|
||||
{ _source: { val: 2 * count } },
|
||||
{ _source: { val: 3 * count } }
|
||||
]
|
||||
hits: [
|
||||
{ _source: { val: 1 * count } },
|
||||
{ _source: { val: 2 * count } },
|
||||
{ _source: { val: 3 * count } }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -348,19 +324,15 @@ test('Fix querystring for scroll search', async t => {
|
||||
if (count === 0) {
|
||||
t.strictEqual(params.querystring, 'size=1&scroll=1m')
|
||||
} else {
|
||||
if (params.method !== 'DELETE') {
|
||||
t.strictEqual(params.querystring, 'scroll=1m')
|
||||
}
|
||||
t.strictEqual(params.querystring, 'scroll=1m')
|
||||
}
|
||||
return {
|
||||
body: {
|
||||
_scroll_id: 'id',
|
||||
_scroll_id: count === 3 ? undefined : 'id',
|
||||
hits: {
|
||||
hits: count === 3
|
||||
? []
|
||||
: [
|
||||
{ _source: { val: count } }
|
||||
]
|
||||
hits: [
|
||||
{ _source: { val: count } }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,28 +1,13 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
const { test } = require('tap')
|
||||
const { URL } = require('url')
|
||||
const FakeTimers = require('@sinonjs/fake-timers')
|
||||
const { createGunzip, gzipSync } = require('zlib')
|
||||
const { createGunzip } = require('zlib')
|
||||
const os = require('os')
|
||||
const intoStream = require('into-stream')
|
||||
const {
|
||||
@ -1665,17 +1650,13 @@ test('Should cast to boolean HEAD request', t => {
|
||||
})
|
||||
|
||||
test('Suggest compression', t => {
|
||||
t.plan(3)
|
||||
t.plan(2)
|
||||
function handler (req, res) {
|
||||
t.match(req.headers, {
|
||||
'accept-encoding': 'gzip,deflate'
|
||||
})
|
||||
|
||||
const body = gzipSync(JSON.stringify({ hello: 'world' }))
|
||||
res.setHeader('Content-Type', 'application/json;utf=8')
|
||||
res.setHeader('Content-Encoding', 'gzip')
|
||||
res.setHeader('Content-Length', Buffer.byteLength(body))
|
||||
res.end(body)
|
||||
res.end(JSON.stringify({ hello: 'world' }))
|
||||
}
|
||||
|
||||
buildServer(handler, ({ port }, server) => {
|
||||
@ -1698,46 +1679,6 @@ test('Suggest compression', t => {
|
||||
path: '/hello'
|
||||
}, (err, { body }) => {
|
||||
t.error(err)
|
||||
t.deepEqual(body, { hello: 'world' })
|
||||
server.stop()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('Broken compression', t => {
|
||||
t.plan(2)
|
||||
function handler (req, res) {
|
||||
t.match(req.headers, {
|
||||
'accept-encoding': 'gzip,deflate'
|
||||
})
|
||||
|
||||
const body = gzipSync(JSON.stringify({ hello: 'world' }))
|
||||
res.setHeader('Content-Type', 'application/json;utf=8')
|
||||
res.setHeader('Content-Encoding', 'gzip')
|
||||
// we are not setting the content length on purpose
|
||||
res.end(body.slice(0, -5))
|
||||
}
|
||||
|
||||
buildServer(handler, ({ port }, server) => {
|
||||
const pool = new ConnectionPool({ Connection })
|
||||
pool.addConnection(`http://localhost:${port}`)
|
||||
|
||||
const transport = new Transport({
|
||||
emit: () => {},
|
||||
connectionPool: pool,
|
||||
serializer: new Serializer(),
|
||||
maxRetries: 3,
|
||||
requestTimeout: 30000,
|
||||
sniffInterval: false,
|
||||
sniffOnStart: false,
|
||||
suggestCompression: true
|
||||
})
|
||||
|
||||
transport.request({
|
||||
method: 'GET',
|
||||
path: '/hello'
|
||||
}, (err, { body }) => {
|
||||
t.ok(err)
|
||||
server.stop()
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
@ -109,7 +94,7 @@ class MockConnectionSniff extends Connection {
|
||||
'content-type': 'application/json;utf=8',
|
||||
date: new Date().toISOString(),
|
||||
connection: 'keep-alive',
|
||||
'content-length': '191'
|
||||
'content-length': '205'
|
||||
}
|
||||
process.nextTick(() => {
|
||||
if (!aborted) {
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,60 +0,0 @@
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
const proxy = require('proxy')
|
||||
const { readFileSync } = require('fs')
|
||||
const { join } = require('path')
|
||||
const http = require('http')
|
||||
const https = require('https')
|
||||
|
||||
const ssl = {
|
||||
key: readFileSync(join(__dirname, '..', 'fixtures', 'https.key')),
|
||||
cert: readFileSync(join(__dirname, '..', 'fixtures', 'https.cert'))
|
||||
}
|
||||
|
||||
function createProxy () {
|
||||
return new Promise((resolve, reject) => {
|
||||
const server = proxy(http.createServer())
|
||||
server.listen(0, '127.0.0.1', () => {
|
||||
resolve(server)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function createSecureProxy () {
|
||||
return new Promise((resolve, reject) => {
|
||||
const server = proxy(https.createServer(ssl))
|
||||
server.listen(0, '127.0.0.1', () => {
|
||||
resolve(server)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function createServer (handler, callback) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const server = http.createServer()
|
||||
server.listen(0, '127.0.0.1', () => {
|
||||
resolve(server)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function createSecureServer (handler, callback) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const server = https.createServer(ssl)
|
||||
server.listen(0, '127.0.0.1', () => {
|
||||
resolve(server)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ssl,
|
||||
createProxy,
|
||||
createSecureProxy,
|
||||
createServer,
|
||||
createSecureServer
|
||||
}
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
|
||||
@ -1,21 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
@ -23,7 +8,6 @@ const { promisify } = require('util')
|
||||
const sleep = promisify(setTimeout)
|
||||
const buildServer = require('./buildServer')
|
||||
const buildCluster = require('./buildCluster')
|
||||
const buildProxy = require('./buildProxy')
|
||||
const connection = require('./MockConnection')
|
||||
|
||||
async function waitCluster (client, waitForStatus = 'green', timeout = '50s', times = 0) {
|
||||
@ -44,7 +28,6 @@ async function waitCluster (client, waitForStatus = 'green', timeout = '50s', ti
|
||||
module.exports = {
|
||||
buildServer,
|
||||
buildCluster,
|
||||
buildProxy,
|
||||
connection,
|
||||
waitCluster
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user