@grapadigital/shared-schemas 1.0.240 → 1.0.242

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.
Files changed (53) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +2 -0
  3. package/dist/schemas/action.schema.d.ts +4 -4
  4. package/dist/schemas/assignment.schema.d.ts +3 -3
  5. package/dist/schemas/benchmark.schema.d.ts +2 -2
  6. package/dist/schemas/campaign.schema.d.ts +2 -2
  7. package/dist/schemas/client.schema.d.ts +62 -26
  8. package/dist/schemas/client.schema.js +2 -2
  9. package/dist/schemas/comment.schema.d.ts +4 -4
  10. package/dist/schemas/commission.schema.d.ts +2 -2
  11. package/dist/schemas/content-capture-process.schema.d.ts +6 -6
  12. package/dist/schemas/content-draft.schema.d.ts +2 -2
  13. package/dist/schemas/content.schema.d.ts +14 -14
  14. package/dist/schemas/contract.schema.d.ts +2 -2
  15. package/dist/schemas/creative.schema.d.ts +5 -5
  16. package/dist/schemas/export-comments-job.schema.d.ts +2 -2
  17. package/dist/schemas/group.schema.d.ts +1 -1
  18. package/dist/schemas/influencer.schema.d.ts +6 -6
  19. package/dist/schemas/invoice.schema.d.ts +2 -2
  20. package/dist/schemas/job.schema.d.ts +2 -2
  21. package/dist/schemas/lead.schema.d.ts +14 -14
  22. package/dist/schemas/log.schema.d.ts +2 -2
  23. package/dist/schemas/note.schema.d.ts +2 -2
  24. package/dist/schemas/notifications.schema.d.ts +2 -2
  25. package/dist/schemas/organization.schema.d.ts +1 -1
  26. package/dist/schemas/party.schema.d.ts +5 -5
  27. package/dist/schemas/payment.schema.d.ts +10 -10
  28. package/dist/schemas/profile.schema.d.ts +2 -2
  29. package/dist/schemas/project.schema.d.ts +5 -5
  30. package/dist/schemas/prospect.schema.d.ts +3 -3
  31. package/dist/schemas/recruitment.schema.d.ts +14 -14
  32. package/dist/schemas/responsible.schema.d.ts +1 -1
  33. package/dist/schemas/sale.schema.d.ts +3 -3
  34. package/dist/schemas/script.schema.d.ts +5 -5
  35. package/dist/schemas/snapshot.schema.d.ts +2 -2
  36. package/dist/schemas/store-visit.schema.d.ts +51 -0
  37. package/dist/schemas/store-visit.schema.js +85 -0
  38. package/dist/schemas/store.schema.d.ts +61 -0
  39. package/dist/schemas/store.schema.js +61 -0
  40. package/dist/schemas/supplier.schema.d.ts +2 -2
  41. package/dist/schemas/tag.schema.d.ts +1 -1
  42. package/dist/schemas/task.schema.d.ts +6 -4
  43. package/dist/schemas/task.schema.js +23 -1
  44. package/dist/schemas/token.schema.d.ts +2 -2
  45. package/dist/schemas/trigger.schema.d.ts +1 -1
  46. package/dist/schemas/user.schema.d.ts +1 -1
  47. package/dist/schemas/webhook.schema.d.ts +5 -5
  48. package/package.json +8 -5
  49. package/src/index.ts +2 -0
  50. package/src/schemas/client.schema.ts +2 -2
  51. package/src/schemas/store-visit.schema.ts +68 -0
  52. package/src/schemas/store.schema.ts +52 -0
  53. package/src/schemas/task.schema.ts +35 -2
@@ -14,6 +14,7 @@ const mongoose_1 = require("@nestjs/mongoose");
14
14
  const swagger_1 = require("@nestjs/swagger");
15
15
  const mongoose_2 = require("mongoose");
16
16
  const action_schema_1 = require("./action.schema");
17
+ const store_visit_schema_1 = require("./store-visit.schema");
17
18
  exports.TASK_FORMAT_VALUES = [
18
19
  'reel',
19
20
  'image',
@@ -31,6 +32,7 @@ exports.TASK_TYPE_VALUES = [
31
32
  'posting',
32
33
  'analytics',
33
34
  'diagnosis',
35
+ 'store_visit',
34
36
  ];
35
37
  exports.TASK_STATUS_BY_TYPE = {
36
38
  briefing: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
@@ -39,6 +41,14 @@ exports.TASK_STATUS_BY_TYPE = {
39
41
  posting: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
40
42
  analytics: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
41
43
  diagnosis: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
44
+ store_visit: [
45
+ 'awaiting_confirmation',
46
+ 'confirmed',
47
+ 'awaiting_approval',
48
+ 'approved',
49
+ 'finished',
50
+ 'cancelled',
51
+ ],
42
52
  };
43
53
  exports.TASK_STATUS_VALUES = [
44
54
  'awaiting',
@@ -48,6 +58,11 @@ exports.TASK_STATUS_VALUES = [
48
58
  'rework',
49
59
  'done',
50
60
  'cancelled',
61
+ 'awaiting_confirmation',
62
+ 'confirmed',
63
+ 'awaiting_approval',
64
+ 'approved',
65
+ 'finished',
51
66
  ];
52
67
  let Task = class Task {
53
68
  };
@@ -92,7 +107,7 @@ __decorate([
92
107
  type: String,
93
108
  enum: exports.TASK_FORMAT_VALUES,
94
109
  required: function () {
95
- return this.type !== 'diagnosis';
110
+ return this.type !== 'diagnosis' && this.type !== 'store_visit';
96
111
  },
97
112
  }),
98
113
  __metadata("design:type", String)
@@ -160,6 +175,11 @@ __decorate([
160
175
  (0, mongoose_1.Prop)({ type: String, enum: action_schema_1.ACTION_BUSINESS_UNIT_VALUES, required: false }),
161
176
  __metadata("design:type", String)
162
177
  ], Task.prototype, "businessUnit", void 0);
178
+ __decorate([
179
+ (0, swagger_1.ApiProperty)({ type: () => store_visit_schema_1.StoreVisitData, required: false }),
180
+ (0, mongoose_1.Prop)({ type: store_visit_schema_1.StoreVisitDataSchema, required: false }),
181
+ __metadata("design:type", store_visit_schema_1.StoreVisitData)
182
+ ], Task.prototype, "storeVisit", void 0);
163
183
  Task = __decorate([
164
184
  (0, mongoose_1.Schema)({ timestamps: true })
165
185
  ], Task);
@@ -174,4 +194,6 @@ exports.TaskSchema.index({ client: 1, dueDate: 1 });
174
194
  exports.TaskSchema.index({ influencer: 1, dueDate: 1 });
175
195
  exports.TaskSchema.index({ organization: 1 });
176
196
  exports.TaskSchema.index({ businessUnit: 1 });
197
+ exports.TaskSchema.index({ 'storeVisit.token': 1 }, { unique: true, sparse: true });
198
+ exports.TaskSchema.index({ 'storeVisit.store': 1 }, { sparse: true });
177
199
  exports.TaskModel = (0, mongoose_2.model)('Task', exports.TaskSchema);
@@ -40,7 +40,7 @@ export declare const TokenSchema: MongooseSchema<Token, import("mongoose").Model
40
40
  _id: Types.ObjectId;
41
41
  }> & {
42
42
  __v: number;
43
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Token, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Token>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Token> & Required<{
43
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Token, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Token>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<Token> & Required<{
44
44
  _id: Types.ObjectId;
45
45
  }> & {
46
46
  __v: number;
@@ -53,7 +53,7 @@ export declare const TokenModel: import("mongoose").Model<Token, {}, {}, {}, imp
53
53
  _id: Types.ObjectId;
54
54
  }> & {
55
55
  __v: number;
56
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Token, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Token>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Token> & Required<{
56
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Token, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Token>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<Token> & Required<{
57
57
  _id: Types.ObjectId;
58
58
  }> & {
59
59
  __v: number;
@@ -46,7 +46,7 @@ export declare const TriggerSchema: import("mongoose").Schema<Trigger, import("m
46
46
  _id: Types.ObjectId;
47
47
  } & {
48
48
  __v: number;
49
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Trigger, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Trigger>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Trigger> & {
49
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Trigger, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Trigger>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<Trigger> & {
50
50
  _id: Types.ObjectId;
51
51
  } & {
52
52
  __v: number;
@@ -57,7 +57,7 @@ export declare const UserSchema: import("mongoose").Schema<User, import("mongoos
57
57
  _id: Types.ObjectId;
58
58
  } & {
59
59
  __v: number;
60
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, User, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<User>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<User> & {
60
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, User, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<User>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<User> & {
61
61
  _id: Types.ObjectId;
62
62
  } & {
63
63
  __v: number;
@@ -33,7 +33,7 @@ export declare const MovementInfoSchema: MongooseSchema<MovementInfo, import("mo
33
33
  _id: Types.ObjectId;
34
34
  } & {
35
35
  __v: number;
36
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, MovementInfo, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<MovementInfo>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<MovementInfo> & {
36
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, MovementInfo, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<MovementInfo>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<MovementInfo> & {
37
37
  _id: Types.ObjectId;
38
38
  } & {
39
39
  __v: number;
@@ -49,7 +49,7 @@ export declare const MovedBySchema: MongooseSchema<MovedBy, import("mongoose").M
49
49
  _id: Types.ObjectId;
50
50
  } & {
51
51
  __v: number;
52
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, MovedBy, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<MovedBy>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<MovedBy> & {
52
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, MovedBy, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<MovedBy>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<MovedBy> & {
53
53
  _id: Types.ObjectId;
54
54
  } & {
55
55
  __v: number;
@@ -63,7 +63,7 @@ export declare const CardInfoSchema: MongooseSchema<CardInfo, import("mongoose")
63
63
  _id: Types.ObjectId;
64
64
  } & {
65
65
  __v: number;
66
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, CardInfo, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<CardInfo>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<CardInfo> & {
66
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, CardInfo, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<CardInfo>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<CardInfo> & {
67
67
  _id: Types.ObjectId;
68
68
  } & {
69
69
  __v: number;
@@ -79,7 +79,7 @@ export declare const EventDataSchema: MongooseSchema<EventData, import("mongoose
79
79
  _id: Types.ObjectId;
80
80
  } & {
81
81
  __v: number;
82
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, EventData, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<EventData>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<EventData> & {
82
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, EventData, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<EventData>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<EventData> & {
83
83
  _id: Types.ObjectId;
84
84
  } & {
85
85
  __v: number;
@@ -94,7 +94,7 @@ export declare const WebhookSchema: MongooseSchema<Webhook, import("mongoose").M
94
94
  _id: Types.ObjectId;
95
95
  }> & {
96
96
  __v: number;
97
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Webhook, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Webhook>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Webhook> & Required<{
97
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Webhook, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Webhook>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<Webhook> & Required<{
98
98
  _id: Types.ObjectId;
99
99
  }> & {
100
100
  __v: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grapadigital/shared-schemas",
3
- "version": "1.0.240",
3
+ "version": "1.0.242",
4
4
  "description": "Shared Mongoose Schemas",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,7 +8,12 @@
8
8
  "build": "tsc",
9
9
  "prepublishOnly": "npm run build"
10
10
  },
11
- "dependencies": {
11
+ "peerDependencies": {
12
+ "@nestjs/mongoose": "^10.0.0 || ^11.0.0",
13
+ "@nestjs/swagger": "^7.4.0 || ^11.0.0",
14
+ "mongoose": "^8.10.1"
15
+ },
16
+ "devDependencies": {
12
17
  "@nestjs/mongoose": "^11.0.1",
13
18
  "@nestjs/swagger": "^11.2.0",
14
19
  "@typescript-eslint/eslint-plugin": "^8.24.0",
@@ -16,9 +21,7 @@
16
21
  "eslint": "^9.20.1",
17
22
  "eslint-config-prettier": "^10.0.1",
18
23
  "eslint-plugin-prettier": "^5.2.3",
19
- "mongoose": "^8.10.1"
20
- },
21
- "devDependencies": {
24
+ "mongoose": "^8.10.1",
22
25
  "typescript": "^4.9.0"
23
26
  },
24
27
  "repository": {
package/src/index.ts CHANGED
@@ -36,5 +36,7 @@ export * from './schemas/export-comments-job.schema';
36
36
  export * from './schemas/job.schema';
37
37
  export * from './schemas/snapshot.schema';
38
38
  export * from './schemas/lead.schema';
39
+ export * from './schemas/store.schema';
40
+ export * from './schemas/store-visit.schema';
39
41
  export * from './utils/normalize-content-link.util';
40
42
  export * from './utils/merge-metrics-breakdown.util';
@@ -14,9 +14,9 @@ export type ClientDocument = HydratedDocument<Client>;
14
14
 
15
15
  /**
16
16
  * Personalizações de cliente: ligam telas e regras que valem só para ele.
17
- * Ver GD-683.
17
+ * Ver GD-683 (samsung) e GD-663 (shoulder).
18
18
  */
19
- export const CLIENT_CUSTOMIZATION_VALUES = ['samsung'] as const;
19
+ export const CLIENT_CUSTOMIZATION_VALUES = ['samsung', 'shoulder'] as const;
20
20
  export type ClientCustomization = (typeof CLIENT_CUSTOMIZATION_VALUES)[number];
21
21
 
22
22
  /**
@@ -0,0 +1,68 @@
1
+ import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
+ import { ApiProperty } from '@nestjs/swagger';
3
+ import { Schema as MongooseSchema, Types } from 'mongoose';
4
+ import { Store } from './store.schema';
5
+
6
+ export const STORE_VISIT_STATUS_VALUES = [
7
+ 'awaiting_confirmation', // Cadastrada pelo time, aguardando influenciadora confirmar horário e aceitar regras
8
+ 'confirmed', // Influenciadora confirmou horário e aceite registrado
9
+ 'awaiting_approval', // Fotos de looks e etiquetas submetidas para aprovação
10
+ 'approved', // Looks e etiquetas aprovados pelo time
11
+ 'done', // Visita realizada em loja
12
+ 'finished', // Processo encerrado e notificação emitida
13
+ ] as const;
14
+
15
+ export type StoreVisitStatus = (typeof STORE_VISIT_STATUS_VALUES)[number];
16
+
17
+ export const STORE_VISIT_PERIOD_VALUES = [
18
+ 'morning',
19
+ 'afternoon',
20
+ 'night',
21
+ ] as const;
22
+
23
+ export type StoreVisitPeriod = (typeof STORE_VISIT_PERIOD_VALUES)[number];
24
+
25
+ @Schema({ _id: false })
26
+ export class StoreVisitData {
27
+ @ApiProperty({ example: '64bfc3a78d3f1e2a12345684', description: 'Loja física agendada' })
28
+ @Prop({
29
+ type: MongooseSchema.Types.ObjectId,
30
+ ref: Store.name,
31
+ required: true,
32
+ })
33
+ store: Types.ObjectId | Store;
34
+
35
+ @ApiProperty({ example: '2026-11-15T00:00:00.000Z', description: 'Data da visita agendada pelo time' })
36
+ @Prop({ type: Date, required: true })
37
+ scheduledDate: Date;
38
+
39
+ @ApiProperty({ example: 'afternoon', enum: STORE_VISIT_PERIOD_VALUES, required: false, nullable: true })
40
+ @Prop({ type: String, enum: STORE_VISIT_PERIOD_VALUES, required: false, default: null })
41
+ scheduledPeriod?: StoreVisitPeriod | null;
42
+
43
+ @ApiProperty({ example: 'abcdef123456...', description: 'Token de 32 bytes base64url' })
44
+ @Prop({ type: String, required: true })
45
+ token: string;
46
+
47
+ @ApiProperty({ example: false, default: false })
48
+ @Prop({ type: Boolean, default: false })
49
+ rulesAccepted: boolean;
50
+
51
+ @ApiProperty({ example: null, required: false, nullable: true })
52
+ @Prop({ type: Date, required: false, default: null })
53
+ acceptedAt?: Date | null;
54
+
55
+ @ApiProperty({ type: [String], example: [] })
56
+ @Prop({ type: [String], default: [] })
57
+ tagPhotos: string[];
58
+
59
+ @ApiProperty({ type: [String], example: [] })
60
+ @Prop({ type: [String], default: [] })
61
+ lookPhotos: string[];
62
+
63
+ @ApiProperty({ example: null, required: false, nullable: true })
64
+ @Prop({ type: String, required: false, default: null })
65
+ reviewNotes?: string | null;
66
+ }
67
+
68
+ export const StoreVisitDataSchema = SchemaFactory.createForClass(StoreVisitData);
@@ -0,0 +1,52 @@
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
+ import { Address, AddressSchema } from './party.schema';
10
+ import { Client } from './client.schema';
11
+
12
+ export type StoreDocument = HydratedDocument<Store>;
13
+
14
+ @Schema({ timestamps: true, collection: 'stores' })
15
+ export class Store {
16
+ @ApiProperty({ example: '64bfc3a78d3f1e2a12345670', required: false })
17
+ @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
18
+ _id?: Types.ObjectId;
19
+
20
+ @ApiProperty({ example: '64bfc3a78d3f1e2a12345682' })
21
+ @Prop({
22
+ type: MongooseSchema.Types.ObjectId,
23
+ ref: Client.name,
24
+ required: true,
25
+ index: true,
26
+ })
27
+ client: Types.ObjectId | Client;
28
+
29
+ @ApiProperty({ example: 'Shoulder Shopping Morumbi' })
30
+ @Prop({ type: String, required: true, trim: true })
31
+ name: string;
32
+
33
+ @ApiProperty({ example: 'Morumbi Shopping', required: false })
34
+ @Prop({ type: String, required: false, trim: true })
35
+ shopping?: string;
36
+
37
+ @ApiProperty({ required: false })
38
+ @Prop({ type: AddressSchema, required: false })
39
+ address?: Address;
40
+
41
+ @ApiProperty({ example: true, default: true })
42
+ @Prop({ type: Boolean, default: true })
43
+ active: boolean;
44
+
45
+ createdAt?: Date;
46
+ updatedAt?: Date;
47
+ }
48
+
49
+ export const StoreSchema = SchemaFactory.createForClass(Store);
50
+ StoreSchema.index({ client: 1, name: 1 });
51
+
52
+ export const StoreModel = MongooseModel('Store', StoreSchema);
@@ -18,6 +18,7 @@ import { Content } from './content.schema';
18
18
  import { Influencer } from './influencer.schema';
19
19
  import { Profile } from './profile.schema';
20
20
  import { Recruitment } from './recruitment.schema';
21
+ import { StoreVisitData, StoreVisitDataSchema } from './store-visit.schema';
21
22
 
22
23
  export type TaskDocument = HydratedDocument<Task>;
23
24
 
@@ -40,6 +41,7 @@ export const TASK_TYPE_VALUES = [
40
41
  'posting',
41
42
  'analytics',
42
43
  'diagnosis',
44
+ 'store_visit',
43
45
  ] as const;
44
46
  export type TaskType = (typeof TASK_TYPE_VALUES)[number];
45
47
 
@@ -50,9 +52,29 @@ export const TASK_STATUS_BY_TYPE: Record<TaskType, string[]> = {
50
52
  posting: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
51
53
  analytics: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
52
54
  diagnosis: ['awaiting', 'pending', 'late', 'done', 'cancelled'],
55
+ store_visit: [
56
+ 'awaiting_confirmation',
57
+ 'confirmed',
58
+ 'awaiting_approval',
59
+ 'approved',
60
+ 'finished',
61
+ 'cancelled',
62
+ ],
53
63
  };
54
64
 
55
- export type TaskStatus = 'awaiting' | 'pending' | 'late' | 'done' | 'cancelled' | 'approval' | 'rework';
65
+ export type TaskStatus =
66
+ | 'awaiting'
67
+ | 'pending'
68
+ | 'late'
69
+ | 'done'
70
+ | 'cancelled'
71
+ | 'approval'
72
+ | 'rework'
73
+ | 'awaiting_confirmation'
74
+ | 'confirmed'
75
+ | 'awaiting_approval'
76
+ | 'approved'
77
+ | 'finished';
56
78
 
57
79
  export const TASK_STATUS_VALUES: TaskStatus[] = [
58
80
  'awaiting',
@@ -62,6 +84,11 @@ export const TASK_STATUS_VALUES: TaskStatus[] = [
62
84
  'rework',
63
85
  'done',
64
86
  'cancelled',
87
+ 'awaiting_confirmation',
88
+ 'confirmed',
89
+ 'awaiting_approval',
90
+ 'approved',
91
+ 'finished',
65
92
  ];
66
93
 
67
94
  @Schema({ timestamps: true })
@@ -99,7 +126,7 @@ export class Task {
99
126
  type: String,
100
127
  enum: TASK_FORMAT_VALUES,
101
128
  required: function (this: Task) {
102
- return this.type !== 'diagnosis';
129
+ return this.type !== 'diagnosis' && this.type !== 'store_visit';
103
130
  },
104
131
  })
105
132
  format?: TaskFormat;
@@ -155,6 +182,10 @@ export class Task {
155
182
  @ApiProperty({ enum: ACTION_BUSINESS_UNIT_VALUES, required: false })
156
183
  @Prop({ type: String, enum: ACTION_BUSINESS_UNIT_VALUES, required: false })
157
184
  businessUnit?: ActionBusinessUnit;
185
+
186
+ @ApiProperty({ type: () => StoreVisitData, required: false })
187
+ @Prop({ type: StoreVisitDataSchema, required: false })
188
+ storeVisit?: StoreVisitData;
158
189
  }
159
190
 
160
191
  export const TaskSchema = SchemaFactory.createForClass(Task);
@@ -168,5 +199,7 @@ TaskSchema.index({ client: 1, dueDate: 1 });
168
199
  TaskSchema.index({ influencer: 1, dueDate: 1 });
169
200
  TaskSchema.index({ organization: 1 });
170
201
  TaskSchema.index({ businessUnit: 1 });
202
+ TaskSchema.index({ 'storeVisit.token': 1 }, { unique: true, sparse: true });
203
+ TaskSchema.index({ 'storeVisit.store': 1 }, { sparse: true });
171
204
 
172
205
  export const TaskModel = MongooseModel('Task', TaskSchema);