agrs-sequelize-sdk 1.4.17 → 1.4.19
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 -0
- package/migrations/2026-05-17-add-platform-to-ad.js +19 -0
- package/migrations/2026-05-17-add-platform-to-adaccount.js +19 -0
- package/migrations/2026-05-17-add-platform-to-adperformance.js +19 -0
- package/migrations/2026-05-17-add-platform-to-adset.js +19 -0
- package/migrations/2026-05-17-add-platform-to-adsetperformance.js +19 -0
- package/migrations/2026-05-17-add-platform-to-aiarticleretryqueue.js +19 -0
- package/migrations/2026-05-17-add-platform-to-aicampaignqueue.js +19 -0
- package/migrations/2026-05-17-add-platform-to-article.js +19 -0
- package/migrations/2026-05-17-add-platform-to-campaign.js +19 -0
- package/migrations/2026-05-17-add-platform-to-codefuelcampaign.js +19 -0
- package/migrations/2026-05-17-add-platform-to-dynamicfeed.js +19 -0
- package/migrations/2026-05-17-add-platform-to-facebookretryqueue.js +19 -0
- package/migrations/2026-05-17-add-platform-to-pages.js +19 -0
- package/migrations/2026-05-17-add-platform-to-presets.js +19 -0
- package/migrations/RUN_ME_MANUALLY_2026-05-17.sql +99 -0
- 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 +143 -136
- package/models/AIGenerationLog.js +85 -85
- package/models/AIGenerationRequest.js +212 -212
- package/models/Ad.js +6 -0
- package/models/AdAccount.js +6 -0
- package/models/AdAccountValues.js +25 -25
- package/models/AdHistory.js +30 -30
- package/models/AdPerformance.js +100 -94
- package/models/AdSet.js +295 -289
- package/models/AdSetHistory.js +30 -30
- package/models/AdsetPerformance.js +132 -126
- package/models/AiArticleRetryQueue.js +157 -150
- package/models/AiCreationRetryQueue.js +127 -127
- package/models/ApiAuditLog.js +84 -0
- package/models/ApiToken.js +67 -0
- package/models/Article.js +212 -206
- package/models/AutomationRule.js +173 -173
- package/models/BannerTemplate.js +129 -129
- package/models/Buyers.js +25 -25
- package/models/Campaign.js +163 -157
- package/models/CampaignActionHistory.js +86 -86
- package/models/CampaignCreationLog.js +309 -309
- package/models/CampaignCreationLogV2.js +314 -314
- package/models/CampaignHistory.js +33 -33
- package/models/Channel.js +55 -55
- package/models/CodefuelCampaign.js +6 -0
- package/models/Domain.js +39 -39
- package/models/DynamicFeed.js +218 -212
- package/models/ExplorAdsChannel.js +61 -61
- package/models/FacebookRetryQueue.js +163 -156
- 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/MineChannel.js +42 -42
- package/models/Pages.js +105 -99
- package/models/PipelineExecution.js +59 -59
- package/models/PolicyDogsCreativeCache.js +50 -50
- package/models/PolicyDogsImageCache.js +30 -30
- package/models/Presets.js +40 -34
- package/models/RSOCFeedCampaign.js +375 -375
- 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/SupportedLocale.js +23 -23
- package/models/SyncHistory.js +249 -249
- package/models/TTQChannel.js +42 -42
- 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/TokenRotationState.js +121 -121
- package/models/TonicRSOCKeywordPerformance.js +122 -122
- package/models/Users.js +148 -148
- package/models/Vertical.js +25 -25
- package/models/newFiles.js +137 -137
- package/package.json +19 -21
- package/run.sh +214 -214
- package/services/sequelizeService.js +110 -110
package/models/Article.js
CHANGED
|
@@ -1,206 +1,212 @@
|
|
|
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
|
-
feed: {
|
|
35
|
-
type: DataTypes.STRING,
|
|
36
|
-
allowNull: false,
|
|
37
|
-
},
|
|
38
|
-
feedName: {
|
|
39
|
-
type: DataTypes.STRING,
|
|
40
|
-
allowNull: false,
|
|
41
|
-
},
|
|
42
|
-
vertical: {
|
|
43
|
-
type: DataTypes.STRING,
|
|
44
|
-
allowNull: false,
|
|
45
|
-
},
|
|
46
|
-
language: {
|
|
47
|
-
type: DataTypes.STRING,
|
|
48
|
-
allowNull: false,
|
|
49
|
-
defaultValue: "en",
|
|
50
|
-
},
|
|
51
|
-
headline: {
|
|
52
|
-
type: DataTypes.STRING(1000),
|
|
53
|
-
allowNull: true,
|
|
54
|
-
},
|
|
55
|
-
topics: {
|
|
56
|
-
type: DataTypes.ARRAY(DataTypes.STRING(1000)),
|
|
57
|
-
allowNull: true,
|
|
58
|
-
},
|
|
59
|
-
translatedTopics: {
|
|
60
|
-
type: DataTypes.ARRAY(DataTypes.STRING(1000)),
|
|
61
|
-
allowNull: true,
|
|
62
|
-
comment: "Topics translated to English for display purposes",
|
|
63
|
-
},
|
|
64
|
-
mainKeyword: {
|
|
65
|
-
type: DataTypes.STRING,
|
|
66
|
-
allowNull: true,
|
|
67
|
-
},
|
|
68
|
-
predictoKeyword: {
|
|
69
|
-
type: DataTypes.STRING,
|
|
70
|
-
allowNull: true,
|
|
71
|
-
comment: "Exact keyword sent to Predicto (with suffix for uniqueness). Used for search= URL param.",
|
|
72
|
-
},
|
|
73
|
-
keywords: {
|
|
74
|
-
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
75
|
-
allowNull: true,
|
|
76
|
-
},
|
|
77
|
-
date: {
|
|
78
|
-
type: DataTypes.DATE,
|
|
79
|
-
allowNull: true,
|
|
80
|
-
defaultValue: DataTypes.NOW,
|
|
81
|
-
},
|
|
82
|
-
nativeKeyword: {
|
|
83
|
-
type: DataTypes.STRING,
|
|
84
|
-
allowNull: false,
|
|
85
|
-
},
|
|
86
|
-
suggestedKeywords: {
|
|
87
|
-
type: DataTypes.STRING,
|
|
88
|
-
allowNull: true,
|
|
89
|
-
},
|
|
90
|
-
articleExcerpt: {
|
|
91
|
-
type: DataTypes.TEXT,
|
|
92
|
-
allowNull: true,
|
|
93
|
-
},
|
|
94
|
-
articleContent: {
|
|
95
|
-
type: DataTypes.TEXT,
|
|
96
|
-
allowNull: true,
|
|
97
|
-
},
|
|
98
|
-
fbPixelId: {
|
|
99
|
-
type: DataTypes.STRING,
|
|
100
|
-
allowNull: true,
|
|
101
|
-
},
|
|
102
|
-
status: {
|
|
103
|
-
type: DataTypes.STRING,
|
|
104
|
-
allowNull: false,
|
|
105
|
-
defaultValue: "pending",
|
|
106
|
-
},
|
|
107
|
-
originalStatus: {
|
|
108
|
-
type: DataTypes.STRING,
|
|
109
|
-
allowNull: true,
|
|
110
|
-
comment: "Original status from Predicto before any mapping",
|
|
111
|
-
},
|
|
112
|
-
rejectionReason: {
|
|
113
|
-
type: DataTypes.TEXT,
|
|
114
|
-
allowNull: true,
|
|
115
|
-
comment: "Rejection reason from Predicto when keyword is disapproved",
|
|
116
|
-
},
|
|
117
|
-
creationType: {
|
|
118
|
-
type: DataTypes.STRING,
|
|
119
|
-
allowNull: false,
|
|
120
|
-
defaultValue: "slug",
|
|
121
|
-
validate: {
|
|
122
|
-
isIn: [["search", "slug", "manual-tonic"]],
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
createdAt: {
|
|
126
|
-
type: DataTypes.DATE,
|
|
127
|
-
defaultValue: DataTypes.NOW,
|
|
128
|
-
},
|
|
129
|
-
updatedAt: {
|
|
130
|
-
type: DataTypes.DATE,
|
|
131
|
-
defaultValue: DataTypes.NOW,
|
|
132
|
-
},
|
|
133
|
-
buyer: {
|
|
134
|
-
type: DataTypes.STRING,
|
|
135
|
-
allowNull: true,
|
|
136
|
-
},
|
|
137
|
-
country: {
|
|
138
|
-
type: DataTypes.STRING,
|
|
139
|
-
allowNull: true,
|
|
140
|
-
},
|
|
141
|
-
name: {
|
|
142
|
-
type: DataTypes.STRING,
|
|
143
|
-
allowNull: true,
|
|
144
|
-
},
|
|
145
|
-
submittedToMine: {
|
|
146
|
-
type: DataTypes.BOOLEAN,
|
|
147
|
-
allowNull: true,
|
|
148
|
-
defaultValue: false,
|
|
149
|
-
comment: "Tracks if article has been submitted to Mine Marketing API in bulk migration"
|
|
150
|
-
},
|
|
151
|
-
submittedToMineAt: {
|
|
152
|
-
type: DataTypes.DATE,
|
|
153
|
-
allowNull: true,
|
|
154
|
-
comment: "Timestamp when article was submitted to Mine Marketing"
|
|
155
|
-
},
|
|
156
|
-
contentType: {
|
|
157
|
-
type: DataTypes.STRING,
|
|
158
|
-
allowNull: true,
|
|
159
|
-
defaultValue: 'generate',
|
|
160
|
-
validate: {
|
|
161
|
-
isIn: [['generate', 'import']]
|
|
162
|
-
},
|
|
163
|
-
comment: "Type of content: 'generate' for AI-generated or 'import' from URL"
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
+
feed: {
|
|
35
|
+
type: DataTypes.STRING,
|
|
36
|
+
allowNull: false,
|
|
37
|
+
},
|
|
38
|
+
feedName: {
|
|
39
|
+
type: DataTypes.STRING,
|
|
40
|
+
allowNull: false,
|
|
41
|
+
},
|
|
42
|
+
vertical: {
|
|
43
|
+
type: DataTypes.STRING,
|
|
44
|
+
allowNull: false,
|
|
45
|
+
},
|
|
46
|
+
language: {
|
|
47
|
+
type: DataTypes.STRING,
|
|
48
|
+
allowNull: false,
|
|
49
|
+
defaultValue: "en",
|
|
50
|
+
},
|
|
51
|
+
headline: {
|
|
52
|
+
type: DataTypes.STRING(1000),
|
|
53
|
+
allowNull: true,
|
|
54
|
+
},
|
|
55
|
+
topics: {
|
|
56
|
+
type: DataTypes.ARRAY(DataTypes.STRING(1000)),
|
|
57
|
+
allowNull: true,
|
|
58
|
+
},
|
|
59
|
+
translatedTopics: {
|
|
60
|
+
type: DataTypes.ARRAY(DataTypes.STRING(1000)),
|
|
61
|
+
allowNull: true,
|
|
62
|
+
comment: "Topics translated to English for display purposes",
|
|
63
|
+
},
|
|
64
|
+
mainKeyword: {
|
|
65
|
+
type: DataTypes.STRING,
|
|
66
|
+
allowNull: true,
|
|
67
|
+
},
|
|
68
|
+
predictoKeyword: {
|
|
69
|
+
type: DataTypes.STRING,
|
|
70
|
+
allowNull: true,
|
|
71
|
+
comment: "Exact keyword sent to Predicto (with suffix for uniqueness). Used for search= URL param.",
|
|
72
|
+
},
|
|
73
|
+
keywords: {
|
|
74
|
+
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
75
|
+
allowNull: true,
|
|
76
|
+
},
|
|
77
|
+
date: {
|
|
78
|
+
type: DataTypes.DATE,
|
|
79
|
+
allowNull: true,
|
|
80
|
+
defaultValue: DataTypes.NOW,
|
|
81
|
+
},
|
|
82
|
+
nativeKeyword: {
|
|
83
|
+
type: DataTypes.STRING,
|
|
84
|
+
allowNull: false,
|
|
85
|
+
},
|
|
86
|
+
suggestedKeywords: {
|
|
87
|
+
type: DataTypes.STRING,
|
|
88
|
+
allowNull: true,
|
|
89
|
+
},
|
|
90
|
+
articleExcerpt: {
|
|
91
|
+
type: DataTypes.TEXT,
|
|
92
|
+
allowNull: true,
|
|
93
|
+
},
|
|
94
|
+
articleContent: {
|
|
95
|
+
type: DataTypes.TEXT,
|
|
96
|
+
allowNull: true,
|
|
97
|
+
},
|
|
98
|
+
fbPixelId: {
|
|
99
|
+
type: DataTypes.STRING,
|
|
100
|
+
allowNull: true,
|
|
101
|
+
},
|
|
102
|
+
status: {
|
|
103
|
+
type: DataTypes.STRING,
|
|
104
|
+
allowNull: false,
|
|
105
|
+
defaultValue: "pending",
|
|
106
|
+
},
|
|
107
|
+
originalStatus: {
|
|
108
|
+
type: DataTypes.STRING,
|
|
109
|
+
allowNull: true,
|
|
110
|
+
comment: "Original status from Predicto before any mapping",
|
|
111
|
+
},
|
|
112
|
+
rejectionReason: {
|
|
113
|
+
type: DataTypes.TEXT,
|
|
114
|
+
allowNull: true,
|
|
115
|
+
comment: "Rejection reason from Predicto when keyword is disapproved",
|
|
116
|
+
},
|
|
117
|
+
creationType: {
|
|
118
|
+
type: DataTypes.STRING,
|
|
119
|
+
allowNull: false,
|
|
120
|
+
defaultValue: "slug",
|
|
121
|
+
validate: {
|
|
122
|
+
isIn: [["search", "slug", "manual-tonic"]],
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
createdAt: {
|
|
126
|
+
type: DataTypes.DATE,
|
|
127
|
+
defaultValue: DataTypes.NOW,
|
|
128
|
+
},
|
|
129
|
+
updatedAt: {
|
|
130
|
+
type: DataTypes.DATE,
|
|
131
|
+
defaultValue: DataTypes.NOW,
|
|
132
|
+
},
|
|
133
|
+
buyer: {
|
|
134
|
+
type: DataTypes.STRING,
|
|
135
|
+
allowNull: true,
|
|
136
|
+
},
|
|
137
|
+
country: {
|
|
138
|
+
type: DataTypes.STRING,
|
|
139
|
+
allowNull: true,
|
|
140
|
+
},
|
|
141
|
+
name: {
|
|
142
|
+
type: DataTypes.STRING,
|
|
143
|
+
allowNull: true,
|
|
144
|
+
},
|
|
145
|
+
submittedToMine: {
|
|
146
|
+
type: DataTypes.BOOLEAN,
|
|
147
|
+
allowNull: true,
|
|
148
|
+
defaultValue: false,
|
|
149
|
+
comment: "Tracks if article has been submitted to Mine Marketing API in bulk migration"
|
|
150
|
+
},
|
|
151
|
+
submittedToMineAt: {
|
|
152
|
+
type: DataTypes.DATE,
|
|
153
|
+
allowNull: true,
|
|
154
|
+
comment: "Timestamp when article was submitted to Mine Marketing"
|
|
155
|
+
},
|
|
156
|
+
contentType: {
|
|
157
|
+
type: DataTypes.STRING,
|
|
158
|
+
allowNull: true,
|
|
159
|
+
defaultValue: 'generate',
|
|
160
|
+
validate: {
|
|
161
|
+
isIn: [['generate', 'import']]
|
|
162
|
+
},
|
|
163
|
+
comment: "Type of content: 'generate' for AI-generated or 'import' from URL"
|
|
164
|
+
},
|
|
165
|
+
platform: {
|
|
166
|
+
type: DataTypes.ENUM("fb", "tt", "snp"),
|
|
167
|
+
allowNull: false,
|
|
168
|
+
defaultValue: "fb",
|
|
169
|
+
comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
tableName: "articles",
|
|
174
|
+
timestamps: true,
|
|
175
|
+
indexes: [
|
|
176
|
+
{
|
|
177
|
+
unique: true,
|
|
178
|
+
fields: ['providerId', 'feed'],
|
|
179
|
+
name: 'unique_provider_per_feed'
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
Article.associate = (models) => {
|
|
186
|
+
Article.hasMany(models.RSOCFeedCampaign, {
|
|
187
|
+
foreignKey: "AGRSAID",
|
|
188
|
+
sourceKey: "AGRSAID",
|
|
189
|
+
as: "RSOCFeedCampaigns",
|
|
190
|
+
constraints: false,
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
Article.prototype.isAvailableForCampaign = function () {
|
|
195
|
+
return ["approved", "keyword_already_exists"].includes(this.status);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// NEW METHODS FOR URL STRUCTURE HANDLING
|
|
199
|
+
Article.prototype.isUnifiedStructure = function () {
|
|
200
|
+
return this.url_structure === "unified";
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
Article.prototype.getTargetDomain = function () {
|
|
204
|
+
return this.target_domain || "sportfoy.com";
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
Article.prototype.isLegacyStructure = function () {
|
|
208
|
+
return this.url_structure === "legacy";
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
return Article;
|
|
212
|
+
};
|