@grapadigital/shared-schemas 1.0.184 → 1.0.185

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
@@ -9,6 +9,7 @@ export * from './schemas/profile.schema';
9
9
  export * from './schemas/recruitment.schema';
10
10
  export * from './schemas/task.schema';
11
11
  export * from './schemas/script.schema';
12
+ export * from './schemas/creative.schema';
12
13
  export * from './schemas/assignment.schema';
13
14
  export * from './schemas/token.schema';
14
15
  export * from './schemas/webhook.schema';
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ __exportStar(require("./schemas/profile.schema"), exports);
26
26
  __exportStar(require("./schemas/recruitment.schema"), exports);
27
27
  __exportStar(require("./schemas/task.schema"), exports);
28
28
  __exportStar(require("./schemas/script.schema"), exports);
29
+ __exportStar(require("./schemas/creative.schema"), exports);
29
30
  __exportStar(require("./schemas/assignment.schema"), exports);
30
31
  __exportStar(require("./schemas/token.schema"), exports);
31
32
  __exportStar(require("./schemas/webhook.schema"), exports);
@@ -0,0 +1,141 @@
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
+ import { Client } from './client.schema';
29
+ import { Profile } from './profile.schema';
30
+ import { TaskFormat } from './task.schema';
31
+ export type CreativeDocument = HydratedDocument<Creative>;
32
+ export declare const CREATIVE_STATUS_VALUES: readonly ["draft", "pending", "approved", "reproved"];
33
+ export type CreativeStatus = (typeof CREATIVE_STATUS_VALUES)[number];
34
+ export declare const CREATIVE_DECISION_VALUES: readonly ["approved", "reproved", "questioned"];
35
+ export type CreativeDecisionValue = (typeof CREATIVE_DECISION_VALUES)[number];
36
+ export declare const CREATIVE_MEDIA_TYPE_VALUES: readonly ["image", "video"];
37
+ export type CreativeMediaType = (typeof CREATIVE_MEDIA_TYPE_VALUES)[number];
38
+ export declare class CreativeDecision {
39
+ decision: CreativeDecisionValue;
40
+ comment?: string;
41
+ team: string;
42
+ respondedBy: string;
43
+ respondedAt: Date;
44
+ }
45
+ export declare const CreativeDecisionSchema: MongooseSchema<CreativeDecision, import("mongoose").Model<CreativeDecision, any, any, any, import("mongoose").Document<unknown, any, CreativeDecision, any, {}> & CreativeDecision & {
46
+ _id: Types.ObjectId;
47
+ } & {
48
+ __v: number;
49
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, CreativeDecision, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<CreativeDecision>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<CreativeDecision> & {
50
+ _id: Types.ObjectId;
51
+ } & {
52
+ __v: number;
53
+ }>;
54
+ export declare class CreativeStaffReply {
55
+ message: string;
56
+ repliedBy: string;
57
+ repliedAt: Date;
58
+ }
59
+ export declare const CreativeStaffReplySchema: MongooseSchema<CreativeStaffReply, import("mongoose").Model<CreativeStaffReply, any, any, any, import("mongoose").Document<unknown, any, CreativeStaffReply, any, {}> & CreativeStaffReply & {
60
+ _id: Types.ObjectId;
61
+ } & {
62
+ __v: number;
63
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, CreativeStaffReply, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<CreativeStaffReply>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<CreativeStaffReply> & {
64
+ _id: Types.ObjectId;
65
+ } & {
66
+ __v: number;
67
+ }>;
68
+ export declare class CreativeVersion {
69
+ version: number;
70
+ fileUrl?: string | null;
71
+ fileName?: string | null;
72
+ mediaType?: CreativeMediaType | null;
73
+ caption?: string | null;
74
+ status: 'approved' | 'reproved';
75
+ submittedBy?: string;
76
+ submittedAt?: Date;
77
+ decisions: CreativeDecision[];
78
+ staffReplies: CreativeStaffReply[];
79
+ archivedAt: Date;
80
+ }
81
+ export declare const CreativeVersionSchema: MongooseSchema<CreativeVersion, import("mongoose").Model<CreativeVersion, any, any, any, import("mongoose").Document<unknown, any, CreativeVersion, any, {}> & CreativeVersion & {
82
+ _id: Types.ObjectId;
83
+ } & {
84
+ __v: number;
85
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, CreativeVersion, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<CreativeVersion>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<CreativeVersion> & {
86
+ _id: Types.ObjectId;
87
+ } & {
88
+ __v: number;
89
+ }>;
90
+ /**
91
+ * Aprovação de conteúdo (prévia final): um documento por (action, profile,
92
+ * deliverableType, deliverableIndex) — não um doc único por Ação. Mesmo
93
+ * padrão de `Script` (ver GD-532); ao reprovar, o estado atual é arquivado em
94
+ * `versions[]` e o doc fica em `reproved` até o staff editar e reenviar
95
+ * (ver GD-537).
96
+ */
97
+ export declare class Creative {
98
+ _id?: Types.ObjectId;
99
+ action: Types.ObjectId | Action;
100
+ client?: Types.ObjectId | Client;
101
+ profile: Types.ObjectId | Profile;
102
+ deliverableType: TaskFormat;
103
+ deliverableIndex: number;
104
+ version: number;
105
+ fileUrl?: string | null;
106
+ fileName?: string | null;
107
+ mediaType?: CreativeMediaType | null;
108
+ caption?: string | null;
109
+ status: CreativeStatus;
110
+ requiredTeams: string[];
111
+ submittedBy?: string;
112
+ submittedAt?: Date;
113
+ decisions: CreativeDecision[];
114
+ staffReplies: CreativeStaffReply[];
115
+ versions: CreativeVersion[];
116
+ organization?: Types.ObjectId;
117
+ createdAt?: Date;
118
+ updatedAt?: Date;
119
+ }
120
+ export declare const CreativeSchema: MongooseSchema<Creative, import("mongoose").Model<Creative, any, any, any, import("mongoose").Document<unknown, any, Creative, any, {}> & Creative & Required<{
121
+ _id: Types.ObjectId;
122
+ }> & {
123
+ __v: number;
124
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Creative, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Creative>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Creative> & Required<{
125
+ _id: Types.ObjectId;
126
+ }> & {
127
+ __v: number;
128
+ }>;
129
+ export declare const CreativeModel: import("mongoose").Model<Creative, {}, {}, {}, import("mongoose").Document<unknown, {}, Creative, {}, import("mongoose").DefaultSchemaOptions> & Creative & Required<{
130
+ _id: Types.ObjectId;
131
+ }> & {
132
+ __v: number;
133
+ }, MongooseSchema<Creative, import("mongoose").Model<Creative, any, any, any, import("mongoose").Document<unknown, any, Creative, any, {}> & Creative & Required<{
134
+ _id: Types.ObjectId;
135
+ }> & {
136
+ __v: number;
137
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Creative, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Creative>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Creative> & Required<{
138
+ _id: Types.ObjectId;
139
+ }> & {
140
+ __v: number;
141
+ }>>;
@@ -0,0 +1,293 @@
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.CreativeModel = exports.CreativeSchema = exports.Creative = exports.CreativeVersionSchema = exports.CreativeVersion = exports.CreativeStaffReplySchema = exports.CreativeStaffReply = exports.CreativeDecisionSchema = exports.CreativeDecision = exports.CREATIVE_MEDIA_TYPE_VALUES = exports.CREATIVE_DECISION_VALUES = exports.CREATIVE_STATUS_VALUES = void 0;
13
+ const mongoose_1 = require("@nestjs/mongoose");
14
+ const swagger_1 = require("@nestjs/swagger");
15
+ const mongoose_2 = require("mongoose");
16
+ const action_schema_1 = require("./action.schema");
17
+ const client_schema_1 = require("./client.schema");
18
+ const profile_schema_1 = require("./profile.schema");
19
+ const task_schema_1 = require("./task.schema");
20
+ exports.CREATIVE_STATUS_VALUES = [
21
+ 'draft',
22
+ 'pending',
23
+ 'approved',
24
+ 'reproved',
25
+ ];
26
+ exports.CREATIVE_DECISION_VALUES = [
27
+ 'approved',
28
+ 'reproved',
29
+ 'questioned',
30
+ ];
31
+ exports.CREATIVE_MEDIA_TYPE_VALUES = ['image', 'video'];
32
+ let CreativeDecision = class CreativeDecision {
33
+ };
34
+ __decorate([
35
+ (0, swagger_1.ApiProperty)({ enum: exports.CREATIVE_DECISION_VALUES }),
36
+ (0, mongoose_1.Prop)({ type: String, enum: exports.CREATIVE_DECISION_VALUES, required: true }),
37
+ __metadata("design:type", String)
38
+ ], CreativeDecision.prototype, "decision", void 0);
39
+ __decorate([
40
+ (0, swagger_1.ApiProperty)({ required: false }),
41
+ (0, mongoose_1.Prop)({ type: String, required: false }),
42
+ __metadata("design:type", String)
43
+ ], CreativeDecision.prototype, "comment", void 0);
44
+ __decorate([
45
+ (0, swagger_1.ApiProperty)({ description: 'Time do cliente que respondeu, lido do JWT' }),
46
+ (0, mongoose_1.Prop)({ type: String, required: true }),
47
+ __metadata("design:type", String)
48
+ ], CreativeDecision.prototype, "team", void 0);
49
+ __decorate([
50
+ (0, swagger_1.ApiProperty)(),
51
+ (0, mongoose_1.Prop)({ type: String, required: true }),
52
+ __metadata("design:type", String)
53
+ ], CreativeDecision.prototype, "respondedBy", void 0);
54
+ __decorate([
55
+ (0, swagger_1.ApiProperty)(),
56
+ (0, mongoose_1.Prop)({ type: Date, required: true }),
57
+ __metadata("design:type", Date)
58
+ ], CreativeDecision.prototype, "respondedAt", void 0);
59
+ CreativeDecision = __decorate([
60
+ (0, mongoose_1.Schema)({ _id: false })
61
+ ], CreativeDecision);
62
+ exports.CreativeDecision = CreativeDecision;
63
+ exports.CreativeDecisionSchema = mongoose_1.SchemaFactory.createForClass(CreativeDecision);
64
+ let CreativeStaffReply = class CreativeStaffReply {
65
+ };
66
+ __decorate([
67
+ (0, swagger_1.ApiProperty)(),
68
+ (0, mongoose_1.Prop)({ type: String, required: true }),
69
+ __metadata("design:type", String)
70
+ ], CreativeStaffReply.prototype, "message", void 0);
71
+ __decorate([
72
+ (0, swagger_1.ApiProperty)(),
73
+ (0, mongoose_1.Prop)({ type: String, required: true }),
74
+ __metadata("design:type", String)
75
+ ], CreativeStaffReply.prototype, "repliedBy", void 0);
76
+ __decorate([
77
+ (0, swagger_1.ApiProperty)(),
78
+ (0, mongoose_1.Prop)({ type: Date, required: true }),
79
+ __metadata("design:type", Date)
80
+ ], CreativeStaffReply.prototype, "repliedAt", void 0);
81
+ CreativeStaffReply = __decorate([
82
+ (0, mongoose_1.Schema)({ _id: false })
83
+ ], CreativeStaffReply);
84
+ exports.CreativeStaffReply = CreativeStaffReply;
85
+ exports.CreativeStaffReplySchema = mongoose_1.SchemaFactory.createForClass(CreativeStaffReply);
86
+ let CreativeVersion = class CreativeVersion {
87
+ };
88
+ __decorate([
89
+ (0, swagger_1.ApiProperty)(),
90
+ (0, mongoose_1.Prop)({ type: Number, required: true }),
91
+ __metadata("design:type", Number)
92
+ ], CreativeVersion.prototype, "version", void 0);
93
+ __decorate([
94
+ (0, swagger_1.ApiProperty)({ required: false }),
95
+ (0, mongoose_1.Prop)({ type: String, required: false, default: null }),
96
+ __metadata("design:type", Object)
97
+ ], CreativeVersion.prototype, "fileUrl", void 0);
98
+ __decorate([
99
+ (0, swagger_1.ApiProperty)({ required: false }),
100
+ (0, mongoose_1.Prop)({ type: String, required: false, default: null }),
101
+ __metadata("design:type", Object)
102
+ ], CreativeVersion.prototype, "fileName", void 0);
103
+ __decorate([
104
+ (0, swagger_1.ApiProperty)({ enum: exports.CREATIVE_MEDIA_TYPE_VALUES, required: false }),
105
+ (0, mongoose_1.Prop)({
106
+ type: String,
107
+ enum: exports.CREATIVE_MEDIA_TYPE_VALUES,
108
+ required: false,
109
+ default: null,
110
+ }),
111
+ __metadata("design:type", Object)
112
+ ], CreativeVersion.prototype, "mediaType", void 0);
113
+ __decorate([
114
+ (0, swagger_1.ApiProperty)({ required: false }),
115
+ (0, mongoose_1.Prop)({ type: String, required: false, default: null }),
116
+ __metadata("design:type", Object)
117
+ ], CreativeVersion.prototype, "caption", void 0);
118
+ __decorate([
119
+ (0, swagger_1.ApiProperty)({ enum: ['approved', 'reproved'] }),
120
+ (0, mongoose_1.Prop)({ type: String, enum: ['approved', 'reproved'], required: true }),
121
+ __metadata("design:type", String)
122
+ ], CreativeVersion.prototype, "status", void 0);
123
+ __decorate([
124
+ (0, swagger_1.ApiProperty)({ required: false }),
125
+ (0, mongoose_1.Prop)({ type: String, required: false }),
126
+ __metadata("design:type", String)
127
+ ], CreativeVersion.prototype, "submittedBy", void 0);
128
+ __decorate([
129
+ (0, swagger_1.ApiProperty)({ required: false }),
130
+ (0, mongoose_1.Prop)({ type: Date, required: false }),
131
+ __metadata("design:type", Date)
132
+ ], CreativeVersion.prototype, "submittedAt", void 0);
133
+ __decorate([
134
+ (0, swagger_1.ApiProperty)({ type: () => [CreativeDecision] }),
135
+ (0, mongoose_1.Prop)({ type: [exports.CreativeDecisionSchema], default: [] }),
136
+ __metadata("design:type", Array)
137
+ ], CreativeVersion.prototype, "decisions", void 0);
138
+ __decorate([
139
+ (0, swagger_1.ApiProperty)({ type: () => [CreativeStaffReply] }),
140
+ (0, mongoose_1.Prop)({ type: [exports.CreativeStaffReplySchema], default: [] }),
141
+ __metadata("design:type", Array)
142
+ ], CreativeVersion.prototype, "staffReplies", void 0);
143
+ __decorate([
144
+ (0, swagger_1.ApiProperty)(),
145
+ (0, mongoose_1.Prop)({ type: Date, required: true }),
146
+ __metadata("design:type", Date)
147
+ ], CreativeVersion.prototype, "archivedAt", void 0);
148
+ CreativeVersion = __decorate([
149
+ (0, mongoose_1.Schema)({ _id: false })
150
+ ], CreativeVersion);
151
+ exports.CreativeVersion = CreativeVersion;
152
+ exports.CreativeVersionSchema = mongoose_1.SchemaFactory.createForClass(CreativeVersion);
153
+ /**
154
+ * Aprovação de conteúdo (prévia final): um documento por (action, profile,
155
+ * deliverableType, deliverableIndex) — não um doc único por Ação. Mesmo
156
+ * padrão de `Script` (ver GD-532); ao reprovar, o estado atual é arquivado em
157
+ * `versions[]` e o doc fica em `reproved` até o staff editar e reenviar
158
+ * (ver GD-537).
159
+ */
160
+ let Creative = class Creative {
161
+ };
162
+ __decorate([
163
+ (0, swagger_1.ApiProperty)(),
164
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, auto: true, required: false }),
165
+ __metadata("design:type", mongoose_2.Types.ObjectId)
166
+ ], Creative.prototype, "_id", void 0);
167
+ __decorate([
168
+ (0, swagger_1.ApiProperty)({ type: () => action_schema_1.Action }),
169
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Action', required: true }),
170
+ __metadata("design:type", Object)
171
+ ], Creative.prototype, "action", void 0);
172
+ __decorate([
173
+ (0, swagger_1.ApiProperty)({ type: () => client_schema_1.Client }),
174
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Client', required: false }),
175
+ __metadata("design:type", Object)
176
+ ], Creative.prototype, "client", void 0);
177
+ __decorate([
178
+ (0, swagger_1.ApiProperty)({ type: () => profile_schema_1.Profile }),
179
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Profile', required: true }),
180
+ __metadata("design:type", Object)
181
+ ], Creative.prototype, "profile", void 0);
182
+ __decorate([
183
+ (0, swagger_1.ApiProperty)({
184
+ enum: task_schema_1.TASK_FORMAT_VALUES,
185
+ description: 'Unidade de entrega do escopo (mesmos valores de recruitment.scope.delivery)',
186
+ }),
187
+ (0, mongoose_1.Prop)({ type: String, enum: task_schema_1.TASK_FORMAT_VALUES, required: true }),
188
+ __metadata("design:type", String)
189
+ ], Creative.prototype, "deliverableType", void 0);
190
+ __decorate([
191
+ (0, swagger_1.ApiProperty)({
192
+ description: 'Ex.: 1 de 2 quando o escopo pede mais de uma unidade do mesmo tipo; sempre 1 para "story"',
193
+ }),
194
+ (0, mongoose_1.Prop)({ type: Number, required: true, default: 1 }),
195
+ __metadata("design:type", Number)
196
+ ], Creative.prototype, "deliverableIndex", void 0);
197
+ __decorate([
198
+ (0, swagger_1.ApiProperty)(),
199
+ (0, mongoose_1.Prop)({ type: Number, required: true, default: 1 }),
200
+ __metadata("design:type", Number)
201
+ ], Creative.prototype, "version", void 0);
202
+ __decorate([
203
+ (0, swagger_1.ApiProperty)({ required: false }),
204
+ (0, mongoose_1.Prop)({ type: String, required: false, default: null }),
205
+ __metadata("design:type", Object)
206
+ ], Creative.prototype, "fileUrl", void 0);
207
+ __decorate([
208
+ (0, swagger_1.ApiProperty)({ required: false }),
209
+ (0, mongoose_1.Prop)({ type: String, required: false, default: null }),
210
+ __metadata("design:type", Object)
211
+ ], Creative.prototype, "fileName", void 0);
212
+ __decorate([
213
+ (0, swagger_1.ApiProperty)({ enum: exports.CREATIVE_MEDIA_TYPE_VALUES, required: false }),
214
+ (0, mongoose_1.Prop)({
215
+ type: String,
216
+ enum: exports.CREATIVE_MEDIA_TYPE_VALUES,
217
+ required: false,
218
+ default: null,
219
+ }),
220
+ __metadata("design:type", Object)
221
+ ], Creative.prototype, "mediaType", void 0);
222
+ __decorate([
223
+ (0, swagger_1.ApiProperty)({ required: false, description: 'Legenda, campo separado do arquivo' }),
224
+ (0, mongoose_1.Prop)({ type: String, required: false, default: null }),
225
+ __metadata("design:type", Object)
226
+ ], Creative.prototype, "caption", void 0);
227
+ __decorate([
228
+ (0, swagger_1.ApiProperty)({ enum: exports.CREATIVE_STATUS_VALUES }),
229
+ (0, mongoose_1.Prop)({
230
+ type: String,
231
+ enum: exports.CREATIVE_STATUS_VALUES,
232
+ required: true,
233
+ default: 'draft',
234
+ }),
235
+ __metadata("design:type", String)
236
+ ], Creative.prototype, "status", void 0);
237
+ __decorate([
238
+ (0, swagger_1.ApiProperty)({
239
+ type: [String],
240
+ description: 'Snapshot de Client.requiredTeams no momento da criação — vazio = 1 aprovação resolve; com times = todos precisam aprovar',
241
+ }),
242
+ (0, mongoose_1.Prop)({ type: [String], required: false, default: [] }),
243
+ __metadata("design:type", Array)
244
+ ], Creative.prototype, "requiredTeams", void 0);
245
+ __decorate([
246
+ (0, swagger_1.ApiProperty)({ required: false }),
247
+ (0, mongoose_1.Prop)({ type: String, required: false }),
248
+ __metadata("design:type", String)
249
+ ], Creative.prototype, "submittedBy", void 0);
250
+ __decorate([
251
+ (0, swagger_1.ApiProperty)({ required: false }),
252
+ (0, mongoose_1.Prop)({ type: Date, required: false }),
253
+ __metadata("design:type", Date)
254
+ ], Creative.prototype, "submittedAt", void 0);
255
+ __decorate([
256
+ (0, swagger_1.ApiProperty)({ type: () => [CreativeDecision] }),
257
+ (0, mongoose_1.Prop)({ type: [exports.CreativeDecisionSchema], default: [] }),
258
+ __metadata("design:type", Array)
259
+ ], Creative.prototype, "decisions", void 0);
260
+ __decorate([
261
+ (0, swagger_1.ApiProperty)({ type: () => [CreativeStaffReply] }),
262
+ (0, mongoose_1.Prop)({ type: [exports.CreativeStaffReplySchema], default: [] }),
263
+ __metadata("design:type", Array)
264
+ ], Creative.prototype, "staffReplies", void 0);
265
+ __decorate([
266
+ (0, swagger_1.ApiProperty)({ type: () => [CreativeVersion] }),
267
+ (0, mongoose_1.Prop)({ type: [exports.CreativeVersionSchema], default: [] }),
268
+ __metadata("design:type", Array)
269
+ ], Creative.prototype, "versions", void 0);
270
+ __decorate([
271
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, required: false }),
272
+ __metadata("design:type", mongoose_2.Types.ObjectId)
273
+ ], Creative.prototype, "organization", void 0);
274
+ __decorate([
275
+ (0, swagger_1.ApiProperty)(),
276
+ (0, mongoose_1.Prop)({ default: Date.now, required: false }),
277
+ __metadata("design:type", Date)
278
+ ], Creative.prototype, "createdAt", void 0);
279
+ __decorate([
280
+ (0, swagger_1.ApiProperty)(),
281
+ (0, mongoose_1.Prop)({ default: Date.now, required: false }),
282
+ __metadata("design:type", Date)
283
+ ], Creative.prototype, "updatedAt", void 0);
284
+ Creative = __decorate([
285
+ (0, mongoose_1.Schema)({ timestamps: true })
286
+ ], Creative);
287
+ exports.Creative = Creative;
288
+ exports.CreativeSchema = mongoose_1.SchemaFactory.createForClass(Creative);
289
+ exports.CreativeSchema.index({ action: 1, profile: 1, deliverableType: 1, deliverableIndex: 1 }, { unique: true });
290
+ exports.CreativeSchema.index({ action: 1, status: 1 });
291
+ exports.CreativeSchema.index({ client: 1, status: 1 });
292
+ exports.CreativeSchema.index({ organization: 1, status: 1 });
293
+ exports.CreativeModel = (0, mongoose_2.model)('Creative', exports.CreativeSchema);
@@ -33,7 +33,7 @@ declare class UpdatedBy {
33
33
  export declare class Log {
34
34
  _id?: Types.ObjectId;
35
35
  referenceId: string;
36
- reference: 'action' | 'recruitment' | 'content' | 'contract' | 'sale' | 'invoice' | 'payment';
36
+ reference: 'action' | 'recruitment' | 'content' | 'contract' | 'sale' | 'invoice' | 'payment' | 'assignment';
37
37
  type: 'created' | 'updated' | 'deleted' | 'email';
38
38
  phase?: string;
39
39
  changes: Record<string, {
@@ -50,6 +50,7 @@ __decorate([
50
50
  'sale',
51
51
  'invoice',
52
52
  'payment',
53
+ 'assignment',
53
54
  ],
54
55
  }),
55
56
  __metadata("design:type", String)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grapadigital/shared-schemas",
3
- "version": "1.0.184",
3
+ "version": "1.0.185",
4
4
  "description": "Shared Mongoose Schemas",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ export * from './schemas/profile.schema';
9
9
  export * from './schemas/recruitment.schema';
10
10
  export * from './schemas/task.schema';
11
11
  export * from './schemas/script.schema';
12
+ export * from './schemas/creative.schema';
12
13
  export * from './schemas/assignment.schema';
13
14
  export * from './schemas/token.schema';
14
15
  export * from './schemas/webhook.schema';
@@ -0,0 +1,256 @@
1
+ import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
+ import { ApiProperty } from '@nestjs/swagger';
3
+ import {
4
+ HydratedDocument,
5
+ Schema as MongooseSchema,
6
+ Types,
7
+ model as MongooseModel,
8
+ } from 'mongoose';
9
+
10
+ import { Action } from './action.schema';
11
+ import { Client } from './client.schema';
12
+ import { Profile } from './profile.schema';
13
+ import { TASK_FORMAT_VALUES, TaskFormat } from './task.schema';
14
+
15
+ export type CreativeDocument = HydratedDocument<Creative>;
16
+
17
+ export const CREATIVE_STATUS_VALUES = [
18
+ 'draft',
19
+ 'pending',
20
+ 'approved',
21
+ 'reproved',
22
+ ] as const;
23
+ export type CreativeStatus = (typeof CREATIVE_STATUS_VALUES)[number];
24
+
25
+ export const CREATIVE_DECISION_VALUES = [
26
+ 'approved',
27
+ 'reproved',
28
+ 'questioned',
29
+ ] as const;
30
+ export type CreativeDecisionValue = (typeof CREATIVE_DECISION_VALUES)[number];
31
+
32
+ export const CREATIVE_MEDIA_TYPE_VALUES = ['image', 'video'] as const;
33
+ export type CreativeMediaType = (typeof CREATIVE_MEDIA_TYPE_VALUES)[number];
34
+
35
+ @Schema({ _id: false })
36
+ export class CreativeDecision {
37
+ @ApiProperty({ enum: CREATIVE_DECISION_VALUES })
38
+ @Prop({ type: String, enum: CREATIVE_DECISION_VALUES, required: true })
39
+ decision: CreativeDecisionValue;
40
+
41
+ @ApiProperty({ required: false })
42
+ @Prop({ type: String, required: false })
43
+ comment?: string;
44
+
45
+ @ApiProperty({ description: 'Time do cliente que respondeu, lido do JWT' })
46
+ @Prop({ type: String, required: true })
47
+ team: string;
48
+
49
+ @ApiProperty()
50
+ @Prop({ type: String, required: true })
51
+ respondedBy: string;
52
+
53
+ @ApiProperty()
54
+ @Prop({ type: Date, required: true })
55
+ respondedAt: Date;
56
+ }
57
+
58
+ export const CreativeDecisionSchema =
59
+ SchemaFactory.createForClass(CreativeDecision);
60
+
61
+ @Schema({ _id: false })
62
+ export class CreativeStaffReply {
63
+ @ApiProperty()
64
+ @Prop({ type: String, required: true })
65
+ message: string;
66
+
67
+ @ApiProperty()
68
+ @Prop({ type: String, required: true })
69
+ repliedBy: string;
70
+
71
+ @ApiProperty()
72
+ @Prop({ type: Date, required: true })
73
+ repliedAt: Date;
74
+ }
75
+
76
+ export const CreativeStaffReplySchema =
77
+ SchemaFactory.createForClass(CreativeStaffReply);
78
+
79
+ @Schema({ _id: false })
80
+ export class CreativeVersion {
81
+ @ApiProperty()
82
+ @Prop({ type: Number, required: true })
83
+ version: number;
84
+
85
+ @ApiProperty({ required: false })
86
+ @Prop({ type: String, required: false, default: null })
87
+ fileUrl?: string | null;
88
+
89
+ @ApiProperty({ required: false })
90
+ @Prop({ type: String, required: false, default: null })
91
+ fileName?: string | null;
92
+
93
+ @ApiProperty({ enum: CREATIVE_MEDIA_TYPE_VALUES, required: false })
94
+ @Prop({
95
+ type: String,
96
+ enum: CREATIVE_MEDIA_TYPE_VALUES,
97
+ required: false,
98
+ default: null,
99
+ })
100
+ mediaType?: CreativeMediaType | null;
101
+
102
+ @ApiProperty({ required: false })
103
+ @Prop({ type: String, required: false, default: null })
104
+ caption?: string | null;
105
+
106
+ @ApiProperty({ enum: ['approved', 'reproved'] })
107
+ @Prop({ type: String, enum: ['approved', 'reproved'], required: true })
108
+ status: 'approved' | 'reproved';
109
+
110
+ @ApiProperty({ required: false })
111
+ @Prop({ type: String, required: false })
112
+ submittedBy?: string;
113
+
114
+ @ApiProperty({ required: false })
115
+ @Prop({ type: Date, required: false })
116
+ submittedAt?: Date;
117
+
118
+ @ApiProperty({ type: () => [CreativeDecision] })
119
+ @Prop({ type: [CreativeDecisionSchema], default: [] })
120
+ decisions: CreativeDecision[];
121
+
122
+ @ApiProperty({ type: () => [CreativeStaffReply] })
123
+ @Prop({ type: [CreativeStaffReplySchema], default: [] })
124
+ staffReplies: CreativeStaffReply[];
125
+
126
+ @ApiProperty()
127
+ @Prop({ type: Date, required: true })
128
+ archivedAt: Date;
129
+ }
130
+
131
+ export const CreativeVersionSchema =
132
+ SchemaFactory.createForClass(CreativeVersion);
133
+
134
+ /**
135
+ * Aprovação de conteúdo (prévia final): um documento por (action, profile,
136
+ * deliverableType, deliverableIndex) — não um doc único por Ação. Mesmo
137
+ * padrão de `Script` (ver GD-532); ao reprovar, o estado atual é arquivado em
138
+ * `versions[]` e o doc fica em `reproved` até o staff editar e reenviar
139
+ * (ver GD-537).
140
+ */
141
+ @Schema({ timestamps: true })
142
+ export class Creative {
143
+ @ApiProperty()
144
+ @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
145
+ _id?: Types.ObjectId;
146
+
147
+ @ApiProperty({ type: () => Action })
148
+ @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Action', required: true })
149
+ action: Types.ObjectId | Action;
150
+
151
+ @ApiProperty({ type: () => Client })
152
+ @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Client', required: false })
153
+ client?: Types.ObjectId | Client;
154
+
155
+ @ApiProperty({ type: () => Profile })
156
+ @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Profile', required: true })
157
+ profile: Types.ObjectId | Profile;
158
+
159
+ @ApiProperty({
160
+ enum: TASK_FORMAT_VALUES,
161
+ description: 'Unidade de entrega do escopo (mesmos valores de recruitment.scope.delivery)',
162
+ })
163
+ @Prop({ type: String, enum: TASK_FORMAT_VALUES, required: true })
164
+ deliverableType: TaskFormat;
165
+
166
+ @ApiProperty({
167
+ description: 'Ex.: 1 de 2 quando o escopo pede mais de uma unidade do mesmo tipo; sempre 1 para "story"',
168
+ })
169
+ @Prop({ type: Number, required: true, default: 1 })
170
+ deliverableIndex: number;
171
+
172
+ @ApiProperty()
173
+ @Prop({ type: Number, required: true, default: 1 })
174
+ version: number;
175
+
176
+ @ApiProperty({ required: false })
177
+ @Prop({ type: String, required: false, default: null })
178
+ fileUrl?: string | null;
179
+
180
+ @ApiProperty({ required: false })
181
+ @Prop({ type: String, required: false, default: null })
182
+ fileName?: string | null;
183
+
184
+ @ApiProperty({ enum: CREATIVE_MEDIA_TYPE_VALUES, required: false })
185
+ @Prop({
186
+ type: String,
187
+ enum: CREATIVE_MEDIA_TYPE_VALUES,
188
+ required: false,
189
+ default: null,
190
+ })
191
+ mediaType?: CreativeMediaType | null;
192
+
193
+ @ApiProperty({ required: false, description: 'Legenda, campo separado do arquivo' })
194
+ @Prop({ type: String, required: false, default: null })
195
+ caption?: string | null;
196
+
197
+ @ApiProperty({ enum: CREATIVE_STATUS_VALUES })
198
+ @Prop({
199
+ type: String,
200
+ enum: CREATIVE_STATUS_VALUES,
201
+ required: true,
202
+ default: 'draft',
203
+ })
204
+ status: CreativeStatus;
205
+
206
+ @ApiProperty({
207
+ type: [String],
208
+ description:
209
+ 'Snapshot de Client.requiredTeams no momento da criação — vazio = 1 aprovação resolve; com times = todos precisam aprovar',
210
+ })
211
+ @Prop({ type: [String], required: false, default: [] })
212
+ requiredTeams: string[];
213
+
214
+ @ApiProperty({ required: false })
215
+ @Prop({ type: String, required: false })
216
+ submittedBy?: string;
217
+
218
+ @ApiProperty({ required: false })
219
+ @Prop({ type: Date, required: false })
220
+ submittedAt?: Date;
221
+
222
+ @ApiProperty({ type: () => [CreativeDecision] })
223
+ @Prop({ type: [CreativeDecisionSchema], default: [] })
224
+ decisions: CreativeDecision[];
225
+
226
+ @ApiProperty({ type: () => [CreativeStaffReply] })
227
+ @Prop({ type: [CreativeStaffReplySchema], default: [] })
228
+ staffReplies: CreativeStaffReply[];
229
+
230
+ @ApiProperty({ type: () => [CreativeVersion] })
231
+ @Prop({ type: [CreativeVersionSchema], default: [] })
232
+ versions: CreativeVersion[];
233
+
234
+ @Prop({ type: MongooseSchema.Types.ObjectId, required: false })
235
+ organization?: Types.ObjectId;
236
+
237
+ @ApiProperty()
238
+ @Prop({ default: Date.now, required: false })
239
+ createdAt?: Date;
240
+
241
+ @ApiProperty()
242
+ @Prop({ default: Date.now, required: false })
243
+ updatedAt?: Date;
244
+ }
245
+
246
+ export const CreativeSchema = SchemaFactory.createForClass(Creative);
247
+
248
+ CreativeSchema.index(
249
+ { action: 1, profile: 1, deliverableType: 1, deliverableIndex: 1 },
250
+ { unique: true },
251
+ );
252
+ CreativeSchema.index({ action: 1, status: 1 });
253
+ CreativeSchema.index({ client: 1, status: 1 });
254
+ CreativeSchema.index({ organization: 1, status: 1 });
255
+
256
+ export const CreativeModel = MongooseModel('Creative', CreativeSchema);
@@ -28,9 +28,10 @@ export class Log {
28
28
  'sale',
29
29
  'invoice',
30
30
  'payment',
31
+ 'assignment',
31
32
  ],
32
33
  })
33
- reference: 'action' | 'recruitment' | 'content' | 'contract' | 'sale' | 'invoice' | 'payment';
34
+ reference: 'action' | 'recruitment' | 'content' | 'contract' | 'sale' | 'invoice' | 'payment' | 'assignment';
34
35
 
35
36
  @Prop({
36
37
  required: true,