import type { Optional } from '../../types'; import type { ServiceRequest, ServiceResponse } from '../schema'; type IsValidArg = T extends Record ? (keyof T extends never ? false : true) : true; type AddOptionalParameters = T extends (a: infer A, b: infer B) => infer R ? IsValidArg extends true ? (a: A, opts?: X) => Promise> : (a: any, opts?: X) => Promise> : never; type InterfaceWithExtraOptionalParameters = { [P in keyof T]: AddOptionalParameters }; export interface ClientRequestOptions { headers?: Record; metadata?: Record; timeout?: number; signal?: AbortSignal; } export type RemoteService = InterfaceWithExtraOptionalParameters; export type ClientResponse = ServiceResponse; export type ClientRequestInit = Optional; export type ClientRequest = ServiceRequest & { options: ClientRequestOptions }; export type ClientConnection = (req: ClientRequest) => Promise>; // export type ClientConnection = (req: ClientRequest) => Promise>;