agrs-sequelize-sdk 1.4.16 → 1.4.18

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.
Files changed (84) hide show
  1. package/migrations/2026-05-17-PIXELS-FOLLOWUP.md +85 -0
  2. package/migrations/2026-05-17-add-platform-to-ad.js +19 -0
  3. package/migrations/2026-05-17-add-platform-to-adaccount.js +19 -0
  4. package/migrations/2026-05-17-add-platform-to-adperformance.js +19 -0
  5. package/migrations/2026-05-17-add-platform-to-adset.js +19 -0
  6. package/migrations/2026-05-17-add-platform-to-adsetperformance.js +19 -0
  7. package/migrations/2026-05-17-add-platform-to-aiarticleretryqueue.js +19 -0
  8. package/migrations/2026-05-17-add-platform-to-aicampaignqueue.js +19 -0
  9. package/migrations/2026-05-17-add-platform-to-article.js +19 -0
  10. package/migrations/2026-05-17-add-platform-to-campaign.js +19 -0
  11. package/migrations/2026-05-17-add-platform-to-codefuelcampaign.js +19 -0
  12. package/migrations/2026-05-17-add-platform-to-dynamicfeed.js +19 -0
  13. package/migrations/2026-05-17-add-platform-to-facebookretryqueue.js +19 -0
  14. package/migrations/2026-05-17-add-platform-to-pages.js +19 -0
  15. package/migrations/2026-05-17-add-platform-to-presets.js +19 -0
  16. package/migrations/RUN_ME_MANUALLY_2026-05-17.sql +99 -0
  17. package/migrations/add-requested-from-dashboard-to-articles.js +17 -17
  18. package/migrations/change-adset-name-to-text.js +79 -79
  19. package/models/AICampaignQueue.js +143 -136
  20. package/models/AIGenerationLog.js +85 -85
  21. package/models/AIGenerationRequest.js +212 -212
  22. package/models/Ad.js +6 -0
  23. package/models/AdAccount.js +6 -0
  24. package/models/AdAccountValues.js +25 -25
  25. package/models/AdHistory.js +30 -30
  26. package/models/AdPerformance.js +100 -94
  27. package/models/AdSet.js +295 -289
  28. package/models/AdSetHistory.js +30 -30
  29. package/models/AdsetPerformance.js +132 -126
  30. package/models/AiArticleRetryQueue.js +157 -150
  31. package/models/AiCreationRetryQueue.js +127 -127
  32. package/models/Article.js +212 -206
  33. package/models/AutomationRule.js +173 -173
  34. package/models/BannerTemplate.js +129 -129
  35. package/models/Buyers.js +25 -25
  36. package/models/Campaign.js +163 -157
  37. package/models/CampaignActionHistory.js +86 -86
  38. package/models/CampaignCreationLog.js +309 -309
  39. package/models/CampaignCreationLogV2.js +314 -314
  40. package/models/CampaignHistory.js +33 -33
  41. package/models/Channel.js +55 -55
  42. package/models/CodefuelCampaign.js +6 -0
  43. package/models/Domain.js +39 -47
  44. package/models/DynamicFeed.js +218 -212
  45. package/models/ExplorAdsChannel.js +61 -61
  46. package/models/FacebookRetryQueue.js +163 -156
  47. package/models/Feed.js +33 -33
  48. package/models/FeedArticleConfiguration.js +80 -80
  49. package/models/FrontStoryChannel.js +59 -59
  50. package/models/FrontStoryChannelV2.js +60 -60
  51. package/models/GenericFlowRequest.js +114 -114
  52. package/models/MidoWebChannel.js +47 -47
  53. package/models/MineChannel.js +42 -42
  54. package/models/Pages.js +105 -99
  55. package/models/PipelineExecution.js +59 -59
  56. package/models/PolicyDogsCreativeCache.js +50 -50
  57. package/models/PolicyDogsImageCache.js +30 -30
  58. package/models/Presets.js +40 -34
  59. package/models/RSOCFeedCampaign.js +375 -375
  60. package/models/RsocKeywordPerformance.js +110 -110
  61. package/models/RuleAction.js +90 -90
  62. package/models/RuleCondition.js +137 -137
  63. package/models/RuleExecution.js +107 -107
  64. package/models/RulesValues.js +56 -56
  65. package/models/SupportedLocale.js +23 -23
  66. package/models/SyncHistory.js +249 -249
  67. package/models/TTQChannel.js +42 -42
  68. package/models/TemplateMetadata.js +260 -260
  69. package/models/Tier2_AdAccounts.js +110 -110
  70. package/models/Tier2_Assets.js +70 -70
  71. package/models/Tier2_BusinessManagers.js +105 -105
  72. package/models/Tier2_CreditLines.js +99 -99
  73. package/models/Tier2_Pages.js +91 -91
  74. package/models/Tier2_Pixels.js +82 -82
  75. package/models/Tier2_Tokens.js +64 -64
  76. package/models/Tier2_UserAdAccounts.js +83 -83
  77. package/models/TokenRotationState.js +121 -121
  78. package/models/TonicRSOCKeywordPerformance.js +122 -122
  79. package/models/Users.js +148 -148
  80. package/models/Vertical.js +25 -25
  81. package/models/newFiles.js +137 -137
  82. package/package.json +19 -21
  83. package/run.sh +214 -214
  84. package/services/sequelizeService.js +110 -110
@@ -1,126 +1,132 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const AdSetPerformance = sequelize.define(
3
- "AdSetPerformance",
4
- {
5
- AdSetID: {
6
- type: DataTypes.STRING,
7
- allowNull: false,
8
- primaryKey: true,
9
- // Part of the composite primary key identifying the AdSet
10
- },
11
- Date: {
12
- type: DataTypes.DATEONLY,
13
- allowNull: false,
14
- primaryKey: true,
15
- // Part of the composite primary key representing the performance date
16
- },
17
- ChannelID: {
18
- type: DataTypes.STRING,
19
- allowNull: true,
20
- // Optional identifier for the channel, extracted from AdSet name if available
21
- },
22
- StyleID: {
23
- type: DataTypes.STRING,
24
- allowNull: true,
25
- // Optional identifier for the style, extracted from AdSet name if available
26
- },
27
- Spend: {
28
- type: DataTypes.FLOAT,
29
- defaultValue: 0,
30
- // Total spend on the AdSet from the source platform (e.g., Facebook)
31
- },
32
- Impressions: {
33
- type: DataTypes.INTEGER,
34
- defaultValue: 0,
35
- // Number of impressions recorded by the source platform
36
- },
37
- LinkClicks: {
38
- type: DataTypes.INTEGER,
39
- defaultValue: 0,
40
- // Number of link clicks recorded by the source platform
41
- },
42
- ViewContent: {
43
- type: DataTypes.INTEGER,
44
- defaultValue: 0,
45
- // Number of view content events recorded by the source platform
46
- },
47
- Search: {
48
- type: DataTypes.INTEGER,
49
- defaultValue: 0,
50
- // Number of search events recorded by the source platform
51
- },
52
- Purchase: {
53
- type: DataTypes.INTEGER,
54
- defaultValue: 0,
55
- // Number of purchase events recorded by the source platform
56
- },
57
- Lead: {
58
- type: DataTypes.INTEGER,
59
- defaultValue: 0,
60
- // Number of lead events recorded by the source platform
61
- },
62
- ExternalRevenue: {
63
- type: DataTypes.FLOAT,
64
- defaultValue: 0,
65
- // Revenue data from an external source (e.g., analytics or monetization platforms)
66
- },
67
- ExternalImpressions: {
68
- type: DataTypes.INTEGER,
69
- defaultValue: 0,
70
- // Number of impressions recorded by an external source
71
- },
72
- ExternalClicks: {
73
- type: DataTypes.INTEGER,
74
- defaultValue: 0,
75
- // Number of clicks recorded by an external source
76
- },
77
- Sessions: {
78
- type: DataTypes.INTEGER,
79
- defaultValue: 0,
80
- // Number of website sessions/visits generated from this AdSet
81
- },
82
- ExternalRequests: {
83
- type: DataTypes.INTEGER,
84
- defaultValue: 0,
85
- // Number of requests recorded by an external source
86
- },
87
- ROI: {
88
- type: DataTypes.FLOAT,
89
- defaultValue: 0,
90
- // Calculated Return on Investment (ExternalRevenue / Spend)
91
- },
92
- agrscid: {
93
- type: DataTypes.STRING,
94
- allowNull: true,
95
- // Optional identifier for the AdSet, extracted from AdSet url if available
96
- },
97
- originalRevenue: {
98
- type: DataTypes.FLOAT,
99
- defaultValue: 0,
100
- // Original revenue value before any modifications or calculations
101
- }
102
- },
103
- {
104
- tableName: "AdSetPerformance",
105
- timestamps: false, // No need for createdAt/updatedAt timestamps
106
- indexes: [
107
- {
108
- unique: true,
109
- fields: ["AdSetID", "Date"],
110
- // Composite unique index to ensure one record per AdSet per date
111
- },
112
- ],
113
- }
114
- );
115
-
116
- // Define associations with other models
117
- AdSetPerformance.associate = (models) => {
118
- AdSetPerformance.belongsTo(models.AdSet, {
119
- foreignKey: "AdSetID",
120
- targetKey: "AdSetID",
121
- // Links to the AdSet model for additional AdSet details
122
- });
123
- };
124
-
125
- return AdSetPerformance;
126
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const AdSetPerformance = sequelize.define(
3
+ "AdSetPerformance",
4
+ {
5
+ AdSetID: {
6
+ type: DataTypes.STRING,
7
+ allowNull: false,
8
+ primaryKey: true,
9
+ // Part of the composite primary key identifying the AdSet
10
+ },
11
+ Date: {
12
+ type: DataTypes.DATEONLY,
13
+ allowNull: false,
14
+ primaryKey: true,
15
+ // Part of the composite primary key representing the performance date
16
+ },
17
+ ChannelID: {
18
+ type: DataTypes.STRING,
19
+ allowNull: true,
20
+ // Optional identifier for the channel, extracted from AdSet name if available
21
+ },
22
+ StyleID: {
23
+ type: DataTypes.STRING,
24
+ allowNull: true,
25
+ // Optional identifier for the style, extracted from AdSet name if available
26
+ },
27
+ Spend: {
28
+ type: DataTypes.FLOAT,
29
+ defaultValue: 0,
30
+ // Total spend on the AdSet from the source platform (e.g., Facebook)
31
+ },
32
+ Impressions: {
33
+ type: DataTypes.INTEGER,
34
+ defaultValue: 0,
35
+ // Number of impressions recorded by the source platform
36
+ },
37
+ LinkClicks: {
38
+ type: DataTypes.INTEGER,
39
+ defaultValue: 0,
40
+ // Number of link clicks recorded by the source platform
41
+ },
42
+ ViewContent: {
43
+ type: DataTypes.INTEGER,
44
+ defaultValue: 0,
45
+ // Number of view content events recorded by the source platform
46
+ },
47
+ Search: {
48
+ type: DataTypes.INTEGER,
49
+ defaultValue: 0,
50
+ // Number of search events recorded by the source platform
51
+ },
52
+ Purchase: {
53
+ type: DataTypes.INTEGER,
54
+ defaultValue: 0,
55
+ // Number of purchase events recorded by the source platform
56
+ },
57
+ Lead: {
58
+ type: DataTypes.INTEGER,
59
+ defaultValue: 0,
60
+ // Number of lead events recorded by the source platform
61
+ },
62
+ ExternalRevenue: {
63
+ type: DataTypes.FLOAT,
64
+ defaultValue: 0,
65
+ // Revenue data from an external source (e.g., analytics or monetization platforms)
66
+ },
67
+ ExternalImpressions: {
68
+ type: DataTypes.INTEGER,
69
+ defaultValue: 0,
70
+ // Number of impressions recorded by an external source
71
+ },
72
+ ExternalClicks: {
73
+ type: DataTypes.INTEGER,
74
+ defaultValue: 0,
75
+ // Number of clicks recorded by an external source
76
+ },
77
+ Sessions: {
78
+ type: DataTypes.INTEGER,
79
+ defaultValue: 0,
80
+ // Number of website sessions/visits generated from this AdSet
81
+ },
82
+ ExternalRequests: {
83
+ type: DataTypes.INTEGER,
84
+ defaultValue: 0,
85
+ // Number of requests recorded by an external source
86
+ },
87
+ ROI: {
88
+ type: DataTypes.FLOAT,
89
+ defaultValue: 0,
90
+ // Calculated Return on Investment (ExternalRevenue / Spend)
91
+ },
92
+ agrscid: {
93
+ type: DataTypes.STRING,
94
+ allowNull: true,
95
+ // Optional identifier for the AdSet, extracted from AdSet url if available
96
+ },
97
+ originalRevenue: {
98
+ type: DataTypes.FLOAT,
99
+ defaultValue: 0,
100
+ // Original revenue value before any modifications or calculations
101
+ },
102
+ platform: {
103
+ type: DataTypes.ENUM("fb", "tt", "snp"),
104
+ allowNull: false,
105
+ defaultValue: "fb",
106
+ comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
107
+ }
108
+ },
109
+ {
110
+ tableName: "AdSetPerformance",
111
+ timestamps: false, // No need for createdAt/updatedAt timestamps
112
+ indexes: [
113
+ {
114
+ unique: true,
115
+ fields: ["AdSetID", "Date"],
116
+ // Composite unique index to ensure one record per AdSet per date
117
+ },
118
+ ],
119
+ }
120
+ );
121
+
122
+ // Define associations with other models
123
+ AdSetPerformance.associate = (models) => {
124
+ AdSetPerformance.belongsTo(models.AdSet, {
125
+ foreignKey: "AdSetID",
126
+ targetKey: "AdSetID",
127
+ // Links to the AdSet model for additional AdSet details
128
+ });
129
+ };
130
+
131
+ return AdSetPerformance;
132
+ };
@@ -1,150 +1,157 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const AiArticleRetryQueue = sequelize.define(
3
- "AiArticleRetryQueue",
4
- {
5
- id: {
6
- type: DataTypes.INTEGER,
7
- primaryKey: true,
8
- autoIncrement: true,
9
- },
10
- agrs_cid: {
11
- type: DataTypes.STRING(255),
12
- allowNull: false,
13
- field: "agrs_cid",
14
- comment: "AGRS Campaign ID (links to the campaign combo)",
15
- },
16
- process_id: {
17
- type: DataTypes.STRING(255),
18
- allowNull: true,
19
- field: "process_id",
20
- comment: "Root process_id from createAICampaign",
21
- },
22
- controller_process_id: {
23
- type: DataTypes.UUID,
24
- allowNull: true,
25
- field: "controller_process_id",
26
- comment: "Per-campaign process_id (for CampaignCreationLog)",
27
- },
28
- feed_provider: {
29
- type: DataTypes.STRING(100),
30
- allowNull: false,
31
- field: "feed_provider",
32
- comment: "Normalized feed name: Mine - RSOC, Predicto - RSOC, etc.",
33
- },
34
- article_creation_payload: {
35
- type: DataTypes.JSONB,
36
- allowNull: false,
37
- field: "article_creation_payload",
38
- comment: "Exact params to pass to createMineArticle/createPredictoArticle/etc.",
39
- },
40
- original_payload: {
41
- type: DataTypes.JSONB,
42
- allowNull: true,
43
- field: "original_payload",
44
- comment: "Full original_payload from createAICampaign (preset, feed config, AI settings, combo values)",
45
- },
46
- generated_assets: {
47
- type: DataTypes.JSONB,
48
- allowNull: true,
49
- field: "generated_assets",
50
- comment: "Already-generated assets: { headlines, primaryTexts, bannerFiles, keywords }",
51
- },
52
- campaign_context: {
53
- type: DataTypes.JSONB,
54
- allowNull: true,
55
- field: "campaign_context",
56
- comment: "Additional context needed to resume campaign flow after article succeeds",
57
- },
58
- status: {
59
- type: DataTypes.STRING(50),
60
- allowNull: false,
61
- defaultValue: "pending",
62
- validate: {
63
- isIn: [["pending", "processing", "completed", "failed", "abandoned"]],
64
- },
65
- },
66
- retry_count: {
67
- type: DataTypes.INTEGER,
68
- allowNull: false,
69
- defaultValue: 0,
70
- field: "retry_count",
71
- },
72
- max_retries: {
73
- type: DataTypes.INTEGER,
74
- allowNull: false,
75
- defaultValue: 10,
76
- field: "max_retries",
77
- },
78
- next_retry_at: {
79
- type: DataTypes.DATE,
80
- allowNull: false,
81
- field: "next_retry_at",
82
- comment: "When the next retry should be attempted",
83
- },
84
- last_error: {
85
- type: DataTypes.TEXT,
86
- allowNull: true,
87
- field: "last_error",
88
- },
89
- last_attempt_at: {
90
- type: DataTypes.DATE,
91
- allowNull: true,
92
- field: "last_attempt_at",
93
- },
94
- created_at: {
95
- type: DataTypes.DATE,
96
- allowNull: false,
97
- defaultValue: DataTypes.NOW,
98
- field: "created_at",
99
- },
100
- completed_at: {
101
- type: DataTypes.DATE,
102
- allowNull: true,
103
- field: "completed_at",
104
- },
105
- article_id: {
106
- type: DataTypes.STRING(255),
107
- allowNull: true,
108
- field: "article_id",
109
- comment: "AGRSAID of created article (populated on success)",
110
- },
111
- article_url: {
112
- type: DataTypes.TEXT,
113
- allowNull: true,
114
- field: "article_url",
115
- comment: "URL of created article (populated on success)",
116
- },
117
- },
118
- {
119
- tableName: "ai_article_retry_queue",
120
- timestamps: false,
121
- indexes: [
122
- {
123
- fields: ["status", "next_retry_at"],
124
- name: "idx_article_retry_status_next",
125
- },
126
- {
127
- fields: ["agrs_cid"],
128
- },
129
- {
130
- fields: ["feed_provider"],
131
- },
132
- {
133
- fields: ["process_id"],
134
- },
135
- {
136
- fields: ["controller_process_id"],
137
- },
138
- {
139
- fields: ["created_at"],
140
- },
141
- ],
142
- }
143
- );
144
-
145
- AiArticleRetryQueue.associate = (models) => {
146
- // No associations needed for now
147
- };
148
-
149
- return AiArticleRetryQueue;
150
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const AiArticleRetryQueue = sequelize.define(
3
+ "AiArticleRetryQueue",
4
+ {
5
+ id: {
6
+ type: DataTypes.INTEGER,
7
+ primaryKey: true,
8
+ autoIncrement: true,
9
+ },
10
+ agrs_cid: {
11
+ type: DataTypes.STRING(255),
12
+ allowNull: false,
13
+ field: "agrs_cid",
14
+ comment: "AGRS Campaign ID (links to the campaign combo)",
15
+ },
16
+ process_id: {
17
+ type: DataTypes.STRING(255),
18
+ allowNull: true,
19
+ field: "process_id",
20
+ comment: "Root process_id from createAICampaign",
21
+ },
22
+ controller_process_id: {
23
+ type: DataTypes.UUID,
24
+ allowNull: true,
25
+ field: "controller_process_id",
26
+ comment: "Per-campaign process_id (for CampaignCreationLog)",
27
+ },
28
+ feed_provider: {
29
+ type: DataTypes.STRING(100),
30
+ allowNull: false,
31
+ field: "feed_provider",
32
+ comment: "Normalized feed name: Mine - RSOC, Predicto - RSOC, etc.",
33
+ },
34
+ article_creation_payload: {
35
+ type: DataTypes.JSONB,
36
+ allowNull: false,
37
+ field: "article_creation_payload",
38
+ comment: "Exact params to pass to createMineArticle/createPredictoArticle/etc.",
39
+ },
40
+ original_payload: {
41
+ type: DataTypes.JSONB,
42
+ allowNull: true,
43
+ field: "original_payload",
44
+ comment: "Full original_payload from createAICampaign (preset, feed config, AI settings, combo values)",
45
+ },
46
+ generated_assets: {
47
+ type: DataTypes.JSONB,
48
+ allowNull: true,
49
+ field: "generated_assets",
50
+ comment: "Already-generated assets: { headlines, primaryTexts, bannerFiles, keywords }",
51
+ },
52
+ campaign_context: {
53
+ type: DataTypes.JSONB,
54
+ allowNull: true,
55
+ field: "campaign_context",
56
+ comment: "Additional context needed to resume campaign flow after article succeeds",
57
+ },
58
+ status: {
59
+ type: DataTypes.STRING(50),
60
+ allowNull: false,
61
+ defaultValue: "pending",
62
+ validate: {
63
+ isIn: [["pending", "processing", "completed", "failed", "abandoned"]],
64
+ },
65
+ },
66
+ retry_count: {
67
+ type: DataTypes.INTEGER,
68
+ allowNull: false,
69
+ defaultValue: 0,
70
+ field: "retry_count",
71
+ },
72
+ max_retries: {
73
+ type: DataTypes.INTEGER,
74
+ allowNull: false,
75
+ defaultValue: 10,
76
+ field: "max_retries",
77
+ },
78
+ next_retry_at: {
79
+ type: DataTypes.DATE,
80
+ allowNull: false,
81
+ field: "next_retry_at",
82
+ comment: "When the next retry should be attempted",
83
+ },
84
+ last_error: {
85
+ type: DataTypes.TEXT,
86
+ allowNull: true,
87
+ field: "last_error",
88
+ },
89
+ last_attempt_at: {
90
+ type: DataTypes.DATE,
91
+ allowNull: true,
92
+ field: "last_attempt_at",
93
+ },
94
+ created_at: {
95
+ type: DataTypes.DATE,
96
+ allowNull: false,
97
+ defaultValue: DataTypes.NOW,
98
+ field: "created_at",
99
+ },
100
+ completed_at: {
101
+ type: DataTypes.DATE,
102
+ allowNull: true,
103
+ field: "completed_at",
104
+ },
105
+ article_id: {
106
+ type: DataTypes.STRING(255),
107
+ allowNull: true,
108
+ field: "article_id",
109
+ comment: "AGRSAID of created article (populated on success)",
110
+ },
111
+ article_url: {
112
+ type: DataTypes.TEXT,
113
+ allowNull: true,
114
+ field: "article_url",
115
+ comment: "URL of created article (populated on success)",
116
+ },
117
+ platform: {
118
+ type: DataTypes.ENUM("fb", "tt", "snp"),
119
+ allowNull: false,
120
+ defaultValue: "fb",
121
+ field: "platform",
122
+ comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
123
+ },
124
+ },
125
+ {
126
+ tableName: "ai_article_retry_queue",
127
+ timestamps: false,
128
+ indexes: [
129
+ {
130
+ fields: ["status", "next_retry_at"],
131
+ name: "idx_article_retry_status_next",
132
+ },
133
+ {
134
+ fields: ["agrs_cid"],
135
+ },
136
+ {
137
+ fields: ["feed_provider"],
138
+ },
139
+ {
140
+ fields: ["process_id"],
141
+ },
142
+ {
143
+ fields: ["controller_process_id"],
144
+ },
145
+ {
146
+ fields: ["created_at"],
147
+ },
148
+ ],
149
+ }
150
+ );
151
+
152
+ AiArticleRetryQueue.associate = (models) => {
153
+ // No associations needed for now
154
+ };
155
+
156
+ return AiArticleRetryQueue;
157
+ };