@battle-racing/br-common-lib 3.5.0 → 3.8.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 (101) hide show
  1. package/REFACTOR_README.md +185 -0
  2. package/br-common-lib.code-workspace +19 -0
  3. package/dist/constants/index.d.ts +2 -0
  4. package/dist/constants/index.js +2 -0
  5. package/dist/constants/payment-provider.d.ts +5 -0
  6. package/dist/constants/payment-provider.js +8 -0
  7. package/dist/constants/payment-status.d.ts +7 -0
  8. package/dist/constants/payment-status.js +10 -0
  9. package/dist/constants/user-role.d.ts +1 -0
  10. package/dist/constants/user-role.js +1 -0
  11. package/dist/schemas/team.schema.d.ts +7 -0
  12. package/dist/schemas/team.schema.js +9 -0
  13. package/dist/types/gameTrack/GameTrackKartConfig.d.ts +9 -0
  14. package/dist/types/gameTrack/index.d.ts +1 -0
  15. package/dist/types/gameTrack/index.js +1 -0
  16. package/dist/types/index.d.ts +3 -0
  17. package/dist/types/index.js +3 -0
  18. package/dist/types/pagination/Pagination.d.ts +3 -0
  19. package/dist/types/pagination/index.d.ts +2 -0
  20. package/dist/types/pagination/index.js +18 -0
  21. package/dist/types/pagination/pagination.schema.d.ts +14 -0
  22. package/dist/types/pagination/pagination.schema.js +16 -0
  23. package/dist/types/racingTeam/RacingTeam.d.ts +6 -0
  24. package/dist/types/racingTeam/RacingTeam.schema.d.ts +44 -0
  25. package/dist/types/racingTeam/RacingTeam.schema.js +27 -0
  26. package/dist/types/racingTeam/RacingTeamMembership.d.ts +6 -0
  27. package/dist/types/racingTeam/RacingTeamMembership.schema.d.ts +31 -0
  28. package/dist/types/racingTeam/RacingTeamMembership.schema.js +27 -0
  29. package/dist/types/racingTeam/index.d.ts +4 -0
  30. package/dist/types/racingTeam/index.js +20 -0
  31. package/dist/types/socket/serverToClient/SocketKartServerToClientEventsParams.d.ts +3 -5
  32. package/dist/types/ticketing/GameTicket.d.ts +3 -0
  33. package/dist/types/ticketing/GameTicket.js +2 -0
  34. package/dist/types/ticketing/GameTurn.d.ts +4 -0
  35. package/dist/types/ticketing/GameTurn.js +2 -0
  36. package/dist/types/ticketing/GameTurn.schema.d.ts +92 -0
  37. package/dist/types/ticketing/GameTurn.schema.js +46 -0
  38. package/dist/types/ticketing/GameTurnTask.d.ts +3 -0
  39. package/dist/types/ticketing/GameTurnTask.js +2 -0
  40. package/dist/types/ticketing/GameTurnTask.schema.d.ts +34 -0
  41. package/dist/types/ticketing/GameTurnTask.schema.js +30 -0
  42. package/dist/types/ticketing/PaymentProvider.d.ts +34 -0
  43. package/dist/types/ticketing/PaymentProvider.js +2 -0
  44. package/dist/types/ticketing/PlayerTurn.d.ts +3 -0
  45. package/dist/types/ticketing/PlayerTurn.js +2 -0
  46. package/dist/types/ticketing/Purchase.d.ts +3 -0
  47. package/dist/types/ticketing/Purchase.js +2 -0
  48. package/dist/types/ticketing/index.d.ts +9 -0
  49. package/dist/types/ticketing/index.js +25 -0
  50. package/dist/types/ticketing/ticketing.schemas.d.ts +58 -0
  51. package/dist/types/ticketing/ticketing.schemas.js +41 -0
  52. package/dist/types/user/User.d.ts +4 -9
  53. package/dist/types/user/index.d.ts +3 -1
  54. package/dist/types/user/index.js +5 -1
  55. package/dist/types/user/user-type.schema.d.ts +9 -0
  56. package/dist/types/user/user-type.schema.js +12 -0
  57. package/dist/types/user/user.schema.d.ts +39 -0
  58. package/dist/types/user/user.schema.js +19 -0
  59. package/package.json +6 -2
  60. package/src/constants/index.ts +2 -1
  61. package/src/constants/payment-provider.ts +5 -0
  62. package/src/constants/payment-status.ts +7 -0
  63. package/src/constants/user-role.ts +1 -0
  64. package/src/schemas/team.schema.ts +9 -0
  65. package/src/types/gameTrack/GameTrackKartConfig.ts +10 -0
  66. package/src/types/gameTrack/index.ts +1 -0
  67. package/src/types/index.ts +3 -1
  68. package/src/types/pagination/Pagination.ts +4 -0
  69. package/src/types/pagination/index.ts +2 -0
  70. package/src/types/pagination/pagination.schema.ts +14 -0
  71. package/src/types/racingTeam/RacingTeam.schema.ts +29 -0
  72. package/src/types/racingTeam/RacingTeam.ts +12 -0
  73. package/src/types/racingTeam/RacingTeamMembership.schema.ts +29 -0
  74. package/src/types/racingTeam/RacingTeamMembership.ts +12 -0
  75. package/src/types/racingTeam/index.ts +4 -0
  76. package/src/types/socket/serverToClient/SocketKartServerToClientEventsParams.ts +3 -4
  77. package/src/types/ticketing/GameTicket.ts +4 -0
  78. package/src/types/ticketing/GameTurn.schema.ts +49 -0
  79. package/src/types/ticketing/GameTurn.ts +6 -0
  80. package/src/types/ticketing/GameTurnTask.schema.ts +32 -0
  81. package/src/types/ticketing/GameTurnTask.ts +4 -0
  82. package/src/types/ticketing/PaymentProvider.ts +40 -0
  83. package/src/types/ticketing/Purchase.ts +4 -0
  84. package/src/types/ticketing/index.ts +9 -0
  85. package/src/types/ticketing/ticketing.schemas.ts +43 -0
  86. package/src/types/user/User.ts +4 -9
  87. package/src/types/user/index.ts +4 -1
  88. package/src/types/user/user-type.schema.ts +8 -0
  89. package/src/types/user/user.schema.ts +19 -0
  90. package/README.md +0 -3
  91. package/dist/data/RoleDefinitions.d.ts +0 -2
  92. package/dist/data/RoleDefinitions.js +0 -27
  93. package/dist/types/hardware/screen/ScreenKartPosition.d.ts +0 -4
  94. package/dist/types/hardware/screen/ScreenRaceLaps.d.ts +0 -4
  95. package/dist/types/response/SuccesResponse.d.ts +0 -5
  96. package/dist/types/user/UserOrigin.d.ts +0 -1
  97. package/src/types/user/UserOrigin.ts +0 -1
  98. /package/dist/types/{hardware/screen/ScreenKartPosition.js → gameTrack/GameTrackKartConfig.js} +0 -0
  99. /package/dist/types/{hardware/screen/ScreenRaceLaps.js → pagination/Pagination.js} +0 -0
  100. /package/dist/types/{response/SuccesResponse.js → racingTeam/RacingTeam.js} +0 -0
  101. /package/dist/types/{user/UserOrigin.js → racingTeam/RacingTeamMembership.js} +0 -0
@@ -0,0 +1,92 @@
1
+ import { z } from 'zod';
2
+ export declare const GAME_TURN_STATUS: {
3
+ readonly CREATED: "created";
4
+ readonly IN_QUEUE: "in_queue";
5
+ readonly READY: "ready";
6
+ readonly PLAYING: "playing";
7
+ readonly COMPLETED: "completed";
8
+ };
9
+ export declare const GAME_TURN_CHECK: {
10
+ readonly TUTORIAL: "tutorial";
11
+ readonly AGE_VERIFICATION: "age_verification";
12
+ readonly TERMS_ACCEPTANCE: "terms_acceptance";
13
+ };
14
+ export declare const GameTurnStatusSchema: z.ZodEnum<{
15
+ completed: "completed";
16
+ created: "created";
17
+ in_queue: "in_queue";
18
+ ready: "ready";
19
+ playing: "playing";
20
+ }>;
21
+ export declare const GameTurnCheckSchema: z.ZodEnum<{
22
+ tutorial: "tutorial";
23
+ age_verification: "age_verification";
24
+ terms_acceptance: "terms_acceptance";
25
+ }>;
26
+ export declare const GameTurnSchema: z.ZodObject<{
27
+ id: z.ZodString;
28
+ purchaseId: z.ZodString;
29
+ leaderUsername: z.ZodString;
30
+ gameTickets: z.ZodArray<z.ZodString>;
31
+ usernames: z.ZodArray<z.ZodString>;
32
+ status: z.ZodEnum<{
33
+ completed: "completed";
34
+ created: "created";
35
+ in_queue: "in_queue";
36
+ ready: "ready";
37
+ playing: "playing";
38
+ }>;
39
+ tasks: z.ZodArray<z.ZodObject<{
40
+ id: z.ZodString;
41
+ type: z.ZodEnum<{
42
+ qr_scan: "qr_scan";
43
+ manual_check: "manual_check";
44
+ link_accept: "link_accept";
45
+ }>;
46
+ status: z.ZodEnum<{
47
+ pending: "pending";
48
+ completed: "completed";
49
+ }>;
50
+ label: z.ZodString;
51
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
52
+ completedAt: z.ZodOptional<z.ZodDate>;
53
+ }, z.core.$strip>>;
54
+ createdAt: z.ZodDate;
55
+ updatedAt: z.ZodDate;
56
+ startedAt: z.ZodOptional<z.ZodDate>;
57
+ completedAt: z.ZodOptional<z.ZodDate>;
58
+ }, z.core.$strip>;
59
+ export declare const GameTurnQueueItemSchema: z.ZodObject<{
60
+ id: z.ZodString;
61
+ purchaseId: z.ZodString;
62
+ leaderUsername: z.ZodString;
63
+ gameTickets: z.ZodArray<z.ZodString>;
64
+ usernames: z.ZodArray<z.ZodString>;
65
+ status: z.ZodEnum<{
66
+ completed: "completed";
67
+ created: "created";
68
+ in_queue: "in_queue";
69
+ ready: "ready";
70
+ playing: "playing";
71
+ }>;
72
+ tasks: z.ZodArray<z.ZodObject<{
73
+ id: z.ZodString;
74
+ type: z.ZodEnum<{
75
+ qr_scan: "qr_scan";
76
+ manual_check: "manual_check";
77
+ link_accept: "link_accept";
78
+ }>;
79
+ status: z.ZodEnum<{
80
+ pending: "pending";
81
+ completed: "completed";
82
+ }>;
83
+ label: z.ZodString;
84
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
85
+ completedAt: z.ZodOptional<z.ZodDate>;
86
+ }, z.core.$strip>>;
87
+ createdAt: z.ZodDate;
88
+ updatedAt: z.ZodDate;
89
+ startedAt: z.ZodOptional<z.ZodDate>;
90
+ completedAt: z.ZodOptional<z.ZodDate>;
91
+ position: z.ZodNumber;
92
+ }, z.core.$strip>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GameTurnQueueItemSchema = exports.GameTurnSchema = exports.GameTurnCheckSchema = exports.GameTurnStatusSchema = exports.GAME_TURN_CHECK = exports.GAME_TURN_STATUS = void 0;
4
+ const zod_1 = require("zod");
5
+ const GameTurnTask_schema_1 = require("./GameTurnTask.schema");
6
+ exports.GAME_TURN_STATUS = {
7
+ CREATED: 'created',
8
+ IN_QUEUE: 'in_queue',
9
+ READY: 'ready',
10
+ PLAYING: 'playing',
11
+ COMPLETED: 'completed',
12
+ };
13
+ exports.GAME_TURN_CHECK = {
14
+ TUTORIAL: 'tutorial',
15
+ AGE_VERIFICATION: 'age_verification',
16
+ TERMS_ACCEPTANCE: 'terms_acceptance',
17
+ };
18
+ exports.GameTurnStatusSchema = zod_1.z.enum([
19
+ exports.GAME_TURN_STATUS.CREATED,
20
+ exports.GAME_TURN_STATUS.IN_QUEUE,
21
+ exports.GAME_TURN_STATUS.READY,
22
+ exports.GAME_TURN_STATUS.PLAYING,
23
+ exports.GAME_TURN_STATUS.COMPLETED,
24
+ ]);
25
+ exports.GameTurnCheckSchema = zod_1.z.enum([
26
+ exports.GAME_TURN_CHECK.TUTORIAL,
27
+ exports.GAME_TURN_CHECK.AGE_VERIFICATION,
28
+ exports.GAME_TURN_CHECK.TERMS_ACCEPTANCE,
29
+ ]);
30
+ exports.GameTurnSchema = zod_1.z.object({
31
+ id: zod_1.z.string(),
32
+ purchaseId: zod_1.z.string(),
33
+ leaderUsername: zod_1.z.string(),
34
+ gameTickets: zod_1.z.array(zod_1.z.string()),
35
+ usernames: zod_1.z.array(zod_1.z.string()),
36
+ status: exports.GameTurnStatusSchema,
37
+ tasks: zod_1.z.array(GameTurnTask_schema_1.GameTurnTaskSchema),
38
+ createdAt: zod_1.z.date(),
39
+ updatedAt: zod_1.z.date(),
40
+ startedAt: zod_1.z.date().optional(),
41
+ completedAt: zod_1.z.date().optional(),
42
+ });
43
+ // The Game turn queue item requires a position to sort it.
44
+ exports.GameTurnQueueItemSchema = exports.GameTurnSchema.extend({
45
+ position: zod_1.z.number(),
46
+ });
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import { GameTurnTaskSchema } from './GameTurnTask.schema';
3
+ export type GameTurnTask = z.infer<typeof GameTurnTaskSchema>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,34 @@
1
+ import { z } from 'zod';
2
+ export declare const GAME_TURN_TASK_TYPE: {
3
+ readonly QR_SCAN: "qr_scan";
4
+ readonly MANUAL_CHECK: "manual_check";
5
+ readonly LINK_ACCEPT: "link_accept";
6
+ };
7
+ export declare const GAME_TURN_TASK_STATUS: {
8
+ readonly PENDING: "pending";
9
+ readonly COMPLETED: "completed";
10
+ };
11
+ export declare const GameTurnTaskTypeSchema: z.ZodEnum<{
12
+ qr_scan: "qr_scan";
13
+ manual_check: "manual_check";
14
+ link_accept: "link_accept";
15
+ }>;
16
+ export declare const GameTurnTaskStatusSchema: z.ZodEnum<{
17
+ pending: "pending";
18
+ completed: "completed";
19
+ }>;
20
+ export declare const GameTurnTaskSchema: z.ZodObject<{
21
+ id: z.ZodString;
22
+ type: z.ZodEnum<{
23
+ qr_scan: "qr_scan";
24
+ manual_check: "manual_check";
25
+ link_accept: "link_accept";
26
+ }>;
27
+ status: z.ZodEnum<{
28
+ pending: "pending";
29
+ completed: "completed";
30
+ }>;
31
+ label: z.ZodString;
32
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
33
+ completedAt: z.ZodOptional<z.ZodDate>;
34
+ }, z.core.$strip>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GameTurnTaskSchema = exports.GameTurnTaskStatusSchema = exports.GameTurnTaskTypeSchema = exports.GAME_TURN_TASK_STATUS = exports.GAME_TURN_TASK_TYPE = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.GAME_TURN_TASK_TYPE = {
6
+ QR_SCAN: 'qr_scan',
7
+ MANUAL_CHECK: 'manual_check',
8
+ LINK_ACCEPT: 'link_accept',
9
+ };
10
+ exports.GAME_TURN_TASK_STATUS = {
11
+ PENDING: 'pending',
12
+ COMPLETED: 'completed',
13
+ };
14
+ exports.GameTurnTaskTypeSchema = zod_1.z.enum([
15
+ exports.GAME_TURN_TASK_TYPE.QR_SCAN,
16
+ exports.GAME_TURN_TASK_TYPE.MANUAL_CHECK,
17
+ exports.GAME_TURN_TASK_TYPE.LINK_ACCEPT,
18
+ ]);
19
+ exports.GameTurnTaskStatusSchema = zod_1.z.enum([
20
+ exports.GAME_TURN_TASK_STATUS.PENDING,
21
+ exports.GAME_TURN_TASK_STATUS.COMPLETED,
22
+ ]);
23
+ exports.GameTurnTaskSchema = zod_1.z.object({
24
+ id: zod_1.z.string(),
25
+ type: exports.GameTurnTaskTypeSchema,
26
+ status: exports.GameTurnTaskStatusSchema,
27
+ label: zod_1.z.string(),
28
+ metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
29
+ completedAt: zod_1.z.date().optional(),
30
+ });
@@ -0,0 +1,34 @@
1
+ import { PAYMENT_PROVIDERS, PAYMENT_STATUSES } from '../../constants';
2
+ export type PaymentProviderName = (typeof PAYMENT_PROVIDERS)[keyof typeof PAYMENT_PROVIDERS];
3
+ export type PaymentStatus = (typeof PAYMENT_STATUSES)[keyof typeof PAYMENT_STATUSES];
4
+ /**
5
+ * Generic payment provider data that can be reused across different providers
6
+ * This allows easy switching between Stripe, PayPal, etc.
7
+ */
8
+ export interface PaymentProviderData {
9
+ provider: PaymentProviderName;
10
+ paymentIntentId?: string;
11
+ transactionId: string;
12
+ amountPaid: number;
13
+ currency: string;
14
+ paymentStatus: PaymentStatus;
15
+ paymentMethod?: string;
16
+ metadata?: Record<string, any>;
17
+ }
18
+ /**
19
+ * Strategy interface for payment providers
20
+ */
21
+ export interface PaymentProvider {
22
+ /**
23
+ * Confirm and validate a purchase from webhook payload
24
+ */
25
+ confirmPurchase(payload: any, signature?: string): Promise<PaymentProviderData>;
26
+ /**
27
+ * Validate webhook signature if provided
28
+ */
29
+ validateWebhookSignature?(payload: any, signature: string): boolean;
30
+ /**
31
+ * Get provider name
32
+ */
33
+ getProviderName(): string;
34
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import { GameTurnSchema } from './ticketing.schemas';
3
+ export type GameTurn = z.infer<typeof GameTurnSchema>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import { PurchaseSchema } from './ticketing.schemas';
3
+ export type Purchase = z.infer<typeof PurchaseSchema>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ export * from './GameTicket';
2
+ export * from './PaymentProvider';
3
+ export * from './GameTurn';
4
+ export * from './Purchase';
5
+ export * from './ticketing.schemas';
6
+ export * from './ticketing.schemas';
7
+ export * from './GameTurnTask';
8
+ export * from './GameTurnTask.schema';
9
+ export * from './GameTurn.schema';
@@ -0,0 +1,25 @@
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("./GameTicket"), exports);
18
+ __exportStar(require("./PaymentProvider"), exports);
19
+ __exportStar(require("./GameTurn"), exports);
20
+ __exportStar(require("./Purchase"), exports);
21
+ __exportStar(require("./ticketing.schemas"), exports);
22
+ __exportStar(require("./ticketing.schemas"), exports);
23
+ __exportStar(require("./GameTurnTask"), exports);
24
+ __exportStar(require("./GameTurnTask.schema"), exports);
25
+ __exportStar(require("./GameTurn.schema"), exports);
@@ -0,0 +1,58 @@
1
+ import { z } from 'zod';
2
+ export declare const GAME_TICKET_STATUS: {
3
+ readonly CREATED: "created";
4
+ readonly ASSIGNED: "assigned";
5
+ readonly ACTIVE: "active";
6
+ readonly COMPLETED: "completed";
7
+ };
8
+ export declare const TICKET_USER_TYPE: {
9
+ readonly LEADER: "leader";
10
+ readonly SUB_USER: "sub-user";
11
+ readonly EXISTING: "existing";
12
+ readonly GUEST: "guest";
13
+ };
14
+ export declare const GameTicketStatusSchema: z.ZodEnum<{
15
+ readonly CREATED: "created";
16
+ readonly ASSIGNED: "assigned";
17
+ readonly ACTIVE: "active";
18
+ readonly COMPLETED: "completed";
19
+ }>;
20
+ export declare const TicketUserTypeSchema: z.ZodEnum<{
21
+ readonly LEADER: "leader";
22
+ readonly SUB_USER: "sub-user";
23
+ readonly EXISTING: "existing";
24
+ readonly GUEST: "guest";
25
+ }>;
26
+ export declare const GameTicketSchema: z.ZodObject<{
27
+ id: z.ZodString;
28
+ purchaseId: z.ZodString;
29
+ gameTurnId: z.ZodString;
30
+ ownerUsername: z.ZodString;
31
+ userType: z.ZodEnum<{
32
+ readonly LEADER: "leader";
33
+ readonly SUB_USER: "sub-user";
34
+ readonly EXISTING: "existing";
35
+ readonly GUEST: "guest";
36
+ }>;
37
+ status: z.ZodEnum<{
38
+ readonly CREATED: "created";
39
+ readonly ASSIGNED: "assigned";
40
+ readonly ACTIVE: "active";
41
+ readonly COMPLETED: "completed";
42
+ }>;
43
+ createdAt: z.ZodDate;
44
+ updatedAt: z.ZodDate;
45
+ completedAt: z.ZodOptional<z.ZodDate>;
46
+ }, z.core.$strip>;
47
+ export declare const PurchaseSchema: z.ZodObject<{
48
+ id: z.ZodString;
49
+ purchaseNumber: z.ZodNumber;
50
+ buyerUserId: z.ZodString;
51
+ totalTickets: z.ZodNumber;
52
+ availableTickets: z.ZodNumber;
53
+ usedTickets: z.ZodNumber;
54
+ purchaseDate: z.ZodDate;
55
+ paymentData: z.ZodOptional<z.ZodAny>;
56
+ createdAt: z.ZodDate;
57
+ updatedAt: z.ZodDate;
58
+ }, z.core.$strip>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PurchaseSchema = exports.GameTicketSchema = exports.TicketUserTypeSchema = exports.GameTicketStatusSchema = exports.TICKET_USER_TYPE = exports.GAME_TICKET_STATUS = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.GAME_TICKET_STATUS = {
6
+ CREATED: 'created',
7
+ ASSIGNED: 'assigned',
8
+ ACTIVE: 'active',
9
+ COMPLETED: 'completed',
10
+ };
11
+ exports.TICKET_USER_TYPE = {
12
+ LEADER: 'leader',
13
+ SUB_USER: 'sub-user',
14
+ EXISTING: 'existing',
15
+ GUEST: 'guest',
16
+ };
17
+ exports.GameTicketStatusSchema = zod_1.z.enum(exports.GAME_TICKET_STATUS);
18
+ exports.TicketUserTypeSchema = zod_1.z.enum(exports.TICKET_USER_TYPE);
19
+ exports.GameTicketSchema = zod_1.z.object({
20
+ id: zod_1.z.string(),
21
+ purchaseId: zod_1.z.string(),
22
+ gameTurnId: zod_1.z.string(),
23
+ ownerUsername: zod_1.z.string(),
24
+ userType: exports.TicketUserTypeSchema,
25
+ status: exports.GameTicketStatusSchema,
26
+ createdAt: zod_1.z.date(),
27
+ updatedAt: zod_1.z.date(),
28
+ completedAt: zod_1.z.date().optional(),
29
+ });
30
+ exports.PurchaseSchema = zod_1.z.object({
31
+ id: zod_1.z.string(),
32
+ purchaseNumber: zod_1.z.number(),
33
+ buyerUserId: zod_1.z.string(),
34
+ totalTickets: zod_1.z.number(),
35
+ availableTickets: zod_1.z.number(),
36
+ usedTickets: zod_1.z.number(),
37
+ purchaseDate: zod_1.z.date(),
38
+ paymentData: zod_1.z.any().optional(),
39
+ createdAt: zod_1.z.date(),
40
+ updatedAt: zod_1.z.date(),
41
+ });
@@ -1,9 +1,4 @@
1
- import type { UserRole } from '../role/UserRole';
2
- import type { UserOrigin } from './UserOrigin';
3
- export interface User {
4
- id: string;
5
- username: string;
6
- name: string;
7
- origin: UserOrigin;
8
- role: UserRole;
9
- }
1
+ import { z } from 'zod';
2
+ import { UserSchema, UserWithPasswordSchema } from './user.schema';
3
+ export type User = z.infer<typeof UserSchema>;
4
+ export type UserWithPassword = z.infer<typeof UserWithPasswordSchema>;
@@ -1,2 +1,4 @@
1
1
  export * from './User';
2
- export * from './UserOrigin';
2
+ export * from './user-type.schema';
3
+ export * from './user.schema';
4
+ export { USER_TYPE } from './user-type.schema';
@@ -14,5 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.USER_TYPE = void 0;
17
18
  __exportStar(require("./User"), exports);
18
- __exportStar(require("./UserOrigin"), exports);
19
+ __exportStar(require("./user-type.schema"), exports);
20
+ __exportStar(require("./user.schema"), exports);
21
+ var user_type_schema_1 = require("./user-type.schema");
22
+ Object.defineProperty(exports, "USER_TYPE", { enumerable: true, get: function () { return user_type_schema_1.USER_TYPE; } });
@@ -0,0 +1,9 @@
1
+ import z from 'zod';
2
+ export declare const USER_TYPE: {
3
+ readonly STAFF: "STAFF";
4
+ readonly PLAYER: "PLAYER";
5
+ };
6
+ export declare const UserTypeSchema: z.ZodEnum<{
7
+ readonly STAFF: "STAFF";
8
+ readonly PLAYER: "PLAYER";
9
+ }>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UserTypeSchema = exports.USER_TYPE = void 0;
7
+ const zod_1 = __importDefault(require("zod"));
8
+ exports.USER_TYPE = {
9
+ STAFF: 'STAFF',
10
+ PLAYER: 'PLAYER',
11
+ };
12
+ exports.UserTypeSchema = zod_1.default.enum(exports.USER_TYPE);
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ export declare const UserRoleSchema: z.ZodEnum<{
3
+ SUPER_ADMIN: "SUPER_ADMIN";
4
+ OPERATOR: "OPERATOR";
5
+ PLAYER: "PLAYER";
6
+ }>;
7
+ export declare const UserSchema: z.ZodObject<{
8
+ id: z.ZodString;
9
+ name: z.ZodString;
10
+ username: z.ZodString;
11
+ email: z.ZodEmail;
12
+ phone: z.ZodOptional<z.ZodString>;
13
+ role: z.ZodEnum<{
14
+ SUPER_ADMIN: "SUPER_ADMIN";
15
+ OPERATOR: "OPERATOR";
16
+ PLAYER: "PLAYER";
17
+ }>;
18
+ type: z.ZodEnum<{
19
+ readonly STAFF: "STAFF";
20
+ readonly PLAYER: "PLAYER";
21
+ }>;
22
+ }, z.core.$strip>;
23
+ export declare const UserWithPasswordSchema: z.ZodObject<{
24
+ id: z.ZodString;
25
+ name: z.ZodString;
26
+ username: z.ZodString;
27
+ email: z.ZodEmail;
28
+ phone: z.ZodOptional<z.ZodString>;
29
+ role: z.ZodEnum<{
30
+ SUPER_ADMIN: "SUPER_ADMIN";
31
+ OPERATOR: "OPERATOR";
32
+ PLAYER: "PLAYER";
33
+ }>;
34
+ type: z.ZodEnum<{
35
+ readonly STAFF: "STAFF";
36
+ readonly PLAYER: "PLAYER";
37
+ }>;
38
+ password: z.ZodString;
39
+ }, z.core.$strip>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserWithPasswordSchema = exports.UserSchema = exports.UserRoleSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const user_role_1 = require("../../constants/user-role");
6
+ const user_type_schema_1 = require("./user-type.schema");
7
+ exports.UserRoleSchema = zod_1.z.enum([user_role_1.USER_ROLE.SUPER_ADMIN, user_role_1.USER_ROLE.PLAYER, user_role_1.USER_ROLE.OPERATOR]);
8
+ exports.UserSchema = zod_1.z.object({
9
+ id: zod_1.z.string(),
10
+ name: zod_1.z.string(),
11
+ username: zod_1.z.string(),
12
+ email: zod_1.z.email(),
13
+ phone: zod_1.z.string().optional(),
14
+ role: exports.UserRoleSchema,
15
+ type: user_type_schema_1.UserTypeSchema,
16
+ });
17
+ exports.UserWithPasswordSchema = exports.UserSchema.extend({
18
+ password: zod_1.z.string(),
19
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@battle-racing/br-common-lib",
3
- "version": "3.5.0",
3
+ "version": "3.8.0",
4
4
  "description": "Common library for all Battle Racing Repositorios",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -30,6 +30,10 @@
30
30
  "license": "MIT",
31
31
  "private": false,
32
32
  "devDependencies": {
33
- "typescript": "^5.8.3"
33
+ "typescript": "^5.8.3",
34
+ "zod": "^4.2.1"
35
+ },
36
+ "peerDependencies": {
37
+ "zod": "^4.2.1"
34
38
  }
35
39
  }
@@ -2,6 +2,7 @@ export * from './checkpoint-type';
2
2
  export * from './hardware';
3
3
  export * from './kart-status';
4
4
  export * from './module-name';
5
+ export * from './payment-provider';
6
+ export * from './payment-status';
5
7
  export * from './permission';
6
8
  export * from './user-role';
7
-
@@ -0,0 +1,5 @@
1
+ export const PAYMENT_PROVIDERS = {
2
+ STRIPE: 'stripe',
3
+ PAYPAL: 'paypal',
4
+ OTHER: 'other',
5
+ } as const;
@@ -0,0 +1,7 @@
1
+ export const PAYMENT_STATUSES = {
2
+ PENDING: 'pending',
3
+ COMPLETED: 'completed',
4
+ FAILED: 'failed',
5
+ REFUNDED: 'refunded',
6
+ CANCELLED: 'cancelled',
7
+ } as const;
@@ -1,4 +1,5 @@
1
1
  export const USER_ROLE = {
2
2
  SUPER_ADMIN: 'SUPER_ADMIN',
3
3
  OPERATOR: 'OPERATOR',
4
+ PLAYER: 'PLAYER',
4
5
  } as const;
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+
3
+ export const TeamSchema = z.object({
4
+ name: z.string().min(3).max(50),
5
+ imageUrl: z.url().optional(),
6
+ fanatismo: z.number().int().min(0).max(100).optional(),
7
+ });
8
+
9
+ export type Team = z.infer<typeof TeamSchema>;
@@ -0,0 +1,10 @@
1
+ import type { Kart } from '../kart';
2
+ import type { GameTrack } from './GameTrack';
3
+
4
+ export interface GameTrackKartConfig {
5
+ gameTrackId: GameTrack['id'];
6
+ kartId: number;
7
+ color: Kart['color'];
8
+ kartNumber: Kart['number'];
9
+ mac: string;
10
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './GameTrack';
2
2
  export * from './GameTrackGameDefaultValues';
3
+ export * from './GameTrackKartConfig';
3
4
  export * from './GameTrackKartsConfig';
@@ -13,11 +13,13 @@ export * from './gameTrack';
13
13
  export * from './hardware';
14
14
  export * from './kart';
15
15
  export * from './kartTracking';
16
+ export * from './pagination';
16
17
  export * from './powerUp';
18
+ export * from './racingTeam';
17
19
  export * from './response';
18
20
  export * from './role';
19
21
  export * from './socket';
20
22
  export * from './sounds';
23
+ export * from './ticketing';
21
24
  export * from './user';
22
25
  export * from './utils';
23
-
@@ -0,0 +1,4 @@
1
+ import z from 'zod';
2
+ import { paginationMetadataSchema } from './pagination.schema';
3
+
4
+ export type Pagination = z.infer<typeof paginationMetadataSchema>;
@@ -0,0 +1,2 @@
1
+ export * from './Pagination';
2
+ export * from './pagination.schema';
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+
3
+ export const paginationMetadataSchema = z.object({
4
+ nextCursor: z.string().optional(),
5
+ hasMore: z.boolean().optional(),
6
+ limit: z.number(),
7
+ });
8
+
9
+ export const paginatedResponseSchema = <T extends z.ZodTypeAny>(itemSchema: T) => {
10
+ return z.object({
11
+ data: z.array(itemSchema),
12
+ meta: paginationMetadataSchema,
13
+ });
14
+ };