Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@flybywiresim/api-client

Package Overview
Dependencies
Maintainers
4
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flybywiresim/api-client - npm Package Compare versions

Comparing version 0.7.0 to 0.7.1

4

lib/index.d.ts

@@ -53,3 +53,3 @@ export declare class MetarResponse {

from: TelexConnection;
to: TelexConnection;
to?: TelexConnection;
}

@@ -130,2 +130,4 @@ export declare class Token {

private static connectionOrThrow;
private static mapConnection;
private static mapMessage;
}

@@ -132,0 +134,0 @@ export declare class Airport {

@@ -15,2 +15,13 @@ "use strict";

})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -72,2 +83,40 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

exports.TelexNotConnectedError = TelexNotConnectedError;
function _get(url, headers) {
return fetch(url.href, { headers: headers })
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
});
}
function _delete(url, headers) {
return fetch(url.href, { method: "DELETE", headers: headers })
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return;
});
}
function _post(url, body, headers) {
var headersToSend = __assign({ "Content-Type": "application/json" }, headers);
return fetch(url.href, { method: "POST", body: JSON.stringify(body), headers: headersToSend })
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
});
}
function _put(url, body, headers) {
var headersToSend = __assign({ "Content-Type": "application/json" }, headers);
return fetch(url.href, { method: "PUT", body: JSON.stringify(body), headers: headersToSend })
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
});
}
var NXApi = /** @class */ (function () {

@@ -91,9 +140,3 @@ function NXApi() {

}
return fetch(url.href)
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
});
return _get(url);
};

@@ -114,9 +157,3 @@ return Metar;

}
return fetch(url.href)
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
});
return _get(url);
};

@@ -137,9 +174,3 @@ return Atis;

}
return fetch(url.href)
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
});
return _get(url);
};

@@ -153,17 +184,6 @@ return Taf;

Telex.connect = function (status) {
var connectBody = Telex.buildBody(status);
var headers = {
"Content-Type": "application/json"
};
var url = new URL("/txcxn", NXApi.url);
return fetch(url.href, { method: "POST", body: JSON.stringify(connectBody), headers: headers })
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json()
.then(function (data) {
Telex.accessToken = data.accessToken;
return data;
});
return _post(new URL("/txcxn", NXApi.url), Telex.buildBody(status))
.then(function (res) {
Telex.accessToken = res.accessToken;
return res;
});

@@ -173,28 +193,15 @@ };

Telex.connectionOrThrow();
var connectBody = Telex.buildBody(status);
var headers = {
"Content-Type": "application/json",
return _put(new URL("/txcxn", NXApi.url), Telex.buildBody(status), {
Authorization: Telex.buildToken()
};
var url = new URL("/txcxn", NXApi.url);
return fetch(url.href, { method: "PUT", body: JSON.stringify(connectBody), headers: headers })
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
});
})
.then(Telex.mapConnection);
};
Telex.disconnect = function () {
Telex.connectionOrThrow();
var headers = {
return _delete(new URL("/txcxn", NXApi.url), {
Authorization: Telex.buildToken()
};
var url = new URL("/txcxn", NXApi.url);
return fetch(url.href, { method: "DELETE", headers: headers })
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
})
.then(function () {
Telex.accessToken = "";
return;
});

@@ -204,32 +211,16 @@ };

Telex.connectionOrThrow();
var body = {
return _post(new URL("/txmsg", NXApi.url), {
to: recipientFlight,
message: message,
};
var headers = {
"Content-Type": "application/json",
message: message
}, {
Authorization: Telex.buildToken()
};
var url = new URL("/txmsg", NXApi.url);
return fetch(url.href, { method: "POST", body: JSON.stringify(body), headers: headers })
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
});
})
.then(Telex.mapMessage);
};
Telex.fetchMessages = function () {
Telex.connectionOrThrow();
var headers = {
return _get(new URL("/txmsg", NXApi.url), {
Authorization: Telex.buildToken()
};
var url = new URL("/txmsg", NXApi.url);
return fetch(url.href, { method: "GET", headers: headers })
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
});
})
.then(function (res) { return res.map(Telex.mapMessage); });
};

@@ -250,8 +241,5 @@ Telex.fetchConnections = function (skip, take, bounds) {

}
return fetch(url.href, { method: "GET" })
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
return _get(url)
.then(function (res) {
return __assign(__assign({}, res), { results: res.results.map(Telex.mapConnection) });
});

@@ -288,10 +276,4 @@ };

Telex.fetchConnection = function (id) {
var url = new URL("/txcxn/" + id, NXApi.url);
return fetch(url.href, { method: "GET" })
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
});
return _get(new URL("/txcxn/" + id, NXApi.url))
.then(Telex.mapConnection);
};

@@ -301,19 +283,7 @@ Telex.findConnections = function (flightNumber) {

url.searchParams.set("flight", flightNumber);
return fetch(url.href, { method: "GET" })
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
});
return _get(url)
.then(function (res) { return res.map(Telex.mapConnection); });
};
Telex.countConnections = function () {
var url = new URL("/txcxn/_count", NXApi.url);
return fetch(url.href, { method: "GET" })
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
});
return _get(new URL("/txcxn/_count", NXApi.url));
};

@@ -324,3 +294,3 @@ Telex.buildBody = function (status) {

x: status.location.long,
y: status.location.lat,
y: status.location.lat
},

@@ -333,3 +303,3 @@ trueAltitude: status.trueAltitude,

flight: status.flight,
aircraftType: status.aircraftType,
aircraftType: status.aircraftType
};

@@ -345,2 +315,15 @@ };

};
Telex.mapConnection = function (connection) {
return __assign(__assign({}, connection), { firstContact: new Date(connection.firstContact), lastContact: new Date(connection.lastContact) });
};
Telex.mapMessage = function (message) {
var msg = __assign(__assign({}, message), { createdAt: new Date(message.createdAt) });
if (message.from) {
msg.from = Telex.mapConnection(message.from);
}
if (message.to) {
msg.to = Telex.mapConnection(message.to);
}
return msg;
};
Telex.refreshRate = 15000;

@@ -357,10 +340,3 @@ return Telex;

}
var url = new URL("/api/v1/airport/" + icao, NXApi.url);
return fetch(url.href)
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
});
return _get(new URL("/api/v1/airport/" + icao, NXApi.url));
};

@@ -371,16 +347,3 @@ Airport.getBatch = function (icaos) {

}
var body = {
icaos: icaos
};
var headers = {
"Content-Type": "application/json"
};
var url = new URL("/api/v1/airport/_batch", NXApi.url);
return fetch(url.href, { method: "POST", body: JSON.stringify(body), headers: headers })
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
});
return _post(new URL("/api/v1/airport/_batch", NXApi.url), { icaos: icaos });
};

@@ -397,9 +360,5 @@ return Airport;

}
var url = new URL("/api/v1/git-versions/" + user + "/" + repo + "/branches/" + branch, NXApi.url);
return fetch(url.href)
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
return _get(new URL("/api/v1/git-versions/" + user + "/" + repo + "/branches/" + branch, NXApi.url))
.then(function (res) {
return __assign(__assign({}, res), { timestamp: new Date(res.timestamp) });
});

@@ -411,10 +370,6 @@ };

}
var url = new URL("/api/v1/git-versions/" + user + "/" + repo + "/releases", NXApi.url);
return fetch(url.href)
.then(function (response) {
if (!response.ok) {
throw new HttpError(response.status);
}
return response.json();
});
return _get(new URL("/api/v1/git-versions/" + user + "/" + repo + "/releases", NXApi.url))
.then(function (res) { return res.map(function (rel) {
return __assign(__assign({}, rel), { publishedAt: new Date(rel.publishedAt) });
}); });
};

@@ -421,0 +376,0 @@ return GitVersions;

{
"name": "@flybywiresim/api-client",
"version": "0.7.0",
"version": "0.7.1",
"description": "Client library for the FlyByWire Simulations API",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc