agrs-sequelize-sdk 1.2.39 → 1.2.42

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.
@@ -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,174 +1,179 @@
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
- category: {
11
- type: DataTypes.STRING,
12
- allowNull: true,
13
- },
14
- AGRSAID: {
15
- type: DataTypes.STRING,
16
- allowNull: false,
17
- unique: true,
18
- },
19
- articleUrl: {
20
- type: DataTypes.STRING(1024),
21
- allowNull: true,
22
- },
23
- feed: {
24
- type: DataTypes.STRING,
25
- allowNull: false,
26
- },
27
- feedName: {
28
- type: DataTypes.STRING,
29
- allowNull: false,
30
- },
31
- vertical: {
32
- type: DataTypes.STRING,
33
- allowNull: false,
34
- },
35
- language: {
36
- type: DataTypes.STRING,
37
- allowNull: false,
38
- defaultValue: "en",
39
- },
40
- headline: {
41
- type: DataTypes.STRING(1000),
42
- allowNull: true,
43
- },
44
- topics: {
45
- type: DataTypes.ARRAY(DataTypes.STRING(1000)),
46
- allowNull: true,
47
- },
48
- translatedTopics: {
49
- type: DataTypes.ARRAY(DataTypes.STRING(1000)),
50
- allowNull: true,
51
- comment: "Topics translated to English for display purposes",
52
- },
53
- mainKeyword: {
54
- type: DataTypes.STRING,
55
- allowNull: true,
56
- },
57
- keywords: {
58
- type: DataTypes.ARRAY(DataTypes.STRING),
59
- allowNull: true,
60
- },
61
- date: {
62
- type: DataTypes.DATE,
63
- allowNull: true,
64
- defaultValue: DataTypes.NOW,
65
- },
66
- nativeKeyword: {
67
- type: DataTypes.STRING,
68
- allowNull: false,
69
- },
70
- suggestedKeywords: {
71
- type: DataTypes.STRING,
72
- allowNull: true,
73
- },
74
- articleExcerpt: {
75
- type: DataTypes.TEXT,
76
- allowNull: true,
77
- },
78
- articleContent: {
79
- type: DataTypes.TEXT,
80
- allowNull: true,
81
- },
82
- fbPixelId: {
83
- type: DataTypes.STRING,
84
- allowNull: true,
85
- },
86
- status: {
87
- type: DataTypes.STRING,
88
- allowNull: false,
89
- defaultValue: "pending",
90
- validate: {
91
- isIn: [
92
- [
93
- "pending",
94
- "approved",
95
- "rejected",
96
- "disapproved",
97
- "duplicated",
98
- "keyword_already_exists",
99
- "invalid_vertical",
100
- "invalid_language",
101
- "in_review",
102
- "error",
103
- ],
104
- ],
105
- },
106
- },
107
- originalStatus: {
108
- type: DataTypes.STRING,
109
- allowNull: true,
110
- comment: "Original status from Predicto before any mapping",
111
- },
112
- creationType: {
113
- type: DataTypes.STRING,
114
- allowNull: false,
115
- defaultValue: "slug",
116
- validate: {
117
- isIn: [["search", "slug", "manual-tonic"]],
118
- },
119
- },
120
- createdAt: {
121
- type: DataTypes.DATE,
122
- defaultValue: DataTypes.NOW,
123
- },
124
- updatedAt: {
125
- type: DataTypes.DATE,
126
- defaultValue: DataTypes.NOW,
127
- },
128
- buyer: {
129
- type: DataTypes.STRING,
130
- allowNull: true,
131
- },
132
- country: {
133
- type: DataTypes.STRING,
134
- allowNull: true,
135
- },
136
- name: {
137
- type: DataTypes.STRING,
138
- allowNull: true,
139
- },
140
- },
141
- {
142
- tableName: "articles",
143
- timestamps: true,
144
- }
145
- );
146
-
147
- Article.associate = (models) => {
148
- Article.hasMany(models.RSOCFeedCampaign, {
149
- foreignKey: "AGRSAID",
150
- sourceKey: "AGRSAID",
151
- as: "RSOCFeedCampaigns",
152
- constraints: false,
153
- });
154
- };
155
-
156
- Article.prototype.isAvailableForCampaign = function () {
157
- return ["approved", "keyword_already_exists"].includes(this.status);
158
- };
159
-
160
- // NEW METHODS FOR URL STRUCTURE HANDLING
161
- Article.prototype.isUnifiedStructure = function () {
162
- return this.url_structure === "unified";
163
- };
164
-
165
- Article.prototype.getTargetDomain = function () {
166
- return this.target_domain || "sportfoy.com";
167
- };
168
-
169
- Article.prototype.isLegacyStructure = function () {
170
- return this.url_structure === "legacy";
171
- };
172
-
173
- return Article;
174
- };
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
+ category: {
16
+ type: DataTypes.STRING,
17
+ allowNull: true,
18
+ },
19
+ AGRSAID: {
20
+ type: DataTypes.STRING,
21
+ allowNull: false,
22
+ unique: true,
23
+ },
24
+ articleUrl: {
25
+ type: DataTypes.STRING(1024),
26
+ allowNull: true,
27
+ },
28
+ feed: {
29
+ type: DataTypes.STRING,
30
+ allowNull: false,
31
+ },
32
+ feedName: {
33
+ type: DataTypes.STRING,
34
+ allowNull: false,
35
+ },
36
+ vertical: {
37
+ type: DataTypes.STRING,
38
+ allowNull: false,
39
+ },
40
+ language: {
41
+ type: DataTypes.STRING,
42
+ allowNull: false,
43
+ defaultValue: "en",
44
+ },
45
+ headline: {
46
+ type: DataTypes.STRING(1000),
47
+ allowNull: true,
48
+ },
49
+ topics: {
50
+ type: DataTypes.ARRAY(DataTypes.STRING(1000)),
51
+ allowNull: true,
52
+ },
53
+ translatedTopics: {
54
+ type: DataTypes.ARRAY(DataTypes.STRING(1000)),
55
+ allowNull: true,
56
+ comment: "Topics translated to English for display purposes",
57
+ },
58
+ mainKeyword: {
59
+ type: DataTypes.STRING,
60
+ allowNull: true,
61
+ },
62
+ keywords: {
63
+ type: DataTypes.ARRAY(DataTypes.STRING),
64
+ allowNull: true,
65
+ },
66
+ date: {
67
+ type: DataTypes.DATE,
68
+ allowNull: true,
69
+ defaultValue: DataTypes.NOW,
70
+ },
71
+ nativeKeyword: {
72
+ type: DataTypes.STRING,
73
+ allowNull: false,
74
+ },
75
+ suggestedKeywords: {
76
+ type: DataTypes.STRING,
77
+ allowNull: true,
78
+ },
79
+ articleExcerpt: {
80
+ type: DataTypes.TEXT,
81
+ allowNull: true,
82
+ },
83
+ articleContent: {
84
+ type: DataTypes.TEXT,
85
+ allowNull: true,
86
+ },
87
+ fbPixelId: {
88
+ type: DataTypes.STRING,
89
+ allowNull: true,
90
+ },
91
+ status: {
92
+ type: DataTypes.STRING,
93
+ allowNull: false,
94
+ defaultValue: "pending",
95
+ validate: {
96
+ isIn: [
97
+ [
98
+ "pending",
99
+ "approved",
100
+ "rejected",
101
+ "disapproved",
102
+ "duplicated",
103
+ "keyword_already_exists",
104
+ "invalid_vertical",
105
+ "invalid_language",
106
+ "in_review",
107
+ "error",
108
+ ],
109
+ ],
110
+ },
111
+ },
112
+ originalStatus: {
113
+ type: DataTypes.STRING,
114
+ allowNull: true,
115
+ comment: "Original status from Predicto before any mapping",
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
+ },
146
+ {
147
+ tableName: "articles",
148
+ timestamps: true,
149
+ }
150
+ );
151
+
152
+ Article.associate = (models) => {
153
+ Article.hasMany(models.RSOCFeedCampaign, {
154
+ foreignKey: "AGRSAID",
155
+ sourceKey: "AGRSAID",
156
+ as: "RSOCFeedCampaigns",
157
+ constraints: false,
158
+ });
159
+ };
160
+
161
+ Article.prototype.isAvailableForCampaign = function () {
162
+ return ["approved", "keyword_already_exists"].includes(this.status);
163
+ };
164
+
165
+ // NEW METHODS FOR URL STRUCTURE HANDLING
166
+ Article.prototype.isUnifiedStructure = function () {
167
+ return this.url_structure === "unified";
168
+ };
169
+
170
+ Article.prototype.getTargetDomain = function () {
171
+ return this.target_domain || "sportfoy.com";
172
+ };
173
+
174
+ Article.prototype.isLegacyStructure = function () {
175
+ return this.url_structure === "legacy";
176
+ };
177
+
178
+ return Article;
179
+ };
package/models/Buyers.js CHANGED
@@ -1,26 +1,26 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const Buyers = sequelize.define(
3
- "Buyers",
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: "Buyers",
22
- }
23
- );
24
-
25
- return Buyers;
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const Buyers = sequelize.define(
3
+ "Buyers",
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: "Buyers",
22
+ }
23
+ );
24
+
25
+ return Buyers;
26
26
  };