|
| 1 | +# `@dgac/nmb2b-client` — Documentation |
| 2 | + |
| 3 | +A TypeScript client for the **EUROCONTROL Network Manager B2B** web services |
| 4 | +(NM target version **27.0.0**). The library wraps the NM SOAP API and removes |
| 5 | +most of its pain points: it downloads and caches the WSDL/XSD automatically, |
| 6 | +serializes/deserializes awkward XSD types into idiomatic JavaScript values, |
| 7 | +reorders request keys to satisfy SOAP ordering rules, and exposes a fully typed, |
| 8 | +promise-based API. |
| 9 | + |
| 10 | +> Package: `@dgac/nmb2b-client` · License: MIT · Node `>=22` · ESM-only |
| 11 | +
|
| 12 | +--- |
| 13 | + |
| 14 | +## How this documentation is organised |
| 15 | + |
| 16 | +These docs are written for three audiences. Start with the one that matches |
| 17 | +what you are trying to do. |
| 18 | + |
| 19 | +| If you are… | Read this | |
| 20 | +| ---------------------------------------- | -------------------------------------------- | |
| 21 | +| **Consuming the library** in your app | [API & Usage Guide](./api-reference.md) | |
| 22 | +| **Contributing / onboarding** to the repo| [Getting Started](./getting-started.md) | |
| 23 | +| **Maintaining internals** / curious how it works | [Architecture](./architecture.md) | |
| 24 | + |
| 25 | +### Document index |
| 26 | + |
| 27 | +- **[Getting Started](./getting-started.md)** — repository layout, tooling |
| 28 | + (pnpm, tsdown, vitest, oxlint), build/test/release workflows, how to add a new |
| 29 | + SOAP operation, and the fixture-based testing system. |
| 30 | +- **[Architecture](./architecture.md)** — the request lifecycle end to end: |
| 31 | + configuration, security, WSDL bootstrapping & caching, the SOAP service |
| 32 | + factory, the serializer/deserializer, hooks, and error handling. |
| 33 | +- **[API & Usage Guide](./api-reference.md)** — the public surface: client |
| 34 | + factories, configuration options, authentication, every service domain and its |
| 35 | + operations, the hooks API, and error handling patterns. |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## 60-second overview |
| 40 | + |
| 41 | +```typescript |
| 42 | +import { createB2BClient } from '@dgac/nmb2b-client'; |
| 43 | +import fs from 'node:fs'; |
| 44 | + |
| 45 | +// 1. Authenticate (client certificate or API-gateway credentials) |
| 46 | +const client = await createB2BClient({ |
| 47 | + security: { |
| 48 | + pfx: fs.readFileSync('/path/to/cert.p12'), |
| 49 | + passphrase: 'your-passphrase', |
| 50 | + }, |
| 51 | +}); |
| 52 | + |
| 53 | +// 2. Call a SOAP operation — fully typed, returns a parsed JS object |
| 54 | +const res = await client.Airspace.queryCompleteAIXMDatasets(); |
| 55 | +``` |
| 56 | + |
| 57 | +Under the hood, `createB2BClient`: |
| 58 | + |
| 59 | +1. Validates the config and security object. |
| 60 | +2. Downloads the NM WSDL/XSD tarball (once) and caches it on disk under a |
| 61 | + version-stamped directory. |
| 62 | +3. Builds one `soap` client per domain, wiring in the serializer, the custom |
| 63 | + deserializer, and the configured hooks. |
| 64 | +4. Returns an object with four domain services: `Airspace`, `Flight`, `Flow`, |
| 65 | + and `GeneralInformation`. |
| 66 | + |
| 67 | +### The four service domains |
| 68 | + |
| 69 | +| Domain | Service WSDL | What it covers | |
| 70 | +| -------------------- | ------------------------- | ------------------------------------------------ | |
| 71 | +| `Airspace` | `AirspaceServices` | AIXM datasets, AUP / E-AUP airspace use plans | |
| 72 | +| `Flight` | `FlightServices` | Flight plans & flight lists/queries | |
| 73 | +| `Flow` | `FlowServices` | Regulations, hotspots, traffic counts, capacity / OTMV plans | |
| 74 | +| `GeneralInformation` | `GeneralinformationServices` | WSDL discovery, user information | |
| 75 | + |
| 76 | +See the [API guide](./api-reference.md#service-domains--operations) for the full |
| 77 | +operation list per domain. |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +## Key design ideas at a glance |
| 82 | + |
| 83 | +- **No bundled WSDL/XSD.** The schema is fetched from NM at startup and cached, |
| 84 | + so the package stays small and always matches the targeted NM version |
| 85 | + (`27.0.0`, defined in [`src/constants.ts`](../src/constants.ts)). |
| 86 | +- **Schema-driven (de)serialization.** Request objects are walked against the |
| 87 | + WSDL schema to reorder keys and convert types (e.g. JS `Date` → |
| 88 | + `DateYearMonthDay` string); responses are converted back (e.g. duration |
| 89 | + strings → seconds). See [Architecture → Transformers](./architecture.md#5-the-transformers-serializer--deserializer). |
| 90 | +- **Typed errors.** A non-`OK` SOAP reply is thrown as an |
| 91 | + [`NMB2BError`](../src/utils/NMB2BError.ts) carrying the NM status code and |
| 92 | + validation details. |
| 93 | +- **Hooks.** User callbacks run around every query for logging, metrics, tracing. |
| 94 | +- **Tree-shakeable subpath exports.** Besides the main entry, the package |
| 95 | + exposes `/security`, `/config`, `/types`, and `/utils`. |
0 commit comments