agrs-sequelize-sdk 1.2.99 → 1.3.1

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 (47) hide show
  1. package/migrations/add-requested-from-dashboard-to-articles.js +17 -17
  2. package/models/AdAccountValues.js +25 -25
  3. package/models/AdHistory.js +30 -30
  4. package/models/AdPerformance.js +94 -94
  5. package/models/AdSet.js +289 -289
  6. package/models/AdSetHistory.js +30 -30
  7. package/models/AdsetPerformance.js +126 -126
  8. package/models/Article.js +190 -190
  9. package/models/AutomationRule.js +161 -127
  10. package/models/Buyers.js +25 -25
  11. package/models/Campaign.js +157 -157
  12. package/models/CampaignActionHistory.js +86 -86
  13. package/models/CampaignCreationLog.js +309 -309
  14. package/models/CampaignHistory.js +33 -33
  15. package/models/Channel.js +55 -55
  16. package/models/Domain.js +25 -25
  17. package/models/DynamicFeed.js +212 -212
  18. package/models/ExplorAdsChannel.js +61 -61
  19. package/models/Feed.js +33 -33
  20. package/models/FrontStoryChannel.js +59 -59
  21. package/models/MineChannel.js +42 -42
  22. package/models/Pages.js +81 -81
  23. package/models/PipelineExecution.js +59 -59
  24. package/models/Presets.js +34 -34
  25. package/models/RSOCFeedCampaign.js +357 -357
  26. package/models/RsocKeywordPerformance.js +110 -110
  27. package/models/RuleAction.js +90 -90
  28. package/models/RuleCondition.js +98 -98
  29. package/models/RuleExecution.js +107 -107
  30. package/models/RulesValues.js +56 -56
  31. package/models/SupportedLocale.js +23 -23
  32. package/models/SyncHistory.js +249 -249
  33. package/models/Tier2_AdAccounts.js +110 -110
  34. package/models/Tier2_Assets.js +70 -70
  35. package/models/Tier2_BusinessManagers.js +105 -105
  36. package/models/Tier2_CreditLines.js +99 -99
  37. package/models/Tier2_Pages.js +91 -91
  38. package/models/Tier2_Pixels.js +82 -82
  39. package/models/Tier2_Tokens.js +64 -64
  40. package/models/Tier2_UserAdAccounts.js +83 -83
  41. package/models/TokenRotationState.js +121 -121
  42. package/models/TonicRSOCKeywordPerformance.js +122 -122
  43. package/models/Vertical.js +25 -25
  44. package/models/newFiles.js +110 -110
  45. package/package.json +19 -21
  46. package/run.sh +214 -214
  47. package/services/sequelizeService.js +63 -63
@@ -1,126 +1,126 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const AdSetPerformance = sequelize.define(
3
- "AdSetPerformance",
4
- {
5
- AdSetID: {
6
- type: DataTypes.STRING,
7
- allowNull: false,
8
- primaryKey: true,
9
- // Part of the composite primary key identifying the AdSet
10
- },
11
- Date: {
12
- type: DataTypes.DATEONLY,
13
- allowNull: false,
14
- primaryKey: true,
15
- // Part of the composite primary key representing the performance date
16
- },
17
- ChannelID: {
18
- type: DataTypes.STRING,
19
- allowNull: true,
20
- // Optional identifier for the channel, extracted from AdSet name if available
21
- },
22
- StyleID: {
23
- type: DataTypes.STRING,
24
- allowNull: true,
25
- // Optional identifier for the style, extracted from AdSet name if available
26
- },
27
- Spend: {
28
- type: DataTypes.FLOAT,
29
- defaultValue: 0,
30
- // Total spend on the AdSet from the source platform (e.g., Facebook)
31
- },
32
- Impressions: {
33
- type: DataTypes.INTEGER,
34
- defaultValue: 0,
35
- // Number of impressions recorded by the source platform
36
- },
37
- LinkClicks: {
38
- type: DataTypes.INTEGER,
39
- defaultValue: 0,
40
- // Number of link clicks recorded by the source platform
41
- },
42
- ViewContent: {
43
- type: DataTypes.INTEGER,
44
- defaultValue: 0,
45
- // Number of view content events recorded by the source platform
46
- },
47
- Search: {
48
- type: DataTypes.INTEGER,
49
- defaultValue: 0,
50
- // Number of search events recorded by the source platform
51
- },
52
- Purchase: {
53
- type: DataTypes.INTEGER,
54
- defaultValue: 0,
55
- // Number of purchase events recorded by the source platform
56
- },
57
- Lead: {
58
- type: DataTypes.INTEGER,
59
- defaultValue: 0,
60
- // Number of lead events recorded by the source platform
61
- },
62
- ExternalRevenue: {
63
- type: DataTypes.FLOAT,
64
- defaultValue: 0,
65
- // Revenue data from an external source (e.g., analytics or monetization platforms)
66
- },
67
- ExternalImpressions: {
68
- type: DataTypes.INTEGER,
69
- defaultValue: 0,
70
- // Number of impressions recorded by an external source
71
- },
72
- ExternalClicks: {
73
- type: DataTypes.INTEGER,
74
- defaultValue: 0,
75
- // Number of clicks recorded by an external source
76
- },
77
- Sessions: {
78
- type: DataTypes.INTEGER,
79
- defaultValue: 0,
80
- // Number of website sessions/visits generated from this AdSet
81
- },
82
- ExternalRequests: {
83
- type: DataTypes.INTEGER,
84
- defaultValue: 0,
85
- // Number of requests recorded by an external source
86
- },
87
- ROI: {
88
- type: DataTypes.FLOAT,
89
- defaultValue: 0,
90
- // Calculated Return on Investment (ExternalRevenue / Spend)
91
- },
92
- agrscid: {
93
- type: DataTypes.STRING,
94
- allowNull: true,
95
- // Optional identifier for the AdSet, extracted from AdSet url if available
96
- },
97
- originalRevenue: {
98
- type: DataTypes.FLOAT,
99
- defaultValue: 0,
100
- // Original revenue value before any modifications or calculations
101
- }
102
- },
103
- {
104
- tableName: "AdSetPerformance",
105
- timestamps: false, // No need for createdAt/updatedAt timestamps
106
- indexes: [
107
- {
108
- unique: true,
109
- fields: ["AdSetID", "Date"],
110
- // Composite unique index to ensure one record per AdSet per date
111
- },
112
- ],
113
- }
114
- );
115
-
116
- // Define associations with other models
117
- AdSetPerformance.associate = (models) => {
118
- AdSetPerformance.belongsTo(models.AdSet, {
119
- foreignKey: "AdSetID",
120
- targetKey: "AdSetID",
121
- // Links to the AdSet model for additional AdSet details
122
- });
123
- };
124
-
125
- return AdSetPerformance;
126
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const AdSetPerformance = sequelize.define(
3
+ "AdSetPerformance",
4
+ {
5
+ AdSetID: {
6
+ type: DataTypes.STRING,
7
+ allowNull: false,
8
+ primaryKey: true,
9
+ // Part of the composite primary key identifying the AdSet
10
+ },
11
+ Date: {
12
+ type: DataTypes.DATEONLY,
13
+ allowNull: false,
14
+ primaryKey: true,
15
+ // Part of the composite primary key representing the performance date
16
+ },
17
+ ChannelID: {
18
+ type: DataTypes.STRING,
19
+ allowNull: true,
20
+ // Optional identifier for the channel, extracted from AdSet name if available
21
+ },
22
+ StyleID: {
23
+ type: DataTypes.STRING,
24
+ allowNull: true,
25
+ // Optional identifier for the style, extracted from AdSet name if available
26
+ },
27
+ Spend: {
28
+ type: DataTypes.FLOAT,
29
+ defaultValue: 0,
30
+ // Total spend on the AdSet from the source platform (e.g., Facebook)
31
+ },
32
+ Impressions: {
33
+ type: DataTypes.INTEGER,
34
+ defaultValue: 0,
35
+ // Number of impressions recorded by the source platform
36
+ },
37
+ LinkClicks: {
38
+ type: DataTypes.INTEGER,
39
+ defaultValue: 0,
40
+ // Number of link clicks recorded by the source platform
41
+ },
42
+ ViewContent: {
43
+ type: DataTypes.INTEGER,
44
+ defaultValue: 0,
45
+ // Number of view content events recorded by the source platform
46
+ },
47
+ Search: {
48
+ type: DataTypes.INTEGER,
49
+ defaultValue: 0,
50
+ // Number of search events recorded by the source platform
51
+ },
52
+ Purchase: {
53
+ type: DataTypes.INTEGER,
54
+ defaultValue: 0,
55
+ // Number of purchase events recorded by the source platform
56
+ },
57
+ Lead: {
58
+ type: DataTypes.INTEGER,
59
+ defaultValue: 0,
60
+ // Number of lead events recorded by the source platform
61
+ },
62
+ ExternalRevenue: {
63
+ type: DataTypes.FLOAT,
64
+ defaultValue: 0,
65
+ // Revenue data from an external source (e.g., analytics or monetization platforms)
66
+ },
67
+ ExternalImpressions: {
68
+ type: DataTypes.INTEGER,
69
+ defaultValue: 0,
70
+ // Number of impressions recorded by an external source
71
+ },
72
+ ExternalClicks: {
73
+ type: DataTypes.INTEGER,
74
+ defaultValue: 0,
75
+ // Number of clicks recorded by an external source
76
+ },
77
+ Sessions: {
78
+ type: DataTypes.INTEGER,
79
+ defaultValue: 0,
80
+ // Number of website sessions/visits generated from this AdSet
81
+ },
82
+ ExternalRequests: {
83
+ type: DataTypes.INTEGER,
84
+ defaultValue: 0,
85
+ // Number of requests recorded by an external source
86
+ },
87
+ ROI: {
88
+ type: DataTypes.FLOAT,
89
+ defaultValue: 0,
90
+ // Calculated Return on Investment (ExternalRevenue / Spend)
91
+ },
92
+ agrscid: {
93
+ type: DataTypes.STRING,
94
+ allowNull: true,
95
+ // Optional identifier for the AdSet, extracted from AdSet url if available
96
+ },
97
+ originalRevenue: {
98
+ type: DataTypes.FLOAT,
99
+ defaultValue: 0,
100
+ // Original revenue value before any modifications or calculations
101
+ }
102
+ },
103
+ {
104
+ tableName: "AdSetPerformance",
105
+ timestamps: false, // No need for createdAt/updatedAt timestamps
106
+ indexes: [
107
+ {
108
+ unique: true,
109
+ fields: ["AdSetID", "Date"],
110
+ // Composite unique index to ensure one record per AdSet per date
111
+ },
112
+ ],
113
+ }
114
+ );
115
+
116
+ // Define associations with other models
117
+ AdSetPerformance.associate = (models) => {
118
+ AdSetPerformance.belongsTo(models.AdSet, {
119
+ foreignKey: "AdSetID",
120
+ targetKey: "AdSetID",
121
+ // Links to the AdSet model for additional AdSet details
122
+ });
123
+ };
124
+
125
+ return AdSetPerformance;
126
+ };
package/models/Article.js CHANGED
@@ -1,190 +1,190 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const Article = sequelize.define(
3
- "Article",
4
- {
5
- providerId: {
6
- type: DataTypes.STRING,
7
- allowNull: true,
8
- unique: true,
9
- },
10
- keywordId: {
11
- type: DataTypes.STRING,
12
- allowNull: true,
13
- comment: "ID of the keyword from Predicto keywords API",
14
- },
15
- requestedFromDashboard: {
16
- type: DataTypes.BOOLEAN,
17
- allowNull: false,
18
- defaultValue: false,
19
- comment:
20
- "Indicates if the article was created through our dashboard (true) or imported from external sources (false)",
21
- },
22
- category: {
23
- type: DataTypes.STRING,
24
- allowNull: true,
25
- },
26
- AGRSAID: {
27
- type: DataTypes.STRING,
28
- allowNull: false,
29
- unique: true,
30
- },
31
- articleUrl: {
32
- type: DataTypes.STRING(1024),
33
- allowNull: true,
34
- },
35
- feed: {
36
- type: DataTypes.STRING,
37
- allowNull: false,
38
- },
39
- feedName: {
40
- type: DataTypes.STRING,
41
- allowNull: false,
42
- },
43
- vertical: {
44
- type: DataTypes.STRING,
45
- allowNull: false,
46
- },
47
- language: {
48
- type: DataTypes.STRING,
49
- allowNull: false,
50
- defaultValue: "en",
51
- },
52
- headline: {
53
- type: DataTypes.STRING(1000),
54
- allowNull: true,
55
- },
56
- topics: {
57
- type: DataTypes.ARRAY(DataTypes.STRING(1000)),
58
- allowNull: true,
59
- },
60
- translatedTopics: {
61
- type: DataTypes.ARRAY(DataTypes.STRING(1000)),
62
- allowNull: true,
63
- comment: "Topics translated to English for display purposes",
64
- },
65
- mainKeyword: {
66
- type: DataTypes.STRING,
67
- allowNull: true,
68
- },
69
- keywords: {
70
- type: DataTypes.ARRAY(DataTypes.STRING),
71
- allowNull: true,
72
- },
73
- date: {
74
- type: DataTypes.DATE,
75
- allowNull: true,
76
- defaultValue: DataTypes.NOW,
77
- },
78
- nativeKeyword: {
79
- type: DataTypes.STRING,
80
- allowNull: false,
81
- },
82
- suggestedKeywords: {
83
- type: DataTypes.STRING,
84
- allowNull: true,
85
- },
86
- articleExcerpt: {
87
- type: DataTypes.TEXT,
88
- allowNull: true,
89
- },
90
- articleContent: {
91
- type: DataTypes.TEXT,
92
- allowNull: true,
93
- },
94
- fbPixelId: {
95
- type: DataTypes.STRING,
96
- allowNull: true,
97
- },
98
- status: {
99
- type: DataTypes.STRING,
100
- allowNull: false,
101
- defaultValue: "pending",
102
- },
103
- originalStatus: {
104
- type: DataTypes.STRING,
105
- allowNull: true,
106
- comment: "Original status from Predicto before any mapping",
107
- },
108
- creationType: {
109
- type: DataTypes.STRING,
110
- allowNull: false,
111
- defaultValue: "slug",
112
- validate: {
113
- isIn: [["search", "slug", "manual-tonic"]],
114
- },
115
- },
116
- createdAt: {
117
- type: DataTypes.DATE,
118
- defaultValue: DataTypes.NOW,
119
- },
120
- updatedAt: {
121
- type: DataTypes.DATE,
122
- defaultValue: DataTypes.NOW,
123
- },
124
- buyer: {
125
- type: DataTypes.STRING,
126
- allowNull: true,
127
- },
128
- country: {
129
- type: DataTypes.STRING,
130
- allowNull: true,
131
- },
132
- name: {
133
- type: DataTypes.STRING,
134
- allowNull: true,
135
- },
136
- submittedToMine: {
137
- type: DataTypes.BOOLEAN,
138
- allowNull: true,
139
- defaultValue: false,
140
- comment: "Tracks if article has been submitted to Mine Marketing API in bulk migration"
141
- },
142
- submittedToMineAt: {
143
- type: DataTypes.DATE,
144
- allowNull: true,
145
- comment: "Timestamp when article was submitted to Mine Marketing"
146
- },
147
- contentType: {
148
- type: DataTypes.STRING,
149
- allowNull: true,
150
- defaultValue: 'generate',
151
- validate: {
152
- isIn: [['generate', 'import']]
153
- },
154
- comment: "Type of content: 'generate' for AI-generated or 'import' from URL"
155
- }
156
- },
157
- {
158
- tableName: "articles",
159
- timestamps: true,
160
- }
161
- );
162
-
163
- Article.associate = (models) => {
164
- Article.hasMany(models.RSOCFeedCampaign, {
165
- foreignKey: "AGRSAID",
166
- sourceKey: "AGRSAID",
167
- as: "RSOCFeedCampaigns",
168
- constraints: false,
169
- });
170
- };
171
-
172
- Article.prototype.isAvailableForCampaign = function () {
173
- return ["approved", "keyword_already_exists"].includes(this.status);
174
- };
175
-
176
- // NEW METHODS FOR URL STRUCTURE HANDLING
177
- Article.prototype.isUnifiedStructure = function () {
178
- return this.url_structure === "unified";
179
- };
180
-
181
- Article.prototype.getTargetDomain = function () {
182
- return this.target_domain || "sportfoy.com";
183
- };
184
-
185
- Article.prototype.isLegacyStructure = function () {
186
- return this.url_structure === "legacy";
187
- };
188
-
189
- return Article;
190
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const Article = sequelize.define(
3
+ "Article",
4
+ {
5
+ providerId: {
6
+ type: DataTypes.STRING,
7
+ allowNull: true,
8
+ unique: true,
9
+ },
10
+ keywordId: {
11
+ type: DataTypes.STRING,
12
+ allowNull: true,
13
+ comment: "ID of the keyword from Predicto keywords API",
14
+ },
15
+ requestedFromDashboard: {
16
+ type: DataTypes.BOOLEAN,
17
+ allowNull: false,
18
+ defaultValue: false,
19
+ comment:
20
+ "Indicates if the article was created through our dashboard (true) or imported from external sources (false)",
21
+ },
22
+ category: {
23
+ type: DataTypes.STRING,
24
+ allowNull: true,
25
+ },
26
+ AGRSAID: {
27
+ type: DataTypes.STRING,
28
+ allowNull: false,
29
+ unique: true,
30
+ },
31
+ articleUrl: {
32
+ type: DataTypes.STRING(1024),
33
+ allowNull: true,
34
+ },
35
+ feed: {
36
+ type: DataTypes.STRING,
37
+ allowNull: false,
38
+ },
39
+ feedName: {
40
+ type: DataTypes.STRING,
41
+ allowNull: false,
42
+ },
43
+ vertical: {
44
+ type: DataTypes.STRING,
45
+ allowNull: false,
46
+ },
47
+ language: {
48
+ type: DataTypes.STRING,
49
+ allowNull: false,
50
+ defaultValue: "en",
51
+ },
52
+ headline: {
53
+ type: DataTypes.STRING(1000),
54
+ allowNull: true,
55
+ },
56
+ topics: {
57
+ type: DataTypes.ARRAY(DataTypes.STRING(1000)),
58
+ allowNull: true,
59
+ },
60
+ translatedTopics: {
61
+ type: DataTypes.ARRAY(DataTypes.STRING(1000)),
62
+ allowNull: true,
63
+ comment: "Topics translated to English for display purposes",
64
+ },
65
+ mainKeyword: {
66
+ type: DataTypes.STRING,
67
+ allowNull: true,
68
+ },
69
+ keywords: {
70
+ type: DataTypes.ARRAY(DataTypes.STRING),
71
+ allowNull: true,
72
+ },
73
+ date: {
74
+ type: DataTypes.DATE,
75
+ allowNull: true,
76
+ defaultValue: DataTypes.NOW,
77
+ },
78
+ nativeKeyword: {
79
+ type: DataTypes.STRING,
80
+ allowNull: false,
81
+ },
82
+ suggestedKeywords: {
83
+ type: DataTypes.STRING,
84
+ allowNull: true,
85
+ },
86
+ articleExcerpt: {
87
+ type: DataTypes.TEXT,
88
+ allowNull: true,
89
+ },
90
+ articleContent: {
91
+ type: DataTypes.TEXT,
92
+ allowNull: true,
93
+ },
94
+ fbPixelId: {
95
+ type: DataTypes.STRING,
96
+ allowNull: true,
97
+ },
98
+ status: {
99
+ type: DataTypes.STRING,
100
+ allowNull: false,
101
+ defaultValue: "pending",
102
+ },
103
+ originalStatus: {
104
+ type: DataTypes.STRING,
105
+ allowNull: true,
106
+ comment: "Original status from Predicto before any mapping",
107
+ },
108
+ creationType: {
109
+ type: DataTypes.STRING,
110
+ allowNull: false,
111
+ defaultValue: "slug",
112
+ validate: {
113
+ isIn: [["search", "slug", "manual-tonic"]],
114
+ },
115
+ },
116
+ createdAt: {
117
+ type: DataTypes.DATE,
118
+ defaultValue: DataTypes.NOW,
119
+ },
120
+ updatedAt: {
121
+ type: DataTypes.DATE,
122
+ defaultValue: DataTypes.NOW,
123
+ },
124
+ buyer: {
125
+ type: DataTypes.STRING,
126
+ allowNull: true,
127
+ },
128
+ country: {
129
+ type: DataTypes.STRING,
130
+ allowNull: true,
131
+ },
132
+ name: {
133
+ type: DataTypes.STRING,
134
+ allowNull: true,
135
+ },
136
+ submittedToMine: {
137
+ type: DataTypes.BOOLEAN,
138
+ allowNull: true,
139
+ defaultValue: false,
140
+ comment: "Tracks if article has been submitted to Mine Marketing API in bulk migration"
141
+ },
142
+ submittedToMineAt: {
143
+ type: DataTypes.DATE,
144
+ allowNull: true,
145
+ comment: "Timestamp when article was submitted to Mine Marketing"
146
+ },
147
+ contentType: {
148
+ type: DataTypes.STRING,
149
+ allowNull: true,
150
+ defaultValue: 'generate',
151
+ validate: {
152
+ isIn: [['generate', 'import']]
153
+ },
154
+ comment: "Type of content: 'generate' for AI-generated or 'import' from URL"
155
+ }
156
+ },
157
+ {
158
+ tableName: "articles",
159
+ timestamps: true,
160
+ }
161
+ );
162
+
163
+ Article.associate = (models) => {
164
+ Article.hasMany(models.RSOCFeedCampaign, {
165
+ foreignKey: "AGRSAID",
166
+ sourceKey: "AGRSAID",
167
+ as: "RSOCFeedCampaigns",
168
+ constraints: false,
169
+ });
170
+ };
171
+
172
+ Article.prototype.isAvailableForCampaign = function () {
173
+ return ["approved", "keyword_already_exists"].includes(this.status);
174
+ };
175
+
176
+ // NEW METHODS FOR URL STRUCTURE HANDLING
177
+ Article.prototype.isUnifiedStructure = function () {
178
+ return this.url_structure === "unified";
179
+ };
180
+
181
+ Article.prototype.getTargetDomain = function () {
182
+ return this.target_domain || "sportfoy.com";
183
+ };
184
+
185
+ Article.prototype.isLegacyStructure = function () {
186
+ return this.url_structure === "legacy";
187
+ };
188
+
189
+ return Article;
190
+ };