@grapadigital/shared-schemas 1.0.202 → 1.0.204

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.
@@ -23,19 +23,20 @@
23
23
  /// <reference types="mongoose/types/schematypes" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  /// <reference types="mongoose/types/inferrawdoctype" />
26
- import { HydratedDocument } from 'mongoose';
26
+ import { HydratedDocument, Schema as MongooseSchema, Types } from 'mongoose';
27
27
  import { Party } from './party.schema';
28
+ import { Profile } from './profile.schema';
28
29
  export type ClientDocument = HydratedDocument<Client>;
29
30
  export declare class Cluster {
30
31
  key: string;
31
32
  label: string;
32
33
  }
33
- export declare const ClusterSchema: import("mongoose").Schema<Cluster, import("mongoose").Model<Cluster, any, any, any, import("mongoose").Document<unknown, any, Cluster, any, {}> & Cluster & {
34
- _id: import("mongoose").Types.ObjectId;
34
+ export declare const ClusterSchema: MongooseSchema<Cluster, import("mongoose").Model<Cluster, any, any, any, import("mongoose").Document<unknown, any, Cluster, any, {}> & Cluster & {
35
+ _id: Types.ObjectId;
35
36
  } & {
36
37
  __v: number;
37
38
  }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Cluster, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Cluster>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Cluster> & {
38
- _id: import("mongoose").Types.ObjectId;
39
+ _id: Types.ObjectId;
39
40
  } & {
40
41
  __v: number;
41
42
  }>;
@@ -43,12 +44,12 @@ export declare class Company {
43
44
  legalName: string;
44
45
  document: string;
45
46
  }
46
- export declare const CompanySchema: import("mongoose").Schema<Company, import("mongoose").Model<Company, any, any, any, import("mongoose").Document<unknown, any, Company, any, {}> & Company & {
47
- _id: import("mongoose").Types.ObjectId;
47
+ export declare const CompanySchema: MongooseSchema<Company, import("mongoose").Model<Company, any, any, any, import("mongoose").Document<unknown, any, Company, any, {}> & Company & {
48
+ _id: Types.ObjectId;
48
49
  } & {
49
50
  __v: number;
50
51
  }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Company, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Company>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Company> & {
51
- _id: import("mongoose").Types.ObjectId;
52
+ _id: Types.ObjectId;
52
53
  } & {
53
54
  __v: number;
54
55
  }>;
@@ -57,12 +58,12 @@ export declare class CommissionRange {
57
58
  endValue: number;
58
59
  percent: number;
59
60
  }
60
- export declare const CommissionRangeSchema: import("mongoose").Schema<CommissionRange, import("mongoose").Model<CommissionRange, any, any, any, import("mongoose").Document<unknown, any, CommissionRange, any, {}> & CommissionRange & {
61
- _id: import("mongoose").Types.ObjectId;
61
+ export declare const CommissionRangeSchema: MongooseSchema<CommissionRange, import("mongoose").Model<CommissionRange, any, any, any, import("mongoose").Document<unknown, any, CommissionRange, any, {}> & CommissionRange & {
62
+ _id: Types.ObjectId;
62
63
  } & {
63
64
  __v: number;
64
65
  }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, CommissionRange, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<CommissionRange>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<CommissionRange> & {
65
- _id: import("mongoose").Types.ObjectId;
66
+ _id: Types.ObjectId;
66
67
  } & {
67
68
  __v: number;
68
69
  }>;
@@ -71,12 +72,12 @@ export declare class AgencyCommissionPeriod {
71
72
  startDate: Date;
72
73
  endDate: Date;
73
74
  }
74
- export declare const AgencyCommissionPeriodSchema: import("mongoose").Schema<AgencyCommissionPeriod, import("mongoose").Model<AgencyCommissionPeriod, any, any, any, import("mongoose").Document<unknown, any, AgencyCommissionPeriod, any, {}> & AgencyCommissionPeriod & {
75
- _id: import("mongoose").Types.ObjectId;
75
+ export declare const AgencyCommissionPeriodSchema: MongooseSchema<AgencyCommissionPeriod, import("mongoose").Model<AgencyCommissionPeriod, any, any, any, import("mongoose").Document<unknown, any, AgencyCommissionPeriod, any, {}> & AgencyCommissionPeriod & {
76
+ _id: Types.ObjectId;
76
77
  } & {
77
78
  __v: number;
78
79
  }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, AgencyCommissionPeriod, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<AgencyCommissionPeriod>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<AgencyCommissionPeriod> & {
79
- _id: import("mongoose").Types.ObjectId;
80
+ _id: Types.ObjectId;
80
81
  } & {
81
82
  __v: number;
82
83
  }>;
@@ -85,12 +86,12 @@ export declare class NicheItem {
85
86
  name: string;
86
87
  parentId?: string;
87
88
  }
88
- export declare const NicheItemSchema: import("mongoose").Schema<NicheItem, import("mongoose").Model<NicheItem, any, any, any, import("mongoose").Document<unknown, any, NicheItem, any, {}> & NicheItem & {
89
- _id: import("mongoose").Types.ObjectId;
89
+ export declare const NicheItemSchema: MongooseSchema<NicheItem, import("mongoose").Model<NicheItem, any, any, any, import("mongoose").Document<unknown, any, NicheItem, any, {}> & NicheItem & {
90
+ _id: Types.ObjectId;
90
91
  } & {
91
92
  __v: number;
92
93
  }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, NicheItem, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<NicheItem>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<NicheItem> & {
93
- _id: import("mongoose").Types.ObjectId;
94
+ _id: Types.ObjectId;
94
95
  } & {
95
96
  __v: number;
96
97
  }>;
@@ -99,12 +100,12 @@ export declare class Responsable {
99
100
  team: string;
100
101
  email: string;
101
102
  }
102
- export declare const ResponsableSchema: import("mongoose").Schema<Responsable, import("mongoose").Model<Responsable, any, any, any, import("mongoose").Document<unknown, any, Responsable, any, {}> & Responsable & {
103
- _id: import("mongoose").Types.ObjectId;
103
+ export declare const ResponsableSchema: MongooseSchema<Responsable, import("mongoose").Model<Responsable, any, any, any, import("mongoose").Document<unknown, any, Responsable, any, {}> & Responsable & {
104
+ _id: Types.ObjectId;
104
105
  } & {
105
106
  __v: number;
106
107
  }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Responsable, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Responsable>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Responsable> & {
107
- _id: import("mongoose").Types.ObjectId;
108
+ _id: Types.ObjectId;
108
109
  } & {
109
110
  __v: number;
110
111
  }>;
@@ -130,28 +131,36 @@ export declare class Client extends Party {
130
131
  * (Antigo `hasReport`.)
131
132
  */
132
133
  hasGenIAAnalysis: boolean;
134
+ /**
135
+ * Client de organização (ex.: "Oma Creators"): representa a organização
136
+ * inteira, não uma marca. Com `hasGenIAAnalysis`, liga a análise GenIA pra
137
+ * todas as actions dessa organização e, no hub, mostra todas elas
138
+ * independentemente do client (marca) de cada action.
139
+ */
140
+ organization?: Types.ObjectId;
133
141
  reportResponsable?: Responsable;
134
142
  brandResponsable?: string;
143
+ profiles?: Types.ObjectId[] | Profile[];
135
144
  }
136
- export declare const ClientSchema: import("mongoose").Schema<Client, import("mongoose").Model<Client, any, any, any, import("mongoose").Document<unknown, any, Client, any, {}> & Client & Required<{
137
- _id: import("mongoose").Types.ObjectId;
145
+ export declare const ClientSchema: MongooseSchema<Client, import("mongoose").Model<Client, any, any, any, import("mongoose").Document<unknown, any, Client, any, {}> & Client & Required<{
146
+ _id: Types.ObjectId;
138
147
  }> & {
139
148
  __v: number;
140
149
  }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Client, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Client>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Client> & Required<{
141
- _id: import("mongoose").Types.ObjectId;
150
+ _id: Types.ObjectId;
142
151
  }> & {
143
152
  __v: number;
144
153
  }>;
145
154
  export declare const ClientModel: import("mongoose").Model<Client, {}, {}, {}, import("mongoose").Document<unknown, {}, Client, {}, import("mongoose").DefaultSchemaOptions> & Client & Required<{
146
- _id: import("mongoose").Types.ObjectId;
155
+ _id: Types.ObjectId;
147
156
  }> & {
148
157
  __v: number;
149
- }, import("mongoose").Schema<Client, import("mongoose").Model<Client, any, any, any, import("mongoose").Document<unknown, any, Client, any, {}> & Client & Required<{
150
- _id: import("mongoose").Types.ObjectId;
158
+ }, MongooseSchema<Client, import("mongoose").Model<Client, any, any, any, import("mongoose").Document<unknown, any, Client, any, {}> & Client & Required<{
159
+ _id: Types.ObjectId;
151
160
  }> & {
152
161
  __v: number;
153
162
  }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Client, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Client>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Client> & Required<{
154
- _id: import("mongoose").Types.ObjectId;
163
+ _id: Types.ObjectId;
155
164
  }> & {
156
165
  __v: number;
157
166
  }>>;
@@ -165,6 +165,10 @@ __decorate([
165
165
  (0, mongoose_1.Prop)({ type: Boolean, default: false }),
166
166
  __metadata("design:type", Boolean)
167
167
  ], Client.prototype, "hasGenIAAnalysis", void 0);
168
+ __decorate([
169
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Organization', required: false }),
170
+ __metadata("design:type", mongoose_2.Types.ObjectId)
171
+ ], Client.prototype, "organization", void 0);
168
172
  __decorate([
169
173
  (0, mongoose_1.Prop)({ type: exports.ResponsableSchema, required: false }),
170
174
  __metadata("design:type", Responsable)
@@ -173,6 +177,12 @@ __decorate([
173
177
  (0, mongoose_1.Prop)({ type: String, required: false }),
174
178
  __metadata("design:type", String)
175
179
  ], Client.prototype, "brandResponsable", void 0);
180
+ __decorate([
181
+ (0, mongoose_1.Prop)([
182
+ { type: mongoose_2.Schema.Types.ObjectId, ref: 'Profile', required: false },
183
+ ]),
184
+ __metadata("design:type", Array)
185
+ ], Client.prototype, "profiles", void 0);
176
186
  Client = __decorate([
177
187
  (0, mongoose_1.Schema)({ timestamps: true })
178
188
  ], Client);
@@ -182,4 +192,5 @@ exports.ClientSchema.index({ name: 1 });
182
192
  exports.ClientSchema.index({ 'company.legalName': 1 });
183
193
  exports.ClientSchema.index({ 'company.document': 1 });
184
194
  exports.ClientSchema.index({ createdAt: -1 });
195
+ exports.ClientSchema.index({ organization: 1 }, { sparse: true });
185
196
  exports.ClientModel = (0, mongoose_2.model)('Client', exports.ClientSchema);
@@ -25,6 +25,7 @@
25
25
  /// <reference types="mongoose/types/inferrawdoctype" />
26
26
  import { HydratedDocument, Schema as MongooseSchema, Types } from 'mongoose';
27
27
  import { Influencer } from './influencer.schema';
28
+ import { Client } from './client.schema';
28
29
  export type ProfileDocument = HydratedDocument<Profile>;
29
30
  export declare class Profile {
30
31
  _id?: Types.ObjectId;
@@ -37,6 +38,7 @@ export declare class Profile {
37
38
  socialnetwork: string;
38
39
  type: string;
39
40
  influencer: Types.ObjectId | Influencer;
41
+ client?: Types.ObjectId | Client;
40
42
  createdAt?: Date;
41
43
  updatedAt?: Date;
42
44
  }
@@ -54,6 +54,10 @@ __decorate([
54
54
  (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Influencer' }),
55
55
  __metadata("design:type", Object)
56
56
  ], Profile.prototype, "influencer", void 0);
57
+ __decorate([
58
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Client', required: false }),
59
+ __metadata("design:type", Object)
60
+ ], Profile.prototype, "client", void 0);
57
61
  __decorate([
58
62
  (0, mongoose_1.Prop)({ default: Date.now, required: false }),
59
63
  __metadata("design:type", Date)
@@ -68,6 +72,7 @@ Profile = __decorate([
68
72
  exports.Profile = Profile;
69
73
  exports.ProfileSchema = mongoose_1.SchemaFactory.createForClass(Profile);
70
74
  exports.ProfileSchema.index({ influencer: 1 });
75
+ exports.ProfileSchema.index({ client: 1 }, { sparse: true });
71
76
  exports.ProfileSchema.index({ username: 1 });
72
77
  exports.ProfileSchema.index({ username: 1, influencer: 1 });
73
78
  exports.ProfileModel = (0, mongoose_2.model)('Profile', exports.ProfileSchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grapadigital/shared-schemas",
3
- "version": "1.0.202",
3
+ "version": "1.0.204",
4
4
  "description": "Shared Mongoose Schemas",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,7 +1,13 @@
1
1
  import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
2
  import { ApiProperty } from '@nestjs/swagger';
3
- import { HydratedDocument, model as MongooseModel } from 'mongoose';
3
+ import {
4
+ HydratedDocument,
5
+ model as MongooseModel,
6
+ Schema as MongooseSchema,
7
+ Types,
8
+ } from 'mongoose';
4
9
  import { Party } from './party.schema';
10
+ import { Profile } from './profile.schema';
5
11
 
6
12
  export type ClientDocument = HydratedDocument<Client>;
7
13
 
@@ -131,11 +137,27 @@ export class Client extends Party {
131
137
  @Prop({ type: Boolean, default: false })
132
138
  hasGenIAAnalysis: boolean;
133
139
 
140
+ /**
141
+ * Client de organização (ex.: "Oma Creators"): representa a organização
142
+ * inteira, não uma marca. Com `hasGenIAAnalysis`, liga a análise GenIA pra
143
+ * todas as actions dessa organização e, no hub, mostra todas elas
144
+ * independentemente do client (marca) de cada action.
145
+ */
146
+ @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Organization', required: false })
147
+ organization?: Types.ObjectId;
148
+
134
149
  @Prop({ type: ResponsableSchema, required: false })
135
150
  reportResponsable?: Responsable;
136
151
 
137
152
  @Prop({ type: String, required: false })
138
153
  brandResponsable?: string;
154
+
155
+ // Perfis da marca nas redes sociais (mesmo vínculo de Influencer.profiles).
156
+ // Usado pelo comment-capture-worker pra reconhecer comentário da própria marca.
157
+ @Prop([
158
+ { type: MongooseSchema.Types.ObjectId, ref: 'Profile', required: false },
159
+ ])
160
+ profiles?: Types.ObjectId[] | Profile[];
139
161
  }
140
162
 
141
163
  export const ClientSchema = SchemaFactory.createForClass(Client);
@@ -144,5 +166,6 @@ ClientSchema.index({ name: 1 });
144
166
  ClientSchema.index({ 'company.legalName': 1 });
145
167
  ClientSchema.index({ 'company.document': 1 });
146
168
  ClientSchema.index({ createdAt: -1 });
169
+ ClientSchema.index({ organization: 1 }, { sparse: true });
147
170
 
148
171
  export const ClientModel = MongooseModel('Client', ClientSchema);
@@ -1,6 +1,7 @@
1
1
  import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
2
  import { HydratedDocument, Schema as MongooseSchema, Types, model as MongooseModel } from 'mongoose';
3
3
  import { Influencer } from './influencer.schema';
4
+ import { Client } from './client.schema';
4
5
 
5
6
  export type ProfileDocument = HydratedDocument<Profile>;
6
7
 
@@ -37,6 +38,11 @@ export class Profile {
37
38
  @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Influencer' })
38
39
  influencer: Types.ObjectId | Influencer;
39
40
 
41
+ // Perfil da própria marca (ex.: @marca no Instagram). Um perfil pertence a um
42
+ // Influencer OU a um Client, nunca aos dois.
43
+ @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Client', required: false })
44
+ client?: Types.ObjectId | Client;
45
+
40
46
  @Prop({ default: Date.now, required: false })
41
47
  createdAt?: Date;
42
48
 
@@ -47,6 +53,7 @@ export class Profile {
47
53
  export const ProfileSchema = SchemaFactory.createForClass(Profile);
48
54
 
49
55
  ProfileSchema.index({ influencer: 1 });
56
+ ProfileSchema.index({ client: 1 }, { sparse: true });
50
57
  ProfileSchema.index({ username: 1 });
51
58
  ProfileSchema.index({ username: 1, influencer: 1 });
52
59