@elastic/elasticsearch 6.8.4 → 6.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +10 -2
  3. package/api/api/bulk.js +18 -3
  4. package/api/api/cat.aliases.js +18 -3
  5. package/api/api/cat.allocation.js +18 -3
  6. package/api/api/cat.count.js +18 -3
  7. package/api/api/cat.fielddata.js +18 -3
  8. package/api/api/cat.health.js +18 -3
  9. package/api/api/cat.help.js +18 -3
  10. package/api/api/cat.indices.js +18 -3
  11. package/api/api/cat.master.js +18 -3
  12. package/api/api/cat.nodeattrs.js +18 -3
  13. package/api/api/cat.nodes.js +18 -3
  14. package/api/api/cat.pending_tasks.js +18 -3
  15. package/api/api/cat.plugins.js +18 -3
  16. package/api/api/cat.recovery.js +18 -3
  17. package/api/api/cat.repositories.js +18 -3
  18. package/api/api/cat.segments.js +18 -3
  19. package/api/api/cat.shards.js +18 -3
  20. package/api/api/cat.snapshots.js +18 -3
  21. package/api/api/cat.tasks.js +18 -3
  22. package/api/api/cat.templates.js +18 -3
  23. package/api/api/cat.thread_pool.js +18 -3
  24. package/api/api/ccr.delete_auto_follow_pattern.js +18 -3
  25. package/api/api/ccr.follow.js +18 -3
  26. package/api/api/ccr.follow_info.js +18 -3
  27. package/api/api/ccr.follow_stats.js +18 -3
  28. package/api/api/ccr.forget_follower.js +18 -3
  29. package/api/api/ccr.get_auto_follow_pattern.js +18 -3
  30. package/api/api/ccr.pause_follow.js +18 -3
  31. package/api/api/ccr.put_auto_follow_pattern.js +18 -3
  32. package/api/api/ccr.resume_follow.js +18 -3
  33. package/api/api/ccr.stats.js +18 -3
  34. package/api/api/ccr.unfollow.js +18 -3
  35. package/api/api/clear_scroll.js +18 -3
  36. package/api/api/cluster.allocation_explain.js +18 -3
  37. package/api/api/cluster.get_settings.js +18 -3
  38. package/api/api/cluster.health.js +18 -3
  39. package/api/api/cluster.pending_tasks.js +18 -3
  40. package/api/api/cluster.put_settings.js +18 -3
  41. package/api/api/cluster.remote_info.js +18 -3
  42. package/api/api/cluster.reroute.js +18 -3
  43. package/api/api/cluster.state.js +18 -3
  44. package/api/api/cluster.stats.js +18 -3
  45. package/api/api/count.js +18 -3
  46. package/api/api/create.js +18 -3
  47. package/api/api/delete.js +18 -3
  48. package/api/api/delete_by_query.js +18 -3
  49. package/api/api/delete_by_query_rethrottle.js +18 -3
  50. package/api/api/delete_script.js +18 -3
  51. package/api/api/exists.js +18 -3
  52. package/api/api/exists_source.js +18 -3
  53. package/api/api/explain.js +18 -3
  54. package/api/api/field_caps.js +18 -3
  55. package/api/api/get.js +18 -3
  56. package/api/api/get_script.js +18 -3
  57. package/api/api/get_source.js +18 -3
  58. package/api/api/ilm.delete_lifecycle.js +18 -3
  59. package/api/api/ilm.explain_lifecycle.js +18 -3
  60. package/api/api/ilm.get_lifecycle.js +18 -3
  61. package/api/api/ilm.get_status.js +18 -3
  62. package/api/api/ilm.move_to_step.js +18 -3
  63. package/api/api/ilm.put_lifecycle.js +18 -3
  64. package/api/api/ilm.remove_policy.js +18 -3
  65. package/api/api/ilm.retry.js +18 -3
  66. package/api/api/ilm.start.js +18 -3
  67. package/api/api/ilm.stop.js +18 -3
  68. package/api/api/index.js +18 -3
  69. package/api/api/indices.analyze.js +18 -3
  70. package/api/api/indices.clear_cache.js +18 -3
  71. package/api/api/indices.close.js +18 -3
  72. package/api/api/indices.create.js +18 -3
  73. package/api/api/indices.delete.js +18 -3
  74. package/api/api/indices.delete_alias.js +18 -3
  75. package/api/api/indices.delete_template.js +18 -3
  76. package/api/api/indices.exists.js +18 -3
  77. package/api/api/indices.exists_alias.js +18 -3
  78. package/api/api/indices.exists_template.js +18 -3
  79. package/api/api/indices.exists_type.js +18 -3
  80. package/api/api/indices.flush.js +18 -3
  81. package/api/api/indices.flush_synced.js +18 -3
  82. package/api/api/indices.forcemerge.js +18 -3
  83. package/api/api/indices.freeze.js +18 -3
  84. package/api/api/indices.get.js +18 -3
  85. package/api/api/indices.get_alias.js +18 -3
  86. package/api/api/indices.get_field_mapping.js +18 -3
  87. package/api/api/indices.get_mapping.js +18 -3
  88. package/api/api/indices.get_settings.js +18 -3
  89. package/api/api/indices.get_template.js +18 -3
  90. package/api/api/indices.get_upgrade.js +18 -3
  91. package/api/api/indices.open.js +18 -3
  92. package/api/api/indices.put_alias.js +18 -3
  93. package/api/api/indices.put_mapping.js +18 -3
  94. package/api/api/indices.put_settings.js +18 -3
  95. package/api/api/indices.put_template.js +18 -3
  96. package/api/api/indices.recovery.js +18 -3
  97. package/api/api/indices.refresh.js +18 -3
  98. package/api/api/indices.rollover.js +18 -3
  99. package/api/api/indices.segments.js +18 -3
  100. package/api/api/indices.shard_stores.js +18 -3
  101. package/api/api/indices.shrink.js +18 -3
  102. package/api/api/indices.split.js +18 -3
  103. package/api/api/indices.stats.js +18 -3
  104. package/api/api/indices.unfreeze.js +18 -3
  105. package/api/api/indices.update_aliases.js +18 -3
  106. package/api/api/indices.upgrade.js +18 -3
  107. package/api/api/indices.validate_query.js +18 -3
  108. package/api/api/info.js +18 -3
  109. package/api/api/ingest.delete_pipeline.js +18 -3
  110. package/api/api/ingest.get_pipeline.js +18 -3
  111. package/api/api/ingest.processor_grok.js +18 -3
  112. package/api/api/ingest.put_pipeline.js +18 -3
  113. package/api/api/ingest.simulate.js +18 -3
  114. package/api/api/mget.js +18 -3
  115. package/api/api/msearch.js +18 -3
  116. package/api/api/msearch_template.js +18 -3
  117. package/api/api/mtermvectors.js +18 -3
  118. package/api/api/nodes.hot_threads.js +18 -3
  119. package/api/api/nodes.info.js +18 -3
  120. package/api/api/nodes.reload_secure_settings.js +18 -3
  121. package/api/api/nodes.stats.js +18 -3
  122. package/api/api/nodes.usage.js +18 -3
  123. package/api/api/ping.js +18 -3
  124. package/api/api/put_script.js +18 -3
  125. package/api/api/rank_eval.js +18 -3
  126. package/api/api/reindex.js +18 -3
  127. package/api/api/reindex_rethrottle.js +18 -3
  128. package/api/api/render_search_template.js +18 -3
  129. package/api/api/scripts_painless_execute.js +18 -3
  130. package/api/api/scroll.js +18 -3
  131. package/api/api/search.js +18 -3
  132. package/api/api/search_shards.js +18 -3
  133. package/api/api/search_template.js +18 -3
  134. package/api/api/security.create_api_key.js +18 -3
  135. package/api/api/security.get_api_key.js +18 -3
  136. package/api/api/security.invalidate_api_key.js +18 -3
  137. package/api/api/snapshot.create.js +18 -3
  138. package/api/api/snapshot.create_repository.js +18 -3
  139. package/api/api/snapshot.delete.js +18 -3
  140. package/api/api/snapshot.delete_repository.js +18 -3
  141. package/api/api/snapshot.get.js +18 -3
  142. package/api/api/snapshot.get_repository.js +18 -3
  143. package/api/api/snapshot.restore.js +18 -3
  144. package/api/api/snapshot.status.js +18 -3
  145. package/api/api/snapshot.verify_repository.js +18 -3
  146. package/api/api/tasks.cancel.js +18 -3
  147. package/api/api/tasks.get.js +18 -3
  148. package/api/api/tasks.list.js +18 -3
  149. package/api/api/termvectors.js +18 -3
  150. package/api/api/update.js +18 -3
  151. package/api/api/update_by_query.js +18 -3
  152. package/api/api/update_by_query_rethrottle.js +18 -3
  153. package/api/api/xpack.graph.explore.js +18 -3
  154. package/api/api/xpack.info.js +18 -3
  155. package/api/api/xpack.license.delete.js +18 -3
  156. package/api/api/xpack.license.get.js +18 -3
  157. package/api/api/xpack.license.get_basic_status.js +18 -3
  158. package/api/api/xpack.license.get_trial_status.js +18 -3
  159. package/api/api/xpack.license.post.js +18 -3
  160. package/api/api/xpack.license.post_start_basic.js +18 -3
  161. package/api/api/xpack.license.post_start_trial.js +18 -3
  162. package/api/api/xpack.migration.deprecations.js +18 -3
  163. package/api/api/xpack.migration.get_assistance.js +18 -3
  164. package/api/api/xpack.migration.upgrade.js +18 -3
  165. package/api/api/xpack.ml.close_job.js +18 -3
  166. package/api/api/xpack.ml.delete_calendar.js +18 -3
  167. package/api/api/xpack.ml.delete_calendar_event.js +18 -3
  168. package/api/api/xpack.ml.delete_calendar_job.js +18 -3
  169. package/api/api/xpack.ml.delete_datafeed.js +18 -3
  170. package/api/api/xpack.ml.delete_expired_data.js +18 -3
  171. package/api/api/xpack.ml.delete_filter.js +18 -3
  172. package/api/api/xpack.ml.delete_forecast.js +18 -3
  173. package/api/api/xpack.ml.delete_job.js +18 -3
  174. package/api/api/xpack.ml.delete_model_snapshot.js +18 -3
  175. package/api/api/xpack.ml.find_file_structure.js +18 -3
  176. package/api/api/xpack.ml.flush_job.js +18 -3
  177. package/api/api/xpack.ml.forecast.js +18 -3
  178. package/api/api/xpack.ml.get_buckets.js +18 -3
  179. package/api/api/xpack.ml.get_calendar_events.js +18 -3
  180. package/api/api/xpack.ml.get_calendars.js +18 -3
  181. package/api/api/xpack.ml.get_categories.js +18 -3
  182. package/api/api/xpack.ml.get_datafeed_stats.js +18 -3
  183. package/api/api/xpack.ml.get_datafeeds.js +18 -3
  184. package/api/api/xpack.ml.get_filters.js +18 -3
  185. package/api/api/xpack.ml.get_influencers.js +18 -3
  186. package/api/api/xpack.ml.get_job_stats.js +18 -3
  187. package/api/api/xpack.ml.get_jobs.js +18 -3
  188. package/api/api/xpack.ml.get_model_snapshots.js +18 -3
  189. package/api/api/xpack.ml.get_overall_buckets.js +18 -3
  190. package/api/api/xpack.ml.get_records.js +18 -3
  191. package/api/api/xpack.ml.info.js +18 -3
  192. package/api/api/xpack.ml.open_job.js +18 -3
  193. package/api/api/xpack.ml.post_calendar_events.js +18 -3
  194. package/api/api/xpack.ml.post_data.js +18 -3
  195. package/api/api/xpack.ml.preview_datafeed.js +18 -3
  196. package/api/api/xpack.ml.put_calendar.js +18 -3
  197. package/api/api/xpack.ml.put_calendar_job.js +18 -3
  198. package/api/api/xpack.ml.put_datafeed.js +18 -3
  199. package/api/api/xpack.ml.put_filter.js +18 -3
  200. package/api/api/xpack.ml.put_job.js +18 -3
  201. package/api/api/xpack.ml.revert_model_snapshot.js +18 -3
  202. package/api/api/xpack.ml.set_upgrade_mode.js +18 -3
  203. package/api/api/xpack.ml.start_datafeed.js +18 -3
  204. package/api/api/xpack.ml.stop_datafeed.js +18 -3
  205. package/api/api/xpack.ml.update_datafeed.js +18 -3
  206. package/api/api/xpack.ml.update_filter.js +18 -3
  207. package/api/api/xpack.ml.update_job.js +18 -3
  208. package/api/api/xpack.ml.update_model_snapshot.js +18 -3
  209. package/api/api/xpack.ml.validate.js +18 -3
  210. package/api/api/xpack.ml.validate_detector.js +18 -3
  211. package/api/api/xpack.monitoring.bulk.js +18 -3
  212. package/api/api/xpack.rollup.delete_job.js +18 -3
  213. package/api/api/xpack.rollup.get_jobs.js +18 -3
  214. package/api/api/xpack.rollup.get_rollup_caps.js +18 -3
  215. package/api/api/xpack.rollup.get_rollup_index_caps.js +18 -3
  216. package/api/api/xpack.rollup.put_job.js +18 -3
  217. package/api/api/xpack.rollup.rollup_search.js +18 -3
  218. package/api/api/xpack.rollup.start_job.js +18 -3
  219. package/api/api/xpack.rollup.stop_job.js +18 -3
  220. package/api/api/xpack.security.authenticate.js +18 -3
  221. package/api/api/xpack.security.change_password.js +18 -3
  222. package/api/api/xpack.security.clear_cached_realms.js +18 -3
  223. package/api/api/xpack.security.clear_cached_roles.js +18 -3
  224. package/api/api/xpack.security.delete_privileges.js +18 -3
  225. package/api/api/xpack.security.delete_role.js +18 -3
  226. package/api/api/xpack.security.delete_role_mapping.js +18 -3
  227. package/api/api/xpack.security.delete_user.js +18 -3
  228. package/api/api/xpack.security.disable_user.js +18 -3
  229. package/api/api/xpack.security.enable_user.js +18 -3
  230. package/api/api/xpack.security.get_privileges.js +18 -3
  231. package/api/api/xpack.security.get_role.js +18 -3
  232. package/api/api/xpack.security.get_role_mapping.js +18 -3
  233. package/api/api/xpack.security.get_token.js +18 -3
  234. package/api/api/xpack.security.get_user.js +18 -3
  235. package/api/api/xpack.security.get_user_privileges.js +18 -3
  236. package/api/api/xpack.security.has_privileges.js +18 -3
  237. package/api/api/xpack.security.invalidate_token.js +18 -3
  238. package/api/api/xpack.security.put_privileges.js +18 -3
  239. package/api/api/xpack.security.put_role.js +18 -3
  240. package/api/api/xpack.security.put_role_mapping.js +18 -3
  241. package/api/api/xpack.security.put_user.js +18 -3
  242. package/api/api/xpack.sql.clear_cursor.js +18 -3
  243. package/api/api/xpack.sql.query.js +18 -3
  244. package/api/api/xpack.sql.translate.js +18 -3
  245. package/api/api/xpack.ssl.certificates.js +18 -3
  246. package/api/api/xpack.usage.js +18 -3
  247. package/api/api/xpack.watcher.ack_watch.js +18 -3
  248. package/api/api/xpack.watcher.activate_watch.js +18 -3
  249. package/api/api/xpack.watcher.deactivate_watch.js +18 -3
  250. package/api/api/xpack.watcher.delete_watch.js +18 -3
  251. package/api/api/xpack.watcher.execute_watch.js +18 -3
  252. package/api/api/xpack.watcher.get_watch.js +18 -3
  253. package/api/api/xpack.watcher.put_watch.js +18 -3
  254. package/api/api/xpack.watcher.restart.js +18 -3
  255. package/api/api/xpack.watcher.start.js +18 -3
  256. package/api/api/xpack.watcher.stats.js +18 -3
  257. package/api/api/xpack.watcher.stop.js +18 -3
  258. package/api/index.js +18 -3
  259. package/api/requestParams.d.ts +18 -3
  260. package/{.codecov.yml → codecov.yml} +1 -1
  261. package/index.d.ts +20 -5
  262. package/index.js +18 -3
  263. package/lib/Connection.d.ts +18 -3
  264. package/lib/Connection.js +20 -7
  265. package/lib/Serializer.d.ts +18 -3
  266. package/lib/Serializer.js +20 -4
  267. package/lib/Transport.d.ts +19 -4
  268. package/lib/Transport.js +29 -13
  269. package/lib/errors.d.ts +18 -3
  270. package/lib/errors.js +19 -4
  271. package/lib/pool/BaseConnectionPool.js +21 -6
  272. package/lib/pool/CloudConnectionPool.js +18 -3
  273. package/lib/pool/ConnectionPool.js +34 -19
  274. package/lib/pool/index.d.ts +19 -4
  275. package/lib/pool/index.js +18 -3
  276. package/package.json +4 -5
package/lib/Serializer.js CHANGED
@@ -1,11 +1,27 @@
1
- // Licensed to Elasticsearch B.V under one or more agreements.
2
- // Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
- // See the LICENSE file in the project root for more information
1
+ /*
2
+ * Licensed to Elasticsearch B.V. under one or more contributor
3
+ * license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright
5
+ * ownership. Elasticsearch B.V. licenses this file to you under
6
+ * the Apache License, Version 2.0 (the "License"); you may
7
+ * not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
4
19
 
5
20
  'use strict'
6
21
 
7
22
  const { stringify } = require('querystring')
8
23
  const debug = require('debug')('elasticsearch')
24
+ const sjson = require('secure-json-parse')
9
25
  const { SerializationError, DeserializationError } = require('./errors')
10
26
 
11
27
  class Serializer {
@@ -22,7 +38,7 @@ class Serializer {
22
38
  deserialize (json) {
23
39
  debug('Deserializing', json)
24
40
  try {
25
- var object = JSON.parse(json)
41
+ var object = sjson.parse(json)
26
42
  } catch (err) {
27
43
  throw new DeserializationError(err.message)
28
44
  }
@@ -1,6 +1,21 @@
1
- // Licensed to Elasticsearch B.V under one or more agreements.
2
- // Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
- // See the LICENSE file in the project root for more information
1
+ /*
2
+ * Licensed to Elasticsearch B.V. under one or more contributor
3
+ * license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright
5
+ * ownership. Elasticsearch B.V. licenses this file to you under
6
+ * the Apache License, Version 2.0 (the "License"); you may
7
+ * not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
4
19
 
5
20
  import { ConnectionPool, CloudConnectionPool } from './pool';
6
21
  import Connection from './Connection';
@@ -81,7 +96,7 @@ export interface TransportRequestParams {
81
96
  }
82
97
 
83
98
  export interface TransportRequestOptions {
84
- ignore?: [number];
99
+ ignore?: number[];
85
100
  requestTimeout?: number | string;
86
101
  maxRetries?: number;
87
102
  asStream?: boolean;
package/lib/Transport.js CHANGED
@@ -1,6 +1,21 @@
1
- // Licensed to Elasticsearch B.V under one or more agreements.
2
- // Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
- // See the LICENSE file in the project root for more information
1
+ /*
2
+ * Licensed to Elasticsearch B.V. under one or more contributor
3
+ * license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright
5
+ * ownership. Elasticsearch B.V. licenses this file to you under
6
+ * the Apache License, Version 2.0 (the "License"); you may
7
+ * not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
4
19
 
5
20
  'use strict'
6
21
 
@@ -108,10 +123,9 @@ class Transport {
108
123
  const makeRequest = () => {
109
124
  if (meta.aborted === true) return
110
125
  meta.connection = this.getConnection({ requestId: meta.request.id })
111
- if (meta.connection === null) {
112
- return callback(new NoLivingConnectionsError('There are not living connections'), result)
126
+ if (meta.connection == null) {
127
+ return callback(new NoLivingConnectionsError(), result)
113
128
  }
114
-
115
129
  // TODO: make this assignment FAST
116
130
  const headers = Object.assign({}, this.headers, options.headers)
117
131
 
@@ -130,15 +144,17 @@ class Transport {
130
144
  return callback(err, result)
131
145
  }
132
146
  }
133
- headers['Content-Type'] = headers['Content-Type'] || 'application/json'
134
147
 
135
- if (compression === 'gzip') {
136
- if (isStream(params.body) === false) {
137
- params.body = intoStream(params.body).pipe(createGzip())
138
- } else {
139
- params.body = params.body.pipe(createGzip())
148
+ if (params.body !== '') {
149
+ headers['Content-Type'] = headers['Content-Type'] || 'application/json'
150
+ if (compression === 'gzip') {
151
+ if (isStream(params.body) === false) {
152
+ params.body = intoStream(params.body).pipe(createGzip())
153
+ } else {
154
+ params.body = params.body.pipe(createGzip())
155
+ }
156
+ headers['Content-Encoding'] = compression
140
157
  }
141
- headers['Content-Encoding'] = compression
142
158
  }
143
159
 
144
160
  if (isStream(params.body) === false) {
package/lib/errors.d.ts CHANGED
@@ -1,6 +1,21 @@
1
- // Licensed to Elasticsearch B.V under one or more agreements.
2
- // Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
- // See the LICENSE file in the project root for more information
1
+ /*
2
+ * Licensed to Elasticsearch B.V. under one or more contributor
3
+ * license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright
5
+ * ownership. Elasticsearch B.V. licenses this file to you under
6
+ * the Apache License, Version 2.0 (the "License"); you may
7
+ * not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
4
19
 
5
20
  import { ApiResponse } from './Transport'
6
21
 
package/lib/errors.js CHANGED
@@ -1,6 +1,21 @@
1
- // Licensed to Elasticsearch B.V under one or more agreements.
2
- // Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
- // See the LICENSE file in the project root for more information
1
+ /*
2
+ * Licensed to Elasticsearch B.V. under one or more contributor
3
+ * license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright
5
+ * ownership. Elasticsearch B.V. licenses this file to you under
6
+ * the Apache License, Version 2.0 (the "License"); you may
7
+ * not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
4
19
 
5
20
  'use strict'
6
21
 
@@ -36,7 +51,7 @@ class NoLivingConnectionsError extends ElasticsearchClientError {
36
51
  super(message)
37
52
  Error.captureStackTrace(this, NoLivingConnectionsError)
38
53
  this.name = 'NoLivingConnectionsError'
39
- this.message = message || 'No Living Connections Error'
54
+ this.message = message || 'Given the configuration, the ConnectionPool was not able to find a usable Connection for this request.'
40
55
  this.meta = meta
41
56
  }
42
57
  }
@@ -1,6 +1,21 @@
1
- // Licensed to Elasticsearch B.V under one or more agreements.
2
- // Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
- // See the LICENSE file in the project root for more information
1
+ /*
2
+ * Licensed to Elasticsearch B.V. under one or more contributor
3
+ * license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright
5
+ * ownership. Elasticsearch B.V. licenses this file to you under
6
+ * the Apache License, Version 2.0 (the "License"); you may
7
+ * not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
4
19
 
5
20
  'use strict'
6
21
 
@@ -42,13 +57,13 @@ class BaseConnectionPool {
42
57
  opts = this.urlToHost(opts)
43
58
  }
44
59
 
45
- if (opts.url.username !== '' && opts.url.password !== '') {
60
+ if (this.auth !== null) {
61
+ opts.auth = this.auth
62
+ } else if (opts.url.username !== '' && opts.url.password !== '') {
46
63
  opts.auth = {
47
64
  username: decodeURIComponent(opts.url.username),
48
65
  password: decodeURIComponent(opts.url.password)
49
66
  }
50
- } else if (this.auth !== null) {
51
- opts.auth = this.auth
52
67
  }
53
68
 
54
69
  if (opts.ssl == null) opts.ssl = this._ssl
@@ -1,6 +1,21 @@
1
- // Licensed to Elasticsearch B.V under one or more agreements.
2
- // Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
- // See the LICENSE file in the project root for more information
1
+ /*
2
+ * Licensed to Elasticsearch B.V. under one or more contributor
3
+ * license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright
5
+ * ownership. Elasticsearch B.V. licenses this file to you under
6
+ * the Apache License, Version 2.0 (the "License"); you may
7
+ * not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
4
19
 
5
20
  'use strict'
6
21
 
@@ -1,6 +1,21 @@
1
- // Licensed to Elasticsearch B.V under one or more agreements.
2
- // Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
- // See the LICENSE file in the project root for more information
1
+ /*
2
+ * Licensed to Elasticsearch B.V. under one or more contributor
3
+ * license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright
5
+ * ownership. Elasticsearch B.V. licenses this file to you under
6
+ * the Apache License, Version 2.0 (the "License"); you may
7
+ * not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
4
19
 
5
20
  'use strict'
6
21
 
@@ -35,13 +50,10 @@ class ConnectionPool extends BaseConnectionPool {
35
50
  * Marks a connection as 'alive'.
36
51
  * If needed removes the connection from the dead list
37
52
  * and then resets the `deadCount`.
38
- * If sniffing is not enabled and there is only
39
- * one node, this method is a noop.
40
53
  *
41
54
  * @param {object} connection
42
55
  */
43
56
  markAlive (connection) {
44
- if (this._sniffEnabled === false && this.size === 1) return this
45
57
  const { id } = connection
46
58
  debug(`Marking as 'alive' connection '${id}'`)
47
59
  const index = this.dead.indexOf(id)
@@ -56,17 +68,24 @@ class ConnectionPool extends BaseConnectionPool {
56
68
  * Marks a connection as 'dead'.
57
69
  * If needed adds the connection to the dead list
58
70
  * and then increments the `deadCount`.
59
- * If sniffing is not enabled and there is only
60
- * one node, this method is a noop.
61
71
  *
62
72
  * @param {object} connection
63
73
  */
64
74
  markDead (connection) {
65
- if (this._sniffEnabled === false && this.size === 1) return this
66
75
  const { id } = connection
67
76
  debug(`Marking as 'dead' connection '${id}'`)
68
77
  if (this.dead.indexOf(id) === -1) {
69
- this.dead.push(id)
78
+ // It might happen that `markDead` is called jsut after
79
+ // a pool update, and in such case we will add to the dead
80
+ // list a node that no longer exist. The following check verify
81
+ // that the connection is still part of the pool before
82
+ // marking it as dead.
83
+ for (var i = 0; i < this.size; i++) {
84
+ if (this.connections[i].id === id) {
85
+ this.dead.push(id)
86
+ break
87
+ }
88
+ }
70
89
  }
71
90
  connection.status = Connection.statuses.DEAD
72
91
  connection.deadCount++
@@ -158,7 +177,7 @@ class ConnectionPool extends BaseConnectionPool {
158
177
 
159
178
  /**
160
179
  * Returns an alive connection if present,
161
- * otherwise returns null.
180
+ * otherwise returns a dead connection.
162
181
  * By default it filters the `master` only nodes.
163
182
  * It uses the selector to choose which
164
183
  * connection return.
@@ -176,11 +195,13 @@ class ConnectionPool extends BaseConnectionPool {
176
195
  name: opts.name
177
196
  })
178
197
 
198
+ const noAliveConnections = this.size === this.dead.length
199
+
179
200
  // TODO: can we cache this?
180
201
  const connections = []
181
202
  for (var i = 0; i < this.size; i++) {
182
203
  const connection = this.connections[i]
183
- if (connection.status === Connection.statuses.ALIVE) {
204
+ if (noAliveConnections || connection.status === Connection.statuses.ALIVE) {
184
205
  if (filter(connection) === true) {
185
206
  connections.push(connection)
186
207
  }
@@ -212,13 +233,7 @@ class ConnectionPool extends BaseConnectionPool {
212
233
  */
213
234
  update (connections) {
214
235
  super.update(connections)
215
-
216
- for (var i = 0; i < this.dead.length; i++) {
217
- if (this.connections.find(c => c.id === this.dead[i]) === undefined) {
218
- this.dead.splice(i, 1)
219
- }
220
- }
221
-
236
+ this.dead = []
222
237
  return this
223
238
  }
224
239
  }
@@ -1,6 +1,21 @@
1
- // Licensed to Elasticsearch B.V under one or more agreements.
2
- // Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
- // See the LICENSE file in the project root for more information
1
+ /*
2
+ * Licensed to Elasticsearch B.V. under one or more contributor
3
+ * license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright
5
+ * ownership. Elasticsearch B.V. licenses this file to you under
6
+ * the Apache License, Version 2.0 (the "License"); you may
7
+ * not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
4
19
 
5
20
  /// <reference types="node" />
6
21
 
@@ -88,7 +103,7 @@ declare class BaseConnectionPool {
88
103
  markDead(connection: Connection): this;
89
104
  /**
90
105
  * Returns an alive connection if present,
91
- * otherwise returns null.
106
+ * otherwise returns a dead connection.
92
107
  * By default it filters the `master` only nodes.
93
108
  * It uses the selector to choose which
94
109
  * connection return.
package/lib/pool/index.js CHANGED
@@ -1,6 +1,21 @@
1
- // Licensed to Elasticsearch B.V under one or more agreements.
2
- // Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
- // See the LICENSE file in the project root for more information
1
+ /*
2
+ * Licensed to Elasticsearch B.V. under one or more contributor
3
+ * license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright
5
+ * ownership. Elasticsearch B.V. licenses this file to you under
6
+ * the Apache License, Version 2.0 (the "License"); you may
7
+ * not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
4
19
 
5
20
  'use strict'
6
21
 
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html",
7
- "version": "6.8.4",
7
+ "version": "6.8.8",
8
8
  "keywords": [
9
9
  "elasticsearch",
10
10
  "elastic",
@@ -21,7 +21,7 @@
21
21
  "test:behavior": "tap test/behavior/*.test.js -t 300 --no-coverage",
22
22
  "test:integration": "tap test/integration/index.js -T --no-coverage",
23
23
  "test:types": "tsc --project ./test/types/tsconfig.json",
24
- "test:coverage": "nyc tap test/unit/*.test.js test/behavior/*.test.js -t 300 && nyc report --reporter=text-lcov > coverage.lcov && codecov",
24
+ "test:coverage": "nyc tap test/unit/*.test.js test/behavior/*.test.js -t 300 && nyc report --reporter=text-lcov > coverage.lcov",
25
25
  "lint": "standard",
26
26
  "lint:fix": "standard --fix",
27
27
  "ci": "npm run license-checker && npm test && npm run test:integration && npm run test:coverage",
@@ -39,7 +39,6 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/node": "^12.6.2",
42
- "codecov": "^3.3.0",
43
42
  "convert-hrtime": "^3.0.0",
44
43
  "dedent": "^0.7.0",
45
44
  "deepmerge": "^4.0.0",
@@ -58,7 +57,6 @@
58
57
  "standard": "^13.0.2",
59
58
  "stoppable": "^1.1.0",
60
59
  "tap": "^14.4.1",
61
- "tap-mocha-reporter": "^4.0.1",
62
60
  "typescript": "^3.4.5",
63
61
  "workq": "^2.1.0"
64
62
  },
@@ -68,7 +66,8 @@
68
66
  "into-stream": "^5.1.0",
69
67
  "ms": "^2.1.1",
70
68
  "once": "^1.4.0",
71
- "pump": "^3.0.0"
69
+ "pump": "^3.0.0",
70
+ "secure-json-parse": "^2.1.0"
72
71
  },
73
72
  "license": "Apache-2.0",
74
73
  "repository": {