@ai-ad-network/frontend-sdk 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/EnhancedContent.d.ts +50 -1
- package/dist/components/EntityLinkAd.simple.d.ts +76 -0
- package/dist/hooks/useAiAds.d.ts +6 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +366 -46
- package/dist/index.js +365 -45
- package/dist/universal/index.d.ts +137 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EntityInfo, EnhancedContentProps } from '@/types';
|
|
1
|
+
import type { EntityInfo, EnhancementOptions, EnhancedContentProps, KoahAd } from '@/types';
|
|
2
2
|
/**
|
|
3
3
|
* EnhancedContent Component
|
|
4
4
|
*
|
|
@@ -51,3 +51,52 @@ export declare function useEntityStats(entities: EntityInfo[]): {
|
|
|
51
51
|
byType: Record<string, number>;
|
|
52
52
|
avgConfidence: number;
|
|
53
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* EnhancedContentV2 Props
|
|
56
|
+
*/
|
|
57
|
+
export interface EnhancedContentV2Props {
|
|
58
|
+
/** The ad data containing entity_link_content */
|
|
59
|
+
ad: KoahAd;
|
|
60
|
+
/** AI response context for styling */
|
|
61
|
+
aiContext?: string;
|
|
62
|
+
/** Custom class name */
|
|
63
|
+
className?: string;
|
|
64
|
+
/** Whether tracking is loading (unused but for API compatibility) */
|
|
65
|
+
isLoading?: boolean;
|
|
66
|
+
requestId: string;
|
|
67
|
+
slotId: string;
|
|
68
|
+
position: number;
|
|
69
|
+
totalAds: number;
|
|
70
|
+
enhancements?: EnhancementOptions;
|
|
71
|
+
onEntityClick?: (entity: EntityInfo) => void;
|
|
72
|
+
onImpression?: () => void;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* EnhancedContentV2 - Entity Link Ad component with Analytics API tracking
|
|
76
|
+
*
|
|
77
|
+
* Renders content with entity-linked affiliate URLs and tracks clicks
|
|
78
|
+
* using the new Analytics API (POST /api/v1/ads/click).
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```tsx
|
|
82
|
+
* <EnhancedContentV2
|
|
83
|
+
* ad={ad}
|
|
84
|
+
* requestId="req-123"
|
|
85
|
+
* slotId="slot-entity-link"
|
|
86
|
+
* position={0}
|
|
87
|
+
* totalAds={3}
|
|
88
|
+
* />
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare function EnhancedContentV2({ ad, aiContext, className, isLoading: _isLoading, requestId, slotId, position, totalAds, enhancements, onEntityClick, onImpression, }: EnhancedContentV2Props): import("react/jsx-runtime").JSX.Element;
|
|
92
|
+
/**
|
|
93
|
+
* Convenience components for V2
|
|
94
|
+
*/
|
|
95
|
+
/**
|
|
96
|
+
* Inline variant - for embedding within existing text
|
|
97
|
+
*/
|
|
98
|
+
export declare function EnhancedContentV2Inline(props: Omit<EnhancedContentV2Props, 'className'>): import("react/jsx-runtime").JSX.Element;
|
|
99
|
+
/**
|
|
100
|
+
* Block variant - for standalone content blocks
|
|
101
|
+
*/
|
|
102
|
+
export declare function EnhancedContentV2Block(props: EnhancedContentV2Props): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { KoahAd, BadgeStyle, OverlapStrategy } from '@/types';
|
|
2
|
+
import type { EntityInfo } from '@/types';
|
|
3
|
+
/**
|
|
4
|
+
* 🆕 Simplified EntityLinkAd Props
|
|
5
|
+
*
|
|
6
|
+
* This component automatically handles all analytics tracking parameters.
|
|
7
|
+
* You only need to provide the ad data and slot ID.
|
|
8
|
+
*/
|
|
9
|
+
export interface EntityLinkAdProps {
|
|
10
|
+
/** The ad data to display (must contain entity_link_content) */
|
|
11
|
+
ad: KoahAd;
|
|
12
|
+
/** Slot identifier (business concept, e.g., "inline-entity", "content-enhancement") */
|
|
13
|
+
slotId: string;
|
|
14
|
+
/** AI response context for template selection */
|
|
15
|
+
aiContext?: string;
|
|
16
|
+
/** Custom class name */
|
|
17
|
+
className?: string;
|
|
18
|
+
/** Loading state */
|
|
19
|
+
isLoading?: boolean;
|
|
20
|
+
/** Badge style for entity links */
|
|
21
|
+
badgeStyle?: BadgeStyle;
|
|
22
|
+
/** Strategy for handling overlapping entities */
|
|
23
|
+
overlapStrategy?: OverlapStrategy;
|
|
24
|
+
/** Maximum number of entity links to show */
|
|
25
|
+
maxLinks?: number;
|
|
26
|
+
/** Minimum confidence threshold for entities */
|
|
27
|
+
minConfidence?: number;
|
|
28
|
+
/** Custom click callback (in addition to automatic tracking) */
|
|
29
|
+
onEntityClick?: (entity: EntityInfo) => void;
|
|
30
|
+
/** Custom impression callback (in addition to automatic tracking) */
|
|
31
|
+
onImpression?: () => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* EntityLinkAd - Simplified component with automatic analytics tracking
|
|
35
|
+
*
|
|
36
|
+
* This component automatically injects all analytics tracking parameters
|
|
37
|
+
* (requestId, position, totalAds) from the SDK context and renders
|
|
38
|
+
* entity-linked content with click tracking.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* // ✅ Simple usage - automatic tracking
|
|
43
|
+
* import { EntityLinkAd } from '@ai-ad-network/frontend-sdk';
|
|
44
|
+
*
|
|
45
|
+
* <EntityLinkAd
|
|
46
|
+
* ad={ad}
|
|
47
|
+
* slotId="inline-entity"
|
|
48
|
+
* aiContext={aiResponse}
|
|
49
|
+
* badgeStyle="subtle"
|
|
50
|
+
* />
|
|
51
|
+
*
|
|
52
|
+
* // With multiple ads
|
|
53
|
+
* {ads.map(ad => (
|
|
54
|
+
* <EntityLinkAd
|
|
55
|
+
* key={ad.id}
|
|
56
|
+
* ad={ad}
|
|
57
|
+
* slotId="inline-entity"
|
|
58
|
+
* />
|
|
59
|
+
* ))}
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* For advanced use cases where you need explicit control over analytics parameters,
|
|
64
|
+
* use `EnhancedContentV2` directly.
|
|
65
|
+
*/
|
|
66
|
+
export declare function EntityLinkAd({ ad, slotId, aiContext, className, isLoading, badgeStyle, overlapStrategy, maxLinks, minConfidence, onEntityClick, onImpression, }: EntityLinkAdProps): import("react/jsx-runtime").JSX.Element;
|
|
67
|
+
/**
|
|
68
|
+
* EntityLinkAdInline - Inline variant for embedding within existing text
|
|
69
|
+
*/
|
|
70
|
+
export declare function EntityLinkAdInline(props: Omit<EntityLinkAdProps, 'className'>): import("react/jsx-runtime").JSX.Element;
|
|
71
|
+
/**
|
|
72
|
+
* EntityLinkAdBlock - Block variant for standalone content blocks
|
|
73
|
+
*/
|
|
74
|
+
export declare function EntityLinkAdBlock(props: EntityLinkAdProps): import("react/jsx-runtime").JSX.Element;
|
|
75
|
+
export { EnhancedContentV2 } from './EnhancedContent';
|
|
76
|
+
export type { EnhancedContentV2Props } from './EnhancedContent';
|
package/dist/hooks/useAiAds.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { KoahAd, IntentResult, RoutingInfo, UseAiAdsOptions, UseAiAdsResult } from '@/types';
|
|
1
|
+
import type { KoahAd, IntentResult, RoutingInfo, UseAiAdsOptions, UseAiAdsResult, AdFormat } from '@/types';
|
|
2
2
|
/**
|
|
3
3
|
* useAiAds - Core hook for fetching AI-powered native ads
|
|
4
4
|
*
|
|
@@ -9,6 +9,8 @@ import type { KoahAd, IntentResult, RoutingInfo, UseAiAdsOptions, UseAiAdsResult
|
|
|
9
9
|
*
|
|
10
10
|
* Uses the unified /api/v1/ads/request endpoint with auto-injected ClientInfo.
|
|
11
11
|
*
|
|
12
|
+
* 🆕 Automatically stabilizes options to prevent infinite render loops.
|
|
13
|
+
*
|
|
12
14
|
* @example
|
|
13
15
|
* ```tsx
|
|
14
16
|
* const { ads, intent, isLoading, error } = useAiAds(
|
|
@@ -43,6 +45,8 @@ export declare function useAiadsWithAnalytics(userQuery: string, aiResponse: str
|
|
|
43
45
|
*
|
|
44
46
|
* Uses the unified /api/v1/ads/request endpoint with auto-injected ClientInfo.
|
|
45
47
|
*
|
|
48
|
+
* 🆕 Automatically stabilizes options to prevent infinite render loops.
|
|
49
|
+
*
|
|
46
50
|
* @example
|
|
47
51
|
* ```tsx
|
|
48
52
|
* const { fetchAds, ads, isLoading } = useAiAdsLazy();
|
|
@@ -57,7 +61,7 @@ export declare function useAiAdsLazy(options?: UseAiAdsOptions): {
|
|
|
57
61
|
routing: RoutingInfo | null;
|
|
58
62
|
isLoading: boolean;
|
|
59
63
|
error: Error | null;
|
|
60
|
-
fetchAds: (query: string, response: string, customFormats?:
|
|
64
|
+
fetchAds: (query: string, response: string, customFormats?: AdFormat[]) => Promise<void>;
|
|
61
65
|
reset: () => void;
|
|
62
66
|
};
|
|
63
67
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,11 @@ export { ActionCardAd } from './components/ActionCardAd.simple';
|
|
|
35
35
|
export { ActionCardAdV2 } from './components/ActionCardAd';
|
|
36
36
|
export type { ActionCardAdV2Props } from './components/ActionCardAd';
|
|
37
37
|
export type { ActionCardAdProps } from './components/ActionCardAd.simple';
|
|
38
|
+
export { EntityLinkAd, EntityLinkAdInline, EntityLinkAdBlock } from './components/EntityLinkAd.simple';
|
|
39
|
+
export { EnhancedContentV2, EnhancedContentV2Inline, EnhancedContentV2Block, } from './components/EnhancedContent';
|
|
38
40
|
export { EnhancedContent, EnhancedContentInline, EnhancedContentBlock, useEntityStats, } from './components/EnhancedContent';
|
|
41
|
+
export type { EnhancedContentV2Props } from './components/EnhancedContent';
|
|
42
|
+
export type { EntityLinkAdProps } from './components/EntityLinkAd.simple';
|
|
39
43
|
export { SuffixAd } from './components/SuffixAd.simple';
|
|
40
44
|
export { SuffixAdV2 } from './components/SuffixAd';
|
|
41
45
|
export { SuffixAdInline, SuffixAdMinimal, } from './components/SuffixAd';
|