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.
Files changed (86) hide show
  1. package/migrations/2026-05-17-PIXELS-FOLLOWUP.md +85 -0
  2. package/migrations/2026-05-17-add-platform-to-ad.js +19 -0
  3. package/migrations/2026-05-17-add-platform-to-adaccount.js +19 -0
  4. package/migrations/2026-05-17-add-platform-to-adperformance.js +19 -0
  5. package/migrations/2026-05-17-add-platform-to-adset.js +19 -0
  6. package/migrations/2026-05-17-add-platform-to-adsetperformance.js +19 -0
  7. package/migrations/2026-05-17-add-platform-to-aiarticleretryqueue.js +19 -0
  8. package/migrations/2026-05-17-add-platform-to-aicampaignqueue.js +19 -0
  9. package/migrations/2026-05-17-add-platform-to-article.js +19 -0
  10. package/migrations/2026-05-17-add-platform-to-campaign.js +19 -0
  11. package/migrations/2026-05-17-add-platform-to-codefuelcampaign.js +19 -0
  12. package/migrations/2026-05-17-add-platform-to-dynamicfeed.js +19 -0
  13. package/migrations/2026-05-17-add-platform-to-facebookretryqueue.js +19 -0
  14. package/migrations/2026-05-17-add-platform-to-pages.js +19 -0
  15. package/migrations/2026-05-17-add-platform-to-presets.js +19 -0
  16. package/migrations/RUN_ME_MANUALLY_2026-05-17.sql +99 -0
  17. package/migrations/add-requested-from-dashboard-to-articles.js +17 -17
  18. package/migrations/change-adset-name-to-text.js +79 -79
  19. package/models/AICampaignQueue.js +143 -136
  20. package/models/AIGenerationLog.js +85 -85
  21. package/models/AIGenerationRequest.js +212 -212
  22. package/models/Ad.js +6 -0
  23. package/models/AdAccount.js +6 -0
  24. package/models/AdAccountValues.js +25 -25
  25. package/models/AdHistory.js +30 -30
  26. package/models/AdPerformance.js +100 -94
  27. package/models/AdSet.js +295 -289
  28. package/models/AdSetHistory.js +30 -30
  29. package/models/AdsetPerformance.js +132 -126
  30. package/models/AiArticleRetryQueue.js +157 -150
  31. package/models/AiCreationRetryQueue.js +127 -127
  32. package/models/ApiAuditLog.js +84 -0
  33. package/models/ApiToken.js +67 -0
  34. package/models/Article.js +212 -206
  35. package/models/AutomationRule.js +173 -173
  36. package/models/BannerTemplate.js +129 -129
  37. package/models/Buyers.js +25 -25
  38. package/models/Campaign.js +163 -157
  39. package/models/CampaignActionHistory.js +86 -86
  40. package/models/CampaignCreationLog.js +309 -309
  41. package/models/CampaignCreationLogV2.js +314 -314
  42. package/models/CampaignHistory.js +33 -33
  43. package/models/Channel.js +55 -55
  44. package/models/CodefuelCampaign.js +6 -0
  45. package/models/Domain.js +39 -39
  46. package/models/DynamicFeed.js +218 -212
  47. package/models/ExplorAdsChannel.js +61 -61
  48. package/models/FacebookRetryQueue.js +163 -156
  49. package/models/Feed.js +33 -33
  50. package/models/FeedArticleConfiguration.js +80 -80
  51. package/models/FrontStoryChannel.js +59 -59
  52. package/models/FrontStoryChannelV2.js +60 -60
  53. package/models/GenericFlowRequest.js +114 -114
  54. package/models/MidoWebChannel.js +47 -47
  55. package/models/MineChannel.js +42 -42
  56. package/models/Pages.js +105 -99
  57. package/models/PipelineExecution.js +59 -59
  58. package/models/PolicyDogsCreativeCache.js +50 -50
  59. package/models/PolicyDogsImageCache.js +30 -30
  60. package/models/Presets.js +40 -34
  61. package/models/RSOCFeedCampaign.js +375 -375
  62. package/models/RsocKeywordPerformance.js +110 -110
  63. package/models/RuleAction.js +90 -90
  64. package/models/RuleCondition.js +137 -137
  65. package/models/RuleExecution.js +107 -107
  66. package/models/RulesValues.js +56 -56
  67. package/models/SupportedLocale.js +23 -23
  68. package/models/SyncHistory.js +249 -249
  69. package/models/TTQChannel.js +42 -42
  70. package/models/TemplateMetadata.js +260 -260
  71. package/models/Tier2_AdAccounts.js +110 -110
  72. package/models/Tier2_Assets.js +70 -70
  73. package/models/Tier2_BusinessManagers.js +105 -105
  74. package/models/Tier2_CreditLines.js +99 -99
  75. package/models/Tier2_Pages.js +91 -91
  76. package/models/Tier2_Pixels.js +82 -82
  77. package/models/Tier2_Tokens.js +64 -64
  78. package/models/Tier2_UserAdAccounts.js +83 -83
  79. package/models/TokenRotationState.js +121 -121
  80. package/models/TonicRSOCKeywordPerformance.js +122 -122
  81. package/models/Users.js +148 -148
  82. package/models/Vertical.js +25 -25
  83. package/models/newFiles.js +137 -137
  84. package/package.json +19 -21
  85. package/run.sh +214 -214
  86. 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
- 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
+ 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
+ };