📋 Overview
This document provides comprehensive TypeScript function documentation for the New Campaign module. This advanced module handles the creation and management of sophisticated A2P SMS campaigns with features like audience targeting, message scheduling, template management, and real-time analytics.
🚀 NewCampaignComponent
File: src/app/new-campaign/new-campaign/new-campaign.component.ts
Purpose: Main campaign creation interface with step-by-step wizard
🔄 Lifecycle Methods
Purpose: Component initialization with campaign builder setup
/**
* Component initialization with campaign builder setup
* Initializes multi-step campaign creation wizard
* Loads templates, audience lists, and configuration data
* Sets up form validation and step navigation
* Configures real-time preview and validation
* @returns {void}
*/
ngOnInit(): void
void
Description: Initializes the campaign creation wizard with comprehensive setup for multi-step campaign building, template management, and audience targeting.
Purpose: Component cleanup and draft saving
/**
* Component cleanup and draft saving
* Saves campaign draft if form has unsaved changes
* Unsubscribes from observables and cleans up resources
* Handles wizard state preservation
* @returns {void}
*/
ngOnDestroy(): void
void
🏗️ Campaign Builder Methods
Purpose: Sets up the campaign creation wizard interface
/**
* Sets up the campaign creation wizard interface
* Initializes step-by-step campaign building process
* Configures form validation for each step
* Sets up navigation between wizard steps
* Prepares templates and audience data
* @returns {void}
*/
initializeCampaignBuilder(): void
void
Purpose: Advances to the next step in campaign creation wizard
/**
* Advances to the next step in campaign creation wizard
* Validates current step before proceeding
* Saves current step data to campaign draft
* Updates wizard progress indicators
* Loads next step configuration and data
* @returns {void}
*/
nextStep(): void
void
Purpose: Returns to the previous step in campaign wizard
/**
* Returns to the previous step in campaign wizard
* Preserves current step data without validation
* Updates wizard step indicators
* Restores previous step form state
* Handles step-specific data loading
* @returns {void}
*/
previousStep(): void
void
Purpose: Jumps to a specific step in the campaign wizard
/**
* Jumps to a specific step in the campaign wizard
* Validates all steps between current and target
* Updates wizard navigation state
* Loads target step data and configuration
* Handles step dependency validation
* @param {number} stepIndex - Target step index
* @returns {void}
*/
goToStep(stepIndex: number): void
void
📝 Message Template Methods
Purpose: Loads available message templates for campaign
/**
* Loads available message templates for campaign
* Fetches pre-approved A2P message templates
* Organizes templates by category and type
* Applies user permission filtering
* Updates template selection interface
* @returns {void}
*/
loadMessageTemplates(): void
void
Purpose: Selects and applies a message template
/**
* Selects and applies a message template
* Loads template content and variables
* Updates message preview with template data
* Validates template compliance requirements
* Configures personalization variables
* @param {string} templateId - ID of template to select
* @returns {void}
*/
selectTemplate(templateId: string): void
void
Purpose: Generates and displays message preview
/**
* Generates and displays message preview
* Renders message with sample personalization data
* Calculates message segments and character count
* Validates message content and compliance
* Updates live preview display
* @returns {void}
*/
previewMessage(): void
void
Purpose: Validates message against A2P compliance rules
/**
* Validates message against A2P compliance rules
* Checks message content for regulatory compliance
* Validates opt-out instructions and branding
* Ensures character limits and format requirements
* Returns validation status and error details
* @returns {boolean} True if message is compliant
*/
validateMessageCompliance(): boolean
boolean - Compliance validation result
👥 Audience Management Methods
Purpose: Loads available audience lists and segments
/**
* Loads available audience lists and segments
* Fetches user-accessible contact lists
* Applies permission-based filtering
* Loads segment criteria and counts
* Updates audience selection interface
* @returns {void}
*/
loadAudienceLists(): void
void
Purpose: Selects target audience for campaign
/**
* Selects target audience for campaign
* Loads audience details and contact count
* Validates audience consent and compliance
* Updates campaign targeting configuration
* Calculates estimated reach and costs
* @param {string} audienceId - ID of audience to select
* @returns {void}
*/
selectAudience(audienceId: string): void
void
Purpose: Creates new audience segment with custom criteria
/**
* Creates new audience segment with custom criteria
* Opens segment builder interface
* Configures filtering and targeting rules
* Validates segment criteria and size
* Saves segment for campaign use
* @returns {void}
*/
createAudienceSegment(): void
void
Purpose: Calculates estimated campaign reach and costs
/**
* Calculates estimated campaign reach and costs
* Analyzes audience size and targeting criteria
* Computes delivery estimates and success rates
* Calculates campaign costs and ROI projections
* Updates reach and cost display
* @returns {void}
*/
estimateReach(): void
void
⏰ Scheduling Methods
Purpose: Sets up campaign scheduling and timing
/**
* Sets up campaign scheduling and timing
* Configures send date and time preferences
* Sets up timezone handling and delivery windows
* Configures recurring campaign schedules
* Validates scheduling constraints and regulations
* @returns {void}
*/
configureCampaignSchedule(): void
void
Purpose: Validates campaign schedule against regulations
/**
* Validates campaign schedule against regulations
* Checks sending time restrictions and blackout periods
* Validates timezone compliance requirements
* Ensures adherence to quiet hours and regulations
* Returns validation status and warnings
* @returns {boolean} True if schedule is compliant
*/
validateScheduleCompliance(): boolean
boolean - Schedule compliance validation
💾 Campaign Management Methods
Purpose: Saves current campaign configuration as draft
/**
* Saves current campaign configuration as draft
* Captures all wizard step data and configurations
* Preserves campaign state for later editing
* Validates draft data consistency
* Provides auto-save functionality
* @returns {void}
*/
saveCampaignDraft(): void
void
Purpose: Loads existing campaign draft for editing
/**
* Loads existing campaign draft for editing
* Restores all campaign configuration data
* Repopulates wizard forms and selections
* Validates loaded data consistency
* Updates wizard state and navigation
* @param {string} draftId - ID of draft to load
* @returns {void}
*/
loadCampaignDraft(draftId: string): void
void
Purpose: Finalizes and launches the campaign
/**
* Finalizes and launches the campaign
* Performs final validation and compliance checks
* Submits campaign for approval if required
* Schedules campaign execution based on configuration
* Initiates campaign monitoring and tracking
* @returns {void}
*/
launchCampaign(): void
void
🏗️ CampaignBuilderComponent
File: src/app/new-campaign/campaign-builder/campaign-builder.component.ts
Purpose: Advanced campaign builder with visual design interface
🎨 Visual Builder Methods
Purpose: Initializes the visual campaign builder interface
/**
* Initializes the visual campaign builder interface
* Sets up drag-and-drop components and layout tools
* Configures real-time preview and editing capabilities
* Loads design templates and asset libraries
* Prepares visual editing workspace
* @returns {void}
*/
initializeBuilder(): void
void
Purpose: Adds components to campaign design
/**
* Adds components to campaign design
* Supports text, image, button, and interactive elements
* Handles component positioning and layout
* Configures component properties and styling
* Updates campaign design structure
* @param {string} componentType - Type of component to add
* @returns {void}
*/
addComponent(componentType: string): void
void
⚙️ NewCampaignService
File: src/app/new-campaign/services/new-campaign.service.ts
Purpose: Core service for campaign creation, management, and API integration
🌐 API Methods
Purpose: Creates new campaign with comprehensive configuration
/**
* Creates new campaign with comprehensive configuration
* Validates campaign data and compliance requirements
* Submits campaign for processing and approval
* Handles A2P registration and carrier submission
* Returns campaign creation status and tracking ID
* @param {any} campaignData - Complete campaign configuration
* @returns {Observable<any>} Campaign creation result
*/
createCampaign(campaignData: any): Observable<any>
Observable<any> - Campaign creation result
Purpose: Retrieves available message templates
/**
* Retrieves available message templates
* Fetches pre-approved A2P message templates
* Applies user permission and compliance filtering
* Returns categorized template collections
* Includes template metadata and preview content
* @returns {Observable<any>} Available message templates
*/
getTemplates(): Observable<any>
Observable<any> - Template collection
Purpose: Validates campaign configuration and compliance
/**
* Validates campaign configuration and compliance
* Checks A2P regulations and carrier requirements
* Validates message content and audience targeting
* Performs scheduling and delivery validation
* Returns comprehensive validation report
* @param {any} campaignData - Campaign data to validate
* @returns {Observable<any>} Validation results and recommendations
*/
validateCampaign(campaignData: any): Observable<any>
Observable<any> - Validation report