import type { MaybePromise } from '@wener/utils'; import type { MethodOptionsInit } from '../meta'; import type { ServiceRequest, ServiceResponse } from '../schema'; type IsValidArg = T extends Record ? (keyof T extends never ? false : true) : true; type AddParameters = T extends (a: infer A, b: infer B) => infer R ? IsValidArg extends true ? (req: A, options: X) => MaybePromise : (req: any, options: X) => MaybePromise : never; type InterfaceWithExtraParameters = { [P in keyof T]: AddParameters }; export interface ServerRequestOptions { id: string; headers: Record; metadata: Record; options: MethodOptionsInit; } export type LocalService = InterfaceWithExtraParameters; export type ServerResponse = ServiceResponse; export type ServerRequest = ServiceRequest;