admesh-ui-sdk
Version:
Beautiful, modern React components for displaying AI-powered product recommendations with citation-based conversation ads, auto-triggered widgets, floating chat, conversational interfaces, persistent sidebar, and built-in tracking. Includes zero-code SDK
109 lines • 3.28 kB
TypeScript
import { AdMeshTheme, AIPContextResponse } from '../types/index';
export interface AdMeshSDKConfig {
apiKey: string;
theme?: AdMeshTheme;
apiBaseUrl?: string;
}
export interface ShowRecommendationsOptions {
query: string;
containerId: string;
theme?: AdMeshTheme;
session_id: string;
platformSurface?: string;
model?: string;
messages?: Array<{
role: string;
content: string;
}>;
locale?: string;
geo?: string;
userId?: string;
latencyBudgetMs?: number;
allowed_formats?: string[];
/** Callback to paste content to input field (for bridge format CTA) */
onPasteToInput?: (content: string) => void;
}
/**
* Main AdMesh SDK class for zero-code integration
*
* The SDK is stateless regarding session management. Developers must provide
* session_id when calling showRecommendations().
*
* @example
* ```typescript
* import { AdMeshSDK } from '@admesh/ui-sdk';
*
* const admesh = new AdMeshSDK({ apiKey: 'your-api-key' });
*
* // Generate session ID on your platform
* const sessionId = AdMeshSDK.createSession();
*
* await admesh.showRecommendations({
* query: 'best CRM for small business',
* containerId: 'admesh-recommendations',
* session_id: sessionId
* });
* ```
*/
export declare class AdMeshSDK {
private config;
private apiBaseUrl;
private renderer;
private tracker;
constructor(config: AdMeshSDKConfig);
/**
* Generate a unique session ID for tracking recommendations
* Call this on your platform to create a new session
*
* @returns A unique session ID
*/
static createSession(): string;
/**
* Generate a unique message ID for tracking recommendations per message
* Call this on your platform to create a message ID for each user message
*
* @param sessionId Optional session ID to include in the message ID
* @returns A unique message ID
*/
static createMessageId(sessionId?: string): string;
/**
* OPTIMIZATION: Lazy initialize renderer on first use
*/
private getRenderer;
/**
* OPTIMIZATION: Lazy initialize tracker on first use
*/
private getTracker;
/**
* Fetch and render recommendations automatically using /aip/context endpoint
*
* Note: session_id is required. Use AdMeshSDK.createSession() to generate a session ID.
*/
showRecommendations(options: ShowRecommendationsOptions): Promise<void>;
/**
* Fetch recommendation from the /aip/context endpoint (new auction-based endpoint)
*/
fetchRecommendationFromAIPContext(params: {
query: string;
sessionId: string;
messageId?: string;
platformSurface?: string;
model?: string;
messages?: Array<{
role: string;
content: string;
id?: string;
}>;
locale?: string;
geo?: string;
userId?: string;
latencyBudgetMs?: number;
allowed_formats?: string[];
}): Promise<AIPContextResponse>;
/**
* Convert AIP context response to AdMeshRecommendation format for compatibility
*/
private convertAIPResponseToRecommendation;
}
export default AdMeshSDK;
//# sourceMappingURL=AdMeshSDK.d.ts.map