UNPKG

@dgac/nmb2b-client

Version:

EUROCONTROL Network Manager B2B SOAP client

41 lines (40 loc) 1.65 kB
import { Config } from "../config.mjs"; import { B2BRequest, Reply } from "../Common/types.mjs"; import { SoapOptions } from "../soap.mjs"; import { WithInjectedSendTime } from "./internals.mjs"; import { Client } from "soap"; //#region src/utils/soap-query-definition.d.ts type SoapQueryDefinition<TInput extends B2BRequest, TResult extends Reply> = { /** * Name of the service. */ service: string; /** * Name of the query. * * Will be used to infer the soap-client query function name if `executeQuery` is not defined. */ query: string; /** * Given a SoapClient, return the schema for the input of this query. * * Will be used to build a serializer. */ getSchema: (client: Client) => unknown; /** * Optional getter to extract the correct query function from a `SoapClient`. * * By default, will use `SoapClient[${query}Async]` */ executeQuery?: (client: Client) => (values: TInput, options?: SoapOptions) => Promise<[TResult]>; }; type SoapService<TDefinitions extends ServiceDefinition> = { readonly __soapClient: Client; readonly config: Config; /** @internal */ readonly __definitions: TDefinitions; } & { [TKey in keyof TDefinitions]: ExtractSoapQuery<TDefinitions[TKey]> }; type ServiceDefinition = Record<string, SoapQueryDefinition<any, any>>; type ExtractSoapQuery<T extends SoapQueryDefinition<B2BRequest, Reply>> = T extends SoapQueryDefinition<infer TInput, infer TResult> ? (input: WithInjectedSendTime<TInput>, options?: SoapOptions) => Promise<TResult> : never; //#endregion export { SoapQueryDefinition, SoapService }; //# sourceMappingURL=soap-query-definition.d.mts.map