agrs-sequelize-sdk 1.4.13 → 1.4.14

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 (65) hide show
  1. package/migrations/add-requested-from-dashboard-to-articles.js +17 -17
  2. package/migrations/change-adset-name-to-text.js +79 -79
  3. package/models/AICampaignQueue.js +136 -136
  4. package/models/AIGenerationLog.js +85 -85
  5. package/models/AIGenerationRequest.js +212 -212
  6. package/models/AdAccountValues.js +25 -25
  7. package/models/AdHistory.js +30 -30
  8. package/models/AdPerformance.js +94 -94
  9. package/models/AdSet.js +289 -289
  10. package/models/AdSetHistory.js +30 -30
  11. package/models/AdsetPerformance.js +126 -126
  12. package/models/AiArticleRetryQueue.js +150 -150
  13. package/models/AiCreationRetryQueue.js +127 -127
  14. package/models/Article.js +206 -206
  15. package/models/AutomationRule.js +173 -173
  16. package/models/BannerTemplate.js +129 -129
  17. package/models/Buyers.js +25 -25
  18. package/models/Campaign.js +157 -157
  19. package/models/CampaignActionHistory.js +86 -86
  20. package/models/CampaignCreationLog.js +309 -309
  21. package/models/CampaignCreationLogV2.js +314 -314
  22. package/models/CampaignHistory.js +33 -33
  23. package/models/Channel.js +55 -55
  24. package/models/Domain.js +43 -43
  25. package/models/DynamicFeed.js +212 -212
  26. package/models/ExplorAdsChannel.js +61 -61
  27. package/models/FacebookRetryQueue.js +156 -156
  28. package/models/Feed.js +33 -33
  29. package/models/FeedArticleConfiguration.js +80 -80
  30. package/models/FrontStoryChannel.js +59 -59
  31. package/models/FrontStoryChannelV2.js +60 -60
  32. package/models/GenericFlowRequest.js +114 -114
  33. package/models/MidoWebChannel.js +47 -47
  34. package/models/MineChannel.js +42 -42
  35. package/models/Pages.js +99 -99
  36. package/models/PipelineExecution.js +59 -59
  37. package/models/PolicyDogsCreativeCache.js +50 -50
  38. package/models/PolicyDogsImageCache.js +30 -30
  39. package/models/Presets.js +34 -34
  40. package/models/RSOCFeedCampaign.js +375 -375
  41. package/models/RsocKeywordPerformance.js +110 -110
  42. package/models/RuleAction.js +90 -90
  43. package/models/RuleCondition.js +137 -137
  44. package/models/RuleExecution.js +107 -107
  45. package/models/RulesValues.js +56 -56
  46. package/models/SupportedLocale.js +23 -23
  47. package/models/SyncHistory.js +249 -249
  48. package/models/TTQChannel.js +42 -42
  49. package/models/TemplateMetadata.js +260 -260
  50. package/models/Tier2_AdAccounts.js +110 -110
  51. package/models/Tier2_Assets.js +70 -70
  52. package/models/Tier2_BusinessManagers.js +105 -105
  53. package/models/Tier2_CreditLines.js +99 -99
  54. package/models/Tier2_Pages.js +91 -91
  55. package/models/Tier2_Pixels.js +82 -82
  56. package/models/Tier2_Tokens.js +64 -64
  57. package/models/Tier2_UserAdAccounts.js +83 -83
  58. package/models/TokenRotationState.js +121 -121
  59. package/models/TonicRSOCKeywordPerformance.js +122 -122
  60. package/models/Users.js +148 -148
  61. package/models/Vertical.js +25 -25
  62. package/models/newFiles.js +137 -137
  63. package/package.json +21 -19
  64. package/run.sh +214 -214
  65. package/services/sequelizeService.js +110 -110
@@ -1,62 +1,62 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const ExplorAdsChannel = sequelize.define(
3
- "ExplorAdsChannel",
4
- {
5
- channelId: {
6
- type: DataTypes.STRING,
7
- allowNull: false,
8
- validate: {
9
- // Validate channel format (br_vt_ch1401 to br_vt_ch1500)
10
- is: /^br_vt_ch(14[0-9][0-9]|1500)$/
11
- }
12
- },
13
- status: {
14
- type: DataTypes.STRING,
15
- allowNull: false,
16
- defaultValue: "free",
17
- validate: {
18
- isIn: [["free", "used", "archived"]],
19
- },
20
- },
21
- domain: {
22
- type: DataTypes.STRING,
23
- allowNull: false,
24
- defaultValue: "nexoreach.com"
25
- },
26
- connectedCampaigns: {
27
- type: DataTypes.JSONB,
28
- allowNull: false,
29
- defaultValue: [],
30
- },
31
- lastUsed: {
32
- type: DataTypes.DATE,
33
- allowNull: true
34
- }
35
- },
36
- {
37
- tableName: "explorads_channels",
38
- timestamps: true,
39
- indexes: [
40
- {
41
- unique: true,
42
- fields: ["channelId"],
43
- name: "unique_explorads_channel"
44
- },
45
- ],
46
- }
47
- );
48
-
49
- // Define associations
50
- ExplorAdsChannel.associate = (models) => {
51
- if (models.RSOCFeedCampaign) {
52
- ExplorAdsChannel.hasMany(models.RSOCFeedCampaign, {
53
- foreignKey: "channelId",
54
- sourceKey: "channelId",
55
- as: "RSOCFeedCampaigns",
56
- constraints: false, // Disable FK constraint
57
- });
58
- }
59
- };
60
-
61
- return ExplorAdsChannel;
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const ExplorAdsChannel = sequelize.define(
3
+ "ExplorAdsChannel",
4
+ {
5
+ channelId: {
6
+ type: DataTypes.STRING,
7
+ allowNull: false,
8
+ validate: {
9
+ // Validate channel format (br_vt_ch1401 to br_vt_ch1500)
10
+ is: /^br_vt_ch(14[0-9][0-9]|1500)$/
11
+ }
12
+ },
13
+ status: {
14
+ type: DataTypes.STRING,
15
+ allowNull: false,
16
+ defaultValue: "free",
17
+ validate: {
18
+ isIn: [["free", "used", "archived"]],
19
+ },
20
+ },
21
+ domain: {
22
+ type: DataTypes.STRING,
23
+ allowNull: false,
24
+ defaultValue: "nexoreach.com"
25
+ },
26
+ connectedCampaigns: {
27
+ type: DataTypes.JSONB,
28
+ allowNull: false,
29
+ defaultValue: [],
30
+ },
31
+ lastUsed: {
32
+ type: DataTypes.DATE,
33
+ allowNull: true
34
+ }
35
+ },
36
+ {
37
+ tableName: "explorads_channels",
38
+ timestamps: true,
39
+ indexes: [
40
+ {
41
+ unique: true,
42
+ fields: ["channelId"],
43
+ name: "unique_explorads_channel"
44
+ },
45
+ ],
46
+ }
47
+ );
48
+
49
+ // Define associations
50
+ ExplorAdsChannel.associate = (models) => {
51
+ if (models.RSOCFeedCampaign) {
52
+ ExplorAdsChannel.hasMany(models.RSOCFeedCampaign, {
53
+ foreignKey: "channelId",
54
+ sourceKey: "channelId",
55
+ as: "RSOCFeedCampaigns",
56
+ constraints: false, // Disable FK constraint
57
+ });
58
+ }
59
+ };
60
+
61
+ return ExplorAdsChannel;
62
62
  };
@@ -1,156 +1,156 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const FacebookRetryQueue = sequelize.define(
3
- "FacebookRetryQueue",
4
- {
5
- id: {
6
- type: DataTypes.INTEGER,
7
- primaryKey: true,
8
- autoIncrement: true,
9
- },
10
- process_id: {
11
- type: DataTypes.UUID,
12
- allowNull: false,
13
- field: "process_id",
14
- comment: "Process ID from the original campaign creation request",
15
- },
16
- feed_campaign_id: {
17
- type: DataTypes.STRING(255),
18
- allowNull: true,
19
- field: "feed_campaign_id",
20
- comment: "AGRS_CID from the feed campaign",
21
- },
22
- feed_provider: {
23
- type: DataTypes.STRING(100),
24
- allowNull: false,
25
- field: "feed_provider",
26
- },
27
- country_group: {
28
- type: DataTypes.JSONB,
29
- allowNull: false,
30
- field: "country_group",
31
- comment: 'Array of country codes, e.g. ["US"] or ["US", "GB"]',
32
- },
33
- campaign_name: {
34
- type: DataTypes.STRING(500),
35
- allowNull: true,
36
- field: "campaign_name",
37
- },
38
- account_id: {
39
- type: DataTypes.STRING(100),
40
- allowNull: true,
41
- field: "account_id",
42
- comment: "Facebook ad account ID",
43
- },
44
- original_request: {
45
- type: DataTypes.JSONB,
46
- allowNull: false,
47
- field: "original_request",
48
- comment: "Full campaignData from the original HTTP request",
49
- },
50
- facebook_payload: {
51
- type: DataTypes.JSONB,
52
- allowNull: false,
53
- field: "facebook_payload",
54
- comment:
55
- "facebookCampaignData passed to createFullCampaignController",
56
- },
57
- feed_campaign_result: {
58
- type: DataTypes.JSONB,
59
- allowNull: true,
60
- field: "feed_campaign_result",
61
- comment:
62
- "feedCampaign result (AGRS_CID, rac, urlTags, channelId, etc.)",
63
- },
64
- last_error: {
65
- type: DataTypes.TEXT,
66
- allowNull: true,
67
- field: "last_error",
68
- },
69
- last_error_code: {
70
- type: DataTypes.INTEGER,
71
- allowNull: true,
72
- field: "last_error_code",
73
- },
74
- is_transient: {
75
- type: DataTypes.BOOLEAN,
76
- allowNull: true,
77
- field: "is_transient",
78
- },
79
- status: {
80
- type: DataTypes.STRING(50),
81
- allowNull: false,
82
- defaultValue: "pending",
83
- validate: {
84
- isIn: [
85
- ["pending", "processing", "completed", "failed", "abandoned"],
86
- ],
87
- },
88
- },
89
- retry_count: {
90
- type: DataTypes.INTEGER,
91
- allowNull: false,
92
- defaultValue: 0,
93
- field: "retry_count",
94
- },
95
- max_retries: {
96
- type: DataTypes.INTEGER,
97
- allowNull: false,
98
- defaultValue: 5,
99
- field: "max_retries",
100
- },
101
- next_retry_at: {
102
- type: DataTypes.DATE,
103
- allowNull: false,
104
- field: "next_retry_at",
105
- comment: "When the next retry should be attempted",
106
- },
107
- last_attempt_at: {
108
- type: DataTypes.DATE,
109
- allowNull: true,
110
- field: "last_attempt_at",
111
- },
112
- completed_at: {
113
- type: DataTypes.DATE,
114
- allowNull: true,
115
- field: "completed_at",
116
- },
117
- facebook_campaign_id: {
118
- type: DataTypes.STRING(255),
119
- allowNull: true,
120
- field: "facebook_campaign_id",
121
- comment: "Facebook campaign ID (populated on success)",
122
- },
123
- created_at: {
124
- type: DataTypes.DATE,
125
- allowNull: false,
126
- defaultValue: DataTypes.NOW,
127
- field: "created_at",
128
- },
129
- },
130
- {
131
- tableName: "facebook_retry_queue",
132
- timestamps: false,
133
- indexes: [
134
- {
135
- fields: ["status", "next_retry_at"],
136
- name: "idx_fb_retry_status_next",
137
- },
138
- {
139
- fields: ["process_id"],
140
- },
141
- {
142
- fields: ["feed_provider"],
143
- },
144
- {
145
- fields: ["created_at"],
146
- },
147
- ],
148
- }
149
- );
150
-
151
- FacebookRetryQueue.associate = (models) => {
152
- // No associations needed
153
- };
154
-
155
- return FacebookRetryQueue;
156
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const FacebookRetryQueue = sequelize.define(
3
+ "FacebookRetryQueue",
4
+ {
5
+ id: {
6
+ type: DataTypes.INTEGER,
7
+ primaryKey: true,
8
+ autoIncrement: true,
9
+ },
10
+ process_id: {
11
+ type: DataTypes.UUID,
12
+ allowNull: false,
13
+ field: "process_id",
14
+ comment: "Process ID from the original campaign creation request",
15
+ },
16
+ feed_campaign_id: {
17
+ type: DataTypes.STRING(255),
18
+ allowNull: true,
19
+ field: "feed_campaign_id",
20
+ comment: "AGRS_CID from the feed campaign",
21
+ },
22
+ feed_provider: {
23
+ type: DataTypes.STRING(100),
24
+ allowNull: false,
25
+ field: "feed_provider",
26
+ },
27
+ country_group: {
28
+ type: DataTypes.JSONB,
29
+ allowNull: false,
30
+ field: "country_group",
31
+ comment: 'Array of country codes, e.g. ["US"] or ["US", "GB"]',
32
+ },
33
+ campaign_name: {
34
+ type: DataTypes.STRING(500),
35
+ allowNull: true,
36
+ field: "campaign_name",
37
+ },
38
+ account_id: {
39
+ type: DataTypes.STRING(100),
40
+ allowNull: true,
41
+ field: "account_id",
42
+ comment: "Facebook ad account ID",
43
+ },
44
+ original_request: {
45
+ type: DataTypes.JSONB,
46
+ allowNull: false,
47
+ field: "original_request",
48
+ comment: "Full campaignData from the original HTTP request",
49
+ },
50
+ facebook_payload: {
51
+ type: DataTypes.JSONB,
52
+ allowNull: false,
53
+ field: "facebook_payload",
54
+ comment:
55
+ "facebookCampaignData passed to createFullCampaignController",
56
+ },
57
+ feed_campaign_result: {
58
+ type: DataTypes.JSONB,
59
+ allowNull: true,
60
+ field: "feed_campaign_result",
61
+ comment:
62
+ "feedCampaign result (AGRS_CID, rac, urlTags, channelId, etc.)",
63
+ },
64
+ last_error: {
65
+ type: DataTypes.TEXT,
66
+ allowNull: true,
67
+ field: "last_error",
68
+ },
69
+ last_error_code: {
70
+ type: DataTypes.INTEGER,
71
+ allowNull: true,
72
+ field: "last_error_code",
73
+ },
74
+ is_transient: {
75
+ type: DataTypes.BOOLEAN,
76
+ allowNull: true,
77
+ field: "is_transient",
78
+ },
79
+ status: {
80
+ type: DataTypes.STRING(50),
81
+ allowNull: false,
82
+ defaultValue: "pending",
83
+ validate: {
84
+ isIn: [
85
+ ["pending", "processing", "completed", "failed", "abandoned"],
86
+ ],
87
+ },
88
+ },
89
+ retry_count: {
90
+ type: DataTypes.INTEGER,
91
+ allowNull: false,
92
+ defaultValue: 0,
93
+ field: "retry_count",
94
+ },
95
+ max_retries: {
96
+ type: DataTypes.INTEGER,
97
+ allowNull: false,
98
+ defaultValue: 5,
99
+ field: "max_retries",
100
+ },
101
+ next_retry_at: {
102
+ type: DataTypes.DATE,
103
+ allowNull: false,
104
+ field: "next_retry_at",
105
+ comment: "When the next retry should be attempted",
106
+ },
107
+ last_attempt_at: {
108
+ type: DataTypes.DATE,
109
+ allowNull: true,
110
+ field: "last_attempt_at",
111
+ },
112
+ completed_at: {
113
+ type: DataTypes.DATE,
114
+ allowNull: true,
115
+ field: "completed_at",
116
+ },
117
+ facebook_campaign_id: {
118
+ type: DataTypes.STRING(255),
119
+ allowNull: true,
120
+ field: "facebook_campaign_id",
121
+ comment: "Facebook campaign ID (populated on success)",
122
+ },
123
+ created_at: {
124
+ type: DataTypes.DATE,
125
+ allowNull: false,
126
+ defaultValue: DataTypes.NOW,
127
+ field: "created_at",
128
+ },
129
+ },
130
+ {
131
+ tableName: "facebook_retry_queue",
132
+ timestamps: false,
133
+ indexes: [
134
+ {
135
+ fields: ["status", "next_retry_at"],
136
+ name: "idx_fb_retry_status_next",
137
+ },
138
+ {
139
+ fields: ["process_id"],
140
+ },
141
+ {
142
+ fields: ["feed_provider"],
143
+ },
144
+ {
145
+ fields: ["created_at"],
146
+ },
147
+ ],
148
+ }
149
+ );
150
+
151
+ FacebookRetryQueue.associate = (models) => {
152
+ // No associations needed
153
+ };
154
+
155
+ return FacebookRetryQueue;
156
+ };
package/models/Feed.js CHANGED
@@ -1,34 +1,34 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const Feed = sequelize.define(
3
- "Feed",
4
- {
5
- id: {
6
- type: DataTypes.UUID,
7
- defaultValue: DataTypes.UUIDV4,
8
- primaryKey: true,
9
- },
10
- label: {
11
- type: DataTypes.STRING,
12
- allowNull: false,
13
- },
14
- code: {
15
- type: DataTypes.STRING,
16
- allowNull: false,
17
- unique: true,
18
- },
19
- sheet: {
20
- type: DataTypes.STRING,
21
- allowNull: false,
22
- },
23
- feedProvider: {
24
- type: DataTypes.STRING,
25
- allowNull: false,
26
- },
27
- },
28
- {
29
- tableName: "Feed",
30
- }
31
- );
32
-
33
- return Feed;
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const Feed = sequelize.define(
3
+ "Feed",
4
+ {
5
+ id: {
6
+ type: DataTypes.UUID,
7
+ defaultValue: DataTypes.UUIDV4,
8
+ primaryKey: true,
9
+ },
10
+ label: {
11
+ type: DataTypes.STRING,
12
+ allowNull: false,
13
+ },
14
+ code: {
15
+ type: DataTypes.STRING,
16
+ allowNull: false,
17
+ unique: true,
18
+ },
19
+ sheet: {
20
+ type: DataTypes.STRING,
21
+ allowNull: false,
22
+ },
23
+ feedProvider: {
24
+ type: DataTypes.STRING,
25
+ allowNull: false,
26
+ },
27
+ },
28
+ {
29
+ tableName: "Feed",
30
+ }
31
+ );
32
+
33
+ return Feed;
34
34
  };
@@ -1,81 +1,81 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const FeedArticleConfiguration = sequelize.define(
3
- "FeedArticleConfiguration",
4
- {
5
- id: {
6
- type: DataTypes.INTEGER,
7
- primaryKey: true,
8
- autoIncrement: true,
9
- },
10
- feedProvider: {
11
- type: DataTypes.STRING(100),
12
- allowNull: false,
13
- unique: true,
14
- field: "feed_provider",
15
- },
16
- requiredFields: {
17
- type: DataTypes.JSONB,
18
- allowNull: false,
19
- defaultValue: [],
20
- field: "required_fields",
21
- comment: "Array of field configs: [{ name, description, allowedValues }]"
22
- },
23
- model: {
24
- type: DataTypes.STRING(50),
25
- allowNull: false,
26
- defaultValue: "gpt-4o-mini",
27
- comment: "OpenAI model to use for this feed"
28
- },
29
- temperature: {
30
- type: DataTypes.FLOAT,
31
- allowNull: false,
32
- defaultValue: 0.7,
33
- comment: "Temperature for AI generation (0.0-1.0)"
34
- },
35
- baseUrl: {
36
- type: DataTypes.STRING(500),
37
- allowNull: true,
38
- field: "base_url",
39
- },
40
- isActive: {
41
- type: DataTypes.BOOLEAN,
42
- allowNull: false,
43
- defaultValue: true,
44
- field: "is_active",
45
- },
46
- createdAt: {
47
- type: DataTypes.DATE,
48
- allowNull: false,
49
- defaultValue: DataTypes.NOW,
50
- field: "created_at",
51
- },
52
- updatedAt: {
53
- type: DataTypes.DATE,
54
- allowNull: false,
55
- defaultValue: DataTypes.NOW,
56
- field: "updated_at",
57
- },
58
- },
59
- {
60
- tableName: "feed_article_configurations",
61
- timestamps: true,
62
- createdAt: "created_at",
63
- updatedAt: "updated_at",
64
- indexes: [
65
- {
66
- unique: true,
67
- fields: ["feed_provider"],
68
- },
69
- {
70
- fields: ["is_active"],
71
- },
72
- ],
73
- }
74
- );
75
-
76
- FeedArticleConfiguration.associate = (models) => {
77
- // Future: Add associations if needed
78
- };
79
-
80
- return FeedArticleConfiguration;
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const FeedArticleConfiguration = sequelize.define(
3
+ "FeedArticleConfiguration",
4
+ {
5
+ id: {
6
+ type: DataTypes.INTEGER,
7
+ primaryKey: true,
8
+ autoIncrement: true,
9
+ },
10
+ feedProvider: {
11
+ type: DataTypes.STRING(100),
12
+ allowNull: false,
13
+ unique: true,
14
+ field: "feed_provider",
15
+ },
16
+ requiredFields: {
17
+ type: DataTypes.JSONB,
18
+ allowNull: false,
19
+ defaultValue: [],
20
+ field: "required_fields",
21
+ comment: "Array of field configs: [{ name, description, allowedValues }]"
22
+ },
23
+ model: {
24
+ type: DataTypes.STRING(50),
25
+ allowNull: false,
26
+ defaultValue: "gpt-4o-mini",
27
+ comment: "OpenAI model to use for this feed"
28
+ },
29
+ temperature: {
30
+ type: DataTypes.FLOAT,
31
+ allowNull: false,
32
+ defaultValue: 0.7,
33
+ comment: "Temperature for AI generation (0.0-1.0)"
34
+ },
35
+ baseUrl: {
36
+ type: DataTypes.STRING(500),
37
+ allowNull: true,
38
+ field: "base_url",
39
+ },
40
+ isActive: {
41
+ type: DataTypes.BOOLEAN,
42
+ allowNull: false,
43
+ defaultValue: true,
44
+ field: "is_active",
45
+ },
46
+ createdAt: {
47
+ type: DataTypes.DATE,
48
+ allowNull: false,
49
+ defaultValue: DataTypes.NOW,
50
+ field: "created_at",
51
+ },
52
+ updatedAt: {
53
+ type: DataTypes.DATE,
54
+ allowNull: false,
55
+ defaultValue: DataTypes.NOW,
56
+ field: "updated_at",
57
+ },
58
+ },
59
+ {
60
+ tableName: "feed_article_configurations",
61
+ timestamps: true,
62
+ createdAt: "created_at",
63
+ updatedAt: "updated_at",
64
+ indexes: [
65
+ {
66
+ unique: true,
67
+ fields: ["feed_provider"],
68
+ },
69
+ {
70
+ fields: ["is_active"],
71
+ },
72
+ ],
73
+ }
74
+ );
75
+
76
+ FeedArticleConfiguration.associate = (models) => {
77
+ // Future: Add associations if needed
78
+ };
79
+
80
+ return FeedArticleConfiguration;
81
81
  };