wili 0.8.0 → 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
@@ -6,7 +6,7 @@
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
 
@@ -28,44 +28,58 @@ const options = {
28
28
  const { trafficInfos } = await wili.trafficInfoList(options);
29
29
  ```
30
30
 
31
- :warning: Für NodeJS-Versionen unterhalb v18, muss die Klasse mit einer `fetch`-Implementierung instanziert werden.
31
+ ## API
32
32
 
33
- **Beispiel**
33
+ ### monitor
34
34
 
35
- ```js
36
- import { createWienerLinien } from 'wili';
37
- import fetch from 'isomorphic-fetch';
35
+ Verwendung: `monitor(stopId, [options])` oder `monitor(options)`
36
+
37
+ Die Monitor Schnittstelle liefert Echtzeiten oder Planzeiten der nächsten 70 Minuten für einen Haltepunkt.
38
38
 
39
- const wili = createWienerLinien(fetch);
39
+ Benötigt `stopId`, `diva` oder beides.
40
+
41
+ ```js
42
+ await wili.monitor(4111);
43
+ await wili.monitor({ diva: 60201040, aArea: true });
40
44
  ```
41
45
 
42
- ## API
46
+ #### Parameter:
43
47
 
44
- ### monitor
48
+ #### `stopId`
45
49
 
46
- Verwendung: `monitor(rbl, [options])`
50
+ Typen: `String`, `Integer`, `Array`
47
51
 
48
- Die Monitor Schnittstelle liefert Echtzeiten oder Planzeiten der nächsten 70 Minuten für einen Haltepunkt
52
+ Haltepunkt-ID, früher RBL Nummer (Rechnergestütztes Betriebsleitsystem), lässt sich [hier](https://till.mabe.at/rbl/?line=214433687&station=231116899) abfragen.
49
53
 
50
- #### Parameter:
54
+ ##### `options.stopId`
55
+
56
+ Typen: `String`, `Integer`, `Array`
57
+
58
+ Wie der Parameter `stopId`.
51
59
 
52
- #### `rbl`
60
+ ##### `options.diva`
53
61
 
54
62
  Typen: `String`, `Integer`, `Array`
55
63
 
56
- RBL Nummer (Rechnergestütztes Betriebsleitsystem), lässt sich [hier](https://till.mabe.at/rbl/?line=214433687&station=231116899) abfragen
64
+ DIVA Nummer einer Haltestelle, liefert alle ihre Haltepunkte.
57
65
 
58
- ##### `options.activeTrafficInfo`
66
+ ##### `options.aArea`
67
+
68
+ Typ: `Boolean`
69
+
70
+ Bezieht alle Steige des Haltestellenbereichs mit ein.
71
+
72
+ ##### `options.activateTrafficInfo`
59
73
 
60
74
  Typen: `String`, `Array`
61
75
 
62
- Störungstypen: `stoerungkurz`, `stoerunglang` oder `aufzugsinfo`
76
+ Störungstypen: `stoerungkurz`, `stoerunglang` oder `aufzugsinfo`.
63
77
 
64
78
  ### newsList
65
79
 
66
80
  Verwendung: `newsList(options)`
67
81
 
68
- Die Schnittstelle liefert Neuigkeiten wie „Aktuelles“ oder „Aufzugswartungen”
82
+ Die Schnittstelle liefert Neuigkeiten wie „Aktuelles“ oder „Aufzugswartungen“.
69
83
 
70
84
  #### Optionen
71
85
 
@@ -73,25 +87,25 @@ Die Schnittstelle liefert Neuigkeiten wie „Aktuelles“ oder „Aufzugswartung
73
87
 
74
88
  Typen: `String`, `Integer`, `Array`
75
89
 
76
- Name der Linie, z.B. U1, S7, 59A (schreibungsunabhängig)
90
+ Name der Linie, z.B. U1, S7, 59A (schreibungsunabhängig).
77
91
 
78
92
  ##### `options.relatedStop`
79
93
 
80
94
  Typen: `String`, `Integer`, `Array`
81
95
 
82
- Haltepunkt ID der Haltestelle
96
+ Haltepunkt ID der Haltestelle.
83
97
 
84
98
  ##### `options.name`
85
99
 
86
100
  Typen: `String`, `Array`
87
101
 
88
- Name der Nachrichtenkategorie, z.B `news` oder `aufzugsservice`
102
+ Name der Nachrichtenkategorie, z.B `news` oder `aufzugsservice`.
89
103
 
90
104
  ### trafficInfoList
91
105
 
92
106
  Verwendung: `trafficInfoList([options])`
93
107
 
94
- Die Schnittstelle liefert Störungen
108
+ Die Schnittstelle liefert Betriebsstörungen und Aufzugsausfälle.
95
109
 
96
110
  #### Optionen
97
111
 
@@ -99,24 +113,20 @@ Die Schnittstelle liefert Störungen
99
113
 
100
114
  Typen: `String`, `Integer`, `Array`
101
115
 
102
- Name der Linie, z.B. U1, S7, 59A (schreibungsunabhängig)
116
+ Name der Linie, z.B. U1, S7, 59A (schreibungsunabhängig).
103
117
 
104
118
  ##### `options.relatedStop`
105
119
 
106
120
  Typen: `String`, `Integer`, `Array`
107
121
 
108
- Haltepunkt ID der Haltestelle
122
+ Haltepunkt ID der Haltestelle.
109
123
 
110
124
  ##### `options.name`
111
125
 
112
126
  Typen: `String`, `Array`
113
127
 
114
- Störungstypen: `stoerungkurz`, `stoerunglang` oder `aufzugsinfo`
128
+ Störungstypen: `stoerungkurz`, `stoerunglang` oder `aufzugsinfo`.
115
129
 
116
130
  ## Lizenz
117
131
 
118
- Diese Software unterliegt den Bestimmungen der [MIT Lizenz](https://opensource.org/licenses/MIT)
119
-
120
- ## Spenden
121
-
122
- 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`
132
+ Diese Software unterliegt den Bestimmungen der [MIT Lizenz](https://opensource.org/licenses/MIT).
package/README.md CHANGED
@@ -6,7 +6,7 @@
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,47 +25,59 @@ 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
- :warning: For NodeJS versions lower than v18, the class needs to be instantiated with a `fetch`-implementation
31
+ ## API
32
32
 
33
- **Example**
33
+ ### monitor
34
34
 
35
- ```js
36
- import { createWienerLinien } from 'wili';
37
- import fetch from 'isomorphic-fetch';
35
+ Usage: `monitor(stopId, [options])` or `monitor(options)`
36
+
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
38
 
39
- const wili = createWienerLinien(fetch);
39
+ ```js
40
+ await wili.monitor(4111);
41
+ await wili.monitor({ diva: 60201040, aArea: true });
40
42
  ```
41
43
 
42
- ## API
44
+ #### Parameters:
43
45
 
44
- ### monitor
46
+ #### `stopId`
45
47
 
46
- Usage: `monitor(rbl, [options])`
48
+ Type: `String`, `Integer`, `Array`
47
49
 
48
- Returns real-time data for a station, including train information such as identifier or accessibility features.
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).
49
51
 
50
- #### Parameters:
52
+ ##### `options.stopId`
53
+
54
+ Type: `String`, `Integer`, `Array`
51
55
 
52
- #### `rbl`
56
+ Same as the `stopId` parameter.
57
+
58
+ ##### `options.diva`
53
59
 
54
60
  Type: `String`, `Integer`, `Array`
55
61
 
56
- RBL number (Rechnergestütztes Betriebsleitsystem - computer-aided operations control system), can be found this [website](https://till.mabe.at/rbl/?line=214433687&station=231116899)
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.
57
69
 
58
- ##### `options.activeTrafficInfo`
70
+ ##### `options.activateTrafficInfo`
59
71
 
60
72
  Type: `String`, `Array`
61
73
 
62
- Disruption type (`stoerungkurz`, `stoerunglang`, or `aufzugsinfo`)
74
+ Disruption type (`stoerungkurz`, `stoerunglang`, or `aufzugsinfo`).
63
75
 
64
76
  ### newsList
65
77
 
66
78
  Usage: `newsList(options)`
67
79
 
68
- Returns news, elevator maintenance and other information
80
+ Returns news, elevator maintenance and other information.
69
81
 
70
82
  #### Options
71
83
 
@@ -73,25 +85,25 @@ Returns news, elevator maintenance and other information
73
85
 
74
86
  Type: `String`, `Integer`, `Array`
75
87
 
76
- Train or bus number, e.g. U1, S7, 59A (case-insensitive)
88
+ Train or bus number, e.g. U1, S7, 59A (case-insensitive).
77
89
 
78
90
  ##### `options.relatedStop`
79
91
 
80
92
  Type: `String`, `Integer`, `Array`
81
93
 
82
- Station ID
94
+ Station ID.
83
95
 
84
96
  ##### `options.name`
85
97
 
86
98
  Type: `String`, `Array`
87
99
 
88
- Information category, e.g `news` or `aufzugsservice`
100
+ Information category, e.g `news` or `aufzugsservice`.
89
101
 
90
102
  ### trafficInfoList
91
103
 
92
104
  Usage: `trafficInfoList([options])`
93
105
 
94
- Returns interruption of operations and elevator outage
106
+ Returns interruption of operations and elevator outage.
95
107
 
96
108
  #### Options
97
109
 
@@ -99,20 +111,20 @@ Returns interruption of operations and elevator outage
99
111
 
100
112
  Type: `String`, `Integer`, `Array`
101
113
 
102
- Train or bus number, e.g. U1, S7, 59A (case-insensitive)
114
+ Train or bus number, e.g. U1, S7, 59A (case-insensitive).
103
115
 
104
116
  ##### `options.relatedStop`
105
117
 
106
118
  Type: `String`, `Integer`, `Array`
107
119
 
108
- Station ID
120
+ Station ID.
109
121
 
110
122
  ##### `options.name`
111
123
 
112
124
  Type: `String`, `Array`
113
125
 
114
- Disruption type (`stoerungkurz`, `stoerunglang`, or `aufzugsinfo`)
126
+ Disruption type (`stoerungkurz`, `stoerunglang`, or `aufzugsinfo`).
115
127
 
116
128
  ## License
117
129
 
118
- This work is licensed under [The MIT License](https://opensource.org/licenses/MIT)
130
+ This work is licensed under [The MIT License](https://opensource.org/licenses/MIT).
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`);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
- * @param {function} fetchParam - The fetch function to use for making HTTP requests.
40
- * @throws {TypeError} - If the supplied fetch parameter is not a function.
41
- * @returns {Object} - 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.
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.0",
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 {function} fetchParam - The fetch function to use for making HTTP requests.
40
- * @throws {TypeError} - If the supplied fetch parameter is not a function.
41
- * @returns {Object} - The WienerLinien API client.
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`);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 };