v0.1.0-pre.060
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: kb-app-demo-desktop/src/demo_decode_replay.rs
|
||||
// version: 29
|
||||
// version: 30
|
||||
|
||||
//! Tauri commands and UI payloads for contextual instruction decode replay.
|
||||
|
||||
@@ -22,6 +22,20 @@ pub(crate) struct DemoDecodeReplayDecoderOption {
|
||||
pub(crate) program_ids: std::vec::Vec<std::string::String>,
|
||||
}
|
||||
|
||||
/// One known program suggested by the free-form Program ID field.
|
||||
#[derive(Clone, Debug, serde::Serialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(
|
||||
export,
|
||||
export_to = "../frontend/ts/bindings/kb_app_demo_desktop/demo_decode_replay/DemoDecodeReplayProgramOption.ts"
|
||||
)]
|
||||
pub(crate) struct DemoDecodeReplayProgramOption {
|
||||
/// Stable program code.
|
||||
pub(crate) code: std::string::String,
|
||||
/// Canonical program identifier.
|
||||
pub(crate) program_id: std::string::String,
|
||||
}
|
||||
|
||||
/// Initial options shown by the contextual decode replay demo.
|
||||
#[derive(Clone, Debug, serde::Serialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@@ -36,6 +50,8 @@ pub(crate) struct DemoDecodeReplayOptionsPayload {
|
||||
pub(crate) decoders: std::vec::Vec<crate::DemoDecodeReplayDecoderOption>,
|
||||
/// Stable names of materializers currently registered by the demo.
|
||||
pub(crate) materializer_names: std::vec::Vec<std::string::String>,
|
||||
/// Known programs offered as non-blocking autocomplete suggestions.
|
||||
pub(crate) programs: std::vec::Vec<crate::DemoDecodeReplayProgramOption>,
|
||||
/// Default bounded selection limit.
|
||||
pub(crate) default_limit: u32,
|
||||
/// Default maximum concurrent contextual inputs.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: kb-app-demo-desktop/src/demo_sql_replay_candidates.rs
|
||||
// version: 7
|
||||
// version: 8
|
||||
|
||||
//! Read-only SQL replay candidate browser commands.
|
||||
|
||||
@@ -266,18 +266,6 @@ pub(crate) fn validated_csv_file_name(
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) fn csv_export_directory_from_current_dir(
|
||||
current_dir: &std::path::Path,
|
||||
) -> std::path::PathBuf {
|
||||
let current_name = current_dir.file_name().and_then(std::ffi::OsStr::to_str);
|
||||
if let (std::option::Option::Some("kb_app_demo_desktop"), std::option::Option::Some(parent)) =
|
||||
(current_name, current_dir.parent())
|
||||
{
|
||||
return parent.join("data").join("exports_csv");
|
||||
}
|
||||
return current_dir.join("data").join("exports_csv");
|
||||
}
|
||||
|
||||
pub(crate) async fn available_csv_export_path(
|
||||
export_dir: &std::path::Path,
|
||||
file_name: &str,
|
||||
@@ -373,13 +361,6 @@ mod tests {
|
||||
assert!(result.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn csv_export_directory_uses_workspace_root_from_demo_crate() {
|
||||
let current_dir = std::path::Path::new("/tmp/khadhroony-bot2/kb_app_demo_desktop");
|
||||
let result = crate::csv_export_directory_from_current_dir(current_dir);
|
||||
assert_eq!(result, std::path::Path::new("/tmp/khadhroony-bot2/data/exports_csv"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn csv_file_name_accepts_split_entity_exports() {
|
||||
let mint_result = crate::validated_csv_file_name("replay_mints.csv");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: kb-app-demo-desktop/src/lib.rs
|
||||
// version: 10
|
||||
// version: 11
|
||||
|
||||
//! Tauri desktop demo application for `khadhroony-bot3`.
|
||||
|
||||
@@ -95,6 +95,8 @@ pub(crate) use self::demo_decode_replay::DemoDecodeReplayDecoderOption;
|
||||
pub(crate) use self::demo_decode_replay::DemoDecodeReplayObserver;
|
||||
/// Internal demo decode replay item.
|
||||
pub(crate) use self::demo_decode_replay::DemoDecodeReplayOptionsPayload;
|
||||
/// One known program suggested by the free-form Program ID field.
|
||||
pub(crate) use self::demo_decode_replay::DemoDecodeReplayProgramOption;
|
||||
/// Internal demo decode replay item.
|
||||
pub(crate) use self::demo_decode_replay::DemoDecodeReplayProgressPayload;
|
||||
/// Internal demo decode replay item.
|
||||
@@ -267,8 +269,6 @@ pub(crate) use self::demo_sql_replay_candidates::DemoSqlReplayTransactionRequest
|
||||
pub(crate) use self::demo_sql_replay_candidates::DemoSqlReplayTransactionRow;
|
||||
/// Resolves an available CSV path.
|
||||
pub(crate) use self::demo_sql_replay_candidates::available_csv_export_path;
|
||||
/// Resolves the CSV export directory.
|
||||
pub(crate) use self::demo_sql_replay_candidates::csv_export_directory_from_current_dir;
|
||||
/// Parses an entity-kind code.
|
||||
pub(crate) use self::demo_sql_replay_candidates::entity_kind_from_code;
|
||||
/// Converts a PostgreSQL entity row.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: kb-app-demo-desktop/src/tauri.rs
|
||||
// version: 14
|
||||
// version: 15
|
||||
|
||||
//! Tauri runtime assembly and private command wrappers.
|
||||
|
||||
@@ -270,6 +270,15 @@ fn demo_decode_replay_options(
|
||||
return format!("{}@{}", identity.name, identity.version);
|
||||
})
|
||||
.collect::<std::vec::Vec<_>>();
|
||||
let programs = kb_program_ids::registered_program_ids()
|
||||
.iter()
|
||||
.map(|entry| {
|
||||
return crate::DemoDecodeReplayProgramOption {
|
||||
code: entry.code().to_string(),
|
||||
program_id: entry.program_id().to_string(),
|
||||
};
|
||||
})
|
||||
.collect();
|
||||
let running = state.demo_decode_replay_running().load(std::sync::atomic::Ordering::Acquire);
|
||||
tracing::debug!(
|
||||
target: crate::TRACING_TARGET,
|
||||
@@ -286,6 +295,7 @@ fn demo_decode_replay_options(
|
||||
pipeline_version: kb_pipeline::DECODE_PIPELINE_VERSION.to_string(),
|
||||
decoders: decoder_options,
|
||||
materializer_names,
|
||||
programs,
|
||||
default_limit: 100,
|
||||
default_max_concurrent_inputs: 4,
|
||||
running,
|
||||
@@ -915,14 +925,7 @@ async fn export_demo_sql_replay_csv(
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => return std::result::Result::Err(error),
|
||||
};
|
||||
let current_dir_result = std::env::current_dir();
|
||||
let current_dir = match current_dir_result {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => {
|
||||
return std::result::Result::Err(format!("cannot resolve current directory: {error}"));
|
||||
},
|
||||
};
|
||||
let export_dir = crate::csv_export_directory_from_current_dir(¤t_dir);
|
||||
let export_dir = crate::workspace_root_dir().join("data").join("exports_csv");
|
||||
let create_result = tokio::fs::create_dir_all(&export_dir).await;
|
||||
if let std::result::Result::Err(error) = create_result {
|
||||
return std::result::Result::Err(format!("cannot create CSV export directory: {error}"));
|
||||
|
||||
Reference in New Issue
Block a user