/** * Path builder utility for API endpoints * Handles version prefixing for different API resources */ /** * API version types */ export type ApiVersion = '' | 'v1' | 'v2'; /** * Build a full API path with version prefix * * @param basePath - The base endpoint path (e.g., '/video/generations') * @param version - The API version ('' for no version, 'v1', or 'v2') * @returns The full path with version prefix (e.g., '/v2/video/generations') * * @example * ```typescript * buildPath('/video/generations', 'v2') // returns '/v2/video/generations' * buildPath('/messages', '') // returns '/messages' * buildPath('/bagoodex/images', 'v1') // returns '/v1/bagoodex/images' * ``` */ export function buildPath(basePath: string, version: ApiVersion): string { if (!version) { return basePath; } return `/${version}${basePath}`; }