notionary 0.1.6__py3-none-any.whl → 0.1.7__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.
Files changed (28) hide show
  1. notionary/core/database/notion_database_manager.py +146 -232
  2. notionary/core/database/notion_database_manager_factory.py +9 -52
  3. notionary/core/database/notion_database_schema.py +1 -314
  4. notionary/core/notion_client.py +2 -10
  5. notionary/core/page/{page_content_manager.py → content/page_content_manager.py} +0 -1
  6. notionary/core/page/metadata/metadata_editor.py +109 -0
  7. notionary/core/page/metadata/notion_icon_manager.py +46 -0
  8. notionary/core/page/{meta_data/metadata_editor.py → metadata/notion_page_cover_manager.py} +20 -30
  9. notionary/core/page/notion_page_manager.py +218 -59
  10. notionary/core/page/properites/database_property_service.py +330 -0
  11. notionary/core/page/properites/page_property_manager.py +146 -0
  12. notionary/core/page/{property_formatter.py → properites/property_formatter.py} +19 -20
  13. notionary/core/page/properites/property_operation_result.py +103 -0
  14. notionary/core/page/properites/property_value_extractor.py +46 -0
  15. notionary/core/page/relations/notion_page_relation_manager.py +364 -0
  16. notionary/core/page/relations/notion_page_title_resolver.py +43 -0
  17. notionary/core/page/relations/page_database_relation.py +70 -0
  18. notionary/core/page/relations/relation_operation_result.py +135 -0
  19. notionary/util/{uuid_utils.py → page_id_utils.py} +15 -0
  20. {notionary-0.1.6.dist-info → notionary-0.1.7.dist-info}/METADATA +1 -1
  21. {notionary-0.1.6.dist-info → notionary-0.1.7.dist-info}/RECORD +24 -18
  22. notionary/core/database/database_query_service.py +0 -73
  23. notionary/core/database/database_schema_service.py +0 -57
  24. notionary/core/database/notion_database_writer.py +0 -390
  25. notionary/core/database/page_service.py +0 -161
  26. {notionary-0.1.6.dist-info → notionary-0.1.7.dist-info}/WHEEL +0 -0
  27. {notionary-0.1.6.dist-info → notionary-0.1.7.dist-info}/licenses/LICENSE +0 -0
  28. {notionary-0.1.6.dist-info → notionary-0.1.7.dist-info}/top_level.txt +0 -0
@@ -1,161 +0,0 @@
1
- from typing import Dict, Optional, Any, List, Union, TYPE_CHECKING
2
- from notionary.core.database.models.page_result import PageResult
3
- from notionary.core.database.notion_database_schema import NotionDatabaseSchema
4
- from notionary.core.database.notion_database_writer import DatabaseWritter
5
- from notionary.core.notion_client import NotionClient
6
-
7
- from notionary.core.page.notion_page_manager import NotionPageManager
8
- from notionary.exceptions.database_exceptions import (
9
- PageNotFoundException,
10
- PageOperationError,
11
- )
12
- from notionary.exceptions.page_creation_exception import PageCreationException
13
- from notionary.util.uuid_utils import format_uuid
14
-
15
-
16
- class DatabasePageService:
17
- """Service für den Umgang mit Datenbankseiten"""
18
-
19
- def __init__(
20
- self,
21
- client: NotionClient,
22
- schema: NotionDatabaseSchema,
23
- writer: DatabaseWritter,
24
- ):
25
- self._client = client
26
- self._schema = schema
27
- self._writer = writer
28
-
29
- def _format_page_id(self, page_id: str) -> str:
30
- """
31
- Format a page ID to ensure it's in the correct format.
32
-
33
- Args:
34
- page_id: The page ID to format
35
-
36
- Returns:
37
- The formatted page ID
38
- """
39
- return format_uuid(page_id) or page_id
40
-
41
- async def create_page(
42
- self,
43
- database_id: str,
44
- properties: Dict[str, Any],
45
- relations: Optional[Dict[str, Union[str, List[str]]]] = None,
46
- ) -> PageResult:
47
- """
48
- Create a new page in the database.
49
-
50
- Args:
51
- database_id: The database ID to create the page in
52
- properties: Dictionary of property names and values
53
- relations: Optional dictionary of relation property names and titles
54
-
55
- Returns:
56
- Result object with success status and page information
57
- """
58
- try:
59
- response = await self._writer.create_page(
60
- database_id, properties, relations
61
- )
62
-
63
- if not response:
64
- return {
65
- "success": False,
66
- "message": f"Failed to create page in database {database_id}",
67
- }
68
-
69
- page_id = response.get("id", "")
70
- page_url = response.get("url", None)
71
-
72
- return {"success": True, "page_id": page_id, "url": page_url}
73
-
74
- except PageCreationException as e:
75
- return {"success": False, "message": str(e)}
76
-
77
- async def update_page(
78
- self,
79
- page_id: str,
80
- properties: Optional[Dict[str, Any]] = None,
81
- relations: Optional[Dict[str, Union[str, List[str]]]] = None,
82
- ) -> PageResult:
83
- """
84
- Update an existing page.
85
-
86
- Args:
87
- page_id: The ID of the page to update
88
- properties: Dictionary of property names and values to update
89
- relations: Optional dictionary of relation property names and titles
90
-
91
- Returns:
92
- Result object with success status and message
93
- """
94
- try:
95
- formatted_page_id = self._format_page_id(page_id)
96
-
97
- response = await self._writer.update_page(
98
- formatted_page_id, properties, relations
99
- )
100
-
101
- if not response:
102
- return {
103
- "success": False,
104
- "message": f"Failed to update page {formatted_page_id}",
105
- }
106
-
107
- return {"success": True, "page_id": formatted_page_id}
108
-
109
- except PageOperationError as e:
110
- return {"success": False, "message": f"Error: {str(e)}"}
111
-
112
- async def delete_page(self, page_id: str) -> PageResult:
113
- """
114
- Delete (archive) a page.
115
-
116
- Args:
117
- page_id: The ID of the page to delete
118
-
119
- Returns:
120
- Result object with success status and message
121
- """
122
- try:
123
- formatted_page_id = self._format_page_id(page_id)
124
-
125
- success = await self._writer.delete_page(formatted_page_id)
126
-
127
- if not success:
128
- return {
129
- "success": False,
130
- "message": f"Failed to delete page {formatted_page_id}",
131
- }
132
-
133
- return {"success": True, "page_id": formatted_page_id}
134
-
135
- except PageOperationError as e:
136
- return {"success": False, "message": f"Error: {str(e)}"}
137
-
138
- async def get_page_manager(self, page_id: str) -> Optional[NotionPageManager]:
139
- """
140
- Get a NotionPageManager for a specific page.
141
-
142
- Args:
143
- page_id: The ID of the page
144
-
145
- Returns:
146
- NotionPageManager instance or None if the page wasn't found
147
- """
148
- formatted_page_id = self._format_page_id(page_id)
149
-
150
- try:
151
- page_data = await self._client.get(f"pages/{formatted_page_id}")
152
-
153
- if not page_data:
154
- return None
155
-
156
- return NotionPageManager(
157
- page_id=formatted_page_id, url=page_data.get("url")
158
- )
159
-
160
- except PageNotFoundException:
161
- return None