From 62ac660e58fcd984f3a83d92e568a89788526cf0 Mon Sep 17 00:00:00 2001 From: Nokome Date: Sun, 29 Aug 2021 16:59:35 +1200 Subject: [PATCH] fix(Rust): Exclude content and parts and add title for simple versions --- rust/src/types.rs | 37 ++++++++++++++++++++----------------- ts/bindings/rust.ts | 13 ++++++++++++- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/rust/src/types.rs b/rust/src/types.rs index e9d75926..00790613 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -938,6 +938,9 @@ pub struct ClaimSimple { /// Elements of the collection which can be a variety of different elements, such as Articles, Datatables, Tables and more. pub parts: Option>, + + /// The title of the creative work. + pub title: Option>, } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -1071,6 +1074,9 @@ pub struct CollectionSimple { /// The identifier for this item. pub id: Option>, + + /// The title of the creative work. + pub title: Option>, } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -1575,9 +1581,6 @@ pub struct AudioObjectSimple { /// The caption for this audio recording. pub caption: Option>, - /// The structured content of this creative work c.f. property `text`. - pub content: Option>, - /// File size in megabits (Mbit, Mb). pub content_size: Option, @@ -1590,8 +1593,8 @@ pub struct AudioObjectSimple { /// IANA media type (MIME type). pub media_type: Option>, - /// Elements of the collection which can be a variety of different elements, such as Articles, Datatables, Tables and more. - pub parts: Option>, + /// The title of the creative work. + pub title: Option>, /// The transcript of this audio recording. pub transcript: Option>, @@ -1987,6 +1990,9 @@ pub struct FigureSimple { /// Elements of the collection which can be a variety of different elements, such as Articles, Datatables, Tables and more. pub parts: Option>, + + /// The title of the creative work. + pub title: Option>, } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -2243,9 +2249,6 @@ pub struct ImageObjectSimple { /// The caption for this image. pub caption: Option>, - /// The structured content of this creative work c.f. property `text`. - pub content: Option>, - /// File size in megabits (Mbit, Mb). pub content_size: Option, @@ -2258,11 +2261,11 @@ pub struct ImageObjectSimple { /// IANA media type (MIME type). pub media_type: Option>, - /// Elements of the collection which can be a variety of different elements, such as Articles, Datatables, Tables and more. - pub parts: Option>, - /// Thumbnail image of this image. pub thumbnail: Option>, + + /// The title of the creative work. + pub title: Option>, } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -4165,6 +4168,9 @@ pub struct TableSimple { /// Elements of the collection which can be a variety of different elements, such as Articles, Datatables, Tables and more. pub parts: Option>, + + /// The title of the creative work. + pub title: Option>, } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -4459,9 +4465,6 @@ pub struct VideoObjectSimple { /// The caption for this video recording. pub caption: Option>, - /// The structured content of this creative work c.f. property `text`. - pub content: Option>, - /// File size in megabits (Mbit, Mb). pub content_size: Option, @@ -4474,12 +4477,12 @@ pub struct VideoObjectSimple { /// IANA media type (MIME type). pub media_type: Option>, - /// Elements of the collection which can be a variety of different elements, such as Articles, Datatables, Tables and more. - pub parts: Option>, - /// Thumbnail image of this video recording. pub thumbnail: Option>, + /// The title of the creative work. + pub title: Option>, + /// The transcript of this video recording. pub transcript: Option>, } diff --git a/ts/bindings/rust.ts b/ts/bindings/rust.ts index 0ac8141b..30be9d62 100644 --- a/ts/bindings/rust.ts +++ b/ts/bindings/rust.ts @@ -329,8 +329,19 @@ export function interfaceSchemaToSimpleStruct( const filteredProperties = Object.fromEntries( Object.entries(properties).reduce( (prev: [string, JsonSchema][], [name, property]) => { + let keepers: string[] + switch (title) { + case 'MediaObject': + case 'AudioObject': + case 'ImageObject': + case 'VideoObject': + keepers = ['title'] + break + default: + keepers = ['title', 'content', 'parts'] + } const keep = - ['content', 'parts'].includes(name) || + keepers.includes(name) || !['Thing', 'CreativeWork'].includes(property.from ?? '') return keep ? [...prev, [name, property]] : prev },