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