agrs-sequelize-sdk 1.1.37 → 1.1.39

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.
@@ -62,6 +62,10 @@ module.exports = (sequelize, DataTypes) => {
62
62
  type: DataTypes.BOOLEAN,
63
63
  allowNull: true,
64
64
  },
65
+ disabled_reason: {
66
+ type: DataTypes.STRING,
67
+ allowNull: true,
68
+ },
65
69
  },
66
70
  {
67
71
  tableName: "AdAccount",
@@ -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,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
+ };
@@ -0,0 +1,110 @@
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const Article = sequelize.define(
3
+ "Article",
4
+ {
5
+ id: {
6
+ type: DataTypes.INTEGER,
7
+ primaryKey: true,
8
+ autoIncrement: true,
9
+ },
10
+ AGRSAID: {
11
+ type: DataTypes.STRING,
12
+ allowNull: false,
13
+ unique: true,
14
+ },
15
+ articleUrl: {
16
+ type: DataTypes.STRING(1024),
17
+ allowNull: true,
18
+ comment: "Generated URL for the article",
19
+ },
20
+ feed: {
21
+ type: DataTypes.STRING,
22
+ allowNull: false,
23
+ comment: "e.g., RSOC, Tonic, Explorer, InMobi",
24
+ },
25
+ feedName: {
26
+ type: DataTypes.STRING,
27
+ allowNull: false,
28
+ comment: "e.g., TNC, SDO, RSOC",
29
+ },
30
+ vertical: {
31
+ type: DataTypes.STRING,
32
+ allowNull: false,
33
+ },
34
+ language: {
35
+ type: DataTypes.STRING,
36
+ allowNull: false,
37
+ defaultValue: "en",
38
+ },
39
+ headline: {
40
+ type: DataTypes.STRING,
41
+ allowNull: true,
42
+ },
43
+ topics: {
44
+ type: DataTypes.ARRAY(DataTypes.STRING),
45
+ allowNull: true,
46
+ comment: "List of topics (3-5 mandatory in UI)",
47
+ },
48
+ keywords: {
49
+ type: DataTypes.ARRAY(DataTypes.STRING),
50
+ allowNull: true,
51
+ comment: "Main keyword and related terms",
52
+ },
53
+ date: {
54
+ type: DataTypes.DATE,
55
+ allowNull: true,
56
+ defaultValue: DataTypes.NOW,
57
+ comment: "Creation date of the article",
58
+ },
59
+ nativeKeyword: {
60
+ type: DataTypes.STRING,
61
+ allowNull: false,
62
+ },
63
+ suggestedKeywords: {
64
+ type: DataTypes.STRING,
65
+ allowNull: true,
66
+ comment: "Comma-separated list of related terms",
67
+ },
68
+ articleExcerpt: {
69
+ type: DataTypes.TEXT,
70
+ allowNull: true,
71
+ },
72
+ articleContent: {
73
+ type: DataTypes.TEXT,
74
+ allowNull: true,
75
+ },
76
+ fbPixelId: {
77
+ type: DataTypes.STRING,
78
+ allowNull: true,
79
+ },
80
+ status: {
81
+ type: DataTypes.STRING,
82
+ defaultValue: "pending",
83
+ comment: "e.g., pending, approved, rejected",
84
+ },
85
+ createdAt: {
86
+ type: DataTypes.DATE,
87
+ defaultValue: DataTypes.NOW,
88
+ },
89
+ updatedAt: {
90
+ type: DataTypes.DATE,
91
+ defaultValue: DataTypes.NOW,
92
+ },
93
+ },
94
+ {
95
+ tableName: "articles",
96
+ timestamps: true,
97
+ }
98
+ );
99
+
100
+ Article.associate = (models) => {
101
+ Article.hasMany(models.RSOCFeedCampaign, {
102
+ foreignKey: "AGRSAID",
103
+ sourceKey: "AGRSAID",
104
+ as: "RSOCFeedCampaigns",
105
+ constraints: false,
106
+ });
107
+ };
108
+
109
+ return Article;
110
+ };
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
  };
@@ -1,33 +1,33 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const CampaignHistory = sequelize.define(
3
- "CampaignHistory",
4
- {
5
- HistoryID: {
6
- type: DataTypes.UUID,
7
- defaultValue: DataTypes.UUIDV4,
8
- primaryKey: true,
9
- },
10
- CampaignID: {
11
- type: DataTypes.STRING,
12
- allowNull: false,
13
- },
14
- TableName: {
15
- type: DataTypes.STRING, // Useful for multi-table history tracking
16
- defaultValue: "Campaign",
17
- },
18
- DataSnapshot: {
19
- type: DataTypes.JSONB, // Store the entire row as JSON
20
- allowNull: false,
21
- },
22
- timestamp: {
23
- type: DataTypes.DATE,
24
- defaultValue: DataTypes.NOW,
25
- },
26
- },
27
- {
28
- tableName: "CampaignHistory",
29
- }
30
- );
31
-
32
- return CampaignHistory;
33
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const CampaignHistory = sequelize.define(
3
+ "CampaignHistory",
4
+ {
5
+ HistoryID: {
6
+ type: DataTypes.UUID,
7
+ defaultValue: DataTypes.UUIDV4,
8
+ primaryKey: true,
9
+ },
10
+ CampaignID: {
11
+ type: DataTypes.STRING,
12
+ allowNull: false,
13
+ },
14
+ TableName: {
15
+ type: DataTypes.STRING, // Useful for multi-table history tracking
16
+ defaultValue: "Campaign",
17
+ },
18
+ DataSnapshot: {
19
+ type: DataTypes.JSONB, // Store the entire row as JSON
20
+ allowNull: false,
21
+ },
22
+ timestamp: {
23
+ type: DataTypes.DATE,
24
+ defaultValue: DataTypes.NOW,
25
+ },
26
+ },
27
+ {
28
+ tableName: "CampaignHistory",
29
+ }
30
+ );
31
+
32
+ return CampaignHistory;
33
+ };
@@ -0,0 +1,69 @@
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const Channel = sequelize.define(
3
+ "Channel",
4
+ {
5
+ id: {
6
+ type: DataTypes.INTEGER,
7
+ primaryKey: true,
8
+ autoIncrement: true,
9
+ },
10
+ channelId: {
11
+ type: DataTypes.STRING,
12
+ allowNull: false,
13
+ unique: true,
14
+ comment: "Channel ID (e.g., ch123+ch456)",
15
+ },
16
+ styleId: {
17
+ type: DataTypes.STRING,
18
+ allowNull: true,
19
+ defaultValue: "3544685732",
20
+ comment: "Style ID (stid)",
21
+ },
22
+ connectedCampaigns: {
23
+ type: DataTypes.JSON,
24
+ allowNull: true,
25
+ defaultValue: [],
26
+ comment: "List of connected campaign AGRS_CID values",
27
+ },
28
+ createdAt: {
29
+ type: DataTypes.DATE,
30
+ defaultValue: DataTypes.NOW,
31
+ },
32
+ updatedAt: {
33
+ type: DataTypes.DATE,
34
+ defaultValue: DataTypes.NOW,
35
+ },
36
+ },
37
+ {
38
+ tableName: "channels",
39
+ timestamps: true,
40
+ }
41
+ );
42
+
43
+ Channel.associate = (models) => {
44
+ Channel.hasMany(models.RSOCFeedCampaign, {
45
+ foreignKey: "channelId",
46
+ sourceKey: "channelId",
47
+ as: "RSOCFeedCampaigns",
48
+ constraints: false,
49
+ });
50
+ };
51
+
52
+ Channel.afterCreate(async (channel, options) => {
53
+ const campaigns = await sequelize.models.RSOCFeedCampaign.findAll({
54
+ where: { channelId: channel.channelId },
55
+ });
56
+ const campaignIds = campaigns.map((campaign) => campaign.AGRS_CID);
57
+ await channel.update({ connectedCampaigns: campaignIds });
58
+ });
59
+
60
+ Channel.afterUpdate(async (channel, options) => {
61
+ const campaigns = await sequelize.models.RSOCFeedCampaign.findAll({
62
+ where: { channelId: channel.channelId },
63
+ });
64
+ const campaignIds = campaigns.map((campaign) => campaign.AGRS_CID);
65
+ await channel.update({ connectedCampaigns: campaignIds });
66
+ });
67
+
68
+ return Channel;
69
+ };
package/models/Domain.js CHANGED
@@ -1,26 +1,26 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const Domain = sequelize.define(
3
- "Domain",
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: "Domain",
22
- }
23
- );
24
-
25
- return Domain;
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const Domain = sequelize.define(
3
+ "Domain",
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: "Domain",
22
+ }
23
+ );
24
+
25
+ return Domain;
26
26
  };
package/models/Feed.js CHANGED
@@ -1,34 +1,34 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const Feed = sequelize.define(
3
- "Feed",
4
- {
5
- id: {
6
- type: DataTypes.UUID,
7
- defaultValue: DataTypes.UUIDV4,
8
- primaryKey: true,
9
- },
10
- label: {
11
- type: DataTypes.STRING,
12
- allowNull: false,
13
- },
14
- code: {
15
- type: DataTypes.STRING,
16
- allowNull: false,
17
- unique: true,
18
- },
19
- sheet: {
20
- type: DataTypes.STRING,
21
- allowNull: false,
22
- },
23
- feedProvider: {
24
- type: DataTypes.STRING,
25
- allowNull: false,
26
- },
27
- },
28
- {
29
- tableName: "Feed",
30
- }
31
- );
32
-
33
- return Feed;
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const Feed = sequelize.define(
3
+ "Feed",
4
+ {
5
+ id: {
6
+ type: DataTypes.UUID,
7
+ defaultValue: DataTypes.UUIDV4,
8
+ primaryKey: true,
9
+ },
10
+ label: {
11
+ type: DataTypes.STRING,
12
+ allowNull: false,
13
+ },
14
+ code: {
15
+ type: DataTypes.STRING,
16
+ allowNull: false,
17
+ unique: true,
18
+ },
19
+ sheet: {
20
+ type: DataTypes.STRING,
21
+ allowNull: false,
22
+ },
23
+ feedProvider: {
24
+ type: DataTypes.STRING,
25
+ allowNull: false,
26
+ },
27
+ },
28
+ {
29
+ tableName: "Feed",
30
+ }
31
+ );
32
+
33
+ return Feed;
34
34
  };
@@ -64,10 +64,6 @@ module.exports = (sequelize, DataTypes) => {
64
64
  hooks: {
65
65
  beforeCreate: async (record, options) => {
66
66
  try {
67
- // Find existing record for this keyword
68
- console.log(
69
- "I got to beforeCreate hook in the KeywordPerformance model"
70
- );
71
67
  const existingKeyword =
72
68
  await sequelize.models.KeywordPerformance.findOne({
73
69
  where: {