notionary 0.2.12__py3-none-any.whl → 0.2.14__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 (86) hide show
  1. notionary/__init__.py +3 -20
  2. notionary/{notion_client.py → base_notion_client.py} +92 -98
  3. notionary/blocks/__init__.py +61 -0
  4. notionary/{elements → blocks}/audio_element.py +6 -4
  5. notionary/{elements → blocks}/bookmark_element.py +3 -6
  6. notionary/{elements → blocks}/bulleted_list_element.py +5 -7
  7. notionary/{elements → blocks}/callout_element.py +5 -8
  8. notionary/{elements → blocks}/code_block_element.py +4 -6
  9. notionary/{elements → blocks}/column_element.py +3 -6
  10. notionary/{elements → blocks}/divider_element.py +3 -6
  11. notionary/{elements → blocks}/embed_element.py +4 -6
  12. notionary/{elements → blocks}/heading_element.py +5 -9
  13. notionary/{elements → blocks}/image_element.py +4 -6
  14. notionary/{elements → blocks}/mention_element.py +3 -7
  15. notionary/blocks/notion_block_client.py +26 -0
  16. notionary/blocks/notion_block_element.py +34 -0
  17. notionary/{elements → blocks}/numbered_list_element.py +4 -7
  18. notionary/{elements → blocks}/paragraph_element.py +4 -7
  19. notionary/{prompting/element_prompt_content.py → blocks/prompts/element_prompt_builder.py} +1 -40
  20. notionary/blocks/prompts/element_prompt_content.py +41 -0
  21. notionary/{elements → blocks}/qoute_element.py +4 -6
  22. notionary/{elements → blocks}/registry/block_registry.py +4 -26
  23. notionary/{elements → blocks}/registry/block_registry_builder.py +26 -25
  24. notionary/{elements → blocks}/table_element.py +6 -8
  25. notionary/{elements → blocks}/text_inline_formatter.py +1 -4
  26. notionary/{elements → blocks}/todo_element.py +6 -8
  27. notionary/{elements → blocks}/toggle_element.py +3 -6
  28. notionary/{elements → blocks}/toggleable_heading_element.py +5 -8
  29. notionary/{elements → blocks}/video_element.py +4 -6
  30. notionary/cli/main.py +245 -53
  31. notionary/cli/onboarding.py +117 -0
  32. notionary/database/__init__.py +0 -0
  33. notionary/database/client.py +132 -0
  34. notionary/database/database_exceptions.py +13 -0
  35. notionary/database/factory.py +0 -0
  36. notionary/database/filter_builder.py +175 -0
  37. notionary/database/notion_database.py +339 -128
  38. notionary/database/notion_database_provider.py +230 -0
  39. notionary/elements/__init__.py +0 -0
  40. notionary/models/notion_database_response.py +294 -13
  41. notionary/models/notion_page_response.py +9 -31
  42. notionary/models/search_response.py +0 -0
  43. notionary/page/__init__.py +0 -0
  44. notionary/page/client.py +110 -0
  45. notionary/page/content/page_content_retriever.py +5 -20
  46. notionary/page/content/page_content_writer.py +3 -4
  47. notionary/page/formatting/markdown_to_notion_converter.py +1 -3
  48. notionary/{prompting → page}/markdown_syntax_prompt_generator.py +1 -2
  49. notionary/page/notion_page.py +354 -317
  50. notionary/page/notion_to_markdown_converter.py +1 -4
  51. notionary/page/properites/property_value_extractor.py +0 -64
  52. notionary/page/{properites/property_formatter.py → property_formatter.py} +7 -4
  53. notionary/page/search_filter_builder.py +131 -0
  54. notionary/page/utils.py +60 -0
  55. notionary/util/__init__.py +12 -3
  56. notionary/util/factory_decorator.py +33 -0
  57. notionary/util/fuzzy_matcher.py +82 -0
  58. notionary/util/page_id_utils.py +0 -21
  59. notionary/util/singleton_metaclass.py +22 -0
  60. notionary/workspace.py +69 -0
  61. {notionary-0.2.12.dist-info → notionary-0.2.14.dist-info}/METADATA +4 -1
  62. notionary-0.2.14.dist-info/RECORD +72 -0
  63. notionary/database/database_discovery.py +0 -142
  64. notionary/database/notion_database_factory.py +0 -193
  65. notionary/elements/notion_block_element.py +0 -70
  66. notionary/exceptions/database_exceptions.py +0 -76
  67. notionary/exceptions/page_creation_exception.py +0 -9
  68. notionary/page/metadata/metadata_editor.py +0 -150
  69. notionary/page/metadata/notion_icon_manager.py +0 -77
  70. notionary/page/metadata/notion_page_cover_manager.py +0 -56
  71. notionary/page/notion_page_factory.py +0 -332
  72. notionary/page/properites/database_property_service.py +0 -302
  73. notionary/page/properites/page_property_manager.py +0 -152
  74. notionary/page/relations/notion_page_relation_manager.py +0 -350
  75. notionary/page/relations/notion_page_title_resolver.py +0 -104
  76. notionary/page/relations/page_database_relation.py +0 -68
  77. notionary/telemetry/__init__.py +0 -7
  78. notionary/telemetry/telemetry.py +0 -226
  79. notionary/telemetry/track_usage_decorator.py +0 -76
  80. notionary/util/warn_direct_constructor_usage.py +0 -54
  81. notionary-0.2.12.dist-info/RECORD +0 -70
  82. /notionary/util/{singleton.py → singleton_decorator.py} +0 -0
  83. {notionary-0.2.12.dist-info → notionary-0.2.14.dist-info}/WHEEL +0 -0
  84. {notionary-0.2.12.dist-info → notionary-0.2.14.dist-info}/entry_points.txt +0 -0
  85. {notionary-0.2.12.dist-info → notionary-0.2.14.dist-info}/licenses/LICENSE +0 -0
  86. {notionary-0.2.12.dist-info → notionary-0.2.14.dist-info}/top_level.txt +0 -0
@@ -1,13 +1,10 @@
1
1
  import re
2
2
  from typing import Dict, Any, Optional
3
- from notionary.elements.notion_block_element import NotionBlockElement, auto_track_conversions
4
- from notionary.prompting.element_prompt_content import (
5
- ElementPromptBuilder,
6
- ElementPromptContent,
7
- )
8
- from notionary.elements.text_inline_formatter import TextInlineFormatter
3
+ from notionary.blocks import NotionBlockElement
4
+ from notionary.blocks import ElementPromptContent, ElementPromptBuilder
5
+ from notionary.blocks.text_inline_formatter import TextInlineFormatter
6
+
9
7
 
10
- @auto_track_conversions
11
8
  class NumberedListElement(NotionBlockElement):
12
9
  """Class for converting between Markdown numbered lists and Notion numbered list items."""
13
10
 
@@ -1,13 +1,10 @@
1
1
  from typing import Dict, Any, Optional
2
2
 
3
- from notionary.elements.notion_block_element import NotionBlockElement, auto_track_conversions
4
- from notionary.prompting.element_prompt_content import (
5
- ElementPromptBuilder,
6
- ElementPromptContent,
7
- )
8
- from notionary.elements.text_inline_formatter import TextInlineFormatter
3
+ from notionary.blocks import NotionBlockElement
4
+ from notionary.blocks import ElementPromptContent, ElementPromptBuilder
5
+ from notionary.blocks.text_inline_formatter import TextInlineFormatter
6
+
9
7
 
10
- @auto_track_conversions
11
8
  class ParagraphElement(NotionBlockElement):
12
9
  """Handles conversion between Markdown paragraphs and Notion paragraph blocks."""
13
10
 
@@ -1,44 +1,5 @@
1
- from dataclasses import field, dataclass
2
1
  from typing import Optional, List, Self
3
-
4
-
5
- @dataclass
6
- class ElementPromptContent:
7
- """
8
- Dataclass defining the standardized structure for element prompt content.
9
- This ensures consistent formatting across all Notion block elements.
10
- """
11
-
12
- description: str
13
- """Concise explanation of what the element is and its purpose in Notion."""
14
-
15
- syntax: str
16
- """The exact markdown syntax pattern used to create this element."""
17
-
18
- when_to_use: str
19
- """Guidelines explaining the appropriate scenarios for using this element."""
20
-
21
- examples: List[str] = field(default_factory=list)
22
- """List of practical usage examples showing the element in context."""
23
-
24
- avoid: Optional[str] = None
25
- """Optional field listing scenarios when this element should be avoided."""
26
-
27
- is_standard_markdown: bool = False
28
- """Indicates whether this element follows standard Markdown syntax (and does not require full examples)."""
29
-
30
- def __post_init__(self):
31
- """Validates that the content meets minimum requirements."""
32
- if not self.description:
33
- raise ValueError("Description is required")
34
- if not self.syntax:
35
- raise ValueError("Syntax is required")
36
- if not self.examples and not self.is_standard_markdown:
37
- raise ValueError(
38
- "At least one example is required unless it's standard markdown."
39
- )
40
- if not self.when_to_use:
41
- raise ValueError("Usage guidelines are required")
2
+ from notionary.blocks.prompts.element_prompt_content import ElementPromptContent
42
3
 
43
4
 
44
5
  class ElementPromptBuilder:
@@ -0,0 +1,41 @@
1
+ from dataclasses import field, dataclass
2
+ from typing import Optional, List
3
+
4
+
5
+ @dataclass
6
+ class ElementPromptContent:
7
+ """
8
+ Dataclass defining the standardized structure for element prompt content.
9
+ This ensures consistent formatting across all Notion block elements.
10
+ """
11
+
12
+ description: str
13
+ """Concise explanation of what the element is and its purpose in Notion."""
14
+
15
+ syntax: str
16
+ """The exact markdown syntax pattern used to create this element."""
17
+
18
+ when_to_use: str
19
+ """Guidelines explaining the appropriate scenarios for using this element."""
20
+
21
+ examples: List[str] = field(default_factory=list)
22
+ """List of practical usage examples showing the element in context."""
23
+
24
+ avoid: Optional[str] = None
25
+ """Optional field listing scenarios when this element should be avoided."""
26
+
27
+ is_standard_markdown: bool = False
28
+ """Indicates whether this element follows standard Markdown syntax (and does not require full examples)."""
29
+
30
+ def __post_init__(self):
31
+ """Validates that the content meets minimum requirements."""
32
+ if not self.description:
33
+ raise ValueError("Description is required")
34
+ if not self.syntax:
35
+ raise ValueError("Syntax is required")
36
+ if not self.examples and not self.is_standard_markdown:
37
+ raise ValueError(
38
+ "At least one example is required unless it's standard markdown."
39
+ )
40
+ if not self.when_to_use:
41
+ raise ValueError("Usage guidelines are required")
@@ -1,12 +1,10 @@
1
1
  import re
2
2
  from typing import Dict, Any, Optional, List, Tuple
3
- from notionary.elements.notion_block_element import NotionBlockElement, auto_track_conversions
4
- from notionary.prompting.element_prompt_content import (
5
- ElementPromptBuilder,
6
- ElementPromptContent,
7
- )
8
3
 
9
- @auto_track_conversions
4
+ from notionary.blocks import NotionBlockElement
5
+ from notionary.blocks import ElementPromptContent, ElementPromptBuilder
6
+
7
+
10
8
  class QuoteElement(NotionBlockElement):
11
9
  """Class for converting between Markdown blockquotes and Notion quote blocks."""
12
10
 
@@ -1,13 +1,13 @@
1
1
  from __future__ import annotations
2
2
  from typing import Dict, Any, Optional, List, Set, Type
3
3
 
4
- from notionary.elements.notion_block_element import NotionBlockElement
5
- from notionary.prompting.markdown_syntax_prompt_generator import (
4
+ from notionary.blocks.notion_block_element import NotionBlockElement
5
+ from notionary.page.markdown_syntax_prompt_generator import (
6
6
  MarkdownSyntaxPromptGenerator,
7
7
  )
8
- from notionary.elements.text_inline_formatter import TextInlineFormatter
8
+ from notionary.blocks.text_inline_formatter import TextInlineFormatter
9
9
 
10
- from notionary.elements.notion_block_element import NotionBlockElement
10
+ from notionary.blocks import NotionBlockElement
11
11
 
12
12
 
13
13
  class BlockRegistry:
@@ -28,28 +28,6 @@ class BlockRegistry:
28
28
  for element in elements:
29
29
  self.register(element)
30
30
 
31
- def to_builder(self):
32
- """
33
- Convert this registry to a builder for modifications.
34
- Imports only when needed to avoid circular imports.
35
- """
36
- from notionary.elements.registry.block_registry_builder import (
37
- BlockRegistryBuilder,
38
- )
39
-
40
- builder = BlockRegistryBuilder()
41
- for element in self._elements:
42
- builder.add_element(element)
43
- return builder
44
-
45
- @property
46
- def builder(self):
47
- """
48
- Returns a new builder pre-configured with the current registry elements.
49
- Uses lazy import to avoid circular dependencies.
50
- """
51
- return self.to_builder()
52
-
53
31
  def register(self, element_class: Type[NotionBlockElement]) -> bool:
54
32
  """
55
33
  Register an element class.
@@ -1,33 +1,32 @@
1
1
  from __future__ import annotations
2
- from typing import List, Type
2
+ from typing import List, Type, TYPE_CHECKING
3
3
  from collections import OrderedDict
4
4
 
5
- from notionary.elements.column_element import ColumnElement
6
- from notionary.elements.notion_block_element import NotionBlockElement
7
-
8
- from notionary.elements.audio_element import AudioElement
9
- from notionary.elements.bulleted_list_element import BulletedListElement
10
- from notionary.elements.embed_element import EmbedElement
11
- from notionary.elements.mention_element import MentionElement
12
- from notionary.elements.notion_block_element import NotionBlockElement
13
- from notionary.elements.numbered_list_element import NumberedListElement
14
- from notionary.elements.registry.block_registry import (
15
- BlockRegistry,
5
+ from notionary.blocks import (
6
+ ParagraphElement,
7
+ AudioElement,
8
+ BulletedListElement,
9
+ CalloutElement,
10
+ CodeBlockElement,
11
+ ColumnElement,
12
+ DividerElement,
13
+ EmbedElement,
14
+ HeadingElement,
15
+ ImageElement,
16
+ MentionElement,
17
+ NumberedListElement,
18
+ TableElement,
19
+ TodoElement,
20
+ ToggleElement,
21
+ ToggleableHeadingElement,
22
+ VideoElement,
23
+ BookmarkElement,
24
+ QuoteElement,
25
+ NotionBlockElement,
16
26
  )
17
27
 
18
- from notionary.elements.paragraph_element import ParagraphElement
19
- from notionary.elements.heading_element import HeadingElement
20
- from notionary.elements.callout_element import CalloutElement
21
- from notionary.elements.code_block_element import CodeBlockElement
22
- from notionary.elements.divider_element import DividerElement
23
- from notionary.elements.table_element import TableElement
24
- from notionary.elements.todo_element import TodoElement
25
- from notionary.elements.qoute_element import QuoteElement
26
- from notionary.elements.image_element import ImageElement
27
- from notionary.elements.toggleable_heading_element import ToggleableHeadingElement
28
- from notionary.elements.video_element import VideoElement
29
- from notionary.elements.toggle_element import ToggleElement
30
- from notionary.elements.bookmark_element import BookmarkElement
28
+ if TYPE_CHECKING:
29
+ from notionary.blocks import BlockRegistry
31
30
 
32
31
 
33
32
  class BlockRegistryBuilder:
@@ -281,6 +280,8 @@ class BlockRegistryBuilder:
281
280
  Returns:
282
281
  A configured BlockRegistry instance
283
282
  """
283
+ from notionary.blocks import BlockRegistry
284
+
284
285
  if ParagraphElement.__name__ not in self._elements:
285
286
  self.add_element(ParagraphElement)
286
287
  else:
@@ -1,13 +1,11 @@
1
1
  import re
2
2
  from typing import Dict, Any, Optional, List, Tuple
3
- from notionary.elements.notion_block_element import NotionBlockElement, auto_track_conversions
4
- from notionary.elements.text_inline_formatter import TextInlineFormatter
5
- from notionary.prompting.element_prompt_content import (
6
- ElementPromptBuilder,
7
- ElementPromptContent,
8
- )
9
-
10
- @auto_track_conversions
3
+
4
+ from notionary.blocks import NotionBlockElement
5
+ from notionary.blocks.text_inline_formatter import TextInlineFormatter
6
+ from notionary.blocks import ElementPromptContent, ElementPromptBuilder
7
+
8
+
11
9
  class TableElement(NotionBlockElement):
12
10
  """
13
11
  Handles conversion between Markdown tables and Notion table blocks.
@@ -1,10 +1,7 @@
1
1
  from typing import Dict, Any, List, Tuple
2
2
  import re
3
3
 
4
- from notionary.prompting.element_prompt_content import (
5
- ElementPromptBuilder,
6
- ElementPromptContent,
7
- )
4
+ from notionary.blocks import ElementPromptBuilder, ElementPromptContent
8
5
 
9
6
 
10
7
  class TextInlineFormatter:
@@ -1,13 +1,11 @@
1
1
  import re
2
2
  from typing import Dict, Any, Optional
3
- from notionary.elements.notion_block_element import NotionBlockElement, auto_track_conversions
4
- from notionary.prompting.element_prompt_content import (
5
- ElementPromptBuilder,
6
- ElementPromptContent,
7
- )
8
- from notionary.elements.text_inline_formatter import TextInlineFormatter
9
-
10
- @auto_track_conversions
3
+
4
+ from notionary.blocks import NotionBlockElement
5
+ from notionary.blocks import ElementPromptContent, ElementPromptBuilder
6
+ from notionary.blocks.text_inline_formatter import TextInlineFormatter
7
+
8
+
11
9
  class TodoElement(NotionBlockElement):
12
10
  """
13
11
  Handles conversion between Markdown todo items and Notion to_do blocks.
@@ -1,13 +1,10 @@
1
1
  import re
2
2
  from typing import Dict, Any, Optional, List, Tuple, Callable
3
3
 
4
- from notionary.elements.notion_block_element import NotionBlockElement, auto_track_conversions
5
- from notionary.prompting.element_prompt_content import (
6
- ElementPromptBuilder,
7
- ElementPromptContent,
8
- )
4
+ from notionary.blocks import NotionBlockElement
5
+ from notionary.blocks import ElementPromptContent, ElementPromptBuilder
6
+
9
7
 
10
- @auto_track_conversions
11
8
  class ToggleElement(NotionBlockElement):
12
9
  """
13
10
  Improved ToggleElement class using pipe syntax instead of indentation.
@@ -1,14 +1,11 @@
1
1
  import re
2
2
  from typing import Dict, Any, Optional, List, Tuple, Callable
3
3
 
4
- from notionary.elements.notion_block_element import NotionBlockElement, auto_track_conversions
5
- from notionary.prompting.element_prompt_content import (
6
- ElementPromptBuilder,
7
- ElementPromptContent,
8
- )
9
- from notionary.elements.text_inline_formatter import TextInlineFormatter
10
-
11
- @auto_track_conversions
4
+ from notionary.blocks import NotionBlockElement
5
+ from notionary.blocks import ElementPromptContent, ElementPromptBuilder
6
+ from notionary.blocks.text_inline_formatter import TextInlineFormatter
7
+
8
+
12
9
  class ToggleableHeadingElement(NotionBlockElement):
13
10
  """Handles conversion between Markdown collapsible headings and Notion toggleable heading blocks with pipe syntax."""
14
11
 
@@ -1,12 +1,10 @@
1
1
  import re
2
2
  from typing import Dict, Any, Optional, List
3
- from notionary.elements.notion_block_element import NotionBlockElement, auto_track_conversions
4
- from notionary.prompting.element_prompt_content import (
5
- ElementPromptBuilder,
6
- ElementPromptContent,
7
- )
8
3
 
9
- @auto_track_conversions
4
+ from notionary.blocks import NotionBlockElement
5
+ from notionary.blocks import ElementPromptContent, ElementPromptBuilder
6
+
7
+
10
8
  class VideoElement(NotionBlockElement):
11
9
  """
12
10
  Handles conversion between Markdown video embeds and Notion video blocks.