aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jake Swenson <jake@jakeswenson.com> 2021-05-14 08:01:21 -0700
committerGravatar Jake Swenson <jake@jakeswenson.com> 2021-05-14 08:01:21 -0700
commit3db26f295de9e2805a2c1c6a083566da0f4e2b07 (patch)
tree1f66623048249f5eadc96cac0d2226926ecd90a3 /src
parent7c069aede00bc1c57910fa2505fd5d0afe747c1c (diff)
downloadnotion-3db26f295de9e2805a2c1c6a083566da0f4e2b07.tar.gz
notion-3db26f295de9e2805a2c1c6a083566da0f4e2b07.tar.zst
notion-3db26f295de9e2805a2c1c6a083566da0f4e2b07.zip
add all properties
Diffstat (limited to 'src')
-rw-r--r--src/models/properties.rs83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/models/properties.rs b/src/models/properties.rs
index 37c1a4e..4139712 100644
--- a/src/models/properties.rs
+++ b/src/models/properties.rs
@@ -1,3 +1,4 @@
+use crate::models::DatabaseId;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
@@ -55,6 +56,62 @@ pub struct Select {
}
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
+pub struct Formula {
+ /// Formula to evaluate for this property
+ expression: String,
+}
+
+#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
+pub struct Relation {
+ /// The database this relation refers to.
+ /// New linked pages must belong to this database in order to be valid.
+ database_id: DatabaseId,
+ /// By default, relations are formed as two synced properties across databases:
+ /// if you make a change to one property, it updates the synced property at the same time.
+ /// `synced_property_name` refers to the name of the property in the related database.
+ synced_property_name: Option<String>,
+ /// By default, relations are formed as two synced properties across databases:
+ /// if you make a change to one property, it updates the synced property at the same time.
+ /// `synced_property_id` refers to the id of the property in the related database.
+ /// This is usually a short string of random letters and symbols.
+ synced_property_id: Option<PropertyId>,
+}
+
+#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
+#[serde(rename_all = "snake_case")]
+pub enum RollupFunction {
+ CountAll,
+ CountValues,
+ CountUniqueValues,
+ CountEmpty,
+ CountNotEmpty,
+ PercentEmpty,
+ PercentNotEmpty,
+ Sum,
+ Average,
+ Median,
+ Min,
+ Max,
+ Range,
+}
+
+#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
+pub struct Rollup {
+ /// The name of the relation property this property is responsible for rolling up.
+ relation_property_name: String,
+ /// The id of the relation property this property is responsible for rolling up.
+ relation_property_id: PropertyId,
+ /// The name of the property of the pages in the related database
+ /// that is used as an input to `function`.
+ rollup_property_name: String,
+ /// The id of the property of the pages in the related database
+ /// that is used as an input to `function`.
+ rollup_property_id: String,
+ /// The function that is evaluated for every page in the relation of the rollup.
+ function: RollupFunction,
+}
+
+#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
#[serde(tag = "type")]
#[serde(rename_all = "snake_case")]
pub enum PropertyConfiguration {
@@ -82,4 +139,30 @@ pub enum PropertyConfiguration {
/// See https://developers.notion.com/reference/database#file-configuration
/// Documentation issue: docs claim type name is `file` but it's is in fact `files`
Files { id: PropertyId },
+ /// Represents a Checkbox Property
+ /// See https://developers.notion.com/reference/database#checkbox-configuration
+ Checkbox { id: PropertyId },
+ /// Represents a URL Property
+ /// See https://developers.notion.com/reference/database#url-configuration
+ URL { id: PropertyId },
+ /// Represents a Email Property
+ /// See https://developers.notion.com/reference/database#email-configuration
+ Email { id: PropertyId },
+ /// Represents a Phone number Property
+ /// See https://developers.notion.com/reference/database#phone-number-configuration
+ PhoneNumber { id: PropertyId },
+ /// See https://developers.notion.com/reference/database#formula-configuration
+ Formula { id: PropertyId, formula: Formula },
+ /// See https://developers.notion.com/reference/database#relation-configuration
+ Relation { id: PropertyId, relation: Relation },
+ /// See https://developers.notion.com/reference/database#rollup-configuration
+ Rollup { id: PropertyId, rollup: Rollup },
+ /// See https://developers.notion.com/reference/database#created-time-configuration
+ CreatedTime { id: PropertyId },
+ /// See https://developers.notion.com/reference/database#created-by-configuration
+ CreatedBy { id: PropertyId },
+ /// See https://developers.notion.com/reference/database#last-edited-time-configuration
+ LastEditTime { id: PropertyId },
+ /// See https://developers.notion.com/reference/database#last-edited-by-configuration
+ LastEditBy { id: PropertyId },
}