agrs-sequelize-sdk 1.3.78 → 1.3.80

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 (63) 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/Article.js +196 -196
  14. package/models/AutomationRule.js +173 -173
  15. package/models/BannerTemplate.js +129 -129
  16. package/models/Buyers.js +25 -25
  17. package/models/Campaign.js +157 -157
  18. package/models/CampaignActionHistory.js +86 -86
  19. package/models/CampaignCreationLog.js +309 -309
  20. package/models/CampaignCreationLogV2.js +314 -314
  21. package/models/CampaignHistory.js +33 -33
  22. package/models/Channel.js +55 -55
  23. package/models/Domain.js +40 -35
  24. package/models/DynamicFeed.js +212 -212
  25. package/models/ExplorAdsChannel.js +61 -61
  26. package/models/Feed.js +33 -33
  27. package/models/FeedArticleConfiguration.js +80 -80
  28. package/models/FrontStoryChannel.js +59 -59
  29. package/models/FrontStoryChannelV2.js +60 -60
  30. package/models/GenericFlowRequest.js +114 -114
  31. package/models/MidoWebChannel.js +47 -47
  32. package/models/MineChannel.js +42 -42
  33. package/models/Pages.js +92 -92
  34. package/models/PipelineExecution.js +59 -59
  35. package/models/PolicyDogsCreativeCache.js +50 -50
  36. package/models/PolicyDogsImageCache.js +30 -30
  37. package/models/Presets.js +34 -34
  38. package/models/RSOCFeedCampaign.js +375 -375
  39. package/models/RsocKeywordPerformance.js +110 -110
  40. package/models/RuleAction.js +90 -90
  41. package/models/RuleCondition.js +137 -137
  42. package/models/RuleExecution.js +107 -107
  43. package/models/RulesValues.js +56 -56
  44. package/models/SupportedLocale.js +23 -23
  45. package/models/SyncHistory.js +249 -249
  46. package/models/TTQChannel.js +42 -42
  47. package/models/TemplateMetadata.js +260 -260
  48. package/models/Tier2_AdAccounts.js +110 -110
  49. package/models/Tier2_Assets.js +70 -70
  50. package/models/Tier2_BusinessManagers.js +105 -105
  51. package/models/Tier2_CreditLines.js +99 -99
  52. package/models/Tier2_Pages.js +91 -91
  53. package/models/Tier2_Pixels.js +82 -82
  54. package/models/Tier2_Tokens.js +64 -64
  55. package/models/Tier2_UserAdAccounts.js +83 -83
  56. package/models/TokenRotationState.js +121 -121
  57. package/models/TonicRSOCKeywordPerformance.js +122 -122
  58. package/models/Users.js +138 -138
  59. package/models/Vertical.js +25 -25
  60. package/models/newFiles.js +137 -137
  61. package/package.json +21 -19
  62. package/run.sh +214 -214
  63. package/services/sequelizeService.js +110 -110
@@ -1,17 +1,17 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- up: async (queryInterface, Sequelize) => {
5
- await queryInterface.addColumn("articles", "requestedFromDashboard", {
6
- type: Sequelize.BOOLEAN,
7
- allowNull: false,
8
- defaultValue: false,
9
- comment:
10
- "Indicates if the article was created through our dashboard (true) or imported from external sources (false)",
11
- });
12
- },
13
-
14
- down: async (queryInterface, Sequelize) => {
15
- await queryInterface.removeColumn("articles", "requestedFromDashboard");
16
- },
17
- };
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ await queryInterface.addColumn("articles", "requestedFromDashboard", {
6
+ type: Sequelize.BOOLEAN,
7
+ allowNull: false,
8
+ defaultValue: false,
9
+ comment:
10
+ "Indicates if the article was created through our dashboard (true) or imported from external sources (false)",
11
+ });
12
+ },
13
+
14
+ down: async (queryInterface, Sequelize) => {
15
+ await queryInterface.removeColumn("articles", "requestedFromDashboard");
16
+ },
17
+ };
@@ -1,79 +1,79 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- up: async (queryInterface, Sequelize) => {
5
- // Change AdSetName column from VARCHAR(255) to TEXT
6
- // This is a SAFE operation - PostgreSQL can convert VARCHAR to TEXT without data loss
7
- // All existing data will be preserved
8
-
9
- // First, check if column exists and get its current type
10
- const [columns] = await queryInterface.sequelize.query(`
11
- SELECT column_name, data_type, character_maximum_length
12
- FROM information_schema.columns
13
- WHERE table_name = 'AdSet' AND column_name = 'AdSetName'
14
- `);
15
-
16
- if (columns.length === 0) {
17
- console.log("⚠️ AdSetName column not found, skipping migration");
18
- return;
19
- }
20
-
21
- const currentType = columns[0].data_type;
22
- const currentMaxLength = columns[0].character_maximum_length;
23
-
24
- console.log(
25
- `Current AdSetName type: ${currentType}(${
26
- currentMaxLength || "unlimited"
27
- })`
28
- );
29
-
30
- // Only change if it's currently VARCHAR with length limit
31
- if (currentType === "character varying" && currentMaxLength) {
32
- console.log("Converting AdSetName from VARCHAR to TEXT...");
33
-
34
- // Use direct SQL for more control
35
- await queryInterface.sequelize.query(`
36
- ALTER TABLE "AdSet"
37
- ALTER COLUMN "AdSetName" TYPE TEXT
38
- USING "AdSetName"::TEXT
39
- `);
40
-
41
- console.log("✅ AdSetName successfully converted to TEXT");
42
- } else if (currentType === "text") {
43
- console.log("✅ AdSetName is already TEXT, no change needed");
44
- } else {
45
- console.log(`⚠️ AdSetName is ${currentType}, not changing`);
46
- }
47
- },
48
-
49
- down: async (queryInterface, Sequelize) => {
50
- // Revert back to VARCHAR(255)
51
- // WARNING: This might truncate existing long values if any exist
52
- console.log(
53
- "⚠️ Reverting AdSetName to VARCHAR(255) - this may truncate long values!"
54
- );
55
-
56
- // Check for any values longer than 255 characters
57
- const [longValues] = await queryInterface.sequelize.query(`
58
- SELECT COUNT(*) as count
59
- FROM "AdSet"
60
- WHERE LENGTH("AdSetName") > 255
61
- `);
62
-
63
- if (longValues[0].count > 0) {
64
- console.log(
65
- `⚠️ WARNING: ${longValues[0].count} rows have AdSetName longer than 255 characters!`
66
- );
67
- console.log(
68
- "⚠️ These will be truncated if you proceed with the down migration."
69
- );
70
- }
71
-
72
- await queryInterface.changeColumn("AdSet", "AdSetName", {
73
- type: Sequelize.STRING(255),
74
- allowNull: true,
75
- });
76
-
77
- console.log("✅ AdSetName reverted to VARCHAR(255)");
78
- },
79
- };
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ // Change AdSetName column from VARCHAR(255) to TEXT
6
+ // This is a SAFE operation - PostgreSQL can convert VARCHAR to TEXT without data loss
7
+ // All existing data will be preserved
8
+
9
+ // First, check if column exists and get its current type
10
+ const [columns] = await queryInterface.sequelize.query(`
11
+ SELECT column_name, data_type, character_maximum_length
12
+ FROM information_schema.columns
13
+ WHERE table_name = 'AdSet' AND column_name = 'AdSetName'
14
+ `);
15
+
16
+ if (columns.length === 0) {
17
+ console.log("⚠️ AdSetName column not found, skipping migration");
18
+ return;
19
+ }
20
+
21
+ const currentType = columns[0].data_type;
22
+ const currentMaxLength = columns[0].character_maximum_length;
23
+
24
+ console.log(
25
+ `Current AdSetName type: ${currentType}(${
26
+ currentMaxLength || "unlimited"
27
+ })`
28
+ );
29
+
30
+ // Only change if it's currently VARCHAR with length limit
31
+ if (currentType === "character varying" && currentMaxLength) {
32
+ console.log("Converting AdSetName from VARCHAR to TEXT...");
33
+
34
+ // Use direct SQL for more control
35
+ await queryInterface.sequelize.query(`
36
+ ALTER TABLE "AdSet"
37
+ ALTER COLUMN "AdSetName" TYPE TEXT
38
+ USING "AdSetName"::TEXT
39
+ `);
40
+
41
+ console.log("✅ AdSetName successfully converted to TEXT");
42
+ } else if (currentType === "text") {
43
+ console.log("✅ AdSetName is already TEXT, no change needed");
44
+ } else {
45
+ console.log(`⚠️ AdSetName is ${currentType}, not changing`);
46
+ }
47
+ },
48
+
49
+ down: async (queryInterface, Sequelize) => {
50
+ // Revert back to VARCHAR(255)
51
+ // WARNING: This might truncate existing long values if any exist
52
+ console.log(
53
+ "⚠️ Reverting AdSetName to VARCHAR(255) - this may truncate long values!"
54
+ );
55
+
56
+ // Check for any values longer than 255 characters
57
+ const [longValues] = await queryInterface.sequelize.query(`
58
+ SELECT COUNT(*) as count
59
+ FROM "AdSet"
60
+ WHERE LENGTH("AdSetName") > 255
61
+ `);
62
+
63
+ if (longValues[0].count > 0) {
64
+ console.log(
65
+ `⚠️ WARNING: ${longValues[0].count} rows have AdSetName longer than 255 characters!`
66
+ );
67
+ console.log(
68
+ "⚠️ These will be truncated if you proceed with the down migration."
69
+ );
70
+ }
71
+
72
+ await queryInterface.changeColumn("AdSet", "AdSetName", {
73
+ type: Sequelize.STRING(255),
74
+ allowNull: true,
75
+ });
76
+
77
+ console.log("✅ AdSetName reverted to VARCHAR(255)");
78
+ },
79
+ };
@@ -1,137 +1,137 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const AICampaignQueue = sequelize.define(
3
- "AICampaignQueue",
4
- {
5
- id: {
6
- type: DataTypes.INTEGER,
7
- primaryKey: true,
8
- autoIncrement: true,
9
- },
10
- article_id: {
11
- type: DataTypes.STRING(255),
12
- allowNull: false,
13
- field: "article_id",
14
- },
15
- feed_provider: {
16
- type: DataTypes.STRING(100),
17
- allowNull: false,
18
- field: "feed_provider",
19
- },
20
- payload: {
21
- type: DataTypes.JSONB,
22
- allowNull: false,
23
- },
24
- status: {
25
- type: DataTypes.STRING(50),
26
- allowNull: false,
27
- defaultValue: "pending",
28
- validate: {
29
- isIn: [["pending", "processing", "completed", "failed"]],
30
- },
31
- },
32
- created_at: {
33
- type: DataTypes.DATE,
34
- allowNull: false,
35
- defaultValue: DataTypes.NOW,
36
- field: "created_at",
37
- },
38
- processed_at: {
39
- type: DataTypes.DATE,
40
- allowNull: true,
41
- field: "processed_at",
42
- },
43
- retry_count: {
44
- type: DataTypes.INTEGER,
45
- allowNull: false,
46
- defaultValue: 0,
47
- field: "retry_count",
48
- },
49
- error_message: {
50
- type: DataTypes.TEXT,
51
- allowNull: true,
52
- field: "error_message",
53
- },
54
- facebook_campaign_id: {
55
- type: DataTypes.STRING(255),
56
- allowNull: true,
57
- field: "facebook_campaign_id",
58
- },
59
- process_id: {
60
- type: DataTypes.STRING(255),
61
- allowNull: true,
62
- field: "process_id",
63
- },
64
- creation_logs_process_id: {
65
- type: DataTypes.UUID,
66
- allowNull: true,
67
- field: "creation_logs_process_id",
68
- comment: "Process ID from CampaignCreationLogV2 (UUID)",
69
- },
70
- agrs_cid: {
71
- type: DataTypes.STRING(255),
72
- allowNull: true,
73
- field: "agrs_cid",
74
- comment: "AGRS Campaign ID",
75
- },
76
- preset_id: {
77
- type: DataTypes.STRING(255),
78
- allowNull: true,
79
- field: "preset_id",
80
- comment: "Preset ID",
81
- },
82
- article_creation_payload: {
83
- type: DataTypes.JSONB,
84
- allowNull: true,
85
- field: "article_creation_payload",
86
- comment: "Payload sent for article creation (Mine/Predicto/Mobitech specific parameters)",
87
- },
88
- original_payload: {
89
- type: DataTypes.JSONB,
90
- allowNull: true,
91
- field: "original_payload",
92
- comment: "Original createAICampaign request params for this campaign (preset, feed config, AI settings, combo values)",
93
- },
94
- },
95
- {
96
- tableName: "ai_campaign_queue",
97
- timestamps: false, // We manage created_at manually
98
- indexes: [
99
- {
100
- fields: ["status"],
101
- },
102
- {
103
- fields: ["article_id"],
104
- },
105
- {
106
- fields: ["created_at"],
107
- },
108
- {
109
- fields: ["feed_provider"],
110
- },
111
- {
112
- fields: ["process_id"],
113
- },
114
- {
115
- fields: ["creation_logs_process_id"],
116
- },
117
- {
118
- fields: ["agrs_cid"],
119
- },
120
- {
121
- fields: ["preset_id"],
122
- },
123
- ],
124
- }
125
- );
126
-
127
- AICampaignQueue.associate = (models) => {
128
- // Optional: Add association to Article model if needed
129
- // AICampaignQueue.belongsTo(models.Article, {
130
- // foreignKey: "article_id",
131
- // targetKey: "AGRSAID",
132
- // as: "Article",
133
- // });
134
- };
135
-
136
- return AICampaignQueue;
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const AICampaignQueue = sequelize.define(
3
+ "AICampaignQueue",
4
+ {
5
+ id: {
6
+ type: DataTypes.INTEGER,
7
+ primaryKey: true,
8
+ autoIncrement: true,
9
+ },
10
+ article_id: {
11
+ type: DataTypes.STRING(255),
12
+ allowNull: false,
13
+ field: "article_id",
14
+ },
15
+ feed_provider: {
16
+ type: DataTypes.STRING(100),
17
+ allowNull: false,
18
+ field: "feed_provider",
19
+ },
20
+ payload: {
21
+ type: DataTypes.JSONB,
22
+ allowNull: false,
23
+ },
24
+ status: {
25
+ type: DataTypes.STRING(50),
26
+ allowNull: false,
27
+ defaultValue: "pending",
28
+ validate: {
29
+ isIn: [["pending", "processing", "completed", "failed"]],
30
+ },
31
+ },
32
+ created_at: {
33
+ type: DataTypes.DATE,
34
+ allowNull: false,
35
+ defaultValue: DataTypes.NOW,
36
+ field: "created_at",
37
+ },
38
+ processed_at: {
39
+ type: DataTypes.DATE,
40
+ allowNull: true,
41
+ field: "processed_at",
42
+ },
43
+ retry_count: {
44
+ type: DataTypes.INTEGER,
45
+ allowNull: false,
46
+ defaultValue: 0,
47
+ field: "retry_count",
48
+ },
49
+ error_message: {
50
+ type: DataTypes.TEXT,
51
+ allowNull: true,
52
+ field: "error_message",
53
+ },
54
+ facebook_campaign_id: {
55
+ type: DataTypes.STRING(255),
56
+ allowNull: true,
57
+ field: "facebook_campaign_id",
58
+ },
59
+ process_id: {
60
+ type: DataTypes.STRING(255),
61
+ allowNull: true,
62
+ field: "process_id",
63
+ },
64
+ creation_logs_process_id: {
65
+ type: DataTypes.UUID,
66
+ allowNull: true,
67
+ field: "creation_logs_process_id",
68
+ comment: "Process ID from CampaignCreationLogV2 (UUID)",
69
+ },
70
+ agrs_cid: {
71
+ type: DataTypes.STRING(255),
72
+ allowNull: true,
73
+ field: "agrs_cid",
74
+ comment: "AGRS Campaign ID",
75
+ },
76
+ preset_id: {
77
+ type: DataTypes.STRING(255),
78
+ allowNull: true,
79
+ field: "preset_id",
80
+ comment: "Preset ID",
81
+ },
82
+ article_creation_payload: {
83
+ type: DataTypes.JSONB,
84
+ allowNull: true,
85
+ field: "article_creation_payload",
86
+ comment: "Payload sent for article creation (Mine/Predicto/Mobitech specific parameters)",
87
+ },
88
+ original_payload: {
89
+ type: DataTypes.JSONB,
90
+ allowNull: true,
91
+ field: "original_payload",
92
+ comment: "Original createAICampaign request params for this campaign (preset, feed config, AI settings, combo values)",
93
+ },
94
+ },
95
+ {
96
+ tableName: "ai_campaign_queue",
97
+ timestamps: false, // We manage created_at manually
98
+ indexes: [
99
+ {
100
+ fields: ["status"],
101
+ },
102
+ {
103
+ fields: ["article_id"],
104
+ },
105
+ {
106
+ fields: ["created_at"],
107
+ },
108
+ {
109
+ fields: ["feed_provider"],
110
+ },
111
+ {
112
+ fields: ["process_id"],
113
+ },
114
+ {
115
+ fields: ["creation_logs_process_id"],
116
+ },
117
+ {
118
+ fields: ["agrs_cid"],
119
+ },
120
+ {
121
+ fields: ["preset_id"],
122
+ },
123
+ ],
124
+ }
125
+ );
126
+
127
+ AICampaignQueue.associate = (models) => {
128
+ // Optional: Add association to Article model if needed
129
+ // AICampaignQueue.belongsTo(models.Article, {
130
+ // foreignKey: "article_id",
131
+ // targetKey: "AGRSAID",
132
+ // as: "Article",
133
+ // });
134
+ };
135
+
136
+ return AICampaignQueue;
137
137
  };
@@ -1,85 +1,85 @@
1
- /**
2
- * AI Generation Log Model
3
- *
4
- * Stores detailed logs for each step of the generation process.
5
- * Useful for debugging and monitoring.
6
- */
7
-
8
- module.exports = (sequelize, DataTypes) => {
9
- const AIGenerationLog = sequelize.define(
10
- "AIGenerationLog",
11
- {
12
- id: {
13
- type: DataTypes.UUID,
14
- defaultValue: DataTypes.UUIDV4,
15
- primaryKey: true,
16
- },
17
- requestId: {
18
- type: DataTypes.STRING,
19
- allowNull: false,
20
- comment: "Reference to AIGenerationRequest.requestId",
21
- indexes: [
22
- {
23
- fields: ["requestId"],
24
- },
25
- ],
26
- },
27
- step: {
28
- type: DataTypes.STRING,
29
- allowNull: false,
30
- comment:
31
- "Step name: parsing, prompt_generation, image_generation, storage, logging",
32
- },
33
- level: {
34
- type: DataTypes.ENUM("info", "warning", "error", "success"),
35
- allowNull: false,
36
- defaultValue: "info",
37
- comment: "Log level",
38
- },
39
- message: {
40
- type: DataTypes.TEXT,
41
- allowNull: false,
42
- comment: "Log message",
43
- },
44
- data: {
45
- type: DataTypes.JSONB,
46
- allowNull: true,
47
- comment: "Additional log data (JSON)",
48
- },
49
- duration: {
50
- type: DataTypes.INTEGER,
51
- allowNull: true,
52
- comment: "Step duration in milliseconds",
53
- },
54
- },
55
- {
56
- tableName: "ai_generation_logs",
57
- timestamps: true,
58
- createdAt: "createdAt",
59
- updatedAt: false, // Logs are immutable
60
- indexes: [
61
- {
62
- fields: ["requestId", "step"],
63
- },
64
- {
65
- fields: ["level"],
66
- },
67
- {
68
- fields: ["createdAt"],
69
- },
70
- ],
71
- }
72
- );
73
-
74
- // Associations
75
- AIGenerationLog.associate = function (models) {
76
- // Each log belongs to a request
77
- AIGenerationLog.belongsTo(models.AIGenerationRequest, {
78
- foreignKey: "requestId",
79
- targetKey: "requestId",
80
- as: "request",
81
- });
82
- };
83
-
84
- return AIGenerationLog;
85
- };
1
+ /**
2
+ * AI Generation Log Model
3
+ *
4
+ * Stores detailed logs for each step of the generation process.
5
+ * Useful for debugging and monitoring.
6
+ */
7
+
8
+ module.exports = (sequelize, DataTypes) => {
9
+ const AIGenerationLog = sequelize.define(
10
+ "AIGenerationLog",
11
+ {
12
+ id: {
13
+ type: DataTypes.UUID,
14
+ defaultValue: DataTypes.UUIDV4,
15
+ primaryKey: true,
16
+ },
17
+ requestId: {
18
+ type: DataTypes.STRING,
19
+ allowNull: false,
20
+ comment: "Reference to AIGenerationRequest.requestId",
21
+ indexes: [
22
+ {
23
+ fields: ["requestId"],
24
+ },
25
+ ],
26
+ },
27
+ step: {
28
+ type: DataTypes.STRING,
29
+ allowNull: false,
30
+ comment:
31
+ "Step name: parsing, prompt_generation, image_generation, storage, logging",
32
+ },
33
+ level: {
34
+ type: DataTypes.ENUM("info", "warning", "error", "success"),
35
+ allowNull: false,
36
+ defaultValue: "info",
37
+ comment: "Log level",
38
+ },
39
+ message: {
40
+ type: DataTypes.TEXT,
41
+ allowNull: false,
42
+ comment: "Log message",
43
+ },
44
+ data: {
45
+ type: DataTypes.JSONB,
46
+ allowNull: true,
47
+ comment: "Additional log data (JSON)",
48
+ },
49
+ duration: {
50
+ type: DataTypes.INTEGER,
51
+ allowNull: true,
52
+ comment: "Step duration in milliseconds",
53
+ },
54
+ },
55
+ {
56
+ tableName: "ai_generation_logs",
57
+ timestamps: true,
58
+ createdAt: "createdAt",
59
+ updatedAt: false, // Logs are immutable
60
+ indexes: [
61
+ {
62
+ fields: ["requestId", "step"],
63
+ },
64
+ {
65
+ fields: ["level"],
66
+ },
67
+ {
68
+ fields: ["createdAt"],
69
+ },
70
+ ],
71
+ }
72
+ );
73
+
74
+ // Associations
75
+ AIGenerationLog.associate = function (models) {
76
+ // Each log belongs to a request
77
+ AIGenerationLog.belongsTo(models.AIGenerationRequest, {
78
+ foreignKey: "requestId",
79
+ targetKey: "requestId",
80
+ as: "request",
81
+ });
82
+ };
83
+
84
+ return AIGenerationLog;
85
+ };