/**
* Message types for communication between SDK Launcher and Iframe App
* Based on the main app's communication system to avoid CORS issues
*/
///
export interface RecommendationRequestMessage {
type: 'GET_RECOMMENDATION';
payload: {
requestId: string;
data: {
page_url: string;
keywords: string[];
context?: Record;
};
};
}
export interface RecommendationResponseMessage {
type: 'RECOMMENDATION_RESPONSE';
payload: {
requestId: string;
success: boolean;
data?: any;
error?: {
message: string;
code?: string;
};
};
}
export interface UserDataUpdatedMessage {
type: 'TRONIC_USER_DATA_UPDATED';
payload: {
user: any;
timestamp: number;
};
}
export declare type LauncherToIframeMessage = RecommendationRequestMessage;
export declare type IframeToLauncherMessage = RecommendationResponseMessage | UserDataUpdatedMessage;
export interface CommunicationManager {
requestRecommendation(pageUrl: string, keywords: string[], context?: Record): Promise;
isReady(): boolean;
destroy(): void;
}
export interface PendingRequest {
requestId: string;
resolve: (data: any) => void;
reject: (error: Error) => void;
timeout: NodeJS.Timeout;
timestamp: number;
}