Notion Datasource
This module contains functionality related to the Notion
datasource.
Cleaner
NotionDatasourceCleaner
Bases: BasicMarkdownCleaner[NotionDocument]
Cleaner for Notion document content.
Implements cleaning logic for Notion databases and pages, removing HTML tags and comments while preserving meaningful content.
Note
Expects documents to be in markdown format.
Source code in src/extraction/datasources/notion/cleaner.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
clean(document)
Clean a single Notion document.
Processes the document based on its type (database or page), removing HTML artifacts and cleaning the content.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/extraction/datasources/notion/cleaner.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
NotionDatasourceCleanerFactory
Bases: Factory
Factory for creating NotionDatasourceCleaner instances.
This factory is responsible for creating instances of NotionDatasourceCleaner with the appropriate configuration.
Source code in src/extraction/datasources/notion/cleaner.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
Client
NotionClientFactory
Bases: SingletonFactory
Factory for creating and managing Notion API client instances.
This singleton factory ensures that only one Notion client instance is created for a specific configuration, promoting resource efficiency and consistency. Client instances are created using the Notion API authentication token from the provided configuration.
The factory follows the singleton pattern to prevent multiple instantiations of clients with identical configurations.
Attributes: |
|
---|
Source code in src/extraction/datasources/notion/client.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
Configuration
Document
NotionDocument
Bases: BaseDocument
Document representation for Notion page content.
Extends BaseDocument to handle Notion-specific document processing including metadata handling and filtering for embeddings and LLM contexts.
Source code in src/extraction/datasources/notion/document.py
4 5 6 7 8 9 10 11 |
|
Exporter
NotionExporter
Exporter for converting Notion pages to markdown documents.
Provides a high-level interface for extracting Notion content and converting it to structured NotionDocument instances.
Source code in src/extraction/datasources/notion/exporter.py
537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 |
|
__init__(api_token)
Initialize Notion exporter.
Parameters: |
|
---|
Source code in src/extraction/datasources/notion/exporter.py
544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
|
run(page_ids=None, database_ids=None)
async
Export Notion content to document collection.
Extracts content from specified pages and databases and converts them to structured document objects.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|
Source code in src/extraction/datasources/notion/exporter.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 |
|
NotionExporterFactory
Bases: SingletonFactory
Factory for creating NotionExporter instances.
Ensures only one instance of NotionExporter is created and reused throughout the application, following the singleton pattern.
Source code in src/extraction/datasources/notion/exporter.py
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 |
|
Manager
NotionDatasourceManager
Bases: BaseDatasourceManager[NotionDocument]
Manager for handling Notion datasource extraction and processing.
This class coordinates the reading, parsing, and cleaning of Notion content to produce structured NotionDocument objects ready for further processing.
Source code in src/extraction/datasources/notion/manager.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
__init__(configuration, reader, parser, cleaner)
Initialize the Notion datasource manager.
Parameters: |
|
---|
Source code in src/extraction/datasources/notion/manager.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
full_refresh_sync()
async
Perform a full refresh of all documents from the Notion datasource.
This method reads all objects from the Notion datasource, parses them into documents, cleans them, and yields the cleaned documents.
Returns: |
|
---|
Source code in src/extraction/datasources/notion/manager.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
incremental_sync()
Not implemented.
Source code in src/extraction/datasources/notion/manager.py
50 51 52 53 54 |
|
NotionDatasourceManagerFactory
Bases: Factory
Factory for creating NotionDatasourceManager instances.
This factory is responsible for creating instances of the NotionDatasourceManager class, which manages the extraction and processing of content from Notion databases and pages.
Attributes: |
|
---|
Source code in src/extraction/datasources/notion/manager.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
Parser
NotionDatasourceParser
Bases: BaseParser[NotionDocument]
Parser for Notion content.
Transforms raw Notion page data into structured NotionDocument objects.
Source code in src/extraction/datasources/notion/parser.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
__init__()
Initialize the Notion parser.
Source code in src/extraction/datasources/notion/parser.py
15 16 17 |
|
parse(object)
Parse Notion page data into a structured document.
Parameters: |
|
---|
Returns: |
|
---|
Source code in src/extraction/datasources/notion/parser.py
19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
NotionDatasourceParserFactory
Bases: Factory
Factory for creating NotionDatasourceParser instances.
Creates and configures parser instances for Notion content.
Source code in src/extraction/datasources/notion/parser.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
Reader
NotionDatasourceReader
Bases: BaseReader
Reader for extracting documents from Notion workspace.
Implements document extraction from Notion pages and databases with support for batched async operations and export limits.
Source code in src/extraction/datasources/notion/reader.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
|
__init__(configuration, client, exporter, logger=LoggerConfiguration.get_logger(__name__))
Initialize Notion reader.
Parameters: |
|
---|
Source code in src/extraction/datasources/notion/reader.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
read_all_async()
async
Asynchronously retrieve all documents from Notion.
Fetches pages and databases in batches, respecting export limits and batch sizes.
Returns: |
|
---|
Source code in src/extraction/datasources/notion/reader.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
NotionDatasourceReaderFactory
Bases: Factory
Factory for creating NotionDatasourceReader instances.
This class is responsible for creating instances of NotionDatasourceReader with the provided configuration and Notion client.
Attributes: |
|
---|
Source code in src/extraction/datasources/notion/reader.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
|
NotionObjectType
Bases: Enum
Enum representing Notion object types. This enum is used to specify the type of Notion object being processed, such as a page or a database.
Source code in src/extraction/datasources/notion/reader.py
23 24 25 26 27 28 29 30 31 |
|