{"_id":"@bazariodev/fsm-inspect","name":"@bazariodev/fsm-inspect","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@bazariodev/fsm-inspect","version":"1.0.0","description":"Dev-time inspection helpers for @bazariodev/fsm timelines and Mermaid diagrams.","license":"MIT","author":{"name":"Bazario"},"repository":{"type":"git","url":"git+https://github.com/Bazariodev/bazario-labs.git","directory":"packages/fsm-inspect"},"homepage":"https://github.com/Bazariodev/bazario-labs/tree/main/packages/fsm-inspect#readme","bugs":{"url":"https://github.com/Bazariodev/bazario-labs/issues"},"keywords":["fsm","finite-state-machine","state-machine","inspection","debugging","mermaid","typescript","realtime","telephony","ucaas"],"type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"sideEffects":false,"peerDependencies":{"@bazariodev/fsm":"^1.0.0"},"devDependencies":{"@bazariodev/fsm-hierarchy":"^1.0.0","@bazariodev/fsm":"^1.0.0"},"publishConfig":{"access":"public"},"scripts":{"build":"tsup","test":"vitest run","test:watch":"vitest","typecheck":"tsc --noEmit"},"_id":"@bazariodev/fsm-inspect@1.0.0","_integrity":"sha512-2XPn1KVfhdaX+/j3W2FjvOH5iAAF5ECLqgRy+k6Q86v9T8pMFB+xmZ4TtUpYZDyoUAtRNOeH21u4C5PzfgfPbQ==","_resolved":"/private/var/folders/xk/pm_239nx0cjgz296_sbs_f1c0000gn/T/d7c63512fc6a2c297a7912442bb421e6/bazariodev-fsm-inspect-1.0.0.tgz","_from":"file:bazariodev-fsm-inspect-1.0.0.tgz","_nodeVersion":"24.7.0","_npmVersion":"11.5.1","dist":{"integrity":"sha512-2XPn1KVfhdaX+/j3W2FjvOH5iAAF5ECLqgRy+k6Q86v9T8pMFB+xmZ4TtUpYZDyoUAtRNOeH21u4C5PzfgfPbQ==","shasum":"dffb76b70876a658f3ff9718dd316eb5148e89e1","tarball":"https://registry.npmjs.org/@bazariodev/fsm-inspect/-/fsm-inspect-1.0.0.tgz","fileCount":9,"unpackedSize":149315,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIG7nnGLH7zT3Dc6I3WBR00okLkVqsUfEiw5q8GKl9o8LAiBR0MoOmDpyeDCaN9/Ct6nMMNeiCOSwfCe0okZoxir5Sg=="}]},"_npmUser":{"name":"bazario","email":"bazario.dev@gmail.com"},"directories":{},"maintainers":[{"name":"bazario","email":"bazario.dev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/fsm-inspect_1.0.0_1783331028635_0.9190905616470728"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-06T09:43:48.493Z","1.0.0":"2026-07-06T09:43:48.769Z","modified":"2026-07-06T09:43:48.962Z"},"maintainers":[{"name":"bazario","email":"bazario.dev@gmail.com"}],"description":"Dev-time inspection helpers for @bazariodev/fsm timelines and Mermaid diagrams.","homepage":"https://github.com/Bazariodev/bazario-labs/tree/main/packages/fsm-inspect#readme","keywords":["fsm","finite-state-machine","state-machine","inspection","debugging","mermaid","typescript","realtime","telephony","ucaas"],"repository":{"type":"git","url":"git+https://github.com/Bazariodev/bazario-labs.git","directory":"packages/fsm-inspect"},"author":{"name":"Bazario"},"bugs":{"url":"https://github.com/Bazariodev/bazario-labs/issues"},"license":"MIT","readme":"# @bazariodev/fsm-inspect\n\nDev-time inspection helpers for the Bazario FSM family.\n\n`@bazariodev/fsm-inspect` is opt-in and side-effect free. It gives you:\n\n- a bounded `InspectRecorder` timeline\n- config instrumentation for `init`, `transition-start`, and `transition` entries\n- a logger adapter that records `debug` / `warn` / `error` diagnostics\n- `recordSource` for subscribe-based commit timelines\n- Mermaid `stateDiagram-v2` export for flat and hierarchy configs\n\n## Timeline\n\n```ts\nimport { Fsm } from '@bazariodev/fsm';\nimport { FsmEffects } from '@bazariodev/fsm-effects';\nimport {\n  InspectRecorder,\n  instrumentFsmConfig,\n  recordSource,\n} from '@bazariodev/fsm-inspect';\n\nconst recorder = new InspectRecorder({\n  limit: 1000,\n  mapContext: redactContext,\n  mapEvent: redactEvent,\n  mapSnapshot: redactSnapshot,\n  mapMeta: redactLogMeta,\n  onEntry: (entry) => console.debug(entry),\n});\n\nconst machine = new Fsm(\n  instrumentFsmConfig({ ...callConfig, logger: recorder.logger }, recorder),\n);\n\nconst effects = new FsmEffects(machine, {\n  ...callEffects,\n  logger: recorder.logger,\n});\n\nconst commits = recordSource(machine, recorder, { name: 'call' });\n\nmachine.send({ type: 'DIAL', destination: '101' });\n\nconsole.table(recorder.entries);\ncommits.stop();\neffects.stop();\n```\n\n`instrumentFsmConfig` is a pure transform. It returns a new config object and never mutates the input. Apply it before constructing the machine.\n\nTransitions are traced as a start/complete pair:\n\n- `transition-start` is recorded from `onTransitionStart`\n- `transition` is recorded from `onTransitionBeforeCommit`\n- both entries share a recorder-allocated `attemptId`\n\nIf an accepted transition aborts before `onTransitionBeforeCommit`, the timeline contains only `transition-start`. If the consumer's own `onTransitionBeforeCommit` throws after the inspector records, both entries remain even though the commit aborts.\n\n## Source Recording\n\n`recordSource(source, recorder, options)` works with anything exposing:\n\n```ts\nimport type { FsmSubscribable } from '@bazariodev/fsm';\n```\n\nThe shared core shape is a stable `snapshot` accessor plus `subscribe(listener)`, where the listener may receive the committed snapshot.\n\nIt records the attach-time snapshot, then one `commit` entry per delivered snapshot. If a source delivers no subscriber payload, `recordSource` falls back to reading `source.snapshot`. Payload-delivered and fallback snapshots are deduped by reference, so hierarchy node birth snapshots are recorded once.\n\nCommit labels are derived from the mapped snapshot, so `mapSnapshot` redaction applies before the default `value` / `path` label or a custom `label` callback runs.\n\n## Mermaid\n\n```ts\nimport { mermaidFromFsmConfig } from '@bazariodev/fsm-inspect';\n\nconst diagram = mermaidFromFsmConfig(callConfig);\n```\n\nThe renderers generate `stateDiagram-v2` text from validated configs. Wildcard transitions render as notes by default:\n\n```ts\nmermaidFromFsmConfig(callConfig, { wildcard: 'note' });\n```\n\nUse `wildcard: 'expand'` to draw wildcard transitions from every state instead.\n\nHierarchy diagrams path-scope every Mermaid id so repeated state names in nested machines do not collide.\n\n## Redaction\n\nInspection retains contexts, snapshots, events, and log metadata in memory by reference. If a recorder forwards entries to a remote sink, redact all capture paths:\n\n- `mapContext`\n- `mapSnapshot`\n- `mapEvent`\n- `mapMeta`\n\nKeeping credentials, tokens, and PII out of machine context and event payloads is still the better default.\n","readmeFilename":"README.md","_rev":"1-9007e0117f53cb1e7f4418d4ab50aa07"}