@grapadigital/shared-schemas 1.0.188 → 1.0.189

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.
@@ -24,37 +24,25 @@
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 { Profile } from './profile.schema';
28
27
  import { Action } from './action.schema';
29
- import { Metrics, Estimates, SentimentAnalysis } from './content.schema';
30
28
  export type ContentDraftDocument = HydratedDocument<ContentDraft>;
31
29
  /**
32
- * Resultado do fetch+map da Primetag, antes de ser promovido para `Content`
33
- * (promoção feita pelo metrics-generator-worker, que agrega métricas e
34
- * reaproveita o mesmo _id). Mesma forma de `Content`, sem os campos que só
35
- * fazem sentido depois de promovido (status de moderação, linha do Google
36
- * Sheets, flags de edição).
30
+ * Registro bruto de auditoria de uma publication devolvida pela Primetag
31
+ * sem nenhum mapeamento de campo de negócio (isso só acontece no
32
+ * metrics-generator-worker, no momento da promoção pra `Content`). Guarda o
33
+ * payload exato da Primetag em `raw`; `action`+`primetagId` é a chave de
34
+ * dedupe, nada mais é derivado/persistido aqui (nem `profile` — quem precisar
35
+ * saber se a publication tem `Recruitment` correspondente resolve isso na
36
+ * hora, em memória, sem gravar no draft). O acesso downstream (metrics-
37
+ * generator-worker) é sempre por `_id` (reaproveitado como `Comment.content`
38
+ * e depois como `Content._id` na promoção), então nenhum índice além do
39
+ * `{action, primetagId}` de dedupe é necessário.
37
40
  */
38
41
  export declare class ContentDraft {
39
42
  _id?: Types.ObjectId;
40
- caption?: string;
41
- link: string;
42
- type: 'reel' | 'carousel' | 'image' | 'story' | 'video' | 'post' | 'pin' | 'tweet';
43
- tagType: 'withTag' | 'withoutTag' | 'brandExposure';
44
- socialnetwork: 'instagram' | 'tiktok' | 'youtube' | 'pinterest' | 'linkedin' | 'twitter';
45
- profile: Types.ObjectId | Profile;
46
43
  action: Types.ObjectId | Action;
47
- postedAt: Date;
48
- isCollab: boolean;
49
- isBoosted: boolean;
50
- hasAffiliateLink: boolean;
51
- collabs?: Types.ObjectId[] | Profile[];
52
- metrics: Metrics;
53
- estimates: Estimates;
54
- primetagId?: string;
55
- sentimentAnalysis?: SentimentAnalysis | null;
56
- thumbnailUrl?: string;
57
- mediaUrl?: string;
44
+ primetagId: string;
45
+ raw: Record<string, unknown>;
58
46
  createdAt?: Date;
59
47
  updatedAt?: Date;
60
48
  }
@@ -12,13 +12,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ContentDraftModel = exports.ContentDraftSchema = exports.ContentDraft = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
- const content_schema_1 = require("./content.schema");
16
15
  /**
17
- * Resultado do fetch+map da Primetag, antes de ser promovido para `Content`
18
- * (promoção feita pelo metrics-generator-worker, que agrega métricas e
19
- * reaproveita o mesmo _id). Mesma forma de `Content`, sem os campos que só
20
- * fazem sentido depois de promovido (status de moderação, linha do Google
21
- * Sheets, flags de edição).
16
+ * Registro bruto de auditoria de uma publication devolvida pela Primetag
17
+ * sem nenhum mapeamento de campo de negócio (isso só acontece no
18
+ * metrics-generator-worker, no momento da promoção pra `Content`). Guarda o
19
+ * payload exato da Primetag em `raw`; `action`+`primetagId` é a chave de
20
+ * dedupe, nada mais é derivado/persistido aqui (nem `profile` — quem precisar
21
+ * saber se a publication tem `Recruitment` correspondente resolve isso na
22
+ * hora, em memória, sem gravar no draft). O acesso downstream (metrics-
23
+ * generator-worker) é sempre por `_id` (reaproveitado como `Comment.content`
24
+ * e depois como `Content._id` na promoção), então nenhum índice além do
25
+ * `{action, primetagId}` de dedupe é necessário.
22
26
  */
23
27
  let ContentDraft = class ContentDraft {
24
28
  };
@@ -26,90 +30,18 @@ __decorate([
26
30
  (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, auto: true, required: false }),
27
31
  __metadata("design:type", mongoose_2.Types.ObjectId)
28
32
  ], ContentDraft.prototype, "_id", void 0);
29
- __decorate([
30
- (0, mongoose_1.Prop)({ type: String, required: false, default: '' }),
31
- __metadata("design:type", String)
32
- ], ContentDraft.prototype, "caption", void 0);
33
- __decorate([
34
- (0, mongoose_1.Prop)({ type: String, required: true }),
35
- __metadata("design:type", String)
36
- ], ContentDraft.prototype, "link", void 0);
37
- __decorate([
38
- (0, mongoose_1.Prop)({
39
- type: String,
40
- enum: ['reel', 'image', 'carousel', 'story', 'video', 'post', 'pin', 'tweet'],
41
- required: true,
42
- }),
43
- __metadata("design:type", String)
44
- ], ContentDraft.prototype, "type", void 0);
45
- __decorate([
46
- (0, mongoose_1.Prop)({
47
- type: String,
48
- enum: ['withTag', 'withoutTag', 'brandExposure'],
49
- required: true,
50
- }),
51
- __metadata("design:type", String)
52
- ], ContentDraft.prototype, "tagType", void 0);
53
- __decorate([
54
- (0, mongoose_1.Prop)({
55
- type: String,
56
- enum: ['instagram', 'tiktok', 'youtube', 'pinterest', 'linkedin', 'twitter'],
57
- required: true,
58
- }),
59
- __metadata("design:type", String)
60
- ], ContentDraft.prototype, "socialnetwork", void 0);
61
- __decorate([
62
- (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Profile', required: true }),
63
- __metadata("design:type", Object)
64
- ], ContentDraft.prototype, "profile", void 0);
65
33
  __decorate([
66
34
  (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Action', required: true }),
67
35
  __metadata("design:type", Object)
68
36
  ], ContentDraft.prototype, "action", void 0);
69
37
  __decorate([
70
- (0, mongoose_1.Prop)({ type: Date, required: true }),
71
- __metadata("design:type", Date)
72
- ], ContentDraft.prototype, "postedAt", void 0);
73
- __decorate([
74
- (0, mongoose_1.Prop)({ type: Boolean, required: true, default: false }),
75
- __metadata("design:type", Boolean)
76
- ], ContentDraft.prototype, "isCollab", void 0);
77
- __decorate([
78
- (0, mongoose_1.Prop)({ type: Boolean, required: true, default: false }),
79
- __metadata("design:type", Boolean)
80
- ], ContentDraft.prototype, "isBoosted", void 0);
81
- __decorate([
82
- (0, mongoose_1.Prop)({ type: Boolean, required: true, default: false }),
83
- __metadata("design:type", Boolean)
84
- ], ContentDraft.prototype, "hasAffiliateLink", void 0);
85
- __decorate([
86
- (0, mongoose_1.Prop)([{ type: mongoose_2.Schema.Types.ObjectId, ref: 'Profile', required: false }]),
87
- __metadata("design:type", Array)
88
- ], ContentDraft.prototype, "collabs", void 0);
89
- __decorate([
90
- (0, mongoose_1.Prop)({ type: content_schema_1.MetricsSchema, required: true }),
91
- __metadata("design:type", content_schema_1.Metrics)
92
- ], ContentDraft.prototype, "metrics", void 0);
93
- __decorate([
94
- (0, mongoose_1.Prop)({ type: content_schema_1.EstimatesSchema, required: true }),
95
- __metadata("design:type", content_schema_1.Estimates)
96
- ], ContentDraft.prototype, "estimates", void 0);
97
- __decorate([
98
- (0, mongoose_1.Prop)({ type: String, required: false }),
38
+ (0, mongoose_1.Prop)({ type: String, required: true }),
99
39
  __metadata("design:type", String)
100
40
  ], ContentDraft.prototype, "primetagId", void 0);
101
41
  __decorate([
102
- (0, mongoose_1.Prop)({ type: content_schema_1.SentimentAnalysisSchema, required: false, default: null }),
42
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.Mixed, required: true }),
103
43
  __metadata("design:type", Object)
104
- ], ContentDraft.prototype, "sentimentAnalysis", void 0);
105
- __decorate([
106
- (0, mongoose_1.Prop)({ type: String, required: false }),
107
- __metadata("design:type", String)
108
- ], ContentDraft.prototype, "thumbnailUrl", void 0);
109
- __decorate([
110
- (0, mongoose_1.Prop)({ type: String, required: false }),
111
- __metadata("design:type", String)
112
- ], ContentDraft.prototype, "mediaUrl", void 0);
44
+ ], ContentDraft.prototype, "raw", void 0);
113
45
  __decorate([
114
46
  (0, mongoose_1.Prop)({ default: Date.now, required: false }),
115
47
  __metadata("design:type", Date)
@@ -123,6 +55,5 @@ ContentDraft = __decorate([
123
55
  ], ContentDraft);
124
56
  exports.ContentDraft = ContentDraft;
125
57
  exports.ContentDraftSchema = mongoose_1.SchemaFactory.createForClass(ContentDraft);
126
- exports.ContentDraftSchema.index({ action: 1, primetagId: 1 });
127
- exports.ContentDraftSchema.index({ action: 1, link: 1 });
58
+ exports.ContentDraftSchema.index({ action: 1, primetagId: 1 }, { unique: true });
128
59
  exports.ContentDraftModel = (0, mongoose_2.model)('ContentDraft', exports.ContentDraftSchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grapadigital/shared-schemas",
3
- "version": "1.0.188",
3
+ "version": "1.0.189",
4
4
  "description": "Shared Mongoose Schemas",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -5,96 +5,35 @@ import {
5
5
  Types,
6
6
  model as MongooseModel,
7
7
  } from 'mongoose';
8
- import { Profile } from './profile.schema';
9
8
  import { Action } from './action.schema';
10
- import {
11
- Metrics,
12
- MetricsSchema,
13
- Estimates,
14
- EstimatesSchema,
15
- SentimentAnalysis,
16
- SentimentAnalysisSchema,
17
- } from './content.schema';
18
9
 
19
10
  export type ContentDraftDocument = HydratedDocument<ContentDraft>;
20
11
 
21
12
  /**
22
- * Resultado do fetch+map da Primetag, antes de ser promovido para `Content`
23
- * (promoção feita pelo metrics-generator-worker, que agrega métricas e
24
- * reaproveita o mesmo _id). Mesma forma de `Content`, sem os campos que só
25
- * fazem sentido depois de promovido (status de moderação, linha do Google
26
- * Sheets, flags de edição).
13
+ * Registro bruto de auditoria de uma publication devolvida pela Primetag
14
+ * sem nenhum mapeamento de campo de negócio (isso só acontece no
15
+ * metrics-generator-worker, no momento da promoção pra `Content`). Guarda o
16
+ * payload exato da Primetag em `raw`; `action`+`primetagId` é a chave de
17
+ * dedupe, nada mais é derivado/persistido aqui (nem `profile` — quem precisar
18
+ * saber se a publication tem `Recruitment` correspondente resolve isso na
19
+ * hora, em memória, sem gravar no draft). O acesso downstream (metrics-
20
+ * generator-worker) é sempre por `_id` (reaproveitado como `Comment.content`
21
+ * e depois como `Content._id` na promoção), então nenhum índice além do
22
+ * `{action, primetagId}` de dedupe é necessário.
27
23
  */
28
24
  @Schema({ collection: 'content-drafts', timestamps: true })
29
25
  export class ContentDraft {
30
26
  @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
31
27
  _id?: Types.ObjectId;
32
28
 
33
- @Prop({ type: String, required: false, default: '' })
34
- caption?: string;
35
-
36
- @Prop({ type: String, required: true })
37
- link: string;
38
-
39
- @Prop({
40
- type: String,
41
- enum: ['reel', 'image', 'carousel', 'story', 'video', 'post', 'pin', 'tweet'],
42
- required: true,
43
- })
44
- type: 'reel' | 'carousel' | 'image' | 'story' | 'video' | 'post' | 'pin' | 'tweet';
45
-
46
- @Prop({
47
- type: String,
48
- enum: ['withTag', 'withoutTag', 'brandExposure'],
49
- required: true,
50
- })
51
- tagType: 'withTag' | 'withoutTag' | 'brandExposure';
52
-
53
- @Prop({
54
- type: String,
55
- enum: ['instagram', 'tiktok', 'youtube', 'pinterest', 'linkedin', 'twitter'],
56
- required: true,
57
- })
58
- socialnetwork: 'instagram' | 'tiktok' | 'youtube' | 'pinterest' | 'linkedin' | 'twitter';
59
-
60
- @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Profile', required: true })
61
- profile: Types.ObjectId | Profile;
62
-
63
29
  @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Action', required: true })
64
30
  action: Types.ObjectId | Action;
65
31
 
66
- @Prop({ type: Date, required: true })
67
- postedAt: Date;
68
-
69
- @Prop({ type: Boolean, required: true, default: false })
70
- isCollab: boolean;
71
-
72
- @Prop({ type: Boolean, required: true, default: false })
73
- isBoosted: boolean;
74
-
75
- @Prop({ type: Boolean, required: true, default: false })
76
- hasAffiliateLink: boolean;
77
-
78
- @Prop([{ type: MongooseSchema.Types.ObjectId, ref: 'Profile', required: false }])
79
- collabs?: Types.ObjectId[] | Profile[];
80
-
81
- @Prop({ type: MetricsSchema, required: true })
82
- metrics: Metrics;
83
-
84
- @Prop({ type: EstimatesSchema, required: true })
85
- estimates: Estimates;
86
-
87
- @Prop({ type: String, required: false })
88
- primetagId?: string;
89
-
90
- @Prop({ type: SentimentAnalysisSchema, required: false, default: null })
91
- sentimentAnalysis?: SentimentAnalysis | null;
92
-
93
- @Prop({ type: String, required: false })
94
- thumbnailUrl?: string;
32
+ @Prop({ type: String, required: true })
33
+ primetagId: string;
95
34
 
96
- @Prop({ type: String, required: false })
97
- mediaUrl?: string;
35
+ @Prop({ type: MongooseSchema.Types.Mixed, required: true })
36
+ raw: Record<string, unknown>;
98
37
 
99
38
  @Prop({ default: Date.now, required: false })
100
39
  createdAt?: Date;
@@ -105,7 +44,6 @@ export class ContentDraft {
105
44
 
106
45
  export const ContentDraftSchema = SchemaFactory.createForClass(ContentDraft);
107
46
 
108
- ContentDraftSchema.index({ action: 1, primetagId: 1 });
109
- ContentDraftSchema.index({ action: 1, link: 1 });
47
+ ContentDraftSchema.index({ action: 1, primetagId: 1 }, { unique: true });
110
48
 
111
49
  export const ContentDraftModel = MongooseModel('ContentDraft', ContentDraftSchema);