From 3656a03f0b09e845c3be6776a6fea45eb48e9e77 Mon Sep 17 00:00:00 2001 From: ccamel Date: Tue, 17 Dec 2024 09:57:21 +0100 Subject: [PATCH 1/2] refactor(cognitarium): move query messages into dedicated AST file --- contracts/axone-cognitarium/src/contract.rs | 61 ++-- contracts/axone-cognitarium/src/lib.rs | 1 + contracts/axone-cognitarium/src/msg.rs | 297 +----------------- contracts/axone-cognitarium/src/parser/ast.rs | 295 +++++++++++++++++ contracts/axone-cognitarium/src/parser/mod.rs | 3 + .../axone-cognitarium/src/querier/engine.rs | 2 +- .../src/querier/expression.rs | 30 +- .../axone-cognitarium/src/querier/mapper.rs | 2 +- .../src/querier/plan_builder.rs | 82 ++--- .../axone-cognitarium/src/querier/variable.rs | 2 +- contracts/axone-cognitarium/src/rdf/mapper.rs | 50 +-- contracts/axone-dataverse/src/contract.rs | 7 +- .../axone-dataverse/src/registrar/registry.rs | 7 +- .../axone-cognitarium-client/src/client.rs | 3 +- 14 files changed, 429 insertions(+), 413 deletions(-) create mode 100644 contracts/axone-cognitarium/src/parser/ast.rs create mode 100644 contracts/axone-cognitarium/src/parser/mod.rs diff --git a/contracts/axone-cognitarium/src/contract.rs b/contracts/axone-cognitarium/src/contract.rs index 6f36ecbf..57ba3323 100644 --- a/contracts/axone-cognitarium/src/contract.rs +++ b/contracts/axone-cognitarium/src/contract.rs @@ -53,7 +53,8 @@ pub fn execute( pub mod execute { use super::*; - use crate::msg::{DataFormat, Prefix, TripleDeleteTemplate, WhereClause}; + use crate::msg::DataFormat; + use crate::parser::{Prefix, TripleDeleteTemplate, WhereClause}; use crate::querier::{PlanBuilder, QueryEngine, QueryPlan, ResolvedVariables}; use crate::rdf::PrefixMap; use crate::state::{HasCachedNamespaces, Triple}; @@ -167,10 +168,10 @@ pub fn query(deps: Deps<'_>, _env: Env, msg: QueryMsg) -> StdResult { pub mod query { use super::*; - use crate::msg::{ - ConstructQuery, ConstructResponse, DescribeQuery, DescribeResponse, Node, SelectQuery, - SelectResponse, StoreResponse, TripleConstructTemplate, TriplePattern, VarOrNamedNode, - VarOrNode, VarOrNodeOrLiteral, WhereClause, + use crate::msg::{ConstructResponse, DescribeResponse, SelectResponse, StoreResponse}; + use crate::parser::{ConstructQuery, DescribeQuery, SelectQuery, WhereClause}; + use crate::parser::{ + Node, TripleConstructTemplate, TriplePattern, VarOrNamedNode, VarOrNode, VarOrNodeOrLiteral, }; use crate::querier::{PlanBuilder, QueryEngine}; use crate::rdf::PrefixMap; @@ -334,9 +335,9 @@ pub mod query { pub mod util { use super::*; - use crate::msg::{ - Head, Prefix, Results, SelectResponse, Value, VarOrNamedNode, VarOrNode, - VarOrNodeOrLiteral, WhereClause, + use crate::msg::{Head, Results, SelectResponse}; + use crate::parser::{ + Prefix, Value, VarOrNamedNode, VarOrNode, VarOrNodeOrLiteral, WhereClause, }; use crate::querier::{PlanBuilder, QueryEngine, SelectResults}; use crate::rdf::{Atom, PrefixMap}; @@ -414,19 +415,21 @@ mod tests { use super::*; use crate::error::StoreError; use crate::msg::ExecuteMsg::{DeleteData, InsertData}; - use crate::msg::Node::{BlankNode, NamedNode}; - use crate::msg::IRI::{Full, Prefixed}; use crate::msg::{ - ConstructQuery, ConstructResponse, DescribeQuery, DescribeResponse, Head, Literal, Prefix, - Results, SelectItem, SelectQuery, SelectResponse, StoreLimitsInput, - StoreLimitsInputBuilder, StoreResponse, Value, VarOrNamedNode, VarOrNamedNodeOrLiteral, - VarOrNode, VarOrNodeOrLiteral, + ConstructResponse, DescribeResponse, Head, Results, SelectResponse, StoreLimitsInput, + StoreLimitsInputBuilder, StoreResponse, + }; + use crate::parser::Node::{BlankNode, NamedNode}; + use crate::parser::IRI::{Full, Prefixed}; + use crate::parser::{ConstructQuery, DescribeQuery, Prefix, SelectQuery, Value, WhereClause}; + use crate::parser::{ + Literal, SelectItem, TriplePattern, VarOrNamedNode, VarOrNamedNodeOrLiteral, VarOrNode, + VarOrNodeOrLiteral, }; - use crate::msg::{TriplePattern, WhereClause}; use crate::state::{ namespaces, triples, Namespace, Node, Object, StoreLimits, StoreStat, Subject, Triple, }; - use crate::{msg, state}; + use crate::{msg, parser, state}; use cosmwasm_std::testing::{message_info, mock_dependencies, mock_env}; use cosmwasm_std::{coins, from_json, Addr, Attribute, Order, Uint128}; use cw_utils::PaymentError; @@ -882,7 +885,7 @@ mod tests { ( DeleteData { prefixes: vec![], - delete: vec![msg::TripleDeleteTemplate { + delete: vec![parser::TripleDeleteTemplate { subject: VarOrNamedNode::NamedNode(Full( "https://ontology.axone.space/dataverse/dataspace/metadata/unknown" .to_string(), @@ -917,7 +920,7 @@ mod tests { ( DeleteData { prefixes: vec![], - delete: vec![msg::TripleDeleteTemplate { + delete: vec![parser::TripleDeleteTemplate { subject: VarOrNamedNode::NamedNode(Full(id.to_string())), predicate: VarOrNamedNode::NamedNode(Full( "https://ontology.axone.space/core/hasTopic".to_string(), @@ -955,7 +958,7 @@ mod tests { namespace: "https://ontology.axone.space/thesaurus/topic/".to_string(), }, ], - delete: vec![msg::TripleDeleteTemplate { + delete: vec![parser::TripleDeleteTemplate { subject: VarOrNamedNode::NamedNode(Full(id.to_string())), predicate: VarOrNamedNode::NamedNode(Prefixed("core:hasTopic".to_string())), object: VarOrNamedNodeOrLiteral::NamedNode(Prefixed( @@ -991,7 +994,7 @@ mod tests { namespace: "https://ontology.axone.space/thesaurus/topic/".to_string(), }, ], - delete: vec![msg::TripleDeleteTemplate { + delete: vec![parser::TripleDeleteTemplate { subject: VarOrNamedNode::NamedNode(Full(id.to_string())), predicate: VarOrNamedNode::NamedNode(Prefixed("core:hasTopic".to_string())), object: VarOrNamedNodeOrLiteral::Variable("o".to_string()), @@ -1014,7 +1017,7 @@ mod tests { ( DeleteData { prefixes: vec![], - delete: vec![msg::TripleDeleteTemplate { + delete: vec![parser::TripleDeleteTemplate { subject: VarOrNamedNode::NamedNode(Full(id.to_string())), predicate: VarOrNamedNode::Variable("p".to_string()), object: VarOrNamedNodeOrLiteral::Variable("o".to_string()), @@ -1078,7 +1081,7 @@ mod tests { namespace: "https://ontology.axone.space/thesaurus/topic/".to_string(), }, ], - delete: vec![msg::TripleDeleteTemplate { + delete: vec![parser::TripleDeleteTemplate { subject: VarOrNamedNode::NamedNode(Full(id.to_string())), predicate: VarOrNamedNode::NamedNode(Prefixed("core:hasTopic".to_string())), object: VarOrNamedNodeOrLiteral::NamedNode(Prefixed( @@ -1160,7 +1163,7 @@ mod tests { TC { command: DeleteData { prefixes: vec![], - delete: vec![msg::TripleDeleteTemplate { + delete: vec![parser::TripleDeleteTemplate { subject: VarOrNamedNode::NamedNode(Prefixed("foo:bar".to_string())), predicate: VarOrNamedNode::NamedNode(Full( "https://ontology.axone.space/core/hasTopic".to_string(), @@ -1187,7 +1190,7 @@ mod tests { TC { command: DeleteData { prefixes: vec![], - delete: vec![msg::TripleDeleteTemplate { + delete: vec![parser::TripleDeleteTemplate { subject: VarOrNamedNode::NamedNode(Full( "https://ontology.axone.space/thesaurus/topic/Test".to_string(), )), @@ -2279,7 +2282,7 @@ mod tests { Prefix { prefix: "metadata-dataset".to_string(), namespace: "https://ontology.axone.space/dataverse/dataset/metadata/".to_string() }, ], construct: vec![ - msg::TripleConstructTemplate { + parser::TripleConstructTemplate { subject: VarOrNode::Node(NamedNode(Prefixed("my-ns:instance-1".to_string()))), predicate: VarOrNamedNode::NamedNode(Full( "https://my-ns/predicate/tag".to_string(), @@ -2315,26 +2318,26 @@ mod tests { Prefix { prefix: "metadata-dataset".to_string(), namespace: "https://ontology.axone.space/dataverse/dataset/metadata/".to_string() }, ], construct: vec![ - msg::TripleConstructTemplate { + parser::TripleConstructTemplate { subject: VarOrNode::Node(BlankNode("my-metadata".to_string())), predicate: VarOrNamedNode::NamedNode(Full( "https://my-ns/predicate/tcov".to_string(), )), object: VarOrNodeOrLiteral::Variable("tcov".to_string()), }, - msg::TripleConstructTemplate { + parser::TripleConstructTemplate { subject: VarOrNode::Node(BlankNode("my-metadata".to_string())), predicate: VarOrNamedNode::NamedNode(Full( "https://my-ns/predicate/info".to_string(), )), object: VarOrNodeOrLiteral::Variable("info".to_string()), }, - msg::TripleConstructTemplate { + parser::TripleConstructTemplate { subject: VarOrNode::Variable("tcov".to_string()), predicate: VarOrNamedNode::Variable("tcov_p".to_string()), object: VarOrNodeOrLiteral::Variable("tcov_o".to_string()), }, - msg::TripleConstructTemplate { + parser::TripleConstructTemplate { subject: VarOrNode::Variable("info".to_string()), predicate: VarOrNamedNode::Variable("info_p".to_string()), object: VarOrNodeOrLiteral::Variable("info_o".to_string()), diff --git a/contracts/axone-cognitarium/src/lib.rs b/contracts/axone-cognitarium/src/lib.rs index 365515f9..14419671 100644 --- a/contracts/axone-cognitarium/src/lib.rs +++ b/contracts/axone-cognitarium/src/lib.rs @@ -1,6 +1,7 @@ pub mod contract; mod error; pub mod msg; +pub mod parser; mod querier; mod rdf; pub mod state; diff --git a/contracts/axone-cognitarium/src/msg.rs b/contracts/axone-cognitarium/src/msg.rs index eb9baefc..a3b402da 100644 --- a/contracts/axone-cognitarium/src/msg.rs +++ b/contracts/axone-cognitarium/src/msg.rs @@ -1,3 +1,6 @@ +use crate::parser::{ + ConstructQuery, DescribeQuery, Prefix, SelectQuery, TripleDeleteTemplate, Value, WhereClause, +}; use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{Binary, Uint128}; use derive_builder::Builder; @@ -303,20 +306,6 @@ pub struct StoreStat { pub byte_size: Uint128, } -/// # IRI -/// Represents an IRI. -#[cw_serde] -pub enum IRI { - /// # Prefixed - /// An IRI prefixed with a prefix. - /// The prefixed IRI is expanded to a full IRI using the prefix definition specified in the query. - /// For example, the prefixed IRI `rdf:type` is expanded to `http://www.w3.org/1999/02/22-rdf-syntax-ns#type`. - Prefixed(String), - /// # Full - /// A full IRI. - Full(String), -} - /// # SelectResponse /// Represents the response of a [QueryMsg::Select] query. #[cw_serde] @@ -363,286 +352,6 @@ pub struct Results { pub bindings: Vec>, } -/// # Value -#[cw_serde] -#[serde(tag = "type")] -pub enum Value { - /// # URI - /// Represents an IRI. - #[serde(rename = "uri")] - URI { - /// The value of the IRI. - value: IRI, - }, - /// # Literal - /// Represents a literal S with optional language tag L or datatype IRI D. - Literal { - /// The value of the literal. - value: String, - /// The language tag of the literal. - #[serde(rename = "xml:lang")] - lang: Option, - /// The datatype of the literal. - datatype: Option, - }, - /// # BlankNode - /// Represents a blank node. - BlankNode { - /// The identifier of the blank node. - value: String, - }, -} - -/// # SelectQuery -/// Represents a SELECT query over the triple store, allowing to select variables to return -/// and to filter the results. -#[cw_serde] -pub struct SelectQuery { - /// The prefixes used in the query. - pub prefixes: Vec, - /// The items to select. - /// Note: the number of items to select cannot exceed the maximum query variable count defined - /// in the store limitations. - pub select: Vec, - /// The WHERE clause. - /// If `None`, there is no WHERE clause, i.e. all triples are returned without filtering. - pub r#where: WhereClause, - /// The maximum number of results to return. - /// If `None`, there is no limit. - /// Note: the value of the limit cannot exceed the maximum query limit defined in the store - /// limitations. - pub limit: Option, -} - -/// # DescribeQuery -/// Represents a DESCRIBE query over the triple store, allowing to retrieve a description of a resource -/// as a set of triples serialized in a specific format. -#[cw_serde] -pub struct DescribeQuery { - /// The prefixes used in the query. - pub prefixes: Vec, - /// The resource to describe given as a variable or a node. - pub resource: VarOrNamedNode, - /// The WHERE clause. - /// This clause is used to specify the resource identifier to describe using variable bindings. - pub r#where: Option, -} - -/// # ConstructQuery -/// Represents a CONSTRUCT query over the triple store, allowing to retrieve a set of triples -/// serialized in a specific format. -#[cw_serde] -pub struct ConstructQuery { - /// The prefixes used in the query. - pub prefixes: Vec, - /// The triples to construct. - /// If nothing is provided and the `where` clause is a single Bgp, the patterns are used for - /// construction. - pub construct: Vec, - /// The WHERE clause. - /// This clause is used to specify the triples to construct using variable bindings. - pub r#where: WhereClause, -} - -/// # Prefix -/// Represents a prefix, i.e. a shortcut for a namespace used in a query. -#[cw_serde] -pub struct Prefix { - /// The prefix. - pub prefix: String, - /// The namespace associated with the prefix. - pub namespace: String, -} - -/// # SelectItem -/// Represents an item to select in a [SelectQuery]. -#[cw_serde] -pub enum SelectItem { - /// # Variable - /// Represents a variable. - Variable(String), -} - -/// # WhereClause -/// Represents a WHERE clause, i.e. a set of conditions to filter the results. -#[cw_serde] -pub enum WhereClause { - /// # Bgp - /// Represents a basic graph pattern expressed as a set of triple patterns. - Bgp { patterns: Vec }, - - /// # LateralJoin - /// Evaluates right for all result row of left - LateralJoin { left: Box, right: Box }, - - /// # Filter - /// Filters the inner clause matching the expression. - /// The solutions coming from the inner clause that do not match the expression are discarded. - /// The variables provided in the inner clause are available in the filter expression. - Filter { expr: Expression, inner: Box }, -} - -/// # Expression -/// Represents a logical combination of operations whose evaluation results in a term. -#[cw_serde] -pub enum Expression { - /// A named node constant. - NamedNode(IRI), - /// A literal constant. - Literal(Literal), - /// A variable that must be bound for evaluation. - Variable(String), - /// Logical conjunction of expressions. - /// All expressions must evaluate to true for the conjunction to be true. - /// If the conjunction is empty, it is considered true. - And(Vec), - /// Logical disjunction of expressions. - /// At least one expression must evaluate to true for the disjunction to be true. - /// If the disjunction is empty, it is considered false. - Or(Vec), - /// Equality comparison. - Equal(Box, Box), - /// Greater than comparison. - Greater(Box, Box), - /// Greater or equal comparison. - GreaterOrEqual(Box, Box), - /// Less than comparison. - Less(Box, Box), - /// Less or equal comparison. - LessOrEqual(Box, Box), - /// Negation of an expression. - Not(Box), -} - -/// # TripleDeleteTemplate -/// Represents a triple template to be deleted. -#[cw_serde] -pub struct TripleDeleteTemplate { - /// The subject of the triple pattern. - pub subject: VarOrNamedNode, - /// The predicate of the triple pattern. - pub predicate: VarOrNamedNode, - /// The object of the triple pattern. - pub object: VarOrNamedNodeOrLiteral, -} - -/// # TripleConstructTemplate -/// Represents a triple template to be forged for a construct query. -#[cw_serde] -pub struct TripleConstructTemplate { - /// The subject of the triple pattern. - pub subject: VarOrNode, - /// The predicate of the triple pattern. - pub predicate: VarOrNamedNode, - /// The object of the triple pattern. - pub object: VarOrNodeOrLiteral, -} - -/// # TriplePattern -/// Represents a triple pattern in a [SimpleWhereCondition]. -#[cw_serde] -pub struct TriplePattern { - /// The subject of the triple pattern. - pub subject: VarOrNode, - /// The predicate of the triple pattern. - pub predicate: VarOrNamedNode, - /// The object of the triple pattern. - pub object: VarOrNodeOrLiteral, -} - -/// # VarOrNode -/// Represents either a variable or a node. -#[cw_serde] -pub enum VarOrNode { - /// # Variable - /// A variable. - Variable(String), - /// # Node - /// A node, i.e. an IRI or a blank node. - Node(Node), -} - -/// # VarOrNamedNode { -/// Represents either a variable or a named node (IRI). -#[cw_serde] -pub enum VarOrNamedNode { - /// # Variable - /// A variable. - Variable(String), - /// # NamedNode - /// An RDF [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri). - NamedNode(IRI), -} - -/// # VarOrNodeOrLiteral -/// Represents either a variable, a node or a literal. -#[cw_serde] -pub enum VarOrNodeOrLiteral { - /// # Variable - /// A variable. - Variable(String), - /// # Node - /// A node, i.e. an IRI or a blank node. - Node(Node), - /// # Literal - /// An RDF [literal](https://www.w3.org/TR/rdf11-concepts/#dfn-literal), i.e. a simple literal, - /// a language-tagged string or a typed value. - Literal(Literal), -} - -/// # VarOrNamedNodeOrLiteral -/// Represents either a variable, a named node or a literal. -#[cw_serde] -pub enum VarOrNamedNodeOrLiteral { - /// # Variable - /// A variable. - Variable(String), - /// # NamedNode - /// An RDF [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri). - NamedNode(IRI), - /// # Literal - /// An RDF [literal](https://www.w3.org/TR/rdf11-concepts/#dfn-literal), i.e. a simple literal, - /// a language-tagged string or a typed value. - Literal(Literal), -} - -/// # Literal -/// An RDF [literal](https://www.w3.org/TR/rdf11-concepts/#dfn-literal). -#[cw_serde] -pub enum Literal { - /// # Simple - /// A [simple literal](https://www.w3.org/TR/rdf11-concepts/#dfn-simple-literal) without datatype or language form. - Simple(String), - /// # LanguageTaggedString - /// A [language-tagged string](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tagged-string) - LanguageTaggedString { - /// The [lexical form](https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form). - value: String, - /// The [language tag](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tag). - language: String, - }, - /// # TypedValue - /// A value with a datatype. - TypedValue { - /// The [lexical form](https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form). - value: String, - /// The [datatype IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-datatype-iri). - datatype: IRI, - }, -} - -/// # Node -/// Represents either an IRI (named node) or a blank node. -#[cw_serde] -pub enum Node { - /// # NamedNode - /// An RDF [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri). - NamedNode(IRI), - /// # BlankNode - /// An RDF [blank node](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node). - BlankNode(String), -} - #[cfg(test)] mod tests { use crate::msg::{InstantiateMsg, StoreLimitsInput}; diff --git a/contracts/axone-cognitarium/src/parser/ast.rs b/contracts/axone-cognitarium/src/parser/ast.rs new file mode 100644 index 00000000..bf9a5427 --- /dev/null +++ b/contracts/axone-cognitarium/src/parser/ast.rs @@ -0,0 +1,295 @@ +use cosmwasm_schema::cw_serde; + +/// # IRI +/// Represents an IRI. +#[cw_serde] +pub enum IRI { + /// # Prefixed + /// An IRI prefixed with a prefix. + /// The prefixed IRI is expanded to a full IRI using the prefix definition specified in the query. + /// For example, the prefixed IRI `rdf:type` is expanded to `http://www.w3.org/1999/02/22-rdf-syntax-ns#type`. + Prefixed(String), + /// # Full + /// A full IRI. + Full(String), +} + +/// # Value +#[cw_serde] +#[serde(tag = "type")] +pub enum Value { + /// # URI + /// Represents an IRI. + #[serde(rename = "uri")] + URI { + /// The value of the IRI. + value: IRI, + }, + /// # Literal + /// Represents a literal S with optional language tag L or datatype IRI D. + Literal { + /// The value of the literal. + value: String, + /// The language tag of the literal. + #[serde(rename = "xml:lang")] + lang: Option, + /// The datatype of the literal. + datatype: Option, + }, + /// # BlankNode + /// Represents a blank node. + BlankNode { + /// The identifier of the blank node. + value: String, + }, +} + +/// # SelectQuery +/// Represents a SELECT query over the triple store, allowing to select variables to return +/// and to filter the results. +#[cw_serde] +pub struct SelectQuery { + /// The prefixes used in the query. + pub prefixes: Vec, + /// The items to select. + /// Note: the number of items to select cannot exceed the maximum query variable count defined + /// in the store limitations. + pub select: Vec, + /// The WHERE clause. + /// If `None`, there is no WHERE clause, i.e. all triples are returned without filtering. + pub r#where: WhereClause, + /// The maximum number of results to return. + /// If `None`, there is no limit. + /// Note: the value of the limit cannot exceed the maximum query limit defined in the store + /// limitations. + pub limit: Option, +} + +/// # DescribeQuery +/// Represents a DESCRIBE query over the triple store, allowing to retrieve a description of a resource +/// as a set of triples serialized in a specific format. +#[cw_serde] +pub struct DescribeQuery { + /// The prefixes used in the query. + pub prefixes: Vec, + /// The resource to describe given as a variable or a node. + pub resource: VarOrNamedNode, + /// The WHERE clause. + /// This clause is used to specify the resource identifier to describe using variable bindings. + pub r#where: Option, +} + +/// # ConstructQuery +/// Represents a CONSTRUCT query over the triple store, allowing to retrieve a set of triples +/// serialized in a specific format. +#[cw_serde] +pub struct ConstructQuery { + /// The prefixes used in the query. + pub prefixes: Vec, + /// The triples to construct. + /// If nothing is provided and the `where` clause is a single Bgp, the patterns are used for + /// construction. + pub construct: Vec, + /// The WHERE clause. + /// This clause is used to specify the triples to construct using variable bindings. + pub r#where: WhereClause, +} + +/// # Prefix +/// Represents a prefix, i.e. a shortcut for a namespace used in a query. +#[cw_serde] +pub struct Prefix { + /// The prefix. + pub prefix: String, + /// The namespace associated with the prefix. + pub namespace: String, +} + +/// # SelectItem +/// Represents an item to select in a [SelectQuery]. +#[cw_serde] +pub enum SelectItem { + /// # Variable + /// Represents a variable. + Variable(String), +} + +/// # WhereClause +/// Represents a WHERE clause, i.e. a set of conditions to filter the results. +#[cw_serde] +pub enum WhereClause { + /// # Bgp + /// Represents a basic graph pattern expressed as a set of triple patterns. + Bgp { patterns: Vec }, + + /// # LateralJoin + /// Evaluates right for all result row of left + LateralJoin { left: Box, right: Box }, + + /// # Filter + /// Filters the inner clause matching the expression. + /// The solutions coming from the inner clause that do not match the expression are discarded. + /// The variables provided in the inner clause are available in the filter expression. + Filter { expr: Expression, inner: Box }, +} + +/// # Expression +/// Represents a logical combination of operations whose evaluation results in a term. +#[cw_serde] +pub enum Expression { + /// A named node constant. + NamedNode(IRI), + /// A literal constant. + Literal(Literal), + /// A variable that must be bound for evaluation. + Variable(String), + /// Logical conjunction of expressions. + /// All expressions must evaluate to true for the conjunction to be true. + /// If the conjunction is empty, it is considered true. + And(Vec), + /// Logical disjunction of expressions. + /// At least one expression must evaluate to true for the disjunction to be true. + /// If the disjunction is empty, it is considered false. + Or(Vec), + /// Equality comparison. + Equal(Box, Box), + /// Greater than comparison. + Greater(Box, Box), + /// Greater or equal comparison. + GreaterOrEqual(Box, Box), + /// Less than comparison. + Less(Box, Box), + /// Less or equal comparison. + LessOrEqual(Box, Box), + /// Negation of an expression. + Not(Box), +} + +/// # TripleDeleteTemplate +/// Represents a triple template to be deleted. +#[cw_serde] +pub struct TripleDeleteTemplate { + /// The subject of the triple pattern. + pub subject: VarOrNamedNode, + /// The predicate of the triple pattern. + pub predicate: VarOrNamedNode, + /// The object of the triple pattern. + pub object: VarOrNamedNodeOrLiteral, +} + +/// # TripleConstructTemplate +/// Represents a triple template to be forged for a construct query. +#[cw_serde] +pub struct TripleConstructTemplate { + /// The subject of the triple pattern. + pub subject: VarOrNode, + /// The predicate of the triple pattern. + pub predicate: VarOrNamedNode, + /// The object of the triple pattern. + pub object: VarOrNodeOrLiteral, +} + +/// # TriplePattern +/// Represents a triple pattern in a [SimpleWhereCondition]. +#[cw_serde] +pub struct TriplePattern { + /// The subject of the triple pattern. + pub subject: VarOrNode, + /// The predicate of the triple pattern. + pub predicate: VarOrNamedNode, + /// The object of the triple pattern. + pub object: VarOrNodeOrLiteral, +} + +/// # VarOrNode +/// Represents either a variable or a node. +#[cw_serde] +pub enum VarOrNode { + /// # Variable + /// A variable. + Variable(String), + /// # Node + /// A node, i.e. an IRI or a blank node. + Node(Node), +} + +/// # VarOrNamedNode { +/// Represents either a variable or a named node (IRI). +#[cw_serde] +pub enum VarOrNamedNode { + /// # Variable + /// A variable. + Variable(String), + /// # NamedNode + /// An RDF [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri). + NamedNode(IRI), +} + +/// # VarOrNodeOrLiteral +/// Represents either a variable, a node or a literal. +#[cw_serde] +pub enum VarOrNodeOrLiteral { + /// # Variable + /// A variable. + Variable(String), + /// # Node + /// A node, i.e. an IRI or a blank node. + Node(Node), + /// # Literal + /// An RDF [literal](https://www.w3.org/TR/rdf11-concepts/#dfn-literal), i.e. a simple literal, + /// a language-tagged string or a typed value. + Literal(Literal), +} + +/// # VarOrNamedNodeOrLiteral +/// Represents either a variable, a named node or a literal. +#[cw_serde] +pub enum VarOrNamedNodeOrLiteral { + /// # Variable + /// A variable. + Variable(String), + /// # NamedNode + /// An RDF [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri). + NamedNode(IRI), + /// # Literal + /// An RDF [literal](https://www.w3.org/TR/rdf11-concepts/#dfn-literal), i.e. a simple literal, + /// a language-tagged string or a typed value. + Literal(Literal), +} + +/// # Literal +/// An RDF [literal](https://www.w3.org/TR/rdf11-concepts/#dfn-literal). +#[cw_serde] +pub enum Literal { + /// # Simple + /// A [simple literal](https://www.w3.org/TR/rdf11-concepts/#dfn-simple-literal) without datatype or language form. + Simple(String), + /// # LanguageTaggedString + /// A [language-tagged string](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tagged-string) + LanguageTaggedString { + /// The [lexical form](https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form). + value: String, + /// The [language tag](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tag). + language: String, + }, + /// # TypedValue + /// A value with a datatype. + TypedValue { + /// The [lexical form](https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form). + value: String, + /// The [datatype IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-datatype-iri). + datatype: IRI, + }, +} + +/// # Node +/// Represents either an IRI (named node) or a blank node. +#[cw_serde] +pub enum Node { + /// # NamedNode + /// An RDF [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri). + NamedNode(IRI), + /// # BlankNode + /// An RDF [blank node](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node). + BlankNode(String), +} diff --git a/contracts/axone-cognitarium/src/parser/mod.rs b/contracts/axone-cognitarium/src/parser/mod.rs new file mode 100644 index 00000000..f47153fd --- /dev/null +++ b/contracts/axone-cognitarium/src/parser/mod.rs @@ -0,0 +1,3 @@ +mod ast; + +pub use crate::parser::ast::*; diff --git a/contracts/axone-cognitarium/src/querier/engine.rs b/contracts/axone-cognitarium/src/querier/engine.rs index 37ccb3ca..88fba83b 100644 --- a/contracts/axone-cognitarium/src/querier/engine.rs +++ b/contracts/axone-cognitarium/src/querier/engine.rs @@ -1,4 +1,4 @@ -use crate::msg::{ +use crate::parser::{ Node, SelectItem, VarOrNamedNode, VarOrNamedNodeOrLiteral, VarOrNode, VarOrNodeOrLiteral, }; use crate::querier::expression::Expression; diff --git a/contracts/axone-cognitarium/src/querier/expression.rs b/contracts/axone-cognitarium/src/querier/expression.rs index 583ad5d6..257599a8 100644 --- a/contracts/axone-cognitarium/src/querier/expression.rs +++ b/contracts/axone-cognitarium/src/querier/expression.rs @@ -1,4 +1,4 @@ -use crate::msg; +use crate::parser; use crate::querier::mapper::iri_as_string; use crate::querier::variable::HasBoundVariables; use crate::querier::ResolvedVariables; @@ -104,20 +104,20 @@ pub enum Term { } impl Term { - pub fn from_iri(iri: msg::IRI, prefixes: &HashMap) -> StdResult { + pub fn from_iri(iri: parser::IRI, prefixes: &HashMap) -> StdResult { Ok(Term::String(iri_as_string(iri, prefixes)?)) } pub fn from_literal( - literal: msg::Literal, + literal: parser::Literal, prefixes: &HashMap, ) -> StdResult { Ok(Term::String(match literal { - msg::Literal::Simple(value) => value, - msg::Literal::LanguageTaggedString { value, language } => { + parser::Literal::Simple(value) => value, + parser::Literal::LanguageTaggedString { value, language } => { format!("{}{}", value, language) } - msg::Literal::TypedValue { value, datatype } => { + parser::Literal::TypedValue { value, datatype } => { format!("{}{}", value, iri_as_string(datatype, prefixes)?) } })) @@ -387,15 +387,15 @@ mod tests { fn term_from_iri() { let cases = vec![ ( - msg::IRI::Prefixed("foo:bar".to_string()), + parser::IRI::Prefixed("foo:bar".to_string()), Ok(Term::String("http://example.com/bar".to_string())), ), ( - msg::IRI::Full("foo:bar".to_string()), + parser::IRI::Full("foo:bar".to_string()), Ok(Term::String("foo:bar".to_string())), ), ( - msg::IRI::Prefixed("unknown:bar".to_string()), + parser::IRI::Prefixed("unknown:bar".to_string()), Err(StdError::generic_err("Prefix not found: unknown")), ), ]; @@ -412,27 +412,27 @@ mod tests { fn term_from_literal() { let cases = vec![ ( - msg::Literal::Simple("foo".to_string()), + parser::Literal::Simple("foo".to_string()), Ok(Term::String("foo".to_string())), ), ( - msg::Literal::LanguageTaggedString { + parser::Literal::LanguageTaggedString { value: "foo".to_string(), language: "en".to_string(), }, Ok(Term::String("fooen".to_string())), ), ( - msg::Literal::TypedValue { + parser::Literal::TypedValue { value: "foo".to_string(), - datatype: msg::IRI::Prefixed("foo:bar".to_string()), + datatype: parser::IRI::Prefixed("foo:bar".to_string()), }, Ok(Term::String("foohttp://example.com/bar".to_string())), ), ( - msg::Literal::TypedValue { + parser::Literal::TypedValue { value: "foo".to_string(), - datatype: msg::IRI::Prefixed("unknown:bar".to_string()), + datatype: parser::IRI::Prefixed("unknown:bar".to_string()), }, Err(StdError::generic_err("Prefix not found: unknown")), ), diff --git a/contracts/axone-cognitarium/src/querier/mapper.rs b/contracts/axone-cognitarium/src/querier/mapper.rs index 2a05f859..a9b241dc 100644 --- a/contracts/axone-cognitarium/src/querier/mapper.rs +++ b/contracts/axone-cognitarium/src/querier/mapper.rs @@ -1,4 +1,4 @@ -use crate::msg::{Literal, IRI}; +use crate::parser::{Literal, IRI}; use crate::state; use crate::state::{NamespaceSolver, Object}; use axone_rdf::uri::{expand_uri, explode_iri}; diff --git a/contracts/axone-cognitarium/src/querier/plan_builder.rs b/contracts/axone-cognitarium/src/querier/plan_builder.rs index 2596dcaa..8a7a2591 100644 --- a/contracts/axone-cognitarium/src/querier/plan_builder.rs +++ b/contracts/axone-cognitarium/src/querier/plan_builder.rs @@ -1,5 +1,7 @@ -use crate::msg; -use crate::msg::{Node, TriplePattern, VarOrNamedNode, VarOrNode, VarOrNodeOrLiteral, WhereClause}; +use crate::parser; +use crate::parser::{ + Node, TriplePattern, VarOrNamedNode, VarOrNode, VarOrNodeOrLiteral, WhereClause, +}; use crate::querier::expression::{Expression, Term}; use crate::querier::mapper::{iri_as_node, literal_as_object}; use crate::querier::plan::{PatternValue, PlanVariable, QueryNode, QueryPlan}; @@ -116,48 +118,48 @@ impl<'a> PlanBuilder<'a> { .unwrap_or(Ok(QueryNode::noop())) } - fn build_expression(&mut self, expr: &msg::Expression) -> StdResult { + fn build_expression(&mut self, expr: &parser::Expression) -> StdResult { match expr { - msg::Expression::NamedNode(iri) => { + parser::Expression::NamedNode(iri) => { Term::from_iri(iri.clone(), self.prefixes).map(Expression::Constant) } - msg::Expression::Literal(literal) => { + parser::Expression::Literal(literal) => { Term::from_literal(literal.clone(), self.prefixes).map(Expression::Constant) } - msg::Expression::Variable(v) => Ok(Expression::Variable( + parser::Expression::Variable(v) => Ok(Expression::Variable( self.resolve_basic_variable(v.to_string()), )), - msg::Expression::And(exprs) => exprs + parser::Expression::And(exprs) => exprs .iter() .map(|e| self.build_expression(e)) .collect::>>() .map(Expression::And), - msg::Expression::Or(exprs) => exprs + parser::Expression::Or(exprs) => exprs .iter() .map(|e| self.build_expression(e)) .collect::>>() .map(Expression::Or), - msg::Expression::Equal(left, right) => Ok(Expression::Equal( + parser::Expression::Equal(left, right) => Ok(Expression::Equal( Box::new(self.build_expression(left)?), Box::new(self.build_expression(right)?), )), - msg::Expression::Greater(left, right) => Ok(Expression::Greater( + parser::Expression::Greater(left, right) => Ok(Expression::Greater( Box::new(self.build_expression(left)?), Box::new(self.build_expression(right)?), )), - msg::Expression::GreaterOrEqual(left, right) => Ok(Expression::GreaterOrEqual( + parser::Expression::GreaterOrEqual(left, right) => Ok(Expression::GreaterOrEqual( Box::new(self.build_expression(left)?), Box::new(self.build_expression(right)?), )), - msg::Expression::Less(left, right) => Ok(Expression::Less( + parser::Expression::Less(left, right) => Ok(Expression::Less( Box::new(self.build_expression(left)?), Box::new(self.build_expression(right)?), )), - msg::Expression::LessOrEqual(left, right) => Ok(Expression::LessOrEqual( + parser::Expression::LessOrEqual(left, right) => Ok(Expression::LessOrEqual( Box::new(self.build_expression(left)?), Box::new(self.build_expression(right)?), )), - msg::Expression::Not(child) => self + parser::Expression::Not(child) => self .build_expression(child) .map(Box::new) .map(Expression::Not), @@ -283,7 +285,7 @@ impl<'a> HasCachedNamespaces for PlanBuilder<'a> { #[cfg(test)] mod test { use super::*; - use crate::msg::{Literal, Node, Prefix, IRI}; + use crate::parser::{Literal, Node, Prefix, IRI}; use crate::rdf::PrefixMap; use crate::state; use crate::state::{namespaces, Namespace}; @@ -666,42 +668,42 @@ mod test { fn build_expression() { let cases = vec![ ( - msg::Expression::NamedNode(IRI::Full("http://axone.space/test".to_string())), + parser::Expression::NamedNode(IRI::Full("http://axone.space/test".to_string())), Ok(Expression::Constant(Term::String( "http://axone.space/test".to_string(), ))), ), ( - msg::Expression::NamedNode(IRI::Prefixed("oups:test".to_string())), + parser::Expression::NamedNode(IRI::Prefixed("oups:test".to_string())), Err(StdError::generic_err("Prefix not found: oups")), ), ( - msg::Expression::Literal(Literal::Simple("simple".to_string())), + parser::Expression::Literal(Literal::Simple("simple".to_string())), Ok(Expression::Constant(Term::String("simple".to_string()))), ), ( - msg::Expression::Literal(Literal::TypedValue { + parser::Expression::Literal(Literal::TypedValue { value: "typed".to_string(), datatype: IRI::Prefixed("oups:type".to_string()), }), Err(StdError::generic_err("Prefix not found: oups")), ), ( - msg::Expression::Variable("variable".to_string()), + parser::Expression::Variable("variable".to_string()), Ok(Expression::Variable(0usize)), ), ( - msg::Expression::And(vec![msg::Expression::Variable("variable".to_string())]), + parser::Expression::And(vec![parser::Expression::Variable("variable".to_string())]), Ok(Expression::And(vec![Expression::Variable(0usize)])), ), ( - msg::Expression::Or(vec![msg::Expression::Variable("variable".to_string())]), + parser::Expression::Or(vec![parser::Expression::Variable("variable".to_string())]), Ok(Expression::Or(vec![Expression::Variable(0usize)])), ), ( - msg::Expression::Equal( - Box::new(msg::Expression::Variable("v1".to_string())), - Box::new(msg::Expression::Variable("v2".to_string())), + parser::Expression::Equal( + Box::new(parser::Expression::Variable("v1".to_string())), + Box::new(parser::Expression::Variable("v2".to_string())), ), Ok(Expression::Equal( Box::new(Expression::Variable(0usize)), @@ -709,9 +711,9 @@ mod test { )), ), ( - msg::Expression::Greater( - Box::new(msg::Expression::Variable("v1".to_string())), - Box::new(msg::Expression::Variable("v2".to_string())), + parser::Expression::Greater( + Box::new(parser::Expression::Variable("v1".to_string())), + Box::new(parser::Expression::Variable("v2".to_string())), ), Ok(Expression::Greater( Box::new(Expression::Variable(0usize)), @@ -719,9 +721,9 @@ mod test { )), ), ( - msg::Expression::GreaterOrEqual( - Box::new(msg::Expression::Variable("v1".to_string())), - Box::new(msg::Expression::Variable("v2".to_string())), + parser::Expression::GreaterOrEqual( + Box::new(parser::Expression::Variable("v1".to_string())), + Box::new(parser::Expression::Variable("v2".to_string())), ), Ok(Expression::GreaterOrEqual( Box::new(Expression::Variable(0usize)), @@ -729,9 +731,9 @@ mod test { )), ), ( - msg::Expression::Less( - Box::new(msg::Expression::Variable("v1".to_string())), - Box::new(msg::Expression::Variable("v2".to_string())), + parser::Expression::Less( + Box::new(parser::Expression::Variable("v1".to_string())), + Box::new(parser::Expression::Variable("v2".to_string())), ), Ok(Expression::Less( Box::new(Expression::Variable(0usize)), @@ -739,9 +741,9 @@ mod test { )), ), ( - msg::Expression::LessOrEqual( - Box::new(msg::Expression::Variable("v1".to_string())), - Box::new(msg::Expression::Variable("v2".to_string())), + parser::Expression::LessOrEqual( + Box::new(parser::Expression::Variable("v1".to_string())), + Box::new(parser::Expression::Variable("v2".to_string())), ), Ok(Expression::LessOrEqual( Box::new(Expression::Variable(0usize)), @@ -749,7 +751,7 @@ mod test { )), ), ( - msg::Expression::Not(Box::new(msg::Expression::Variable("v1".to_string()))), + parser::Expression::Not(Box::new(parser::Expression::Variable("v1".to_string()))), Ok(Expression::Not(Box::new(Expression::Variable(0usize)))), ), ]; @@ -910,7 +912,7 @@ mod test { object: VarOrNodeOrLiteral::Variable("2".to_string()), }], }), - expr: msg::Expression::Variable("1".to_string()), + expr: parser::Expression::Variable("1".to_string()), }, Ok(QueryPlan { entrypoint: QueryNode::Filter { @@ -938,7 +940,7 @@ mod test { object: VarOrNodeOrLiteral::Variable("2".to_string()), }], }), - expr: msg::Expression::Variable("oups".to_string()), + expr: parser::Expression::Variable("oups".to_string()), }, Err(StdError::generic_err( "Unbound variable in filter expression", diff --git a/contracts/axone-cognitarium/src/querier/variable.rs b/contracts/axone-cognitarium/src/querier/variable.rs index 62da1e19..66e9a4cd 100644 --- a/contracts/axone-cognitarium/src/querier/variable.rs +++ b/contracts/axone-cognitarium/src/querier/variable.rs @@ -1,4 +1,4 @@ -use crate::msg::{Value, IRI}; +use crate::parser::{Value, IRI}; use crate::querier::expression::Term; use crate::state::{Literal, NamespaceSolver, Object, Predicate, Subject}; use axone_rdf::normalize::IdentifierIssuer; diff --git a/contracts/axone-cognitarium/src/rdf/mapper.rs b/contracts/axone-cognitarium/src/rdf/mapper.rs index 678c14a2..2a4092f6 100644 --- a/contracts/axone-cognitarium/src/rdf/mapper.rs +++ b/contracts/axone-cognitarium/src/rdf/mapper.rs @@ -1,72 +1,72 @@ -use crate::msg; +use crate::parser; use crate::rdf::{Property, Subject, Value}; use axone_rdf::uri::expand_uri; use cosmwasm_std::StdError; use std::collections::HashMap; -impl TryFrom<(msg::Node, &HashMap)> for Subject { +impl TryFrom<(parser::Node, &HashMap)> for Subject { type Error = StdError; fn try_from( - (node, prefixes): (msg::Node, &HashMap), + (node, prefixes): (parser::Node, &HashMap), ) -> Result { match node { - msg::Node::BlankNode(id) => Ok(Subject::BlankNode(id)), - msg::Node::NamedNode(msg::IRI::Full(uri)) => Ok(Subject::NamedNode(uri)), - msg::Node::NamedNode(msg::IRI::Prefixed(curie)) => { + parser::Node::BlankNode(id) => Ok(Subject::BlankNode(id)), + parser::Node::NamedNode(parser::IRI::Full(uri)) => Ok(Subject::NamedNode(uri)), + parser::Node::NamedNode(parser::IRI::Prefixed(curie)) => { Ok(Subject::NamedNode(expand_uri(&curie, prefixes)?)) } } } } -impl TryFrom<(msg::IRI, &HashMap)> for Property { +impl TryFrom<(parser::IRI, &HashMap)> for Property { type Error = StdError; fn try_from( - (iri, prefixes): (msg::IRI, &HashMap), + (iri, prefixes): (parser::IRI, &HashMap), ) -> Result { match iri { - msg::IRI::Full(uri) => Ok(Property(uri)), - msg::IRI::Prefixed(curie) => Ok(Property(expand_uri(&curie, prefixes)?)), + parser::IRI::Full(uri) => Ok(Property(uri)), + parser::IRI::Prefixed(curie) => Ok(Property(expand_uri(&curie, prefixes)?)), } } } -impl TryFrom<(msg::Node, &HashMap)> for Value { +impl TryFrom<(parser::Node, &HashMap)> for Value { type Error = StdError; fn try_from( - (node, prefixes): (msg::Node, &HashMap), + (node, prefixes): (parser::Node, &HashMap), ) -> Result { match node { - msg::Node::NamedNode(msg::IRI::Full(uri)) => Ok(Value::NamedNode(uri)), - msg::Node::NamedNode(msg::IRI::Prefixed(curie)) => { + parser::Node::NamedNode(parser::IRI::Full(uri)) => Ok(Value::NamedNode(uri)), + parser::Node::NamedNode(parser::IRI::Prefixed(curie)) => { Ok(Value::NamedNode(expand_uri(&curie, prefixes)?)) } - msg::Node::BlankNode(id) => Ok(Value::BlankNode(id)), + parser::Node::BlankNode(id) => Ok(Value::BlankNode(id)), } } } -impl TryFrom<(msg::Literal, &HashMap)> for Value { +impl TryFrom<(parser::Literal, &HashMap)> for Value { type Error = StdError; fn try_from( - (literal, prefixes): (msg::Literal, &HashMap), + (literal, prefixes): (parser::Literal, &HashMap), ) -> Result { match literal { - msg::Literal::Simple(value) => Ok(Value::LiteralSimple(value)), - msg::Literal::LanguageTaggedString { value, language } => { + parser::Literal::Simple(value) => Ok(Value::LiteralSimple(value)), + parser::Literal::LanguageTaggedString { value, language } => { Ok(Value::LiteralLang(value, language)) } - msg::Literal::TypedValue { + parser::Literal::TypedValue { value, - datatype: msg::IRI::Full(uri), + datatype: parser::IRI::Full(uri), } => Ok(Value::LiteralDatatype(value, uri)), - msg::Literal::TypedValue { + parser::Literal::TypedValue { value, - datatype: msg::IRI::Prefixed(prefix), + datatype: parser::IRI::Prefixed(prefix), } => Ok(Value::LiteralDatatype( value, expand_uri(&prefix, prefixes)?, @@ -83,8 +83,8 @@ impl PrefixMap { } } -impl From> for PrefixMap { - fn from(as_list: Vec) -> Self { +impl From> for PrefixMap { + fn from(as_list: Vec) -> Self { PrefixMap( as_list .into_iter() diff --git a/contracts/axone-dataverse/src/contract.rs b/contracts/axone-dataverse/src/contract.rs index 634f12c3..4a858ce7 100644 --- a/contracts/axone-dataverse/src/contract.rs +++ b/contracts/axone-dataverse/src/contract.rs @@ -151,9 +151,10 @@ mod tests { DataverseResponse, RdfDatasetFormat, TripleStoreConfig, TripleStoreLimitsInput, }; use crate::testutil::testutil::read_test_data; - use axone_cognitarium::msg::{ - DataFormat, Head, Node, Results, SelectItem, SelectQuery, SelectResponse, TriplePattern, - Value, VarOrNamedNode, VarOrNode, VarOrNodeOrLiteral, WhereClause, IRI, + use axone_cognitarium::msg::{DataFormat, Head, Results, SelectResponse}; + use axone_cognitarium::parser::{ + Node, SelectItem, SelectQuery, TriplePattern, Value, VarOrNamedNode, VarOrNode, + VarOrNodeOrLiteral, WhereClause, IRI, }; use cosmwasm_std::testing::{message_info, mock_dependencies, mock_env}; use cosmwasm_std::{ diff --git a/contracts/axone-dataverse/src/registrar/registry.rs b/contracts/axone-dataverse/src/registrar/registry.rs index 0057000f..69774733 100644 --- a/contracts/axone-dataverse/src/registrar/registry.rs +++ b/contracts/axone-dataverse/src/registrar/registry.rs @@ -1,9 +1,10 @@ use crate::registrar::credential::DataverseCredential; use crate::state::DATAVERSE; use crate::ContractError; -use axone_cognitarium::msg::{ - DataFormat, Node, SelectItem, SelectQuery, TriplePattern, VarOrNamedNode, VarOrNode, - VarOrNodeOrLiteral, WhereClause, IRI, +use axone_cognitarium::msg::DataFormat; +use axone_cognitarium::parser::{ + Node, SelectItem, SelectQuery, TriplePattern, VarOrNamedNode, VarOrNode, VarOrNodeOrLiteral, + WhereClause, IRI, }; use axone_cognitarium_client::CognitariumClient; use cosmwasm_std::{DepsMut, StdResult, Storage, WasmMsg}; diff --git a/packages/axone-cognitarium-client/src/client.rs b/packages/axone-cognitarium-client/src/client.rs index bcbf6cda..374ff942 100644 --- a/packages/axone-cognitarium-client/src/client.rs +++ b/packages/axone-cognitarium-client/src/client.rs @@ -1,4 +1,5 @@ -use axone_cognitarium::msg::{DataFormat, ExecuteMsg, QueryMsg, SelectQuery, SelectResponse}; +use axone_cognitarium::msg::{DataFormat, ExecuteMsg, QueryMsg, SelectResponse}; +use axone_cognitarium::parser::SelectQuery; use cosmwasm_std::{ to_json_binary, Addr, Binary, Coin, CustomQuery, QuerierWrapper, QueryRequest, StdResult, WasmMsg, WasmQuery, From b9738204882bd562866901b68ed2898c65a65687 Mon Sep 17 00:00:00 2001 From: ccamel Date: Tue, 17 Dec 2024 11:20:58 +0100 Subject: [PATCH 2/2] docs(cognitarium): correct minor typo --- contracts/axone-cognitarium/src/parser/ast.rs | 2 +- docs/axone-cognitarium.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/axone-cognitarium/src/parser/ast.rs b/contracts/axone-cognitarium/src/parser/ast.rs index bf9a5427..dd6f4033 100644 --- a/contracts/axone-cognitarium/src/parser/ast.rs +++ b/contracts/axone-cognitarium/src/parser/ast.rs @@ -213,7 +213,7 @@ pub enum VarOrNode { Node(Node), } -/// # VarOrNamedNode { +/// # VarOrNamedNode /// Represents either a variable or a named node (IRI). #[cw_serde] pub enum VarOrNamedNode { diff --git a/docs/axone-cognitarium.md b/docs/axone-cognitarium.md index f17a05ef..efe8a0a6 100644 --- a/docs/axone-cognitarium.md +++ b/docs/axone-cognitarium.md @@ -925,4 +925,4 @@ A named node constant. --- -_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `axone-cognitarium.json` (`197d77d83ca86dc6`)_ +_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `axone-cognitarium.json` (`330cdbb56c7cee44`)_