wili 0.7.1 → 0.8.1
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 +15 -45
- package/README.md +14 -40
- package/lib/index.cjs +1 -0
- package/lib/index.d.cts +49 -0
- package/lib/index.d.ts +45 -7
- package/lib/index.js +1 -0
- package/package.json +28 -29
- package/types/index.d.ts +40 -31
- package/lib/wili.mjs +0 -100
- package/lib/wili.mjs.map +0 -1
package/README.de.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/idleberg/node-wili/blob/main/LICENSE)
|
|
4
4
|
[](https://www.npmjs.org/package/wili)
|
|
5
|
-
|
|
5
|
+

|
|
6
6
|
|
|
7
7
|
[English](README.md) | **Deutsch**
|
|
8
8
|
|
|
9
|
-
Node Wrapper für die Echtzeitdaten-API der Wiener Linien
|
|
9
|
+
Node Wrapper für die Echtzeitdaten-API der Wiener Linien.
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
@@ -25,33 +25,7 @@ const options = {
|
|
|
25
25
|
relatedLine: ['U2', 'U4', 'U6']
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
wili.trafficInfoList(options)
|
|
30
|
-
.then( data => {
|
|
31
|
-
console.log(data.trafficInfos);
|
|
32
|
-
})
|
|
33
|
-
.catch( error => {
|
|
34
|
-
console.error(error);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// async/await
|
|
38
|
-
try {
|
|
39
|
-
const data = await wili.trafficInfoList(options);
|
|
40
|
-
console.log(data.trafficInfos);
|
|
41
|
-
} catch (output) {
|
|
42
|
-
console.error(error);
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
:warning: Für NodeJS-Versionen unterhalb v18, muss die Klasse mit einer `fetch`-Implementierung instanziert werden.
|
|
47
|
-
|
|
48
|
-
**Beispiel**
|
|
49
|
-
|
|
50
|
-
```js
|
|
51
|
-
import { createWienerLinien } from 'wili';
|
|
52
|
-
import fetch from 'isomorphic-fetch';
|
|
53
|
-
|
|
54
|
-
const wili = createWienerLinien(fetch);
|
|
28
|
+
const { trafficInfos } = await wili.trafficInfoList(options);
|
|
55
29
|
```
|
|
56
30
|
|
|
57
31
|
## API
|
|
@@ -60,7 +34,7 @@ const wili = createWienerLinien(fetch);
|
|
|
60
34
|
|
|
61
35
|
Verwendung: `monitor(rbl, [options])`
|
|
62
36
|
|
|
63
|
-
Die Monitor Schnittstelle liefert Echtzeiten oder Planzeiten der nächsten 70 Minuten für einen Haltepunkt
|
|
37
|
+
Die Monitor Schnittstelle liefert Echtzeiten oder Planzeiten der nächsten 70 Minuten für einen Haltepunkt.
|
|
64
38
|
|
|
65
39
|
#### Parameter:
|
|
66
40
|
|
|
@@ -68,19 +42,19 @@ Die Monitor Schnittstelle liefert Echtzeiten oder Planzeiten der nächsten 70 M
|
|
|
68
42
|
|
|
69
43
|
Typen: `String`, `Integer`, `Array`
|
|
70
44
|
|
|
71
|
-
RBL Nummer (Rechnergestütztes Betriebsleitsystem), lässt sich [hier](https://till.mabe.at/rbl/?line=214433687&station=231116899) abfragen
|
|
45
|
+
RBL Nummer (Rechnergestütztes Betriebsleitsystem), lässt sich [hier](https://till.mabe.at/rbl/?line=214433687&station=231116899) abfragen.
|
|
72
46
|
|
|
73
47
|
##### `options.activeTrafficInfo`
|
|
74
48
|
|
|
75
49
|
Typen: `String`, `Array`
|
|
76
50
|
|
|
77
|
-
Störungstypen: `stoerungkurz`, `stoerunglang` oder `aufzugsinfo
|
|
51
|
+
Störungstypen: `stoerungkurz`, `stoerunglang` oder `aufzugsinfo`.
|
|
78
52
|
|
|
79
53
|
### newsList
|
|
80
54
|
|
|
81
55
|
Verwendung: `newsList(options)`
|
|
82
56
|
|
|
83
|
-
Die Schnittstelle liefert Neuigkeiten wie „Aktuelles“ oder „Aufzugswartungen
|
|
57
|
+
Die Schnittstelle liefert Neuigkeiten wie „Aktuelles“ oder „Aufzugswartungen”.
|
|
84
58
|
|
|
85
59
|
#### Optionen
|
|
86
60
|
|
|
@@ -88,25 +62,25 @@ Die Schnittstelle liefert Neuigkeiten wie „Aktuelles“ oder „Aufzugswartung
|
|
|
88
62
|
|
|
89
63
|
Typen: `String`, `Integer`, `Array`
|
|
90
64
|
|
|
91
|
-
Name der Linie, z.B. U1, S7, 59A (schreibungsunabhängig)
|
|
65
|
+
Name der Linie, z.B. U1, S7, 59A (schreibungsunabhängig).
|
|
92
66
|
|
|
93
67
|
##### `options.relatedStop`
|
|
94
68
|
|
|
95
69
|
Typen: `String`, `Integer`, `Array`
|
|
96
70
|
|
|
97
|
-
Haltepunkt ID der Haltestelle
|
|
71
|
+
Haltepunkt ID der Haltestelle.
|
|
98
72
|
|
|
99
73
|
##### `options.name`
|
|
100
74
|
|
|
101
75
|
Typen: `String`, `Array`
|
|
102
76
|
|
|
103
|
-
Name der Nachrichtenkategorie, z.B `news` oder `aufzugsservice
|
|
77
|
+
Name der Nachrichtenkategorie, z.B `news` oder `aufzugsservice`.
|
|
104
78
|
|
|
105
79
|
### trafficInfoList
|
|
106
80
|
|
|
107
81
|
Verwendung: `trafficInfoList([options])`
|
|
108
82
|
|
|
109
|
-
Die Schnittstelle liefert Störungen
|
|
83
|
+
Die Schnittstelle liefert Störungen.
|
|
110
84
|
|
|
111
85
|
#### Optionen
|
|
112
86
|
|
|
@@ -114,24 +88,20 @@ Die Schnittstelle liefert Störungen
|
|
|
114
88
|
|
|
115
89
|
Typen: `String`, `Integer`, `Array`
|
|
116
90
|
|
|
117
|
-
Name der Linie, z.B. U1, S7, 59A (schreibungsunabhängig)
|
|
91
|
+
Name der Linie, z.B. U1, S7, 59A (schreibungsunabhängig).
|
|
118
92
|
|
|
119
93
|
##### `options.relatedStop`
|
|
120
94
|
|
|
121
95
|
Typen: `String`, `Integer`, `Array`
|
|
122
96
|
|
|
123
|
-
Haltepunkt ID der Haltestelle
|
|
97
|
+
Haltepunkt ID der Haltestelle.
|
|
124
98
|
|
|
125
99
|
##### `options.name`
|
|
126
100
|
|
|
127
101
|
Typen: `String`, `Array`
|
|
128
102
|
|
|
129
|
-
Störungstypen: `stoerungkurz`, `stoerunglang` oder `aufzugsinfo
|
|
103
|
+
Störungstypen: `stoerungkurz`, `stoerunglang` oder `aufzugsinfo`.
|
|
130
104
|
|
|
131
105
|
## Lizenz
|
|
132
106
|
|
|
133
|
-
Diese Software unterliegt den Bestimmungen der [MIT Lizenz](https://opensource.org/licenses/MIT)
|
|
134
|
-
|
|
135
|
-
## Spenden
|
|
136
|
-
|
|
137
|
-
Wenn Du mir einen Kaffee oder ein Bier ausgeben möchtest, freue mich über Spenden via [Flattr](https://flattr.com/submit/auto?user_id=idleberg&url=https://github.com/idleberg/node-wili) oder Bitcoin `17CXJuPsmhuTzFV2k4RKYwpEHVjskJktRd`
|
|
107
|
+
Diese Software unterliegt den Bestimmungen der [MIT Lizenz](https://opensource.org/licenses/MIT).
|
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/idleberg/node-wili/blob/main/LICENSE)
|
|
4
4
|
[](https://www.npmjs.org/package/wili)
|
|
5
|
-
|
|
5
|
+

|
|
6
6
|
|
|
7
7
|
**English** | [Deutsch](README.de.md)
|
|
8
8
|
|
|
9
|
-
A Node wrapper for the Wiener Linien public transport API
|
|
9
|
+
A Node wrapper for the Wiener Linien public transport API.
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
@@ -25,33 +25,7 @@ const options = {
|
|
|
25
25
|
relatedLine: ['U2', 'U4', 'U6']
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
wili.trafficInfoList(options)
|
|
30
|
-
.then( data => {
|
|
31
|
-
console.log(data.trafficInfos);
|
|
32
|
-
})
|
|
33
|
-
.catch( error => {
|
|
34
|
-
console.error(error);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// async/await
|
|
38
|
-
try {
|
|
39
|
-
const data = await wili.trafficInfoList(options);
|
|
40
|
-
console.log(data.trafficInfos);
|
|
41
|
-
} catch (output) {
|
|
42
|
-
console.error(error);
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
:warning: For NodeJS versions lower than v18, the class needs to be instantiated with a `fetch`-implementation
|
|
47
|
-
|
|
48
|
-
**Example**
|
|
49
|
-
|
|
50
|
-
```js
|
|
51
|
-
import { createWienerLinien } from 'wili';
|
|
52
|
-
import fetch from 'isomorphic-fetch';
|
|
53
|
-
|
|
54
|
-
const wili = createWienerLinien(fetch);
|
|
28
|
+
const { trafficInfos } = await wili.trafficInfoList(options);
|
|
55
29
|
```
|
|
56
30
|
|
|
57
31
|
## API
|
|
@@ -68,19 +42,19 @@ Returns real-time data for a station, including train information such as identi
|
|
|
68
42
|
|
|
69
43
|
Type: `String`, `Integer`, `Array`
|
|
70
44
|
|
|
71
|
-
RBL number (Rechnergestütztes Betriebsleitsystem - computer-aided operations control system), can be found this [website](https://till.mabe.at/rbl/?line=214433687&station=231116899)
|
|
45
|
+
RBL number (Rechnergestütztes Betriebsleitsystem - computer-aided operations control system), can be found this [website](https://till.mabe.at/rbl/?line=214433687&station=231116899).
|
|
72
46
|
|
|
73
47
|
##### `options.activeTrafficInfo`
|
|
74
48
|
|
|
75
49
|
Type: `String`, `Array`
|
|
76
50
|
|
|
77
|
-
Disruption type (`stoerungkurz`, `stoerunglang`, or `aufzugsinfo`)
|
|
51
|
+
Disruption type (`stoerungkurz`, `stoerunglang`, or `aufzugsinfo`).
|
|
78
52
|
|
|
79
53
|
### newsList
|
|
80
54
|
|
|
81
55
|
Usage: `newsList(options)`
|
|
82
56
|
|
|
83
|
-
Returns news, elevator maintenance and other information
|
|
57
|
+
Returns news, elevator maintenance and other information.
|
|
84
58
|
|
|
85
59
|
#### Options
|
|
86
60
|
|
|
@@ -88,25 +62,25 @@ Returns news, elevator maintenance and other information
|
|
|
88
62
|
|
|
89
63
|
Type: `String`, `Integer`, `Array`
|
|
90
64
|
|
|
91
|
-
Train or bus number, e.g. U1, S7, 59A (case-insensitive)
|
|
65
|
+
Train or bus number, e.g. U1, S7, 59A (case-insensitive).
|
|
92
66
|
|
|
93
67
|
##### `options.relatedStop`
|
|
94
68
|
|
|
95
69
|
Type: `String`, `Integer`, `Array`
|
|
96
70
|
|
|
97
|
-
Station ID
|
|
71
|
+
Station ID.
|
|
98
72
|
|
|
99
73
|
##### `options.name`
|
|
100
74
|
|
|
101
75
|
Type: `String`, `Array`
|
|
102
76
|
|
|
103
|
-
Information category, e.g `news` or `aufzugsservice
|
|
77
|
+
Information category, e.g `news` or `aufzugsservice`.
|
|
104
78
|
|
|
105
79
|
### trafficInfoList
|
|
106
80
|
|
|
107
81
|
Usage: `trafficInfoList([options])`
|
|
108
82
|
|
|
109
|
-
Returns interruption of operations and elevator outage
|
|
83
|
+
Returns interruption of operations and elevator outage.
|
|
110
84
|
|
|
111
85
|
#### Options
|
|
112
86
|
|
|
@@ -114,20 +88,20 @@ Returns interruption of operations and elevator outage
|
|
|
114
88
|
|
|
115
89
|
Type: `String`, `Integer`, `Array`
|
|
116
90
|
|
|
117
|
-
Train or bus number, e.g. U1, S7, 59A (case-insensitive)
|
|
91
|
+
Train or bus number, e.g. U1, S7, 59A (case-insensitive).
|
|
118
92
|
|
|
119
93
|
##### `options.relatedStop`
|
|
120
94
|
|
|
121
95
|
Type: `String`, `Integer`, `Array`
|
|
122
96
|
|
|
123
|
-
Station ID
|
|
97
|
+
Station ID.
|
|
124
98
|
|
|
125
99
|
##### `options.name`
|
|
126
100
|
|
|
127
101
|
Type: `String`, `Array`
|
|
128
102
|
|
|
129
|
-
Disruption type (`stoerungkurz`, `stoerunglang`, or `aufzugsinfo`)
|
|
103
|
+
Disruption type (`stoerungkurz`, `stoerunglang`, or `aufzugsinfo`).
|
|
130
104
|
|
|
131
105
|
## License
|
|
132
106
|
|
|
133
|
-
This work is licensed under [The MIT License](https://opensource.org/licenses/MIT)
|
|
107
|
+
This work is licensed under [The MIT License](https://opensource.org/licenses/MIT).
|
package/lib/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e=globalThis.fetch){if(typeof e!=`function`)throw TypeError(`The supplied fetch parameter is not a function`);e!==globalThis.fetch&&console.warn(`Providing a custom fetch implementation is deprecated and will be removed in future versions.`);async function t(e,t={}){return await o(`/monitor`,{...t,rbl:e})}async function n(e={}){return await o(`newsList`,e)}async function r(e={}){return await o(`trafficInfoList`,e)}function i(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t))if(Array.isArray(r))for(let t of r)n.append(e,String(t));else n.set(e,String(r));return new URL(`https://www.wienerlinien.at/ogd_realtime/${e}?${n.toString()}`)}async function a(e){if(e.ok)return e;throw Error(`HTTP ${e.status}: ${e.statusText} (${e.url})`)}async function o(t,n){return(await(await a(await e(i(t,n).href))).json()).data}return{monitor:t,newsList:n,trafficInfoList:r}}exports.createWienerLinien=e;
|
package/lib/index.d.cts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region types/index.d.ts
|
|
2
|
+
declare namespace Wili {
|
|
3
|
+
type Fetch = (input: URL | RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
|
|
4
|
+
type StringNumbers = number | string | number[] | string[];
|
|
5
|
+
type UrlParams = MonitorOptions | NewsListOptions | TrafficInfoOptions;
|
|
6
|
+
type MonitorOptions = {
|
|
7
|
+
activateTrafficInfo?: string | string[];
|
|
8
|
+
};
|
|
9
|
+
interface MonitorParams extends MonitorOptions {
|
|
10
|
+
rbl?: StringNumbers;
|
|
11
|
+
}
|
|
12
|
+
type NewsListOptions = {
|
|
13
|
+
name?: string | string[];
|
|
14
|
+
relatedLine?: StringNumbers;
|
|
15
|
+
relatedStop?: StringNumbers;
|
|
16
|
+
};
|
|
17
|
+
type TrafficInfoOptions = {
|
|
18
|
+
name?: string | string[];
|
|
19
|
+
relatedLine?: StringNumbers;
|
|
20
|
+
relatedStop?: StringNumbers;
|
|
21
|
+
};
|
|
22
|
+
type MonitorResponse = {
|
|
23
|
+
monitors: unknown[];
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
type NewsListResponse = {
|
|
27
|
+
pois: unknown[];
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
type TrafficInfoListResponse = {
|
|
31
|
+
trafficInfos: unknown[];
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/index.d.ts
|
|
37
|
+
/**
|
|
38
|
+
* Creates an instance of the WienerLinien API client.
|
|
39
|
+
* @param fetchParam The fetch function to use for making HTTP requests.
|
|
40
|
+
* @returns The WienerLinien API client.
|
|
41
|
+
* @throws If the supplied fetch parameter is not a function.
|
|
42
|
+
*/
|
|
43
|
+
declare function createWienerLinien(fetchParam?: typeof fetch): {
|
|
44
|
+
monitor: (rbl: Wili.StringNumbers, options?: {}) => Promise<Wili.MonitorResponse>;
|
|
45
|
+
newsList: (options?: {}) => Promise<Wili.NewsListResponse>;
|
|
46
|
+
trafficInfoList: (options?: {}) => Promise<Wili.TrafficInfoListResponse>;
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { createWienerLinien };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,11 +1,49 @@
|
|
|
1
|
+
//#region types/index.d.ts
|
|
2
|
+
declare namespace Wili {
|
|
3
|
+
type Fetch = (input: URL | RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
|
|
4
|
+
type StringNumbers = number | string | number[] | string[];
|
|
5
|
+
type UrlParams = MonitorOptions | NewsListOptions | TrafficInfoOptions;
|
|
6
|
+
type MonitorOptions = {
|
|
7
|
+
activateTrafficInfo?: string | string[];
|
|
8
|
+
};
|
|
9
|
+
interface MonitorParams extends MonitorOptions {
|
|
10
|
+
rbl?: StringNumbers;
|
|
11
|
+
}
|
|
12
|
+
type NewsListOptions = {
|
|
13
|
+
name?: string | string[];
|
|
14
|
+
relatedLine?: StringNumbers;
|
|
15
|
+
relatedStop?: StringNumbers;
|
|
16
|
+
};
|
|
17
|
+
type TrafficInfoOptions = {
|
|
18
|
+
name?: string | string[];
|
|
19
|
+
relatedLine?: StringNumbers;
|
|
20
|
+
relatedStop?: StringNumbers;
|
|
21
|
+
};
|
|
22
|
+
type MonitorResponse = {
|
|
23
|
+
monitors: unknown[];
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
type NewsListResponse = {
|
|
27
|
+
pois: unknown[];
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
type TrafficInfoListResponse = {
|
|
31
|
+
trafficInfos: unknown[];
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/index.d.ts
|
|
1
37
|
/**
|
|
2
38
|
* Creates an instance of the WienerLinien API client.
|
|
3
|
-
* @param
|
|
4
|
-
* @
|
|
5
|
-
* @
|
|
39
|
+
* @param fetchParam The fetch function to use for making HTTP requests.
|
|
40
|
+
* @returns The WienerLinien API client.
|
|
41
|
+
* @throws If the supplied fetch parameter is not a function.
|
|
6
42
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
43
|
+
declare function createWienerLinien(fetchParam?: typeof fetch): {
|
|
44
|
+
monitor: (rbl: Wili.StringNumbers, options?: {}) => Promise<Wili.MonitorResponse>;
|
|
45
|
+
newsList: (options?: {}) => Promise<Wili.NewsListResponse>;
|
|
46
|
+
trafficInfoList: (options?: {}) => Promise<Wili.TrafficInfoListResponse>;
|
|
11
47
|
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { createWienerLinien };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e=globalThis.fetch){if(typeof e!=`function`)throw TypeError(`The supplied fetch parameter is not a function`);e!==globalThis.fetch&&console.warn(`Providing a custom fetch implementation is deprecated and will be removed in future versions.`);async function t(e,t={}){return await o(`/monitor`,{...t,rbl:e})}async function n(e={}){return await o(`newsList`,e)}async function r(e={}){return await o(`trafficInfoList`,e)}function i(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t))if(Array.isArray(r))for(let t of r)n.append(e,String(t));else n.set(e,String(r));return new URL(`https://www.wienerlinien.at/ogd_realtime/${e}?${n.toString()}`)}async function a(e){if(e.ok)return e;throw Error(`HTTP ${e.status}: ${e.statusText} (${e.url})`)}async function o(t,n){return(await(await a(await e(i(t,n).href))).json()).data}return{monitor:t,newsList:n,trafficInfoList:r}}export{e as createWienerLinien};
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wili",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
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
|
-
"typings": "./types",
|
|
9
8
|
"exports": {
|
|
10
|
-
"
|
|
9
|
+
"types": "./lib/index.d.ts",
|
|
10
|
+
"import": "./lib/index.js"
|
|
11
11
|
},
|
|
12
|
+
"main": "./lib/index.cjs",
|
|
13
|
+
"types": "./lib/index.d.cts",
|
|
12
14
|
"engines": {
|
|
13
|
-
"node": ">=
|
|
15
|
+
"node": ">=20"
|
|
14
16
|
},
|
|
15
17
|
"files": [
|
|
16
18
|
"lib/",
|
|
@@ -20,17 +22,7 @@
|
|
|
20
22
|
],
|
|
21
23
|
"repository": {
|
|
22
24
|
"type": "git",
|
|
23
|
-
"url": "https://github.com/idleberg/node-wili.git"
|
|
24
|
-
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "rollup -c",
|
|
27
|
-
"dev": "npm run start",
|
|
28
|
-
"lint:fix": "eslint --fix ./src",
|
|
29
|
-
"lint": "eslint ./src",
|
|
30
|
-
"prepack": "npm run build",
|
|
31
|
-
"prepare": "husky install",
|
|
32
|
-
"start": "npm run build -- --watch",
|
|
33
|
-
"test": "uvu -r tsm tests"
|
|
25
|
+
"url": "git+https://github.com/idleberg/node-wili.git"
|
|
34
26
|
},
|
|
35
27
|
"keywords": [
|
|
36
28
|
"wiener linien",
|
|
@@ -40,21 +32,28 @@
|
|
|
40
32
|
"public transport"
|
|
41
33
|
],
|
|
42
34
|
"devDependencies": {
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
35
|
+
"@commitlint/cli": "^20.1.0",
|
|
36
|
+
"@commitlint/config-conventional": "^20.0.0",
|
|
37
|
+
"@idleberg/configs": "^0.3.1",
|
|
38
|
+
"@types/node": "^24.8.1",
|
|
39
|
+
"concurrently": "^9.2.1",
|
|
40
|
+
"execa": "^9.6.0",
|
|
41
|
+
"knip": "^5.65.0",
|
|
42
|
+
"np": "^10.2.0",
|
|
43
|
+
"publint": "^0.3.14",
|
|
44
|
+
"tsdown": "^0.15.6",
|
|
53
45
|
"tsm": "^2.3.0",
|
|
54
|
-
"typescript": "^5.
|
|
46
|
+
"typescript": "^5.9.3",
|
|
55
47
|
"uvu": "^0.5.6"
|
|
56
48
|
},
|
|
57
|
-
"
|
|
58
|
-
"
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsdown",
|
|
51
|
+
"dev": "tsdown --watch",
|
|
52
|
+
"lint": "concurrently --prefix-colors blue,green,magenta npm:lint:*",
|
|
53
|
+
"lint:biome": "biome check",
|
|
54
|
+
"lint:knip": "knip --cache --production",
|
|
55
|
+
"lint:publint": "publint",
|
|
56
|
+
"publish:npm": "np --any-branch",
|
|
57
|
+
"test": "uvu -r tsm tests"
|
|
59
58
|
}
|
|
60
|
-
}
|
|
59
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,34 +1,43 @@
|
|
|
1
1
|
declare namespace Wili {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
2
|
+
type Fetch = (input: URL | RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
|
|
3
|
+
type StringNumbers = number | string | number[] | string[];
|
|
4
|
+
type UrlParams = MonitorOptions | NewsListOptions | TrafficInfoOptions;
|
|
5
|
+
|
|
6
|
+
type MonitorOptions = {
|
|
7
|
+
activateTrafficInfo?: string | string[];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
interface MonitorParams extends MonitorOptions {
|
|
11
|
+
rbl?: StringNumbers;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type NewsListOptions = {
|
|
15
|
+
name?: string | string[];
|
|
16
|
+
relatedLine?: StringNumbers;
|
|
17
|
+
relatedStop?: StringNumbers;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type TrafficInfoOptions = {
|
|
21
|
+
name?: string | string[];
|
|
22
|
+
relatedLine?: StringNumbers;
|
|
23
|
+
relatedStop?: StringNumbers;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type MonitorResponse = {
|
|
27
|
+
monitors: unknown[];
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type NewsListResponse = {
|
|
32
|
+
pois: unknown[];
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type TrafficInfoListResponse = {
|
|
37
|
+
trafficInfos: unknown[];
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
};
|
|
31
40
|
}
|
|
32
41
|
|
|
33
|
-
export
|
|
34
|
-
export
|
|
42
|
+
export default Wili;
|
|
43
|
+
export { Wili };
|
package/lib/wili.mjs
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates an instance of the WienerLinien API client.
|
|
3
|
-
* @param {function} fetchParam - The fetch function to use for making HTTP requests.
|
|
4
|
-
* @throws {TypeError} - If the supplied fetch parameter is not a function.
|
|
5
|
-
* @returns {Object} - The WienerLinien API client.
|
|
6
|
-
*/
|
|
7
|
-
function createWienerLinien(fetchParam = globalThis.fetch) {
|
|
8
|
-
if (typeof fetchParam !== 'function') {
|
|
9
|
-
throw new TypeError('The supplied fetch parameter is not a function');
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Returns real-time data for a station.
|
|
13
|
-
* @param {string} rbl - The RBL number.
|
|
14
|
-
* @param {Object} options - The monitor options.
|
|
15
|
-
* @returns {Promise<Object>} - The real-time data for the station.
|
|
16
|
-
*/
|
|
17
|
-
async function monitor(rbl, options = {}) {
|
|
18
|
-
const urlParams = {
|
|
19
|
-
...options,
|
|
20
|
-
rbl: rbl
|
|
21
|
-
};
|
|
22
|
-
return await apiCall('/monitor', urlParams);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Returns news, elevator maintenance, and other information.
|
|
26
|
-
* @param {Object} options - The news list options.
|
|
27
|
-
* @returns {Promise<Object>} - The news and information.
|
|
28
|
-
*/
|
|
29
|
-
async function newsList(options = {}) {
|
|
30
|
-
return await apiCall('newsList', options);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Returns interruptions of operations and elevator outages.
|
|
34
|
-
* @param {Object} options - The traffic info options.
|
|
35
|
-
* @returns {Promise<Object>} - The traffic information.
|
|
36
|
-
*/
|
|
37
|
-
async function trafficInfoList(options = {}) {
|
|
38
|
-
return await apiCall('trafficInfoList', options);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Builds the URL for making API requests.
|
|
42
|
-
* @param {string} urlPath - The URL path.
|
|
43
|
-
* @param {Object} urlParams - The URL parameters.
|
|
44
|
-
* @returns {URL} - The constructed URL.
|
|
45
|
-
*/
|
|
46
|
-
function buildUrl(urlPath, urlParams) {
|
|
47
|
-
const searchParams = new URLSearchParams();
|
|
48
|
-
for (const [key, value] of Object.entries(urlParams)) {
|
|
49
|
-
if (Array.isArray(value)) {
|
|
50
|
-
for (const item of value) {
|
|
51
|
-
searchParams.append(key, String(item));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
searchParams.set(key, String(value));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return new URL(`https://www.wienerlinien.at/ogd_realtime/${urlPath}?${searchParams.toString()}`);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Checks the response status and throws an error if it's not OK.
|
|
62
|
-
* @param {Response} response - The HTTP response.
|
|
63
|
-
* @returns {Promise<Response>} - The resolved response if the status is OK.
|
|
64
|
-
* @throws {Error} - If the response status is not OK.
|
|
65
|
-
*/
|
|
66
|
-
async function checkStatus(response) {
|
|
67
|
-
if (response.ok) {
|
|
68
|
-
return response;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
throw new Error(response.statusText);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Makes an API call to the specified URL path with the given parameters.
|
|
76
|
-
* @param {string} urlPath - The URL path.
|
|
77
|
-
* @param {Object} urlParams - The URL parameters.
|
|
78
|
-
* @returns {Promise<Object>} - The API response data.
|
|
79
|
-
*/
|
|
80
|
-
async function apiCall(urlPath, urlParams) {
|
|
81
|
-
const url = buildUrl(urlPath, urlParams);
|
|
82
|
-
try {
|
|
83
|
-
const response = await fetchParam(url.href);
|
|
84
|
-
const checkedResponse = await checkStatus(response);
|
|
85
|
-
const json = await checkedResponse.json();
|
|
86
|
-
return json.data;
|
|
87
|
-
}
|
|
88
|
-
catch (error) {
|
|
89
|
-
console.error(error);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
monitor,
|
|
94
|
-
newsList,
|
|
95
|
-
trafficInfoList
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export { createWienerLinien };
|
|
100
|
-
//# sourceMappingURL=wili.mjs.map
|
package/lib/wili.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wili.mjs","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;SACa,kBAAkB,CAAC,UAAU,GAAG,UAAU,CAAC,KAAK,EAAA;AAC9D,IAAA,IAAI,OAAO,UAAU,KAAK,UAAU,EAAE;AACpC,QAAA,MAAM,IAAI,SAAS,CAAC,gDAAgD,CAAC,CAAC;AACvE,KAAA;AAED;;;;;AAKG;AACH,IAAA,eAAe,OAAO,CAAC,GAAuB,EAAE,OAAO,GAAG,EAAE,EAAA;AAC1D,QAAA,MAAM,SAAS,GAAuB;AACpC,YAAA,GAAG,OAAO;AACV,YAAA,GAAG,EAAE,GAAG;SACT,CAAC;AAEF,QAAA,OAAO,MAAM,OAAO,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;KAC7C;AAED;;;;AAIG;AACH,IAAA,eAAe,QAAQ,CAAC,OAAO,GAAG,EAAE,EAAA;AAClC,QAAA,OAAO,MAAM,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;KAC3C;AAED;;;;AAIG;AACH,IAAA,eAAe,eAAe,CAAC,OAAO,GAAG,EAAE,EAAA;AACzC,QAAA,OAAO,MAAM,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;KAClD;AAED;;;;;AAKG;AACH,IAAA,SAAS,QAAQ,CAAC,OAAe,EAAE,SAAyB,EAAA;AAC1D,QAAA,MAAM,YAAY,GAAG,IAAI,eAAe,EAAE,CAAC;AAE3C,QAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;AACpD,YAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACxB,gBAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;oBACxB,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,iBAAA;AACF,aAAA;AAAM,iBAAA;gBACL,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACtC,aAAA;AACF,SAAA;AAED,QAAA,OAAO,IAAI,GAAG,CAAC,CAAA,yCAAA,EAA4C,OAAO,CAAA,CAAA,EAAI,YAAY,CAAC,QAAQ,EAAE,CAAE,CAAA,CAAC,CAAC;KAClG;AAED;;;;;AAKG;IACH,eAAe,WAAW,CAAC,QAAkB,EAAA;QAC3C,IAAI,QAAQ,CAAC,EAAE,EAAE;AACf,YAAA,OAAO,QAAQ,CAAC;AACjB,SAAA;AAAM,aAAA;AACL,YAAA,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACtC,SAAA;KACF;AAED;;;;;AAKG;AACH,IAAA,eAAe,OAAO,CAAC,OAAe,EAAE,SAAyB,EAAA;QAC/D,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAEzC,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC5C,YAAA,MAAM,eAAe,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC,CAAC;AACpD,YAAA,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC,IAAI,CAAC;AAClB,SAAA;AAAC,QAAA,OAAO,KAAK,EAAE;AACd,YAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACtB,SAAA;KACF;IAED,OAAO;QACL,OAAO;QACP,QAAQ;QACR,eAAe;KAChB,CAAC;AACJ;;;;"}
|