@grapadigital/shared-schemas 2.11.1 → 2.13.0

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.
@@ -1,9 +1,19 @@
1
1
  import { HydratedDocument, Schema as MongooseSchema, Types } from "mongoose";
2
2
  import { Client } from "./client.schema";
3
- /** Métrica do benchmark, com nomes por extenso (GD-751). */
4
- export declare const BENCHMARK_METRIC_VALUES: readonly ["reach", "engagementRate", "costPerThousandImpressions", "costPerEngagement"];
3
+ /**
4
+ * Métrica do benchmark, com nomes por extenso (GD-751). Alcance e Alcance
5
+ * efetivo são métricas diferentes: `reach` é contagem, `effectiveReach` é
6
+ * alcance sobre os seguidores no momento do post, em % (GD-668).
7
+ */
8
+ export declare const BENCHMARK_METRIC_VALUES: readonly ["reach", "effectiveReach", "impressions", "engagementCount", "engagementRate", "qualifiedEngagementRate", "score", "costPerInfluency", "costPerThousandImpressions", "costPerEngagement"];
5
9
  export type BenchmarkMetric = (typeof BENCHMARK_METRIC_VALUES)[number];
6
10
  export type BenchmarkMode = "organic" | "paid";
11
+ /**
12
+ * Unidade dos percentis da faixa: médias por campanha no registro de um
13
+ * cliente, medianas por cliente no registro global. Ver GD-668.
14
+ */
15
+ export declare const BENCHMARK_SAMPLE_UNIT_VALUES: readonly ["campaigns", "clients"];
16
+ export type BenchmarkSampleUnit = (typeof BENCHMARK_SAMPLE_UNIT_VALUES)[number];
7
17
  export type BenchmarkDocument = HydratedDocument<Benchmark>;
8
18
  export declare class Benchmark {
9
19
  _id?: Types.ObjectId;
@@ -14,6 +24,22 @@ export declare class Benchmark {
14
24
  good: number;
15
25
  inverted: boolean;
16
26
  client?: Types.ObjectId | Client;
27
+ /** Mediana da distribuição, entre `bad` e `good`. */
28
+ p50?: number | null;
29
+ /** Quantas unidades formaram os percentis; a unidade está em `sampleUnit`. */
30
+ sampleSize?: number | null;
31
+ sampleUnit?: BenchmarkSampleUnit | null;
32
+ /** Conteúdos por trás da faixa. Só para depuração, não vai para a tela. */
33
+ contentCount?: number | null;
34
+ /** Início da janela móvel considerada, inclusivo. */
35
+ from?: Date | null;
36
+ /** Fim da janela móvel considerada, exclusivo. */
37
+ to?: Date | null;
38
+ /**
39
+ * Quando a rotina gravou este registro. Vazio é registro que não veio dela:
40
+ * legado do script de 26/10 ou gravado à mão pelo `POST /admin/benchmark`.
41
+ */
42
+ generatedAt?: Date | null;
17
43
  }
18
44
  export declare const BenchmarkSchema: MongooseSchema<Benchmark, import("mongoose").Model<Benchmark, any, any, any, import("mongoose").Document<unknown, any, Benchmark, any, {}> & Benchmark & Required<{
19
45
  _id: Types.ObjectId;
@@ -9,16 +9,32 @@ 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.BenchmarkModel = exports.BenchmarkSchema = exports.Benchmark = exports.BENCHMARK_METRIC_VALUES = void 0;
12
+ exports.BenchmarkModel = exports.BenchmarkSchema = exports.Benchmark = exports.BENCHMARK_SAMPLE_UNIT_VALUES = exports.BENCHMARK_METRIC_VALUES = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
+ const swagger_1 = require("@nestjs/swagger");
14
15
  const mongoose_2 = require("mongoose");
15
- /** Métrica do benchmark, com nomes por extenso (GD-751). */
16
+ /**
17
+ * Métrica do benchmark, com nomes por extenso (GD-751). Alcance e Alcance
18
+ * efetivo são métricas diferentes: `reach` é contagem, `effectiveReach` é
19
+ * alcance sobre os seguidores no momento do post, em % (GD-668).
20
+ */
16
21
  exports.BENCHMARK_METRIC_VALUES = [
17
22
  "reach",
23
+ "effectiveReach",
24
+ "impressions",
25
+ "engagementCount",
18
26
  "engagementRate",
27
+ "qualifiedEngagementRate",
28
+ "score",
29
+ "costPerInfluency",
19
30
  "costPerThousandImpressions",
20
31
  "costPerEngagement",
21
32
  ];
33
+ /**
34
+ * Unidade dos percentis da faixa: médias por campanha no registro de um
35
+ * cliente, medianas por cliente no registro global. Ver GD-668.
36
+ */
37
+ exports.BENCHMARK_SAMPLE_UNIT_VALUES = ["campaigns", "clients"];
22
38
  let Benchmark = class Benchmark {
23
39
  };
24
40
  exports.Benchmark = Benchmark;
@@ -54,8 +70,58 @@ __decorate([
54
70
  (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: "Client", required: false }),
55
71
  __metadata("design:type", Object)
56
72
  ], Benchmark.prototype, "client", void 0);
73
+ __decorate([
74
+ (0, swagger_1.ApiProperty)({ type: Number, required: false, nullable: true }),
75
+ (0, mongoose_1.Prop)({ type: Number, required: false, default: null }),
76
+ __metadata("design:type", Object)
77
+ ], Benchmark.prototype, "p50", void 0);
78
+ __decorate([
79
+ (0, swagger_1.ApiProperty)({ type: Number, required: false, nullable: true }),
80
+ (0, mongoose_1.Prop)({ type: Number, required: false, default: null }),
81
+ __metadata("design:type", Object)
82
+ ], Benchmark.prototype, "sampleSize", void 0);
83
+ __decorate([
84
+ (0, swagger_1.ApiProperty)({ enum: exports.BENCHMARK_SAMPLE_UNIT_VALUES, required: false, nullable: true }),
85
+ (0, mongoose_1.Prop)({ type: String, enum: exports.BENCHMARK_SAMPLE_UNIT_VALUES, required: false, default: null }),
86
+ __metadata("design:type", Object)
87
+ ], Benchmark.prototype, "sampleUnit", void 0);
88
+ __decorate([
89
+ (0, swagger_1.ApiProperty)({ type: Number, required: false, nullable: true }),
90
+ (0, mongoose_1.Prop)({ type: Number, required: false, default: null }),
91
+ __metadata("design:type", Object)
92
+ ], Benchmark.prototype, "contentCount", void 0);
93
+ __decorate([
94
+ (0, swagger_1.ApiProperty)({ type: Date, required: false, nullable: true }),
95
+ (0, mongoose_1.Prop)({ type: Date, required: false, default: null }),
96
+ __metadata("design:type", Object)
97
+ ], Benchmark.prototype, "from", void 0);
98
+ __decorate([
99
+ (0, swagger_1.ApiProperty)({ type: Date, required: false, nullable: true }),
100
+ (0, mongoose_1.Prop)({ type: Date, required: false, default: null }),
101
+ __metadata("design:type", Object)
102
+ ], Benchmark.prototype, "to", void 0);
103
+ __decorate([
104
+ (0, swagger_1.ApiProperty)({ type: Date, required: false, nullable: true }),
105
+ (0, mongoose_1.Prop)({ type: Date, required: false, default: null }),
106
+ __metadata("design:type", Object)
107
+ ], Benchmark.prototype, "generatedAt", void 0);
57
108
  exports.Benchmark = Benchmark = __decorate([
58
109
  (0, mongoose_1.Schema)({ timestamps: true })
59
110
  ], Benchmark);
60
111
  exports.BenchmarkSchema = mongoose_1.SchemaFactory.createForClass(Benchmark);
112
+ /**
113
+ * `metric` vem antes de `format` e `mode` porque a consulta mais frequente é a
114
+ * do relatório, que filtra por cliente e métrica sem citar formato nem modo
115
+ * (GD-998). Nesta ordem o índice serve também ao `find` por escopo da rotina,
116
+ * que usa só o prefixo `client`.
117
+ *
118
+ * Ainda **não é único**: a chave única só pode subir depois da primeira rodada
119
+ * da rotina, que é quando a coleção passa a ter uma combinação por chave
120
+ * garantida (Passo 9 da GD-668). O nome é explícito porque o `autoIndex` não
121
+ * altera índice existente: criar o único com o nome que o Mongoose daria a
122
+ * este devolveria `IndexOptionsConflict`, que o Mongoose só emite no evento
123
+ * `index` do model e passa batido no boot. O Passo 9 derruba
124
+ * `benchmark_scope` e cria `benchmark_scope_unique`.
125
+ */
126
+ exports.BenchmarkSchema.index({ client: 1, metric: 1, format: 1, mode: 1 }, { name: "benchmark_scope" });
61
127
  exports.BenchmarkModel = (0, mongoose_2.model)("Benchmark", exports.BenchmarkSchema);
@@ -11,6 +11,9 @@ export declare class StoreVisitData {
11
11
  token: string;
12
12
  rulesAccepted: boolean;
13
13
  acceptedAt?: Date | null;
14
+ /** Caminhos no bucket; a leitura sai assinada. Anexadas pela equipe no Flow. */
15
+ tagPhotos: string[];
16
+ lookPhotos: string[];
14
17
  }
15
18
  export declare const StoreVisitDataSchema: MongooseSchema<StoreVisitData, import("mongoose").Model<StoreVisitData, any, any, any, import("mongoose").Document<unknown, any, StoreVisitData, any, {}> & StoreVisitData & {
16
19
  _id: Types.ObjectId;
@@ -66,6 +66,16 @@ __decorate([
66
66
  (0, mongoose_1.Prop)({ type: Date, required: false, default: null }),
67
67
  __metadata("design:type", Object)
68
68
  ], StoreVisitData.prototype, "acceptedAt", void 0);
69
+ __decorate([
70
+ (0, swagger_1.ApiProperty)({ type: [String], example: [] }),
71
+ (0, mongoose_1.Prop)({ type: [String], default: [] }),
72
+ __metadata("design:type", Array)
73
+ ], StoreVisitData.prototype, "tagPhotos", void 0);
74
+ __decorate([
75
+ (0, swagger_1.ApiProperty)({ type: [String], example: [] }),
76
+ (0, mongoose_1.Prop)({ type: [String], default: [] }),
77
+ __metadata("design:type", Array)
78
+ ], StoreVisitData.prototype, "lookPhotos", void 0);
69
79
  exports.StoreVisitData = StoreVisitData = __decorate([
70
80
  (0, mongoose_1.Schema)({ _id: false })
71
81
  ], StoreVisitData);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grapadigital/shared-schemas",
3
- "version": "2.11.1",
3
+ "version": "2.13.0",
4
4
  "description": "Shared Mongoose Schemas",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",