v0.3.15-pre.006
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// file: crates/ksp-app-raw-transaction-ingest-desk/src/dto_route.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
//! Safe route-identity and lifecycle-state foundation for Raw Transaction Ingest Desk.
|
||||
//! Safe route-identity, Config-composability and lifecycle DTOs for Raw Transaction Ingest Desk.
|
||||
|
||||
use ts_rs::TS; // rust-rules: trait-import
|
||||
|
||||
@@ -28,6 +28,72 @@ impl crate::RawIngestRouteId {
|
||||
pub(crate) fn all() -> std::vec::Vec<Self> {
|
||||
return vec![Self::YellowstoneHydrated, Self::StandardLogsHydrated, Self::StandardBlockDirect, Self::HeliusTransactionHydrated, Self::HttpBlockPolling];
|
||||
}
|
||||
|
||||
/// Returns the application-owned route family used by safe UI projections.
|
||||
#[must_use]
|
||||
pub(crate) const fn family(self) -> crate::RawIngestRouteFamily {
|
||||
return match self {
|
||||
Self::YellowstoneHydrated => crate::RawIngestRouteFamily::Yellowstone,
|
||||
Self::StandardLogsHydrated => crate::RawIngestRouteFamily::StandardLogs,
|
||||
Self::StandardBlockDirect => crate::RawIngestRouteFamily::StandardBlock,
|
||||
Self::HeliusTransactionHydrated => crate::RawIngestRouteFamily::HeliusTransaction,
|
||||
Self::HttpBlockPolling => crate::RawIngestRouteFamily::HttpBlockPolling,
|
||||
};
|
||||
}
|
||||
|
||||
/// Returns the stable operator-facing route label without exposing physical endpoint metadata.
|
||||
#[must_use]
|
||||
pub(crate) const fn label(self) -> &'static str {
|
||||
return match self {
|
||||
Self::YellowstoneHydrated => "Yellowstone + HTTP hydration",
|
||||
Self::StandardLogsHydrated => "Standard Logs + HTTP hydration",
|
||||
Self::StandardBlockDirect => "Standard Block direct",
|
||||
Self::HeliusTransactionHydrated => "Helius Transaction + HTTP hydration",
|
||||
Self::HttpBlockPolling => "HTTP Block Polling",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// Stable application-owned route families used only for safe presentation and orchestration.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, serde::Serialize, TS)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[ts(export, export_to = "../frontend/ts/bindings/ksp_app_raw_transaction_ingest_desk/dto_route/RawIngestRouteFamily.ts")]
|
||||
pub(crate) enum RawIngestRouteFamily {
|
||||
/// Yellowstone gRPC subscription route.
|
||||
Yellowstone,
|
||||
/// Standard Solana logs WebSocket route.
|
||||
StandardLogs,
|
||||
/// Standard Solana block WebSocket route.
|
||||
StandardBlock,
|
||||
/// Helius transaction WebSocket route.
|
||||
HeliusTransaction,
|
||||
/// HTTP block polling route.
|
||||
HttpBlockPolling,
|
||||
}
|
||||
|
||||
/// Safe reasons explaining why one logical route cannot currently be composed from Config.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, serde::Serialize, TS)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[ts(export, export_to = "../frontend/ts/bindings/ksp_app_raw_transaction_ingest_desk/dto_route/RawIngestRouteUnavailableReason.ts")]
|
||||
pub(crate) enum RawIngestRouteUnavailableReason {
|
||||
/// The selected composite or one of its typed Config components could not be resolved safely.
|
||||
ProfileUnresolved,
|
||||
/// Transport and Store do not prove one identical logical network.
|
||||
NetworkMismatch,
|
||||
/// No HTTP role can satisfy `getTransaction` for same-network hydration.
|
||||
MissingHttpGetTransaction,
|
||||
/// No HTTP role can satisfy the complete block-polling method set.
|
||||
MissingHttpBlockScan,
|
||||
/// No enabled standard WebSocket endpoint explicitly declares `Logs`.
|
||||
MissingWsLogsCapability,
|
||||
/// No enabled standard WebSocket endpoint explicitly declares `Block`.
|
||||
MissingWsBlockCapability,
|
||||
/// No enabled Helius WebSocket endpoint explicitly declares `HeliusTransaction`.
|
||||
MissingHeliusTransactionCapability,
|
||||
/// No enabled same-network Yellowstone gRPC endpoint is configured.
|
||||
MissingYellowstoneGrpc,
|
||||
/// A required Config secret is not resolved for the selected composite profile.
|
||||
MissingRequiredSecret,
|
||||
}
|
||||
|
||||
/// Stable Raw Transaction Ingest Desk route lifecycle states.
|
||||
@@ -59,25 +125,104 @@ impl crate::RawIngestRouteState {
|
||||
}
|
||||
}
|
||||
|
||||
/// Static route/state foundation exposed by the scaffold before Config route inventory exists.
|
||||
/// Static route/state foundation retained as the bounded vocabulary behind the live Config inventory.
|
||||
#[derive(Clone, Debug, serde::Serialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export, export_to = "../frontend/ts/bindings/ksp_app_raw_transaction_ingest_desk/dto_route/RawIngestRouteFoundationDto.ts")]
|
||||
pub(crate) struct RawIngestRouteFoundationDto {
|
||||
/// Five stable V1 logical route identifiers; this is not a composability claim.
|
||||
pub(crate) route_ids: std::vec::Vec<crate::RawIngestRouteId>,
|
||||
/// Stable lifecycle state vocabulary reserved for later runtime projections.
|
||||
/// Stable lifecycle state vocabulary reserved for runtime projections.
|
||||
pub(crate) states: std::vec::Vec<crate::RawIngestRouteState>,
|
||||
}
|
||||
|
||||
impl crate::RawIngestRouteFoundationDto {
|
||||
/// Builds the static scaffold contract without resolving endpoints, secrets or Worker resources.
|
||||
/// Builds the bounded route/state vocabulary without resolving endpoints, secrets or Worker resources.
|
||||
#[must_use]
|
||||
pub(crate) fn scaffold() -> Self {
|
||||
return Self { route_ids: crate::RawIngestRouteId::all(), states: crate::RawIngestRouteState::all() };
|
||||
}
|
||||
}
|
||||
|
||||
/// Safe Config-only composability projection for one logical route.
|
||||
#[derive(Clone, Debug, serde::Serialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export, export_to = "../frontend/ts/bindings/ksp_app_raw_transaction_ingest_desk/dto_route/RawIngestRouteDto.ts")]
|
||||
pub(crate) struct RawIngestRouteDto {
|
||||
/// Stable route family used for presentation and bounded orchestration.
|
||||
pub(crate) family: crate::RawIngestRouteFamily,
|
||||
/// Stable operator-facing label with no physical resource identity.
|
||||
pub(crate) label: String,
|
||||
/// Logical network proven by Config when available.
|
||||
pub(crate) network: std::option::Option<String>,
|
||||
/// Safe reason explaining an unavailable route.
|
||||
pub(crate) reason: std::option::Option<crate::RawIngestRouteUnavailableReason>,
|
||||
/// Stable logical V1 route identifier.
|
||||
pub(crate) route_id: crate::RawIngestRouteId,
|
||||
/// Whether all Config requirements for the route are currently composable.
|
||||
pub(crate) selectable: bool,
|
||||
/// Config-level lifecycle projection; `Configured` is not a runtime health claim.
|
||||
pub(crate) state: crate::RawIngestRouteState,
|
||||
}
|
||||
|
||||
impl crate::RawIngestRouteDto {
|
||||
/// Builds one route that is composable from Config without claiming runtime operability.
|
||||
#[must_use]
|
||||
pub(crate) fn configured(route_id: crate::RawIngestRouteId, network: &str) -> Self {
|
||||
return Self {
|
||||
family: route_id.family(),
|
||||
label: route_id.label().to_owned(),
|
||||
network: std::option::Option::Some(network.to_owned()),
|
||||
reason: std::option::Option::None,
|
||||
route_id,
|
||||
selectable: true,
|
||||
state: crate::RawIngestRouteState::Configured,
|
||||
};
|
||||
}
|
||||
|
||||
/// Builds one route that is not composable from the current Config profile.
|
||||
#[must_use]
|
||||
pub(crate) fn unavailable(route_id: crate::RawIngestRouteId, network: std::option::Option<&str>, reason: crate::RawIngestRouteUnavailableReason) -> Self {
|
||||
return Self {
|
||||
family: route_id.family(),
|
||||
label: route_id.label().to_owned(),
|
||||
network: network.map(str::to_owned),
|
||||
reason: std::option::Option::Some(reason),
|
||||
route_id,
|
||||
selectable: false,
|
||||
state: crate::RawIngestRouteState::Unavailable,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// Safe route inventory for one logical Raw Transaction Ingest Desk composite profile.
|
||||
#[derive(Clone, Debug, serde::Serialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export, export_to = "../frontend/ts/bindings/ksp_app_raw_transaction_ingest_desk/dto_route/RawIngestProfileInventoryDto.ts")]
|
||||
pub(crate) struct RawIngestProfileInventoryDto {
|
||||
/// Whether this profile is the composite's autonomous default.
|
||||
pub(crate) is_default: bool,
|
||||
/// Logical network proven from the resolved Config profile when available.
|
||||
pub(crate) network: std::option::Option<String>,
|
||||
/// Stable composite profile identifier.
|
||||
pub(crate) profile_id: String,
|
||||
/// Five logical routes in stable V1 presentation order.
|
||||
pub(crate) routes: std::vec::Vec<crate::RawIngestRouteDto>,
|
||||
}
|
||||
|
||||
/// Deterministic Config-only route inventory returned to the frontend.
|
||||
#[derive(Clone, Debug, serde::Serialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export, export_to = "../frontend/ts/bindings/ksp_app_raw_transaction_ingest_desk/dto_route/RawIngestRouteInventoryDto.ts")]
|
||||
pub(crate) struct RawIngestRouteInventoryDto {
|
||||
/// Composite default profile identifier.
|
||||
pub(crate) default_profile: String,
|
||||
/// Monotonic application-owned generation incremented after each successful inventory rebuild.
|
||||
pub(crate) generation: u32,
|
||||
/// Safe inventories for every validated composite profile in source order.
|
||||
pub(crate) profiles: std::vec::Vec<crate::RawIngestProfileInventoryDto>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "../unit_tests/dto_route.rs"]
|
||||
mod tests;
|
||||
|
||||
Reference in New Issue
Block a user