@natrave/shared-entities 1.5.6 → 1.6.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.
@@ -5,6 +5,10 @@ export declare class RefreshToken {
5
5
  expiresAt: Date;
6
6
  revokedAt: Date | null;
7
7
  token: string;
8
+ tokenHash: string | null;
9
+ usedAt: Date | null;
10
+ replacedByTokenId: string | null;
11
+ issuedSessionVersion: number;
8
12
  userId: string;
9
13
  user: User;
10
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"refresh-token.entity.d.ts","sourceRoot":"","sources":["../../../src/app-auth/refresh-tokens/refresh-token.entity.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAYhC,qBAEa,YAAY;IAEvB,EAAE,EAAE,MAAM,CAAC;IAOX,SAAS,EAAE,IAAI,CAAC;IAOhB,SAAS,EAAE,IAAI,CAAC;IAQhB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IAQvB,KAAK,EAAE,MAAM,CAAC;IAOd,MAAM,EAAE,MAAM,CAAC;IASf,IAAI,EAAE,IAAI,CAAC;CACZ"}
1
+ {"version":3,"file":"refresh-token.entity.d.ts","sourceRoot":"","sources":["../../../src/app-auth/refresh-tokens/refresh-token.entity.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAYhC,qBAOa,YAAY;IAEvB,EAAE,EAAE,MAAM,CAAC;IAOX,SAAS,EAAE,IAAI,CAAC;IAOhB,SAAS,EAAE,IAAI,CAAC;IAQhB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IAQvB,KAAK,EAAE,MAAM,CAAC;IASd,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAQzB,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IAQpB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAQjC,oBAAoB,EAAE,MAAM,CAAC;IAO7B,MAAM,EAAE,MAAM,CAAC;IASf,IAAI,EAAE,IAAI,CAAC;CACZ"}
@@ -12,6 +12,7 @@ import {
12
12
  Column,
13
13
  CreateDateColumn,
14
14
  Entity,
15
+ Index,
15
16
  JoinColumn,
16
17
  ManyToOne,
17
18
  PrimaryGeneratedColumn,
@@ -53,6 +54,39 @@ __decorateClass([
53
54
  comment: "Token de atualiza\xE7\xE3o propriamente dito, utilizado para renovar a sess\xE3o."
54
55
  })
55
56
  ], RefreshToken.prototype, "token", 2);
57
+ __decorateClass([
58
+ Column({
59
+ name: "token_hash",
60
+ type: "char",
61
+ length: 64,
62
+ nullable: true,
63
+ comment: "Hash do refresh token para lookup e valida\xE7\xE3o sem armazenar o token em claro."
64
+ })
65
+ ], RefreshToken.prototype, "tokenHash", 2);
66
+ __decorateClass([
67
+ Column({
68
+ name: "used_at",
69
+ type: "timestamptz",
70
+ nullable: true,
71
+ comment: "Data e hora em que o refresh token foi utilizado."
72
+ })
73
+ ], RefreshToken.prototype, "usedAt", 2);
74
+ __decorateClass([
75
+ Column({
76
+ name: "replaced_by_token_id",
77
+ type: "uuid",
78
+ nullable: true,
79
+ comment: "ID do novo refresh token que substituiu este token."
80
+ })
81
+ ], RefreshToken.prototype, "replacedByTokenId", 2);
82
+ __decorateClass([
83
+ Column({
84
+ name: "issued_session_version",
85
+ type: "int",
86
+ default: 0,
87
+ comment: "Vers\xE3o da sess\xE3o do usu\xE1rio no momento da emiss\xE3o do refresh token."
88
+ })
89
+ ], RefreshToken.prototype, "issuedSessionVersion", 2);
56
90
  __decorateClass([
57
91
  Column({
58
92
  name: "user_id",
@@ -66,7 +100,12 @@ __decorateClass([
66
100
  ], RefreshToken.prototype, "user", 2);
67
101
  RefreshToken = __decorateClass([
68
102
  Entity("refresh_tokens"),
69
- Unique(["token"])
103
+ Unique(["token"]),
104
+ Index("UQ_refresh_tokens_token_hash", ["tokenHash"], {
105
+ unique: true,
106
+ where: '"token_hash" IS NOT NULL'
107
+ }),
108
+ Index("IDX_refresh_tokens_user_id_revoked_at", ["userId", "revokedAt"])
70
109
  ], RefreshToken);
71
110
  export {
72
111
  RefreshToken
@@ -19,6 +19,7 @@ export declare class User {
19
19
  cpfHash: string | null;
20
20
  phone: string | null;
21
21
  imageUrl: string | null;
22
+ sessionVersion: number;
22
23
  refreshTokens: RefreshToken[];
23
24
  userAuthProviders: UserAuthProvider[];
24
25
  player: Player;
@@ -1 +1 @@
1
- {"version":3,"file":"user.entity.d.ts","sourceRoot":"","sources":["../../../src/app-auth/users/user.entity.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAa7C,qBAiBa,IAAI;IAIf,EAAE,EAAE,MAAM,CAAC;IAUX,SAAS,EAAE,MAAM,CAAC;IAOlB,SAAS,EAAE,IAAI,CAAC;IAOhB,SAAS,EAAE,IAAI,CAAC;IAQhB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IASvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAQpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAQzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAQ3B,KAAK,EAAE,MAAM,CAAC;IAQd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAQtB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAS5B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAUvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IASrB,QAAQ,EAAE,MAAM,GAA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,EAAE,MAAM,GAAG,IAAI,CAAC;IASrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAQxB,cAAc,EAAE,MAAM,CAAC;IAKvB,aAAa,EAAE,YAAY,EAAE,CAAC;IAK9B,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IAKtC,MAAM,EAAE,MAAM,CAAC;IAGf,aAAa,EAAE,YAAY,EAAE,CAAC;IAG9B,gBAAgB,EAAE,eAAe,EAAE,CAAC;IAMpC,sBAAsB,EAAE,0BAA0B,GAAG,IAAI,CAAC;IAG1D,8BAA8B,EAAE,6BAA6B,EAAE,CAAC;IAMhE,WAAW,IAAI,IAAI;CAGpB"}
@@ -147,6 +147,14 @@ __decorateClass([
147
147
  comment: "URL da imagem de perfil do usu\xE1rio."
148
148
  })
149
149
  ], User.prototype, "imageUrl", 2);
150
+ __decorateClass([
151
+ Column({
152
+ name: "session_version",
153
+ type: "int",
154
+ default: 0,
155
+ comment: "Vers\xE3o atual de sess\xE3o do usu\xE1rio para invalida\xE7\xE3o global de refresh tokens."
156
+ })
157
+ ], User.prototype, "sessionVersion", 2);
150
158
  __decorateClass([
151
159
  OneToMany(() => RefreshToken, (refreshToken) => refreshToken.user)
152
160
  ], User.prototype, "refreshTokens", 2);
@@ -195,7 +203,8 @@ User = __decorateClass([
195
203
  Index("IDX_users_created_at", ["createdAt"]),
196
204
  Index("IDX_users_updated_at", ["updatedAt"]),
197
205
  Index("IDX_users_name", ["name"], { where: '"deleted_at" IS NULL' }),
198
- Index("IDX_users_gender", ["gender"], { where: '"deleted_at" IS NULL' })
206
+ Index("IDX_users_gender", ["gender"], { where: '"deleted_at" IS NULL' }),
207
+ Index("IDX_users_id_session_version", ["id", "sessionVersion"])
199
208
  ], User);
200
209
  export {
201
210
  User
@@ -6,8 +6,8 @@ import { TeamPlayerMergeHistory } from '../history-logs';
6
6
  import { Notification, NotificationDelivery, NotificationDispatchLog, PushDeviceToken, UserNotificationPreference } from '../notifications';
7
7
  import { Payment, PaymentProvider, UserPaymentProvider } from '../payments';
8
8
  import { Player, PlayerPersonalData, PlayerPosition } from '../players';
9
- import { PlayerTeam, Team, TeamJoinRequest, TeamModality, TeamTrophy } from '../teams';
9
+ import { PlayerTeam, Team, TeamAccessCode, TeamJoinRequest, TeamModality, TeamTrophy } from '../teams';
10
10
  import { Tournament, TournamentAllowedPhone, TournamentBracket, TournamentBracketSlot, TournamentContact, TournamentCoupon, TournamentFacility, TournamentFormatConfig, TournamentGroup, TournamentMatch, TournamentMatchAvailability, TournamentMatchCard, TournamentMatchGoal, TournamentMatchRule, TournamentMatchSchema, TournamentPayment, TournamentPenaltyShootout, TournamentPlayer, TournamentPlayerRule, TournamentPrizeRule, TournamentPublicationChargeRule, TournamentRegistrationRequest, TournamentRegistrationRequirement, TournamentTeam, TournamentTeamContactAttempt } from '../tournaments';
11
11
  import { UserDomainEvent, UserEventView } from '../user-events';
12
- export declare const DATABASE_ENTITIES: (typeof PasswordReset | typeof Notification | typeof User | typeof NotificationDelivery | typeof NotificationDispatchLog | typeof PushDeviceToken | typeof UserNotificationPreference | typeof TeamPlayerMergeHistory | typeof Team | typeof PlayerTeam | typeof Player | typeof FacilityImage | typeof Facility | typeof FieldImage | typeof Field | typeof Address | typeof TournamentFacility | typeof OrganizationUserBillingInfo | typeof PhoneNumber | typeof Organization | typeof TournamentAllowedPhone | typeof OrganizationUser | typeof Tournament | typeof TournamentPayment | typeof FacilityOwner | typeof TournamentContact | typeof Coupon | typeof CouponUsage | typeof TournamentCoupon | typeof TournamentFormatConfig | typeof TournamentMatchGoal | typeof TournamentTeam | typeof TournamentMatch | typeof TournamentPlayer | typeof TournamentMatchCard | typeof TournamentPenaltyShootout | typeof TournamentGroup | typeof TournamentBracketSlot | typeof TournamentMatchRule | typeof TournamentMatchSchema | typeof TournamentMatchAvailability | typeof UserPaymentProvider | typeof PaymentProvider | typeof Payment | typeof TournamentPlayerRule | typeof TournamentPrizeRule | typeof TournamentRegistrationRequest | typeof TournamentRegistrationRequirement | typeof TournamentTeamContactAttempt | typeof TournamentBracket | typeof TeamTrophy | typeof TournamentPublicationChargeRule | typeof TeamJoinRequest | typeof TeamModality | typeof PlayerPosition | typeof PlayerPersonalData | typeof UserAuthProvider | typeof RefreshToken | typeof UserVerification | typeof UserDomainEvent | typeof UserEventView)[];
12
+ export declare const DATABASE_ENTITIES: (typeof PasswordReset | typeof Notification | typeof User | typeof NotificationDelivery | typeof NotificationDispatchLog | typeof PushDeviceToken | typeof UserNotificationPreference | typeof TeamPlayerMergeHistory | typeof Team | typeof PlayerTeam | typeof Player | typeof FacilityImage | typeof Facility | typeof FieldImage | typeof Field | typeof Address | typeof TournamentFacility | typeof OrganizationUserBillingInfo | typeof PhoneNumber | typeof Organization | typeof TournamentAllowedPhone | typeof OrganizationUser | typeof Tournament | typeof TournamentPayment | typeof FacilityOwner | typeof TournamentContact | typeof Coupon | typeof CouponUsage | typeof TournamentCoupon | typeof TournamentFormatConfig | typeof TournamentMatchGoal | typeof TournamentTeam | typeof TournamentMatch | typeof TournamentPlayer | typeof TournamentMatchCard | typeof TournamentPenaltyShootout | typeof TournamentGroup | typeof TournamentBracketSlot | typeof TournamentMatchRule | typeof TournamentMatchSchema | typeof TournamentMatchAvailability | typeof UserPaymentProvider | typeof PaymentProvider | typeof Payment | typeof TournamentPlayerRule | typeof TournamentPrizeRule | typeof TournamentRegistrationRequest | typeof TournamentRegistrationRequirement | typeof TournamentTeamContactAttempt | typeof TournamentBracket | typeof TeamTrophy | typeof TournamentPublicationChargeRule | typeof TeamJoinRequest | typeof TeamModality | typeof TeamAccessCode | typeof PlayerPosition | typeof PlayerPersonalData | typeof UserAuthProvider | typeof RefreshToken | typeof UserVerification | typeof UserDomainEvent | typeof UserEventView)[];
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/database-entities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE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"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/database-entities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpG,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,2BAA2B,EAC3B,WAAW,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,EACf,0BAA0B,EAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EACL,UAAU,EACV,IAAI,EACJ,cAAc,EACd,eAAe,EACf,YAAY,EACZ,UAAU,EACX,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,2BAA2B,EAC3B,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,+BAA+B,EAC/B,6BAA6B,EAC7B,iCAAiC,EAEjC,cAAc,EACd,4BAA4B,EAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEhE,eAAO,MAAM,iBAAiB,ulDAgE7B,CAAC"}
@@ -17,7 +17,14 @@ import {
17
17
  } from "../notifications/index.js";
18
18
  import { Payment, PaymentProvider, UserPaymentProvider } from "../payments/index.js";
19
19
  import { Player, PlayerPersonalData, PlayerPosition } from "../players/index.js";
20
- import { PlayerTeam, Team, TeamJoinRequest, TeamModality, TeamTrophy } from "../teams/index.js";
20
+ import {
21
+ PlayerTeam,
22
+ Team,
23
+ TeamAccessCode,
24
+ TeamJoinRequest,
25
+ TeamModality,
26
+ TeamTrophy
27
+ } from "../teams/index.js";
21
28
  import {
22
29
  Tournament,
23
30
  TournamentAllowedPhone,
@@ -96,6 +103,7 @@ const DATABASE_ENTITIES = [
96
103
  PlayerPersonalData,
97
104
  PlayerPosition,
98
105
  Team,
106
+ TeamAccessCode,
99
107
  PlayerTeam,
100
108
  TeamModality,
101
109
  TeamJoinRequest,
@@ -1,5 +1,6 @@
1
1
  export { TeamJoinRequestStatus } from './enums/request-status.enum';
2
2
  export * from './player-team';
3
+ export * from './team-access-codes';
3
4
  export * from './team-join-requests';
4
5
  export * from './team-modality';
5
6
  export * from './team-trophy';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/teams/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/teams/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { TeamJoinRequestStatus } from "./enums/request-status.enum.js";
2
2
  export * from "./player-team/index.js";
3
+ export * from "./team-access-codes/index.js";
3
4
  export * from "./team-join-requests/index.js";
4
5
  export * from "./team-modality/index.js";
5
6
  export * from "./team-trophy/index.js";
@@ -0,0 +1,2 @@
1
+ export { TeamAccessCode } from './team-access-code.entity';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/teams/team-access-codes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { TeamAccessCode } from "./team-access-code.entity.js";
2
+ export {
3
+ TeamAccessCode
4
+ };
@@ -0,0 +1,16 @@
1
+ import { Team } from '../teams/team.entity';
2
+ export declare class TeamAccessCode {
3
+ id: number;
4
+ teamId: number;
5
+ code: string;
6
+ isActive: boolean;
7
+ expiresAt: Date | null;
8
+ maxUses: number | null;
9
+ usedCount: number;
10
+ lastUsedAt: Date | null;
11
+ revokedAt: Date | null;
12
+ createdAt: Date;
13
+ updatedAt: Date;
14
+ team: Team;
15
+ }
16
+ //# sourceMappingURL=team-access-code.entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"team-access-code.entity.d.ts","sourceRoot":"","sources":["../../../src/teams/team-access-codes/team-access-code.entity.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,qBAOa,cAAc;IAIzB,EAAE,EAAE,MAAM,CAAC;IAGX,MAAM,EAAE,MAAM,CAAC;IAOf,IAAI,EAAE,MAAM,CAAC;IASb,QAAQ,EAAE,OAAO,CAAC;IAQlB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IAQvB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAQvB,SAAS,EAAE,MAAM,CAAC;IAQlB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IAQxB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IAOvB,SAAS,EAAE,IAAI,CAAC;IAOhB,SAAS,EAAE,IAAI,CAAC;IAIhB,IAAI,EAAE,IAAI,CAAC;CACZ"}
@@ -0,0 +1,116 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+ import {
12
+ Check,
13
+ Column,
14
+ CreateDateColumn,
15
+ Entity,
16
+ JoinColumn,
17
+ ManyToOne,
18
+ PrimaryGeneratedColumn,
19
+ UpdateDateColumn
20
+ } from "typeorm";
21
+ import { Team } from "../teams/team.entity.js";
22
+ let TeamAccessCode = class {
23
+ };
24
+ __decorateClass([
25
+ PrimaryGeneratedColumn({
26
+ comment: "Identificador unico do codigo de acesso do time."
27
+ })
28
+ ], TeamAccessCode.prototype, "id", 2);
29
+ __decorateClass([
30
+ Column({ name: "team_id", type: "int", comment: "FK teams.id" })
31
+ ], TeamAccessCode.prototype, "teamId", 2);
32
+ __decorateClass([
33
+ Column({
34
+ type: "varchar",
35
+ length: 7,
36
+ comment: "Codigo de acesso unico utilizado para entrada no time."
37
+ })
38
+ ], TeamAccessCode.prototype, "code", 2);
39
+ __decorateClass([
40
+ Column({
41
+ name: "is_active",
42
+ type: "boolean",
43
+ default: true,
44
+ comment: "Indica se o codigo esta disponivel para uso. A migration deve garantir no maximo um ativo por time."
45
+ })
46
+ ], TeamAccessCode.prototype, "isActive", 2);
47
+ __decorateClass([
48
+ Column({
49
+ name: "expires_at",
50
+ type: "timestamptz",
51
+ nullable: true,
52
+ comment: "Data limite de validade do codigo, quando aplicavel."
53
+ })
54
+ ], TeamAccessCode.prototype, "expiresAt", 2);
55
+ __decorateClass([
56
+ Column({
57
+ name: "max_uses",
58
+ type: "int",
59
+ nullable: true,
60
+ comment: "Quantidade maxima de usos permitidos para o codigo."
61
+ })
62
+ ], TeamAccessCode.prototype, "maxUses", 2);
63
+ __decorateClass([
64
+ Column({
65
+ name: "used_count",
66
+ type: "int",
67
+ default: 0,
68
+ comment: "Quantidade de vezes em que o codigo foi utilizado."
69
+ })
70
+ ], TeamAccessCode.prototype, "usedCount", 2);
71
+ __decorateClass([
72
+ Column({
73
+ name: "last_used_at",
74
+ type: "timestamptz",
75
+ nullable: true,
76
+ comment: "Data do ultimo uso bem-sucedido do codigo."
77
+ })
78
+ ], TeamAccessCode.prototype, "lastUsedAt", 2);
79
+ __decorateClass([
80
+ Column({
81
+ name: "revoked_at",
82
+ type: "timestamptz",
83
+ nullable: true,
84
+ comment: "Data em que o codigo foi revogado manualmente."
85
+ })
86
+ ], TeamAccessCode.prototype, "revokedAt", 2);
87
+ __decorateClass([
88
+ CreateDateColumn({
89
+ name: "created_at",
90
+ type: "timestamptz",
91
+ comment: "Data de criacao do codigo de acesso."
92
+ })
93
+ ], TeamAccessCode.prototype, "createdAt", 2);
94
+ __decorateClass([
95
+ UpdateDateColumn({
96
+ name: "updated_at",
97
+ type: "timestamptz",
98
+ comment: "Data da ultima atualizacao do codigo de acesso."
99
+ })
100
+ ], TeamAccessCode.prototype, "updatedAt", 2);
101
+ __decorateClass([
102
+ ManyToOne(() => Team, (team) => team.accessCodes, { onDelete: "CASCADE" }),
103
+ JoinColumn({ name: "team_id" })
104
+ ], TeamAccessCode.prototype, "team", 2);
105
+ TeamAccessCode = __decorateClass([
106
+ Entity("team_access_codes"),
107
+ Check("CHK_team_access_codes_used_count_non_negative", '"used_count" >= 0'),
108
+ Check("CHK_team_access_codes_max_uses_positive", '"max_uses" IS NULL OR "max_uses" > 0'),
109
+ Check(
110
+ "CHK_team_access_codes_used_count_within_limit",
111
+ '"max_uses" IS NULL OR "used_count" <= "max_uses"'
112
+ )
113
+ ], TeamAccessCode);
114
+ export {
115
+ TeamAccessCode
116
+ };
@@ -1,8 +1,14 @@
1
1
  import { TournamentGender } from '@natrave/tournaments-service-types';
2
2
  import { BrazilianState } from '../../common/enums/brazilian-state.enum';
3
- import { TeamPlayerMergeHistory } from '../../history-logs';
4
- import { PlayerTeam, TeamJoinRequest, TeamModality, TeamTrophy } from '../../teams';
5
- import { TournamentRegistrationRequest, TournamentTeam, TournamentTeamContactAttempt } from '../../tournaments';
3
+ import { TeamPlayerMergeHistory } from '../../history-logs/team-player-merge-history/team-player-merge-history.entity';
4
+ import { TournamentRegistrationRequest } from '../../tournaments/tournament-registration-requests/tournament-registration-request.entity';
5
+ import { TournamentTeamContactAttempt } from '../../tournaments/tournament-team-contact-attempts/tournament-team-contact-attempt.entity';
6
+ import { TournamentTeam } from '../../tournaments/tournament-teams/tournament-team.entity';
7
+ import { PlayerTeam } from '../player-team/player-team.entity';
8
+ import { TeamAccessCode } from '../team-access-codes/team-access-code.entity';
9
+ import { TeamJoinRequest } from '../team-join-requests/team-join-request.entity';
10
+ import { TeamModality } from '../team-modality/team-modality.entity';
11
+ import { TeamTrophy } from '../team-trophy/team-trophy.entity';
6
12
  export declare class Team {
7
13
  id: number;
8
14
  name: string;
@@ -19,6 +25,7 @@ export declare class Team {
19
25
  updatedAt: Date;
20
26
  tournamentTeams: TournamentTeam[];
21
27
  playerMemberships: PlayerTeam[];
28
+ accessCodes: TeamAccessCode[];
22
29
  teamModalities: TeamModality[];
23
30
  joinRequests: TeamJoinRequest[];
24
31
  tournamentContactAttempts: TournamentTeamContactAttempt[];
@@ -1 +1 @@
1
- {"version":3,"file":"team.entity.d.ts","sourceRoot":"","sources":["../../../src/teams/teams/team.entity.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CAAC;IAGhC,yBAAyB,EAAE,4BAA4B,EAAE,CAAC;IAG1D,QAAQ,EAAE,UAAU,EAAE,CAAC;IAGvB,8BAA8B,EAAE,6BAA6B,EAAE,CAAC;IAGhE,YAAY,EAAE,sBAAsB,EAAE,CAAC;CACxC"}
@@ -20,13 +20,15 @@ import {
20
20
  UpdateDateColumn
21
21
  } from "typeorm";
22
22
  import { BrazilianState } from "../../common/enums/brazilian-state.enum.js";
23
- import { TeamPlayerMergeHistory } from "../../history-logs/index.js";
24
- import { PlayerTeam, TeamJoinRequest, TeamModality, TeamTrophy } from "../../teams/index.js";
25
- import {
26
- TournamentRegistrationRequest,
27
- TournamentTeam,
28
- TournamentTeamContactAttempt
29
- } from "../../tournaments/index.js";
23
+ import { TeamPlayerMergeHistory } from "../../history-logs/team-player-merge-history/team-player-merge-history.entity.js";
24
+ import { TournamentRegistrationRequest } from "../../tournaments/tournament-registration-requests/tournament-registration-request.entity.js";
25
+ import { TournamentTeamContactAttempt } from "../../tournaments/tournament-team-contact-attempts/tournament-team-contact-attempt.entity.js";
26
+ import { TournamentTeam } from "../../tournaments/tournament-teams/tournament-team.entity.js";
27
+ import { PlayerTeam } from "../player-team/player-team.entity.js";
28
+ import { TeamAccessCode } from "../team-access-codes/team-access-code.entity.js";
29
+ import { TeamJoinRequest } from "../team-join-requests/team-join-request.entity.js";
30
+ import { TeamModality } from "../team-modality/team-modality.entity.js";
31
+ import { TeamTrophy } from "../team-trophy/team-trophy.entity.js";
30
32
  let Team = class {
31
33
  constructor() {
32
34
  this.deletedAt = null;
@@ -92,6 +94,9 @@ __decorateClass([
92
94
  __decorateClass([
93
95
  OneToMany(() => PlayerTeam, (pt) => pt.team)
94
96
  ], Team.prototype, "playerMemberships", 2);
97
+ __decorateClass([
98
+ OneToMany(() => TeamAccessCode, (accessCode) => accessCode.team)
99
+ ], Team.prototype, "accessCodes", 2);
95
100
  __decorateClass([
96
101
  OneToMany(() => TeamModality, (tm) => tm.team)
97
102
  ], Team.prototype, "teamModalities", 2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@natrave/shared-entities",
3
- "version": "1.5.6",
3
+ "version": "1.6.1",
4
4
  "description": "Entidades compartilhadass da NaTrave",
5
5
  "module": "dist/index.js",
6
6
  "main": "dist/index.js",