@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.
- package/dist/index.d.ts +42 -42
- package/dist/schemas/action.schema.d.ts +13 -38
- package/dist/schemas/action.schema.js +81 -64
- package/dist/schemas/assignment.schema.d.ts +6 -31
- package/dist/schemas/assignment.schema.js +44 -44
- package/dist/schemas/benchmark.schema.d.ts +5 -30
- package/dist/schemas/benchmark.schema.js +11 -6
- package/dist/schemas/campaign.schema.d.ts +4 -29
- package/dist/schemas/campaign.schema.js +4 -4
- package/dist/schemas/client.schema.d.ts +30 -91
- package/dist/schemas/client.schema.js +73 -71
- package/dist/schemas/comment.schema.d.ts +9 -34
- package/dist/schemas/comment.schema.js +42 -37
- package/dist/schemas/commission.schema.d.ts +7 -32
- package/dist/schemas/commission.schema.js +10 -10
- package/dist/schemas/content-capture-process.schema.d.ts +12 -37
- package/dist/schemas/content-capture-process.schema.js +24 -17
- package/dist/schemas/content-draft.schema.d.ts +4 -29
- package/dist/schemas/content-draft.schema.js +5 -5
- package/dist/schemas/content.schema.d.ts +20 -45
- package/dist/schemas/content.schema.js +84 -74
- package/dist/schemas/contract.schema.d.ts +5 -30
- package/dist/schemas/contract.schema.js +5 -5
- package/dist/schemas/creative.schema.d.ts +11 -36
- package/dist/schemas/creative.schema.js +22 -31
- package/dist/schemas/export-comments-job.schema.d.ts +4 -29
- package/dist/schemas/export-comments-job.schema.js +6 -6
- package/dist/schemas/group.schema.d.ts +2 -27
- package/dist/schemas/group.schema.js +5 -5
- package/dist/schemas/influencer.schema.d.ts +12 -37
- package/dist/schemas/influencer.schema.js +16 -18
- package/dist/schemas/invoice.schema.d.ts +6 -31
- package/dist/schemas/invoice.schema.js +42 -32
- package/dist/schemas/job.schema.d.ts +4 -29
- package/dist/schemas/job.schema.js +14 -14
- package/dist/schemas/lead.schema.d.ts +15 -40
- package/dist/schemas/lead.schema.js +67 -64
- package/dist/schemas/log.schema.d.ts +3 -28
- package/dist/schemas/log.schema.js +24 -24
- package/dist/schemas/note.schema.d.ts +3 -28
- package/dist/schemas/note.schema.js +9 -9
- package/dist/schemas/notifications.schema.d.ts +3 -28
- package/dist/schemas/notifications.schema.js +8 -8
- package/dist/schemas/organization.schema.d.ts +2 -27
- package/dist/schemas/organization.schema.js +4 -4
- package/dist/schemas/party.schema.d.ts +6 -31
- package/dist/schemas/party.schema.js +11 -11
- package/dist/schemas/payment.schema.d.ts +20 -45
- package/dist/schemas/payment.schema.js +63 -54
- package/dist/schemas/profile.schema.d.ts +5 -30
- package/dist/schemas/profile.schema.js +6 -6
- package/dist/schemas/project.schema.d.ts +9 -34
- package/dist/schemas/project.schema.js +13 -13
- package/dist/schemas/prospect.schema.d.ts +6 -31
- package/dist/schemas/prospect.schema.js +9 -9
- package/dist/schemas/recruitment.schema.d.ts +19 -44
- package/dist/schemas/recruitment.schema.js +36 -36
- package/dist/schemas/responsible.schema.d.ts +1 -27
- package/dist/schemas/responsible.schema.js +6 -6
- package/dist/schemas/sale.schema.d.ts +19 -44
- package/dist/schemas/sale.schema.js +43 -51
- package/dist/schemas/script.schema.d.ts +11 -36
- package/dist/schemas/script.schema.js +21 -30
- package/dist/schemas/snapshot.schema.d.ts +5 -30
- package/dist/schemas/snapshot.schema.js +6 -6
- package/dist/schemas/store-visit.schema.d.ts +3 -28
- package/dist/schemas/store-visit.schema.js +21 -17
- package/dist/schemas/store.schema.d.ts +5 -30
- package/dist/schemas/store.schema.js +8 -8
- package/dist/schemas/supplier.schema.d.ts +4 -29
- package/dist/schemas/supplier.schema.js +3 -3
- package/dist/schemas/tag.schema.d.ts +2 -27
- package/dist/schemas/tag.schema.js +5 -5
- package/dist/schemas/task.schema.d.ts +11 -36
- package/dist/schemas/task.schema.js +67 -67
- package/dist/schemas/token.schema.d.ts +3 -28
- package/dist/schemas/token.schema.js +3 -3
- package/dist/schemas/trigger.schema.d.ts +3 -28
- package/dist/schemas/trigger.schema.js +5 -5
- package/dist/schemas/user.schema.d.ts +3 -28
- package/dist/schemas/user.schema.js +7 -7
- package/dist/schemas/webhook.schema.d.ts +6 -31
- package/dist/schemas/webhook.schema.js +10 -10
- package/dist/utils/merge-metrics-breakdown.util.d.ts +1 -1
- package/dist/utils/merge-metrics-breakdown.util.js +7 -2
- package/dist/utils/normalize-content-link.util.js +7 -7
- package/package.json +29 -16
- package/.eslintrc.json +0 -28
- package/.prettierrc +0 -4
- package/dist/schemas/profile-followers-snapshot.schema.d.ts +0 -67
- package/dist/schemas/profile-followers-snapshot.schema.js +0 -65
- package/dist/schemas/schedule.schema.d.ts +0 -73
- package/dist/schemas/schedule.schema.js +0 -116
- package/dist/utils/cost-per-impact.util.d.ts +0 -37
- package/dist/utils/cost-per-impact.util.js +0 -72
- package/dist/utils/influencer-contract.util.d.ts +0 -32
- package/dist/utils/influencer-contract.util.js +0 -77
- package/docs/code-review.md +0 -27
- package/docs/constitution.md +0 -75
- package/docs/specs/GD-692.md +0 -112
- package/docs/specs/GD-761.md +0 -94
- package/index.d.ts +0 -3
- package/src/index.ts +0 -42
- package/src/schemas/action.schema.ts +0 -328
- package/src/schemas/assignment.schema.ts +0 -154
- package/src/schemas/benchmark.schema.ts +0 -39
- package/src/schemas/campaign.schema.ts +0 -38
- package/src/schemas/client.schema.ts +0 -319
- package/src/schemas/comment.schema.ts +0 -216
- package/src/schemas/commission.schema.ts +0 -108
- package/src/schemas/content-capture-process.schema.ts +0 -195
- package/src/schemas/content-draft.schema.ts +0 -49
- package/src/schemas/content.schema.ts +0 -688
- package/src/schemas/contract.schema.ts +0 -44
- package/src/schemas/creative.schema.ts +0 -256
- package/src/schemas/export-comments-job.schema.ts +0 -59
- package/src/schemas/group.schema.ts +0 -23
- package/src/schemas/influencer.schema.ts +0 -184
- package/src/schemas/invoice.schema.ts +0 -164
- package/src/schemas/job.schema.ts +0 -111
- package/src/schemas/lead.schema.ts +0 -372
- package/src/schemas/log.schema.ts +0 -91
- package/src/schemas/note.schema.ts +0 -34
- package/src/schemas/notifications.schema.ts +0 -61
- package/src/schemas/organization.schema.ts +0 -29
- package/src/schemas/party.schema.ts +0 -65
- package/src/schemas/payment.schema.ts +0 -275
- package/src/schemas/profile.schema.ts +0 -77
- package/src/schemas/project.schema.ts +0 -116
- package/src/schemas/prospect.schema.ts +0 -62
- package/src/schemas/recruitment.schema.ts +0 -277
- package/src/schemas/responsible.schema.ts +0 -27
- package/src/schemas/sale.schema.ts +0 -297
- package/src/schemas/script.schema.ts +0 -235
- package/src/schemas/snapshot.schema.ts +0 -55
- package/src/schemas/store-visit.schema.ts +0 -68
- package/src/schemas/store.schema.ts +0 -52
- package/src/schemas/supplier.schema.ts +0 -12
- package/src/schemas/tag.schema.ts +0 -26
- package/src/schemas/task.schema.ts +0 -205
- package/src/schemas/token.schema.ts +0 -42
- package/src/schemas/trigger.schema.ts +0 -48
- package/src/schemas/user.schema.ts +0 -59
- package/src/schemas/webhook.schema.ts +0 -81
- package/src/utils/merge-metrics-breakdown.util.ts +0 -51
- package/src/utils/normalize-content-link.util.ts +0 -31
- package/tsconfig.build.json +0 -5
- package/tsconfig.json +0 -29
|
@@ -1,297 +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 { Profile } from './profile.schema';
|
|
9
|
-
import { Client } from './client.schema';
|
|
10
|
-
import { Influencer } from './influencer.schema';
|
|
11
|
-
import { Note } from './note.schema';
|
|
12
|
-
import { Responsible, ResponsibleSchema } from './responsible.schema';
|
|
13
|
-
|
|
14
|
-
export type SaleDocument = HydratedDocument<Sale>;
|
|
15
|
-
|
|
16
|
-
@Schema({ _id: false })
|
|
17
|
-
export class Proposal {
|
|
18
|
-
@Prop({ required: true }) businessUnit: 'service' | 'comercial';
|
|
19
|
-
@Prop({ required: true }) contact: string;
|
|
20
|
-
@Prop({ required: true }) initialScope: string;
|
|
21
|
-
|
|
22
|
-
@Prop({
|
|
23
|
-
type: String,
|
|
24
|
-
enum: ['inbound', 'outbound'],
|
|
25
|
-
required: true,
|
|
26
|
-
})
|
|
27
|
-
origin: 'inbound' | 'outbound';
|
|
28
|
-
|
|
29
|
-
@Prop({
|
|
30
|
-
type: MongooseSchema.Types.ObjectId,
|
|
31
|
-
ref: 'Profile',
|
|
32
|
-
required: false,
|
|
33
|
-
})
|
|
34
|
-
profile?: Types.ObjectId | Profile;
|
|
35
|
-
|
|
36
|
-
@Prop({
|
|
37
|
-
type: MongooseSchema.Types.ObjectId,
|
|
38
|
-
ref: 'Influencer',
|
|
39
|
-
required: false,
|
|
40
|
-
})
|
|
41
|
-
influencer?: Types.ObjectId | Influencer;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@Schema({ _id: false })
|
|
45
|
-
export class Negotiation {
|
|
46
|
-
@Prop({ required: true }) calculatorType:
|
|
47
|
-
| 'withPreDefinedBudget'
|
|
48
|
-
| 'withoutPreDefinedBudget'
|
|
49
|
-
| 'byCommission'
|
|
50
|
-
| 'bourbon';
|
|
51
|
-
@Prop({ required: false }) childPermit?: boolean;
|
|
52
|
-
@Prop({ required: false }) childPermitValue?: number;
|
|
53
|
-
@Prop({ required: false }) childPermitMethod?:
|
|
54
|
-
| 'direct'
|
|
55
|
-
| 'debit_note'
|
|
56
|
-
| 'client';
|
|
57
|
-
@Prop({ required: true }) influencerBroadcastValue: number;
|
|
58
|
-
@Prop({ required: true }) influencerBroadcastMethod:
|
|
59
|
-
| 'transfer'
|
|
60
|
-
| 'direct'
|
|
61
|
-
| 'debit_note'
|
|
62
|
-
| 'client';
|
|
63
|
-
@Prop({ required: true }) productionAndOthersValue: number;
|
|
64
|
-
@Prop({ required: true }) productionAndOthersMethod:
|
|
65
|
-
| 'direct'
|
|
66
|
-
| 'debit_note'
|
|
67
|
-
| 'client';
|
|
68
|
-
@Prop({ required: true }) commissionRate: number;
|
|
69
|
-
@Prop({ required: true }) broadcastBonusRate: number;
|
|
70
|
-
@Prop({ required: true }) taxRate: number;
|
|
71
|
-
@Prop({ required: true }) budget: number;
|
|
72
|
-
@Prop({ required: true }) activationValue: number;
|
|
73
|
-
@Prop({ required: true }) revenue: number;
|
|
74
|
-
@Prop({ required: true }) transferValue: number;
|
|
75
|
-
@Prop({ required: true }) taxValue: number;
|
|
76
|
-
@Prop({ required: true }) ISSQNValue: number;
|
|
77
|
-
@Prop({ required: true }) broadcastBonusValue: number;
|
|
78
|
-
@Prop({ required: true }) debitNoteValue: number;
|
|
79
|
-
@Prop({ required: true }) freeValue: number;
|
|
80
|
-
@Prop({ required: true }) grossProfitRate: number;
|
|
81
|
-
@Prop({ required: true }) takeRate: number;
|
|
82
|
-
@Prop({ required: true }) grossIncomeValue: number;
|
|
83
|
-
@Prop({ required: true }) isDollarNegotiation: boolean;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@Schema({ _id: false })
|
|
87
|
-
export class Formalization {
|
|
88
|
-
@Prop({ required: true }) billingTriggerEvent: string;
|
|
89
|
-
@Prop({ required: true }) estimatedIssueDate: Date;
|
|
90
|
-
@Prop({ required: true }) estimatedDueDate: Date;
|
|
91
|
-
@Prop({ required: true }) paymentTerms: string;
|
|
92
|
-
@Prop({ required: true }) handlingInvoices: string;
|
|
93
|
-
@Prop({ required: true }) finalScope: string;
|
|
94
|
-
|
|
95
|
-
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Client' })
|
|
96
|
-
brand: Types.ObjectId | Client;
|
|
97
|
-
|
|
98
|
-
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Client', required: false })
|
|
99
|
-
agency?: Types.ObjectId | Client;
|
|
100
|
-
|
|
101
|
-
@Prop({ type: Number, required: true })
|
|
102
|
-
totalInstallments: number;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
@Schema({ _id: false })
|
|
106
|
-
export class Lost {
|
|
107
|
-
@Prop({ required: true }) reason: 'declined' | 'other' | 'spam' | 'no_response' | 'no_budget' | 'no_profile_fit' | 'invite_exchange';
|
|
108
|
-
@Prop() details?: string;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
@Schema({ _id: false })
|
|
112
|
-
export class Activity {
|
|
113
|
-
@Prop({ required: true }) type: 'email' | 'whatsapp' | 'meeting' | 'call' | 'linkedin' | 'instagram_dm';
|
|
114
|
-
@Prop({ required: false }) description?: string;
|
|
115
|
-
@Prop({ required: true }) owner: string;
|
|
116
|
-
@Prop({ required: true }) createdAt: Date;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
@Schema({ _id: false })
|
|
120
|
-
export class TimelineEntry {
|
|
121
|
-
@Prop({ required: true }) phase: string;
|
|
122
|
-
@Prop({ required: true }) date: Date;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
@Schema({ _id: false })
|
|
126
|
-
export class CommissionParticipant {
|
|
127
|
-
@Prop({ required: true }) email: string;
|
|
128
|
-
@Prop({ required: true }) role: string;
|
|
129
|
-
@Prop({ required: true }) percentage: number;
|
|
130
|
-
@Prop({ required: true }) value: number;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
@Schema({ _id: false })
|
|
134
|
-
export class CommissionInfo {
|
|
135
|
-
@Prop({ required: true }) budget: number;
|
|
136
|
-
@Prop({ required: true }) freeValue: number;
|
|
137
|
-
@Prop({ required: true }) marginPercentage: number;
|
|
138
|
-
@Prop({ required: true }) commissionPercentage: number;
|
|
139
|
-
@Prop({ required: true }) totalCommissionValue: number;
|
|
140
|
-
|
|
141
|
-
@Prop({ type: [CommissionParticipant], required: true })
|
|
142
|
-
participants: CommissionParticipant[];
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
@Schema({ _id: false })
|
|
146
|
-
export class Inbox {
|
|
147
|
-
@Prop({ required: true, unique: true, sparse: true }) gmailMessageId: string;
|
|
148
|
-
@Prop({ required: true }) gmailThreadId: string;
|
|
149
|
-
@Prop({ required: true }) from: string;
|
|
150
|
-
@Prop({ required: true }) to: string;
|
|
151
|
-
@Prop({ required: true }) subject: string;
|
|
152
|
-
@Prop({ required: true }) bodyText: string;
|
|
153
|
-
@Prop({ required: false }) bodyHtml?: string;
|
|
154
|
-
@Prop({ required: true }) receivedAt: Date;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Responsáveis da venda por papel: comercial (proposta), curadoria e planejamento.
|
|
159
|
-
*/
|
|
160
|
-
@Schema({ _id: false })
|
|
161
|
-
export class SaleResponsible {
|
|
162
|
-
@Prop({ type: [ResponsibleSchema], required: false, default: [] })
|
|
163
|
-
proposal?: Responsible[];
|
|
164
|
-
|
|
165
|
-
@Prop({ type: [ResponsibleSchema], required: false, default: [] })
|
|
166
|
-
curation?: Responsible[];
|
|
167
|
-
|
|
168
|
-
@Prop({ type: [ResponsibleSchema], required: false, default: [] })
|
|
169
|
-
planning?: Responsible[];
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export const SaleResponsibleSchema = SchemaFactory.createForClass(SaleResponsible);
|
|
173
|
-
|
|
174
|
-
@Schema({ _id: false })
|
|
175
|
-
export class SaleLinks {
|
|
176
|
-
@Prop({ required: false })
|
|
177
|
-
contract?: string;
|
|
178
|
-
|
|
179
|
-
@Prop({ required: false })
|
|
180
|
-
clientSheet?: string;
|
|
181
|
-
|
|
182
|
-
@Prop({ required: false })
|
|
183
|
-
internalSheet?: string;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
@Schema({ timestamps: true })
|
|
187
|
-
export class Sale {
|
|
188
|
-
@Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
|
|
189
|
-
_id?: Types.ObjectId;
|
|
190
|
-
|
|
191
|
-
@Prop({ required: true }) title: string;
|
|
192
|
-
|
|
193
|
-
@Prop({
|
|
194
|
-
required: true,
|
|
195
|
-
enum: [
|
|
196
|
-
'inbox',
|
|
197
|
-
'proposal',
|
|
198
|
-
'negotiation',
|
|
199
|
-
'commission',
|
|
200
|
-
'formalization',
|
|
201
|
-
'closed',
|
|
202
|
-
'lost',
|
|
203
|
-
],
|
|
204
|
-
})
|
|
205
|
-
phase:
|
|
206
|
-
| 'inbox'
|
|
207
|
-
| 'proposal'
|
|
208
|
-
| 'negotiation'
|
|
209
|
-
| 'commission'
|
|
210
|
-
| 'formalization'
|
|
211
|
-
| 'closed'
|
|
212
|
-
| 'lost';
|
|
213
|
-
|
|
214
|
-
@Prop({
|
|
215
|
-
type: String,
|
|
216
|
-
enum: [
|
|
217
|
-
'new',
|
|
218
|
-
'organic_expansion',
|
|
219
|
-
'strategic_expansion',
|
|
220
|
-
'renewal',
|
|
221
|
-
'comercial_winback',
|
|
222
|
-
'organic_winback',
|
|
223
|
-
],
|
|
224
|
-
default: 'new',
|
|
225
|
-
})
|
|
226
|
-
type:
|
|
227
|
-
| 'new'
|
|
228
|
-
| 'organic_expansion'
|
|
229
|
-
| 'strategic_expansion'
|
|
230
|
-
| 'renewal'
|
|
231
|
-
| 'comercial_winback'
|
|
232
|
-
| 'organic_winback';
|
|
233
|
-
|
|
234
|
-
@Prop({ type: Proposal }) proposal?: Proposal;
|
|
235
|
-
@Prop({ type: Negotiation }) negotiation?: Negotiation;
|
|
236
|
-
@Prop({ type: Formalization }) formalization?: Formalization;
|
|
237
|
-
@Prop({ type: CommissionInfo, required: false }) commission?: CommissionInfo;
|
|
238
|
-
|
|
239
|
-
@Prop({ type: Inbox }) inbox?: Inbox;
|
|
240
|
-
|
|
241
|
-
@Prop({ type: Lost }) lost?: Lost;
|
|
242
|
-
|
|
243
|
-
@Prop([{ type: Note, required: false }])
|
|
244
|
-
notes?: Note[];
|
|
245
|
-
|
|
246
|
-
@Prop([{ type: Activity, required: false }])
|
|
247
|
-
activities?: Activity[];
|
|
248
|
-
|
|
249
|
-
@Prop({ type: MongooseSchema.Types.ObjectId })
|
|
250
|
-
organization: Types.ObjectId;
|
|
251
|
-
|
|
252
|
-
@Prop({ type: [{ type: MongooseSchema.Types.ObjectId }], required: false, default: [] })
|
|
253
|
-
tags?: Types.ObjectId[];
|
|
254
|
-
|
|
255
|
-
@Prop([{ type: TimelineEntry, required: false }])
|
|
256
|
-
timeline?: TimelineEntry[];
|
|
257
|
-
|
|
258
|
-
@Prop([
|
|
259
|
-
{
|
|
260
|
-
type: MongooseSchema.Types.ObjectId,
|
|
261
|
-
ref: 'Profile',
|
|
262
|
-
required: false,
|
|
263
|
-
},
|
|
264
|
-
])
|
|
265
|
-
profiles?: Types.ObjectId[] | Profile[];
|
|
266
|
-
|
|
267
|
-
@Prop({ required: false })
|
|
268
|
-
closedAt?: Date;
|
|
269
|
-
|
|
270
|
-
@Prop({ default: Date.now, required: false })
|
|
271
|
-
createdAt?: Date;
|
|
272
|
-
|
|
273
|
-
@Prop({ default: Date.now, required: false })
|
|
274
|
-
updatedAt?: Date;
|
|
275
|
-
|
|
276
|
-
@Prop({ type: String, required: false })
|
|
277
|
-
omieId?: string;
|
|
278
|
-
|
|
279
|
-
@Prop({ type: SaleResponsibleSchema, required: false })
|
|
280
|
-
responsible?: SaleResponsible;
|
|
281
|
-
|
|
282
|
-
@Prop({ type: SaleLinks, required: false })
|
|
283
|
-
links?: SaleLinks;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
export const SaleSchema = SchemaFactory.createForClass(Sale);
|
|
287
|
-
|
|
288
|
-
SaleSchema.index({ organization: 1, phase: 1 });
|
|
289
|
-
SaleSchema.index({ organization: 1, createdAt: -1 });
|
|
290
|
-
SaleSchema.index({ organization: 1, 'formalization.brand': 1 });
|
|
291
|
-
SaleSchema.index({ organization: 1, 'formalization.agency': 1 });
|
|
292
|
-
SaleSchema.index({ organization: 1, closedAt: 1, phase: 1 });
|
|
293
|
-
SaleSchema.index({ 'proposal.influencer': 1 });
|
|
294
|
-
SaleSchema.index({ 'responsible.proposal.email': 1 });
|
|
295
|
-
SaleSchema.index({ tags: 1 });
|
|
296
|
-
|
|
297
|
-
export const SaleModel = MongooseModel('Sale', SaleSchema);
|
|
@@ -1,235 +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 ScriptDocument = HydratedDocument<Script>;
|
|
16
|
-
|
|
17
|
-
export const SCRIPT_STATUS_VALUES = [
|
|
18
|
-
'draft',
|
|
19
|
-
'pending',
|
|
20
|
-
'approved',
|
|
21
|
-
'reproved',
|
|
22
|
-
] as const;
|
|
23
|
-
export type ScriptStatus = (typeof SCRIPT_STATUS_VALUES)[number];
|
|
24
|
-
|
|
25
|
-
export const SCRIPT_DECISION_VALUES = [
|
|
26
|
-
'approved',
|
|
27
|
-
'reproved',
|
|
28
|
-
'questioned',
|
|
29
|
-
] as const;
|
|
30
|
-
export type ScriptDecisionValue = (typeof SCRIPT_DECISION_VALUES)[number];
|
|
31
|
-
|
|
32
|
-
@Schema({ _id: false })
|
|
33
|
-
export class ScriptDecision {
|
|
34
|
-
@ApiProperty({ enum: SCRIPT_DECISION_VALUES })
|
|
35
|
-
@Prop({ type: String, enum: SCRIPT_DECISION_VALUES, required: true })
|
|
36
|
-
decision: ScriptDecisionValue;
|
|
37
|
-
|
|
38
|
-
@ApiProperty({ required: false })
|
|
39
|
-
@Prop({ type: String, required: false })
|
|
40
|
-
comment?: string;
|
|
41
|
-
|
|
42
|
-
@ApiProperty({ description: 'Time do cliente que respondeu, lido do JWT' })
|
|
43
|
-
@Prop({ type: String, required: true })
|
|
44
|
-
team: string;
|
|
45
|
-
|
|
46
|
-
@ApiProperty()
|
|
47
|
-
@Prop({ type: String, required: true })
|
|
48
|
-
respondedBy: string;
|
|
49
|
-
|
|
50
|
-
@ApiProperty()
|
|
51
|
-
@Prop({ type: Date, required: true })
|
|
52
|
-
respondedAt: Date;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const ScriptDecisionSchema = SchemaFactory.createForClass(ScriptDecision);
|
|
56
|
-
|
|
57
|
-
@Schema({ _id: false })
|
|
58
|
-
export class ScriptStaffReply {
|
|
59
|
-
@ApiProperty()
|
|
60
|
-
@Prop({ type: String, required: true })
|
|
61
|
-
message: string;
|
|
62
|
-
|
|
63
|
-
@ApiProperty()
|
|
64
|
-
@Prop({ type: String, required: true })
|
|
65
|
-
repliedBy: string;
|
|
66
|
-
|
|
67
|
-
@ApiProperty()
|
|
68
|
-
@Prop({ type: Date, required: true })
|
|
69
|
-
repliedAt: Date;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export const ScriptStaffReplySchema =
|
|
73
|
-
SchemaFactory.createForClass(ScriptStaffReply);
|
|
74
|
-
|
|
75
|
-
@Schema({ _id: false })
|
|
76
|
-
export class ScriptVersion {
|
|
77
|
-
@ApiProperty()
|
|
78
|
-
@Prop({ type: Number, required: true })
|
|
79
|
-
version: number;
|
|
80
|
-
|
|
81
|
-
@ApiProperty({ required: false })
|
|
82
|
-
@Prop({ type: String, required: false, default: null })
|
|
83
|
-
fileUrl?: string | null;
|
|
84
|
-
|
|
85
|
-
@ApiProperty({ required: false })
|
|
86
|
-
@Prop({ type: String, required: false, default: null })
|
|
87
|
-
fileName?: string | null;
|
|
88
|
-
|
|
89
|
-
@ApiProperty({ required: false })
|
|
90
|
-
@Prop({ type: String, required: false, default: null })
|
|
91
|
-
link?: string | null;
|
|
92
|
-
|
|
93
|
-
@ApiProperty({ enum: ['approved', 'reproved'] })
|
|
94
|
-
@Prop({ type: String, enum: ['approved', 'reproved'], required: true })
|
|
95
|
-
status: 'approved' | 'reproved';
|
|
96
|
-
|
|
97
|
-
@ApiProperty({ required: false })
|
|
98
|
-
@Prop({ type: String, required: false })
|
|
99
|
-
submittedBy?: string;
|
|
100
|
-
|
|
101
|
-
@ApiProperty({ required: false })
|
|
102
|
-
@Prop({ type: Date, required: false })
|
|
103
|
-
submittedAt?: Date;
|
|
104
|
-
|
|
105
|
-
@ApiProperty({ type: () => [ScriptDecision] })
|
|
106
|
-
@Prop({ type: [ScriptDecisionSchema], default: [] })
|
|
107
|
-
decisions: ScriptDecision[];
|
|
108
|
-
|
|
109
|
-
@ApiProperty({ type: () => [ScriptStaffReply] })
|
|
110
|
-
@Prop({ type: [ScriptStaffReplySchema], default: [] })
|
|
111
|
-
staffReplies: ScriptStaffReply[];
|
|
112
|
-
|
|
113
|
-
@ApiProperty()
|
|
114
|
-
@Prop({ type: Date, required: true })
|
|
115
|
-
archivedAt: Date;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export const ScriptVersionSchema = SchemaFactory.createForClass(ScriptVersion);
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Aprovação de roteiro: um documento por (action, profile, deliverableType,
|
|
122
|
-
* deliverableIndex) — não um doc único por Ação. A versão mora no mesmo doc;
|
|
123
|
-
* ao reprovar, o estado atual é arquivado em `versions[]` e o doc volta a
|
|
124
|
-
* `draft` para uma nova tentativa (ver GD-532).
|
|
125
|
-
*/
|
|
126
|
-
@Schema({ timestamps: true })
|
|
127
|
-
export class Script {
|
|
128
|
-
@ApiProperty()
|
|
129
|
-
@Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
|
|
130
|
-
_id?: Types.ObjectId;
|
|
131
|
-
|
|
132
|
-
@ApiProperty({ type: () => Action })
|
|
133
|
-
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Action', required: true })
|
|
134
|
-
action: Types.ObjectId | Action;
|
|
135
|
-
|
|
136
|
-
@ApiProperty({ type: () => Client })
|
|
137
|
-
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Client', required: false })
|
|
138
|
-
client?: Types.ObjectId | Client;
|
|
139
|
-
|
|
140
|
-
@ApiProperty({ type: () => Profile })
|
|
141
|
-
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Profile', required: true })
|
|
142
|
-
profile: Types.ObjectId | Profile;
|
|
143
|
-
|
|
144
|
-
@ApiProperty({
|
|
145
|
-
enum: TASK_FORMAT_VALUES,
|
|
146
|
-
description: 'Unidade de entrega do escopo (mesmos valores de recruitment.scope.delivery)',
|
|
147
|
-
})
|
|
148
|
-
@Prop({ type: String, enum: TASK_FORMAT_VALUES, required: true })
|
|
149
|
-
deliverableType: TaskFormat;
|
|
150
|
-
|
|
151
|
-
@ApiProperty({
|
|
152
|
-
description: 'Ex.: 1 de 2 quando o escopo pede mais de uma unidade do mesmo tipo; sempre 1 para "story"',
|
|
153
|
-
})
|
|
154
|
-
@Prop({ type: Number, required: true, default: 1 })
|
|
155
|
-
deliverableIndex: number;
|
|
156
|
-
|
|
157
|
-
@ApiProperty()
|
|
158
|
-
@Prop({ type: Number, required: true, default: 1 })
|
|
159
|
-
version: number;
|
|
160
|
-
|
|
161
|
-
@ApiProperty({ required: false })
|
|
162
|
-
@Prop({ type: String, required: false, default: null })
|
|
163
|
-
fileUrl?: string | null;
|
|
164
|
-
|
|
165
|
-
@ApiProperty({ required: false })
|
|
166
|
-
@Prop({ type: String, required: false, default: null })
|
|
167
|
-
fileName?: string | null;
|
|
168
|
-
|
|
169
|
-
@ApiProperty({
|
|
170
|
-
required: false,
|
|
171
|
-
description: 'Alternativa ao arquivo — staff usa arquivo OU link',
|
|
172
|
-
})
|
|
173
|
-
@Prop({ type: String, required: false, default: null })
|
|
174
|
-
link?: string | null;
|
|
175
|
-
|
|
176
|
-
@ApiProperty({ enum: SCRIPT_STATUS_VALUES })
|
|
177
|
-
@Prop({
|
|
178
|
-
type: String,
|
|
179
|
-
enum: SCRIPT_STATUS_VALUES,
|
|
180
|
-
required: true,
|
|
181
|
-
default: 'draft',
|
|
182
|
-
})
|
|
183
|
-
status: ScriptStatus;
|
|
184
|
-
|
|
185
|
-
@ApiProperty({
|
|
186
|
-
type: [String],
|
|
187
|
-
description:
|
|
188
|
-
'Snapshot de Client.requiredTeams no momento da criação — vazio = 1 aprovação resolve; com times = todos precisam aprovar',
|
|
189
|
-
})
|
|
190
|
-
@Prop({ type: [String], required: false, default: [] })
|
|
191
|
-
requiredTeams: string[];
|
|
192
|
-
|
|
193
|
-
@ApiProperty({ required: false })
|
|
194
|
-
@Prop({ type: String, required: false })
|
|
195
|
-
submittedBy?: string;
|
|
196
|
-
|
|
197
|
-
@ApiProperty({ required: false })
|
|
198
|
-
@Prop({ type: Date, required: false })
|
|
199
|
-
submittedAt?: Date;
|
|
200
|
-
|
|
201
|
-
@ApiProperty({ type: () => [ScriptDecision] })
|
|
202
|
-
@Prop({ type: [ScriptDecisionSchema], default: [] })
|
|
203
|
-
decisions: ScriptDecision[];
|
|
204
|
-
|
|
205
|
-
@ApiProperty({ type: () => [ScriptStaffReply] })
|
|
206
|
-
@Prop({ type: [ScriptStaffReplySchema], default: [] })
|
|
207
|
-
staffReplies: ScriptStaffReply[];
|
|
208
|
-
|
|
209
|
-
@ApiProperty({ type: () => [ScriptVersion] })
|
|
210
|
-
@Prop({ type: [ScriptVersionSchema], default: [] })
|
|
211
|
-
versions: ScriptVersion[];
|
|
212
|
-
|
|
213
|
-
@Prop({ type: MongooseSchema.Types.ObjectId, required: false })
|
|
214
|
-
organization?: Types.ObjectId;
|
|
215
|
-
|
|
216
|
-
@ApiProperty()
|
|
217
|
-
@Prop({ default: Date.now, required: false })
|
|
218
|
-
createdAt?: Date;
|
|
219
|
-
|
|
220
|
-
@ApiProperty()
|
|
221
|
-
@Prop({ default: Date.now, required: false })
|
|
222
|
-
updatedAt?: Date;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export const ScriptSchema = SchemaFactory.createForClass(Script);
|
|
226
|
-
|
|
227
|
-
ScriptSchema.index(
|
|
228
|
-
{ action: 1, profile: 1, deliverableType: 1, deliverableIndex: 1 },
|
|
229
|
-
{ unique: true },
|
|
230
|
-
);
|
|
231
|
-
ScriptSchema.index({ action: 1, status: 1 });
|
|
232
|
-
ScriptSchema.index({ client: 1, status: 1 });
|
|
233
|
-
ScriptSchema.index({ organization: 1, status: 1 });
|
|
234
|
-
|
|
235
|
-
export const ScriptModel = MongooseModel('Script', ScriptSchema);
|
|
@@ -1,55 +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 { Profile } from './profile.schema';
|
|
9
|
-
|
|
10
|
-
export type SnapshotDocument = HydratedDocument<Snapshot>;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Histórico diário de seguidores por perfil, gravado pelo profile-sync-worker
|
|
14
|
-
* a partir do `audience_size` que a Primetag devolve na captura. Um doc por
|
|
15
|
-
* perfil por dia (`date` truncado em UTC): uma rodada repetida no mesmo dia só
|
|
16
|
-
* sobrescreve o valor do dia.
|
|
17
|
-
*/
|
|
18
|
-
@Schema({ collection: 'snapshots', timestamps: true })
|
|
19
|
-
export class Snapshot {
|
|
20
|
-
@Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
|
|
21
|
-
_id?: Types.ObjectId;
|
|
22
|
-
|
|
23
|
-
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Profile', required: true })
|
|
24
|
-
profile: Types.ObjectId | Profile;
|
|
25
|
-
|
|
26
|
-
@Prop({ type: String, required: false })
|
|
27
|
-
socialnetwork?: string;
|
|
28
|
-
|
|
29
|
-
@Prop({ type: Number, required: true })
|
|
30
|
-
followers: number;
|
|
31
|
-
|
|
32
|
-
@Prop({ type: Date, required: true })
|
|
33
|
-
date: Date;
|
|
34
|
-
|
|
35
|
-
@Prop({ type: Date, required: true })
|
|
36
|
-
capturedAt: Date;
|
|
37
|
-
|
|
38
|
-
@Prop({ type: String, enum: ['primetag'], required: true, default: 'primetag' })
|
|
39
|
-
source: 'primetag';
|
|
40
|
-
|
|
41
|
-
@Prop({ default: Date.now, required: false })
|
|
42
|
-
createdAt?: Date;
|
|
43
|
-
|
|
44
|
-
@Prop({ default: Date.now, required: false })
|
|
45
|
-
updatedAt?: Date;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const SnapshotSchema = SchemaFactory.createForClass(Snapshot);
|
|
49
|
-
|
|
50
|
-
SnapshotSchema.index({ profile: 1, date: 1 }, { unique: true });
|
|
51
|
-
|
|
52
|
-
export const SnapshotModel = MongooseModel(
|
|
53
|
-
'Snapshot',
|
|
54
|
-
SnapshotSchema,
|
|
55
|
-
);
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
-
import { ApiProperty } from '@nestjs/swagger';
|
|
3
|
-
import { Schema as MongooseSchema, Types } from 'mongoose';
|
|
4
|
-
import { Store } from './store.schema';
|
|
5
|
-
|
|
6
|
-
export const STORE_VISIT_STATUS_VALUES = [
|
|
7
|
-
'awaiting_confirmation', // Cadastrada pelo time, aguardando influenciadora confirmar horário e aceitar regras
|
|
8
|
-
'confirmed', // Influenciadora confirmou horário e aceite registrado
|
|
9
|
-
'awaiting_approval', // Fotos de looks e etiquetas submetidas para aprovação
|
|
10
|
-
'approved', // Looks e etiquetas aprovados pelo time
|
|
11
|
-
'done', // Visita realizada em loja
|
|
12
|
-
'finished', // Processo encerrado e notificação emitida
|
|
13
|
-
] as const;
|
|
14
|
-
|
|
15
|
-
export type StoreVisitStatus = (typeof STORE_VISIT_STATUS_VALUES)[number];
|
|
16
|
-
|
|
17
|
-
export const STORE_VISIT_PERIOD_VALUES = [
|
|
18
|
-
'morning',
|
|
19
|
-
'afternoon',
|
|
20
|
-
'night',
|
|
21
|
-
] as const;
|
|
22
|
-
|
|
23
|
-
export type StoreVisitPeriod = (typeof STORE_VISIT_PERIOD_VALUES)[number];
|
|
24
|
-
|
|
25
|
-
@Schema({ _id: false })
|
|
26
|
-
export class StoreVisitData {
|
|
27
|
-
@ApiProperty({ example: '64bfc3a78d3f1e2a12345684', description: 'Loja física agendada' })
|
|
28
|
-
@Prop({
|
|
29
|
-
type: MongooseSchema.Types.ObjectId,
|
|
30
|
-
ref: Store.name,
|
|
31
|
-
required: true,
|
|
32
|
-
})
|
|
33
|
-
store: Types.ObjectId | Store;
|
|
34
|
-
|
|
35
|
-
@ApiProperty({ example: '2026-11-15T00:00:00.000Z', description: 'Data da visita agendada pelo time' })
|
|
36
|
-
@Prop({ type: Date, required: true })
|
|
37
|
-
scheduledDate: Date;
|
|
38
|
-
|
|
39
|
-
@ApiProperty({ example: 'afternoon', enum: STORE_VISIT_PERIOD_VALUES, required: false, nullable: true })
|
|
40
|
-
@Prop({ type: String, enum: STORE_VISIT_PERIOD_VALUES, required: false, default: null })
|
|
41
|
-
scheduledPeriod?: StoreVisitPeriod | null;
|
|
42
|
-
|
|
43
|
-
@ApiProperty({ example: 'abcdef123456...', description: 'Token de 32 bytes base64url' })
|
|
44
|
-
@Prop({ type: String, required: true })
|
|
45
|
-
token: string;
|
|
46
|
-
|
|
47
|
-
@ApiProperty({ example: false, default: false })
|
|
48
|
-
@Prop({ type: Boolean, default: false })
|
|
49
|
-
rulesAccepted: boolean;
|
|
50
|
-
|
|
51
|
-
@ApiProperty({ example: null, required: false, nullable: true })
|
|
52
|
-
@Prop({ type: Date, required: false, default: null })
|
|
53
|
-
acceptedAt?: Date | null;
|
|
54
|
-
|
|
55
|
-
@ApiProperty({ type: [String], example: [] })
|
|
56
|
-
@Prop({ type: [String], default: [] })
|
|
57
|
-
tagPhotos: string[];
|
|
58
|
-
|
|
59
|
-
@ApiProperty({ type: [String], example: [] })
|
|
60
|
-
@Prop({ type: [String], default: [] })
|
|
61
|
-
lookPhotos: string[];
|
|
62
|
-
|
|
63
|
-
@ApiProperty({ example: null, required: false, nullable: true })
|
|
64
|
-
@Prop({ type: String, required: false, default: null })
|
|
65
|
-
reviewNotes?: string | null;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export const StoreVisitDataSchema = SchemaFactory.createForClass(StoreVisitData);
|
|
@@ -1,52 +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
|
-
import { Address, AddressSchema } from './party.schema';
|
|
10
|
-
import { Client } from './client.schema';
|
|
11
|
-
|
|
12
|
-
export type StoreDocument = HydratedDocument<Store>;
|
|
13
|
-
|
|
14
|
-
@Schema({ timestamps: true, collection: 'stores' })
|
|
15
|
-
export class Store {
|
|
16
|
-
@ApiProperty({ example: '64bfc3a78d3f1e2a12345670', required: false })
|
|
17
|
-
@Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
|
|
18
|
-
_id?: Types.ObjectId;
|
|
19
|
-
|
|
20
|
-
@ApiProperty({ example: '64bfc3a78d3f1e2a12345682' })
|
|
21
|
-
@Prop({
|
|
22
|
-
type: MongooseSchema.Types.ObjectId,
|
|
23
|
-
ref: Client.name,
|
|
24
|
-
required: true,
|
|
25
|
-
index: true,
|
|
26
|
-
})
|
|
27
|
-
client: Types.ObjectId | Client;
|
|
28
|
-
|
|
29
|
-
@ApiProperty({ example: 'Shoulder Shopping Morumbi' })
|
|
30
|
-
@Prop({ type: String, required: true, trim: true })
|
|
31
|
-
name: string;
|
|
32
|
-
|
|
33
|
-
@ApiProperty({ example: 'Morumbi Shopping', required: false })
|
|
34
|
-
@Prop({ type: String, required: false, trim: true })
|
|
35
|
-
shopping?: string;
|
|
36
|
-
|
|
37
|
-
@ApiProperty({ required: false })
|
|
38
|
-
@Prop({ type: AddressSchema, required: false })
|
|
39
|
-
address?: Address;
|
|
40
|
-
|
|
41
|
-
@ApiProperty({ example: true, default: true })
|
|
42
|
-
@Prop({ type: Boolean, default: true })
|
|
43
|
-
active: boolean;
|
|
44
|
-
|
|
45
|
-
createdAt?: Date;
|
|
46
|
-
updatedAt?: Date;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const StoreSchema = SchemaFactory.createForClass(Store);
|
|
50
|
-
StoreSchema.index({ client: 1, name: 1 });
|
|
51
|
-
|
|
52
|
-
export const StoreModel = MongooseModel('Store', StoreSchema);
|