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
|
|
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:
|
|
15
|
-
comment: "Rule name for identification",
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
type: DataTypes.
|
|
19
|
-
allowNull:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
allowNull: false,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
comment: "
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
type: DataTypes.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
allowNull:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
allowNull:
|
|
75
|
-
comment:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
allowNull:
|
|
81
|
-
comment: "
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
type: DataTypes.
|
|
85
|
-
allowNull: true,
|
|
86
|
-
comment: "
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
type: DataTypes.
|
|
90
|
-
allowNull: true,
|
|
91
|
-
comment: "
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
+
};
|
package/models/RuleAction.js
CHANGED
package/models/RuleCondition.js
CHANGED
package/models/RuleExecution.js
CHANGED