Skip to content

Commit a77db75

Browse files
committed
feat: ChainExecutor 및 SortableStepItem 컴포넌트의 매핑 로직 개선
- ChainExecutor에서 'field' 매핑 타입 제거 및 'skip' 타입 추가로 매핑 로직 간소화 - SortableStepItem 컴포넌트에서 매핑 타입 선택 UI 개선 및 'field' 옵션 제거 - 매핑 타입을 정규화하는 함수 추가로 코드 가독성 향상 - 사용자 경험을 고려한 UI 요소 개선으로 매핑 설정 기능 향상
1 parent f1fb0f0 commit a77db75

2 files changed

Lines changed: 20 additions & 70 deletions

File tree

src/main/chainExecutor.ts

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -294,25 +294,17 @@ export class ChainExecutor {
294294
const mapping = paramMappings[paramName];
295295
if (mapping) {
296296
switch (mapping.type) {
297-
case 'auto':
298-
// Use entire input as parameter value
299-
pathParams[paramName] = String(inputData);
300-
break;
301-
case 'field':
302-
// Extract field from JSON input
303-
if (mapping.value && mapping.value.startsWith('$.')) {
304-
const fieldName = mapping.value.substring(2);
305-
if (typeof inputData === 'object' && inputData !== null && fieldName in inputData) {
306-
pathParams[paramName] = String(inputData[fieldName]);
307-
}
308-
}
309-
break;
310297
case 'fixed':
311298
// Use fixed value
312299
pathParams[paramName] = mapping.value || '';
313300
break;
301+
case 'skip':
302+
// Explicitly omit the parameter
303+
pathParams[paramName] = '';
304+
break;
305+
case 'auto':
314306
default:
315-
// Default to auto mapping
307+
// Use entire input as parameter value
316308
pathParams[paramName] = String(inputData);
317309
}
318310
} else {
@@ -336,15 +328,6 @@ export class ChainExecutor {
336328
// Use entire input as parameter value
337329
queryParams[paramName] = String(inputData);
338330
break;
339-
case 'field':
340-
// Extract field from JSON input
341-
if (mapping.value && mapping.value.startsWith('$.')) {
342-
const fieldName = mapping.value.substring(2);
343-
if (typeof inputData === 'object' && inputData !== null && fieldName in inputData) {
344-
queryParams[paramName] = String(inputData[fieldName]);
345-
}
346-
}
347-
break;
348331
case 'fixed':
349332
// Use fixed value
350333
queryParams[paramName] = mapping.value || '';
@@ -528,4 +511,4 @@ export class ChainExecutor {
528511
}
529512

530513
// Export singleton instance
531-
export const chainExecutor = new ChainExecutor();
514+
export const chainExecutor = new ChainExecutor();

src/renderer/components/SortableStepItem.tsx

Lines changed: 13 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ export const SortableStepItem: React.FC<SortableStepItemProps> = ({
9797
const availablePathParams = selectedTemplate ? extractPathParams(selectedTemplate.pathTemplate) : [];
9898
const availableQueryParams = selectedTemplate ? extractQueryParams(selectedTemplate.queryTemplate) : [];
9999

100+
const normalizeMappingType = (type?: string): 'auto' | 'fixed' | 'skip' => {
101+
if (type === 'fixed') return 'fixed';
102+
if (type === 'skip') return 'skip';
103+
return 'auto';
104+
};
105+
100106
const getStepIcon = () => {
101107
switch (step.type) {
102108
case 'rsa-encrypt':
@@ -457,7 +463,7 @@ export const SortableStepItem: React.FC<SortableStepItemProps> = ({
457463
</span>
458464
<Select
459465
placeholder="매핑 선택"
460-
value={step.params?.paramMappings?.[param]?.type || 'auto'}
466+
value={normalizeMappingType(step.params?.paramMappings?.[param]?.type)}
461467
onChange={(value) => {
462468
const paramMappings = { ...step.params?.paramMappings };
463469
paramMappings[param] = { type: value };
@@ -468,31 +474,12 @@ export const SortableStepItem: React.FC<SortableStepItemProps> = ({
468474
style={{ flex: 1 }}
469475
size="small"
470476
>
471-
<Select.Option value="auto">🔄 이전 출력 전체</Select.Option>
472-
<Select.Option value="field">📌 JSON 필드</Select.Option>
477+
<Select.Option value="auto">🔄 이전 출력</Select.Option>
473478
<Select.Option value="fixed">📎 고정 값</Select.Option>
479+
<Select.Option value="skip">⏭️ 사용하지 않음</Select.Option>
474480
</Select>
475481
</div>
476482

477-
{step.params?.paramMappings?.[param]?.type === 'field' && (
478-
<Input
479-
placeholder="필드 경로 (예: $.id)"
480-
value={step.params?.paramMappings?.[param]?.value || ''}
481-
onChange={(e) => {
482-
const paramMappings = { ...step.params?.paramMappings };
483-
paramMappings[param] = {
484-
...paramMappings[param],
485-
value: e.target.value
486-
};
487-
onUpdateStep(step.id, {
488-
params: { ...step.params, paramMappings }
489-
});
490-
}}
491-
size="small"
492-
style={{ marginTop: 4, marginLeft: 68 }}
493-
/>
494-
)}
495-
496483
{step.params?.paramMappings?.[param]?.type === 'fixed' && (
497484
<Input
498485
placeholder="고정 값"
@@ -530,7 +517,7 @@ export const SortableStepItem: React.FC<SortableStepItemProps> = ({
530517
</span>
531518
<Select
532519
placeholder="매핑 선택"
533-
value={step.params?.queryMappings?.[param]?.type || 'auto'}
520+
value={normalizeMappingType(step.params?.queryMappings?.[param]?.type)}
534521
onChange={(value) => {
535522
const queryMappings = { ...step.params?.queryMappings };
536523
queryMappings[param] = { type: value };
@@ -541,32 +528,12 @@ export const SortableStepItem: React.FC<SortableStepItemProps> = ({
541528
style={{ flex: 1 }}
542529
size="small"
543530
>
544-
<Select.Option value="auto">🔄 이전 출력 전체</Select.Option>
545-
<Select.Option value="field">📌 JSON 필드</Select.Option>
531+
<Select.Option value="auto">🔄 이전 출력</Select.Option>
546532
<Select.Option value="fixed">📎 고정 값</Select.Option>
547-
<Select.Option value="skip">⏭️ 생략</Select.Option>
533+
<Select.Option value="skip">⏭️ 사용하지 않음</Select.Option>
548534
</Select>
549535
</div>
550536

551-
{step.params?.queryMappings?.[param]?.type === 'field' && (
552-
<Input
553-
placeholder="필드 경로 (예: $.page)"
554-
value={step.params?.queryMappings?.[param]?.value || ''}
555-
onChange={(e) => {
556-
const queryMappings = { ...step.params?.queryMappings };
557-
queryMappings[param] = {
558-
...queryMappings[param],
559-
value: e.target.value
560-
};
561-
onUpdateStep(step.id, {
562-
params: { ...step.params, queryMappings }
563-
});
564-
}}
565-
size="small"
566-
style={{ marginTop: 4, marginLeft: 68 }}
567-
/>
568-
)}
569-
570537
{step.params?.queryMappings?.[param]?.type === 'fixed' && (
571538
<Input
572539
placeholder="고정 값"
@@ -624,4 +591,4 @@ export const SortableStepItem: React.FC<SortableStepItemProps> = ({
624591
</Card>
625592
</div>
626593
);
627-
};
594+
};

0 commit comments

Comments
 (0)