@grapadigital/shared-schemas 1.0.178 → 1.0.180

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
@@ -21,5 +21,6 @@ export * from './schemas/notifications.schema';
21
21
  export * from './schemas/organization.schema';
22
22
  export * from './schemas/user.schema';
23
23
  export * from './schemas/group.schema';
24
+ export * from './schemas/tag.schema';
24
25
  export * from './schemas/trigger.schema';
25
26
  export { Note, NoteSchema, NoteMention, NoteMentionSchema } from './schemas/note.schema';
package/dist/index.js CHANGED
@@ -38,11 +38,8 @@ __exportStar(require("./schemas/notifications.schema"), exports);
38
38
  __exportStar(require("./schemas/organization.schema"), exports);
39
39
  __exportStar(require("./schemas/user.schema"), exports);
40
40
  __exportStar(require("./schemas/group.schema"), exports);
41
+ __exportStar(require("./schemas/tag.schema"), exports);
41
42
  __exportStar(require("./schemas/trigger.schema"), exports);
42
- // Exportação explícita: `influencer.schema.ts` já exporta seu próprio `Note`/`NoteSchema`
43
- // (domínio de anotações do Influencer, sem `mentioneds`, não tocado por esta mudança). A
44
- // exportação nomeada abaixo tem precedência sobre a ambiguidade do `export *` e faz o `Note`
45
- // deste arquivo (usado por Sale/Invoice/Payment/Action) ser o resolvido na raiz do pacote.
46
43
  var note_schema_1 = require("./schemas/note.schema");
47
44
  Object.defineProperty(exports, "Note", { enumerable: true, get: function () { return note_schema_1.Note; } });
48
45
  Object.defineProperty(exports, "NoteSchema", { enumerable: true, get: function () { return note_schema_1.NoteSchema; } });
@@ -60,7 +60,7 @@ export declare const ResponsiblesSchema: MongooseSchema<Responsibles, import("mo
60
60
  }>;
61
61
  export declare const ACTION_BUSINESS_UNIT_VALUES: readonly ["service", "comercial", "squad_a", "squad_b"];
62
62
  export type ActionBusinessUnit = (typeof ACTION_BUSINESS_UNIT_VALUES)[number];
63
- export declare const ACTION_STATUS_VALUES: readonly ["config", "script", "production", "posting", "analytics", "finished", "onHold", "cancelled", "inProgress", "archived"];
63
+ export declare const ACTION_STATUS_VALUES: readonly ["config", "inProgress", "finished", "archived", "cancelled"];
64
64
  export type ActionStatus = (typeof ACTION_STATUS_VALUES)[number];
65
65
  export declare class Action {
66
66
  _id?: Types.ObjectId;
@@ -99,7 +99,7 @@ export declare class Action {
99
99
  keywords?: string[];
100
100
  objective?: string;
101
101
  description?: string;
102
- tags?: string[];
102
+ tags?: Types.ObjectId[];
103
103
  businessUnit?: ActionBusinessUnit;
104
104
  campaign?: Types.ObjectId | Campaign;
105
105
  }
@@ -66,15 +66,10 @@ exports.ACTION_BUSINESS_UNIT_VALUES = [
66
66
  ];
67
67
  exports.ACTION_STATUS_VALUES = [
68
68
  'config',
69
- 'script',
70
- 'production',
71
- 'posting',
72
- 'analytics',
69
+ 'inProgress',
73
70
  'finished',
74
- 'onHold',
71
+ 'archived',
75
72
  'cancelled',
76
- 'inProgress',
77
- 'archived', // legado — mantido por compatibilidade
78
73
  ];
79
74
  let Action = class Action {
80
75
  };
@@ -275,7 +270,7 @@ __decorate([
275
270
  __metadata("design:type", String)
276
271
  ], Action.prototype, "description", void 0);
277
272
  __decorate([
278
- (0, mongoose_1.Prop)({ type: [String], required: false }),
273
+ (0, mongoose_1.Prop)({ type: [{ type: mongoose_2.Schema.Types.ObjectId }], required: false }),
279
274
  __metadata("design:type", Array)
280
275
  ], Action.prototype, "tags", void 0);
281
276
  __decorate([
@@ -299,4 +294,5 @@ exports.ActionSchema.index({ organization: 1, sale: 1 });
299
294
  exports.ActionSchema.index({ sale: 1 });
300
295
  exports.ActionSchema.index({ organization: 1, startDate: 1, endDate: 1 });
301
296
  exports.ActionSchema.index({ 'responsibles.service.email': 1 });
297
+ exports.ActionSchema.index({ campaign: 1 });
302
298
  exports.ActionModel = (0, mongoose_2.model)('Action', exports.ActionSchema);
@@ -51,4 +51,5 @@ Campaign = __decorate([
51
51
  ], Campaign);
52
52
  exports.Campaign = Campaign;
53
53
  exports.CampaignSchema = mongoose_1.SchemaFactory.createForClass(Campaign);
54
+ exports.CampaignSchema.index({ client: 1 });
54
55
  exports.CampaignModel = (0, mongoose_2.model)('Campaign', exports.CampaignSchema);
@@ -34,14 +34,25 @@ export declare class Commission {
34
34
  role: 'origination' | 'commercial' | 'planning' | 'curation';
35
35
  value: number;
36
36
  percentage: number;
37
- status: 'pending' | 'approved' | 'ready' | 'paid' | 'cancelled' | 'disputed';
37
+ status: 'pending' | 'approved' | 'ready' | 'paid' | 'cancelled' | 'disputed' | 'reproved';
38
38
  type: 'collaborator' | 'agency' | 'bonus';
39
39
  sale: Types.ObjectId | Sale;
40
40
  paidAt?: Date;
41
41
  approvedAt?: Date;
42
42
  readyAt?: Date;
43
43
  paymentDate?: Date;
44
- approvedBy?: string;
44
+ approvedBy?: {
45
+ _id: string;
46
+ name: string;
47
+ email: string;
48
+ username: string;
49
+ };
50
+ reprovedBy?: {
51
+ _id: string;
52
+ name: string;
53
+ email: string;
54
+ username: string;
55
+ };
45
56
  description?: string;
46
57
  createdAt?: Date;
47
58
  updatedAt?: Date;
@@ -50,7 +50,7 @@ __decorate([
50
50
  __decorate([
51
51
  (0, mongoose_1.Prop)({
52
52
  type: String,
53
- enum: ['pending', 'approved', 'ready', 'paid', 'cancelled', 'disputed'],
53
+ enum: ['pending', 'approved', 'ready', 'paid', 'cancelled', 'disputed', 'reproved'],
54
54
  default: 'pending',
55
55
  required: true,
56
56
  }),
@@ -85,9 +85,13 @@ __decorate([
85
85
  __metadata("design:type", Date)
86
86
  ], Commission.prototype, "paymentDate", void 0);
87
87
  __decorate([
88
- (0, mongoose_1.Prop)({ type: String, required: false }),
89
- __metadata("design:type", String)
88
+ (0, mongoose_1.Prop)({ type: Object, required: false }),
89
+ __metadata("design:type", Object)
90
90
  ], Commission.prototype, "approvedBy", void 0);
91
+ __decorate([
92
+ (0, mongoose_1.Prop)({ type: Object, required: false }),
93
+ __metadata("design:type", Object)
94
+ ], Commission.prototype, "reprovedBy", void 0);
91
95
  __decorate([
92
96
  (0, mongoose_1.Prop)({ type: String, required: false }),
93
97
  __metadata("design:type", String)
@@ -149,6 +149,8 @@ export declare class Content {
149
149
  sentimentAnalysis?: SentimentAnalysis | null;
150
150
  thumbnailUrl?: string;
151
151
  mediaUrl?: string;
152
+ isEdited?: boolean;
153
+ editedAt?: Date;
152
154
  }
153
155
  export declare const ContentSchema: MongooseSchema<Content, import("mongoose").Model<Content, any, any, any, import("mongoose").Document<unknown, any, Content, any, {}> & Content & Required<{
154
156
  _id: Types.ObjectId;
@@ -295,6 +295,14 @@ __decorate([
295
295
  (0, mongoose_1.Prop)({ type: String, required: false }),
296
296
  __metadata("design:type", String)
297
297
  ], Content.prototype, "mediaUrl", void 0);
298
+ __decorate([
299
+ (0, mongoose_1.Prop)({ type: Boolean, required: false, default: false }),
300
+ __metadata("design:type", Boolean)
301
+ ], Content.prototype, "isEdited", void 0);
302
+ __decorate([
303
+ (0, mongoose_1.Prop)({ type: Date, required: false }),
304
+ __metadata("design:type", Date)
305
+ ], Content.prototype, "editedAt", void 0);
298
306
  Content = __decorate([
299
307
  (0, mongoose_1.Schema)({ timestamps: true })
300
308
  ], Content);
@@ -75,7 +75,7 @@ export declare class Invoice {
75
75
  received?: Received;
76
76
  canceled?: Canceled;
77
77
  notes?: Note[];
78
- tags?: string[];
78
+ tags?: Types.ObjectId[];
79
79
  createdAt?: Date;
80
80
  updatedAt?: Date;
81
81
  }
@@ -225,7 +225,7 @@ __decorate([
225
225
  ], Invoice.prototype, "notes", void 0);
226
226
  __decorate([
227
227
  (0, swagger_1.ApiProperty)({ example: ['Aguardando Faturamento', 'Janeiro'] }),
228
- (0, mongoose_1.Prop)({ type: [String], default: [] }),
228
+ (0, mongoose_1.Prop)({ type: [{ type: mongoose_2.Schema.Types.ObjectId }], default: [] }),
229
229
  __metadata("design:type", Array)
230
230
  ], Invoice.prototype, "tags", void 0);
231
231
  __decorate([
@@ -60,7 +60,7 @@ export declare class Pending {
60
60
  value: number;
61
61
  description: string;
62
62
  installmentNumber: number;
63
- sale: Types.ObjectId | Sale;
63
+ sale?: Types.ObjectId | Sale;
64
64
  action?: Types.ObjectId | Action;
65
65
  commissions?: Types.ObjectId[];
66
66
  }
@@ -171,7 +171,7 @@ export declare class Payment {
171
171
  paid?: Paid;
172
172
  canceled?: Canceled;
173
173
  notes?: Note[];
174
- tags?: string[];
174
+ tags?: Types.ObjectId[];
175
175
  omieId?: string;
176
176
  createdAt?: Date;
177
177
  updatedAt?: Date;
@@ -130,7 +130,7 @@ __decorate([
130
130
  __metadata("design:type", Number)
131
131
  ], Pending.prototype, "installmentNumber", void 0);
132
132
  __decorate([
133
- (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Sale' }),
133
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Sale', required: false }),
134
134
  __metadata("design:type", Object)
135
135
  ], Pending.prototype, "sale", void 0);
136
136
  __decorate([
@@ -320,7 +320,7 @@ __decorate([
320
320
  __metadata("design:type", Array)
321
321
  ], Payment.prototype, "notes", void 0);
322
322
  __decorate([
323
- (0, mongoose_1.Prop)({ type: [String], required: false, default: [] }),
323
+ (0, mongoose_1.Prop)({ type: [{ type: mongoose_2.Schema.Types.ObjectId }], required: false, default: [] }),
324
324
  __metadata("design:type", Array)
325
325
  ], Payment.prototype, "tags", void 0);
326
326
  __decorate([
@@ -341,6 +341,7 @@ Payment = __decorate([
341
341
  exports.Payment = Payment;
342
342
  exports.PaymentSchema = mongoose_1.SchemaFactory.createForClass(Payment);
343
343
  exports.PaymentSchema.index({ 'pending.sale': 1 });
344
+ exports.PaymentSchema.index({ 'pending.sale': 1, 'pending.installmentNumber': 1 });
344
345
  exports.PaymentSchema.index({ 'pending.influencer': 1 });
345
346
  exports.PaymentSchema.index({ 'pending.recruitment': 1 });
346
347
  exports.PaymentSchema.index({ 'pending.action': 1 });
@@ -131,7 +131,7 @@ export declare class Sale {
131
131
  notes?: Note[];
132
132
  activities?: Activity[];
133
133
  organization: Types.ObjectId;
134
- tags?: string[];
134
+ tags?: Types.ObjectId[];
135
135
  timeline?: TimelineEntry[];
136
136
  profiles?: Types.ObjectId[] | Profile[];
137
137
  closedAt?: Date;
@@ -428,7 +428,7 @@ __decorate([
428
428
  __metadata("design:type", mongoose_2.Types.ObjectId)
429
429
  ], Sale.prototype, "organization", void 0);
430
430
  __decorate([
431
- (0, mongoose_1.Prop)({ type: [String], required: false, default: [] }),
431
+ (0, mongoose_1.Prop)({ type: [{ type: mongoose_2.Schema.Types.ObjectId }], required: false, default: [] }),
432
432
  __metadata("design:type", Array)
433
433
  ], Sale.prototype, "tags", void 0);
434
434
  __decorate([
@@ -0,0 +1,44 @@
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/types/schematypes" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ /// <reference types="mongoose/types/inferrawdoctype" />
26
+ import { HydratedDocument, Types } from 'mongoose';
27
+ export type TagDocument = HydratedDocument<Tag>;
28
+ export declare class Tag {
29
+ organization: Types.ObjectId;
30
+ module: string;
31
+ name: string;
32
+ color?: string;
33
+ createdAt?: Date;
34
+ updatedAt?: Date;
35
+ }
36
+ export declare const TagSchema: import("mongoose").Schema<Tag, import("mongoose").Model<Tag, any, any, any, import("mongoose").Document<unknown, any, Tag, any, {}> & Tag & {
37
+ _id: Types.ObjectId;
38
+ } & {
39
+ __v: number;
40
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Tag, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Tag>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Tag> & {
41
+ _id: Types.ObjectId;
42
+ } & {
43
+ __v: number;
44
+ }>;
@@ -0,0 +1,38 @@
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.TagSchema = exports.Tag = void 0;
13
+ const mongoose_1 = require("@nestjs/mongoose");
14
+ const mongoose_2 = require("mongoose");
15
+ let Tag = class Tag {
16
+ };
17
+ __decorate([
18
+ (0, mongoose_1.Prop)({ type: mongoose_2.Types.ObjectId, ref: 'Organization', required: true, index: true }),
19
+ __metadata("design:type", mongoose_2.Types.ObjectId)
20
+ ], Tag.prototype, "organization", void 0);
21
+ __decorate([
22
+ (0, mongoose_1.Prop)({ required: true, enum: ['sales', 'invoices', 'payments', 'actions'], index: true }),
23
+ __metadata("design:type", String)
24
+ ], Tag.prototype, "module", void 0);
25
+ __decorate([
26
+ (0, mongoose_1.Prop)({ required: true, trim: true }),
27
+ __metadata("design:type", String)
28
+ ], Tag.prototype, "name", void 0);
29
+ __decorate([
30
+ (0, mongoose_1.Prop)({ required: false }),
31
+ __metadata("design:type", String)
32
+ ], Tag.prototype, "color", void 0);
33
+ Tag = __decorate([
34
+ (0, mongoose_1.Schema)({ timestamps: true, collection: 'tag' })
35
+ ], Tag);
36
+ exports.Tag = Tag;
37
+ exports.TagSchema = mongoose_1.SchemaFactory.createForClass(Tag);
38
+ exports.TagSchema.index({ organization: 1, module: 1, name: 1 }, { unique: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grapadigital/shared-schemas",
3
- "version": "1.0.178",
3
+ "version": "1.0.180",
4
4
  "description": "Shared Mongoose Schemas",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -21,9 +21,6 @@ export * from './schemas/notifications.schema';
21
21
  export * from './schemas/organization.schema';
22
22
  export * from './schemas/user.schema';
23
23
  export * from './schemas/group.schema';
24
+ export * from './schemas/tag.schema';
24
25
  export * from './schemas/trigger.schema';
25
- // Exportação explícita: `influencer.schema.ts` já exporta seu próprio `Note`/`NoteSchema`
26
- // (domínio de anotações do Influencer, sem `mentioneds`, não tocado por esta mudança). A
27
- // exportação nomeada abaixo tem precedência sobre a ambiguidade do `export *` e faz o `Note`
28
- // deste arquivo (usado por Sale/Invoice/Payment/Action) ser o resolvido na raiz do pacote.
29
26
  export { Note, NoteSchema, NoteMention, NoteMentionSchema } from './schemas/note.schema';
@@ -57,15 +57,10 @@ export type ActionBusinessUnit = (typeof ACTION_BUSINESS_UNIT_VALUES)[number];
57
57
 
58
58
  export const ACTION_STATUS_VALUES = [
59
59
  'config',
60
- 'script',
61
- 'production',
62
- 'posting',
63
- 'analytics',
60
+ 'inProgress',
64
61
  'finished',
65
- 'onHold',
62
+ 'archived',
66
63
  'cancelled',
67
- 'inProgress', // legado — mantido por compatibilidade
68
- 'archived', // legado — mantido por compatibilidade
69
64
  ] as const;
70
65
  export type ActionStatus = (typeof ACTION_STATUS_VALUES)[number];
71
66
 
@@ -231,8 +226,8 @@ export class Action {
231
226
  @Prop({ type: String, required: false })
232
227
  description?: string;
233
228
 
234
- @Prop({ type: [String], required: false})
235
- tags?: string[];
229
+ @Prop({ type: [{ type: MongooseSchema.Types.ObjectId }], required: false })
230
+ tags?: Types.ObjectId[];
236
231
 
237
232
  @ApiProperty({ enum: ACTION_BUSINESS_UNIT_VALUES, required: false })
238
233
  @Prop({ type: String, enum: ACTION_BUSINESS_UNIT_VALUES, required: false })
@@ -251,5 +246,6 @@ ActionSchema.index({ organization: 1, sale: 1 });
251
246
  ActionSchema.index({ sale: 1 });
252
247
  ActionSchema.index({ organization: 1, startDate: 1, endDate: 1 });
253
248
  ActionSchema.index({ 'responsibles.service.email': 1 });
249
+ ActionSchema.index({ campaign: 1 });
254
250
 
255
251
  export const ActionModel = MongooseModel('Action', ActionSchema);
@@ -32,4 +32,7 @@ export class Campaign {
32
32
  }
33
33
 
34
34
  export const CampaignSchema = SchemaFactory.createForClass(Campaign);
35
+
36
+ CampaignSchema.index({ client: 1 });
37
+
35
38
  export const CampaignModel = MongooseModel('Campaign', CampaignSchema);
@@ -41,11 +41,11 @@ export class Commission {
41
41
 
42
42
  @Prop({
43
43
  type: String,
44
- enum: ['pending', 'approved', 'ready', 'paid', 'cancelled', 'disputed'],
44
+ enum: ['pending', 'approved', 'ready', 'paid', 'cancelled', 'disputed', 'reproved'],
45
45
  default: 'pending',
46
46
  required: true,
47
47
  })
48
- status: 'pending' | 'approved' | 'ready' | 'paid' | 'cancelled' | 'disputed';
48
+ status: 'pending' | 'approved' | 'ready' | 'paid' | 'cancelled' | 'disputed' | 'reproved';
49
49
 
50
50
  @Prop({
51
51
  type: String,
@@ -69,8 +69,11 @@ export class Commission {
69
69
  @Prop({ type: Date, required: false })
70
70
  paymentDate?: Date;
71
71
 
72
- @Prop({ type: String, required: false })
73
- approvedBy?: string;
72
+ @Prop({ type: Object, required: false })
73
+ approvedBy?: { _id: string; name: string; email: string; username: string };
74
+
75
+ @Prop({ type: Object, required: false })
76
+ reprovedBy?: { _id: string; name: string; email: string; username: string };
74
77
 
75
78
  @Prop({ type: String, required: false })
76
79
  description?: string;
@@ -225,6 +225,12 @@ export class Content {
225
225
 
226
226
  @Prop({ type: String, required: false })
227
227
  mediaUrl?: string;
228
+
229
+ @Prop({ type: Boolean, required: false, default: false })
230
+ isEdited?: boolean;
231
+
232
+ @Prop({ type: Date, required: false })
233
+ editedAt?: Date;
228
234
  }
229
235
 
230
236
  export const ContentSchema = SchemaFactory.createForClass(Content);
@@ -144,7 +144,7 @@ export class Invoice {
144
144
  @Prop({ type: [Note], default: [] }) notes?: Note[];
145
145
 
146
146
  @ApiProperty({ example: ['Aguardando Faturamento', 'Janeiro'] })
147
- @Prop({ type: [String], default: [] }) tags?: string[];
147
+ @Prop({ type: [{ type: MongooseSchema.Types.ObjectId }], default: [] }) tags?: Types.ObjectId[];
148
148
 
149
149
  @ApiProperty({ example: '2025-08-28T15:00:00.000Z' })
150
150
  @Prop({ default: Date.now }) createdAt?: Date;
@@ -124,8 +124,8 @@ export class Pending {
124
124
 
125
125
  @Prop() installmentNumber: number;
126
126
 
127
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Sale' })
128
- sale: Types.ObjectId | Sale;
127
+ @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Sale', required: false })
128
+ sale?: Types.ObjectId | Sale;
129
129
 
130
130
  @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Action' })
131
131
  action?: Types.ObjectId | Action;
@@ -245,8 +245,8 @@ export class Payment {
245
245
  @Prop({ type: [Note], required: false, default: [] })
246
246
  notes?: Note[];
247
247
 
248
- @Prop({ type: [String], required: false, default: [] })
249
- tags?: string[];
248
+ @Prop({ type: [{ type: MongooseSchema.Types.ObjectId }], required: false, default: [] })
249
+ tags?: Types.ObjectId[];
250
250
 
251
251
  @Prop()
252
252
  omieId?: string;
@@ -261,6 +261,7 @@ export class Payment {
261
261
  export const PaymentSchema = SchemaFactory.createForClass(Payment);
262
262
 
263
263
  PaymentSchema.index({ 'pending.sale': 1 });
264
+ PaymentSchema.index({ 'pending.sale': 1, 'pending.installmentNumber': 1 });
264
265
  PaymentSchema.index({ 'pending.influencer': 1 });
265
266
  PaymentSchema.index({ 'pending.recruitment': 1 });
266
267
  PaymentSchema.index({ 'pending.action': 1 });
@@ -234,8 +234,8 @@ export class Sale {
234
234
  @Prop({ type: MongooseSchema.Types.ObjectId })
235
235
  organization: Types.ObjectId;
236
236
 
237
- @Prop({ type: [String], required: false, default: [] })
238
- tags?: string[];
237
+ @Prop({ type: [{ type: MongooseSchema.Types.ObjectId }], required: false, default: [] })
238
+ tags?: Types.ObjectId[];
239
239
 
240
240
  @Prop([{ type: TimelineEntry, required: false }])
241
241
  timeline?: TimelineEntry[];
@@ -0,0 +1,26 @@
1
+ import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
+ import { HydratedDocument, Types } from 'mongoose';
3
+
4
+ export type TagDocument = HydratedDocument<Tag>;
5
+
6
+ @Schema({ timestamps: true, collection: 'tag' })
7
+ export class Tag {
8
+ @Prop({ type: Types.ObjectId, ref: 'Organization', required: true, index: true })
9
+ organization: Types.ObjectId;
10
+
11
+ @Prop({ required: true, enum: ['sales', 'invoices', 'payments', 'actions'], index: true })
12
+ module: string;
13
+
14
+ @Prop({ required: true, trim: true })
15
+ name: string;
16
+
17
+ @Prop({ required: false })
18
+ color?: string;
19
+
20
+ createdAt?: Date;
21
+ updatedAt?: Date;
22
+ }
23
+
24
+ export const TagSchema = SchemaFactory.createForClass(Tag);
25
+
26
+ TagSchema.index({ organization: 1, module: 1, name: 1 }, { unique: true });