@redocly/respect-core
Version:
API testing framework core
29 lines • 1.28 kB
JavaScript
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