Kind: Service
Source: atloria-monorepo/apps/api/src/technical-docs/techdocs-connectors.service.ts
TechDocsConnectorsService manages integrations between the platform and external technical documentation providers. It handles connector lifecycle operations, enablement, removal, and both manual and scheduled synchronization of documentation content.
Methods
| Method | Signature | Returns | Description |
|---|---|---|---|
create | create(projectId: string, userId: string, dto: CreateConnectorDto) | unknown | |
list | list(projectId: string, userId: string) | unknown | |
setEnabled | setEnabled(projectId: string, userId: string, id: string, enabled: boolean) | unknown | |
remove | remove(projectId: string, userId: string, id: string) | unknown | |
syncNow | syncNow(projectId: string, userId: string, id: string) | unknown | Manual "sync now" from the UI. |
syncDue | syncDue() | unknown | Cron: every 10 minutes, sync connectors whose interval has elapsed. |
syncOne | syncOne(id: string) | unknown | Sync a single connector: pull the delta by cursor, ingest new items, advance the cursor. |
Dependencies
PrismaServiceTechDocsSourcesService
Where it refuses work
TechDocsConnectorsServicestops the work withNotFoundExceptionwhen!c— “Connector not found”, in 3 places.TechDocsConnectorsServicestops the work withNotFoundExceptionwhen!project— “Project not found”.TechDocsConnectorsServicestops the work withBadRequestExceptionwhen!c.subdomain || !c.email || !c.apiToken— “Zendesk connector needs subdomain, email and apiToken.”.TechDocsConnectorsServicestops the work withBadRequestExceptionwhen!c.accessToken— “Intercom connector needs an accessToken.”.TechDocsConnectorsServicestops the work withBadRequestExceptionwhentype !== 'ZENDESK' && type !== 'INTERCOM'— “type must be zendesk or intercom.”.TechDocsConnectorsServicestops the work with an early return when!due.length.
When something fails
TechDocsConnectorsServicehandles failure in 1 place: it lets it reach the caller in all 1.
Diagram
mermaidsequenceDiagram participant Client participant Service as TechDocsConnectorsService participant Connector as Connector Repository participant Provider as External Docs Provider Client->>Service: create(connectorConfig) Service->>Connector: persist connector Connector-->>Service: connector Service-->>Client: created connector Client->>Service: syncNow(connectorId) Service->>Connector: load enabled connector Connector-->>Service: connector Service->>Provider: fetch documentation Provider-->>Service: documentation data Service->>Connector: store sync state/content Service-->>Client: sync result Service->>Service: syncDue() Service->>Connector: find due enabled connectors loop Each connector Service->>Service: syncOne(connector) Service->>Provider: fetch documentation end
Usage
tsimport { TechDocsConnectorsService } from './technical-docs/techdocs-connectors.service';
@Injectable()
export class DocumentationAdminService {
constructor(
private readonly techDocsConnectorsService: TechDocsConnectorsService,
) {}
async addAndSyncConnector() {
const connector = await this.techDocsConnectorsService.create({
name: 'Engineering Docs',
provider: 'github',
enabled: true,
// Include provider-specific repository, authentication, and sync settings.
});
await this.techDocsConnectorsService.syncNow(connector.id);
return connector;
}
async disableConnector(connectorId: string) {
return this.techDocsConnectorsService.setEnabled(connectorId, false);
}
}
AI Coding Instructions
- Use
create()for new connector configuration and validate provider-specific settings before attempting a sync. - Prefer
syncNow()for user-initiated synchronization; usesyncDue()only from scheduled/background job integration points. - Keep
syncOne()focused on synchronizing a single connector and reuse it from both manual and scheduled sync flows. - Check that a connector is enabled before fetching external documentation, and preserve sync status or errors for observability.
- When removing a connector with
remove(), ensure related synced content, credentials, and scheduled-sync state are handled consistently.
Relationships
- DEPENDS_ON →
PrismaService - DEPENDS_ON →
TechDocsSourcesService
Referenced By
TechnicalDocsController(DEPENDS_ON)TechnicalDocsModule(MODULE_PROVIDES)
Was this page helpful?