@synnaxlabs/client 0.38.1 → 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 +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 +3376 -3423
- 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/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 +64 -39
- package/src/hardware/device/device.spec.ts +49 -33
- package/src/hardware/device/payload.ts +29 -29
- 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
|
@@ -10,42 +10,38 @@
|
|
|
10
10
|
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
|
|
13
|
+
import {
|
|
14
|
+
groupZ,
|
|
15
|
+
type Key,
|
|
16
|
+
keyZ,
|
|
17
|
+
type Name,
|
|
18
|
+
nameZ,
|
|
19
|
+
type Payload,
|
|
20
|
+
} from "@/ontology/group/payload";
|
|
21
|
+
import { type ID as OntologyID, idZ as ontologyIDZ } from "@/ontology/payload";
|
|
15
22
|
|
|
16
|
-
const resZ = z.object({
|
|
17
|
-
group: groupZ,
|
|
18
|
-
});
|
|
23
|
+
const resZ = z.object({ group: groupZ });
|
|
19
24
|
|
|
20
|
-
const createReqZ = z.object({
|
|
21
|
-
parent: idZ,
|
|
22
|
-
key: z.string().uuid().optional(),
|
|
23
|
-
name: z.string(),
|
|
24
|
-
});
|
|
25
|
+
const createReqZ = z.object({ parent: ontologyIDZ, key: keyZ.optional(), name: nameZ });
|
|
25
26
|
|
|
26
|
-
const renameReqZ = z.object({
|
|
27
|
-
key: z.string(),
|
|
28
|
-
name: z.string(),
|
|
29
|
-
});
|
|
27
|
+
const renameReqZ = z.object({ key: keyZ, name: nameZ });
|
|
30
28
|
|
|
31
|
-
const deleteReqZ = z.object({
|
|
32
|
-
keys: z.array(z.string()),
|
|
33
|
-
});
|
|
29
|
+
const deleteReqZ = z.object({ keys: z.array(keyZ) });
|
|
34
30
|
|
|
35
31
|
export class Writer {
|
|
36
|
-
private static readonly
|
|
37
|
-
private static readonly
|
|
38
|
-
private static readonly
|
|
32
|
+
private static readonly CREATE_ENDPOINT = "/ontology/create-group";
|
|
33
|
+
private static readonly RENAME_ENDPOINT = "/ontology/rename-group";
|
|
34
|
+
private static readonly DELETE_ENDPOINT = "/ontology/delete-group";
|
|
39
35
|
client: UnaryClient;
|
|
40
36
|
|
|
41
37
|
constructor(client: UnaryClient) {
|
|
42
38
|
this.client = client;
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
async create(parent:
|
|
41
|
+
async create(parent: OntologyID, name: Name, key?: Key): Promise<Payload> {
|
|
46
42
|
const res = await sendRequired(
|
|
47
43
|
this.client,
|
|
48
|
-
Writer.
|
|
44
|
+
Writer.CREATE_ENDPOINT,
|
|
49
45
|
{ parent, name, key },
|
|
50
46
|
createReqZ,
|
|
51
47
|
resZ,
|
|
@@ -53,20 +49,20 @@ export class Writer {
|
|
|
53
49
|
return res.group;
|
|
54
50
|
}
|
|
55
51
|
|
|
56
|
-
async rename(key:
|
|
52
|
+
async rename(key: Key, name: Name): Promise<void> {
|
|
57
53
|
await sendRequired(
|
|
58
54
|
this.client,
|
|
59
|
-
Writer.
|
|
55
|
+
Writer.RENAME_ENDPOINT,
|
|
60
56
|
{ key, name },
|
|
61
57
|
renameReqZ,
|
|
62
58
|
z.object({}),
|
|
63
59
|
);
|
|
64
60
|
}
|
|
65
61
|
|
|
66
|
-
async delete(keys:
|
|
62
|
+
async delete(keys: Key[]): Promise<void> {
|
|
67
63
|
await sendRequired(
|
|
68
64
|
this.client,
|
|
69
|
-
Writer.
|
|
65
|
+
Writer.DELETE_ENDPOINT,
|
|
70
66
|
{ keys },
|
|
71
67
|
deleteReqZ,
|
|
72
68
|
z.object({}),
|
|
@@ -20,13 +20,13 @@ describe("Ontology", () => {
|
|
|
20
20
|
describe("retrieve", () => {
|
|
21
21
|
test("retrieve", async () => {
|
|
22
22
|
const name = randomName();
|
|
23
|
-
const g = await client.ontology.groups.create(ontology.
|
|
23
|
+
const g = await client.ontology.groups.create(ontology.ROOT_ID, name);
|
|
24
24
|
const g2 = await client.ontology.retrieve(g.ontologyID);
|
|
25
25
|
expect(g2.name).toEqual(name);
|
|
26
26
|
});
|
|
27
27
|
test("retrieve children", async () => {
|
|
28
28
|
const name = randomName();
|
|
29
|
-
const g = await client.ontology.groups.create(ontology.
|
|
29
|
+
const g = await client.ontology.groups.create(ontology.ROOT_ID, name);
|
|
30
30
|
const name2 = randomName();
|
|
31
31
|
await client.ontology.groups.create(g.ontologyID, name2);
|
|
32
32
|
const children = await client.ontology.retrieveChildren(g.ontologyID);
|
|
@@ -35,7 +35,7 @@ describe("Ontology", () => {
|
|
|
35
35
|
});
|
|
36
36
|
test("retrieve parents", async () => {
|
|
37
37
|
const name = randomName();
|
|
38
|
-
const g = await client.ontology.groups.create(ontology.
|
|
38
|
+
const g = await client.ontology.groups.create(ontology.ROOT_ID, name);
|
|
39
39
|
const name2 = randomName();
|
|
40
40
|
const g2 = await client.ontology.groups.create(g.ontologyID, name2);
|
|
41
41
|
const parents = await client.ontology.retrieveParents(g2.ontologyID);
|
|
@@ -46,7 +46,7 @@ describe("Ontology", () => {
|
|
|
46
46
|
describe("page", () => {
|
|
47
47
|
it("should return a page of resources", async () => {
|
|
48
48
|
for (let i = 0; i < 10; i++)
|
|
49
|
-
await client.ontology.groups.create(ontology.
|
|
49
|
+
await client.ontology.groups.create(ontology.ROOT_ID, randomName());
|
|
50
50
|
const page = await client.ontology.page(0, 5);
|
|
51
51
|
expect(page.length).toEqual(5);
|
|
52
52
|
const page2 = await client.ontology.page(5, 5);
|
|
@@ -60,9 +60,9 @@ describe("Ontology", () => {
|
|
|
60
60
|
describe("write", () => {
|
|
61
61
|
test("add children", async () => {
|
|
62
62
|
const name = randomName();
|
|
63
|
-
const g = await client.ontology.groups.create(ontology.
|
|
63
|
+
const g = await client.ontology.groups.create(ontology.ROOT_ID, name);
|
|
64
64
|
const name2 = randomName();
|
|
65
|
-
const g2 = await client.ontology.groups.create(ontology.
|
|
65
|
+
const g2 = await client.ontology.groups.create(ontology.ROOT_ID, name2);
|
|
66
66
|
await client.ontology.addChildren(g.ontologyID, g2.ontologyID);
|
|
67
67
|
const children = await client.ontology.retrieveChildren(g.ontologyID);
|
|
68
68
|
expect(children.length).toEqual(1);
|
|
@@ -70,9 +70,9 @@ describe("Ontology", () => {
|
|
|
70
70
|
});
|
|
71
71
|
test("remove children", async () => {
|
|
72
72
|
const name = randomName();
|
|
73
|
-
const g = await client.ontology.groups.create(ontology.
|
|
73
|
+
const g = await client.ontology.groups.create(ontology.ROOT_ID, name);
|
|
74
74
|
const name2 = randomName();
|
|
75
|
-
const g2 = await client.ontology.groups.create(ontology.
|
|
75
|
+
const g2 = await client.ontology.groups.create(ontology.ROOT_ID, name2);
|
|
76
76
|
await client.ontology.addChildren(g.ontologyID, g2.ontologyID);
|
|
77
77
|
await client.ontology.removeChildren(g.ontologyID, g2.ontologyID);
|
|
78
78
|
const children = await client.ontology.retrieveChildren(g.ontologyID);
|
|
@@ -80,15 +80,15 @@ describe("Ontology", () => {
|
|
|
80
80
|
});
|
|
81
81
|
test("move children", async () => {
|
|
82
82
|
const name = randomName();
|
|
83
|
-
const g = await client.ontology.groups.create(ontology.
|
|
83
|
+
const g = await client.ontology.groups.create(ontology.ROOT_ID, name);
|
|
84
84
|
const name2 = randomName();
|
|
85
|
-
const g2 = await client.ontology.groups.create(ontology.
|
|
86
|
-
const oldRootLength = (await client.ontology.retrieveChildren(ontology.
|
|
85
|
+
const g2 = await client.ontology.groups.create(ontology.ROOT_ID, name2);
|
|
86
|
+
const oldRootLength = (await client.ontology.retrieveChildren(ontology.ROOT_ID))
|
|
87
87
|
.length;
|
|
88
|
-
await client.ontology.moveChildren(ontology.
|
|
88
|
+
await client.ontology.moveChildren(ontology.ROOT_ID, g.ontologyID, g2.ontologyID);
|
|
89
89
|
const children = await client.ontology.retrieveChildren(g.ontologyID);
|
|
90
90
|
expect(children.length).toEqual(1);
|
|
91
|
-
const newRootLength = (await client.ontology.retrieveChildren(ontology.
|
|
91
|
+
const newRootLength = (await client.ontology.retrieveChildren(ontology.ROOT_ID))
|
|
92
92
|
.length;
|
|
93
93
|
expect(newRootLength).toEqual(oldRootLength - 1);
|
|
94
94
|
});
|
|
@@ -107,7 +107,7 @@ describe("Ontology", () => {
|
|
|
107
107
|
const p = new Promise<ontology.ResourceChange[]>((resolve) =>
|
|
108
108
|
change.resources.onChange((changes) => resolve(changes)),
|
|
109
109
|
);
|
|
110
|
-
await client.ontology.groups.create(ontology.
|
|
110
|
+
await client.ontology.groups.create(ontology.ROOT_ID, randomName());
|
|
111
111
|
const c = await p;
|
|
112
112
|
expect(c.length).toBeGreaterThan(0);
|
|
113
113
|
await change.close();
|
|
@@ -119,7 +119,7 @@ describe("Ontology", () => {
|
|
|
119
119
|
resolve(changes);
|
|
120
120
|
});
|
|
121
121
|
});
|
|
122
|
-
await client.ontology.groups.create(ontology.
|
|
122
|
+
await client.ontology.groups.create(ontology.ROOT_ID, randomName());
|
|
123
123
|
const c = await p;
|
|
124
124
|
expect(c.length).toBeGreaterThan(0);
|
|
125
125
|
await change.close();
|
package/src/ontology/payload.ts
CHANGED
|
@@ -10,43 +10,65 @@
|
|
|
10
10
|
import { type change, type UnknownRecord } from "@synnaxlabs/x";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
|
+
import {
|
|
14
|
+
ALLOW_ALL_ONTOLOGY_TYPE as ALLOW_ALL_TYPE,
|
|
15
|
+
ONTOLOGY_TYPE as POLICY_TYPE,
|
|
16
|
+
} from "@/access/policy/ontology";
|
|
17
|
+
import { ONTOLOGY_TYPE as CHANNEL_TYPE } from "@/channel/payload";
|
|
18
|
+
import { ONTOLOGY_TYPE as FRAMER_TYPE } from "@/framer/frame";
|
|
19
|
+
import { ONTOLOGY_TYPE as DEVICE_TYPE } from "@/hardware/device/payload";
|
|
20
|
+
import { ONTOLOGY_TYPE as RACK_TYPE } from "@/hardware/rack/payload";
|
|
21
|
+
import { ONTOLOGY_TYPE as TASK_TYPE } from "@/hardware/task/payload";
|
|
22
|
+
import { ONTOLOGY_TYPE as LABEL_TYPE } from "@/label/payload";
|
|
23
|
+
import { ONTOLOGY_TYPE as GROUP_TYPE } from "@/ontology/group/payload";
|
|
24
|
+
import {
|
|
25
|
+
ALIAS_ONTOLOGY_TYPE as RANGE_ALIAS_TYPE,
|
|
26
|
+
ONTOLOGY_TYPE as RANGE_TYPE,
|
|
27
|
+
} from "@/ranger/payload";
|
|
28
|
+
import { ONTOLOGY_TYPE as USER_TYPE } from "@/user/payload";
|
|
29
|
+
import { ONTOLOGY_TYPE as LINE_PLOT_TYPE } from "@/workspace/lineplot/payload";
|
|
30
|
+
import { ONTOLOGY_TYPE as LOG_TYPE } from "@/workspace/log/payload";
|
|
31
|
+
import { ONTOLOGY_TYPE as WORKSPACE_TYPE } from "@/workspace/payload";
|
|
32
|
+
import { ONTOLOGY_TYPE as SCHEMATIC_TYPE } from "@/workspace/schematic/payload";
|
|
33
|
+
import { ONTOLOGY_TYPE as TABLE_TYPE } from "@/workspace/table/payload";
|
|
34
|
+
|
|
13
35
|
export type ResourceChange = change.Change<ID, Resource>;
|
|
14
|
-
export
|
|
15
|
-
export
|
|
36
|
+
export interface ResourceSet extends change.Set<ID, Resource> {}
|
|
37
|
+
export interface ResourceDelete extends change.Delete<ID, Resource> {}
|
|
16
38
|
export type RelationshipChange = change.Change<Relationship, undefined>;
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
export const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
export interface RelationshipSet extends change.Set<Relationship, undefined> {}
|
|
40
|
+
export interface RelationshipDelete extends change.Delete<Relationship, undefined> {}
|
|
41
|
+
|
|
42
|
+
export const BUILTIN_TYPE = "builtin";
|
|
43
|
+
export const CLUSTER_TYPE = "cluster";
|
|
44
|
+
export const NODE_TYPE = "node";
|
|
45
|
+
|
|
46
|
+
export const resourceTypeZ = z.enum([
|
|
47
|
+
LABEL_TYPE,
|
|
48
|
+
LOG_TYPE,
|
|
49
|
+
ALLOW_ALL_TYPE,
|
|
50
|
+
BUILTIN_TYPE,
|
|
51
|
+
CLUSTER_TYPE,
|
|
52
|
+
CHANNEL_TYPE,
|
|
53
|
+
NODE_TYPE,
|
|
54
|
+
GROUP_TYPE,
|
|
55
|
+
RANGE_TYPE,
|
|
56
|
+
FRAMER_TYPE,
|
|
57
|
+
RANGE_ALIAS_TYPE,
|
|
58
|
+
USER_TYPE,
|
|
59
|
+
WORKSPACE_TYPE,
|
|
60
|
+
SCHEMATIC_TYPE,
|
|
61
|
+
LINE_PLOT_TYPE,
|
|
62
|
+
RACK_TYPE,
|
|
63
|
+
DEVICE_TYPE,
|
|
64
|
+
TASK_TYPE,
|
|
65
|
+
POLICY_TYPE,
|
|
66
|
+
TABLE_TYPE,
|
|
41
67
|
]);
|
|
42
68
|
export type ResourceType = z.infer<typeof resourceTypeZ>;
|
|
43
69
|
|
|
44
|
-
export const BUILTIN_TYPE: ResourceType = "builtin";
|
|
45
|
-
export const CLUSTER_TYPE: ResourceType = "cluster";
|
|
46
|
-
export const NODE_TYPE: ResourceType = "node";
|
|
47
|
-
|
|
48
70
|
export const idZ = z.object({ type: resourceTypeZ, key: z.string() });
|
|
49
|
-
export
|
|
71
|
+
export interface IDPayload extends z.infer<typeof idZ> {}
|
|
50
72
|
|
|
51
73
|
export const stringIDZ = z.string().transform((v) => {
|
|
52
74
|
const [type, key] = v.split(":");
|
|
@@ -95,19 +117,18 @@ export class ID {
|
|
|
95
117
|
static readonly z = z.union([z.instanceof(ID), crudeIDZ.transform((v) => new ID(v))]);
|
|
96
118
|
}
|
|
97
119
|
|
|
98
|
-
export const
|
|
120
|
+
export const ROOT_ID = new ID({ type: BUILTIN_TYPE, key: "root" });
|
|
99
121
|
|
|
100
122
|
export const schemaFieldZ = z.object({ type: z.number() });
|
|
101
|
-
|
|
102
|
-
export type SchemaField = z.infer<typeof schemaFieldZ>;
|
|
123
|
+
export interface SchemaField extends z.infer<typeof schemaFieldZ> {}
|
|
103
124
|
|
|
104
125
|
export const schemaZ = z.object({
|
|
105
126
|
type: resourceTypeZ,
|
|
106
127
|
fields: z.record(schemaFieldZ),
|
|
107
128
|
});
|
|
108
|
-
export
|
|
129
|
+
export interface Schema extends z.infer<typeof schemaZ> {}
|
|
109
130
|
|
|
110
|
-
export const
|
|
131
|
+
export const resourceZ = z
|
|
111
132
|
.object({
|
|
112
133
|
id: ID.z,
|
|
113
134
|
name: z.string(),
|
|
@@ -115,16 +136,19 @@ export const resourceSchemaZ = z
|
|
|
115
136
|
data: z.record(z.unknown()).optional().nullable(),
|
|
116
137
|
})
|
|
117
138
|
.transform((resource) => ({ key: resource.id.toString(), ...resource }));
|
|
139
|
+
export interface Resource<T extends UnknownRecord = UnknownRecord>
|
|
140
|
+
extends Omit<z.output<typeof resourceZ>, "data"> {
|
|
141
|
+
data?: T | null;
|
|
142
|
+
}
|
|
118
143
|
|
|
119
|
-
export
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
export type RelationshipDirection = "from" | "to";
|
|
144
|
+
export const TO_RELATIONSHIP_DIRECTION = "to";
|
|
145
|
+
export const FROM_RELATIONSHIP_DIRECTION = "from";
|
|
146
|
+
export type RelationshipDirection =
|
|
147
|
+
| typeof TO_RELATIONSHIP_DIRECTION
|
|
148
|
+
| typeof FROM_RELATIONSHIP_DIRECTION;
|
|
125
149
|
|
|
126
150
|
export const relationshipSchemaZ = z.object({ from: ID.z, type: z.string(), to: ID.z });
|
|
127
|
-
export
|
|
151
|
+
export interface Relationship extends z.infer<typeof relationshipSchemaZ> {}
|
|
128
152
|
|
|
129
153
|
export const parseRelationship = (str: string): Relationship => {
|
|
130
154
|
const [from, type, to] = str.split("->");
|
package/src/ontology/writer.ts
CHANGED
|
@@ -12,22 +12,15 @@ import { z } from "zod";
|
|
|
12
12
|
|
|
13
13
|
import { type CrudeID, ID, idZ } from "@/ontology/payload";
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
MOVE_CHILDREN: "/ontology/move-children",
|
|
19
|
-
};
|
|
15
|
+
const ADD_CHILDREN_ENDPOINT = "/ontology/add-children";
|
|
16
|
+
const REMOVE_CHILDREN_ENDPOINT = "/ontology/remove-children";
|
|
17
|
+
const MOVE_CHILDREN_ENDPOINT = "/ontology/move-children";
|
|
20
18
|
|
|
21
|
-
const addRemoveChildrenReqZ = z.object({
|
|
22
|
-
id: idZ,
|
|
23
|
-
children: idZ.array(),
|
|
24
|
-
});
|
|
19
|
+
const addRemoveChildrenReqZ = z.object({ id: idZ, children: idZ.array() });
|
|
25
20
|
|
|
26
|
-
const moveChildrenReqZ = z.object({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
children: idZ.array(),
|
|
30
|
-
});
|
|
21
|
+
const moveChildrenReqZ = z.object({ from: idZ, to: idZ, children: idZ.array() });
|
|
22
|
+
|
|
23
|
+
const emptyResZ = z.object({});
|
|
31
24
|
|
|
32
25
|
export class Writer {
|
|
33
26
|
client: UnaryClient;
|
|
@@ -37,22 +30,22 @@ export class Writer {
|
|
|
37
30
|
}
|
|
38
31
|
|
|
39
32
|
async addChildren(id: CrudeID, ...children: CrudeID[]): Promise<void> {
|
|
40
|
-
await sendRequired<typeof addRemoveChildrenReqZ,
|
|
33
|
+
await sendRequired<typeof addRemoveChildrenReqZ, typeof emptyResZ>(
|
|
41
34
|
this.client,
|
|
42
|
-
|
|
35
|
+
ADD_CHILDREN_ENDPOINT,
|
|
43
36
|
{ id: new ID(id).payload, children: children.map((c) => new ID(c).payload) },
|
|
44
37
|
addRemoveChildrenReqZ,
|
|
45
|
-
|
|
38
|
+
emptyResZ,
|
|
46
39
|
);
|
|
47
40
|
}
|
|
48
41
|
|
|
49
42
|
async removeChildren(id: CrudeID, ...children: CrudeID[]): Promise<void> {
|
|
50
|
-
await sendRequired<typeof addRemoveChildrenReqZ,
|
|
43
|
+
await sendRequired<typeof addRemoveChildrenReqZ, typeof emptyResZ>(
|
|
51
44
|
this.client,
|
|
52
|
-
|
|
45
|
+
REMOVE_CHILDREN_ENDPOINT,
|
|
53
46
|
{ id: new ID(id).payload, children: children.map((c) => new ID(c).payload) },
|
|
54
47
|
addRemoveChildrenReqZ,
|
|
55
|
-
|
|
48
|
+
emptyResZ,
|
|
56
49
|
);
|
|
57
50
|
}
|
|
58
51
|
|
|
@@ -66,12 +59,12 @@ export class Writer {
|
|
|
66
59
|
to: new ID(to).payload,
|
|
67
60
|
children: children.map((c) => new ID(c).payload),
|
|
68
61
|
};
|
|
69
|
-
await sendRequired(
|
|
62
|
+
await sendRequired<typeof moveChildrenReqZ, typeof emptyResZ>(
|
|
70
63
|
this.client,
|
|
71
|
-
|
|
64
|
+
MOVE_CHILDREN_ENDPOINT,
|
|
72
65
|
req,
|
|
73
66
|
moveChildrenReqZ,
|
|
74
|
-
|
|
67
|
+
emptyResZ,
|
|
75
68
|
);
|
|
76
69
|
}
|
|
77
70
|
}
|
package/src/ranger/alias.ts
CHANGED
|
@@ -11,73 +11,60 @@ import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
|
11
11
|
import { type change } from "@synnaxlabs/x/change";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
import { type
|
|
16
|
-
import { type Client as FrameClient } from "@/framer/client";
|
|
14
|
+
import { channel } from "@/channel";
|
|
15
|
+
import { type framer } from "@/framer";
|
|
17
16
|
import { type Key, keyZ } from "@/ranger/payload";
|
|
18
17
|
import { signals } from "@/signals";
|
|
19
18
|
|
|
20
|
-
export const
|
|
21
|
-
export const
|
|
19
|
+
export const SET_ALIAS_CHANNEL_NAME = "sy_range_alias_set";
|
|
20
|
+
export const DELETE_ALIAS_CHANNEL_NAME = "sy_range_alias_delete";
|
|
22
21
|
|
|
23
|
-
const resolveReqZ = z.object({
|
|
24
|
-
range: keyZ,
|
|
25
|
-
aliases: z.string().array(),
|
|
26
|
-
});
|
|
22
|
+
const resolveReqZ = z.object({ range: keyZ, aliases: z.string().array() });
|
|
27
23
|
|
|
28
|
-
const resolveResZ = z.object({
|
|
29
|
-
aliases: z.record(z.string(), channelKeyZ),
|
|
30
|
-
});
|
|
24
|
+
const resolveResZ = z.object({ aliases: z.record(z.string(), channel.keyZ) });
|
|
31
25
|
|
|
32
26
|
const setReqZ = z.object({
|
|
33
27
|
range: keyZ,
|
|
34
|
-
aliases: z.record(
|
|
28
|
+
aliases: z.record(channel.keyZ.or(z.string()), z.string()),
|
|
35
29
|
});
|
|
36
30
|
|
|
37
31
|
const setResZ = z.unknown();
|
|
38
32
|
|
|
39
|
-
const deleteReqZ = z.object({
|
|
40
|
-
range: keyZ,
|
|
41
|
-
channels: channelKeyZ.array(),
|
|
42
|
-
});
|
|
33
|
+
const deleteReqZ = z.object({ range: keyZ, channels: channel.keyZ.array() });
|
|
43
34
|
|
|
44
35
|
const deleteResZ = z.unknown();
|
|
45
36
|
|
|
46
|
-
const listReqZ = z.object({
|
|
47
|
-
range: keyZ,
|
|
48
|
-
});
|
|
37
|
+
const listReqZ = z.object({ range: keyZ });
|
|
49
38
|
|
|
50
|
-
const listResZ = z.object({
|
|
51
|
-
aliases: z.record(z.string(), z.string()),
|
|
52
|
-
});
|
|
39
|
+
const listResZ = z.object({ aliases: z.record(z.string(), z.string()) });
|
|
53
40
|
|
|
54
41
|
export class Aliaser {
|
|
55
42
|
private static readonly SET_ENDPOINT = "/range/alias/set";
|
|
56
43
|
private static readonly RESOLVE_ENDPOINT = "/range/alias/resolve";
|
|
57
44
|
private static readonly LIST_ENDPOINT = "/range/alias/list";
|
|
58
45
|
private static readonly DELETE_ENDPOINT = "/range/alias/delete";
|
|
59
|
-
private readonly frameClient:
|
|
60
|
-
private readonly cache = new Map<string,
|
|
46
|
+
private readonly frameClient: framer.Client;
|
|
47
|
+
private readonly cache = new Map<string, channel.Key>();
|
|
61
48
|
private readonly client: UnaryClient;
|
|
62
49
|
private readonly rangeKey: Key;
|
|
63
50
|
|
|
64
|
-
constructor(rangeKey: Key, frameClient:
|
|
51
|
+
constructor(rangeKey: Key, frameClient: framer.Client, client: UnaryClient) {
|
|
65
52
|
this.rangeKey = rangeKey;
|
|
66
53
|
this.cache = new Map();
|
|
67
54
|
this.client = client;
|
|
68
55
|
this.frameClient = frameClient;
|
|
69
56
|
}
|
|
70
57
|
|
|
71
|
-
resolve(aliases: string): Promise<
|
|
58
|
+
resolve(aliases: string): Promise<channel.Key>;
|
|
72
59
|
|
|
73
|
-
resolve(aliases: string[]): Promise<Record<string,
|
|
60
|
+
resolve(aliases: string[]): Promise<Record<string, channel.Key>>;
|
|
74
61
|
|
|
75
62
|
async resolve(
|
|
76
63
|
aliases: string | string[],
|
|
77
|
-
): Promise<
|
|
64
|
+
): Promise<channel.Key | Record<string, channel.Key>> {
|
|
78
65
|
const toFetch: string[] = [];
|
|
79
66
|
const isSingle = typeof aliases === "string";
|
|
80
|
-
const cached: Record<string,
|
|
67
|
+
const cached: Record<string, channel.Key> = {};
|
|
81
68
|
if (isSingle) {
|
|
82
69
|
const c = this.cache.get(aliases);
|
|
83
70
|
if (c != null) return c;
|
|
@@ -100,7 +87,7 @@ export class Aliaser {
|
|
|
100
87
|
return isSingle ? res.aliases[toFetch[0]] : { ...cached, ...res.aliases };
|
|
101
88
|
}
|
|
102
89
|
|
|
103
|
-
async set(aliases: Record<
|
|
90
|
+
async set(aliases: Record<channel.Key, string>): Promise<void> {
|
|
104
91
|
await sendRequired<typeof setReqZ, typeof setResZ>(
|
|
105
92
|
this.client,
|
|
106
93
|
Aliaser.SET_ENDPOINT,
|
|
@@ -110,7 +97,7 @@ export class Aliaser {
|
|
|
110
97
|
);
|
|
111
98
|
}
|
|
112
99
|
|
|
113
|
-
async list(): Promise<Record<
|
|
100
|
+
async list(): Promise<Record<channel.Key, string>> {
|
|
114
101
|
return (
|
|
115
102
|
await sendRequired<typeof listReqZ, typeof listResZ>(
|
|
116
103
|
this.client,
|
|
@@ -122,7 +109,7 @@ export class Aliaser {
|
|
|
122
109
|
).aliases;
|
|
123
110
|
}
|
|
124
111
|
|
|
125
|
-
async delete(aliases:
|
|
112
|
+
async delete(aliases: channel.Key[]): Promise<void> {
|
|
126
113
|
await sendRequired<typeof deleteReqZ, typeof deleteResZ>(
|
|
127
114
|
this.client,
|
|
128
115
|
Aliaser.DELETE_ENDPOINT,
|
|
@@ -135,8 +122,8 @@ export class Aliaser {
|
|
|
135
122
|
async openChangeTracker(): Promise<signals.Observable<string, Alias>> {
|
|
136
123
|
return await signals.openObservable<string, Alias>(
|
|
137
124
|
this.frameClient,
|
|
138
|
-
|
|
139
|
-
|
|
125
|
+
SET_ALIAS_CHANNEL_NAME,
|
|
126
|
+
DELETE_ALIAS_CHANNEL_NAME,
|
|
140
127
|
decodeAliasChanges(this.rangeKey),
|
|
141
128
|
);
|
|
142
129
|
}
|
|
@@ -150,13 +137,9 @@ export interface Alias {
|
|
|
150
137
|
|
|
151
138
|
export type AliasChange = change.Change<string, Alias>;
|
|
152
139
|
|
|
153
|
-
const aliasZ = z.object({
|
|
154
|
-
range: keyZ,
|
|
155
|
-
channel: channelKeyZ,
|
|
156
|
-
alias: z.string(),
|
|
157
|
-
});
|
|
140
|
+
const aliasZ = z.object({ range: keyZ, channel: channel.keyZ, alias: z.string() });
|
|
158
141
|
|
|
159
|
-
const
|
|
142
|
+
const separator = "---";
|
|
160
143
|
|
|
161
144
|
const decodeAliasChanges =
|
|
162
145
|
(rangeKey: Key): signals.Decoder<string, Alias> =>
|
|
@@ -164,7 +147,7 @@ const decodeAliasChanges =
|
|
|
164
147
|
if (variant === "delete")
|
|
165
148
|
return data
|
|
166
149
|
.toStrings()
|
|
167
|
-
.filter((k) => k.split(
|
|
150
|
+
.filter((k) => k.split(separator)[0] === rangeKey)
|
|
168
151
|
.map((alias) => ({
|
|
169
152
|
variant,
|
|
170
153
|
key: alias,
|