@synnaxlabs/client 0.38.1 → 0.40.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 +6 -5
- 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 +3387 -3433
- 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 +20 -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/examples/node/basicReadWrite.js +26 -26
- package/examples/node/liveStream.js +15 -15
- package/examples/node/seriesAndFrames.js +38 -38
- package/examples/node/streamWrite.js +47 -45
- package/package.json +15 -13
- package/src/access/payload.ts +12 -12
- package/src/access/policy/client.ts +13 -12
- package/src/access/policy/external.ts +1 -0
- package/src/access/policy/ontology.ts +17 -0
- package/src/access/policy/payload.ts +7 -19
- package/src/access/policy/policy.spec.ts +16 -16
- package/src/access/policy/retriever.ts +2 -1
- package/src/access/policy/writer.ts +4 -4
- package/src/auth/auth.spec.ts +27 -23
- package/src/auth/auth.ts +7 -11
- package/src/channel/batchRetriever.spec.ts +25 -22
- package/src/channel/client.ts +19 -21
- package/src/channel/payload.ts +16 -20
- package/src/channel/retriever.ts +20 -21
- package/src/channel/writer.ts +11 -13
- package/src/client.ts +6 -16
- package/src/connection/checker.ts +9 -11
- package/src/connection/connection.spec.ts +17 -5
- package/src/control/state.ts +8 -9
- package/src/errors.spec.ts +1 -1
- package/src/errors.ts +8 -0
- package/src/framer/adapter.spec.ts +28 -23
- package/src/framer/adapter.ts +37 -41
- package/src/framer/client.spec.ts +5 -11
- package/src/framer/client.ts +34 -38
- package/src/framer/deleter.ts +5 -6
- package/src/framer/frame.ts +62 -50
- package/src/framer/iterator.ts +11 -16
- package/src/framer/streamer.spec.ts +2 -10
- package/src/framer/streamer.ts +15 -19
- package/src/framer/writer.spec.ts +48 -7
- package/src/framer/writer.ts +39 -31
- package/src/hardware/device/client.ts +67 -39
- package/src/hardware/device/device.spec.ts +91 -33
- package/src/hardware/device/payload.ts +29 -28
- package/src/hardware/rack/client.ts +52 -65
- package/src/hardware/rack/payload.ts +9 -18
- package/src/hardware/rack/rack.spec.ts +12 -0
- package/src/hardware/task/client.ts +160 -131
- package/src/hardware/task/payload.ts +49 -68
- package/src/hardware/task/task.spec.ts +98 -81
- package/src/label/client.ts +12 -15
- package/src/label/payload.ts +3 -9
- package/src/label/retriever.ts +3 -7
- package/src/label/writer.ts +8 -15
- package/src/ontology/client.ts +17 -22
- package/src/ontology/group/client.ts +5 -5
- package/src/ontology/group/group.spec.ts +4 -4
- package/src/ontology/group/group.ts +10 -7
- package/src/ontology/group/payload.ts +11 -35
- package/src/ontology/group/writer.ts +22 -26
- package/src/ontology/ontology.spec.ts +15 -15
- package/src/ontology/payload.ts +67 -43
- package/src/ontology/writer.ts +16 -23
- package/src/ranger/alias.ts +25 -42
- package/src/ranger/client.ts +29 -38
- package/src/ranger/external.ts +1 -1
- package/src/ranger/kv.ts +9 -32
- package/src/ranger/payload.ts +14 -36
- package/src/ranger/ranger.spec.ts +1 -2
- package/src/ranger/writer.ts +8 -26
- package/src/signals/observable.ts +3 -4
- package/src/user/client.ts +8 -4
- package/src/user/payload.ts +5 -9
- package/src/user/retriever.ts +1 -1
- package/src/user/user.spec.ts +17 -15
- package/src/user/writer.ts +3 -10
- package/src/util/decodeJSONString.ts +13 -0
- package/src/util/parseWithoutKeyConversion.ts +19 -0
- package/src/util/retrieve.spec.ts +3 -13
- package/src/util/retrieve.ts +2 -12
- package/src/util/telem.ts +1 -1
- package/src/vite-env.d.ts +1 -0
- package/src/workspace/client.ts +30 -57
- package/src/workspace/external.ts +11 -0
- package/src/workspace/index.ts +1 -1
- package/src/workspace/lineplot/client.ts +22 -36
- package/src/workspace/lineplot/external.ts +11 -0
- package/src/workspace/lineplot/index.ts +1 -1
- package/src/workspace/lineplot/linePlot.spec.ts +1 -2
- package/src/workspace/lineplot/payload.ts +32 -0
- package/src/workspace/log/client.ts +25 -39
- package/src/workspace/log/external.ts +11 -0
- package/src/workspace/log/index.ts +1 -1
- package/src/workspace/log/log.spec.ts +5 -18
- package/src/workspace/log/payload.ts +32 -0
- package/src/workspace/payload.ts +36 -0
- package/src/workspace/schematic/client.ts +30 -56
- package/src/workspace/schematic/external.ts +11 -0
- package/src/workspace/schematic/index.ts +1 -1
- package/src/workspace/schematic/payload.ts +37 -0
- package/src/workspace/schematic/schematic.spec.ts +15 -6
- package/src/workspace/table/client.ts +27 -50
- package/src/workspace/table/external.ts +11 -0
- package/src/workspace/table/index.ts +1 -1
- package/src/workspace/table/payload.ts +36 -0
- package/src/workspace/workspace.spec.ts +1 -2
- package/dist/channel/creator.d.ts +0 -9
- package/dist/channel/creator.d.ts.map +0 -1
- package/src/channel/creator.ts +0 -37
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const keyZ: z.ZodString;
|
|
3
|
+
export type Key = z.infer<typeof keyZ>;
|
|
4
|
+
export type Params = Key | Key[];
|
|
5
|
+
export declare const tableZ: z.ZodObject<{
|
|
6
|
+
key: z.ZodString;
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
data: z.ZodUnion<[z.ZodRecord<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodSymbol]>, z.ZodUnknown>, z.ZodEffects<z.ZodString, import('@synnaxlabs/x').UnknownRecord, string>]>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
name: string;
|
|
11
|
+
key: string;
|
|
12
|
+
data: import('@synnaxlabs/x').UnknownRecord | Record<string | number | symbol, unknown>;
|
|
13
|
+
}, {
|
|
14
|
+
name: string;
|
|
15
|
+
key: string;
|
|
16
|
+
data: string | Record<string | number | symbol, unknown>;
|
|
17
|
+
}>;
|
|
18
|
+
export interface Table extends z.infer<typeof tableZ> {
|
|
19
|
+
}
|
|
20
|
+
export declare const newZ: z.ZodEffects<z.ZodObject<{
|
|
21
|
+
name: z.ZodString;
|
|
22
|
+
key: z.ZodOptional<z.ZodString>;
|
|
23
|
+
data: z.ZodUnion<[z.ZodRecord<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodSymbol]>, z.ZodUnknown>, z.ZodEffects<z.ZodString, import('@synnaxlabs/x').UnknownRecord, string>]>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
name: string;
|
|
26
|
+
data: import('@synnaxlabs/x').UnknownRecord | Record<string | number | symbol, unknown>;
|
|
27
|
+
key?: string | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
name: string;
|
|
30
|
+
data: string | Record<string | number | symbol, unknown>;
|
|
31
|
+
key?: string | undefined;
|
|
32
|
+
}>, {
|
|
33
|
+
data: string;
|
|
34
|
+
name: string;
|
|
35
|
+
key?: string | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
name: string;
|
|
38
|
+
data: string | Record<string | number | symbol, unknown>;
|
|
39
|
+
key?: string | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
export interface New extends z.input<typeof newZ> {
|
|
42
|
+
}
|
|
43
|
+
export declare const remoteZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
44
|
+
key: z.ZodString;
|
|
45
|
+
name: z.ZodString;
|
|
46
|
+
data: z.ZodUnion<[z.ZodRecord<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodSymbol]>, z.ZodUnknown>, z.ZodEffects<z.ZodString, import('@synnaxlabs/x').UnknownRecord, string>]>;
|
|
47
|
+
}, {
|
|
48
|
+
data: z.ZodEffects<z.ZodString, import('@synnaxlabs/x').UnknownRecord, string>;
|
|
49
|
+
}>, "strip", z.ZodTypeAny, {
|
|
50
|
+
name: string;
|
|
51
|
+
key: string;
|
|
52
|
+
data: import('@synnaxlabs/x').UnknownRecord;
|
|
53
|
+
}, {
|
|
54
|
+
name: string;
|
|
55
|
+
key: string;
|
|
56
|
+
data: string;
|
|
57
|
+
}>;
|
|
58
|
+
export declare const ONTOLOGY_TYPE = "table";
|
|
59
|
+
export type OntologyType = typeof ONTOLOGY_TYPE;
|
|
60
|
+
//# sourceMappingURL=payload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../../src/workspace/table/payload.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,IAAI,aAAoB,CAAC;AACtC,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AACvC,MAAM,MAAM,MAAM,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC;AAEjC,eAAO,MAAM,MAAM;;;;;;;;;;;;EAIjB,CAAC;AACH,MAAM,WAAW,KAAM,SAAQ,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC;CAAG;AAExD,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;EAE4C,CAAC;AAC9D,MAAM,WAAW,GAAI,SAAQ,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC;CAAG;AAEpD,eAAO,MAAM,OAAO;;;;;;;;;;;;;;EAElB,CAAC;AAEH,eAAO,MAAM,aAAa,UAAU,CAAC;AACrC,MAAM,MAAM,YAAY,GAAG,OAAO,aAAa,CAAC"}
|
|
@@ -16,34 +16,34 @@ import { DataType, Synnax, TimeRange, TimeSpan, TimeStamp } from "@synnaxlabs/cl
|
|
|
16
16
|
// Connect to a locally running, insecure Synnax cluster. If your connection parameters
|
|
17
17
|
// are different, enter them here.
|
|
18
18
|
const client = new Synnax({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
host: "localhost",
|
|
20
|
+
port: 9090,
|
|
21
|
+
username: "synnax",
|
|
22
|
+
password: "seldon",
|
|
23
|
+
secure: false,
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
// Create an index channel that will be used to store our timestamps.
|
|
27
27
|
const timeChannel = await client.channels.create(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
{
|
|
29
|
+
name: "basic_read_write_time",
|
|
30
|
+
isIndex: true,
|
|
31
|
+
dataType: DataType.TIMESTAMP,
|
|
32
|
+
},
|
|
33
|
+
{ retrieveIfNameExists: true },
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
// Create a channel that will be used to store our data.
|
|
37
37
|
const dataChannel = await client.channels.create(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
{
|
|
39
|
+
name: "basic_read_write_data",
|
|
40
|
+
isIndex: false,
|
|
41
|
+
dataType: DataType.FLOAT32,
|
|
42
|
+
// We need to specify the index channel that we want to use to store the timestamps
|
|
43
|
+
// for this data channel.
|
|
44
|
+
index: timeChannel.key,
|
|
45
|
+
},
|
|
46
|
+
{ retrieveIfNameExists: true },
|
|
47
47
|
);
|
|
48
48
|
|
|
49
49
|
const N_SAMPLES = 5000;
|
|
@@ -54,7 +54,7 @@ const start = TimeStamp.now();
|
|
|
54
54
|
|
|
55
55
|
// Generate a new timestamp every millisecond for N_SAMPLES.
|
|
56
56
|
const time = BigInt64Array.from({ length: N_SAMPLES }, (_, i) =>
|
|
57
|
-
|
|
57
|
+
start.add(TimeSpan.milliseconds(i)).valueOf(),
|
|
58
58
|
);
|
|
59
59
|
|
|
60
60
|
// Generate a sine wave for N_SAMPLES.
|
|
@@ -75,11 +75,11 @@ const readData = await dataChannel.read(tr);
|
|
|
75
75
|
|
|
76
76
|
// Print out some information.
|
|
77
77
|
console.log({
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
firstTimestamp: readTime.at(0),
|
|
79
|
+
firstData: readData.at(0),
|
|
80
|
+
lastTimestamp: readTime.at(N_SAMPLES - 1),
|
|
81
|
+
lastData: readData.at(N_SAMPLES - 1),
|
|
82
|
+
returnLength: readData.length,
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
// Make sure to close the client when you're done.
|
|
@@ -19,18 +19,18 @@ import { Synnax } from "@synnaxlabs/client";
|
|
|
19
19
|
// Connect to a locally running, insecure Synnax cluster. If your connection parameters
|
|
20
20
|
// are different, enter them here.
|
|
21
21
|
const client = new Synnax({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
host: "localhost",
|
|
23
|
+
port: 9090,
|
|
24
|
+
username: "synnax",
|
|
25
|
+
password: "seldon",
|
|
26
|
+
secure: false,
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
// We can just specify the names of the channels we'd like to stream from.
|
|
30
30
|
const read_from = [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
"stream_write_example_time",
|
|
32
|
+
"stream_write_example_data_1",
|
|
33
|
+
"stream_write_example_data_2",
|
|
34
34
|
];
|
|
35
35
|
|
|
36
36
|
const streamer = await client.openStreamer(read_from);
|
|
@@ -39,12 +39,12 @@ const streamer = await client.openStreamer(read_from);
|
|
|
39
39
|
// network connections and other resources, so we wrap the streaming loop in a
|
|
40
40
|
// try-finally block.
|
|
41
41
|
try {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
// Loop through the frames in the streamer. Each iteration will block until a new
|
|
43
|
+
// frame is available, and then we'll just print out the last sample for each
|
|
44
|
+
// channel in the frame.
|
|
45
|
+
for await (const frame of streamer) console.log(frame.at(-1));
|
|
46
46
|
} finally {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
streamer.close();
|
|
48
|
+
// Close the client when we're done with it.
|
|
49
|
+
client.close();
|
|
50
50
|
}
|
|
@@ -67,9 +67,9 @@ const start = TimeStamp.now();
|
|
|
67
67
|
const tr = new TimeRange(start, start.add(TimeSpan.seconds(5)));
|
|
68
68
|
|
|
69
69
|
series = new Series({
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
data: [1, 2, 3, 4, 5],
|
|
71
|
+
dataType: "float64",
|
|
72
|
+
timeRange: tr,
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
series = new Series([1, 2, 3, 4, 5]);
|
|
@@ -93,52 +93,52 @@ import { Frame } from "@synnaxlabs/client";
|
|
|
93
93
|
|
|
94
94
|
// Construct a frame for the given channel names.
|
|
95
95
|
let frame = new Frame({
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
channel1: new Series([1, 2, 3, 4, 5]),
|
|
97
|
+
channel2: new Series([5, 4, 3, 2, 1]),
|
|
98
|
+
channel3: new Series([1, 1, 1, 1, 1]),
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
// Construct a frame for the given channel keys
|
|
102
102
|
frame = new Frame({
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
1: new Series([1, 2, 3, 4, 5]),
|
|
104
|
+
2: new Series([5, 4, 3, 2, 1]),
|
|
105
|
+
// Notice that series do not need to be the same length.
|
|
106
|
+
3: new Series([1, 1, 1]),
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
// Construct a frame from a map
|
|
110
110
|
frame = new Frame(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
new Map([
|
|
112
|
+
["channel1", new Series([1, 2, 3, 4, 5])],
|
|
113
|
+
["channel2", new Series([5, 4, 3, 2, 1])],
|
|
114
|
+
["channel3", new Series([1, 1, 1, 1, 1])],
|
|
115
|
+
]),
|
|
116
116
|
);
|
|
117
117
|
|
|
118
118
|
// Or from an array of keys and series
|
|
119
119
|
frame = new Frame(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
["channel1", "channel2", "channel3"],
|
|
121
|
+
[
|
|
122
|
+
new Series([1, 2, 3, 4, 5]),
|
|
123
|
+
new Series([5, 4, 3, 2, 1]),
|
|
124
|
+
new Series([1, 1, 1, 1, 1]),
|
|
125
|
+
],
|
|
126
126
|
);
|
|
127
127
|
|
|
128
128
|
// Or construct a frame with multiple series for a single channel
|
|
129
129
|
frame = new Frame({
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
130
|
+
channel1: [
|
|
131
|
+
new Series([1, 2, 3, 4, 5]),
|
|
132
|
+
new Series([5, 4, 3, 2, 1]),
|
|
133
|
+
new Series([1, 1, 1, 1, 1]),
|
|
134
|
+
],
|
|
135
|
+
channel2: [new Series([1, 2, 3, 4, 5])],
|
|
136
136
|
});
|
|
137
137
|
|
|
138
138
|
frame = new Frame({
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
channel1: [new Series([1, 2]), new Series([3, 4, 5])],
|
|
140
|
+
channel2: new Series([5, 4, 3, 2, 1]),
|
|
141
|
+
channel3: new Series([1, 1, 1, 1, 1]),
|
|
142
142
|
});
|
|
143
143
|
|
|
144
144
|
const multiSeries = frame.get("channel1");
|
|
@@ -153,21 +153,21 @@ jsArray = [...multiSeries];
|
|
|
153
153
|
console.log(jsArray); // [ 1, 2, 3, 4, 5 ]
|
|
154
154
|
|
|
155
155
|
frame = new Frame({
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
channel1: new Series([1, 2, 3, 4, 5]),
|
|
157
|
+
channel2: new Series([5, 4, 3, 2, 1]),
|
|
158
|
+
channel3: new Series([1, 1]),
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
let obj = frame.at(3);
|
|
162
162
|
console.log(obj); // { channel1: 1, channel2: 5, channel3: undefined }
|
|
163
163
|
|
|
164
164
|
frame = new Frame({
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
channel1: new Series([1, 2, 3, 4, 5]),
|
|
166
|
+
channel2: new Series([5, 4, 3, 2, 1]),
|
|
167
|
+
channel3: new Series([1, 1]),
|
|
168
168
|
});
|
|
169
169
|
try {
|
|
170
|
-
|
|
170
|
+
obj = frame.at(3, true); // Throws an error
|
|
171
171
|
} catch (e) {
|
|
172
|
-
|
|
172
|
+
console.log(e.message); // no value at index
|
|
173
173
|
}
|
|
@@ -17,39 +17,39 @@ import { Rate, Synnax, TimeStamp } from "@synnaxlabs/client";
|
|
|
17
17
|
// Connect to a locally running, insecure Synnax cluster. If your connection parameters
|
|
18
18
|
// are different, enter them here.
|
|
19
19
|
const client = new Synnax({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
host: "localhost",
|
|
21
|
+
port: 9090,
|
|
22
|
+
username: "synnax",
|
|
23
|
+
password: "seldon",
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
// Create an index channel that will be used to store our timestamps.
|
|
27
27
|
const timeChannel = await client.channels.create(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
{
|
|
29
|
+
name: "stream_write_example_time",
|
|
30
|
+
isIndex: true,
|
|
31
|
+
dataType: "timestamp",
|
|
32
|
+
},
|
|
33
|
+
{ retrieveIfNameExists: true },
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
// Create a data channel that will be used to store our fake sensor data.
|
|
37
37
|
const dataChannel1 = await client.channels.create(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
{
|
|
39
|
+
name: "stream_write_example_data_1",
|
|
40
|
+
dataType: "float32",
|
|
41
|
+
index: timeChannel.key,
|
|
42
|
+
},
|
|
43
|
+
{ retrieveIfNameExists: true },
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
const dataChannel2 = await client.channels.create(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
{
|
|
48
|
+
name: "stream_write_example_data_2",
|
|
49
|
+
dataType: "int32",
|
|
50
|
+
index: timeChannel.key,
|
|
51
|
+
},
|
|
52
|
+
{ retrieveIfNameExists: true },
|
|
53
53
|
);
|
|
54
54
|
|
|
55
55
|
// We'll start our write at the current time. This timestamps should be the same as or
|
|
@@ -61,32 +61,34 @@ const start = TimeStamp.now();
|
|
|
61
61
|
const roughRate = Rate.hz(25);
|
|
62
62
|
|
|
63
63
|
const writer = await client.openWriter({
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
start,
|
|
65
|
+
channels: [timeChannel.key, dataChannel1.key, dataChannel2.key],
|
|
66
|
+
enableAutoCommit: true,
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
try {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
console.log(`Writing sample ${i} at ${timestamp.toISOString()}`);
|
|
70
|
+
let i = 0;
|
|
71
|
+
while (true) {
|
|
72
|
+
await new Promise((resolve) => setTimeout(resolve, roughRate.period.milliseconds));
|
|
73
|
+
i++;
|
|
74
|
+
const timestamp = TimeStamp.now();
|
|
75
|
+
const data1 = Math.sin(i / 10);
|
|
76
|
+
const data2 = i % 2;
|
|
77
|
+
if (
|
|
78
|
+
!(await writer.write({
|
|
79
|
+
[timeChannel.key]: timestamp,
|
|
80
|
+
[dataChannel1.key]: data1,
|
|
81
|
+
[dataChannel2.key]: data2,
|
|
82
|
+
}))
|
|
83
|
+
) {
|
|
84
|
+
console.error("Failed to write");
|
|
85
|
+
break;
|
|
87
86
|
}
|
|
87
|
+
|
|
88
|
+
if (i % 60 == 0) console.log(`Writing sample ${i} at ${timestamp.toISOString()}`);
|
|
89
|
+
}
|
|
88
90
|
} finally {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
// Close the writer and the client when you are done
|
|
92
|
+
await writer.close();
|
|
93
|
+
client.close();
|
|
92
94
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synnaxlabs/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.0",
|
|
4
4
|
"description": "The Synnax Client Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"synnax",
|
|
@@ -25,21 +25,22 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"async-mutex": "^0.5.0",
|
|
28
|
-
"uuid": "^11.0
|
|
29
|
-
"zod": "^3.24.
|
|
30
|
-
"@synnaxlabs/freighter": "0.
|
|
31
|
-
"@synnaxlabs/x": "0.
|
|
28
|
+
"uuid": "^11.1.0",
|
|
29
|
+
"zod": "^3.24.2",
|
|
30
|
+
"@synnaxlabs/freighter": "0.40.0",
|
|
31
|
+
"@synnaxlabs/x": "0.40.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/node": "^22.10
|
|
34
|
+
"@types/node": "^22.13.10",
|
|
35
35
|
"@types/uuid": "^10.0.0",
|
|
36
|
-
"eslint": "^9.
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
36
|
+
"eslint": "^9.22.0",
|
|
37
|
+
"madge": "^8.0.0",
|
|
38
|
+
"typescript": "^5.8.2",
|
|
39
|
+
"vite": "^6.2.1",
|
|
40
|
+
"vitest": "^2.1.9",
|
|
41
|
+
"@synnaxlabs/tsconfig": "0.0.2",
|
|
40
42
|
"@synnaxlabs/vite-plugin": "0.0.1",
|
|
41
|
-
"eslint-config-synnaxlabs": "0.0.1"
|
|
42
|
-
"@synnaxlabs/tsconfig": "0.0.2"
|
|
43
|
+
"eslint-config-synnaxlabs": "0.0.1"
|
|
43
44
|
},
|
|
44
45
|
"type": "module",
|
|
45
46
|
"types": "dist/index.d.ts",
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
"watch": "tsc --noEmit && vite build --watch",
|
|
50
51
|
"test": "vitest",
|
|
51
52
|
"lint": "eslint --cache",
|
|
52
|
-
"fix": "eslint --cache --fix"
|
|
53
|
+
"fix": "eslint --cache --fix",
|
|
54
|
+
"madge": "madge --circular src"
|
|
53
55
|
}
|
|
54
56
|
}
|
package/src/access/payload.ts
CHANGED
|
@@ -9,17 +9,17 @@
|
|
|
9
9
|
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
|
|
12
|
-
export const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
export const ALL_ACTION = "all";
|
|
13
|
+
export const CREATE_ACTION = "create";
|
|
14
|
+
export const DELETE_ACTION = "delete";
|
|
15
|
+
export const RETRIEVE_ACTION = "retrieve";
|
|
16
|
+
export const UPDATE_ACTION = "update";
|
|
17
|
+
|
|
18
|
+
export const actionZ = z.enum([
|
|
19
|
+
ALL_ACTION,
|
|
20
|
+
CREATE_ACTION,
|
|
21
|
+
DELETE_ACTION,
|
|
22
|
+
RETRIEVE_ACTION,
|
|
23
|
+
UPDATE_ACTION,
|
|
18
24
|
]);
|
|
19
25
|
export type Action = z.infer<typeof actionZ>;
|
|
20
|
-
|
|
21
|
-
export const ALL_ACTION: Action = "all";
|
|
22
|
-
export const CREATE_ACTION: Action = "create";
|
|
23
|
-
export const DELETE_ACTION: Action = "delete";
|
|
24
|
-
export const RETRIEVE_ACTION: Action = "retrieve";
|
|
25
|
-
export const UPDATE_ACTION: Action = "update";
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { toArray } from "@synnaxlabs/x/toArray";
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { ALLOW_ALL_ONTOLOGY_TYPE, ONTOLOGY_TYPE } from "@/access/policy/ontology";
|
|
14
|
+
import { type Key, type New, type Policy } from "@/access/policy/payload";
|
|
14
15
|
import { Retriever } from "@/access/policy/retriever";
|
|
15
16
|
import { Writer } from "@/access/policy/writer";
|
|
16
17
|
import { ontology } from "@/ontology";
|
|
@@ -24,20 +25,16 @@ export class Client {
|
|
|
24
25
|
this.writer = new Writer(client);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
async create(policy:
|
|
28
|
-
|
|
29
|
-
async create(policies:
|
|
30
|
-
|
|
31
|
-
async create(policies: NewPolicy | NewPolicy[]): Promise<Policy | Policy[]> {
|
|
28
|
+
async create(policy: New): Promise<Policy>;
|
|
29
|
+
async create(policies: New[]): Promise<Policy[]>;
|
|
30
|
+
async create(policies: New | New[]): Promise<Policy | Policy[]> {
|
|
32
31
|
const isMany = Array.isArray(policies);
|
|
33
32
|
const createdPolicies = await this.writer.create(policies);
|
|
34
33
|
return isMany ? createdPolicies : createdPolicies[0];
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
async retrieve(key: Key): Promise<Policy>;
|
|
38
|
-
|
|
39
37
|
async retrieve(keys: Key[]): Promise<Policy[]>;
|
|
40
|
-
|
|
41
38
|
async retrieve(keys: Key | Key[]): Promise<Policy | Policy[]> {
|
|
42
39
|
const isMany = Array.isArray(keys);
|
|
43
40
|
const res = await this.retriever.retrieve({ keys: toArray(keys) });
|
|
@@ -45,9 +42,7 @@ export class Client {
|
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
async retrieveFor(subject: ontology.CrudeID): Promise<Policy[]>;
|
|
48
|
-
|
|
49
45
|
async retrieveFor(subjects: ontology.CrudeID[]): Promise<Policy[]>;
|
|
50
|
-
|
|
51
46
|
async retrieveFor(
|
|
52
47
|
subjects: ontology.CrudeID | ontology.CrudeID[],
|
|
53
48
|
): Promise<Policy[]> {
|
|
@@ -56,10 +51,16 @@ export class Client {
|
|
|
56
51
|
}
|
|
57
52
|
|
|
58
53
|
async delete(key: Key): Promise<void>;
|
|
59
|
-
|
|
60
54
|
async delete(keys: Key[]): Promise<void>;
|
|
61
|
-
|
|
62
55
|
async delete(keys: Key | Key[]): Promise<void> {
|
|
63
56
|
await this.writer.delete(keys);
|
|
64
57
|
}
|
|
65
58
|
}
|
|
59
|
+
|
|
60
|
+
export const ontologyID = (key: Key): ontology.ID =>
|
|
61
|
+
new ontology.ID({ type: ONTOLOGY_TYPE, key });
|
|
62
|
+
|
|
63
|
+
export const ALLOW_ALL_ONTOLOGY_ID = new ontology.ID({
|
|
64
|
+
type: ALLOW_ALL_ONTOLOGY_TYPE,
|
|
65
|
+
key: "",
|
|
66
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
// This needs to be a separate file because these types are imported by the ontology
|
|
11
|
+
// module, but the policy module need to import the ID schema from the ontology module.
|
|
12
|
+
|
|
13
|
+
export const ONTOLOGY_TYPE = "policy";
|
|
14
|
+
export type OntologyType = typeof ONTOLOGY_TYPE;
|
|
15
|
+
|
|
16
|
+
export const ALLOW_ALL_ONTOLOGY_TYPE = "allow_all";
|
|
17
|
+
export type AllowAllOntologyType = typeof ALLOW_ALL_ONTOLOGY_TYPE;
|
|
@@ -16,30 +16,18 @@ import { nullableArrayZ } from "@/util/zod";
|
|
|
16
16
|
export const keyZ = z.string().uuid();
|
|
17
17
|
export type Key = z.infer<typeof keyZ>;
|
|
18
18
|
|
|
19
|
-
export const newPolicyZ = z.object({
|
|
20
|
-
key: keyZ.optional(),
|
|
21
|
-
subjects: ontology.crudeIDZ.array().or(ontology.crudeIDZ),
|
|
22
|
-
objects: ontology.crudeIDZ.array().or(ontology.crudeIDZ),
|
|
23
|
-
actions: actionZ.array().or(actionZ),
|
|
24
|
-
});
|
|
25
|
-
export type NewPolicy = z.input<typeof newPolicyZ>;
|
|
26
|
-
|
|
27
19
|
export const policyZ = z.object({
|
|
28
20
|
key: keyZ,
|
|
29
21
|
subjects: nullableArrayZ(ontology.idZ),
|
|
30
22
|
objects: nullableArrayZ(ontology.idZ),
|
|
31
23
|
actions: nullableArrayZ(actionZ),
|
|
32
24
|
});
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
export const ONTOLOGY_TYPE: ontology.ResourceType = "policy";
|
|
25
|
+
export interface Policy extends z.infer<typeof policyZ> {}
|
|
36
26
|
|
|
37
|
-
export const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
export const ALLOW_ALL_ONTOLOGY_ID = new ontology.ID({
|
|
43
|
-
type: ALLOW_ALL_ONTOLOGY_TYPE,
|
|
44
|
-
key: "",
|
|
27
|
+
export const newZ = z.object({
|
|
28
|
+
key: keyZ.optional(),
|
|
29
|
+
subjects: ontology.crudeIDZ.array().or(ontology.crudeIDZ),
|
|
30
|
+
objects: ontology.crudeIDZ.array().or(ontology.crudeIDZ),
|
|
31
|
+
actions: actionZ.array().or(actionZ),
|
|
45
32
|
});
|
|
33
|
+
export interface New extends z.input<typeof newZ> {}
|