@synnaxlabs/client 0.49.3 → 0.52.3
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/.turbo/turbo-build.log +10 -10
- package/CONTRIBUTING.md +1 -2
- package/README.md +1 -1
- package/dist/client.cjs +58 -34
- package/dist/client.js +5256 -4528
- package/dist/eslint.config.d.ts +2 -2
- package/dist/eslint.config.d.ts.map +1 -1
- package/dist/src/access/policy/client.d.ts +90 -76
- package/dist/src/access/policy/client.d.ts.map +1 -1
- package/dist/src/access/policy/payload.d.ts +17 -14
- package/dist/src/access/policy/payload.d.ts.map +1 -1
- package/dist/src/access/role/payload.d.ts +2 -2
- package/dist/src/arc/payload.d.ts +21 -20
- package/dist/src/arc/payload.d.ts.map +1 -1
- package/dist/src/channel/client.d.ts +9 -15
- package/dist/src/channel/client.d.ts.map +1 -1
- package/dist/src/channel/payload.d.ts +18 -18
- package/dist/src/channel/payload.d.ts.map +1 -1
- package/dist/src/channel/retriever.d.ts.map +1 -1
- package/dist/src/client.d.ts +12 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/device/client.d.ts +14 -7
- package/dist/src/device/client.d.ts.map +1 -1
- package/dist/src/device/payload.d.ts +65 -32
- package/dist/src/device/payload.d.ts.map +1 -1
- package/dist/src/device/payload.spec.d.ts +2 -0
- package/dist/src/device/payload.spec.d.ts.map +1 -0
- package/dist/src/framer/adapter.d.ts.map +1 -1
- package/dist/src/framer/client.d.ts +2 -2
- package/dist/src/framer/frame.d.ts +5 -5
- package/dist/src/framer/frame.d.ts.map +1 -1
- package/dist/src/framer/streamer.d.ts +7 -17
- package/dist/src/framer/streamer.d.ts.map +1 -1
- package/dist/src/framer/writer.d.ts +9 -19
- package/dist/src/framer/writer.d.ts.map +1 -1
- package/dist/src/group/access.spec.d.ts.map +1 -0
- package/dist/src/{ontology/group → group}/client.d.ts +3 -2
- package/dist/src/group/client.d.ts.map +1 -0
- package/dist/src/group/external.d.ts.map +1 -0
- package/dist/src/group/group.spec.d.ts.map +1 -0
- package/dist/src/group/index.d.ts.map +1 -0
- package/dist/src/{ontology/group → group}/payload.d.ts +1 -1
- package/dist/src/group/payload.d.ts.map +1 -0
- package/dist/src/index.d.ts +6 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/label/client.d.ts +27 -10
- package/dist/src/label/client.d.ts.map +1 -1
- package/dist/src/label/payload.d.ts +15 -1
- package/dist/src/label/payload.d.ts.map +1 -1
- package/dist/src/lineplot/access.spec.d.ts.map +1 -0
- package/dist/src/{workspace/lineplot → lineplot}/client.d.ts +6 -6
- package/dist/src/lineplot/client.d.ts.map +1 -0
- package/dist/src/lineplot/external.d.ts.map +1 -0
- package/dist/src/lineplot/index.d.ts.map +1 -0
- package/dist/src/lineplot/lineplot.spec.d.ts.map +1 -0
- package/dist/src/{workspace/lineplot → lineplot}/payload.d.ts +3 -3
- package/dist/src/lineplot/payload.d.ts.map +1 -0
- package/dist/src/log/access.spec.d.ts.map +1 -0
- package/dist/src/{workspace/log → log}/client.d.ts +6 -6
- package/dist/src/log/client.d.ts.map +1 -0
- package/dist/src/log/external.d.ts.map +1 -0
- package/dist/src/log/index.d.ts.map +1 -0
- package/dist/src/log/log.spec.d.ts.map +1 -0
- package/dist/src/{workspace/log → log}/payload.d.ts +3 -3
- package/dist/src/log/payload.d.ts.map +1 -0
- package/dist/src/ontology/client.d.ts +7 -9
- package/dist/src/ontology/client.d.ts.map +1 -1
- package/dist/src/ontology/payload.d.ts +25 -20
- package/dist/src/ontology/payload.d.ts.map +1 -1
- package/dist/src/ontology/writer.d.ts +15 -10
- package/dist/src/ontology/writer.d.ts.map +1 -1
- package/dist/src/rack/client.d.ts +2 -2
- package/dist/src/rack/payload.d.ts +44 -16
- package/dist/src/rack/payload.d.ts.map +1 -1
- package/dist/src/ranger/alias/client.d.ts +17 -0
- package/dist/src/ranger/alias/client.d.ts.map +1 -0
- package/dist/src/ranger/alias/external.d.ts +2 -0
- package/dist/src/ranger/alias/external.d.ts.map +1 -0
- package/dist/src/ranger/alias/index.d.ts +2 -0
- package/dist/src/ranger/alias/index.d.ts.map +1 -0
- package/dist/src/ranger/{alias.d.ts → alias/payload.d.ts} +14 -20
- package/dist/src/ranger/alias/payload.d.ts.map +1 -0
- package/dist/src/ranger/client.d.ts +10 -10
- package/dist/src/ranger/client.d.ts.map +1 -1
- package/dist/src/ranger/external.d.ts +20 -0
- package/dist/src/ranger/external.d.ts.map +1 -1
- package/dist/src/ranger/kv/client.d.ts +14 -0
- package/dist/src/ranger/kv/client.d.ts.map +1 -0
- package/dist/src/ranger/kv/external.d.ts +2 -0
- package/dist/src/ranger/kv/external.d.ts.map +1 -0
- package/dist/src/ranger/kv/index.d.ts +2 -0
- package/dist/src/ranger/kv/index.d.ts.map +1 -0
- package/dist/src/ranger/kv/payload.d.ts +26 -0
- package/dist/src/ranger/kv/payload.d.ts.map +1 -0
- package/dist/src/ranger/payload.d.ts +45 -3
- package/dist/src/ranger/payload.d.ts.map +1 -1
- package/dist/src/ranger/writer.d.ts +18 -3
- package/dist/src/ranger/writer.d.ts.map +1 -1
- package/dist/src/schematic/access.spec.d.ts.map +1 -0
- package/dist/src/{workspace/schematic → schematic}/client.d.ts +6 -6
- package/dist/src/schematic/client.d.ts.map +1 -0
- package/dist/src/schematic/external.d.ts.map +1 -0
- package/dist/src/schematic/index.d.ts.map +1 -0
- package/dist/src/{workspace/schematic → schematic}/payload.d.ts +3 -3
- package/dist/src/schematic/payload.d.ts.map +1 -0
- package/dist/src/schematic/schematic.spec.d.ts.map +1 -0
- package/dist/src/schematic/symbol/access.spec.d.ts.map +1 -0
- package/dist/src/{workspace/schematic → schematic}/symbol/client.d.ts +2 -2
- package/dist/src/schematic/symbol/client.d.ts.map +1 -0
- package/dist/src/schematic/symbol/client.spec.d.ts.map +1 -0
- package/dist/src/schematic/symbol/external.d.ts.map +1 -0
- package/dist/src/schematic/symbol/index.d.ts.map +1 -0
- package/dist/src/schematic/symbol/payload.d.ts.map +1 -0
- package/dist/src/status/payload.d.ts +43 -7
- package/dist/src/status/payload.d.ts.map +1 -1
- package/dist/src/table/access.spec.d.ts.map +1 -0
- package/dist/src/{workspace/table → table}/client.d.ts +6 -6
- package/dist/src/table/client.d.ts.map +1 -0
- package/dist/src/table/external.d.ts.map +1 -0
- package/dist/src/table/index.d.ts.map +1 -0
- package/dist/src/{workspace/table → table}/payload.d.ts +3 -3
- package/dist/src/table/payload.d.ts.map +1 -0
- package/dist/src/table/table.spec.d.ts.map +1 -0
- package/dist/src/task/client.d.ts +2 -2
- package/dist/src/task/client.d.ts.map +1 -1
- package/dist/src/task/payload.d.ts +5 -4
- package/dist/src/task/payload.d.ts.map +1 -1
- package/dist/src/task/payload.spec.d.ts +2 -0
- package/dist/src/task/payload.spec.d.ts.map +1 -0
- package/dist/src/user/client.d.ts +2 -2
- package/dist/src/view/client.d.ts +43 -0
- package/dist/src/view/client.d.ts.map +1 -0
- package/dist/src/view/external.d.ts +3 -0
- package/dist/src/view/external.d.ts.map +1 -0
- package/dist/src/view/index.d.ts +2 -0
- package/dist/src/view/index.d.ts.map +1 -0
- package/dist/src/view/payload.d.ts +20 -0
- package/dist/src/view/payload.d.ts.map +1 -0
- package/dist/src/view/view.spec.d.ts +2 -0
- package/dist/src/view/view.spec.d.ts.map +1 -0
- package/dist/src/workspace/client.d.ts +3 -11
- package/dist/src/workspace/client.d.ts.map +1 -1
- package/dist/src/workspace/payload.d.ts +3 -3
- package/eslint.config.ts +3 -4
- package/examples/node/basicReadWrite.js +1 -1
- package/examples/node/createChannels.js +50 -0
- package/examples/node/createRange.js +67 -0
- package/examples/node/readLatest.js +76 -0
- package/examples/node/seriesAndFrames.js +2 -2
- package/examples/node/{liveStream.js → streamRead.js} +1 -1
- package/examples/node/streamWrite.js +1 -1
- package/package.json +11 -10
- package/src/access/client.ts +1 -1
- package/src/access/enforce.spec.ts +1 -1
- package/src/access/enforce.ts +1 -1
- package/src/access/external.ts +1 -1
- package/src/access/index.ts +1 -1
- package/src/access/payload.ts +1 -1
- package/src/access/policy/access.spec.ts +1 -1
- package/src/access/policy/client.ts +1 -1
- package/src/access/policy/external.ts +1 -1
- package/src/access/policy/index.ts +1 -1
- package/src/access/policy/payload.ts +1 -1
- package/src/access/role/client.ts +1 -1
- package/src/access/role/external.ts +1 -1
- package/src/access/role/index.ts +1 -1
- package/src/access/role/payload.ts +1 -1
- package/src/access/role/role.spec.ts +1 -1
- package/src/arc/access.spec.ts +1 -7
- package/src/arc/client.ts +1 -1
- package/src/arc/external.ts +1 -1
- package/src/arc/index.ts +1 -1
- package/src/arc/lsp.spec.ts +156 -287
- package/src/arc/payload.ts +7 -12
- package/src/auth/auth.spec.ts +1 -1
- package/src/auth/auth.ts +1 -1
- package/src/auth/index.ts +1 -1
- package/src/channel/access.spec.ts +1 -1
- package/src/channel/batchRetriever.spec.ts +1 -3
- package/src/channel/channel.spec.ts +13 -20
- package/src/channel/client.ts +8 -41
- package/src/channel/external.ts +1 -1
- package/src/channel/index.ts +1 -1
- package/src/channel/payload.spec.ts +1 -58
- package/src/channel/payload.ts +19 -19
- package/src/channel/retriever.ts +7 -6
- package/src/channel/writer.ts +1 -1
- package/src/client.ts +24 -4
- package/src/connection/checker.ts +2 -2
- package/src/connection/connection.spec.ts +1 -1
- package/src/connection/index.ts +1 -1
- package/src/connection.spec.ts +1 -1
- package/src/control/client.ts +1 -1
- package/src/control/external.ts +1 -1
- package/src/control/index.ts +1 -1
- package/src/control/state.spec.ts +1 -1
- package/src/control/state.ts +1 -1
- package/src/device/access.spec.ts +1 -1
- package/src/device/client.ts +90 -44
- package/src/device/device.spec.ts +1 -1
- package/src/device/external.ts +1 -1
- package/src/device/index.ts +1 -1
- package/src/device/payload.spec.ts +118 -0
- package/src/device/payload.ts +56 -31
- package/src/errors.spec.ts +2 -2
- package/src/errors.ts +1 -1
- package/src/framer/adapter.spec.ts +1 -1
- package/src/framer/adapter.ts +6 -8
- package/src/framer/client.spec.ts +1 -1
- package/src/framer/client.ts +1 -1
- package/src/framer/codec.spec.ts +1 -1
- package/src/framer/codec.ts +1 -1
- package/src/framer/deleter.spec.ts +1 -1
- package/src/framer/deleter.ts +1 -1
- package/src/framer/external.ts +1 -1
- package/src/framer/frame.spec.ts +1 -1
- package/src/framer/frame.ts +9 -9
- package/src/framer/index.ts +1 -1
- package/src/framer/iterator.spec.ts +1 -1
- package/src/framer/iterator.ts +1 -1
- package/src/framer/payload.ts +1 -1
- package/src/framer/reader.spec.ts +1 -1
- package/src/framer/reader.ts +1 -1
- package/src/framer/streamProxy.ts +1 -1
- package/src/framer/streamer.spec.ts +1 -2
- package/src/framer/streamer.ts +4 -4
- package/src/framer/writer.spec.ts +1 -1
- package/src/framer/writer.ts +1 -1
- package/src/{ontology/group → group}/access.spec.ts +8 -8
- package/src/{ontology/group → group}/client.ts +2 -2
- package/src/group/external.ts +11 -0
- package/src/{ontology/group → group}/group.spec.ts +10 -10
- package/src/{workspace/log → group}/index.ts +2 -2
- package/src/{ontology/group → group}/payload.ts +1 -1
- package/src/index.ts +7 -6
- package/src/label/access.spec.ts +2 -2
- package/src/label/client.ts +2 -2
- package/src/label/external.ts +1 -1
- package/src/label/index.ts +1 -1
- package/src/label/label.spec.ts +5 -5
- package/src/label/payload.ts +1 -1
- package/src/{workspace/lineplot → lineplot}/access.spec.ts +15 -15
- package/src/{workspace/lineplot → lineplot}/client.ts +14 -14
- package/src/lineplot/external.ts +11 -0
- package/src/{ontology/group → lineplot}/index.ts +2 -2
- package/src/{workspace/lineplot → lineplot}/lineplot.spec.ts +13 -13
- package/src/{workspace/lineplot → lineplot}/payload.ts +1 -1
- package/src/{workspace/log → log}/access.spec.ts +17 -19
- package/src/{workspace/log → log}/client.ts +14 -14
- package/src/{workspace/schematic/index.ts → log/external.ts} +3 -2
- package/src/{workspace/table → log}/index.ts +2 -2
- package/src/{workspace/log → log}/log.spec.ts +11 -11
- package/src/{workspace/log → log}/payload.ts +1 -1
- package/src/ontology/client.ts +7 -14
- package/src/ontology/external.ts +1 -1
- package/src/ontology/index.ts +1 -1
- package/src/ontology/ontology.spec.ts +13 -13
- package/src/ontology/payload.ts +6 -3
- package/src/ontology/writer.ts +1 -1
- package/src/rack/access.spec.ts +1 -1
- package/src/rack/client.ts +1 -1
- package/src/rack/external.ts +1 -1
- package/src/rack/index.ts +1 -1
- package/src/rack/payload.ts +1 -1
- package/src/rack/rack.spec.ts +1 -1
- package/src/ranger/access.spec.ts +1 -1
- package/src/ranger/{alias.ts → alias/client.ts} +7 -38
- package/src/{workspace/lineplot → ranger/alias}/external.ts +11 -3
- package/src/{workspace/lineplot → ranger/alias}/index.ts +2 -2
- package/src/ranger/alias/payload.ts +50 -0
- package/src/ranger/client.ts +27 -20
- package/src/ranger/external.ts +23 -1
- package/src/ranger/index.ts +1 -1
- package/src/ranger/{kv.ts → kv/client.ts} +6 -20
- package/src/{workspace/schematic → ranger/kv}/external.ts +8 -4
- package/src/ranger/kv/index.ts +10 -0
- package/src/ranger/kv/payload.ts +32 -0
- package/src/ranger/payload.ts +3 -3
- package/src/ranger/ranger.spec.ts +2 -2
- package/src/ranger/writer.ts +1 -1
- package/src/{workspace/schematic → schematic}/access.spec.ts +15 -15
- package/src/{workspace/schematic → schematic}/client.ts +15 -15
- package/src/{workspace/log → schematic}/external.ts +4 -3
- package/src/schematic/index.ts +10 -0
- package/src/{workspace/schematic → schematic}/payload.ts +1 -1
- package/src/{workspace/schematic → schematic}/schematic.spec.ts +18 -18
- package/src/{workspace/schematic → schematic}/symbol/access.spec.ts +20 -20
- package/src/{workspace/schematic → schematic}/symbol/client.spec.ts +17 -17
- package/src/{workspace/schematic → schematic}/symbol/client.ts +9 -9
- package/src/{ontology/group → schematic/symbol}/external.ts +3 -3
- package/src/schematic/symbol/index.ts +10 -0
- package/src/{workspace/schematic → schematic}/symbol/payload.ts +1 -1
- package/src/status/access.spec.ts +1 -1
- package/src/status/client.ts +1 -1
- package/src/status/external.ts +1 -1
- package/src/status/index.ts +1 -1
- package/src/status/payload.ts +2 -2
- package/src/status/status.spec.ts +3 -3
- package/src/{workspace/table → table}/access.spec.ts +15 -15
- package/src/{workspace/table → table}/client.ts +16 -13
- package/src/table/external.ts +11 -0
- package/src/table/index.ts +10 -0
- package/src/{workspace/table → table}/payload.ts +1 -1
- package/src/{workspace/table → table}/table.spec.ts +13 -13
- package/src/task/access.spec.ts +1 -1
- package/src/task/client.ts +11 -6
- package/src/task/external.ts +1 -1
- package/src/task/index.ts +1 -1
- package/src/task/payload.spec.ts +113 -0
- package/src/task/payload.ts +14 -10
- package/src/task/task.spec.ts +1 -1
- package/src/testutil/access.ts +1 -1
- package/src/testutil/channels.ts +1 -1
- package/src/testutil/client.ts +1 -1
- package/src/testutil/telem.ts +1 -1
- package/src/transport.ts +1 -1
- package/src/user/access.spec.ts +1 -1
- package/src/user/client.ts +1 -1
- package/src/user/external.ts +1 -1
- package/src/user/index.ts +1 -1
- package/src/user/payload.ts +1 -1
- package/src/user/user.spec.ts +1 -1
- package/src/util/decodeJSONString.ts +1 -1
- package/src/util/parseWithoutKeyConversion.ts +1 -1
- package/src/util/retrieve.spec.ts +1 -1
- package/src/util/retrieve.ts +1 -1
- package/src/util/telem.ts +1 -1
- package/src/view/client.ts +96 -0
- package/src/view/external.ts +11 -0
- package/src/view/index.ts +10 -0
- package/src/view/payload.ts +25 -0
- package/src/view/view.spec.ts +161 -0
- package/src/vite-env.d.ts +1 -1
- package/src/workspace/access.spec.ts +1 -1
- package/src/workspace/client.ts +1 -13
- package/src/workspace/external.ts +1 -1
- package/src/workspace/index.ts +1 -1
- package/src/workspace/payload.ts +1 -1
- package/src/workspace/workspace.spec.ts +1 -1
- package/vite.config.ts +1 -1
- package/dist/src/ontology/group/access.spec.d.ts.map +0 -1
- package/dist/src/ontology/group/client.d.ts.map +0 -1
- package/dist/src/ontology/group/external.d.ts.map +0 -1
- package/dist/src/ontology/group/group.spec.d.ts.map +0 -1
- package/dist/src/ontology/group/index.d.ts.map +0 -1
- package/dist/src/ontology/group/payload.d.ts.map +0 -1
- package/dist/src/ranger/alias.d.ts.map +0 -1
- package/dist/src/ranger/kv.d.ts +0 -48
- package/dist/src/ranger/kv.d.ts.map +0 -1
- package/dist/src/workspace/lineplot/access.spec.d.ts.map +0 -1
- package/dist/src/workspace/lineplot/client.d.ts.map +0 -1
- package/dist/src/workspace/lineplot/external.d.ts.map +0 -1
- package/dist/src/workspace/lineplot/index.d.ts.map +0 -1
- package/dist/src/workspace/lineplot/lineplot.spec.d.ts.map +0 -1
- package/dist/src/workspace/lineplot/payload.d.ts.map +0 -1
- package/dist/src/workspace/log/access.spec.d.ts.map +0 -1
- package/dist/src/workspace/log/client.d.ts.map +0 -1
- package/dist/src/workspace/log/external.d.ts.map +0 -1
- package/dist/src/workspace/log/index.d.ts.map +0 -1
- package/dist/src/workspace/log/log.spec.d.ts.map +0 -1
- package/dist/src/workspace/log/payload.d.ts.map +0 -1
- package/dist/src/workspace/schematic/access.spec.d.ts.map +0 -1
- package/dist/src/workspace/schematic/client.d.ts.map +0 -1
- package/dist/src/workspace/schematic/external.d.ts.map +0 -1
- package/dist/src/workspace/schematic/index.d.ts.map +0 -1
- package/dist/src/workspace/schematic/payload.d.ts.map +0 -1
- package/dist/src/workspace/schematic/schematic.spec.d.ts.map +0 -1
- package/dist/src/workspace/schematic/symbol/access.spec.d.ts.map +0 -1
- package/dist/src/workspace/schematic/symbol/client.d.ts.map +0 -1
- package/dist/src/workspace/schematic/symbol/client.spec.d.ts.map +0 -1
- package/dist/src/workspace/schematic/symbol/external.d.ts.map +0 -1
- package/dist/src/workspace/schematic/symbol/index.d.ts.map +0 -1
- package/dist/src/workspace/schematic/symbol/payload.d.ts.map +0 -1
- package/dist/src/workspace/table/access.spec.d.ts.map +0 -1
- package/dist/src/workspace/table/client.d.ts.map +0 -1
- package/dist/src/workspace/table/external.d.ts.map +0 -1
- package/dist/src/workspace/table/index.d.ts.map +0 -1
- package/dist/src/workspace/table/payload.d.ts.map +0 -1
- package/dist/src/workspace/table/table.spec.d.ts.map +0 -1
- package/src/workspace/schematic/symbol/external.ts +0 -11
- package/src/workspace/schematic/symbol/index.ts +0 -10
- package/src/workspace/table/external.ts +0 -11
- /package/dist/src/{ontology/group → group}/access.spec.d.ts +0 -0
- /package/dist/src/{ontology/group → group}/external.d.ts +0 -0
- /package/dist/src/{ontology/group → group}/group.spec.d.ts +0 -0
- /package/dist/src/{ontology/group → group}/index.d.ts +0 -0
- /package/dist/src/{workspace/lineplot → lineplot}/access.spec.d.ts +0 -0
- /package/dist/src/{workspace/lineplot → lineplot}/external.d.ts +0 -0
- /package/dist/src/{workspace/lineplot → lineplot}/index.d.ts +0 -0
- /package/dist/src/{workspace/lineplot → lineplot}/lineplot.spec.d.ts +0 -0
- /package/dist/src/{workspace/log → log}/access.spec.d.ts +0 -0
- /package/dist/src/{workspace/log → log}/external.d.ts +0 -0
- /package/dist/src/{workspace/log → log}/index.d.ts +0 -0
- /package/dist/src/{workspace/log → log}/log.spec.d.ts +0 -0
- /package/dist/src/{workspace/schematic → schematic}/access.spec.d.ts +0 -0
- /package/dist/src/{workspace/schematic → schematic}/external.d.ts +0 -0
- /package/dist/src/{workspace/schematic → schematic}/index.d.ts +0 -0
- /package/dist/src/{workspace/schematic → schematic}/schematic.spec.d.ts +0 -0
- /package/dist/src/{workspace/schematic → schematic}/symbol/access.spec.d.ts +0 -0
- /package/dist/src/{workspace/schematic → schematic}/symbol/client.spec.d.ts +0 -0
- /package/dist/src/{workspace/schematic → schematic}/symbol/external.d.ts +0 -0
- /package/dist/src/{workspace/schematic → schematic}/symbol/index.d.ts +0 -0
- /package/dist/src/{workspace/schematic → schematic}/symbol/payload.d.ts +0 -0
- /package/dist/src/{workspace/table → table}/access.spec.d.ts +0 -0
- /package/dist/src/{workspace/table → table}/external.d.ts +0 -0
- /package/dist/src/{workspace/table → table}/index.d.ts +0 -0
- /package/dist/src/{workspace/table → table}/table.spec.d.ts +0 -0
package/src/device/client.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2026 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -8,10 +8,18 @@
|
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
10
|
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
|
-
import { array, type record } from "@synnaxlabs/x";
|
|
11
|
+
import { array, type record, zod } from "@synnaxlabs/x";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
type Device,
|
|
16
|
+
type DeviceSchemas,
|
|
17
|
+
deviceZ,
|
|
18
|
+
type Key,
|
|
19
|
+
keyZ,
|
|
20
|
+
type New,
|
|
21
|
+
newZ,
|
|
22
|
+
} from "@/device/payload";
|
|
15
23
|
import { ontology } from "@/ontology";
|
|
16
24
|
import { keyZ as rackKeyZ } from "@/rack/payload";
|
|
17
25
|
import { checkForMultipleOrNoResults } from "@/util/retrieve";
|
|
@@ -19,8 +27,21 @@ import { checkForMultipleOrNoResults } from "@/util/retrieve";
|
|
|
19
27
|
export const SET_CHANNEL_NAME = "sy_device_set";
|
|
20
28
|
export const DELETE_CHANNEL_NAME = "sy_device_delete";
|
|
21
29
|
|
|
22
|
-
const createReqZ =
|
|
23
|
-
|
|
30
|
+
const createReqZ = <
|
|
31
|
+
Properties extends z.ZodType<record.Unknown> = typeof record.unknownZ,
|
|
32
|
+
Make extends z.ZodType<string> = z.ZodString,
|
|
33
|
+
Model extends z.ZodType<string> = z.ZodString,
|
|
34
|
+
>(
|
|
35
|
+
schemas?: DeviceSchemas<Properties, Make, Model>,
|
|
36
|
+
) => z.object({ devices: zod.toArray(newZ(schemas)) });
|
|
37
|
+
|
|
38
|
+
const createResZ = <
|
|
39
|
+
Properties extends z.ZodType<record.Unknown> = typeof record.unknownZ,
|
|
40
|
+
Make extends z.ZodType<string> = z.ZodString,
|
|
41
|
+
Model extends z.ZodType<string> = z.ZodString,
|
|
42
|
+
>(
|
|
43
|
+
schemas?: DeviceSchemas<Properties, Make, Model>,
|
|
44
|
+
) => z.object({ devices: deviceZ(schemas).array() });
|
|
24
45
|
|
|
25
46
|
const deleteReqZ = z.object({ keys: keyZ.array() });
|
|
26
47
|
const deleteResZ = z.object({});
|
|
@@ -37,7 +58,14 @@ const retrieveRequestZ = z.object({
|
|
|
37
58
|
offset: z.int().optional(),
|
|
38
59
|
includeStatus: z.boolean().optional(),
|
|
39
60
|
});
|
|
40
|
-
|
|
61
|
+
|
|
62
|
+
const retrieveResZ = <
|
|
63
|
+
Properties extends z.ZodType<record.Unknown> = typeof record.unknownZ,
|
|
64
|
+
Make extends z.ZodType<string> = z.ZodString,
|
|
65
|
+
Model extends z.ZodType<string> = z.ZodString,
|
|
66
|
+
>(
|
|
67
|
+
schemas?: DeviceSchemas<Properties, Make, Model>,
|
|
68
|
+
) => z.object({ devices: array.nullableZ(deviceZ(schemas)) });
|
|
41
69
|
|
|
42
70
|
const singleRetrieveArgsZ = z
|
|
43
71
|
.object({
|
|
@@ -56,6 +84,12 @@ const retrieveArgsZ = z.union([singleRetrieveArgsZ, retrieveRequestZ]);
|
|
|
56
84
|
|
|
57
85
|
export type RetrieveArgs = z.input<typeof retrieveArgsZ>;
|
|
58
86
|
|
|
87
|
+
type RetrieveSchemas<
|
|
88
|
+
Properties extends z.ZodType<record.Unknown>,
|
|
89
|
+
Make extends z.ZodType<string>,
|
|
90
|
+
Model extends z.ZodType<string>,
|
|
91
|
+
> = { schemas: DeviceSchemas<Properties, Make, Model> };
|
|
92
|
+
|
|
59
93
|
export class Client {
|
|
60
94
|
private readonly client: UnaryClient;
|
|
61
95
|
|
|
@@ -64,64 +98,76 @@ export class Client {
|
|
|
64
98
|
}
|
|
65
99
|
|
|
66
100
|
async retrieve<
|
|
67
|
-
Properties extends
|
|
68
|
-
Make extends string
|
|
69
|
-
Model extends string
|
|
70
|
-
>(
|
|
101
|
+
Properties extends z.ZodType<record.Unknown>,
|
|
102
|
+
Make extends z.ZodType<string>,
|
|
103
|
+
Model extends z.ZodType<string>,
|
|
104
|
+
>(
|
|
105
|
+
args: RetrieveSingleParams & RetrieveSchemas<Properties, Make, Model>,
|
|
106
|
+
): Promise<Device<Properties, Make, Model>>;
|
|
71
107
|
|
|
72
|
-
async retrieve<
|
|
73
|
-
Properties extends record.Unknown = record.Unknown,
|
|
74
|
-
Make extends string = string,
|
|
75
|
-
Model extends string = string,
|
|
76
|
-
>(args: RetrieveMultipleParams): Promise<Array<Device<Properties, Make, Model>>>;
|
|
108
|
+
async retrieve(args: RetrieveSingleParams): Promise<Device>;
|
|
77
109
|
|
|
78
110
|
async retrieve<
|
|
79
|
-
Properties extends
|
|
80
|
-
Make extends string
|
|
81
|
-
Model extends string
|
|
111
|
+
Properties extends z.ZodType<record.Unknown>,
|
|
112
|
+
Make extends z.ZodType<string>,
|
|
113
|
+
Model extends z.ZodType<string>,
|
|
82
114
|
>(
|
|
83
|
-
args:
|
|
84
|
-
): Promise<
|
|
85
|
-
|
|
115
|
+
args: RetrieveMultipleParams & RetrieveSchemas<Properties, Make, Model>,
|
|
116
|
+
): Promise<Array<Device<Properties, Make, Model>>>;
|
|
117
|
+
|
|
118
|
+
async retrieve(args: RetrieveMultipleParams): Promise<Array<Device>>;
|
|
119
|
+
|
|
120
|
+
async retrieve(
|
|
121
|
+
args: RetrieveArgs & { schemas?: DeviceSchemas },
|
|
122
|
+
): Promise<Device | Array<Device>> {
|
|
123
|
+
const { schemas, ...rest } = args as RetrieveArgs & { schemas?: DeviceSchemas };
|
|
124
|
+
const isSingle = typeof rest === "object" && "key" in rest;
|
|
86
125
|
const res = await sendRequired(
|
|
87
126
|
this.client,
|
|
88
127
|
"/device/retrieve",
|
|
89
|
-
|
|
128
|
+
rest,
|
|
90
129
|
retrieveArgsZ,
|
|
91
|
-
retrieveResZ,
|
|
130
|
+
retrieveResZ(schemas),
|
|
92
131
|
);
|
|
93
|
-
checkForMultipleOrNoResults("Device",
|
|
94
|
-
|
|
95
|
-
return isSingle ? devices[0] : devices;
|
|
132
|
+
checkForMultipleOrNoResults("Device", rest, res.devices, isSingle);
|
|
133
|
+
return isSingle ? res.devices[0] : res.devices;
|
|
96
134
|
}
|
|
97
135
|
|
|
98
136
|
async create<
|
|
99
|
-
Properties extends
|
|
100
|
-
Make extends string
|
|
101
|
-
Model extends string
|
|
102
|
-
>(
|
|
103
|
-
|
|
104
|
-
Properties
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
137
|
+
Properties extends z.ZodType<record.Unknown>,
|
|
138
|
+
Make extends z.ZodType<string>,
|
|
139
|
+
Model extends z.ZodType<string>,
|
|
140
|
+
>(
|
|
141
|
+
device: New<Properties, Make, Model>,
|
|
142
|
+
schemas: DeviceSchemas<Properties, Make, Model>,
|
|
143
|
+
): Promise<Device<Properties, Make, Model>>;
|
|
144
|
+
|
|
145
|
+
async create(device: New): Promise<Device>;
|
|
146
|
+
|
|
108
147
|
async create<
|
|
109
|
-
Properties extends
|
|
110
|
-
Make extends string
|
|
111
|
-
Model extends string
|
|
148
|
+
Properties extends z.ZodType<record.Unknown>,
|
|
149
|
+
Make extends z.ZodType<string>,
|
|
150
|
+
Model extends z.ZodType<string>,
|
|
112
151
|
>(
|
|
113
|
-
devices: New<Properties, Make
|
|
114
|
-
|
|
152
|
+
devices: New<Properties, Make, Model>[],
|
|
153
|
+
schemas: DeviceSchemas<Properties, Make, Model>,
|
|
154
|
+
): Promise<Device<Properties, Make, Model>[]>;
|
|
155
|
+
|
|
156
|
+
async create(devices: New[]): Promise<Device[]>;
|
|
157
|
+
|
|
158
|
+
async create(
|
|
159
|
+
devices: New | New[],
|
|
160
|
+
schemas?: DeviceSchemas,
|
|
161
|
+
): Promise<Device | Device[]> {
|
|
115
162
|
const isSingle = !Array.isArray(devices);
|
|
116
163
|
const res = await sendRequired(
|
|
117
164
|
this.client,
|
|
118
165
|
"/device/create",
|
|
119
166
|
{ devices: array.toArray(devices) },
|
|
120
|
-
createReqZ,
|
|
121
|
-
createResZ,
|
|
167
|
+
createReqZ(schemas),
|
|
168
|
+
createResZ(schemas),
|
|
122
169
|
);
|
|
123
|
-
|
|
124
|
-
return isSingle ? created[0] : created;
|
|
170
|
+
return isSingle ? res.devices[0] : res.devices;
|
|
125
171
|
}
|
|
126
172
|
|
|
127
173
|
async delete(keys: Key | Key[]): Promise<void> {
|
package/src/device/external.ts
CHANGED
package/src/device/index.ts
CHANGED
|
@@ -0,0 +1,118 @@
|
|
|
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 { deviceZ, newZ } from "@/device/payload";
|
|
14
|
+
|
|
15
|
+
const VALID_DEVICE = {
|
|
16
|
+
key: "dev-1",
|
|
17
|
+
rack: 1,
|
|
18
|
+
name: "Test Device",
|
|
19
|
+
make: "ni",
|
|
20
|
+
model: "pxi-6281",
|
|
21
|
+
location: "Lab1",
|
|
22
|
+
properties: { rate: 10 },
|
|
23
|
+
status: null,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
describe("deviceZ", () => {
|
|
27
|
+
describe("default schemas", () => {
|
|
28
|
+
it("should accept a valid device", () => {
|
|
29
|
+
const result = deviceZ().safeParse(VALID_DEVICE);
|
|
30
|
+
expect(result.success).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should reject a device with an empty name", () => {
|
|
34
|
+
const result = deviceZ().safeParse({ ...VALID_DEVICE, name: "" });
|
|
35
|
+
expect(result.success).toBe(false);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("should reject a device with an empty make", () => {
|
|
39
|
+
const result = deviceZ().safeParse({ ...VALID_DEVICE, make: "" });
|
|
40
|
+
expect(result.success).toBe(false);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("should reject a device with an empty model", () => {
|
|
44
|
+
const result = deviceZ().safeParse({ ...VALID_DEVICE, model: "" });
|
|
45
|
+
expect(result.success).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("should accept properties as an object", () => {
|
|
49
|
+
const result = deviceZ().parse(VALID_DEVICE);
|
|
50
|
+
expect(result.properties).toEqual({ rate: 10 });
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe("custom make schema", () => {
|
|
55
|
+
const makeZ = z.enum(["ni", "labjack"]);
|
|
56
|
+
|
|
57
|
+
it("should accept a valid make value", () => {
|
|
58
|
+
const result = deviceZ({ make: makeZ }).safeParse(VALID_DEVICE);
|
|
59
|
+
expect(result.success).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("should reject an invalid make value", () => {
|
|
63
|
+
const result = deviceZ({ make: makeZ }).safeParse({
|
|
64
|
+
...VALID_DEVICE,
|
|
65
|
+
make: "unknown",
|
|
66
|
+
});
|
|
67
|
+
expect(result.success).toBe(false);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe("custom model schema", () => {
|
|
72
|
+
const modelZ = z.literal("pxi-6281");
|
|
73
|
+
|
|
74
|
+
it("should accept a matching model", () => {
|
|
75
|
+
const result = deviceZ({ model: modelZ }).safeParse(VALID_DEVICE);
|
|
76
|
+
expect(result.success).toBe(true);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("should reject a non-matching model", () => {
|
|
80
|
+
const result = deviceZ({ model: modelZ }).safeParse({
|
|
81
|
+
...VALID_DEVICE,
|
|
82
|
+
model: "t7",
|
|
83
|
+
});
|
|
84
|
+
expect(result.success).toBe(false);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe("custom properties schema", () => {
|
|
89
|
+
const propertiesZ = z.object({ rate: z.number(), channel: z.string() });
|
|
90
|
+
|
|
91
|
+
it("should validate properties against the custom schema", () => {
|
|
92
|
+
const result = deviceZ({ properties: propertiesZ }).safeParse({
|
|
93
|
+
...VALID_DEVICE,
|
|
94
|
+
properties: { rate: 10, channel: "ai0" },
|
|
95
|
+
});
|
|
96
|
+
expect(result.success).toBe(true);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("should reject properties that don't match the custom schema", () => {
|
|
100
|
+
expect(() => deviceZ({ properties: propertiesZ }).parse(VALID_DEVICE)).toThrow();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe("newZ", () => {
|
|
106
|
+
it("should encode properties to a JSON string", () => {
|
|
107
|
+
const result = newZ().parse(VALID_DEVICE);
|
|
108
|
+
expect(result.properties).toEqual(VALID_DEVICE.properties);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("should still validate make and model with custom schemas", () => {
|
|
112
|
+
const makeZ = z.literal("ni");
|
|
113
|
+
const result = newZ({ make: makeZ }).safeParse(VALID_DEVICE);
|
|
114
|
+
expect(result.success).toBe(true);
|
|
115
|
+
const bad = newZ({ make: makeZ }).safeParse({ ...VALID_DEVICE, make: "opc" });
|
|
116
|
+
expect(bad.success).toBe(false);
|
|
117
|
+
});
|
|
118
|
+
});
|
package/src/device/payload.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2026 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -7,11 +7,10 @@
|
|
|
7
7
|
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { record, status, zod } from "@synnaxlabs/x";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
13
|
import { keyZ as rackKeyZ } from "@/rack/payload";
|
|
14
|
-
import { decodeJSONString } from "@/util/decodeJSONString";
|
|
15
14
|
|
|
16
15
|
export const keyZ = z.string();
|
|
17
16
|
export type Key = z.infer<typeof keyZ>;
|
|
@@ -21,38 +20,64 @@ export const statusZ = status.statusZ(statusDetailsZ);
|
|
|
21
20
|
|
|
22
21
|
export interface Status extends z.infer<typeof statusZ> {}
|
|
23
22
|
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
export interface DeviceSchemas<
|
|
24
|
+
Properties extends z.ZodType<record.Unknown> = typeof record.unknownZ,
|
|
25
|
+
Make extends z.ZodType<string> = z.ZodString,
|
|
26
|
+
Model extends z.ZodType<string> = z.ZodString,
|
|
27
|
+
> {
|
|
28
|
+
properties?: Properties;
|
|
29
|
+
make?: Make;
|
|
30
|
+
model?: Model;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const deviceZ = <
|
|
34
|
+
Properties extends z.ZodType<record.Unknown> = typeof record.unknownZ,
|
|
35
|
+
Make extends z.ZodType<string> = z.ZodString,
|
|
36
|
+
Model extends z.ZodType<string> = z.ZodString,
|
|
37
|
+
>({ properties, make, model }: DeviceSchemas<Properties, Make, Model> = {}) =>
|
|
38
|
+
z.object({
|
|
39
|
+
key: keyZ,
|
|
40
|
+
rack: rackKeyZ.min(1, "Must select a location to connect from"),
|
|
41
|
+
name: z.string().min(1, "Name is required"),
|
|
42
|
+
make: make ?? z.string().min(1, "Make is required"),
|
|
43
|
+
model: model ?? z.string().min(1, "Model is required"),
|
|
44
|
+
location: z.string().min(1, "Location is required"),
|
|
45
|
+
configured: z.boolean().optional(),
|
|
46
|
+
properties: properties ?? record.nullishToEmpty(),
|
|
47
|
+
status: zod.nullToUndefined(statusZ),
|
|
48
|
+
});
|
|
35
49
|
|
|
36
50
|
export interface Device<
|
|
37
|
-
Properties extends record.Unknown = record.
|
|
38
|
-
Make extends string =
|
|
39
|
-
Model extends string =
|
|
40
|
-
> extends Omit<
|
|
41
|
-
|
|
42
|
-
make
|
|
43
|
-
|
|
51
|
+
Properties extends z.ZodType<record.Unknown> = typeof record.unknownZ,
|
|
52
|
+
Make extends z.ZodType<string> = z.ZodString,
|
|
53
|
+
Model extends z.ZodType<string> = z.ZodString,
|
|
54
|
+
> extends Omit<
|
|
55
|
+
z.infer<ReturnType<typeof deviceZ>>,
|
|
56
|
+
"properties" | "make" | "model" | "status"
|
|
57
|
+
> {
|
|
58
|
+
properties: z.infer<Properties>;
|
|
59
|
+
make: z.infer<Make>;
|
|
60
|
+
model: z.infer<Model>;
|
|
44
61
|
status?: Status;
|
|
45
62
|
}
|
|
46
63
|
|
|
47
|
-
export const newZ =
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
export const newZ = <
|
|
65
|
+
Properties extends z.ZodType<record.Unknown> = typeof record.unknownZ,
|
|
66
|
+
Make extends z.ZodType<string> = z.ZodString,
|
|
67
|
+
Model extends z.ZodType<string> = z.ZodString,
|
|
68
|
+
>(
|
|
69
|
+
schemas: DeviceSchemas<Properties, Make, Model> = {},
|
|
70
|
+
) =>
|
|
71
|
+
deviceZ(schemas).extend({
|
|
72
|
+
properties: schemas?.properties ?? record.nullishToEmpty(),
|
|
73
|
+
});
|
|
74
|
+
|
|
50
75
|
export interface New<
|
|
51
|
-
Properties extends record.Unknown = record.
|
|
52
|
-
Make extends string =
|
|
53
|
-
Model extends string =
|
|
54
|
-
> extends Omit<z.input<typeof newZ
|
|
55
|
-
properties: Properties
|
|
56
|
-
make: Make
|
|
57
|
-
model: Model
|
|
76
|
+
Properties extends z.ZodType<record.Unknown> = typeof record.unknownZ,
|
|
77
|
+
Make extends z.ZodType<string> = z.ZodString,
|
|
78
|
+
Model extends z.ZodType<string> = z.ZodString,
|
|
79
|
+
> extends Omit<z.input<ReturnType<typeof newZ>>, "properties"> {
|
|
80
|
+
properties: z.infer<Properties>;
|
|
81
|
+
make: z.infer<Make>;
|
|
82
|
+
model: z.infer<Model>;
|
|
58
83
|
}
|
package/src/errors.spec.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2026 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -64,7 +64,7 @@ test("client", async () => {
|
|
|
64
64
|
expect(NotFoundError.matches(e)).toBe(true);
|
|
65
65
|
}
|
|
66
66
|
try {
|
|
67
|
-
await client.
|
|
67
|
+
await client.schematics.retrieve({ key: uuid.create() });
|
|
68
68
|
} catch (e) {
|
|
69
69
|
expect(NotFoundError.matches(e)).toBe(true);
|
|
70
70
|
}
|
package/src/errors.ts
CHANGED
package/src/framer/adapter.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2026 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -15,7 +15,7 @@ import { Codec } from "@/framer/codec";
|
|
|
15
15
|
import { type CrudeFrame, Frame } from "@/framer/frame";
|
|
16
16
|
|
|
17
17
|
export class ReadAdapter {
|
|
18
|
-
private adapter: Map<channel.Key,
|
|
18
|
+
private adapter: Map<channel.Key, string> | null;
|
|
19
19
|
retriever: channel.Retriever;
|
|
20
20
|
keys: Set<channel.Key>;
|
|
21
21
|
codec: Codec;
|
|
@@ -54,7 +54,7 @@ export class ReadAdapter {
|
|
|
54
54
|
this.keys = new Set(normalized as channel.Key[]);
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
57
|
-
const a = new Map<channel.Key,
|
|
57
|
+
const a = new Map<channel.Key, string>();
|
|
58
58
|
this.adapter = a;
|
|
59
59
|
normalized.forEach((name) => {
|
|
60
60
|
const channel = fetched.find((channel) => channel.name === name);
|
|
@@ -87,7 +87,7 @@ export class ReadAdapter {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export class WriteAdapter {
|
|
90
|
-
private adapter: Map<
|
|
90
|
+
private adapter: Map<string, channel.Key> | null;
|
|
91
91
|
retriever: channel.Retriever;
|
|
92
92
|
keys: channel.Key[];
|
|
93
93
|
codec: Codec;
|
|
@@ -125,9 +125,7 @@ export class WriteAdapter {
|
|
|
125
125
|
const hasRemovedKeys = !previousKeySet.isSubsetOf(newKeySet);
|
|
126
126
|
const hasChanged = hasAddedKeys || hasRemovedKeys;
|
|
127
127
|
if (!hasChanged) return false;
|
|
128
|
-
this.adapter = new Map<
|
|
129
|
-
results.map((c) => [c.name, c.key]),
|
|
130
|
-
);
|
|
128
|
+
this.adapter = new Map<string, channel.Key>(results.map((c) => [c.name, c.key]));
|
|
131
129
|
this.keys = newKeys;
|
|
132
130
|
this.codec.update(
|
|
133
131
|
this.keys,
|
|
@@ -137,7 +135,7 @@ export class WriteAdapter {
|
|
|
137
135
|
}
|
|
138
136
|
|
|
139
137
|
private async fetchChannel(
|
|
140
|
-
ch: channel.
|
|
138
|
+
ch: channel.KeyOrName | channel.Payload,
|
|
141
139
|
): Promise<channel.Payload> {
|
|
142
140
|
const res = await this.retriever.retrieve(ch);
|
|
143
141
|
if (res.length === 0) throw new Error(`Channel ${JSON.stringify(ch)} not found`);
|
package/src/framer/client.ts
CHANGED
package/src/framer/codec.spec.ts
CHANGED
package/src/framer/codec.ts
CHANGED
package/src/framer/deleter.ts
CHANGED
package/src/framer/external.ts
CHANGED
package/src/framer/frame.spec.ts
CHANGED
package/src/framer/frame.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2026 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -95,7 +95,7 @@ export type CrudeFrame =
|
|
|
95
95
|
* and array can be square.
|
|
96
96
|
*/
|
|
97
97
|
export class Frame {
|
|
98
|
-
readonly columns: channel.
|
|
98
|
+
readonly columns: channel.KeysOrNames = [];
|
|
99
99
|
readonly series: Series[] = [];
|
|
100
100
|
|
|
101
101
|
constructor(
|
|
@@ -140,7 +140,7 @@ export class Frame {
|
|
|
140
140
|
["string", "number"].includes(typeof columnsOrData)
|
|
141
141
|
) {
|
|
142
142
|
const data_ = array.toArray(series);
|
|
143
|
-
const cols = array.toArray(columnsOrData) as channel.
|
|
143
|
+
const cols = array.toArray(columnsOrData) as channel.KeysOrNames;
|
|
144
144
|
validateMatchedColsAndSeries(cols, data_);
|
|
145
145
|
data_.forEach((d, i) => this.push(cols[i], d));
|
|
146
146
|
return;
|
|
@@ -184,23 +184,23 @@ export class Frame {
|
|
|
184
184
|
* @returns the channel names if the frame is keyed by channel name, and throws an error
|
|
185
185
|
* otherwise.
|
|
186
186
|
*/
|
|
187
|
-
get names():
|
|
187
|
+
get names(): string[] {
|
|
188
188
|
if (this.colType === "key") throw new UnexpectedError("colType is not name");
|
|
189
|
-
return (this.columns as
|
|
189
|
+
return (this.columns as string[]) ?? [];
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
193
|
* @returns the unique channel names if the frame is keyed by channel name, and throws an
|
|
194
194
|
* otherwise.
|
|
195
195
|
*/
|
|
196
|
-
get uniqueNames():
|
|
196
|
+
get uniqueNames(): string[] {
|
|
197
197
|
return unique.unique(this.names);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
/**
|
|
201
201
|
* @returns the unique columns in the frame.
|
|
202
202
|
*/
|
|
203
|
-
get uniqueColumns(): channel.
|
|
203
|
+
get uniqueColumns(): channel.KeysOrNames {
|
|
204
204
|
return this.colType === "key" ? this.uniqueKeys : this.uniqueNames;
|
|
205
205
|
}
|
|
206
206
|
|
|
@@ -280,9 +280,9 @@ export class Frame {
|
|
|
280
280
|
* @returns a frame with the given channel keys or names.
|
|
281
281
|
* @param keys the channel keys or names.
|
|
282
282
|
*/
|
|
283
|
-
get(keys: channel.
|
|
283
|
+
get(keys: channel.KeysOrNames): Frame;
|
|
284
284
|
|
|
285
|
-
get(key: channel.
|
|
285
|
+
get(key: channel.PrimitiveParams): MultiSeries | Frame {
|
|
286
286
|
if (Array.isArray(key))
|
|
287
287
|
return this.filter((k) => (key as channel.Keys).includes(k as channel.Key));
|
|
288
288
|
return new MultiSeries(this.series.filter((_, i) => this.columns[i] === key));
|
package/src/framer/index.ts
CHANGED