@ampsec/platform-client 87.3.0 → 87.4.0
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/build/src/dto/index.d.ts +1 -0
- package/build/src/dto/index.js +1 -0
- package/build/src/dto/index.js.map +1 -1
- package/build/src/dto/ruleSet.dto.d.ts +38 -0
- package/build/src/dto/ruleSet.dto.js +18 -0
- package/build/src/dto/ruleSet.dto.js.map +1 -0
- package/build/src/dto/rules.dto.d.ts +233 -16
- package/build/src/dto/rules.dto.js +69 -7
- package/build/src/dto/rules.dto.js.map +1 -1
- package/package.json +1 -1
- package/src/dto/index.ts +1 -0
- package/src/dto/ruleSet.dto.ts +19 -0
- package/src/dto/rules.dto.ts +140 -7
package/build/src/dto/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export * from './providers.dto';
|
|
|
33
33
|
export * from './reportResults.dto';
|
|
34
34
|
export * from './riskContributors.dto';
|
|
35
35
|
export * from './rules.dto';
|
|
36
|
+
export * from './ruleSet.dto';
|
|
36
37
|
export * from './saasAssets.dto';
|
|
37
38
|
export * from './saasComponents.dto';
|
|
38
39
|
export * from './saasUsers.dto';
|
package/build/src/dto/index.js
CHANGED
|
@@ -49,6 +49,7 @@ __exportStar(require("./providers.dto"), exports);
|
|
|
49
49
|
__exportStar(require("./reportResults.dto"), exports);
|
|
50
50
|
__exportStar(require("./riskContributors.dto"), exports);
|
|
51
51
|
__exportStar(require("./rules.dto"), exports);
|
|
52
|
+
__exportStar(require("./ruleSet.dto"), exports);
|
|
52
53
|
__exportStar(require("./saasAssets.dto"), exports);
|
|
53
54
|
__exportStar(require("./saasComponents.dto"), exports);
|
|
54
55
|
__exportStar(require("./saasUsers.dto"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,kDAAgC;AAChC,+CAA6B;AAC7B,8CAA4B;AAC5B,6CAA2B;AAC3B,mDAAiC;AACjC,2DAAyC;AACzC,uDAAqC;AACrC,8CAA4B;AAC5B,iDAA+B;AAC/B,sDAAoC;AACpC,qDAAmC;AACnC,yDAAuC;AACvC,wCAAsB;AACtB,2DAAyC;AACzC,gEAA8C;AAC9C,uDAAqC;AACrC,2DAAyC;AACzC,0DAAwC;AACxC,6CAA2B;AAC3B,0CAAwB;AACxB,kDAAgC;AAChC,iDAA+B;AAC/B,yDAAuC;AACvC,qDAAmC;AACnC,8CAA4B;AAC5B,wCAAsB;AACtB,gDAA8B;AAC9B,qDAAmC;AACnC,6CAA2B;AAC3B,6CAA2B;AAC3B,kDAAgC;AAChC,sDAAoC;AACpC,yDAAuC;AACvC,8CAA4B;AAC5B,mDAAiC;AACjC,uDAAqC;AACrC,kDAAgC;AAChC,mDAAiC;AACjC,iDAA+B;AAC/B,gDAA8B;AAC9B,oDAAkC;AAClC,+CAA6B;AAC7B,wDAAsC;AACtC,kDAAgC;AAChC,8CAA4B;AAC5B,sDAAoC;AACpC,+CAA6B;AAC7B,wDAAsC;AACtC,sDAAoC;AACpC,iDAA+B;AAC/B,8DAA4C;AAC5C,yDAAuC;AACvC,6DAA2C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,kDAAgC;AAChC,+CAA6B;AAC7B,8CAA4B;AAC5B,6CAA2B;AAC3B,mDAAiC;AACjC,2DAAyC;AACzC,uDAAqC;AACrC,8CAA4B;AAC5B,iDAA+B;AAC/B,sDAAoC;AACpC,qDAAmC;AACnC,yDAAuC;AACvC,wCAAsB;AACtB,2DAAyC;AACzC,gEAA8C;AAC9C,uDAAqC;AACrC,2DAAyC;AACzC,0DAAwC;AACxC,6CAA2B;AAC3B,0CAAwB;AACxB,kDAAgC;AAChC,iDAA+B;AAC/B,yDAAuC;AACvC,qDAAmC;AACnC,8CAA4B;AAC5B,wCAAsB;AACtB,gDAA8B;AAC9B,qDAAmC;AACnC,6CAA2B;AAC3B,6CAA2B;AAC3B,kDAAgC;AAChC,sDAAoC;AACpC,yDAAuC;AACvC,8CAA4B;AAC5B,gDAA8B;AAC9B,mDAAiC;AACjC,uDAAqC;AACrC,kDAAgC;AAChC,mDAAiC;AACjC,iDAA+B;AAC/B,gDAA8B;AAC9B,oDAAkC;AAClC,+CAA6B;AAC7B,wDAAsC;AACtC,kDAAgC;AAChC,8CAA4B;AAC5B,sDAAoC;AACpC,+CAA6B;AAC7B,wDAAsC;AACtC,sDAAoC;AACpC,iDAA+B;AAC/B,8DAA4C;AAC5C,yDAAuC;AACvC,6DAA2C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const RULESET_CREATE_SCHEMA: z.ZodObject<{
|
|
3
|
+
tid: z.ZodOptional<z.ZodString>;
|
|
4
|
+
cid: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
7
|
+
is_default: z.ZodDefault<z.ZodBoolean>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
name: string;
|
|
10
|
+
is_default: boolean;
|
|
11
|
+
description?: string | null | undefined;
|
|
12
|
+
tid?: string | undefined;
|
|
13
|
+
cid?: string | null | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
name: string;
|
|
16
|
+
description?: string | null | undefined;
|
|
17
|
+
tid?: string | undefined;
|
|
18
|
+
cid?: string | null | undefined;
|
|
19
|
+
is_default?: boolean | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const RULESET_UPDATE_SCHEMA: z.ZodObject<{
|
|
22
|
+
name: z.ZodOptional<z.ZodString>;
|
|
23
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
24
|
+
is_default: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
+
cid: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
name?: string | undefined;
|
|
28
|
+
description?: string | null | undefined;
|
|
29
|
+
cid?: string | null | undefined;
|
|
30
|
+
is_default?: boolean | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
name?: string | undefined;
|
|
33
|
+
description?: string | null | undefined;
|
|
34
|
+
cid?: string | null | undefined;
|
|
35
|
+
is_default?: boolean | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
export type RuleSetCreateDto = z.infer<typeof RULESET_CREATE_SCHEMA>;
|
|
38
|
+
export type RuleSetUpdateDto = z.infer<typeof RULESET_UPDATE_SCHEMA>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RULESET_UPDATE_SCHEMA = exports.RULESET_CREATE_SCHEMA = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.RULESET_CREATE_SCHEMA = zod_1.z.object({
|
|
6
|
+
tid: zod_1.z.string().optional(),
|
|
7
|
+
cid: zod_1.z.string().optional().nullable(),
|
|
8
|
+
name: zod_1.z.string(),
|
|
9
|
+
description: zod_1.z.string().optional().nullable(),
|
|
10
|
+
is_default: zod_1.z.boolean().default(false),
|
|
11
|
+
});
|
|
12
|
+
exports.RULESET_UPDATE_SCHEMA = zod_1.z.object({
|
|
13
|
+
name: zod_1.z.string().optional(),
|
|
14
|
+
description: zod_1.z.string().optional().nullable(),
|
|
15
|
+
is_default: zod_1.z.boolean().optional(),
|
|
16
|
+
cid: zod_1.z.string().optional().nullable(),
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=ruleSet.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruleSet.dto.js","sourceRoot":"","sources":["../../../src/dto/ruleSet.dto.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AAET,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACrC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC7C,UAAU,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACvC,CAAC,CAAC;AAEU,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC7C,UAAU,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAClC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAC"}
|
|
@@ -1,51 +1,212 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Flat condition format (backward compatible)
|
|
4
|
+
* Used when submitting simple or flat conditions
|
|
5
|
+
*/
|
|
6
|
+
export declare const _FlatConditionSchema: z.ZodObject<{
|
|
7
|
+
type: z.ZodEnum<["bool", "numeric", "string", "array", "datetime"]>;
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
operator: z.ZodString;
|
|
10
|
+
value: z.ZodOptional<z.ZodAny>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
name: string;
|
|
13
|
+
type: "string" | "numeric" | "array" | "datetime" | "bool";
|
|
14
|
+
operator: string;
|
|
15
|
+
value?: any;
|
|
16
|
+
}, {
|
|
17
|
+
name: string;
|
|
18
|
+
type: "string" | "numeric" | "array" | "datetime" | "bool";
|
|
19
|
+
operator: string;
|
|
20
|
+
value?: any;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Hierarchical condition group format (new)
|
|
24
|
+
* Supports nested AND/OR logic with unlimited depth
|
|
25
|
+
*/
|
|
26
|
+
export declare const _ConditionGroupSchema: z.ZodType<any>;
|
|
27
|
+
/**
|
|
28
|
+
* Action format
|
|
29
|
+
* Each action has a type and associated data
|
|
30
|
+
*/
|
|
31
|
+
export declare const _ActionSchema: z.ZodObject<{
|
|
32
|
+
action_type: z.ZodEnum<["then", "else"]>;
|
|
33
|
+
action_data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
action_type: "then" | "else";
|
|
36
|
+
action_data?: Record<string, any> | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
action_type: "then" | "else";
|
|
39
|
+
action_data?: Record<string, any> | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Create rule schema - supports both flat and hierarchical conditions
|
|
43
|
+
*/
|
|
2
44
|
export declare const _CreateRuleSchema: z.ZodObject<{
|
|
3
|
-
|
|
45
|
+
rule_set_id: z.ZodString;
|
|
46
|
+
cid: z.ZodOptional<z.ZodString>;
|
|
47
|
+
tid: z.ZodOptional<z.ZodString>;
|
|
4
48
|
priority: z.ZodDefault<z.ZodNumber>;
|
|
5
|
-
conditions: z.ZodOptional<z.
|
|
6
|
-
|
|
49
|
+
conditions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
50
|
+
type: z.ZodEnum<["bool", "numeric", "string", "array", "datetime"]>;
|
|
51
|
+
name: z.ZodString;
|
|
52
|
+
operator: z.ZodString;
|
|
53
|
+
value: z.ZodOptional<z.ZodAny>;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
name: string;
|
|
56
|
+
type: "string" | "numeric" | "array" | "datetime" | "bool";
|
|
57
|
+
operator: string;
|
|
58
|
+
value?: any;
|
|
59
|
+
}, {
|
|
60
|
+
name: string;
|
|
61
|
+
type: "string" | "numeric" | "array" | "datetime" | "bool";
|
|
62
|
+
operator: string;
|
|
63
|
+
value?: any;
|
|
64
|
+
}>, "many">>;
|
|
65
|
+
conditionGroups: z.ZodOptional<z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">>;
|
|
66
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
67
|
+
action_type: z.ZodEnum<["then", "else"]>;
|
|
68
|
+
action_data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
action_type: "then" | "else";
|
|
71
|
+
action_data?: Record<string, any> | undefined;
|
|
72
|
+
}, {
|
|
73
|
+
action_type: "then" | "else";
|
|
74
|
+
action_data?: Record<string, any> | undefined;
|
|
75
|
+
}>, "many">>;
|
|
7
76
|
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
|
|
77
|
+
rule_set_id: string;
|
|
9
78
|
priority: number;
|
|
10
|
-
|
|
11
|
-
|
|
79
|
+
tid?: string | undefined;
|
|
80
|
+
cid?: string | undefined;
|
|
81
|
+
actions?: {
|
|
82
|
+
action_type: "then" | "else";
|
|
83
|
+
action_data?: Record<string, any> | undefined;
|
|
84
|
+
}[] | undefined;
|
|
85
|
+
conditions?: {
|
|
86
|
+
name: string;
|
|
87
|
+
type: "string" | "numeric" | "array" | "datetime" | "bool";
|
|
88
|
+
operator: string;
|
|
89
|
+
value?: any;
|
|
90
|
+
}[] | undefined;
|
|
91
|
+
conditionGroups?: any[] | undefined;
|
|
12
92
|
}, {
|
|
13
|
-
|
|
14
|
-
|
|
93
|
+
rule_set_id: string;
|
|
94
|
+
tid?: string | undefined;
|
|
95
|
+
cid?: string | undefined;
|
|
96
|
+
actions?: {
|
|
97
|
+
action_type: "then" | "else";
|
|
98
|
+
action_data?: Record<string, any> | undefined;
|
|
99
|
+
}[] | undefined;
|
|
100
|
+
conditions?: {
|
|
101
|
+
name: string;
|
|
102
|
+
type: "string" | "numeric" | "array" | "datetime" | "bool";
|
|
103
|
+
operator: string;
|
|
104
|
+
value?: any;
|
|
105
|
+
}[] | undefined;
|
|
15
106
|
priority?: number | undefined;
|
|
16
|
-
|
|
107
|
+
conditionGroups?: any[] | undefined;
|
|
17
108
|
}>;
|
|
109
|
+
/**
|
|
110
|
+
* Upsert rule schema - for updates
|
|
111
|
+
*/
|
|
18
112
|
export declare const _RuleUpsertSchema: z.ZodObject<{
|
|
19
113
|
id: z.ZodString;
|
|
20
114
|
priority: z.ZodOptional<z.ZodNumber>;
|
|
21
|
-
conditions: z.ZodOptional<z.
|
|
22
|
-
|
|
115
|
+
conditions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
116
|
+
type: z.ZodEnum<["bool", "numeric", "string", "array", "datetime"]>;
|
|
117
|
+
name: z.ZodString;
|
|
118
|
+
operator: z.ZodString;
|
|
119
|
+
value: z.ZodOptional<z.ZodAny>;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
name: string;
|
|
122
|
+
type: "string" | "numeric" | "array" | "datetime" | "bool";
|
|
123
|
+
operator: string;
|
|
124
|
+
value?: any;
|
|
125
|
+
}, {
|
|
126
|
+
name: string;
|
|
127
|
+
type: "string" | "numeric" | "array" | "datetime" | "bool";
|
|
128
|
+
operator: string;
|
|
129
|
+
value?: any;
|
|
130
|
+
}>, "many">>;
|
|
131
|
+
conditionGroups: z.ZodOptional<z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">>;
|
|
132
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
133
|
+
action_type: z.ZodEnum<["then", "else"]>;
|
|
134
|
+
action_data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
|
136
|
+
action_type: "then" | "else";
|
|
137
|
+
action_data?: Record<string, any> | undefined;
|
|
138
|
+
}, {
|
|
139
|
+
action_type: "then" | "else";
|
|
140
|
+
action_data?: Record<string, any> | undefined;
|
|
141
|
+
}>, "many">>;
|
|
142
|
+
rule_set_id: z.ZodOptional<z.ZodString>;
|
|
23
143
|
}, "strip", z.ZodTypeAny, {
|
|
24
144
|
id: string;
|
|
25
|
-
actions?:
|
|
145
|
+
actions?: {
|
|
146
|
+
action_type: "then" | "else";
|
|
147
|
+
action_data?: Record<string, any> | undefined;
|
|
148
|
+
}[] | undefined;
|
|
149
|
+
conditions?: {
|
|
150
|
+
name: string;
|
|
151
|
+
type: "string" | "numeric" | "array" | "datetime" | "bool";
|
|
152
|
+
operator: string;
|
|
153
|
+
value?: any;
|
|
154
|
+
}[] | undefined;
|
|
155
|
+
rule_set_id?: string | undefined;
|
|
26
156
|
priority?: number | undefined;
|
|
27
|
-
|
|
157
|
+
conditionGroups?: any[] | undefined;
|
|
28
158
|
}, {
|
|
29
159
|
id: string;
|
|
30
|
-
actions?:
|
|
160
|
+
actions?: {
|
|
161
|
+
action_type: "then" | "else";
|
|
162
|
+
action_data?: Record<string, any> | undefined;
|
|
163
|
+
}[] | undefined;
|
|
164
|
+
conditions?: {
|
|
165
|
+
name: string;
|
|
166
|
+
type: "string" | "numeric" | "array" | "datetime" | "bool";
|
|
167
|
+
operator: string;
|
|
168
|
+
value?: any;
|
|
169
|
+
}[] | undefined;
|
|
170
|
+
rule_set_id?: string | undefined;
|
|
31
171
|
priority?: number | undefined;
|
|
32
|
-
|
|
172
|
+
conditionGroups?: any[] | undefined;
|
|
33
173
|
}>;
|
|
34
174
|
export type CreateRuleDtoSchema = z.infer<typeof _CreateRuleSchema> & {
|
|
35
175
|
tid: string;
|
|
176
|
+
rule_set_id: string;
|
|
36
177
|
};
|
|
37
178
|
export type RuleUpsertDtoSchema = z.infer<typeof _RuleUpsertSchema>;
|
|
179
|
+
export type FlatConditionSchema = z.infer<typeof _FlatConditionSchema>;
|
|
180
|
+
export type ConditionGroupSchema = z.infer<typeof _ConditionGroupSchema>;
|
|
181
|
+
export type ActionSchema = z.infer<typeof _ActionSchema>;
|
|
182
|
+
/**
|
|
183
|
+
* Leaf condition (single condition)
|
|
184
|
+
* e.g. { type: "string", name: "severity", operator: "equal_to", value: "CRITICAL" }
|
|
185
|
+
*/
|
|
38
186
|
export type CompiledLeafCondition = {
|
|
39
187
|
type: string;
|
|
40
188
|
name: string;
|
|
41
189
|
operator: string;
|
|
42
190
|
value: unknown;
|
|
43
191
|
};
|
|
192
|
+
/**
|
|
193
|
+
* Composite condition (AND/OR grouping)
|
|
194
|
+
* e.g. { any: [...], all: [...] }
|
|
195
|
+
* Supports unlimited nesting
|
|
196
|
+
*/
|
|
44
197
|
export type CompiledCompositeCondition = {
|
|
45
198
|
any?: CompiledConditionNode[];
|
|
46
199
|
all?: CompiledConditionNode[];
|
|
47
200
|
};
|
|
201
|
+
/**
|
|
202
|
+
* A condition node is either a leaf condition or composite group
|
|
203
|
+
* Recursive type supporting arbitrary nesting depth
|
|
204
|
+
*/
|
|
48
205
|
export type CompiledConditionNode = CompiledLeafCondition | CompiledCompositeCondition;
|
|
206
|
+
/**
|
|
207
|
+
* Action payload structure
|
|
208
|
+
* Each action has a type and arbitrary metadata
|
|
209
|
+
*/
|
|
49
210
|
export type CompiledActionData = {
|
|
50
211
|
type: string;
|
|
51
212
|
[key: string]: unknown;
|
|
@@ -57,13 +218,69 @@ export type CompiledActionData = {
|
|
|
57
218
|
export type CompiledActions = {
|
|
58
219
|
[action_type: string]: CompiledActionData[];
|
|
59
220
|
};
|
|
60
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* Compiled rule as produced by compileRulesToJson()
|
|
223
|
+
* This is what RulesEngine.execute() receives
|
|
224
|
+
*/
|
|
61
225
|
export type CompiledRule = {
|
|
226
|
+
id: string;
|
|
62
227
|
priority: number;
|
|
63
228
|
conditions: CompiledConditionNode | null;
|
|
64
229
|
actions: CompiledActions;
|
|
65
230
|
};
|
|
231
|
+
/**
|
|
232
|
+
* Result type for getRuleSetByRuleIds()
|
|
233
|
+
* Maps rule ID to its compiled ruleset
|
|
234
|
+
*/
|
|
66
235
|
export type RuleSetByIdResult = {
|
|
67
236
|
ruleId: string;
|
|
68
237
|
ruleSet: CompiledRule[];
|
|
69
238
|
};
|
|
239
|
+
/**
|
|
240
|
+
* Database representation of a condition group (hierarchical storage)
|
|
241
|
+
* NOT used by RulesEngine - only internal storage
|
|
242
|
+
*/
|
|
243
|
+
export type ConditionGroupEntity = {
|
|
244
|
+
id: string;
|
|
245
|
+
rule_id: string;
|
|
246
|
+
parent_group_id: string | null;
|
|
247
|
+
behavior: 'any' | 'all';
|
|
248
|
+
sort_order: number;
|
|
249
|
+
conditions?: FlatConditionSchema[];
|
|
250
|
+
childGroups?: ConditionGroupEntity[];
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Database representation of a condition (flat storage)
|
|
254
|
+
* Can be used standalone (legacy) or within a ConditionGroup (new)
|
|
255
|
+
*/
|
|
256
|
+
export type ConditionEntity = {
|
|
257
|
+
id: string;
|
|
258
|
+
rule_id: string;
|
|
259
|
+
condition_group_id?: string | null;
|
|
260
|
+
type: string;
|
|
261
|
+
name: string;
|
|
262
|
+
operator: string;
|
|
263
|
+
value: unknown;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Compilation flow:
|
|
267
|
+
*
|
|
268
|
+
* Database Layer:
|
|
269
|
+
* Rule.conditionGroups: ConditionGroupEntity[] (hierarchical)
|
|
270
|
+
* Rule.conditions: ConditionEntity[] (flat - legacy fallback)
|
|
271
|
+
*
|
|
272
|
+
* ↓ RuleService.compileRulesToJson()
|
|
273
|
+
*
|
|
274
|
+
* Compilation Layer:
|
|
275
|
+
* buildConditionsFromGroups(conditionGroups, conditions)
|
|
276
|
+
* - If conditionGroups exist: recursively build tree via buildGroupNode()
|
|
277
|
+
* - If empty: fallback to flat conditions
|
|
278
|
+
* buildActions() wraps in array-of-arrays
|
|
279
|
+
*
|
|
280
|
+
* ↓ Returns CompiledRule[]
|
|
281
|
+
*
|
|
282
|
+
* RulesEngine Layer:
|
|
283
|
+
* RulesEngine.execute(compiledRules, input)
|
|
284
|
+
* - Processes CompiledConditionNode (any/all nested structure)
|
|
285
|
+
* - Actions are array of arrays: `response.then.push(...rule.actions.then)`
|
|
286
|
+
*/
|
|
@@ -1,18 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._RuleUpsertSchema = exports._CreateRuleSchema = void 0;
|
|
3
|
+
exports._RuleUpsertSchema = exports._CreateRuleSchema = exports._ActionSchema = exports._ConditionGroupSchema = exports._FlatConditionSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
/* ─── Create / Upsert
|
|
5
|
+
/* ─── Database Input Schemas (Create / Upsert) ──── */
|
|
6
|
+
/**
|
|
7
|
+
* Flat condition format (backward compatible)
|
|
8
|
+
* Used when submitting simple or flat conditions
|
|
9
|
+
*/
|
|
10
|
+
exports._FlatConditionSchema = zod_1.z.object({
|
|
11
|
+
type: zod_1.z.enum(['bool', 'numeric', 'string', 'array', 'datetime']),
|
|
12
|
+
name: zod_1.z.string(),
|
|
13
|
+
operator: zod_1.z.string(),
|
|
14
|
+
value: zod_1.z.any().optional(),
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Hierarchical condition group format (new)
|
|
18
|
+
* Supports nested AND/OR logic with unlimited depth
|
|
19
|
+
*/
|
|
20
|
+
exports._ConditionGroupSchema = zod_1.z.lazy(() => zod_1.z.object({
|
|
21
|
+
id: zod_1.z.string().optional(),
|
|
22
|
+
behavior: zod_1.z.enum(['any', 'all']),
|
|
23
|
+
sort_order: zod_1.z.number().default(0),
|
|
24
|
+
conditions: zod_1.z.array(exports._FlatConditionSchema).optional(),
|
|
25
|
+
childGroups: zod_1.z.array(exports._ConditionGroupSchema).optional(),
|
|
26
|
+
}));
|
|
27
|
+
/**
|
|
28
|
+
* Action format
|
|
29
|
+
* Each action has a type and associated data
|
|
30
|
+
*/
|
|
31
|
+
exports._ActionSchema = zod_1.z.object({
|
|
32
|
+
action_type: zod_1.z.enum(['then', 'else']),
|
|
33
|
+
action_data: zod_1.z.record(zod_1.z.any()).optional(),
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Create rule schema - supports both flat and hierarchical conditions
|
|
37
|
+
*/
|
|
6
38
|
exports._CreateRuleSchema = zod_1.z.object({
|
|
7
|
-
|
|
39
|
+
rule_set_id: zod_1.z.string(),
|
|
40
|
+
cid: zod_1.z.string().optional(),
|
|
41
|
+
tid: zod_1.z.string().optional(),
|
|
8
42
|
priority: zod_1.z.number().default(0),
|
|
9
|
-
conditions: zod_1.z.
|
|
10
|
-
|
|
43
|
+
conditions: zod_1.z.array(exports._FlatConditionSchema).optional(),
|
|
44
|
+
conditionGroups: zod_1.z.array(exports._ConditionGroupSchema).optional(),
|
|
45
|
+
actions: zod_1.z.array(exports._ActionSchema).optional(),
|
|
11
46
|
});
|
|
47
|
+
/**
|
|
48
|
+
* Upsert rule schema - for updates
|
|
49
|
+
*/
|
|
12
50
|
exports._RuleUpsertSchema = zod_1.z.object({
|
|
13
51
|
id: zod_1.z.string(),
|
|
14
52
|
priority: zod_1.z.number().optional(),
|
|
15
|
-
conditions: zod_1.z.
|
|
16
|
-
|
|
53
|
+
conditions: zod_1.z.array(exports._FlatConditionSchema).optional(),
|
|
54
|
+
conditionGroups: zod_1.z.array(exports._ConditionGroupSchema).optional(),
|
|
55
|
+
actions: zod_1.z.array(exports._ActionSchema).optional(),
|
|
56
|
+
rule_set_id: zod_1.z.string().optional(),
|
|
17
57
|
});
|
|
58
|
+
/**
|
|
59
|
+
* Compilation flow:
|
|
60
|
+
*
|
|
61
|
+
* Database Layer:
|
|
62
|
+
* Rule.conditionGroups: ConditionGroupEntity[] (hierarchical)
|
|
63
|
+
* Rule.conditions: ConditionEntity[] (flat - legacy fallback)
|
|
64
|
+
*
|
|
65
|
+
* ↓ RuleService.compileRulesToJson()
|
|
66
|
+
*
|
|
67
|
+
* Compilation Layer:
|
|
68
|
+
* buildConditionsFromGroups(conditionGroups, conditions)
|
|
69
|
+
* - If conditionGroups exist: recursively build tree via buildGroupNode()
|
|
70
|
+
* - If empty: fallback to flat conditions
|
|
71
|
+
* buildActions() wraps in array-of-arrays
|
|
72
|
+
*
|
|
73
|
+
* ↓ Returns CompiledRule[]
|
|
74
|
+
*
|
|
75
|
+
* RulesEngine Layer:
|
|
76
|
+
* RulesEngine.execute(compiledRules, input)
|
|
77
|
+
* - Processes CompiledConditionNode (any/all nested structure)
|
|
78
|
+
* - Actions are array of arrays: `response.then.push(...rule.actions.then)`
|
|
79
|
+
*/
|
|
18
80
|
//# sourceMappingURL=rules.dto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.dto.js","sourceRoot":"","sources":["../../../src/dto/rules.dto.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AAEtB,
|
|
1
|
+
{"version":3,"file":"rules.dto.js","sourceRoot":"","sources":["../../../src/dto/rules.dto.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AAEtB,uDAAuD;AAEvD;;;GAGG;AACU,QAAA,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAChE,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;IACpB,KAAK,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;CAC1B,CAAC,CAAC;AAEH;;;GAGG;AACU,QAAA,qBAAqB,GAAmB,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAC/D,OAAC,CAAC,MAAM,CAAC;IACP,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACzB,QAAQ,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAChC,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACjC,UAAU,EAAE,OAAC,CAAC,KAAK,CAAC,4BAAoB,CAAC,CAAC,QAAQ,EAAE;IACpD,WAAW,EAAE,OAAC,CAAC,KAAK,CAAC,6BAAqB,CAAC,CAAC,QAAQ,EAAE;CACvD,CAAC,CACH,CAAC;AAEF;;;GAGG;AACU,QAAA,aAAa,GAAG,OAAC,CAAC,MAAM,CAAC;IACpC,WAAW,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC1C,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE;IACvB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/B,UAAU,EAAE,OAAC,CAAC,KAAK,CAAC,4BAAoB,CAAC,CAAC,QAAQ,EAAE;IACpD,eAAe,EAAE,OAAC,CAAC,KAAK,CAAC,6BAAqB,CAAC,CAAC,QAAQ,EAAE;IAC1D,OAAO,EAAE,OAAC,CAAC,KAAK,CAAC,qBAAa,CAAC,CAAC,QAAQ,EAAE;CAC3C,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,UAAU,EAAE,OAAC,CAAC,KAAK,CAAC,4BAAoB,CAAC,CAAC,QAAQ,EAAE;IACpD,eAAe,EAAE,OAAC,CAAC,KAAK,CAAC,6BAAqB,CAAC,CAAC,QAAQ,EAAE;IAC1D,OAAO,EAAE,OAAC,CAAC,KAAK,CAAC,qBAAa,CAAC,CAAC,QAAQ,EAAE;IAC1C,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAoHH;;;;;;;;;;;;;;;;;;;;;GAqBG"}
|
package/package.json
CHANGED
package/src/dto/index.ts
CHANGED
|
@@ -33,6 +33,7 @@ export * from './providers.dto';
|
|
|
33
33
|
export * from './reportResults.dto';
|
|
34
34
|
export * from './riskContributors.dto';
|
|
35
35
|
export * from './rules.dto';
|
|
36
|
+
export * from './ruleSet.dto';
|
|
36
37
|
export * from './saasAssets.dto';
|
|
37
38
|
export * from './saasComponents.dto';
|
|
38
39
|
export * from './saasUsers.dto';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {z} from 'zod';
|
|
2
|
+
|
|
3
|
+
export const RULESET_CREATE_SCHEMA = z.object({
|
|
4
|
+
tid: z.string().optional(),
|
|
5
|
+
cid: z.string().optional().nullable(),
|
|
6
|
+
name: z.string(),
|
|
7
|
+
description: z.string().optional().nullable(),
|
|
8
|
+
is_default: z.boolean().default(false),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const RULESET_UPDATE_SCHEMA = z.object({
|
|
12
|
+
name: z.string().optional(),
|
|
13
|
+
description: z.string().optional().nullable(),
|
|
14
|
+
is_default: z.boolean().optional(),
|
|
15
|
+
cid: z.string().optional().nullable(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export type RuleSetCreateDto = z.infer<typeof RULESET_CREATE_SCHEMA>;
|
|
19
|
+
export type RuleSetUpdateDto = z.infer<typeof RULESET_UPDATE_SCHEMA>;
|
package/src/dto/rules.dto.ts
CHANGED
|
@@ -1,31 +1,90 @@
|
|
|
1
1
|
import {z} from 'zod';
|
|
2
2
|
|
|
3
|
-
/* ─── Create / Upsert
|
|
3
|
+
/* ─── Database Input Schemas (Create / Upsert) ──── */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Flat condition format (backward compatible)
|
|
7
|
+
* Used when submitting simple or flat conditions
|
|
8
|
+
*/
|
|
9
|
+
export const _FlatConditionSchema = z.object({
|
|
10
|
+
type: z.enum(['bool', 'numeric', 'string', 'array', 'datetime']),
|
|
11
|
+
name: z.string(),
|
|
12
|
+
operator: z.string(),
|
|
13
|
+
value: z.any().optional(),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Hierarchical condition group format (new)
|
|
18
|
+
* Supports nested AND/OR logic with unlimited depth
|
|
19
|
+
*/
|
|
20
|
+
export const _ConditionGroupSchema: z.ZodType<any> = z.lazy(() =>
|
|
21
|
+
z.object({
|
|
22
|
+
id: z.string().optional(),
|
|
23
|
+
behavior: z.enum(['any', 'all']),
|
|
24
|
+
sort_order: z.number().default(0),
|
|
25
|
+
conditions: z.array(_FlatConditionSchema).optional(),
|
|
26
|
+
childGroups: z.array(_ConditionGroupSchema).optional(),
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Action format
|
|
32
|
+
* Each action has a type and associated data
|
|
33
|
+
*/
|
|
34
|
+
export const _ActionSchema = z.object({
|
|
35
|
+
action_type: z.enum(['then', 'else']),
|
|
36
|
+
action_data: z.record(z.any()).optional(),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Create rule schema - supports both flat and hierarchical conditions
|
|
41
|
+
*/
|
|
4
42
|
export const _CreateRuleSchema = z.object({
|
|
5
|
-
|
|
43
|
+
rule_set_id: z.string(),
|
|
44
|
+
cid: z.string().optional(),
|
|
45
|
+
tid: z.string().optional(),
|
|
6
46
|
priority: z.number().default(0),
|
|
7
|
-
conditions: z.
|
|
8
|
-
|
|
47
|
+
conditions: z.array(_FlatConditionSchema).optional(),
|
|
48
|
+
conditionGroups: z.array(_ConditionGroupSchema).optional(),
|
|
49
|
+
actions: z.array(_ActionSchema).optional(),
|
|
9
50
|
});
|
|
10
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Upsert rule schema - for updates
|
|
54
|
+
*/
|
|
11
55
|
export const _RuleUpsertSchema = z.object({
|
|
12
56
|
id: z.string(),
|
|
13
57
|
priority: z.number().optional(),
|
|
14
|
-
conditions: z.
|
|
15
|
-
|
|
58
|
+
conditions: z.array(_FlatConditionSchema).optional(),
|
|
59
|
+
conditionGroups: z.array(_ConditionGroupSchema).optional(),
|
|
60
|
+
actions: z.array(_ActionSchema).optional(),
|
|
61
|
+
rule_set_id: z.string().optional(),
|
|
16
62
|
});
|
|
17
63
|
|
|
18
64
|
export type CreateRuleDtoSchema = z.infer<typeof _CreateRuleSchema> & {
|
|
19
65
|
tid: string;
|
|
66
|
+
rule_set_id: string;
|
|
20
67
|
};
|
|
21
68
|
|
|
22
69
|
export type RuleUpsertDtoSchema = z.infer<typeof _RuleUpsertSchema>;
|
|
23
70
|
|
|
71
|
+
export type FlatConditionSchema = z.infer<typeof _FlatConditionSchema>;
|
|
72
|
+
export type ConditionGroupSchema = z.infer<typeof _ConditionGroupSchema>;
|
|
73
|
+
export type ActionSchema = z.infer<typeof _ActionSchema>;
|
|
74
|
+
|
|
24
75
|
/* ─── Compiled Rule Types ─────────────────────────────────────────────────
|
|
25
76
|
* Describe the JSON shape produced by RuleService.compileRulesToJson()
|
|
26
77
|
* and consumed by the rules engine.
|
|
78
|
+
*
|
|
79
|
+
* NOTE: The RulesEngine receives COMPILED conditions (CompiledConditionNode),
|
|
80
|
+
* NOT raw database ConditionGroups. The compilation process converts the
|
|
81
|
+
* hierarchical ConditionGroup structure to this CompositeConditions format.
|
|
27
82
|
* ────────────────────────────────────────────────────────────────────────── */
|
|
28
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Leaf condition (single condition)
|
|
86
|
+
* e.g. { type: "string", name: "severity", operator: "equal_to", value: "CRITICAL" }
|
|
87
|
+
*/
|
|
29
88
|
export type CompiledLeafCondition = {
|
|
30
89
|
type: string;
|
|
31
90
|
name: string;
|
|
@@ -33,13 +92,26 @@ export type CompiledLeafCondition = {
|
|
|
33
92
|
value: unknown;
|
|
34
93
|
};
|
|
35
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Composite condition (AND/OR grouping)
|
|
97
|
+
* e.g. { any: [...], all: [...] }
|
|
98
|
+
* Supports unlimited nesting
|
|
99
|
+
*/
|
|
36
100
|
export type CompiledCompositeCondition = {
|
|
37
101
|
any?: CompiledConditionNode[];
|
|
38
102
|
all?: CompiledConditionNode[];
|
|
39
103
|
};
|
|
40
104
|
|
|
105
|
+
/**
|
|
106
|
+
* A condition node is either a leaf condition or composite group
|
|
107
|
+
* Recursive type supporting arbitrary nesting depth
|
|
108
|
+
*/
|
|
41
109
|
export type CompiledConditionNode = CompiledLeafCondition | CompiledCompositeCondition;
|
|
42
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Action payload structure
|
|
113
|
+
* Each action has a type and arbitrary metadata
|
|
114
|
+
*/
|
|
43
115
|
export type CompiledActionData = {
|
|
44
116
|
type: string;
|
|
45
117
|
[key: string]: unknown;
|
|
@@ -53,14 +125,75 @@ export type CompiledActions = {
|
|
|
53
125
|
[action_type: string]: CompiledActionData[];
|
|
54
126
|
};
|
|
55
127
|
|
|
56
|
-
/**
|
|
128
|
+
/**
|
|
129
|
+
* Compiled rule as produced by compileRulesToJson()
|
|
130
|
+
* This is what RulesEngine.execute() receives
|
|
131
|
+
*/
|
|
57
132
|
export type CompiledRule = {
|
|
133
|
+
id: string;
|
|
58
134
|
priority: number;
|
|
59
135
|
conditions: CompiledConditionNode | null;
|
|
60
136
|
actions: CompiledActions;
|
|
61
137
|
};
|
|
62
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Result type for getRuleSetByRuleIds()
|
|
141
|
+
* Maps rule ID to its compiled ruleset
|
|
142
|
+
*/
|
|
63
143
|
export type RuleSetByIdResult = {
|
|
64
144
|
ruleId: string;
|
|
65
145
|
ruleSet: CompiledRule[];
|
|
66
146
|
};
|
|
147
|
+
|
|
148
|
+
/* ─── Internal Database Types ──────────────────────────────────────────── */
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Database representation of a condition group (hierarchical storage)
|
|
152
|
+
* NOT used by RulesEngine - only internal storage
|
|
153
|
+
*/
|
|
154
|
+
export type ConditionGroupEntity = {
|
|
155
|
+
id: string;
|
|
156
|
+
rule_id: string;
|
|
157
|
+
parent_group_id: string | null;
|
|
158
|
+
behavior: 'any' | 'all';
|
|
159
|
+
sort_order: number;
|
|
160
|
+
conditions?: FlatConditionSchema[];
|
|
161
|
+
childGroups?: ConditionGroupEntity[];
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Database representation of a condition (flat storage)
|
|
166
|
+
* Can be used standalone (legacy) or within a ConditionGroup (new)
|
|
167
|
+
*/
|
|
168
|
+
export type ConditionEntity = {
|
|
169
|
+
id: string;
|
|
170
|
+
rule_id: string;
|
|
171
|
+
condition_group_id?: string | null;
|
|
172
|
+
type: string;
|
|
173
|
+
name: string;
|
|
174
|
+
operator: string;
|
|
175
|
+
value: unknown;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Compilation flow:
|
|
180
|
+
*
|
|
181
|
+
* Database Layer:
|
|
182
|
+
* Rule.conditionGroups: ConditionGroupEntity[] (hierarchical)
|
|
183
|
+
* Rule.conditions: ConditionEntity[] (flat - legacy fallback)
|
|
184
|
+
*
|
|
185
|
+
* ↓ RuleService.compileRulesToJson()
|
|
186
|
+
*
|
|
187
|
+
* Compilation Layer:
|
|
188
|
+
* buildConditionsFromGroups(conditionGroups, conditions)
|
|
189
|
+
* - If conditionGroups exist: recursively build tree via buildGroupNode()
|
|
190
|
+
* - If empty: fallback to flat conditions
|
|
191
|
+
* buildActions() wraps in array-of-arrays
|
|
192
|
+
*
|
|
193
|
+
* ↓ Returns CompiledRule[]
|
|
194
|
+
*
|
|
195
|
+
* RulesEngine Layer:
|
|
196
|
+
* RulesEngine.execute(compiledRules, input)
|
|
197
|
+
* - Processes CompiledConditionNode (any/all nested structure)
|
|
198
|
+
* - Actions are array of arrays: `response.then.push(...rule.actions.then)`
|
|
199
|
+
*/
|