@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,164 +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
- import { Sale } from './sale.schema';
11
- import { Note } from './note.schema';
12
-
13
- export type InvoiceDocument = HydratedDocument<Invoice>;
14
-
15
- @Schema({ _id: false })
16
- class Recipient {
17
- @ApiProperty({ example: 'nome da empresa LTDA' })
18
- @Prop({ required: true }) legalName: string;
19
-
20
- @ApiProperty({ example: 'xx.xxx.xxx/xxxx-xx' })
21
- @Prop({ required: true }) document: string;
22
- }
23
-
24
- @Schema({ _id: false })
25
- class Inbox {
26
- @ApiProperty({ example: 'CNPJ da Marca que foi selecionado para o faturamento' })
27
- @Prop() document?: string;
28
-
29
- @ApiProperty({ example: 'Razão Social da Marca que foi selecionado para o faturamento' })
30
- @Prop() legalName?: string;
31
-
32
- @ApiProperty({ example: 'Descrição que deve contar na nota fiscal referente à prestação de serviços' })
33
- @Prop() invoiceDescription?: string;
34
-
35
- @ApiProperty({ example: 'Descrição que deve contar na nota fiscal referente ao influenciador' })
36
- @Prop() influencerInvoiceDescription?: string;
37
-
38
- @ApiProperty({ example: 'financeiro@empresa.com' })
39
- @Prop() invoiceEmail?: string;
40
-
41
- @ApiProperty({ example: 'Emitir até 5 dias úteis após a entrega' })
42
- @Prop() emissionNotes?: string;
43
-
44
- @ApiProperty({ type: () => Recipient })
45
- @Prop({ type: Recipient }) recipient?: Recipient;
46
-
47
- @ApiProperty({ example: 10000 })
48
- @Prop({ required: true }) installmentGrossIncomeValue: number;
49
-
50
- @ApiProperty({ example: 8500 })
51
- @Prop({ required: true }) installmentRevenue: number;
52
-
53
- @ApiProperty({ example: 3000 })
54
- @Prop({ required: true }) installmentInfluencerBroadcastValue: number;
55
-
56
- @ApiProperty({ example: 2000 })
57
- @Prop({ required: true }) installmentProductionAndOthersValue: number;
58
-
59
- @ApiProperty({ example: '2025-09-10T00:00:00.000Z' })
60
- @Prop({ required: true }) estimatedIssueDate: Date;
61
-
62
- @ApiProperty({ example: '2025-09-25T00:00:00.000Z' })
63
- @Prop({ required: true }) estimatedDueDate: Date;
64
- }
65
-
66
- @Schema({ _id: false })
67
- class Review {
68
- @ApiProperty({ example: '2025-09-12T00:00:00.000Z' })
69
- @Prop({ required: true }) revisedIssueDate: Date;
70
-
71
- @ApiProperty({ example: '2025-09-28T00:00:00.000Z' })
72
- @Prop({ required: true }) revisedDueDate: Date;
73
- }
74
-
75
- @Schema({ _id: false })
76
- class Invoiced {
77
- @ApiProperty({ example: 'NF123456' })
78
- @Prop({ required: true }) code: string;
79
-
80
- @ApiProperty({ example: '2025-09-15T00:00:00.000Z' })
81
- @Prop({ required: true }) issueDate: Date;
82
-
83
- @ApiProperty({ example: '2025-09-30T00:00:00.000Z' })
84
- @Prop({ required: true }) dueDate: Date;
85
- }
86
-
87
- @Schema({ _id: false })
88
- class Received {
89
- @ApiProperty({ example: '2025-10-05T00:00:00.000Z' })
90
- @Prop({ required: true }) date: Date;
91
- }
92
-
93
- @Schema({ _id: false })
94
- class Canceled {
95
- @ApiProperty({ example: 'Cliente cancelou o contrato' })
96
- @Prop({ required: true }) reason: string;
97
-
98
- @ApiProperty({ example: 'Cancelamento solicitado via e-mail em 25/08/2025' })
99
- @Prop({ required: true }) details: string;
100
- }
101
-
102
- @Schema({ timestamps: true })
103
- export class Invoice {
104
- @ApiProperty({ example: '64f1a5c8c7e4d5a6b2e9f123' })
105
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
106
- _id?: Types.ObjectId;
107
-
108
- @ApiProperty({ example: 'Fatura Parcela 01/03' })
109
- @Prop({ required: true }) title: string;
110
-
111
- @ApiProperty({ example: 1 })
112
- @Prop({ required: true }) installmentNumber: number;
113
-
114
- @ApiProperty({ example: 'inbox', enum: ['inbox', 'review', 'awaiting', 'invoiced', 'received', 'canceled'] })
115
- @Prop({
116
- required: true,
117
- enum: ['inbox', 'review', 'awaiting', 'invoiced', 'received', 'canceled'],
118
- })
119
- phase: 'inbox' | 'review' | 'awaiting' | 'invoiced' | 'received' | 'canceled';
120
-
121
- @ApiProperty({ example: '64f1a5c8c7e4d5a6b2e9f999' })
122
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Sale', required: true })
123
- sale: Types.ObjectId | Sale;
124
-
125
- @Prop({ type: MongooseSchema.Types.ObjectId })
126
- organization: Types.ObjectId ;
127
-
128
- @ApiProperty({ type: () => Inbox })
129
- @Prop({ type: Inbox }) inbox?: Inbox;
130
-
131
- @ApiProperty({ type: () => Review })
132
- @Prop({ type: Review }) review?: Review;
133
-
134
- @ApiProperty({ type: () => Invoiced })
135
- @Prop({ type: Invoiced }) invoiced?: Invoiced;
136
-
137
- @ApiProperty({ type: () => Received })
138
- @Prop({ type: Received }) received?: Received;
139
-
140
- @ApiProperty({ type: () => Canceled })
141
- @Prop({ type: Canceled }) canceled?: Canceled;
142
-
143
- @ApiProperty({ type: [Note], example: [{ text: 'Emitir NF', owner: 'maria.joaquina', createdAt: '2025-08-28T15:00:00.000Z' }] })
144
- @Prop({ type: [Note], default: [] }) notes?: Note[];
145
-
146
- @ApiProperty({ example: ['Aguardando Faturamento', 'Janeiro'] })
147
- @Prop({ type: [{ type: MongooseSchema.Types.ObjectId }], default: [] }) tags?: Types.ObjectId[];
148
-
149
- @ApiProperty({ example: '2025-08-28T15:00:00.000Z' })
150
- @Prop({ default: Date.now }) createdAt?: Date;
151
-
152
- @ApiProperty({ example: '2025-08-28T15:00:00.000Z' })
153
- @Prop({ default: Date.now }) updatedAt?: Date;
154
- }
155
-
156
- export const InvoiceSchema = SchemaFactory.createForClass(Invoice);
157
-
158
- InvoiceSchema.index({ organization: 1, phase: 1 });
159
- InvoiceSchema.index({ organization: 1, 'invoiced.issueDate': 1 });
160
- InvoiceSchema.index({ sale: 1, installmentNumber: 1 });
161
- InvoiceSchema.index({ sale: 1, phase: 1 });
162
- InvoiceSchema.index({ tags: 1 });
163
-
164
- export const InvoiceModel = MongooseModel('Invoice', InvoiceSchema);
@@ -1,111 +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
- import { Action } from './action.schema';
9
-
10
- export type JobDocument = HydratedDocument<Job>;
11
-
12
- // tagger: import do JSON da Tagger na tela (GD-767).
13
- export const JOB_ORIGINS = ['trigger', 'approval', 'reclassify', 'tagger'] as const;
14
- export type JobOrigin = (typeof JOB_ORIGINS)[number];
15
-
16
- export const JOB_WORKERS = [
17
- // Clique de aprovação (lote): quantos conteúdos o disparo colocou no pipeline.
18
- 'api-campaigns',
19
- 'content-capture-trigger',
20
- 'content-capture',
21
- 'comment-capture',
22
- 'content-classification',
23
- 'metrics-generator',
24
- 'profile-sync',
25
- ] as const;
26
- export type JobWorker = (typeof JOB_WORKERS)[number];
27
-
28
- // running: trabalho em andamento com checkpoint (ex.: job assíncrono da
29
- // exportcomments em criação/polling).
30
- export const JOB_STATUSES = ['running', 'done', 'skipped', 'error'] as const;
31
- export type JobStatus = (typeof JOB_STATUSES)[number];
32
-
33
- /**
34
- * Trilha única do pipeline de captura: cada worker grava uma linha por
35
- * unidade de trabalho (action ou content), e todas as linhas da mesma rodada
36
- * compartilham o `runId` gerado pelo content-capture-trigger. `requestId`
37
- * separa cada disparo dentro de um `runId` — na captura é igual ao `runId`;
38
- * na aprovação/reclassificação a api-campaigns gera um por clique. `input` é
39
- * o payload recebido, `response` o que veio de fora (Primetag, exportcomments,
40
- * OpenAI) e `result` o que o worker decidiu ou gravou.
41
- */
42
- @Schema({ collection: 'jobs', timestamps: true })
43
- export class Job {
44
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
45
- _id?: Types.ObjectId;
46
-
47
- @Prop({ type: String, required: true })
48
- runId: string;
49
-
50
- @Prop({ type: String, required: true })
51
- requestId: string;
52
-
53
- @Prop({ type: String, enum: JOB_ORIGINS, required: true })
54
- origin: JobOrigin;
55
-
56
- @Prop({ type: String, enum: JOB_WORKERS, required: true })
57
- worker: JobWorker;
58
-
59
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Action', required: true })
60
- actionId: Types.ObjectId | Action;
61
-
62
- @Prop({ type: MongooseSchema.Types.ObjectId, required: false })
63
- contentId?: Types.ObjectId;
64
-
65
- @Prop({ type: String, required: false })
66
- primetagId?: string;
67
-
68
- @Prop({ type: String, enum: JOB_STATUSES, required: true })
69
- status: JobStatus;
70
-
71
- @Prop({ type: MongooseSchema.Types.Mixed, required: false })
72
- input?: unknown;
73
-
74
- @Prop({ type: MongooseSchema.Types.Mixed, required: false })
75
- response?: unknown;
76
-
77
- @Prop({ type: MongooseSchema.Types.Mixed, required: false })
78
- result?: unknown;
79
-
80
- @Prop({ type: String, required: false })
81
- error?: string;
82
-
83
- @Prop({ type: Date, required: true, default: Date.now })
84
- startedAt: Date;
85
-
86
- @Prop({ type: Date, required: false })
87
- finishedAt?: Date;
88
-
89
- @Prop({ default: Date.now, required: false })
90
- createdAt?: Date;
91
-
92
- @Prop({ default: Date.now, required: false })
93
- updatedAt?: Date;
94
- }
95
-
96
- export const JobSchema = SchemaFactory.createForClass(Job);
97
-
98
- // Reentrega da mesma mensagem atualiza a mesma linha.
99
- JobSchema.index(
100
- { runId: 1, requestId: 1, worker: 1, contentId: 1, primetagId: 1 },
101
- { unique: true },
102
- );
103
- // Trava do trigger: última rodada de uma action.
104
- JobSchema.index({ actionId: 1, worker: 1, origin: 1, startedAt: -1 });
105
- // A trilha guarda o payload bruto de cada rodada e cresce rápido: o Mongo
106
- // apaga sozinho as linhas com mais de 180 dias.
107
- JobSchema.index({ createdAt: 1 }, { expireAfterSeconds: 180 * 24 * 60 * 60 });
108
- // Raw mais recente de uma publication (linhas do content-capture).
109
- JobSchema.index({ actionId: 1, worker: 1, primetagId: 1, startedAt: -1 });
110
-
111
- export const JobModel = MongooseModel('Job', JobSchema);
@@ -1,372 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { HydratedDocument, Types, model as MongooseModel } from 'mongoose';
3
-
4
- // Lead = briefing de campanha preenchido pelo cliente numa página pública (GD-616).
5
- // O acesso público é sempre pelo accessToken, nunca pelo _id.
6
-
7
- export const LEAD_STATUS_VALUES = ['draft', 'submitted'] as const;
8
- export type LeadStatus = (typeof LEAD_STATUS_VALUES)[number];
9
-
10
- export const LEAD_PRESENTATION_FORMAT_VALUES = ['online', 'in_person', 'email_only'] as const;
11
- export type LeadPresentationFormat = (typeof LEAD_PRESENTATION_FORMAT_VALUES)[number];
12
-
13
- export const LEAD_PAYMENT_TERM_VALUES = [30, 60, 90, 120] as const;
14
- export type LeadPaymentTerm = (typeof LEAD_PAYMENT_TERM_VALUES)[number];
15
-
16
- export const LEAD_BILLING_MODEL_VALUES = [
17
- 'transfer',
18
- 'double_taxation',
19
- 'direct_payment',
20
- ] as const;
21
- export type LeadBillingModel = (typeof LEAD_BILLING_MODEL_VALUES)[number];
22
-
23
- export const LEAD_DELIVERABLE_VALUES = [
24
- 'content_strategy',
25
- 'ppt_presentation',
26
- 'curation_sheet',
27
- 'production_sheet',
28
- ] as const;
29
- export type LeadDeliverable = (typeof LEAD_DELIVERABLE_VALUES)[number];
30
-
31
- export const LEAD_GOAL_VALUES = ['awareness', 'consideration', 'intent'] as const;
32
- export type LeadGoal = (typeof LEAD_GOAL_VALUES)[number];
33
-
34
- export const LEAD_CHANNEL_VALUES = ['online', 'offline'] as const;
35
- export type LeadChannel = (typeof LEAD_CHANNEL_VALUES)[number];
36
-
37
- export const LEAD_RIGHT_VALUES = [
38
- 'influencer_collab',
39
- 'brand_collab',
40
- 'client_boost',
41
- 'influencer_boost',
42
- 'segment_exclusivity',
43
- 'image_rights',
44
- 'dark_post',
45
- 'offline',
46
- ] as const;
47
- export type LeadRight = (typeof LEAD_RIGHT_VALUES)[number];
48
-
49
- export const LEAD_FOLLOWER_TIER_VALUES = ['heroes', 'macros', 'medios', 'micros', 'nanos', 'nda'] as const;
50
- export type LeadFollowerTier = (typeof LEAD_FOLLOWER_TIER_VALUES)[number];
51
-
52
- export const LEAD_SECTION_KEYS = [
53
- 'general',
54
- 'confidentiality',
55
- 'budget',
56
- 'competition',
57
- 'deliverables',
58
- 'strategicContext',
59
- 'objectives',
60
- 'deliveryScope',
61
- 'audience',
62
- 'curation',
63
- 'logistics',
64
- 'contentGuidelines',
65
- ] as const;
66
- export type LeadSectionKey = (typeof LEAD_SECTION_KEYS)[number];
67
-
68
- @Schema({ _id: false })
69
- export class LeadGeneral {
70
- @Prop({ trim: true })
71
- advertiser?: string;
72
-
73
- @Prop({ trim: true })
74
- brand?: string;
75
-
76
- @Prop()
77
- socialProfiles?: string;
78
-
79
- @Prop({ trim: true })
80
- campaignName?: string;
81
-
82
- @Prop()
83
- language?: string;
84
-
85
- @Prop()
86
- materialsUrl?: string;
87
-
88
- @Prop()
89
- presentationDate?: Date;
90
-
91
- @Prop()
92
- schedule?: string;
93
-
94
- @Prop({ type: String, enum: LEAD_PRESENTATION_FORMAT_VALUES })
95
- presentationFormat?: LeadPresentationFormat;
96
-
97
- @Prop({ trim: true })
98
- contactName?: string;
99
-
100
- @Prop({ trim: true, lowercase: true })
101
- contactEmail?: string;
102
- }
103
- export const LeadGeneralSchema = SchemaFactory.createForClass(LeadGeneral);
104
-
105
- @Schema({ _id: false })
106
- export class LeadConfidentiality {
107
- @Prop()
108
- hasRestriction?: boolean;
109
-
110
- @Prop()
111
- restrictionDetails?: string;
112
- }
113
- export const LeadConfidentialitySchema = SchemaFactory.createForClass(LeadConfidentiality);
114
-
115
- @Schema({ _id: false })
116
- export class LeadBudget {
117
- @Prop()
118
- totalBudget?: number;
119
-
120
- @Prop()
121
- creatorsBudget?: number;
122
-
123
- @Prop({ type: Number, enum: LEAD_PAYMENT_TERM_VALUES })
124
- paymentTerm?: LeadPaymentTerm;
125
-
126
- @Prop({ type: String, enum: LEAD_BILLING_MODEL_VALUES })
127
- billingModel?: LeadBillingModel;
128
-
129
- @Prop()
130
- campaignDurationMonths?: number;
131
- }
132
- export const LeadBudgetSchema = SchemaFactory.createForClass(LeadBudget);
133
-
134
- @Schema({ _id: false })
135
- export class LeadCompetition {
136
- @Prop()
137
- isCompetitive?: boolean;
138
-
139
- @Prop()
140
- involveAreaLeaders?: boolean;
141
- }
142
- export const LeadCompetitionSchema = SchemaFactory.createForClass(LeadCompetition);
143
-
144
- @Schema({ _id: false })
145
- export class LeadDeliverables {
146
- @Prop({ type: [String], enum: LEAD_DELIVERABLE_VALUES, default: undefined })
147
- types?: LeadDeliverable[];
148
- }
149
- export const LeadDeliverablesSchema = SchemaFactory.createForClass(LeadDeliverables);
150
-
151
- @Schema({ _id: false })
152
- export class LeadStrategicContext {
153
- @Prop()
154
- brandScenario?: string;
155
-
156
- @Prop()
157
- productInfo?: string;
158
-
159
- @Prop()
160
- parentCampaign?: string;
161
-
162
- @Prop()
163
- message?: string;
164
-
165
- @Prop()
166
- callToAction?: string;
167
-
168
- @Prop()
169
- highlights?: string;
170
-
171
- @Prop()
172
- centralChallenge?: string;
173
-
174
- @Prop()
175
- tone?: string;
176
- }
177
- export const LeadStrategicContextSchema = SchemaFactory.createForClass(LeadStrategicContext);
178
-
179
- @Schema({ _id: false })
180
- export class LeadObjectives {
181
- @Prop({ type: [String], enum: LEAD_GOAL_VALUES, default: undefined })
182
- goals?: LeadGoal[];
183
-
184
- @Prop({ type: String, enum: LEAD_GOAL_VALUES })
185
- primaryGoal?: LeadGoal;
186
- }
187
- export const LeadObjectivesSchema = SchemaFactory.createForClass(LeadObjectives);
188
-
189
- @Schema({ _id: false })
190
- export class LeadDeliveryScope {
191
- @Prop({ type: [String], enum: LEAD_CHANNEL_VALUES, default: undefined })
192
- channels?: LeadChannel[];
193
-
194
- @Prop()
195
- primaryNetworks?: string;
196
-
197
- @Prop()
198
- secondaryNetworks?: string;
199
-
200
- @Prop()
201
- contentPerNetwork?: string;
202
-
203
- @Prop({ type: [String], enum: LEAD_RIGHT_VALUES, default: undefined })
204
- rights?: LeadRight[];
205
-
206
- @Prop()
207
- imageRightsMonths?: number;
208
-
209
- @Prop()
210
- offlineFormats?: string;
211
- }
212
- export const LeadDeliveryScopeSchema = SchemaFactory.createForClass(LeadDeliveryScope);
213
-
214
- @Schema({ _id: false })
215
- export class LeadAudience {
216
- @Prop()
217
- ageRange?: string;
218
-
219
- @Prop()
220
- gender?: string;
221
-
222
- @Prop()
223
- region?: string;
224
-
225
- @Prop()
226
- attitudinalProfile?: string;
227
- }
228
- export const LeadAudienceSchema = SchemaFactory.createForClass(LeadAudience);
229
-
230
- @Schema({ _id: false })
231
- export class LeadCuration {
232
- @Prop()
233
- influencerProfile?: string;
234
-
235
- @Prop()
236
- referenceNames?: string;
237
-
238
- @Prop()
239
- namesToAvoid?: string;
240
-
241
- @Prop()
242
- approveCount?: number;
243
-
244
- @Prop()
245
- analyzeCount?: number;
246
-
247
- @Prop({ type: [String], enum: LEAD_FOLLOWER_TIER_VALUES, default: undefined })
248
- followerTiers?: LeadFollowerTier[];
249
-
250
- @Prop()
251
- competitorBrands?: string;
252
-
253
- @Prop()
254
- competitorCheckPeriod?: string;
255
-
256
- @Prop()
257
- requirements?: string;
258
- }
259
- export const LeadCurationSchema = SchemaFactory.createForClass(LeadCuration);
260
-
261
- @Schema({ _id: false })
262
- export class LeadLogistics {
263
- @Prop()
264
- productShipping?: string;
265
-
266
- @Prop()
267
- eventPresence?: string;
268
-
269
- @Prop()
270
- otherLogistics?: string;
271
- }
272
- export const LeadLogisticsSchema = SchemaFactory.createForClass(LeadLogistics);
273
-
274
- @Schema({ _id: false })
275
- export class LeadContentGuidelines {
276
- @Prop()
277
- productionRequirements?: string;
278
-
279
- @Prop()
280
- dos?: string;
281
-
282
- @Prop()
283
- donts?: string;
284
-
285
- @Prop()
286
- mandatoryWords?: string;
287
-
288
- @Prop()
289
- forbiddenTopics?: string;
290
-
291
- @Prop()
292
- forbiddenWords?: string;
293
-
294
- @Prop()
295
- creatorMessage?: string;
296
-
297
- @Prop()
298
- additionalDirections?: string;
299
- }
300
- export const LeadContentGuidelinesSchema = SchemaFactory.createForClass(LeadContentGuidelines);
301
-
302
- export type LeadDocument = HydratedDocument<Lead>;
303
-
304
- @Schema({ timestamps: true, collection: 'leads' })
305
- export class Lead {
306
- // select: false para o token nunca sair numa consulta sem pedir explicitamente.
307
- @Prop({ required: true, unique: true, select: false })
308
- accessToken: string;
309
-
310
- @Prop({ type: String, enum: LEAD_STATUS_VALUES, default: 'draft', index: true })
311
- status: LeadStatus;
312
-
313
- @Prop({ type: Types.ObjectId, ref: 'Organization', required: true })
314
- organization: Types.ObjectId;
315
-
316
- @Prop()
317
- submittedAt?: Date;
318
-
319
- @Prop({ index: true })
320
- lastEditedAt?: Date;
321
-
322
- /**
323
- * Data de exclusão lógica (soft delete).
324
- * Mantém o registro no banco de dados para fins de auditoria/histórico,
325
- * mas deve ser desconsiderado nas consultas padrão (`deletedAt: null`).
326
- */
327
- @Prop({ index: true })
328
- deletedAt?: Date;
329
-
330
- @Prop({ type: LeadGeneralSchema, default: {} })
331
- general: LeadGeneral;
332
-
333
- @Prop({ type: LeadConfidentialitySchema, default: {} })
334
- confidentiality: LeadConfidentiality;
335
-
336
- @Prop({ type: LeadBudgetSchema, default: {} })
337
- budget: LeadBudget;
338
-
339
- @Prop({ type: LeadCompetitionSchema, default: {} })
340
- competition: LeadCompetition;
341
-
342
- @Prop({ type: LeadDeliverablesSchema, default: {} })
343
- deliverables: LeadDeliverables;
344
-
345
- @Prop({ type: LeadStrategicContextSchema, default: {} })
346
- strategicContext: LeadStrategicContext;
347
-
348
- @Prop({ type: LeadObjectivesSchema, default: {} })
349
- objectives: LeadObjectives;
350
-
351
- @Prop({ type: LeadDeliveryScopeSchema, default: {} })
352
- deliveryScope: LeadDeliveryScope;
353
-
354
- @Prop({ type: LeadAudienceSchema, default: {} })
355
- audience: LeadAudience;
356
-
357
- @Prop({ type: LeadCurationSchema, default: {} })
358
- curation: LeadCuration;
359
-
360
- @Prop({ type: LeadLogisticsSchema, default: {} })
361
- logistics: LeadLogistics;
362
-
363
- @Prop({ type: LeadContentGuidelinesSchema, default: {} })
364
- contentGuidelines: LeadContentGuidelines;
365
-
366
- createdAt?: Date;
367
- updatedAt?: Date;
368
- }
369
-
370
- export const LeadSchema = SchemaFactory.createForClass(Lead);
371
-
372
- export const LeadModel = MongooseModel('Lead', LeadSchema);