1- import jp from 'jsonpath' ;
1+ import { JSONPath } from 'jsonpath-plus ' ;
22import { useDataSchema , useFlattenSchema , type SchemaNode } from './useDataSchema' ;
33import type { INodeUi , Schema } from '@/Interface' ;
44import type { IExecutionResponse } from '@/features/execution/executions/executions.types' ;
@@ -300,10 +300,10 @@ describe('useDataSchema', () => {
300300 it ( 'should return the correct data when using the generated json path on an object' , ( ) => {
301301 const input = { people : [ 'Joe' , 'John' ] } ;
302302 const schema = getSchema ( input ) ;
303- const pathData = jp . query (
304- input ,
305- `$ ${ ( ( schema . value as Schema [ ] ) [ 0 ] . value as Schema [ ] ) [ 0 ] . path } ` ,
306- ) ;
303+ const pathData = JSONPath ( {
304+ path : `$ ${ ( ( schema . value as Schema [ ] ) [ 0 ] . value as Schema [ ] ) [ 0 ] . path } ` ,
305+ json : input ,
306+ } ) ;
307307 expect ( pathData ) . toEqual ( [ 'Joe' ] ) ;
308308 } ) ;
309309
@@ -313,20 +313,20 @@ describe('useDataSchema', () => {
313313 { name : 'Joe' , age : 33 , hobbies : [ 'skateboarding' , 'gaming' ] } ,
314314 ] ;
315315 const schema = getSchema ( input ) ;
316- const pathData = jp . query (
317- input ,
318- `$ ${ ( ( ( schema . value as Schema [ ] ) [ 0 ] . value as Schema [ ] ) [ 2 ] . value as Schema [ ] ) [ 1 ] . path } ` ,
319- ) ;
316+ const pathData = JSONPath ( {
317+ path : `$ ${ ( ( ( schema . value as Schema [ ] ) [ 0 ] . value as Schema [ ] ) [ 2 ] . value as Schema [ ] ) [ 1 ] . path } ` ,
318+ json : input ,
319+ } ) ;
320320 expect ( pathData ) . toEqual ( [ 'traveling' ] ) ;
321321 } ) ;
322322
323323 it ( 'should return the correct data when using the generated json path on a list of list' , ( ) => {
324324 const input = [ [ 1 , 2 ] ] ;
325325 const schema = getSchema ( input ) ;
326- const pathData = jp . query (
327- input ,
328- `$ ${ ( ( schema . value as Schema [ ] ) [ 0 ] . value as Schema [ ] ) [ 1 ] . path } ` ,
329- ) ;
326+ const pathData = JSONPath ( {
327+ path : `$ ${ ( ( schema . value as Schema [ ] ) [ 0 ] . value as Schema [ ] ) [ 1 ] . path } ` ,
328+ json : input ,
329+ } ) ;
330330 expect ( pathData ) . toEqual ( [ 2 ] ) ;
331331 } ) ;
332332
@@ -338,10 +338,10 @@ describe('useDataSchema', () => {
338338 ] ,
339339 ] ;
340340 const schema = getSchema ( input ) ;
341- const pathData = jp . query (
342- input ,
343- `$ ${ ( ( ( schema . value as Schema [ ] ) [ 0 ] . value as Schema [ ] ) [ 1 ] . value as Schema [ ] ) [ 1 ] . path } ` ,
344- ) ;
341+ const pathData = JSONPath ( {
342+ path : `$ ${ ( ( ( schema . value as Schema [ ] ) [ 0 ] . value as Schema [ ] ) [ 1 ] . value as Schema [ ] ) [ 1 ] . path } ` ,
343+ json : input ,
344+ } ) ;
345345 expect ( pathData ) . toEqual ( [ 33 ] ) ;
346346 } ) ;
347347
@@ -355,15 +355,15 @@ describe('useDataSchema', () => {
355355 } ,
356356 ] ;
357357 const schema = getSchema ( input ) ;
358- const pathData = jp . query (
359- input ,
360- `$${
358+ const pathData = JSONPath ( {
359+ path : `$${
361360 (
362361 ( ( ( schema . value as Schema [ ] ) [ 0 ] . value as Schema [ ] ) [ 0 ] . value as Schema [ ] ) [ 0 ]
363362 . value as Schema [ ]
364363 ) [ 0 ] . path
365364 } `,
366- ) ;
365+ json : input ,
366+ } ) ;
367367 expect ( pathData ) . toEqual ( [ new Date ( '2022-11-22T00:00:00.000Z' ) ] ) ;
368368 } ) ;
369369
0 commit comments