Skip to content

Commit

Permalink
refactor: shuffle functions (#643)
Browse files Browse the repository at this point in the history
* refactor: shuffle functions

* refactor continued

* rename files

* remove unused function (duplicated elsewhere)

* some more renaming

* remove get of operators

* fix imports

* update openapi

* fix bug introduced in the PR

* file rename

* reintegrate changes from case name templating #647

* fix imports
  • Loading branch information
Pascal-Delange authored Jan 16, 2025
1 parent 1964d56 commit f88d5a5
Show file tree
Hide file tree
Showing 69 changed files with 1,215 additions and 1,433 deletions.
14 changes: 5 additions & 9 deletions packages/app-builder/src/components/Cases/CaseDecisions.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { type Pivot, type TableModel } from '@app-builder/models';
import {
type DatabaseAccessAstNode,
type PayloadAstNode,
type Pivot,
type TableModel,
} from '@app-builder/models';
} from '@app-builder/models/astNode/data-accessor';
import { type CustomList } from '@app-builder/models/custom-list';
import {
type Decision,
type DecisionDetail,
type RuleExecution,
} from '@app-builder/models/decision';
import { type OperatorFunction } from '@app-builder/models/editable-operators';
import { type LicenseEntitlements } from '@app-builder/models/license';
import { type RuleSnoozeWithRuleId } from '@app-builder/models/rule-snooze';
import { type ScenarioIterationRule } from '@app-builder/models/scenario-iteration-rule';
Expand Down Expand Up @@ -49,7 +47,7 @@ import { CasePivotValues } from './CasePivotValues';
import { casesI18n } from './cases-i18n';
import { RuleSnoozes } from './RuleSnoozes';

interface DecisionsDetail {
interface DecisionsDetailWithContext {
decisionId: string;
ruleExecutions: RuleExecution[];
triggerObjectType: string;
Expand All @@ -59,7 +57,6 @@ interface DecisionsDetail {
databaseAccessors: DatabaseAccessAstNode[];
payloadAccessors: PayloadAstNode[];
};
operators: OperatorFunction[];
ruleSnoozes: RuleSnoozeWithRuleId[];
}

Expand All @@ -76,7 +73,7 @@ export function CaseDecisions({
};
entitlements: LicenseEntitlements;
caseDecisionsPromise: Promise<
[TableModel[], CustomList[], DecisionsDetail[]]
[TableModel[], CustomList[], DecisionsDetailWithContext[]]
>;
}) {
const { t } = useTranslation(casesI18n);
Expand Down Expand Up @@ -273,7 +270,7 @@ function DecisionDetail({
featureAccess,
}: {
decision: Decision;
decisionsDetail: DecisionsDetail[];
decisionsDetail: DecisionsDetailWithContext[];
dataModel: TableModel[];
customLists: CustomList[];
entitlements: LicenseEntitlements;
Expand Down Expand Up @@ -358,7 +355,6 @@ function DecisionDetail({
decisionDetail.accessors.databaseAccessors,
payloadAccessors:
decisionDetail.accessors.payloadAccessors,
operators: decisionDetail.operators,
rules: decisionDetail.rules,
}}
/>
Expand Down
12 changes: 2 additions & 10 deletions packages/app-builder/src/components/Decisions/RulesDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { decisionsI18n, Paper } from '@app-builder/components';
import { type AstNode, type DataModel } from '@app-builder/models';
import {
type AstNode,
type DatabaseAccessAstNode,
type DataModel,
type PayloadAstNode,
} from '@app-builder/models';
} from '@app-builder/models/astNode/data-accessor';
import { type CustomList } from '@app-builder/models/custom-list';
import { type RuleExecution } from '@app-builder/models/decision';
import { type OperatorFunction } from '@app-builder/models/editable-operators';
import { type NodeEvaluation } from '@app-builder/models/node-evaluation';
import { type ScenarioIterationRule } from '@app-builder/models/scenario-iteration-rule';
import { useAstNodeEditor } from '@app-builder/services/editor/ast-editor';
Expand Down Expand Up @@ -41,7 +39,6 @@ export function RulesDetail({
rules: ScenarioIterationRule[];
databaseAccessors: DatabaseAccessAstNode[];
payloadAccessors: PayloadAstNode[];
operators: OperatorFunction[];
dataModel: DataModel;
customLists: CustomList[];
}>;
Expand Down Expand Up @@ -94,7 +91,6 @@ export function RuleExecutionDetail({
rules: ScenarioIterationRule[];
databaseAccessors: DatabaseAccessAstNode[];
payloadAccessors: PayloadAstNode[];
operators: OperatorFunction[];
dataModel: DataModel;
customLists: CustomList[];
};
Expand Down Expand Up @@ -140,7 +136,6 @@ export function RuleExecutionDetail({
evaluation={ruleExecution.evaluation}
databaseAccessors={astRuleData.databaseAccessors}
payloadAccessors={astRuleData.payloadAccessors}
operators={astRuleData.operators}
dataModel={astRuleData.dataModel}
customLists={astRuleData.customLists}
triggerObjectType={triggerObjectType}
Expand Down Expand Up @@ -175,7 +170,6 @@ function RuleFormula({
databaseAccessors,
evaluation,
payloadAccessors,
operators,
dataModel,
customLists,
triggerObjectType,
Expand All @@ -184,7 +178,6 @@ function RuleFormula({
evaluation?: NodeEvaluation;
databaseAccessors: DatabaseAccessAstNode[];
payloadAccessors: PayloadAstNode[];
operators: OperatorFunction[];
dataModel: DataModel;
customLists: CustomList[];
triggerObjectType: string;
Expand All @@ -199,7 +192,6 @@ function RuleFormula({
options={{
databaseAccessors,
payloadAccessors,
operators,
dataModel,
customLists,
triggerObjectType,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { type DataModel } from '@app-builder/models';
import {
type DatabaseAccessAstNode,
type DataModel,
type PayloadAstNode,
} from '@app-builder/models';
} from '@app-builder/models/astNode/data-accessor';
import { type CustomList } from '@app-builder/models/custom-list';
import { type OperatorFunction } from '@app-builder/models/editable-operators';
import {
type AstEditorStore,
AstNodeEditorProvider,
Expand All @@ -18,7 +17,6 @@ interface AstBuilderProps {
options: {
databaseAccessors: DatabaseAccessAstNode[];
payloadAccessors: PayloadAstNode[];
operators: OperatorFunction[];
dataModel: DataModel;
customLists: CustomList[];
triggerObjectType: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type AstNode } from '@app-builder/models';
import {
type AstNode,
isMainAstBinaryNode,
isMainAstUnaryNode,
} from '@app-builder/models';
} from '@app-builder/models/astNode/builder-ast-node';
import {
useEnumValuesFromNeighbour,
useEvaluation,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { type AstNode, NewUndefinedAstNode } from '@app-builder/models';
import {
type AstNode,
isMainAstNode,
type MainAstBinaryNode,
type MainAstUnaryNode,
NewUndefinedAstNode,
} from '@app-builder/models';
} from '@app-builder/models/astNode/builder-ast-node';
import { allMainAstOperatorFunctions } from '@app-builder/models/astNode/builder-ast-node-node-operator';
import {
useAstNodeEditorActions,
useEvaluationErrors,
} from '@app-builder/services/editor/ast-editor';
import { useMainAstOperatorFunctions } from '@app-builder/services/editor/options';
import type * as React from 'react';
import { useTranslation } from 'react-i18next';
import { MenuButton, MenuItem, MenuPopover, MenuRoot } from 'ui-design-system';
Expand Down Expand Up @@ -63,7 +62,7 @@ export function MainAstBinaryOperatorLine({
);
}

const operators = useMainAstOperatorFunctions();
const operators = allMainAstOperatorFunctions;

const left = mainAstNode.children[0];
const leftPath = `${treePath}.children.0`;
Expand Down Expand Up @@ -156,7 +155,7 @@ export function MainAstUnaryOperatorLine({
);
}

const operators = useMainAstOperatorFunctions();
const operators = allMainAstOperatorFunctions;

const left = mainAstNode.children[0];
const leftPath = `${treePath}.children.0`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
type AstNode,
type ConstantAstNode,
type ConstantType,
type DataType,
isKnownOperandAstNode,
} from '@app-builder/models';
import { isKnownOperandAstNode } from '@app-builder/models/astNode/builder-ast-node';
import { type ConstantAstNode } from '@app-builder/models/astNode/constant';
import { type OperandType } from '@app-builder/models/operand-type';
import {
type AstNodeErrors,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Callout } from '@app-builder/components/Callout';
import { ExternalLink } from '@app-builder/components/ExternalLink';
import { EvaluationErrors } from '@app-builder/components/Scenario/ScenarioValidationError';
import { type AstNode } from '@app-builder/models';
import {
type AggregationAstNode,
aggregationAstNodeName,
type AstNode,
NewConstantAstNode,
} from '@app-builder/models';
} from '@app-builder/models/astNode/aggregation';
import { NewConstantAstNode } from '@app-builder/models/astNode/constant';
import {
type AggregatorOperator,
aggregatorOperators,
} from '@app-builder/models/editable-operators';
} from '@app-builder/models/modale-operators';
import { type EvaluationError } from '@app-builder/models/node-evaluation';
import { aggregationDocHref } from '@app-builder/services/documentation-href';
import { useDataModel } from '@app-builder/services/editor/options';
Expand Down
Loading

0 comments on commit f88d5a5

Please sign in to comment.