agrs-sequelize-sdk 1.1.63 → 1.1.65
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.
- package/models/Ad.js +38 -4
- package/models/AdAccountValues.js +25 -25
- package/models/AdHistory.js +30 -30
- package/models/AdSetHistory.js +30 -30
- package/models/AdsetPerformance.js +111 -111
- package/models/Article.js +131 -131
- package/models/Buyers.js +25 -25
- package/models/CampaignHistory.js +33 -33
- package/models/Channel.js +55 -55
- package/models/Domain.js +25 -25
- package/models/Feed.js +33 -33
- package/models/Pages.js +73 -73
- package/models/PipelineExecution.js +46 -46
- package/models/RSOCFeedCampaign.js +293 -293
- package/models/RulesValues.js +56 -56
- package/models/Vertical.js +25 -25
- package/models/newFiles.js +68 -68
- package/package.json +19 -21
- package/run.sh +214 -214
package/models/Ad.js
CHANGED
|
@@ -128,15 +128,38 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
128
128
|
}
|
|
129
129
|
);
|
|
130
130
|
|
|
131
|
+
// Ad.associate = (models) => {
|
|
132
|
+
// Ad.belongsTo(models.AdSet, { foreignKey: "AdSetID" });
|
|
133
|
+
|
|
134
|
+
// // Association with CodefuelCampaign using AGRS_CID
|
|
135
|
+
// Ad.belongsTo(models.CodefuelCampaign, {
|
|
136
|
+
// foreignKey: "AGRS_CID",
|
|
137
|
+
// targetKey: "AGRSCID",
|
|
138
|
+
// as: "CodefuelCampaign",
|
|
139
|
+
// constraints: false, // Disable FK constraint at the DB level
|
|
140
|
+
// });
|
|
141
|
+
|
|
142
|
+
// Ad.hasMany(models.AdPerformance, {
|
|
143
|
+
// foreignKey: "AdID",
|
|
144
|
+
// });
|
|
145
|
+
// };
|
|
146
|
+
|
|
131
147
|
Ad.associate = (models) => {
|
|
132
148
|
Ad.belongsTo(models.AdSet, { foreignKey: "AdSetID" });
|
|
133
149
|
|
|
134
|
-
//
|
|
150
|
+
// Add a dynamic relationship that supports either CodefuelCampaign or RSOCFeedCampaign
|
|
135
151
|
Ad.belongsTo(models.CodefuelCampaign, {
|
|
136
152
|
foreignKey: "AGRS_CID",
|
|
137
153
|
targetKey: "AGRSCID",
|
|
138
154
|
as: "CodefuelCampaign",
|
|
139
|
-
constraints: false,
|
|
155
|
+
constraints: false,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
Ad.belongsTo(models.RSOCFeedCampaign, {
|
|
159
|
+
foreignKey: "AGRS_CID",
|
|
160
|
+
targetKey: "AGRS_CID",
|
|
161
|
+
as: "RSOCFeedCampaign",
|
|
162
|
+
constraints: false,
|
|
140
163
|
});
|
|
141
164
|
|
|
142
165
|
Ad.hasMany(models.AdPerformance, {
|
|
@@ -170,9 +193,20 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
170
193
|
};
|
|
171
194
|
}
|
|
172
195
|
|
|
196
|
+
// do the same with RSOCFeedCampaign
|
|
197
|
+
const rsocFeedCampaign = await sequelize.models.RSOCFeedCampaign.findOne({
|
|
198
|
+
where: { AGRS_CID: this.AGRS_CID },
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
if (rsocFeedCampaign) {
|
|
202
|
+
return {
|
|
203
|
+
type: "RSOCFeedCampaign",
|
|
204
|
+
data: rsocFeedCampaign,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
173
207
|
return null;
|
|
174
208
|
};
|
|
175
|
-
|
|
209
|
+
|
|
176
210
|
Ad.addHook("afterCreate", async (ad, options) => {
|
|
177
211
|
if (ad.publish === false) {
|
|
178
212
|
// If publish is false on creation, save a snapshot to AdHistory
|
|
@@ -182,7 +216,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
182
216
|
});
|
|
183
217
|
}
|
|
184
218
|
});
|
|
185
|
-
|
|
219
|
+
|
|
186
220
|
Ad.addHook("beforeUpdate", async (ad, options) => {
|
|
187
221
|
if (ad.changed("publish")) {
|
|
188
222
|
if (ad.previous("publish") === true && ad.publish === false) {
|
|
@@ -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
|
};
|
package/models/AdHistory.js
CHANGED
|
@@ -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
|
+
};
|
package/models/AdSetHistory.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const AdSetHistory = sequelize.define(
|
|
3
|
-
"AdSetHistory",
|
|
4
|
-
{
|
|
5
|
-
HistoryID: {
|
|
6
|
-
type: DataTypes.UUID,
|
|
7
|
-
defaultValue: DataTypes.UUIDV4,
|
|
8
|
-
primaryKey: true,
|
|
9
|
-
},
|
|
10
|
-
AdSetID: {
|
|
11
|
-
type: DataTypes.STRING,
|
|
12
|
-
allowNull: false,
|
|
13
|
-
},
|
|
14
|
-
DataSnapshot: {
|
|
15
|
-
type: DataTypes.JSONB, // Store the full AdSet row as a JSON object
|
|
16
|
-
allowNull: false,
|
|
17
|
-
},
|
|
18
|
-
timestamp: {
|
|
19
|
-
type: DataTypes.DATE,
|
|
20
|
-
defaultValue: DataTypes.NOW,
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
tableName: "AdSetHistory",
|
|
25
|
-
timestamps: false,
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
return AdSetHistory;
|
|
30
|
-
};
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const AdSetHistory = sequelize.define(
|
|
3
|
+
"AdSetHistory",
|
|
4
|
+
{
|
|
5
|
+
HistoryID: {
|
|
6
|
+
type: DataTypes.UUID,
|
|
7
|
+
defaultValue: DataTypes.UUIDV4,
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
},
|
|
10
|
+
AdSetID: {
|
|
11
|
+
type: DataTypes.STRING,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
DataSnapshot: {
|
|
15
|
+
type: DataTypes.JSONB, // Store the full AdSet row as a JSON object
|
|
16
|
+
allowNull: false,
|
|
17
|
+
},
|
|
18
|
+
timestamp: {
|
|
19
|
+
type: DataTypes.DATE,
|
|
20
|
+
defaultValue: DataTypes.NOW,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
tableName: "AdSetHistory",
|
|
25
|
+
timestamps: false,
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
return AdSetHistory;
|
|
30
|
+
};
|
|
@@ -1,111 +1,111 @@
|
|
|
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
|
-
ExternalRevenue: {
|
|
58
|
-
type: DataTypes.FLOAT,
|
|
59
|
-
defaultValue: 0,
|
|
60
|
-
// Revenue data from an external source (e.g., analytics or monetization platforms)
|
|
61
|
-
},
|
|
62
|
-
ExternalImpressions: {
|
|
63
|
-
type: DataTypes.INTEGER,
|
|
64
|
-
defaultValue: 0,
|
|
65
|
-
// Number of impressions recorded by an external source
|
|
66
|
-
},
|
|
67
|
-
ExternalClicks: {
|
|
68
|
-
type: DataTypes.INTEGER,
|
|
69
|
-
defaultValue: 0,
|
|
70
|
-
// Number of clicks recorded by an external source
|
|
71
|
-
},
|
|
72
|
-
ExternalRequests: {
|
|
73
|
-
type: DataTypes.INTEGER,
|
|
74
|
-
defaultValue: 0,
|
|
75
|
-
// Number of requests recorded by an external source
|
|
76
|
-
},
|
|
77
|
-
ROI: {
|
|
78
|
-
type: DataTypes.FLOAT,
|
|
79
|
-
defaultValue: 0,
|
|
80
|
-
// Calculated Return on Investment (ExternalRevenue / Spend)
|
|
81
|
-
},
|
|
82
|
-
agrscid: {
|
|
83
|
-
type: DataTypes.STRING,
|
|
84
|
-
allowNull: true,
|
|
85
|
-
// Optional identifier for the AdSet, extracted from AdSet url if available
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
tableName: "AdSetPerformance",
|
|
90
|
-
timestamps: false, // No need for createdAt/updatedAt timestamps
|
|
91
|
-
indexes: [
|
|
92
|
-
{
|
|
93
|
-
unique: true,
|
|
94
|
-
fields: ["AdSetID", "Date"],
|
|
95
|
-
// Composite unique index to ensure one record per AdSet per date
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
// Define associations with other models
|
|
102
|
-
AdSetPerformance.associate = (models) => {
|
|
103
|
-
AdSetPerformance.belongsTo(models.AdSet, {
|
|
104
|
-
foreignKey: "AdSetID",
|
|
105
|
-
targetKey: "AdSetID",
|
|
106
|
-
// Links to the AdSet model for additional AdSet details
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
return AdSetPerformance;
|
|
111
|
-
};
|
|
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
|
+
ExternalRevenue: {
|
|
58
|
+
type: DataTypes.FLOAT,
|
|
59
|
+
defaultValue: 0,
|
|
60
|
+
// Revenue data from an external source (e.g., analytics or monetization platforms)
|
|
61
|
+
},
|
|
62
|
+
ExternalImpressions: {
|
|
63
|
+
type: DataTypes.INTEGER,
|
|
64
|
+
defaultValue: 0,
|
|
65
|
+
// Number of impressions recorded by an external source
|
|
66
|
+
},
|
|
67
|
+
ExternalClicks: {
|
|
68
|
+
type: DataTypes.INTEGER,
|
|
69
|
+
defaultValue: 0,
|
|
70
|
+
// Number of clicks recorded by an external source
|
|
71
|
+
},
|
|
72
|
+
ExternalRequests: {
|
|
73
|
+
type: DataTypes.INTEGER,
|
|
74
|
+
defaultValue: 0,
|
|
75
|
+
// Number of requests recorded by an external source
|
|
76
|
+
},
|
|
77
|
+
ROI: {
|
|
78
|
+
type: DataTypes.FLOAT,
|
|
79
|
+
defaultValue: 0,
|
|
80
|
+
// Calculated Return on Investment (ExternalRevenue / Spend)
|
|
81
|
+
},
|
|
82
|
+
agrscid: {
|
|
83
|
+
type: DataTypes.STRING,
|
|
84
|
+
allowNull: true,
|
|
85
|
+
// Optional identifier for the AdSet, extracted from AdSet url if available
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
tableName: "AdSetPerformance",
|
|
90
|
+
timestamps: false, // No need for createdAt/updatedAt timestamps
|
|
91
|
+
indexes: [
|
|
92
|
+
{
|
|
93
|
+
unique: true,
|
|
94
|
+
fields: ["AdSetID", "Date"],
|
|
95
|
+
// Composite unique index to ensure one record per AdSet per date
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
// Define associations with other models
|
|
102
|
+
AdSetPerformance.associate = (models) => {
|
|
103
|
+
AdSetPerformance.belongsTo(models.AdSet, {
|
|
104
|
+
foreignKey: "AdSetID",
|
|
105
|
+
targetKey: "AdSetID",
|
|
106
|
+
// Links to the AdSet model for additional AdSet details
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return AdSetPerformance;
|
|
111
|
+
};
|