Kind: Service
Source: atloria-monorepo/apps/api/src/technical-docs/techdocs-notion-export.service.ts
TechDocsNotionExportService is a NestJS backend service responsible for exporting technical documentation content to Notion. It coordinates the transformation and delivery of generated TechDocs data to the configured Notion workspace, acting as the integration boundary between the technical documentation module and Notion APIs.
Methods
| Method | Signature | Returns |
|---|---|---|
exportToNotion | exportToNotion(projectId: string, userId: string, dto: NotionExportDto) | unknown |
Dependencies
PrismaServiceTechnicalDocsMaterializerService
Where it refuses work
TechDocsNotionExportServicestops the work withNotFoundExceptionwhen!member— “Project not found”.TechDocsNotionExportServicestops the work withBadRequestExceptionwhen!pages.length.TechDocsNotionExportServicestops the work withBadRequestExceptionwhen!integrationToken || !parentPageId— “integrationToken and parentPageId are required (or pass dryRun: true).”.TechDocsNotionExportServicestops the work withBadRequestExceptionwhen!container.ok.TechDocsNotionExportServicestops the work with an early return whendto?.dryRun.TechDocsNotionExportServicestops the work with an early return when!res.ok.
When something fails
TechDocsNotionExportServicehandles failure in 2 places: it turns it into a return value in all 2.
Diagram
mermaidsequenceDiagram participant Client as API Controller / Job participant ExportService as TechDocsNotionExportService participant TechDocs as Technical Docs Source participant Notion as Notion API Client->>ExportService: exportToNotion() ExportService->>TechDocs: Load documentation content TechDocs-->>ExportService: Documentation data ExportService->>ExportService: Transform content for Notion blocks ExportService->>Notion: Create or update Notion pages Notion-->>ExportService: Export result ExportService-->>Client: Return export status/result
Usage
tsimport { Injectable } from '@nestjs/common';
import { TechDocsNotionExportService } from './techdocs-notion-export.service';
@Injectable()
export class TechDocsExportJob {
constructor(
private readonly notionExportService: TechDocsNotionExportService,
) {}
async run() {
const result = await this.notionExportService.exportToNotion();
return {
success: true,
result,
};
}
}
AI Coding Instructions
- Inject
TechDocsNotionExportServicethrough NestJS dependency injection; do not instantiate it directly withnew. - Keep Notion-specific API calls and block/page transformation logic inside this service or dedicated Notion client helpers.
- Ensure exported documentation is validated and normalized before creating Notion blocks, especially for headings, code blocks, and nested content.
- Handle Notion API failures, rate limits, and partial exports explicitly so callers receive actionable error information.
- Preserve idempotency where possible by updating existing Notion pages instead of creating duplicate pages on repeated exports.
Relationships
- DEPENDS_ON →
PrismaService - DEPENDS_ON →
TechnicalDocsMaterializerService
Referenced By
TechnicalDocsController(DEPENDS_ON)TechnicalDocsModule(MODULE_PROVIDES)
Was this page helpful?