UNPKG

@redocly/respect-core

Version:
29 lines 1.28 kB
import { resolveInputValuesToSchema } from '../inputs/index.js'; import { getPublicSteps } from './set-public-steps.js'; export function getPublicWorkflows({ workflows, inputs, env = {}, }) { const publicWorkflows = {}; for (const workflow of workflows) { const workflowInputSchema = workflow.inputs; const mergedInputs = mergeWorkflowInputs({ inputs, workflowInputSchema, env }); publicWorkflows[workflow.workflowId] = { steps: getPublicSteps(workflow.steps || []), inputs: workflowInputSchema ? mergedInputs : undefined, outputs: workflow.outputs, }; } return publicWorkflows; } export function mergeWorkflowInputs({ inputs, workflowInputSchema, env, }) { let resolvedInputs = {}; let resolvedDotEnvInputs = {}; if (workflowInputSchema) { resolvedInputs = resolveInputValuesToSchema(inputs, workflowInputSchema); } if (workflowInputSchema?.properties?.env) { resolvedDotEnvInputs = resolveInputValuesToSchema(env || {}, workflowInputSchema.properties.env); } return Object.keys(resolvedDotEnvInputs).length > 0 ? { ...resolvedInputs, env: resolvedDotEnvInputs } : resolvedInputs; } //# sourceMappingURL=set-public-workflows.js.map