Skip to content

Commit

Permalink
NM B2B 27.0.0 (#121)
Browse files Browse the repository at this point in the history
* NM B2B 27.0.0

* Tweak gitattributes for merge strategy on CHANGELOG.md

* Update target NM version

* Tweak typings, tweak tests
  • Loading branch information
kouak authored Jun 7, 2024
1 parent ec8ad21 commit 8d39632
Show file tree
Hide file tree
Showing 36 changed files with 255 additions and 788 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHANGELOG.md merge=union
2 changes: 1 addition & 1 deletion .github/workflows/test_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ env:
CI: true
B2B_FLAVOUR: PREOPS
B2B_ENDPOINT: https://b2b-proxy.4me.im/
B2B_XSD_REMOTE_URL: https://wsdl.b2B-proxy.4me.im/26.0.0.tar.gz
B2B_XSD_REMOTE_URL: https://wsdl.b2B-proxy.4me.im/27.0.0.tar.gz
B2B_API_KEY_ID: ${{ secrets.B2B_API_KEY_ID }}
B2B_API_SECRET_KEY: ${{ secrets.B2B_API_SECRET_KEY }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Master

- NMB2B v27.0.0
- Attach the current configuration to the service definition : `xxxxService.config`.
- Remove moment.js, move to `date-fns`
- Update dependencies
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

Exposes 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.

NM target version: **26.0.0**
NM target version: **27.0.0**

## Simple usage example

Expand Down
1 change: 1 addition & 0 deletions src/Airspace/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ type ADRMessageType = object; // eurocontrol.cfmu.cua.b2b.aixm.ADRMessage
export interface AUPManualEntries {
cdrs?: ADRMessageType;
rsas?: ADRMessageType;
radRestrictionActivations?: ADRMessageType;
}

export interface AUPComputedEntries {
Expand Down
3 changes: 3 additions & 0 deletions src/Common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export type AirNavigationUnitId = string; // (UALPHA|DIGIT|SPECIAL_CHARACTER){1,
export type UserId = string; // ANY{1,12}
export type PlanDataId = string; // (O|F|S)(DIGIT){14}(UALPHA|DIGIT){0,40}

export type Colours = string; // TEXT{1,51}

// TODO: Implement proper duration (seconds) parsing
export type SignedDurationHourMinuteSecond = string; // +hhmmss / -hhmmss

Expand Down Expand Up @@ -140,6 +142,7 @@ export interface Reply {

export interface Request {
endUserId?: string;
onBehalfOfUnit?: AirNavigationUnitId;
sendTime: DateTimeSecond;
}

Expand Down
10 changes: 8 additions & 2 deletions src/Flight/queryFlightsByAerodrome.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('queryFlightsByAirspace', async () => {
trafficType: 'LOAD',
trafficWindow,
aerodrome: 'LFPG',
aerodromeRole: 'BOTH',
aerodromeRole: 'GLOBAL',
});

/**
Expand All @@ -41,7 +41,13 @@ describe('queryFlightsByAirspace', async () => {
),
).toBeLessThan(60 * 1000);

expect(res.data?.flights).toEqual(expect.any(Array));
if (!res.data.flights) {
console.warn('No flights in the response.');
return;
}

expect(res.data.flights).toEqual(expect.any(Array));

for (const flight of res.data?.flights) {
expect(flight).toMatchObject({
flight: {
Expand Down
12 changes: 9 additions & 3 deletions src/Flight/queryFlightsByAerodromeSet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('queryFlightsByAirspace', async () => {
trafficType: 'LOAD',
trafficWindow,
aerodromeSet: 'LFPG+',
aerodromeRole: 'BOTH',
aerodromeRole: 'GLOBAL',
});

/**
Expand All @@ -41,8 +41,14 @@ describe('queryFlightsByAirspace', async () => {
),
).toBeLessThan(60 * 1000);

expect(res.data?.flights).toEqual(expect.any(Array));
for (const flight of res.data?.flights) {
if (!res.data.flights) {
console.warn('No flights in the response.');
return;
}

expect(res.data.flights).toEqual(expect.any(Array));

for (const flight of res.data.flights) {
expect(flight).toMatchObject({
flight: {
flightId: {
Expand Down
10 changes: 8 additions & 2 deletions src/Flight/queryFlightsByAircraftOperator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ describe('queryFlightsByAircraftOperator', async () => {
),
).toBeLessThan(60 * 1000);

expect(res.data?.flights).toEqual(expect.any(Array));
for (const flight of res.data?.flights) {
if (!res.data.flights) {
console.warn('No flights in the response.');
return;
}

expect(res.data.flights).toEqual(expect.any(Array));

for (const flight of res.data.flights) {
expect(flight).toMatchObject({
flight: {
flightId: {
Expand Down
10 changes: 8 additions & 2 deletions src/Flight/queryFlightsByAirspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ describe('queryFlightsByAirspace', async () => {
),
).toBeLessThan(60 * 1000);

expect(res.data?.flights).toEqual(expect.any(Array));
for (const flight of res.data?.flights) {
if (!res.data.flights) {
console.warn('No flights in the response.');
return;
}

expect(res.data.flights).toEqual(expect.any(Array));

for (const flight of res.data.flights) {
expect(flight).toMatchObject({
flight: {
flightId: {
Expand Down
11 changes: 9 additions & 2 deletions src/Flight/queryFlightsByMeasure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,15 @@ describe('queryFlightsByMeasure', async () => {
});

expect(res.data.effectiveTrafficWindow).toEqual(measure.applicability);
expect(res.data?.flights).toEqual(expect.any(Array));
for (const flight of res.data?.flights) {

if (!res.data.flights) {
console.warn('No flights in the response.');
return;
}

expect(res.data.flights).toEqual(expect.any(Array));

for (const flight of res.data.flights) {
expect(flight).toMatchObject({
flight: {
flightId: {
Expand Down
10 changes: 8 additions & 2 deletions src/Flight/queryFlightsByTrafficVolume.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ describe('queryFlightsByTrafficVolume', async () => {
),
).toBeLessThan(60 * 1000);

expect(res.data?.flights).toEqual(expect.any(Array));
for (const flight of res.data?.flights) {
if (!res.data.flights) {
console.warn('No flights in the response.');
return;
}

expect(res.data.flights).toEqual(expect.any(Array));

for (const flight of res.data.flights) {
if (!('flight' in flight)) {
continue;
}
Expand Down
38 changes: 23 additions & 15 deletions src/Flight/retrieveFlight.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NMB2BError, makeFlightClient } from '..';
import b2bOptions from '../../tests/options';
import type { FlightKeys } from './types';
import { shouldUseRealB2BConnection } from '../../tests/utils';
import { expect, beforeAll, test, describe } from 'vitest';
import { expect, beforeAll, test, describe, assert } from 'vitest';
import { add, sub } from 'date-fns';

describe('retrieveFlight', async () => {
Expand All @@ -27,18 +27,24 @@ describe('retrieveFlight', async () => {
airspace: 'LFEERMS',
});

const flights = res.data.flights.filter((f) => {
if ('flightPlan' in f) {
return false;
}
if (!res.data.flights) {
console.warn('No flights in the response.');
return;
}

return true;
});
const flights = res.data.flights.filter(
(f): f is Extract<typeof f, { flight: any }> => {
if ('flightPlan' in f) {
return false;
}

return true;
},
);

// Second condition is here because TS won't infer that the array contains
// only Flight and not FlightPlan anymore
const flight = flights[0];
if (!flight || !('flight' in flight)) {

if (!flight) {
console.error('Could not fetch a known flight, test aborted');
return;
}
Expand Down Expand Up @@ -77,11 +83,11 @@ describe('retrieveFlight', async () => {
},
requestedFlightDatasets: ['flight'],
requestedFlightFields: ['ftfmPointProfile'],
requestedDataFormat: 'NM_B2B',
});

expect(res.data.flight?.ftfmPointProfile).toBeDefined();
res.data.flight?.ftfmPointProfile?.forEach((item) => {
assert(res.data.flight?.ftfmPointProfile);

res.data.flight.ftfmPointProfile.forEach((item) => {
expect(item).toEqual(
expect.objectContaining({
timeOver: expect.any(Date),
Expand All @@ -90,7 +96,10 @@ describe('retrieveFlight', async () => {
);
});
} catch (err) {
console.error(inspect(err, { depth: 4 }));
if (err instanceof NMB2BError) {
console.log(inspect(err, { depth: 4 }));
}

throw err;
}
},
Expand All @@ -114,7 +123,6 @@ describe('retrieveFlight', async () => {
},
requestedFlightDatasets: ['flight'],
requestedFlightFields: ['aircraftType', 'delay'],
requestedDataFormat: 'NM_B2B',
});

const flight = res.data?.flight;
Expand Down
Loading

0 comments on commit 8d39632

Please sign in to comment.