@@ -4,6 +4,7 @@ use common::{
4
4
CanonicalizedComponentFunctionPath ,
5
5
ComponentFunctionPath ,
6
6
ComponentId ,
7
+ ComponentName ,
7
8
ComponentPath ,
8
9
} ,
9
10
errors:: JsError ,
@@ -494,15 +495,25 @@ impl ValidatedPathAndArgs {
494
495
path,
495
496
args,
496
497
npm_version,
498
+ component_path,
497
499
} : pb:: common:: ValidatedPathAndArgs ,
498
500
) -> anyhow:: Result < Self > {
499
501
let args_json: JsonValue =
500
502
serde_json:: from_slice ( & args. ok_or_else ( || anyhow:: anyhow!( "Missing args" ) ) ?) ?;
501
503
let args_value = ConvexValue :: try_from ( args_json) ?;
502
504
let args = ConvexArray :: try_from ( args_value) ?;
505
+ let component = component_path
506
+ . map ( |c| {
507
+ c. path
508
+ . into_iter ( )
509
+ . map ( |name| name. parse :: < ComponentName > ( ) )
510
+ . try_collect :: < Vec < _ > > ( )
511
+ . map ( ComponentPath :: from)
512
+ } )
513
+ . unwrap_or ( Ok ( ComponentPath :: root ( ) ) ) ?;
503
514
Ok ( Self {
504
515
path : CanonicalizedComponentFunctionPath {
505
- component : ComponentPath :: root ( ) ,
516
+ component,
506
517
udf_path : path
507
518
. ok_or_else ( || anyhow:: anyhow!( "Missing udf_path" ) ) ?
508
519
. parse ( ) ?,
@@ -525,11 +536,14 @@ impl TryFrom<ValidatedPathAndArgs> for pb::common::ValidatedPathAndArgs {
525
536
) -> anyhow:: Result < Self > {
526
537
let args_json = JsonValue :: from ( args) ;
527
538
let args = serde_json:: to_vec ( & args_json) ?;
528
- anyhow:: ensure!( path. component. is_root( ) ) ;
539
+ let component_path = Some ( pb:: common:: ComponentPath {
540
+ path : path. component . iter ( ) . map ( |name| name. to_string ( ) ) . collect ( ) ,
541
+ } ) ;
529
542
Ok ( Self {
530
543
path : Some ( path. udf_path . to_string ( ) ) ,
531
544
args : Some ( args) ,
532
545
npm_version : npm_version. map ( |v| v. to_string ( ) ) ,
546
+ component_path,
533
547
} )
534
548
}
535
549
}
0 commit comments