@natrave/shared-entities 1.6.3 → 1.6.4

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.
@@ -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, TeamAccessCode, TeamJoinRequest, TeamMember, TeamModality, TeamTrophy } from '../teams';
9
+ import { PlayerTeam, Team, TeamAccessCode, TeamJoinRequest, TeamMember, TeamMemberPersonalData, 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 TeamMember | typeof TeamModality | typeof TeamAccessCode | 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 TeamMemberPersonalData | typeof TeamMember | 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,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,UAAU,EACV,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,2mDAiE7B,CAAC"}
1
+ {"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,UAAU,EACV,sBAAsB,EACtB,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,2oDAkE7B,CAAC"}
@@ -23,6 +23,7 @@ import {
23
23
  TeamAccessCode,
24
24
  TeamJoinRequest,
25
25
  TeamMember,
26
+ TeamMemberPersonalData,
26
27
  TeamModality,
27
28
  TeamTrophy
28
29
  } from "../teams/index.js";
@@ -107,6 +108,7 @@ const DATABASE_ENTITIES = [
107
108
  TeamAccessCode,
108
109
  PlayerTeam,
109
110
  TeamMember,
111
+ TeamMemberPersonalData,
110
112
  TeamModality,
111
113
  TeamJoinRequest,
112
114
  NotificationDispatchLog,
@@ -3,6 +3,7 @@ export * from './player-team';
3
3
  export * from './team-access-codes';
4
4
  export * from './team-join-requests';
5
5
  export * from './team-member';
6
+ export * from './team-member-personal-data';
6
7
  export * from './team-modality';
7
8
  export * from './team-trophy';
8
9
  export * from './teams';
@@ -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,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,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,eAAe,CAAC;AAC9B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC"}
@@ -3,6 +3,7 @@ export * from "./player-team/index.js";
3
3
  export * from "./team-access-codes/index.js";
4
4
  export * from "./team-join-requests/index.js";
5
5
  export * from "./team-member/index.js";
6
+ export * from "./team-member-personal-data/index.js";
6
7
  export * from "./team-modality/index.js";
7
8
  export * from "./team-trophy/index.js";
8
9
  export * from "./teams/index.js";
@@ -1,16 +1,18 @@
1
1
  import { User } from '../../app-auth';
2
+ import { TeamMemberPersonalData } from '../team-member-personal-data';
2
3
  import { Team } from '../teams/team.entity';
3
4
  import { TeamMemberRole } from './enums/team-member-role.enum';
4
5
  export declare class TeamMember {
5
6
  id: number;
6
- userId: string;
7
+ userId: string | null;
7
8
  teamId: number;
8
9
  role: TeamMemberRole;
9
10
  isAdmin: boolean;
10
11
  deletedAt: Date | null;
11
12
  createdAt: Date;
12
13
  updatedAt: Date;
13
- user: User;
14
+ user: User | null;
14
15
  team: Team;
16
+ personalData: TeamMemberPersonalData | null;
15
17
  }
16
18
  //# sourceMappingURL=team-member.entity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"team-member.entity.d.ts","sourceRoot":"","sources":["../../../src/teams/team-member/team-member.entity.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,qBAOa,UAAU;IAIrB,EAAE,EAAE,MAAM,CAAC;IAGX,MAAM,EAAE,MAAM,CAAC;IAGf,MAAM,EAAE,MAAM,CAAC;IAOf,IAAI,EAAE,cAAc,CAAC;IAQrB,OAAO,EAAE,OAAO,CAAC;IAQjB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IAGvB,SAAS,EAAE,IAAI,CAAC;IAGhB,SAAS,EAAE,IAAI,CAAC;IAIhB,IAAI,EAAE,IAAI,CAAC;IAIX,IAAI,EAAE,IAAI,CAAC;CACZ"}
1
+ {"version":3,"file":"team-member.entity.d.ts","sourceRoot":"","sources":["../../../src/teams/team-member/team-member.entity.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,qBAOa,UAAU;IAIrB,EAAE,EAAE,MAAM,CAAC;IAGX,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAGtB,MAAM,EAAE,MAAM,CAAC;IAOf,IAAI,EAAE,cAAc,CAAC;IAQrB,OAAO,EAAE,OAAO,CAAC;IAQjB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IAGvB,SAAS,EAAE,IAAI,CAAC;IAGhB,SAAS,EAAE,IAAI,CAAC;IAIhB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAIlB,IAAI,EAAE,IAAI,CAAC;IAGX,YAAY,EAAE,sBAAsB,GAAG,IAAI,CAAC;CAC7C"}
@@ -16,11 +16,13 @@ import {
16
16
  Index,
17
17
  JoinColumn,
18
18
  ManyToOne,
19
+ OneToOne,
19
20
  PrimaryGeneratedColumn,
20
21
  Unique,
21
22
  UpdateDateColumn
22
23
  } from "typeorm";
23
24
  import { User } from "../../app-auth/index.js";
25
+ import { TeamMemberPersonalData } from "../team-member-personal-data/index.js";
24
26
  import { Team } from "../teams/team.entity.js";
25
27
  import { TeamMemberRole } from "./enums/team-member-role.enum.js";
26
28
  let TeamMember = class {
@@ -31,7 +33,7 @@ __decorateClass([
31
33
  })
32
34
  ], TeamMember.prototype, "id", 2);
33
35
  __decorateClass([
34
- Column({ name: "user_id", type: "uuid", comment: "FK users.id" })
36
+ Column({ name: "user_id", type: "uuid", nullable: true, comment: "FK users.id" })
35
37
  ], TeamMember.prototype, "userId", 2);
36
38
  __decorateClass([
37
39
  Column({ name: "team_id", type: "int", comment: "FK teams.id" })
@@ -66,13 +68,16 @@ __decorateClass([
66
68
  UpdateDateColumn({ name: "updated_at", type: "timestamptz" })
67
69
  ], TeamMember.prototype, "updatedAt", 2);
68
70
  __decorateClass([
69
- ManyToOne(() => User, (user) => user.teamMemberships, { onDelete: "CASCADE" }),
71
+ ManyToOne(() => User, (user) => user.teamMemberships, { onDelete: "CASCADE", nullable: true }),
70
72
  JoinColumn({ name: "user_id" })
71
73
  ], TeamMember.prototype, "user", 2);
72
74
  __decorateClass([
73
75
  ManyToOne(() => Team, (team) => team.members, { onDelete: "CASCADE" }),
74
76
  JoinColumn({ name: "team_id" })
75
77
  ], TeamMember.prototype, "team", 2);
78
+ __decorateClass([
79
+ OneToOne(() => TeamMemberPersonalData, (personalData) => personalData.teamMember)
80
+ ], TeamMember.prototype, "personalData", 2);
76
81
  TeamMember = __decorateClass([
77
82
  Entity("team_members"),
78
83
  Unique(["userId", "teamId"]),
@@ -0,0 +1,2 @@
1
+ export { TeamMemberPersonalData } from './team-member-personal-data.entity';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/teams/team-member-personal-data/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { TeamMemberPersonalData } from "./team-member-personal-data.entity.js";
2
+ export {
3
+ TeamMemberPersonalData
4
+ };
@@ -0,0 +1,20 @@
1
+ import { User } from '../../app-auth';
2
+ import { TeamMember } from '../team-member';
3
+ export declare class TeamMemberPersonalData {
4
+ id: number;
5
+ teamMemberId: number;
6
+ name: string;
7
+ birthDate: string | null;
8
+ cpfEncrypted: string | null;
9
+ cpfHash: string | null;
10
+ collectedAt: Date | null;
11
+ migratedAt: Date | null;
12
+ migratedToUserId: string | null;
13
+ deletedAt: Date | null;
14
+ createdAt: Date;
15
+ updatedAt: Date;
16
+ teamMember: TeamMember;
17
+ migratedToUser: User | null;
18
+ prepareData(): void;
19
+ }
20
+ //# sourceMappingURL=team-member-personal-data.entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"team-member-personal-data.entity.d.ts","sourceRoot":"","sources":["../../../src/teams/team-member-personal-data/team-member-personal-data.entity.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,qBAuBa,sBAAsB;IAIjC,EAAE,EAAE,MAAM,CAAC;IAOX,YAAY,EAAE,MAAM,CAAC;IAOrB,IAAI,EAAE,MAAM,CAAC;IAQb,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAQzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAS5B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAQvB,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IAQzB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IAQxB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAQhC,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IAOvB,SAAS,EAAE,IAAI,CAAC;IAOhB,SAAS,EAAE,IAAI,CAAC;IAIhB,UAAU,EAAE,UAAU,CAAC;IAIvB,cAAc,EAAE,IAAI,GAAG,IAAI,CAAC;IAI5B,WAAW,IAAI,IAAI;CAYpB"}
@@ -0,0 +1,169 @@
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
+ BeforeInsert,
13
+ BeforeUpdate,
14
+ Check,
15
+ Column,
16
+ CreateDateColumn,
17
+ DeleteDateColumn,
18
+ Entity,
19
+ Index,
20
+ JoinColumn,
21
+ ManyToOne,
22
+ OneToOne,
23
+ PrimaryGeneratedColumn,
24
+ UpdateDateColumn
25
+ } from "typeorm";
26
+ import { User } from "../../app-auth/index.js";
27
+ import { TeamMember } from "../team-member/index.js";
28
+ let TeamMemberPersonalData = class {
29
+ prepareData() {
30
+ this.name = this.name.trim();
31
+ if (this.cpfEncrypted) {
32
+ this.cpfEncrypted = this.cpfEncrypted.trim();
33
+ }
34
+ if (this.cpfHash) {
35
+ const normalizedHash = this.cpfHash.trim().toLowerCase();
36
+ this.cpfHash = /^[a-f0-9]{64}$/.test(normalizedHash) ? normalizedHash : null;
37
+ }
38
+ }
39
+ };
40
+ __decorateClass([
41
+ PrimaryGeneratedColumn({
42
+ comment: "Identificador \xFAnico dos dados pessoais do membro do time."
43
+ })
44
+ ], TeamMemberPersonalData.prototype, "id", 2);
45
+ __decorateClass([
46
+ Column({
47
+ name: "team_member_id",
48
+ type: "int",
49
+ comment: "FK team_members.id."
50
+ })
51
+ ], TeamMemberPersonalData.prototype, "teamMemberId", 2);
52
+ __decorateClass([
53
+ Column({
54
+ type: "varchar",
55
+ length: 255,
56
+ comment: "Nome do membro do time."
57
+ })
58
+ ], TeamMemberPersonalData.prototype, "name", 2);
59
+ __decorateClass([
60
+ Column({
61
+ name: "birth_date",
62
+ type: "date",
63
+ nullable: true,
64
+ comment: "Data de nascimento do membro do time (YYYY-MM-DD)."
65
+ })
66
+ ], TeamMemberPersonalData.prototype, "birthDate", 2);
67
+ __decorateClass([
68
+ Column({
69
+ name: "cpf_encrypted",
70
+ type: "text",
71
+ nullable: true,
72
+ comment: "CPF criptografado (ex.: AES-256-GCM)."
73
+ })
74
+ ], TeamMemberPersonalData.prototype, "cpfEncrypted", 2);
75
+ __decorateClass([
76
+ Column({
77
+ name: "cpf_hash",
78
+ type: "char",
79
+ length: 64,
80
+ nullable: true,
81
+ comment: "Hash SHA-256 do CPF normalizado com pepper para busca/compara\xE7\xE3o."
82
+ })
83
+ ], TeamMemberPersonalData.prototype, "cpfHash", 2);
84
+ __decorateClass([
85
+ Column({
86
+ name: "collected_at",
87
+ type: "timestamptz",
88
+ nullable: true,
89
+ comment: "Data/hora em que os dados pessoais foram coletados."
90
+ })
91
+ ], TeamMemberPersonalData.prototype, "collectedAt", 2);
92
+ __decorateClass([
93
+ Column({
94
+ name: "migrated_at",
95
+ type: "timestamptz",
96
+ nullable: true,
97
+ comment: "Data/hora em que os dados foram migrados para users."
98
+ })
99
+ ], TeamMemberPersonalData.prototype, "migratedAt", 2);
100
+ __decorateClass([
101
+ Column({
102
+ name: "migrated_to_user_id",
103
+ type: "uuid",
104
+ nullable: true,
105
+ comment: "FK users.id que recebeu os dados apos migracao."
106
+ })
107
+ ], TeamMemberPersonalData.prototype, "migratedToUserId", 2);
108
+ __decorateClass([
109
+ DeleteDateColumn({
110
+ name: "deleted_at",
111
+ type: "timestamptz",
112
+ nullable: true,
113
+ comment: "Soft delete para retencao/auditoria."
114
+ })
115
+ ], TeamMemberPersonalData.prototype, "deletedAt", 2);
116
+ __decorateClass([
117
+ CreateDateColumn({
118
+ name: "created_at",
119
+ type: "timestamptz",
120
+ comment: "Data/hora de criacao do registro."
121
+ })
122
+ ], TeamMemberPersonalData.prototype, "createdAt", 2);
123
+ __decorateClass([
124
+ UpdateDateColumn({
125
+ name: "updated_at",
126
+ type: "timestamptz",
127
+ comment: "Data/hora da ultima atualizacao do registro."
128
+ })
129
+ ], TeamMemberPersonalData.prototype, "updatedAt", 2);
130
+ __decorateClass([
131
+ OneToOne(() => TeamMember, (teamMember) => teamMember.personalData, { onDelete: "CASCADE" }),
132
+ JoinColumn({ name: "team_member_id" })
133
+ ], TeamMemberPersonalData.prototype, "teamMember", 2);
134
+ __decorateClass([
135
+ ManyToOne(() => User, { onDelete: "SET NULL" }),
136
+ JoinColumn({ name: "migrated_to_user_id" })
137
+ ], TeamMemberPersonalData.prototype, "migratedToUser", 2);
138
+ __decorateClass([
139
+ BeforeInsert(),
140
+ BeforeUpdate()
141
+ ], TeamMemberPersonalData.prototype, "prepareData", 1);
142
+ TeamMemberPersonalData = __decorateClass([
143
+ Entity("team_member_personal_data"),
144
+ Check(
145
+ "CHK_team_member_personal_data_cpf_hash_format",
146
+ `"cpf_hash" IS NULL OR "cpf_hash" ~ '^[a-f0-9]{64}$'`
147
+ ),
148
+ Check(
149
+ "CHK_team_member_personal_data_migration_user",
150
+ '"migrated_at" IS NULL OR "migrated_to_user_id" IS NOT NULL'
151
+ ),
152
+ Check(
153
+ "CHK_team_member_personal_data_birth_date",
154
+ '"birth_date" IS NULL OR "birth_date" <= CURRENT_DATE'
155
+ ),
156
+ Index("IDX_team_member_personal_data_team_member_id", ["teamMemberId"]),
157
+ Index("IDX_team_member_personal_data_deleted_at", ["deletedAt"]),
158
+ Index("IDX_team_member_personal_data_migrated_at", ["migratedAt"]),
159
+ Index("IDX_team_member_personal_data_cpf_hash_lookup", ["cpfHash"], {
160
+ where: '"deleted_at" IS NULL AND "migrated_at" IS NULL AND "cpf_hash" IS NOT NULL'
161
+ }),
162
+ Index("UX_team_member_personal_data_member_active", ["teamMemberId"], {
163
+ unique: true,
164
+ where: '"deleted_at" IS NULL'
165
+ })
166
+ ], TeamMemberPersonalData);
167
+ export {
168
+ TeamMemberPersonalData
169
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@natrave/shared-entities",
3
- "version": "1.6.3",
3
+ "version": "1.6.4",
4
4
  "description": "Entidades compartilhadass da NaTrave",
5
5
  "module": "dist/index.js",
6
6
  "main": "dist/index.js",