Skip to content

Commit

Permalink
H-3384: Replace empty-list with list (#5286)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDiekmann authored Oct 1, 2024
1 parent 2db0e09 commit f67494c
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"$schema": "https://blockprotocol.org/types/modules/graph/0.3/schema/data-type",
"kind": "dataType",
"$id": "https://blockprotocol.org/@blockprotocol/types/data-type/empty-list/v/1",
"$id": "https://blockprotocol.org/@blockprotocol/types/data-type/list/v/1",
"allOf": [
{
"$ref": "https://blockprotocol.org/@blockprotocol/types/data-type/value/v/1"
}
],
"title": "Empty List",
"description": "An Empty List",
"type": "array",
"items": false
"title": "List",
"description": "An ordered list of values",
"type": "array"
}
Original file line number Diff line number Diff line change
Expand Up @@ -719,9 +719,9 @@ mod tests {
}

#[tokio::test]
async fn empty_list() {
async fn list() {
ensure_validation_from_str::<DataType, _>(
graph_test_data::data_type::EMPTY_LIST_V1,
graph_test_data::data_type::LIST_V1,
DataTypeValidator,
JsonEqualityCheck::Yes,
)
Expand All @@ -737,7 +737,7 @@ mod tests {
"$id": "https://blockprotocol.org/@blockprotocol/types/data-type/two-numbers/v/1",
"title": "Two Numbers",
"description": "A tuple of two numbers",
"allOf": [{ "$ref": "https://blockprotocol.org/@blockprotocol/types/data-type/value/v/1" }],
"allOf": [{ "$ref": "https://blockprotocol.org/@blockprotocol/types/data-type/list/v/1" }],
"type": "array",
"abstract": false,
"items": false,
Expand All @@ -761,7 +761,7 @@ mod tests {
"$id": "https://blockprotocol.org/@blockprotocol/types/data-type/array/v/1",
"title": "Number List",
"description": "A list of numbers",
"allOf": [{ "$ref": "https://blockprotocol.org/@blockprotocol/types/data-type/value/v/1" }],
"allOf": [{ "$ref": "https://blockprotocol.org/@blockprotocol/types/data-type/list/v/1" }],
"type": "array",
"abstract": false,
"items": { "type": "number" },
Expand Down
2 changes: 1 addition & 1 deletion libs/@blockprotocol/type-system/rust/src/url/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ mod tests {

#[test]
fn versioned_url() {
let input_str = "https://blockprotocol.org/@blockprotocol/types/data-type/empty-list/v/1";
let input_str = "https://blockprotocol.org/@blockprotocol/types/data-type/list/v/1";
let url = VersionedUrl::from_str(input_str).expect("parsing versioned URL failed");
assert_eq!(&url.to_string(), input_str);
}
Expand Down
8 changes: 4 additions & 4 deletions libs/@local/hash-isomorphic-utils/src/ontology-type-ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1590,11 +1590,11 @@ export const blockProtocolDataTypes = {
},
emptyList: {
dataTypeId:
"https://blockprotocol.org/@blockprotocol/types/data-type/empty-list/v/1",
"https://blockprotocol.org/@blockprotocol/types/data-type/list/v/1",
dataTypeBaseUrl:
"https://blockprotocol.org/@blockprotocol/types/data-type/empty-list/" as BaseUrl,
title: "Empty List",
description: "An Empty List",
"https://blockprotocol.org/@blockprotocol/types/data-type/list/" as BaseUrl,
title: "List",
description: "An ordered list of values",
},
null: {
dataTypeId:
Expand Down
8 changes: 4 additions & 4 deletions libs/@local/hash-validation/src/test_data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,21 @@ async fn string() {
async fn array() {
validate_data(
json!([]),
graph_test_data::data_type::EMPTY_LIST_V1,
graph_test_data::data_type::LIST_V1,
[graph_test_data::data_type::VALUE_V1],
ValidateEntityComponents::full(),
)
.await
.expect("validation failed");

_ = validate_data(
validate_data(
json!(["foo", "bar"]),
graph_test_data::data_type::EMPTY_LIST_V1,
graph_test_data::data_type::LIST_V1,
[graph_test_data::data_type::VALUE_V1],
ValidateEntityComponents::full(),
)
.await
.expect_err("validation succeeded");
.expect("validation failed");
}

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion tests/hash-graph-benches/representative_read/seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::util::{StoreWrapper, seed};
const SEED_DATA_TYPES: [&str; 7] = [
data_type::VALUE_V1,
data_type::BOOLEAN_V1,
data_type::EMPTY_LIST_V1,
data_type::LIST_V1,
data_type::NULL_V1,
data_type::NUMBER_V1,
data_type::OBJECT_V1,
Expand Down
8 changes: 4 additions & 4 deletions tests/hash-graph-integration/postgres/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async fn insert() {

#[tokio::test]
async fn query() {
let empty_list_dt: DataType = serde_json::from_str(graph_test_data::data_type::EMPTY_LIST_V1)
let list_v1: DataType = serde_json::from_str(graph_test_data::data_type::LIST_V1)
.expect("could not parse data type representation");

let mut database = DatabaseTestWrapper::new().await;
Expand All @@ -75,7 +75,7 @@ async fn query() {
.expect("could not seed database");

api.create_data_type(api.account_id, CreateDataTypeParams {
schema: empty_list_dt.clone(),
schema: list_v1.clone(),
classification: OntologyTypeClassificationMetadata::Owned {
owned_by_id: OwnedById::new(api.account_id.into_uuid()),
},
Expand All @@ -89,7 +89,7 @@ async fn query() {

let data_types = api
.get_data_types(api.account_id, GetDataTypesParams {
filter: Filter::for_versioned_url(&empty_list_dt.id),
filter: Filter::for_versioned_url(&list_v1.id),
temporal_axes: QueryTemporalAxesUnresolved::DecisionTime {
pinned: PinnedTemporalAxisUnresolved::new(None),
variable: VariableTemporalAxisUnresolved::new(Some(TemporalBound::Unbounded), None),
Expand All @@ -108,7 +108,7 @@ async fn query() {
1,
"expected one data type, got {data_types:?}"
);
assert_eq!(data_types[0].schema.id, empty_list_dt.id);
assert_eq!(data_types[0].schema.id, list_v1.id);
}

#[tokio::test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"$schema": "https://blockprotocol.org/types/modules/graph/0.3/schema/data-type",
"kind": "dataType",
"$id": "https://blockprotocol.org/@blockprotocol/types/data-type/empty-list/v/1",
"$id": "https://blockprotocol.org/@blockprotocol/types/data-type/list/v/1",
"allOf": [
{
"$ref": "https://blockprotocol.org/@blockprotocol/types/data-type/value/v/1"
}
],
"title": "Empty List",
"description": "An Empty List",
"title": "List",
"description": "An ordered list of values",
"type": "array",
"items": false,
"abstract": false
}
2 changes: 1 addition & 1 deletion tests/hash-graph-test-data/rust/src/data_type/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub const VALUE_V1: &str = include_str!("value.json");

pub const BOOLEAN_V1: &str = include_str!("boolean.json");
pub const EMPTY_LIST_V1: &str = include_str!("empty_list.json");
pub const LIST_V1: &str = include_str!("list.json");
pub const NULL_V1: &str = include_str!("null.json");
pub const NUMBER_V1: &str = include_str!("number.json");
pub const OBJECT_V1: &str = include_str!("object_v1.json");
Expand Down

0 comments on commit f67494c

Please sign in to comment.