mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-18 15:29:11 +00:00
move arg structs into the builder closure
This commit is contained in:
parent
35144be8a1
commit
a5e81a898e
|
@ -5,18 +5,6 @@ use serde::Deserialize;
|
|||
|
||||
use super::{utils::LibraryRequest, RouterBuilder};
|
||||
|
||||
#[derive(Type, Deserialize)]
|
||||
pub struct SetNoteArgs {
|
||||
pub id: i32,
|
||||
pub note: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Type, Deserialize)]
|
||||
pub struct SetFavoriteArgs {
|
||||
pub id: i32,
|
||||
pub favorite: bool,
|
||||
}
|
||||
|
||||
pub(crate) fn mount() -> RouterBuilder {
|
||||
<RouterBuilder>::new()
|
||||
.library_query("readMetadata", |t| {
|
||||
|
@ -26,6 +14,12 @@ pub(crate) fn mount() -> RouterBuilder {
|
|||
})
|
||||
})
|
||||
.library_mutation("setNote", |t| {
|
||||
#[derive(Type, Deserialize)]
|
||||
pub struct SetNoteArgs {
|
||||
pub id: i32,
|
||||
pub note: Option<String>,
|
||||
}
|
||||
|
||||
t(|_, args: SetNoteArgs, library| async move {
|
||||
library
|
||||
.db
|
||||
|
@ -43,6 +37,12 @@ pub(crate) fn mount() -> RouterBuilder {
|
|||
})
|
||||
})
|
||||
.library_mutation("setFavorite", |t| {
|
||||
#[derive(Type, Deserialize)]
|
||||
pub struct SetFavoriteArgs {
|
||||
pub id: i32,
|
||||
pub favorite: bool,
|
||||
}
|
||||
|
||||
t(|_, args: SetFavoriteArgs, library| async move {
|
||||
library
|
||||
.db
|
||||
|
|
|
@ -14,18 +14,6 @@ use std::path::PathBuf;
|
|||
|
||||
use super::{utils::LibraryRequest, CoreEvent, RouterBuilder};
|
||||
|
||||
#[derive(Type, Deserialize)]
|
||||
pub struct GenerateThumbsForLocationArgs {
|
||||
pub id: i32,
|
||||
pub path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Type, Deserialize)]
|
||||
pub struct IdentifyUniqueFilesArgs {
|
||||
pub id: i32,
|
||||
pub path: PathBuf,
|
||||
}
|
||||
|
||||
pub(crate) fn mount() -> RouterBuilder {
|
||||
<RouterBuilder>::new()
|
||||
.library_query("getRunning", |t| {
|
||||
|
@ -35,6 +23,12 @@ pub(crate) fn mount() -> RouterBuilder {
|
|||
t(|_, _: (), library| async move { Ok(JobManager::get_history(&library).await?) })
|
||||
})
|
||||
.library_mutation("generateThumbsForLocation", |t| {
|
||||
#[derive(Type, Deserialize)]
|
||||
pub struct GenerateThumbsForLocationArgs {
|
||||
pub id: i32,
|
||||
pub path: PathBuf,
|
||||
}
|
||||
|
||||
t(
|
||||
|_, args: GenerateThumbsForLocationArgs, library| async move {
|
||||
if library
|
||||
|
@ -63,6 +57,12 @@ pub(crate) fn mount() -> RouterBuilder {
|
|||
)
|
||||
})
|
||||
.library_mutation("identifyUniqueFiles", |t| {
|
||||
#[derive(Type, Deserialize)]
|
||||
pub struct IdentifyUniqueFilesArgs {
|
||||
pub id: i32,
|
||||
pub path: PathBuf,
|
||||
}
|
||||
|
||||
t(|_, args: IdentifyUniqueFilesArgs, library| async move {
|
||||
if fetch_location(&library, args.id).exec().await?.is_none() {
|
||||
return Err(rspc::Error::new(
|
||||
|
|
|
@ -12,13 +12,6 @@ use serde::Deserialize;
|
|||
use tokio::fs;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Type, Deserialize)]
|
||||
pub struct EditLibraryArgs {
|
||||
pub id: Uuid,
|
||||
pub name: Option<String>,
|
||||
pub description: Option<String>,
|
||||
}
|
||||
|
||||
pub(crate) fn mount() -> RouterBuilder {
|
||||
<RouterBuilder>::new()
|
||||
.query("list", |t| {
|
||||
|
@ -91,6 +84,13 @@ pub(crate) fn mount() -> RouterBuilder {
|
|||
})
|
||||
})
|
||||
.mutation("edit", |t| {
|
||||
#[derive(Type, Deserialize)]
|
||||
pub struct EditLibraryArgs {
|
||||
pub id: Uuid,
|
||||
pub name: Option<String>,
|
||||
pub description: Option<String>,
|
||||
}
|
||||
|
||||
t(|ctx, args: EditLibraryArgs| async move {
|
||||
Ok(ctx
|
||||
.library_manager
|
||||
|
|
|
@ -15,12 +15,6 @@ use tracing::info;
|
|||
|
||||
use super::{utils::LibraryRequest, Ctx, RouterBuilder};
|
||||
|
||||
#[derive(Serialize, Deserialize, Type, Debug)]
|
||||
pub struct ExplorerData {
|
||||
pub context: ExplorerContext,
|
||||
pub items: Vec<ExplorerItem>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Type, Debug)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum ExplorerContext {
|
||||
|
@ -29,9 +23,6 @@ pub enum ExplorerContext {
|
|||
// Space(object_in_space::Data),
|
||||
}
|
||||
|
||||
file_path::include!(file_path_with_object { object });
|
||||
object::include!(object_with_file_paths { file_paths });
|
||||
|
||||
#[derive(Serialize, Deserialize, Type, Debug)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum ExplorerItem {
|
||||
|
@ -39,14 +30,15 @@ pub enum ExplorerItem {
|
|||
Object(Box<object_with_file_paths::Data>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Type, Debug)]
|
||||
pub struct LocationExplorerArgs {
|
||||
pub location_id: i32,
|
||||
pub path: String,
|
||||
pub limit: i32,
|
||||
pub cursor: Option<String>,
|
||||
#[derive(Serialize, Deserialize, Type, Debug)]
|
||||
pub struct ExplorerData {
|
||||
pub context: ExplorerContext,
|
||||
pub items: Vec<ExplorerItem>,
|
||||
}
|
||||
|
||||
file_path::include!(file_path_with_object { object });
|
||||
object::include!(object_with_file_paths { file_paths });
|
||||
|
||||
// TODO(@Oscar): This return type sucks. Add an upstream rspc solution.
|
||||
pub(crate) fn mount() -> rspc::RouterBuilder<
|
||||
Ctx,
|
||||
|
@ -76,6 +68,14 @@ pub(crate) fn mount() -> rspc::RouterBuilder<
|
|||
})
|
||||
})
|
||||
.library_query("getExplorerData", |t| {
|
||||
#[derive(Clone, Serialize, Deserialize, Type, Debug)]
|
||||
pub struct LocationExplorerArgs {
|
||||
pub location_id: i32,
|
||||
pub path: String,
|
||||
pub limit: i32,
|
||||
pub cursor: Option<String>,
|
||||
}
|
||||
|
||||
t(|_, args: LocationExplorerArgs, library| async move {
|
||||
let location = library
|
||||
.db
|
||||
|
|
|
@ -12,26 +12,6 @@ use crate::{
|
|||
|
||||
use super::{utils::LibraryRequest, RouterBuilder};
|
||||
|
||||
#[derive(Type, Deserialize)]
|
||||
pub struct TagCreateArgs {
|
||||
pub name: String,
|
||||
pub color: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Type, Deserialize)]
|
||||
pub struct TagAssignArgs {
|
||||
pub object_id: i32,
|
||||
pub tag_id: i32,
|
||||
pub unassign: bool,
|
||||
}
|
||||
|
||||
#[derive(Type, Deserialize)]
|
||||
pub struct TagUpdateArgs {
|
||||
pub id: i32,
|
||||
pub name: Option<String>,
|
||||
pub color: Option<String>,
|
||||
}
|
||||
|
||||
pub(crate) fn mount() -> RouterBuilder {
|
||||
RouterBuilder::new()
|
||||
.library_query("list", |t| {
|
||||
|
@ -118,6 +98,12 @@ pub(crate) fn mount() -> RouterBuilder {
|
|||
})
|
||||
})
|
||||
.library_mutation("create", |t| {
|
||||
#[derive(Type, Deserialize)]
|
||||
pub struct TagCreateArgs {
|
||||
pub name: String,
|
||||
pub color: String,
|
||||
}
|
||||
|
||||
t(|_, args: TagCreateArgs, library| async move {
|
||||
let created_tag = library
|
||||
.db
|
||||
|
@ -138,6 +124,13 @@ pub(crate) fn mount() -> RouterBuilder {
|
|||
})
|
||||
})
|
||||
.library_mutation("assign", |t| {
|
||||
#[derive(Debug, Type, Deserialize)]
|
||||
pub struct TagAssignArgs {
|
||||
pub object_id: i32,
|
||||
pub tag_id: i32,
|
||||
pub unassign: bool,
|
||||
}
|
||||
|
||||
t(|_, args: TagAssignArgs, library| async move {
|
||||
if args.unassign {
|
||||
library
|
||||
|
@ -165,6 +158,13 @@ pub(crate) fn mount() -> RouterBuilder {
|
|||
})
|
||||
})
|
||||
.library_mutation("update", |t| {
|
||||
#[derive(Type, Deserialize)]
|
||||
pub struct TagUpdateArgs {
|
||||
pub id: i32,
|
||||
pub name: Option<String>,
|
||||
pub color: Option<String>,
|
||||
}
|
||||
|
||||
t(|_, args: TagUpdateArgs, library| async move {
|
||||
library
|
||||
.db
|
||||
|
|
Loading…
Reference in a new issue