agrs-sequelize-sdk 1.1.77 → 1.1.78

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/Article.js CHANGED
@@ -1,156 +1,156 @@
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,
42
- allowNull: true,
43
- },
44
- topics: {
45
- type: DataTypes.ARRAY(DataTypes.STRING),
46
- allowNull: true,
47
- },
48
- mainKeyword: {
49
- type: DataTypes.STRING,
50
- allowNull: true,
51
- },
52
- keywords: {
53
- type: DataTypes.ARRAY(DataTypes.STRING),
54
- allowNull: true,
55
- },
56
- date: {
57
- type: DataTypes.DATE,
58
- allowNull: true,
59
- defaultValue: DataTypes.NOW,
60
- },
61
- nativeKeyword: {
62
- type: DataTypes.STRING,
63
- allowNull: false,
64
- },
65
- suggestedKeywords: {
66
- type: DataTypes.STRING,
67
- allowNull: true,
68
- },
69
- articleExcerpt: {
70
- type: DataTypes.TEXT,
71
- allowNull: true,
72
- },
73
- articleContent: {
74
- type: DataTypes.TEXT,
75
- allowNull: true,
76
- },
77
- fbPixelId: {
78
- type: DataTypes.STRING,
79
- allowNull: true,
80
- },
81
- status: {
82
- type: DataTypes.STRING,
83
- allowNull: false,
84
- defaultValue: "pending",
85
- validate: {
86
- isIn: [
87
- [
88
- "pending",
89
- "approved",
90
- "rejected",
91
- "disapproved",
92
- "duplicated",
93
- "keyword_already_exists",
94
- "invalid_vertical",
95
- "invalid_language",
96
- "in_review",
97
- "error",
98
- ],
99
- ],
100
- },
101
- },
102
- originalStatus: {
103
- type: DataTypes.STRING,
104
- allowNull: true,
105
- comment: "Original status from Predicto before any mapping",
106
- },
107
- creationType: {
108
- type: DataTypes.STRING,
109
- allowNull: false,
110
- defaultValue: "slug",
111
- validate: {
112
- isIn: [["search", "slug"]],
113
- },
114
- },
115
- createdAt: {
116
- type: DataTypes.DATE,
117
- defaultValue: DataTypes.NOW,
118
- },
119
- updatedAt: {
120
- type: DataTypes.DATE,
121
- defaultValue: DataTypes.NOW,
122
- },
123
- buyer: {
124
- type: DataTypes.STRING,
125
- allowNull: true,
126
- },
127
- country: {
128
- type: DataTypes.STRING,
129
- allowNull: true,
130
- },
131
- name: {
132
- type: DataTypes.STRING,
133
- allowNull: true,
134
- },
135
- },
136
- {
137
- tableName: "articles",
138
- timestamps: true,
139
- }
140
- );
141
-
142
- Article.associate = (models) => {
143
- Article.hasMany(models.RSOCFeedCampaign, {
144
- foreignKey: "AGRSAID",
145
- sourceKey: "AGRSAID",
146
- as: "RSOCFeedCampaigns",
147
- constraints: false,
148
- });
149
- };
150
-
151
- Article.prototype.isAvailableForCampaign = function () {
152
- return ["approved", "keyword_already_exists"].includes(this.status);
153
- };
154
-
155
- return Article;
156
- };
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,
42
+ allowNull: true,
43
+ },
44
+ topics: {
45
+ type: DataTypes.ARRAY(DataTypes.STRING),
46
+ allowNull: true,
47
+ },
48
+ mainKeyword: {
49
+ type: DataTypes.STRING,
50
+ allowNull: true,
51
+ },
52
+ keywords: {
53
+ type: DataTypes.ARRAY(DataTypes.STRING),
54
+ allowNull: true,
55
+ },
56
+ date: {
57
+ type: DataTypes.DATE,
58
+ allowNull: true,
59
+ defaultValue: DataTypes.NOW,
60
+ },
61
+ nativeKeyword: {
62
+ type: DataTypes.STRING,
63
+ allowNull: false,
64
+ },
65
+ suggestedKeywords: {
66
+ type: DataTypes.STRING,
67
+ allowNull: true,
68
+ },
69
+ articleExcerpt: {
70
+ type: DataTypes.TEXT,
71
+ allowNull: true,
72
+ },
73
+ articleContent: {
74
+ type: DataTypes.TEXT,
75
+ allowNull: true,
76
+ },
77
+ fbPixelId: {
78
+ type: DataTypes.STRING,
79
+ allowNull: true,
80
+ },
81
+ status: {
82
+ type: DataTypes.STRING,
83
+ allowNull: false,
84
+ defaultValue: "pending",
85
+ validate: {
86
+ isIn: [
87
+ [
88
+ "pending",
89
+ "approved",
90
+ "rejected",
91
+ "disapproved",
92
+ "duplicated",
93
+ "keyword_already_exists",
94
+ "invalid_vertical",
95
+ "invalid_language",
96
+ "in_review",
97
+ "error",
98
+ ],
99
+ ],
100
+ },
101
+ },
102
+ originalStatus: {
103
+ type: DataTypes.STRING,
104
+ allowNull: true,
105
+ comment: "Original status from Predicto before any mapping",
106
+ },
107
+ creationType: {
108
+ type: DataTypes.STRING,
109
+ allowNull: false,
110
+ defaultValue: "slug",
111
+ validate: {
112
+ isIn: [["search", "slug"]],
113
+ },
114
+ },
115
+ createdAt: {
116
+ type: DataTypes.DATE,
117
+ defaultValue: DataTypes.NOW,
118
+ },
119
+ updatedAt: {
120
+ type: DataTypes.DATE,
121
+ defaultValue: DataTypes.NOW,
122
+ },
123
+ buyer: {
124
+ type: DataTypes.STRING,
125
+ allowNull: true,
126
+ },
127
+ country: {
128
+ type: DataTypes.STRING,
129
+ allowNull: true,
130
+ },
131
+ name: {
132
+ type: DataTypes.STRING,
133
+ allowNull: true,
134
+ },
135
+ },
136
+ {
137
+ tableName: "articles",
138
+ timestamps: true,
139
+ }
140
+ );
141
+
142
+ Article.associate = (models) => {
143
+ Article.hasMany(models.RSOCFeedCampaign, {
144
+ foreignKey: "AGRSAID",
145
+ sourceKey: "AGRSAID",
146
+ as: "RSOCFeedCampaigns",
147
+ constraints: false,
148
+ });
149
+ };
150
+
151
+ Article.prototype.isAvailableForCampaign = function () {
152
+ return ["approved", "keyword_already_exists"].includes(this.status);
153
+ };
154
+
155
+ return Article;
156
+ };
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,86 +1,86 @@
1
- // models/CampaignCreationLog.js
2
- module.exports = (sequelize, DataTypes) => {
3
- const CampaignCreationLog = sequelize.define(
4
- "CampaignCreationLog",
5
- {
6
- id: {
7
- type: DataTypes.INTEGER,
8
- primaryKey: true,
9
- autoIncrement: true,
10
- },
11
- process_id: {
12
- type: DataTypes.UUID,
13
- allowNull: false,
14
- comment: "Unique ID for the creation batch process",
15
- },
16
- status: {
17
- type: DataTypes.ENUM("STARTED", "IN_PROGRESS", "COMPLETED", "FAILED"),
18
- allowNull: false,
19
- defaultValue: "STARTED",
20
- },
21
- country: {
22
- type: DataTypes.STRING,
23
- allowNull: true,
24
- comment: "Country being processed",
25
- },
26
- feed_campaign_id: {
27
- type: DataTypes.STRING,
28
- allowNull: true,
29
- comment: "AGRS_CID of the created feed campaign",
30
- },
31
- facebook_campaign_id: {
32
- type: DataTypes.STRING,
33
- allowNull: true,
34
- comment: "Facebook campaign ID if created",
35
- },
36
- details: {
37
- type: DataTypes.JSONB,
38
- allowNull: true,
39
- comment: "Additional details about the process or results",
40
- },
41
- error_message: {
42
- type: DataTypes.TEXT,
43
- allowNull: true,
44
- comment: "Error message if process failed",
45
- },
46
- },
47
- {
48
- tableName: "CampaignCreationLogs",
49
- timestamps: true,
50
- indexes: [
51
- {
52
- fields: ["process_id"],
53
- },
54
- {
55
- fields: ["status"],
56
- },
57
- {
58
- fields: ["country"],
59
- },
60
- {
61
- fields: ["feed_campaign_id"],
62
- },
63
- {
64
- fields: ["facebook_campaign_id"],
65
- },
66
- {
67
- fields: ["createdAt"],
68
- },
69
- ],
70
- }
71
- );
72
-
73
- CampaignCreationLog.associate = (models) => {
74
- // Add associations if needed
75
- if (models.CodefuelCampaign) {
76
- CampaignCreationLog.belongsTo(models.CodefuelCampaign, {
77
- foreignKey: "feed_campaign_id",
78
- targetKey: "AGRSCID",
79
- as: "FeedCampaign",
80
- constraints: false,
81
- });
82
- }
83
- };
84
-
85
- return CampaignCreationLog;
86
- };
1
+ // models/CampaignCreationLog.js
2
+ module.exports = (sequelize, DataTypes) => {
3
+ const CampaignCreationLog = sequelize.define(
4
+ "CampaignCreationLog",
5
+ {
6
+ id: {
7
+ type: DataTypes.INTEGER,
8
+ primaryKey: true,
9
+ autoIncrement: true,
10
+ },
11
+ process_id: {
12
+ type: DataTypes.UUID,
13
+ allowNull: false,
14
+ comment: "Unique ID for the creation batch process",
15
+ },
16
+ status: {
17
+ type: DataTypes.ENUM("STARTED", "IN_PROGRESS", "COMPLETED", "FAILED"),
18
+ allowNull: false,
19
+ defaultValue: "STARTED",
20
+ },
21
+ country: {
22
+ type: DataTypes.STRING,
23
+ allowNull: true,
24
+ comment: "Country being processed",
25
+ },
26
+ feed_campaign_id: {
27
+ type: DataTypes.STRING,
28
+ allowNull: true,
29
+ comment: "AGRS_CID of the created feed campaign",
30
+ },
31
+ facebook_campaign_id: {
32
+ type: DataTypes.STRING,
33
+ allowNull: true,
34
+ comment: "Facebook campaign ID if created",
35
+ },
36
+ details: {
37
+ type: DataTypes.JSONB,
38
+ allowNull: true,
39
+ comment: "Additional details about the process or results",
40
+ },
41
+ error_message: {
42
+ type: DataTypes.TEXT,
43
+ allowNull: true,
44
+ comment: "Error message if process failed",
45
+ },
46
+ },
47
+ {
48
+ tableName: "CampaignCreationLogs",
49
+ timestamps: true,
50
+ indexes: [
51
+ {
52
+ fields: ["process_id"],
53
+ },
54
+ {
55
+ fields: ["status"],
56
+ },
57
+ {
58
+ fields: ["country"],
59
+ },
60
+ {
61
+ fields: ["feed_campaign_id"],
62
+ },
63
+ {
64
+ fields: ["facebook_campaign_id"],
65
+ },
66
+ {
67
+ fields: ["createdAt"],
68
+ },
69
+ ],
70
+ }
71
+ );
72
+
73
+ CampaignCreationLog.associate = (models) => {
74
+ // Add associations if needed
75
+ if (models.CodefuelCampaign) {
76
+ CampaignCreationLog.belongsTo(models.CodefuelCampaign, {
77
+ foreignKey: "feed_campaign_id",
78
+ targetKey: "AGRSCID",
79
+ as: "FeedCampaign",
80
+ constraints: false,
81
+ });
82
+ }
83
+ };
84
+
85
+ return CampaignCreationLog;
86
+ };
@@ -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
+ };