@battle-racing/br-common-lib 4.1.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.
- package/.agents/rules/01-naming-and-typing.md +14 -0
- package/.agents/rules/02-architecture-and-routing.md +15 -0
- package/.agents/rules/03-state-and-data.md +10 -0
- package/.agents/rules/04-ui-and-styling.md +10 -0
- package/.agents/rules/05-code-quality-and-practices.md +10 -0
- package/dist/__deprecated__/constants/checkpoint-type.d.ts +6 -0
- package/dist/__deprecated__/constants/checkpoint-type.js +9 -0
- package/dist/__deprecated__/constants/hardware/base-hardware-status.d.ts +6 -0
- package/dist/__deprecated__/constants/hardware/base-hardware-status.js +9 -0
- package/dist/__deprecated__/constants/hardware/damage.d.ts +10 -0
- package/dist/__deprecated__/constants/hardware/damage.js +13 -0
- package/dist/__deprecated__/constants/hardware/flag-media-name.d.ts +63 -0
- package/dist/__deprecated__/constants/hardware/flag-media-name.js +71 -0
- package/dist/__deprecated__/constants/hardware/flag-status.d.ts +10 -0
- package/dist/__deprecated__/constants/hardware/flag-status.js +11 -0
- package/dist/__deprecated__/constants/hardware/index.js +25 -0
- package/dist/__deprecated__/constants/hardware/lights-effect.d.ts +10 -0
- package/dist/__deprecated__/constants/hardware/lights-effect.js +14 -0
- package/dist/__deprecated__/constants/hardware/rgb-status.d.ts +8 -0
- package/dist/__deprecated__/constants/hardware/rgb-status.js +11 -0
- package/dist/__deprecated__/constants/hardware/screen-status.d.ts +7 -0
- package/dist/__deprecated__/constants/hardware/screen-status.js +8 -0
- package/dist/__deprecated__/constants/hardware/screen-view.d.ts +9 -0
- package/dist/__deprecated__/constants/hardware/screen-view.js +12 -0
- package/dist/__deprecated__/constants/hardware/speed-status.d.ts +9 -0
- package/dist/__deprecated__/constants/hardware/speed-status.js +10 -0
- package/dist/__deprecated__/constants/index.js +25 -0
- package/dist/__deprecated__/constants/kart-status.d.ts +12 -0
- package/dist/__deprecated__/constants/kart-status.js +15 -0
- package/dist/__deprecated__/constants/module-name.d.ts +12 -0
- package/dist/__deprecated__/constants/module-name.js +15 -0
- package/dist/__deprecated__/constants/payment-provider.d.ts +5 -0
- package/dist/__deprecated__/constants/payment-provider.js +8 -0
- package/dist/__deprecated__/constants/payment-status.d.ts +7 -0
- package/dist/__deprecated__/constants/payment-status.js +10 -0
- package/dist/__deprecated__/constants/permission.d.ts +12 -0
- package/dist/__deprecated__/constants/permission.js +15 -0
- package/dist/__deprecated__/constants/racing-team-role.d.ts +5 -0
- package/dist/__deprecated__/constants/racing-team-role.js +8 -0
- package/dist/__deprecated__/constants/user-role.d.ts +5 -0
- package/dist/__deprecated__/constants/user-role.js +8 -0
- package/dist/__deprecated__/types/checkpoint/CheckpointType.d.ts +1 -1
- package/dist/__deprecated__/types/damage/DamageName.d.ts +1 -1
- package/dist/__deprecated__/types/hardware/ModuleName.d.ts +1 -1
- package/dist/__deprecated__/types/hardware/flag/FlagMediaName.d.ts +1 -1
- package/dist/__deprecated__/types/hardware/flag/FlagStatus.d.ts +1 -1
- package/dist/__deprecated__/types/hardware/lights/LightsEffect.d.ts +1 -1
- package/dist/__deprecated__/types/hardware/rgb/RGBStatus.d.ts +1 -1
- package/dist/__deprecated__/types/hardware/screen/ScreenFinishViewInput.d.ts +1 -1
- package/dist/__deprecated__/types/hardware/screen/ScreenStatus.d.ts +1 -1
- package/dist/__deprecated__/types/hardware/screen/ScreenView.d.ts +1 -1
- package/dist/__deprecated__/types/hardware/speed/SpeedStatus.d.ts +1 -1
- package/dist/__deprecated__/types/kart/KartStatus.d.ts +1 -1
- package/dist/__deprecated__/types/racingTeam/RacingTeamMembership.schema.js +1 -1
- package/dist/__deprecated__/types/role/Permission.d.ts +1 -1
- package/dist/__deprecated__/types/role/UserRole.d.ts +1 -1
- package/dist/__deprecated__/types/ticketing/GameTurn.schema.d.ts +9 -9
- package/dist/__deprecated__/types/ticketing/GameTurn.schema.js +2 -2
- package/dist/__deprecated__/types/ticketing/GameTurnTask.schema.d.ts +2 -2
- package/dist/__deprecated__/types/ticketing/PaymentProvider.d.ts +1 -1
- package/dist/__deprecated__/types/ticketing/ticketing.schemas.d.ts +1 -2
- package/dist/__deprecated__/types/ticketing/ticketing.schemas.js +0 -1
- package/dist/__deprecated__/types/user/user.schema.js +1 -1
- package/dist/domains/damage/Damage.schema.js +4 -3
- package/dist/domains/game/race/Race.schema.d.ts +2 -2
- package/dist/domains/hardware/KartHardwareState.schema.js +10 -10
- package/dist/domains/hardware/screen/Screen.schema.d.ts +0 -52
- package/dist/domains/hardware/screen/Screen.schema.js +5 -9
- package/dist/domains/hardware/screen/Screen.types.d.ts +2 -1
- package/dist/domains/hardware/screen/ScreenDebug.schema.d.ts +53 -0
- package/dist/domains/hardware/screen/ScreenDebug.schema.js +8 -0
- package/dist/domains/hardware/screen/index.d.ts +1 -0
- package/dist/domains/hardware/screen/index.js +1 -0
- package/dist/domains/index.d.ts +2 -0
- package/dist/domains/index.js +2 -0
- package/dist/domains/kart/Kart.schema.js +2 -2
- package/dist/domains/player/Player.const.d.ts +4 -0
- package/dist/domains/player/Player.const.js +7 -0
- package/dist/domains/player/Player.schema.d.ts +53 -0
- package/dist/domains/player/Player.schema.js +47 -0
- package/dist/domains/player/Player.types.d.ts +6 -0
- package/dist/domains/player/Player.types.js +2 -0
- package/dist/domains/player/index.d.ts +3 -0
- package/dist/domains/player/index.js +19 -0
- package/dist/domains/role/Role.const.d.ts +1 -0
- package/dist/domains/role/Role.const.js +1 -0
- package/dist/domains/role/Role.schema.d.ts +1 -0
- package/dist/domains/session/Session.const.d.ts +8 -0
- package/dist/domains/session/Session.const.js +11 -0
- package/dist/domains/session/Session.schema.d.ts +198 -0
- package/dist/domains/session/Session.schema.js +60 -0
- package/dist/domains/session/Session.types.d.ts +10 -0
- package/dist/domains/session/Session.types.js +2 -0
- package/dist/domains/session/index.d.ts +3 -0
- package/dist/domains/session/index.js +19 -0
- package/dist/domains/ticketing/Ticketing.const.d.ts +5 -0
- package/dist/domains/ticketing/Ticketing.const.js +6 -1
- package/dist/domains/ticketing/Ticketing.schema.d.ts +55 -34
- package/dist/domains/ticketing/Ticketing.schema.js +31 -26
- package/dist/domains/ticketing/Ticketing.types.d.ts +2 -3
- package/dist/domains/user/User.schema.d.ts +38 -9
- package/dist/domains/user/User.schema.js +49 -8
- package/docs/USER_VS_PLAYER.md +87 -0
- package/package.json +1 -1
- package/src/__deprecated__/constants/hardware/index.ts +9 -0
- package/src/__deprecated__/constants/index.ts +9 -0
- package/src/__deprecated__/types/checkpoint/CheckpointType.ts +1 -1
- package/src/__deprecated__/types/damage/DamageName.ts +1 -1
- package/src/__deprecated__/types/hardware/ModuleName.ts +1 -1
- package/src/__deprecated__/types/hardware/flag/FlagMediaName.ts +1 -1
- package/src/__deprecated__/types/hardware/flag/FlagStatus.ts +1 -1
- package/src/__deprecated__/types/hardware/lights/LightsEffect.ts +1 -1
- package/src/__deprecated__/types/hardware/rgb/RGBStatus.ts +1 -1
- package/src/__deprecated__/types/hardware/screen/ScreenFinishViewInput.ts +1 -1
- package/src/__deprecated__/types/hardware/screen/ScreenStatus.ts +1 -1
- package/src/__deprecated__/types/hardware/screen/ScreenView.ts +1 -1
- package/src/__deprecated__/types/hardware/speed/SpeedStatus.ts +1 -1
- package/src/__deprecated__/types/kart/KartStatus.ts +1 -1
- package/src/__deprecated__/types/racingTeam/RacingTeamMembership.schema.ts +1 -1
- package/src/__deprecated__/types/role/Permission.ts +1 -1
- package/src/__deprecated__/types/role/UserRole.ts +1 -1
- package/src/__deprecated__/types/ticketing/GameTurn.schema.ts +2 -2
- package/src/__deprecated__/types/ticketing/PaymentProvider.ts +1 -1
- package/src/__deprecated__/types/ticketing/ticketing.schemas.ts +0 -1
- package/src/__deprecated__/types/user/user.schema.ts +1 -1
- package/src/domains/damage/Damage.schema.ts +2 -1
- package/src/domains/hardware/KartHardwareState.schema.ts +5 -5
- package/src/domains/hardware/screen/Screen.schema.ts +2 -7
- package/src/domains/hardware/screen/Screen.types.ts +2 -1
- package/src/domains/hardware/screen/ScreenDebug.schema.ts +6 -0
- package/src/domains/hardware/screen/index.ts +1 -0
- package/src/domains/index.ts +2 -0
- package/src/domains/kart/Kart.schema.ts +1 -1
- package/src/domains/player/Player.const.ts +4 -0
- package/src/domains/player/Player.schema.ts +54 -0
- package/src/domains/player/Player.types.ts +8 -0
- package/src/domains/player/index.ts +3 -0
- package/src/domains/role/Role.const.ts +1 -0
- package/src/domains/session/Session.const.ts +8 -0
- package/src/domains/session/Session.schema.ts +74 -0
- package/src/domains/session/Session.types.ts +20 -0
- package/src/domains/session/index.ts +3 -0
- package/src/domains/ticketing/Ticketing.const.ts +6 -0
- package/src/domains/ticketing/Ticketing.schema.ts +38 -27
- package/src/domains/ticketing/Ticketing.types.ts +2 -4
- package/src/domains/user/User.schema.ts +64 -7
- package/br-common-lib.code-workspace +0 -19
- /package/{src/constants/hardware/index.ts → dist/__deprecated__/constants/hardware/index.d.ts} +0 -0
- /package/{src/constants/index.ts → dist/__deprecated__/constants/index.d.ts} +0 -0
- /package/{MIGRATION_GUIDE.md → docs/MIGRATION_GUIDE.md} +0 -0
- /package/{REFACTOR_README.md → docs/REFACTOR_README.md} +0 -0
- /package/src/{constants → __deprecated__/constants}/checkpoint-type.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/hardware/base-hardware-status.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/hardware/damage.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/hardware/flag-media-name.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/hardware/flag-status.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/hardware/lights-effect.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/hardware/rgb-status.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/hardware/screen-status.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/hardware/screen-view.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/hardware/speed-status.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/kart-status.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/module-name.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/payment-provider.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/payment-status.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/permission.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/racing-team-role.ts +0 -0
- /package/src/{constants → __deprecated__/constants}/user-role.ts +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PLAYER_TYPE } from './Player.const';
|
|
3
|
+
|
|
4
|
+
export const playerTypeSchema = z.enum(PLAYER_TYPE);
|
|
5
|
+
|
|
6
|
+
export const playerWaiverStatusSchema = z.object({
|
|
7
|
+
isSigned: z.boolean().default(false),
|
|
8
|
+
waiverId: z.uuidv4().nullable().optional(),
|
|
9
|
+
templateVersion: z.string().optional(),
|
|
10
|
+
expiresAt: z.date().nullable().optional(),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const playerStatsSchema = z.object({
|
|
14
|
+
totalRaces: z.number().int().default(0),
|
|
15
|
+
bestTimeMs: z.number().int().nullable().optional(),
|
|
16
|
+
xp: z.number().int().default(0),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const playerSchema = z.object({
|
|
20
|
+
id: z.uuidv4(),
|
|
21
|
+
nickname: z.string().min(2).max(20),
|
|
22
|
+
avatarUrl: z.url().optional(),
|
|
23
|
+
birthDate: z.date(),
|
|
24
|
+
type: playerTypeSchema.default(PLAYER_TYPE.ADULT),
|
|
25
|
+
|
|
26
|
+
ownerUserId: z.uuidv4().nullable().optional(),
|
|
27
|
+
isGuest: z.boolean().default(true),
|
|
28
|
+
waiver: playerWaiverStatusSchema,
|
|
29
|
+
|
|
30
|
+
// TODO: Add the stats here, to aovid extra queries
|
|
31
|
+
stats: playerStatsSchema.optional().nullable(),
|
|
32
|
+
|
|
33
|
+
createdAt: z.date(),
|
|
34
|
+
updatedAt: z.date(),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export const createPlayerSchema = playerSchema
|
|
38
|
+
.pick({
|
|
39
|
+
nickname: true,
|
|
40
|
+
})
|
|
41
|
+
.extend({
|
|
42
|
+
birthDate: z.coerce.date(),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const signWaiverSchema = z.object({
|
|
46
|
+
signature: z.string().optional(), // Base64 or simply a boolean acceptance. Let's make it flexible.
|
|
47
|
+
accepted: z.literal(true), // They must explicitly pass accepted: true
|
|
48
|
+
});
|
|
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
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { playerSchema, playerStatsSchema, playerTypeSchema, playerWaiverStatusSchema } from './Player.schema';
|
|
3
|
+
|
|
4
|
+
export type PlayerType = z.infer<typeof playerTypeSchema>;
|
|
5
|
+
export type PlayerStats = z.infer<typeof playerStatsSchema>;
|
|
6
|
+
export type PlayerWaiverStatus = z.infer<typeof playerWaiverStatusSchema>;
|
|
7
|
+
|
|
8
|
+
export type Player = z.infer<typeof playerSchema>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SESSION_STATUS } from './Session.const';
|
|
3
|
+
import { gameTypeSchema } from '../game/Game.schema';
|
|
4
|
+
import { playerSchema } from '../player/Player.schema';
|
|
5
|
+
import { gameTicketSchema, gameTurnSchema } from '../ticketing/Ticketing.schema';
|
|
6
|
+
|
|
7
|
+
export const sessionStatusSchema = z.enum(SESSION_STATUS);
|
|
8
|
+
|
|
9
|
+
export const sessionTicketSchema = z.object({
|
|
10
|
+
quantity: z.number().int().positive(),
|
|
11
|
+
type: gameTypeSchema,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const gameSessionSchema = z.object({
|
|
15
|
+
id: z.uuidv4(),
|
|
16
|
+
code: z.string().length(6), // 6-char alphanumeric
|
|
17
|
+
contactPhone: z.string().optional(),
|
|
18
|
+
userId: z.string().optional().nullable(),
|
|
19
|
+
|
|
20
|
+
tickets: z.array(gameTicketSchema).optional(),
|
|
21
|
+
playerIds: z.array(z.uuidv4()),
|
|
22
|
+
linkedPurchaseId: z.string().optional(),
|
|
23
|
+
|
|
24
|
+
status: sessionStatusSchema.default(SESSION_STATUS.REGISTRATION),
|
|
25
|
+
|
|
26
|
+
createdAt: z.date(),
|
|
27
|
+
updatedAt: z.date(),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const gameSessionWithPlayersSchema = gameSessionSchema.extend({
|
|
31
|
+
players: z.array(playerSchema),
|
|
32
|
+
turns: z.array(gameTurnSchema).optional(),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const createSessionInputSchema = z.object({
|
|
36
|
+
contactPhone: z.string().optional(),
|
|
37
|
+
userId: z.string().optional().nullable(),
|
|
38
|
+
tickets: z.array(sessionTicketSchema).min(1),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const joinSessionSchema = z.object({
|
|
42
|
+
nickname: z.string().min(2),
|
|
43
|
+
birthDate: z.coerce.date(),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const updateSessionStatusSchema = z.object({
|
|
47
|
+
status: sessionStatusSchema,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const createGameTurnInputSchema = z.object({
|
|
51
|
+
assignments: z
|
|
52
|
+
.array(
|
|
53
|
+
z.object({
|
|
54
|
+
ticketId: z.string(),
|
|
55
|
+
playerId: z.uuidv4(),
|
|
56
|
+
}),
|
|
57
|
+
)
|
|
58
|
+
.min(1),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const assignSessionTicketsInputSchema = z.object({
|
|
62
|
+
assignments: z
|
|
63
|
+
.array(
|
|
64
|
+
z.object({
|
|
65
|
+
ticketId: z.string(),
|
|
66
|
+
playerId: z.uuidv4(),
|
|
67
|
+
}),
|
|
68
|
+
)
|
|
69
|
+
.min(1),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const bulkCreateGameTurnSchema = z.object({
|
|
73
|
+
turns: z.array(createGameTurnInputSchema).min(1),
|
|
74
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
assignSessionTicketsInputSchema,
|
|
4
|
+
createSessionInputSchema,
|
|
5
|
+
gameSessionSchema,
|
|
6
|
+
gameSessionWithPlayersSchema,
|
|
7
|
+
joinSessionSchema,
|
|
8
|
+
bulkCreateGameTurnSchema,
|
|
9
|
+
sessionStatusSchema,
|
|
10
|
+
sessionTicketSchema,
|
|
11
|
+
} from './Session.schema';
|
|
12
|
+
|
|
13
|
+
export type SessionStatus = z.infer<typeof sessionStatusSchema>;
|
|
14
|
+
export type SessionTicket = z.infer<typeof sessionTicketSchema>;
|
|
15
|
+
export type GameSession = z.infer<typeof gameSessionSchema>;
|
|
16
|
+
export type GameSessionWithPlayers = z.infer<typeof gameSessionWithPlayersSchema>;
|
|
17
|
+
export type CreateSessionInput = z.infer<typeof createSessionInputSchema>;
|
|
18
|
+
export type AssignSessionTicketsInput = z.infer<typeof assignSessionTicketsInputSchema>;
|
|
19
|
+
export type JoinSessionInput = z.infer<typeof joinSessionSchema>;
|
|
20
|
+
export type BulkCreateGameTurnInput = z.infer<typeof bulkCreateGameTurnSchema>;
|
|
@@ -5,9 +5,11 @@ import {
|
|
|
5
5
|
GAME_TURN_STATUS,
|
|
6
6
|
GAME_TURN_TASK_STATUS,
|
|
7
7
|
GAME_TURN_TASK_TYPE,
|
|
8
|
+
PURCHASE_STATUS,
|
|
8
9
|
TICKET_TYPE,
|
|
9
10
|
TICKET_USER_TYPE,
|
|
10
11
|
} from './Ticketing.const';
|
|
12
|
+
import { gameTypeSchema } from '../game';
|
|
11
13
|
|
|
12
14
|
export const gameTicketStatusSchema = z.enum(GAME_TICKET_STATUS);
|
|
13
15
|
export const ticketUserTypeSchema = z.enum(TICKET_USER_TYPE);
|
|
@@ -15,11 +17,11 @@ export const ticketTypeSchema = z.enum(TICKET_TYPE);
|
|
|
15
17
|
export const ticketSummarySchema = z.record(ticketTypeSchema, z.number());
|
|
16
18
|
|
|
17
19
|
export const gameTicketSchema = z.object({
|
|
18
|
-
id: z.
|
|
20
|
+
id: z.uuidv4(),
|
|
19
21
|
purchaseId: z.string(),
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
sessionId: z.string().optional().nullable(),
|
|
23
|
+
gameTurnId: z.string().optional().nullable(),
|
|
24
|
+
playerId: z.uuidv4().optional().nullable(),
|
|
23
25
|
status: gameTicketStatusSchema,
|
|
24
26
|
type: ticketTypeSchema.default(TICKET_TYPE.RACE),
|
|
25
27
|
createdAt: z.date(),
|
|
@@ -27,34 +29,42 @@ export const gameTicketSchema = z.object({
|
|
|
27
29
|
completedAt: z.date().optional(),
|
|
28
30
|
});
|
|
29
31
|
|
|
32
|
+
export const purchaseStatusSchema = z.enum(PURCHASE_STATUS);
|
|
33
|
+
|
|
34
|
+
export const purchaseItemSchema = z.object({
|
|
35
|
+
ticketType: gameTypeSchema,
|
|
36
|
+
quantity: z.number().int().positive(),
|
|
37
|
+
priceCents: z.number().int().nonnegative(),
|
|
38
|
+
});
|
|
39
|
+
|
|
30
40
|
export const purchaseSchema = z.object({
|
|
31
|
-
id: z.
|
|
41
|
+
id: z.uuidv4(),
|
|
32
42
|
purchaseNumber: z.number(),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
|
|
44
|
+
// Buyer can be null for Guest/On-Site purchases
|
|
45
|
+
buyerUserId: z.string().optional().nullable(),
|
|
46
|
+
guestName: z.string().optional().nullable(),
|
|
47
|
+
guestContact: z.string().optional().nullable(),
|
|
48
|
+
|
|
49
|
+
items: z.array(purchaseItemSchema),
|
|
50
|
+
totalAmountCents: z.number().min(0),
|
|
51
|
+
status: purchaseStatusSchema.default(PURCHASE_STATUS.PENDING),
|
|
52
|
+
|
|
53
|
+
// Deprecated fields (kept for backward compatibility if needed, or remove if safe)
|
|
54
|
+
totalTickets: z.number().optional(),
|
|
55
|
+
ticketType: ticketTypeSchema.optional(),
|
|
56
|
+
|
|
37
57
|
paymentData: z.any().optional(),
|
|
38
58
|
createdAt: z.date(),
|
|
39
59
|
updatedAt: z.date(),
|
|
40
60
|
});
|
|
41
61
|
|
|
42
|
-
export const
|
|
43
|
-
.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
.
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
export const createPurchaseInternalSchema = purchaseSchema
|
|
51
|
-
.pick({
|
|
52
|
-
ticketType: true,
|
|
53
|
-
buyerUserId: true,
|
|
54
|
-
})
|
|
55
|
-
.extend({
|
|
56
|
-
ticketCount: z.number(),
|
|
57
|
-
});
|
|
62
|
+
export const createPurchaseInputSchema = z.object({
|
|
63
|
+
buyerUserId: z.string().optional(),
|
|
64
|
+
guestName: z.string().optional(),
|
|
65
|
+
guestContact: z.string().optional(),
|
|
66
|
+
items: z.array(purchaseItemSchema).min(1),
|
|
67
|
+
});
|
|
58
68
|
|
|
59
69
|
export const gameTurnStatusSchema = z.enum(GAME_TURN_STATUS);
|
|
60
70
|
|
|
@@ -76,9 +86,10 @@ export const gameTurnTaskSchema = z.object({
|
|
|
76
86
|
export const gameTurnSchema = z.object({
|
|
77
87
|
id: z.string(),
|
|
78
88
|
purchaseId: z.string(),
|
|
79
|
-
|
|
89
|
+
sessionId: z.string().optional(),
|
|
90
|
+
leaderPlayerId: z.string(),
|
|
80
91
|
gameTickets: z.array(z.string()),
|
|
81
|
-
|
|
92
|
+
playerIds: z.array(z.string()),
|
|
82
93
|
status: gameTurnStatusSchema,
|
|
83
94
|
tasks: z.array(gameTurnTaskSchema),
|
|
84
95
|
createdAt: z.date(),
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
createPurchasePublicSchema,
|
|
3
|
+
createPurchaseInputSchema,
|
|
5
4
|
gameTicketSchema,
|
|
6
5
|
gameTicketStatusSchema,
|
|
7
6
|
gameTurnCheckSchema,
|
|
@@ -23,8 +22,7 @@ export type TicketUserType = z.infer<typeof ticketUserTypeSchema>;
|
|
|
23
22
|
export type TicketSummary = z.infer<typeof ticketSummarySchema>;
|
|
24
23
|
|
|
25
24
|
export type Purchase = z.infer<typeof purchaseSchema>;
|
|
26
|
-
export type
|
|
27
|
-
export type CreatePurchaseInternalInput = z.infer<typeof createPurchaseInternalSchema>;
|
|
25
|
+
export type CreatePurchaseInput = z.infer<typeof createPurchaseInputSchema>;
|
|
28
26
|
|
|
29
27
|
export type GameTicket = z.infer<typeof gameTicketSchema>;
|
|
30
28
|
|
|
@@ -4,16 +4,73 @@ import { USER_TYPE } from './User.const';
|
|
|
4
4
|
|
|
5
5
|
export const userTypeSchema = z.enum(USER_TYPE);
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
7
|
+
export const PHONE_REGEX = /^([+]?[\\s0-9]+)?(\\d{3}|[(]?[0-9]+[)])?([-]?[\\s]?[0-9])+$/;
|
|
8
|
+
const MIN_PASSWORD_LENGTH = 6;
|
|
9
|
+
|
|
10
|
+
const baseUserObj = z.object({
|
|
11
|
+
id: z.uuidv4(),
|
|
12
|
+
|
|
9
13
|
name: z.string(),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
lastName: z.string(),
|
|
15
|
+
|
|
16
|
+
email: z.email().toLowerCase().optional(),
|
|
17
|
+
|
|
18
|
+
phoneNumber: z.string().regex(PHONE_REGEX, 'Invalid phone number format').optional(),
|
|
19
|
+
|
|
20
|
+
// --- ACCESS CONTROL ---
|
|
13
21
|
role: userRoleSchema,
|
|
14
22
|
type: userTypeSchema,
|
|
23
|
+
|
|
24
|
+
isActive: z.boolean().default(true),
|
|
25
|
+
// TODO: Implement mechanism to validate users later by email or phone
|
|
26
|
+
isEmailVerified: z.boolean().default(false),
|
|
27
|
+
isPhoneVerified: z.boolean().default(false),
|
|
28
|
+
|
|
29
|
+
defaultPlayerId: z.uuidv4().optional(),
|
|
30
|
+
|
|
31
|
+
createdAt: z.date(),
|
|
32
|
+
lastLoginAt: z.date().optional(),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const userSchema = baseUserObj.refine((data) => data.email || data.phoneNumber, {
|
|
36
|
+
message: 'User must have either an email or a phone number',
|
|
37
|
+
path: ['email', 'phoneNumber'],
|
|
15
38
|
});
|
|
16
39
|
|
|
17
|
-
export const userWithPasswordSchema = userSchema.
|
|
18
|
-
|
|
40
|
+
export const userWithPasswordSchema = userSchema.and(
|
|
41
|
+
z.object({
|
|
42
|
+
password: z.string().min(MIN_PASSWORD_LENGTH),
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export const userRegistrationInputSchema = baseUserObj
|
|
47
|
+
.pick({
|
|
48
|
+
name: true,
|
|
49
|
+
lastName: true,
|
|
50
|
+
email: true,
|
|
51
|
+
phoneNumber: true,
|
|
52
|
+
})
|
|
53
|
+
.extend({
|
|
54
|
+
password: z.string().min(6),
|
|
55
|
+
nickname: z.string().min(2),
|
|
56
|
+
birthDate: z.coerce.date(),
|
|
57
|
+
})
|
|
58
|
+
.refine((data) => data.email || data.phoneNumber, {
|
|
59
|
+
message: 'User must have either an email or a phone number',
|
|
60
|
+
path: ['email', 'phoneNumber'],
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
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
|
+
),
|
|
75
|
+
password: z.string().min(MIN_PASSWORD_LENGTH, `Password must be at least ${MIN_PASSWORD_LENGTH} characters`),
|
|
19
76
|
});
|
/package/{src/constants/hardware/index.ts → dist/__deprecated__/constants/hardware/index.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|