UNPKG

@dgac/nmb2b-client

Version:

EUROCONTROL Network Manager B2B SOAP client

108 lines (106 loc) 3.14 kB
import debug_default from "./utils/debug.js"; import { isConfigValid, obfuscate } from "./config.js"; import { download } from "./utils/xsd/index.js"; import { getAirspaceClient } from "./Airspace/index.js"; import { getFlightClient } from "./Flight/index.js"; import { getFlowClient } from "./Flow/index.js"; import { getGeneralInformationClient } from "./GeneralInformation/index.js"; //#region src/createB2BClient.ts const debug = debug_default(); const defaults = { flavour: "OPS", XSD_PATH: "/tmp/b2b-xsd" }; async function createB2BClient(args) { const options = { ...defaults, ...args }; debug("Instantiating B2B Client ..."); if (!isConfigValid(options)) { debug("Invalid options provided"); throw new Error("Invalid options provided"); } debug("Config is %o", obfuscate(options)); await download(options); const [Airspace, Flight, Flow, GeneralInformation] = await Promise.all([ getAirspaceClient(options), getFlightClient(options), getFlowClient(options), getGeneralInformationClient(options) ]); debug("Successfully created B2B Client"); return { Airspace, Flight, Flow, GeneralInformation }; } async function createAirspaceClient(args) { const options = { ...defaults, ...args }; debug("Instantiating B2B Airspace client ..."); if (!isConfigValid(options)) { debug("Invalid options provided"); throw new Error("Invalid options provided"); } debug("Config is %o", obfuscate(options)); await download(options); const client = await getAirspaceClient(options); debug("Successfully created B2B Airspace client"); return client; } async function createFlightClient(args) { const options = { ...defaults, ...args }; debug("Instantiating B2B Flight client ..."); if (!isConfigValid(options)) { debug("Invalid options provided"); throw new Error("Invalid options provided"); } debug("Config is %o", obfuscate(options)); await download(options); const client = await getFlightClient(options); debug("Successfully created B2B Flight client"); return client; } async function createFlowClient(args) { const options = { ...defaults, ...args }; debug("Instantiating B2B Flow client ..."); if (!isConfigValid(options)) { debug("Invalid options provided"); throw new Error("Invalid options provided"); } debug("Config is %o", obfuscate(options)); await download(options); const client = await getFlowClient(options); debug("Successfully created B2B Flow client"); return client; } async function createGeneralInformationClient(args) { const options = { ...defaults, ...args }; debug("Instantiating B2B GeneralInformation client ..."); if (!isConfigValid(options)) { debug("Invalid options provided"); throw new Error("Invalid options provided"); } debug("Config is %o", obfuscate(options)); await download(options); const client = await getGeneralInformationClient(options); debug("Successfully created B2B GeneralInformation client"); return client; } //#endregion export { createAirspaceClient, createB2BClient, createFlightClient, createFlowClient, createGeneralInformationClient }; //# sourceMappingURL=createB2BClient.js.map