Compare commits

...

3 commits

Author SHA1 Message Date
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 7 additions and 8 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_json = { version = "^1.0", features = ["raw_value"], 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

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

@ -1,6 +1,6 @@
use std::collections::HashMap;
use chrono::{DateTime, NaiveTime, Utc};
use chrono::{DateTime, 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: String,
pub id: uuid::Uuid,
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: SelectOption,
select: Option<SelectOption>,
},
MultiSelect {
multi_select: Vec<SelectOption>,
@ -1573,8 +1573,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,9 +1583,7 @@ 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"))?.date_naive(),
)
DateValue::Date(DateTime::parse_from_rfc3339(&format!("{string}T00:00:00Z"))?.into())
} else {
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 {
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
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(),
};
Ok(write!(formatter, "{}", value)?)