@artilleryio/int-commons 2.10.0 → 2.11.0-6d31f8a

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 (2) hide show
  1. package/engine_util.js +7 -4
  2. package/package.json +5 -2
package/engine_util.js CHANGED
@@ -271,8 +271,7 @@ function templateObjectOrArray(o, context) {
271
271
  debug(
272
272
  `path = ${path} ; value = ${JSON.stringify(
273
273
  value
274
- )} (${typeof value}) ; (subj type: ${
275
- subj.length ? 'list' : 'hash'
274
+ )} (${typeof value}) ; (subj type: ${subj.length ? 'list' : 'hash'
276
275
  }) ; newValue = ${JSON.stringify(newValue)} ; newPath = ${newPath}`
277
276
  );
278
277
 
@@ -572,7 +571,7 @@ function dummyParser(body, callback) {
572
571
  }
573
572
 
574
573
  // doc is a JSON object
575
- function extractJSONPath(doc, expr) {
574
+ function extractJSONPath(doc, expr, opts) {
576
575
  // typeof null is 'object' hence the explicit check here
577
576
  if (typeof doc !== 'object' || doc === null) {
578
577
  return '';
@@ -581,7 +580,7 @@ function extractJSONPath(doc, expr) {
581
580
  let results;
582
581
 
583
582
  try {
584
- results = jsonpath(expr, doc);
583
+ results = jsonpath({ path: expr, json: doc, wrap: opts.multiple ?? true });
585
584
  } catch (queryErr) {
586
585
  debug(queryErr);
587
586
  }
@@ -590,6 +589,10 @@ function extractJSONPath(doc, expr) {
590
589
  return '';
591
590
  }
592
591
 
592
+ if (opts.multiple === false) {
593
+ return results;
594
+ }
595
+
593
596
  if (results.length > 1) {
594
597
  return results[randomInt(0, results.length - 1)];
595
598
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artilleryio/int-commons",
3
- "version": "2.10.0",
3
+ "version": "2.11.0-6d31f8a",
4
4
  "main": "./index.js",
5
5
  "license": "MPL-2.0",
6
6
  "dependencies": {
@@ -9,10 +9,13 @@
9
9
  "debug": "^4.3.1",
10
10
  "deep-for-each": "^3.0.0",
11
11
  "espree": "^9.4.1",
12
- "jsonpath-plus": "^7.2.0",
12
+ "jsonpath-plus": "^10.0.0",
13
13
  "lodash": "^4.17.19",
14
14
  "ms": "^2.1.3"
15
15
  },
16
+ "engines": {
17
+ "node": ">=18.0.0"
18
+ },
16
19
  "scripts": {
17
20
  "lint": "eslint --ext \".js,.ts,.tsx\" .",
18
21
  "lint-fix": "npm run lint -- --fix",