@natrave/shared-entities 8.33.0 → 8.35.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 (97) hide show
  1. package/dist/app-auth/index.d.ts +1 -0
  2. package/dist/app-auth/index.d.ts.map +1 -1
  3. package/dist/app-auth/index.js +1 -0
  4. package/dist/app-auth/user-localities/enums/user-locality-source.enum.d.ts +5 -0
  5. package/dist/app-auth/user-localities/enums/user-locality-source.enum.d.ts.map +1 -0
  6. package/dist/app-auth/user-localities/enums/user-locality-source.enum.js +8 -0
  7. package/dist/app-auth/user-localities/index.d.ts +3 -0
  8. package/dist/app-auth/user-localities/index.d.ts.map +1 -0
  9. package/dist/app-auth/user-localities/index.js +6 -0
  10. package/dist/app-auth/user-localities/user-locality.entity.d.ts +14 -0
  11. package/dist/app-auth/user-localities/user-locality.entity.d.ts.map +1 -0
  12. package/dist/app-auth/user-localities/user-locality.entity.js +94 -0
  13. package/dist/database-entities/index.d.ts +3 -2
  14. package/dist/database-entities/index.d.ts.map +1 -1
  15. package/dist/database-entities/index.js +19 -1
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1 -0
  19. package/dist/promotions/enums/promotion-advertiser-entity-type.enum.d.ts +4 -0
  20. package/dist/promotions/enums/promotion-advertiser-entity-type.enum.d.ts.map +1 -0
  21. package/dist/promotions/enums/promotion-advertiser-entity-type.enum.js +7 -0
  22. package/dist/promotions/enums/promotion-creative-status.enum.d.ts +6 -0
  23. package/dist/promotions/enums/promotion-creative-status.enum.d.ts.map +1 -0
  24. package/dist/promotions/enums/promotion-creative-status.enum.js +9 -0
  25. package/dist/promotions/enums/promotion-creative-template.enum.d.ts +4 -0
  26. package/dist/promotions/enums/promotion-creative-template.enum.d.ts.map +1 -0
  27. package/dist/promotions/enums/promotion-creative-template.enum.js +7 -0
  28. package/dist/promotions/enums/promotion-event-type.enum.d.ts +7 -0
  29. package/dist/promotions/enums/promotion-event-type.enum.d.ts.map +1 -0
  30. package/dist/promotions/enums/promotion-event-type.enum.js +10 -0
  31. package/dist/promotions/enums/promotion-match-source.enum.d.ts +8 -0
  32. package/dist/promotions/enums/promotion-match-source.enum.d.ts.map +1 -0
  33. package/dist/promotions/enums/promotion-match-source.enum.js +11 -0
  34. package/dist/promotions/enums/promotion-placement.enum.d.ts +4 -0
  35. package/dist/promotions/enums/promotion-placement.enum.d.ts.map +1 -0
  36. package/dist/promotions/enums/promotion-placement.enum.js +7 -0
  37. package/dist/promotions/enums/promotion-status.enum.d.ts +7 -0
  38. package/dist/promotions/enums/promotion-status.enum.d.ts.map +1 -0
  39. package/dist/promotions/enums/promotion-status.enum.js +10 -0
  40. package/dist/promotions/enums/promotion-subject-type.enum.d.ts +4 -0
  41. package/dist/promotions/enums/promotion-subject-type.enum.d.ts.map +1 -0
  42. package/dist/promotions/enums/promotion-subject-type.enum.js +7 -0
  43. package/dist/promotions/enums/promotion-target-type.enum.d.ts +5 -0
  44. package/dist/promotions/enums/promotion-target-type.enum.d.ts.map +1 -0
  45. package/dist/promotions/enums/promotion-target-type.enum.js +8 -0
  46. package/dist/promotions/index.d.ts +20 -0
  47. package/dist/promotions/index.d.ts.map +1 -0
  48. package/dist/promotions/index.js +33 -0
  49. package/dist/promotions/promotion-advertisers/index.d.ts +2 -0
  50. package/dist/promotions/promotion-advertisers/index.d.ts.map +1 -0
  51. package/dist/promotions/promotion-advertisers/index.js +4 -0
  52. package/dist/promotions/promotion-advertisers/promotion-advertiser.entity.d.ts +15 -0
  53. package/dist/promotions/promotion-advertisers/promotion-advertiser.entity.d.ts.map +1 -0
  54. package/dist/promotions/promotion-advertisers/promotion-advertiser.entity.js +117 -0
  55. package/dist/promotions/promotion-contacts/index.d.ts +2 -0
  56. package/dist/promotions/promotion-contacts/index.d.ts.map +1 -0
  57. package/dist/promotions/promotion-contacts/index.js +4 -0
  58. package/dist/promotions/promotion-contacts/promotion-contact.entity.d.ts +14 -0
  59. package/dist/promotions/promotion-contacts/promotion-contact.entity.d.ts.map +1 -0
  60. package/dist/promotions/promotion-contacts/promotion-contact.entity.js +106 -0
  61. package/dist/promotions/promotion-creatives/index.d.ts +2 -0
  62. package/dist/promotions/promotion-creatives/index.d.ts.map +1 -0
  63. package/dist/promotions/promotion-creatives/index.js +4 -0
  64. package/dist/promotions/promotion-creatives/promotion-creative.entity.d.ts +21 -0
  65. package/dist/promotions/promotion-creatives/promotion-creative.entity.d.ts.map +1 -0
  66. package/dist/promotions/promotion-creatives/promotion-creative.entity.js +132 -0
  67. package/dist/promotions/promotion-events/index.d.ts +2 -0
  68. package/dist/promotions/promotion-events/index.d.ts.map +1 -0
  69. package/dist/promotions/promotion-events/index.js +4 -0
  70. package/dist/promotions/promotion-events/promotion-event.entity.d.ts +20 -0
  71. package/dist/promotions/promotion-events/promotion-event.entity.d.ts.map +1 -0
  72. package/dist/promotions/promotion-events/promotion-event.entity.js +135 -0
  73. package/dist/promotions/promotion-targets/index.d.ts +2 -0
  74. package/dist/promotions/promotion-targets/index.d.ts.map +1 -0
  75. package/dist/promotions/promotion-targets/index.js +4 -0
  76. package/dist/promotions/promotion-targets/promotion-target.entity.d.ts +15 -0
  77. package/dist/promotions/promotion-targets/promotion-target.entity.d.ts.map +1 -0
  78. package/dist/promotions/promotion-targets/promotion-target.entity.js +102 -0
  79. package/dist/promotions/promotion-user-states/index.d.ts +2 -0
  80. package/dist/promotions/promotion-user-states/index.d.ts.map +1 -0
  81. package/dist/promotions/promotion-user-states/index.js +4 -0
  82. package/dist/promotions/promotion-user-states/promotion-user-state.entity.d.ts +21 -0
  83. package/dist/promotions/promotion-user-states/promotion-user-state.entity.d.ts.map +1 -0
  84. package/dist/promotions/promotion-user-states/promotion-user-state.entity.js +158 -0
  85. package/dist/promotions/promotions/index.d.ts +2 -0
  86. package/dist/promotions/promotions/index.d.ts.map +1 -0
  87. package/dist/promotions/promotions/index.js +4 -0
  88. package/dist/promotions/promotions/promotion.entity.d.ts +27 -0
  89. package/dist/promotions/promotions/promotion.entity.d.ts.map +1 -0
  90. package/dist/promotions/promotions/promotion.entity.js +179 -0
  91. package/dist/promotions/types/promotion-content.types.d.ts +17 -0
  92. package/dist/promotions/types/promotion-content.types.d.ts.map +1 -0
  93. package/dist/promotions/types/promotion-content.types.js +0 -0
  94. package/dist/promotions/validation/promotion-creative.validation.d.ts +13 -0
  95. package/dist/promotions/validation/promotion-creative.validation.d.ts.map +1 -0
  96. package/dist/promotions/validation/promotion-creative.validation.js +82 -0
  97. package/package.json +1 -1
@@ -0,0 +1,102 @@
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
+ Index,
17
+ JoinColumn,
18
+ ManyToOne,
19
+ PrimaryGeneratedColumn
20
+ } from "typeorm";
21
+ import { City } from "../../facilities/cities/index.js";
22
+ import { Promotion } from "../promotions/promotion.entity.js";
23
+ let PromotionTarget = class {
24
+ };
25
+ __decorateClass([
26
+ PrimaryGeneratedColumn("uuid", {
27
+ primaryKeyConstraintName: "PK_promotion_targets",
28
+ comment: "Identificador \xFAnico da regra."
29
+ })
30
+ ], PromotionTarget.prototype, "id", 2);
31
+ __decorateClass([
32
+ Column({
33
+ name: "promotion_id",
34
+ type: "uuid",
35
+ comment: "FK promotions.id."
36
+ })
37
+ ], PromotionTarget.prototype, "promotionId", 2);
38
+ __decorateClass([
39
+ Column({
40
+ type: "varchar",
41
+ length: 16,
42
+ comment: "CITY | STATE. Define qual coluna de local \xE9 obrigat\xF3ria."
43
+ })
44
+ ], PromotionTarget.prototype, "type", 2);
45
+ __decorateClass([
46
+ Column({
47
+ name: "city_ibge_code",
48
+ type: "int",
49
+ nullable: true,
50
+ comment: "FK cities.ibge_code. Munic\xEDpio alvo quando type = CITY."
51
+ })
52
+ ], PromotionTarget.prototype, "cityIbgeCode", 2);
53
+ __decorateClass([
54
+ Column({
55
+ type: "varchar",
56
+ length: 2,
57
+ nullable: true,
58
+ comment: "UF alvo quando type = STATE."
59
+ })
60
+ ], PromotionTarget.prototype, "state", 2);
61
+ __decorateClass([
62
+ CreateDateColumn({
63
+ name: "created_at",
64
+ type: "timestamptz",
65
+ default: () => "now()",
66
+ comment: "Data/hora de cria\xE7\xE3o do registro."
67
+ })
68
+ ], PromotionTarget.prototype, "createdAt", 2);
69
+ __decorateClass([
70
+ ManyToOne(() => Promotion, (promotion) => promotion.targets, { onDelete: "CASCADE" }),
71
+ JoinColumn({
72
+ name: "promotion_id",
73
+ foreignKeyConstraintName: "FK_promotion_targets_promotion"
74
+ })
75
+ ], PromotionTarget.prototype, "promotion", 2);
76
+ __decorateClass([
77
+ ManyToOne(() => City, { onDelete: "RESTRICT" }),
78
+ JoinColumn({
79
+ name: "city_ibge_code",
80
+ referencedColumnName: "ibgeCode",
81
+ foreignKeyConstraintName: "FK_promotion_targets_city"
82
+ })
83
+ ], PromotionTarget.prototype, "city", 2);
84
+ PromotionTarget = __decorateClass([
85
+ Entity("promotion_targets"),
86
+ Index("UQ_promotion_targets_city", ["promotionId", "cityIbgeCode"], {
87
+ unique: true,
88
+ where: `"type" = 'CITY'`
89
+ }),
90
+ Index("UQ_promotion_targets_state", ["promotionId", "state"], {
91
+ unique: true,
92
+ where: `"type" = 'STATE'`
93
+ }),
94
+ Index("IDX_promotion_targets_city", ["cityIbgeCode"]),
95
+ Check(
96
+ "CHK_promotion_targets_shape",
97
+ `("type" = 'CITY' AND "city_ibge_code" IS NOT NULL AND "state" IS NULL) OR ("type" = 'STATE' AND "state" IS NOT NULL AND "city_ibge_code" IS NULL)`
98
+ )
99
+ ], PromotionTarget);
100
+ export {
101
+ PromotionTarget
102
+ };
@@ -0,0 +1,2 @@
1
+ export { PromotionUserState } from './promotion-user-state.entity';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/promotions/promotion-user-states/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { PromotionUserState } from "./promotion-user-state.entity.js";
2
+ export {
3
+ PromotionUserState
4
+ };
@@ -0,0 +1,21 @@
1
+ import { User } from '../../app-auth';
2
+ import { PromotionCreative } from '../promotion-creatives/promotion-creative.entity';
3
+ import { Promotion } from '../promotions/promotion.entity';
4
+ export declare class PromotionUserState {
5
+ promotionId: string;
6
+ userId: string;
7
+ creativeId: string | null;
8
+ impressions: number;
9
+ firstShownAt: Date | null;
10
+ lastShownAt: Date | null;
11
+ dismissedAt: Date | null;
12
+ interestedAt: Date | null;
13
+ leadDeliveredAt: Date | null;
14
+ contactClickedAt: Date | null;
15
+ createdAt: Date;
16
+ updatedAt: Date;
17
+ promotion: Promotion;
18
+ user: User;
19
+ creative: PromotionCreative | null;
20
+ }
21
+ //# sourceMappingURL=promotion-user-state.entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promotion-user-state.entity.d.ts","sourceRoot":"","sources":["../../../src/promotions/promotion-user-states/promotion-user-state.entity.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAqB3D,qBAWa,kBAAkB;IAO7B,WAAW,EAAE,MAAM,CAAC;IAQpB,MAAM,EAAE,MAAM,CAAC;IAQf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAO1B,WAAW,EAAE,MAAM,CAAC;IAQpB,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAQ1B,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IAQzB,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IAQzB,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAQ1B,eAAe,EAAE,IAAI,GAAG,IAAI,CAAC;IAQ7B,gBAAgB,EAAE,IAAI,GAAG,IAAI,CAAC;IAQ9B,SAAS,EAAE,IAAI,CAAC;IAQhB,SAAS,EAAE,IAAI,CAAC;IAShB,SAAS,EAAE,SAAS,CAAC;IAOrB,IAAI,EAAE,IAAI,CAAC;IAOX,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACpC"}
@@ -0,0 +1,158 @@
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
+ Index,
17
+ JoinColumn,
18
+ ManyToOne,
19
+ PrimaryColumn,
20
+ UpdateDateColumn
21
+ } from "typeorm";
22
+ import { User } from "../../app-auth/index.js";
23
+ import { PromotionCreative } from "../promotion-creatives/promotion-creative.entity.js";
24
+ import { Promotion } from "../promotions/promotion.entity.js";
25
+ let PromotionUserState = class {
26
+ };
27
+ __decorateClass([
28
+ PrimaryColumn({
29
+ name: "promotion_id",
30
+ type: "uuid",
31
+ primaryKeyConstraintName: "PK_promotion_user_states",
32
+ comment: "FK promotions.id."
33
+ })
34
+ ], PromotionUserState.prototype, "promotionId", 2);
35
+ __decorateClass([
36
+ PrimaryColumn({
37
+ name: "user_id",
38
+ type: "uuid",
39
+ primaryKeyConstraintName: "PK_promotion_user_states",
40
+ comment: "FK users.id."
41
+ })
42
+ ], PromotionUserState.prototype, "userId", 2);
43
+ __decorateClass([
44
+ Column({
45
+ name: "creative_id",
46
+ type: "uuid",
47
+ nullable: true,
48
+ comment: "FK promotion_creatives.id. Criativo sorteado para este usu\xE1rio."
49
+ })
50
+ ], PromotionUserState.prototype, "creativeId", 2);
51
+ __decorateClass([
52
+ Column({
53
+ type: "int",
54
+ default: 0,
55
+ comment: "Quantas vezes o destaque abriu para este usu\xE1rio."
56
+ })
57
+ ], PromotionUserState.prototype, "impressions", 2);
58
+ __decorateClass([
59
+ Column({
60
+ name: "first_shown_at",
61
+ type: "timestamptz",
62
+ nullable: true,
63
+ comment: "Data/hora da primeira exibi\xE7\xE3o."
64
+ })
65
+ ], PromotionUserState.prototype, "firstShownAt", 2);
66
+ __decorateClass([
67
+ Column({
68
+ name: "last_shown_at",
69
+ type: "timestamptz",
70
+ nullable: true,
71
+ comment: "Data/hora da \xFAltima exibi\xE7\xE3o. Base do intervalo entre destaques."
72
+ })
73
+ ], PromotionUserState.prototype, "lastShownAt", 2);
74
+ __decorateClass([
75
+ Column({
76
+ name: "dismissed_at",
77
+ type: "timestamptz",
78
+ nullable: true,
79
+ comment: 'Quando recusou ("Agora n\xE3o" ou fechar). O destaque n\xE3o volta.'
80
+ })
81
+ ], PromotionUserState.prototype, "dismissedAt", 2);
82
+ __decorateClass([
83
+ Column({
84
+ name: "interested_at",
85
+ type: "timestamptz",
86
+ nullable: true,
87
+ comment: 'Quando tocou em "Tenho interesse". Lead para o organizador.'
88
+ })
89
+ ], PromotionUserState.prototype, "interestedAt", 2);
90
+ __decorateClass([
91
+ Column({
92
+ name: "lead_delivered_at",
93
+ type: "timestamptz",
94
+ nullable: true,
95
+ comment: "Quando o lead foi repassado ao organizador. Nulo: ainda n\xE3o enviado."
96
+ })
97
+ ], PromotionUserState.prototype, "leadDeliveredAt", 2);
98
+ __decorateClass([
99
+ Column({
100
+ name: "contact_clicked_at",
101
+ type: "timestamptz",
102
+ nullable: true,
103
+ comment: "Primeira vez que abriu o contato do organizador."
104
+ })
105
+ ], PromotionUserState.prototype, "contactClickedAt", 2);
106
+ __decorateClass([
107
+ CreateDateColumn({
108
+ name: "created_at",
109
+ type: "timestamptz",
110
+ default: () => "now()",
111
+ comment: "Data/hora de cria\xE7\xE3o do registro."
112
+ })
113
+ ], PromotionUserState.prototype, "createdAt", 2);
114
+ __decorateClass([
115
+ UpdateDateColumn({
116
+ name: "updated_at",
117
+ type: "timestamptz",
118
+ default: () => "now()",
119
+ comment: "Data/hora da \xFAltima altera\xE7\xE3o do registro."
120
+ })
121
+ ], PromotionUserState.prototype, "updatedAt", 2);
122
+ __decorateClass([
123
+ ManyToOne(() => Promotion, { onDelete: "CASCADE" }),
124
+ JoinColumn({
125
+ name: "promotion_id",
126
+ foreignKeyConstraintName: "FK_promotion_user_states_promotion"
127
+ })
128
+ ], PromotionUserState.prototype, "promotion", 2);
129
+ __decorateClass([
130
+ ManyToOne(() => User, { onDelete: "CASCADE" }),
131
+ JoinColumn({
132
+ name: "user_id",
133
+ foreignKeyConstraintName: "FK_promotion_user_states_user"
134
+ })
135
+ ], PromotionUserState.prototype, "user", 2);
136
+ __decorateClass([
137
+ ManyToOne(() => PromotionCreative, { onDelete: "NO ACTION" }),
138
+ JoinColumn({
139
+ name: "creative_id",
140
+ foreignKeyConstraintName: "FK_promotion_user_states_creative"
141
+ })
142
+ ], PromotionUserState.prototype, "creative", 2);
143
+ PromotionUserState = __decorateClass([
144
+ Entity("promotion_user_states"),
145
+ Index("IDX_promotion_user_states_user_last_shown", ["userId", "lastShownAt"]),
146
+ Index("IDX_promotion_user_states_leads", ["promotionId", "interestedAt"], {
147
+ where: '"interested_at" IS NOT NULL'
148
+ }),
149
+ Check("CHK_promotion_user_states_impressions", `"impressions" >= 0`),
150
+ Check("CHK_promotion_user_states_creative", `"impressions" = 0 OR "creative_id" IS NOT NULL`),
151
+ Check(
152
+ "CHK_promotion_user_states_delivery",
153
+ `"lead_delivered_at" IS NULL OR "interested_at" IS NOT NULL`
154
+ )
155
+ ], PromotionUserState);
156
+ export {
157
+ PromotionUserState
158
+ };
@@ -0,0 +1,2 @@
1
+ export { Promotion } from './promotion.entity';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/promotions/promotions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Promotion } from "./promotion.entity.js";
2
+ export {
3
+ Promotion
4
+ };
@@ -0,0 +1,27 @@
1
+ import { PromotionStatus } from '../enums/promotion-status.enum';
2
+ import { PromotionSubjectType } from '../enums/promotion-subject-type.enum';
3
+ import { PromotionAdvertiser } from '../promotion-advertisers/promotion-advertiser.entity';
4
+ import { PromotionContact } from '../promotion-contacts/promotion-contact.entity';
5
+ import { PromotionCreative } from '../promotion-creatives/promotion-creative.entity';
6
+ import { PromotionTarget } from '../promotion-targets/promotion-target.entity';
7
+ export declare class Promotion {
8
+ id: string;
9
+ name: string;
10
+ status: PromotionStatus;
11
+ advertiserId: string | null;
12
+ subjectType: PromotionSubjectType | null;
13
+ subjectId: string | null;
14
+ startsAt: Date | null;
15
+ endsAt: Date | null;
16
+ priority: number;
17
+ maxImpressionsPerUser: number;
18
+ contractRef: string | null;
19
+ createdBy: string | null;
20
+ createdAt: Date;
21
+ updatedAt: Date;
22
+ advertiser: PromotionAdvertiser | null;
23
+ targets: PromotionTarget[];
24
+ creatives: PromotionCreative[];
25
+ contacts: PromotionContact[];
26
+ }
27
+ //# sourceMappingURL=promotion.entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promotion.entity.d.ts","sourceRoot":"","sources":["../../../src/promotions/promotions/promotion.entity.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sDAAsD,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAkC/E,qBAiBa,SAAS;IAKpB,EAAE,EAAE,MAAM,CAAC;IAOX,IAAI,EAAE,MAAM,CAAC;IAQb,MAAM,EAAE,eAAe,CAAC;IAQxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAS5B,WAAW,EAAE,oBAAoB,GAAG,IAAI,CAAC;IASzC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAQzB,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IAQtB,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IAOpB,QAAQ,EAAE,MAAM,CAAC;IAQjB,qBAAqB,EAAE,MAAM,CAAC;IAS9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAS3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAQzB,SAAS,EAAE,IAAI,CAAC;IAQhB,SAAS,EAAE,IAAI,CAAC;IAYhB,UAAU,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAGvC,OAAO,EAAE,eAAe,EAAE,CAAC;IAG3B,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAG/B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;CAC9B"}
@@ -0,0 +1,179 @@
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
+ Index,
17
+ JoinColumn,
18
+ ManyToOne,
19
+ OneToMany,
20
+ PrimaryGeneratedColumn,
21
+ UpdateDateColumn
22
+ } from "typeorm";
23
+ import { PromotionStatus } from "../enums/promotion-status.enum.js";
24
+ import { PromotionAdvertiser } from "../promotion-advertisers/promotion-advertiser.entity.js";
25
+ import { PromotionContact } from "../promotion-contacts/promotion-contact.entity.js";
26
+ import { PromotionCreative } from "../promotion-creatives/promotion-creative.entity.js";
27
+ import { PromotionTarget } from "../promotion-targets/promotion-target.entity.js";
28
+ let Promotion = class {
29
+ };
30
+ __decorateClass([
31
+ PrimaryGeneratedColumn("uuid", {
32
+ primaryKeyConstraintName: "PK_promotions",
33
+ comment: "Identificador \xFAnico do destaque."
34
+ })
35
+ ], Promotion.prototype, "id", 2);
36
+ __decorateClass([
37
+ Column({
38
+ type: "varchar",
39
+ length: 120,
40
+ comment: "Nome interno do destaque no backoffice. N\xE3o aparece no app."
41
+ })
42
+ ], Promotion.prototype, "name", 2);
43
+ __decorateClass([
44
+ Column({
45
+ type: "varchar",
46
+ length: 16,
47
+ default: PromotionStatus.DRAFT,
48
+ comment: "DRAFT | ACTIVE | PAUSED | ENDED. S\xF3 ACTIVE dentro da janela aparece."
49
+ })
50
+ ], Promotion.prototype, "status", 2);
51
+ __decorateClass([
52
+ Column({
53
+ name: "advertiser_id",
54
+ type: "uuid",
55
+ nullable: true,
56
+ comment: "FK promotion_advertisers.id. Quem pagou pelo destaque. Nulo s\xF3 em rascunho."
57
+ })
58
+ ], Promotion.prototype, "advertiserId", 2);
59
+ __decorateClass([
60
+ Column({
61
+ name: "subject_type",
62
+ type: "varchar",
63
+ length: 32,
64
+ nullable: true,
65
+ comment: "Tipo do que \xE9 anunciado (TOURNAMENT). Nulo: destaque sem assunto."
66
+ })
67
+ ], Promotion.prototype, "subjectType", 2);
68
+ __decorateClass([
69
+ Column({
70
+ name: "subject_id",
71
+ type: "bigint",
72
+ nullable: true,
73
+ comment: "Id do assunto em subject_type (TOURNAMENT: tournament_category_groups.id). Sem FK (polim\xF3rfico)."
74
+ })
75
+ ], Promotion.prototype, "subjectId", 2);
76
+ __decorateClass([
77
+ Column({
78
+ name: "starts_at",
79
+ type: "timestamptz",
80
+ nullable: true,
81
+ comment: "In\xEDcio da janela em que o destaque pode aparecer. Nulo s\xF3 em rascunho."
82
+ })
83
+ ], Promotion.prototype, "startsAt", 2);
84
+ __decorateClass([
85
+ Column({
86
+ name: "ends_at",
87
+ type: "timestamptz",
88
+ nullable: true,
89
+ comment: "Fim da janela (exclusivo). Depois disso n\xE3o aparece mais. Nulo s\xF3 em rascunho."
90
+ })
91
+ ], Promotion.prototype, "endsAt", 2);
92
+ __decorateClass([
93
+ Column({
94
+ type: "int",
95
+ default: 0,
96
+ comment: "Desempate quando mais de um destaque serve ao mesmo usu\xE1rio. Maior vence."
97
+ })
98
+ ], Promotion.prototype, "priority", 2);
99
+ __decorateClass([
100
+ Column({
101
+ name: "max_impressions_per_user",
102
+ type: "int",
103
+ default: 1,
104
+ comment: "Quantas vezes o mesmo usu\xE1rio pode ver este destaque, somando os criativos."
105
+ })
106
+ ], Promotion.prototype, "maxImpressionsPerUser", 2);
107
+ __decorateClass([
108
+ Column({
109
+ name: "contract_ref",
110
+ type: "varchar",
111
+ length: 120,
112
+ nullable: true,
113
+ comment: "Refer\xEAncia externa da venda (proposta, nota, contrato)."
114
+ })
115
+ ], Promotion.prototype, "contractRef", 2);
116
+ __decorateClass([
117
+ Column({
118
+ name: "created_by",
119
+ type: "varchar",
120
+ length: 64,
121
+ nullable: true,
122
+ comment: "Usu\xE1rio do backoffice que criou o destaque."
123
+ })
124
+ ], Promotion.prototype, "createdBy", 2);
125
+ __decorateClass([
126
+ CreateDateColumn({
127
+ name: "created_at",
128
+ type: "timestamptz",
129
+ default: () => "now()",
130
+ comment: "Data/hora de cria\xE7\xE3o do registro."
131
+ })
132
+ ], Promotion.prototype, "createdAt", 2);
133
+ __decorateClass([
134
+ UpdateDateColumn({
135
+ name: "updated_at",
136
+ type: "timestamptz",
137
+ default: () => "now()",
138
+ comment: "Data/hora da \xFAltima altera\xE7\xE3o do registro."
139
+ })
140
+ ], Promotion.prototype, "updatedAt", 2);
141
+ __decorateClass([
142
+ ManyToOne(() => PromotionAdvertiser, (advertiser) => advertiser.promotions, {
143
+ nullable: true,
144
+ onDelete: "RESTRICT"
145
+ }),
146
+ JoinColumn({
147
+ name: "advertiser_id",
148
+ foreignKeyConstraintName: "FK_promotions_advertiser"
149
+ })
150
+ ], Promotion.prototype, "advertiser", 2);
151
+ __decorateClass([
152
+ OneToMany(() => PromotionTarget, (target) => target.promotion)
153
+ ], Promotion.prototype, "targets", 2);
154
+ __decorateClass([
155
+ OneToMany(() => PromotionCreative, (creative) => creative.promotion)
156
+ ], Promotion.prototype, "creatives", 2);
157
+ __decorateClass([
158
+ OneToMany(() => PromotionContact, (contact) => contact.promotion)
159
+ ], Promotion.prototype, "contacts", 2);
160
+ Promotion = __decorateClass([
161
+ Entity("promotions"),
162
+ Index("IDX_promotions_live", ["status", "endsAt"]),
163
+ Index("IDX_promotions_subject", ["subjectType", "subjectId"]),
164
+ Index("IDX_promotions_advertiser", ["advertiserId"]),
165
+ Check("CHK_promotions_status", `"status" IN ('DRAFT', 'ACTIVE', 'PAUSED', 'ENDED')`),
166
+ Check(
167
+ "CHK_promotions_subject",
168
+ `("subject_type" IS NULL AND "subject_id" IS NULL) OR ("subject_type" IS NOT NULL AND "subject_type" IN ('TOURNAMENT') AND "subject_id" IS NOT NULL)`
169
+ ),
170
+ Check("CHK_promotions_window", `"ends_at" > "starts_at"`),
171
+ Check(
172
+ "CHK_promotions_ready",
173
+ `"status" = 'DRAFT' OR ("advertiser_id" IS NOT NULL AND "starts_at" IS NOT NULL AND "ends_at" IS NOT NULL)`
174
+ ),
175
+ Check("CHK_promotions_max_impressions", `"max_impressions_per_user" >= 1`)
176
+ ], Promotion);
177
+ export {
178
+ Promotion
179
+ };
@@ -0,0 +1,17 @@
1
+ import type { PromotionCreativeTemplate } from '../enums/promotion-creative-template.enum';
2
+ export interface TournamentPosterContent {
3
+ posterColor: string;
4
+ monogram: string;
5
+ posterImageUrl?: string;
6
+ headline?: string;
7
+ kicker?: string;
8
+ badge?: string;
9
+ ctaLabel: string;
10
+ dismissLabel: string;
11
+ contactMessage?: string;
12
+ }
13
+ export interface PromotionCreativeContentByTemplate {
14
+ [PromotionCreativeTemplate.TOURNAMENT_POSTER]: TournamentPosterContent;
15
+ }
16
+ export type PromotionCreativeContent = PromotionCreativeContentByTemplate[keyof PromotionCreativeContentByTemplate];
17
+ //# sourceMappingURL=promotion-content.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promotion-content.types.d.ts","sourceRoot":"","sources":["../../../src/promotions/types/promotion-content.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAS3F,MAAM,WAAW,uBAAuB;IAEtC,WAAW,EAAE,MAAM,CAAC;IAEpB,QAAQ,EAAE,MAAM,CAAC;IAEjB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,QAAQ,EAAE,MAAM,CAAC;IAEjB,YAAY,EAAE,MAAM,CAAC;IAErB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAMD,MAAM,WAAW,kCAAkC;IACjD,CAAC,yBAAyB,CAAC,iBAAiB,CAAC,EAAE,uBAAuB,CAAC;CACxE;AAGD,MAAM,MAAM,wBAAwB,GAClC,kCAAkC,CAAC,MAAM,kCAAkC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export interface PromotionCreativeIssue {
2
+ field: string;
3
+ code: 'REQUIRED' | 'INVALID' | 'TOO_LONG' | 'UNKNOWN_TEMPLATE';
4
+ message: string;
5
+ }
6
+ export interface PromotionCreativeValidationInput {
7
+ template: string;
8
+ content: unknown;
9
+ consentText: string | null;
10
+ }
11
+ export declare function validatePromotionCreative(input: PromotionCreativeValidationInput): PromotionCreativeIssue[];
12
+ export declare function isPromotionCreativeLive(input: PromotionCreativeValidationInput): boolean;
13
+ //# sourceMappingURL=promotion-creative.validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promotion-creative.validation.d.ts","sourceRoot":"","sources":["../../../src/promotions/validation/promotion-creative.validation.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,sBAAsB;IAErC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,kBAAkB,CAAC;IAC/D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAqDD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,gCAAgC,GACtC,sBAAsB,EAAE,CAqC1B;AAGD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,gCAAgC,GAAG,OAAO,CAExF"}
@@ -0,0 +1,82 @@
1
+ import { PromotionCreativeTemplate } from "../enums/promotion-creative-template.enum.js";
2
+ const HEX_COLOR = /^#[0-9a-fA-F]{6}$/;
3
+ const HTTPS_URL = /^https:\/\/\S+$/;
4
+ const CONSENT_MAX_LENGTH = 280;
5
+ const tournamentPosterRules = (hasImage) => ({
6
+ posterColor: {
7
+ required: true,
8
+ maxLength: 7,
9
+ pattern: HEX_COLOR,
10
+ patternMessage: "Use a cor no formato #RRGGBB."
11
+ },
12
+ monogram: { required: !hasImage, maxLength: 3 },
13
+ posterImageUrl: {
14
+ required: false,
15
+ maxLength: 2048,
16
+ pattern: HTTPS_URL,
17
+ patternMessage: "Use uma URL https."
18
+ },
19
+ headline: { required: false, maxLength: 80 },
20
+ kicker: { required: false, maxLength: 80 },
21
+ badge: { required: false, maxLength: 40 },
22
+ ctaLabel: { required: true, maxLength: 40 },
23
+ dismissLabel: { required: true, maxLength: 40 },
24
+ contactMessage: { required: false, maxLength: 500 }
25
+ });
26
+ const isFilled = (value) => typeof value === "string" && value.trim().length > 0;
27
+ function validatePromotionCreative(input) {
28
+ if (input.template !== PromotionCreativeTemplate.TOURNAMENT_POSTER) {
29
+ return [{ field: "template", code: "UNKNOWN_TEMPLATE", message: "Layout desconhecido." }];
30
+ }
31
+ const issues = [];
32
+ if (!isFilled(input.consentText)) {
33
+ issues.push({
34
+ field: "consentText",
35
+ code: "REQUIRED",
36
+ message: "Preencha o aviso de compartilhamento."
37
+ });
38
+ } else if (input.consentText.trim().length > CONSENT_MAX_LENGTH) {
39
+ issues.push({
40
+ field: "consentText",
41
+ code: "TOO_LONG",
42
+ message: `Use at\xE9 ${CONSENT_MAX_LENGTH} caracteres.`
43
+ });
44
+ }
45
+ const content = input.content;
46
+ if (typeof content !== "object" || content === null || Array.isArray(content)) {
47
+ issues.push({ field: "content", code: "INVALID", message: "Conte\xFAdo do criativo inv\xE1lido." });
48
+ return issues;
49
+ }
50
+ const fields = new Map(Object.entries(content));
51
+ const rules = tournamentPosterRules(isFilled(fields.get("posterImageUrl")));
52
+ for (const [name, rule] of Object.entries(rules)) {
53
+ const issue = checkField(name, fields.get(name), rule);
54
+ if (issue) {
55
+ issues.push(issue);
56
+ }
57
+ }
58
+ return issues;
59
+ }
60
+ function isPromotionCreativeLive(input) {
61
+ return validatePromotionCreative(input).length === 0;
62
+ }
63
+ function checkField(name, value, rule) {
64
+ const field = `content.${name}`;
65
+ if (value === void 0 || value === null || typeof value === "string" && !value.trim()) {
66
+ return rule.required ? { field, code: "REQUIRED", message: "Campo obrigat\xF3rio." } : null;
67
+ }
68
+ if (typeof value !== "string") {
69
+ return { field, code: "INVALID", message: "Use texto." };
70
+ }
71
+ if (value.trim().length > rule.maxLength) {
72
+ return { field, code: "TOO_LONG", message: `Use at\xE9 ${rule.maxLength} caracteres.` };
73
+ }
74
+ if (rule.pattern && !rule.pattern.test(value.trim())) {
75
+ return { field, code: "INVALID", message: rule.patternMessage ?? "Formato inv\xE1lido." };
76
+ }
77
+ return null;
78
+ }
79
+ export {
80
+ isPromotionCreativeLive,
81
+ validatePromotionCreative
82
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@natrave/shared-entities",
3
- "version": "8.33.0",
3
+ "version": "8.35.0",
4
4
  "description": "Entidades compartilhadass da NaTrave",
5
5
  "module": "dist/index.js",
6
6
  "main": "dist/index.js",