// file: kb_lib/src/db.rs

//! Database facade.
//!
//! This module centralizes the database layer and exposes a storage API that is
//! intentionally structured to remain evolutive across backends.

mod connection;
mod dtos;
mod entities;
mod queries;
mod schema;
mod sqlite;
mod types;

pub use connection::Database;
pub use connection::DatabaseConnection;
pub use dtos::AnalysisSignalDto;
pub use dtos::ChainInstructionDto;
pub use dtos::ChainSlotDto;
pub use dtos::ChainTransactionDto;
pub use dtos::DbMetadataDto;
pub use dtos::DbRuntimeEventDto;
pub use dtos::DexDecodeReplayLedgerDto;
pub use dtos::DexDecodedEventDto;
pub use dtos::DexDto;
pub use dtos::DexEventCoverageEntryDto;
pub use dtos::DexEventCoverageSummaryDto;
pub use dtos::FeeEventAmountDto;
pub use dtos::FeeEventDto;
pub use dtos::InstructionObservationDto;
pub use dtos::InstructionObservationSourceRow;
pub use dtos::KnownHttpEndpointDto;
pub use dtos::KnownWsEndpointDto;
pub use dtos::LaunchAttributionDto;
pub use dtos::LaunchEventUpsertInput;
pub use dtos::LaunchSurfaceDto;
pub use dtos::LaunchSurfaceKeyDto;
pub use dtos::LiquidityEventDto;
pub use dtos::LocalDecodedEventDiagnosticSummaryDto;
pub use dtos::LocalDexCorpusDecodedEventSampleDto;
pub use dtos::LocalDexCorpusPoolPairSampleDto;
pub use dtos::LocalDexCorpusSearchRequestDto;
pub use dtos::LocalDexCorpusSearchResultDto;
pub use dtos::LocalDexCorpusSearchSummaryDto;
pub use dtos::LocalDexCorpusTransactionSampleDto;
pub use dtos::LocalDexDiagnosticSummaryDto;
pub use dtos::LocalDuplicateDecodedEventTradeDiagnosticSampleDto;
pub use dtos::LocalEventClassificationDiagnosticSummaryDto;
pub use dtos::LocalLaunchOriginDiagnosticSampleDto;
pub use dtos::LocalMissingTradeEventDiagnosticSampleDto;
pub use dtos::LocalMissingTradeEventReasonSummaryDto;
pub use dtos::LocalMultiTradeSignaturePairDiagnosticSampleDto;
pub use dtos::LocalNonActionablePairDiagnosticSummaryDto;
pub use dtos::LocalPairActionabilityDiagnosticSummaryDto;
pub use dtos::LocalPairDiagnosticSummaryDto;
pub use dtos::LocalPairGapDiagnosticSampleDto;
pub use dtos::LocalPairTradingReadinessDiagnosticSummaryDto;
pub use dtos::LocalPipelineDiagnosticCountersDto;
pub use dtos::LocalPipelineDiagnosticSummaryDto;
pub use dtos::LocalPoolOriginDiagnosticSampleDto;
pub use dtos::LocalRaydiumProgramInstructionDiagnosticSummaryDto;
pub use dtos::LocalRaydiumSurfaceDiagnosticSummaryDto;
pub use dtos::LocalTokenMetadataGapDiagnosticSampleDto;
pub use dtos::ObservedTokenDto;
pub use dtos::OnchainObservationDto;
pub use dtos::OrderbookEventDto;
pub use dtos::PairAnalyticSignalDto;
pub use dtos::PairCandleDto;
pub use dtos::PairDto;
pub use dtos::PairMetricDto;
pub use dtos::PoolAdminEventDto;
pub use dtos::PoolDto;
pub use dtos::PoolLifecycleEventDto;
pub use dtos::PoolListingDto;
pub use dtos::PoolOriginDto;
pub use dtos::PoolTokenDto;
pub use dtos::ProgramInstructionDiagnosticDto;
pub use dtos::ProgramInstructionDiscriminatorSummaryDto;
pub use dtos::ProtocolCandidateDto;
pub use dtos::ProtocolCandidateSummaryDto;
pub use dtos::RewardEventDto;
pub use dtos::SwapDto;
pub use dtos::TokenAccountEventDto;
pub use dtos::TokenBurnEventDto;
pub use dtos::TokenDto;
pub use dtos::TokenMintEventDto;
pub use dtos::TradeEventDto;
pub use dtos::TransactionClassificationDto;
pub use dtos::WalletDto;
pub use dtos::WalletHoldingDto;
pub use dtos::WalletParticipationDto;
pub use entities::AnalysisSignalEntity;
pub use entities::ChainInstructionEntity;
pub use entities::ChainSlotEntity;
pub use entities::ChainTransactionEntity;
pub use entities::DbMetadataEntity;
pub use entities::DbRuntimeEventEntity;
pub use entities::DexDecodeReplayLedgerEntity;
pub use entities::DexDecodedEventEntity;
pub use entities::DexEntity;
pub use entities::DexEventCoverageEntryEntity;
pub use entities::DexEventCoverageSummaryEntity;
pub use entities::FeeEventAmountEntity;
pub use entities::FeeEventEntity;
pub use entities::InstructionObservationEntity;
pub use entities::KnownHttpEndpointEntity;
pub use entities::KnownWsEndpointEntity;
pub use entities::LaunchAttributionEntity;
pub use entities::LaunchSurfaceEntity;
pub use entities::LaunchSurfaceKeyEntity;
pub use entities::LiquidityEventEntity;
pub use entities::ObservedTokenEntity;
pub use entities::OnchainObservationEntity;
pub use entities::OrderbookEventEntity;
pub use entities::PairAnalyticSignalEntity;
pub use entities::PairCandleEntity;
pub use entities::PairEntity;
pub use entities::PairMetricEntity;
pub use entities::PoolAdminEventEntity;
pub use entities::PoolEntity;
pub use entities::PoolLifecycleEventEntity;
pub use entities::PoolListingEntity;
pub use entities::PoolOriginEntity;
pub use entities::PoolTokenEntity;
pub use entities::ProgramInstructionDiagnosticEntity;
pub use entities::ProgramInstructionDiscriminatorRowEntity;
pub use entities::ProtocolCandidateEntity;
pub use entities::ProtocolCandidateSummaryEntity;
pub use entities::RewardEventEntity;
pub use entities::SwapEntity;
pub use entities::TokenAccountEventEntity;
pub use entities::TokenBurnEventEntity;
pub use entities::TokenEntity;
pub use entities::TokenMintEventEntity;
pub use entities::TradeEventEntity;
pub use entities::TransactionClassificationEntity;
pub use entities::WalletEntity;
pub use entities::WalletHoldingEntity;
pub use entities::WalletParticipationEntity;
pub use queries::query_analysis_signals_insert;
pub use queries::query_analysis_signals_list;
pub use queries::query_chain_instructions_delete_by_transaction_id;
pub use queries::query_chain_instructions_get_by_id;
pub use queries::query_chain_instructions_insert;
pub use queries::query_chain_instructions_list_by_transaction_id;
pub use queries::query_chain_slots_get;
pub use queries::query_chain_slots_list_recent;
pub use queries::query_chain_slots_upsert;
pub use queries::query_chain_transactions_get_by_signature;
pub use queries::query_chain_transactions_list_recent;
pub use queries::query_chain_transactions_list_signatures_for_replay;
pub use queries::query_chain_transactions_upsert;
pub use queries::query_db_metadatas_get;
pub use queries::query_db_metadatas_list;
pub use queries::query_db_metadatas_upsert;
pub use queries::query_db_runtime_events_insert;
pub use queries::query_db_runtime_events_list_recent;
pub use queries::query_dex_decode_replay_ledger_get_by_signature;
pub use queries::query_dex_decode_replay_ledger_get_by_transaction;
pub use queries::query_dex_decode_replay_ledger_upsert;
pub use queries::query_dex_decoded_events_cleanup_raydium_launchpad_anchor_self_cpi_audits;
pub use queries::query_dex_decoded_events_delete_by_key;
pub use queries::query_dex_decoded_events_delete_instruction_audit_by_discriminator;
pub use queries::query_dex_decoded_events_delete_local_replay_scope_by_transaction_id;
pub use queries::query_dex_decoded_events_delete_locally_covered_upstream_instruction_matches;
pub use queries::query_dex_decoded_events_delete_meteora_dlmm_anchor_swap_instruction_audits;
pub use queries::query_dex_decoded_events_delete_raydium_clmm_instruction_audit_by_discriminator;
pub use queries::query_dex_decoded_events_delete_raydium_launchpad_anchor_self_cpi_audit;
pub use queries::query_dex_decoded_events_delete_related_instruction_audit;
pub use queries::query_dex_decoded_events_delete_replaced_raydium_clmm_instruction_audits;
pub use queries::query_dex_decoded_events_delete_replaced_raydium_cpmm_instruction_audits;
pub use queries::query_dex_decoded_events_get_by_key;
pub use queries::query_dex_decoded_events_get_latest_pump_fun_create_payload_by_mint;
pub use queries::query_dex_decoded_events_list_by_transaction_id;
pub use queries::query_dex_decoded_events_update_payload_json_by_id;
pub use queries::query_dex_decoded_events_upsert;
pub use queries::query_dex_event_coverage_entries_delete_by_decoder;
pub use queries::query_dex_event_coverage_entries_list_by_decoder;
pub use queries::query_dex_event_coverage_entries_list_summary_by_decoder;
pub use queries::query_dex_event_coverage_entries_refresh_local_counts;
pub use queries::query_dex_event_coverage_entries_refresh_local_counts_by_decoder;
pub use queries::query_dex_event_coverage_entries_upsert;
pub use queries::query_dexs_get_by_code;
pub use queries::query_dexs_list;
pub use queries::query_dexs_upsert;
pub use queries::query_fee_event_amounts_backfill_single_leg_from_fee_events;
pub use queries::query_fee_event_amounts_delete_by_fee_event_id;
pub use queries::query_fee_event_amounts_list_by_fee_event_id;
pub use queries::query_fee_event_amounts_replace_for_fee_event;
pub use queries::query_fee_events_upsert_with_amount_legs;
pub use queries::query_fee_events_get_by_decoded_event_id;
pub use queries::query_fee_events_list_recent;
pub use queries::query_fee_events_upsert;
pub use queries::query_instruction_observation_source_rows_list_by_signature;
pub use queries::query_instruction_observation_source_rows_list_recent;
pub use queries::query_instruction_observation_source_rows_list_replay_window;
pub use queries::query_instruction_observations_delete_by_transaction_ids;
pub use queries::query_instruction_observations_list_by_filter;
pub use queries::query_instruction_observations_upsert;
pub use queries::query_known_http_endpoints_get;
pub use queries::query_known_http_endpoints_list;
pub use queries::query_known_http_endpoints_upsert;
pub use queries::query_known_ws_endpoints_get;
pub use queries::query_known_ws_endpoints_list;
pub use queries::query_known_ws_endpoints_upsert;
pub use queries::query_launch_attributions_get_by_decoded_event_id;
pub use queries::query_launch_attributions_list_by_pool_id;
pub use queries::query_launch_attributions_upsert;
pub use queries::query_launch_events_upsert;
pub use queries::query_launch_surface_keys_get_by_match;
pub use queries::query_launch_surface_keys_list_by_surface_id;
pub use queries::query_launch_surface_keys_upsert;
pub use queries::query_launch_surfaces_get_by_code;
pub use queries::query_launch_surfaces_list;
pub use queries::query_launch_surfaces_upsert;
pub use queries::query_liquidity_events_list_recent;
pub use queries::query_liquidity_events_upsert;
pub use queries::query_local_decoded_event_diagnostic_list_summaries;
pub use queries::query_local_dex_corpus_search_get_summary;
pub use queries::query_local_dex_corpus_search_list_decoded_event_samples;
pub use queries::query_local_dex_corpus_search_list_pool_pair_samples;
pub use queries::query_local_dex_corpus_search_list_transaction_samples;
pub use queries::query_local_duplicate_decoded_event_trade_diagnostic_list_samples;
pub use queries::query_local_event_classification_diagnostic_list_summaries;
pub use queries::query_local_launch_origin_diagnostic_list_samples;
pub use queries::query_local_missing_trade_event_diagnostic_list_samples;
pub use queries::query_local_missing_trade_event_reason_list_summaries;
pub use queries::query_local_multi_trade_signature_pair_diagnostic_list_samples;
pub use queries::query_local_non_actionable_pair_diagnostic_list_summaries;
pub use queries::query_local_pair_actionability_diagnostic_list_summaries;
pub use queries::query_local_pair_diagnostic_list_summaries;
pub use queries::query_local_pair_trading_readiness_diagnostic_list_summaries;
pub use queries::query_local_pair_without_candle_diagnostic_list_samples;
pub use queries::query_local_pair_without_trade_diagnostic_list_samples;
pub use queries::query_local_pipeline_diagnostic_get_counters;
pub use queries::query_local_pipeline_diagnostic_list_summaries;
pub use queries::query_local_pool_origin_diagnostic_list_samples;
pub use queries::query_local_raydium_program_instruction_diagnostic_list_summaries;
pub use queries::query_local_token_metadata_gap_diagnostic_list_samples;
pub use queries::query_observed_tokens_get_by_mint;
pub use queries::query_observed_tokens_list;
pub use queries::query_observed_tokens_upsert;
pub use queries::query_onchain_observations_insert;
pub use queries::query_onchain_observations_list_recent;
pub use queries::query_orderbook_events_upsert;
pub use queries::query_pair_analytic_signals_get_by_key;
pub use queries::query_pair_analytic_signals_list_by_pair_id;
pub use queries::query_pair_analytic_signals_upsert;
pub use queries::query_pair_candles_get_by_key;
pub use queries::query_pair_candles_list_by_pair_and_timeframe;
pub use queries::query_pair_candles_upsert;
pub use queries::query_pair_metrics_get_by_pair_id;
pub use queries::query_pair_metrics_list;
pub use queries::query_pair_metrics_upsert;
pub use queries::query_pairs_get_by_pool_id;
pub use queries::query_pairs_list;
pub use queries::query_pairs_update_symbol;
pub use queries::query_pairs_upsert;
pub use queries::query_pool_admin_events_delete_by_decoded_event_id;
pub use queries::query_pool_admin_events_get_by_decoded_event_id;
pub use queries::query_pool_admin_events_list_recent;
pub use queries::query_pool_admin_events_upsert;
pub use queries::query_pool_lifecycle_events_get_by_decoded_event_id;
pub use queries::query_pool_lifecycle_events_list_recent;
pub use queries::query_pool_lifecycle_events_upsert;
pub use queries::query_pool_listings_get_by_pool_id;
pub use queries::query_pool_listings_list;
pub use queries::query_pool_listings_upsert;
pub use queries::query_pool_origins_get_by_pool_id;
pub use queries::query_pool_origins_list;
pub use queries::query_pool_origins_upsert;
pub use queries::query_pool_tokens_list_by_pool_id;
pub use queries::query_pool_tokens_upsert;
pub use queries::query_pools_get_by_address;
pub use queries::query_pools_list;
pub use queries::query_pools_upsert;
pub use queries::query_program_instruction_diagnostics_list_by_program_id;
pub use queries::query_program_instruction_discriminator_summaries_list_by_program_id;
pub use queries::query_protocol_candidate_summaries_list_by_priority;
pub use queries::query_protocol_candidates_delete_by_transaction_id;
pub use queries::query_protocol_candidates_insert;
pub use queries::query_protocol_candidates_list_by_program_id;
pub use queries::query_protocol_candidates_list_by_transaction_id;
pub use queries::query_protocol_candidates_list_recent;
pub use queries::query_reward_events_get_by_decoded_event_id;
pub use queries::query_reward_events_list_recent;
pub use queries::query_reward_events_upsert;
pub use queries::query_swaps_list_recent;
pub use queries::query_swaps_upsert;
pub use queries::query_token_account_events_upsert;
pub use queries::query_token_burn_events_list_recent;
pub use queries::query_token_burn_events_upsert;
pub use queries::query_token_mint_events_list_recent;
pub use queries::query_token_mint_events_upsert;
pub use queries::query_tokens_get_by_id;
pub use queries::query_tokens_get_by_mint;
pub use queries::query_tokens_list;
pub use queries::query_tokens_list_missing_metadata;
pub use queries::query_tokens_upsert;
pub use queries::query_trade_events_get_by_decoded_event_id;
pub use queries::query_trade_events_list_by_pair_id;
pub use queries::query_trade_events_list_by_transaction_id;
pub use queries::query_trade_events_upsert;
pub use queries::query_trade_market_materialization_delete_all;
pub use queries::query_transaction_classifications_get_by_signature;
pub use queries::query_transaction_classifications_get_by_transaction_id;
pub use queries::query_transaction_classifications_list_recent;
pub use queries::query_transaction_classifications_upsert;
pub use queries::query_wallet_holdings_get_by_wallet_and_token;
pub use queries::query_wallet_holdings_list_by_wallet_id;
pub use queries::query_wallet_holdings_upsert;
pub use queries::query_wallet_participations_get_by_unique_key;
pub use queries::query_wallet_participations_list_by_pool_id;
pub use queries::query_wallet_participations_list_by_wallet_id;
pub use queries::query_wallet_participations_upsert;
pub use queries::query_wallets_get_by_address;
pub use queries::query_wallets_list;
pub use queries::query_wallets_upsert;
pub use types::AnalysisSignalSeverity;
pub use types::DatabaseBackend;
pub use types::DbRuntimeEventLevel;
pub use types::LiquidityEventKind;
pub use types::ObservationSourceKind;
pub use types::ObservedTokenStatus;
pub use types::PoolKind;
pub use types::PoolStatus;
pub use types::PoolTokenRole;
pub use types::SwapTradeSide;
