@venulog/phasing-engine-schemas 0.1.0

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,82 @@
1
+ import { z } from './zod.js';
2
+ import { SlotStatus } from './enums/slotStatus.js';
3
+ export declare const getAvailableSlotsQuerySchema: z.ZodObject<{
4
+ 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";
15
+ }>;
16
+ }, z.core.$strip>>>;
17
+ }, 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;
26
+ }, z.core.$strip>;
27
+ export declare const availablePhaseSlotSchema: z.ZodObject<{
28
+ id: z.ZodNumber;
29
+ event_id: z.ZodNumber;
30
+ slot_number: z.ZodNumber;
31
+ vehicle_type_id: z.ZodNullable<z.ZodNumber>;
32
+ company_role: z.ZodNullable<z.ZodString>;
33
+ status: z.ZodEnum<typeof SlotStatus>;
34
+ is_active: z.ZodBoolean;
35
+ created_at: z.ZodString;
36
+ 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>>>;
46
+ }, z.core.$strip>;
47
+ export declare const availableSlotsResponseSchema: z.ZodObject<{
48
+ event_id: z.ZodNumber;
49
+ event_name: z.ZodString;
50
+ phase_status: z.ZodString;
51
+ available_slots: z.ZodArray<z.ZodObject<{
52
+ id: z.ZodNumber;
53
+ event_id: z.ZodNumber;
54
+ slot_number: z.ZodNumber;
55
+ vehicle_type_id: z.ZodNullable<z.ZodNumber>;
56
+ company_role: z.ZodNullable<z.ZodString>;
57
+ status: z.ZodEnum<typeof SlotStatus>;
58
+ is_active: z.ZodBoolean;
59
+ created_at: z.ZodString;
60
+ 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>>>;
70
+ }, z.core.$strip>>;
71
+ total_count: z.ZodNumber;
72
+ }, 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
+ export type GetAvailableSlotsQuery = z.infer<typeof getAvailableSlotsQuerySchema>;
79
+ export type AvailablePhaseSlot = z.infer<typeof availablePhaseSlotSchema>;
80
+ export type AvailableSlotsResponse = z.infer<typeof availableSlotsResponseSchema>;
81
+ export type GetAvailableSlotsFilters = z.infer<typeof availableSlotsFiltersSchema>;
82
+ export type ExtendedVehicleType = z.infer<typeof extendedVehicleTypeSchema>;
@@ -0,0 +1,74 @@
1
+ // packages/phasing-schemas/src/phaseSlot.ts
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
+ // ------------------------------
7
+ // Query parameters schema
8
+ // ------------------------------
9
+ export const getAvailableSlotsQuerySchema = z
10
+ .object({
11
+ event_code: z.string().min(1, 'Event code is required'),
12
+ provider_id: z
13
+ .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'
18
+ }),
19
+ vehicle_type_id: z
20
+ .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'
25
+ }),
26
+ min_priority: z
27
+ .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'
32
+ })
33
+ })
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
+ });
45
+ // ------------------------------
46
+ // Response schemas
47
+ // ------------------------------
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
+ });
67
+ // ------------------------------
68
+ // Filters type
69
+ // ------------------------------
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
+ });
package/dist/zod.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { z as originalZ } from 'zod/v4';
2
+ export { originalZ as z };
package/dist/zod.js ADDED
@@ -0,0 +1,4 @@
1
+ import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
2
+ import { z as originalZ } from 'zod/v4';
3
+ extendZodWithOpenApi(originalZ);
4
+ export { originalZ as z };
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@venulog/phasing-engine-schemas",
3
+ "version": "0.1.0",
4
+ "description": "Shared schemas and types for Phasing Engine API",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./auth": {
14
+ "types": "./dist/auth.d.ts",
15
+ "import": "./dist/auth.js"
16
+ },
17
+ "./common": {
18
+ "types": "./dist/common.d.ts",
19
+ "import": "./dist/common.js"
20
+ },
21
+ "./pagination": {
22
+ "types": "./dist/pagination.d.ts",
23
+ "import": "./dist/pagination.js"
24
+ },
25
+ "./phaseBooking": {
26
+ "types": "./dist/phaseBooking.d.ts",
27
+ "import": "./dist/phaseBooking.js"
28
+ },
29
+ "./phaseSlot": {
30
+ "types": "./dist/phaseSlot.d.ts",
31
+ "import": "./dist/phaseSlot.js"
32
+ },
33
+ "./company": {
34
+ "types": "./dist/company.d.ts",
35
+ "import": "./dist/company.js"
36
+ }
37
+ },
38
+ "files": [
39
+ "dist"
40
+ ],
41
+ "scripts": {
42
+ "build": "npm run clean && tsc",
43
+ "dev": "tsc --watch",
44
+ "clean": "rm -rf dist",
45
+ "prepublishOnly": "npm run build"
46
+ },
47
+ "keywords": [
48
+ "schemas",
49
+ "validation",
50
+ "types",
51
+ "zod",
52
+ "phasing-engine"
53
+ ],
54
+ "license": "MIT",
55
+ "dependencies": {
56
+ "@asteasolutions/zod-to-openapi": "^8.1.0",
57
+ "zod": "^4.1.13"
58
+ },
59
+ "devDependencies": {
60
+ "typescript": "^5.6.3"
61
+ },
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "git+https://github.com/manaty/phasing_engine.git",
65
+ "directory": "packages/phasing-schemas"
66
+ }
67
+ }