@opensearch-project/opensearch 2.8.0 → 2.10.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/index.d.ts CHANGED
@@ -4621,6 +4621,104 @@ declare class Client {
4621
4621
  options: TransportRequestOptions,
4622
4622
  callback: callbackFn<TResponse, TContext>
4623
4623
  ): TransportRequestCallback;
4624
+ rollups: {
4625
+ delete<TResponse = Record<string, any>, TContext = Context>(
4626
+ params?: Record<string, any>,
4627
+ options?: TransportRequestOptions
4628
+ ): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
4629
+ delete<TResponse = Record<string, any>, TContext = Context>(
4630
+ callback: callbackFn<TResponse, TContext>
4631
+ ): TransportRequestCallback;
4632
+ delete<TResponse = Record<string, any>, TContext = Context>(
4633
+ params: Record<string, any>,
4634
+ callback: callbackFn<TResponse, TContext>
4635
+ ): TransportRequestCallback;
4636
+ delete<TResponse = Record<string, any>, TContext = Context>(
4637
+ params: Record<string, any>,
4638
+ options: TransportRequestOptions,
4639
+ callback: callbackFn<TResponse, TContext>
4640
+ ): TransportRequestCallback;
4641
+ get<TResponse = Record<string, any>, TContext = Context>(
4642
+ params?: Record<string, any>,
4643
+ options?: TransportRequestOptions
4644
+ ): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
4645
+ get<TResponse = Record<string, any>, TContext = Context>(
4646
+ callback: callbackFn<TResponse, TContext>
4647
+ ): TransportRequestCallback;
4648
+ get<TResponse = Record<string, any>, TContext = Context>(
4649
+ params: Record<string, any>,
4650
+ callback: callbackFn<TResponse, TContext>
4651
+ ): TransportRequestCallback;
4652
+ get<TResponse = Record<string, any>, TContext = Context>(
4653
+ params: Record<string, any>,
4654
+ options: TransportRequestOptions,
4655
+ callback: callbackFn<TResponse, TContext>
4656
+ ): TransportRequestCallback;
4657
+ put<TResponse = Record<string, any>, TContext = Context>(
4658
+ params?: Record<string, any>,
4659
+ options?: TransportRequestOptions
4660
+ ): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
4661
+ put<TResponse = Record<string, any>, TContext = Context>(
4662
+ callback: callbackFn<TResponse, TContext>
4663
+ ): TransportRequestCallback;
4664
+ put<TResponse = Record<string, any>, TContext = Context>(
4665
+ params: Record<string, any>,
4666
+ callback: callbackFn<TResponse, TContext>
4667
+ ): TransportRequestCallback;
4668
+ put<TResponse = Record<string, any>, TContext = Context>(
4669
+ params: Record<string, any>,
4670
+ options: TransportRequestOptions,
4671
+ callback: callbackFn<TResponse, TContext>
4672
+ ): TransportRequestCallback;
4673
+ explain<TResponse = Record<string, any>, TContext = Context>(
4674
+ params?: Record<string, any>,
4675
+ options?: TransportRequestOptions
4676
+ ): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
4677
+ explain<TResponse = Record<string, any>, TContext = Context>(
4678
+ callback: callbackFn<TResponse, TContext>
4679
+ ): TransportRequestCallback;
4680
+ explain<TResponse = Record<string, any>, TContext = Context>(
4681
+ params: Record<string, any>,
4682
+ callback: callbackFn<TResponse, TContext>
4683
+ ): TransportRequestCallback;
4684
+ explain<TResponse = Record<string, any>, TContext = Context>(
4685
+ params: Record<string, any>,
4686
+ options: TransportRequestOptions,
4687
+ callback: callbackFn<TResponse, TContext>
4688
+ ): TransportRequestCallback;
4689
+ start<TResponse = Record<string, any>, TContext = Context>(
4690
+ params?: Record<string, any>,
4691
+ options?: TransportRequestOptions
4692
+ ): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
4693
+ start<TResponse = Record<string, any>, TContext = Context>(
4694
+ callback: callbackFn<TResponse, TContext>
4695
+ ): TransportRequestCallback;
4696
+ start<TResponse = Record<string, any>, TContext = Context>(
4697
+ params: Record<string, any>,
4698
+ callback: callbackFn<TResponse, TContext>
4699
+ ): TransportRequestCallback;
4700
+ start<TResponse = Record<string, any>, TContext = Context>(
4701
+ params: Record<string, any>,
4702
+ options: TransportRequestOptions,
4703
+ callback: callbackFn<TResponse, TContext>
4704
+ ): TransportRequestCallback;
4705
+ stop<TResponse = Record<string, any>, TContext = Context>(
4706
+ params?: Record<string, any>,
4707
+ options?: TransportRequestOptions
4708
+ ): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
4709
+ stop<TResponse = Record<string, any>, TContext = Context>(
4710
+ callback: callbackFn<TResponse, TContext>
4711
+ ): TransportRequestCallback;
4712
+ stop<TResponse = Record<string, any>, TContext = Context>(
4713
+ params: Record<string, any>,
4714
+ callback: callbackFn<TResponse, TContext>
4715
+ ): TransportRequestCallback;
4716
+ stop<TResponse = Record<string, any>, TContext = Context>(
4717
+ params: Record<string, any>,
4718
+ options: TransportRequestOptions,
4719
+ callback: callbackFn<TResponse, TContext>
4720
+ ): TransportRequestCallback;
4721
+ };
4624
4722
  scripts_painless_execute<
4625
4723
  TResponse = Record<string, any>,
4626
4724
  TRequestBody extends RequestBody = Record<string, any>,
@@ -5473,6 +5571,136 @@ declare class Client {
5473
5571
  options: TransportRequestOptions,
5474
5572
  callback: callbackFn<TResponse, TContext>
5475
5573
  ): TransportRequestCallback;
5574
+ transforms: {
5575
+ search<TResponse = Record<string, any>, TContext = Context>(
5576
+ params?: Record<string, any>,
5577
+ options?: TransportRequestOptions
5578
+ ): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
5579
+ search<TResponse = Record<string, any>, TContext = Context>(
5580
+ callback: callbackFn<TResponse, TContext>
5581
+ ): TransportRequestCallback;
5582
+ search<TResponse = Record<string, any>, TContext = Context>(
5583
+ params: Record<string, any>,
5584
+ callback: callbackFn<TResponse, TContext>
5585
+ ): TransportRequestCallback;
5586
+ search<TResponse = Record<string, any>, TContext = Context>(
5587
+ params: Record<string, any>,
5588
+ options: TransportRequestOptions,
5589
+ callback: callbackFn<TResponse, TContext>
5590
+ ): TransportRequestCallback;
5591
+ preview<TResponse = Record<string, any>, TContext = Context>(
5592
+ params?: Record<string, any>,
5593
+ options?: TransportRequestOptions
5594
+ ): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
5595
+ preview<TResponse = Record<string, any>, TContext = Context>(
5596
+ callback: callbackFn<TResponse, TContext>
5597
+ ): TransportRequestCallback;
5598
+ preview<TResponse = Record<string, any>, TContext = Context>(
5599
+ params: Record<string, any>,
5600
+ callback: callbackFn<TResponse, TContext>
5601
+ ): TransportRequestCallback;
5602
+ preview<TResponse = Record<string, any>, TContext = Context>(
5603
+ params: Record<string, any>,
5604
+ options: TransportRequestOptions,
5605
+ callback: callbackFn<TResponse, TContext>
5606
+ ): TransportRequestCallback;
5607
+ delete<TResponse = Record<string, any>, TContext = Context>(
5608
+ params?: Record<string, any>,
5609
+ options?: TransportRequestOptions
5610
+ ): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
5611
+ delete<TResponse = Record<string, any>, TContext = Context>(
5612
+ callback: callbackFn<TResponse, TContext>
5613
+ ): TransportRequestCallback;
5614
+ delete<TResponse = Record<string, any>, TContext = Context>(
5615
+ params: Record<string, any>,
5616
+ callback: callbackFn<TResponse, TContext>
5617
+ ): TransportRequestCallback;
5618
+ delete<TResponse = Record<string, any>, TContext = Context>(
5619
+ params: Record<string, any>,
5620
+ options: TransportRequestOptions,
5621
+ callback: callbackFn<TResponse, TContext>
5622
+ ): TransportRequestCallback;
5623
+ get<TResponse = Record<string, any>, TContext = Context>(
5624
+ params?: Record<string, any>,
5625
+ options?: TransportRequestOptions
5626
+ ): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
5627
+ get<TResponse = Record<string, any>, TContext = Context>(
5628
+ callback: callbackFn<TResponse, TContext>
5629
+ ): TransportRequestCallback;
5630
+ get<TResponse = Record<string, any>, TContext = Context>(
5631
+ params: Record<string, any>,
5632
+ callback: callbackFn<TResponse, TContext>
5633
+ ): TransportRequestCallback;
5634
+ get<TResponse = Record<string, any>, TContext = Context>(
5635
+ params: Record<string, any>,
5636
+ options: TransportRequestOptions,
5637
+ callback: callbackFn<TResponse, TContext>
5638
+ ): TransportRequestCallback;
5639
+ put<TResponse = Record<string, any>, TContext = Context>(
5640
+ params?: Record<string, any>,
5641
+ options?: TransportRequestOptions
5642
+ ): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
5643
+ put<TResponse = Record<string, any>, TContext = Context>(
5644
+ callback: callbackFn<TResponse, TContext>
5645
+ ): TransportRequestCallback;
5646
+ put<TResponse = Record<string, any>, TContext = Context>(
5647
+ params: Record<string, any>,
5648
+ callback: callbackFn<TResponse, TContext>
5649
+ ): TransportRequestCallback;
5650
+ put<TResponse = Record<string, any>, TContext = Context>(
5651
+ params: Record<string, any>,
5652
+ options: TransportRequestOptions,
5653
+ callback: callbackFn<TResponse, TContext>
5654
+ ): TransportRequestCallback;
5655
+ explain<TResponse = Record<string, any>, TContext = Context>(
5656
+ params?: Record<string, any>,
5657
+ options?: TransportRequestOptions
5658
+ ): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
5659
+ explain<TResponse = Record<string, any>, TContext = Context>(
5660
+ callback: callbackFn<TResponse, TContext>
5661
+ ): TransportRequestCallback;
5662
+ explain<TResponse = Record<string, any>, TContext = Context>(
5663
+ params: Record<string, any>,
5664
+ callback: callbackFn<TResponse, TContext>
5665
+ ): TransportRequestCallback;
5666
+ explain<TResponse = Record<string, any>, TContext = Context>(
5667
+ params: Record<string, any>,
5668
+ options: TransportRequestOptions,
5669
+ callback: callbackFn<TResponse, TContext>
5670
+ ): TransportRequestCallback;
5671
+ start<TResponse = Record<string, any>, TContext = Context>(
5672
+ params?: Record<string, any>,
5673
+ options?: TransportRequestOptions
5674
+ ): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
5675
+ start<TResponse = Record<string, any>, TContext = Context>(
5676
+ callback: callbackFn<TResponse, TContext>
5677
+ ): TransportRequestCallback;
5678
+ start<TResponse = Record<string, any>, TContext = Context>(
5679
+ params: Record<string, any>,
5680
+ callback: callbackFn<TResponse, TContext>
5681
+ ): TransportRequestCallback;
5682
+ start<TResponse = Record<string, any>, TContext = Context>(
5683
+ params: Record<string, any>,
5684
+ options: TransportRequestOptions,
5685
+ callback: callbackFn<TResponse, TContext>
5686
+ ): TransportRequestCallback;
5687
+ stop<TResponse = Record<string, any>, TContext = Context>(
5688
+ params?: Record<string, any>,
5689
+ options?: TransportRequestOptions
5690
+ ): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
5691
+ stop<TResponse = Record<string, any>, TContext = Context>(
5692
+ callback: callbackFn<TResponse, TContext>
5693
+ ): TransportRequestCallback;
5694
+ stop<TResponse = Record<string, any>, TContext = Context>(
5695
+ params: Record<string, any>,
5696
+ callback: callbackFn<TResponse, TContext>
5697
+ ): TransportRequestCallback;
5698
+ stop<TResponse = Record<string, any>, TContext = Context>(
5699
+ params: Record<string, any>,
5700
+ options: TransportRequestOptions,
5701
+ callback: callbackFn<TResponse, TContext>
5702
+ ): TransportRequestCallback;
5703
+ };
5476
5704
  update<
5477
5705
  TResponse = Record<string, any>,
5478
5706
  TRequestBody extends RequestBody = Record<string, any>,
package/lib/Serializer.js CHANGED
@@ -34,60 +34,9 @@ const debug = require('debug')('opensearch');
34
34
  const sjson = require('secure-json-parse');
35
35
  const { SerializationError, DeserializationError } = require('./errors');
36
36
  const kJsonOptions = Symbol('secure json parse options');
37
+ const JSON11 = require('json11');
37
38
 
38
- /* In JavaScript, a `Number` is a 64-bit floating-point value which can store 16 digits. However, the
39
- * serializer and deserializer will need to cater to numeric values generated by other languages which
40
- * can have up to 19 digits. Native JSON parser and stringifier, incapable of handling the extra
41
- * digits, corrupt the values, making them unusable.
42
- *
43
- * To work around this limitation, the deserializer converts long sequences of digits into strings and
44
- * marks them before applying the parser. During the parsing, string values that begin with the mark
45
- * are converted to `BigInt` values.
46
- * Similarly, during stringification, the serializer converts `BigInt` values to marked strings and
47
- * when done, it replaces them with plain numerals.
48
- *
49
- * `Number.MAX_SAFE_INTEGER`, 9,007,199,254,740,991, is the largest number that the native methods can
50
- * parse and stringify, and any numeral greater than that would need to be translated using the
51
- * workaround; all 17-digits or longer and only tail-end of the 16-digits need translation. It would
52
- * be unfair to all the 16-digit numbers if the translation applied to `\d{16,}` only to cover the
53
- * less than 10%. Hence, a RegExp is created to only match numerals too long to be a number.
54
- *
55
- * To make the explanation simpler, let's assume that MAX_SAFE_INTEGER is 8921 which has 4 digits.
56
- * Starting from the right, we take each digit onwards, `[<start>-9]`:
57
- * 1) 7922 - 7929: 792[2-9]\d{0}
58
- * 2) 7930 - 7999: 79[3-9]\d{1}
59
- * 9) 9 + 1 = 10 which results in a rollover; no need to do anything.
60
- * 8) 9000 - 9999: [9-9]\d{3}
61
- * Finally we add anything 5 digits or longer: `\d{5,}
62
- *
63
- * PS, a better solution would use AST but considering its performance penalty, RegExp is the next
64
- * the best solution.
65
- */
66
39
  const isBigIntSupported = typeof BigInt !== 'undefined';
67
- const maxIntAsString = String(Number.MAX_SAFE_INTEGER);
68
- const maxIntLength = maxIntAsString.length;
69
- // Sub-patterns for each digit
70
- const bigIntMatcherTokens = [`\\d{${maxIntAsString.length + 1},}`];
71
- for (let i = 0; i < maxIntLength; i++) {
72
- if (maxIntAsString[i] !== '9') {
73
- bigIntMatcherTokens.push(
74
- maxIntAsString.substring(0, i) +
75
- `[${parseInt(maxIntAsString[i], 10) + 1}-9]` +
76
- `\\d{${maxIntLength - i - 1}}`
77
- );
78
- }
79
- }
80
-
81
- /* The matcher that looks for `": <numerals>, ...}` and `[..., <numeral>, ...]`
82
- *
83
- * The pattern starts by looking for `":` not immediately preceded by a `\`. That should be
84
- * followed by any of the numeric sub-patterns. A comma, end of an array, end of an object, or
85
- * the end of the input are the only acceptable elements after it.
86
- */
87
- const bigIntMatcher = new RegExp(
88
- `((?:\\[|,|(?<!\\\\)"\\s*:)\\s*)(-?(?:${bigIntMatcherTokens.join('|')}))(\\s*)(?=,|}|]|$)`,
89
- 'g'
90
- );
91
40
 
92
41
  class Serializer {
93
42
  constructor(opts = {}) {
@@ -99,154 +48,6 @@ class Serializer {
99
48
  };
100
49
  }
101
50
 
102
- /* The characters with a highly unlikely chance of occurrence in strings, alone or in combination.
103
- *
104
- * ToDo: When support for ancient versions of Node.js are dropped, replace with
105
- * _bigIntMarkChars = ['෴', '߷', '֍'];
106
- */
107
- get _bigIntMarkChars() {
108
- return ['෴', '߷', '֍'];
109
- }
110
-
111
- /* Generates an array of all combinations of `_bigIntMarkChars` with the requested length. */
112
- _bigIntMarkerCombinations(length = 3) {
113
- const results = [];
114
- const arr = this._bigIntMarkChars;
115
- const arrLength = arr.length;
116
- const temp = Array(length);
117
-
118
- (function fill(pos, start) {
119
- if (pos === length) return results.push(temp.join(''));
120
-
121
- for (let i = start; i < arrLength; i++) {
122
- temp[pos] = arr[i];
123
- fill(pos + 1, i);
124
- }
125
- })(0, 0);
126
-
127
- return results;
128
- }
129
-
130
- /* Experiments with different combinations of various lengths, until one is found to not be in
131
- * the input string.
132
- */
133
- _getSuitableBigIntMarker(json) {
134
- let bigIntMarker;
135
- let length = 0;
136
- do {
137
- length++;
138
- this._bigIntMarkerCombinations(length).some((marker) => {
139
- if (json.indexOf(marker) === -1) {
140
- bigIntMarker = marker;
141
- return true;
142
- }
143
- });
144
- } while (!bigIntMarker);
145
-
146
- return {
147
- bigIntMarker,
148
- length,
149
- };
150
- }
151
-
152
- _parseWithBigInt(json) {
153
- const { bigIntMarker, length } = this._getSuitableBigIntMarker(json);
154
-
155
- let hadException;
156
- let markedJSON = json.replace(bigIntMatcher, `$1"${bigIntMarker}$2"$3`);
157
-
158
- /* RegExp cannot replace AST and the process of marking adds quotes. So, any false-positive hit
159
- * will make the JSON string unparseable.
160
- *
161
- * To find those instances, we try to parse and watch for the location of any errors. If an error
162
- * is caused by the marking, we remove that single marking and try again.
163
- */
164
- do {
165
- try {
166
- hadException = false;
167
- JSON.parse(markedJSON);
168
- } catch (e) {
169
- hadException = true;
170
- /* There are two types of exception objects that can be raised:
171
- * 1) a proper object with lineNumber and columnNumber which we can use
172
- * 2) a textual message with the position that we need to parse
173
- */
174
- let { lineNumber, columnNumber } = e;
175
- if (!lineNumber || !columnNumber) {
176
- const match =
177
- // ToDo: When support for ancient versions of Node.js are dropped, replace with
178
- // e?.message?.match?.()
179
- e &&
180
- e.message &&
181
- typeof e.message.match === 'function' &&
182
- e.message.match(/^Unexpected token.*at position (\d+)$/);
183
- if (match) {
184
- lineNumber = 1;
185
- // The position is zero-indexed; adding 1 to normalize it for the -2 that comes later
186
- columnNumber = parseInt(match[1], 10) + 1;
187
- }
188
- }
189
-
190
- if (lineNumber < 1 || columnNumber < 2) {
191
- // The problem is not with this replacement; just return a failure.
192
- return;
193
- }
194
-
195
- /* We need to skip e.lineNumber - 1 number of `\n` occurrences.
196
- * Then, we need to go to e.columnNumber - 2 to look for `"<mark>\d+"`; we need to `-1` to
197
- * account for the quote but an additional `-1` is needed because columnNumber starts from 1.
198
- */
199
- const re = new RegExp(
200
- `^((?:.*\\n){${lineNumber - 1}}[^\\n]{${columnNumber - 2}})"${bigIntMarker}(-?\\d+)"`
201
- );
202
- if (!re.test(markedJSON)) {
203
- // The exception is not caused by adding the marker
204
- return;
205
- }
206
-
207
- // We have found a bad replacement; let's remove it.
208
- markedJSON = markedJSON.replace(re, '$1$2');
209
- }
210
- } while (hadException);
211
-
212
- const bigIntMarkFinder = new RegExp(`^${bigIntMarker}-?\\d+$`);
213
-
214
- // Exceptions will trickle up to the caller
215
- return sjson.parse(
216
- markedJSON,
217
- (key, val) =>
218
- /* Convert marked values to BigInt values.
219
- * The `startsWith` is purely for performance, to avoid running `test` if not needed.
220
- */
221
- typeof val === 'string' && val.startsWith(bigIntMarker) && bigIntMarkFinder.test(val)
222
- ? BigInt(val.substring(length)) // eslint-disable-line no-undef
223
- : val,
224
- this[kJsonOptions]
225
- );
226
- }
227
-
228
- _stringifyWithBigInt(object, candidate) {
229
- const { bigIntMarker } = this._getSuitableBigIntMarker(candidate);
230
-
231
- /* The matcher that looks for "<marker><numerals>"
232
- * Because we have made sure that `bigIntMarker` was never present in the original object, we can
233
- * carelessly assume every "<marker><numerals>" is due to our marking.
234
- */
235
- const markedBigIntMatcher = new RegExp(`"${bigIntMarker}(-?\\d+)"`, 'g');
236
-
237
- return (
238
- JSON.stringify(
239
- object,
240
- /* Convert BigInt values to a string and mark them.
241
- * Can't be bothered with Number values beyond safe values because they are already corrupted.
242
- */
243
- (key, val) => (typeof val === 'bigint' ? `${bigIntMarker}${val.toString()}` : val)
244
- )
245
- // Replace marked substrings with just the numerals
246
- .replace(markedBigIntMatcher, '$1')
247
- );
248
- }
249
-
250
51
  serialize(object) {
251
52
  debug('Serializing', object);
252
53
  let json;
@@ -262,11 +63,29 @@ class Serializer {
262
63
  const shouldHandleLongNumerals =
263
64
  isBigIntSupported && this[kJsonOptions].enableLongNumeralSupport;
264
65
  try {
66
+ /* When handling long numerals is not requested or the platform doesn't support BigInt, the
67
+ * result of JSON.stringify are returned.
68
+ *
69
+ * When long numerals should be handled:
70
+ * Use JSON.stringify to check if any value is a BigInt:
71
+ * * If no BigInt values are found, the result of JSON.stringify is good enough to be returned.
72
+ * * Only If a BigInt value is found, JSON11.stringify is employed and its result is returned.
73
+ */
265
74
  json = JSON.stringify(object, shouldHandleLongNumerals ? checkForBigInts : null);
266
75
 
267
76
  if (shouldHandleLongNumerals && !numeralsAreNumbers) {
268
- const temp = this._stringifyWithBigInt(object, json);
269
- if (temp) json = temp;
77
+ try {
78
+ // With `withBigInt: false`, valid JSON is produced while maintaining accuracy
79
+ const temp = JSON11.stringify(object, {
80
+ withBigInt: false,
81
+ quote: '"',
82
+ quoteNames: true,
83
+ });
84
+ if (temp) json = temp;
85
+ } catch (ex) {
86
+ // Do nothing: JSON.stringify succeeded but JSON11.stringify failed; return the
87
+ // JSON.stringify result.
88
+ }
270
89
  }
271
90
  } catch (err) {
272
91
  throw new SerializationError(err.message, object);
@@ -292,6 +111,14 @@ class Serializer {
292
111
  const shouldHandleLongNumerals =
293
112
  isBigIntSupported && this[kJsonOptions].enableLongNumeralSupport;
294
113
  try {
114
+ /* When handling long numerals is not requested or the platform doesn't support BigInt, the
115
+ * result of sjson.parse are returned.
116
+ *
117
+ * When long numerals should be handled:
118
+ * Use sjson.parse to check if any value is outside the range of safe integers:
119
+ * * If no long numerals are found, the result of sjson.parse is good enough to be returned.
120
+ * * Only If long numerals are found, JSON11.parse is employed and its result is returned.
121
+ */
295
122
  object = sjson.parse(
296
123
  json,
297
124
  shouldHandleLongNumerals ? checkForLargeNumerals : null,
@@ -299,9 +126,13 @@ class Serializer {
299
126
  );
300
127
 
301
128
  if (shouldHandleLongNumerals && !numeralsAreNumbers) {
302
- const temp = this._parseWithBigInt(json);
303
- if (temp) {
304
- object = temp;
129
+ try {
130
+ const temp = JSON11.parse(json, null, { withLongNumerals: true });
131
+ if (temp) {
132
+ object = temp;
133
+ }
134
+ } catch (ex) {
135
+ // Do nothing: sjson.parse succeeded but JSON11.parse failed; return the sjson.parse result
305
136
  }
306
137
  }
307
138
  } catch (err) {
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright OpenSearch Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ *
5
+ * The OpenSearch Contributors require contributions made to
6
+ * this file be licensed under the Apache-2.0 license or a
7
+ * compatible open source license.
8
+ *
9
+ */
10
+
11
+ /// <reference types="node" />
12
+
13
+ import {
14
+ AwsSigv4Signer,
15
+ AwsSigv4SignerError,
16
+ AwsSigv4SignerOptions,
17
+ AwsSigv4SignerResponse,
18
+ } from './index';
19
+
20
+ export { AwsSigv4Signer, AwsSigv4SignerOptions, AwsSigv4SignerResponse, AwsSigv4SignerError };
package/package.json CHANGED
@@ -30,7 +30,7 @@
30
30
  }
31
31
  },
32
32
  "homepage": "https://www.opensearch.org/",
33
- "version": "2.8.0",
33
+ "version": "2.10.0",
34
34
  "versionCanary": "7.10.0-canary.6",
35
35
  "keywords": [
36
36
  "opensearch",
@@ -75,6 +75,7 @@
75
75
  "eslint": "^8.30.0",
76
76
  "eslint-config-prettier": "^9.0.0",
77
77
  "eslint-plugin-prettier": "^5.0.0",
78
+ "faker": "^5.5.3",
78
79
  "fast-deep-equal": "^3.1.3",
79
80
  "into-stream": "^6.0.0",
80
81
  "js-yaml": "^4.1.0",
@@ -100,6 +101,7 @@
100
101
  "dependencies": {
101
102
  "aws4": "^1.11.0",
102
103
  "debug": "^4.3.1",
104
+ "json11": "^1.1.2",
103
105
  "hpagent": "^1.2.0",
104
106
  "ms": "^2.1.3",
105
107
  "secure-json-parse": "^2.4.0"