Skip to content

Commit

Permalink
[bfops/remove-expand]: actually remove?
Browse files Browse the repository at this point in the history
  • Loading branch information
bfops committed Sep 27, 2024
1 parent b399a95 commit 126acd3
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions crates/client-api/src/routes/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,19 +261,13 @@ pub struct DescribeParams {
entity: String,
}

#[derive(Deserialize)]
pub struct DescribeQueryParams {
expand: Option<bool>,
}

pub async fn describe<S>(
State(worker_ctx): State<S>,
Path(DescribeParams {
name_or_address,
entity_type,
entity,
}): Path<DescribeParams>,
Query(DescribeQueryParams { expand }): Query<DescribeQueryParams>,
Extension(auth): Extension<SpacetimeAuth>,
) -> axum::response::Result<impl IntoResponse>
where
Expand Down Expand Up @@ -304,8 +298,7 @@ where
.ok_or_else(|| (StatusCode::NOT_FOUND, format!("{entity_type} {entity:?} not found")))?;
let description = WithTypespace::new(module.info().module_def.typespace(), &description);

let expand = expand.unwrap_or(true);
let response_json = json!({ entity: entity_description_json(description, expand) });
let response_json = json!({ entity: entity_description_json(description) });

Ok((
StatusCode::OK,
Expand Down Expand Up @@ -336,26 +329,18 @@ pub struct CatalogParams {
}
#[derive(Deserialize)]
pub struct CatalogQueryParams {
expand: Option<bool>,
#[serde(default)]
module_def: bool,
}
pub async fn catalog<S>(
State(worker_ctx): State<S>,
Path(CatalogParams { name_or_address }): Path<CatalogParams>,
Query(CatalogQueryParams { expand, module_def }): Query<CatalogQueryParams>,
Query(CatalogQueryParams { module_def }): Query<CatalogQueryParams>,
Extension(auth): Extension<SpacetimeAuth>,
) -> axum::response::Result<impl IntoResponse>
where
S: ControlStateDelegate + NodeDelegate,
{
if module_def && expand.is_some() {
return Err((
StatusCode::BAD_REQUEST,
"expand and module_def cannot both be specified",
)
.into());
}
let address = name_or_address.resolve(&worker_ctx).await?.into();
let database = worker_ctx_find_database(&worker_ctx, &address)
.await?
Expand All @@ -374,15 +359,11 @@ where
let raw = RawModuleDefV9::from(module.info().module_def.clone());
serde_json::to_value(SerializeWrapper::from_ref(&raw)).map_err(log_and_500)?
} else {
let expand = expand.unwrap_or(false);
let response_catalog: HashMap<_, _> = get_catalog(&module)
.map(|entity| {
(
entity.name().to_string().into_boxed_str(),
entity_description_json(
WithTypespace::new(module.info().module_def.typespace(), &entity),
expand,
),
entity_description_json(WithTypespace::new(module.info().module_def.typespace(), &entity)),
)
})
.collect();
Expand Down

0 comments on commit 126acd3

Please sign in to comment.