@the_ro_show/agent-ads-sdk 0.2.1 → 0.4.0
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/index.d.mts +171 -1
- package/dist/index.d.ts +171 -1
- package/dist/index.js +147 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +138 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -61,6 +61,15 @@ interface Constraints {
|
|
|
61
61
|
interface Privacy {
|
|
62
62
|
data_policy: 'coarse_only' | 'none' | 'extended';
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Scoring metadata for agent curation (Option C: Intelligent Integration)
|
|
66
|
+
* Included in multi-ad responses to help agents choose the best ad
|
|
67
|
+
*/
|
|
68
|
+
interface AdScore {
|
|
69
|
+
relevance: number;
|
|
70
|
+
composite: number;
|
|
71
|
+
position: number;
|
|
72
|
+
}
|
|
64
73
|
/**
|
|
65
74
|
* AdUnit is a discriminated union enforcing the OpenAPI oneOf constraint.
|
|
66
75
|
* Either suggestion OR tool is required based on unit_type.
|
|
@@ -71,12 +80,14 @@ type AdUnit = {
|
|
|
71
80
|
disclosure: Disclosure;
|
|
72
81
|
tracking: Tracking;
|
|
73
82
|
suggestion: SponsoredSuggestion;
|
|
83
|
+
_score?: AdScore;
|
|
74
84
|
} | {
|
|
75
85
|
unit_id: string;
|
|
76
86
|
unit_type: 'sponsored_tool';
|
|
77
87
|
disclosure: Disclosure;
|
|
78
88
|
tracking: Tracking;
|
|
79
89
|
tool: SponsoredTool;
|
|
90
|
+
_score?: AdScore;
|
|
80
91
|
};
|
|
81
92
|
interface Disclosure {
|
|
82
93
|
label: string;
|
|
@@ -93,6 +104,8 @@ interface SponsoredSuggestion {
|
|
|
93
104
|
body: string;
|
|
94
105
|
cta: string;
|
|
95
106
|
action_url: string;
|
|
107
|
+
tracking_url?: string;
|
|
108
|
+
tracked_url?: string;
|
|
96
109
|
}
|
|
97
110
|
interface SponsoredTool {
|
|
98
111
|
tool_name: string;
|
|
@@ -474,4 +487,161 @@ declare class TimeoutError extends AttentionMarketError {
|
|
|
474
487
|
constructor(message?: string);
|
|
475
488
|
}
|
|
476
489
|
|
|
477
|
-
|
|
490
|
+
/**
|
|
491
|
+
* Taxonomy helper utilities for AttentionMarket SDK
|
|
492
|
+
* Helps with building, validating, and working with the 4-tier taxonomy system
|
|
493
|
+
*/
|
|
494
|
+
type TaxonomyIntent = 'research' | 'compare' | 'quote' | 'trial' | 'book' | 'apply' | 'consultation';
|
|
495
|
+
/**
|
|
496
|
+
* Build a valid taxonomy string
|
|
497
|
+
*
|
|
498
|
+
* @param vertical - Industry vertical (e.g., "insurance", "business", "healthcare")
|
|
499
|
+
* @param category - Product/service category (e.g., "auto", "saas", "dental")
|
|
500
|
+
* @param subcategory - Specific offering (e.g., "full_coverage", "crm", "cosmetic")
|
|
501
|
+
* @param intent - Optional user journey stage
|
|
502
|
+
* @returns Properly formatted taxonomy string
|
|
503
|
+
*
|
|
504
|
+
* @example
|
|
505
|
+
* buildTaxonomy('insurance', 'auto', 'full_coverage', 'quote')
|
|
506
|
+
* // Returns: 'insurance.auto.full_coverage.quote'
|
|
507
|
+
*
|
|
508
|
+
* @example
|
|
509
|
+
* buildTaxonomy('business', 'saas', 'crm', 'trial')
|
|
510
|
+
* // Returns: 'business.saas.crm.trial'
|
|
511
|
+
*/
|
|
512
|
+
declare function buildTaxonomy(vertical: string, category: string, subcategory: string, intent?: TaxonomyIntent): string;
|
|
513
|
+
/**
|
|
514
|
+
* Detect user intent from query string
|
|
515
|
+
*
|
|
516
|
+
* Analyzes the user's query to determine their stage in the buying journey.
|
|
517
|
+
* Returns the most appropriate intent modifier.
|
|
518
|
+
*
|
|
519
|
+
* @param query - User's search query or question
|
|
520
|
+
* @returns Detected intent modifier
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* detectIntent("What is term life insurance?")
|
|
524
|
+
* // Returns: 'research'
|
|
525
|
+
*
|
|
526
|
+
* @example
|
|
527
|
+
* detectIntent("Get car insurance quote")
|
|
528
|
+
* // Returns: 'quote'
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* detectIntent("Best CRM software comparison")
|
|
532
|
+
* // Returns: 'compare'
|
|
533
|
+
*/
|
|
534
|
+
declare function detectIntent(query: string): TaxonomyIntent;
|
|
535
|
+
/**
|
|
536
|
+
* Validate taxonomy format
|
|
537
|
+
*
|
|
538
|
+
* Checks if a taxonomy string follows the correct format:
|
|
539
|
+
* - 3 or 4 parts separated by dots
|
|
540
|
+
* - All parts are lowercase alphanumeric with underscores
|
|
541
|
+
* - If 4 parts, last part must be a valid intent
|
|
542
|
+
*
|
|
543
|
+
* @param taxonomy - Taxonomy string to validate
|
|
544
|
+
* @returns True if valid, false otherwise
|
|
545
|
+
*
|
|
546
|
+
* @example
|
|
547
|
+
* isValidTaxonomy('insurance.auto.full_coverage.quote') // true
|
|
548
|
+
* isValidTaxonomy('insurance.auto') // false (too short)
|
|
549
|
+
* isValidTaxonomy('Insurance.Auto.Quote') // false (uppercase)
|
|
550
|
+
* isValidTaxonomy('insurance.auto.full_coverage.invalid') // false (invalid intent)
|
|
551
|
+
*/
|
|
552
|
+
declare function isValidTaxonomy(taxonomy: string): boolean;
|
|
553
|
+
/**
|
|
554
|
+
* Parsed taxonomy components
|
|
555
|
+
*/
|
|
556
|
+
interface ParsedTaxonomy {
|
|
557
|
+
/** Industry vertical (tier 1) */
|
|
558
|
+
vertical: string;
|
|
559
|
+
/** Product/service category (tier 2) */
|
|
560
|
+
category: string;
|
|
561
|
+
/** Specific offering (tier 3) */
|
|
562
|
+
subcategory: string;
|
|
563
|
+
/** User journey stage (tier 4, optional) */
|
|
564
|
+
intent?: TaxonomyIntent;
|
|
565
|
+
/** Full taxonomy string */
|
|
566
|
+
full: string;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Parse taxonomy into components
|
|
570
|
+
*
|
|
571
|
+
* Breaks down a taxonomy string into its constituent parts for analysis.
|
|
572
|
+
*
|
|
573
|
+
* @param taxonomy - Taxonomy string to parse
|
|
574
|
+
* @returns Parsed components or null if invalid
|
|
575
|
+
*
|
|
576
|
+
* @example
|
|
577
|
+
* parseTaxonomy('insurance.auto.full_coverage.quote')
|
|
578
|
+
* // Returns: {
|
|
579
|
+
* // vertical: 'insurance',
|
|
580
|
+
* // category: 'auto',
|
|
581
|
+
* // subcategory: 'full_coverage',
|
|
582
|
+
* // intent: 'quote',
|
|
583
|
+
* // full: 'insurance.auto.full_coverage.quote'
|
|
584
|
+
* // }
|
|
585
|
+
*/
|
|
586
|
+
declare function parseTaxonomy(taxonomy: string): ParsedTaxonomy | null;
|
|
587
|
+
/**
|
|
588
|
+
* Get taxonomy without intent modifier
|
|
589
|
+
*
|
|
590
|
+
* Useful for broader matching or grouping taxonomies by product/service.
|
|
591
|
+
*
|
|
592
|
+
* @param taxonomy - Full taxonomy string
|
|
593
|
+
* @returns Taxonomy without intent, or null if invalid
|
|
594
|
+
*
|
|
595
|
+
* @example
|
|
596
|
+
* getBaseTaxonomy('insurance.auto.full_coverage.quote')
|
|
597
|
+
* // Returns: 'insurance.auto.full_coverage'
|
|
598
|
+
*/
|
|
599
|
+
declare function getBaseTaxonomy(taxonomy: string): string | null;
|
|
600
|
+
/**
|
|
601
|
+
* Check if two taxonomies match hierarchically
|
|
602
|
+
*
|
|
603
|
+
* Returns true if they share the same vertical, category, and subcategory
|
|
604
|
+
* (regardless of intent).
|
|
605
|
+
*
|
|
606
|
+
* @param taxonomy1 - First taxonomy
|
|
607
|
+
* @param taxonomy2 - Second taxonomy
|
|
608
|
+
* @returns True if they match hierarchically
|
|
609
|
+
*
|
|
610
|
+
* @example
|
|
611
|
+
* matchesTaxonomy(
|
|
612
|
+
* 'insurance.auto.full_coverage.quote',
|
|
613
|
+
* 'insurance.auto.full_coverage.apply'
|
|
614
|
+
* )
|
|
615
|
+
* // Returns: true (same base, different intent)
|
|
616
|
+
*/
|
|
617
|
+
declare function matchesTaxonomy(taxonomy1: string, taxonomy2: string): boolean;
|
|
618
|
+
/**
|
|
619
|
+
* Get vertical from taxonomy
|
|
620
|
+
*
|
|
621
|
+
* Extracts just the industry vertical (tier 1).
|
|
622
|
+
*
|
|
623
|
+
* @param taxonomy - Taxonomy string
|
|
624
|
+
* @returns Vertical or null if invalid
|
|
625
|
+
*
|
|
626
|
+
* @example
|
|
627
|
+
* getVertical('insurance.auto.full_coverage.quote')
|
|
628
|
+
* // Returns: 'insurance'
|
|
629
|
+
*/
|
|
630
|
+
declare function getVertical(taxonomy: string): string | null;
|
|
631
|
+
/**
|
|
632
|
+
* Suggest taxonomies based on user query
|
|
633
|
+
*
|
|
634
|
+
* Analyzes a user query and suggests appropriate taxonomies.
|
|
635
|
+
* This is a basic implementation - you may want to enhance it
|
|
636
|
+
* with ML/NLP for better accuracy.
|
|
637
|
+
*
|
|
638
|
+
* @param query - User's search query
|
|
639
|
+
* @returns Array of suggested taxonomy strings
|
|
640
|
+
*
|
|
641
|
+
* @example
|
|
642
|
+
* suggestTaxonomies("I need car insurance")
|
|
643
|
+
* // Returns: ['insurance.auto.full_coverage.quote', 'insurance.auto.liability.quote']
|
|
644
|
+
*/
|
|
645
|
+
declare function suggestTaxonomies(query: string): string[];
|
|
646
|
+
|
|
647
|
+
export { type APIError, APIRequestError, type AdScore, type AdUnit, type AgentSignupRequest, type AgentSignupResponse, AttentionMarketClient, AttentionMarketError, type Constraints, type Context, type CreateClickEventParams, type CreateImpressionEventParams, type CreateOpportunityParams, type DecideRequest, type DecideResponse, type Disclosure, type EventIngestRequest, type EventIngestResponse, type EventType, type Intent, MockAttentionMarketClient, type MockClientConfig, NetworkError, type Opportunity, type ParsedTaxonomy, type Placement, type PlacementType, type PolicyResponse, type Privacy, type SDKConfig, type SanitizeURLOptions, type SponsoredSuggestion, type SponsoredTool, type TaxonomyIntent, TimeoutError, type ToolCall, type Tracking, buildTaxonomy, createClickEvent, createImpressionEvent, createOpportunity, detectIntent, escapeHTML, generateTimestamp, generateUUID, getBaseTaxonomy, getVertical, isValidTaxonomy, matchesTaxonomy, parseTaxonomy, sanitizeURL, suggestTaxonomies };
|
package/dist/index.d.ts
CHANGED
|
@@ -61,6 +61,15 @@ interface Constraints {
|
|
|
61
61
|
interface Privacy {
|
|
62
62
|
data_policy: 'coarse_only' | 'none' | 'extended';
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Scoring metadata for agent curation (Option C: Intelligent Integration)
|
|
66
|
+
* Included in multi-ad responses to help agents choose the best ad
|
|
67
|
+
*/
|
|
68
|
+
interface AdScore {
|
|
69
|
+
relevance: number;
|
|
70
|
+
composite: number;
|
|
71
|
+
position: number;
|
|
72
|
+
}
|
|
64
73
|
/**
|
|
65
74
|
* AdUnit is a discriminated union enforcing the OpenAPI oneOf constraint.
|
|
66
75
|
* Either suggestion OR tool is required based on unit_type.
|
|
@@ -71,12 +80,14 @@ type AdUnit = {
|
|
|
71
80
|
disclosure: Disclosure;
|
|
72
81
|
tracking: Tracking;
|
|
73
82
|
suggestion: SponsoredSuggestion;
|
|
83
|
+
_score?: AdScore;
|
|
74
84
|
} | {
|
|
75
85
|
unit_id: string;
|
|
76
86
|
unit_type: 'sponsored_tool';
|
|
77
87
|
disclosure: Disclosure;
|
|
78
88
|
tracking: Tracking;
|
|
79
89
|
tool: SponsoredTool;
|
|
90
|
+
_score?: AdScore;
|
|
80
91
|
};
|
|
81
92
|
interface Disclosure {
|
|
82
93
|
label: string;
|
|
@@ -93,6 +104,8 @@ interface SponsoredSuggestion {
|
|
|
93
104
|
body: string;
|
|
94
105
|
cta: string;
|
|
95
106
|
action_url: string;
|
|
107
|
+
tracking_url?: string;
|
|
108
|
+
tracked_url?: string;
|
|
96
109
|
}
|
|
97
110
|
interface SponsoredTool {
|
|
98
111
|
tool_name: string;
|
|
@@ -474,4 +487,161 @@ declare class TimeoutError extends AttentionMarketError {
|
|
|
474
487
|
constructor(message?: string);
|
|
475
488
|
}
|
|
476
489
|
|
|
477
|
-
|
|
490
|
+
/**
|
|
491
|
+
* Taxonomy helper utilities for AttentionMarket SDK
|
|
492
|
+
* Helps with building, validating, and working with the 4-tier taxonomy system
|
|
493
|
+
*/
|
|
494
|
+
type TaxonomyIntent = 'research' | 'compare' | 'quote' | 'trial' | 'book' | 'apply' | 'consultation';
|
|
495
|
+
/**
|
|
496
|
+
* Build a valid taxonomy string
|
|
497
|
+
*
|
|
498
|
+
* @param vertical - Industry vertical (e.g., "insurance", "business", "healthcare")
|
|
499
|
+
* @param category - Product/service category (e.g., "auto", "saas", "dental")
|
|
500
|
+
* @param subcategory - Specific offering (e.g., "full_coverage", "crm", "cosmetic")
|
|
501
|
+
* @param intent - Optional user journey stage
|
|
502
|
+
* @returns Properly formatted taxonomy string
|
|
503
|
+
*
|
|
504
|
+
* @example
|
|
505
|
+
* buildTaxonomy('insurance', 'auto', 'full_coverage', 'quote')
|
|
506
|
+
* // Returns: 'insurance.auto.full_coverage.quote'
|
|
507
|
+
*
|
|
508
|
+
* @example
|
|
509
|
+
* buildTaxonomy('business', 'saas', 'crm', 'trial')
|
|
510
|
+
* // Returns: 'business.saas.crm.trial'
|
|
511
|
+
*/
|
|
512
|
+
declare function buildTaxonomy(vertical: string, category: string, subcategory: string, intent?: TaxonomyIntent): string;
|
|
513
|
+
/**
|
|
514
|
+
* Detect user intent from query string
|
|
515
|
+
*
|
|
516
|
+
* Analyzes the user's query to determine their stage in the buying journey.
|
|
517
|
+
* Returns the most appropriate intent modifier.
|
|
518
|
+
*
|
|
519
|
+
* @param query - User's search query or question
|
|
520
|
+
* @returns Detected intent modifier
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* detectIntent("What is term life insurance?")
|
|
524
|
+
* // Returns: 'research'
|
|
525
|
+
*
|
|
526
|
+
* @example
|
|
527
|
+
* detectIntent("Get car insurance quote")
|
|
528
|
+
* // Returns: 'quote'
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* detectIntent("Best CRM software comparison")
|
|
532
|
+
* // Returns: 'compare'
|
|
533
|
+
*/
|
|
534
|
+
declare function detectIntent(query: string): TaxonomyIntent;
|
|
535
|
+
/**
|
|
536
|
+
* Validate taxonomy format
|
|
537
|
+
*
|
|
538
|
+
* Checks if a taxonomy string follows the correct format:
|
|
539
|
+
* - 3 or 4 parts separated by dots
|
|
540
|
+
* - All parts are lowercase alphanumeric with underscores
|
|
541
|
+
* - If 4 parts, last part must be a valid intent
|
|
542
|
+
*
|
|
543
|
+
* @param taxonomy - Taxonomy string to validate
|
|
544
|
+
* @returns True if valid, false otherwise
|
|
545
|
+
*
|
|
546
|
+
* @example
|
|
547
|
+
* isValidTaxonomy('insurance.auto.full_coverage.quote') // true
|
|
548
|
+
* isValidTaxonomy('insurance.auto') // false (too short)
|
|
549
|
+
* isValidTaxonomy('Insurance.Auto.Quote') // false (uppercase)
|
|
550
|
+
* isValidTaxonomy('insurance.auto.full_coverage.invalid') // false (invalid intent)
|
|
551
|
+
*/
|
|
552
|
+
declare function isValidTaxonomy(taxonomy: string): boolean;
|
|
553
|
+
/**
|
|
554
|
+
* Parsed taxonomy components
|
|
555
|
+
*/
|
|
556
|
+
interface ParsedTaxonomy {
|
|
557
|
+
/** Industry vertical (tier 1) */
|
|
558
|
+
vertical: string;
|
|
559
|
+
/** Product/service category (tier 2) */
|
|
560
|
+
category: string;
|
|
561
|
+
/** Specific offering (tier 3) */
|
|
562
|
+
subcategory: string;
|
|
563
|
+
/** User journey stage (tier 4, optional) */
|
|
564
|
+
intent?: TaxonomyIntent;
|
|
565
|
+
/** Full taxonomy string */
|
|
566
|
+
full: string;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Parse taxonomy into components
|
|
570
|
+
*
|
|
571
|
+
* Breaks down a taxonomy string into its constituent parts for analysis.
|
|
572
|
+
*
|
|
573
|
+
* @param taxonomy - Taxonomy string to parse
|
|
574
|
+
* @returns Parsed components or null if invalid
|
|
575
|
+
*
|
|
576
|
+
* @example
|
|
577
|
+
* parseTaxonomy('insurance.auto.full_coverage.quote')
|
|
578
|
+
* // Returns: {
|
|
579
|
+
* // vertical: 'insurance',
|
|
580
|
+
* // category: 'auto',
|
|
581
|
+
* // subcategory: 'full_coverage',
|
|
582
|
+
* // intent: 'quote',
|
|
583
|
+
* // full: 'insurance.auto.full_coverage.quote'
|
|
584
|
+
* // }
|
|
585
|
+
*/
|
|
586
|
+
declare function parseTaxonomy(taxonomy: string): ParsedTaxonomy | null;
|
|
587
|
+
/**
|
|
588
|
+
* Get taxonomy without intent modifier
|
|
589
|
+
*
|
|
590
|
+
* Useful for broader matching or grouping taxonomies by product/service.
|
|
591
|
+
*
|
|
592
|
+
* @param taxonomy - Full taxonomy string
|
|
593
|
+
* @returns Taxonomy without intent, or null if invalid
|
|
594
|
+
*
|
|
595
|
+
* @example
|
|
596
|
+
* getBaseTaxonomy('insurance.auto.full_coverage.quote')
|
|
597
|
+
* // Returns: 'insurance.auto.full_coverage'
|
|
598
|
+
*/
|
|
599
|
+
declare function getBaseTaxonomy(taxonomy: string): string | null;
|
|
600
|
+
/**
|
|
601
|
+
* Check if two taxonomies match hierarchically
|
|
602
|
+
*
|
|
603
|
+
* Returns true if they share the same vertical, category, and subcategory
|
|
604
|
+
* (regardless of intent).
|
|
605
|
+
*
|
|
606
|
+
* @param taxonomy1 - First taxonomy
|
|
607
|
+
* @param taxonomy2 - Second taxonomy
|
|
608
|
+
* @returns True if they match hierarchically
|
|
609
|
+
*
|
|
610
|
+
* @example
|
|
611
|
+
* matchesTaxonomy(
|
|
612
|
+
* 'insurance.auto.full_coverage.quote',
|
|
613
|
+
* 'insurance.auto.full_coverage.apply'
|
|
614
|
+
* )
|
|
615
|
+
* // Returns: true (same base, different intent)
|
|
616
|
+
*/
|
|
617
|
+
declare function matchesTaxonomy(taxonomy1: string, taxonomy2: string): boolean;
|
|
618
|
+
/**
|
|
619
|
+
* Get vertical from taxonomy
|
|
620
|
+
*
|
|
621
|
+
* Extracts just the industry vertical (tier 1).
|
|
622
|
+
*
|
|
623
|
+
* @param taxonomy - Taxonomy string
|
|
624
|
+
* @returns Vertical or null if invalid
|
|
625
|
+
*
|
|
626
|
+
* @example
|
|
627
|
+
* getVertical('insurance.auto.full_coverage.quote')
|
|
628
|
+
* // Returns: 'insurance'
|
|
629
|
+
*/
|
|
630
|
+
declare function getVertical(taxonomy: string): string | null;
|
|
631
|
+
/**
|
|
632
|
+
* Suggest taxonomies based on user query
|
|
633
|
+
*
|
|
634
|
+
* Analyzes a user query and suggests appropriate taxonomies.
|
|
635
|
+
* This is a basic implementation - you may want to enhance it
|
|
636
|
+
* with ML/NLP for better accuracy.
|
|
637
|
+
*
|
|
638
|
+
* @param query - User's search query
|
|
639
|
+
* @returns Array of suggested taxonomy strings
|
|
640
|
+
*
|
|
641
|
+
* @example
|
|
642
|
+
* suggestTaxonomies("I need car insurance")
|
|
643
|
+
* // Returns: ['insurance.auto.full_coverage.quote', 'insurance.auto.liability.quote']
|
|
644
|
+
*/
|
|
645
|
+
declare function suggestTaxonomies(query: string): string[];
|
|
646
|
+
|
|
647
|
+
export { type APIError, APIRequestError, type AdScore, type AdUnit, type AgentSignupRequest, type AgentSignupResponse, AttentionMarketClient, AttentionMarketError, type Constraints, type Context, type CreateClickEventParams, type CreateImpressionEventParams, type CreateOpportunityParams, type DecideRequest, type DecideResponse, type Disclosure, type EventIngestRequest, type EventIngestResponse, type EventType, type Intent, MockAttentionMarketClient, type MockClientConfig, NetworkError, type Opportunity, type ParsedTaxonomy, type Placement, type PlacementType, type PolicyResponse, type Privacy, type SDKConfig, type SanitizeURLOptions, type SponsoredSuggestion, type SponsoredTool, type TaxonomyIntent, TimeoutError, type ToolCall, type Tracking, buildTaxonomy, createClickEvent, createImpressionEvent, createOpportunity, detectIntent, escapeHTML, generateTimestamp, generateUUID, getBaseTaxonomy, getVertical, isValidTaxonomy, matchesTaxonomy, parseTaxonomy, sanitizeURL, suggestTaxonomies };
|
package/dist/index.js
CHANGED
|
@@ -26,13 +26,21 @@ __export(index_exports, {
|
|
|
26
26
|
MockAttentionMarketClient: () => MockAttentionMarketClient,
|
|
27
27
|
NetworkError: () => NetworkError,
|
|
28
28
|
TimeoutError: () => TimeoutError,
|
|
29
|
+
buildTaxonomy: () => buildTaxonomy,
|
|
29
30
|
createClickEvent: () => createClickEvent,
|
|
30
31
|
createImpressionEvent: () => createImpressionEvent,
|
|
31
32
|
createOpportunity: () => createOpportunity,
|
|
33
|
+
detectIntent: () => detectIntent,
|
|
32
34
|
escapeHTML: () => escapeHTML,
|
|
33
35
|
generateTimestamp: () => generateTimestamp,
|
|
34
36
|
generateUUID: () => generateUUID,
|
|
35
|
-
|
|
37
|
+
getBaseTaxonomy: () => getBaseTaxonomy,
|
|
38
|
+
getVertical: () => getVertical,
|
|
39
|
+
isValidTaxonomy: () => isValidTaxonomy,
|
|
40
|
+
matchesTaxonomy: () => matchesTaxonomy,
|
|
41
|
+
parseTaxonomy: () => parseTaxonomy,
|
|
42
|
+
sanitizeURL: () => sanitizeURL,
|
|
43
|
+
suggestTaxonomies: () => suggestTaxonomies
|
|
36
44
|
});
|
|
37
45
|
module.exports = __toCommonJS(index_exports);
|
|
38
46
|
|
|
@@ -736,6 +744,135 @@ var MockAttentionMarketClient = class {
|
|
|
736
744
|
return Object.keys(this.mockUnits);
|
|
737
745
|
}
|
|
738
746
|
};
|
|
747
|
+
|
|
748
|
+
// src/taxonomy-utils.ts
|
|
749
|
+
function buildTaxonomy(vertical, category, subcategory, intent) {
|
|
750
|
+
const parts = [vertical, category, subcategory];
|
|
751
|
+
if (intent) {
|
|
752
|
+
parts.push(intent);
|
|
753
|
+
}
|
|
754
|
+
return parts.join(".");
|
|
755
|
+
}
|
|
756
|
+
function detectIntent(query) {
|
|
757
|
+
const lowerQuery = query.toLowerCase();
|
|
758
|
+
if (/what is|how does|how do|learn about|tell me about|explain|understand|definition/i.test(lowerQuery)) {
|
|
759
|
+
return "research";
|
|
760
|
+
}
|
|
761
|
+
if (/best|compare|vs|versus|which|top|options|alternatives|review|recommend/i.test(lowerQuery)) {
|
|
762
|
+
return "compare";
|
|
763
|
+
}
|
|
764
|
+
if (/price|cost|how much|quote|estimate|pricing|rate|afford/i.test(lowerQuery)) {
|
|
765
|
+
return "quote";
|
|
766
|
+
}
|
|
767
|
+
if (/try|demo|free trial|test|preview|sample/i.test(lowerQuery)) {
|
|
768
|
+
return "trial";
|
|
769
|
+
}
|
|
770
|
+
if (/book|schedule|appointment|reserve|set up|make appointment/i.test(lowerQuery)) {
|
|
771
|
+
return "book";
|
|
772
|
+
}
|
|
773
|
+
if (/apply|sign up|get started|register|enroll|join/i.test(lowerQuery)) {
|
|
774
|
+
return "apply";
|
|
775
|
+
}
|
|
776
|
+
if (/talk to|speak with|consult|meet with|call|contact|discuss/i.test(lowerQuery)) {
|
|
777
|
+
return "consultation";
|
|
778
|
+
}
|
|
779
|
+
return "compare";
|
|
780
|
+
}
|
|
781
|
+
function isValidTaxonomy(taxonomy) {
|
|
782
|
+
const parts = taxonomy.split(".");
|
|
783
|
+
if (parts.length < 3 || parts.length > 4) {
|
|
784
|
+
return false;
|
|
785
|
+
}
|
|
786
|
+
const validIntents = [
|
|
787
|
+
"research",
|
|
788
|
+
"compare",
|
|
789
|
+
"quote",
|
|
790
|
+
"trial",
|
|
791
|
+
"book",
|
|
792
|
+
"apply",
|
|
793
|
+
"consultation"
|
|
794
|
+
];
|
|
795
|
+
if (parts.length === 4 && !validIntents.includes(parts[3])) {
|
|
796
|
+
return false;
|
|
797
|
+
}
|
|
798
|
+
return parts.every((part) => /^[a-z0-9_]+$/.test(part));
|
|
799
|
+
}
|
|
800
|
+
function parseTaxonomy(taxonomy) {
|
|
801
|
+
if (!isValidTaxonomy(taxonomy)) {
|
|
802
|
+
return null;
|
|
803
|
+
}
|
|
804
|
+
const parts = taxonomy.split(".");
|
|
805
|
+
const result = {
|
|
806
|
+
vertical: parts[0],
|
|
807
|
+
category: parts[1],
|
|
808
|
+
subcategory: parts[2],
|
|
809
|
+
full: taxonomy
|
|
810
|
+
};
|
|
811
|
+
if (parts[3]) {
|
|
812
|
+
result.intent = parts[3];
|
|
813
|
+
}
|
|
814
|
+
return result;
|
|
815
|
+
}
|
|
816
|
+
function getBaseTaxonomy(taxonomy) {
|
|
817
|
+
const parsed = parseTaxonomy(taxonomy);
|
|
818
|
+
if (!parsed) return null;
|
|
819
|
+
return `${parsed.vertical}.${parsed.category}.${parsed.subcategory}`;
|
|
820
|
+
}
|
|
821
|
+
function matchesTaxonomy(taxonomy1, taxonomy2) {
|
|
822
|
+
const base1 = getBaseTaxonomy(taxonomy1);
|
|
823
|
+
const base2 = getBaseTaxonomy(taxonomy2);
|
|
824
|
+
return base1 !== null && base2 !== null && base1 === base2;
|
|
825
|
+
}
|
|
826
|
+
function getVertical(taxonomy) {
|
|
827
|
+
const parsed = parseTaxonomy(taxonomy);
|
|
828
|
+
return parsed ? parsed.vertical : null;
|
|
829
|
+
}
|
|
830
|
+
function suggestTaxonomies(query) {
|
|
831
|
+
const lowerQuery = query.toLowerCase();
|
|
832
|
+
const intent = detectIntent(query);
|
|
833
|
+
const suggestions = [];
|
|
834
|
+
if (/car|auto|vehicle|drive|driving/.test(lowerQuery)) {
|
|
835
|
+
suggestions.push(buildTaxonomy("insurance", "auto", "full_coverage", intent));
|
|
836
|
+
suggestions.push(buildTaxonomy("insurance", "auto", "liability", intent));
|
|
837
|
+
}
|
|
838
|
+
if (/health|medical|doctor/.test(lowerQuery)) {
|
|
839
|
+
suggestions.push(buildTaxonomy("insurance", "health", "individual", intent));
|
|
840
|
+
}
|
|
841
|
+
if (/life insurance/.test(lowerQuery)) {
|
|
842
|
+
suggestions.push(buildTaxonomy("insurance", "life", "term", intent));
|
|
843
|
+
}
|
|
844
|
+
if (/crm|customer|sales|lead/.test(lowerQuery)) {
|
|
845
|
+
suggestions.push(buildTaxonomy("business", "saas", "crm", intent));
|
|
846
|
+
}
|
|
847
|
+
if (/online store|ecommerce|sell online/.test(lowerQuery)) {
|
|
848
|
+
suggestions.push(buildTaxonomy("business", "ecommerce", "platform", intent));
|
|
849
|
+
}
|
|
850
|
+
if (/project management|task|team/.test(lowerQuery)) {
|
|
851
|
+
suggestions.push(buildTaxonomy("business", "saas", "project_management", intent));
|
|
852
|
+
}
|
|
853
|
+
if (/accident|injury|hurt/.test(lowerQuery)) {
|
|
854
|
+
suggestions.push(buildTaxonomy("legal", "personal_injury", "accident", intent));
|
|
855
|
+
}
|
|
856
|
+
if (/divorce|custody|family law/.test(lowerQuery)) {
|
|
857
|
+
suggestions.push(buildTaxonomy("legal", "family_law", "divorce", intent));
|
|
858
|
+
}
|
|
859
|
+
if (/dentist|teeth|dental/.test(lowerQuery)) {
|
|
860
|
+
suggestions.push(buildTaxonomy("healthcare", "dental", "general", intent));
|
|
861
|
+
}
|
|
862
|
+
if (/therapist|therapy|counseling/.test(lowerQuery)) {
|
|
863
|
+
suggestions.push(buildTaxonomy("healthcare", "mental_health", "therapy", intent));
|
|
864
|
+
}
|
|
865
|
+
if (/mover|moving|relocate/.test(lowerQuery)) {
|
|
866
|
+
suggestions.push(buildTaxonomy("home_services", "moving", "local", intent));
|
|
867
|
+
}
|
|
868
|
+
if (/plumber|plumbing|leak/.test(lowerQuery)) {
|
|
869
|
+
suggestions.push(buildTaxonomy("home_services", "plumbing", "emergency", intent));
|
|
870
|
+
}
|
|
871
|
+
if (/clean|cleaning|maid/.test(lowerQuery)) {
|
|
872
|
+
suggestions.push(buildTaxonomy("home_services", "cleaning", "regular", intent));
|
|
873
|
+
}
|
|
874
|
+
return suggestions;
|
|
875
|
+
}
|
|
739
876
|
// Annotate the CommonJS export names for ESM import in node:
|
|
740
877
|
0 && (module.exports = {
|
|
741
878
|
APIRequestError,
|
|
@@ -744,12 +881,20 @@ var MockAttentionMarketClient = class {
|
|
|
744
881
|
MockAttentionMarketClient,
|
|
745
882
|
NetworkError,
|
|
746
883
|
TimeoutError,
|
|
884
|
+
buildTaxonomy,
|
|
747
885
|
createClickEvent,
|
|
748
886
|
createImpressionEvent,
|
|
749
887
|
createOpportunity,
|
|
888
|
+
detectIntent,
|
|
750
889
|
escapeHTML,
|
|
751
890
|
generateTimestamp,
|
|
752
891
|
generateUUID,
|
|
753
|
-
|
|
892
|
+
getBaseTaxonomy,
|
|
893
|
+
getVertical,
|
|
894
|
+
isValidTaxonomy,
|
|
895
|
+
matchesTaxonomy,
|
|
896
|
+
parseTaxonomy,
|
|
897
|
+
sanitizeURL,
|
|
898
|
+
suggestTaxonomies
|
|
754
899
|
});
|
|
755
900
|
//# sourceMappingURL=index.js.map
|