notionary 0.1.17__py3-none-any.whl → 0.1.19__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -217,6 +217,26 @@ class NotionDatabase(LoggingMixin):
217
217
  self.logger.error("Error in delete_page: %s", str(e))
218
218
  return {"success": False, "message": f"Error: {str(e)}"}
219
219
 
220
+ async def get_last_edited_time(self) -> Optional[str]:
221
+ """
222
+ Retrieve the last edited time of the database.
223
+
224
+ Returns:
225
+ ISO 8601 timestamp string of the last database edit, or None if request fails
226
+ """
227
+ try:
228
+ response = await self._client.get(f"databases/{self.database_id}")
229
+
230
+ if response and "last_edited_time" in response:
231
+ return response["last_edited_time"]
232
+
233
+ self.logger.warning("Could not retrieve last_edited_time for database %s", self.database_id)
234
+ return None
235
+
236
+ except Exception as e:
237
+ self.logger.error("Error fetching last_edited_time: %s", str(e))
238
+ return None
239
+
220
240
  async def close(self) -> None:
221
241
  """Close the client connection."""
222
242
  await self._client.close()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: notionary
3
- Version: 0.1.17
3
+ Version: 0.1.19
4
4
  Summary: A toolkit to convert between Markdown and Notion blocks
5
5
  Home-page: https://github.com/mathisarends/notionary
6
6
  Author: Mathis Arends
@@ -10,13 +10,8 @@ Classifier: License :: OSI Approved :: MIT License
10
10
  Requires-Python: >=3.7
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
- Requires-Dist: notion-client>=2.0.0
14
- Requires-Dist: markdown-it-py>=3.0.0
15
- Requires-Dist: beautifulsoup4>=4.13.0
16
13
  Requires-Dist: httpx>=0.28.0
17
14
  Requires-Dist: python-dotenv>=1.1.0
18
- Requires-Dist: lxml>=5.3.0
19
- Requires-Dist: attrs>=25.3.0
20
15
  Dynamic: author
21
16
  Dynamic: author-email
22
17
  Dynamic: classifier
@@ -33,12 +28,14 @@ Dynamic: summary
33
28
  [![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
34
29
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
35
30
 
36
- **Notionary** is a powerful Python library for interacting with the Notion API, making it easy to create, update, and manage Notion pages and databases programmatically with a clean, intuitive interface.
31
+ **Notionary** is a powerful Python library for interacting with the Notion API, making it easy to create, update, and manage Notion pages and databases programmatically with a clean, intuitive interface. It's specifically designed to be the foundation for AI-driven Notion content generation.
37
32
 
38
33
  ## Features
39
34
 
40
- - **Rich Markdown Support**: Write Notion pages using intuitive Markdown syntax with custom extensions
35
+ - **Rich Markdown Support**: Create Notion pages using intuitive Markdown syntax with custom extensions
41
36
  - **Dynamic Database Operations**: Create, update, and query database entries with schema auto-detection
37
+ - **Extensible Block Registry**: Add, customize, or remove Notion block elements with a flexible registry pattern
38
+ - **LLM-Ready Prompts**: Generate system prompts explaining Markdown syntax for LLMs to create Notion content
42
39
  - **Async-First Design**: Built for modern Python with full async/await support
43
40
  - **Schema-Based Validation**: Automatic property validation based on database schemas
44
41
  - **Intelligent Content Conversion**: Bidirectional conversion between Markdown and Notion blocks
@@ -56,7 +53,7 @@ Notionary extends standard Markdown with special syntax to support Notion-specif
56
53
  ### Text Formatting
57
54
 
58
55
  - Standard Markdown: `**bold**`, `*italic*`, `~~strikethrough~~`, `` `code` ``
59
- - Highlights: `==highlighted text==`, `==red warning==`, `==blue==`
56
+ - Highlights: `==highlighted text==`, `==red:warning==`, `==blue:note==`
60
57
 
61
58
  ### Block Elements
62
59
 
@@ -111,50 +108,43 @@ Notionary makes it easy to work with Notion databases, automatically handling sc
111
108
 
112
109
  ```python
113
110
  import asyncio
114
- from notionary.core.database.notion_database_manager import NotionDatabaseManager
111
+ from notionary import NotionDatabaseFactory
115
112
 
116
113
  async def main():
117
- database_id = "1a6389d5-7bd3-8097-aa38-e93cb052615a"
118
- db = NotionDatabaseManager(database_id)
119
- await db.initialize()
114
+ # Find database by name with fuzzy matching
115
+ db_manager = await NotionDatabaseFactory.from_database_name("Projects")
120
116
 
117
+ # Create a new page with properties
121
118
  properties = {
122
119
  "Title": "Created via Notionary",
123
- "Description": "This entry was created using Notionary.",
124
120
  "Status": "In Progress",
125
121
  "Priority": "High"
126
122
  }
127
123
 
128
- result = await db.create_page(properties)
124
+ page = await db_manager.create_blank_page()
129
125
 
130
- if result["success"]:
131
- page_id = result["page_id"]
132
- await db.update_page(page_id, {"Status": "Completed"})
126
+ # Set page content with rich Markdown
127
+ await page.set_title("My New Project")
128
+ await page.set_page_icon(emoji="🚀")
133
129
 
134
- filter_conditions = {
135
- "property": "Status",
136
- "status": {"equals": "Completed"}
137
- }
130
+ markdown = """
131
+ # Project Overview
138
132
 
139
- pages = await db.get_pages(limit=10, filter_conditions=filter_conditions)
133
+ !> [💡] This page was created programmatically using Notionary.
140
134
 
141
- await db.close()
135
+ ## Tasks
136
+ - [ ] Define project scope
137
+ - [ ] Create timeline
138
+ - [ ] Assign resources
142
139
 
143
- if __name__ == "__main__":
144
- asyncio.run(main())
145
- ```
146
-
147
- ## Finding Databases by Name
148
-
149
- Use fuzzy matching to find databases:
140
+ +++ Implementation Details
141
+ This project will use our standard architecture with custom extensions.
142
+ """
150
143
 
151
- ```python
152
- from notionary.core.database.notion_database_manager_factory import NotionDatabaseFactory
144
+ await page.replace_content(markdown)
153
145
 
154
- async def main():
155
- db_manager = await NotionDatabaseFactory.from_database_name("Projects")
156
- print(f"Found database: {db_manager.title}")
157
- await db_manager.close()
146
+ if __name__ == "__main__":
147
+ asyncio.run(main())
158
148
  ```
159
149
 
160
150
  ## Page Content Management
@@ -162,11 +152,11 @@ async def main():
162
152
  Create rich Notion pages using enhanced Markdown:
163
153
 
164
154
  ```python
165
- from notionary.core.page.notion_page_manager import NotionPageManager
155
+ from notionary import NotionPage
166
156
 
167
157
  async def create_rich_page():
168
158
  url = "https://www.notion.so/Your-Page-1cd389d57bd381e58be9d35ce24adf3d"
169
- page_manager = NotionPageManager(url=url)
159
+ page_manager = NotionPage(url=url)
170
160
 
171
161
  await page_manager.set_title("Notionary Demo")
172
162
  await page_manager.set_page_icon(emoji="✨")
@@ -190,20 +180,71 @@ async def create_rich_page():
190
180
  await page_manager.replace_content(markdown)
191
181
  ```
192
182
 
193
- ## Perfect for AI Agents and Automation
183
+ ## Block Registry & Builder
194
184
 
195
- - **Dynamic Content Generation**: AI agents can generate content in Markdown and render it as Notion pages
196
- - **Schema-Aware Operations**: Automatically validate and format properties
197
- - **Simplified API**: Easier integration with AI workflows
185
+ Notionary uses a flexible registry pattern with a builder to customize which Notion elements are supported, allowing programmatic creation of complex UI layouts that were previously only possible through Notion's UI:
186
+
187
+ ```python
188
+ from notionary import NotionPage
189
+ from notionary.elements.block_element_registry_builder import BlockElementRegistryBuilder
190
+
191
+ # Create a registry with standard Notion elements
192
+ registry = BlockElementRegistryBuilder.create_standard_registry()
193
+
194
+ # Or build a custom registry with only the elements you need
195
+ custom_registry = (
196
+ BlockElementRegistryBuilder()
197
+ .with_headings()
198
+ .with_callouts()
199
+ .with_toggles()
200
+ .with_lists()
201
+ .with_tables()
202
+ .with_paragraphs()
203
+ .build()
204
+ )
205
+
206
+ # Apply this registry to a page to enable custom Markdown support
207
+ page = NotionPage(url="https://www.notion.so/your-page-url")
208
+ page.block_registry = custom_registry
209
+
210
+ # Now your page supports exactly the elements you've defined
211
+ await page.replace_content("# Custom heading with only selected elements")
212
+ ```
213
+
214
+ This registry approach gives you granular control over which Notion UI elements can be created through Markdown, making it possible to programmatically construct any page layout that would normally require manual UI interaction.
215
+
216
+ ## AI-Ready LLM Prompt Generation
217
+
218
+ Notionary can automatically generate comprehensive system prompts for LLMs to understand Notion's custom Markdown syntax:
219
+
220
+ ```python
221
+ from notionary.elements.block_element_registry_builder import BlockElementRegistryBuilder
222
+
223
+ registry = BlockElementRegistryBuilder.create_standard_registry()
224
+ llm_system_prompt = registry.generate_llm_prompt()
225
+
226
+ # Use this prompt with your LLM to generate Notion-compatible Markdown
227
+ print(llm_system_prompt)
228
+ ```
229
+
230
+ This makes Notionary the perfect foundation for AI-driven Notion content generation, enabling LLMs to create properly formatted Notion pages.
198
231
 
199
232
  ## Examples
200
233
 
201
- See the `examples` folder for:
234
+ See the [examples folder](examples/) for more comprehensive demonstrations:
235
+
236
+ - [Database discovery and querying](examples/database_discovery_example.py)
237
+ - [Rich page creation with Markdown](examples/page_example.py)
238
+ - [Database factory usage](examples/database_factory_example.py)
239
+ - [Page lookup and access](examples/page_factory_by_url_example.py)
240
+ - [Iterating through database entries](examples/iter_database_example.py)
241
+
242
+ ## Perfect for AI Agents and Automation
202
243
 
203
- - Database discovery and querying
204
- - Rich page creation with Markdown
205
- - Entry management
206
- - Metadata manipulation
244
+ - **LLM Integration**: Generate Notion-compatible content with LLMs using the system prompt generator
245
+ - **Dynamic Content Generation**: AI agents can generate content in Markdown and render it as Notion pages
246
+ - **Schema-Aware Operations**: Automatically validate and format properties
247
+ - **Simplified API**: Easier integration with AI workflows
207
248
 
208
249
  ## License
209
250
 
@@ -2,7 +2,7 @@ notionary/__init__.py,sha256=sVqdwzMQcc9jf6FKi1qflilsx8rnWzluVhWewVi5gyI,717
2
2
  notionary/notion_client.py,sha256=NPPK7zId6EaC-hQeFJ7geaiROGtZfmc8cVP2nQez5DU,6040
3
3
  notionary/database/database_discovery.py,sha256=qDGFhXG9s-_6CXdRg8tMiwX4dvX7jLjgAUFPSNlYtlI,4506
4
4
  notionary/database/database_info_service.py,sha256=Ig6gx8jUSPYORJvfgEV5kV6t72pZQsWU8HPMqd43B-o,1336
5
- notionary/database/notion_database.py,sha256=RY5MlXNE5DVNWLC_Derljsz87ZMHkE-05Vgm80kvLxg,7250
5
+ notionary/database/notion_database.py,sha256=Zm5Ev0n4idKUe3ms8l3B4fyIezNNCCEDWHZ5vDoTknQ,7985
6
6
  notionary/database/notion_database_factory.py,sha256=Af57yaUHidD8TKJ8uyXOc2nnqHm7on6VGFdDRjxiq9o,6692
7
7
  notionary/database/models/page_result.py,sha256=Vmm5_oYpYAkIIJVoTd1ZZGloeC3cmFLMYP255mAmtaw,233
8
8
  notionary/elements/audio_element.py,sha256=XLARz5zlPPW_Qof6uhcYXFmyYzyS1fLdxdfsvh6GMOs,5589
@@ -49,8 +49,8 @@ notionary/page/relations/relation_operation_result.py,sha256=NDxBzGntOxc_89ti-HG
49
49
  notionary/util/logging_mixin.py,sha256=fKsx9t90bwvL74ZX3dU-sXdC4TZCQyO6qU9I8txkw_U,1369
50
50
  notionary/util/page_id_utils.py,sha256=EYNMxgf-7ghzL5K8lKZBZfW7g5CsdY0Xuj4IYmU8RPk,1381
51
51
  notionary/util/singleton_decorator.py,sha256=GTNMfIlVNRUVMw_c88xqd12-DcqZJjmyidN54yqiNVw,472
52
- notionary-0.1.17.dist-info/licenses/LICENSE,sha256=zOm3cRT1qD49eg7vgw95MI79rpUAZa1kRBFwL2FkAr8,1120
53
- notionary-0.1.17.dist-info/METADATA,sha256=VZF2Dx-fZCwhEE42S8RTXaJabhLml8qrL_SVfSlcB-w,6154
54
- notionary-0.1.17.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
55
- notionary-0.1.17.dist-info/top_level.txt,sha256=fhONa6BMHQXqthx5PanWGbPL0b8rdFqhrJKVLf_adSs,10
56
- notionary-0.1.17.dist-info/RECORD,,
52
+ notionary-0.1.19.dist-info/licenses/LICENSE,sha256=zOm3cRT1qD49eg7vgw95MI79rpUAZa1kRBFwL2FkAr8,1120
53
+ notionary-0.1.19.dist-info/METADATA,sha256=Ws3WI2Yp4HopH7_Jo4eQbzSN0ziOHZOaqieDNZK9kSM,8350
54
+ notionary-0.1.19.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
55
+ notionary-0.1.19.dist-info/top_level.txt,sha256=fhONa6BMHQXqthx5PanWGbPL0b8rdFqhrJKVLf_adSs,10
56
+ notionary-0.1.19.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (79.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5