agrs-sequelize-sdk 1.2.73 → 1.2.74

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.
@@ -1,153 +1,124 @@
1
- const { DataTypes } = require("sequelize");
2
-
3
- module.exports = (sequelize) => {
4
- const Rule = sequelize.define(
5
- "AutomationRule", // Change model name to avoid conflict
6
- {
7
- id: {
8
- type: DataTypes.UUID,
9
- defaultValue: DataTypes.UUIDV4,
10
- primaryKey: true,
11
- },
12
- name: {
13
- type: DataTypes.STRING,
14
- allowNull: true,
15
- comment: "Rule name for identification",
16
- },
17
- code: {
18
- type: DataTypes.STRING,
19
- allowNull: false,
20
- unique: true,
21
- comment: "Unique code for the rule",
22
- },
23
- permissions: {
24
- type: DataTypes.ARRAY(DataTypes.STRING),
25
- allowNull: false,
26
- defaultValue: [],
27
- comment: "Permissions required for this rule",
28
- },
29
- feature: {
30
- type: DataTypes.STRING,
31
- allowNull: true,
32
- comment: "Feature this rule belongs to",
33
- },
34
- parentId: {
35
- type: DataTypes.UUID,
36
- allowNull: true,
37
- references: {
38
- model: "RulesValues",
39
- key: "id",
40
- },
41
- onDelete: "CASCADE",
42
- comment: "Parent rule ID for hierarchical rules",
43
- },
44
- // Additional fields for the new rules system
45
- description: {
46
- type: DataTypes.TEXT,
47
- allowNull: true,
48
- comment: "Optional description of what this rule does",
49
- },
50
- isActive: {
51
- type: DataTypes.BOOLEAN,
52
- defaultValue: true,
53
- allowNull: false,
54
- comment: "Whether the rule is currently active",
55
- },
56
- ruleType: {
57
- type: DataTypes.ENUM("PAUSE", "BUDGET", "BID", "STATUS", "CUSTOM"),
58
- allowNull: true,
59
- comment: "Type of rule - determines the action category",
60
- },
61
- targetLevel: {
62
- type: DataTypes.ENUM("CAMPAIGN", "ADSET", "AD"),
63
- allowNull: true,
64
- comment: "Level at which the rule operates",
65
- },
66
- scheduleType: {
67
- type: DataTypes.ENUM("INTERVAL", "CRON", "MANUAL"),
68
- allowNull: true,
69
- defaultValue: "MANUAL",
70
- comment: "How the rule is triggered",
71
- },
72
- scheduleConfig: {
73
- type: DataTypes.JSONB,
74
- allowNull: true,
75
- comment:
76
- "Schedule configuration (interval minutes, cron expression, etc.)",
77
- },
78
- gcpJobName: {
79
- type: DataTypes.STRING(255),
80
- allowNull: true,
81
- comment: "GCP Cloud Scheduler job name for this rule",
82
- },
83
- lastExecuted: {
84
- type: DataTypes.DATE,
85
- allowNull: true,
86
- comment: "When the rule was last executed",
87
- },
88
- nextExecution: {
89
- type: DataTypes.DATE,
90
- allowNull: true,
91
- comment: "When the rule is scheduled to run next",
92
- },
93
- executionCount: {
94
- type: DataTypes.INTEGER,
95
- defaultValue: 0,
96
- allowNull: false,
97
- comment: "Number of times this rule has been executed",
98
- },
99
- successCount: {
100
- type: DataTypes.INTEGER,
101
- defaultValue: 0,
102
- allowNull: false,
103
- comment: "Number of successful executions",
104
- },
105
- failureCount: {
106
- type: DataTypes.INTEGER,
107
- defaultValue: 0,
108
- allowNull: false,
109
- comment: "Number of failed executions",
110
- },
111
- createdBy: {
112
- type: DataTypes.STRING(255),
113
- allowNull: true,
114
- comment: "User who created this rule",
115
- },
116
- updatedBy: {
117
- type: DataTypes.STRING(255),
118
- allowNull: true,
119
- comment: "User who last updated this rule",
120
- },
121
- },
122
- {
123
- tableName: "RulesValues", // Use the existing table name
124
- timestamps: true,
125
- // Remove indexes from model definition - they will be created by migration
126
- }
127
- );
128
-
129
- Rule.associate = (models) => {
130
- // A rule has many conditions
131
- Rule.hasMany(models.RuleCondition, {
132
- foreignKey: "ruleId",
133
- as: "conditions",
134
- onDelete: "CASCADE",
135
- });
136
-
137
- // A rule has many actions
138
- Rule.hasMany(models.RuleAction, {
139
- foreignKey: "ruleId",
140
- as: "actions",
141
- onDelete: "CASCADE",
142
- });
143
-
144
- // A rule has many execution logs
145
- Rule.hasMany(models.RuleExecution, {
146
- foreignKey: "ruleId",
147
- as: "executions",
148
- onDelete: "CASCADE",
149
- });
150
- };
151
-
152
- return Rule;
153
- };
1
+ const { DataTypes } = require("sequelize");
2
+
3
+ module.exports = (sequelize) => {
4
+ const AutomationRule = sequelize.define(
5
+ "AutomationRule",
6
+ {
7
+ id: {
8
+ type: DataTypes.UUID,
9
+ defaultValue: DataTypes.UUIDV4,
10
+ primaryKey: true,
11
+ },
12
+ name: {
13
+ type: DataTypes.STRING,
14
+ allowNull: false,
15
+ comment: "Rule name for identification",
16
+ },
17
+ description: {
18
+ type: DataTypes.TEXT,
19
+ allowNull: true,
20
+ comment: "Optional description of what this rule does",
21
+ },
22
+ isActive: {
23
+ type: DataTypes.BOOLEAN,
24
+ defaultValue: true,
25
+ allowNull: false,
26
+ comment: "Whether the rule is currently active",
27
+ },
28
+ ruleType: {
29
+ type: DataTypes.ENUM("PAUSE", "BUDGET", "BID", "STATUS", "CUSTOM"),
30
+ allowNull: true,
31
+ comment: "Type of rule - determines the action category",
32
+ },
33
+ targetLevel: {
34
+ type: DataTypes.ENUM("CAMPAIGN", "ADSET", "AD"),
35
+ allowNull: true,
36
+ comment: "Level at which the rule operates",
37
+ },
38
+ scheduleType: {
39
+ type: DataTypes.ENUM("INTERVAL", "CRON", "MANUAL"),
40
+ allowNull: true,
41
+ defaultValue: "MANUAL",
42
+ comment: "How the rule is triggered",
43
+ },
44
+ scheduleConfig: {
45
+ type: DataTypes.JSONB,
46
+ allowNull: true,
47
+ comment:
48
+ "Schedule configuration (interval minutes, cron expression, etc.)",
49
+ },
50
+ gcpJobName: {
51
+ type: DataTypes.STRING(255),
52
+ allowNull: true,
53
+ comment: "GCP Cloud Scheduler job name for this rule",
54
+ },
55
+ lastExecuted: {
56
+ type: DataTypes.DATE,
57
+ allowNull: true,
58
+ comment: "When the rule was last executed",
59
+ },
60
+ nextExecution: {
61
+ type: DataTypes.DATE,
62
+ allowNull: true,
63
+ comment: "When the rule is scheduled to run next",
64
+ },
65
+ executionCount: {
66
+ type: DataTypes.INTEGER,
67
+ defaultValue: 0,
68
+ allowNull: false,
69
+ comment: "Number of times this rule has been executed",
70
+ },
71
+ successCount: {
72
+ type: DataTypes.INTEGER,
73
+ defaultValue: 0,
74
+ allowNull: false,
75
+ comment: "Number of successful executions",
76
+ },
77
+ failureCount: {
78
+ type: DataTypes.INTEGER,
79
+ defaultValue: 0,
80
+ allowNull: false,
81
+ comment: "Number of failed executions",
82
+ },
83
+ createdBy: {
84
+ type: DataTypes.STRING(255),
85
+ allowNull: true,
86
+ comment: "User who created this rule",
87
+ },
88
+ updatedBy: {
89
+ type: DataTypes.STRING(255),
90
+ allowNull: true,
91
+ comment: "User who last updated this rule",
92
+ },
93
+ },
94
+ {
95
+ tableName: "AutomationRules", // New table name
96
+ timestamps: true,
97
+ }
98
+ );
99
+
100
+ AutomationRule.associate = (models) => {
101
+ // A rule has many conditions
102
+ AutomationRule.hasMany(models.RuleCondition, {
103
+ foreignKey: "ruleId",
104
+ as: "conditions",
105
+ onDelete: "CASCADE",
106
+ });
107
+
108
+ // A rule has many actions
109
+ AutomationRule.hasMany(models.RuleAction, {
110
+ foreignKey: "ruleId",
111
+ as: "actions",
112
+ onDelete: "CASCADE",
113
+ });
114
+
115
+ // A rule has many execution logs
116
+ AutomationRule.hasMany(models.RuleExecution, {
117
+ foreignKey: "ruleId",
118
+ as: "executions",
119
+ onDelete: "CASCADE",
120
+ });
121
+ };
122
+
123
+ return AutomationRule;
124
+ };
@@ -13,7 +13,7 @@ module.exports = (sequelize) => {
13
13
  type: DataTypes.UUID,
14
14
  allowNull: false,
15
15
  references: {
16
- model: "RulesValues",
16
+ model: "AutomationRules",
17
17
  key: "id",
18
18
  },
19
19
  comment: "Reference to the parent rule",
@@ -13,7 +13,7 @@ module.exports = (sequelize) => {
13
13
  type: DataTypes.UUID,
14
14
  allowNull: false,
15
15
  references: {
16
- model: "RulesValues",
16
+ model: "AutomationRules",
17
17
  key: "id",
18
18
  },
19
19
  comment: "Reference to the parent rule",
@@ -13,7 +13,7 @@ module.exports = (sequelize) => {
13
13
  type: DataTypes.UUID,
14
14
  allowNull: false,
15
15
  references: {
16
- model: "RulesValues",
16
+ model: "AutomationRules",
17
17
  key: "id",
18
18
  },
19
19
  comment: "Reference to the executed rule",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agrs-sequelize-sdk",
3
- "version": "1.2.73",
3
+ "version": "1.2.74",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "start": "node index.js",