@o3r/rules-engine 15.3.0-prerelease.9 → 15.3.0-rc.1
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/fesm2022/o3r-rules-engine-fixtures-jasmine.mjs +10 -19
- package/fesm2022/o3r-rules-engine-fixtures-jasmine.mjs.map +1 -1
- package/fesm2022/o3r-rules-engine-fixtures-jest.mjs +10 -19
- package/fesm2022/o3r-rules-engine-fixtures-jest.mjs.map +1 -1
- package/fesm2022/o3r-rules-engine.mjs +2375 -2458
- package/fesm2022/o3r-rules-engine.mjs.map +1 -1
- package/package.json +6 -6
- package/schematics/facts-service/schema.json +0 -3
- package/schematics/ng-add/schema.json +0 -3
- package/schematics/rules-engine-to-component/schema.json +0 -3
- package/types/o3r-rules-engine-fixtures-jasmine.d.ts +11 -14
- package/types/o3r-rules-engine-fixtures-jasmine.d.ts.map +1 -1
- package/types/o3r-rules-engine-fixtures-jest.d.ts +11 -14
- package/types/o3r-rules-engine-fixtures-jest.d.ts.map +1 -1
- package/types/o3r-rules-engine.d.ts +1060 -1095
- package/types/o3r-rules-engine.d.ts.map +1 -1
|
@@ -1,81 +1,72 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import * as
|
|
10
|
-
import {
|
|
11
|
-
import * as _ngrx_entity from '@ngrx/entity';
|
|
12
|
-
import { EntityState } from '@ngrx/entity';
|
|
13
|
-
import * as _ngrx_effects from '@ngrx/effects';
|
|
14
|
-
import { Actions } from '@ngrx/effects';
|
|
15
|
-
|
|
1
|
+
import { BehaviorSubject, Observable } from "rxjs";
|
|
2
|
+
import { Logger } from "@o3r/logger";
|
|
3
|
+
import { AsyncRequest, AsyncStoreItem, ConnectContentMessage, DevtoolsCommonOptions, DevtoolsServiceInterface, FailAsyncStoreItemEntitiesActionPayload, FromApiActionPayload, ItemIdentifier, Logger as Logger$1, MessageDataTypes, OtterMessageContent, RequestMessagesContentMessage, RulesEngineAction, RulesEngineActionHandler, Serializer, SetActionPayload, SetAsyncStoreItemEntitiesActionPayload, UpdateActionPayload } from "@o3r/core";
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
import { EnvironmentProviders, InjectionToken, ModuleWithProviders, PipeTransform } from "@angular/core";
|
|
6
|
+
import * as i1 from "@ngrx/store";
|
|
7
|
+
import { Action, ActionCreator, ActionReducer, ReducerTypes, Store } from "@ngrx/store";
|
|
8
|
+
import { EntityState } from "@ngrx/entity";
|
|
9
|
+
import * as i2 from "@ngrx/effects";
|
|
10
|
+
import { Actions } from "@ngrx/effects";
|
|
16
11
|
/** Represents all the supported facts types TOCHECK utils.Date vs Date */
|
|
17
|
-
type Facts = string | number | boolean | null | Date | Record<string, unknown> | unknown[];
|
|
12
|
+
export type Facts = string | number | boolean | null | Date | Record<string, unknown> | unknown[];
|
|
18
13
|
/** Fact basic value type */
|
|
19
|
-
type FactBasicValues = number | boolean | string | string[] | boolean[] | number[] | undefined;
|
|
14
|
+
export type FactBasicValues = number | boolean | string | string[] | boolean[] | number[] | undefined;
|
|
20
15
|
/** Map of fact name / type pairs */
|
|
21
|
-
interface FactDefinitions {
|
|
22
|
-
|
|
16
|
+
export interface FactDefinitions {
|
|
17
|
+
[factName: string]: unknown;
|
|
23
18
|
}
|
|
24
19
|
/** Return type of a fact factory */
|
|
25
|
-
type FactFactoryReturn<T> = Observable<T> | Promise<T> | T;
|
|
20
|
+
export type FactFactoryReturn<T> = Observable<T> | Promise<T> | T;
|
|
26
21
|
/** Set of facts */
|
|
27
|
-
type FactSet<T extends FactDefinitions> = {
|
|
28
|
-
[P in keyof T]: FactFactoryReturn<T[P] | undefined | null>;
|
|
29
|
-
};
|
|
22
|
+
export type FactSet<T extends FactDefinitions> = { [P in keyof T]: FactFactoryReturn<T[P] | undefined | null>; };
|
|
30
23
|
/** Fact stream type */
|
|
31
|
-
type FactValueStream<T = unknown> = Observable<T | undefined>;
|
|
24
|
+
export type FactValueStream<T = unknown> = Observable<T | undefined>;
|
|
32
25
|
/** Fact stream */
|
|
33
|
-
interface Fact<T = unknown> {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
export interface Fact<T = unknown> {
|
|
27
|
+
/** Fact ID */
|
|
28
|
+
id: string;
|
|
29
|
+
/** Stream of the fact fact value */
|
|
30
|
+
value$: FactValueStream<T>;
|
|
38
31
|
}
|
|
39
|
-
|
|
40
32
|
/**
|
|
41
33
|
* Rule Engine operator
|
|
42
34
|
*/
|
|
43
|
-
interface Operator<LeftExposed = unknown, RightExposed = unknown, LeftSupported = LeftExposed, RightSupported = RightExposed> {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
35
|
+
export interface Operator<LeftExposed = unknown, RightExposed = unknown, LeftSupported = LeftExposed, RightSupported = RightExposed> {
|
|
36
|
+
/** Operator name to use in condition */
|
|
37
|
+
name: string;
|
|
38
|
+
/** Priority in the dropdown display */
|
|
39
|
+
orderingWeight?: number;
|
|
40
|
+
/** Left Hand Value validator function */
|
|
41
|
+
validateLhs?: unknown extends LeftSupported ? (operand: unknown) => boolean : (operand: unknown) => operand is LeftSupported;
|
|
42
|
+
/** Right Hand Value validator function */
|
|
43
|
+
validateRhs?: unknown extends RightSupported ? (operand: unknown) => boolean : (operand: unknown) => operand is RightSupported;
|
|
44
|
+
/** Evaluate the values */
|
|
45
|
+
evaluator: (lhs: LeftSupported, rhs: RightSupported, operatorFactValues?: Record<string, Facts>) => boolean;
|
|
46
|
+
/** List of facts names that the operator can depend on */
|
|
47
|
+
factImplicitDependencies?: string[];
|
|
56
48
|
}
|
|
57
49
|
/**
|
|
58
50
|
* Rule Engine unary operator
|
|
59
51
|
*/
|
|
60
|
-
interface UnaryOperator<L = unknown> {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
52
|
+
export interface UnaryOperator<L = unknown> {
|
|
53
|
+
/** Operator name to use in condition */
|
|
54
|
+
name: string;
|
|
55
|
+
/** Left Hand Value validator function */
|
|
56
|
+
validateLhs?: unknown extends L ? (operand: unknown) => boolean : (operand: unknown) => operand is L;
|
|
57
|
+
/** Evaluate the values */
|
|
58
|
+
evaluator: (lhs: L) => boolean;
|
|
67
59
|
}
|
|
68
60
|
/**
|
|
69
61
|
* Alias for supported simple types in AEM to be used in the operators to avoid repetition of the
|
|
70
62
|
* (string | boolean | Date | number)
|
|
71
63
|
* This type reference is specifically handled by the rule operator extractor.
|
|
72
64
|
*/
|
|
73
|
-
type SupportedSimpleTypes = string | boolean | Date | number | null | undefined;
|
|
65
|
+
export type SupportedSimpleTypes = string | boolean | Date | number | null | undefined;
|
|
74
66
|
/**
|
|
75
67
|
* Any input that can be used as single parameter for Date constructor (Date, string, number)
|
|
76
68
|
*/
|
|
77
|
-
type DateInput = Date | string | number;
|
|
78
|
-
|
|
69
|
+
export type DateInput = Date | string | number;
|
|
79
70
|
/**
|
|
80
71
|
* Execute Operator
|
|
81
72
|
* @param lhs Left hand side
|
|
@@ -83,1510 +74,1484 @@ type DateInput = Date | string | number;
|
|
|
83
74
|
* @param operator Operator to compare values
|
|
84
75
|
* @param operatorFacts Facts that operator can depend on
|
|
85
76
|
*/
|
|
86
|
-
declare function executeOperator<L = unknown, R = unknown>(lhs: L, rhs: R, operator: Operator<L, R>, operatorFacts?: Record<string, Facts | undefined>): boolean;
|
|
77
|
+
export declare function executeOperator<L = unknown, R = unknown>(lhs: L, rhs: R, operator: Operator<L, R>, operatorFacts?: Record<string, Facts | undefined>): boolean;
|
|
87
78
|
/**
|
|
88
79
|
* Validate a number operand
|
|
89
80
|
* @param operand value of one of the operands
|
|
90
81
|
*/
|
|
91
|
-
declare function numberValidator(operand: unknown): operand is number | string;
|
|
82
|
+
export declare function numberValidator(operand: unknown): operand is number | string;
|
|
92
83
|
/**
|
|
93
84
|
* Validate an operand is a range of numbers
|
|
94
85
|
* @param operatorInput value of one of the operands
|
|
95
86
|
*/
|
|
96
|
-
declare function isRangeNumber(operatorInput: unknown): operatorInput is [number | string, number | string];
|
|
87
|
+
export declare function isRangeNumber(operatorInput: unknown): operatorInput is [number | string, number | string];
|
|
97
88
|
/**
|
|
98
89
|
* Verifies if the parameter is a valid date for the operator (getTime function available returning a number)
|
|
99
90
|
* @param operatorInput
|
|
100
91
|
*/
|
|
101
|
-
declare const isValidDate: (operatorInput: any) => operatorInput is Date;
|
|
92
|
+
export declare const isValidDate: (operatorInput: any) => operatorInput is Date;
|
|
102
93
|
/**
|
|
103
94
|
* Verifies if the parameter is a valid input for Date constructor (new Date returns a valid date)
|
|
104
95
|
* @param operatorInput
|
|
105
96
|
*/
|
|
106
|
-
declare const isValidDateInput: (operatorInput: any) => operatorInput is DateInput;
|
|
97
|
+
export declare const isValidDateInput: (operatorInput: any) => operatorInput is DateInput;
|
|
107
98
|
/**
|
|
108
99
|
* Verifies if the parameter is a valid date range
|
|
109
100
|
* @param operatorInput
|
|
110
101
|
*/
|
|
111
|
-
declare const isValidDateRange: (operatorInput: any) => operatorInput is [DateInput, DateInput];
|
|
102
|
+
export declare const isValidDateRange: (operatorInput: any) => operatorInput is [DateInput, DateInput];
|
|
112
103
|
/**
|
|
113
104
|
* Verifies if the parameter is a valid time input
|
|
114
105
|
* @param operatorInput
|
|
115
106
|
*/
|
|
116
|
-
declare const isValidTimeInput: (operatorInput: any) => operatorInput is string;
|
|
107
|
+
export declare const isValidTimeInput: (operatorInput: any) => operatorInput is string;
|
|
117
108
|
/**
|
|
118
109
|
* Verifies if the parameter is a valid time range
|
|
119
110
|
* @param operatorInput
|
|
120
111
|
*/
|
|
121
|
-
declare const isValidTimeRange: (operatorInput: any) => operatorInput is [string, string];
|
|
112
|
+
export declare const isValidTimeRange: (operatorInput: any) => operatorInput is [string, string];
|
|
122
113
|
/**
|
|
123
114
|
* Validate that a value is a supported simple type
|
|
124
115
|
* @param value value to validate
|
|
125
116
|
*/
|
|
126
|
-
declare function isSupportedSimpleTypes(value: unknown): value is SupportedSimpleTypes;
|
|
117
|
+
export declare function isSupportedSimpleTypes(value: unknown): value is SupportedSimpleTypes;
|
|
127
118
|
/**
|
|
128
119
|
* Validate that a value is a string
|
|
129
120
|
* @param value
|
|
130
121
|
*/
|
|
131
|
-
declare function isString(value: unknown): value is string;
|
|
122
|
+
export declare function isString(value: unknown): value is string;
|
|
132
123
|
/**
|
|
133
124
|
* Parse input to return RegExp
|
|
134
125
|
* @param inputRegExp
|
|
135
126
|
*/
|
|
136
|
-
declare function parseRegExp(inputRegExp: string): RegExp;
|
|
137
|
-
|
|
127
|
+
export declare function parseRegExp(inputRegExp: string): RegExp;
|
|
138
128
|
/**
|
|
139
129
|
* Check if any of the variable's value is equal to a specific value
|
|
140
130
|
* @title contains
|
|
141
131
|
*/
|
|
142
|
-
declare const arrayContains: Operator<SupportedSimpleTypes[], SupportedSimpleTypes>;
|
|
132
|
+
export declare const arrayContains: Operator<SupportedSimpleTypes[], SupportedSimpleTypes>;
|
|
143
133
|
/**
|
|
144
134
|
* Check if the specified text value is included in the text variable
|
|
145
135
|
* @title contains
|
|
146
136
|
*/
|
|
147
|
-
declare const stringContains: Operator<string, string>;
|
|
137
|
+
export declare const stringContains: Operator<string, string>;
|
|
148
138
|
/**
|
|
149
139
|
* Check if every value of the variable is different from a specific value
|
|
150
140
|
* @title does not contain
|
|
151
141
|
*/
|
|
152
|
-
declare const notArrayContains: Operator<SupportedSimpleTypes[], SupportedSimpleTypes>;
|
|
142
|
+
export declare const notArrayContains: Operator<SupportedSimpleTypes[], SupportedSimpleTypes>;
|
|
153
143
|
/**
|
|
154
144
|
* Check if the specified text value is not included in the text variable
|
|
155
145
|
* @title does not contain
|
|
156
146
|
*/
|
|
157
|
-
declare const notStringContains: Operator<string, string>;
|
|
147
|
+
export declare const notStringContains: Operator<string, string>;
|
|
158
148
|
/**
|
|
159
149
|
* Check if every value of the variable equals a specific value
|
|
160
150
|
* @title all equal to
|
|
161
151
|
*/
|
|
162
|
-
declare const allEqual: Operator<SupportedSimpleTypes[], SupportedSimpleTypes>;
|
|
152
|
+
export declare const allEqual: Operator<SupportedSimpleTypes[], SupportedSimpleTypes>;
|
|
163
153
|
/**
|
|
164
154
|
* Check if every numerical value of the variable is greater than a specific value
|
|
165
155
|
* @title all >
|
|
166
156
|
*/
|
|
167
|
-
declare const allGreater: Operator<SupportedSimpleTypes[], number | string>;
|
|
157
|
+
export declare const allGreater: Operator<SupportedSimpleTypes[], number | string>;
|
|
168
158
|
/**
|
|
169
159
|
* Check if every value of the variable is in a specific list
|
|
170
160
|
* @title all in
|
|
171
161
|
*/
|
|
172
|
-
declare const allIn: Operator<SupportedSimpleTypes[], SupportedSimpleTypes[]>;
|
|
162
|
+
export declare const allIn: Operator<SupportedSimpleTypes[], SupportedSimpleTypes[]>;
|
|
173
163
|
/**
|
|
174
164
|
* Check if every value of the variable is not in a specific list
|
|
175
165
|
* @title none in
|
|
176
166
|
*/
|
|
177
|
-
declare const allNotIn: Operator<SupportedSimpleTypes[], SupportedSimpleTypes[]>;
|
|
167
|
+
export declare const allNotIn: Operator<SupportedSimpleTypes[], SupportedSimpleTypes[]>;
|
|
178
168
|
/**
|
|
179
169
|
* Check if every numerical value of the variable is lower than a specific value
|
|
180
170
|
* @title all <
|
|
181
171
|
*/
|
|
182
|
-
declare const allLower: Operator<number[], number | string>;
|
|
172
|
+
export declare const allLower: Operator<number[], number | string>;
|
|
183
173
|
/**
|
|
184
174
|
* Check if every string value of the variable matches a specific pattern
|
|
185
175
|
* @title all match
|
|
186
176
|
*/
|
|
187
|
-
declare const allMatch: Operator<string[], string>;
|
|
177
|
+
export declare const allMatch: Operator<string[], string>;
|
|
188
178
|
/**
|
|
189
179
|
* Check if every value of the variable is included in a specified range
|
|
190
180
|
* @title all between
|
|
191
181
|
*/
|
|
192
|
-
declare const allRangeNumber: Operator<number[], [number | string, number | string]>;
|
|
182
|
+
export declare const allRangeNumber: Operator<number[], [number | string, number | string]>;
|
|
193
183
|
/**
|
|
194
184
|
* Check if at least one of the values of the variable equals a specific value
|
|
195
185
|
* @title one equal to
|
|
196
186
|
*/
|
|
197
|
-
declare const oneEquals: Operator<SupportedSimpleTypes[], SupportedSimpleTypes>;
|
|
187
|
+
export declare const oneEquals: Operator<SupportedSimpleTypes[], SupportedSimpleTypes>;
|
|
198
188
|
/**
|
|
199
189
|
* Check if one of the values of the variable is greater than a specific value
|
|
200
190
|
* @title one >
|
|
201
191
|
*/
|
|
202
|
-
declare const oneGreater: Operator<number[], number | string>;
|
|
192
|
+
export declare const oneGreater: Operator<number[], number | string>;
|
|
203
193
|
/**
|
|
204
194
|
* Check if at least one of the values of the variable is equal to one in a specified list
|
|
205
195
|
* @title one in
|
|
206
196
|
*/
|
|
207
|
-
declare const oneIn: Operator<SupportedSimpleTypes[], SupportedSimpleTypes[]>;
|
|
197
|
+
export declare const oneIn: Operator<SupportedSimpleTypes[], SupportedSimpleTypes[]>;
|
|
208
198
|
/**
|
|
209
199
|
* Check if one of the values of the variable is lower than a specific value
|
|
210
200
|
* @title one <
|
|
211
201
|
*/
|
|
212
|
-
declare const oneLower: Operator<number[], number | string>;
|
|
202
|
+
export declare const oneLower: Operator<number[], number | string>;
|
|
213
203
|
/**
|
|
214
204
|
* Check if one of the values of the variable matches a specific pattern
|
|
215
205
|
* @title one matches
|
|
216
206
|
*/
|
|
217
|
-
declare const oneMatches: Operator<string[], string>;
|
|
207
|
+
export declare const oneMatches: Operator<string[], string>;
|
|
218
208
|
/**
|
|
219
209
|
* Check if one of the values of the variable is included in a specified range
|
|
220
210
|
* @title one between
|
|
221
211
|
*/
|
|
222
|
-
declare const oneRangeNumber: Operator<number[], [number | string, number | string]>;
|
|
212
|
+
export declare const oneRangeNumber: Operator<number[], [number | string, number | string]>;
|
|
223
213
|
/**
|
|
224
214
|
* Check if the number of values of the variable is equal to a specific value
|
|
225
215
|
* @title number of =
|
|
226
216
|
*/
|
|
227
|
-
declare const lengthEquals: Operator<any[], number | string>;
|
|
217
|
+
export declare const lengthEquals: Operator<any[], number | string>;
|
|
228
218
|
/**
|
|
229
219
|
* Check if the number of values of the variable is different from a specific value
|
|
230
220
|
* @title number of ≠
|
|
231
221
|
*/
|
|
232
|
-
declare const lengthNotEquals: Operator<any[], number | string>;
|
|
222
|
+
export declare const lengthNotEquals: Operator<any[], number | string>;
|
|
233
223
|
/**
|
|
234
224
|
* Check if the number of values of the variable is lower or equal to a specific value
|
|
235
225
|
* @title number of ≤
|
|
236
226
|
*/
|
|
237
|
-
declare const lengthLessThanOrEquals: Operator<any[], number | string>;
|
|
227
|
+
export declare const lengthLessThanOrEquals: Operator<any[], number | string>;
|
|
238
228
|
/**
|
|
239
229
|
* Check if the number of values of the variable is lower than a specific value
|
|
240
230
|
* @title number of <
|
|
241
231
|
*/
|
|
242
|
-
declare const lengthLessThan: Operator<any[], number | string>;
|
|
232
|
+
export declare const lengthLessThan: Operator<any[], number | string>;
|
|
243
233
|
/**
|
|
244
234
|
* Check if the number of values of the variable is greater or equal to a specific value
|
|
245
235
|
* @title number of ≥
|
|
246
236
|
*/
|
|
247
|
-
declare const lengthGreaterThanOrEquals: Operator<any[], number | string>;
|
|
237
|
+
export declare const lengthGreaterThanOrEquals: Operator<any[], number | string>;
|
|
248
238
|
/**
|
|
249
239
|
* Check if the number of values of the variable is greater than a specific value
|
|
250
240
|
* @title number of >
|
|
251
241
|
*/
|
|
252
|
-
declare const lengthGreaterThan: Operator<any[], number | string>;
|
|
242
|
+
export declare const lengthGreaterThan: Operator<any[], number | string>;
|
|
253
243
|
/** List of all default array operators */
|
|
254
|
-
declare const arrayBasedOperators: (Operator<SupportedSimpleTypes[], SupportedSimpleTypes, SupportedSimpleTypes[], SupportedSimpleTypes> | Operator<string, string, string, string> | Operator<SupportedSimpleTypes[], string | number, SupportedSimpleTypes[], string | number> | Operator<SupportedSimpleTypes[], SupportedSimpleTypes[], SupportedSimpleTypes[], SupportedSimpleTypes[]> | Operator<number[], string | number, number[], string | number> | Operator<string[], string, string[], string> | Operator<number[], [string | number, string | number], number[], [string | number, string | number]> | Operator<any[], string | number, any[], string | number>)[];
|
|
255
|
-
|
|
244
|
+
export declare const arrayBasedOperators: (Operator<SupportedSimpleTypes[], SupportedSimpleTypes, SupportedSimpleTypes[], SupportedSimpleTypes> | Operator<string, string, string, string> | Operator<SupportedSimpleTypes[], string | number, SupportedSimpleTypes[], string | number> | Operator<SupportedSimpleTypes[], SupportedSimpleTypes[], SupportedSimpleTypes[], SupportedSimpleTypes[]> | Operator<number[], string | number, number[], string | number> | Operator<string[], string, string[], string> | Operator<number[], [string | number, string | number], number[], [string | number, string | number]> | Operator<any[], string | number, any[], string | number>)[];
|
|
256
245
|
/**
|
|
257
246
|
* Check if a variable is equal to a specific value
|
|
258
247
|
* @title is equal to
|
|
259
248
|
*/
|
|
260
|
-
declare const equals: Operator;
|
|
249
|
+
export declare const equals: Operator;
|
|
261
250
|
/**
|
|
262
251
|
* Check if a variable is different from a specific value
|
|
263
252
|
* @title is not equal to
|
|
264
253
|
*/
|
|
265
|
-
declare const notEquals: Operator;
|
|
254
|
+
export declare const notEquals: Operator;
|
|
266
255
|
/**
|
|
267
256
|
* Check if the variable's value is included in a specified list
|
|
268
257
|
* @title is in
|
|
269
258
|
*/
|
|
270
|
-
declare const inArray: Operator<SupportedSimpleTypes, SupportedSimpleTypes[]>;
|
|
259
|
+
export declare const inArray: Operator<SupportedSimpleTypes, SupportedSimpleTypes[]>;
|
|
271
260
|
/**
|
|
272
261
|
* Check if the variable's value is not included in the value list
|
|
273
262
|
* @title is not in
|
|
274
263
|
*/
|
|
275
|
-
declare const notInArray: Operator<SupportedSimpleTypes, SupportedSimpleTypes[]>;
|
|
264
|
+
export declare const notInArray: Operator<SupportedSimpleTypes, SupportedSimpleTypes[]>;
|
|
276
265
|
/**
|
|
277
266
|
* Check if the text variable is part of the specified value
|
|
278
267
|
* @title within
|
|
279
268
|
*/
|
|
280
|
-
declare const inString: Operator<string, string>;
|
|
269
|
+
export declare const inString: Operator<string, string>;
|
|
281
270
|
/**
|
|
282
271
|
* Check if the text variable is not part of the specified value
|
|
283
272
|
* @title not within
|
|
284
273
|
*/
|
|
285
|
-
declare const notInString: Operator<string, string>;
|
|
274
|
+
export declare const notInString: Operator<string, string>;
|
|
286
275
|
/**
|
|
287
276
|
* Check if the variable and its value are defined
|
|
288
277
|
* @title is defined
|
|
289
278
|
*/
|
|
290
|
-
declare const isDefined: UnaryOperator<any>;
|
|
279
|
+
export declare const isDefined: UnaryOperator<any>;
|
|
291
280
|
/**
|
|
292
281
|
* Check if the variable and its value are undefined
|
|
293
282
|
* @title is not defined
|
|
294
283
|
*/
|
|
295
|
-
declare const isUndefined: UnaryOperator<any>;
|
|
284
|
+
export declare const isUndefined: UnaryOperator<any>;
|
|
296
285
|
/**
|
|
297
286
|
* Check if the text variable matches the specified RegExp pattern
|
|
298
287
|
* @title matches the pattern
|
|
299
288
|
*/
|
|
300
|
-
declare const matchesPattern: Operator<string, string>;
|
|
289
|
+
export declare const matchesPattern: Operator<string, string>;
|
|
301
290
|
/** List of all default basic operators */
|
|
302
|
-
declare const basicOperators: (Operator<string, string, string, string> | Operator<unknown, unknown, unknown, unknown> | Operator<SupportedSimpleTypes, SupportedSimpleTypes[], SupportedSimpleTypes, SupportedSimpleTypes[]> | UnaryOperator<any>)[];
|
|
303
|
-
|
|
291
|
+
export declare const basicOperators: (Operator<string, string, string, string> | Operator<unknown, unknown, unknown, unknown> | Operator<SupportedSimpleTypes, SupportedSimpleTypes[], SupportedSimpleTypes, SupportedSimpleTypes[]> | UnaryOperator<any>)[];
|
|
304
292
|
/**
|
|
305
293
|
* Check if a date variable is in a specified date range
|
|
306
294
|
* @title is between
|
|
307
295
|
*/
|
|
308
|
-
declare const inRangeDate: Operator<Date, [DateInput, DateInput], DateInput>;
|
|
296
|
+
export declare const inRangeDate: Operator<Date, [DateInput, DateInput], DateInput>;
|
|
309
297
|
/**
|
|
310
298
|
* Check if the value of the variable is in the next x minutes
|
|
311
299
|
* @title is in next minutes
|
|
312
300
|
* @returns false for dates before `now` and for dates after `now` + `nextMinutes`, true for dates between `now` and `now` + `nextMinutes`
|
|
313
301
|
*/
|
|
314
|
-
declare const dateInNextMinutes: Operator<Date, number, DateInput, string | number>;
|
|
302
|
+
export declare const dateInNextMinutes: Operator<Date, number, DateInput, string | number>;
|
|
315
303
|
/**
|
|
316
304
|
* Check if the value of the variable is not in the next x minutes
|
|
317
305
|
* @title is not in next minutes
|
|
318
306
|
* @returns false for dates before `now` and for dates between `now` and `now` + `nextMinutes`, true for dates after `now` + `nextMinutes`
|
|
319
307
|
*/
|
|
320
|
-
declare const dateNotInNextMinutes: Operator<Date, number, DateInput, string | number>;
|
|
308
|
+
export declare const dateNotInNextMinutes: Operator<Date, number, DateInput, string | number>;
|
|
321
309
|
/**
|
|
322
310
|
* Check if a date variable is prior than a specified date
|
|
323
311
|
* @title is before
|
|
324
312
|
*/
|
|
325
|
-
declare const dateBefore: Operator<Date, DateInput, DateInput>;
|
|
313
|
+
export declare const dateBefore: Operator<Date, DateInput, DateInput>;
|
|
326
314
|
/**
|
|
327
315
|
* Check if a date variable is posterior than a specified date
|
|
328
316
|
* @title is after
|
|
329
317
|
*/
|
|
330
|
-
declare const dateAfter: Operator<Date, DateInput, DateInput>;
|
|
318
|
+
export declare const dateAfter: Operator<Date, DateInput, DateInput>;
|
|
331
319
|
/**
|
|
332
320
|
* Check if a date variable is the same as a specified date
|
|
333
321
|
* @title is equal to
|
|
334
322
|
*/
|
|
335
|
-
declare const dateEquals: Operator<Date, DateInput, DateInput>;
|
|
323
|
+
export declare const dateEquals: Operator<Date, DateInput, DateInput>;
|
|
336
324
|
/**
|
|
337
325
|
* Check if a date variable is different from a specified date
|
|
338
326
|
* @title is not equal
|
|
339
327
|
*/
|
|
340
|
-
declare const dateNotEquals: Operator<Date, DateInput, DateInput>;
|
|
341
|
-
declare const dateBasedOperators: (Operator<Date, [DateInput, DateInput], DateInput, [DateInput, DateInput]> | Operator<Date, number, DateInput, string | number> | Operator<Date, DateInput, DateInput, DateInput>)[];
|
|
342
|
-
|
|
328
|
+
export declare const dateNotEquals: Operator<Date, DateInput, DateInput>;
|
|
329
|
+
export declare const dateBasedOperators: (Operator<Date, [DateInput, DateInput], DateInput, [DateInput, DateInput]> | Operator<Date, number, DateInput, string | number> | Operator<Date, DateInput, DateInput, DateInput>)[];
|
|
343
330
|
/**
|
|
344
331
|
* Check if the number variable is greater or equal to a specific value
|
|
345
332
|
* @title ≥
|
|
346
333
|
*/
|
|
347
|
-
declare const greaterThanOrEqual: Operator<number, number, number | string, number | string>;
|
|
334
|
+
export declare const greaterThanOrEqual: Operator<number, number, number | string, number | string>;
|
|
348
335
|
/**
|
|
349
336
|
* Check if the number variable is greater than a specific value
|
|
350
337
|
* @title >
|
|
351
338
|
*/
|
|
352
|
-
declare const greaterThan: Operator<number, number, number | string, number | string>;
|
|
339
|
+
export declare const greaterThan: Operator<number, number, number | string, number | string>;
|
|
353
340
|
/**
|
|
354
341
|
* Check if the number variable is lower or equal to a specific value
|
|
355
342
|
* @title ≤
|
|
356
343
|
*/
|
|
357
|
-
declare const lessOrEqual: Operator<number, number, number | string, number | string>;
|
|
344
|
+
export declare const lessOrEqual: Operator<number, number, number | string, number | string>;
|
|
358
345
|
/**
|
|
359
346
|
* Check if the number variable is lower than a specific value
|
|
360
347
|
* @title <
|
|
361
348
|
*/
|
|
362
|
-
declare const lessThan: Operator<number, number, number | string, number | string>;
|
|
349
|
+
export declare const lessThan: Operator<number, number, number | string, number | string>;
|
|
363
350
|
/** List of all default number based operators */
|
|
364
|
-
declare const numberBasedOperators: Operator<number, number, string | number, string | number>[];
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
type NativeTypes = string | boolean | number;
|
|
351
|
+
export declare const numberBasedOperators: Operator<number, number, string | number, string | number>[];
|
|
352
|
+
export declare const operatorList: (import("@o3r/rules-engine").Operator<import("@o3r/rules-engine").SupportedSimpleTypes[], import("@o3r/rules-engine").SupportedSimpleTypes, import("@o3r/rules-engine").SupportedSimpleTypes[], import("@o3r/rules-engine").SupportedSimpleTypes> | import("@o3r/rules-engine").Operator<string, string, string, string> | import("@o3r/rules-engine").Operator<import("@o3r/rules-engine").SupportedSimpleTypes[], string | number, import("@o3r/rules-engine").SupportedSimpleTypes[], string | number> | import("@o3r/rules-engine").Operator<import("@o3r/rules-engine").SupportedSimpleTypes[], import("@o3r/rules-engine").SupportedSimpleTypes[], import("@o3r/rules-engine").SupportedSimpleTypes[], import("@o3r/rules-engine").SupportedSimpleTypes[]> | import("@o3r/rules-engine").Operator<number[], string | number, number[], string | number> | import("@o3r/rules-engine").Operator<string[], string, string[], string> | import("@o3r/rules-engine").Operator<number[], [string | number, string | number], number[], [string | number, string | number]> | import("@o3r/rules-engine").Operator<any[], string | number, any[], string | number> | import("@o3r/rules-engine").Operator<unknown, unknown, unknown, unknown> | import("@o3r/rules-engine").Operator<import("@o3r/rules-engine").SupportedSimpleTypes, import("@o3r/rules-engine").SupportedSimpleTypes[], import("@o3r/rules-engine").SupportedSimpleTypes, import("@o3r/rules-engine").SupportedSimpleTypes[]> | import("@o3r/rules-engine").UnaryOperator<any> | import("@o3r/rules-engine").Operator<Date, [import("@o3r/rules-engine").DateInput, import("@o3r/rules-engine").DateInput], import("@o3r/rules-engine").DateInput, [import("@o3r/rules-engine").DateInput, import("@o3r/rules-engine").DateInput]> | import("@o3r/rules-engine").Operator<Date, number, import("@o3r/rules-engine").DateInput, string | number> | import("@o3r/rules-engine").Operator<Date, import("@o3r/rules-engine").DateInput, import("@o3r/rules-engine").DateInput, import("@o3r/rules-engine").DateInput> | import("@o3r/rules-engine").Operator<number, number, string | number, string | number>)[];
|
|
353
|
+
export type NativeTypes = string | boolean | number;
|
|
369
354
|
/** Generic operand */
|
|
370
|
-
interface Operand<T extends string, U extends NativeTypes = NativeTypes> {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
355
|
+
export interface Operand<T extends string, U extends NativeTypes = NativeTypes> {
|
|
356
|
+
/** Operand type */
|
|
357
|
+
type: T;
|
|
358
|
+
/** Static value */
|
|
359
|
+
value: U;
|
|
375
360
|
}
|
|
376
361
|
/** Operand based on fact */
|
|
377
|
-
interface OperandFact extends Operand<'FACT', string> {
|
|
378
|
-
|
|
379
|
-
|
|
362
|
+
export interface OperandFact extends Operand<'FACT', string> {
|
|
363
|
+
/** JSONPath to deep read the fact value */
|
|
364
|
+
path?: string;
|
|
380
365
|
}
|
|
381
366
|
/** Condition available operand types */
|
|
382
|
-
type GenericOperand = OperandFact | Operand<'RUNTIME_FACT', string> | Operand<'LITERAL'>;
|
|
367
|
+
export type GenericOperand = OperandFact | Operand<'RUNTIME_FACT', string> | Operand<'LITERAL'>;
|
|
383
368
|
/** Condition object interface with unary operator */
|
|
384
|
-
interface UnaryOperation {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
369
|
+
export interface UnaryOperation {
|
|
370
|
+
/** Left Hand Side */
|
|
371
|
+
lhs: GenericOperand;
|
|
372
|
+
/** Operator */
|
|
373
|
+
operator: string;
|
|
389
374
|
}
|
|
390
375
|
/** Condition object interface */
|
|
391
|
-
interface BinaryOperation {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
376
|
+
export interface BinaryOperation {
|
|
377
|
+
/** Left Hand Side */
|
|
378
|
+
lhs: GenericOperand;
|
|
379
|
+
/** Right Hand Side */
|
|
380
|
+
rhs: GenericOperand;
|
|
381
|
+
/** Operator */
|
|
382
|
+
operator: string;
|
|
398
383
|
}
|
|
399
384
|
/** Nested Condition */
|
|
400
|
-
type NestedCondition = UnaryOperation | BinaryOperation | TopLevelCondition;
|
|
385
|
+
export type NestedCondition = UnaryOperation | BinaryOperation | TopLevelCondition;
|
|
401
386
|
/** All Condition */
|
|
402
|
-
type AllConditions = {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
387
|
+
export type AllConditions = {
|
|
388
|
+
all: NestedCondition[];
|
|
389
|
+
any?: never;
|
|
390
|
+
not?: never;
|
|
406
391
|
};
|
|
407
392
|
/** Any Condition */
|
|
408
|
-
type AnyConditions = {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
393
|
+
export type AnyConditions = {
|
|
394
|
+
any: NestedCondition[];
|
|
395
|
+
all?: never;
|
|
396
|
+
not?: never;
|
|
412
397
|
};
|
|
413
398
|
/** Not Condition */
|
|
414
|
-
type NotCondition = {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
399
|
+
export type NotCondition = {
|
|
400
|
+
not: NestedCondition;
|
|
401
|
+
all?: never;
|
|
402
|
+
any?: never;
|
|
418
403
|
};
|
|
419
404
|
/** Top level Condition in the rule definition */
|
|
420
|
-
type TopLevelCondition = AllConditions | AnyConditions | NotCondition | UnaryOperation | BinaryOperation;
|
|
405
|
+
export type TopLevelCondition = AllConditions | AnyConditions | NotCondition | UnaryOperation | BinaryOperation;
|
|
421
406
|
/** Event emitted in case the rule condition is passed */
|
|
422
|
-
interface RuleEvent {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
407
|
+
export interface RuleEvent {
|
|
408
|
+
/** Type (or name) of the event */
|
|
409
|
+
type: string;
|
|
410
|
+
/** list of parameter associated to the event */
|
|
411
|
+
params?: Record<string, any>;
|
|
427
412
|
}
|
|
428
413
|
/** Base for the Rule definition */
|
|
429
|
-
interface Rule {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
414
|
+
export interface Rule {
|
|
415
|
+
/** Unique id associated to a rule*/
|
|
416
|
+
id: string;
|
|
417
|
+
/** Runtime facts that are needed for the rule execution (sent by the CMS) */
|
|
418
|
+
inputRuntimeFacts: string[];
|
|
419
|
+
/** Runtime facts that are created/updated by the rule*/
|
|
420
|
+
outputRuntimeFacts: string[];
|
|
421
|
+
/** Name of the rule*/
|
|
422
|
+
name: string;
|
|
423
|
+
/** rootElement of the rule, that contains either a block, either an action list */
|
|
424
|
+
rootElement: AllBlock;
|
|
440
425
|
}
|
|
441
426
|
/**
|
|
442
427
|
* List of possible types of actions resulted as output of a rule execution
|
|
443
428
|
* @deprecated the actions are now depending of executing modules
|
|
444
429
|
*/
|
|
445
|
-
type ActionTypes = 'SET_FACT' | 'UPDATE_CONFIG' | 'UPDATE_ASSET' | 'UPDATE_LOCALISATION' | 'UPDATE_PLACEHOLDER';
|
|
430
|
+
export type ActionTypes = 'SET_FACT' | 'UPDATE_CONFIG' | 'UPDATE_ASSET' | 'UPDATE_LOCALISATION' | 'UPDATE_PLACEHOLDER';
|
|
446
431
|
/** Types associated to the condition blocks that are supported */
|
|
447
|
-
type ConditionBlockTypes = 'IF_ELSE';
|
|
432
|
+
export type ConditionBlockTypes = 'IF_ELSE';
|
|
448
433
|
/** Interface common to all elements */
|
|
449
|
-
interface RuleElement {
|
|
450
|
-
|
|
451
|
-
|
|
434
|
+
export interface RuleElement {
|
|
435
|
+
/** Type of the element*/
|
|
436
|
+
elementType: string;
|
|
452
437
|
}
|
|
453
438
|
/** Interface common to all actions */
|
|
454
|
-
interface ActionBlock extends RuleElement, RulesEngineAction {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
439
|
+
export interface ActionBlock extends RuleElement, RulesEngineAction {
|
|
440
|
+
elementType: 'ACTION';
|
|
441
|
+
actionType: string;
|
|
442
|
+
value: any;
|
|
458
443
|
}
|
|
459
444
|
/** Interface of action that sets or updates a temporary fact */
|
|
460
|
-
interface ActionSetTemporaryFactBlock extends ActionBlock {
|
|
461
|
-
|
|
462
|
-
|
|
445
|
+
export interface ActionSetTemporaryFactBlock extends ActionBlock {
|
|
446
|
+
actionType: 'SET_FACT';
|
|
447
|
+
fact: string;
|
|
463
448
|
}
|
|
464
449
|
/** Interface of block Rule */
|
|
465
|
-
interface RuleBlock extends RuleElement {
|
|
466
|
-
|
|
467
|
-
|
|
450
|
+
export interface RuleBlock extends RuleElement {
|
|
451
|
+
elementType: 'RULE_BLOCK';
|
|
452
|
+
blockType: ConditionBlockTypes;
|
|
468
453
|
}
|
|
469
454
|
/** All supported blocks (supporting nested structure) */
|
|
470
|
-
type AllBlock = IfElseBlock | (ActionBlock & Record<string, any>);
|
|
455
|
+
export type AllBlock = IfElseBlock | (ActionBlock & Record<string, any>);
|
|
471
456
|
/** Block representing an 'if else' condition. If no condition specified it will execute success elements only */
|
|
472
|
-
interface IfElseBlock extends RuleBlock {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
457
|
+
export interface IfElseBlock extends RuleBlock {
|
|
458
|
+
blockType: 'IF_ELSE';
|
|
459
|
+
successElements: AllBlock[];
|
|
460
|
+
failureElements: AllBlock[];
|
|
461
|
+
condition?: TopLevelCondition;
|
|
477
462
|
}
|
|
478
463
|
/** Interface of a ruleset as it's specified in the json file */
|
|
479
|
-
interface Ruleset {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
464
|
+
export interface Ruleset {
|
|
465
|
+
/** Unique id of the ruleset*/
|
|
466
|
+
id: string;
|
|
467
|
+
/** Name of the ruleset */
|
|
468
|
+
name: string;
|
|
469
|
+
/** Optional ruleset description */
|
|
470
|
+
description?: string;
|
|
471
|
+
/** List of rules associated to the ruleset */
|
|
472
|
+
rules: Rule[];
|
|
473
|
+
/** Optional date range where the ruleset will be executed*/
|
|
474
|
+
validityRange?: {
|
|
475
|
+
from?: string;
|
|
476
|
+
to?: string;
|
|
477
|
+
};
|
|
478
|
+
/**
|
|
479
|
+
* Components linked to the ruleset. If present the ruleset will not be active by default.
|
|
480
|
+
* 'or' condition: If at least one component has subscribed, the ruleset will become active.
|
|
481
|
+
*/
|
|
482
|
+
linkedComponents?: {
|
|
483
|
+
or: ItemIdentifier[];
|
|
484
|
+
};
|
|
500
485
|
}
|
|
501
|
-
|
|
502
486
|
/** Performance object supporting NodeJs Performance and Web Performance reporting */
|
|
503
|
-
type CrossPlatformPerformance = {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
487
|
+
export type CrossPlatformPerformance = {
|
|
488
|
+
/** @see Performance.mark */
|
|
489
|
+
mark: (...x: Parameters<Performance['mark']>) => ReturnType<Performance['mark']> | void;
|
|
490
|
+
/** @see Performance.measure */
|
|
491
|
+
measure: (measureName: string, startOrMeasureOptions?: string, endMark?: string) => ReturnType<Performance['measure']> | void;
|
|
508
492
|
};
|
|
509
493
|
/** Fact stream object to handle fact reference change */
|
|
510
|
-
interface FactObject<T> {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
494
|
+
export interface FactObject<T> {
|
|
495
|
+
/** Subject of fact stream */
|
|
496
|
+
subject: BehaviorSubject<Observable<T> | undefined>;
|
|
497
|
+
/** Stream of the fact value */
|
|
498
|
+
value$: Observable<T | undefined>;
|
|
515
499
|
}
|
|
516
500
|
/** Rule Engine constructor options */
|
|
517
|
-
interface RulesEngineOptions {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
501
|
+
export interface RulesEngineOptions {
|
|
502
|
+
/** List of facts */
|
|
503
|
+
facts?: Fact<Facts>[];
|
|
504
|
+
/** List of rules */
|
|
505
|
+
rules?: Ruleset[];
|
|
506
|
+
/** List of custom operators */
|
|
507
|
+
operators?: Operator<any, any>[];
|
|
508
|
+
/** Delay before fact stream defaulting value */
|
|
509
|
+
factDefaultDelay?: number;
|
|
510
|
+
/**
|
|
511
|
+
* Skip the rule and fact circular dependency checks
|
|
512
|
+
* Turn to true to increase the speed of the upsert of a rule
|
|
513
|
+
*/
|
|
514
|
+
skipCircularDependencyChecks?: boolean;
|
|
515
|
+
/**
|
|
516
|
+
* Provide debugger instance to the rules engine
|
|
517
|
+
*/
|
|
518
|
+
debugger?: EngineDebugger;
|
|
519
|
+
/**
|
|
520
|
+
* Instance of the performance reporter to use for performance measurements.
|
|
521
|
+
* @default window.performance on browser only, undefined on node
|
|
522
|
+
*/
|
|
523
|
+
performance?: CrossPlatformPerformance;
|
|
524
|
+
/**
|
|
525
|
+
* Name of the rules engine instance
|
|
526
|
+
* @default RulesEngine
|
|
527
|
+
*/
|
|
528
|
+
rulesEngineInstanceName?: string;
|
|
529
|
+
/**
|
|
530
|
+
* Client to log the warning and error message
|
|
531
|
+
*/
|
|
532
|
+
logger?: Logger$1;
|
|
549
533
|
}
|
|
550
534
|
/** Rule as stored in the rules engine */
|
|
551
|
-
interface EngineRule extends Rule {
|
|
552
|
-
|
|
553
|
-
|
|
535
|
+
export interface EngineRule extends Rule {
|
|
536
|
+
/** stream of the rule conditions result */
|
|
537
|
+
result$: BehaviorSubject<ActionBlock[]>;
|
|
554
538
|
}
|
|
555
539
|
/** Rule as stored in the rules engine */
|
|
556
|
-
interface EngineRuleset {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
540
|
+
export interface EngineRuleset {
|
|
541
|
+
/** Optional date range where the ruleset will be executed, it supports a dateString or a timestamp as number, more info on javascript Date() documentation */
|
|
542
|
+
validityRange?: {
|
|
543
|
+
from?: string | number;
|
|
544
|
+
to?: string | number;
|
|
545
|
+
};
|
|
546
|
+
/**
|
|
547
|
+
* Components linked to the ruleset. If present the ruleset will not be active by default.
|
|
548
|
+
* 'or' condition: If at least one component has subscribed, the ruleset will become active.
|
|
549
|
+
*/
|
|
550
|
+
linkedComponents?: {
|
|
551
|
+
or: ItemIdentifier[];
|
|
552
|
+
};
|
|
553
|
+
/** Unique id of the ruleset*/
|
|
554
|
+
id: string;
|
|
555
|
+
/** Stores the result of each rules from the ruleset */
|
|
556
|
+
rulesResultsSubject$: Observable<ActionBlock[]>;
|
|
573
557
|
}
|
|
574
558
|
/** Timestamp of a rules engine output event */
|
|
575
|
-
interface TimedEvent {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
559
|
+
export interface TimedEvent {
|
|
560
|
+
/** Timestamp value when the event occurs */
|
|
561
|
+
timestamp: number;
|
|
562
|
+
/** Duration of the execution */
|
|
563
|
+
duration?: number;
|
|
580
564
|
}
|
|
581
565
|
/** Fact change triggering the evaluation of a rule/execution of a ruleset */
|
|
582
|
-
interface EvaluationReason {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
566
|
+
export interface EvaluationReason {
|
|
567
|
+
/** Name of the fact that changed */
|
|
568
|
+
factName: string;
|
|
569
|
+
/** New value of the fact */
|
|
570
|
+
newValue?: Facts;
|
|
571
|
+
/** Old value of the fact */
|
|
572
|
+
oldValue?: Facts;
|
|
589
573
|
}
|
|
590
574
|
/** Result object resulted at the end of a rule evaluation */
|
|
591
|
-
interface RuleEvaluation extends TimedEvent {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
575
|
+
export interface RuleEvaluation extends TimedEvent {
|
|
576
|
+
/** Identifier of the evaluation (ruleset name + rule name) */
|
|
577
|
+
id: string;
|
|
578
|
+
/** Evaluated rule identifier */
|
|
579
|
+
rule: Pick<Rule, 'id' | 'name'>;
|
|
580
|
+
/** Actions outputted by the rule evaluation */
|
|
581
|
+
outputActions: ActionBlock[] | undefined;
|
|
582
|
+
/** Map containing the facts changes triggering the rule evaluation */
|
|
583
|
+
triggers: Record<string, Record<string, EvaluationReason>>;
|
|
584
|
+
/** Error object in case of rule evaluation failure */
|
|
585
|
+
error?: any;
|
|
586
|
+
/** Runtime facts with values at the end of rule evaluation */
|
|
587
|
+
temporaryFacts?: Record<string, Facts>;
|
|
588
|
+
/** Flag to notify if the rules evaluation comes from an old ruleset execution */
|
|
589
|
+
cached?: boolean;
|
|
606
590
|
}
|
|
607
591
|
/** Wrapped rule evaluation output */
|
|
608
|
-
interface RuleEvaluationOutput {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
592
|
+
export interface RuleEvaluationOutput {
|
|
593
|
+
/** Actions emitted at the end of rule evaluation */
|
|
594
|
+
actions: ActionBlock[] | undefined;
|
|
595
|
+
/** Rule evaluation output object */
|
|
596
|
+
evaluation?: RuleEvaluation;
|
|
597
|
+
/** Error object emitted at the end of rule evaluation, if any */
|
|
598
|
+
error?: any;
|
|
615
599
|
}
|
|
616
600
|
/** Base object resulted at the end of a ruleset execution */
|
|
617
|
-
interface BaseRulesetExecution {
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
601
|
+
export interface BaseRulesetExecution {
|
|
602
|
+
/** Id of the ruleset execution */
|
|
603
|
+
executionId: string;
|
|
604
|
+
/** Id of the ruleset which was executed */
|
|
605
|
+
rulesetId: string;
|
|
606
|
+
/** Name of the executed ruleset */
|
|
607
|
+
rulesetName: string;
|
|
608
|
+
/** Counter of executions for the ruleset */
|
|
609
|
+
executionCounter: number;
|
|
610
|
+
/** All input facts affecting the ruleset */
|
|
611
|
+
inputFacts: {
|
|
612
|
+
factName: string;
|
|
613
|
+
value: Facts;
|
|
614
|
+
}[];
|
|
615
|
+
/** Runtime facts used across the ruleset */
|
|
616
|
+
temporaryFacts?: Record<string, Facts>;
|
|
617
|
+
/** Facts changes that triggered the execution of the ruleset */
|
|
618
|
+
triggers: Record<string, Record<string, EvaluationReason>>;
|
|
619
|
+
/** List of evaluated rules accros ruleset execution */
|
|
620
|
+
rulesEvaluations: RuleEvaluation[];
|
|
637
621
|
}
|
|
638
622
|
/** Debug event emitted in case of successful ruleset execution */
|
|
639
|
-
interface RulesetExecutionEvent extends BaseRulesetExecution, TimedEvent {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
623
|
+
export interface RulesetExecutionEvent extends BaseRulesetExecution, TimedEvent {
|
|
624
|
+
/** Event type */
|
|
625
|
+
type: 'RulesetExecution';
|
|
626
|
+
/** List of the actions emitted at the end of ruleset execution */
|
|
627
|
+
outputActions: ActionBlock[];
|
|
644
628
|
}
|
|
645
629
|
/** Debug event emitted in case of ruleset execution failure */
|
|
646
|
-
interface RulesetExecutionErrorEvent extends BaseRulesetExecution, TimedEvent {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
630
|
+
export interface RulesetExecutionErrorEvent extends BaseRulesetExecution, TimedEvent {
|
|
631
|
+
/** Event type */
|
|
632
|
+
type: 'RulesetExecutionError';
|
|
633
|
+
/** List of rules causing the execution error*/
|
|
634
|
+
rulesCausingTheError: Pick<Rule, 'name' | 'id'>[];
|
|
635
|
+
/** List of outputted errors */
|
|
636
|
+
errors: any[];
|
|
653
637
|
}
|
|
654
638
|
/** Debug event emitted when active rulesets are changing */
|
|
655
|
-
interface ActiveRulesetsEvent extends TimedEvent {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
639
|
+
export interface ActiveRulesetsEvent extends TimedEvent {
|
|
640
|
+
/** Event type */
|
|
641
|
+
type: 'ActiveRulesets';
|
|
642
|
+
/** List of active rulesets */
|
|
643
|
+
rulesets: Pick<Ruleset, 'name' | 'id'>[];
|
|
660
644
|
}
|
|
661
645
|
/** Debug event emitted each time the Rules Engine outputs a list of actions */
|
|
662
|
-
interface AllActionsEvent extends TimedEvent {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
646
|
+
export interface AllActionsEvent extends TimedEvent {
|
|
647
|
+
/** event type */
|
|
648
|
+
type: 'AllActions';
|
|
649
|
+
/** List of emitted actions */
|
|
650
|
+
actions: ActionBlock[];
|
|
667
651
|
}
|
|
668
652
|
/** Debug event emitted when rulesets are registered to the rules engine */
|
|
669
|
-
interface AvailableRulesets extends TimedEvent {
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
653
|
+
export interface AvailableRulesets extends TimedEvent {
|
|
654
|
+
/** Event type */
|
|
655
|
+
type: 'AvailableRulesets';
|
|
656
|
+
/** Registered rulesets list */
|
|
657
|
+
availableRulesets: Pick<Ruleset, 'name' | 'id'>[];
|
|
674
658
|
}
|
|
675
659
|
/** Debug event emitted when facts are updated */
|
|
676
|
-
interface AvailableFactsSnapshot extends TimedEvent {
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
660
|
+
export interface AvailableFactsSnapshot extends TimedEvent {
|
|
661
|
+
/** Event type */
|
|
662
|
+
type: 'AvailableFactsSnapshot';
|
|
663
|
+
/** List of all facts */
|
|
664
|
+
facts: {
|
|
665
|
+
factName: string;
|
|
666
|
+
value: Facts;
|
|
667
|
+
}[];
|
|
684
668
|
}
|
|
685
669
|
/** Type of possible debug events emitted by Rules Engine */
|
|
686
|
-
type DebugEvent = RulesetExecutionEvent | RulesetExecutionErrorEvent | ActiveRulesetsEvent | AllActionsEvent | AvailableRulesets | AvailableFactsSnapshot;
|
|
687
|
-
|
|
670
|
+
export type DebugEvent = RulesetExecutionEvent | RulesetExecutionErrorEvent | ActiveRulesetsEvent | AllActionsEvent | AvailableRulesets | AvailableFactsSnapshot;
|
|
688
671
|
/** Rules engine */
|
|
689
|
-
declare class RulesEngine {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
672
|
+
export declare class RulesEngine {
|
|
673
|
+
/** Map of registered fact stream, this map is mutated by the ruleset executors */
|
|
674
|
+
private readonly factMap;
|
|
675
|
+
/** Subject containing the rulesets and the results stream*/
|
|
676
|
+
private readonly rulesetMapSubject;
|
|
677
|
+
/** Map of available operators */
|
|
678
|
+
operators: Record<string, Operator<unknown, unknown>>;
|
|
679
|
+
/** List of events for the current state of the rules engine */
|
|
680
|
+
readonly events$: Observable<ActionBlock[]>;
|
|
681
|
+
/** Delay before fact stream defaulting value */
|
|
682
|
+
factDefaultDelay?: number;
|
|
683
|
+
/**
|
|
684
|
+
* Instance of engine debug object; Undefined if debugMode is not active
|
|
685
|
+
*/
|
|
686
|
+
readonly engineDebug?: EngineDebugger;
|
|
687
|
+
/** Name of the rules engine instance */
|
|
688
|
+
readonly rulesEngineInstanceName: string;
|
|
689
|
+
/**
|
|
690
|
+
* Performance reporter to use for performance measurements.
|
|
691
|
+
* @default window.performance on browser only, undefined on node
|
|
692
|
+
*/
|
|
693
|
+
readonly performance: import("@o3r/rules-engine").CrossPlatformPerformance | undefined;
|
|
694
|
+
/**
|
|
695
|
+
* Log the engine errors
|
|
696
|
+
*/
|
|
697
|
+
readonly logger?: Logger;
|
|
698
|
+
/**
|
|
699
|
+
* Flag to check if the run is in debug mode or not
|
|
700
|
+
*/
|
|
701
|
+
get debugMode(): boolean;
|
|
702
|
+
/**
|
|
703
|
+
* Rules engine
|
|
704
|
+
* @param options rules engine options
|
|
705
|
+
*/
|
|
706
|
+
constructor(options?: RulesEngineOptions);
|
|
707
|
+
/**
|
|
708
|
+
* Attach debug events to actions stream if debug engine is activated
|
|
709
|
+
*/
|
|
710
|
+
private handleActionsStreamOutput;
|
|
711
|
+
/**
|
|
712
|
+
* Create the actions stream event based on provided active rulesets ids; Handle debug too
|
|
713
|
+
* @param ruleSets
|
|
714
|
+
*/
|
|
715
|
+
private prepareActionsStream;
|
|
716
|
+
/**
|
|
717
|
+
* Create or retrieve a fact stream
|
|
718
|
+
* The fact stream created will be registered in the engine
|
|
719
|
+
* @param id ID of the fact to retrieve
|
|
720
|
+
* @param factValue$ Value stream for the fact
|
|
721
|
+
*/
|
|
722
|
+
retrieveOrCreateFactStream<T = Facts>(id: string, factValue$?: Observable<T>): Observable<T | undefined>;
|
|
723
|
+
/**
|
|
724
|
+
* Retrieve the promise of the latest value of a fact.
|
|
725
|
+
* Return undefined if the fact is not defined.
|
|
726
|
+
* @param id ID of the fact to retrieve
|
|
727
|
+
*/
|
|
728
|
+
retrieveFactValue<T = unknown>(id: string): Promise<T | undefined> | undefined;
|
|
729
|
+
/**
|
|
730
|
+
* Update or insert fact in rules engine
|
|
731
|
+
* @param facts fact list to add / update
|
|
732
|
+
*/
|
|
733
|
+
upsertFacts<T = unknown>(facts: Fact<T> | Fact<T>[]): void;
|
|
734
|
+
/**
|
|
735
|
+
* Update or insert rule in rules engine
|
|
736
|
+
* @param rulesets
|
|
737
|
+
*/
|
|
738
|
+
upsertRulesets(rulesets: Ruleset[]): void;
|
|
739
|
+
/**
|
|
740
|
+
* Update or insert operator in rules engine
|
|
741
|
+
* @param operators operator list to add / update
|
|
742
|
+
*/
|
|
743
|
+
upsertOperators(operators: (Operator<any, any> | UnaryOperator<any>)[]): void;
|
|
744
|
+
/**
|
|
745
|
+
* Operator to apply on a stream of rulesets ids
|
|
746
|
+
* Returns a stream of actions outputted by the rules engine, corresponding to the rulesetsIds
|
|
747
|
+
*/
|
|
748
|
+
getEventStream<T extends ActionBlock = ActionBlock>(): (rulesetsIds$: Observable<string[] | undefined>) => Observable<T[]>;
|
|
749
|
+
/** Get the list of registered facts names */
|
|
750
|
+
getRegisteredFactsNames(): string[];
|
|
768
751
|
}
|
|
769
|
-
|
|
770
752
|
declare class RulesetExecutor {
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
753
|
+
/** retrieveFactFunc */
|
|
754
|
+
protected readonly rulesEngine: RulesEngine;
|
|
755
|
+
/** Map of available operators */
|
|
756
|
+
protected readonly operators: Record<string, Operator<unknown, unknown>>;
|
|
757
|
+
/** Delay before fact stream defaulting value */
|
|
758
|
+
readonly factDefaultDelay?: number;
|
|
759
|
+
/** Ruleset associated to the current executor*/
|
|
760
|
+
readonly ruleset: Ruleset;
|
|
761
|
+
/** Ruleset plugged to the fact stream, that contains actions stream result */
|
|
762
|
+
readonly engineRuleset: EngineRuleset;
|
|
763
|
+
private executionCounter;
|
|
764
|
+
/**
|
|
765
|
+
* Create a new ruleset executor
|
|
766
|
+
* @param ruleset Ruleset to evaluate
|
|
767
|
+
* @param rulesEngine Instance of the rules engine
|
|
768
|
+
*/
|
|
769
|
+
constructor(ruleset: Ruleset, rulesEngine: RulesEngine);
|
|
770
|
+
/**
|
|
771
|
+
* Recursively explores a rule to identify and collect input facts.
|
|
772
|
+
* Input facts are identified based on the 'FACT' type and operator-specific implicit dependencies.
|
|
773
|
+
* @param currentObject The current object being explored.
|
|
774
|
+
* @param ruleInputFacts A set to store the identified input facts for the rule.
|
|
775
|
+
*/
|
|
776
|
+
private collectRuleInputFacts;
|
|
777
|
+
/**
|
|
778
|
+
* Report performance mark for a rule run
|
|
779
|
+
* @param rule Rule to measure
|
|
780
|
+
* @param status status of the rule evaluation
|
|
781
|
+
*/
|
|
782
|
+
protected performanceMark(rule: Rule, status: 'start' | 'end'): void;
|
|
783
|
+
/**
|
|
784
|
+
* Get operand value stream according to its type
|
|
785
|
+
* @param operand operand of the condition
|
|
786
|
+
* @param factsValue
|
|
787
|
+
* @param runtimeFactValues
|
|
788
|
+
*/
|
|
789
|
+
protected getOperandValue(operand: GenericOperand | undefined, factsValue: Record<string, Facts | undefined>, runtimeFactValues: Record<string, Facts>): unknown;
|
|
790
|
+
/**
|
|
791
|
+
* Process a root rule from a ruleset, and return the associated actions to be processed
|
|
792
|
+
* Will also update the runtimeFactValues map that is ruleset wise
|
|
793
|
+
* Note that runtimeFactValues will be mutated by all the runtime facts actions executed
|
|
794
|
+
* @param rule
|
|
795
|
+
* @param factsValue
|
|
796
|
+
* @param runtimeFactValues
|
|
797
|
+
* @protected
|
|
798
|
+
*/
|
|
799
|
+
protected evaluateRule(rule: Rule, factsValue: Record<string, Facts | undefined>, runtimeFactValues: Record<string, Facts>): ActionBlock[];
|
|
800
|
+
/**
|
|
801
|
+
* Recursively process a block to extract all the actions keeping the order
|
|
802
|
+
* Note that runtimeFactValues will be mutated by all the runtime facts actions executed
|
|
803
|
+
* @param element
|
|
804
|
+
* @param factsValue
|
|
805
|
+
* @param runtimeFactValues This runtime fact map will be mutated by all the runtime facts actions executed
|
|
806
|
+
* @param actions
|
|
807
|
+
* @protected
|
|
808
|
+
*/
|
|
809
|
+
protected evaluateBlock(element: AllBlock, factsValue: Record<string, Facts | undefined>, runtimeFactValues: Record<string, Facts>, actions?: ActionBlock[]): ActionBlock[];
|
|
810
|
+
/**
|
|
811
|
+
* Returns true if the element is a IfElse block
|
|
812
|
+
* @param element
|
|
813
|
+
* @protected
|
|
814
|
+
*/
|
|
815
|
+
protected isIfElseBlock(element: AllBlock): element is IfElseBlock;
|
|
816
|
+
/**
|
|
817
|
+
* Returns true if the element is an action block
|
|
818
|
+
* @param element
|
|
819
|
+
* @protected
|
|
820
|
+
*/
|
|
821
|
+
protected isActionBlock(element: AllBlock): element is ActionBlock;
|
|
822
|
+
/**
|
|
823
|
+
* Returns true if the action sets a temporary fact
|
|
824
|
+
* @param element
|
|
825
|
+
* @protected
|
|
826
|
+
*/
|
|
827
|
+
protected isActionSetTemporaryFactBlock(element: ActionBlock): element is ActionSetTemporaryFactBlock;
|
|
828
|
+
/**
|
|
829
|
+
* Evaluate a condition block
|
|
830
|
+
* @param nestedCondition
|
|
831
|
+
* @param factsValue
|
|
832
|
+
* @param runtimeFactValues
|
|
833
|
+
* @protected
|
|
834
|
+
*/
|
|
835
|
+
protected evaluateCondition(nestedCondition: NestedCondition, factsValue: Record<string, Facts | undefined>, runtimeFactValues: Record<string, Facts>): boolean;
|
|
836
|
+
/**
|
|
837
|
+
* Find rule input facts
|
|
838
|
+
* @param obj
|
|
839
|
+
*/
|
|
840
|
+
protected readonly findRuleInputFacts: (obj: AllBlock) => string[];
|
|
841
|
+
/**
|
|
842
|
+
* Plug ruleset to fact streams and trigger a first evaluation
|
|
843
|
+
*/
|
|
844
|
+
protected plugRuleset(): EngineRuleset;
|
|
863
845
|
}
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
eventsStackLimit?: number;
|
|
846
|
+
export interface EngineDebuggerOptions {
|
|
847
|
+
/**
|
|
848
|
+
* Limit of events to keep in the stack before subscribing to the debugEvents$ stream.
|
|
849
|
+
* @default undefined no limit
|
|
850
|
+
*/
|
|
851
|
+
eventsStackLimit?: number;
|
|
871
852
|
}
|
|
872
853
|
/**
|
|
873
854
|
* Rules engine debugger object to emit debug events
|
|
874
855
|
*/
|
|
875
|
-
declare class EngineDebugger {
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
856
|
+
export declare class EngineDebugger {
|
|
857
|
+
private registeredRuleEngine?;
|
|
858
|
+
private registeredRulesets;
|
|
859
|
+
private readonly debugEventsSubject$;
|
|
860
|
+
private performanceMeasures$;
|
|
861
|
+
private readonly requestFactsSnapshot;
|
|
862
|
+
/** Stream emitting a debug event when is fired; timeline is kept */
|
|
863
|
+
readonly debugEvents$: Observable<DebugEvent>;
|
|
864
|
+
/** Retrieved the rules engine plugged to the debugger */
|
|
865
|
+
get rulesEngine(): RulesEngine | undefined;
|
|
866
|
+
/**
|
|
867
|
+
* Instantiate a rules engine debugger
|
|
868
|
+
* @param options Options to configure the debugger
|
|
869
|
+
*/
|
|
870
|
+
constructor(options?: EngineDebuggerOptions);
|
|
871
|
+
private initializePerformanceObserver;
|
|
872
|
+
private createBaseExecutionOutputObject;
|
|
873
|
+
private rulesetExecution;
|
|
874
|
+
private rulesetExecutionError;
|
|
875
|
+
/**
|
|
876
|
+
* Plug the debugger to a Rule Engine
|
|
877
|
+
* @param rulesEngine
|
|
878
|
+
*/
|
|
879
|
+
registerRuleEngine(rulesEngine: RulesEngine): void;
|
|
880
|
+
/**
|
|
881
|
+
* Handle ruleset execution debug info
|
|
882
|
+
* @param currRes
|
|
883
|
+
* @param prevRes
|
|
884
|
+
* @param allExecutionsValid
|
|
885
|
+
* @param rulesetInputFacts
|
|
886
|
+
* @param runtimeFactValues
|
|
887
|
+
* @param executionCounter
|
|
888
|
+
* @param ruleset
|
|
889
|
+
*/
|
|
890
|
+
handleDebugRulesetExecutionInfo(currRes: RuleEvaluationOutput[], prevRes: RuleEvaluationOutput[] | undefined, allExecutionsValid: boolean, rulesetInputFacts: string[], runtimeFactValues: Record<string, Facts>, executionCounter: number, ruleset: Ruleset): {
|
|
891
|
+
executionCounter: number;
|
|
892
|
+
rulesetOutputExecution: RuleEvaluation[];
|
|
893
|
+
allExecutionsValid: boolean;
|
|
894
|
+
rulesetTriggers: Record<string, Record<string, EvaluationReason>>;
|
|
895
|
+
};
|
|
896
|
+
/**
|
|
897
|
+
* Emits an 'AvailableRulesets' debug event when rulesets are registered to the rules engine
|
|
898
|
+
* @param rulesets
|
|
899
|
+
*/
|
|
900
|
+
addAvailableRulesets(rulesets: Ruleset[]): void;
|
|
901
|
+
/**
|
|
902
|
+
* Computes and emits an 'ActiveRulesets' debug event when the active rulesets are changing
|
|
903
|
+
* @param ruleSetExecutorMap map off all rulesets executors
|
|
904
|
+
* @param restrictiveRuleSets ids of the rulesets to activate; if not provided all registered rulesets will be considered as active
|
|
905
|
+
*/
|
|
906
|
+
activeRulesetsChange(ruleSetExecutorMap: Record<string, RulesetExecutor>, restrictiveRuleSets?: string[]): void;
|
|
907
|
+
/**
|
|
908
|
+
* Emits an 'AllActions' debug event each time the rules engine outputs the list of actions
|
|
909
|
+
* @param actions list of outputted actions
|
|
910
|
+
*/
|
|
911
|
+
allActionsChange(actions: ActionBlock[]): void;
|
|
912
|
+
/**
|
|
913
|
+
* Emits a 'RulesetExecution' debug event at the output of a successful ruleset execution
|
|
914
|
+
* @param ruleset
|
|
915
|
+
* @param executionCounter
|
|
916
|
+
* @param rulesetInputFacts
|
|
917
|
+
* @param allOutputActions
|
|
918
|
+
* @param runtimeFactValues
|
|
919
|
+
* @param rulesetTriggers
|
|
920
|
+
* @param rulesExecutions
|
|
921
|
+
*/
|
|
922
|
+
addRulesetExecutionEvent(ruleset: Ruleset, executionCounter: number, rulesetInputFacts: string[], allOutputActions: ActionBlock[], runtimeFactValues: Record<string, Facts>, rulesetTriggers: Record<string, Record<string, EvaluationReason>>, rulesExecutions: RuleEvaluation[]): void;
|
|
923
|
+
/**
|
|
924
|
+
* Emits a 'RulesetExecutionError' debug event at the output of a failing ruleset execution
|
|
925
|
+
* @param ruleset
|
|
926
|
+
* @param rulesetInputFacts
|
|
927
|
+
* @param executionCounter
|
|
928
|
+
* @param runtimeFactValues
|
|
929
|
+
* @param rulesetTriggers
|
|
930
|
+
* @param rulesExecutions
|
|
931
|
+
*/
|
|
932
|
+
addRulesetExecutionErrorEvent(ruleset: Ruleset, rulesetInputFacts: string[], executionCounter: number, runtimeFactValues: Record<string, Facts>, rulesetTriggers: Record<string, Record<string, EvaluationReason>>, rulesExecutions: RuleEvaluation[]): void;
|
|
933
|
+
/**
|
|
934
|
+
* Emits a 'AvailableFactsSnapshot' debug event when a fact value is updated
|
|
935
|
+
* @param _id
|
|
936
|
+
* @param factValue$
|
|
937
|
+
*/
|
|
938
|
+
addAvailableFactsSnapshotEvent(_id: string, factValue$: Observable<any>): void;
|
|
939
|
+
/**
|
|
940
|
+
* Returns a list of fact name and value pairs
|
|
941
|
+
* @param factsNames List of facts names to get the value for
|
|
942
|
+
*/
|
|
943
|
+
getFactsSnapshot(factsNames: string[]): Promise<{
|
|
944
|
+
factName: string;
|
|
945
|
+
value: any;
|
|
946
|
+
}[]>;
|
|
966
947
|
}
|
|
967
|
-
|
|
968
948
|
/**
|
|
969
949
|
* Determine if the condition is a properties condition
|
|
970
950
|
* @param condition Condition to analyze
|
|
971
951
|
*/
|
|
972
|
-
declare function isConditionProperties(condition: any): condition is BinaryOperation | UnaryOperation;
|
|
952
|
+
export declare function isConditionProperties(condition: any): condition is BinaryOperation | UnaryOperation;
|
|
973
953
|
/**
|
|
974
954
|
* Determine if the given operand is a Fact operand
|
|
975
955
|
* @param operand Operand to analyze
|
|
976
956
|
*/
|
|
977
|
-
declare function isOperandFact(operand: any): operand is OperandFact;
|
|
957
|
+
export declare function isOperandFact(operand: any): operand is OperandFact;
|
|
978
958
|
/**
|
|
979
959
|
* Determine if the given operand is a Inner Fact operand
|
|
980
960
|
* @param operand Operand to analyze
|
|
981
961
|
*/
|
|
982
|
-
declare function isOperandRuntimeFact(operand: any): operand is Operand<'RUNTIME_FACT', string>;
|
|
962
|
+
export declare function isOperandRuntimeFact(operand: any): operand is Operand<'RUNTIME_FACT', string>;
|
|
983
963
|
/**
|
|
984
964
|
* Determine if the given operand is a Static Value operand
|
|
985
965
|
* @param operand Operand to analyze
|
|
986
966
|
*/
|
|
987
|
-
declare function isOperandLiteral(operand: any): operand is Operand<'LITERAL'>;
|
|
967
|
+
export declare function isOperandLiteral(operand: any): operand is Operand<'LITERAL'>;
|
|
988
968
|
/**
|
|
989
969
|
* Determine if the given condition is All based child conditions
|
|
990
970
|
* @param condition Condition node
|
|
991
971
|
*/
|
|
992
|
-
declare function isAllConditions(condition: any): condition is AllConditions;
|
|
972
|
+
export declare function isAllConditions(condition: any): condition is AllConditions;
|
|
993
973
|
/**
|
|
994
974
|
* Determine if the given condition is Any based child conditions
|
|
995
975
|
* @param condition Condition node
|
|
996
976
|
*/
|
|
997
|
-
declare function isAnyConditions(condition: any): condition is AnyConditions;
|
|
977
|
+
export declare function isAnyConditions(condition: any): condition is AnyConditions;
|
|
998
978
|
/**
|
|
999
979
|
* Determine if the given condition is Not based child conditions
|
|
1000
980
|
* @param condition Condition node
|
|
1001
981
|
*/
|
|
1002
|
-
declare function isNotCondition(condition: any): condition is NotCondition;
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
982
|
+
export declare function isNotCondition(condition: any): condition is NotCondition;
|
|
983
|
+
export declare class FactsSnapshotComponent {
|
|
984
|
+
/**
|
|
985
|
+
* Full list of available facts with their current value
|
|
986
|
+
*/
|
|
987
|
+
readonly facts: import("@angular/core").InputSignal<{
|
|
988
|
+
factName: string;
|
|
989
|
+
value: Facts;
|
|
990
|
+
}[]>;
|
|
991
|
+
/**
|
|
992
|
+
* Search terms
|
|
993
|
+
*/
|
|
994
|
+
readonly search: import("@angular/core").WritableSignal<string>;
|
|
995
|
+
/**
|
|
996
|
+
* Filtered list of facts using search terms
|
|
997
|
+
*/
|
|
998
|
+
readonly filteredFacts: import("@angular/core").Signal<{
|
|
999
|
+
factName: string;
|
|
1000
|
+
value: Facts;
|
|
1001
|
+
}[]>;
|
|
1002
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FactsSnapshotComponent, never>;
|
|
1003
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<FactsSnapshotComponent, "o3r-facts-snapshot", never, {
|
|
1004
|
+
"facts": {
|
|
1005
|
+
"alias": "facts";
|
|
1006
|
+
"required": true;
|
|
1007
|
+
"isSignal": true;
|
|
1008
|
+
};
|
|
1009
|
+
}, {}, never, never, true, never>;
|
|
1025
1010
|
}
|
|
1026
|
-
|
|
1027
|
-
type RulesetExecutionStatus = 'Error' | 'Active' | 'Deactivated' | 'NoEffect';
|
|
1011
|
+
export type RulesetExecutionStatus = 'Error' | 'Active' | 'Deactivated' | 'NoEffect';
|
|
1028
1012
|
/**
|
|
1029
1013
|
* Model of a RulesetExecution with more information for debug purpose
|
|
1030
1014
|
*/
|
|
1031
|
-
type RulesetExecutionDebug = (RulesetExecutionEvent | RulesetExecutionErrorEvent) & {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1015
|
+
export type RulesetExecutionDebug = (RulesetExecutionEvent | RulesetExecutionErrorEvent) & {
|
|
1016
|
+
isActive: boolean;
|
|
1017
|
+
status: RulesetExecutionStatus;
|
|
1018
|
+
rulesetInformation: Ruleset | undefined;
|
|
1035
1019
|
};
|
|
1036
|
-
declare class RulesetHistoryPresComponent {
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
};
|
|
1020
|
+
export declare class RulesetHistoryPresComponent {
|
|
1021
|
+
private readonly cd;
|
|
1022
|
+
/**
|
|
1023
|
+
* Reflects the state of each ruleset expanded elements.
|
|
1024
|
+
* Each ruleset entry contains a list of subpanel that can be collapsed or expanded.
|
|
1025
|
+
* Ruleset whole panel status is store the 'ruleset' entry.
|
|
1026
|
+
* @example
|
|
1027
|
+
* Expanded ruleset with rule overview collapsed:
|
|
1028
|
+
* {'rulesetId': {'ruleset' : true, 'ruleOverview': false}}
|
|
1029
|
+
* @note Collapsing a ruleset will not reset the subpanel expansion status
|
|
1030
|
+
*/
|
|
1031
|
+
expansionStatus: {
|
|
1032
|
+
[key: string]: {
|
|
1033
|
+
[subpanel: string]: boolean;
|
|
1051
1034
|
};
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1035
|
+
};
|
|
1036
|
+
rulesetExecutions: import("@angular/core").InputSignal<RulesetExecutionDebug[] | null | undefined>;
|
|
1037
|
+
executionDurationFormat: import("@angular/core").InputSignal<string>;
|
|
1038
|
+
/**
|
|
1039
|
+
* Toggle a ruleset subpanel
|
|
1040
|
+
* @param ruleId
|
|
1041
|
+
* @param subpanel element to collapse. 'ruleset' will toggle the whole panel but won't reset the subpanels states.
|
|
1042
|
+
*/
|
|
1043
|
+
toggleExpansion(ruleId: string, subpanel: string): void;
|
|
1044
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RulesetHistoryPresComponent, never>;
|
|
1045
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<RulesetHistoryPresComponent, "o3r-ruleset-history-pres", never, {
|
|
1046
|
+
"rulesetExecutions": {
|
|
1047
|
+
"alias": "rulesetExecutions";
|
|
1048
|
+
"required": false;
|
|
1049
|
+
"isSignal": true;
|
|
1050
|
+
};
|
|
1051
|
+
"executionDurationFormat": {
|
|
1052
|
+
"alias": "executionDurationFormat";
|
|
1053
|
+
"required": false;
|
|
1054
|
+
"isSignal": true;
|
|
1055
|
+
};
|
|
1056
|
+
}, {}, never, never, true, never>;
|
|
1062
1057
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
static ɵpipe: i0.ɵɵPipeDeclaration<O3rFallbackToPipe, "o3rFallbackTo", true>;
|
|
1058
|
+
export declare class O3rFallbackToPipe implements PipeTransform {
|
|
1059
|
+
transform<T>(value: T, fallback?: string): T | string;
|
|
1060
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<O3rFallbackToPipe, never>;
|
|
1061
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<O3rFallbackToPipe, "o3rFallbackTo", true>;
|
|
1068
1062
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
static ɵpipe: i0.ɵɵPipeDeclaration<O3rJsonOrStringPipe, "o3rJsonOrString", true>;
|
|
1063
|
+
export declare class O3rJsonOrStringPipe implements PipeTransform {
|
|
1064
|
+
/**
|
|
1065
|
+
* @inheritDoc
|
|
1066
|
+
*/
|
|
1067
|
+
transform(value: any): string;
|
|
1068
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<O3rJsonOrStringPipe, never>;
|
|
1069
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<O3rJsonOrStringPipe, "o3rJsonOrString", true>;
|
|
1077
1070
|
}
|
|
1078
|
-
|
|
1079
1071
|
/**
|
|
1080
1072
|
* Compute the status of the execution depending on its execution event type, the output and whether the execution
|
|
1081
1073
|
* is still active
|
|
1082
1074
|
* @param rulesetExecution
|
|
1083
1075
|
* @param isActive
|
|
1084
1076
|
*/
|
|
1085
|
-
declare const getStatus: (rulesetExecution: RulesetExecutionErrorEvent | RulesetExecutionEvent, isActive: boolean) => RulesetExecutionStatus;
|
|
1077
|
+
export declare const getStatus: (rulesetExecution: RulesetExecutionErrorEvent | RulesetExecutionEvent, isActive: boolean) => RulesetExecutionStatus;
|
|
1086
1078
|
/**
|
|
1087
1079
|
* Transform the output of the debug reports into the model for the ruleset history debug panel
|
|
1088
1080
|
* @param events
|
|
1089
1081
|
* @param rulesetMap
|
|
1090
1082
|
*/
|
|
1091
|
-
declare const rulesetReportToHistory: (events: DebugEvent[], rulesetMap: Record<string, Ruleset>) => RulesetExecutionDebug[];
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
rulesEngineStackLimit?: number;
|
|
1083
|
+
export declare const rulesetReportToHistory: (events: DebugEvent[], rulesetMap: Record<string, Ruleset>) => RulesetExecutionDebug[];
|
|
1084
|
+
export interface RulesEngineDevtoolsServiceOptions extends DevtoolsCommonOptions {
|
|
1085
|
+
/** Size of events list emitted by rules engine; When undefined all history will be kept */
|
|
1086
|
+
rulesEngineStackLimit?: number;
|
|
1096
1087
|
}
|
|
1097
1088
|
/** Rules Engine debug event Message Content */
|
|
1098
|
-
interface RulesEngineDebugEventsContentMessage extends OtterMessageContent<'rulesEngineEvents'> {
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1089
|
+
export interface RulesEngineDebugEventsContentMessage extends OtterMessageContent<'rulesEngineEvents'> {
|
|
1090
|
+
/** Map of registered rulesets */
|
|
1091
|
+
rulesetMap: Record<string, Ruleset>;
|
|
1092
|
+
/** List of event from the Rules Engine Debugger */
|
|
1093
|
+
events: DebugEvent[];
|
|
1103
1094
|
}
|
|
1104
1095
|
type RulesEngineMessageContents = RulesEngineDebugEventsContentMessage;
|
|
1105
1096
|
/** List of possible DataTypes for RulesEngine messages */
|
|
1106
|
-
type RulesEngineMessageDataTypes = MessageDataTypes<RulesEngineMessageContents>;
|
|
1097
|
+
export type RulesEngineMessageDataTypes = MessageDataTypes<RulesEngineMessageContents>;
|
|
1107
1098
|
/** List of all messages for configuration purpose */
|
|
1108
|
-
type AvailableRulesEngineMessageContents = RulesEngineMessageContents | ConnectContentMessage | RequestMessagesContentMessage<RulesEngineMessageDataTypes>;
|
|
1109
|
-
declare const isRulesEngineMessage: (message: any) => message is AvailableRulesEngineMessageContents;
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
1099
|
+
export type AvailableRulesEngineMessageContents = RulesEngineMessageContents | ConnectContentMessage | RequestMessagesContentMessage<RulesEngineMessageDataTypes>;
|
|
1100
|
+
export declare const isRulesEngineMessage: (message: any) => message is AvailableRulesEngineMessageContents;
|
|
1101
|
+
export declare class RulesEngineDevtoolsConsoleService implements DevtoolsServiceInterface {
|
|
1102
|
+
/** Name of the Window property to access to the devtools */
|
|
1103
|
+
static readonly windowModuleName = "rulesEngine";
|
|
1104
|
+
private readonly rulesEngineDevtools;
|
|
1105
|
+
private readonly options;
|
|
1106
|
+
constructor();
|
|
1107
|
+
/** @inheritDoc */
|
|
1108
|
+
activate(): void;
|
|
1109
|
+
/** Return the list of debug events emitted by rules engine */
|
|
1110
|
+
getCurrentRulesEngineEventsStack(): Promise<void>;
|
|
1111
|
+
/** Returns the list of active rulesets (name and id) at the moment when the function is called */
|
|
1112
|
+
getActiveRulesets(): Promise<void>;
|
|
1113
|
+
/** Returns the list of available rulesets (name and id) at the moment when the function is called */
|
|
1114
|
+
getAvailableRulesets(): Promise<void>;
|
|
1115
|
+
/** Returns the list of output actions emitted by the rules engine at the moment when the function is called */
|
|
1116
|
+
getAllOutputActions(): Promise<void>;
|
|
1117
|
+
/**
|
|
1118
|
+
* Get the list of executions for the given ruleset
|
|
1119
|
+
* @param rulesetId
|
|
1120
|
+
*/
|
|
1121
|
+
getRulesetExecutions(rulesetId: string): Promise<void>;
|
|
1122
|
+
/**
|
|
1123
|
+
* Check if the ruleset is activ in the moment when the function is called
|
|
1124
|
+
* @param rulesetId
|
|
1125
|
+
* @returns True if the ruleset is active; False if the ruleset is inactive or it does not exist
|
|
1126
|
+
*/
|
|
1127
|
+
isRulesetActive(rulesetId: string): Promise<void>;
|
|
1128
|
+
/**
|
|
1129
|
+
* Get the list of rules executed for the specified ruleset
|
|
1130
|
+
* @param rulesetId
|
|
1131
|
+
*/
|
|
1132
|
+
getRulesEvaluationsForRuleset(rulesetId: string): Promise<void>;
|
|
1133
|
+
/**
|
|
1134
|
+
* Get the list of input facts (name, current value) for the specified ruleset, at the moment when the function is called
|
|
1135
|
+
* @param rulesetId
|
|
1136
|
+
*/
|
|
1137
|
+
getInputFactsForRuleset(rulesetId: string): Promise<void>;
|
|
1138
|
+
/**
|
|
1139
|
+
* Get the list of triggers for the specified ruleset
|
|
1140
|
+
* @param rulesetId
|
|
1141
|
+
*/
|
|
1142
|
+
getTriggersForRuleset(rulesetId: string): Promise<void>;
|
|
1143
|
+
/**
|
|
1144
|
+
* Get the list of outputed actions emitted by the given ruleset, at the moment when the function is called
|
|
1145
|
+
* @param rulesetId
|
|
1146
|
+
*/
|
|
1147
|
+
getOutputActionsForRuleset(rulesetId: string): Promise<void>;
|
|
1148
|
+
/** Get the list of fact names and corresponding values */
|
|
1149
|
+
getAllFactsSnapshot(): Promise<void>;
|
|
1150
|
+
/**
|
|
1151
|
+
* Retrieve the ruleset information (rules, linkedComponents, validity range etc.) for a ruleset id
|
|
1152
|
+
* @param rulesetId
|
|
1153
|
+
*/
|
|
1154
|
+
getRulesetInformation(rulesetId: string): Promise<void>;
|
|
1155
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RulesEngineDevtoolsConsoleService, never>;
|
|
1156
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
1167
1157
|
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
1158
|
+
export declare class RulesEngineDevtoolsMessageService implements DevtoolsServiceInterface {
|
|
1159
|
+
private readonly rulesEngineDevtools;
|
|
1160
|
+
private readonly logger;
|
|
1161
|
+
private readonly options;
|
|
1162
|
+
private readonly forceEmitRulesEngineReport;
|
|
1163
|
+
private readonly sendMessage;
|
|
1164
|
+
private readonly destroyRef;
|
|
1165
|
+
constructor();
|
|
1166
|
+
/**
|
|
1167
|
+
* Function to trigger a re-send a requested messages to the Otter Chrome DevTools extension
|
|
1168
|
+
* @param only restricted list of messages to re-send
|
|
1169
|
+
*/
|
|
1170
|
+
private handleReEmitRequest;
|
|
1171
|
+
/**
|
|
1172
|
+
* Function to handle the incoming messages from Otter Chrome DevTools extension
|
|
1173
|
+
* @param message
|
|
1174
|
+
*/
|
|
1175
|
+
private handleEvents;
|
|
1176
|
+
private readonly serializeError;
|
|
1177
|
+
/**
|
|
1178
|
+
* Serialize exceptions in a way that will display the error message after a JSON.stringify()
|
|
1179
|
+
* @param debugEvent
|
|
1180
|
+
*/
|
|
1181
|
+
private serializeReportEvent;
|
|
1182
|
+
/**
|
|
1183
|
+
* Function to start the rules engine reporting to the Otter Chrome DevTools extension
|
|
1184
|
+
*/
|
|
1185
|
+
private startRulesEngineReport;
|
|
1186
|
+
/**
|
|
1187
|
+
* Function to connect the plugin to the Otter DevTools extension
|
|
1188
|
+
*/
|
|
1189
|
+
private connectPlugin;
|
|
1190
|
+
/** Activate the Otter DevTools */
|
|
1191
|
+
activate(): void;
|
|
1192
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RulesEngineDevtoolsMessageService, never>;
|
|
1193
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
1205
1194
|
}
|
|
1206
|
-
|
|
1207
1195
|
/**
|
|
1208
1196
|
* Rulesets model
|
|
1209
1197
|
*/
|
|
1210
|
-
interface RulesetsModel extends Ruleset {
|
|
1211
|
-
}
|
|
1198
|
+
export interface RulesetsModel extends Ruleset {}
|
|
1212
1199
|
/**
|
|
1213
1200
|
* Rulesets state details
|
|
1214
1201
|
*/
|
|
1215
|
-
interface RulesetsStateDetails extends AsyncStoreItem {
|
|
1216
|
-
}
|
|
1202
|
+
export interface RulesetsStateDetails extends AsyncStoreItem {}
|
|
1217
1203
|
/**
|
|
1218
1204
|
* Rulesets store state
|
|
1219
1205
|
*/
|
|
1220
|
-
interface RulesetsState extends EntityState<RulesetsModel>, RulesetsStateDetails {
|
|
1221
|
-
}
|
|
1206
|
+
export interface RulesetsState extends EntityState<RulesetsModel>, RulesetsStateDetails {}
|
|
1222
1207
|
/**
|
|
1223
1208
|
* Name of the Rulesets Store
|
|
1224
1209
|
*/
|
|
1225
|
-
declare const RULESETS_STORE_NAME = "rulesets";
|
|
1210
|
+
export declare const RULESETS_STORE_NAME = "rulesets";
|
|
1226
1211
|
/**
|
|
1227
1212
|
* Rulesets Store Interface
|
|
1228
1213
|
*/
|
|
1229
|
-
interface RulesetsStore {
|
|
1230
|
-
|
|
1231
|
-
|
|
1214
|
+
export interface RulesetsStore {
|
|
1215
|
+
/** Rulesets state */
|
|
1216
|
+
[RULESETS_STORE_NAME]: RulesetsState;
|
|
1232
1217
|
}
|
|
1233
|
-
|
|
1234
1218
|
/** Token of the Rulesets reducer */
|
|
1235
|
-
declare const RULESETS_REDUCER_TOKEN: InjectionToken<ActionReducer<RulesetsState, Action<string>>>;
|
|
1219
|
+
export declare const RULESETS_REDUCER_TOKEN: InjectionToken<ActionReducer<RulesetsState, Action<string>>>;
|
|
1236
1220
|
/** Provide default reducer for Rulesets store */
|
|
1237
|
-
declare function getDefaultRulesetsReducer(): ActionReducer<RulesetsState, Action<string>>;
|
|
1221
|
+
export declare function getDefaultRulesetsReducer(): ActionReducer<RulesetsState, Action<string>>;
|
|
1238
1222
|
/**
|
|
1239
1223
|
* @deprecated Will be removed in v16. Use {@link provideRulesetsStore} instead.
|
|
1240
1224
|
*/
|
|
1241
|
-
declare class RulesetsStoreModule {
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1225
|
+
export declare class RulesetsStoreModule {
|
|
1226
|
+
static forRoot<T extends RulesetsState>(reducerFactory: () => ActionReducer<T, Action>): ModuleWithProviders<RulesetsStoreModule>;
|
|
1227
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RulesetsStoreModule, never>;
|
|
1228
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<RulesetsStoreModule, never, [typeof i1.StoreFeatureModule, typeof i2.EffectsFeatureModule], never>;
|
|
1229
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<RulesetsStoreModule>;
|
|
1246
1230
|
}
|
|
1247
1231
|
/**
|
|
1248
1232
|
* Provide Rulesets feature store.
|
|
1249
1233
|
* @param reducerFactory Optional factory to override the default reducer.
|
|
1250
1234
|
*/
|
|
1251
|
-
declare function provideRulesetsStore(reducerFactory?: () => ActionReducer<RulesetsState, Action>): EnvironmentProviders;
|
|
1252
|
-
|
|
1235
|
+
export declare function provideRulesetsStore(reducerFactory?: () => ActionReducer<RulesetsState, Action>): EnvironmentProviders;
|
|
1253
1236
|
/**
|
|
1254
1237
|
* @deprecated Will be removed in v16. Use {@link provideRulesEngineDevtools} instead.
|
|
1255
1238
|
*/
|
|
1256
|
-
declare class RulesEngineDevtoolsModule {
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1239
|
+
export declare class RulesEngineDevtoolsModule {
|
|
1240
|
+
/**
|
|
1241
|
+
* Initialize Otter Devtools
|
|
1242
|
+
* @param options
|
|
1243
|
+
*/
|
|
1244
|
+
static instrument(options: Partial<RulesEngineDevtoolsServiceOptions>): ModuleWithProviders<RulesEngineDevtoolsModule>;
|
|
1245
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RulesEngineDevtoolsModule, never>;
|
|
1246
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<RulesEngineDevtoolsModule, never, [typeof i1.StoreModule, typeof RulesetsStoreModule], never>;
|
|
1247
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<RulesEngineDevtoolsModule>;
|
|
1265
1248
|
}
|
|
1266
1249
|
/**
|
|
1267
1250
|
* Provide rules engine devtools functionality.
|
|
1268
1251
|
* @param options Rules engine devtools options
|
|
1269
1252
|
*/
|
|
1270
|
-
declare function provideRulesEngineDevtools(options?: Partial<RulesEngineDevtoolsServiceOptions>): EnvironmentProviders;
|
|
1271
|
-
|
|
1253
|
+
export declare function provideRulesEngineDevtools(options?: Partial<RulesEngineDevtoolsServiceOptions>): EnvironmentProviders;
|
|
1272
1254
|
/** Action to clear the StateDetails of the store and replace it */
|
|
1273
|
-
declare const setRulesets:
|
|
1255
|
+
export declare const setRulesets: import("@ngrx/store").ActionCreator<"[Rulesets] set", (props: SetActionPayload<RulesetsStateDetails>) => SetActionPayload<RulesetsStateDetails> & import("@ngrx/store").Action<"[Rulesets] set">>;
|
|
1274
1256
|
/** Action to change a part or the whole object in the store. */
|
|
1275
|
-
declare const updateRulesets:
|
|
1257
|
+
export declare const updateRulesets: import("@ngrx/store").ActionCreator<"[Rulesets] update", (props: UpdateActionPayload<RulesetsStateDetails>) => UpdateActionPayload<RulesetsStateDetails> & import("@ngrx/store").Action<"[Rulesets] update">>;
|
|
1276
1258
|
/** Action to reset the whole state, by returning it to initial state. */
|
|
1277
|
-
declare const resetRulesets:
|
|
1259
|
+
export declare const resetRulesets: import("@ngrx/store").ActionCreator<"[Rulesets] reset", () => import("@ngrx/store").Action<"[Rulesets] reset">>;
|
|
1278
1260
|
/** Action to cancel a Request ID registered in the store. Can happen from effect based on a switchMap for instance */
|
|
1279
|
-
declare const cancelRulesetsRequest:
|
|
1261
|
+
export declare const cancelRulesetsRequest: import("@ngrx/store").ActionCreator<"[Rulesets] cancel request", (props: AsyncRequest) => AsyncRequest & import("@ngrx/store").Action<"[Rulesets] cancel request">>;
|
|
1280
1262
|
/** Action to clear all rulesets and fill the store with the payload */
|
|
1281
|
-
declare const setRulesetsEntities:
|
|
1263
|
+
export declare const setRulesetsEntities: import("@ngrx/store").ActionCreator<"[Rulesets] set entities", (props: SetAsyncStoreItemEntitiesActionPayload<RulesetsModel>) => SetAsyncStoreItemEntitiesActionPayload<RulesetsModel> & import("@ngrx/store").Action<"[Rulesets] set entities">>;
|
|
1282
1264
|
/** Action to update rulesets with known IDs, insert the new ones */
|
|
1283
|
-
declare const upsertRulesetsEntities:
|
|
1265
|
+
export declare const upsertRulesetsEntities: import("@ngrx/store").ActionCreator<"[Rulesets] upsert entities", (props: SetAsyncStoreItemEntitiesActionPayload<RulesetsModel>) => SetAsyncStoreItemEntitiesActionPayload<RulesetsModel> & import("@ngrx/store").Action<"[Rulesets] upsert entities">>;
|
|
1284
1266
|
/** Action to empty the list of entities, keeping the global state */
|
|
1285
|
-
declare const clearRulesetsEntities:
|
|
1267
|
+
export declare const clearRulesetsEntities: import("@ngrx/store").ActionCreator<"[Rulesets] clear entities", () => import("@ngrx/store").Action<"[Rulesets] clear entities">>;
|
|
1286
1268
|
/** Action to update failureStatus for every RulesetsModel */
|
|
1287
|
-
declare const failRulesetsEntities:
|
|
1269
|
+
export declare const failRulesetsEntities: import("@ngrx/store").ActionCreator<"[Rulesets] fail entities", (props: FailAsyncStoreItemEntitiesActionPayload<any>) => FailAsyncStoreItemEntitiesActionPayload<any> & import("@ngrx/store").Action<"[Rulesets] fail entities">>;
|
|
1288
1270
|
/**
|
|
1289
1271
|
* Action to put the global status of the store in a pending state. Call SET action with the list of RulesetsModels received, when this action resolves.
|
|
1290
1272
|
* If the call fails, dispatch FAIL_ENTITIES action
|
|
1291
1273
|
*/
|
|
1292
|
-
declare const setRulesetsEntitiesFromApi:
|
|
1274
|
+
export declare const setRulesetsEntitiesFromApi: import("@ngrx/store").FunctionWithParametersType<[props: FromApiActionPayload<RulesetsModel[]>], FromApiActionPayload<RulesetsModel[]> & AsyncRequest & import("@ngrx/store").Action<"[Rulesets] set entities from api">> & import("@ngrx/store").Action<"[Rulesets] set entities from api">;
|
|
1293
1275
|
/**
|
|
1294
1276
|
* Action to put global status of the store in a pending state. Call UPSERT action with the list of RulesetsModels received, when this action resolves.
|
|
1295
1277
|
* If the call fails, dispatch FAIL_ENTITIES action
|
|
1296
1278
|
*/
|
|
1297
|
-
declare const upsertRulesetsEntitiesFromApi:
|
|
1298
|
-
|
|
1279
|
+
export declare const upsertRulesetsEntitiesFromApi: import("@ngrx/store").FunctionWithParametersType<[props: FromApiActionPayload<RulesetsModel[]>], FromApiActionPayload<RulesetsModel[]> & AsyncRequest & import("@ngrx/store").Action<"[Rulesets] upsert entities from api">> & import("@ngrx/store").Action<"[Rulesets] upsert entities from api">;
|
|
1299
1280
|
/**
|
|
1300
1281
|
* Service to handle async Rulesets actions
|
|
1301
1282
|
*/
|
|
1302
|
-
declare class RulesetsEffect {
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1283
|
+
export declare class RulesetsEffect {
|
|
1284
|
+
protected actions$: Actions<any>;
|
|
1285
|
+
/**
|
|
1286
|
+
* Set the entities with the reply content, dispatch failRulesetsEntities if it catches a failure
|
|
1287
|
+
*/
|
|
1288
|
+
setEntitiesFromApi$: import("rxjs").Observable<(import("@o3r/core").AsyncRequest & import("@ngrx/store").Action<"[Rulesets] cancel request">) | (import("@o3r/core").SetAsyncStoreItemEntitiesActionPayload<import("@o3r/rules-engine").RulesetsModel> & import("@ngrx/store").Action<"[Rulesets] set entities">) | (import("@o3r/core").FailAsyncStoreItemEntitiesActionPayload<any> & import("@ngrx/store").Action<"[Rulesets] fail entities">)> & import("@ngrx/effects").CreateEffectMetadata;
|
|
1289
|
+
/**
|
|
1290
|
+
* Upsert the entities with the reply content, dispatch failRulesetsEntities if it catches a failure
|
|
1291
|
+
*/
|
|
1292
|
+
upsertEntitiesFromApi$: import("rxjs").Observable<(import("@o3r/core").FailAsyncStoreItemEntitiesActionPayload<any> & import("@ngrx/store").Action<"[Rulesets] fail entities">) | (import("@o3r/core").SetAsyncStoreItemEntitiesActionPayload<import("@o3r/rules-engine").RulesetsModel> & import("@ngrx/store").Action<"[Rulesets] upsert entities">)> & import("@ngrx/effects").CreateEffectMetadata;
|
|
1293
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RulesetsEffect, never>;
|
|
1294
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
1314
1295
|
}
|
|
1315
|
-
|
|
1316
1296
|
/**
|
|
1317
1297
|
* Rulesets Store adapter
|
|
1318
1298
|
*/
|
|
1319
|
-
declare const rulesetsAdapter:
|
|
1299
|
+
export declare const rulesetsAdapter: import("@ngrx/entity").EntityAdapter<RulesetsModel, string>;
|
|
1320
1300
|
/**
|
|
1321
1301
|
* Rulesets Store initial value
|
|
1322
1302
|
*/
|
|
1323
|
-
declare const rulesetsInitialState: RulesetsState;
|
|
1303
|
+
export declare const rulesetsInitialState: RulesetsState;
|
|
1324
1304
|
/**
|
|
1325
1305
|
* List of basic actions for Rulesets Store
|
|
1326
1306
|
*/
|
|
1327
|
-
declare const rulesetsReducerFeatures: ReducerTypes<RulesetsState, ActionCreator[]>[];
|
|
1307
|
+
export declare const rulesetsReducerFeatures: ReducerTypes<RulesetsState, ActionCreator[]>[];
|
|
1328
1308
|
/**
|
|
1329
1309
|
* Rulesets Store reducer
|
|
1330
1310
|
*/
|
|
1331
|
-
declare const rulesetsReducer:
|
|
1332
|
-
|
|
1311
|
+
export declare const rulesetsReducer: import("@ngrx/store").ActionReducer<RulesetsState, import("@ngrx/store").Action<string>>;
|
|
1333
1312
|
/** Select Rulesets State */
|
|
1334
|
-
declare const selectRulesetsState:
|
|
1313
|
+
export declare const selectRulesetsState: import("@ngrx/store").MemoizedSelector<object, RulesetsState, import("@ngrx/store").DefaultProjectorFn<RulesetsState>>;
|
|
1335
1314
|
/** Select the array of Rulesets ids */
|
|
1336
|
-
declare const selectRulesetsIds:
|
|
1315
|
+
export declare const selectRulesetsIds: import("@ngrx/store").MemoizedSelector<object, string[] | number[], (s1: RulesetsState) => string[] | number[]>;
|
|
1337
1316
|
/** Select the array of Rulesets */
|
|
1338
|
-
declare const selectAllRulesets:
|
|
1317
|
+
export declare const selectAllRulesets: import("@ngrx/store").MemoizedSelector<object, import("@o3r/rules-engine").RulesetsModel[], (s1: RulesetsState) => import("@o3r/rules-engine").RulesetsModel[]>;
|
|
1339
1318
|
/** Select the dictionary of Rulesets entities */
|
|
1340
|
-
declare const selectRulesetsEntities:
|
|
1319
|
+
export declare const selectRulesetsEntities: import("@ngrx/store").MemoizedSelector<object, import("@ngrx/entity").Dictionary<import("@o3r/rules-engine").RulesetsModel>, (s1: RulesetsState) => import("@ngrx/entity").Dictionary<import("@o3r/rules-engine").RulesetsModel>>;
|
|
1341
1320
|
/** Select the total Rulesets count */
|
|
1342
|
-
declare const selectRulesetsTotal:
|
|
1321
|
+
export declare const selectRulesetsTotal: import("@ngrx/store").MemoizedSelector<object, number, (s1: RulesetsState) => number>;
|
|
1343
1322
|
/** Select the store pending status */
|
|
1344
|
-
declare const selectRulesetsStorePendingStatus:
|
|
1323
|
+
export declare const selectRulesetsStorePendingStatus: import("@ngrx/store").MemoizedSelector<object, boolean, (s1: RulesetsState) => boolean>;
|
|
1345
1324
|
/**
|
|
1346
1325
|
* Returns the rulesets which are in the validity range, if provided
|
|
1347
1326
|
*/
|
|
1348
|
-
declare const selectRuleSetsInRange:
|
|
1327
|
+
export declare const selectRuleSetsInRange: import("@ngrx/store").MemoizedSelector<object, import("@o3r/rules-engine").RulesetsModel[], (s1: import("@o3r/rules-engine").RulesetsModel[]) => import("@o3r/rules-engine").RulesetsModel[]>;
|
|
1349
1328
|
/**
|
|
1350
1329
|
* Returns the rulesets ids which are not onDemand and in the validity range
|
|
1351
1330
|
*/
|
|
1352
|
-
declare const selectActiveRuleSets:
|
|
1331
|
+
export declare const selectActiveRuleSets: import("@ngrx/store").MemoizedSelector<object, string[], (s1: import("@o3r/rules-engine").RulesetsModel[]) => string[]>;
|
|
1353
1332
|
/**
|
|
1354
1333
|
* Select the map of ruleSets to activate based on linked components
|
|
1355
1334
|
*/
|
|
1356
|
-
declare const selectComponentsLinkedToRuleset:
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
}, (s1:
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1335
|
+
export declare const selectComponentsLinkedToRuleset: import("@ngrx/store").MemoizedSelector<object, {
|
|
1336
|
+
or: {
|
|
1337
|
+
[key: string]: string[];
|
|
1338
|
+
};
|
|
1339
|
+
}, (s1: import("@o3r/rules-engine").RulesetsModel[]) => {
|
|
1340
|
+
or: {
|
|
1341
|
+
[key: string]: string[];
|
|
1342
|
+
};
|
|
1364
1343
|
}>;
|
|
1365
|
-
|
|
1366
|
-
declare const
|
|
1367
|
-
declare const
|
|
1368
|
-
declare
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<OtterRulesEngineDevtools, never>;
|
|
1438
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
1344
|
+
export declare const rulesetsStorageSerializer: (state: RulesetsState) => RulesetsState;
|
|
1345
|
+
export declare const rulesetsStorageDeserializer: (rawObject: any) => RulesetsState;
|
|
1346
|
+
export declare const rulesetsStorageSync: Serializer<RulesetsState>;
|
|
1347
|
+
export declare class OtterRulesEngineDevtools {
|
|
1348
|
+
protected store: Store<RulesetsStore>;
|
|
1349
|
+
private readonly rulesEngineService;
|
|
1350
|
+
/** Stream of rules engine report */
|
|
1351
|
+
readonly rulesEngineReport$?: Observable<{
|
|
1352
|
+
events: DebugEvent[];
|
|
1353
|
+
rulesetMap: Record<string, Ruleset>;
|
|
1354
|
+
}>;
|
|
1355
|
+
/** Stream of rules engine event */
|
|
1356
|
+
readonly rulesEngineEvents$?: Observable<DebugEvent[]>;
|
|
1357
|
+
/**
|
|
1358
|
+
* Return true if the rules engine debug option is activated
|
|
1359
|
+
*/
|
|
1360
|
+
get isRulesEngineDebugActivated(): boolean;
|
|
1361
|
+
constructor();
|
|
1362
|
+
/** Return the list of debug events emitted by rules engine */
|
|
1363
|
+
getCurrentRulesEngineEventsStack(): Promise<DebugEvent[] | undefined>;
|
|
1364
|
+
/** Returns the list of active rulesets (name and id) at the moment when the function is called */
|
|
1365
|
+
getActiveRulesets(): Promise<Pick<Ruleset, "id" | "name">[]>;
|
|
1366
|
+
/** Returns the list of available rulesets (name and id) at the moment when the function is called */
|
|
1367
|
+
getAvailableRulesets(): Promise<Pick<Ruleset, "id" | "name">[]>;
|
|
1368
|
+
/** Returns the list of output actions emitted by the rules engine at the moment when the function is called */
|
|
1369
|
+
getAllOutputActions(): Promise<import("@o3r/rules-engine").AllActionsEvent | undefined>;
|
|
1370
|
+
/**
|
|
1371
|
+
* Get the list of executions for the given ruleset
|
|
1372
|
+
* @param rulesetId
|
|
1373
|
+
*/
|
|
1374
|
+
getRulesetExecutions(rulesetId: string): Promise<(RulesetExecutionEvent | RulesetExecutionErrorEvent)[] | undefined>;
|
|
1375
|
+
/**
|
|
1376
|
+
* Check if the ruleset is activ in the moment when the function is called
|
|
1377
|
+
* @param rulesetId
|
|
1378
|
+
* @returns True if the ruleset is active; False if the ruleset is inactive or it does not exist
|
|
1379
|
+
*/
|
|
1380
|
+
isRulesetActive(rulesetId: string): Promise<boolean>;
|
|
1381
|
+
/**
|
|
1382
|
+
* Get the list of rules executed for the specified ruleset
|
|
1383
|
+
* @param rulesetId
|
|
1384
|
+
*/
|
|
1385
|
+
getRulesEvaluationsForRuleset(rulesetId: string): Promise<import("@o3r/rules-engine").RuleEvaluation[] | undefined>;
|
|
1386
|
+
/**
|
|
1387
|
+
* Get the list of input facts (name, current value) for the specified ruleset, at the moment when the function is called
|
|
1388
|
+
* @param rulesetId
|
|
1389
|
+
*/
|
|
1390
|
+
getInputFactsForRuleset(rulesetId: string): Promise<{
|
|
1391
|
+
factName: string;
|
|
1392
|
+
value: import("@o3r/rules-engine").Facts;
|
|
1393
|
+
}[] | undefined>;
|
|
1394
|
+
/**
|
|
1395
|
+
* Get the list of triggers for the specified ruleset
|
|
1396
|
+
* @param rulesetId
|
|
1397
|
+
*/
|
|
1398
|
+
getTriggersForRuleset(rulesetId: string): Promise<import("@o3r/rules-engine").EvaluationReason[] | undefined>;
|
|
1399
|
+
/**
|
|
1400
|
+
* Get the list of outputed actions emitted by the given ruleset, at the moment when the function is called
|
|
1401
|
+
* @param rulesetId
|
|
1402
|
+
*/
|
|
1403
|
+
getOutputActionsForRuleset(rulesetId: string): Promise<import("@o3r/rules-engine").ActionBlock[] | undefined>;
|
|
1404
|
+
/** Get the list of fact names and corresponding values */
|
|
1405
|
+
getAllFactsSnapshot(): Promise<{
|
|
1406
|
+
factName: string;
|
|
1407
|
+
value: any;
|
|
1408
|
+
}[]> | undefined;
|
|
1409
|
+
/**
|
|
1410
|
+
* Retrieve the ruleset information (rules, linkedComponents, validity range etc.) for a ruleset id
|
|
1411
|
+
* @param rulesetId
|
|
1412
|
+
*/
|
|
1413
|
+
getRulesetInformation(rulesetId: string): Promise<Ruleset | undefined>;
|
|
1414
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<OtterRulesEngineDevtools, never>;
|
|
1415
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
1439
1416
|
}
|
|
1440
|
-
|
|
1441
|
-
declare const
|
|
1442
|
-
declare
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<RulesEngineRunnerService, never>;
|
|
1503
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
1417
|
+
export declare const OTTER_RULES_ENGINE_DEVTOOLS_DEFAULT_OPTIONS: Readonly<RulesEngineDevtoolsServiceOptions>;
|
|
1418
|
+
export declare const OTTER_RULES_ENGINE_DEVTOOLS_OPTIONS: InjectionToken<RulesEngineDevtoolsServiceOptions>;
|
|
1419
|
+
export declare class RulesEngineRunnerService {
|
|
1420
|
+
private readonly store;
|
|
1421
|
+
private readonly logger;
|
|
1422
|
+
/** Rulesets to restrict the execution of the engine */
|
|
1423
|
+
protected ruleSets$: Observable<string[] | undefined>;
|
|
1424
|
+
/** List of action handlers */
|
|
1425
|
+
protected readonly actionHandlers: Set<RulesEngineActionHandler<import("@o3r/core").RulesEngineAction<string, any>>>;
|
|
1426
|
+
/** Observable of component linked to the component */
|
|
1427
|
+
protected linkedComponents$: BehaviorSubject<{
|
|
1428
|
+
[key: string]: number;
|
|
1429
|
+
}>;
|
|
1430
|
+
/** Map of engines dedicated to each rule sets */
|
|
1431
|
+
readonly engine: RulesEngine;
|
|
1432
|
+
/** stream of the whole ruleset results */
|
|
1433
|
+
events$: Observable<ActionBlock[]>;
|
|
1434
|
+
/** Enable action execution on new state change */
|
|
1435
|
+
enabled: boolean;
|
|
1436
|
+
constructor();
|
|
1437
|
+
/**
|
|
1438
|
+
* Execute the list of actions
|
|
1439
|
+
* @param actions
|
|
1440
|
+
*/
|
|
1441
|
+
protected executeActions(actions: ActionBlock[]): Promise<void>;
|
|
1442
|
+
/**
|
|
1443
|
+
* Update or insert fact in the rules engine
|
|
1444
|
+
* @param facts fact list to add / update
|
|
1445
|
+
*/
|
|
1446
|
+
upsertFacts(facts: Fact<unknown> | Fact<unknown>[]): void;
|
|
1447
|
+
/**
|
|
1448
|
+
* Update or insert operator in the rules engine
|
|
1449
|
+
* @param operators operator list to add / update
|
|
1450
|
+
*/
|
|
1451
|
+
upsertOperators(operators: (Operator<any, any> | UnaryOperator<any>)[]): void;
|
|
1452
|
+
/**
|
|
1453
|
+
* Upsert a list of RuleSets to be run in the rules engine
|
|
1454
|
+
* @param ruleSets
|
|
1455
|
+
*/
|
|
1456
|
+
upsertRulesets(ruleSets: Ruleset[]): void;
|
|
1457
|
+
/**
|
|
1458
|
+
* Add action handlers in the rules engine
|
|
1459
|
+
* @param actionHandlers
|
|
1460
|
+
*/
|
|
1461
|
+
registerActionHandlers(...actionHandlers: RulesEngineActionHandler[]): void;
|
|
1462
|
+
/**
|
|
1463
|
+
* Remove action handlers in the rules engine
|
|
1464
|
+
* @param actionHandlers
|
|
1465
|
+
*/
|
|
1466
|
+
unregisterActionHandlers(...actionHandlers: RulesEngineActionHandler[]): void;
|
|
1467
|
+
/**
|
|
1468
|
+
* Enable temporary a rule set
|
|
1469
|
+
* @param componentComputedName Name of the component to enable the ruleset for
|
|
1470
|
+
*/
|
|
1471
|
+
enableRuleSetFor(componentComputedName: string): void;
|
|
1472
|
+
/**
|
|
1473
|
+
* Disable temporary a rule set
|
|
1474
|
+
* @param componentComputedName Name of the component to disable the ruleset for
|
|
1475
|
+
*/
|
|
1476
|
+
disableRuleSetFor(componentComputedName: string): void;
|
|
1477
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RulesEngineRunnerService, never>;
|
|
1478
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
1504
1479
|
}
|
|
1505
|
-
|
|
1506
1480
|
/** Abstract fact set service */
|
|
1507
|
-
declare abstract class FactsService<T extends FactDefinitions> {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1481
|
+
export declare abstract class FactsService<T extends FactDefinitions> {
|
|
1482
|
+
#private;
|
|
1483
|
+
private readonly rulesEngine;
|
|
1484
|
+
/** Get the registered state */
|
|
1485
|
+
get isRegistered(): boolean;
|
|
1486
|
+
/** Set of facts provided */
|
|
1487
|
+
abstract facts: FactSet<T>;
|
|
1488
|
+
constructor(rulesEngine: RulesEngineRunnerService);
|
|
1489
|
+
/** Register the set of facts */
|
|
1490
|
+
register(): void;
|
|
1517
1491
|
}
|
|
1518
|
-
|
|
1519
1492
|
/**
|
|
1520
1493
|
* Interface that contains the portalFacts definition
|
|
1521
1494
|
* This is one of the reserved fact names, it won't be part of metadata
|
|
1522
1495
|
*/
|
|
1523
|
-
interface PortalFacts extends FactDefinitions {
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1496
|
+
export interface PortalFacts extends FactDefinitions {
|
|
1497
|
+
/**
|
|
1498
|
+
* Map of facts coming from the portal
|
|
1499
|
+
*/
|
|
1500
|
+
portalFacts: {
|
|
1501
|
+
[key: string]: string;
|
|
1502
|
+
};
|
|
1530
1503
|
}
|
|
1531
|
-
|
|
1532
1504
|
/**
|
|
1533
1505
|
* Operator facts that provide the current time
|
|
1534
1506
|
*/
|
|
1535
|
-
interface CurrentTimeFacts extends FactDefinitions {
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1507
|
+
export interface CurrentTimeFacts extends FactDefinitions {
|
|
1508
|
+
/**
|
|
1509
|
+
* The current time as a timestamp
|
|
1510
|
+
*/
|
|
1511
|
+
o3rCurrentTime: number;
|
|
1540
1512
|
}
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
1513
|
+
export declare class CurrentTimeFactsService extends FactsService<CurrentTimeFacts> {
|
|
1514
|
+
private readonly currentTimeSubject$;
|
|
1515
|
+
/** @inheritDoc */
|
|
1516
|
+
facts: {
|
|
1517
|
+
o3rCurrentTime: import("rxjs").Observable<number>;
|
|
1518
|
+
};
|
|
1519
|
+
constructor();
|
|
1520
|
+
/** Compute the current time */
|
|
1521
|
+
tick(): void;
|
|
1522
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CurrentTimeFactsService, never>;
|
|
1523
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
1553
1524
|
}
|
|
1554
|
-
|
|
1555
1525
|
/**
|
|
1556
1526
|
* Components which are activating ruleset should implement this to be identified by CMS extractor
|
|
1557
1527
|
*/
|
|
1558
|
-
interface LinkableToRuleset {
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1528
|
+
export interface LinkableToRuleset {}
|
|
1561
1529
|
/** Determine if the action should be executed */
|
|
1562
|
-
declare const RULES_ENGINE_OPTIONS: InjectionToken<boolean>;
|
|
1530
|
+
export declare const RULES_ENGINE_OPTIONS: InjectionToken<boolean>;
|
|
1563
1531
|
/** Rules engine configuration */
|
|
1564
|
-
interface RulesEngineServiceOptions {
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1532
|
+
export interface RulesEngineServiceOptions {
|
|
1533
|
+
/** Determine if the actions resulting of the rule engine should be executed */
|
|
1534
|
+
dryRun: boolean;
|
|
1535
|
+
/** Flag to activate the run of Rules Engine in debug mode */
|
|
1536
|
+
debug: boolean;
|
|
1537
|
+
/** Limit the number of debug events kept in stack */
|
|
1538
|
+
debugEventsStackLimit?: number;
|
|
1571
1539
|
}
|
|
1572
1540
|
/** Default Rules engine options */
|
|
1573
|
-
declare const DEFAULT_RULES_ENGINE_OPTIONS: Readonly<RulesEngineServiceOptions>;
|
|
1574
|
-
|
|
1541
|
+
export declare const DEFAULT_RULES_ENGINE_OPTIONS: Readonly<RulesEngineServiceOptions>;
|
|
1575
1542
|
/**
|
|
1576
1543
|
* @deprecated Will be removed in v16. Use {@link provideRulesEngineRunner} instead.
|
|
1577
1544
|
*/
|
|
1578
|
-
declare class RulesEngineRunnerModule {
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1545
|
+
export declare class RulesEngineRunnerModule {
|
|
1546
|
+
static forRoot(options?: Partial<RulesEngineServiceOptions>): ModuleWithProviders<RulesEngineRunnerModule>;
|
|
1547
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RulesEngineRunnerModule, never>;
|
|
1548
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<RulesEngineRunnerModule, never, [typeof i1.StoreModule, typeof RulesetsStoreModule], never>;
|
|
1549
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<RulesEngineRunnerModule>;
|
|
1583
1550
|
}
|
|
1584
1551
|
/**
|
|
1585
1552
|
* Provide rules engine runner service.
|
|
1586
1553
|
* @param options Rules engine service options
|
|
1587
1554
|
*/
|
|
1588
|
-
declare function provideRulesEngineRunner(options?: Partial<RulesEngineServiceOptions>): EnvironmentProviders;
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
export type { ActionBlock, ActionSetTemporaryFactBlock, ActionTypes, ActiveRulesetsEvent, AllActionsEvent, AllBlock, AllConditions, AnyConditions, AvailableFactsSnapshot, AvailableRulesEngineMessageContents, AvailableRulesets, BaseRulesetExecution, BinaryOperation, ConditionBlockTypes, CrossPlatformPerformance, CurrentTimeFacts, DateInput, DebugEvent, EngineDebuggerOptions, EngineRule, EngineRuleset, EvaluationReason, Fact, FactBasicValues, FactDefinitions, FactFactoryReturn, FactObject, FactSet, FactValueStream, Facts, GenericOperand, IfElseBlock, LinkableToRuleset, NativeTypes, NestedCondition, NotCondition, Operand, OperandFact, Operator, PortalFacts, Rule, RuleBlock, RuleElement, RuleEvaluation, RuleEvaluationOutput, RuleEvent, RulesEngineDebugEventsContentMessage, RulesEngineDevtoolsServiceOptions, RulesEngineMessageDataTypes, RulesEngineOptions, RulesEngineServiceOptions, Ruleset, RulesetExecutionDebug, RulesetExecutionErrorEvent, RulesetExecutionEvent, RulesetExecutionStatus, RulesetsModel, RulesetsState, RulesetsStateDetails, RulesetsStore, SupportedSimpleTypes, TimedEvent, TopLevelCondition, UnaryOperation, UnaryOperator };
|
|
1592
|
-
//# sourceMappingURL=o3r-rules-engine.d.ts.map
|
|
1555
|
+
export declare function provideRulesEngineRunner(options?: Partial<RulesEngineServiceOptions>): EnvironmentProviders;
|
|
1556
|
+
export {};
|
|
1557
|
+
//# sourceMappingURL=o3r-rules-engine.d.ts.map
|