Skip to content

Commit c31ef80

Browse files
refactor: convert remaining Flow files in rules-engine to TypeScript (#4356)
* refactor: convert remaining Flow files in rules-engine to TypeScript Co-Authored-By: Simona Domnisoru <[email protected]> * fix: fix TypeScript errors in rulesEffectsProcessor.ts Co-Authored-By: Simona Domnisoru <[email protected]> * chore: cleanup * chore: fix complex typescript errors * chore: cleanup --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Simona Domnisoru <[email protected]> Co-authored-by: Simona Domnisoru <[email protected]>
1 parent 73b29a8 commit c31ef80

File tree

54 files changed

+490
-533
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+490
-533
lines changed

.eslintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@
158158
"flowtype/no-types-missing-file-annotation": "off",
159159
"flowtype/define-flow-type": "off",
160160
"flowtype/require-valid-file-annotation": "off",
161-
162161
"@typescript-eslint/explicit-module-boundary-types": "off",
163162
"@typescript-eslint/explicit-function-return-type": "off",
164163
"@typescript-eslint/no-unused-vars": [

packages/rules-engine/.eslintrc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@
7777
"flowtype/no-types-missing-file-annotation": "off",
7878
"flowtype/define-flow-type": "off",
7979
"flowtype/require-valid-file-annotation": "off",
80-
81-
"@typescript-eslint/indent": [2, 4],
8280
"@typescript-eslint/explicit-function-return-type": "off",
8381
"@typescript-eslint/no-unused-vars": [
8482
"error",

packages/rules-engine/d2.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
type: 'lib',
33
entryPoints: {
4-
lib: 'src/index.js',
4+
lib: 'src/index.ts',
55
},
66
};
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @flow
21
import log from 'loglevel';
32
import { VariableService } from './services/VariableService';
43
import { ValueProcessor } from './processors/ValueProcessor';
@@ -13,30 +12,30 @@ import type {
1312
Flag,
1413
} from './rulesEngine.types';
1514
import { getRulesEffectsProcessor } from './processors/rulesEffectsProcessor/rulesEffectsProcessor';
16-
import { effectActions, typeof environmentTypes } from './constants';
15+
import { effectActions, environmentTypes } from './constants';
1716

1817
export class RulesEngine {
1918
inputConverter: IConvertInputRulesValue;
2019
outputConverter: IConvertOutputRulesEffectsValue;
2120
valueProcessor: ValueProcessor;
2221
variableService: VariableService;
2322
dateUtils: IDateUtils;
24-
userRoles: Array<string>;
23+
userRoles!: Array<string>;
2524
flags: Flag;
2625

2726
constructor(
2827
inputConverter: IConvertInputRulesValue,
2928
outputConverter: IConvertOutputRulesEffectsValue,
3029
dateUtils: IDateUtils,
31-
environment: $Values<environmentTypes>,
30+
environment: typeof environmentTypes[keyof typeof environmentTypes],
3231
flags?: Flag,
3332
) {
3433
this.inputConverter = inputConverter;
3534
this.outputConverter = outputConverter;
3635
this.valueProcessor = new ValueProcessor(inputConverter);
3736
this.variableService = new VariableService(this.valueProcessor.processValue, dateUtils, environment);
3837
this.dateUtils = dateUtils;
39-
this.flags = flags ?? {};
38+
this.flags = flags ?? { verbose: false };
4039
}
4140

4241
/**
@@ -136,7 +135,7 @@ export class RulesEngine {
136135
'had no condition specified. Please check rule configuration.');
137136
}
138137

139-
let programRuleEffects = [];
138+
let programRuleEffects: any[] = [];
140139
if (isProgramRuleExpressionEffective) {
141140
programRuleEffects = rule.programRuleActions.map((
142141
{
@@ -207,7 +206,6 @@ export class RulesEngine {
207206
effects,
208207
dataElements,
209208
trackedEntityAttributes,
210-
// $FlowFixMe[exponential-spread]
211209
formValues: { ...selectedEntity, ...currentEvent },
212210
onProcessValue: this.valueProcessor.processValue,
213211
});

packages/rules-engine/src/constants/environmentTypes.const.js renamed to packages/rules-engine/src/constants/environmentTypes.const.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @flow
21
export const environmentTypes = Object.freeze({
32
WebClient: 'WebClient',
43
AndroidClient: 'AndroidClient',

packages/rules-engine/src/constants/idNames.const.js renamed to packages/rules-engine/src/constants/idNames.const.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @flow
2-
31
export const idNames = {
42
DATA_ELEMENT_ID: 'dataElementId',
53
TRACKED_ENTITY_ATTRIBUTE_ID: 'trackedEntityAttributeId',

packages/rules-engine/src/constants/index.js renamed to packages/rules-engine/src/constants/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @flow
21
export { effectActions } from './effectActions.const';
32
export { rulesEngineEffectTargetDataTypes } from './targetDataTypes.const';
43
export { idNames } from './idNames.const';

packages/rules-engine/src/constants/targetDataTypes.const.js renamed to packages/rules-engine/src/constants/targetDataTypes.const.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @flow
2-
31
export const rulesEngineEffectTargetDataTypes = {
42
DATA_ELEMENT: 'dataElement',
53
TRACKED_ENTITY_ATTRIBUTE: 'trackedEntityAttribute',

packages/rules-engine/src/constants/typeKeys.const.js renamed to packages/rules-engine/src/constants/typeKeys.const.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @flow
21
export const typeKeys = {
32
TEXT: 'TEXT',
43
MULTI_TEXT: 'MULTI_TEXT',

packages/rules-engine/src/constants/typeToInterfaceFnName.const.js renamed to packages/rules-engine/src/constants/typeToInterfaceFnName.const.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @flow
21
import { typeKeys } from './typeKeys.const';
32

43
export const mapTypeToInterfaceFnName = {

0 commit comments

Comments
 (0)