@grapadigital/shared-schemas 1.0.242 → 1.1.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 (148) hide show
  1. package/dist/index.d.ts +42 -42
  2. package/dist/schemas/action.schema.d.ts +9 -34
  3. package/dist/schemas/action.schema.js +81 -64
  4. package/dist/schemas/assignment.schema.d.ts +3 -28
  5. package/dist/schemas/assignment.schema.js +44 -44
  6. package/dist/schemas/benchmark.schema.d.ts +3 -28
  7. package/dist/schemas/benchmark.schema.js +11 -6
  8. package/dist/schemas/campaign.schema.d.ts +2 -27
  9. package/dist/schemas/campaign.schema.js +4 -4
  10. package/dist/schemas/client.schema.d.ts +18 -79
  11. package/dist/schemas/client.schema.js +73 -71
  12. package/dist/schemas/comment.schema.d.ts +5 -30
  13. package/dist/schemas/comment.schema.js +42 -37
  14. package/dist/schemas/commission.schema.d.ts +5 -30
  15. package/dist/schemas/commission.schema.js +10 -10
  16. package/dist/schemas/content-capture-process.schema.d.ts +6 -31
  17. package/dist/schemas/content-capture-process.schema.js +24 -17
  18. package/dist/schemas/content-draft.schema.d.ts +2 -27
  19. package/dist/schemas/content-draft.schema.js +5 -5
  20. package/dist/schemas/content.schema.d.ts +6 -31
  21. package/dist/schemas/content.schema.js +84 -74
  22. package/dist/schemas/contract.schema.d.ts +3 -28
  23. package/dist/schemas/contract.schema.js +5 -5
  24. package/dist/schemas/creative.schema.d.ts +6 -31
  25. package/dist/schemas/creative.schema.js +22 -31
  26. package/dist/schemas/export-comments-job.schema.d.ts +2 -27
  27. package/dist/schemas/export-comments-job.schema.js +6 -6
  28. package/dist/schemas/group.schema.d.ts +1 -26
  29. package/dist/schemas/group.schema.js +5 -5
  30. package/dist/schemas/influencer.schema.d.ts +6 -31
  31. package/dist/schemas/influencer.schema.js +16 -18
  32. package/dist/schemas/invoice.schema.d.ts +4 -29
  33. package/dist/schemas/invoice.schema.js +42 -32
  34. package/dist/schemas/job.schema.d.ts +2 -27
  35. package/dist/schemas/job.schema.js +14 -14
  36. package/dist/schemas/lead.schema.d.ts +1 -26
  37. package/dist/schemas/lead.schema.js +67 -64
  38. package/dist/schemas/log.schema.d.ts +1 -26
  39. package/dist/schemas/log.schema.js +24 -24
  40. package/dist/schemas/note.schema.d.ts +1 -26
  41. package/dist/schemas/note.schema.js +9 -9
  42. package/dist/schemas/notifications.schema.d.ts +1 -26
  43. package/dist/schemas/notifications.schema.js +8 -8
  44. package/dist/schemas/organization.schema.d.ts +1 -26
  45. package/dist/schemas/organization.schema.js +4 -4
  46. package/dist/schemas/party.schema.d.ts +1 -26
  47. package/dist/schemas/party.schema.js +11 -11
  48. package/dist/schemas/payment.schema.d.ts +10 -35
  49. package/dist/schemas/payment.schema.js +63 -54
  50. package/dist/schemas/profile.schema.d.ts +3 -28
  51. package/dist/schemas/profile.schema.js +6 -6
  52. package/dist/schemas/project.schema.d.ts +4 -29
  53. package/dist/schemas/project.schema.js +13 -13
  54. package/dist/schemas/prospect.schema.d.ts +3 -28
  55. package/dist/schemas/prospect.schema.js +9 -9
  56. package/dist/schemas/recruitment.schema.d.ts +5 -30
  57. package/dist/schemas/recruitment.schema.js +36 -36
  58. package/dist/schemas/responsible.schema.d.ts +0 -26
  59. package/dist/schemas/responsible.schema.js +6 -6
  60. package/dist/schemas/sale.schema.d.ts +16 -41
  61. package/dist/schemas/sale.schema.js +43 -51
  62. package/dist/schemas/script.schema.d.ts +6 -31
  63. package/dist/schemas/script.schema.js +21 -30
  64. package/dist/schemas/snapshot.schema.d.ts +3 -28
  65. package/dist/schemas/snapshot.schema.js +6 -6
  66. package/dist/schemas/store-visit.schema.d.ts +2 -27
  67. package/dist/schemas/store-visit.schema.js +21 -17
  68. package/dist/schemas/store.schema.d.ts +3 -28
  69. package/dist/schemas/store.schema.js +8 -8
  70. package/dist/schemas/supplier.schema.d.ts +2 -27
  71. package/dist/schemas/supplier.schema.js +3 -3
  72. package/dist/schemas/tag.schema.d.ts +1 -26
  73. package/dist/schemas/tag.schema.js +5 -5
  74. package/dist/schemas/task.schema.d.ts +9 -34
  75. package/dist/schemas/task.schema.js +67 -67
  76. package/dist/schemas/token.schema.d.ts +1 -26
  77. package/dist/schemas/token.schema.js +3 -3
  78. package/dist/schemas/trigger.schema.d.ts +2 -27
  79. package/dist/schemas/trigger.schema.js +5 -5
  80. package/dist/schemas/user.schema.d.ts +2 -27
  81. package/dist/schemas/user.schema.js +7 -7
  82. package/dist/schemas/webhook.schema.d.ts +1 -26
  83. package/dist/schemas/webhook.schema.js +10 -10
  84. package/dist/utils/merge-metrics-breakdown.util.d.ts +1 -1
  85. package/dist/utils/merge-metrics-breakdown.util.js +7 -2
  86. package/dist/utils/normalize-content-link.util.js +7 -7
  87. package/package.json +23 -13
  88. package/.eslintrc.json +0 -28
  89. package/.prettierrc +0 -4
  90. package/dist/schemas/profile-followers-snapshot.schema.d.ts +0 -67
  91. package/dist/schemas/profile-followers-snapshot.schema.js +0 -65
  92. package/dist/schemas/schedule.schema.d.ts +0 -73
  93. package/dist/schemas/schedule.schema.js +0 -116
  94. package/dist/utils/cost-per-impact.util.d.ts +0 -37
  95. package/dist/utils/cost-per-impact.util.js +0 -72
  96. package/dist/utils/influencer-contract.util.d.ts +0 -32
  97. package/dist/utils/influencer-contract.util.js +0 -77
  98. package/docs/code-review.md +0 -27
  99. package/docs/constitution.md +0 -75
  100. package/docs/specs/GD-692.md +0 -112
  101. package/docs/specs/GD-761.md +0 -94
  102. package/index.d.ts +0 -3
  103. package/src/index.ts +0 -42
  104. package/src/schemas/action.schema.ts +0 -328
  105. package/src/schemas/assignment.schema.ts +0 -154
  106. package/src/schemas/benchmark.schema.ts +0 -39
  107. package/src/schemas/campaign.schema.ts +0 -38
  108. package/src/schemas/client.schema.ts +0 -319
  109. package/src/schemas/comment.schema.ts +0 -216
  110. package/src/schemas/commission.schema.ts +0 -108
  111. package/src/schemas/content-capture-process.schema.ts +0 -195
  112. package/src/schemas/content-draft.schema.ts +0 -49
  113. package/src/schemas/content.schema.ts +0 -688
  114. package/src/schemas/contract.schema.ts +0 -44
  115. package/src/schemas/creative.schema.ts +0 -256
  116. package/src/schemas/export-comments-job.schema.ts +0 -59
  117. package/src/schemas/group.schema.ts +0 -23
  118. package/src/schemas/influencer.schema.ts +0 -184
  119. package/src/schemas/invoice.schema.ts +0 -164
  120. package/src/schemas/job.schema.ts +0 -111
  121. package/src/schemas/lead.schema.ts +0 -372
  122. package/src/schemas/log.schema.ts +0 -91
  123. package/src/schemas/note.schema.ts +0 -34
  124. package/src/schemas/notifications.schema.ts +0 -61
  125. package/src/schemas/organization.schema.ts +0 -29
  126. package/src/schemas/party.schema.ts +0 -65
  127. package/src/schemas/payment.schema.ts +0 -275
  128. package/src/schemas/profile.schema.ts +0 -77
  129. package/src/schemas/project.schema.ts +0 -116
  130. package/src/schemas/prospect.schema.ts +0 -62
  131. package/src/schemas/recruitment.schema.ts +0 -277
  132. package/src/schemas/responsible.schema.ts +0 -27
  133. package/src/schemas/sale.schema.ts +0 -297
  134. package/src/schemas/script.schema.ts +0 -235
  135. package/src/schemas/snapshot.schema.ts +0 -55
  136. package/src/schemas/store-visit.schema.ts +0 -68
  137. package/src/schemas/store.schema.ts +0 -52
  138. package/src/schemas/supplier.schema.ts +0 -12
  139. package/src/schemas/tag.schema.ts +0 -26
  140. package/src/schemas/task.schema.ts +0 -205
  141. package/src/schemas/token.schema.ts +0 -42
  142. package/src/schemas/trigger.schema.ts +0 -48
  143. package/src/schemas/user.schema.ts +0 -59
  144. package/src/schemas/webhook.schema.ts +0 -81
  145. package/src/utils/merge-metrics-breakdown.util.ts +0 -51
  146. package/src/utils/normalize-content-link.util.ts +0 -31
  147. package/tsconfig.build.json +0 -5
  148. package/tsconfig.json +0 -29
@@ -1,44 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { HydratedDocument, Schema as MongooseSchema, Types, model as MongooseModel } from 'mongoose';
3
- import { Recruitment } from './recruitment.schema';
4
-
5
- export type ContractDocument = HydratedDocument<Contract>;
6
-
7
- @Schema({ timestamps: true })
8
- export class Contract {
9
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
10
- _id?: Types.ObjectId;
11
-
12
- @Prop()
13
- variables: MongooseSchema.Types.Mixed;
14
-
15
- @Prop({ type: String, default: 'none', enum: ['none', 'signed'] })
16
- status: 'none' | 'signed';
17
-
18
- @Prop()
19
- ip: string;
20
-
21
- @Prop()
22
- userAgent: string;
23
-
24
- @Prop()
25
- signedAt: Date;
26
-
27
- @Prop()
28
- contractText: string;
29
-
30
- @Prop()
31
- contractHash: string;
32
-
33
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Recruitment' })
34
- recruitment: Types.ObjectId | Recruitment;
35
-
36
- @Prop({ default: Date.now, required: false })
37
- createdAt?: Date;
38
-
39
- @Prop({ default: Date.now, required: false })
40
- updatedAt?: Date;
41
- }
42
-
43
- export const ContractSchema = SchemaFactory.createForClass(Contract);
44
- export const ContractModel = MongooseModel('Contract', ContractSchema);
@@ -1,256 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { ApiProperty } from '@nestjs/swagger';
3
- import {
4
- HydratedDocument,
5
- Schema as MongooseSchema,
6
- Types,
7
- model as MongooseModel,
8
- } from 'mongoose';
9
-
10
- import { Action } from './action.schema';
11
- import { Client } from './client.schema';
12
- import { Profile } from './profile.schema';
13
- import { TASK_FORMAT_VALUES, TaskFormat } from './task.schema';
14
-
15
- export type CreativeDocument = HydratedDocument<Creative>;
16
-
17
- export const CREATIVE_STATUS_VALUES = [
18
- 'draft',
19
- 'pending',
20
- 'approved',
21
- 'reproved',
22
- ] as const;
23
- export type CreativeStatus = (typeof CREATIVE_STATUS_VALUES)[number];
24
-
25
- export const CREATIVE_DECISION_VALUES = [
26
- 'approved',
27
- 'reproved',
28
- 'questioned',
29
- ] as const;
30
- export type CreativeDecisionValue = (typeof CREATIVE_DECISION_VALUES)[number];
31
-
32
- export const CREATIVE_MEDIA_TYPE_VALUES = ['image', 'video'] as const;
33
- export type CreativeMediaType = (typeof CREATIVE_MEDIA_TYPE_VALUES)[number];
34
-
35
- @Schema({ _id: false })
36
- export class CreativeDecision {
37
- @ApiProperty({ enum: CREATIVE_DECISION_VALUES })
38
- @Prop({ type: String, enum: CREATIVE_DECISION_VALUES, required: true })
39
- decision: CreativeDecisionValue;
40
-
41
- @ApiProperty({ required: false })
42
- @Prop({ type: String, required: false })
43
- comment?: string;
44
-
45
- @ApiProperty({ description: 'Time do cliente que respondeu, lido do JWT' })
46
- @Prop({ type: String, required: true })
47
- team: string;
48
-
49
- @ApiProperty()
50
- @Prop({ type: String, required: true })
51
- respondedBy: string;
52
-
53
- @ApiProperty()
54
- @Prop({ type: Date, required: true })
55
- respondedAt: Date;
56
- }
57
-
58
- export const CreativeDecisionSchema =
59
- SchemaFactory.createForClass(CreativeDecision);
60
-
61
- @Schema({ _id: false })
62
- export class CreativeStaffReply {
63
- @ApiProperty()
64
- @Prop({ type: String, required: true })
65
- message: string;
66
-
67
- @ApiProperty()
68
- @Prop({ type: String, required: true })
69
- repliedBy: string;
70
-
71
- @ApiProperty()
72
- @Prop({ type: Date, required: true })
73
- repliedAt: Date;
74
- }
75
-
76
- export const CreativeStaffReplySchema =
77
- SchemaFactory.createForClass(CreativeStaffReply);
78
-
79
- @Schema({ _id: false })
80
- export class CreativeVersion {
81
- @ApiProperty()
82
- @Prop({ type: Number, required: true })
83
- version: number;
84
-
85
- @ApiProperty({ required: false })
86
- @Prop({ type: String, required: false, default: null })
87
- fileUrl?: string | null;
88
-
89
- @ApiProperty({ required: false })
90
- @Prop({ type: String, required: false, default: null })
91
- fileName?: string | null;
92
-
93
- @ApiProperty({ enum: CREATIVE_MEDIA_TYPE_VALUES, required: false })
94
- @Prop({
95
- type: String,
96
- enum: CREATIVE_MEDIA_TYPE_VALUES,
97
- required: false,
98
- default: null,
99
- })
100
- mediaType?: CreativeMediaType | null;
101
-
102
- @ApiProperty({ required: false })
103
- @Prop({ type: String, required: false, default: null })
104
- caption?: string | null;
105
-
106
- @ApiProperty({ enum: ['approved', 'reproved'] })
107
- @Prop({ type: String, enum: ['approved', 'reproved'], required: true })
108
- status: 'approved' | 'reproved';
109
-
110
- @ApiProperty({ required: false })
111
- @Prop({ type: String, required: false })
112
- submittedBy?: string;
113
-
114
- @ApiProperty({ required: false })
115
- @Prop({ type: Date, required: false })
116
- submittedAt?: Date;
117
-
118
- @ApiProperty({ type: () => [CreativeDecision] })
119
- @Prop({ type: [CreativeDecisionSchema], default: [] })
120
- decisions: CreativeDecision[];
121
-
122
- @ApiProperty({ type: () => [CreativeStaffReply] })
123
- @Prop({ type: [CreativeStaffReplySchema], default: [] })
124
- staffReplies: CreativeStaffReply[];
125
-
126
- @ApiProperty()
127
- @Prop({ type: Date, required: true })
128
- archivedAt: Date;
129
- }
130
-
131
- export const CreativeVersionSchema =
132
- SchemaFactory.createForClass(CreativeVersion);
133
-
134
- /**
135
- * Aprovação de conteúdo (prévia final): um documento por (action, profile,
136
- * deliverableType, deliverableIndex) — não um doc único por Ação. Mesmo
137
- * padrão de `Script` (ver GD-532); ao reprovar, o estado atual é arquivado em
138
- * `versions[]` e o doc fica em `reproved` até o staff editar e reenviar
139
- * (ver GD-537).
140
- */
141
- @Schema({ timestamps: true })
142
- export class Creative {
143
- @ApiProperty()
144
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
145
- _id?: Types.ObjectId;
146
-
147
- @ApiProperty({ type: () => Action })
148
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Action', required: true })
149
- action: Types.ObjectId | Action;
150
-
151
- @ApiProperty({ type: () => Client })
152
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Client', required: false })
153
- client?: Types.ObjectId | Client;
154
-
155
- @ApiProperty({ type: () => Profile })
156
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Profile', required: true })
157
- profile: Types.ObjectId | Profile;
158
-
159
- @ApiProperty({
160
- enum: TASK_FORMAT_VALUES,
161
- description: 'Unidade de entrega do escopo (mesmos valores de recruitment.scope.delivery)',
162
- })
163
- @Prop({ type: String, enum: TASK_FORMAT_VALUES, required: true })
164
- deliverableType: TaskFormat;
165
-
166
- @ApiProperty({
167
- description: 'Ex.: 1 de 2 quando o escopo pede mais de uma unidade do mesmo tipo; sempre 1 para "story"',
168
- })
169
- @Prop({ type: Number, required: true, default: 1 })
170
- deliverableIndex: number;
171
-
172
- @ApiProperty()
173
- @Prop({ type: Number, required: true, default: 1 })
174
- version: number;
175
-
176
- @ApiProperty({ required: false })
177
- @Prop({ type: String, required: false, default: null })
178
- fileUrl?: string | null;
179
-
180
- @ApiProperty({ required: false })
181
- @Prop({ type: String, required: false, default: null })
182
- fileName?: string | null;
183
-
184
- @ApiProperty({ enum: CREATIVE_MEDIA_TYPE_VALUES, required: false })
185
- @Prop({
186
- type: String,
187
- enum: CREATIVE_MEDIA_TYPE_VALUES,
188
- required: false,
189
- default: null,
190
- })
191
- mediaType?: CreativeMediaType | null;
192
-
193
- @ApiProperty({ required: false, description: 'Legenda, campo separado do arquivo' })
194
- @Prop({ type: String, required: false, default: null })
195
- caption?: string | null;
196
-
197
- @ApiProperty({ enum: CREATIVE_STATUS_VALUES })
198
- @Prop({
199
- type: String,
200
- enum: CREATIVE_STATUS_VALUES,
201
- required: true,
202
- default: 'draft',
203
- })
204
- status: CreativeStatus;
205
-
206
- @ApiProperty({
207
- type: [String],
208
- description:
209
- 'Snapshot de Client.requiredTeams no momento da criação — vazio = 1 aprovação resolve; com times = todos precisam aprovar',
210
- })
211
- @Prop({ type: [String], required: false, default: [] })
212
- requiredTeams: string[];
213
-
214
- @ApiProperty({ required: false })
215
- @Prop({ type: String, required: false })
216
- submittedBy?: string;
217
-
218
- @ApiProperty({ required: false })
219
- @Prop({ type: Date, required: false })
220
- submittedAt?: Date;
221
-
222
- @ApiProperty({ type: () => [CreativeDecision] })
223
- @Prop({ type: [CreativeDecisionSchema], default: [] })
224
- decisions: CreativeDecision[];
225
-
226
- @ApiProperty({ type: () => [CreativeStaffReply] })
227
- @Prop({ type: [CreativeStaffReplySchema], default: [] })
228
- staffReplies: CreativeStaffReply[];
229
-
230
- @ApiProperty({ type: () => [CreativeVersion] })
231
- @Prop({ type: [CreativeVersionSchema], default: [] })
232
- versions: CreativeVersion[];
233
-
234
- @Prop({ type: MongooseSchema.Types.ObjectId, required: false })
235
- organization?: Types.ObjectId;
236
-
237
- @ApiProperty()
238
- @Prop({ default: Date.now, required: false })
239
- createdAt?: Date;
240
-
241
- @ApiProperty()
242
- @Prop({ default: Date.now, required: false })
243
- updatedAt?: Date;
244
- }
245
-
246
- export const CreativeSchema = SchemaFactory.createForClass(Creative);
247
-
248
- CreativeSchema.index(
249
- { action: 1, profile: 1, deliverableType: 1, deliverableIndex: 1 },
250
- { unique: true },
251
- );
252
- CreativeSchema.index({ action: 1, status: 1 });
253
- CreativeSchema.index({ client: 1, status: 1 });
254
- CreativeSchema.index({ organization: 1, status: 1 });
255
-
256
- export const CreativeModel = MongooseModel('Creative', CreativeSchema);
@@ -1,59 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import {
3
- HydratedDocument,
4
- Schema as MongooseSchema,
5
- Types,
6
- model as MongooseModel,
7
- } from 'mongoose';
8
-
9
- export type ExportCommentsJobDocument = HydratedDocument<ExportCommentsJob>;
10
-
11
- /**
12
- * Checkpoint de idempotência para o job assíncrono de captura de comentários
13
- * na exportcomments.com: garante que um crash no meio do polling não crie um
14
- * job duplicado na API externa ao reprocessar a mensagem. `raw` guarda o JSON
15
- * exato devolvido pela exportcomments.com pra esse content — auditoria
16
- * completa (mesmo padrão do `raw` em `ContentDraft` pra Primetag) e checkpoint
17
- * de reuso: se já existe `raw` salvo, não precisa chamar a API de novo mesmo
18
- * que o mapeamento/upsert em `Comment` tenha falhado depois do download.
19
- */
20
- @Schema({ collection: 'export-comments-jobs', timestamps: true })
21
- export class ExportCommentsJob {
22
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
23
- _id?: Types.ObjectId;
24
-
25
- @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
26
- contentId: Types.ObjectId;
27
-
28
- @Prop({ type: String, required: false })
29
- guid?: string;
30
-
31
- @Prop({ type: String, required: false })
32
- jsonUrl?: string;
33
-
34
- @Prop({ type: MongooseSchema.Types.Mixed, required: false })
35
- raw?: unknown[];
36
-
37
- @Prop({
38
- type: String,
39
- enum: ['creating', 'polling', 'done', 'error', 'timeout'],
40
- required: true,
41
- default: 'creating',
42
- })
43
- status: 'creating' | 'polling' | 'done' | 'error' | 'timeout';
44
-
45
- @Prop({ type: String, required: false })
46
- error?: string;
47
-
48
- @Prop({ default: Date.now, required: false })
49
- createdAt?: Date;
50
-
51
- @Prop({ default: Date.now, required: false })
52
- updatedAt?: Date;
53
- }
54
-
55
- export const ExportCommentsJobSchema = SchemaFactory.createForClass(ExportCommentsJob);
56
-
57
- ExportCommentsJobSchema.index({ contentId: 1 }, { unique: true });
58
-
59
- export const ExportCommentsJobModel = MongooseModel('ExportCommentsJob', ExportCommentsJobSchema);
@@ -1,23 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { HydratedDocument, Types } from 'mongoose';
3
-
4
- export type GroupDocument = HydratedDocument<Group>;
5
-
6
- @Schema({ timestamps: true, collection: 'group' })
7
- export class Group {
8
- @Prop({ type: Types.ObjectId, ref: 'Organization', required: true, index: true })
9
- organization: Types.ObjectId;
10
-
11
- @Prop({ required: true, trim: true })
12
- name: string;
13
-
14
- @Prop({ type: [Types.ObjectId], ref: 'User', default: [] })
15
- memberIds: Types.ObjectId[];
16
-
17
- createdAt?: Date;
18
- updatedAt?: Date;
19
- }
20
-
21
- export const GroupSchema = SchemaFactory.createForClass(Group);
22
-
23
- GroupSchema.index({ organization: 1, name: 1 }, { unique: true });
@@ -1,184 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { HydratedDocument, Schema as MongooseSchema, Types, model as MongooseModel } from 'mongoose';
3
- import { Profile } from './profile.schema';
4
- import { Party } from './party.schema';
5
- import { Client } from './client.schema';
6
- import { Delivery, DeliverySchema } from './recruitment.schema';
7
-
8
- export type InfluencerDocument = HydratedDocument<Influencer>;
9
- @Schema({ _id: false })
10
- export class Advisor {
11
- @Prop()
12
- email: string;
13
-
14
- @Prop()
15
- legalName: string;
16
-
17
- @Prop()
18
- document: string;
19
-
20
- @Prop()
21
- phone: string;
22
-
23
- @Prop()
24
- bank: string;
25
-
26
- @Prop()
27
- agency: string;
28
-
29
- @Prop()
30
- account: string;
31
-
32
- @Prop()
33
- digit: string;
34
- }
35
-
36
- export const AdvisorSchema = SchemaFactory.createForClass(Advisor);
37
-
38
- @Schema({ _id: false })
39
- export class Note {
40
- @Prop() text: string;
41
-
42
- @Prop() owner: string;
43
-
44
- @Prop({ type: Date, default: Date.now })
45
- createdAt: Date;
46
- }
47
-
48
- export const NoteSchema = SchemaFactory.createForClass(Note);
49
-
50
- /** Status do Contrato do Influenciador. Ver GD-715. */
51
- export const CONTRACT_STATUS_VALUES = ['draft', 'proposed', 'signed', 'rejected'] as const;
52
- export type ContractStatus = (typeof CONTRACT_STATUS_VALUES)[number];
53
-
54
- /**
55
- * Aditivo do Contrato: soma no valor total quando ativo e pode estender a
56
- * vigência (o fim do Contrato vai até o fim do último Aditivo ativo). Não tem
57
- * ligação com Ações. Ver GD-715.
58
- */
59
- @Schema({ timestamps: true })
60
- export class ContractAmendment {
61
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
62
- _id?: Types.ObjectId;
63
-
64
- @Prop({ type: Number, required: true })
65
- value: number;
66
-
67
- @Prop({ type: Boolean, required: false, default: true })
68
- isActive?: boolean;
69
-
70
- @Prop({ type: Date, required: true })
71
- startDate: Date;
72
-
73
- @Prop({ type: Date, required: true })
74
- endDate: Date;
75
-
76
- @Prop({ type: String, required: false, default: null })
77
- description?: string | null;
78
- }
79
-
80
- export const ContractAmendmentSchema = SchemaFactory.createForClass(ContractAmendment);
81
-
82
- // Contrato de valor fixo recorrente (influenciador embaixador de marca) —
83
- // alternativa ao pagamento avulso por Recruitment (scope.payment/advisorPayment).
84
- // Escopo de entregas reaproveita a mesma classe Delivery do termo de aceite
85
- // (Recruitment.scope.delivery), pra manter o mesmo vocabulário.
86
- @Schema({ timestamps: true })
87
- export class InfluencerContract {
88
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
89
- _id?: Types.ObjectId;
90
-
91
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Client', required: true })
92
- client: Types.ObjectId | Client;
93
-
94
- /** Cachê total do Contrato (o `valor_cache` do genc). Ver GD-715. */
95
- @Prop({ type: Number, required: true })
96
- value: number;
97
-
98
- /** Valor em produtos; entra no total. Ver GD-715. */
99
- @Prop({ type: Number, required: false, default: 0 })
100
- productsValue?: number;
101
-
102
- @Prop({ type: String, enum: CONTRACT_STATUS_VALUES, required: false, default: 'signed' })
103
- status?: ContractStatus;
104
-
105
- /** Desligado = Contrato encerrado. */
106
- @Prop({ type: Boolean, required: false, default: true })
107
- isActive?: boolean;
108
-
109
- /**
110
- * Rateio do custo: monthly = valor mensal (total ÷ meses) por mês-calendário;
111
- * annual = valor total no período.
112
- */
113
- @Prop({ type: String, enum: ['monthly', 'annual'], required: true })
114
- periodType: 'monthly' | 'annual';
115
-
116
- @Prop({ type: Date, required: true })
117
- startDate: Date;
118
-
119
- // Ausente = contrato em aberto/vigente.
120
- @Prop({ type: Date, required: false })
121
- endDate?: Date;
122
-
123
- // Ausente/não preenchido = sem limite de escopo (denominador do rateio usa
124
- // a contagem real de contents entregues no período); presente = soma de
125
- // todos os campos preenchidos vira o denominador fixo (ex.: reels:1 + stories:3 = 4).
126
- @Prop({ type: DeliverySchema, required: false })
127
- deliveryScope?: Delivery;
128
-
129
- // URL do documento do contrato (upload feito fora daqui, ex.: S3/GCS pela
130
- // futura tela de "Contratos" no perfil do influenciador) — só a referência
131
- // fica salva no Mongo.
132
- @Prop({ type: String, required: false })
133
- documentUrl?: string;
134
-
135
- /** CPI (Custo por Impacto) contratual, digitado no planejamento. Ver GD-715. */
136
- @Prop({ type: Number, required: false, default: null })
137
- contractedCostPerImpact?: number | null;
138
-
139
- /** E/R contratual, em fração (0,02 = 2%). */
140
- @Prop({ type: Number, required: false, default: null })
141
- contractedEngagementRate?: number | null;
142
-
143
- /** Chave de `Client.squads` do cliente do Contrato (ex.: `team_galaxy`). Ver GD-770. */
144
- @Prop({ type: String, required: false, default: null })
145
- squad?: string | null;
146
-
147
- /** Ex.: "Technology", "Camera", "Fashion". */
148
- @Prop({ type: String, required: false, default: null })
149
- passionPoint?: string | null;
150
-
151
- @Prop({ type: String, required: false, default: null })
152
- description?: string | null;
153
-
154
- @Prop({ type: [ContractAmendmentSchema], required: false, default: [] })
155
- amendments?: ContractAmendment[];
156
- }
157
-
158
- export const InfluencerContractSchema = SchemaFactory.createForClass(InfluencerContract);
159
-
160
- @Schema({ timestamps: true })
161
- export class Influencer extends Party {
162
- @Prop({ required: false })
163
- financialManagementSheet?: string;
164
-
165
- @Prop({ type: Boolean, default: false })
166
- isExclusive: boolean;
167
-
168
- @Prop({ type: AdvisorSchema, required: false })
169
- advisor?: Advisor;
170
-
171
- @Prop([
172
- { type: MongooseSchema.Types.ObjectId, ref: 'Profile', required: false },
173
- ])
174
- profiles?: Types.ObjectId[] | Profile[];
175
-
176
- @Prop({ type: [NoteSchema], required: false })
177
- notes?: Note[];
178
-
179
- @Prop({ type: [InfluencerContractSchema], required: false })
180
- contracts?: InfluencerContract[];
181
- }
182
-
183
- export const InfluencerSchema = SchemaFactory.createForClass(Influencer);
184
- export const InfluencerModel = MongooseModel('Influencer', InfluencerSchema);