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.
Files changed (80) hide show
  1. notionary/__init__.py +6 -1
  2. notionary/blocks/enums.py +0 -6
  3. notionary/blocks/schemas.py +32 -78
  4. notionary/comments/schemas.py +2 -29
  5. notionary/data_source/properties/schemas.py +128 -107
  6. notionary/data_source/schemas.py +2 -2
  7. notionary/data_source/service.py +32 -23
  8. notionary/database/schemas.py +2 -2
  9. notionary/database/service.py +3 -5
  10. notionary/exceptions/__init__.py +6 -2
  11. notionary/exceptions/api.py +2 -2
  12. notionary/exceptions/base.py +1 -1
  13. notionary/exceptions/block_parsing.py +3 -3
  14. notionary/exceptions/data_source/builder.py +2 -2
  15. notionary/exceptions/data_source/properties.py +3 -3
  16. notionary/exceptions/file_upload.py +67 -0
  17. notionary/exceptions/properties.py +4 -4
  18. notionary/exceptions/search.py +4 -4
  19. notionary/file_upload/__init__.py +4 -0
  20. notionary/file_upload/client.py +124 -210
  21. notionary/file_upload/config/__init__.py +17 -0
  22. notionary/file_upload/config/config.py +32 -0
  23. notionary/file_upload/config/constants.py +16 -0
  24. notionary/file_upload/file/reader.py +28 -0
  25. notionary/file_upload/query/__init__.py +7 -0
  26. notionary/file_upload/query/builder.py +54 -0
  27. notionary/file_upload/query/models.py +37 -0
  28. notionary/file_upload/schemas.py +78 -0
  29. notionary/file_upload/service.py +152 -289
  30. notionary/file_upload/validation/factory.py +64 -0
  31. notionary/file_upload/validation/impl/file_name_length.py +23 -0
  32. notionary/file_upload/validation/models.py +124 -0
  33. notionary/file_upload/validation/port.py +7 -0
  34. notionary/file_upload/validation/service.py +17 -0
  35. notionary/file_upload/validation/validators/__init__.py +11 -0
  36. notionary/file_upload/validation/validators/file_exists.py +15 -0
  37. notionary/file_upload/validation/validators/file_extension.py +122 -0
  38. notionary/file_upload/validation/validators/file_name_length.py +21 -0
  39. notionary/file_upload/validation/validators/upload_limit.py +31 -0
  40. notionary/http/client.py +6 -22
  41. notionary/page/content/parser/factory.py +8 -5
  42. notionary/page/content/parser/parsers/audio.py +8 -33
  43. notionary/page/content/parser/parsers/embed.py +0 -2
  44. notionary/page/content/parser/parsers/file.py +8 -35
  45. notionary/page/content/parser/parsers/file_like_block.py +89 -0
  46. notionary/page/content/parser/parsers/image.py +8 -35
  47. notionary/page/content/parser/parsers/pdf.py +8 -35
  48. notionary/page/content/parser/parsers/video.py +8 -35
  49. notionary/page/content/renderer/renderers/audio.py +9 -21
  50. notionary/page/content/renderer/renderers/file.py +9 -21
  51. notionary/page/content/renderer/renderers/file_like_block.py +43 -0
  52. notionary/page/content/renderer/renderers/image.py +9 -21
  53. notionary/page/content/renderer/renderers/pdf.py +9 -21
  54. notionary/page/content/renderer/renderers/video.py +9 -21
  55. notionary/page/content/syntax/__init__.py +2 -1
  56. notionary/page/content/syntax/registry.py +38 -60
  57. notionary/page/properties/client.py +1 -1
  58. notionary/page/properties/{models.py → schemas.py} +93 -107
  59. notionary/page/properties/service.py +1 -1
  60. notionary/page/schemas.py +3 -3
  61. notionary/page/service.py +1 -1
  62. notionary/shared/entity/dto_parsers.py +1 -36
  63. notionary/shared/entity/entity_metadata_update_client.py +18 -4
  64. notionary/shared/entity/schemas.py +6 -6
  65. notionary/shared/entity/service.py +53 -30
  66. notionary/shared/models/file.py +34 -6
  67. notionary/shared/models/icon.py +5 -12
  68. notionary/user/bot.py +12 -12
  69. notionary/utils/decorators.py +8 -8
  70. notionary/workspace/__init__.py +2 -2
  71. notionary/workspace/query/__init__.py +2 -1
  72. notionary/workspace/query/service.py +3 -17
  73. notionary/workspace/service.py +45 -45
  74. {notionary-0.3.1.dist-info → notionary-0.4.0.dist-info}/METADATA +1 -1
  75. {notionary-0.3.1.dist-info → notionary-0.4.0.dist-info}/RECORD +77 -58
  76. notionary/file_upload/models.py +0 -69
  77. notionary/page/page_context.py +0 -50
  78. notionary/shared/models/cover.py +0 -20
  79. {notionary-0.3.1.dist-info → notionary-0.4.0.dist-info}/WHEEL +0 -0
  80. {notionary-0.3.1.dist-info → notionary-0.4.0.dist-info}/licenses/LICENSE +0 -0
@@ -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
@@ -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
@@ -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))