agrs-sequelize-sdk 1.0.64 → 1.0.65

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 CHANGED
@@ -98,6 +98,11 @@ module.exports = (sequelize, DataTypes) => {
98
98
  type: DataTypes.STRING,
99
99
  allowNull: true,
100
100
  },
101
+ // add effective_status field
102
+ effectiveStatus: {
103
+ type: DataTypes.STRING,
104
+ allowNull: true,
105
+ },
101
106
  },
102
107
  {
103
108
  tableName: "Ad",
package/models/AdSet.js CHANGED
@@ -53,7 +53,7 @@ module.exports = (sequelize, DataTypes) => {
53
53
  type: DataTypes.STRING,
54
54
  allowNull: true,
55
55
  },
56
- publish:{
56
+ publish: {
57
57
  type: DataTypes.BOOLEAN,
58
58
  allowNull: true,
59
59
  defaultValue: true,
@@ -66,6 +66,10 @@ module.exports = (sequelize, DataTypes) => {
66
66
  key: "CampaignID",
67
67
  },
68
68
  },
69
+ effectiveStatus: {
70
+ type: DataTypes.STRING,
71
+ allowNull: true,
72
+ },
69
73
  },
70
74
  {
71
75
  tableName: "AdSet",
@@ -82,27 +86,30 @@ module.exports = (sequelize, DataTypes) => {
82
86
  AdSet.hasMany(models.Ad, { foreignKey: "AdSetID" });
83
87
  };
84
88
 
85
- AdSet.addHook('beforeUpdate', async (adSet, options) => {
86
- if (adSet.changed('publish')) {
87
- if (adSet.previous('publish') === true && adSet.publish === false) {
89
+ AdSet.addHook("beforeUpdate", async (adSet, options) => {
90
+ if (adSet.changed("publish")) {
91
+ if (adSet.previous("publish") === true && adSet.publish === false) {
88
92
  // Save current state to AdSetHistory
89
93
  await sequelize.models.AdSetHistory.create({
90
94
  AdSetID: adSet.AdSetID,
91
95
  DataSnapshot: adSet._previousDataValues, // Save the full AdSet data as JSON
92
96
  });
93
- } else if (adSet.previous('publish') === false && adSet.publish === true) {
97
+ } else if (
98
+ adSet.previous("publish") === false &&
99
+ adSet.publish === true
100
+ ) {
94
101
  // Delete the latest history entry
95
102
  const latestHistory = await sequelize.models.AdSetHistory.findOne({
96
103
  where: { AdSetID: adSet.AdSetID },
97
- order: [['timestamp', 'DESC']], // Get the latest history entry
104
+ order: [["timestamp", "DESC"]], // Get the latest history entry
98
105
  });
99
-
106
+
100
107
  if (latestHistory) {
101
108
  await latestHistory.destroy();
102
109
  }
103
110
  }
104
111
  }
105
112
  });
106
-
113
+
107
114
  return AdSet;
108
115
  };
@@ -66,6 +66,10 @@ module.exports = (sequelize, DataTypes) => {
66
66
  type: DataTypes.ARRAY(DataTypes.STRING),
67
67
  allowNull: true,
68
68
  },
69
+ effectiveStatus: {
70
+ type: DataTypes.STRING,
71
+ allowNull: true,
72
+ },
69
73
  },
70
74
  {
71
75
  tableName: "Campaign",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agrs-sequelize-sdk",
3
- "version": "1.0.64",
3
+ "version": "1.0.65",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "start": "node index.js",