mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
feat(core): Rename crate data_models to hyperswitch_domain_models (#4504)
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
use async_bb8_diesel::{AsyncConnection, ConnectionError};
|
||||
use bb8::CustomizeConnection;
|
||||
use data_models::errors::{StorageError, StorageResult};
|
||||
use diesel::PgConnection;
|
||||
use error_stack::ResultExt;
|
||||
use hyperswitch_domain_models::errors::{StorageError, StorageResult};
|
||||
use masking::PeekInterface;
|
||||
|
||||
use crate::config::Database;
|
||||
|
||||
@ -3,8 +3,8 @@ use std::fmt::Display;
|
||||
use actix_web::ResponseError;
|
||||
use common_utils::errors::ErrorSwitch;
|
||||
use config::ConfigError;
|
||||
use data_models::errors::StorageError as DataStorageError;
|
||||
use http::StatusCode;
|
||||
use hyperswitch_domain_models::errors::StorageError as DataStorageError;
|
||||
pub use redis_interface::errors::RedisError;
|
||||
use router_env::opentelemetry::metrics::MetricsError;
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use data_models::errors::{StorageError, StorageResult};
|
||||
use diesel_models as store;
|
||||
use error_stack::ResultExt;
|
||||
use hyperswitch_domain_models::errors::{StorageError, StorageResult};
|
||||
use masking::StrongSecret;
|
||||
use redis::{kv_store::RedisConnInterface, RedisStore};
|
||||
mod address;
|
||||
@ -25,9 +25,9 @@ mod reverse_lookup;
|
||||
mod utils;
|
||||
|
||||
use common_utils::errors::CustomResult;
|
||||
#[cfg(not(feature = "payouts"))]
|
||||
use data_models::{PayoutAttemptInterface, PayoutsInterface};
|
||||
use database::store::PgPool;
|
||||
#[cfg(not(feature = "payouts"))]
|
||||
use hyperswitch_domain_models::{PayoutAttemptInterface, PayoutsInterface};
|
||||
pub use mock_db::MockDb;
|
||||
use redis_interface::{errors::RedisError, SaddReply};
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
use common_utils::errors::CustomResult;
|
||||
use data_models::errors;
|
||||
use diesel_models::{
|
||||
enums as storage_enums, kv,
|
||||
reverse_lookup::{
|
||||
@ -7,6 +6,7 @@ use diesel_models::{
|
||||
},
|
||||
};
|
||||
use error_stack::ResultExt;
|
||||
use hyperswitch_domain_models::errors;
|
||||
use redis_interface::SetnxReply;
|
||||
|
||||
use crate::{
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use data_models::{
|
||||
errors::StorageError,
|
||||
payments::{payment_attempt::PaymentAttempt, PaymentIntent},
|
||||
};
|
||||
use diesel_models::{self as store};
|
||||
use error_stack::ResultExt;
|
||||
use futures::lock::Mutex;
|
||||
use hyperswitch_domain_models::{
|
||||
errors::StorageError,
|
||||
payments::{payment_attempt::PaymentAttempt, PaymentIntent},
|
||||
};
|
||||
use redis_interface::RedisSettings;
|
||||
|
||||
use crate::redis::RedisStore;
|
||||
@ -19,7 +19,7 @@ pub mod payout_attempt;
|
||||
pub mod payouts;
|
||||
pub mod redis_conn;
|
||||
#[cfg(not(feature = "payouts"))]
|
||||
use data_models::{PayoutAttemptInterface, PayoutsInterface};
|
||||
use hyperswitch_domain_models::{PayoutAttemptInterface, PayoutsInterface};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MockDb {
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
use api_models::enums::{AuthenticationType, Connector, PaymentMethod, PaymentMethodType};
|
||||
use common_utils::errors::CustomResult;
|
||||
use data_models::{
|
||||
use diesel_models::enums as storage_enums;
|
||||
use hyperswitch_domain_models::{
|
||||
errors::StorageError,
|
||||
payments::payment_attempt::{
|
||||
PaymentAttempt, PaymentAttemptInterface, PaymentAttemptNew, PaymentAttemptUpdate,
|
||||
},
|
||||
};
|
||||
use diesel_models::enums as storage_enums;
|
||||
|
||||
use super::MockDb;
|
||||
use crate::DataModelExt;
|
||||
@ -26,11 +26,13 @@ impl PaymentAttemptInterface for MockDb {
|
||||
|
||||
async fn get_filters_for_payments(
|
||||
&self,
|
||||
_pi: &[data_models::payments::PaymentIntent],
|
||||
_pi: &[hyperswitch_domain_models::payments::PaymentIntent],
|
||||
_merchant_id: &str,
|
||||
_storage_scheme: storage_enums::MerchantStorageScheme,
|
||||
) -> CustomResult<data_models::payments::payment_attempt::PaymentListFilters, StorageError>
|
||||
{
|
||||
) -> CustomResult<
|
||||
hyperswitch_domain_models::payments::payment_attempt::PaymentListFilters,
|
||||
StorageError,
|
||||
> {
|
||||
Err(StorageError::MockDbError)?
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
use common_utils::errors::CustomResult;
|
||||
use data_models::{
|
||||
use diesel_models::enums as storage_enums;
|
||||
use error_stack::ResultExt;
|
||||
use hyperswitch_domain_models::{
|
||||
errors::StorageError,
|
||||
payments::{
|
||||
payment_attempt::PaymentAttempt,
|
||||
@ -7,8 +9,6 @@ use data_models::{
|
||||
PaymentIntent,
|
||||
},
|
||||
};
|
||||
use diesel_models::enums as storage_enums;
|
||||
use error_stack::ResultExt;
|
||||
|
||||
use super::MockDb;
|
||||
use crate::DataModelExt;
|
||||
@ -19,7 +19,7 @@ impl PaymentIntentInterface for MockDb {
|
||||
async fn filter_payment_intent_by_constraints(
|
||||
&self,
|
||||
_merchant_id: &str,
|
||||
_filters: &data_models::payments::payment_intent::PaymentIntentFetchConstraints,
|
||||
_filters: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
|
||||
_storage_scheme: storage_enums::MerchantStorageScheme,
|
||||
) -> CustomResult<Vec<PaymentIntent>, StorageError> {
|
||||
// [#172]: Implement function for `MockDb`
|
||||
@ -39,7 +39,7 @@ impl PaymentIntentInterface for MockDb {
|
||||
async fn get_filtered_active_attempt_ids_for_total_count(
|
||||
&self,
|
||||
_merchant_id: &str,
|
||||
_constraints: &data_models::payments::payment_intent::PaymentIntentFetchConstraints,
|
||||
_constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
|
||||
_storage_scheme: storage_enums::MerchantStorageScheme,
|
||||
) -> error_stack::Result<Vec<String>, StorageError> {
|
||||
// [#172]: Implement function for `MockDb`
|
||||
@ -49,7 +49,7 @@ impl PaymentIntentInterface for MockDb {
|
||||
async fn get_filtered_payment_intents_attempt(
|
||||
&self,
|
||||
_merchant_id: &str,
|
||||
_constraints: &data_models::payments::payment_intent::PaymentIntentFetchConstraints,
|
||||
_constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
|
||||
_storage_scheme: storage_enums::MerchantStorageScheme,
|
||||
) -> error_stack::Result<Vec<(PaymentIntent, PaymentAttempt)>, StorageError> {
|
||||
// [#172]: Implement function for `MockDb`
|
||||
@ -159,7 +159,7 @@ impl PaymentIntentInterface for MockDb {
|
||||
_storage_scheme: storage_enums::MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentAttempt, StorageError> {
|
||||
match payment.active_attempt.clone() {
|
||||
data_models::RemoteStorageObject::ForeignID(id) => {
|
||||
hyperswitch_domain_models::RemoteStorageObject::ForeignID(id) => {
|
||||
let attempts = self.payment_attempts.lock().await;
|
||||
let attempt = attempts
|
||||
.iter()
|
||||
@ -169,7 +169,7 @@ impl PaymentIntentInterface for MockDb {
|
||||
payment.active_attempt = attempt.clone().into();
|
||||
Ok(attempt.clone())
|
||||
}
|
||||
data_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
|
||||
hyperswitch_domain_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
use common_utils::errors::CustomResult;
|
||||
use data_models::{
|
||||
use diesel_models::enums as storage_enums;
|
||||
use hyperswitch_domain_models::{
|
||||
errors::StorageError,
|
||||
payouts::{
|
||||
payout_attempt::{
|
||||
@ -8,7 +9,6 @@ use data_models::{
|
||||
payouts::Payouts,
|
||||
},
|
||||
};
|
||||
use diesel_models::enums as storage_enums;
|
||||
|
||||
use super::MockDb;
|
||||
|
||||
@ -50,7 +50,10 @@ impl PayoutAttemptInterface for MockDb {
|
||||
_payouts: &[Payouts],
|
||||
_merchant_id: &str,
|
||||
_storage_scheme: storage_enums::MerchantStorageScheme,
|
||||
) -> CustomResult<data_models::payouts::payout_attempt::PayoutListFilters, StorageError> {
|
||||
) -> CustomResult<
|
||||
hyperswitch_domain_models::payouts::payout_attempt::PayoutListFilters,
|
||||
StorageError,
|
||||
> {
|
||||
Err(StorageError::MockDbError)?
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
use common_utils::errors::CustomResult;
|
||||
use data_models::{
|
||||
use diesel_models::enums as storage_enums;
|
||||
use hyperswitch_domain_models::{
|
||||
errors::StorageError,
|
||||
payouts::{
|
||||
payout_attempt::PayoutAttempt,
|
||||
payouts::{Payouts, PayoutsInterface, PayoutsNew, PayoutsUpdate},
|
||||
},
|
||||
};
|
||||
use diesel_models::enums as storage_enums;
|
||||
|
||||
use super::MockDb;
|
||||
|
||||
@ -56,7 +56,7 @@ impl PayoutsInterface for MockDb {
|
||||
async fn filter_payouts_by_constraints(
|
||||
&self,
|
||||
_merchant_id: &str,
|
||||
_filters: &data_models::payouts::PayoutFetchConstraints,
|
||||
_filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
|
||||
_storage_scheme: storage_enums::MerchantStorageScheme,
|
||||
) -> CustomResult<Vec<Payouts>, StorageError> {
|
||||
// TODO: Implement function for `MockDb`
|
||||
@ -67,7 +67,7 @@ impl PayoutsInterface for MockDb {
|
||||
async fn filter_payouts_and_attempts(
|
||||
&self,
|
||||
_merchant_id: &str,
|
||||
_filters: &data_models::payouts::PayoutFetchConstraints,
|
||||
_filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
|
||||
_storage_scheme: storage_enums::MerchantStorageScheme,
|
||||
) -> CustomResult<Vec<(Payouts, PayoutAttempt, diesel_models::Customer)>, StorageError> {
|
||||
// TODO: Implement function for `MockDb`
|
||||
|
||||
@ -1,16 +1,5 @@
|
||||
use api_models::enums::{AuthenticationType, Connector, PaymentMethod, PaymentMethodType};
|
||||
use common_utils::{errors::CustomResult, fallback_reverse_lookup_not_found};
|
||||
use data_models::{
|
||||
errors,
|
||||
mandates::{MandateAmountData, MandateDataType, MandateDetails},
|
||||
payments::{
|
||||
payment_attempt::{
|
||||
PaymentAttempt, PaymentAttemptInterface, PaymentAttemptNew, PaymentAttemptUpdate,
|
||||
PaymentListFilters,
|
||||
},
|
||||
PaymentIntent,
|
||||
},
|
||||
};
|
||||
use diesel_models::{
|
||||
enums::{
|
||||
MandateAmountData as DieselMandateAmountData, MandateDataType as DieselMandateType,
|
||||
@ -24,6 +13,17 @@ use diesel_models::{
|
||||
reverse_lookup::{ReverseLookup, ReverseLookupNew},
|
||||
};
|
||||
use error_stack::ResultExt;
|
||||
use hyperswitch_domain_models::{
|
||||
errors,
|
||||
mandates::{MandateAmountData, MandateDataType, MandateDetails},
|
||||
payments::{
|
||||
payment_attempt::{
|
||||
PaymentAttempt, PaymentAttemptInterface, PaymentAttemptNew, PaymentAttemptUpdate,
|
||||
PaymentListFilters,
|
||||
},
|
||||
PaymentIntent,
|
||||
},
|
||||
};
|
||||
use redis_interface::HsetnxReply;
|
||||
use router_env::{instrument, tracing};
|
||||
|
||||
|
||||
@ -6,17 +6,6 @@ use async_bb8_diesel::{AsyncConnection, AsyncRunQueryDsl};
|
||||
use common_utils::errors::ReportSwitchExt;
|
||||
use common_utils::{date_time, ext_traits::Encode};
|
||||
#[cfg(feature = "olap")]
|
||||
use data_models::payments::payment_intent::PaymentIntentFetchConstraints;
|
||||
use data_models::{
|
||||
errors::StorageError,
|
||||
payments::{
|
||||
payment_attempt::PaymentAttempt,
|
||||
payment_intent::{PaymentIntentInterface, PaymentIntentNew, PaymentIntentUpdate},
|
||||
PaymentIntent,
|
||||
},
|
||||
RemoteStorageObject,
|
||||
};
|
||||
#[cfg(feature = "olap")]
|
||||
use diesel::{associations::HasTable, ExpressionMethods, JoinOnDsl, QueryDsl};
|
||||
use diesel_models::{
|
||||
enums::MerchantStorageScheme,
|
||||
@ -33,6 +22,17 @@ use diesel_models::{
|
||||
schema::{payment_attempt::dsl as pa_dsl, payment_intent::dsl as pi_dsl},
|
||||
};
|
||||
use error_stack::ResultExt;
|
||||
#[cfg(feature = "olap")]
|
||||
use hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints;
|
||||
use hyperswitch_domain_models::{
|
||||
errors::StorageError,
|
||||
payments::{
|
||||
payment_attempt::PaymentAttempt,
|
||||
payment_intent::{PaymentIntentInterface, PaymentIntentNew, PaymentIntentUpdate},
|
||||
PaymentIntent,
|
||||
},
|
||||
RemoteStorageObject,
|
||||
};
|
||||
use redis_interface::HsetnxReply;
|
||||
#[cfg(feature = "olap")]
|
||||
use router_env::logger;
|
||||
@ -257,7 +257,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
_storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentAttempt, StorageError> {
|
||||
match payment.active_attempt.clone() {
|
||||
data_models::RemoteStorageObject::ForeignID(attempt_id) => {
|
||||
hyperswitch_domain_models::RemoteStorageObject::ForeignID(attempt_id) => {
|
||||
let conn = pg_connection_read(self).await?;
|
||||
|
||||
let pa = DieselPaymentAttempt::find_by_merchant_id_attempt_id(
|
||||
@ -271,10 +271,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
er.change_context(new_err)
|
||||
})
|
||||
.map(PaymentAttempt::from_storage_model)?;
|
||||
payment.active_attempt = data_models::RemoteStorageObject::Object(pa.clone());
|
||||
payment.active_attempt =
|
||||
hyperswitch_domain_models::RemoteStorageObject::Object(pa.clone());
|
||||
Ok(pa)
|
||||
}
|
||||
data_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
|
||||
hyperswitch_domain_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -396,7 +397,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
_storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentAttempt, StorageError> {
|
||||
match &payment.active_attempt {
|
||||
data_models::RemoteStorageObject::ForeignID(attempt_id) => {
|
||||
hyperswitch_domain_models::RemoteStorageObject::ForeignID(attempt_id) => {
|
||||
let conn = pg_connection_read(self).await?;
|
||||
|
||||
let pa = DieselPaymentAttempt::find_by_merchant_id_attempt_id(
|
||||
@ -410,10 +411,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
er.change_context(new_err)
|
||||
})
|
||||
.map(PaymentAttempt::from_storage_model)?;
|
||||
payment.active_attempt = data_models::RemoteStorageObject::Object(pa.clone());
|
||||
payment.active_attempt =
|
||||
hyperswitch_domain_models::RemoteStorageObject::Object(pa.clone());
|
||||
Ok(pa)
|
||||
}
|
||||
data_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
|
||||
hyperswitch_domain_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,16 +2,6 @@ use std::str::FromStr;
|
||||
|
||||
use api_models::enums::PayoutConnectors;
|
||||
use common_utils::{errors::CustomResult, ext_traits::Encode, fallback_reverse_lookup_not_found};
|
||||
use data_models::{
|
||||
errors,
|
||||
payouts::{
|
||||
payout_attempt::{
|
||||
PayoutAttempt, PayoutAttemptInterface, PayoutAttemptNew, PayoutAttemptUpdate,
|
||||
PayoutListFilters,
|
||||
},
|
||||
payouts::Payouts,
|
||||
},
|
||||
};
|
||||
use diesel_models::{
|
||||
enums::MerchantStorageScheme,
|
||||
kv,
|
||||
@ -22,6 +12,16 @@ use diesel_models::{
|
||||
ReverseLookupNew,
|
||||
};
|
||||
use error_stack::ResultExt;
|
||||
use hyperswitch_domain_models::{
|
||||
errors,
|
||||
payouts::{
|
||||
payout_attempt::{
|
||||
PayoutAttempt, PayoutAttemptInterface, PayoutAttemptNew, PayoutAttemptUpdate,
|
||||
PayoutListFilters,
|
||||
},
|
||||
payouts::Payouts,
|
||||
},
|
||||
};
|
||||
use redis_interface::HsetnxReply;
|
||||
use router_env::{instrument, logger, tracing};
|
||||
|
||||
|
||||
@ -2,15 +2,6 @@
|
||||
use async_bb8_diesel::{AsyncConnection, AsyncRunQueryDsl};
|
||||
use common_utils::ext_traits::Encode;
|
||||
#[cfg(feature = "olap")]
|
||||
use data_models::payouts::PayoutFetchConstraints;
|
||||
use data_models::{
|
||||
errors::StorageError,
|
||||
payouts::{
|
||||
payout_attempt::PayoutAttempt,
|
||||
payouts::{Payouts, PayoutsInterface, PayoutsNew, PayoutsUpdate},
|
||||
},
|
||||
};
|
||||
#[cfg(feature = "olap")]
|
||||
use diesel::{associations::HasTable, ExpressionMethods, JoinOnDsl, QueryDsl};
|
||||
#[cfg(feature = "olap")]
|
||||
use diesel_models::{
|
||||
@ -28,6 +19,15 @@ use diesel_models::{
|
||||
},
|
||||
};
|
||||
use error_stack::ResultExt;
|
||||
#[cfg(feature = "olap")]
|
||||
use hyperswitch_domain_models::payouts::PayoutFetchConstraints;
|
||||
use hyperswitch_domain_models::{
|
||||
errors::StorageError,
|
||||
payouts::{
|
||||
payout_attempt::PayoutAttempt,
|
||||
payouts::{Payouts, PayoutsInterface, PayoutsNew, PayoutsUpdate},
|
||||
},
|
||||
};
|
||||
use redis_interface::HsetnxReply;
|
||||
#[cfg(feature = "olap")]
|
||||
use router_env::logger;
|
||||
|
||||
@ -4,9 +4,9 @@ use common_utils::{
|
||||
errors::{self, CustomResult},
|
||||
ext_traits::AsyncExt,
|
||||
};
|
||||
use data_models::errors::StorageError;
|
||||
use dyn_clone::DynClone;
|
||||
use error_stack::{Report, ResultExt};
|
||||
use hyperswitch_domain_models::errors::StorageError;
|
||||
use moka::future::Cache as MokaCache;
|
||||
use once_cell::sync::Lazy;
|
||||
use redis_interface::{errors::RedisError, RedisValue};
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use bb8::PooledConnection;
|
||||
use data_models::errors::StorageError;
|
||||
use diesel::PgConnection;
|
||||
use error_stack::ResultExt;
|
||||
use hyperswitch_domain_models::errors::StorageError;
|
||||
|
||||
use crate::{errors::RedisErrorExt, metrics, DatabaseStore};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user