@elastic/elasticsearch 7.15.0

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 (103) hide show
  1. package/.dockerignore +5 -0
  2. package/LICENSE +202 -0
  3. package/README.md +232 -0
  4. package/api/api/async_search.js +141 -0
  5. package/api/api/autoscaling.js +147 -0
  6. package/api/api/bulk.js +70 -0
  7. package/api/api/cat.js +648 -0
  8. package/api/api/ccr.js +403 -0
  9. package/api/api/clear_scroll.js +55 -0
  10. package/api/api/close_point_in_time.js +50 -0
  11. package/api/api/cluster.js +420 -0
  12. package/api/api/count.js +64 -0
  13. package/api/api/create.js +69 -0
  14. package/api/api/dangling_indices.js +115 -0
  15. package/api/api/delete.js +65 -0
  16. package/api/api/delete_by_query.js +71 -0
  17. package/api/api/delete_by_query_rethrottle.js +60 -0
  18. package/api/api/delete_script.js +56 -0
  19. package/api/api/enrich.js +173 -0
  20. package/api/api/eql.js +150 -0
  21. package/api/api/exists.js +65 -0
  22. package/api/api/exists_source.js +74 -0
  23. package/api/api/explain.js +65 -0
  24. package/api/api/features.js +81 -0
  25. package/api/api/field_caps.js +55 -0
  26. package/api/api/fleet.js +65 -0
  27. package/api/api/get.js +65 -0
  28. package/api/api/get_script.js +56 -0
  29. package/api/api/get_script_context.js +50 -0
  30. package/api/api/get_script_languages.js +50 -0
  31. package/api/api/get_source.js +65 -0
  32. package/api/api/graph.js +72 -0
  33. package/api/api/ilm.js +317 -0
  34. package/api/api/index.js +71 -0
  35. package/api/api/indices.js +1753 -0
  36. package/api/api/info.js +50 -0
  37. package/api/api/ingest.js +200 -0
  38. package/api/api/license.js +188 -0
  39. package/api/api/logstash.js +125 -0
  40. package/api/api/mget.js +70 -0
  41. package/api/api/migration.js +60 -0
  42. package/api/api/ml.js +2010 -0
  43. package/api/api/monitoring.js +66 -0
  44. package/api/api/msearch.js +70 -0
  45. package/api/api/msearch_template.js +70 -0
  46. package/api/api/mtermvectors.js +64 -0
  47. package/api/api/nodes.js +268 -0
  48. package/api/api/open_point_in_time.js +56 -0
  49. package/api/api/ping.js +50 -0
  50. package/api/api/put_script.js +71 -0
  51. package/api/api/rank_eval.js +61 -0
  52. package/api/api/reindex.js +56 -0
  53. package/api/api/reindex_rethrottle.js +60 -0
  54. package/api/api/render_search_template.js +55 -0
  55. package/api/api/rollup.js +319 -0
  56. package/api/api/scripts_painless_execute.js +50 -0
  57. package/api/api/scroll.js +55 -0
  58. package/api/api/search.js +64 -0
  59. package/api/api/search_mvt.js +87 -0
  60. package/api/api/search_shards.js +55 -0
  61. package/api/api/search_template.js +70 -0
  62. package/api/api/searchable_snapshots.js +186 -0
  63. package/api/api/security.js +1261 -0
  64. package/api/api/shutdown.js +124 -0
  65. package/api/api/slm.js +256 -0
  66. package/api/api/snapshot.js +439 -0
  67. package/api/api/sql.js +203 -0
  68. package/api/api/ssl.js +55 -0
  69. package/api/api/tasks.js +108 -0
  70. package/api/api/terms_enum.js +56 -0
  71. package/api/api/termvectors.js +67 -0
  72. package/api/api/text_structure.js +65 -0
  73. package/api/api/transform.js +268 -0
  74. package/api/api/update.js +69 -0
  75. package/api/api/update_by_query.js +67 -0
  76. package/api/api/update_by_query_rethrottle.js +60 -0
  77. package/api/api/watcher.js +333 -0
  78. package/api/api/xpack.js +76 -0
  79. package/api/index.js +508 -0
  80. package/api/new.d.ts +1585 -0
  81. package/api/requestParams.d.ts +2920 -0
  82. package/api/types.d.ts +15420 -0
  83. package/api/utils.js +58 -0
  84. package/codecov.yml +14 -0
  85. package/index.d.ts +2991 -0
  86. package/index.js +349 -0
  87. package/index.mjs +29 -0
  88. package/lib/Connection.d.ts +99 -0
  89. package/lib/Connection.js +392 -0
  90. package/lib/Helpers.d.ts +124 -0
  91. package/lib/Helpers.js +770 -0
  92. package/lib/Serializer.d.ts +30 -0
  93. package/lib/Serializer.js +94 -0
  94. package/lib/Transport.d.ts +162 -0
  95. package/lib/Transport.js +689 -0
  96. package/lib/errors.d.ts +90 -0
  97. package/lib/errors.js +159 -0
  98. package/lib/pool/BaseConnectionPool.js +262 -0
  99. package/lib/pool/CloudConnectionPool.js +64 -0
  100. package/lib/pool/ConnectionPool.js +246 -0
  101. package/lib/pool/index.d.ts +220 -0
  102. package/lib/pool/index.js +30 -0
  103. package/package.json +106 -0
@@ -0,0 +1,30 @@
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
+ */
19
+
20
+ export interface SerializerOptions {
21
+ disablePrototypePoisoningProtection: boolean | 'proto' | 'constructor'
22
+ }
23
+
24
+ export default class Serializer {
25
+ constructor (opts?: SerializerOptions)
26
+ serialize(object: any): string;
27
+ deserialize(json: string): any;
28
+ ndserialize(array: any[]): string;
29
+ qserialize(object: any): string;
30
+ }
@@ -0,0 +1,94 @@
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
+ */
19
+
20
+ 'use strict'
21
+
22
+ const { stringify } = require('querystring')
23
+ const debug = require('debug')('elasticsearch')
24
+ const sjson = require('secure-json-parse')
25
+ const { SerializationError, DeserializationError } = require('./errors')
26
+ const kJsonOptions = Symbol('secure json parse options')
27
+
28
+ class Serializer {
29
+ constructor (opts = {}) {
30
+ const disable = opts.disablePrototypePoisoningProtection
31
+ this[kJsonOptions] = {
32
+ protoAction: disable === true || disable === 'proto' ? 'ignore' : 'error',
33
+ constructorAction: disable === true || disable === 'constructor' ? 'ignore' : 'error'
34
+ }
35
+ }
36
+
37
+ serialize (object) {
38
+ debug('Serializing', object)
39
+ let json
40
+ try {
41
+ json = JSON.stringify(object)
42
+ } catch (err) {
43
+ throw new SerializationError(err.message, object)
44
+ }
45
+ return json
46
+ }
47
+
48
+ deserialize (json) {
49
+ debug('Deserializing', json)
50
+ let object
51
+ try {
52
+ object = sjson.parse(json, this[kJsonOptions])
53
+ } catch (err) {
54
+ throw new DeserializationError(err.message, json)
55
+ }
56
+ return object
57
+ }
58
+
59
+ ndserialize (array) {
60
+ debug('ndserialize', array)
61
+ if (Array.isArray(array) === false) {
62
+ throw new SerializationError('The argument provided is not an array')
63
+ }
64
+ let ndjson = ''
65
+ for (let i = 0, len = array.length; i < len; i++) {
66
+ if (typeof array[i] === 'string') {
67
+ ndjson += array[i] + '\n'
68
+ } else {
69
+ ndjson += this.serialize(array[i]) + '\n'
70
+ }
71
+ }
72
+ return ndjson
73
+ }
74
+
75
+ qserialize (object) {
76
+ debug('qserialize', object)
77
+ if (object == null) return ''
78
+ if (typeof object === 'string') return object
79
+ // arrays should be serialized as comma separated list
80
+ const keys = Object.keys(object)
81
+ for (let i = 0, len = keys.length; i < len; i++) {
82
+ const key = keys[i]
83
+ // elasticsearch will complain for keys without a value
84
+ if (object[key] === undefined) {
85
+ delete object[key]
86
+ } else if (Array.isArray(object[key]) === true) {
87
+ object[key] = object[key].join(',')
88
+ }
89
+ }
90
+ return stringify(object)
91
+ }
92
+ }
93
+
94
+ module.exports = Serializer
@@ -0,0 +1,162 @@
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
+ */
19
+
20
+ import { Readable as ReadableStream } from 'stream';
21
+ import { ConnectionPool, CloudConnectionPool } from './pool';
22
+ import Connection from './Connection';
23
+ import Serializer from './Serializer';
24
+ import * as errors from './errors';
25
+
26
+ export type ApiError = errors.ConfigurationError | errors.ConnectionError |
27
+ errors.DeserializationError | errors.SerializationError |
28
+ errors.NoLivingConnectionsError | errors.ResponseError |
29
+ errors.TimeoutError | errors.RequestAbortedError |
30
+ errors.ProductNotSupportedError
31
+
32
+ export type Context = unknown
33
+
34
+ export interface nodeSelectorFn {
35
+ (connections: Connection[]): Connection;
36
+ }
37
+
38
+ export interface nodeFilterFn {
39
+ (connection: Connection): boolean;
40
+ }
41
+
42
+ export interface generateRequestIdFn {
43
+ (params: TransportRequestParams, options: TransportRequestOptions): any;
44
+ }
45
+
46
+ interface TransportOptions {
47
+ emit: (event: string | symbol, ...args: any[]) => boolean;
48
+ connectionPool: ConnectionPool | CloudConnectionPool;
49
+ serializer: Serializer;
50
+ maxRetries: number;
51
+ requestTimeout: number | string;
52
+ suggestCompression?: boolean;
53
+ compression?: 'gzip';
54
+ sniffInterval?: number;
55
+ sniffOnConnectionFault?: boolean;
56
+ sniffEndpoint: string;
57
+ sniffOnStart?: boolean;
58
+ nodeFilter?: nodeFilterFn;
59
+ nodeSelector?: string | nodeSelectorFn;
60
+ headers?: Record<string, any>;
61
+ generateRequestId?: generateRequestIdFn;
62
+ name?: string;
63
+ opaqueIdPrefix?: string;
64
+ }
65
+
66
+ export interface RequestEvent<TResponse = Record<string, any>, TContext = Context> {
67
+ body: TResponse;
68
+ statusCode: number | null;
69
+ headers: Record<string, any> | null;
70
+ warnings: string[] | null;
71
+ meta: {
72
+ context: TContext;
73
+ name: string | symbol;
74
+ request: {
75
+ params: TransportRequestParams;
76
+ options: TransportRequestOptions;
77
+ id: any;
78
+ };
79
+ connection: Connection;
80
+ attempts: number;
81
+ aborted: boolean;
82
+ sniff?: {
83
+ hosts: any[];
84
+ reason: string;
85
+ };
86
+ };
87
+ }
88
+
89
+ // ApiResponse and RequestEvent are the same thing
90
+ // we are doing this for have more clear names
91
+ export interface ApiResponse<TResponse = Record<string, any>, TContext = Context> extends RequestEvent<TResponse, TContext> {}
92
+
93
+ export type RequestBody<T = Record<string, any>> = T | string | Buffer | ReadableStream
94
+ export type RequestNDBody<T = Record<string, any>[]> = T | string | string[] | Buffer | ReadableStream
95
+
96
+ export interface TransportRequestParams {
97
+ method: string;
98
+ path: string;
99
+ body?: RequestBody;
100
+ bulkBody?: RequestNDBody;
101
+ querystring?: Record<string, any> | string;
102
+ }
103
+
104
+ export interface TransportRequestOptions {
105
+ ignore?: number[];
106
+ requestTimeout?: number | string;
107
+ maxRetries?: number;
108
+ asStream?: boolean;
109
+ headers?: Record<string, any>;
110
+ querystring?: Record<string, any>;
111
+ compression?: 'gzip';
112
+ id?: any;
113
+ context?: Context;
114
+ warnings?: string[];
115
+ opaqueId?: string;
116
+ }
117
+
118
+ export interface TransportRequestCallback {
119
+ abort: () => void;
120
+ }
121
+
122
+ export interface TransportRequestPromise<T> extends Promise<T> {
123
+ abort: () => void;
124
+ finally(onFinally?: (() => void) | undefined | null): Promise<T>;
125
+ }
126
+
127
+ export interface TransportGetConnectionOptions {
128
+ requestId: string;
129
+ }
130
+
131
+ export interface TransportSniffOptions {
132
+ reason: string;
133
+ requestId?: string;
134
+ }
135
+
136
+ export default class Transport {
137
+ static sniffReasons: {
138
+ SNIFF_ON_START: string;
139
+ SNIFF_INTERVAL: string;
140
+ SNIFF_ON_CONNECTION_FAULT: string;
141
+ DEFAULT: string;
142
+ };
143
+ emit: (event: string | symbol, ...args: any[]) => boolean;
144
+ connectionPool: ConnectionPool | CloudConnectionPool;
145
+ serializer: Serializer;
146
+ maxRetries: number;
147
+ requestTimeout: number;
148
+ suggestCompression: boolean;
149
+ compression: 'gzip' | false;
150
+ sniffInterval: number;
151
+ sniffOnConnectionFault: boolean;
152
+ opaqueIdPrefix: string | null;
153
+ sniffEndpoint: string;
154
+ _sniffEnabled: boolean;
155
+ _nextSniff: number;
156
+ _isSniffing: boolean;
157
+ constructor(opts: TransportOptions);
158
+ request<TResponse = Record<string, any>, TContext = Context>(params: TransportRequestParams, options?: TransportRequestOptions): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
159
+ request<TResponse = Record<string, any>, TContext = Context>(params: TransportRequestParams, options?: TransportRequestOptions, callback?: (err: ApiError, result: ApiResponse<TResponse, TContext>) => void): TransportRequestCallback;
160
+ getConnection(opts: TransportGetConnectionOptions): Connection | null;
161
+ sniff(opts?: TransportSniffOptions, callback?: (...args: any[]) => void): void;
162
+ }