agrs-sequelize-sdk 1.4.59 → 1.4.60
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.
- package/migrations/2026-05-17-PIXELS-FOLLOWUP.md +85 -85
- package/migrations/2026-05-17-add-platform-to-ad.js +19 -19
- package/migrations/2026-05-17-add-platform-to-adaccount.js +19 -19
- package/migrations/2026-05-17-add-platform-to-adperformance.js +19 -19
- package/migrations/2026-05-17-add-platform-to-adset.js +19 -19
- package/migrations/2026-05-17-add-platform-to-adsetperformance.js +19 -19
- package/migrations/2026-05-17-add-platform-to-aiarticleretryqueue.js +19 -19
- package/migrations/2026-05-17-add-platform-to-aicampaignqueue.js +19 -19
- package/migrations/2026-05-17-add-platform-to-article.js +19 -19
- package/migrations/2026-05-17-add-platform-to-campaign.js +19 -19
- package/migrations/2026-05-17-add-platform-to-codefuelcampaign.js +19 -19
- package/migrations/2026-05-17-add-platform-to-dynamicfeed.js +19 -19
- package/migrations/2026-05-17-add-platform-to-facebookretryqueue.js +19 -19
- package/migrations/2026-05-17-add-platform-to-pages.js +19 -19
- package/migrations/2026-05-17-add-platform-to-presets.js +19 -19
- package/migrations/2026-05-18-add-group-id-to-ai-campaign-queue.js +18 -18
- package/migrations/2026-05-18-add-platform-code-to-creation-logs.js +65 -65
- package/migrations/2026-05-18-add-platform-code-to-pixels.js +55 -55
- package/migrations/2026-05-18-add-platform-code-to-rsoc-feed-campaigns.js +55 -55
- package/migrations/2026-05-18-add-platform-date-index-to-adperformance.js +16 -16
- package/migrations/2026-05-18-add-platform-date-index-to-adsetperformance.js +16 -16
- package/migrations/2026-05-18-add-review-status-to-ad.js +36 -36
- package/migrations/2026-05-18-create-canonical-insights.js +84 -84
- package/migrations/2026-05-18-create-snapchat-public-profiles.js +68 -68
- package/migrations/2026-05-18-create-tiktok-identities.js +71 -71
- package/migrations/2026-05-18-create-tiktok-snapchat-campaigns.js +143 -143
- package/migrations/2026-05-18-create-tt-snp-adset-ad-tables.js +309 -309
- package/migrations/RUN_ME_MANUALLY_2026-05-17.sql +99 -99
- package/migrations/add-requested-from-dashboard-to-articles.js +17 -17
- package/migrations/change-adset-name-to-text.js +79 -79
- package/models/AICampaignQueue.js +151 -151
- package/models/AIGenerationLog.js +85 -85
- package/models/AIGenerationRequest.js +212 -212
- package/models/AdAccountValues.js +25 -25
- package/models/AdHistory.js +30 -30
- package/models/AdPerformance.js +104 -104
- package/models/AdSet.js +295 -295
- package/models/AdSetHistory.js +30 -30
- package/models/AdsetPerformance.js +137 -137
- package/models/AiArticleRetryQueue.js +157 -157
- package/models/AiCreationRetryQueue.js +134 -134
- package/models/ApiAuditLog.js +127 -127
- package/models/ApiToken.js +67 -67
- package/models/Article.js +222 -222
- package/models/AutomationRule.js +179 -179
- package/models/BannerTemplate.js +129 -129
- package/models/Buyers.js +25 -25
- package/models/Campaign.js +168 -168
- package/models/CampaignActionHistory.js +101 -101
- package/models/CampaignCreationLog.js +340 -340
- package/models/CampaignCreationLogV2.js +392 -392
- package/models/CampaignHistory.js +33 -33
- package/models/CampaignTag.js +46 -46
- package/models/CampaignTagAssignment.js +48 -48
- package/models/CanonicalInsights.js +68 -68
- package/models/Channel.js +55 -55
- package/models/Domain.js +44 -44
- package/models/DynamicFeed.js +218 -218
- package/models/ExplorAdsChannel.js +61 -61
- package/models/FacebookRetryQueue.js +163 -163
- package/models/Feed.js +33 -33
- package/models/FeedArticleConfiguration.js +80 -80
- package/models/FrontStoryChannel.js +59 -59
- package/models/FrontStoryChannelV2.js +60 -60
- package/models/GenericFlowRequest.js +114 -114
- package/models/MidoWebChannel.js +47 -47
- package/models/MineBrandBlocklist.js +56 -56
- package/models/MineBrandConfig.js +26 -26
- package/models/MineChannel.js +47 -47
- package/models/MineRedirectDomain.js +42 -42
- package/models/MineWebhookEvent.js +53 -53
- package/models/Pages.js +117 -117
- package/models/PipelineExecution.js +59 -59
- package/models/PolicyDogsCreativeCache.js +50 -50
- package/models/PolicyDogsImageCache.js +30 -30
- package/models/Presets.js +40 -40
- package/models/PublicApiBatch.js +155 -155
- package/models/PublicApiBatchItem.js +166 -166
- package/models/PublicApiIdempotencyCache.js +135 -135
- package/models/RSOCFeedCampaign.js +387 -387
- package/models/RSOCFeedConfig.js +46 -46
- package/models/RSOCRedirectWsCode.js +22 -22
- package/models/RsocKeywordPerformance.js +110 -110
- package/models/RuleAction.js +90 -90
- package/models/RuleCondition.js +137 -137
- package/models/RuleExecution.js +107 -107
- package/models/RulesValues.js +56 -56
- package/models/SingularChannel.js +31 -31
- package/models/SnapchatAd.js +69 -69
- package/models/SnapchatAdSquad.js +92 -92
- package/models/SnapchatCampaign.js +69 -69
- package/models/SnapchatChannel.js +31 -31
- package/models/SnapchatPublicProfiles.js +67 -67
- package/models/SupportedLocale.js +23 -23
- package/models/SyncHistory.js +249 -249
- package/models/TTQChannel.js +42 -42
- package/models/Team.js +33 -43
- package/models/TemplateMetadata.js +260 -260
- package/models/Tier2_AdAccounts.js +110 -110
- package/models/Tier2_Assets.js +70 -70
- package/models/Tier2_BusinessManagers.js +105 -105
- package/models/Tier2_CreditLines.js +99 -99
- package/models/Tier2_Pages.js +91 -91
- package/models/Tier2_Pixels.js +82 -82
- package/models/Tier2_Tokens.js +64 -64
- package/models/Tier2_UserAdAccounts.js +83 -83
- package/models/TikTokAd.js +71 -71
- package/models/TikTokAdGroup.js +82 -82
- package/models/TikTokCampaign.js +71 -71
- package/models/TiktokChannel.js +31 -31
- package/models/TiktokIdentities.js +65 -65
- package/models/TokenRotationState.js +121 -121
- package/models/TonicRSOCKeywordPerformance.js +122 -122
- package/models/Users.js +204 -204
- package/models/Vertical.js +25 -25
- package/models/newFiles.js +137 -137
- package/package.json +21 -19
- package/run.sh +214 -214
- package/services/sequelizeService.js +110 -110
- package/tarzo-skalio-integration-docs.md +691 -691
package/models/RuleCondition.js
CHANGED
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
const { DataTypes } = require("sequelize");
|
|
2
|
-
|
|
3
|
-
module.exports = (sequelize) => {
|
|
4
|
-
const RuleCondition = sequelize.define(
|
|
5
|
-
"RuleCondition",
|
|
6
|
-
{
|
|
7
|
-
id: {
|
|
8
|
-
type: DataTypes.UUID,
|
|
9
|
-
defaultValue: DataTypes.UUIDV4,
|
|
10
|
-
primaryKey: true,
|
|
11
|
-
},
|
|
12
|
-
ruleId: {
|
|
13
|
-
type: DataTypes.UUID,
|
|
14
|
-
allowNull: false,
|
|
15
|
-
references: {
|
|
16
|
-
model: "AutomationRule",
|
|
17
|
-
key: "id",
|
|
18
|
-
},
|
|
19
|
-
comment: "Reference to the parent rule",
|
|
20
|
-
},
|
|
21
|
-
field: {
|
|
22
|
-
type: DataTypes.STRING(100),
|
|
23
|
-
allowNull: false,
|
|
24
|
-
comment: "Field to evaluate (e.g., roi, ctr, campaign_name)",
|
|
25
|
-
},
|
|
26
|
-
type: {
|
|
27
|
-
type: DataTypes.ENUM("DIMENSION", "METRIC"),
|
|
28
|
-
allowNull: false,
|
|
29
|
-
defaultValue: "DIMENSION",
|
|
30
|
-
comment:
|
|
31
|
-
"Type of field - DIMENSION for filtering, METRIC for calculations",
|
|
32
|
-
},
|
|
33
|
-
operator: {
|
|
34
|
-
type: DataTypes.ENUM(
|
|
35
|
-
"EQUALS",
|
|
36
|
-
"NOT_EQUALS",
|
|
37
|
-
"GREATER_THAN",
|
|
38
|
-
"LESS_THAN",
|
|
39
|
-
"GREATER_THAN_OR_EQUAL",
|
|
40
|
-
"LESS_THAN_OR_EQUAL",
|
|
41
|
-
"BETWEEN",
|
|
42
|
-
"IN",
|
|
43
|
-
"NOT_IN",
|
|
44
|
-
"CONTAINS",
|
|
45
|
-
"NOT_CONTAINS",
|
|
46
|
-
"IS_NULL",
|
|
47
|
-
"IS_NOT_NULL"
|
|
48
|
-
),
|
|
49
|
-
allowNull: false,
|
|
50
|
-
comment: "Comparison operator",
|
|
51
|
-
},
|
|
52
|
-
value: {
|
|
53
|
-
type: DataTypes.JSONB,
|
|
54
|
-
allowNull: true,
|
|
55
|
-
comment:
|
|
56
|
-
"Value(s) to compare against (can be array for BETWEEN, IN, etc.)",
|
|
57
|
-
},
|
|
58
|
-
valueType: {
|
|
59
|
-
type: DataTypes.ENUM("STRING", "NUMBER", "ARRAY"),
|
|
60
|
-
allowNull: true,
|
|
61
|
-
defaultValue: "STRING",
|
|
62
|
-
comment: "Type of the value field",
|
|
63
|
-
},
|
|
64
|
-
logicalOperator: {
|
|
65
|
-
type: DataTypes.ENUM("AND", "OR"),
|
|
66
|
-
allowNull: false,
|
|
67
|
-
defaultValue: "AND",
|
|
68
|
-
comment: "How this condition connects to the next one",
|
|
69
|
-
},
|
|
70
|
-
order: {
|
|
71
|
-
type: DataTypes.INTEGER,
|
|
72
|
-
allowNull: false,
|
|
73
|
-
defaultValue: 0,
|
|
74
|
-
comment: "Order of this condition within the rule",
|
|
75
|
-
},
|
|
76
|
-
isActive: {
|
|
77
|
-
type: DataTypes.BOOLEAN,
|
|
78
|
-
defaultValue: true,
|
|
79
|
-
allowNull: false,
|
|
80
|
-
comment: "Whether this condition is active",
|
|
81
|
-
},
|
|
82
|
-
groupId: {
|
|
83
|
-
type: DataTypes.STRING(50),
|
|
84
|
-
allowNull: true,
|
|
85
|
-
comment: "ID to group conditions together (e.g., group1, group2)",
|
|
86
|
-
},
|
|
87
|
-
groupOperator: {
|
|
88
|
-
type: DataTypes.ENUM("AND", "OR"),
|
|
89
|
-
allowNull: false,
|
|
90
|
-
defaultValue: "AND",
|
|
91
|
-
comment: "Operator within the group (AND/OR)",
|
|
92
|
-
},
|
|
93
|
-
betweenGroupsOperator: {
|
|
94
|
-
type: DataTypes.ENUM("AND", "OR"),
|
|
95
|
-
allowNull: true,
|
|
96
|
-
comment:
|
|
97
|
-
"Operator between different groups (AND/OR) - only for first condition in group",
|
|
98
|
-
},
|
|
99
|
-
dateRangeType: {
|
|
100
|
-
type: DataTypes.STRING(50),
|
|
101
|
-
allowNull: true,
|
|
102
|
-
comment:
|
|
103
|
-
"Type of date range (last_7_days, yesterday, today, custom, etc.)",
|
|
104
|
-
},
|
|
105
|
-
dateRangeValue: {
|
|
106
|
-
type: DataTypes.INTEGER,
|
|
107
|
-
allowNull: true,
|
|
108
|
-
comment: "Number of days for relative date ranges",
|
|
109
|
-
},
|
|
110
|
-
customStartDate: {
|
|
111
|
-
type: DataTypes.DATE,
|
|
112
|
-
allowNull: true,
|
|
113
|
-
comment: "Custom start date if dateRangeType is custom",
|
|
114
|
-
},
|
|
115
|
-
customEndDate: {
|
|
116
|
-
type: DataTypes.DATE,
|
|
117
|
-
allowNull: true,
|
|
118
|
-
comment: "Custom end date if dateRangeType is custom",
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
tableName: "RuleConditions",
|
|
123
|
-
timestamps: true,
|
|
124
|
-
// Remove indexes from model definition - they will be created by migration
|
|
125
|
-
}
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
RuleCondition.associate = (models) => {
|
|
129
|
-
// A condition belongs to a rule
|
|
130
|
-
RuleCondition.belongsTo(models.AutomationRule, {
|
|
131
|
-
foreignKey: "ruleId",
|
|
132
|
-
as: "rule",
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
return RuleCondition;
|
|
137
|
-
};
|
|
1
|
+
const { DataTypes } = require("sequelize");
|
|
2
|
+
|
|
3
|
+
module.exports = (sequelize) => {
|
|
4
|
+
const RuleCondition = sequelize.define(
|
|
5
|
+
"RuleCondition",
|
|
6
|
+
{
|
|
7
|
+
id: {
|
|
8
|
+
type: DataTypes.UUID,
|
|
9
|
+
defaultValue: DataTypes.UUIDV4,
|
|
10
|
+
primaryKey: true,
|
|
11
|
+
},
|
|
12
|
+
ruleId: {
|
|
13
|
+
type: DataTypes.UUID,
|
|
14
|
+
allowNull: false,
|
|
15
|
+
references: {
|
|
16
|
+
model: "AutomationRule",
|
|
17
|
+
key: "id",
|
|
18
|
+
},
|
|
19
|
+
comment: "Reference to the parent rule",
|
|
20
|
+
},
|
|
21
|
+
field: {
|
|
22
|
+
type: DataTypes.STRING(100),
|
|
23
|
+
allowNull: false,
|
|
24
|
+
comment: "Field to evaluate (e.g., roi, ctr, campaign_name)",
|
|
25
|
+
},
|
|
26
|
+
type: {
|
|
27
|
+
type: DataTypes.ENUM("DIMENSION", "METRIC"),
|
|
28
|
+
allowNull: false,
|
|
29
|
+
defaultValue: "DIMENSION",
|
|
30
|
+
comment:
|
|
31
|
+
"Type of field - DIMENSION for filtering, METRIC for calculations",
|
|
32
|
+
},
|
|
33
|
+
operator: {
|
|
34
|
+
type: DataTypes.ENUM(
|
|
35
|
+
"EQUALS",
|
|
36
|
+
"NOT_EQUALS",
|
|
37
|
+
"GREATER_THAN",
|
|
38
|
+
"LESS_THAN",
|
|
39
|
+
"GREATER_THAN_OR_EQUAL",
|
|
40
|
+
"LESS_THAN_OR_EQUAL",
|
|
41
|
+
"BETWEEN",
|
|
42
|
+
"IN",
|
|
43
|
+
"NOT_IN",
|
|
44
|
+
"CONTAINS",
|
|
45
|
+
"NOT_CONTAINS",
|
|
46
|
+
"IS_NULL",
|
|
47
|
+
"IS_NOT_NULL"
|
|
48
|
+
),
|
|
49
|
+
allowNull: false,
|
|
50
|
+
comment: "Comparison operator",
|
|
51
|
+
},
|
|
52
|
+
value: {
|
|
53
|
+
type: DataTypes.JSONB,
|
|
54
|
+
allowNull: true,
|
|
55
|
+
comment:
|
|
56
|
+
"Value(s) to compare against (can be array for BETWEEN, IN, etc.)",
|
|
57
|
+
},
|
|
58
|
+
valueType: {
|
|
59
|
+
type: DataTypes.ENUM("STRING", "NUMBER", "ARRAY"),
|
|
60
|
+
allowNull: true,
|
|
61
|
+
defaultValue: "STRING",
|
|
62
|
+
comment: "Type of the value field",
|
|
63
|
+
},
|
|
64
|
+
logicalOperator: {
|
|
65
|
+
type: DataTypes.ENUM("AND", "OR"),
|
|
66
|
+
allowNull: false,
|
|
67
|
+
defaultValue: "AND",
|
|
68
|
+
comment: "How this condition connects to the next one",
|
|
69
|
+
},
|
|
70
|
+
order: {
|
|
71
|
+
type: DataTypes.INTEGER,
|
|
72
|
+
allowNull: false,
|
|
73
|
+
defaultValue: 0,
|
|
74
|
+
comment: "Order of this condition within the rule",
|
|
75
|
+
},
|
|
76
|
+
isActive: {
|
|
77
|
+
type: DataTypes.BOOLEAN,
|
|
78
|
+
defaultValue: true,
|
|
79
|
+
allowNull: false,
|
|
80
|
+
comment: "Whether this condition is active",
|
|
81
|
+
},
|
|
82
|
+
groupId: {
|
|
83
|
+
type: DataTypes.STRING(50),
|
|
84
|
+
allowNull: true,
|
|
85
|
+
comment: "ID to group conditions together (e.g., group1, group2)",
|
|
86
|
+
},
|
|
87
|
+
groupOperator: {
|
|
88
|
+
type: DataTypes.ENUM("AND", "OR"),
|
|
89
|
+
allowNull: false,
|
|
90
|
+
defaultValue: "AND",
|
|
91
|
+
comment: "Operator within the group (AND/OR)",
|
|
92
|
+
},
|
|
93
|
+
betweenGroupsOperator: {
|
|
94
|
+
type: DataTypes.ENUM("AND", "OR"),
|
|
95
|
+
allowNull: true,
|
|
96
|
+
comment:
|
|
97
|
+
"Operator between different groups (AND/OR) - only for first condition in group",
|
|
98
|
+
},
|
|
99
|
+
dateRangeType: {
|
|
100
|
+
type: DataTypes.STRING(50),
|
|
101
|
+
allowNull: true,
|
|
102
|
+
comment:
|
|
103
|
+
"Type of date range (last_7_days, yesterday, today, custom, etc.)",
|
|
104
|
+
},
|
|
105
|
+
dateRangeValue: {
|
|
106
|
+
type: DataTypes.INTEGER,
|
|
107
|
+
allowNull: true,
|
|
108
|
+
comment: "Number of days for relative date ranges",
|
|
109
|
+
},
|
|
110
|
+
customStartDate: {
|
|
111
|
+
type: DataTypes.DATE,
|
|
112
|
+
allowNull: true,
|
|
113
|
+
comment: "Custom start date if dateRangeType is custom",
|
|
114
|
+
},
|
|
115
|
+
customEndDate: {
|
|
116
|
+
type: DataTypes.DATE,
|
|
117
|
+
allowNull: true,
|
|
118
|
+
comment: "Custom end date if dateRangeType is custom",
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
tableName: "RuleConditions",
|
|
123
|
+
timestamps: true,
|
|
124
|
+
// Remove indexes from model definition - they will be created by migration
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
RuleCondition.associate = (models) => {
|
|
129
|
+
// A condition belongs to a rule
|
|
130
|
+
RuleCondition.belongsTo(models.AutomationRule, {
|
|
131
|
+
foreignKey: "ruleId",
|
|
132
|
+
as: "rule",
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
return RuleCondition;
|
|
137
|
+
};
|
package/models/RuleExecution.js
CHANGED
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
const { DataTypes } = require("sequelize");
|
|
2
|
-
|
|
3
|
-
module.exports = (sequelize) => {
|
|
4
|
-
const RuleExecution = sequelize.define(
|
|
5
|
-
"RuleExecution",
|
|
6
|
-
{
|
|
7
|
-
id: {
|
|
8
|
-
type: DataTypes.UUID,
|
|
9
|
-
defaultValue: DataTypes.UUIDV4,
|
|
10
|
-
primaryKey: true,
|
|
11
|
-
},
|
|
12
|
-
ruleId: {
|
|
13
|
-
type: DataTypes.UUID,
|
|
14
|
-
allowNull: false,
|
|
15
|
-
references: {
|
|
16
|
-
model: "AutomationRule",
|
|
17
|
-
key: "id",
|
|
18
|
-
},
|
|
19
|
-
comment: "Reference to the executed rule",
|
|
20
|
-
},
|
|
21
|
-
executionType: {
|
|
22
|
-
type: DataTypes.ENUM("SCHEDULED", "MANUAL", "API_TRIGGER"),
|
|
23
|
-
allowNull: false,
|
|
24
|
-
comment: "How the rule was triggered",
|
|
25
|
-
},
|
|
26
|
-
status: {
|
|
27
|
-
type: DataTypes.ENUM("RUNNING", "SUCCESS", "FAILED", "PARTIAL_SUCCESS"),
|
|
28
|
-
allowNull: false,
|
|
29
|
-
comment: "Execution status",
|
|
30
|
-
},
|
|
31
|
-
startTime: {
|
|
32
|
-
type: DataTypes.DATE,
|
|
33
|
-
allowNull: false,
|
|
34
|
-
comment: "When execution started",
|
|
35
|
-
},
|
|
36
|
-
endTime: {
|
|
37
|
-
type: DataTypes.DATE,
|
|
38
|
-
allowNull: true,
|
|
39
|
-
comment: "When execution completed",
|
|
40
|
-
},
|
|
41
|
-
duration: {
|
|
42
|
-
type: DataTypes.INTEGER,
|
|
43
|
-
allowNull: true,
|
|
44
|
-
comment: "Execution duration in milliseconds",
|
|
45
|
-
},
|
|
46
|
-
itemsEvaluated: {
|
|
47
|
-
type: DataTypes.INTEGER,
|
|
48
|
-
defaultValue: 0,
|
|
49
|
-
allowNull: false,
|
|
50
|
-
comment: "Number of items (campaigns/adsets/ads) evaluated",
|
|
51
|
-
},
|
|
52
|
-
itemsMatched: {
|
|
53
|
-
type: DataTypes.INTEGER,
|
|
54
|
-
defaultValue: 0,
|
|
55
|
-
allowNull: false,
|
|
56
|
-
comment: "Number of items that matched the conditions",
|
|
57
|
-
},
|
|
58
|
-
actionsExecuted: {
|
|
59
|
-
type: DataTypes.INTEGER,
|
|
60
|
-
defaultValue: 0,
|
|
61
|
-
allowNull: false,
|
|
62
|
-
comment: "Number of actions successfully executed",
|
|
63
|
-
},
|
|
64
|
-
actionsFailed: {
|
|
65
|
-
type: DataTypes.INTEGER,
|
|
66
|
-
defaultValue: 0,
|
|
67
|
-
allowNull: false,
|
|
68
|
-
comment: "Number of actions that failed",
|
|
69
|
-
},
|
|
70
|
-
errorMessage: {
|
|
71
|
-
type: DataTypes.TEXT,
|
|
72
|
-
allowNull: true,
|
|
73
|
-
comment: "Error message if execution failed",
|
|
74
|
-
},
|
|
75
|
-
executionDetails: {
|
|
76
|
-
type: DataTypes.JSONB,
|
|
77
|
-
allowNull: true,
|
|
78
|
-
comment: "Detailed execution results and logs",
|
|
79
|
-
},
|
|
80
|
-
matchedItems: {
|
|
81
|
-
type: DataTypes.JSONB,
|
|
82
|
-
allowNull: true,
|
|
83
|
-
comment: "List of items that matched the rule conditions and had actions applied",
|
|
84
|
-
},
|
|
85
|
-
triggeredBy: {
|
|
86
|
-
type: DataTypes.STRING(255),
|
|
87
|
-
allowNull: true,
|
|
88
|
-
comment: "User or system that triggered the execution",
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
tableName: "RuleExecutions",
|
|
93
|
-
timestamps: true,
|
|
94
|
-
// Remove indexes from model definition - they will be created by migration
|
|
95
|
-
}
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
RuleExecution.associate = (models) => {
|
|
99
|
-
// An execution belongs to a rule
|
|
100
|
-
RuleExecution.belongsTo(models.AutomationRule, {
|
|
101
|
-
foreignKey: "ruleId",
|
|
102
|
-
as: "rule",
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
return RuleExecution;
|
|
107
|
-
};
|
|
1
|
+
const { DataTypes } = require("sequelize");
|
|
2
|
+
|
|
3
|
+
module.exports = (sequelize) => {
|
|
4
|
+
const RuleExecution = sequelize.define(
|
|
5
|
+
"RuleExecution",
|
|
6
|
+
{
|
|
7
|
+
id: {
|
|
8
|
+
type: DataTypes.UUID,
|
|
9
|
+
defaultValue: DataTypes.UUIDV4,
|
|
10
|
+
primaryKey: true,
|
|
11
|
+
},
|
|
12
|
+
ruleId: {
|
|
13
|
+
type: DataTypes.UUID,
|
|
14
|
+
allowNull: false,
|
|
15
|
+
references: {
|
|
16
|
+
model: "AutomationRule",
|
|
17
|
+
key: "id",
|
|
18
|
+
},
|
|
19
|
+
comment: "Reference to the executed rule",
|
|
20
|
+
},
|
|
21
|
+
executionType: {
|
|
22
|
+
type: DataTypes.ENUM("SCHEDULED", "MANUAL", "API_TRIGGER"),
|
|
23
|
+
allowNull: false,
|
|
24
|
+
comment: "How the rule was triggered",
|
|
25
|
+
},
|
|
26
|
+
status: {
|
|
27
|
+
type: DataTypes.ENUM("RUNNING", "SUCCESS", "FAILED", "PARTIAL_SUCCESS"),
|
|
28
|
+
allowNull: false,
|
|
29
|
+
comment: "Execution status",
|
|
30
|
+
},
|
|
31
|
+
startTime: {
|
|
32
|
+
type: DataTypes.DATE,
|
|
33
|
+
allowNull: false,
|
|
34
|
+
comment: "When execution started",
|
|
35
|
+
},
|
|
36
|
+
endTime: {
|
|
37
|
+
type: DataTypes.DATE,
|
|
38
|
+
allowNull: true,
|
|
39
|
+
comment: "When execution completed",
|
|
40
|
+
},
|
|
41
|
+
duration: {
|
|
42
|
+
type: DataTypes.INTEGER,
|
|
43
|
+
allowNull: true,
|
|
44
|
+
comment: "Execution duration in milliseconds",
|
|
45
|
+
},
|
|
46
|
+
itemsEvaluated: {
|
|
47
|
+
type: DataTypes.INTEGER,
|
|
48
|
+
defaultValue: 0,
|
|
49
|
+
allowNull: false,
|
|
50
|
+
comment: "Number of items (campaigns/adsets/ads) evaluated",
|
|
51
|
+
},
|
|
52
|
+
itemsMatched: {
|
|
53
|
+
type: DataTypes.INTEGER,
|
|
54
|
+
defaultValue: 0,
|
|
55
|
+
allowNull: false,
|
|
56
|
+
comment: "Number of items that matched the conditions",
|
|
57
|
+
},
|
|
58
|
+
actionsExecuted: {
|
|
59
|
+
type: DataTypes.INTEGER,
|
|
60
|
+
defaultValue: 0,
|
|
61
|
+
allowNull: false,
|
|
62
|
+
comment: "Number of actions successfully executed",
|
|
63
|
+
},
|
|
64
|
+
actionsFailed: {
|
|
65
|
+
type: DataTypes.INTEGER,
|
|
66
|
+
defaultValue: 0,
|
|
67
|
+
allowNull: false,
|
|
68
|
+
comment: "Number of actions that failed",
|
|
69
|
+
},
|
|
70
|
+
errorMessage: {
|
|
71
|
+
type: DataTypes.TEXT,
|
|
72
|
+
allowNull: true,
|
|
73
|
+
comment: "Error message if execution failed",
|
|
74
|
+
},
|
|
75
|
+
executionDetails: {
|
|
76
|
+
type: DataTypes.JSONB,
|
|
77
|
+
allowNull: true,
|
|
78
|
+
comment: "Detailed execution results and logs",
|
|
79
|
+
},
|
|
80
|
+
matchedItems: {
|
|
81
|
+
type: DataTypes.JSONB,
|
|
82
|
+
allowNull: true,
|
|
83
|
+
comment: "List of items that matched the rule conditions and had actions applied",
|
|
84
|
+
},
|
|
85
|
+
triggeredBy: {
|
|
86
|
+
type: DataTypes.STRING(255),
|
|
87
|
+
allowNull: true,
|
|
88
|
+
comment: "User or system that triggered the execution",
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
tableName: "RuleExecutions",
|
|
93
|
+
timestamps: true,
|
|
94
|
+
// Remove indexes from model definition - they will be created by migration
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
RuleExecution.associate = (models) => {
|
|
99
|
+
// An execution belongs to a rule
|
|
100
|
+
RuleExecution.belongsTo(models.AutomationRule, {
|
|
101
|
+
foreignKey: "ruleId",
|
|
102
|
+
as: "rule",
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
return RuleExecution;
|
|
107
|
+
};
|
package/models/RulesValues.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const RulesValues = sequelize.define(
|
|
3
|
-
"RulesValues",
|
|
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
|
-
permissions: {
|
|
20
|
-
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
21
|
-
allowNull: false,
|
|
22
|
-
defaultValue: [],
|
|
23
|
-
},
|
|
24
|
-
feature: {
|
|
25
|
-
type: DataTypes.STRING,
|
|
26
|
-
allowNull: true,
|
|
27
|
-
},
|
|
28
|
-
parentId: {
|
|
29
|
-
type: DataTypes.UUID,
|
|
30
|
-
allowNull: true,
|
|
31
|
-
references: {
|
|
32
|
-
model: "RulesValues",
|
|
33
|
-
key: "id",
|
|
34
|
-
},
|
|
35
|
-
onDelete: "CASCADE",
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
tableName: "RulesValues",
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
// Self-referential association to define sub-rules
|
|
44
|
-
RulesValues.hasMany(RulesValues, {
|
|
45
|
-
as: "subRules",
|
|
46
|
-
foreignKey: "parentId",
|
|
47
|
-
onDelete: "CASCADE",
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
RulesValues.belongsTo(RulesValues, {
|
|
51
|
-
as: "parentRule",
|
|
52
|
-
foreignKey: "parentId",
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
return RulesValues;
|
|
56
|
-
};
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const RulesValues = sequelize.define(
|
|
3
|
+
"RulesValues",
|
|
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
|
+
permissions: {
|
|
20
|
+
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
21
|
+
allowNull: false,
|
|
22
|
+
defaultValue: [],
|
|
23
|
+
},
|
|
24
|
+
feature: {
|
|
25
|
+
type: DataTypes.STRING,
|
|
26
|
+
allowNull: true,
|
|
27
|
+
},
|
|
28
|
+
parentId: {
|
|
29
|
+
type: DataTypes.UUID,
|
|
30
|
+
allowNull: true,
|
|
31
|
+
references: {
|
|
32
|
+
model: "RulesValues",
|
|
33
|
+
key: "id",
|
|
34
|
+
},
|
|
35
|
+
onDelete: "CASCADE",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
tableName: "RulesValues",
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
// Self-referential association to define sub-rules
|
|
44
|
+
RulesValues.hasMany(RulesValues, {
|
|
45
|
+
as: "subRules",
|
|
46
|
+
foreignKey: "parentId",
|
|
47
|
+
onDelete: "CASCADE",
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
RulesValues.belongsTo(RulesValues, {
|
|
51
|
+
as: "parentRule",
|
|
52
|
+
foreignKey: "parentId",
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return RulesValues;
|
|
56
|
+
};
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
module.exports = (sequelize, DataTypes) => {
|
|
2
|
-
const SingularChannel = sequelize.define(
|
|
3
|
-
"SingularChannel",
|
|
4
|
-
{
|
|
5
|
-
channelId: {
|
|
6
|
-
type: DataTypes.STRING,
|
|
7
|
-
allowNull: false,
|
|
8
|
-
unique: true,
|
|
9
|
-
},
|
|
10
|
-
status: {
|
|
11
|
-
type: DataTypes.STRING,
|
|
12
|
-
allowNull: false,
|
|
13
|
-
defaultValue: "free",
|
|
14
|
-
validate: {
|
|
15
|
-
isIn: [["free", "used", "archived"]],
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
connectedCampaigns: {
|
|
19
|
-
type: DataTypes.JSONB,
|
|
20
|
-
allowNull: false,
|
|
21
|
-
defaultValue: [],
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
tableName: "singular_rsoc_channels",
|
|
26
|
-
timestamps: true,
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
return SingularChannel;
|
|
31
|
-
};
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const SingularChannel = sequelize.define(
|
|
3
|
+
"SingularChannel",
|
|
4
|
+
{
|
|
5
|
+
channelId: {
|
|
6
|
+
type: DataTypes.STRING,
|
|
7
|
+
allowNull: false,
|
|
8
|
+
unique: true,
|
|
9
|
+
},
|
|
10
|
+
status: {
|
|
11
|
+
type: DataTypes.STRING,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
defaultValue: "free",
|
|
14
|
+
validate: {
|
|
15
|
+
isIn: [["free", "used", "archived"]],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
connectedCampaigns: {
|
|
19
|
+
type: DataTypes.JSONB,
|
|
20
|
+
allowNull: false,
|
|
21
|
+
defaultValue: [],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
tableName: "singular_rsoc_channels",
|
|
26
|
+
timestamps: true,
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
return SingularChannel;
|
|
31
|
+
};
|