agrs-sequelize-sdk 1.2.21 → 1.2.22

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.
@@ -104,6 +104,16 @@ module.exports = (sequelize, DataTypes) => {
104
104
  domain: {
105
105
  type: DataTypes.STRING,
106
106
  allowNull: true,
107
+ defaultValue: "searchlabz.com",
108
+ comment:
109
+ "Target domain for campaign URLs (searchlabz.com or sportfoy.com)",
110
+ },
111
+ url_structure: {
112
+ type: DataTypes.ENUM("legacy", "unified"),
113
+ allowNull: false,
114
+ defaultValue: "legacy",
115
+ comment:
116
+ "URL structure type: legacy (slug-based) or unified (search-based)",
107
117
  },
108
118
  feedProvider: {
109
119
  type: DataTypes.STRING,
@@ -182,6 +192,22 @@ module.exports = (sequelize, DataTypes) => {
182
192
  RSOCFeedCampaign.beforeCreate(async (campaign, options) => {
183
193
  campaign.setDataValue("redirectLink", null);
184
194
 
195
+ // Set default domain and url_structure if not provided
196
+ if (!campaign.domain) {
197
+ campaign.setDataValue("domain", "searchlabz.com");
198
+ }
199
+ if (!campaign.url_structure) {
200
+ campaign.setDataValue("url_structure", "legacy");
201
+ }
202
+
203
+ // Auto-adjust url_structure based on domain
204
+ if (
205
+ campaign.domain === "sportfoy.com" &&
206
+ campaign.url_structure === "legacy"
207
+ ) {
208
+ campaign.setDataValue("url_structure", "unified");
209
+ }
210
+
185
211
  // Skip channel update if in a silent operation (e.g., during sync)
186
212
  if (options.silent) return;
187
213
 
@@ -225,6 +251,16 @@ module.exports = (sequelize, DataTypes) => {
225
251
  RSOCFeedCampaign.beforeUpdate(async (campaign, options) => {
226
252
  campaign.setDataValue("redirectLink", null);
227
253
 
254
+ // Auto-adjust url_structure based on domain if domain changed
255
+ if (campaign.changed("domain")) {
256
+ if (
257
+ campaign.domain === "sportfoy.com" &&
258
+ campaign.url_structure === "legacy"
259
+ ) {
260
+ campaign.setDataValue("url_structure", "unified");
261
+ }
262
+ }
263
+
228
264
  // Skip channel update if in a silent operation or no relevant changes
229
265
  if (
230
266
  options.silent ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agrs-sequelize-sdk",
3
- "version": "1.2.21",
3
+ "version": "1.2.22",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "start": "node index.js",