diff --git a/catalyst-gateway/bin/src/db/event/common/mod.rs b/catalyst-gateway/bin/src/db/event/common/mod.rs index 1a18688ff93..dae7db62fa5 100644 --- a/catalyst-gateway/bin/src/db/event/common/mod.rs +++ b/catalyst-gateway/bin/src/db/event/common/mod.rs @@ -1,4 +1,28 @@ //! Reusable common database objects -pub(crate) mod eq_or_ranged_uuid; pub(crate) mod query_limits; +pub(crate) mod uuid_list; +pub(crate) mod uuid_selector; + +/// SQL conditional statement trait +pub(crate) trait ConditionalStmt { + /// Return a sql conditional statement by the provided `table_field` + fn conditional_stmt( + &self, + f: &mut std::fmt::Formatter<'_>, + table_field: &str, + ) -> std::fmt::Result; +} + +impl ConditionalStmt for Option { + fn conditional_stmt( + &self, + f: &mut std::fmt::Formatter<'_>, + table_field: &str, + ) -> std::fmt::Result { + if let Some(v) = self { + v.conditional_stmt(f, table_field)?; + } + Ok(()) + } +} diff --git a/catalyst-gateway/bin/src/db/event/common/uuid_list.rs b/catalyst-gateway/bin/src/db/event/common/uuid_list.rs new file mode 100644 index 00000000000..4d23773ca60 --- /dev/null +++ b/catalyst-gateway/bin/src/db/event/common/uuid_list.rs @@ -0,0 +1,39 @@ +//! `UuidList` query conditional stmt object. + +use std::ops::Deref; + +use itertools::Itertools; + +use crate::db::event::common::ConditionalStmt; + +/// Search by a list of UUIDs. +#[derive(Clone, Debug, PartialEq, Default)] +pub(crate) struct UuidList(Vec); + +impl Deref for UuidList { + type Target = Vec; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl From> for UuidList { + fn from(value: Vec) -> Self { + Self(value) + } +} + +impl ConditionalStmt for UuidList { + fn conditional_stmt( + &self, + f: &mut std::fmt::Formatter<'_>, + table_field: &str, + ) -> std::fmt::Result { + write!( + f, + "{table_field} IN ({})", + self.0.iter().map(|uuid| format!("'{uuid}'")).join(",") + ) + } +} diff --git a/catalyst-gateway/bin/src/db/event/common/eq_or_ranged_uuid.rs b/catalyst-gateway/bin/src/db/event/common/uuid_selector.rs similarity index 52% rename from catalyst-gateway/bin/src/db/event/common/eq_or_ranged_uuid.rs rename to catalyst-gateway/bin/src/db/event/common/uuid_selector.rs index fd4225a42ef..dd133f0c7b3 100644 --- a/catalyst-gateway/bin/src/db/event/common/eq_or_ranged_uuid.rs +++ b/catalyst-gateway/bin/src/db/event/common/uuid_selector.rs @@ -1,5 +1,7 @@ //! `EqOrRangedUuid` query conditional stmt object. +use crate::db::event::common::{ConditionalStmt, uuid_list::UuidList}; + /// Search either by a singe UUID, a range of UUIDs or a list of UUIDs. #[derive(Clone, Debug, PartialEq)] pub(crate) enum UuidSelector { @@ -13,27 +15,21 @@ pub(crate) enum UuidSelector { max: uuid::Uuid, }, /// Search UUIDs in the given list. - In(Vec), + In(UuidList), } -impl UuidSelector { - /// Return a sql conditional statement by the provided `table_field` - pub(crate) fn conditional_stmt( +impl ConditionalStmt for UuidSelector { + fn conditional_stmt( &self, + f: &mut std::fmt::Formatter<'_>, table_field: &str, - ) -> String { + ) -> std::fmt::Result { match self { - Self::Eq(id) => format!("{table_field} = '{id}'"), + Self::Eq(id) => write!(f, "{table_field} = '{id}'"), Self::Range { min, max } => { - format!("{table_field} >= '{min}' AND {table_field} <= '{max}'") - }, - Self::In(ids) => { - itertools::intersperse( - ids.iter().map(|id| format!("{table_field} = '{id}'")), - " OR ".to_string(), - ) - .collect() + write!(f, "{table_field} >= '{min}' AND {table_field} <= '{max}'") }, + Self::In(ids) => ids.conditional_stmt(f, table_field), } } } diff --git a/catalyst-gateway/bin/src/db/event/signed_docs/doc_ref.rs b/catalyst-gateway/bin/src/db/event/signed_docs/doc_ref.rs index f93e3bf94e0..b05134ab3a4 100644 --- a/catalyst-gateway/bin/src/db/event/signed_docs/doc_ref.rs +++ b/catalyst-gateway/bin/src/db/event/signed_docs/doc_ref.rs @@ -1,8 +1,6 @@ //! Document Reference filtering object. -use std::fmt::Write; - -use crate::db::event::common::eq_or_ranged_uuid::UuidSelector; +use crate::db::event::common::{ConditionalStmt, uuid_selector::UuidSelector}; /// Document Reference filtering struct. #[derive(Clone, Debug)] @@ -13,30 +11,26 @@ pub(crate) struct DocumentRef { pub(crate) ver: Option, } -impl DocumentRef { - /// Return a sql conditional statement by the provided `table_field` - pub(crate) fn conditional_stmt( +impl ConditionalStmt for DocumentRef { + fn conditional_stmt( &self, + f: &mut std::fmt::Formatter<'_>, table_field: &str, - ) -> String { - let mut stmt = "TRUE".to_string(); + ) -> std::fmt::Result { + write!( + f, + "EXISTS (SELECT 1 FROM JSONB_ARRAY_ELEMENTS({table_field}) AS doc_ref WHERE TRUE" + )?; + if let Some(id) = &self.id { - let _ = write!( - stmt, - " AND {}", - id.conditional_stmt("(doc_ref->>'id')::uuid") - ); + write!(f, " AND ")?; + id.conditional_stmt(f, "(doc_ref->>'id')::uuid")?; } if let Some(ver) = &self.ver { - let _ = write!( - stmt, - " AND {}", - ver.conditional_stmt("(doc_ref->>'ver')::uuid") - ); + write!(f, " AND ")?; + ver.conditional_stmt(f, "(doc_ref->>'id')::uuid")?; } - format!( - "EXISTS (SELECT 1 FROM JSONB_ARRAY_ELEMENTS({table_field}) AS doc_ref WHERE {stmt})" - ) + write!(f, ")") } } diff --git a/catalyst-gateway/bin/src/db/event/signed_docs/query_filter.rs b/catalyst-gateway/bin/src/db/event/signed_docs/query_filter.rs index 324d642837d..e535709a3fa 100644 --- a/catalyst-gateway/bin/src/db/event/signed_docs/query_filter.rs +++ b/catalyst-gateway/bin/src/db/event/signed_docs/query_filter.rs @@ -3,26 +3,26 @@ use std::fmt::Display; use super::DocumentRef; -use crate::db::event::common::eq_or_ranged_uuid::UuidSelector; +use crate::db::event::common::{ConditionalStmt, uuid_list::UuidList, uuid_selector::UuidSelector}; /// A `select_signed_docs` query filtering argument. /// If all fields would be `None` the query will search for all entries from the db. #[derive(Clone, Debug, Default)] pub(crate) struct DocsQueryFilter { /// `type` field. Empty list if unspecified. - doc_type: Vec, + doc_type: UuidList, /// `id` field. `None` if unspecified. id: Option, /// `ver` field. `None` if unspecified. ver: Option, - /// `metadata->'ref'` field. Empty list if unspecified. - doc_ref: Vec, - /// `metadata->'template'` field. Empty list if unspecified. - template: Vec, - /// `metadata->'reply'` field. Empty list if unspecified. - reply: Vec, - /// `metadata->'parameters'` field. Empty list if unspecified. - parameters: Vec, + /// `metadata->'ref'` field. + doc_ref: Option, + /// `metadata->'template'` field. + template: Option, + /// `metadata->'reply'` field. + reply: Option, + /// `metadata->'parameters'` field. + parameters: Option, } impl Display for DocsQueryFilter { @@ -30,51 +30,51 @@ impl Display for DocsQueryFilter { &self, f: &mut std::fmt::Formatter<'_>, ) -> std::fmt::Result { - use std::fmt::Write; - let mut query = "TRUE".to_string(); - - if !self.doc_type.is_empty() { - write!( - &mut query, - " AND signed_docs.type IN ({})", - self.doc_type - .iter() - .map(|uuid| format!("'{uuid}'")) - .collect::>() - .join(",") - )?; - } - - if let Some(id) = &self.id { - write!(&mut query, " AND {}", id.conditional_stmt("signed_docs.id"))?; - } - if let Some(ver) = &self.ver { - write!( - &mut query, - " AND {}", - ver.conditional_stmt("signed_docs.ver") - )?; - } - let doc_ref_queries = [ - ("ref", &self.doc_ref), - ("template", &self.template), - ("reply", &self.reply), - ("parameters", &self.parameters), + write!(f, "TRUE")?; + + let stmts: [(_, Option<&dyn ConditionalStmt>); _] = [ + ( + "signed_docs.type", + (!self.doc_type.is_empty()).then_some(&self.doc_type), + ), + ( + "signed_docs.id", + self.id.as_ref().map(|v| -> &dyn ConditionalStmt { v }), + ), + ( + "signed_docs.ver", + self.ver.as_ref().map(|v| -> &dyn ConditionalStmt { v }), + ), + ( + "metadata->'ref'", + self.doc_ref.as_ref().map(|v| -> &dyn ConditionalStmt { v }), + ), + ( + "metadata->'template'", + self.template + .as_ref() + .map(|v| -> &dyn ConditionalStmt { v }), + ), + ( + "metadata->'reply'", + self.reply.as_ref().map(|v| -> &dyn ConditionalStmt { v }), + ), + ( + "metadata->'parameters'", + self.parameters + .as_ref() + .map(|v| -> &dyn ConditionalStmt { v }), + ), ]; - for (field_name, doc_refs) in doc_ref_queries { - if !doc_refs.is_empty() { - let stmt = doc_refs - .iter() - .map(|doc_ref| doc_ref.conditional_stmt(&format!("metadata->'{field_name}'"))) - .collect::>() - .join(" OR "); - - write!(&mut query, " AND ({stmt})")?; + for (field_name, stmt) in stmts { + if let Some(stmt) = stmt { + write!(f, " AND ",)?; + stmt.conditional_stmt(f, field_name)?; } } - write!(f, "{query}") + Ok(()) } } @@ -89,7 +89,10 @@ impl DocsQueryFilter { self, doc_type: Vec, ) -> Self { - DocsQueryFilter { doc_type, ..self } + DocsQueryFilter { + doc_type: doc_type.into(), + ..self + } } /// Set the `id` field filter condition @@ -119,10 +122,10 @@ impl DocsQueryFilter { self, arg: DocumentRef, ) -> Self { - let mut doc_ref = self.doc_ref; - doc_ref.push(arg); - - DocsQueryFilter { doc_ref, ..self } + DocsQueryFilter { + doc_ref: Some(arg), + ..self + } } /// Set the `metadata->'template'` field filter condition @@ -130,10 +133,10 @@ impl DocsQueryFilter { self, arg: DocumentRef, ) -> Self { - let mut template = self.template; - template.push(arg); - - DocsQueryFilter { template, ..self } + DocsQueryFilter { + template: Some(arg), + ..self + } } /// Set the `metadata->'reply'` field filter condition @@ -141,10 +144,10 @@ impl DocsQueryFilter { self, arg: DocumentRef, ) -> Self { - let mut reply = self.reply; - reply.push(arg); - - DocsQueryFilter { reply, ..self } + DocsQueryFilter { + reply: Some(arg), + ..self + } } /// Set the `metadata->'parameters'` field filter condition @@ -152,9 +155,9 @@ impl DocsQueryFilter { self, arg: DocumentRef, ) -> Self { - let mut parameters = self.parameters; - parameters.push(arg); - - DocsQueryFilter { parameters, ..self } + DocsQueryFilter { + parameters: Some(arg), + ..self + } } } diff --git a/catalyst-gateway/bin/src/db/event/signed_docs/tests/mod.rs b/catalyst-gateway/bin/src/db/event/signed_docs/tests/mod.rs index 9aca89bb6c0..6b7b5bdd93a 100644 --- a/catalyst-gateway/bin/src/db/event/signed_docs/tests/mod.rs +++ b/catalyst-gateway/bin/src/db/event/signed_docs/tests/mod.rs @@ -6,7 +6,7 @@ use futures::TryStreamExt; use super::*; use crate::db::event::{ - common::{eq_or_ranged_uuid::UuidSelector, query_limits::QueryLimits}, + common::{query_limits::QueryLimits, uuid_selector::UuidSelector}, establish_connection_pool, }; diff --git a/catalyst-gateway/bin/src/service/api/documents/post_document_index_query/v2/request.rs b/catalyst-gateway/bin/src/service/api/documents/post_document_index_query/v2/request.rs index 4a886c689c4..27455dd2cc5 100644 --- a/catalyst-gateway/bin/src/service/api/documents/post_document_index_query/v2/request.rs +++ b/catalyst-gateway/bin/src/service/api/documents/post_document_index_query/v2/request.rs @@ -28,7 +28,7 @@ pub(crate) struct DocumentIndexQueryFilterV2 { /// ## Signed Document Type. /// /// The document type must match one of the - /// [Registered Document Types](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/types/) + /// [Registered Document Types](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/types/) /// /// UUIDv4 Formatted 128bit value. #[oai(rename = "type", skip_serializing_if_is_none)] @@ -36,99 +36,73 @@ pub(crate) struct DocumentIndexQueryFilterV2 { /// ## Document ID /// /// Either an absolute single Document ID or a range of - /// [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id) + /// [Document IDs](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#id) #[oai(skip_serializing_if_is_none)] id: Option, /// ## Document Version /// /// Either an absolute single Document Version or a range of - /// [Document Versions](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver) + /// [Document Versions](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#ver) #[oai(skip_serializing_if_is_none)] ver: Option, /// ## Document Reference /// - /// A [reference](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/meta/#ref-document-reference) + /// A [reference](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#ref) /// to another signed document. This fields can match any reference that matches the - /// defined [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id) + /// defined [Document IDs](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#id) /// and/or - /// [Document Versions](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver) + /// [Document Versions](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#ver) /// /// The kind of document that the reference refers to is defined by the - /// [Document Type](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/types/) + /// [Document Type](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/types/) #[oai(rename = "ref", skip_serializing_if_is_none)] - doc_ref: Option, + doc_ref: Option, /// ## Document Template /// /// Documents that are created based on a template include the - /// [template reference](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/meta/#template-template-reference) + /// [template reference](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#template) /// to another signed document. This fields can match any template reference that - /// matches the defined [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id) + /// matches the defined [Document IDs](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#id) /// and/or - /// [Document Versions](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver) + /// [Document Versions](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#ver) /// /// The kind of document that the reference refers to is defined by the - /// [Document Type](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/types/) + /// [Document Type](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/types/) /// however, it will always be a template type document that matches the document /// itself. #[oai(skip_serializing_if_is_none)] - template: Option, + template: Option, /// ## Document Reply /// /// This is a - /// [reply reference](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/meta/#reply-reply-reference) + /// [reply reference](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#reply) /// which links one document to another, when acting as a reply to it. /// Replies typically reference the same kind of document. /// This fields can match any reply reference that matches the defined - /// [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id) + /// [Document IDs](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#id) /// and/or - /// [Document Versions](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver) + /// [Document Versions](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#ver) /// /// The kind of document that the reference refers to is defined by the - /// [Document Type](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/types/). + /// [Document Type](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/types/). #[oai(skip_serializing_if_is_none)] - reply: Option, - /// ## Brand + reply: Option, + /// ## Document Parameters /// /// This is a - /// [brand reference](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/meta/#brand_id) - /// to a brand document which defines the brand the document falls under. - /// This fields can match any brand reference that matches the defined - /// [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id) + /// [parameters reference](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#parameters). + /// Reference to a configuration document. + /// This fields can match any reference that matches the defined + /// [Document IDs](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#id) /// and/or - /// [Document Versions](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver) - /// - /// Whether a Document Type has a brand reference is defined by its - /// [Document Type](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/types/). - #[oai(skip_serializing_if_is_none)] - brand: Option, - /// ## Campaign - /// - /// This is a - /// [campaign reference](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/meta/#campaign_id) - /// to a campaign document which defines the campaign the document falls under. - /// This fields can match any campaign reference that matches the defined - /// [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id) - /// and/or - /// [Document Versions](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver) - /// - /// Whether a Document Type has a campaign reference is defined by its - /// [Document Type](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/types/). - #[oai(skip_serializing_if_is_none)] - campaign: Option, - /// ## Category - /// - /// This is a - /// [category reference](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/meta/#category_id) - /// to a category document which defines the category the document falls under. - /// This fields can match any category reference that matches the defined - /// [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id) - /// and/or - /// [Document Versions](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver) - /// - /// Whether a Document Type has a category reference is defined by its - /// [Document Type](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/types/). - #[oai(skip_serializing_if_is_none)] - category: Option, + /// [Document Versions](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#ver) + /// + /// Whether a Document Type has a brand, campaign, category etc. reference is defined + /// by its [Document Type](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/types/). + #[oai(skip_serializing_if_is_none, rename = "doc_parameters")] + // renaming to 'doc_parameters' because of the openapi linter, which cannot process + // 'parameters' name for the property of the object + parameters: Option, } impl Example for DocumentIndexQueryFilterV2 { @@ -140,8 +114,7 @@ impl Example for DocumentIndexQueryFilterV2 { doc_ref: Some(Example::example()), template: Some(Example::example()), reply: Some(Example::example()), - brand: Some(Example::example()), - ..Default::default() + parameters: Some(Example::example()), } } } @@ -163,23 +136,6 @@ impl Example for DocumentTypeList { } } -impl_array_types!( - IdAndVerRefDocumentedList, - IdAndVerRefDocumented, - Some(poem_openapi::registry::MetaSchema { - example: Self::example().to_json(), - max_items: Some(10), - items: Some(Box::new(IdAndVerRefDocumented::schema_ref())), - ..poem_openapi::registry::MetaSchema::ANY - }) -); - -impl Example for IdAndVerRefDocumentedList { - fn example() -> Self { - Self(vec![IdAndVerRefDocumented::example()]) - } -} - // Note: We need to do this, because POEM doesn't give us a way to set `"title"` for the // openapi docs on an object. #[derive(NewType)] @@ -223,53 +179,19 @@ impl TryFrom for DocsQueryFilter { { db_filter = db_filter.with_ver(version); } - if let Some(doc_refs) = value.doc_ref { - let doc_refs = doc_refs - .0 - .into_iter() - .map(TryInto::try_into) - .collect::, _>>()?; - - for doc_ref in doc_refs { - db_filter = db_filter.with_ref(doc_ref); - } + if let Some(doc_ref) = value.doc_ref { + db_filter = db_filter.with_ref(doc_ref.try_into()?); } - if let Some(templates) = value.template { - let templates = templates - .0 - .into_iter() - .map(TryInto::try_into) - .collect::, _>>()?; - - for template in templates { - db_filter = db_filter.with_template(template); - } + if let Some(template) = value.template { + db_filter = db_filter.with_template(template.try_into()?); } - if let Some(replies) = value.reply { - let replies = replies - .0 - .into_iter() - .map(TryInto::try_into) - .collect::, _>>()?; - - for reply in replies { - db_filter = db_filter.with_reply(reply); - } + if let Some(reply) = value.reply { + db_filter = db_filter.with_reply(reply.try_into()?); } - for params in [value.brand, value.campaign, value.category] - .into_iter() - .flatten() - { - let params = params - .0 - .into_iter() - .map(TryInto::try_into) - .collect::, _>>()?; - - for param in params { - db_filter = db_filter.with_parameters(param); - } + if let Some(parameters) = value.parameters { + db_filter = db_filter.with_parameters(parameters.try_into()?); } + Ok(db_filter) } } diff --git a/catalyst-gateway/bin/src/service/api/documents/post_document_index_query/v2/response.rs b/catalyst-gateway/bin/src/service/api/documents/post_document_index_query/v2/response.rs index 1e6b8b13886..b5a31e083e7 100644 --- a/catalyst-gateway/bin/src/service/api/documents/post_document_index_query/v2/response.rs +++ b/catalyst-gateway/bin/src/service/api/documents/post_document_index_query/v2/response.rs @@ -167,6 +167,8 @@ pub(crate) struct IndexedDocumentVersionV2 { pub template: Option, /// Document Parameter Reference that matches the filter #[oai(rename = "doc_parameters", skip_serializing_if_is_none)] + // renaming to 'doc_parameters' because of the openapi linter, which cannot process + // 'parameters' name for the property of the object pub parameters: Option, /// A list of collaborators who can participate in drafting and submitting a document /// that matches the filter. diff --git a/catalyst-gateway/bin/src/service/api/mod.rs b/catalyst-gateway/bin/src/service/api/mod.rs index 80bd3f94965..017b27b7f65 100644 --- a/catalyst-gateway/bin/src/service/api/mod.rs +++ b/catalyst-gateway/bin/src/service/api/mod.rs @@ -23,7 +23,7 @@ pub(crate) mod health; const API_TITLE: &str = "Catalyst Gateway"; /// The version of the API -const API_VERSION: &str = "0.8.0"; +const API_VERSION: &str = "0.9.0"; /// Get the contact details for inquiring about the API fn get_api_contact() -> ContactObject { diff --git a/catalyst-gateway/bin/src/service/common/types/document/id.rs b/catalyst-gateway/bin/src/service/common/types/document/id.rs index 8e94d1c434a..1f8b7f7862d 100644 --- a/catalyst-gateway/bin/src/service/common/types/document/id.rs +++ b/catalyst-gateway/bin/src/service/common/types/document/id.rs @@ -14,7 +14,7 @@ use serde_json::Value; use self::generic::uuidv7; use crate::{ - db::event::common::eq_or_ranged_uuid::UuidSelector, + db::event::common::uuid_selector::UuidSelector, service::common::types::{ array_types::impl_array_types, generic, string_types::impl_string_types, }, @@ -302,7 +302,8 @@ impl TryFrom for UuidSelector { Vec::from(ids.0.r#in) .into_iter() .map(|id| id.0.parse::()) - .collect::>()?, + .collect::, _>>()? + .into(), )) }, } @@ -344,7 +345,8 @@ impl TryFrom for Option { Vec::from(ids.0.r#in) .into_iter() .map(|id| id.0.parse::()) - .collect::>()?, + .collect::, _>>()? + .into(), ))) }, IdSelector::In(_) => Ok(None), diff --git a/catalyst-gateway/bin/src/service/common/types/document/ver.rs b/catalyst-gateway/bin/src/service/common/types/document/ver.rs index 4e0c09cb71a..ac44fb471f9 100644 --- a/catalyst-gateway/bin/src/service/common/types/document/ver.rs +++ b/catalyst-gateway/bin/src/service/common/types/document/ver.rs @@ -14,7 +14,7 @@ use serde_json::Value; use self::generic::uuidv7; use crate::{ - db::event::common::eq_or_ranged_uuid::UuidSelector, + db::event::common::uuid_selector::UuidSelector, service::common::types::{ array_types::impl_array_types, generic, string_types::impl_string_types, }, @@ -313,7 +313,8 @@ impl TryFrom for UuidSelector { Vec::<_>::from(vers.0.r#in) .into_iter() .map(|v| v.0.parse::()) - .collect::>()?, + .collect::, _>>()? + .into(), )) }, } @@ -355,7 +356,8 @@ impl TryFrom for Option { Vec::<_>::from(vers.0.r#in) .into_iter() .map(|v| v.0.parse()) - .collect::>()?, + .collect::, _>>()? + .into(), ))) }, VerSelector::In(_) => Ok(None),