import { orderRoutes } from '@d8d/allin-order-module'; import { rpcClient } from '@d8d/shared-ui-components/utils/hc' import type { InferRequestType, InferResponseType } from 'hono/client'; export class OrderClientManager { private static instance: OrderClientManager; private client: ReturnType> | null = null; private constructor() {} public static getInstance(): OrderClientManager { if (!OrderClientManager.instance) { OrderClientManager.instance = new OrderClientManager(); } return OrderClientManager.instance; } // 初始化客户端 public init(baseUrl: string = '/'): ReturnType> { return this.client = rpcClient(baseUrl); } // 获取客户端实例 public get(): ReturnType> { if (!this.client) { return this.init() } return this.client; } // 重置客户端(用于测试或重新初始化) public reset(): void { this.client = null; } } // 导出单例实例 const orderClientManager = OrderClientManager.getInstance(); // 导出默认客户端实例(延迟初始化) export const orderClient = orderClientManager.get() // 导出类型定义 export type CreateOrderRequest = InferRequestType['json']; export type CreateOrderResponse = InferResponseType; export type UpdateOrderRequest = InferRequestType['json']; export type UpdateOrderResponse = InferResponseType; export type DeleteOrderRequest = InferRequestType['param']; export type DeleteOrderResponse = InferResponseType; export type GetAllOrdersRequest = InferRequestType['query']; export type GetAllOrdersResponse = InferResponseType; export type GetOrderByIdRequest = InferRequestType['param']; export type GetOrderByIdResponse = InferResponseType; export type ActivateOrderRequest = InferRequestType['param']; export type ActivateOrderResponse = InferResponseType; export type CloseOrderRequest = InferRequestType['param']; export type CloseOrderResponse = InferResponseType; export type BatchAddPersonsRequest = InferRequestType['json']; export type BatchAddPersonsResponse = InferResponseType; export type CreateOrderPersonAssetRequest = InferRequestType['json']; export type CreateOrderPersonAssetResponse = InferResponseType; export type QueryOrderPersonAssetRequest = InferRequestType['query']; export type QueryOrderPersonAssetResponse = InferResponseType; export type DeleteOrderPersonAssetRequest = InferRequestType['param']; export type DeleteOrderPersonAssetResponse = InferResponseType; export { orderClientManager }