@venulog/phasing-engine-schemas 0.2.0-alpha.0 → 0.2.0-alpha.2

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,82 +1,85 @@
1
1
  import { z } from './zod.js';
2
- import { SlotStatus } from './enums/slotStatus.js';
3
2
  export declare const getAvailableSlotsQuerySchema: z.ZodObject<{
3
+ event_id: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
4
+ year: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
5
+ month: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
6
+ phase_slot_id: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
7
+ schedule_type: z.ZodOptional<z.ZodEnum<{
8
+ assembly: "assembly";
9
+ dismantling: "dismantling";
10
+ }>>;
11
+ }, z.core.$strip>;
12
+ export declare const availableTimeSlotSchema: z.ZodObject<{
13
+ phase_slot_schedule_id: z.ZodNumber;
14
+ date: z.ZodString;
15
+ start_time: z.ZodString;
16
+ end_time: z.ZodString;
17
+ duration: z.ZodNumber;
18
+ schedule_type: z.ZodEnum<{
19
+ assembly: "assembly";
20
+ dismantling: "dismantling";
21
+ }>;
22
+ max_capacity: z.ZodNumber;
23
+ current_bookings: z.ZodNumber;
24
+ confirmed_bookings: z.ZodNumber;
25
+ available_capacity: z.ZodNumber;
26
+ is_available: z.ZodBoolean;
27
+ }, z.core.$strip>;
28
+ export declare const availableSlotsResponseSchema: z.ZodObject<{
29
+ event_id: z.ZodNumber;
4
30
  event_code: z.ZodString;
5
- provider_id: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<number | undefined, string | undefined>>;
6
- vehicle_type_id: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<number | undefined, string | undefined>>;
7
- min_priority: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<number | undefined, string | undefined>>;
8
- page: z.ZodOptional<z.ZodDefault<z.ZodCoercedNumber<unknown>>>;
9
- limit: z.ZodOptional<z.ZodDefault<z.ZodCoercedNumber<unknown>>>;
10
- sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
11
- column: z.ZodString;
12
- direction: z.ZodEnum<{
13
- asc: "asc";
14
- desc: "desc";
31
+ event_name: z.ZodString;
32
+ company_role: z.ZodNullable<z.ZodString>;
33
+ year: z.ZodNumber;
34
+ month: z.ZodNumber;
35
+ available_slots: z.ZodArray<z.ZodObject<{
36
+ phase_slot_schedule_id: z.ZodNumber;
37
+ date: z.ZodString;
38
+ start_time: z.ZodString;
39
+ end_time: z.ZodString;
40
+ duration: z.ZodNumber;
41
+ schedule_type: z.ZodEnum<{
42
+ assembly: "assembly";
43
+ dismantling: "dismantling";
15
44
  }>;
16
- }, z.core.$strip>>>;
45
+ max_capacity: z.ZodNumber;
46
+ current_bookings: z.ZodNumber;
47
+ confirmed_bookings: z.ZodNumber;
48
+ available_capacity: z.ZodNumber;
49
+ is_available: z.ZodBoolean;
50
+ }, z.core.$strip>>;
51
+ total_slots: z.ZodNumber;
17
52
  }, z.core.$strip>;
18
- export declare const extendedVehicleTypeSchema: z.ZodObject<{
19
- id: z.ZodNumber;
20
- name: z.ZodString;
21
- code: z.ZodString;
22
- height: z.ZodString;
23
- surface_area_side: z.ZodNumber;
24
- surface_aread_back: z.ZodNumber;
25
- loading_duration: z.ZodNumber;
53
+ export declare const getPhaseSlotsByEventIdParamsSchema: z.ZodObject<{
54
+ eventId: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
26
55
  }, z.core.$strip>;
27
- export declare const availablePhaseSlotSchema: z.ZodObject<{
56
+ export declare const phaseSlotItemSchema: z.ZodObject<{
28
57
  id: z.ZodNumber;
29
58
  event_id: z.ZodNumber;
30
- slot_number: z.ZodNumber;
31
- vehicle_type_id: z.ZodNullable<z.ZodNumber>;
32
59
  company_role: z.ZodNullable<z.ZodString>;
33
- status: z.ZodEnum<typeof SlotStatus>;
34
60
  is_active: z.ZodBoolean;
35
61
  created_at: z.ZodString;
36
62
  updated_at: z.ZodString;
37
- vehicle_type: z.ZodOptional<z.ZodNullable<z.ZodObject<{
38
- id: z.ZodNumber;
39
- name: z.ZodString;
40
- code: z.ZodString;
41
- height: z.ZodString;
42
- surface_area_side: z.ZodNumber;
43
- surface_aread_back: z.ZodNumber;
44
- loading_duration: z.ZodNumber;
45
- }, z.core.$strip>>>;
63
+ created_by: z.ZodNullable<z.ZodString>;
64
+ updated_by: z.ZodNullable<z.ZodString>;
46
65
  }, z.core.$strip>;
47
- export declare const availableSlotsResponseSchema: z.ZodObject<{
66
+ export declare const getPhaseSlotsResponseSchema: z.ZodObject<{
48
67
  event_id: z.ZodNumber;
49
- event_name: z.ZodString;
50
- phase_status: z.ZodString;
51
- available_slots: z.ZodArray<z.ZodObject<{
68
+ slots: z.ZodArray<z.ZodObject<{
52
69
  id: z.ZodNumber;
53
70
  event_id: z.ZodNumber;
54
- slot_number: z.ZodNumber;
55
- vehicle_type_id: z.ZodNullable<z.ZodNumber>;
56
71
  company_role: z.ZodNullable<z.ZodString>;
57
- status: z.ZodEnum<typeof SlotStatus>;
58
72
  is_active: z.ZodBoolean;
59
73
  created_at: z.ZodString;
60
74
  updated_at: z.ZodString;
61
- vehicle_type: z.ZodOptional<z.ZodNullable<z.ZodObject<{
62
- id: z.ZodNumber;
63
- name: z.ZodString;
64
- code: z.ZodString;
65
- height: z.ZodString;
66
- surface_area_side: z.ZodNumber;
67
- surface_aread_back: z.ZodNumber;
68
- loading_duration: z.ZodNumber;
69
- }, z.core.$strip>>>;
75
+ created_by: z.ZodNullable<z.ZodString>;
76
+ updated_by: z.ZodNullable<z.ZodString>;
70
77
  }, z.core.$strip>>;
71
78
  total_count: z.ZodNumber;
72
79
  }, z.core.$strip>;
73
- export declare const availableSlotsFiltersSchema: z.ZodObject<{
74
- provider_id: z.ZodOptional<z.ZodNumber>;
75
- vehicle_type_id: z.ZodOptional<z.ZodNumber>;
76
- min_priority: z.ZodOptional<z.ZodNumber>;
77
- }, z.core.$strip>;
78
80
  export type GetAvailableSlotsQuery = z.infer<typeof getAvailableSlotsQuerySchema>;
79
- export type AvailablePhaseSlot = z.infer<typeof availablePhaseSlotSchema>;
81
+ export type AvailableTimeSlot = z.infer<typeof availableTimeSlotSchema>;
80
82
  export type AvailableSlotsResponse = z.infer<typeof availableSlotsResponseSchema>;
81
- export type GetAvailableSlotsFilters = z.infer<typeof availableSlotsFiltersSchema>;
82
- export type ExtendedVehicleType = z.infer<typeof extendedVehicleTypeSchema>;
83
+ export type GetPhaseSlotsByEventIdParams = z.infer<typeof getPhaseSlotsByEventIdParamsSchema>;
84
+ export type PhaseSlotItem = z.infer<typeof phaseSlotItemSchema>;
85
+ export type GetPhaseSlotsResponse = z.infer<typeof getPhaseSlotsResponseSchema>;
package/dist/phaseSlot.js CHANGED
@@ -1,74 +1,206 @@
1
1
  // packages/phasing-schemas/src/phaseSlot.ts
2
2
  import { z } from './zod.js';
3
- import { paginationSchema } from './pagination.js';
4
- import { vehicleTypeSchema } from './phaseBooking.js';
5
- import { SlotStatus } from './enums/slotStatus.js';
6
3
  // ------------------------------
7
4
  // Query parameters schema
8
5
  // ------------------------------
9
6
  export const getAvailableSlotsQuerySchema = z
10
7
  .object({
11
- event_code: z.string().min(1, 'Event code is required'),
12
- provider_id: z
8
+ event_id: z
13
9
  .string()
14
- .optional()
15
- .transform(val => (val ? parseInt(val, 10) : undefined))
16
- .refine(val => val === undefined || (!isNaN(val) && val > 0), {
17
- message: 'Provider ID must be a positive number'
10
+ .min(1)
11
+ .transform(val => parseInt(val, 10))
12
+ .refine(val => !isNaN(val) && val > 0, {
13
+ message: 'Event ID must be a positive number'
14
+ })
15
+ .openapi({
16
+ description: 'The ID of the event',
17
+ example: '1'
18
+ }),
19
+ year: z
20
+ .string()
21
+ .regex(/^\d{4}$/, 'Year must be in YYYY format')
22
+ .transform(val => parseInt(val, 10))
23
+ .openapi({
24
+ description: 'Year for filtering slots (YYYY). Slots before today will be excluded.',
25
+ example: '2026'
18
26
  }),
19
- vehicle_type_id: z
27
+ month: z
20
28
  .string()
21
- .optional()
22
- .transform(val => (val ? parseInt(val, 10) : undefined))
23
- .refine(val => val === undefined || (!isNaN(val) && val > 0), {
24
- message: 'Vehicle type ID must be a positive number'
29
+ .regex(/^(0?[1-9]|1[0-2])$/, 'Month must be between 1 and 12')
30
+ .transform(val => parseInt(val, 10))
31
+ .openapi({
32
+ description: 'Month for filtering slots (1-12). Slots before today will be excluded.',
33
+ example: '6'
25
34
  }),
26
- min_priority: z
35
+ phase_slot_id: z
27
36
  .string()
28
- .optional()
29
- .transform(val => (val ? parseInt(val, 10) : undefined))
30
- .refine(val => val === undefined || !isNaN(val), {
31
- message: 'Min priority must be a number'
37
+ .min(1)
38
+ .transform(val => parseInt(val, 10))
39
+ .refine(val => !isNaN(val) && val > 0, {
40
+ message: 'Phase slot ID must be a positive number'
41
+ })
42
+ .openapi({
43
+ description: 'The ID of the phase slot',
44
+ example: '1'
45
+ }),
46
+ schedule_type: z.enum(['assembly', 'dismantling']).optional().openapi({
47
+ description: 'Filter by schedule type',
48
+ example: 'assembly'
32
49
  })
33
50
  })
34
- .extend(paginationSchema.shape);
35
- // ------------------------------
36
- // Extended vehicle type schema for available slots
37
- // ------------------------------
38
- export const extendedVehicleTypeSchema = vehicleTypeSchema.extend({
39
- code: z.string(),
40
- height: z.string(),
41
- surface_area_side: z.number(),
42
- surface_aread_back: z.number(),
43
- loading_duration: z.number()
44
- });
51
+ .openapi('GetAvailableSlotsQuery');
45
52
  // ------------------------------
46
53
  // Response schemas
47
54
  // ------------------------------
48
- export const availablePhaseSlotSchema = z.object({
49
- id: z.number(),
50
- event_id: z.number(),
51
- slot_number: z.number(),
52
- vehicle_type_id: z.number().nullable(),
53
- company_role: z.string().nullable(),
54
- status: z.enum(SlotStatus),
55
- is_active: z.boolean(),
56
- created_at: z.string(),
57
- updated_at: z.string(),
58
- vehicle_type: extendedVehicleTypeSchema.nullable().optional()
59
- });
60
- export const availableSlotsResponseSchema = z.object({
61
- event_id: z.number(),
62
- event_name: z.string(),
63
- phase_status: z.string(),
64
- available_slots: z.array(availablePhaseSlotSchema),
65
- total_count: z.number()
66
- });
55
+ export const availableTimeSlotSchema = z
56
+ .object({
57
+ phase_slot_schedule_id: z.number().openapi({
58
+ description: 'Phase slot schedule ID',
59
+ example: 1
60
+ }),
61
+ date: z.string().openapi({
62
+ description: 'Date of the time slot (YYYY-MM-DD)',
63
+ example: '2026-06-15'
64
+ }),
65
+ start_time: z.string().openapi({
66
+ description: 'Start time of the slot (HH:MM)',
67
+ example: '08:00'
68
+ }),
69
+ end_time: z.string().openapi({
70
+ description: 'End time of the slot (HH:MM)',
71
+ example: '08:30'
72
+ }),
73
+ duration: z.number().openapi({
74
+ description: 'Duration in minutes',
75
+ example: 30
76
+ }),
77
+ schedule_type: z.enum(['assembly', 'dismantling']).openapi({
78
+ description: 'Type of schedule',
79
+ example: 'assembly'
80
+ }),
81
+ max_capacity: z.number().openapi({
82
+ description: 'Maximum booking capacity for this slot',
83
+ example: 5
84
+ }),
85
+ current_bookings: z.number().openapi({
86
+ description: 'Number of current bookings',
87
+ example: 3
88
+ }),
89
+ confirmed_bookings: z.number().openapi({
90
+ description: 'Number of confirmed bookings',
91
+ example: 1
92
+ }),
93
+ available_capacity: z.number().openapi({
94
+ description: 'Remaining available capacity',
95
+ example: 2
96
+ }),
97
+ is_available: z.boolean().openapi({
98
+ description: 'Whether the slot is available for booking',
99
+ example: true
100
+ })
101
+ })
102
+ .openapi('AvailableTimeSlot');
103
+ export const availableSlotsResponseSchema = z
104
+ .object({
105
+ event_id: z.number().openapi({
106
+ description: 'ID of the event',
107
+ example: 1
108
+ }),
109
+ event_code: z.string().openapi({
110
+ description: 'Code of the event',
111
+ example: 'COEC2025'
112
+ }),
113
+ event_name: z.string().openapi({
114
+ description: 'Name of the event',
115
+ example: 'COEC 2025'
116
+ }),
117
+ company_role: z.string().nullable().openapi({
118
+ description: 'Company role for the phase slots',
119
+ example: 'exhibitor'
120
+ }),
121
+ year: z.number().openapi({
122
+ description: 'Year of the slots',
123
+ example: 2026
124
+ }),
125
+ month: z.number().openapi({
126
+ description: 'Month of the slots',
127
+ example: 6
128
+ }),
129
+ available_slots: z.array(availableTimeSlotSchema).openapi({
130
+ description: 'List of available time slots with capacity information'
131
+ }),
132
+ total_slots: z.number().openapi({
133
+ description: 'Total number of time slots in the period',
134
+ example: 48
135
+ })
136
+ })
137
+ .openapi('AvailableSlotsResponse');
67
138
  // ------------------------------
68
- // Filters type
139
+ // Get Phase Slots by Event ID
69
140
  // ------------------------------
70
- export const availableSlotsFiltersSchema = z.object({
71
- provider_id: z.number().optional(),
72
- vehicle_type_id: z.number().optional(),
73
- min_priority: z.number().optional()
74
- });
141
+ export const getPhaseSlotsByEventIdParamsSchema = z
142
+ .object({
143
+ eventId: z
144
+ .string()
145
+ .min(1)
146
+ .transform(val => parseInt(val, 10))
147
+ .refine(val => !isNaN(val) && val > 0, {
148
+ message: 'Event ID must be a positive number'
149
+ })
150
+ .openapi({
151
+ description: 'The ID of the event',
152
+ example: '1'
153
+ })
154
+ })
155
+ .openapi('GetPhaseSlotsByEventIdParams');
156
+ export const phaseSlotItemSchema = z
157
+ .object({
158
+ id: z.number().openapi({
159
+ description: 'Phase slot ID',
160
+ example: 1
161
+ }),
162
+ event_id: z.number().openapi({
163
+ description: 'Event ID',
164
+ example: 1
165
+ }),
166
+ company_role: z.string().nullable().openapi({
167
+ description: 'Company role for this slot',
168
+ example: 'exhibitor'
169
+ }),
170
+ is_active: z.boolean().openapi({
171
+ description: 'Whether the slot is active',
172
+ example: true
173
+ }),
174
+ created_at: z.string().openapi({
175
+ description: 'Creation timestamp',
176
+ example: '2025-12-16T10:30:00Z'
177
+ }),
178
+ updated_at: z.string().openapi({
179
+ description: 'Last update timestamp',
180
+ example: '2025-12-16T10:30:00Z'
181
+ }),
182
+ created_by: z.string().nullable().openapi({
183
+ description: 'User ID who created the slot',
184
+ example: 'user-uuid-123'
185
+ }),
186
+ updated_by: z.string().nullable().openapi({
187
+ description: 'User ID who last updated the slot',
188
+ example: 'user-uuid-123'
189
+ })
190
+ })
191
+ .openapi('PhaseSlotItem');
192
+ export const getPhaseSlotsResponseSchema = z
193
+ .object({
194
+ event_id: z.number().openapi({
195
+ description: 'ID of the event',
196
+ example: 1
197
+ }),
198
+ slots: z.array(phaseSlotItemSchema).openapi({
199
+ description: 'List of phase slots for the event'
200
+ }),
201
+ total_count: z.number().openapi({
202
+ description: 'Total number of phase slots',
203
+ example: 10
204
+ })
205
+ })
206
+ .openapi('GetPhaseSlotsResponse');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@venulog/phasing-engine-schemas",
3
- "version": "0.2.0-alpha.0",
3
+ "version": "0.2.0-alpha.2",
4
4
  "description": "Shared schemas and types for Phasing Engine API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -29,6 +29,10 @@
29
29
  "./phaseSlot": {
30
30
  "types": "./dist/phaseSlot.d.ts",
31
31
  "import": "./dist/phaseSlot.js"
32
+ },
33
+ "./event": {
34
+ "types": "./dist/event.d.ts",
35
+ "import": "./dist/event.js"
32
36
  }
33
37
  },
34
38
  "files": [
@@ -1,5 +0,0 @@
1
- export declare enum SlotStatus {
2
- AVAILABLE = "available",
3
- TAKEN = "taken",
4
- RESERVED = "reserved"
5
- }
@@ -1,6 +0,0 @@
1
- export var SlotStatus;
2
- (function (SlotStatus) {
3
- SlotStatus["AVAILABLE"] = "available";
4
- SlotStatus["TAKEN"] = "taken";
5
- SlotStatus["RESERVED"] = "reserved";
6
- })(SlotStatus || (SlotStatus = {}));