@o3r/rules-engine 14.1.0-prerelease.4 → 14.1.0-prerelease.40

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