/** * Theme Marketplace Service * * Provides community theme sharing, browsing, and installation. * Fetches from NinSys API with offline fallback to bundled gallery. * Max tier feature. * * @since v1.57.4 * @updated v2.2.3 — API integration + offline fallback */ import type { Tier } from '../../core/types/auth.js'; import type { ExtendedTheme } from './theme-types.js'; /** * Marketplace theme entry (includes community metadata) */ export interface MarketplaceTheme { theme: ExtendedTheme; author: { id: string; name: string; avatar?: string; }; stats: { downloads: number; rating: number; ratingCount: number; }; publishedAt: string; updatedAt: string; featured: boolean; verified: boolean; } /** * Theme search filters */ export interface ThemeSearchFilters { query?: string; type?: 'dark' | 'light' | 'all'; category?: string; sortBy?: 'popular' | 'rating' | 'recent' | 'downloads'; page?: number; pageSize?: number; } /** * Theme search result */ export interface ThemeSearchResult { themes: MarketplaceTheme[]; total: number; page: number; pageSize: number; hasMore: boolean; } /** * Theme install result */ export interface ThemeInstallResult { success: boolean; theme?: ExtendedTheme; error?: string; } /** * Marketplace submission request */ export interface ThemeSubmission { theme: ExtendedTheme; description: string; tags: string[]; screenshots?: string[]; } /** * Submission result */ export interface SubmissionResult { success: boolean; themeId?: string; message: string; } /** * Theme rating request */ export interface ThemeRating { themeId: string; rating: number; review?: string; } /** * Theme Marketplace Service */ export declare class ThemeMarketplaceService { private readonly apiUrl; private installedThemes; private cachedResults; private cacheExpiry; private lastCacheTime; constructor(apiUrl?: string); /** * Check if user has marketplace access */ hasAccess(tier: Tier): boolean; /** * Search marketplace themes via API, with offline fallback */ search(filters?: ThemeSearchFilters): Promise; /** * Get featured themes */ getFeatured(): Promise; /** * Get theme by ID from marketplace, with offline fallback */ getTheme(themeId: string): Promise; /** * Install theme from marketplace */ installTheme(themeId: string): Promise; /** * Install theme from URL (JSON file). * * Hardened against giant-response DoS (Phase 3 audit P1 #19): caps the * fetched body at THEME_MAX_BYTES via both the Content-Length header * (cheap pre-check) and a streaming-read cap (defends against missing or * lying headers). Without this cap, a 1 GB JSON response would be fully * buffered into memory. */ installFromUrl(url: string): Promise; /** * Submit theme to marketplace */ submitTheme(submission: ThemeSubmission): Promise; /** * Rate a theme */ rateTheme(rating: ThemeRating): Promise<{ success: boolean; message: string; }>; /** * Check if theme is installed */ isInstalled(themeId: string): boolean; /** * Get installed marketplace themes */ getInstalledThemes(): ExtendedTheme[]; /** * Uninstall marketplace theme */ uninstallTheme(themeId: string): boolean; /** * Clear cache */ clearCache(): void; } /** * Get marketplace service instance */ export declare function getMarketplaceService(): ThemeMarketplaceService; /** * Initialize marketplace with custom API URL */ export declare function initMarketplaceService(apiUrl?: string): ThemeMarketplaceService; /** * Format download count for display */ export declare function formatDownloadCount(count: number): string; /** * Format rating for display */ export declare function formatRating(rating: number): string; /** * Get star display for rating */ export declare function getRatingStars(rating: number): string; /** * Validate marketplace theme */ export declare function validateMarketplaceTheme(data: unknown): { valid: boolean; errors: string[]; }; //# sourceMappingURL=theme-marketplace.d.ts.map