wili 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.de.md +26 -24
- package/README.md +26 -24
- package/data/wienerlinien-ogd-haltestellen.json +24004 -0
- package/data/wienerlinien-ogd-linien.json +1482 -0
- package/data/wienerlinien-ogd-steige.json +96566 -0
- package/data/wienerlinien-ogd-teilstrecken-lonlat.json +331802 -0
- package/data/wienerlinien-ogd-teilstrecken-wkt.json +10676 -0
- package/lib/wili.mjs +63 -94
- package/package.json +30 -29
- package/types/index.d.ts +34 -0
- package/.eslintrc.cjs +0 -16
- package/.github/workflows/default.yml +0 -44
- package/.github/workflows/stale.yml +0 -21
- package/.vscode/tasks.json +0 -19
- package/lib/wili.cjs +0 -106
- package/rollup.config.js +0 -55
package/lib/wili.mjs
CHANGED
|
@@ -1,97 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.API_KEY = (API_KEY && API_KEY.length)
|
|
8
|
-
? String(API_KEY)
|
|
9
|
-
: String(process.env.WIENER_LINIEN_API_KEY) || 'undefined';
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var WienerLinien = class {
|
|
3
|
+
#fetch;
|
|
4
|
+
constructor(fetchParam = globalThis.fetch) {
|
|
5
|
+
if (typeof fetch !== "function") {
|
|
6
|
+
throw new TypeError("The supplied fetch parameter is not a function");
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
urlParams['activateTrafficInfo'] = options.activateTrafficInfo;
|
|
24
|
-
}
|
|
25
|
-
if (this.API_KEY && this.API_KEY.trim().length) {
|
|
26
|
-
urlParams['sender'] = this.API_KEY;
|
|
27
|
-
}
|
|
28
|
-
return this.apiCall('/monitor', urlParams);
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Returns news, elevator maintenance and other information
|
|
32
|
-
* @param options optional arguments
|
|
33
|
-
* @returns JSON
|
|
34
|
-
*/
|
|
35
|
-
WienerLinien.prototype.newsList = function (options) {
|
|
36
|
-
if (options === void 0) { options = {}; }
|
|
37
|
-
var urlParams = {};
|
|
38
|
-
if (typeof options.relatedLine !== 'undefined' && options.relatedLine) {
|
|
39
|
-
urlParams['relatedLine'] = options.relatedLine;
|
|
40
|
-
}
|
|
41
|
-
if (typeof options.relatedStop !== 'undefined' && options.relatedStop) {
|
|
42
|
-
urlParams['relatedStop'] = options.relatedStop;
|
|
43
|
-
}
|
|
44
|
-
if (typeof options.name !== 'undefined' && options.name) {
|
|
45
|
-
urlParams['name'] = options.name;
|
|
46
|
-
}
|
|
47
|
-
if (this.API_KEY && this.API_KEY.trim().length) {
|
|
48
|
-
urlParams['sender'] = this.API_KEY;
|
|
49
|
-
}
|
|
50
|
-
return this.apiCall('newsList', urlParams);
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Returns interruption of operations and elevator outage
|
|
54
|
-
* @param options optional arguments
|
|
55
|
-
* @returns JSON
|
|
56
|
-
*/
|
|
57
|
-
WienerLinien.prototype.trafficInfoList = function (options) {
|
|
58
|
-
if (options === void 0) { options = {}; }
|
|
59
|
-
var urlParams = {};
|
|
60
|
-
if (typeof options.relatedLine !== 'undefined' && options.relatedLine) {
|
|
61
|
-
urlParams['relatedLine'] = options.relatedLine;
|
|
62
|
-
}
|
|
63
|
-
if (typeof options.relatedStop !== 'undefined' && options.relatedStop) {
|
|
64
|
-
urlParams['relatedStop'] = options.relatedStop;
|
|
65
|
-
}
|
|
66
|
-
if (typeof options.name !== 'undefined' && options.name) {
|
|
67
|
-
urlParams['name'] = options.name;
|
|
68
|
-
}
|
|
69
|
-
if (this.API_KEY && this.API_KEY.trim().length) {
|
|
70
|
-
urlParams['sender'] = this.API_KEY;
|
|
71
|
-
}
|
|
72
|
-
return this.apiCall('trafficInfoList', urlParams);
|
|
8
|
+
this.#fetch = fetchParam;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Returns real-time data for a station
|
|
12
|
+
* @param {StringNumbers} rbl - RBL number
|
|
13
|
+
* @param {MonitorOptions} options
|
|
14
|
+
* @returns {object}
|
|
15
|
+
*/
|
|
16
|
+
monitor(rbl, options = {}) {
|
|
17
|
+
const urlParams = {
|
|
18
|
+
...options,
|
|
19
|
+
rbl
|
|
73
20
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
21
|
+
return this.#apiCall("/monitor", urlParams);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns news, elevator maintenance and other information
|
|
25
|
+
* @param {NewsListOptions} options
|
|
26
|
+
* @returns {object}
|
|
27
|
+
*/
|
|
28
|
+
newsList(options = {}) {
|
|
29
|
+
return this.#apiCall("newsList", options);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns interruption of operations and elevator outage
|
|
33
|
+
* @param {TrafficInfoOptions} options
|
|
34
|
+
* @returns {object}
|
|
35
|
+
*/
|
|
36
|
+
trafficInfoList(options = {}) {
|
|
37
|
+
return this.#apiCall("trafficInfoList", options);
|
|
38
|
+
}
|
|
39
|
+
#buildUrl(urlPath, urlParams) {
|
|
40
|
+
const searchParams = new URLSearchParams();
|
|
41
|
+
for (const [key, value] of Object.entries(urlParams)) {
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
for (const item of value) {
|
|
44
|
+
searchParams.append(key, String(item));
|
|
77
45
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
46
|
+
} else {
|
|
47
|
+
searchParams.set(key, String(value));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return new URL(`https://www.wienerlinien.at/ogd_realtime/${urlPath}?${searchParams.toString()}`);
|
|
51
|
+
}
|
|
52
|
+
#checkStatus(response) {
|
|
53
|
+
if (response.ok) {
|
|
54
|
+
return Promise.resolve(response);
|
|
55
|
+
} else {
|
|
56
|
+
return Promise.reject(new Error(response.statusText));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
#apiCall(urlPath, urlParams) {
|
|
60
|
+
const url = this.#buildUrl(urlPath, urlParams);
|
|
61
|
+
return this.#fetch(url.href).then(this.#checkStatus).then((response) => response.json()).then((json) => json.data).catch(console.error);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
WienerLinien
|
|
66
|
+
};
|
package/package.json
CHANGED
|
@@ -1,27 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wili",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "A Node client for the Wiener Linien public transport API",
|
|
5
5
|
"author": "Jan T. Sott",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"exports":
|
|
9
|
-
"import": "./lib/wili.mjs",
|
|
10
|
-
"require": "./lib/wili.cjs"
|
|
11
|
-
},
|
|
8
|
+
"exports": "./lib/wili.mjs",
|
|
12
9
|
"typings": "types/",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=16.13 || >=18"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"data/",
|
|
15
|
+
"lib/",
|
|
16
|
+
"types/",
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
13
20
|
"repository": {
|
|
14
21
|
"type": "git",
|
|
15
22
|
"url": "https://github.com/idleberg/node-wili.git"
|
|
16
23
|
},
|
|
17
24
|
"scripts": {
|
|
18
|
-
"build": "
|
|
25
|
+
"build": "esbuild src/index.ts --bundle --platform=node --outfile=lib/wili.mjs --format=esm --external:isomorphic-fetch --external:query-string",
|
|
19
26
|
"dev": "npm run start",
|
|
20
|
-
"lint": "eslint ./src",
|
|
21
27
|
"lint:fix": "eslint --fix ./src",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"prepare": "husky install"
|
|
28
|
+
"lint": "eslint ./src",
|
|
29
|
+
"prepack": "npm run build",
|
|
30
|
+
"prepare": "husky install",
|
|
31
|
+
"start": "npm run build -- --watch",
|
|
32
|
+
"test": "uvu tests"
|
|
25
33
|
},
|
|
26
34
|
"keywords": [
|
|
27
35
|
"wiener linien",
|
|
@@ -30,26 +38,19 @@
|
|
|
30
38
|
"öpvn",
|
|
31
39
|
"public transport"
|
|
32
40
|
],
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"isomorphic-fetch": "^3.0.0",
|
|
35
|
-
"query-string": "^7.0.1"
|
|
36
|
-
},
|
|
41
|
+
"dependencies": {},
|
|
37
42
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"lint-staged": "^11.1.1",
|
|
50
|
-
"rollup": "^2.23.0",
|
|
51
|
-
"tslib": "^2.2.0",
|
|
52
|
-
"typescript": "^4.2.3"
|
|
43
|
+
"@types/isomorphic-fetch": "^0.0.36",
|
|
44
|
+
"@types/node": "^18.15.5",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
|
46
|
+
"@typescript-eslint/parser": "^5.56.0",
|
|
47
|
+
"esbuild": "^0.17.12",
|
|
48
|
+
"eslint": "^8.36.0",
|
|
49
|
+
"husky": "^8.0.3",
|
|
50
|
+
"lint-staged": "^13.2.0",
|
|
51
|
+
"tslib": "^2.5.0",
|
|
52
|
+
"typescript": "^5.0.2",
|
|
53
|
+
"uvu": "^0.5.6"
|
|
53
54
|
},
|
|
54
55
|
"lint-staged": {
|
|
55
56
|
"*.ts": "eslint --cache --fix"
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
type StringNumbers = number | string | number[] | string[];
|
|
2
|
+
|
|
3
|
+
declare class WienerLinien {
|
|
4
|
+
constructor(API_KEY?: string);
|
|
5
|
+
|
|
6
|
+
monitor(rbl: StringNumbers, options: MonitorOptions): Promise<Record<string, unknown>>;
|
|
7
|
+
newsList(options: NewsListOptions): Promise<Record<string, unknown>>;
|
|
8
|
+
trafficInfoList(options: TrafficInfoOptions): Promise<Record<string, unknown>>;
|
|
9
|
+
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
reqUrl?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type MonitorOptions = {
|
|
15
|
+
activateTrafficInfo?: string | string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface MonitorParams extends MonitorOptions {
|
|
19
|
+
rbl?: StringNumbers;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type NewsListOptions = {
|
|
23
|
+
name?: string | string[];
|
|
24
|
+
relatedLine?: StringNumbers;
|
|
25
|
+
relatedStop?: StringNumbers;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type TrafficInfoOptions = {
|
|
29
|
+
name?: string | string[];
|
|
30
|
+
relatedLine?: StringNumbers;
|
|
31
|
+
relatedStop?: StringNumbers;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type UrlParams = MonitorOptions | NewsListOptions | TrafficInfoOptions;
|
package/.eslintrc.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
module.exports = {
|
|
3
|
-
root: true,
|
|
4
|
-
parser: '@typescript-eslint/parser',
|
|
5
|
-
plugins: [
|
|
6
|
-
'@typescript-eslint',
|
|
7
|
-
],
|
|
8
|
-
extends: [
|
|
9
|
-
'eslint:recommended',
|
|
10
|
-
'plugin:@typescript-eslint/recommended',
|
|
11
|
-
],
|
|
12
|
-
rules: {
|
|
13
|
-
// temporary
|
|
14
|
-
"@typescript-eslint/no-explicit-any": "off"
|
|
15
|
-
}
|
|
16
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
|
|
3
|
-
on: [push]
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
default:
|
|
7
|
-
runs-on: ${{ matrix.os }}
|
|
8
|
-
strategy:
|
|
9
|
-
matrix:
|
|
10
|
-
node-version: ['lts/*']
|
|
11
|
-
os: [ubuntu-latest]
|
|
12
|
-
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v2
|
|
15
|
-
with:
|
|
16
|
-
fetch-depth: 1
|
|
17
|
-
|
|
18
|
-
- uses: actions/setup-node@v2
|
|
19
|
-
with:
|
|
20
|
-
node-version: ${{ matrix.node-version }}
|
|
21
|
-
|
|
22
|
-
- name: Cache node modules
|
|
23
|
-
uses: actions/cache@v2
|
|
24
|
-
env:
|
|
25
|
-
cache-name: cache-node-modules
|
|
26
|
-
with:
|
|
27
|
-
path: ~/.npm
|
|
28
|
-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
|
29
|
-
restore-keys: |
|
|
30
|
-
${{ runner.os }}-build-${{ env.cache-name }}-
|
|
31
|
-
${{ runner.os }}-build-
|
|
32
|
-
${{ runner.os }}-
|
|
33
|
-
|
|
34
|
-
- name: Install Packages Dependencies
|
|
35
|
-
run: npm ci
|
|
36
|
-
|
|
37
|
-
- name: Lint Source
|
|
38
|
-
run: npm run lint --if-present
|
|
39
|
-
|
|
40
|
-
- name: Build Source
|
|
41
|
-
run: npm run build --if-present
|
|
42
|
-
|
|
43
|
-
- name: Run Tests
|
|
44
|
-
run: npm run test --if-present
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
name: 'Stale issues and PR'
|
|
2
|
-
on:
|
|
3
|
-
schedule:
|
|
4
|
-
- cron: '30 1 * * *'
|
|
5
|
-
|
|
6
|
-
jobs:
|
|
7
|
-
stale:
|
|
8
|
-
runs-on: ubuntu-latest
|
|
9
|
-
steps:
|
|
10
|
-
- uses: actions/stale@v4
|
|
11
|
-
with:
|
|
12
|
-
stale-issue-label: stale
|
|
13
|
-
stale-pr-label: stale
|
|
14
|
-
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 14 days.'
|
|
15
|
-
stale-pr-message: 'This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 14 days.'
|
|
16
|
-
close-issue-message: 'This issue was closed because it has been stalled for 14 days with no activity.'
|
|
17
|
-
close-pr-message: 'This PR was closed because it has been stalled for 14 days with no activity.'
|
|
18
|
-
days-before-issue-stale: 30
|
|
19
|
-
days-before-pr-stale: 30
|
|
20
|
-
days-before-issue-close: 14
|
|
21
|
-
days-before-pr-close: 14
|
package/.vscode/tasks.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "2.0.0",
|
|
3
|
-
"tasks": [
|
|
4
|
-
{
|
|
5
|
-
"label": "Development",
|
|
6
|
-
"type": "npm",
|
|
7
|
-
"script": "start",
|
|
8
|
-
"presentation": {
|
|
9
|
-
"clear": true,
|
|
10
|
-
"focus": false,
|
|
11
|
-
"panel": "shared",
|
|
12
|
-
"showReuseMessage": true
|
|
13
|
-
},
|
|
14
|
-
"runOptions": {
|
|
15
|
-
"runOn": "folderOpen"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
package/lib/wili.cjs
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var fetch = require('isomorphic-fetch');
|
|
6
|
-
var queryString = require('query-string');
|
|
7
|
-
|
|
8
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
-
|
|
10
|
-
var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
|
|
11
|
-
var queryString__default = /*#__PURE__*/_interopDefaultLegacy(queryString);
|
|
12
|
-
|
|
13
|
-
var WienerLinien = /** @class */ (function () {
|
|
14
|
-
function WienerLinien(API_KEY) {
|
|
15
|
-
if (API_KEY === void 0) { API_KEY = undefined; }
|
|
16
|
-
this.API_KEY = (API_KEY && API_KEY.length)
|
|
17
|
-
? String(API_KEY)
|
|
18
|
-
: String(process.env.WIENER_LINIEN_API_KEY) || 'undefined';
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Returns real-time data for a station
|
|
22
|
-
* @param rbl - RBL number
|
|
23
|
-
* @param options optional arguments
|
|
24
|
-
* @returns - JSON
|
|
25
|
-
*/
|
|
26
|
-
WienerLinien.prototype.monitor = function (rbl, options) {
|
|
27
|
-
if (options === void 0) { options = {}; }
|
|
28
|
-
var urlParams = {
|
|
29
|
-
rbl: rbl
|
|
30
|
-
};
|
|
31
|
-
if (typeof options.activateTrafficInfo !== 'undefined' && options.activateTrafficInfo) {
|
|
32
|
-
urlParams['activateTrafficInfo'] = options.activateTrafficInfo;
|
|
33
|
-
}
|
|
34
|
-
if (this.API_KEY && this.API_KEY.trim().length) {
|
|
35
|
-
urlParams['sender'] = this.API_KEY;
|
|
36
|
-
}
|
|
37
|
-
return this.apiCall('/monitor', urlParams);
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Returns news, elevator maintenance and other information
|
|
41
|
-
* @param options optional arguments
|
|
42
|
-
* @returns JSON
|
|
43
|
-
*/
|
|
44
|
-
WienerLinien.prototype.newsList = function (options) {
|
|
45
|
-
if (options === void 0) { options = {}; }
|
|
46
|
-
var urlParams = {};
|
|
47
|
-
if (typeof options.relatedLine !== 'undefined' && options.relatedLine) {
|
|
48
|
-
urlParams['relatedLine'] = options.relatedLine;
|
|
49
|
-
}
|
|
50
|
-
if (typeof options.relatedStop !== 'undefined' && options.relatedStop) {
|
|
51
|
-
urlParams['relatedStop'] = options.relatedStop;
|
|
52
|
-
}
|
|
53
|
-
if (typeof options.name !== 'undefined' && options.name) {
|
|
54
|
-
urlParams['name'] = options.name;
|
|
55
|
-
}
|
|
56
|
-
if (this.API_KEY && this.API_KEY.trim().length) {
|
|
57
|
-
urlParams['sender'] = this.API_KEY;
|
|
58
|
-
}
|
|
59
|
-
return this.apiCall('newsList', urlParams);
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Returns interruption of operations and elevator outage
|
|
63
|
-
* @param options optional arguments
|
|
64
|
-
* @returns JSON
|
|
65
|
-
*/
|
|
66
|
-
WienerLinien.prototype.trafficInfoList = function (options) {
|
|
67
|
-
if (options === void 0) { options = {}; }
|
|
68
|
-
var urlParams = {};
|
|
69
|
-
if (typeof options.relatedLine !== 'undefined' && options.relatedLine) {
|
|
70
|
-
urlParams['relatedLine'] = options.relatedLine;
|
|
71
|
-
}
|
|
72
|
-
if (typeof options.relatedStop !== 'undefined' && options.relatedStop) {
|
|
73
|
-
urlParams['relatedStop'] = options.relatedStop;
|
|
74
|
-
}
|
|
75
|
-
if (typeof options.name !== 'undefined' && options.name) {
|
|
76
|
-
urlParams['name'] = options.name;
|
|
77
|
-
}
|
|
78
|
-
if (this.API_KEY && this.API_KEY.trim().length) {
|
|
79
|
-
urlParams['sender'] = this.API_KEY;
|
|
80
|
-
}
|
|
81
|
-
return this.apiCall('trafficInfoList', urlParams);
|
|
82
|
-
};
|
|
83
|
-
WienerLinien.prototype.checkStatus = function (response) {
|
|
84
|
-
if (response.status >= 200 && response.status < 300) {
|
|
85
|
-
return Promise.resolve(response);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
return Promise.reject(new Error(response.statusText));
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
WienerLinien.prototype.parseJson = function (response) {
|
|
92
|
-
return response.json();
|
|
93
|
-
};
|
|
94
|
-
WienerLinien.prototype.apiCall = function (urlPath, urlParams) {
|
|
95
|
-
var url = new URL('https://www.wienerlinien.at');
|
|
96
|
-
url.pathname = "/ogd_realtime/" + urlPath;
|
|
97
|
-
url.search = queryString__default['default'].stringify(urlParams);
|
|
98
|
-
return fetch__default['default'](url.href)
|
|
99
|
-
.then(this.checkStatus)
|
|
100
|
-
.then(this.parseJson)
|
|
101
|
-
.then(function (response) { return response.data; })["catch"](console.error);
|
|
102
|
-
};
|
|
103
|
-
return WienerLinien;
|
|
104
|
-
}());
|
|
105
|
-
|
|
106
|
-
exports.WienerLinien = WienerLinien;
|
package/rollup.config.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import commonjs from '@rollup/plugin-commonjs';
|
|
2
|
-
import json from '@rollup/plugin-json';
|
|
3
|
-
import typescript from '@rollup/plugin-typescript';
|
|
4
|
-
|
|
5
|
-
const plugins = [
|
|
6
|
-
commonjs(),
|
|
7
|
-
json()
|
|
8
|
-
];
|
|
9
|
-
|
|
10
|
-
const compilerOptions = {
|
|
11
|
-
allowSyntheticDefaultImports: true,
|
|
12
|
-
moduleResolution: "node",
|
|
13
|
-
strictNullChecks: true,
|
|
14
|
-
typeRoots: ['./types', './node_modules/@types']
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const external = [
|
|
18
|
-
'child_process',
|
|
19
|
-
'events',
|
|
20
|
-
'isomorphic-fetch',
|
|
21
|
-
'os',
|
|
22
|
-
'query-string',
|
|
23
|
-
'stream'
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
export default [
|
|
27
|
-
{
|
|
28
|
-
external,
|
|
29
|
-
input: 'src/index.ts',
|
|
30
|
-
output: {
|
|
31
|
-
file: 'lib/wili.cjs',
|
|
32
|
-
format: 'cjs'
|
|
33
|
-
},
|
|
34
|
-
plugins: [
|
|
35
|
-
...plugins,
|
|
36
|
-
typescript(compilerOptions)
|
|
37
|
-
]
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
external,
|
|
41
|
-
input: 'src/index.ts',
|
|
42
|
-
output: {
|
|
43
|
-
file: 'lib/wili.mjs',
|
|
44
|
-
format: 'esm'
|
|
45
|
-
},
|
|
46
|
-
plugins: [
|
|
47
|
-
...plugins,
|
|
48
|
-
typescript({
|
|
49
|
-
...compilerOptions,
|
|
50
|
-
module: "ES2020",
|
|
51
|
-
moduleResolution: "node"
|
|
52
|
-
})
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
];
|