@tmlmobilidade/external 20260625.1419.32 → 20260625.1714.32

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.
@@ -0,0 +1,21 @@
1
+ import { type GtfsRtFeedMessage } from '@tmlmobilidade/types';
2
+ export declare const CrtmLaVelozClient: Readonly<{
3
+ /**
4
+ * Fetches GTFS-RT Vehicle Positions feed from the CRTM La Veloz API.
5
+ *
6
+ * @returns {Promise<GtfsRtFeedMessage>} A promise that resolves with the decoded GTFS-RT Vehicle Positions feed message.
7
+ */
8
+ vehiclePositions: () => Promise<GtfsRtFeedMessage>;
9
+ /**
10
+ * Fetches GTFS-RT Trip Updates feed from the CRTM La Veloz API.
11
+ *
12
+ * @returns {Promise<GtfsRtFeedMessage>} A promise that resolves with the decoded GTFS-RT Trip Updates feed message.
13
+ */
14
+ tripUpdates: () => Promise<GtfsRtFeedMessage>;
15
+ /**
16
+ * Fetches GTFS-RT Service Alerts feed from the CRTM La Veloz API.
17
+ *
18
+ * @returns {Promise<GtfsRtFeedMessage>} A promise that resolves with the decoded GTFS-RT Service Alerts feed message.
19
+ */
20
+ serviceAlerts: () => Promise<GtfsRtFeedMessage>;
21
+ }>;
@@ -0,0 +1,57 @@
1
+ /* * */
2
+ import { decodeGtfsRtFeed } from '@tmlmobilidade/gtfs-rt';
3
+ /* * */
4
+ const BASE_URL = process.env.CRTM_LAVELOZ_API_URL;
5
+ async function fetcher(endpoint) {
6
+ if (!BASE_URL) {
7
+ throw new Error('Missing CRTM_LAVELOZ_API_URL environment variable.');
8
+ }
9
+ const response = await fetch(`${BASE_URL}${endpoint}`, {
10
+ headers: {
11
+ Accept: 'application/json, text/plain',
12
+ Authorization: process.env.CRTM_LAVELOZ_API_KEY,
13
+ },
14
+ });
15
+ if (!response.ok) {
16
+ throw new Error(`Request failed (${response.status}): ${response.statusText}`);
17
+ }
18
+ return response;
19
+ }
20
+ const endpoints = {
21
+ serviceAlerts: '/gtfs-rt-alerts/v2',
22
+ tripUpdates: '/gtfs-rt-trip-updates',
23
+ vehiclePositions: '/gtfs-rt-vehicle-positions',
24
+ };
25
+ export const CrtmLaVelozClient = Object.freeze({
26
+ //
27
+ /**
28
+ * Fetches GTFS-RT Vehicle Positions feed from the CRTM La Veloz API.
29
+ *
30
+ * @returns {Promise<GtfsRtFeedMessage>} A promise that resolves with the decoded GTFS-RT Vehicle Positions feed message.
31
+ */
32
+ vehiclePositions: async () => {
33
+ const response = await fetcher(endpoints.vehiclePositions);
34
+ const arrayBuffer = await response.arrayBuffer();
35
+ return decodeGtfsRtFeed(arrayBuffer);
36
+ },
37
+ /**
38
+ * Fetches GTFS-RT Trip Updates feed from the CRTM La Veloz API.
39
+ *
40
+ * @returns {Promise<GtfsRtFeedMessage>} A promise that resolves with the decoded GTFS-RT Trip Updates feed message.
41
+ */
42
+ tripUpdates: async () => {
43
+ const response = await fetcher(endpoints.tripUpdates);
44
+ const arrayBuffer = await response.arrayBuffer();
45
+ return decodeGtfsRtFeed(arrayBuffer);
46
+ },
47
+ /**
48
+ * Fetches GTFS-RT Service Alerts feed from the CRTM La Veloz API.
49
+ *
50
+ * @returns {Promise<GtfsRtFeedMessage>} A promise that resolves with the decoded GTFS-RT Service Alerts feed message.
51
+ */
52
+ serviceAlerts: async () => {
53
+ const response = await fetcher(endpoints.serviceAlerts);
54
+ const arrayBuffer = await response.arrayBuffer();
55
+ return decodeGtfsRtFeed(arrayBuffer);
56
+ },
57
+ });
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@
8
8
  * - ccfl: Companhia dos Caminhos de Ferro de Lisboa (CCFL) AKA Carris Munícipal API Client.
9
9
  * - cp: Comboios de Portugal (CP) API Client
10
10
  * - crtmAisa: Consorcio Regional de Transportes de Madrid (AISACRTM) API Client
11
+ * - crtmLaVeloz: Consorcio Regional de Transportes de La Veloz (CRTM La Veloz) API Client
11
12
  * - mobi: MobiCascais API Client
12
13
  * - ml: Metro Lisboa (ML) API Client
13
14
  * - tcb: Transportes Colectivos do Barreiro (TCB) API Client
@@ -28,6 +29,11 @@ export declare const externalClients: Readonly<{
28
29
  tripUpdates: () => Promise<import("@tmlmobilidade/types").GtfsRtFeedMessage>;
29
30
  schedule: () => Promise<Buffer>;
30
31
  }>;
32
+ crtmLaVeloz: Readonly<{
33
+ vehiclePositions: () => Promise<import("@tmlmobilidade/types").GtfsRtFeedMessage>;
34
+ tripUpdates: () => Promise<import("@tmlmobilidade/types").GtfsRtFeedMessage>;
35
+ serviceAlerts: () => Promise<import("@tmlmobilidade/types").GtfsRtFeedMessage>;
36
+ }>;
31
37
  fertagus: Readonly<{
32
38
  trains: () => Promise<import("./clients/fertagus/types.js").TrainsResponse>;
33
39
  }>;
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { CcflClient } from './clients/ccfl/index.js';
3
3
  import { CpClient } from './clients/cp/index.js';
4
4
  import { CrtmAisaClient } from './clients/crtm-aisa/index.js';
5
+ import { CrtmLaVelozClient } from './clients/crtm-laveloz/index.js';
5
6
  import { FertagusClient } from './clients/fertagus/index.js';
6
7
  import { MlClient } from './clients/ml/index.js';
7
8
  import { MobiClient } from './clients/mobi/index.js';
@@ -17,6 +18,7 @@ import { TtslClient } from './clients/ttsl/index.js';
17
18
  * - ccfl: Companhia dos Caminhos de Ferro de Lisboa (CCFL) AKA Carris Munícipal API Client.
18
19
  * - cp: Comboios de Portugal (CP) API Client
19
20
  * - crtmAisa: Consorcio Regional de Transportes de Madrid (AISACRTM) API Client
21
+ * - crtmLaVeloz: Consorcio Regional de Transportes de La Veloz (CRTM La Veloz) API Client
20
22
  * - mobi: MobiCascais API Client
21
23
  * - ml: Metro Lisboa (ML) API Client
22
24
  * - tcb: Transportes Colectivos do Barreiro (TCB) API Client
@@ -26,6 +28,7 @@ export const externalClients = Object.freeze({
26
28
  ccfl: CcflClient,
27
29
  cp: CpClient,
28
30
  crtmAisa: CrtmAisaClient,
31
+ crtmLaVeloz: CrtmLaVelozClient,
29
32
  fertagus: FertagusClient,
30
33
  ml: MlClient,
31
34
  mobi: MobiClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/external",
3
- "version": "20260625.1419.32",
3
+ "version": "20260625.1714.32",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"