text stringlengths 70 351k | source stringclasses 4 values |
|---|---|
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use crate::{
query::generics, schema::users::dsl as users_dsl, user::*, PgPooledConn, StorageResult,
};
pub async fn delete_by_user_id(conn: &PgPooledConn, user_id: &str) -> StorageResult<bool> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user.rs | crate: diesel_models
use common_utils::pii;
use diesel::{associations::HasTable, ExpressionMethods};
use crate::{
query::generics, schema::users::dsl as users_dsl, user::*, PgPooledConn, StorageResult,
};
pub async fn update_by_user_email(
conn: &PgPooledConn,
user_email: &pii::Email,
user_update: UserUpdate,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use crate::{
query::generics, schema::users::dsl as users_dsl, user::*, PgPooledConn, StorageResult,
};
pub async fn update_by_user_id(
conn: &PgPooledConn,
user_id: &str,
user_update: UserUpdate,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user.rs | crate: diesel_models
use common_utils::pii;
use diesel::{associations::HasTable, ExpressionMethods};
use crate::{
query::generics, schema::users::dsl as users_dsl, user::*, PgPooledConn, StorageResult,
};
pub async fn find_by_user_email(
conn: &PgPooledConn,
user_email: &pii::Email,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user.rs | crate: diesel_models
use crate::{
query::generics, schema::users::dsl as users_dsl, user::*, PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<User> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/unified_translations.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use error_stack::report;
use crate::{
errors,
query::generics,
schema::unified_translations::dsl,
unified_translations::{UnifiedTranslationsUpdateInternal, *},
PgPooledConn, StorageResult,
};
pub async fn update_by_unified_code_unified_message_locale(
conn: &PgPooledConn,
unified_code: String,
unified_message: String,
locale: String,
data: UnifiedTranslationsUpdate,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/unified_translations.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use crate::{
errors,
query::generics,
schema::unified_translations::dsl,
unified_translations::{UnifiedTranslationsUpdateInternal, *},
PgPooledConn, StorageResult,
};
pub async fn delete_by_unified_code_unified_message_locale(
conn: &PgPooledConn,
unified_code: String,
unified_message: String,
locale: String,
) -> StorageResult<bool> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/unified_translations.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use crate::{
errors,
query::generics,
schema::unified_translations::dsl,
unified_translations::{UnifiedTranslationsUpdateInternal, *},
PgPooledConn, StorageResult,
};
pub async fn find_by_unified_code_unified_message_locale(
conn: &PgPooledConn,
unified_code: String,
unified_message: String,
locale: String,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/unified_translations.rs | crate: diesel_models
use crate::{
errors,
query::generics,
schema::unified_translations::dsl,
unified_translations::{UnifiedTranslationsUpdateInternal, *},
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<UnifiedTranslations> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/dashboard_metadata.rs | crate: diesel_models
use common_utils::id_type;
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use crate::{
enums,
query::generics,
schema::dashboard_metadata::dsl,
user::dashboard_metadata::{
DashboardMetadata, DashboardMetadataNew, DashboardMetadataUpdate,
DashboardMetadataUpdateInternal,
},
PgPooledConn, StorageResult,
};
pub async fn update(
conn: &PgPooledConn,
user_id: Option<String>,
merchant_id: id_type::MerchantId,
org_id: id_type::OrganizationId,
data_key: enums::DashboardMetadata,
dashboard_metadata_update: DashboardMetadataUpdate,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/dashboard_metadata.rs | crate: diesel_models
use common_utils::id_type;
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use crate::{
enums,
query::generics,
schema::dashboard_metadata::dsl,
user::dashboard_metadata::{
DashboardMetadata, DashboardMetadataNew, DashboardMetadataUpdate,
DashboardMetadataUpdateInternal,
},
PgPooledConn, StorageResult,
};
pub async fn delete_user_scoped_dashboard_metadata_by_merchant_id_data_key(
conn: &PgPooledConn,
user_id: String,
merchant_id: id_type::MerchantId,
data_key: enums::DashboardMetadata,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/dashboard_metadata.rs | crate: diesel_models
use common_utils::id_type;
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use crate::{
enums,
query::generics,
schema::dashboard_metadata::dsl,
user::dashboard_metadata::{
DashboardMetadata, DashboardMetadataNew, DashboardMetadataUpdate,
DashboardMetadataUpdateInternal,
},
PgPooledConn, StorageResult,
};
pub async fn delete_all_user_scoped_dashboard_metadata_by_merchant_id(
conn: &PgPooledConn,
user_id: String,
merchant_id: id_type::MerchantId,
) -> StorageResult<bool> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/dashboard_metadata.rs | crate: diesel_models
use common_utils::id_type;
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use crate::{
enums,
query::generics,
schema::dashboard_metadata::dsl,
user::dashboard_metadata::{
DashboardMetadata, DashboardMetadataNew, DashboardMetadataUpdate,
DashboardMetadataUpdateInternal,
},
PgPooledConn, StorageResult,
};
pub async fn find_merchant_scoped_dashboard_metadata(
conn: &PgPooledConn,
merchant_id: id_type::MerchantId,
org_id: id_type::OrganizationId,
data_types: Vec<enums::DashboardMetadata>,
) -> StorageResult<Vec<Self>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/dashboard_metadata.rs | crate: diesel_models
use common_utils::id_type;
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use crate::{
enums,
query::generics,
schema::dashboard_metadata::dsl,
user::dashboard_metadata::{
DashboardMetadata, DashboardMetadataNew, DashboardMetadataUpdate,
DashboardMetadataUpdateInternal,
},
PgPooledConn, StorageResult,
};
pub async fn find_user_scoped_dashboard_metadata(
conn: &PgPooledConn,
user_id: String,
merchant_id: id_type::MerchantId,
org_id: id_type::OrganizationId,
data_types: Vec<enums::DashboardMetadata>,
) -> StorageResult<Vec<Self>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/dashboard_metadata.rs | crate: diesel_models
use crate::{
enums,
query::generics,
schema::dashboard_metadata::dsl,
user::dashboard_metadata::{
DashboardMetadata, DashboardMetadataNew, DashboardMetadataUpdate,
DashboardMetadataUpdateInternal,
},
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<DashboardMetadata> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/authentication.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
authentication::{
Authentication, AuthenticationNew, AuthenticationUpdate, AuthenticationUpdateInternal,
},
errors,
schema::authentication::dsl,
PgPooledConn, StorageResult,
};
pub async fn update_by_merchant_id_authentication_id(
conn: &PgPooledConn,
merchant_id: common_utils::id_type::MerchantId,
authentication_id: String,
authorization_update: AuthenticationUpdate,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/authentication.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
authentication::{
Authentication, AuthenticationNew, AuthenticationUpdate, AuthenticationUpdateInternal,
},
errors,
schema::authentication::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_authentication_by_merchant_id_connector_authentication_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
connector_authentication_id: &str,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/authentication.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
authentication::{
Authentication, AuthenticationNew, AuthenticationUpdate, AuthenticationUpdateInternal,
},
errors,
schema::authentication::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_by_merchant_id_authentication_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
authentication_id: &str,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/authentication.rs | crate: diesel_models
use super::generics;
use crate::{
authentication::{
Authentication, AuthenticationNew, AuthenticationUpdate, AuthenticationUpdateInternal,
},
errors,
schema::authentication::dsl,
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<Authentication> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/reverse_lookup.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use super::generics;
use crate::{
reverse_lookup::{ReverseLookup, ReverseLookupNew},
schema::reverse_lookup::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_by_lookup_id(lookup_id: &str, conn: &PgPooledConn) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/reverse_lookup.rs | crate: diesel_models
use super::generics;
use crate::{
reverse_lookup::{ReverseLookup, ReverseLookupNew},
schema::reverse_lookup::dsl,
PgPooledConn, StorageResult,
};
pub async fn batch_insert(
reverse_lookups: Vec<Self>,
conn: &PgPooledConn,
) -> StorageResult<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/reverse_lookup.rs | crate: diesel_models
use super::generics;
use crate::{
reverse_lookup::{ReverseLookup, ReverseLookupNew},
schema::reverse_lookup::dsl,
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<ReverseLookup> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/relay.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
errors,
relay::{Relay, RelayNew, RelayUpdateInternal},
schema::relay::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_by_profile_id_connector_reference_id(
conn: &PgPooledConn,
profile_id: &common_utils::id_type::ProfileId,
connector_reference_id: &str,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/relay.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
errors,
relay::{Relay, RelayNew, RelayUpdateInternal},
schema::relay::dsl,
PgPooledConn, StorageResult,
};
pub async fn find_by_id(
conn: &PgPooledConn,
id: &common_utils::id_type::RelayId,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/relay.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
errors,
relay::{Relay, RelayNew, RelayUpdateInternal},
schema::relay::dsl,
PgPooledConn, StorageResult,
};
pub async fn update(
self,
conn: &PgPooledConn,
relay: RelayUpdateInternal,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/relay.rs | crate: diesel_models
use super::generics;
use crate::{
errors,
relay::{Relay, RelayNew, RelayUpdateInternal},
schema::relay::dsl,
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<Relay> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/authorization.rs | crate: diesel_models
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
authorization::{
Authorization, AuthorizationNew, AuthorizationUpdate, AuthorizationUpdateInternal,
},
errors,
schema::incremental_authorization::dsl,
PgPooledConn, StorageResult,
};
pub async fn update_by_merchant_id_authorization_id(
conn: &PgPooledConn,
merchant_id: common_utils::id_type::MerchantId,
authorization_id: String,
authorization_update: AuthorizationUpdate,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/authorization.rs | crate: diesel_models
use super::generics;
use crate::{
authorization::{
Authorization, AuthorizationNew, AuthorizationUpdate, AuthorizationUpdateInternal,
},
errors,
schema::incremental_authorization::dsl,
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<Authorization> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user_authentication_method.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use crate::{
query::generics, schema::user_authentication_methods::dsl, user_authentication_method::*,
PgPooledConn, StorageResult,
};
pub async fn list_user_authentication_methods_for_email_domain(
conn: &PgPooledConn,
email_domain: &str,
) -> StorageResult<Vec<Self>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user_authentication_method.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use crate::{
query::generics, schema::user_authentication_methods::dsl, user_authentication_method::*,
PgPooledConn, StorageResult,
};
pub async fn update_user_authentication_method(
conn: &PgPooledConn,
id: &str,
user_authentication_method_update: UserAuthenticationMethodUpdate,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user_authentication_method.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use crate::{
query::generics, schema::user_authentication_methods::dsl, user_authentication_method::*,
PgPooledConn, StorageResult,
};
pub async fn list_user_authentication_methods_for_owner_id(
conn: &PgPooledConn,
owner_id: &str,
) -> StorageResult<Vec<Self>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user_authentication_method.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use crate::{
query::generics, schema::user_authentication_methods::dsl, user_authentication_method::*,
PgPooledConn, StorageResult,
};
pub async fn list_user_authentication_methods_for_auth_id(
conn: &PgPooledConn,
auth_id: &str,
) -> StorageResult<Vec<Self>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user_authentication_method.rs | crate: diesel_models
use diesel::{associations::HasTable, ExpressionMethods};
use crate::{
query::generics, schema::user_authentication_methods::dsl, user_authentication_method::*,
PgPooledConn, StorageResult,
};
pub async fn get_user_authentication_method_by_id(
conn: &PgPooledConn,
id: &str,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user_authentication_method.rs | crate: diesel_models
use crate::{
query::generics, schema::user_authentication_methods::dsl, user_authentication_method::*,
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<UserAuthenticationMethod> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user/theme.rs | crate: diesel_models
use common_utils::types::theme::ThemeLineage;
use diesel::{
associations::HasTable,
debug_query,
pg::Pg,
result::Error as DieselError,
sql_types::{Bool, Nullable},
BoolExpressionMethods, ExpressionMethods, NullableExpressionMethods, QueryDsl,
};
use error_stack::{report, ResultExt};
use router_env::logger;
use crate::{
errors::DatabaseError,
query::generics::{
self,
db_metrics::{track_database_call, DatabaseOperation},
},
schema::themes::dsl,
user::theme::{Theme, ThemeNew},
PgPooledConn, StorageResult,
};
pub async fn find_most_specific_theme_in_lineage(
conn: &PgPooledConn,
lineage: ThemeLineage,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user/theme.rs | crate: diesel_models
use common_utils::types::theme::ThemeLineage;
use diesel::{
associations::HasTable,
debug_query,
pg::Pg,
result::Error as DieselError,
sql_types::{Bool, Nullable},
BoolExpressionMethods, ExpressionMethods, NullableExpressionMethods, QueryDsl,
};
use crate::{
errors::DatabaseError,
query::generics::{
self,
db_metrics::{track_database_call, DatabaseOperation},
},
schema::themes::dsl,
user::theme::{Theme, ThemeNew},
PgPooledConn, StorageResult,
};
fn lineage_filter(
lineage: ThemeLineage,
) -> Box<
dyn diesel::BoxableExpression<<Self as HasTable>::Table, Pg, SqlType = Nullable<Bool>>
+ 'static,
> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user/theme.rs | crate: diesel_models
use common_utils::types::theme::ThemeLineage;
use diesel::{
associations::HasTable,
debug_query,
pg::Pg,
result::Error as DieselError,
sql_types::{Bool, Nullable},
BoolExpressionMethods, ExpressionMethods, NullableExpressionMethods, QueryDsl,
};
use crate::{
errors::DatabaseError,
query::generics::{
self,
db_metrics::{track_database_call, DatabaseOperation},
},
schema::themes::dsl,
user::theme::{Theme, ThemeNew},
PgPooledConn, StorageResult,
};
pub async fn delete_by_theme_id_and_lineage(
conn: &PgPooledConn,
theme_id: String,
lineage: ThemeLineage,
) -> StorageResult<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user/theme.rs | crate: diesel_models
use common_utils::types::theme::ThemeLineage;
use diesel::{
associations::HasTable,
debug_query,
pg::Pg,
result::Error as DieselError,
sql_types::{Bool, Nullable},
BoolExpressionMethods, ExpressionMethods, NullableExpressionMethods, QueryDsl,
};
use crate::{
errors::DatabaseError,
query::generics::{
self,
db_metrics::{track_database_call, DatabaseOperation},
},
schema::themes::dsl,
user::theme::{Theme, ThemeNew},
PgPooledConn, StorageResult,
};
pub async fn find_by_lineage(
conn: &PgPooledConn,
lineage: ThemeLineage,
) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user/theme.rs | crate: diesel_models
use diesel::{
associations::HasTable,
debug_query,
pg::Pg,
result::Error as DieselError,
sql_types::{Bool, Nullable},
BoolExpressionMethods, ExpressionMethods, NullableExpressionMethods, QueryDsl,
};
use crate::{
errors::DatabaseError,
query::generics::{
self,
db_metrics::{track_database_call, DatabaseOperation},
},
schema::themes::dsl,
user::theme::{Theme, ThemeNew},
PgPooledConn, StorageResult,
};
pub async fn find_by_theme_id(conn: &PgPooledConn, theme_id: String) -> StorageResult<Self> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/diesel_models/src/query/user/theme.rs | crate: diesel_models
use crate::{
errors::DatabaseError,
query::generics::{
self,
db_metrics::{track_database_call, DatabaseOperation},
},
schema::themes::dsl,
user::theme::{Theme, ThemeNew},
PgPooledConn, StorageResult,
};
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<Theme> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/scheduler/src/errors.rs | crate: scheduler
use crate::env::logger::{self, error};
fn from(error: error_stack::Report<T>) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/scheduler/src/errors.rs | crate: scheduler
use crate::env::logger::{self, error};
fn to_pt_error(&self) -> ProcessTrackerError {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/scheduler/src/settings.rs | crate: scheduler
use common_utils::ext_traits::ConfigExt;
use storage_impl::errors::ApplicationError;
pub use crate::configs::settings::SchedulerSettings;
pub fn validate(&self) -> Result<(), ApplicationError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/scheduler/src/consumer.rs | crate: scheduler
use common_utils::{errors::CustomResult, id_type, signals::get_allowed_signals};
use diesel_models::enums;
pub use diesel_models::{self, process_tracker as storage};
use redis_interface::{RedisConnectionPool, RedisEntryId};
pub use super::workflows::ProcessTrackerWorkflow;
use crate::{
configs::settings::SchedulerSettings, db::process_tracker::ProcessTrackerInterface, errors,
metrics, utils as pt_utils, SchedulerAppState, SchedulerInterface, SchedulerSessionState,
};
pub async fn fetch_consumer_tasks(
db: &dyn ProcessTrackerInterface,
redis_conn: &RedisConnectionPool,
stream_name: &str,
group_name: &str,
consumer_name: &str,
) -> CustomResult<Vec<storage::ProcessTracker>, errors::ProcessTrackerError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/scheduler/src/consumer.rs | crate: scheduler
use std::{
sync::{self, atomic},
time as std_time,
};
use common_utils::{errors::CustomResult, id_type, signals::get_allowed_signals};
pub use diesel_models::{self, process_tracker as storage};
use futures::future;
use redis_interface::{RedisConnectionPool, RedisEntryId};
use tokio::sync::mpsc;
use uuid::Uuid;
use super::env::logger;
pub use super::workflows::ProcessTrackerWorkflow;
use crate::{
configs::settings::SchedulerSettings, db::process_tracker::ProcessTrackerInterface, errors,
metrics, utils as pt_utils, SchedulerAppState, SchedulerInterface, SchedulerSessionState,
};
pub async fn consumer_operations<T: SchedulerSessionState + 'static>(
state: &T,
settings: &SchedulerSettings,
workflow_selector: impl workflows::ProcessTrackerWorkflows<T> + 'static + Copy + std::fmt::Debug,
) -> CustomResult<(), errors::ProcessTrackerError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/scheduler/src/consumer.rs | crate: scheduler
use common_utils::{errors::CustomResult, id_type, signals::get_allowed_signals};
pub use diesel_models::{self, process_tracker as storage};
pub use super::workflows::ProcessTrackerWorkflow;
use crate::{
configs::settings::SchedulerSettings, db::process_tracker::ProcessTrackerInterface, errors,
metrics, utils as pt_utils, SchedulerAppState, SchedulerInterface, SchedulerSessionState,
};
pub async fn create_task(
db: &dyn ProcessTrackerInterface,
process_tracker_entry: storage::ProcessTrackerNew,
) -> CustomResult<(), storage_impl::errors::StorageError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/scheduler/src/consumer.rs | crate: scheduler
use common_utils::{errors::CustomResult, id_type, signals::get_allowed_signals};
use diesel_models::enums;
pub use diesel_models::{self, process_tracker as storage};
use super::env::logger;
pub use super::workflows::ProcessTrackerWorkflow;
use crate::{
configs::settings::SchedulerSettings, db::process_tracker::ProcessTrackerInterface, errors,
metrics, utils as pt_utils, SchedulerAppState, SchedulerInterface, SchedulerSessionState,
};
pub async fn consumer_error_handler(
state: &(dyn SchedulerInterface + 'static),
process: storage::ProcessTracker,
error: errors::ProcessTrackerError,
) -> CustomResult<(), errors::ProcessTrackerError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/scheduler/src/consumer.rs | crate: scheduler
use std::{
sync::{self, atomic},
time as std_time,
};
use common_utils::{errors::CustomResult, id_type, signals::get_allowed_signals};
pub use diesel_models::{self, process_tracker as storage};
use router_env::{
instrument,
tracing::{self, Instrument},
};
use time::PrimitiveDateTime;
use uuid::Uuid;
use super::env::logger;
pub use super::workflows::ProcessTrackerWorkflow;
use crate::{
configs::settings::SchedulerSettings, db::process_tracker::ProcessTrackerInterface, errors,
metrics, utils as pt_utils, SchedulerAppState, SchedulerInterface, SchedulerSessionState,
};
pub async fn start_workflow<T>(
state: T,
process: storage::ProcessTracker,
_pickup_time: PrimitiveDateTime,
workflow_selector: impl workflows::ProcessTrackerWorkflows<T> + 'static + std::fmt::Debug,
) -> CustomResult<(), errors::ProcessTrackerError>
where
T: SchedulerSessionState,
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/scheduler/src/consumer.rs | crate: scheduler
pub use diesel_models::{self, process_tracker as storage};
pub use super::workflows::ProcessTrackerWorkflow;
pub fn valid_business_statuses() -> Vec<&'static str> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/scheduler/src/consumer.rs | crate: scheduler
use std::{
sync::{self, atomic},
time as std_time,
};
use common_utils::{errors::CustomResult, id_type, signals::get_allowed_signals};
use diesel_models::enums;
pub use diesel_models::{self, process_tracker as storage};
use error_stack::ResultExt;
use futures::future;
use redis_interface::{RedisConnectionPool, RedisEntryId};
use router_env::{
instrument,
tracing::{self, Instrument},
};
use time::PrimitiveDateTime;
use tokio::sync::mpsc;
use uuid::Uuid;
use super::env::logger;
pub use super::workflows::ProcessTrackerWorkflow;
use crate::{
configs::settings::SchedulerSettings, db::process_tracker::ProcessTrackerInterface, errors,
metrics, utils as pt_utils, SchedulerAppState, SchedulerInterface, SchedulerSessionState,
};
pub async fn start_consumer<T: SchedulerAppState + 'static, U: SchedulerSessionState + 'static, F>(
state: &T,
settings: sync::Arc<SchedulerSettings>,
workflow_selector: impl workflows::ProcessTrackerWorkflows<U> + 'static + Copy + std::fmt::Debug,
(tx, mut rx): (mpsc::Sender<()>, mpsc::Receiver<()>),
app_state_to_session_state: F,
) -> CustomResult<(), errors::ProcessTrackerError>
where
F: Fn(&T, &id_type::TenantId) -> CustomResult<U, errors::ProcessTrackerError>,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/scheduler/src/configs/validations.rs | crate: scheduler
use common_utils::ext_traits::ConfigExt;
use storage_impl::errors::ApplicationError;
pub fn validate(&self) -> Result<(), ApplicationError> {
common_utils::fp_utils::when(self.lock_key.is_default_or_empty(), || {
Err(ApplicationError::InvalidConfigurationValueError(
"producer lock key must not be empty".into(),
))
})
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/scheduler/src/consumer/types/batch.rs | crate: scheduler
use std::collections::HashMap;
use common_utils::{errors::CustomResult, ext_traits::OptionExt};
use diesel_models::process_tracker::ProcessTracker;
use time::PrimitiveDateTime;
use crate::errors;
pub fn from_redis_stream_entry(
entry: HashMap<String, Option<String>>,
) -> CustomResult<Self, errors::ProcessTrackerError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/scheduler/src/consumer/types/batch.rs | crate: scheduler
use common_utils::{errors::CustomResult, ext_traits::OptionExt};
use crate::errors;
pub fn to_redis_field_value_pairs(
&self,
) -> CustomResult<Vec<(&str, String)>, errors::ProcessTrackerError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/types.rs | crate: drainer
use std::collections::HashMap;
use common_utils::errors;
use serde::{de::value::MapDeserializer, Deserialize, Serialize};
pub fn from_hashmap(
hashmap: HashMap<String, String>,
) -> errors::CustomResult<Self, errors::ParsingError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/lib.rs | crate: drainer
use std::{collections::HashMap, sync::Arc};
use common_utils::{id_type, signals::get_allowed_signals};
use tokio::sync::mpsc;
pub(crate) type Settings = settings::Settings<RawSecret>;
use crate::{
connection::pg_connection, services::Store, settings::DrainerSettings, types::StreamData,
};
pub async fn start_drainer(
stores: HashMap<id_type::TenantId, Arc<Store>>,
conf: DrainerSettings,
) -> errors::DrainerResult<()> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/lib.rs | crate: drainer
use std::{collections::HashMap, sync::Arc};
use actix_web::dev::Server;
use common_utils::{id_type, signals::get_allowed_signals};
pub(crate) type Settings = settings::Settings<RawSecret>;
use crate::{
connection::pg_connection, services::Store, settings::DrainerSettings, types::StreamData,
};
pub async fn start_web_server(
conf: Settings,
stores: HashMap<id_type::TenantId, Arc<Store>>,
) -> Result<Server, errors::DrainerError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/services.rs | crate: drainer
use actix_web::{body, HttpResponse, ResponseError};
pub fn http_response_json<T: body::MessageBody + 'static>(response: T) -> HttpResponse {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/services.rs | crate: drainer
use actix_web::{body, HttpResponse, ResponseError};
use error_stack::Report;
use crate::{
connection::{diesel_make_pg_pool, PgPool},
logger,
settings::Tenant,
};
pub fn log_and_return_error_response<T>(error: Report<T>) -> HttpResponse
where
T: error_stack::Context + ResponseError + Clone,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/services.rs | crate: drainer
use std::sync::Arc;
use redis_interface::RedisConnectionPool;
use crate::{
connection::{diesel_make_pg_pool, PgPool},
logger,
settings::Tenant,
};
/// # Panics
///
/// Panics if there is a failure while obtaining the HashiCorp client using the provided configuration.
/// This panic indicates a critical failure in setting up external services, and the application cannot proceed without a valid HashiCorp client.
pub async fn new(config: &crate::Settings, test_transaction: bool, tenant: &Tenant) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/errors.rs | crate: drainer
use redis_interface as redis;
use thiserror::Error;
fn status_code(&self) -> reqwest::StatusCode {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/errors.rs | crate: drainer
use redis_interface as redis;
pub type DrainerResult<T> = error_stack::Result<T, DrainerError>;
fn from(err: error_stack::Report<redis::errors::RedisError>) -> Self {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/errors.rs | crate: drainer
fn from(err: config::ConfigError) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/secrets_transformers.rs | crate: drainer
use hyperswitch_interfaces::secrets_interface::{
secret_handler::SecretsHandler,
secret_state::{RawSecret, SecretStateContainer, SecuredSecret},
SecretManagementInterface, SecretsManagementError,
};
use crate::settings::{Database, Settings};
/// # Panics
///
/// Will panic even if fetching raw secret fails for at least one config value
pub async fn fetch_raw_secrets(
conf: Settings<SecuredSecret>,
secret_management_client: &dyn SecretManagementInterface,
) -> Settings<RawSecret> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/secrets_transformers.rs | crate: drainer
use common_utils::errors::CustomResult;
use hyperswitch_interfaces::secrets_interface::{
secret_handler::SecretsHandler,
secret_state::{RawSecret, SecretStateContainer, SecuredSecret},
SecretManagementInterface, SecretsManagementError,
};
async fn convert_to_raw_secret(
value: SecretStateContainer<Self, SecuredSecret>,
secret_management_client: &dyn SecretManagementInterface,
) -> CustomResult<SecretStateContainer<Self, RawSecret>, SecretsManagementError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/settings.rs | crate: drainer
use external_services::managers::{
encryption_management::EncryptionManagementConfig, secrets_management::SecretsManagementConfig,
};
use redis_interface as redis;
pub use router_env::config::{Log, LogConsole, LogFile, LogTelemetry};
use router_env::{env, logger};
use crate::{errors, secrets_transformers};
pub fn validate(&self) -> Result<(), errors::DrainerError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/settings.rs | crate: drainer
use std::{collections::HashMap, path::PathBuf, sync::Arc};
use config::{Environment, File};
use redis_interface as redis;
pub use router_env::config::{Log, LogConsole, LogFile, LogTelemetry};
use router_env::{env, logger};
use crate::{errors, secrets_transformers};
pub fn with_config_path(config_path: Option<PathBuf>) -> Result<Self, errors::DrainerError> {
{// Configuration values are picked up in the following priority order (1 being least<|fim_suffix|>
<|fim_middle|>
serde_path_to_error::deserialize(config).map_err(|error| {
logger::error!(%error, "Unable to deserialize application configuration");
eprintln!("Unable to deserialize application configuration: {error}");
errors::DrainerError::from(error.into_inner())
})}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/settings.rs | crate: drainer
pub use router_env::config::{Log, LogConsole, LogFile, LogTelemetry};
use crate::{errors, secrets_transformers};
pub fn new() -> Result<Self, errors::DrainerError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/settings.rs | crate: drainer
use common_utils::{ext_traits::ConfigExt, id_type, DbConnectionParams};
use crate::{errors, secrets_transformers};
fn validate(&self) -> Result<(), errors::DrainerError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/settings.rs | crate: drainer
use common_utils::{ext_traits::ConfigExt, id_type, DbConnectionParams};
pub use router_env::config::{Log, LogConsole, LogFile, LogTelemetry};
pub fn get_tenant(&self, tenant_id: &id_type::TenantId) -> Option<&Tenant> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/settings.rs | crate: drainer
use common_utils::{ext_traits::ConfigExt, id_type, DbConnectionParams};
pub use router_env::config::{Log, LogConsole, LogFile, LogTelemetry};
pub fn get_tenant_ids(&self) -> Vec<id_type::TenantId> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/settings.rs | crate: drainer
fn get_port(&self) -> u16 {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/drainer/src/settings.rs | crate: drainer
fn get_host(&self) -> &str {
&self.host
} | ast_fragments |
// file: hyperswitch/crates/drainer/src/settings.rs | crate: drainer
fn get_username(&self) -> &str {
&self.username
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/settings.rs | crate: drainer
use std::{collections::HashMap, path::PathBuf, sync::Arc};
use external_services::managers::{
encryption_management::EncryptionManagementConfig, secrets_management::SecretsManagementConfig,
};
use hyperswitch_interfaces::{
encryption_interface::EncryptionManagementInterface,
secrets_interface::secret_state::{
RawSecret, SecretState, SecretStateContainer, SecuredSecret,
},
};
pub use router_env::config::{Log, LogConsole, LogFile, LogTelemetry};
use crate::{errors, secrets_transformers};
/// # Panics
///
/// Panics if secret or encryption management client cannot be initiated
pub async fn new(conf: Settings<SecuredSecret>) -> Self {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/connection.rs | crate: drainer
use bb8::PooledConnection;
use diesel::PgConnection;
pub type PgPool = bb8::Pool<async_bb8_diesel::ConnectionManager<PgConnection>>;
pub async fn pg_connection(
pool: &PgPool,
) -> PooledConnection<'_, async_bb8_diesel::ConnectionManager<PgConnection>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/connection.rs | crate: drainer
use bb8::PooledConnection;
use diesel::PgConnection;
use crate::{settings::Database, Settings};
pub type PgPool = bb8::Pool<async_bb8_diesel::ConnectionManager<PgConnection>>;
pub async fn diesel_make_pg_pool(
database: &Database,
_test_transaction: bool,
schema: &str,
) -> PgPool {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/drainer/src/connection.rs | crate: drainer
use crate::{settings::Database, Settings};
pub type PgPool = bb8::Pool<async_bb8_diesel::ConnectionManager<PgConnection>>;
pub async fn redis_connection(conf: &Settings) -> redis_interface::RedisConnectionPool {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router_derive/src/macros.rs | crate: router_derive
use proc_macro2::TokenStream;
use quote::quote;
use syn::DeriveInput;
pub(crate) use self::{
api_error::api_error_derive_inner,
diesel::{diesel_enum_derive_inner, diesel_enum_text_derive_inner},
generate_permissions::generate_permissions_inner,
generate_schema::polymorphic_macro_derive_inner,
to_encryptable::derive_to_encryption,
};
pub(crate) fn debug_as_display_inner(ast: &DeriveInput) -> syn::Result<TokenStream> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router_derive/src/macros/try_get_enum.rs | crate: router_derive
use proc_macro2::Span;
use quote::ToTokens;
use syn::{parse::Parse, punctuated::Punctuated};
/// Try and get the variants for an enum
pub fn try_get_enum_variant(
input: syn::DeriveInput,
) -> Result<proc_macro2::TokenStream, syn::Error> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router_derive/src/macros/try_get_enum.rs | crate: router_derive
use proc_macro2::Span;
use syn::{parse::Parse, punctuated::Punctuated};
/// Get Field from an enum variant
fn get_enum_variant_field(
variant: &syn::Variant,
) -> syn::Result<Punctuated<syn::Field, syn::token::Comma>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router_derive/src/macros/try_get_enum.rs | crate: router_derive
use syn::{parse::Parse, punctuated::Punctuated};
/// Get variants from Enum
fn get_enum_variants(data: &syn::Data) -> syn::Result<Punctuated<syn::Variant, syn::token::Comma>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router_derive/src/macros/try_get_enum.rs | crate: router_derive
use proc_macro2::Span;
fn to_tokens(&self, _: &mut proc_macro2::TokenStream) {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router_derive/src/macros/try_get_enum.rs | crate: router_derive
use syn::{parse::Parse, punctuated::Punctuated};
fn get_metadata(&self) -> syn::Result<Vec<TryGetEnumMeta>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router_derive/src/macros/generate_schema.rs | crate: router_derive
use syn::{self, parse::Parse, parse_quote, punctuated::Punctuated, Token};
/// Get the inner type of option
fn get_inner_option_type(field: &syn::Type) -> syn::Result<syn::Ident> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router_derive/src/macros/generate_schema.rs | crate: router_derive
use syn::{self, parse::Parse, parse_quote, punctuated::Punctuated, Token};
/// Get the type of field
fn get_field_type(field_type: syn::Type) -> syn::Result<syn::Ident> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router_derive/src/macros/generate_schema.rs | crate: router_derive
use syn::{self, parse::Parse, parse_quote, punctuated::Punctuated, Token};
/// Parse schemas from attribute
/// Example
///
/// #[mandatory_in(PaymentsCreateRequest, PaymentsUpdateRequest)]
/// would return
///
/// [PaymentsCreateRequest, PaymentsUpdateRequest]
fn get_inner_path_ident(attribute: &syn::Attribute) -> syn::Result<Vec<syn::Ident>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router_derive/src/macros/generate_schema.rs | crate: router_derive
use std::collections::{HashMap, HashSet};
use indexmap::IndexMap;
use syn::{self, parse::Parse, parse_quote, punctuated::Punctuated, Token};
use crate::macros::helpers;
pub fn polymorphic_macro_derive_inner(
input: syn::DeriveInput,
) -> syn::Result<proc_macro2::TokenStream> {
{let schemas_to_create =
helpers::get_metadata_inner::<syn::Ident>("generate_schemas", &input.attrs)?;<|fim_suffix|>
<|fim_middle|>
Ok(quote::quote! {
#(#schemas)*
})}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router_derive/src/macros/generate_permissions.rs | crate: router_derive
use proc_macro::TokenStream;
use quote::{format_ident, quote};
use syn::{
braced, bracketed,
parse::{Parse, ParseBuffer, ParseStream},
parse_macro_input,
punctuated::Punctuated,
token::Comma,
Ident, Token,
};
pub fn generate_permissions_inner(input: TokenStream) -> TokenStream {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router_derive/src/macros/generate_permissions.rs | crate: router_derive
use syn::{
braced, bracketed,
parse::{Parse, ParseBuffer, ParseStream},
parse_macro_input,
punctuated::Punctuated,
token::Comma,
Ident, Token,
};
fn parse_label_with_punctuated_data<T: Parse>(
input: &ParseBuffer<'_>,
) -> syn::Result<(Ident, Punctuated<T, Token![,]>)> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router_derive/src/macros/generate_permissions.rs | crate: router_derive
use syn::{
braced, bracketed,
parse::{Parse, ParseBuffer, ParseStream},
parse_macro_input,
punctuated::Punctuated,
token::Comma,
Ident, Token,
};
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hsdev/src/input_file.rs | crate: hsdev
use std::string::String;
pub fn postgres_url(&self) -> String {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/hsdev/src/input_file.rs | crate: hsdev
use toml::Value;
pub fn read(db_table: &Value) -> Result<Self, toml::de::Error> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/euclid/src/dssa/analyzer.rs | crate: euclid
use crate::{
dssa::{
graph::CgraphExt,
state_machine, truth,
types::{self, EuclidAnalysable},
},
frontend::{
ast,
dir::{self, EuclidDirFilter},
vir,
},
types::{DataType, Metadata},
};
fn test_negation_graph_analysis() {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/euclid/src/dssa/analyzer.rs | crate: euclid
use crate::{
dssa::{
graph::CgraphExt,
state_machine, truth,
types::{self, EuclidAnalysable},
},
frontend::{
ast,
dir::{self, EuclidDirFilter},
vir,
},
types::{DataType, Metadata},
};
fn test_negated_assertions_detection() {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/euclid/src/dssa/analyzer.rs | crate: euclid
use crate::{
dssa::{
graph::CgraphExt,
state_machine, truth,
types::{self, EuclidAnalysable},
},
frontend::{
ast,
dir::{self, EuclidDirFilter},
vir,
},
types::{DataType, Metadata},
};
fn test_conflicting_assertion_detection() {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/euclid/src/dssa/analyzer.rs | crate: euclid
use rustc_hash::{FxHashMap, FxHashSet};
use crate::{
dssa::{
graph::CgraphExt,
state_machine, truth,
types::{self, EuclidAnalysable},
},
frontend::{
ast,
dir::{self, EuclidDirFilter},
vir,
},
types::{DataType, Metadata},
};
fn perform_condition_analyses(
context: &types::ConjunctiveContext<'_>,
) -> Result<(), types::AnalysisError> {
let mut assertion_metadata: FxHashMap<&dir::DirValue, &Metadata> = FxHashMap::default();
let mut keywise_assertions: FxHashMap<dir::DirKey, FxHashSet<&dir::DirValue>> =
FxHashMap::default();
let mut negation_metadata: FxHashMap<&dir::DirValue, &Metadata> = FxHashMap::default();
let mut keywise_negation_metadata: FxHashMap<dir::DirKey, Vec<&Metadata>> =
FxHashMap::default();
let mut keywise_negations: FxHashMap<dir::DirKey, FxHashSet<&dir::DirValue>> =
FxHashMap::default();
for ctx_val in context {
let key = if let Some(k) = ctx_val.value.get_key() {
k
} else {
continue;
};
if let dir::DirKeyKind::Connector = key.kind {
continue;
}
if !matches!(key.kind.get_type(), DataType::EnumVariant) {
continue;
}
match ctx_val.value {
types::CtxValueKind::Assertion(val) => {
keywise_assertions
.entry(key.clone())
.or_default()
.insert(val);
assertion_metadata.insert(val, ctx_val.metadata);
}
types::CtxValueKind::Negation(vals) => {
let negation_set = keywise_negations.entry(key.clone()).or_default();
for val in vals {
negation_set.insert(val);
negation_metadata.insert(val, ctx_val.metadata);
}
keywise_negation_metadata
.entry(key.clone())
.or_default()
.push(ctx_val.metadata);
}
}
}
analyze_conflicting_assertions(&keywise_assertions, &assertion_metadata)?;
analyze_exhaustive_negations(&keywise_negations, &keywise_negation_metadata)?;
analyze_negated_assertions(
&keywise_assertions,
&assertion_metadata,
&keywise_negations,
&negation_metadata,
)?;
Ok(())
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/euclid/src/dssa/analyzer.rs | crate: euclid
use rustc_hash::{FxHashMap, FxHashSet};
use crate::{
dssa::{
graph::CgraphExt,
state_machine, truth,
types::{self, EuclidAnalysable},
},
frontend::{
ast,
dir::{self, EuclidDirFilter},
vir,
},
types::{DataType, Metadata},
};
fn analyze_negated_assertions(
keywise_assertions: &FxHashMap<dir::DirKey, FxHashSet<&dir::DirValue>>,
assertion_metadata: &FxHashMap<&dir::DirValue, &Metadata>,
keywise_negations: &FxHashMap<dir::DirKey, FxHashSet<&dir::DirValue>>,
negation_metadata: &FxHashMap<&dir::DirValue, &Metadata>,
) -> Result<(), types::AnalysisError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/euclid/src/dssa/analyzer.rs | crate: euclid
use rustc_hash::{FxHashMap, FxHashSet};
use crate::{
dssa::{
graph::CgraphExt,
state_machine, truth,
types::{self, EuclidAnalysable},
},
frontend::{
ast,
dir::{self, EuclidDirFilter},
vir,
},
types::{DataType, Metadata},
};
/// Analyses exhaustive negations on the same key in a conjunctive context.
///
/// For example,
/// ```notrust
/// authentication_type /= three_ds && ... && authentication_type /= no_three_ds
/// ```notrust
/// This is a condition that will never evaluate to `true` given any authentication_type
/// since all the possible values authentication_type can take have been negated.
pub fn analyze_exhaustive_negations(
keywise_negations: &FxHashMap<dir::DirKey, FxHashSet<&dir::DirValue>>,
keywise_negation_metadata: &FxHashMap<dir::DirKey, Vec<&Metadata>>,
) -> Result<(), types::AnalysisError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/euclid/src/dssa/analyzer.rs | crate: euclid
use rustc_hash::{FxHashMap, FxHashSet};
use crate::{
dssa::{
graph::CgraphExt,
state_machine, truth,
types::{self, EuclidAnalysable},
},
frontend::{
ast,
dir::{self, EuclidDirFilter},
vir,
},
types::{DataType, Metadata},
};
/// Analyses conflicting assertions on the same key in a conjunctive context.
///
/// For example,
/// ```notrust
/// payment_method = card && ... && payment_method = bank_debit
/// ```notrust
/// This is a condition that will never evaluate to `true` given a single
/// payment method and needs to be caught in analysis.
pub fn analyze_conflicting_assertions(
keywise_assertions: &FxHashMap<dir::DirKey, FxHashSet<&dir::DirValue>>,
assertion_metadata: &FxHashMap<&dir::DirValue, &Metadata>,
) -> Result<(), types::AnalysisError> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/euclid/src/dssa/analyzer.rs | crate: euclid
use hyperswitch_constraint_graph::{ConstraintGraph, Memoization};
use crate::{
dssa::{
graph::CgraphExt,
state_machine, truth,
types::{self, EuclidAnalysable},
},
frontend::{
ast,
dir::{self, EuclidDirFilter},
vir,
},
types::{DataType, Metadata},
};
pub fn analyze<O: EuclidAnalysable + EuclidDirFilter>(
program: ast::Program<O>,
knowledge_graph: Option<&ConstraintGraph<dir::DirValue>>,
) -> Result<vir::ValuedProgram<O>, types::AnalysisError> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.