@tmlmobilidade/types 20251015.1047.23 → 20251017.932.51

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.
@@ -1,27 +1,126 @@
1
1
  import { z } from 'zod';
2
2
  /* * */
3
3
  import { MetricBasePropertiesSchema, MetricBaseSchema } from './common.js';
4
- // /metrics/demand_by_line_by_year?line=4701
5
- export const DemandByLineByYearSchema = MetricBaseSchema.extend({
6
- data: z.record(z.string(), // e.g. "2024", "2025"
7
- z.object({
4
+ /* DEMAND BY LINE */
5
+ const DemandByLinePropertiesSchema = MetricBasePropertiesSchema.extend({
6
+ line_id: z.string(),
7
+ });
8
+ const DemandByLineSchema = MetricBaseSchema.extend({
9
+ data: z.record(z.string(), z.object({
8
10
  qty: z.number(),
9
11
  })),
12
+ properties: DemandByLinePropertiesSchema,
13
+ });
14
+ export const DemandByLineByYearSchema = DemandByLineSchema.extend({
10
15
  metric: z.literal('demand_by_line_by_year'),
16
+ });
17
+ export const DemandByLineByMonthSchema = DemandByLineSchema.extend({
18
+ metric: z.literal('demand_by_line_by_month'),
19
+ });
20
+ export const DemandByLineByDaySchema = DemandByLineSchema.extend({
21
+ data: z.record(z.string(), z.object({
22
+ day_type: z.number(),
23
+ holiday: z.number(),
24
+ notes: z.string().nullable(),
25
+ period: z.number(),
26
+ qty: z.number(),
27
+ })),
28
+ metric: z.literal('demand_by_line_by_day'),
29
+ });
30
+ // data: "2025-03": {
31
+ // "weekday": { "qty": 9300, "count": 31, "avg": 300 },
32
+ // "saturday": { "qty": 600, "count": 4, "avg": 150 },
33
+ // "sunday": { "qty": 200, "count": 4, "avg": 50 }
34
+ // },
35
+ export const MeanDemandByLineByMonthSchema = DemandByLineSchema.extend({
36
+ data: z.record(z.string(), z.record(z.string(), z.object({
37
+ avg: z.number().optional(),
38
+ count: z.number(),
39
+ qty: z.number(),
40
+ }))),
41
+ metric: z.literal('mean_demand_by_line_by_month'),
42
+ });
43
+ // data: {
44
+ // "12345": { increase: 20, qty: 4800, year_avg: 4000 },
45
+ // "67890": { increase: 18, qty: 3700, year_avg: 3130 },
46
+ // },
47
+ export const TopMeanDemandByLineByMonthSchema = DemandByLineSchema.extend({
48
+ data: z.record(z.string(), z.object({
49
+ increase_pct: z.number(),
50
+ qty: z.number(),
51
+ year_avg: z.number(),
52
+ })),
53
+ metric: z.literal('top_mean_demand_by_line_by_month'),
11
54
  properties: MetricBasePropertiesSchema.extend({
12
- interval: z.literal(300000),
13
- line_id: z.string(),
55
+ year_month: z.string(),
14
56
  }),
15
57
  });
16
- export const DemandByLineByMonthSchema = MetricBaseSchema.extend({
17
- data: z.record(z.string(), // e.g. "2024-01", "2024-02"
18
- z.object({
58
+ /* DEMAND BY AGENCY */
59
+ const DemandByAgencySchema = MetricBaseSchema.extend({
60
+ data: z.record(z.string(), z.object({
61
+ qty: z.number(),
62
+ })),
63
+ properties: MetricBasePropertiesSchema.extend({
64
+ agency_id: z.string(),
65
+ }),
66
+ });
67
+ export const DemandByAgencyByYearSchema = DemandByAgencySchema.extend({
68
+ metric: z.literal('demand_by_agency_by_year'),
69
+ });
70
+ export const DemandByAgencyByMonthSchema = DemandByAgencySchema.extend({
71
+ metric: z.literal('demand_by_agency_by_month'),
72
+ });
73
+ export const DemandByAgencyByDaySchema = DemandByAgencySchema.extend({
74
+ metric: z.literal('demand_by_agency_by_day'),
75
+ });
76
+ /* DEMAND BY PATTERN */
77
+ const DemandByPatternSchema = MetricBaseSchema.extend({
78
+ data: z.record(z.string(), z.object({
19
79
  qty: z.number(),
20
80
  })),
21
- metric: z.literal('demand_by_line_by_month'),
22
81
  properties: MetricBasePropertiesSchema.extend({
23
- interval: z.literal(300000),
24
- line_id: z.string(),
82
+ pattern_id: z.string(),
83
+ }),
84
+ });
85
+ export const DemandByPatternByYearSchema = DemandByPatternSchema.extend({
86
+ metric: z.literal('demand_by_pattern_by_year'),
87
+ properties: MetricBasePropertiesSchema.extend({
88
+ pattern_id: z.string(),
89
+ }),
90
+ });
91
+ export const DemandByPatternByMonthSchema = DemandByPatternSchema.extend({
92
+ metric: z.literal('demand_by_pattern_by_month'),
93
+ });
94
+ export const DemandByPatternByDaySchema = DemandByPatternSchema.extend({
95
+ metric: z.literal('demand_by_pattern_by_day'),
96
+ });
97
+ /* DEMAND BY PATTERN_HOUR */
98
+ export const DemandByPatternHourByYearSchema = DemandByPatternSchema.extend({
99
+ metric: z.literal('demand_by_pattern_hour_by_year'),
100
+ properties: MetricBasePropertiesSchema.extend({
101
+ hour: z.number().min(0).max(23),
102
+ minute: z.number().min(0).max(59),
103
+ pattern_id: z.string(),
104
+ }),
105
+ });
106
+ export const DemandByPatternHourByMonthSchema = DemandByPatternSchema.extend({
107
+ metric: z.literal('demand_by_pattern_hour_by_month'),
108
+ properties: MetricBasePropertiesSchema.extend({
109
+ hour: z.number().min(0).max(23),
110
+ minute: z.number().min(0).max(59),
111
+ pattern_id: z.string(),
112
+ }),
113
+ });
114
+ /* RECORD BY AGENCY */
115
+ export const TopDemandByAgencySchema = MetricBaseSchema.extend({
116
+ data: z.object({
117
+ operators: z.record(z.string(), z.record(z.string(), z.object({
118
+ qty: z.number(),
119
+ }))),
120
+ total: z.record(z.string(), z.object({
121
+ qty: z.number(),
122
+ })),
25
123
  }),
124
+ metric: z.literal('top_demand_by_agency'),
26
125
  });
27
126
  /* * */