refactor(trello): rearrange model
Some checks failed
Test / build (map[name:nightly]) (push) Failing after 57s
Test / build (map[name:stable]) (push) Failing after 1m11s

This commit is contained in:
Paul Campbell 2024-12-19 08:28:15 +00:00
parent 3249da92b0
commit 0993b75338
15 changed files with 98 additions and 71 deletions

View file

@ -6,7 +6,7 @@ use color_eyre::Result;
use crate::{execute::Execute, p, FullCtx}; use crate::{execute::Execute, p, FullCtx};
use super::model::{TrelloAttachmentId, TrelloCardId}; use super::model::{attachment::TrelloAttachmentId, card::TrelloCardId};
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
pub enum TrelloAttachmentCommand { pub enum TrelloAttachmentCommand {

View file

@ -4,7 +4,7 @@ use clap::Parser;
use crate::execute::Execute; use crate::execute::Execute;
use crate::{p, FullCtx}; use crate::{p, FullCtx};
use super::model::TrelloBoardId; use super::model::board::TrelloBoardId;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
pub enum TrelloBoardCommand { pub enum TrelloBoardCommand {

View file

@ -4,7 +4,7 @@ use color_eyre::Result;
use crate::{execute::Execute, p, FullCtx}; use crate::{execute::Execute, p, FullCtx};
use super::model::TrelloCardId; use super::model::card::TrelloCardId;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
pub enum TrelloCardCommand { pub enum TrelloCardCommand {

View file

@ -5,14 +5,15 @@ use std::path::PathBuf;
use color_eyre::eyre::Context; use color_eyre::eyre::Context;
use kxio::net::{Net, ReqBuilder}; use kxio::net::{Net, ReqBuilder};
use crate::trello::model::{TrelloAttachment, TrelloAttachmentId};
use crate::{ use crate::{
api_result::APIResult, api_result::APIResult,
f, s, f, s,
trello::model::{ trello::model::{
board::TrelloBoard, attachment::{TrelloAttachment, TrelloAttachmentId},
board::{TrelloBoard, TrelloBoardId},
card::TrelloCardId,
card::{TrelloLongCard, TrelloShortCard}, card::{TrelloLongCard, TrelloShortCard},
TrelloBoardId, TrelloCardId, TrelloListId, list::TrelloListId,
}, },
FullCtx, FullCtx,
}; };

View file

@ -0,0 +1,25 @@
//
use derive_more::derive::Display;
use serde::Deserialize;
use crate::newtype;
newtype!(TrelloAttachmentId, String, Display, "Card Attachment ID");
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub(crate) struct TrelloAttachment {
pub(crate) id: String, // "5abbe4b7ddc1b351ef961414",
pub(crate) bytes: i64,
pub(crate) date: String, //"2018-10-17T19:10:14.808Z",
#[serde(rename = "idMember")]
pub(crate) id_member: String, //"5abbe4b7ddc1b351ef961414",
#[serde(rename = "isUpload")]
pub(crate) is_upload: bool, //false,
#[serde(rename = "mimeType")]
pub(crate) mime_type: Option<String>, //"",
pub(crate) name: String, //"Deprecation Extension Notice",
pub(crate) url: String, //"https://admin.typeform.com/form/RzExEM/share#/link",
pub(crate) pos: i64, //1638
#[serde(rename = "fileName")]
pub(crate) file_name: String,
}

View file

@ -1,7 +1,10 @@
// //
use crate::trello::model::list::TrelloList; use derive_more::derive::Display;
use super::{TrelloBoardId, TrelloBoardName}; use crate::{newtype, trello::model::list::TrelloList};
newtype!(TrelloBoardId, String, Display, "Board ID");
newtype!(TrelloBoardName, String, Display, "Board Name");
#[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize)]
pub(crate) struct TrelloBoard { pub(crate) struct TrelloBoard {

View file

@ -1,10 +1,18 @@
// //
use super::{ use derive_more::derive::Display;
TrelloAttachment, TrelloAttachmentId, TrelloCardDescription, TrelloCardDue, TrelloCardId, use serde::Deserialize;
TrelloCardName, TrelloCardPosition, TrelloLabelId, TrelloListId,
};
#[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize)] use crate::newtype;
use super::{attachment::{TrelloAttachment, TrelloAttachmentId}, label::TrelloLabelId, list::TrelloListId};
newtype!(TrelloCardId, String, Display, "Card ID");
newtype!(TrelloCardName, String, Display, "Card Name");
newtype!(TrelloCardDescription, String, Display, "Card Description");
newtype!(TrelloCardDue, String, Display, "Card Due");
newtype!(TrelloCardPosition, i64, Display, "Card Position");
#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
pub(crate) struct TrelloCard { pub(crate) struct TrelloCard {
pub(crate) id: TrelloCardId, pub(crate) id: TrelloCardId,
pub(crate) name: TrelloCardName, pub(crate) name: TrelloCardName,
@ -12,7 +20,7 @@ pub(crate) struct TrelloCard {
pub(crate) id_list: TrelloListId, pub(crate) id_list: TrelloListId,
} }
#[derive(Debug, PartialEq, Eq, serde::Deserialize)] #[derive(Debug, PartialEq, Eq, Deserialize)]
pub(crate) struct TrelloShortCard { pub(crate) struct TrelloShortCard {
pub(crate) id: TrelloCardId, pub(crate) id: TrelloCardId,
pub(crate) name: TrelloCardName, pub(crate) name: TrelloCardName,
@ -24,7 +32,7 @@ pub(crate) struct TrelloShortCard {
pub(crate) pos: TrelloCardPosition, pub(crate) pos: TrelloCardPosition,
} }
#[derive(Debug, PartialEq, Eq, serde::Deserialize)] #[derive(Debug, PartialEq, Eq, Deserialize)]
pub(crate) struct TrelloLongCard { pub(crate) struct TrelloLongCard {
pub(crate) id: TrelloCardId, pub(crate) id: TrelloCardId,
pub(crate) name: TrelloCardName, pub(crate) name: TrelloCardName,

View file

@ -0,0 +1,6 @@
//
use derive_more::derive::Display;
use crate::newtype;
newtype!(TrelloLabelId, String, Display, "Label ID");

View file

@ -1,7 +1,20 @@
// //
use super::{TrelloListId, TrelloListName}; use derive_more::derive::Display;
use serde::Deserialize;
#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)] use crate::newtype;
newtype!(TrelloListId, String, Display, "List ID");
newtype!(
TrelloListName,
String,
Display,
PartialOrd,
Ord,
"List Name"
);
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
pub(crate) struct TrelloList { pub(crate) struct TrelloList {
pub(crate) id: TrelloListId, pub(crate) id: TrelloListId,
pub(crate) name: TrelloListName, pub(crate) name: TrelloListName,

View file

@ -1,46 +1,7 @@
//
pub(crate) mod attachment;
pub(crate) mod auth; pub(crate) mod auth;
pub(crate) mod board; pub(crate) mod board;
pub(crate) mod card; pub(crate) mod card;
pub(crate) mod label;
pub(crate) mod list; pub(crate) mod list;
use derive_more::derive::Display;
use serde::{Deserialize, Serialize};
use crate::newtype;
newtype!(TrelloBoardId, String, Display, "Board ID");
newtype!(TrelloBoardName, String, Display, "Board Name");
newtype!(TrelloListId, String, Display, "List ID");
newtype!(
TrelloListName,
String,
Display,
PartialOrd,
Ord,
"List Name"
);
newtype!(TrelloCardId, String, Display, "Card ID");
newtype!(TrelloCardName, String, Display, "Card Name");
newtype!(TrelloCardDescription, String, Display, "Card Description");
newtype!(TrelloCardDue, String, Display, "Card Due");
newtype!(TrelloCardPosition, i64, Display, "Card Position");
newtype!(TrelloAttachmentId, String, Display, "Card Attachment ID");
newtype!(TrelloLabelId, String, Display, "Label ID");
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub(crate) struct TrelloAttachment {
pub(crate) id: String, // "5abbe4b7ddc1b351ef961414",
pub(crate) bytes: i64,
pub(crate) date: String, //"2018-10-17T19:10:14.808Z",
#[serde(rename = "idMember")]
pub(crate) id_member: String, //"5abbe4b7ddc1b351ef961414",
#[serde(rename = "isUpload")]
pub(crate) is_upload: bool, //false,
#[serde(rename = "mimeType")]
pub(crate) mime_type: Option<String>, //"",
pub(crate) name: String, //"Deprecation Extension Notice",
pub(crate) url: String, //"https://admin.typeform.com/form/RzExEM/share#/link",
pub(crate) pos: i64, //1638
#[serde(rename = "fileName")]
pub(crate) file_name: String,
}

View file

@ -4,7 +4,7 @@ use color_eyre::Result;
use crate::{execute::Execute, p, FullCtx}; use crate::{execute::Execute, p, FullCtx};
use super::model::TrelloListId; use super::model::list::TrelloListId;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
pub enum TrelloStackCommand { pub enum TrelloStackCommand {

View file

@ -1,6 +1,8 @@
// //
use crate::trello::attachment::TrelloAttachmentCommand; use crate::trello::{
use crate::trello::model::TrelloAttachmentId; attachment::TrelloAttachmentCommand,
model::{attachment::TrelloAttachmentId, card::TrelloCardId},
};
use super::*; use super::*;

View file

@ -1,11 +1,18 @@
use crate::trello::attachment::TrelloAttachmentCommand; //
use crate::trello::model::{TrelloAttachmentId, TrelloCardId}; use std::path::PathBuf;
use crate::Command;
use assert2::let_assert; use assert2::let_assert;
use http::Response; use http::Response;
use kxio::fs::{FileSystem, TempFileSystem}; use kxio::fs::{FileSystem, TempFileSystem};
use std::path::PathBuf;
// use crate::{
trello::{
attachment::TrelloAttachmentCommand,
model::{attachment::TrelloAttachmentId, card::TrelloCardId},
},
Command,
};
use super::*; use super::*;
#[rstest::fixture] #[rstest::fixture]

View file

@ -19,8 +19,8 @@ use crate::{
card::TrelloCardCommand, card::TrelloCardCommand,
member::TrelloMemberCommand, member::TrelloMemberCommand,
model::{ model::{
board::{TrelloBoard, TrelloBoards}, board::{TrelloBoard, TrelloBoardId, TrelloBoardName, TrelloBoards},
TrelloBoardId, TrelloBoardName, TrelloCardId, card::TrelloCardId,
}, },
stack::TrelloStackCommand, stack::TrelloStackCommand,
TrelloCommand, TrelloConfig, TrelloCommand, TrelloConfig,

View file

@ -1,5 +1,6 @@
use crate::trello::model::TrelloListId;
// //
use crate::trello::model::list::TrelloListId;
use super::*; use super::*;
#[rstest::fixture] #[rstest::fixture]