Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions crates/lineark-sdk/src/blocking_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,20 @@ blocking_query_builder! {
methods = [before(impl Into<String>), after(impl Into<String>), first(i64), last(i64), include_archived(bool), include_comments(bool), team_id(impl Into<String>)]
}

blocking_query_builder! {
query_type = SearchDocumentsQueryBuilder,
node_type = DocumentSearchResult,
return_type = Connection<DocumentSearchResult>,
methods = [before(impl Into<String>), after(impl Into<String>), first(i64), last(i64), include_archived(bool), include_comments(bool), team_id(impl Into<String>)]
}

blocking_query_builder! {
query_type = SearchProjectsQueryBuilder,
node_type = ProjectSearchResult,
return_type = Connection<ProjectSearchResult>,
methods = [before(impl Into<String>), after(impl Into<String>), first(i64), last(i64), include_archived(bool), include_comments(bool), team_id(impl Into<String>)]
}

blocking_query_builder! {
query_type = DocumentsQueryBuilder,
node_type = Document,
Expand Down Expand Up @@ -357,6 +371,34 @@ impl Client {
)
}

/// Search documents (blocking).
pub fn search_documents(
&self,
term: impl Into<String>,
) -> BlockingQuery<
'_,
crate::generated::queries::SearchDocumentsQueryBuilder<'_, DocumentSearchResult>,
> {
BlockingQuery::new(
self.inner.search_documents::<DocumentSearchResult>(term),
&self.rt,
)
}

/// Search projects (blocking).
pub fn search_projects(
&self,
term: impl Into<String>,
) -> BlockingQuery<
'_,
crate::generated::queries::SearchProjectsQueryBuilder<'_, ProjectSearchResult>,
> {
BlockingQuery::new(
self.inner.search_projects::<ProjectSearchResult>(term),
&self.rt,
)
}

/// List documents (blocking).
pub fn documents(
&self,
Expand Down
15 changes: 15 additions & 0 deletions crates/lineark-sdk/src/generated/client_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ impl Client {
) -> Result<T, LinearError> {
crate::generated::queries::team::<T>(self, id).await
}
/// Search documents.
///
/// Full type: [`DocumentSearchResult`](super::types::DocumentSearchResult)
pub fn search_documents<T>(
&self,
term: impl Into<String>,
) -> SearchDocumentsQueryBuilder<'_, T> {
crate::generated::queries::search_documents(self, term)
}
/// Search projects.
///
/// Full type: [`ProjectSearchResult`](super::types::ProjectSearchResult)
pub fn search_projects<T>(&self, term: impl Into<String>) -> SearchProjectsQueryBuilder<'_, T> {
crate::generated::queries::search_projects(self, term)
}
/// Search issues.
///
/// Full type: [`IssueSearchResult`](super::types::IssueSearchResult)
Expand Down
236 changes: 236 additions & 0 deletions crates/lineark-sdk/src/generated/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,200 @@ impl<'a, T: DeserializeOwned + GraphQLFields<FullType = super::types::Team>>
.await
}
}
/// Query builder: Search documents.
///
/// Full type: [`DocumentSearchResult`](super::types::DocumentSearchResult)
///
/// Use setter methods to configure optional parameters, then call
/// [`.send()`](Self::send) to execute the query.
#[must_use]
pub struct SearchDocumentsQueryBuilder<'a, T> {
client: &'a Client,
term: String,
before: Option<String>,
after: Option<String>,
first: Option<i64>,
last: Option<i64>,
include_archived: Option<bool>,
order_by: Option<PaginationOrderBy>,
include_comments: Option<bool>,
team_id: Option<String>,
_marker: std::marker::PhantomData<T>,
}
impl<'a, T: DeserializeOwned + GraphQLFields<FullType = super::types::DocumentSearchResult>>
SearchDocumentsQueryBuilder<'a, T>
{
pub fn before(mut self, value: impl Into<String>) -> Self {
self.before = Some(value.into());
self
}
pub fn after(mut self, value: impl Into<String>) -> Self {
self.after = Some(value.into());
self
}
pub fn first(mut self, value: i64) -> Self {
self.first = Some(value);
self
}
pub fn last(mut self, value: i64) -> Self {
self.last = Some(value);
self
}
pub fn include_archived(mut self, value: bool) -> Self {
self.include_archived = Some(value);
self
}
pub fn order_by(mut self, value: PaginationOrderBy) -> Self {
self.order_by = Some(value);
self
}
pub fn include_comments(mut self, value: bool) -> Self {
self.include_comments = Some(value);
self
}
pub fn team_id(mut self, value: impl Into<String>) -> Self {
self.team_id = Some(value.into());
self
}
pub async fn send(self) -> Result<Connection<T>, LinearError> {
let mut map = serde_json::Map::new();
map.insert("term".to_string(), serde_json::json!(self.term));
if let Some(ref v) = self.before {
map.insert("before".to_string(), serde_json::json!(v));
}
if let Some(ref v) = self.after {
map.insert("after".to_string(), serde_json::json!(v));
}
if let Some(ref v) = self.first {
map.insert("first".to_string(), serde_json::json!(v));
}
if let Some(ref v) = self.last {
map.insert("last".to_string(), serde_json::json!(v));
}
if let Some(ref v) = self.include_archived {
map.insert("includeArchived".to_string(), serde_json::json!(v));
}
if let Some(ref v) = self.order_by {
map.insert("orderBy".to_string(), serde_json::json!(v));
}
if let Some(ref v) = self.include_comments {
map.insert("includeComments".to_string(), serde_json::json!(v));
}
if let Some(ref v) = self.team_id {
map.insert("teamId".to_string(), serde_json::json!(v));
}
let variables = serde_json::Value::Object(map);
let selection = T::selection();
let query = format!(
"query {}({}) {{ {}({}) {{ nodes {{ {} }} pageInfo {{ hasNextPage endCursor }} }} }}",
"SearchDocuments",
"$before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean, $orderBy: PaginationOrderBy, $term: String!, $includeComments: Boolean, $teamId: String",
"searchDocuments",
"before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived, orderBy: $orderBy, term: $term, includeComments: $includeComments, teamId: $teamId",
selection
);
self.client
.execute_connection::<T>(&query, variables, "searchDocuments")
.await
}
}
/// Query builder: Search projects.
///
/// Full type: [`ProjectSearchResult`](super::types::ProjectSearchResult)
///
/// Use setter methods to configure optional parameters, then call
/// [`.send()`](Self::send) to execute the query.
#[must_use]
pub struct SearchProjectsQueryBuilder<'a, T> {
client: &'a Client,
term: String,
before: Option<String>,
after: Option<String>,
first: Option<i64>,
last: Option<i64>,
include_archived: Option<bool>,
order_by: Option<PaginationOrderBy>,
include_comments: Option<bool>,
team_id: Option<String>,
_marker: std::marker::PhantomData<T>,
}
impl<'a, T: DeserializeOwned + GraphQLFields<FullType = super::types::ProjectSearchResult>>
SearchProjectsQueryBuilder<'a, T>
{
pub fn before(mut self, value: impl Into<String>) -> Self {
self.before = Some(value.into());
self
}
pub fn after(mut self, value: impl Into<String>) -> Self {
self.after = Some(value.into());
self
}
pub fn first(mut self, value: i64) -> Self {
self.first = Some(value);
self
}
pub fn last(mut self, value: i64) -> Self {
self.last = Some(value);
self
}
pub fn include_archived(mut self, value: bool) -> Self {
self.include_archived = Some(value);
self
}
pub fn order_by(mut self, value: PaginationOrderBy) -> Self {
self.order_by = Some(value);
self
}
pub fn include_comments(mut self, value: bool) -> Self {
self.include_comments = Some(value);
self
}
pub fn team_id(mut self, value: impl Into<String>) -> Self {
self.team_id = Some(value.into());
self
}
pub async fn send(self) -> Result<Connection<T>, LinearError> {
let mut map = serde_json::Map::new();
map.insert("term".to_string(), serde_json::json!(self.term));
if let Some(ref v) = self.before {
map.insert("before".to_string(), serde_json::json!(v));
}
if let Some(ref v) = self.after {
map.insert("after".to_string(), serde_json::json!(v));
}
if let Some(ref v) = self.first {
map.insert("first".to_string(), serde_json::json!(v));
}
if let Some(ref v) = self.last {
map.insert("last".to_string(), serde_json::json!(v));
}
if let Some(ref v) = self.include_archived {
map.insert("includeArchived".to_string(), serde_json::json!(v));
}
if let Some(ref v) = self.order_by {
map.insert("orderBy".to_string(), serde_json::json!(v));
}
if let Some(ref v) = self.include_comments {
map.insert("includeComments".to_string(), serde_json::json!(v));
}
if let Some(ref v) = self.team_id {
map.insert("teamId".to_string(), serde_json::json!(v));
}
let variables = serde_json::Value::Object(map);
let selection = T::selection();
let query = format!(
"query {}({}) {{ {}({}) {{ nodes {{ {} }} pageInfo {{ hasNextPage endCursor }} }} }}",
"SearchProjects",
"$before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean, $orderBy: PaginationOrderBy, $term: String!, $includeComments: Boolean, $teamId: String",
"searchProjects",
"before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived, orderBy: $orderBy, term: $term, includeComments: $includeComments, teamId: $teamId",
selection
);
self.client
.execute_connection::<T>(&query, variables, "searchProjects")
.await
}
}
/// Query builder: Search issues.
///
/// Full type: [`IssueSearchResult`](super::types::IssueSearchResult)
Expand Down Expand Up @@ -1119,6 +1313,48 @@ pub async fn team<T: DeserializeOwned + GraphQLFields<FullType = super::types::T
);
client.execute::<T>(&query, variables, "team").await
}
/// Search documents.
///
/// Full type: [`DocumentSearchResult`](super::types::DocumentSearchResult)
pub fn search_documents<'a, T>(
client: &'a Client,
term: impl Into<String>,
) -> SearchDocumentsQueryBuilder<'a, T> {
SearchDocumentsQueryBuilder {
client,
term: term.into(),
before: None,
after: None,
first: None,
last: None,
include_archived: None,
order_by: None,
include_comments: None,
team_id: None,
_marker: std::marker::PhantomData,
}
}
/// Search projects.
///
/// Full type: [`ProjectSearchResult`](super::types::ProjectSearchResult)
pub fn search_projects<'a, T>(
client: &'a Client,
term: impl Into<String>,
) -> SearchProjectsQueryBuilder<'a, T> {
SearchProjectsQueryBuilder {
client,
term: term.into(),
before: None,
after: None,
first: None,
last: None,
include_archived: None,
order_by: None,
include_comments: None,
team_id: None,
_marker: std::marker::PhantomData,
}
}
/// Search issues.
///
/// Full type: [`IssueSearchResult`](super::types::IssueSearchResult)
Expand Down
Loading