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
@@ -1,212 +1,212 @@
1
- /**
2
- * AI Generation Request Model
3
- *
4
- * Stores all AI generation requests (banners, text, etc.)
5
- * Replaces Google Sheets logging with database storage.
6
- */
7
-
8
- module.exports = (sequelize, DataTypes) => {
9
- const AIGenerationRequest = sequelize.define(
10
- "AIGenerationRequest",
11
- {
12
- id: {
13
- type: DataTypes.UUID,
14
- defaultValue: DataTypes.UUIDV4,
15
- primaryKey: true,
16
- },
17
- requestId: {
18
- type: DataTypes.STRING,
19
- allowNull: false,
20
- unique: true,
21
- comment: "Unique request identifier",
22
- },
23
- generatorType: {
24
- type: DataTypes.STRING,
25
- allowNull: false,
26
- defaultValue: "banner",
27
- comment: "Type of generator: banner, text, video, etc.",
28
- },
29
- // Request data
30
- requestText: {
31
- type: DataTypes.TEXT,
32
- allowNull: false,
33
- comment: "Original user request text",
34
- },
35
- hasReferenceImage: {
36
- type: DataTypes.BOOLEAN,
37
- allowNull: false,
38
- defaultValue: false,
39
- comment: "Whether reference image was provided",
40
- },
41
- referenceImageUrl: {
42
- type: DataTypes.STRING,
43
- allowNull: true,
44
- comment: "URL to reference image if provided",
45
- },
46
- // Parsed request data
47
- subject: {
48
- type: DataTypes.STRING,
49
- allowNull: true,
50
- comment: "Extracted subject from request",
51
- },
52
- language: {
53
- type: DataTypes.STRING,
54
- allowNull: true,
55
- comment: "Detected language",
56
- },
57
- styleDescription: {
58
- type: DataTypes.TEXT,
59
- allowNull: true,
60
- comment: "Style description from parsing",
61
- },
62
- bannerText: {
63
- type: DataTypes.TEXT,
64
- allowNull: true,
65
- comment: "Banner text to display",
66
- },
67
- visualElements: {
68
- type: DataTypes.TEXT,
69
- allowNull: true,
70
- comment: "Visual elements description",
71
- },
72
- // Generation prompts
73
- promptVersion1: {
74
- type: DataTypes.TEXT,
75
- allowNull: true,
76
- comment: "First prompt version",
77
- },
78
- promptVersion2: {
79
- type: DataTypes.TEXT,
80
- allowNull: true,
81
- comment: "Second prompt version",
82
- },
83
- promptVersion3: {
84
- type: DataTypes.TEXT,
85
- allowNull: true,
86
- comment: "Third prompt version",
87
- },
88
- // Storage info
89
- driveFolderId: {
90
- type: DataTypes.STRING,
91
- allowNull: true,
92
- comment: "Google Drive folder ID",
93
- },
94
- driveFolderName: {
95
- type: DataTypes.STRING,
96
- allowNull: true,
97
- comment: "Google Drive folder name",
98
- },
99
- driveFolderLink: {
100
- type: DataTypes.STRING,
101
- allowNull: true,
102
- comment: "Google Drive folder link",
103
- },
104
- // Generation results
105
- imagesTotal: {
106
- type: DataTypes.INTEGER,
107
- allowNull: false,
108
- defaultValue: 0,
109
- comment: "Total number of images generated",
110
- },
111
- imagesSuccessful: {
112
- type: DataTypes.INTEGER,
113
- allowNull: false,
114
- defaultValue: 0,
115
- comment: "Number of successfully generated images",
116
- },
117
- imagesFailed: {
118
- type: DataTypes.INTEGER,
119
- allowNull: false,
120
- defaultValue: 0,
121
- comment: "Number of failed image generations",
122
- },
123
- // Status
124
- status: {
125
- type: DataTypes.ENUM(
126
- "pending",
127
- "processing",
128
- "completed",
129
- "failed",
130
- "partial"
131
- ),
132
- allowNull: false,
133
- defaultValue: "pending",
134
- comment: "Request status",
135
- },
136
- errorMessage: {
137
- type: DataTypes.TEXT,
138
- allowNull: true,
139
- comment: "Error message if generation failed",
140
- },
141
- // Metadata
142
- user: {
143
- type: DataTypes.STRING,
144
- allowNull: true,
145
- comment: "User who made the request",
146
- },
147
- duration: {
148
- type: DataTypes.INTEGER,
149
- allowNull: true,
150
- comment: "Generation duration in milliseconds",
151
- },
152
- // Model info
153
- parsingModel: {
154
- type: DataTypes.STRING,
155
- allowNull: true,
156
- comment: "Model used for parsing",
157
- },
158
- promptModel: {
159
- type: DataTypes.STRING,
160
- allowNull: true,
161
- comment: "Model used for prompt generation",
162
- },
163
- imageModel: {
164
- type: DataTypes.STRING,
165
- allowNull: true,
166
- comment: "Model used for image generation",
167
- },
168
- },
169
- {
170
- tableName: "ai_generation_requests",
171
- timestamps: true,
172
- createdAt: "createdAt",
173
- updatedAt: "updatedAt",
174
- indexes: [
175
- {
176
- fields: ["requestId"],
177
- unique: true,
178
- },
179
- {
180
- fields: ["generatorType"],
181
- },
182
- {
183
- fields: ["status"],
184
- },
185
- {
186
- fields: ["createdAt"],
187
- },
188
- {
189
- fields: ["user"],
190
- },
191
- ],
192
- }
193
- );
194
-
195
- // Associations
196
- AIGenerationRequest.associate = function (models) {
197
- // One request has many logs
198
- AIGenerationRequest.hasMany(models.AIGenerationLog, {
199
- foreignKey: "requestId",
200
- sourceKey: "requestId",
201
- as: "logs",
202
- });
203
- // ✅ NEW: One request can have many generated files
204
- AIGenerationRequest.hasMany(models.NewFiles, {
205
- foreignKey: "generationRequestId",
206
- sourceKey: "requestId",
207
- as: "generatedFiles",
208
- });
209
- };
210
-
211
- return AIGenerationRequest;
212
- };
1
+ /**
2
+ * AI Generation Request Model
3
+ *
4
+ * Stores all AI generation requests (banners, text, etc.)
5
+ * Replaces Google Sheets logging with database storage.
6
+ */
7
+
8
+ module.exports = (sequelize, DataTypes) => {
9
+ const AIGenerationRequest = sequelize.define(
10
+ "AIGenerationRequest",
11
+ {
12
+ id: {
13
+ type: DataTypes.UUID,
14
+ defaultValue: DataTypes.UUIDV4,
15
+ primaryKey: true,
16
+ },
17
+ requestId: {
18
+ type: DataTypes.STRING,
19
+ allowNull: false,
20
+ unique: true,
21
+ comment: "Unique request identifier",
22
+ },
23
+ generatorType: {
24
+ type: DataTypes.STRING,
25
+ allowNull: false,
26
+ defaultValue: "banner",
27
+ comment: "Type of generator: banner, text, video, etc.",
28
+ },
29
+ // Request data
30
+ requestText: {
31
+ type: DataTypes.TEXT,
32
+ allowNull: false,
33
+ comment: "Original user request text",
34
+ },
35
+ hasReferenceImage: {
36
+ type: DataTypes.BOOLEAN,
37
+ allowNull: false,
38
+ defaultValue: false,
39
+ comment: "Whether reference image was provided",
40
+ },
41
+ referenceImageUrl: {
42
+ type: DataTypes.STRING,
43
+ allowNull: true,
44
+ comment: "URL to reference image if provided",
45
+ },
46
+ // Parsed request data
47
+ subject: {
48
+ type: DataTypes.STRING,
49
+ allowNull: true,
50
+ comment: "Extracted subject from request",
51
+ },
52
+ language: {
53
+ type: DataTypes.STRING,
54
+ allowNull: true,
55
+ comment: "Detected language",
56
+ },
57
+ styleDescription: {
58
+ type: DataTypes.TEXT,
59
+ allowNull: true,
60
+ comment: "Style description from parsing",
61
+ },
62
+ bannerText: {
63
+ type: DataTypes.TEXT,
64
+ allowNull: true,
65
+ comment: "Banner text to display",
66
+ },
67
+ visualElements: {
68
+ type: DataTypes.TEXT,
69
+ allowNull: true,
70
+ comment: "Visual elements description",
71
+ },
72
+ // Generation prompts
73
+ promptVersion1: {
74
+ type: DataTypes.TEXT,
75
+ allowNull: true,
76
+ comment: "First prompt version",
77
+ },
78
+ promptVersion2: {
79
+ type: DataTypes.TEXT,
80
+ allowNull: true,
81
+ comment: "Second prompt version",
82
+ },
83
+ promptVersion3: {
84
+ type: DataTypes.TEXT,
85
+ allowNull: true,
86
+ comment: "Third prompt version",
87
+ },
88
+ // Storage info
89
+ driveFolderId: {
90
+ type: DataTypes.STRING,
91
+ allowNull: true,
92
+ comment: "Google Drive folder ID",
93
+ },
94
+ driveFolderName: {
95
+ type: DataTypes.STRING,
96
+ allowNull: true,
97
+ comment: "Google Drive folder name",
98
+ },
99
+ driveFolderLink: {
100
+ type: DataTypes.STRING,
101
+ allowNull: true,
102
+ comment: "Google Drive folder link",
103
+ },
104
+ // Generation results
105
+ imagesTotal: {
106
+ type: DataTypes.INTEGER,
107
+ allowNull: false,
108
+ defaultValue: 0,
109
+ comment: "Total number of images generated",
110
+ },
111
+ imagesSuccessful: {
112
+ type: DataTypes.INTEGER,
113
+ allowNull: false,
114
+ defaultValue: 0,
115
+ comment: "Number of successfully generated images",
116
+ },
117
+ imagesFailed: {
118
+ type: DataTypes.INTEGER,
119
+ allowNull: false,
120
+ defaultValue: 0,
121
+ comment: "Number of failed image generations",
122
+ },
123
+ // Status
124
+ status: {
125
+ type: DataTypes.ENUM(
126
+ "pending",
127
+ "processing",
128
+ "completed",
129
+ "failed",
130
+ "partial"
131
+ ),
132
+ allowNull: false,
133
+ defaultValue: "pending",
134
+ comment: "Request status",
135
+ },
136
+ errorMessage: {
137
+ type: DataTypes.TEXT,
138
+ allowNull: true,
139
+ comment: "Error message if generation failed",
140
+ },
141
+ // Metadata
142
+ user: {
143
+ type: DataTypes.STRING,
144
+ allowNull: true,
145
+ comment: "User who made the request",
146
+ },
147
+ duration: {
148
+ type: DataTypes.INTEGER,
149
+ allowNull: true,
150
+ comment: "Generation duration in milliseconds",
151
+ },
152
+ // Model info
153
+ parsingModel: {
154
+ type: DataTypes.STRING,
155
+ allowNull: true,
156
+ comment: "Model used for parsing",
157
+ },
158
+ promptModel: {
159
+ type: DataTypes.STRING,
160
+ allowNull: true,
161
+ comment: "Model used for prompt generation",
162
+ },
163
+ imageModel: {
164
+ type: DataTypes.STRING,
165
+ allowNull: true,
166
+ comment: "Model used for image generation",
167
+ },
168
+ },
169
+ {
170
+ tableName: "ai_generation_requests",
171
+ timestamps: true,
172
+ createdAt: "createdAt",
173
+ updatedAt: "updatedAt",
174
+ indexes: [
175
+ {
176
+ fields: ["requestId"],
177
+ unique: true,
178
+ },
179
+ {
180
+ fields: ["generatorType"],
181
+ },
182
+ {
183
+ fields: ["status"],
184
+ },
185
+ {
186
+ fields: ["createdAt"],
187
+ },
188
+ {
189
+ fields: ["user"],
190
+ },
191
+ ],
192
+ }
193
+ );
194
+
195
+ // Associations
196
+ AIGenerationRequest.associate = function (models) {
197
+ // One request has many logs
198
+ AIGenerationRequest.hasMany(models.AIGenerationLog, {
199
+ foreignKey: "requestId",
200
+ sourceKey: "requestId",
201
+ as: "logs",
202
+ });
203
+ // ✅ NEW: One request can have many generated files
204
+ AIGenerationRequest.hasMany(models.NewFiles, {
205
+ foreignKey: "generationRequestId",
206
+ sourceKey: "requestId",
207
+ as: "generatedFiles",
208
+ });
209
+ };
210
+
211
+ return AIGenerationRequest;
212
+ };
package/models/Ad.js CHANGED
@@ -133,6 +133,12 @@ module.exports = (sequelize, DataTypes) => {
133
133
  type: DataTypes.BOOLEAN,
134
134
  defaultValue: false,
135
135
  },
136
+ platform: {
137
+ type: DataTypes.ENUM("fb", "tt", "snp"),
138
+ allowNull: false,
139
+ defaultValue: "fb",
140
+ comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
141
+ },
136
142
  },
137
143
  {
138
144
  tableName: "Ad",
@@ -66,6 +66,12 @@ module.exports = (sequelize, DataTypes) => {
66
66
  type: DataTypes.STRING,
67
67
  allowNull: true,
68
68
  },
69
+ platform: {
70
+ type: DataTypes.ENUM("fb", "tt", "snp"),
71
+ allowNull: false,
72
+ defaultValue: "fb",
73
+ comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
74
+ },
69
75
  },
70
76
  {
71
77
  tableName: "AdAccount",
@@ -1,26 +1,26 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const AdAccountValues = sequelize.define(
3
- "AdAccountValues",
4
- {
5
- id: {
6
- type: DataTypes.UUID,
7
- defaultValue: DataTypes.UUIDV4,
8
- primaryKey: true,
9
- },
10
- name: {
11
- type: DataTypes.STRING,
12
- allowNull: false,
13
- },
14
- code: {
15
- type: DataTypes.STRING,
16
- allowNull: false,
17
- unique: true,
18
- },
19
- },
20
- {
21
- tableName: "AdAccountValues",
22
- }
23
- );
24
-
25
- return AdAccountValues;
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const AdAccountValues = sequelize.define(
3
+ "AdAccountValues",
4
+ {
5
+ id: {
6
+ type: DataTypes.UUID,
7
+ defaultValue: DataTypes.UUIDV4,
8
+ primaryKey: true,
9
+ },
10
+ name: {
11
+ type: DataTypes.STRING,
12
+ allowNull: false,
13
+ },
14
+ code: {
15
+ type: DataTypes.STRING,
16
+ allowNull: false,
17
+ unique: true,
18
+ },
19
+ },
20
+ {
21
+ tableName: "AdAccountValues",
22
+ }
23
+ );
24
+
25
+ return AdAccountValues;
26
26
  };
@@ -1,30 +1,30 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const AdHistory = sequelize.define(
3
- "AdHistory",
4
- {
5
- HistoryID: {
6
- type: DataTypes.UUID,
7
- defaultValue: DataTypes.UUIDV4,
8
- primaryKey: true,
9
- },
10
- AdID: {
11
- type: DataTypes.STRING,
12
- allowNull: false,
13
- },
14
- DataSnapshot: {
15
- type: DataTypes.JSONB, // Store the full Ad row as a JSON object
16
- allowNull: false,
17
- },
18
- timestamp: {
19
- type: DataTypes.DATE,
20
- defaultValue: DataTypes.NOW,
21
- },
22
- },
23
- {
24
- tableName: "AdHistory",
25
- timestamps: false, // Disable Sequelize timestamps
26
- }
27
- );
28
-
29
- return AdHistory;
30
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const AdHistory = sequelize.define(
3
+ "AdHistory",
4
+ {
5
+ HistoryID: {
6
+ type: DataTypes.UUID,
7
+ defaultValue: DataTypes.UUIDV4,
8
+ primaryKey: true,
9
+ },
10
+ AdID: {
11
+ type: DataTypes.STRING,
12
+ allowNull: false,
13
+ },
14
+ DataSnapshot: {
15
+ type: DataTypes.JSONB, // Store the full Ad row as a JSON object
16
+ allowNull: false,
17
+ },
18
+ timestamp: {
19
+ type: DataTypes.DATE,
20
+ defaultValue: DataTypes.NOW,
21
+ },
22
+ },
23
+ {
24
+ tableName: "AdHistory",
25
+ timestamps: false, // Disable Sequelize timestamps
26
+ }
27
+ );
28
+
29
+ return AdHistory;
30
+ };