@grapadigital/shared-schemas 1.0.241 → 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 +13 -38
  3. package/dist/schemas/action.schema.js +81 -64
  4. package/dist/schemas/assignment.schema.d.ts +6 -31
  5. package/dist/schemas/assignment.schema.js +44 -44
  6. package/dist/schemas/benchmark.schema.d.ts +5 -30
  7. package/dist/schemas/benchmark.schema.js +11 -6
  8. package/dist/schemas/campaign.schema.d.ts +4 -29
  9. package/dist/schemas/campaign.schema.js +4 -4
  10. package/dist/schemas/client.schema.d.ts +30 -91
  11. package/dist/schemas/client.schema.js +73 -71
  12. package/dist/schemas/comment.schema.d.ts +9 -34
  13. package/dist/schemas/comment.schema.js +42 -37
  14. package/dist/schemas/commission.schema.d.ts +7 -32
  15. package/dist/schemas/commission.schema.js +10 -10
  16. package/dist/schemas/content-capture-process.schema.d.ts +12 -37
  17. package/dist/schemas/content-capture-process.schema.js +24 -17
  18. package/dist/schemas/content-draft.schema.d.ts +4 -29
  19. package/dist/schemas/content-draft.schema.js +5 -5
  20. package/dist/schemas/content.schema.d.ts +20 -45
  21. package/dist/schemas/content.schema.js +84 -74
  22. package/dist/schemas/contract.schema.d.ts +5 -30
  23. package/dist/schemas/contract.schema.js +5 -5
  24. package/dist/schemas/creative.schema.d.ts +11 -36
  25. package/dist/schemas/creative.schema.js +22 -31
  26. package/dist/schemas/export-comments-job.schema.d.ts +4 -29
  27. package/dist/schemas/export-comments-job.schema.js +6 -6
  28. package/dist/schemas/group.schema.d.ts +2 -27
  29. package/dist/schemas/group.schema.js +5 -5
  30. package/dist/schemas/influencer.schema.d.ts +12 -37
  31. package/dist/schemas/influencer.schema.js +16 -18
  32. package/dist/schemas/invoice.schema.d.ts +6 -31
  33. package/dist/schemas/invoice.schema.js +42 -32
  34. package/dist/schemas/job.schema.d.ts +4 -29
  35. package/dist/schemas/job.schema.js +14 -14
  36. package/dist/schemas/lead.schema.d.ts +15 -40
  37. package/dist/schemas/lead.schema.js +67 -64
  38. package/dist/schemas/log.schema.d.ts +3 -28
  39. package/dist/schemas/log.schema.js +24 -24
  40. package/dist/schemas/note.schema.d.ts +3 -28
  41. package/dist/schemas/note.schema.js +9 -9
  42. package/dist/schemas/notifications.schema.d.ts +3 -28
  43. package/dist/schemas/notifications.schema.js +8 -8
  44. package/dist/schemas/organization.schema.d.ts +2 -27
  45. package/dist/schemas/organization.schema.js +4 -4
  46. package/dist/schemas/party.schema.d.ts +6 -31
  47. package/dist/schemas/party.schema.js +11 -11
  48. package/dist/schemas/payment.schema.d.ts +20 -45
  49. package/dist/schemas/payment.schema.js +63 -54
  50. package/dist/schemas/profile.schema.d.ts +5 -30
  51. package/dist/schemas/profile.schema.js +6 -6
  52. package/dist/schemas/project.schema.d.ts +9 -34
  53. package/dist/schemas/project.schema.js +13 -13
  54. package/dist/schemas/prospect.schema.d.ts +6 -31
  55. package/dist/schemas/prospect.schema.js +9 -9
  56. package/dist/schemas/recruitment.schema.d.ts +19 -44
  57. package/dist/schemas/recruitment.schema.js +36 -36
  58. package/dist/schemas/responsible.schema.d.ts +1 -27
  59. package/dist/schemas/responsible.schema.js +6 -6
  60. package/dist/schemas/sale.schema.d.ts +19 -44
  61. package/dist/schemas/sale.schema.js +43 -51
  62. package/dist/schemas/script.schema.d.ts +11 -36
  63. package/dist/schemas/script.schema.js +21 -30
  64. package/dist/schemas/snapshot.schema.d.ts +5 -30
  65. package/dist/schemas/snapshot.schema.js +6 -6
  66. package/dist/schemas/store-visit.schema.d.ts +3 -28
  67. package/dist/schemas/store-visit.schema.js +21 -17
  68. package/dist/schemas/store.schema.d.ts +5 -30
  69. package/dist/schemas/store.schema.js +8 -8
  70. package/dist/schemas/supplier.schema.d.ts +4 -29
  71. package/dist/schemas/supplier.schema.js +3 -3
  72. package/dist/schemas/tag.schema.d.ts +2 -27
  73. package/dist/schemas/tag.schema.js +5 -5
  74. package/dist/schemas/task.schema.d.ts +11 -36
  75. package/dist/schemas/task.schema.js +67 -67
  76. package/dist/schemas/token.schema.d.ts +3 -28
  77. package/dist/schemas/token.schema.js +3 -3
  78. package/dist/schemas/trigger.schema.d.ts +3 -28
  79. package/dist/schemas/trigger.schema.js +5 -5
  80. package/dist/schemas/user.schema.d.ts +3 -28
  81. package/dist/schemas/user.schema.js +7 -7
  82. package/dist/schemas/webhook.schema.d.ts +6 -31
  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 +29 -16
  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,328 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { ApiProperty } from '@nestjs/swagger';
3
-
4
- import {
5
- HydratedDocument,
6
- Schema as MongooseSchema,
7
- Types,
8
- model as MongooseModel,
9
- } from 'mongoose';
10
-
11
- import { Recruitment } from './recruitment.schema';
12
- import { Content } from './content.schema';
13
- import { Client, ClientMetricGoal, ClientMetricGoalSchema } from './client.schema';
14
- import { Sale } from './sale.schema';
15
- import { Campaign } from './campaign.schema';
16
- import { Note, NoteSchema } from './note.schema';
17
- import { Responsible, ResponsibleSchema } from './responsible.schema';
18
-
19
- export type ActionDocument = HydratedDocument<Action>;
20
-
21
- export const ACTION_BUSINESS_UNIT_VALUES = [
22
- 'service',
23
- 'comercial',
24
- 'squad_a',
25
- 'squad_b',
26
- ] as const;
27
- export type ActionBusinessUnit = (typeof ACTION_BUSINESS_UNIT_VALUES)[number];
28
-
29
- @Schema({ _id: false })
30
- export class ActionPromptConfig {
31
- @ApiProperty({ required: false, description: 'Contexto da campanha (cliente, influencer, produto) para os prompts de classificação de comentário por IA' })
32
- @Prop({ type: String, required: false })
33
- context?: string;
34
-
35
- @ApiProperty({ required: false, description: 'Prompt customizado do estágio "alvo" (target)' })
36
- @Prop({ type: String, required: false })
37
- targetPrompt?: string;
38
-
39
- @ApiProperty({ required: false, description: 'Prompt customizado do estágio "assunto" (subject) para o grupo Influencer' })
40
- @Prop({ type: String, required: false })
41
- influencerPrompt?: string;
42
-
43
- @ApiProperty({ required: false, description: 'Prompt customizado do estágio "assunto" (subject) para o grupo Marca' })
44
- @Prop({ type: String, required: false })
45
- brandPrompt?: string;
46
-
47
- @ApiProperty({ required: false, description: 'Prompt customizado do estágio "assunto" (subject) para o grupo Conteúdo' })
48
- @Prop({ type: String, required: false })
49
- contentPrompt?: string;
50
-
51
- @ApiProperty({ required: false, description: 'Prompt customizado do estágio "polaridade" (polarity)' })
52
- @Prop({ type: String, required: false })
53
- polarityPrompt?: string;
54
-
55
- @ApiProperty({ required: false, description: 'Prompt customizado do estágio "funil" (funnel)' })
56
- @Prop({ type: String, required: false })
57
- funnelPrompt?: string;
58
- }
59
-
60
- export const ActionPromptConfigSchema = SchemaFactory.createForClass(ActionPromptConfig);
61
-
62
- export const ACTION_STATUS_VALUES = [
63
- 'config',
64
- 'inProgress',
65
- 'finished',
66
- 'archived',
67
- 'cancelled',
68
- ] as const;
69
- export type ActionStatus = (typeof ACTION_STATUS_VALUES)[number];
70
-
71
- /**
72
- * Tipo da Ação (Action.type). O nome evita confusão com o ACTION_TYPE_VALUES
73
- * do shared-app-modules, que é partnership. Ver GD-711.
74
- * - influency: Influência (antes "creator", "Creators Pago");
75
- * - organic: Orgânicos do mês da Samsung (GD-699/GD-711);
76
- * - annual: Ação anual da Samsung, fora da captura diária, atualizada só pelo
77
- * modo metrics-only do content-capture-worker.
78
- */
79
- export const ACTION_KIND_VALUES = ['seeding', 'ugc', 'influency', 'organic', 'annual'] as const;
80
- export type ActionKind = (typeof ACTION_KIND_VALUES)[number];
81
-
82
- /**
83
- * Fase da Ação (antigo briefing do genc). Com `_id` porque o Conteúdo aponta
84
- * para ela (`Content.phase`). Período e hashtags opcionais fazem a captura
85
- * sugerir a Fase sozinha; Fase sem os dois nunca é automática. Fases podem se
86
- * sobrepor: vale a primeira por `order`. Ver GD-691.
87
- */
88
- @Schema()
89
- export class ActionPhase {
90
- @ApiProperty({ example: '6710a1b2c3d4e5f601234567' })
91
- _id: Types.ObjectId;
92
-
93
- @ApiProperty({ example: 'Lançamento' })
94
- @Prop({ type: String, required: true })
95
- name: string;
96
-
97
- /** Hex #rrggbb, da paleta do cpanel. */
98
- @ApiProperty({ example: '#2563eb' })
99
- @Prop({ type: String, required: true })
100
- color: string;
101
-
102
- @ApiProperty({ example: 0, description: 'Prioridade quando Fases se sobrepõem (menor vale primeiro)' })
103
- @Prop({ type: Number, required: true })
104
- order: number;
105
-
106
- /** Inclusivo. */
107
- @ApiProperty({ type: Date, required: false, nullable: true })
108
- @Prop({ type: Date, required: false, default: null })
109
- startDate?: Date | null;
110
-
111
- /** Inclusivo (vale o dia inteiro). */
112
- @ApiProperty({ type: Date, required: false, nullable: true })
113
- @Prop({ type: Date, required: false, default: null })
114
- endDate?: Date | null;
115
-
116
- /** Normalizadas (minúsculas, sem # e sem acento). */
117
- @ApiProperty({ type: [String], example: ['galaxys26'] })
118
- @Prop({ type: [String], default: [] })
119
- hashtags: string[];
120
- }
121
-
122
- export const ActionPhaseSchema = SchemaFactory.createForClass(ActionPhase);
123
-
124
- @Schema({ timestamps: true })
125
- export class Action {
126
- @ApiProperty({ example: '64bfc3a78d3f1e2a12345678' })
127
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
128
- _id?: Types.ObjectId;
129
-
130
- @ApiProperty({ example: 'Campanha Black Friday' })
131
- @Prop({ type: String, required: true })
132
- title: string;
133
-
134
- @ApiProperty({ example: 'https://image.url/thumb.png', required: false })
135
- @Prop({ type: String, required: false })
136
- thumbnail?: string;
137
-
138
- @ApiProperty({ example: '2025-11-01T00:00:00.000Z' })
139
- @Prop({ type: Date, required: true })
140
- startDate: Date;
141
-
142
- @ApiProperty({ example: '2025-11-30T23:59:59.000Z' })
143
- @Prop({ type: Date, required: true })
144
- endDate: Date;
145
-
146
- @ApiProperty({ example: 8, description: 'NPS da campanha' })
147
- @Prop({ type: Number, required: false })
148
- nps?: number;
149
-
150
- @ApiProperty({ enum: ACTION_STATUS_VALUES, example: 'config' })
151
- @Prop({
152
- type: String,
153
- enum: ACTION_STATUS_VALUES,
154
- default: 'config',
155
- required: true,
156
- })
157
- status: ActionStatus;
158
-
159
- @ApiProperty({ enum: ['partner', 'exclusive'], example: 'partner' })
160
- @Prop({ type: String, enum: ['partner', 'exclusive'], required: true })
161
- partnership: 'partner' | 'exclusive';
162
-
163
- /** Ver ACTION_KIND_VALUES. organic: post aprovado numa Ação de produto sai dela (GD-699). */
164
- @ApiProperty({ enum: ACTION_KIND_VALUES, example: 'seeding' })
165
- @Prop({ type: String, enum: ACTION_KIND_VALUES, required: true })
166
- type: ActionKind;
167
-
168
- @ApiProperty({ example: ['instagram', 'tiktok'], required: false })
169
- @Prop({ type: [String], required: false })
170
- socialnetworks?: string[];
171
-
172
- @ApiProperty({ example: 50, description: 'Número de influenciadores recrutados' })
173
- @Prop({ type: Number, default: 0, required: false })
174
- recruitedInfluencers?: number;
175
-
176
- @ApiProperty({ example: 40, description: 'Número de influenciadores contratados' })
177
- @Prop({ type: Number, default: 0, required: false })
178
- hiredInfluencers?: number;
179
-
180
- @ApiProperty({ example: 100, description: 'Número de conteúdos produzidos' })
181
- @Prop({ type: Number, default: 0, required: false })
182
- producedContent?: number;
183
-
184
- @ApiProperty({ example: 80, description: 'Número de conteúdos contratados' })
185
- @Prop({ type: Number, default: 0, required: false })
186
- hiredContent?: number;
187
-
188
- @ApiProperty({ type: () => Client })
189
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Client', required: true })
190
- client: Types.ObjectId | Client;
191
-
192
- @ApiProperty({ type: () => [Recruitment], required: false })
193
- @Prop([
194
- {
195
- type: MongooseSchema.Types.ObjectId,
196
- ref: 'Recruitment',
197
- required: false,
198
- },
199
- ])
200
- recruitments?: Types.ObjectId[] | Recruitment[];
201
-
202
- @ApiProperty({ type: () => [Content], required: false })
203
- @Prop([
204
- {
205
- type: MongooseSchema.Types.ObjectId,
206
- ref: 'Content',
207
- required: false,
208
- },
209
- ])
210
- contents?: Types.ObjectId[] | Content[];
211
-
212
- @ApiProperty({ example: 'Cluster A' })
213
- @Prop({ type: String, required: true })
214
- cluster: string;
215
-
216
- @ApiProperty({ example: 'Shopping Center Norte', required: false })
217
- @Prop({ type: String, required: false })
218
- shopping?: string;
219
-
220
- @ApiProperty({ example: 'Projeto Verão 2025', required: false })
221
- @Prop({ type: String, required: false })
222
- project?: string;
223
-
224
- @ApiProperty({ type: () => Sale })
225
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Sale' })
226
- sale: Types.ObjectId | Sale;
227
-
228
- @Prop({ type: MongooseSchema.Types.ObjectId })
229
- organization: Types.ObjectId ;
230
-
231
- @ApiProperty({ type: () => [Responsible] })
232
- @Prop({ type: [ResponsibleSchema], required: true })
233
- responsible: Responsible[];
234
-
235
- @ApiProperty({ example: '@brand', required: false })
236
- @Prop({ type: String, required: false })
237
- brandUsername?: string;
238
-
239
- @ApiProperty({ example: '2025-08-29T15:00:00.000Z' })
240
- @Prop({ type: Date, default: Date.now, required: false })
241
- createdAt?: Date;
242
-
243
- @ApiProperty({ example: '2025-08-29T15:00:00.000Z' })
244
- @Prop({ type: Date, default: Date.now, required: false })
245
- updatedAt?: Date;
246
-
247
- @ApiProperty({ type: () => [Note], required: false })
248
- @Prop({ type: [NoteSchema], required: false })
249
- notes?: Note[];
250
-
251
- @ApiProperty({ example: '12345', required: false })
252
- @Prop({ type: String, required: false })
253
- primetagId?: string;
254
-
255
- /**
256
- * Liga a análise GenIA (comentários + classificação por IA) só pra esta
257
- * action, mesmo que o client dela não tenha `Client.hasGenIAAnalysis`.
258
- */
259
- @ApiProperty({ example: false, required: false })
260
- @Prop({ type: Boolean, required: false })
261
- hasGenIAAnalysis?: boolean;
262
-
263
- @ApiProperty({ example: ['#trending', '#viral'], required: false })
264
- @Prop({ type: [String], required: false })
265
- hashtags?: string[];
266
-
267
- @ApiProperty({ example: ['@influencer', '@brand'], required: false })
268
- @Prop({ type: [String], required: false })
269
- instagramMentions?: string[];
270
-
271
- @ApiProperty({ example: ['@influencer', '@brand'], required: false })
272
- @Prop({ type: [String], required: false })
273
- tiktokMentions?: string[];
274
-
275
- @ApiProperty({ example: ['produto', 'categoria'], required: false })
276
- @Prop({ type: [String], required: false })
277
- keywords?: string[];
278
-
279
- @Prop({ type: [{ type: MongooseSchema.Types.ObjectId }], required: false })
280
- tags?: Types.ObjectId[];
281
-
282
- @ApiProperty({ enum: ACTION_BUSINESS_UNIT_VALUES, required: false })
283
- @Prop({ type: String, enum: ACTION_BUSINESS_UNIT_VALUES, required: false })
284
- businessUnit?: ActionBusinessUnit;
285
-
286
- @ApiProperty({ type: () => Campaign, required: false })
287
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Campaign', required: false })
288
- campaign?: Types.ObjectId | Campaign;
289
-
290
- @ApiProperty({ type: () => ActionPromptConfig, required: false, description: 'Customização de prompts de classificação de comentário por IA para esta action — campos ausentes caem no prompt genérico default' })
291
- @Prop({ type: ActionPromptConfigSchema, required: false, default: null })
292
- promptConfig?: ActionPromptConfig | null;
293
-
294
- /**
295
- * Hashtags que marcam o Conteúdo como Orgânico (Tipo, fora do escopo
296
- * contratado). Normalizadas. Vazio = a captura não sugere Tipo. Ver GD-691.
297
- */
298
- @ApiProperty({ type: [String], required: false, example: ['galaxymoments'] })
299
- @Prop({ type: [String], default: [] })
300
- organicHashtags?: string[];
301
-
302
- /** Fases da Ação. Ver ActionPhase e GD-691. */
303
- @ApiProperty({ type: () => [ActionPhase], required: false })
304
- @Prop({ type: [ActionPhaseSchema], default: [] })
305
- phases?: ActionPhase[];
306
-
307
- /** Metas da Ação: mesmo { metric, value } e catálogo dos Tiers do cliente. Ver GD-691. */
308
- @ApiProperty({ type: () => [ClientMetricGoal], required: false })
309
- @Prop({ type: [ClientMetricGoalSchema], default: [] })
310
- goals?: ClientMetricGoal[];
311
-
312
- /** Fora dos relatórios do cliente no Hub (total de campanhas, lista e métricas). */
313
- @ApiProperty({ required: false, default: false })
314
- @Prop({ type: Boolean, default: false })
315
- hideFromReports?: boolean;
316
- }
317
-
318
- export const ActionSchema = SchemaFactory.createForClass(Action);
319
-
320
- ActionSchema.index({ organization: 1, status: 1 });
321
- ActionSchema.index({ organization: 1, client: 1 });
322
- ActionSchema.index({ organization: 1, sale: 1 });
323
- ActionSchema.index({ sale: 1 });
324
- ActionSchema.index({ organization: 1, startDate: 1, endDate: 1 });
325
- ActionSchema.index({ 'responsible.email': 1 });
326
- ActionSchema.index({ campaign: 1 });
327
-
328
- export const ActionModel = MongooseModel('Action', ActionSchema);
@@ -1,154 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { ApiProperty } from '@nestjs/swagger';
3
-
4
- import {
5
- HydratedDocument,
6
- Schema as MongooseSchema,
7
- Types,
8
- model as MongooseModel,
9
- } from 'mongoose';
10
-
11
- import { Action } from './action.schema';
12
- import { Responsible, ResponsibleSchema } from './responsible.schema';
13
-
14
- export type AssignmentDocument = HydratedDocument<Assignment>;
15
-
16
- export const ASSIGNMENT_TYPE_VALUES = [
17
- 'report',
18
- 'curation',
19
- 'opt-in',
20
- 'metrics-monitoring',
21
- 'data-update',
22
- 'study',
23
- ] as const;
24
- export type AssignmentType = (typeof ASSIGNMENT_TYPE_VALUES)[number];
25
-
26
- export const ASSIGNMENT_STATUS_VALUES = [
27
- 'todo',
28
- 'in-progress',
29
- 'waiting',
30
- 'review',
31
- 'done',
32
- 'paused',
33
- 'cancelled',
34
- 'deleted',
35
- ] as const;
36
- export type AssignmentStatus = (typeof ASSIGNMENT_STATUS_VALUES)[number];
37
-
38
- export const ASSIGNMENT_RECURRENCE_FREQUENCY_VALUES = [
39
- 'none',
40
- 'daily',
41
- 'weekly',
42
- 'biweekly',
43
- 'monthly',
44
- 'yearly',
45
- 'weekdays',
46
- 'custom',
47
- ] as const;
48
- export type AssignmentRecurrenceFrequency =
49
- (typeof ASSIGNMENT_RECURRENCE_FREQUENCY_VALUES)[number];
50
-
51
- @Schema({ _id: false })
52
- export class AssignmentRecurrence {
53
- @ApiProperty({ enum: ASSIGNMENT_RECURRENCE_FREQUENCY_VALUES, example: 'monthly' })
54
- @Prop({
55
- type: String,
56
- enum: ASSIGNMENT_RECURRENCE_FREQUENCY_VALUES,
57
- required: true,
58
- })
59
- frequency: AssignmentRecurrenceFrequency;
60
-
61
- @ApiProperty({ example: 1, required: false })
62
- @Prop({ type: Number, required: false })
63
- interval?: number;
64
-
65
- @ApiProperty({ example: [1, 3, 5], required: false })
66
- @Prop({ type: [Number], required: false })
67
- byWeekday?: number[];
68
-
69
- @ApiProperty({ example: '2026-12-31T00:00:00.000Z', required: false })
70
- @Prop({ type: Date, required: false })
71
- until?: Date;
72
-
73
- @ApiProperty({ example: 12, required: false })
74
- @Prop({ type: Number, required: false })
75
- occurrencesCount?: number;
76
- }
77
-
78
- export const AssignmentRecurrenceSchema = SchemaFactory.createForClass(
79
- AssignmentRecurrence,
80
- );
81
-
82
- @Schema({ timestamps: true })
83
- export class Assignment {
84
- @ApiProperty({ example: '64bfc3a78d3f1e2a12345670' })
85
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
86
- _id?: Types.ObjectId;
87
-
88
- @ApiProperty({ example: '64bfc3a78d3f1e2a12345678' })
89
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Action', required: true })
90
- action: Types.ObjectId | Action;
91
-
92
- @ApiProperty({ example: '64bfc3a78d3f1e2a12345679' })
93
- @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
94
- organization: Types.ObjectId;
95
-
96
- @ApiProperty({ enum: ASSIGNMENT_TYPE_VALUES, example: 'report' })
97
- @Prop({ type: String, enum: ASSIGNMENT_TYPE_VALUES, required: true })
98
- type: AssignmentType;
99
-
100
- @ApiProperty({ example: 'Relatório mensal de performance' })
101
- @Prop({ type: String, required: true })
102
- title: string;
103
-
104
- @ApiProperty({ type: () => [Responsible], required: false })
105
- @Prop({ type: [ResponsibleSchema], required: false, default: [] })
106
- responsible?: Responsible[];
107
-
108
- @ApiProperty({ example: '2026-08-25T00:00:00.000Z', required: false })
109
- @Prop({ type: Date, required: false, default: null })
110
- startDate?: Date | null;
111
-
112
- @ApiProperty({ example: '2026-09-01T00:00:00.000Z', required: false })
113
- @Prop({ type: Date, required: false, default: null })
114
- dueDate?: Date | null;
115
-
116
- @ApiProperty({ enum: ASSIGNMENT_STATUS_VALUES, example: 'todo' })
117
- @Prop({
118
- type: String,
119
- enum: ASSIGNMENT_STATUS_VALUES,
120
- default: 'todo',
121
- required: true,
122
- })
123
- status: AssignmentStatus;
124
-
125
- @ApiProperty({ type: () => AssignmentRecurrence, required: false })
126
- @Prop({ type: AssignmentRecurrenceSchema, required: false })
127
- recurrence?: AssignmentRecurrence;
128
-
129
- @ApiProperty({ example: '64bfc3a78d3f1e2a1234567b', required: false })
130
- @Prop({ type: MongooseSchema.Types.ObjectId, required: false })
131
- seriesId?: Types.ObjectId;
132
-
133
- @ApiProperty({ example: 'Aguardando retorno do cliente', required: false })
134
- @Prop({ type: String, required: false })
135
- notes?: string;
136
-
137
- @ApiProperty({ example: '2026-08-26T15:00:00.000Z' })
138
- @Prop({ type: Date, default: Date.now, required: false })
139
- createdAt?: Date;
140
-
141
- @ApiProperty({ example: '2026-08-26T15:00:00.000Z' })
142
- @Prop({ type: Date, default: Date.now, required: false })
143
- updatedAt?: Date;
144
- }
145
-
146
- export const AssignmentSchema = SchemaFactory.createForClass(Assignment);
147
-
148
- AssignmentSchema.index({ action: 1 });
149
- AssignmentSchema.index({ organization: 1, status: 1 });
150
- AssignmentSchema.index({ organization: 1, dueDate: 1 });
151
- AssignmentSchema.index({ seriesId: 1 });
152
- AssignmentSchema.index({ 'responsible.email': 1, dueDate: 1 });
153
-
154
- export const AssignmentModel = MongooseModel('Assignment', AssignmentSchema);
@@ -1,39 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { HydratedDocument, Schema as MongooseSchema, Types, model as MongooseModel } from 'mongoose';
3
- import { Client } from './client.schema';
4
-
5
- /** Métrica do benchmark, com nomes por extenso (GD-751). */
6
- export const BENCHMARK_METRIC_VALUES = ['reach', 'engagementRate', 'costPerThousandImpressions', 'costPerEngagement'] as const;
7
- export type BenchmarkMetric = (typeof BENCHMARK_METRIC_VALUES)[number];
8
- export type BenchmarkMode = 'organic' | 'paid';
9
- export type BenchmarkDocument = HydratedDocument<Benchmark>;
10
-
11
- @Schema({ timestamps: true })
12
- export class Benchmark {
13
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
14
- _id?: Types.ObjectId;
15
-
16
- @Prop({ type: String, required: true })
17
- format: string;
18
-
19
- @Prop({ type: String, enum: ['organic', 'paid'], required: true })
20
- mode: BenchmarkMode;
21
-
22
- @Prop({ type: String, enum: BENCHMARK_METRIC_VALUES, required: true })
23
- metric: BenchmarkMetric;
24
-
25
- @Prop({ type: Number, required: true })
26
- bad: number;
27
-
28
- @Prop({ type: Number, required: true })
29
- good: number;
30
-
31
- @Prop({ type: Boolean, required: true })
32
- inverted: boolean;
33
-
34
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Client', required: false })
35
- client?: Types.ObjectId | Client;
36
- }
37
-
38
- export const BenchmarkSchema = SchemaFactory.createForClass(Benchmark);
39
- export const BenchmarkModel = MongooseModel('Benchmark', BenchmarkSchema);
@@ -1,38 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { HydratedDocument, Schema as MongooseSchema, Types, model as MongooseModel } from 'mongoose';
3
- import { Client } from './client.schema';
4
-
5
- export type CampaignDocument = HydratedDocument<Campaign>;
6
-
7
- @Schema({ timestamps: true })
8
- export class Campaign {
9
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
10
- _id?: Types.ObjectId;
11
-
12
- @Prop()
13
- title: string;
14
-
15
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Client' })
16
- client: Types.ObjectId | Client;
17
-
18
- @Prop({ default: Date.now, required: false })
19
- createdAt?: Date;
20
-
21
- @Prop({ default: Date.now, required: false })
22
- updatedAt?: Date;
23
-
24
- @Prop({ required: false })
25
- description?: string;
26
-
27
- @Prop({ required: false })
28
- startDate?: Date;
29
-
30
- @Prop({ required: false })
31
- endDate?: Date;
32
- }
33
-
34
- export const CampaignSchema = SchemaFactory.createForClass(Campaign);
35
-
36
- CampaignSchema.index({ client: 1 });
37
-
38
- export const CampaignModel = MongooseModel('Campaign', CampaignSchema);