aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-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>
2022-05-11[bun.js] eagerly convert to import.meta.requireGravatar Jarred Sumner 2-3/+24 2022-05-11[json] Fix bug with negative integers in json parserGravatar Jarred Sumner 1-3/+6 2022-05-11[bun.js] Implement a polyfill for the `detect-libc` npm packageGravatar Jarred Sumner 2-0/+53 2022-05-11[bun.js] Implement `import.meta.require`Gravatar Jarred Sumner 13-158/+539 2022-05-11[bun.js] Implement `import.meta.resolveSync`Gravatar Jarred Sumner 3-1/+78 2022-05-10Include napi in plus100Gravatar Jarred Sumner 1-4/+20 2022-05-10Add test for Buffer.byteLengthGravatar Jarred Sumner 1-0/+7 2022-05-10[napi] Error on import .nodeGravatar Jarred Sumner 1-29/+1 2022-05-10Update napi.cppGravatar Jarred Sumner 1-1/+0 2022-05-10[napi] Fix string bugGravatar Jarred Sumner 4-58/+125 2022-05-10[napi] transpile require(*.node) into process.dlopenGravatar Jarred Sumner 4-3/+30 2022-05-10[bun.js] Implement `Buffer.byteLength`Gravatar Jarred Sumner 7-47/+443 2022-05-09Fix extra quote in bundled require errorsGravatar Jarred Sumner 1-2/+2 2022-05-09few more napi functionsGravatar Jarred Sumner 2-1/+30 2022-05-09Update MakefileGravatar Jarred Sumner 1-3/+3 2022-05-09Update Dockerfile.baseGravatar Jarred Sumner 1-1/+1 2022-05-09[napi] getters & setters workGravatar Jarred Sumner 1-26/+39