@opensearch-project/opensearch 1.1.0 → 2.0.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 +26 -0
- package/.prettierrc.json +5 -0
- package/.whitesource +15 -0
- package/ADMINS.md +18 -11
- package/COMPATIBILITY.md +24 -0
- package/DEVELOPER_GUIDE.md +22 -5
- package/MAINTAINERS.md +23 -18
- package/README.md +100 -101
- package/RELEASING.md +3 -3
- package/SECURITY.md +1 -1
- package/api/api/bulk.js +53 -26
- package/api/api/cat.js +354 -264
- package/api/api/clear_scroll.js +17 -17
- package/api/api/cluster.js +366 -219
- package/api/api/count.js +55 -24
- package/api/api/create.js +50 -24
- package/api/api/dangling_indices.js +95 -51
- package/api/api/delete.js +49 -22
- package/api/api/delete_by_query.js +88 -25
- package/api/api/delete_by_query_rethrottle.js +33 -19
- package/api/api/delete_script.js +31 -17
- package/api/api/exists.js +55 -22
- package/api/api/exists_source.js +60 -27
- package/api/api/explain.js +60 -22
- package/api/api/features.js +56 -35
- package/api/api/field_caps.js +36 -18
- package/api/api/get.js +55 -22
- package/api/api/get_script.js +30 -17
- package/api/api/get_script_context.js +15 -15
- package/api/api/get_script_languages.js +15 -15
- package/api/api/get_source.js +55 -22
- package/api/api/index.js +60 -28
- package/api/api/indices.js +1068 -857
- package/api/api/info.js +15 -15
- package/api/api/ingest.js +132 -96
- package/api/api/mget.js +50 -26
- package/api/api/msearch.js +49 -26
- package/api/api/msearch_template.js +53 -26
- package/api/api/mtermvectors.js +48 -24
- package/api/api/nodes.js +281 -154
- package/api/api/ping.js +15 -15
- package/api/api/put_script.js +40 -25
- package/api/api/rank_eval.js +37 -20
- package/api/api/reindex.js +38 -17
- package/api/api/reindex_rethrottle.js +32 -19
- package/api/api/render_search_template.js +18 -18
- package/api/api/scripts_painless_execute.js +15 -15
- package/api/api/scroll.js +31 -17
- package/api/api/search.js +108 -24
- package/api/api/search_shards.js +36 -18
- package/api/api/search_template.js +64 -26
- package/api/api/shutdown.js +66 -54
- package/api/api/snapshot.js +347 -224
- package/api/api/tasks.js +65 -46
- package/api/api/terms_enum.js +17 -17
- package/api/api/termvectors.js +57 -26
- package/api/api/update.js +64 -24
- package/api/api/update_by_query.js +89 -23
- package/api/api/update_by_query_rethrottle.js +33 -19
- package/api/index.js +267 -179
- package/api/new.d.ts +2042 -529
- package/api/opensearch_dashboards.d.ts +239 -236
- package/api/requestParams.d.ts +301 -69
- package/api/types.d.ts +6204 -5719
- package/api/utils.js +22 -22
- package/codecov.yml +2 -2
- package/index.d.ts +4776 -935
- package/index.js +152 -140
- package/index.mjs +9 -9
- package/lib/Connection.d.ts +37 -26
- package/lib/Connection.js +163 -168
- package/lib/Helpers.d.ts +103 -64
- package/lib/Helpers.js +398 -371
- package/lib/Serializer.d.ts +2 -2
- package/lib/Serializer.js +39 -39
- package/lib/Transport.d.ts +30 -12
- package/lib/Transport.js +375 -336
- package/lib/errors.d.ts +25 -7
- package/lib/errors.js +75 -71
- package/lib/pool/BaseConnectionPool.js +100 -97
- package/lib/pool/CloudConnectionPool.js +16 -16
- package/lib/pool/ConnectionPool.js +105 -105
- package/lib/pool/index.d.ts +8 -6
- package/lib/pool/index.js +6 -6
- package/package.json +13 -8
package/lib/Serializer.d.ts
CHANGED
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
export interface SerializerOptions {
|
|
32
|
-
disablePrototypePoisoningProtection: boolean | 'proto' | 'constructor'
|
|
32
|
+
disablePrototypePoisoningProtection: boolean | 'proto' | 'constructor';
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export default class Serializer {
|
|
36
|
-
constructor(opts?: SerializerOptions)
|
|
36
|
+
constructor(opts?: SerializerOptions);
|
|
37
37
|
serialize(object: any): string;
|
|
38
38
|
deserialize(json: string): any;
|
|
39
39
|
ndserialize(array: any[]): string;
|
package/lib/Serializer.js
CHANGED
|
@@ -28,78 +28,78 @@
|
|
|
28
28
|
* under the License.
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
'use strict'
|
|
31
|
+
'use strict';
|
|
32
32
|
|
|
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')
|
|
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');
|
|
38
38
|
|
|
39
39
|
class Serializer {
|
|
40
|
-
constructor
|
|
41
|
-
const disable = opts.disablePrototypePoisoningProtection
|
|
40
|
+
constructor(opts = {}) {
|
|
41
|
+
const disable = opts.disablePrototypePoisoningProtection;
|
|
42
42
|
this[kJsonOptions] = {
|
|
43
43
|
protoAction: disable === true || disable === 'proto' ? 'ignore' : 'error',
|
|
44
|
-
constructorAction: disable === true || disable === 'constructor' ? 'ignore' : 'error'
|
|
45
|
-
}
|
|
44
|
+
constructorAction: disable === true || disable === 'constructor' ? 'ignore' : 'error',
|
|
45
|
+
};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
serialize
|
|
49
|
-
debug('Serializing', object)
|
|
50
|
-
let json
|
|
48
|
+
serialize(object) {
|
|
49
|
+
debug('Serializing', object);
|
|
50
|
+
let json;
|
|
51
51
|
try {
|
|
52
|
-
json = JSON.stringify(object)
|
|
52
|
+
json = JSON.stringify(object);
|
|
53
53
|
} catch (err) {
|
|
54
|
-
throw new SerializationError(err.message, object)
|
|
54
|
+
throw new SerializationError(err.message, object);
|
|
55
55
|
}
|
|
56
|
-
return json
|
|
56
|
+
return json;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
deserialize
|
|
60
|
-
debug('Deserializing', json)
|
|
61
|
-
let object
|
|
59
|
+
deserialize(json) {
|
|
60
|
+
debug('Deserializing', json);
|
|
61
|
+
let object;
|
|
62
62
|
try {
|
|
63
|
-
object = sjson.parse(json, this[kJsonOptions])
|
|
63
|
+
object = sjson.parse(json, this[kJsonOptions]);
|
|
64
64
|
} catch (err) {
|
|
65
|
-
throw new DeserializationError(err.message, json)
|
|
65
|
+
throw new DeserializationError(err.message, json);
|
|
66
66
|
}
|
|
67
|
-
return object
|
|
67
|
+
return object;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
ndserialize
|
|
71
|
-
debug('ndserialize', array)
|
|
70
|
+
ndserialize(array) {
|
|
71
|
+
debug('ndserialize', array);
|
|
72
72
|
if (Array.isArray(array) === false) {
|
|
73
|
-
throw new SerializationError('The argument provided is not an array')
|
|
73
|
+
throw new SerializationError('The argument provided is not an array');
|
|
74
74
|
}
|
|
75
|
-
let ndjson = ''
|
|
75
|
+
let ndjson = '';
|
|
76
76
|
for (let i = 0, len = array.length; i < len; i++) {
|
|
77
77
|
if (typeof array[i] === 'string') {
|
|
78
|
-
ndjson += array[i] + '\n'
|
|
78
|
+
ndjson += array[i] + '\n';
|
|
79
79
|
} else {
|
|
80
|
-
ndjson += this.serialize(array[i]) + '\n'
|
|
80
|
+
ndjson += this.serialize(array[i]) + '\n';
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
return ndjson
|
|
83
|
+
return ndjson;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
qserialize
|
|
87
|
-
debug('qserialize', object)
|
|
88
|
-
if (object == null) return ''
|
|
89
|
-
if (typeof object === 'string') return object
|
|
86
|
+
qserialize(object) {
|
|
87
|
+
debug('qserialize', object);
|
|
88
|
+
if (object == null) return '';
|
|
89
|
+
if (typeof object === 'string') return object;
|
|
90
90
|
// arrays should be serialized as comma separated list
|
|
91
|
-
const keys = Object.keys(object)
|
|
91
|
+
const keys = Object.keys(object);
|
|
92
92
|
for (let i = 0, len = keys.length; i < len; i++) {
|
|
93
|
-
const key = keys[i]
|
|
93
|
+
const key = keys[i];
|
|
94
94
|
// OpenSearch will complain for keys without a value
|
|
95
95
|
if (object[key] === undefined) {
|
|
96
|
-
delete object[key]
|
|
96
|
+
delete object[key];
|
|
97
97
|
} else if (Array.isArray(object[key]) === true) {
|
|
98
|
-
object[key] = object[key].join(',')
|
|
98
|
+
object[key] = object[key].join(',');
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
return stringify(object)
|
|
101
|
+
return stringify(object);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
module.exports = Serializer
|
|
105
|
+
module.exports = Serializer;
|
package/lib/Transport.d.ts
CHANGED
|
@@ -34,13 +34,18 @@ import Connection from './Connection';
|
|
|
34
34
|
import Serializer from './Serializer';
|
|
35
35
|
import * as errors from './errors';
|
|
36
36
|
|
|
37
|
-
export type ApiError =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
errors.
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
export type ApiError =
|
|
38
|
+
| errors.ConfigurationError
|
|
39
|
+
| errors.ConnectionError
|
|
40
|
+
| errors.DeserializationError
|
|
41
|
+
| errors.SerializationError
|
|
42
|
+
| errors.NoLivingConnectionsError
|
|
43
|
+
| errors.ResponseError
|
|
44
|
+
| errors.TimeoutError
|
|
45
|
+
| errors.RequestAbortedError
|
|
46
|
+
| errors.NotCompatibleError;
|
|
47
|
+
|
|
48
|
+
export type Context = unknown;
|
|
44
49
|
|
|
45
50
|
export interface nodeSelectorFn {
|
|
46
51
|
(connections: Connection[]): Connection;
|
|
@@ -99,10 +104,16 @@ export interface RequestEvent<TResponse = Record<string, any>, TContext = Contex
|
|
|
99
104
|
|
|
100
105
|
// ApiResponse and RequestEvent are the same thing
|
|
101
106
|
// we are doing this for have more clear names
|
|
102
|
-
export interface ApiResponse<TResponse = Record<string, any>, TContext = Context>
|
|
107
|
+
export interface ApiResponse<TResponse = Record<string, any>, TContext = Context>
|
|
108
|
+
extends RequestEvent<TResponse, TContext> {}
|
|
103
109
|
|
|
104
|
-
export type RequestBody<T = Record<string, any>> = T | string | Buffer | ReadableStream
|
|
105
|
-
export type RequestNDBody<T = Record<string, any>[]> =
|
|
110
|
+
export type RequestBody<T = Record<string, any>> = T | string | Buffer | ReadableStream;
|
|
111
|
+
export type RequestNDBody<T = Record<string, any>[]> =
|
|
112
|
+
| T
|
|
113
|
+
| string
|
|
114
|
+
| string[]
|
|
115
|
+
| Buffer
|
|
116
|
+
| ReadableStream;
|
|
106
117
|
|
|
107
118
|
export interface TransportRequestParams {
|
|
108
119
|
method: string;
|
|
@@ -166,8 +177,15 @@ export default class Transport {
|
|
|
166
177
|
_nextSniff: number;
|
|
167
178
|
_isSniffing: boolean;
|
|
168
179
|
constructor(opts: TransportOptions);
|
|
169
|
-
request(
|
|
170
|
-
|
|
180
|
+
request(
|
|
181
|
+
params: TransportRequestParams,
|
|
182
|
+
options?: TransportRequestOptions
|
|
183
|
+
): TransportRequestPromise<ApiResponse>;
|
|
184
|
+
request(
|
|
185
|
+
params: TransportRequestParams,
|
|
186
|
+
options?: TransportRequestOptions,
|
|
187
|
+
callback?: (err: ApiError, result: ApiResponse) => void
|
|
188
|
+
): TransportRequestCallback;
|
|
171
189
|
getConnection(opts: TransportGetConnectionOptions): Connection | null;
|
|
172
190
|
sniff(opts?: TransportSniffOptions, callback?: (...args: any[]) => void): void;
|
|
173
191
|
}
|