/** * Factory functions for creating {@link ProtopediaInMemoryRepository} instances. * * This module provides convenience factory functions that simplify the setup * of ProtopediaInMemoryRepository for common use cases. * * ## About This Implementation * * These factory functions serve as **sample implementations** and are intentionally * verbose to demonstrate the pattern. Users are encouraged to create their own * custom factory functions optimized for their specific use cases. * * The current implementations are simple wrappers around {@link PromidasRepositoryBuilder}, * but can be extended with environment-specific defaults (e.g., different TTL values, * log levels, or API client configurations). * * @example Creating a custom factory * ```typescript * import { PromidasRepositoryBuilder } from 'promidas'; * import type { ProtopediaInMemoryRepository } from 'promidas'; * * export function createMyCustomRepository(): ProtopediaInMemoryRepository { * return new PromidasRepositoryBuilder() * .setStoreConfig({ ttlMs: 60 * 60 * 1000, logLevel: 'warn' }) // 1 hour TTL * .build(); * } * ``` * * @module */ import type { LogLevel } from './logger/index.js'; import type { ProtopediaInMemoryRepository } from './repository/types/index.js'; /** * Creates a PromidasRepository instance optimized for local execution environments. * * This factory function is designed for personal computers, local scripts, * and development environments where the TOKEN can be safely stored. * * ## Pre-configured Settings * * This function automatically configures the following settings: * * **Logger:** * - Log Level: `'info'` (records normal operations for development monitoring) * * **Store:** * - TTL: 30 minutes (1,800,000 ms) * - Max Data Size: 30 MiB (hard limit) * * **API Client:** * - Timeout: 90 seconds (accommodates 1-2 Mbps connections) * - User-Agent: `PromidasForLocal/{version}` * * ## Use Cases * * - Local development and testing * - Command-line scripts * - Personal automation tools * - Data analysis scripts * * @param config - Configuration options * @param config.protopediaApiToken - ProtoPedia API v2 token * @param config.logLevel - Log level for all components (optional, default: 'info') * @returns A configured PromidasRepository instance * * @example Basic usage * ```typescript * import { createPromidasForLocal } from "promidas"; * * const repository = createPromidasForLocal({ * protopediaApiToken: 'your-api-token', * }); * * // Setup snapshot with 100 prototypes * await repository.setupSnapshot({ limit: 100 }); * * // Get random prototype * const prototype = await repository.getRandomPrototypeFromSnapshot(); * console.log(prototype?.prototypeNm); * ``` * * @example With custom log level * ```typescript * const repository = createPromidasForLocal({ * protopediaApiToken: process.env.PROTOPEDIA_API_V2_TOKEN ?? 'no-token', * logLevel: 'warn', // Only show warnings and errors * }); * ``` */ export declare function createPromidasForLocal(config: { protopediaApiToken: string; logLevel?: LogLevel; }): ProtopediaInMemoryRepository; /** * Creates a PromidasRepository instance optimized for server backend environments. * * This factory function is designed for Node.js server applications * where the TOKEN is managed securely via environment variables. * * ## Pre-configured Settings * * This function automatically configures the following settings: * * **Environment Variable:** * - Token Source: `PROTOPEDIA_API_V2_TOKEN` (required) * * **Logger:** * - Log Level: `'warn'` (production-ready, warnings and errors only) * * **Store:** * - TTL: 10 minutes (600,000 ms) * - Max Data Size: 30 MiB (hard limit) * * **API Client:** * - Timeout: 30 seconds (server-grade connection) * - User-Agent: `PromidasForServer/{version}` * * ## Use Cases * * - REST API servers * - Background job processors * - Serverless functions (AWS Lambda, Cloud Functions) * - Microservices * * @param config - Configuration options * @param config.logLevel - Log level for all components (optional, default: 'warn') * @returns A configured PromidasRepository instance * @throws {Error} If PROTOPEDIA_API_V2_TOKEN environment variable is not set * * @example Basic usage * ```typescript * import { createPromidasForServer } from "promidas"; * * // TOKEN is read from PROTOPEDIA_API_V2_TOKEN environment variable * const repository = createPromidasForServer(); * * // Setup snapshot with 1000 prototypes * await repository.setupSnapshot({ limit: 1000 }); * * // Get prototype by ID * const prototype = await repository.getPrototypeFromSnapshotByPrototypeId(123); * ``` * * @example With custom log level * ```typescript * const repository = createPromidasForServer({ * logLevel: 'error', // Only show errors in production * }); * ``` */ export declare function createPromidasForServer(config?: { logLevel?: LogLevel; }): ProtopediaInMemoryRepository; //# sourceMappingURL=factory.d.ts.map