@natrave/shared-entities 1.1.1

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 (79) hide show
  1. package/.changeset/README.md +9 -0
  2. package/.changeset/config.json +11 -0
  3. package/.github/workflows/release.yml +80 -0
  4. package/.husky/pre-commit +4 -0
  5. package/.husky/pre-push +4 -0
  6. package/.lintstagedrc.json +5 -0
  7. package/.prettierignore +2 -0
  8. package/.prettierrc.json +12 -0
  9. package/CHANGELOG.md +13 -0
  10. package/eslint.config.js +84 -0
  11. package/package.json +52 -0
  12. package/src/app-auth/index.ts +5 -0
  13. package/src/app-auth/password-resets/index.ts +1 -0
  14. package/src/app-auth/password-resets/password-reset.entity.ts +52 -0
  15. package/src/app-auth/refresh-tokens/index.ts +1 -0
  16. package/src/app-auth/refresh-tokens/refresh-token.entity.ts +52 -0
  17. package/src/app-auth/user-auth-providers/enums/auth-provider.enum.ts +24 -0
  18. package/src/app-auth/user-auth-providers/index.ts +3 -0
  19. package/src/app-auth/user-auth-providers/user-auth-provider.entity.ts +58 -0
  20. package/src/app-auth/user-verifications/enums/verification-type.enum.ts +19 -0
  21. package/src/app-auth/user-verifications/index.ts +3 -0
  22. package/src/app-auth/user-verifications/user-verification.entity.ts +62 -0
  23. package/src/app-auth/users/index.ts +1 -0
  24. package/src/app-auth/users/user.entity.ts +149 -0
  25. package/src/app-auth/users/utils/format-data.utils.ts +38 -0
  26. package/src/common/utils/decimal-transformer.utils.ts +13 -0
  27. package/src/facilities/addresses/address.entity.ts +82 -0
  28. package/src/facilities/addresses/index.ts +1 -0
  29. package/src/facilities/facilities/enums/facility-status.enum.ts +25 -0
  30. package/src/facilities/facilities/facility.entity.ts +137 -0
  31. package/src/facilities/facilities/index.ts +3 -0
  32. package/src/facilities/facilities/utils/sanititze.utils.ts +19 -0
  33. package/src/facilities/facility-images/facility-image.entity.ts +64 -0
  34. package/src/facilities/facility-images/index.ts +1 -0
  35. package/src/facilities/facility-owners/facility-owner.entity.ts +74 -0
  36. package/src/facilities/facility-owners/index.ts +1 -0
  37. package/src/facilities/facility-owners/utils/sanitize.utils.ts +16 -0
  38. package/src/facilities/fields/enums/surface-type.enum.ts +35 -0
  39. package/src/facilities/fields/field.entity.ts +74 -0
  40. package/src/facilities/fields/index.ts +3 -0
  41. package/src/facilities/index.ts +5 -0
  42. package/src/index.ts +7 -0
  43. package/src/payments/index.ts +5 -0
  44. package/src/payments/payment-providers/enums/payment-provider-name.enum.ts +15 -0
  45. package/src/payments/payment-providers/index.ts +3 -0
  46. package/src/payments/payment-providers/payment-provider.entity.ts +61 -0
  47. package/src/payments/payments/enums/payment-method.enum.ts +20 -0
  48. package/src/payments/payments/enums/payment-status.enum.ts +45 -0
  49. package/src/payments/payments/index.ts +5 -0
  50. package/src/payments/payments/payment.entity.ts +84 -0
  51. package/src/payments/user-payment-providers/index.ts +1 -0
  52. package/src/payments/user-payment-providers/user-payment-provider.entity.ts +73 -0
  53. package/src/tournaments/index.ts +12 -0
  54. package/src/tournaments/tournament-facilities/index.ts +1 -0
  55. package/src/tournaments/tournament-facilities/tournament-facility.entity.ts +67 -0
  56. package/src/tournaments/tournament-format-configs/index.ts +1 -0
  57. package/src/tournaments/tournament-format-configs/tournament-format-config.entity.ts +69 -0
  58. package/src/tournaments/tournament-match-cards/index.ts +1 -0
  59. package/src/tournaments/tournament-match-cards/tournament-match-card.entity.ts +86 -0
  60. package/src/tournaments/tournament-match-goals/index.ts +1 -0
  61. package/src/tournaments/tournament-match-goals/tournament-match-goal.entity.ts +88 -0
  62. package/src/tournaments/tournament-match-schemas/index.ts +1 -0
  63. package/src/tournaments/tournament-match-schemas/tournament-match-schema.entity.ts +51 -0
  64. package/src/tournaments/tournament-matches/index.ts +1 -0
  65. package/src/tournaments/tournament-matches/tournament-match.entity.ts +101 -0
  66. package/src/tournaments/tournament-payments/index.ts +1 -0
  67. package/src/tournaments/tournament-payments/tournament-payment.entity.ts +67 -0
  68. package/src/tournaments/tournament-players/index.ts +1 -0
  69. package/src/tournaments/tournament-players/tournament-player.entity.ts +96 -0
  70. package/src/tournaments/tournament-prize-rules/index.ts +1 -0
  71. package/src/tournaments/tournament-prize-rules/tournament-prize-rule.entity.ts +65 -0
  72. package/src/tournaments/tournament-rules/index.ts +1 -0
  73. package/src/tournaments/tournament-rules/tournament-rule.entity.ts +81 -0
  74. package/src/tournaments/tournament-teams/index.ts +1 -0
  75. package/src/tournaments/tournament-teams/tournament-team.entity.ts +111 -0
  76. package/src/tournaments/tournament-teams/utils/invite-code-generator.ts +12 -0
  77. package/src/tournaments/tournaments/index.ts +1 -0
  78. package/src/tournaments/tournaments/tournament.entity.ts +153 -0
  79. package/tsconfig.json +29 -0
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Gera um código de convite aleatório com 5 dígitos.
3
+ *
4
+ * @returns {string} Um código de convite como string.
5
+ *
6
+ * @remarks
7
+ * A função utiliza o método Math.random para gerar um número aleatório entre 10000 e 99999,
8
+ * garantindo que o código tenha sempre 5 dígitos.
9
+ */
10
+ export function generateRandomInviteCode(): string {
11
+ return Math.floor(10000 + Math.random() * 90000).toString();
12
+ }
@@ -0,0 +1 @@
1
+ export { Tournament } from './tournament.entity';
@@ -0,0 +1,153 @@
1
+ import { DayOfWeek, ITournament, TournamentGender } from '@natrave/tournaments-service-types';
2
+ import {
3
+ Entity,
4
+ Column,
5
+ PrimaryGeneratedColumn,
6
+ CreateDateColumn,
7
+ UpdateDateColumn,
8
+ OneToMany,
9
+ OneToOne,
10
+ ManyToOne,
11
+ JoinColumn,
12
+ } from 'typeorm';
13
+
14
+ import { TournamentFacility } from 'tournaments/tournament-facilities';
15
+ import { TournamentFormatConfig } from 'tournaments/tournament-format-configs';
16
+ import { TournamentMatchSchema } from 'tournaments/tournament-match-schemas';
17
+ import { TournamentMatch } from 'tournaments/tournament-matches';
18
+ import { TournamentPayment } from 'tournaments/tournament-payments';
19
+ import { TournamentPrizeRule } from 'tournaments/tournament-prize-rules';
20
+ import { TournamentRule } from 'tournaments/tournament-rules';
21
+ import { TournamentTeam } from 'tournaments/tournament-teams';
22
+
23
+ /**
24
+ * Entidade que representa um torneio.
25
+ *
26
+ * @remarks
27
+ * Esta entidade armazena todas as propriedades essenciais de um torneio, como datas, formato, regras,
28
+ * dias de partida, informações de localização e gênero, além das datas de criação e atualização.
29
+ *
30
+ * @public
31
+ */
32
+ @Entity('tournaments')
33
+ export class Tournament implements ITournament {
34
+ @PrimaryGeneratedColumn()
35
+ id: number;
36
+
37
+ @Column({ type: 'varchar', length: 255 })
38
+ name: string;
39
+
40
+ @Column({ name: 'initial_date', type: 'timestamptz' })
41
+ initialDate: Date;
42
+
43
+ @Column({ name: 'end_date', type: 'timestamptz' })
44
+ endDate: Date;
45
+
46
+ @Column({ type: 'text', nullable: true })
47
+ description?: string | null;
48
+
49
+ @Column({ name: 'tournament_image', type: 'text', nullable: true })
50
+ tournamentImage?: string | null;
51
+
52
+ @Column({ name: 'match_schema_id', type: 'int', nullable: true })
53
+ matchSchemaId?: number | null;
54
+
55
+ @Column({ name: 'rule_id', type: 'int' })
56
+ ruleId: number;
57
+
58
+ @Column({ name: 'format_config_id', type: 'int' })
59
+ formatConfigId: number;
60
+
61
+ @Column({
62
+ name: 'match_days',
63
+ type: 'enum',
64
+ enum: Object.values(DayOfWeek),
65
+ array: true,
66
+ })
67
+ matchDays: DayOfWeek[];
68
+
69
+ @Column({ name: 'price_per_team', type: 'int' })
70
+ pricePerTeam: number;
71
+
72
+ @Column({ name: 'match_start_time', type: 'time' })
73
+ matchStartTime: string;
74
+
75
+ @Column({ name: 'match_end_time', type: 'time' })
76
+ matchEndTime: string;
77
+
78
+ @Column({ type: 'varchar', length: 100 })
79
+ city: string;
80
+
81
+ @Column({ type: 'varchar', length: 2 })
82
+ state: string;
83
+
84
+ @Column({
85
+ type: 'enum',
86
+ enum: Object.values(TournamentGender),
87
+ })
88
+ gender: TournamentGender;
89
+
90
+ @Column({ name: 'deleted_at', type: 'timestamptz', nullable: true })
91
+ deletedAt: Date | null;
92
+
93
+ @CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
94
+ createdAt: Date;
95
+
96
+ @UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
97
+ updatedAt: Date;
98
+
99
+ /** RELAÇÕES */
100
+
101
+ /**
102
+ * Relação com o esquema de partidas associado ao torneio.
103
+ */
104
+ @ManyToOne(() => TournamentMatchSchema, (matchSchema) => matchSchema.tournaments, {
105
+ onDelete: 'CASCADE',
106
+ })
107
+ @JoinColumn({ name: 'match_schema_id' })
108
+ matchSchema: TournamentMatchSchema;
109
+
110
+ /**
111
+ * Relação com os times associados ao torneio.
112
+ */
113
+ @OneToMany(() => TournamentTeam, (team) => team.tournament)
114
+ teams: TournamentTeam[];
115
+
116
+ /**
117
+ * Relação com as regras do torneio.
118
+ */
119
+ @OneToOne(() => TournamentRule, (rule) => rule.tournament, { cascade: true })
120
+ @JoinColumn({ name: 'rule_id' })
121
+ rule: TournamentRule;
122
+
123
+ /**
124
+ * Relação com o formato do torneio.
125
+ */
126
+ @OneToOne(() => TournamentFormatConfig, (format) => format.tournament, { cascade: true })
127
+ @JoinColumn({ name: 'format_config_id' })
128
+ format: TournamentFormatConfig;
129
+
130
+ /**
131
+ * Relação com as regras de premiação associadas ao torneio.
132
+ */
133
+ @OneToMany(() => TournamentPrizeRule, (prizeRule) => prizeRule.tournament)
134
+ prizeRules: TournamentPrizeRule[];
135
+
136
+ /**
137
+ * Relação com os pagamentos associados ao torneio.
138
+ */
139
+ @OneToMany(() => TournamentPayment, (payment) => payment.tournament)
140
+ payments: TournamentPayment[];
141
+
142
+ /**
143
+ * Relação com as partidas associadas ao torneio.
144
+ */
145
+ @OneToMany(() => TournamentMatch, (match) => match.tournament)
146
+ matches: TournamentMatch[];
147
+
148
+ /**
149
+ * Relação com os estabelecimentos associadas ao torneio.
150
+ */
151
+ @OneToMany(() => TournamentFacility, (facility) => facility.tournament)
152
+ tournamentFacilities: TournamentFacility[];
153
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "dist",
4
+ "module": "ESNext",
5
+ "target": "ES2021",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "sourceMap": true,
9
+ "strict": true,
10
+ "moduleResolution": "node",
11
+ "esModuleInterop": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "allowSyntheticDefaultImports": true,
14
+ "skipLibCheck": true,
15
+ "resolveJsonModule": true,
16
+ "noImplicitAny": true,
17
+ "noUnusedLocals": true,
18
+ "noUnusedParameters": true,
19
+ "noFallthroughCasesInSwitch": true,
20
+ "removeComments": true,
21
+ "experimentalDecorators": true,
22
+ "emitDecoratorMetadata": true,
23
+ "strictPropertyInitialization": false,
24
+ "baseUrl": "./src"
25
+ },
26
+
27
+ "include": ["src"],
28
+ "exclude": ["node_modules", "dist", "tests"]
29
+ }