@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.
- package/README.md +13 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +21 -0
- package/dist/src/agency.d.ts +155 -0
- package/dist/src/agency.js +20 -0
- package/dist/src/alert.d.ts +289 -0
- package/dist/src/alert.js +81 -0
- package/dist/src/apex-t11.d.ts +152 -0
- package/dist/src/apex-t11.js +98 -0
- package/dist/src/apex-t19.d.ts +67 -0
- package/dist/src/apex-t19.js +17 -0
- package/dist/src/auth.d.ts +525 -0
- package/dist/src/auth.js +97 -0
- package/dist/src/common.d.ts +77 -0
- package/dist/src/common.js +50 -0
- package/dist/src/file.d.ts +121 -0
- package/dist/src/file.js +16 -0
- package/dist/src/hashed-shape.d.ts +186 -0
- package/dist/src/hashed-shape.js +19 -0
- package/dist/src/hashed-trip.d.ts +445 -0
- package/dist/src/hashed-trip.js +37 -0
- package/dist/src/locality.d.ts +145 -0
- package/dist/src/locality.js +20 -0
- package/dist/src/municipality.d.ts +145 -0
- package/dist/src/municipality.js +20 -0
- package/dist/src/organization.d.ts +52 -0
- package/dist/src/organization.js +8 -0
- package/dist/src/plan.d.ts +127 -0
- package/dist/src/plan.js +16 -0
- package/dist/src/ride.d.ts +498 -0
- package/dist/src/ride.js +44 -0
- package/dist/src/stop.d.ts +474 -0
- package/dist/src/stop.js +139 -0
- package/dist/src/vehicle-event.d.ts +76 -0
- package/dist/src/vehicle-event.js +20 -0
- package/dist/src/zone.d.ts +120 -0
- package/dist/src/zone.js +16 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## @tmlmobilidade/types
|
|
2
|
+
|
|
3
|
+
This package provides shared Zod validation schemas and their corresponding TypeScript types for use across projects. All types are automatically inferred from the schemas to ensure full type safety and reduce maintenance overhead.
|
|
4
|
+
|
|
5
|
+
### Purpose
|
|
6
|
+
- Ensure consistent validation rules across services
|
|
7
|
+
- Reduce duplication by centralizing schema definitions
|
|
8
|
+
- Automatically infer TypeScript types from schemas for type-safe usage
|
|
9
|
+
|
|
10
|
+
### Installation
|
|
11
|
+
```
|
|
12
|
+
npm install -D @tmlmobilidade/types
|
|
13
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from './src/common.js';
|
|
2
|
+
export * from './src/agency.js';
|
|
3
|
+
export * from './src/alert.js';
|
|
4
|
+
export * from './src/apex-t11.js';
|
|
5
|
+
export * from './src/apex-t19.js';
|
|
6
|
+
export * from './src/auth.js';
|
|
7
|
+
export * from './src/file.js';
|
|
8
|
+
export * from './src/hashed-shape.js';
|
|
9
|
+
export * from './src/hashed-trip.js';
|
|
10
|
+
export * from './src/locality.js';
|
|
11
|
+
export * from './src/municipality.js';
|
|
12
|
+
export * from './src/organization.js';
|
|
13
|
+
export * from './src/plan.js';
|
|
14
|
+
export * from './src/plan.js';
|
|
15
|
+
export * from './src/ride.js';
|
|
16
|
+
export * from './src/stop.js';
|
|
17
|
+
export * from './src/vehicle-event.js';
|
|
18
|
+
export * from './src/zone.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* eslint-disable perfectionist/sort-exports */
|
|
2
|
+
/* * */
|
|
3
|
+
export * from './src/common.js'; // This is the first export because it is used in files bellow
|
|
4
|
+
/* * */
|
|
5
|
+
export * from './src/agency.js';
|
|
6
|
+
export * from './src/alert.js';
|
|
7
|
+
export * from './src/apex-t11.js';
|
|
8
|
+
export * from './src/apex-t19.js';
|
|
9
|
+
export * from './src/auth.js';
|
|
10
|
+
export * from './src/file.js';
|
|
11
|
+
export * from './src/hashed-shape.js';
|
|
12
|
+
export * from './src/hashed-trip.js';
|
|
13
|
+
export * from './src/locality.js';
|
|
14
|
+
export * from './src/municipality.js';
|
|
15
|
+
export * from './src/organization.js';
|
|
16
|
+
export * from './src/plan.js';
|
|
17
|
+
export * from './src/plan.js';
|
|
18
|
+
export * from './src/ride.js';
|
|
19
|
+
export * from './src/stop.js';
|
|
20
|
+
export * from './src/vehicle-event.js';
|
|
21
|
+
export * from './src/zone.js';
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { type OperationalDate, type UnixTimestamp } from './common.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const AgencySchema: 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
|
+
code: z.ZodString;
|
|
9
|
+
email: z.ZodString;
|
|
10
|
+
fare_url: z.ZodString;
|
|
11
|
+
is_locked: z.ZodBoolean;
|
|
12
|
+
lang: z.ZodString;
|
|
13
|
+
name: z.ZodString;
|
|
14
|
+
operation_start_date: z.ZodBranded<z.ZodEffects<z.ZodString, OperationalDate, string>, "OperationalDate">;
|
|
15
|
+
phone: z.ZodString;
|
|
16
|
+
price_per_km: z.ZodNumber;
|
|
17
|
+
timezone: z.ZodString;
|
|
18
|
+
total_vkm_per_year: z.ZodNumber;
|
|
19
|
+
url: z.ZodString;
|
|
20
|
+
}>, "strict", z.ZodTypeAny, {
|
|
21
|
+
_id: string;
|
|
22
|
+
code: string;
|
|
23
|
+
email: string;
|
|
24
|
+
fare_url: string;
|
|
25
|
+
is_locked: boolean;
|
|
26
|
+
lang: string;
|
|
27
|
+
name: string;
|
|
28
|
+
operation_start_date: string & {
|
|
29
|
+
__brand: "OperationalDate";
|
|
30
|
+
} & z.BRAND<"OperationalDate">;
|
|
31
|
+
phone: string;
|
|
32
|
+
price_per_km: number;
|
|
33
|
+
timezone: string;
|
|
34
|
+
total_vkm_per_year: number;
|
|
35
|
+
url: string;
|
|
36
|
+
created_at?: (number & {
|
|
37
|
+
__brand: "UnixTimestamp";
|
|
38
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
39
|
+
updated_at?: (number & {
|
|
40
|
+
__brand: "UnixTimestamp";
|
|
41
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
_id: string;
|
|
44
|
+
code: string;
|
|
45
|
+
email: string;
|
|
46
|
+
fare_url: string;
|
|
47
|
+
is_locked: boolean;
|
|
48
|
+
lang: string;
|
|
49
|
+
name: string;
|
|
50
|
+
operation_start_date: string;
|
|
51
|
+
phone: string;
|
|
52
|
+
price_per_km: number;
|
|
53
|
+
timezone: string;
|
|
54
|
+
total_vkm_per_year: number;
|
|
55
|
+
url: string;
|
|
56
|
+
created_at?: number | null | undefined;
|
|
57
|
+
updated_at?: number | null | undefined;
|
|
58
|
+
}>;
|
|
59
|
+
export declare const CreateAgencySchema: z.ZodObject<Omit<z.objectUtil.extendShape<{
|
|
60
|
+
_id: z.ZodString;
|
|
61
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
62
|
+
updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
63
|
+
}, {
|
|
64
|
+
code: z.ZodString;
|
|
65
|
+
email: z.ZodString;
|
|
66
|
+
fare_url: z.ZodString;
|
|
67
|
+
is_locked: z.ZodBoolean;
|
|
68
|
+
lang: z.ZodString;
|
|
69
|
+
name: z.ZodString;
|
|
70
|
+
operation_start_date: z.ZodBranded<z.ZodEffects<z.ZodString, OperationalDate, string>, "OperationalDate">;
|
|
71
|
+
phone: z.ZodString;
|
|
72
|
+
price_per_km: z.ZodNumber;
|
|
73
|
+
timezone: z.ZodString;
|
|
74
|
+
total_vkm_per_year: z.ZodNumber;
|
|
75
|
+
url: z.ZodString;
|
|
76
|
+
}>, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, {
|
|
77
|
+
code: string;
|
|
78
|
+
email: string;
|
|
79
|
+
fare_url: string;
|
|
80
|
+
is_locked: boolean;
|
|
81
|
+
lang: string;
|
|
82
|
+
name: string;
|
|
83
|
+
operation_start_date: string & {
|
|
84
|
+
__brand: "OperationalDate";
|
|
85
|
+
} & z.BRAND<"OperationalDate">;
|
|
86
|
+
phone: string;
|
|
87
|
+
price_per_km: number;
|
|
88
|
+
timezone: string;
|
|
89
|
+
total_vkm_per_year: number;
|
|
90
|
+
url: string;
|
|
91
|
+
}, {
|
|
92
|
+
code: string;
|
|
93
|
+
email: string;
|
|
94
|
+
fare_url: string;
|
|
95
|
+
is_locked: boolean;
|
|
96
|
+
lang: string;
|
|
97
|
+
name: string;
|
|
98
|
+
operation_start_date: string;
|
|
99
|
+
phone: string;
|
|
100
|
+
price_per_km: number;
|
|
101
|
+
timezone: string;
|
|
102
|
+
total_vkm_per_year: number;
|
|
103
|
+
url: string;
|
|
104
|
+
}>;
|
|
105
|
+
export declare const UpdateAgencySchema: z.ZodObject<{
|
|
106
|
+
code: z.ZodOptional<z.ZodString>;
|
|
107
|
+
email: z.ZodOptional<z.ZodString>;
|
|
108
|
+
fare_url: z.ZodOptional<z.ZodString>;
|
|
109
|
+
is_locked: z.ZodOptional<z.ZodBoolean>;
|
|
110
|
+
lang: z.ZodOptional<z.ZodString>;
|
|
111
|
+
name: z.ZodOptional<z.ZodString>;
|
|
112
|
+
operation_start_date: z.ZodOptional<z.ZodBranded<z.ZodEffects<z.ZodString, OperationalDate, string>, "OperationalDate">>;
|
|
113
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
114
|
+
price_per_km: z.ZodOptional<z.ZodNumber>;
|
|
115
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
116
|
+
total_vkm_per_year: z.ZodOptional<z.ZodNumber>;
|
|
117
|
+
url: z.ZodOptional<z.ZodString>;
|
|
118
|
+
}, "strict", z.ZodTypeAny, {
|
|
119
|
+
code?: string | undefined;
|
|
120
|
+
email?: string | undefined;
|
|
121
|
+
fare_url?: string | undefined;
|
|
122
|
+
is_locked?: boolean | undefined;
|
|
123
|
+
lang?: string | undefined;
|
|
124
|
+
name?: string | undefined;
|
|
125
|
+
operation_start_date?: (string & {
|
|
126
|
+
__brand: "OperationalDate";
|
|
127
|
+
} & z.BRAND<"OperationalDate">) | undefined;
|
|
128
|
+
phone?: string | undefined;
|
|
129
|
+
price_per_km?: number | undefined;
|
|
130
|
+
timezone?: string | undefined;
|
|
131
|
+
total_vkm_per_year?: number | undefined;
|
|
132
|
+
url?: string | undefined;
|
|
133
|
+
}, {
|
|
134
|
+
code?: string | undefined;
|
|
135
|
+
email?: string | undefined;
|
|
136
|
+
fare_url?: string | undefined;
|
|
137
|
+
is_locked?: boolean | undefined;
|
|
138
|
+
lang?: string | undefined;
|
|
139
|
+
name?: string | undefined;
|
|
140
|
+
operation_start_date?: string | undefined;
|
|
141
|
+
phone?: string | undefined;
|
|
142
|
+
price_per_km?: number | undefined;
|
|
143
|
+
timezone?: string | undefined;
|
|
144
|
+
total_vkm_per_year?: number | undefined;
|
|
145
|
+
url?: string | undefined;
|
|
146
|
+
}>;
|
|
147
|
+
export interface Agency extends Omit<z.infer<typeof AgencySchema>, 'created_at' | 'operation_start_date' | 'updated_at'> {
|
|
148
|
+
created_at: UnixTimestamp;
|
|
149
|
+
operation_start_date: OperationalDate;
|
|
150
|
+
updated_at: UnixTimestamp;
|
|
151
|
+
}
|
|
152
|
+
export interface CreateAgencyDto extends Omit<z.infer<typeof CreateAgencySchema>, 'operation_start_date'> {
|
|
153
|
+
operation_start_date: OperationalDate;
|
|
154
|
+
}
|
|
155
|
+
export type UpdateAgencyDto = Partial<CreateAgencyDto>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* * */
|
|
2
|
+
import { DocumentSchema, validateOperationalDate } from './common.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
/* * */
|
|
5
|
+
export const AgencySchema = DocumentSchema.extend({
|
|
6
|
+
code: z.string(),
|
|
7
|
+
email: z.string().email(),
|
|
8
|
+
fare_url: z.string().url(),
|
|
9
|
+
is_locked: z.boolean(),
|
|
10
|
+
lang: z.string(),
|
|
11
|
+
name: z.string(),
|
|
12
|
+
operation_start_date: z.string().transform(validateOperationalDate).brand('OperationalDate'),
|
|
13
|
+
phone: z.string(),
|
|
14
|
+
price_per_km: z.number(),
|
|
15
|
+
timezone: z.string(),
|
|
16
|
+
total_vkm_per_year: z.number(),
|
|
17
|
+
url: z.string().url(),
|
|
18
|
+
}).strict();
|
|
19
|
+
export const CreateAgencySchema = AgencySchema.omit({ _id: true, created_at: true, updated_at: true });
|
|
20
|
+
export const UpdateAgencySchema = CreateAgencySchema.partial();
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { type UnixTimestamp } from './common.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const causeSchema: z.ZodEnum<["ACCIDENT", "CONSTRUCTION", "DEMONSTRATION", "HOLIDAY", "MAINTENANCE", "MEDICAL_EMERGENCY", "OTHER_CAUSE", "POLICE_ACTIVITY", "STRIKE", "TECHNICAL_PROBLEM", "UNKNOWN_CAUSE", "WEATHER"]>;
|
|
4
|
+
export declare const effectSchema: z.ZodEnum<["ACCESSIBILITY_ISSUE", "ADDITIONAL_SERVICE", "DETOUR", "MODIFIED_SERVICE", "NO_EFFECT", "NO_SERVICE", "OTHER_EFFECT", "REDUCED_SERVICE", "SIGNIFICANT_DELAYS", "STOP_MOVED", "UNKNOWN_EFFECT"]>;
|
|
5
|
+
export declare const publishStatusSchema: z.ZodEnum<["PUBLISHED", "ARCHIVED", "DRAFT"]>;
|
|
6
|
+
export declare const alertTypeSchema: z.ZodEnum<["PLANNED", "REALTIME"]>;
|
|
7
|
+
export declare const referenceTypeSchema: z.ZodEnum<["LINE", "STOP", "AGENCY", "TRIP"]>;
|
|
8
|
+
export declare const AlertSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
9
|
+
_id: z.ZodString;
|
|
10
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
11
|
+
updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
12
|
+
}, {
|
|
13
|
+
active_period_end_date: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
14
|
+
active_period_start_date: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
|
|
15
|
+
cause: z.ZodEnum<["ACCIDENT", "CONSTRUCTION", "DEMONSTRATION", "HOLIDAY", "MAINTENANCE", "MEDICAL_EMERGENCY", "OTHER_CAUSE", "POLICE_ACTIVITY", "STRIKE", "TECHNICAL_PROBLEM", "UNKNOWN_CAUSE", "WEATHER"]>;
|
|
16
|
+
created_by: z.ZodString;
|
|
17
|
+
description: z.ZodString;
|
|
18
|
+
effect: z.ZodEnum<["ACCESSIBILITY_ISSUE", "ADDITIONAL_SERVICE", "DETOUR", "MODIFIED_SERVICE", "NO_EFFECT", "NO_SERVICE", "OTHER_EFFECT", "REDUCED_SERVICE", "SIGNIFICANT_DELAYS", "STOP_MOVED", "UNKNOWN_EFFECT"]>;
|
|
19
|
+
file_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
20
|
+
info_url: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
|
|
21
|
+
modified_by: z.ZodString;
|
|
22
|
+
municipality_ids: z.ZodArray<z.ZodString, "many">;
|
|
23
|
+
publish_end_date: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
24
|
+
publish_start_date: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
|
|
25
|
+
publish_status: z.ZodEnum<["PUBLISHED", "ARCHIVED", "DRAFT"]>;
|
|
26
|
+
reference_type: z.ZodEnum<["LINE", "STOP", "AGENCY", "TRIP"]>;
|
|
27
|
+
references: z.ZodArray<z.ZodObject<{
|
|
28
|
+
child_ids: z.ZodArray<z.ZodString, "many">;
|
|
29
|
+
parent_id: z.ZodString;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
child_ids: string[];
|
|
32
|
+
parent_id: string;
|
|
33
|
+
}, {
|
|
34
|
+
child_ids: string[];
|
|
35
|
+
parent_id: string;
|
|
36
|
+
}>, "many">;
|
|
37
|
+
title: z.ZodString;
|
|
38
|
+
type: z.ZodEnum<["PLANNED", "REALTIME"]>;
|
|
39
|
+
}>, "strict", z.ZodTypeAny, {
|
|
40
|
+
_id: string;
|
|
41
|
+
type: "PLANNED" | "REALTIME";
|
|
42
|
+
active_period_start_date: number & {
|
|
43
|
+
__brand: "UnixTimestamp";
|
|
44
|
+
} & z.BRAND<"UnixTimestamp">;
|
|
45
|
+
cause: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "HOLIDAY" | "MAINTENANCE" | "MEDICAL_EMERGENCY" | "OTHER_CAUSE" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_PROBLEM" | "UNKNOWN_CAUSE" | "WEATHER";
|
|
46
|
+
created_by: string;
|
|
47
|
+
description: string;
|
|
48
|
+
effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT";
|
|
49
|
+
modified_by: string;
|
|
50
|
+
municipality_ids: string[];
|
|
51
|
+
publish_start_date: number & {
|
|
52
|
+
__brand: "UnixTimestamp";
|
|
53
|
+
} & z.BRAND<"UnixTimestamp">;
|
|
54
|
+
publish_status: "PUBLISHED" | "ARCHIVED" | "DRAFT";
|
|
55
|
+
reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP";
|
|
56
|
+
references: {
|
|
57
|
+
child_ids: string[];
|
|
58
|
+
parent_id: string;
|
|
59
|
+
}[];
|
|
60
|
+
title: string;
|
|
61
|
+
created_at?: (number & {
|
|
62
|
+
__brand: "UnixTimestamp";
|
|
63
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
64
|
+
updated_at?: (number & {
|
|
65
|
+
__brand: "UnixTimestamp";
|
|
66
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
67
|
+
active_period_end_date?: (number & {
|
|
68
|
+
__brand: "UnixTimestamp";
|
|
69
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
70
|
+
file_id?: string | null | undefined;
|
|
71
|
+
info_url?: string | undefined;
|
|
72
|
+
publish_end_date?: (number & {
|
|
73
|
+
__brand: "UnixTimestamp";
|
|
74
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
_id: string;
|
|
77
|
+
type: "PLANNED" | "REALTIME";
|
|
78
|
+
active_period_start_date: number;
|
|
79
|
+
cause: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "HOLIDAY" | "MAINTENANCE" | "MEDICAL_EMERGENCY" | "OTHER_CAUSE" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_PROBLEM" | "UNKNOWN_CAUSE" | "WEATHER";
|
|
80
|
+
created_by: string;
|
|
81
|
+
description: string;
|
|
82
|
+
effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT";
|
|
83
|
+
modified_by: string;
|
|
84
|
+
municipality_ids: string[];
|
|
85
|
+
publish_start_date: number;
|
|
86
|
+
publish_status: "PUBLISHED" | "ARCHIVED" | "DRAFT";
|
|
87
|
+
reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP";
|
|
88
|
+
references: {
|
|
89
|
+
child_ids: string[];
|
|
90
|
+
parent_id: string;
|
|
91
|
+
}[];
|
|
92
|
+
title: string;
|
|
93
|
+
created_at?: number | null | undefined;
|
|
94
|
+
updated_at?: number | null | undefined;
|
|
95
|
+
active_period_end_date?: number | null | undefined;
|
|
96
|
+
file_id?: string | null | undefined;
|
|
97
|
+
info_url?: string | undefined;
|
|
98
|
+
publish_end_date?: number | null | undefined;
|
|
99
|
+
}>;
|
|
100
|
+
export declare const CreateAlertSchema: z.ZodObject<Omit<z.objectUtil.extendShape<{
|
|
101
|
+
_id: z.ZodString;
|
|
102
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
103
|
+
updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
104
|
+
}, {
|
|
105
|
+
active_period_end_date: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
106
|
+
active_period_start_date: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
|
|
107
|
+
cause: z.ZodEnum<["ACCIDENT", "CONSTRUCTION", "DEMONSTRATION", "HOLIDAY", "MAINTENANCE", "MEDICAL_EMERGENCY", "OTHER_CAUSE", "POLICE_ACTIVITY", "STRIKE", "TECHNICAL_PROBLEM", "UNKNOWN_CAUSE", "WEATHER"]>;
|
|
108
|
+
created_by: z.ZodString;
|
|
109
|
+
description: z.ZodString;
|
|
110
|
+
effect: z.ZodEnum<["ACCESSIBILITY_ISSUE", "ADDITIONAL_SERVICE", "DETOUR", "MODIFIED_SERVICE", "NO_EFFECT", "NO_SERVICE", "OTHER_EFFECT", "REDUCED_SERVICE", "SIGNIFICANT_DELAYS", "STOP_MOVED", "UNKNOWN_EFFECT"]>;
|
|
111
|
+
file_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
112
|
+
info_url: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
|
|
113
|
+
modified_by: z.ZodString;
|
|
114
|
+
municipality_ids: z.ZodArray<z.ZodString, "many">;
|
|
115
|
+
publish_end_date: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
116
|
+
publish_start_date: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
|
|
117
|
+
publish_status: z.ZodEnum<["PUBLISHED", "ARCHIVED", "DRAFT"]>;
|
|
118
|
+
reference_type: z.ZodEnum<["LINE", "STOP", "AGENCY", "TRIP"]>;
|
|
119
|
+
references: z.ZodArray<z.ZodObject<{
|
|
120
|
+
child_ids: z.ZodArray<z.ZodString, "many">;
|
|
121
|
+
parent_id: z.ZodString;
|
|
122
|
+
}, "strip", z.ZodTypeAny, {
|
|
123
|
+
child_ids: string[];
|
|
124
|
+
parent_id: string;
|
|
125
|
+
}, {
|
|
126
|
+
child_ids: string[];
|
|
127
|
+
parent_id: string;
|
|
128
|
+
}>, "many">;
|
|
129
|
+
title: z.ZodString;
|
|
130
|
+
type: z.ZodEnum<["PLANNED", "REALTIME"]>;
|
|
131
|
+
}>, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, {
|
|
132
|
+
type: "PLANNED" | "REALTIME";
|
|
133
|
+
active_period_start_date: number & {
|
|
134
|
+
__brand: "UnixTimestamp";
|
|
135
|
+
} & z.BRAND<"UnixTimestamp">;
|
|
136
|
+
cause: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "HOLIDAY" | "MAINTENANCE" | "MEDICAL_EMERGENCY" | "OTHER_CAUSE" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_PROBLEM" | "UNKNOWN_CAUSE" | "WEATHER";
|
|
137
|
+
created_by: string;
|
|
138
|
+
description: string;
|
|
139
|
+
effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT";
|
|
140
|
+
modified_by: string;
|
|
141
|
+
municipality_ids: string[];
|
|
142
|
+
publish_start_date: number & {
|
|
143
|
+
__brand: "UnixTimestamp";
|
|
144
|
+
} & z.BRAND<"UnixTimestamp">;
|
|
145
|
+
publish_status: "PUBLISHED" | "ARCHIVED" | "DRAFT";
|
|
146
|
+
reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP";
|
|
147
|
+
references: {
|
|
148
|
+
child_ids: string[];
|
|
149
|
+
parent_id: string;
|
|
150
|
+
}[];
|
|
151
|
+
title: string;
|
|
152
|
+
active_period_end_date?: (number & {
|
|
153
|
+
__brand: "UnixTimestamp";
|
|
154
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
155
|
+
file_id?: string | null | undefined;
|
|
156
|
+
info_url?: string | undefined;
|
|
157
|
+
publish_end_date?: (number & {
|
|
158
|
+
__brand: "UnixTimestamp";
|
|
159
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
160
|
+
}, {
|
|
161
|
+
type: "PLANNED" | "REALTIME";
|
|
162
|
+
active_period_start_date: number;
|
|
163
|
+
cause: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "HOLIDAY" | "MAINTENANCE" | "MEDICAL_EMERGENCY" | "OTHER_CAUSE" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_PROBLEM" | "UNKNOWN_CAUSE" | "WEATHER";
|
|
164
|
+
created_by: string;
|
|
165
|
+
description: string;
|
|
166
|
+
effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT";
|
|
167
|
+
modified_by: string;
|
|
168
|
+
municipality_ids: string[];
|
|
169
|
+
publish_start_date: number;
|
|
170
|
+
publish_status: "PUBLISHED" | "ARCHIVED" | "DRAFT";
|
|
171
|
+
reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP";
|
|
172
|
+
references: {
|
|
173
|
+
child_ids: string[];
|
|
174
|
+
parent_id: string;
|
|
175
|
+
}[];
|
|
176
|
+
title: string;
|
|
177
|
+
active_period_end_date?: number | null | undefined;
|
|
178
|
+
file_id?: string | null | undefined;
|
|
179
|
+
info_url?: string | undefined;
|
|
180
|
+
publish_end_date?: number | null | undefined;
|
|
181
|
+
}>;
|
|
182
|
+
export declare const UpdateAlertSchema: z.ZodObject<{
|
|
183
|
+
type: z.ZodOptional<z.ZodEnum<["PLANNED", "REALTIME"]>>;
|
|
184
|
+
active_period_end_date: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>>;
|
|
185
|
+
active_period_start_date: z.ZodOptional<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>;
|
|
186
|
+
cause: z.ZodOptional<z.ZodEnum<["ACCIDENT", "CONSTRUCTION", "DEMONSTRATION", "HOLIDAY", "MAINTENANCE", "MEDICAL_EMERGENCY", "OTHER_CAUSE", "POLICE_ACTIVITY", "STRIKE", "TECHNICAL_PROBLEM", "UNKNOWN_CAUSE", "WEATHER"]>>;
|
|
187
|
+
created_by: z.ZodOptional<z.ZodString>;
|
|
188
|
+
description: z.ZodOptional<z.ZodString>;
|
|
189
|
+
effect: z.ZodOptional<z.ZodEnum<["ACCESSIBILITY_ISSUE", "ADDITIONAL_SERVICE", "DETOUR", "MODIFIED_SERVICE", "NO_EFFECT", "NO_SERVICE", "OTHER_EFFECT", "REDUCED_SERVICE", "SIGNIFICANT_DELAYS", "STOP_MOVED", "UNKNOWN_EFFECT"]>>;
|
|
190
|
+
file_id: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
191
|
+
info_url: z.ZodOptional<z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>>;
|
|
192
|
+
modified_by: z.ZodOptional<z.ZodString>;
|
|
193
|
+
municipality_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
194
|
+
publish_end_date: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>>;
|
|
195
|
+
publish_start_date: z.ZodOptional<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>;
|
|
196
|
+
publish_status: z.ZodOptional<z.ZodEnum<["PUBLISHED", "ARCHIVED", "DRAFT"]>>;
|
|
197
|
+
reference_type: z.ZodOptional<z.ZodEnum<["LINE", "STOP", "AGENCY", "TRIP"]>>;
|
|
198
|
+
references: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
199
|
+
child_ids: z.ZodArray<z.ZodString, "many">;
|
|
200
|
+
parent_id: z.ZodString;
|
|
201
|
+
}, "strip", z.ZodTypeAny, {
|
|
202
|
+
child_ids: string[];
|
|
203
|
+
parent_id: string;
|
|
204
|
+
}, {
|
|
205
|
+
child_ids: string[];
|
|
206
|
+
parent_id: string;
|
|
207
|
+
}>, "many">>;
|
|
208
|
+
title: z.ZodOptional<z.ZodString>;
|
|
209
|
+
}, "strict", z.ZodTypeAny, {
|
|
210
|
+
type?: "PLANNED" | "REALTIME" | undefined;
|
|
211
|
+
active_period_end_date?: (number & {
|
|
212
|
+
__brand: "UnixTimestamp";
|
|
213
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
214
|
+
active_period_start_date?: (number & {
|
|
215
|
+
__brand: "UnixTimestamp";
|
|
216
|
+
} & z.BRAND<"UnixTimestamp">) | undefined;
|
|
217
|
+
cause?: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "HOLIDAY" | "MAINTENANCE" | "MEDICAL_EMERGENCY" | "OTHER_CAUSE" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_PROBLEM" | "UNKNOWN_CAUSE" | "WEATHER" | undefined;
|
|
218
|
+
created_by?: string | undefined;
|
|
219
|
+
description?: string | undefined;
|
|
220
|
+
effect?: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT" | undefined;
|
|
221
|
+
file_id?: string | null | undefined;
|
|
222
|
+
info_url?: string | undefined;
|
|
223
|
+
modified_by?: string | undefined;
|
|
224
|
+
municipality_ids?: string[] | undefined;
|
|
225
|
+
publish_end_date?: (number & {
|
|
226
|
+
__brand: "UnixTimestamp";
|
|
227
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
228
|
+
publish_start_date?: (number & {
|
|
229
|
+
__brand: "UnixTimestamp";
|
|
230
|
+
} & z.BRAND<"UnixTimestamp">) | undefined;
|
|
231
|
+
publish_status?: "PUBLISHED" | "ARCHIVED" | "DRAFT" | undefined;
|
|
232
|
+
reference_type?: "LINE" | "STOP" | "AGENCY" | "TRIP" | undefined;
|
|
233
|
+
references?: {
|
|
234
|
+
child_ids: string[];
|
|
235
|
+
parent_id: string;
|
|
236
|
+
}[] | undefined;
|
|
237
|
+
title?: string | undefined;
|
|
238
|
+
}, {
|
|
239
|
+
type?: "PLANNED" | "REALTIME" | undefined;
|
|
240
|
+
active_period_end_date?: number | null | undefined;
|
|
241
|
+
active_period_start_date?: number | undefined;
|
|
242
|
+
cause?: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "HOLIDAY" | "MAINTENANCE" | "MEDICAL_EMERGENCY" | "OTHER_CAUSE" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_PROBLEM" | "UNKNOWN_CAUSE" | "WEATHER" | undefined;
|
|
243
|
+
created_by?: string | undefined;
|
|
244
|
+
description?: string | undefined;
|
|
245
|
+
effect?: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT" | undefined;
|
|
246
|
+
file_id?: string | null | undefined;
|
|
247
|
+
info_url?: string | undefined;
|
|
248
|
+
modified_by?: string | undefined;
|
|
249
|
+
municipality_ids?: string[] | undefined;
|
|
250
|
+
publish_end_date?: number | null | undefined;
|
|
251
|
+
publish_start_date?: number | undefined;
|
|
252
|
+
publish_status?: "PUBLISHED" | "ARCHIVED" | "DRAFT" | undefined;
|
|
253
|
+
reference_type?: "LINE" | "STOP" | "AGENCY" | "TRIP" | undefined;
|
|
254
|
+
references?: {
|
|
255
|
+
child_ids: string[];
|
|
256
|
+
parent_id: string;
|
|
257
|
+
}[] | undefined;
|
|
258
|
+
title?: string | undefined;
|
|
259
|
+
}>;
|
|
260
|
+
export type Cause = z.infer<typeof causeSchema>;
|
|
261
|
+
export type Effect = z.infer<typeof effectSchema>;
|
|
262
|
+
export type PublishStatus = z.infer<typeof publishStatusSchema>;
|
|
263
|
+
export type AlertType = z.infer<typeof alertTypeSchema>;
|
|
264
|
+
export type ReferenceType = z.infer<typeof referenceTypeSchema>;
|
|
265
|
+
export interface Alert extends Omit<z.infer<typeof AlertSchema>, 'active_period_end_date' | 'active_period_start_date' | 'cause' | 'created_at' | 'effect' | 'publish_end_date' | 'publish_start_date' | 'publish_status' | 'reference_type' | 'type' | 'updated_at'> {
|
|
266
|
+
active_period_end_date: null | undefined | UnixTimestamp;
|
|
267
|
+
active_period_start_date: UnixTimestamp;
|
|
268
|
+
cause: Cause;
|
|
269
|
+
created_at: UnixTimestamp;
|
|
270
|
+
effect: Effect;
|
|
271
|
+
publish_end_date: null | undefined | UnixTimestamp;
|
|
272
|
+
publish_start_date: UnixTimestamp;
|
|
273
|
+
publish_status: PublishStatus;
|
|
274
|
+
reference_type: ReferenceType;
|
|
275
|
+
type: AlertType;
|
|
276
|
+
updated_at: UnixTimestamp;
|
|
277
|
+
}
|
|
278
|
+
export interface CreateAlertDto extends Omit<z.infer<typeof CreateAlertSchema>, 'active_period_end_date' | 'active_period_start_date' | 'cause' | 'effect' | 'publish_end_date' | 'publish_start_date' | 'publish_status' | 'reference_type' | 'type'> {
|
|
279
|
+
active_period_end_date: null | undefined | UnixTimestamp;
|
|
280
|
+
active_period_start_date: UnixTimestamp;
|
|
281
|
+
cause: Cause;
|
|
282
|
+
effect: Effect;
|
|
283
|
+
publish_end_date: null | undefined | UnixTimestamp;
|
|
284
|
+
publish_start_date: UnixTimestamp;
|
|
285
|
+
publish_status: PublishStatus;
|
|
286
|
+
reference_type: ReferenceType;
|
|
287
|
+
type: AlertType;
|
|
288
|
+
}
|
|
289
|
+
export type UpdateAlertDto = Partial<Omit<CreateAlertDto, 'created_by'>>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* * */
|
|
2
|
+
import { DocumentSchema, validateUnixTimestamp } from './common.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
/* * */
|
|
5
|
+
// Define constants for enum values for better maintainability
|
|
6
|
+
const CAUSE_VALUES = [
|
|
7
|
+
'ACCIDENT',
|
|
8
|
+
'CONSTRUCTION',
|
|
9
|
+
'DEMONSTRATION',
|
|
10
|
+
'HOLIDAY',
|
|
11
|
+
'MAINTENANCE',
|
|
12
|
+
'MEDICAL_EMERGENCY',
|
|
13
|
+
'OTHER_CAUSE',
|
|
14
|
+
'POLICE_ACTIVITY',
|
|
15
|
+
'STRIKE',
|
|
16
|
+
'TECHNICAL_PROBLEM',
|
|
17
|
+
'UNKNOWN_CAUSE',
|
|
18
|
+
'WEATHER',
|
|
19
|
+
];
|
|
20
|
+
const EFFECT_VALUES = [
|
|
21
|
+
'ACCESSIBILITY_ISSUE',
|
|
22
|
+
'ADDITIONAL_SERVICE',
|
|
23
|
+
'DETOUR',
|
|
24
|
+
'MODIFIED_SERVICE',
|
|
25
|
+
'NO_EFFECT',
|
|
26
|
+
'NO_SERVICE',
|
|
27
|
+
'OTHER_EFFECT',
|
|
28
|
+
'REDUCED_SERVICE',
|
|
29
|
+
'SIGNIFICANT_DELAYS',
|
|
30
|
+
'STOP_MOVED',
|
|
31
|
+
'UNKNOWN_EFFECT',
|
|
32
|
+
];
|
|
33
|
+
const PUBLISH_STATUS_VALUES = [
|
|
34
|
+
'PUBLISHED',
|
|
35
|
+
'ARCHIVED',
|
|
36
|
+
'DRAFT',
|
|
37
|
+
];
|
|
38
|
+
const ALERT_TYPE_VALUES = [
|
|
39
|
+
'PLANNED',
|
|
40
|
+
'REALTIME',
|
|
41
|
+
];
|
|
42
|
+
const REFERENCE_TYPE_VALUES = [
|
|
43
|
+
'LINE',
|
|
44
|
+
'STOP',
|
|
45
|
+
'AGENCY',
|
|
46
|
+
'TRIP',
|
|
47
|
+
];
|
|
48
|
+
// Define schemas using constants
|
|
49
|
+
export const causeSchema = z.enum(CAUSE_VALUES);
|
|
50
|
+
export const effectSchema = z.enum(EFFECT_VALUES);
|
|
51
|
+
export const publishStatusSchema = z.enum(PUBLISH_STATUS_VALUES);
|
|
52
|
+
export const alertTypeSchema = z.enum(ALERT_TYPE_VALUES);
|
|
53
|
+
export const referenceTypeSchema = z.enum(REFERENCE_TYPE_VALUES);
|
|
54
|
+
// Base schema for alerts with common validation rules
|
|
55
|
+
export const AlertSchema = DocumentSchema.extend({
|
|
56
|
+
active_period_end_date: z.number().transform(validateUnixTimestamp).brand('UnixTimestamp').nullish(),
|
|
57
|
+
active_period_start_date: z.number().transform(validateUnixTimestamp).brand('UnixTimestamp'),
|
|
58
|
+
cause: causeSchema,
|
|
59
|
+
created_by: z.string().min(1),
|
|
60
|
+
description: z.string(),
|
|
61
|
+
effect: effectSchema,
|
|
62
|
+
file_id: z.string().nullish(),
|
|
63
|
+
info_url: z.string().url().optional().or(z.literal('')),
|
|
64
|
+
modified_by: z.string().min(1),
|
|
65
|
+
municipality_ids: z.array(z.string().min(1)),
|
|
66
|
+
publish_end_date: z.number().transform(validateUnixTimestamp).brand('UnixTimestamp').nullish(),
|
|
67
|
+
publish_start_date: z.number().transform(validateUnixTimestamp).brand('UnixTimestamp'),
|
|
68
|
+
publish_status: publishStatusSchema,
|
|
69
|
+
reference_type: referenceTypeSchema,
|
|
70
|
+
references: z.array(z.object({
|
|
71
|
+
child_ids: z.array(z.string().min(1)),
|
|
72
|
+
parent_id: z.string().min(1),
|
|
73
|
+
})),
|
|
74
|
+
title: z.string().min(1),
|
|
75
|
+
type: alertTypeSchema,
|
|
76
|
+
}).strict();
|
|
77
|
+
export const CreateAlertSchema = AlertSchema
|
|
78
|
+
.omit({ _id: true, created_at: true, updated_at: true });
|
|
79
|
+
export const UpdateAlertSchema = AlertSchema
|
|
80
|
+
.omit({ _id: true, created_at: true, updated_at: true })
|
|
81
|
+
.partial();
|