yaml-flow 7.0.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/asset-integrity.json +8 -4
- package/browser/board-livecards-client.js +1 -1
- package/browser/board-livecards-localstorage.js +5 -5
- package/browser/live-cards.js +19 -3307
- package/cli/board-live-cards-lib-tjYsPt5U.d.ts +321 -0
- package/{dist/cli → cli}/browser-api/board-live-cards-browser-adapter.d.ts +3 -5
- package/cli/browser-api/board-live-cards-browser-adapter.js +3 -0
- package/{dist/cli → cli}/browser-api/card-store-browser-api.d.ts +1 -2
- package/{dist/cli → cli}/browser-api/card-store-browser-api.js +1 -1
- package/cli/execution-interface-C_A6WCiK.d.ts +284 -0
- package/cli/node/artifacts-store-cli.js +11 -0
- package/cli/node/batch-runner-cli.js +3 -0
- package/cli/node/board-live-cards-cli.js +15 -0
- package/cli/node/card-store-cli.js +8 -0
- package/{dist/cli → cli}/node/execution-adapter.d.ts +3 -3
- package/cli/node/execution-adapter.js +3 -0
- package/{dist/cli → cli}/node/fs-board-adapter.d.ts +24 -11
- package/cli/node/fs-board-adapter.js +14 -0
- package/{dist/cli → cli}/node/source-cli-task-executor.js +2 -2
- package/cli/node/step-machine-cli.d.ts +7 -0
- package/cli/node/step-machine-cli.js +5 -0
- package/{dist/board-live-cards-public-CW5074xr.d.cts → cli/types-CziUxkiv.d.ts} +69 -7
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.config/card-store-ref.json +1 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.config/chat-handler.json +1 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.config/outputs-store-ref.json +1 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.config/task-executor.json +1 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.state-snapshot/board/graph.json +29 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.state-snapshot/board/lastJournalProcessedId.json +1 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime-out/.outputs/status.json +25 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/cards/card-market-prices/computed_values.json +67 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/cards/card-portfolio/computed_values.json +1 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/cards/card-portfolio-value/computed_values.json +52 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/data-objects/holdings.json +22 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/data-objects/positions.json +46 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/data-objects/quotes.json +35 -0
- package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/status.json +113 -0
- package/examples/{example-board/cards/card-market-prices.json → board/cards/cardT-market-prices.json} +2 -2
- package/examples/{example-board/cards/card-portfolio.json → board/cards/cardT-portfolio.json} +3 -13
- package/examples/{example-board → board}/demo-server-config.json +0 -1
- package/examples/{example-board → board}/demo-server.js +70 -72
- package/examples/{example-board → board}/demo-shell-with-server.html +3 -3
- package/examples/{example-board → board}/demo-task-executor.js +75 -32
- package/examples/board/gandalf-cards/card-source-kinds.json +36 -0
- package/examples/board/gandalf-cards/cards/_index.json +7 -0
- package/examples/board/gandalf-cards/cards/card-source-kinds.json +64 -0
- package/examples/board/source-def-flows/copilot.flow.json +33 -0
- package/examples/board/source-def-flows/mock.flow.json +35 -0
- package/examples/board/source-def-flows/url-list.flow.json +33 -0
- package/examples/board/source-def-flows/url.flow.json +33 -0
- package/examples/board/source-def-flows/workiq.flow.json +34 -0
- package/examples/board/source-def-handlers/copilot-source-handler.js +141 -0
- package/examples/board/source-def-handlers/http-source-handler.js +145 -0
- package/examples/board/source_def_flows.json +249 -0
- package/examples/board/test/demo-http-test.js +317 -0
- package/examples/{example-board → board-local}/demo-shell-localstorage.html +4 -4
- package/examples/{browser/boards/portfolio-tracker → portfolio-tracker/handlers}/portfolio-tracker-fetch-prices.js +1 -1
- package/examples/{browser/boards/portfolio-tracker/portfolio-tracker-public.js → portfolio-tracker/portfolio-tracker.js} +11 -14
- package/examples/{browser/boards/portfolio-tracker → portfolio-tracker/test}/portfolio-t4.js +32 -50
- package/lib/artifacts-store-lib-public-BABrgFkV.d.ts +119 -0
- package/lib/artifacts-store-lib-public-DGa8BpJT.d.cts +119 -0
- package/lib/artifacts-store-public.cjs +2 -0
- package/lib/artifacts-store-public.d.cts +5 -0
- package/lib/artifacts-store-public.d.ts +5 -0
- package/lib/artifacts-store-public.js +2 -0
- package/lib/board-live-cards-node.cjs +14 -0
- package/{dist/cli/node/execution-adapter.d.cts → lib/board-live-cards-node.d.cts} +45 -85
- package/lib/board-live-cards-node.d.ts +134 -0
- package/lib/board-live-cards-node.js +14 -0
- package/lib/board-live-cards-public-BnmRAbQV.d.cts +383 -0
- package/{dist/board-live-cards-public-hnZo0mAf.d.ts → lib/board-live-cards-public-CsmYrvpd.d.ts} +142 -77
- package/lib/board-live-cards-public.cjs +3 -0
- package/lib/board-live-cards-public.d.cts +4 -0
- package/lib/board-live-cards-public.d.ts +4 -0
- package/lib/board-live-cards-public.js +3 -0
- package/lib/board-live-cards-server-runtime.cjs +9 -0
- package/lib/board-live-cards-server-runtime.d.cts +6 -0
- package/lib/board-live-cards-server-runtime.d.ts +6 -0
- package/lib/board-live-cards-server-runtime.js +9 -0
- package/lib/board-livegraph-runtime/index.cjs +3 -0
- package/{dist → lib}/board-livegraph-runtime/index.d.cts +1 -2
- package/{dist → lib}/board-livegraph-runtime/index.d.ts +1 -2
- package/lib/board-livegraph-runtime/index.js +3 -0
- package/lib/board-worker-adapter.cjs +10 -0
- package/{dist/storage-refs.d.cts → lib/board-worker-adapter.d.cts} +5 -5
- package/{dist/storage-refs.d.ts → lib/board-worker-adapter.d.ts} +5 -5
- package/lib/board-worker-adapter.js +10 -0
- package/{dist → lib}/card-compute/index.cjs +1 -1
- package/{dist → lib}/card-compute/index.js +1 -1
- package/lib/card-store-public.cjs +2 -0
- package/lib/card-store-public.d.cts +61 -0
- package/lib/card-store-public.d.ts +61 -0
- package/lib/card-store-public.js +2 -0
- package/lib/card-validation.cjs +10 -0
- package/lib/card-validation.d.cts +35 -0
- package/lib/card-validation.d.ts +35 -0
- package/lib/card-validation.js +10 -0
- package/{dist/constants-oCEbNpul.d.ts → lib/constants-BPVLb3Es.d.ts} +1 -1
- package/{dist/constants-BzZUyYlp.d.cts → lib/constants-DXxsRN9y.d.cts} +1 -1
- package/{dist → lib}/continuous-event-graph/index.cjs +2 -2
- package/{dist → lib}/continuous-event-graph/index.d.cts +3 -5
- package/{dist → lib}/continuous-event-graph/index.d.ts +3 -5
- package/{dist → lib}/continuous-event-graph/index.js +2 -2
- package/{dist → lib}/event-graph/index.d.cts +2 -2
- package/{dist → lib}/event-graph/index.d.ts +2 -2
- package/lib/execution-refs.cjs +3 -0
- package/{dist → lib}/execution-refs.d.cts +38 -14
- package/{dist → lib}/execution-refs.d.ts +38 -14
- package/lib/execution-refs.js +3 -0
- package/lib/index.cjs +25 -0
- package/{dist → lib}/index.d.cts +7 -8
- package/{dist → lib}/index.d.ts +7 -8
- package/lib/index.js +25 -0
- package/{dist/live-cards-bridge-BXbVTsna.d.cts → lib/live-cards-bridge-DC_ZU0eS.d.ts} +134 -3
- package/{dist/live-cards-bridge-Ds28XR15.d.ts → lib/live-cards-bridge-b25aAVvE.d.cts} +134 -3
- package/lib/loader-CuuLjxVA.d.cts +42 -0
- package/lib/loader-Zborm2pq.d.ts +42 -0
- package/lib/server-runtime/index.cjs +9 -0
- package/{dist → lib}/server-runtime/index.d.cts +4 -4
- package/{dist → lib}/server-runtime/index.d.ts +4 -4
- package/lib/server-runtime/index.js +9 -0
- package/lib/step-machine/index.d.cts +64 -0
- package/lib/step-machine/index.d.ts +64 -0
- package/lib/step-machine-public/index.cjs +5 -0
- package/{dist → lib}/step-machine-public/index.d.cts +21 -1
- package/{dist → lib}/step-machine-public/index.d.ts +21 -1
- package/lib/step-machine-public/index.js +5 -0
- package/lib/storage-interface-BhAON-gW.d.cts +84 -0
- package/lib/storage-interface-BhAON-gW.d.ts +84 -0
- package/lib/stores/index.cjs +3 -0
- package/lib/stores/index.d.cts +4 -0
- package/lib/stores/index.d.ts +4 -0
- package/lib/stores/index.js +3 -0
- package/lib/stores/kv.cjs +3 -0
- package/lib/stores/kv.d.cts +32 -0
- package/lib/stores/kv.d.ts +32 -0
- package/lib/stores/kv.js +3 -0
- package/{dist → lib}/stores/memory.d.cts +1 -1
- package/{dist → lib}/stores/memory.d.ts +1 -1
- package/{dist/types-B1ZRa4aI.d.ts → lib/types-CBxkYuLY.d.ts} +2 -1
- package/{dist/types-ycun84cq.d.cts → lib/types-DQ1bKuB1.d.cts} +11 -0
- package/{dist/types-ycun84cq.d.ts → lib/types-DQ1bKuB1.d.ts} +11 -0
- package/{dist/types-BxEFcVK9.d.cts → lib/types-DkFvgxwq.d.cts} +2 -1
- package/package.json +79 -119
- package/board-live-cards-cli.js +0 -37
- package/browser/board-livecards-client.js.map +0 -1
- package/browser/board-livecards-localstorage.js.map +0 -1
- package/browser/board-livegraph-engine.js +0 -3
- package/browser/board-livegraph-engine.js.map +0 -1
- package/browser/card-compute.js +0 -266
- package/browser/compute-jsonata.js.map +0 -1
- package/card-store.js +0 -37
- package/dist/batch/index.cjs.map +0 -1
- package/dist/batch/index.js.map +0 -1
- package/dist/board-live-cards-lib-Bg6EvCo5.d.cts +0 -136
- package/dist/board-live-cards-lib-jM2uYG1v.d.ts +0 -136
- package/dist/board-livegraph-runtime/index.cjs +0 -3
- package/dist/board-livegraph-runtime/index.cjs.map +0 -1
- package/dist/board-livegraph-runtime/index.js +0 -3
- package/dist/board-livegraph-runtime/index.js.map +0 -1
- package/dist/card-compute/index.cjs.map +0 -1
- package/dist/card-compute/index.js.map +0 -1
- package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs +0 -3
- package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs.map +0 -1
- package/dist/cli/browser-api/board-live-cards-browser-adapter.d.cts +0 -37
- package/dist/cli/browser-api/board-live-cards-browser-adapter.js +0 -3
- package/dist/cli/browser-api/board-live-cards-browser-adapter.js.map +0 -1
- package/dist/cli/browser-api/card-store-browser-api.cjs +0 -2
- package/dist/cli/browser-api/card-store-browser-api.cjs.map +0 -1
- package/dist/cli/browser-api/card-store-browser-api.d.cts +0 -26
- package/dist/cli/browser-api/card-store-browser-api.js.map +0 -1
- package/dist/cli/node/artifacts-store-cli.cjs +0 -11
- package/dist/cli/node/artifacts-store-cli.cjs.map +0 -1
- package/dist/cli/node/artifacts-store-cli.d.cts +0 -8
- package/dist/cli/node/artifacts-store-cli.js +0 -11
- package/dist/cli/node/artifacts-store-cli.js.map +0 -1
- package/dist/cli/node/board-live-cards-cli.cjs +0 -15
- package/dist/cli/node/board-live-cards-cli.cjs.map +0 -1
- package/dist/cli/node/board-live-cards-cli.d.cts +0 -20
- package/dist/cli/node/board-live-cards-cli.js +0 -15
- package/dist/cli/node/board-live-cards-cli.js.map +0 -1
- package/dist/cli/node/card-store-cli.cjs +0 -8
- package/dist/cli/node/card-store-cli.cjs.map +0 -1
- package/dist/cli/node/card-store-cli.d.cts +0 -15
- package/dist/cli/node/card-store-cli.js +0 -8
- package/dist/cli/node/card-store-cli.js.map +0 -1
- package/dist/cli/node/execution-adapter.cjs +0 -3
- package/dist/cli/node/execution-adapter.cjs.map +0 -1
- package/dist/cli/node/execution-adapter.js +0 -3
- package/dist/cli/node/execution-adapter.js.map +0 -1
- package/dist/cli/node/fs-board-adapter.cjs +0 -14
- package/dist/cli/node/fs-board-adapter.cjs.map +0 -1
- package/dist/cli/node/fs-board-adapter.d.cts +0 -204
- package/dist/cli/node/fs-board-adapter.js +0 -14
- package/dist/cli/node/fs-board-adapter.js.map +0 -1
- package/dist/cli/node/source-cli-task-executor.cjs +0 -11
- package/dist/cli/node/source-cli-task-executor.cjs.map +0 -1
- package/dist/cli/node/source-cli-task-executor.js.map +0 -1
- package/dist/config/index.cjs.map +0 -1
- package/dist/config/index.js.map +0 -1
- package/dist/continuous-event-graph/index.cjs.map +0 -1
- package/dist/continuous-event-graph/index.js.map +0 -1
- package/dist/event-graph/index.cjs.map +0 -1
- package/dist/event-graph/index.js.map +0 -1
- package/dist/execution-refs.cjs +0 -3
- package/dist/execution-refs.cjs.map +0 -1
- package/dist/execution-refs.js +0 -3
- package/dist/execution-refs.js.map +0 -1
- package/dist/index.cjs +0 -30
- package/dist/index.cjs.map +0 -1
- package/dist/index.js +0 -30
- package/dist/index.js.map +0 -1
- package/dist/inference/index.cjs +0 -7
- package/dist/inference/index.cjs.map +0 -1
- package/dist/inference/index.d.cts +0 -229
- package/dist/inference/index.d.ts +0 -229
- package/dist/inference/index.js +0 -7
- package/dist/inference/index.js.map +0 -1
- package/dist/server-runtime/index.cjs +0 -9
- package/dist/server-runtime/index.cjs.map +0 -1
- package/dist/server-runtime/index.js +0 -9
- package/dist/server-runtime/index.js.map +0 -1
- package/dist/step-machine/index.cjs.map +0 -1
- package/dist/step-machine/index.d.cts +0 -102
- package/dist/step-machine/index.d.ts +0 -102
- package/dist/step-machine/index.js.map +0 -1
- package/dist/step-machine-public/index.cjs +0 -2
- package/dist/step-machine-public/index.cjs.map +0 -1
- package/dist/step-machine-public/index.js +0 -2
- package/dist/step-machine-public/index.js.map +0 -1
- package/dist/storage-refs.cjs +0 -10
- package/dist/storage-refs.cjs.map +0 -1
- package/dist/storage-refs.js +0 -10
- package/dist/storage-refs.js.map +0 -1
- package/dist/stores/file.cjs +0 -2
- package/dist/stores/file.cjs.map +0 -1
- package/dist/stores/file.d.cts +0 -36
- package/dist/stores/file.d.ts +0 -36
- package/dist/stores/file.js +0 -2
- package/dist/stores/file.js.map +0 -1
- package/dist/stores/index.cjs +0 -2
- package/dist/stores/index.cjs.map +0 -1
- package/dist/stores/index.d.cts +0 -4
- package/dist/stores/index.d.ts +0 -4
- package/dist/stores/index.js +0 -2
- package/dist/stores/index.js.map +0 -1
- package/dist/stores/localStorage.cjs +0 -2
- package/dist/stores/localStorage.cjs.map +0 -1
- package/dist/stores/localStorage.d.cts +0 -34
- package/dist/stores/localStorage.d.ts +0 -34
- package/dist/stores/localStorage.js +0 -2
- package/dist/stores/localStorage.js.map +0 -1
- package/dist/stores/memory.cjs.map +0 -1
- package/dist/stores/memory.js.map +0 -1
- package/dist/types-CHSdoAAA.d.cts +0 -135
- package/dist/types-CoW0gQl3.d.ts +0 -135
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.py +0 -201
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-http-test.js +0 -357
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-inference-adapter.js +0 -196
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-server.js +0 -300
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-server.py +0 -617
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.py +0 -366
- package/examples/browser/livecards-browser/index.html +0 -41
- package/examples/browser/step-machine-browser/index.html +0 -367
- package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/.runtime-out +0 -1
- package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/board-graph.json +0 -32
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/holdings-table.json +0 -22
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +0 -43
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +0 -15
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/price-fetch.json +0 -15
- package/examples/cli/step-machine-cli/portfolio-tracker/fetch-prices.js +0 -48
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +0 -125
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +0 -32
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +0 -26
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/poll-status-cli.js +0 -49
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +0 -25
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +0 -23
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +0 -21
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +0 -38
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +0 -48
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +0 -31
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/_board_pycli.py +0 -107
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/add-cards.py +0 -51
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/init-board.py +0 -45
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/poll-status.py +0 -71
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/reset-board-dir.py +0 -36
- package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-demo.flow.yaml +0 -26
- package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-handlers.py +0 -39
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker-pycli.flow.yaml +0 -80
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +0 -76
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +0 -44
- package/examples/cli/step-machine-cli/portfolio-tracker/run-inline-python-demo-pycli.py +0 -43
- package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker-pycli.py +0 -77
- package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +0 -28
- package/examples/cli/step-machine-demo/jsonata-init-board-cli.js +0 -31
- package/examples/cli/step-machine-demo/jsonata-init-board.flow.yaml +0 -54
- package/examples/cli/step-machine-demo/one-step-cli-only.flow.yaml +0 -21
- package/examples/cli/step-machine-demo/step-cli-echo-y.js +0 -15
- package/examples/cli/step-machine-demo/step2-double-cli.js +0 -33
- package/examples/cli/step-machine-demo/two-step-math.flow.yaml +0 -93
- package/examples/cli/step-machine-demo/two-step-mixed.flow.yaml +0 -43
- package/examples/example-board/agent-instructions-cardlayout.md +0 -56
- package/examples/example-board/agent-instructions.md +0 -834
- package/examples/example-board/cards/_index.json +0 -47
- package/examples/example-board/demo-shell.html +0 -63
- package/examples/index.html +0 -785
- package/examples/npm-libs/batch/batch-step-machine.ts +0 -121
- package/examples/npm-libs/continuous-event-graph/live-cards-board.ts +0 -215
- package/examples/npm-libs/continuous-event-graph/live-portfolio-dashboard.ts +0 -555
- package/examples/npm-libs/continuous-event-graph/portfolio-tracker.ts +0 -287
- package/examples/npm-libs/continuous-event-graph/reactive-monitoring.ts +0 -265
- package/examples/npm-libs/continuous-event-graph/reactive-pipeline.ts +0 -168
- package/examples/npm-libs/continuous-event-graph/soc-incident-board.ts +0 -287
- package/examples/npm-libs/continuous-event-graph/stock-dashboard.ts +0 -229
- package/examples/npm-libs/event-graph/ci-cd-pipeline.ts +0 -243
- package/examples/npm-libs/event-graph/executor-diamond.ts +0 -165
- package/examples/npm-libs/event-graph/executor-pipeline.ts +0 -161
- package/examples/npm-libs/event-graph/research-pipeline.ts +0 -137
- package/examples/npm-libs/flows/ai-conversation.yaml +0 -116
- package/examples/npm-libs/flows/order-processing.yaml +0 -143
- package/examples/npm-libs/flows/simple-greeting.yaml +0 -54
- package/examples/npm-libs/graph-of-graphs/multi-stage-etl.ts +0 -307
- package/examples/npm-libs/graph-of-graphs/url-processing-pipeline.ts +0 -254
- package/examples/npm-libs/inference/azure-deployment.ts +0 -149
- package/examples/npm-libs/inference/copilot-cli.ts +0 -138
- package/examples/npm-libs/inference/data-pipeline.ts +0 -145
- package/examples/npm-libs/inference/pluggable-adapters.ts +0 -254
- package/examples/npm-libs/node/ai-conversation.ts +0 -195
- package/examples/npm-libs/node/simple-greeting.ts +0 -101
- package/examples/step-machine-cli/portfolio-tracker/cards/holdings-table.json +0 -22
- package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +0 -43
- package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +0 -15
- package/examples/step-machine-cli/portfolio-tracker/cards/price-fetch.json +0 -15
- package/examples/step-machine-cli/portfolio-tracker/fetch-prices.js +0 -48
- package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +0 -57
- package/examples/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +0 -27
- package/examples/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +0 -25
- package/examples/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +0 -29
- package/examples/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +0 -27
- package/examples/step-machine-cli/portfolio-tracker/handlers/status-cli.js +0 -25
- package/examples/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +0 -37
- package/examples/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +0 -53
- package/examples/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +0 -35
- package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker-task-executor.cjs +0 -96
- package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +0 -227
- package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +0 -38
- package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +0 -28
- package/step-machine-cli.js +0 -407
- /package/{dist/board-livegraph-runtime → cli/browser-api}/jsonata-sync.cjs +0 -0
- /package/{dist/cli → cli}/node/artifacts-store-cli.d.ts +0 -0
- /package/{dist/cli/node/source-cli-task-executor.d.cts → cli/node/batch-runner-cli.d.ts} +0 -0
- /package/{dist/cli → cli}/node/board-live-cards-cli.d.ts +0 -0
- /package/{dist/cli → cli}/node/card-store-cli.d.ts +0 -0
- /package/{dist/card-compute → cli/node}/jsonata-sync.cjs +0 -0
- /package/{dist/cli → cli}/node/source-cli-task-executor.d.ts +0 -0
- /package/examples/{example-board → board}/cards/card-concentration.json +0 -0
- /package/examples/{example-board → board}/cards/card-my-identity.json +0 -0
- /package/examples/{example-board → board}/cards/card-portfolio-action.json +0 -0
- /package/examples/{example-board → board}/cards/card-portfolio-intelligence.json +0 -0
- /package/examples/{example-board → board}/cards/card-portfolio-risks.json +0 -0
- /package/examples/{example-board → board}/cards/card-rebalance-impact.json +0 -0
- /package/examples/{example-board → board}/cards/card-rebalance-sim.json +0 -0
- /package/examples/{example-board/cards/card-portfolio-value.json → board/cards/cardT-portfolio-value.json} +0 -0
- /package/examples/{example-board → board}/demo-chat-handler.js +0 -0
- /package/examples/{example-board → board}/scripts/copilot_wrapper.bat +0 -0
- /package/examples/{example-board → board}/scripts/copilot_wrapper_helper.ps1 +0 -0
- /package/examples/{example-board → board}/scripts/workiq_wrapper.mjs +0 -0
- /package/examples/{browser/boards/portfolio-tracker → board/test}/portfolio-tracker-sse-worker.js +0 -0
- /package/{dist → lib}/batch/index.cjs +0 -0
- /package/{dist → lib}/batch/index.d.cts +0 -0
- /package/{dist → lib}/batch/index.d.ts +0 -0
- /package/{dist → lib}/batch/index.js +0 -0
- /package/{dist/cli/browser-api → lib/board-livegraph-runtime}/jsonata-sync.cjs +0 -0
- /package/{dist → lib}/card-compute/index.d.cts +0 -0
- /package/{dist → lib}/card-compute/index.d.ts +0 -0
- /package/{dist/cli/node → lib/card-compute}/jsonata-sync.cjs +0 -0
- /package/{dist → lib}/config/index.cjs +0 -0
- /package/{dist → lib}/config/index.d.cts +0 -0
- /package/{dist → lib}/config/index.d.ts +0 -0
- /package/{dist → lib}/config/index.js +0 -0
- /package/{dist → lib}/continuous-event-graph/jsonata-sync.cjs +0 -0
- /package/{dist → lib}/event-graph/index.cjs +0 -0
- /package/{dist → lib}/event-graph/index.js +0 -0
- /package/{dist → lib}/jsonata-sync.cjs +0 -0
- /package/{dist → lib}/server-runtime/jsonata-sync.cjs +0 -0
- /package/{dist → lib}/step-machine/index.cjs +0 -0
- /package/{dist → lib}/step-machine/index.js +0 -0
- /package/{dist → lib}/step-machine-public/jsonata-sync.cjs +0 -0
- /package/{dist → lib}/stores/memory.cjs +0 -0
- /package/{dist → lib}/stores/memory.js +0 -0
- /package/{dist → lib}/types-BBhqYGhE.d.cts +0 -0
- /package/{dist → lib}/types-BBhqYGhE.d.ts +0 -0
- /package/{dist → lib}/validate-BAVzUJWa.d.ts +0 -0
- /package/{dist → lib}/validate-Dbu7ygys.d.cts +0 -0
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var module$1=require('module');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;var $=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))),d=$("./jsonata-sync.cjs");function y(r,e){if(!r||typeof r!="object")throw new Error(`[step-machine-public] Step "${e}" returned a non-object result.`);let o=r,n=o.result??o.status;if(typeof n=="string"&&n.trim().length>0){let s=o.data&&typeof o.data=="object"&&!Array.isArray(o.data)?{...o.data}:{},a=typeof o.error=="string"?o.error:void 0;return a&&!("error"in s)&&(s.error=a),{result:n,data:s,...a?{error:a}:{}}}return {result:"success",data:{...o}}}function w(r,e){if(!e||e.length===0)return r;let o={};for(let n of e)Object.prototype.hasOwnProperty.call(r,n)&&(o[n]=r[n]);return o}function g(r,e){return async(o,n)=>{let s=await r(o,n),a=y(s,n?.stepName??"unknown");return {result:a.result,data:w(a.data,e),...a.error?{error:a.error}:{}}}}function S(r,e,o){if(!e||e.length===0)return null;for(let n of e)try{if(!d(n).evaluate(r))return {result:"failure",data:{error:`[${o}] input validation failed: ${n}`}}}catch(s){let a=s instanceof Error?s.message:String(s);return {result:"failure",data:{error:`[${o}] input validation error on "${n}": ${a}`}}}return null}function m(r,e,o){return !e||e.length===0?r:async(n,s)=>{let a=S(n,e,o);return a||r(n,s)}}var R=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));function O(){try{return R("./jsonata-sync.cjs")}catch{return R("../../card-compute/jsonata-sync.cjs")}}var f=O();function x(r,e,o){if(!r||typeof r!="object")return e;let n={output:e},s=e.result,a=e.data,i=e.error;if(typeof r.resultExpr=="string")try{let t=f(r.resultExpr).evaluate(n);if(typeof t!="string"||!t.trim())throw new Error(`resultExpr did not produce a non-empty string (got ${JSON.stringify(t)})`);s=t;}catch(t){let u=t instanceof Error?t.message:String(t);throw new Error(`[${o}] outputTransforms.resultExpr failed: ${u}`)}if(typeof r.dataTemplate=="string")try{let t=f(r.dataTemplate).evaluate(n);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`dataTemplate did not produce an object (got ${JSON.stringify(t)})`);a=t;}catch(t){let u=t instanceof Error?t.message:String(t);throw new Error(`[${o}] outputTransforms.dataTemplate failed: ${u}`)}if(typeof r.errorExpr=="string")try{let t=f(r.errorExpr).evaluate(n);i=t!=null?String(t):void 0;}catch(t){let u=t instanceof Error?t.message:String(t);throw new Error(`[${o}] outputTransforms.errorExpr failed: ${u}`)}return i!==void 0?{result:s,data:a,error:i}:{result:s,data:a}}function h(r){return !!r&&typeof r=="object"&&r.type==="compute-jsonata"&&Array.isArray(r.expr)&&r.expr.length>0}function k(r){if(!r||typeof r!="object")return false;let e=r;return e.type==="ref"&&typeof e.howToRun=="string"&&typeof e.whatToRun=="string"}function F(r){if(typeof r=="string"){let e=r.indexOf("=");if(e<1)throw new Error(`[step-machine-public] Invalid compute expression (missing "="): "${r}"`);return {bindTo:r.slice(0,e).trim(),expr:r.slice(e+1).trim()}}if(r&&typeof r=="object"&&typeof r.bindTo=="string"&&typeof r.expr=="string")return r;throw new Error(`[step-machine-public] Invalid compute step: ${JSON.stringify(r)}`)}function J(r,e,o){let n=e.split("."),s=r;for(let a=0;a<n.length-1;a++){let i=n[a];(s[i]==null||typeof s[i]!="object")&&(s[i]={}),s=s[i];}s[n[n.length-1]]=o;}function H(r,e,o){let n=r.expr.map(F);return async s=>{let a=s&&typeof s=="object"&&!Array.isArray(s)?{...s}:{},i={},t={expects_data:a,data:i,...o?{config:o}:{}},u,l;for(let p of n)try{let c=d(p.expr).evaluate(t);if(p.bindTo==="result")u=c!=null?String(c):"success";else if(p.bindTo==="error")l=c!=null?String(c):void 0;else if(p.bindTo.startsWith("data."))J(i,p.bindTo.slice(5),c);else return {result:"failure",data:{},error:`[${e}] invalid bindTo "${p.bindTo}": must be "result", "error", or start with "data."`}}catch(c){let E=c instanceof Error?c.message:String(c);return {result:"failure",data:{},error:`[${e}] compute "${p.bindTo}" failed: ${E}`}}return u===void 0?{result:"failure",data:{},error:`[${e}] compute-jsonata: no "result" binding declared \u2014 add '- result = "success"' to expr`}:l?{result:u,data:i,error:l}:{result:u,data:i}}}function b(r,e,o,n){let{type:s,...a}=r,i=a;return async t=>{let u=t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{};n&&(u.config=n);try{let l=await o(i,u);if(!r.outputTransforms)return l;try{return x(r.outputTransforms,l,e)}catch(p){let c=p instanceof Error?p.message:String(p);return {result:"failure",data:{},error:c}}}catch(l){let p=l instanceof Error?l.message:String(l);return {result:"failure",data:{error:`[step-machine-public] step "${e}" invoke threw: ${p}`}}}}}function j(){return async r=>({result:"success",data:r&&typeof r=="object"&&!Array.isArray(r)?r:{}})}function v(r,e,o){let n=Array.isArray(e?.produces_data)?e?.produces_data:void 0,s=Array.isArray(e?.input_validations)?e?.input_validations:void 0,a=e?.config??void 0,i=e?.handler,t;return h(i)?t=H(i,r,a):k(i)?t=b(i,r,o.invoke,a):t=j(),m(g(t,n),s,r)}function z(r,e){let o={};for(let[n,s]of Object.entries(r.steps??{}))o[n]=v(n,s,e);return o}exports.buildStepHandlersForFlow=z;exports.createComputeJsonataHandler=H;exports.createPassthroughHandler=j;exports.createRefStepHandler=b;exports.filterProducedData=w;exports.isComputeJsonataSpec=h;exports.isRefSpec=k;exports.jsonata=d;exports.normalizeHandlerResult=y;exports.resolveStepHandler=v;exports.runInputValidations=S;exports.wrapWithInputValidations=m;exports.wrapWithOutputFiltering=g;//# sourceMappingURL=index.cjs.map
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/step-machine-public/jsonata-loader.ts","../../src/step-machine-public/result-utils.ts","../../src/cli/common/jsonata-loader.ts","../../src/cli/common/args-massaging.ts","../../src/step-machine-public/handler-factory.ts"],"names":["_require","createRequire","jsonata","normalizeHandlerResult","raw","stepName","obj","result","data","error","filterProducedData","produces","filtered","key","wrapWithOutputFiltering","handler","input","context","normalized","runInputValidations","validations","expr","err","msg","wrapWithInputValidations","failure","_loadJsonata","resolveOutputTransforms","transforms","label","ctx","val","isComputeJsonataSpec","spec","isRefSpec","s","normalizeComputeStep","item","eq","deepSet","path","value","parts","cur","i","k","createComputeJsonataHandler","config","steps","expects_data","transitionResult","transitionError","step","createRefStepHandler","invoke","_t","refOnly","ref","stepInput","createPassthroughHandler","resolveStepHandler","stepConfig","options","inputValidations","base","buildStepHandlersForFlow","flow","handlers"],"mappings":"iIAeA,IAAMA,CAAAA,CAAWC,sBAAAA,CAAc,2PAAe,CAAA,CAMjCC,CAAAA,CAA+CF,CAAAA,CAAS,oBAAoB,ECHlF,SAASG,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACyB,CACzB,GAAI,CAACD,CAAAA,EAAO,OAAOA,CAAAA,EAAQ,QAAA,CACzB,MAAM,IAAI,KAAA,CAAM,CAAA,4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EAAMrD,CAAQ,CAAA,CACtCoD,CAAAA,CACA1D,CACF,CACF,CAUO,SAAS4D,CAAAA,CACdC,EACAJ,CAAAA,CAC6B,CAC7B,IAAMK,CAAAA,CAAwC,EAAC,CAC/C,IAAA,GAAW,CAAC9D,EAAUwD,CAAU,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQK,CAAAA,CAAK,KAAA,EAAS,EAAE,EAClEC,CAAAA,CAAS9D,CAAQ,CAAA,CAAIuD,CAAAA,CAAmBvD,CAAAA,CAAUwD,CAAAA,CAAYC,CAAO,CAAA,CAEvE,OAAOK,CACT","file":"index.cjs","sourcesContent":["/**\n * step-machine-public — jsonata loader\n *\n * Synchronous jsonata wrapper. Mirrors the loader pattern in\n * src/card-compute/index.ts — uses createRequire to load the vendored\n * synchronous CommonJS build.\n *\n * Runtime portability:\n * - Node ESM: createRequire works.\n * - Browser/cloud: package this lib for that runtime; the consumer ships\n * jsonata-sync.cjs alongside (tsup post-build does this automatically).\n */\n\nimport { createRequire } from 'module';\n\nconst _require = createRequire(import.meta.url);\n\nexport type JsonataExpression = {\n evaluate: (data: unknown) => unknown;\n};\n\nexport const jsonata: (expr: string) => JsonataExpression = _require('./jsonata-sync.cjs');\n","/**\n * step-machine-public — result utilities\n *\n * Pure helpers that:\n * - Normalize handler return shapes into NormalizedHandlerResult.\n * - Filter `data` to the keys declared in `produces_data`.\n * - Wrap a handler with output filtering / input validation.\n *\n * No transport, no I/O — only object reshaping.\n */\n\nimport type { NormalizedHandlerResult, StepHandler } from './types.js';\nimport { jsonata } from './jsonata-loader.js';\n\n// ============================================================================\n// normalizeHandlerResult — accept legacy or strict shape\n// ============================================================================\n\nexport function normalizeHandlerResult(\n raw: unknown,\n stepName: string,\n): NormalizedHandlerResult {\n if (!raw || typeof raw !== 'object') {\n throw new Error(`[step-machine-public] Step \"${stepName}\" returned a non-object result.`);\n }\n\n const obj = raw as Record<string, unknown>;\n const result = (obj.result ?? obj.status) as unknown;\n\n // Strict envelope: { result, data, error? }\n if (typeof result === 'string' && result.trim().length > 0) {\n const data: Record<string, unknown> =\n obj.data && typeof obj.data === 'object' && !Array.isArray(obj.data)\n ? { ...(obj.data as Record<string, unknown>) }\n : {};\n const error = typeof obj.error === 'string' ? (obj.error as string) : undefined;\n if (error && !('error' in data)) {\n data.error = error;\n }\n return { result, data, ...(error ? { error } : {}) };\n }\n\n // Bare object — treat the whole thing as data, intent = success.\n return { result: 'success', data: { ...obj } };\n}\n\n// ============================================================================\n// filterProducedData — narrow data to declared produces_data keys\n// ============================================================================\n\nexport function filterProducedData(\n data: Record<string, unknown>,\n produces: string[] | undefined,\n): Record<string, unknown> {\n if (!produces || produces.length === 0) return data;\n const filtered: Record<string, unknown> = {};\n for (const key of produces) {\n if (Object.prototype.hasOwnProperty.call(data, key)) {\n filtered[key] = data[key];\n }\n }\n return filtered;\n}\n\n// ============================================================================\n// wrapWithOutputFiltering — compose normalization + produces_data filtering\n// ============================================================================\n\nexport function wrapWithOutputFiltering(\n handler: StepHandler,\n produces: string[] | undefined,\n): StepHandler {\n return async (input, context) => {\n const raw = await handler(input, context);\n const normalized = normalizeHandlerResult(raw, context?.stepName ?? 'unknown');\n return {\n result: normalized.result,\n data: filterProducedData(normalized.data, produces),\n ...(normalized.error ? { error: normalized.error } : {}),\n };\n };\n}\n\n// ============================================================================\n// runInputValidations — evaluate validation expressions\n// ============================================================================\n\n/**\n * Evaluate each validation as a JSONata expression returning truthy.\n *\n * Returns `null` on success, or a normalized failure result on the first\n * failed/throwing validation.\n */\nexport function runInputValidations(\n input: Record<string, unknown>,\n validations: string[] | undefined,\n stepName: string,\n): NormalizedHandlerResult | null {\n if (!validations || validations.length === 0) return null;\n for (const expr of validations) {\n try {\n const ok = jsonata(expr).evaluate(input);\n if (!ok) {\n return {\n result: 'failure',\n data: { error: `[${stepName}] input validation failed: ${expr}` },\n };\n }\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n result: 'failure',\n data: { error: `[${stepName}] input validation error on \"${expr}\": ${msg}` },\n };\n }\n }\n return null;\n}\n\n// ============================================================================\n// wrapWithInputValidations — short-circuit if any validation fails\n// ============================================================================\n\nexport function wrapWithInputValidations(\n handler: StepHandler,\n validations: string[] | undefined,\n stepName: string,\n): StepHandler {\n if (!validations || validations.length === 0) return handler;\n return async (input, context) => {\n const failure = runInputValidations(input, validations, stepName);\n if (failure) return failure;\n return handler(input, context);\n };\n}\n","/**\n * cli/common/jsonata-loader — synchronous jsonata wrapper.\n *\n * Mirrors the loader pattern used by card-compute. Uses createRequire so the\n * vendored CommonJS sync build can be loaded from ESM. The canonical source\n * file is `src/card-compute/jsonata-sync.cjs`; the tsup post-build hook copies\n * it next to every dist bundle that references it.\n */\n\nimport { createRequire } from 'module';\n\nconst _require = createRequire(import.meta.url);\n\nexport type JsonataExpression = {\n evaluate: (data: unknown) => unknown;\n};\n\n// Source path resolves via the file's location at src/cli/common/.\n// Dist path resolves via the post-build copy that places jsonata-sync.cjs\n// alongside the bundled output (handled by tsup's copyJsonataSyncToDistDirs).\nfunction _loadJsonata(): (expr: string) => JsonataExpression {\n // Try sibling first (dist layout). If that fails, fall back to the canonical\n // source location (used when running TypeScript directly under vitest/tsx).\n try {\n return _require('./jsonata-sync.cjs');\n } catch {\n return _require('../../card-compute/jsonata-sync.cjs');\n }\n}\n\nexport const jsonata: (expr: string) => JsonataExpression = _loadJsonata();\n","/**\n * cli/common/args-massaging — JSONata-based mapping from logical args to\n * transport-specific shape.\n *\n * `argsMassaging` is a property of `ExecutionRef`, so honoring it is the job\n * of every adapter (Node spawn, HTTP, Azure Function, etc.). This helper is\n * the shared pure-JSONata implementation reused by all adapters.\n *\n * Adapters call this as the first step inside their `invokeRefSync` /\n * `dispatchExecution` implementation, then perform their transport using\n * `cmdArgs` / `body` / `url`.\n */\n\nimport { jsonata } from './jsonata-loader.js';\nimport type { ArgsMassaging, OutputTransforms } from './execution-interface.js';\nimport type { NormalizedHandlerResult } from '../../step-machine-public/types.js';\n\nexport interface MassagedArgs {\n /** Resolved argv tail for local transports. */\n cmdArgs?: string[];\n /** Resolved request body for http transports (or stdin payload for local). */\n body?: unknown;\n /** Resolved final URL string for http transports. */\n url?: string;\n}\n\n/**\n * Evaluate `argsMassaging` against the supplied context.\n *\n * Throws with a label-tagged message if any expression fails. Adapters\n * should catch and convert to a normalized failure result.\n */\nexport function resolveArgsMassaging(\n argsMassaging: ArgsMassaging | undefined,\n context: Record<string, unknown>,\n label: string,\n): MassagedArgs {\n if (!argsMassaging || typeof argsMassaging !== 'object') return {};\n\n const out: MassagedArgs = {};\n\n if (Array.isArray(argsMassaging.cmdTemplate)) {\n const resolved: string[] = [];\n for (const expr of argsMassaging.cmdTemplate) {\n try {\n resolved.push(String(jsonata(expr).evaluate(context)));\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(\n `[${label}] argsMassaging.cmdTemplate failed on \"${expr}\": ${msg}`,\n );\n }\n }\n out.cmdArgs = resolved;\n }\n\n if (typeof argsMassaging.bodyTemplate === 'string') {\n try {\n out.body = jsonata(argsMassaging.bodyTemplate).evaluate(context);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(\n `[${label}] argsMassaging.bodyTemplate failed: ${msg}`,\n );\n }\n }\n\n if (typeof argsMassaging.urlTemplate === 'string') {\n try {\n out.url = String(jsonata(argsMassaging.urlTemplate).evaluate(context));\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(\n `[${label}] argsMassaging.urlTemplate failed: ${msg}`,\n );\n }\n }\n\n return out;\n}\n\n/**\n * Apply `outputTransforms` to a raw invoke result.\n *\n * Context for all expressions: `{ output }` where `output` is the raw\n * { result, data, error? } envelope from invokeRefSync.\n *\n * Returns a new NormalizedHandlerResult with overrides applied.\n * Throws with a label-tagged message if any expression fails.\n */\nexport function resolveOutputTransforms(\n transforms: OutputTransforms | undefined,\n raw: NormalizedHandlerResult,\n label: string,\n): NormalizedHandlerResult {\n if (!transforms || typeof transforms !== 'object') return raw;\n\n const ctx = { output: raw };\n let result = raw.result;\n let data = raw.data;\n let error = raw.error;\n\n if (typeof transforms.resultExpr === 'string') {\n try {\n const val = jsonata(transforms.resultExpr).evaluate(ctx);\n if (typeof val !== 'string' || !val.trim()) {\n throw new Error(`resultExpr did not produce a non-empty string (got ${JSON.stringify(val)})`);\n }\n result = val;\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(`[${label}] outputTransforms.resultExpr failed: ${msg}`);\n }\n }\n\n if (typeof transforms.dataTemplate === 'string') {\n try {\n const val = jsonata(transforms.dataTemplate).evaluate(ctx);\n if (!val || typeof val !== 'object' || Array.isArray(val)) {\n throw new Error(`dataTemplate did not produce an object (got ${JSON.stringify(val)})`);\n }\n data = val as Record<string, unknown>;\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(`[${label}] outputTransforms.dataTemplate failed: ${msg}`);\n }\n }\n\n if (typeof transforms.errorExpr === 'string') {\n try {\n const val = jsonata(transforms.errorExpr).evaluate(ctx);\n // $undefined() evaluates to undefined — clears the error field\n error = val != null ? String(val) : undefined;\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(`[${label}] outputTransforms.errorExpr failed: ${msg}`);\n }\n }\n\n return error !== undefined\n ? { result, data, error }\n : { result, data };\n}\n","/**\n * step-machine-public — handler factory\n *\n * Builds engine-facing StepHandlers from declarative HandlerSpec entries.\n * Pure: no Node imports, no transport. Refs are dispatched through the\n * caller-supplied `InvokeFn`, which is the single boundary between this lib\n * and any transport (Node spawn, HTTP, Azure Function, etc.).\n *\n * Layering:\n *\n * step-machine (pure FSM) — runs handlers, never builds them.\n * step-machine-public (this lib) — declarative spec → StepHandler map.\n * adapter (e.g. node-spawn-invoker) — InvokeFn implementation per transport.\n * step-machine-cli (thin shell) — wires adapter + flow loader + run.\n */\n\nimport { jsonata } from './jsonata-loader.js';\nimport { wrapWithInputValidations, wrapWithOutputFiltering } from './result-utils.js';\nimport { resolveOutputTransforms } from '../cli/common/args-massaging.js';\nimport type {\n ComputeJsonataSpec,\n HandlerSpec,\n InvokeRefFn,\n NormalizedHandlerResult,\n RefSpec,\n StepConfigForFactory,\n StepHandler,\n} from './types.js';\n\n// ============================================================================\n// Discriminators\n// ============================================================================\n\nexport function isComputeJsonataSpec(spec: unknown): spec is ComputeJsonataSpec {\n return (\n !!spec &&\n typeof spec === 'object' &&\n (spec as Record<string, unknown>).type === 'compute-jsonata' &&\n Array.isArray((spec as Record<string, unknown>).expr) &&\n ((spec as Record<string, unknown>).expr as unknown[]).length > 0\n );\n}\n\nexport function isRefSpec(spec: unknown): spec is RefSpec {\n if (!spec || typeof spec !== 'object') return false;\n const s = spec as Record<string, unknown>;\n return (\n s.type === 'ref' &&\n typeof s.howToRun === 'string' &&\n typeof s.whatToRun === 'string'\n );\n}\n\n// ============================================================================\n// Compute-jsonata handler\n// ============================================================================\n\ninterface NormalizedComputeStep {\n bindTo: string;\n expr: string;\n}\n\nfunction normalizeComputeStep(item: string | { bindTo: string; expr: string }): NormalizedComputeStep {\n if (typeof item === 'string') {\n const eq = item.indexOf('=');\n if (eq < 1) {\n throw new Error(`[step-machine-public] Invalid compute expression (missing \"=\"): \"${item}\"`);\n }\n return { bindTo: item.slice(0, eq).trim(), expr: item.slice(eq + 1).trim() };\n }\n if (item && typeof item === 'object' && typeof item.bindTo === 'string' && typeof item.expr === 'string') {\n return item;\n }\n throw new Error(`[step-machine-public] Invalid compute step: ${JSON.stringify(item)}`);\n}\n\n/** Mutate nested dict via dot-path key. */\nfunction deepSet(obj: Record<string, unknown>, path: string, value: unknown): void {\n const parts = path.split('.');\n let cur: Record<string, unknown> = obj;\n for (let i = 0; i < parts.length - 1; i++) {\n const k = parts[i];\n if (cur[k] == null || typeof cur[k] !== 'object') cur[k] = {};\n cur = cur[k] as Record<string, unknown>;\n }\n cur[parts[parts.length - 1]] = value;\n}\n\nexport function createComputeJsonataHandler(\n spec: ComputeJsonataSpec,\n stepName: string,\n config?: Record<string, unknown>,\n): StepHandler {\n const steps = spec.expr.map(normalizeComputeStep);\n return async (input) => {\n const expects_data: Record<string, unknown> =\n input && typeof input === 'object' && !Array.isArray(input)\n ? { ...input }\n : {};\n\n // `data` accumulates computed outputs; it is placed in ctx by reference\n // so subsequent expressions can read `data.x` after earlier steps set it.\n const data: Record<string, unknown> = {};\n\n // Context shape:\n // expects_data — named namespace for declared step inputs (from flow state)\n // data — accumulating output namespace (required, mutated by reference)\n // config — optional step-level config\n const ctx: Record<string, unknown> = {\n expects_data,\n data, // same reference — mutations visible in later steps\n ...(config ? { config } : {}),\n };\n\n let transitionResult: string | undefined;\n let transitionError: string | undefined;\n\n for (const step of steps) {\n try {\n const val = jsonata(step.expr).evaluate(ctx);\n\n if (step.bindTo === 'result') {\n // Transition outcome\n transitionResult = val != null ? String(val) : 'success';\n } else if (step.bindTo === 'error') {\n // Transition error detail\n transitionError = val != null ? String(val) : undefined;\n } else if (step.bindTo.startsWith('data.')) {\n // Namespaced output — mutates the shared data reference\n deepSet(data, step.bindTo.slice('data.'.length), val);\n } else {\n return {\n result: 'failure',\n data: {},\n error: `[${stepName}] invalid bindTo \"${step.bindTo}\": must be \"result\", \"error\", or start with \"data.\"`,\n };\n }\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n result: 'failure',\n data: {},\n error: `[${stepName}] compute \"${step.bindTo}\" failed: ${msg}`,\n };\n }\n }\n\n if (transitionResult === undefined) {\n return {\n result: 'failure',\n data: {},\n error: `[${stepName}] compute-jsonata: no \"result\" binding declared — add '- result = \"success\"' to expr`,\n };\n }\n return transitionError\n ? { result: transitionResult, data, error: transitionError }\n : { result: transitionResult, data };\n };\n}\n\n// ============================================================================\n// Ref handler — dispatches via InvokeFn\n// ============================================================================\n\nexport function createRefStepHandler(\n spec: RefSpec,\n stepName: string,\n invoke: InvokeRefFn,\n config?: Record<string, unknown>,\n): StepHandler {\n // The handler spec itself is a superset of ExecutionRef. Strip the discriminator\n // before passing to the adapter so it sees a plain ExecutionRef.\n const { type: _t, ...refOnly } = spec;\n const ref = refOnly;\n\n return async (input) => {\n const stepInput: Record<string, unknown> =\n input && typeof input === 'object' && !Array.isArray(input)\n ? { ...input }\n : {};\n if (config) stepInput.config = config;\n\n try {\n const raw = await invoke(ref, stepInput);\n if (!spec.outputTransforms) return raw;\n try {\n return resolveOutputTransforms(spec.outputTransforms, raw, stepName);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n return { result: 'failure', data: {}, error: msg };\n }\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n result: 'failure',\n data: { error: `[step-machine-public] step \"${stepName}\" invoke threw: ${msg}` },\n };\n }\n };\n}\n\n// ============================================================================\n// Passthrough handler\n// ============================================================================\n\nexport function createPassthroughHandler(): StepHandler {\n return async (input) => {\n const data: Record<string, unknown> =\n input && typeof input === 'object' && !Array.isArray(input)\n ? (input as Record<string, unknown>)\n : {};\n return { result: 'success', data };\n };\n}\n\n// ============================================================================\n// resolveStepHandler — pick + decorate the right handler for a step\n// ============================================================================\n\nexport interface ResolveStepHandlerOptions {\n invoke: InvokeRefFn;\n}\n\nexport function resolveStepHandler(\n stepName: string,\n stepConfig: StepConfigForFactory | undefined,\n options: ResolveStepHandlerOptions,\n): StepHandler {\n const produces = Array.isArray(stepConfig?.produces_data) ? stepConfig?.produces_data : undefined;\n const inputValidations = Array.isArray(stepConfig?.input_validations)\n ? stepConfig?.input_validations\n : undefined;\n const config = stepConfig?.config ?? undefined;\n const spec: HandlerSpec | undefined = stepConfig?.handler;\n\n let base: StepHandler;\n if (isComputeJsonataSpec(spec)) {\n // compute-jsonata: validations are baked in via the wrapper as well; both work.\n base = createComputeJsonataHandler(spec, stepName, config);\n } else if (isRefSpec(spec)) {\n base = createRefStepHandler(spec, stepName, options.invoke, config);\n } else {\n base = createPassthroughHandler();\n }\n\n return wrapWithInputValidations(\n wrapWithOutputFiltering(base, produces),\n inputValidations,\n stepName,\n );\n}\n\n// ============================================================================\n// buildStepHandlersForFlow — produce the Record<stepName, StepHandler> map\n// ============================================================================\n\nexport interface BuildStepHandlersOptions {\n invoke: InvokeRefFn;\n}\n\nexport function buildStepHandlersForFlow(\n flow: { steps?: Record<string, StepConfigForFactory> },\n options: BuildStepHandlersOptions,\n): Record<string, StepHandler> {\n const handlers: Record<string, StepHandler> = {};\n for (const [stepName, stepConfig] of Object.entries(flow.steps ?? {})) {\n handlers[stepName] = resolveStepHandler(stepName, stepConfig, options);\n }\n return handlers;\n}\n\n// Re-export for adapter convenience.\nexport type { NormalizedHandlerResult };\n"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {createRequire}from'module';var $=createRequire(import.meta.url),d=$("./jsonata-sync.cjs");function y(r,e){if(!r||typeof r!="object")throw new Error(`[step-machine-public] Step "${e}" returned a non-object result.`);let o=r,n=o.result??o.status;if(typeof n=="string"&&n.trim().length>0){let s=o.data&&typeof o.data=="object"&&!Array.isArray(o.data)?{...o.data}:{},a=typeof o.error=="string"?o.error:void 0;return a&&!("error"in s)&&(s.error=a),{result:n,data:s,...a?{error:a}:{}}}return {result:"success",data:{...o}}}function w(r,e){if(!e||e.length===0)return r;let o={};for(let n of e)Object.prototype.hasOwnProperty.call(r,n)&&(o[n]=r[n]);return o}function g(r,e){return async(o,n)=>{let s=await r(o,n),a=y(s,n?.stepName??"unknown");return {result:a.result,data:w(a.data,e),...a.error?{error:a.error}:{}}}}function S(r,e,o){if(!e||e.length===0)return null;for(let n of e)try{if(!d(n).evaluate(r))return {result:"failure",data:{error:`[${o}] input validation failed: ${n}`}}}catch(s){let a=s instanceof Error?s.message:String(s);return {result:"failure",data:{error:`[${o}] input validation error on "${n}": ${a}`}}}return null}function m(r,e,o){return !e||e.length===0?r:async(n,s)=>{let a=S(n,e,o);return a||r(n,s)}}var R=createRequire(import.meta.url);function O(){try{return R("./jsonata-sync.cjs")}catch{return R("../../card-compute/jsonata-sync.cjs")}}var f=O();function x(r,e,o){if(!r||typeof r!="object")return e;let n={output:e},s=e.result,a=e.data,i=e.error;if(typeof r.resultExpr=="string")try{let t=f(r.resultExpr).evaluate(n);if(typeof t!="string"||!t.trim())throw new Error(`resultExpr did not produce a non-empty string (got ${JSON.stringify(t)})`);s=t;}catch(t){let u=t instanceof Error?t.message:String(t);throw new Error(`[${o}] outputTransforms.resultExpr failed: ${u}`)}if(typeof r.dataTemplate=="string")try{let t=f(r.dataTemplate).evaluate(n);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`dataTemplate did not produce an object (got ${JSON.stringify(t)})`);a=t;}catch(t){let u=t instanceof Error?t.message:String(t);throw new Error(`[${o}] outputTransforms.dataTemplate failed: ${u}`)}if(typeof r.errorExpr=="string")try{let t=f(r.errorExpr).evaluate(n);i=t!=null?String(t):void 0;}catch(t){let u=t instanceof Error?t.message:String(t);throw new Error(`[${o}] outputTransforms.errorExpr failed: ${u}`)}return i!==void 0?{result:s,data:a,error:i}:{result:s,data:a}}function h(r){return !!r&&typeof r=="object"&&r.type==="compute-jsonata"&&Array.isArray(r.expr)&&r.expr.length>0}function k(r){if(!r||typeof r!="object")return false;let e=r;return e.type==="ref"&&typeof e.howToRun=="string"&&typeof e.whatToRun=="string"}function F(r){if(typeof r=="string"){let e=r.indexOf("=");if(e<1)throw new Error(`[step-machine-public] Invalid compute expression (missing "="): "${r}"`);return {bindTo:r.slice(0,e).trim(),expr:r.slice(e+1).trim()}}if(r&&typeof r=="object"&&typeof r.bindTo=="string"&&typeof r.expr=="string")return r;throw new Error(`[step-machine-public] Invalid compute step: ${JSON.stringify(r)}`)}function J(r,e,o){let n=e.split("."),s=r;for(let a=0;a<n.length-1;a++){let i=n[a];(s[i]==null||typeof s[i]!="object")&&(s[i]={}),s=s[i];}s[n[n.length-1]]=o;}function H(r,e,o){let n=r.expr.map(F);return async s=>{let a=s&&typeof s=="object"&&!Array.isArray(s)?{...s}:{},i={},t={expects_data:a,data:i,...o?{config:o}:{}},u,l;for(let p of n)try{let c=d(p.expr).evaluate(t);if(p.bindTo==="result")u=c!=null?String(c):"success";else if(p.bindTo==="error")l=c!=null?String(c):void 0;else if(p.bindTo.startsWith("data."))J(i,p.bindTo.slice(5),c);else return {result:"failure",data:{},error:`[${e}] invalid bindTo "${p.bindTo}": must be "result", "error", or start with "data."`}}catch(c){let E=c instanceof Error?c.message:String(c);return {result:"failure",data:{},error:`[${e}] compute "${p.bindTo}" failed: ${E}`}}return u===void 0?{result:"failure",data:{},error:`[${e}] compute-jsonata: no "result" binding declared \u2014 add '- result = "success"' to expr`}:l?{result:u,data:i,error:l}:{result:u,data:i}}}function b(r,e,o,n){let{type:s,...a}=r,i=a;return async t=>{let u=t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{};n&&(u.config=n);try{let l=await o(i,u);if(!r.outputTransforms)return l;try{return x(r.outputTransforms,l,e)}catch(p){let c=p instanceof Error?p.message:String(p);return {result:"failure",data:{},error:c}}}catch(l){let p=l instanceof Error?l.message:String(l);return {result:"failure",data:{error:`[step-machine-public] step "${e}" invoke threw: ${p}`}}}}}function j(){return async r=>({result:"success",data:r&&typeof r=="object"&&!Array.isArray(r)?r:{}})}function v(r,e,o){let n=Array.isArray(e?.produces_data)?e?.produces_data:void 0,s=Array.isArray(e?.input_validations)?e?.input_validations:void 0,a=e?.config??void 0,i=e?.handler,t;return h(i)?t=H(i,r,a):k(i)?t=b(i,r,o.invoke,a):t=j(),m(g(t,n),s,r)}function z(r,e){let o={};for(let[n,s]of Object.entries(r.steps??{}))o[n]=v(n,s,e);return o}export{z as buildStepHandlersForFlow,H as createComputeJsonataHandler,j as createPassthroughHandler,b as createRefStepHandler,w as filterProducedData,h as isComputeJsonataSpec,k as isRefSpec,d as jsonata,y as normalizeHandlerResult,v as resolveStepHandler,S as runInputValidations,m as wrapWithInputValidations,g as wrapWithOutputFiltering};//# sourceMappingURL=index.js.map
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/step-machine-public/jsonata-loader.ts","../../src/step-machine-public/result-utils.ts","../../src/cli/common/jsonata-loader.ts","../../src/cli/common/args-massaging.ts","../../src/step-machine-public/handler-factory.ts"],"names":["_require","createRequire","jsonata","normalizeHandlerResult","raw","stepName","obj","result","data","error","filterProducedData","produces","filtered","key","wrapWithOutputFiltering","handler","input","context","normalized","runInputValidations","validations","expr","err","msg","wrapWithInputValidations","failure","_loadJsonata","resolveOutputTransforms","transforms","label","ctx","val","isComputeJsonataSpec","spec","isRefSpec","s","normalizeComputeStep","item","eq","deepSet","path","value","parts","cur","i","k","createComputeJsonataHandler","config","steps","expects_data","transitionResult","transitionError","step","createRefStepHandler","invoke","_t","refOnly","ref","stepInput","createPassthroughHandler","resolveStepHandler","stepConfig","options","inputValidations","base","buildStepHandlersForFlow","flow","handlers"],"mappings":"mCAeA,IAAMA,CAAAA,CAAWC,aAAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA,CAMjCC,CAAAA,CAA+CF,CAAAA,CAAS,oBAAoB,ECHlF,SAASG,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACyB,CACzB,GAAI,CAACD,CAAAA,EAAO,OAAOA,CAAAA,EAAQ,QAAA,CACzB,MAAM,IAAI,KAAA,CAAM,CAAA,4BAAA,EAA+BC,CAAQ,CAAA,+BAAA,CAAiC,EAG1F,IAAMC,CAAAA,CAAMF,CAAAA,CACNG,CAAAA,CAAUD,CAAAA,CAAI,MAAA,EAAUA,CAAAA,CAAI,MAAA,CAGlC,GAAI,OAAOC,CAAAA,EAAW,QAAA,EAAYA,CAAAA,CAAO,IAAA,EAAK,CAAE,MAAA,CAAS,CAAA,CAAG,CAC1D,IAAMC,CAAAA,CACJF,CAAAA,CAAI,IAAA,EAAQ,OAAOA,CAAAA,CAAI,IAAA,EAAS,QAAA,EAAY,CAAC,KAAA,CAAM,OAAA,CAAQA,CAAAA,CAAI,IAAI,CAAA,CAC/D,CAAE,GAAIA,CAAAA,CAAI,IAAiC,CAAA,CAC3C,E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Mirrors the loader pattern in\n * src/card-compute/index.ts — uses createRequire to load the vendored\n * synchronous CommonJS build.\n *\n * Runtime portability:\n * - Node ESM: createRequire works.\n * - Browser/cloud: package this lib for that runtime; the consumer ships\n * jsonata-sync.cjs alongside (tsup post-build does this automatically).\n */\n\nimport { createRequire } from 'module';\n\nconst _require = createRequire(import.meta.url);\n\nexport type JsonataExpression = {\n evaluate: (data: unknown) => unknown;\n};\n\nexport const jsonata: (expr: string) => JsonataExpression = _require('./jsonata-sync.cjs');\n","/**\n * step-machine-public — result utilities\n *\n * Pure helpers that:\n * - Normalize handler return shapes into NormalizedHandlerResult.\n * - Filter `data` to the keys declared in `produces_data`.\n * - Wrap a handler with output filtering / input validation.\n *\n * No transport, no I/O — only object reshaping.\n */\n\nimport type { NormalizedHandlerResult, StepHandler } from './types.js';\nimport { jsonata } from './jsonata-loader.js';\n\n// ============================================================================\n// normalizeHandlerResult — accept legacy or strict shape\n// ============================================================================\n\nexport function normalizeHandlerResult(\n raw: unknown,\n stepName: string,\n): NormalizedHandlerResult {\n if (!raw || typeof raw !== 'object') {\n throw new Error(`[step-machine-public] Step \"${stepName}\" returned a non-object result.`);\n }\n\n const obj = raw as Record<string, unknown>;\n const result = (obj.result ?? obj.status) as unknown;\n\n // Strict envelope: { result, data, error? }\n if (typeof result === 'string' && result.trim().length > 0) {\n const data: Record<string, unknown> =\n obj.data && typeof obj.data === 'object' && !Array.isArray(obj.data)\n ? { ...(obj.data as Record<string, unknown>) }\n : {};\n const error = typeof obj.error === 'string' ? (obj.error as string) : undefined;\n if (error && !('error' in data)) {\n data.error = error;\n }\n return { result, data, ...(error ? { error } : {}) };\n }\n\n // Bare object — treat the whole thing as data, intent = success.\n return { result: 'success', data: { ...obj } };\n}\n\n// ============================================================================\n// filterProducedData — narrow data to declared produces_data keys\n// ============================================================================\n\nexport function filterProducedData(\n data: Record<string, unknown>,\n produces: string[] | undefined,\n): Record<string, unknown> {\n if (!produces || produces.length === 0) return data;\n const filtered: Record<string, unknown> = {};\n for (const key of produces) {\n if (Object.prototype.hasOwnProperty.call(data, key)) {\n filtered[key] = data[key];\n }\n }\n return filtered;\n}\n\n// ============================================================================\n// wrapWithOutputFiltering — compose normalization + produces_data filtering\n// ============================================================================\n\nexport function wrapWithOutputFiltering(\n handler: StepHandler,\n produces: string[] | undefined,\n): StepHandler {\n return async (input, context) => {\n const raw = await handler(input, context);\n const normalized = normalizeHandlerResult(raw, context?.stepName ?? 'unknown');\n return {\n result: normalized.result,\n data: filterProducedData(normalized.data, produces),\n ...(normalized.error ? { error: normalized.error } : {}),\n };\n };\n}\n\n// ============================================================================\n// runInputValidations — evaluate validation expressions\n// ============================================================================\n\n/**\n * Evaluate each validation as a JSONata expression returning truthy.\n *\n * Returns `null` on success, or a normalized failure result on the first\n * failed/throwing validation.\n */\nexport function runInputValidations(\n input: Record<string, unknown>,\n validations: string[] | undefined,\n stepName: string,\n): NormalizedHandlerResult | null {\n if (!validations || validations.length === 0) return null;\n for (const expr of validations) {\n try {\n const ok = jsonata(expr).evaluate(input);\n if (!ok) {\n return {\n result: 'failure',\n data: { error: `[${stepName}] input validation failed: ${expr}` },\n };\n }\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n result: 'failure',\n data: { error: `[${stepName}] input validation error on \"${expr}\": ${msg}` },\n };\n }\n }\n return null;\n}\n\n// ============================================================================\n// wrapWithInputValidations — short-circuit if any validation fails\n// ============================================================================\n\nexport function wrapWithInputValidations(\n handler: StepHandler,\n validations: string[] | undefined,\n stepName: string,\n): StepHandler {\n if (!validations || validations.length === 0) return handler;\n return async (input, context) => {\n const failure = runInputValidations(input, validations, stepName);\n if (failure) return failure;\n return handler(input, context);\n };\n}\n","/**\n * cli/common/jsonata-loader — synchronous jsonata wrapper.\n *\n * Mirrors the loader pattern used by card-compute. Uses createRequire so the\n * vendored CommonJS sync build can be loaded from ESM. The canonical source\n * file is `src/card-compute/jsonata-sync.cjs`; the tsup post-build hook copies\n * it next to every dist bundle that references it.\n */\n\nimport { createRequire } from 'module';\n\nconst _require = createRequire(import.meta.url);\n\nexport type JsonataExpression = {\n evaluate: (data: unknown) => unknown;\n};\n\n// Source path resolves via the file's location at src/cli/common/.\n// Dist path resolves via the post-build copy that places jsonata-sync.cjs\n// alongside the bundled output (handled by tsup's copyJsonataSyncToDistDirs).\nfunction _loadJsonata(): (expr: string) => JsonataExpression {\n // Try sibling first (dist layout). If that fails, fall back to the canonical\n // source location (used when running TypeScript directly under vitest/tsx).\n try {\n return _require('./jsonata-sync.cjs');\n } catch {\n return _require('../../card-compute/jsonata-sync.cjs');\n }\n}\n\nexport const jsonata: (expr: string) => JsonataExpression = _loadJsonata();\n","/**\n * cli/common/args-massaging — JSONata-based mapping from logical args to\n * transport-specific shape.\n *\n * `argsMassaging` is a property of `ExecutionRef`, so honoring it is the job\n * of every adapter (Node spawn, HTTP, Azure Function, etc.). This helper is\n * the shared pure-JSONata implementation reused by all adapters.\n *\n * Adapters call this as the first step inside their `invokeRefSync` /\n * `dispatchExecution` implementation, then perform their transport using\n * `cmdArgs` / `body` / `url`.\n */\n\nimport { jsonata } from './jsonata-loader.js';\nimport type { ArgsMassaging, OutputTransforms } from './execution-interface.js';\nimport type { NormalizedHandlerResult } from '../../step-machine-public/types.js';\n\nexport interface MassagedArgs {\n /** Resolved argv tail for local transports. */\n cmdArgs?: string[];\n /** Resolved request body for http transports (or stdin payload for local). */\n body?: unknown;\n /** Resolved final URL string for http transports. */\n url?: string;\n}\n\n/**\n * Evaluate `argsMassaging` against the supplied context.\n *\n * Throws with a label-tagged message if any expression fails. Adapters\n * should catch and convert to a normalized failure result.\n */\nexport function resolveArgsMassaging(\n argsMassaging: ArgsMassaging | undefined,\n context: Record<string, unknown>,\n label: string,\n): MassagedArgs {\n if (!argsMassaging || typeof argsMassaging !== 'object') return {};\n\n const out: MassagedArgs = {};\n\n if (Array.isArray(argsMassaging.cmdTemplate)) {\n const resolved: string[] = [];\n for (const expr of argsMassaging.cmdTemplate) {\n try {\n resolved.push(String(jsonata(expr).evaluate(context)));\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(\n `[${label}] argsMassaging.cmdTemplate failed on \"${expr}\": ${msg}`,\n );\n }\n }\n out.cmdArgs = resolved;\n }\n\n if (typeof argsMassaging.bodyTemplate === 'string') {\n try {\n out.body = jsonata(argsMassaging.bodyTemplate).evaluate(context);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(\n `[${label}] argsMassaging.bodyTemplate failed: ${msg}`,\n );\n }\n }\n\n if (typeof argsMassaging.urlTemplate === 'string') {\n try {\n out.url = String(jsonata(argsMassaging.urlTemplate).evaluate(context));\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(\n `[${label}] argsMassaging.urlTemplate failed: ${msg}`,\n );\n }\n }\n\n return out;\n}\n\n/**\n * Apply `outputTransforms` to a raw invoke result.\n *\n * Context for all expressions: `{ output }` where `output` is the raw\n * { result, data, error? } envelope from invokeRefSync.\n *\n * Returns a new NormalizedHandlerResult with overrides applied.\n * Throws with a label-tagged message if any expression fails.\n */\nexport function resolveOutputTransforms(\n transforms: OutputTransforms | undefined,\n raw: NormalizedHandlerResult,\n label: string,\n): NormalizedHandlerResult {\n if (!transforms || typeof transforms !== 'object') return raw;\n\n const ctx = { output: raw };\n let result = raw.result;\n let data = raw.data;\n let error = raw.error;\n\n if (typeof transforms.resultExpr === 'string') {\n try {\n const val = jsonata(transforms.resultExpr).evaluate(ctx);\n if (typeof val !== 'string' || !val.trim()) {\n throw new Error(`resultExpr did not produce a non-empty string (got ${JSON.stringify(val)})`);\n }\n result = val;\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(`[${label}] outputTransforms.resultExpr failed: ${msg}`);\n }\n }\n\n if (typeof transforms.dataTemplate === 'string') {\n try {\n const val = jsonata(transforms.dataTemplate).evaluate(ctx);\n if (!val || typeof val !== 'object' || Array.isArray(val)) {\n throw new Error(`dataTemplate did not produce an object (got ${JSON.stringify(val)})`);\n }\n data = val as Record<string, unknown>;\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(`[${label}] outputTransforms.dataTemplate failed: ${msg}`);\n }\n }\n\n if (typeof transforms.errorExpr === 'string') {\n try {\n const val = jsonata(transforms.errorExpr).evaluate(ctx);\n // $undefined() evaluates to undefined — clears the error field\n error = val != null ? String(val) : undefined;\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(`[${label}] outputTransforms.errorExpr failed: ${msg}`);\n }\n }\n\n return error !== undefined\n ? { result, data, error }\n : { result, data };\n}\n","/**\n * step-machine-public — handler factory\n *\n * Builds engine-facing StepHandlers from declarative HandlerSpec entries.\n * Pure: no Node imports, no transport. Refs are dispatched through the\n * caller-supplied `InvokeFn`, which is the single boundary between this lib\n * and any transport (Node spawn, HTTP, Azure Function, etc.).\n *\n * Layering:\n *\n * step-machine (pure FSM) — runs handlers, never builds them.\n * step-machine-public (this lib) — declarative spec → StepHandler map.\n * adapter (e.g. node-spawn-invoker) — InvokeFn implementation per transport.\n * step-machine-cli (thin shell) — wires adapter + flow loader + run.\n */\n\nimport { jsonata } from './jsonata-loader.js';\nimport { wrapWithInputValidations, wrapWithOutputFiltering } from './result-utils.js';\nimport { resolveOutputTransforms } from '../cli/common/args-massaging.js';\nimport type {\n ComputeJsonataSpec,\n HandlerSpec,\n InvokeRefFn,\n NormalizedHandlerResult,\n RefSpec,\n StepConfigForFactory,\n StepHandler,\n} from './types.js';\n\n// ============================================================================\n// Discriminators\n// ============================================================================\n\nexport function isComputeJsonataSpec(spec: unknown): spec is ComputeJsonataSpec {\n return (\n !!spec &&\n typeof spec === 'object' &&\n (spec as Record<string, unknown>).type === 'compute-jsonata' &&\n Array.isArray((spec as Record<string, unknown>).expr) &&\n ((spec as Record<string, unknown>).expr as unknown[]).length > 0\n );\n}\n\nexport function isRefSpec(spec: unknown): spec is RefSpec {\n if (!spec || typeof spec !== 'object') return false;\n const s = spec as Record<string, unknown>;\n return (\n s.type === 'ref' &&\n typeof s.howToRun === 'string' &&\n typeof s.whatToRun === 'string'\n );\n}\n\n// ============================================================================\n// Compute-jsonata handler\n// ============================================================================\n\ninterface NormalizedComputeStep {\n bindTo: string;\n expr: string;\n}\n\nfunction normalizeComputeStep(item: string | { bindTo: string; expr: string }): NormalizedComputeStep {\n if (typeof item === 'string') {\n const eq = item.indexOf('=');\n if (eq < 1) {\n throw new Error(`[step-machine-public] Invalid compute expression (missing \"=\"): \"${item}\"`);\n }\n return { bindTo: item.slice(0, eq).trim(), expr: item.slice(eq + 1).trim() };\n }\n if (item && typeof item === 'object' && typeof item.bindTo === 'string' && typeof item.expr === 'string') {\n return item;\n }\n throw new Error(`[step-machine-public] Invalid compute step: ${JSON.stringify(item)}`);\n}\n\n/** Mutate nested dict via dot-path key. */\nfunction deepSet(obj: Record<string, unknown>, path: string, value: unknown): void {\n const parts = path.split('.');\n let cur: Record<string, unknown> = obj;\n for (let i = 0; i < parts.length - 1; i++) {\n const k = parts[i];\n if (cur[k] == null || typeof cur[k] !== 'object') cur[k] = {};\n cur = cur[k] as Record<string, unknown>;\n }\n cur[parts[parts.length - 1]] = value;\n}\n\nexport function createComputeJsonataHandler(\n spec: ComputeJsonataSpec,\n stepName: string,\n config?: Record<string, unknown>,\n): StepHandler {\n const steps = spec.expr.map(normalizeComputeStep);\n return async (input) => {\n const expects_data: Record<string, unknown> =\n input && typeof input === 'object' && !Array.isArray(input)\n ? { ...input }\n : {};\n\n // `data` accumulates computed outputs; it is placed in ctx by reference\n // so subsequent expressions can read `data.x` after earlier steps set it.\n const data: Record<string, unknown> = {};\n\n // Context shape:\n // expects_data — named namespace for declared step inputs (from flow state)\n // data — accumulating output namespace (required, mutated by reference)\n // config — optional step-level config\n const ctx: Record<string, unknown> = {\n expects_data,\n data, // same reference — mutations visible in later steps\n ...(config ? { config } : {}),\n };\n\n let transitionResult: string | undefined;\n let transitionError: string | undefined;\n\n for (const step of steps) {\n try {\n const val = jsonata(step.expr).evaluate(ctx);\n\n if (step.bindTo === 'result') {\n // Transition outcome\n transitionResult = val != null ? String(val) : 'success';\n } else if (step.bindTo === 'error') {\n // Transition error detail\n transitionError = val != null ? String(val) : undefined;\n } else if (step.bindTo.startsWith('data.')) {\n // Namespaced output — mutates the shared data reference\n deepSet(data, step.bindTo.slice('data.'.length), val);\n } else {\n return {\n result: 'failure',\n data: {},\n error: `[${stepName}] invalid bindTo \"${step.bindTo}\": must be \"result\", \"error\", or start with \"data.\"`,\n };\n }\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n result: 'failure',\n data: {},\n error: `[${stepName}] compute \"${step.bindTo}\" failed: ${msg}`,\n };\n }\n }\n\n if (transitionResult === undefined) {\n return {\n result: 'failure',\n data: {},\n error: `[${stepName}] compute-jsonata: no \"result\" binding declared — add '- result = \"success\"' to expr`,\n };\n }\n return transitionError\n ? { result: transitionResult, data, error: transitionError }\n : { result: transitionResult, data };\n };\n}\n\n// ============================================================================\n// Ref handler — dispatches via InvokeFn\n// ============================================================================\n\nexport function createRefStepHandler(\n spec: RefSpec,\n stepName: string,\n invoke: InvokeRefFn,\n config?: Record<string, unknown>,\n): StepHandler {\n // The handler spec itself is a superset of ExecutionRef. Strip the discriminator\n // before passing to the adapter so it sees a plain ExecutionRef.\n const { type: _t, ...refOnly } = spec;\n const ref = refOnly;\n\n return async (input) => {\n const stepInput: Record<string, unknown> =\n input && typeof input === 'object' && !Array.isArray(input)\n ? { ...input }\n : {};\n if (config) stepInput.config = config;\n\n try {\n const raw = await invoke(ref, stepInput);\n if (!spec.outputTransforms) return raw;\n try {\n return resolveOutputTransforms(spec.outputTransforms, raw, stepName);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n return { result: 'failure', data: {}, error: msg };\n }\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n result: 'failure',\n data: { error: `[step-machine-public] step \"${stepName}\" invoke threw: ${msg}` },\n };\n }\n };\n}\n\n// ============================================================================\n// Passthrough handler\n// ============================================================================\n\nexport function createPassthroughHandler(): StepHandler {\n return async (input) => {\n const data: Record<string, unknown> =\n input && typeof input === 'object' && !Array.isArray(input)\n ? (input as Record<string, unknown>)\n : {};\n return { result: 'success', data };\n };\n}\n\n// ============================================================================\n// resolveStepHandler — pick + decorate the right handler for a step\n// ============================================================================\n\nexport interface ResolveStepHandlerOptions {\n invoke: InvokeRefFn;\n}\n\nexport function resolveStepHandler(\n stepName: string,\n stepConfig: StepConfigForFactory | undefined,\n options: ResolveStepHandlerOptions,\n): StepHandler {\n const produces = Array.isArray(stepConfig?.produces_data) ? stepConfig?.produces_data : undefined;\n const inputValidations = Array.isArray(stepConfig?.input_validations)\n ? stepConfig?.input_validations\n : undefined;\n const config = stepConfig?.config ?? undefined;\n const spec: HandlerSpec | undefined = stepConfig?.handler;\n\n let base: StepHandler;\n if (isComputeJsonataSpec(spec)) {\n // compute-jsonata: validations are baked in via the wrapper as well; both work.\n base = createComputeJsonataHandler(spec, stepName, config);\n } else if (isRefSpec(spec)) {\n base = createRefStepHandler(spec, stepName, options.invoke, config);\n } else {\n base = createPassthroughHandler();\n }\n\n return wrapWithInputValidations(\n wrapWithOutputFiltering(base, produces),\n inputValidations,\n stepName,\n );\n}\n\n// ============================================================================\n// buildStepHandlersForFlow — produce the Record<stepName, StepHandler> map\n// ============================================================================\n\nexport interface BuildStepHandlersOptions {\n invoke: InvokeRefFn;\n}\n\nexport function buildStepHandlersForFlow(\n flow: { steps?: Record<string, StepConfigForFactory> },\n options: BuildStepHandlersOptions,\n): Record<string, StepHandler> {\n const handlers: Record<string, StepHandler> = {};\n for (const [stepName, stepConfig] of Object.entries(flow.steps ?? {})) {\n handlers[stepName] = resolveStepHandler(stepName, stepConfig, options);\n }\n return handlers;\n}\n\n// Re-export for adapter convenience.\nexport type { NormalizedHandlerResult };\n"]}
|
package/dist/storage-refs.cjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use strict';var i=require('fs'),c=require('path'),child_process=require('child_process');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var i__namespace=/*#__PURE__*/_interopNamespace(i);var c__namespace=/*#__PURE__*/_interopNamespace(c);function y(t){if(t.startsWith("::fs-path::"))return {kind:"fs-path",value:t.slice(11)};if(!t.startsWith("b64:"))throw new Error(`Invalid ref format (expected b64:<base64url(json)>): ${t}`);let n=t.slice(4),o=n.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-n.length%4)%4),e;try{e=JSON.parse(Buffer.from(o,"base64").toString("utf8"));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${t}`)}if(!e||typeof e!="object")throw new Error(`Invalid ref format (expected object payload): ${t}`);let r=e;if(typeof r.kind!="string"||typeof r.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${t}`);return {kind:r.kind,value:r.value}}function h(t){return `b64:${Buffer.from(JSON.stringify(t),"utf8").toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}`}function k(){return {read(t){if(!i__namespace.existsSync(t))return null;try{return i__namespace.readFileSync(t,"utf-8")}catch{return null}},write(t,n){i__namespace.mkdirSync(c__namespace.dirname(t),{recursive:true}),i__namespace.writeFileSync(t,n,"utf-8");}}}function R(t){if(t.kind==="fs-path")return k();throw new Error(`Unsupported storage kind: "${t.kind}". Supported kinds: fs-path`)}function l(t){try{return y(t).value}catch{return t}}function g(t){let n=t.extra?.notifyChannel;return typeof n=="string"&&n.length>0?n:void 0}function w(t){if(!t.endsWith(".ts"))return {cmd:process.execPath,args:[t]};let n=c__namespace.dirname(t),o=[];for(let r=1;r<=5;r++){let s=c__namespace.join(n,...Array(r).fill(".."),"node_modules");o.push(c__namespace.join(s,"tsx","dist","cli.mjs")),o.push(c__namespace.join(s,".bin","tsx"));}let e=o.find(r=>i__namespace.existsSync(r));return e?{cmd:process.execPath,args:[e,t]}:{cmd:"npx",args:["tsx",t]}}function b(t,n){let{token:o,via:e}=t;if(e.howToRun==="local-node"||e.howToRun==="local-process"){let r=l(e.whatToRun),{cmd:s,args:d}=w(r),u=g(e),f=[...d,"source-data-fetched","--ref",h(n),"--token",o,...u?["--notify-channel",u]:[]],a=child_process.spawnSync(s,f,{encoding:"utf-8",windowsHide:true});if(a.status!==0)throw new Error(`reportComplete: board CLI exited ${a.status}: ${a.stderr?.trim()}`);return}if(e.howToRun==="http:post"){let r=l(e.whatToRun),s=JSON.stringify({status:"complete",ref:h(n),token:o});m(r,s);return}throw new Error(`reportComplete: unsupported via.howToRun "${e.howToRun}"`)}function v(t,n){let{token:o,via:e}=t;if(e.howToRun==="local-node"||e.howToRun==="local-process"){let r=l(e.whatToRun),{cmd:s,args:d}=w(r),u=g(e),f=[...d,"source-data-fetch-failure","--token",o,"--reason",n,...u?["--notify-channel",u]:[]],a=child_process.spawnSync(s,f,{encoding:"utf-8",windowsHide:true});if(a.status!==0)throw new Error(`reportFailed: board CLI exited ${a.status}: ${a.stderr?.trim()}`);return}if(e.howToRun==="http:post"){let r=l(e.whatToRun),s=JSON.stringify({status:"failed",reason:n,token:o});m(r,s);return}throw new Error(`reportFailed: unsupported via.howToRun "${e.howToRun}"`)}function m(t,n){let o=`
|
|
2
|
-
const {request} = require(new URL('${t}').protocol === 'https:' ? 'https' : 'http');
|
|
3
|
-
const h = ${JSON.stringify({"Content-Type":"application/json","Content-Length":Buffer.byteLength(n)})};
|
|
4
|
-
const u = new URL('${t}');
|
|
5
|
-
const req = request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:'POST',headers:h});
|
|
6
|
-
req.on('error', e => { process.stderr.write(e.message); process.exit(1); });
|
|
7
|
-
req.write(${JSON.stringify(n)});
|
|
8
|
-
req.end();
|
|
9
|
-
`,e=child_process.spawnSync(process.execPath,["-e",o],{encoding:"utf-8",windowsHide:true});if(e.status!==0)throw new Error(`http-post failed: ${e.stderr?.trim()}`)}exports.blobStorageForRef=R;exports.parseRef=y;exports.reportComplete=b;exports.reportFailed=v;exports.serializeRef=h;//# sourceMappingURL=storage-refs.cjs.map
|
|
10
|
-
//# sourceMappingURL=storage-refs.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/node/public-storage-adapter.ts"],"names":["parseRef","s","payload","padded","decoded","candidate","serializeRef","ref","createFsPathBlobStorage","key","i","content","c","blobStorageForRef","_parseWhatToRun","whatToRun","_notifyChannelFromVia","via","_resolveLocalNodeInvocation","scriptPath","dir","candidates","up","base","tsx","p","reportComplete","callback","outRef","token","cmd","args","notifyChannel","callbackArgs","result","spawnSync","url","body","_httpPostSync","reportFailed","reason","script"],"mappings":"mfA+CO,SAASA,CAAAA,CAASC,CAAAA,CAAyB,CAEhD,GAAIA,EAAE,UAAA,CAAW,aAAa,CAAA,CAC5B,OAAO,CAAE,IAAA,CAAM,SAAA,CAAW,KAAA,CAAOA,CAAAA,CAAE,MAAM,EAAoB,CAAE,CAAA,CAEjE,GAAI,CAACA,CAAAA,CAAE,UAAA,CAAW,MAAM,CAAA,CAAG,MAAM,IAAI,KAAA,CAAM,CAAA,qDAAA,EAAwDA,CAAC,CAAA,CAAE,CAAA,CACtG,IAAMC,CAAAA,CAAUD,EAAE,KAAA,CAAM,CAAC,CAAA,CACnBE,CAAAA,CAASD,EAAQ,OAAA,CAAQ,IAAA,CAAM,GAAG,CAAA,CAAE,QAAQ,IAAA,CAAM,GAAG,CAAA,CAAI,GAAA,CAAI,QAAQ,CAAA,CAAKA,CAAAA,CAAQ,MAAA,CAAS,CAAA,EAAM,CAAC,CAAA,CACpGE,CAAAA,CACJ,GAAI,CACFA,EAAU,IAAA,CAAK,KAAA,CAAM,MAAA,CAAO,IAAA,CAAKD,EAAQ,QAAQ,CAAA,CAAE,QAAA,CAAS,MAAM,CAAC,EACrE,CAAA,KA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B,CAAAA,CAAMtB,CAAAA,CAAgBG,EAAI,SAAS,CAAA,CACnCoB,CAAAA,CAAO,IAAA,CAAK,UAAU,CAAE,MAAA,CAAQ,QAAA,CAAU,MAAA,CAAAG,EAAQ,KAAA,CAAAX,CAAM,CAAC,CAAA,CAC/DS,EAAcF,CAAAA,CAAKC,CAAI,CAAA,CACvB,MACF,CACA,MAAM,IAAI,KAAA,CAAM,CAAA,wCAAA,EAA2CpB,EAAI,QAAQ,CAAA,CAAA,CAAG,CAC5E,CAGA,SAASqB,CAAAA,CAAcF,CAAAA,CAAaC,CAAAA,CAAoB,CACtD,IAAMI,CAAAA,CAAS;AAAA,uCAAA,EACwBL,CAAG,CAAA;AAAA,cAAA,EAC5B,IAAA,CAAK,SAAA,CAAU,CAAE,cAAA,CAAgB,kBAAA,CAAoB,gBAAA,CAAkB,MAAA,CAAO,UAAA,CAAWC,CAAI,CAAE,CAAC,CAAC,CAAA;AAAA,uBAAA,EACxFD,CAAG,CAAA;AAAA;AAAA;AAAA,cAAA,EAGZ,IAAA,CAAK,SAAA,CAAUC,CAAI,CAAC,CAAA;AAAA;AAAA,EAAA,CAAA,CAG5BH,CAAAA,CAASC,uBAAAA,CAAU,OAAA,CAAQ,QAAA,CAAU,CAAC,IAAA,CAAMM,CAAM,CAAA,CAAG,CAAE,QAAA,CAAU,OAAA,CAAS,WAAA,CAAa,IAAK,CAAC,CAAA,CACnG,GAAIP,CAAAA,CAAO,MAAA,GAAW,CAAA,CAAG,MAAM,IAAI,KAAA,CAAM,CAAA,kBAAA,EAAqBA,CAAAA,CAAO,MAAA,EAAQ,IAAA,EAAM,CAAA,CAAE,CACvF","file":"storage-refs.cjs","sourcesContent":["/**\n * public-storage-adapter.ts\n *\n * Standalone file — copy this to your task-executor project.\n * Zero dependencies on the rest of yaml-flow.\n *\n * Provides:\n * - KindValueRef wire format: b64:<base64url(json)>\n * - parseRef() parse a b64:<base64url(json)> string\n * - serializeRef() produce a b64:<base64url(json)> string\n * - BlobStorage read/write interface\n * - blobStorageForRef resolve a ref to its BlobStorage backend\n * - ExecutionRef portable invocation descriptor (inlined, stays standalone)\n * - TaskCallback how to report task completion back to the board\n * - reportComplete() call from executor on success\n * - reportFailed() call from executor on failure\n *\n * Supported storage kinds:\n * fs-path — ref.value is an absolute file path; reads/writes via node:fs\n *\n * Supported callback transports (via ExecutionRef.howToRun):\n * local-node — invoke board CLI as a child Node process\n * http:post — HTTP POST to a board endpoint\n *\n * Usage:\n * import { parseRef, blobStorageForRef, reportComplete, reportFailed } from './public-storage-adapter.js';\n *\n * const { source_def, callback } = JSON.parse(blobStorageForRef(inRef).read(inRef.value));\n * // ... do work, write to outRef ...\n * reportComplete(callback, outRef);\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { spawnSync } from 'node:child_process';\n\n// ============================================================================\n// KindValueRef\n// ============================================================================\n\nexport interface KindValueRef {\n readonly kind: string;\n readonly value: string;\n}\n\n/** Parse a wire-format ref string (b64:<base64url(json)>) into a KindValueRef.\n * Also accepts the legacy ::fs-path::<path> format for backward compatibility. */\nexport function parseRef(s: string): KindValueRef {\n // Legacy format: ::fs-path::<path>\n if (s.startsWith('::fs-path::')) {\n return { kind: 'fs-path', value: s.slice('::fs-path::'.length) };\n }\n if (!s.startsWith('b64:')) throw new Error(`Invalid ref format (expected b64:<base64url(json)>): ${s}`);\n const payload = s.slice(4);\n const padded = payload.replace(/-/g, '+').replace(/_/g, '/') + '='.repeat((4 - (payload.length % 4)) % 4);\n let decoded: unknown;\n try {\n decoded = JSON.parse(Buffer.from(padded, 'base64').toString('utf8'));\n } catch {\n throw new Error(`Invalid ref format (malformed base64url/json): ${s}`);\n }\n if (!decoded || typeof decoded !== 'object') {\n throw new Error(`Invalid ref format (expected object payload): ${s}`);\n }\n const candidate = decoded as { kind?: unknown; value?: unknown };\n if (typeof candidate.kind !== 'string' || typeof candidate.value !== 'string') {\n throw new Error(`Invalid ref format (payload must contain string kind/value): ${s}`);\n }\n return { kind: candidate.kind, value: candidate.value };\n}\n\n/** Serialize a KindValueRef to the wire format: b64:<base64url(json)> */\nexport function serializeRef(ref: KindValueRef): string {\n return `b64:${Buffer.from(JSON.stringify(ref), 'utf8').toString('base64').replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/g, '')}`;\n}\n\n// ============================================================================\n// BlobStorage\n// ============================================================================\n\nexport interface BlobStorage {\n /** Returns content string, or null if not found. */\n read(key: string): string | null;\n /** Write content at key. */\n write(key: string, content: string): void;\n}\n\n// ============================================================================\n// fs-path backend — key IS the absolute file path\n// ============================================================================\n\nfunction createFsPathBlobStorage(): BlobStorage {\n return {\n read(key: string): string | null {\n if (!fs.existsSync(key)) return null;\n try { return fs.readFileSync(key, 'utf-8'); } catch { return null; }\n },\n write(key: string, content: string): void {\n fs.mkdirSync(path.dirname(key), { recursive: true });\n fs.writeFileSync(key, content, 'utf-8');\n },\n };\n}\n\n// ============================================================================\n// blobStorageForRef\n// ============================================================================\n\n/**\n * Resolve a KindValueRef to its BlobStorage backend.\n * Throws a clear error for unrecognised kinds.\n */\nexport function blobStorageForRef(ref: KindValueRef): BlobStorage {\n switch (ref.kind) {\n case 'fs-path': return createFsPathBlobStorage();\n default: throw new Error(`Unsupported storage kind: \"${ref.kind}\". Supported kinds: fs-path`);\n }\n}\n\n// ============================================================================\n// TaskCallback — how a task-executor reports results back to the board\n// ============================================================================\n\n/**\n * Portable invocation descriptor for the board CLI back-channel.\n * Inlined here so this file stays standalone (zero deps on yaml-flow internals).\n * Shape matches ExecutionRef in execution-interface.ts — keep in sync.\n *\n * Supported howToRun values for TaskCallback.via:\n * local-node — invoke board CLI as: node [tsx?] <whatToRun.value> <cmd> [...argv]\n * http:post — POST to <whatToRun.value> with a JSON body\n */\nexport interface ExecutionRef {\n /** Optional human-readable label. Not used for dispatch. */\n meta?: string;\n /** Transport / runtime kind. */\n howToRun: 'local-node' | 'local-python' | 'local-process' | 'http:post' | 'http:get' | 'built-in';\n /** Address of the target in b64:<base64url(json)> wire form. */\n whatToRun: string;\n /** Opaque executor config stored with the ref. */\n extra?: Record<string, unknown>;\n}\n\n/**\n * Describes how the board wants to receive task completion callbacks.\n * Baked into the inRef payload as { source_def, callback }.\n * The executor treats `token` as opaque and passes it back unchanged.\n */\nexport interface TaskCallback {\n /** Opaque routing token — generated by the board, passed back unchanged. */\n token: string;\n /** Delivery mechanism — an ExecutionRef pointing at the board CLI or endpoint. */\n via: ExecutionRef;\n}\n\n/**\n * Extract the path/url value from a whatToRun b64:<base64url(json)> wire string.\n * Falls back to the raw string if it isn’t in b64:<base64url(json)> form.\n */\nfunction _parseWhatToRun(whatToRun: string): string {\n try { return parseRef(whatToRun).value; } catch { return whatToRun; }\n}\n\nfunction _notifyChannelFromVia(via: ExecutionRef): string | undefined {\n const candidate = via.extra?.['notifyChannel'];\n return typeof candidate === 'string' && candidate.length > 0 ? candidate : undefined;\n}\n\n/**\n * Resolve the Node invocation for a local board CLI script.\n * If the path ends in .ts (dev mode), attempts to locate tsx alongside it;\n * otherwise assumes it’s a compiled .js and invokes directly with node.\n */\nfunction _resolveLocalNodeInvocation(scriptPath: string): { cmd: string; args: string[] } {\n if (!scriptPath.endsWith('.ts')) {\n return { cmd: process.execPath, args: [scriptPath] };\n }\n // Dev path: look for tsx in node_modules relative to the script's package root.\n // The .ts file may be at src/cli/node/<file>.ts — walk up until we find node_modules/tsx.\n const dir = path.dirname(scriptPath);\n const candidates: string[] = [];\n for (let up = 1; up <= 5; up++) {\n const base = path.join(dir, ...Array(up).fill('..'), 'node_modules');\n candidates.push(path.join(base, 'tsx', 'dist', 'cli.mjs'));\n candidates.push(path.join(base, '.bin', 'tsx'));\n }\n const tsx = candidates.find(p => fs.existsSync(p));\n if (tsx) return { cmd: process.execPath, args: [tsx, scriptPath] };\n return { cmd: 'npx', args: ['tsx', scriptPath] };\n}\n\n/**\n * Report successful task completion back to the board.\n * Call this from a task-executor after writing the result to outRef.\n */\nexport function reportComplete(callback: TaskCallback, outRef: KindValueRef): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetched',\n '--ref', serializeRef(outRef),\n '--token', token,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportComplete: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'complete', ref: serializeRef(outRef), token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportComplete: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/**\n * Report task failure back to the board.\n * Call this from a task-executor instead of writing to outRef.\n */\nexport function reportFailed(callback: TaskCallback, reason: string): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetch-failure',\n '--token', token,\n '--reason', reason,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportFailed: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'failed', reason, token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportFailed: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/** Synchronous HTTP POST using a child node process (keeps this file free of async). */\nfunction _httpPostSync(url: string, body: string): void {\n const script = `\n const {request} = require(new URL('${url}').protocol === 'https:' ? 'https' : 'http');\n const h = ${JSON.stringify({ 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) })};\n const u = new URL('${url}');\n const req = request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:'POST',headers:h});\n req.on('error', e => { process.stderr.write(e.message); process.exit(1); });\n req.write(${JSON.stringify(body)});\n req.end();\n `;\n const result = spawnSync(process.execPath, ['-e', script], { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) throw new Error(`http-post failed: ${result.stderr?.trim()}`);\n}\n"]}
|
package/dist/storage-refs.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import*as i from'fs';import*as c from'path';import {spawnSync}from'child_process';function y(t){if(t.startsWith("::fs-path::"))return {kind:"fs-path",value:t.slice(11)};if(!t.startsWith("b64:"))throw new Error(`Invalid ref format (expected b64:<base64url(json)>): ${t}`);let n=t.slice(4),o=n.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-n.length%4)%4),e;try{e=JSON.parse(Buffer.from(o,"base64").toString("utf8"));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${t}`)}if(!e||typeof e!="object")throw new Error(`Invalid ref format (expected object payload): ${t}`);let r=e;if(typeof r.kind!="string"||typeof r.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${t}`);return {kind:r.kind,value:r.value}}function h(t){return `b64:${Buffer.from(JSON.stringify(t),"utf8").toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}`}function k(){return {read(t){if(!i.existsSync(t))return null;try{return i.readFileSync(t,"utf-8")}catch{return null}},write(t,n){i.mkdirSync(c.dirname(t),{recursive:true}),i.writeFileSync(t,n,"utf-8");}}}function R(t){if(t.kind==="fs-path")return k();throw new Error(`Unsupported storage kind: "${t.kind}". Supported kinds: fs-path`)}function l(t){try{return y(t).value}catch{return t}}function g(t){let n=t.extra?.notifyChannel;return typeof n=="string"&&n.length>0?n:void 0}function w(t){if(!t.endsWith(".ts"))return {cmd:process.execPath,args:[t]};let n=c.dirname(t),o=[];for(let r=1;r<=5;r++){let s=c.join(n,...Array(r).fill(".."),"node_modules");o.push(c.join(s,"tsx","dist","cli.mjs")),o.push(c.join(s,".bin","tsx"));}let e=o.find(r=>i.existsSync(r));return e?{cmd:process.execPath,args:[e,t]}:{cmd:"npx",args:["tsx",t]}}function b(t,n){let{token:o,via:e}=t;if(e.howToRun==="local-node"||e.howToRun==="local-process"){let r=l(e.whatToRun),{cmd:s,args:d}=w(r),u=g(e),f=[...d,"source-data-fetched","--ref",h(n),"--token",o,...u?["--notify-channel",u]:[]],a=spawnSync(s,f,{encoding:"utf-8",windowsHide:true});if(a.status!==0)throw new Error(`reportComplete: board CLI exited ${a.status}: ${a.stderr?.trim()}`);return}if(e.howToRun==="http:post"){let r=l(e.whatToRun),s=JSON.stringify({status:"complete",ref:h(n),token:o});m(r,s);return}throw new Error(`reportComplete: unsupported via.howToRun "${e.howToRun}"`)}function v(t,n){let{token:o,via:e}=t;if(e.howToRun==="local-node"||e.howToRun==="local-process"){let r=l(e.whatToRun),{cmd:s,args:d}=w(r),u=g(e),f=[...d,"source-data-fetch-failure","--token",o,"--reason",n,...u?["--notify-channel",u]:[]],a=spawnSync(s,f,{encoding:"utf-8",windowsHide:true});if(a.status!==0)throw new Error(`reportFailed: board CLI exited ${a.status}: ${a.stderr?.trim()}`);return}if(e.howToRun==="http:post"){let r=l(e.whatToRun),s=JSON.stringify({status:"failed",reason:n,token:o});m(r,s);return}throw new Error(`reportFailed: unsupported via.howToRun "${e.howToRun}"`)}function m(t,n){let o=`
|
|
2
|
-
const {request} = require(new URL('${t}').protocol === 'https:' ? 'https' : 'http');
|
|
3
|
-
const h = ${JSON.stringify({"Content-Type":"application/json","Content-Length":Buffer.byteLength(n)})};
|
|
4
|
-
const u = new URL('${t}');
|
|
5
|
-
const req = request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:'POST',headers:h});
|
|
6
|
-
req.on('error', e => { process.stderr.write(e.message); process.exit(1); });
|
|
7
|
-
req.write(${JSON.stringify(n)});
|
|
8
|
-
req.end();
|
|
9
|
-
`,e=spawnSync(process.execPath,["-e",o],{encoding:"utf-8",windowsHide:true});if(e.status!==0)throw new Error(`http-post failed: ${e.stderr?.trim()}`)}export{R as blobStorageForRef,y as parseRef,b as reportComplete,v as reportFailed,h as serializeRef};//# sourceMappingURL=storage-refs.js.map
|
|
10
|
-
//# sourceMappingURL=storage-refs.js.map
|
package/dist/storage-refs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/node/public-storage-adapter.ts"],"names":["parseRef","s","payload","padded","decoded","candidate","serializeRef","ref","createFsPathBlobStorage","key","content","blobStorageForRef","_parseWhatToRun","whatToRun","_notifyChannelFromVia","via","_resolveLocalNodeInvocation","scriptPath","dir","candidates","up","base","tsx","p","reportComplete","callback","outRef","token","cmd","args","notifyChannel","callbackArgs","result","spawnSync","url","body","_httpPostSync","reportFailed","reason","script"],"mappings":"kFA+CO,SAASA,CAAAA,CAASC,CAAAA,CAAyB,CAEhD,GAAIA,EAAE,UAAA,CAAW,aAAa,CAAA,CAC5B,OAAO,CAAE,IAAA,CAAM,SAAA,CAAW,KAAA,CAAOA,CAAAA,CAAE,MAAM,EAAoB,CAAE,CAAA,CAEjE,GAAI,CAACA,CAAAA,CAAE,UAAA,CAAW,MAAM,CAAA,CAAG,MAAM,IAAI,KAAA,CAAM,CAAA,qDAAA,EAAwDA,CAAC,CAAA,CAAE,CAAA,CACtG,IAAMC,CAAAA,CAAUD,EAAE,KAAA,CAAM,CAAC,CAAA,CACnBE,CAAAA,CAASD,EAAQ,OAAA,CAAQ,IAAA,CAAM,GAAG,CAAA,CAAE,QAAQ,IAAA,CAAM,GAAG,CAAA,CAAI,GAAA,CAAI,QAAQ,CAAA,CAAKA,CAAAA,CAAQ,MAAA,CAAS,CAAA,EAAM,CA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project.\n * Zero dependencies on the rest of yaml-flow.\n *\n * Provides:\n * - KindValueRef wire format: b64:<base64url(json)>\n * - parseRef() parse a b64:<base64url(json)> string\n * - serializeRef() produce a b64:<base64url(json)> string\n * - BlobStorage read/write interface\n * - blobStorageForRef resolve a ref to its BlobStorage backend\n * - ExecutionRef portable invocation descriptor (inlined, stays standalone)\n * - TaskCallback how to report task completion back to the board\n * - reportComplete() call from executor on success\n * - reportFailed() call from executor on failure\n *\n * Supported storage kinds:\n * fs-path — ref.value is an absolute file path; reads/writes via node:fs\n *\n * Supported callback transports (via ExecutionRef.howToRun):\n * local-node — invoke board CLI as a child Node process\n * http:post — HTTP POST to a board endpoint\n *\n * Usage:\n * import { parseRef, blobStorageForRef, reportComplete, reportFailed } from './public-storage-adapter.js';\n *\n * const { source_def, callback } = JSON.parse(blobStorageForRef(inRef).read(inRef.value));\n * // ... do work, write to outRef ...\n * reportComplete(callback, outRef);\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { spawnSync } from 'node:child_process';\n\n// ============================================================================\n// KindValueRef\n// ============================================================================\n\nexport interface KindValueRef {\n readonly kind: string;\n readonly value: string;\n}\n\n/** Parse a wire-format ref string (b64:<base64url(json)>) into a KindValueRef.\n * Also accepts the legacy ::fs-path::<path> format for backward compatibility. */\nexport function parseRef(s: string): KindValueRef {\n // Legacy format: ::fs-path::<path>\n if (s.startsWith('::fs-path::')) {\n return { kind: 'fs-path', value: s.slice('::fs-path::'.length) };\n }\n if (!s.startsWith('b64:')) throw new Error(`Invalid ref format (expected b64:<base64url(json)>): ${s}`);\n const payload = s.slice(4);\n const padded = payload.replace(/-/g, '+').replace(/_/g, '/') + '='.repeat((4 - (payload.length % 4)) % 4);\n let decoded: unknown;\n try {\n decoded = JSON.parse(Buffer.from(padded, 'base64').toString('utf8'));\n } catch {\n throw new Error(`Invalid ref format (malformed base64url/json): ${s}`);\n }\n if (!decoded || typeof decoded !== 'object') {\n throw new Error(`Invalid ref format (expected object payload): ${s}`);\n }\n const candidate = decoded as { kind?: unknown; value?: unknown };\n if (typeof candidate.kind !== 'string' || typeof candidate.value !== 'string') {\n throw new Error(`Invalid ref format (payload must contain string kind/value): ${s}`);\n }\n return { kind: candidate.kind, value: candidate.value };\n}\n\n/** Serialize a KindValueRef to the wire format: b64:<base64url(json)> */\nexport function serializeRef(ref: KindValueRef): string {\n return `b64:${Buffer.from(JSON.stringify(ref), 'utf8').toString('base64').replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/g, '')}`;\n}\n\n// ============================================================================\n// BlobStorage\n// ============================================================================\n\nexport interface BlobStorage {\n /** Returns content string, or null if not found. */\n read(key: string): string | null;\n /** Write content at key. */\n write(key: string, content: string): void;\n}\n\n// ============================================================================\n// fs-path backend — key IS the absolute file path\n// ============================================================================\n\nfunction createFsPathBlobStorage(): BlobStorage {\n return {\n read(key: string): string | null {\n if (!fs.existsSync(key)) return null;\n try { return fs.readFileSync(key, 'utf-8'); } catch { return null; }\n },\n write(key: string, content: string): void {\n fs.mkdirSync(path.dirname(key), { recursive: true });\n fs.writeFileSync(key, content, 'utf-8');\n },\n };\n}\n\n// ============================================================================\n// blobStorageForRef\n// ============================================================================\n\n/**\n * Resolve a KindValueRef to its BlobStorage backend.\n * Throws a clear error for unrecognised kinds.\n */\nexport function blobStorageForRef(ref: KindValueRef): BlobStorage {\n switch (ref.kind) {\n case 'fs-path': return createFsPathBlobStorage();\n default: throw new Error(`Unsupported storage kind: \"${ref.kind}\". Supported kinds: fs-path`);\n }\n}\n\n// ============================================================================\n// TaskCallback — how a task-executor reports results back to the board\n// ============================================================================\n\n/**\n * Portable invocation descriptor for the board CLI back-channel.\n * Inlined here so this file stays standalone (zero deps on yaml-flow internals).\n * Shape matches ExecutionRef in execution-interface.ts — keep in sync.\n *\n * Supported howToRun values for TaskCallback.via:\n * local-node — invoke board CLI as: node [tsx?] <whatToRun.value> <cmd> [...argv]\n * http:post — POST to <whatToRun.value> with a JSON body\n */\nexport interface ExecutionRef {\n /** Optional human-readable label. Not used for dispatch. */\n meta?: string;\n /** Transport / runtime kind. */\n howToRun: 'local-node' | 'local-python' | 'local-process' | 'http:post' | 'http:get' | 'built-in';\n /** Address of the target in b64:<base64url(json)> wire form. */\n whatToRun: string;\n /** Opaque executor config stored with the ref. */\n extra?: Record<string, unknown>;\n}\n\n/**\n * Describes how the board wants to receive task completion callbacks.\n * Baked into the inRef payload as { source_def, callback }.\n * The executor treats `token` as opaque and passes it back unchanged.\n */\nexport interface TaskCallback {\n /** Opaque routing token — generated by the board, passed back unchanged. */\n token: string;\n /** Delivery mechanism — an ExecutionRef pointing at the board CLI or endpoint. */\n via: ExecutionRef;\n}\n\n/**\n * Extract the path/url value from a whatToRun b64:<base64url(json)> wire string.\n * Falls back to the raw string if it isn’t in b64:<base64url(json)> form.\n */\nfunction _parseWhatToRun(whatToRun: string): string {\n try { return parseRef(whatToRun).value; } catch { return whatToRun; }\n}\n\nfunction _notifyChannelFromVia(via: ExecutionRef): string | undefined {\n const candidate = via.extra?.['notifyChannel'];\n return typeof candidate === 'string' && candidate.length > 0 ? candidate : undefined;\n}\n\n/**\n * Resolve the Node invocation for a local board CLI script.\n * If the path ends in .ts (dev mode), attempts to locate tsx alongside it;\n * otherwise assumes it’s a compiled .js and invokes directly with node.\n */\nfunction _resolveLocalNodeInvocation(scriptPath: string): { cmd: string; args: string[] } {\n if (!scriptPath.endsWith('.ts')) {\n return { cmd: process.execPath, args: [scriptPath] };\n }\n // Dev path: look for tsx in node_modules relative to the script's package root.\n // The .ts file may be at src/cli/node/<file>.ts — walk up until we find node_modules/tsx.\n const dir = path.dirname(scriptPath);\n const candidates: string[] = [];\n for (let up = 1; up <= 5; up++) {\n const base = path.join(dir, ...Array(up).fill('..'), 'node_modules');\n candidates.push(path.join(base, 'tsx', 'dist', 'cli.mjs'));\n candidates.push(path.join(base, '.bin', 'tsx'));\n }\n const tsx = candidates.find(p => fs.existsSync(p));\n if (tsx) return { cmd: process.execPath, args: [tsx, scriptPath] };\n return { cmd: 'npx', args: ['tsx', scriptPath] };\n}\n\n/**\n * Report successful task completion back to the board.\n * Call this from a task-executor after writing the result to outRef.\n */\nexport function reportComplete(callback: TaskCallback, outRef: KindValueRef): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetched',\n '--ref', serializeRef(outRef),\n '--token', token,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportComplete: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'complete', ref: serializeRef(outRef), token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportComplete: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/**\n * Report task failure back to the board.\n * Call this from a task-executor instead of writing to outRef.\n */\nexport function reportFailed(callback: TaskCallback, reason: string): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetch-failure',\n '--token', token,\n '--reason', reason,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportFailed: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'failed', reason, token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportFailed: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/** Synchronous HTTP POST using a child node process (keeps this file free of async). */\nfunction _httpPostSync(url: string, body: string): void {\n const script = `\n const {request} = require(new URL('${url}').protocol === 'https:' ? 'https' : 'http');\n const h = ${JSON.stringify({ 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) })};\n const u = new URL('${url}');\n const req = request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:'POST',headers:h});\n req.on('error', e => { process.stderr.write(e.message); process.exit(1); });\n req.write(${JSON.stringify(body)});\n req.end();\n `;\n const result = spawnSync(process.execPath, ['-e', script], { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) throw new Error(`http-post failed: ${result.stderr?.trim()}`);\n}\n"]}
|
package/dist/stores/file.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var a=class{directory;fs=null;path=null;constructor(i){this.directory=i.directory;}async ensureModules(){(!this.fs||!this.path)&&(this.fs=await import('fs/promises'),this.path=await import('path'),await this.fs.mkdir(this.directory,{recursive:true}));}runPath(i){return this.path.join(this.directory,`${i}.run.json`)}dataPath(i){return this.path.join(this.directory,`${i}.data.json`)}async saveRunState(i,t){await this.ensureModules(),await this.fs.writeFile(this.runPath(i),JSON.stringify(t,null,2),"utf-8");}async loadRunState(i){await this.ensureModules();try{let t=await this.fs.readFile(this.runPath(i),"utf-8");return JSON.parse(t)}catch(t){if(t.code==="ENOENT")return null;throw t}}async deleteRunState(i){await this.ensureModules();try{await this.fs.unlink(this.runPath(i));}catch(t){if(t.code!=="ENOENT")throw t}try{await this.fs.unlink(this.dataPath(i));}catch(t){if(t.code!=="ENOENT")throw t}}async setData(i,t,r){await this.ensureModules();let e=await this.getAllData(i);e[t]=r,await this.fs.writeFile(this.dataPath(i),JSON.stringify(e,null,2),"utf-8");}async getData(i,t){return (await this.getAllData(i))[t]}async getAllData(i){await this.ensureModules();try{let t=await this.fs.readFile(this.dataPath(i),"utf-8");return JSON.parse(t)}catch(t){if(t.code==="ENOENT")return {};throw t}}async clearData(i){await this.ensureModules();try{await this.fs.unlink(this.dataPath(i));}catch(t){if(t.code!=="ENOENT")throw t}}async listRuns(){await this.ensureModules();try{return (await this.fs.readdir(this.directory)).filter(t=>t.endsWith(".run.json")).map(t=>t.replace(".run.json",""))}catch(i){if(i.code==="ENOENT")return [];throw i}}async clearAll(){await this.ensureModules();let i=await this.listRuns();await Promise.all(i.map(t=>this.deleteRunState(t)));}};exports.FileStore=a;//# sourceMappingURL=file.cjs.map
|
|
2
|
-
//# sourceMappingURL=file.cjs.map
|
package/dist/stores/file.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/stores/file.ts"],"names":["FileStore","options","runId","state","raw","err","key","value","allData","f","runs"],"mappings":"aAcO,IAAMA,CAAAA,CAAN,KAA4C,CACzC,SAAA,CACA,GAA0C,IAAA,CAC1C,IAAA,CAAqC,KAE7C,WAAA,CAAYC,CAAAA,CAA2B,CACrC,IAAA,CAAK,SAAA,CAAYA,EAAQ,UAC3B,CAEA,MAAc,aAAA,EAA+B,CAAA,CACvC,CAAC,IAAA,CAAK,EAAA,EAAM,CAAC,IAAA,CAAK,IAAA,IAEpB,KAAK,EAAA,CAAK,aAAa,aAAa,CAAA,CACpC,KAAK,IAAA,CAAO,aAAa,MAAM,CAAA,CAG/B,MAAM,IAAA,CAAK,EAAA,CAAG,MAAM,IAAA,CAAK,SAAA,CAAW,CAAE,SAAA,CAAW,IAAK,CAAC,GAE3D,CAEQ,OAAA,CAAQC,EAAuB,CACrC,OAAO,KAAK,IAAA,CAAM,IAAA,CAAK,KAAK,SAAA,CAAW,CAAA,EAAGA,CAAK,CAAA,SAAA,CAAW,CAC5D,CAEQ,QAAA,CAASA,CAAAA,CAAuB,CACtC,OAAO,IAAA,CAAK,KAAM,IAAA,CAAK,IAAA,CAAK,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A0B,CAC9B,MAAM,IAAA,CAAK,eAAc,CACzB,IAAMK,EAAO,MAAM,IAAA,CAAK,UAAS,CACjC,MAAM,QAAQ,GAAA,CAAIA,CAAAA,CAAK,IAAIR,CAAAA,EAAS,IAAA,CAAK,eAAeA,CAAK,CAAC,CAAC,EACjE,CACF","file":"file.cjs","sourcesContent":["/**\n * yaml-flow - File Store\n * \n * File-system based store for Node.js environments.\n * Stores each run as a JSON file in the specified directory.\n */\n\nimport type { StepMachineStore, StepMachineState } from '../step-machine/types.js';\n\nexport interface FileStoreOptions {\n /** Directory path for storing flow data */\n directory: string;\n}\n\nexport class FileStore implements StepMachineStore {\n private directory: string;\n private fs: typeof import('fs/promises') | null = null;\n private path: typeof import('path') | null = null;\n\n constructor(options: FileStoreOptions) {\n this.directory = options.directory;\n }\n\n private async ensureModules(): Promise<void> {\n if (!this.fs || !this.path) {\n // Dynamic import for Node.js modules\n this.fs = await import('fs/promises');\n this.path = await import('path');\n \n // Ensure directory exists\n await this.fs.mkdir(this.directory, { recursive: true });\n }\n }\n\n private runPath(runId: string): string {\n return this.path!.join(this.directory, `${runId}.run.json`);\n }\n\n private dataPath(runId: string): string {\n return this.path!.join(this.directory, `${runId}.data.json`);\n }\n\n async saveRunState(runId: string, state: StepMachineState): Promise<void> {\n await this.ensureModules();\n await this.fs!.writeFile(\n this.runPath(runId),\n JSON.stringify(state, null, 2),\n 'utf-8'\n );\n }\n\n async loadRunState(runId: string): Promise<StepMachineState | null> {\n await this.ensureModules();\n try {\n const raw = await this.fs!.readFile(this.runPath(runId), 'utf-8');\n return JSON.parse(raw);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return null;\n }\n throw err;\n }\n }\n\n async deleteRunState(runId: string): Promise<void> {\n await this.ensureModules();\n try {\n await this.fs!.unlink(this.runPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n try {\n await this.fs!.unlink(this.dataPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n }\n\n async setData(runId: string, key: string, value: unknown): Promise<void> {\n await this.ensureModules();\n const allData = await this.getAllData(runId);\n allData[key] = value;\n await this.fs!.writeFile(\n this.dataPath(runId),\n JSON.stringify(allData, null, 2),\n 'utf-8'\n );\n }\n\n async getData(runId: string, key: string): Promise<unknown> {\n const allData = await this.getAllData(runId);\n return allData[key];\n }\n\n async getAllData(runId: string): Promise<Record<string, unknown>> {\n await this.ensureModules();\n try {\n const raw = await this.fs!.readFile(this.dataPath(runId), 'utf-8');\n return JSON.parse(raw);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return {};\n }\n throw err;\n }\n }\n\n async clearData(runId: string): Promise<void> {\n await this.ensureModules();\n try {\n await this.fs!.unlink(this.dataPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n }\n\n async listRuns(): Promise<string[]> {\n await this.ensureModules();\n try {\n const files = await this.fs!.readdir(this.directory);\n return files\n .filter(f => f.endsWith('.run.json'))\n .map(f => f.replace('.run.json', ''));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return [];\n }\n throw err;\n }\n }\n\n /**\n * Clear all flow data from directory\n */\n async clearAll(): Promise<void> {\n await this.ensureModules();\n const runs = await this.listRuns();\n await Promise.all(runs.map(runId => this.deleteRunState(runId)));\n }\n}\n"]}
|
package/dist/stores/file.d.cts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { l as StepMachineStore, k as StepMachineState } from '../types-ycun84cq.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* yaml-flow - File Store
|
|
5
|
-
*
|
|
6
|
-
* File-system based store for Node.js environments.
|
|
7
|
-
* Stores each run as a JSON file in the specified directory.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
interface FileStoreOptions {
|
|
11
|
-
/** Directory path for storing flow data */
|
|
12
|
-
directory: string;
|
|
13
|
-
}
|
|
14
|
-
declare class FileStore implements StepMachineStore {
|
|
15
|
-
private directory;
|
|
16
|
-
private fs;
|
|
17
|
-
private path;
|
|
18
|
-
constructor(options: FileStoreOptions);
|
|
19
|
-
private ensureModules;
|
|
20
|
-
private runPath;
|
|
21
|
-
private dataPath;
|
|
22
|
-
saveRunState(runId: string, state: StepMachineState): Promise<void>;
|
|
23
|
-
loadRunState(runId: string): Promise<StepMachineState | null>;
|
|
24
|
-
deleteRunState(runId: string): Promise<void>;
|
|
25
|
-
setData(runId: string, key: string, value: unknown): Promise<void>;
|
|
26
|
-
getData(runId: string, key: string): Promise<unknown>;
|
|
27
|
-
getAllData(runId: string): Promise<Record<string, unknown>>;
|
|
28
|
-
clearData(runId: string): Promise<void>;
|
|
29
|
-
listRuns(): Promise<string[]>;
|
|
30
|
-
/**
|
|
31
|
-
* Clear all flow data from directory
|
|
32
|
-
*/
|
|
33
|
-
clearAll(): Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { FileStore, type FileStoreOptions };
|
package/dist/stores/file.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { l as StepMachineStore, k as StepMachineState } from '../types-ycun84cq.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* yaml-flow - File Store
|
|
5
|
-
*
|
|
6
|
-
* File-system based store for Node.js environments.
|
|
7
|
-
* Stores each run as a JSON file in the specified directory.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
interface FileStoreOptions {
|
|
11
|
-
/** Directory path for storing flow data */
|
|
12
|
-
directory: string;
|
|
13
|
-
}
|
|
14
|
-
declare class FileStore implements StepMachineStore {
|
|
15
|
-
private directory;
|
|
16
|
-
private fs;
|
|
17
|
-
private path;
|
|
18
|
-
constructor(options: FileStoreOptions);
|
|
19
|
-
private ensureModules;
|
|
20
|
-
private runPath;
|
|
21
|
-
private dataPath;
|
|
22
|
-
saveRunState(runId: string, state: StepMachineState): Promise<void>;
|
|
23
|
-
loadRunState(runId: string): Promise<StepMachineState | null>;
|
|
24
|
-
deleteRunState(runId: string): Promise<void>;
|
|
25
|
-
setData(runId: string, key: string, value: unknown): Promise<void>;
|
|
26
|
-
getData(runId: string, key: string): Promise<unknown>;
|
|
27
|
-
getAllData(runId: string): Promise<Record<string, unknown>>;
|
|
28
|
-
clearData(runId: string): Promise<void>;
|
|
29
|
-
listRuns(): Promise<string[]>;
|
|
30
|
-
/**
|
|
31
|
-
* Clear all flow data from directory
|
|
32
|
-
*/
|
|
33
|
-
clearAll(): Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { FileStore, type FileStoreOptions };
|
package/dist/stores/file.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var a=class{directory;fs=null;path=null;constructor(i){this.directory=i.directory;}async ensureModules(){(!this.fs||!this.path)&&(this.fs=await import('fs/promises'),this.path=await import('path'),await this.fs.mkdir(this.directory,{recursive:true}));}runPath(i){return this.path.join(this.directory,`${i}.run.json`)}dataPath(i){return this.path.join(this.directory,`${i}.data.json`)}async saveRunState(i,t){await this.ensureModules(),await this.fs.writeFile(this.runPath(i),JSON.stringify(t,null,2),"utf-8");}async loadRunState(i){await this.ensureModules();try{let t=await this.fs.readFile(this.runPath(i),"utf-8");return JSON.parse(t)}catch(t){if(t.code==="ENOENT")return null;throw t}}async deleteRunState(i){await this.ensureModules();try{await this.fs.unlink(this.runPath(i));}catch(t){if(t.code!=="ENOENT")throw t}try{await this.fs.unlink(this.dataPath(i));}catch(t){if(t.code!=="ENOENT")throw t}}async setData(i,t,r){await this.ensureModules();let e=await this.getAllData(i);e[t]=r,await this.fs.writeFile(this.dataPath(i),JSON.stringify(e,null,2),"utf-8");}async getData(i,t){return (await this.getAllData(i))[t]}async getAllData(i){await this.ensureModules();try{let t=await this.fs.readFile(this.dataPath(i),"utf-8");return JSON.parse(t)}catch(t){if(t.code==="ENOENT")return {};throw t}}async clearData(i){await this.ensureModules();try{await this.fs.unlink(this.dataPath(i));}catch(t){if(t.code!=="ENOENT")throw t}}async listRuns(){await this.ensureModules();try{return (await this.fs.readdir(this.directory)).filter(t=>t.endsWith(".run.json")).map(t=>t.replace(".run.json",""))}catch(i){if(i.code==="ENOENT")return [];throw i}}async clearAll(){await this.ensureModules();let i=await this.listRuns();await Promise.all(i.map(t=>this.deleteRunState(t)));}};export{a as FileStore};//# sourceMappingURL=file.js.map
|
|
2
|
-
//# sourceMappingURL=file.js.map
|
package/dist/stores/file.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/stores/file.ts"],"names":["FileStore","options","runId","state","raw","err","key","value","allData","f","runs"],"mappings":"AAcO,IAAMA,CAAAA,CAAN,KAA4C,CACzC,SAAA,CACA,GAA0C,IAAA,CAC1C,IAAA,CAAqC,KAE7C,WAAA,CAAYC,CAAAA,CAA2B,CACrC,IAAA,CAAK,SAAA,CAAYA,EAAQ,UAC3B,CAEA,MAAc,aAAA,EAA+B,CAAA,CACvC,CAAC,IAAA,CAAK,EAAA,EAAM,CAAC,IAAA,CAAK,IAAA,IAEpB,KAAK,EAAA,CAAK,aAAa,aAAa,CAAA,CACpC,KAAK,IAAA,CAAO,aAAa,MAAM,CAAA,CAG/B,MAAM,IAAA,CAAK,EAAA,CAAG,MAAM,IAAA,CAAK,SAAA,CAAW,CAAE,SAAA,CAAW,IAAK,CAAC,GAE3D,CAEQ,OAAA,CAAQC,EAAuB,CACrC,OAAO,KAAK,IAAA,CAAM,IAAA,CAAK,KAAK,SAAA,CAAW,CAAA,EAAGA,CAAK,CAAA,SAAA,CAAW,CAC5D,CAEQ,QAAA,CAASA,CAAAA,CAAuB,CACtC,OAAO,IAAA,CAAK,KAAM,IAAA,CAAK,IAAA,CAAK,UAAW,CAAA,EAAGA,CAAK,YAAY,CAC7D,CAEA,MAAM,YAAA,CAAaA,CAAAA,CAAeC,EAAw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C,MAAM,QAAQ,GAAA,CAAIA,CAAAA,CAAK,IAAIR,CAAAA,EAAS,IAAA,CAAK,eAAeA,CAAK,CAAC,CAAC,EACjE,CACF","file":"file.js","sourcesContent":["/**\n * yaml-flow - File Store\n * \n * File-system based store for Node.js environments.\n * Stores each run as a JSON file in the specified directory.\n */\n\nimport type { StepMachineStore, StepMachineState } from '../step-machine/types.js';\n\nexport interface FileStoreOptions {\n /** Directory path for storing flow data */\n directory: string;\n}\n\nexport class FileStore implements StepMachineStore {\n private directory: string;\n private fs: typeof import('fs/promises') | null = null;\n private path: typeof import('path') | null = null;\n\n constructor(options: FileStoreOptions) {\n this.directory = options.directory;\n }\n\n private async ensureModules(): Promise<void> {\n if (!this.fs || !this.path) {\n // Dynamic import for Node.js modules\n this.fs = await import('fs/promises');\n this.path = await import('path');\n \n // Ensure directory exists\n await this.fs.mkdir(this.directory, { recursive: true });\n }\n }\n\n private runPath(runId: string): string {\n return this.path!.join(this.directory, `${runId}.run.json`);\n }\n\n private dataPath(runId: string): string {\n return this.path!.join(this.directory, `${runId}.data.json`);\n }\n\n async saveRunState(runId: string, state: StepMachineState): Promise<void> {\n await this.ensureModules();\n await this.fs!.writeFile(\n this.runPath(runId),\n JSON.stringify(state, null, 2),\n 'utf-8'\n );\n }\n\n async loadRunState(runId: string): Promise<StepMachineState | null> {\n await this.ensureModules();\n try {\n const raw = await this.fs!.readFile(this.runPath(runId), 'utf-8');\n return JSON.parse(raw);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return null;\n }\n throw err;\n }\n }\n\n async deleteRunState(runId: string): Promise<void> {\n await this.ensureModules();\n try {\n await this.fs!.unlink(this.runPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n try {\n await this.fs!.unlink(this.dataPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n }\n\n async setData(runId: string, key: string, value: unknown): Promise<void> {\n await this.ensureModules();\n const allData = await this.getAllData(runId);\n allData[key] = value;\n await this.fs!.writeFile(\n this.dataPath(runId),\n JSON.stringify(allData, null, 2),\n 'utf-8'\n );\n }\n\n async getData(runId: string, key: string): Promise<unknown> {\n const allData = await this.getAllData(runId);\n return allData[key];\n }\n\n async getAllData(runId: string): Promise<Record<string, unknown>> {\n await this.ensureModules();\n try {\n const raw = await this.fs!.readFile(this.dataPath(runId), 'utf-8');\n return JSON.parse(raw);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return {};\n }\n throw err;\n }\n }\n\n async clearData(runId: string): Promise<void> {\n await this.ensureModules();\n try {\n await this.fs!.unlink(this.dataPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n }\n\n async listRuns(): Promise<string[]> {\n await this.ensureModules();\n try {\n const files = await this.fs!.readdir(this.directory);\n return files\n .filter(f => f.endsWith('.run.json'))\n .map(f => f.replace('.run.json', ''));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return [];\n }\n throw err;\n }\n }\n\n /**\n * Clear all flow data from directory\n */\n async clearAll(): Promise<void> {\n await this.ensureModules();\n const runs = await this.listRuns();\n await Promise.all(runs.map(runId => this.deleteRunState(runId)));\n }\n}\n"]}
|
package/dist/stores/index.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var i=class{runs=new Map;data=new Map;async saveRunState(t,e){this.runs.set(t,{...e});}async loadRunState(t){let e=this.runs.get(t);return e?{...e}:null}async deleteRunState(t){this.runs.delete(t),this.data.delete(t);}async setData(t,e,a){this.data.has(t)||this.data.set(t,{});let r=this.data.get(t);r[e]=a;}async getData(t,e){return this.data.get(t)?.[e]}async getAllData(t){return {...this.data.get(t)??{}}}async clearData(t){this.data.delete(t);}async listRuns(){return Array.from(this.runs.keys())}clear(){this.runs.clear(),this.data.clear();}};var s=class{prefix;constructor(t={}){if(this.prefix=t.prefix??"yamlflow",typeof localStorage>"u")throw new Error("LocalStorageStore requires localStorage (browser environment)")}runKey(t){return `${this.prefix}:run:${t}`}dataKey(t){return `${this.prefix}:data:${t}`}indexKey(){return `${this.prefix}:runs`}async saveRunState(t,e){localStorage.setItem(this.runKey(t),JSON.stringify(e));let a=await this.listRuns();a.includes(t)||(a.push(t),localStorage.setItem(this.indexKey(),JSON.stringify(a)));}async loadRunState(t){let e=localStorage.getItem(this.runKey(t));return e?JSON.parse(e):null}async deleteRunState(t){localStorage.removeItem(this.runKey(t)),localStorage.removeItem(this.dataKey(t));let a=(await this.listRuns()).filter(r=>r!==t);localStorage.setItem(this.indexKey(),JSON.stringify(a));}async setData(t,e,a){let r=await this.getAllData(t);r[e]=a,localStorage.setItem(this.dataKey(t),JSON.stringify(r));}async getData(t,e){return (await this.getAllData(t))[e]}async getAllData(t){let e=localStorage.getItem(this.dataKey(t));return e?JSON.parse(e):{}}async clearData(t){localStorage.removeItem(this.dataKey(t));}async listRuns(){let t=localStorage.getItem(this.indexKey());return t?JSON.parse(t):[]}clearAll(){let t=[];for(let e=0;e<localStorage.length;e++){let a=localStorage.key(e);a?.startsWith(this.prefix+":")&&t.push(a);}t.forEach(e=>localStorage.removeItem(e));}};var n=class{directory;fs=null;path=null;constructor(t){this.directory=t.directory;}async ensureModules(){(!this.fs||!this.path)&&(this.fs=await import('fs/promises'),this.path=await import('path'),await this.fs.mkdir(this.directory,{recursive:true}));}runPath(t){return this.path.join(this.directory,`${t}.run.json`)}dataPath(t){return this.path.join(this.directory,`${t}.data.json`)}async saveRunState(t,e){await this.ensureModules(),await this.fs.writeFile(this.runPath(t),JSON.stringify(e,null,2),"utf-8");}async loadRunState(t){await this.ensureModules();try{let e=await this.fs.readFile(this.runPath(t),"utf-8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async deleteRunState(t){await this.ensureModules();try{await this.fs.unlink(this.runPath(t));}catch(e){if(e.code!=="ENOENT")throw e}try{await this.fs.unlink(this.dataPath(t));}catch(e){if(e.code!=="ENOENT")throw e}}async setData(t,e,a){await this.ensureModules();let r=await this.getAllData(t);r[e]=a,await this.fs.writeFile(this.dataPath(t),JSON.stringify(r,null,2),"utf-8");}async getData(t,e){return (await this.getAllData(t))[e]}async getAllData(t){await this.ensureModules();try{let e=await this.fs.readFile(this.dataPath(t),"utf-8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return {};throw e}}async clearData(t){await this.ensureModules();try{await this.fs.unlink(this.dataPath(t));}catch(e){if(e.code!=="ENOENT")throw e}}async listRuns(){await this.ensureModules();try{return (await this.fs.readdir(this.directory)).filter(e=>e.endsWith(".run.json")).map(e=>e.replace(".run.json",""))}catch(t){if(t.code==="ENOENT")return [];throw t}}async clearAll(){await this.ensureModules();let t=await this.listRuns();await Promise.all(t.map(e=>this.deleteRunState(e)));}};exports.FileStore=n;exports.LocalStorageStore=s;exports.MemoryStore=i;//# sourceMappingURL=index.cjs.map
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/stores/memory.ts","../../src/stores/localStorage.ts","../../src/stores/file.ts"],"names":["MemoryStore","runId","state","key","value","runData","LocalStorageStore","options","runs","raw","filtered","id","allData","keysToRemove","i","FileStore","err","f"],"mappings":"aASO,IAAMA,CAAAA,CAAN,KAA8C,CAC3C,IAAA,CAAsC,IAAI,GAAA,CAC1C,IAAA,CAA6C,IAAI,GAAA,CAEzD,MAAM,YAAA,CAAaC,EAAeC,CAAAA,CAAwC,CACxE,KAAK,IAAA,CAAK,GAAA,CAAID,EAAO,CAAE,GAAGC,CAAM,CAAC,EACnC,CAEA,MAAM,YAAA,CAAaD,CAAAA,CAAiD,CAClE,IAAMC,CAAAA,CAAQ,KAAK,IAAA,CAAK,GAAA,CAAID,CAAK,CAAA,CACjC,OAAOC,CAAAA,CAAQ,CAAE,GAAGA,CAAM,EAAI,IAChC,CA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AAMQ,CAAG,CACvB,CAAA,MAASO,CAAAA,CAAc,CACrB,GAAKA,CAAAA,CAA8B,OAAS,QAAA,CAC1C,OAAO,EAAC,CAEV,MAAMA,CACR,CACF,CAEA,MAAM,UAAUf,CAAAA,CAA8B,CAC5C,MAAM,IAAA,CAAK,aAAA,EAAc,CACzB,GAAI,CACF,MAAM,KAAK,EAAA,CAAI,MAAA,CAAO,KAAK,QAAA,CAASA,CAAK,CAAC,EAC5C,CAAA,MAASe,CAAAA,CAAc,CACrB,GAAKA,CAAAA,CAA8B,OAAS,QAAA,CAAU,MAAMA,CAC9D,CACF,CAEA,MAAM,QAAA,EAA8B,CAClC,MAAM,IAAA,CAAK,aAAA,EAAc,CACzB,GAAI,CAEF,OAAA,CADc,MAAM,IAAA,CAAK,EAAA,CAAI,QAAQ,IAAA,CAAK,SAAS,CAAA,EAEhD,MAAA,CAAOC,CAAAA,EAAKA,CAAAA,CAAE,SAAS,WAAW,CAAC,EACnC,GAAA,CAAIA,CAAAA,EAAKA,EAAE,OAAA,CAAQ,WAAA,CAAa,EAAE,CAAC,CACxC,CAAA,MAASD,EAAc,CACrB,GAAKA,EAA8B,IAAA,GAAS,QAAA,CAC1C,OAAO,EAAC,CAEV,MAAMA,CACR,CACF,CAKA,MAAM,QAAA,EAA0B,CAC9B,MAAM,IAAA,CAAK,aAAA,GACX,IAAMR,CAAAA,CAAO,MAAM,IAAA,CAAK,QAAA,EAAS,CACjC,MAAM,OAAA,CAAQ,GAAA,CAAIA,CAAAA,CAAK,GAAA,CAAIP,CAAAA,EAAS,IAAA,CAAK,eAAeA,CAAK,CAAC,CAAC,EACjE,CACF","file":"index.cjs","sourcesContent":["/**\n * yaml-flow - Memory Store\n * \n * In-memory store implementation. Works in both browser and Node.js.\n * Data is lost when the process exits - use for testing or short-lived flows.\n */\n\nimport type { StepMachineStore, StepMachineState } from '../step-machine/types.js';\n\nexport class MemoryStore implements StepMachineStore {\n private runs: Map<string, StepMachineState> = new Map();\n private data: Map<string, Record<string, unknown>> = new Map();\n\n async saveRunState(runId: string, state: StepMachineState): Promise<void> {\n this.runs.set(runId, { ...state });\n }\n\n async loadRunState(runId: string): Promise<StepMachineState | null> {\n const state = this.runs.get(runId);\n return state ? { ...state } : null;\n }\n\n async deleteRunState(runId: string): Promise<void> {\n this.runs.delete(runId);\n this.data.delete(runId);\n }\n\n async setData(runId: string, key: string, value: unknown): Promise<void> {\n if (!this.data.has(runId)) {\n this.data.set(runId, {});\n }\n const runData = this.data.get(runId)!;\n runData[key] = value;\n }\n\n async getData(runId: string, key: string): Promise<unknown> {\n return this.data.get(runId)?.[key];\n }\n\n async getAllData(runId: string): Promise<Record<string, unknown>> {\n return { ...(this.data.get(runId) ?? {}) };\n }\n\n async clearData(runId: string): Promise<void> {\n this.data.delete(runId);\n }\n\n async listRuns(): Promise<string[]> {\n return Array.from(this.runs.keys());\n }\n\n /**\n * Clear all data (useful for testing)\n */\n clear(): void {\n this.runs.clear();\n this.data.clear();\n }\n}\n","/**\n * yaml-flow - LocalStorage Store\n * \n * Browser localStorage-based store implementation.\n * Data persists across page reloads but is limited to ~5MB per origin.\n */\n\nimport type { StepMachineStore, StepMachineState } from '../step-machine/types.js';\n\nexport interface LocalStorageStoreOptions {\n /** Key prefix for namespacing (default: 'yamlflow') */\n prefix?: string;\n}\n\nexport class LocalStorageStore implements StepMachineStore {\n private prefix: string;\n\n constructor(options: LocalStorageStoreOptions = {}) {\n this.prefix = options.prefix ?? 'yamlflow';\n \n // Ensure localStorage is available\n if (typeof localStorage === 'undefined') {\n throw new Error('LocalStorageStore requires localStorage (browser environment)');\n }\n }\n\n private runKey(runId: string): string {\n return `${this.prefix}:run:${runId}`;\n }\n\n private dataKey(runId: string): string {\n return `${this.prefix}:data:${runId}`;\n }\n\n private indexKey(): string {\n return `${this.prefix}:runs`;\n }\n\n async saveRunState(runId: string, state: StepMachineState): Promise<void> {\n localStorage.setItem(this.runKey(runId), JSON.stringify(state));\n \n // Update run index\n const runs = await this.listRuns();\n if (!runs.includes(runId)) {\n runs.push(runId);\n localStorage.setItem(this.indexKey(), JSON.stringify(runs));\n }\n }\n\n async loadRunState(runId: string): Promise<StepMachineState | null> {\n const raw = localStorage.getItem(this.runKey(runId));\n return raw ? JSON.parse(raw) : null;\n }\n\n async deleteRunState(runId: string): Promise<void> {\n localStorage.removeItem(this.runKey(runId));\n localStorage.removeItem(this.dataKey(runId));\n \n // Update run index\n const runs = await this.listRuns();\n const filtered = runs.filter(id => id !== runId);\n localStorage.setItem(this.indexKey(), JSON.stringify(filtered));\n }\n\n async setData(runId: string, key: string, value: unknown): Promise<void> {\n const allData = await this.getAllData(runId);\n allData[key] = value;\n localStorage.setItem(this.dataKey(runId), JSON.stringify(allData));\n }\n\n async getData(runId: string, key: string): Promise<unknown> {\n const allData = await this.getAllData(runId);\n return allData[key];\n }\n\n async getAllData(runId: string): Promise<Record<string, unknown>> {\n const raw = localStorage.getItem(this.dataKey(runId));\n return raw ? JSON.parse(raw) : {};\n }\n\n async clearData(runId: string): Promise<void> {\n localStorage.removeItem(this.dataKey(runId));\n }\n\n async listRuns(): Promise<string[]> {\n const raw = localStorage.getItem(this.indexKey());\n return raw ? JSON.parse(raw) : [];\n }\n\n /**\n * Clear all flow data from localStorage\n */\n clearAll(): void {\n const keysToRemove: string[] = [];\n \n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i);\n if (key?.startsWith(this.prefix + ':')) {\n keysToRemove.push(key);\n }\n }\n \n keysToRemove.forEach(key => localStorage.removeItem(key));\n }\n}\n","/**\n * yaml-flow - File Store\n * \n * File-system based store for Node.js environments.\n * Stores each run as a JSON file in the specified directory.\n */\n\nimport type { StepMachineStore, StepMachineState } from '../step-machine/types.js';\n\nexport interface FileStoreOptions {\n /** Directory path for storing flow data */\n directory: string;\n}\n\nexport class FileStore implements StepMachineStore {\n private directory: string;\n private fs: typeof import('fs/promises') | null = null;\n private path: typeof import('path') | null = null;\n\n constructor(options: FileStoreOptions) {\n this.directory = options.directory;\n }\n\n private async ensureModules(): Promise<void> {\n if (!this.fs || !this.path) {\n // Dynamic import for Node.js modules\n this.fs = await import('fs/promises');\n this.path = await import('path');\n \n // Ensure directory exists\n await this.fs.mkdir(this.directory, { recursive: true });\n }\n }\n\n private runPath(runId: string): string {\n return this.path!.join(this.directory, `${runId}.run.json`);\n }\n\n private dataPath(runId: string): string {\n return this.path!.join(this.directory, `${runId}.data.json`);\n }\n\n async saveRunState(runId: string, state: StepMachineState): Promise<void> {\n await this.ensureModules();\n await this.fs!.writeFile(\n this.runPath(runId),\n JSON.stringify(state, null, 2),\n 'utf-8'\n );\n }\n\n async loadRunState(runId: string): Promise<StepMachineState | null> {\n await this.ensureModules();\n try {\n const raw = await this.fs!.readFile(this.runPath(runId), 'utf-8');\n return JSON.parse(raw);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return null;\n }\n throw err;\n }\n }\n\n async deleteRunState(runId: string): Promise<void> {\n await this.ensureModules();\n try {\n await this.fs!.unlink(this.runPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n try {\n await this.fs!.unlink(this.dataPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n }\n\n async setData(runId: string, key: string, value: unknown): Promise<void> {\n await this.ensureModules();\n const allData = await this.getAllData(runId);\n allData[key] = value;\n await this.fs!.writeFile(\n this.dataPath(runId),\n JSON.stringify(allData, null, 2),\n 'utf-8'\n );\n }\n\n async getData(runId: string, key: string): Promise<unknown> {\n const allData = await this.getAllData(runId);\n return allData[key];\n }\n\n async getAllData(runId: string): Promise<Record<string, unknown>> {\n await this.ensureModules();\n try {\n const raw = await this.fs!.readFile(this.dataPath(runId), 'utf-8');\n return JSON.parse(raw);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return {};\n }\n throw err;\n }\n }\n\n async clearData(runId: string): Promise<void> {\n await this.ensureModules();\n try {\n await this.fs!.unlink(this.dataPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n }\n\n async listRuns(): Promise<string[]> {\n await this.ensureModules();\n try {\n const files = await this.fs!.readdir(this.directory);\n return files\n .filter(f => f.endsWith('.run.json'))\n .map(f => f.replace('.run.json', ''));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return [];\n }\n throw err;\n }\n }\n\n /**\n * Clear all flow data from directory\n */\n async clearAll(): Promise<void> {\n await this.ensureModules();\n const runs = await this.listRuns();\n await Promise.all(runs.map(runId => this.deleteRunState(runId)));\n }\n}\n"]}
|
package/dist/stores/index.d.cts
DELETED
package/dist/stores/index.d.ts
DELETED
package/dist/stores/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var i=class{runs=new Map;data=new Map;async saveRunState(t,e){this.runs.set(t,{...e});}async loadRunState(t){let e=this.runs.get(t);return e?{...e}:null}async deleteRunState(t){this.runs.delete(t),this.data.delete(t);}async setData(t,e,a){this.data.has(t)||this.data.set(t,{});let r=this.data.get(t);r[e]=a;}async getData(t,e){return this.data.get(t)?.[e]}async getAllData(t){return {...this.data.get(t)??{}}}async clearData(t){this.data.delete(t);}async listRuns(){return Array.from(this.runs.keys())}clear(){this.runs.clear(),this.data.clear();}};var s=class{prefix;constructor(t={}){if(this.prefix=t.prefix??"yamlflow",typeof localStorage>"u")throw new Error("LocalStorageStore requires localStorage (browser environment)")}runKey(t){return `${this.prefix}:run:${t}`}dataKey(t){return `${this.prefix}:data:${t}`}indexKey(){return `${this.prefix}:runs`}async saveRunState(t,e){localStorage.setItem(this.runKey(t),JSON.stringify(e));let a=await this.listRuns();a.includes(t)||(a.push(t),localStorage.setItem(this.indexKey(),JSON.stringify(a)));}async loadRunState(t){let e=localStorage.getItem(this.runKey(t));return e?JSON.parse(e):null}async deleteRunState(t){localStorage.removeItem(this.runKey(t)),localStorage.removeItem(this.dataKey(t));let a=(await this.listRuns()).filter(r=>r!==t);localStorage.setItem(this.indexKey(),JSON.stringify(a));}async setData(t,e,a){let r=await this.getAllData(t);r[e]=a,localStorage.setItem(this.dataKey(t),JSON.stringify(r));}async getData(t,e){return (await this.getAllData(t))[e]}async getAllData(t){let e=localStorage.getItem(this.dataKey(t));return e?JSON.parse(e):{}}async clearData(t){localStorage.removeItem(this.dataKey(t));}async listRuns(){let t=localStorage.getItem(this.indexKey());return t?JSON.parse(t):[]}clearAll(){let t=[];for(let e=0;e<localStorage.length;e++){let a=localStorage.key(e);a?.startsWith(this.prefix+":")&&t.push(a);}t.forEach(e=>localStorage.removeItem(e));}};var n=class{directory;fs=null;path=null;constructor(t){this.directory=t.directory;}async ensureModules(){(!this.fs||!this.path)&&(this.fs=await import('fs/promises'),this.path=await import('path'),await this.fs.mkdir(this.directory,{recursive:true}));}runPath(t){return this.path.join(this.directory,`${t}.run.json`)}dataPath(t){return this.path.join(this.directory,`${t}.data.json`)}async saveRunState(t,e){await this.ensureModules(),await this.fs.writeFile(this.runPath(t),JSON.stringify(e,null,2),"utf-8");}async loadRunState(t){await this.ensureModules();try{let e=await this.fs.readFile(this.runPath(t),"utf-8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async deleteRunState(t){await this.ensureModules();try{await this.fs.unlink(this.runPath(t));}catch(e){if(e.code!=="ENOENT")throw e}try{await this.fs.unlink(this.dataPath(t));}catch(e){if(e.code!=="ENOENT")throw e}}async setData(t,e,a){await this.ensureModules();let r=await this.getAllData(t);r[e]=a,await this.fs.writeFile(this.dataPath(t),JSON.stringify(r,null,2),"utf-8");}async getData(t,e){return (await this.getAllData(t))[e]}async getAllData(t){await this.ensureModules();try{let e=await this.fs.readFile(this.dataPath(t),"utf-8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return {};throw e}}async clearData(t){await this.ensureModules();try{await this.fs.unlink(this.dataPath(t));}catch(e){if(e.code!=="ENOENT")throw e}}async listRuns(){await this.ensureModules();try{return (await this.fs.readdir(this.directory)).filter(e=>e.endsWith(".run.json")).map(e=>e.replace(".run.json",""))}catch(t){if(t.code==="ENOENT")return [];throw t}}async clearAll(){await this.ensureModules();let t=await this.listRuns();await Promise.all(t.map(e=>this.deleteRunState(e)));}};export{n as FileStore,s as LocalStorageStore,i as MemoryStore};//# sourceMappingURL=index.js.map
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/dist/stores/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/stores/memory.ts","../../src/stores/localStorage.ts","../../src/stores/file.ts"],"names":["MemoryStore","runId","state","key","value","runData","LocalStorageStore","options","runs","raw","filtered","id","allData","keysToRemove","i","FileStore","err","f"],"mappings":"AASO,IAAMA,CAAAA,CAAN,KAA8C,CAC3C,IAAA,CAAsC,IAAI,GAAA,CAC1C,IAAA,CAA6C,IAAI,GAAA,CAEzD,MAAM,YAAA,CAAaC,EAAeC,CAAAA,CAAwC,CACxE,KAAK,IAAA,CAAK,GAAA,CAAID,EAAO,CAAE,GAAGC,CAAM,CAAC,EACnC,CAEA,MAAM,YAAA,CAAaD,CAAAA,CAAiD,CAClE,IAAMC,CAAAA,CAAQ,KAAK,IAAA,CAAK,GAAA,CAAID,CAAK,CAAA,CACjC,OAAOC,CAAAA,CAAQ,CAAE,GAAGA,CAAM,EAAI,IAChC,CAEA,MAAM,cAAA,CAAeD,CAAAA,CAA8B,CACjD,IAAA,CAAK,IAAA,CAAK,MAAA,CAAOA,CAAK,CAAA,CACtB,IAAA,CAAK,KAAK,MAAA,CAAOA,CAAK,EACxB,CAEA,MAAM,OAAA,CAAQA,CAAAA,CAAeE,CAAAA,CAAaC,CAAAA,CAA+B,CAClE,IAAA,CAAK,IAAA,CAAK,IAAIH,CAAK,CAAA,EACtB,KAAK,IAAA,CAAK,GAAA,CAAIA,CAAAA,CAAO,EAAE,CAAA,CAEzB,IAAMI,CAAAA,CAAU,IAAA,CAAK,K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A,CAC9D,CACF,CAEA,MAAM,QAAA,EAA8B,CAClC,MAAM,IAAA,CAAK,aAAA,EAAc,CACzB,GAAI,CAEF,OAAA,CADc,MAAM,IAAA,CAAK,EAAA,CAAI,QAAQ,IAAA,CAAK,SAAS,CAAA,EAEhD,MAAA,CAAOC,CAAAA,EAAKA,CAAAA,CAAE,SAAS,WAAW,CAAC,EACnC,GAAA,CAAIA,CAAAA,EAAKA,EAAE,OAAA,CAAQ,WAAA,CAAa,EAAE,CAAC,CACxC,CAAA,MAASD,EAAc,CACrB,GAAKA,EAA8B,IAAA,GAAS,QAAA,CAC1C,OAAO,EAAC,CAEV,MAAMA,CACR,CACF,CAKA,MAAM,QAAA,EAA0B,CAC9B,MAAM,IAAA,CAAK,aAAA,GACX,IAAMR,CAAAA,CAAO,MAAM,IAAA,CAAK,QAAA,EAAS,CACjC,MAAM,OAAA,CAAQ,GAAA,CAAIA,CAAAA,CAAK,GAAA,CAAIP,CAAAA,EAAS,IAAA,CAAK,eAAeA,CAAK,CAAC,CAAC,EACjE,CACF","file":"index.js","sourcesContent":["/**\n * yaml-flow - Memory Store\n * \n * In-memory store implementation. Works in both browser and Node.js.\n * Data is lost when the process exits - use for testing or short-lived flows.\n */\n\nimport type { StepMachineStore, StepMachineState } from '../step-machine/types.js';\n\nexport class MemoryStore implements StepMachineStore {\n private runs: Map<string, StepMachineState> = new Map();\n private data: Map<string, Record<string, unknown>> = new Map();\n\n async saveRunState(runId: string, state: StepMachineState): Promise<void> {\n this.runs.set(runId, { ...state });\n }\n\n async loadRunState(runId: string): Promise<StepMachineState | null> {\n const state = this.runs.get(runId);\n return state ? { ...state } : null;\n }\n\n async deleteRunState(runId: string): Promise<void> {\n this.runs.delete(runId);\n this.data.delete(runId);\n }\n\n async setData(runId: string, key: string, value: unknown): Promise<void> {\n if (!this.data.has(runId)) {\n this.data.set(runId, {});\n }\n const runData = this.data.get(runId)!;\n runData[key] = value;\n }\n\n async getData(runId: string, key: string): Promise<unknown> {\n return this.data.get(runId)?.[key];\n }\n\n async getAllData(runId: string): Promise<Record<string, unknown>> {\n return { ...(this.data.get(runId) ?? {}) };\n }\n\n async clearData(runId: string): Promise<void> {\n this.data.delete(runId);\n }\n\n async listRuns(): Promise<string[]> {\n return Array.from(this.runs.keys());\n }\n\n /**\n * Clear all data (useful for testing)\n */\n clear(): void {\n this.runs.clear();\n this.data.clear();\n }\n}\n","/**\n * yaml-flow - LocalStorage Store\n * \n * Browser localStorage-based store implementation.\n * Data persists across page reloads but is limited to ~5MB per origin.\n */\n\nimport type { StepMachineStore, StepMachineState } from '../step-machine/types.js';\n\nexport interface LocalStorageStoreOptions {\n /** Key prefix for namespacing (default: 'yamlflow') */\n prefix?: string;\n}\n\nexport class LocalStorageStore implements StepMachineStore {\n private prefix: string;\n\n constructor(options: LocalStorageStoreOptions = {}) {\n this.prefix = options.prefix ?? 'yamlflow';\n \n // Ensure localStorage is available\n if (typeof localStorage === 'undefined') {\n throw new Error('LocalStorageStore requires localStorage (browser environment)');\n }\n }\n\n private runKey(runId: string): string {\n return `${this.prefix}:run:${runId}`;\n }\n\n private dataKey(runId: string): string {\n return `${this.prefix}:data:${runId}`;\n }\n\n private indexKey(): string {\n return `${this.prefix}:runs`;\n }\n\n async saveRunState(runId: string, state: StepMachineState): Promise<void> {\n localStorage.setItem(this.runKey(runId), JSON.stringify(state));\n \n // Update run index\n const runs = await this.listRuns();\n if (!runs.includes(runId)) {\n runs.push(runId);\n localStorage.setItem(this.indexKey(), JSON.stringify(runs));\n }\n }\n\n async loadRunState(runId: string): Promise<StepMachineState | null> {\n const raw = localStorage.getItem(this.runKey(runId));\n return raw ? JSON.parse(raw) : null;\n }\n\n async deleteRunState(runId: string): Promise<void> {\n localStorage.removeItem(this.runKey(runId));\n localStorage.removeItem(this.dataKey(runId));\n \n // Update run index\n const runs = await this.listRuns();\n const filtered = runs.filter(id => id !== runId);\n localStorage.setItem(this.indexKey(), JSON.stringify(filtered));\n }\n\n async setData(runId: string, key: string, value: unknown): Promise<void> {\n const allData = await this.getAllData(runId);\n allData[key] = value;\n localStorage.setItem(this.dataKey(runId), JSON.stringify(allData));\n }\n\n async getData(runId: string, key: string): Promise<unknown> {\n const allData = await this.getAllData(runId);\n return allData[key];\n }\n\n async getAllData(runId: string): Promise<Record<string, unknown>> {\n const raw = localStorage.getItem(this.dataKey(runId));\n return raw ? JSON.parse(raw) : {};\n }\n\n async clearData(runId: string): Promise<void> {\n localStorage.removeItem(this.dataKey(runId));\n }\n\n async listRuns(): Promise<string[]> {\n const raw = localStorage.getItem(this.indexKey());\n return raw ? JSON.parse(raw) : [];\n }\n\n /**\n * Clear all flow data from localStorage\n */\n clearAll(): void {\n const keysToRemove: string[] = [];\n \n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i);\n if (key?.startsWith(this.prefix + ':')) {\n keysToRemove.push(key);\n }\n }\n \n keysToRemove.forEach(key => localStorage.removeItem(key));\n }\n}\n","/**\n * yaml-flow - File Store\n * \n * File-system based store for Node.js environments.\n * Stores each run as a JSON file in the specified directory.\n */\n\nimport type { StepMachineStore, StepMachineState } from '../step-machine/types.js';\n\nexport interface FileStoreOptions {\n /** Directory path for storing flow data */\n directory: string;\n}\n\nexport class FileStore implements StepMachineStore {\n private directory: string;\n private fs: typeof import('fs/promises') | null = null;\n private path: typeof import('path') | null = null;\n\n constructor(options: FileStoreOptions) {\n this.directory = options.directory;\n }\n\n private async ensureModules(): Promise<void> {\n if (!this.fs || !this.path) {\n // Dynamic import for Node.js modules\n this.fs = await import('fs/promises');\n this.path = await import('path');\n \n // Ensure directory exists\n await this.fs.mkdir(this.directory, { recursive: true });\n }\n }\n\n private runPath(runId: string): string {\n return this.path!.join(this.directory, `${runId}.run.json`);\n }\n\n private dataPath(runId: string): string {\n return this.path!.join(this.directory, `${runId}.data.json`);\n }\n\n async saveRunState(runId: string, state: StepMachineState): Promise<void> {\n await this.ensureModules();\n await this.fs!.writeFile(\n this.runPath(runId),\n JSON.stringify(state, null, 2),\n 'utf-8'\n );\n }\n\n async loadRunState(runId: string): Promise<StepMachineState | null> {\n await this.ensureModules();\n try {\n const raw = await this.fs!.readFile(this.runPath(runId), 'utf-8');\n return JSON.parse(raw);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return null;\n }\n throw err;\n }\n }\n\n async deleteRunState(runId: string): Promise<void> {\n await this.ensureModules();\n try {\n await this.fs!.unlink(this.runPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n try {\n await this.fs!.unlink(this.dataPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n }\n\n async setData(runId: string, key: string, value: unknown): Promise<void> {\n await this.ensureModules();\n const allData = await this.getAllData(runId);\n allData[key] = value;\n await this.fs!.writeFile(\n this.dataPath(runId),\n JSON.stringify(allData, null, 2),\n 'utf-8'\n );\n }\n\n async getData(runId: string, key: string): Promise<unknown> {\n const allData = await this.getAllData(runId);\n return allData[key];\n }\n\n async getAllData(runId: string): Promise<Record<string, unknown>> {\n await this.ensureModules();\n try {\n const raw = await this.fs!.readFile(this.dataPath(runId), 'utf-8');\n return JSON.parse(raw);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return {};\n }\n throw err;\n }\n }\n\n async clearData(runId: string): Promise<void> {\n await this.ensureModules();\n try {\n await this.fs!.unlink(this.dataPath(runId));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n }\n }\n\n async listRuns(): Promise<string[]> {\n await this.ensureModules();\n try {\n const files = await this.fs!.readdir(this.directory);\n return files\n .filter(f => f.endsWith('.run.json'))\n .map(f => f.replace('.run.json', ''));\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n return [];\n }\n throw err;\n }\n }\n\n /**\n * Clear all flow data from directory\n */\n async clearAll(): Promise<void> {\n await this.ensureModules();\n const runs = await this.listRuns();\n await Promise.all(runs.map(runId => this.deleteRunState(runId)));\n }\n}\n"]}
|