@tmlmobilidade/types 20250325.1729.12

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,76 @@
1
+ import { type UnixTimestamp } from './common.js';
2
+ import { z } from 'zod';
3
+ export declare const VehicleEventSchema: z.ZodObject<z.objectUtil.extendShape<{
4
+ _id: z.ZodString;
5
+ created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
6
+ updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
7
+ }, {
8
+ agency_id: z.ZodString;
9
+ driver_id: z.ZodString;
10
+ event_id: z.ZodString;
11
+ extra_trip_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
12
+ latitude: z.ZodNumber;
13
+ longitude: z.ZodNumber;
14
+ odometer: z.ZodNumber;
15
+ pattern_id: z.ZodString;
16
+ received_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
17
+ stop_id: z.ZodString;
18
+ trigger_activity: z.ZodString;
19
+ trigger_door: z.ZodString;
20
+ trip_id: z.ZodString;
21
+ vehicle_id: z.ZodString;
22
+ }>, "strict", z.ZodTypeAny, {
23
+ _id: string;
24
+ agency_id: string;
25
+ pattern_id: string;
26
+ received_at: number & {
27
+ __brand: "UnixTimestamp";
28
+ } & z.BRAND<"UnixTimestamp">;
29
+ stop_id: string;
30
+ trip_id: string;
31
+ vehicle_id: string;
32
+ latitude: number;
33
+ longitude: number;
34
+ driver_id: string;
35
+ event_id: string;
36
+ odometer: number;
37
+ trigger_activity: string;
38
+ trigger_door: string;
39
+ created_at?: (number & {
40
+ __brand: "UnixTimestamp";
41
+ } & z.BRAND<"UnixTimestamp">) | null | undefined;
42
+ updated_at?: (number & {
43
+ __brand: "UnixTimestamp";
44
+ } & z.BRAND<"UnixTimestamp">) | null | undefined;
45
+ extra_trip_id?: string | null | undefined;
46
+ }, {
47
+ _id: string;
48
+ agency_id: string;
49
+ pattern_id: string;
50
+ received_at: number;
51
+ stop_id: string;
52
+ trip_id: string;
53
+ vehicle_id: string;
54
+ latitude: number;
55
+ longitude: number;
56
+ driver_id: string;
57
+ event_id: string;
58
+ odometer: number;
59
+ trigger_activity: string;
60
+ trigger_door: string;
61
+ created_at?: number | null | undefined;
62
+ updated_at?: number | null | undefined;
63
+ extra_trip_id?: string | null | undefined;
64
+ }>;
65
+ /**
66
+ * Vehicle Events are produced by the vehicle's on-board computer on a regular schedule
67
+ * or whenever a significant event occurs. These events are used to track the vehicle's
68
+ * location, speed, and status, as well as the current service being provided by the vehicle.
69
+ * These events are based on the GTFS-RT specification but extended with additional fields
70
+ * specific to TML's needs.
71
+ */
72
+ export interface VehicleEvent extends Omit<z.infer<typeof VehicleEventSchema>, 'created_at' | 'received_at' | 'updated_at'> {
73
+ created_at: UnixTimestamp;
74
+ received_at: UnixTimestamp;
75
+ updated_at: UnixTimestamp;
76
+ }
@@ -0,0 +1,20 @@
1
+ /* * */
2
+ import { DocumentSchema, validateUnixTimestamp } from './common.js';
3
+ import { z } from 'zod';
4
+ /* * */
5
+ export const VehicleEventSchema = DocumentSchema.extend({
6
+ agency_id: z.string(),
7
+ driver_id: z.string(),
8
+ event_id: z.string(),
9
+ extra_trip_id: z.string().nullish(),
10
+ latitude: z.number(),
11
+ longitude: z.number(),
12
+ odometer: z.number(),
13
+ pattern_id: z.string(),
14
+ received_at: z.number().transform(validateUnixTimestamp).brand('UnixTimestamp'),
15
+ stop_id: z.string(),
16
+ trigger_activity: z.string(),
17
+ trigger_door: z.string(),
18
+ trip_id: z.string(),
19
+ vehicle_id: z.string(),
20
+ }).strict();
@@ -0,0 +1,120 @@
1
+ import { type GeoJSON } from 'geojson';
2
+ import { z } from 'zod';
3
+ export declare const ZoneSchema: z.ZodObject<z.objectUtil.extendShape<{
4
+ _id: z.ZodString;
5
+ created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, import("./common.js").UnixTimestamp, number>, "UnixTimestamp">>>;
6
+ updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, import("./common.js").UnixTimestamp, number>, "UnixTimestamp">>>;
7
+ }, {
8
+ border_color: z.ZodString;
9
+ border_opacity: z.ZodNumber;
10
+ border_width: z.ZodNumber;
11
+ code: z.ZodString;
12
+ created_at: z.ZodDate;
13
+ fill_color: z.ZodString;
14
+ fill_opacity: z.ZodNumber;
15
+ geojson: z.ZodRecord<z.ZodString, z.ZodAny>;
16
+ is_locked: z.ZodBoolean;
17
+ name: z.ZodString;
18
+ }>, "strict", z.ZodTypeAny, {
19
+ _id: string;
20
+ created_at: Date;
21
+ code: string;
22
+ is_locked: boolean;
23
+ name: string;
24
+ border_color: string;
25
+ border_opacity: number;
26
+ border_width: number;
27
+ fill_color: string;
28
+ fill_opacity: number;
29
+ geojson: Record<string, any>;
30
+ updated_at?: (number & {
31
+ __brand: "UnixTimestamp";
32
+ } & z.BRAND<"UnixTimestamp">) | null | undefined;
33
+ }, {
34
+ _id: string;
35
+ created_at: Date;
36
+ code: string;
37
+ is_locked: boolean;
38
+ name: string;
39
+ border_color: string;
40
+ border_opacity: number;
41
+ border_width: number;
42
+ fill_color: string;
43
+ fill_opacity: number;
44
+ geojson: Record<string, any>;
45
+ updated_at?: number | null | undefined;
46
+ }>;
47
+ export declare const CreateZoneSchema: z.ZodObject<Omit<z.objectUtil.extendShape<{
48
+ _id: z.ZodString;
49
+ created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, import("./common.js").UnixTimestamp, number>, "UnixTimestamp">>>;
50
+ updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, import("./common.js").UnixTimestamp, number>, "UnixTimestamp">>>;
51
+ }, {
52
+ border_color: z.ZodString;
53
+ border_opacity: z.ZodNumber;
54
+ border_width: z.ZodNumber;
55
+ code: z.ZodString;
56
+ created_at: z.ZodDate;
57
+ fill_color: z.ZodString;
58
+ fill_opacity: z.ZodNumber;
59
+ geojson: z.ZodRecord<z.ZodString, z.ZodAny>;
60
+ is_locked: z.ZodBoolean;
61
+ name: z.ZodString;
62
+ }>, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, {
63
+ code: string;
64
+ is_locked: boolean;
65
+ name: string;
66
+ border_color: string;
67
+ border_opacity: number;
68
+ border_width: number;
69
+ fill_color: string;
70
+ fill_opacity: number;
71
+ geojson: Record<string, any>;
72
+ }, {
73
+ code: string;
74
+ is_locked: boolean;
75
+ name: string;
76
+ border_color: string;
77
+ border_opacity: number;
78
+ border_width: number;
79
+ fill_color: string;
80
+ fill_opacity: number;
81
+ geojson: Record<string, any>;
82
+ }>;
83
+ export declare const UpdateZoneSchema: z.ZodObject<{
84
+ code: z.ZodOptional<z.ZodString>;
85
+ is_locked: z.ZodOptional<z.ZodBoolean>;
86
+ name: z.ZodOptional<z.ZodString>;
87
+ border_color: z.ZodOptional<z.ZodString>;
88
+ border_opacity: z.ZodOptional<z.ZodNumber>;
89
+ border_width: z.ZodOptional<z.ZodNumber>;
90
+ fill_color: z.ZodOptional<z.ZodString>;
91
+ fill_opacity: z.ZodOptional<z.ZodNumber>;
92
+ geojson: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
93
+ }, "strict", z.ZodTypeAny, {
94
+ code?: string | undefined;
95
+ is_locked?: boolean | undefined;
96
+ name?: string | undefined;
97
+ border_color?: string | undefined;
98
+ border_opacity?: number | undefined;
99
+ border_width?: number | undefined;
100
+ fill_color?: string | undefined;
101
+ fill_opacity?: number | undefined;
102
+ geojson?: Record<string, any> | undefined;
103
+ }, {
104
+ code?: string | undefined;
105
+ is_locked?: boolean | undefined;
106
+ name?: string | undefined;
107
+ border_color?: string | undefined;
108
+ border_opacity?: number | undefined;
109
+ border_width?: number | undefined;
110
+ fill_color?: string | undefined;
111
+ fill_opacity?: number | undefined;
112
+ geojson?: Record<string, any> | undefined;
113
+ }>;
114
+ export type Zone = Omit<z.infer<typeof ZoneSchema>, 'geojson'> & {
115
+ geojson: GeoJSON;
116
+ };
117
+ export type CreateZoneDto = Omit<z.infer<typeof CreateZoneSchema>, 'geojson'> & {
118
+ geojson: GeoJSON;
119
+ };
120
+ export type UpdateZoneDto = Partial<CreateZoneDto>;
@@ -0,0 +1,16 @@
1
+ import { DocumentSchema } from './common.js';
2
+ import { z } from 'zod';
3
+ export const ZoneSchema = DocumentSchema.extend({
4
+ border_color: z.string(),
5
+ border_opacity: z.number(),
6
+ border_width: z.number(),
7
+ code: z.string(),
8
+ created_at: z.coerce.date(),
9
+ fill_color: z.string(),
10
+ fill_opacity: z.number(),
11
+ geojson: z.record(z.any()), // TODO: Validate GeoJSON
12
+ is_locked: z.boolean(),
13
+ name: z.string(),
14
+ }).strict();
15
+ export const CreateZoneSchema = ZoneSchema.omit({ _id: true, created_at: true, updated_at: true });
16
+ export const UpdateZoneSchema = CreateZoneSchema.partial();
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@tmlmobilidade/types",
3
+ "version": "20250325.1729.12",
4
+ "author": "João de Vasconcelos & Jusi Monteiro",
5
+ "license": "AGPL-3.0-or-later",
6
+ "homepage": "https://github.com/tmlmobilidade/services#readme",
7
+ "bugs": {
8
+ "url": "https://github.com/tmlmobilidade/services/issues"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/tmlmobilidade/services.git"
13
+ },
14
+ "keywords": [
15
+ "public transit",
16
+ "tml",
17
+ "transportes metropolitanos de lisboa",
18
+ "services"
19
+ ],
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "type": "module",
24
+ "module": "dist/src/index.js",
25
+ "files": [
26
+ "dist/"
27
+ ],
28
+ "types": "dist/index.d.ts",
29
+ "scripts": {
30
+ "build": "rimraf ./dist && tsc && resolve-tspaths",
31
+ "clean": "sh cleanup.sh",
32
+ "lint": "eslint && tsc --noEmit",
33
+ "lint:fix": "eslint --fix"
34
+ },
35
+ "dependencies": {
36
+ "geojson": "0.5.0",
37
+ "luxon": "3.5.0",
38
+ "mongodb": "6.15.0",
39
+ "zod": "3.24.2"
40
+ },
41
+ "devDependencies": {
42
+ "@carrismetropolitana/eslint": "20250303.2009.45",
43
+ "@tmlmobilidade/tsconfig": "*",
44
+ "@types/luxon": "3.4.2",
45
+ "@types/node": "22.13.13",
46
+ "resolve-tspaths": "0.8.23",
47
+ "rimraf": "6.0.1",
48
+ "turbo": "2.4.4",
49
+ "typescript": "5.8.2"
50
+ }
51
+ }