@grapadigital/shared-schemas 1.0.241 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/index.d.ts +42 -42
  2. package/dist/schemas/action.schema.d.ts +13 -38
  3. package/dist/schemas/action.schema.js +81 -64
  4. package/dist/schemas/assignment.schema.d.ts +6 -31
  5. package/dist/schemas/assignment.schema.js +44 -44
  6. package/dist/schemas/benchmark.schema.d.ts +5 -30
  7. package/dist/schemas/benchmark.schema.js +11 -6
  8. package/dist/schemas/campaign.schema.d.ts +4 -29
  9. package/dist/schemas/campaign.schema.js +4 -4
  10. package/dist/schemas/client.schema.d.ts +30 -91
  11. package/dist/schemas/client.schema.js +73 -71
  12. package/dist/schemas/comment.schema.d.ts +9 -34
  13. package/dist/schemas/comment.schema.js +42 -37
  14. package/dist/schemas/commission.schema.d.ts +7 -32
  15. package/dist/schemas/commission.schema.js +10 -10
  16. package/dist/schemas/content-capture-process.schema.d.ts +12 -37
  17. package/dist/schemas/content-capture-process.schema.js +24 -17
  18. package/dist/schemas/content-draft.schema.d.ts +4 -29
  19. package/dist/schemas/content-draft.schema.js +5 -5
  20. package/dist/schemas/content.schema.d.ts +20 -45
  21. package/dist/schemas/content.schema.js +84 -74
  22. package/dist/schemas/contract.schema.d.ts +5 -30
  23. package/dist/schemas/contract.schema.js +5 -5
  24. package/dist/schemas/creative.schema.d.ts +11 -36
  25. package/dist/schemas/creative.schema.js +22 -31
  26. package/dist/schemas/export-comments-job.schema.d.ts +4 -29
  27. package/dist/schemas/export-comments-job.schema.js +6 -6
  28. package/dist/schemas/group.schema.d.ts +2 -27
  29. package/dist/schemas/group.schema.js +5 -5
  30. package/dist/schemas/influencer.schema.d.ts +12 -37
  31. package/dist/schemas/influencer.schema.js +16 -18
  32. package/dist/schemas/invoice.schema.d.ts +6 -31
  33. package/dist/schemas/invoice.schema.js +42 -32
  34. package/dist/schemas/job.schema.d.ts +4 -29
  35. package/dist/schemas/job.schema.js +14 -14
  36. package/dist/schemas/lead.schema.d.ts +15 -40
  37. package/dist/schemas/lead.schema.js +67 -64
  38. package/dist/schemas/log.schema.d.ts +3 -28
  39. package/dist/schemas/log.schema.js +24 -24
  40. package/dist/schemas/note.schema.d.ts +3 -28
  41. package/dist/schemas/note.schema.js +9 -9
  42. package/dist/schemas/notifications.schema.d.ts +3 -28
  43. package/dist/schemas/notifications.schema.js +8 -8
  44. package/dist/schemas/organization.schema.d.ts +2 -27
  45. package/dist/schemas/organization.schema.js +4 -4
  46. package/dist/schemas/party.schema.d.ts +6 -31
  47. package/dist/schemas/party.schema.js +11 -11
  48. package/dist/schemas/payment.schema.d.ts +20 -45
  49. package/dist/schemas/payment.schema.js +63 -54
  50. package/dist/schemas/profile.schema.d.ts +5 -30
  51. package/dist/schemas/profile.schema.js +6 -6
  52. package/dist/schemas/project.schema.d.ts +9 -34
  53. package/dist/schemas/project.schema.js +13 -13
  54. package/dist/schemas/prospect.schema.d.ts +6 -31
  55. package/dist/schemas/prospect.schema.js +9 -9
  56. package/dist/schemas/recruitment.schema.d.ts +19 -44
  57. package/dist/schemas/recruitment.schema.js +36 -36
  58. package/dist/schemas/responsible.schema.d.ts +1 -27
  59. package/dist/schemas/responsible.schema.js +6 -6
  60. package/dist/schemas/sale.schema.d.ts +19 -44
  61. package/dist/schemas/sale.schema.js +43 -51
  62. package/dist/schemas/script.schema.d.ts +11 -36
  63. package/dist/schemas/script.schema.js +21 -30
  64. package/dist/schemas/snapshot.schema.d.ts +5 -30
  65. package/dist/schemas/snapshot.schema.js +6 -6
  66. package/dist/schemas/store-visit.schema.d.ts +3 -28
  67. package/dist/schemas/store-visit.schema.js +21 -17
  68. package/dist/schemas/store.schema.d.ts +5 -30
  69. package/dist/schemas/store.schema.js +8 -8
  70. package/dist/schemas/supplier.schema.d.ts +4 -29
  71. package/dist/schemas/supplier.schema.js +3 -3
  72. package/dist/schemas/tag.schema.d.ts +2 -27
  73. package/dist/schemas/tag.schema.js +5 -5
  74. package/dist/schemas/task.schema.d.ts +11 -36
  75. package/dist/schemas/task.schema.js +67 -67
  76. package/dist/schemas/token.schema.d.ts +3 -28
  77. package/dist/schemas/token.schema.js +3 -3
  78. package/dist/schemas/trigger.schema.d.ts +3 -28
  79. package/dist/schemas/trigger.schema.js +5 -5
  80. package/dist/schemas/user.schema.d.ts +3 -28
  81. package/dist/schemas/user.schema.js +7 -7
  82. package/dist/schemas/webhook.schema.d.ts +6 -31
  83. package/dist/schemas/webhook.schema.js +10 -10
  84. package/dist/utils/merge-metrics-breakdown.util.d.ts +1 -1
  85. package/dist/utils/merge-metrics-breakdown.util.js +7 -2
  86. package/dist/utils/normalize-content-link.util.js +7 -7
  87. package/package.json +29 -16
  88. package/.eslintrc.json +0 -28
  89. package/.prettierrc +0 -4
  90. package/dist/schemas/profile-followers-snapshot.schema.d.ts +0 -67
  91. package/dist/schemas/profile-followers-snapshot.schema.js +0 -65
  92. package/dist/schemas/schedule.schema.d.ts +0 -73
  93. package/dist/schemas/schedule.schema.js +0 -116
  94. package/dist/utils/cost-per-impact.util.d.ts +0 -37
  95. package/dist/utils/cost-per-impact.util.js +0 -72
  96. package/dist/utils/influencer-contract.util.d.ts +0 -32
  97. package/dist/utils/influencer-contract.util.js +0 -77
  98. package/docs/code-review.md +0 -27
  99. package/docs/constitution.md +0 -75
  100. package/docs/specs/GD-692.md +0 -112
  101. package/docs/specs/GD-761.md +0 -94
  102. package/index.d.ts +0 -3
  103. package/src/index.ts +0 -42
  104. package/src/schemas/action.schema.ts +0 -328
  105. package/src/schemas/assignment.schema.ts +0 -154
  106. package/src/schemas/benchmark.schema.ts +0 -39
  107. package/src/schemas/campaign.schema.ts +0 -38
  108. package/src/schemas/client.schema.ts +0 -319
  109. package/src/schemas/comment.schema.ts +0 -216
  110. package/src/schemas/commission.schema.ts +0 -108
  111. package/src/schemas/content-capture-process.schema.ts +0 -195
  112. package/src/schemas/content-draft.schema.ts +0 -49
  113. package/src/schemas/content.schema.ts +0 -688
  114. package/src/schemas/contract.schema.ts +0 -44
  115. package/src/schemas/creative.schema.ts +0 -256
  116. package/src/schemas/export-comments-job.schema.ts +0 -59
  117. package/src/schemas/group.schema.ts +0 -23
  118. package/src/schemas/influencer.schema.ts +0 -184
  119. package/src/schemas/invoice.schema.ts +0 -164
  120. package/src/schemas/job.schema.ts +0 -111
  121. package/src/schemas/lead.schema.ts +0 -372
  122. package/src/schemas/log.schema.ts +0 -91
  123. package/src/schemas/note.schema.ts +0 -34
  124. package/src/schemas/notifications.schema.ts +0 -61
  125. package/src/schemas/organization.schema.ts +0 -29
  126. package/src/schemas/party.schema.ts +0 -65
  127. package/src/schemas/payment.schema.ts +0 -275
  128. package/src/schemas/profile.schema.ts +0 -77
  129. package/src/schemas/project.schema.ts +0 -116
  130. package/src/schemas/prospect.schema.ts +0 -62
  131. package/src/schemas/recruitment.schema.ts +0 -277
  132. package/src/schemas/responsible.schema.ts +0 -27
  133. package/src/schemas/sale.schema.ts +0 -297
  134. package/src/schemas/script.schema.ts +0 -235
  135. package/src/schemas/snapshot.schema.ts +0 -55
  136. package/src/schemas/store-visit.schema.ts +0 -68
  137. package/src/schemas/store.schema.ts +0 -52
  138. package/src/schemas/supplier.schema.ts +0 -12
  139. package/src/schemas/tag.schema.ts +0 -26
  140. package/src/schemas/task.schema.ts +0 -205
  141. package/src/schemas/token.schema.ts +0 -42
  142. package/src/schemas/trigger.schema.ts +0 -48
  143. package/src/schemas/user.schema.ts +0 -59
  144. package/src/schemas/webhook.schema.ts +0 -81
  145. package/src/utils/merge-metrics-breakdown.util.ts +0 -51
  146. package/src/utils/normalize-content-link.util.ts +0 -31
  147. package/tsconfig.build.json +0 -5
  148. package/tsconfig.json +0 -29
@@ -1,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
-