agrs-sequelize-sdk 1.4.16 → 1.4.18

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 (84) 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/Article.js +212 -206
  33. package/models/AutomationRule.js +173 -173
  34. package/models/BannerTemplate.js +129 -129
  35. package/models/Buyers.js +25 -25
  36. package/models/Campaign.js +163 -157
  37. package/models/CampaignActionHistory.js +86 -86
  38. package/models/CampaignCreationLog.js +309 -309
  39. package/models/CampaignCreationLogV2.js +314 -314
  40. package/models/CampaignHistory.js +33 -33
  41. package/models/Channel.js +55 -55
  42. package/models/CodefuelCampaign.js +6 -0
  43. package/models/Domain.js +39 -47
  44. package/models/DynamicFeed.js +218 -212
  45. package/models/ExplorAdsChannel.js +61 -61
  46. package/models/FacebookRetryQueue.js +163 -156
  47. package/models/Feed.js +33 -33
  48. package/models/FeedArticleConfiguration.js +80 -80
  49. package/models/FrontStoryChannel.js +59 -59
  50. package/models/FrontStoryChannelV2.js +60 -60
  51. package/models/GenericFlowRequest.js +114 -114
  52. package/models/MidoWebChannel.js +47 -47
  53. package/models/MineChannel.js +42 -42
  54. package/models/Pages.js +105 -99
  55. package/models/PipelineExecution.js +59 -59
  56. package/models/PolicyDogsCreativeCache.js +50 -50
  57. package/models/PolicyDogsImageCache.js +30 -30
  58. package/models/Presets.js +40 -34
  59. package/models/RSOCFeedCampaign.js +375 -375
  60. package/models/RsocKeywordPerformance.js +110 -110
  61. package/models/RuleAction.js +90 -90
  62. package/models/RuleCondition.js +137 -137
  63. package/models/RuleExecution.js +107 -107
  64. package/models/RulesValues.js +56 -56
  65. package/models/SupportedLocale.js +23 -23
  66. package/models/SyncHistory.js +249 -249
  67. package/models/TTQChannel.js +42 -42
  68. package/models/TemplateMetadata.js +260 -260
  69. package/models/Tier2_AdAccounts.js +110 -110
  70. package/models/Tier2_Assets.js +70 -70
  71. package/models/Tier2_BusinessManagers.js +105 -105
  72. package/models/Tier2_CreditLines.js +99 -99
  73. package/models/Tier2_Pages.js +91 -91
  74. package/models/Tier2_Pixels.js +82 -82
  75. package/models/Tier2_Tokens.js +64 -64
  76. package/models/Tier2_UserAdAccounts.js +83 -83
  77. package/models/TokenRotationState.js +121 -121
  78. package/models/TonicRSOCKeywordPerformance.js +122 -122
  79. package/models/Users.js +148 -148
  80. package/models/Vertical.js +25 -25
  81. package/models/newFiles.js +137 -137
  82. package/package.json +19 -21
  83. package/run.sh +214 -214
  84. package/services/sequelizeService.js +110 -110
@@ -1,314 +1,314 @@
1
- // models/CampaignCreationLogV2.js
2
- module.exports = (sequelize, DataTypes) => {
3
- const CampaignCreationLogV2 = sequelize.define(
4
- "CampaignCreationLogV2",
5
- {
6
- id: {
7
- type: DataTypes.INTEGER,
8
- primaryKey: true,
9
- autoIncrement: true,
10
- },
11
- original_log_id: {
12
- type: DataTypes.INTEGER,
13
- allowNull: true,
14
- unique: true,
15
- comment: "ID from CampaignCreationLog (V1) - prevents duplicates",
16
- },
17
- process_id: {
18
- type: DataTypes.UUID,
19
- allowNull: false,
20
- comment: "Unique ID for the creation batch process",
21
- },
22
- status: {
23
- type: DataTypes.ENUM(
24
- "STARTED",
25
- "IN_PROGRESS",
26
- "COMPLETED",
27
- "FAILED",
28
- "PARTIALLY_COMPLETED"
29
- ),
30
- allowNull: false,
31
- defaultValue: "STARTED",
32
- },
33
-
34
- // Location & Targeting
35
- country: {
36
- type: DataTypes.TEXT,
37
- allowNull: true,
38
- },
39
- countries: {
40
- type: DataTypes.ARRAY(DataTypes.TEXT),
41
- allowNull: true,
42
- },
43
- country_type: {
44
- type: DataTypes.ENUM("ww", "mix"),
45
- allowNull: true,
46
- comment:
47
- "Computed: ww (has WW), mix (multiple countries without WW), or NULL (single country)",
48
- },
49
-
50
- // Campaign identifiers
51
- feed_campaign_id: {
52
- type: DataTypes.STRING,
53
- allowNull: true,
54
- },
55
- facebook_campaign_id: {
56
- type: DataTypes.STRING,
57
- allowNull: true,
58
- },
59
- campaign_name: {
60
- type: DataTypes.STRING(255),
61
- allowNull: true,
62
- },
63
- facebook_campaign_name: {
64
- type: DataTypes.STRING(255),
65
- allowNull: true,
66
- },
67
-
68
- // Feed & Provider
69
- feed_provider: {
70
- type: DataTypes.STRING(100),
71
- allowNull: true,
72
- },
73
- feed_name: {
74
- type: DataTypes.STRING(100),
75
- allowNull: true,
76
- comment: "Display name (e.g., 'predicto.ai' -> 'Predicto')",
77
- },
78
-
79
- // User & Account
80
- media_buyer: {
81
- type: DataTypes.STRING(100),
82
- allowNull: true,
83
- },
84
- assignee: {
85
- type: DataTypes.STRING(100),
86
- allowNull: true,
87
- },
88
- user_name: {
89
- type: DataTypes.STRING(100),
90
- allowNull: true,
91
- comment: "Full name from user mapping",
92
- },
93
- account_id: {
94
- type: DataTypes.STRING(100),
95
- allowNull: true,
96
- },
97
- account_name: {
98
- type: DataTypes.STRING(255),
99
- allowNull: true,
100
- comment: "From AdAccount table",
101
- },
102
-
103
- // Campaign metadata
104
- vertical: {
105
- type: DataTypes.STRING(100),
106
- allowNull: true,
107
- },
108
- platform: {
109
- type: DataTypes.STRING(50),
110
- allowNull: true,
111
- },
112
- language: {
113
- type: DataTypes.STRING(50),
114
- allowNull: true,
115
- },
116
- domain: {
117
- type: DataTypes.STRING(255),
118
- allowNull: true,
119
- },
120
-
121
- // Keywords & Content
122
- keywords: {
123
- type: DataTypes.ARRAY(DataTypes.TEXT),
124
- allowNull: true,
125
- },
126
- main_keyword: {
127
- type: DataTypes.STRING(255),
128
- allowNull: true,
129
- },
130
- article_style: {
131
- type: DataTypes.STRING(50),
132
- allowNull: true,
133
- comment: "black, blue, green, white",
134
- },
135
- ads_category: {
136
- type: DataTypes.STRING(10),
137
- allowNull: true,
138
- comment: "l (Low), m (Medium), h (High)",
139
- },
140
- ad_title: {
141
- type: DataTypes.STRING(500),
142
- allowNull: true,
143
- },
144
- notes: {
145
- type: DataTypes.TEXT,
146
- allowNull: true,
147
- },
148
- free_text: {
149
- type: DataTypes.TEXT,
150
- allowNull: true,
151
- },
152
-
153
- // Facebook Campaign Settings
154
- pixel_id: {
155
- type: DataTypes.STRING(100),
156
- allowNull: true,
157
- },
158
- pixel_name: {
159
- type: DataTypes.STRING(255),
160
- allowNull: true,
161
- },
162
- pixel_event: {
163
- type: DataTypes.STRING(50),
164
- allowNull: true,
165
- },
166
- bid_strategy: {
167
- type: DataTypes.STRING(100),
168
- allowNull: true,
169
- },
170
- daily_budget: {
171
- type: DataTypes.DECIMAL(10, 2),
172
- allowNull: true,
173
- },
174
- bid_amount: {
175
- type: DataTypes.DECIMAL(10, 2),
176
- allowNull: true,
177
- },
178
- optimization_goal: {
179
- type: DataTypes.STRING(100),
180
- allowNull: true,
181
- },
182
- special_ad_categories: {
183
- type: DataTypes.ARRAY(DataTypes.TEXT),
184
- allowNull: true,
185
- comment: "Array of categories (CREDIT, HOUSING, EMPLOYMENT)",
186
- },
187
-
188
- // Page info
189
- page_id: {
190
- type: DataTypes.UUID,
191
- allowNull: true,
192
- },
193
- page_code: {
194
- type: DataTypes.STRING(100),
195
- allowNull: true,
196
- },
197
- page_name: {
198
- type: DataTypes.STRING(255),
199
- allowNull: true,
200
- },
201
-
202
- // Article/Content
203
- agrs_aid: {
204
- type: DataTypes.STRING(255),
205
- allowNull: true,
206
- comment: "Article ID",
207
- },
208
- article_id: {
209
- type: DataTypes.STRING(255),
210
- allowNull: true,
211
- comment: "For Mine/Predicto feeds",
212
- },
213
-
214
- // Error handling
215
- error_message: {
216
- type: DataTypes.TEXT,
217
- allowNull: true,
218
- },
219
- error_user_title: {
220
- type: DataTypes.STRING(255),
221
- allowNull: true,
222
- },
223
- error_code: {
224
- type: DataTypes.STRING(50),
225
- allowNull: true,
226
- },
227
- error_subcode: {
228
- type: DataTypes.STRING(50),
229
- allowNull: true,
230
- },
231
-
232
- // JSON fields for backward compatibility
233
- details: {
234
- type: DataTypes.JSONB,
235
- allowNull: true,
236
- comment: "For backward compatibility and complex nested data",
237
- },
238
- original_request_data: {
239
- type: DataTypes.JSONB,
240
- allowNull: true,
241
- comment: "Full original request for reference",
242
- },
243
- facebook_response: {
244
- type: DataTypes.JSONB,
245
- allowNull: true,
246
- comment: "Facebook API response",
247
- },
248
- },
249
- {
250
- tableName: "CampaignCreationLogsV2",
251
- timestamps: true,
252
- createdAt: "created_at",
253
- updatedAt: "updated_at",
254
- indexes: [
255
- { fields: ["original_log_id"], unique: true }, // Prevent duplicate V1 logs
256
- { fields: ["process_id"] },
257
- { fields: ["status"] },
258
- { fields: ["country"] },
259
- { fields: ["countries"], using: "gin" },
260
- { fields: ["country_type"] },
261
- { fields: ["feed_provider"] },
262
- { fields: ["media_buyer"] },
263
- { fields: ["account_id"] },
264
- { fields: ["vertical"] },
265
- { fields: ["keywords"], using: "gin" },
266
- { fields: [{ name: "created_at", order: "DESC" }] },
267
- {
268
- fields: [
269
- "process_id",
270
- "status",
271
- { name: "created_at", order: "DESC" },
272
- ],
273
- },
274
- { fields: ["status", "country"] },
275
- { fields: ["feed_provider", "status"] },
276
- { fields: ["media_buyer", "status"] },
277
- { fields: ["account_id", "status"] },
278
- { fields: ["vertical", "feed_provider"] },
279
- { fields: ["details"], using: "gin" },
280
- ],
281
- }
282
- );
283
-
284
- CampaignCreationLogV2.associate = (models) => {
285
- if (models.CampaignCreationLog) {
286
- CampaignCreationLogV2.belongsTo(models.CampaignCreationLog, {
287
- foreignKey: "process_id",
288
- targetKey: "process_id",
289
- as: "OriginalLog",
290
- constraints: false,
291
- });
292
- }
293
-
294
- if (models.AdAccount) {
295
- CampaignCreationLogV2.belongsTo(models.AdAccount, {
296
- foreignKey: "account_id",
297
- targetKey: "AdAccountID",
298
- as: "Account",
299
- constraints: false,
300
- });
301
- }
302
-
303
- if (models.Pages) {
304
- CampaignCreationLogV2.belongsTo(models.Pages, {
305
- foreignKey: "page_code",
306
- targetKey: "code",
307
- as: "Page",
308
- constraints: false,
309
- });
310
- }
311
- };
312
-
313
- return CampaignCreationLogV2;
314
- };
1
+ // models/CampaignCreationLogV2.js
2
+ module.exports = (sequelize, DataTypes) => {
3
+ const CampaignCreationLogV2 = sequelize.define(
4
+ "CampaignCreationLogV2",
5
+ {
6
+ id: {
7
+ type: DataTypes.INTEGER,
8
+ primaryKey: true,
9
+ autoIncrement: true,
10
+ },
11
+ original_log_id: {
12
+ type: DataTypes.INTEGER,
13
+ allowNull: true,
14
+ unique: true,
15
+ comment: "ID from CampaignCreationLog (V1) - prevents duplicates",
16
+ },
17
+ process_id: {
18
+ type: DataTypes.UUID,
19
+ allowNull: false,
20
+ comment: "Unique ID for the creation batch process",
21
+ },
22
+ status: {
23
+ type: DataTypes.ENUM(
24
+ "STARTED",
25
+ "IN_PROGRESS",
26
+ "COMPLETED",
27
+ "FAILED",
28
+ "PARTIALLY_COMPLETED"
29
+ ),
30
+ allowNull: false,
31
+ defaultValue: "STARTED",
32
+ },
33
+
34
+ // Location & Targeting
35
+ country: {
36
+ type: DataTypes.TEXT,
37
+ allowNull: true,
38
+ },
39
+ countries: {
40
+ type: DataTypes.ARRAY(DataTypes.TEXT),
41
+ allowNull: true,
42
+ },
43
+ country_type: {
44
+ type: DataTypes.ENUM("ww", "mix"),
45
+ allowNull: true,
46
+ comment:
47
+ "Computed: ww (has WW), mix (multiple countries without WW), or NULL (single country)",
48
+ },
49
+
50
+ // Campaign identifiers
51
+ feed_campaign_id: {
52
+ type: DataTypes.STRING,
53
+ allowNull: true,
54
+ },
55
+ facebook_campaign_id: {
56
+ type: DataTypes.STRING,
57
+ allowNull: true,
58
+ },
59
+ campaign_name: {
60
+ type: DataTypes.STRING(255),
61
+ allowNull: true,
62
+ },
63
+ facebook_campaign_name: {
64
+ type: DataTypes.STRING(255),
65
+ allowNull: true,
66
+ },
67
+
68
+ // Feed & Provider
69
+ feed_provider: {
70
+ type: DataTypes.STRING(100),
71
+ allowNull: true,
72
+ },
73
+ feed_name: {
74
+ type: DataTypes.STRING(100),
75
+ allowNull: true,
76
+ comment: "Display name (e.g., 'predicto.ai' -> 'Predicto')",
77
+ },
78
+
79
+ // User & Account
80
+ media_buyer: {
81
+ type: DataTypes.STRING(100),
82
+ allowNull: true,
83
+ },
84
+ assignee: {
85
+ type: DataTypes.STRING(100),
86
+ allowNull: true,
87
+ },
88
+ user_name: {
89
+ type: DataTypes.STRING(100),
90
+ allowNull: true,
91
+ comment: "Full name from user mapping",
92
+ },
93
+ account_id: {
94
+ type: DataTypes.STRING(100),
95
+ allowNull: true,
96
+ },
97
+ account_name: {
98
+ type: DataTypes.STRING(255),
99
+ allowNull: true,
100
+ comment: "From AdAccount table",
101
+ },
102
+
103
+ // Campaign metadata
104
+ vertical: {
105
+ type: DataTypes.STRING(100),
106
+ allowNull: true,
107
+ },
108
+ platform: {
109
+ type: DataTypes.STRING(50),
110
+ allowNull: true,
111
+ },
112
+ language: {
113
+ type: DataTypes.STRING(50),
114
+ allowNull: true,
115
+ },
116
+ domain: {
117
+ type: DataTypes.STRING(255),
118
+ allowNull: true,
119
+ },
120
+
121
+ // Keywords & Content
122
+ keywords: {
123
+ type: DataTypes.ARRAY(DataTypes.TEXT),
124
+ allowNull: true,
125
+ },
126
+ main_keyword: {
127
+ type: DataTypes.STRING(255),
128
+ allowNull: true,
129
+ },
130
+ article_style: {
131
+ type: DataTypes.STRING(50),
132
+ allowNull: true,
133
+ comment: "black, blue, green, white",
134
+ },
135
+ ads_category: {
136
+ type: DataTypes.STRING(10),
137
+ allowNull: true,
138
+ comment: "l (Low), m (Medium), h (High)",
139
+ },
140
+ ad_title: {
141
+ type: DataTypes.STRING(500),
142
+ allowNull: true,
143
+ },
144
+ notes: {
145
+ type: DataTypes.TEXT,
146
+ allowNull: true,
147
+ },
148
+ free_text: {
149
+ type: DataTypes.TEXT,
150
+ allowNull: true,
151
+ },
152
+
153
+ // Facebook Campaign Settings
154
+ pixel_id: {
155
+ type: DataTypes.STRING(100),
156
+ allowNull: true,
157
+ },
158
+ pixel_name: {
159
+ type: DataTypes.STRING(255),
160
+ allowNull: true,
161
+ },
162
+ pixel_event: {
163
+ type: DataTypes.STRING(50),
164
+ allowNull: true,
165
+ },
166
+ bid_strategy: {
167
+ type: DataTypes.STRING(100),
168
+ allowNull: true,
169
+ },
170
+ daily_budget: {
171
+ type: DataTypes.DECIMAL(10, 2),
172
+ allowNull: true,
173
+ },
174
+ bid_amount: {
175
+ type: DataTypes.DECIMAL(10, 2),
176
+ allowNull: true,
177
+ },
178
+ optimization_goal: {
179
+ type: DataTypes.STRING(100),
180
+ allowNull: true,
181
+ },
182
+ special_ad_categories: {
183
+ type: DataTypes.ARRAY(DataTypes.TEXT),
184
+ allowNull: true,
185
+ comment: "Array of categories (CREDIT, HOUSING, EMPLOYMENT)",
186
+ },
187
+
188
+ // Page info
189
+ page_id: {
190
+ type: DataTypes.UUID,
191
+ allowNull: true,
192
+ },
193
+ page_code: {
194
+ type: DataTypes.STRING(100),
195
+ allowNull: true,
196
+ },
197
+ page_name: {
198
+ type: DataTypes.STRING(255),
199
+ allowNull: true,
200
+ },
201
+
202
+ // Article/Content
203
+ agrs_aid: {
204
+ type: DataTypes.STRING(255),
205
+ allowNull: true,
206
+ comment: "Article ID",
207
+ },
208
+ article_id: {
209
+ type: DataTypes.STRING(255),
210
+ allowNull: true,
211
+ comment: "For Mine/Predicto feeds",
212
+ },
213
+
214
+ // Error handling
215
+ error_message: {
216
+ type: DataTypes.TEXT,
217
+ allowNull: true,
218
+ },
219
+ error_user_title: {
220
+ type: DataTypes.STRING(255),
221
+ allowNull: true,
222
+ },
223
+ error_code: {
224
+ type: DataTypes.STRING(50),
225
+ allowNull: true,
226
+ },
227
+ error_subcode: {
228
+ type: DataTypes.STRING(50),
229
+ allowNull: true,
230
+ },
231
+
232
+ // JSON fields for backward compatibility
233
+ details: {
234
+ type: DataTypes.JSONB,
235
+ allowNull: true,
236
+ comment: "For backward compatibility and complex nested data",
237
+ },
238
+ original_request_data: {
239
+ type: DataTypes.JSONB,
240
+ allowNull: true,
241
+ comment: "Full original request for reference",
242
+ },
243
+ facebook_response: {
244
+ type: DataTypes.JSONB,
245
+ allowNull: true,
246
+ comment: "Facebook API response",
247
+ },
248
+ },
249
+ {
250
+ tableName: "CampaignCreationLogsV2",
251
+ timestamps: true,
252
+ createdAt: "created_at",
253
+ updatedAt: "updated_at",
254
+ indexes: [
255
+ { fields: ["original_log_id"], unique: true }, // Prevent duplicate V1 logs
256
+ { fields: ["process_id"] },
257
+ { fields: ["status"] },
258
+ { fields: ["country"] },
259
+ { fields: ["countries"], using: "gin" },
260
+ { fields: ["country_type"] },
261
+ { fields: ["feed_provider"] },
262
+ { fields: ["media_buyer"] },
263
+ { fields: ["account_id"] },
264
+ { fields: ["vertical"] },
265
+ { fields: ["keywords"], using: "gin" },
266
+ { fields: [{ name: "created_at", order: "DESC" }] },
267
+ {
268
+ fields: [
269
+ "process_id",
270
+ "status",
271
+ { name: "created_at", order: "DESC" },
272
+ ],
273
+ },
274
+ { fields: ["status", "country"] },
275
+ { fields: ["feed_provider", "status"] },
276
+ { fields: ["media_buyer", "status"] },
277
+ { fields: ["account_id", "status"] },
278
+ { fields: ["vertical", "feed_provider"] },
279
+ { fields: ["details"], using: "gin" },
280
+ ],
281
+ }
282
+ );
283
+
284
+ CampaignCreationLogV2.associate = (models) => {
285
+ if (models.CampaignCreationLog) {
286
+ CampaignCreationLogV2.belongsTo(models.CampaignCreationLog, {
287
+ foreignKey: "process_id",
288
+ targetKey: "process_id",
289
+ as: "OriginalLog",
290
+ constraints: false,
291
+ });
292
+ }
293
+
294
+ if (models.AdAccount) {
295
+ CampaignCreationLogV2.belongsTo(models.AdAccount, {
296
+ foreignKey: "account_id",
297
+ targetKey: "AdAccountID",
298
+ as: "Account",
299
+ constraints: false,
300
+ });
301
+ }
302
+
303
+ if (models.Pages) {
304
+ CampaignCreationLogV2.belongsTo(models.Pages, {
305
+ foreignKey: "page_code",
306
+ targetKey: "code",
307
+ as: "Page",
308
+ constraints: false,
309
+ });
310
+ }
311
+ };
312
+
313
+ return CampaignCreationLogV2;
314
+ };