agrs-sequelize-sdk 1.3.9 → 1.3.11

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.
@@ -23,6 +23,13 @@ module.exports = (sequelize, DataTypes) => {
23
23
  allowNull: false,
24
24
  comment: "Whether the rule is currently active",
25
25
  },
26
+ dryRun: {
27
+ type: DataTypes.BOOLEAN,
28
+ defaultValue: false,
29
+ allowNull: false,
30
+ comment:
31
+ "If true, rule will evaluate but not execute actions (simulation mode)",
32
+ },
26
33
  ruleType: {
27
34
  type: DataTypes.ENUM("PAUSE", "BUDGET", "BID", "STATUS", "CUSTOM"),
28
35
  allowNull: true,
@@ -0,0 +1,308 @@
1
+ // models/CampaignCreationLogV2.js
2
+ module.exports = (sequelize, DataTypes) => {
3
+ const CampaignCreationLogV2 = sequelize.define(
4
+ "CampaignCreationLogV2",
5
+ {
6
+ id: {
7
+ type: DataTypes.INTEGER,
8
+ primaryKey: true,
9
+ autoIncrement: true,
10
+ },
11
+ original_log_id: {
12
+ type: DataTypes.INTEGER,
13
+ allowNull: true,
14
+ unique: true,
15
+ comment: "ID from CampaignCreationLog (V1) - prevents duplicates",
16
+ },
17
+ process_id: {
18
+ type: DataTypes.UUID,
19
+ allowNull: false,
20
+ comment: "Unique ID for the creation batch process",
21
+ },
22
+ status: {
23
+ type: DataTypes.ENUM(
24
+ "STARTED",
25
+ "IN_PROGRESS",
26
+ "COMPLETED",
27
+ "FAILED",
28
+ "PARTIALLY_COMPLETED"
29
+ ),
30
+ allowNull: false,
31
+ defaultValue: "STARTED",
32
+ },
33
+
34
+ // Location & Targeting
35
+ country: {
36
+ type: DataTypes.TEXT,
37
+ allowNull: true,
38
+ },
39
+ countries: {
40
+ type: DataTypes.ARRAY(DataTypes.TEXT),
41
+ allowNull: true,
42
+ },
43
+ country_type: {
44
+ type: DataTypes.ENUM("ww", "mix"),
45
+ allowNull: true,
46
+ comment:
47
+ "Computed: ww (has WW), mix (multiple countries without WW), or NULL (single country)",
48
+ },
49
+
50
+ // Campaign identifiers
51
+ feed_campaign_id: {
52
+ type: DataTypes.STRING,
53
+ allowNull: true,
54
+ },
55
+ facebook_campaign_id: {
56
+ type: DataTypes.STRING,
57
+ allowNull: true,
58
+ },
59
+ campaign_name: {
60
+ type: DataTypes.STRING(255),
61
+ allowNull: true,
62
+ },
63
+ facebook_campaign_name: {
64
+ type: DataTypes.STRING(255),
65
+ allowNull: true,
66
+ },
67
+
68
+ // Feed & Provider
69
+ feed_provider: {
70
+ type: DataTypes.STRING(100),
71
+ allowNull: true,
72
+ },
73
+ feed_name: {
74
+ type: DataTypes.STRING(100),
75
+ allowNull: true,
76
+ comment: "Display name (e.g., 'predicto.ai' -> 'Predicto')",
77
+ },
78
+
79
+ // User & Account
80
+ media_buyer: {
81
+ type: DataTypes.STRING(100),
82
+ allowNull: true,
83
+ },
84
+ assignee: {
85
+ type: DataTypes.STRING(100),
86
+ allowNull: true,
87
+ },
88
+ user_name: {
89
+ type: DataTypes.STRING(100),
90
+ allowNull: true,
91
+ comment: "Full name from user mapping",
92
+ },
93
+ account_id: {
94
+ type: DataTypes.STRING(100),
95
+ allowNull: true,
96
+ },
97
+ account_name: {
98
+ type: DataTypes.STRING(255),
99
+ allowNull: true,
100
+ comment: "From AdAccount table",
101
+ },
102
+
103
+ // Campaign metadata
104
+ vertical: {
105
+ type: DataTypes.STRING(100),
106
+ allowNull: true,
107
+ },
108
+ platform: {
109
+ type: DataTypes.STRING(50),
110
+ allowNull: true,
111
+ },
112
+ language: {
113
+ type: DataTypes.STRING(50),
114
+ allowNull: true,
115
+ },
116
+ domain: {
117
+ type: DataTypes.STRING(255),
118
+ allowNull: true,
119
+ },
120
+
121
+ // Keywords & Content
122
+ keywords: {
123
+ type: DataTypes.ARRAY(DataTypes.TEXT),
124
+ allowNull: true,
125
+ },
126
+ main_keyword: {
127
+ type: DataTypes.STRING(255),
128
+ allowNull: true,
129
+ },
130
+ article_style: {
131
+ type: DataTypes.STRING(50),
132
+ allowNull: true,
133
+ comment: "black, blue, green, white",
134
+ },
135
+ ad_title: {
136
+ type: DataTypes.STRING(500),
137
+ allowNull: true,
138
+ },
139
+ notes: {
140
+ type: DataTypes.TEXT,
141
+ allowNull: true,
142
+ },
143
+ free_text: {
144
+ type: DataTypes.TEXT,
145
+ allowNull: true,
146
+ },
147
+
148
+ // Facebook Campaign Settings
149
+ pixel_id: {
150
+ type: DataTypes.STRING(100),
151
+ allowNull: true,
152
+ },
153
+ pixel_name: {
154
+ type: DataTypes.STRING(255),
155
+ allowNull: true,
156
+ },
157
+ pixel_event: {
158
+ type: DataTypes.STRING(50),
159
+ allowNull: true,
160
+ },
161
+ bid_strategy: {
162
+ type: DataTypes.STRING(100),
163
+ allowNull: true,
164
+ },
165
+ daily_budget: {
166
+ type: DataTypes.DECIMAL(10, 2),
167
+ allowNull: true,
168
+ },
169
+ bid_amount: {
170
+ type: DataTypes.DECIMAL(10, 2),
171
+ allowNull: true,
172
+ },
173
+ optimization_goal: {
174
+ type: DataTypes.STRING(100),
175
+ allowNull: true,
176
+ },
177
+ special_ad_categories: {
178
+ type: DataTypes.ARRAY(DataTypes.TEXT),
179
+ allowNull: true,
180
+ comment: "Array of categories (CREDIT, HOUSING, EMPLOYMENT)",
181
+ },
182
+
183
+ // Page info
184
+ page_id: {
185
+ type: DataTypes.UUID,
186
+ allowNull: true,
187
+ },
188
+ page_code: {
189
+ type: DataTypes.STRING(100),
190
+ allowNull: true,
191
+ },
192
+ page_name: {
193
+ type: DataTypes.STRING(255),
194
+ allowNull: true,
195
+ },
196
+
197
+ // Article/Content
198
+ agrs_aid: {
199
+ type: DataTypes.STRING(255),
200
+ allowNull: true,
201
+ comment: "Article ID",
202
+ },
203
+ article_id: {
204
+ type: DataTypes.STRING(255),
205
+ allowNull: true,
206
+ comment: "For Mine/Predicto feeds",
207
+ },
208
+
209
+ // Error handling
210
+ error_message: {
211
+ type: DataTypes.TEXT,
212
+ allowNull: true,
213
+ },
214
+ error_user_title: {
215
+ type: DataTypes.STRING(255),
216
+ allowNull: true,
217
+ },
218
+ error_code: {
219
+ type: DataTypes.STRING(50),
220
+ allowNull: true,
221
+ },
222
+ error_subcode: {
223
+ type: DataTypes.STRING(50),
224
+ allowNull: true,
225
+ },
226
+
227
+ // JSON fields for backward compatibility
228
+ details: {
229
+ type: DataTypes.JSONB,
230
+ allowNull: true,
231
+ comment: "For backward compatibility and complex nested data",
232
+ },
233
+ original_request_data: {
234
+ type: DataTypes.JSONB,
235
+ allowNull: true,
236
+ comment: "Full original request for reference",
237
+ },
238
+ facebook_response: {
239
+ type: DataTypes.JSONB,
240
+ allowNull: true,
241
+ comment: "Facebook API response",
242
+ },
243
+ },
244
+ {
245
+ tableName: "CampaignCreationLogsV2",
246
+ timestamps: true,
247
+ createdAt: "created_at",
248
+ updatedAt: "updated_at",
249
+ indexes: [
250
+ { fields: ["process_id"] },
251
+ { fields: ["status"] },
252
+ { fields: ["country"] },
253
+ { fields: ["countries"], using: "gin" },
254
+ { fields: ["country_type"] },
255
+ { fields: ["feed_provider"] },
256
+ { fields: ["media_buyer"] },
257
+ { fields: ["account_id"] },
258
+ { fields: ["vertical"] },
259
+ { fields: ["keywords"], using: "gin" },
260
+ { fields: [{ name: "created_at", order: "DESC" }] },
261
+ {
262
+ fields: [
263
+ "process_id",
264
+ "status",
265
+ { name: "created_at", order: "DESC" },
266
+ ],
267
+ },
268
+ { fields: ["status", "country"] },
269
+ { fields: ["feed_provider", "status"] },
270
+ { fields: ["media_buyer", "status"] },
271
+ { fields: ["account_id", "status"] },
272
+ { fields: ["vertical", "feed_provider"] },
273
+ { fields: ["details"], using: "gin" },
274
+ ],
275
+ }
276
+ );
277
+
278
+ CampaignCreationLogV2.associate = (models) => {
279
+ if (models.CampaignCreationLog) {
280
+ CampaignCreationLogV2.belongsTo(models.CampaignCreationLog, {
281
+ foreignKey: "process_id",
282
+ targetKey: "process_id",
283
+ as: "OriginalLog",
284
+ constraints: false,
285
+ });
286
+ }
287
+
288
+ if (models.AdAccount) {
289
+ CampaignCreationLogV2.belongsTo(models.AdAccount, {
290
+ foreignKey: "account_id",
291
+ targetKey: "AdAccountID",
292
+ as: "Account",
293
+ constraints: false,
294
+ });
295
+ }
296
+
297
+ if (models.Pages) {
298
+ CampaignCreationLogV2.belongsTo(models.Pages, {
299
+ foreignKey: "page_code",
300
+ targetKey: "code",
301
+ as: "Page",
302
+ constraints: false,
303
+ });
304
+ }
305
+ };
306
+
307
+ return CampaignCreationLogV2;
308
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agrs-sequelize-sdk",
3
- "version": "1.3.9",
3
+ "version": "1.3.11",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "start": "node index.js",