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

metro-info

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metro-info - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

dist/content/content.mapper.test.d.ts

17

CHANGELOG.md

@@ -8,2 +8,16 @@ # Changelog

## [1.0.5] - 2019-04-27
### Added
- Complete test coverage for mappers.
- Docstrings expanded to note the source schema name.
### Fixed
- Docstrings were being stripped due to a bad tsconfig setting.
- Fixed a bug in Platform Times where a Trip ID would always be undefined.
- Fixed `Trip` interface as `id` and `wheelchairAccess` are optional according to the schema.
- Change `PlatformTimes` optional properties to non-optional as they're always defined.
## [1.0.4] - 2019-03-26

@@ -62,3 +76,4 @@

[unreleased]: https://github.com/Codex-/metro-info/compare/v1.0.4...HEAD
[unreleased]: https://github.com/Codex-/metro-info/compare/v1.0.5...HEAD
[1.0.5]: https://github.com/Codex-/metro-info/compare/v1.0.4...v1.0.5
[1.0.4]: https://github.com/Codex-/metro-info/compare/v1.0.3...v1.0.4

@@ -65,0 +80,0 @@ [1.0.3]: https://github.com/Codex-/metro-info/compare/v1.0.2...v1.0.3

4

dist/alert/alert.mapper.test.js

@@ -20,4 +20,4 @@ "use strict";

expect(alert.detail).toEqual(singleAlertJson.Detail._text);
expect(alert.routes.length).toBe(1);
expect(alert.routes[0].number).toBe(singleAlertJson.Route.$.RouteNo);
expect(alert.routes.length).toEqual(1);
expect(alert.routes[0].number).toEqual(singleAlertJson.Route.$.RouteNo);
expect(alert.title).toEqual(singleAlertJson.$.Title);

@@ -24,0 +24,0 @@ expect(alert.validFrom).toBeInstanceOf(Date);

@@ -0,11 +1,37 @@

/**
* Interfaces provided as an adaptation of the Connexionz schema.
*
* Schema: Alert
*/
/**
* Rider alert for a period. Gives warnings about issues on one or more routes.
*/
export interface Alert {
/**
* Commentary on the alert.
*/
detail: string;
/**
* True where alert has been recently created or updated.
*/
new?: boolean;
routes: AlertRoute[];
title: string;
/**
* Start date of alert.
*/
validFrom: Date;
/**
* End date of alert, if omitted - perpetual.
*/
validTo?: Date;
}
/**
* Route affected by alert, if omitted all routes are affected.
*/
export interface AlertRoute {
/**
* Designator for route.
*/
number: string;
}
"use strict";
/**
* Interfaces provided as an adaptation of the Connexionz schema.
*
* Schema: Alert
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=alert.model.js.map

@@ -40,2 +40,3 @@ "use strict";

if (typeof global.fetch === 'undefined') {
// tslint:disable-next-line: no-var-requires
global.fetch = require('node-fetch');

@@ -49,9 +50,9 @@ }

switch (_a.label) {
case 0: return [4, fetch(uri)];
case 0: return [4 /*yield*/, fetch(uri)];
case 1:
apiResponse = _a.sent();
return [4, apiResponse.text()];
return [4 /*yield*/, apiResponse.text()];
case 2:
apiText = _a.sent();
return [2, xml_js_1.xml2js(apiText, {
return [2 /*return*/, xml_js_1.xml2js(apiText, {
attributesKey: '$',

@@ -58,0 +59,0 @@ compact: true,

@@ -0,4 +1,19 @@

/**
* Interfaces provided as an adaptation of the Connexionz schema.
*
* Schema: Content
*/
/**
* Information provided on the content of the original XML document.
*/
export interface Content {
/**
* Local time at which the documents content may change.
* This is time that the document cache will be refreshed.
*/
expires: Date;
/**
* Maximum ETA (in minutes) included.
*/
maxArrivalScope: number;
}
"use strict";
/**
* Interfaces provided as an adaptation of the Connexionz schema.
*
* Schema: Content
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=content.model.js.map

@@ -0,1 +1,11 @@

/**
* Enums provided as an adaptation of the Connexionz schema.
*
* Omitted:
* - enum-service
* - enum-vehicletype
*/
/**
* Perceived direction from the start to the end of the route pattern.
*/
export declare enum Direction {

@@ -16,2 +26,5 @@ AC = "Anti-Clockwise",

}
/**
* Indicates status of schedule.
*/
export declare enum Schedule {

@@ -18,0 +31,0 @@ Active = 0,

"use strict";
/**
* Enums provided as an adaptation of the Connexionz schema.
*
* Omitted:
* - enum-service
* - enum-vehicletype
*/
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Perceived direction from the start to the end of the route pattern.
*/
var Direction;

@@ -19,2 +29,5 @@ (function (Direction) {

})(Direction = exports.Direction || (exports.Direction = {}));
/**
* Indicates status of schedule.
*/
var Schedule;

@@ -21,0 +34,0 @@ (function (Schedule) {

@@ -0,5 +1,20 @@

/**
* Interfaces provided as an adaptation of the Connexionz schema.
*
* Schema: PlatformHdr
*/
export interface PlatformHeader {
/**
* The common name of the platform defaulting to the nearest intersection.
*/
name: string;
/**
* Platform number attached to the street furniture.
* Used for public identification and may change due to maintenance (vandalism, furniture replacement etc).
*/
number?: number;
/**
* Internal key for platform. This key will remain constant for this platform.
*/
tag: number;
}
"use strict";
/**
* Interfaces provided as an adaptation of the Connexionz schema.
*
* Schema: PlatformHdr
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=platform.header.model.js.map

@@ -43,3 +43,3 @@ "use strict";

return __generator(this, function (_a) {
return [2, api_1.fetchXmlAsJson("" + constants_1.API_URL + constants_1.API_LOCATIONS)];
return [2 /*return*/, api_1.fetchXmlAsJson("" + constants_1.API_URL + constants_1.API_LOCATIONS)];
});

@@ -46,0 +46,0 @@ });

import { PlatformLocations } from './platform.locations.model';
/**
* Fetch all Platform locations from the MetroInfo API.
*
* @returns parsed PlatformLocations object.
*/
export declare function getPlatformLocations(): Promise<PlatformLocations>;

@@ -40,2 +40,7 @@ "use strict";

var platform_locations_mapper_1 = require("./platform.locations.mapper");
/**
* Fetch all Platform locations from the MetroInfo API.
*
* @returns parsed PlatformLocations object.
*/
function getPlatformLocations() {

@@ -46,6 +51,6 @@ return __awaiter(this, void 0, void 0, function () {

switch (_a.label) {
case 0: return [4, platform_locations_api_1.fetchPlatformLocationsAsJson()];
case 0: return [4 /*yield*/, platform_locations_api_1.fetchPlatformLocationsAsJson()];
case 1:
json = _a.sent();
return [2, platform_locations_mapper_1.mapToPlatformLocations(json)];
return [2 /*return*/, platform_locations_mapper_1.mapToPlatformLocations(json)];
}

@@ -52,0 +57,0 @@ });

@@ -7,2 +7,5 @@ "use strict";

var utils_1 = require("../../utils");
/**
* This is due to an inconsistency between the schema design and the returned XML.
*/
var LOCATIONS = constants_1.API_LOCATIONS + "s";

@@ -9,0 +12,0 @@ function mapToPlatformLocations(locationJson) {

import { Content } from '../../content/content.model';
import { Point } from '../../point/point.model';
import { PlatformHeader } from '../header/platform.header.model';
/**
* Interfaces provided as an adaptation of the Connexionz schema.
*
* Schema: JPPlatforms
*/
/**
* Locations and names of all platforms in the system.
*/
export interface PlatformLocations {

@@ -9,6 +17,17 @@ content: Content;

export interface Platform extends PlatformHeader {
/**
* Bearing from platform to road in decimal degrees.
*/
bearingToRoad?: number;
position: Point;
/**
* Name of the road on which the platform is located.
*/
roadName?: string;
/**
* Type of vehicle that can use platform.
*
* TODO: Not yet implemented.
*/
vehicleType?: any;
}

@@ -43,3 +43,3 @@ "use strict";

return __generator(this, function (_a) {
return [2, api_1.fetchXmlAsJson("" + constants_1.API_URL + constants_1.API_TIMES + "&PlatformTag=" + platformNumber)];
return [2 /*return*/, api_1.fetchXmlAsJson("" + constants_1.API_URL + constants_1.API_TIMES + "&PlatformTag=" + platformNumber)];
});

@@ -46,0 +46,0 @@ });

import { PlatformTimes } from './platform.times.model';
/**
* Fetch all Platform times for a given platform from the MetroInfo API.
*
* @param platformNumber
* @returns parsed PlatformTimes object.
*/
export declare function getPlatformTimes(platformNumber: number): Promise<PlatformTimes>;

@@ -40,2 +40,8 @@ "use strict";

var platform_times_mapper_1 = require("./platform.times.mapper");
/**
* Fetch all Platform times for a given platform from the MetroInfo API.
*
* @param platformNumber
* @returns parsed PlatformTimes object.
*/
function getPlatformTimes(platformNumber) {

@@ -46,6 +52,6 @@ return __awaiter(this, void 0, void 0, function () {

switch (_a.label) {
case 0: return [4, platform_times_api_1.fetchPlatformTimesAsJson(platformNumber)];
case 0: return [4 /*yield*/, platform_times_api_1.fetchPlatformTimesAsJson(platformNumber)];
case 1:
json = _a.sent();
return [2, platform_times_mapper_1.mapToPlatformTimes(json)];
return [2 /*return*/, platform_times_mapper_1.mapToPlatformTimes(json)];
}

@@ -52,0 +58,0 @@ });

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

name: platform.$.Name,
number: platform.$.PlatformNo
? parseInt(platform.$.PlatformNo, 10)
: undefined,
routes: utils_1.propertyToArray(platform.Route).map(mapToRoute),

@@ -34,7 +37,9 @@ tag: parseInt(platform.$.PlatformTag, 10),

return {
eta: tripJson.$.ETA,
id: tripJson.$.TripNo,
wheelchairAccess: tripJson.$.WheelchairAccess,
eta: parseInt(tripJson.$.ETA, 10),
id: tripJson.$.TripID ? parseInt(tripJson.$.TripID, 10) : undefined,
wheelchairAccess: tripJson.$.WheelchairAccess
? tripJson.$.WheelchairAccess === 'true'
: undefined,
};
}
//# sourceMappingURL=platform.times.mapper.js.map
import { Alert } from '../../alert/alert.model';
import { Content } from '../../content/content.model';
import { PlatformHeader } from '../header/platform.header.model';
/**
* Interfaces provided as an adaptation of the Connexionz schema.
*
* Schema: JPRoutePositionET2
*/
export interface Destination {

@@ -8,6 +13,9 @@ name: string;

}
/**
* Arrival information at a given platform including service alerts.
*/
export interface PlatformTimes extends PlatformHeader {
alerts?: Alert[];
alerts: Alert[];
content: Content;
routes?: Route[];
routes: Route[];
}

@@ -17,8 +25,20 @@ export interface Route {

name: string;
/**
* Route numbers can be letters or numbers.
*/
number: string;
}
export interface Trip {
/**
* Number of minutes to the expected arrival.
*/
eta: number;
id: number;
wheelchairAccess: boolean;
/**
* Trip identifier as contained in GTFS dataset.
*/
id?: number;
/**
* True when vehicle has wheelchair access.
*/
wheelchairAccess?: boolean;
}

@@ -0,4 +1,18 @@

/**
* Interfaces provided as an adaptation of the Connexionz schema.
*
* Schema: JPPlatforms
*/
/**
* Geo-coded location of platform in WGS84 format.
*/
export interface Point {
/**
* WGS84 Latitude in decimal degrees.
*/
lat: number;
/**
* WGS84 Longitude in decimal degrees.
*/
long: number;
}
"use strict";
/**
* Interfaces provided as an adaptation of the Connexionz schema.
*
* Schema: JPPlatforms
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=point.model.js.map

@@ -0,1 +1,7 @@

/**
* Support function to check if the property is an object or array of objects.
*
* @param property
* @returns an array of object(s) or an empty array if undefined.
*/
export declare function propertyToArray(property: any): any[];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Support function to check if the property is an object or array of objects.
*
* @param property
* @returns an array of object(s) or an empty array if undefined.
*/
function propertyToArray(property) {
if (!property) {
if (property === undefined) {
return [];

@@ -6,0 +12,0 @@ }

{
"name": "metro-info",
"version": "1.0.4",
"version": "1.0.5",
"description": "Christchurch (Unofficial) MetroInfo API NodeJS library",

@@ -16,5 +16,5 @@ "main": "dist/index.js",

"prepare": "npm run build",
"prepublishOnly": "npm run lint && npm run format",
"pretest": "npm run build",
"preversion": "npm run lint && npm run format",
"prepublishOnly": "npm run format && npm run lint",
"pretest": "npm run format && npm run lint",
"preversion": "npm run format && npm run lint",
"test": "jest",

@@ -46,3 +46,3 @@ "tsc": "tsc -p tsconfig.json",

"dependencies": {
"node-fetch": "^2.3.0",
"node-fetch": "^2.4.1",
"xml-js": "^1.6.11"

@@ -52,14 +52,14 @@ },

"@types/jest": "^24.0.11",
"@types/node-fetch": "^2.1.7",
"@types/node-fetch": "^2.3.3",
"coveralls": "*",
"husky": "^1.3.1",
"jest": "^24.5.0",
"husky": "^2.1.0",
"jest": "^24.7.1",
"lint-staged": "^8.1.5",
"prettier": "^1.16.4",
"prettier": "^1.17.0",
"rimraf": "^2.6.3",
"ts-jest": "^24.0.0",
"tslint": "^5.14.0",
"ts-jest": "^24.0.2",
"tslint": "^5.16.0",
"tslint-config-prettier": "^1.18.0",
"tslint-eslint-rules": "^5.4.0",
"typescript": "^3.3.3333"
"typescript": "^3.4.5"
},

@@ -66,0 +66,0 @@ "husky": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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