keywrods libarry update

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-18 17:57:56 +00:00
parent 9e88c475f7
commit 43df7af989
16 changed files with 1428 additions and 45 deletions

View File

@@ -2270,7 +2270,8 @@ export interface SeedKeywordResponse {
results: SeedKeyword[];
}
export async function fetchSeedKeywords(filters?: {
// Keywords Library API - uses /v1/auth/keywords-library/ endpoint
export async function fetchKeywordsLibrary(filters?: {
industry?: number;
sector?: number;
country?: string;
@@ -2302,9 +2303,12 @@ export async function fetchSeedKeywords(filters?: {
if (filters?.difficulty_max !== undefined) params.append('difficulty_max', filters.difficulty_max.toString());
const queryString = params.toString();
return fetchAPI(`/v1/auth/seed-keywords/${queryString ? `?${queryString}` : ''}`);
return fetchAPI(`/v1/auth/keywords-library/${queryString ? `?${queryString}` : ''}`);
}
// Legacy alias - maps to new endpoint
export const fetchSeedKeywords = fetchKeywordsLibrary;
/**
* Fetch Seed Keyword Statistics
*/
@@ -2330,7 +2334,110 @@ export interface KeywordStats {
}
export async function fetchKeywordStats(): Promise<KeywordStats> {
return fetchAPI('/v1/auth/seed-keywords/stats/');
return fetchAPI('/v1/auth/keywords-library/stats/');
}
/**
* Keywords Library - Sector Stats with dynamic fallback thresholds
*/
export interface SectorStatResult {
count: number;
threshold?: number;
}
export interface SectorStats {
total: SectorStatResult;
available: SectorStatResult;
high_volume: SectorStatResult;
premium_traffic: SectorStatResult;
long_tail: SectorStatResult;
quick_wins: SectorStatResult;
}
export interface SectorStatsItem {
sector_id: number;
sector_name: string;
stats: SectorStats;
}
export interface SectorStatsResponse {
industry_id?: number;
sector_id?: number;
sectors?: SectorStatsItem[];
stats?: SectorStats;
}
export async function fetchSectorStats(filters: {
industry_id: number;
sector_id?: number;
site_id?: number;
}): Promise<SectorStatsResponse> {
const params = new URLSearchParams();
params.append('industry_id', filters.industry_id.toString());
if (filters.sector_id) params.append('sector_id', filters.sector_id.toString());
if (filters.site_id) params.append('site_id', filters.site_id.toString());
return fetchAPI(`/v1/auth/keywords-library/sector_stats/?${params.toString()}`);
}
/**
* Keywords Library - Filter Options (cascading)
*/
export interface FilterIndustryOption {
id: number;
name: string;
slug: string;
keyword_count: number;
}
export interface FilterSectorOption {
id: number;
name: string;
slug: string;
keyword_count: number;
}
export interface DifficultyLevel {
level: number;
label: string;
backend_range: [number, number];
}
export interface FilterOptionsResponse {
industries: FilterIndustryOption[];
sectors: FilterSectorOption[];
difficulty: {
range: { min_difficulty: number; max_difficulty: number };
levels: DifficultyLevel[];
};
volume: { min_volume: number; max_volume: number };
}
export async function fetchKeywordsLibraryFilterOptions(industryId?: number): Promise<FilterOptionsResponse> {
const params = new URLSearchParams();
if (industryId) params.append('industry_id', industryId.toString());
const queryString = params.toString();
return fetchAPI(`/v1/auth/keywords-library/filter_options/${queryString ? `?${queryString}` : ''}`);
}
/**
* Keywords Library - Bulk Add to Site
*/
export interface BulkAddResponse {
added: number;
skipped: number;
total_requested: number;
}
export async function bulkAddKeywordsToSite(siteId: number, keywordIds: number[]): Promise<BulkAddResponse> {
return fetchAPI('/v1/auth/keywords-library/bulk_add/', {
method: 'POST',
body: JSON.stringify({
site_id: siteId,
keyword_ids: keywordIds,
}),
});
}
/**