Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
jaddek committed Sep 24, 2024
2 parents 4c0d389 + 99923b8 commit 07103fd
Show file tree
Hide file tree
Showing 110 changed files with 10,946 additions and 9,534 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ name: Node.js CI

on:
push:
branches: [ "main" ]
branches: ['main']
pull_request:
branches: [ "main" ]
branches: ['main']

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand All @@ -29,3 +28,4 @@ jobs:
- run: npm ci
- run: npm run build --if-present
- run: npm run test-unit
- run: npm run lint
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8 changes: 4 additions & 4 deletions .jest/setEnvVars.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {readFileSync} from "node:fs";
import { readFileSync } from 'node:fs'

const tokenFile: string = process.env.TOKEN_FILE || ".token";
const tokenFile: string = process.env.TOKEN_FILE || '.token'

try {
process.env.METLINK_TOKEN = readFileSync(tokenFile, "utf-8");
process.env.METLINK_TOKEN = readFileSync(tokenFile, 'utf-8')
} catch {
process.env.METLINK_TOKEN = process.env.METLINK_TOKEN || ""
process.env.METLINK_TOKEN = process.env.METLINK_TOKEN || ''
}
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
trailingComma: 'es5'
tabWidth: 4
semi: false
singleQuote: true
121 changes: 63 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,51 +31,59 @@ https://api.opendata.metlink.org.nz/v1
#### Client

```ts
import {MetlinkHttpClientInterface} from "./Contracts";
import {MetlinkHttpClientBuilder} from "./MetlinkHttpClientBuilder";
import { MetlinkHttpClientInterface } from './Contracts'
import { MetlinkHttpClientBuilder } from './MetlinkHttpClientBuilder'

const options = {
timeout: 1000
};
const metlinkHttpClient: MetlinkHttpClientInterface = MetlinkHttpClientBuilder.buildWithAxios(
token,
options,
function (axios: AxiosInstance) {
axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
return Promise.reject(error);
});
}
);
timeout: 1000,
}
const metlinkHttpClient: MetlinkHttpClientInterface =
MetlinkHttpClientBuilder.buildWithAxios(
token,
options,
function (axios: AxiosInstance) {
axios.interceptors.response.use(
function (response) {
return response
},
function (error) {
return Promise.reject(error)
}
)
}
)
```

OR

```ts
import {MetlinkHttpClientInterface} from "./Contracts";
import {MetlinkHttpClientBuilder} from "./MetlinkHttpClientBuilder";
import { MetlinkHttpClientInterface } from './Contracts'
import { MetlinkHttpClientBuilder } from './MetlinkHttpClientBuilder'

const options = {
timeout: 1000
};
const metlinkHttpClient: MetlinkHttpClientInterface = MetlinkHttpClientBuilder.buildWithAxiosAndDecorate(
token,
options,
function (axios: AxiosInstance) {
axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
return Promise.reject(error);
});
}
);
timeout: 1000,
}
const metlinkHttpClient: MetlinkHttpClientInterface =
MetlinkHttpClientBuilder.buildWithAxiosAndDecorate(
token,
options,
function (axios: AxiosInstance) {
axios.interceptors.response.use(
function (response) {
return response
},
function (error) {
return Promise.reject(error)
}
)
}
)
```

#### Wrapped response body

```ts
const metlinkHttpClient = new ResponseDataDecorator(httpClient);
const metlinkHttpClient = new ResponseDataDecorator(httpClient)
```

### Tests
Expand All @@ -94,8 +102,8 @@ TOKEN_FILE=.token jest tests

#### Unresolved issues:

- GTFS-RT: Service Alerts: Validation Scheme issue
- GTFS-RT: Trip Updates: Validation Scheme issue
- GTFS-RT: Service Alerts: Validation Scheme issue
- GTFS-RT: Trip Updates: Validation Scheme issue

## API

Expand All @@ -106,71 +114,71 @@ TOKEN_FILE=.token jest tests
Transit agencies with service represented in this dataset.

```ts
metlinkHttpClient.getGtfsAgencies();
metlinkHttpClient.getGtfsAgencies()
```

#### Calendars

Service dates specified using a weekly schedule with start and end dates.

```ts
metlinkHttpClient.getGtfsCalendar();
metlinkHttpClient.getGtfsCalendar()
```

#### Calendar Dates

Exceptions for the services defined in the calendar.

```ts
metlinkHttpClient.getGtfsCalendarDates();
metlinkHttpClient.getGtfsCalendarDates()
```

#### Feed info

Dataset metadata, including publisher, version, and expiration information.

```ts
metlinkHttpClient.getGtfsFeedInfo();
metlinkHttpClient.getGtfsFeedInfo()
```

#### Routes

Transit routes. A route is a group of trips that are displayed to riders as a single service.

```ts
metlinkHttpClient.getGtfsRoutes();
metlinkHttpClient.getGtfsRoutes()
```

#### Shapes

Rules for mapping vehicle travel paths, sometimes referred to as route alignments.

```ts
metlinkHttpClient.getGtfsShapes("shapeId");
metlinkHttpClient.getGtfsShapes('shapeId')
```

#### Stop Times

Times that a vehicle arrives at and departs from stops for each trip.

```ts
metlinkHttpClient.getGtfsStopTimes("tripId");
metlinkHttpClient.getGtfsStopTimes('tripId')
```

#### Stops

Stops where vehicles pick up or drop off riders. Also defines stations and station entrances.

```ts
metlinkHttpClient.getGtfsStops();
metlinkHttpClient.getGtfsStops()
```

#### Transfers

Rules for making connections at transfer points between routes.

```ts
metlinkHttpClient.getGtfsTransfers();
metlinkHttpClient.getGtfsTransfers()
```

#### Trips
Expand All @@ -179,12 +187,12 @@ Trips for each route. A trip is a sequence of two or more stops that occur durin

```ts
metlinkHttpClient.getGtfsTrips(
"start",
"extraFields",
"routeId",
"tripId",
"end"
);
'start',
'extraFields',
'routeId',
'tripId',
'end'
)
```

### GTFS-RT
Expand All @@ -195,23 +203,23 @@ Information about unforeseen events affecting routes, stops, or the network. Use
to receive in Protobuf format.

```ts
metlinkHttpClient.getGtfsServiceAlerts();
metlinkHttpClient.getGtfsServiceAlerts()
```

#### Trip Updates

Delays, cancellations, changed routes. Use accept header 'application/x-protobuf' to receive in Protobuf format.

```ts
metlinkHttpClient.getGtfsRtTripUpdates();
metlinkHttpClient.getGtfsRtTripUpdates()
```

#### Vehicle Positions

Information about vehicles including location. Use accept header 'application/x-protobuf' to receive in Protobuf format.

```ts
metlinkHttpClient.getGtfsRtVehiclePositions();
metlinkHttpClient.getGtfsRtVehiclePositions()
```

### Other
Expand All @@ -221,18 +229,15 @@ metlinkHttpClient.getGtfsRtVehiclePositions();
Predictions for when vehicles will arrive and depart through stops.

```ts
metlinkHttpClient.getStopPredictions("stopId");
metlinkHttpClient.getStopPredictions('stopId')
```

#### Trip Cancellations

Historical, current, and known future data for trip cancellations.

```ts
const query: Query = new Query();
query.dateCreated = Date.now().toString();
metlinkHttpClient.getTripCancellation(query);
const query: Query = new Query()
query.dateCreated = Date.now().toString()
metlinkHttpClient.getTripCancellation(query)
```



14 changes: 14 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// @ts-check

import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
}
)
Loading

0 comments on commit 07103fd

Please sign in to comment.