async def generate_entities(self) -> AsyncGenerator[ChunkEntity, None]:
        """Generate all entities from Notion using comprehensive discovery."""
        logger.info("Starting comprehensive Notion entity generation with content aggregation")
        self._stats = {
            "api_calls": 0,
            "rate_limit_waits": 0,
            "databases_found": 0,
            "child_databases_found": 0,
            "pages_found": 0,
            "total_blocks_processed": 0,
            "total_files_found": 0,
            "max_page_depth": 0,
        }

        try:
            async with httpx.AsyncClient() as client:
                self._client_ref = client  # Store for lazy operations

                # Phase 1: Top-Level Discovery
                discovered = await self._discover_all_objects(client)

                # Phase 2: Database Schema Analysis
                database_schemas = await self._analyze_database_schemas(
                    client, discovered["databases"]
                )

                # Phase 3: Database Content Extraction with Aggregation
                async for entity in self._extract_database_content(client, database_schemas):
                    yield entity

                # Phase 4: Standalone Page Processing with Aggregation
                async for entity in self._process_standalone_pages(client, discovered["pages"]):
                    yield entity

                # Phase 5: Child Database Processing
                async for entity in self._process_child_databases(client):
                    yield entity

            logger.info(f"Notion sync complete. Final stats: {self._stats}")

        except Exception as e:
            logger.error(
                f"Error during comprehensive Notion entity generation: {str(e)}", exc_info=True
            )
            raise
Generate all entities from Notion using comprehensive discovery.
backend/airweave/platform/sources/notion.py