@synnaxlabs/client 0.2.0 → 0.13.5
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/.eslintrc.cjs +18 -0
- package/.pytest_cache/README.md +8 -0
- package/.turbo/turbo-build.log +16 -0
- package/LICENSE +4 -21
- package/{build/main/lib → dist/auth}/auth.d.ts +16 -19
- package/dist/auth/index.d.ts +1 -0
- package/dist/cdc/external.d.ts +1 -0
- package/dist/cdc/index.d.ts +1 -0
- package/dist/cdc/observable.d.ts +17 -0
- package/dist/channel/client.d.ts +58 -0
- package/dist/channel/creator.d.ts +8 -0
- package/dist/channel/external.d.ts +4 -0
- package/dist/channel/index.d.ts +1 -0
- package/dist/channel/payload.d.ts +63 -0
- package/dist/channel/retriever.d.ts +49 -0
- package/dist/client.cjs.js +23050 -0
- package/dist/client.cjs.js.map +1 -0
- package/dist/client.d.ts +73 -0
- package/dist/client.es.js +23050 -0
- package/dist/client.es.js.map +1 -0
- package/dist/connection/checker.d.ts +66 -0
- package/dist/connection/index.d.ts +1 -0
- package/dist/control/authority.d.ts +6 -0
- package/dist/control/external.d.ts +2 -0
- package/dist/control/index.d.ts +1 -0
- package/dist/control/state.d.ts +81 -0
- package/{build/main/lib → dist}/errors.d.ts +6 -3
- package/dist/framer/adapter.d.ts +21 -0
- package/dist/framer/client.d.ts +44 -0
- package/dist/framer/external.d.ts +5 -0
- package/dist/framer/frame.d.ts +251 -0
- package/dist/framer/index.d.ts +1 -0
- package/{build/module/lib/segment → dist/framer}/iterator.d.ts +32 -64
- package/dist/framer/streamProxy.d.ts +12 -0
- package/dist/framer/streamer.d.ts +17 -0
- package/dist/framer/writer.d.ts +257 -0
- package/dist/index.d.ts +16 -0
- package/dist/label/client.d.ts +25 -0
- package/dist/label/external.d.ts +4 -0
- package/dist/label/index.d.ts +1 -0
- package/dist/label/payload.d.ts +20 -0
- package/dist/label/retriever.d.ts +13 -0
- package/dist/label/writer.d.ts +26 -0
- package/dist/ontology/cdc.d.ts +25 -0
- package/dist/ontology/client.d.ts +25 -0
- package/dist/ontology/external.d.ts +3 -0
- package/dist/ontology/group/client.d.ts +11 -0
- package/dist/ontology/group/external.d.ts +2 -0
- package/dist/ontology/group/group.d.ts +7 -0
- package/dist/ontology/group/index.d.ts +1 -0
- package/dist/ontology/group/payload.d.ts +40 -0
- package/dist/ontology/group/writer.d.ts +13 -0
- package/dist/ontology/index.d.ts +1 -0
- package/dist/ontology/ontology.spec.d.ts +1 -0
- package/dist/ontology/payload.d.ts +235 -0
- package/dist/ontology/retriever.d.ts +12 -0
- package/dist/ontology/signals.d.ts +25 -0
- package/dist/ontology/writer.d.ts +9 -0
- package/dist/ranger/active.d.ts +9 -0
- package/dist/ranger/alias.d.ts +32 -0
- package/dist/ranger/client.d.ts +31 -0
- package/dist/ranger/external.d.ts +6 -0
- package/dist/ranger/index.d.ts +1 -0
- package/dist/ranger/kv.d.ts +50 -0
- package/dist/ranger/payload.d.ts +94 -0
- package/dist/ranger/range.d.ts +29 -0
- package/dist/ranger/ranger.spec.d.ts +1 -0
- package/dist/ranger/retriever.d.ts +10 -0
- package/dist/ranger/writer.d.ts +9 -0
- package/{build/main → dist}/setupspecs.d.ts +2 -2
- package/dist/signals/external.d.ts +1 -0
- package/dist/signals/index.d.ts +1 -0
- package/dist/signals/observable.d.ts +17 -0
- package/dist/transport.d.ts +10 -0
- package/dist/user/index.d.ts +1 -0
- package/{build/main/lib → dist}/user/payload.d.ts +3 -3
- package/dist/util/telem.d.ts +2 -0
- package/dist/workspace/client.d.ts +22 -0
- package/dist/workspace/external.d.ts +2 -0
- package/dist/workspace/index.d.ts +1 -0
- package/dist/workspace/lineplot/client.d.ts +15 -0
- package/dist/workspace/lineplot/external.d.ts +2 -0
- package/dist/workspace/lineplot/index.d.ts +1 -0
- package/dist/workspace/lineplot/linePlot.spec.d.ts +1 -0
- package/dist/workspace/lineplot/payload.d.ts +31 -0
- package/dist/workspace/lineplot/retriever.d.ts +9 -0
- package/dist/workspace/lineplot/writer.d.ts +39 -0
- package/dist/workspace/payload.d.ts +31 -0
- package/dist/workspace/pid/client.d.ts +16 -0
- package/dist/workspace/pid/external.d.ts +2 -0
- package/dist/workspace/pid/index.d.ts +1 -0
- package/dist/workspace/pid/payload.d.ts +37 -0
- package/dist/workspace/pid/pid.spec.d.ts +1 -0
- package/dist/workspace/pid/retriever.d.ts +9 -0
- package/dist/workspace/pid/writer.d.ts +46 -0
- package/dist/workspace/retriever.d.ts +12 -0
- package/dist/workspace/workspace.spec.d.ts +1 -0
- package/dist/workspace/writer.d.ts +55 -0
- package/package.json +27 -98
- package/src/auth/auth.spec.ts +46 -0
- package/src/auth/auth.ts +83 -0
- package/src/auth/index.ts +10 -0
- package/src/cdc/external.ts +10 -0
- package/src/cdc/index.ts +10 -0
- package/src/cdc/observable.ts +80 -0
- package/src/channel/channel.spec.ts +82 -0
- package/src/channel/client.ts +209 -0
- package/src/channel/creator.ts +43 -0
- package/src/channel/external.ts +13 -0
- package/src/channel/index.ts +10 -0
- package/src/channel/payload.ts +52 -0
- package/src/channel/retriever.ts +160 -0
- package/src/client.ts +112 -0
- package/src/connection/checker.ts +104 -0
- package/src/connection/connection.spec.ts +35 -0
- package/src/connection/index.ts +10 -0
- package/src/control/authority.ts +25 -0
- package/src/control/external.ts +11 -0
- package/src/control/index.ts +10 -0
- package/src/control/state.spec.ts +24 -0
- package/src/control/state.ts +117 -0
- package/src/errors.ts +153 -0
- package/src/framer/adapter.ts +116 -0
- package/src/framer/client.ts +116 -0
- package/src/framer/external.ts +14 -0
- package/src/framer/frame.spec.ts +317 -0
- package/src/framer/frame.ts +412 -0
- package/src/framer/index.ts +10 -0
- package/src/framer/iterator.spec.ts +62 -0
- package/src/framer/iterator.ts +240 -0
- package/src/framer/streamProxy.ts +59 -0
- package/src/framer/streamer.spec.ts +42 -0
- package/src/framer/streamer.ts +86 -0
- package/src/framer/writer.spec.ts +52 -0
- package/src/framer/writer.ts +236 -0
- package/src/index.ts +43 -4
- package/src/ontology/cdc.ts +135 -0
- package/src/ontology/client.ts +103 -0
- package/src/ontology/external.ts +12 -0
- package/src/ontology/group/client.ts +40 -0
- package/src/ontology/group/external.ts +11 -0
- package/src/ontology/group/group.spec.ts +46 -0
- package/src/ontology/group/group.ts +27 -0
- package/src/ontology/group/index.ts +10 -0
- package/src/ontology/group/payload.ts +65 -0
- package/src/ontology/group/writer.ts +48 -0
- package/src/ontology/index.ts +10 -0
- package/src/ontology/ontology.spec.ts +114 -0
- package/src/ontology/payload.ts +121 -0
- package/src/ontology/retriever.ts +91 -0
- package/src/ontology/writer.ts +49 -0
- package/src/ranger/active.ts +56 -0
- package/src/ranger/alias.ts +183 -0
- package/src/ranger/client.ts +124 -0
- package/src/ranger/external.ts +15 -0
- package/src/ranger/index.ts +10 -0
- package/src/ranger/kv.ts +91 -0
- package/src/ranger/payload.ts +70 -0
- package/src/ranger/range.ts +74 -0
- package/src/ranger/ranger.spec.ts +167 -0
- package/src/ranger/retriever.ts +50 -0
- package/src/ranger/writer.ts +80 -0
- package/src/setupspecs.ts +14 -5
- package/src/transport.ts +39 -0
- package/src/user/index.ts +10 -0
- package/src/user/payload.ts +17 -0
- package/src/util/telem.ts +19 -0
- package/src/vite-env.d.ts +11 -0
- package/src/workspace/client.ts +75 -0
- package/src/workspace/external.ts +11 -0
- package/src/workspace/index.ts +10 -0
- package/src/workspace/lineplot/client.ts +51 -0
- package/src/workspace/lineplot/external.ts +11 -0
- package/src/workspace/lineplot/index.ts +10 -0
- package/src/workspace/lineplot/linePlot.spec.ts +78 -0
- package/src/workspace/lineplot/payload.ts +29 -0
- package/src/workspace/lineplot/retriever.ts +49 -0
- package/src/workspace/lineplot/writer.ts +109 -0
- package/src/workspace/payload.ts +29 -0
- package/src/workspace/pid/client.ts +55 -0
- package/src/workspace/pid/external.ts +11 -0
- package/src/workspace/pid/index.ts +10 -0
- package/src/workspace/pid/payload.ts +31 -0
- package/src/workspace/pid/pid.spec.ts +111 -0
- package/src/workspace/pid/retriever.ts +45 -0
- package/src/workspace/pid/writer.ts +130 -0
- package/src/workspace/retriever.ts +67 -0
- package/src/workspace/workspace.spec.ts +62 -0
- package/src/workspace/writer.ts +103 -0
- package/tsconfig.json +3 -43
- package/tsconfig.vite.json +4 -0
- package/vite.config.ts +25 -0
- package/.DS_Store +0 -0
- package/.editorconfig +0 -15
- package/.eslintrc.json +0 -33
- package/.gitignore +0 -9
- package/.nyc_output/20720f2d-6abe-420f-a3c5-304d52d60827.json +0 -1
- package/.nyc_output/4725921c-6f1b-4ae9-9819-e455f702d31c.json +0 -1
- package/.nyc_output/47478588-5ffd-4332-873c-facaa4a2fc38.json +0 -1
- package/.nyc_output/48180641-e0b2-49ab-a6eb-e7910e9eac2f.json +0 -1
- package/.nyc_output/cb0abf31-740f-47db-b94a-8e3f8f117cb8.json +0 -1
- package/.nyc_output/fc77fce2-dad0-49a8-8d4b-0a9014ecf8c5.json +0 -1
- package/.nyc_output/processinfo/20720f2d-6abe-420f-a3c5-304d52d60827.json +0 -1
- package/.nyc_output/processinfo/4725921c-6f1b-4ae9-9819-e455f702d31c.json +0 -1
- package/.nyc_output/processinfo/47478588-5ffd-4332-873c-facaa4a2fc38.json +0 -1
- package/.nyc_output/processinfo/48180641-e0b2-49ab-a6eb-e7910e9eac2f.json +0 -1
- package/.nyc_output/processinfo/cb0abf31-740f-47db-b94a-8e3f8f117cb8.json +0 -1
- package/.nyc_output/processinfo/fc77fce2-dad0-49a8-8d4b-0a9014ecf8c5.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/.prettierignore +0 -2
- package/CHANGELOG.md +0 -5
- package/build/main/index.d.ts +0 -4
- package/build/main/index.js +0 -35
- package/build/main/lib/auth.js +0 -62
- package/build/main/lib/auth.spec.js +0 -39
- package/build/main/lib/channel/channel.spec.js +0 -49
- package/build/main/lib/channel/client.d.ts +0 -94
- package/build/main/lib/channel/client.js +0 -134
- package/build/main/lib/channel/creator.d.ts +0 -19
- package/build/main/lib/channel/creator.js +0 -44
- package/build/main/lib/channel/payload.d.ts +0 -25
- package/build/main/lib/channel/payload.js +0 -18
- package/build/main/lib/channel/registry.d.ts +0 -9
- package/build/main/lib/channel/registry.js +0 -37
- package/build/main/lib/channel/retriever.d.ts +0 -11
- package/build/main/lib/channel/retriever.js +0 -39
- package/build/main/lib/client.d.ts +0 -30
- package/build/main/lib/client.js +0 -46
- package/build/main/lib/errors.js +0 -122
- package/build/main/lib/segment/client.d.ts +0 -62
- package/build/main/lib/segment/client.js +0 -95
- package/build/main/lib/segment/iterator.d.ts +0 -134
- package/build/main/lib/segment/iterator.js +0 -253
- package/build/main/lib/segment/iterator.spec.js +0 -73
- package/build/main/lib/segment/payload.d.ts +0 -16
- package/build/main/lib/segment/payload.js +0 -13
- package/build/main/lib/segment/splitter.d.ts +0 -7
- package/build/main/lib/segment/splitter.js +0 -25
- package/build/main/lib/segment/typed.d.ts +0 -15
- package/build/main/lib/segment/typed.js +0 -49
- package/build/main/lib/segment/validator.d.ts +0 -22
- package/build/main/lib/segment/validator.js +0 -64
- package/build/main/lib/segment/writer.d.ts +0 -98
- package/build/main/lib/segment/writer.js +0 -183
- package/build/main/lib/segment/writer.spec.js +0 -90
- package/build/main/lib/telem.d.ts +0 -395
- package/build/main/lib/telem.js +0 -553
- package/build/main/lib/telem.spec.js +0 -152
- package/build/main/lib/transport.d.ts +0 -10
- package/build/main/lib/transport.js +0 -22
- package/build/main/lib/user/payload.js +0 -9
- package/build/main/lib/util/telem.d.ts +0 -2
- package/build/main/lib/util/telem.js +0 -13
- package/build/main/setupspecs.js +0 -17
- package/build/module/index.d.ts +0 -4
- package/build/module/index.js +0 -5
- package/build/module/lib/auth.d.ts +0 -54
- package/build/module/lib/auth.js +0 -63
- package/build/module/lib/auth.spec.js +0 -34
- package/build/module/lib/channel/channel.spec.js +0 -44
- package/build/module/lib/channel/client.d.ts +0 -94
- package/build/module/lib/channel/client.js +0 -134
- package/build/module/lib/channel/creator.d.ts +0 -19
- package/build/module/lib/channel/creator.js +0 -42
- package/build/module/lib/channel/payload.d.ts +0 -25
- package/build/module/lib/channel/payload.js +0 -15
- package/build/module/lib/channel/registry.d.ts +0 -9
- package/build/module/lib/channel/registry.js +0 -36
- package/build/module/lib/channel/retriever.d.ts +0 -11
- package/build/module/lib/channel/retriever.js +0 -37
- package/build/module/lib/client.d.ts +0 -30
- package/build/module/lib/client.js +0 -44
- package/build/module/lib/errors.d.ts +0 -53
- package/build/module/lib/errors.js +0 -113
- package/build/module/lib/segment/client.d.ts +0 -62
- package/build/module/lib/segment/client.js +0 -94
- package/build/module/lib/segment/iterator.js +0 -248
- package/build/module/lib/segment/iterator.spec.js +0 -68
- package/build/module/lib/segment/payload.d.ts +0 -16
- package/build/module/lib/segment/payload.js +0 -10
- package/build/module/lib/segment/splitter.d.ts +0 -7
- package/build/module/lib/segment/splitter.js +0 -26
- package/build/module/lib/segment/typed.d.ts +0 -15
- package/build/module/lib/segment/typed.js +0 -49
- package/build/module/lib/segment/validator.d.ts +0 -22
- package/build/module/lib/segment/validator.js +0 -60
- package/build/module/lib/segment/writer.d.ts +0 -98
- package/build/module/lib/segment/writer.js +0 -183
- package/build/module/lib/segment/writer.spec.js +0 -85
- package/build/module/lib/telem.d.ts +0 -395
- package/build/module/lib/telem.js +0 -545
- package/build/module/lib/telem.spec.js +0 -147
- package/build/module/lib/transport.d.ts +0 -10
- package/build/module/lib/transport.js +0 -22
- package/build/module/lib/user/payload.d.ts +0 -12
- package/build/module/lib/user/payload.js +0 -6
- package/build/module/lib/util/telem.d.ts +0 -2
- package/build/module/lib/util/telem.js +0 -9
- package/build/module/setupspecs.d.ts +0 -4
- package/build/module/setupspecs.js +0 -16
- package/build/tsconfig.module.tsbuildinfo +0 -1
- package/build/tsconfig.tsbuildinfo +0 -1
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -191
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -191
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/index.html +0 -116
- package/coverage/lcov-report/src/lib/auth.ts.html +0 -340
- package/coverage/lcov-report/src/lib/channel/client.ts.html +0 -604
- package/coverage/lcov-report/src/lib/channel/creator.ts.html +0 -304
- package/coverage/lcov-report/src/lib/channel/index.html +0 -176
- package/coverage/lcov-report/src/lib/channel/payload.ts.html +0 -139
- package/coverage/lcov-report/src/lib/channel/registry.ts.html +0 -202
- package/coverage/lcov-report/src/lib/channel/retriever.ts.html +0 -244
- package/coverage/lcov-report/src/lib/client.ts.html +0 -244
- package/coverage/lcov-report/src/lib/errors.ts.html +0 -484
- package/coverage/lcov-report/src/lib/index.html +0 -176
- package/coverage/lcov-report/src/lib/segment/client.ts.html +0 -463
- package/coverage/lcov-report/src/lib/segment/index.html +0 -206
- package/coverage/lcov-report/src/lib/segment/iterator.ts.html +0 -928
- package/coverage/lcov-report/src/lib/segment/payload.ts.html +0 -139
- package/coverage/lcov-report/src/lib/segment/splitter.ts.html +0 -181
- package/coverage/lcov-report/src/lib/segment/typed.ts.html +0 -307
- package/coverage/lcov-report/src/lib/segment/validator.ts.html +0 -331
- package/coverage/lcov-report/src/lib/segment/writer.ts.html +0 -727
- package/coverage/lcov-report/src/lib/telem.ts.html +0 -2056
- package/coverage/lcov-report/src/lib/transport.ts.html +0 -196
- package/coverage/lcov-report/src/lib/user/index.html +0 -116
- package/coverage/lcov-report/src/lib/user/payload.ts.html +0 -109
- package/coverage/lcov-report/src/lib/util/index.html +0 -116
- package/coverage/lcov-report/src/lib/util/telem.ts.html +0 -124
- package/coverage/lcov-report/src/setupspecs.ts.html +0 -133
- package/coverage/lcov.info +0 -1230
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
- package/coverage/src/index.html +0 -116
- package/coverage/src/lib/auth.ts.html +0 -340
- package/coverage/src/lib/channel/client.ts.html +0 -604
- package/coverage/src/lib/channel/creator.ts.html +0 -304
- package/coverage/src/lib/channel/index.html +0 -176
- package/coverage/src/lib/channel/payload.ts.html +0 -139
- package/coverage/src/lib/channel/registry.ts.html +0 -202
- package/coverage/src/lib/channel/retriever.ts.html +0 -244
- package/coverage/src/lib/client.ts.html +0 -244
- package/coverage/src/lib/errors.ts.html +0 -484
- package/coverage/src/lib/index.html +0 -176
- package/coverage/src/lib/segment/client.ts.html +0 -463
- package/coverage/src/lib/segment/index.html +0 -206
- package/coverage/src/lib/segment/iterator.ts.html +0 -928
- package/coverage/src/lib/segment/payload.ts.html +0 -139
- package/coverage/src/lib/segment/splitter.ts.html +0 -181
- package/coverage/src/lib/segment/typed.ts.html +0 -307
- package/coverage/src/lib/segment/validator.ts.html +0 -331
- package/coverage/src/lib/segment/writer.ts.html +0 -727
- package/coverage/src/lib/telem.ts.html +0 -2056
- package/coverage/src/lib/transport.ts.html +0 -196
- package/coverage/src/lib/user/index.html +0 -116
- package/coverage/src/lib/user/payload.ts.html +0 -109
- package/coverage/src/lib/util/index.html +0 -116
- package/coverage/src/lib/util/telem.ts.html +0 -124
- package/coverage/src/setupspecs.ts.html +0 -133
- package/src/lib/.DS_Store +0 -0
- package/src/lib/auth.spec.ts +0 -36
- package/src/lib/auth.ts +0 -85
- package/src/lib/channel/channel.spec.ts +0 -49
- package/src/lib/channel/client.ts +0 -173
- package/src/lib/channel/creator.ts +0 -73
- package/src/lib/channel/payload.ts +0 -18
- package/src/lib/channel/registry.ts +0 -39
- package/src/lib/channel/retriever.ts +0 -53
- package/src/lib/client.ts +0 -53
- package/src/lib/errors.ts +0 -133
- package/src/lib/segment/client.ts +0 -126
- package/src/lib/segment/iterator.spec.ts +0 -78
- package/src/lib/segment/iterator.ts +0 -281
- package/src/lib/segment/payload.ts +0 -18
- package/src/lib/segment/splitter.ts +0 -32
- package/src/lib/segment/typed.ts +0 -74
- package/src/lib/segment/validator.ts +0 -82
- package/src/lib/segment/writer.spec.ts +0 -85
- package/src/lib/segment/writer.ts +0 -214
- package/src/lib/telem.spec.ts +0 -200
- package/src/lib/telem.ts +0 -657
- package/src/lib/transport.ts +0 -37
- package/src/lib/user/payload.ts +0 -8
- package/src/lib/util/telem.ts +0 -13
- package/tsconfig.module.json +0 -9
- package/yarn-error.log +0 -5756
- package/yarn.lock +0 -5936
- /package/{build/main/lib → dist/auth}/auth.spec.d.ts +0 -0
- /package/{build/main/lib → dist}/channel/channel.spec.d.ts +0 -0
- /package/{build/main/lib/segment/iterator.spec.d.ts → dist/connection/connection.spec.d.ts} +0 -0
- /package/{build/main/lib/segment/writer.spec.d.ts → dist/control/state.spec.d.ts} +0 -0
- /package/{build/main/lib/telem.spec.d.ts → dist/framer/frame.spec.d.ts} +0 -0
- /package/{build/module/lib/segment → dist/framer}/iterator.spec.d.ts +0 -0
- /package/{build/module/lib/auth.spec.d.ts → dist/framer/streamer.spec.d.ts} +0 -0
- /package/{build/module/lib/segment → dist/framer}/writer.spec.d.ts +0 -0
- /package/{build/module/lib/channel/channel.spec.d.ts → dist/label/label.spec.d.ts} +0 -0
- /package/{build/module/lib/telem.spec.d.ts → dist/ontology/group/group.spec.d.ts} +0 -0
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
|
|
5
|
-
<head>
|
|
6
|
-
<title>Code coverage report for src/setupspecs.ts</title>
|
|
7
|
-
<meta charset="utf-8" />
|
|
8
|
-
<link rel="stylesheet" href="../prettify.css" />
|
|
9
|
-
<link rel="stylesheet" href="../base.css" />
|
|
10
|
-
<link rel="shortcut icon" type="image/x-icon" href="../favicon.png" />
|
|
11
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
-
<style type='text/css'>
|
|
13
|
-
.coverage-summary .sorter {
|
|
14
|
-
background-image: url(../sort-arrow-sprite.png);
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<div class='wrapper'>
|
|
21
|
-
<div class='pad1'>
|
|
22
|
-
<h1><a href="../index.html">All files</a> / <a href="index.html">src</a> setupspecs.ts</h1>
|
|
23
|
-
<div class='clearfix'>
|
|
24
|
-
|
|
25
|
-
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">88.88% </span>
|
|
27
|
-
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>8/9</span>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">50% </span>
|
|
34
|
-
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>1/2</span>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">100% </span>
|
|
41
|
-
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>1/1</span>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">100% </span>
|
|
48
|
-
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>7/7</span>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
<p class="quiet">
|
|
55
|
-
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
-
</p>
|
|
57
|
-
<template id="filterTemplate">
|
|
58
|
-
<div class="quiet">
|
|
59
|
-
Filter:
|
|
60
|
-
<input oninput="onInput()" type="search" id="fileSearch">
|
|
61
|
-
</div>
|
|
62
|
-
</template>
|
|
63
|
-
</div>
|
|
64
|
-
<div class='status-line high'></div>
|
|
65
|
-
<pre><table class="coverage">
|
|
66
|
-
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
|
67
|
-
<a name='L2'></a><a href='#L2'>2</a>
|
|
68
|
-
<a name='L3'></a><a href='#L3'>3</a>
|
|
69
|
-
<a name='L4'></a><a href='#L4'>4</a>
|
|
70
|
-
<a name='L5'></a><a href='#L5'>5</a>
|
|
71
|
-
<a name='L6'></a><a href='#L6'>6</a>
|
|
72
|
-
<a name='L7'></a><a href='#L7'>7</a>
|
|
73
|
-
<a name='L8'></a><a href='#L8'>8</a>
|
|
74
|
-
<a name='L9'></a><a href='#L9'>9</a>
|
|
75
|
-
<a name='L10'></a><a href='#L10'>10</a>
|
|
76
|
-
<a name='L11'></a><a href='#L11'>11</a>
|
|
77
|
-
<a name='L12'></a><a href='#L12'>12</a>
|
|
78
|
-
<a name='L13'></a><a href='#L13'>13</a>
|
|
79
|
-
<a name='L14'></a><a href='#L14'>14</a>
|
|
80
|
-
<a name='L15'></a><a href='#L15'>15</a>
|
|
81
|
-
<a name='L16'></a><a href='#L16'>16</a>
|
|
82
|
-
<a name='L17'></a><a href='#L17'>17</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">4x</span>
|
|
83
|
-
<span class="cline-any cline-neutral"> </span>
|
|
84
|
-
<span class="cline-any cline-yes">4x</span>
|
|
85
|
-
<span class="cline-any cline-yes">4x</span>
|
|
86
|
-
<span class="cline-any cline-neutral"> </span>
|
|
87
|
-
<span class="cline-any cline-yes">4x</span>
|
|
88
|
-
<span class="cline-any cline-yes">3x</span>
|
|
89
|
-
<span class="cline-any cline-yes">3x</span>
|
|
90
|
-
<span class="cline-any cline-yes">3x</span>
|
|
91
|
-
<span class="cline-any cline-neutral"> </span>
|
|
92
|
-
<span class="cline-any cline-neutral"> </span>
|
|
93
|
-
<span class="cline-any cline-neutral"> </span>
|
|
94
|
-
<span class="cline-any cline-neutral"> </span>
|
|
95
|
-
<span class="cline-any cline-neutral"> </span>
|
|
96
|
-
<span class="cline-any cline-neutral"> </span>
|
|
97
|
-
<span class="cline-any cline-neutral"> </span>
|
|
98
|
-
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import Synnax, { SynnaxProps } from './lib/client';
|
|
99
|
-
|
|
100
|
-
export const HOST = 'localhost';
|
|
101
|
-
export const PORT = 8080;
|
|
102
|
-
|
|
103
|
-
export const newClient = (...props: SynnaxProps[]): Synnax => {
|
|
104
|
-
let _props = {};
|
|
105
|
-
<span class="missing-if-branch" title="if path not taken" >I</span>if (props.length > 0) <span class="cstat-no" title="statement not covered" >_props = props[0];</span>
|
|
106
|
-
return new Synnax({
|
|
107
|
-
host: HOST,
|
|
108
|
-
port: PORT,
|
|
109
|
-
username: 'synnax',
|
|
110
|
-
password: 'seldon',
|
|
111
|
-
..._props,
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
</pre></td></tr></table></pre>
|
|
115
|
-
|
|
116
|
-
<div class='push'></div><!-- for sticky footer -->
|
|
117
|
-
</div><!-- /wrapper -->
|
|
118
|
-
<div class='footer quiet pad2 space-top1 center small'>
|
|
119
|
-
Code coverage generated by
|
|
120
|
-
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
121
|
-
at 2022-10-04T02:07:47.903Z
|
|
122
|
-
</div>
|
|
123
|
-
<script src="../prettify.js"></script>
|
|
124
|
-
<script>
|
|
125
|
-
window.onload = function () {
|
|
126
|
-
prettyPrint();
|
|
127
|
-
};
|
|
128
|
-
</script>
|
|
129
|
-
<script src="../sorter.js"></script>
|
|
130
|
-
<script src="../block-navigation.js"></script>
|
|
131
|
-
</body>
|
|
132
|
-
</html>
|
|
133
|
-
|
package/src/lib/.DS_Store
DELETED
|
Binary file
|
package/src/lib/auth.spec.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { URL } from '@synnaxlabs/freighter';
|
|
2
|
-
import test from 'ava';
|
|
3
|
-
|
|
4
|
-
import { HOST, PORT } from '../setupspecs';
|
|
5
|
-
|
|
6
|
-
import AuthenticationClient from './auth';
|
|
7
|
-
import { AuthError } from './errors';
|
|
8
|
-
import Transport from './transport';
|
|
9
|
-
|
|
10
|
-
test('[auth] - valid credentials', async (t) => {
|
|
11
|
-
const transport = new Transport(new URL({ host: HOST, port: PORT }));
|
|
12
|
-
const client = new AuthenticationClient(transport.httpFactory, {
|
|
13
|
-
username: 'synnax',
|
|
14
|
-
password: 'seldon',
|
|
15
|
-
});
|
|
16
|
-
await client.authenticating;
|
|
17
|
-
t.assert(client.authenticated);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('[auth] - invalid credentials', async (t) => {
|
|
21
|
-
const transport = new Transport(new URL({ host: HOST, port: PORT }));
|
|
22
|
-
const client = new AuthenticationClient(transport.httpFactory, {
|
|
23
|
-
username: 'synnax',
|
|
24
|
-
password: 'wrong',
|
|
25
|
-
});
|
|
26
|
-
try {
|
|
27
|
-
await client.authenticating;
|
|
28
|
-
t.assert(false);
|
|
29
|
-
} catch (e) {
|
|
30
|
-
t.assert(!client.authenticated);
|
|
31
|
-
t.assert(e instanceof AuthError);
|
|
32
|
-
if (e instanceof AuthError) {
|
|
33
|
-
t.is(e.message, '[synnax] - invalid credentials');
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
});
|
package/src/lib/auth.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HTTPClientFactory,
|
|
3
|
-
Middleware,
|
|
4
|
-
UnaryClient,
|
|
5
|
-
} from '@synnaxlabs/freighter';
|
|
6
|
-
import { z } from 'zod';
|
|
7
|
-
|
|
8
|
-
import { AuthError } from './errors';
|
|
9
|
-
import { UserPayload, UserPayloadSchema } from './user/payload';
|
|
10
|
-
|
|
11
|
-
export const tokenMiddleware = (token: () => Promise<string>): Middleware => {
|
|
12
|
-
return async (md, next) => {
|
|
13
|
-
md.params['Authorization'] = `Bearer ${await token()}`;
|
|
14
|
-
return await next(md);
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const InsecureCredentialsSchema = z.object({
|
|
19
|
-
username: z.string(),
|
|
20
|
-
password: z.string(),
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export type InsecureCredentials = z.infer<typeof InsecureCredentialsSchema>;
|
|
24
|
-
|
|
25
|
-
export const TokenResponseSchema = z.object({
|
|
26
|
-
token: z.string(),
|
|
27
|
-
user: UserPayloadSchema,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export type TokenResponse = z.infer<typeof TokenResponseSchema>;
|
|
31
|
-
|
|
32
|
-
export default class AuthenticationClient {
|
|
33
|
-
private static ENDPOINT = '/auth/login';
|
|
34
|
-
private token: string | undefined;
|
|
35
|
-
private client: UnaryClient;
|
|
36
|
-
private credentials: InsecureCredentials;
|
|
37
|
-
authenticating: Promise<void> | undefined;
|
|
38
|
-
authenticated: boolean;
|
|
39
|
-
user: UserPayload | undefined;
|
|
40
|
-
|
|
41
|
-
constructor(factory: HTTPClientFactory, creds: InsecureCredentials) {
|
|
42
|
-
this.client = factory.postClient();
|
|
43
|
-
this.credentials = creds;
|
|
44
|
-
this.authenticated = false;
|
|
45
|
-
this.authenticate();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
authenticate() {
|
|
49
|
-
this.authenticating = new Promise((resolve, reject) => {
|
|
50
|
-
this.client
|
|
51
|
-
.send<InsecureCredentials, TokenResponse>(
|
|
52
|
-
AuthenticationClient.ENDPOINT,
|
|
53
|
-
this.credentials,
|
|
54
|
-
TokenResponseSchema
|
|
55
|
-
)
|
|
56
|
-
.then(([res, err]) => {
|
|
57
|
-
if (err) {
|
|
58
|
-
reject(err);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
this.token = res?.token;
|
|
62
|
-
this.user = res?.user;
|
|
63
|
-
this.authenticated = true;
|
|
64
|
-
resolve();
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private async maybeWaitAuthenticated() {
|
|
70
|
-
if (this.authenticating) await this.authenticating;
|
|
71
|
-
this.authenticating = undefined;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
middleware(): Middleware {
|
|
75
|
-
return tokenMiddleware(async () => {
|
|
76
|
-
await this.maybeWaitAuthenticated();
|
|
77
|
-
if (!this.token) {
|
|
78
|
-
throw new AuthError(
|
|
79
|
-
'[auth] - attempting to authenticate without a token'
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
return this.token;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import test from 'ava';
|
|
2
|
-
|
|
3
|
-
import { newClient } from '../../setupspecs';
|
|
4
|
-
import { QueryError } from '../errors';
|
|
5
|
-
import { DataType, Rate } from '../telem';
|
|
6
|
-
|
|
7
|
-
const client = newClient();
|
|
8
|
-
|
|
9
|
-
test('Channel - create', async (t) => {
|
|
10
|
-
const channel = await client.channel.create({
|
|
11
|
-
name: 'test',
|
|
12
|
-
nodeId: 1,
|
|
13
|
-
rate: Rate.Hz(1),
|
|
14
|
-
dataType: DataType.Float32,
|
|
15
|
-
});
|
|
16
|
-
t.is(channel.name, 'test');
|
|
17
|
-
t.is(channel.nodeId, 1);
|
|
18
|
-
t.deepEqual(channel.rate, Rate.Hz(1));
|
|
19
|
-
t.deepEqual(channel.dataType, DataType.Float32);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('Channel - retrieve by key', async (t) => {
|
|
23
|
-
const channel = await client.channel.create({
|
|
24
|
-
name: 'test',
|
|
25
|
-
nodeId: 1,
|
|
26
|
-
rate: Rate.Hz(1),
|
|
27
|
-
dataType: DataType.Float32,
|
|
28
|
-
});
|
|
29
|
-
const retrieved = (await client.channel.retrieveByKeys(channel.key))[0];
|
|
30
|
-
t.is(retrieved.name, 'test');
|
|
31
|
-
t.is(retrieved.nodeId, 1);
|
|
32
|
-
t.deepEqual(retrieved.rate, Rate.Hz(1));
|
|
33
|
-
t.deepEqual(retrieved.dataType, DataType.Float32);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('Channel - retrieve by key - not found', async (t) => {
|
|
37
|
-
const err = await t.throwsAsync(async () => {
|
|
38
|
-
await client.channel.retrieveByKeys('1-1000');
|
|
39
|
-
});
|
|
40
|
-
t.true(err instanceof QueryError);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('Channel - retrieve by node id', async (t) => {
|
|
44
|
-
const retrieved = await client.channel.retrieveByNodeId(1);
|
|
45
|
-
t.true(retrieved.length > 0);
|
|
46
|
-
retrieved.forEach((ch) => {
|
|
47
|
-
t.is(ch.nodeId, 1);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import SegmentClient from '../segment/client';
|
|
2
|
-
import {
|
|
3
|
-
DataType,
|
|
4
|
-
Density,
|
|
5
|
-
Rate,
|
|
6
|
-
TypedArray,
|
|
7
|
-
UnparsedTimeStamp,
|
|
8
|
-
} from '../telem';
|
|
9
|
-
|
|
10
|
-
import ChannelCreator from './creator';
|
|
11
|
-
import { CreateChannelProps } from './creator';
|
|
12
|
-
import { ChannelPayload } from './payload';
|
|
13
|
-
import ChannelRetriever from './retriever';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Represents a Channel in a Synnax database. It should not be instantiated
|
|
17
|
-
* directly, but rather created or retrieved from a {@link ChannelClient}.
|
|
18
|
-
*/
|
|
19
|
-
export class Channel {
|
|
20
|
-
private readonly segmentClient: SegmentClient;
|
|
21
|
-
private payload: ChannelPayload;
|
|
22
|
-
|
|
23
|
-
constructor(payload: ChannelPayload, segmentClient: SegmentClient) {
|
|
24
|
-
this.payload = payload;
|
|
25
|
-
this.segmentClient = segmentClient;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
get key(): string {
|
|
29
|
-
if (!this.payload.key) {
|
|
30
|
-
throw new Error('Channel key is not set');
|
|
31
|
-
}
|
|
32
|
-
return this.payload.key;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
get name(): string {
|
|
36
|
-
if (!this.payload.name) {
|
|
37
|
-
throw new Error('Channel name is not set');
|
|
38
|
-
}
|
|
39
|
-
return this.payload.name;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get nodeId(): number {
|
|
43
|
-
if (this.payload.nodeId === undefined) {
|
|
44
|
-
throw new Error('Channel nodeId is not set');
|
|
45
|
-
}
|
|
46
|
-
return this.payload.nodeId;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
get rate(): Rate {
|
|
50
|
-
return this.payload.rate;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
get dataType(): DataType {
|
|
54
|
-
return this.payload.dataType;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
get density(): Density {
|
|
58
|
-
if (!this.payload.density) {
|
|
59
|
-
throw new Error('Channel density is not set');
|
|
60
|
-
}
|
|
61
|
-
return this.payload.density;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Reads telemetry from the channel between the two timestamps.
|
|
66
|
-
*
|
|
67
|
-
* @param start - The starting timestamp of the range to read from.
|
|
68
|
-
* @param end - The ending timestamp of the range to read from.
|
|
69
|
-
* @returns a typed array containing the retrieved
|
|
70
|
-
*/
|
|
71
|
-
async read(
|
|
72
|
-
start: UnparsedTimeStamp,
|
|
73
|
-
end: UnparsedTimeStamp
|
|
74
|
-
): Promise<TypedArray> {
|
|
75
|
-
return await this.segmentClient.read(this.key, start, end);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Writes telemetry to the channel starting at the given timestamp.
|
|
80
|
-
*
|
|
81
|
-
* @param start - The starting timestamp of the first sample in data.
|
|
82
|
-
* @param data - THe telemetry to write to the channel.
|
|
83
|
-
*/
|
|
84
|
-
async write(start: UnparsedTimeStamp, data: TypedArray) {
|
|
85
|
-
return await this.segmentClient.write(this.key, start, data);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/** The core client class for executing channel operations against a Synnax
|
|
90
|
-
* database .
|
|
91
|
-
* */
|
|
92
|
-
export default class ChannelClient {
|
|
93
|
-
private readonly segmentClient: SegmentClient;
|
|
94
|
-
private readonly retriever: ChannelRetriever;
|
|
95
|
-
private readonly creator: ChannelCreator;
|
|
96
|
-
|
|
97
|
-
constructor(
|
|
98
|
-
segmentClient: SegmentClient,
|
|
99
|
-
retriever: ChannelRetriever,
|
|
100
|
-
creator: ChannelCreator
|
|
101
|
-
) {
|
|
102
|
-
this.segmentClient = segmentClient;
|
|
103
|
-
this.retriever = retriever;
|
|
104
|
-
this.creator = creator;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Creates a new channel with the given properties.
|
|
109
|
-
*
|
|
110
|
-
* @param props.rate - The rate of the channel.
|
|
111
|
-
* @param props.dataType - The data type of the channel.
|
|
112
|
-
* @param props.name - The name of the channel. Optional.
|
|
113
|
-
* @param props.nodeId - The ID of the node that holds the lease on the channel.
|
|
114
|
-
* If you don't know what this is, don't worry about it.
|
|
115
|
-
* @returns the created channel.
|
|
116
|
-
*/
|
|
117
|
-
async create(props: CreateChannelProps): Promise<Channel> {
|
|
118
|
-
return (await this.createMany({ ...props, count: 1 }))[0];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* creates N channels using the given parameters as a template.
|
|
123
|
-
*
|
|
124
|
-
* @param props.rate - The rate of the channel.
|
|
125
|
-
* @param props.dataType - The data type of the channel.
|
|
126
|
-
* @param props.name - The name of the channel. Optional.
|
|
127
|
-
* @param props.nodeId - The ID of the node that holds the lease on the channel.
|
|
128
|
-
* If you don't know what this is, don't worry about it.
|
|
129
|
-
* @param props.count - The number of channels to create.
|
|
130
|
-
* @returns the created channels.
|
|
131
|
-
*/
|
|
132
|
-
async createMany(
|
|
133
|
-
props: CreateChannelProps & { count: number }
|
|
134
|
-
): Promise<Channel[]> {
|
|
135
|
-
return this.sugar(...(await this.creator.createMany(props)));
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Retrieves channels with the given keys.
|
|
140
|
-
*
|
|
141
|
-
* @param keys - The keys of the channels to retrieve.
|
|
142
|
-
* @throws QueryError if any of the channels can't be found.
|
|
143
|
-
* @returns the retrieved channels.
|
|
144
|
-
*/
|
|
145
|
-
async retrieveByKeys(...keys: string[]): Promise<Channel[]> {
|
|
146
|
-
return this.sugar(...(await this.retriever.retrieveByKeys(...keys)));
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Retrieves channels with the given names.
|
|
151
|
-
*
|
|
152
|
-
* @param names - The list of names to retrieve channels for.
|
|
153
|
-
* @returns A list of retrieved channels matching the given names. If a channel
|
|
154
|
-
* with a given name can't be found, it will be omitted from the list.
|
|
155
|
-
*/
|
|
156
|
-
async retrieveByNames(...names: string[]): Promise<Channel[]> {
|
|
157
|
-
return this.sugar(...(await this.retriever.retrieveByNames(...names)));
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Retrieves channels whose lease node is the given ID.
|
|
162
|
-
*
|
|
163
|
-
* @param nodeId - The ID of the node to retrieve channels for.
|
|
164
|
-
* @returns A list of retrieved channels matching the given node ID.
|
|
165
|
-
*/
|
|
166
|
-
async retrieveByNodeId(nodeId: number): Promise<Channel[]> {
|
|
167
|
-
return this.sugar(...(await this.retriever.retrieveByNodeID(nodeId)));
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
private sugar(...payloads: ChannelPayload[]): Channel[] {
|
|
171
|
-
return payloads.map((p) => new Channel(p, this.segmentClient));
|
|
172
|
-
}
|
|
173
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { UnaryClient } from '@synnaxlabs/freighter';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
|
|
4
|
-
import { DataType, Rate, UnparsedDataType, UnparsedRate } from '../telem';
|
|
5
|
-
import Transport from '../transport';
|
|
6
|
-
|
|
7
|
-
import { ChannelPayload, ChannelPayloadSchema } from './payload';
|
|
8
|
-
|
|
9
|
-
const RequestSchema = z.object({
|
|
10
|
-
channel: ChannelPayloadSchema,
|
|
11
|
-
count: z.number(),
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
type Request = z.infer<typeof RequestSchema>;
|
|
15
|
-
|
|
16
|
-
const ResponseSchema = z.object({
|
|
17
|
-
channels: ChannelPayloadSchema.array(),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
type Response = z.infer<typeof ResponseSchema>;
|
|
21
|
-
|
|
22
|
-
export type CreateChannelProps = {
|
|
23
|
-
rate: UnparsedRate;
|
|
24
|
-
dataType: UnparsedDataType;
|
|
25
|
-
name?: string;
|
|
26
|
-
nodeId?: number;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default class Creator {
|
|
30
|
-
private static ENDPOINT = '/channel/create';
|
|
31
|
-
private client: UnaryClient;
|
|
32
|
-
|
|
33
|
-
constructor(transport: Transport) {
|
|
34
|
-
this.client = transport.postClient();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async create(props: CreateChannelProps): Promise<ChannelPayload> {
|
|
38
|
-
const [channel] = await this.createMany({ ...props, count: 1 });
|
|
39
|
-
return channel;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async createMany({
|
|
43
|
-
rate,
|
|
44
|
-
dataType,
|
|
45
|
-
name = '',
|
|
46
|
-
nodeId = 0,
|
|
47
|
-
count = 1,
|
|
48
|
-
}: CreateChannelProps & { count: number }): Promise<ChannelPayload[]> {
|
|
49
|
-
return (
|
|
50
|
-
await this.execute({
|
|
51
|
-
channel: {
|
|
52
|
-
name,
|
|
53
|
-
nodeId,
|
|
54
|
-
rate: new Rate(rate),
|
|
55
|
-
dataType: new DataType(dataType),
|
|
56
|
-
},
|
|
57
|
-
count,
|
|
58
|
-
})
|
|
59
|
-
).channels;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private async execute(request: Request): Promise<Response> {
|
|
63
|
-
const [res, err] = await this.client.send(
|
|
64
|
-
Creator.ENDPOINT,
|
|
65
|
-
request,
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
ResponseSchema
|
|
69
|
-
);
|
|
70
|
-
if (err) throw err;
|
|
71
|
-
return res as Response;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
import { DataType, Density, Rate } from '../telem';
|
|
4
|
-
|
|
5
|
-
export const ChannelPayloadSchema = z.object({
|
|
6
|
-
rate: z.number().transform((n) => new Rate(n)),
|
|
7
|
-
dataType: z.string().transform((s) => new DataType(s)),
|
|
8
|
-
key: z.string().default('').optional(),
|
|
9
|
-
name: z.string().default('').optional(),
|
|
10
|
-
nodeId: z.number().default(0).optional(),
|
|
11
|
-
density: z
|
|
12
|
-
.number()
|
|
13
|
-
.default(0)
|
|
14
|
-
.transform((n) => new Density(n))
|
|
15
|
-
.optional(),
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export type ChannelPayload = z.infer<typeof ChannelPayloadSchema>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { ChannelPayload } from './payload';
|
|
2
|
-
import Retriever from './retriever';
|
|
3
|
-
|
|
4
|
-
export default class Registry {
|
|
5
|
-
private retriever: Retriever;
|
|
6
|
-
private channels: Map<string, ChannelPayload>;
|
|
7
|
-
|
|
8
|
-
constructor(retriever: Retriever) {
|
|
9
|
-
this.retriever = retriever;
|
|
10
|
-
this.channels = new Map();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async get(key: string): Promise<ChannelPayload> {
|
|
14
|
-
let channel = this.channels.get(key);
|
|
15
|
-
if (channel === undefined) {
|
|
16
|
-
channel = (await this.retriever.retrieveByKeys(key))[0];
|
|
17
|
-
this.channels.set(key, channel);
|
|
18
|
-
}
|
|
19
|
-
return channel;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async getN(...keys: string[]): Promise<ChannelPayload[]> {
|
|
23
|
-
const results: ChannelPayload[] = [];
|
|
24
|
-
const retrieveKeys: string[] = [];
|
|
25
|
-
keys.forEach((key) => {
|
|
26
|
-
const channel = this.channels.get(key);
|
|
27
|
-
if (channel === undefined) retrieveKeys.push(key);
|
|
28
|
-
else results.push(channel);
|
|
29
|
-
});
|
|
30
|
-
if (retrieveKeys.length > 0) {
|
|
31
|
-
const channels = await this.retriever.retrieveByKeys(...retrieveKeys);
|
|
32
|
-
channels.forEach((channel) => {
|
|
33
|
-
this.channels.set(channel.key as string, channel);
|
|
34
|
-
results.push(channel);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return results;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { UnaryClient } from '@synnaxlabs/freighter';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
|
|
4
|
-
import Transport from '../transport';
|
|
5
|
-
|
|
6
|
-
import { ChannelPayload, ChannelPayloadSchema } from './payload';
|
|
7
|
-
|
|
8
|
-
const RequestSchema = z.object({
|
|
9
|
-
keys: z.string().array().optional(),
|
|
10
|
-
nodeId: z.number().optional(),
|
|
11
|
-
names: z.string().array().optional(),
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
type Request = z.infer<typeof RequestSchema>;
|
|
15
|
-
|
|
16
|
-
const ResponseSchema = z.object({
|
|
17
|
-
channels: ChannelPayloadSchema.array(),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export default class Retriever {
|
|
21
|
-
private static ENDPOINT = '/channel/retrieve';
|
|
22
|
-
private client: UnaryClient;
|
|
23
|
-
|
|
24
|
-
constructor(transport: Transport) {
|
|
25
|
-
this.client = transport.getClient();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
private async execute(request: Request): Promise<ChannelPayload[]> {
|
|
29
|
-
const [res, err] = await this.client.send(
|
|
30
|
-
Retriever.ENDPOINT,
|
|
31
|
-
request,
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
ResponseSchema
|
|
35
|
-
);
|
|
36
|
-
if (err) {
|
|
37
|
-
throw err;
|
|
38
|
-
}
|
|
39
|
-
return res?.channels as ChannelPayload[];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async retrieveByKeys(...keys: string[]): Promise<ChannelPayload[]> {
|
|
43
|
-
return await this.execute({ keys });
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async retrieveByNames(...names: string[]): Promise<ChannelPayload[]> {
|
|
47
|
-
return await this.execute({ names });
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async retrieveByNodeID(nodeId: number): Promise<ChannelPayload[]> {
|
|
51
|
-
return await this.execute({ nodeId: nodeId });
|
|
52
|
-
}
|
|
53
|
-
}
|