@synnaxlabs/client 0.56.2 → 0.57.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/dist/client-B08VDLSA.js +14463 -0
- package/dist/client-B08VDLSA.js.map +1 -0
- package/dist/client.js +1128 -14876
- package/dist/client.js.map +1 -0
- package/dist/src/access/client.d.ts +10 -1
- package/dist/src/access/client.d.ts.map +1 -1
- package/dist/src/access/enforce.d.ts.map +1 -1
- package/dist/src/access/external.d.ts +1 -0
- package/dist/src/access/external.d.ts.map +1 -1
- package/dist/src/access/granted.d.ts +39 -0
- package/dist/src/access/granted.d.ts.map +1 -0
- package/dist/src/access/policy/client.d.ts +136 -147
- package/dist/src/access/policy/client.d.ts.map +1 -1
- package/dist/src/access/policy/types.gen.d.ts +15 -68
- package/dist/src/access/policy/types.gen.d.ts.map +1 -1
- package/dist/src/access/role/client.d.ts +77 -58
- package/dist/src/access/role/client.d.ts.map +1 -1
- package/dist/src/access/role/types.gen.d.ts +8 -14
- package/dist/src/access/role/types.gen.d.ts.map +1 -1
- package/dist/src/actions/actions.d.ts +5 -6
- package/dist/src/actions/actions.d.ts.map +1 -1
- package/dist/src/actions/controller.d.ts +194 -0
- package/dist/src/actions/controller.d.ts.map +1 -0
- package/dist/src/actions/external.d.ts +1 -0
- package/dist/src/actions/external.d.ts.map +1 -1
- package/dist/src/arc/actions.d.ts +575 -0
- package/dist/src/arc/actions.d.ts.map +1 -0
- package/dist/src/arc/actions.gen.d.ts +1439 -0
- package/dist/src/arc/actions.gen.d.ts.map +1 -0
- package/dist/src/arc/client.d.ts +97 -13
- package/dist/src/arc/client.d.ts.map +1 -1
- package/dist/src/arc/compiler/types.gen.d.ts +3 -3
- package/dist/src/arc/compiler/types.gen.d.ts.map +1 -1
- package/dist/src/arc/external.d.ts +2 -0
- package/dist/src/arc/external.d.ts.map +1 -1
- package/dist/src/arc/graph/types.gen.d.ts +45 -597
- package/dist/src/arc/graph/types.gen.d.ts.map +1 -1
- package/dist/src/arc/ir/index.d.ts +1 -1
- package/dist/src/arc/ir/index.d.ts.map +1 -1
- package/dist/src/arc/ir/ir.d.ts +2 -0
- package/dist/src/arc/ir/ir.d.ts.map +1 -0
- package/dist/src/arc/ir/types.gen.d.ts +58 -2807
- package/dist/src/arc/ir/types.gen.d.ts.map +1 -1
- package/dist/src/arc/module/types.gen.d.ts +18 -1090
- package/dist/src/arc/module/types.gen.d.ts.map +1 -1
- package/dist/src/arc/program/types.gen.d.ts +18 -1090
- package/dist/src/arc/program/types.gen.d.ts.map +1 -1
- package/dist/src/arc/text/types.gen.d.ts +54 -1
- package/dist/src/arc/text/types.gen.d.ts.map +1 -1
- package/dist/src/arc/types/types.gen.d.ts +35 -153
- package/dist/src/arc/types/types.gen.d.ts.map +1 -1
- package/dist/src/arc/types.gen.d.ts +98 -2278
- package/dist/src/arc/types.gen.d.ts.map +1 -1
- package/dist/src/auth/auth.d.ts +14 -2
- package/dist/src/auth/auth.d.ts.map +1 -1
- package/dist/src/channel/client.d.ts +113 -75
- package/dist/src/channel/client.d.ts.map +1 -1
- package/dist/src/channel/external.d.ts +0 -1
- package/dist/src/channel/external.d.ts.map +1 -1
- package/dist/src/channel/payload.d.ts +65 -56
- package/dist/src/channel/payload.d.ts.map +1 -1
- package/dist/src/channel/types.gen.d.ts +26 -73
- package/dist/src/channel/types.gen.d.ts.map +1 -1
- package/dist/src/channel/writer.d.ts +1 -3
- package/dist/src/channel/writer.d.ts.map +1 -1
- package/dist/src/client.d.ts +55 -27
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/connection/client.d.ts +146 -0
- package/dist/src/connection/client.d.ts.map +1 -0
- package/dist/src/connection/external.d.ts +3 -0
- package/dist/src/connection/external.d.ts.map +1 -0
- package/dist/src/connection/index.d.ts +1 -1
- package/dist/src/connection/index.d.ts.map +1 -1
- package/dist/src/connection/status.d.ts +252 -0
- package/dist/src/connection/status.d.ts.map +1 -0
- package/dist/src/control/client.d.ts +31 -7
- package/dist/src/control/client.d.ts.map +1 -1
- package/dist/src/control/state.d.ts +47 -16
- package/dist/src/control/state.d.ts.map +1 -1
- package/dist/src/device/client.d.ts +59 -17
- package/dist/src/device/client.d.ts.map +1 -1
- package/dist/src/device/types.gen.d.ts +17 -67
- package/dist/src/device/types.gen.d.ts.map +1 -1
- package/dist/src/errors.d.ts +17 -20
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/ethercat/external.d.ts +2 -0
- package/dist/src/ethercat/external.d.ts.map +1 -0
- package/dist/src/ethercat/index.d.ts +2 -0
- package/dist/src/ethercat/index.d.ts.map +1 -0
- package/dist/src/ethercat/types.gen.d.ts +243 -0
- package/dist/src/ethercat/types.gen.d.ts.map +1 -0
- package/dist/src/framer/adapter.d.ts +8 -5
- package/dist/src/framer/adapter.d.ts.map +1 -1
- package/dist/src/framer/benchutil.d.ts +19 -0
- package/dist/src/framer/benchutil.d.ts.map +1 -0
- package/dist/src/framer/cache/cache.d.ts +38 -0
- package/dist/src/framer/cache/cache.d.ts.map +1 -0
- package/dist/src/framer/cache/dynamic.d.ts +71 -0
- package/dist/src/framer/cache/dynamic.d.ts.map +1 -0
- package/dist/src/framer/cache/reader.d.ts +43 -0
- package/dist/src/framer/cache/reader.d.ts.map +1 -0
- package/dist/src/framer/cache/static.d.ts +66 -0
- package/dist/src/framer/cache/static.d.ts.map +1 -0
- package/dist/src/framer/cache/streamer.d.ts +86 -0
- package/dist/src/framer/cache/streamer.d.ts.map +1 -0
- package/dist/src/framer/cache/transform.d.ts +18 -0
- package/dist/src/framer/cache/transform.d.ts.map +1 -0
- package/dist/src/framer/cache/unary.d.ts +37 -0
- package/dist/src/framer/cache/unary.d.ts.map +1 -0
- package/dist/src/framer/client.d.ts +35 -14
- package/dist/src/framer/client.d.ts.map +1 -1
- package/dist/src/framer/codec.d.ts.map +1 -1
- package/dist/src/framer/deleter.d.ts +3 -2
- package/dist/src/framer/deleter.d.ts.map +1 -1
- package/dist/src/framer/external.d.ts +6 -0
- package/dist/src/framer/external.d.ts.map +1 -1
- package/dist/src/framer/feed.d.ts +40 -0
- package/dist/src/framer/feed.d.ts.map +1 -0
- package/dist/src/framer/frame.d.ts +16 -20
- package/dist/src/framer/frame.d.ts.map +1 -1
- package/dist/src/framer/hardened.d.ts +70 -0
- package/dist/src/framer/hardened.d.ts.map +1 -0
- package/dist/src/framer/iterator.d.ts +36 -43
- package/dist/src/framer/iterator.d.ts.map +1 -1
- package/dist/src/framer/reader.d.ts +3 -2
- package/dist/src/framer/reader.d.ts.map +1 -1
- package/dist/src/framer/streamer.d.ts +132 -205
- package/dist/src/framer/streamer.d.ts.map +1 -1
- package/dist/src/framer/writer.d.ts +130 -161
- package/dist/src/framer/writer.d.ts.map +1 -1
- package/dist/src/group/client.d.ts +66 -9
- package/dist/src/group/client.d.ts.map +1 -1
- package/dist/src/group/types.gen.d.ts +2 -2
- package/dist/src/http/external.d.ts +2 -0
- package/dist/src/http/external.d.ts.map +1 -0
- package/dist/src/http/index.d.ts +2 -0
- package/dist/src/http/index.d.ts.map +1 -0
- package/dist/src/http/types.gen.d.ts +451 -0
- package/dist/src/http/types.gen.d.ts.map +1 -0
- package/dist/src/imex/client.d.ts +88 -0
- package/dist/src/imex/client.d.ts.map +1 -0
- package/dist/src/imex/index.d.ts +2 -0
- package/dist/src/imex/index.d.ts.map +1 -0
- package/dist/src/index.d.ts +18 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/label/client.d.ts +55 -36
- package/dist/src/label/client.d.ts.map +1 -1
- package/dist/src/label/external.d.ts +2 -0
- package/dist/src/label/external.d.ts.map +1 -1
- package/dist/src/label/payload.d.ts +4 -46
- package/dist/src/label/payload.d.ts.map +1 -1
- package/dist/src/label/store.d.ts +8 -0
- package/dist/src/label/store.d.ts.map +1 -0
- package/dist/src/label/types.gen.d.ts +45 -0
- package/dist/src/label/types.gen.d.ts.map +1 -0
- package/dist/src/labjack/external.d.ts +2 -0
- package/dist/src/labjack/external.d.ts.map +1 -0
- package/dist/src/labjack/index.d.ts +2 -0
- package/dist/src/labjack/index.d.ts.map +1 -0
- package/dist/src/labjack/types.gen.d.ts +442 -0
- package/dist/src/labjack/types.gen.d.ts.map +1 -0
- package/dist/src/lineplot/actions.d.ts +914 -0
- package/dist/src/lineplot/actions.d.ts.map +1 -0
- package/dist/src/lineplot/actions.gen.d.ts +4208 -0
- package/dist/src/lineplot/actions.gen.d.ts.map +1 -0
- package/dist/src/lineplot/client.d.ts +66 -16
- package/dist/src/lineplot/client.d.ts.map +1 -1
- package/dist/src/lineplot/external.d.ts +3 -0
- package/dist/src/lineplot/external.d.ts.map +1 -1
- package/dist/src/lineplot/line.d.ts +16 -0
- package/dist/src/lineplot/line.d.ts.map +1 -0
- package/dist/src/lineplot/types.gen.d.ts +837 -14
- package/dist/src/lineplot/types.gen.d.ts.map +1 -1
- package/dist/src/log/actions.d.ts +271 -0
- package/dist/src/log/actions.d.ts.map +1 -0
- package/dist/src/log/actions.gen.d.ts +1529 -0
- package/dist/src/log/actions.gen.d.ts.map +1 -0
- package/dist/src/log/client.d.ts +66 -16
- package/dist/src/log/client.d.ts.map +1 -1
- package/dist/src/log/external.d.ts +2 -0
- package/dist/src/log/external.d.ts.map +1 -1
- package/dist/src/log/types.gen.d.ts +139 -14
- package/dist/src/log/types.gen.d.ts.map +1 -1
- package/dist/src/modbus/external.d.ts +2 -0
- package/dist/src/modbus/external.d.ts.map +1 -0
- package/dist/src/modbus/index.d.ts +2 -0
- package/dist/src/modbus/index.d.ts.map +1 -0
- package/dist/src/modbus/types.gen.d.ts +280 -0
- package/dist/src/modbus/types.gen.d.ts.map +1 -0
- package/dist/src/ni/external.d.ts +2 -0
- package/dist/src/ni/external.d.ts.map +1 -0
- package/dist/src/ni/index.d.ts +2 -0
- package/dist/src/ni/index.d.ts.map +1 -0
- package/dist/src/ni/types.gen.d.ts +21029 -0
- package/dist/src/ni/types.gen.d.ts.map +1 -0
- package/dist/src/node/index.d.ts +2 -0
- package/dist/src/node/index.d.ts.map +1 -0
- package/dist/src/node/types.gen.d.ts +4 -0
- package/dist/src/node/types.gen.d.ts.map +1 -0
- package/dist/src/ontology/client.d.ts +314 -67
- package/dist/src/ontology/client.d.ts.map +1 -1
- package/dist/src/ontology/external.d.ts +1 -0
- package/dist/src/ontology/external.d.ts.map +1 -1
- package/dist/src/ontology/payload.d.ts +60 -18
- package/dist/src/ontology/payload.d.ts.map +1 -1
- package/dist/src/ontology/store.d.ts +32 -0
- package/dist/src/ontology/store.d.ts.map +1 -0
- package/dist/src/ontology/types.gen.d.ts +3 -2
- package/dist/src/ontology/types.gen.d.ts.map +1 -1
- package/dist/src/ontology/writer.d.ts +16 -10
- package/dist/src/ontology/writer.d.ts.map +1 -1
- package/dist/src/opcua/external.d.ts +2 -0
- package/dist/src/opcua/external.d.ts.map +1 -0
- package/dist/src/opcua/index.d.ts +2 -0
- package/dist/src/opcua/index.d.ts.map +1 -0
- package/dist/src/opcua/types.gen.d.ts +82 -0
- package/dist/src/opcua/types.gen.d.ts.map +1 -0
- package/dist/src/pagerduty/external.d.ts +2 -0
- package/dist/src/pagerduty/external.d.ts.map +1 -0
- package/dist/src/pagerduty/index.d.ts +2 -0
- package/dist/src/pagerduty/index.d.ts.map +1 -0
- package/dist/src/pagerduty/types.gen.d.ts +30 -0
- package/dist/src/pagerduty/types.gen.d.ts.map +1 -0
- package/dist/src/panel/actions.d.ts +273 -0
- package/dist/src/panel/actions.d.ts.map +1 -0
- package/dist/src/panel/actions.gen.d.ts +1255 -0
- package/dist/src/panel/actions.gen.d.ts.map +1 -0
- package/dist/src/panel/client.d.ts +148 -0
- package/dist/src/panel/client.d.ts.map +1 -0
- package/dist/src/panel/external.d.ts +6 -0
- package/dist/src/panel/external.d.ts.map +1 -0
- package/dist/src/panel/index.d.ts +2 -0
- package/dist/src/panel/index.d.ts.map +1 -0
- package/dist/src/panel/tree.d.ts +50 -0
- package/dist/src/panel/tree.d.ts.map +1 -0
- package/dist/src/panel/types.gen.d.ts +370 -0
- package/dist/src/panel/types.gen.d.ts.map +1 -0
- package/dist/src/project/client.d.ts +89 -0
- package/dist/src/project/client.d.ts.map +1 -0
- package/dist/src/project/external.d.ts.map +1 -0
- package/dist/src/project/index.d.ts +2 -0
- package/dist/src/project/index.d.ts.map +1 -0
- package/dist/src/project/types.gen.d.ts +27 -0
- package/dist/src/project/types.gen.d.ts.map +1 -0
- package/dist/src/query/cache.d.ts +132 -0
- package/dist/src/query/cache.d.ts.map +1 -0
- package/dist/src/query/deleted.d.ts +20 -0
- package/dist/src/query/deleted.d.ts.map +1 -0
- package/dist/src/query/derived.d.ts +33 -0
- package/dist/src/query/derived.d.ts.map +1 -0
- package/dist/src/query/external.d.ts +10 -0
- package/dist/src/query/external.d.ts.map +1 -0
- package/dist/src/query/index.d.ts +2 -0
- package/dist/src/query/index.d.ts.map +1 -0
- package/dist/src/query/query.d.ts +235 -0
- package/dist/src/query/query.d.ts.map +1 -0
- package/dist/src/query/retriever.d.ts +135 -0
- package/dist/src/query/retriever.d.ts.map +1 -0
- package/dist/src/query/streamer.d.ts +67 -0
- package/dist/src/query/streamer.d.ts.map +1 -0
- package/dist/src/query/table.d.ts +219 -0
- package/dist/src/query/table.d.ts.map +1 -0
- package/dist/src/query/types.d.ts +35 -0
- package/dist/src/query/types.d.ts.map +1 -0
- package/dist/src/query/write.d.ts +21 -0
- package/dist/src/query/write.d.ts.map +1 -0
- package/dist/src/rack/client.d.ts +58 -20
- package/dist/src/rack/client.d.ts.map +1 -1
- package/dist/src/rack/types.gen.d.ts +11 -12
- package/dist/src/rack/types.gen.d.ts.map +1 -1
- package/dist/src/range/alias/types.gen.d.ts +2 -3
- package/dist/src/range/alias/types.gen.d.ts.map +1 -1
- package/dist/src/ranger/client.d.ts +138 -27
- package/dist/src/ranger/client.d.ts.map +1 -1
- package/dist/src/ranger/kv/client.d.ts +7 -4
- package/dist/src/ranger/kv/client.d.ts.map +1 -1
- package/dist/src/ranger/payload.d.ts +3 -0
- package/dist/src/ranger/payload.d.ts.map +1 -1
- package/dist/src/ranger/types.gen.d.ts +45 -101
- package/dist/src/ranger/types.gen.d.ts.map +1 -1
- package/dist/src/ranger/writer.d.ts +2 -74
- package/dist/src/ranger/writer.d.ts.map +1 -1
- package/dist/src/schematic/actions.d.ts +90 -33
- package/dist/src/schematic/actions.d.ts.map +1 -1
- package/dist/src/schematic/actions.gen.d.ts +207 -114
- package/dist/src/schematic/actions.gen.d.ts.map +1 -1
- package/dist/src/schematic/client.d.ts +70 -68
- package/dist/src/schematic/client.d.ts.map +1 -1
- package/dist/src/schematic/symbol/client.d.ts +133 -27
- package/dist/src/schematic/symbol/client.d.ts.map +1 -1
- package/dist/src/schematic/symbol/types.gen.d.ts +258 -153
- package/dist/src/schematic/symbol/types.gen.d.ts.map +1 -1
- package/dist/src/schematic/types.gen.d.ts +17 -96
- package/dist/src/schematic/types.gen.d.ts.map +1 -1
- package/dist/src/status/client.d.ts +69 -14
- package/dist/src/status/client.d.ts.map +1 -1
- package/dist/src/status/external.d.ts +2 -0
- package/dist/src/status/external.d.ts.map +1 -1
- package/dist/src/status/payload.d.ts +2 -36
- package/dist/src/status/payload.d.ts.map +1 -1
- package/dist/src/status/status.d.ts +65 -0
- package/dist/src/status/status.d.ts.map +1 -0
- package/dist/src/status/types.gen.d.ts +58 -0
- package/dist/src/status/types.gen.d.ts.map +1 -0
- package/dist/src/table/actions.d.ts +72 -13
- package/dist/src/table/actions.d.ts.map +1 -1
- package/dist/src/table/actions.gen.d.ts +221 -137
- package/dist/src/table/actions.gen.d.ts.map +1 -1
- package/dist/src/table/client.d.ts +64 -40
- package/dist/src/table/client.d.ts.map +1 -1
- package/dist/src/table/types.gen.d.ts +20 -55
- package/dist/src/table/types.gen.d.ts.map +1 -1
- package/dist/src/task/client.d.ts +149 -28
- package/dist/src/task/client.d.ts.map +1 -1
- package/dist/src/task/types.gen.d.ts +71 -89
- package/dist/src/task/types.gen.d.ts.map +1 -1
- package/dist/src/testutil/access.d.ts +27 -1
- package/dist/src/testutil/access.d.ts.map +1 -1
- package/dist/src/testutil/channels.d.ts +2 -0
- package/dist/src/testutil/channels.d.ts.map +1 -1
- package/dist/src/testutil/client.d.ts +5 -0
- package/dist/src/testutil/client.d.ts.map +1 -1
- package/dist/src/testutil/connection.d.ts +10 -0
- package/dist/src/testutil/connection.d.ts.map +1 -0
- package/dist/src/testutil/index.d.ts +9 -0
- package/dist/src/testutil/index.d.ts.map +1 -0
- package/dist/src/testutil/panels.d.ts +8 -0
- package/dist/src/testutil/panels.d.ts.map +1 -0
- package/dist/src/testutil/proxy.d.ts +29 -0
- package/dist/src/testutil/proxy.d.ts.map +1 -0
- package/dist/src/testutil/query.d.ts +7 -0
- package/dist/src/testutil/query.d.ts.map +1 -0
- package/dist/src/testutil/telem.d.ts +4 -0
- package/dist/src/testutil/telem.d.ts.map +1 -1
- package/dist/src/transport.d.ts +10 -4
- package/dist/src/transport.d.ts.map +1 -1
- package/dist/src/user/client.d.ts +29 -28
- package/dist/src/user/client.d.ts.map +1 -1
- package/dist/src/user/external.d.ts +1 -1
- package/dist/src/user/external.d.ts.map +1 -1
- package/dist/src/user/types.gen.d.ts +4 -4
- package/dist/src/util/retrieve.d.ts +2 -2
- package/dist/src/util/retrieve.d.ts.map +1 -1
- package/dist/src/util/telem.d.ts.map +1 -1
- package/dist/src/view/client.d.ts +30 -14
- package/dist/src/view/client.d.ts.map +1 -1
- package/dist/src/view/types.gen.d.ts +7 -15
- package/dist/src/view/types.gen.d.ts.map +1 -1
- package/dist/testutil.js +189 -0
- package/dist/testutil.js.map +1 -0
- package/package.json +40 -17
- package/src/access/client.ts +14 -3
- package/src/access/enforce.ts +0 -3
- package/src/access/external.ts +1 -0
- package/src/access/granted.ts +114 -0
- package/src/access/policy/client.ts +135 -43
- package/src/access/policy/types.gen.ts +9 -11
- package/src/access/role/client.ts +160 -38
- package/src/access/role/types.gen.ts +8 -12
- package/src/actions/actions.ts +5 -6
- package/src/actions/controller.ts +626 -0
- package/src/actions/external.ts +11 -0
- package/src/arc/actions.gen.ts +313 -0
- package/src/arc/actions.ts +192 -0
- package/src/arc/client.ts +424 -41
- package/src/arc/compiler/types.gen.ts +5 -6
- package/src/arc/external.ts +2 -0
- package/src/arc/graph/types.gen.ts +24 -22
- package/src/arc/ir/index.ts +1 -1
- package/{eslint.config.ts → src/arc/ir/ir.ts} +1 -4
- package/src/arc/ir/types.gen.ts +42 -41
- package/src/arc/text/types.gen.ts +21 -2
- package/src/arc/types/types.gen.ts +40 -32
- package/src/arc/types.gen.ts +31 -29
- package/src/auth/auth.ts +40 -8
- package/src/channel/client.ts +529 -132
- package/src/channel/external.ts +0 -1
- package/src/channel/payload.ts +30 -3
- package/src/channel/types.gen.ts +37 -48
- package/src/channel/writer.ts +2 -11
- package/src/client.ts +215 -91
- package/src/connection/client.ts +495 -0
- package/src/connection/external.ts +34 -0
- package/src/connection/index.ts +1 -1
- package/src/connection/status.ts +442 -0
- package/src/control/client.ts +84 -12
- package/src/control/state.ts +17 -36
- package/src/device/client.ts +293 -41
- package/src/device/types.gen.ts +15 -26
- package/src/errors.ts +45 -22
- package/src/{workspace → ethercat}/external.ts +1 -2
- package/src/{workspace → ethercat}/index.ts +1 -1
- package/src/ethercat/types.gen.ts +151 -0
- package/src/framer/adapter.ts +60 -37
- package/src/framer/benchutil.ts +67 -0
- package/src/framer/cache/cache.ts +115 -0
- package/src/framer/cache/dynamic.ts +279 -0
- package/src/framer/cache/reader.ts +160 -0
- package/src/framer/cache/static.ts +215 -0
- package/src/framer/cache/streamer.ts +391 -0
- package/src/framer/cache/transform.ts +31 -0
- package/src/framer/cache/unary.ts +104 -0
- package/src/framer/client.ts +71 -43
- package/src/framer/codec.ts +55 -18
- package/src/framer/deleter.ts +4 -6
- package/src/framer/external.ts +10 -0
- package/src/framer/feed.ts +108 -0
- package/src/framer/frame.ts +13 -23
- package/src/framer/hardened.ts +283 -0
- package/src/framer/iterator.ts +31 -42
- package/src/framer/reader.ts +11 -11
- package/src/framer/streamer.ts +18 -178
- package/src/framer/writer.ts +39 -59
- package/src/group/client.ts +158 -23
- package/src/http/external.ts +10 -0
- package/src/{cluster → http}/index.ts +1 -1
- package/src/http/types.gen.ts +245 -0
- package/src/imex/client.ts +125 -0
- package/src/imex/index.ts +10 -0
- package/src/index.ts +18 -6
- package/src/label/client.ts +193 -54
- package/src/label/external.ts +2 -0
- package/src/label/payload.ts +4 -9
- package/src/label/store.ts +28 -0
- package/src/label/types.gen.ts +31 -0
- package/src/labjack/external.ts +10 -0
- package/src/labjack/index.ts +10 -0
- package/src/labjack/types.gen.ts +251 -0
- package/src/lineplot/actions.gen.ts +880 -0
- package/src/lineplot/actions.ts +535 -0
- package/src/lineplot/client.ts +224 -52
- package/src/lineplot/external.ts +3 -0
- package/src/lineplot/line.ts +80 -0
- package/src/lineplot/types.gen.ts +225 -12
- package/src/log/actions.gen.ts +474 -0
- package/src/log/actions.ts +242 -0
- package/src/log/client.ts +223 -52
- package/src/log/external.ts +2 -0
- package/src/log/types.gen.ts +45 -14
- package/src/modbus/external.ts +10 -0
- package/src/modbus/index.ts +10 -0
- package/src/modbus/types.gen.ts +185 -0
- package/src/ni/external.ts +10 -0
- package/src/ni/index.ts +10 -0
- package/src/ni/types.gen.ts +1632 -0
- package/src/node/index.ts +10 -0
- package/src/{cluster → node}/types.gen.ts +2 -2
- package/src/ontology/client.ts +408 -99
- package/src/ontology/external.ts +7 -0
- package/src/ontology/payload.ts +48 -7
- package/src/ontology/store.ts +83 -0
- package/src/ontology/types.gen.ts +2 -1
- package/src/ontology/writer.ts +1 -0
- package/src/opcua/external.ts +10 -0
- package/src/opcua/index.ts +10 -0
- package/src/opcua/types.gen.ts +65 -0
- package/src/pagerduty/external.ts +10 -0
- package/src/pagerduty/index.ts +10 -0
- package/src/pagerduty/types.gen.ts +41 -0
- package/src/panel/actions.gen.ts +267 -0
- package/src/panel/actions.ts +357 -0
- package/src/panel/client.ts +327 -0
- package/src/panel/external.ts +14 -0
- package/src/panel/index.ts +10 -0
- package/src/panel/tree.ts +163 -0
- package/src/panel/types.gen.ts +164 -0
- package/src/project/client.ts +273 -0
- package/src/project/external.ts +11 -0
- package/src/project/index.ts +10 -0
- package/src/project/types.gen.ts +40 -0
- package/src/query/cache.ts +326 -0
- package/src/query/deleted.ts +38 -0
- package/src/query/derived.ts +101 -0
- package/src/query/external.ts +51 -0
- package/src/query/index.ts +10 -0
- package/src/query/query.ts +865 -0
- package/src/query/retriever.ts +308 -0
- package/src/query/streamer.ts +207 -0
- package/src/query/table.ts +625 -0
- package/src/query/types.ts +54 -0
- package/src/query/write.ts +42 -0
- package/src/rack/client.ts +233 -45
- package/src/rack/types.gen.ts +15 -16
- package/src/range/alias/types.gen.ts +2 -3
- package/src/ranger/client.ts +581 -70
- package/src/ranger/kv/client.ts +52 -21
- package/src/ranger/payload.ts +3 -0
- package/src/ranger/types.gen.ts +21 -23
- package/src/ranger/writer.ts +4 -8
- package/src/schematic/actions.gen.ts +62 -53
- package/src/schematic/actions.ts +44 -42
- package/src/schematic/client.ts +226 -70
- package/src/schematic/symbol/client.ts +277 -48
- package/src/schematic/symbol/types.gen.ts +22 -34
- package/src/schematic/types.gen.ts +22 -29
- package/src/status/client.ts +321 -44
- package/src/status/external.ts +2 -0
- package/src/status/payload.ts +1 -23
- package/src/status/status.ts +241 -0
- package/src/status/types.gen.ts +108 -0
- package/src/table/actions.gen.ts +96 -63
- package/src/table/actions.ts +44 -19
- package/src/table/client.ts +220 -56
- package/src/table/types.gen.ts +24 -31
- package/src/task/client.ts +580 -101
- package/src/task/types.gen.ts +68 -75
- package/src/testutil/access.ts +102 -6
- package/src/testutil/channels.ts +29 -0
- package/src/testutil/client.ts +27 -2
- package/src/testutil/connection.ts +47 -0
- package/src/testutil/index.ts +17 -0
- package/src/testutil/panels.ts +26 -0
- package/src/testutil/proxy.ts +106 -0
- package/src/testutil/query.ts +28 -0
- package/src/testutil/telem.ts +17 -1
- package/src/transport.ts +18 -7
- package/src/user/client.ts +165 -64
- package/src/user/external.ts +1 -1
- package/src/user/types.gen.ts +5 -5
- package/src/util/retrieve.ts +4 -4
- package/src/util/telem.ts +0 -1
- package/src/view/client.ts +120 -37
- package/src/view/types.gen.ts +8 -11
- package/.turbo/turbo-build.log +0 -20
- package/.vscode/settings.json +0 -3
- package/CONTRIBUTING.md +0 -47
- package/dist/client.cjs +0 -118
- package/dist/eslint.config.d.ts +0 -4
- package/dist/eslint.config.d.ts.map +0 -1
- package/dist/src/access/enforce.spec.d.ts +0 -2
- package/dist/src/access/enforce.spec.d.ts.map +0 -1
- package/dist/src/access/policy/access.spec.d.ts +0 -2
- package/dist/src/access/policy/access.spec.d.ts.map +0 -1
- package/dist/src/access/role/role.spec.d.ts +0 -2
- package/dist/src/access/role/role.spec.d.ts.map +0 -1
- package/dist/src/actions/actions.spec.d.ts +0 -2
- package/dist/src/actions/actions.spec.d.ts.map +0 -1
- package/dist/src/arc/access.spec.d.ts +0 -2
- package/dist/src/arc/access.spec.d.ts.map +0 -1
- package/dist/src/arc/arc.spec.d.ts +0 -2
- package/dist/src/arc/arc.spec.d.ts.map +0 -1
- package/dist/src/arc/lsp.spec.d.ts +0 -2
- package/dist/src/arc/lsp.spec.d.ts.map +0 -1
- package/dist/src/auth/auth.spec.d.ts +0 -2
- package/dist/src/auth/auth.spec.d.ts.map +0 -1
- package/dist/src/channel/access.spec.d.ts +0 -2
- package/dist/src/channel/access.spec.d.ts.map +0 -1
- package/dist/src/channel/batchRetriever.spec.d.ts +0 -2
- package/dist/src/channel/batchRetriever.spec.d.ts.map +0 -1
- package/dist/src/channel/channel.spec.d.ts +0 -2
- package/dist/src/channel/channel.spec.d.ts.map +0 -1
- package/dist/src/channel/payload.spec.d.ts +0 -2
- package/dist/src/channel/payload.spec.d.ts.map +0 -1
- package/dist/src/channel/retriever.d.ts +0 -64
- package/dist/src/channel/retriever.d.ts.map +0 -1
- package/dist/src/cluster/index.d.ts +0 -2
- package/dist/src/cluster/index.d.ts.map +0 -1
- package/dist/src/cluster/types.gen.d.ts +0 -4
- package/dist/src/cluster/types.gen.d.ts.map +0 -1
- package/dist/src/connection/checker.d.ts +0 -86
- package/dist/src/connection/checker.d.ts.map +0 -1
- package/dist/src/connection/connection.spec.d.ts +0 -2
- package/dist/src/connection/connection.spec.d.ts.map +0 -1
- package/dist/src/connection.spec.d.ts +0 -2
- package/dist/src/connection.spec.d.ts.map +0 -1
- package/dist/src/control/state.spec.d.ts +0 -2
- package/dist/src/control/state.spec.d.ts.map +0 -1
- package/dist/src/device/access.spec.d.ts +0 -2
- package/dist/src/device/access.spec.d.ts.map +0 -1
- package/dist/src/device/device.spec.d.ts +0 -2
- package/dist/src/device/device.spec.d.ts.map +0 -1
- package/dist/src/device/payload.spec.d.ts +0 -2
- package/dist/src/device/payload.spec.d.ts.map +0 -1
- package/dist/src/errors.spec.d.ts +0 -2
- package/dist/src/errors.spec.d.ts.map +0 -1
- package/dist/src/framer/adapter.spec.d.ts +0 -2
- package/dist/src/framer/adapter.spec.d.ts.map +0 -1
- package/dist/src/framer/client.spec.d.ts +0 -2
- package/dist/src/framer/client.spec.d.ts.map +0 -1
- package/dist/src/framer/codec.spec.d.ts +0 -2
- package/dist/src/framer/codec.spec.d.ts.map +0 -1
- package/dist/src/framer/deleter.spec.d.ts +0 -2
- package/dist/src/framer/deleter.spec.d.ts.map +0 -1
- package/dist/src/framer/frame.spec.d.ts +0 -2
- package/dist/src/framer/frame.spec.d.ts.map +0 -1
- package/dist/src/framer/iterator.spec.d.ts +0 -2
- package/dist/src/framer/iterator.spec.d.ts.map +0 -1
- package/dist/src/framer/reader.spec.d.ts +0 -2
- package/dist/src/framer/reader.spec.d.ts.map +0 -1
- package/dist/src/framer/streamer.spec.d.ts +0 -2
- package/dist/src/framer/streamer.spec.d.ts.map +0 -1
- package/dist/src/framer/writer.spec.d.ts +0 -2
- package/dist/src/framer/writer.spec.d.ts.map +0 -1
- package/dist/src/group/access.spec.d.ts +0 -2
- package/dist/src/group/access.spec.d.ts.map +0 -1
- package/dist/src/group/group.spec.d.ts +0 -2
- package/dist/src/group/group.spec.d.ts.map +0 -1
- package/dist/src/label/access.spec.d.ts +0 -2
- package/dist/src/label/access.spec.d.ts.map +0 -1
- package/dist/src/label/label.spec.d.ts +0 -2
- package/dist/src/label/label.spec.d.ts.map +0 -1
- package/dist/src/lineplot/access.spec.d.ts +0 -2
- package/dist/src/lineplot/access.spec.d.ts.map +0 -1
- package/dist/src/lineplot/lineplot.spec.d.ts +0 -2
- package/dist/src/lineplot/lineplot.spec.d.ts.map +0 -1
- package/dist/src/log/access.spec.d.ts +0 -2
- package/dist/src/log/access.spec.d.ts.map +0 -1
- package/dist/src/log/log.spec.d.ts +0 -2
- package/dist/src/log/log.spec.d.ts.map +0 -1
- package/dist/src/ontology/ontology.spec.d.ts +0 -2
- package/dist/src/ontology/ontology.spec.d.ts.map +0 -1
- package/dist/src/rack/access.spec.d.ts +0 -2
- package/dist/src/rack/access.spec.d.ts.map +0 -1
- package/dist/src/rack/rack.spec.d.ts +0 -2
- package/dist/src/rack/rack.spec.d.ts.map +0 -1
- package/dist/src/ranger/access.spec.d.ts +0 -2
- package/dist/src/ranger/access.spec.d.ts.map +0 -1
- package/dist/src/ranger/alias/payload.spec.d.ts +0 -2
- package/dist/src/ranger/alias/payload.spec.d.ts.map +0 -1
- package/dist/src/ranger/ranger.spec.d.ts +0 -2
- package/dist/src/ranger/ranger.spec.d.ts.map +0 -1
- package/dist/src/schematic/access.spec.d.ts +0 -2
- package/dist/src/schematic/access.spec.d.ts.map +0 -1
- package/dist/src/schematic/actions.spec.d.ts +0 -2
- package/dist/src/schematic/actions.spec.d.ts.map +0 -1
- package/dist/src/schematic/schematic.spec.d.ts +0 -2
- package/dist/src/schematic/schematic.spec.d.ts.map +0 -1
- package/dist/src/schematic/symbol/access.spec.d.ts +0 -2
- package/dist/src/schematic/symbol/access.spec.d.ts.map +0 -1
- package/dist/src/schematic/symbol/client.spec.d.ts +0 -2
- package/dist/src/schematic/symbol/client.spec.d.ts.map +0 -1
- package/dist/src/status/access.spec.d.ts +0 -2
- package/dist/src/status/access.spec.d.ts.map +0 -1
- package/dist/src/status/status.spec.d.ts +0 -2
- package/dist/src/status/status.spec.d.ts.map +0 -1
- package/dist/src/table/access.spec.d.ts +0 -2
- package/dist/src/table/access.spec.d.ts.map +0 -1
- package/dist/src/table/table.spec.d.ts +0 -2
- package/dist/src/table/table.spec.d.ts.map +0 -1
- package/dist/src/task/access.spec.d.ts +0 -2
- package/dist/src/task/access.spec.d.ts.map +0 -1
- package/dist/src/task/payload.spec.d.ts +0 -2
- package/dist/src/task/payload.spec.d.ts.map +0 -1
- package/dist/src/task/task.spec.d.ts +0 -2
- package/dist/src/task/task.spec.d.ts.map +0 -1
- package/dist/src/user/access.spec.d.ts +0 -2
- package/dist/src/user/access.spec.d.ts.map +0 -1
- package/dist/src/user/user.spec.d.ts +0 -2
- package/dist/src/user/user.spec.d.ts.map +0 -1
- package/dist/src/util/retrieve.spec.d.ts +0 -2
- package/dist/src/util/retrieve.spec.d.ts.map +0 -1
- package/dist/src/view/view.spec.d.ts +0 -2
- package/dist/src/view/view.spec.d.ts.map +0 -1
- package/dist/src/workspace/access.spec.d.ts +0 -2
- package/dist/src/workspace/access.spec.d.ts.map +0 -1
- package/dist/src/workspace/client.d.ts +0 -36
- package/dist/src/workspace/client.d.ts.map +0 -1
- package/dist/src/workspace/external.d.ts.map +0 -1
- package/dist/src/workspace/index.d.ts +0 -2
- package/dist/src/workspace/index.d.ts.map +0 -1
- package/dist/src/workspace/types.gen.d.ts +0 -34
- package/dist/src/workspace/types.gen.d.ts.map +0 -1
- package/dist/src/workspace/workspace.spec.d.ts +0 -2
- package/dist/src/workspace/workspace.spec.d.ts.map +0 -1
- package/examples/node/basicReadWrite.js +0 -86
- package/examples/node/createChannels.js +0 -50
- package/examples/node/createRange.js +0 -67
- package/examples/node/package-lock.json +0 -133
- package/examples/node/package.json +0 -17
- package/examples/node/readLatest.js +0 -76
- package/examples/node/seriesAndFrames.js +0 -173
- package/examples/node/streamRead.js +0 -50
- package/examples/node/streamWrite.js +0 -87
- package/src/access/enforce.spec.ts +0 -188
- package/src/access/policy/access.spec.ts +0 -147
- package/src/access/role/role.spec.ts +0 -95
- package/src/actions/actions.spec.ts +0 -229
- package/src/arc/access.spec.ts +0 -149
- package/src/arc/arc.spec.ts +0 -44
- package/src/arc/lsp.spec.ts +0 -717
- package/src/auth/auth.spec.ts +0 -101
- package/src/channel/access.spec.ts +0 -116
- package/src/channel/batchRetriever.spec.ts +0 -115
- package/src/channel/channel.spec.ts +0 -352
- package/src/channel/payload.spec.ts +0 -117
- package/src/channel/retriever.ts +0 -252
- package/src/connection/checker.ts +0 -203
- package/src/connection/connection.spec.ts +0 -152
- package/src/connection.spec.ts +0 -145
- package/src/control/state.spec.ts +0 -22
- package/src/device/access.spec.ts +0 -159
- package/src/device/device.spec.ts +0 -461
- package/src/device/payload.spec.ts +0 -142
- package/src/errors.spec.ts +0 -71
- package/src/framer/adapter.spec.ts +0 -620
- package/src/framer/client.spec.ts +0 -180
- package/src/framer/codec.spec.ts +0 -383
- package/src/framer/deleter.spec.ts +0 -103
- package/src/framer/frame.spec.ts +0 -973
- package/src/framer/iterator.spec.ts +0 -169
- package/src/framer/reader.spec.ts +0 -865
- package/src/framer/streamer.spec.ts +0 -871
- package/src/framer/writer.spec.ts +0 -486
- package/src/group/access.spec.ts +0 -77
- package/src/group/group.spec.ts +0 -65
- package/src/label/access.spec.ts +0 -109
- package/src/label/label.spec.ts +0 -83
- package/src/lineplot/access.spec.ts +0 -134
- package/src/lineplot/lineplot.spec.ts +0 -120
- package/src/log/access.spec.ts +0 -132
- package/src/log/log.spec.ts +0 -106
- package/src/ontology/ontology.spec.ts +0 -521
- package/src/rack/access.spec.ts +0 -102
- package/src/rack/rack.spec.ts +0 -171
- package/src/ranger/access.spec.ts +0 -115
- package/src/ranger/alias/payload.spec.ts +0 -52
- package/src/ranger/ranger.spec.ts +0 -343
- package/src/schematic/access.spec.ts +0 -134
- package/src/schematic/actions.spec.ts +0 -699
- package/src/schematic/schematic.spec.ts +0 -340
- package/src/schematic/symbol/access.spec.ts +0 -172
- package/src/schematic/symbol/client.spec.ts +0 -160
- package/src/status/access.spec.ts +0 -129
- package/src/status/status.spec.ts +0 -448
- package/src/table/access.spec.ts +0 -128
- package/src/table/table.spec.ts +0 -651
- package/src/task/access.spec.ts +0 -131
- package/src/task/payload.spec.ts +0 -113
- package/src/task/task.spec.ts +0 -657
- package/src/user/access.spec.ts +0 -107
- package/src/user/user.spec.ts +0 -290
- package/src/util/retrieve.spec.ts +0 -49
- package/src/view/view.spec.ts +0 -165
- package/src/workspace/access.spec.ts +0 -108
- package/src/workspace/client.ts +0 -112
- package/src/workspace/types.gen.ts +0 -46
- package/src/workspace/workspace.spec.ts +0 -111
- package/tsconfig.json +0 -5
- package/tsconfig.vite.json +0 -4
- package/vite.config.ts +0 -29
- /package/dist/src/{workspace → project}/external.d.ts +0 -0
|
@@ -1,699 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Synnax Labs, Inc.
|
|
2
|
-
//
|
|
3
|
-
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
-
// licenses/BSL.txt.
|
|
5
|
-
//
|
|
6
|
-
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
-
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
-
// included in the file licenses/APL.txt.
|
|
9
|
-
|
|
10
|
-
import { describe, expect, it } from "vitest";
|
|
11
|
-
import { z } from "zod";
|
|
12
|
-
|
|
13
|
-
import { isUndoable, reduceAll } from "@/schematic/actions";
|
|
14
|
-
import {
|
|
15
|
-
type Action,
|
|
16
|
-
actionZ,
|
|
17
|
-
addEdge,
|
|
18
|
-
removeEdge,
|
|
19
|
-
removeNode,
|
|
20
|
-
rename,
|
|
21
|
-
setConfig,
|
|
22
|
-
setNode,
|
|
23
|
-
setNodeMeasured,
|
|
24
|
-
setNodePosition,
|
|
25
|
-
} from "@/schematic/actions.gen";
|
|
26
|
-
import { type Edge, type Node, type Schematic } from "@/schematic/types.gen";
|
|
27
|
-
|
|
28
|
-
const node = (key: string, x: number, y: number): Node => ({
|
|
29
|
-
key,
|
|
30
|
-
position: { x, y },
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const edge = (
|
|
34
|
-
key: string,
|
|
35
|
-
srcNode: string,
|
|
36
|
-
srcParam: string,
|
|
37
|
-
tgtNode: string,
|
|
38
|
-
tgtParam: string,
|
|
39
|
-
): Edge => ({
|
|
40
|
-
key,
|
|
41
|
-
source: { node: srcNode, param: srcParam },
|
|
42
|
-
target: { node: tgtNode, param: tgtParam },
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const empty = (overrides: Partial<Schematic> = {}): Schematic => ({
|
|
46
|
-
key: "00000000-0000-0000-0000-000000000000",
|
|
47
|
-
name: "",
|
|
48
|
-
snapshot: false,
|
|
49
|
-
nodes: [],
|
|
50
|
-
edges: [],
|
|
51
|
-
configs: {},
|
|
52
|
-
...overrides,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const apply = (state: Schematic, ...actions: Action[]): Schematic =>
|
|
56
|
-
reduceAll(state, actions).next;
|
|
57
|
-
|
|
58
|
-
describe("schematic reducer", () => {
|
|
59
|
-
describe("rename", () => {
|
|
60
|
-
it("should set the schematic name to the payload name", () => {
|
|
61
|
-
const state = empty({ name: "old" });
|
|
62
|
-
const out = apply(state, rename({ name: "new" }));
|
|
63
|
-
expect(out.name).toEqual("new");
|
|
64
|
-
});
|
|
65
|
-
it("should accept an empty name", () => {
|
|
66
|
-
const state = empty({ name: "old" });
|
|
67
|
-
const out = apply(state, rename({ name: "" }));
|
|
68
|
-
expect(out.name).toEqual("");
|
|
69
|
-
});
|
|
70
|
-
it("should leave nodes, edges, and configs untouched", () => {
|
|
71
|
-
const state = empty({
|
|
72
|
-
name: "old",
|
|
73
|
-
nodes: [node("n1", 0, 0)],
|
|
74
|
-
edges: [edge("e1", "a", "o", "b", "i")],
|
|
75
|
-
configs: { n1: { label: "Pump" } },
|
|
76
|
-
});
|
|
77
|
-
const out = apply(state, rename({ name: "new" }));
|
|
78
|
-
expect(out.nodes).toEqual(state.nodes);
|
|
79
|
-
expect(out.edges).toEqual(state.edges);
|
|
80
|
-
expect(out.configs).toEqual(state.configs);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
describe("setNodePosition", () => {
|
|
85
|
-
it("should move the matching node to the new position", () => {
|
|
86
|
-
const state = empty({ nodes: [node("n1", 0, 0), node("n2", 5, 5)] });
|
|
87
|
-
const out = apply(
|
|
88
|
-
state,
|
|
89
|
-
setNodePosition({ key: "n1", position: { x: 100, y: 200 } }),
|
|
90
|
-
);
|
|
91
|
-
expect(out.nodes).toEqual([node("n1", 100, 200), node("n2", 5, 5)]);
|
|
92
|
-
});
|
|
93
|
-
it("should be a no-op when the key does not match any node", () => {
|
|
94
|
-
const state = empty({ nodes: [node("n1", 0, 0)] });
|
|
95
|
-
const out = apply(
|
|
96
|
-
state,
|
|
97
|
-
setNodePosition({ key: "ghost", position: { x: 9, y: 9 } }),
|
|
98
|
-
);
|
|
99
|
-
expect(out.nodes).toEqual([node("n1", 0, 0)]);
|
|
100
|
-
});
|
|
101
|
-
it("should only move the first matching node when keys are duplicated", () => {
|
|
102
|
-
const state = empty({ nodes: [node("dup", 0, 0), node("dup", 1, 1)] });
|
|
103
|
-
const out = apply(
|
|
104
|
-
state,
|
|
105
|
-
setNodePosition({ key: "dup", position: { x: 9, y: 9 } }),
|
|
106
|
-
);
|
|
107
|
-
expect(out.nodes[0].position).toEqual({ x: 9, y: 9 });
|
|
108
|
-
expect(out.nodes[1].position).toEqual({ x: 1, y: 1 });
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
describe("setNode", () => {
|
|
113
|
-
it("should append the node to the end of the slice when no node has the same key", () => {
|
|
114
|
-
const state = empty({ nodes: [node("n1", 0, 0)] });
|
|
115
|
-
const out = apply(state, setNode({ node: node("n2", 1, 2) }));
|
|
116
|
-
expect(out.nodes).toEqual([node("n1", 0, 0), node("n2", 1, 2)]);
|
|
117
|
-
});
|
|
118
|
-
it("should write config under the node's key when config is non-undefined", () => {
|
|
119
|
-
const out = apply(
|
|
120
|
-
empty(),
|
|
121
|
-
setNode({ node: node("n1", 0, 0), config: { label: "Pump", color: "#f00" } }),
|
|
122
|
-
);
|
|
123
|
-
expect(out.configs).toEqual({ n1: { label: "Pump", color: "#f00" } });
|
|
124
|
-
});
|
|
125
|
-
it("should leave configs untouched when the action's config is undefined", () => {
|
|
126
|
-
const out = apply(empty(), setNode({ node: node("n1", 0, 0) }));
|
|
127
|
-
expect(out.configs).toEqual({});
|
|
128
|
-
});
|
|
129
|
-
it("should replace an existing node in place when the key already exists, preserving slice index", () => {
|
|
130
|
-
const state = empty({
|
|
131
|
-
nodes: [node("n1", 0, 0), node("n2", 1, 1), node("n3", 2, 2)],
|
|
132
|
-
});
|
|
133
|
-
const out = apply(state, setNode({ node: node("n2", 9, 9) }));
|
|
134
|
-
expect(out.nodes).toHaveLength(3);
|
|
135
|
-
expect(out.nodes[0]).toEqual(node("n1", 0, 0));
|
|
136
|
-
expect(out.nodes[1]).toEqual(node("n2", 9, 9));
|
|
137
|
-
expect(out.nodes[2]).toEqual(node("n3", 2, 2));
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
describe("removeNode", () => {
|
|
142
|
-
it("should remove the matching node and any config stored under its key", () => {
|
|
143
|
-
const state = empty({
|
|
144
|
-
nodes: [node("n1", 0, 0), node("n2", 1, 1)],
|
|
145
|
-
configs: { n1: { label: "Pump" }, n2: { label: "Tank" } },
|
|
146
|
-
});
|
|
147
|
-
const out = apply(state, removeNode({ key: "n1" }));
|
|
148
|
-
expect(out.nodes).toEqual([node("n2", 1, 1)]);
|
|
149
|
-
expect(out.configs).toEqual({ n2: { label: "Tank" } });
|
|
150
|
-
});
|
|
151
|
-
it("should leave existing edges intact even when they reference the removed node", () => {
|
|
152
|
-
const state = empty({
|
|
153
|
-
nodes: [node("n1", 0, 0), node("n2", 1, 1)],
|
|
154
|
-
edges: [edge("e1", "n1", "out", "n2", "in")],
|
|
155
|
-
});
|
|
156
|
-
const out = apply(state, removeNode({ key: "n1" }));
|
|
157
|
-
expect(out.edges).toHaveLength(1);
|
|
158
|
-
expect(out.edges[0].source.node).toBe("n1");
|
|
159
|
-
});
|
|
160
|
-
it("should be a no-op when the key does not match any node", () => {
|
|
161
|
-
const state = empty({
|
|
162
|
-
nodes: [node("n1", 0, 0)],
|
|
163
|
-
configs: { n1: { label: "Pump" } },
|
|
164
|
-
});
|
|
165
|
-
const out = apply(state, removeNode({ key: "ghost" }));
|
|
166
|
-
expect(out.nodes).toEqual(state.nodes);
|
|
167
|
-
expect(out.configs).toEqual(state.configs);
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
describe("setEdge", () => {
|
|
172
|
-
it("should append an edge whose key is not yet present", () => {
|
|
173
|
-
const state = empty({ edges: [edge("e1", "a", "o", "b", "i")] });
|
|
174
|
-
const out = apply(state, addEdge({ edge: edge("e2", "b", "o", "c", "i") }));
|
|
175
|
-
expect(out.edges).toHaveLength(2);
|
|
176
|
-
expect(out.edges[1].key).toBe("e2");
|
|
177
|
-
});
|
|
178
|
-
it("should be a no-op when an edge with the same key already exists", () => {
|
|
179
|
-
const original = edge("e2", "b", "o", "c", "i");
|
|
180
|
-
const state = empty({
|
|
181
|
-
edges: [
|
|
182
|
-
edge("e1", "a", "o", "b", "i"),
|
|
183
|
-
original,
|
|
184
|
-
edge("e3", "c", "o", "d", "i"),
|
|
185
|
-
],
|
|
186
|
-
});
|
|
187
|
-
const out = apply(state, addEdge({ edge: edge("e2", "x", "y", "z", "w") }));
|
|
188
|
-
expect(out.edges).toHaveLength(3);
|
|
189
|
-
expect(out.edges[0].key).toBe("e1");
|
|
190
|
-
expect(out.edges[1]).toEqual(original);
|
|
191
|
-
expect(out.edges[2].key).toBe("e3");
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
describe("removeEdge", () => {
|
|
196
|
-
it("should remove the matching edge", () => {
|
|
197
|
-
const state = empty({
|
|
198
|
-
edges: [edge("e1", "a", "o", "b", "i"), edge("e2", "b", "o", "c", "i")],
|
|
199
|
-
});
|
|
200
|
-
const out = apply(state, removeEdge({ key: "e1" }));
|
|
201
|
-
expect(out.edges).toEqual([edge("e2", "b", "o", "c", "i")]);
|
|
202
|
-
});
|
|
203
|
-
it("should be a no-op when the key does not match any edge", () => {
|
|
204
|
-
const state = empty({ edges: [edge("e1", "a", "o", "b", "i")] });
|
|
205
|
-
const out = apply(state, removeEdge({ key: "ghost" }));
|
|
206
|
-
expect(out.edges).toEqual(state.edges);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
describe("setConfig", () => {
|
|
211
|
-
it("should write the config entry under the given key", () => {
|
|
212
|
-
const out = apply(empty(), setConfig({ key: "n1", config: { label: "Pump" } }));
|
|
213
|
-
expect(out.configs).toEqual({ n1: { label: "Pump" } });
|
|
214
|
-
});
|
|
215
|
-
it("should merge payload fields into an existing config entry", () => {
|
|
216
|
-
const state = empty({
|
|
217
|
-
configs: { n1: { label: "Old", color: "#ff0000" } },
|
|
218
|
-
});
|
|
219
|
-
const out = apply(state, setConfig({ key: "n1", config: { label: "New" } }));
|
|
220
|
-
expect(out.configs).toEqual({ n1: { label: "New", color: "#ff0000" } });
|
|
221
|
-
});
|
|
222
|
-
it("should accept a key that does not match any node or edge", () => {
|
|
223
|
-
const out = apply(empty(), setConfig({ key: "orphan", config: { data: 1 } }));
|
|
224
|
-
expect(out.configs).toEqual({ orphan: { data: 1 } });
|
|
225
|
-
});
|
|
226
|
-
it("should override the payload color with the source node's color when the new entry is for an edge", () => {
|
|
227
|
-
const state = empty({
|
|
228
|
-
edges: [edge("e1", "src", "o", "tgt", "i")],
|
|
229
|
-
configs: { src: { color: [0, 1, 0, 1] } },
|
|
230
|
-
});
|
|
231
|
-
const out = apply(
|
|
232
|
-
state,
|
|
233
|
-
setConfig({ key: "e1", config: { variant: "pipe", color: [0, 0, 0, 0] } }),
|
|
234
|
-
);
|
|
235
|
-
expect(out.configs.e1).toEqual({ variant: "pipe", color: [0, 1, 0, 1] });
|
|
236
|
-
});
|
|
237
|
-
it("should inherit the source node's color when the payload omits color", () => {
|
|
238
|
-
const state = empty({
|
|
239
|
-
edges: [edge("e1", "src", "o", "tgt", "i")],
|
|
240
|
-
configs: { src: { color: [0, 1, 0, 1] } },
|
|
241
|
-
});
|
|
242
|
-
const out = apply(state, setConfig({ key: "e1", config: { variant: "pipe" } }));
|
|
243
|
-
expect(out.configs.e1).toEqual({ variant: "pipe", color: [0, 1, 0, 1] });
|
|
244
|
-
});
|
|
245
|
-
it("should leave the payload untouched when the source node has a zero color", () => {
|
|
246
|
-
const state = empty({
|
|
247
|
-
edges: [edge("e1", "src", "o", "tgt", "i")],
|
|
248
|
-
configs: { src: { color: [0, 0, 0, 0] } },
|
|
249
|
-
});
|
|
250
|
-
const out = apply(
|
|
251
|
-
state,
|
|
252
|
-
setConfig({ key: "e1", config: { variant: "pipe", color: [0, 0, 0, 0] } }),
|
|
253
|
-
);
|
|
254
|
-
expect(out.configs.e1).toEqual({ variant: "pipe", color: [0, 0, 0, 0] });
|
|
255
|
-
});
|
|
256
|
-
it("should leave the payload untouched when the source node has no color", () => {
|
|
257
|
-
const state = empty({
|
|
258
|
-
edges: [edge("e1", "src", "o", "tgt", "i")],
|
|
259
|
-
configs: { src: { label: "Pump" } },
|
|
260
|
-
});
|
|
261
|
-
const out = apply(
|
|
262
|
-
state,
|
|
263
|
-
setConfig({ key: "e1", config: { variant: "pipe", color: [0, 0, 0, 0] } }),
|
|
264
|
-
);
|
|
265
|
-
expect(out.configs.e1).toEqual({ variant: "pipe", color: [0, 0, 0, 0] });
|
|
266
|
-
});
|
|
267
|
-
it("should leave the payload untouched when the source node has no config", () => {
|
|
268
|
-
const state = empty({
|
|
269
|
-
edges: [edge("e1", "src", "o", "tgt", "i")],
|
|
270
|
-
});
|
|
271
|
-
const out = apply(
|
|
272
|
-
state,
|
|
273
|
-
setConfig({ key: "e1", config: { variant: "pipe", color: [0, 0, 0, 0] } }),
|
|
274
|
-
);
|
|
275
|
-
expect(out.configs.e1).toEqual({ variant: "pipe", color: [0, 0, 0, 0] });
|
|
276
|
-
});
|
|
277
|
-
it("should not override the color when merging into an existing edge config", () => {
|
|
278
|
-
const state = empty({
|
|
279
|
-
edges: [edge("e1", "src", "o", "tgt", "i")],
|
|
280
|
-
configs: {
|
|
281
|
-
src: { color: [0, 1, 0, 1] },
|
|
282
|
-
e1: { variant: "pipe", color: [0, 0, 0, 0] },
|
|
283
|
-
},
|
|
284
|
-
});
|
|
285
|
-
const out = apply(
|
|
286
|
-
state,
|
|
287
|
-
setConfig({ key: "e1", config: { variant: "electric" } }),
|
|
288
|
-
);
|
|
289
|
-
expect(out.configs.e1).toEqual({ variant: "electric", color: [0, 0, 0, 0] });
|
|
290
|
-
});
|
|
291
|
-
it("should inherit the source color end-to-end when addEdge is followed by setConfig in one batch", () => {
|
|
292
|
-
const state = empty({
|
|
293
|
-
nodes: [node("src", 0, 0), node("tgt", 100, 0)],
|
|
294
|
-
configs: { src: { color: [0, 1, 0, 1] } },
|
|
295
|
-
});
|
|
296
|
-
const out = apply(
|
|
297
|
-
state,
|
|
298
|
-
addEdge({ edge: edge("e1", "src", "o", "tgt", "i") }),
|
|
299
|
-
setConfig({
|
|
300
|
-
key: "e1",
|
|
301
|
-
config: { variant: "pipe", color: [0, 0, 0, 0], segments: [] },
|
|
302
|
-
}),
|
|
303
|
-
);
|
|
304
|
-
expect(out.configs.e1).toEqual({
|
|
305
|
-
variant: "pipe",
|
|
306
|
-
color: [0, 1, 0, 1],
|
|
307
|
-
segments: [],
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
describe("immutability", () => {
|
|
313
|
-
it("should leave the input state object unmodified", () => {
|
|
314
|
-
const state = empty({ nodes: [node("n1", 0, 0)] });
|
|
315
|
-
const before = structuredClone(state);
|
|
316
|
-
reduceAll(state, [setNodePosition({ key: "n1", position: { x: 9, y: 9 } })]);
|
|
317
|
-
expect(state).toEqual(before);
|
|
318
|
-
});
|
|
319
|
-
it("should return a new state object when any action mutates", () => {
|
|
320
|
-
const state = empty({ nodes: [node("n1", 0, 0)] });
|
|
321
|
-
const out = reduceAll(state, [
|
|
322
|
-
setNodePosition({ key: "n1", position: { x: 9, y: 9 } }),
|
|
323
|
-
]);
|
|
324
|
-
expect(out.next).not.toBe(state);
|
|
325
|
-
expect(out.next.nodes).not.toBe(state.nodes);
|
|
326
|
-
});
|
|
327
|
-
it("should return the same state object when an action is a no-op", () => {
|
|
328
|
-
const state = empty({ nodes: [node("n1", 0, 0)] });
|
|
329
|
-
const out = reduceAll(state, [
|
|
330
|
-
setNodePosition({ key: "ghost", position: { x: 9, y: 9 } }),
|
|
331
|
-
]);
|
|
332
|
-
expect(out.next).toBe(state);
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
describe("real-world scenarios", () => {
|
|
337
|
-
it("should converge to the final position after a 30-action drag storm", () => {
|
|
338
|
-
const state = empty({ nodes: [node("pump", 0, 0)] });
|
|
339
|
-
const actions: Action[] = [];
|
|
340
|
-
for (let i = 0; i < 30; i++)
|
|
341
|
-
actions.push(setNodePosition({ key: "pump", position: { x: i, y: i * 2 } }));
|
|
342
|
-
const out = reduceAll(state, actions).next;
|
|
343
|
-
expect(out.nodes[0].position).toEqual({ x: 29, y: 58 });
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
it("should build a complete graph from an empty schematic", () => {
|
|
347
|
-
const out = apply(
|
|
348
|
-
empty(),
|
|
349
|
-
setNode({ node: node("pump", 0, 0) }),
|
|
350
|
-
setNode({ node: node("valve", 100, 0) }),
|
|
351
|
-
setNode({ node: node("tank", 200, 0) }),
|
|
352
|
-
addEdge({ edge: edge("e1", "pump", "out", "valve", "in") }),
|
|
353
|
-
addEdge({ edge: edge("e2", "valve", "out", "tank", "in") }),
|
|
354
|
-
setConfig({ key: "pump", config: { label: "Main Pump" } }),
|
|
355
|
-
setConfig({ key: "e1", config: { variant: "pipe" } }),
|
|
356
|
-
);
|
|
357
|
-
expect(out.nodes).toHaveLength(3);
|
|
358
|
-
expect(out.edges).toHaveLength(2);
|
|
359
|
-
expect(out.configs).toEqual({
|
|
360
|
-
pump: { label: "Main Pump" },
|
|
361
|
-
e1: { variant: "pipe" },
|
|
362
|
-
});
|
|
363
|
-
});
|
|
364
|
-
|
|
365
|
-
it("should drop config but keep dangling edges when a node is removed and re-added", () => {
|
|
366
|
-
const state = empty({
|
|
367
|
-
nodes: [node("n1", 0, 0), node("n2", 1, 1)],
|
|
368
|
-
edges: [edge("e1", "n1", "o", "n2", "i")],
|
|
369
|
-
configs: { n1: { label: "v1" } },
|
|
370
|
-
});
|
|
371
|
-
const out = apply(
|
|
372
|
-
state,
|
|
373
|
-
removeNode({ key: "n1" }),
|
|
374
|
-
setNode({ node: node("n1", 50, 50) }),
|
|
375
|
-
);
|
|
376
|
-
expect(out.nodes).toHaveLength(2);
|
|
377
|
-
expect(out.nodes[1]).toEqual(node("n1", 50, 50));
|
|
378
|
-
expect(out.configs).toEqual({});
|
|
379
|
-
expect(out.edges).toHaveLength(1);
|
|
380
|
-
expect(out.edges[0].source.node).toBe("n1");
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
it("should converge an idempotent action sequence to the same state as a single application", () => {
|
|
384
|
-
const state = empty({ nodes: [node("n1", 0, 0)] });
|
|
385
|
-
const a = setNodePosition({ key: "n1", position: { x: 10, y: 20 } });
|
|
386
|
-
expect(reduceAll(state, [a]).next).toEqual(reduceAll(state, [a, a, a]).next);
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
it("should apply a 50-action editor session and converge to a coherent schematic", () => {
|
|
390
|
-
const state = empty();
|
|
391
|
-
const actions: Action[] = [];
|
|
392
|
-
for (let i = 0; i < 5; i++)
|
|
393
|
-
actions.push(setNode({ node: node(`n${i}`, i * 100, 0) }));
|
|
394
|
-
for (let i = 0; i < 5; i++) {
|
|
395
|
-
actions.push(
|
|
396
|
-
setNodePosition({ key: `n${i}`, position: { x: i * 100, y: 50 } }),
|
|
397
|
-
);
|
|
398
|
-
actions.push(
|
|
399
|
-
setNodePosition({ key: `n${i}`, position: { x: i * 100, y: 100 } }),
|
|
400
|
-
);
|
|
401
|
-
}
|
|
402
|
-
for (let i = 0; i < 4; i++)
|
|
403
|
-
actions.push(
|
|
404
|
-
addEdge({
|
|
405
|
-
edge: edge(`e${i}`, `n${i}`, "out", `n${i + 1}`, "in"),
|
|
406
|
-
}),
|
|
407
|
-
);
|
|
408
|
-
for (let i = 0; i < 3; i++)
|
|
409
|
-
actions.push(setConfig({ key: `n${i}`, config: { label: `node ${i}` } }));
|
|
410
|
-
actions.push(setConfig({ key: "e1", config: { variant: "electric" } }));
|
|
411
|
-
const out = reduceAll(state, actions).next;
|
|
412
|
-
expect(out.nodes).toHaveLength(5);
|
|
413
|
-
expect(out.nodes[0].position).toEqual({ x: 0, y: 100 });
|
|
414
|
-
expect(out.nodes[4].position).toEqual({ x: 400, y: 100 });
|
|
415
|
-
expect(out.edges).toHaveLength(4);
|
|
416
|
-
expect(Object.keys(out.configs)).toHaveLength(4);
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
it("should leave state untouched when given an empty action list", () => {
|
|
420
|
-
const state = empty({ nodes: [node("n1", 0, 0)] });
|
|
421
|
-
expect(reduceAll(state, []).next).toBe(state);
|
|
422
|
-
});
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
describe("zod parsing", () => {
|
|
426
|
-
it("should reject an action with an unknown discriminator with a ZodError", () => {
|
|
427
|
-
expect(() => actionZ.parse({ type: "unknown", payload: { foo: 1 } })).toThrow(
|
|
428
|
-
z.ZodError,
|
|
429
|
-
);
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
it("should reject a setNodePosition action missing required fields with a ZodError", () => {
|
|
433
|
-
expect(() =>
|
|
434
|
-
actionZ.parse({ type: "set_node_position", setNodePosition: {} }),
|
|
435
|
-
).toThrow(z.ZodError);
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
it("should accept a fully populated setNodePosition action", () => {
|
|
439
|
-
const a = setNodePosition({ key: "n1", position: { x: 1, y: 2 } });
|
|
440
|
-
expect(actionZ.parse(a)).toEqual(a);
|
|
441
|
-
});
|
|
442
|
-
});
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
describe("schematic reducer inverses", () => {
|
|
446
|
-
const expectRoundTrip = (state: Schematic, actions: Action[]) => {
|
|
447
|
-
const { next, inverse } = reduceAll(state, actions);
|
|
448
|
-
const restored = reduceAll(next, inverse).next;
|
|
449
|
-
expect(restored).toEqual(state);
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
// Acknowledges the documented gap in setConfig's inverse: keys newly added
|
|
453
|
-
// by a SetConfig action cannot be removed by the inverse (SetConfig is a
|
|
454
|
-
// merge, not a replace). Asserts that nodes and edges round-trip cleanly,
|
|
455
|
-
// and that every config key present in the original is restored to its
|
|
456
|
-
// original value. Keys absent from the original may persist as phantom
|
|
457
|
-
// entries on the restored state.
|
|
458
|
-
const expectUserVisibleRoundTrip = (state: Schematic, actions: Action[]) => {
|
|
459
|
-
const { next, inverse } = reduceAll(state, actions);
|
|
460
|
-
const restored = reduceAll(next, inverse).next;
|
|
461
|
-
expect(restored.nodes).toEqual(state.nodes);
|
|
462
|
-
expect(restored.edges).toEqual(state.edges);
|
|
463
|
-
for (const [k, v] of Object.entries(state.configs))
|
|
464
|
-
expect(restored.configs[k]).toEqual(v);
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
describe("rename", () => {
|
|
468
|
-
it("should invert to restore the prior name", () => {
|
|
469
|
-
const state = empty({ name: "old" });
|
|
470
|
-
expectRoundTrip(state, [rename({ name: "new" })]);
|
|
471
|
-
});
|
|
472
|
-
it("should round-trip when renaming to the same name", () => {
|
|
473
|
-
const state = empty({ name: "same" });
|
|
474
|
-
expectRoundTrip(state, [rename({ name: "same" })]);
|
|
475
|
-
});
|
|
476
|
-
it("should report the schematic key as a target so concurrent renames invalidate each other", () => {
|
|
477
|
-
const state = empty({ key: "11111111-1111-1111-1111-111111111111", name: "a" });
|
|
478
|
-
const { targets } = reduceAll(state, [rename({ name: "b" })]);
|
|
479
|
-
expect(targets).toEqual([state.key]);
|
|
480
|
-
});
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
describe("setNodePosition", () => {
|
|
484
|
-
it("should invert to restore the prior position", () => {
|
|
485
|
-
const state = empty({ nodes: [node("n1", 1, 2)] });
|
|
486
|
-
expectRoundTrip(state, [
|
|
487
|
-
setNodePosition({ key: "n1", position: { x: 99, y: 100 } }),
|
|
488
|
-
]);
|
|
489
|
-
});
|
|
490
|
-
it("should produce an empty inverse for a no-op", () => {
|
|
491
|
-
const state = empty({ nodes: [node("n1", 1, 2)] });
|
|
492
|
-
const { inverse } = reduceAll(state, [
|
|
493
|
-
setNodePosition({ key: "ghost", position: { x: 9, y: 9 } }),
|
|
494
|
-
]);
|
|
495
|
-
expect(inverse).toEqual([]);
|
|
496
|
-
});
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
describe("setNode", () => {
|
|
500
|
-
it("should invert an insert with a removeNode", () => {
|
|
501
|
-
const state = empty({ nodes: [node("n1", 0, 0)] });
|
|
502
|
-
expectRoundTrip(state, [
|
|
503
|
-
setNode({ node: node("n2", 5, 5), config: { label: "x" } }),
|
|
504
|
-
]);
|
|
505
|
-
});
|
|
506
|
-
it("should invert a replace with a setNode of the prior node and config", () => {
|
|
507
|
-
const state = empty({
|
|
508
|
-
nodes: [node("n1", 1, 1)],
|
|
509
|
-
configs: { n1: { label: "Old", color: "#ff0000" } },
|
|
510
|
-
});
|
|
511
|
-
expectRoundTrip(state, [
|
|
512
|
-
setNode({ node: { ...node("n1", 9, 9) }, config: { label: "New" } }),
|
|
513
|
-
]);
|
|
514
|
-
});
|
|
515
|
-
it("should invert a replace with no new config by restoring the prior node", () => {
|
|
516
|
-
const state = empty({
|
|
517
|
-
nodes: [node("n1", 1, 1)],
|
|
518
|
-
configs: { n1: { label: "Old" } },
|
|
519
|
-
});
|
|
520
|
-
expectRoundTrip(state, [setNode({ node: node("n1", 9, 9) })]);
|
|
521
|
-
});
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
describe("removeNode", () => {
|
|
525
|
-
it("should invert by re-inserting the node and its config (order not preserved)", () => {
|
|
526
|
-
// setNode appends rather than inserting at a specific index, so a
|
|
527
|
-
// remove + undo cycle can rearrange the nodes array. The contents are
|
|
528
|
-
// restored but the original index is lost. Would be addressed by an
|
|
529
|
-
// InsertNode(node, idx) action.
|
|
530
|
-
const state = empty({
|
|
531
|
-
nodes: [node("n1", 0, 0), node("n2", 1, 1)],
|
|
532
|
-
configs: { n1: { label: "Pump" }, n2: { label: "Tank" } },
|
|
533
|
-
});
|
|
534
|
-
const { next, inverse } = reduceAll(state, [removeNode({ key: "n1" })]);
|
|
535
|
-
const restored = reduceAll(next, inverse).next;
|
|
536
|
-
expect(restored.configs).toEqual(state.configs);
|
|
537
|
-
const byKey = (ns: Schematic["nodes"]) =>
|
|
538
|
-
Object.fromEntries(ns.map((n) => [n.key, n]));
|
|
539
|
-
expect(byKey(restored.nodes)).toEqual(byKey(state.nodes));
|
|
540
|
-
});
|
|
541
|
-
it("should invert a single-node removal cleanly when order is unambiguous", () => {
|
|
542
|
-
const state = empty({ nodes: [node("n1", 0, 0)] });
|
|
543
|
-
expectRoundTrip(state, [removeNode({ key: "n1" })]);
|
|
544
|
-
});
|
|
545
|
-
it("should produce an empty inverse for a no-op removal", () => {
|
|
546
|
-
const state = empty({ nodes: [node("n1", 0, 0)] });
|
|
547
|
-
const { inverse } = reduceAll(state, [removeNode({ key: "ghost" })]);
|
|
548
|
-
expect(inverse).toEqual([]);
|
|
549
|
-
});
|
|
550
|
-
});
|
|
551
|
-
|
|
552
|
-
describe("addEdge / removeEdge", () => {
|
|
553
|
-
it("should invert addEdge with removeEdge", () => {
|
|
554
|
-
const state = empty();
|
|
555
|
-
expectRoundTrip(state, [addEdge({ edge: edge("e1", "a", "o", "b", "i") })]);
|
|
556
|
-
});
|
|
557
|
-
it("should invert removeEdge with addEdge", () => {
|
|
558
|
-
const state = empty({ edges: [edge("e1", "a", "o", "b", "i")] });
|
|
559
|
-
expectRoundTrip(state, [removeEdge({ key: "e1" })]);
|
|
560
|
-
});
|
|
561
|
-
it("should produce an empty inverse for a duplicate addEdge", () => {
|
|
562
|
-
const state = empty({ edges: [edge("e1", "a", "o", "b", "i")] });
|
|
563
|
-
const { inverse } = reduceAll(state, [
|
|
564
|
-
addEdge({ edge: edge("e1", "x", "y", "z", "w") }),
|
|
565
|
-
]);
|
|
566
|
-
expect(inverse).toEqual([]);
|
|
567
|
-
});
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
describe("setConfig", () => {
|
|
571
|
-
it("should restore overwritten fields and leave phantom new fields", () => {
|
|
572
|
-
const state = empty({
|
|
573
|
-
configs: { n1: { label: "Old", color: "#ff0000" } },
|
|
574
|
-
});
|
|
575
|
-
const { next, inverse } = reduceAll(state, [
|
|
576
|
-
setConfig({ key: "n1", config: { label: "New", count: 1 } }),
|
|
577
|
-
]);
|
|
578
|
-
const restored = reduceAll(next, inverse).next;
|
|
579
|
-
// Overwritten fields are restored to their original values:
|
|
580
|
-
expect(restored.configs.n1).toMatchObject({ label: "Old", color: "#ff0000" });
|
|
581
|
-
// Newly-added fields persist as phantom entries — documented limitation
|
|
582
|
-
// until a ReplaceConfig action exists.
|
|
583
|
-
expect(restored.configs.n1).toHaveProperty("count", 1);
|
|
584
|
-
});
|
|
585
|
-
it("should produce an empty inverse when no key in the payload was previously present", () => {
|
|
586
|
-
const state = empty({ configs: { n1: { label: "Old" } } });
|
|
587
|
-
const { inverse } = reduceAll(state, [
|
|
588
|
-
setConfig({ key: "n1", config: { count: 1 } }),
|
|
589
|
-
]);
|
|
590
|
-
expect(inverse).toEqual([]);
|
|
591
|
-
});
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
describe("setNodeMeasured", () => {
|
|
595
|
-
it("should be reported as not undoable", () => {
|
|
596
|
-
expect(
|
|
597
|
-
isUndoable(setNodeMeasured({ key: "n1", measured: { width: 10, height: 20 } })),
|
|
598
|
-
).toBe(false);
|
|
599
|
-
});
|
|
600
|
-
it("should produce an empty inverse", () => {
|
|
601
|
-
const state = empty({ nodes: [node("n1", 0, 0)] });
|
|
602
|
-
const { inverse } = reduceAll(state, [
|
|
603
|
-
setNodeMeasured({ key: "n1", measured: { width: 10, height: 20 } }),
|
|
604
|
-
]);
|
|
605
|
-
expect(inverse).toEqual([]);
|
|
606
|
-
});
|
|
607
|
-
it("should report no targets so it does not invalidate concurrent undoables", () => {
|
|
608
|
-
const state = empty({ nodes: [node("n1", 0, 0)] });
|
|
609
|
-
const { targets } = reduceAll(state, [
|
|
610
|
-
setNodeMeasured({ key: "n1", measured: { width: 10, height: 20 } }),
|
|
611
|
-
]);
|
|
612
|
-
expect(targets).toEqual([]);
|
|
613
|
-
});
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
describe("multi-action transactions", () => {
|
|
617
|
-
it("should invert a build sequence (nodes and edges restored; phantom edge config persists)", () => {
|
|
618
|
-
// Inverse cannot strip the e1 config that setConfig added — see
|
|
619
|
-
// expectUserVisibleRoundTrip's docstring for the limitation.
|
|
620
|
-
expectUserVisibleRoundTrip(empty(), [
|
|
621
|
-
setNode({ node: node("pump", 0, 0) }),
|
|
622
|
-
setNode({ node: node("valve", 100, 0) }),
|
|
623
|
-
addEdge({ edge: edge("e1", "pump", "out", "valve", "in") }),
|
|
624
|
-
setConfig({ key: "e1", config: { variant: "pipe" } }),
|
|
625
|
-
]);
|
|
626
|
-
});
|
|
627
|
-
it("should invert a multi-step move to the original positions", () => {
|
|
628
|
-
const state = empty({ nodes: [node("n1", 0, 0), node("n2", 1, 1)] });
|
|
629
|
-
expectRoundTrip(state, [
|
|
630
|
-
setNodePosition({ key: "n1", position: { x: 10, y: 20 } }),
|
|
631
|
-
setNodePosition({ key: "n2", position: { x: 30, y: 40 } }),
|
|
632
|
-
]);
|
|
633
|
-
});
|
|
634
|
-
it("should invert a remove + re-add by restoring the original schematic", () => {
|
|
635
|
-
const state = empty({
|
|
636
|
-
nodes: [node("n1", 0, 0)],
|
|
637
|
-
configs: { n1: { label: "Pump" } },
|
|
638
|
-
});
|
|
639
|
-
expectRoundTrip(state, [
|
|
640
|
-
removeNode({ key: "n1" }),
|
|
641
|
-
setNode({ node: node("n1", 50, 50), config: { label: "Pump" } }),
|
|
642
|
-
]);
|
|
643
|
-
});
|
|
644
|
-
});
|
|
645
|
-
|
|
646
|
-
describe("isUndoable", () => {
|
|
647
|
-
it("should return true for every action other than setNodeMeasured", () => {
|
|
648
|
-
expect(isUndoable(rename({ name: "x" }))).toBe(true);
|
|
649
|
-
expect(isUndoable(setNodePosition({ key: "n1", position: { x: 0, y: 0 } }))).toBe(
|
|
650
|
-
true,
|
|
651
|
-
);
|
|
652
|
-
expect(isUndoable(setNode({ node: node("n1", 0, 0) }))).toBe(true);
|
|
653
|
-
expect(isUndoable(removeNode({ key: "n1" }))).toBe(true);
|
|
654
|
-
expect(isUndoable(addEdge({ edge: edge("e1", "a", "o", "b", "i") }))).toBe(true);
|
|
655
|
-
expect(isUndoable(removeEdge({ key: "e1" }))).toBe(true);
|
|
656
|
-
expect(isUndoable(setConfig({ key: "n1", config: {} }))).toBe(true);
|
|
657
|
-
});
|
|
658
|
-
});
|
|
659
|
-
|
|
660
|
-
describe("single-action reduce against a draft", () => {
|
|
661
|
-
it("should return the inverse and mutate the draft via reduceAll", () => {
|
|
662
|
-
const state = empty({ nodes: [node("n1", 0, 0)] });
|
|
663
|
-
const { next, inverse } = reduceAll(state, [
|
|
664
|
-
setNodePosition({ key: "n1", position: { x: 10, y: 20 } }),
|
|
665
|
-
]);
|
|
666
|
-
expect(next.nodes[0].position).toEqual({ x: 10, y: 20 });
|
|
667
|
-
expect(inverse).toEqual([
|
|
668
|
-
setNodePosition({ key: "n1", position: { x: 0, y: 0 } }),
|
|
669
|
-
]);
|
|
670
|
-
});
|
|
671
|
-
});
|
|
672
|
-
|
|
673
|
-
describe("coalesced setConfig undo (regression)", () => {
|
|
674
|
-
it("should restore the original config after two rapid setConfig calls", () => {
|
|
675
|
-
const initial = empty({
|
|
676
|
-
nodes: [node("n1", 0, 0)],
|
|
677
|
-
configs: { n1: { label: { level: "p" }, scale: 1, color: "red" } },
|
|
678
|
-
});
|
|
679
|
-
// Each dispatch carries the FULL form values, matching IndividualConfig's
|
|
680
|
-
// onChange: ({ values }) => dispatch(setConfig({ key, config: values })).
|
|
681
|
-
const r1 = reduceAll(initial, [
|
|
682
|
-
setConfig({
|
|
683
|
-
key: "n1",
|
|
684
|
-
config: { label: { level: "h2" }, scale: 1, color: "red" },
|
|
685
|
-
}),
|
|
686
|
-
]);
|
|
687
|
-
const r2 = reduceAll(r1.next, [
|
|
688
|
-
setConfig({
|
|
689
|
-
key: "n1",
|
|
690
|
-
config: { label: { level: "h3" }, scale: 1, color: "red" },
|
|
691
|
-
}),
|
|
692
|
-
]);
|
|
693
|
-
// Matches pushOnto's coalescing: inverse = [next.inverse, ...top.inverse]
|
|
694
|
-
const mergedInverse = [...r2.inverse, ...r1.inverse];
|
|
695
|
-
const restored = reduceAll(r2.next, mergedInverse).next;
|
|
696
|
-
expect(restored.configs.n1).toEqual(initial.configs.n1);
|
|
697
|
-
});
|
|
698
|
-
});
|
|
699
|
-
});
|