@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.
- package/.dockerignore +5 -0
- package/LICENSE +202 -0
- package/README.md +232 -0
- package/api/api/async_search.js +141 -0
- package/api/api/autoscaling.js +147 -0
- package/api/api/bulk.js +70 -0
- package/api/api/cat.js +648 -0
- package/api/api/ccr.js +403 -0
- package/api/api/clear_scroll.js +55 -0
- package/api/api/close_point_in_time.js +50 -0
- package/api/api/cluster.js +420 -0
- package/api/api/count.js +64 -0
- package/api/api/create.js +69 -0
- package/api/api/dangling_indices.js +115 -0
- package/api/api/delete.js +65 -0
- package/api/api/delete_by_query.js +71 -0
- package/api/api/delete_by_query_rethrottle.js +60 -0
- package/api/api/delete_script.js +56 -0
- package/api/api/enrich.js +173 -0
- package/api/api/eql.js +150 -0
- package/api/api/exists.js +65 -0
- package/api/api/exists_source.js +74 -0
- package/api/api/explain.js +65 -0
- package/api/api/features.js +81 -0
- package/api/api/field_caps.js +55 -0
- package/api/api/fleet.js +65 -0
- package/api/api/get.js +65 -0
- package/api/api/get_script.js +56 -0
- package/api/api/get_script_context.js +50 -0
- package/api/api/get_script_languages.js +50 -0
- package/api/api/get_source.js +65 -0
- package/api/api/graph.js +72 -0
- package/api/api/ilm.js +317 -0
- package/api/api/index.js +71 -0
- package/api/api/indices.js +1753 -0
- package/api/api/info.js +50 -0
- package/api/api/ingest.js +200 -0
- package/api/api/license.js +188 -0
- package/api/api/logstash.js +125 -0
- package/api/api/mget.js +70 -0
- package/api/api/migration.js +60 -0
- package/api/api/ml.js +2010 -0
- package/api/api/monitoring.js +66 -0
- package/api/api/msearch.js +70 -0
- package/api/api/msearch_template.js +70 -0
- package/api/api/mtermvectors.js +64 -0
- package/api/api/nodes.js +268 -0
- package/api/api/open_point_in_time.js +56 -0
- package/api/api/ping.js +50 -0
- package/api/api/put_script.js +71 -0
- package/api/api/rank_eval.js +61 -0
- package/api/api/reindex.js +56 -0
- package/api/api/reindex_rethrottle.js +60 -0
- package/api/api/render_search_template.js +55 -0
- package/api/api/rollup.js +319 -0
- package/api/api/scripts_painless_execute.js +50 -0
- package/api/api/scroll.js +55 -0
- package/api/api/search.js +64 -0
- package/api/api/search_mvt.js +87 -0
- package/api/api/search_shards.js +55 -0
- package/api/api/search_template.js +70 -0
- package/api/api/searchable_snapshots.js +186 -0
- package/api/api/security.js +1261 -0
- package/api/api/shutdown.js +124 -0
- package/api/api/slm.js +256 -0
- package/api/api/snapshot.js +439 -0
- package/api/api/sql.js +203 -0
- package/api/api/ssl.js +55 -0
- package/api/api/tasks.js +108 -0
- package/api/api/terms_enum.js +56 -0
- package/api/api/termvectors.js +67 -0
- package/api/api/text_structure.js +65 -0
- package/api/api/transform.js +268 -0
- package/api/api/update.js +69 -0
- package/api/api/update_by_query.js +67 -0
- package/api/api/update_by_query_rethrottle.js +60 -0
- package/api/api/watcher.js +333 -0
- package/api/api/xpack.js +76 -0
- package/api/index.js +508 -0
- package/api/new.d.ts +1585 -0
- package/api/requestParams.d.ts +2920 -0
- package/api/types.d.ts +15420 -0
- package/api/utils.js +58 -0
- package/codecov.yml +14 -0
- package/index.d.ts +2991 -0
- package/index.js +349 -0
- package/index.mjs +29 -0
- package/lib/Connection.d.ts +99 -0
- package/lib/Connection.js +392 -0
- package/lib/Helpers.d.ts +124 -0
- package/lib/Helpers.js +770 -0
- package/lib/Serializer.d.ts +30 -0
- package/lib/Serializer.js +94 -0
- package/lib/Transport.d.ts +162 -0
- package/lib/Transport.js +689 -0
- package/lib/errors.d.ts +90 -0
- package/lib/errors.js +159 -0
- package/lib/pool/BaseConnectionPool.js +262 -0
- package/lib/pool/CloudConnectionPool.js +64 -0
- package/lib/pool/ConnectionPool.js +246 -0
- package/lib/pool/index.d.ts +220 -0
- package/lib/pool/index.js +30 -0
- 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
|
+
}
|