Compare commits
1 commit
main
...
notion-to-
| Author | SHA1 | Date | |
|---|---|---|---|
| c13ee32911 |
5 changed files with 22 additions and 7 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 = { version = "^1.0", features = ["derive"], default-features = false }
|
||||||
serde_json = { version = "^1.0", features = ["raw_value"], default-features = false }
|
serde_json = { version = "^1.0", features = ["raw_value"], default-features = false }
|
||||||
surf = { version = "2.3.2", 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
28
src/lib.rs
Executable file → Normal file
28
src/lib.rs
Executable file → Normal file
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, NaiveTime, Utc};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use serde::de::Error as SerdeError;
|
use serde::de::Error as SerdeError;
|
||||||
|
|
@ -701,7 +701,7 @@ pub struct ChildDatabase {
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||||
pub struct User {
|
pub struct User {
|
||||||
pub id: uuid::Uuid,
|
pub id: String,
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub person: Option<Person>,
|
pub person: Option<Person>,
|
||||||
pub avatar_url: Option<String>,
|
pub avatar_url: Option<String>,
|
||||||
|
|
@ -1069,7 +1069,7 @@ pub enum RollupProperty {
|
||||||
last_edited_time: DateValue,
|
last_edited_time: DateValue,
|
||||||
},
|
},
|
||||||
Select {
|
Select {
|
||||||
select: Option<SelectOption>,
|
select: SelectOption,
|
||||||
},
|
},
|
||||||
MultiSelect {
|
MultiSelect {
|
||||||
multi_select: Vec<SelectOption>,
|
multi_select: Vec<SelectOption>,
|
||||||
|
|
@ -1501,6 +1501,19 @@ pub enum RichText {
|
||||||
Unsupported,
|
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)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||||
pub struct Text {
|
pub struct Text {
|
||||||
pub content: String,
|
pub content: String,
|
||||||
|
|
@ -1573,8 +1586,8 @@ impl std::fmt::Display for Date {
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||||
#[serde(try_from = "String", into = "String")]
|
#[serde(try_from = "String", into = "String")]
|
||||||
pub enum DateValue {
|
pub enum DateValue {
|
||||||
Date(DateTime<Utc>),
|
|
||||||
DateTime(DateTime<Utc>),
|
DateTime(DateTime<Utc>),
|
||||||
|
Date(chrono::NaiveDate),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<String> for DateValue {
|
impl TryFrom<String> for DateValue {
|
||||||
|
|
@ -1583,7 +1596,9 @@ impl TryFrom<String> for DateValue {
|
||||||
fn try_from(string: String) -> Result<DateValue> {
|
fn try_from(string: String) -> Result<DateValue> {
|
||||||
// NOTE: is either ISO 8601 Date or assumed to be ISO 8601 DateTime
|
// NOTE: is either ISO 8601 Date or assumed to be ISO 8601 DateTime
|
||||||
let value = if ISO_8601_DATE.is_match(&string) {
|
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 {
|
} else {
|
||||||
DateValue::DateTime(DateTime::parse_from_rfc3339(&string)?.with_timezone(&Utc))
|
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 {
|
impl std::fmt::Display for DateValue {
|
||||||
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
let value = match self {
|
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(),
|
DateValue::DateTime(date_time) => date_time.to_rfc3339(),
|
||||||
};
|
};
|
||||||
Ok(write!(formatter, "{}", value)?)
|
Ok(write!(formatter, "{}", value)?)
|
||||||
|
|
@ -1685,6 +1700,7 @@ pub enum File {
|
||||||
},
|
},
|
||||||
External {
|
External {
|
||||||
external: ExternalFile,
|
external: ExternalFile,
|
||||||
|
caption: Option<Vec<RichText>>,
|
||||||
},
|
},
|
||||||
|
|
||||||
#[serde(other)]
|
#[serde(other)]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue