UNPKG

@radcliffetech/symbolos-core

Version:

Core symbolic simulation and execution engine for Symbolos

30 lines (29 loc) 1.03 kB
export async function applyFunctor(functor, input, inputId, context = {}) { const output = await functor.apply(input, context); if (!output) { throw new Error(`Functor ${functor.method} did not return a valid output.`); } // check to see of this is a list of outputs or a single output const provenance = functor.describeProvenance(input, output); const outputId = output.id ?? 'unknown-output'; const id = `tx-${crypto.randomUUID()}`; const entry = { id, type: 'Transformation', label: functor.name || functor.method, inputType: functor.inputType, outputType: functor.outputType, inputId, outputId, method: functor.method, metadata: provenance, createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), status: 'complete', rootId: 'transformation-root', // all transformations share the same root }; return { output, transformation: entry, }; }