/** * ProtopediaApiCustomClient class implementation. * * This module provides a class-based wrapper around the official * protopedia-api-v2-client with integrated logger management, * event-driven progress tracking, and high-level helper methods. * * Features: * - Fastify-style logger configuration (logger + logLevel) * - Event-driven progress tracking with type-safe discriminated unions * - Automatic data normalization and validation * - Result type for type-safe error handling * * @module */ import { type ListPrototypesParams } from 'protopedia-api-v2-client'; import type { FetchPrototypesResult } from '../types/result.types.js'; import type { ProtopediaApiCustomClientConfig } from './config.js'; /** * Custom API client that wraps protopedia-api-v2-client with enhanced features. * * This class manages: * - Logger configuration (Fastify-style with logger + logLevel) * - Integration with protopedia-api-v2-client * - Event-driven progress tracking for download operations * - High-level fetchPrototypes helper with normalization and error handling * * @example Basic usage * ```typescript * const client = new ProtopediaApiCustomClient({ * protoPediaApiClientOptions: { * token: process.env.PROTOPEDIA_API_TOKEN, * }, * logLevel: 'debug', * }); * * const result = await client.fetchPrototypes({ limit: 10 }); * if (result.ok) { * console.log(result.data); * } * ``` * * @example With progress tracking * ```typescript * const client = new ProtopediaApiCustomClient({ * protoPediaApiClientOptions: { * token: process.env.PROTOPEDIA_API_TOKEN, * }, * progressCallback: (event) => { * switch (event.type) { * case 'request-start': * console.log('Starting request...'); * break; * case 'download-progress': * console.log(`Progress: ${event.percentage.toFixed(1)}%`); * break; * case 'complete': * console.log(`Complete in ${event.totalTimeMs}ms`); * break; * } * }, * }); * ``` */ export declare class ProtopediaApiCustomClient { #private; /** * Create a new ProtopediaApiCustomClient instance. * * @param config - Configuration options for the client * @param config.protoPediaApiClientOptions - Options for protopedia-api-v2-client * @param config.protoPediaApiClientOptions.timeoutMs - Optional request timeout in milliseconds * @param config.protoPediaApiClientOptions.fetch - Optional custom fetch implementation * @param config.logger - Custom logger instance * @param config.logLevel - Log level for default logger or to update existing logger * @param config.progressLog - Enable download progress logging (default: true) * @param config.progressCallback - Event handler for download progress lifecycle events * * @throws {unknown} If the underlying protopedia-api-v2-client initialization fails * * @example Basic usage with progress logging * ```typescript * const client = new ProtopediaApiCustomClient({ * protoPediaApiClientOptions: { token: process.env.TOKEN }, * logLevel: 'info', // Shows progress logs * }); * ``` * * @example With custom event handler * ```typescript * const client = new ProtopediaApiCustomClient({ * protoPediaApiClientOptions: { token: process.env.TOKEN }, * progressLog: false, // Disable automatic logging * progressCallback: (event) => { * if (event.type === 'download-progress') { * updateProgressBar(event.percentage); * } * }, * }); * ``` */ constructor(config?: ProtopediaApiCustomClientConfig | null); /** * Fetch prototypes using the configured client, normalize them, * and return a structured result. * * This high-level helper combines API fetching, normalization, and * error handling into a single call. It uses the logger configured * during construction for error diagnostics. * * @param params - Query parameters for listing prototypes * @returns A {@link FetchPrototypesResult} with normalized data or error details * * @example * ```typescript * const result = await client.fetchPrototypes({ offset: 0, limit: 100 }); * if (result.ok) { * console.log(`Fetched ${result.data.length} prototypes`); * } else { * console.error(result.error, result.status); * } * ``` */ fetchPrototypes(params: ListPrototypesParams): Promise; /** * Direct access to the underlying protopedia-api-v2-client's listPrototypes method. * * Use this when you need the raw API response without normalization. * * @param params - Query parameters for listing prototypes * @returns Raw API response from protopedia-api-v2-client * * @example * ```typescript * const rawResult = await client.listPrototypes({ limit: 10 }); * console.log(rawResult.results); * ``` */ listPrototypes(params: ListPrototypesParams): Promise; } //# sourceMappingURL=protopedia-api-custom-client.d.ts.map