Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
Bump Dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Codex- committed Jan 24, 2022
1 parent eb96daf commit a80e29e
Show file tree
Hide file tree
Showing 29 changed files with 5,293 additions and 2,235 deletions.
5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

20 changes: 10 additions & 10 deletions lib/alert/alert.mapper.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { mapToAlert } from './alert.mapper';
import { Alert } from './alert.model';
import { mapToAlert } from "./alert.mapper";
import { Alert } from "./alert.model";

describe('mapToAlert', () => {
describe('for valid alert json', () => {
it('maps a single alert', () => {
describe("mapToAlert", () => {
describe("for valid alert json", () => {
it("maps a single alert", () => {
const singleAlertJson = {
$: {
ValidFrom: '2017-12-19',
ValidTo: '2019-12-25',
Title: 'Notification',
ValidFrom: "2017-12-19",
ValidTo: "2019-12-25",
Title: "Notification",
},
Detail: {
_text: 'Express trip rules',
_text: "Express trip rules",
},
Route: { $: { RouteNo: 'Y' } },
Route: { $: { RouteNo: "Y" } },
};
const alert: Alert = mapToAlert(singleAlertJson);

Expand Down
6 changes: 3 additions & 3 deletions lib/alert/alert.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ElementCompact } from 'xml-js';
import { propertyToArray } from '../utils';
import { Alert, AlertRoute } from './alert.model';
import { ElementCompact } from "xml-js";
import { propertyToArray } from "../utils";
import { Alert, AlertRoute } from "./alert.model";

export function mapToAlert(alertJson: ElementCompact): Alert {
return {
Expand Down
2 changes: 1 addition & 1 deletion lib/alert/alert.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './alert.model';
export * from "./alert.model";
10 changes: 5 additions & 5 deletions lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ElementCompact, xml2js } from 'xml-js';
import { ElementCompact, xml2js } from "xml-js";

if (
typeof (global as any).fetch === 'undefined' &&
typeof window.fetch === 'undefined'
typeof (global as any).fetch === "undefined" &&
typeof window.fetch === "undefined"
) {
// tslint:disable-next-line: no-var-requires no-implicit-dependencies
(global as any).fetch = require('node-fetch');
(global as any).fetch = require("node-fetch");
}

const fetch = (global as any).fetch || window.fetch;
Expand All @@ -15,7 +15,7 @@ export async function fetchXmlAsJson(uri: string): Promise<ElementCompact> {
const apiText: string = await apiResponse.text();

return xml2js(apiText, {
attributesKey: '$',
attributesKey: "$",
compact: true,
nativeType: true,
});
Expand Down
8 changes: 4 additions & 4 deletions lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const API_URL_BASE = 'http://rtt.metroinfo.org.nz/rtt/public/utility/';
const API_URL_GET = 'file.aspx?ContentType=SQLXML&Name=';
const API_URL_BASE = "http://rtt.metroinfo.org.nz/rtt/public/utility/";
const API_URL_GET = "file.aspx?ContentType=SQLXML&Name=";
export const API_URL = `${API_URL_BASE}${API_URL_GET}`;

export const API_TIMES = 'JPRoutePositionET2';
export const API_LOCATIONS = 'JPPlatform';
export const API_TIMES = "JPRoutePositionET2";
export const API_LOCATIONS = "JPPlatform";
12 changes: 6 additions & 6 deletions lib/content/content.mapper.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { mapToContent } from './content.mapper';
import { Content } from './content.model';
import { mapToContent } from "./content.mapper";
import { Content } from "./content.model";

describe('mapToContent', () => {
describe('for valid content json', () => {
it('maps content', () => {
describe("mapToContent", () => {
describe("for valid content json", () => {
it("maps content", () => {
const contentJson = {
$: { Expires: '2019-04-26T23:34:31+12:00', MaxArrivalScope: '60' },
$: { Expires: "2019-04-26T23:34:31+12:00", MaxArrivalScope: "60" },
};
const content: Content = mapToContent(contentJson);

Expand Down
4 changes: 2 additions & 2 deletions lib/content/content.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ElementCompact } from 'xml-js';
import { Content } from './content.model';
import { ElementCompact } from "xml-js";
import { Content } from "./content.model";

export function mapToContent(contentJson: ElementCompact): Content {
return {
Expand Down
2 changes: 1 addition & 1 deletion lib/content/content.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './content.model';
export * from "./content.model";
26 changes: 13 additions & 13 deletions lib/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
* Perceived direction from the start to the end of the route pattern.
*/
export enum Direction {
AC = 'Anti-Clockwise',
CC = 'Counterclockwise',
CL = 'Clockwise',
DN = 'Down',
EB = 'Eastbound',
IB = 'Inbound',
IW = 'Inward',
NB = 'Northbound',
OB = 'Outbound',
OW = 'Outward',
SB = 'Southbound',
UP = 'Up',
WB = 'Westbound',
AC = "Anti-Clockwise",
CC = "Counterclockwise",
CL = "Clockwise",
DN = "Down",
EB = "Eastbound",
IB = "Inbound",
IW = "Inward",
NB = "Northbound",
OB = "Outbound",
OW = "Outward",
SB = "Southbound",
UP = "Up",
WB = "Westbound",
}

/**
Expand Down
8 changes: 4 additions & 4 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './alert/alert';
export * from './content/content';
export * from './platform/platform';
export * from './point/point';
export * from "./alert/alert";
export * from "./content/content";
export * from "./platform/platform";
export * from "./point/point";
6 changes: 3 additions & 3 deletions lib/platform/locations/platform.locations.api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ElementCompact } from 'xml-js';
import { fetchXmlAsJson } from '../../api';
import { API_LOCATIONS, API_URL } from '../../constants';
import { ElementCompact } from "xml-js";
import { fetchXmlAsJson } from "../../api";
import { API_LOCATIONS, API_URL } from "../../constants";

export async function fetchPlatformLocationsAsJson(): Promise<ElementCompact> {
return fetchXmlAsJson(`${API_URL}${API_LOCATIONS}`);
Expand Down
8 changes: 4 additions & 4 deletions lib/platform/locations/platform.locations.getter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ElementCompact } from 'xml-js';
import { fetchPlatformLocationsAsJson } from './platform.locations.api';
import { mapToPlatformLocations } from './platform.locations.mapper';
import { PlatformLocations } from './platform.locations.model';
import { ElementCompact } from "xml-js";
import { fetchPlatformLocationsAsJson } from "./platform.locations.api";
import { mapToPlatformLocations } from "./platform.locations.mapper";
import { PlatformLocations } from "./platform.locations.model";

/**
* Fetch all Platform locations from the MetroInfo API.
Expand Down
80 changes: 40 additions & 40 deletions lib/platform/locations/platform.locations.mapper.test.ts
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
import { mapToPlatformLocations } from './platform.locations.mapper';
import { PlatformLocations } from './platform.locations.model';
import { mapToPlatformLocations } from "./platform.locations.mapper";
import { PlatformLocations } from "./platform.locations.model";

describe('mapToPlatformLocations', () => {
describe('for valid platform locations json', () => {
it('maps platform locations', () => {
describe("mapToPlatformLocations", () => {
describe("for valid platform locations json", () => {
it("maps platform locations", () => {
const platformLocationsJson = {
_declaration: { $: { version: '1.0', encoding: 'utf-8' } },
_declaration: { $: { version: "1.0", encoding: "utf-8" } },
JPPlatforms: {
$: {
xmlns: 'urn:connexionz-co-nz:jp',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation': 'urn:connexionz-co-nz:jp JourneyPlanner.xsd',
xmlns: "urn:connexionz-co-nz:jp",
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
"xsi:schemaLocation": "urn:connexionz-co-nz:jp JourneyPlanner.xsd",
},
Content: { $: { Expires: '2019-04-27T03:30:00+12:00' } },
Content: { $: { Expires: "2019-04-27T03:30:00+12:00" } },
Platform: [
{
$: {
PlatformTag: '1219',
PlatformNo: '28142',
Name: 'Addington Village',
BearingToRoad: '3.2193924e+002',
RoadName: 'Lincoln Rd',
PlatformTag: "1219",
PlatformNo: "28142",
Name: "Addington Village",
BearingToRoad: "3.2193924e+002",
RoadName: "Lincoln Rd",
},
Position: {
$: {
Lat: '-4.354269524000000e+001',
Long: '1.726134222000000e+002',
Lat: "-4.354269524000000e+001",
Long: "1.726134222000000e+002",
},
},
},
{
$: {
PlatformTag: '1220',
PlatformNo: '44108',
Name: 'Addington Village',
BearingToRoad: '1.4198888e+002',
RoadName: 'Lincoln Rd',
PlatformTag: "1220",
PlatformNo: "44108",
Name: "Addington Village",
BearingToRoad: "1.4198888e+002",
RoadName: "Lincoln Rd",
},
Position: {
$: {
Lat: '-4.354386705000000e+001',
Long: '1.726111654000000e+002',
Lat: "-4.354386705000000e+001",
Long: "1.726111654000000e+002",
},
},
},
{
$: {
PlatformTag: '2940',
PlatformNo: '45477',
Name: 'Aidanfield Dr near Bibiana St',
BearingToRoad: '2.1811232e+002',
RoadName: 'Aidanfield Dr',
PlatformTag: "2940",
PlatformNo: "45477",
Name: "Aidanfield Dr near Bibiana St",
BearingToRoad: "2.1811232e+002",
RoadName: "Aidanfield Dr",
},
Position: {
$: {
Lat: '-4.356581921000000e+001',
Long: '1.725743414000000e+002',
Lat: "-4.356581921000000e+001",
Long: "1.725743414000000e+002",
},
},
},
{
$: {
PlatformTag: '2941',
PlatformNo: '47192',
Name: 'Aidanfield Dr near Bibiana St',
BearingToRoad: '3.8112324e+001',
RoadName: 'Aidanfield Dr',
PlatformTag: "2941",
PlatformNo: "47192",
Name: "Aidanfield Dr near Bibiana St",
BearingToRoad: "3.8112324e+001",
RoadName: "Aidanfield Dr",
},
Position: {
$: {
Lat: '-4.356595693000000e+001',
Long: '1.725742336000000e+002',
Lat: "-4.356595693000000e+001",
Long: "1.725742336000000e+002",
},
},
},
Expand All @@ -84,7 +84,7 @@ describe('mapToPlatformLocations', () => {
platformLocationsJson as any
);

expect(typeof platformLocations.content).toBe('object');
expect(typeof platformLocations.content).toBe("object");
expect(Array.isArray(platformLocations.platforms)).toBe(true);
expect(platformLocations.platforms.length).toBeGreaterThan(0);

Expand All @@ -103,7 +103,7 @@ describe('mapToPlatformLocations', () => {
expect(mappedPlatform.number).toEqual(
parseInt(originalPlatform.$.PlatformNo, 10)
);
expect(typeof mappedPlatform.position).toBe('object');
expect(typeof mappedPlatform.position).toBe("object");
expect(mappedPlatform.roadName).toEqual(originalPlatform.$.RoadName);
expect(mappedPlatform.tag).toEqual(
parseInt(originalPlatform.$.PlatformTag, 10)
Expand Down
12 changes: 6 additions & 6 deletions lib/platform/locations/platform.locations.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ElementCompact } from 'xml-js';
import { API_LOCATIONS } from '../../constants';
import { mapToContent } from '../../content/content.mapper';
import { mapToPoint } from '../../point/point.mapper';
import { propertyToArray } from '../../utils';
import { Platform, PlatformLocations } from './platform.locations.model';
import { ElementCompact } from "xml-js";
import { API_LOCATIONS } from "../../constants";
import { mapToContent } from "../../content/content.mapper";
import { mapToPoint } from "../../point/point.mapper";
import { propertyToArray } from "../../utils";
import { Platform, PlatformLocations } from "./platform.locations.model";

/**
* This is due to an inconsistency between the schema design and the returned XML.
Expand Down
6 changes: 3 additions & 3 deletions lib/platform/locations/platform.locations.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Content } from '../../content/content.model';
import { Point } from '../../point/point.model';
import { PlatformHeader } from '../header/platform.header.model';
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.
Expand Down
8 changes: 4 additions & 4 deletions lib/platform/platform.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './locations/platform.locations.getter';
export * from './locations/platform.locations.model';
export * from "./locations/platform.locations.getter";
export * from "./locations/platform.locations.model";

export * from './times/platform.times.getter';
export * from './times/platform.times.model';
export * from "./times/platform.times.getter";
export * from "./times/platform.times.model";
6 changes: 3 additions & 3 deletions lib/platform/times/platform.times.api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ElementCompact } from 'xml-js';
import { fetchXmlAsJson } from '../../api';
import { API_TIMES, API_URL } from '../../constants';
import { ElementCompact } from "xml-js";
import { fetchXmlAsJson } from "../../api";
import { API_TIMES, API_URL } from "../../constants";

export async function fetchPlatformTimesAsJson(
platformNumber: number
Expand Down
8 changes: 4 additions & 4 deletions lib/platform/times/platform.times.getter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ElementCompact } from 'xml-js';
import { fetchPlatformTimesAsJson } from './platform.times.api';
import { mapToPlatformTimes } from './platform.times.mapper';
import { PlatformTimes } from './platform.times.model';
import { ElementCompact } from "xml-js";
import { fetchPlatformTimesAsJson } from "./platform.times.api";
import { mapToPlatformTimes } from "./platform.times.mapper";
import { PlatformTimes } from "./platform.times.model";

/**
* Fetch all Platform times for a given platform from the MetroInfo API.
Expand Down
Loading

0 comments on commit a80e29e

Please sign in to comment.