Flatten cfg attr

This commit is contained in:
eraden 2022-12-22 09:25:23 +01:00
parent 95aa01d333
commit b4d8522511
5 changed files with 70 additions and 92 deletions

1
Cargo.lock generated
View File

@ -718,6 +718,7 @@ dependencies = [
"thiserror",
"tokio 1.23.0",
"tracing",
"uuid 1.2.2",
"whatlang",
]

View File

@ -29,3 +29,4 @@ thiserror = { version = "1" }
tokio = { version = "1", features = ['full'] }
tracing = { version = "0" }
whatlang = { version = "0" }
uuid = { version = "1", features = ['v4'] }

View File

@ -6,13 +6,25 @@ pub enum Topic {}
pub enum Error {}
pub mod create_pair {
use model::{AccessToken, AccessTokenString, RefreshToken, Token};
pub use model::{AccountId, Role};
use super::Error;
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct Input {}
pub struct Input {
pub customer_id: uuid::Uuid,
pub role: Role,
pub account_id: AccountId,
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct Details {}
pub struct Details {
pub access_token: AccessToken,
pub access_token_string: AccessTokenString,
pub refresh_token: RefreshToken,
pub refresh_token_string: model::RefreshTokenString,
}
pub type Output = Result<Details, Error>;
}

View File

@ -221,8 +221,7 @@ impl Default for Audience {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Default,
Debug,
@ -263,8 +262,7 @@ pub trait Ranged: Sized + From<u32> + Copy {
fn into_raw(self) -> i32;
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Debug, Copy, Clone, Hash, PartialOrd, PartialEq, Eq, Serialize, Deserialize, Deref, From,
)]
@ -295,8 +293,7 @@ impl Limit {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Default,
Debug,
@ -332,8 +329,7 @@ impl Offset {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Serialize, Deserialize, Default, Debug, PartialEq, Eq, Copy, Clone, Hash, Deref, From)]
#[serde(transparent)]
pub struct Quantity(NonNegative);
@ -368,8 +364,7 @@ impl TryFrom<i32> for Quantity {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Deref, From, Display)]
#[serde(transparent)]
pub struct Login(String);
@ -380,8 +375,7 @@ impl Login {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Serialize, Debug, Clone, Default, PartialOrd, PartialEq, Eq, Deref, DerefMut, From, Display,
)]
@ -398,8 +392,7 @@ impl Email {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Serialize,
Deserialize,
@ -468,8 +461,7 @@ impl<'de> serde::Deserialize<'de> for Email {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Default, Debug, PartialEq, Eq, PartialOrd, Copy, Clone, Hash, Serialize, Deref, Display,
)]
@ -712,8 +704,7 @@ where
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Serialize, Deserialize, Debug, Deref, Display)]
#[serde(transparent)]
pub struct ResetToken(String);
@ -724,8 +715,7 @@ impl ResetToken {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Serialize, Deserialize, Debug, Clone, Deref, From, Display)]
#[serde(transparent)]
pub struct Password(String);
@ -736,8 +726,7 @@ impl Password {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Serialize, Deserialize, Debug, Clone, Deref, From, Display)]
#[serde(transparent)]
pub struct PasswordConfirmation(String);
@ -748,8 +737,7 @@ impl PasswordConfirmation {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Deref, From, Display)]
#[serde(transparent)]
pub struct PassHash(String);
@ -766,8 +754,7 @@ impl PartialEq<PasswordConfirmation> for Password {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Serialize, Deserialize, Copy, Clone, Debug, PartialOrd, PartialEq, Eq, Deref, Display, From,
)]
@ -820,8 +807,7 @@ impl From<FullAccount> for Account {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Deref, From)]
#[serde(transparent)]
pub struct ProductId(RecordId);
@ -832,8 +818,7 @@ impl Display for ProductId {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
#[serde(transparent)]
pub struct ProductName(String);
@ -852,8 +837,7 @@ impl ProductName {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
#[serde(transparent)]
pub struct ProductShortDesc(String);
@ -872,8 +856,7 @@ impl ProductShortDesc {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
#[serde(transparent)]
pub struct ProductLongDesc(String);
@ -894,8 +877,7 @@ impl ProductLongDesc {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
#[serde(transparent)]
pub struct ProductCategory(pub String);
@ -922,8 +904,7 @@ pub struct Product {
pub deliver_days_flag: Days,
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, PartialEq, Eq, Copy, Clone, Serialize, Deserialize)]
#[serde(transparent)]
pub struct StockId(pub RecordId);
@ -937,20 +918,17 @@ pub struct Stock {
pub quantity_unit: QuantityUnit,
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Display, Deref)]
#[serde(transparent)]
pub struct OrderAddressId(RecordId);
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Display, Deref)]
#[serde(transparent)]
pub struct OrderId(RecordId);
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Display, Deref)]
#[serde(transparent)]
pub struct ExtOrderId(String);
@ -1015,8 +993,7 @@ impl From<Order> for PublicOrder {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Deref)]
pub struct OrderItemId(pub RecordId);
@ -1031,8 +1008,7 @@ pub struct OrderItem {
pub state: OrderItemState,
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Serialize, Deserialize, PartialEq, Eq, Copy, Clone, Debug, Deref, Display)]
#[serde(transparent)]
pub struct ShoppingCartId(pub RecordId);
@ -1047,8 +1023,7 @@ pub struct ShoppingCart {
pub checkout_notes: Option<String>,
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(PartialEq, Eq, Copy, Clone, Debug, Serialize, Deserialize, Deref, Display)]
#[serde(transparent)]
pub struct ShoppingCartItemId(RecordId);
@ -1070,8 +1045,7 @@ impl ShoppingCartItem {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Serialize, Deserialize, Copy, Clone, PartialEq, Eq, Deref, Display, Debug)]
#[serde(transparent)]
pub struct TokenId(RecordId);
@ -1101,14 +1075,21 @@ pub struct Token {
pub jwt_id: uuid::Uuid,
}
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Deref, From)]
pub struct AccessToken(Token);
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Deref, From)]
pub struct RefreshToken(Token);
impl Token {
pub fn account_id(&self) -> AccountId {
AccountId(self.subject)
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
pub struct AccessTokenString(String);
@ -1124,8 +1105,7 @@ impl From<RefreshTokenString> for AccessTokenString {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
pub struct RefreshTokenString(String);
@ -1141,8 +1121,7 @@ impl RefreshTokenString {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, Hash, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
pub struct LocalPath(String);
@ -1152,8 +1131,7 @@ impl LocalPath {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, Hash, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
pub struct UniqueName(String);
@ -1163,8 +1141,7 @@ impl UniqueName {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, Hash, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
pub struct FileName(String);
@ -1174,8 +1151,7 @@ impl FileName {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Debug,
Copy,
@ -1192,8 +1168,7 @@ impl FileName {
)]
pub struct PhotoId(RecordId);
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, Hash, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
pub struct ProductPhotoId(RecordId);
@ -1234,8 +1209,7 @@ pub enum ShippingMethod {
Manual,
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Serialize,
Deserialize,
@ -1258,8 +1232,7 @@ impl AddressId {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Serialize,
Deserialize,
@ -1283,8 +1256,7 @@ impl Name {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Serialize,
Deserialize,
@ -1308,8 +1280,7 @@ impl Street {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Serialize,
Deserialize,
@ -1333,8 +1304,7 @@ impl City {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Serialize,
Deserialize,
@ -1358,8 +1328,7 @@ impl Country {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Serialize,
Deserialize,
@ -1422,8 +1391,7 @@ pub mod v2 {
RecordId, ShoppingCartId, StockId, UniqueName,
};
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
#[serde(transparent)]
pub struct ProductVariantName(String);
@ -1442,8 +1410,7 @@ pub mod v2 {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Deref, From)]
#[serde(transparent)]
pub struct ProductVariantId(pub RecordId);
@ -1536,8 +1503,7 @@ pub mod v2 {
pub photo_id: PhotoId,
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Debug,
Clone,
@ -1556,8 +1522,7 @@ pub mod v2 {
#[serde(transparent)]
pub struct CategoryId(NonNegative);
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Debug,
Clone,
@ -1581,8 +1546,7 @@ pub mod v2 {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Debug,
Clone,
@ -1606,8 +1570,7 @@ pub mod v2 {
}
}
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[cfg_attr(feature = "db", derive(sqlx::Type), sqlx(transparent))]
#[derive(
Debug,
Clone,

View File

@ -71,6 +71,7 @@
//! ```
mod actions;
mod context;
mod db;
/*struct Jwt {