@battle-racing/br-common-lib 4.4.0 → 4.6.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.
Files changed (97) hide show
  1. package/dist/domains/command/Command.schema.d.ts +76 -10
  2. package/dist/domains/command/Command.schema.js +17 -3
  3. package/dist/domains/command/Command.types.d.ts +3 -1
  4. package/dist/domains/damage/Damage.schema.d.ts +2 -2
  5. package/dist/domains/flow/Flow.schema.d.ts +39 -6
  6. package/dist/domains/hardware/KartHardwareState.schema.js +8 -8
  7. package/dist/domains/hardware/KartHardwareState.types.d.ts +3 -0
  8. package/dist/domains/hardware/KartHardwareState.types.js +2 -0
  9. package/dist/domains/hardware/ModuleStatus.schema.d.ts +28 -0
  10. package/dist/domains/hardware/ModuleStatus.schema.js +4 -0
  11. package/dist/domains/hardware/ballSensor/BallSensor.const.d.ts +5 -0
  12. package/dist/domains/hardware/ballSensor/BallSensor.const.js +6 -1
  13. package/dist/domains/hardware/ballSensor/BallSensor.schema.d.ts +5 -0
  14. package/dist/domains/hardware/ballSensor/BallSensor.schema.js +2 -1
  15. package/dist/domains/hardware/ballSensor/BallSensor.types.d.ts +2 -1
  16. package/dist/domains/hardware/flag/Flag.const.d.ts +7 -0
  17. package/dist/domains/hardware/flag/Flag.const.js +8 -1
  18. package/dist/domains/hardware/flag/Flag.schema.d.ts +11 -4
  19. package/dist/domains/hardware/flag/Flag.schema.js +5 -2
  20. package/dist/domains/hardware/flag/Flag.types.d.ts +2 -1
  21. package/dist/domains/hardware/index.d.ts +1 -0
  22. package/dist/domains/hardware/index.js +2 -1
  23. package/dist/domains/hardware/lights/Lights.const.d.ts +4 -0
  24. package/dist/domains/hardware/lights/Lights.const.js +5 -1
  25. package/dist/domains/hardware/lights/Lights.schema.d.ts +16 -0
  26. package/dist/domains/hardware/lights/Lights.schema.js +5 -1
  27. package/dist/domains/hardware/lights/Lights.types.d.ts +3 -1
  28. package/dist/domains/hardware/rgb/RGB.const.d.ts +4 -0
  29. package/dist/domains/hardware/rgb/RGB.const.js +5 -1
  30. package/dist/domains/hardware/rgb/RGB.schema.d.ts +4 -0
  31. package/dist/domains/hardware/rgb/RGB.schema.js +2 -1
  32. package/dist/domains/hardware/rgb/RGB.types.d.ts +2 -1
  33. package/dist/domains/hardware/sound/Sound.const.d.ts +3 -0
  34. package/dist/domains/hardware/sound/Sound.const.js +4 -1
  35. package/dist/domains/hardware/sound/Sound.schema.d.ts +3 -0
  36. package/dist/domains/hardware/sound/Sound.schema.js +2 -1
  37. package/dist/domains/hardware/sound/Sound.types.d.ts +2 -1
  38. package/dist/domains/hardware/steering-wheel/SteeringWheel.const.d.ts +4 -0
  39. package/dist/domains/hardware/steering-wheel/SteeringWheel.const.js +7 -0
  40. package/dist/domains/hardware/steering-wheel/SteeringWheel.schema.d.ts +4 -0
  41. package/dist/domains/hardware/steering-wheel/SteeringWheel.schema.js +3 -1
  42. package/dist/domains/hardware/steering-wheel/SteeringWheel.types.d.ts +2 -1
  43. package/dist/domains/player/Player.schema.d.ts +2 -4
  44. package/dist/domains/player/Player.schema.js +3 -6
  45. package/dist/domains/powerUp/PowerUp.schema.d.ts +117 -18
  46. package/dist/domains/racingTeam/RacingTeam.schema.d.ts +77 -3
  47. package/dist/domains/racingTeam/RacingTeam.schema.js +18 -4
  48. package/dist/domains/racingTeam/RacingTeam.types.d.ts +4 -1
  49. package/dist/domains/session/Session.schema.d.ts +5 -0
  50. package/dist/domains/session/Session.schema.js +4 -1
  51. package/dist/domains/socket/index.d.ts +1 -0
  52. package/dist/domains/socket/index.js +1 -0
  53. package/dist/domains/socket/screen/SocketScreenServerToClientEventsParams.d.ts +14 -0
  54. package/dist/domains/socket/screen/SocketScreenServerToClientEventsParams.js +2 -0
  55. package/dist/domains/socket/screen/index.d.ts +1 -0
  56. package/dist/domains/socket/screen/index.js +17 -0
  57. package/dist/domains/ticketing/Ticketing.schema.d.ts +4 -0
  58. package/dist/domains/ticketing/Ticketing.schema.js +2 -0
  59. package/dist/domains/user/User.schema.d.ts +65 -6
  60. package/dist/domains/user/User.schema.js +52 -11
  61. package/dist/domains/user/User.types.d.ts +7 -1
  62. package/docs/TICKETING_AND_PURCHASE_FLOW.md +110 -0
  63. package/package.json +1 -1
  64. package/src/domains/command/Command.schema.ts +30 -12
  65. package/src/domains/command/Command.types.ts +4 -0
  66. package/src/domains/hardware/KartHardwareState.schema.ts +4 -4
  67. package/src/domains/hardware/KartHardwareState.types.ts +4 -0
  68. package/src/domains/hardware/ModuleStatus.schema.ts +4 -0
  69. package/src/domains/hardware/ballSensor/BallSensor.const.ts +6 -0
  70. package/src/domains/hardware/ballSensor/BallSensor.schema.ts +3 -1
  71. package/src/domains/hardware/ballSensor/BallSensor.types.ts +2 -0
  72. package/src/domains/hardware/flag/Flag.const.ts +8 -0
  73. package/src/domains/hardware/flag/Flag.schema.ts +6 -2
  74. package/src/domains/hardware/flag/Flag.types.ts +2 -0
  75. package/src/domains/hardware/index.ts +2 -1
  76. package/src/domains/hardware/lights/Lights.const.ts +5 -0
  77. package/src/domains/hardware/lights/Lights.schema.ts +7 -1
  78. package/src/domains/hardware/lights/Lights.types.ts +9 -1
  79. package/src/domains/hardware/rgb/RGB.const.ts +5 -0
  80. package/src/domains/hardware/rgb/RGB.schema.ts +3 -1
  81. package/src/domains/hardware/rgb/RGB.types.ts +2 -0
  82. package/src/domains/hardware/sound/Sound.const.ts +4 -0
  83. package/src/domains/hardware/sound/Sound.schema.ts +3 -1
  84. package/src/domains/hardware/sound/Sound.types.ts +3 -1
  85. package/src/domains/hardware/steering-wheel/SteeringWheel.const.ts +4 -0
  86. package/src/domains/hardware/steering-wheel/SteeringWheel.schema.ts +3 -0
  87. package/src/domains/hardware/steering-wheel/SteeringWheel.types.ts +3 -1
  88. package/src/domains/player/Player.schema.ts +2 -6
  89. package/src/domains/racingTeam/RacingTeam.schema.ts +20 -3
  90. package/src/domains/racingTeam/RacingTeam.types.ts +7 -0
  91. package/src/domains/session/Session.schema.ts +4 -0
  92. package/src/domains/socket/index.ts +1 -0
  93. package/src/domains/socket/screen/SocketScreenServerToClientEventsParams.ts +19 -0
  94. package/src/domains/socket/screen/index.ts +1 -0
  95. package/src/domains/ticketing/Ticketing.schema.ts +2 -0
  96. package/src/domains/user/User.schema.ts +60 -13
  97. package/src/domains/user/User.types.ts +17 -1
@@ -8,7 +8,8 @@ export * from './lights';
8
8
  export * from './ModuleName.const';
9
9
  export * from './ModuleStatus.schema';
10
10
  export * from './ModuleStatus.types';
11
- export * from './KartHardwareState.schema'; // Added
11
+ export * from './KartHardwareState.schema';
12
+ export * from './KartHardwareState.types';
12
13
  export * from './rgb';
13
14
  export * from './screen';
14
15
  export * from './sound';
@@ -9,3 +9,8 @@ export const LIGHTS_EFFECT = {
9
9
  RED_FLAG: 'RED_FLAG',
10
10
  PULSE: 'PULSE',
11
11
  } as const;
12
+
13
+ export const LIGHTS_ACTION_COMMAND = {
14
+ SHOW_COLOR: 'ShowColor',
15
+ SHOW_EFFECT: 'ShowEffect',
16
+ } as const;
@@ -1,5 +1,7 @@
1
1
  import { z } from 'zod';
2
- import { LIGHTS_EFFECT } from './Lights.const';
2
+ import { LIGHTS_EFFECT, LIGHTS_ACTION_COMMAND } from './Lights.const';
3
+
4
+ export const lightsActionCommandSchema = z.enum(LIGHTS_ACTION_COMMAND);
3
5
 
4
6
  export const lightsEffectSchema = z.enum(LIGHTS_EFFECT);
5
7
 
@@ -14,3 +16,7 @@ export const showLightsEffectParamsSchema = z.object({
14
16
  effect: lightsEffectSchema,
15
17
  timeDuration: z.number().min(1).max(25),
16
18
  });
19
+
20
+ export const lightsModuleStatusSchema = z.object({
21
+ currentEffect: lightsEffectSchema.nullable(),
22
+ });
@@ -1,6 +1,14 @@
1
1
  import { z } from 'zod';
2
- import { lightsEffectSchema, showLightsColorParamsSchema, showLightsEffectParamsSchema } from './Lights.schema';
2
+ import {
3
+ lightsActionCommandSchema,
4
+ lightsEffectSchema,
5
+ lightsModuleStatusSchema,
6
+ showLightsColorParamsSchema,
7
+ showLightsEffectParamsSchema,
8
+ } from './Lights.schema';
3
9
 
10
+ export type LightsActionCommand = z.infer<typeof lightsActionCommandSchema>;
4
11
  export type LightsEffect = z.infer<typeof lightsEffectSchema>;
12
+ export type LightsModuleStatus = z.infer<typeof lightsModuleStatusSchema>;
5
13
  export type ShowLightsColorParams = z.infer<typeof showLightsColorParamsSchema>;
6
14
  export type ShowLightsEffectParams = z.infer<typeof showLightsEffectParamsSchema>;
@@ -6,3 +6,8 @@ export const RGB_STATUS = {
6
6
  UNKNOWN: 'Unknown',
7
7
  ERROR: 'Error',
8
8
  } as const;
9
+
10
+ export const RGB_ACTION_COMMANDS = {
11
+ EXEC: 'Exec',
12
+ CONFIGURE: 'Configure',
13
+ } as const;
@@ -1,10 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { colorNameSchema } from '../../color';
3
3
  import { kartEffectSchema } from '../../hardware/kart-effect';
4
- import { RGB_STATUS } from './RGB.const';
4
+ import { RGB_STATUS, RGB_ACTION_COMMANDS } from './RGB.const';
5
5
 
6
6
  export const rgbStatusSchema = z.enum(RGB_STATUS);
7
7
 
8
+ export const rgbActionCommandSchema = z.enum(RGB_ACTION_COMMANDS);
9
+
8
10
  export const rgbModuleStatusSchema = z.object({
9
11
  rgbStatus: rgbStatusSchema,
10
12
  kartColor: colorNameSchema,
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import {
3
+ rgbActionCommandSchema,
3
4
  rgbConfigurationOptionsSchema,
4
5
  rgbModuleStatusSchema,
5
6
  rgbShowEffectOptionsSchema,
@@ -10,3 +11,4 @@ export type RGBStatus = z.infer<typeof rgbStatusSchema>;
10
11
  export type RGBModuleStatus = z.infer<typeof rgbModuleStatusSchema>;
11
12
  export type RGBConfigurationOptions = z.infer<typeof rgbConfigurationOptionsSchema>;
12
13
  export type RGBShowEffectOptions = z.infer<typeof rgbShowEffectOptionsSchema>;
14
+ export type RGBActionCommand = z.infer<typeof rgbActionCommandSchema>;
@@ -1,3 +1,7 @@
1
1
  export const PLAY_SOUND_DURATION = {
2
2
  INFINITE: 'infinite',
3
3
  } as const;
4
+
5
+ export const SOUND_ACTION_COMMAND = {
6
+ PLAY: 'Play',
7
+ } as const;
@@ -1,6 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  import { soundNameSchema } from '../../sounds'; // Import from domains/sounds
3
- import { PLAY_SOUND_DURATION } from './Sound.const';
3
+ import { PLAY_SOUND_DURATION, SOUND_ACTION_COMMAND } from './Sound.const';
4
+
5
+ export const soundActionCommandSchema = z.enum(SOUND_ACTION_COMMAND);
4
6
 
5
7
  export const playSoundOptionsSchema = z.object({
6
8
  soundName: soundNameSchema,
@@ -1,4 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { playSoundOptionsSchema } from './Sound.schema';
2
+ import { soundActionCommandSchema, playSoundOptionsSchema } from './Sound.schema';
3
+
4
+ export type SoundActionCommand = z.infer<typeof soundActionCommandSchema>;
3
5
 
4
6
  export type PlaySoundOptions = z.infer<typeof playSoundOptionsSchema>;
@@ -0,0 +1,4 @@
1
+ export const STEERING_WHEEL_ACTION_COMMAND = {
2
+ TURN_LED_ON: 'TurnLedOn',
3
+ TURN_LED_OFF: 'TurnLedOff',
4
+ } as const;
@@ -1,4 +1,7 @@
1
1
  import { z } from 'zod';
2
+ import { STEERING_WHEEL_ACTION_COMMAND } from './SteeringWheel.const';
3
+
4
+ export const steeringWheelActionCommandSchema = z.enum(STEERING_WHEEL_ACTION_COMMAND);
2
5
 
3
6
  export const steeringWheelModuleStatusSchema = z.object({
4
7
  isLeftButtonPressed: z.boolean(),
@@ -1,4 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { steeringWheelModuleStatusSchema } from './SteeringWheel.schema';
2
+ import { steeringWheelActionCommandSchema, steeringWheelModuleStatusSchema } from './SteeringWheel.schema';
3
+
4
+ export type SteeringWheelActionCommand = z.infer<typeof steeringWheelActionCommandSchema>;
3
5
 
4
6
  export type SteeringWheelModuleStatus = z.infer<typeof steeringWheelModuleStatusSchema>;
@@ -37,6 +37,8 @@ export const playerSchema = z.object({
37
37
  export const createPlayerSchema = playerSchema
38
38
  .pick({
39
39
  nickname: true,
40
+ ownerUserId: true,
41
+ isGuest: true,
40
42
  })
41
43
  .extend({
42
44
  birthDate: z.coerce.date(),
@@ -46,9 +48,3 @@ export const signWaiverSchema = z.object({
46
48
  signature: z.string().optional(), // Base64 or simply a boolean acceptance. Let's make it flexible.
47
49
  accepted: z.literal(true), // They must explicitly pass accepted: true
48
50
  });
49
-
50
- export const createMinorPlayerSchema = z.object({
51
- nickname: z.string().min(2).max(20),
52
- birthDate: z.coerce.date(),
53
- // For a minor, the signature is implicitly granted by the tutor calling this endpoint
54
- });
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { paginatedResponseSchema } from '../pagination';
3
3
  import { JOIN_REQUEST_STATUS, RACING_TEAM_ROLE } from './RacingTeam.const';
4
+ import { playerSchema } from '../player/Player.schema';
4
5
 
5
6
  // --- Team Schemas ---
6
7
 
@@ -44,25 +45,41 @@ export const paginatedRacingTeamSummarySchema = paginatedResponseSchema(racingTe
44
45
  export const joinRequestSchema = z.object({
45
46
  id: z.string(),
46
47
  racingTeamId: z.string(),
47
- userId: z.string(),
48
+ playerId: z.string(),
48
49
  status: z.enum(JOIN_REQUEST_STATUS),
49
50
  createdAt: z.date(),
50
51
  updatedAt: z.date(),
51
52
  });
52
53
 
53
54
  export const teamMemberSchema = z.object({
55
+ id: z.string(),
54
56
  racingTeamId: z.string(),
55
- userId: z.string(),
57
+ playerId: z.string(),
58
+ role: z.enum(RACING_TEAM_ROLE),
59
+ joinedAt: z.date(),
60
+ });
61
+
62
+ export const teamMemberWithPlayerSchema = playerSchema.extend({
56
63
  role: z.enum(RACING_TEAM_ROLE),
57
64
  joinedAt: z.date(),
58
65
  });
59
66
 
67
+ export const racingTeamWithMembersSchema = racingTeamSchema.extend({
68
+ members: z.array(teamMemberWithPlayerSchema),
69
+ });
70
+
60
71
  export const createJoinRequestSchema = z.object({
61
72
  racingTeamId: z.string(),
73
+ playerId: z.string(),
62
74
  });
63
75
 
64
76
  export const answerJoinRequestSchema = z.object({
65
77
  racingTeamId: z.string(),
66
- targetUserId: z.string(),
78
+ targetPlayerId: z.string(),
67
79
  accepted: z.boolean(),
68
80
  });
81
+
82
+ export const addTeamMemberSchema = z.object({
83
+ nickname: z.string().min(2).max(20),
84
+ birthDate: z.coerce.date(),
85
+ });
@@ -6,10 +6,13 @@ import {
6
6
  joinRequestSchema,
7
7
  paginatedRacingTeamSchema,
8
8
  paginatedRacingTeamSummarySchema,
9
+ racingTeamWithMembersSchema,
9
10
  racingTeamSchema,
10
11
  racingTeamSummarySchema,
12
+ teamMemberWithPlayerSchema,
11
13
  teamMemberSchema,
12
14
  updateRacingTeamSchema,
15
+ addTeamMemberSchema,
13
16
  } from './RacingTeam.schema';
14
17
 
15
18
  export type RacingTeam = z.infer<typeof racingTeamSchema>;
@@ -23,3 +26,7 @@ export type JoinRequest = z.infer<typeof joinRequestSchema>;
23
26
  export type TeamMember = z.infer<typeof teamMemberSchema>;
24
27
  export type CreateJoinRequest = z.infer<typeof createJoinRequestSchema>;
25
28
  export type AnswerJoinRequest = z.infer<typeof answerJoinRequestSchema>;
29
+
30
+ export type TeamMemberWithPlayer = z.infer<typeof teamMemberWithPlayerSchema>;
31
+ export type RacingTeamWithMembers = z.infer<typeof racingTeamWithMembersSchema>;
32
+ export type AddTeamMember = z.infer<typeof addTeamMemberSchema>;
@@ -43,6 +43,10 @@ export const joinSessionSchema = z.object({
43
43
  birthDate: z.coerce.date(),
44
44
  });
45
45
 
46
+ export const addExistingPlayersSchema = z.object({
47
+ playerIds: z.array(z.uuidv4()).min(1),
48
+ });
49
+
46
50
  export const updateSessionStatusSchema = z.object({
47
51
  status: sessionStatusSchema,
48
52
  });
@@ -5,3 +5,4 @@ export * from './SocketHardwareModulesEventsParams';
5
5
  export * from './SocketHardwareOnDataEventsParams';
6
6
  export * from './SocketPowerUpEventsParams';
7
7
  export * from './utils';
8
+ export * from './screen';
@@ -0,0 +1,19 @@
1
+ import type {
2
+ ScreenCountdownParams,
3
+ ScreenDebugViewInput,
4
+ ScreenFinishViewInput,
5
+ ScreenHomeViewInput,
6
+ ScreenUpdateGameViewInput,
7
+ } from '../../hardware';
8
+
9
+ /**
10
+ * Socket events from Raspberry Pi to Screen
11
+ */
12
+ export interface SocketScreenServerToClientEventsParams {
13
+ 'view:home': ScreenHomeViewInput;
14
+ 'view:countdown': ScreenCountdownParams;
15
+ 'game:sync_state': ScreenUpdateGameViewInput;
16
+ 'view:summary': ScreenFinishViewInput & { state: 'Victory' | 'Defeat' };
17
+ 'view:debug': ScreenDebugViewInput;
18
+ 'view:instruction_video': Record<string, never>;
19
+ }
@@ -0,0 +1 @@
1
+ export * from './SocketScreenServerToClientEventsParams';
@@ -85,6 +85,8 @@ export const gameTurnTaskSchema = z.object({
85
85
 
86
86
  export const gameTurnSchema = z.object({
87
87
  id: z.string(),
88
+ turnNumber: z.number().int().positive(),
89
+ groupName: z.string().optional(),
88
90
  purchaseId: z.string(),
89
91
  sessionId: z.string().optional(),
90
92
  leaderPlayerId: z.string(),
@@ -7,15 +7,27 @@ export const userTypeSchema = z.enum(USER_TYPE);
7
7
  export const PHONE_REGEX = /^([+]?[\\s0-9]+)?(\\d{3}|[(]?[0-9]+[)])?([-]?[\\s]?[0-9])+$/;
8
8
  const MIN_PASSWORD_LENGTH = 6;
9
9
 
10
+ export const emailOrPhoneSchema = z
11
+ .string()
12
+ .min(1, 'Email or phone is required')
13
+ .refine(
14
+ (val) => {
15
+ const isEmail = z.email().safeParse(val).success;
16
+ const isPhone = PHONE_REGEX.test(val);
17
+ return isEmail || isPhone;
18
+ },
19
+ { message: 'Must be a valid email or phone number' },
20
+ );
21
+
10
22
  const baseUserObj = z.object({
11
23
  id: z.uuidv4(),
12
24
 
13
25
  name: z.string(),
14
26
  lastName: z.string(),
15
27
 
16
- email: z.email().toLowerCase().optional(),
28
+ email: z.email().toLowerCase().optional().nullable(),
17
29
 
18
- phoneNumber: z.string().regex(PHONE_REGEX, 'Invalid phone number format').optional(),
30
+ phoneNumber: z.string().regex(PHONE_REGEX, 'Invalid phone number format').optional().nullable(),
19
31
 
20
32
  // --- ACCESS CONTROL ---
21
33
  role: userRoleSchema,
@@ -37,12 +49,57 @@ export const userSchema = baseUserObj.refine((data) => data.email || data.phoneN
37
49
  path: ['email', 'phoneNumber'],
38
50
  });
39
51
 
52
+ /**
53
+ * When a user registers, we don't have all the information, so we use this schema
54
+ */
55
+ export const initialUserSchema = baseUserObj.pick({
56
+ id: true,
57
+ email: true,
58
+ phoneNumber: true,
59
+ isEmailVerified: true,
60
+ isPhoneVerified: true,
61
+ type: true,
62
+ createdAt: true,
63
+ });
64
+
65
+ /**
66
+ * The schema for the user returned on login
67
+ */
68
+ export const authUserSchema = baseUserObj.extend({
69
+ authToken: z.string(),
70
+ });
71
+
40
72
  export const userWithPasswordSchema = userSchema.and(
41
73
  z.object({
42
74
  password: z.string().min(MIN_PASSWORD_LENGTH),
43
75
  }),
44
76
  );
45
77
 
78
+ export const userInitialRegistrationSchema = z.object({
79
+ emailOrPhone: emailOrPhoneSchema,
80
+ password: z.string().min(MIN_PASSWORD_LENGTH, `Password must be at least ${MIN_PASSWORD_LENGTH} characters`),
81
+ });
82
+
83
+ export const userVerifySchema = z.object({
84
+ emailOrPhone: emailOrPhoneSchema,
85
+ code: z.string().min(6, 'Code must be at least 6 characters').max(10, 'Code is too long'),
86
+ });
87
+
88
+ export const userCompleteProfileSchema = baseUserObj
89
+ .pick({
90
+ name: true,
91
+ })
92
+ .extend({
93
+ lastName: z.string().optional(),
94
+ nickname: z.string().min(2),
95
+ birthDate: z.coerce.date(),
96
+ waiverSignature: z.boolean().refine((val) => val === true, {
97
+ message: 'You must accept the waiver signature',
98
+ }),
99
+ teamName: z.string().optional(),
100
+ });
101
+
102
+ // Deprecated in favor of multi-step registration
46
103
  export const userRegistrationInputSchema = baseUserObj
47
104
  .pick({
48
105
  name: true,
@@ -61,16 +118,6 @@ export const userRegistrationInputSchema = baseUserObj
61
118
  });
62
119
 
63
120
  export const userLoginInputSchema = z.object({
64
- emailOrPhone: z
65
- .string()
66
- .min(1, 'Email or phone is required')
67
- .refine(
68
- (val) => {
69
- const isEmail = z.email().safeParse(val).success;
70
- const isPhone = PHONE_REGEX.test(val);
71
- return isEmail || isPhone;
72
- },
73
- { message: 'Must be a valid email or phone number' },
74
- ),
121
+ emailOrPhone: emailOrPhoneSchema,
75
122
  password: z.string().min(MIN_PASSWORD_LENGTH, `Password must be at least ${MIN_PASSWORD_LENGTH} characters`),
76
123
  });
@@ -1,6 +1,22 @@
1
1
  import { z } from 'zod';
2
- import { userSchema, userTypeSchema, userWithPasswordSchema } from './User.schema';
2
+ import {
3
+ authUserSchema,
4
+ initialUserSchema,
5
+ userCompleteProfileSchema,
6
+ userInitialRegistrationSchema,
7
+ userLoginInputSchema,
8
+ userSchema,
9
+ userTypeSchema,
10
+ userVerifySchema,
11
+ userWithPasswordSchema,
12
+ } from './User.schema';
3
13
 
4
14
  export type UserType = z.infer<typeof userTypeSchema>;
5
15
  export type User = z.infer<typeof userSchema>;
6
16
  export type UserWithPassword = z.infer<typeof userWithPasswordSchema>;
17
+ export type AuthUser = z.infer<typeof authUserSchema>;
18
+ export type InitialUser = z.infer<typeof initialUserSchema>;
19
+ export type UserInitialRegistration = z.infer<typeof userInitialRegistrationSchema>;
20
+ export type UserVerify = z.infer<typeof userVerifySchema>;
21
+ export type UserCompleteProfile = z.infer<typeof userCompleteProfileSchema>;
22
+ export type UserLogin = z.infer<typeof userLoginInputSchema>;