Skip to content

Commit 917fe42

Browse files
committed
better organization
1 parent 71e80f4 commit 917fe42

13 files changed

Lines changed: 543 additions & 333 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/search-replace/hooks/use-workflow-search-reference-hydration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useMemo } from 'react'
2-
import { getWorkflowSearchMatchResourceGroupKey } from '@/lib/workflows/search-replace/resource-resolvers'
2+
import { getWorkflowSearchMatchResourceGroupKey } from '@/lib/workflows/search-replace/resources'
33
import type { WorkflowSearchMatch } from '@/lib/workflows/search-replace/types'
44
import { usePersonalEnvironment, useWorkspaceEnvironment } from '@/hooks/queries/environment'
55
import {

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/search-replace/workflow-search-replace.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ import { Button, Input } from '@/components/emcn'
77
import { cn } from '@/lib/core/utils/cn'
88
import { getWorkflowSearchDependentClears } from '@/lib/workflows/search-replace/dependencies'
99
import { indexWorkflowSearchMatches } from '@/lib/workflows/search-replace/indexer'
10-
import {
11-
getCompatibleResourceReplacementOptions,
12-
getWorkflowSearchReplacementIssue,
13-
isConstrainedResourceMatch,
14-
} from '@/lib/workflows/search-replace/replacement-validation'
1510
import { buildWorkflowSearchReplacePlan } from '@/lib/workflows/search-replace/replacements'
1611
import {
12+
getCompatibleResourceReplacementOptions,
1713
getWorkflowSearchCompatibleResourceMatches,
1814
getWorkflowSearchMatchResourceGroupKey,
15+
getWorkflowSearchReplacementIssue,
16+
isConstrainedResourceMatch,
1917
workflowSearchMatchMatchesQuery,
20-
} from '@/lib/workflows/search-replace/resource-resolvers'
18+
} from '@/lib/workflows/search-replace/resources'
2119
import { getWorkflowSearchBlocks } from '@/lib/workflows/search-replace/state'
2220
import { WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS } from '@/lib/workflows/search-replace/subflow-fields'
2321
import type { WorkflowSearchReplaceSubflowUpdate } from '@/lib/workflows/search-replace/types'

apps/sim/hooks/queries/workflow-search-replace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
} from '@/lib/api/contracts/workspace-files'
2121
import { createMcpToolId } from '@/lib/mcp/shared'
2222
import type { Credential } from '@/lib/oauth'
23-
import { stableStringifyWorkflowSearchValue } from '@/lib/workflows/search-replace/resource-resolvers'
23+
import { stableStringifyWorkflowSearchValue } from '@/lib/workflows/search-replace/resources'
2424
import type {
2525
WorkflowSearchMatch,
2626
WorkflowSearchReplacementOption,

apps/sim/lib/workflows/search-replace/indexer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import { describe, expect, it } from 'vitest'
55
import { indexWorkflowSearchMatches } from '@/lib/workflows/search-replace/indexer'
6-
import { workflowSearchMatchMatchesQuery } from '@/lib/workflows/search-replace/resource-resolvers'
6+
import { workflowSearchMatchMatchesQuery } from '@/lib/workflows/search-replace/resources'
77
import {
88
createSearchReplaceWorkflowFixture,
99
SEARCH_REPLACE_BLOCK_CONFIGS,

apps/sim/lib/workflows/search-replace/indexer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
matchesSearchText,
1010
parseInlineReferences,
1111
parseStructuredResourceReferences,
12-
} from '@/lib/workflows/search-replace/reference-registry'
12+
} from '@/lib/workflows/search-replace/resources'
1313
import { getWorkflowSearchSubflowFields } from '@/lib/workflows/search-replace/subflow-fields'
1414
import type {
1515
WorkflowSearchBlockState,

apps/sim/lib/workflows/search-replace/reference-registry.ts

Lines changed: 0 additions & 194 deletions
This file was deleted.

apps/sim/lib/workflows/search-replace/replacements.test.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,60 @@ describe('buildWorkflowSearchReplacePlan', () => {
505505
])
506506
})
507507

508+
it('rejects invalid file upload replacement payloads', () => {
509+
const workflow = createSearchReplaceWorkflowFixture()
510+
workflow.blocks['file-upload-1'] = {
511+
id: 'file-upload-1',
512+
type: 'custom',
513+
name: 'File Upload Block',
514+
position: { x: 0, y: 0 },
515+
enabled: true,
516+
outputs: {},
517+
subBlocks: {
518+
file: {
519+
id: 'file',
520+
type: 'file-upload',
521+
value: {
522+
name: 'old.csv',
523+
path: '/workspace/ws-1/old-key',
524+
key: 'old-key',
525+
},
526+
},
527+
},
528+
}
529+
const blockConfigs = {
530+
...SEARCH_REPLACE_BLOCK_CONFIGS,
531+
custom: {
532+
subBlocks: [{ id: 'file', title: 'File', type: 'file-upload' }],
533+
},
534+
}
535+
536+
const matches = indexWorkflowSearchMatches({
537+
workflow,
538+
query: 'old',
539+
mode: 'resource',
540+
blockConfigs,
541+
}).filter((match) => match.blockId === 'file-upload-1')
542+
543+
const plan = buildWorkflowSearchReplacePlan({
544+
blocks: workflow.blocks,
545+
matches,
546+
selectedMatchIds: new Set(matches.map((match) => match.id)),
547+
defaultReplacement: '"not-a-file-object"',
548+
resourceReplacementOptions: [
549+
{ kind: 'file', value: '"not-a-file-object"', label: 'Invalid file' },
550+
],
551+
})
552+
553+
expect(plan.updates).toEqual([])
554+
expect(plan.conflicts).toEqual([
555+
{
556+
matchId: matches[0].id,
557+
reason: 'Replacement file is no longer valid',
558+
},
559+
])
560+
})
561+
508562
it('rejects invalid subflow iteration replacements', () => {
509563
const workflow = createSearchReplaceWorkflowFixture()
510564
workflow.blocks['parallel-1'] = {

0 commit comments

Comments
 (0)