agrs-sequelize-sdk 1.4.52 → 1.4.53

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 (116) hide show
  1. package/migrations/2026-05-17-PIXELS-FOLLOWUP.md +85 -85
  2. package/migrations/2026-05-17-add-platform-to-ad.js +19 -19
  3. package/migrations/2026-05-17-add-platform-to-adaccount.js +19 -19
  4. package/migrations/2026-05-17-add-platform-to-adperformance.js +19 -19
  5. package/migrations/2026-05-17-add-platform-to-adset.js +19 -19
  6. package/migrations/2026-05-17-add-platform-to-adsetperformance.js +19 -19
  7. package/migrations/2026-05-17-add-platform-to-aiarticleretryqueue.js +19 -19
  8. package/migrations/2026-05-17-add-platform-to-aicampaignqueue.js +19 -19
  9. package/migrations/2026-05-17-add-platform-to-article.js +19 -19
  10. package/migrations/2026-05-17-add-platform-to-campaign.js +19 -19
  11. package/migrations/2026-05-17-add-platform-to-codefuelcampaign.js +19 -19
  12. package/migrations/2026-05-17-add-platform-to-dynamicfeed.js +19 -19
  13. package/migrations/2026-05-17-add-platform-to-facebookretryqueue.js +19 -19
  14. package/migrations/2026-05-17-add-platform-to-pages.js +19 -19
  15. package/migrations/2026-05-17-add-platform-to-presets.js +19 -19
  16. package/migrations/2026-05-18-add-group-id-to-ai-campaign-queue.js +18 -18
  17. package/migrations/2026-05-18-add-platform-code-to-creation-logs.js +65 -65
  18. package/migrations/2026-05-18-add-platform-code-to-pixels.js +55 -55
  19. package/migrations/2026-05-18-add-platform-code-to-rsoc-feed-campaigns.js +55 -55
  20. package/migrations/2026-05-18-add-platform-date-index-to-adperformance.js +16 -16
  21. package/migrations/2026-05-18-add-platform-date-index-to-adsetperformance.js +16 -16
  22. package/migrations/2026-05-18-add-review-status-to-ad.js +36 -36
  23. package/migrations/2026-05-18-create-canonical-insights.js +84 -84
  24. package/migrations/2026-05-18-create-snapchat-public-profiles.js +68 -68
  25. package/migrations/2026-05-18-create-tiktok-identities.js +71 -71
  26. package/migrations/2026-05-18-create-tiktok-snapchat-campaigns.js +143 -143
  27. package/migrations/2026-05-18-create-tt-snp-adset-ad-tables.js +309 -309
  28. package/migrations/RUN_ME_MANUALLY_2026-05-17.sql +99 -99
  29. package/migrations/add-requested-from-dashboard-to-articles.js +17 -17
  30. package/migrations/change-adset-name-to-text.js +79 -79
  31. package/models/AICampaignQueue.js +152 -152
  32. package/models/AIGenerationLog.js +85 -85
  33. package/models/AIGenerationRequest.js +212 -212
  34. package/models/AdAccountValues.js +25 -25
  35. package/models/AdHistory.js +30 -30
  36. package/models/AdPerformance.js +104 -104
  37. package/models/AdSet.js +295 -295
  38. package/models/AdSetHistory.js +30 -30
  39. package/models/AdsetPerformance.js +137 -137
  40. package/models/AiArticleRetryQueue.js +157 -157
  41. package/models/AiCreationRetryQueue.js +134 -134
  42. package/models/ApiAuditLog.js +127 -127
  43. package/models/ApiToken.js +67 -67
  44. package/models/Article.js +222 -222
  45. package/models/AutomationRule.js +179 -179
  46. package/models/BannerTemplate.js +129 -129
  47. package/models/Buyers.js +25 -25
  48. package/models/Campaign.js +168 -163
  49. package/models/CampaignActionHistory.js +101 -101
  50. package/models/CampaignCreationLog.js +340 -340
  51. package/models/CampaignCreationLogV2.js +392 -392
  52. package/models/CampaignHistory.js +33 -33
  53. package/models/CampaignTag.js +46 -0
  54. package/models/CampaignTagAssignment.js +48 -0
  55. package/models/CanonicalInsights.js +68 -68
  56. package/models/Channel.js +55 -55
  57. package/models/Domain.js +44 -44
  58. package/models/DynamicFeed.js +218 -218
  59. package/models/ExplorAdsChannel.js +61 -61
  60. package/models/FacebookRetryQueue.js +163 -163
  61. package/models/Feed.js +33 -33
  62. package/models/FeedArticleConfiguration.js +80 -80
  63. package/models/FrontStoryChannel.js +59 -59
  64. package/models/FrontStoryChannelV2.js +60 -60
  65. package/models/GenericFlowRequest.js +114 -114
  66. package/models/MidoWebChannel.js +47 -47
  67. package/models/MineBrandBlocklist.js +40 -40
  68. package/models/MineChannel.js +42 -42
  69. package/models/MineRedirectDomain.js +36 -36
  70. package/models/MineWebhookEvent.js +53 -53
  71. package/models/Pages.js +117 -117
  72. package/models/PipelineExecution.js +59 -59
  73. package/models/PolicyDogsCreativeCache.js +50 -50
  74. package/models/PolicyDogsImageCache.js +30 -30
  75. package/models/Presets.js +40 -40
  76. package/models/PublicApiBatch.js +155 -155
  77. package/models/PublicApiBatchItem.js +166 -166
  78. package/models/PublicApiIdempotencyCache.js +135 -135
  79. package/models/RSOCFeedCampaign.js +387 -387
  80. package/models/RsocKeywordPerformance.js +110 -110
  81. package/models/RuleAction.js +90 -90
  82. package/models/RuleCondition.js +137 -137
  83. package/models/RuleExecution.js +107 -107
  84. package/models/RulesValues.js +56 -56
  85. package/models/SingularChannel.js +31 -31
  86. package/models/SnapchatAd.js +69 -69
  87. package/models/SnapchatAdSquad.js +92 -92
  88. package/models/SnapchatCampaign.js +69 -69
  89. package/models/SnapchatChannel.js +31 -31
  90. package/models/SnapchatPublicProfiles.js +67 -67
  91. package/models/SupportedLocale.js +23 -23
  92. package/models/SyncHistory.js +249 -249
  93. package/models/TTQChannel.js +42 -42
  94. package/models/TemplateMetadata.js +260 -260
  95. package/models/Tier2_AdAccounts.js +110 -110
  96. package/models/Tier2_Assets.js +70 -70
  97. package/models/Tier2_BusinessManagers.js +105 -105
  98. package/models/Tier2_CreditLines.js +99 -99
  99. package/models/Tier2_Pages.js +91 -91
  100. package/models/Tier2_Pixels.js +82 -82
  101. package/models/Tier2_Tokens.js +64 -64
  102. package/models/Tier2_UserAdAccounts.js +83 -83
  103. package/models/TikTokAd.js +71 -71
  104. package/models/TikTokAdGroup.js +82 -82
  105. package/models/TikTokCampaign.js +71 -71
  106. package/models/TiktokChannel.js +31 -31
  107. package/models/TiktokIdentities.js +65 -65
  108. package/models/TokenRotationState.js +121 -121
  109. package/models/TonicRSOCKeywordPerformance.js +122 -122
  110. package/models/Users.js +190 -185
  111. package/models/Vertical.js +25 -25
  112. package/models/newFiles.js +137 -137
  113. package/package.json +21 -19
  114. package/run.sh +214 -214
  115. package/services/sequelizeService.js +110 -110
  116. package/tarzo-skalio-integration-docs.md +691 -691
@@ -1,163 +1,168 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const Campaign = sequelize.define(
3
- "Campaign",
4
- {
5
- CampaignID: {
6
- type: DataTypes.STRING,
7
- primaryKey: true,
8
- },
9
- CampaignName: {
10
- type: DataTypes.TEXT,
11
- allowNull: true,
12
- },
13
- pixelId: {
14
- type: DataTypes.STRING,
15
- allowNull: true,
16
- },
17
- customEventType: {
18
- type: DataTypes.STRING,
19
- allowNull: false,
20
- defaultValue: "PURCHASE",
21
- },
22
- objective: {
23
- type: DataTypes.STRING,
24
- allowNull: false,
25
- defaultValue: "OUTCOME_SALES",
26
- },
27
- status: {
28
- type: DataTypes.STRING,
29
- allowNull: true,
30
- },
31
- AdAccountID: {
32
- type: DataTypes.STRING,
33
- allowNull: false,
34
- references: {
35
- model: "AdAccount",
36
- key: "AdAccountID",
37
- },
38
- },
39
- CreatedTime: {
40
- type: DataTypes.DATE,
41
- allowNull: false,
42
- },
43
- CampaignDelivery: {
44
- type: DataTypes.STRING,
45
- allowNull: true,
46
- },
47
- DailyBudget: {
48
- type: DataTypes.INTEGER,
49
- allowNull: true,
50
- },
51
- Draft: {
52
- type: DataTypes.BOOLEAN,
53
- allowNull: true,
54
- defaultValue: false,
55
- },
56
- publish: {
57
- type: DataTypes.BOOLEAN,
58
- allowNull: true,
59
- defaultValue: true,
60
- },
61
- UserCreated: {
62
- type: DataTypes.STRING,
63
- allowNull: true,
64
- },
65
- special_ad_categories: {
66
- type: DataTypes.ARRAY(DataTypes.STRING),
67
- allowNull: true,
68
- },
69
- effectiveStatus: {
70
- type: DataTypes.STRING,
71
- allowNull: true,
72
- },
73
- issuesInfo: {
74
- type: DataTypes.JSONB,
75
- allowNull: true,
76
- },
77
- waiting: {
78
- type: DataTypes.BOOLEAN,
79
- defaultValue: false,
80
- },
81
- policy_status: {
82
- type: DataTypes.STRING,
83
- allowNull: true,
84
- comment: "Facebook policy status: APPROVED, DENIED, PENDING, etc.",
85
- },
86
- policy_rejection_reason: {
87
- type: DataTypes.TEXT,
88
- allowNull: true,
89
- comment: "Detailed reason for policy rejection",
90
- },
91
- first_spend_date: {
92
- type: DataTypes.DATEONLY,
93
- allowNull: true,
94
- comment:
95
- "First date when campaign had spend > 0 (for accurate days_running calculation)",
96
- },
97
- platform: {
98
- type: DataTypes.ENUM("fb", "tt", "snp"),
99
- allowNull: false,
100
- defaultValue: "fb",
101
- comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
102
- },
103
- },
104
- {
105
- tableName: "Campaign",
106
- indexes: [
107
- {
108
- fields: ["AdAccountID"], // Index on AdAccountID for faster joins
109
- },
110
- {
111
- fields: ["first_spend_date"], // Index for days_running calculations
112
- },
113
- {
114
- fields: ["CampaignID", "first_spend_date"], // Composite index for performance queries
115
- },
116
- ],
117
- }
118
- );
119
-
120
- // Define associations
121
- Campaign.associate = (models) => {
122
- Campaign.belongsTo(models.AdAccount, { foreignKey: "AdAccountID" });
123
- Campaign.hasMany(models.AdSet, { foreignKey: "CampaignID" });
124
- };
125
-
126
- // Combined beforeUpdate hook
127
- Campaign.addHook("beforeUpdate", async (campaign, options) => {
128
- if (campaign.changed("publish")) {
129
- if (campaign.previous("publish") === true && campaign.publish === false) {
130
- // Save current state to CampaignHistory
131
- await sequelize.models.CampaignHistory.create({
132
- CampaignID: campaign.CampaignID,
133
- DataSnapshot: campaign._previousDataValues, // Store current state as JSON
134
- });
135
- } else if (
136
- campaign.previous("publish") === false &&
137
- campaign.publish === true
138
- ) {
139
- // Delete the latest history entry
140
- const latestHistory = await sequelize.models.CampaignHistory.findOne({
141
- where: { CampaignID: campaign.CampaignID },
142
- order: [["timestamp", "DESC"]], // Get the latest history entry
143
- });
144
-
145
- if (latestHistory) {
146
- await latestHistory.destroy(); // Delete the latest history entry
147
- }
148
- }
149
- }
150
- });
151
-
152
- Campaign.addHook("afterCreate", async (campaign, options) => {
153
- if (campaign.publish === false) {
154
- // If publish is false on creation, save a snapshot to CampaignHistory
155
- await sequelize.models.CampaignHistory.create({
156
- CampaignID: campaign.CampaignID,
157
- DataSnapshot: campaign.toJSON(), // Save current state
158
- });
159
- }
160
- });
161
-
162
- return Campaign;
163
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const Campaign = sequelize.define(
3
+ "Campaign",
4
+ {
5
+ CampaignID: {
6
+ type: DataTypes.STRING,
7
+ primaryKey: true,
8
+ },
9
+ CampaignName: {
10
+ type: DataTypes.TEXT,
11
+ allowNull: true,
12
+ },
13
+ pixelId: {
14
+ type: DataTypes.STRING,
15
+ allowNull: true,
16
+ },
17
+ customEventType: {
18
+ type: DataTypes.STRING,
19
+ allowNull: false,
20
+ defaultValue: "PURCHASE",
21
+ },
22
+ objective: {
23
+ type: DataTypes.STRING,
24
+ allowNull: false,
25
+ defaultValue: "OUTCOME_SALES",
26
+ },
27
+ status: {
28
+ type: DataTypes.STRING,
29
+ allowNull: true,
30
+ },
31
+ AdAccountID: {
32
+ type: DataTypes.STRING,
33
+ allowNull: false,
34
+ references: {
35
+ model: "AdAccount",
36
+ key: "AdAccountID",
37
+ },
38
+ },
39
+ CreatedTime: {
40
+ type: DataTypes.DATE,
41
+ allowNull: false,
42
+ },
43
+ CampaignDelivery: {
44
+ type: DataTypes.STRING,
45
+ allowNull: true,
46
+ },
47
+ DailyBudget: {
48
+ type: DataTypes.INTEGER,
49
+ allowNull: true,
50
+ },
51
+ Draft: {
52
+ type: DataTypes.BOOLEAN,
53
+ allowNull: true,
54
+ defaultValue: false,
55
+ },
56
+ publish: {
57
+ type: DataTypes.BOOLEAN,
58
+ allowNull: true,
59
+ defaultValue: true,
60
+ },
61
+ UserCreated: {
62
+ type: DataTypes.STRING,
63
+ allowNull: true,
64
+ },
65
+ special_ad_categories: {
66
+ type: DataTypes.ARRAY(DataTypes.STRING),
67
+ allowNull: true,
68
+ },
69
+ effectiveStatus: {
70
+ type: DataTypes.STRING,
71
+ allowNull: true,
72
+ },
73
+ issuesInfo: {
74
+ type: DataTypes.JSONB,
75
+ allowNull: true,
76
+ },
77
+ waiting: {
78
+ type: DataTypes.BOOLEAN,
79
+ defaultValue: false,
80
+ },
81
+ policy_status: {
82
+ type: DataTypes.STRING,
83
+ allowNull: true,
84
+ comment: "Facebook policy status: APPROVED, DENIED, PENDING, etc.",
85
+ },
86
+ policy_rejection_reason: {
87
+ type: DataTypes.TEXT,
88
+ allowNull: true,
89
+ comment: "Detailed reason for policy rejection",
90
+ },
91
+ first_spend_date: {
92
+ type: DataTypes.DATEONLY,
93
+ allowNull: true,
94
+ comment:
95
+ "First date when campaign had spend > 0 (for accurate days_running calculation)",
96
+ },
97
+ platform: {
98
+ type: DataTypes.ENUM("fb", "tt", "snp"),
99
+ allowNull: false,
100
+ defaultValue: "fb",
101
+ comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
102
+ },
103
+ },
104
+ {
105
+ tableName: "Campaign",
106
+ indexes: [
107
+ {
108
+ fields: ["AdAccountID"], // Index on AdAccountID for faster joins
109
+ },
110
+ {
111
+ fields: ["first_spend_date"], // Index for days_running calculations
112
+ },
113
+ {
114
+ fields: ["CampaignID", "first_spend_date"], // Composite index for performance queries
115
+ },
116
+ ],
117
+ }
118
+ );
119
+
120
+ // Define associations
121
+ Campaign.associate = (models) => {
122
+ Campaign.belongsTo(models.AdAccount, { foreignKey: "AdAccountID" });
123
+ Campaign.hasMany(models.AdSet, { foreignKey: "CampaignID" });
124
+ Campaign.hasMany(models.CampaignTagAssignment, {
125
+ foreignKey: "campaign_id",
126
+ sourceKey: "CampaignID",
127
+ as: "tagAssignments",
128
+ });
129
+ };
130
+
131
+ // Combined beforeUpdate hook
132
+ Campaign.addHook("beforeUpdate", async (campaign, options) => {
133
+ if (campaign.changed("publish")) {
134
+ if (campaign.previous("publish") === true && campaign.publish === false) {
135
+ // Save current state to CampaignHistory
136
+ await sequelize.models.CampaignHistory.create({
137
+ CampaignID: campaign.CampaignID,
138
+ DataSnapshot: campaign._previousDataValues, // Store current state as JSON
139
+ });
140
+ } else if (
141
+ campaign.previous("publish") === false &&
142
+ campaign.publish === true
143
+ ) {
144
+ // Delete the latest history entry
145
+ const latestHistory = await sequelize.models.CampaignHistory.findOne({
146
+ where: { CampaignID: campaign.CampaignID },
147
+ order: [["timestamp", "DESC"]], // Get the latest history entry
148
+ });
149
+
150
+ if (latestHistory) {
151
+ await latestHistory.destroy(); // Delete the latest history entry
152
+ }
153
+ }
154
+ }
155
+ });
156
+
157
+ Campaign.addHook("afterCreate", async (campaign, options) => {
158
+ if (campaign.publish === false) {
159
+ // If publish is false on creation, save a snapshot to CampaignHistory
160
+ await sequelize.models.CampaignHistory.create({
161
+ CampaignID: campaign.CampaignID,
162
+ DataSnapshot: campaign.toJSON(), // Save current state
163
+ });
164
+ }
165
+ });
166
+
167
+ return Campaign;
168
+ };
@@ -1,101 +1,101 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const CampaignActionHistory = sequelize.define(
3
- "CampaignActionHistory",
4
- {
5
- id: {
6
- type: DataTypes.UUID,
7
- defaultValue: DataTypes.UUIDV4,
8
- primaryKey: true,
9
- },
10
- objectId: {
11
- type: DataTypes.STRING,
12
- allowNull: false,
13
- comment:
14
- "ID of the object being tracked (campaignId, AGRSCID, adsetId, etc.)",
15
- index: true,
16
- },
17
- objectType: {
18
- type: DataTypes.ENUM("campaign", "agrscid", "adset", "ad"),
19
- allowNull: false,
20
- comment: "Type of object to know what objectId represents",
21
- index: true,
22
- },
23
- actionType: {
24
- type: DataTypes.STRING,
25
- allowNull: false,
26
- comment:
27
- "Type of action: budget_update, bid_update, keyword_update, duplicated, etc.",
28
- index: true,
29
- },
30
- previousValue: {
31
- type: DataTypes.JSON,
32
- allowNull: true,
33
- comment: "Previous value before the action",
34
- },
35
- newValue: {
36
- type: DataTypes.JSON,
37
- allowNull: true,
38
- comment: "New value after the action",
39
- },
40
- details: {
41
- type: DataTypes.JSON,
42
- allowNull: true,
43
- comment: "Additional context and metadata about the action",
44
- },
45
- userId: {
46
- type: DataTypes.STRING,
47
- allowNull: true,
48
- comment: "ID of the user who performed the action",
49
- },
50
- source: {
51
- type: DataTypes.STRING,
52
- allowNull: true,
53
- comment: "Origin of the change: ui | public_api | system",
54
- },
55
- correlationId: {
56
- type: DataTypes.STRING,
57
- allowNull: true,
58
- comment:
59
- "Correlation id (x-request-id / processId) linking changes made in one request or batch",
60
- },
61
- createdAt: {
62
- type: DataTypes.DATE,
63
- defaultValue: DataTypes.NOW,
64
- allowNull: false,
65
- index: true,
66
- },
67
- updatedAt: {
68
- type: DataTypes.DATE,
69
- defaultValue: DataTypes.NOW,
70
- },
71
- },
72
- {
73
- tableName: "CampaignActionHistories",
74
- timestamps: true,
75
- indexes: [
76
- {
77
- fields: ["objectId", "objectType"],
78
- name: "idx_object_id_type",
79
- },
80
- {
81
- fields: ["actionType"],
82
- name: "idx_action_type",
83
- },
84
- {
85
- fields: ["createdAt"],
86
- name: "idx_created_at",
87
- },
88
- {
89
- fields: ["objectId", "actionType"],
90
- name: "idx_object_action",
91
- },
92
- {
93
- fields: ["correlationId"],
94
- name: "idx_correlation_id",
95
- },
96
- ],
97
- }
98
- );
99
-
100
- return CampaignActionHistory;
101
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const CampaignActionHistory = sequelize.define(
3
+ "CampaignActionHistory",
4
+ {
5
+ id: {
6
+ type: DataTypes.UUID,
7
+ defaultValue: DataTypes.UUIDV4,
8
+ primaryKey: true,
9
+ },
10
+ objectId: {
11
+ type: DataTypes.STRING,
12
+ allowNull: false,
13
+ comment:
14
+ "ID of the object being tracked (campaignId, AGRSCID, adsetId, etc.)",
15
+ index: true,
16
+ },
17
+ objectType: {
18
+ type: DataTypes.ENUM("campaign", "agrscid", "adset", "ad"),
19
+ allowNull: false,
20
+ comment: "Type of object to know what objectId represents",
21
+ index: true,
22
+ },
23
+ actionType: {
24
+ type: DataTypes.STRING,
25
+ allowNull: false,
26
+ comment:
27
+ "Type of action: budget_update, bid_update, keyword_update, duplicated, etc.",
28
+ index: true,
29
+ },
30
+ previousValue: {
31
+ type: DataTypes.JSON,
32
+ allowNull: true,
33
+ comment: "Previous value before the action",
34
+ },
35
+ newValue: {
36
+ type: DataTypes.JSON,
37
+ allowNull: true,
38
+ comment: "New value after the action",
39
+ },
40
+ details: {
41
+ type: DataTypes.JSON,
42
+ allowNull: true,
43
+ comment: "Additional context and metadata about the action",
44
+ },
45
+ userId: {
46
+ type: DataTypes.STRING,
47
+ allowNull: true,
48
+ comment: "ID of the user who performed the action",
49
+ },
50
+ source: {
51
+ type: DataTypes.STRING,
52
+ allowNull: true,
53
+ comment: "Origin of the change: ui | public_api | system",
54
+ },
55
+ correlationId: {
56
+ type: DataTypes.STRING,
57
+ allowNull: true,
58
+ comment:
59
+ "Correlation id (x-request-id / processId) linking changes made in one request or batch",
60
+ },
61
+ createdAt: {
62
+ type: DataTypes.DATE,
63
+ defaultValue: DataTypes.NOW,
64
+ allowNull: false,
65
+ index: true,
66
+ },
67
+ updatedAt: {
68
+ type: DataTypes.DATE,
69
+ defaultValue: DataTypes.NOW,
70
+ },
71
+ },
72
+ {
73
+ tableName: "CampaignActionHistories",
74
+ timestamps: true,
75
+ indexes: [
76
+ {
77
+ fields: ["objectId", "objectType"],
78
+ name: "idx_object_id_type",
79
+ },
80
+ {
81
+ fields: ["actionType"],
82
+ name: "idx_action_type",
83
+ },
84
+ {
85
+ fields: ["createdAt"],
86
+ name: "idx_created_at",
87
+ },
88
+ {
89
+ fields: ["objectId", "actionType"],
90
+ name: "idx_object_action",
91
+ },
92
+ {
93
+ fields: ["correlationId"],
94
+ name: "idx_correlation_id",
95
+ },
96
+ ],
97
+ }
98
+ );
99
+
100
+ return CampaignActionHistory;
101
+ };