@battle-racing/br-common-lib 4.1.0 → 4.3.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/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 +4 -4
- package/dist/__deprecated__/types/ticketing/GameTurn.schema.js +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 +57 -0
- package/dist/domains/player/Player.schema.js +48 -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 +7 -0
- package/dist/domains/session/Session.const.js +10 -0
- package/dist/domains/session/Session.schema.d.ts +65 -0
- package/dist/domains/session/Session.schema.js +47 -0
- package/dist/domains/session/Session.types.d.ts +7 -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 +49 -34
- package/dist/domains/ticketing/Ticketing.schema.js +26 -26
- package/dist/domains/ticketing/Ticketing.types.d.ts +2 -3
- package/dist/domains/user/User.schema.d.ts +35 -11
- package/dist/domains/user/User.schema.js +47 -9
- 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 +55 -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 +7 -0
- package/src/domains/session/Session.schema.ts +58 -0
- package/src/domains/session/Session.types.ts +14 -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 +33 -27
- package/src/domains/ticketing/Ticketing.types.ts +2 -4
- package/src/domains/user/User.schema.ts +61 -8
- 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,65 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const sessionStatusSchema: z.ZodEnum<{
|
|
3
|
+
readonly CREATED: "CREATED";
|
|
4
|
+
readonly READY: "READY";
|
|
5
|
+
readonly STARTED: "STARTED";
|
|
6
|
+
readonly FINISHED: "FINISHED";
|
|
7
|
+
readonly CANCELLED: "CANCELLED";
|
|
8
|
+
}>;
|
|
9
|
+
export declare const sessionTicketSchema: z.ZodObject<{
|
|
10
|
+
quantity: z.ZodNumber;
|
|
11
|
+
type: z.ZodEnum<{
|
|
12
|
+
readonly Race: "Race";
|
|
13
|
+
readonly Battle: "Battle";
|
|
14
|
+
}>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export declare const gameSessionSchema: z.ZodObject<{
|
|
17
|
+
code: z.ZodString;
|
|
18
|
+
contactPhone: z.ZodOptional<z.ZodString>;
|
|
19
|
+
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";
|
|
25
|
+
}>;
|
|
26
|
+
}, z.core.$strip>>;
|
|
27
|
+
playerIds: z.ZodArray<z.ZodUUID>;
|
|
28
|
+
linkedPurchaseId: z.ZodOptional<z.ZodString>;
|
|
29
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
30
|
+
readonly CREATED: "CREATED";
|
|
31
|
+
readonly READY: "READY";
|
|
32
|
+
readonly STARTED: "STARTED";
|
|
33
|
+
readonly FINISHED: "FINISHED";
|
|
34
|
+
readonly CANCELLED: "CANCELLED";
|
|
35
|
+
}>>;
|
|
36
|
+
createdAt: z.ZodDate;
|
|
37
|
+
updatedAt: z.ZodDate;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
export declare const createSessionInputSchema: z.ZodObject<{
|
|
40
|
+
contactPhone: z.ZodOptional<z.ZodString>;
|
|
41
|
+
userId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
42
|
+
tickets: z.ZodArray<z.ZodObject<{
|
|
43
|
+
quantity: z.ZodNumber;
|
|
44
|
+
type: z.ZodEnum<{
|
|
45
|
+
readonly Race: "Race";
|
|
46
|
+
readonly Battle: "Battle";
|
|
47
|
+
}>;
|
|
48
|
+
}, z.core.$strip>>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export declare const joinSessionSchema: z.ZodObject<{
|
|
51
|
+
nickname: z.ZodString;
|
|
52
|
+
birthDate: z.ZodCoercedDate<unknown>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
export declare const createGameTurnInputSchema: z.ZodObject<{
|
|
55
|
+
assignments: z.ZodArray<z.ZodObject<{
|
|
56
|
+
ticketId: z.ZodString;
|
|
57
|
+
playerId: z.ZodUUID;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
export declare const assignSessionTicketsInputSchema: z.ZodObject<{
|
|
61
|
+
assignments: z.ZodArray<z.ZodObject<{
|
|
62
|
+
ticketId: z.ZodString;
|
|
63
|
+
playerId: z.ZodUUID;
|
|
64
|
+
}, z.core.$strip>>;
|
|
65
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assignSessionTicketsInputSchema = exports.createGameTurnInputSchema = exports.joinSessionSchema = exports.createSessionInputSchema = exports.gameSessionSchema = exports.sessionTicketSchema = exports.sessionStatusSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const Session_const_1 = require("./Session.const");
|
|
6
|
+
const Game_schema_1 = require("../game/Game.schema");
|
|
7
|
+
exports.sessionStatusSchema = zod_1.z.enum(Session_const_1.SESSION_STATUS);
|
|
8
|
+
exports.sessionTicketSchema = zod_1.z.object({
|
|
9
|
+
quantity: zod_1.z.number().int().positive(),
|
|
10
|
+
type: Game_schema_1.gameTypeSchema,
|
|
11
|
+
});
|
|
12
|
+
exports.gameSessionSchema = zod_1.z.object({
|
|
13
|
+
code: zod_1.z.string().length(6), // 6-char alphanumeric
|
|
14
|
+
contactPhone: zod_1.z.string().optional(),
|
|
15
|
+
userId: zod_1.z.string().optional().nullable(),
|
|
16
|
+
tickets: zod_1.z.array(exports.sessionTicketSchema),
|
|
17
|
+
playerIds: zod_1.z.array(zod_1.z.uuidv4()),
|
|
18
|
+
linkedPurchaseId: zod_1.z.string().optional(),
|
|
19
|
+
status: exports.sessionStatusSchema.default(Session_const_1.SESSION_STATUS.CREATED),
|
|
20
|
+
createdAt: zod_1.z.date(),
|
|
21
|
+
updatedAt: zod_1.z.date(),
|
|
22
|
+
});
|
|
23
|
+
exports.createSessionInputSchema = zod_1.z.object({
|
|
24
|
+
contactPhone: zod_1.z.string().optional(),
|
|
25
|
+
userId: zod_1.z.string().optional().nullable(),
|
|
26
|
+
tickets: zod_1.z.array(exports.sessionTicketSchema).min(1),
|
|
27
|
+
});
|
|
28
|
+
exports.joinSessionSchema = zod_1.z.object({
|
|
29
|
+
nickname: zod_1.z.string().min(2),
|
|
30
|
+
birthDate: zod_1.z.coerce.date(),
|
|
31
|
+
});
|
|
32
|
+
exports.createGameTurnInputSchema = zod_1.z.object({
|
|
33
|
+
assignments: zod_1.z
|
|
34
|
+
.array(zod_1.z.object({
|
|
35
|
+
ticketId: zod_1.z.string(),
|
|
36
|
+
playerId: zod_1.z.uuidv4(),
|
|
37
|
+
}))
|
|
38
|
+
.min(1),
|
|
39
|
+
});
|
|
40
|
+
exports.assignSessionTicketsInputSchema = zod_1.z.object({
|
|
41
|
+
assignments: zod_1.z
|
|
42
|
+
.array(zod_1.z.object({
|
|
43
|
+
ticketId: zod_1.z.string(),
|
|
44
|
+
playerId: zod_1.z.uuidv4(),
|
|
45
|
+
}))
|
|
46
|
+
.min(1),
|
|
47
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { assignSessionTicketsInputSchema, createSessionInputSchema, gameSessionSchema, sessionStatusSchema, sessionTicketSchema } from './Session.schema';
|
|
3
|
+
export type SessionStatus = z.infer<typeof sessionStatusSchema>;
|
|
4
|
+
export type SessionTicket = z.infer<typeof sessionTicketSchema>;
|
|
5
|
+
export type GameSession = z.infer<typeof gameSessionSchema>;
|
|
6
|
+
export type CreateSessionInput = z.infer<typeof createSessionInputSchema>;
|
|
7
|
+
export type AssignSessionTicketsInput = z.infer<typeof assignSessionTicketsInputSchema>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Session.const"), exports);
|
|
18
|
+
__exportStar(require("./Session.schema"), exports);
|
|
19
|
+
__exportStar(require("./Session.types"), exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GAME_TURN_TASK_STATUS = exports.GAME_TURN_TASK_TYPE = exports.GAME_TURN_CHECK = exports.GAME_TURN_STATUS = exports.TICKET_TYPE = exports.TICKET_USER_TYPE = exports.GAME_TICKET_STATUS = void 0;
|
|
3
|
+
exports.PURCHASE_STATUS = exports.GAME_TURN_TASK_STATUS = exports.GAME_TURN_TASK_TYPE = exports.GAME_TURN_CHECK = exports.GAME_TURN_STATUS = exports.TICKET_TYPE = exports.TICKET_USER_TYPE = exports.GAME_TICKET_STATUS = void 0;
|
|
4
4
|
exports.GAME_TICKET_STATUS = {
|
|
5
5
|
CREATED: 'created',
|
|
6
6
|
ASSIGNED: 'assigned',
|
|
@@ -39,3 +39,8 @@ exports.GAME_TURN_TASK_STATUS = {
|
|
|
39
39
|
PENDING: 'pending',
|
|
40
40
|
COMPLETED: 'completed',
|
|
41
41
|
};
|
|
42
|
+
exports.PURCHASE_STATUS = {
|
|
43
|
+
PENDING: 'pending',
|
|
44
|
+
PAID: 'paid',
|
|
45
|
+
CANCELLED: 'cancelled',
|
|
46
|
+
};
|
|
@@ -22,16 +22,11 @@ export declare const ticketSummarySchema: z.ZodRecord<z.ZodEnum<{
|
|
|
22
22
|
readonly SOCCER: "soccer";
|
|
23
23
|
}>, z.ZodNumber>;
|
|
24
24
|
export declare const gameTicketSchema: z.ZodObject<{
|
|
25
|
-
id: z.
|
|
25
|
+
id: z.ZodUUID;
|
|
26
26
|
purchaseId: z.ZodString;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
readonly LEADER: "leader";
|
|
31
|
-
readonly SUB_USER: "sub-user";
|
|
32
|
-
readonly EXISTING: "existing";
|
|
33
|
-
readonly GUEST: "guest";
|
|
34
|
-
}>;
|
|
27
|
+
sessionId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
28
|
+
gameTurnId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
29
|
+
playerId: z.ZodNullable<z.ZodOptional<z.ZodUUID>>;
|
|
35
30
|
status: z.ZodEnum<{
|
|
36
31
|
readonly CREATED: "created";
|
|
37
32
|
readonly ASSIGNED: "assigned";
|
|
@@ -47,13 +42,39 @@ export declare const gameTicketSchema: z.ZodObject<{
|
|
|
47
42
|
updatedAt: z.ZodDate;
|
|
48
43
|
completedAt: z.ZodOptional<z.ZodDate>;
|
|
49
44
|
}, z.core.$strip>;
|
|
45
|
+
export declare const purchaseStatusSchema: z.ZodEnum<{
|
|
46
|
+
readonly PENDING: "pending";
|
|
47
|
+
readonly PAID: "paid";
|
|
48
|
+
readonly CANCELLED: "cancelled";
|
|
49
|
+
}>;
|
|
50
|
+
export declare const purchaseItemSchema: z.ZodObject<{
|
|
51
|
+
ticketType: z.ZodEnum<{
|
|
52
|
+
readonly Race: "Race";
|
|
53
|
+
readonly Battle: "Battle";
|
|
54
|
+
}>;
|
|
55
|
+
quantity: z.ZodNumber;
|
|
56
|
+
priceCents: z.ZodNumber;
|
|
57
|
+
}, z.core.$strip>;
|
|
50
58
|
export declare const purchaseSchema: z.ZodObject<{
|
|
51
|
-
id: z.
|
|
59
|
+
id: z.ZodUUID;
|
|
52
60
|
purchaseNumber: z.ZodNumber;
|
|
53
|
-
buyerUserId: z.ZodString
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
buyerUserId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
62
|
+
items: z.ZodArray<z.ZodObject<{
|
|
63
|
+
ticketType: z.ZodEnum<{
|
|
64
|
+
readonly Race: "Race";
|
|
65
|
+
readonly Battle: "Battle";
|
|
66
|
+
}>;
|
|
67
|
+
quantity: z.ZodNumber;
|
|
68
|
+
priceCents: z.ZodNumber;
|
|
69
|
+
}, z.core.$strip>>;
|
|
70
|
+
totalAmountCents: z.ZodNumber;
|
|
71
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
72
|
+
readonly PENDING: "pending";
|
|
73
|
+
readonly PAID: "paid";
|
|
74
|
+
readonly CANCELLED: "cancelled";
|
|
75
|
+
}>>;
|
|
76
|
+
totalTickets: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
ticketType: z.ZodOptional<z.ZodEnum<{
|
|
57
78
|
readonly RACE: "race";
|
|
58
79
|
readonly BATTLE: "battle";
|
|
59
80
|
readonly SOCCER: "soccer";
|
|
@@ -62,22 +83,16 @@ export declare const purchaseSchema: z.ZodObject<{
|
|
|
62
83
|
createdAt: z.ZodDate;
|
|
63
84
|
updatedAt: z.ZodDate;
|
|
64
85
|
}, z.core.$strip>;
|
|
65
|
-
export declare const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
ticketType: z.ZodDefault<z.ZodEnum<{
|
|
76
|
-
readonly RACE: "race";
|
|
77
|
-
readonly BATTLE: "battle";
|
|
78
|
-
readonly SOCCER: "soccer";
|
|
79
|
-
}>>;
|
|
80
|
-
ticketCount: z.ZodNumber;
|
|
86
|
+
export declare const createPurchaseInputSchema: z.ZodObject<{
|
|
87
|
+
buyerUserId: z.ZodOptional<z.ZodString>;
|
|
88
|
+
items: z.ZodArray<z.ZodObject<{
|
|
89
|
+
ticketType: z.ZodEnum<{
|
|
90
|
+
readonly Race: "Race";
|
|
91
|
+
readonly Battle: "Battle";
|
|
92
|
+
}>;
|
|
93
|
+
quantity: z.ZodNumber;
|
|
94
|
+
priceCents: z.ZodNumber;
|
|
95
|
+
}, z.core.$strip>>;
|
|
81
96
|
}, z.core.$strip>;
|
|
82
97
|
export declare const gameTurnStatusSchema: z.ZodEnum<{
|
|
83
98
|
readonly CREATED: "created";
|
|
@@ -118,9 +133,9 @@ export declare const gameTurnTaskSchema: z.ZodObject<{
|
|
|
118
133
|
export declare const gameTurnSchema: z.ZodObject<{
|
|
119
134
|
id: z.ZodString;
|
|
120
135
|
purchaseId: z.ZodString;
|
|
121
|
-
|
|
136
|
+
leaderPlayerId: z.ZodString;
|
|
122
137
|
gameTickets: z.ZodArray<z.ZodString>;
|
|
123
|
-
|
|
138
|
+
playerIds: z.ZodArray<z.ZodString>;
|
|
124
139
|
status: z.ZodEnum<{
|
|
125
140
|
readonly CREATED: "created";
|
|
126
141
|
readonly IN_QUEUE: "in_queue";
|
|
@@ -151,9 +166,9 @@ export declare const gameTurnSchema: z.ZodObject<{
|
|
|
151
166
|
export declare const gameTurnQueueItemSchema: z.ZodObject<{
|
|
152
167
|
id: z.ZodString;
|
|
153
168
|
purchaseId: z.ZodString;
|
|
154
|
-
|
|
169
|
+
leaderPlayerId: z.ZodString;
|
|
155
170
|
gameTickets: z.ZodArray<z.ZodString>;
|
|
156
|
-
|
|
171
|
+
playerIds: z.ZodArray<z.ZodString>;
|
|
157
172
|
status: z.ZodEnum<{
|
|
158
173
|
readonly CREATED: "created";
|
|
159
174
|
readonly IN_QUEUE: "in_queue";
|
|
@@ -1,49 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gameTurnQueueItemSchema = exports.gameTurnSchema = exports.gameTurnTaskSchema = exports.gameTurnTaskStatusSchema = exports.gameTurnTaskTypeSchema = exports.gameTurnCheckSchema = exports.gameTurnStatusSchema = exports.
|
|
3
|
+
exports.gameTurnQueueItemSchema = exports.gameTurnSchema = exports.gameTurnTaskSchema = exports.gameTurnTaskStatusSchema = exports.gameTurnTaskTypeSchema = exports.gameTurnCheckSchema = exports.gameTurnStatusSchema = exports.createPurchaseInputSchema = exports.purchaseSchema = exports.purchaseItemSchema = exports.purchaseStatusSchema = exports.gameTicketSchema = exports.ticketSummarySchema = exports.ticketTypeSchema = exports.ticketUserTypeSchema = exports.gameTicketStatusSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const Ticketing_const_1 = require("./Ticketing.const");
|
|
6
|
+
const game_1 = require("../game");
|
|
6
7
|
exports.gameTicketStatusSchema = zod_1.z.enum(Ticketing_const_1.GAME_TICKET_STATUS);
|
|
7
8
|
exports.ticketUserTypeSchema = zod_1.z.enum(Ticketing_const_1.TICKET_USER_TYPE);
|
|
8
9
|
exports.ticketTypeSchema = zod_1.z.enum(Ticketing_const_1.TICKET_TYPE);
|
|
9
10
|
exports.ticketSummarySchema = zod_1.z.record(exports.ticketTypeSchema, zod_1.z.number());
|
|
10
11
|
exports.gameTicketSchema = zod_1.z.object({
|
|
11
|
-
id: zod_1.z.
|
|
12
|
+
id: zod_1.z.uuidv4(),
|
|
12
13
|
purchaseId: zod_1.z.string(),
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
sessionId: zod_1.z.string().optional().nullable(),
|
|
15
|
+
gameTurnId: zod_1.z.string().optional().nullable(),
|
|
16
|
+
playerId: zod_1.z.uuidv4().optional().nullable(),
|
|
16
17
|
status: exports.gameTicketStatusSchema,
|
|
17
18
|
type: exports.ticketTypeSchema.default(Ticketing_const_1.TICKET_TYPE.RACE),
|
|
18
19
|
createdAt: zod_1.z.date(),
|
|
19
20
|
updatedAt: zod_1.z.date(),
|
|
20
21
|
completedAt: zod_1.z.date().optional(),
|
|
21
22
|
});
|
|
23
|
+
exports.purchaseStatusSchema = zod_1.z.enum(Ticketing_const_1.PURCHASE_STATUS);
|
|
24
|
+
exports.purchaseItemSchema = zod_1.z.object({
|
|
25
|
+
ticketType: game_1.gameTypeSchema,
|
|
26
|
+
quantity: zod_1.z.number().int().positive(),
|
|
27
|
+
priceCents: zod_1.z.number().int().nonnegative(),
|
|
28
|
+
});
|
|
22
29
|
exports.purchaseSchema = zod_1.z.object({
|
|
23
|
-
id: zod_1.z.
|
|
30
|
+
id: zod_1.z.uuidv4(),
|
|
24
31
|
purchaseNumber: zod_1.z.number(),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
// Buyer can be null for Guest/On-Site purchases
|
|
33
|
+
buyerUserId: zod_1.z.string().optional().nullable(),
|
|
34
|
+
items: zod_1.z.array(exports.purchaseItemSchema),
|
|
35
|
+
totalAmountCents: zod_1.z.number().min(0),
|
|
36
|
+
status: exports.purchaseStatusSchema.default(Ticketing_const_1.PURCHASE_STATUS.PENDING),
|
|
37
|
+
// Deprecated fields (kept for backward compatibility if needed, or remove if safe)
|
|
38
|
+
totalTickets: zod_1.z.number().optional(),
|
|
39
|
+
ticketType: exports.ticketTypeSchema.optional(),
|
|
29
40
|
paymentData: zod_1.z.any().optional(),
|
|
30
41
|
createdAt: zod_1.z.date(),
|
|
31
42
|
updatedAt: zod_1.z.date(),
|
|
32
43
|
});
|
|
33
|
-
exports.
|
|
34
|
-
.
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
.extend({
|
|
38
|
-
ticketCount: zod_1.z.number(),
|
|
39
|
-
});
|
|
40
|
-
exports.createPurchaseInternalSchema = exports.purchaseSchema
|
|
41
|
-
.pick({
|
|
42
|
-
ticketType: true,
|
|
43
|
-
buyerUserId: true,
|
|
44
|
-
})
|
|
45
|
-
.extend({
|
|
46
|
-
ticketCount: zod_1.z.number(),
|
|
44
|
+
exports.createPurchaseInputSchema = zod_1.z.object({
|
|
45
|
+
buyerUserId: zod_1.z.string().optional(),
|
|
46
|
+
items: zod_1.z.array(exports.purchaseItemSchema).min(1),
|
|
47
47
|
});
|
|
48
48
|
exports.gameTurnStatusSchema = zod_1.z.enum(Ticketing_const_1.GAME_TURN_STATUS);
|
|
49
49
|
exports.gameTurnCheckSchema = zod_1.z.enum(Ticketing_const_1.GAME_TURN_CHECK);
|
|
@@ -60,9 +60,9 @@ exports.gameTurnTaskSchema = zod_1.z.object({
|
|
|
60
60
|
exports.gameTurnSchema = zod_1.z.object({
|
|
61
61
|
id: zod_1.z.string(),
|
|
62
62
|
purchaseId: zod_1.z.string(),
|
|
63
|
-
|
|
63
|
+
leaderPlayerId: zod_1.z.string(),
|
|
64
64
|
gameTickets: zod_1.z.array(zod_1.z.string()),
|
|
65
|
-
|
|
65
|
+
playerIds: zod_1.z.array(zod_1.z.string()),
|
|
66
66
|
status: exports.gameTurnStatusSchema,
|
|
67
67
|
tasks: zod_1.z.array(exports.gameTurnTaskSchema),
|
|
68
68
|
createdAt: zod_1.z.date(),
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { createPurchaseInputSchema, gameTicketSchema, gameTicketStatusSchema, gameTurnCheckSchema, gameTurnQueueItemSchema, gameTurnSchema, gameTurnStatusSchema, gameTurnTaskSchema, gameTurnTaskStatusSchema, gameTurnTaskTypeSchema, purchaseSchema, ticketSummarySchema, ticketTypeSchema, ticketUserTypeSchema } from './Ticketing.schema';
|
|
3
3
|
export type TicketType = z.infer<typeof ticketTypeSchema>;
|
|
4
4
|
export type GameTicketStatus = z.infer<typeof gameTicketStatusSchema>;
|
|
5
5
|
export type TicketUserType = z.infer<typeof ticketUserTypeSchema>;
|
|
6
6
|
export type TicketSummary = z.infer<typeof ticketSummarySchema>;
|
|
7
7
|
export type Purchase = z.infer<typeof purchaseSchema>;
|
|
8
|
-
export type
|
|
9
|
-
export type CreatePurchaseInternalInput = z.infer<typeof createPurchaseInternalSchema>;
|
|
8
|
+
export type CreatePurchaseInput = z.infer<typeof createPurchaseInputSchema>;
|
|
10
9
|
export type GameTicket = z.infer<typeof gameTicketSchema>;
|
|
11
10
|
export type GameTurnStatus = z.infer<typeof gameTurnStatusSchema>;
|
|
12
11
|
export type GameTurnCheck = z.infer<typeof gameTurnCheckSchema>;
|
|
@@ -3,36 +3,60 @@ export declare const userTypeSchema: z.ZodEnum<{
|
|
|
3
3
|
readonly STAFF: "STAFF";
|
|
4
4
|
readonly PLAYER: "PLAYER";
|
|
5
5
|
}>;
|
|
6
|
+
export declare const PHONE_REGEX: RegExp;
|
|
6
7
|
export declare const userSchema: z.ZodObject<{
|
|
7
|
-
id: z.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
email: z.ZodEmail;
|
|
11
|
-
phone: z.ZodOptional<z.ZodString>;
|
|
8
|
+
id: z.ZodUUID;
|
|
9
|
+
email: z.ZodOptional<z.ZodEmail>;
|
|
10
|
+
phoneNumber: z.ZodOptional<z.ZodString>;
|
|
12
11
|
role: z.ZodEnum<{
|
|
13
12
|
readonly SUPER_ADMIN: "SUPER_ADMIN";
|
|
14
13
|
readonly OPERATOR: "OPERATOR";
|
|
15
14
|
readonly PLAYER: "PLAYER";
|
|
15
|
+
readonly CASHIER: "CASHIER";
|
|
16
16
|
}>;
|
|
17
17
|
type: z.ZodEnum<{
|
|
18
18
|
readonly STAFF: "STAFF";
|
|
19
19
|
readonly PLAYER: "PLAYER";
|
|
20
20
|
}>;
|
|
21
|
+
isActive: z.ZodDefault<z.ZodBoolean>;
|
|
22
|
+
isEmailVerified: z.ZodDefault<z.ZodBoolean>;
|
|
23
|
+
isPhoneVerified: z.ZodDefault<z.ZodBoolean>;
|
|
24
|
+
defaultPlayerId: z.ZodOptional<z.ZodUUID>;
|
|
25
|
+
createdAt: z.ZodDate;
|
|
26
|
+
lastLoginAt: z.ZodOptional<z.ZodDate>;
|
|
21
27
|
}, z.core.$strip>;
|
|
22
|
-
export declare const userWithPasswordSchema: z.ZodObject<{
|
|
23
|
-
id: z.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
email: z.ZodEmail;
|
|
27
|
-
phone: z.ZodOptional<z.ZodString>;
|
|
28
|
+
export declare const userWithPasswordSchema: z.ZodIntersection<z.ZodObject<{
|
|
29
|
+
id: z.ZodUUID;
|
|
30
|
+
email: z.ZodOptional<z.ZodEmail>;
|
|
31
|
+
phoneNumber: z.ZodOptional<z.ZodString>;
|
|
28
32
|
role: z.ZodEnum<{
|
|
29
33
|
readonly SUPER_ADMIN: "SUPER_ADMIN";
|
|
30
34
|
readonly OPERATOR: "OPERATOR";
|
|
31
35
|
readonly PLAYER: "PLAYER";
|
|
36
|
+
readonly CASHIER: "CASHIER";
|
|
32
37
|
}>;
|
|
33
38
|
type: z.ZodEnum<{
|
|
34
39
|
readonly STAFF: "STAFF";
|
|
35
40
|
readonly PLAYER: "PLAYER";
|
|
36
41
|
}>;
|
|
42
|
+
isActive: z.ZodDefault<z.ZodBoolean>;
|
|
43
|
+
isEmailVerified: z.ZodDefault<z.ZodBoolean>;
|
|
44
|
+
isPhoneVerified: z.ZodDefault<z.ZodBoolean>;
|
|
45
|
+
defaultPlayerId: z.ZodOptional<z.ZodUUID>;
|
|
46
|
+
createdAt: z.ZodDate;
|
|
47
|
+
lastLoginAt: z.ZodOptional<z.ZodDate>;
|
|
48
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
49
|
+
password: z.ZodString;
|
|
50
|
+
}, z.core.$strip>>;
|
|
51
|
+
export declare const userRegistrationInputSchema: z.ZodObject<{
|
|
52
|
+
email: z.ZodOptional<z.ZodEmail>;
|
|
53
|
+
phoneNumber: z.ZodOptional<z.ZodString>;
|
|
54
|
+
name: z.ZodOptional<z.ZodString>;
|
|
55
|
+
password: z.ZodString;
|
|
56
|
+
nickname: z.ZodString;
|
|
57
|
+
birthDate: z.ZodCoercedDate<unknown>;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
export declare const userLoginInputSchema: z.ZodObject<{
|
|
60
|
+
emailOrPhone: z.ZodString;
|
|
37
61
|
password: z.ZodString;
|
|
38
62
|
}, z.core.$strip>;
|
|
@@ -1,19 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.userWithPasswordSchema = exports.userSchema = exports.userTypeSchema = void 0;
|
|
3
|
+
exports.userLoginInputSchema = exports.userRegistrationInputSchema = exports.userWithPasswordSchema = exports.userSchema = exports.PHONE_REGEX = exports.userTypeSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const role_1 = require("../role");
|
|
6
6
|
const User_const_1 = require("./User.const");
|
|
7
7
|
exports.userTypeSchema = zod_1.z.enum(User_const_1.USER_TYPE);
|
|
8
|
-
exports.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
email: zod_1.z.email(),
|
|
13
|
-
|
|
8
|
+
exports.PHONE_REGEX = /^([+]?[\\s0-9]+)?(\\d{3}|[(]?[0-9]+[)])?([-]?[\\s]?[0-9])+$/;
|
|
9
|
+
const MIN_PASSWORD_LENGTH = 6;
|
|
10
|
+
const baseUserObj = zod_1.z.object({
|
|
11
|
+
id: zod_1.z.uuidv4(),
|
|
12
|
+
email: zod_1.z.email().toLowerCase().optional(),
|
|
13
|
+
phoneNumber: zod_1.z.string().regex(exports.PHONE_REGEX, 'Invalid phone number format').optional(),
|
|
14
|
+
// --- ACCESS CONTROL ---
|
|
14
15
|
role: role_1.userRoleSchema,
|
|
15
16
|
type: exports.userTypeSchema,
|
|
17
|
+
isActive: zod_1.z.boolean().default(true),
|
|
18
|
+
// TODO: Implement mechanism to validate users later by email or phone
|
|
19
|
+
isEmailVerified: zod_1.z.boolean().default(false),
|
|
20
|
+
isPhoneVerified: zod_1.z.boolean().default(false),
|
|
21
|
+
defaultPlayerId: zod_1.z.uuidv4().optional(),
|
|
22
|
+
createdAt: zod_1.z.date(),
|
|
23
|
+
lastLoginAt: zod_1.z.date().optional(),
|
|
16
24
|
});
|
|
17
|
-
exports.
|
|
18
|
-
|
|
25
|
+
exports.userSchema = baseUserObj.refine((data) => data.email || data.phoneNumber, {
|
|
26
|
+
message: 'User must have either an email or a phone number',
|
|
27
|
+
path: ['email', 'phoneNumber'],
|
|
28
|
+
});
|
|
29
|
+
exports.userWithPasswordSchema = exports.userSchema.and(zod_1.z.object({
|
|
30
|
+
password: zod_1.z.string().min(MIN_PASSWORD_LENGTH),
|
|
31
|
+
}));
|
|
32
|
+
exports.userRegistrationInputSchema = baseUserObj
|
|
33
|
+
.pick({
|
|
34
|
+
email: true,
|
|
35
|
+
phoneNumber: true,
|
|
36
|
+
})
|
|
37
|
+
.extend({
|
|
38
|
+
name: zod_1.z.string().optional(),
|
|
39
|
+
password: zod_1.z.string().min(6),
|
|
40
|
+
nickname: zod_1.z.string().min(2),
|
|
41
|
+
birthDate: zod_1.z.coerce.date(),
|
|
42
|
+
})
|
|
43
|
+
.refine((data) => data.email || data.phoneNumber, {
|
|
44
|
+
message: 'User must have either an email or a phone number',
|
|
45
|
+
path: ['email', 'phoneNumber'],
|
|
46
|
+
});
|
|
47
|
+
exports.userLoginInputSchema = zod_1.z.object({
|
|
48
|
+
emailOrPhone: zod_1.z
|
|
49
|
+
.string()
|
|
50
|
+
.min(1, 'Email or phone is required')
|
|
51
|
+
.refine((val) => {
|
|
52
|
+
const isEmail = zod_1.z.email().safeParse(val).success;
|
|
53
|
+
const isPhone = exports.PHONE_REGEX.test(val);
|
|
54
|
+
return isEmail || isPhone;
|
|
55
|
+
}, { message: 'Must be a valid email or phone number' }),
|
|
56
|
+
password: zod_1.z.string().min(MIN_PASSWORD_LENGTH, `Password must be at least ${MIN_PASSWORD_LENGTH} characters`),
|
|
19
57
|
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Battle Racing Common Library (`br-common-lib`)
|
|
2
|
+
|
|
3
|
+
Este repositorio contiene los esquemas de validación Zod, los tipos TypeScript, y las constantes compartidas de domino que actúan como la **fuente única de verdad (Single Source of Truth)** para los microservicios y clientes del ecosistema de Battle Racing (POS, Game Manager Backend, y Web Apps).
|
|
4
|
+
|
|
5
|
+
Para asegurar la coherencia arquitectónica y facilitar la integración con futuras herramientas de IA (agentes), **todas las modificaciones al ecosistema deben respetar las siguientes convenciones y flujos**.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🏗️ 1. Modelo de Dominio Crítico: `User` vs `Player`
|
|
10
|
+
|
|
11
|
+
La decisión arquitectónica más importante del sistema es la inyección de **cero fricción** en el entorno físico de la pista. Para ello, se ha separado estrictamente el concepto de "Cuenta" (quien paga y se loguea) del concepto de "Corredor" (quien sale en la pantalla y maneja el Kart).
|
|
12
|
+
|
|
13
|
+
### `User` (La Cuenta / El Pagador)
|
|
14
|
+
|
|
15
|
+
- **Propósito:** Representa a la persona física que se registra en la app, gestiona un método de pago, y posee un historial transaccional.
|
|
16
|
+
- **Autenticación (Email o Teléfono):** En lugar de utilizar un `username` de foros antiguos, **la autenticación se realiza estrictamente a través de `email` o `phoneNumber`**. Esto asegura un proceso de on-boarding sin fricción y previene cuellos de botella en los puntos de venta (POS) donde un cajero o totém no puede adivinar qué `username` no está registrado.
|
|
17
|
+
- **Propiedades Clave:** `password`, `role` (SUPER_ADMIN, CASHIER, PLAYER), `type`.
|
|
18
|
+
- **Relación:** Un `User` siempre tiene asignado automáticamente un `defaultPlayerId` (su perfil de corredor). Sin embargo, un `User` (tutor o papá) puede administrar y poseer múltiples `Players` hijos (`MINOR`).
|
|
19
|
+
|
|
20
|
+
### `Player` (El Corredor)
|
|
21
|
+
|
|
22
|
+
- **Propósito:** Es la entidad gamificada. Representa los datos que ven los espectadores en la pantalla del líder, en la pista, y lo que se le asigna físicamente a un Kart.
|
|
23
|
+
- **Identificador (`nickname`):** Los jugadores se identifican por su `nickname` (ej. "Maverick 🏎️💨").
|
|
24
|
+
- **Regla de Oro (No Unicidad):** **Los `nicknames` NO son únicos en la base de datos**. Diferentes jugadores pueden llamarse "Juan" para evitar fricción en un sábado por la noche lleno de clientes registrándose. El sistema interno los diferencia mediante su `UUID` o vinculándolos temporalmente al número de Kart en la carrera activa.
|
|
25
|
+
- **Waivers:** Los `Players` deben firmar (o sus tutores deben firmar por ellos) un documento de exención de responsabilidad (`waiver`).
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 🛡️ 2. Práctica de Validación (Zod First)
|
|
30
|
+
|
|
31
|
+
Nuestra arquitectura delega TODA la validación de negocio y seguridad a **Zod**. En lugar de duplicar lógicas de validación en frontend, backend, y bases de datos, los moldes residen aquí en `br-common-lib`.
|
|
32
|
+
|
|
33
|
+
### Organización de Archivos (Arquitectura de Dominio)
|
|
34
|
+
|
|
35
|
+
Dentro de `src/domains/{domainName}/`:
|
|
36
|
+
|
|
37
|
+
- `*.schema.ts`: Aquí residen todos los objetos Zod (ej. `userSchema`, `userLoginInputSchema`).
|
|
38
|
+
- `*.types.ts`: Tipos estáticos autogenerados mediante `z.infer<typeof schema>`. Nunca se debe escribir un `interface` manualmente si ya existe un esquema de validación.
|
|
39
|
+
- `*.const.ts`: Enums, literales y variables constantes.
|
|
40
|
+
|
|
41
|
+
### DTOs en NestJS (`nestjs-zod`)
|
|
42
|
+
|
|
43
|
+
En el ecosistema Backend (`game-manager-backend`), está **estrictamente prohibido** usar decoradores de `class-validator` (como `@IsString()`).
|
|
44
|
+
En su lugar, los DTOs heredan del esquema Zod importado de esta librería utilizando la función `createZodDto`:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
// En game-manager-backend: src/modules/auth/dto/login.dto.ts
|
|
48
|
+
import { createZodDto } from 'nestjs-zod';
|
|
49
|
+
import { userLoginInputSchema } from '@battle-racing/br-common-lib';
|
|
50
|
+
|
|
51
|
+
export class LoginInputDto extends createZodDto(userLoginInputSchema) {}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Cualquier cambio a los endpoints o al pipeline de registro DEBE comenzar por actualizar el `.schema.ts` dentro de `br-common-lib` y recompilar la librería (`npm run build`).
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 🎟️ 3. Flujo Transaccional: Compras y Turnos de Juego (Ticketing)
|
|
59
|
+
|
|
60
|
+
### The `Purchase` (Compra)
|
|
61
|
+
|
|
62
|
+
- Agrupa múltiples "Items" de juegos bajo una misma transacción de pago con un `buyerUserId` (que puede ser Null si la compra se hace 100% anónima como Guest en el POS).
|
|
63
|
+
- La creación de compras asíncronas es un proceso validado por Webhooks (ej. una vez liquidado el pago en el gateway, se genera legalmente la compra).
|
|
64
|
+
|
|
65
|
+
### The `GameTicket` (El Boleto individual)
|
|
66
|
+
|
|
67
|
+
- Una compra de "3 Carreras" se desfragmenta en 3 `GameTicket` separados en la base de datos.
|
|
68
|
+
- Los Boletos nacen en estado `CREATED`.
|
|
69
|
+
- Un boleto es asignado a un corredor físico mediante el `playerId`. **Ya no se usa `ownerUsername`**.
|
|
70
|
+
|
|
71
|
+
### The `GameTurn` (El Turno Físico en Pista)
|
|
72
|
+
|
|
73
|
+
- Cuando un grupo de amigos se acerca a la fila, el operador (o el sistema automático) los agrupa en un `GameTurn`.
|
|
74
|
+
- El `GameTurn` toma un conjunto de `GameTickets` válidos (de cualquier compra anterior) y un conjunto de `playerIds` participantes.
|
|
75
|
+
- Enlaza la lógica del hardware, controlando qué `Kart` se le asigna a cada integrante para la carrera real y las misiones/tareas (`tasks`) escaneadas por QR.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 🔄 4. Flujo de Trabajo para Inteligencias Múltiples (Agentes)
|
|
80
|
+
|
|
81
|
+
Si eres un modelo de IA leyendo este archivo para continuar con el desarrollo de Battle Racing:
|
|
82
|
+
|
|
83
|
+
1. **Nunca añadas `username`** ni regreses a prácticas de validación por foros.
|
|
84
|
+
2. Si un endpoint o componente frontend necesita una regla de UI o validación nueva, módificala **primero** en los schemas de `br-common-lib` y recompila con `npm run build`.
|
|
85
|
+
3. Evita las dependencias circulares usando los archivos de mapeo de barril (`index.ts`) y organizando siempre el código en `/domains`.
|
|
86
|
+
4. Todos los identificadores (ID's) a través del sistema están diseñados con `z.uuidv4()`. Mantén ese estándar para migraciones futuras a bases de datos escalables.
|
|
87
|
+
5. Emplea variables `emailOrPhone` cuando realices un flujo de acceso. No dupliques ni requieras ambas salvo expresamente configurado.
|
package/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './base-hardware-status';
|
|
2
|
+
export * from './damage';
|
|
3
|
+
export * from './flag-media-name';
|
|
4
|
+
export * from './flag-status';
|
|
5
|
+
export * from './lights-effect';
|
|
6
|
+
export * from './rgb-status';
|
|
7
|
+
export * from './screen-status';
|
|
8
|
+
export * from './screen-view';
|
|
9
|
+
export * from './speed-status';
|