@opensearch-project/opensearch 1.1.0 → 2.1.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/.eslintignore +2 -0
- package/.eslintrc.json +31 -0
- package/.prettierrc.json +5 -0
- package/.whitesource +15 -0
- package/ADMINS.md +13 -31
- package/CHANGELOG.md +24 -0
- package/COMPATIBILITY.md +27 -0
- package/DEVELOPER_GUIDE.md +22 -5
- package/MAINTAINERS.md +15 -70
- package/Makefile +2 -12
- package/README.md +19 -123
- package/RELEASING.md +3 -3
- package/SECURITY.md +1 -1
- package/USER_GUIDE.md +197 -0
- package/api/api/bulk.js +54 -28
- package/api/api/cat.js +355 -266
- package/api/api/clear_scroll.js +18 -19
- package/api/api/cluster.js +367 -221
- package/api/api/count.js +56 -26
- package/api/api/create.js +51 -26
- package/api/api/dangling_indices.js +96 -53
- package/api/api/delete.js +50 -24
- package/api/api/delete_by_query.js +89 -27
- package/api/api/delete_by_query_rethrottle.js +34 -21
- package/api/api/delete_script.js +32 -19
- package/api/api/exists.js +56 -24
- package/api/api/exists_source.js +61 -29
- package/api/api/explain.js +61 -24
- package/api/api/features.js +57 -37
- package/api/api/field_caps.js +37 -20
- package/api/api/get.js +56 -24
- package/api/api/get_script.js +31 -19
- package/api/api/get_script_context.js +16 -17
- package/api/api/get_script_languages.js +16 -17
- package/api/api/get_source.js +56 -24
- package/api/api/index.js +61 -30
- package/api/api/indices.js +1069 -859
- package/api/api/info.js +16 -17
- package/api/api/ingest.js +133 -98
- package/api/api/mget.js +51 -28
- package/api/api/msearch.js +50 -28
- package/api/api/msearch_template.js +54 -28
- package/api/api/mtermvectors.js +49 -26
- package/api/api/nodes.js +282 -156
- package/api/api/ping.js +16 -17
- package/api/api/put_script.js +41 -27
- package/api/api/rank_eval.js +38 -22
- package/api/api/reindex.js +39 -19
- package/api/api/reindex_rethrottle.js +33 -21
- package/api/api/render_search_template.js +19 -20
- package/api/api/scripts_painless_execute.js +16 -17
- package/api/api/scroll.js +32 -19
- package/api/api/search.js +109 -26
- package/api/api/search_shards.js +37 -20
- package/api/api/search_template.js +65 -28
- package/api/api/shutdown.js +67 -56
- package/api/api/snapshot.js +348 -226
- package/api/api/tasks.js +66 -48
- package/api/api/terms_enum.js +18 -19
- package/api/api/termvectors.js +58 -28
- package/api/api/update.js +65 -26
- package/api/api/update_by_query.js +90 -25
- package/api/api/update_by_query_rethrottle.js +34 -21
- package/api/index.js +268 -181
- package/api/new.d.ts +2043 -531
- package/api/opensearch_dashboards.d.ts +240 -238
- package/api/requestParams.d.ts +302 -71
- package/api/types.d.ts +6205 -5721
- package/api/utils.js +23 -24
- package/codecov.yml +2 -2
- package/index.d.ts +5203 -1037
- package/index.js +154 -143
- package/index.mjs +10 -11
- package/jenkins/release.JenkinsFile +11 -0
- package/lib/Connection.d.ts +38 -28
- package/lib/Connection.js +166 -170
- package/lib/Helpers.d.ts +108 -68
- package/lib/Helpers.js +401 -378
- package/lib/Serializer.d.ts +3 -4
- package/lib/Serializer.js +40 -41
- package/lib/Transport.d.ts +39 -15
- package/lib/Transport.js +381 -337
- package/lib/aws/AwsSigv4Signer.js +167 -0
- package/lib/aws/errors.js +24 -0
- package/lib/aws/index.d.ts +39 -0
- package/lib/aws/index.js +19 -0
- package/lib/errors.d.ts +26 -9
- package/lib/errors.js +76 -73
- package/lib/pool/BaseConnectionPool.js +101 -99
- package/lib/pool/CloudConnectionPool.js +17 -18
- package/lib/pool/ConnectionPool.js +106 -107
- package/lib/pool/index.d.ts +9 -8
- package/lib/pool/index.js +7 -8
- package/package.json +37 -15
package/lib/Serializer.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
2
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
3
4
|
*
|
|
4
5
|
* The OpenSearch Contributors require contributions made to
|
|
5
6
|
* this file be licensed under the Apache-2.0 license or a
|
|
6
7
|
* compatible open source license.
|
|
7
8
|
*
|
|
8
|
-
* Modifications Copyright OpenSearch Contributors. See
|
|
9
|
-
* GitHub history for details.
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
11
|
/*
|
|
@@ -29,11 +28,11 @@
|
|
|
29
28
|
*/
|
|
30
29
|
|
|
31
30
|
export interface SerializerOptions {
|
|
32
|
-
disablePrototypePoisoningProtection: boolean | 'proto' | 'constructor'
|
|
31
|
+
disablePrototypePoisoningProtection: boolean | 'proto' | 'constructor';
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
export default class Serializer {
|
|
36
|
-
constructor(opts?: SerializerOptions)
|
|
35
|
+
constructor(opts?: SerializerOptions);
|
|
37
36
|
serialize(object: any): string;
|
|
38
37
|
deserialize(json: string): any;
|
|
39
38
|
ndserialize(array: any[]): string;
|
package/lib/Serializer.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
2
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
3
4
|
*
|
|
4
5
|
* The OpenSearch Contributors require contributions made to
|
|
5
6
|
* this file be licensed under the Apache-2.0 license or a
|
|
6
7
|
* compatible open source license.
|
|
7
8
|
*
|
|
8
|
-
* Modifications Copyright OpenSearch Contributors. See
|
|
9
|
-
* GitHub history for details.
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
11
|
/*
|
|
@@ -28,78 +27,78 @@
|
|
|
28
27
|
* under the License.
|
|
29
28
|
*/
|
|
30
29
|
|
|
31
|
-
'use strict'
|
|
30
|
+
'use strict';
|
|
32
31
|
|
|
33
|
-
const { stringify } = require('querystring')
|
|
34
|
-
const debug = require('debug')('opensearch')
|
|
35
|
-
const sjson = require('secure-json-parse')
|
|
36
|
-
const { SerializationError, DeserializationError } = require('./errors')
|
|
37
|
-
const kJsonOptions = Symbol('secure json parse options')
|
|
32
|
+
const { stringify } = require('querystring');
|
|
33
|
+
const debug = require('debug')('opensearch');
|
|
34
|
+
const sjson = require('secure-json-parse');
|
|
35
|
+
const { SerializationError, DeserializationError } = require('./errors');
|
|
36
|
+
const kJsonOptions = Symbol('secure json parse options');
|
|
38
37
|
|
|
39
38
|
class Serializer {
|
|
40
|
-
constructor
|
|
41
|
-
const disable = opts.disablePrototypePoisoningProtection
|
|
39
|
+
constructor(opts = {}) {
|
|
40
|
+
const disable = opts.disablePrototypePoisoningProtection;
|
|
42
41
|
this[kJsonOptions] = {
|
|
43
42
|
protoAction: disable === true || disable === 'proto' ? 'ignore' : 'error',
|
|
44
|
-
constructorAction: disable === true || disable === 'constructor' ? 'ignore' : 'error'
|
|
45
|
-
}
|
|
43
|
+
constructorAction: disable === true || disable === 'constructor' ? 'ignore' : 'error',
|
|
44
|
+
};
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
serialize
|
|
49
|
-
debug('Serializing', object)
|
|
50
|
-
let json
|
|
47
|
+
serialize(object) {
|
|
48
|
+
debug('Serializing', object);
|
|
49
|
+
let json;
|
|
51
50
|
try {
|
|
52
|
-
json = JSON.stringify(object)
|
|
51
|
+
json = JSON.stringify(object);
|
|
53
52
|
} catch (err) {
|
|
54
|
-
throw new SerializationError(err.message, object)
|
|
53
|
+
throw new SerializationError(err.message, object);
|
|
55
54
|
}
|
|
56
|
-
return json
|
|
55
|
+
return json;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
deserialize
|
|
60
|
-
debug('Deserializing', json)
|
|
61
|
-
let object
|
|
58
|
+
deserialize(json) {
|
|
59
|
+
debug('Deserializing', json);
|
|
60
|
+
let object;
|
|
62
61
|
try {
|
|
63
|
-
object = sjson.parse(json, this[kJsonOptions])
|
|
62
|
+
object = sjson.parse(json, this[kJsonOptions]);
|
|
64
63
|
} catch (err) {
|
|
65
|
-
throw new DeserializationError(err.message, json)
|
|
64
|
+
throw new DeserializationError(err.message, json);
|
|
66
65
|
}
|
|
67
|
-
return object
|
|
66
|
+
return object;
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
ndserialize
|
|
71
|
-
debug('ndserialize', array)
|
|
69
|
+
ndserialize(array) {
|
|
70
|
+
debug('ndserialize', array);
|
|
72
71
|
if (Array.isArray(array) === false) {
|
|
73
|
-
throw new SerializationError('The argument provided is not an array')
|
|
72
|
+
throw new SerializationError('The argument provided is not an array');
|
|
74
73
|
}
|
|
75
|
-
let ndjson = ''
|
|
74
|
+
let ndjson = '';
|
|
76
75
|
for (let i = 0, len = array.length; i < len; i++) {
|
|
77
76
|
if (typeof array[i] === 'string') {
|
|
78
|
-
ndjson += array[i] + '\n'
|
|
77
|
+
ndjson += array[i] + '\n';
|
|
79
78
|
} else {
|
|
80
|
-
ndjson += this.serialize(array[i]) + '\n'
|
|
79
|
+
ndjson += this.serialize(array[i]) + '\n';
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
|
-
return ndjson
|
|
82
|
+
return ndjson;
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
qserialize
|
|
87
|
-
debug('qserialize', object)
|
|
88
|
-
if (object == null) return ''
|
|
89
|
-
if (typeof object === 'string') return object
|
|
85
|
+
qserialize(object) {
|
|
86
|
+
debug('qserialize', object);
|
|
87
|
+
if (object == null) return '';
|
|
88
|
+
if (typeof object === 'string') return object;
|
|
90
89
|
// arrays should be serialized as comma separated list
|
|
91
|
-
const keys = Object.keys(object)
|
|
90
|
+
const keys = Object.keys(object);
|
|
92
91
|
for (let i = 0, len = keys.length; i < len; i++) {
|
|
93
|
-
const key = keys[i]
|
|
92
|
+
const key = keys[i];
|
|
94
93
|
// OpenSearch will complain for keys without a value
|
|
95
94
|
if (object[key] === undefined) {
|
|
96
|
-
delete object[key]
|
|
95
|
+
delete object[key];
|
|
97
96
|
} else if (Array.isArray(object[key]) === true) {
|
|
98
|
-
object[key] = object[key].join(',')
|
|
97
|
+
object[key] = object[key].join(',');
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
|
-
return stringify(object)
|
|
100
|
+
return stringify(object);
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
|
|
105
|
-
module.exports = Serializer
|
|
104
|
+
module.exports = Serializer;
|
package/lib/Transport.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
2
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
3
4
|
*
|
|
4
5
|
* The OpenSearch Contributors require contributions made to
|
|
5
6
|
* this file be licensed under the Apache-2.0 license or a
|
|
6
7
|
* compatible open source license.
|
|
7
8
|
*
|
|
8
|
-
* Modifications Copyright OpenSearch Contributors. See
|
|
9
|
-
* GitHub history for details.
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
11
|
/*
|
|
@@ -29,18 +28,23 @@
|
|
|
29
28
|
*/
|
|
30
29
|
|
|
31
30
|
import { Readable as ReadableStream } from 'stream';
|
|
32
|
-
import { ConnectionPool, CloudConnectionPool } from './pool';
|
|
33
31
|
import Connection from './Connection';
|
|
34
|
-
import Serializer from './Serializer';
|
|
35
32
|
import * as errors from './errors';
|
|
33
|
+
import { CloudConnectionPool, ConnectionPool } from './pool';
|
|
34
|
+
import Serializer from './Serializer';
|
|
36
35
|
|
|
37
|
-
export type ApiError =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
errors.
|
|
36
|
+
export type ApiError =
|
|
37
|
+
| errors.ConfigurationError
|
|
38
|
+
| errors.ConnectionError
|
|
39
|
+
| errors.DeserializationError
|
|
40
|
+
| errors.SerializationError
|
|
41
|
+
| errors.NoLivingConnectionsError
|
|
42
|
+
| errors.ResponseError
|
|
43
|
+
| errors.TimeoutError
|
|
44
|
+
| errors.RequestAbortedError
|
|
45
|
+
| errors.NotCompatibleError;
|
|
42
46
|
|
|
43
|
-
export type Context = unknown
|
|
47
|
+
export type Context = unknown;
|
|
44
48
|
|
|
45
49
|
export interface nodeSelectorFn {
|
|
46
50
|
(connections: Connection[]): Connection;
|
|
@@ -54,6 +58,11 @@ export interface generateRequestIdFn {
|
|
|
54
58
|
(params: TransportRequestParams, options: TransportRequestOptions): any;
|
|
55
59
|
}
|
|
56
60
|
|
|
61
|
+
export interface MemoryCircuitBreakerOptions {
|
|
62
|
+
enabled: boolean;
|
|
63
|
+
maxPercentage: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
57
66
|
interface TransportOptions {
|
|
58
67
|
emit: (event: string | symbol, ...args: any[]) => boolean;
|
|
59
68
|
connectionPool: ConnectionPool | CloudConnectionPool;
|
|
@@ -72,6 +81,7 @@ interface TransportOptions {
|
|
|
72
81
|
generateRequestId?: generateRequestIdFn;
|
|
73
82
|
name?: string;
|
|
74
83
|
opaqueIdPrefix?: string;
|
|
84
|
+
memoryCircuitBreaker?: MemoryCircuitBreakerOptions;
|
|
75
85
|
}
|
|
76
86
|
|
|
77
87
|
export interface RequestEvent<TResponse = Record<string, any>, TContext = Context> {
|
|
@@ -99,10 +109,16 @@ export interface RequestEvent<TResponse = Record<string, any>, TContext = Contex
|
|
|
99
109
|
|
|
100
110
|
// ApiResponse and RequestEvent are the same thing
|
|
101
111
|
// we are doing this for have more clear names
|
|
102
|
-
export interface ApiResponse<TResponse = Record<string, any>, TContext = Context>
|
|
112
|
+
export interface ApiResponse<TResponse = Record<string, any>, TContext = Context>
|
|
113
|
+
extends RequestEvent<TResponse, TContext> {}
|
|
103
114
|
|
|
104
|
-
export type RequestBody<T = Record<string, any>> = T | string | Buffer | ReadableStream
|
|
105
|
-
export type RequestNDBody<T = Record<string, any>[]> =
|
|
115
|
+
export type RequestBody<T = Record<string, any>> = T | string | Buffer | ReadableStream;
|
|
116
|
+
export type RequestNDBody<T = Record<string, any>[]> =
|
|
117
|
+
| T
|
|
118
|
+
| string
|
|
119
|
+
| string[]
|
|
120
|
+
| Buffer
|
|
121
|
+
| ReadableStream;
|
|
106
122
|
|
|
107
123
|
export interface TransportRequestParams {
|
|
108
124
|
method: string;
|
|
@@ -161,13 +177,21 @@ export default class Transport {
|
|
|
161
177
|
sniffInterval: number;
|
|
162
178
|
sniffOnConnectionFault: boolean;
|
|
163
179
|
opaqueIdPrefix: string | null;
|
|
180
|
+
memoryCircuitBreaker: MemoryCircuitBreakerOptions | undefined;
|
|
164
181
|
sniffEndpoint: string;
|
|
165
182
|
_sniffEnabled: boolean;
|
|
166
183
|
_nextSniff: number;
|
|
167
184
|
_isSniffing: boolean;
|
|
168
185
|
constructor(opts: TransportOptions);
|
|
169
|
-
request(
|
|
170
|
-
|
|
186
|
+
request(
|
|
187
|
+
params: TransportRequestParams,
|
|
188
|
+
options?: TransportRequestOptions
|
|
189
|
+
): TransportRequestPromise<ApiResponse>;
|
|
190
|
+
request(
|
|
191
|
+
params: TransportRequestParams,
|
|
192
|
+
options?: TransportRequestOptions,
|
|
193
|
+
callback?: (err: ApiError, result: ApiResponse) => void
|
|
194
|
+
): TransportRequestCallback;
|
|
171
195
|
getConnection(opts: TransportGetConnectionOptions): Connection | null;
|
|
172
196
|
sniff(opts?: TransportSniffOptions, callback?: (...args: any[]) => void): void;
|
|
173
197
|
}
|