A command-line tool to convert handwritten notes to markdown files
fix: added other notion properties for deserializing the api response else the app crashed
Tejas Raskar8dbe40a99be3
diff --git a/src/clients/notion_client.rs b/src/clients/notion_client.rsindex 13b1cb5..c8420f5 100644--- a/src/clients/notion_client.rs+++ b/src/clients/notion_client.rs@@ -25,7 +25,8 @@ pub struct Parent {// Response Struct#[derive(Deserialize, Debug)]pub struct NotionResponse {- pub id: String,+ #[serde(rename = "id")]+ pub _id: String,pub url: String,}@@ -36,7 +37,8 @@ pub struct NotionDatabase {#[derive(Deserialize, Debug)]pub struct DatabaseProperty {- pub id: String,+ #[serde(rename = "id")]+ pub _id: String,pub name: String,#[serde(flatten)]pub type_specific_config: PropertyType,@@ -48,7 +50,7 @@ pub struct DatabaseProperty {pub enum PropertyType {Title(EmptyStruct),RichText(EmptyStruct),- Number(NumberStruct),+ Number(EmptyStruct),Select { select: SelectStruct },MultiSelect { multi_select: SelectStruct },Date(EmptyStruct),@@ -61,6 +63,14 @@ pub enum PropertyType {CreatedBy(EmptyStruct),LastEditedTime(EmptyStruct),LastEditedBy(EmptyStruct),+ Status { status: SelectStruct },+ Formula(EmptyStruct),+ Relation(EmptyStruct),+ Rollup(EmptyStruct),+ PhoneNumber(EmptyStruct),+ Button(EmptyStruct),+ UniqueId(EmptyStruct),+ Verification(EmptyStruct),}#[derive(Deserialize, Debug)]@@ -70,19 +80,21 @@ pub struct SelectStruct {#[derive(Deserialize, Debug, Clone)]pub struct DatabaseSelectOption {- pub id: String,+ #[serde(rename = "id")]+ pub _id: String,pub name: String,- pub color: String,+ #[serde(rename = "color")]+ pub _color: String,}#[derive(Deserialize, Debug)]pub struct NumberStruct {- pub number: NumberFormat,+ pub _number: NumberFormat,}#[derive(Deserialize, Debug)]pub struct NumberFormat {- pub format: String,+ pub _format: String,}#[derive(Deserialize, Debug)]diff --git a/src/main.rs b/src/main.rsindex cca5b82..649c69f 100644--- a/src/main.rs+++ b/src/main.rs@@ -92,7 +92,7 @@ async fn process_and_save_file(if let (Some(client), Some(config)) = (notion_client, notion_config) {match client.create_notion_page(- file_name.to_str().unwrap(),+ file_name.to_string_lossy().into_owned().as_str(),&config.title_property_name,&config.properties,&markdown,@@ -399,7 +399,7 @@ async fn run() -> Result<(), NotedError> {.map(|option| option.name.clone()).collect();let selection = Select::with_theme(&ColorfulTheme::default())- .with_prompt(format!("Select default option for '{}' (press Space to select and Enter to confirm)", name))+ .with_prompt(format!("Select default option for '{}' (Select and Enter to confirm)", name)).items(&options).interact()?;let selected_name = options[selection].clone();diff --git a/src/notion/converter.rs b/src/notion/converter.rsindex e59edca..d2e8a0b 100644--- a/src/notion/converter.rs+++ b/src/notion/converter.rs@@ -13,7 +13,7 @@ use notion_client::objects::{};pub struct Converter<'a> {- arena: &'a Arena<AstNode<'a>>,+ _arena: &'a Arena<AstNode<'a>>,}impl<'a> Converter<'a> {@@ -21,7 +21,7 @@ impl<'a> Converter<'a> {let mut options = ComrakOptions::default();options.extension.math_dollars = true;let root = parse_document(arena, markdown, &options);- let mut converter = Self { arena };+ let mut converter = Self { _arena: arena };let blocks = converter.render_nodes(root.children())?;Ok(blocks)diff --git a/src/ui.rs b/src/ui.rsindex d8ba8d2..c393094 100644--- a/src/ui.rs+++ b/src/ui.rs@@ -69,7 +69,10 @@ pub fn print_clean_config(config: Config) {let api_key = if openai_config.api_key.is_none() {"API key empty.".to_string()} else {- openai_config.api_key.unwrap()+ format!(+ "{:.3}***************** (hidden for security)",+ openai_config.api_key.unwrap()+ )};println!(" API Key: {}", api_key);@@ -85,6 +88,11 @@ pub fn print_clean_config(config: Config) {);println!(" API Key: {}", api_key);println!(" Database ID: {}", notion_config.database_id);+ println!(+ " Title Property Name: {}",+ notion_config.title_property_name+ );+ println!(" Database Properties: {:#?}", notion_config.properties);} else {println!(" (Not Configured)");}