agrs-sequelize-sdk 1.2.12 → 1.2.14

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,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
+ };
@@ -1,84 +1,84 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const AdPerformance = sequelize.define(
3
- "AdPerformance",
4
- {
5
- Date: {
6
- type: DataTypes.DATEONLY,
7
- primaryKey: true,
8
- },
9
- AdID: {
10
- type: DataTypes.STRING,
11
- allowNull: false,
12
- primaryKey: true,
13
- },
14
- AmountSpent: {
15
- type: DataTypes.FLOAT,
16
- allowNull: true,
17
- },
18
- Impressions: {
19
- type: DataTypes.INTEGER,
20
- allowNull: true,
21
- },
22
- LinkClicks: {
23
- type: DataTypes.INTEGER,
24
- allowNull: true,
25
- },
26
- Revenue: {
27
- type: DataTypes.FLOAT,
28
- allowNull: true,
29
- },
30
- AdClicks: {
31
- type: DataTypes.INTEGER,
32
- allowNull: true,
33
- },
34
- Sessions: {
35
- type: DataTypes.INTEGER,
36
- allowNull: true,
37
- },
38
- ViewContent: {
39
- // New field
40
- type: DataTypes.INTEGER,
41
- allowNull: true,
42
- },
43
- Search: {
44
- // New field
45
- type: DataTypes.INTEGER,
46
- allowNull: true,
47
- },
48
- Purchase: {
49
- // New field
50
- type: DataTypes.INTEGER,
51
- allowNull: true,
52
- },
53
- originalSpend: {
54
- type: DataTypes.FLOAT,
55
- allowNull: true,
56
- },
57
- originRevenue: {
58
- type: DataTypes.FLOAT,
59
- allowNull: true,
60
- },
61
- },
62
- {
63
- tableName: "AdPerformance",
64
- indexes: [
65
- {
66
- unique: true,
67
- fields: ["AdID", "Date"], // Composite unique index
68
- },
69
- {
70
- fields: ["Date"], // Index on Date for faster range queries
71
- },
72
- {
73
- fields: ["AdID"], // Index on AdID for faster join
74
- },
75
- ],
76
- }
77
- );
78
-
79
- AdPerformance.associate = (models) => {
80
- AdPerformance.belongsTo(models.Ad, { foreignKey: "AdID" });
81
- };
82
-
83
- return AdPerformance;
84
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const AdPerformance = sequelize.define(
3
+ "AdPerformance",
4
+ {
5
+ Date: {
6
+ type: DataTypes.DATEONLY,
7
+ primaryKey: true,
8
+ },
9
+ AdID: {
10
+ type: DataTypes.STRING,
11
+ allowNull: false,
12
+ primaryKey: true,
13
+ },
14
+ AmountSpent: {
15
+ type: DataTypes.FLOAT,
16
+ allowNull: true,
17
+ },
18
+ Impressions: {
19
+ type: DataTypes.INTEGER,
20
+ allowNull: true,
21
+ },
22
+ LinkClicks: {
23
+ type: DataTypes.INTEGER,
24
+ allowNull: true,
25
+ },
26
+ Revenue: {
27
+ type: DataTypes.FLOAT,
28
+ allowNull: true,
29
+ },
30
+ AdClicks: {
31
+ type: DataTypes.INTEGER,
32
+ allowNull: true,
33
+ },
34
+ Sessions: {
35
+ type: DataTypes.INTEGER,
36
+ allowNull: true,
37
+ },
38
+ ViewContent: {
39
+ // New field
40
+ type: DataTypes.INTEGER,
41
+ allowNull: true,
42
+ },
43
+ Search: {
44
+ // New field
45
+ type: DataTypes.INTEGER,
46
+ allowNull: true,
47
+ },
48
+ Purchase: {
49
+ // New field
50
+ type: DataTypes.INTEGER,
51
+ allowNull: true,
52
+ },
53
+ originalSpend: {
54
+ type: DataTypes.FLOAT,
55
+ allowNull: true,
56
+ },
57
+ originRevenue: {
58
+ type: DataTypes.FLOAT,
59
+ allowNull: true,
60
+ },
61
+ },
62
+ {
63
+ tableName: "AdPerformance",
64
+ indexes: [
65
+ {
66
+ unique: true,
67
+ fields: ["AdID", "Date"], // Composite unique index
68
+ },
69
+ {
70
+ fields: ["Date"], // Index on Date for faster range queries
71
+ },
72
+ {
73
+ fields: ["AdID"], // Index on AdID for faster join
74
+ },
75
+ ],
76
+ }
77
+ );
78
+
79
+ AdPerformance.associate = (models) => {
80
+ AdPerformance.belongsTo(models.Ad, { foreignKey: "AdID" });
81
+ };
82
+
83
+ return AdPerformance;
84
+ };
@@ -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,116 +1,116 @@
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
- originalRevenue: {
88
- type: DataTypes.FLOAT,
89
- defaultValue: 0,
90
- // Original revenue value before any modifications or calculations
91
- }
92
- },
93
- {
94
- tableName: "AdSetPerformance",
95
- timestamps: false, // No need for createdAt/updatedAt timestamps
96
- indexes: [
97
- {
98
- unique: true,
99
- fields: ["AdSetID", "Date"],
100
- // Composite unique index to ensure one record per AdSet per date
101
- },
102
- ],
103
- }
104
- );
105
-
106
- // Define associations with other models
107
- AdSetPerformance.associate = (models) => {
108
- AdSetPerformance.belongsTo(models.AdSet, {
109
- foreignKey: "AdSetID",
110
- targetKey: "AdSetID",
111
- // Links to the AdSet model for additional AdSet details
112
- });
113
- };
114
-
115
- return AdSetPerformance;
116
- };
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
+ originalRevenue: {
88
+ type: DataTypes.FLOAT,
89
+ defaultValue: 0,
90
+ // Original revenue value before any modifications or calculations
91
+ }
92
+ },
93
+ {
94
+ tableName: "AdSetPerformance",
95
+ timestamps: false, // No need for createdAt/updatedAt timestamps
96
+ indexes: [
97
+ {
98
+ unique: true,
99
+ fields: ["AdSetID", "Date"],
100
+ // Composite unique index to ensure one record per AdSet per date
101
+ },
102
+ ],
103
+ }
104
+ );
105
+
106
+ // Define associations with other models
107
+ AdSetPerformance.associate = (models) => {
108
+ AdSetPerformance.belongsTo(models.AdSet, {
109
+ foreignKey: "AdSetID",
110
+ targetKey: "AdSetID",
111
+ // Links to the AdSet model for additional AdSet details
112
+ });
113
+ };
114
+
115
+ return AdSetPerformance;
116
+ };