agrs-sequelize-sdk 1.4.59 → 1.4.61
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/migrations/2026-05-17-PIXELS-FOLLOWUP.md +85 -85
- package/migrations/2026-05-17-add-platform-to-ad.js +19 -19
- package/migrations/2026-05-17-add-platform-to-adaccount.js +19 -19
- package/migrations/2026-05-17-add-platform-to-adperformance.js +19 -19
- package/migrations/2026-05-17-add-platform-to-adset.js +19 -19
- package/migrations/2026-05-17-add-platform-to-adsetperformance.js +19 -19
- package/migrations/2026-05-17-add-platform-to-aiarticleretryqueue.js +19 -19
- package/migrations/2026-05-17-add-platform-to-aicampaignqueue.js +19 -19
- package/migrations/2026-05-17-add-platform-to-article.js +19 -19
- package/migrations/2026-05-17-add-platform-to-campaign.js +19 -19
- package/migrations/2026-05-17-add-platform-to-codefuelcampaign.js +19 -19
- package/migrations/2026-05-17-add-platform-to-dynamicfeed.js +19 -19
- package/migrations/2026-05-17-add-platform-to-facebookretryqueue.js +19 -19
- package/migrations/2026-05-17-add-platform-to-pages.js +19 -19
- package/migrations/2026-05-17-add-platform-to-presets.js +19 -19
- package/migrations/2026-05-18-add-group-id-to-ai-campaign-queue.js +18 -18
- package/migrations/2026-05-18-add-platform-code-to-creation-logs.js +65 -65
- package/migrations/2026-05-18-add-platform-code-to-pixels.js +55 -55
- package/migrations/2026-05-18-add-platform-code-to-rsoc-feed-campaigns.js +55 -55
- package/migrations/2026-05-18-add-platform-date-index-to-adperformance.js +16 -16
- package/migrations/2026-05-18-add-platform-date-index-to-adsetperformance.js +16 -16
- package/migrations/2026-05-18-add-review-status-to-ad.js +36 -36
- package/migrations/2026-05-18-create-canonical-insights.js +84 -84
- package/migrations/2026-05-18-create-snapchat-public-profiles.js +68 -68
- package/migrations/2026-05-18-create-tiktok-identities.js +71 -71
- package/migrations/2026-05-18-create-tiktok-snapchat-campaigns.js +143 -143
- package/migrations/2026-05-18-create-tt-snp-adset-ad-tables.js +309 -309
- package/migrations/RUN_ME_MANUALLY_2026-05-17.sql +99 -99
- package/migrations/add-requested-from-dashboard-to-articles.js +17 -17
- package/migrations/change-adset-name-to-text.js +79 -79
- package/models/AICampaignQueue.js +151 -151
- package/models/AIGenerationLog.js +85 -85
- package/models/AIGenerationRequest.js +212 -212
- package/models/AdAccountValues.js +25 -25
- package/models/AdHistory.js +30 -30
- package/models/AdPerformance.js +104 -104
- package/models/AdSet.js +295 -295
- package/models/AdSetHistory.js +30 -30
- package/models/AdsetPerformance.js +137 -137
- package/models/AiArticleRetryQueue.js +157 -157
- package/models/AiCreationRetryQueue.js +134 -134
- package/models/ApiAuditLog.js +127 -127
- package/models/ApiToken.js +67 -67
- package/models/Article.js +222 -222
- package/models/AutomationRule.js +179 -179
- package/models/BannerTemplate.js +129 -129
- package/models/Buyers.js +25 -25
- package/models/Campaign.js +168 -168
- package/models/CampaignActionHistory.js +101 -101
- package/models/CampaignCreationLog.js +340 -340
- package/models/CampaignCreationLogV2.js +392 -392
- package/models/CampaignHistory.js +33 -33
- package/models/CampaignTag.js +46 -46
- package/models/CampaignTagAssignment.js +48 -48
- package/models/CanonicalInsights.js +68 -68
- package/models/Channel.js +55 -55
- package/models/Domain.js +49 -44
- package/models/DynamicFeed.js +218 -218
- package/models/ExplorAdsChannel.js +61 -61
- package/models/FacebookRetryQueue.js +163 -163
- package/models/Feed.js +33 -33
- package/models/FeedArticleConfiguration.js +80 -80
- package/models/FrontStoryChannel.js +59 -59
- package/models/FrontStoryChannelV2.js +60 -60
- package/models/GenericFlowRequest.js +114 -114
- package/models/MidoWebChannel.js +47 -47
- package/models/MineBrandBlocklist.js +56 -56
- package/models/MineBrandConfig.js +26 -26
- package/models/MineChannel.js +47 -47
- package/models/MineRedirectDomain.js +42 -42
- package/models/MineWebhookEvent.js +53 -53
- package/models/Pages.js +117 -117
- package/models/PipelineExecution.js +59 -59
- package/models/PolicyDogsCreativeCache.js +50 -50
- package/models/PolicyDogsImageCache.js +30 -30
- package/models/Presets.js +40 -40
- package/models/PublicApiBatch.js +155 -155
- package/models/PublicApiBatchItem.js +166 -166
- package/models/PublicApiIdempotencyCache.js +135 -135
- package/models/RSOCFeedCampaign.js +387 -387
- package/models/RSOCFeedConfig.js +46 -46
- package/models/RSOCRedirectWsCode.js +22 -22
- package/models/RsocKeywordPerformance.js +110 -110
- package/models/RuleAction.js +90 -90
- package/models/RuleCondition.js +137 -137
- package/models/RuleExecution.js +107 -107
- package/models/RulesValues.js +56 -56
- package/models/SingularChannel.js +31 -31
- package/models/SnapchatAd.js +69 -69
- package/models/SnapchatAdSquad.js +92 -92
- package/models/SnapchatCampaign.js +69 -69
- package/models/SnapchatChannel.js +31 -31
- package/models/SnapchatPublicProfiles.js +67 -67
- package/models/SupportedLocale.js +23 -23
- package/models/SyncHistory.js +249 -249
- package/models/TTQChannel.js +42 -42
- package/models/Team.js +33 -43
- package/models/TemplateMetadata.js +260 -260
- package/models/Tier2_AdAccounts.js +110 -110
- package/models/Tier2_Assets.js +70 -70
- package/models/Tier2_BusinessManagers.js +105 -105
- package/models/Tier2_CreditLines.js +99 -99
- package/models/Tier2_Pages.js +91 -91
- package/models/Tier2_Pixels.js +82 -82
- package/models/Tier2_Tokens.js +64 -64
- package/models/Tier2_UserAdAccounts.js +83 -83
- package/models/TikTokAd.js +71 -71
- package/models/TikTokAdGroup.js +82 -82
- package/models/TikTokCampaign.js +71 -71
- package/models/TiktokChannel.js +31 -31
- package/models/TiktokIdentities.js +65 -65
- package/models/TokenRotationState.js +121 -121
- package/models/TonicRSOCKeywordPerformance.js +122 -122
- package/models/Users.js +204 -204
- package/models/Vertical.js +25 -25
- package/models/newFiles.js +137 -137
- package/package.json +21 -19
- package/run.sh +214 -214
- package/services/sequelizeService.js +110 -110
- package/tarzo-skalio-integration-docs.md +691 -691
package/models/Article.js
CHANGED
|
@@ -1,222 +1,222 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const Article = sequelize.define(
|
|
3
|
-
"Article",
|
|
4
|
-
{
|
|
5
|
-
providerId: {
|
|
6
|
-
type: DataTypes.STRING,
|
|
7
|
-
allowNull: true,
|
|
8
|
-
},
|
|
9
|
-
keywordId: {
|
|
10
|
-
type: DataTypes.STRING,
|
|
11
|
-
allowNull: true,
|
|
12
|
-
comment: "ID of the keyword from Predicto keywords API",
|
|
13
|
-
},
|
|
14
|
-
requestedFromDashboard: {
|
|
15
|
-
type: DataTypes.BOOLEAN,
|
|
16
|
-
allowNull: false,
|
|
17
|
-
defaultValue: false,
|
|
18
|
-
comment:
|
|
19
|
-
"Indicates if the article was created through our dashboard (true) or imported from external sources (false)",
|
|
20
|
-
},
|
|
21
|
-
category: {
|
|
22
|
-
type: DataTypes.STRING,
|
|
23
|
-
allowNull: true,
|
|
24
|
-
},
|
|
25
|
-
AGRSAID: {
|
|
26
|
-
type: DataTypes.STRING,
|
|
27
|
-
allowNull: false,
|
|
28
|
-
unique: true,
|
|
29
|
-
},
|
|
30
|
-
articleUrl: {
|
|
31
|
-
type: DataTypes.STRING(1024),
|
|
32
|
-
allowNull: true,
|
|
33
|
-
},
|
|
34
|
-
sourceCampaignId: {
|
|
35
|
-
type: DataTypes.STRING,
|
|
36
|
-
allowNull: true,
|
|
37
|
-
comment:
|
|
38
|
-
"FB campaign id of the campaign that originally created this article. Populated by Tarzo mirror on create-success so duplicate-as-reuse can find the source when this article is reused. Nullable — not all articles have a known source (legacy rows, articles whose source campaign was deleted).",
|
|
39
|
-
},
|
|
40
|
-
feed: {
|
|
41
|
-
type: DataTypes.STRING,
|
|
42
|
-
allowNull: false,
|
|
43
|
-
},
|
|
44
|
-
feedName: {
|
|
45
|
-
type: DataTypes.STRING,
|
|
46
|
-
allowNull: false,
|
|
47
|
-
},
|
|
48
|
-
vertical: {
|
|
49
|
-
type: DataTypes.STRING,
|
|
50
|
-
allowNull: false,
|
|
51
|
-
},
|
|
52
|
-
language: {
|
|
53
|
-
type: DataTypes.STRING,
|
|
54
|
-
allowNull: false,
|
|
55
|
-
defaultValue: "en",
|
|
56
|
-
},
|
|
57
|
-
headline: {
|
|
58
|
-
type: DataTypes.STRING(1000),
|
|
59
|
-
allowNull: true,
|
|
60
|
-
},
|
|
61
|
-
topics: {
|
|
62
|
-
type: DataTypes.ARRAY(DataTypes.STRING(1000)),
|
|
63
|
-
allowNull: true,
|
|
64
|
-
},
|
|
65
|
-
translatedTopics: {
|
|
66
|
-
type: DataTypes.ARRAY(DataTypes.STRING(1000)),
|
|
67
|
-
allowNull: true,
|
|
68
|
-
comment: "Topics translated to English for display purposes",
|
|
69
|
-
},
|
|
70
|
-
mainKeyword: {
|
|
71
|
-
type: DataTypes.STRING,
|
|
72
|
-
allowNull: true,
|
|
73
|
-
},
|
|
74
|
-
predictoKeyword: {
|
|
75
|
-
type: DataTypes.STRING,
|
|
76
|
-
allowNull: true,
|
|
77
|
-
comment: "Exact keyword sent to Predicto (with suffix for uniqueness). Used for search= URL param.",
|
|
78
|
-
},
|
|
79
|
-
keywords: {
|
|
80
|
-
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
81
|
-
allowNull: true,
|
|
82
|
-
},
|
|
83
|
-
date: {
|
|
84
|
-
type: DataTypes.DATE,
|
|
85
|
-
allowNull: true,
|
|
86
|
-
defaultValue: DataTypes.NOW,
|
|
87
|
-
},
|
|
88
|
-
nativeKeyword: {
|
|
89
|
-
type: DataTypes.STRING,
|
|
90
|
-
allowNull: false,
|
|
91
|
-
},
|
|
92
|
-
suggestedKeywords: {
|
|
93
|
-
type: DataTypes.STRING,
|
|
94
|
-
allowNull: true,
|
|
95
|
-
},
|
|
96
|
-
articleExcerpt: {
|
|
97
|
-
type: DataTypes.TEXT,
|
|
98
|
-
allowNull: true,
|
|
99
|
-
},
|
|
100
|
-
articleContent: {
|
|
101
|
-
type: DataTypes.TEXT,
|
|
102
|
-
allowNull: true,
|
|
103
|
-
},
|
|
104
|
-
fbPixelId: {
|
|
105
|
-
type: DataTypes.STRING,
|
|
106
|
-
allowNull: true,
|
|
107
|
-
},
|
|
108
|
-
status: {
|
|
109
|
-
type: DataTypes.STRING,
|
|
110
|
-
allowNull: false,
|
|
111
|
-
defaultValue: "pending",
|
|
112
|
-
},
|
|
113
|
-
originalStatus: {
|
|
114
|
-
type: DataTypes.STRING,
|
|
115
|
-
allowNull: true,
|
|
116
|
-
comment: "Original status from Predicto before any mapping",
|
|
117
|
-
},
|
|
118
|
-
rejectionReason: {
|
|
119
|
-
type: DataTypes.TEXT,
|
|
120
|
-
allowNull: true,
|
|
121
|
-
comment: "Rejection reason from Predicto when keyword is disapproved",
|
|
122
|
-
},
|
|
123
|
-
creationType: {
|
|
124
|
-
type: DataTypes.STRING,
|
|
125
|
-
allowNull: false,
|
|
126
|
-
defaultValue: "slug",
|
|
127
|
-
validate: {
|
|
128
|
-
isIn: [["search", "slug", "manual-tonic"]],
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
createdAt: {
|
|
132
|
-
type: DataTypes.DATE,
|
|
133
|
-
defaultValue: DataTypes.NOW,
|
|
134
|
-
},
|
|
135
|
-
updatedAt: {
|
|
136
|
-
type: DataTypes.DATE,
|
|
137
|
-
defaultValue: DataTypes.NOW,
|
|
138
|
-
},
|
|
139
|
-
buyer: {
|
|
140
|
-
type: DataTypes.STRING,
|
|
141
|
-
allowNull: true,
|
|
142
|
-
},
|
|
143
|
-
country: {
|
|
144
|
-
type: DataTypes.STRING,
|
|
145
|
-
allowNull: true,
|
|
146
|
-
},
|
|
147
|
-
name: {
|
|
148
|
-
type: DataTypes.STRING,
|
|
149
|
-
allowNull: true,
|
|
150
|
-
},
|
|
151
|
-
submittedToMine: {
|
|
152
|
-
type: DataTypes.BOOLEAN,
|
|
153
|
-
allowNull: true,
|
|
154
|
-
defaultValue: false,
|
|
155
|
-
comment: "Tracks if article has been submitted to Mine Marketing API in bulk migration"
|
|
156
|
-
},
|
|
157
|
-
submittedToMineAt: {
|
|
158
|
-
type: DataTypes.DATE,
|
|
159
|
-
allowNull: true,
|
|
160
|
-
comment: "Timestamp when article was submitted to Mine Marketing"
|
|
161
|
-
},
|
|
162
|
-
contentType: {
|
|
163
|
-
type: DataTypes.STRING,
|
|
164
|
-
allowNull: true,
|
|
165
|
-
defaultValue: 'generate',
|
|
166
|
-
validate: {
|
|
167
|
-
isIn: [['generate', 'import']]
|
|
168
|
-
},
|
|
169
|
-
comment: "Type of content: 'generate' for AI-generated or 'import' from URL"
|
|
170
|
-
},
|
|
171
|
-
platform: {
|
|
172
|
-
type: DataTypes.ENUM("fb", "tt", "snp"),
|
|
173
|
-
allowNull: false,
|
|
174
|
-
defaultValue: "fb",
|
|
175
|
-
comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
tableName: "articles",
|
|
180
|
-
timestamps: true,
|
|
181
|
-
indexes: [
|
|
182
|
-
{
|
|
183
|
-
unique: true,
|
|
184
|
-
fields: ['providerId', 'feed'],
|
|
185
|
-
name: 'unique_provider_per_feed'
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
fields: ['sourceCampaignId'],
|
|
189
|
-
name: 'idx_article_source_campaign_id'
|
|
190
|
-
}
|
|
191
|
-
]
|
|
192
|
-
}
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
Article.associate = (models) => {
|
|
196
|
-
Article.hasMany(models.RSOCFeedCampaign, {
|
|
197
|
-
foreignKey: "AGRSAID",
|
|
198
|
-
sourceKey: "AGRSAID",
|
|
199
|
-
as: "RSOCFeedCampaigns",
|
|
200
|
-
constraints: false,
|
|
201
|
-
});
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
Article.prototype.isAvailableForCampaign = function () {
|
|
205
|
-
return ["approved", "keyword_already_exists"].includes(this.status);
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
// NEW METHODS FOR URL STRUCTURE HANDLING
|
|
209
|
-
Article.prototype.isUnifiedStructure = function () {
|
|
210
|
-
return this.url_structure === "unified";
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
Article.prototype.getTargetDomain = function () {
|
|
214
|
-
return this.target_domain || "sportfoy.com";
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
Article.prototype.isLegacyStructure = function () {
|
|
218
|
-
return this.url_structure === "legacy";
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
return Article;
|
|
222
|
-
};
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const Article = sequelize.define(
|
|
3
|
+
"Article",
|
|
4
|
+
{
|
|
5
|
+
providerId: {
|
|
6
|
+
type: DataTypes.STRING,
|
|
7
|
+
allowNull: true,
|
|
8
|
+
},
|
|
9
|
+
keywordId: {
|
|
10
|
+
type: DataTypes.STRING,
|
|
11
|
+
allowNull: true,
|
|
12
|
+
comment: "ID of the keyword from Predicto keywords API",
|
|
13
|
+
},
|
|
14
|
+
requestedFromDashboard: {
|
|
15
|
+
type: DataTypes.BOOLEAN,
|
|
16
|
+
allowNull: false,
|
|
17
|
+
defaultValue: false,
|
|
18
|
+
comment:
|
|
19
|
+
"Indicates if the article was created through our dashboard (true) or imported from external sources (false)",
|
|
20
|
+
},
|
|
21
|
+
category: {
|
|
22
|
+
type: DataTypes.STRING,
|
|
23
|
+
allowNull: true,
|
|
24
|
+
},
|
|
25
|
+
AGRSAID: {
|
|
26
|
+
type: DataTypes.STRING,
|
|
27
|
+
allowNull: false,
|
|
28
|
+
unique: true,
|
|
29
|
+
},
|
|
30
|
+
articleUrl: {
|
|
31
|
+
type: DataTypes.STRING(1024),
|
|
32
|
+
allowNull: true,
|
|
33
|
+
},
|
|
34
|
+
sourceCampaignId: {
|
|
35
|
+
type: DataTypes.STRING,
|
|
36
|
+
allowNull: true,
|
|
37
|
+
comment:
|
|
38
|
+
"FB campaign id of the campaign that originally created this article. Populated by Tarzo mirror on create-success so duplicate-as-reuse can find the source when this article is reused. Nullable — not all articles have a known source (legacy rows, articles whose source campaign was deleted).",
|
|
39
|
+
},
|
|
40
|
+
feed: {
|
|
41
|
+
type: DataTypes.STRING,
|
|
42
|
+
allowNull: false,
|
|
43
|
+
},
|
|
44
|
+
feedName: {
|
|
45
|
+
type: DataTypes.STRING,
|
|
46
|
+
allowNull: false,
|
|
47
|
+
},
|
|
48
|
+
vertical: {
|
|
49
|
+
type: DataTypes.STRING,
|
|
50
|
+
allowNull: false,
|
|
51
|
+
},
|
|
52
|
+
language: {
|
|
53
|
+
type: DataTypes.STRING,
|
|
54
|
+
allowNull: false,
|
|
55
|
+
defaultValue: "en",
|
|
56
|
+
},
|
|
57
|
+
headline: {
|
|
58
|
+
type: DataTypes.STRING(1000),
|
|
59
|
+
allowNull: true,
|
|
60
|
+
},
|
|
61
|
+
topics: {
|
|
62
|
+
type: DataTypes.ARRAY(DataTypes.STRING(1000)),
|
|
63
|
+
allowNull: true,
|
|
64
|
+
},
|
|
65
|
+
translatedTopics: {
|
|
66
|
+
type: DataTypes.ARRAY(DataTypes.STRING(1000)),
|
|
67
|
+
allowNull: true,
|
|
68
|
+
comment: "Topics translated to English for display purposes",
|
|
69
|
+
},
|
|
70
|
+
mainKeyword: {
|
|
71
|
+
type: DataTypes.STRING,
|
|
72
|
+
allowNull: true,
|
|
73
|
+
},
|
|
74
|
+
predictoKeyword: {
|
|
75
|
+
type: DataTypes.STRING,
|
|
76
|
+
allowNull: true,
|
|
77
|
+
comment: "Exact keyword sent to Predicto (with suffix for uniqueness). Used for search= URL param.",
|
|
78
|
+
},
|
|
79
|
+
keywords: {
|
|
80
|
+
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
81
|
+
allowNull: true,
|
|
82
|
+
},
|
|
83
|
+
date: {
|
|
84
|
+
type: DataTypes.DATE,
|
|
85
|
+
allowNull: true,
|
|
86
|
+
defaultValue: DataTypes.NOW,
|
|
87
|
+
},
|
|
88
|
+
nativeKeyword: {
|
|
89
|
+
type: DataTypes.STRING,
|
|
90
|
+
allowNull: false,
|
|
91
|
+
},
|
|
92
|
+
suggestedKeywords: {
|
|
93
|
+
type: DataTypes.STRING,
|
|
94
|
+
allowNull: true,
|
|
95
|
+
},
|
|
96
|
+
articleExcerpt: {
|
|
97
|
+
type: DataTypes.TEXT,
|
|
98
|
+
allowNull: true,
|
|
99
|
+
},
|
|
100
|
+
articleContent: {
|
|
101
|
+
type: DataTypes.TEXT,
|
|
102
|
+
allowNull: true,
|
|
103
|
+
},
|
|
104
|
+
fbPixelId: {
|
|
105
|
+
type: DataTypes.STRING,
|
|
106
|
+
allowNull: true,
|
|
107
|
+
},
|
|
108
|
+
status: {
|
|
109
|
+
type: DataTypes.STRING,
|
|
110
|
+
allowNull: false,
|
|
111
|
+
defaultValue: "pending",
|
|
112
|
+
},
|
|
113
|
+
originalStatus: {
|
|
114
|
+
type: DataTypes.STRING,
|
|
115
|
+
allowNull: true,
|
|
116
|
+
comment: "Original status from Predicto before any mapping",
|
|
117
|
+
},
|
|
118
|
+
rejectionReason: {
|
|
119
|
+
type: DataTypes.TEXT,
|
|
120
|
+
allowNull: true,
|
|
121
|
+
comment: "Rejection reason from Predicto when keyword is disapproved",
|
|
122
|
+
},
|
|
123
|
+
creationType: {
|
|
124
|
+
type: DataTypes.STRING,
|
|
125
|
+
allowNull: false,
|
|
126
|
+
defaultValue: "slug",
|
|
127
|
+
validate: {
|
|
128
|
+
isIn: [["search", "slug", "manual-tonic"]],
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
createdAt: {
|
|
132
|
+
type: DataTypes.DATE,
|
|
133
|
+
defaultValue: DataTypes.NOW,
|
|
134
|
+
},
|
|
135
|
+
updatedAt: {
|
|
136
|
+
type: DataTypes.DATE,
|
|
137
|
+
defaultValue: DataTypes.NOW,
|
|
138
|
+
},
|
|
139
|
+
buyer: {
|
|
140
|
+
type: DataTypes.STRING,
|
|
141
|
+
allowNull: true,
|
|
142
|
+
},
|
|
143
|
+
country: {
|
|
144
|
+
type: DataTypes.STRING,
|
|
145
|
+
allowNull: true,
|
|
146
|
+
},
|
|
147
|
+
name: {
|
|
148
|
+
type: DataTypes.STRING,
|
|
149
|
+
allowNull: true,
|
|
150
|
+
},
|
|
151
|
+
submittedToMine: {
|
|
152
|
+
type: DataTypes.BOOLEAN,
|
|
153
|
+
allowNull: true,
|
|
154
|
+
defaultValue: false,
|
|
155
|
+
comment: "Tracks if article has been submitted to Mine Marketing API in bulk migration"
|
|
156
|
+
},
|
|
157
|
+
submittedToMineAt: {
|
|
158
|
+
type: DataTypes.DATE,
|
|
159
|
+
allowNull: true,
|
|
160
|
+
comment: "Timestamp when article was submitted to Mine Marketing"
|
|
161
|
+
},
|
|
162
|
+
contentType: {
|
|
163
|
+
type: DataTypes.STRING,
|
|
164
|
+
allowNull: true,
|
|
165
|
+
defaultValue: 'generate',
|
|
166
|
+
validate: {
|
|
167
|
+
isIn: [['generate', 'import']]
|
|
168
|
+
},
|
|
169
|
+
comment: "Type of content: 'generate' for AI-generated or 'import' from URL"
|
|
170
|
+
},
|
|
171
|
+
platform: {
|
|
172
|
+
type: DataTypes.ENUM("fb", "tt", "snp"),
|
|
173
|
+
allowNull: false,
|
|
174
|
+
defaultValue: "fb",
|
|
175
|
+
comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
tableName: "articles",
|
|
180
|
+
timestamps: true,
|
|
181
|
+
indexes: [
|
|
182
|
+
{
|
|
183
|
+
unique: true,
|
|
184
|
+
fields: ['providerId', 'feed'],
|
|
185
|
+
name: 'unique_provider_per_feed'
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
fields: ['sourceCampaignId'],
|
|
189
|
+
name: 'idx_article_source_campaign_id'
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
Article.associate = (models) => {
|
|
196
|
+
Article.hasMany(models.RSOCFeedCampaign, {
|
|
197
|
+
foreignKey: "AGRSAID",
|
|
198
|
+
sourceKey: "AGRSAID",
|
|
199
|
+
as: "RSOCFeedCampaigns",
|
|
200
|
+
constraints: false,
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
Article.prototype.isAvailableForCampaign = function () {
|
|
205
|
+
return ["approved", "keyword_already_exists"].includes(this.status);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// NEW METHODS FOR URL STRUCTURE HANDLING
|
|
209
|
+
Article.prototype.isUnifiedStructure = function () {
|
|
210
|
+
return this.url_structure === "unified";
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
Article.prototype.getTargetDomain = function () {
|
|
214
|
+
return this.target_domain || "sportfoy.com";
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
Article.prototype.isLegacyStructure = function () {
|
|
218
|
+
return this.url_structure === "legacy";
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
return Article;
|
|
222
|
+
};
|