From b49afa6be03b73b2075e4344c39761e775cae8b4 Mon Sep 17 00:00:00 2001 From: 1AhmedYasser <26207361+1AhmedYasser@users.noreply.github.com> Date: Tue, 3 Feb 2026 22:31:22 +0200 Subject: [PATCH 1/4] fix(897): Fixed Raw Body Parsing in intial loading --- .../components/FlowElementsPopup/index.tsx | 18 ++--------- GUI/src/store/new-services.store.ts | 23 +++++++++++-- GUI/src/utils/json-request-utils.ts | 32 ++----------------- 3 files changed, 24 insertions(+), 49 deletions(-) diff --git a/GUI/src/components/FlowElementsPopup/index.tsx b/GUI/src/components/FlowElementsPopup/index.tsx index 764022c4..9b76c784 100644 --- a/GUI/src/components/FlowElementsPopup/index.tsx +++ b/GUI/src/components/FlowElementsPopup/index.tsx @@ -4,7 +4,7 @@ import React, { useEffect, useMemo, useState } from 'react'; import { DndProvider } from 'react-dnd'; import { HTML5Backend } from 'react-dnd-html5-backend'; import { useTranslation } from 'react-i18next'; -import useServiceStore from 'store/new-services.store'; +import useServiceStore, { extractMapValues, getEndpointBody } from 'store/new-services.store'; import useServiceListStore from 'store/services.store'; import useToastStore from 'store/toasts.store'; import { DynamicChoices } from 'types/dynamic-choices'; @@ -318,7 +318,7 @@ const FlowElementsPopup: React.FC = () => { url: endpoint.url, method: endpoint.methodType, headers: extractMapValues(endpoint.headers), - body: extractMapValues(endpoint.body), + body: getEndpointBody(endpoint), params: extractMapValues(endpoint.params), }, ], @@ -330,20 +330,6 @@ const FlowElementsPopup: React.FC = () => { } }; - function extractMapValues(element: any) { - if (element?.rawData && element?.rawData?.length > 0) { - return element.rawData.value; - } - - let result: any = {}; - if (element?.variables) { - for (const entry of element.variables) { - result = { ...result, [entry.name]: entry.value }; - } - } - return result; - } - const getJsonRequestButtonTitle = () => { if (!isUserDefinedNode || selectedTab === t('serviceFlow.tabs.test')) return ''; if (isJsonRequestVisible) return t('serviceFlow.popup.hideJsonRequest'); diff --git a/GUI/src/store/new-services.store.ts b/GUI/src/store/new-services.store.ts index 431af448..60a92088 100644 --- a/GUI/src/store/new-services.store.ts +++ b/GUI/src/store/new-services.store.ts @@ -26,7 +26,7 @@ import { saveFlowClick } from 'services/service-builder'; import { EndpointDefinitionJson, Service, ServiceState, Step, StepType } from 'types'; import { Assign } from 'types/assign'; import { Chip } from 'types/chip'; -import { EndpointData, EndpointEnv, EndpointTab, PreDefinedEndpointEnvVariables } from 'types/endpoint'; +import { EndpointData, EndpointDefinition, EndpointEnv, EndpointTab, PreDefinedEndpointEnvVariables } from 'types/endpoint'; import { EndpointResponseVariable } from 'types/endpoint/endpoint-response-variables'; import { EndpointType } from 'types/endpoint/endpoint-type'; import { RequestVariablesTabsRawData, RequestVariablesTabsRowsData } from 'types/request-variables'; @@ -259,7 +259,7 @@ const useServiceStore = create((set, get) => ({ url: endpoint.url, method: endpoint.methodType, headers: extractMapValues(endpoint.headers), - body: extractMapValues(endpoint.body), + body: getEndpointBody(endpoint), params: extractMapValues(endpoint.params), })), ); @@ -904,7 +904,24 @@ const useServiceStore = create((set, get) => ({ canRedo: () => get().historyIndex < get().history.length - 1, })); -function extractMapValues(element: any) { +export function getEndpointBody(endpoint: EndpointDefinition): any { + const isRawBodySelected = endpoint?.body?.isRawSelected ?? false; + const rawBody = endpoint?.body?.rawData ?? {}; + let body: any = extractMapValues(endpoint.body); + + if (isRawBodySelected) { + try { + const rawJson = JSON.parse(rawBody?.value ?? ''); + body = rawJson; + } catch (e: any) { + body = extractMapValues(endpoint.body); + console.log(`Unable to save JSON to Yaml. ${e.message}`); + } + } + return body; +} + +export function extractMapValues(element: any) { if (!element) return {}; if (element.rawData && element.rawData.length > 0) { diff --git a/GUI/src/utils/json-request-utils.ts b/GUI/src/utils/json-request-utils.ts index 4b60fabf..4a69c856 100644 --- a/GUI/src/utils/json-request-utils.ts +++ b/GUI/src/utils/json-request-utils.ts @@ -1,45 +1,17 @@ +import { extractMapValues, getEndpointBody } from 'store/new-services.store'; import { servicesRequestsExplain } from '../resources/api-constants'; import api from '../services/api-dev'; import { EndpointDefinition } from '../types/endpoint'; -export const extractMapValues = (element: any) => { - if (element?.rawData && element?.rawData?.length > 0) { - return element.rawData.value; - } - - let result: any = {}; - if (element?.variables) { - for (const entry of element.variables) { - result = { ...result, [entry.name]: entry.value }; - } - } - return result; -}; - export const generateJsonRequest = async (endpoint: EndpointDefinition) => { try { - console.log('Generating JSON request for endpoint: ', endpoint); - const isRawBodySelected = endpoint?.body?.isRawSelected ?? false; - const rawBody = endpoint?.body?.rawData ?? {}; - let body: any = extractMapValues(endpoint.body); - - if (isRawBodySelected) { - try { - const rawJson = JSON.parse(rawBody?.value ?? ''); - body = rawJson; - } catch (e: any) { - body = extractMapValues(endpoint.body); - console.log(`Unable to save JSON to Yaml. ${e.message}`); - } - } - const response = await api.post(servicesRequestsExplain(), { requests: [ { url: endpoint.url, method: endpoint.methodType, headers: extractMapValues(endpoint.headers), - body: body, + body: getEndpointBody(endpoint), params: extractMapValues(endpoint.params), }, ], From 60894a7460ee3672dac4e0b0ef31e6a0a6807eb5 Mon Sep 17 00:00:00 2001 From: 1AhmedYasser <26207361+1AhmedYasser@users.noreply.github.com> Date: Tue, 3 Feb 2026 22:32:05 +0200 Subject: [PATCH 2/4] fix(897): Fixed Format --- GUI/src/store/new-services.store.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/GUI/src/store/new-services.store.ts b/GUI/src/store/new-services.store.ts index 60a92088..411b7630 100644 --- a/GUI/src/store/new-services.store.ts +++ b/GUI/src/store/new-services.store.ts @@ -26,7 +26,13 @@ import { saveFlowClick } from 'services/service-builder'; import { EndpointDefinitionJson, Service, ServiceState, Step, StepType } from 'types'; import { Assign } from 'types/assign'; import { Chip } from 'types/chip'; -import { EndpointData, EndpointDefinition, EndpointEnv, EndpointTab, PreDefinedEndpointEnvVariables } from 'types/endpoint'; +import { + EndpointData, + EndpointDefinition, + EndpointEnv, + EndpointTab, + PreDefinedEndpointEnvVariables, +} from 'types/endpoint'; import { EndpointResponseVariable } from 'types/endpoint/endpoint-response-variables'; import { EndpointType } from 'types/endpoint/endpoint-type'; import { RequestVariablesTabsRawData, RequestVariablesTabsRowsData } from 'types/request-variables'; From d8908b1d26e4299444f6d488ad86d32217715c98 Mon Sep 17 00:00:00 2001 From: 1AhmedYasser <26207361+1AhmedYasser@users.noreply.github.com> Date: Tue, 3 Feb 2026 22:33:20 +0200 Subject: [PATCH 3/4] fix(897): Fixed lint --- GUI/src/utils/json-request-utils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/GUI/src/utils/json-request-utils.ts b/GUI/src/utils/json-request-utils.ts index 4a69c856..08beb72b 100644 --- a/GUI/src/utils/json-request-utils.ts +++ b/GUI/src/utils/json-request-utils.ts @@ -1,4 +1,5 @@ import { extractMapValues, getEndpointBody } from 'store/new-services.store'; + import { servicesRequestsExplain } from '../resources/api-constants'; import api from '../services/api-dev'; import { EndpointDefinition } from '../types/endpoint'; From e23c88912cfb7c08f2db8c44c487b8fe0e25fb7c Mon Sep 17 00:00:00 2001 From: 1AhmedYasser <26207361+1AhmedYasser@users.noreply.github.com> Date: Tue, 3 Feb 2026 22:43:05 +0200 Subject: [PATCH 4/4] chore(898): Added Base pill to api previous pills --- GUI/src/store/new-services.store.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GUI/src/store/new-services.store.ts b/GUI/src/store/new-services.store.ts index 411b7630..1ace8196 100644 --- a/GUI/src/store/new-services.store.ts +++ b/GUI/src/store/new-services.store.ts @@ -288,6 +288,12 @@ const useServiceStore = create((set, get) => ({ }); } + chips.push({ + name: 'Base Response', + value: `${endpoint?.name.replaceAll(' ', '_')}_res.response.body`, + data: `${endpoint?.name.replaceAll(' ', '_')}_res.response.body`, + }); + chips.push({ name: 'Status Code', value: `${endpoint?.name.replaceAll(' ', '_')}_res.response.statusCodeValue`,