@synnaxlabs/client 0.18.0 → 0.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +5 -5
- package/dist/client.cjs +19 -19
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +6611 -8742
- package/dist/client.js.map +1 -1
- package/examples/node/liveStream.js +4 -3
- package/examples/node/package-lock.json +28 -16
- package/examples/node/package.json +1 -1
- package/examples/node/seriesAndFrames.js +64 -0
- package/examples/node/streamWrite.js +1 -1
- package/package.json +4 -4
|
@@ -24,15 +24,16 @@ const read_from = [
|
|
|
24
24
|
"stream_write_example_data_2"
|
|
25
25
|
]
|
|
26
26
|
|
|
27
|
-
const streamer = await client.telem.
|
|
27
|
+
const streamer = await client.telem.openStreamer(read_from);
|
|
28
28
|
|
|
29
29
|
// It's very important that we close the streamer when we're done with it to release
|
|
30
30
|
// network connections and other resources, so we wrap the streaming loop in a try-finally
|
|
31
31
|
// block.
|
|
32
32
|
try {
|
|
33
33
|
// Loop through the frames in the streamer. Each iteration will block until a new
|
|
34
|
-
// frame is available, and then we'll just print
|
|
35
|
-
|
|
34
|
+
// frame is available, and then we'll just print out the last sample for each
|
|
35
|
+
// channel in the frame.
|
|
36
|
+
for await (const frame of streamer) console.log(frame.at(-1));
|
|
36
37
|
} finally {
|
|
37
38
|
streamer.close();
|
|
38
39
|
// Close the client when we're done with it.
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@synnaxlabs/client": "^0.
|
|
12
|
+
"@synnaxlabs/client": "^0.18.1"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"node_modules/@grpc/grpc-js": {
|
|
@@ -3653,23 +3653,35 @@
|
|
|
3653
3653
|
}
|
|
3654
3654
|
},
|
|
3655
3655
|
"node_modules/@synnaxlabs/client": {
|
|
3656
|
-
"version": "0.
|
|
3657
|
-
"resolved": "https://registry.npmjs.org/@synnaxlabs/client/-/client-0.
|
|
3658
|
-
"integrity": "sha512-
|
|
3656
|
+
"version": "0.18.1",
|
|
3657
|
+
"resolved": "https://registry.npmjs.org/@synnaxlabs/client/-/client-0.18.1.tgz",
|
|
3658
|
+
"integrity": "sha512-W8S3DnTqygR7/pT2iE/Prt6YTqdz+XelVC7C0kHNG5UnBjljUJx06axpO+fFPUTbqKpPBY85l20NqHcR7W4PKg==",
|
|
3659
3659
|
"dependencies": {
|
|
3660
|
-
"@synnaxlabs/freighter": "0.9.
|
|
3661
|
-
"@synnaxlabs/x": "0.
|
|
3660
|
+
"@synnaxlabs/freighter": "0.9.3",
|
|
3661
|
+
"@synnaxlabs/x": "0.15.1",
|
|
3662
3662
|
"async-mutex": "^0.4.0",
|
|
3663
3663
|
"zod": "3.22.4"
|
|
3664
3664
|
}
|
|
3665
3665
|
},
|
|
3666
|
+
"node_modules/@synnaxlabs/client/node_modules/@synnaxlabs/x": {
|
|
3667
|
+
"version": "0.15.1",
|
|
3668
|
+
"resolved": "https://registry.npmjs.org/@synnaxlabs/x/-/x-0.15.1.tgz",
|
|
3669
|
+
"integrity": "sha512-fwCXg1xxD+L7tHwSW/DbLWZzfXIDXUinEKks4Vj76N7Ex2UKEAa1NnxhpFXU9IQjefnVFFFOkFvuvyk7bYlWEQ==",
|
|
3670
|
+
"dependencies": {
|
|
3671
|
+
"async-mutex": "^0.4.0",
|
|
3672
|
+
"js-convert-case": "^4.2.0",
|
|
3673
|
+
"nanoid": "^5.0.2",
|
|
3674
|
+
"typescript": "^5.3.3",
|
|
3675
|
+
"zod": "3.22.4"
|
|
3676
|
+
}
|
|
3677
|
+
},
|
|
3666
3678
|
"node_modules/@synnaxlabs/freighter": {
|
|
3667
|
-
"version": "0.9.
|
|
3668
|
-
"resolved": "https://registry.npmjs.org/@synnaxlabs/freighter/-/freighter-0.9.
|
|
3669
|
-
"integrity": "sha512-
|
|
3679
|
+
"version": "0.9.3",
|
|
3680
|
+
"resolved": "https://registry.npmjs.org/@synnaxlabs/freighter/-/freighter-0.9.3.tgz",
|
|
3681
|
+
"integrity": "sha512-H8a4HePVykwlkQMw8yClJ/BpydMDieBD2HHC2bBcvfJKZ3w32uiAqvhqezy14aU2XgNG92hU65IBi2FT6esBng==",
|
|
3670
3682
|
"dependencies": {
|
|
3671
3683
|
"@synnaxlabs/alamos": "0.3.0",
|
|
3672
|
-
"@synnaxlabs/x": "0.
|
|
3684
|
+
"@synnaxlabs/x": "0.15.0",
|
|
3673
3685
|
"js-convert-case": "^4.2.0",
|
|
3674
3686
|
"node-fetch": "2.6.11",
|
|
3675
3687
|
"ws": "^8.15.1",
|
|
@@ -3680,9 +3692,9 @@
|
|
|
3680
3692
|
}
|
|
3681
3693
|
},
|
|
3682
3694
|
"node_modules/@synnaxlabs/x": {
|
|
3683
|
-
"version": "0.
|
|
3684
|
-
"resolved": "https://registry.npmjs.org/@synnaxlabs/x/-/x-0.
|
|
3685
|
-
"integrity": "sha512-
|
|
3695
|
+
"version": "0.15.0",
|
|
3696
|
+
"resolved": "https://registry.npmjs.org/@synnaxlabs/x/-/x-0.15.0.tgz",
|
|
3697
|
+
"integrity": "sha512-baowvPsc0oKeMscKHh/5u0WVRB7J3ylIYzkx8feyP67QkjE8PCQpf0gmdThMGg6r0HwUbubzTcD0N64TNvahWw==",
|
|
3686
3698
|
"dependencies": {
|
|
3687
3699
|
"async-mutex": "^0.4.0",
|
|
3688
3700
|
"js-convert-case": "^4.2.0",
|
|
@@ -3886,9 +3898,9 @@
|
|
|
3886
3898
|
}
|
|
3887
3899
|
},
|
|
3888
3900
|
"node_modules/@types/node": {
|
|
3889
|
-
"version": "20.12.
|
|
3890
|
-
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.
|
|
3891
|
-
"integrity": "sha512-
|
|
3901
|
+
"version": "20.12.4",
|
|
3902
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.4.tgz",
|
|
3903
|
+
"integrity": "sha512-E+Fa9z3wSQpzgYQdYmme5X3OTuejnnTx88A6p6vkkJosR3KBz+HpE3kqNm98VE6cfLFcISx7zW7MsJkH6KwbTw==",
|
|
3892
3904
|
"dependencies": {
|
|
3893
3905
|
"undici-types": "~5.26.4"
|
|
3894
3906
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Series } from "@synnaxlabs/client";
|
|
2
|
+
|
|
3
|
+
// Construct a series from an array of numbers. In this case, the series will
|
|
4
|
+
// automatically be of type float64.
|
|
5
|
+
let series = new Series([1, 2, 3, 4, 5]);
|
|
6
|
+
|
|
7
|
+
// Construct a series from an array of numbers, but this time we specify the type
|
|
8
|
+
// explicitly.
|
|
9
|
+
series = new Series({ data: [1, 2, 3, 4, 5], dataType: "float32" });
|
|
10
|
+
|
|
11
|
+
// Construct a series from an array of strings. In this case, the series will
|
|
12
|
+
// automatically be of type string.
|
|
13
|
+
series = new Series(["apple", "banana", "cherry"]);
|
|
14
|
+
|
|
15
|
+
// Construct a series from a Float32Array. This is the most efficient way to
|
|
16
|
+
// construct a series from a large amount of data.
|
|
17
|
+
series = new Series(new Float32Array([1, 2, 3, 4, 5]));
|
|
18
|
+
|
|
19
|
+
// Construct a series from a JSON object. This is useful when you have a series
|
|
20
|
+
// that has been serialized to JSON.
|
|
21
|
+
series = new Series([{ red: "cherry" }, { yellow: "banana" }, {orange: "orange" }]);
|
|
22
|
+
|
|
23
|
+
series = new Series([1, "a", 3, "b", 5]);
|
|
24
|
+
|
|
25
|
+
series = new Series([1, 2, 3, 4, 5]);
|
|
26
|
+
|
|
27
|
+
console.log(series.at(0)); // 1
|
|
28
|
+
console.log(series.at(-1)); // 5
|
|
29
|
+
|
|
30
|
+
series = new Series([1, 2, 3, 4, 5]);
|
|
31
|
+
// Is it a number? Is it a string? Who knows?
|
|
32
|
+
let v = series.at(0);
|
|
33
|
+
|
|
34
|
+
series = new Series([1, 2, 3, 4, 5]);
|
|
35
|
+
let easierSeries = series.as("number");
|
|
36
|
+
// Now we have a guarantee that this is a series of numbers.
|
|
37
|
+
v = easierSeries.at(0);
|
|
38
|
+
console.log(v);
|
|
39
|
+
|
|
40
|
+
series = new Series({ data: [1, 2, 3, 4, 5], dataType: "int8" });
|
|
41
|
+
const ta = series.data;
|
|
42
|
+
console.log(ta); // Int8Array [ 1, 2, 3, 4, 5 ]
|
|
43
|
+
|
|
44
|
+
series = new Series([1, 2, 3, 4, 5]);
|
|
45
|
+
let jsArray = [...series];
|
|
46
|
+
console.log(jsArray); // [ 1, 2, 3, 4, 5 ]
|
|
47
|
+
const jsArray2 = Array.from(series);
|
|
48
|
+
console.log(jsArray2); // [ 1, 2, 3, 4, 5 ]
|
|
49
|
+
|
|
50
|
+
series = new Series([{ red: "cherry", yellow: "banana", orange: "orange" }]);
|
|
51
|
+
jsArray = [...series];
|
|
52
|
+
console.log(jsArray); // [ { red: 'cherry', yellow: 'banana', orange: 'orange' } ]
|
|
53
|
+
|
|
54
|
+
import { TimeRange, TimeStamp, TimeSpan } from "@synnaxlabs/client";
|
|
55
|
+
|
|
56
|
+
const start = TimeStamp.now();
|
|
57
|
+
|
|
58
|
+
const tr = new TimeRange(start, start.add(TimeSpan.seconds(5)));
|
|
59
|
+
|
|
60
|
+
series = new Series({
|
|
61
|
+
data: [1, 2, 3, 4, 5],
|
|
62
|
+
dataType: "float64",
|
|
63
|
+
timeRange: new TimeRange({ start, end: start.add(TimeSpan.seconds(6)) })
|
|
64
|
+
});
|
|
@@ -48,7 +48,7 @@ const roughRate = Rate.hz(40);
|
|
|
48
48
|
// historical reads every 500 samples.
|
|
49
49
|
const commitInterval = 500;
|
|
50
50
|
|
|
51
|
-
const writer = await client.telem.
|
|
51
|
+
const writer = await client.telem.openWriter({
|
|
52
52
|
start,
|
|
53
53
|
channels: [timeChannel.key, dataChannel1.key, dataChannel2.key]
|
|
54
54
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synnaxlabs/client",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "The Client Library for Synnax",
|
|
7
7
|
"repository": "https://github.com/synnaxlabs/synnax/tree/main/client/ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"async-mutex": "^0.4.0",
|
|
20
20
|
"zod": "3.22.4",
|
|
21
21
|
"@synnaxlabs/freighter": "0.9.3",
|
|
22
|
-
"@synnaxlabs/x": "0.15.
|
|
22
|
+
"@synnaxlabs/x": "0.15.2"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^20.10.5",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"vite": "^5.1.2",
|
|
30
30
|
"vitest": "^1.2.2",
|
|
31
31
|
"@synnaxlabs/tsconfig": "0.0.2",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"@synnaxlabs/vite-plugin": "0.0.1",
|
|
33
|
+
"eslint-config-synnaxlabs": "0.0.1"
|
|
34
34
|
},
|
|
35
35
|
"main": "dist/client.cjs",
|
|
36
36
|
"module": "dist/client.js",
|