@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
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// Copyright 2023 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 { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
|
+
import { type change } from "@synnaxlabs/x";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
|
|
14
|
+
import { cdc } from "@/cdc";
|
|
15
|
+
import { type channel } from "@/channel";
|
|
16
|
+
import { keyZ as channelKeyZ, type Key as ChannelKey } from "@/channel/payload";
|
|
17
|
+
import { type Client as FrameClient } from "@/framer/client";
|
|
18
|
+
import { type Key, keyZ } from "@/ranger/payload";
|
|
19
|
+
|
|
20
|
+
export const ALIAS_SET_NAME = "sy_range_alias_set";
|
|
21
|
+
export const ALIAS_DELETE_NAME = "sy_range_alias_delete";
|
|
22
|
+
|
|
23
|
+
const resolveReqZ = z.object({
|
|
24
|
+
range: keyZ,
|
|
25
|
+
aliases: z.string().array(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const resolveResZ = z.object({
|
|
29
|
+
aliases: z.record(z.string(), channelKeyZ),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const setReqZ = z.object({
|
|
33
|
+
range: keyZ,
|
|
34
|
+
aliases: z.record(channelKeyZ, z.string()),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const setResZ = z.unknown();
|
|
38
|
+
|
|
39
|
+
const deleteReqZ = z.object({
|
|
40
|
+
range: keyZ,
|
|
41
|
+
channels: channelKeyZ.array(),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const deleteResZ = z.unknown();
|
|
45
|
+
|
|
46
|
+
const listReqZ = z.object({
|
|
47
|
+
range: keyZ,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const listResZ = z.object({
|
|
51
|
+
aliases: z.record(z.string(), z.string()),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export class Aliaser {
|
|
55
|
+
private static readonly SET_ENDPOINT = "/range/alias/set";
|
|
56
|
+
private static readonly RESOLVE_ENDPOINT = "/range/alias/resolve";
|
|
57
|
+
private static readonly LIST_ENDPOINT = "/range/alias/list";
|
|
58
|
+
private static readonly DELETE_ENDPOINT = "/range/alias/delete";
|
|
59
|
+
private readonly frameClient: FrameClient;
|
|
60
|
+
private readonly cache = new Map<string, ChannelKey>();
|
|
61
|
+
private readonly client: UnaryClient;
|
|
62
|
+
private readonly rangeKey: Key;
|
|
63
|
+
|
|
64
|
+
constructor(rangeKey: Key, frameClient: FrameClient, client: UnaryClient) {
|
|
65
|
+
this.rangeKey = rangeKey;
|
|
66
|
+
this.cache = new Map();
|
|
67
|
+
this.client = client;
|
|
68
|
+
this.frameClient = frameClient;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
resolve(aliases: string): Promise<ChannelKey>;
|
|
72
|
+
|
|
73
|
+
resolve(aliases: string[]): Promise<Record<string, ChannelKey>>;
|
|
74
|
+
|
|
75
|
+
async resolve(
|
|
76
|
+
aliases: string | string[],
|
|
77
|
+
): Promise<ChannelKey | Record<string, ChannelKey>> {
|
|
78
|
+
const toFetch: string[] = [];
|
|
79
|
+
const isSingle = typeof aliases === "string";
|
|
80
|
+
const cached: Record<string, ChannelKey> = {};
|
|
81
|
+
if (isSingle) {
|
|
82
|
+
const c = this.cache.get(aliases);
|
|
83
|
+
if (c != null) return c;
|
|
84
|
+
toFetch.push(aliases);
|
|
85
|
+
} else
|
|
86
|
+
aliases.forEach((alias) => {
|
|
87
|
+
const c = this.cache.get(alias);
|
|
88
|
+
if (c != null) cached[alias] = c;
|
|
89
|
+
else toFetch.push(alias);
|
|
90
|
+
});
|
|
91
|
+
if (toFetch.length === 0) return cached;
|
|
92
|
+
const res = await sendRequired<typeof resolveReqZ, typeof resolveResZ>(
|
|
93
|
+
this.client,
|
|
94
|
+
Aliaser.RESOLVE_ENDPOINT,
|
|
95
|
+
{ range: this.rangeKey, aliases: toFetch },
|
|
96
|
+
resolveResZ,
|
|
97
|
+
);
|
|
98
|
+
Object.entries(res.aliases).forEach(([alias, key]) => this.cache.set(alias, key));
|
|
99
|
+
return isSingle ? res.aliases[toFetch[0]] : { ...cached, ...res.aliases };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async set(aliases: Record<ChannelKey, string>): Promise<void> {
|
|
103
|
+
await sendRequired<typeof setReqZ, typeof setResZ>(
|
|
104
|
+
this.client,
|
|
105
|
+
Aliaser.SET_ENDPOINT,
|
|
106
|
+
{
|
|
107
|
+
range: this.rangeKey,
|
|
108
|
+
aliases,
|
|
109
|
+
},
|
|
110
|
+
z.unknown(),
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async list(): Promise<Record<ChannelKey, string>> {
|
|
115
|
+
return (
|
|
116
|
+
await sendRequired<typeof listReqZ, typeof listResZ>(
|
|
117
|
+
this.client,
|
|
118
|
+
Aliaser.LIST_ENDPOINT,
|
|
119
|
+
{
|
|
120
|
+
range: this.rangeKey,
|
|
121
|
+
},
|
|
122
|
+
listResZ,
|
|
123
|
+
)
|
|
124
|
+
).aliases;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async delete(aliases: ChannelKey[]): Promise<void> {
|
|
128
|
+
await sendRequired<typeof deleteReqZ, typeof deleteResZ>(
|
|
129
|
+
this.client,
|
|
130
|
+
Aliaser.DELETE_ENDPOINT,
|
|
131
|
+
{
|
|
132
|
+
range: this.rangeKey,
|
|
133
|
+
channels: aliases,
|
|
134
|
+
},
|
|
135
|
+
deleteResZ,
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async openChangeTracker(): Promise<cdc.Observable<string, Alias>> {
|
|
140
|
+
return await cdc.Observable.open<string, Alias>(
|
|
141
|
+
this.frameClient,
|
|
142
|
+
ALIAS_SET_NAME,
|
|
143
|
+
ALIAS_DELETE_NAME,
|
|
144
|
+
decodeAliasChanges(this.rangeKey),
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface Alias {
|
|
150
|
+
range: Key;
|
|
151
|
+
channel: channel.Key;
|
|
152
|
+
alias: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export type AliasChange = change.Change<string, Alias>;
|
|
156
|
+
|
|
157
|
+
const aliasZ = z.object({
|
|
158
|
+
range: keyZ,
|
|
159
|
+
channel: channelKeyZ,
|
|
160
|
+
alias: z.string(),
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const aliasSeparator = "---";
|
|
164
|
+
|
|
165
|
+
const decodeAliasChanges =
|
|
166
|
+
(rangeKey: Key): cdc.Decoder<string, Alias> =>
|
|
167
|
+
(variant, data) => {
|
|
168
|
+
if (variant === "delete") {
|
|
169
|
+
return data
|
|
170
|
+
.toStrings()
|
|
171
|
+
.filter((k) => k.split(aliasSeparator)[0] === rangeKey)
|
|
172
|
+
.map((alias) => ({
|
|
173
|
+
variant,
|
|
174
|
+
key: alias,
|
|
175
|
+
value: undefined,
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
return data.parseJSON(aliasZ).map((alias) => ({
|
|
179
|
+
variant,
|
|
180
|
+
key: alias.alias,
|
|
181
|
+
value: alias,
|
|
182
|
+
}));
|
|
183
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Copyright 2023 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 { type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
|
+
import { type AsyncTermSearcher, toArray } from "@synnaxlabs/x";
|
|
12
|
+
|
|
13
|
+
import { type Retriever as ChannelRetriever } from "@/channel/retriever";
|
|
14
|
+
import { QueryError } from "@/errors";
|
|
15
|
+
import { type framer } from "@/framer";
|
|
16
|
+
import { Aliaser } from "@/ranger/alias";
|
|
17
|
+
import { KV } from "@/ranger/kv";
|
|
18
|
+
import {
|
|
19
|
+
type NewPayload,
|
|
20
|
+
type Key,
|
|
21
|
+
type Keys,
|
|
22
|
+
type Name,
|
|
23
|
+
type Names,
|
|
24
|
+
type Params,
|
|
25
|
+
type Payload,
|
|
26
|
+
analyzeParams,
|
|
27
|
+
} from "@/ranger/payload";
|
|
28
|
+
import { Range } from "@/ranger/range";
|
|
29
|
+
import { type Retriever } from "@/ranger/retriever";
|
|
30
|
+
import { type Writer } from "@/ranger/writer";
|
|
31
|
+
|
|
32
|
+
import { Active } from "./active";
|
|
33
|
+
|
|
34
|
+
export class Client implements AsyncTermSearcher<string, Key, Range> {
|
|
35
|
+
private readonly frameClient: framer.Client;
|
|
36
|
+
private readonly retriever: Retriever;
|
|
37
|
+
private readonly writer: Writer;
|
|
38
|
+
private readonly unaryClient: UnaryClient;
|
|
39
|
+
private readonly channels: ChannelRetriever;
|
|
40
|
+
private readonly active: Active;
|
|
41
|
+
|
|
42
|
+
constructor(
|
|
43
|
+
frameClient: framer.Client,
|
|
44
|
+
retriever: Retriever,
|
|
45
|
+
writer: Writer,
|
|
46
|
+
unary: UnaryClient,
|
|
47
|
+
channels: ChannelRetriever,
|
|
48
|
+
) {
|
|
49
|
+
this.frameClient = frameClient;
|
|
50
|
+
this.retriever = retriever;
|
|
51
|
+
this.writer = writer;
|
|
52
|
+
this.unaryClient = unary;
|
|
53
|
+
this.channels = channels;
|
|
54
|
+
this.active = new Active(unary);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async create(range: NewPayload): Promise<Range>;
|
|
58
|
+
|
|
59
|
+
async create(ranges: NewPayload[]): Promise<Range[]>;
|
|
60
|
+
|
|
61
|
+
async create(ranges: NewPayload | NewPayload[]): Promise<Range | Range[]> {
|
|
62
|
+
const single = !Array.isArray(ranges);
|
|
63
|
+
const res = this.sugar(await this.writer.create(toArray(ranges)));
|
|
64
|
+
return single ? res[0] : res;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async rename(key: Key, name: Name): Promise<void> {
|
|
68
|
+
await this.writer.rename(key, name);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async delete(key: Key | Keys): Promise<void> {
|
|
72
|
+
await this.writer.delete(toArray(key));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async search(term: string): Promise<Range[]> {
|
|
76
|
+
return this.sugar(await this.retriever.search(term));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async page(offset: number, limit: number): Promise<Range[]> {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async retrieve(range: Key | Name): Promise<Range>;
|
|
84
|
+
|
|
85
|
+
async retrieve(params: Keys | Names): Promise<Range[]>;
|
|
86
|
+
|
|
87
|
+
async retrieve(params: Params): Promise<Range | Range[]> {
|
|
88
|
+
const { single, actual } = analyzeParams(params);
|
|
89
|
+
const res = this.sugar(await this.retriever.retrieve(params));
|
|
90
|
+
if (!single) return res;
|
|
91
|
+
if (res.length === 0) throw new QueryError(`range matching ${actual} not found`);
|
|
92
|
+
if (res.length > 1)
|
|
93
|
+
throw new QueryError(`multiple ranges matching ${actual} found`);
|
|
94
|
+
return res[0];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async setActive(range: Key): Promise<void> {
|
|
98
|
+
await this.active.setActive(range);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async retrieveActive(): Promise<Range | null> {
|
|
102
|
+
const res = await this.active.retrieveActive();
|
|
103
|
+
if (res == null) return null;
|
|
104
|
+
return this.sugar([res])[0];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async clearActive(range: Key): Promise<void> {
|
|
108
|
+
await this.active.clearActive(range);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private sugar(payloads: Payload[]): Range[] {
|
|
112
|
+
return payloads.map((payload) => {
|
|
113
|
+
return new Range(
|
|
114
|
+
payload.name,
|
|
115
|
+
payload.timeRange,
|
|
116
|
+
payload.key,
|
|
117
|
+
this.frameClient,
|
|
118
|
+
new KV(payload.key, this.unaryClient),
|
|
119
|
+
new Aliaser(payload.key, this.frameClient, this.unaryClient),
|
|
120
|
+
this.channels,
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2023 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
|
+
export * from "@/ranger/client";
|
|
11
|
+
export * from "@/ranger/writer";
|
|
12
|
+
export * from "@/ranger/payload";
|
|
13
|
+
export * from "@/ranger/range";
|
|
14
|
+
export * from "@/ranger/retriever";
|
|
15
|
+
export type { Alias, AliasChange } from "@/ranger/alias";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2023 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
|
+
export * as ranger from "@/ranger/external";
|
package/src/ranger/kv.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Copyright 2023 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 { type UnaryClient, sendRequired } from "@synnaxlabs/freighter";
|
|
11
|
+
import { isObject, toArray } from "@synnaxlabs/x";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
|
|
14
|
+
import { type Key, keyZ } from "@/ranger/payload";
|
|
15
|
+
|
|
16
|
+
const getReqZ = z.object({
|
|
17
|
+
range: keyZ,
|
|
18
|
+
keys: z.string().array(),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const getResZ = z.object({
|
|
22
|
+
pairs: z.record(z.string(), z.string()),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export type GetRequest = z.infer<typeof getReqZ>;
|
|
26
|
+
|
|
27
|
+
const setReqZ = z.object({
|
|
28
|
+
range: keyZ,
|
|
29
|
+
pairs: z.record(z.string(), z.string()),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export type SetRequest = z.infer<typeof setReqZ>;
|
|
33
|
+
|
|
34
|
+
const deleteReqZ = z.object({
|
|
35
|
+
range: keyZ,
|
|
36
|
+
keys: z.string().array(),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export type DeleteRequest = z.infer<typeof deleteReqZ>;
|
|
40
|
+
|
|
41
|
+
export class KV {
|
|
42
|
+
private static readonly GET_ENDPOINT = "/range/kv/get";
|
|
43
|
+
private static readonly SET_ENDPOINT = "/range/kv/set";
|
|
44
|
+
private static readonly DELETE_ENDPOINT = "/range/kv/delete";
|
|
45
|
+
private readonly rangeKey: Key;
|
|
46
|
+
private readonly client: UnaryClient;
|
|
47
|
+
|
|
48
|
+
constructor(rng: Key, client: UnaryClient) {
|
|
49
|
+
this.rangeKey = rng;
|
|
50
|
+
this.client = client;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async get(key: string): Promise<string>;
|
|
54
|
+
|
|
55
|
+
async get(keys: string[]): Promise<Record<string, string>>;
|
|
56
|
+
|
|
57
|
+
async get(keys: string | string[]): Promise<string | Record<string, string>> {
|
|
58
|
+
const [res, err] = await this.client.send(
|
|
59
|
+
KV.GET_ENDPOINT,
|
|
60
|
+
{ range: this.rangeKey, keys: toArray(keys) },
|
|
61
|
+
getResZ,
|
|
62
|
+
);
|
|
63
|
+
if (err != null) throw err;
|
|
64
|
+
return Array.isArray(keys) ? res.pairs : res.pairs[keys];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async set(key: string, value: string): Promise<void>;
|
|
68
|
+
|
|
69
|
+
async set(kv: Record<string, string>): Promise<void>;
|
|
70
|
+
|
|
71
|
+
async set(key: string | Record<string, string>, value?: string): Promise<void> {
|
|
72
|
+
await sendRequired(
|
|
73
|
+
this.client,
|
|
74
|
+
KV.SET_ENDPOINT,
|
|
75
|
+
{
|
|
76
|
+
range: this.rangeKey,
|
|
77
|
+
pairs: isObject(key) ? key : { [key]: value },
|
|
78
|
+
},
|
|
79
|
+
z.unknown(),
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async delete(key: string | string[]): Promise<void> {
|
|
84
|
+
await sendRequired(
|
|
85
|
+
this.client,
|
|
86
|
+
KV.DELETE_ENDPOINT,
|
|
87
|
+
{ range: this.rangeKey, keys: toArray(key) },
|
|
88
|
+
z.unknown(),
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Copyright 2023 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 { TimeRange, toArray } from "@synnaxlabs/x";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
|
|
13
|
+
export const keyZ = z.string().uuid();
|
|
14
|
+
export type Key = z.infer<typeof keyZ>;
|
|
15
|
+
export type Name = string;
|
|
16
|
+
export type Keys = Key[];
|
|
17
|
+
export type Names = Name[];
|
|
18
|
+
export type Params = Key | Name | Keys | Names;
|
|
19
|
+
|
|
20
|
+
export const payloadZ = z.object({
|
|
21
|
+
key: keyZ,
|
|
22
|
+
name: z.string(),
|
|
23
|
+
timeRange: TimeRange.z,
|
|
24
|
+
});
|
|
25
|
+
export type Payload = z.infer<typeof payloadZ>;
|
|
26
|
+
|
|
27
|
+
export const newPayloadZ = payloadZ.extend({
|
|
28
|
+
key: z.string().uuid().optional(),
|
|
29
|
+
});
|
|
30
|
+
export type NewPayload = z.infer<typeof newPayloadZ>;
|
|
31
|
+
|
|
32
|
+
export type ParamAnalsysisResult =
|
|
33
|
+
| {
|
|
34
|
+
single: true;
|
|
35
|
+
variant: "keys";
|
|
36
|
+
normalized: Keys;
|
|
37
|
+
actual: Key;
|
|
38
|
+
}
|
|
39
|
+
| {
|
|
40
|
+
single: true;
|
|
41
|
+
variant: "names";
|
|
42
|
+
normalized: Names;
|
|
43
|
+
actual: Name;
|
|
44
|
+
}
|
|
45
|
+
| {
|
|
46
|
+
single: false;
|
|
47
|
+
variant: "keys";
|
|
48
|
+
normalized: Keys;
|
|
49
|
+
actual: Keys;
|
|
50
|
+
}
|
|
51
|
+
| {
|
|
52
|
+
single: false;
|
|
53
|
+
variant: "names";
|
|
54
|
+
normalized: Names;
|
|
55
|
+
actual: Names;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const analyzeParams = (params: Params): ParamAnalsysisResult => {
|
|
59
|
+
const normal = toArray(params) as Keys | Names;
|
|
60
|
+
if (normal.length === 0) {
|
|
61
|
+
throw new Error("Range params must not be empty");
|
|
62
|
+
}
|
|
63
|
+
const isKey = keyZ.safeParse(normal[0]).success;
|
|
64
|
+
return {
|
|
65
|
+
single: !Array.isArray(params),
|
|
66
|
+
variant: isKey ? "keys" : "names",
|
|
67
|
+
normalized: normal,
|
|
68
|
+
actual: params,
|
|
69
|
+
} as const as ParamAnalsysisResult;
|
|
70
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Copyright 2023 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 { type Series, TimeRange } from "@synnaxlabs/x";
|
|
11
|
+
|
|
12
|
+
import { type cdc } from "@/cdc";
|
|
13
|
+
import { type Key, type Params, type Name } from "@/channel/payload";
|
|
14
|
+
import { type Retriever as ChannelRetriever } from "@/channel/retriever";
|
|
15
|
+
import { QueryError } from "@/errors";
|
|
16
|
+
import { type framer } from "@/framer";
|
|
17
|
+
import { type Alias, type Aliaser } from "@/ranger/alias";
|
|
18
|
+
import { type KV } from "@/ranger/kv";
|
|
19
|
+
|
|
20
|
+
export class Range {
|
|
21
|
+
key: string;
|
|
22
|
+
name: string;
|
|
23
|
+
readonly kv: KV;
|
|
24
|
+
readonly timeRange: TimeRange;
|
|
25
|
+
readonly channels: ChannelRetriever;
|
|
26
|
+
private readonly aliaser: Aliaser;
|
|
27
|
+
private readonly frameClient: framer.Client;
|
|
28
|
+
|
|
29
|
+
constructor(
|
|
30
|
+
name: string,
|
|
31
|
+
timeRange: TimeRange = TimeRange.ZERO,
|
|
32
|
+
key: string,
|
|
33
|
+
_frameClient: framer.Client,
|
|
34
|
+
_kv: KV,
|
|
35
|
+
_aliaser: Aliaser,
|
|
36
|
+
_channels: ChannelRetriever,
|
|
37
|
+
) {
|
|
38
|
+
this.key = key;
|
|
39
|
+
this.name = name;
|
|
40
|
+
this.timeRange = timeRange;
|
|
41
|
+
this.frameClient = _frameClient;
|
|
42
|
+
this.kv = _kv;
|
|
43
|
+
this.aliaser = _aliaser;
|
|
44
|
+
this.channels = _channels;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async setAlias(channel: Key | Name, alias: string): Promise<void> {
|
|
48
|
+
const ch = await this.channels.retrieve(channel);
|
|
49
|
+
if (ch.length === 0) {
|
|
50
|
+
throw new QueryError(`Channel ${channel} does not exist`);
|
|
51
|
+
}
|
|
52
|
+
await this.aliaser.set({ [ch[0].key]: alias });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async deleteAlias(...channels: Key[]): Promise<void> {
|
|
56
|
+
await this.aliaser.delete(channels);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async listAliases(): Promise<Record<Key, string>> {
|
|
60
|
+
return await this.aliaser.list();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async openAliasTracker(): Promise<cdc.Observable<string, Alias>> {
|
|
64
|
+
return await this.aliaser.openChangeTracker();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async read(channel: Key | Name): Promise<Series>;
|
|
68
|
+
|
|
69
|
+
async read(channels: Params): Promise<framer.Frame>;
|
|
70
|
+
|
|
71
|
+
async read(channels: Params): Promise<Series | framer.Frame> {
|
|
72
|
+
return await this.frameClient.read(this.timeRange, channels);
|
|
73
|
+
}
|
|
74
|
+
}
|