@grapadigital/shared-schemas 2.9.0 → 2.11.1
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/schemas/content.schema.d.ts +4 -3
- package/dist/schemas/recruitment.schema.d.ts +10 -1
- package/dist/schemas/recruitment.schema.js +14 -3
- package/dist/schemas/store-visit.schema.d.ts +2 -5
- package/dist/schemas/store-visit.schema.js +1 -18
- package/dist/schemas/task.schema.d.ts +1 -1
- package/dist/schemas/task.schema.js +6 -13
- package/package.json +1 -1
|
@@ -329,9 +329,10 @@ export declare class Content {
|
|
|
329
329
|
/** Hashtags da publicação, normalizadas (minúsculas, sem # e sem acento). Ver GD-691. */
|
|
330
330
|
hashtags?: string[];
|
|
331
331
|
/**
|
|
332
|
-
* Tipo do Conteúdo: Orgânico (fora do escopo contratado) ou
|
|
333
|
-
* Ação sem hashtag de Orgânico. Não confundir com
|
|
334
|
-
* (métrica pública) nem com isBoosted (mídia paga).
|
|
332
|
+
* Tipo do Conteúdo: Orgânico (fora do escopo contratado) ou Obrigatório
|
|
333
|
+
* (dentro dele). null = Ação sem hashtag de Orgânico. Não confundir com
|
|
334
|
+
* metricsSource 'organic' (métrica pública) nem com isBoosted (mídia paga).
|
|
335
|
+
* Ver GD-691 e GD-914.
|
|
335
336
|
*/
|
|
336
337
|
isOrganic?: boolean | null;
|
|
337
338
|
isOrganicSource?: ContentClassificationSource | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HydratedDocument, Schema as MongooseSchema, Types } from "mongoose";
|
|
2
2
|
import { Action } from "./action.schema";
|
|
3
|
+
import type { Client } from "./client.schema";
|
|
3
4
|
import type { Influencer } from "./influencer.schema";
|
|
4
5
|
import { Profile } from "./profile.schema";
|
|
5
6
|
export type RecruitmentDocument = HydratedDocument<Recruitment>;
|
|
@@ -201,7 +202,15 @@ export declare class Recruitment {
|
|
|
201
202
|
picture: string;
|
|
202
203
|
status: "selected" | "inContact" | "inApproval" | "recruited" | "removed" | "deleted";
|
|
203
204
|
action: Types.ObjectId | Action;
|
|
204
|
-
influencer
|
|
205
|
+
influencer?: Types.ObjectId | Influencer;
|
|
206
|
+
/**
|
|
207
|
+
* Cliente dono do recrutamento, quando o recrutado é a própria marca: os
|
|
208
|
+
* perfis de `profiles` são perfis de marca (`Profile.client`). O Recrutamento
|
|
209
|
+
* tem `influencer` OU `client`, nunca os dois — quem garante isso é a API, não
|
|
210
|
+
* o schema, porque recrutamento legado não tem nenhum dos dois. Marca não tem
|
|
211
|
+
* pagamento, termo de aceite, contrato nem squad. Ver GD-962.
|
|
212
|
+
*/
|
|
213
|
+
client?: Types.ObjectId | Client;
|
|
205
214
|
profiles: RecruitmentProfile[];
|
|
206
215
|
scope?: Scope;
|
|
207
216
|
createdAt?: Date;
|
|
@@ -317,8 +317,10 @@ exports.RecruitmentProfile = RecruitmentProfile = __decorate([
|
|
|
317
317
|
(0, mongoose_1.Schema)({ _id: false })
|
|
318
318
|
], RecruitmentProfile);
|
|
319
319
|
exports.RecruitmentProfileSchema = mongoose_1.SchemaFactory.createForClass(RecruitmentProfile);
|
|
320
|
-
// 1 por (action, influencer)
|
|
321
|
-
//
|
|
320
|
+
// 1 por (action, influencer) quando o recrutado é Influenciador, ou 1 por
|
|
321
|
+
// (action, client) quando é a própria marca (perfil de marca, GD-962). O scope
|
|
322
|
+
// (entregas + pagamento) é do recrutado na campanha inteira, dividido entre
|
|
323
|
+
// todos os perfis de `profiles`; o escopo da marca não tem pagamento.
|
|
322
324
|
let Recruitment = class Recruitment {
|
|
323
325
|
};
|
|
324
326
|
exports.Recruitment = Recruitment;
|
|
@@ -347,9 +349,13 @@ __decorate([
|
|
|
347
349
|
__metadata("design:type", Object)
|
|
348
350
|
], Recruitment.prototype, "action", void 0);
|
|
349
351
|
__decorate([
|
|
350
|
-
(0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: "Influencer", required:
|
|
352
|
+
(0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: "Influencer", required: false }),
|
|
351
353
|
__metadata("design:type", Object)
|
|
352
354
|
], Recruitment.prototype, "influencer", void 0);
|
|
355
|
+
__decorate([
|
|
356
|
+
(0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: "Client", required: false }),
|
|
357
|
+
__metadata("design:type", Object)
|
|
358
|
+
], Recruitment.prototype, "client", void 0);
|
|
353
359
|
__decorate([
|
|
354
360
|
(0, mongoose_1.Prop)({ type: [exports.RecruitmentProfileSchema], default: [] }),
|
|
355
361
|
__metadata("design:type", Array)
|
|
@@ -383,6 +389,11 @@ exports.RecruitmentSchema.index({ action: 1 });
|
|
|
383
389
|
// Parcial: recrutamentos legados cujo perfil não tem influenciador ficaram no
|
|
384
390
|
// formato antigo (sem `influencer`) e não entram na unicidade.
|
|
385
391
|
exports.RecruitmentSchema.index({ action: 1, influencer: 1 }, { unique: true, partialFilterExpression: { influencer: { $type: "objectId" } } });
|
|
392
|
+
// Parcial: só recrutamento de marca entra na unicidade (GD-962). Não filtra
|
|
393
|
+
// deletedAt, então a checagem de duplicidade da API precisa enxergar o
|
|
394
|
+
// excluído (.setOptions({ withDeleted: true })), senão recrutar a mesma marca
|
|
395
|
+
// depois de excluir estoura E11000 em vez de 400.
|
|
396
|
+
exports.RecruitmentSchema.index({ action: 1, client: 1 }, { unique: true, partialFilterExpression: { client: { $type: "objectId" } } });
|
|
386
397
|
exports.RecruitmentSchema.index({ "profiles.profile": 1, status: 1 });
|
|
387
398
|
exports.RecruitmentSchema.index({ influencer: 1, status: 1, "scope.exclusivity": 1 });
|
|
388
399
|
exports.RecruitmentSchema.index({ action: 1, "profiles.primetagId": 1 });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Schema as MongooseSchema, Types } from "mongoose";
|
|
2
2
|
import { Store } from "./store.schema";
|
|
3
|
-
export declare const STORE_VISIT_STATUS_VALUES: readonly ["awaiting_confirmation", "confirmed", "
|
|
3
|
+
export declare const STORE_VISIT_STATUS_VALUES: readonly ["awaiting_confirmation", "confirmed", "done", "finished"];
|
|
4
4
|
export type StoreVisitStatus = (typeof STORE_VISIT_STATUS_VALUES)[number];
|
|
5
|
-
export declare const STORE_VISIT_PERIOD_VALUES: readonly ["morning", "afternoon"
|
|
5
|
+
export declare const STORE_VISIT_PERIOD_VALUES: readonly ["morning", "afternoon"];
|
|
6
6
|
export type StoreVisitPeriod = (typeof STORE_VISIT_PERIOD_VALUES)[number];
|
|
7
7
|
export declare class StoreVisitData {
|
|
8
8
|
store: Types.ObjectId | Store;
|
|
@@ -11,9 +11,6 @@ export declare class StoreVisitData {
|
|
|
11
11
|
token: string;
|
|
12
12
|
rulesAccepted: boolean;
|
|
13
13
|
acceptedAt?: Date | null;
|
|
14
|
-
tagPhotos: string[];
|
|
15
|
-
lookPhotos: string[];
|
|
16
|
-
reviewNotes?: string | null;
|
|
17
14
|
}
|
|
18
15
|
export declare const StoreVisitDataSchema: MongooseSchema<StoreVisitData, import("mongoose").Model<StoreVisitData, any, any, any, import("mongoose").Document<unknown, any, StoreVisitData, any, {}> & StoreVisitData & {
|
|
19
16
|
_id: Types.ObjectId;
|
|
@@ -17,12 +17,10 @@ const store_schema_1 = require("./store.schema");
|
|
|
17
17
|
exports.STORE_VISIT_STATUS_VALUES = [
|
|
18
18
|
"awaiting_confirmation", // Cadastrada pelo time, aguardando influenciadora confirmar horário e aceitar regras
|
|
19
19
|
"confirmed", // Influenciadora confirmou horário e aceite registrado
|
|
20
|
-
"awaiting_approval", // Fotos de looks e etiquetas submetidas para aprovação
|
|
21
|
-
"approved", // Looks e etiquetas aprovados pelo time
|
|
22
20
|
"done", // Visita realizada em loja
|
|
23
21
|
"finished", // Processo encerrado e notificação emitida
|
|
24
22
|
];
|
|
25
|
-
exports.STORE_VISIT_PERIOD_VALUES = ["morning", "afternoon"
|
|
23
|
+
exports.STORE_VISIT_PERIOD_VALUES = ["morning", "afternoon"];
|
|
26
24
|
let StoreVisitData = class StoreVisitData {
|
|
27
25
|
};
|
|
28
26
|
exports.StoreVisitData = StoreVisitData;
|
|
@@ -68,21 +66,6 @@ __decorate([
|
|
|
68
66
|
(0, mongoose_1.Prop)({ type: Date, required: false, default: null }),
|
|
69
67
|
__metadata("design:type", Object)
|
|
70
68
|
], StoreVisitData.prototype, "acceptedAt", void 0);
|
|
71
|
-
__decorate([
|
|
72
|
-
(0, swagger_1.ApiProperty)({ type: [String], example: [] }),
|
|
73
|
-
(0, mongoose_1.Prop)({ type: [String], default: [] }),
|
|
74
|
-
__metadata("design:type", Array)
|
|
75
|
-
], StoreVisitData.prototype, "tagPhotos", void 0);
|
|
76
|
-
__decorate([
|
|
77
|
-
(0, swagger_1.ApiProperty)({ type: [String], example: [] }),
|
|
78
|
-
(0, mongoose_1.Prop)({ type: [String], default: [] }),
|
|
79
|
-
__metadata("design:type", Array)
|
|
80
|
-
], StoreVisitData.prototype, "lookPhotos", void 0);
|
|
81
|
-
__decorate([
|
|
82
|
-
(0, swagger_1.ApiProperty)({ example: null, required: false, nullable: true }),
|
|
83
|
-
(0, mongoose_1.Prop)({ type: String, required: false, default: null }),
|
|
84
|
-
__metadata("design:type", Object)
|
|
85
|
-
], StoreVisitData.prototype, "reviewNotes", void 0);
|
|
86
69
|
exports.StoreVisitData = StoreVisitData = __decorate([
|
|
87
70
|
(0, mongoose_1.Schema)({ _id: false })
|
|
88
71
|
], StoreVisitData);
|
|
@@ -12,7 +12,7 @@ export type TaskFormat = (typeof TASK_FORMAT_VALUES)[number];
|
|
|
12
12
|
export declare const TASK_TYPE_VALUES: readonly ["briefing", "script", "production", "posting", "analytics", "diagnosis", "store_visit"];
|
|
13
13
|
export type TaskType = (typeof TASK_TYPE_VALUES)[number];
|
|
14
14
|
export declare const TASK_STATUS_BY_TYPE: Record<TaskType, string[]>;
|
|
15
|
-
export type TaskStatus = "awaiting" | "pending" | "late" | "done" | "cancelled" | "approval" | "rework" | "awaiting_confirmation" | "confirmed" | "
|
|
15
|
+
export type TaskStatus = "awaiting" | "pending" | "late" | "done" | "cancelled" | "approval" | "rework" | "awaiting_confirmation" | "confirmed" | "finished";
|
|
16
16
|
export declare const TASK_STATUS_VALUES: TaskStatus[];
|
|
17
17
|
export declare class Task {
|
|
18
18
|
_id?: Types.ObjectId;
|
|
@@ -41,14 +41,7 @@ exports.TASK_STATUS_BY_TYPE = {
|
|
|
41
41
|
posting: ["awaiting", "pending", "late", "done", "cancelled"],
|
|
42
42
|
analytics: ["awaiting", "pending", "late", "done", "cancelled"],
|
|
43
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
|
-
],
|
|
44
|
+
store_visit: ["awaiting_confirmation", "confirmed", "finished", "cancelled"],
|
|
52
45
|
};
|
|
53
46
|
exports.TASK_STATUS_VALUES = [
|
|
54
47
|
"awaiting",
|
|
@@ -60,8 +53,6 @@ exports.TASK_STATUS_VALUES = [
|
|
|
60
53
|
"cancelled",
|
|
61
54
|
"awaiting_confirmation",
|
|
62
55
|
"confirmed",
|
|
63
|
-
"awaiting_approval",
|
|
64
|
-
"approved",
|
|
65
56
|
"finished",
|
|
66
57
|
];
|
|
67
58
|
let Task = class Task {
|
|
@@ -201,18 +192,20 @@ exports.TaskSchema.index({ organization: 1 });
|
|
|
201
192
|
exports.TaskSchema.index({ businessUnit: 1 });
|
|
202
193
|
exports.TaskSchema.index({ "storeVisit.token": 1 }, { unique: true, sparse: true });
|
|
203
194
|
exports.TaskSchema.index({ "storeVisit.store": 1 }, { sparse: true });
|
|
195
|
+
// Uma única ida em loja por loja e por dia, qualquer que seja o período.
|
|
196
|
+
// O índice parcial não aceita $ne, por isso os status entram listados em $in:
|
|
197
|
+
// com $ne o índice era recusado pelo Mongo e nunca chegou a existir.
|
|
204
198
|
exports.TaskSchema.index({
|
|
205
199
|
"storeVisit.store": 1,
|
|
206
200
|
"storeVisit.scheduledDate": 1,
|
|
207
|
-
"storeVisit.scheduledPeriod": 1,
|
|
208
201
|
}, {
|
|
202
|
+
name: "store_visit_unique_store_day",
|
|
209
203
|
unique: true,
|
|
210
204
|
partialFilterExpression: {
|
|
211
205
|
type: "store_visit",
|
|
212
|
-
status: { $
|
|
206
|
+
status: { $in: ["awaiting_confirmation", "confirmed", "finished"] },
|
|
213
207
|
"storeVisit.store": { $exists: true },
|
|
214
208
|
"storeVisit.scheduledDate": { $exists: true },
|
|
215
|
-
"storeVisit.scheduledPeriod": { $exists: true },
|
|
216
209
|
},
|
|
217
210
|
});
|
|
218
211
|
exports.TaskModel = (0, mongoose_2.model)("Task", exports.TaskSchema);
|