@grapadigital/shared-schemas 1.0.242 → 1.1.1

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 (150) 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/attachment.schema.d.ts +13 -0
  7. package/dist/schemas/attachment.schema.js +28 -0
  8. package/dist/schemas/benchmark.schema.d.ts +3 -28
  9. package/dist/schemas/benchmark.schema.js +11 -6
  10. package/dist/schemas/campaign.schema.d.ts +2 -27
  11. package/dist/schemas/campaign.schema.js +4 -4
  12. package/dist/schemas/client.schema.d.ts +18 -79
  13. package/dist/schemas/client.schema.js +73 -71
  14. package/dist/schemas/comment.schema.d.ts +5 -30
  15. package/dist/schemas/comment.schema.js +42 -37
  16. package/dist/schemas/commission.schema.d.ts +5 -30
  17. package/dist/schemas/commission.schema.js +10 -10
  18. package/dist/schemas/content-capture-process.schema.d.ts +6 -31
  19. package/dist/schemas/content-capture-process.schema.js +24 -17
  20. package/dist/schemas/content-draft.schema.d.ts +2 -27
  21. package/dist/schemas/content-draft.schema.js +5 -5
  22. package/dist/schemas/content.schema.d.ts +6 -31
  23. package/dist/schemas/content.schema.js +84 -74
  24. package/dist/schemas/contract.schema.d.ts +3 -28
  25. package/dist/schemas/contract.schema.js +5 -5
  26. package/dist/schemas/creative.schema.d.ts +6 -31
  27. package/dist/schemas/creative.schema.js +22 -31
  28. package/dist/schemas/export-comments-job.schema.d.ts +2 -27
  29. package/dist/schemas/export-comments-job.schema.js +6 -6
  30. package/dist/schemas/group.schema.d.ts +1 -26
  31. package/dist/schemas/group.schema.js +5 -5
  32. package/dist/schemas/influencer.schema.d.ts +6 -31
  33. package/dist/schemas/influencer.schema.js +16 -18
  34. package/dist/schemas/invoice.schema.d.ts +4 -29
  35. package/dist/schemas/invoice.schema.js +42 -32
  36. package/dist/schemas/job.schema.d.ts +2 -27
  37. package/dist/schemas/job.schema.js +14 -14
  38. package/dist/schemas/lead.schema.d.ts +1 -26
  39. package/dist/schemas/lead.schema.js +67 -64
  40. package/dist/schemas/log.schema.d.ts +1 -26
  41. package/dist/schemas/log.schema.js +24 -24
  42. package/dist/schemas/note.schema.d.ts +1 -26
  43. package/dist/schemas/note.schema.js +9 -9
  44. package/dist/schemas/notifications.schema.d.ts +1 -26
  45. package/dist/schemas/notifications.schema.js +8 -8
  46. package/dist/schemas/organization.schema.d.ts +2 -26
  47. package/dist/schemas/organization.schema.js +8 -4
  48. package/dist/schemas/party.schema.d.ts +1 -26
  49. package/dist/schemas/party.schema.js +11 -11
  50. package/dist/schemas/payment.schema.d.ts +12 -49
  51. package/dist/schemas/payment.schema.js +66 -69
  52. package/dist/schemas/profile.schema.d.ts +3 -28
  53. package/dist/schemas/profile.schema.js +6 -6
  54. package/dist/schemas/project.schema.d.ts +4 -29
  55. package/dist/schemas/project.schema.js +13 -13
  56. package/dist/schemas/prospect.schema.d.ts +3 -28
  57. package/dist/schemas/prospect.schema.js +9 -9
  58. package/dist/schemas/recruitment.schema.d.ts +5 -30
  59. package/dist/schemas/recruitment.schema.js +36 -36
  60. package/dist/schemas/responsible.schema.d.ts +0 -26
  61. package/dist/schemas/responsible.schema.js +6 -6
  62. package/dist/schemas/sale.schema.d.ts +31 -46
  63. package/dist/schemas/sale.schema.js +66 -62
  64. package/dist/schemas/script.schema.d.ts +6 -31
  65. package/dist/schemas/script.schema.js +21 -30
  66. package/dist/schemas/snapshot.schema.d.ts +3 -28
  67. package/dist/schemas/snapshot.schema.js +6 -6
  68. package/dist/schemas/store-visit.schema.d.ts +2 -27
  69. package/dist/schemas/store-visit.schema.js +21 -17
  70. package/dist/schemas/store.schema.d.ts +3 -28
  71. package/dist/schemas/store.schema.js +8 -8
  72. package/dist/schemas/supplier.schema.d.ts +2 -27
  73. package/dist/schemas/supplier.schema.js +3 -3
  74. package/dist/schemas/tag.schema.d.ts +1 -26
  75. package/dist/schemas/tag.schema.js +5 -5
  76. package/dist/schemas/task.schema.d.ts +9 -34
  77. package/dist/schemas/task.schema.js +67 -67
  78. package/dist/schemas/token.schema.d.ts +1 -26
  79. package/dist/schemas/token.schema.js +3 -3
  80. package/dist/schemas/trigger.schema.d.ts +2 -27
  81. package/dist/schemas/trigger.schema.js +5 -5
  82. package/dist/schemas/user.schema.d.ts +2 -27
  83. package/dist/schemas/user.schema.js +7 -7
  84. package/dist/schemas/webhook.schema.d.ts +1 -26
  85. package/dist/schemas/webhook.schema.js +10 -10
  86. package/dist/utils/merge-metrics-breakdown.util.d.ts +1 -1
  87. package/dist/utils/merge-metrics-breakdown.util.js +7 -2
  88. package/dist/utils/normalize-content-link.util.js +7 -7
  89. package/package.json +22 -10
  90. package/.eslintrc.json +0 -28
  91. package/.prettierrc +0 -4
  92. package/dist/schemas/profile-followers-snapshot.schema.d.ts +0 -67
  93. package/dist/schemas/profile-followers-snapshot.schema.js +0 -65
  94. package/dist/schemas/schedule.schema.d.ts +0 -73
  95. package/dist/schemas/schedule.schema.js +0 -116
  96. package/dist/utils/cost-per-impact.util.d.ts +0 -37
  97. package/dist/utils/cost-per-impact.util.js +0 -72
  98. package/dist/utils/influencer-contract.util.d.ts +0 -32
  99. package/dist/utils/influencer-contract.util.js +0 -77
  100. package/docs/code-review.md +0 -27
  101. package/docs/constitution.md +0 -75
  102. package/docs/specs/GD-692.md +0 -112
  103. package/docs/specs/GD-761.md +0 -94
  104. package/index.d.ts +0 -3
  105. package/src/index.ts +0 -42
  106. package/src/schemas/action.schema.ts +0 -328
  107. package/src/schemas/assignment.schema.ts +0 -154
  108. package/src/schemas/benchmark.schema.ts +0 -39
  109. package/src/schemas/campaign.schema.ts +0 -38
  110. package/src/schemas/client.schema.ts +0 -319
  111. package/src/schemas/comment.schema.ts +0 -216
  112. package/src/schemas/commission.schema.ts +0 -108
  113. package/src/schemas/content-capture-process.schema.ts +0 -195
  114. package/src/schemas/content-draft.schema.ts +0 -49
  115. package/src/schemas/content.schema.ts +0 -688
  116. package/src/schemas/contract.schema.ts +0 -44
  117. package/src/schemas/creative.schema.ts +0 -256
  118. package/src/schemas/export-comments-job.schema.ts +0 -59
  119. package/src/schemas/group.schema.ts +0 -23
  120. package/src/schemas/influencer.schema.ts +0 -184
  121. package/src/schemas/invoice.schema.ts +0 -164
  122. package/src/schemas/job.schema.ts +0 -111
  123. package/src/schemas/lead.schema.ts +0 -372
  124. package/src/schemas/log.schema.ts +0 -91
  125. package/src/schemas/note.schema.ts +0 -34
  126. package/src/schemas/notifications.schema.ts +0 -61
  127. package/src/schemas/organization.schema.ts +0 -29
  128. package/src/schemas/party.schema.ts +0 -65
  129. package/src/schemas/payment.schema.ts +0 -275
  130. package/src/schemas/profile.schema.ts +0 -77
  131. package/src/schemas/project.schema.ts +0 -116
  132. package/src/schemas/prospect.schema.ts +0 -62
  133. package/src/schemas/recruitment.schema.ts +0 -277
  134. package/src/schemas/responsible.schema.ts +0 -27
  135. package/src/schemas/sale.schema.ts +0 -297
  136. package/src/schemas/script.schema.ts +0 -235
  137. package/src/schemas/snapshot.schema.ts +0 -55
  138. package/src/schemas/store-visit.schema.ts +0 -68
  139. package/src/schemas/store.schema.ts +0 -52
  140. package/src/schemas/supplier.schema.ts +0 -12
  141. package/src/schemas/tag.schema.ts +0 -26
  142. package/src/schemas/task.schema.ts +0 -205
  143. package/src/schemas/token.schema.ts +0 -42
  144. package/src/schemas/trigger.schema.ts +0 -48
  145. package/src/schemas/user.schema.ts +0 -59
  146. package/src/schemas/webhook.schema.ts +0 -81
  147. package/src/utils/merge-metrics-breakdown.util.ts +0 -51
  148. package/src/utils/normalize-content-link.util.ts +0 -31
  149. package/tsconfig.build.json +0 -5
  150. package/tsconfig.json +0 -29
@@ -1,91 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
2
- import { ApiProperty } from '@nestjs/swagger';
3
- import { HydratedDocument, Schema as MongooseSchema, Types, model as MongooseModel } from 'mongoose';
4
-
5
- export type LogDocument = HydratedDocument<Log>;
6
-
7
- export const LOG_REFERENCE_VALUES = [
8
- 'action',
9
- 'recruitment',
10
- 'content',
11
- 'contract',
12
- 'sale',
13
- 'invoice',
14
- 'payment',
15
- 'assignment',
16
- 'commission',
17
- 'hub-access',
18
- ] as const;
19
- export type LogReference = (typeof LOG_REFERENCE_VALUES)[number];
20
-
21
- export const LOG_TYPE_VALUES = [
22
- 'created',
23
- 'updated',
24
- 'deleted',
25
- 'email',
26
- 'client-selected',
27
- 'access-blocked',
28
- ] as const;
29
- export type LogType = (typeof LOG_TYPE_VALUES)[number];
30
-
31
- @Schema({ _id: false })
32
- class UpdatedBy {
33
- @Prop({ required: true }) team: string;
34
- @Prop({ required: true }) name: string;
35
- @Prop({ required: true }) email: string;
36
- }
37
-
38
- @Schema({ _id: false })
39
- export class LogTarget {
40
- /** uid da conta no Firebase do Hub (projeto hub-grapa). */
41
- @ApiProperty({ example: 'FmWcCgBLTwOR2YIEZ5toRdoRpGC3' })
42
- @Prop({ required: true })
43
- uid: string;
44
-
45
- @ApiProperty({ example: 'pessoa@cliente.com.br' })
46
- @Prop({ required: true })
47
- email: string;
48
- }
49
-
50
- @Schema()
51
- export class Log {
52
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
53
- _id?: Types.ObjectId;
54
-
55
- @Prop({ type: MongooseSchema.Types.ObjectId })
56
- referenceId: string;
57
-
58
- @ApiProperty({ enum: LOG_REFERENCE_VALUES })
59
- @Prop({ required: true, enum: LOG_REFERENCE_VALUES })
60
- reference: LogReference;
61
-
62
- @ApiProperty({ enum: LOG_TYPE_VALUES })
63
- @Prop({ required: true, enum: LOG_TYPE_VALUES })
64
- type: LogType;
65
-
66
- @Prop({ required: false }) phase?: string;
67
-
68
- @Prop({ type: Object })
69
- changes: Record<string, { before: any; after: any }>;
70
-
71
- @Prop()
72
- updatedAt: Date;
73
-
74
- @Prop({ type: UpdatedBy })
75
- updatedBy?: UpdatedBy;
76
-
77
- /**
78
- * Conta do Hub afetada pela ação. Vazio fora de `hub-access`. Ver GD-760.
79
- */
80
- @ApiProperty({ type: LogTarget, required: false, nullable: true })
81
- @Prop({ type: LogTarget, default: null })
82
- target?: LogTarget | null;
83
- }
84
-
85
- export const LogSchema = SchemaFactory.createForClass(Log);
86
-
87
- LogSchema.index({ referenceId: 1, reference: 1 });
88
- LogSchema.index({ reference: 1, updatedAt: -1 });
89
- LogSchema.index({ reference: 1, 'target.uid': 1, updatedAt: -1 });
90
-
91
- export const LogModel = MongooseModel('Log', LogSchema);
@@ -1,34 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { ApiProperty } from '@nestjs/swagger';
3
- import { Types } from 'mongoose';
4
-
5
- @Schema({ _id: false })
6
- export class NoteMention {
7
- @ApiProperty({ example: '65f1a2b3c4d5e6f7a8b9c0d2' })
8
- @Prop({ type: Types.ObjectId, required: true })
9
- userId: Types.ObjectId;
10
-
11
- @ApiProperty({ example: 'jose.junior' })
12
- @Prop({ required: true, trim: true })
13
- username: string;
14
- }
15
-
16
- export const NoteMentionSchema = SchemaFactory.createForClass(NoteMention);
17
-
18
- @Schema({ _id: false })
19
- export class Note {
20
- @ApiProperty({ example: 'Emitir NF até dia 10' })
21
- @Prop({ required: true }) text: string;
22
-
23
- @ApiProperty({ example: 'João Silva' })
24
- @Prop({ required: true }) owner: string;
25
-
26
- @ApiProperty({ example: '2025-08-28T15:00:00.000Z' })
27
- @Prop({ required: true }) createdAt: Date;
28
-
29
- @ApiProperty({ type: [NoteMention], required: false })
30
- @Prop({ type: [NoteMentionSchema], default: [] })
31
- mentioneds?: NoteMention[];
32
- }
33
-
34
- export const NoteSchema = SchemaFactory.createForClass(Note);
@@ -1,61 +0,0 @@
1
-
2
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
3
- import { HydratedDocument, model as MongooseModel } from 'mongoose';
4
-
5
-
6
-
7
- export type NotificationDocument = HydratedDocument<Notification>;
8
-
9
- @Schema({ _id: false })
10
- export class NotificationRecipient {
11
- @Prop({ type: String })
12
- name?: string;
13
-
14
- @Prop({ type: String })
15
- username?: string;
16
-
17
- @Prop({ type: String })
18
- email?: string;
19
- }
20
-
21
- @Schema({ _id: false })
22
- export class NotificationEntity {
23
- @Prop({ type: String })
24
- name?: string;
25
-
26
- @Prop({ type: String })
27
- title?: string;
28
-
29
- @Prop({ type: String })
30
- _id?: string;
31
- }
32
-
33
- @Schema({ timestamps: true, collection: 'notifications' })
34
- export class Notification {
35
- @Prop({ type: NotificationRecipient, required: true })
36
- recipient: NotificationRecipient;
37
-
38
- @Prop({ required: true, type: String })
39
- event: string;
40
-
41
- @Prop({ type: [String], default: [] })
42
- channels: string[];
43
-
44
- @Prop({ type: String })
45
- title?: string;
46
-
47
- @Prop({ type: String })
48
- body?: string;
49
-
50
- @Prop({ type: NotificationEntity })
51
- entity?: NotificationEntity;
52
-
53
- @Prop({ type: Boolean, default: false })
54
- read: boolean;
55
-
56
- @Prop({ type: Date, default: Date.now })
57
- createdAt: Date;
58
- }
59
-
60
- export const NotificationSchema = SchemaFactory.createForClass(Notification);
61
- export const NotificationModel = MongooseModel('Notification', NotificationSchema);
@@ -1,29 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { HydratedDocument } from 'mongoose';
3
-
4
- export type OrganizationDocument = HydratedDocument<Organization>;
5
-
6
- @Schema({ timestamps: true, collection: 'organizations', strict: true })
7
- export class Organization {
8
- @Prop({ required: true, trim: true })
9
- corporateName: string;
10
-
11
- @Prop({ required: true, trim: true })
12
- fantasyName: string;
13
-
14
- @Prop({ required: true, unique: true, index: true })
15
- cnpj: string;
16
-
17
- @Prop()
18
- logo?: string;
19
-
20
- @Prop()
21
- logoSmall?: string;
22
-
23
- createdAt?: Date;
24
- updatedAt?: Date;
25
- }
26
-
27
- export const OrganizationSchema = SchemaFactory.createForClass(Organization);
28
-
29
- OrganizationSchema.index({ fantasyName: 'text', corporateName: 'text' });
@@ -1,65 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { HydratedDocument, Schema as MongooseSchema, Types, model as MongooseModel } from 'mongoose';
3
-
4
- export type PartyDocument = HydratedDocument<Party>;
5
-
6
- @Schema({ _id: false })
7
- export class Address {
8
- @Prop() zipcode: string;
9
- @Prop() city: string;
10
- @Prop() state: string;
11
- @Prop() street: string;
12
- @Prop() number: string;
13
- @Prop() complement: string;
14
- }
15
- export const AddressSchema = SchemaFactory.createForClass(Address);
16
-
17
- @Schema({ _id: false })
18
- export class Company {
19
- @Prop() legalName: string;
20
- @Prop() document: string;
21
- @Prop() bank: string;
22
- @Prop() agency: string;
23
- @Prop() account: string;
24
- @Prop() digit: string;
25
- @Prop() pix: string;
26
- @Prop() email: string;
27
- @Prop({ required: false }) omieGrapaId?: string;
28
- @Prop({ required: false }) omieOmaId?: string;
29
- }
30
- export const CompanySchema = SchemaFactory.createForClass(Company);
31
-
32
- @Schema({ _id: false })
33
- export class Individual {
34
- @Prop() rg: string;
35
- @Prop() cpf: string;
36
- @Prop() birthday: Date;
37
- @Prop() maritalStatus: string;
38
- @Prop() nationality: string;
39
- @Prop() profession: string;
40
- }
41
- export const IndividualSchema = SchemaFactory.createForClass(Individual);
42
-
43
- @Schema({ timestamps: true })
44
- export class Party {
45
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
46
- _id?: Types.ObjectId;
47
-
48
- @Prop() name: string;
49
- @Prop({ required: false }) email?: string;
50
- @Prop({ required: false }) phone?: string;
51
- @Prop({ required: false }) picture?: string;
52
- @Prop({ type: AddressSchema, required: false }) address?: Address;
53
- @Prop({ type: CompanySchema, required: false }) company?: Company;
54
- @Prop({ type: IndividualSchema, required: false }) individual?: Individual;
55
- @Prop({ default: Date.now, required: false }) createdAt?: Date;
56
- @Prop({ default: Date.now, required: false }) updatedAt?: Date;
57
- }
58
- export const PartySchema = SchemaFactory.createForClass(Party);
59
-
60
- PartySchema.index({ name: 1 });
61
- PartySchema.index({ 'company.document': 1 });
62
- PartySchema.index({ 'company.legalName': 1 });
63
- PartySchema.index({ createdAt: -1 });
64
-
65
- export const PartyModel = MongooseModel('Party', PartySchema);
@@ -1,275 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
-
3
- import {
4
- HydratedDocument,
5
- Schema as MongooseSchema,
6
- Types,
7
- model as MongooseModel
8
- } from 'mongoose';
9
-
10
- import { Influencer } from './influencer.schema';
11
- import { Supplier } from './supplier.schema';
12
- import { Action } from './action.schema';
13
- import { Recruitment } from './recruitment.schema';
14
- import { Sale } from './sale.schema';
15
- import { Note } from './note.schema';
16
-
17
- export type PaymentDocument = HydratedDocument<Payment>;
18
-
19
- @Schema({ _id: false })
20
- class Requester {
21
- @Prop()
22
- name: string;
23
-
24
- @Prop()
25
- email: string;
26
-
27
- @Prop()
28
- team: string;
29
- }
30
- const RequesterSchema = SchemaFactory.createForClass(Requester);
31
-
32
- @Schema({ _id: false })
33
- export class Review {
34
- @Prop()
35
- revisedDueDate: Date;
36
-
37
- @Prop()
38
- revisedIssueDate: Date;
39
- }
40
- export const ReviewSchema = SchemaFactory.createForClass(Review);
41
-
42
- @Schema({ _id: false })
43
- export class Pending {
44
- @Prop({ type: RequesterSchema, required: true })
45
- requester: Requester;
46
-
47
- @Prop({
48
- type: String,
49
- enum: [
50
- "influencer",
51
- "advisor",
52
- "employee_refund",
53
- "influencer_extra",
54
- "influencer_refund",
55
- "partlog",
56
- "airplane_ticket",
57
- "hotel_ticket",
58
- "supplier",
59
- "rumo_certo",
60
- "correios",
61
- "conta_simples",
62
- "motoboy_bruno",
63
- "motoboy_others",
64
- "commission"
65
- ]
66
- })
67
- type:
68
- "influencer" |
69
- "advisor" |
70
- "employee_refund" |
71
- "influencer_extra" |
72
- "influencer_refund" |
73
- "partlog" |
74
- "airplane_ticket" |
75
- "hotel_ticket" |
76
- "supplier" |
77
- "rumo_certo" |
78
- "correios" |
79
- "conta_simples" |
80
- "motoboy_bruno" |
81
- "motoboy_others" |
82
- "commission";
83
-
84
- @Prop({
85
- type: String,
86
- enum: [
87
- 'Envio SP',
88
- 'Envio Outros',
89
- 'Passagem',
90
- 'Hospedagem',
91
- 'Compras',
92
- 'Logistica Time',
93
- 'Outros'
94
- ],
95
- required: false
96
- })
97
- purpose?: 'Envio SP' | 'Envio Outros' | 'Passagem' | 'Hospedagem' | 'Compras' | 'Logistica Time' | 'Outros';
98
-
99
- @Prop({
100
- type: String,
101
- enum: [
102
- 'Originals',
103
- 'Running',
104
- 'Football',
105
- 'Training',
106
- 'Omni'
107
- ],
108
- required: false
109
- })
110
- adidasCategory?: 'Originals' | 'Running' | 'Football' | 'Training' | 'Omni';
111
-
112
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Influencer'})
113
- influencer?: Types.ObjectId | Influencer;
114
-
115
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Supplier'})
116
- supplier?: Types.ObjectId | Supplier;
117
-
118
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Recruitment' })
119
- recruitment?: Types.ObjectId | Recruitment;
120
-
121
- @Prop() value: number;
122
-
123
- @Prop() description: string;
124
-
125
- @Prop() installmentNumber: number;
126
-
127
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Sale', required: false })
128
- sale?: Types.ObjectId | Sale;
129
-
130
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Action' })
131
- action?: Types.ObjectId | Action;
132
-
133
- @Prop({ type: [MongooseSchema.Types.ObjectId], ref: 'Commission', required: false, default: [] })
134
- commissions?: Types.ObjectId[];
135
- }
136
- export const PendingSchema = SchemaFactory.createForClass(Pending);
137
-
138
- @Schema({ _id: false })
139
- export class Requested {
140
- @Prop()
141
- date: Date;
142
- }
143
- export const RequestedSchema = SchemaFactory.createForClass(Requested);
144
-
145
- @Schema({ _id: false })
146
- class ReceivedNote {
147
- @Prop() text: string;
148
-
149
- @Prop() email: string;
150
- }
151
- const ReceivedNoteSchema = SchemaFactory.createForClass(ReceivedNote);
152
-
153
- @Schema({ _id: false })
154
- export class Received {
155
- @Prop() takerConfirmed: boolean;
156
-
157
- @Prop() descriptionConfirmed: boolean;
158
-
159
- @Prop() bankDataConfirmed: boolean;
160
-
161
- @Prop() valueConfirmed: boolean;
162
-
163
- @Prop({ type: [ReceivedNoteSchema], default: [] })
164
- resendNotes: ReceivedNote[];
165
- }
166
- export const ReceivedSchema = SchemaFactory.createForClass(Received);
167
-
168
- @Schema({ _id: false })
169
- export class Queued {
170
- @Prop() issueDate: Date;
171
-
172
- @Prop() dueDate: Date;
173
-
174
- @Prop() code: string;
175
- }
176
- export const QueuedSchema = SchemaFactory.createForClass(Queued);
177
-
178
- @Schema({ _id: false })
179
- export class Paid {
180
- @Prop()
181
- date: Date;
182
- }
183
- export const PaidSchema = SchemaFactory.createForClass(Paid);
184
-
185
- @Schema({ _id: false })
186
- export class Canceled {
187
- @Prop() reason: string;
188
-
189
- @Prop() details: string;
190
- }
191
- export const CanceledSchema = SchemaFactory.createForClass(Canceled);
192
-
193
- @Schema({ _id: false })
194
- export class Attachment {
195
- @Prop() name: string;
196
-
197
- @Prop() url: string;
198
- }
199
- export const AttachmentSchema = SchemaFactory.createForClass(Attachment);
200
-
201
- @Schema({ timestamps: true })
202
- export class Payment {
203
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
204
- _id?: Types.ObjectId;
205
-
206
- @Prop() title: string;
207
-
208
- @Prop({
209
- type: String,
210
- enum: [ 'pending', 'review', 'awaiting', 'requested', 'received', 'queued', 'paid', 'client', 'canceled'],
211
- })
212
- phase: 'pending' | 'review' | 'approval' | 'awaiting' | 'requested' | 'received' | 'queued' | 'paid' | 'client' | 'canceled';
213
-
214
- @Prop({
215
- type: [Attachment],
216
- required: false,
217
- default: []
218
- })
219
- attachments?: Attachment[];
220
-
221
- @Prop({ type: MongooseSchema.Types.ObjectId })
222
- organization: Types.ObjectId ;
223
-
224
- @Prop({ type: PendingSchema, required: false })
225
- pending?: Pending;
226
-
227
- @Prop({ type: ReviewSchema, required: false })
228
- review?: Review;
229
-
230
- @Prop({ type: RequestedSchema, required: false })
231
- requested?: Requested;
232
-
233
- @Prop({ type: ReceivedSchema, required: false })
234
- received?: Received;
235
-
236
- @Prop({ type: QueuedSchema, required: false })
237
- queued?: Queued;
238
-
239
- @Prop({ type: PaidSchema, required: false })
240
- paid?: Paid;
241
-
242
- @Prop({ type: CanceledSchema, required: false })
243
- canceled?: Canceled;
244
-
245
- @Prop({ type: [Note], required: false, default: [] })
246
- notes?: Note[];
247
-
248
- @Prop({ type: [{ type: MongooseSchema.Types.ObjectId }], required: false, default: [] })
249
- tags?: Types.ObjectId[];
250
-
251
- @Prop()
252
- omieId?: string;
253
-
254
- @Prop({ default: Date.now, required: false })
255
- createdAt?: Date;
256
-
257
- @Prop({ default: Date.now, required: false })
258
- updatedAt?: Date;
259
- }
260
-
261
- export const PaymentSchema = SchemaFactory.createForClass(Payment);
262
-
263
- PaymentSchema.index({ 'pending.sale': 1 });
264
- PaymentSchema.index({ 'pending.sale': 1, 'pending.installmentNumber': 1 });
265
- PaymentSchema.index({ 'pending.influencer': 1 });
266
- PaymentSchema.index({ 'pending.recruitment': 1 });
267
- PaymentSchema.index({ 'pending.action': 1 });
268
- PaymentSchema.index({ 'pending.supplier': 1 });
269
- PaymentSchema.index({ 'pending.recruitment': 1, 'pending.type': 1 });
270
- PaymentSchema.index({ 'pending.influencer': 1, 'pending.recruitment': 1, 'pending.action': 1, 'pending.type': 1 });
271
- PaymentSchema.index({ organization: 1, phase: 1 });
272
- PaymentSchema.index({ organization: 1, 'queued.issueDate': 1 });
273
- PaymentSchema.index({ omieId: 1 }, { sparse: true });
274
-
275
- export const PaymentModel = MongooseModel('Payment', PaymentSchema);
@@ -1,77 +0,0 @@
1
- import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
- import { HydratedDocument, Schema as MongooseSchema, Types, model as MongooseModel } from 'mongoose';
3
- import { Influencer } from './influencer.schema';
4
- import { Client } from './client.schema';
5
-
6
- export type ProfileDocument = HydratedDocument<Profile>;
7
-
8
- export const PROFILE_OPTIN_STATUS_VALUES = ['active', 'inactive'] as const;
9
- export type ProfileOptinStatus = (typeof PROFILE_OPTIN_STATUS_VALUES)[number];
10
-
11
- @Schema({ timestamps: true })
12
- export class Profile {
13
- @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
14
- _id?: Types.ObjectId;
15
-
16
- @Prop()
17
- username: string;
18
-
19
- @Prop()
20
- followers: number;
21
-
22
- // Atualizado pelo profile-sync-worker a partir do social_profile da Primetag.
23
- @Prop({ type: Date, required: false })
24
- followersUpdatedAt?: Date;
25
-
26
- @Prop()
27
- picture: string;
28
-
29
- @Prop({ type: Date, required: false })
30
- pictureUpdatedAt?: Date;
31
-
32
- @Prop({ type: Number, required: false })
33
- primetagSocialProfileId?: number;
34
-
35
- // Opt-in na Primetag (conta conectada): 'active' quando o social_profile
36
- // vem com connection_status CONNECTED, 'inactive' pra qualquer outro valor.
37
- // Ausente enquanto o perfil não foi sincronizado.
38
- @Prop({ type: String, enum: PROFILE_OPTIN_STATUS_VALUES, required: false })
39
- optinStatus?: ProfileOptinStatus;
40
-
41
- @Prop({ type: Date, required: false })
42
- optinUpdatedAt?: Date;
43
-
44
- // Último aviso de mudança de opt-in (no máximo um por perfil por dia).
45
- @Prop({ type: Date, required: false })
46
- optinNotifiedAt?: Date;
47
-
48
- @Prop()
49
- socialnetwork: string;
50
-
51
- @Prop()
52
- type: string;
53
-
54
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Influencer' })
55
- influencer: Types.ObjectId | Influencer;
56
-
57
- // Perfil da própria marca (ex.: @marca no Instagram). Um perfil pertence a um
58
- // Influencer OU a um Client, nunca aos dois.
59
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Client', required: false })
60
- client?: Types.ObjectId | Client;
61
-
62
- @Prop({ default: Date.now, required: false })
63
- createdAt?: Date;
64
-
65
- @Prop({ default: Date.now, required: false })
66
- updatedAt?: Date;
67
- }
68
-
69
- export const ProfileSchema = SchemaFactory.createForClass(Profile);
70
-
71
- ProfileSchema.index({ influencer: 1 });
72
- ProfileSchema.index({ client: 1 }, { sparse: true });
73
- ProfileSchema.index({ username: 1 });
74
- ProfileSchema.index({ username: 1, influencer: 1 });
75
-
76
- export const ProfileModel = MongooseModel('Profile', ProfileSchema);
77
-