notionary 0.2.6__tar.gz → 0.2.8__tar.gz

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.
Files changed (70) hide show
  1. notionary-0.2.8/PKG-INFO +271 -0
  2. notionary-0.2.8/README.md +245 -0
  3. {notionary-0.2.6 → notionary-0.2.8}/notionary/database/database_discovery.py +24 -24
  4. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/code_block_element.py +59 -18
  5. notionary-0.2.8/notionary/elements/column_element.py +353 -0
  6. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/divider_element.py +1 -1
  7. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/heading_element.py +4 -1
  8. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/registry/block_registry.py +1 -1
  9. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/registry/block_registry_builder.py +8 -0
  10. notionary-0.2.8/notionary/page/content/page_content_writer.py +203 -0
  11. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/markdown_to_notion_converter.py +145 -13
  12. {notionary-0.2.6 → notionary-0.2.8}/notionary/prompting/markdown_syntax_prompt_generator.py +33 -29
  13. notionary-0.2.8/notionary.egg-info/PKG-INFO +271 -0
  14. {notionary-0.2.6 → notionary-0.2.8}/notionary.egg-info/SOURCES.txt +1 -0
  15. {notionary-0.2.6 → notionary-0.2.8}/setup.py +1 -1
  16. notionary-0.2.6/PKG-INFO +0 -256
  17. notionary-0.2.6/README.md +0 -230
  18. notionary-0.2.6/notionary/page/content/page_content_writer.py +0 -103
  19. notionary-0.2.6/notionary.egg-info/PKG-INFO +0 -256
  20. {notionary-0.2.6 → notionary-0.2.8}/LICENSE +0 -0
  21. {notionary-0.2.6 → notionary-0.2.8}/notionary/__init__.py +0 -0
  22. {notionary-0.2.6 → notionary-0.2.8}/notionary/database/models/page_result.py +0 -0
  23. {notionary-0.2.6 → notionary-0.2.8}/notionary/database/notion_database.py +0 -0
  24. {notionary-0.2.6 → notionary-0.2.8}/notionary/database/notion_database_factory.py +0 -0
  25. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/audio_element.py +0 -0
  26. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/bookmark_element.py +0 -0
  27. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/bulleted_list_element.py +0 -0
  28. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/callout_element.py +0 -0
  29. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/embed_element.py +0 -0
  30. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/image_element.py +0 -0
  31. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/mention_element.py +0 -0
  32. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/notion_block_element.py +0 -0
  33. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/numbered_list_element.py +0 -0
  34. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/paragraph_element.py +0 -0
  35. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/qoute_element.py +0 -0
  36. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/table_element.py +0 -0
  37. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/text_inline_formatter.py +0 -0
  38. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/todo_element.py +0 -0
  39. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/toggle_element.py +0 -0
  40. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/toggleable_heading_element.py +0 -0
  41. {notionary-0.2.6 → notionary-0.2.8}/notionary/elements/video_element.py +0 -0
  42. {notionary-0.2.6 → notionary-0.2.8}/notionary/exceptions/database_exceptions.py +0 -0
  43. {notionary-0.2.6 → notionary-0.2.8}/notionary/exceptions/page_creation_exception.py +0 -0
  44. {notionary-0.2.6 → notionary-0.2.8}/notionary/models/notion_block_response.py +0 -0
  45. {notionary-0.2.6 → notionary-0.2.8}/notionary/models/notion_database_response.py +0 -0
  46. {notionary-0.2.6 → notionary-0.2.8}/notionary/models/notion_page_response.py +0 -0
  47. {notionary-0.2.6 → notionary-0.2.8}/notionary/notion_client.py +0 -0
  48. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/content/notion_page_content_chunker.py +0 -0
  49. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/content/page_content_retriever.py +0 -0
  50. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/metadata/metadata_editor.py +0 -0
  51. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/metadata/notion_icon_manager.py +0 -0
  52. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/metadata/notion_page_cover_manager.py +0 -0
  53. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/notion_page.py +0 -0
  54. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/notion_page_factory.py +0 -0
  55. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/notion_to_markdown_converter.py +0 -0
  56. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/properites/database_property_service.py +0 -0
  57. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/properites/page_property_manager.py +0 -0
  58. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/properites/property_formatter.py +0 -0
  59. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/properites/property_value_extractor.py +0 -0
  60. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/relations/notion_page_relation_manager.py +0 -0
  61. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/relations/notion_page_title_resolver.py +0 -0
  62. {notionary-0.2.6 → notionary-0.2.8}/notionary/page/relations/page_database_relation.py +0 -0
  63. {notionary-0.2.6 → notionary-0.2.8}/notionary/prompting/element_prompt_content.py +0 -0
  64. {notionary-0.2.6 → notionary-0.2.8}/notionary/util/logging_mixin.py +0 -0
  65. {notionary-0.2.6 → notionary-0.2.8}/notionary/util/page_id_utils.py +0 -0
  66. {notionary-0.2.6 → notionary-0.2.8}/notionary/util/warn_direct_constructor_usage.py +0 -0
  67. {notionary-0.2.6 → notionary-0.2.8}/notionary.egg-info/dependency_links.txt +0 -0
  68. {notionary-0.2.6 → notionary-0.2.8}/notionary.egg-info/requires.txt +0 -0
  69. {notionary-0.2.6 → notionary-0.2.8}/notionary.egg-info/top_level.txt +0 -0
  70. {notionary-0.2.6 → notionary-0.2.8}/setup.cfg +0 -0
@@ -0,0 +1,271 @@
1
+ Metadata-Version: 2.4
2
+ Name: notionary
3
+ Version: 0.2.8
4
+ Summary: A toolkit to convert between Markdown and Notion blocks
5
+ Home-page: https://github.com/mathisarends/notionary
6
+ Author: Mathis Arends
7
+ Author-email: mathisarends27@gmail.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Requires-Python: >=3.7
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: httpx>=0.28.0
14
+ Requires-Dist: python-dotenv>=1.1.0
15
+ Requires-Dist: pydantic>=2.11.4
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: license-file
23
+ Dynamic: requires-dist
24
+ Dynamic: requires-python
25
+ Dynamic: summary
26
+
27
+ # Notionary 📝
28
+
29
+ [![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
30
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
31
+
32
+ **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.
33
+
34
+ ---
35
+
36
+ ## Features
37
+
38
+ - **Rich Markdown Support**: Create Notion pages using intuitive Markdown syntax with custom extensions
39
+ - **Dynamic Database Operations**: Create, update, and query database entries with schema auto-detection
40
+ - **Extensible Block Registry**: Add, customize, or remove Notion block elements with a flexible registry pattern
41
+ - **LLM-Ready Prompts**: Generate system prompts explaining Markdown syntax for LLMs to create Notion content
42
+ - **Async-First Design**: Built for modern Python with full async/await support
43
+ - **Schema-Based Validation**: Automatic property validation based on database schemas
44
+ - **Intelligent Content Conversion**: Bidirectional conversion between Markdown and Notion blocks
45
+
46
+ ---
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ pip install notionary
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Quick Start
57
+
58
+ ### Creating and Managing Pages
59
+
60
+ ```python
61
+ import asyncio
62
+ from notionary import NotionPage
63
+
64
+ async def main():
65
+ # Create a page from URL
66
+ page = NotionPage.from_url("https://www.notion.so/your-page-url")
67
+
68
+ # Or find by name
69
+ page = await NotionPage.from_page_name("My Project Page")
70
+
71
+ # Update page metadata
72
+ await page.set_title("Updated Title")
73
+ await page.set_emoji_icon("🚀")
74
+ await page.set_random_gradient_cover()
75
+
76
+ # Add markdown content
77
+ markdown = """
78
+ # Project Overview
79
+
80
+ !> [💡] This page was created programmatically using Notionary.
81
+
82
+ ## Features
83
+ - **Rich** Markdown support
84
+ - Async functionality
85
+ - Custom syntax extensions
86
+
87
+ +++ Implementation Details
88
+ | Notionary uses a custom converter to transform Markdown into Notion blocks.
89
+ | This makes it easy to create rich content programmatically.
90
+ """
91
+
92
+ await page.replace_content(markdown)
93
+
94
+ if __name__ == "__main__":
95
+ asyncio.run(main())
96
+ ```
97
+
98
+ ### Working with Databases
99
+
100
+ ```python
101
+ import asyncio
102
+ from notionary import NotionDatabase, DatabaseDiscovery
103
+
104
+ async def main():
105
+ # Discover available databases
106
+ discovery = DatabaseDiscovery()
107
+ await discovery()
108
+
109
+ # Connect to a database by name
110
+ db = await NotionDatabase.from_database_name("Projects")
111
+
112
+ # Create a new page in the database
113
+ page = await db.create_blank_page()
114
+
115
+ # Set properties
116
+ await page.set_property_value_by_name("Status", "In Progress")
117
+ await page.set_property_value_by_name("Priority", "High")
118
+
119
+ # Query pages from database
120
+ async for page in db.iter_pages():
121
+ title = await page.get_title()
122
+ print(f"Page: {title}")
123
+
124
+ if __name__ == "__main__":
125
+ asyncio.run(main())
126
+ ```
127
+
128
+ ## Custom Markdown Syntax
129
+
130
+ Notionary extends standard Markdown with special syntax to support Notion-specific features:
131
+
132
+ ### Text Formatting
133
+
134
+ - Standard: `**bold**`, `*italic*`, `~~strikethrough~~`, `` `code` ``
135
+ - Links: `[text](url)`
136
+ - Quotes: `> This is a quote`
137
+ - Divider: `---`
138
+
139
+ ### Callouts
140
+
141
+ ```markdown
142
+ !> [💡] This is a default callout with the light bulb emoji
143
+ !> [🔔] This is a notification with a bell emoji
144
+ !> [⚠️] Warning: This is an important note
145
+ ```
146
+
147
+ ### Toggles
148
+
149
+ ```markdown
150
+ +++ How to use Notionary
151
+ | 1. Initialize with NotionPage
152
+ | 2. Update metadata with set_title(), set_emoji_icon(), etc.
153
+ | 3. Add content with replace_content() or append_markdown()
154
+ ```
155
+
156
+ ### Multi-Column Layout
157
+
158
+ ```markdown
159
+ ::: columns
160
+ ::: column
161
+
162
+ ## Left Column
163
+
164
+ - Item 1
165
+ - Item 2
166
+ - Item 3
167
+ :::
168
+ ::: column
169
+
170
+ ## Right Column
171
+
172
+ This text appears in the second column. Multi-column layouts are perfect for:
173
+
174
+ - Comparing features
175
+ - Creating side-by-side content
176
+ - Improving readability of wide content
177
+ :::
178
+ :::
179
+ ```
180
+
181
+ ### Code Blocks
182
+
183
+ ```python
184
+ def hello_world():
185
+ print("Hello from Notionary!")
186
+ ```
187
+
188
+ ### To-do Lists
189
+
190
+ ```markdown
191
+ - [ ] Define project scope
192
+ - [x] Create timeline
193
+ - [ ] Assign resources
194
+ ```
195
+
196
+ ### Tables
197
+
198
+ ```markdown
199
+ | Feature | Status | Priority |
200
+ | --------------- | ----------- | -------- |
201
+ | API Integration | Complete | High |
202
+ | Documentation | In Progress | Medium |
203
+ ```
204
+
205
+ ### More Elements
206
+
207
+ ```markdown
208
+ ![Caption](https://example.com/image.jpg)
209
+ @[Caption](https://youtube.com/watch?v=...)
210
+ [bookmark](https://example.com "Title" "Description")
211
+ ```
212
+
213
+ ## Block Registry & Customization
214
+
215
+ ```python
216
+ from notionary import NotionPage, BlockRegistryBuilder
217
+
218
+ # Create a custom registry with only the elements you need
219
+ custom_registry = (
220
+ BlockRegistryBuilder()
221
+ .with_headings()
222
+ .with_callouts()
223
+ .with_toggles()
224
+ .with_columns() # Include multi-column support
225
+ .with_code()
226
+ .with_todos()
227
+ .with_paragraphs()
228
+ .build()
229
+ )
230
+
231
+ # Apply this registry to a page
232
+ page = NotionPage.from_url("https://www.notion.so/your-page-url")
233
+ page.block_registry = custom_registry
234
+
235
+ # Replace content using only supported elements
236
+ await page.replace_content("# Custom heading with selected elements only")
237
+ ```
238
+
239
+ ## AI-Ready: Generate LLM Prompts
240
+
241
+ ```python
242
+ from notionary import BlockRegistryBuilder
243
+
244
+ # Create a registry with all standard elements
245
+ registry = BlockRegistryBuilder.create_full_registry()
246
+
247
+ # Generate the LLM system prompt
248
+ llm_system_prompt = registry.get_notion_markdown_syntax_prompt()
249
+ print(llm_system_prompt)
250
+ ```
251
+
252
+ ## Examples
253
+
254
+ See the `examples/` folder for:
255
+
256
+ - [Database discovery and querying](examples/database_discovery_example.py)
257
+ - [Rich page creation with Markdown](examples/page_example.py)
258
+ - [Database management](examples/database_management_example.py)
259
+ - [Iterating through database entries](examples/database_iteration_example.py)
260
+ - [Temporary usage & debugging](examples/temp.py)
261
+
262
+ ## Perfect for AI Agents and Automation
263
+
264
+ - **LLM Integration**: Generate Notion-compatible content with any LLM using the system prompt generator
265
+ - **Dynamic Content Generation**: AI agents can generate content in Markdown and render it directly as Notion pages
266
+ - **Schema-Aware Operations**: Automatically validate and format properties based on database schemas
267
+ - **Simplified API**: Clean, intuitive interface for both human developers and AI systems
268
+
269
+ ## Contributing
270
+
271
+ Contributions welcome — feel free to submit a pull request!
@@ -0,0 +1,245 @@
1
+ # Notionary 📝
2
+
3
+ [![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
4
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
5
+
6
+ **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.
7
+
8
+ ---
9
+
10
+ ## Features
11
+
12
+ - **Rich Markdown Support**: Create Notion pages using intuitive Markdown syntax with custom extensions
13
+ - **Dynamic Database Operations**: Create, update, and query database entries with schema auto-detection
14
+ - **Extensible Block Registry**: Add, customize, or remove Notion block elements with a flexible registry pattern
15
+ - **LLM-Ready Prompts**: Generate system prompts explaining Markdown syntax for LLMs to create Notion content
16
+ - **Async-First Design**: Built for modern Python with full async/await support
17
+ - **Schema-Based Validation**: Automatic property validation based on database schemas
18
+ - **Intelligent Content Conversion**: Bidirectional conversion between Markdown and Notion blocks
19
+
20
+ ---
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install notionary
26
+ ```
27
+
28
+ ---
29
+
30
+ ## Quick Start
31
+
32
+ ### Creating and Managing Pages
33
+
34
+ ```python
35
+ import asyncio
36
+ from notionary import NotionPage
37
+
38
+ async def main():
39
+ # Create a page from URL
40
+ page = NotionPage.from_url("https://www.notion.so/your-page-url")
41
+
42
+ # Or find by name
43
+ page = await NotionPage.from_page_name("My Project Page")
44
+
45
+ # Update page metadata
46
+ await page.set_title("Updated Title")
47
+ await page.set_emoji_icon("🚀")
48
+ await page.set_random_gradient_cover()
49
+
50
+ # Add markdown content
51
+ markdown = """
52
+ # Project Overview
53
+
54
+ !> [💡] This page was created programmatically using Notionary.
55
+
56
+ ## Features
57
+ - **Rich** Markdown support
58
+ - Async functionality
59
+ - Custom syntax extensions
60
+
61
+ +++ Implementation Details
62
+ | Notionary uses a custom converter to transform Markdown into Notion blocks.
63
+ | This makes it easy to create rich content programmatically.
64
+ """
65
+
66
+ await page.replace_content(markdown)
67
+
68
+ if __name__ == "__main__":
69
+ asyncio.run(main())
70
+ ```
71
+
72
+ ### Working with Databases
73
+
74
+ ```python
75
+ import asyncio
76
+ from notionary import NotionDatabase, DatabaseDiscovery
77
+
78
+ async def main():
79
+ # Discover available databases
80
+ discovery = DatabaseDiscovery()
81
+ await discovery()
82
+
83
+ # Connect to a database by name
84
+ db = await NotionDatabase.from_database_name("Projects")
85
+
86
+ # Create a new page in the database
87
+ page = await db.create_blank_page()
88
+
89
+ # Set properties
90
+ await page.set_property_value_by_name("Status", "In Progress")
91
+ await page.set_property_value_by_name("Priority", "High")
92
+
93
+ # Query pages from database
94
+ async for page in db.iter_pages():
95
+ title = await page.get_title()
96
+ print(f"Page: {title}")
97
+
98
+ if __name__ == "__main__":
99
+ asyncio.run(main())
100
+ ```
101
+
102
+ ## Custom Markdown Syntax
103
+
104
+ Notionary extends standard Markdown with special syntax to support Notion-specific features:
105
+
106
+ ### Text Formatting
107
+
108
+ - Standard: `**bold**`, `*italic*`, `~~strikethrough~~`, `` `code` ``
109
+ - Links: `[text](url)`
110
+ - Quotes: `> This is a quote`
111
+ - Divider: `---`
112
+
113
+ ### Callouts
114
+
115
+ ```markdown
116
+ !> [💡] This is a default callout with the light bulb emoji
117
+ !> [🔔] This is a notification with a bell emoji
118
+ !> [⚠️] Warning: This is an important note
119
+ ```
120
+
121
+ ### Toggles
122
+
123
+ ```markdown
124
+ +++ How to use Notionary
125
+ | 1. Initialize with NotionPage
126
+ | 2. Update metadata with set_title(), set_emoji_icon(), etc.
127
+ | 3. Add content with replace_content() or append_markdown()
128
+ ```
129
+
130
+ ### Multi-Column Layout
131
+
132
+ ```markdown
133
+ ::: columns
134
+ ::: column
135
+
136
+ ## Left Column
137
+
138
+ - Item 1
139
+ - Item 2
140
+ - Item 3
141
+ :::
142
+ ::: column
143
+
144
+ ## Right Column
145
+
146
+ This text appears in the second column. Multi-column layouts are perfect for:
147
+
148
+ - Comparing features
149
+ - Creating side-by-side content
150
+ - Improving readability of wide content
151
+ :::
152
+ :::
153
+ ```
154
+
155
+ ### Code Blocks
156
+
157
+ ```python
158
+ def hello_world():
159
+ print("Hello from Notionary!")
160
+ ```
161
+
162
+ ### To-do Lists
163
+
164
+ ```markdown
165
+ - [ ] Define project scope
166
+ - [x] Create timeline
167
+ - [ ] Assign resources
168
+ ```
169
+
170
+ ### Tables
171
+
172
+ ```markdown
173
+ | Feature | Status | Priority |
174
+ | --------------- | ----------- | -------- |
175
+ | API Integration | Complete | High |
176
+ | Documentation | In Progress | Medium |
177
+ ```
178
+
179
+ ### More Elements
180
+
181
+ ```markdown
182
+ ![Caption](https://example.com/image.jpg)
183
+ @[Caption](https://youtube.com/watch?v=...)
184
+ [bookmark](https://example.com "Title" "Description")
185
+ ```
186
+
187
+ ## Block Registry & Customization
188
+
189
+ ```python
190
+ from notionary import NotionPage, BlockRegistryBuilder
191
+
192
+ # Create a custom registry with only the elements you need
193
+ custom_registry = (
194
+ BlockRegistryBuilder()
195
+ .with_headings()
196
+ .with_callouts()
197
+ .with_toggles()
198
+ .with_columns() # Include multi-column support
199
+ .with_code()
200
+ .with_todos()
201
+ .with_paragraphs()
202
+ .build()
203
+ )
204
+
205
+ # Apply this registry to a page
206
+ page = NotionPage.from_url("https://www.notion.so/your-page-url")
207
+ page.block_registry = custom_registry
208
+
209
+ # Replace content using only supported elements
210
+ await page.replace_content("# Custom heading with selected elements only")
211
+ ```
212
+
213
+ ## AI-Ready: Generate LLM Prompts
214
+
215
+ ```python
216
+ from notionary import BlockRegistryBuilder
217
+
218
+ # Create a registry with all standard elements
219
+ registry = BlockRegistryBuilder.create_full_registry()
220
+
221
+ # Generate the LLM system prompt
222
+ llm_system_prompt = registry.get_notion_markdown_syntax_prompt()
223
+ print(llm_system_prompt)
224
+ ```
225
+
226
+ ## Examples
227
+
228
+ See the `examples/` folder for:
229
+
230
+ - [Database discovery and querying](examples/database_discovery_example.py)
231
+ - [Rich page creation with Markdown](examples/page_example.py)
232
+ - [Database management](examples/database_management_example.py)
233
+ - [Iterating through database entries](examples/database_iteration_example.py)
234
+ - [Temporary usage & debugging](examples/temp.py)
235
+
236
+ ## Perfect for AI Agents and Automation
237
+
238
+ - **LLM Integration**: Generate Notion-compatible content with any LLM using the system prompt generator
239
+ - **Dynamic Content Generation**: AI agents can generate content in Markdown and render it directly as Notion pages
240
+ - **Schema-Aware Operations**: Automatically validate and format properties based on database schemas
241
+ - **Simplified API**: Clean, intuitive interface for both human developers and AI systems
242
+
243
+ ## Contributing
244
+
245
+ Contributions welcome — feel free to submit a pull request!
@@ -26,29 +26,7 @@ class DatabaseDiscovery(LoggingMixin):
26
26
  self._client = client if client else NotionClient()
27
27
  self.logger.info("DatabaseDiscovery initialized")
28
28
 
29
- async def discover(self, page_size: int = 100) -> List[Tuple[str, str]]:
30
- """
31
- Discover all accessible databases and return their titles and IDs.
32
-
33
- Args:
34
- page_size: The number of databases to fetch per request
35
-
36
- Returns:
37
- List of tuples containing (database_title, database_id)
38
- """
39
- databases = []
40
-
41
- async for database in self._iter_databases(page_size):
42
- db_id = database.get("id")
43
- if not db_id:
44
- continue
45
-
46
- title = self._extract_database_title(database)
47
- databases.append((title, db_id))
48
-
49
- return databases
50
-
51
- async def discover_and_print(self, page_size: int = 100) -> List[Tuple[str, str]]:
29
+ async def __call__(self, page_size: int = 100) -> List[Tuple[str, str]]:
52
30
  """
53
31
  Discover databases and print the results in a nicely formatted way.
54
32
 
@@ -61,7 +39,7 @@ class DatabaseDiscovery(LoggingMixin):
61
39
  Returns:
62
40
  The same list of databases as discover() for further processing
63
41
  """
64
- databases = await self.discover(page_size)
42
+ databases = await self._discover(page_size)
65
43
 
66
44
  if not databases:
67
45
  print("\n⚠️ No databases found!")
@@ -78,6 +56,28 @@ class DatabaseDiscovery(LoggingMixin):
78
56
 
79
57
  return databases
80
58
 
59
+ async def _discover(self, page_size: int = 100) -> List[Tuple[str, str]]:
60
+ """
61
+ Discover all accessible databases and return their titles and IDs.
62
+
63
+ Args:
64
+ page_size: The number of databases to fetch per request
65
+
66
+ Returns:
67
+ List of tuples containing (database_title, database_id)
68
+ """
69
+ databases = []
70
+
71
+ async for database in self._iter_databases(page_size):
72
+ db_id = database.get("id")
73
+ if not db_id:
74
+ continue
75
+
76
+ title = self._extract_database_title(database)
77
+ databases.append((title, db_id))
78
+
79
+ return databases
80
+
81
81
  async def _iter_databases(
82
82
  self, page_size: int = 100
83
83
  ) -> AsyncGenerator[Dict[str, Any], None]: