From 3afaddab2ba48440ecf6669bb6b8223cdb96120c Mon Sep 17 00:00:00 2001 From: Eric Wu <95886809+Eric-B-Wu@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:44:36 -0400 Subject: [PATCH] fix(desinger): Move non-outputschema dynamic data outside fetch (#4656) move logic outside fetch --- .../lib/core/utils/parameters/dynamicdata.ts | 75 +++++++++---------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/libs/designer/src/lib/core/utils/parameters/dynamicdata.ts b/libs/designer/src/lib/core/utils/parameters/dynamicdata.ts index 89b1cdf6a41..04275a6f249 100644 --- a/libs/designer/src/lib/core/utils/parameters/dynamicdata.ts +++ b/libs/designer/src/lib/core/utils/parameters/dynamicdata.ts @@ -156,6 +156,43 @@ export async function getDynamicSchema( const { parameter, definition } = dependencyInfo; const emptySchema = { ...parameter?.schema }; try { + if (isDynamicPropertiesExtension(definition)) { + const { dynamicState, parameters } = definition.extension; + const operationParameters = getParameterValuesForDynamicInvoke(parameters, nodeInputs, idReplacements, workflowParameters); + let schema: OpenAPIV2.SchemaObject; + switch (dynamicState?.extension?.builtInOperation) { + case 'getVariableSchema': { + schema = { + type: getSwaggerTypeFromVariableType(operationParameters['type']?.toLowerCase() ?? 'boolean'), + enum: getSwaggerEnumFromVariableType(operationParameters['type']?.toLowerCase() ?? 'boolean'), + }; + + break; + } + case 'getVariable': { + const variable = variables.find((variable) => variable.name === operationParameters['name']); + schema = variable + ? { + type: getSwaggerTypeFromVariableType(variable.type?.toLowerCase()), + enum: getSwaggerEnumFromVariableType(variable.type?.toLowerCase()), + } + : {}; + break; + } + default: { + schema = await getDynamicSchemaProperties( + connectionReference?.connection.id, + operationInfo.connectorId, + operationInfo.operationId, + operationParameters, + dynamicState + ); + break; + } + } + + return schema ? { ...emptySchema, ...schema } : schema; + } const queryClient = getReactQueryClient(); const outputSchema = await queryClient.fetchQuery( [ @@ -166,44 +203,6 @@ export async function getDynamicSchema( dependencyInfo.parameter?.key, ], async () => { - if (isDynamicPropertiesExtension(definition)) { - const { dynamicState, parameters } = definition.extension; - const operationParameters = getParameterValuesForDynamicInvoke(parameters, nodeInputs, idReplacements, workflowParameters); - let schema: OpenAPIV2.SchemaObject; - - switch (dynamicState?.extension?.builtInOperation) { - case 'getVariableSchema': { - schema = { - type: getSwaggerTypeFromVariableType(operationParameters['type']?.toLowerCase() ?? 'boolean'), - enum: getSwaggerEnumFromVariableType(operationParameters['type']?.toLowerCase() ?? 'boolean'), - }; - - break; - } - case 'getVariable': { - const variable = variables.find((variable) => variable.name === operationParameters['name']); - schema = variable - ? { - type: getSwaggerTypeFromVariableType(variable.type?.toLowerCase()), - enum: getSwaggerEnumFromVariableType(variable.type?.toLowerCase()), - } - : {}; - break; - } - default: { - schema = await getDynamicSchemaProperties( - connectionReference?.connection.id, - operationInfo.connectorId, - operationInfo.operationId, - operationParameters, - dynamicState - ); - break; - } - } - - return schema ? { ...emptySchema, ...schema } : schema; - } const { connectorId } = operationInfo; const { parameters, operationId } = definition.extension; const { connector, parsedSwagger } = await getConnectorWithSwagger(connectorId);