adpa-enterprise-framework-automation
Version:
Modular, standards-compliant Node.js/TypeScript automation framework for enterprise requirements, project, and data management. Provides CLI and API for BABOK v3, PMBOK 7th Edition, and DMBOK 2.0 (in progress). Production-ready Express.js API with TypeSpe
190 lines • 5.78 kB
TypeScript
/**
* Confluence Publisher Module
* Part of ADPA (Automated Document Processing Assistant) v2.1.3
*
* Handles publishing generated documents to Confluence Cloud
* Features:
* - API-based publishing to Confluence spaces
* - OAuth 2.0 (3LO) and API token authentication
* - Automatic page creation and updates
* - Hierarchical document organization
* - Metadata preservation and tagging
* - Error handling and retry logic
*/
import { OAuth2Config } from './ConfluenceOAuth2.js';
export interface ConfluenceConfig {
authMethod: 'oauth2' | 'api-token';
oauth2?: OAuth2Config;
baseUrl?: string;
email?: string;
apiToken?: string;
spaceKey: string;
parentPageId?: string;
cloudId?: string;
}
export interface ConfluencePage {
id?: string;
title: string;
content: string;
spaceKey: string;
parentId?: string;
labels?: string[];
metadata?: Record<string, any>;
}
export interface PublishResult {
success: boolean;
pageId?: string;
pageUrl?: string;
error?: string;
title: string;
}
/**
* Main Confluence Publisher class
* Handles all interactions with Confluence Cloud API
*/
export declare class ConfluencePublisher {
private client;
private config;
private oauth2Handler?;
constructor(config: ConfluenceConfig);
/**
* Create a placeholder client for OAuth2 initialization
*/
private createPlaceholderClient;
/**
* Initialize or refresh OAuth2 client
*/
private ensureOAuth2Client;
/**
* Initialize client for API token authentication (legacy)
*/
private initializeApiTokenClient; /**
* Ensure client is properly configured before making API calls
*/
private ensureClient;
/**
* Start OAuth2 authentication flow (for OAuth2 method)
* @returns Promise with OAuth2 tokens
*/
startOAuth2Login(): Promise<{
success: boolean;
tokens?: any;
error?: string;
}>; /**
* Check if OAuth2 is authorized
* @returns Boolean indicating authorization status
*/
isOAuth2Authorized(): boolean; /**
* Test connectivity to Confluence API
* @returns Promise with connection status
*/
testConnection(): Promise<{
success: boolean;
error?: string;
userInfo?: any;
cloudId?: string;
}>; /**
* Get space information
* @param spaceKey Space key to query
* @returns Space information or null if not found
*/
getSpace(spaceKey?: string): Promise<any | null>;
/**
* Create a new page in Confluence
* @param page Page data to create
* @returns Created page information
*/
createPage(page: ConfluencePage): Promise<PublishResult>;
/**
* Update an existing page in Confluence
* @param pageId Page ID to update
* @param page Updated page data
* @returns Update result
*/
updatePage(pageId: string, page: ConfluencePage): Promise<PublishResult>;
/**
* Find page by title in the configured space
* @param title Page title to search for
* @returns Page data or null if not found
*/
findPageByTitle(title: string): Promise<any | null>;
/**
* Publish or update a page (create if doesn't exist, update if it does)
* @param page Page data to publish
* @returns Publish result
*/
publishPage(page: ConfluencePage): Promise<PublishResult>;
/**
* Publish multiple documents from a directory
* @param documentsPath Path to generated documents
* @param options Publishing options
* @returns Array of publish results
*/
publishDocuments(documentsPath: string, options?: {
parentPageTitle?: string;
labelPrefix?: string;
includeMetadata?: boolean;
}): Promise<PublishResult[]>;
/**
* Add labels to a page
* @param pageId Page ID
* @param labels Array of label names
*/
private addLabelsToPage;
/**
* Replace all labels on a page
* @param pageId Page ID
* @param labels New labels array
*/
private replaceLabelsOnPage;
/**
* Convert Markdown content to Confluence Storage Format
* Basic conversion - can be enhanced for more complex formatting
* @param markdown Markdown content
* @returns Confluence storage format HTML
*/
private convertMarkdownToConfluence;
/**
* Utility method to add delays between API calls
* @param ms Milliseconds to delay
*/
private delay; /**
* Generate page URL based on authentication method
* @param webuiPath Web UI path from Confluence response
* @returns Full page URL
*/
private generatePageUrl;
/**
* Get publishing statistics
* @returns Statistics object
*/
getPublishingStats(): Promise<{
totalPages: number;
spaceInfo: any;
lastUpdated: string;
}>; /**
* Detect if we need Cloud API and try to get Cloud ID automatically (legacy API token method)
* @returns Promise with detection result
*/
detectAndConfigureCloudApi(): Promise<{
success: boolean;
cloudId?: string;
error?: string;
}>;
}
/**
* Factory function to create ConfluencePublisher instance
* @param config Confluence configuration
* @returns ConfluencePublisher instance
*/
export declare function createConfluencePublisher(config: ConfluenceConfig): ConfluencePublisher;
/**
* Utility function to validate Confluence configuration
* @param config Configuration to validate
* @returns Validation result
*/
export declare function validateConfluenceConfig(config: Partial<ConfluenceConfig>): {
valid: boolean;
errors: string[];
};
//# sourceMappingURL=ConfluencePublisher.d.ts.map