Skip to content

Commit

Permalink
chore(api): remove redundant second variables compute
Browse files Browse the repository at this point in the history
  • Loading branch information
djabarovgeorge committed Dec 16, 2024
1 parent 8ad7d1c commit ef47067
Showing 1 changed file with 1 addition and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
TemplateParseResult,
Variable,
} from '../../util/template-parser/liquid-parser';
import { flattenObjectValues } from '../../util/utils';
import { pathsToObject } from '../../util/path-to-object';
import { HydrateEmailSchemaUseCase } from '../../../environments-v1/usecases/output-renderers';

Expand Down Expand Up @@ -190,7 +189,7 @@ export class GeneratePreviewUsecase {
): ProcessedControlResult {
const variables = this.processControlValueVariables(controlValues, variableSchema);
const processedControlValues = this.fixControlValueInvalidVariables(controlValues, variables.invalid);
const extractedTemplateVariables = this.extractTemplateVariables([processedControlValues]);
const extractedTemplateVariables = variables.valid.map((variable) => variable.name);
const payloadVariableExample =
workflow.origin === WorkflowOriginEnum.EXTERNAL
? createMockObjectFromSchema({
Expand Down Expand Up @@ -248,14 +247,6 @@ export class GeneratePreviewUsecase {
};
}

@Instrument()
private extractTemplateVariables(controlValues: Record<string, unknown>[]): string[] {
const controlValuesString = controlValues.map(flattenObjectValues).flat().join(' ');
const { validVariables } = extractLiquidTemplateVariables(controlValuesString);

return validVariables.map((variable) => variable.name);
}

@Instrument()
private async buildVariablesSchema(
variables: Record<string, unknown>,
Expand Down

0 comments on commit ef47067

Please sign in to comment.