@grapadigital/shared-schemas 1.0.170 → 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,8 @@ 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];
64
66
  export declare const ACTION_STATUS_VALUES: readonly ["config", "script", "production", "posting", "analytics", "finished", "onHold", "cancelled", "inProgress", "archived"];
65
67
  export type ActionStatus = (typeof ACTION_STATUS_VALUES)[number];
66
68
  export declare class Action {
@@ -101,6 +103,7 @@ export declare class Action {
101
103
  objective?: string;
102
104
  description?: string;
103
105
  tags?: string[];
106
+ businessUnit?: ActionBusinessUnit;
104
107
  }
105
108
  export declare const ActionSchema: MongooseSchema<Action, import("mongoose").Model<Action, any, any, any, import("mongoose").Document<unknown, any, Action, any, {}> & Action & Required<{
106
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.ACTION_STATUS_VALUES = 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,12 @@ 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
+ ];
77
83
  exports.ACTION_STATUS_VALUES = [
78
84
  'config',
79
85
  'script',
@@ -288,6 +294,11 @@ __decorate([
288
294
  (0, mongoose_1.Prop)({ type: [String], required: false }),
289
295
  __metadata("design:type", Array)
290
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);
291
302
  Action = __decorate([
292
303
  (0, mongoose_1.Schema)({ timestamps: true })
293
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.170",
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,14 @@ 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
+
57
65
  export const ACTION_STATUS_VALUES = [
58
66
  'config',
59
67
  'script',
@@ -233,6 +241,10 @@ export class Action {
233
241
  @Prop({ type: [String], required: false})
234
242
  tags?: string[];
235
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
+
236
248
  }
237
249
 
238
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);