notionary 0.3.1__py3-none-any.whl → 0.4.0__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 +6 -1
- notionary/blocks/enums.py +0 -6
- notionary/blocks/schemas.py +32 -78
- notionary/comments/schemas.py +2 -29
- notionary/data_source/properties/schemas.py +128 -107
- notionary/data_source/schemas.py +2 -2
- notionary/data_source/service.py +32 -23
- notionary/database/schemas.py +2 -2
- notionary/database/service.py +3 -5
- notionary/exceptions/__init__.py +6 -2
- notionary/exceptions/api.py +2 -2
- notionary/exceptions/base.py +1 -1
- notionary/exceptions/block_parsing.py +3 -3
- notionary/exceptions/data_source/builder.py +2 -2
- notionary/exceptions/data_source/properties.py +3 -3
- notionary/exceptions/file_upload.py +67 -0
- notionary/exceptions/properties.py +4 -4
- notionary/exceptions/search.py +4 -4
- notionary/file_upload/__init__.py +4 -0
- notionary/file_upload/client.py +124 -210
- notionary/file_upload/config/__init__.py +17 -0
- notionary/file_upload/config/config.py +32 -0
- notionary/file_upload/config/constants.py +16 -0
- notionary/file_upload/file/reader.py +28 -0
- notionary/file_upload/query/__init__.py +7 -0
- notionary/file_upload/query/builder.py +54 -0
- notionary/file_upload/query/models.py +37 -0
- notionary/file_upload/schemas.py +78 -0
- notionary/file_upload/service.py +152 -289
- notionary/file_upload/validation/factory.py +64 -0
- notionary/file_upload/validation/impl/file_name_length.py +23 -0
- notionary/file_upload/validation/models.py +124 -0
- notionary/file_upload/validation/port.py +7 -0
- notionary/file_upload/validation/service.py +17 -0
- notionary/file_upload/validation/validators/__init__.py +11 -0
- notionary/file_upload/validation/validators/file_exists.py +15 -0
- notionary/file_upload/validation/validators/file_extension.py +122 -0
- notionary/file_upload/validation/validators/file_name_length.py +21 -0
- notionary/file_upload/validation/validators/upload_limit.py +31 -0
- notionary/http/client.py +6 -22
- notionary/page/content/parser/factory.py +8 -5
- notionary/page/content/parser/parsers/audio.py +8 -33
- notionary/page/content/parser/parsers/embed.py +0 -2
- notionary/page/content/parser/parsers/file.py +8 -35
- notionary/page/content/parser/parsers/file_like_block.py +89 -0
- notionary/page/content/parser/parsers/image.py +8 -35
- notionary/page/content/parser/parsers/pdf.py +8 -35
- notionary/page/content/parser/parsers/video.py +8 -35
- notionary/page/content/renderer/renderers/audio.py +9 -21
- notionary/page/content/renderer/renderers/file.py +9 -21
- notionary/page/content/renderer/renderers/file_like_block.py +43 -0
- notionary/page/content/renderer/renderers/image.py +9 -21
- notionary/page/content/renderer/renderers/pdf.py +9 -21
- notionary/page/content/renderer/renderers/video.py +9 -21
- notionary/page/content/syntax/__init__.py +2 -1
- notionary/page/content/syntax/registry.py +38 -60
- notionary/page/properties/client.py +1 -1
- notionary/page/properties/{models.py → schemas.py} +93 -107
- notionary/page/properties/service.py +1 -1
- notionary/page/schemas.py +3 -3
- notionary/page/service.py +1 -1
- notionary/shared/entity/dto_parsers.py +1 -36
- notionary/shared/entity/entity_metadata_update_client.py +18 -4
- notionary/shared/entity/schemas.py +6 -6
- notionary/shared/entity/service.py +53 -30
- notionary/shared/models/file.py +34 -6
- notionary/shared/models/icon.py +5 -12
- notionary/user/bot.py +12 -12
- notionary/utils/decorators.py +8 -8
- notionary/workspace/__init__.py +2 -2
- notionary/workspace/query/__init__.py +2 -1
- notionary/workspace/query/service.py +3 -17
- notionary/workspace/service.py +45 -45
- {notionary-0.3.1.dist-info → notionary-0.4.0.dist-info}/METADATA +1 -1
- {notionary-0.3.1.dist-info → notionary-0.4.0.dist-info}/RECORD +77 -58
- notionary/file_upload/models.py +0 -69
- notionary/page/page_context.py +0 -50
- notionary/shared/models/cover.py +0 -20
- {notionary-0.3.1.dist-info → notionary-0.4.0.dist-info}/WHEEL +0 -0
- {notionary-0.3.1.dist-info → notionary-0.4.0.dist-info}/licenses/LICENSE +0 -0
notionary/file_upload/models.py
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
from enum import Enum
|
|
2
|
-
from typing import Literal
|
|
3
|
-
|
|
4
|
-
from pydantic import BaseModel
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class UploadMode(str, Enum):
|
|
8
|
-
"""Enum for file upload modes."""
|
|
9
|
-
|
|
10
|
-
SINGLE_PART = "single_part"
|
|
11
|
-
MULTI_PART = "multi_part"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class FileUploadResponse(BaseModel):
|
|
15
|
-
"""
|
|
16
|
-
Represents a Notion file upload object as returned by the File Upload API.
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
object: Literal["file_upload"]
|
|
20
|
-
id: str
|
|
21
|
-
created_time: str
|
|
22
|
-
last_edited_time: str
|
|
23
|
-
expiry_time: str
|
|
24
|
-
upload_url: str
|
|
25
|
-
archived: bool
|
|
26
|
-
status: str # "pending", "uploaded", "failed", etc.
|
|
27
|
-
filename: str | None = None
|
|
28
|
-
content_type: str | None = None
|
|
29
|
-
content_length: int | None = None
|
|
30
|
-
request_id: str
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class FileUploadListResponse(BaseModel):
|
|
34
|
-
"""
|
|
35
|
-
Response model for listing file uploads from /v1/file_uploads endpoint.
|
|
36
|
-
"""
|
|
37
|
-
|
|
38
|
-
object: Literal["list"]
|
|
39
|
-
results: list[FileUploadResponse]
|
|
40
|
-
next_cursor: str | None = None
|
|
41
|
-
has_more: bool
|
|
42
|
-
type: Literal["file_upload"]
|
|
43
|
-
file_upload: dict = {}
|
|
44
|
-
request_id: str
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
class FileUploadCreateRequest(BaseModel):
|
|
48
|
-
"""
|
|
49
|
-
Request model for creating a file upload.
|
|
50
|
-
"""
|
|
51
|
-
|
|
52
|
-
filename: str
|
|
53
|
-
content_type: str | None = None
|
|
54
|
-
content_length: int | None = None
|
|
55
|
-
mode: UploadMode = UploadMode.SINGLE_PART
|
|
56
|
-
|
|
57
|
-
def model_dump(self, **kwargs):
|
|
58
|
-
"""Override to exclude None values"""
|
|
59
|
-
data = super().model_dump(**kwargs)
|
|
60
|
-
return {k: v for k, v in data.items() if v is not None}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
class FileUploadCompleteRequest(BaseModel):
|
|
64
|
-
"""
|
|
65
|
-
Request model for completing a multi-part file upload.
|
|
66
|
-
"""
|
|
67
|
-
|
|
68
|
-
# Usually empty for complete requests, but keeping for future extensibility
|
|
69
|
-
pass
|
notionary/page/page_context.py
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from contextvars import ContextVar
|
|
4
|
-
from dataclasses import dataclass
|
|
5
|
-
from typing import TYPE_CHECKING
|
|
6
|
-
|
|
7
|
-
if TYPE_CHECKING:
|
|
8
|
-
from notionary.file_upload import FileUploadHttpClient
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@dataclass(frozen=True)
|
|
12
|
-
class PageContextProvider:
|
|
13
|
-
"""Context object that provides dependencies for block conversion operations."""
|
|
14
|
-
|
|
15
|
-
page_id: str
|
|
16
|
-
file_upload_client: FileUploadHttpClient
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
# Context variable
|
|
20
|
-
_page_context: ContextVar[PageContextProvider | None] = ContextVar("page_context", default=None)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def get_page_context() -> PageContextProvider:
|
|
24
|
-
"""Get current page context or raise if not available."""
|
|
25
|
-
context = _page_context.get()
|
|
26
|
-
if context is None:
|
|
27
|
-
raise RuntimeError("No page context available. Use 'async with page_context(...)'")
|
|
28
|
-
return context
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class page_context:
|
|
32
|
-
def __init__(self, provider: PageContextProvider) -> None:
|
|
33
|
-
self.provider = provider
|
|
34
|
-
self._token = None
|
|
35
|
-
|
|
36
|
-
def _set_context(self) -> PageContextProvider:
|
|
37
|
-
self._token = _page_context.set(self.provider)
|
|
38
|
-
return self.provider
|
|
39
|
-
|
|
40
|
-
def _reset_context(self) -> None:
|
|
41
|
-
"""Helper to reset context."""
|
|
42
|
-
if self._token is not None:
|
|
43
|
-
_page_context.reset(self._token)
|
|
44
|
-
|
|
45
|
-
async def __aenter__(self) -> PageContextProvider:
|
|
46
|
-
return self._set_context()
|
|
47
|
-
|
|
48
|
-
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
49
|
-
self._reset_context()
|
|
50
|
-
return False
|
notionary/shared/models/cover.py
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
from enum import StrEnum
|
|
2
|
-
from typing import Literal, Self
|
|
3
|
-
|
|
4
|
-
from pydantic import BaseModel
|
|
5
|
-
|
|
6
|
-
from notionary.shared.models.file import ExternalFile
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class CoverType(StrEnum):
|
|
10
|
-
EXTERNAL = "external"
|
|
11
|
-
FILE = "file"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class NotionCover(BaseModel):
|
|
15
|
-
type: Literal[CoverType.EXTERNAL, CoverType.FILE] = CoverType.EXTERNAL
|
|
16
|
-
external: ExternalFile | None = None
|
|
17
|
-
|
|
18
|
-
@classmethod
|
|
19
|
-
def from_url(cls, url: str) -> Self:
|
|
20
|
-
return cls(external=ExternalFile(url=url))
|
|
File without changes
|
|
File without changes
|