@synnaxlabs/client 0.38.0 → 0.39.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 +7 -7
- package/dist/access/payload.d.ts +6 -6
- package/dist/access/payload.d.ts.map +1 -1
- package/dist/access/policy/client.d.ts +5 -3
- package/dist/access/policy/client.d.ts.map +1 -1
- package/dist/access/policy/external.d.ts +1 -0
- package/dist/access/policy/external.d.ts.map +1 -1
- package/dist/access/policy/ontology.d.ts +5 -0
- package/dist/access/policy/ontology.d.ts.map +1 -0
- package/dist/access/policy/payload.d.ts +86 -89
- package/dist/access/policy/payload.d.ts.map +1 -1
- package/dist/access/policy/retriever.d.ts +7 -6
- package/dist/access/policy/retriever.d.ts.map +1 -1
- package/dist/access/policy/writer.d.ts +2 -2
- package/dist/access/policy/writer.d.ts.map +1 -1
- package/dist/auth/auth.d.ts +2 -1
- package/dist/auth/auth.d.ts.map +1 -1
- package/dist/channel/client.d.ts +8 -7
- package/dist/channel/client.d.ts.map +1 -1
- package/dist/channel/payload.d.ts +13 -11
- package/dist/channel/payload.d.ts.map +1 -1
- package/dist/channel/retriever.d.ts +9 -6
- package/dist/channel/retriever.d.ts.map +1 -1
- package/dist/channel/writer.d.ts +6 -4
- package/dist/channel/writer.d.ts.map +1 -1
- package/dist/client.cjs +30 -30
- package/dist/client.d.ts +4 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3488 -3500
- package/dist/connection/checker.d.ts +5 -4
- package/dist/connection/checker.d.ts.map +1 -1
- package/dist/control/state.d.ts +10 -8
- package/dist/control/state.d.ts.map +1 -1
- package/dist/errors.d.ts +5 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/framer/adapter.d.ts +14 -15
- package/dist/framer/adapter.d.ts.map +1 -1
- package/dist/framer/client.d.ts +13 -15
- package/dist/framer/client.d.ts.map +1 -1
- package/dist/framer/deleter.d.ts +3 -2
- package/dist/framer/deleter.d.ts.map +1 -1
- package/dist/framer/frame.d.ts +31 -27
- package/dist/framer/frame.d.ts.map +1 -1
- package/dist/framer/iterator.d.ts +4 -5
- package/dist/framer/iterator.d.ts.map +1 -1
- package/dist/framer/streamer.d.ts +5 -6
- package/dist/framer/streamer.d.ts.map +1 -1
- package/dist/framer/writer.d.ts +42 -39
- package/dist/framer/writer.d.ts.map +1 -1
- package/dist/hardware/device/client.d.ts +17 -12
- package/dist/hardware/device/client.d.ts.map +1 -1
- package/dist/hardware/device/payload.d.ts +19 -16
- package/dist/hardware/device/payload.d.ts.map +1 -1
- package/dist/hardware/rack/client.d.ts +15 -15
- package/dist/hardware/rack/client.d.ts.map +1 -1
- package/dist/hardware/rack/payload.d.ts +9 -8
- package/dist/hardware/rack/payload.d.ts.map +1 -1
- package/dist/hardware/task/client.d.ts +38 -29
- package/dist/hardware/task/client.d.ts.map +1 -1
- package/dist/hardware/task/payload.d.ts +58 -53
- package/dist/hardware/task/payload.d.ts.map +1 -1
- package/dist/label/client.d.ts +4 -3
- package/dist/label/client.d.ts.map +1 -1
- package/dist/label/payload.d.ts +4 -4
- package/dist/label/payload.d.ts.map +1 -1
- package/dist/label/retriever.d.ts.map +1 -1
- package/dist/label/writer.d.ts +13 -10
- package/dist/label/writer.d.ts.map +1 -1
- package/dist/ontology/client.d.ts +12 -10
- package/dist/ontology/client.d.ts.map +1 -1
- package/dist/ontology/group/client.d.ts +5 -4
- package/dist/ontology/group/client.d.ts.map +1 -1
- package/dist/ontology/group/group.d.ts +7 -5
- package/dist/ontology/group/group.d.ts.map +1 -1
- package/dist/ontology/group/payload.d.ts +6 -5
- package/dist/ontology/group/payload.d.ts.map +1 -1
- package/dist/ontology/group/writer.d.ts +8 -8
- package/dist/ontology/group/writer.d.ts.map +1 -1
- package/dist/ontology/payload.d.ts +72 -62
- package/dist/ontology/payload.d.ts.map +1 -1
- package/dist/ontology/writer.d.ts.map +1 -1
- package/dist/ranger/alias.d.ts +9 -10
- package/dist/ranger/alias.d.ts.map +1 -1
- package/dist/ranger/client.d.ts +18 -18
- package/dist/ranger/client.d.ts.map +1 -1
- package/dist/ranger/external.d.ts +1 -1
- package/dist/ranger/external.d.ts.map +1 -1
- package/dist/ranger/kv.d.ts +18 -14
- package/dist/ranger/kv.d.ts.map +1 -1
- package/dist/ranger/payload.d.ts +13 -13
- package/dist/ranger/payload.d.ts.map +1 -1
- package/dist/ranger/writer.d.ts +14 -14
- package/dist/ranger/writer.d.ts.map +1 -1
- package/dist/setupspecs.d.ts.map +1 -1
- package/dist/signals/observable.d.ts +3 -1
- package/dist/signals/observable.d.ts.map +1 -1
- package/dist/user/client.d.ts +5 -3
- package/dist/user/client.d.ts.map +1 -1
- package/dist/user/payload.d.ts +7 -6
- package/dist/user/payload.d.ts.map +1 -1
- package/dist/user/retriever.d.ts +2 -1
- package/dist/user/retriever.d.ts.map +1 -1
- package/dist/user/writer.d.ts +2 -2
- package/dist/user/writer.d.ts.map +1 -1
- package/dist/util/decodeJSONString.d.ts +3 -0
- package/dist/util/decodeJSONString.d.ts.map +1 -0
- package/dist/util/parseWithoutKeyConversion.d.ts +3 -0
- package/dist/util/parseWithoutKeyConversion.d.ts.map +1 -0
- package/dist/util/retrieve.d.ts +1 -1
- package/dist/util/retrieve.d.ts.map +1 -1
- package/dist/util/telem.d.ts.map +1 -1
- package/dist/util/zod.d.ts.map +1 -1
- package/dist/workspace/client.d.ts +6 -60
- package/dist/workspace/client.d.ts.map +1 -1
- package/dist/workspace/external.d.ts +3 -0
- package/dist/workspace/external.d.ts.map +1 -0
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/lineplot/client.d.ts +5 -44
- package/dist/workspace/lineplot/client.d.ts.map +1 -1
- package/dist/workspace/lineplot/external.d.ts +3 -0
- package/dist/workspace/lineplot/external.d.ts.map +1 -0
- package/dist/workspace/lineplot/index.d.ts +1 -1
- package/dist/workspace/lineplot/index.d.ts.map +1 -1
- package/dist/workspace/lineplot/payload.d.ts +45 -0
- package/dist/workspace/lineplot/payload.d.ts.map +1 -0
- package/dist/workspace/log/client.d.ts +5 -44
- package/dist/workspace/log/client.d.ts.map +1 -1
- package/dist/workspace/log/external.d.ts +3 -0
- package/dist/workspace/log/external.d.ts.map +1 -0
- package/dist/workspace/log/index.d.ts +1 -1
- package/dist/workspace/log/index.d.ts.map +1 -1
- package/dist/workspace/log/payload.d.ts +45 -0
- package/dist/workspace/log/payload.d.ts.map +1 -0
- package/dist/workspace/payload.d.ts +60 -0
- package/dist/workspace/payload.d.ts.map +1 -0
- package/dist/workspace/schematic/client.d.ts +5 -68
- package/dist/workspace/schematic/client.d.ts.map +1 -1
- package/dist/workspace/schematic/external.d.ts +3 -0
- package/dist/workspace/schematic/external.d.ts.map +1 -0
- package/dist/workspace/schematic/index.d.ts +1 -1
- package/dist/workspace/schematic/index.d.ts.map +1 -1
- package/dist/workspace/schematic/payload.d.ts +71 -0
- package/dist/workspace/schematic/payload.d.ts.map +1 -0
- package/dist/workspace/table/client.d.ts +5 -57
- package/dist/workspace/table/client.d.ts.map +1 -1
- package/dist/workspace/table/external.d.ts +3 -0
- package/dist/workspace/table/external.d.ts.map +1 -0
- package/dist/workspace/table/index.d.ts +1 -1
- package/dist/workspace/table/index.d.ts.map +1 -1
- package/dist/workspace/table/payload.d.ts +60 -0
- package/dist/workspace/table/payload.d.ts.map +1 -0
- package/eslint.config.js +1 -1
- package/examples/node/basicReadWrite.js +27 -27
- package/examples/node/liveStream.js +16 -16
- package/examples/node/seriesAndFrames.js +39 -39
- package/examples/node/streamWrite.js +48 -46
- package/package.json +14 -12
- package/src/access/client.ts +1 -1
- package/src/access/external.ts +1 -1
- package/src/access/index.ts +1 -1
- package/src/access/payload.ts +13 -13
- package/src/access/policy/client.ts +14 -13
- package/src/access/policy/external.ts +2 -1
- package/src/access/policy/index.ts +1 -1
- package/src/access/policy/ontology.ts +17 -0
- package/src/access/policy/payload.ts +8 -20
- package/src/access/policy/policy.spec.ts +17 -17
- package/src/access/policy/retriever.ts +3 -2
- package/src/access/policy/writer.ts +5 -5
- package/src/auth/auth.spec.ts +28 -24
- package/src/auth/auth.ts +8 -12
- package/src/auth/index.ts +1 -1
- package/src/channel/batchRetriever.spec.ts +26 -23
- package/src/channel/channel.spec.ts +1 -1
- package/src/channel/client.ts +24 -24
- package/src/channel/external.ts +1 -1
- package/src/channel/index.ts +1 -1
- package/src/channel/payload.ts +17 -21
- package/src/channel/retriever.ts +21 -22
- package/src/channel/writer.ts +12 -14
- package/src/client.ts +7 -17
- package/src/connection/checker.ts +10 -12
- package/src/connection/connection.spec.ts +18 -6
- package/src/connection/index.ts +1 -1
- package/src/control/client.ts +1 -1
- package/src/control/external.ts +1 -1
- package/src/control/index.ts +1 -1
- package/src/control/state.spec.ts +1 -1
- package/src/control/state.ts +9 -10
- package/src/errors.spec.ts +2 -2
- package/src/errors.ts +9 -1
- package/src/framer/adapter.spec.ts +29 -24
- package/src/framer/adapter.ts +38 -42
- package/src/framer/client.spec.ts +6 -12
- package/src/framer/client.ts +35 -39
- package/src/framer/deleter.spec.ts +1 -1
- package/src/framer/deleter.ts +6 -7
- package/src/framer/external.ts +1 -1
- package/src/framer/frame.spec.ts +1 -1
- package/src/framer/frame.ts +63 -51
- package/src/framer/index.ts +1 -1
- package/src/framer/iterator.spec.ts +1 -1
- package/src/framer/iterator.ts +12 -17
- package/src/framer/streamProxy.ts +2 -2
- package/src/framer/streamer.spec.ts +3 -11
- package/src/framer/streamer.ts +16 -20
- package/src/framer/writer.spec.ts +49 -8
- package/src/framer/writer.ts +40 -32
- package/src/hardware/client.ts +1 -1
- package/src/hardware/device/client.ts +65 -40
- package/src/hardware/device/device.spec.ts +50 -34
- package/src/hardware/device/external.ts +1 -1
- package/src/hardware/device/index.ts +1 -1
- package/src/hardware/device/payload.ts +30 -30
- package/src/hardware/external.ts +1 -1
- package/src/hardware/index.ts +1 -1
- package/src/hardware/rack/client.ts +53 -66
- package/src/hardware/rack/external.ts +1 -1
- package/src/hardware/rack/index.ts +1 -1
- package/src/hardware/rack/payload.ts +10 -19
- package/src/hardware/rack/rack.spec.ts +13 -1
- package/src/hardware/task/client.ts +161 -132
- package/src/hardware/task/external.ts +1 -1
- package/src/hardware/task/index.ts +1 -1
- package/src/hardware/task/payload.ts +50 -69
- package/src/hardware/task/task.spec.ts +99 -82
- package/src/index.ts +1 -1
- package/src/label/client.ts +13 -16
- package/src/label/external.ts +1 -1
- package/src/label/index.ts +1 -1
- package/src/label/label.spec.ts +1 -1
- package/src/label/payload.ts +4 -10
- package/src/label/retriever.ts +4 -8
- package/src/label/writer.ts +9 -16
- package/src/ontology/client.ts +31 -29
- package/src/ontology/external.ts +1 -1
- package/src/ontology/group/client.ts +6 -6
- package/src/ontology/group/external.ts +1 -1
- package/src/ontology/group/group.spec.ts +5 -5
- package/src/ontology/group/group.ts +11 -8
- package/src/ontology/group/index.ts +1 -1
- package/src/ontology/group/payload.ts +12 -36
- package/src/ontology/group/writer.ts +23 -27
- package/src/ontology/index.ts +1 -1
- package/src/ontology/ontology.spec.ts +16 -16
- package/src/ontology/payload.ts +68 -44
- package/src/ontology/writer.ts +17 -24
- package/src/ranger/alias.ts +26 -43
- package/src/ranger/client.ts +34 -41
- package/src/ranger/external.ts +2 -2
- package/src/ranger/index.ts +1 -1
- package/src/ranger/kv.ts +10 -33
- package/src/ranger/payload.ts +15 -37
- package/src/ranger/ranger.spec.ts +2 -3
- package/src/ranger/writer.ts +9 -27
- package/src/setupspecs.ts +1 -1
- package/src/signals/external.ts +1 -1
- package/src/signals/index.ts +1 -1
- package/src/signals/observable.ts +4 -5
- package/src/transport.ts +1 -1
- package/src/user/client.ts +9 -5
- package/src/user/external.ts +1 -1
- package/src/user/index.ts +1 -1
- package/src/user/payload.ts +6 -10
- package/src/user/retriever.ts +2 -2
- package/src/user/user.spec.ts +18 -16
- package/src/user/writer.ts +4 -11
- package/src/util/decodeJSONString.ts +13 -0
- package/src/util/parseWithoutKeyConversion.ts +19 -0
- package/src/util/retrieve.spec.ts +4 -14
- package/src/util/retrieve.ts +3 -13
- package/src/util/telem.ts +2 -2
- package/src/util/zod.ts +1 -1
- package/src/vite-env.d.ts +2 -1
- package/src/workspace/client.ts +39 -57
- package/src/workspace/external.ts +11 -0
- package/src/workspace/index.ts +2 -2
- package/src/workspace/lineplot/client.ts +31 -36
- package/src/workspace/lineplot/external.ts +11 -0
- package/src/workspace/lineplot/index.ts +2 -2
- package/src/workspace/lineplot/linePlot.spec.ts +2 -3
- package/src/workspace/lineplot/payload.ts +32 -0
- package/src/workspace/log/client.ts +34 -39
- package/src/workspace/log/external.ts +11 -0
- package/src/workspace/log/index.ts +2 -2
- package/src/workspace/log/log.spec.ts +6 -19
- package/src/workspace/log/payload.ts +32 -0
- package/src/workspace/payload.ts +36 -0
- package/src/workspace/schematic/client.ts +39 -56
- package/src/workspace/schematic/external.ts +11 -0
- package/src/workspace/schematic/index.ts +2 -2
- package/src/workspace/schematic/payload.ts +37 -0
- package/src/workspace/schematic/schematic.spec.ts +16 -7
- package/src/workspace/table/client.ts +36 -50
- package/src/workspace/table/external.ts +11 -0
- package/src/workspace/table/index.ts +2 -2
- package/src/workspace/table/payload.ts +36 -0
- package/src/workspace/table/table.spec.ts +1 -1
- package/src/workspace/workspace.spec.ts +2 -3
- package/vite.config.ts +1 -1
- package/dist/channel/creator.d.ts +0 -9
- package/dist/channel/creator.d.ts.map +0 -1
- package/src/channel/creator.ts +0 -37
package/src/channel/payload.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -10,25 +10,25 @@
|
|
|
10
10
|
import { DataType, Rate } from "@synnaxlabs/x/telem";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
|
-
import { ontology } from "@/ontology";
|
|
14
13
|
import { nullableArrayZ } from "@/util/zod";
|
|
15
14
|
|
|
16
15
|
export const keyZ = z.number();
|
|
17
|
-
export type Key =
|
|
18
|
-
export type Keys =
|
|
19
|
-
export
|
|
20
|
-
export type
|
|
16
|
+
export type Key = z.infer<typeof keyZ>;
|
|
17
|
+
export type Keys = Key[];
|
|
18
|
+
export const nameZ = z.string();
|
|
19
|
+
export type Name = z.infer<typeof nameZ>;
|
|
20
|
+
export type Names = Name[];
|
|
21
21
|
export type KeyOrName = Key | Name;
|
|
22
22
|
export type KeysOrNames = Keys | Names;
|
|
23
23
|
export type Params = Key | Name | Keys | Names;
|
|
24
24
|
|
|
25
|
-
export const
|
|
26
|
-
name:
|
|
27
|
-
key:
|
|
25
|
+
export const channelZ = z.object({
|
|
26
|
+
name: nameZ,
|
|
27
|
+
key: keyZ,
|
|
28
28
|
rate: Rate.z,
|
|
29
29
|
dataType: DataType.z,
|
|
30
30
|
leaseholder: z.number(),
|
|
31
|
-
index:
|
|
31
|
+
index: keyZ,
|
|
32
32
|
isIndex: z.boolean(),
|
|
33
33
|
internal: z.boolean(),
|
|
34
34
|
virtual: z.boolean(),
|
|
@@ -36,13 +36,12 @@ export const payload = z.object({
|
|
|
36
36
|
expression: z.string().default(""),
|
|
37
37
|
requires: nullableArrayZ(keyZ),
|
|
38
38
|
});
|
|
39
|
+
export interface Payload extends z.infer<typeof channelZ> {}
|
|
39
40
|
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
export const newPayload = payload.extend({
|
|
43
|
-
key: z.number().optional(),
|
|
41
|
+
export const newZ = channelZ.extend({
|
|
42
|
+
key: keyZ.optional(),
|
|
44
43
|
leaseholder: z.number().optional(),
|
|
45
|
-
index:
|
|
44
|
+
index: keyZ.optional(),
|
|
46
45
|
rate: Rate.z.optional().default(0),
|
|
47
46
|
isIndex: z.boolean().optional(),
|
|
48
47
|
internal: z.boolean().optional().default(false),
|
|
@@ -50,10 +49,7 @@ export const newPayload = payload.extend({
|
|
|
50
49
|
expression: z.string().optional().default(""),
|
|
51
50
|
requires: nullableArrayZ(keyZ).optional().default([]),
|
|
52
51
|
});
|
|
52
|
+
export interface New extends z.input<typeof newZ> {}
|
|
53
53
|
|
|
54
|
-
export
|
|
55
|
-
|
|
56
|
-
export const ONTOLOGY_TYPE: ontology.ResourceType = "channel";
|
|
57
|
-
|
|
58
|
-
export const ontologyID = (key: Key): ontology.ID =>
|
|
59
|
-
new ontology.ID({ type: ONTOLOGY_TYPE, key: key.toString() });
|
|
54
|
+
export const ONTOLOGY_TYPE = "channel";
|
|
55
|
+
export type OntologyType = typeof ONTOLOGY_TYPE;
|
package/src/channel/retriever.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -6,28 +6,33 @@
|
|
|
6
6
|
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
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 UnaryClient } from "@synnaxlabs/freighter";
|
|
10
11
|
import { debounce } from "@synnaxlabs/x/debounce";
|
|
11
12
|
import { DataType } from "@synnaxlabs/x/telem";
|
|
12
13
|
import { Mutex } from "async-mutex";
|
|
13
14
|
import { z } from "zod";
|
|
14
15
|
|
|
15
16
|
import {
|
|
17
|
+
channelZ,
|
|
16
18
|
type Key,
|
|
17
19
|
type KeyOrName,
|
|
18
20
|
type Keys,
|
|
19
21
|
type KeysOrNames,
|
|
22
|
+
keyZ,
|
|
20
23
|
type Params,
|
|
21
24
|
type Payload,
|
|
22
|
-
payload,
|
|
23
25
|
} from "@/channel/payload";
|
|
24
26
|
import { QueryError } from "@/errors";
|
|
25
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
analyzeParams as analyzeParameters,
|
|
29
|
+
type ParamAnalysisResult,
|
|
30
|
+
} from "@/util/retrieve";
|
|
26
31
|
import { nullableArrayZ } from "@/util/zod";
|
|
27
32
|
|
|
28
33
|
const reqZ = z.object({
|
|
29
34
|
leaseholder: z.number().optional(),
|
|
30
|
-
keys:
|
|
35
|
+
keys: keyZ.array().optional(),
|
|
31
36
|
names: z.string().array().optional(),
|
|
32
37
|
search: z.string().optional(),
|
|
33
38
|
rangeKey: z.string().optional(),
|
|
@@ -39,23 +44,17 @@ const reqZ = z.object({
|
|
|
39
44
|
isIndex: z.boolean().optional(),
|
|
40
45
|
internal: z.boolean().optional(),
|
|
41
46
|
});
|
|
47
|
+
interface Request extends z.input<typeof reqZ> {}
|
|
42
48
|
|
|
43
|
-
|
|
49
|
+
export interface RetrieveOptions extends Omit<Request, "keys" | "names" | "search"> {}
|
|
50
|
+
export interface PageOptions extends Omit<RetrieveOptions, "offset" | "limit"> {}
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
export type PageOptions = Omit<RetrieveOptions, "offset" | "limit">;
|
|
52
|
+
const resZ = z.object({ channels: nullableArrayZ(channelZ) });
|
|
47
53
|
|
|
48
|
-
const
|
|
49
|
-
channels: nullableArrayZ(payload),
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
export const analyzeChannelParams = (
|
|
54
|
+
export const analyzeParams = (
|
|
53
55
|
channels: Params,
|
|
54
56
|
): ParamAnalysisResult<KeyOrName, { number: "keys"; string: "names" }> =>
|
|
55
|
-
|
|
56
|
-
number: "keys",
|
|
57
|
-
string: "names",
|
|
58
|
-
});
|
|
57
|
+
analyzeParameters(channels, { number: "keys", string: "names" });
|
|
59
58
|
|
|
60
59
|
export interface Retriever {
|
|
61
60
|
retrieve: (channels: Params, opts?: RetrieveOptions) => Promise<Payload[]>;
|
|
@@ -76,7 +75,7 @@ export class ClusterRetriever implements Retriever {
|
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
async retrieve(channels: Params, options?: RetrieveOptions): Promise<Payload[]> {
|
|
79
|
-
const res =
|
|
78
|
+
const res = analyzeParams(channels);
|
|
80
79
|
const { variant } = res;
|
|
81
80
|
let { normalized } = res;
|
|
82
81
|
if (variant === "keys" && (normalized as Key[]).indexOf(0) !== -1)
|
|
@@ -121,7 +120,7 @@ export class CacheRetriever implements Retriever {
|
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
async retrieve(channels: Params, options?: RetrieveOptions): Promise<Payload[]> {
|
|
124
|
-
const { normalized } =
|
|
123
|
+
const { normalized } = analyzeParameters<string | number>(channels, {
|
|
125
124
|
string: "names",
|
|
126
125
|
number: "keys",
|
|
127
126
|
});
|
|
@@ -139,7 +138,7 @@ export class CacheRetriever implements Retriever {
|
|
|
139
138
|
}
|
|
140
139
|
|
|
141
140
|
delete(channels: Params): void {
|
|
142
|
-
const { variant, normalized } =
|
|
141
|
+
const { variant, normalized } = analyzeParams(channels);
|
|
143
142
|
if (variant === "names")
|
|
144
143
|
(normalized as string[]).forEach((name) => {
|
|
145
144
|
const keys = this.namesToKeys.get(name);
|
|
@@ -234,7 +233,7 @@ export class DebouncedBatchRetriever implements Retriever {
|
|
|
234
233
|
}
|
|
235
234
|
|
|
236
235
|
async retrieve(channels: Params): Promise<Payload[]> {
|
|
237
|
-
const { normalized, variant } =
|
|
236
|
+
const { normalized, variant } = analyzeParams(channels);
|
|
238
237
|
// Bypass on name fetches for now.
|
|
239
238
|
if (variant === "names") return await this.wrapped.retrieve(normalized);
|
|
240
239
|
|
|
@@ -269,7 +268,7 @@ export const retrieveRequired = async (
|
|
|
269
268
|
r: Retriever,
|
|
270
269
|
channels: Params,
|
|
271
270
|
): Promise<Payload[]> => {
|
|
272
|
-
const { normalized } =
|
|
271
|
+
const { normalized } = analyzeParams(channels);
|
|
273
272
|
const results = await r.retrieve(normalized);
|
|
274
273
|
const notFound: KeyOrName[] = [];
|
|
275
274
|
normalized.forEach((v) => {
|
package/src/channel/writer.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -11,36 +11,34 @@ import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
|
+
channelZ,
|
|
14
15
|
type Key,
|
|
15
16
|
keyZ,
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
nameZ,
|
|
18
|
+
type New,
|
|
19
|
+
newZ,
|
|
18
20
|
type Payload,
|
|
19
|
-
payload,
|
|
20
21
|
} from "@/channel/payload";
|
|
21
22
|
import { type CacheRetriever } from "@/channel/retriever";
|
|
22
23
|
|
|
23
|
-
const createReqZ = z.object({ channels:
|
|
24
|
-
const createResZ = z.object({ channels:
|
|
24
|
+
const createReqZ = z.object({ channels: newZ.array() });
|
|
25
|
+
const createResZ = z.object({ channels: channelZ.array() });
|
|
25
26
|
|
|
26
27
|
const deleteReqZ = z.object({
|
|
27
28
|
keys: keyZ.array().optional(),
|
|
28
|
-
names:
|
|
29
|
+
names: nameZ.array().optional(),
|
|
29
30
|
});
|
|
30
31
|
const deleteResZ = z.object({});
|
|
31
32
|
|
|
32
|
-
const renameReqZ = z.object({
|
|
33
|
-
keys: keyZ.array(),
|
|
34
|
-
names: z.string().array(),
|
|
35
|
-
});
|
|
33
|
+
const renameReqZ = z.object({ keys: keyZ.array(), names: nameZ.array() });
|
|
36
34
|
const renameResZ = z.object({});
|
|
37
35
|
|
|
38
36
|
const CREATE_ENDPOINT = "/channel/create";
|
|
39
37
|
const DELETE_ENDPOINT = "/channel/delete";
|
|
40
38
|
const RENAME_ENDPOINT = "/channel/rename";
|
|
41
39
|
|
|
42
|
-
export
|
|
43
|
-
export
|
|
40
|
+
export interface DeleteProps extends z.input<typeof deleteReqZ> {}
|
|
41
|
+
export interface RenameProps extends z.input<typeof renameReqZ> {}
|
|
44
42
|
|
|
45
43
|
export class Writer {
|
|
46
44
|
private readonly client: UnaryClient;
|
|
@@ -51,7 +49,7 @@ export class Writer {
|
|
|
51
49
|
this.cache = cache;
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
async create(channels:
|
|
52
|
+
async create(channels: New[]): Promise<Payload[]> {
|
|
55
53
|
const { channels: created } = await sendRequired<
|
|
56
54
|
typeof createReqZ,
|
|
57
55
|
typeof createResZ
|
package/src/client.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -31,20 +31,10 @@ import { user } from "@/user";
|
|
|
31
31
|
import { workspace } from "@/workspace";
|
|
32
32
|
|
|
33
33
|
export const synnaxPropsZ = z.object({
|
|
34
|
-
host: z
|
|
35
|
-
.string({
|
|
36
|
-
required_error: "Host is required",
|
|
37
|
-
})
|
|
38
|
-
.min(1, "Host is required"),
|
|
34
|
+
host: z.string({ required_error: "Host is required" }).min(1, "Host is required"),
|
|
39
35
|
port: z
|
|
40
|
-
.number({
|
|
41
|
-
|
|
42
|
-
})
|
|
43
|
-
.or(
|
|
44
|
-
z.string({
|
|
45
|
-
required_error: "Port is required",
|
|
46
|
-
}),
|
|
47
|
-
),
|
|
36
|
+
.number({ required_error: "Port is required" })
|
|
37
|
+
.or(z.string({ required_error: "Port is required" })),
|
|
48
38
|
username: z.string().min(1, "Username is required"),
|
|
49
39
|
password: z.string().min(1, "Password is required"),
|
|
50
40
|
connectivityPollFrequency: TimeSpan.z.default(TimeSpan.seconds(30)),
|
|
@@ -53,8 +43,8 @@ export const synnaxPropsZ = z.object({
|
|
|
53
43
|
retry: breaker.breakerConfig.optional(),
|
|
54
44
|
});
|
|
55
45
|
|
|
56
|
-
export
|
|
57
|
-
export
|
|
46
|
+
export interface SynnaxProps extends z.input<typeof synnaxPropsZ> {}
|
|
47
|
+
export interface ParsedSynnaxProps extends z.output<typeof synnaxPropsZ> {}
|
|
58
48
|
|
|
59
49
|
/**
|
|
60
50
|
* Client to perform operations against a Synnax cluster.
|
|
@@ -161,7 +151,7 @@ export default class Synnax extends framer.Client {
|
|
|
161
151
|
this.ontology,
|
|
162
152
|
this.ranges,
|
|
163
153
|
);
|
|
164
|
-
const racks = new rack.Client(this.transport.unary,
|
|
154
|
+
const racks = new rack.Client(this.transport.unary, tasks);
|
|
165
155
|
this.hardware = new hardware.Client(tasks, racks, devices);
|
|
166
156
|
}
|
|
167
157
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -12,12 +12,11 @@ import { migrate } from "@synnaxlabs/x";
|
|
|
12
12
|
import { TimeSpan } from "@synnaxlabs/x/telem";
|
|
13
13
|
import { z } from "zod";
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
export
|
|
17
|
-
export type Status = z.infer<typeof status>;
|
|
15
|
+
export const statusZ = z.enum(["disconnected", "connecting", "connected", "failed"]);
|
|
16
|
+
export type Status = z.infer<typeof statusZ>;
|
|
18
17
|
|
|
19
|
-
export const
|
|
20
|
-
status,
|
|
18
|
+
export const stateZ = z.object({
|
|
19
|
+
status: statusZ,
|
|
21
20
|
error: z.instanceof(Error).optional(),
|
|
22
21
|
message: z.string().optional(),
|
|
23
22
|
clusterKey: z.string(),
|
|
@@ -25,8 +24,7 @@ export const state = z.object({
|
|
|
25
24
|
clientServerCompatible: z.boolean(),
|
|
26
25
|
nodeVersion: z.string().optional(),
|
|
27
26
|
});
|
|
28
|
-
|
|
29
|
-
export type State = z.infer<typeof state>;
|
|
27
|
+
export interface State extends z.infer<typeof stateZ> {}
|
|
30
28
|
|
|
31
29
|
const responseZ = z.object({
|
|
32
30
|
clusterKey: z.string(),
|
|
@@ -42,7 +40,7 @@ const DEFAULT: State = {
|
|
|
42
40
|
clientVersion: __VERSION__,
|
|
43
41
|
};
|
|
44
42
|
|
|
45
|
-
const
|
|
43
|
+
const createWarning = (
|
|
46
44
|
nodeVersion: string | null,
|
|
47
45
|
clientVersion: string,
|
|
48
46
|
clientIsNewer: boolean,
|
|
@@ -64,7 +62,7 @@ export class Checker {
|
|
|
64
62
|
private interval?: NodeJS.Timeout;
|
|
65
63
|
private readonly clientVersion: string;
|
|
66
64
|
private readonly onChangeHandlers: Array<(state: State) => void> = [];
|
|
67
|
-
static readonly connectionStateZ =
|
|
65
|
+
static readonly connectionStateZ = stateZ;
|
|
68
66
|
private versionWarned = false;
|
|
69
67
|
|
|
70
68
|
/**
|
|
@@ -112,7 +110,7 @@ export class Checker {
|
|
|
112
110
|
if (nodeVersion == null) {
|
|
113
111
|
this._state.clientServerCompatible = false;
|
|
114
112
|
if (!warned) {
|
|
115
|
-
console.warn(
|
|
113
|
+
console.warn(createWarning(null, clientVersion, true));
|
|
116
114
|
this.versionWarned = true;
|
|
117
115
|
}
|
|
118
116
|
} else if (
|
|
@@ -125,7 +123,7 @@ export class Checker {
|
|
|
125
123
|
this._state.clientServerCompatible = false;
|
|
126
124
|
if (!warned) {
|
|
127
125
|
console.warn(
|
|
128
|
-
|
|
126
|
+
createWarning(
|
|
129
127
|
nodeVersion,
|
|
130
128
|
clientVersion,
|
|
131
129
|
migrate.semVerNewer(clientVersion, nodeVersion),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -12,7 +12,7 @@ import { describe, expect, it } from "vitest";
|
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
14
14
|
import { auth } from "@/auth";
|
|
15
|
-
import {
|
|
15
|
+
import { connection } from "@/connection";
|
|
16
16
|
import { HOST, PORT } from "@/setupspecs";
|
|
17
17
|
import { Transport } from "@/transport";
|
|
18
18
|
|
|
@@ -24,7 +24,11 @@ describe("connectivity", () => {
|
|
|
24
24
|
password: "seldon",
|
|
25
25
|
});
|
|
26
26
|
transport.use(client.middleware());
|
|
27
|
-
const connectivity = new Checker(
|
|
27
|
+
const connectivity = new connection.Checker(
|
|
28
|
+
transport.unary,
|
|
29
|
+
undefined,
|
|
30
|
+
__VERSION__,
|
|
31
|
+
);
|
|
28
32
|
const state = await connectivity.check();
|
|
29
33
|
expect(state.status).toEqual("connected");
|
|
30
34
|
expect(z.string().uuid().safeParse(state.clusterKey).success).toBe(true);
|
|
@@ -37,7 +41,11 @@ describe("connectivity", () => {
|
|
|
37
41
|
password: "seldon",
|
|
38
42
|
});
|
|
39
43
|
transport.use(client.middleware());
|
|
40
|
-
const connectivity = new Checker(
|
|
44
|
+
const connectivity = new connection.Checker(
|
|
45
|
+
transport.unary,
|
|
46
|
+
undefined,
|
|
47
|
+
__VERSION__,
|
|
48
|
+
);
|
|
41
49
|
const state = await connectivity.check();
|
|
42
50
|
expect(state.clientServerCompatible).toBe(true);
|
|
43
51
|
expect(state.clientVersion).toBe(__VERSION__);
|
|
@@ -49,7 +57,11 @@ describe("connectivity", () => {
|
|
|
49
57
|
password: "seldon",
|
|
50
58
|
});
|
|
51
59
|
transport.use(client.middleware());
|
|
52
|
-
const connectivity = new Checker(
|
|
60
|
+
const connectivity = new connection.Checker(
|
|
61
|
+
transport.unary,
|
|
62
|
+
undefined,
|
|
63
|
+
"50000.0.0",
|
|
64
|
+
);
|
|
53
65
|
const state = await connectivity.check();
|
|
54
66
|
expect(state.clientServerCompatible).toBe(false);
|
|
55
67
|
expect(state.clientVersion).toBe("50000.0.0");
|
|
@@ -61,7 +73,7 @@ describe("connectivity", () => {
|
|
|
61
73
|
password: "seldon",
|
|
62
74
|
});
|
|
63
75
|
transport.use(client.middleware());
|
|
64
|
-
const connectivity = new Checker(transport.unary, undefined, "0.0.0");
|
|
76
|
+
const connectivity = new connection.Checker(transport.unary, undefined, "0.0.0");
|
|
65
77
|
const state = await connectivity.check();
|
|
66
78
|
expect(state.clientServerCompatible).toBe(false);
|
|
67
79
|
expect(state.clientVersion).toBe("0.0.0");
|
package/src/connection/index.ts
CHANGED
package/src/control/client.ts
CHANGED
package/src/control/external.ts
CHANGED
package/src/control/index.ts
CHANGED
package/src/control/state.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -12,15 +12,14 @@ import { binary } from "@synnaxlabs/x/binary";
|
|
|
12
12
|
import { type observe } from "@synnaxlabs/x/observe";
|
|
13
13
|
import { z } from "zod";
|
|
14
14
|
|
|
15
|
-
import { type
|
|
15
|
+
import { type channel } from "@/channel";
|
|
16
16
|
import { framer } from "@/framer";
|
|
17
|
-
import { type Streamer as FrameStreamer } from "@/framer/streamer";
|
|
18
17
|
|
|
19
|
-
export
|
|
18
|
+
export interface Authority extends control.Authority {}
|
|
20
19
|
export const Authority = control.Authority;
|
|
21
|
-
export type Transfer = control.Transfer<
|
|
22
|
-
export
|
|
23
|
-
export
|
|
20
|
+
export type Transfer = control.Transfer<channel.Key>;
|
|
21
|
+
export interface State extends control.State<channel.Key> {}
|
|
22
|
+
export interface Subject extends control.Subject {}
|
|
24
23
|
export const stateZ = control.stateZ(z.number());
|
|
25
24
|
|
|
26
25
|
export const transferString = (t: Transfer): string => {
|
|
@@ -35,17 +34,17 @@ export const transferString = (t: Transfer): string => {
|
|
|
35
34
|
};
|
|
36
35
|
|
|
37
36
|
interface Update {
|
|
38
|
-
transfers: control.Transfer<
|
|
37
|
+
transfers: control.Transfer<channel.Key>[];
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
export class StateTracker
|
|
42
41
|
extends framer.ObservableStreamer<Transfer[]>
|
|
43
42
|
implements observe.ObservableAsyncCloseable<Transfer[]>
|
|
44
43
|
{
|
|
45
|
-
readonly states: Map<
|
|
44
|
+
readonly states: Map<channel.Key, State>;
|
|
46
45
|
private readonly codec: binary.Codec;
|
|
47
46
|
|
|
48
|
-
constructor(streamer:
|
|
47
|
+
constructor(streamer: framer.Streamer) {
|
|
49
48
|
super(streamer, (frame) => {
|
|
50
49
|
const update: Update = this.codec.decode(frame.series[0].buffer);
|
|
51
50
|
this.merge(update);
|
package/src/errors.spec.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -55,7 +55,7 @@ const client = newClient();
|
|
|
55
55
|
test("client", async () => {
|
|
56
56
|
expect.assertions(2);
|
|
57
57
|
try {
|
|
58
|
-
await client.channels.retrieve(id.
|
|
58
|
+
await client.channels.retrieve(id.create());
|
|
59
59
|
} catch (e) {
|
|
60
60
|
expect(NotFoundError.matches(e)).toBe(true);
|
|
61
61
|
}
|
package/src/errors.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -64,6 +64,12 @@ export class InvalidTokenError extends AuthError {
|
|
|
64
64
|
static readonly matches = errorMatcher(InvalidTokenError.TYPE);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
export class ExpiredTokenError extends AuthError {
|
|
68
|
+
static readonly TYPE = `${AuthError.TYPE}.expired-token`;
|
|
69
|
+
type = ExpiredTokenError.TYPE;
|
|
70
|
+
static readonly matches = errorMatcher(ExpiredTokenError.TYPE);
|
|
71
|
+
}
|
|
72
|
+
|
|
67
73
|
/**
|
|
68
74
|
* UnexpectedError is raised when an unexpected error occurs.
|
|
69
75
|
*/
|
|
@@ -154,6 +160,8 @@ const decode = (payload: ErrorPayload): Error | null => {
|
|
|
154
160
|
if (payload.type.startsWith(AuthError.TYPE)) {
|
|
155
161
|
if (payload.type.startsWith(InvalidTokenError.TYPE))
|
|
156
162
|
return new InvalidTokenError(payload.data);
|
|
163
|
+
if (payload.type.startsWith(ExpiredTokenError.TYPE))
|
|
164
|
+
return new ExpiredTokenError(payload.data);
|
|
157
165
|
return new AuthError(payload.data);
|
|
158
166
|
}
|
|
159
167
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -11,7 +11,7 @@ import { DataType, Series, TimeStamp } from "@synnaxlabs/x/telem";
|
|
|
11
11
|
import { beforeAll, describe, expect, it } from "vitest";
|
|
12
12
|
|
|
13
13
|
import { type channel } from "@/channel";
|
|
14
|
-
import {
|
|
14
|
+
import { WriteAdapter } from "@/framer/adapter";
|
|
15
15
|
import { Frame } from "@/index";
|
|
16
16
|
import { newClient } from "@/setupspecs";
|
|
17
17
|
|
|
@@ -20,7 +20,7 @@ const client = newClient();
|
|
|
20
20
|
describe("WriteFrameAdapter", () => {
|
|
21
21
|
let timeCh: channel.Channel;
|
|
22
22
|
let dataCh: channel.Channel;
|
|
23
|
-
let adapter:
|
|
23
|
+
let adapter: WriteAdapter;
|
|
24
24
|
|
|
25
25
|
beforeAll(async () => {
|
|
26
26
|
timeCh = await client.channels.create({
|
|
@@ -34,7 +34,7 @@ describe("WriteFrameAdapter", () => {
|
|
|
34
34
|
index: timeCh.key,
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
adapter = await
|
|
37
|
+
adapter = await WriteAdapter.open(client.channels.retriever, [
|
|
38
38
|
timeCh.key,
|
|
39
39
|
dataCh.key,
|
|
40
40
|
]);
|
|
@@ -42,10 +42,7 @@ describe("WriteFrameAdapter", () => {
|
|
|
42
42
|
|
|
43
43
|
it("should correctly adapt a record of keys to single values", async () => {
|
|
44
44
|
const ts = TimeStamp.now().valueOf();
|
|
45
|
-
const res = await adapter.adapt({
|
|
46
|
-
[timeCh.key]: ts,
|
|
47
|
-
[dataCh.key]: 1,
|
|
48
|
-
});
|
|
45
|
+
const res = await adapter.adapt({ [timeCh.key]: ts, [dataCh.key]: 1 });
|
|
49
46
|
expect(res.columns).toHaveLength(2);
|
|
50
47
|
expect(res.series).toHaveLength(2);
|
|
51
48
|
expect(res.get(timeCh.key)).toHaveLength(1);
|
|
@@ -56,10 +53,7 @@ describe("WriteFrameAdapter", () => {
|
|
|
56
53
|
|
|
57
54
|
it("should correctly adapt a record of names to single values", async () => {
|
|
58
55
|
const ts = TimeStamp.now().valueOf();
|
|
59
|
-
const res2 = await adapter.adapt({
|
|
60
|
-
[timeCh.name]: ts,
|
|
61
|
-
[dataCh.name]: 1,
|
|
62
|
-
});
|
|
56
|
+
const res2 = await adapter.adapt({ [timeCh.name]: ts, [dataCh.name]: 1 });
|
|
63
57
|
expect(res2.columns).toHaveLength(2);
|
|
64
58
|
expect(res2.series).toHaveLength(2);
|
|
65
59
|
expect(res2.get(timeCh.key)).toHaveLength(1);
|
|
@@ -103,10 +97,7 @@ describe("WriteFrameAdapter", () => {
|
|
|
103
97
|
|
|
104
98
|
it("should not modify a frame keyed by key", async () => {
|
|
105
99
|
const ts = TimeStamp.now().valueOf();
|
|
106
|
-
const fr = new Frame({
|
|
107
|
-
[timeCh.key]: new Series(ts),
|
|
108
|
-
[dataCh.key]: new Series(1),
|
|
109
|
-
});
|
|
100
|
+
const fr = new Frame({ [timeCh.key]: new Series(ts), [dataCh.key]: new Series(1) });
|
|
110
101
|
const res = await adapter.adapt(fr);
|
|
111
102
|
expect(res.columns).toHaveLength(2);
|
|
112
103
|
expect(res.series).toHaveLength(2);
|
|
@@ -131,7 +122,7 @@ describe("WriteFrameAdapter", () => {
|
|
|
131
122
|
dataType: DataType.JSON,
|
|
132
123
|
virtual: true,
|
|
133
124
|
});
|
|
134
|
-
const adapter = await
|
|
125
|
+
const adapter = await WriteAdapter.open(client.channels.retriever, [
|
|
135
126
|
jsonChannel.key,
|
|
136
127
|
]);
|
|
137
128
|
const res = await adapter.adapt(jsonChannel.name, [{ dog: "blue" }]);
|
|
@@ -147,7 +138,7 @@ describe("WriteFrameAdapter", () => {
|
|
|
147
138
|
dataType: DataType.JSON,
|
|
148
139
|
virtual: true,
|
|
149
140
|
});
|
|
150
|
-
const adapter = await
|
|
141
|
+
const adapter = await WriteAdapter.open(client.channels.retriever, [
|
|
151
142
|
jsonChannel.key,
|
|
152
143
|
]);
|
|
153
144
|
const res = await adapter.adapt(jsonChannel.name, new Series([{ dog: "blue" }]));
|
|
@@ -157,12 +148,26 @@ describe("WriteFrameAdapter", () => {
|
|
|
157
148
|
expect(res.get(jsonChannel.key).at(0)).toEqual({ dog: "blue" });
|
|
158
149
|
});
|
|
159
150
|
|
|
160
|
-
it("should correctly adapt
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
151
|
+
it("should correctly adapt a numeric value to a BigInt keyed by key", async () => {
|
|
152
|
+
const bigIntCh = await client.channels.create({
|
|
153
|
+
name: `bigint-${Math.random()}-${TimeStamp.now().toString()}`,
|
|
154
|
+
dataType: DataType.INT64,
|
|
155
|
+
virtual: true,
|
|
156
|
+
});
|
|
157
|
+
const res = await adapter.adapt({
|
|
158
|
+
[bigIntCh.key]: 12,
|
|
159
|
+
});
|
|
160
|
+
expect(res.get(bigIntCh.key).at(0)).toEqual(12n);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe("adaptObjectKeys", () => {
|
|
164
|
+
it("should correctly adapt generic object keys", async () => {
|
|
165
|
+
const res = await adapter.adaptObjectKeys({
|
|
166
|
+
[timeCh.name]: 532,
|
|
167
|
+
[dataCh.name]: 123,
|
|
168
|
+
});
|
|
169
|
+
expect(res).toHaveProperty(timeCh.key.toString());
|
|
170
|
+
expect(res).toHaveProperty(dataCh.key.toString());
|
|
164
171
|
});
|
|
165
|
-
expect(res).toHaveProperty(timeCh.key.toString());
|
|
166
|
-
expect(res).toHaveProperty(dataCh.key.toString());
|
|
167
172
|
});
|
|
168
173
|
});
|