agrs-sequelize-sdk 1.1.63 → 1.1.64
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 +13 -2
- 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
|
@@ -170,9 +170,20 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
// do the same with RSOCFeedCampaign
|
|
174
|
+
const rsocFeedCampaign = await sequelize.models.RSOCFeedCampaign.findOne({
|
|
175
|
+
where: { AGRS_CID: this.AGRS_CID },
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
if (rsocFeedCampaign) {
|
|
179
|
+
return {
|
|
180
|
+
type: "RSOCFeedCampaign",
|
|
181
|
+
data: rsocFeedCampaign,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
173
184
|
return null;
|
|
174
185
|
};
|
|
175
|
-
|
|
186
|
+
|
|
176
187
|
Ad.addHook("afterCreate", async (ad, options) => {
|
|
177
188
|
if (ad.publish === false) {
|
|
178
189
|
// If publish is false on creation, save a snapshot to AdHistory
|
|
@@ -182,7 +193,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
182
193
|
});
|
|
183
194
|
}
|
|
184
195
|
});
|
|
185
|
-
|
|
196
|
+
|
|
186
197
|
Ad.addHook("beforeUpdate", async (ad, options) => {
|
|
187
198
|
if (ad.changed("publish")) {
|
|
188
199
|
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
|
+
};
|