Skip to content

Commit

Permalink
Add format script for formatting non-eslinted filed
Browse files Browse the repository at this point in the history
  • Loading branch information
draperunner committed Jan 14, 2021
1 parent b2ce48f commit 70cdc1b
Show file tree
Hide file tree
Showing 29 changed files with 470 additions and 369 deletions.
399 changes: 209 additions & 190 deletions LICENSE.md

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions docs/advanced/queryJourneyPlanner.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ The GraphQL query string.
An object with GraphQL variables.

### options (`RequestOptions`) [Optional]

An object containing a subset of `RequestInit` options that's applied to the request.

| Key | Type | Description |
|:---------|:--------------|:------------|
| Key | Type | Description |
| :------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------ |
| `signal` | `AbortSignal` | Allows you to communicate with a fetch request and abort it if desired. [Read more](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) |

## Example

The example below finds lines that stops at the given stop places. Also check this out at [Shamash](https://api.staging.entur.io/journey-planner/v2/ide/?query=%7B%0A%20%20%0A%7D&variables=%7B%0A%20%20%22ids%22%3A%20%5B%22NSR%3AStopPlace%3A4089%22%2C%20%22NSR%3AStopPlace%3A1337%22%5D%0A%7D).


```typescript
import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default

const service = createEnturService({
clientName: 'awesomecompany-awesomeapp'
clientName: 'awesomecompany-awesomeapp',
})

const query = `
Expand All @@ -57,9 +57,8 @@ query ($ids: [String!]!) {
`

const variables = {
ids: ['NSR:StopPlace:4089', 'NSR:StopPlace:1337']
ids: ['NSR:StopPlace:4089', 'NSR:StopPlace:1337'],
}

service.queryJourneyPlanner(query, variables)
.then(res => console.log(res)) // Print out lines servicing these stop places
service.queryJourneyPlanner(query, variables).then((res) => console.log(res)) // Print out lines servicing these stop places
```
5 changes: 3 additions & 2 deletions docs/advanced/queryNsr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ The GraphQL query string.
An object with GraphQL variables.

### options (`RequestOptions`) [Optional]

An object containing a subset of `RequestInit` options that's applied to the request.

| Key | Type | Description |
|:---------|:--------------|:------------|
| Key | Type | Description |
| :------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------ |
| `signal` | `AbortSignal` | Allows you to communicate with a fetch request and abort it if desired. [Read more](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) |
12 changes: 8 additions & 4 deletions docs/bikes/getBikeRentalStation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ route: /bikes/getBikeRentalStation
## Parameters

### stationId (`string`)

The ID of the bike rental station you are interested in. The method will return a Promise which will resolve to an object of type BikeRentalStation.

### options (`RequestOptions`) [Optional]

An object containing a subset of `RequestInit` options that's applied to the request.

| Key | Type | Description |
|:---------|:--------------|:------------|
| Key | Type | Description |
| :------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------ |
| `signal` | `AbortSignal` | Allows you to communicate with a fetch request and abort it if desired. [Read more](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) |

## Example
Expand All @@ -31,12 +33,14 @@ import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default

const service = createEnturService({
clientName: 'awesomecompany-awesomeapp'
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
try {
const bikeRentalStation = await service.getBikeRentalStation('YBE:VehicleSharingParkingArea:368')
const bikeRentalStation = await service.getBikeRentalStation(
'YBE:VehicleSharingParkingArea:368',
)
console.log(bikeRentalStation)
} catch (error) {
console.error(error)
Expand Down
8 changes: 5 additions & 3 deletions docs/bikes/getBikeRentalStations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ route: /bikes/getBikeRentalStations
## Parameters

### stationIds (`Array<string>`)

The IDs of the bike rental stations you are interested in. The method will return a Promise which will resolve to an array of objects of type BikeRentalStation.

### options (`RequestOptions`) [Optional]

An object containing a subset of `RequestInit` options that's applied to the request.

| Key | Type | Description |
|:---------|:--------------|:------------|
| Key | Type | Description |
| :------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------ |
| `signal` | `AbortSignal` | Allows you to communicate with a fetch request and abort it if desired. [Read more](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) |

## Example
Expand All @@ -31,7 +33,7 @@ import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default

const service = createEnturService({
clientName: 'awesomecompany-awesomeapp'
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
Expand Down
9 changes: 6 additions & 3 deletions docs/bikes/getBikeRentalStationsByPosition.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@ route: /bikes/getBikeRentalStationsByPosition
## Parameters

### coordinates (`{ latitude: number, longitude: number }`)

The coordinates of which to find bike rental stations around.

### distance (`number`) [Optional]

Default: `500`

The "radius" in meters of the surrounding bounding box in which you want to find bike rental stations.
The width and height of the bounding box are therefore `2 * distance`, and the coordinates given are its centerpoint.

### options (`RequestOptions`) [Optional]

An object containing a subset of `RequestInit` options that's applied to the request.

| Key | Type | Description |
|:---------|:--------------|:------------|
| Key | Type | Description |
| :------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------ |
| `signal` | `AbortSignal` | Allows you to communicate with a fetch request and abort it if desired. [Read more](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) |

## Example
Expand All @@ -37,7 +40,7 @@ import createEnturService from '@entur/sdk'
// or: const createEnturService = require('@entur/sdk').default

const service = createEnturService({
clientName: 'awesomecompany-awesomeapp'
clientName: 'awesomecompany-awesomeapp',
})

async function example() {
Expand Down
15 changes: 9 additions & 6 deletions docs/departures/getDeparturesBetweenStopPlaces.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,24 @@ route: /departures/getDeparturesBetweenStopPlaces
## Parameters

### fromStopPlaceId (`string`)

The ID of the stop place to get departures _from_.

### toStopPlaceId (`string`)

The ID of the stop place to get departures _to_.

### params (`Object`) [Optional]

| Key | Type | Default | Description |
|:-------------------------|:---------------|:-------------|:------------|
| `start` | `Date` | `new Date()` | DateTime for when to fetch estimated calls from. |
| `limit` | `number` | `20` | The maximum number of departures to fetch. |
| Key | Type | Default | Description |
| :------ | :-------- | :----------- | :----------------------------------------------- |
| `start` |  `Date` | `new Date()` | DateTime for when to fetch estimated calls from. |
| `limit` |  `number` | `20` | The maximum number of departures to fetch. |

### options (`RequestOptions`) [Optional]

An object containing a subset of `RequestInit` options that's applied to the request.

| Key | Type | Description |
|:---------|:--------------|:------------|
| Key | Type | Description |
| :------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------ |
| `signal` | `AbortSignal` | Allows you to communicate with a fetch request and abort it if desired. [Read more](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) |
7 changes: 5 additions & 2 deletions docs/departures/getDeparturesForServiceJourney.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ route: /departures/getDeparturesForServiceJourney
## Parameters

### id (`string`)

The ID of the service journey to get departures for.

### date (`string`) [Optional]

A date on the form "YYYY-MM-DD" to use if you want the service journey's departures for another date than today.

### options (`RequestOptions`) [Optional]

An object containing a subset of `RequestInit` options that's applied to the request.

| Key | Type | Description |
|:---------|:--------------|:------------|
| Key | Type | Description |
| :------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------ |
| `signal` | `AbortSignal` | Allows you to communicate with a fetch request and abort it if desired. [Read more](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) |
6 changes: 4 additions & 2 deletions docs/departures/getDeparturesFromQuays.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ The method will return an array of objects containing fields for the quay's `id`
## Parameters

### quayIds (`Array<string>`)

The IDs of the quays you are interested in.

### params (`Object`) [Optional]

See the `params` parameter for [`getDeparturesForStopPlace`](/departures/getDeparturesFromStopPlace#params-object-optional).

### options (`RequestOptions`) [Optional]

An object containing a subset of `RequestInit` options that's applied to the request.

| Key | Type | Description |
|:---------|:--------------|:------------|
| Key | Type | Description |
| :------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------ |
| `signal` | `AbortSignal` | Allows you to communicate with a fetch request and abort it if desired. [Read more](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) |
29 changes: 16 additions & 13 deletions docs/departures/getDeparturesFromStopPlace.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,29 @@ The method will return a Promise which will resolve to an array of departures fo
## Parameters

### stopPlaceId (`string`)

The ID of the stop place you are interested in.

### params (`Object`) [Optional]

An optional object of parameters to pass to the query.

| Key | Type | Default | Description |
|:-------------------------|:---------------|:-------------|:------------|
| `start` | `Date` | `new Date()` | DateTime for when to fetch estimated calls from. |
| `timeRange` | `number` | `72000` | The time range for departures to include in seconds. |
| `includeCancelledTrips` | `boolean` | `false` | Whether to include cancelled departures. |
| `includeNonBoarding` | `boolean` | `false` | Whether to include departures that do not accept boarding at given stop place. |
| `limit` | `number` | `50` | The maximum number of departures to fetch. |
| `limitPerLine` | `number` | No limit | The maximum number of departures to fetch per line and destination display. |
| `whiteListedLines` | `Array<string>` | `undefined` | A list of line IDs to include. All others will be excluded. If omitted, all are included. |
| `whiteListedAuthorities` | `Array<string>` | `undefined` | A list of authority IDs to include. All others will be excluded. If omitted, all are included. |
| `whiteListedModes` | `Array<QueryMode>` | `undefined` | A list of transport modes to include. All others will be excluded. If omitted, all are included. |
| Key | Type | Default | Description |
| :----------------------- | :------------------ | :----------- | :----------------------------------------------------------------------------------------------- |
| `start` |  `Date` | `new Date()` | DateTime for when to fetch estimated calls from. |
| `timeRange` |  `number` | `72000` | The time range for departures to include in seconds. |
| `includeCancelledTrips` |  `boolean` | `false` | Whether to include cancelled departures. |
| `includeNonBoarding` |  `boolean` | `false` | Whether to include departures that do not accept boarding at given stop place. |
| `limit` |  `number` | `50` | The maximum number of departures to fetch. |
| `limitPerLine` |  `number` | No limit | The maximum number of departures to fetch per line and destination display. |
| `whiteListedLines` |  `Array<string>` | `undefined` | A list of line IDs to include. All others will be excluded. If omitted, all are included. |
| `whiteListedAuthorities` |  `Array<string>` | `undefined` | A list of authority IDs to include. All others will be excluded. If omitted, all are included. |
| `whiteListedModes` |  `Array<QueryMode>` | `undefined` | A list of transport modes to include. All others will be excluded. If omitted, all are included. |

### options (`RequestOptions`) [Optional]

An object containing a subset of `RequestInit` options that's applied to the request.

| Key | Type | Description |
|:---------|:--------------|:------------|
| Key | Type | Description |
| :------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------ |
| `signal` | `AbortSignal` | Allows you to communicate with a fetch request and abort it if desired. [Read more](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) |
6 changes: 4 additions & 2 deletions docs/departures/getDeparturesFromStopPlaces.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ The returned array _can_ contain undefined values. If that's the case, the ID yo
## Parameters

### stopPlaceIds (`Array<string>`)

The IDs of the stop places you are interested in.

### params (`Object`) [Optional]

See the `params` parameter for [`getDeparturesForStopPlace`](/departures/getDeparturesFromStopPlace#params-object-optional).

### options (`RequestOptions`) [Optional]

An object containing a subset of `RequestInit` options that's applied to the request.

| Key | Type | Description |
|:---------|:--------------|:------------|
| Key | Type | Description |
| :------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------ |
| `signal` | `AbortSignal` | Allows you to communicate with a fetch request and abort it if desired. [Read more](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) |
5 changes: 3 additions & 2 deletions docs/geocoder/getFeaturesReverse.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ An optional object of parameters to pass to the query.
| `layers` |  `Array<string>` | `["venue","address"]` | The types of places to search for in a comma-separated string. `venue` means stop places and stations, `address` means postal addresses that might not be connected to public transport. |

### options (`RequestOptions`) [Optional]

An object containing a subset of `RequestInit` options that's applied to the request.

| Key | Type | Description |
|:---------|:--------------|:------------|
| Key | Type | Description |
| :------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------ |
| `signal` | `AbortSignal` | Allows you to communicate with a fetch request and abort it if desired. [Read more](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) |
22 changes: 14 additions & 8 deletions docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ route: /getting-started
---

## Install

```bash
npm install @entur/sdk --save
```

## Setup

Import the service creator:

```javascript
Expand All @@ -28,17 +30,20 @@ const service = createEnturService({ clientName: 'awesomecompany-awesomeapp' })
```

### Configuration
| Name | Required? | Type | Default | Description |
|:------------|-----------|:----------------------|:------------|:----------------------------------------|
| clientName | Yes | `string` | `undefined` | The name of your application |
| hosts | No | `{object of hosts}` | `{}` | Override default endpoints |
| fetch | No | `function` | native fetch if browser, `node-fetch` if Node.JS | |

| Name | Required? | Type | Default | Description |
| :--------- | --------- | :------------------ | :----------------------------------------------- | :--------------------------- |
| clientName | Yes | `string` | `undefined` | The name of your application |
| hosts | No | `{object of hosts}` | `{}` | Override default endpoints |
| fetch | No | `function` | native fetch if browser, `node-fetch` if Node.JS | |

#### clientName (required)

We require that you pass a `clientName` that identifies your application. It should contain the name of your company or organization,
followed by a hyphen and your application's name. See https://developer.entur.org/pages-intro-authentication for more information.

#### hosts

The Entur SDK uses multiple endpoints for its services. Each endpoint can be overridden with hosts config (in case you use a proxy or a local instance of the endpoint). Available hosts are:

```javascript
Expand All @@ -50,11 +55,12 @@ The Entur SDK uses multiple endpoints for its services. Each endpoint can be ove
```

#### fetch

If you need to configure the fetch implementation that is used, use this. You could use this for:

* Specifying default headers
* Specifying custom agents
* Do some common logging on all SDK requests
- Specifying default headers
- Specifying custom agents
- Do some common logging on all SDK requests

```
const service = createEnturService({
Expand Down
Loading

0 comments on commit 70cdc1b

Please sign in to comment.