Skip to content

Commit 28f7074

Browse files
emmaling27Convex, Inc.
authored andcommitted
Component path protos (#27593)
This PR adds `ComponentPath` to protos. GitOrigin-RevId: 989bd1ae154f6fddd8d6fd03290c5155489361f0
1 parent 7011546 commit 28f7074

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

crates/isolate/src/environment/helpers/validation.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use common::{
44
CanonicalizedComponentFunctionPath,
55
ComponentFunctionPath,
66
ComponentId,
7+
ComponentName,
78
ComponentPath,
89
},
910
errors::JsError,
@@ -494,15 +495,25 @@ impl ValidatedPathAndArgs {
494495
path,
495496
args,
496497
npm_version,
498+
component_path,
497499
}: pb::common::ValidatedPathAndArgs,
498500
) -> anyhow::Result<Self> {
499501
let args_json: JsonValue =
500502
serde_json::from_slice(&args.ok_or_else(|| anyhow::anyhow!("Missing args"))?)?;
501503
let args_value = ConvexValue::try_from(args_json)?;
502504
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()))?;
503514
Ok(Self {
504515
path: CanonicalizedComponentFunctionPath {
505-
component: ComponentPath::root(),
516+
component,
506517
udf_path: path
507518
.ok_or_else(|| anyhow::anyhow!("Missing udf_path"))?
508519
.parse()?,
@@ -525,11 +536,14 @@ impl TryFrom<ValidatedPathAndArgs> for pb::common::ValidatedPathAndArgs {
525536
) -> anyhow::Result<Self> {
526537
let args_json = JsonValue::from(args);
527538
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+
});
529542
Ok(Self {
530543
path: Some(path.udf_path.to_string()),
531544
args: Some(args),
532545
npm_version: npm_version.map(|v| v.to_string()),
546+
component_path,
533547
})
534548
}
535549
}

crates/pb/protos/common.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ message ValidatedPathAndArgs {
88
optional string path = 1;
99
optional bytes args = 2;
1010
optional string npm_version = 3;
11+
optional ComponentPath component_path = 4;
12+
}
13+
14+
message ComponentPath {
15+
repeated string path = 1;
1116
}
1217

1318
message ResolvedDocument {

0 commit comments

Comments
 (0)