agrs-sequelize-sdk 1.1.87 → 1.1.90

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,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
+ };
package/models/Channel.js CHANGED
@@ -1,55 +1,55 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const Channel = sequelize.define(
3
- "Channel",
4
- {
5
- channelId: {
6
- type: DataTypes.STRING,
7
- allowNull: false,
8
- // Not setting as primary key or unique since duplicates are allowed
9
- },
10
- styleId: {
11
- type: DataTypes.STRING,
12
- allowNull: false,
13
- },
14
- status: {
15
- type: DataTypes.STRING,
16
- allowNull: false,
17
- defaultValue: "free",
18
- validate: {
19
- isIn: [["free", "used", "archived"]],
20
- },
21
- },
22
- connectedCampaigns: {
23
- type: DataTypes.JSONB, // Use JSONB for better querying capabilities
24
- allowNull: false,
25
- defaultValue: [],
26
- },
27
- },
28
- {
29
- tableName: "channels",
30
- timestamps: true,
31
- indexes: [
32
- // Add a composite unique index on channelId and styleId if needed
33
- {
34
- unique: true,
35
- fields: ["channelId", "styleId"],
36
- name: "unique_channel_style",
37
- },
38
- ],
39
- }
40
- );
41
-
42
- // Define associations without enforcing constraints
43
- Channel.associate = (models) => {
44
- if (models.RSOCFeedCampaign) {
45
- Channel.hasMany(models.RSOCFeedCampaign, {
46
- foreignKey: "channelId",
47
- sourceKey: "channelId",
48
- as: "RSOCFeedCampaigns",
49
- constraints: false, // Disable FK constraint
50
- });
51
- }
52
- };
53
-
54
- return Channel;
55
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const Channel = sequelize.define(
3
+ "Channel",
4
+ {
5
+ channelId: {
6
+ type: DataTypes.STRING,
7
+ allowNull: false,
8
+ // Not setting as primary key or unique since duplicates are allowed
9
+ },
10
+ styleId: {
11
+ type: DataTypes.STRING,
12
+ allowNull: false,
13
+ },
14
+ status: {
15
+ type: DataTypes.STRING,
16
+ allowNull: false,
17
+ defaultValue: "free",
18
+ validate: {
19
+ isIn: [["free", "used", "archived"]],
20
+ },
21
+ },
22
+ connectedCampaigns: {
23
+ type: DataTypes.JSONB, // Use JSONB for better querying capabilities
24
+ allowNull: false,
25
+ defaultValue: [],
26
+ },
27
+ },
28
+ {
29
+ tableName: "channels",
30
+ timestamps: true,
31
+ indexes: [
32
+ // Add a composite unique index on channelId and styleId if needed
33
+ {
34
+ unique: true,
35
+ fields: ["channelId", "styleId"],
36
+ name: "unique_channel_style",
37
+ },
38
+ ],
39
+ }
40
+ );
41
+
42
+ // Define associations without enforcing constraints
43
+ Channel.associate = (models) => {
44
+ if (models.RSOCFeedCampaign) {
45
+ Channel.hasMany(models.RSOCFeedCampaign, {
46
+ foreignKey: "channelId",
47
+ sourceKey: "channelId",
48
+ as: "RSOCFeedCampaigns",
49
+ constraints: false, // Disable FK constraint
50
+ });
51
+ }
52
+ };
53
+
54
+ return Channel;
55
+ };
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
  };
@@ -1,62 +1,62 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const ExplorAdsChannel = sequelize.define(
3
- "ExplorAdsChannel",
4
- {
5
- channelId: {
6
- type: DataTypes.STRING,
7
- allowNull: false,
8
- validate: {
9
- // Validate channel format (br_vt_ch1401 to br_vt_ch1500)
10
- is: /^br_vt_ch(14[0-9][0-9]|1500)$/
11
- }
12
- },
13
- status: {
14
- type: DataTypes.STRING,
15
- allowNull: false,
16
- defaultValue: "free",
17
- validate: {
18
- isIn: [["free", "used", "archived"]],
19
- },
20
- },
21
- domain: {
22
- type: DataTypes.STRING,
23
- allowNull: false,
24
- defaultValue: "nexoreach.com"
25
- },
26
- connectedCampaigns: {
27
- type: DataTypes.JSONB,
28
- allowNull: false,
29
- defaultValue: [],
30
- },
31
- lastUsed: {
32
- type: DataTypes.DATE,
33
- allowNull: true
34
- }
35
- },
36
- {
37
- tableName: "explorads_channels",
38
- timestamps: true,
39
- indexes: [
40
- {
41
- unique: true,
42
- fields: ["channelId"],
43
- name: "unique_explorads_channel"
44
- },
45
- ],
46
- }
47
- );
48
-
49
- // Define associations
50
- ExplorAdsChannel.associate = (models) => {
51
- if (models.RSOCFeedCampaign) {
52
- ExplorAdsChannel.hasMany(models.RSOCFeedCampaign, {
53
- foreignKey: "channelId",
54
- sourceKey: "channelId",
55
- as: "RSOCFeedCampaigns",
56
- constraints: false, // Disable FK constraint
57
- });
58
- }
59
- };
60
-
61
- return ExplorAdsChannel;
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const ExplorAdsChannel = sequelize.define(
3
+ "ExplorAdsChannel",
4
+ {
5
+ channelId: {
6
+ type: DataTypes.STRING,
7
+ allowNull: false,
8
+ validate: {
9
+ // Validate channel format (br_vt_ch1401 to br_vt_ch1500)
10
+ is: /^br_vt_ch(14[0-9][0-9]|1500)$/
11
+ }
12
+ },
13
+ status: {
14
+ type: DataTypes.STRING,
15
+ allowNull: false,
16
+ defaultValue: "free",
17
+ validate: {
18
+ isIn: [["free", "used", "archived"]],
19
+ },
20
+ },
21
+ domain: {
22
+ type: DataTypes.STRING,
23
+ allowNull: false,
24
+ defaultValue: "nexoreach.com"
25
+ },
26
+ connectedCampaigns: {
27
+ type: DataTypes.JSONB,
28
+ allowNull: false,
29
+ defaultValue: [],
30
+ },
31
+ lastUsed: {
32
+ type: DataTypes.DATE,
33
+ allowNull: true
34
+ }
35
+ },
36
+ {
37
+ tableName: "explorads_channels",
38
+ timestamps: true,
39
+ indexes: [
40
+ {
41
+ unique: true,
42
+ fields: ["channelId"],
43
+ name: "unique_explorads_channel"
44
+ },
45
+ ],
46
+ }
47
+ );
48
+
49
+ // Define associations
50
+ ExplorAdsChannel.associate = (models) => {
51
+ if (models.RSOCFeedCampaign) {
52
+ ExplorAdsChannel.hasMany(models.RSOCFeedCampaign, {
53
+ foreignKey: "channelId",
54
+ sourceKey: "channelId",
55
+ as: "RSOCFeedCampaigns",
56
+ constraints: false, // Disable FK constraint
57
+ });
58
+ }
59
+ };
60
+
61
+ return ExplorAdsChannel;
62
62
  };
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
  };