@opensearch-project/opensearch 2.3.0 → 2.4.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/api/utils.js CHANGED
@@ -40,6 +40,11 @@ function handleError(err, callback) {
40
40
  return Promise.reject(err);
41
41
  }
42
42
 
43
+ function encodePathParam(camelName, snakeName = null) {
44
+ if (camelName == null && snakeName == null) return null;
45
+ return encodeURIComponent(snakeName || camelName);
46
+ }
47
+
43
48
  function snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) {
44
49
  const target = {};
45
50
  const keys = Object.keys(querystring);
@@ -65,4 +70,11 @@ function normalizeArguments(params, options, callback) {
65
70
 
66
71
  function noop() {}
67
72
 
68
- module.exports = { handleError, snakeCaseKeys, normalizeArguments, noop, kConfigurationError };
73
+ module.exports = {
74
+ handleError,
75
+ snakeCaseKeys,
76
+ normalizeArguments,
77
+ noop,
78
+ kConfigurationError,
79
+ encodePathParam,
80
+ };
package/index.d.ts CHANGED
@@ -138,6 +138,7 @@ interface ClientOptions {
138
138
  };
139
139
  disablePrototypePoisoningProtection?: boolean | 'proto' | 'constructor';
140
140
  memoryCircuitBreaker?: MemoryCircuitBreakerOptions;
141
+ enableLongNumeralSupport?: boolean;
141
142
  }
142
143
 
143
144
  declare class Client {
package/index.js CHANGED
@@ -128,6 +128,7 @@ class Client extends OpenSearchAPI {
128
128
  proxy: null,
129
129
  enableMetaHeader: true,
130
130
  disablePrototypePoisoningProtection: false,
131
+ enableLongNumeralSupport: false,
131
132
  },
132
133
  opts
133
134
  );
@@ -151,6 +152,7 @@ class Client extends OpenSearchAPI {
151
152
  this[kEventEmitter] = new EventEmitter();
152
153
  this.serializer = new options.Serializer({
153
154
  disablePrototypePoisoningProtection: options.disablePrototypePoisoningProtection,
155
+ enableLongNumeralSupport: options.enableLongNumeralSupport,
154
156
  });
155
157
  this.connectionPool = new options.ConnectionPool({
156
158
  pingTimeout: options.pingTimeout,
@@ -29,6 +29,7 @@
29
29
 
30
30
  export interface SerializerOptions {
31
31
  disablePrototypePoisoningProtection: boolean | 'proto' | 'constructor';
32
+ enableLongNumeralSupport: boolean;
32
33
  }
33
34
 
34
35
  export default class Serializer {
package/lib/Serializer.js CHANGED
@@ -95,6 +95,7 @@ class Serializer {
95
95
  this[kJsonOptions] = {
96
96
  protoAction: disable === true || disable === 'proto' ? 'ignore' : 'error',
97
97
  constructorAction: disable === true || disable === 'constructor' ? 'ignore' : 'error',
98
+ enableLongNumeralSupport: opts.enableLongNumeralSupport === true,
98
99
  };
99
100
  }
100
101
 
@@ -258,10 +259,12 @@ class Serializer {
258
259
  }
259
260
  return val;
260
261
  };
262
+ const shouldHandleLongNumerals =
263
+ isBigIntSupported && this[kJsonOptions].enableLongNumeralSupport;
261
264
  try {
262
- json = JSON.stringify(object, isBigIntSupported ? checkForBigInts : null);
265
+ json = JSON.stringify(object, shouldHandleLongNumerals ? checkForBigInts : null);
263
266
 
264
- if (isBigIntSupported && !numeralsAreNumbers) {
267
+ if (shouldHandleLongNumerals && !numeralsAreNumbers) {
265
268
  const temp = this._stringifyWithBigInt(object, json);
266
269
  if (temp) json = temp;
267
270
  }
@@ -286,14 +289,16 @@ class Serializer {
286
289
 
287
290
  return val;
288
291
  };
292
+ const shouldHandleLongNumerals =
293
+ isBigIntSupported && this[kJsonOptions].enableLongNumeralSupport;
289
294
  try {
290
295
  object = sjson.parse(
291
296
  json,
292
- isBigIntSupported ? checkForLargeNumerals : null,
297
+ shouldHandleLongNumerals ? checkForLargeNumerals : null,
293
298
  this[kJsonOptions]
294
299
  );
295
300
 
296
- if (isBigIntSupported && !numeralsAreNumbers) {
301
+ if (shouldHandleLongNumerals && !numeralsAreNumbers) {
297
302
  const temp = this._parseWithBigInt(json);
298
303
  if (temp) {
299
304
  object = temp;
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  }
24
24
  },
25
25
  "homepage": "https://www.opensearch.org/",
26
- "version": "2.3.0",
26
+ "version": "2.4.0",
27
27
  "versionCanary": "7.10.0-canary.6",
28
28
  "keywords": [
29
29
  "opensearch",
@@ -59,15 +59,15 @@
59
59
  "@aws-sdk/types": "^3.160.0",
60
60
  "@babel/eslint-parser": "^7.19.1",
61
61
  "@sinonjs/fake-timers": "github:sinonjs/fake-timers#0bfffc1",
62
- "@types/node": "^18.15.3",
62
+ "@types/node": "^20.1.4",
63
63
  "convert-hrtime": "^5.0.0",
64
64
  "cross-zip": "^4.0.0",
65
- "dedent": "^0.7.0",
65
+ "dedent": "^1.1.0",
66
66
  "deepmerge": "^4.2.2",
67
67
  "dezalgo": "^1.0.3",
68
68
  "eslint": "^8.30.0",
69
- "eslint-config-prettier": "^8.5.0",
70
- "eslint-plugin-prettier": "^4.0.0",
69
+ "eslint-config-prettier": "^9.0.0",
70
+ "eslint-plugin-prettier": "^5.0.0",
71
71
  "fast-deep-equal": "^3.1.3",
72
72
  "into-stream": "^6.0.0",
73
73
  "js-yaml": "^4.1.0",
@@ -75,8 +75,8 @@
75
75
  "license-checker": "^25.0.1",
76
76
  "minimist": "^1.2.5",
77
77
  "node-fetch": "^3.2.10",
78
- "ora": "^6.1.2",
79
- "prettier": "^2.6.2",
78
+ "ora": "^7.0.1",
79
+ "prettier": "^3.0.1",
80
80
  "pretty-hrtime": "^1.0.3",
81
81
  "proxy": "^1.0.2",
82
82
  "rimraf": "^5.0.0",