agrs-sequelize-sdk 1.1.98 → 1.2.0
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/agrs-sequelize/LICENSE +21 -0
- package/agrs-sequelize/README.md +179 -0
- package/agrs-sequelize/index.js +169 -0
- package/agrs-sequelize/jq.exe +0 -0
- package/agrs-sequelize/models/ActivityHistory.js +73 -0
- package/agrs-sequelize/models/Ad.js +209 -0
- package/agrs-sequelize/models/AdAccount.js +91 -0
- package/agrs-sequelize/models/AdAccountValues.js +26 -0
- package/agrs-sequelize/models/AdHistory.js +30 -0
- package/agrs-sequelize/models/AdPerformance.js +84 -0
- package/agrs-sequelize/models/AdPerformanceHourly.js +66 -0
- package/agrs-sequelize/models/AdSet.js +140 -0
- package/agrs-sequelize/models/AdSetHistory.js +30 -0
- package/agrs-sequelize/models/AdsetPerformance.js +116 -0
- package/agrs-sequelize/models/Article.js +156 -0
- package/agrs-sequelize/models/Buyers.js +26 -0
- package/agrs-sequelize/models/Campaign.js +136 -0
- package/agrs-sequelize/models/CampaignCreationLog.js +86 -0
- package/agrs-sequelize/models/CampaignHistory.js +33 -0
- package/agrs-sequelize/models/Channel.js +55 -0
- package/agrs-sequelize/models/CodefuelCampaign.js +159 -0
- package/agrs-sequelize/models/CodefuelCampaignKWHistory.js +41 -0
- package/agrs-sequelize/models/CodefuelKeywords.js +35 -0
- package/agrs-sequelize/models/CurrencyRate.js +27 -0
- package/agrs-sequelize/models/Domain.js +26 -0
- package/agrs-sequelize/models/ExplorAdsChannel.js +62 -0
- package/agrs-sequelize/models/Feed.js +34 -0
- package/agrs-sequelize/models/Files.js +73 -0
- package/agrs-sequelize/models/Folders.js +133 -0
- package/agrs-sequelize/models/KeywordPerformance.js +99 -0
- package/agrs-sequelize/models/KeywordRotationState.js +51 -0
- package/agrs-sequelize/models/Pages.js +74 -0
- package/agrs-sequelize/models/PipelineExecution.js +46 -0
- package/agrs-sequelize/models/RSOCFeedCampaign.js +302 -0
- package/agrs-sequelize/models/RsocKeywordPerformance.js +111 -0
- package/agrs-sequelize/models/Rule.js +39 -0
- package/agrs-sequelize/models/RulesValues.js +56 -0
- package/agrs-sequelize/models/SupportedLocale.js +24 -0
- package/agrs-sequelize/models/TonicCampaign.js +97 -0
- package/agrs-sequelize/models/Users.js +111 -0
- package/agrs-sequelize/models/Vertical.js +26 -0
- package/agrs-sequelize/models/newFiles.js +68 -0
- package/agrs-sequelize/models/pixel.js +33 -0
- package/agrs-sequelize/models/pixels.js +33 -0
- package/agrs-sequelize/package-lock.json +405 -0
- package/agrs-sequelize/package.json +19 -0
- package/agrs-sequelize/run.ps1 +98 -0
- package/agrs-sequelize/run.sh +214 -0
- package/migrations/20240321000000-add-performance-indexes.js +73 -0
- package/models/Ad.js +73 -9
- package/models/AdPerformance.js +84 -84
- package/models/AdSet.js +144 -0
- package/models/Campaign.js +135 -136
- package/models/RSOCFeedCampaign.js +1 -10
- package/models/pixel.js +5 -1
- package/models/pixels.js +5 -1
- package/package.json +1 -1
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const RSOCFeedCampaign = sequelize.define(
|
|
3
|
+
"RSOCFeedCampaign",
|
|
4
|
+
{
|
|
5
|
+
AGRS_CID: {
|
|
6
|
+
type: DataTypes.STRING,
|
|
7
|
+
allowNull: false,
|
|
8
|
+
unique: true,
|
|
9
|
+
primaryKey: true,
|
|
10
|
+
},
|
|
11
|
+
AGRSAID: {
|
|
12
|
+
type: DataTypes.STRING,
|
|
13
|
+
allowNull: true,
|
|
14
|
+
comment: "ID referencing Article.AGRSAID",
|
|
15
|
+
},
|
|
16
|
+
articleName: {
|
|
17
|
+
type: DataTypes.STRING,
|
|
18
|
+
allowNull: true,
|
|
19
|
+
comment: "Name of the associated article",
|
|
20
|
+
},
|
|
21
|
+
channelId: {
|
|
22
|
+
type: DataTypes.STRING,
|
|
23
|
+
allowNull: false,
|
|
24
|
+
comment: "ID referencing Channel.channelId",
|
|
25
|
+
},
|
|
26
|
+
styleId: {
|
|
27
|
+
type: DataTypes.STRING,
|
|
28
|
+
allowNull: true,
|
|
29
|
+
comment: "Style ID (stid) inherited from Channel",
|
|
30
|
+
},
|
|
31
|
+
assignee: {
|
|
32
|
+
type: DataTypes.STRING,
|
|
33
|
+
allowNull: false,
|
|
34
|
+
},
|
|
35
|
+
status: {
|
|
36
|
+
type: DataTypes.STRING,
|
|
37
|
+
allowNull: false,
|
|
38
|
+
defaultValue: "active",
|
|
39
|
+
validate: {
|
|
40
|
+
isIn: [["active", "inactive", "archived"]],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
country: {
|
|
44
|
+
type: DataTypes.STRING,
|
|
45
|
+
allowNull: false,
|
|
46
|
+
},
|
|
47
|
+
vertical: {
|
|
48
|
+
type: DataTypes.STRING,
|
|
49
|
+
allowNull: false,
|
|
50
|
+
comment: "Maps to Article.category for dynamic selection",
|
|
51
|
+
},
|
|
52
|
+
freeText: {
|
|
53
|
+
type: DataTypes.TEXT,
|
|
54
|
+
allowNull: true,
|
|
55
|
+
},
|
|
56
|
+
campaignName: {
|
|
57
|
+
type: DataTypes.STRING,
|
|
58
|
+
allowNull: false,
|
|
59
|
+
},
|
|
60
|
+
campaignId: {
|
|
61
|
+
type: DataTypes.STRING,
|
|
62
|
+
allowNull: true,
|
|
63
|
+
},
|
|
64
|
+
keywords: {
|
|
65
|
+
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
66
|
+
allowNull: true,
|
|
67
|
+
},
|
|
68
|
+
link: {
|
|
69
|
+
type: DataTypes.STRING(1024),
|
|
70
|
+
allowNull: true,
|
|
71
|
+
comment: "Campaign-specific URL based on article URL with parameters",
|
|
72
|
+
},
|
|
73
|
+
redirectLink: {
|
|
74
|
+
type: DataTypes.STRING(1024),
|
|
75
|
+
allowNull: true,
|
|
76
|
+
},
|
|
77
|
+
pixelId: {
|
|
78
|
+
type: DataTypes.STRING(1024),
|
|
79
|
+
allowNull: true,
|
|
80
|
+
},
|
|
81
|
+
token: {
|
|
82
|
+
type: DataTypes.STRING(1024),
|
|
83
|
+
allowNull: true,
|
|
84
|
+
},
|
|
85
|
+
accountId: {
|
|
86
|
+
type: DataTypes.STRING,
|
|
87
|
+
allowNull: false,
|
|
88
|
+
},
|
|
89
|
+
feedName: {
|
|
90
|
+
type: DataTypes.STRING,
|
|
91
|
+
allowNull: true,
|
|
92
|
+
defaultValue: "RSOC",
|
|
93
|
+
},
|
|
94
|
+
adTitle: {
|
|
95
|
+
type: DataTypes.STRING,
|
|
96
|
+
allowNull: true,
|
|
97
|
+
},
|
|
98
|
+
domain: {
|
|
99
|
+
type: DataTypes.STRING,
|
|
100
|
+
allowNull: true,
|
|
101
|
+
},
|
|
102
|
+
feedProvider: {
|
|
103
|
+
type: DataTypes.STRING,
|
|
104
|
+
allowNull: false,
|
|
105
|
+
defaultValue: "RSOC",
|
|
106
|
+
},
|
|
107
|
+
createdCampaignAt: {
|
|
108
|
+
type: DataTypes.DATE,
|
|
109
|
+
allowNull: true,
|
|
110
|
+
defaultValue: DataTypes.NOW,
|
|
111
|
+
},
|
|
112
|
+
draft: {
|
|
113
|
+
type: DataTypes.BOOLEAN,
|
|
114
|
+
allowNull: true,
|
|
115
|
+
defaultValue: false,
|
|
116
|
+
},
|
|
117
|
+
createdAt: {
|
|
118
|
+
type: DataTypes.DATE,
|
|
119
|
+
allowNull: false,
|
|
120
|
+
defaultValue: DataTypes.NOW,
|
|
121
|
+
},
|
|
122
|
+
updatedAt: {
|
|
123
|
+
type: DataTypes.DATE,
|
|
124
|
+
allowNull: false,
|
|
125
|
+
defaultValue: DataTypes.NOW,
|
|
126
|
+
},
|
|
127
|
+
platform: {
|
|
128
|
+
type: DataTypes.STRING,
|
|
129
|
+
allowNull: false,
|
|
130
|
+
},
|
|
131
|
+
mediaBuyer: {
|
|
132
|
+
type: DataTypes.STRING,
|
|
133
|
+
allowNull: true,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
tableName: "rsoc_feed_campaigns",
|
|
138
|
+
timestamps: true,
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
// Define associations without enforcing foreign key constraints
|
|
143
|
+
RSOCFeedCampaign.associate = (models) => {
|
|
144
|
+
if (models.Article) {
|
|
145
|
+
RSOCFeedCampaign.belongsTo(models.Article, {
|
|
146
|
+
foreignKey: "AGRSAID",
|
|
147
|
+
targetKey: "AGRSAID",
|
|
148
|
+
as: "Article",
|
|
149
|
+
constraints: false,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (models.Channel) {
|
|
154
|
+
RSOCFeedCampaign.belongsTo(models.Channel, {
|
|
155
|
+
foreignKey: "channelId",
|
|
156
|
+
targetKey: "channelId",
|
|
157
|
+
as: "Channel",
|
|
158
|
+
constraints: false,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (models.Ad) {
|
|
163
|
+
RSOCFeedCampaign.hasMany(models.Ad, {
|
|
164
|
+
foreignKey: "AGRS_CID",
|
|
165
|
+
sourceKey: "AGRS_CID",
|
|
166
|
+
as: "Ads",
|
|
167
|
+
constraints: false,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// BeforeCreate hook: Update Channel status and connectedCampaigns
|
|
173
|
+
RSOCFeedCampaign.beforeCreate(async (campaign, options) => {
|
|
174
|
+
campaign.setDataValue("redirectLink", null);
|
|
175
|
+
|
|
176
|
+
// Skip channel update if in a silent operation (e.g., during sync)
|
|
177
|
+
if (options.silent) return;
|
|
178
|
+
|
|
179
|
+
try {
|
|
180
|
+
const channel = await sequelize.models.Channel.findOne({
|
|
181
|
+
where: {
|
|
182
|
+
channelId: campaign.channelId,
|
|
183
|
+
styleId: campaign.styleId || null,
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
if (channel) {
|
|
188
|
+
const connectedCampaigns = channel.connectedCampaigns || [];
|
|
189
|
+
if (
|
|
190
|
+
!connectedCampaigns.some((c) => c.campaignId === campaign.AGRS_CID)
|
|
191
|
+
) {
|
|
192
|
+
connectedCampaigns.push({
|
|
193
|
+
campaignId: campaign.AGRS_CID,
|
|
194
|
+
assignedAt: new Date(),
|
|
195
|
+
releasedAt: null,
|
|
196
|
+
});
|
|
197
|
+
await channel.update(
|
|
198
|
+
{
|
|
199
|
+
status: "used",
|
|
200
|
+
connectedCampaigns,
|
|
201
|
+
},
|
|
202
|
+
{ silent: true }
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
console.warn(
|
|
207
|
+
`Channel not found for channelId: ${campaign.channelId}, styleId: ${campaign.styleId}`
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
} catch (error) {
|
|
211
|
+
console.error("Error in beforeCreate hook:", error.message);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// BeforeUpdate hook: Handle channel reassignment
|
|
216
|
+
RSOCFeedCampaign.beforeUpdate(async (campaign, options) => {
|
|
217
|
+
campaign.setDataValue("redirectLink", null);
|
|
218
|
+
|
|
219
|
+
// Skip channel update if in a silent operation or no relevant changes
|
|
220
|
+
if (
|
|
221
|
+
options.silent ||
|
|
222
|
+
(!campaign.changed("channelId") && !campaign.changed("styleId"))
|
|
223
|
+
) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
try {
|
|
228
|
+
const oldChannelId = campaign.previous("channelId");
|
|
229
|
+
const oldStyleId = campaign.previous("styleId") || null;
|
|
230
|
+
const newChannelId = campaign.channelId;
|
|
231
|
+
const newStyleId = campaign.styleId || null;
|
|
232
|
+
|
|
233
|
+
// Release old channel
|
|
234
|
+
if (
|
|
235
|
+
oldChannelId &&
|
|
236
|
+
(oldChannelId !== newChannelId || oldStyleId !== newStyleId)
|
|
237
|
+
) {
|
|
238
|
+
const oldChannel = await sequelize.models.Channel.findOne({
|
|
239
|
+
where: {
|
|
240
|
+
channelId: oldChannelId,
|
|
241
|
+
styleId: oldStyleId,
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
if (oldChannel) {
|
|
246
|
+
const connectedCampaigns = oldChannel.connectedCampaigns || [];
|
|
247
|
+
const updatedCampaigns = connectedCampaigns
|
|
248
|
+
.map((c) =>
|
|
249
|
+
c.campaignId === campaign.AGRS_CID
|
|
250
|
+
? { ...c, releasedAt: new Date() }
|
|
251
|
+
: c
|
|
252
|
+
)
|
|
253
|
+
.filter((c) => !c.releasedAt);
|
|
254
|
+
|
|
255
|
+
await oldChannel.update(
|
|
256
|
+
{
|
|
257
|
+
connectedCampaigns: updatedCampaigns,
|
|
258
|
+
status: updatedCampaigns.length > 0 ? "used" : "free",
|
|
259
|
+
},
|
|
260
|
+
{ silent: true }
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Assign new channel
|
|
266
|
+
const newChannel = await sequelize.models.Channel.findOne({
|
|
267
|
+
where: {
|
|
268
|
+
channelId: newChannelId,
|
|
269
|
+
styleId: newStyleId,
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
if (newChannel) {
|
|
274
|
+
const connectedCampaigns = newChannel.connectedCampaigns || [];
|
|
275
|
+
if (
|
|
276
|
+
!connectedCampaigns.some((c) => c.campaignId === campaign.AGRS_CID)
|
|
277
|
+
) {
|
|
278
|
+
connectedCampaigns.push({
|
|
279
|
+
campaignId: campaign.AGRS_CID,
|
|
280
|
+
assignedAt: new Date(),
|
|
281
|
+
releasedAt: null,
|
|
282
|
+
});
|
|
283
|
+
await newChannel.update(
|
|
284
|
+
{
|
|
285
|
+
status: "used",
|
|
286
|
+
connectedCampaigns,
|
|
287
|
+
},
|
|
288
|
+
{ silent: true }
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
} else {
|
|
292
|
+
console.warn(
|
|
293
|
+
`Channel not found for channelId: ${newChannelId}, styleId: ${newStyleId}`
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
} catch (error) {
|
|
297
|
+
console.error("Error in beforeUpdate hook:", error.message);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
return RSOCFeedCampaign;
|
|
302
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const RsocKeywordPerformance = sequelize.define('RsocKeywordPerformance', {
|
|
3
|
+
id: {
|
|
4
|
+
type: DataTypes.INTEGER,
|
|
5
|
+
primaryKey: true,
|
|
6
|
+
autoIncrement: true,
|
|
7
|
+
allowNull: false
|
|
8
|
+
},
|
|
9
|
+
ts: {
|
|
10
|
+
type: DataTypes.DATE,
|
|
11
|
+
allowNull: false,
|
|
12
|
+
comment: 'Timestamp of the record'
|
|
13
|
+
},
|
|
14
|
+
channel_id: {
|
|
15
|
+
type: DataTypes.STRING,
|
|
16
|
+
allowNull: false,
|
|
17
|
+
comment: 'Channel identifier'
|
|
18
|
+
},
|
|
19
|
+
style_id: {
|
|
20
|
+
type: DataTypes.STRING,
|
|
21
|
+
allowNull: true,
|
|
22
|
+
comment: 'Style identifier'
|
|
23
|
+
},
|
|
24
|
+
country_code: {
|
|
25
|
+
type: DataTypes.STRING(2),
|
|
26
|
+
allowNull: true,
|
|
27
|
+
comment: 'Country code (ISO 2-letter)'
|
|
28
|
+
},
|
|
29
|
+
custom_query: {
|
|
30
|
+
type: DataTypes.TEXT,
|
|
31
|
+
allowNull: true,
|
|
32
|
+
comment: 'Custom search query'
|
|
33
|
+
},
|
|
34
|
+
query: {
|
|
35
|
+
type: DataTypes.TEXT,
|
|
36
|
+
allowNull: true,
|
|
37
|
+
comment: 'Standard search query'
|
|
38
|
+
},
|
|
39
|
+
funnel_page_views: {
|
|
40
|
+
type: DataTypes.INTEGER,
|
|
41
|
+
allowNull: true,
|
|
42
|
+
defaultValue: 0,
|
|
43
|
+
comment: 'Number of funnel page views'
|
|
44
|
+
},
|
|
45
|
+
funnel_impressions: {
|
|
46
|
+
type: DataTypes.INTEGER,
|
|
47
|
+
allowNull: true,
|
|
48
|
+
defaultValue: 0,
|
|
49
|
+
comment: 'Number of funnel impressions'
|
|
50
|
+
},
|
|
51
|
+
funnel_clicks: {
|
|
52
|
+
type: DataTypes.INTEGER,
|
|
53
|
+
allowNull: true,
|
|
54
|
+
defaultValue: 0,
|
|
55
|
+
comment: 'Number of funnel clicks'
|
|
56
|
+
},
|
|
57
|
+
page_views: {
|
|
58
|
+
type: DataTypes.INTEGER,
|
|
59
|
+
allowNull: true,
|
|
60
|
+
defaultValue: 0,
|
|
61
|
+
comment: 'Number of page views'
|
|
62
|
+
},
|
|
63
|
+
impressions: {
|
|
64
|
+
type: DataTypes.INTEGER,
|
|
65
|
+
allowNull: true,
|
|
66
|
+
defaultValue: 0,
|
|
67
|
+
comment: 'Number of impressions'
|
|
68
|
+
},
|
|
69
|
+
clicks: {
|
|
70
|
+
type: DataTypes.INTEGER,
|
|
71
|
+
allowNull: true,
|
|
72
|
+
defaultValue: 0,
|
|
73
|
+
comment: 'Number of clicks'
|
|
74
|
+
},
|
|
75
|
+
agrs_cid: {
|
|
76
|
+
type: DataTypes.STRING,
|
|
77
|
+
allowNull: true,
|
|
78
|
+
comment: 'AGRS campaign identifier linking to campaign data'
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
tableName: 'rsoc_keyword_performance',
|
|
82
|
+
timestamps: true, // Adds createdAt and updatedAt columns
|
|
83
|
+
indexes: [
|
|
84
|
+
{
|
|
85
|
+
fields: ['channel_id', 'ts'],
|
|
86
|
+
name: 'idx_rsoc_keyword_channel_time'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
fields: ['style_id'],
|
|
90
|
+
name: 'idx_rsoc_keyword_style'
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
fields: ['country_code'],
|
|
94
|
+
name: 'idx_rsoc_keyword_country'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
fields: ['agrs_cid'],
|
|
98
|
+
name: 'idx_rsoc_keyword_agrs_cid'
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Define associations if needed
|
|
104
|
+
RsocKeywordPerformance.associate = (models) => {
|
|
105
|
+
// Add associations here if your table needs to reference other tables
|
|
106
|
+
// For example:
|
|
107
|
+
// RsocKeywordPerformance.belongsTo(models.Channel, { foreignKey: 'channel_id' });
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return RsocKeywordPerformance;
|
|
111
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const Rule = sequelize.define("Rule", {
|
|
3
|
+
ruleName: {
|
|
4
|
+
type: DataTypes.STRING,
|
|
5
|
+
allowNull: false,
|
|
6
|
+
},
|
|
7
|
+
timeUnit: {
|
|
8
|
+
type: DataTypes.ENUM("minutes", "hours", "days"),
|
|
9
|
+
allowNull: false,
|
|
10
|
+
},
|
|
11
|
+
timeValue: {
|
|
12
|
+
type: DataTypes.INTEGER,
|
|
13
|
+
allowNull: false,
|
|
14
|
+
},
|
|
15
|
+
daysAndTimes: {
|
|
16
|
+
type: DataTypes.JSONB, // Store days, time ranges, and conditions as a JSON object
|
|
17
|
+
allowNull: true,
|
|
18
|
+
},
|
|
19
|
+
filters: {
|
|
20
|
+
type: DataTypes.JSONB,
|
|
21
|
+
allowNull: true,
|
|
22
|
+
},
|
|
23
|
+
triggers: {
|
|
24
|
+
type: DataTypes.JSONB,
|
|
25
|
+
allowNull: false,
|
|
26
|
+
},
|
|
27
|
+
actions: {
|
|
28
|
+
type: DataTypes.JSONB,
|
|
29
|
+
allowNull: false,
|
|
30
|
+
},
|
|
31
|
+
status: {
|
|
32
|
+
type: DataTypes.ENUM("active", "paused"),
|
|
33
|
+
allowNull: false,
|
|
34
|
+
defaultValue: "active",
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return Rule;
|
|
39
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const RulesValues = sequelize.define(
|
|
3
|
+
"RulesValues",
|
|
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
|
+
permissions: {
|
|
20
|
+
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
21
|
+
allowNull: false,
|
|
22
|
+
defaultValue: [],
|
|
23
|
+
},
|
|
24
|
+
feature: {
|
|
25
|
+
type: DataTypes.STRING,
|
|
26
|
+
allowNull: true,
|
|
27
|
+
},
|
|
28
|
+
parentId: {
|
|
29
|
+
type: DataTypes.UUID,
|
|
30
|
+
allowNull: true,
|
|
31
|
+
references: {
|
|
32
|
+
model: "RulesValues",
|
|
33
|
+
key: "id",
|
|
34
|
+
},
|
|
35
|
+
onDelete: "CASCADE",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
tableName: "RulesValues",
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
// Self-referential association to define sub-rules
|
|
44
|
+
RulesValues.hasMany(RulesValues, {
|
|
45
|
+
as: "subRules",
|
|
46
|
+
foreignKey: "parentId",
|
|
47
|
+
onDelete: "CASCADE",
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
RulesValues.belongsTo(RulesValues, {
|
|
51
|
+
as: "parentRule",
|
|
52
|
+
foreignKey: "parentId",
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return RulesValues;
|
|
56
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const SupportedLocale = sequelize.define('SupportedLocale', {
|
|
3
|
+
country: {
|
|
4
|
+
type: DataTypes.STRING,
|
|
5
|
+
allowNull: false,
|
|
6
|
+
},
|
|
7
|
+
locale: {
|
|
8
|
+
type: DataTypes.STRING,
|
|
9
|
+
allowNull: false,
|
|
10
|
+
},
|
|
11
|
+
language: {
|
|
12
|
+
type: DataTypes.STRING,
|
|
13
|
+
allowNull: true,
|
|
14
|
+
comment: 'Language code (e.g., en, es, fr)'
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Define associations if needed in the future
|
|
19
|
+
// SupportedLocale.associate = (models) => {
|
|
20
|
+
// // e.g., SupportedLocale.hasMany(models.OtherModel);
|
|
21
|
+
// };
|
|
22
|
+
|
|
23
|
+
return SupportedLocale;
|
|
24
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const { DataTypes } = require("sequelize");
|
|
2
|
+
|
|
3
|
+
module.exports = (sequelize, DataTypes) => {
|
|
4
|
+
const TonicCampaign = sequelize.define("TonicCampaign", {
|
|
5
|
+
AGRSCID: {
|
|
6
|
+
type: DataTypes.STRING,
|
|
7
|
+
allowNull: false,
|
|
8
|
+
unique: true,
|
|
9
|
+
primaryKey: true,
|
|
10
|
+
},
|
|
11
|
+
CampaignName: {
|
|
12
|
+
type: DataTypes.STRING,
|
|
13
|
+
allowNull: false,
|
|
14
|
+
},
|
|
15
|
+
CampaignID: {
|
|
16
|
+
type: DataTypes.STRING,
|
|
17
|
+
allowNull: true,
|
|
18
|
+
},
|
|
19
|
+
Vertical: {
|
|
20
|
+
type: DataTypes.STRING,
|
|
21
|
+
allowNull: true,
|
|
22
|
+
},
|
|
23
|
+
Offer: {
|
|
24
|
+
type: DataTypes.STRING,
|
|
25
|
+
allowNull: true,
|
|
26
|
+
},
|
|
27
|
+
OfferID: {
|
|
28
|
+
type: DataTypes.STRING,
|
|
29
|
+
allowNull: true,
|
|
30
|
+
},
|
|
31
|
+
Country: {
|
|
32
|
+
type: DataTypes.STRING,
|
|
33
|
+
allowNull: false,
|
|
34
|
+
},
|
|
35
|
+
Domain: {
|
|
36
|
+
type: DataTypes.STRING,
|
|
37
|
+
allowNull: true,
|
|
38
|
+
},
|
|
39
|
+
Imprint: {
|
|
40
|
+
type: DataTypes.STRING,
|
|
41
|
+
allowNull: true,
|
|
42
|
+
defaultValue: "no",
|
|
43
|
+
},
|
|
44
|
+
Status: {
|
|
45
|
+
type: DataTypes.STRING,
|
|
46
|
+
allowNull: false,
|
|
47
|
+
defaultValue: "inactive",
|
|
48
|
+
},
|
|
49
|
+
FinalLink: {
|
|
50
|
+
type: DataTypes.STRING(1024),
|
|
51
|
+
allowNull: true,
|
|
52
|
+
},
|
|
53
|
+
Assignee: {
|
|
54
|
+
type: DataTypes.STRING,
|
|
55
|
+
allowNull: false,
|
|
56
|
+
},
|
|
57
|
+
KW: {
|
|
58
|
+
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
59
|
+
allowNull: true,
|
|
60
|
+
},
|
|
61
|
+
PixelID: {
|
|
62
|
+
type: DataTypes.STRING(1024),
|
|
63
|
+
allowNull: true,
|
|
64
|
+
},
|
|
65
|
+
Token: {
|
|
66
|
+
type: DataTypes.STRING(1024),
|
|
67
|
+
allowNull: true,
|
|
68
|
+
},
|
|
69
|
+
AccountID: {
|
|
70
|
+
type: DataTypes.STRING,
|
|
71
|
+
allowNull: false,
|
|
72
|
+
},
|
|
73
|
+
FeedName: {
|
|
74
|
+
type: DataTypes.STRING,
|
|
75
|
+
allowNull: true,
|
|
76
|
+
},
|
|
77
|
+
AdTitle: {
|
|
78
|
+
type: DataTypes.STRING,
|
|
79
|
+
allowNull: true,
|
|
80
|
+
},
|
|
81
|
+
Target: {
|
|
82
|
+
type: DataTypes.STRING,
|
|
83
|
+
allowNull: true,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
TonicCampaign.associate = (models) => {
|
|
88
|
+
TonicCampaign.hasMany(models.Ad, {
|
|
89
|
+
foreignKey: "AGRS_CID",
|
|
90
|
+
sourceKey: "AGRSCID",
|
|
91
|
+
constraints: false, // Disable the strict foreign key constraint
|
|
92
|
+
as: "Ads",
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return TonicCampaign;
|
|
97
|
+
};
|