Compare commits
1 commit
main
...
notion-to-
| Author | SHA1 | Date | |
|---|---|---|---|
| c13ee32911 |
5 changed files with 23 additions and 8 deletions
0
.gitignore
vendored
Executable file → Normal file
0
.gitignore
vendored
Executable file → Normal file
1
Cargo.toml
Executable file → Normal file
1
Cargo.toml
Executable file → Normal file
|
|
@ -20,4 +20,3 @@ regex = "1.7.1"
|
|||
serde = { version = "^1.0", features = ["derive"], default-features = false }
|
||||
serde_json = { version = "^1.0", features = ["raw_value"], default-features = false }
|
||||
surf = { version = "2.3.2", default-features = false }
|
||||
uuid = "1.16.0"
|
||||
|
|
|
|||
0
LICENSE
Executable file → Normal file
0
LICENSE
Executable file → Normal file
0
README.md
Executable file → Normal file
0
README.md
Executable file → Normal file
30
src/lib.rs
Executable file → Normal file
30
src/lib.rs
Executable file → Normal file
|
|
@ -1,6 +1,6 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use chrono::{DateTime, NaiveTime, Utc};
|
||||
use lazy_static::lazy_static;
|
||||
use regex::Regex;
|
||||
use serde::de::Error as SerdeError;
|
||||
|
|
@ -701,7 +701,7 @@ pub struct ChildDatabase {
|
|||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||
pub struct User {
|
||||
pub id: uuid::Uuid,
|
||||
pub id: String,
|
||||
pub name: Option<String>,
|
||||
pub person: Option<Person>,
|
||||
pub avatar_url: Option<String>,
|
||||
|
|
@ -1069,7 +1069,7 @@ pub enum RollupProperty {
|
|||
last_edited_time: DateValue,
|
||||
},
|
||||
Select {
|
||||
select: Option<SelectOption>,
|
||||
select: SelectOption,
|
||||
},
|
||||
MultiSelect {
|
||||
multi_select: Vec<SelectOption>,
|
||||
|
|
@ -1114,7 +1114,7 @@ pub struct QueryResponse<T> {
|
|||
pub has_more: Option<bool>,
|
||||
pub next_cursor: Option<String>,
|
||||
pub results: Vec<T>,
|
||||
pub page_or_database: Value,
|
||||
// pub page_or_database: Value,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||
|
|
@ -1501,6 +1501,19 @@ pub enum RichText {
|
|||
Unsupported,
|
||||
}
|
||||
|
||||
impl RichText {
|
||||
pub fn plain_text(&self) -> String {
|
||||
use RichText::*;
|
||||
match self {
|
||||
Text { plain_text, .. } | Mention { plain_text, .. } | Equation { plain_text, .. } => {
|
||||
plain_text
|
||||
}
|
||||
Unsupported => "",
|
||||
}
|
||||
.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||
pub struct Text {
|
||||
pub content: String,
|
||||
|
|
@ -1573,8 +1586,8 @@ impl std::fmt::Display for Date {
|
|||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||
#[serde(try_from = "String", into = "String")]
|
||||
pub enum DateValue {
|
||||
Date(DateTime<Utc>),
|
||||
DateTime(DateTime<Utc>),
|
||||
Date(chrono::NaiveDate),
|
||||
}
|
||||
|
||||
impl TryFrom<String> for DateValue {
|
||||
|
|
@ -1583,7 +1596,9 @@ impl TryFrom<String> for DateValue {
|
|||
fn try_from(string: String) -> Result<DateValue> {
|
||||
// NOTE: is either ISO 8601 Date or assumed to be ISO 8601 DateTime
|
||||
let value = if ISO_8601_DATE.is_match(&string) {
|
||||
DateValue::Date(DateTime::parse_from_rfc3339(&format!("{string}T00:00:00Z"))?.into())
|
||||
DateValue::Date(
|
||||
DateTime::parse_from_rfc3339(&format!("{string}T00:00:00Z"))?.date_naive(),
|
||||
)
|
||||
} else {
|
||||
DateValue::DateTime(DateTime::parse_from_rfc3339(&string)?.with_timezone(&Utc))
|
||||
};
|
||||
|
|
@ -1601,7 +1616,7 @@ impl From<DateValue> for String {
|
|||
impl std::fmt::Display for DateValue {
|
||||
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
let value = match self {
|
||||
DateValue::Date(date) => date.format("%Y-%m-%d").to_string(),
|
||||
DateValue::Date(date) => date.and_time(NaiveTime::MIN).and_utc().to_rfc3339(),
|
||||
DateValue::DateTime(date_time) => date_time.to_rfc3339(),
|
||||
};
|
||||
Ok(write!(formatter, "{}", value)?)
|
||||
|
|
@ -1685,6 +1700,7 @@ pub enum File {
|
|||
},
|
||||
External {
|
||||
external: ExternalFile,
|
||||
caption: Option<Vec<RichText>>,
|
||||
},
|
||||
|
||||
#[serde(other)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue