File tree Expand file tree Collapse file tree 4 files changed +28
-60
lines changed
Expand file tree Collapse file tree 4 files changed +28
-60
lines changed Original file line number Diff line number Diff line change 1+ # v0.25.0
2+ ## Changed
3+ * Update dependencies
4+
5+ ## Added
6+ * Add AuditProcessor
7+
18# v0.24.0
29## Changed
310* template: provide more useful error message on duplicate keys during template rendering
Original file line number Diff line number Diff line change @@ -24,7 +24,6 @@ const Mustache = require('mustache');
2424const yaml = require ( 'js-yaml' ) ;
2525const $RefParser = require ( '@apidevtools/json-schema-ref-parser' ) ;
2626const deepmerge = require ( 'deepmerge' ) ;
27- const JSONPath = require ( 'jsonpath-plus' ) . JSONPath ;
2827const axios = require ( 'axios' ) ;
2928const mexp = require ( 'math-expression-evaluator' ) ;
3029
@@ -1242,6 +1241,20 @@ class Template {
12421241 return rendered ;
12431242 }
12441243
1244+ JsonPathMinus ( path , obj ) {
1245+ // Only supports dot/bracket notation, e.g. "foo.bar[0].baz"
1246+ const parts = path
1247+ . replace ( / \[ ( \w + ) \] / g, '.$1' ) // convert [0] to .0
1248+ . split ( '.' )
1249+ . filter ( Boolean ) ;
1250+ let result = obj ;
1251+ for ( const part of parts ) {
1252+ if ( result == null ) return [ ] ;
1253+ result = result [ part ] ;
1254+ }
1255+ return [ result ] ;
1256+ }
1257+
12451258 /**
12461259 * Fetch data using an HTTP request for properties that specify a URL
12471260 *
@@ -1273,7 +1286,8 @@ class Template {
12731286 view [ def ] = res . data ;
12741287 }
12751288 if ( defProp . pathQuery ) {
1276- const results = JSONPath ( defProp . pathQuery , view [ def ] ) ;
1289+ // const results = JSONPath(defProp.pathQuery, view[def]);
1290+ const results = JsonPathMinus ( defProp . pathQuery , view [ def ] ) ;
12771291 view [ def ] = results [ 0 ] ;
12781292 }
12791293 return Promise . resolve ( ) ;
Original file line number Diff line number Diff line change 5050 "@f5devcentral/atg-storage" : " ^1.3.9" ,
5151 "adm-zip" : " ^0.5.10" ,
5252 "ajv" : " ^6.12.6" ,
53- "axios" : " ^0.30.0 " ,
53+ "axios" : " ^0.30.2 " ,
5454 "deepmerge" : " ^4.3.1" ,
5555 "js-yaml" : " ^4.1.0" ,
56- "jsonpath-plus" : " ^10.2.0" ,
5756 "math-expression-evaluator" : " ^1.4.0" ,
5857 "merge-lite" : " ^1.0.2" ,
5958 "mustache" : " ^4.2.0" ,
You can’t perform that action at this time.
0 commit comments