@grapadigital/shared-schemas 1.0.179 → 1.0.181

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
@@ -8,6 +8,7 @@ export * from './schemas/payment.schema';
8
8
  export * from './schemas/profile.schema';
9
9
  export * from './schemas/recruitment.schema';
10
10
  export * from './schemas/task.schema';
11
+ export * from './schemas/assignment.schema';
11
12
  export * from './schemas/token.schema';
12
13
  export * from './schemas/webhook.schema';
13
14
  export * from './schemas/sale.schema';
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ __exportStar(require("./schemas/payment.schema"), exports);
25
25
  __exportStar(require("./schemas/profile.schema"), exports);
26
26
  __exportStar(require("./schemas/recruitment.schema"), exports);
27
27
  __exportStar(require("./schemas/task.schema"), exports);
28
+ __exportStar(require("./schemas/assignment.schema"), exports);
28
29
  __exportStar(require("./schemas/token.schema"), exports);
29
30
  __exportStar(require("./schemas/webhook.schema"), exports);
30
31
  __exportStar(require("./schemas/sale.schema"), exports);
@@ -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
  }
@@ -270,7 +270,7 @@ __decorate([
270
270
  __metadata("design:type", String)
271
271
  ], Action.prototype, "description", void 0);
272
272
  __decorate([
273
- (0, mongoose_1.Prop)({ type: [String], required: false }),
273
+ (0, mongoose_1.Prop)({ type: [{ type: mongoose_2.Schema.Types.ObjectId }], required: false }),
274
274
  __metadata("design:type", Array)
275
275
  ], Action.prototype, "tags", void 0);
276
276
  __decorate([
@@ -0,0 +1,87 @@
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, Schema as MongooseSchema, Types } from 'mongoose';
27
+ import { Action } from './action.schema';
28
+ export type AssignmentDocument = HydratedDocument<Assignment>;
29
+ export declare const ASSIGNMENT_TYPE_VALUES: readonly ["report", "curation", "opt-in", "metrics-monitoring", "data-update", "study"];
30
+ export type AssignmentType = (typeof ASSIGNMENT_TYPE_VALUES)[number];
31
+ export declare const ASSIGNMENT_STATUS_VALUES: readonly ["todo", "in-progress", "waiting", "review", "done", "paused", "cancelled", "deleted"];
32
+ export type AssignmentStatus = (typeof ASSIGNMENT_STATUS_VALUES)[number];
33
+ export declare const ASSIGNMENT_RECURRENCE_FREQUENCY_VALUES: readonly ["none", "daily", "weekly", "biweekly", "monthly", "yearly", "weekdays", "custom"];
34
+ export type AssignmentRecurrenceFrequency = (typeof ASSIGNMENT_RECURRENCE_FREQUENCY_VALUES)[number];
35
+ export declare class AssignmentRecurrence {
36
+ frequency: AssignmentRecurrenceFrequency;
37
+ interval?: number;
38
+ byWeekday?: number[];
39
+ until?: Date;
40
+ occurrencesCount?: number;
41
+ }
42
+ export declare const AssignmentRecurrenceSchema: MongooseSchema<AssignmentRecurrence, import("mongoose").Model<AssignmentRecurrence, any, any, any, import("mongoose").Document<unknown, any, AssignmentRecurrence, any, {}> & AssignmentRecurrence & {
43
+ _id: Types.ObjectId;
44
+ } & {
45
+ __v: number;
46
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, AssignmentRecurrence, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<AssignmentRecurrence>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<AssignmentRecurrence> & {
47
+ _id: Types.ObjectId;
48
+ } & {
49
+ __v: number;
50
+ }>;
51
+ export declare class Assignment {
52
+ _id?: Types.ObjectId;
53
+ action: Types.ObjectId | Action;
54
+ organization: Types.ObjectId;
55
+ type: AssignmentType;
56
+ title: string;
57
+ responsible?: Types.ObjectId;
58
+ dueDate?: Date | null;
59
+ status: AssignmentStatus;
60
+ recurrence?: AssignmentRecurrence;
61
+ seriesId?: Types.ObjectId;
62
+ notes?: string;
63
+ createdAt?: Date;
64
+ updatedAt?: Date;
65
+ }
66
+ export declare const AssignmentSchema: MongooseSchema<Assignment, import("mongoose").Model<Assignment, any, any, any, import("mongoose").Document<unknown, any, Assignment, any, {}> & Assignment & Required<{
67
+ _id: Types.ObjectId;
68
+ }> & {
69
+ __v: number;
70
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Assignment, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Assignment>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Assignment> & Required<{
71
+ _id: Types.ObjectId;
72
+ }> & {
73
+ __v: number;
74
+ }>;
75
+ export declare const AssignmentModel: import("mongoose").Model<Assignment, {}, {}, {}, import("mongoose").Document<unknown, {}, Assignment, {}, import("mongoose").DefaultSchemaOptions> & Assignment & Required<{
76
+ _id: Types.ObjectId;
77
+ }> & {
78
+ __v: number;
79
+ }, MongooseSchema<Assignment, import("mongoose").Model<Assignment, any, any, any, import("mongoose").Document<unknown, any, Assignment, any, {}> & Assignment & Required<{
80
+ _id: Types.ObjectId;
81
+ }> & {
82
+ __v: number;
83
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Assignment, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Assignment>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Assignment> & Required<{
84
+ _id: Types.ObjectId;
85
+ }> & {
86
+ __v: number;
87
+ }>>;
@@ -0,0 +1,162 @@
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.AssignmentModel = exports.AssignmentSchema = exports.Assignment = exports.AssignmentRecurrenceSchema = exports.AssignmentRecurrence = exports.ASSIGNMENT_RECURRENCE_FREQUENCY_VALUES = exports.ASSIGNMENT_STATUS_VALUES = exports.ASSIGNMENT_TYPE_VALUES = void 0;
13
+ const mongoose_1 = require("@nestjs/mongoose");
14
+ const swagger_1 = require("@nestjs/swagger");
15
+ const mongoose_2 = require("mongoose");
16
+ exports.ASSIGNMENT_TYPE_VALUES = [
17
+ 'report',
18
+ 'curation',
19
+ 'opt-in',
20
+ 'metrics-monitoring',
21
+ 'data-update',
22
+ 'study',
23
+ ];
24
+ exports.ASSIGNMENT_STATUS_VALUES = [
25
+ 'todo',
26
+ 'in-progress',
27
+ 'waiting',
28
+ 'review',
29
+ 'done',
30
+ 'paused',
31
+ 'cancelled',
32
+ 'deleted',
33
+ ];
34
+ exports.ASSIGNMENT_RECURRENCE_FREQUENCY_VALUES = [
35
+ 'none',
36
+ 'daily',
37
+ 'weekly',
38
+ 'biweekly',
39
+ 'monthly',
40
+ 'yearly',
41
+ 'weekdays',
42
+ 'custom',
43
+ ];
44
+ let AssignmentRecurrence = class AssignmentRecurrence {
45
+ };
46
+ __decorate([
47
+ (0, swagger_1.ApiProperty)({ enum: exports.ASSIGNMENT_RECURRENCE_FREQUENCY_VALUES, example: 'monthly' }),
48
+ (0, mongoose_1.Prop)({
49
+ type: String,
50
+ enum: exports.ASSIGNMENT_RECURRENCE_FREQUENCY_VALUES,
51
+ required: true,
52
+ }),
53
+ __metadata("design:type", String)
54
+ ], AssignmentRecurrence.prototype, "frequency", void 0);
55
+ __decorate([
56
+ (0, swagger_1.ApiProperty)({ example: 1, required: false }),
57
+ (0, mongoose_1.Prop)({ type: Number, required: false }),
58
+ __metadata("design:type", Number)
59
+ ], AssignmentRecurrence.prototype, "interval", void 0);
60
+ __decorate([
61
+ (0, swagger_1.ApiProperty)({ example: [1, 3, 5], required: false }),
62
+ (0, mongoose_1.Prop)({ type: [Number], required: false }),
63
+ __metadata("design:type", Array)
64
+ ], AssignmentRecurrence.prototype, "byWeekday", void 0);
65
+ __decorate([
66
+ (0, swagger_1.ApiProperty)({ example: '2026-12-31T00:00:00.000Z', required: false }),
67
+ (0, mongoose_1.Prop)({ type: Date, required: false }),
68
+ __metadata("design:type", Date)
69
+ ], AssignmentRecurrence.prototype, "until", void 0);
70
+ __decorate([
71
+ (0, swagger_1.ApiProperty)({ example: 12, required: false }),
72
+ (0, mongoose_1.Prop)({ type: Number, required: false }),
73
+ __metadata("design:type", Number)
74
+ ], AssignmentRecurrence.prototype, "occurrencesCount", void 0);
75
+ AssignmentRecurrence = __decorate([
76
+ (0, mongoose_1.Schema)({ _id: false })
77
+ ], AssignmentRecurrence);
78
+ exports.AssignmentRecurrence = AssignmentRecurrence;
79
+ exports.AssignmentRecurrenceSchema = mongoose_1.SchemaFactory.createForClass(AssignmentRecurrence);
80
+ let Assignment = class Assignment {
81
+ };
82
+ __decorate([
83
+ (0, swagger_1.ApiProperty)({ example: '64bfc3a78d3f1e2a12345670' }),
84
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, auto: true, required: false }),
85
+ __metadata("design:type", mongoose_2.Types.ObjectId)
86
+ ], Assignment.prototype, "_id", void 0);
87
+ __decorate([
88
+ (0, swagger_1.ApiProperty)({ example: '64bfc3a78d3f1e2a12345678' }),
89
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Action', required: true }),
90
+ __metadata("design:type", Object)
91
+ ], Assignment.prototype, "action", void 0);
92
+ __decorate([
93
+ (0, swagger_1.ApiProperty)({ example: '64bfc3a78d3f1e2a12345679' }),
94
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, required: true }),
95
+ __metadata("design:type", mongoose_2.Types.ObjectId)
96
+ ], Assignment.prototype, "organization", void 0);
97
+ __decorate([
98
+ (0, swagger_1.ApiProperty)({ enum: exports.ASSIGNMENT_TYPE_VALUES, example: 'report' }),
99
+ (0, mongoose_1.Prop)({ type: String, enum: exports.ASSIGNMENT_TYPE_VALUES, required: true }),
100
+ __metadata("design:type", String)
101
+ ], Assignment.prototype, "type", void 0);
102
+ __decorate([
103
+ (0, swagger_1.ApiProperty)({ example: 'Relatório mensal de performance' }),
104
+ (0, mongoose_1.Prop)({ type: String, required: true }),
105
+ __metadata("design:type", String)
106
+ ], Assignment.prototype, "title", void 0);
107
+ __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)
111
+ ], Assignment.prototype, "responsible", void 0);
112
+ __decorate([
113
+ (0, swagger_1.ApiProperty)({ example: '2026-09-01T00:00:00.000Z', required: false }),
114
+ (0, mongoose_1.Prop)({ type: Date, required: false, default: null }),
115
+ __metadata("design:type", Object)
116
+ ], Assignment.prototype, "dueDate", void 0);
117
+ __decorate([
118
+ (0, swagger_1.ApiProperty)({ enum: exports.ASSIGNMENT_STATUS_VALUES, example: 'todo' }),
119
+ (0, mongoose_1.Prop)({
120
+ type: String,
121
+ enum: exports.ASSIGNMENT_STATUS_VALUES,
122
+ default: 'todo',
123
+ required: true,
124
+ }),
125
+ __metadata("design:type", String)
126
+ ], Assignment.prototype, "status", void 0);
127
+ __decorate([
128
+ (0, swagger_1.ApiProperty)({ type: () => AssignmentRecurrence, required: false }),
129
+ (0, mongoose_1.Prop)({ type: exports.AssignmentRecurrenceSchema, required: false }),
130
+ __metadata("design:type", AssignmentRecurrence)
131
+ ], Assignment.prototype, "recurrence", void 0);
132
+ __decorate([
133
+ (0, swagger_1.ApiProperty)({ example: '64bfc3a78d3f1e2a1234567b', required: false }),
134
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, required: false }),
135
+ __metadata("design:type", mongoose_2.Types.ObjectId)
136
+ ], Assignment.prototype, "seriesId", void 0);
137
+ __decorate([
138
+ (0, swagger_1.ApiProperty)({ example: 'Aguardando retorno do cliente', required: false }),
139
+ (0, mongoose_1.Prop)({ type: String, required: false }),
140
+ __metadata("design:type", String)
141
+ ], Assignment.prototype, "notes", void 0);
142
+ __decorate([
143
+ (0, swagger_1.ApiProperty)({ example: '2026-08-26T15:00:00.000Z' }),
144
+ (0, mongoose_1.Prop)({ type: Date, default: Date.now, required: false }),
145
+ __metadata("design:type", Date)
146
+ ], Assignment.prototype, "createdAt", void 0);
147
+ __decorate([
148
+ (0, swagger_1.ApiProperty)({ example: '2026-08-26T15:00:00.000Z' }),
149
+ (0, mongoose_1.Prop)({ type: Date, default: Date.now, required: false }),
150
+ __metadata("design:type", Date)
151
+ ], Assignment.prototype, "updatedAt", void 0);
152
+ Assignment = __decorate([
153
+ (0, mongoose_1.Schema)({ timestamps: true })
154
+ ], Assignment);
155
+ exports.Assignment = Assignment;
156
+ exports.AssignmentSchema = mongoose_1.SchemaFactory.createForClass(Assignment);
157
+ exports.AssignmentSchema.index({ action: 1 });
158
+ exports.AssignmentSchema.index({ organization: 1, status: 1 });
159
+ exports.AssignmentSchema.index({ organization: 1, dueDate: 1 });
160
+ exports.AssignmentSchema.index({ seriesId: 1 });
161
+ exports.AssignmentSchema.index({ responsible: 1, dueDate: 1 });
162
+ exports.AssignmentModel = (0, mongoose_2.model)('Assignment', exports.AssignmentSchema);
@@ -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([
@@ -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;
@@ -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([
@@ -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([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grapadigital/shared-schemas",
3
- "version": "1.0.179",
3
+ "version": "1.0.181",
4
4
  "description": "Shared Mongoose Schemas",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ export * from './schemas/payment.schema';
8
8
  export * from './schemas/profile.schema';
9
9
  export * from './schemas/recruitment.schema';
10
10
  export * from './schemas/task.schema';
11
+ export * from './schemas/assignment.schema';
11
12
  export * from './schemas/token.schema';
12
13
  export * from './schemas/webhook.schema';
13
14
  export * from './schemas/sale.schema';
@@ -226,8 +226,8 @@ export class Action {
226
226
  @Prop({ type: String, required: false })
227
227
  description?: string;
228
228
 
229
- @Prop({ type: [String], required: false})
230
- tags?: string[];
229
+ @Prop({ type: [{ type: MongooseSchema.Types.ObjectId }], required: false })
230
+ tags?: Types.ObjectId[];
231
231
 
232
232
  @ApiProperty({ enum: ACTION_BUSINESS_UNIT_VALUES, required: false })
233
233
  @Prop({ type: String, enum: ACTION_BUSINESS_UNIT_VALUES, required: false })
@@ -0,0 +1,149 @@
1
+ import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
+ import { ApiProperty } from '@nestjs/swagger';
3
+
4
+ import {
5
+ HydratedDocument,
6
+ Schema as MongooseSchema,
7
+ Types,
8
+ model as MongooseModel,
9
+ } from 'mongoose';
10
+
11
+ import { Action } from './action.schema';
12
+
13
+ export type AssignmentDocument = HydratedDocument<Assignment>;
14
+
15
+ export const ASSIGNMENT_TYPE_VALUES = [
16
+ 'report',
17
+ 'curation',
18
+ 'opt-in',
19
+ 'metrics-monitoring',
20
+ 'data-update',
21
+ 'study',
22
+ ] as const;
23
+ export type AssignmentType = (typeof ASSIGNMENT_TYPE_VALUES)[number];
24
+
25
+ export const ASSIGNMENT_STATUS_VALUES = [
26
+ 'todo',
27
+ 'in-progress',
28
+ 'waiting',
29
+ 'review',
30
+ 'done',
31
+ 'paused',
32
+ 'cancelled',
33
+ 'deleted',
34
+ ] as const;
35
+ export type AssignmentStatus = (typeof ASSIGNMENT_STATUS_VALUES)[number];
36
+
37
+ export const ASSIGNMENT_RECURRENCE_FREQUENCY_VALUES = [
38
+ 'none',
39
+ 'daily',
40
+ 'weekly',
41
+ 'biweekly',
42
+ 'monthly',
43
+ 'yearly',
44
+ 'weekdays',
45
+ 'custom',
46
+ ] as const;
47
+ export type AssignmentRecurrenceFrequency =
48
+ (typeof ASSIGNMENT_RECURRENCE_FREQUENCY_VALUES)[number];
49
+
50
+ @Schema({ _id: false })
51
+ export class AssignmentRecurrence {
52
+ @ApiProperty({ enum: ASSIGNMENT_RECURRENCE_FREQUENCY_VALUES, example: 'monthly' })
53
+ @Prop({
54
+ type: String,
55
+ enum: ASSIGNMENT_RECURRENCE_FREQUENCY_VALUES,
56
+ required: true,
57
+ })
58
+ frequency: AssignmentRecurrenceFrequency;
59
+
60
+ @ApiProperty({ example: 1, required: false })
61
+ @Prop({ type: Number, required: false })
62
+ interval?: number;
63
+
64
+ @ApiProperty({ example: [1, 3, 5], required: false })
65
+ @Prop({ type: [Number], required: false })
66
+ byWeekday?: number[];
67
+
68
+ @ApiProperty({ example: '2026-12-31T00:00:00.000Z', required: false })
69
+ @Prop({ type: Date, required: false })
70
+ until?: Date;
71
+
72
+ @ApiProperty({ example: 12, required: false })
73
+ @Prop({ type: Number, required: false })
74
+ occurrencesCount?: number;
75
+ }
76
+
77
+ export const AssignmentRecurrenceSchema = SchemaFactory.createForClass(
78
+ AssignmentRecurrence,
79
+ );
80
+
81
+ @Schema({ timestamps: true })
82
+ export class Assignment {
83
+ @ApiProperty({ example: '64bfc3a78d3f1e2a12345670' })
84
+ @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
85
+ _id?: Types.ObjectId;
86
+
87
+ @ApiProperty({ example: '64bfc3a78d3f1e2a12345678' })
88
+ @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Action', required: true })
89
+ action: Types.ObjectId | Action;
90
+
91
+ @ApiProperty({ example: '64bfc3a78d3f1e2a12345679' })
92
+ @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
93
+ organization: Types.ObjectId;
94
+
95
+ @ApiProperty({ enum: ASSIGNMENT_TYPE_VALUES, example: 'report' })
96
+ @Prop({ type: String, enum: ASSIGNMENT_TYPE_VALUES, required: true })
97
+ type: AssignmentType;
98
+
99
+ @ApiProperty({ example: 'Relatório mensal de performance' })
100
+ @Prop({ type: String, required: true })
101
+ title: string;
102
+
103
+ @ApiProperty({ example: '64bfc3a78d3f1e2a1234567a', required: false })
104
+ @Prop({ type: MongooseSchema.Types.ObjectId, required: false })
105
+ responsible?: Types.ObjectId;
106
+
107
+ @ApiProperty({ example: '2026-09-01T00:00:00.000Z', required: false })
108
+ @Prop({ type: Date, required: false, default: null })
109
+ dueDate?: Date | null;
110
+
111
+ @ApiProperty({ enum: ASSIGNMENT_STATUS_VALUES, example: 'todo' })
112
+ @Prop({
113
+ type: String,
114
+ enum: ASSIGNMENT_STATUS_VALUES,
115
+ default: 'todo',
116
+ required: true,
117
+ })
118
+ status: AssignmentStatus;
119
+
120
+ @ApiProperty({ type: () => AssignmentRecurrence, required: false })
121
+ @Prop({ type: AssignmentRecurrenceSchema, required: false })
122
+ recurrence?: AssignmentRecurrence;
123
+
124
+ @ApiProperty({ example: '64bfc3a78d3f1e2a1234567b', required: false })
125
+ @Prop({ type: MongooseSchema.Types.ObjectId, required: false })
126
+ seriesId?: Types.ObjectId;
127
+
128
+ @ApiProperty({ example: 'Aguardando retorno do cliente', required: false })
129
+ @Prop({ type: String, required: false })
130
+ notes?: string;
131
+
132
+ @ApiProperty({ example: '2026-08-26T15:00:00.000Z' })
133
+ @Prop({ type: Date, default: Date.now, required: false })
134
+ createdAt?: Date;
135
+
136
+ @ApiProperty({ example: '2026-08-26T15:00:00.000Z' })
137
+ @Prop({ type: Date, default: Date.now, required: false })
138
+ updatedAt?: Date;
139
+ }
140
+
141
+ export const AssignmentSchema = SchemaFactory.createForClass(Assignment);
142
+
143
+ AssignmentSchema.index({ action: 1 });
144
+ AssignmentSchema.index({ organization: 1, status: 1 });
145
+ AssignmentSchema.index({ organization: 1, dueDate: 1 });
146
+ AssignmentSchema.index({ seriesId: 1 });
147
+ AssignmentSchema.index({ responsible: 1, dueDate: 1 });
148
+
149
+ export const AssignmentModel = MongooseModel('Assignment', AssignmentSchema);
@@ -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;
@@ -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;
@@ -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[];