zet-api 1.0.0 → 1.0.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/.github/workflows/publish-to-npm.yml +21 -35
- package/dist/auth/types.d.ts +20 -20
- package/dist/core/config.d.ts +1 -0
- package/dist/core/config.js +1 -0
- package/dist/core/constants.d.ts +14 -0
- package/dist/core/constants.js +27 -1
- package/dist/core/manager.d.ts +2 -3
- package/dist/core/manager.js +9 -24
- package/dist/core/parsers.d.ts +916 -9
- package/dist/core/parsers.js +57 -4
- package/dist/core/utils.d.ts +2 -0
- package/dist/core/utils.js +56 -0
- package/dist/test.js +11 -30
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/pnpm-workspace.yaml +2 -0
- package/dist/core/auth-manager.d.ts +0 -54
- package/dist/core/auth-manager.js +0 -159
- package/dist/core/auth-types.d.ts +0 -238
- package/dist/core/auth-types.js +0 -54
- package/dist/core/gtfs-types.d.ts +0 -198
- package/dist/core/gtfs-types.js +0 -70
- package/dist/live-polling.d.ts +0 -1
- package/dist/live-polling.js +0 -105
- package/dist/text.d.ts +0 -1
- package/dist/text.js +0 -35
|
@@ -4,17 +4,17 @@ on:
|
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
6
|
- main
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- 'package.json'
|
|
10
|
-
- 'tsconfig.json'
|
|
11
|
-
- 'pnpm-lock.yaml'
|
|
7
|
+
release:
|
|
8
|
+
types: [published]
|
|
12
9
|
workflow_dispatch:
|
|
13
10
|
|
|
14
11
|
permissions:
|
|
15
12
|
id-token: write
|
|
16
13
|
contents: read
|
|
17
14
|
|
|
15
|
+
env:
|
|
16
|
+
publish: false
|
|
17
|
+
|
|
18
18
|
jobs:
|
|
19
19
|
publish:
|
|
20
20
|
runs-on: ubuntu-latest
|
|
@@ -26,55 +26,41 @@ jobs:
|
|
|
26
26
|
- name: Set up Node.js
|
|
27
27
|
uses: actions/setup-node@v4
|
|
28
28
|
with:
|
|
29
|
-
node-version:
|
|
30
|
-
registry-url:
|
|
29
|
+
node-version: "20"
|
|
30
|
+
registry-url: "https://registry.npmjs.org"
|
|
31
31
|
always-auth: true
|
|
32
32
|
|
|
33
|
-
- name: Ensure latest npm
|
|
33
|
+
- name: Ensure latest npm (for OIDC support)
|
|
34
34
|
run: npm install -g npm@latest
|
|
35
35
|
|
|
36
|
-
- name: Install pnpm
|
|
37
|
-
uses: pnpm/action-setup@v3
|
|
38
|
-
with:
|
|
39
|
-
version: latest
|
|
40
|
-
|
|
41
|
-
- name: Cache pnpm store
|
|
42
|
-
uses: actions/cache@v3
|
|
43
|
-
with:
|
|
44
|
-
path: ~/.pnpm-store
|
|
45
|
-
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
46
|
-
restore-keys: |
|
|
47
|
-
${{ runner.os }}-pnpm-
|
|
48
|
-
|
|
49
36
|
- name: Install dependencies
|
|
50
|
-
run:
|
|
37
|
+
run: |
|
|
38
|
+
npm i -g pnpm
|
|
39
|
+
pnpm install
|
|
51
40
|
|
|
52
41
|
- name: Check if package needs publishing
|
|
53
42
|
id: check_publish
|
|
54
43
|
run: |
|
|
55
44
|
current_version=$(node -p "require('./package.json').version")
|
|
56
|
-
|
|
57
|
-
published_version=$(npm
|
|
45
|
+
npm_package_name=$(node -p "require('./package.json').name")
|
|
46
|
+
published_version=$(npm show $npm_package_name version) || echo "0.0.0"
|
|
58
47
|
|
|
59
48
|
echo "Current version: $current_version"
|
|
60
49
|
echo "Published version: $published_version"
|
|
61
50
|
|
|
62
51
|
if [ "$current_version" == "$published_version" ]; then
|
|
63
52
|
echo "No new version. Skipping publish."
|
|
64
|
-
echo "
|
|
53
|
+
echo "publish=false" >> $GITHUB_ENV
|
|
65
54
|
else
|
|
66
55
|
echo "New version available. Proceeding to publish."
|
|
67
|
-
echo "
|
|
56
|
+
echo "publish=true" >> $GITHUB_ENV
|
|
68
57
|
fi
|
|
69
58
|
|
|
70
|
-
- name: Run linting
|
|
71
|
-
if: steps.check_publish.outputs.should_publish == 'true'
|
|
72
|
-
run: pnpm run lint
|
|
73
|
-
|
|
74
59
|
- name: Build the project
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
run: |
|
|
61
|
+
pnpm run build
|
|
77
62
|
|
|
78
|
-
- name: Publish to
|
|
79
|
-
if:
|
|
80
|
-
run:
|
|
63
|
+
- name: Publish to npm using OIDC
|
|
64
|
+
if: env.publish == 'true'
|
|
65
|
+
run: |
|
|
66
|
+
npm publish --provenance
|
package/dist/auth/types.d.ts
CHANGED
|
@@ -88,8 +88,8 @@ export declare const AccountSchema: z.ZodObject<{
|
|
|
88
88
|
messages: z.ZodArray<z.ZodUnknown, "many">;
|
|
89
89
|
processes: z.ZodNullable<z.ZodUnknown>;
|
|
90
90
|
}, "strip", z.ZodTypeAny, {
|
|
91
|
-
email: string;
|
|
92
91
|
id: number;
|
|
92
|
+
email: string;
|
|
93
93
|
uid: string;
|
|
94
94
|
firstName: string;
|
|
95
95
|
lastName: string;
|
|
@@ -100,8 +100,8 @@ export declare const AccountSchema: z.ZodObject<{
|
|
|
100
100
|
messages: unknown[];
|
|
101
101
|
processes?: unknown;
|
|
102
102
|
}, {
|
|
103
|
-
email: string;
|
|
104
103
|
id: number;
|
|
104
|
+
email: string;
|
|
105
105
|
uid: string;
|
|
106
106
|
firstName: string;
|
|
107
107
|
lastName: string;
|
|
@@ -153,13 +153,8 @@ export declare const StopIncomingTripSchema: z.ZodObject<{
|
|
|
153
153
|
} | undefined;
|
|
154
154
|
}>, "many">;
|
|
155
155
|
}, "strip", z.ZodTypeAny, {
|
|
156
|
-
tripId: string;
|
|
157
|
-
routeShortName: string;
|
|
158
156
|
headsign: string;
|
|
159
|
-
expectedArrivalDateTime: string;
|
|
160
157
|
hasLiveTracking: boolean;
|
|
161
|
-
daysFromToday: number;
|
|
162
|
-
shapeId: string;
|
|
163
158
|
vehicles: {
|
|
164
159
|
id: string;
|
|
165
160
|
isForDisabledPeople: boolean | null;
|
|
@@ -169,14 +164,14 @@ export declare const StopIncomingTripSchema: z.ZodObject<{
|
|
|
169
164
|
longitude: number;
|
|
170
165
|
} | undefined;
|
|
171
166
|
}[];
|
|
172
|
-
|
|
167
|
+
shapeId: string;
|
|
168
|
+
expectedArrivalDateTime: string;
|
|
169
|
+
daysFromToday: number;
|
|
173
170
|
tripId: string;
|
|
174
171
|
routeShortName: string;
|
|
172
|
+
}, {
|
|
175
173
|
headsign: string;
|
|
176
|
-
expectedArrivalDateTime: string;
|
|
177
174
|
hasLiveTracking: boolean;
|
|
178
|
-
daysFromToday: number;
|
|
179
|
-
shapeId: string;
|
|
180
175
|
vehicles: {
|
|
181
176
|
id: string;
|
|
182
177
|
isForDisabledPeople: boolean | null;
|
|
@@ -186,6 +181,11 @@ export declare const StopIncomingTripSchema: z.ZodObject<{
|
|
|
186
181
|
longitude: number;
|
|
187
182
|
} | undefined;
|
|
188
183
|
}[];
|
|
184
|
+
shapeId: string;
|
|
185
|
+
expectedArrivalDateTime: string;
|
|
186
|
+
daysFromToday: number;
|
|
187
|
+
tripId: string;
|
|
188
|
+
routeShortName: string;
|
|
189
189
|
}>;
|
|
190
190
|
export type StopIncomingTripWithDates = Omit<StopIncomingTrip, 'expectedArrivalDateTime'> & {
|
|
191
191
|
expectedArrivalDateTime: Date;
|
|
@@ -241,13 +241,8 @@ export declare const StopIncomingTripsResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
241
241
|
} | undefined;
|
|
242
242
|
}>, "many">;
|
|
243
243
|
}, "strip", z.ZodTypeAny, {
|
|
244
|
-
tripId: string;
|
|
245
|
-
routeShortName: string;
|
|
246
244
|
headsign: string;
|
|
247
|
-
expectedArrivalDateTime: string;
|
|
248
245
|
hasLiveTracking: boolean;
|
|
249
|
-
daysFromToday: number;
|
|
250
|
-
shapeId: string;
|
|
251
246
|
vehicles: {
|
|
252
247
|
id: string;
|
|
253
248
|
isForDisabledPeople: boolean | null;
|
|
@@ -257,14 +252,14 @@ export declare const StopIncomingTripsResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
257
252
|
longitude: number;
|
|
258
253
|
} | undefined;
|
|
259
254
|
}[];
|
|
260
|
-
|
|
255
|
+
shapeId: string;
|
|
256
|
+
expectedArrivalDateTime: string;
|
|
257
|
+
daysFromToday: number;
|
|
261
258
|
tripId: string;
|
|
262
259
|
routeShortName: string;
|
|
260
|
+
}, {
|
|
263
261
|
headsign: string;
|
|
264
|
-
expectedArrivalDateTime: string;
|
|
265
262
|
hasLiveTracking: boolean;
|
|
266
|
-
daysFromToday: number;
|
|
267
|
-
shapeId: string;
|
|
268
263
|
vehicles: {
|
|
269
264
|
id: string;
|
|
270
265
|
isForDisabledPeople: boolean | null;
|
|
@@ -274,4 +269,9 @@ export declare const StopIncomingTripsResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
274
269
|
longitude: number;
|
|
275
270
|
} | undefined;
|
|
276
271
|
}[];
|
|
272
|
+
shapeId: string;
|
|
273
|
+
expectedArrivalDateTime: string;
|
|
274
|
+
daysFromToday: number;
|
|
275
|
+
tripId: string;
|
|
276
|
+
routeShortName: string;
|
|
277
277
|
}>, "many">;
|
package/dist/core/config.d.ts
CHANGED
package/dist/core/config.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.headers = void 0;
|
|
4
4
|
exports.default = {
|
|
5
5
|
baseUrl: 'https://api.zet.hr',
|
|
6
|
+
gtfsRtUrl: 'https://www.zet.hr/gtfs-rt-protobuf',
|
|
6
7
|
timetableServiceUrl: 'https://api.zet.hr/TimetableService.Api/api/gtfs',
|
|
7
8
|
newsProxyServiceUrl: 'https://api.zet.hr/NewsProxyService.Api/api/newsfeed',
|
|
8
9
|
authServiceUrl: 'https://api.zet.hr/AuthService.Api/api/auth',
|
package/dist/core/constants.d.ts
CHANGED
|
@@ -19,7 +19,21 @@ export declare enum NewsTypeEnum {
|
|
|
19
19
|
ScheduleChange = 3,
|
|
20
20
|
ServiceChange = 4
|
|
21
21
|
}
|
|
22
|
+
export declare enum ScheduleRelationshipEnum {
|
|
23
|
+
Scheduled = "SCHEDULED",
|
|
24
|
+
Added = "ADDED",
|
|
25
|
+
Unscheduled = "UNSCHEDULED",
|
|
26
|
+
Canceled = "CANCELED",
|
|
27
|
+
Replacement = "REPLACEMENT",
|
|
28
|
+
Duplicated = "DUPLICATED"
|
|
29
|
+
}
|
|
30
|
+
export declare enum IncrementalityEnum {
|
|
31
|
+
FullDataSet = "FULL_DATASET",
|
|
32
|
+
Differential = "DIFFERENTIAL"
|
|
33
|
+
}
|
|
22
34
|
export declare const routeTypeMap: Record<RouteTypeEnum, string>;
|
|
23
35
|
export declare const directionMap: Record<DirectionEnum, string>;
|
|
24
36
|
export declare const tripStatusMap: Record<TripStatusEnum, string>;
|
|
25
37
|
export declare const newsTypeMap: Record<NewsTypeEnum, string>;
|
|
38
|
+
export declare const scheduleRelationshipMap: Record<ScheduleRelationshipEnum, string>;
|
|
39
|
+
export declare const incrementalityMap: Record<IncrementalityEnum, string>;
|
package/dist/core/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.newsTypeMap = exports.tripStatusMap = exports.directionMap = exports.routeTypeMap = exports.NewsTypeEnum = exports.TripStatusEnum = exports.DirectionEnum = exports.RouteTypeEnum = void 0;
|
|
3
|
+
exports.incrementalityMap = exports.scheduleRelationshipMap = exports.newsTypeMap = exports.tripStatusMap = exports.directionMap = exports.routeTypeMap = exports.IncrementalityEnum = exports.ScheduleRelationshipEnum = exports.NewsTypeEnum = exports.TripStatusEnum = exports.DirectionEnum = exports.RouteTypeEnum = void 0;
|
|
4
4
|
var RouteTypeEnum;
|
|
5
5
|
(function (RouteTypeEnum) {
|
|
6
6
|
RouteTypeEnum[RouteTypeEnum["Tram"] = 0] = "Tram";
|
|
@@ -28,6 +28,20 @@ var NewsTypeEnum;
|
|
|
28
28
|
NewsTypeEnum[NewsTypeEnum["ScheduleChange"] = 3] = "ScheduleChange";
|
|
29
29
|
NewsTypeEnum[NewsTypeEnum["ServiceChange"] = 4] = "ServiceChange";
|
|
30
30
|
})(NewsTypeEnum || (exports.NewsTypeEnum = NewsTypeEnum = {}));
|
|
31
|
+
var ScheduleRelationshipEnum;
|
|
32
|
+
(function (ScheduleRelationshipEnum) {
|
|
33
|
+
ScheduleRelationshipEnum["Scheduled"] = "SCHEDULED";
|
|
34
|
+
ScheduleRelationshipEnum["Added"] = "ADDED";
|
|
35
|
+
ScheduleRelationshipEnum["Unscheduled"] = "UNSCHEDULED";
|
|
36
|
+
ScheduleRelationshipEnum["Canceled"] = "CANCELED";
|
|
37
|
+
ScheduleRelationshipEnum["Replacement"] = "REPLACEMENT";
|
|
38
|
+
ScheduleRelationshipEnum["Duplicated"] = "DUPLICATED";
|
|
39
|
+
})(ScheduleRelationshipEnum || (exports.ScheduleRelationshipEnum = ScheduleRelationshipEnum = {}));
|
|
40
|
+
var IncrementalityEnum;
|
|
41
|
+
(function (IncrementalityEnum) {
|
|
42
|
+
IncrementalityEnum["FullDataSet"] = "FULL_DATASET";
|
|
43
|
+
IncrementalityEnum["Differential"] = "DIFFERENTIAL";
|
|
44
|
+
})(IncrementalityEnum || (exports.IncrementalityEnum = IncrementalityEnum = {}));
|
|
31
45
|
exports.routeTypeMap = {
|
|
32
46
|
[RouteTypeEnum.Tram]: 'Tram',
|
|
33
47
|
[RouteTypeEnum.Bus]: 'Bus',
|
|
@@ -49,3 +63,15 @@ exports.newsTypeMap = {
|
|
|
49
63
|
[NewsTypeEnum.ScheduleChange]: 'Schedule Change',
|
|
50
64
|
[NewsTypeEnum.ServiceChange]: 'Service Change',
|
|
51
65
|
};
|
|
66
|
+
exports.scheduleRelationshipMap = {
|
|
67
|
+
[ScheduleRelationshipEnum.Scheduled]: 'Scheduled',
|
|
68
|
+
[ScheduleRelationshipEnum.Added]: 'Added',
|
|
69
|
+
[ScheduleRelationshipEnum.Unscheduled]: 'Unscheduled',
|
|
70
|
+
[ScheduleRelationshipEnum.Canceled]: 'Canceled',
|
|
71
|
+
[ScheduleRelationshipEnum.Replacement]: 'Replacement',
|
|
72
|
+
[ScheduleRelationshipEnum.Duplicated]: 'Duplicated',
|
|
73
|
+
};
|
|
74
|
+
exports.incrementalityMap = {
|
|
75
|
+
[IncrementalityEnum.FullDataSet]: 'Full Dataset',
|
|
76
|
+
[IncrementalityEnum.Differential]: 'Differential',
|
|
77
|
+
};
|
package/dist/core/manager.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Route, Stop, News, GetRoutesInput, GetRouteTripsInput, GetStopsInput, GetTripStopTimesInput, SearchRoutesInput, SearchStopsInput,
|
|
1
|
+
import { Route, Stop, News, GetRoutesInput, GetRouteTripsInput, GetStopsInput, GetTripStopTimesInput, SearchRoutesInput, SearchStopsInput, TripWithDates, TripStopTimeWithDates, NewsWithDates, GTFSRTVehiclePosition } from './parsers';
|
|
2
2
|
import { GetStopIncomingTripsInput, StopIncomingTripWithDates, Account } from '../auth/types';
|
|
3
3
|
import { ZetAuthManager } from '../auth/manager';
|
|
4
4
|
import { RouteTypeEnum } from './constants';
|
|
@@ -30,8 +30,7 @@ export declare class ZetManager {
|
|
|
30
30
|
private getNewsfeedInternal;
|
|
31
31
|
getNewsfeed(): Promise<NewsWithDates[]>;
|
|
32
32
|
getNewsByRoute(routeId: number): Promise<News[]>;
|
|
33
|
-
getLiveVehicles(
|
|
34
|
-
getVehicleById(vehicleId: string): Promise<Vehicle | null>;
|
|
33
|
+
getLiveVehicles(routeId?: number): Promise<GTFSRTVehiclePosition[]>;
|
|
35
34
|
refreshCache(): Promise<void>;
|
|
36
35
|
clearCache(): void;
|
|
37
36
|
private fetchAndCacheRoutes;
|
package/dist/core/manager.js
CHANGED
|
@@ -284,31 +284,16 @@ class ZetManager {
|
|
|
284
284
|
return news.filter((item) => item.lines.includes(routeId));
|
|
285
285
|
}
|
|
286
286
|
// Vehicles.
|
|
287
|
-
async getLiveVehicles(
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (options?.vehicleId && vehicle.id !== options.vehicleId)
|
|
296
|
-
continue;
|
|
297
|
-
if (vehicle.position) {
|
|
298
|
-
vehicles.push(vehicle);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
catch (error) {
|
|
304
|
-
continue;
|
|
305
|
-
}
|
|
287
|
+
async getLiveVehicles(routeId) {
|
|
288
|
+
const response = await axios_1.default.get(config_1.default.gtfsRtUrl, { headers: config_1.headers, timeout: this.timeoutMs, responseType: 'arraybuffer' }).catch((err) => err.response);
|
|
289
|
+
if (!response || response.status !== 200)
|
|
290
|
+
throw new Error(`Failed to fetch GTFS-RT feed: ${response?.statusText || 'Unknown error'}`);
|
|
291
|
+
const allVehicles = (0, utils_1.parseGtfsRtVehicles)(response.data);
|
|
292
|
+
if (routeId !== undefined) {
|
|
293
|
+
const routeIdStr = routeId.toString();
|
|
294
|
+
return allVehicles.filter((vehicle) => vehicle.trip.routeId === routeIdStr);
|
|
306
295
|
}
|
|
307
|
-
return
|
|
308
|
-
}
|
|
309
|
-
async getVehicleById(vehicleId) {
|
|
310
|
-
const vehicles = await this.getLiveVehicles({ vehicleId });
|
|
311
|
-
return vehicles[0] || null;
|
|
296
|
+
return allVehicles;
|
|
312
297
|
}
|
|
313
298
|
// Cache.
|
|
314
299
|
async refreshCache() {
|