@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.
Files changed (94) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.json +31 -0
  3. package/.prettierrc.json +5 -0
  4. package/.whitesource +15 -0
  5. package/ADMINS.md +13 -31
  6. package/CHANGELOG.md +24 -0
  7. package/COMPATIBILITY.md +27 -0
  8. package/DEVELOPER_GUIDE.md +22 -5
  9. package/MAINTAINERS.md +15 -70
  10. package/Makefile +2 -12
  11. package/README.md +19 -123
  12. package/RELEASING.md +3 -3
  13. package/SECURITY.md +1 -1
  14. package/USER_GUIDE.md +197 -0
  15. package/api/api/bulk.js +54 -28
  16. package/api/api/cat.js +355 -266
  17. package/api/api/clear_scroll.js +18 -19
  18. package/api/api/cluster.js +367 -221
  19. package/api/api/count.js +56 -26
  20. package/api/api/create.js +51 -26
  21. package/api/api/dangling_indices.js +96 -53
  22. package/api/api/delete.js +50 -24
  23. package/api/api/delete_by_query.js +89 -27
  24. package/api/api/delete_by_query_rethrottle.js +34 -21
  25. package/api/api/delete_script.js +32 -19
  26. package/api/api/exists.js +56 -24
  27. package/api/api/exists_source.js +61 -29
  28. package/api/api/explain.js +61 -24
  29. package/api/api/features.js +57 -37
  30. package/api/api/field_caps.js +37 -20
  31. package/api/api/get.js +56 -24
  32. package/api/api/get_script.js +31 -19
  33. package/api/api/get_script_context.js +16 -17
  34. package/api/api/get_script_languages.js +16 -17
  35. package/api/api/get_source.js +56 -24
  36. package/api/api/index.js +61 -30
  37. package/api/api/indices.js +1069 -859
  38. package/api/api/info.js +16 -17
  39. package/api/api/ingest.js +133 -98
  40. package/api/api/mget.js +51 -28
  41. package/api/api/msearch.js +50 -28
  42. package/api/api/msearch_template.js +54 -28
  43. package/api/api/mtermvectors.js +49 -26
  44. package/api/api/nodes.js +282 -156
  45. package/api/api/ping.js +16 -17
  46. package/api/api/put_script.js +41 -27
  47. package/api/api/rank_eval.js +38 -22
  48. package/api/api/reindex.js +39 -19
  49. package/api/api/reindex_rethrottle.js +33 -21
  50. package/api/api/render_search_template.js +19 -20
  51. package/api/api/scripts_painless_execute.js +16 -17
  52. package/api/api/scroll.js +32 -19
  53. package/api/api/search.js +109 -26
  54. package/api/api/search_shards.js +37 -20
  55. package/api/api/search_template.js +65 -28
  56. package/api/api/shutdown.js +67 -56
  57. package/api/api/snapshot.js +348 -226
  58. package/api/api/tasks.js +66 -48
  59. package/api/api/terms_enum.js +18 -19
  60. package/api/api/termvectors.js +58 -28
  61. package/api/api/update.js +65 -26
  62. package/api/api/update_by_query.js +90 -25
  63. package/api/api/update_by_query_rethrottle.js +34 -21
  64. package/api/index.js +268 -181
  65. package/api/new.d.ts +2043 -531
  66. package/api/opensearch_dashboards.d.ts +240 -238
  67. package/api/requestParams.d.ts +302 -71
  68. package/api/types.d.ts +6205 -5721
  69. package/api/utils.js +23 -24
  70. package/codecov.yml +2 -2
  71. package/index.d.ts +5203 -1037
  72. package/index.js +154 -143
  73. package/index.mjs +10 -11
  74. package/jenkins/release.JenkinsFile +11 -0
  75. package/lib/Connection.d.ts +38 -28
  76. package/lib/Connection.js +166 -170
  77. package/lib/Helpers.d.ts +108 -68
  78. package/lib/Helpers.js +401 -378
  79. package/lib/Serializer.d.ts +3 -4
  80. package/lib/Serializer.js +40 -41
  81. package/lib/Transport.d.ts +39 -15
  82. package/lib/Transport.js +381 -337
  83. package/lib/aws/AwsSigv4Signer.js +167 -0
  84. package/lib/aws/errors.js +24 -0
  85. package/lib/aws/index.d.ts +39 -0
  86. package/lib/aws/index.js +19 -0
  87. package/lib/errors.d.ts +26 -9
  88. package/lib/errors.js +76 -73
  89. package/lib/pool/BaseConnectionPool.js +101 -99
  90. package/lib/pool/CloudConnectionPool.js +17 -18
  91. package/lib/pool/ConnectionPool.js +106 -107
  92. package/lib/pool/index.d.ts +9 -8
  93. package/lib/pool/index.js +7 -8
  94. package/package.json +37 -15
package/lib/Helpers.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
  /*
@@ -28,109 +27,150 @@
28
27
  * under the License.
29
28
  */
30
29
 
31
- import { Readable as ReadableStream } from 'stream'
32
- import { TransportRequestOptions, ApiError, ApiResponse, RequestBody, Context } from './Transport'
33
- import { Search, Msearch, Bulk } from '../api/requestParams'
30
+ import { Readable as ReadableStream } from 'stream';
31
+ import { TransportRequestOptions, ApiError, ApiResponse, RequestBody, Context } from './Transport';
32
+ import { Search, Msearch, Bulk } from '../api/requestParams';
34
33
 
35
34
  export default class Helpers {
36
- search<TDocument = unknown, TRequestBody extends RequestBody = Record<string, any>>(params: Search<TRequestBody>, options?: TransportRequestOptions): Promise<TDocument[]>
37
- scrollSearch<TDocument = unknown, TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(params: Search<TRequestBody>, options?: TransportRequestOptions): AsyncIterable<ScrollSearchResponse<TDocument, TResponse, TContext>>
38
- scrollDocuments<TDocument = unknown, TRequestBody extends RequestBody = Record<string, any>>(params: Search<TRequestBody>, options?: TransportRequestOptions): AsyncIterable<TDocument>
39
- msearch(options?: MsearchHelperOptions, reqOptions?: TransportRequestOptions): MsearchHelper
40
- bulk<TDocument = unknown>(options: BulkHelperOptions<TDocument>, reqOptions?: TransportRequestOptions): BulkHelper<BulkStats>
35
+ search<TDocument = unknown, TRequestBody extends RequestBody = Record<string, any>>(
36
+ params: Search<TRequestBody>,
37
+ options?: TransportRequestOptions
38
+ ): Promise<TDocument[]>;
39
+ scrollSearch<
40
+ TDocument = unknown,
41
+ TResponse = Record<string, any>,
42
+ TRequestBody extends RequestBody = Record<string, any>,
43
+ TContext = Context
44
+ >(
45
+ params: Search<TRequestBody>,
46
+ options?: TransportRequestOptions
47
+ ): AsyncIterable<ScrollSearchResponse<TDocument, TResponse, TContext>>;
48
+ scrollDocuments<TDocument = unknown, TRequestBody extends RequestBody = Record<string, any>>(
49
+ params: Search<TRequestBody>,
50
+ options?: TransportRequestOptions
51
+ ): AsyncIterable<TDocument>;
52
+ msearch(options?: MsearchHelperOptions, reqOptions?: TransportRequestOptions): MsearchHelper;
53
+ bulk<TDocument = unknown>(
54
+ options: BulkHelperOptions<TDocument>,
55
+ reqOptions?: TransportRequestOptions
56
+ ): BulkHelper<BulkStats>;
41
57
  }
42
58
 
43
- export interface ScrollSearchResponse<TDocument = unknown, TResponse = Record<string, any>, TContext = Context> extends ApiResponse<TResponse, TContext> {
44
- clear: () => Promise<void>
45
- documents: TDocument[]
59
+ export interface ScrollSearchResponse<
60
+ TDocument = unknown,
61
+ TResponse = Record<string, any>,
62
+ TContext = Context
63
+ > extends ApiResponse<TResponse, TContext> {
64
+ clear: () => Promise<void>;
65
+ documents: TDocument[];
46
66
  }
47
67
 
48
68
  export interface BulkHelper<T> extends Promise<T> {
49
- abort: () => BulkHelper<T>
50
- readonly stats: BulkStats
69
+ abort: () => BulkHelper<T>;
70
+ readonly stats: BulkStats;
51
71
  }
52
72
 
53
73
  export interface BulkStats {
54
- total: number
55
- failed: number
56
- retry: number
57
- successful: number
58
- noop: number
59
- time: number
60
- bytes: number
61
- aborted: boolean
74
+ total: number;
75
+ failed: number;
76
+ retry: number;
77
+ successful: number;
78
+ noop: number;
79
+ time: number;
80
+ bytes: number;
81
+ aborted: boolean;
62
82
  }
63
83
 
64
- interface IndexAction {
84
+ interface IndexActionOperation {
65
85
  index: {
66
- _index: string
67
- [key: string]: any
68
- }
86
+ _index: string;
87
+ [key: string]: any;
88
+ };
69
89
  }
70
90
 
71
- interface CreateAction {
91
+ interface CreateActionOperation {
72
92
  create: {
73
- _index: string
74
- [key: string]: any
75
- }
93
+ _index: string;
94
+ [key: string]: any;
95
+ };
76
96
  }
77
97
 
78
98
  interface UpdateActionOperation {
79
99
  update: {
80
- _index: string
81
- [key: string]: any
82
- }
100
+ _index: string;
101
+ [key: string]: any;
102
+ };
83
103
  }
84
104
 
85
105
  interface DeleteAction {
86
106
  delete: {
87
- _index: string
88
- [key: string]: any
89
- }
107
+ _index: string;
108
+ [key: string]: any;
109
+ };
90
110
  }
91
111
 
92
- type UpdateAction = [UpdateActionOperation, Record<string, any>]
93
- type Action = IndexAction | CreateAction | UpdateAction | DeleteAction
94
- type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
112
+ type CreateAction = CreateActionOperation | [CreateActionOperation, unknown];
113
+ type IndexAction = IndexActionOperation | [IndexActionOperation, unknown];
114
+ type UpdateAction = [UpdateActionOperation, Record<string, any>];
115
+ type Action = IndexAction | CreateAction | UpdateAction | DeleteAction;
116
+ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
95
117
 
96
118
  export interface BulkHelperOptions<TDocument = unknown> extends Omit<Bulk, 'body'> {
97
- datasource: TDocument[] | Buffer | ReadableStream | AsyncIterator<TDocument>
98
- onDocument: (doc: TDocument) => Action
99
- flushBytes?: number
100
- flushInterval?: number
101
- concurrency?: number
102
- retries?: number
103
- wait?: number
104
- onDrop?: (doc: OnDropDocument<TDocument>) => void
105
- refreshOnCompletion?: boolean | string
119
+ datasource: TDocument[] | Buffer | ReadableStream | AsyncIterator<TDocument>;
120
+ onDocument: (doc: TDocument) => Action;
121
+ flushBytes?: number;
122
+ flushInterval?: number;
123
+ concurrency?: number;
124
+ retries?: number;
125
+ wait?: number;
126
+ onDrop?: (doc: OnDropDocument<TDocument>) => void;
127
+ refreshOnCompletion?: boolean | string;
106
128
  }
107
129
 
108
130
  export interface OnDropDocument<TDocument = unknown> {
109
- status: number
131
+ status: number;
110
132
  error: {
111
- type: string,
112
- reason: string,
133
+ type: string;
134
+ reason: string;
113
135
  caused_by: {
114
- type: string,
115
- reason: string
116
- }
117
- }
118
- operation: Action
119
- document: TDocument
120
- retried: boolean
136
+ type: string;
137
+ reason: string;
138
+ };
139
+ };
140
+ operation: Action;
141
+ document: TDocument;
142
+ retried: boolean;
121
143
  }
122
144
 
123
145
  export interface MsearchHelperOptions extends Omit<Msearch, 'body'> {
124
- operations?: number
125
- flushInterval?: number
126
- concurrency?: number
127
- retries?: number
128
- wait?: number
146
+ operations?: number;
147
+ flushInterval?: number;
148
+ concurrency?: number;
149
+ retries?: number;
150
+ wait?: number;
129
151
  }
130
152
 
131
- declare type callbackFn<Response, Context> = (err: ApiError, result: ApiResponse<Response, Context>) => void;
153
+ declare type callbackFn<Response, Context> = (
154
+ err: ApiError,
155
+ result: ApiResponse<Response, Context>
156
+ ) => void;
132
157
  export interface MsearchHelper extends Promise<void> {
133
- stop(error?: Error): void
134
- search<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(header: Omit<Search, 'body'>, body: TRequestBody): Promise<ApiResponse<TResponse, TContext>>
135
- search<TResponse = Record<string, any>, TRequestBody extends RequestBody = Record<string, any>, TContext = Context>(header: Omit<Search, 'body'>, body: TRequestBody, callback: callbackFn<TResponse, TContext>): void
158
+ stop(error?: Error): void;
159
+ search<
160
+ TResponse = Record<string, any>,
161
+ TRequestBody extends RequestBody = Record<string, any>,
162
+ TContext = Context
163
+ >(
164
+ header: Omit<Search, 'body'>,
165
+ body: TRequestBody
166
+ ): Promise<ApiResponse<TResponse, TContext>>;
167
+ search<
168
+ TResponse = Record<string, any>,
169
+ TRequestBody extends RequestBody = Record<string, any>,
170
+ TContext = Context
171
+ >(
172
+ header: Omit<Search, 'body'>,
173
+ body: TRequestBody,
174
+ callback: callbackFn<TResponse, TContext>
175
+ ): void;
136
176
  }