Skip to content

Commit 55d12a5

Browse files
committed
wip update request part
1 parent f2b71f9 commit 55d12a5

File tree

1 file changed

+37
-101
lines changed
  • catalyst-gateway/bin/src/service/api/documents/post_document_index_query/v2

1 file changed

+37
-101
lines changed

catalyst-gateway/bin/src/service/api/documents/post_document_index_query/v2/request.rs

Lines changed: 37 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -28,107 +28,77 @@ pub(crate) struct DocumentIndexQueryFilterV2 {
2828
/// ## Signed Document Type.
2929
///
3030
/// The document type must match one of the
31-
/// [Registered Document Types](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/types/)
31+
/// [Registered Document Types](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/types/)
3232
///
3333
/// UUIDv4 Formatted 128bit value.
3434
#[oai(rename = "type", skip_serializing_if_is_none)]
3535
doc_type: Option<DocumentTypeList>,
3636
/// ## Document ID
3737
///
3838
/// Either an absolute single Document ID or a range of
39-
/// [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id)
39+
/// [Document IDs](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#id)
4040
#[oai(skip_serializing_if_is_none)]
4141
id: Option<IdSelectorDocumented>,
4242
/// ## Document Version
4343
///
4444
/// Either an absolute single Document Version or a range of
45-
/// [Document Versions](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver)
45+
/// [Document Versions](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#ver)
4646
#[oai(skip_serializing_if_is_none)]
4747
ver: Option<VerSelectorDocumented>,
4848
/// ## Document Reference
4949
///
50-
/// A [reference](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/meta/#ref-document-reference)
50+
/// A [reference](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#ref)
5151
/// to another signed document. This fields can match any reference that matches the
52-
/// defined [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id)
52+
/// defined [Document IDs](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#id)
5353
/// and/or
54-
/// [Document Versions](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver)
54+
/// [Document Versions](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#ver)
5555
///
5656
/// The kind of document that the reference refers to is defined by the
57-
/// [Document Type](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/types/)
57+
/// [Document Type](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/types/)
5858
#[oai(rename = "ref", skip_serializing_if_is_none)]
59-
doc_ref: Option<IdAndVerRefDocumentedList>,
59+
doc_ref: Option<IdAndVerRefDocumented>,
6060
/// ## Document Template
6161
///
6262
/// Documents that are created based on a template include the
63-
/// [template reference](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/meta/#template-template-reference)
63+
/// [template reference](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#template)
6464
/// to another signed document. This fields can match any template reference that
65-
/// matches the defined [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id)
65+
/// matches the defined [Document IDs](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#id)
6666
/// and/or
67-
/// [Document Versions](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver)
67+
/// [Document Versions](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#ver)
6868
///
6969
/// The kind of document that the reference refers to is defined by the
70-
/// [Document Type](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/types/)
70+
/// [Document Type](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/types/)
7171
/// however, it will always be a template type document that matches the document
7272
/// itself.
7373
#[oai(skip_serializing_if_is_none)]
74-
template: Option<IdAndVerRefDocumentedList>,
74+
template: Option<IdAndVerRefDocumented>,
7575
/// ## Document Reply
7676
///
7777
/// This is a
78-
/// [reply reference](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/meta/#reply-reply-reference)
78+
/// [reply reference](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#reply)
7979
/// which links one document to another, when acting as a reply to it.
8080
/// Replies typically reference the same kind of document.
8181
/// This fields can match any reply reference that matches the defined
82-
/// [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id)
82+
/// [Document IDs](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#id)
8383
/// and/or
84-
/// [Document Versions](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver)
84+
/// [Document Versions](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#ver)
8585
///
8686
/// The kind of document that the reference refers to is defined by the
87-
/// [Document Type](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/types/).
87+
/// [Document Type](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/types/).
8888
#[oai(skip_serializing_if_is_none)]
89-
reply: Option<IdAndVerRefDocumentedList>,
90-
/// ## Brand
89+
reply: Option<IdAndVerRefDocumented>,
90+
/// ## Parameters
9191
///
92-
/// This is a
93-
/// [brand reference](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/meta/#brand_id)
94-
/// to a brand document which defines the brand the document falls under.
95-
/// This fields can match any brand reference that matches the defined
96-
/// [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id)
97-
/// and/or
98-
/// [Document Versions](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver)
99-
///
100-
/// Whether a Document Type has a brand reference is defined by its
101-
/// [Document Type](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/types/).
102-
#[oai(skip_serializing_if_is_none)]
103-
brand: Option<IdAndVerRefDocumentedList>,
104-
/// ## Campaign
105-
///
106-
/// This is a
107-
/// [campaign reference](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/meta/#campaign_id)
108-
/// to a campaign document which defines the campaign the document falls under.
109-
/// This fields can match any campaign reference that matches the defined
110-
/// [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id)
111-
/// and/or
112-
/// [Document Versions](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver)
113-
///
114-
/// Whether a Document Type has a campaign reference is defined by its
115-
/// [Document Type](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/types/).
116-
#[oai(skip_serializing_if_is_none)]
117-
campaign: Option<IdAndVerRefDocumentedList>,
118-
/// ## Category
119-
///
120-
/// This is a
121-
/// [category reference](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/meta/#category_id)
122-
/// to a category document which defines the category the document falls under.
123-
/// This fields can match any category reference that matches the defined
124-
/// [Document IDs](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#id)
92+
/// This is a reference to a configuration document.
93+
/// This fields can match any reference that matches the defined
94+
/// [Document IDs](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#id)
12595
/// and/or
126-
/// [Document Versions](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/spec/#ver)
96+
/// [Document Versions](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/metadata/#ver)
12797
///
128-
/// Whether a Document Type has a category reference is defined by its
129-
/// [Document Type](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/signed_doc/types/).
98+
/// Whether a Document Type has a brand, campaign, category etc. reference is defined
99+
/// by its [Document Type](https://docs.dev.projectcatalyst.io/libs/main/architecture/08_concepts/signed_doc/types/).
130100
#[oai(skip_serializing_if_is_none)]
131-
category: Option<IdAndVerRefDocumentedList>,
101+
parameters: Option<IdAndVerRefDocumented>,
132102
}
133103

134104
impl Example for DocumentIndexQueryFilterV2 {
@@ -140,8 +110,7 @@ impl Example for DocumentIndexQueryFilterV2 {
140110
doc_ref: Some(Example::example()),
141111
template: Some(Example::example()),
142112
reply: Some(Example::example()),
143-
brand: Some(Example::example()),
144-
..Default::default()
113+
parameters: Some(Example::example()),
145114
}
146115
}
147116
}
@@ -223,53 +192,20 @@ impl TryFrom<DocumentIndexQueryFilterV2> for DocsQueryFilter {
223192
{
224193
db_filter = db_filter.with_ver(version);
225194
}
226-
if let Some(doc_refs) = value.doc_ref {
227-
let doc_refs = doc_refs
228-
.0
229-
.into_iter()
230-
.map(TryInto::try_into)
231-
.collect::<Result<Vec<_>, _>>()?;
232-
233-
for doc_ref in doc_refs {
234-
db_filter = db_filter.with_ref(doc_ref);
235-
}
195+
if let Some(doc_ref) = value.doc_ref {
196+
db_filter = db_filter.with_ref(doc_ref.try_into()?);
236197
}
237-
if let Some(templates) = value.template {
238-
let templates = templates
239-
.0
240-
.into_iter()
241-
.map(TryInto::try_into)
242-
.collect::<Result<Vec<_>, _>>()?;
243-
244-
for template in templates {
245-
db_filter = db_filter.with_template(template);
246-
}
198+
if let Some(template) = value.template {
199+
db_filter = db_filter.with_template(template.try_into()?);
247200
}
248-
if let Some(replies) = value.reply {
249-
let replies = replies
250-
.0
251-
.into_iter()
252-
.map(TryInto::try_into)
253-
.collect::<Result<Vec<_>, _>>()?;
254-
255-
for reply in replies {
256-
db_filter = db_filter.with_reply(reply);
257-
}
201+
if let Some(reply) = value.reply {
202+
db_filter = db_filter.with_reply(reply.try_into()?);
203+
258204
}
259-
for params in [value.brand, value.campaign, value.category]
260-
.into_iter()
261-
.flatten()
262-
{
263-
let params = params
264-
.0
265-
.into_iter()
266-
.map(TryInto::try_into)
267-
.collect::<Result<Vec<_>, _>>()?;
268-
269-
for param in params {
270-
db_filter = db_filter.with_parameters(param);
271-
}
205+
if let Some(parameters) = value.parameters {
206+
db_filter = db_filter.with_parameters(parameters.try_into()?);
272207
}
208+
273209
Ok(db_filter)
274210
}
275211
}

0 commit comments

Comments
 (0)