@glyphlab/scenario-core
v0.3.1
Published
The scenario engine: the scenario file format, running a scripted walk against a graph of nodes and edges, checking that it fits, and the highlights a run lights up. No UI.
Maintainers
Readme
@glyphlab/scenario-core
The scenario engine, without UI. Peer dependencies: zod, @glyphlab/diagram-core.
import { defaultInput, readScenarioFile, runScenario } from '@glyphlab/scenario-core'
const file = readScenarioFile(json) // { ok, value: { scenarios } } or a typed error
const graph = { nodes: [{ id: 'a', title: 'Web' }], edges: [{ id: 'e', from: 'a', to: 'b' }] }
const scenario = file.ok ? file.value.scenarios[0] : undefined
const trace = scenario && runScenario(graph, scenario, defaultInput(scenario)) // steps, outcome, messagerunScenario(graph, scenario, input)is pure: the same graph, scenario and input give the same trace.validateScenario/checkNewScenarioreport the steps that point at nodes or edges the graph does not have.highlightsAt(trace, cursor)gives what to light up on a diagram at a step (the types arediagram-core's).scenarioSchemais the one definition used by the file format and by the createScenario tool.
