diff --git a/LICENSE.md b/LICENSE.md index bc0429be..967dca4d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,190 +1,209 @@ -# EUROPEAN UNION PUBLIC LICENCE v. 1.2 -EUPL © the European Union 2007, 2016 - -This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined below) which is provided under the -terms of this Licence. Any use of the Work, other than as authorised under this Licence is prohibited (to the extent such -use is covered by a right of the copyright holder of the Work). -The Work is provided under the terms of this Licence when the Licensor (as defined below) has placed the following -notice immediately following the copyright notice for the Work: - Licensed under the EUPL -or has expressed by any other means his willingness to license under the EUPL. - -## 1.Definitions -In this Licence, the following terms have the following meaning: -* ‘The Licence’:this Licence. -* ‘The Original Work’:the work or software distributed or communicated by the Licensor under this Licence, available -as Source Code and also as Executable Code as the case may be. -* ‘Derivative Works’:the works or software that could be created by the Licensee, based upon the Original Work or -modifications thereof. This Licence does not define the extent of modification or dependence on the Original Work -required in order to classify a work as a Derivative Work; this extent is determined by copyright law applicable in -the country mentioned in Article 15. -* ‘The Work’:the Original Work or its Derivative Works. -* ‘The Source Code’:the human-readable form of the Work which is the most convenient for people to study and -modify. -* ‘The Executable Code’:any code which has generally been compiled and which is meant to be interpreted by -a computer as a program. -* ‘The Licensor’:the natural or legal person that distributes or communicates the Work under the Licence. -* ‘Contributor(s)’:any natural or legal person who modifies the Work under the Licence, or otherwise contributes to -the creation of a Derivative Work. -* ‘The Licensee’ or ‘You’:any natural or legal person who makes any usage of the Work under the terms of the -Licence. -* ‘Distribution’ or ‘Communication’:any act of selling, giving, lending, renting, distributing, communicating, -transmitting, or otherwise making available, online or offline, copies of the Work or providing access to its essential -functionalities at the disposal of any other natural or legal person. - -## 2.Scope of the rights granted by the Licence -The Licensor hereby grants You a worldwide, royalty-free, non-exclusive, sublicensable licence to do the following, for -the duration of copyright vested in the Original Work: -* use the Work in any circumstance and for all usage, -* reproduce the Work, -* modify the Work, and make Derivative Works based upon the Work, -* communicate to the public, including the right to make available or display the Work or copies thereof to the public -and perform publicly, as the case may be, the Work, -* distribute the Work or copies thereof, -* lend and rent the Work or copies thereof, -* sublicense rights in the Work or copies thereof. -Those rights can be exercised on any media, supports and formats, whether now known or later invented, as far as the -applicable law permits so. -In the countries where moral rights apply, the Licensor waives his right to exercise his moral right to the extent allowed -by law in order to make effective the licence of the economic rights here above listed. -The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to any patents held by the Licensor, to the -extent necessary to make use of the rights granted on the Work under this Licence. - -3.Communication of the Source Code -The Licensor may provide the Work either in its Source Code form, or as Executable Code. If the Work is provided as -Executable Code, the Licensor provides in addition a machine-readable copy of the Source Code of the Work along with -each copy of the Work that the Licensor distributes or indicates, in a notice following the copyright notice attached to -the Work, a repository where the Source Code is easily and freely accessible for as long as the Licensor continues to -distribute or communicate the Work. - -## 4.Limitations on copyright -Nothing in this Licence is intended to deprive the Licensee of the benefits from any exception or limitation to the -exclusive rights of the rights owners in the Work, of the exhaustion of those rights or of other applicable limitations -thereto. - -## 5.Obligations of the Licensee -The grant of the rights mentioned above is subject to some restrictions and obligations imposed on the Licensee. Those -obligations are the following: - -Attribution right: The Licensee shall keep intact all copyright, patent or trademarks notices and all notices that refer to -the Licence and to the disclaimer of warranties. The Licensee must include a copy of such notices and a copy of the -Licence with every copy of the Work he/she distributes or communicates. The Licensee must cause any Derivative Work -to carry prominent notices stating that the Work has been modified and the date of modification. - -Copyleft clause: If the Licensee distributes or communicates copies of the Original Works or Derivative Works, this -Distribution or Communication will be done under the terms of this Licence or of a later version of this Licence unless -the Original Work is expressly distributed only under this version of the Licence — for example by communicating -‘EUPL v. 1.2 only’. The Licensee (becoming Licensor) cannot offer or impose any additional terms or conditions on the -Work or Derivative Work that alter or restrict the terms of the Licence. - -Compatibility clause: If the Licensee Distributes or Communicates Derivative Works or copies thereof based upon both -the Work and another work licensed under a Compatible Licence, this Distribution or Communication can be done -under the terms of this Compatible Licence. For the sake of this clause, ‘Compatible Licence’ refers to the licences listed -in the appendix attached to this Licence. Should the Licensee's obligations under the Compatible Licence conflict with -his/her obligations under this Licence, the obligations of the Compatible Licence shall prevail. - -Provision of Source Code: When distributing or communicating copies of the Work, the Licensee will provide -a machine-readable copy of the Source Code or indicate a repository where this Source will be easily and freely available -for as long as the Licensee continues to distribute or communicate the Work. -Legal Protection: This Licence does not grant permission to use the trade names, trademarks, service marks, or names -of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and -reproducing the content of the copyright notice. - -## 6.Chain of Authorship -The original Licensor warrants that the copyright in the Original Work granted hereunder is owned by him/her or -licensed to him/her and that he/she has the power and authority to grant the Licence. -Each Contributor warrants that the copyright in the modifications he/she brings to the Work are owned by him/her or -licensed to him/her and that he/she has the power and authority to grant the Licence. -Each time You accept the Licence, the original Licensor and subsequent Contributors grant You a licence to their contributions -to the Work, under the terms of this Licence. - -## 7.Disclaimer of Warranty -The Work is a work in progress, which is continuously improved by numerous Contributors. It is not a finished work -and may therefore contain defects or ‘bugs’ inherent to this type of development. -For the above reason, the Work is provided under the Licence on an ‘as is’ basis and without warranties of any kind -concerning the Work, including without limitation merchantability, fitness for a particular purpose, absence of defects or -errors, accuracy, non-infringement of intellectual property rights other than copyright as stated in Article 6 of this -Licence. -This disclaimer of warranty is an essential part of the Licence and a condition for the grant of any rights to the Work. - -## 8.Disclaimer of Liability -Except in the cases of wilful misconduct or damages directly caused to natural persons, the Licensor will in no event be -liable for any direct or indirect, material or moral, damages of any kind, arising out of the Licence or of the use of the -Work, including without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, loss -of data or any commercial damage, even if the Licensor has been advised of the possibility of such damage. However, -the Licensor will be liable under statutory product liability laws as far such laws apply to the Work. - -## 9.Additional agreements -While distributing the Work, You may choose to conclude an additional agreement, defining obligations or services -consistent with this Licence. However, if accepting obligations, You may act only on your own behalf and on your sole -responsibility, not on behalf of the original Licensor or any other Contributor, and only if You agree to indemnify, -defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against such Contributor by -the fact You have accepted any warranty or additional liability. - -## 10.Acceptance of the Licence -The provisions of this Licence can be accepted by clicking on an icon ‘I agree’ placed under the bottom of a window -displaying the text of this Licence or by affirming consent in any other similar way, in accordance with the rules of -applicable law. Clicking on that icon indicates your clear and irrevocable acceptance of this Licence and all of its terms -and conditions. -Similarly, you irrevocably accept this Licence and all of its terms and conditions by exercising any rights granted to You -by Article 2 of this Licence, such as the use of the Work, the creation by You of a Derivative Work or the Distribution -or Communication by You of the Work or copies thereof. - -## 11.Information to the public -In case of any Distribution or Communication of the Work by means of electronic communication by You (for example, -by offering to download the Work from a remote location) the distribution channel or media (for example, a website) -must at least provide to the public the information requested by the applicable law regarding the Licensor, the Licence -and the way it may be accessible, concluded, stored and reproduced by the Licensee. - -## 12.Termination of the Licence -The Licence and the rights granted hereunder will terminate automatically upon any breach by the Licensee of the terms -of the Licence. -Such a termination will not terminate the licences of any person who has received the Work from the Licensee under -the Licence, provided such persons remain in full compliance with the Licence. - -## 13.Miscellaneous -Without prejudice of Article 9 above, the Licence represents the complete agreement between the Parties as to the -Work. -If any provision of the Licence is invalid or unenforceable under applicable law, this will not affect the validity or -enforceability of the Licence as a whole. Such provision will be construed or reformed so as necessary to make it valid -and enforceable. -The European Commission may publish other linguistic versions or new versions of this Licence or updated versions of -the Appendix, so far this is required and reasonable, without reducing the scope of the rights granted by the Licence. -New versions of the Licence will be published with a unique version number. -All linguistic versions of this Licence, approved by the European Commission, have identical value. Parties can take -advantage of the linguistic version of their choice. - -## 14.Jurisdiction -Without prejudice to specific agreement between parties, -* any litigation resulting from the interpretation of this License, arising between the European Union institutions, -bodies, offices or agencies, as a Licensor, and any Licensee, will be subject to the jurisdiction of the Court of Justice -of the European Union, as laid down in article 272 of the Treaty on the Functioning of the European Union, -* any litigation arising between other parties and resulting from the interpretation of this License, will be subject to -the exclusive jurisdiction of the competent court where the Licensor resides or conducts its primary business. - -## 15.Applicable Law -Without prejudice to specific agreement between parties, -* this Licence shall be governed by the law of the European Union Member State where the Licensor has his seat, -resides or has his registered office, -* this licence shall be governed by Belgian law if the Licensor has no seat, residence or registered office inside -a European Union Member State. - - - Appendix - -‘Compatible Licences’ according to Article 5 EUPL are: -* GNU General Public License (GPL) v. 2, v. 3 -* GNU Affero General Public License (AGPL) v. 3 -* Open Software License (OSL) v. 2.1, v. 3.0 -* Eclipse Public License (EPL) v. 1.0 -* CeCILL v. 2.0, v. 2.1 -* Mozilla Public Licence (MPL) v. 2 -* GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3 -* Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for works other than software -* European Union Public Licence (EUPL) v. 1.1, v. 1.2 -* Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong Reciprocity (LiLiQ-R+). - -The European Commission may update this Appendix to later versions of the above licences without producing -a new version of the EUPL, as long as they provide the rights granted in Article 2 of this Licence and protect the -covered Source Code from exclusive appropriation. -All other changes or additions to this Appendix require the production of a new EUPL version. +# EUROPEAN UNION PUBLIC LICENCE v. 1.2 + +EUPL © the European Union 2007, 2016 + +This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined below) which is provided under the +terms of this Licence. Any use of the Work, other than as authorised under this Licence is prohibited (to the extent such +use is covered by a right of the copyright holder of the Work). +The Work is provided under the terms of this Licence when the Licensor (as defined below) has placed the following +notice immediately following the copyright notice for the Work: +Licensed under the EUPL +or has expressed by any other means his willingness to license under the EUPL. + +## 1.Definitions + +In this Licence, the following terms have the following meaning: + +- ‘The Licence’:this Licence. +- ‘The Original Work’:the work or software distributed or communicated by the Licensor under this Licence, available + as Source Code and also as Executable Code as the case may be. +- ‘Derivative Works’:the works or software that could be created by the Licensee, based upon the Original Work or + modifications thereof. This Licence does not define the extent of modification or dependence on the Original Work + required in order to classify a work as a Derivative Work; this extent is determined by copyright law applicable in + the country mentioned in Article 15. +- ‘The Work’:the Original Work or its Derivative Works. +- ‘The Source Code’:the human-readable form of the Work which is the most convenient for people to study and + modify. +- ‘The Executable Code’:any code which has generally been compiled and which is meant to be interpreted by + a computer as a program. +- ‘The Licensor’:the natural or legal person that distributes or communicates the Work under the Licence. +- ‘Contributor(s)’:any natural or legal person who modifies the Work under the Licence, or otherwise contributes to + the creation of a Derivative Work. +- ‘The Licensee’ or ‘You’:any natural or legal person who makes any usage of the Work under the terms of the + Licence. +- ‘Distribution’ or ‘Communication’:any act of selling, giving, lending, renting, distributing, communicating, + transmitting, or otherwise making available, online or offline, copies of the Work or providing access to its essential + functionalities at the disposal of any other natural or legal person. + +## 2.Scope of the rights granted by the Licence + +The Licensor hereby grants You a worldwide, royalty-free, non-exclusive, sublicensable licence to do the following, for +the duration of copyright vested in the Original Work: + +- use the Work in any circumstance and for all usage, +- reproduce the Work, +- modify the Work, and make Derivative Works based upon the Work, +- communicate to the public, including the right to make available or display the Work or copies thereof to the public + and perform publicly, as the case may be, the Work, +- distribute the Work or copies thereof, +- lend and rent the Work or copies thereof, +- sublicense rights in the Work or copies thereof. + Those rights can be exercised on any media, supports and formats, whether now known or later invented, as far as the + applicable law permits so. + In the countries where moral rights apply, the Licensor waives his right to exercise his moral right to the extent allowed + by law in order to make effective the licence of the economic rights here above listed. + The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to any patents held by the Licensor, to the + extent necessary to make use of the rights granted on the Work under this Licence. + + 3.Communication of the Source Code + The Licensor may provide the Work either in its Source Code form, or as Executable Code. If the Work is provided as + Executable Code, the Licensor provides in addition a machine-readable copy of the Source Code of the Work along with + each copy of the Work that the Licensor distributes or indicates, in a notice following the copyright notice attached to + the Work, a repository where the Source Code is easily and freely accessible for as long as the Licensor continues to + distribute or communicate the Work. + +## 4.Limitations on copyright + +Nothing in this Licence is intended to deprive the Licensee of the benefits from any exception or limitation to the +exclusive rights of the rights owners in the Work, of the exhaustion of those rights or of other applicable limitations +thereto. + +## 5.Obligations of the Licensee + +The grant of the rights mentioned above is subject to some restrictions and obligations imposed on the Licensee. Those +obligations are the following: + +Attribution right: The Licensee shall keep intact all copyright, patent or trademarks notices and all notices that refer to +the Licence and to the disclaimer of warranties. The Licensee must include a copy of such notices and a copy of the +Licence with every copy of the Work he/she distributes or communicates. The Licensee must cause any Derivative Work +to carry prominent notices stating that the Work has been modified and the date of modification. + +Copyleft clause: If the Licensee distributes or communicates copies of the Original Works or Derivative Works, this +Distribution or Communication will be done under the terms of this Licence or of a later version of this Licence unless +the Original Work is expressly distributed only under this version of the Licence — for example by communicating +‘EUPL v. 1.2 only’. The Licensee (becoming Licensor) cannot offer or impose any additional terms or conditions on the +Work or Derivative Work that alter or restrict the terms of the Licence. + +Compatibility clause: If the Licensee Distributes or Communicates Derivative Works or copies thereof based upon both +the Work and another work licensed under a Compatible Licence, this Distribution or Communication can be done +under the terms of this Compatible Licence. For the sake of this clause, ‘Compatible Licence’ refers to the licences listed +in the appendix attached to this Licence. Should the Licensee's obligations under the Compatible Licence conflict with +his/her obligations under this Licence, the obligations of the Compatible Licence shall prevail. + +Provision of Source Code: When distributing or communicating copies of the Work, the Licensee will provide +a machine-readable copy of the Source Code or indicate a repository where this Source will be easily and freely available +for as long as the Licensee continues to distribute or communicate the Work. +Legal Protection: This Licence does not grant permission to use the trade names, trademarks, service marks, or names +of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and +reproducing the content of the copyright notice. + +## 6.Chain of Authorship + +The original Licensor warrants that the copyright in the Original Work granted hereunder is owned by him/her or +licensed to him/her and that he/she has the power and authority to grant the Licence. +Each Contributor warrants that the copyright in the modifications he/she brings to the Work are owned by him/her or +licensed to him/her and that he/she has the power and authority to grant the Licence. +Each time You accept the Licence, the original Licensor and subsequent Contributors grant You a licence to their contributions +to the Work, under the terms of this Licence. + +## 7.Disclaimer of Warranty + +The Work is a work in progress, which is continuously improved by numerous Contributors. It is not a finished work +and may therefore contain defects or ‘bugs’ inherent to this type of development. +For the above reason, the Work is provided under the Licence on an ‘as is’ basis and without warranties of any kind +concerning the Work, including without limitation merchantability, fitness for a particular purpose, absence of defects or +errors, accuracy, non-infringement of intellectual property rights other than copyright as stated in Article 6 of this +Licence. +This disclaimer of warranty is an essential part of the Licence and a condition for the grant of any rights to the Work. + +## 8.Disclaimer of Liability + +Except in the cases of wilful misconduct or damages directly caused to natural persons, the Licensor will in no event be +liable for any direct or indirect, material or moral, damages of any kind, arising out of the Licence or of the use of the +Work, including without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, loss +of data or any commercial damage, even if the Licensor has been advised of the possibility of such damage. However, +the Licensor will be liable under statutory product liability laws as far such laws apply to the Work. + +## 9.Additional agreements + +While distributing the Work, You may choose to conclude an additional agreement, defining obligations or services +consistent with this Licence. However, if accepting obligations, You may act only on your own behalf and on your sole +responsibility, not on behalf of the original Licensor or any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against such Contributor by +the fact You have accepted any warranty or additional liability. + +## 10.Acceptance of the Licence + +The provisions of this Licence can be accepted by clicking on an icon ‘I agree’ placed under the bottom of a window +displaying the text of this Licence or by affirming consent in any other similar way, in accordance with the rules of +applicable law. Clicking on that icon indicates your clear and irrevocable acceptance of this Licence and all of its terms +and conditions. +Similarly, you irrevocably accept this Licence and all of its terms and conditions by exercising any rights granted to You +by Article 2 of this Licence, such as the use of the Work, the creation by You of a Derivative Work or the Distribution +or Communication by You of the Work or copies thereof. + +## 11.Information to the public + +In case of any Distribution or Communication of the Work by means of electronic communication by You (for example, +by offering to download the Work from a remote location) the distribution channel or media (for example, a website) +must at least provide to the public the information requested by the applicable law regarding the Licensor, the Licence +and the way it may be accessible, concluded, stored and reproduced by the Licensee. + +## 12.Termination of the Licence + +The Licence and the rights granted hereunder will terminate automatically upon any breach by the Licensee of the terms +of the Licence. +Such a termination will not terminate the licences of any person who has received the Work from the Licensee under +the Licence, provided such persons remain in full compliance with the Licence. + +## 13.Miscellaneous + +Without prejudice of Article 9 above, the Licence represents the complete agreement between the Parties as to the +Work. +If any provision of the Licence is invalid or unenforceable under applicable law, this will not affect the validity or +enforceability of the Licence as a whole. Such provision will be construed or reformed so as necessary to make it valid +and enforceable. +The European Commission may publish other linguistic versions or new versions of this Licence or updated versions of +the Appendix, so far this is required and reasonable, without reducing the scope of the rights granted by the Licence. +New versions of the Licence will be published with a unique version number. +All linguistic versions of this Licence, approved by the European Commission, have identical value. Parties can take +advantage of the linguistic version of their choice. + +## 14.Jurisdiction + +Without prejudice to specific agreement between parties, + +- any litigation resulting from the interpretation of this License, arising between the European Union institutions, + bodies, offices or agencies, as a Licensor, and any Licensee, will be subject to the jurisdiction of the Court of Justice + of the European Union, as laid down in article 272 of the Treaty on the Functioning of the European Union, +- any litigation arising between other parties and resulting from the interpretation of this License, will be subject to + the exclusive jurisdiction of the competent court where the Licensor resides or conducts its primary business. + +## 15.Applicable Law + +Without prejudice to specific agreement between parties, + +- this Licence shall be governed by the law of the European Union Member State where the Licensor has his seat, + resides or has his registered office, +- this licence shall be governed by Belgian law if the Licensor has no seat, residence or registered office inside + a European Union Member State. + + Appendix + +‘Compatible Licences’ according to Article 5 EUPL are: + +- GNU General Public License (GPL) v. 2, v. 3 +- GNU Affero General Public License (AGPL) v. 3 +- Open Software License (OSL) v. 2.1, v. 3.0 +- Eclipse Public License (EPL) v. 1.0 +- CeCILL v. 2.0, v. 2.1 +- Mozilla Public Licence (MPL) v. 2 +- GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3 +- Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for works other than software +- European Union Public Licence (EUPL) v. 1.1, v. 1.2 +- Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong Reciprocity (LiLiQ-R+). + +The European Commission may update this Appendix to later versions of the above licences without producing +a new version of the EUPL, as long as they provide the rights granted in Article 2 of this Licence and protect the +covered Source Code from exclusive appropriation. +All other changes or additions to this Appendix require the production of a new EUPL version. diff --git a/docs/advanced/queryJourneyPlanner.mdx b/docs/advanced/queryJourneyPlanner.mdx index 84508cb3..d124276c 100644 --- a/docs/advanced/queryJourneyPlanner.mdx +++ b/docs/advanced/queryJourneyPlanner.mdx @@ -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 = ` @@ -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 ``` diff --git a/docs/advanced/queryNsr.mdx b/docs/advanced/queryNsr.mdx index bc373f7e..d8088d37 100644 --- a/docs/advanced/queryNsr.mdx +++ b/docs/advanced/queryNsr.mdx @@ -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) | diff --git a/docs/bikes/getBikeRentalStation.mdx b/docs/bikes/getBikeRentalStation.mdx index 8ab22e54..98543cba 100644 --- a/docs/bikes/getBikeRentalStation.mdx +++ b/docs/bikes/getBikeRentalStation.mdx @@ -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 @@ -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) diff --git a/docs/bikes/getBikeRentalStations.mdx b/docs/bikes/getBikeRentalStations.mdx index 969bc805..44bf3c33 100644 --- a/docs/bikes/getBikeRentalStations.mdx +++ b/docs/bikes/getBikeRentalStations.mdx @@ -15,13 +15,15 @@ route: /bikes/getBikeRentalStations ## Parameters ### stationIds (`Array`) + 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 @@ -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() { diff --git a/docs/bikes/getBikeRentalStationsByPosition.mdx b/docs/bikes/getBikeRentalStationsByPosition.mdx index 86768df3..2ca28fe5 100644 --- a/docs/bikes/getBikeRentalStationsByPosition.mdx +++ b/docs/bikes/getBikeRentalStationsByPosition.mdx @@ -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 @@ -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() { diff --git a/docs/departures/getDeparturesBetweenStopPlaces.mdx b/docs/departures/getDeparturesBetweenStopPlaces.mdx index 2bf816ba..0fdb3a47 100644 --- a/docs/departures/getDeparturesBetweenStopPlaces.mdx +++ b/docs/departures/getDeparturesBetweenStopPlaces.mdx @@ -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) | diff --git a/docs/departures/getDeparturesForServiceJourney.mdx b/docs/departures/getDeparturesForServiceJourney.mdx index 9453fd5d..b62cccff 100644 --- a/docs/departures/getDeparturesForServiceJourney.mdx +++ b/docs/departures/getDeparturesForServiceJourney.mdx @@ -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) | diff --git a/docs/departures/getDeparturesFromQuays.mdx b/docs/departures/getDeparturesFromQuays.mdx index 3690100c..f61fe89a 100644 --- a/docs/departures/getDeparturesFromQuays.mdx +++ b/docs/departures/getDeparturesFromQuays.mdx @@ -17,6 +17,7 @@ The method will return an array of objects containing fields for the quay's `id` ## Parameters ### quayIds (`Array`) + The IDs of the quays you are interested in. ### params (`Object`) [Optional] @@ -24,8 +25,9 @@ The IDs of the quays you are interested in. 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) | diff --git a/docs/departures/getDeparturesFromStopPlace.mdx b/docs/departures/getDeparturesFromStopPlace.mdx index e15e2cdc..1204d2b0 100644 --- a/docs/departures/getDeparturesFromStopPlace.mdx +++ b/docs/departures/getDeparturesFromStopPlace.mdx @@ -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` | `undefined` | A list of line IDs to include. All others will be excluded. If omitted, all are included. | -| `whiteListedAuthorities` | `Array` | `undefined` | A list of authority IDs to include. All others will be excluded. If omitted, all are included. | -| `whiteListedModes` | `Array` | `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` | `undefined` | A list of line IDs to include. All others will be excluded. If omitted, all are included. | +| `whiteListedAuthorities` |  `Array` | `undefined` | A list of authority IDs to include. All others will be excluded. If omitted, all are included. | +| `whiteListedModes` |  `Array` | `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) | diff --git a/docs/departures/getDeparturesFromStopPlaces.mdx b/docs/departures/getDeparturesFromStopPlaces.mdx index 0f81c2a3..85559683 100644 --- a/docs/departures/getDeparturesFromStopPlaces.mdx +++ b/docs/departures/getDeparturesFromStopPlaces.mdx @@ -19,6 +19,7 @@ The returned array _can_ contain undefined values. If that's the case, the ID yo ## Parameters ### stopPlaceIds (`Array`) + The IDs of the stop places you are interested in. ### params (`Object`) [Optional] @@ -26,8 +27,9 @@ The IDs of the stop places you are interested in. 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) | diff --git a/docs/geocoder/getFeaturesReverse.mdx b/docs/geocoder/getFeaturesReverse.mdx index 16c1405f..5be86974 100644 --- a/docs/geocoder/getFeaturesReverse.mdx +++ b/docs/geocoder/getFeaturesReverse.mdx @@ -29,8 +29,9 @@ An optional object of parameters to pass to the query. | `layers` |  `Array` | `["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) | diff --git a/docs/getting-started.mdx b/docs/getting-started.mdx index 6eaf3288..04aff7eb 100644 --- a/docs/getting-started.mdx +++ b/docs/getting-started.mdx @@ -4,11 +4,13 @@ route: /getting-started --- ## Install + ```bash npm install @entur/sdk --save ``` ## Setup + Import the service creator: ```javascript @@ -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 @@ -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({ diff --git a/docs/intro.mdx b/docs/intro.mdx index 940b01bb..1a695942 100644 --- a/docs/intro.mdx +++ b/docs/intro.mdx @@ -15,6 +15,7 @@ Miss anything? Found a bug? File an [issue](https://github.com/entur/sdk/issues/ Ready to get started? Check out [Getting Started!](/getting-started) ## Why use the SDK? + TL;DR: simplicity and types. The SDK provides a simple interface to accessing Entur's JourneyPlanner and Geocoder APIs through fully typed JavaScript functions for TypeScript. @@ -23,6 +24,7 @@ You avoid a lot of boilerplate like handling network requests, defining GraphQL The data types do not include _all_ possible fields and values that the APIs provide, but most likely more than you need. ## Why NOT use the SDK? + TL;DR: performance and flexibility. If performance is very important to you, querying the GraphQL APIs directly is probably the way to go. With GraphQL you can specify exactly what data you need, which will reduce payloads and increase speed. diff --git a/docs/places/getNearestPlaces.mdx b/docs/places/getNearestPlaces.mdx index a4fd0c4a..a6125fa3 100644 --- a/docs/places/getNearestPlaces.mdx +++ b/docs/places/getNearestPlaces.mdx @@ -15,24 +15,26 @@ Finds the nearest places to a given coordinate. ## Parameters ### coordinates (`{ latitude: number, longitude: number }`) + The latitude and longitude for the point you want to find places close to. ### params (`Object`) [Optional] -| Key | Type | Default | Description | -|:-------------------------|:---------------|:-------------|:------------| -| `maximumDistance` | `number` | `2000` | Maximum distance (in meters) to search for from the specified location. | -| `maximumResults` | `number` | `20` | The maximum number of results to return. | -| `filterByPlaceTypes` | `'BikePark' | 'BikeRentalStation' | 'CarPark' | 'Quay' | 'StopPlace'` | No restrictions. | Only include places of given types if set. | -| `filterByModes` | `TransportMode` | No restrictions. | Only include places that include this mode. Only checked for places with mode i.e. quays, departures. | -| `filterByInUse` | `boolean` | `false`. | Only affects queries for quays and stop places. If true only quays and stop places with at least one visiting line are included. | -| `multiModalMode` | `'parent' | 'child' | 'all'` | `'parent'`. | MultiModalMode for query. To control whether multi modal parent stop places, their mono modal children or both are included in the response. Does not affect mono modal stop places that do not belong to a multi modal stop place. Only applicable for placeType StopPlace | +| Key | Type | Default | Description | +| :------------------- | :--------------- | :------------------ | :------------------------------------------------------------------------------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | ------------------------------------------ | +| `maximumDistance` |  `number` | `2000` | Maximum distance (in meters) to search for from the specified location. | +| `maximumResults` |  `number` | `20` | The maximum number of results to return. | +| `filterByPlaceTypes` |  `'BikePark' | 'BikeRentalStation' | 'CarPark' | 'Quay' | 'StopPlace'` | No restrictions. | Only include places of given types if set. | +| `filterByModes` |  `TransportMode` | No restrictions. | Only include places that include this mode. Only checked for places with mode i.e. quays, departures. | +| `filterByInUse` |  `boolean` | `false`. | Only affects queries for quays and stop places. If true only quays and stop places with at least one visiting line are included. | +| `multiModalMode` |  `'parent' | 'child' | 'all'` | `'parent'`. | MultiModalMode for query. To control whether multi modal parent stop places, their mono modal children or both are included in the response. Does not affect mono modal stop places that do not belong to a multi modal stop place. Only applicable for placeType StopPlace | ### 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 @@ -42,7 +44,7 @@ import createEnturService, { TypeName } from '@entur/sdk' // or: const createEnturService = require('@entur/sdk').default const service = createEnturService({ - clientName: 'awesomecompany-awesomeapp' + clientName: 'awesomecompany-awesomeapp', }) async function example() { @@ -50,7 +52,7 @@ async function example() { const nearbyPlaces = await service.getNearestPlaces( { latitude: 59.911898, - longitude:10.75038, + longitude: 10.75038, }, { filterByPlaceTypes: [TypeName.STOP_PLACE], diff --git a/docs/places/getParentStopPlace.mdx b/docs/places/getParentStopPlace.mdx index 758d0f67..2e4b3643 100644 --- a/docs/places/getParentStopPlace.mdx +++ b/docs/places/getParentStopPlace.mdx @@ -21,8 +21,9 @@ The ID of the stop place to get the parent stop place of. See the `params` parameter for `getStopPlace`. ### 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) | diff --git a/docs/places/getQuaysForStopPlace.mdx b/docs/places/getQuaysForStopPlace.mdx index 3c49edd2..787e5da6 100644 --- a/docs/places/getQuaysForStopPlace.mdx +++ b/docs/places/getQuaysForStopPlace.mdx @@ -15,17 +15,19 @@ Returns all the quays that belong to a stop place. ## Parameters ### stopPlaceId (`string`) + The ID of the stop place to find quays for. Example: `"NSR:StopPlace:59616"`. ### params (`Object`) [Optional] -| Key | Type | Default | Description | -|:-------------------------|:---------------|:-------------|:------------| -| `includeUnusedQuays` | `boolean` | `true` | Whether to include quays no longer in use or not. | +| Key | Type | Default | Description | +| :------------------- | :--------- | :------ | :------------------------------------------------ | +| `includeUnusedQuays` |  `boolean` | `true` | Whether to include quays no longer in use or not. | ### 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) | diff --git a/docs/places/getStopPlace.mdx b/docs/places/getStopPlace.mdx index a4dc7a30..7221cee7 100644 --- a/docs/places/getStopPlace.mdx +++ b/docs/places/getStopPlace.mdx @@ -20,13 +20,14 @@ The ID of the stop place to get. ### params (`Object`) [Optional] -| Key | Type | Default | Description | -|:-------------------------|:---------------|:-------------|:------------| -| `includeUnusedQuays` | `boolean` | `true` | Whether to include quays no longer in use or not. | +| Key | Type | Default | Description | +| :------------------- | :--------- | :------ | :------------------------------------------------ | +| `includeUnusedQuays` |  `boolean` | `true` | Whether to include quays no longer in use or not. | ### 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) | diff --git a/docs/places/getStopPlaceFacilities.mdx b/docs/places/getStopPlaceFacilities.mdx index f2e7bbdd..3679a247 100644 --- a/docs/places/getStopPlaceFacilities.mdx +++ b/docs/places/getStopPlaceFacilities.mdx @@ -16,11 +16,13 @@ Facilities can be accessibility assessments like is the stop place wheelchair ac ## Parameters ### stopPlaceId (`string`) + The ID of the stop place to find facilities for. Example: `"NSR:StopPlace:59616"`. ### 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) | diff --git a/docs/places/getStopPlaces.mdx b/docs/places/getStopPlaces.mdx index 49d2a20d..ab827144 100644 --- a/docs/places/getStopPlaces.mdx +++ b/docs/places/getStopPlaces.mdx @@ -23,8 +23,9 @@ The IDs of the stop places to get. See the `params` parameter for `getStopPlace`. ### 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) | diff --git a/docs/places/getStopPlacesByPosition.mdx b/docs/places/getStopPlacesByPosition.mdx index ae12a773..184e6d8c 100644 --- a/docs/places/getStopPlacesByPosition.mdx +++ b/docs/places/getStopPlacesByPosition.mdx @@ -15,9 +15,11 @@ route: /places/getStopPlacesByPosition ## Parameters ### coordinates (`Coordinates`) + 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 stop places. @@ -28,8 +30,9 @@ The width and height of the bounding box are therefore `2 * distance`, and the c See the `params` parameter for `getStopPlace`. ### 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) | diff --git a/docs/scooters/getScootersByPosition.mdx b/docs/scooters/getScootersByPosition.mdx index d79ada5b..3d2f0ffc 100644 --- a/docs/scooters/getScootersByPosition.mdx +++ b/docs/scooters/getScootersByPosition.mdx @@ -18,19 +18,20 @@ This method uses the [Scooters API](https://developer.entur.org/pages-mobility-d ### params (`Object`) -| Key | Type | Required? | Default | Description | -|:------------|:--------------------|:----------|:--------| -| `latitude` | `number` | `true` | N/A | The latitude coordinate to find scooters around | -| `longitude` | `number` | `true` | N/A | The longitude coordinate to find scooters around | -| `distance` | `number` | `false` | 200 | The radius of the search area, surrounding the latitude/longitude coordinates | -| `limit` | `number` | `false` | 20 | The max number of scooters to return | -| `operators` | `ScooterOperator[]` | `false` | `['TIER', 'VOI', 'LIME', 'ZVIPP', 'BOLT' ]` | A list of operators to find scooters for. If not specified, all are returned. | +| Key | Type | Required? | Default | Description | +| :---------- | :------------------- | :-------- | :------------------------------------------ | ----------------------------------------------------------------------------- | +| `latitude` |  `number` | `true` | N/A | The latitude coordinate to find scooters around | +| `longitude` |  `number` | `true` | N/A | The longitude coordinate to find scooters around | +| `distance` |  `number` | `false` | 200 | The radius of the search area, surrounding the latitude/longitude coordinates | +| `limit` |  `number` | `false` | 20 | The max number of scooters to return | +| `operators` |  `ScooterOperator[]` | `false` | `['TIER', 'VOI', 'LIME', 'ZVIPP', 'BOLT' ]` | A list of operators to find scooters for. If not specified, all are returned. | ### 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 @@ -40,20 +41,18 @@ 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 scooters = await service.getScootersByPosition( - { - latitude: 59.95, - longitude: 10.75, - distance: 200, - limit: 10, - operators: ['TIER', 'VOI'], // Use the ScooterOperator enum if using TypeScript - }, - ) + const scooters = await service.getScootersByPosition({ + latitude: 59.95, + longitude: 10.75, + distance: 200, + limit: 10, + operators: ['TIER', 'VOI'], // Use the ScooterOperator enum if using TypeScript + }) console.log(scooters) } catch (error) { console.error(error) @@ -70,16 +69,24 @@ We have explicitly typed this by making the `Scooter` type a union type of `Batt The utility method `isBatteryScooter` and `isBatteryLevelScooter` can be used to refine the type, as shown in the example below: ```typescript -import createEnturService, { Scooter, isBatteryScooter, BatteryLevel } from '@entur/sdk' +import createEnturService, { + Scooter, + isBatteryScooter, + BatteryLevel, +} from '@entur/sdk' const service = createEnturService({ - clientName: 'awesomecompany-awesomeapp' + clientName: 'awesomecompany-awesomeapp', }) async function averageBatteryPercentage(): Promise { - const scooters = await service.getScootersByPosition({ latitude: 59.909, longitude: 10.746, limit: 1 }) + const scooters = await service.getScootersByPosition({ + latitude: 59.909, + longitude: 10.746, + limit: 1, + }) - const batteryPercentages: number[] = scooters.map(scooter => { + const batteryPercentages: number[] = scooters.map((scooter) => { if (isBatteryScooter(scooter)) { return scooter.battery } @@ -97,7 +104,9 @@ async function averageBatteryPercentage(): Promise { } }) - return batteryPercentages.reduce((a, b) => a + b) / batteryPercentages.length + return ( + batteryPercentages.reduce((a, b) => a + b) / batteryPercentages.length + ) } averageBatteryPercentage() diff --git a/docs/travel/findTrips.mdx b/docs/travel/findTrips.mdx index 30ebe8c8..7ccf5dfd 100644 --- a/docs/travel/findTrips.mdx +++ b/docs/travel/findTrips.mdx @@ -17,19 +17,23 @@ If no locations are found for either `from` or `to`, or if `date` is invalid, an ## Parameters ### from (`string`) + The place you want to search from. For instance `"Oslo"` ### to (`string`) + The place you want to search from. For instance `"Bergen"` ### date (`Date | string | number`) [Optional] + The wanted time of departure. Can be anything that is parseable by `new Date()`. If not provided, the search will be from "now". ### 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 @@ -39,13 +43,13 @@ import createEnturService from '@entur/sdk' // or: const createEnturService = require('@entur/sdk').default const service = createEnturService({ - clientName: 'awesomecompany-awesomeapp' + clientName: 'awesomecompany-awesomeapp', }) async function findSomeTrips() { try { const trips = await service.findTrips('Oslo S', 'Bergen stasjon') - console.log(trips); + console.log(trips) } catch (error) { console.error(error) } diff --git a/docs/travel/getTripPatterns.mdx b/docs/travel/getTripPatterns.mdx index 36512ab1..6df8b041 100644 --- a/docs/travel/getTripPatterns.mdx +++ b/docs/travel/getTripPatterns.mdx @@ -17,41 +17,42 @@ If you are going to do a huge amount of different searches at the same time, con ## Parameters ### params (`GetTripPatternsParams`) + An object of search parameters. -| Key | Type | Default | Description | -|:----------------------------|:-------------------|:----------|:------------| -| `from` | `Location` |  | The location to search for travels from. | -| `to` | `Location` | | The destination location to search for travels to. | -| `allowBikeRental` | `boolean` | `false` | Is bike rental allowed? | -| `arriveBy` | `boolean` | `false` | Depart by `searchDate`, or arrive by `searchDate` | -| `limit` | `number` | `5` | Limit result to this number of trip patterns | -| `maxPreTransitWalkDistance` | `number` | `Number.MAX_VALUE` | Max walk distance for access/egress legs. | -| `modes` | [`QueryMode[]`](https://github.com/entur/sdk/blob/master/src/types/Mode.ts) | `['foot', 'bus', 'tram', 'rail', 'metro', 'water', 'air']` | modes of transport to include in trip | -| `searchDate` | `Date` | | When to calculate patterns | -| `useFlex` | `boolean` | `false` | Whether to allow flexible search results or not | -| `walkSpeed` | `number` | `1.3` | The walk speed to use in searches in meters per second | -| `minimumTransferTime` | `number` | `120` | The minimum transfer time to use in searches in seconds | -| `wheelchairAccessible` | `boolean` | `false` | Include only stops which are wheelchair accessible | -| `banned` | `InputBanned` |  | Parameters for indicating authorities, lines or quays not be used in the trip patterns | -| `whiteListed` | `InputWhitelisted` |  | Parameters for indicating the only authorities, lines or quays to be used in the trip patterns | +| Key | Type | Default | Description | +| :-------------------------- | :--------------------------------------------------------------------------- | :---------------------------------------------------------- | :--------------------------------------------------------------------------------------------- | +| `from` |  `Location` |   | The location to search for travels from. | +| `to` |  `Location` | | The destination location to search for travels to. | +| `allowBikeRental` |  `boolean` |  `false` | Is bike rental allowed? | +| `arriveBy` |  `boolean` |  `false` | Depart by `searchDate`, or arrive by `searchDate` | +| `limit` |  `number` |  `5` | Limit result to this number of trip patterns | +| `maxPreTransitWalkDistance` |  `number` |  `Number.MAX_VALUE` | Max walk distance for access/egress legs. | +| `modes` |  [`QueryMode[]`](https://github.com/entur/sdk/blob/master/src/types/Mode.ts) |  `['foot', 'bus', 'tram', 'rail', 'metro', 'water', 'air']` | modes of transport to include in trip | +| `searchDate` |  `Date` | | When to calculate patterns | +| `useFlex` |  `boolean` | `false` | Whether to allow flexible search results or not | +| `walkSpeed` |  `number` |  `1.3` | The walk speed to use in searches in meters per second | +| `minimumTransferTime` |  `number` |  `120` | The minimum transfer time to use in searches in seconds | +| `wheelchairAccessible` |  `boolean` |  `false` | Include only stops which are wheelchair accessible | +| `banned` |  `InputBanned` |   | Parameters for indicating authorities, lines or quays not be used in the trip patterns | +| `whiteListed` |  `InputWhitelisted` |   | Parameters for indicating the only authorities, lines or quays to be used in the trip patterns | InputBanned and InputWhitelisted types: ```typescript interface InputBanned { - lines?: Array; - authorities?: Array; - organisations?: Array; - quays?: Array; - quaysHard?: Array; - serviceJourneys?: Array; + lines?: Array + authorities?: Array + organisations?: Array + quays?: Array + quaysHard?: Array + serviceJourneys?: Array } interface InputWhiteListed { - lines?: Array; - authorities?: Array; - organisations?: Array; + lines?: Array + authorities?: Array + organisations?: Array } ``` @@ -61,21 +62,22 @@ You can override the default service config on invocation if necessary. ```typescript interface OverrideConfig { - clientName?: string; + clientName?: string hosts?: { - journeyPlanner?: string; - geocoder?: string; - nsr?: string; - }; - headers?: {[key: string]: string}; + journeyPlanner?: string + geocoder?: string + nsr?: string + } + headers?: { [key: string]: string } } ``` ### 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 diff --git a/docs/utils/convertFeatureToLocation.mdx b/docs/utils/convertFeatureToLocation.mdx index 84503bfc..043eca80 100644 --- a/docs/utils/convertFeatureToLocation.mdx +++ b/docs/utils/convertFeatureToLocation.mdx @@ -32,7 +32,7 @@ async function example() { const tripPatterns = await service.getTripPatterns({ from: osloLocation, - to: bergenLocation + to: bergenLocation, }) console.log(tripPatterns) diff --git a/docs/utils/throttler.mdx b/docs/utils/throttler.mdx index 49864f32..3ccd38db 100644 --- a/docs/utils/throttler.mdx +++ b/docs/utils/throttler.mdx @@ -12,27 +12,35 @@ To help you with this, we have a `throttler` utility that throttles the requests Example usage: ```javascript -import createEnturService, { throttler, convertFeatureToLocation } from '@entur/sdk' +import createEnturService, { + throttler, + convertFeatureToLocation, +} from '@entur/sdk' // or: const { default: createEnturService, throttler, convertFeatureToLocation } = require('@entur/sdk') -const service = createEnturService({ clientName: 'myawesomecompany-myawesomeapp' }) +const service = createEnturService({ + clientName: 'myawesomecompany-myawesomeapp', +}) async function getTripPatternsForVeryManyDifferentLocations() { - const [fromLocation] = await service.getFeatures('Oslo S') - const [toLocation] = await service.getFeatures('Drammen stasjon') - const params = { - searchDate: new Date(), - from: convertFeatureToLocation(fromLocation), - to: convertFeatureToLocation(toLocation), - } - - // A huge array of arguments that we want to call a function with, one by one. - const queries = Array(3000).fill(params) - - // We pass the function and the huge list of arguments to the throttler. - // The resulting list will be in the same order as the arguments passed. - const tripPatterns = await throttler(query => service.getTripPatterns(query), queries) - console.log('Done!') - return tripPatterns + const [fromLocation] = await service.getFeatures('Oslo S') + const [toLocation] = await service.getFeatures('Drammen stasjon') + const params = { + searchDate: new Date(), + from: convertFeatureToLocation(fromLocation), + to: convertFeatureToLocation(toLocation), + } + + // A huge array of arguments that we want to call a function with, one by one. + const queries = Array(3000).fill(params) + + // We pass the function and the huge list of arguments to the throttler. + // The resulting list will be in the same order as the arguments passed. + const tripPatterns = await throttler( + (query) => service.getTripPatterns(query), + queries, + ) + console.log('Done!') + return tripPatterns } ``` diff --git a/package.json b/package.json index 14a17e23..5e972e6f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,9 @@ "index.d.ts" ], "scripts": { - "lint": "eslint src/ scripts/ --ext=js,ts", + "lint": "eslint src/ scripts/ --ext=js,ts && npm run prettier -- --check", + "prettier": "prettier src docs scripts *.{md,js}", + "format": "npm run prettier -- --write", "test": "npm run lint && ts-node scripts/validate-queries.js && tsc --noEmit --emitDeclarationOnly false -p .", "prebuild": "npm test && rm -rf lib", "declaration": "tsc", diff --git a/src/service.ts b/src/service.ts index 91eae9c1..c1d09a75 100644 --- a/src/service.ts +++ b/src/service.ts @@ -43,8 +43,9 @@ function createEnturService(config: ArgumentConfig) { config: ServiceConfig, ): Promise => { if (process.env.NODE_ENV !== 'production') { - // eslint-disable-next-line - console.warn('journeyPlannerQuery is deprecated and will be removed in a future release. Please use queryJourneyPlanner instead.') + console.warn( + 'journeyPlannerQuery is deprecated and will be removed in a future release. Please use queryJourneyPlanner instead.', + ) } return journeyPlannerQuery(query, variables, config) }, @@ -65,8 +66,9 @@ function createEnturService(config: ArgumentConfig) { config: ServiceConfig, ): Promise => { if (process.env.NODE_ENV !== 'production') { - // eslint-disable-next-line - console.warn('nsrQuery is deprecated and will be removed in a future release. Please use queryNsr instead.') + console.warn( + 'nsrQuery is deprecated and will be removed in a future release. Please use queryNsr instead.', + ) } return nsrQuery(query, variables, config) }, diff --git a/test.js b/test.js index ae21d10d..191301c0 100644 --- a/test.js +++ b/test.js @@ -1,10 +1,13 @@ -const [,, nameOfMethodToRun] = process.argv +const [, , nameOfMethodToRun] = process.argv require('@babel/register')({ presets: [ - ['@babel/preset-env', { - targets: { node: 'current' }, - }], + [ + '@babel/preset-env', + { + targets: { node: 'current' }, + }, + ], ], ignore: [/node_modules/], }) @@ -67,10 +70,13 @@ function getMethodToRun(name) { case 'getBikeRentalStation': return service.getBikeRentalStation(JERNBANETORGET_BIKE_STOP) case 'getBikeRentalStationsByPosition': - return service.getBikeRentalStationsByPosition({ - latitude: 59.911898, - longitude: 10.75038, - }, 50) + return service.getBikeRentalStationsByPosition( + { + latitude: 59.911898, + longitude: 10.75038, + }, + 50, + ) case 'getDeparturesFromStopPlace': return service.getDeparturesFromStopPlace(JERNBANETORGET) case 'getDeparturesFromStopPlaces': @@ -79,7 +85,10 @@ function getMethodToRun(name) { { limit: 2 }, ) case 'getDeparturesBetweenStopPlaces': - return service.getDeparturesBetweenStopPlaces(LILLEHAMMER_STASJON, HAMAR_STASJON) + return service.getDeparturesBetweenStopPlaces( + LILLEHAMMER_STASJON, + HAMAR_STASJON, + ) default: // eslint-disable-next-line prefer-promise-reject-errors return Promise.reject(`Error: method ${name} is not defined`) @@ -88,4 +97,7 @@ function getMethodToRun(name) { getMethodToRun(nameOfMethodToRun) // eslint-disable-next-line no-console - .then(data => console.log(JSON.stringify(data, undefined, 4)), console.error) + .then( + (data) => console.log(JSON.stringify(data, undefined, 4)), + console.error, + )