UNPKG

netstorage

Version:

A TypeScript API and CLI for the Akamai NetStorage REST interface

43 lines (42 loc) 2.23 kB
import { createLogger, createRateLimiters, type WinstonLogLevel, type RateLimitConfig } from '../index'; /** * Unified configuration interface for initializing a NetStorage client. * * @property {string} key - The API key used for NetStorage authentication. * @property {string} keyName - The name associated with the API key. * @property {string} host - The NetStorage hostname (excluding protocol). * @property {boolean} [ssl] - Whether to use SSL (HTTPS). Defaults to false. * @property {string} [cpCode] - Optional CP code used to prefix NetStorage paths. * @property {WinstonLogLevel} [logLevel] - Optional log level for internal logging. * @property {RateLimitConfig} [rateLimitConfig] - Optional configuration for rate limiter creation. * @property {{ timeout?: number }} [request] - Optional request config (e.g., request timeout in ms). * @property {ReturnType<typeof createLogger>} logger - Logger instance to use for internal logging. * @property {ReturnType<typeof createRateLimiters>} rateLimiters - Rate limiter instance to use for request throttling. * @property {string} [lastReplPath] - Optional REPL path to restore previous session location in interactive shell. * @property {(path?: string) => string} uri - Method to build a URI with an optional path. */ export interface NetStorageClientConfig { key: string; keyName: string; host: string; ssl?: boolean; cpCode?: string; logLevel?: WinstonLogLevel; rateLimitConfig?: RateLimitConfig; request?: { timeout?: number; }; logger: ReturnType<typeof createLogger>; rateLimiters: ReturnType<typeof createRateLimiters>; lastReplPath?: string; uri(path?: string): string; } /** * Creates a fully validated and normalized NetStorage client configuration. * Ensures required fields are present and applies defaults for optional values. * * @param input - A partial configuration object provided by the consumer. * @returns A complete NetStorageClientConfig with defaults applied and values validated. * @throws {ConfigValidationError} If a required field is missing or invalid. */ export declare function createConfig(input: Partial<NetStorageClientConfig>): NetStorageClientConfig;