@synnaxlabs/client 0.16.4 → 0.17.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 +5 -5
- package/dist/auth/auth.d.ts +2 -2
- package/dist/client.cjs +11 -11
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +14 -4
- package/dist/client.js +5437 -5436
- package/dist/client.js.map +1 -1
- package/dist/framer/frame.d.ts +280 -24
- package/dist/framer/writer.d.ts +203 -15
- package/dist/hardware/rack/client.d.ts +1 -1
- package/dist/hardware/task/payload.d.ts +5 -5
- package/dist/ontology/retriever.d.ts +1 -1
- package/dist/ranger/active.d.ts +1 -1
- package/dist/ranger/payload.d.ts +308 -20
- package/dist/workspace/client.d.ts +2 -2
- package/dist/workspace/lineplot/client.d.ts +2 -2
- package/dist/workspace/lineplot/payload.d.ts +3 -16
- package/dist/workspace/lineplot/retriever.d.ts +0 -1
- package/dist/workspace/lineplot/writer.d.ts +9 -14
- package/dist/workspace/payload.d.ts +3 -3
- package/dist/workspace/pid/client.d.ts +2 -2
- package/dist/workspace/pid/payload.d.ts +3 -3
- package/dist/workspace/pid/retriever.d.ts +0 -1
- package/dist/workspace/pid/writer.d.ts +12 -18
- package/dist/workspace/writer.d.ts +14 -6
- package/examples/node/basicReadWriter.js +34 -5
- package/examples/node/package-lock.json +23 -23
- package/examples/node/package.json +1 -1
- package/package.json +3 -3
- package/src/auth/auth.ts +5 -4
- package/src/channel/client.ts +0 -1
- package/src/channel/creator.ts +1 -0
- package/src/channel/retriever.ts +2 -2
- package/src/client.ts +2 -2
- package/src/connection/checker.ts +1 -1
- package/src/framer/client.ts +1 -1
- package/src/framer/frame.ts +4 -4
- package/src/hardware/device/retriever.ts +3 -3
- package/src/hardware/device/writer.ts +3 -1
- package/src/hardware/rack/client.ts +3 -4
- package/src/hardware/rack/retriever.ts +3 -0
- package/src/hardware/rack/writer.ts +2 -0
- package/src/hardware/task/payload.ts +5 -4
- package/src/hardware/task/retriever.ts +10 -7
- package/src/hardware/task/writer.ts +3 -1
- package/src/label/retriever.ts +1 -0
- package/src/label/writer.ts +4 -0
- package/src/ontology/group/writer.ts +18 -5
- package/src/ontology/retriever.ts +9 -9
- package/src/ontology/writer.ts +25 -11
- package/src/ranger/active.ts +26 -8
- package/src/ranger/alias.ts +9 -13
- package/src/ranger/client.ts +0 -1
- package/src/ranger/kv.ts +4 -1
- package/src/ranger/retriever.ts +1 -1
- package/src/ranger/writer.ts +3 -0
- package/src/workspace/client.ts +3 -3
- package/src/workspace/lineplot/client.ts +2 -2
- package/src/workspace/lineplot/payload.ts +1 -7
- package/src/workspace/lineplot/retriever.ts +10 -11
- package/src/workspace/lineplot/writer.ts +13 -8
- package/src/workspace/payload.ts +1 -1
- package/src/workspace/pid/client.ts +2 -2
- package/src/workspace/pid/payload.ts +1 -1
- package/src/workspace/pid/retriever.ts +8 -10
- package/src/workspace/pid/writer.ts +12 -5
- package/src/workspace/retriever.ts +2 -4
- package/src/workspace/workspace.spec.ts +4 -4
- package/src/workspace/writer.ts +12 -10
|
@@ -11,12 +11,26 @@ import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
13
|
import { type Payload, payloadZ } from "@/ontology/group/payload";
|
|
14
|
-
import { type ID } from "@/ontology/payload";
|
|
14
|
+
import { idZ, type ID } from "@/ontology/payload";
|
|
15
15
|
|
|
16
16
|
const resZ = z.object({
|
|
17
17
|
group: payloadZ,
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
+
const createReqZ = z.object({
|
|
21
|
+
parent: idZ,
|
|
22
|
+
name: z.string(),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const renameReqZ = z.object({
|
|
26
|
+
key: z.string(),
|
|
27
|
+
name: z.string(),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const deleteReqZ = z.object({
|
|
31
|
+
keys: z.array(z.string()),
|
|
32
|
+
});
|
|
33
|
+
|
|
20
34
|
export class Writer {
|
|
21
35
|
private static readonly ENDPOINT = "/ontology/create-group";
|
|
22
36
|
private static readonly ENDPOINT_RENAME = "/ontology/rename-group";
|
|
@@ -28,21 +42,20 @@ export class Writer {
|
|
|
28
42
|
}
|
|
29
43
|
|
|
30
44
|
async create(parent: ID, name: string): Promise<Payload> {
|
|
31
|
-
const
|
|
32
|
-
const [res, err] = await this.client.send(Writer.ENDPOINT, req, resZ);
|
|
45
|
+
const [res, err] = await this.client.send(Writer.ENDPOINT, {parent, name},createReqZ, resZ);
|
|
33
46
|
if (err != null) throw err;
|
|
34
47
|
return res.group;
|
|
35
48
|
}
|
|
36
49
|
|
|
37
50
|
async rename(key: string, name: string): Promise<void> {
|
|
38
51
|
const req = { key, name };
|
|
39
|
-
const [, err] = await this.client.send(Writer.ENDPOINT_RENAME, req, z.object({}));
|
|
52
|
+
const [, err] = await this.client.send(Writer.ENDPOINT_RENAME, req, renameReqZ, z.object({}));
|
|
40
53
|
if (err != null) throw err;
|
|
41
54
|
}
|
|
42
55
|
|
|
43
56
|
async delete(keys: string[]): Promise<void> {
|
|
44
57
|
const req = { keys };
|
|
45
|
-
const [, err] = await this.client.send(Writer.ENDPOINT_DELETE, req, z.object({}));
|
|
58
|
+
const [, err] = await this.client.send(Writer.ENDPOINT_DELETE, req, deleteReqZ, z.object({}));
|
|
46
59
|
if (err != null) throw err;
|
|
47
60
|
}
|
|
48
61
|
}
|
|
@@ -7,13 +7,13 @@
|
|
|
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
|
|
10
|
+
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { toArray } from "@synnaxlabs/x";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
14
14
|
import { ID, type Resource, idZ, resourceSchemaZ } from "@/ontology/payload";
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const reqZ = z.object({
|
|
17
17
|
ids: idZ.array().optional(),
|
|
18
18
|
children: z.boolean().optional(),
|
|
19
19
|
parents: z.boolean().optional(),
|
|
@@ -22,9 +22,9 @@ const requestSchema = z.object({
|
|
|
22
22
|
term: z.string().optional(),
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
type Request = z.infer<typeof
|
|
25
|
+
type Request = z.infer<typeof reqZ>;
|
|
26
26
|
|
|
27
|
-
const
|
|
27
|
+
const resZ = z.object({
|
|
28
28
|
resources: resourceSchemaZ.array(),
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -80,12 +80,12 @@ export class Retriever {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
private async execute(request: Request): Promise<Resource[]> {
|
|
83
|
-
|
|
83
|
+
return (await sendRequired(
|
|
84
|
+
this.client,
|
|
84
85
|
Retriever.ENDPOINT,
|
|
85
86
|
request,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return res.resources;
|
|
87
|
+
reqZ,
|
|
88
|
+
resZ,
|
|
89
|
+
)).resources;
|
|
90
90
|
}
|
|
91
91
|
}
|
package/src/ontology/writer.ts
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
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
|
+
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
|
-
import { type ID } from "@/ontology/payload";
|
|
13
|
+
import { idZ, type ID } from "@/ontology/payload";
|
|
14
14
|
|
|
15
15
|
const ENDPOINTS = {
|
|
16
16
|
ADD_CHILDREN: "/ontology/add-children",
|
|
@@ -18,6 +18,17 @@ const ENDPOINTS = {
|
|
|
18
18
|
MOVE_CHILDREN: "/ontology/move-children",
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
const addRemoveChildrenReqZ = z.object({
|
|
22
|
+
id: idZ,
|
|
23
|
+
children: idZ.array(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const moveChildrenReqZ = z.object({
|
|
27
|
+
from: idZ,
|
|
28
|
+
to: idZ,
|
|
29
|
+
children: idZ.array(),
|
|
30
|
+
});
|
|
31
|
+
|
|
21
32
|
export class Writer {
|
|
22
33
|
client: UnaryClient;
|
|
23
34
|
|
|
@@ -26,24 +37,27 @@ export class Writer {
|
|
|
26
37
|
}
|
|
27
38
|
|
|
28
39
|
async addChildren(id: ID, ...children: ID[]): Promise<void> {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
await sendRequired<typeof addRemoveChildrenReqZ, z.ZodTypeAny>(
|
|
41
|
+
this.client,
|
|
42
|
+
ENDPOINTS.ADD_CHILDREN,
|
|
43
|
+
{ id, children },
|
|
44
|
+
addRemoveChildrenReqZ,
|
|
45
|
+
z.object({})
|
|
46
|
+
);
|
|
32
47
|
}
|
|
33
48
|
|
|
34
49
|
async removeChildren(id: ID, ...children: ID[]): Promise<void> {
|
|
35
|
-
|
|
36
|
-
|
|
50
|
+
await sendRequired<typeof addRemoveChildrenReqZ, z.ZodTypeAny>(
|
|
51
|
+
this.client,
|
|
37
52
|
ENDPOINTS.REMOVE_CHILDREN,
|
|
38
|
-
|
|
53
|
+
{ id, children },
|
|
54
|
+
addRemoveChildrenReqZ,
|
|
39
55
|
z.object({}),
|
|
40
56
|
);
|
|
41
|
-
if (err != null) throw err;
|
|
42
57
|
}
|
|
43
58
|
|
|
44
59
|
async moveChildren(from: ID, to: ID, ...children: ID[]): Promise<void> {
|
|
45
60
|
const req = { from, to, children };
|
|
46
|
-
|
|
47
|
-
if (err != null) throw err;
|
|
61
|
+
await sendRequired(this.client, ENDPOINTS.MOVE_CHILDREN, req, moveChildrenReqZ, z.object({}));
|
|
48
62
|
}
|
|
49
63
|
}
|
package/src/ranger/active.ts
CHANGED
|
@@ -7,12 +7,11 @@
|
|
|
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
|
+
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
|
-
import { QueryError } from "
|
|
14
|
-
|
|
15
|
-
import { type Payload, payloadZ, type Key } from "./payload";
|
|
13
|
+
import { QueryError } from "@/errors";
|
|
14
|
+
import { type Payload, payloadZ, type Key, keyZ } from "@/ranger/payload";
|
|
16
15
|
|
|
17
16
|
const setActiveResZ = z.object({});
|
|
18
17
|
|
|
@@ -20,6 +19,14 @@ const retrieveActiveResZ = z.object({
|
|
|
20
19
|
range: payloadZ,
|
|
21
20
|
});
|
|
22
21
|
|
|
22
|
+
const setActiveReqZ = z.object({
|
|
23
|
+
range: keyZ,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const clearActiveReqZ = z.object({
|
|
27
|
+
range: keyZ,
|
|
28
|
+
});
|
|
29
|
+
|
|
23
30
|
const clearActiveResZ = z.object({});
|
|
24
31
|
|
|
25
32
|
const SET_ENDPOINT = "/range/set-active";
|
|
@@ -34,14 +41,20 @@ export class Active {
|
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
async setActive(range: Key): Promise<void> {
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
await sendRequired<typeof setActiveReqZ, typeof setActiveResZ>(
|
|
45
|
+
this.client,
|
|
46
|
+
SET_ENDPOINT,
|
|
47
|
+
{ range },
|
|
48
|
+
setActiveReqZ,
|
|
49
|
+
setActiveResZ,
|
|
50
|
+
);
|
|
39
51
|
}
|
|
40
52
|
|
|
41
53
|
async retrieveActive(): Promise<Payload | null> {
|
|
42
54
|
const [res, err] = await this.client.send(
|
|
43
55
|
RETRIEVE_ENDPOINT,
|
|
44
56
|
{},
|
|
57
|
+
z.object({}),
|
|
45
58
|
retrieveActiveResZ,
|
|
46
59
|
);
|
|
47
60
|
if (err instanceof QueryError) return null;
|
|
@@ -50,7 +63,12 @@ export class Active {
|
|
|
50
63
|
}
|
|
51
64
|
|
|
52
65
|
async clearActive(range: Key): Promise<void> {
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
await sendRequired<typeof clearActiveReqZ, typeof clearActiveResZ>(
|
|
67
|
+
this.client,
|
|
68
|
+
CLEAR_ENDPOINT,
|
|
69
|
+
{ range },
|
|
70
|
+
clearActiveReqZ,
|
|
71
|
+
clearActiveResZ,
|
|
72
|
+
);
|
|
55
73
|
}
|
|
56
74
|
}
|
package/src/ranger/alias.ts
CHANGED
|
@@ -31,7 +31,7 @@ const resolveResZ = z.object({
|
|
|
31
31
|
|
|
32
32
|
const setReqZ = z.object({
|
|
33
33
|
range: keyZ,
|
|
34
|
-
aliases: z.record(channelKeyZ, z.string()),
|
|
34
|
+
aliases: z.record(channelKeyZ.or(z.string()), z.string()),
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
const setResZ = z.unknown();
|
|
@@ -93,6 +93,7 @@ export class Aliaser {
|
|
|
93
93
|
this.client,
|
|
94
94
|
Aliaser.RESOLVE_ENDPOINT,
|
|
95
95
|
{ range: this.rangeKey, aliases: toFetch },
|
|
96
|
+
resolveReqZ,
|
|
96
97
|
resolveResZ,
|
|
97
98
|
);
|
|
98
99
|
Object.entries(res.aliases).forEach(([alias, key]) => this.cache.set(alias, key));
|
|
@@ -103,11 +104,9 @@ export class Aliaser {
|
|
|
103
104
|
await sendRequired<typeof setReqZ, typeof setResZ>(
|
|
104
105
|
this.client,
|
|
105
106
|
Aliaser.SET_ENDPOINT,
|
|
106
|
-
{
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
},
|
|
110
|
-
z.unknown(),
|
|
107
|
+
{ range: this.rangeKey, aliases },
|
|
108
|
+
setReqZ,
|
|
109
|
+
setResZ,
|
|
111
110
|
);
|
|
112
111
|
}
|
|
113
112
|
|
|
@@ -116,9 +115,8 @@ export class Aliaser {
|
|
|
116
115
|
await sendRequired<typeof listReqZ, typeof listResZ>(
|
|
117
116
|
this.client,
|
|
118
117
|
Aliaser.LIST_ENDPOINT,
|
|
119
|
-
{
|
|
120
|
-
|
|
121
|
-
},
|
|
118
|
+
{ range: this.rangeKey },
|
|
119
|
+
listReqZ,
|
|
122
120
|
listResZ,
|
|
123
121
|
)
|
|
124
122
|
).aliases;
|
|
@@ -128,10 +126,8 @@ export class Aliaser {
|
|
|
128
126
|
await sendRequired<typeof deleteReqZ, typeof deleteResZ>(
|
|
129
127
|
this.client,
|
|
130
128
|
Aliaser.DELETE_ENDPOINT,
|
|
131
|
-
{
|
|
132
|
-
|
|
133
|
-
channels: aliases,
|
|
134
|
-
},
|
|
129
|
+
{ range: this.rangeKey, channels: aliases },
|
|
130
|
+
deleteReqZ,
|
|
135
131
|
deleteResZ,
|
|
136
132
|
);
|
|
137
133
|
}
|
package/src/ranger/client.ts
CHANGED
|
@@ -14,7 +14,6 @@ import { type Retriever as ChannelRetriever } from "@/channel/retriever";
|
|
|
14
14
|
import { QueryError } from "@/errors";
|
|
15
15
|
import { type framer } from "@/framer";
|
|
16
16
|
import { type label } from "@/label";
|
|
17
|
-
import { type ontology } from "@/ontology";
|
|
18
17
|
import { Active } from "@/ranger/active";
|
|
19
18
|
import { Aliaser } from "@/ranger/alias";
|
|
20
19
|
import { KV } from "@/ranger/kv";
|
package/src/ranger/kv.ts
CHANGED
|
@@ -58,6 +58,7 @@ export class KV {
|
|
|
58
58
|
const [res, err] = await this.client.send(
|
|
59
59
|
KV.GET_ENDPOINT,
|
|
60
60
|
{ range: this.rangeKey, keys: toArray(keys) },
|
|
61
|
+
getReqZ,
|
|
61
62
|
getResZ,
|
|
62
63
|
);
|
|
63
64
|
if (err != null) throw err;
|
|
@@ -68,7 +69,7 @@ export class KV {
|
|
|
68
69
|
|
|
69
70
|
async set(kv: Record<string, string>): Promise<void>;
|
|
70
71
|
|
|
71
|
-
async set(key: string | Record<string, string>, value
|
|
72
|
+
async set(key: string | Record<string, string>, value: string = ""): Promise<void> {
|
|
72
73
|
await sendRequired(
|
|
73
74
|
this.client,
|
|
74
75
|
KV.SET_ENDPOINT,
|
|
@@ -76,6 +77,7 @@ export class KV {
|
|
|
76
77
|
range: this.rangeKey,
|
|
77
78
|
pairs: isObject(key) ? key : { [key]: value },
|
|
78
79
|
},
|
|
80
|
+
setReqZ,
|
|
79
81
|
z.unknown(),
|
|
80
82
|
);
|
|
81
83
|
}
|
|
@@ -85,6 +87,7 @@ export class KV {
|
|
|
85
87
|
this.client,
|
|
86
88
|
KV.DELETE_ENDPOINT,
|
|
87
89
|
{ range: this.rangeKey, keys: toArray(key) },
|
|
90
|
+
deleteReqZ,
|
|
88
91
|
z.unknown(),
|
|
89
92
|
);
|
|
90
93
|
}
|
package/src/ranger/retriever.ts
CHANGED
|
@@ -43,7 +43,7 @@ export class Retriever {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
private async execute(request: Request): Promise<Payload[]> {
|
|
46
|
-
const [res, err] = await this.client.send(this.ENDPOINT, request, resZ);
|
|
46
|
+
const [res, err] = await this.client.send(this.ENDPOINT, request, reqZ, resZ);
|
|
47
47
|
if (err != null) throw err;
|
|
48
48
|
return res.ranges;
|
|
49
49
|
}
|
package/src/ranger/writer.ts
CHANGED
|
@@ -55,6 +55,7 @@ export class Writer {
|
|
|
55
55
|
this.client,
|
|
56
56
|
RENAME_ENDPOINT,
|
|
57
57
|
{ key, name },
|
|
58
|
+
renameReqZ,
|
|
58
59
|
renameResZ,
|
|
59
60
|
);
|
|
60
61
|
}
|
|
@@ -64,6 +65,7 @@ export class Writer {
|
|
|
64
65
|
this.client,
|
|
65
66
|
CREATE_ENDPOINT,
|
|
66
67
|
{ ranges },
|
|
68
|
+
createReqZ,
|
|
67
69
|
createResZ,
|
|
68
70
|
);
|
|
69
71
|
return res.ranges;
|
|
@@ -74,6 +76,7 @@ export class Writer {
|
|
|
74
76
|
this.client,
|
|
75
77
|
DELETE_ENDPOINT,
|
|
76
78
|
{ keys },
|
|
79
|
+
deleteReqZ,
|
|
77
80
|
deleteResZ,
|
|
78
81
|
);
|
|
79
82
|
}
|
package/src/workspace/client.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { linePlot } from "@/workspace/lineplot";
|
|
|
14
14
|
import { type Key, type Workspace } from "@/workspace/payload";
|
|
15
15
|
import { pid } from "@/workspace/pid";
|
|
16
16
|
import { Retriever } from "@/workspace/retriever";
|
|
17
|
-
import { type
|
|
17
|
+
import { type NewWorkspace, Writer } from "@/workspace/writer";
|
|
18
18
|
|
|
19
19
|
export class Client implements AsyncTermSearcher<string, Key, Workspace> {
|
|
20
20
|
readonly pid: pid.Client;
|
|
@@ -51,10 +51,10 @@ export class Client implements AsyncTermSearcher<string, Key, Workspace> {
|
|
|
51
51
|
return await this.retriever.page(offset, limit);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
async create(workspace:
|
|
54
|
+
async create(workspace: NewWorkspace): Promise<Workspace>;
|
|
55
55
|
|
|
56
56
|
async create(
|
|
57
|
-
workspaces:
|
|
57
|
+
workspaces: NewWorkspace | NewWorkspace[],
|
|
58
58
|
): Promise<Workspace | Workspace[]> {
|
|
59
59
|
const isMany = Array.isArray(workspaces);
|
|
60
60
|
const res = await this.writer.create(workspaces);
|
|
@@ -12,7 +12,7 @@ import { type UnknownRecord } from "@synnaxlabs/x";
|
|
|
12
12
|
|
|
13
13
|
import { type LinePlot, type Key, type Params } from "@/workspace/lineplot/payload";
|
|
14
14
|
import { Retriever } from "@/workspace/lineplot/retriever";
|
|
15
|
-
import { type
|
|
15
|
+
import { type NewLinePlot, Writer } from "@/workspace/lineplot/writer";
|
|
16
16
|
|
|
17
17
|
export class Client {
|
|
18
18
|
private readonly writer: Writer;
|
|
@@ -23,7 +23,7 @@ export class Client {
|
|
|
23
23
|
this.retriever = new Retriever(client);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
async create(workspace: string, pid:
|
|
26
|
+
async create(workspace: string, pid: NewLinePlot): Promise<LinePlot> {
|
|
27
27
|
return await this.writer.create(workspace, pid);
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -17,13 +17,7 @@ export type Params = Key | Key[];
|
|
|
17
17
|
export const linePlotZ = z.object({
|
|
18
18
|
key: z.string(),
|
|
19
19
|
name: z.string(),
|
|
20
|
-
data: unknownRecordZ,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export const linePlotRemoteZ = z.object({
|
|
24
|
-
key: z.string(),
|
|
25
|
-
name: z.string(),
|
|
26
|
-
data: z.string().transform((s) => JSON.parse(s) as UnknownRecord),
|
|
20
|
+
data: unknownRecordZ.or(z.string().transform((s) => JSON.parse(s) as UnknownRecord)),
|
|
27
21
|
});
|
|
28
22
|
|
|
29
23
|
export type LinePlot = z.infer<typeof linePlotZ>;
|
|
@@ -7,14 +7,14 @@
|
|
|
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
|
+
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { toArray } from "@synnaxlabs/x";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
15
|
type LinePlot,
|
|
16
16
|
type Params,
|
|
17
|
-
|
|
17
|
+
linePlotZ,
|
|
18
18
|
} from "@/workspace/lineplot/payload";
|
|
19
19
|
|
|
20
20
|
const reqZ = z.object({
|
|
@@ -24,7 +24,7 @@ const reqZ = z.object({
|
|
|
24
24
|
type Request = z.infer<typeof reqZ>;
|
|
25
25
|
|
|
26
26
|
const resZ = z.object({
|
|
27
|
-
linePlots:
|
|
27
|
+
linePlots: linePlotZ.array(),
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
export class Retriever {
|
|
@@ -37,13 +37,12 @@ export class Retriever {
|
|
|
37
37
|
|
|
38
38
|
async retrieve(params: Params): Promise<LinePlot[]> {
|
|
39
39
|
const normalized = toArray(params);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return res.linePlots;
|
|
40
|
+
return (await sendRequired(
|
|
41
|
+
this.client,
|
|
42
|
+
this.ENDPOINT,
|
|
43
|
+
{ keys: normalized },
|
|
44
|
+
reqZ,
|
|
45
|
+
resZ
|
|
46
|
+
)).linePlots;
|
|
48
47
|
}
|
|
49
48
|
}
|
|
@@ -17,22 +17,23 @@ import {
|
|
|
17
17
|
type Params,
|
|
18
18
|
keyZ,
|
|
19
19
|
type Key,
|
|
20
|
-
linePlotRemoteZ,
|
|
21
20
|
} from "@/workspace/lineplot/payload";
|
|
22
21
|
import { keyZ as workspaceKeyZ } from "@/workspace/payload";
|
|
23
22
|
|
|
24
|
-
export const
|
|
25
|
-
|
|
23
|
+
export const newLinePlotZ = linePlotZ.partial({ key: true }).transform((p) => ({
|
|
24
|
+
...p,
|
|
25
|
+
data: JSON.stringify(p.data),
|
|
26
|
+
}));
|
|
26
27
|
|
|
27
|
-
export type
|
|
28
|
+
export type NewLinePlot = z.input<typeof newLinePlotZ>;
|
|
28
29
|
|
|
29
30
|
const createReqZ = z.object({
|
|
30
31
|
workspace: workspaceKeyZ,
|
|
31
|
-
linePlots:
|
|
32
|
+
linePlots: newLinePlotZ.array(),
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
const createResZ = z.object({
|
|
35
|
-
linePlots:
|
|
36
|
+
linePlots: linePlotZ.array(),
|
|
36
37
|
});
|
|
37
38
|
|
|
38
39
|
const deleteReqZ = z.object({
|
|
@@ -67,12 +68,13 @@ export class Writer {
|
|
|
67
68
|
this.client = client;
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
async create(workspace: string, plot:
|
|
71
|
+
async create(workspace: string, plot: NewLinePlot): Promise<LinePlot> {
|
|
71
72
|
const pid_ = { ...plot, data: JSON.stringify(plot.data) };
|
|
72
73
|
const res = await sendRequired<typeof createReqZ, typeof createResZ>(
|
|
73
74
|
this.client,
|
|
74
75
|
CREATE_ENDPOINT,
|
|
75
76
|
{ workspace, linePlots: [pid_] },
|
|
77
|
+
createReqZ,
|
|
76
78
|
createResZ,
|
|
77
79
|
);
|
|
78
80
|
|
|
@@ -85,6 +87,7 @@ export class Writer {
|
|
|
85
87
|
this.client,
|
|
86
88
|
DELETE_ENDPOINT,
|
|
87
89
|
{ keys: normalized },
|
|
90
|
+
deleteReqZ,
|
|
88
91
|
deleteResZ,
|
|
89
92
|
);
|
|
90
93
|
}
|
|
@@ -94,6 +97,7 @@ export class Writer {
|
|
|
94
97
|
this.client,
|
|
95
98
|
RENAME_ENDPOINT,
|
|
96
99
|
{ key: pid, name },
|
|
100
|
+
renameReqZ,
|
|
97
101
|
renameResZ,
|
|
98
102
|
);
|
|
99
103
|
}
|
|
@@ -103,7 +107,8 @@ export class Writer {
|
|
|
103
107
|
this.client,
|
|
104
108
|
SET_DATA_ENDPOINT,
|
|
105
109
|
{ key: pid, data: JSON.stringify(data) },
|
|
106
|
-
|
|
110
|
+
setDataReqZ,
|
|
111
|
+
setDataResZ,
|
|
107
112
|
);
|
|
108
113
|
}
|
|
109
114
|
}
|
package/src/workspace/payload.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type Params = Key | Key[];
|
|
|
19
19
|
export const workspaceZ = z.object({
|
|
20
20
|
name: z.string(),
|
|
21
21
|
key: keyZ,
|
|
22
|
-
layout: unknownRecordZ,
|
|
22
|
+
layout: unknownRecordZ.or(z.string().transform((s) => JSON.parse(s) as UnknownRecord)),
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
export const workspaceRemoteZ = workspaceZ.omit({ layout: true }).extend({
|
|
@@ -12,7 +12,7 @@ import { type UnknownRecord } from "@synnaxlabs/x";
|
|
|
12
12
|
|
|
13
13
|
import { type Key, type Params, type PID } from "@/workspace/pid/payload";
|
|
14
14
|
import { Retriever } from "@/workspace/pid/retriever";
|
|
15
|
-
import { Writer, type
|
|
15
|
+
import { Writer, type NewPID } from "@/workspace/pid/writer";
|
|
16
16
|
|
|
17
17
|
export class Client {
|
|
18
18
|
private readonly writer: Writer;
|
|
@@ -23,7 +23,7 @@ export class Client {
|
|
|
23
23
|
this.retriever = new Retriever(client);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
async create(workspace: string, pid:
|
|
26
|
+
async create(workspace: string, pid: NewPID): Promise<PID> {
|
|
27
27
|
return await this.writer.create(workspace, pid);
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
|
-
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
10
|
+
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { toArray } from "@synnaxlabs/x";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
@@ -32,14 +32,12 @@ export class Retriever {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
async retrieve(params: Params): Promise<PID[]> {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (err != null) throw err;
|
|
43
|
-
return res.pids;
|
|
35
|
+
return (await sendRequired(
|
|
36
|
+
this.client,
|
|
37
|
+
this.ENDPOINT,
|
|
38
|
+
{ keys: toArray(params) },
|
|
39
|
+
reqZ,
|
|
40
|
+
resZ,
|
|
41
|
+
)).pids;
|
|
44
42
|
}
|
|
45
43
|
}
|
|
@@ -21,14 +21,16 @@ import {
|
|
|
21
21
|
pidRemoteZ,
|
|
22
22
|
} from "@/workspace/pid/payload";
|
|
23
23
|
|
|
24
|
-
export const
|
|
25
|
-
|
|
24
|
+
export const newPIDZ = pidZ.partial({ key: true, snapshot: true }).transform((p) => ({
|
|
25
|
+
...p,
|
|
26
|
+
data: JSON.stringify(p.data),
|
|
27
|
+
}));
|
|
26
28
|
|
|
27
|
-
export type
|
|
29
|
+
export type NewPID = z.input<typeof newPIDZ>;
|
|
28
30
|
|
|
29
31
|
const createReqZ = z.object({
|
|
30
32
|
workspace: workspaceKeyZ,
|
|
31
|
-
pids:
|
|
33
|
+
pids: newPIDZ.array(),
|
|
32
34
|
});
|
|
33
35
|
|
|
34
36
|
const createResZ = z.object({
|
|
@@ -78,12 +80,13 @@ export class Writer {
|
|
|
78
80
|
this.client = client;
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
async create(workspace: string, pid:
|
|
83
|
+
async create(workspace: string, pid: NewPID): Promise<PID> {
|
|
82
84
|
const pid_ = { ...pid, data: JSON.stringify(pid.data) };
|
|
83
85
|
const res = await sendRequired<typeof createReqZ, typeof createResZ>(
|
|
84
86
|
this.client,
|
|
85
87
|
CREATE_ENDPOINT,
|
|
86
88
|
{ workspace, pids: [pid_] },
|
|
89
|
+
createReqZ,
|
|
87
90
|
createResZ,
|
|
88
91
|
);
|
|
89
92
|
|
|
@@ -95,6 +98,7 @@ export class Writer {
|
|
|
95
98
|
this.client,
|
|
96
99
|
COPY_ENDPOINT,
|
|
97
100
|
{ key, name, snapshot },
|
|
101
|
+
copyReqZ,
|
|
98
102
|
copyResZ,
|
|
99
103
|
);
|
|
100
104
|
return res.pid;
|
|
@@ -106,6 +110,7 @@ export class Writer {
|
|
|
106
110
|
this.client,
|
|
107
111
|
DELETE_ENDPOINT,
|
|
108
112
|
{ keys: normalized },
|
|
113
|
+
deleteReqZ,
|
|
109
114
|
deleteResZ,
|
|
110
115
|
);
|
|
111
116
|
}
|
|
@@ -115,6 +120,7 @@ export class Writer {
|
|
|
115
120
|
this.client,
|
|
116
121
|
RENAME_ENDPOINT,
|
|
117
122
|
{ key: pid, name },
|
|
123
|
+
renameReqZ,
|
|
118
124
|
renameResZ,
|
|
119
125
|
);
|
|
120
126
|
}
|
|
@@ -124,6 +130,7 @@ export class Writer {
|
|
|
124
130
|
this.client,
|
|
125
131
|
SET_DATA_ENDPOINT,
|
|
126
132
|
{ key: pid, data: JSON.stringify(data) },
|
|
133
|
+
setDataReqZ,
|
|
127
134
|
renameResZ,
|
|
128
135
|
);
|
|
129
136
|
}
|