@synnaxlabs/client 0.41.0 → 0.42.0
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 +6 -6
- package/dist/access/payload.d.ts +7 -1
- package/dist/access/payload.d.ts.map +1 -1
- package/dist/access/policy/payload.d.ts +182 -142
- package/dist/access/policy/payload.d.ts.map +1 -1
- package/dist/access/policy/retriever.d.ts +25 -22
- package/dist/access/policy/retriever.d.ts.map +1 -1
- package/dist/auth/auth.d.ts +1 -7
- package/dist/auth/auth.d.ts.map +1 -1
- package/dist/channel/client.d.ts +2 -7
- package/dist/channel/client.d.ts.map +1 -1
- package/dist/channel/payload.d.ts +13 -74
- package/dist/channel/payload.d.ts.map +1 -1
- package/dist/channel/retriever.d.ts +5 -31
- package/dist/channel/retriever.d.ts.map +1 -1
- package/dist/channel/writer.d.ts +6 -18
- package/dist/channel/writer.d.ts.map +1 -1
- package/dist/client.cjs +36 -31
- package/dist/client.d.ts +8 -56
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +6486 -3979
- package/dist/connection/checker.d.ts +22 -39
- package/dist/connection/checker.d.ts.map +1 -1
- package/dist/control/client.d.ts.map +1 -1
- package/dist/control/state.d.ts +6 -26
- package/dist/control/state.d.ts.map +1 -1
- package/dist/errors.d.ts +31 -56
- package/dist/errors.d.ts.map +1 -1
- package/dist/framer/adapter.d.ts +4 -0
- package/dist/framer/adapter.d.ts.map +1 -1
- package/dist/framer/client.d.ts +2 -2
- package/dist/framer/client.d.ts.map +1 -1
- package/dist/framer/codec.d.ts +34 -0
- package/dist/framer/codec.d.ts.map +1 -0
- package/dist/framer/codec.spec.d.ts +2 -0
- package/dist/framer/codec.spec.d.ts.map +1 -0
- package/dist/framer/deleter.d.ts +12 -49
- package/dist/framer/deleter.d.ts.map +1 -1
- package/dist/framer/frame.d.ts +26 -88
- package/dist/framer/frame.d.ts.map +1 -1
- package/dist/framer/iterator.d.ts.map +1 -1
- package/dist/framer/streamer.d.ts +69 -11
- package/dist/framer/streamer.d.ts.map +1 -1
- package/dist/framer/writer.d.ts +60 -257
- package/dist/framer/writer.d.ts.map +1 -1
- package/dist/hardware/device/client.d.ts +7 -31
- package/dist/hardware/device/client.d.ts.map +1 -1
- package/dist/hardware/device/payload.d.ts +11 -93
- package/dist/hardware/device/payload.d.ts.map +1 -1
- package/dist/hardware/rack/payload.d.ts +15 -103
- package/dist/hardware/rack/payload.d.ts.map +1 -1
- package/dist/hardware/task/client.d.ts +4 -20
- package/dist/hardware/task/client.d.ts.map +1 -1
- package/dist/hardware/task/payload.d.ts +41 -116
- package/dist/hardware/task/payload.d.ts.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/label/payload.d.ts +1 -9
- package/dist/label/payload.d.ts.map +1 -1
- package/dist/label/writer.d.ts +27 -36
- package/dist/label/writer.d.ts.map +1 -1
- package/dist/ontology/client.d.ts +46 -36
- package/dist/ontology/client.d.ts.map +1 -1
- package/dist/ontology/group/payload.d.ts +1 -7
- package/dist/ontology/group/payload.d.ts.map +1 -1
- package/dist/ontology/payload.d.ts +239 -146
- package/dist/ontology/payload.d.ts.map +1 -1
- package/dist/ranger/client.d.ts +13 -58
- package/dist/ranger/client.d.ts.map +1 -1
- package/dist/ranger/kv.d.ts +7 -49
- package/dist/ranger/kv.d.ts.map +1 -1
- package/dist/ranger/payload.d.ts +21 -99
- package/dist/ranger/payload.d.ts.map +1 -1
- package/dist/ranger/writer.d.ts +35 -88
- package/dist/ranger/writer.d.ts.map +1 -1
- package/dist/testutil/indexedPair.d.ts +5 -0
- package/dist/testutil/indexedPair.d.ts.map +1 -0
- package/dist/testutil/telem.d.ts +3 -0
- package/dist/testutil/telem.d.ts.map +1 -0
- package/dist/transport.d.ts +2 -2
- package/dist/transport.d.ts.map +1 -1
- package/dist/user/payload.d.ts +3 -29
- package/dist/user/payload.d.ts.map +1 -1
- package/dist/user/retriever.d.ts +3 -9
- package/dist/user/retriever.d.ts.map +1 -1
- package/dist/util/decodeJSONString.d.ts.map +1 -1
- package/dist/util/zod.d.ts +1 -1
- package/dist/util/zod.d.ts.map +1 -1
- package/dist/workspace/lineplot/payload.d.ts +10 -26
- package/dist/workspace/lineplot/payload.d.ts.map +1 -1
- package/dist/workspace/log/payload.d.ts +10 -26
- package/dist/workspace/log/payload.d.ts.map +1 -1
- package/dist/workspace/payload.d.ts +14 -40
- package/dist/workspace/payload.d.ts.map +1 -1
- package/dist/workspace/schematic/payload.d.ts +13 -45
- package/dist/workspace/schematic/payload.d.ts.map +1 -1
- package/dist/workspace/table/payload.d.ts +13 -39
- package/dist/workspace/table/payload.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/channel/channel.spec.ts +26 -27
- package/src/channel/client.ts +0 -9
- package/src/channel/payload.ts +22 -5
- package/src/channel/retriever.ts +12 -6
- package/src/client.ts +3 -3
- package/src/control/client.ts +5 -2
- package/src/control/state.ts +8 -3
- package/src/errors.spec.ts +5 -4
- package/src/errors.ts +21 -82
- package/src/framer/adapter.ts +22 -3
- package/src/framer/client.ts +38 -21
- package/src/framer/codec.spec.ts +303 -0
- package/src/framer/codec.ts +396 -0
- package/src/framer/deleter.spec.ts +51 -63
- package/src/framer/frame.ts +16 -5
- package/src/framer/iterator.spec.ts +45 -28
- package/src/framer/iterator.ts +6 -5
- package/src/framer/streamProxy.ts +1 -1
- package/src/framer/streamer.spec.ts +10 -18
- package/src/framer/streamer.ts +138 -22
- package/src/framer/writer.spec.ts +125 -150
- package/src/framer/writer.ts +74 -68
- package/src/hardware/device/payload.ts +3 -3
- package/src/hardware/task/payload.ts +9 -6
- package/src/hardware/task/task.spec.ts +1 -1
- package/src/index.ts +0 -2
- package/src/ontology/group/group.spec.ts +2 -2
- package/src/ontology/payload.ts +3 -3
- package/src/ranger/ranger.spec.ts +9 -7
- package/src/testutil/indexedPair.ts +40 -0
- package/src/testutil/telem.ts +13 -0
- package/src/transport.ts +1 -2
- package/src/util/decodeJSONString.ts +2 -2
- package/src/util/retrieve.spec.ts +1 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
|
-
import { binary, type UnknownRecord } from "@synnaxlabs/x";
|
|
10
|
+
import { binary, type UnknownRecord, unknownRecordZ } from "@synnaxlabs/x";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
13
|
import { keyZ as rackKeyZ } from "@/hardware/rack/payload";
|
|
@@ -19,7 +19,7 @@ export type Key = z.infer<typeof keyZ>;
|
|
|
19
19
|
export const stateZ = z.object({
|
|
20
20
|
key: keyZ,
|
|
21
21
|
variant: z.string(),
|
|
22
|
-
details:
|
|
22
|
+
details: unknownRecordZ.or(z.string().transform(decodeJSONString)),
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
export interface State<Details extends {} = UnknownRecord>
|
|
@@ -35,7 +35,7 @@ export const deviceZ = z.object({
|
|
|
35
35
|
model: z.string(),
|
|
36
36
|
location: z.string(),
|
|
37
37
|
configured: z.boolean().optional(),
|
|
38
|
-
properties:
|
|
38
|
+
properties: unknownRecordZ.or(z.string().transform(decodeJSONString)),
|
|
39
39
|
state: stateZ.optional(),
|
|
40
40
|
});
|
|
41
41
|
|
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
binary,
|
|
12
|
+
type observe,
|
|
13
|
+
type UnknownRecord,
|
|
14
|
+
unknownRecordZ,
|
|
15
|
+
} from "@synnaxlabs/x";
|
|
11
16
|
import { z } from "zod";
|
|
12
17
|
|
|
13
18
|
import { type Key as RackKey } from "@/hardware/rack/payload";
|
|
@@ -28,8 +33,7 @@ export const stateZ = z.object({
|
|
|
28
33
|
task: keyZ,
|
|
29
34
|
variant: statusZ,
|
|
30
35
|
key: z.string().optional(),
|
|
31
|
-
details:
|
|
32
|
-
.record(z.unknown())
|
|
36
|
+
details: unknownRecordZ
|
|
33
37
|
.or(z.string().transform(parseWithoutKeyConversion))
|
|
34
38
|
.or(z.array(z.unknown()))
|
|
35
39
|
.or(z.null()) as z.ZodType<UnknownRecord | undefined>,
|
|
@@ -44,7 +48,7 @@ export const taskZ = z.object({
|
|
|
44
48
|
name: z.string(),
|
|
45
49
|
type: z.string(),
|
|
46
50
|
internal: z.boolean().optional(),
|
|
47
|
-
config:
|
|
51
|
+
config: unknownRecordZ.or(z.string().transform(decodeJSONString)),
|
|
48
52
|
state: stateZ.optional().nullable(),
|
|
49
53
|
snapshot: z.boolean().optional(),
|
|
50
54
|
});
|
|
@@ -74,8 +78,7 @@ export const commandZ = z.object({
|
|
|
74
78
|
task: keyZ,
|
|
75
79
|
type: z.string(),
|
|
76
80
|
key: z.string(),
|
|
77
|
-
args:
|
|
78
|
-
.record(z.unknown())
|
|
81
|
+
args: unknownRecordZ
|
|
79
82
|
.or(z.string().transform(parseWithoutKeyConversion))
|
|
80
83
|
.or(z.array(z.unknown()))
|
|
81
84
|
.or(z.null())
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { describe, expect, it } from "vitest";
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { NotFoundError } from "@/errors";
|
|
13
13
|
import { ontology } from "@/ontology";
|
|
14
14
|
import { newClient } from "@/setupspecs";
|
|
15
15
|
|
|
@@ -40,7 +40,7 @@ describe("Group", () => {
|
|
|
40
40
|
await client.ontology.groups.delete(g.key);
|
|
41
41
|
await expect(
|
|
42
42
|
async () => await client.ontology.retrieve(g.ontologyID),
|
|
43
|
-
).rejects.
|
|
43
|
+
).rejects.toThrowError(NotFoundError);
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
});
|
package/src/ontology/payload.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
|
-
import { type change, type UnknownRecord } from "@synnaxlabs/x";
|
|
10
|
+
import { type change, type UnknownRecord, unknownRecordZ } from "@synnaxlabs/x";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
13
|
import {
|
|
@@ -124,7 +124,7 @@ export interface SchemaField extends z.infer<typeof schemaFieldZ> {}
|
|
|
124
124
|
|
|
125
125
|
export const schemaZ = z.object({
|
|
126
126
|
type: resourceTypeZ,
|
|
127
|
-
fields: z.record(schemaFieldZ),
|
|
127
|
+
fields: z.record(z.string(), schemaFieldZ),
|
|
128
128
|
});
|
|
129
129
|
export interface Schema extends z.infer<typeof schemaZ> {}
|
|
130
130
|
|
|
@@ -133,7 +133,7 @@ export const resourceZ = z
|
|
|
133
133
|
id: ID.z,
|
|
134
134
|
name: z.string(),
|
|
135
135
|
schema: schemaZ.optional().nullable(),
|
|
136
|
-
data:
|
|
136
|
+
data: unknownRecordZ.optional().nullable(),
|
|
137
137
|
})
|
|
138
138
|
.transform((resource) => ({ key: resource.id.toString(), ...resource }));
|
|
139
139
|
export interface Resource<T extends UnknownRecord = UnknownRecord>
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
10
|
import { type change } from "@synnaxlabs/x";
|
|
11
|
-
import { DataType,
|
|
11
|
+
import { DataType, TimeSpan, TimeStamp } from "@synnaxlabs/x/telem";
|
|
12
12
|
import { describe, expect, it } from "vitest";
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { NotFoundError } from "@/errors";
|
|
15
15
|
import { type ranger } from "@/ranger";
|
|
16
16
|
import { newClient } from "@/setupspecs";
|
|
17
17
|
|
|
@@ -74,7 +74,7 @@ describe("Ranger", () => {
|
|
|
74
74
|
});
|
|
75
75
|
await client.ranges.delete(range.key);
|
|
76
76
|
await expect(async () => await client.ranges.retrieve(range.key)).rejects.toThrow(
|
|
77
|
-
|
|
77
|
+
NotFoundError,
|
|
78
78
|
);
|
|
79
79
|
});
|
|
80
80
|
});
|
|
@@ -172,7 +172,9 @@ describe("Ranger", () => {
|
|
|
172
172
|
const val = await rng.kv.get("foo");
|
|
173
173
|
expect(val).toEqual("bar");
|
|
174
174
|
await rng.kv.delete("foo");
|
|
175
|
-
await expect(async () => await rng.kv.get("foo")).rejects.
|
|
175
|
+
await expect(async () => await rng.kv.get("foo")).rejects.toThrowError(
|
|
176
|
+
NotFoundError,
|
|
177
|
+
);
|
|
176
178
|
});
|
|
177
179
|
|
|
178
180
|
it("should set and get multiple keys", async () => {
|
|
@@ -240,7 +242,7 @@ describe("Ranger", () => {
|
|
|
240
242
|
const ch = await client.channels.create({
|
|
241
243
|
name: "My New Channel",
|
|
242
244
|
dataType: DataType.FLOAT32,
|
|
243
|
-
|
|
245
|
+
virtual: true,
|
|
244
246
|
});
|
|
245
247
|
const rng = await client.ranges.create({
|
|
246
248
|
name: "My New One Second Range",
|
|
@@ -256,7 +258,7 @@ describe("Ranger", () => {
|
|
|
256
258
|
const ch = await client.channels.create({
|
|
257
259
|
name: "My New Channel",
|
|
258
260
|
dataType: DataType.FLOAT32,
|
|
259
|
-
|
|
261
|
+
virtual: true,
|
|
260
262
|
});
|
|
261
263
|
const rng = await client.ranges.create({
|
|
262
264
|
name: "My New One Second Range",
|
|
@@ -272,7 +274,7 @@ describe("Ranger", () => {
|
|
|
272
274
|
const ch = await client.channels.create({
|
|
273
275
|
name: "My New Channel",
|
|
274
276
|
dataType: DataType.FLOAT32,
|
|
275
|
-
|
|
277
|
+
virtual: true,
|
|
276
278
|
});
|
|
277
279
|
const rng = await client.ranges.create({
|
|
278
280
|
name: "My New One Second Range",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright 2025 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 { DataType, id } from "@synnaxlabs/x";
|
|
11
|
+
|
|
12
|
+
import { type channel } from "@/channel";
|
|
13
|
+
import type Synnax from "@/client";
|
|
14
|
+
|
|
15
|
+
export const newIndexedPair = async (
|
|
16
|
+
client: Synnax,
|
|
17
|
+
): Promise<[channel.Channel, channel.Channel]> => {
|
|
18
|
+
const index = await client.channels.create({
|
|
19
|
+
leaseholder: 1,
|
|
20
|
+
name: `test-${id.create()}`,
|
|
21
|
+
dataType: DataType.TIMESTAMP,
|
|
22
|
+
isIndex: true,
|
|
23
|
+
});
|
|
24
|
+
const data = await client.channels.create({
|
|
25
|
+
leaseholder: 1,
|
|
26
|
+
name: `test-${id.create()}`,
|
|
27
|
+
dataType: DataType.FLOAT64,
|
|
28
|
+
index: index.key,
|
|
29
|
+
});
|
|
30
|
+
return [index, data];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const newVirtualChannel = async (client: Synnax): Promise<channel.Channel> => {
|
|
34
|
+
const ch = await client.channels.create({
|
|
35
|
+
name: `test-${id.create()}`,
|
|
36
|
+
dataType: DataType.FLOAT64,
|
|
37
|
+
virtual: true,
|
|
38
|
+
});
|
|
39
|
+
return ch;
|
|
40
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright 2025 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 { TimeStamp } from "@synnaxlabs/x";
|
|
11
|
+
|
|
12
|
+
export const secondsLinspace = (start: number, n: number): TimeStamp[] =>
|
|
13
|
+
Array.from({ length: n }, (_, i) => start + i).map((n) => TimeStamp.seconds(n));
|
package/src/transport.ts
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
import {
|
|
11
11
|
HTTPClient,
|
|
12
12
|
type Middleware,
|
|
13
|
-
type StreamClient,
|
|
14
13
|
type UnaryClient,
|
|
15
14
|
unaryWithBreaker,
|
|
16
15
|
WebSocketClient,
|
|
@@ -24,7 +23,7 @@ const baseAPIEndpoint = "/api/v1/";
|
|
|
24
23
|
export class Transport {
|
|
25
24
|
readonly url: URL;
|
|
26
25
|
readonly unary: UnaryClient;
|
|
27
|
-
readonly stream:
|
|
26
|
+
readonly stream: WebSocketClient;
|
|
28
27
|
readonly secure: boolean;
|
|
29
28
|
|
|
30
29
|
constructor(url: URL, breakerCfg: breaker.Config = {}, secure: boolean = false) {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
|
-
import { binary, type UnknownRecord } from "@synnaxlabs/x";
|
|
10
|
+
import { binary, type UnknownRecord, unknownRecordZ } from "@synnaxlabs/x";
|
|
11
11
|
|
|
12
12
|
export const decodeJSONString = (s: string): UnknownRecord =>
|
|
13
|
-
s ? binary.JSON_CODEC.decodeString(s) : {};
|
|
13
|
+
s ? binary.JSON_CODEC.decodeString(s, unknownRecordZ) : {};
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
|
+
import { type Primitive } from "@synnaxlabs/x";
|
|
10
11
|
import { describe, expect, it } from "vitest";
|
|
11
|
-
import { type Primitive } from "zod";
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
14
|
analyzeParams,
|