Skip to content

Commit

Permalink
Overhaul return behavior for entity validation
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDiekmann committed Dec 6, 2024
1 parent fe05c6a commit a971f9a
Show file tree
Hide file tree
Showing 32 changed files with 1,085 additions and 492 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ pub struct ClosedEntityTypeMetadata {
pub inverse: InverseEntityTypeMetadata,
}

impl ClosedEntityTypeMetadata {
#[must_use]
pub fn is_link(&self) -> bool {
self.all_of.iter().any(|entity_type| {
entity_type.id.base_url.as_str()
== "https://blockprotocol.org/@blockprotocol/types/entity-type/link/"
})
}
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[cfg_attr(target_arch = "wasm32", derive(tsify::Tsify))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
Expand Down Expand Up @@ -160,6 +170,10 @@ impl ClosedMultiEntityType {
}
}

pub fn is_link(&self) -> bool {
self.all_of.iter().any(ClosedEntityTypeMetadata::is_link)
}

/// Creates a closed entity type from multiple closed entity types.
///
/// This results in a closed entity type which is used for entities with multiple types.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub use self::{
closed::{
ClosedEntityType, ClosedEntityTypeMetadata, ClosedMultiEntityType, EntityTypeResolveData,
ResolveClosedEntityTypeError,
},
constraints::EntityConstraints,
reference::EntityTypeReference,
Expand Down Expand Up @@ -81,12 +82,6 @@ pub struct EntityTypeDisplayMetadata {
pub icon: Option<String>,
}

impl EntityTypeDisplayMetadata {
pub const fn is_empty(&self) -> bool {
self.label_property.is_none() && self.icon.is_none()
}
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(target_arch = "wasm32", derive(tsify::Tsify))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
Expand Down
1 change: 1 addition & 0 deletions libs/@blockprotocol/type-system/rust/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub use self::{
EntityType, EntityTypeReference, EntityTypeResolveData, EntityTypeSchemaMetadata,
EntityTypeToEntityTypeEdge, EntityTypeToPropertyTypeEdge, EntityTypeValidationError,
EntityTypeValidator, InverseEntityTypeMetadata, PartialEntityType,
ResolveClosedEntityTypeError,
},
identifier::{DataTypeUuid, EntityTypeUuid, OntologyTypeUuid, PropertyTypeUuid},
object::{
Expand Down
1 change: 1 addition & 0 deletions libs/@local/graph/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ harpc-types = { workspace = true }
hash-graph-store = { workspace = true, features = ["utoipa"] }
hash-graph-temporal-versioning = { workspace = true }
hash-graph-type-defs = { workspace = true }
hash-graph-validation = { workspace = true }
hash-status = { workspace = true }
type-system = { workspace = true, features = ["utoipa"] }

Expand Down
9 changes: 9 additions & 0 deletions libs/@local/graph/api/openapi/models/multi_report.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions libs/@local/graph/api/openapi/models/report.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions libs/@local/graph/api/openapi/models/report_context_info.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a971f9a

Please sign in to comment.