{"id":26129225,"url":"https://github.com/dgac/nmb2b-client-js","last_synced_at":"2026-01-29T10:11:35.693Z","repository":{"id":38821506,"uuid":"147816594","full_name":"DGAC/nmb2b-client-js","owner":"DGAC","description":"EUROCONTROL Network Manager B2B WebService client","archived":false,"fork":false,"pushed_at":"2025-03-14T21:19:05.000Z","size":1217,"stargazers_count":8,"open_issues_count":2,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-12T22:02:07.067Z","etag":null,"topics":["b2b","eurocontrol","network-manager","nodejs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DGAC.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-07T11:49:42.000Z","updated_at":"2025-03-14T21:18:52.000Z","dependencies_parsed_at":"2024-01-09T09:40:08.752Z","dependency_job_id":"f018d854-a5e3-480a-ae1b-d8c860dac80a","html_url":"https://github.com/DGAC/nmb2b-client-js","commit_stats":{"total_commits":296,"total_committers":9,"mean_commits":"32.888888888888886","dds":"0.20608108108108103","last_synced_commit":"84cb2dad05db5f3c3ec63f4961070b9b2650303f"},"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DGAC%2Fnmb2b-client-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DGAC%2Fnmb2b-client-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DGAC%2Fnmb2b-client-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DGAC%2Fnmb2b-client-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DGAC","download_url":"https://codeload.github.com/DGAC/nmb2b-client-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248761613,"owners_count":21157589,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["b2b","eurocontrol","network-manager","nodejs","typescript"],"created_at":"2025-03-10T19:40:03.617Z","updated_at":"2026-01-18T02:40:13.074Z","avatar_url":"https://github.com/DGAC.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Network Manager B2B Client\n\n![License](https://img.shields.io/npm/l/@dgac/nmb2b-client.svg)\n![NodeVersion](https://img.shields.io/node/v/@dgac/nmb2b-client.svg)\n[![PackageVersion](https://img.shields.io/npm/v/@dgac/nmb2b-client.svg)](https://npmjs.com/package/@dgac/nmb2b-client)\n![Downloads](https://img.shields.io/npm/dm/@dgac/nmb2b-client)\n![Test](https://github.com/DGAC/nmb2b-client-js/workflows/Build,%20test,%20publish/badge.svg?branch=master)\n[![codecov](https://codecov.io/gh/DGAC/nmb2b-client-js/branch/master/graph/badge.svg)](https://codecov.io/gh/DGAC/nmb2b-client-js)\n\nExposes a general purpose Javascript library to interact with NM B2B web services. The idea is to abstract pain points while offering an API that maps the NM B2B WS API.\n\nNM target version: **27.0.0**\n\n## Simple usage example\n\nhttps://github.com/DGAC/nmb2b-client-js-example\n\n# Features\n\n- No WSDL/XSD dependency. The library will download and cache those on start up.\n- Natural serialization/deserialization of certain types.\n\nFor instance, the Flow.retrieveOTMVPlan query expects a `day` attribute with the XSD type `DateYearMonthDay`. This type is a string, representing a date in the `YYYY-MM-DD` format. This library allows you to pass a traditional JS Date object instead.\n\n```typescript\nconst res = await Flow.retrieveOTMVPlan({\n  dataset: { type: 'OPERATIONAL' },\n  day: new Date(),\n  otmvsWithDuration: { item: [{ trafficVolume: 'LFERMS' }] },\n});\n```\n\n- Request object key reordering when needed.\n\nIn SOAP, key order matters.\n\n```typescript\n// OK\nawait Flow.retrieveOTMVPlan({\n  dataset: { type: 'OPERATIONAL' },\n  day: moment.utc().toDate(),\n  otmvsWithDuration: { item: [{ trafficVolume: 'LFERMS' }] },\n});\n\n// Would normally fail\nawait const Flow.retrieveOTMVPlan({\n  day: moment.utc().toDate(),\n  dataset: { type: 'OPERATIONAL' },\n  otmvsWithDuration: { item: [{ trafficVolume: 'LFERMS' }] },\n});\n```\n\nThe library reorder request object keys to match what's expressed in the XSD/WSDL. Therefore, the second example works fine.\n\n- TypeScript support.\n\nThe following example will raise a type error.\n\n```typescript\n// Raises a type error\nawait Flow.retrieveOTMVPlan({\n  dataset: { type: 'OPERATIONNAL' }, // Notice the typo\n  day: moment.utc().toDate(),\n  otmvsWithDuration: { item: [{ trafficVolume: 'LFERMS' }] },\n});\n```\n\n- Debug output\n\nDebug output is controlled via the [`debug`](https://npmjs.com/package/debug) package. All debug output from this library is scoped under `@dgac/nmb2b-client` namespace.\n\nJust set a `DEBUG=@dgac/nmb2b-client*` environment variable :\n[![asciicast](https://asciinema.org/a/xWovjkKlkqePBolRl3OqAFBi8.svg)](https://asciinema.org/a/xWovjkKlkqePBolRl3OqAFBi8)\n\n- Hooks\n\nCustom user provided callbacks to be executed when a SOAP query is either started or completed.\n\n# Usage\n\n## Main service\n\n```typescript\nimport { createB2BClient } from '@dgac/nmb2b-client';\n\n// See below for more information about the security argument\nconst client = await createB2BClient({ security });\n\nconst res = await client.Airspace.queryCompleteAIXMDatasets();\n```\n\n## Per domain service\n\n```typescript\nimport { createAirspaceClient } from '@dgac/nmb2b-client';\n\n// See below for more information about the security argument\nconst Airspace = await createAirspaceClient({ security });\n\nconst res = await Airspace.queryCompleteAIXMDatasets();\n```\n\n## Error handling\n\n```typescript\nimport { createAirspaceClient, NMB2BError } from '@dgac/nmb2b-client';\n\ntry {\n  const Airspace = await createAirspaceClient({ security });\n\n  const res = await Airspace.queryCompleteAIXMDatasets();\n} catch (err) {\n  if (err instanceof NMB2BError) {\n    if (err.status === 'OBJECT_NOT_FOUND') {\n      // ...\n    }\n  }\n\n  // ...\n}\n```\n\n## B2B Security\n\nEvery request to the NM B2B web services must be authenticated using a client certificate. This library needs to be initialized with a `security` object, containing the certificate, key and passphrase associated.\n\n### With P12 certificate\n\n```javascript\nimport fs from 'fs';\n\nconst security = {\n  pfx: fs.readFileSync('/path/to/cert.p12'),\n  passphrase: 'your-passphrase',\n};\n\ncreateB2BClient({ security }).then((client) =\u003e {\n  client.Airspace.queryCompleteAIXMDatasets().then(() =\u003e {});\n});\n```\n\n### With PEM certificate\n\n```javascript\nimport fs from 'fs';\n\nconst security = {\n  pem: fs.readFileSync('/path/to/cert.pem'),\n  key: fs.readFileSync('/path/to/cert.key'),\n  passphrase: 'your-passphrase',\n};\n\ncreateB2BClient({ security }).then((client) =\u003e {\n  client.Airspace.queryCompleteAIXMDatasets().then(() =\u003e {});\n});\n```\n\n## Hooks\n\nHooks are user provided callbacks which will be executed during the SOAP query process.\n\nBasic example :\n\n```typescript\nconst client = await createB2BClient({\n  // ... other options,\n  hooks: [\n    function onRequestStart({ service, query, input }) {\n      console.log(`Query ${query} of service ${service} was invoked with input`, input)\n    }\n  ]\n})\n```\n\nA hook can return an optional object containing success / error hooks :\n\n```typescript\nconst client = await createB2BClient({\n  // ... other options,\n  hooks: [\n    function onRequestStart({ service, query, input }) {\n      const startTime = new Date();\n\n      console.log(\n        `Query ${query} of service ${service} was invoked with input:`,\n        input,\n      );\n\n      return {\n        onRequestSuccess: ({ response }) =\u003e {\n          const durationMs = new Date().valueOf() - startTime;\n          console.log(`Query took ${durationMs}ms`);\n          console.log(`Query responded with`, response);\n        },\n        onRequestError: ({ error }) =\u003e {\n          const durationMs = new Date().valueOf() - startTime;\n          console.log(`Query took ${durationMs}ms`);\n          console.log(`Query failed with error ${error.message}`);\n        },\n      };\n    },\n  ],\n});\n```\n\nHooks can also be async :\n\n```typescript\nconst client = await createB2BClient({\n  // ... other options,\n  hooks: [\n    async function onRequestStart({ service, query, input }) {\n      await sendLog(`Query ${query} of service ${service} was invoked`);\n    },\n  ],\n});\n```\n\nTo get proper typescript support when creating custom hooks, a `createHook()` function helper is now exported :\n\n```typescript\nimport { createHook } from '@dgac/nmb2b-client';\n\nconst withPrometheusMetrics = createHook(({ service, query }) =\u003e {\n  prometheusCounter.inc({ service, query, status: 'started' });\n\n  return {\n    onRequestSuccess: () =\u003e\n      prometheusCounter.inc({ service, query, status: 'completed' }),\n    onRequestError: () =\u003e\n      prometheusCounter.inc({ service, query, status: 'completed' }),\n  };\n});\n\n// ... in another file\n\nconst b2bClient = await createB2BClient({\n  // ... other options\n  hooks: [withPrometheusMetrics],\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgac%2Fnmb2b-client-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgac%2Fnmb2b-client-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgac%2Fnmb2b-client-js/lists"}