agrs-sequelize-sdk 1.4.13 → 1.4.15
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/add-requested-from-dashboard-to-articles.js +17 -17
- package/migrations/change-adset-name-to-text.js +79 -79
- package/models/AICampaignQueue.js +136 -136
- 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 +94 -94
- package/models/AdSet.js +289 -289
- package/models/AdSetHistory.js +30 -30
- package/models/AdsetPerformance.js +126 -126
- package/models/AiArticleRetryQueue.js +150 -150
- package/models/AiCreationRetryQueue.js +127 -127
- package/models/Article.js +206 -206
- package/models/AutomationRule.js +173 -173
- package/models/BannerTemplate.js +129 -129
- package/models/Buyers.js +25 -25
- package/models/Campaign.js +157 -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/Domain.js +39 -43
- package/models/DynamicFeed.js +212 -212
- package/models/ExplorAdsChannel.js +61 -61
- package/models/FacebookRetryQueue.js +156 -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 +99 -99
- package/models/PipelineExecution.js +59 -59
- package/models/PolicyDogsCreativeCache.js +50 -50
- package/models/PolicyDogsImageCache.js +30 -30
- package/models/Presets.js +34 -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 +21 -19
- package/run.sh +214 -214
- package/services/sequelizeService.js +110 -110
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const AiCreationRetryQueue = sequelize.define(
|
|
3
|
-
"AiCreationRetryQueue",
|
|
4
|
-
{
|
|
5
|
-
id: {
|
|
6
|
-
type: DataTypes.INTEGER,
|
|
7
|
-
primaryKey: true,
|
|
8
|
-
autoIncrement: true,
|
|
9
|
-
},
|
|
10
|
-
agrs_cid: {
|
|
11
|
-
type: DataTypes.STRING(255),
|
|
12
|
-
allowNull: false,
|
|
13
|
-
field: "agrs_cid",
|
|
14
|
-
comment: "AGRS Campaign ID (links to the campaign combo)",
|
|
15
|
-
},
|
|
16
|
-
process_id: {
|
|
17
|
-
type: DataTypes.STRING(255),
|
|
18
|
-
allowNull: true,
|
|
19
|
-
field: "process_id",
|
|
20
|
-
comment: "Root process_id from createAICampaign",
|
|
21
|
-
},
|
|
22
|
-
controller_process_id: {
|
|
23
|
-
type: DataTypes.UUID,
|
|
24
|
-
allowNull: true,
|
|
25
|
-
field: "controller_process_id",
|
|
26
|
-
comment: "Per-combination process_id (for CampaignCreationLog)",
|
|
27
|
-
},
|
|
28
|
-
feed_provider: {
|
|
29
|
-
type: DataTypes.STRING(100),
|
|
30
|
-
allowNull: false,
|
|
31
|
-
field: "feed_provider",
|
|
32
|
-
comment: "Normalized feed name: Mine - RSOC, Predicto - RSOC, etc.",
|
|
33
|
-
},
|
|
34
|
-
failed_step: {
|
|
35
|
-
type: DataTypes.STRING(50),
|
|
36
|
-
allowNull: false,
|
|
37
|
-
field: "failed_step",
|
|
38
|
-
comment:
|
|
39
|
-
"Step that failed: keywords, texts, banners, fb_creation, rabbitmq_publish",
|
|
40
|
-
},
|
|
41
|
-
original_payload: {
|
|
42
|
-
type: DataTypes.JSONB,
|
|
43
|
-
allowNull: false,
|
|
44
|
-
field: "original_payload",
|
|
45
|
-
comment: "Full combination payload for retry",
|
|
46
|
-
},
|
|
47
|
-
generated_assets: {
|
|
48
|
-
type: DataTypes.JSONB,
|
|
49
|
-
allowNull: true,
|
|
50
|
-
defaultValue: {},
|
|
51
|
-
field: "generated_assets",
|
|
52
|
-
comment:
|
|
53
|
-
"Assets generated before failure: { keywords, headlines, primaryTexts, bannerFiles }",
|
|
54
|
-
},
|
|
55
|
-
campaign_context: {
|
|
56
|
-
type: DataTypes.JSONB,
|
|
57
|
-
allowNull: true,
|
|
58
|
-
defaultValue: {},
|
|
59
|
-
field: "campaign_context",
|
|
60
|
-
comment:
|
|
61
|
-
"Additional context needed to resume campaign flow after retry",
|
|
62
|
-
},
|
|
63
|
-
status: {
|
|
64
|
-
type: DataTypes.STRING(50),
|
|
65
|
-
allowNull: false,
|
|
66
|
-
defaultValue: "pending",
|
|
67
|
-
validate: {
|
|
68
|
-
isIn: [["pending", "processing", "completed", "failed", "abandoned"]],
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
retry_count: {
|
|
72
|
-
type: DataTypes.INTEGER,
|
|
73
|
-
allowNull: false,
|
|
74
|
-
defaultValue: 0,
|
|
75
|
-
field: "retry_count",
|
|
76
|
-
},
|
|
77
|
-
max_retries: {
|
|
78
|
-
type: DataTypes.INTEGER,
|
|
79
|
-
allowNull: false,
|
|
80
|
-
defaultValue: 5,
|
|
81
|
-
field: "max_retries",
|
|
82
|
-
},
|
|
83
|
-
next_retry_at: {
|
|
84
|
-
type: DataTypes.DATE,
|
|
85
|
-
allowNull: false,
|
|
86
|
-
field: "next_retry_at",
|
|
87
|
-
comment: "When the next retry should be attempted",
|
|
88
|
-
},
|
|
89
|
-
last_error: {
|
|
90
|
-
type: DataTypes.TEXT,
|
|
91
|
-
allowNull: true,
|
|
92
|
-
field: "last_error",
|
|
93
|
-
},
|
|
94
|
-
last_attempt_at: {
|
|
95
|
-
type: DataTypes.DATE,
|
|
96
|
-
allowNull: true,
|
|
97
|
-
field: "last_attempt_at",
|
|
98
|
-
},
|
|
99
|
-
completed_at: {
|
|
100
|
-
type: DataTypes.DATE,
|
|
101
|
-
allowNull: true,
|
|
102
|
-
field: "completed_at",
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
tableName: "ai_creation_retry_queue",
|
|
107
|
-
timestamps: true,
|
|
108
|
-
underscored: true,
|
|
109
|
-
indexes: [
|
|
110
|
-
{
|
|
111
|
-
fields: ["status", "next_retry_at"],
|
|
112
|
-
name: "idx_creation_retry_status_next",
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
fields: ["agrs_cid"],
|
|
116
|
-
name: "idx_creation_retry_agrs_cid",
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
}
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
AiCreationRetryQueue.associate = (models) => {
|
|
123
|
-
// No associations needed for now
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
return AiCreationRetryQueue;
|
|
127
|
-
};
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const AiCreationRetryQueue = sequelize.define(
|
|
3
|
+
"AiCreationRetryQueue",
|
|
4
|
+
{
|
|
5
|
+
id: {
|
|
6
|
+
type: DataTypes.INTEGER,
|
|
7
|
+
primaryKey: true,
|
|
8
|
+
autoIncrement: true,
|
|
9
|
+
},
|
|
10
|
+
agrs_cid: {
|
|
11
|
+
type: DataTypes.STRING(255),
|
|
12
|
+
allowNull: false,
|
|
13
|
+
field: "agrs_cid",
|
|
14
|
+
comment: "AGRS Campaign ID (links to the campaign combo)",
|
|
15
|
+
},
|
|
16
|
+
process_id: {
|
|
17
|
+
type: DataTypes.STRING(255),
|
|
18
|
+
allowNull: true,
|
|
19
|
+
field: "process_id",
|
|
20
|
+
comment: "Root process_id from createAICampaign",
|
|
21
|
+
},
|
|
22
|
+
controller_process_id: {
|
|
23
|
+
type: DataTypes.UUID,
|
|
24
|
+
allowNull: true,
|
|
25
|
+
field: "controller_process_id",
|
|
26
|
+
comment: "Per-combination process_id (for CampaignCreationLog)",
|
|
27
|
+
},
|
|
28
|
+
feed_provider: {
|
|
29
|
+
type: DataTypes.STRING(100),
|
|
30
|
+
allowNull: false,
|
|
31
|
+
field: "feed_provider",
|
|
32
|
+
comment: "Normalized feed name: Mine - RSOC, Predicto - RSOC, etc.",
|
|
33
|
+
},
|
|
34
|
+
failed_step: {
|
|
35
|
+
type: DataTypes.STRING(50),
|
|
36
|
+
allowNull: false,
|
|
37
|
+
field: "failed_step",
|
|
38
|
+
comment:
|
|
39
|
+
"Step that failed: keywords, texts, banners, fb_creation, rabbitmq_publish",
|
|
40
|
+
},
|
|
41
|
+
original_payload: {
|
|
42
|
+
type: DataTypes.JSONB,
|
|
43
|
+
allowNull: false,
|
|
44
|
+
field: "original_payload",
|
|
45
|
+
comment: "Full combination payload for retry",
|
|
46
|
+
},
|
|
47
|
+
generated_assets: {
|
|
48
|
+
type: DataTypes.JSONB,
|
|
49
|
+
allowNull: true,
|
|
50
|
+
defaultValue: {},
|
|
51
|
+
field: "generated_assets",
|
|
52
|
+
comment:
|
|
53
|
+
"Assets generated before failure: { keywords, headlines, primaryTexts, bannerFiles }",
|
|
54
|
+
},
|
|
55
|
+
campaign_context: {
|
|
56
|
+
type: DataTypes.JSONB,
|
|
57
|
+
allowNull: true,
|
|
58
|
+
defaultValue: {},
|
|
59
|
+
field: "campaign_context",
|
|
60
|
+
comment:
|
|
61
|
+
"Additional context needed to resume campaign flow after retry",
|
|
62
|
+
},
|
|
63
|
+
status: {
|
|
64
|
+
type: DataTypes.STRING(50),
|
|
65
|
+
allowNull: false,
|
|
66
|
+
defaultValue: "pending",
|
|
67
|
+
validate: {
|
|
68
|
+
isIn: [["pending", "processing", "completed", "failed", "abandoned"]],
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
retry_count: {
|
|
72
|
+
type: DataTypes.INTEGER,
|
|
73
|
+
allowNull: false,
|
|
74
|
+
defaultValue: 0,
|
|
75
|
+
field: "retry_count",
|
|
76
|
+
},
|
|
77
|
+
max_retries: {
|
|
78
|
+
type: DataTypes.INTEGER,
|
|
79
|
+
allowNull: false,
|
|
80
|
+
defaultValue: 5,
|
|
81
|
+
field: "max_retries",
|
|
82
|
+
},
|
|
83
|
+
next_retry_at: {
|
|
84
|
+
type: DataTypes.DATE,
|
|
85
|
+
allowNull: false,
|
|
86
|
+
field: "next_retry_at",
|
|
87
|
+
comment: "When the next retry should be attempted",
|
|
88
|
+
},
|
|
89
|
+
last_error: {
|
|
90
|
+
type: DataTypes.TEXT,
|
|
91
|
+
allowNull: true,
|
|
92
|
+
field: "last_error",
|
|
93
|
+
},
|
|
94
|
+
last_attempt_at: {
|
|
95
|
+
type: DataTypes.DATE,
|
|
96
|
+
allowNull: true,
|
|
97
|
+
field: "last_attempt_at",
|
|
98
|
+
},
|
|
99
|
+
completed_at: {
|
|
100
|
+
type: DataTypes.DATE,
|
|
101
|
+
allowNull: true,
|
|
102
|
+
field: "completed_at",
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
tableName: "ai_creation_retry_queue",
|
|
107
|
+
timestamps: true,
|
|
108
|
+
underscored: true,
|
|
109
|
+
indexes: [
|
|
110
|
+
{
|
|
111
|
+
fields: ["status", "next_retry_at"],
|
|
112
|
+
name: "idx_creation_retry_status_next",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
fields: ["agrs_cid"],
|
|
116
|
+
name: "idx_creation_retry_agrs_cid",
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
AiCreationRetryQueue.associate = (models) => {
|
|
123
|
+
// No associations needed for now
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
return AiCreationRetryQueue;
|
|
127
|
+
};
|
package/models/Article.js
CHANGED
|
@@ -1,206 +1,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
|
-
},
|
|
166
|
-
{
|
|
167
|
-
tableName: "articles",
|
|
168
|
-
timestamps: true,
|
|
169
|
-
indexes: [
|
|
170
|
-
{
|
|
171
|
-
unique: true,
|
|
172
|
-
fields: ['providerId', 'feed'],
|
|
173
|
-
name: 'unique_provider_per_feed'
|
|
174
|
-
}
|
|
175
|
-
]
|
|
176
|
-
}
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
Article.associate = (models) => {
|
|
180
|
-
Article.hasMany(models.RSOCFeedCampaign, {
|
|
181
|
-
foreignKey: "AGRSAID",
|
|
182
|
-
sourceKey: "AGRSAID",
|
|
183
|
-
as: "RSOCFeedCampaigns",
|
|
184
|
-
constraints: false,
|
|
185
|
-
});
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
Article.prototype.isAvailableForCampaign = function () {
|
|
189
|
-
return ["approved", "keyword_already_exists"].includes(this.status);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
// NEW METHODS FOR URL STRUCTURE HANDLING
|
|
193
|
-
Article.prototype.isUnifiedStructure = function () {
|
|
194
|
-
return this.url_structure === "unified";
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
Article.prototype.getTargetDomain = function () {
|
|
198
|
-
return this.target_domain || "sportfoy.com";
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
Article.prototype.isLegacyStructure = function () {
|
|
202
|
-
return this.url_structure === "legacy";
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
return Article;
|
|
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
|
+
},
|
|
166
|
+
{
|
|
167
|
+
tableName: "articles",
|
|
168
|
+
timestamps: true,
|
|
169
|
+
indexes: [
|
|
170
|
+
{
|
|
171
|
+
unique: true,
|
|
172
|
+
fields: ['providerId', 'feed'],
|
|
173
|
+
name: 'unique_provider_per_feed'
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
Article.associate = (models) => {
|
|
180
|
+
Article.hasMany(models.RSOCFeedCampaign, {
|
|
181
|
+
foreignKey: "AGRSAID",
|
|
182
|
+
sourceKey: "AGRSAID",
|
|
183
|
+
as: "RSOCFeedCampaigns",
|
|
184
|
+
constraints: false,
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
Article.prototype.isAvailableForCampaign = function () {
|
|
189
|
+
return ["approved", "keyword_already_exists"].includes(this.status);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// NEW METHODS FOR URL STRUCTURE HANDLING
|
|
193
|
+
Article.prototype.isUnifiedStructure = function () {
|
|
194
|
+
return this.url_structure === "unified";
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
Article.prototype.getTargetDomain = function () {
|
|
198
|
+
return this.target_domain || "sportfoy.com";
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
Article.prototype.isLegacyStructure = function () {
|
|
202
|
+
return this.url_structure === "legacy";
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
return Article;
|
|
206
|
+
};
|