MCPcopy Index your code
hub / github.com/simstudioai/sim / buildSelectorContext

Function buildSelectorContext

apps/sim/lib/workflows/search-replace/indexer.ts:842–888  ·  view source on GitHub ↗
({
  subBlockConfig,
  subBlockValues,
  canonicalIndex,
  canonicalModes,
  workspaceId,
  workflowId,
}: {
  subBlockConfig?: WorkflowSearchSubBlockConfig
  subBlockValues: Record<string, unknown>
  canonicalIndex: ReturnType<typeof buildCanonicalIndex>
  canonicalModes?: CanonicalModeOverrides
  workspaceId?: string
  workflowId?: string
})

Source from the content-addressed store, hash-verified

840}
841
842function buildSelectorContext({
843 subBlockConfig,
844 subBlockValues,
845 canonicalIndex,
846 canonicalModes,
847 workspaceId,
848 workflowId,
849}: {
850 subBlockConfig?: WorkflowSearchSubBlockConfig
851 subBlockValues: Record<string, unknown>
852 canonicalIndex: ReturnType<typeof buildCanonicalIndex>
853 canonicalModes?: CanonicalModeOverrides
854 workspaceId?: string
855 workflowId?: string
856}): SelectorContext {
857 const context: SelectorContext = {}
858 if (workspaceId) context.workspaceId = workspaceId
859 if (workflowId) {
860 context.workflowId = workflowId
861 context.excludeWorkflowId = workflowId
862 }
863
864 if (subBlockConfig?.mimeType) context.mimeType = subBlockConfig.mimeType
865
866 const { allDependsOnFields } = parseDependsOn(subBlockConfig?.dependsOn)
867
868 for (const subBlockId of allDependsOnFields) {
869 const value = normalizeDependencyValue(
870 resolveDependencyValue(subBlockId, subBlockValues, canonicalIndex, canonicalModes)
871 )
872 if (value === null || value === undefined) continue
873 const stringValue = typeof value === 'string' ? value : String(value)
874 if (!stringValue) continue
875 if (isReference(stringValue)) continue
876
877 const canonicalKey = canonicalIndex.canonicalIdBySubBlockId[subBlockId] ?? subBlockId
878 if (subBlockConfig?.type === 'mcp-tool-selector' && canonicalKey === 'server') {
879 context.mcpServerId = stringValue
880 continue
881 }
882 if (SELECTOR_CONTEXT_FIELDS.has(canonicalKey as keyof SelectorContext)) {
883 context[canonicalKey as keyof SelectorContext] = stringValue
884 }
885 }
886
887 return context
888}
889
890function buildSearchSelectorContext({
891 block,

Callers 2

getToolInputParamConfigsFunction · 0.85

Calls 4

parseDependsOnFunction · 0.90
normalizeDependencyValueFunction · 0.90
resolveDependencyValueFunction · 0.90
isReferenceFunction · 0.90

Tested by

no test coverage detected