wili 0.8.1 → 0.9.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 CHANGED
@@ -32,29 +32,54 @@ const { trafficInfos } = await wili.trafficInfoList(options);
32
32
 
33
33
  ### monitor
34
34
 
35
- Verwendung: `monitor(rbl, [options])`
35
+ Verwendung: `monitor(stopId, [options])` oder `monitor(options)`
36
36
 
37
- 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.
38
+
39
+ Benötigt `stopId`, `diva` oder beides.
40
+
41
+ ```js
42
+ await wili.monitor(4111);
43
+ await wili.monitor({ diva: 60201040, aArea: true });
44
+ ```
38
45
 
39
46
  #### Parameter:
40
47
 
41
- #### `rbl`
48
+ #### `stopId`
49
+
50
+ Typen: `String`, `Integer`, `Array`
51
+
52
+ Haltepunkt-ID, früher RBL Nummer (Rechnergestütztes Betriebsleitsystem), lässt sich [hier](https://till.mabe.at/rbl/?line=214433687&station=231116899) abfragen.
53
+
54
+ ##### `options.stopId`
42
55
 
43
56
  Typen: `String`, `Integer`, `Array`
44
57
 
45
- RBL Nummer (Rechnergestütztes Betriebsleitsystem), lässt sich [hier](https://till.mabe.at/rbl/?line=214433687&station=231116899) abfragen.
58
+ Wie der Parameter `stopId`.
59
+
60
+ ##### `options.diva`
61
+
62
+ Typen: `String`, `Integer`, `Array`
63
+
64
+ DIVA Nummer einer Haltestelle, liefert alle ihre Haltepunkte.
65
+
66
+ ##### `options.aArea`
67
+
68
+ Typ: `Boolean`
69
+
70
+ Bezieht alle Steige des Haltestellenbereichs mit ein.
46
71
 
47
- ##### `options.activeTrafficInfo`
72
+ ##### `options.activateTrafficInfo`
48
73
 
49
74
  Typen: `String`, `Array`
50
75
 
51
- Störungstypen: `stoerungkurz`, `stoerunglang` oder `aufzugsinfo`.
76
+ Störungstypen: `stoerungkurz`, `stoerunglang` oder `aufzugsinfo`.
52
77
 
53
78
  ### newsList
54
79
 
55
80
  Verwendung: `newsList(options)`
56
81
 
57
- Die Schnittstelle liefert Neuigkeiten wie „Aktuelles“ oder „Aufzugswartungen”.
82
+ Die Schnittstelle liefert Neuigkeiten wie „Aktuelles“ oder „Aufzugswartungen“.
58
83
 
59
84
  #### Optionen
60
85
 
@@ -80,7 +105,7 @@ Name der Nachrichtenkategorie, z.B `news` oder `aufzugsservice`.
80
105
 
81
106
  Verwendung: `trafficInfoList([options])`
82
107
 
83
- Die Schnittstelle liefert Störungen.
108
+ Die Schnittstelle liefert Betriebsstörungen und Aufzugsausfälle.
84
109
 
85
110
  #### Optionen
86
111
 
@@ -100,7 +125,7 @@ Haltepunkt ID der Haltestelle.
100
125
 
101
126
  Typen: `String`, `Array`
102
127
 
103
- Störungstypen: `stoerungkurz`, `stoerunglang` oder `aufzugsinfo`.
128
+ Störungstypen: `stoerungkurz`, `stoerunglang` oder `aufzugsinfo`.
104
129
 
105
130
  ## Lizenz
106
131
 
package/README.md CHANGED
@@ -25,26 +25,49 @@ const options = {
25
25
  relatedLine: ['U2', 'U4', 'U6']
26
26
  };
27
27
 
28
- const { trafficInfos } = await wili.trafficInfoList(options);
28
+ const { trafficInfos } = await wili.trafficInfoList(options);
29
29
  ```
30
30
 
31
31
  ## API
32
32
 
33
33
  ### monitor
34
34
 
35
- Usage: `monitor(rbl, [options])`
35
+ Usage: `monitor(stopId, [options])` or `monitor(options)`
36
36
 
37
- Returns real-time data for a station, including train information such as identifier or accessibility features.
37
+ Returns real-time or scheduled departures for the next 70 minutes for a station, including train information such as identifier or accessibility features. Requires `stopId`, `diva`, or both.
38
+
39
+ ```js
40
+ await wili.monitor(4111);
41
+ await wili.monitor({ diva: 60201040, aArea: true });
42
+ ```
38
43
 
39
44
  #### Parameters:
40
45
 
41
- #### `rbl`
46
+ #### `stopId`
47
+
48
+ Type: `String`, `Integer`, `Array`
49
+
50
+ Stop ID, formerly known as RBL number (Rechnergestütztes Betriebsleitsystem - computer-aided operations control system), can be found this [website](https://till.mabe.at/rbl/?line=214433687&station=231116899).
51
+
52
+ ##### `options.stopId`
42
53
 
43
54
  Type: `String`, `Integer`, `Array`
44
55
 
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).
56
+ Same as the `stopId` parameter.
57
+
58
+ ##### `options.diva`
59
+
60
+ Type: `String`, `Integer`, `Array`
61
+
62
+ DIVA number of a station, returns all of its stops.
63
+
64
+ ##### `options.aArea`
65
+
66
+ Type: `Boolean`
67
+
68
+ Include all platforms of the stop's area.
46
69
 
47
- ##### `options.activeTrafficInfo`
70
+ ##### `options.activateTrafficInfo`
48
71
 
49
72
  Type: `String`, `Array`
50
73
 
package/lib/index.cjs CHANGED
@@ -1 +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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),exports.createWienerLinien=function(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,...typeof e==`object`&&!Array.isArray(e)?e:{stopId: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(r!==void 0){if(typeof r==`boolean`)n.set(e,r?`1`:`0`);else 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){let r=i(t,n),o=await(await a(await e(r.href))).json();if(o.message?.messageCode!==1)throw Error(`API ${o.message?.messageCode}: ${o.message?.value} (${r.href})`);return o.data}return{monitor:t,newsList:n,trafficInfoList:r}};
package/lib/index.d.cts CHANGED
@@ -1,49 +1,45 @@
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
+ type StringNumbers = number | string | number[] | string[];
2
+ type UrlParams = MonitorOptions | NewsListOptions | TrafficInfoOptions;
3
+ type MonitorOptions = {
4
+ activateTrafficInfo?: string | string[];
5
+ /** Include all platforms of the stop's area. */
6
+ aArea?: boolean;
7
+ /** DIVA number of a station. */
8
+ diva?: StringNumbers;
9
+ /** Stop ID (formerly RBL number). */
10
+ stopId?: 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
+ };
37
34
  /**
38
35
  * Creates an instance of the WienerLinien API client.
39
36
  * @param fetchParam The fetch function to use for making HTTP requests.
40
37
  * @returns The WienerLinien API client.
41
38
  * @throws If the supplied fetch parameter is not a function.
42
39
  */
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>;
40
+ export declare function createWienerLinien(fetchParam?: typeof fetch): {
41
+ monitor: (stopId: StringNumbers | MonitorOptions, options?: MonitorOptions) => Promise<MonitorResponse>;
42
+ newsList: (options?: NewsListOptions) => Promise<NewsListResponse>;
43
+ trafficInfoList: (options?: TrafficInfoOptions) => Promise<TrafficInfoListResponse>;
47
44
  };
48
- //#endregion
49
- export { createWienerLinien };
45
+ export type { MonitorOptions, MonitorResponse, NewsListOptions, NewsListResponse, StringNumbers, TrafficInfoListResponse, TrafficInfoOptions, UrlParams };
@@ -0,0 +1,45 @@
1
+ type StringNumbers = number | string | number[] | string[];
2
+ type UrlParams = MonitorOptions | NewsListOptions | TrafficInfoOptions;
3
+ type MonitorOptions = {
4
+ activateTrafficInfo?: string | string[];
5
+ /** Include all platforms of the stop's area. */
6
+ aArea?: boolean;
7
+ /** DIVA number of a station. */
8
+ diva?: StringNumbers;
9
+ /** Stop ID (formerly RBL number). */
10
+ stopId?: 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
+ * Creates an instance of the WienerLinien API client.
36
+ * @param fetchParam The fetch function to use for making HTTP requests.
37
+ * @returns The WienerLinien API client.
38
+ * @throws If the supplied fetch parameter is not a function.
39
+ */
40
+ export declare function createWienerLinien(fetchParam?: typeof fetch): {
41
+ monitor: (stopId: StringNumbers | MonitorOptions, options?: MonitorOptions) => Promise<MonitorResponse>;
42
+ newsList: (options?: NewsListOptions) => Promise<NewsListResponse>;
43
+ trafficInfoList: (options?: TrafficInfoOptions) => Promise<TrafficInfoListResponse>;
44
+ };
45
+ export type { MonitorOptions, MonitorResponse, NewsListOptions, NewsListResponse, StringNumbers, TrafficInfoListResponse, TrafficInfoOptions, UrlParams };
package/lib/index.mjs 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,...typeof e==`object`&&!Array.isArray(e)?e:{stopId: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(r!==void 0){if(typeof r==`boolean`)n.set(e,r?`1`:`0`);else 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){let r=i(t,n),o=await(await a(await e(r.href))).json();if(o.message?.messageCode!==1)throw Error(`API ${o.message?.messageCode}: ${o.message?.value} (${r.href})`);return o.data}return{monitor:t,newsList:n,trafficInfoList:r}}export{e as createWienerLinien};
package/package.json CHANGED
@@ -1,22 +1,27 @@
1
1
  {
2
2
  "name": "wili",
3
- "version": "0.8.1",
3
+ "version": "0.9.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
8
  "exports": {
9
- "types": "./lib/index.d.ts",
10
- "import": "./lib/index.js"
9
+ "import": {
10
+ "types": "./lib/index.d.mts",
11
+ "default": "./lib/index.mjs"
12
+ },
13
+ "require": {
14
+ "types": "./lib/index.d.cts",
15
+ "default": "./lib/index.cjs"
16
+ }
11
17
  },
12
18
  "main": "./lib/index.cjs",
13
19
  "types": "./lib/index.d.cts",
14
20
  "engines": {
15
- "node": ">=20"
21
+ "node": ">=22"
16
22
  },
17
23
  "files": [
18
24
  "lib/",
19
- "types/",
20
25
  "LICENSE",
21
26
  "README.md"
22
27
  ],
@@ -32,28 +37,24 @@
32
37
  "public transport"
33
38
  ],
34
39
  "devDependencies": {
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",
45
- "tsm": "^2.3.0",
46
- "typescript": "^5.9.3",
47
- "uvu": "^0.5.6"
40
+ "@commitlint/cli": "^21.3.0",
41
+ "@commitlint/config-conventional": "^21.3.0",
42
+ "@idleberg/configs": "^0.4.6",
43
+ "@types/node": "^26.6.11",
44
+ "concurrently": "^10.1.0",
45
+ "execa": "^10.2.1",
46
+ "np": "^12.1.1",
47
+ "tsdown": "^0.23.8",
48
+ "typescript": "^7.0.2",
49
+ "vitest": "^5.1.2"
48
50
  },
49
51
  "scripts": {
50
52
  "build": "tsdown",
51
53
  "dev": "tsdown --watch",
52
54
  "lint": "concurrently --prefix-colors blue,green,magenta npm:lint:*",
53
55
  "lint:biome": "biome check",
54
- "lint:knip": "knip --cache --production",
55
- "lint:publint": "publint",
56
+ "lint:e18e": "e18e-cli analyze --log-level error",
56
57
  "publish:npm": "np --any-branch",
57
- "test": "uvu -r tsm tests"
58
+ "test": "vitest run"
58
59
  }
59
60
  }
package/lib/index.d.ts DELETED
@@ -1,49 +0,0 @@
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.js DELETED
@@ -1 +0,0 @@
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/types/index.d.ts DELETED
@@ -1,43 +0,0 @@
1
- declare namespace Wili {
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
- };
40
- }
41
-
42
- export default Wili;
43
- export { Wili };