aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/models/mod.rs22
-rw-r--r--src/models/properties.rs116
2 files changed, 115 insertions, 23 deletions
diff --git a/src/models/mod.rs b/src/models/mod.rs
index 795accd..be920fe 100644
--- a/src/models/mod.rs
+++ b/src/models/mod.rs
@@ -11,11 +11,13 @@ pub mod users;
use crate::models::properties::{PropertyConfiguration, PropertyValue};
use crate::models::text::RichText;
use crate::Error;
+use block::ExternalFileObject;
use serde::{Deserialize, Serialize};
+use serde_json::Value;
use std::collections::HashMap;
use crate::ids::{AsIdentifier, DatabaseId, PageId};
-use crate::models::block::{Block, CreateBlock};
+use crate::models::block::{Block, CreateBlock, FileObject};
use crate::models::error::ErrorResponse;
use crate::models::paging::PagingCursor;
use crate::models::users::User;
@@ -48,9 +50,26 @@ pub struct Database {
//
// value object
// A Property object.
+ pub icon: Option<IconObject>,
pub properties: HashMap<String, PropertyConfiguration>,
}
+#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)]
+#[serde(tag = "type")]
+#[serde(rename_all = "snake_case")]
+pub enum IconObject {
+ File {
+ #[serde(flatten)]
+ file: FileObject,
+ },
+ External {
+ external: ExternalFileObject,
+ },
+ Emoji {
+ emoji: String,
+ },
+}
+
impl AsIdentifier<DatabaseId> for Database {
fn as_id(&self) -> &DatabaseId {
&self.id
@@ -200,6 +219,7 @@ pub struct Page {
/// The archived status of the page.
pub archived: bool,
pub properties: Properties,
+ pub icon: Option<IconObject>,
pub parent: Parent,
}
diff --git a/src/models/properties.rs b/src/models/properties.rs
index 918eed6..545a611 100644
--- a/src/models/properties.rs
+++ b/src/models/properties.rs
@@ -156,11 +156,15 @@ pub struct Rollup {
pub enum PropertyConfiguration {
/// Represents the special Title property required on every database.
/// See <https://developers.notion.com/reference/database#title-configuration>
- Title { id: PropertyId },
+ Title {
+ id: PropertyId,
+ },
/// Represents a Text property
/// <https://developers.notion.com/reference/database#text-configuration>
#[serde(rename = "rich_text")]
- Text { id: PropertyId },
+ Text {
+ id: PropertyId,
+ },
/// Represents a Number Property
/// See <https://developers.notion.com/reference/database#number-configuration>
Number {
@@ -170,9 +174,15 @@ pub enum PropertyConfiguration {
},
/// Represents a Select Property
/// See <https://developers.notion.com/reference/database#select-configuration>
- Select { id: PropertyId, select: Select },
+ Select {
+ id: PropertyId,
+ select: Select,
+ },
/// Represents a Status property
- Status { id: PropertyId, status: Status },
+ Status {
+ id: PropertyId,
+ status: Status,
+ },
/// Represents a Multi-select Property
/// See <https://developers.notion.com/reference/database#multi-select-configuration>
MultiSelect {
@@ -181,41 +191,78 @@ pub enum PropertyConfiguration {
},
/// Represents a Date Property
/// See <https://developers.notion.com/reference/database#date-configuration>
- Date { id: PropertyId },
+ Date {
+ id: PropertyId,
+ },
/// Represents a People Property
/// See <https://developers.notion.com/reference/database#people-configuration>
- People { id: PropertyId },
+ People {
+ id: PropertyId,
+ },
/// Represents a File Property
/// See <https://developers.notion.com/reference/database#file-configuration>
// Todo: File a bug with notion
// Documentation issue: docs claim type name is `file` but it is in fact `files`
- Files { id: PropertyId },
+ Files {
+ id: PropertyId,
+ },
/// Represents a Checkbox Property
/// See <https://developers.notion.com/reference/database#checkbox-configuration>
- Checkbox { id: PropertyId },
+ Checkbox {
+ id: PropertyId,
+ },
/// Represents a URL Property
/// See <https://developers.notion.com/reference/database#url-configuration>
- Url { id: PropertyId },
+ Url {
+ id: PropertyId,
+ },
/// Represents a Email Property
/// See <https://developers.notion.com/reference/database#email-configuration>
- Email { id: PropertyId },
+ Email {
+ id: PropertyId,
+ },
/// Represents a Phone number Property
/// See <https://developers.notion.com/reference/database#phone-number-configuration>
- PhoneNumber { id: PropertyId },
+ PhoneNumber {
+ id: PropertyId,
+ },
/// See <https://developers.notion.com/reference/database#formula-configuration>
- Formula { id: PropertyId, formula: Formula },
+ Formula {
+ id: PropertyId,
+ formula: Formula,
+ },
/// See <https://developers.notion.com/reference/database#relation-configuration>
- Relation { id: PropertyId, relation: Relation },
+ Relation {
+ id: PropertyId,
+ relation: Relation,
+ },
/// See <https://developers.notion.com/reference/database#rollup-configuration>
- Rollup { id: PropertyId, rollup: Rollup },
+ Rollup {
+ id: PropertyId,
+ rollup: Rollup,
+ },
/// See <https://developers.notion.com/reference/database#created-time-configuration>
- CreatedTime { id: PropertyId },
+ CreatedTime {
+ id: PropertyId,
+ },
/// See <https://developers.notion.com/reference/database#created-by-configuration>
- CreatedBy { id: PropertyId },
+ CreatedBy {
+ id: PropertyId,
+ },
/// See <https://developers.notion.com/reference/database#last-edited-time-configuration>
- LastEditedTime { id: PropertyId },
+ LastEditedTime {
+ id: PropertyId,
+ },
/// See <https://developers.notion.com/reference/database#last-edited-by-configuration>
- LastEditBy { id: PropertyId },
+ LastEditBy {
+ id: PropertyId,
+ },
+ UniqueId {
+ id: PropertyId,
+ },
+ Button {
+ id: PropertyId,
+ },
}
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)]
@@ -333,16 +380,25 @@ pub enum PropertyValue {
rollup: Option<RollupValue>,
},
/// <https://developers.notion.com/reference/property-object#people-configuration>
- People { id: PropertyId, people: Vec<User> },
+ People {
+ id: PropertyId,
+ people: Vec<User>,
+ },
/// <https://developers.notion.com/reference/property-object#files-configuration>
Files {
id: PropertyId,
files: Option<Vec<FileReference>>,
},
/// <https://developers.notion.com/reference/property-object#checkbox-configuration>
- Checkbox { id: PropertyId, checkbox: bool },
+ Checkbox {
+ id: PropertyId,
+ checkbox: bool,
+ },
/// <https://developers.notion.com/reference/property-object#url-configuration>
- Url { id: PropertyId, url: Option<String> },
+ Url {
+ id: PropertyId,
+ url: Option<String>,
+ },
/// <https://developers.notion.com/reference/property-object#email-configuration>
Email {
id: PropertyId,
@@ -359,7 +415,10 @@ pub enum PropertyValue {
created_time: DateTime<Utc>,
},
/// <https://developers.notion.com/reference/property-object#created-by-configuration>
- CreatedBy { id: PropertyId, created_by: User },
+ CreatedBy {
+ id: PropertyId,
+ created_by: User,
+ },
/// <https://developers.notion.com/reference/property-object#last-edited-time-configuration>
LastEditedTime {
id: PropertyId,
@@ -370,6 +429,19 @@ pub enum PropertyValue {
id: PropertyId,
last_edited_by: User,
},
+ UniqueId {
+ id: PropertyId,
+ unique_id: UniqueidValue,
+ },
+ Button {
+ id: PropertyId,
+ },
+}
+
+#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
+pub struct UniqueidValue {
+ pub prefix: Option<String>,
+ pub number: u32,
}
/// <https://developers.notion.com/reference/page#rollup-property-value-element>
3-07-28optional parameterGravatar Dylan Conway 1-3/+3 2023-07-28Fixes #3868Gravatar Jarred Sumner 1-2/+3 2023-07-28Fix assertion failure and possible infinite loop when printing as yarn lock f...Gravatar Jarred Sumner 2-3/+16 2023-07-28Mark broken test as todoGravatar Jarred Sumner 2-1/+5 2023-07-28fix types and add message channel/port gc testGravatar Dylan Conway 2-62/+18 2023-07-28`MessageChannel` and `MessagePort` (#3860)Gravatar Dylan Conway 57-247/+3752 2023-07-28mark tests as todoGravatar Jarred Sumner 2-81/+75 2023-07-28add fork to child_process (#3851)Gravatar Vlad Sirenko 7-19/+446 2023-07-28feat(bun/test): Impl. expect().pass() & expect().fail() (#3843)Gravatar Tiramify (A.K. Daniel) 6-5/+212 2023-07-28fix the chunk boundary (`node:stream:createReadStream`) (#3853)Gravatar Ai Hoshino 3-8/+90 2023-07-28Support file: URLs in `fetch` (#3858)Gravatar Jarred Sumner 6-183/+281 2023-07-28fix(tls) exposes native canonicalizeIP and fix rootCertificates (#3866)Gravatar Ciro Spaciari 7-29/+125 2023-07-28Fixes #3795 (#3856)Gravatar Jarred Sumner 11-6/+140 2023-07-28Add todoGravatar Jarred Sumner 2-0/+8 2023-07-28Update pull_request_template.mdGravatar Jarred Sumner 1-1/+1 2023-07-28Update pull_request_template.mdGravatar Jarred Sumner 1-11/+16 2023-07-27Fix bug with // @bun annotation in main thread (#3855)Gravatar Jarred Sumner 4-2/+53 2023-07-27Add `Bun.isMainThread`Gravatar Jarred Sumner 7-3/+48 2023-07-27Uncomment testGravatar Jarred Sumner 1-1/+1 2023-07-27Resolve watch directories outside main thread + async iterator and symlink fi...Gravatar Ciro Spaciari 8-197/+523 2023-07-27Update pull_request_template.mdGravatar Jarred Sumner 1-1/+1 2023-07-27Update pull_request_template.mdGravatar Jarred Sumner 1-1/+1 2023-07-27Update pull_request_template.mdGravatar Jarred Sumner 1-1/+1 2023-07-27Update pull_request_template.mdGravatar Jarred Sumner 1-2/+2 2023-07-27Update pull_request_template.mdGravatar Jarred Sumner 1-0/+4 2023-07-27Update pull_request_template.mdGravatar Jarred Sumner 1-5/+11