@battle-racing/br-common-lib 4.3.0 → 4.4.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,14 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # Naming Convention & Typing Rules
6
+
7
+ - **Nomenclatura Exacta:** El nombre del archivo DEBE coincidir con el componente, hook o servicio principal exportado (Ej: `useSearchClientMutation` en `useSearchClientMutation.ts`).
8
+ - **Inglés Obligatorio:** Textos, variables, funciones y UI DEBEN estar en inglés.
9
+ - **Comentarios:** No agregar comentarios en el código a menos que la lógica sea excepcionalmente compleja. Si son estrictamente necesarios, usar JSDoc en inglés.
10
+ - **Componentes:** `PascalCase.tsx`. Separar contenedores (smart) de componentes puros.
11
+ - **Hooks:** `camelCase.ts` con prefijo `use`. Separar queries y mutations.
12
+ - **Servicios/Utils:** `camelCase.ts`.
13
+ - **Tipado (Regla de ORO):** NUNCA usar `any` o `as any`. Usar validaciones, narrowings o `unknown`.
14
+ - **Importaciones compartidas:** Los types vienen de `@battle-racing/br-common-lib`. Si no existen, crearlos allí o en la carpeta `types` si son locales. NUNCA usar `import * as BrCommon`. Importar específicamente.
@@ -0,0 +1,15 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # Module Architecture & Routing
6
+
7
+ - **Encapsulación por Feature:** Cada módulo en `src/features/{nombre-modulo}` debe contener:
8
+ - `index.ts`: Public API, exporta solo lo necesario.
9
+ - `types/`: Definiciones locales.
10
+ - `services/`: Lógica de API. **SIEMPRE** se debe usar un patrón de objeto para exportar los métodos (Ej: `export const authService = { login: () => {} }`) y realizar las consultas HTTP reusando la instancia de Axios definida en `src/lib/api.ts`. usando la instancia Axios en `src/lib/api.ts`.
11
+ - `hooks/`: Queries y Mutations usando `@tanstack/react-query`.
12
+ - `store/`: Estados de Zustand (si aplica).
13
+ - **TanStack Router:** Rutas en `src/routes/` NO deben tener lógica de componentes o UI compleja.
14
+ - **Componentes Page:** Las rutas importan componentes de la carpeta `pages/` de cada feature (Ej: `src/routes/guest-registration.tsx` importa `<GuestRegistrationPage />`).
15
+ - **Semántica:** Nombres basados en la función específica (ej. `ticket-sales`), no usar nombres genéricos abstractos.
@@ -0,0 +1,10 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # Data Management & State
6
+
7
+ - **TanStack Query:** Usar siempre `@tanstack/react-query` en los hooks, invocando servicios.
8
+ - **Query Key Factory:** Definir constantes de llaves (`userKeys`, `raceKeys`) en cada módulo para invalidación centralizada.
9
+ - **Separación de Hooks:** Mantener Queries (lectura) y Mutations (escritura) en archivos distintos.
10
+ - **Prioridad de Tipos:** Priorizar esquemas de `@battle-racing/br-common-lib` antes de definir locales.
@@ -0,0 +1,10 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # UI, UX & Styling
6
+
7
+ - **ShadCN:** Usar v4.1. Lógica de estilos en CSS, sin `tailwind.config.ts`.
8
+ - **Estructura de Componentes:** Cada componente en su carpeta. Extraer variantes a `*.variants.ts`.
9
+ - **Diseño Atómico:** Separar en Átomos (elementos básicos) y Moléculas (componentes compuestos).
10
+ - **Colores:** NUNCA usar colores puros. Usar la capa semántica de ShadCN. Crear nuevos tokens semánticos si el color no existe para soportar white labels.
@@ -0,0 +1,10 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # Code Quality & React Best Practices
6
+
7
+ - **Legibilidad y Mantenimiento:** Priorizar código fácil de leer. Si hay múltiples enfoques para una solución, evaluar ventajas/desventajas antes de implementar.
8
+ - **Variables de Entorno:** Acceder mediante `import.meta.env`. Usar prefijo `VITE_` para públicas.
9
+ - **Rendimiento:** Evitar optimización prematura. Usar `useMemo` y `useCallback` solo con componentes `React.memo` o cálculos costosos demostrables. Usar `React.lazy` y `Suspense` para lazy loading en rutas.
10
+ - **Error Boundaries:** Cada módulo en `src/features/` debe exportar un Error Boundary a nivel de ruta para aislar fallos.
@@ -12,8 +12,8 @@ export declare const GAME_TURN_CHECK: {
12
12
  readonly TERMS_ACCEPTANCE: "terms_acceptance";
13
13
  };
14
14
  export declare const GameTurnStatusSchema: z.ZodEnum<{
15
- completed: "completed";
16
15
  created: "created";
16
+ completed: "completed";
17
17
  in_queue: "in_queue";
18
18
  ready: "ready";
19
19
  playing: "playing";
@@ -30,8 +30,8 @@ export declare const GameTurnSchema: z.ZodObject<{
30
30
  gameTickets: z.ZodArray<z.ZodString>;
31
31
  playerIds: z.ZodArray<z.ZodString>;
32
32
  status: z.ZodEnum<{
33
- completed: "completed";
34
33
  created: "created";
34
+ completed: "completed";
35
35
  in_queue: "in_queue";
36
36
  ready: "ready";
37
37
  playing: "playing";
@@ -44,8 +44,8 @@ export declare const GameTurnSchema: z.ZodObject<{
44
44
  link_accept: "link_accept";
45
45
  }>;
46
46
  status: z.ZodEnum<{
47
- pending: "pending";
48
47
  completed: "completed";
48
+ pending: "pending";
49
49
  }>;
50
50
  label: z.ZodString;
51
51
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
@@ -63,8 +63,8 @@ export declare const GameTurnQueueItemSchema: z.ZodObject<{
63
63
  gameTickets: z.ZodArray<z.ZodString>;
64
64
  playerIds: z.ZodArray<z.ZodString>;
65
65
  status: z.ZodEnum<{
66
- completed: "completed";
67
66
  created: "created";
67
+ completed: "completed";
68
68
  in_queue: "in_queue";
69
69
  ready: "ready";
70
70
  playing: "playing";
@@ -77,8 +77,8 @@ export declare const GameTurnQueueItemSchema: z.ZodObject<{
77
77
  link_accept: "link_accept";
78
78
  }>;
79
79
  status: z.ZodEnum<{
80
- pending: "pending";
81
80
  completed: "completed";
81
+ pending: "pending";
82
82
  }>;
83
83
  label: z.ZodString;
84
84
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
@@ -14,8 +14,8 @@ export declare const GameTurnTaskTypeSchema: z.ZodEnum<{
14
14
  link_accept: "link_accept";
15
15
  }>;
16
16
  export declare const GameTurnTaskStatusSchema: z.ZodEnum<{
17
- pending: "pending";
18
17
  completed: "completed";
18
+ pending: "pending";
19
19
  }>;
20
20
  export declare const GameTurnTaskSchema: z.ZodObject<{
21
21
  id: z.ZodString;
@@ -25,8 +25,8 @@ export declare const GameTurnTaskSchema: z.ZodObject<{
25
25
  link_accept: "link_accept";
26
26
  }>;
27
27
  status: z.ZodEnum<{
28
- pending: "pending";
29
28
  completed: "completed";
29
+ pending: "pending";
30
30
  }>;
31
31
  label: z.ZodString;
32
32
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
@@ -40,10 +40,6 @@ export declare const playerSchema: z.ZodObject<{
40
40
  updatedAt: z.ZodDate;
41
41
  }, z.core.$strip>;
42
42
  export declare const createPlayerSchema: z.ZodObject<{
43
- type: z.ZodDefault<z.ZodEnum<{
44
- readonly ADULT: "ADULT";
45
- readonly MINOR: "MINOR";
46
- }>>;
47
43
  nickname: z.ZodString;
48
44
  birthDate: z.ZodCoercedDate<unknown>;
49
45
  }, z.core.$strip>;
@@ -32,7 +32,6 @@ exports.playerSchema = zod_1.z.object({
32
32
  exports.createPlayerSchema = exports.playerSchema
33
33
  .pick({
34
34
  nickname: true,
35
- type: true,
36
35
  })
37
36
  .extend({
38
37
  birthDate: zod_1.z.coerce.date(),
@@ -1,5 +1,6 @@
1
1
  export declare const SESSION_STATUS: {
2
- readonly CREATED: "CREATED";
2
+ readonly REGISTRATION: "REGISTRATION";
3
+ readonly TURN_CREATION: "TURN_CREATION";
3
4
  readonly READY: "READY";
4
5
  readonly STARTED: "STARTED";
5
6
  readonly FINISHED: "FINISHED";
@@ -2,7 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SESSION_STATUS = void 0;
4
4
  exports.SESSION_STATUS = {
5
- CREATED: 'CREATED',
5
+ REGISTRATION: 'REGISTRATION',
6
+ TURN_CREATION: 'TURN_CREATION',
6
7
  READY: 'READY',
7
8
  STARTED: 'STARTED',
8
9
  FINISHED: 'FINISHED',
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  export declare const sessionStatusSchema: z.ZodEnum<{
3
- readonly CREATED: "CREATED";
3
+ readonly REGISTRATION: "REGISTRATION";
4
+ readonly TURN_CREATION: "TURN_CREATION";
4
5
  readonly READY: "READY";
5
6
  readonly STARTED: "STARTED";
6
7
  readonly FINISHED: "FINISHED";
@@ -14,20 +15,36 @@ export declare const sessionTicketSchema: z.ZodObject<{
14
15
  }>;
15
16
  }, z.core.$strip>;
16
17
  export declare const gameSessionSchema: z.ZodObject<{
18
+ id: z.ZodUUID;
17
19
  code: z.ZodString;
18
20
  contactPhone: z.ZodOptional<z.ZodString>;
19
21
  userId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
20
- tickets: z.ZodArray<z.ZodObject<{
21
- quantity: z.ZodNumber;
22
- type: z.ZodEnum<{
23
- readonly Race: "Race";
24
- readonly Battle: "Battle";
22
+ tickets: z.ZodOptional<z.ZodArray<z.ZodObject<{
23
+ id: z.ZodUUID;
24
+ purchaseId: z.ZodString;
25
+ sessionId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
26
+ gameTurnId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
27
+ playerId: z.ZodNullable<z.ZodOptional<z.ZodUUID>>;
28
+ status: z.ZodEnum<{
29
+ readonly CREATED: "created";
30
+ readonly ASSIGNED: "assigned";
31
+ readonly ACTIVE: "active";
32
+ readonly COMPLETED: "completed";
25
33
  }>;
26
- }, z.core.$strip>>;
34
+ type: z.ZodDefault<z.ZodEnum<{
35
+ readonly RACE: "race";
36
+ readonly BATTLE: "battle";
37
+ readonly SOCCER: "soccer";
38
+ }>>;
39
+ createdAt: z.ZodDate;
40
+ updatedAt: z.ZodDate;
41
+ completedAt: z.ZodOptional<z.ZodDate>;
42
+ }, z.core.$strip>>>;
27
43
  playerIds: z.ZodArray<z.ZodUUID>;
28
44
  linkedPurchaseId: z.ZodOptional<z.ZodString>;
29
45
  status: z.ZodDefault<z.ZodEnum<{
30
- readonly CREATED: "CREATED";
46
+ readonly REGISTRATION: "REGISTRATION";
47
+ readonly TURN_CREATION: "TURN_CREATION";
31
48
  readonly READY: "READY";
32
49
  readonly STARTED: "STARTED";
33
50
  readonly FINISHED: "FINISHED";
@@ -36,6 +53,104 @@ export declare const gameSessionSchema: z.ZodObject<{
36
53
  createdAt: z.ZodDate;
37
54
  updatedAt: z.ZodDate;
38
55
  }, z.core.$strip>;
56
+ export declare const gameSessionWithPlayersSchema: z.ZodObject<{
57
+ id: z.ZodUUID;
58
+ code: z.ZodString;
59
+ contactPhone: z.ZodOptional<z.ZodString>;
60
+ userId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
61
+ tickets: z.ZodOptional<z.ZodArray<z.ZodObject<{
62
+ id: z.ZodUUID;
63
+ purchaseId: z.ZodString;
64
+ sessionId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
65
+ gameTurnId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
66
+ playerId: z.ZodNullable<z.ZodOptional<z.ZodUUID>>;
67
+ status: z.ZodEnum<{
68
+ readonly CREATED: "created";
69
+ readonly ASSIGNED: "assigned";
70
+ readonly ACTIVE: "active";
71
+ readonly COMPLETED: "completed";
72
+ }>;
73
+ type: z.ZodDefault<z.ZodEnum<{
74
+ readonly RACE: "race";
75
+ readonly BATTLE: "battle";
76
+ readonly SOCCER: "soccer";
77
+ }>>;
78
+ createdAt: z.ZodDate;
79
+ updatedAt: z.ZodDate;
80
+ completedAt: z.ZodOptional<z.ZodDate>;
81
+ }, z.core.$strip>>>;
82
+ playerIds: z.ZodArray<z.ZodUUID>;
83
+ linkedPurchaseId: z.ZodOptional<z.ZodString>;
84
+ status: z.ZodDefault<z.ZodEnum<{
85
+ readonly REGISTRATION: "REGISTRATION";
86
+ readonly TURN_CREATION: "TURN_CREATION";
87
+ readonly READY: "READY";
88
+ readonly STARTED: "STARTED";
89
+ readonly FINISHED: "FINISHED";
90
+ readonly CANCELLED: "CANCELLED";
91
+ }>>;
92
+ createdAt: z.ZodDate;
93
+ updatedAt: z.ZodDate;
94
+ players: z.ZodArray<z.ZodObject<{
95
+ id: z.ZodUUID;
96
+ nickname: z.ZodString;
97
+ avatarUrl: z.ZodOptional<z.ZodURL>;
98
+ birthDate: z.ZodDate;
99
+ type: z.ZodDefault<z.ZodEnum<{
100
+ readonly ADULT: "ADULT";
101
+ readonly MINOR: "MINOR";
102
+ }>>;
103
+ ownerUserId: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
104
+ isGuest: z.ZodDefault<z.ZodBoolean>;
105
+ waiver: z.ZodObject<{
106
+ isSigned: z.ZodDefault<z.ZodBoolean>;
107
+ waiverId: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
108
+ templateVersion: z.ZodOptional<z.ZodString>;
109
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
110
+ }, z.core.$strip>;
111
+ stats: z.ZodNullable<z.ZodOptional<z.ZodObject<{
112
+ totalRaces: z.ZodDefault<z.ZodNumber>;
113
+ bestTimeMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
114
+ xp: z.ZodDefault<z.ZodNumber>;
115
+ }, z.core.$strip>>>;
116
+ createdAt: z.ZodDate;
117
+ updatedAt: z.ZodDate;
118
+ }, z.core.$strip>>;
119
+ turns: z.ZodOptional<z.ZodArray<z.ZodObject<{
120
+ id: z.ZodString;
121
+ purchaseId: z.ZodString;
122
+ sessionId: z.ZodOptional<z.ZodString>;
123
+ leaderPlayerId: z.ZodString;
124
+ gameTickets: z.ZodArray<z.ZodString>;
125
+ playerIds: z.ZodArray<z.ZodString>;
126
+ status: z.ZodEnum<{
127
+ readonly CREATED: "created";
128
+ readonly IN_QUEUE: "in_queue";
129
+ readonly READY: "ready";
130
+ readonly PLAYING: "playing";
131
+ readonly COMPLETED: "completed";
132
+ }>;
133
+ tasks: z.ZodArray<z.ZodObject<{
134
+ id: z.ZodString;
135
+ type: z.ZodEnum<{
136
+ readonly QR_SCAN: "qr_scan";
137
+ readonly MANUAL_CHECK: "manual_check";
138
+ readonly LINK_ACCEPT: "link_accept";
139
+ }>;
140
+ status: z.ZodEnum<{
141
+ readonly PENDING: "pending";
142
+ readonly COMPLETED: "completed";
143
+ }>;
144
+ label: z.ZodString;
145
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
146
+ completedAt: z.ZodOptional<z.ZodDate>;
147
+ }, z.core.$strip>>;
148
+ createdAt: z.ZodDate;
149
+ updatedAt: z.ZodDate;
150
+ startedAt: z.ZodOptional<z.ZodDate>;
151
+ completedAt: z.ZodOptional<z.ZodDate>;
152
+ }, z.core.$strip>>>;
153
+ }, z.core.$strip>;
39
154
  export declare const createSessionInputSchema: z.ZodObject<{
40
155
  contactPhone: z.ZodOptional<z.ZodString>;
41
156
  userId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
@@ -51,6 +166,16 @@ export declare const joinSessionSchema: z.ZodObject<{
51
166
  nickname: z.ZodString;
52
167
  birthDate: z.ZodCoercedDate<unknown>;
53
168
  }, z.core.$strip>;
169
+ export declare const updateSessionStatusSchema: z.ZodObject<{
170
+ status: z.ZodEnum<{
171
+ readonly REGISTRATION: "REGISTRATION";
172
+ readonly TURN_CREATION: "TURN_CREATION";
173
+ readonly READY: "READY";
174
+ readonly STARTED: "STARTED";
175
+ readonly FINISHED: "FINISHED";
176
+ readonly CANCELLED: "CANCELLED";
177
+ }>;
178
+ }, z.core.$strip>;
54
179
  export declare const createGameTurnInputSchema: z.ZodObject<{
55
180
  assignments: z.ZodArray<z.ZodObject<{
56
181
  ticketId: z.ZodString;
@@ -63,3 +188,11 @@ export declare const assignSessionTicketsInputSchema: z.ZodObject<{
63
188
  playerId: z.ZodUUID;
64
189
  }, z.core.$strip>>;
65
190
  }, z.core.$strip>;
191
+ export declare const bulkCreateGameTurnSchema: z.ZodObject<{
192
+ turns: z.ZodArray<z.ZodObject<{
193
+ assignments: z.ZodArray<z.ZodObject<{
194
+ ticketId: z.ZodString;
195
+ playerId: z.ZodUUID;
196
+ }, z.core.$strip>>;
197
+ }, z.core.$strip>>;
198
+ }, z.core.$strip>;
@@ -1,25 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assignSessionTicketsInputSchema = exports.createGameTurnInputSchema = exports.joinSessionSchema = exports.createSessionInputSchema = exports.gameSessionSchema = exports.sessionTicketSchema = exports.sessionStatusSchema = void 0;
3
+ exports.bulkCreateGameTurnSchema = exports.assignSessionTicketsInputSchema = exports.createGameTurnInputSchema = exports.updateSessionStatusSchema = exports.joinSessionSchema = exports.createSessionInputSchema = exports.gameSessionWithPlayersSchema = exports.gameSessionSchema = exports.sessionTicketSchema = exports.sessionStatusSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const Session_const_1 = require("./Session.const");
6
6
  const Game_schema_1 = require("../game/Game.schema");
7
+ const Player_schema_1 = require("../player/Player.schema");
8
+ const Ticketing_schema_1 = require("../ticketing/Ticketing.schema");
7
9
  exports.sessionStatusSchema = zod_1.z.enum(Session_const_1.SESSION_STATUS);
8
10
  exports.sessionTicketSchema = zod_1.z.object({
9
11
  quantity: zod_1.z.number().int().positive(),
10
12
  type: Game_schema_1.gameTypeSchema,
11
13
  });
12
14
  exports.gameSessionSchema = zod_1.z.object({
15
+ id: zod_1.z.uuidv4(),
13
16
  code: zod_1.z.string().length(6), // 6-char alphanumeric
14
17
  contactPhone: zod_1.z.string().optional(),
15
18
  userId: zod_1.z.string().optional().nullable(),
16
- tickets: zod_1.z.array(exports.sessionTicketSchema),
19
+ tickets: zod_1.z.array(Ticketing_schema_1.gameTicketSchema).optional(),
17
20
  playerIds: zod_1.z.array(zod_1.z.uuidv4()),
18
21
  linkedPurchaseId: zod_1.z.string().optional(),
19
- status: exports.sessionStatusSchema.default(Session_const_1.SESSION_STATUS.CREATED),
22
+ status: exports.sessionStatusSchema.default(Session_const_1.SESSION_STATUS.REGISTRATION),
20
23
  createdAt: zod_1.z.date(),
21
24
  updatedAt: zod_1.z.date(),
22
25
  });
26
+ exports.gameSessionWithPlayersSchema = exports.gameSessionSchema.extend({
27
+ players: zod_1.z.array(Player_schema_1.playerSchema),
28
+ turns: zod_1.z.array(Ticketing_schema_1.gameTurnSchema).optional(),
29
+ });
23
30
  exports.createSessionInputSchema = zod_1.z.object({
24
31
  contactPhone: zod_1.z.string().optional(),
25
32
  userId: zod_1.z.string().optional().nullable(),
@@ -29,6 +36,9 @@ exports.joinSessionSchema = zod_1.z.object({
29
36
  nickname: zod_1.z.string().min(2),
30
37
  birthDate: zod_1.z.coerce.date(),
31
38
  });
39
+ exports.updateSessionStatusSchema = zod_1.z.object({
40
+ status: exports.sessionStatusSchema,
41
+ });
32
42
  exports.createGameTurnInputSchema = zod_1.z.object({
33
43
  assignments: zod_1.z
34
44
  .array(zod_1.z.object({
@@ -45,3 +55,6 @@ exports.assignSessionTicketsInputSchema = zod_1.z.object({
45
55
  }))
46
56
  .min(1),
47
57
  });
58
+ exports.bulkCreateGameTurnSchema = zod_1.z.object({
59
+ turns: zod_1.z.array(exports.createGameTurnInputSchema).min(1),
60
+ });
@@ -1,7 +1,10 @@
1
1
  import { z } from 'zod';
2
- import { assignSessionTicketsInputSchema, createSessionInputSchema, gameSessionSchema, sessionStatusSchema, sessionTicketSchema } from './Session.schema';
2
+ import { assignSessionTicketsInputSchema, createSessionInputSchema, gameSessionSchema, gameSessionWithPlayersSchema, joinSessionSchema, bulkCreateGameTurnSchema, sessionStatusSchema, sessionTicketSchema } from './Session.schema';
3
3
  export type SessionStatus = z.infer<typeof sessionStatusSchema>;
4
4
  export type SessionTicket = z.infer<typeof sessionTicketSchema>;
5
5
  export type GameSession = z.infer<typeof gameSessionSchema>;
6
+ export type GameSessionWithPlayers = z.infer<typeof gameSessionWithPlayersSchema>;
6
7
  export type CreateSessionInput = z.infer<typeof createSessionInputSchema>;
7
8
  export type AssignSessionTicketsInput = z.infer<typeof assignSessionTicketsInputSchema>;
9
+ export type JoinSessionInput = z.infer<typeof joinSessionSchema>;
10
+ export type BulkCreateGameTurnInput = z.infer<typeof bulkCreateGameTurnSchema>;
@@ -59,6 +59,8 @@ export declare const purchaseSchema: z.ZodObject<{
59
59
  id: z.ZodUUID;
60
60
  purchaseNumber: z.ZodNumber;
61
61
  buyerUserId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
62
+ guestName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
63
+ guestContact: z.ZodNullable<z.ZodOptional<z.ZodString>>;
62
64
  items: z.ZodArray<z.ZodObject<{
63
65
  ticketType: z.ZodEnum<{
64
66
  readonly Race: "Race";
@@ -85,6 +87,8 @@ export declare const purchaseSchema: z.ZodObject<{
85
87
  }, z.core.$strip>;
86
88
  export declare const createPurchaseInputSchema: z.ZodObject<{
87
89
  buyerUserId: z.ZodOptional<z.ZodString>;
90
+ guestName: z.ZodOptional<z.ZodString>;
91
+ guestContact: z.ZodOptional<z.ZodString>;
88
92
  items: z.ZodArray<z.ZodObject<{
89
93
  ticketType: z.ZodEnum<{
90
94
  readonly Race: "Race";
@@ -133,6 +137,7 @@ export declare const gameTurnTaskSchema: z.ZodObject<{
133
137
  export declare const gameTurnSchema: z.ZodObject<{
134
138
  id: z.ZodString;
135
139
  purchaseId: z.ZodString;
140
+ sessionId: z.ZodOptional<z.ZodString>;
136
141
  leaderPlayerId: z.ZodString;
137
142
  gameTickets: z.ZodArray<z.ZodString>;
138
143
  playerIds: z.ZodArray<z.ZodString>;
@@ -166,6 +171,7 @@ export declare const gameTurnSchema: z.ZodObject<{
166
171
  export declare const gameTurnQueueItemSchema: z.ZodObject<{
167
172
  id: z.ZodString;
168
173
  purchaseId: z.ZodString;
174
+ sessionId: z.ZodOptional<z.ZodString>;
169
175
  leaderPlayerId: z.ZodString;
170
176
  gameTickets: z.ZodArray<z.ZodString>;
171
177
  playerIds: z.ZodArray<z.ZodString>;
@@ -31,6 +31,8 @@ exports.purchaseSchema = zod_1.z.object({
31
31
  purchaseNumber: zod_1.z.number(),
32
32
  // Buyer can be null for Guest/On-Site purchases
33
33
  buyerUserId: zod_1.z.string().optional().nullable(),
34
+ guestName: zod_1.z.string().optional().nullable(),
35
+ guestContact: zod_1.z.string().optional().nullable(),
34
36
  items: zod_1.z.array(exports.purchaseItemSchema),
35
37
  totalAmountCents: zod_1.z.number().min(0),
36
38
  status: exports.purchaseStatusSchema.default(Ticketing_const_1.PURCHASE_STATUS.PENDING),
@@ -43,6 +45,8 @@ exports.purchaseSchema = zod_1.z.object({
43
45
  });
44
46
  exports.createPurchaseInputSchema = zod_1.z.object({
45
47
  buyerUserId: zod_1.z.string().optional(),
48
+ guestName: zod_1.z.string().optional(),
49
+ guestContact: zod_1.z.string().optional(),
46
50
  items: zod_1.z.array(exports.purchaseItemSchema).min(1),
47
51
  });
48
52
  exports.gameTurnStatusSchema = zod_1.z.enum(Ticketing_const_1.GAME_TURN_STATUS);
@@ -60,6 +64,7 @@ exports.gameTurnTaskSchema = zod_1.z.object({
60
64
  exports.gameTurnSchema = zod_1.z.object({
61
65
  id: zod_1.z.string(),
62
66
  purchaseId: zod_1.z.string(),
67
+ sessionId: zod_1.z.string().optional(),
63
68
  leaderPlayerId: zod_1.z.string(),
64
69
  gameTickets: zod_1.z.array(zod_1.z.string()),
65
70
  playerIds: zod_1.z.array(zod_1.z.string()),
@@ -6,6 +6,8 @@ export declare const userTypeSchema: z.ZodEnum<{
6
6
  export declare const PHONE_REGEX: RegExp;
7
7
  export declare const userSchema: z.ZodObject<{
8
8
  id: z.ZodUUID;
9
+ name: z.ZodString;
10
+ lastName: z.ZodString;
9
11
  email: z.ZodOptional<z.ZodEmail>;
10
12
  phoneNumber: z.ZodOptional<z.ZodString>;
11
13
  role: z.ZodEnum<{
@@ -27,6 +29,8 @@ export declare const userSchema: z.ZodObject<{
27
29
  }, z.core.$strip>;
28
30
  export declare const userWithPasswordSchema: z.ZodIntersection<z.ZodObject<{
29
31
  id: z.ZodUUID;
32
+ name: z.ZodString;
33
+ lastName: z.ZodString;
30
34
  email: z.ZodOptional<z.ZodEmail>;
31
35
  phoneNumber: z.ZodOptional<z.ZodString>;
32
36
  role: z.ZodEnum<{
@@ -49,9 +53,10 @@ export declare const userWithPasswordSchema: z.ZodIntersection<z.ZodObject<{
49
53
  password: z.ZodString;
50
54
  }, z.core.$strip>>;
51
55
  export declare const userRegistrationInputSchema: z.ZodObject<{
56
+ name: z.ZodString;
57
+ lastName: z.ZodString;
52
58
  email: z.ZodOptional<z.ZodEmail>;
53
59
  phoneNumber: z.ZodOptional<z.ZodString>;
54
- name: z.ZodOptional<z.ZodString>;
55
60
  password: z.ZodString;
56
61
  nickname: z.ZodString;
57
62
  birthDate: z.ZodCoercedDate<unknown>;
@@ -9,6 +9,8 @@ exports.PHONE_REGEX = /^([+]?[\\s0-9]+)?(\\d{3}|[(]?[0-9]+[)])?([-]?[\\s]?[0-9])
9
9
  const MIN_PASSWORD_LENGTH = 6;
10
10
  const baseUserObj = zod_1.z.object({
11
11
  id: zod_1.z.uuidv4(),
12
+ name: zod_1.z.string(),
13
+ lastName: zod_1.z.string(),
12
14
  email: zod_1.z.email().toLowerCase().optional(),
13
15
  phoneNumber: zod_1.z.string().regex(exports.PHONE_REGEX, 'Invalid phone number format').optional(),
14
16
  // --- ACCESS CONTROL ---
@@ -31,11 +33,12 @@ exports.userWithPasswordSchema = exports.userSchema.and(zod_1.z.object({
31
33
  }));
32
34
  exports.userRegistrationInputSchema = baseUserObj
33
35
  .pick({
36
+ name: true,
37
+ lastName: true,
34
38
  email: true,
35
39
  phoneNumber: true,
36
40
  })
37
41
  .extend({
38
- name: zod_1.z.string().optional(),
39
42
  password: zod_1.z.string().min(6),
40
43
  nickname: zod_1.z.string().min(2),
41
44
  birthDate: zod_1.z.coerce.date(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@battle-racing/br-common-lib",
3
- "version": "4.3.0",
3
+ "version": "4.4.0",
4
4
  "description": "Common library for all Battle Racing Repositorios",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -37,7 +37,6 @@ export const playerSchema = z.object({
37
37
  export const createPlayerSchema = playerSchema
38
38
  .pick({
39
39
  nickname: true,
40
- type: true,
41
40
  })
42
41
  .extend({
43
42
  birthDate: z.coerce.date(),
@@ -1,5 +1,6 @@
1
1
  export const SESSION_STATUS = {
2
- CREATED: 'CREATED',
2
+ REGISTRATION: 'REGISTRATION',
3
+ TURN_CREATION: 'TURN_CREATION',
3
4
  READY: 'READY',
4
5
  STARTED: 'STARTED',
5
6
  FINISHED: 'FINISHED',
@@ -1,6 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  import { SESSION_STATUS } from './Session.const';
3
3
  import { gameTypeSchema } from '../game/Game.schema';
4
+ import { playerSchema } from '../player/Player.schema';
5
+ import { gameTicketSchema, gameTurnSchema } from '../ticketing/Ticketing.schema';
4
6
 
5
7
  export const sessionStatusSchema = z.enum(SESSION_STATUS);
6
8
 
@@ -10,20 +12,26 @@ export const sessionTicketSchema = z.object({
10
12
  });
11
13
 
12
14
  export const gameSessionSchema = z.object({
15
+ id: z.uuidv4(),
13
16
  code: z.string().length(6), // 6-char alphanumeric
14
17
  contactPhone: z.string().optional(),
15
18
  userId: z.string().optional().nullable(),
16
19
 
17
- tickets: z.array(sessionTicketSchema),
20
+ tickets: z.array(gameTicketSchema).optional(),
18
21
  playerIds: z.array(z.uuidv4()),
19
22
  linkedPurchaseId: z.string().optional(),
20
23
 
21
- status: sessionStatusSchema.default(SESSION_STATUS.CREATED),
24
+ status: sessionStatusSchema.default(SESSION_STATUS.REGISTRATION),
22
25
 
23
26
  createdAt: z.date(),
24
27
  updatedAt: z.date(),
25
28
  });
26
29
 
30
+ export const gameSessionWithPlayersSchema = gameSessionSchema.extend({
31
+ players: z.array(playerSchema),
32
+ turns: z.array(gameTurnSchema).optional(),
33
+ });
34
+
27
35
  export const createSessionInputSchema = z.object({
28
36
  contactPhone: z.string().optional(),
29
37
  userId: z.string().optional().nullable(),
@@ -35,6 +43,10 @@ export const joinSessionSchema = z.object({
35
43
  birthDate: z.coerce.date(),
36
44
  });
37
45
 
46
+ export const updateSessionStatusSchema = z.object({
47
+ status: sessionStatusSchema,
48
+ });
49
+
38
50
  export const createGameTurnInputSchema = z.object({
39
51
  assignments: z
40
52
  .array(
@@ -56,3 +68,7 @@ export const assignSessionTicketsInputSchema = z.object({
56
68
  )
57
69
  .min(1),
58
70
  });
71
+
72
+ export const bulkCreateGameTurnSchema = z.object({
73
+ turns: z.array(createGameTurnInputSchema).min(1),
74
+ });
@@ -3,6 +3,9 @@ import {
3
3
  assignSessionTicketsInputSchema,
4
4
  createSessionInputSchema,
5
5
  gameSessionSchema,
6
+ gameSessionWithPlayersSchema,
7
+ joinSessionSchema,
8
+ bulkCreateGameTurnSchema,
6
9
  sessionStatusSchema,
7
10
  sessionTicketSchema,
8
11
  } from './Session.schema';
@@ -10,5 +13,8 @@ import {
10
13
  export type SessionStatus = z.infer<typeof sessionStatusSchema>;
11
14
  export type SessionTicket = z.infer<typeof sessionTicketSchema>;
12
15
  export type GameSession = z.infer<typeof gameSessionSchema>;
16
+ export type GameSessionWithPlayers = z.infer<typeof gameSessionWithPlayersSchema>;
13
17
  export type CreateSessionInput = z.infer<typeof createSessionInputSchema>;
14
18
  export type AssignSessionTicketsInput = z.infer<typeof assignSessionTicketsInputSchema>;
19
+ export type JoinSessionInput = z.infer<typeof joinSessionSchema>;
20
+ export type BulkCreateGameTurnInput = z.infer<typeof bulkCreateGameTurnSchema>;
@@ -43,6 +43,8 @@ export const purchaseSchema = z.object({
43
43
 
44
44
  // Buyer can be null for Guest/On-Site purchases
45
45
  buyerUserId: z.string().optional().nullable(),
46
+ guestName: z.string().optional().nullable(),
47
+ guestContact: z.string().optional().nullable(),
46
48
 
47
49
  items: z.array(purchaseItemSchema),
48
50
  totalAmountCents: z.number().min(0),
@@ -59,6 +61,8 @@ export const purchaseSchema = z.object({
59
61
 
60
62
  export const createPurchaseInputSchema = z.object({
61
63
  buyerUserId: z.string().optional(),
64
+ guestName: z.string().optional(),
65
+ guestContact: z.string().optional(),
62
66
  items: z.array(purchaseItemSchema).min(1),
63
67
  });
64
68
 
@@ -82,6 +86,7 @@ export const gameTurnTaskSchema = z.object({
82
86
  export const gameTurnSchema = z.object({
83
87
  id: z.string(),
84
88
  purchaseId: z.string(),
89
+ sessionId: z.string().optional(),
85
90
  leaderPlayerId: z.string(),
86
91
  gameTickets: z.array(z.string()),
87
92
  playerIds: z.array(z.string()),
@@ -10,6 +10,9 @@ const MIN_PASSWORD_LENGTH = 6;
10
10
  const baseUserObj = z.object({
11
11
  id: z.uuidv4(),
12
12
 
13
+ name: z.string(),
14
+ lastName: z.string(),
15
+
13
16
  email: z.email().toLowerCase().optional(),
14
17
 
15
18
  phoneNumber: z.string().regex(PHONE_REGEX, 'Invalid phone number format').optional(),
@@ -42,11 +45,12 @@ export const userWithPasswordSchema = userSchema.and(
42
45
 
43
46
  export const userRegistrationInputSchema = baseUserObj
44
47
  .pick({
48
+ name: true,
49
+ lastName: true,
45
50
  email: true,
46
51
  phoneNumber: true,
47
52
  })
48
53
  .extend({
49
- name: z.string().optional(),
50
54
  password: z.string().min(6),
51
55
  nickname: z.string().min(2),
52
56
  birthDate: z.coerce.date(),