@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,98 +0,0 @@
|
|
|
1
|
-
import { StreamClient } from '@synnaxlabs/freighter';
|
|
2
|
-
import ChannelRegistry from '../channel/registry';
|
|
3
|
-
import { TypedArray, UnparsedTimeStamp } from '../telem';
|
|
4
|
-
import { SegmentPayload } from './payload';
|
|
5
|
-
/**
|
|
6
|
-
* CoreWriter is used to write telemetry to a set of channels in time-order. It
|
|
7
|
-
* should not be instantiated directly, but rather through a {@link SegmentClient}.
|
|
8
|
-
*
|
|
9
|
-
* Using a writer is ideal when writing large volumes of data (such as recording
|
|
10
|
-
* telemetry from a sensor), but it is relatively complex and challenging to use.
|
|
11
|
-
* If you're looking to write a contiguous block of telemetry, see the {@link SegmentClient}
|
|
12
|
-
* write() method.
|
|
13
|
-
*/
|
|
14
|
-
export declare class CoreWriter {
|
|
15
|
-
private static ENDPOINT;
|
|
16
|
-
private client;
|
|
17
|
-
private stream;
|
|
18
|
-
private keys;
|
|
19
|
-
constructor(client: StreamClient);
|
|
20
|
-
/**
|
|
21
|
-
* Opens the writer, acquiring an exclusive lock on the given channels for
|
|
22
|
-
* the duration of the writer's lifetime. open must be called before any other
|
|
23
|
-
* writer methods.
|
|
24
|
-
*
|
|
25
|
-
* @param keys - A list of keys representing the channels the writer will write
|
|
26
|
-
* to.
|
|
27
|
-
*/
|
|
28
|
-
open(keys: string[]): Promise<void>;
|
|
29
|
-
/**
|
|
30
|
-
* Validates and writes the given segments to the database. The provided segments
|
|
31
|
-
* must:
|
|
32
|
-
*
|
|
33
|
-
* 1. Be in time order (on a per-channel basis)
|
|
34
|
-
* 2. Have channel keys in the set of keys this writer was opened with.
|
|
35
|
-
* 3. Have non-zero length data with the correct data type.
|
|
36
|
-
*
|
|
37
|
-
* @param segments - A list of segments to write to the database.
|
|
38
|
-
* @returns false if the writer has accumulated an error. In this case,
|
|
39
|
-
* the caller should stop executing requests and close the writer.
|
|
40
|
-
*/
|
|
41
|
-
write(segments: SegmentPayload[]): Promise<boolean>;
|
|
42
|
-
/**
|
|
43
|
-
* Closes the writer, raising any accumulated error encountered during operation.
|
|
44
|
-
* A writer MUST be closed after use, and this method should probably be placed
|
|
45
|
-
* in a 'finally' block. If the writer is not closed, the database will not release
|
|
46
|
-
* the exclusive lock on the channels, preventing any other callers from
|
|
47
|
-
* writing to them. It also might leak resources and threads.
|
|
48
|
-
*/
|
|
49
|
-
close(): Promise<void>;
|
|
50
|
-
private checkKeys;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* TypedWriter is used to write telemetry to a set of channels in time-order. It
|
|
54
|
-
* should not be instantiated directly, but rather through a {@link SegmentClient}.
|
|
55
|
-
*
|
|
56
|
-
* Using a writer is ideal when writing large volumes of data (such as recording
|
|
57
|
-
* telemetry from a sensor), but it is relatively complex and challenging to use.
|
|
58
|
-
* If you're looking to write a contiguous block of telemetry, see the {@link SegmentClient}
|
|
59
|
-
* write() method.
|
|
60
|
-
*/
|
|
61
|
-
export declare class TypedWriter {
|
|
62
|
-
private core;
|
|
63
|
-
private splitter;
|
|
64
|
-
private channels;
|
|
65
|
-
private scalarTypeValidator;
|
|
66
|
-
private contiguityValidator;
|
|
67
|
-
constructor(client: StreamClient, channels: ChannelRegistry);
|
|
68
|
-
/**
|
|
69
|
-
* Opens the writer, acquiring an exclusive lock on the given channels for
|
|
70
|
-
* the duration of the writer's lifetime. open must be called before any other
|
|
71
|
-
* writer methods.
|
|
72
|
-
*
|
|
73
|
-
* @param keys - A list of keys representing the channels the writer will write
|
|
74
|
-
* to.
|
|
75
|
-
*/
|
|
76
|
-
open(keys: string[]): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* Writes the given telemetry to the database.
|
|
79
|
-
*
|
|
80
|
-
* @param to - They key of the channel to write to. This must be in the set of
|
|
81
|
-
* keys this writer was opened with.
|
|
82
|
-
* @param start - The start time of the telemetry. This must be equal to
|
|
83
|
-
* the end of the previous segment written to the channel (unless it's the first
|
|
84
|
-
* write to that channel).
|
|
85
|
-
* @param data - The telemetry to write. This must be a valid type for the channel.
|
|
86
|
-
* @returns false if the writer has accumulated an error. In this case,
|
|
87
|
-
* the caller should stop executing requests and close the writer.
|
|
88
|
-
*/
|
|
89
|
-
write(to: string, start: UnparsedTimeStamp, data: TypedArray): Promise<boolean>;
|
|
90
|
-
/**
|
|
91
|
-
* Closes the writer, raising any accumulated error encountered during operation.
|
|
92
|
-
* A writer MUST be closed after use, and this method should probably be placed
|
|
93
|
-
* in a 'finally' block. If the writer is not closed, the database will not release
|
|
94
|
-
* the exclusive lock on the channels, preventing any other callers from
|
|
95
|
-
* writing to them. It also might leak resources and threads.
|
|
96
|
-
*/
|
|
97
|
-
close(): Promise<void>;
|
|
98
|
-
}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { decodeError, EOF, ErrorPayloadSchema, } from '@synnaxlabs/freighter';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { GeneralError, UnexpectedError, ValidationError } from '../errors';
|
|
4
|
-
import { Size, TimeStamp } from '../telem';
|
|
5
|
-
import { SegmentPayloadSchema } from './payload';
|
|
6
|
-
import Splitter from './splitter';
|
|
7
|
-
import TypedSegment from './typed';
|
|
8
|
-
import { ContiguityValidator, ScalarTypeValidator } from './validator';
|
|
9
|
-
const RequestSchema = z.object({
|
|
10
|
-
openKeys: z.string().array().optional(),
|
|
11
|
-
segments: SegmentPayloadSchema.array().optional(),
|
|
12
|
-
});
|
|
13
|
-
const ResponseSchema = z.object({
|
|
14
|
-
ack: z.boolean(),
|
|
15
|
-
error: ErrorPayloadSchema.optional(),
|
|
16
|
-
});
|
|
17
|
-
const NOT_OPEN = new GeneralError('Writer has not been opened. Please open before calling write() or close().');
|
|
18
|
-
/**
|
|
19
|
-
* CoreWriter is used to write telemetry to a set of channels in time-order. It
|
|
20
|
-
* should not be instantiated directly, but rather through a {@link SegmentClient}.
|
|
21
|
-
*
|
|
22
|
-
* Using a writer is ideal when writing large volumes of data (such as recording
|
|
23
|
-
* telemetry from a sensor), but it is relatively complex and challenging to use.
|
|
24
|
-
* If you're looking to write a contiguous block of telemetry, see the {@link SegmentClient}
|
|
25
|
-
* write() method.
|
|
26
|
-
*/
|
|
27
|
-
export class CoreWriter {
|
|
28
|
-
static ENDPOINT = '/segment/write';
|
|
29
|
-
client;
|
|
30
|
-
stream;
|
|
31
|
-
keys;
|
|
32
|
-
constructor(client) {
|
|
33
|
-
this.client = client;
|
|
34
|
-
this.keys = [];
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Opens the writer, acquiring an exclusive lock on the given channels for
|
|
38
|
-
* the duration of the writer's lifetime. open must be called before any other
|
|
39
|
-
* writer methods.
|
|
40
|
-
*
|
|
41
|
-
* @param keys - A list of keys representing the channels the writer will write
|
|
42
|
-
* to.
|
|
43
|
-
*/
|
|
44
|
-
async open(keys) {
|
|
45
|
-
this.keys = keys;
|
|
46
|
-
this.stream = await this.client.stream(CoreWriter.ENDPOINT,
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
RequestSchema, ResponseSchema);
|
|
50
|
-
this.stream.send({ openKeys: keys });
|
|
51
|
-
const [res, err] = await this.stream.receive();
|
|
52
|
-
if (err)
|
|
53
|
-
throw err;
|
|
54
|
-
if (!res?.ack)
|
|
55
|
-
throw new UnexpectedError('Writer failed to positively acknowledge open request. This is a bug. Please report it.');
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Validates and writes the given segments to the database. The provided segments
|
|
59
|
-
* must:
|
|
60
|
-
*
|
|
61
|
-
* 1. Be in time order (on a per-channel basis)
|
|
62
|
-
* 2. Have channel keys in the set of keys this writer was opened with.
|
|
63
|
-
* 3. Have non-zero length data with the correct data type.
|
|
64
|
-
*
|
|
65
|
-
* @param segments - A list of segments to write to the database.
|
|
66
|
-
* @returns false if the writer has accumulated an error. In this case,
|
|
67
|
-
* the caller should stop executing requests and close the writer.
|
|
68
|
-
*/
|
|
69
|
-
async write(segments) {
|
|
70
|
-
if (!this.stream)
|
|
71
|
-
throw NOT_OPEN;
|
|
72
|
-
if (this.stream.received())
|
|
73
|
-
return false;
|
|
74
|
-
this.checkKeys(segments);
|
|
75
|
-
const err = this.stream.send({ segments });
|
|
76
|
-
if (err)
|
|
77
|
-
throw err;
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Closes the writer, raising any accumulated error encountered during operation.
|
|
82
|
-
* A writer MUST be closed after use, and this method should probably be placed
|
|
83
|
-
* in a 'finally' block. If the writer is not closed, the database will not release
|
|
84
|
-
* the exclusive lock on the channels, preventing any other callers from
|
|
85
|
-
* writing to them. It also might leak resources and threads.
|
|
86
|
-
*/
|
|
87
|
-
async close() {
|
|
88
|
-
if (!this.stream)
|
|
89
|
-
throw NOT_OPEN;
|
|
90
|
-
this.stream.closeSend();
|
|
91
|
-
const [res, err] = await this.stream.receive();
|
|
92
|
-
if (!err && res?.error)
|
|
93
|
-
throw decodeError(res.error);
|
|
94
|
-
if (!(err instanceof EOF))
|
|
95
|
-
throw err;
|
|
96
|
-
}
|
|
97
|
-
checkKeys(segments) {
|
|
98
|
-
// check that the channel key of each segment is in the open keys
|
|
99
|
-
segments
|
|
100
|
-
.map((segment) => segment.channelKey)
|
|
101
|
-
.forEach((key) => {
|
|
102
|
-
if (!this.keys.includes(key))
|
|
103
|
-
throw new ValidationError({
|
|
104
|
-
field: 'channelKey',
|
|
105
|
-
message: `Channel key ${key} is not in the list of keys this writer was opened with.`,
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* TypedWriter is used to write telemetry to a set of channels in time-order. It
|
|
112
|
-
* should not be instantiated directly, but rather through a {@link SegmentClient}.
|
|
113
|
-
*
|
|
114
|
-
* Using a writer is ideal when writing large volumes of data (such as recording
|
|
115
|
-
* telemetry from a sensor), but it is relatively complex and challenging to use.
|
|
116
|
-
* If you're looking to write a contiguous block of telemetry, see the {@link SegmentClient}
|
|
117
|
-
* write() method.
|
|
118
|
-
*/
|
|
119
|
-
export class TypedWriter {
|
|
120
|
-
core;
|
|
121
|
-
splitter;
|
|
122
|
-
channels;
|
|
123
|
-
scalarTypeValidator;
|
|
124
|
-
contiguityValidator;
|
|
125
|
-
constructor(client, channels) {
|
|
126
|
-
this.core = new CoreWriter(client);
|
|
127
|
-
this.channels = channels;
|
|
128
|
-
this.scalarTypeValidator = new ScalarTypeValidator();
|
|
129
|
-
this.contiguityValidator = new ContiguityValidator({
|
|
130
|
-
allowNoHighWaterMark: true,
|
|
131
|
-
allowGaps: false,
|
|
132
|
-
allowOverlap: false,
|
|
133
|
-
});
|
|
134
|
-
this.splitter = new Splitter(Size.Megabytes(4));
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Opens the writer, acquiring an exclusive lock on the given channels for
|
|
138
|
-
* the duration of the writer's lifetime. open must be called before any other
|
|
139
|
-
* writer methods.
|
|
140
|
-
*
|
|
141
|
-
* @param keys - A list of keys representing the channels the writer will write
|
|
142
|
-
* to.
|
|
143
|
-
*/
|
|
144
|
-
async open(keys) {
|
|
145
|
-
await this.core.open(keys);
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Writes the given telemetry to the database.
|
|
149
|
-
*
|
|
150
|
-
* @param to - They key of the channel to write to. This must be in the set of
|
|
151
|
-
* keys this writer was opened with.
|
|
152
|
-
* @param start - The start time of the telemetry. This must be equal to
|
|
153
|
-
* the end of the previous segment written to the channel (unless it's the first
|
|
154
|
-
* write to that channel).
|
|
155
|
-
* @param data - The telemetry to write. This must be a valid type for the channel.
|
|
156
|
-
* @returns false if the writer has accumulated an error. In this case,
|
|
157
|
-
* the caller should stop executing requests and close the writer.
|
|
158
|
-
*/
|
|
159
|
-
async write(to, start, data) {
|
|
160
|
-
const ch = await this.channels.get(to);
|
|
161
|
-
this.scalarTypeValidator.validate(data, ch.dataType);
|
|
162
|
-
const pld = {
|
|
163
|
-
channelKey: to,
|
|
164
|
-
start: new TimeStamp(start),
|
|
165
|
-
data: new Uint8Array(data.buffer),
|
|
166
|
-
};
|
|
167
|
-
const segment = new TypedSegment(ch, pld);
|
|
168
|
-
this.contiguityValidator.validate(segment);
|
|
169
|
-
const segments = this.splitter.split(segment);
|
|
170
|
-
return this.core.write(segments.map((s) => s.payload));
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Closes the writer, raising any accumulated error encountered during operation.
|
|
174
|
-
* A writer MUST be closed after use, and this method should probably be placed
|
|
175
|
-
* in a 'finally' block. If the writer is not closed, the database will not release
|
|
176
|
-
* the exclusive lock on the channels, preventing any other callers from
|
|
177
|
-
* writing to them. It also might leak resources and threads.
|
|
178
|
-
*/
|
|
179
|
-
async close() {
|
|
180
|
-
await this.core.close();
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid3JpdGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2xpYi9zZWdtZW50L3dyaXRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0wsV0FBVyxFQUNYLEdBQUcsRUFDSCxrQkFBa0IsR0FHbkIsTUFBTSx1QkFBdUIsQ0FBQztBQUMvQixPQUFPLEVBQUUsQ0FBQyxFQUFFLE1BQU0sS0FBSyxDQUFDO0FBR3hCLE9BQU8sRUFBRSxZQUFZLEVBQUUsZUFBZSxFQUFFLGVBQWUsRUFBRSxNQUFNLFdBQVcsQ0FBQztBQUMzRSxPQUFPLEVBQUUsSUFBSSxFQUFFLFNBQVMsRUFBaUMsTUFBTSxVQUFVLENBQUM7QUFFMUUsT0FBTyxFQUFrQixvQkFBb0IsRUFBRSxNQUFNLFdBQVcsQ0FBQztBQUNqRSxPQUFPLFFBQVEsTUFBTSxZQUFZLENBQUM7QUFDbEMsT0FBTyxZQUFZLE1BQU0sU0FBUyxDQUFDO0FBQ25DLE9BQU8sRUFBRSxtQkFBbUIsRUFBRSxtQkFBbUIsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUV2RSxNQUFNLGFBQWEsR0FBRyxDQUFDLENBQUMsTUFBTSxDQUFDO0lBQzdCLFFBQVEsRUFBRSxDQUFDLENBQUMsTUFBTSxFQUFFLENBQUMsS0FBSyxFQUFFLENBQUMsUUFBUSxFQUFFO0lBQ3ZDLFFBQVEsRUFBRSxvQkFBb0IsQ0FBQyxLQUFLL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TyxDQUFDLENBQUM7UUFDOUMsT0FBTyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxRQUFRLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxFQUFFLEVBQUUsQ0FBQyxDQUFDLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQztJQUN6RCxDQUFDO0lBRUQ7Ozs7OztPQU1HO0lBQ0gsS0FBSyxDQUFDLEtBQUs7UUFDVCxNQUFNLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDMUIsQ0FBQztDQUNGIn0=
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import test from 'ava';
|
|
2
|
-
import { newClient } from '../../setupspecs';
|
|
3
|
-
import { ContiguityError, ValidationError } from '../errors';
|
|
4
|
-
import { DataType, Rate, Size, TimeSpan } from '../telem';
|
|
5
|
-
import { randomTypedArray } from '../util/telem';
|
|
6
|
-
const client = newClient();
|
|
7
|
-
const newChannel = async () => {
|
|
8
|
-
return await client.channel.create({
|
|
9
|
-
name: 'test',
|
|
10
|
-
nodeId: 1,
|
|
11
|
-
rate: Rate.Hz(1),
|
|
12
|
-
dataType: DataType.Float64,
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
test('TypedWriter - basic write', async (t) => {
|
|
16
|
-
const ch = await newChannel();
|
|
17
|
-
const writer = await client.data.newWriter([ch.key]);
|
|
18
|
-
try {
|
|
19
|
-
await writer.write(ch.key, 0, randomTypedArray(10, ch.dataType));
|
|
20
|
-
}
|
|
21
|
-
finally {
|
|
22
|
-
await writer.close();
|
|
23
|
-
}
|
|
24
|
-
t.true(true);
|
|
25
|
-
});
|
|
26
|
-
test('TypedWriter - invalid data type', async (t) => {
|
|
27
|
-
const ch = await newChannel();
|
|
28
|
-
const writer = await client.data.newWriter([ch.key]);
|
|
29
|
-
try {
|
|
30
|
-
await writer.write(ch.key, 0, randomTypedArray(16, DataType.Uint8));
|
|
31
|
-
t.fail('Expected error');
|
|
32
|
-
}
|
|
33
|
-
catch (err) {
|
|
34
|
-
t.true(err instanceof ValidationError);
|
|
35
|
-
}
|
|
36
|
-
finally {
|
|
37
|
-
await writer.close();
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
test('TypedWriter - non contiguous', async (t) => {
|
|
41
|
-
const ch = await newChannel();
|
|
42
|
-
const writer = await client.data.newWriter([ch.key]);
|
|
43
|
-
try {
|
|
44
|
-
await writer.write(ch.key, 0, randomTypedArray(10, ch.dataType));
|
|
45
|
-
await writer.write(ch.key, 12, randomTypedArray(10, ch.dataType));
|
|
46
|
-
t.fail('Expected error');
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
t.true(err instanceof ContiguityError);
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
await writer.close();
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
test('TypedWriter - multi segment write', async (t) => {
|
|
56
|
-
const ch = await newChannel();
|
|
57
|
-
const nSamples = 1000;
|
|
58
|
-
const nWrites = 100;
|
|
59
|
-
const writer = await client.data.newWriter([ch.key]);
|
|
60
|
-
const data = randomTypedArray(nSamples, ch.dataType);
|
|
61
|
-
try {
|
|
62
|
-
for (let i = 0; i < nWrites; i++) {
|
|
63
|
-
await writer.write(ch.key, TimeSpan.Seconds(i * nSamples), data);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
finally {
|
|
67
|
-
await writer.close();
|
|
68
|
-
}
|
|
69
|
-
t.true(true);
|
|
70
|
-
});
|
|
71
|
-
test('TypedWriter - segment splitting', async (t) => {
|
|
72
|
-
const ch = await newChannel();
|
|
73
|
-
const span = ch.rate.byteSpan(new Size(9e6), ch.density);
|
|
74
|
-
const nSamples = ch.rate.sampleCount(span);
|
|
75
|
-
const data = randomTypedArray(nSamples, ch.dataType);
|
|
76
|
-
const writer = await client.data.newWriter([ch.key]);
|
|
77
|
-
try {
|
|
78
|
-
await writer.write(ch.key, 0, data);
|
|
79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