@grapadigital/shared-schemas 1.0.216 → 1.0.218

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 CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './schemas/responsible.schema';
1
2
  export * from './schemas/action.schema';
2
3
  export * from './schemas/prospect.schema';
3
4
  export * from './schemas/client.schema';
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.NoteMentionSchema = exports.NoteMention = exports.NoteSchema = exports.Note = void 0;
18
+ __exportStar(require("./schemas/responsible.schema"), exports);
18
19
  __exportStar(require("./schemas/action.schema"), exports);
19
20
  __exportStar(require("./schemas/prospect.schema"), exports);
20
21
  __exportStar(require("./schemas/client.schema"), exports);
@@ -30,36 +30,8 @@ import { Client } from './client.schema';
30
30
  import { Sale } from './sale.schema';
31
31
  import { Campaign } from './campaign.schema';
32
32
  import { Note } from './note.schema';
33
+ import { Responsible } from './responsible.schema';
33
34
  export type ActionDocument = HydratedDocument<Action>;
34
- export declare class Responsible {
35
- name: string;
36
- team: string;
37
- email: string;
38
- }
39
- export declare const ResponsibleSchema: MongooseSchema<Responsible, import("mongoose").Model<Responsible, any, any, any, import("mongoose").Document<unknown, any, Responsible, any, {}> & Responsible & {
40
- _id: Types.ObjectId;
41
- } & {
42
- __v: number;
43
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Responsible, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Responsible>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Responsible> & {
44
- _id: Types.ObjectId;
45
- } & {
46
- __v: number;
47
- }>;
48
- /**
49
- * @deprecated Use `Responsible` or `Responsible[]` on Action.responsible
50
- */
51
- export declare class ActionResponsible extends Responsible {
52
- }
53
- export declare const ActionResponsibleSchema: MongooseSchema<ActionResponsible, import("mongoose").Model<ActionResponsible, any, any, any, import("mongoose").Document<unknown, any, ActionResponsible, any, {}> & ActionResponsible & {
54
- _id: Types.ObjectId;
55
- } & {
56
- __v: number;
57
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, ActionResponsible, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<ActionResponsible>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<ActionResponsible> & {
58
- _id: Types.ObjectId;
59
- } & {
60
- __v: number;
61
- }>;
62
- export { ActionResponsible as Responsibles, ActionResponsibleSchema as ResponsiblesSchema };
63
35
  export declare const ACTION_BUSINESS_UNIT_VALUES: readonly ["service", "comercial", "squad_a", "squad_b"];
64
36
  export type ActionBusinessUnit = (typeof ACTION_BUSINESS_UNIT_VALUES)[number];
65
37
  export declare class ActionPromptConfig {
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ActionModel = exports.ActionSchema = exports.Action = exports.ACTION_STATUS_VALUES = exports.ActionPromptConfigSchema = exports.ActionPromptConfig = exports.ACTION_BUSINESS_UNIT_VALUES = exports.ResponsiblesSchema = exports.Responsibles = exports.ActionResponsibleSchema = exports.ActionResponsible = exports.ResponsibleSchema = exports.Responsible = void 0;
12
+ exports.ActionModel = exports.ActionSchema = exports.Action = exports.ACTION_STATUS_VALUES = exports.ActionPromptConfigSchema = exports.ActionPromptConfig = exports.ACTION_BUSINESS_UNIT_VALUES = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const swagger_1 = require("@nestjs/swagger");
15
15
  const mongoose_2 = require("mongoose");
@@ -19,37 +19,7 @@ const client_schema_1 = require("./client.schema");
19
19
  const sale_schema_1 = require("./sale.schema");
20
20
  const campaign_schema_1 = require("./campaign.schema");
21
21
  const note_schema_1 = require("./note.schema");
22
- let Responsible = class Responsible {
23
- };
24
- __decorate([
25
- (0, swagger_1.ApiProperty)({ example: 'Maria Oliveira' }),
26
- (0, mongoose_1.Prop)(),
27
- __metadata("design:type", String)
28
- ], Responsible.prototype, "name", void 0);
29
- __decorate([
30
- (0, swagger_1.ApiProperty)({ example: 'Comercial' }),
31
- (0, mongoose_1.Prop)(),
32
- __metadata("design:type", String)
33
- ], Responsible.prototype, "team", void 0);
34
- __decorate([
35
- (0, swagger_1.ApiProperty)({ example: 'maria@empresa.com' }),
36
- (0, mongoose_1.Prop)(),
37
- __metadata("design:type", String)
38
- ], Responsible.prototype, "email", void 0);
39
- Responsible = __decorate([
40
- (0, mongoose_1.Schema)({ _id: false })
41
- ], Responsible);
42
- exports.Responsible = Responsible;
43
- exports.ResponsibleSchema = mongoose_1.SchemaFactory.createForClass(Responsible);
44
- /**
45
- * @deprecated Use `Responsible` or `Responsible[]` on Action.responsible
46
- */
47
- class ActionResponsible extends Responsible {
48
- }
49
- exports.ActionResponsible = ActionResponsible;
50
- exports.Responsibles = ActionResponsible;
51
- exports.ActionResponsibleSchema = mongoose_1.SchemaFactory.createForClass(ActionResponsible);
52
- exports.ResponsiblesSchema = exports.ActionResponsibleSchema;
22
+ const responsible_schema_1 = require("./responsible.schema");
53
23
  exports.ACTION_BUSINESS_UNIT_VALUES = [
54
24
  'service',
55
25
  'comercial',
@@ -234,8 +204,8 @@ __decorate([
234
204
  __metadata("design:type", mongoose_2.Types.ObjectId)
235
205
  ], Action.prototype, "organization", void 0);
236
206
  __decorate([
237
- (0, swagger_1.ApiProperty)({ type: () => [Responsible] }),
238
- (0, mongoose_1.Prop)({ type: [exports.ResponsibleSchema], required: true }),
207
+ (0, swagger_1.ApiProperty)({ type: () => [responsible_schema_1.Responsible] }),
208
+ (0, mongoose_1.Prop)({ type: [responsible_schema_1.ResponsibleSchema], required: true }),
239
209
  __metadata("design:type", Array)
240
210
  ], Action.prototype, "responsible", void 0);
241
211
  __decorate([
@@ -25,6 +25,7 @@
25
25
  /// <reference types="mongoose/types/inferrawdoctype" />
26
26
  import { HydratedDocument, Schema as MongooseSchema, Types } from 'mongoose';
27
27
  import { Action } from './action.schema';
28
+ import { Responsible } from './responsible.schema';
28
29
  export type AssignmentDocument = HydratedDocument<Assignment>;
29
30
  export declare const ASSIGNMENT_TYPE_VALUES: readonly ["report", "curation", "opt-in", "metrics-monitoring", "data-update", "study"];
30
31
  export type AssignmentType = (typeof ASSIGNMENT_TYPE_VALUES)[number];
@@ -54,7 +55,7 @@ export declare class Assignment {
54
55
  organization: Types.ObjectId;
55
56
  type: AssignmentType;
56
57
  title: string;
57
- responsible?: Types.ObjectId;
58
+ responsible?: Responsible[];
58
59
  startDate?: Date | null;
59
60
  dueDate?: Date | null;
60
61
  status: AssignmentStatus;
@@ -13,6 +13,7 @@ exports.AssignmentModel = exports.AssignmentSchema = exports.Assignment = export
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const swagger_1 = require("@nestjs/swagger");
15
15
  const mongoose_2 = require("mongoose");
16
+ const responsible_schema_1 = require("./responsible.schema");
16
17
  exports.ASSIGNMENT_TYPE_VALUES = [
17
18
  'report',
18
19
  'curation',
@@ -105,9 +106,9 @@ __decorate([
105
106
  __metadata("design:type", String)
106
107
  ], Assignment.prototype, "title", void 0);
107
108
  __decorate([
108
- (0, swagger_1.ApiProperty)({ example: '64bfc3a78d3f1e2a1234567a', required: false }),
109
- (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, required: false }),
110
- __metadata("design:type", mongoose_2.Types.ObjectId)
109
+ (0, swagger_1.ApiProperty)({ type: () => [responsible_schema_1.Responsible], required: false }),
110
+ (0, mongoose_1.Prop)({ type: [responsible_schema_1.ResponsibleSchema], required: false, default: [] }),
111
+ __metadata("design:type", Array)
111
112
  ], Assignment.prototype, "responsible", void 0);
112
113
  __decorate([
113
114
  (0, swagger_1.ApiProperty)({ example: '2026-08-25T00:00:00.000Z', required: false }),
@@ -163,5 +164,5 @@ exports.AssignmentSchema.index({ action: 1 });
163
164
  exports.AssignmentSchema.index({ organization: 1, status: 1 });
164
165
  exports.AssignmentSchema.index({ organization: 1, dueDate: 1 });
165
166
  exports.AssignmentSchema.index({ seriesId: 1 });
166
- exports.AssignmentSchema.index({ responsible: 1, dueDate: 1 });
167
+ exports.AssignmentSchema.index({ 'responsible.email': 1, dueDate: 1 });
167
168
  exports.AssignmentModel = (0, mongoose_2.model)('Assignment', exports.AssignmentSchema);
@@ -26,7 +26,14 @@
26
26
  import { HydratedDocument, Schema as MongooseSchema, Types } from 'mongoose';
27
27
  import { Party } from './party.schema';
28
28
  import { Profile } from './profile.schema';
29
+ import { Responsible } from './responsible.schema';
29
30
  export type ClientDocument = HydratedDocument<Client>;
31
+ /**
32
+ * Personalizações de cliente: ligam telas e regras que valem só para ele.
33
+ * Ver GD-683.
34
+ */
35
+ export declare const CLIENT_CUSTOMIZATION_VALUES: readonly ["samsung"];
36
+ export type ClientCustomization = (typeof CLIENT_CUSTOMIZATION_VALUES)[number];
30
37
  export declare class Cluster {
31
38
  key: string;
32
39
  label: string;
@@ -95,10 +102,13 @@ export declare const NicheItemSchema: MongooseSchema<NicheItem, import("mongoose
95
102
  } & {
96
103
  __v: number;
97
104
  }>;
105
+ /**
106
+ * Responsáveis do cliente: `report` são usuários da plataforma que cuidam dos
107
+ * relatórios; `brand` é o contato do lado da marca (texto livre, não é usuário).
108
+ */
98
109
  export declare class ClientResponsible {
99
- name: string;
100
- team: string;
101
- email: string;
110
+ report?: Responsible[];
111
+ brand?: string;
102
112
  }
103
113
  export declare const ClientResponsibleSchema: MongooseSchema<ClientResponsible, import("mongoose").Model<ClientResponsible, any, any, any, import("mongoose").Document<unknown, any, ClientResponsible, any, {}> & ClientResponsible & {
104
114
  _id: Types.ObjectId;
@@ -132,6 +142,13 @@ export declare class Client extends Party {
132
142
  * (Antigo `hasReport`.)
133
143
  */
134
144
  hasGenIAAnalysis: boolean;
145
+ /**
146
+ * Personalização do cliente (ex.: `samsung`): liga as telas e regras
147
+ * específicas dele no Flow e no Hub. Ausente ou `null` = comportamento
148
+ * padrão. Nunca comparar id de cliente no código, sempre este campo.
149
+ * Ver GD-683.
150
+ */
151
+ customization?: ClientCustomization | null;
135
152
  /**
136
153
  * Client de organização (ex.: "Oma Creators"): representa a organização
137
154
  * inteira, não uma marca. No hub, mostra todas as actions dessa organização
@@ -140,8 +157,7 @@ export declare class Client extends Party {
140
157
  * ou `Action.hasGenIAAnalysis`.
141
158
  */
142
159
  organization?: Types.ObjectId;
143
- reportResponsible?: ClientResponsible;
144
- brandResponsible?: string;
160
+ responsible?: ClientResponsible;
145
161
  profiles?: Types.ObjectId[] | Profile[];
146
162
  }
147
163
  export declare const ClientSchema: MongooseSchema<Client, import("mongoose").Model<Client, any, any, any, import("mongoose").Document<unknown, any, Client, any, {}> & Client & Required<{
@@ -9,11 +9,17 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ClientModel = exports.ClientSchema = exports.Client = exports.ClientResponsibleSchema = exports.ClientResponsible = exports.NicheItemSchema = exports.NicheItem = exports.AgencyCommissionPeriodSchema = exports.AgencyCommissionPeriod = exports.CommissionRangeSchema = exports.CommissionRange = exports.CompanySchema = exports.Company = exports.ClusterSchema = exports.Cluster = void 0;
12
+ exports.ClientModel = exports.ClientSchema = exports.Client = exports.ClientResponsibleSchema = exports.ClientResponsible = exports.NicheItemSchema = exports.NicheItem = exports.AgencyCommissionPeriodSchema = exports.AgencyCommissionPeriod = exports.CommissionRangeSchema = exports.CommissionRange = exports.CompanySchema = exports.Company = exports.ClusterSchema = exports.Cluster = exports.CLIENT_CUSTOMIZATION_VALUES = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const swagger_1 = require("@nestjs/swagger");
15
15
  const mongoose_2 = require("mongoose");
16
16
  const party_schema_1 = require("./party.schema");
17
+ const responsible_schema_1 = require("./responsible.schema");
18
+ /**
19
+ * Personalizações de cliente: ligam telas e regras que valem só para ele.
20
+ * Ver GD-683.
21
+ */
22
+ exports.CLIENT_CUSTOMIZATION_VALUES = ['samsung'];
17
23
  let Cluster = class Cluster {
18
24
  };
19
25
  __decorate([
@@ -101,23 +107,22 @@ NicheItem = __decorate([
101
107
  ], NicheItem);
102
108
  exports.NicheItem = NicheItem;
103
109
  exports.NicheItemSchema = mongoose_1.SchemaFactory.createForClass(NicheItem);
110
+ /**
111
+ * Responsáveis do cliente: `report` são usuários da plataforma que cuidam dos
112
+ * relatórios; `brand` é o contato do lado da marca (texto livre, não é usuário).
113
+ */
104
114
  let ClientResponsible = class ClientResponsible {
105
115
  };
106
116
  __decorate([
107
- (0, swagger_1.ApiProperty)({ example: 'Maria Oliveira' }),
108
- (0, mongoose_1.Prop)(),
109
- __metadata("design:type", String)
110
- ], ClientResponsible.prototype, "name", void 0);
111
- __decorate([
112
- (0, swagger_1.ApiProperty)({ example: 'Comercial' }),
113
- (0, mongoose_1.Prop)(),
114
- __metadata("design:type", String)
115
- ], ClientResponsible.prototype, "team", void 0);
117
+ (0, swagger_1.ApiProperty)({ type: () => [responsible_schema_1.Responsible], required: false }),
118
+ (0, mongoose_1.Prop)({ type: [responsible_schema_1.ResponsibleSchema], required: false, default: [] }),
119
+ __metadata("design:type", Array)
120
+ ], ClientResponsible.prototype, "report", void 0);
116
121
  __decorate([
117
- (0, swagger_1.ApiProperty)({ example: 'maria@empresa.com' }),
118
- (0, mongoose_1.Prop)(),
122
+ (0, swagger_1.ApiProperty)({ example: 'Maite', required: false }),
123
+ (0, mongoose_1.Prop)({ type: String, required: false }),
119
124
  __metadata("design:type", String)
120
- ], ClientResponsible.prototype, "email", void 0);
125
+ ], ClientResponsible.prototype, "brand", void 0);
121
126
  ClientResponsible = __decorate([
122
127
  (0, mongoose_1.Schema)({ _id: false })
123
128
  ], ClientResponsible);
@@ -169,6 +174,10 @@ __decorate([
169
174
  (0, mongoose_1.Prop)({ type: Boolean, default: false }),
170
175
  __metadata("design:type", Boolean)
171
176
  ], Client.prototype, "hasGenIAAnalysis", void 0);
177
+ __decorate([
178
+ (0, mongoose_1.Prop)({ type: String, enum: exports.CLIENT_CUSTOMIZATION_VALUES, required: false, default: null }),
179
+ __metadata("design:type", Object)
180
+ ], Client.prototype, "customization", void 0);
172
181
  __decorate([
173
182
  (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Organization', required: false }),
174
183
  __metadata("design:type", mongoose_2.Types.ObjectId)
@@ -176,11 +185,7 @@ __decorate([
176
185
  __decorate([
177
186
  (0, mongoose_1.Prop)({ type: exports.ClientResponsibleSchema, required: false }),
178
187
  __metadata("design:type", ClientResponsible)
179
- ], Client.prototype, "reportResponsible", void 0);
180
- __decorate([
181
- (0, mongoose_1.Prop)({ type: String, required: false }),
182
- __metadata("design:type", String)
183
- ], Client.prototype, "brandResponsible", void 0);
188
+ ], Client.prototype, "responsible", void 0);
184
189
  __decorate([
185
190
  (0, mongoose_1.Prop)([
186
191
  { type: mongoose_2.Schema.Types.ObjectId, ref: 'Profile', required: false },
@@ -25,6 +25,7 @@
25
25
  /// <reference types="mongoose/types/inferrawdoctype" />
26
26
  import { HydratedDocument, Schema as MongooseSchema, Types } from 'mongoose';
27
27
  import { Action } from './action.schema';
28
+ import { Responsible } from './responsible.schema';
28
29
  export type ContentCaptureProcessDocument = HydratedDocument<ContentCaptureProcess>;
29
30
  export declare class ContentCaptureProcessMetrics {
30
31
  impressionCount?: number | null;
@@ -94,40 +95,13 @@ export declare const ContentCaptureProcessItemSchema: MongooseSchema<ContentCapt
94
95
  } & {
95
96
  __v: number;
96
97
  }>;
97
- export declare class ContentCaptureProcessResponsibleContact {
98
- name?: string;
99
- team?: string;
100
- email?: string;
101
- }
102
- export declare const ContentCaptureProcessResponsibleContactSchema: MongooseSchema<ContentCaptureProcessResponsibleContact, import("mongoose").Model<ContentCaptureProcessResponsibleContact, any, any, any, import("mongoose").Document<unknown, any, ContentCaptureProcessResponsibleContact, any, {}> & ContentCaptureProcessResponsibleContact & {
103
- _id: Types.ObjectId;
104
- } & {
105
- __v: number;
106
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, ContentCaptureProcessResponsibleContact, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<ContentCaptureProcessResponsibleContact>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<ContentCaptureProcessResponsibleContact> & {
107
- _id: Types.ObjectId;
108
- } & {
109
- __v: number;
110
- }>;
111
- export declare class ContentCaptureProcessResponsible {
112
- service?: ContentCaptureProcessResponsibleContact[];
113
- }
114
- export declare const ContentCaptureProcessResponsibleSchema: MongooseSchema<ContentCaptureProcessResponsible, import("mongoose").Model<ContentCaptureProcessResponsible, any, any, any, import("mongoose").Document<unknown, any, ContentCaptureProcessResponsible, any, {}> & ContentCaptureProcessResponsible & {
115
- _id: Types.ObjectId;
116
- } & {
117
- __v: number;
118
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, ContentCaptureProcessResponsible, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<ContentCaptureProcessResponsible>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<ContentCaptureProcessResponsible> & {
119
- _id: Types.ObjectId;
120
- } & {
121
- __v: number;
122
- }>;
123
- export { ContentCaptureProcessResponsible as ContentCaptureProcessResponsibles, ContentCaptureProcessResponsibleSchema as ContentCaptureProcessResponsiblesSchema, };
124
98
  export declare class ContentCaptureProcess {
125
99
  _id?: Types.ObjectId;
126
100
  actionId: Types.ObjectId | Action;
127
101
  runId: string;
128
102
  actionTitle: string;
129
103
  primetagId?: string;
130
- responsible?: ContentCaptureProcessResponsible;
104
+ responsible?: Responsible[];
131
105
  status: 'fetching' | 'awaiting_comments' | 'reported' | 'failed';
132
106
  publicationsFetched: number;
133
107
  contentsMapped: number;
@@ -9,9 +9,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ContentCaptureProcessModel = exports.ContentCaptureProcessSchema = exports.ContentCaptureProcess = exports.ContentCaptureProcessResponsiblesSchema = exports.ContentCaptureProcessResponsibles = exports.ContentCaptureProcessResponsibleSchema = exports.ContentCaptureProcessResponsible = exports.ContentCaptureProcessResponsibleContactSchema = exports.ContentCaptureProcessResponsibleContact = exports.ContentCaptureProcessItemSchema = exports.ContentCaptureProcessItem = exports.ContentCaptureProcessCommentCaptureStatusSchema = exports.ContentCaptureProcessCommentCaptureStatus = exports.ContentCaptureProcessInfluencerSchema = exports.ContentCaptureProcessInfluencer = exports.ContentCaptureProcessMetricsSchema = exports.ContentCaptureProcessMetrics = void 0;
12
+ exports.ContentCaptureProcessModel = exports.ContentCaptureProcessSchema = exports.ContentCaptureProcess = exports.ContentCaptureProcessItemSchema = exports.ContentCaptureProcessItem = exports.ContentCaptureProcessCommentCaptureStatusSchema = exports.ContentCaptureProcessCommentCaptureStatus = exports.ContentCaptureProcessInfluencerSchema = exports.ContentCaptureProcessInfluencer = exports.ContentCaptureProcessMetricsSchema = exports.ContentCaptureProcessMetrics = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
+ const responsible_schema_1 = require("./responsible.schema");
15
16
  let ContentCaptureProcessMetrics = class ContentCaptureProcessMetrics {
16
17
  };
17
18
  __decorate([
@@ -140,38 +141,6 @@ ContentCaptureProcessItem = __decorate([
140
141
  ], ContentCaptureProcessItem);
141
142
  exports.ContentCaptureProcessItem = ContentCaptureProcessItem;
142
143
  exports.ContentCaptureProcessItemSchema = mongoose_1.SchemaFactory.createForClass(ContentCaptureProcessItem);
143
- let ContentCaptureProcessResponsibleContact = class ContentCaptureProcessResponsibleContact {
144
- };
145
- __decorate([
146
- (0, mongoose_1.Prop)({ type: String, required: false }),
147
- __metadata("design:type", String)
148
- ], ContentCaptureProcessResponsibleContact.prototype, "name", void 0);
149
- __decorate([
150
- (0, mongoose_1.Prop)({ type: String, required: false }),
151
- __metadata("design:type", String)
152
- ], ContentCaptureProcessResponsibleContact.prototype, "team", void 0);
153
- __decorate([
154
- (0, mongoose_1.Prop)({ type: String, required: false }),
155
- __metadata("design:type", String)
156
- ], ContentCaptureProcessResponsibleContact.prototype, "email", void 0);
157
- ContentCaptureProcessResponsibleContact = __decorate([
158
- (0, mongoose_1.Schema)({ _id: false })
159
- ], ContentCaptureProcessResponsibleContact);
160
- exports.ContentCaptureProcessResponsibleContact = ContentCaptureProcessResponsibleContact;
161
- exports.ContentCaptureProcessResponsibleContactSchema = mongoose_1.SchemaFactory.createForClass(ContentCaptureProcessResponsibleContact);
162
- let ContentCaptureProcessResponsible = class ContentCaptureProcessResponsible {
163
- };
164
- __decorate([
165
- (0, mongoose_1.Prop)({ type: [exports.ContentCaptureProcessResponsibleContactSchema], required: false }),
166
- __metadata("design:type", Array)
167
- ], ContentCaptureProcessResponsible.prototype, "service", void 0);
168
- ContentCaptureProcessResponsible = __decorate([
169
- (0, mongoose_1.Schema)({ _id: false })
170
- ], ContentCaptureProcessResponsible);
171
- exports.ContentCaptureProcessResponsible = ContentCaptureProcessResponsible;
172
- exports.ContentCaptureProcessResponsibles = ContentCaptureProcessResponsible;
173
- exports.ContentCaptureProcessResponsibleSchema = mongoose_1.SchemaFactory.createForClass(ContentCaptureProcessResponsible);
174
- exports.ContentCaptureProcessResponsiblesSchema = exports.ContentCaptureProcessResponsibleSchema;
175
144
  let ContentCaptureProcess = class ContentCaptureProcess {
176
145
  };
177
146
  __decorate([
@@ -195,8 +164,8 @@ __decorate([
195
164
  __metadata("design:type", String)
196
165
  ], ContentCaptureProcess.prototype, "primetagId", void 0);
197
166
  __decorate([
198
- (0, mongoose_1.Prop)({ type: exports.ContentCaptureProcessResponsibleSchema, required: false }),
199
- __metadata("design:type", ContentCaptureProcessResponsible)
167
+ (0, mongoose_1.Prop)({ type: [responsible_schema_1.ResponsibleSchema], required: false, default: [] }),
168
+ __metadata("design:type", Array)
200
169
  ], ContentCaptureProcess.prototype, "responsible", void 0);
201
170
  __decorate([
202
171
  (0, mongoose_1.Prop)({
@@ -24,20 +24,8 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  /// <reference types="mongoose/types/inferrawdoctype" />
26
26
  import { HydratedDocument, Schema as MongooseSchema, Types } from 'mongoose';
27
+ import { Responsible } from './responsible.schema';
27
28
  export type ProspectDocument = HydratedDocument<Prospect>;
28
- export declare class ProspectResponsible {
29
- name: string;
30
- email: string;
31
- }
32
- export declare const ProspectResponsibleSchema: MongooseSchema<ProspectResponsible, import("mongoose").Model<ProspectResponsible, any, any, any, import("mongoose").Document<unknown, any, ProspectResponsible, any, {}> & ProspectResponsible & {
33
- _id: Types.ObjectId;
34
- } & {
35
- __v: number;
36
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, ProspectResponsible, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<ProspectResponsible>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<ProspectResponsible> & {
37
- _id: Types.ObjectId;
38
- } & {
39
- __v: number;
40
- }>;
41
29
  export declare class ProspectNote {
42
30
  text: string;
43
31
  author: string;
@@ -59,7 +47,7 @@ export declare class Prospect {
59
47
  value?: number;
60
48
  status: 'open' | 'won' | 'lost';
61
49
  hot: boolean;
62
- responsible: ProspectResponsible;
50
+ responsible: Responsible[];
63
51
  lastContactAt: Date;
64
52
  lastReminderAt?: Date;
65
53
  notes: ProspectNote[];
@@ -9,27 +9,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ProspectModel = exports.ProspectSchema = exports.Prospect = exports.ProspectNoteSchema = exports.ProspectNote = exports.ProspectResponsibleSchema = exports.ProspectResponsible = void 0;
12
+ exports.ProspectModel = exports.ProspectSchema = exports.Prospect = exports.ProspectNoteSchema = exports.ProspectNote = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const swagger_1 = require("@nestjs/swagger");
15
15
  const mongoose_2 = require("mongoose");
16
- let ProspectResponsible = class ProspectResponsible {
17
- };
18
- __decorate([
19
- (0, swagger_1.ApiProperty)({ example: 'João' }),
20
- (0, mongoose_1.Prop)({ required: true }),
21
- __metadata("design:type", String)
22
- ], ProspectResponsible.prototype, "name", void 0);
23
- __decorate([
24
- (0, swagger_1.ApiProperty)({ example: 'joao@empresa.com' }),
25
- (0, mongoose_1.Prop)({ required: true }),
26
- __metadata("design:type", String)
27
- ], ProspectResponsible.prototype, "email", void 0);
28
- ProspectResponsible = __decorate([
29
- (0, mongoose_1.Schema)({ _id: false })
30
- ], ProspectResponsible);
31
- exports.ProspectResponsible = ProspectResponsible;
32
- exports.ProspectResponsibleSchema = mongoose_1.SchemaFactory.createForClass(ProspectResponsible);
16
+ const responsible_schema_1 = require("./responsible.schema");
33
17
  let ProspectNote = class ProspectNote {
34
18
  };
35
19
  __decorate([
@@ -77,8 +61,9 @@ __decorate([
77
61
  __metadata("design:type", Boolean)
78
62
  ], Prospect.prototype, "hot", void 0);
79
63
  __decorate([
80
- (0, mongoose_1.Prop)({ type: exports.ProspectResponsibleSchema, required: true }),
81
- __metadata("design:type", ProspectResponsible)
64
+ (0, swagger_1.ApiProperty)({ type: () => [responsible_schema_1.Responsible] }),
65
+ (0, mongoose_1.Prop)({ type: [responsible_schema_1.ResponsibleSchema], required: true }),
66
+ __metadata("design:type", Array)
82
67
  ], Prospect.prototype, "responsible", void 0);
83
68
  __decorate([
84
69
  (0, mongoose_1.Prop)({ required: true }),
@@ -98,4 +83,5 @@ Prospect = __decorate([
98
83
  exports.Prospect = Prospect;
99
84
  exports.ProspectSchema = mongoose_1.SchemaFactory.createForClass(Prospect);
100
85
  exports.ProspectSchema.index({ organization: 1, status: 1, lastContactAt: 1 });
86
+ exports.ProspectSchema.index({ 'responsible.email': 1 });
101
87
  exports.ProspectModel = (0, mongoose_2.model)('Prospect', exports.ProspectSchema);
@@ -0,0 +1,45 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/session" />
19
+ /// <reference types="mongoose/types/types" />
20
+ /// <reference types="mongoose/types/utility" />
21
+ /// <reference types="mongoose/types/validation" />
22
+ /// <reference types="mongoose/types/virtuals" />
23
+ /// <reference types="mongoose" />
24
+ /// <reference types="mongoose/types/schematypes" />
25
+ /// <reference types="mongoose/types/inferschematype" />
26
+ /// <reference types="mongoose/types/inferrawdoctype" />
27
+ /**
28
+ * Formato único de responsável em todas as entidades (`responsible`).
29
+ * `username` vem de `User.username` (api-admin).
30
+ */
31
+ export declare class Responsible {
32
+ name: string;
33
+ email: string;
34
+ username: string;
35
+ team?: string;
36
+ }
37
+ export declare const ResponsibleSchema: import("mongoose").Schema<Responsible, import("mongoose").Model<Responsible, any, any, any, import("mongoose").Document<unknown, any, Responsible, any, {}> & Responsible & {
38
+ _id: import("mongoose").Types.ObjectId;
39
+ } & {
40
+ __v: number;
41
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Responsible, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Responsible>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Responsible> & {
42
+ _id: import("mongoose").Types.ObjectId;
43
+ } & {
44
+ __v: number;
45
+ }>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ResponsibleSchema = exports.Responsible = void 0;
13
+ const mongoose_1 = require("@nestjs/mongoose");
14
+ const swagger_1 = require("@nestjs/swagger");
15
+ /**
16
+ * Formato único de responsável em todas as entidades (`responsible`).
17
+ * `username` vem de `User.username` (api-admin).
18
+ */
19
+ let Responsible = class Responsible {
20
+ };
21
+ __decorate([
22
+ (0, swagger_1.ApiProperty)({ example: 'Maria Oliveira' }),
23
+ (0, mongoose_1.Prop)({ type: String, required: true }),
24
+ __metadata("design:type", String)
25
+ ], Responsible.prototype, "name", void 0);
26
+ __decorate([
27
+ (0, swagger_1.ApiProperty)({ example: 'maria@empresa.com' }),
28
+ (0, mongoose_1.Prop)({ type: String, required: true }),
29
+ __metadata("design:type", String)
30
+ ], Responsible.prototype, "email", void 0);
31
+ __decorate([
32
+ (0, swagger_1.ApiProperty)({ example: 'maria.oliveira' }),
33
+ (0, mongoose_1.Prop)({ type: String, required: true }),
34
+ __metadata("design:type", String)
35
+ ], Responsible.prototype, "username", void 0);
36
+ __decorate([
37
+ (0, swagger_1.ApiProperty)({ example: 'service', required: false }),
38
+ (0, mongoose_1.Prop)({ type: String, required: false }),
39
+ __metadata("design:type", String)
40
+ ], Responsible.prototype, "team", void 0);
41
+ Responsible = __decorate([
42
+ (0, mongoose_1.Schema)({ _id: false })
43
+ ], Responsible);
44
+ exports.Responsible = Responsible;
45
+ exports.ResponsibleSchema = mongoose_1.SchemaFactory.createForClass(Responsible);
@@ -28,6 +28,7 @@ import { Profile } from './profile.schema';
28
28
  import { Client } from './client.schema';
29
29
  import { Influencer } from './influencer.schema';
30
30
  import { Note } from './note.schema';
31
+ import { Responsible } from './responsible.schema';
31
32
  export type SaleDocument = HydratedDocument<Sale>;
32
33
  export declare class Proposal {
33
34
  businessUnit: 'service' | 'comercial';
@@ -36,11 +37,6 @@ export declare class Proposal {
36
37
  origin: 'inbound' | 'outbound';
37
38
  profile?: Types.ObjectId | Profile;
38
39
  influencer?: Types.ObjectId | Influencer;
39
- responsible: {
40
- team: string;
41
- name: string;
42
- email: string;
43
- }[];
44
40
  }
45
41
  export declare class Negotiation {
46
42
  calculatorType: 'withPreDefinedBudget' | 'withoutPreDefinedBudget' | 'byCommission' | 'bourbon';
@@ -117,18 +113,23 @@ export declare class Inbox {
117
113
  bodyHtml?: string;
118
114
  receivedAt: Date;
119
115
  }
116
+ /**
117
+ * Responsáveis da venda por papel: comercial (proposta), curadoria e planejamento.
118
+ */
120
119
  export declare class SaleResponsible {
121
- curation?: {
122
- team: string;
123
- name: string;
124
- email: string;
125
- }[];
126
- planning?: {
127
- team: string;
128
- name: string;
129
- email: string;
130
- }[];
120
+ proposal?: Responsible[];
121
+ curation?: Responsible[];
122
+ planning?: Responsible[];
131
123
  }
124
+ export declare const SaleResponsibleSchema: MongooseSchema<SaleResponsible, import("mongoose").Model<SaleResponsible, any, any, any, import("mongoose").Document<unknown, any, SaleResponsible, any, {}> & SaleResponsible & {
125
+ _id: Types.ObjectId;
126
+ } & {
127
+ __v: number;
128
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, SaleResponsible, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<SaleResponsible>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<SaleResponsible> & {
129
+ _id: Types.ObjectId;
130
+ } & {
131
+ __v: number;
132
+ }>;
132
133
  export declare class SaleLinks {
133
134
  contract?: string;
134
135
  clientSheet?: string;
@@ -9,10 +9,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.SaleModel = exports.SaleSchema = exports.Sale = exports.SaleLinks = exports.SaleResponsible = exports.Inbox = exports.CommissionInfo = exports.CommissionParticipant = exports.TimelineEntry = exports.Activity = exports.Lost = exports.Formalization = exports.Negotiation = exports.Proposal = void 0;
12
+ exports.SaleModel = exports.SaleSchema = exports.Sale = exports.SaleLinks = exports.SaleResponsibleSchema = exports.SaleResponsible = exports.Inbox = exports.CommissionInfo = exports.CommissionParticipant = exports.TimelineEntry = exports.Activity = exports.Lost = exports.Formalization = exports.Negotiation = exports.Proposal = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
15
  const note_schema_1 = require("./note.schema");
16
+ const responsible_schema_1 = require("./responsible.schema");
16
17
  let Proposal = class Proposal {
17
18
  };
18
19
  __decorate([
@@ -51,18 +52,6 @@ __decorate([
51
52
  }),
52
53
  __metadata("design:type", Object)
53
54
  ], Proposal.prototype, "influencer", void 0);
54
- __decorate([
55
- (0, mongoose_1.Prop)({
56
- _id: false,
57
- required: true,
58
- type: [{
59
- team: String,
60
- name: String,
61
- email: String,
62
- }],
63
- }),
64
- __metadata("design:type", Array)
65
- ], Proposal.prototype, "responsible", void 0);
66
55
  Proposal = __decorate([
67
56
  (0, mongoose_1.Schema)({ _id: false })
68
57
  ], Proposal);
@@ -351,36 +340,28 @@ Inbox = __decorate([
351
340
  (0, mongoose_1.Schema)({ _id: false })
352
341
  ], Inbox);
353
342
  exports.Inbox = Inbox;
343
+ /**
344
+ * Responsáveis da venda por papel: comercial (proposta), curadoria e planejamento.
345
+ */
354
346
  let SaleResponsible = class SaleResponsible {
355
347
  };
356
348
  __decorate([
357
- (0, mongoose_1.Prop)({
358
- _id: false,
359
- required: false,
360
- type: [{
361
- team: String,
362
- name: String,
363
- email: String,
364
- }],
365
- }),
349
+ (0, mongoose_1.Prop)({ type: [responsible_schema_1.ResponsibleSchema], required: false, default: [] }),
350
+ __metadata("design:type", Array)
351
+ ], SaleResponsible.prototype, "proposal", void 0);
352
+ __decorate([
353
+ (0, mongoose_1.Prop)({ type: [responsible_schema_1.ResponsibleSchema], required: false, default: [] }),
366
354
  __metadata("design:type", Array)
367
355
  ], SaleResponsible.prototype, "curation", void 0);
368
356
  __decorate([
369
- (0, mongoose_1.Prop)({
370
- _id: false,
371
- required: false,
372
- type: [{
373
- team: String,
374
- name: String,
375
- email: String,
376
- }],
377
- }),
357
+ (0, mongoose_1.Prop)({ type: [responsible_schema_1.ResponsibleSchema], required: false, default: [] }),
378
358
  __metadata("design:type", Array)
379
359
  ], SaleResponsible.prototype, "planning", void 0);
380
360
  SaleResponsible = __decorate([
381
361
  (0, mongoose_1.Schema)({ _id: false })
382
362
  ], SaleResponsible);
383
363
  exports.SaleResponsible = SaleResponsible;
364
+ exports.SaleResponsibleSchema = mongoose_1.SchemaFactory.createForClass(SaleResponsible);
384
365
  let SaleLinks = class SaleLinks {
385
366
  };
386
367
  __decorate([
@@ -510,7 +491,7 @@ __decorate([
510
491
  __metadata("design:type", String)
511
492
  ], Sale.prototype, "omieId", void 0);
512
493
  __decorate([
513
- (0, mongoose_1.Prop)({ type: SaleResponsible, required: false }),
494
+ (0, mongoose_1.Prop)({ type: exports.SaleResponsibleSchema, required: false }),
514
495
  __metadata("design:type", SaleResponsible)
515
496
  ], Sale.prototype, "responsible", void 0);
516
497
  __decorate([
@@ -528,6 +509,6 @@ exports.SaleSchema.index({ organization: 1, 'formalization.brand': 1 });
528
509
  exports.SaleSchema.index({ organization: 1, 'formalization.agency': 1 });
529
510
  exports.SaleSchema.index({ organization: 1, closedAt: 1, phase: 1 });
530
511
  exports.SaleSchema.index({ 'proposal.influencer': 1 });
531
- exports.SaleSchema.index({ 'proposal.responsible.email': 1 });
512
+ exports.SaleSchema.index({ 'responsible.proposal.email': 1 });
532
513
  exports.SaleSchema.index({ tags: 1 });
533
514
  exports.SaleModel = (0, mongoose_2.model)('Sale', exports.SaleSchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grapadigital/shared-schemas",
3
- "version": "1.0.216",
3
+ "version": "1.0.218",
4
4
  "description": "Shared Mongoose Schemas",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './schemas/responsible.schema';
1
2
  export * from './schemas/action.schema';
2
3
  export * from './schemas/prospect.schema';
3
4
  export * from './schemas/client.schema';
@@ -14,34 +14,10 @@ import { Client } from './client.schema';
14
14
  import { Sale } from './sale.schema';
15
15
  import { Campaign } from './campaign.schema';
16
16
  import { Note, NoteSchema } from './note.schema';
17
+ import { Responsible, ResponsibleSchema } from './responsible.schema';
17
18
 
18
19
  export type ActionDocument = HydratedDocument<Action>;
19
20
 
20
- @Schema({ _id: false })
21
- export class Responsible {
22
- @ApiProperty({ example: 'Maria Oliveira' })
23
- @Prop()
24
- name: string;
25
-
26
- @ApiProperty({ example: 'Comercial' })
27
- @Prop()
28
- team: string;
29
-
30
- @ApiProperty({ example: 'maria@empresa.com' })
31
- @Prop()
32
- email: string;
33
- }
34
-
35
- export const ResponsibleSchema = SchemaFactory.createForClass(Responsible);
36
-
37
- /**
38
- * @deprecated Use `Responsible` or `Responsible[]` on Action.responsible
39
- */
40
- export class ActionResponsible extends Responsible {}
41
- export const ActionResponsibleSchema = SchemaFactory.createForClass(ActionResponsible);
42
-
43
- export { ActionResponsible as Responsibles, ActionResponsibleSchema as ResponsiblesSchema };
44
-
45
21
  export const ACTION_BUSINESS_UNIT_VALUES = [
46
22
  'service',
47
23
  'comercial',
@@ -9,6 +9,7 @@ import {
9
9
  } from 'mongoose';
10
10
 
11
11
  import { Action } from './action.schema';
12
+ import { Responsible, ResponsibleSchema } from './responsible.schema';
12
13
 
13
14
  export type AssignmentDocument = HydratedDocument<Assignment>;
14
15
 
@@ -100,9 +101,9 @@ export class Assignment {
100
101
  @Prop({ type: String, required: true })
101
102
  title: string;
102
103
 
103
- @ApiProperty({ example: '64bfc3a78d3f1e2a1234567a', required: false })
104
- @Prop({ type: MongooseSchema.Types.ObjectId, required: false })
105
- responsible?: Types.ObjectId;
104
+ @ApiProperty({ type: () => [Responsible], required: false })
105
+ @Prop({ type: [ResponsibleSchema], required: false, default: [] })
106
+ responsible?: Responsible[];
106
107
 
107
108
  @ApiProperty({ example: '2026-08-25T00:00:00.000Z', required: false })
108
109
  @Prop({ type: Date, required: false, default: null })
@@ -148,6 +149,6 @@ AssignmentSchema.index({ action: 1 });
148
149
  AssignmentSchema.index({ organization: 1, status: 1 });
149
150
  AssignmentSchema.index({ organization: 1, dueDate: 1 });
150
151
  AssignmentSchema.index({ seriesId: 1 });
151
- AssignmentSchema.index({ responsible: 1, dueDate: 1 });
152
+ AssignmentSchema.index({ 'responsible.email': 1, dueDate: 1 });
152
153
 
153
154
  export const AssignmentModel = MongooseModel('Assignment', AssignmentSchema);
@@ -8,9 +8,17 @@ import {
8
8
  } from 'mongoose';
9
9
  import { Party } from './party.schema';
10
10
  import { Profile } from './profile.schema';
11
+ import { Responsible, ResponsibleSchema } from './responsible.schema';
11
12
 
12
13
  export type ClientDocument = HydratedDocument<Client>;
13
14
 
15
+ /**
16
+ * Personalizações de cliente: ligam telas e regras que valem só para ele.
17
+ * Ver GD-683.
18
+ */
19
+ export const CLIENT_CUSTOMIZATION_VALUES = ['samsung'] as const;
20
+ export type ClientCustomization = (typeof CLIENT_CUSTOMIZATION_VALUES)[number];
21
+
14
22
  @Schema({ _id: false })
15
23
  export class Cluster {
16
24
  @Prop({ required: true })
@@ -75,19 +83,19 @@ export class NicheItem {
75
83
 
76
84
  export const NicheItemSchema = SchemaFactory.createForClass(NicheItem);
77
85
 
86
+ /**
87
+ * Responsáveis do cliente: `report` são usuários da plataforma que cuidam dos
88
+ * relatórios; `brand` é o contato do lado da marca (texto livre, não é usuário).
89
+ */
78
90
  @Schema({ _id: false })
79
91
  export class ClientResponsible {
80
- @ApiProperty({ example: 'Maria Oliveira' })
81
- @Prop()
82
- name: string;
92
+ @ApiProperty({ type: () => [Responsible], required: false })
93
+ @Prop({ type: [ResponsibleSchema], required: false, default: [] })
94
+ report?: Responsible[];
83
95
 
84
- @ApiProperty({ example: 'Comercial' })
85
- @Prop()
86
- team: string;
87
-
88
- @ApiProperty({ example: 'maria@empresa.com' })
89
- @Prop()
90
- email: string;
96
+ @ApiProperty({ example: 'Maite', required: false })
97
+ @Prop({ type: String, required: false })
98
+ brand?: string;
91
99
  }
92
100
 
93
101
  export const ClientResponsibleSchema = SchemaFactory.createForClass(ClientResponsible);
@@ -140,6 +148,15 @@ export class Client extends Party {
140
148
  @Prop({ type: Boolean, default: false })
141
149
  hasGenIAAnalysis: boolean;
142
150
 
151
+ /**
152
+ * Personalização do cliente (ex.: `samsung`): liga as telas e regras
153
+ * específicas dele no Flow e no Hub. Ausente ou `null` = comportamento
154
+ * padrão. Nunca comparar id de cliente no código, sempre este campo.
155
+ * Ver GD-683.
156
+ */
157
+ @Prop({ type: String, enum: CLIENT_CUSTOMIZATION_VALUES, required: false, default: null })
158
+ customization?: ClientCustomization | null;
159
+
143
160
  /**
144
161
  * Client de organização (ex.: "Oma Creators"): representa a organização
145
162
  * inteira, não uma marca. No hub, mostra todas as actions dessa organização
@@ -151,10 +168,7 @@ export class Client extends Party {
151
168
  organization?: Types.ObjectId;
152
169
 
153
170
  @Prop({ type: ClientResponsibleSchema, required: false })
154
- reportResponsible?: ClientResponsible;
155
-
156
- @Prop({ type: String, required: false })
157
- brandResponsible?: string;
171
+ responsible?: ClientResponsible;
158
172
 
159
173
  // Perfis da marca nas redes sociais (mesmo vínculo de Influencer.profiles).
160
174
  // Usado pelo comment-capture-worker pra reconhecer comentário da própria marca.
@@ -6,6 +6,7 @@ import {
6
6
  model as MongooseModel,
7
7
  } from 'mongoose';
8
8
  import { Action } from './action.schema';
9
+ import { Responsible, ResponsibleSchema } from './responsible.schema';
9
10
 
10
11
  export type ContentCaptureProcessDocument = HydratedDocument<ContentCaptureProcess>;
11
12
 
@@ -112,37 +113,6 @@ export class ContentCaptureProcessItem {
112
113
  export const ContentCaptureProcessItemSchema =
113
114
  SchemaFactory.createForClass(ContentCaptureProcessItem);
114
115
 
115
- @Schema({ _id: false })
116
- export class ContentCaptureProcessResponsibleContact {
117
- @Prop({ type: String, required: false })
118
- name?: string;
119
-
120
- @Prop({ type: String, required: false })
121
- team?: string;
122
-
123
- @Prop({ type: String, required: false })
124
- email?: string;
125
- }
126
-
127
- export const ContentCaptureProcessResponsibleContactSchema = SchemaFactory.createForClass(
128
- ContentCaptureProcessResponsibleContact,
129
- );
130
-
131
- @Schema({ _id: false })
132
- export class ContentCaptureProcessResponsible {
133
- @Prop({ type: [ContentCaptureProcessResponsibleContactSchema], required: false })
134
- service?: ContentCaptureProcessResponsibleContact[];
135
- }
136
-
137
- export const ContentCaptureProcessResponsibleSchema = SchemaFactory.createForClass(
138
- ContentCaptureProcessResponsible,
139
- );
140
-
141
- export {
142
- ContentCaptureProcessResponsible as ContentCaptureProcessResponsibles,
143
- ContentCaptureProcessResponsibleSchema as ContentCaptureProcessResponsiblesSchema,
144
- };
145
-
146
116
  @Schema({ collection: 'content-capture-processes', timestamps: true })
147
117
  export class ContentCaptureProcess {
148
118
  @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
@@ -160,8 +130,8 @@ export class ContentCaptureProcess {
160
130
  @Prop({ type: String, required: false })
161
131
  primetagId?: string;
162
132
 
163
- @Prop({ type: ContentCaptureProcessResponsibleSchema, required: false })
164
- responsible?: ContentCaptureProcessResponsible;
133
+ @Prop({ type: [ResponsibleSchema], required: false, default: [] })
134
+ responsible?: Responsible[];
165
135
 
166
136
  @Prop({
167
137
  type: String,
@@ -1,22 +1,10 @@
1
1
  import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
2
  import { ApiProperty } from '@nestjs/swagger';
3
3
  import { HydratedDocument, Schema as MongooseSchema, Types, model as MongooseModel } from 'mongoose';
4
+ import { Responsible, ResponsibleSchema } from './responsible.schema';
4
5
 
5
6
  export type ProspectDocument = HydratedDocument<Prospect>;
6
7
 
7
- @Schema({ _id: false })
8
- export class ProspectResponsible {
9
- @ApiProperty({ example: 'João' })
10
- @Prop({ required: true })
11
- name: string;
12
-
13
- @ApiProperty({ example: 'joao@empresa.com' })
14
- @Prop({ required: true })
15
- email: string;
16
- }
17
-
18
- export const ProspectResponsibleSchema = SchemaFactory.createForClass(ProspectResponsible);
19
-
20
8
  @Schema({ _id: false })
21
9
  export class ProspectNote {
22
10
  @Prop({ required: true })
@@ -52,8 +40,9 @@ export class Prospect {
52
40
  @Prop({ required: true, default: false })
53
41
  hot: boolean;
54
42
 
55
- @Prop({ type: ProspectResponsibleSchema, required: true })
56
- responsible: ProspectResponsible;
43
+ @ApiProperty({ type: () => [Responsible] })
44
+ @Prop({ type: [ResponsibleSchema], required: true })
45
+ responsible: Responsible[];
57
46
 
58
47
  @Prop({ required: true })
59
48
  lastContactAt: Date;
@@ -68,5 +57,6 @@ export class Prospect {
68
57
  export const ProspectSchema = SchemaFactory.createForClass(Prospect);
69
58
 
70
59
  ProspectSchema.index({ organization: 1, status: 1, lastContactAt: 1 });
60
+ ProspectSchema.index({ 'responsible.email': 1 });
71
61
 
72
62
  export const ProspectModel = MongooseModel('Prospect', ProspectSchema);
@@ -0,0 +1,27 @@
1
+ import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
+ import { ApiProperty } from '@nestjs/swagger';
3
+
4
+ /**
5
+ * Formato único de responsável em todas as entidades (`responsible`).
6
+ * `username` vem de `User.username` (api-admin).
7
+ */
8
+ @Schema({ _id: false })
9
+ export class Responsible {
10
+ @ApiProperty({ example: 'Maria Oliveira' })
11
+ @Prop({ type: String, required: true })
12
+ name: string;
13
+
14
+ @ApiProperty({ example: 'maria@empresa.com' })
15
+ @Prop({ type: String, required: true })
16
+ email: string;
17
+
18
+ @ApiProperty({ example: 'maria.oliveira' })
19
+ @Prop({ type: String, required: true })
20
+ username: string;
21
+
22
+ @ApiProperty({ example: 'service', required: false })
23
+ @Prop({ type: String, required: false })
24
+ team?: string;
25
+ }
26
+
27
+ export const ResponsibleSchema = SchemaFactory.createForClass(Responsible);
@@ -9,6 +9,7 @@ import { Profile } from './profile.schema';
9
9
  import { Client } from './client.schema';
10
10
  import { Influencer } from './influencer.schema';
11
11
  import { Note } from './note.schema';
12
+ import { Responsible, ResponsibleSchema } from './responsible.schema';
12
13
 
13
14
  export type SaleDocument = HydratedDocument<Sale>;
14
15
 
@@ -38,21 +39,6 @@ export class Proposal {
38
39
  required: false,
39
40
  })
40
41
  influencer?: Types.ObjectId | Influencer;
41
-
42
- @Prop({
43
- _id: false,
44
- required: true,
45
- type: [{
46
- team: String,
47
- name: String,
48
- email: String,
49
- }],
50
- })
51
- responsible: {
52
- team: string;
53
- name: string;
54
- email: string;
55
- }[];
56
42
  }
57
43
 
58
44
  @Schema({ _id: false })
@@ -168,39 +154,23 @@ export class Inbox {
168
154
  @Prop({ required: true }) receivedAt: Date;
169
155
  }
170
156
 
157
+ /**
158
+ * Responsáveis da venda por papel: comercial (proposta), curadoria e planejamento.
159
+ */
171
160
  @Schema({ _id: false })
172
161
  export class SaleResponsible {
173
- @Prop({
174
- _id: false,
175
- required: false,
176
- type: [{
177
- team: String,
178
- name: String,
179
- email: String,
180
- }],
181
- })
182
- curation?: {
183
- team: string;
184
- name: string;
185
- email: string;
186
- }[];
162
+ @Prop({ type: [ResponsibleSchema], required: false, default: [] })
163
+ proposal?: Responsible[];
187
164
 
188
- @Prop({
189
- _id: false,
190
- required: false,
191
- type: [{
192
- team: String,
193
- name: String,
194
- email: String,
195
- }],
196
- })
197
- planning?: {
198
- team: string;
199
- name: string;
200
- email: string;
201
- }[];
165
+ @Prop({ type: [ResponsibleSchema], required: false, default: [] })
166
+ curation?: Responsible[];
167
+
168
+ @Prop({ type: [ResponsibleSchema], required: false, default: [] })
169
+ planning?: Responsible[];
202
170
  }
203
171
 
172
+ export const SaleResponsibleSchema = SchemaFactory.createForClass(SaleResponsible);
173
+
204
174
  @Schema({ _id: false })
205
175
  export class SaleLinks {
206
176
  @Prop({ required: false })
@@ -306,7 +276,7 @@ export class Sale {
306
276
  @Prop({ type: String, required: false })
307
277
  omieId?: string;
308
278
 
309
- @Prop({ type: SaleResponsible, required: false })
279
+ @Prop({ type: SaleResponsibleSchema, required: false })
310
280
  responsible?: SaleResponsible;
311
281
 
312
282
  @Prop({ type: SaleLinks, required: false })
@@ -321,7 +291,7 @@ SaleSchema.index({ organization: 1, 'formalization.brand': 1 });
321
291
  SaleSchema.index({ organization: 1, 'formalization.agency': 1 });
322
292
  SaleSchema.index({ organization: 1, closedAt: 1, phase: 1 });
323
293
  SaleSchema.index({ 'proposal.influencer': 1 });
324
- SaleSchema.index({ 'proposal.responsible.email': 1 });
294
+ SaleSchema.index({ 'responsible.proposal.email': 1 });
325
295
  SaleSchema.index({ tags: 1 });
326
296
 
327
297
  export const SaleModel = MongooseModel('Sale', SaleSchema);