mira-app-server
Version:
Mira Server - standalone server application using mira-app-core
71 lines • 2 kB
TypeScript
/**
* MiraClient 工厂与 server 解析
*
* 统一从全局选项 / 当前 profile / 默认值解析出 server 与 token,
* 为各命令提供已配置好鉴权的 MiraClient 实例。
*/
import { MiraClient } from 'mira-app-core/shared/sdk';
import { CredentialProfile } from './credentials';
/** 默认服务器地址 */
export declare const DEFAULT_SERVER = "http://localhost:8081";
/**
* 解析目标 server 地址:
* 1. 全局 --server 参数
* 2. --profile 指定的 profile 的 server
* 3. 当前 profile 的 server
* 4. 默认 DEFAULT_SERVER
*/
export declare function resolveServer(opts?: {
server?: string;
profile?: string;
}): string;
/**
* 解析 token:
* 1. 全局 --token 参数
* 2. --profile 指定的 profile 的 token
* 3. 当前 profile 的 token
*/
export declare function resolveToken(opts?: {
token?: string;
profile?: string;
}): string | undefined;
/**
* 解析后的连接信息
*/
export interface ResolvedConnection {
server: string;
token?: string;
profile?: CredentialProfile;
}
/**
* 解析出完整的连接信息(server + token + 来源 profile)
*/
export declare function resolveConnection(opts?: {
server?: string;
token?: string;
profile?: string;
}): ResolvedConnection;
/**
* 创建已配置鉴权的 MiraClient(合并全局选项)
*
* @param requireAuth 是否要求已登录(为 true 且无 token 时直接 fatal)
* @param overrides 命令级行为覆盖(一般留空,从全局选项读取)
*/
export declare function getClient(requireAuth?: boolean, overrides?: {
server?: string;
token?: string;
profile?: string;
}): {
client: MiraClient;
connection: ResolvedConnection;
};
/**
* 创建无需鉴权的 MiraClient(用于 login/register/health 等公开接口)
*/
export declare function getAnonymousClient(overrides?: {
server?: string;
}): {
client: MiraClient;
connection: ResolvedConnection;
};
//# sourceMappingURL=client.d.ts.map