notionary 0.2.13__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.
- notionary/__init__.py +3 -16
- notionary/{notion_client.py → base_notion_client.py} +92 -98
- notionary/blocks/__init__.py +61 -0
- notionary/{elements → blocks}/audio_element.py +6 -3
- notionary/{elements → blocks}/bookmark_element.py +3 -5
- notionary/{elements → blocks}/bulleted_list_element.py +5 -6
- notionary/{elements → blocks}/callout_element.py +4 -6
- notionary/{elements → blocks}/code_block_element.py +4 -5
- notionary/{elements → blocks}/column_element.py +3 -5
- notionary/{elements → blocks}/divider_element.py +3 -5
- notionary/{elements → blocks}/embed_element.py +4 -5
- notionary/{elements → blocks}/heading_element.py +4 -7
- notionary/{elements → blocks}/image_element.py +4 -5
- notionary/{elements → blocks}/mention_element.py +3 -6
- notionary/blocks/notion_block_client.py +26 -0
- notionary/{elements → blocks}/notion_block_element.py +2 -3
- notionary/{elements → blocks}/numbered_list_element.py +4 -6
- notionary/{elements → blocks}/paragraph_element.py +4 -6
- notionary/{prompting/element_prompt_content.py → blocks/prompts/element_prompt_builder.py} +1 -40
- notionary/blocks/prompts/element_prompt_content.py +41 -0
- notionary/{elements → blocks}/qoute_element.py +4 -5
- notionary/{elements → blocks}/registry/block_registry.py +4 -26
- notionary/{elements → blocks}/registry/block_registry_builder.py +26 -25
- notionary/{elements → blocks}/table_element.py +5 -6
- notionary/{elements → blocks}/text_inline_formatter.py +1 -4
- notionary/{elements → blocks}/todo_element.py +5 -6
- notionary/{elements → blocks}/toggle_element.py +3 -5
- notionary/{elements → blocks}/toggleable_heading_element.py +4 -6
- notionary/{elements → blocks}/video_element.py +4 -5
- notionary/cli/main.py +157 -128
- notionary/cli/onboarding.py +10 -9
- notionary/database/__init__.py +0 -0
- notionary/database/client.py +132 -0
- notionary/database/database_exceptions.py +13 -0
- notionary/database/factory.py +0 -0
- notionary/database/filter_builder.py +175 -0
- notionary/database/notion_database.py +339 -126
- notionary/database/notion_database_provider.py +230 -0
- notionary/elements/__init__.py +0 -0
- notionary/models/notion_database_response.py +294 -13
- notionary/models/notion_page_response.py +9 -31
- notionary/models/search_response.py +0 -0
- notionary/page/__init__.py +0 -0
- notionary/page/client.py +110 -0
- notionary/page/content/page_content_retriever.py +5 -20
- notionary/page/content/page_content_writer.py +3 -4
- notionary/page/formatting/markdown_to_notion_converter.py +1 -3
- notionary/{prompting → page}/markdown_syntax_prompt_generator.py +1 -2
- notionary/page/notion_page.py +354 -317
- notionary/page/notion_to_markdown_converter.py +1 -4
- notionary/page/properites/property_value_extractor.py +0 -64
- notionary/page/{properites/property_formatter.py → property_formatter.py} +7 -4
- notionary/page/search_filter_builder.py +131 -0
- notionary/page/utils.py +60 -0
- notionary/util/__init__.py +12 -3
- notionary/util/factory_decorator.py +33 -0
- notionary/util/fuzzy_matcher.py +82 -0
- notionary/util/page_id_utils.py +0 -21
- notionary/util/singleton_metaclass.py +22 -0
- notionary/workspace.py +69 -0
- {notionary-0.2.13.dist-info → notionary-0.2.14.dist-info}/METADATA +4 -1
- notionary-0.2.14.dist-info/RECORD +72 -0
- notionary/database/database_discovery.py +0 -142
- notionary/database/notion_database_factory.py +0 -190
- notionary/exceptions/database_exceptions.py +0 -76
- notionary/exceptions/page_creation_exception.py +0 -9
- notionary/page/metadata/metadata_editor.py +0 -150
- notionary/page/metadata/notion_icon_manager.py +0 -77
- notionary/page/metadata/notion_page_cover_manager.py +0 -56
- notionary/page/notion_page_factory.py +0 -328
- notionary/page/properites/database_property_service.py +0 -302
- notionary/page/properites/page_property_manager.py +0 -152
- notionary/page/relations/notion_page_relation_manager.py +0 -350
- notionary/page/relations/notion_page_title_resolver.py +0 -104
- notionary/page/relations/page_database_relation.py +0 -68
- notionary/util/warn_direct_constructor_usage.py +0 -54
- notionary-0.2.13.dist-info/RECORD +0 -67
- /notionary/util/{singleton.py → singleton_decorator.py} +0 -0
- {notionary-0.2.13.dist-info → notionary-0.2.14.dist-info}/WHEEL +0 -0
- {notionary-0.2.13.dist-info → notionary-0.2.14.dist-info}/entry_points.txt +0 -0
- {notionary-0.2.13.dist-info → notionary-0.2.14.dist-info}/licenses/LICENSE +0 -0
- {notionary-0.2.13.dist-info → notionary-0.2.14.dist-info}/top_level.txt +0 -0
@@ -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,10 +1,9 @@
|
|
1
1
|
import re
|
2
2
|
from typing import Dict, Any, Optional, List, Tuple
|
3
|
-
|
4
|
-
from notionary.
|
5
|
-
|
6
|
-
|
7
|
-
)
|
3
|
+
|
4
|
+
from notionary.blocks import NotionBlockElement
|
5
|
+
from notionary.blocks import ElementPromptContent, ElementPromptBuilder
|
6
|
+
|
8
7
|
|
9
8
|
class QuoteElement(NotionBlockElement):
|
10
9
|
"""Class for converting between Markdown blockquotes and Notion quote blocks."""
|
@@ -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.
|
5
|
-
from notionary.
|
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.
|
8
|
+
from notionary.blocks.text_inline_formatter import TextInlineFormatter
|
9
9
|
|
10
|
-
from notionary.
|
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.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
19
|
-
from notionary.
|
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,11 +1,10 @@
|
|
1
1
|
import re
|
2
2
|
from typing import Dict, Any, Optional, List, Tuple
|
3
|
-
|
4
|
-
from notionary.
|
5
|
-
from notionary.
|
6
|
-
|
7
|
-
|
8
|
-
)
|
3
|
+
|
4
|
+
from notionary.blocks import NotionBlockElement
|
5
|
+
from notionary.blocks.text_inline_formatter import TextInlineFormatter
|
6
|
+
from notionary.blocks import ElementPromptContent, ElementPromptBuilder
|
7
|
+
|
9
8
|
|
10
9
|
class TableElement(NotionBlockElement):
|
11
10
|
"""
|
@@ -1,10 +1,7 @@
|
|
1
1
|
from typing import Dict, Any, List, Tuple
|
2
2
|
import re
|
3
3
|
|
4
|
-
from notionary.
|
5
|
-
ElementPromptBuilder,
|
6
|
-
ElementPromptContent,
|
7
|
-
)
|
4
|
+
from notionary.blocks import ElementPromptBuilder, ElementPromptContent
|
8
5
|
|
9
6
|
|
10
7
|
class TextInlineFormatter:
|
@@ -1,11 +1,10 @@
|
|
1
1
|
import re
|
2
2
|
from typing import Dict, Any, Optional
|
3
|
-
|
4
|
-
from notionary.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
from notionary.elements.text_inline_formatter import TextInlineFormatter
|
3
|
+
|
4
|
+
from notionary.blocks import NotionBlockElement
|
5
|
+
from notionary.blocks import ElementPromptContent, ElementPromptBuilder
|
6
|
+
from notionary.blocks.text_inline_formatter import TextInlineFormatter
|
7
|
+
|
9
8
|
|
10
9
|
class TodoElement(NotionBlockElement):
|
11
10
|
"""
|
@@ -1,11 +1,9 @@
|
|
1
1
|
import re
|
2
2
|
from typing import Dict, Any, Optional, List, Tuple, Callable
|
3
3
|
|
4
|
-
from notionary.
|
5
|
-
from notionary.
|
6
|
-
|
7
|
-
ElementPromptContent,
|
8
|
-
)
|
4
|
+
from notionary.blocks import NotionBlockElement
|
5
|
+
from notionary.blocks import ElementPromptContent, ElementPromptBuilder
|
6
|
+
|
9
7
|
|
10
8
|
class ToggleElement(NotionBlockElement):
|
11
9
|
"""
|
@@ -1,12 +1,10 @@
|
|
1
1
|
import re
|
2
2
|
from typing import Dict, Any, Optional, List, Tuple, Callable
|
3
3
|
|
4
|
-
from notionary.
|
5
|
-
from notionary.
|
6
|
-
|
7
|
-
|
8
|
-
)
|
9
|
-
from notionary.elements.text_inline_formatter import TextInlineFormatter
|
4
|
+
from notionary.blocks import NotionBlockElement
|
5
|
+
from notionary.blocks import ElementPromptContent, ElementPromptBuilder
|
6
|
+
from notionary.blocks.text_inline_formatter import TextInlineFormatter
|
7
|
+
|
10
8
|
|
11
9
|
class ToggleableHeadingElement(NotionBlockElement):
|
12
10
|
"""Handles conversion between Markdown collapsible headings and Notion toggleable heading blocks with pipe syntax."""
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import re
|
2
2
|
from typing import Dict, Any, Optional, List
|
3
|
-
|
4
|
-
from notionary.
|
5
|
-
|
6
|
-
|
7
|
-
)
|
3
|
+
|
4
|
+
from notionary.blocks import NotionBlockElement
|
5
|
+
from notionary.blocks import ElementPromptContent, ElementPromptBuilder
|
6
|
+
|
8
7
|
|
9
8
|
class VideoElement(NotionBlockElement):
|
10
9
|
"""
|