Compare commits

...

4 commits

Author SHA1 Message Date
904e83a7d1 fix: commented out page_or_database since it causes crash 2025-12-08 13:58:05 +01:00
1686293bac fix: changed DateValue to both be UTC and be serialized reliably 2025-04-11 14:17:39 +02:00
b664f777d3 feat: made sure that notion user id is Uuid
fix: made sure that Rollup -> Select has Option since it can be null
2025-04-04 14:53:56 +02:00
509b3ccd90 chore: switched to linux 2025-03-21 15:34:19 +01:00
5 changed files with 8 additions and 9 deletions

0
.gitignore vendored Normal file → Executable file
View file

1
Cargo.toml Normal file → Executable file
View file

@ -20,3 +20,4 @@ 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 Normal file → Executable file
View file

0
README.md Normal file → Executable file
View file

16
src/lib.rs Normal file → Executable file
View file

@ -1,6 +1,6 @@
use std::collections::HashMap; use std::collections::HashMap;
use chrono::{DateTime, NaiveTime, Utc}; use chrono::{DateTime, 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: String, pub id: uuid::Uuid,
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: SelectOption, select: Option<SelectOption>,
}, },
MultiSelect { MultiSelect {
multi_select: Vec<SelectOption>, multi_select: Vec<SelectOption>,
@ -1114,7 +1114,7 @@ pub struct QueryResponse<T> {
pub has_more: Option<bool>, pub has_more: Option<bool>,
pub next_cursor: Option<String>, pub next_cursor: Option<String>,
pub results: Vec<T>, pub results: Vec<T>,
pub page_or_database: Value, // pub page_or_database: Value,
} }
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
@ -1573,8 +1573,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,9 +1583,7 @@ 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( DateValue::Date(DateTime::parse_from_rfc3339(&format!("{string}T00:00:00Z"))?.into())
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))
}; };
@ -1603,7 +1601,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.and_time(NaiveTime::MIN).and_utc().to_rfc3339(), DateValue::Date(date) => date.format("%Y-%m-%d").to_string(),
DateValue::DateTime(date_time) => date_time.to_rfc3339(), DateValue::DateTime(date_time) => date_time.to_rfc3339(),
}; };
Ok(write!(formatter, "{}", value)?) Ok(write!(formatter, "{}", value)?)