clhq-postgres-module 1.1.0-alpha.170 → 1.1.0-alpha.171

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 (31) hide show
  1. package/dist/entities/account-analytics-summary.entity.d.ts +17 -0
  2. package/dist/entities/account-analytics-summary.entity.js +82 -0
  3. package/dist/entities/analytics-report.entity.d.ts +20 -0
  4. package/dist/entities/analytics-report.entity.js +66 -0
  5. package/dist/entities/index.d.ts +7 -0
  6. package/dist/entities/index.js +7 -0
  7. package/dist/entities/platform-config.entity.d.ts +16 -0
  8. package/dist/entities/platform-config.entity.js +72 -0
  9. package/dist/entities/post-analytics-snapshot.entity.d.ts +33 -0
  10. package/dist/entities/post-analytics-snapshot.entity.js +122 -0
  11. package/dist/entities/post-brand-analysis.entity.d.ts +26 -0
  12. package/dist/entities/post-brand-analysis.entity.js +75 -0
  13. package/dist/entities/social-account.entity.d.ts +39 -0
  14. package/dist/entities/social-account.entity.js +131 -0
  15. package/dist/entities/social-post.entity.d.ts +45 -0
  16. package/dist/entities/social-post.entity.js +171 -0
  17. package/dist/repositories/account-analytics-summary.repository.d.ts +12 -0
  18. package/dist/repositories/account-analytics-summary.repository.js +55 -0
  19. package/dist/repositories/index.d.ts +5 -0
  20. package/dist/repositories/index.js +11 -1
  21. package/dist/repositories/platform-config.repository.d.ts +10 -0
  22. package/dist/repositories/platform-config.repository.js +43 -0
  23. package/dist/repositories/post-analytics-snapshot.repository.d.ts +9 -0
  24. package/dist/repositories/post-analytics-snapshot.repository.js +50 -0
  25. package/dist/repositories/repository.module.d.ts +1 -0
  26. package/dist/repositories/repository.module.js +16 -1
  27. package/dist/repositories/social-account.repository.d.ts +9 -0
  28. package/dist/repositories/social-account.repository.js +44 -0
  29. package/dist/repositories/social-post.repository.d.ts +17 -0
  30. package/dist/repositories/social-post.repository.js +91 -0
  31. package/package.json +1 -1
@@ -0,0 +1,131 @@
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.SocialAccount = exports.SocialAccountStatus = exports.AuthMethod = exports.SocialPlatform = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const workspace_entity_1 = require("./workspace.entity");
15
+ var SocialPlatform;
16
+ (function (SocialPlatform) {
17
+ SocialPlatform["YOUTUBE"] = "YOUTUBE";
18
+ SocialPlatform["TIKTOK"] = "TIKTOK";
19
+ SocialPlatform["INSTAGRAM"] = "INSTAGRAM";
20
+ SocialPlatform["LINKEDIN"] = "LINKEDIN";
21
+ })(SocialPlatform || (exports.SocialPlatform = SocialPlatform = {}));
22
+ var AuthMethod;
23
+ (function (AuthMethod) {
24
+ AuthMethod["OAUTH"] = "OAUTH";
25
+ AuthMethod["API_KEY"] = "API_KEY";
26
+ })(AuthMethod || (exports.AuthMethod = AuthMethod = {}));
27
+ var SocialAccountStatus;
28
+ (function (SocialAccountStatus) {
29
+ SocialAccountStatus["ACTIVE"] = "active";
30
+ SocialAccountStatus["EXPIRED"] = "expired";
31
+ SocialAccountStatus["REVOKED"] = "revoked";
32
+ SocialAccountStatus["ERROR"] = "error";
33
+ })(SocialAccountStatus || (exports.SocialAccountStatus = SocialAccountStatus = {}));
34
+ let SocialAccount = class SocialAccount {
35
+ };
36
+ exports.SocialAccount = SocialAccount;
37
+ __decorate([
38
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
39
+ __metadata("design:type", String)
40
+ ], SocialAccount.prototype, "id", void 0);
41
+ __decorate([
42
+ (0, typeorm_1.Column)({ name: 'workspace_id', type: 'uuid' }),
43
+ __metadata("design:type", String)
44
+ ], SocialAccount.prototype, "workspaceId", void 0);
45
+ __decorate([
46
+ (0, typeorm_1.ManyToOne)(() => workspace_entity_1.Workspace, { nullable: false }),
47
+ (0, typeorm_1.JoinColumn)({ name: 'workspace_id' }),
48
+ __metadata("design:type", workspace_entity_1.Workspace)
49
+ ], SocialAccount.prototype, "workspace", void 0);
50
+ __decorate([
51
+ (0, typeorm_1.Column)({ name: 'connected_by_user_id', type: 'uuid' }),
52
+ __metadata("design:type", String)
53
+ ], SocialAccount.prototype, "connectedByUserId", void 0);
54
+ __decorate([
55
+ (0, typeorm_1.Column)({ type: 'enum', enum: SocialPlatform }),
56
+ __metadata("design:type", String)
57
+ ], SocialAccount.prototype, "platform", void 0);
58
+ __decorate([
59
+ (0, typeorm_1.Column)({ name: 'auth_method', type: 'enum', enum: AuthMethod }),
60
+ __metadata("design:type", String)
61
+ ], SocialAccount.prototype, "authMethod", void 0);
62
+ __decorate([
63
+ (0, typeorm_1.Column)({ name: 'platform_account_id', type: 'varchar', length: 255 }),
64
+ __metadata("design:type", String)
65
+ ], SocialAccount.prototype, "platformAccountId", void 0);
66
+ __decorate([
67
+ (0, typeorm_1.Column)({
68
+ name: 'platform_account_name',
69
+ type: 'varchar',
70
+ length: 255,
71
+ nullable: true,
72
+ }),
73
+ __metadata("design:type", String)
74
+ ], SocialAccount.prototype, "platformAccountName", void 0);
75
+ __decorate([
76
+ (0, typeorm_1.Column)({ name: 'platform_profile_url', type: 'text', nullable: true }),
77
+ __metadata("design:type", String)
78
+ ], SocialAccount.prototype, "platformProfileUrl", void 0);
79
+ __decorate([
80
+ (0, typeorm_1.Column)({ name: 'platform_avatar_url', type: 'text', nullable: true }),
81
+ __metadata("design:type", String)
82
+ ], SocialAccount.prototype, "platformAvatarUrl", void 0);
83
+ __decorate([
84
+ (0, typeorm_1.Column)({ name: 'encrypted_access_token', type: 'text', nullable: true }),
85
+ __metadata("design:type", String)
86
+ ], SocialAccount.prototype, "encryptedAccessToken", void 0);
87
+ __decorate([
88
+ (0, typeorm_1.Column)({ name: 'encrypted_refresh_token', type: 'text', nullable: true }),
89
+ __metadata("design:type", String)
90
+ ], SocialAccount.prototype, "encryptedRefreshToken", void 0);
91
+ __decorate([
92
+ (0, typeorm_1.Column)({ name: 'encrypted_api_key', type: 'text', nullable: true }),
93
+ __metadata("design:type", String)
94
+ ], SocialAccount.prototype, "encryptedApiKey", void 0);
95
+ __decorate([
96
+ (0, typeorm_1.Column)({ name: 'token_expires_at', type: 'timestamp', nullable: true }),
97
+ __metadata("design:type", Date)
98
+ ], SocialAccount.prototype, "tokenExpiresAt", void 0);
99
+ __decorate([
100
+ (0, typeorm_1.Column)({ name: 'platform_metadata', type: 'jsonb', nullable: true }),
101
+ __metadata("design:type", Object)
102
+ ], SocialAccount.prototype, "platformMetadata", void 0);
103
+ __decorate([
104
+ (0, typeorm_1.Column)({
105
+ type: 'enum',
106
+ enum: SocialAccountStatus,
107
+ default: SocialAccountStatus.ACTIVE,
108
+ }),
109
+ __metadata("design:type", String)
110
+ ], SocialAccount.prototype, "status", void 0);
111
+ __decorate([
112
+ (0, typeorm_1.Column)({ name: 'last_error', type: 'text', nullable: true }),
113
+ __metadata("design:type", String)
114
+ ], SocialAccount.prototype, "lastError", void 0);
115
+ __decorate([
116
+ (0, typeorm_1.Column)({ name: 'last_synced_at', type: 'timestamp', nullable: true }),
117
+ __metadata("design:type", Date)
118
+ ], SocialAccount.prototype, "lastSyncedAt", void 0);
119
+ __decorate([
120
+ (0, typeorm_1.CreateDateColumn)({ name: 'created_at' }),
121
+ __metadata("design:type", Date)
122
+ ], SocialAccount.prototype, "createdAt", void 0);
123
+ __decorate([
124
+ (0, typeorm_1.UpdateDateColumn)({ name: 'updated_at' }),
125
+ __metadata("design:type", Date)
126
+ ], SocialAccount.prototype, "updatedAt", void 0);
127
+ exports.SocialAccount = SocialAccount = __decorate([
128
+ (0, typeorm_1.Entity)('social_accounts'),
129
+ (0, typeorm_1.Index)(['workspaceId']),
130
+ (0, typeorm_1.Index)(['workspaceId', 'platform'])
131
+ ], SocialAccount);
@@ -0,0 +1,45 @@
1
+ import { Workspace } from './workspace.entity';
2
+ import { SocialAccount, SocialPlatform } from './social-account.entity';
3
+ export { SocialPlatform } from './social-account.entity';
4
+ export declare enum SocialPostStatus {
5
+ PENDING = "pending",
6
+ UPLOADING = "uploading",
7
+ PROCESSING = "processing",
8
+ SCHEDULED = "scheduled",
9
+ PUBLISHED = "published",
10
+ FAILED = "failed",
11
+ CANCELLED = "cancelled"
12
+ }
13
+ export declare enum SocialPostVisibility {
14
+ PUBLIC = "public",
15
+ PRIVATE = "private",
16
+ UNLISTED = "unlisted",
17
+ DRAFT = "draft"
18
+ }
19
+ export declare class SocialPost {
20
+ id: string;
21
+ workspaceId: string;
22
+ workspace: Workspace;
23
+ userId: string;
24
+ socialAccountId: string;
25
+ socialAccount: SocialAccount;
26
+ projectId: string | null;
27
+ videoRenderId: string | null;
28
+ platform: SocialPlatform;
29
+ title: string | null;
30
+ description: string | null;
31
+ tags: string[] | null;
32
+ visibility: string | null;
33
+ thumbnailS3Key: string | null;
34
+ platformSpecificOptions: Record<string, unknown> | null;
35
+ scheduledAt: Date | null;
36
+ status: SocialPostStatus;
37
+ platformPostId: string | null;
38
+ platformPostUrl: string | null;
39
+ lastError: string | null;
40
+ retryCount: number;
41
+ publishedAt: Date | null;
42
+ creditReservationId: string | null;
43
+ createdAt: Date;
44
+ updatedAt: Date;
45
+ }
@@ -0,0 +1,171 @@
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.SocialPost = exports.SocialPostVisibility = exports.SocialPostStatus = exports.SocialPlatform = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const workspace_entity_1 = require("./workspace.entity");
15
+ const social_account_entity_1 = require("./social-account.entity");
16
+ var social_account_entity_2 = require("./social-account.entity");
17
+ Object.defineProperty(exports, "SocialPlatform", { enumerable: true, get: function () { return social_account_entity_2.SocialPlatform; } });
18
+ var SocialPostStatus;
19
+ (function (SocialPostStatus) {
20
+ SocialPostStatus["PENDING"] = "pending";
21
+ SocialPostStatus["UPLOADING"] = "uploading";
22
+ SocialPostStatus["PROCESSING"] = "processing";
23
+ SocialPostStatus["SCHEDULED"] = "scheduled";
24
+ SocialPostStatus["PUBLISHED"] = "published";
25
+ SocialPostStatus["FAILED"] = "failed";
26
+ SocialPostStatus["CANCELLED"] = "cancelled";
27
+ })(SocialPostStatus || (exports.SocialPostStatus = SocialPostStatus = {}));
28
+ var SocialPostVisibility;
29
+ (function (SocialPostVisibility) {
30
+ SocialPostVisibility["PUBLIC"] = "public";
31
+ SocialPostVisibility["PRIVATE"] = "private";
32
+ SocialPostVisibility["UNLISTED"] = "unlisted";
33
+ SocialPostVisibility["DRAFT"] = "draft";
34
+ })(SocialPostVisibility || (exports.SocialPostVisibility = SocialPostVisibility = {}));
35
+ let SocialPost = class SocialPost {
36
+ };
37
+ exports.SocialPost = SocialPost;
38
+ __decorate([
39
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
40
+ __metadata("design:type", String)
41
+ ], SocialPost.prototype, "id", void 0);
42
+ __decorate([
43
+ (0, typeorm_1.Column)({ name: 'workspace_id', type: 'uuid' }),
44
+ __metadata("design:type", String)
45
+ ], SocialPost.prototype, "workspaceId", void 0);
46
+ __decorate([
47
+ (0, typeorm_1.ManyToOne)(() => workspace_entity_1.Workspace, { nullable: false }),
48
+ (0, typeorm_1.JoinColumn)({ name: 'workspace_id' }),
49
+ __metadata("design:type", workspace_entity_1.Workspace)
50
+ ], SocialPost.prototype, "workspace", void 0);
51
+ __decorate([
52
+ (0, typeorm_1.Column)({ name: 'user_id', type: 'uuid' }),
53
+ __metadata("design:type", String)
54
+ ], SocialPost.prototype, "userId", void 0);
55
+ __decorate([
56
+ (0, typeorm_1.Column)({ name: 'social_account_id', type: 'uuid' }),
57
+ __metadata("design:type", String)
58
+ ], SocialPost.prototype, "socialAccountId", void 0);
59
+ __decorate([
60
+ (0, typeorm_1.ManyToOne)(() => social_account_entity_1.SocialAccount, { nullable: false }),
61
+ (0, typeorm_1.JoinColumn)({ name: 'social_account_id' }),
62
+ __metadata("design:type", social_account_entity_1.SocialAccount)
63
+ ], SocialPost.prototype, "socialAccount", void 0);
64
+ __decorate([
65
+ (0, typeorm_1.Column)({ name: 'project_id', type: 'varchar', length: 255, nullable: true }),
66
+ __metadata("design:type", String)
67
+ ], SocialPost.prototype, "projectId", void 0);
68
+ __decorate([
69
+ (0, typeorm_1.Column)({
70
+ name: 'video_render_id',
71
+ type: 'varchar',
72
+ length: 255,
73
+ nullable: true,
74
+ }),
75
+ __metadata("design:type", String)
76
+ ], SocialPost.prototype, "videoRenderId", void 0);
77
+ __decorate([
78
+ (0, typeorm_1.Column)({ type: 'enum', enum: social_account_entity_1.SocialPlatform }),
79
+ __metadata("design:type", String)
80
+ ], SocialPost.prototype, "platform", void 0);
81
+ __decorate([
82
+ (0, typeorm_1.Column)({ type: 'varchar', length: 500, nullable: true }),
83
+ __metadata("design:type", String)
84
+ ], SocialPost.prototype, "title", void 0);
85
+ __decorate([
86
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
87
+ __metadata("design:type", String)
88
+ ], SocialPost.prototype, "description", void 0);
89
+ __decorate([
90
+ (0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
91
+ __metadata("design:type", Array)
92
+ ], SocialPost.prototype, "tags", void 0);
93
+ __decorate([
94
+ (0, typeorm_1.Column)({ name: 'visibility', type: 'varchar', length: 50, nullable: true }),
95
+ __metadata("design:type", String)
96
+ ], SocialPost.prototype, "visibility", void 0);
97
+ __decorate([
98
+ (0, typeorm_1.Column)({
99
+ name: 'thumbnail_s3_key',
100
+ type: 'varchar',
101
+ length: 500,
102
+ nullable: true,
103
+ }),
104
+ __metadata("design:type", String)
105
+ ], SocialPost.prototype, "thumbnailS3Key", void 0);
106
+ __decorate([
107
+ (0, typeorm_1.Column)({ name: 'platform_specific_options', type: 'jsonb', nullable: true }),
108
+ __metadata("design:type", Object)
109
+ ], SocialPost.prototype, "platformSpecificOptions", void 0);
110
+ __decorate([
111
+ (0, typeorm_1.Column)({ name: 'scheduled_at', type: 'timestamp', nullable: true }),
112
+ __metadata("design:type", Date)
113
+ ], SocialPost.prototype, "scheduledAt", void 0);
114
+ __decorate([
115
+ (0, typeorm_1.Column)({
116
+ type: 'enum',
117
+ enum: SocialPostStatus,
118
+ default: SocialPostStatus.PENDING,
119
+ }),
120
+ __metadata("design:type", String)
121
+ ], SocialPost.prototype, "status", void 0);
122
+ __decorate([
123
+ (0, typeorm_1.Column)({
124
+ name: 'platform_post_id',
125
+ type: 'varchar',
126
+ length: 255,
127
+ nullable: true,
128
+ }),
129
+ __metadata("design:type", String)
130
+ ], SocialPost.prototype, "platformPostId", void 0);
131
+ __decorate([
132
+ (0, typeorm_1.Column)({ name: 'platform_post_url', type: 'text', nullable: true }),
133
+ __metadata("design:type", String)
134
+ ], SocialPost.prototype, "platformPostUrl", void 0);
135
+ __decorate([
136
+ (0, typeorm_1.Column)({ name: 'last_error', type: 'text', nullable: true }),
137
+ __metadata("design:type", String)
138
+ ], SocialPost.prototype, "lastError", void 0);
139
+ __decorate([
140
+ (0, typeorm_1.Column)({ name: 'retry_count', type: 'int', default: 0 }),
141
+ __metadata("design:type", Number)
142
+ ], SocialPost.prototype, "retryCount", void 0);
143
+ __decorate([
144
+ (0, typeorm_1.Column)({ name: 'published_at', type: 'timestamp', nullable: true }),
145
+ __metadata("design:type", Date)
146
+ ], SocialPost.prototype, "publishedAt", void 0);
147
+ __decorate([
148
+ (0, typeorm_1.Column)({
149
+ name: 'credit_reservation_id',
150
+ type: 'varchar',
151
+ length: 255,
152
+ nullable: true,
153
+ }),
154
+ __metadata("design:type", String)
155
+ ], SocialPost.prototype, "creditReservationId", void 0);
156
+ __decorate([
157
+ (0, typeorm_1.CreateDateColumn)({ name: 'created_at' }),
158
+ __metadata("design:type", Date)
159
+ ], SocialPost.prototype, "createdAt", void 0);
160
+ __decorate([
161
+ (0, typeorm_1.UpdateDateColumn)({ name: 'updated_at' }),
162
+ __metadata("design:type", Date)
163
+ ], SocialPost.prototype, "updatedAt", void 0);
164
+ exports.SocialPost = SocialPost = __decorate([
165
+ (0, typeorm_1.Entity)('social_posts'),
166
+ (0, typeorm_1.Index)(['workspaceId']),
167
+ (0, typeorm_1.Index)(['socialAccountId']),
168
+ (0, typeorm_1.Index)(['projectId']),
169
+ (0, typeorm_1.Index)(['status']),
170
+ (0, typeorm_1.Index)(['workspaceId', 'publishedAt'])
171
+ ], SocialPost);
@@ -0,0 +1,12 @@
1
+ import { DataSource, Repository } from 'typeorm';
2
+ import { AccountAnalyticsSummary } from '../entities/account-analytics-summary.entity';
3
+ export declare class AccountAnalyticsSummaryRepository extends Repository<AccountAnalyticsSummary> {
4
+ private dataSource;
5
+ constructor(dataSource: DataSource);
6
+ findByAccountInRange(socialAccountId: string, startDate: string, endDate: string): Promise<AccountAnalyticsSummary[]>;
7
+ findByWorkspaceInRange(workspaceId: string, startDate: string, endDate: string): Promise<AccountAnalyticsSummary[]>;
8
+ upsertForDate(data: Partial<AccountAnalyticsSummary> & {
9
+ socialAccountId: string;
10
+ date: string;
11
+ }): Promise<AccountAnalyticsSummary>;
12
+ }
@@ -0,0 +1,55 @@
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.AccountAnalyticsSummaryRepository = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const typeorm_1 = require("typeorm");
15
+ const account_analytics_summary_entity_1 = require("../entities/account-analytics-summary.entity");
16
+ let AccountAnalyticsSummaryRepository = class AccountAnalyticsSummaryRepository extends typeorm_1.Repository {
17
+ constructor(dataSource) {
18
+ super(account_analytics_summary_entity_1.AccountAnalyticsSummary, dataSource.createEntityManager());
19
+ this.dataSource = dataSource;
20
+ }
21
+ async findByAccountInRange(socialAccountId, startDate, endDate) {
22
+ return this.find({
23
+ where: {
24
+ socialAccountId,
25
+ date: (0, typeorm_1.Between)(startDate, endDate),
26
+ },
27
+ order: { date: 'ASC' },
28
+ });
29
+ }
30
+ async findByWorkspaceInRange(workspaceId, startDate, endDate) {
31
+ return this.find({
32
+ where: {
33
+ workspaceId,
34
+ date: (0, typeorm_1.Between)(startDate, endDate),
35
+ },
36
+ order: { date: 'ASC' },
37
+ });
38
+ }
39
+ async upsertForDate(data) {
40
+ const existing = await this.findOne({
41
+ where: { socialAccountId: data.socialAccountId, date: data.date },
42
+ });
43
+ if (existing) {
44
+ Object.assign(existing, data);
45
+ return this.save(existing);
46
+ }
47
+ const entity = this.create(data);
48
+ return this.save(entity);
49
+ }
50
+ };
51
+ exports.AccountAnalyticsSummaryRepository = AccountAnalyticsSummaryRepository;
52
+ exports.AccountAnalyticsSummaryRepository = AccountAnalyticsSummaryRepository = __decorate([
53
+ (0, common_1.Injectable)(),
54
+ __metadata("design:paramtypes", [typeorm_1.DataSource])
55
+ ], AccountAnalyticsSummaryRepository);
@@ -43,3 +43,8 @@ export { AssetCategoryRepository } from './asset-category.repository';
43
43
  export { ProjectBrandOverrideRepository } from './project-brand-override.repository';
44
44
  export { AiVideoJobRepository } from './ai-video-job.repository';
45
45
  export { AiVideoSceneTaskRepository } from './ai-video-scene-task.repository';
46
+ export { SocialAccountRepository } from './social-account.repository';
47
+ export { PlatformConfigRepository } from './platform-config.repository';
48
+ export { SocialPostRepository } from './social-post.repository';
49
+ export { PostAnalyticsSnapshotRepository } from './post-analytics-snapshot.repository';
50
+ export { AccountAnalyticsSummaryRepository } from './account-analytics-summary.repository';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AiVideoSceneTaskRepository = exports.AiVideoJobRepository = exports.ProjectBrandOverrideRepository = exports.AssetCategoryRepository = exports.BrandAssetRepository = exports.BrandKitRepository = exports.ProjectShareRepository = exports.RemotionRenderRepository = exports.ItemRepository = exports.SceneRepository = exports.ProjectSceneRepository = exports.MetadataActivityLogRepository = exports.AiEmbeddingRepository = exports.UserContextRepository = exports.ProjectMetadataRepository = exports.AssetMetadataRepository = exports.AudioWaveformRepository = exports.VideoFilmstripRepository = exports.VideoSubtitleRepository = exports.VideoRenderRepository = exports.VideoTranscodeRepository = exports.EffectRepository = exports.AssetRepository = exports.AiUsageRepository = exports.ReferralEventRepository = exports.RewardRuleRepository = exports.PlanCreditConfigurationRepository = exports.CreditTransactionRepository = exports.CreditAllocationRepository = exports.StripeWebhookRepository = exports.PaymentTransactionRepository = exports.SubscriptionUsageRepository = exports.UserSubscriptionRepository = exports.PlanRepository = exports.SubscriptionPlanRepository = exports.CommentRepository = exports.EditorProjectRepository = exports.InviteRepository = exports.WorkspaceMemberRepository = exports.WorkspaceRepository = exports.AuthSessionRepository = exports.UserOnboardingRepository = exports.UserProfileRepository = exports.UserRepository = exports.BaseRepository = void 0;
3
+ exports.AccountAnalyticsSummaryRepository = exports.PostAnalyticsSnapshotRepository = exports.SocialPostRepository = exports.PlatformConfigRepository = exports.SocialAccountRepository = exports.AiVideoSceneTaskRepository = exports.AiVideoJobRepository = exports.ProjectBrandOverrideRepository = exports.AssetCategoryRepository = exports.BrandAssetRepository = exports.BrandKitRepository = exports.ProjectShareRepository = exports.RemotionRenderRepository = exports.ItemRepository = exports.SceneRepository = exports.ProjectSceneRepository = exports.MetadataActivityLogRepository = exports.AiEmbeddingRepository = exports.UserContextRepository = exports.ProjectMetadataRepository = exports.AssetMetadataRepository = exports.AudioWaveformRepository = exports.VideoFilmstripRepository = exports.VideoSubtitleRepository = exports.VideoRenderRepository = exports.VideoTranscodeRepository = exports.EffectRepository = exports.AssetRepository = exports.AiUsageRepository = exports.ReferralEventRepository = exports.RewardRuleRepository = exports.PlanCreditConfigurationRepository = exports.CreditTransactionRepository = exports.CreditAllocationRepository = exports.StripeWebhookRepository = exports.PaymentTransactionRepository = exports.SubscriptionUsageRepository = exports.UserSubscriptionRepository = exports.PlanRepository = exports.SubscriptionPlanRepository = exports.CommentRepository = exports.EditorProjectRepository = exports.InviteRepository = exports.WorkspaceMemberRepository = exports.WorkspaceRepository = exports.AuthSessionRepository = exports.UserOnboardingRepository = exports.UserProfileRepository = exports.UserRepository = exports.BaseRepository = void 0;
4
4
  var base_repository_1 = require("./base.repository");
5
5
  Object.defineProperty(exports, "BaseRepository", { enumerable: true, get: function () { return base_repository_1.BaseRepository; } });
6
6
  var user_repository_1 = require("./user.repository");
@@ -91,3 +91,13 @@ var ai_video_job_repository_1 = require("./ai-video-job.repository");
91
91
  Object.defineProperty(exports, "AiVideoJobRepository", { enumerable: true, get: function () { return ai_video_job_repository_1.AiVideoJobRepository; } });
92
92
  var ai_video_scene_task_repository_1 = require("./ai-video-scene-task.repository");
93
93
  Object.defineProperty(exports, "AiVideoSceneTaskRepository", { enumerable: true, get: function () { return ai_video_scene_task_repository_1.AiVideoSceneTaskRepository; } });
94
+ var social_account_repository_1 = require("./social-account.repository");
95
+ Object.defineProperty(exports, "SocialAccountRepository", { enumerable: true, get: function () { return social_account_repository_1.SocialAccountRepository; } });
96
+ var platform_config_repository_1 = require("./platform-config.repository");
97
+ Object.defineProperty(exports, "PlatformConfigRepository", { enumerable: true, get: function () { return platform_config_repository_1.PlatformConfigRepository; } });
98
+ var social_post_repository_1 = require("./social-post.repository");
99
+ Object.defineProperty(exports, "SocialPostRepository", { enumerable: true, get: function () { return social_post_repository_1.SocialPostRepository; } });
100
+ var post_analytics_snapshot_repository_1 = require("./post-analytics-snapshot.repository");
101
+ Object.defineProperty(exports, "PostAnalyticsSnapshotRepository", { enumerable: true, get: function () { return post_analytics_snapshot_repository_1.PostAnalyticsSnapshotRepository; } });
102
+ var account_analytics_summary_repository_1 = require("./account-analytics-summary.repository");
103
+ Object.defineProperty(exports, "AccountAnalyticsSummaryRepository", { enumerable: true, get: function () { return account_analytics_summary_repository_1.AccountAnalyticsSummaryRepository; } });
@@ -0,0 +1,10 @@
1
+ import { Repository } from 'typeorm';
2
+ import { BaseRepository } from './base.repository';
3
+ import { PlatformConfig } from '../entities/platform-config.entity';
4
+ import { SocialPlatform } from '../entities/social-account.entity';
5
+ export declare class PlatformConfigRepository extends BaseRepository<PlatformConfig> {
6
+ private readonly platformConfigRepository;
7
+ constructor(platformConfigRepository: Repository<PlatformConfig>);
8
+ findByWorkspace(workspaceId: string): Promise<PlatformConfig[]>;
9
+ findByWorkspaceAndPlatform(workspaceId: string, platform: SocialPlatform): Promise<PlatformConfig | null>;
10
+ }
@@ -0,0 +1,43 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.PlatformConfigRepository = void 0;
16
+ const typeorm_1 = require("typeorm");
17
+ const common_1 = require("@nestjs/common");
18
+ const typeorm_2 = require("@nestjs/typeorm");
19
+ const base_repository_1 = require("./base.repository");
20
+ const platform_config_entity_1 = require("../entities/platform-config.entity");
21
+ let PlatformConfigRepository = class PlatformConfigRepository extends base_repository_1.BaseRepository {
22
+ constructor(platformConfigRepository) {
23
+ super(platformConfigRepository);
24
+ this.platformConfigRepository = platformConfigRepository;
25
+ }
26
+ async findByWorkspace(workspaceId) {
27
+ return this.platformConfigRepository.find({
28
+ where: { workspaceId },
29
+ order: { createdAt: 'DESC' },
30
+ });
31
+ }
32
+ async findByWorkspaceAndPlatform(workspaceId, platform) {
33
+ return this.platformConfigRepository.findOne({
34
+ where: { workspaceId, platform },
35
+ });
36
+ }
37
+ };
38
+ exports.PlatformConfigRepository = PlatformConfigRepository;
39
+ exports.PlatformConfigRepository = PlatformConfigRepository = __decorate([
40
+ (0, common_1.Injectable)(),
41
+ __param(0, (0, typeorm_2.InjectRepository)(platform_config_entity_1.PlatformConfig)),
42
+ __metadata("design:paramtypes", [typeorm_1.Repository])
43
+ ], PlatformConfigRepository);
@@ -0,0 +1,9 @@
1
+ import { DataSource, Repository } from 'typeorm';
2
+ import { PostAnalyticsSnapshot } from '../entities/post-analytics-snapshot.entity';
3
+ export declare class PostAnalyticsSnapshotRepository extends Repository<PostAnalyticsSnapshot> {
4
+ private dataSource;
5
+ constructor(dataSource: DataSource);
6
+ findLatestByPost(socialPostId: string): Promise<PostAnalyticsSnapshot | null>;
7
+ findByPostInRange(socialPostId: string, startDate: Date, endDate: Date): Promise<PostAnalyticsSnapshot[]>;
8
+ findByWorkspaceInRange(workspaceId: string, startDate: Date, endDate: Date): Promise<PostAnalyticsSnapshot[]>;
9
+ }
@@ -0,0 +1,50 @@
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.PostAnalyticsSnapshotRepository = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const typeorm_1 = require("typeorm");
15
+ const post_analytics_snapshot_entity_1 = require("../entities/post-analytics-snapshot.entity");
16
+ let PostAnalyticsSnapshotRepository = class PostAnalyticsSnapshotRepository extends typeorm_1.Repository {
17
+ constructor(dataSource) {
18
+ super(post_analytics_snapshot_entity_1.PostAnalyticsSnapshot, dataSource.createEntityManager());
19
+ this.dataSource = dataSource;
20
+ }
21
+ async findLatestByPost(socialPostId) {
22
+ return this.findOne({
23
+ where: { socialPostId },
24
+ order: { snapshotTakenAt: 'DESC' },
25
+ });
26
+ }
27
+ async findByPostInRange(socialPostId, startDate, endDate) {
28
+ return this.find({
29
+ where: {
30
+ socialPostId,
31
+ snapshotTakenAt: (0, typeorm_1.Between)(startDate, endDate),
32
+ },
33
+ order: { snapshotTakenAt: 'ASC' },
34
+ });
35
+ }
36
+ async findByWorkspaceInRange(workspaceId, startDate, endDate) {
37
+ return this.find({
38
+ where: {
39
+ workspaceId,
40
+ snapshotTakenAt: (0, typeorm_1.Between)(startDate, endDate),
41
+ },
42
+ order: { snapshotTakenAt: 'DESC' },
43
+ });
44
+ }
45
+ };
46
+ exports.PostAnalyticsSnapshotRepository = PostAnalyticsSnapshotRepository;
47
+ exports.PostAnalyticsSnapshotRepository = PostAnalyticsSnapshotRepository = __decorate([
48
+ (0, common_1.Injectable)(),
49
+ __metadata("design:paramtypes", [typeorm_1.DataSource])
50
+ ], PostAnalyticsSnapshotRepository);
@@ -1,2 +1,3 @@
1
+ export { SocialPlatform, AuthMethod, SocialAccountStatus, SocialPostStatus, } from '../entities';
1
2
  export declare class RepositoryModule {
2
3
  }
@@ -6,10 +6,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.RepositoryModule = void 0;
9
+ exports.RepositoryModule = exports.SocialPostStatus = exports.SocialAccountStatus = exports.AuthMethod = exports.SocialPlatform = void 0;
10
10
  const common_1 = require("@nestjs/common");
11
11
  const typeorm_1 = require("@nestjs/typeorm");
12
12
  const entities_1 = require("../entities");
13
+ var entities_2 = require("../entities");
14
+ Object.defineProperty(exports, "SocialPlatform", { enumerable: true, get: function () { return entities_2.SocialPlatform; } });
15
+ Object.defineProperty(exports, "AuthMethod", { enumerable: true, get: function () { return entities_2.AuthMethod; } });
16
+ Object.defineProperty(exports, "SocialAccountStatus", { enumerable: true, get: function () { return entities_2.SocialAccountStatus; } });
17
+ Object.defineProperty(exports, "SocialPostStatus", { enumerable: true, get: function () { return entities_2.SocialPostStatus; } });
13
18
  const _1 = require("./");
14
19
  const repositories = [
15
20
  _1.UserRepository,
@@ -56,6 +61,11 @@ const repositories = [
56
61
  _1.ProjectBrandOverrideRepository,
57
62
  _1.AiVideoJobRepository,
58
63
  _1.AiVideoSceneTaskRepository,
64
+ _1.SocialAccountRepository,
65
+ _1.PlatformConfigRepository,
66
+ _1.SocialPostRepository,
67
+ _1.PostAnalyticsSnapshotRepository,
68
+ _1.AccountAnalyticsSummaryRepository,
59
69
  ];
60
70
  const entities = [
61
71
  entities_1.User,
@@ -104,6 +114,11 @@ const entities = [
104
114
  entities_1.ProjectBrandOverride,
105
115
  entities_1.AiVideoJob,
106
116
  entities_1.AiVideoSceneTask,
117
+ entities_1.SocialAccount,
118
+ entities_1.PlatformConfig,
119
+ entities_1.SocialPost,
120
+ entities_1.PostAnalyticsSnapshot,
121
+ entities_1.AccountAnalyticsSummary,
107
122
  ];
108
123
  let RepositoryModule = class RepositoryModule {
109
124
  };
@@ -0,0 +1,9 @@
1
+ import { Repository } from 'typeorm';
2
+ import { BaseRepository } from './base.repository';
3
+ import { SocialAccount, SocialPlatform } from '../entities/social-account.entity';
4
+ export declare class SocialAccountRepository extends BaseRepository<SocialAccount> {
5
+ private readonly socialAccountRepository;
6
+ constructor(socialAccountRepository: Repository<SocialAccount>);
7
+ findByWorkspace(workspaceId: string): Promise<SocialAccount[]>;
8
+ findByWorkspaceAndPlatform(workspaceId: string, platform: SocialPlatform): Promise<SocialAccount[]>;
9
+ }