@grapadigital/shared-schemas 1.0.169 → 1.0.171

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.
@@ -61,6 +61,10 @@ declare class Note {
61
61
  owner: string;
62
62
  createdAt: Date;
63
63
  }
64
+ export declare const ACTION_BUSINESS_UNIT_VALUES: readonly ["service", "comercial", "squad_a", "squad_b"];
65
+ export type ActionBusinessUnit = (typeof ACTION_BUSINESS_UNIT_VALUES)[number];
66
+ export declare const ACTION_STATUS_VALUES: readonly ["config", "script", "production", "posting", "analytics", "finished", "onHold", "cancelled", "inProgress", "archived"];
67
+ export type ActionStatus = (typeof ACTION_STATUS_VALUES)[number];
64
68
  export declare class Action {
65
69
  _id?: Types.ObjectId;
66
70
  title: string;
@@ -68,7 +72,7 @@ export declare class Action {
68
72
  startDate: Date;
69
73
  endDate: Date;
70
74
  nps?: number;
71
- status: 'config' | 'inProgress' | 'onHold' | 'finished' | 'archived';
75
+ status: ActionStatus;
72
76
  partnership: 'partner' | 'exclusive';
73
77
  type: 'seeding' | 'ugc' | 'creator';
74
78
  socialnetworks?: string[];
@@ -99,6 +103,7 @@ export declare class Action {
99
103
  objective?: string;
100
104
  description?: string;
101
105
  tags?: string[];
106
+ businessUnit?: ActionBusinessUnit;
102
107
  }
103
108
  export declare const ActionSchema: MongooseSchema<Action, import("mongoose").Model<Action, any, any, any, import("mongoose").Document<unknown, any, Action, any, {}> & Action & Required<{
104
109
  _id: Types.ObjectId;
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ActionModel = exports.ActionSchema = exports.Action = exports.ResponsiblesSchema = exports.Responsibles = exports.ResponsibleSchema = exports.Responsible = void 0;
12
+ exports.ActionModel = exports.ActionSchema = exports.Action = exports.ACTION_STATUS_VALUES = exports.ACTION_BUSINESS_UNIT_VALUES = exports.ResponsiblesSchema = exports.Responsibles = exports.ResponsibleSchema = exports.Responsible = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const swagger_1 = require("@nestjs/swagger");
15
15
  const mongoose_2 = require("mongoose");
@@ -74,6 +74,24 @@ Note = __decorate([
74
74
  (0, mongoose_1.Schema)({ _id: false })
75
75
  ], Note);
76
76
  const NoteSchema = mongoose_1.SchemaFactory.createForClass(Note);
77
+ exports.ACTION_BUSINESS_UNIT_VALUES = [
78
+ 'service',
79
+ 'comercial',
80
+ 'squad_a',
81
+ 'squad_b',
82
+ ];
83
+ exports.ACTION_STATUS_VALUES = [
84
+ 'config',
85
+ 'script',
86
+ 'production',
87
+ 'posting',
88
+ 'analytics',
89
+ 'finished',
90
+ 'onHold',
91
+ 'cancelled',
92
+ 'inProgress',
93
+ 'archived', // legado — mantido por compatibilidade
94
+ ];
77
95
  let Action = class Action {
78
96
  };
79
97
  __decorate([
@@ -107,10 +125,10 @@ __decorate([
107
125
  __metadata("design:type", Number)
108
126
  ], Action.prototype, "nps", void 0);
109
127
  __decorate([
110
- (0, swagger_1.ApiProperty)({ enum: ['config', 'inProgress', 'onHold', 'finished', 'archived'], example: 'config' }),
128
+ (0, swagger_1.ApiProperty)({ enum: exports.ACTION_STATUS_VALUES, example: 'config' }),
111
129
  (0, mongoose_1.Prop)({
112
130
  type: String,
113
- enum: ['config', 'inProgress', 'onHold', 'finished', 'archived'],
131
+ enum: exports.ACTION_STATUS_VALUES,
114
132
  default: 'config',
115
133
  required: true,
116
134
  }),
@@ -276,6 +294,11 @@ __decorate([
276
294
  (0, mongoose_1.Prop)({ type: [String], required: false }),
277
295
  __metadata("design:type", Array)
278
296
  ], Action.prototype, "tags", void 0);
297
+ __decorate([
298
+ (0, swagger_1.ApiProperty)({ enum: exports.ACTION_BUSINESS_UNIT_VALUES, required: false }),
299
+ (0, mongoose_1.Prop)({ type: String, enum: exports.ACTION_BUSINESS_UNIT_VALUES, required: false }),
300
+ __metadata("design:type", String)
301
+ ], Action.prototype, "businessUnit", void 0);
279
302
  Action = __decorate([
280
303
  (0, mongoose_1.Schema)({ timestamps: true })
281
304
  ], Action);
@@ -24,7 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  /// <reference types="mongoose/types/inferrawdoctype" />
26
26
  import { HydratedDocument, Schema as MongooseSchema, Types } from 'mongoose';
27
- import { Action } from './action.schema';
27
+ import { Action, ActionBusinessUnit } from './action.schema';
28
28
  import { Client } from './client.schema';
29
29
  import { Content } from './content.schema';
30
30
  import { Influencer } from './influencer.schema';
@@ -33,7 +33,7 @@ import { Recruitment } from './recruitment.schema';
33
33
  export type TaskDocument = HydratedDocument<Task>;
34
34
  export declare const TASK_FORMAT_VALUES: readonly ["reel", "image", "carousel", "story", "tiktok", "youtube", "linkedin", "pinterest"];
35
35
  export type TaskFormat = (typeof TASK_FORMAT_VALUES)[number];
36
- export declare const TASK_TYPE_VALUES: readonly ["briefing", "script", "production", "posting", "analytics"];
36
+ export declare const TASK_TYPE_VALUES: readonly ["briefing", "script", "production", "posting", "analytics", "diagnosis"];
37
37
  export type TaskType = (typeof TASK_TYPE_VALUES)[number];
38
38
  export declare const TASK_STATUS_BY_TYPE: Record<TaskType, string[]>;
39
39
  export declare class Task {
@@ -44,7 +44,7 @@ export declare class Task {
44
44
  profile: Types.ObjectId | Profile;
45
45
  influencer: Types.ObjectId | Influencer;
46
46
  deliverableId: Types.ObjectId;
47
- format: TaskFormat;
47
+ format?: TaskFormat;
48
48
  sequence: number;
49
49
  type: TaskType;
50
50
  status: string;
@@ -54,6 +54,8 @@ export declare class Task {
54
54
  socialnetwork?: string;
55
55
  requiredTags?: string;
56
56
  observation?: string;
57
+ organization: Types.ObjectId;
58
+ businessUnit?: ActionBusinessUnit;
57
59
  }
58
60
  export declare const TaskSchema: MongooseSchema<Task, import("mongoose").Model<Task, any, any, any, import("mongoose").Document<unknown, any, Task, any, {}> & Task & Required<{
59
61
  _id: Types.ObjectId;
@@ -13,6 +13,7 @@ exports.TaskModel = exports.TaskSchema = exports.Task = exports.TASK_STATUS_BY_T
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const swagger_1 = require("@nestjs/swagger");
15
15
  const mongoose_2 = require("mongoose");
16
+ const action_schema_1 = require("./action.schema");
16
17
  exports.TASK_FORMAT_VALUES = [
17
18
  'reel',
18
19
  'image',
@@ -29,13 +30,15 @@ exports.TASK_TYPE_VALUES = [
29
30
  'production',
30
31
  'posting',
31
32
  'analytics',
33
+ 'diagnosis',
32
34
  ];
33
35
  exports.TASK_STATUS_BY_TYPE = {
34
- briefing: ['awaiting', 'received'],
35
- script: ['pending', 'approval', 'rework', 'approved'],
36
- production: ['pending', 'approval', 'rework', 'approved', 'cancelled'],
37
- posting: ['pending', 'scheduled', 'published', 'late', 'cancelled'],
38
- analytics: ['requested', 'received'],
36
+ briefing: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
37
+ script: ['awaiting', 'pending', 'late', 'done', 'approval', 'rework', 'cancelled'],
38
+ production: ['awaiting', 'pending', 'late', 'done', 'approval', 'rework', 'cancelled'],
39
+ posting: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
40
+ analytics: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
41
+ diagnosis: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
39
42
  };
40
43
  let Task = class Task {
41
44
  };
@@ -75,8 +78,14 @@ __decorate([
75
78
  __metadata("design:type", mongoose_2.Types.ObjectId)
76
79
  ], Task.prototype, "deliverableId", void 0);
77
80
  __decorate([
78
- (0, swagger_1.ApiProperty)({ enum: exports.TASK_FORMAT_VALUES, example: 'reel' }),
79
- (0, mongoose_1.Prop)({ type: String, enum: exports.TASK_FORMAT_VALUES, required: true }),
81
+ (0, swagger_1.ApiProperty)({ enum: exports.TASK_FORMAT_VALUES, example: 'reel', required: false }),
82
+ (0, mongoose_1.Prop)({
83
+ type: String,
84
+ enum: exports.TASK_FORMAT_VALUES,
85
+ required: function () {
86
+ return this.type !== 'diagnosis';
87
+ },
88
+ }),
80
89
  __metadata("design:type", String)
81
90
  ], Task.prototype, "format", void 0);
82
91
  __decorate([
@@ -133,15 +142,27 @@ __decorate([
133
142
  (0, mongoose_1.Prop)({ type: String, required: false }),
134
143
  __metadata("design:type", String)
135
144
  ], Task.prototype, "observation", void 0);
145
+ __decorate([
146
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, required: true }),
147
+ __metadata("design:type", mongoose_2.Types.ObjectId)
148
+ ], Task.prototype, "organization", void 0);
149
+ __decorate([
150
+ (0, swagger_1.ApiProperty)({ enum: action_schema_1.ACTION_BUSINESS_UNIT_VALUES, required: false }),
151
+ (0, mongoose_1.Prop)({ type: String, enum: action_schema_1.ACTION_BUSINESS_UNIT_VALUES, required: false }),
152
+ __metadata("design:type", String)
153
+ ], Task.prototype, "businessUnit", void 0);
136
154
  Task = __decorate([
137
155
  (0, mongoose_1.Schema)({ timestamps: true })
138
156
  ], Task);
139
157
  exports.Task = Task;
140
158
  exports.TaskSchema = mongoose_1.SchemaFactory.createForClass(Task);
141
159
  exports.TaskSchema.index({ deliverableId: 1 });
160
+ exports.TaskSchema.index({ deliverableId: 1, type: 1 }, { unique: true });
142
161
  exports.TaskSchema.index({ recruitment: 1 });
143
162
  exports.TaskSchema.index({ action: 1, type: 1, status: 1 });
144
163
  exports.TaskSchema.index({ dueDate: 1 });
145
164
  exports.TaskSchema.index({ client: 1, dueDate: 1 });
146
165
  exports.TaskSchema.index({ influencer: 1, dueDate: 1 });
166
+ exports.TaskSchema.index({ organization: 1 });
167
+ exports.TaskSchema.index({ businessUnit: 1 });
147
168
  exports.TaskModel = (0, mongoose_2.model)('Task', exports.TaskSchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grapadigital/shared-schemas",
3
- "version": "1.0.169",
3
+ "version": "1.0.171",
4
4
  "description": "Shared Mongoose Schemas",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -54,6 +54,27 @@ class Note {
54
54
 
55
55
  const NoteSchema = SchemaFactory.createForClass(Note);
56
56
 
57
+ export const ACTION_BUSINESS_UNIT_VALUES = [
58
+ 'service',
59
+ 'comercial',
60
+ 'squad_a',
61
+ 'squad_b',
62
+ ] as const;
63
+ export type ActionBusinessUnit = (typeof ACTION_BUSINESS_UNIT_VALUES)[number];
64
+
65
+ export const ACTION_STATUS_VALUES = [
66
+ 'config',
67
+ 'script',
68
+ 'production',
69
+ 'posting',
70
+ 'analytics',
71
+ 'finished',
72
+ 'onHold',
73
+ 'cancelled',
74
+ 'inProgress', // legado — mantido por compatibilidade
75
+ 'archived', // legado — mantido por compatibilidade
76
+ ] as const;
77
+ export type ActionStatus = (typeof ACTION_STATUS_VALUES)[number];
57
78
 
58
79
  @Schema({ timestamps: true })
59
80
  export class Action {
@@ -81,14 +102,14 @@ export class Action {
81
102
  @Prop({ type: Number, required: false })
82
103
  nps?: number;
83
104
 
84
- @ApiProperty({ enum: ['config', 'inProgress', 'onHold', 'finished', 'archived'], example: 'config' })
105
+ @ApiProperty({ enum: ACTION_STATUS_VALUES, example: 'config' })
85
106
  @Prop({
86
107
  type: String,
87
- enum: ['config', 'inProgress', 'onHold', 'finished', 'archived'],
108
+ enum: ACTION_STATUS_VALUES,
88
109
  default: 'config',
89
110
  required: true,
90
111
  })
91
- status: 'config' | 'inProgress' | 'onHold' | 'finished' | 'archived';
112
+ status: ActionStatus;
92
113
 
93
114
  @ApiProperty({ enum: ['partner', 'exclusive'], example: 'partner' })
94
115
  @Prop({ type: String, enum: ['partner', 'exclusive'], required: true })
@@ -220,6 +241,10 @@ export class Action {
220
241
  @Prop({ type: [String], required: false})
221
242
  tags?: string[];
222
243
 
244
+ @ApiProperty({ enum: ACTION_BUSINESS_UNIT_VALUES, required: false })
245
+ @Prop({ type: String, enum: ACTION_BUSINESS_UNIT_VALUES, required: false })
246
+ businessUnit?: ActionBusinessUnit;
247
+
223
248
  }
224
249
 
225
250
  export const ActionSchema = SchemaFactory.createForClass(Action);
@@ -8,7 +8,11 @@ import {
8
8
  model as MongooseModel,
9
9
  } from 'mongoose';
10
10
 
11
- import { Action } from './action.schema';
11
+ import {
12
+ Action,
13
+ ACTION_BUSINESS_UNIT_VALUES,
14
+ ActionBusinessUnit,
15
+ } from './action.schema';
12
16
  import { Client } from './client.schema';
13
17
  import { Content } from './content.schema';
14
18
  import { Influencer } from './influencer.schema';
@@ -35,15 +39,17 @@ export const TASK_TYPE_VALUES = [
35
39
  'production',
36
40
  'posting',
37
41
  'analytics',
42
+ 'diagnosis',
38
43
  ] as const;
39
44
  export type TaskType = (typeof TASK_TYPE_VALUES)[number];
40
45
 
41
46
  export const TASK_STATUS_BY_TYPE: Record<TaskType, string[]> = {
42
- briefing: ['awaiting', 'received'],
43
- script: ['pending', 'approval', 'rework', 'approved'],
44
- production: ['pending', 'approval', 'rework', 'approved', 'cancelled'],
45
- posting: ['pending', 'scheduled', 'published', 'late', 'cancelled'],
46
- analytics: ['requested', 'received'],
47
+ briefing: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
48
+ script: ['awaiting', 'pending', 'late', 'done', 'approval', 'rework', 'cancelled'],
49
+ production: ['awaiting', 'pending', 'late', 'done', 'approval', 'rework', 'cancelled'],
50
+ posting: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
51
+ analytics: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
52
+ diagnosis: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
47
53
  };
48
54
 
49
55
  @Schema({ timestamps: true })
@@ -76,9 +82,15 @@ export class Task {
76
82
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
77
83
  deliverableId: Types.ObjectId;
78
84
 
79
- @ApiProperty({ enum: TASK_FORMAT_VALUES, example: 'reel' })
80
- @Prop({ type: String, enum: TASK_FORMAT_VALUES, required: true })
81
- format: TaskFormat;
85
+ @ApiProperty({ enum: TASK_FORMAT_VALUES, example: 'reel', required: false })
86
+ @Prop({
87
+ type: String,
88
+ enum: TASK_FORMAT_VALUES,
89
+ required: function (this: Task) {
90
+ return this.type !== 'diagnosis';
91
+ },
92
+ })
93
+ format?: TaskFormat;
82
94
 
83
95
  @ApiProperty({ example: 1 })
84
96
  @Prop({ type: Number, required: true })
@@ -124,15 +136,25 @@ export class Task {
124
136
  @ApiProperty({ example: 'Confirmar com o cliente antes de publicar', required: false })
125
137
  @Prop({ type: String, required: false })
126
138
  observation?: string;
139
+
140
+ @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
141
+ organization: Types.ObjectId;
142
+
143
+ @ApiProperty({ enum: ACTION_BUSINESS_UNIT_VALUES, required: false })
144
+ @Prop({ type: String, enum: ACTION_BUSINESS_UNIT_VALUES, required: false })
145
+ businessUnit?: ActionBusinessUnit;
127
146
  }
128
147
 
129
148
  export const TaskSchema = SchemaFactory.createForClass(Task);
130
149
 
131
150
  TaskSchema.index({ deliverableId: 1 });
151
+ TaskSchema.index({ deliverableId: 1, type: 1 }, { unique: true });
132
152
  TaskSchema.index({ recruitment: 1 });
133
153
  TaskSchema.index({ action: 1, type: 1, status: 1 });
134
154
  TaskSchema.index({ dueDate: 1 });
135
155
  TaskSchema.index({ client: 1, dueDate: 1 });
136
156
  TaskSchema.index({ influencer: 1, dueDate: 1 });
157
+ TaskSchema.index({ organization: 1 });
158
+ TaskSchema.index({ businessUnit: 1 });
137
159
 
138
160
  export const TaskModel = MongooseModel('Task', TaskSchema);