@grapadigital/shared-schemas 1.0.208 → 1.0.210

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/index.d.ts CHANGED
@@ -32,5 +32,5 @@ export * from './schemas/content-capture-process.schema';
32
32
  export * from './schemas/content-draft.schema';
33
33
  export * from './schemas/export-comments-job.schema';
34
34
  export * from './schemas/job.schema';
35
- export * from './schemas/profile-followers-snapshot.schema';
35
+ export * from './schemas/snapshot.schema';
36
36
  export * from './schemas/lead.schema';
package/dist/index.js CHANGED
@@ -53,5 +53,5 @@ __exportStar(require("./schemas/content-capture-process.schema"), exports);
53
53
  __exportStar(require("./schemas/content-draft.schema"), exports);
54
54
  __exportStar(require("./schemas/export-comments-job.schema"), exports);
55
55
  __exportStar(require("./schemas/job.schema"), exports);
56
- __exportStar(require("./schemas/profile-followers-snapshot.schema"), exports);
56
+ __exportStar(require("./schemas/snapshot.schema"), exports);
57
57
  __exportStar(require("./schemas/lead.schema"), exports);
@@ -28,7 +28,7 @@ import { Action } from './action.schema';
28
28
  export type JobDocument = HydratedDocument<Job>;
29
29
  export declare const JOB_ORIGINS: readonly ["trigger", "approval", "reclassify"];
30
30
  export type JobOrigin = (typeof JOB_ORIGINS)[number];
31
- export declare const JOB_WORKERS: readonly ["content-capture-trigger", "content-capture", "comment-capture", "content-classification", "metrics-generator", "profile-sync"];
31
+ export declare const JOB_WORKERS: readonly ["api-campaigns", "content-capture-trigger", "content-capture", "comment-capture", "content-classification", "metrics-generator", "profile-sync"];
32
32
  export type JobWorker = (typeof JOB_WORKERS)[number];
33
33
  export declare const JOB_STATUSES: readonly ["running", "done", "skipped", "error"];
34
34
  export type JobStatus = (typeof JOB_STATUSES)[number];
@@ -14,6 +14,8 @@ const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
15
  exports.JOB_ORIGINS = ['trigger', 'approval', 'reclassify'];
16
16
  exports.JOB_WORKERS = [
17
+ // Clique de aprovação (lote): quantos conteúdos o disparo colocou no pipeline.
18
+ 'api-campaigns',
17
19
  'content-capture-trigger',
18
20
  'content-capture',
19
21
  'comment-capture',
@@ -27,6 +27,8 @@ import { HydratedDocument, Schema as MongooseSchema, Types } from 'mongoose';
27
27
  import { Influencer } from './influencer.schema';
28
28
  import { Client } from './client.schema';
29
29
  export type ProfileDocument = HydratedDocument<Profile>;
30
+ export declare const PROFILE_OPTIN_STATUS_VALUES: readonly ["active", "inactive"];
31
+ export type ProfileOptinStatus = (typeof PROFILE_OPTIN_STATUS_VALUES)[number];
30
32
  export declare class Profile {
31
33
  _id?: Types.ObjectId;
32
34
  username: string;
@@ -35,6 +37,9 @@ export declare class Profile {
35
37
  picture: string;
36
38
  pictureUpdatedAt?: Date;
37
39
  primetagSocialProfileId?: number;
40
+ optinStatus?: ProfileOptinStatus;
41
+ optinUpdatedAt?: Date;
42
+ optinNotifiedAt?: Date;
38
43
  socialnetwork: string;
39
44
  type: string;
40
45
  influencer: Types.ObjectId | Influencer;
@@ -9,9 +9,10 @@ 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.ProfileModel = exports.ProfileSchema = exports.Profile = void 0;
12
+ exports.ProfileModel = exports.ProfileSchema = exports.Profile = exports.PROFILE_OPTIN_STATUS_VALUES = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
+ exports.PROFILE_OPTIN_STATUS_VALUES = ['active', 'inactive'];
15
16
  let Profile = class Profile {
16
17
  };
17
18
  __decorate([
@@ -42,6 +43,18 @@ __decorate([
42
43
  (0, mongoose_1.Prop)({ type: Number, required: false }),
43
44
  __metadata("design:type", Number)
44
45
  ], Profile.prototype, "primetagSocialProfileId", void 0);
46
+ __decorate([
47
+ (0, mongoose_1.Prop)({ type: String, enum: exports.PROFILE_OPTIN_STATUS_VALUES, required: false }),
48
+ __metadata("design:type", String)
49
+ ], Profile.prototype, "optinStatus", void 0);
50
+ __decorate([
51
+ (0, mongoose_1.Prop)({ type: Date, required: false }),
52
+ __metadata("design:type", Date)
53
+ ], Profile.prototype, "optinUpdatedAt", void 0);
54
+ __decorate([
55
+ (0, mongoose_1.Prop)({ type: Date, required: false }),
56
+ __metadata("design:type", Date)
57
+ ], Profile.prototype, "optinNotifiedAt", void 0);
45
58
  __decorate([
46
59
  (0, mongoose_1.Prop)(),
47
60
  __metadata("design:type", String)
@@ -0,0 +1,67 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/session" />
19
+ /// <reference types="mongoose/types/types" />
20
+ /// <reference types="mongoose/types/utility" />
21
+ /// <reference types="mongoose/types/validation" />
22
+ /// <reference types="mongoose/types/virtuals" />
23
+ /// <reference types="mongoose/types/schematypes" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ /// <reference types="mongoose/types/inferrawdoctype" />
26
+ import { HydratedDocument, Schema as MongooseSchema, Types } from 'mongoose';
27
+ import { Profile } from './profile.schema';
28
+ export type SnapshotDocument = HydratedDocument<Snapshot>;
29
+ /**
30
+ * Histórico diário de seguidores por perfil, gravado pelo profile-sync-worker
31
+ * a partir do `audience_size` que a Primetag devolve na captura. Um doc por
32
+ * perfil por dia (`date` truncado em UTC): uma rodada repetida no mesmo dia só
33
+ * sobrescreve o valor do dia.
34
+ */
35
+ export declare class Snapshot {
36
+ _id?: Types.ObjectId;
37
+ profile: Types.ObjectId | Profile;
38
+ socialnetwork?: string;
39
+ followers: number;
40
+ date: Date;
41
+ capturedAt: Date;
42
+ source: 'primetag';
43
+ createdAt?: Date;
44
+ updatedAt?: Date;
45
+ }
46
+ export declare const SnapshotSchema: MongooseSchema<Snapshot, import("mongoose").Model<Snapshot, any, any, any, import("mongoose").Document<unknown, any, Snapshot, any, {}> & Snapshot & Required<{
47
+ _id: Types.ObjectId;
48
+ }> & {
49
+ __v: number;
50
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Snapshot, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Snapshot>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Snapshot> & Required<{
51
+ _id: Types.ObjectId;
52
+ }> & {
53
+ __v: number;
54
+ }>;
55
+ export declare const SnapshotModel: import("mongoose").Model<Snapshot, {}, {}, {}, import("mongoose").Document<unknown, {}, Snapshot, {}, import("mongoose").DefaultSchemaOptions> & Snapshot & Required<{
56
+ _id: Types.ObjectId;
57
+ }> & {
58
+ __v: number;
59
+ }, MongooseSchema<Snapshot, import("mongoose").Model<Snapshot, any, any, any, import("mongoose").Document<unknown, any, Snapshot, any, {}> & Snapshot & Required<{
60
+ _id: Types.ObjectId;
61
+ }> & {
62
+ __v: number;
63
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Snapshot, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Snapshot>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Snapshot> & Required<{
64
+ _id: Types.ObjectId;
65
+ }> & {
66
+ __v: number;
67
+ }>>;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SnapshotModel = exports.SnapshotSchema = exports.Snapshot = void 0;
13
+ const mongoose_1 = require("@nestjs/mongoose");
14
+ const mongoose_2 = require("mongoose");
15
+ /**
16
+ * Histórico diário de seguidores por perfil, gravado pelo profile-sync-worker
17
+ * a partir do `audience_size` que a Primetag devolve na captura. Um doc por
18
+ * perfil por dia (`date` truncado em UTC): uma rodada repetida no mesmo dia só
19
+ * sobrescreve o valor do dia.
20
+ */
21
+ let Snapshot = class Snapshot {
22
+ };
23
+ __decorate([
24
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, auto: true, required: false }),
25
+ __metadata("design:type", mongoose_2.Types.ObjectId)
26
+ ], Snapshot.prototype, "_id", void 0);
27
+ __decorate([
28
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Profile', required: true }),
29
+ __metadata("design:type", Object)
30
+ ], Snapshot.prototype, "profile", void 0);
31
+ __decorate([
32
+ (0, mongoose_1.Prop)({ type: String, required: false }),
33
+ __metadata("design:type", String)
34
+ ], Snapshot.prototype, "socialnetwork", void 0);
35
+ __decorate([
36
+ (0, mongoose_1.Prop)({ type: Number, required: true }),
37
+ __metadata("design:type", Number)
38
+ ], Snapshot.prototype, "followers", void 0);
39
+ __decorate([
40
+ (0, mongoose_1.Prop)({ type: Date, required: true }),
41
+ __metadata("design:type", Date)
42
+ ], Snapshot.prototype, "date", void 0);
43
+ __decorate([
44
+ (0, mongoose_1.Prop)({ type: Date, required: true }),
45
+ __metadata("design:type", Date)
46
+ ], Snapshot.prototype, "capturedAt", void 0);
47
+ __decorate([
48
+ (0, mongoose_1.Prop)({ type: String, enum: ['primetag'], required: true, default: 'primetag' }),
49
+ __metadata("design:type", String)
50
+ ], Snapshot.prototype, "source", void 0);
51
+ __decorate([
52
+ (0, mongoose_1.Prop)({ default: Date.now, required: false }),
53
+ __metadata("design:type", Date)
54
+ ], Snapshot.prototype, "createdAt", void 0);
55
+ __decorate([
56
+ (0, mongoose_1.Prop)({ default: Date.now, required: false }),
57
+ __metadata("design:type", Date)
58
+ ], Snapshot.prototype, "updatedAt", void 0);
59
+ Snapshot = __decorate([
60
+ (0, mongoose_1.Schema)({ collection: 'snapshots', timestamps: true })
61
+ ], Snapshot);
62
+ exports.Snapshot = Snapshot;
63
+ exports.SnapshotSchema = mongoose_1.SchemaFactory.createForClass(Snapshot);
64
+ exports.SnapshotSchema.index({ profile: 1, date: 1 }, { unique: true });
65
+ exports.SnapshotModel = (0, mongoose_2.model)('Snapshot', exports.SnapshotSchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grapadigital/shared-schemas",
3
- "version": "1.0.208",
3
+ "version": "1.0.210",
4
4
  "description": "Shared Mongoose Schemas",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -32,5 +32,5 @@ export * from './schemas/content-capture-process.schema';
32
32
  export * from './schemas/content-draft.schema';
33
33
  export * from './schemas/export-comments-job.schema';
34
34
  export * from './schemas/job.schema';
35
- export * from './schemas/profile-followers-snapshot.schema';
35
+ export * from './schemas/snapshot.schema';
36
36
  export * from './schemas/lead.schema';
@@ -13,6 +13,8 @@ export const JOB_ORIGINS = ['trigger', 'approval', 'reclassify'] as const;
13
13
  export type JobOrigin = (typeof JOB_ORIGINS)[number];
14
14
 
15
15
  export const JOB_WORKERS = [
16
+ // Clique de aprovação (lote): quantos conteúdos o disparo colocou no pipeline.
17
+ 'api-campaigns',
16
18
  'content-capture-trigger',
17
19
  'content-capture',
18
20
  'comment-capture',
@@ -5,6 +5,9 @@ import { Client } from './client.schema';
5
5
 
6
6
  export type ProfileDocument = HydratedDocument<Profile>;
7
7
 
8
+ export const PROFILE_OPTIN_STATUS_VALUES = ['active', 'inactive'] as const;
9
+ export type ProfileOptinStatus = (typeof PROFILE_OPTIN_STATUS_VALUES)[number];
10
+
8
11
  @Schema({ timestamps: true })
9
12
  export class Profile {
10
13
  @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
@@ -29,6 +32,19 @@ export class Profile {
29
32
  @Prop({ type: Number, required: false })
30
33
  primetagSocialProfileId?: number;
31
34
 
35
+ // Opt-in na Primetag (conta conectada): 'active' quando o social_profile
36
+ // vem com connection_status CONNECTED, 'inactive' pra qualquer outro valor.
37
+ // Ausente enquanto o perfil não foi sincronizado.
38
+ @Prop({ type: String, enum: PROFILE_OPTIN_STATUS_VALUES, required: false })
39
+ optinStatus?: ProfileOptinStatus;
40
+
41
+ @Prop({ type: Date, required: false })
42
+ optinUpdatedAt?: Date;
43
+
44
+ // Último aviso de mudança de opt-in (no máximo um por perfil por dia).
45
+ @Prop({ type: Date, required: false })
46
+ optinNotifiedAt?: Date;
47
+
32
48
  @Prop()
33
49
  socialnetwork: string;
34
50
 
@@ -7,16 +7,16 @@ import {
7
7
  } from 'mongoose';
8
8
  import { Profile } from './profile.schema';
9
9
 
10
- export type ProfileFollowersSnapshotDocument = HydratedDocument<ProfileFollowersSnapshot>;
10
+ export type SnapshotDocument = HydratedDocument<Snapshot>;
11
11
 
12
12
  /**
13
13
  * Histórico diário de seguidores por perfil, gravado pelo profile-sync-worker
14
14
  * a partir do `audience_size` que a Primetag devolve na captura. Um doc por
15
- * perfil por dia (`date` truncado em UTC): o trigger roda várias vezes ao dia
16
- * e cada rodada só sobrescreve o valor do dia.
15
+ * perfil por dia (`date` truncado em UTC): uma rodada repetida no mesmo dia só
16
+ * sobrescreve o valor do dia.
17
17
  */
18
- @Schema({ collection: 'profile-followers-snapshots', timestamps: true })
19
- export class ProfileFollowersSnapshot {
18
+ @Schema({ collection: 'snapshots', timestamps: true })
19
+ export class Snapshot {
20
20
  @Prop({ type: MongooseSchema.Types.ObjectId, auto: true, required: false })
21
21
  _id?: Types.ObjectId;
22
22
 
@@ -45,11 +45,11 @@ export class ProfileFollowersSnapshot {
45
45
  updatedAt?: Date;
46
46
  }
47
47
 
48
- export const ProfileFollowersSnapshotSchema = SchemaFactory.createForClass(ProfileFollowersSnapshot);
48
+ export const SnapshotSchema = SchemaFactory.createForClass(Snapshot);
49
49
 
50
- ProfileFollowersSnapshotSchema.index({ profile: 1, date: 1 }, { unique: true });
50
+ SnapshotSchema.index({ profile: 1, date: 1 }, { unique: true });
51
51
 
52
- export const ProfileFollowersSnapshotModel = MongooseModel(
53
- 'ProfileFollowersSnapshot',
54
- ProfileFollowersSnapshotSchema,
52
+ export const SnapshotModel = MongooseModel(
53
+ 'Snapshot',
54
+ SnapshotSchema,
55
55
  );