agrs-sequelize-sdk 1.2.86 → 1.2.87

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 (45) hide show
  1. package/migrations/add-requested-from-dashboard-to-articles.js +17 -17
  2. package/models/AdAccountValues.js +25 -25
  3. package/models/AdHistory.js +30 -30
  4. package/models/AdPerformance.js +89 -89
  5. package/models/AdSet.js +289 -289
  6. package/models/AdSetHistory.js +30 -30
  7. package/models/AdsetPerformance.js +126 -126
  8. package/models/Article.js +170 -170
  9. package/models/AutomationRule.js +127 -127
  10. package/models/Buyers.js +25 -25
  11. package/models/Campaign.js +145 -145
  12. package/models/CampaignCreationLog.js +280 -280
  13. package/models/CampaignHistory.js +33 -33
  14. package/models/Channel.js +55 -55
  15. package/models/Domain.js +25 -25
  16. package/models/DynamicFeed.js +89 -89
  17. package/models/ExplorAdsChannel.js +61 -61
  18. package/models/Feed.js +33 -33
  19. package/models/FrontStoryChannel.js +59 -59
  20. package/models/MineChannel.js +43 -0
  21. package/models/Pages.js +73 -73
  22. package/models/PipelineExecution.js +59 -59
  23. package/models/Presets.js +34 -34
  24. package/models/RSOCFeedCampaign.js +357 -357
  25. package/models/RsocKeywordPerformance.js +110 -110
  26. package/models/RuleAction.js +90 -90
  27. package/models/RuleCondition.js +98 -98
  28. package/models/RuleExecution.js +107 -107
  29. package/models/RulesValues.js +56 -56
  30. package/models/SupportedLocale.js +23 -23
  31. package/models/SyncHistory.js +249 -249
  32. package/models/Tier2_AdAccounts.js +110 -110
  33. package/models/Tier2_Assets.js +70 -70
  34. package/models/Tier2_BusinessManagers.js +105 -105
  35. package/models/Tier2_CreditLines.js +99 -99
  36. package/models/Tier2_Pages.js +91 -91
  37. package/models/Tier2_Pixels.js +82 -82
  38. package/models/Tier2_Tokens.js +64 -64
  39. package/models/Tier2_UserAdAccounts.js +83 -83
  40. package/models/TonicRSOCKeywordPerformance.js +122 -122
  41. package/models/Vertical.js +25 -25
  42. package/models/newFiles.js +110 -110
  43. package/package.json +21 -19
  44. package/run.sh +214 -214
  45. package/services/sequelizeService.js +63 -63
@@ -1,83 +1,83 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const Tier2_UserAdAccounts = sequelize.define(
3
- "Tier2_UserAdAccounts",
4
- {
5
- id: {
6
- type: DataTypes.UUID,
7
- defaultValue: DataTypes.UUIDV4,
8
- primaryKey: true,
9
- },
10
- userId: {
11
- type: DataTypes.STRING,
12
- allowNull: false,
13
- comment: "User ID (can be internal system ID or external ID)",
14
- },
15
- adAccountId: {
16
- type: DataTypes.UUID,
17
- allowNull: false,
18
- references: {
19
- model: "Tier2_AdAccounts",
20
- key: "id",
21
- },
22
- onUpdate: "CASCADE",
23
- onDelete: "CASCADE",
24
- },
25
- facebookAdAccountId: {
26
- type: DataTypes.STRING,
27
- allowNull: false,
28
- comment: "Facebook Ad Account ID (for quick reference)",
29
- },
30
- permissions: {
31
- type: DataTypes.ARRAY(DataTypes.STRING),
32
- allowNull: false,
33
- defaultValue: ["view", "create_campaigns", "view_performance"],
34
- comment:
35
- "Permissions: view, create_campaigns, edit_campaigns, view_performance, manage_assets",
36
- },
37
- assignedAt: {
38
- type: DataTypes.DATE,
39
- allowNull: false,
40
- defaultValue: DataTypes.NOW,
41
- },
42
- assignedBy: {
43
- type: DataTypes.STRING,
44
- allowNull: true,
45
- comment: "User ID who assigned this ad account",
46
- },
47
- status: {
48
- type: DataTypes.ENUM("active", "suspended", "revoked"),
49
- allowNull: false,
50
- defaultValue: "active",
51
- },
52
- },
53
- {
54
- tableName: "Tier2_UserAdAccounts",
55
- indexes: [
56
- {
57
- fields: ["userId"],
58
- },
59
- {
60
- fields: ["adAccountId"],
61
- },
62
- {
63
- fields: ["facebookAdAccountId"],
64
- },
65
- {
66
- unique: true,
67
- fields: ["userId", "adAccountId"],
68
- name: "unique_user_ad_account",
69
- },
70
- ],
71
- }
72
- );
73
-
74
- Tier2_UserAdAccounts.associate = (models) => {
75
- // Association with Tier2_AdAccounts
76
- Tier2_UserAdAccounts.belongsTo(models.Tier2_AdAccounts, {
77
- foreignKey: "adAccountId",
78
- as: "adAccount",
79
- });
80
- };
81
-
82
- return Tier2_UserAdAccounts;
83
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const Tier2_UserAdAccounts = sequelize.define(
3
+ "Tier2_UserAdAccounts",
4
+ {
5
+ id: {
6
+ type: DataTypes.UUID,
7
+ defaultValue: DataTypes.UUIDV4,
8
+ primaryKey: true,
9
+ },
10
+ userId: {
11
+ type: DataTypes.STRING,
12
+ allowNull: false,
13
+ comment: "User ID (can be internal system ID or external ID)",
14
+ },
15
+ adAccountId: {
16
+ type: DataTypes.UUID,
17
+ allowNull: false,
18
+ references: {
19
+ model: "Tier2_AdAccounts",
20
+ key: "id",
21
+ },
22
+ onUpdate: "CASCADE",
23
+ onDelete: "CASCADE",
24
+ },
25
+ facebookAdAccountId: {
26
+ type: DataTypes.STRING,
27
+ allowNull: false,
28
+ comment: "Facebook Ad Account ID (for quick reference)",
29
+ },
30
+ permissions: {
31
+ type: DataTypes.ARRAY(DataTypes.STRING),
32
+ allowNull: false,
33
+ defaultValue: ["view", "create_campaigns", "view_performance"],
34
+ comment:
35
+ "Permissions: view, create_campaigns, edit_campaigns, view_performance, manage_assets",
36
+ },
37
+ assignedAt: {
38
+ type: DataTypes.DATE,
39
+ allowNull: false,
40
+ defaultValue: DataTypes.NOW,
41
+ },
42
+ assignedBy: {
43
+ type: DataTypes.STRING,
44
+ allowNull: true,
45
+ comment: "User ID who assigned this ad account",
46
+ },
47
+ status: {
48
+ type: DataTypes.ENUM("active", "suspended", "revoked"),
49
+ allowNull: false,
50
+ defaultValue: "active",
51
+ },
52
+ },
53
+ {
54
+ tableName: "Tier2_UserAdAccounts",
55
+ indexes: [
56
+ {
57
+ fields: ["userId"],
58
+ },
59
+ {
60
+ fields: ["adAccountId"],
61
+ },
62
+ {
63
+ fields: ["facebookAdAccountId"],
64
+ },
65
+ {
66
+ unique: true,
67
+ fields: ["userId", "adAccountId"],
68
+ name: "unique_user_ad_account",
69
+ },
70
+ ],
71
+ }
72
+ );
73
+
74
+ Tier2_UserAdAccounts.associate = (models) => {
75
+ // Association with Tier2_AdAccounts
76
+ Tier2_UserAdAccounts.belongsTo(models.Tier2_AdAccounts, {
77
+ foreignKey: "adAccountId",
78
+ as: "adAccount",
79
+ });
80
+ };
81
+
82
+ return Tier2_UserAdAccounts;
83
+ };
@@ -1,123 +1,123 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const TonicRSOCKeywordPerformance = sequelize.define(
3
- "TonicRSOCKeywordPerformance",
4
- {
5
- Date: {
6
- type: DataTypes.DATEONLY,
7
- primaryKey: true,
8
- },
9
- adID: {
10
- type: DataTypes.STRING,
11
- references: {
12
- model: "Ad",
13
- key: "AdID",
14
- },
15
- foreignKey: true,
16
- primaryKey: true,
17
- },
18
- Keyword: {
19
- type: DataTypes.STRING,
20
- allowNull: false,
21
- primaryKey: true,
22
- },
23
- Country: {
24
- type: DataTypes.STRING,
25
- allowNull: false,
26
- primaryKey: true, // ✅ Country is now part of primary key
27
- },
28
- Revenue: {
29
- type: DataTypes.FLOAT,
30
- allowNull: false,
31
- },
32
- Clicks: {
33
- type: DataTypes.INTEGER,
34
- allowNull: false,
35
- },
36
- TemplatedKeyword: {
37
- type: DataTypes.STRING,
38
- allowNull: true,
39
- },
40
- FirstAppearanceDate: {
41
- type: DataTypes.DATEONLY,
42
- allowNull: true,
43
- },
44
- },
45
- {
46
- tableName: "TonicRSOCKeywordPerformance",
47
- indexes: [
48
- {
49
- unique: true,
50
- fields: ["Date", "adID", "Keyword", "Country"],
51
- name: "tonic_primary_idx" // ✅ Custom short name
52
- },
53
- {
54
- fields: ["Date"],
55
- name: "tonic_date_idx"
56
- },
57
- {
58
- fields: ["adID"],
59
- name: "tonic_adid_idx"
60
- },
61
- {
62
- fields: ["Keyword"],
63
- name: "tonic_keyword_idx"
64
- },
65
- {
66
- fields: ["Country"],
67
- name: "tonic_country_idx"
68
- },
69
- {
70
- fields: ["Revenue"],
71
- name: "tonic_revenue_idx"
72
- },
73
- {
74
- fields: ["Clicks"],
75
- name: "tonic_clicks_idx"
76
- },
77
- {
78
- fields: ["Country", "Date"],
79
- name: "tonic_country_date_idx"
80
- },
81
- {
82
- fields: ["Keyword", "Country"],
83
- name: "tonic_keyword_country_idx"
84
- },
85
- {
86
- fields: ["Date", "Revenue"],
87
- name: "tonic_date_revenue_idx"
88
- },
89
- ],
90
- hooks: {
91
- beforeCreate: async (record, options) => {
92
- try {
93
- const existingKeyword = await sequelize.models.TonicRSOCKeywordPerformance.findOne({
94
- where: {
95
- Keyword: sequelize.where(
96
- sequelize.fn("LOWER", sequelize.col("Keyword")),
97
- sequelize.fn("LOWER", record.Keyword)
98
- ),
99
- Country: record.Country,
100
- },
101
- attributes: ["FirstAppearanceDate"],
102
- transaction: options.transaction,
103
- });
104
-
105
- record.FirstAppearanceDate =
106
- existingKeyword?.FirstAppearanceDate || record.Date;
107
- } catch (error) {
108
- console.error("Error in TonicRSOCKeywordPerformance FirstAppearanceDate hook:", error);
109
- throw error;
110
- }
111
- },
112
- },
113
- }
114
- );
115
-
116
- TonicRSOCKeywordPerformance.associate = (models) => {
117
- TonicRSOCKeywordPerformance.belongsTo(models.Ad, {
118
- foreignKey: "adID",
119
- });
120
- };
121
-
122
- return TonicRSOCKeywordPerformance;
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const TonicRSOCKeywordPerformance = sequelize.define(
3
+ "TonicRSOCKeywordPerformance",
4
+ {
5
+ Date: {
6
+ type: DataTypes.DATEONLY,
7
+ primaryKey: true,
8
+ },
9
+ adID: {
10
+ type: DataTypes.STRING,
11
+ references: {
12
+ model: "Ad",
13
+ key: "AdID",
14
+ },
15
+ foreignKey: true,
16
+ primaryKey: true,
17
+ },
18
+ Keyword: {
19
+ type: DataTypes.STRING,
20
+ allowNull: false,
21
+ primaryKey: true,
22
+ },
23
+ Country: {
24
+ type: DataTypes.STRING,
25
+ allowNull: false,
26
+ primaryKey: true, // ✅ Country is now part of primary key
27
+ },
28
+ Revenue: {
29
+ type: DataTypes.FLOAT,
30
+ allowNull: false,
31
+ },
32
+ Clicks: {
33
+ type: DataTypes.INTEGER,
34
+ allowNull: false,
35
+ },
36
+ TemplatedKeyword: {
37
+ type: DataTypes.STRING,
38
+ allowNull: true,
39
+ },
40
+ FirstAppearanceDate: {
41
+ type: DataTypes.DATEONLY,
42
+ allowNull: true,
43
+ },
44
+ },
45
+ {
46
+ tableName: "TonicRSOCKeywordPerformance",
47
+ indexes: [
48
+ {
49
+ unique: true,
50
+ fields: ["Date", "adID", "Keyword", "Country"],
51
+ name: "tonic_primary_idx" // ✅ Custom short name
52
+ },
53
+ {
54
+ fields: ["Date"],
55
+ name: "tonic_date_idx"
56
+ },
57
+ {
58
+ fields: ["adID"],
59
+ name: "tonic_adid_idx"
60
+ },
61
+ {
62
+ fields: ["Keyword"],
63
+ name: "tonic_keyword_idx"
64
+ },
65
+ {
66
+ fields: ["Country"],
67
+ name: "tonic_country_idx"
68
+ },
69
+ {
70
+ fields: ["Revenue"],
71
+ name: "tonic_revenue_idx"
72
+ },
73
+ {
74
+ fields: ["Clicks"],
75
+ name: "tonic_clicks_idx"
76
+ },
77
+ {
78
+ fields: ["Country", "Date"],
79
+ name: "tonic_country_date_idx"
80
+ },
81
+ {
82
+ fields: ["Keyword", "Country"],
83
+ name: "tonic_keyword_country_idx"
84
+ },
85
+ {
86
+ fields: ["Date", "Revenue"],
87
+ name: "tonic_date_revenue_idx"
88
+ },
89
+ ],
90
+ hooks: {
91
+ beforeCreate: async (record, options) => {
92
+ try {
93
+ const existingKeyword = await sequelize.models.TonicRSOCKeywordPerformance.findOne({
94
+ where: {
95
+ Keyword: sequelize.where(
96
+ sequelize.fn("LOWER", sequelize.col("Keyword")),
97
+ sequelize.fn("LOWER", record.Keyword)
98
+ ),
99
+ Country: record.Country,
100
+ },
101
+ attributes: ["FirstAppearanceDate"],
102
+ transaction: options.transaction,
103
+ });
104
+
105
+ record.FirstAppearanceDate =
106
+ existingKeyword?.FirstAppearanceDate || record.Date;
107
+ } catch (error) {
108
+ console.error("Error in TonicRSOCKeywordPerformance FirstAppearanceDate hook:", error);
109
+ throw error;
110
+ }
111
+ },
112
+ },
113
+ }
114
+ );
115
+
116
+ TonicRSOCKeywordPerformance.associate = (models) => {
117
+ TonicRSOCKeywordPerformance.belongsTo(models.Ad, {
118
+ foreignKey: "adID",
119
+ });
120
+ };
121
+
122
+ return TonicRSOCKeywordPerformance;
123
123
  };
@@ -1,26 +1,26 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const Vertical = sequelize.define(
3
- "Vertical",
4
- {
5
- id: {
6
- type: DataTypes.UUID,
7
- defaultValue: DataTypes.UUIDV4,
8
- primaryKey: true,
9
- },
10
- name: {
11
- type: DataTypes.STRING,
12
- allowNull: false,
13
- },
14
- code: {
15
- type: DataTypes.STRING,
16
- allowNull: false,
17
- unique: true,
18
- },
19
- },
20
- {
21
- tableName: "Vertical",
22
- }
23
- );
24
-
25
- return Vertical;
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const Vertical = sequelize.define(
3
+ "Vertical",
4
+ {
5
+ id: {
6
+ type: DataTypes.UUID,
7
+ defaultValue: DataTypes.UUIDV4,
8
+ primaryKey: true,
9
+ },
10
+ name: {
11
+ type: DataTypes.STRING,
12
+ allowNull: false,
13
+ },
14
+ code: {
15
+ type: DataTypes.STRING,
16
+ allowNull: false,
17
+ unique: true,
18
+ },
19
+ },
20
+ {
21
+ tableName: "Vertical",
22
+ }
23
+ );
24
+
25
+ return Vertical;
26
26
  };
@@ -1,110 +1,110 @@
1
- module.exports = (sequelize, DataTypes) => {
2
- const NewFiles = sequelize.define("NewFiles", {
3
- id: {
4
- type: DataTypes.STRING,
5
- primaryKey: true,
6
- },
7
- accounts: {
8
- type: DataTypes.JSONB(),
9
- allowNull: true,
10
- },
11
- name: {
12
- type: DataTypes.STRING,
13
- allowNull: false,
14
- },
15
- // need to add a field of the name in the gcp bucket
16
- gcpFileName: {
17
- type: DataTypes.STRING,
18
- allowNull: true,
19
- },
20
- type: {
21
- type: DataTypes.STRING, // Can be "image" or "video"
22
- allowNull: false,
23
- },
24
- URL: {
25
- type: DataTypes.STRING, // URL for the file
26
- allowNull: false,
27
- },
28
- FileType: {
29
- type: DataTypes.STRING,
30
- allowNull: true,
31
- defaultValue: "image",
32
- },
33
- Size: {
34
- type: DataTypes.STRING,
35
- allowNull: true,
36
- },
37
- Language: {
38
- type: DataTypes.STRING,
39
- allowNull: true,
40
- },
41
- Vertical: {
42
- type: DataTypes.STRING,
43
- allowNull: true,
44
- },
45
- // want to add length ( duration of the video) if the file is a video.
46
- // maybe call it duration
47
- Duration: {
48
- type: DataTypes.STRING,
49
- allowNull: true,
50
- },
51
- // Thumbnail URL
52
- Thumbnail: {
53
- type: DataTypes.TEXT,
54
- allowNull: true,
55
- },
56
- Thumbnai2: {
57
- type: DataTypes.TEXT,
58
- allowNull: true,
59
- },
60
- // ImageHash
61
- ImageHash: {
62
- type: DataTypes.STRING,
63
- allowNull: true,
64
- },
65
- isGenerated: {
66
- type: DataTypes.BOOLEAN,
67
- allowNull: true,
68
- defaultValue: false,
69
- },
70
- isUploading: {
71
- type: DataTypes.BOOLEAN,
72
- allowNull: true,
73
- defaultValue: false,
74
- },
75
- freeText: {
76
- type: DataTypes.STRING,
77
- allowNull: true,
78
- },
79
- style: {
80
- type: DataTypes.STRING,
81
- allowNull: true,
82
- },
83
- ratio: {
84
- type: DataTypes.STRING,
85
- allowNull: true,
86
- },
87
- notes: {
88
- type: DataTypes.STRING(1000),
89
- allowNull: true,
90
- },
91
- headline: {
92
- type: DataTypes.STRING(1000),
93
- allowNull: true,
94
- },
95
- subtext: {
96
- type: DataTypes.STRING(1000),
97
- allowNull: true,
98
- },
99
- cta: {
100
- type: DataTypes.STRING(1000),
101
- allowNull: true,
102
- },
103
- script: {
104
- type: DataTypes.STRING(1000),
105
- allowNull: true,
106
- },
107
- });
108
-
109
- return NewFiles;
110
- };
1
+ module.exports = (sequelize, DataTypes) => {
2
+ const NewFiles = sequelize.define("NewFiles", {
3
+ id: {
4
+ type: DataTypes.STRING,
5
+ primaryKey: true,
6
+ },
7
+ accounts: {
8
+ type: DataTypes.JSONB(),
9
+ allowNull: true,
10
+ },
11
+ name: {
12
+ type: DataTypes.STRING,
13
+ allowNull: false,
14
+ },
15
+ // need to add a field of the name in the gcp bucket
16
+ gcpFileName: {
17
+ type: DataTypes.STRING,
18
+ allowNull: true,
19
+ },
20
+ type: {
21
+ type: DataTypes.STRING, // Can be "image" or "video"
22
+ allowNull: false,
23
+ },
24
+ URL: {
25
+ type: DataTypes.STRING, // URL for the file
26
+ allowNull: false,
27
+ },
28
+ FileType: {
29
+ type: DataTypes.STRING,
30
+ allowNull: true,
31
+ defaultValue: "image",
32
+ },
33
+ Size: {
34
+ type: DataTypes.STRING,
35
+ allowNull: true,
36
+ },
37
+ Language: {
38
+ type: DataTypes.STRING,
39
+ allowNull: true,
40
+ },
41
+ Vertical: {
42
+ type: DataTypes.STRING,
43
+ allowNull: true,
44
+ },
45
+ // want to add length ( duration of the video) if the file is a video.
46
+ // maybe call it duration
47
+ Duration: {
48
+ type: DataTypes.STRING,
49
+ allowNull: true,
50
+ },
51
+ // Thumbnail URL
52
+ Thumbnail: {
53
+ type: DataTypes.TEXT,
54
+ allowNull: true,
55
+ },
56
+ Thumbnai2: {
57
+ type: DataTypes.TEXT,
58
+ allowNull: true,
59
+ },
60
+ // ImageHash
61
+ ImageHash: {
62
+ type: DataTypes.STRING,
63
+ allowNull: true,
64
+ },
65
+ isGenerated: {
66
+ type: DataTypes.BOOLEAN,
67
+ allowNull: true,
68
+ defaultValue: false,
69
+ },
70
+ isUploading: {
71
+ type: DataTypes.BOOLEAN,
72
+ allowNull: true,
73
+ defaultValue: false,
74
+ },
75
+ freeText: {
76
+ type: DataTypes.STRING,
77
+ allowNull: true,
78
+ },
79
+ style: {
80
+ type: DataTypes.STRING,
81
+ allowNull: true,
82
+ },
83
+ ratio: {
84
+ type: DataTypes.STRING,
85
+ allowNull: true,
86
+ },
87
+ notes: {
88
+ type: DataTypes.STRING(1000),
89
+ allowNull: true,
90
+ },
91
+ headline: {
92
+ type: DataTypes.STRING(1000),
93
+ allowNull: true,
94
+ },
95
+ subtext: {
96
+ type: DataTypes.STRING(1000),
97
+ allowNull: true,
98
+ },
99
+ cta: {
100
+ type: DataTypes.STRING(1000),
101
+ allowNull: true,
102
+ },
103
+ script: {
104
+ type: DataTypes.STRING(1000),
105
+ allowNull: true,
106
+ },
107
+ });
108
+
109
+ return NewFiles;
110
+ };