UNPKG

coze-plugin-utils

Version:

Comprehensive utility library for Coze plugins with multimedia processing, browser automation, cloud storage integration, and AI-powered video/audio generation capabilities

107 lines (106 loc) 3.39 kB
/** * 全局配置管理模块 * 提供设置和获取全局配置的功能 */ import { IGlobalConfig, IJWTConfig, IWorkflows, IOSSConfig, IBrowserConfig, IViduConfig, IAzureConfig, IMinimaxConfig } from '../types/config'; /** * 重置全局配置到默认值 * * @returns 重置后的默认配置对象 * * @example * ```typescript * // 重置配置 * resetGlobalConfig(); * ``` */ export declare function resetGlobalConfig(): IGlobalConfig; /** * 设置全局配置 * * @param config - 要设置的配置对象,将与现有配置合并 * @returns 合并后的完整配置对象 * * @example * ```typescript * // 设置整个配置对象 * setGlobalConfig({ baseUrl: 'https://custom-api.coze.cn' }); * ``` */ export declare function setGlobalConfig(config: Partial<IGlobalConfig>): IGlobalConfig; /** * 设置全局配置 * * @param key - 指定要设置的配置键名,如 'baseUrl', 'jwt', 'workflows' * @param config - 要设置的配置值,类型取决于 key * @returns 合并后的完整配置对象 * @throws 当指定的 key 无效时抛出错误 * * @example * ```typescript * // 只设置 JWT 配置 * setGlobalConfig('jwt', { * appId: 'your-app-id', * keyid: 'your-key-id', * privateKey: 'your-private-key' * }); * * // 设置 Azure Speech 配置 * setGlobalConfig('azure', { * speech: { * key: 'your-azure-speech-key', * region: 'your-azure-region' * } * }); * * // 设置 MiniMax 配置 * setGlobalConfig('minimax', { * apiKey: 'your-minimax-api-key', * groupId: 'your-group-id' * }); * * // 设置 baseUrl * setGlobalConfig('baseUrl', 'https://custom-api.coze.cn'); * ``` */ export declare function setGlobalConfig<K extends keyof IGlobalConfig>(key: K, config: K extends 'baseUrl' ? string : K extends 'jwt' ? Partial<IJWTConfig> : K extends 'workflows' ? Partial<IWorkflows> : K extends 'aliyun' ? Partial<IOSSConfig> : K extends 'browser' ? Partial<IBrowserConfig> : K extends 'vidu' ? Partial<IViduConfig> : K extends 'azure' ? Partial<IAzureConfig> : K extends 'minimax' ? Partial<IMinimaxConfig> : never): IGlobalConfig; /** * 获取当前全局配置 * * @param key - 可选,指定要获取的配置键名,如 'baseUrl', 'jwt', 'workflows' * @returns 当前的全局配置对象或指定键的配置值(返回副本以防止意外修改) * @throws 当指定的 key 无效时抛出错误 * * @example * ```typescript * // 获取完整配置 * const config = getGlobalConfig(); * console.log(config.baseUrl); * * // 获取特定配置项 * const jwtConfig = getGlobalConfig('jwt'); * if (jwtConfig) { * // 使用JWT配置进行认证 * } * * // 获取 Azure 配置 * const azureConfig = getGlobalConfig('azure'); * if (azureConfig?.speech) { * // 使用 Azure Speech Service * console.log(azureConfig.speech.key, azureConfig.speech.region); * } * * // 获取 MiniMax 配置 * const minimaxConfig = getGlobalConfig('minimax'); * if (minimaxConfig?.apiKey) { * // 使用 MiniMax API * console.log(minimaxConfig.apiKey, minimaxConfig.groupId); * } * * // 获取 baseUrl * const baseUrl = getGlobalConfig('baseUrl'); * console.log(baseUrl); // https://api.coze.cn * ``` */ export declare function getGlobalConfig(): IGlobalConfig; export declare function getGlobalConfig<K extends keyof IGlobalConfig>(key: K): IGlobalConfig[K];