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 super::model::{TrelloAttachmentId, TrelloCardId};
use super::model::{attachment::TrelloAttachmentId, card::TrelloCardId};
#[derive(Parser, Debug)]
pub enum TrelloAttachmentCommand {

View file

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

View file

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

View file

@ -5,14 +5,15 @@ use std::path::PathBuf;
use color_eyre::eyre::Context;
use kxio::net::{Net, ReqBuilder};
use crate::trello::model::{TrelloAttachment, TrelloAttachmentId};
use crate::{
api_result::APIResult,
f, s,
trello::model::{
board::TrelloBoard,
attachment::{TrelloAttachment, TrelloAttachmentId},
board::{TrelloBoard, TrelloBoardId},
card::TrelloCardId,
card::{TrelloLongCard, TrelloShortCard},
TrelloBoardId, TrelloCardId, TrelloListId,
list::TrelloListId,
},
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)]
pub(crate) struct TrelloBoard {

View file

@ -1,10 +1,18 @@
//
use super::{
TrelloAttachment, TrelloAttachmentId, TrelloCardDescription, TrelloCardDue, TrelloCardId,
TrelloCardName, TrelloCardPosition, TrelloLabelId, TrelloListId,
};
use derive_more::derive::Display;
use serde::Deserialize;
#[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) id: TrelloCardId,
pub(crate) name: TrelloCardName,
@ -12,7 +20,7 @@ pub(crate) struct TrelloCard {
pub(crate) id_list: TrelloListId,
}
#[derive(Debug, PartialEq, Eq, serde::Deserialize)]
#[derive(Debug, PartialEq, Eq, Deserialize)]
pub(crate) struct TrelloShortCard {
pub(crate) id: TrelloCardId,
pub(crate) name: TrelloCardName,
@ -24,7 +32,7 @@ pub(crate) struct TrelloShortCard {
pub(crate) pos: TrelloCardPosition,
}
#[derive(Debug, PartialEq, Eq, serde::Deserialize)]
#[derive(Debug, PartialEq, Eq, Deserialize)]
pub(crate) struct TrelloLongCard {
pub(crate) id: TrelloCardId,
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) id: TrelloListId,
pub(crate) name: TrelloListName,

View file

@ -1,46 +1,7 @@
//
pub(crate) mod attachment;
pub(crate) mod auth;
pub(crate) mod board;
pub(crate) mod card;
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,
}
pub(crate) mod label;
pub(crate) mod list;

View file

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

View file

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

View file

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

View file

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

View file

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