@synnaxlabs/client 0.45.0 → 0.46.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/policy/client.d.ts +38 -26
- package/dist/access/policy/client.d.ts.map +1 -1
- package/dist/access/policy/payload.d.ts +22 -10
- package/dist/access/policy/payload.d.ts.map +1 -1
- package/dist/arc/client.d.ts +72 -0
- package/dist/arc/client.d.ts.map +1 -0
- package/dist/arc/external.d.ts +3 -0
- package/dist/arc/external.d.ts.map +1 -0
- package/dist/arc/index.d.ts +2 -0
- package/dist/arc/index.d.ts.map +1 -0
- package/dist/arc/payload.d.ts +155 -0
- package/dist/arc/payload.d.ts.map +1 -0
- package/dist/channel/client.d.ts +2 -3
- package/dist/channel/client.d.ts.map +1 -1
- package/dist/channel/payload.d.ts +23 -63
- package/dist/channel/payload.d.ts.map +1 -1
- package/dist/channel/retriever.d.ts.map +1 -1
- package/dist/client.cjs +44 -25
- package/dist/client.d.ts +5 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7548 -4837
- package/dist/framer/client.d.ts +2 -2
- package/dist/framer/client.d.ts.map +1 -1
- package/dist/framer/deleter.d.ts +2 -2
- package/dist/framer/frame.d.ts +2 -2
- package/dist/framer/streamer.d.ts +42 -56
- package/dist/framer/streamer.d.ts.map +1 -1
- package/dist/framer/writer.d.ts +45 -43
- package/dist/framer/writer.d.ts.map +1 -1
- package/dist/hardware/device/client.d.ts +5 -6
- package/dist/hardware/device/client.d.ts.map +1 -1
- package/dist/hardware/device/payload.d.ts +83 -18
- package/dist/hardware/device/payload.d.ts.map +1 -1
- package/dist/hardware/rack/client.d.ts +4 -5
- package/dist/hardware/rack/client.d.ts.map +1 -1
- package/dist/hardware/rack/payload.d.ts +81 -17
- package/dist/hardware/rack/payload.d.ts.map +1 -1
- package/dist/hardware/task/client.d.ts +61 -12
- package/dist/hardware/task/client.d.ts.map +1 -1
- package/dist/hardware/task/payload.d.ts +18 -51
- package/dist/hardware/task/payload.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/label/client.d.ts +14 -9
- package/dist/label/client.d.ts.map +1 -1
- package/dist/label/payload.d.ts +10 -11
- package/dist/label/payload.d.ts.map +1 -1
- package/dist/ontology/client.d.ts +7 -3
- package/dist/ontology/client.d.ts.map +1 -1
- package/dist/ontology/group/client.d.ts +45 -9
- package/dist/ontology/group/client.d.ts.map +1 -1
- package/dist/ontology/group/external.d.ts +0 -1
- package/dist/ontology/group/external.d.ts.map +1 -1
- package/dist/ontology/group/payload.d.ts +3 -1
- package/dist/ontology/group/payload.d.ts.map +1 -1
- package/dist/ontology/payload.d.ts +30 -17
- package/dist/ontology/payload.d.ts.map +1 -1
- package/dist/ontology/writer.d.ts +161 -0
- package/dist/ontology/writer.d.ts.map +1 -1
- package/dist/ranger/alias.d.ts +1 -1
- package/dist/ranger/alias.d.ts.map +1 -1
- package/dist/ranger/client.d.ts +9 -8
- package/dist/ranger/client.d.ts.map +1 -1
- package/dist/ranger/kv.d.ts.map +1 -1
- package/dist/ranger/payload.d.ts +5 -5
- package/dist/ranger/payload.d.ts.map +1 -1
- package/dist/ranger/writer.d.ts +6 -4
- package/dist/ranger/writer.d.ts.map +1 -1
- package/dist/status/client.d.ts +63 -0
- package/dist/status/client.d.ts.map +1 -0
- package/dist/status/external.d.ts +3 -0
- package/dist/status/external.d.ts.map +1 -0
- package/dist/status/index.d.ts +2 -0
- package/dist/status/index.d.ts.map +1 -0
- package/dist/status/payload.d.ts +32 -0
- package/dist/status/payload.d.ts.map +1 -0
- package/dist/status/status.spec.d.ts +2 -0
- package/dist/status/status.spec.d.ts.map +1 -0
- package/dist/user/client.d.ts.map +1 -1
- package/dist/user/retriever.d.ts.map +1 -1
- package/dist/workspace/client.d.ts +11 -6
- package/dist/workspace/client.d.ts.map +1 -1
- package/dist/workspace/lineplot/client.d.ts +28 -5
- package/dist/workspace/lineplot/client.d.ts.map +1 -1
- package/dist/workspace/lineplot/index.d.ts +1 -1
- package/dist/workspace/log/client.d.ts +28 -5
- package/dist/workspace/log/client.d.ts.map +1 -1
- package/dist/workspace/schematic/client.d.ts +35 -6
- package/dist/workspace/schematic/client.d.ts.map +1 -1
- package/dist/workspace/schematic/symbol/client.d.ts +6 -7
- package/dist/workspace/schematic/symbol/client.d.ts.map +1 -1
- package/dist/workspace/table/client.d.ts +28 -5
- package/dist/workspace/table/client.d.ts.map +1 -1
- package/examples/node/package-lock.json +30 -95
- package/examples/node/package.json +1 -1
- package/package.json +8 -8
- package/src/access/policy/client.ts +5 -6
- package/src/access/policy/payload.ts +4 -4
- package/src/access/policy/policy.spec.ts +4 -4
- package/src/arc/client.ts +117 -0
- package/src/{util/zod.ts → arc/external.ts} +2 -7
- package/src/arc/index.ts +10 -0
- package/src/arc/payload.ts +69 -0
- package/src/channel/client.ts +3 -4
- package/src/channel/payload.ts +4 -6
- package/src/channel/retriever.ts +2 -2
- package/src/client.ts +8 -2
- package/src/errors.spec.ts +1 -1
- package/src/framer/client.ts +4 -3
- package/src/framer/codec.spec.ts +1 -1
- package/src/hardware/device/client.ts +6 -8
- package/src/hardware/device/payload.ts +7 -6
- package/src/hardware/rack/client.ts +6 -8
- package/src/hardware/rack/payload.ts +2 -1
- package/src/hardware/task/client.ts +140 -100
- package/src/hardware/task/payload.ts +4 -4
- package/src/hardware/task/task.spec.ts +9 -2
- package/src/index.ts +3 -1
- package/src/label/client.ts +5 -8
- package/src/label/payload.ts +6 -11
- package/src/ontology/client.ts +3 -3
- package/src/ontology/group/client.ts +51 -18
- package/src/ontology/group/external.ts +0 -1
- package/src/ontology/group/group.spec.ts +6 -5
- package/src/ontology/group/payload.ts +5 -1
- package/src/ontology/ontology.spec.ts +88 -21
- package/src/ontology/payload.ts +15 -6
- package/src/ontology/writer.ts +3 -5
- package/src/ranger/alias.ts +2 -2
- package/src/ranger/client.ts +7 -3
- package/src/ranger/kv.ts +1 -2
- package/src/ranger/payload.ts +13 -1
- package/src/ranger/ranger.spec.ts +65 -1
- package/src/status/client.ts +129 -0
- package/src/status/external.ts +11 -0
- package/src/status/index.ts +10 -0
- package/src/status/payload.ts +35 -0
- package/src/status/status.spec.ts +352 -0
- package/src/user/client.ts +1 -2
- package/src/user/payload.ts +1 -1
- package/src/user/retriever.ts +2 -2
- package/src/user/user.spec.ts +41 -41
- package/src/workspace/client.ts +18 -15
- package/src/workspace/lineplot/client.ts +27 -13
- package/src/workspace/lineplot/index.ts +1 -1
- package/src/workspace/lineplot/lineplot.spec.ts +13 -10
- package/src/workspace/log/client.ts +26 -12
- package/src/workspace/log/log.spec.ts +13 -10
- package/src/workspace/payload.ts +1 -1
- package/src/workspace/schematic/client.ts +42 -17
- package/src/workspace/schematic/schematic.spec.ts +29 -25
- package/src/workspace/schematic/symbol/client.spec.ts +27 -24
- package/src/workspace/schematic/symbol/client.ts +6 -9
- package/src/workspace/table/client.ts +26 -12
- package/src/workspace/table/table.spec.ts +13 -10
- package/dist/ontology/group/group.d.ts +0 -10
- package/dist/ontology/group/group.d.ts.map +0 -1
- package/dist/ontology/group/writer.d.ts +0 -14
- package/dist/ontology/group/writer.d.ts.map +0 -1
- package/dist/util/zod.d.ts +0 -3
- package/dist/util/zod.d.ts.map +0 -1
- package/src/ontology/group/group.ts +0 -27
- package/src/ontology/group/writer.ts +0 -71
package/src/user/user.spec.ts
CHANGED
|
@@ -47,7 +47,7 @@ describe("User", () => {
|
|
|
47
47
|
describe("Create", () => {
|
|
48
48
|
describe("One", () => {
|
|
49
49
|
test("with a name", async () => {
|
|
50
|
-
const res = await client.
|
|
50
|
+
const res = await client.users.create(userOne);
|
|
51
51
|
expect(res.username).toEqual(userOne.username);
|
|
52
52
|
expect(res.key).not.toEqual("");
|
|
53
53
|
expect(res.firstName).toEqual(userOne.firstName);
|
|
@@ -55,7 +55,7 @@ describe("User", () => {
|
|
|
55
55
|
userOne.key = res.key;
|
|
56
56
|
});
|
|
57
57
|
test("with no name", async () => {
|
|
58
|
-
const res = await client.
|
|
58
|
+
const res = await client.users.create(userTwo);
|
|
59
59
|
expect(res.username).toEqual(userTwo.username);
|
|
60
60
|
expect(res.key).not.toEqual("");
|
|
61
61
|
userTwo.key = res.key;
|
|
@@ -64,16 +64,16 @@ describe("User", () => {
|
|
|
64
64
|
});
|
|
65
65
|
test("Repeated username", async () =>
|
|
66
66
|
await expect(
|
|
67
|
-
client.
|
|
67
|
+
client.users.create({ username: userOne.username, password: "test" }),
|
|
68
68
|
).rejects.toThrow(AuthError));
|
|
69
69
|
});
|
|
70
70
|
describe("Many", () => {
|
|
71
71
|
test("array empty", async () => {
|
|
72
|
-
const res = await client.
|
|
72
|
+
const res = await client.users.create([]);
|
|
73
73
|
expect(res).toHaveLength(0);
|
|
74
74
|
});
|
|
75
75
|
test("array is one", async () => {
|
|
76
|
-
const res = await client.
|
|
76
|
+
const res = await client.users.create([userThree]);
|
|
77
77
|
expect(res).toHaveLength(1);
|
|
78
78
|
expect(res[0].username).toEqual(userThree.username);
|
|
79
79
|
expect(res[0].key).not.toEqual("");
|
|
@@ -82,7 +82,7 @@ describe("User", () => {
|
|
|
82
82
|
expect(res[0].lastName).toEqual(userThree.lastName);
|
|
83
83
|
});
|
|
84
84
|
test("array not empty", async () => {
|
|
85
|
-
const res = await client.
|
|
85
|
+
const res = await client.users.create(userArray);
|
|
86
86
|
expect(res).toHaveLength(2);
|
|
87
87
|
userArray.forEach((u, i) => {
|
|
88
88
|
expect(res[i].username).toEqual(u.username);
|
|
@@ -93,7 +93,7 @@ describe("User", () => {
|
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
95
|
test("Repeated username", async () =>
|
|
96
|
-
await expect(client.
|
|
96
|
+
await expect(client.users.create([userOne, userTwo])).rejects.toThrow(
|
|
97
97
|
AuthError,
|
|
98
98
|
));
|
|
99
99
|
});
|
|
@@ -102,20 +102,20 @@ describe("User", () => {
|
|
|
102
102
|
describe("by name", () => {
|
|
103
103
|
describe("one", () => {
|
|
104
104
|
test("found", async () => {
|
|
105
|
-
const res = await client.
|
|
105
|
+
const res = await client.users.retrieve({ username: userOne.username });
|
|
106
106
|
expect(res.username).toEqual(userOne.username);
|
|
107
107
|
expect(res.key).toEqual(userOne.key);
|
|
108
108
|
expect(res.firstName).toEqual(userOne.firstName);
|
|
109
109
|
expect(res.lastName).toEqual(userOne.lastName);
|
|
110
110
|
});
|
|
111
111
|
test("not found", async () =>
|
|
112
|
-
await expect(
|
|
113
|
-
|
|
114
|
-
));
|
|
112
|
+
await expect(
|
|
113
|
+
client.users.retrieve({ username: id.create() }),
|
|
114
|
+
).rejects.toThrow(NotFoundError));
|
|
115
115
|
});
|
|
116
116
|
describe("many", () => {
|
|
117
117
|
test("found", async () => {
|
|
118
|
-
const res = await client.
|
|
118
|
+
const res = await client.users.retrieve({
|
|
119
119
|
usernames: userArray.map((u) => u.username),
|
|
120
120
|
});
|
|
121
121
|
expect(res.sort(sort)).toHaveLength(2);
|
|
@@ -127,11 +127,11 @@ describe("User", () => {
|
|
|
127
127
|
});
|
|
128
128
|
});
|
|
129
129
|
test("not found", async () => {
|
|
130
|
-
const res = await client.
|
|
130
|
+
const res = await client.users.retrieve({ usernames: [id.create()] });
|
|
131
131
|
expect(res).toEqual([]);
|
|
132
132
|
});
|
|
133
133
|
test("extra names getting deleted", async () => {
|
|
134
|
-
const res = await client.
|
|
134
|
+
const res = await client.users.retrieve({
|
|
135
135
|
usernames: [...userArray.map((u) => u.username), id.create()],
|
|
136
136
|
});
|
|
137
137
|
expect(res.sort(sort)).toHaveLength(2);
|
|
@@ -143,7 +143,7 @@ describe("User", () => {
|
|
|
143
143
|
});
|
|
144
144
|
});
|
|
145
145
|
test("calling with no names", async () => {
|
|
146
|
-
const res = await client.
|
|
146
|
+
const res = await client.users.retrieve({ usernames: [] });
|
|
147
147
|
const usernames = res.map((u) => u.username);
|
|
148
148
|
expect(usernames).toContain(userOne.username);
|
|
149
149
|
expect(usernames).toContain(userTwo.username);
|
|
@@ -155,7 +155,7 @@ describe("User", () => {
|
|
|
155
155
|
describe("by key", () => {
|
|
156
156
|
describe("one", () => {
|
|
157
157
|
test("found", async () => {
|
|
158
|
-
const res = await client.
|
|
158
|
+
const res = await client.users.retrieve({ key: userOne.key as string });
|
|
159
159
|
expect(res.username).toEqual(userOne.username);
|
|
160
160
|
expect(res.key).toEqual(userOne.key);
|
|
161
161
|
expect(res.firstName).toEqual(userOne.firstName);
|
|
@@ -163,18 +163,18 @@ describe("User", () => {
|
|
|
163
163
|
});
|
|
164
164
|
test("not found", async () => {
|
|
165
165
|
await expect(
|
|
166
|
-
client.
|
|
166
|
+
client.users.delete(userOne.key as string),
|
|
167
167
|
).resolves.toBeUndefined();
|
|
168
168
|
await expect(
|
|
169
|
-
client.
|
|
169
|
+
client.users.retrieve({ key: userOne.key as string }),
|
|
170
170
|
).rejects.toThrow(NotFoundError);
|
|
171
|
-
const u = await client.
|
|
171
|
+
const u = await client.users.create(userOne);
|
|
172
172
|
userOne.key = u.key;
|
|
173
173
|
});
|
|
174
174
|
});
|
|
175
175
|
describe("many", () => {
|
|
176
176
|
test("found", async () => {
|
|
177
|
-
const res = await client.
|
|
177
|
+
const res = await client.users.retrieve({
|
|
178
178
|
keys: userArray.map((u) => u.key as string),
|
|
179
179
|
});
|
|
180
180
|
expect(res.sort(sort)).toHaveLength(2);
|
|
@@ -187,15 +187,15 @@ describe("User", () => {
|
|
|
187
187
|
});
|
|
188
188
|
test("not found", async () => {
|
|
189
189
|
for (const u of userArray)
|
|
190
|
-
await expect(client.
|
|
190
|
+
await expect(client.users.delete(u.key as string)).resolves.toBeUndefined();
|
|
191
191
|
await expect(
|
|
192
|
-
client.
|
|
192
|
+
client.users.retrieve({ keys: userArray.map((u) => u.key as string) }),
|
|
193
193
|
).rejects.toThrow(NotFoundError);
|
|
194
|
-
const users = await client.
|
|
194
|
+
const users = await client.users.create(userArray);
|
|
195
195
|
users.forEach((u, i) => (userArray[i].key = u.key));
|
|
196
196
|
});
|
|
197
197
|
test("all", async () => {
|
|
198
|
-
const res = await client.
|
|
198
|
+
const res = await client.users.retrieve({ keys: [] });
|
|
199
199
|
const usernames = res.map((u) => u.username);
|
|
200
200
|
expect(usernames).toContain(userOne.username);
|
|
201
201
|
expect(usernames).toContain(userTwo.username);
|
|
@@ -209,9 +209,9 @@ describe("User", () => {
|
|
|
209
209
|
test("Successful", async () => {
|
|
210
210
|
const newUsername = id.create();
|
|
211
211
|
await expect(
|
|
212
|
-
client.
|
|
212
|
+
client.users.changeUsername(userOne.key as string, newUsername),
|
|
213
213
|
).resolves.toBeUndefined();
|
|
214
|
-
const res = await client.
|
|
214
|
+
const res = await client.users.retrieve({ username: newUsername });
|
|
215
215
|
expect(res.username).toEqual(newUsername);
|
|
216
216
|
expect(res.key).not.toEqual("");
|
|
217
217
|
expect(res.firstName).toEqual(userOne.firstName);
|
|
@@ -220,27 +220,27 @@ describe("User", () => {
|
|
|
220
220
|
});
|
|
221
221
|
test("Unsuccessful", async () =>
|
|
222
222
|
await expect(
|
|
223
|
-
client.
|
|
223
|
+
client.users.changeUsername(userTwo.key as string, userOne.username),
|
|
224
224
|
).rejects.toThrow(AuthError));
|
|
225
225
|
test("Repeated usernames fail", async () => {
|
|
226
226
|
const oldUsername = id.create();
|
|
227
|
-
const user = await client.
|
|
227
|
+
const user = await client.users.create({
|
|
228
228
|
username: oldUsername,
|
|
229
229
|
password: "test",
|
|
230
230
|
});
|
|
231
231
|
const newUsername = id.create();
|
|
232
|
-
await client.
|
|
232
|
+
await client.users.changeUsername(user.key, newUsername);
|
|
233
233
|
await expect(
|
|
234
|
-
client.
|
|
234
|
+
client.users.create({ username: newUsername, password: "test" }),
|
|
235
235
|
).rejects.toThrow(AuthError);
|
|
236
236
|
});
|
|
237
237
|
});
|
|
238
238
|
describe("Change Name", () => {
|
|
239
239
|
test("Successful", async () => {
|
|
240
240
|
await expect(
|
|
241
|
-
client.
|
|
241
|
+
client.users.rename(userOne.key as string, "Thomas", "Jefferson"),
|
|
242
242
|
).resolves.toBeUndefined();
|
|
243
|
-
const res = await client.
|
|
243
|
+
const res = await client.users.retrieve({ key: userOne.key as string });
|
|
244
244
|
expect(res.username).toEqual(userOne.username);
|
|
245
245
|
expect(res.key).toEqual(userOne.key);
|
|
246
246
|
expect(res.firstName).toEqual("Thomas");
|
|
@@ -250,9 +250,9 @@ describe("User", () => {
|
|
|
250
250
|
});
|
|
251
251
|
test("Only one name", async () => {
|
|
252
252
|
await expect(
|
|
253
|
-
client.
|
|
253
|
+
client.users.rename(userOne.key as string, "James"),
|
|
254
254
|
).resolves.toBeUndefined();
|
|
255
|
-
const res = await client.
|
|
255
|
+
const res = await client.users.retrieve({ key: userOne.key as string });
|
|
256
256
|
expect(res.username).toEqual(userOne.username);
|
|
257
257
|
expect(res.key).toEqual(userOne.key);
|
|
258
258
|
expect(res.firstName).toEqual("James");
|
|
@@ -262,28 +262,28 @@ describe("User", () => {
|
|
|
262
262
|
});
|
|
263
263
|
describe("Delete", () => {
|
|
264
264
|
test("one that exists", async () => {
|
|
265
|
-
await expect(client.
|
|
265
|
+
await expect(client.users.delete(userOne.key as string)).resolves.toBeUndefined();
|
|
266
266
|
await expect(
|
|
267
|
-
client.
|
|
267
|
+
client.users.retrieve({ key: userOne.key as string }),
|
|
268
268
|
).rejects.toThrow(NotFoundError);
|
|
269
269
|
});
|
|
270
270
|
test("many that exist", async () => {
|
|
271
271
|
await expect(
|
|
272
|
-
client.
|
|
272
|
+
client.users.delete(userArray.map((u) => u.key as string)),
|
|
273
273
|
).resolves.toBeUndefined();
|
|
274
274
|
await expect(
|
|
275
|
-
client.
|
|
275
|
+
client.users.retrieve({ keys: userArray.map((u) => u.key as string) }),
|
|
276
276
|
).rejects.toThrow(NotFoundError);
|
|
277
277
|
});
|
|
278
278
|
test("one that doesn't exist", async () => {
|
|
279
|
-
await expect(client.
|
|
279
|
+
await expect(client.users.delete(userOne.key as string)).resolves.toBeUndefined();
|
|
280
280
|
});
|
|
281
281
|
test("many where some don't exist", async () => {
|
|
282
282
|
await expect(
|
|
283
|
-
client.
|
|
283
|
+
client.users.delete([userOne.key as string, userTwo.key as string]),
|
|
284
284
|
).resolves.toBeUndefined();
|
|
285
285
|
await expect(
|
|
286
|
-
client.
|
|
286
|
+
client.users.retrieve({ key: userTwo.key as string }),
|
|
287
287
|
).rejects.toThrow(NotFoundError);
|
|
288
288
|
});
|
|
289
289
|
});
|
package/src/workspace/client.ts
CHANGED
|
@@ -8,13 +8,12 @@
|
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
10
|
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
|
-
import { array,
|
|
11
|
+
import { array, record } from "@synnaxlabs/x";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
14
14
|
import { type ontology } from "@/ontology";
|
|
15
15
|
import { type Key as UserKey, keyZ as userKeyZ } from "@/user/payload";
|
|
16
|
-
import {
|
|
17
|
-
import { linePlot } from "@/workspace/lineplot";
|
|
16
|
+
import { lineplot } from "@/workspace/lineplot";
|
|
18
17
|
import { log } from "@/workspace/log";
|
|
19
18
|
import {
|
|
20
19
|
type Key,
|
|
@@ -45,30 +44,34 @@ const retrieveReqZ = z.object({
|
|
|
45
44
|
export interface RetrieveRequest extends z.infer<typeof retrieveReqZ> {}
|
|
46
45
|
const createReqZ = z.object({ workspaces: newZ.array() });
|
|
47
46
|
const renameReqZ = z.object({ key: keyZ, name: z.string() });
|
|
48
|
-
const setLayoutReqZ = z.object({
|
|
47
|
+
const setLayoutReqZ = z.object({
|
|
48
|
+
key: keyZ,
|
|
49
|
+
layout: record.unknownZ.transform((l) => JSON.stringify(l)),
|
|
50
|
+
});
|
|
49
51
|
const deleteReqZ = z.object({ keys: keyZ.array() });
|
|
50
52
|
|
|
51
|
-
const retrieveResZ = z.object({ workspaces:
|
|
53
|
+
const retrieveResZ = z.object({ workspaces: array.nullableZ(workspaceZ) });
|
|
52
54
|
const createResZ = z.object({ workspaces: remoteZ.array() });
|
|
53
55
|
const emptyResZ = z.object({});
|
|
54
56
|
|
|
55
57
|
export const SET_CHANNEL_NAME = "sy_workspace_set";
|
|
56
58
|
export const DELETE_CHANNEL_NAME = "sy_workspace_delete";
|
|
57
59
|
|
|
60
|
+
export interface SetLayoutArgs extends z.input<typeof setLayoutReqZ> {}
|
|
61
|
+
|
|
58
62
|
export class Client {
|
|
59
|
-
readonly
|
|
60
|
-
readonly
|
|
61
|
-
readonly
|
|
62
|
-
readonly
|
|
63
|
-
readonly table: table.Client;
|
|
63
|
+
readonly schematics: schematic.Client;
|
|
64
|
+
readonly lineplots: lineplot.Client;
|
|
65
|
+
readonly logs: log.Client;
|
|
66
|
+
readonly tables: table.Client;
|
|
64
67
|
private readonly client: UnaryClient;
|
|
65
68
|
|
|
66
69
|
constructor(client: UnaryClient) {
|
|
67
70
|
this.client = client;
|
|
68
|
-
this.
|
|
69
|
-
this.
|
|
70
|
-
this.
|
|
71
|
-
this.
|
|
71
|
+
this.schematics = new schematic.Client(client);
|
|
72
|
+
this.lineplots = new lineplot.Client(client);
|
|
73
|
+
this.logs = new log.Client(client);
|
|
74
|
+
this.tables = new table.Client(client);
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
async create(workspace: New): Promise<Workspace>;
|
|
@@ -99,7 +102,7 @@ export class Client {
|
|
|
99
102
|
await sendRequired(
|
|
100
103
|
this.client,
|
|
101
104
|
SET_LAYOUT_ENDPOINT,
|
|
102
|
-
{ key, layout
|
|
105
|
+
{ key, layout },
|
|
103
106
|
setLayoutReqZ,
|
|
104
107
|
emptyResZ,
|
|
105
108
|
);
|
|
@@ -12,7 +12,7 @@ import { array, type record } from "@synnaxlabs/x";
|
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
14
14
|
import { type ontology } from "@/ontology";
|
|
15
|
-
import {
|
|
15
|
+
import { checkForMultipleOrNoResults } from "@/util/retrieve";
|
|
16
16
|
import {
|
|
17
17
|
type Key,
|
|
18
18
|
keyZ,
|
|
@@ -30,13 +30,26 @@ const RENAME_ENDPOINT = "/workspace/lineplot/rename";
|
|
|
30
30
|
const SET_DATA_ENDPOINT = "/workspace/lineplot/set-data";
|
|
31
31
|
const DELETE_ENDPOINT = "/workspace/lineplot/delete";
|
|
32
32
|
|
|
33
|
-
const retrieveReqZ = z.object({ keys: keyZ.array() });
|
|
34
|
-
const createReqZ = z.object({ workspace: workspaceKeyZ, linePlots: newZ.array() });
|
|
35
33
|
const renameReqZ = z.object({ key: keyZ, name: z.string() });
|
|
34
|
+
|
|
36
35
|
const setDataReqZ = z.object({ key: keyZ, data: z.string() });
|
|
37
36
|
const deleteReqZ = z.object({ keys: keyZ.array() });
|
|
38
|
-
|
|
37
|
+
|
|
38
|
+
const retrieveReqZ = z.object({ keys: keyZ.array() });
|
|
39
|
+
const singleRetrieveArgsZ = z
|
|
40
|
+
.object({ key: keyZ })
|
|
41
|
+
.transform(({ key }) => ({ keys: [key] }));
|
|
42
|
+
|
|
43
|
+
export const retrieveArgsZ = z.union([singleRetrieveArgsZ, retrieveReqZ]);
|
|
44
|
+
export type RetrieveArgs = z.input<typeof retrieveArgsZ>;
|
|
45
|
+
export type RetrieveSingleParams = z.input<typeof singleRetrieveArgsZ>;
|
|
46
|
+
export type RetrieveMultipleParams = z.input<typeof retrieveReqZ>;
|
|
47
|
+
|
|
48
|
+
const retrieveResZ = z.object({ linePlots: array.nullableZ(linePlotZ) });
|
|
49
|
+
|
|
50
|
+
const createReqZ = z.object({ workspace: workspaceKeyZ, linePlots: newZ.array() });
|
|
39
51
|
const createResZ = z.object({ linePlots: linePlotZ.array() });
|
|
52
|
+
|
|
40
53
|
const emptyResZ = z.object({});
|
|
41
54
|
|
|
42
55
|
export class Client {
|
|
@@ -83,22 +96,23 @@ export class Client {
|
|
|
83
96
|
);
|
|
84
97
|
}
|
|
85
98
|
|
|
86
|
-
async retrieve(
|
|
87
|
-
async retrieve(
|
|
88
|
-
async retrieve(
|
|
89
|
-
|
|
99
|
+
async retrieve(args: RetrieveSingleParams): Promise<LinePlot>;
|
|
100
|
+
async retrieve(args: RetrieveMultipleParams): Promise<LinePlot[]>;
|
|
101
|
+
async retrieve(
|
|
102
|
+
args: RetrieveSingleParams | RetrieveMultipleParams,
|
|
103
|
+
): Promise<LinePlot | LinePlot[]> {
|
|
104
|
+
const isSingle = singleRetrieveArgsZ.safeParse(args).success;
|
|
90
105
|
const res = await sendRequired(
|
|
91
106
|
this.client,
|
|
92
107
|
RETRIEVE_ENDPOINT,
|
|
93
|
-
|
|
94
|
-
|
|
108
|
+
args,
|
|
109
|
+
retrieveArgsZ,
|
|
95
110
|
retrieveResZ,
|
|
96
111
|
);
|
|
97
|
-
|
|
112
|
+
checkForMultipleOrNoResults("LinePlot", args, res.linePlots, isSingle);
|
|
113
|
+
return isSingle ? res.linePlots[0] : res.linePlots;
|
|
98
114
|
}
|
|
99
115
|
|
|
100
|
-
async delete(key: Key): Promise<void>;
|
|
101
|
-
async delete(keys: Key[]): Promise<void>;
|
|
102
116
|
async delete(keys: Params): Promise<void> {
|
|
103
117
|
await sendRequired(
|
|
104
118
|
this.client,
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { uuid } from "@synnaxlabs/x";
|
|
11
11
|
import { describe, expect, test } from "vitest";
|
|
12
12
|
|
|
13
|
+
import { NotFoundError } from "@/errors";
|
|
13
14
|
import { createTestClient } from "@/testutil/client";
|
|
14
15
|
|
|
15
16
|
const client = createTestClient();
|
|
@@ -21,7 +22,7 @@ describe("LinePlot", () => {
|
|
|
21
22
|
name: "Line Plot",
|
|
22
23
|
layout: { one: 1 },
|
|
23
24
|
});
|
|
24
|
-
const linePlot = await client.workspaces.
|
|
25
|
+
const linePlot = await client.workspaces.lineplots.create(ws.key, {
|
|
25
26
|
name: "Line Plot",
|
|
26
27
|
data: { one: 1 },
|
|
27
28
|
});
|
|
@@ -36,12 +37,12 @@ describe("LinePlot", () => {
|
|
|
36
37
|
name: "Line Plot",
|
|
37
38
|
layout: { one: 1 },
|
|
38
39
|
});
|
|
39
|
-
const linePlot = await client.workspaces.
|
|
40
|
+
const linePlot = await client.workspaces.lineplots.create(ws.key, {
|
|
40
41
|
name: "Line Plot",
|
|
41
42
|
data: { one: 1 },
|
|
42
43
|
});
|
|
43
|
-
await client.workspaces.
|
|
44
|
-
const res = await client.workspaces.
|
|
44
|
+
await client.workspaces.lineplots.rename(linePlot.key, "Line Plot2");
|
|
45
|
+
const res = await client.workspaces.lineplots.retrieve({ key: linePlot.key });
|
|
45
46
|
expect(res.name).toEqual("Line Plot2");
|
|
46
47
|
});
|
|
47
48
|
});
|
|
@@ -51,12 +52,12 @@ describe("LinePlot", () => {
|
|
|
51
52
|
name: "Line Plot",
|
|
52
53
|
layout: { one: 1 },
|
|
53
54
|
});
|
|
54
|
-
const linePlot = await client.workspaces.
|
|
55
|
+
const linePlot = await client.workspaces.lineplots.create(ws.key, {
|
|
55
56
|
name: "Line Plot",
|
|
56
57
|
data: { one: 1 },
|
|
57
58
|
});
|
|
58
|
-
await client.workspaces.
|
|
59
|
-
const res = await client.workspaces.
|
|
59
|
+
await client.workspaces.lineplots.setData(linePlot.key, { two: 2 });
|
|
60
|
+
const res = await client.workspaces.lineplots.retrieve({ key: linePlot.key });
|
|
60
61
|
expect(res.data.two).toEqual(2);
|
|
61
62
|
});
|
|
62
63
|
});
|
|
@@ -66,12 +67,14 @@ describe("LinePlot", () => {
|
|
|
66
67
|
name: "Line Plot",
|
|
67
68
|
layout: { one: 1 },
|
|
68
69
|
});
|
|
69
|
-
const linePlot = await client.workspaces.
|
|
70
|
+
const linePlot = await client.workspaces.lineplots.create(ws.key, {
|
|
70
71
|
name: "Line Plot",
|
|
71
72
|
data: { one: 1 },
|
|
72
73
|
});
|
|
73
|
-
await client.workspaces.
|
|
74
|
-
await expect(
|
|
74
|
+
await client.workspaces.lineplots.delete(linePlot.key);
|
|
75
|
+
await expect(
|
|
76
|
+
client.workspaces.lineplots.retrieve({ key: linePlot.key }),
|
|
77
|
+
).rejects.toThrow(NotFoundError);
|
|
75
78
|
});
|
|
76
79
|
});
|
|
77
80
|
});
|
|
@@ -12,6 +12,7 @@ import { array, type record } from "@synnaxlabs/x";
|
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
14
14
|
import { type ontology } from "@/ontology";
|
|
15
|
+
import { checkForMultipleOrNoResults } from "@/util/retrieve";
|
|
15
16
|
import {
|
|
16
17
|
type Key,
|
|
17
18
|
keyZ,
|
|
@@ -29,14 +30,26 @@ const RENAME_ENDPOINT = "/workspace/log/rename";
|
|
|
29
30
|
const SET_DATA_ENDPOINT = "/workspace/log/set-data";
|
|
30
31
|
const DELETE_ENDPOINT = "/workspace/log/delete";
|
|
31
32
|
|
|
32
|
-
const retrieveReqZ = z.object({ keys: keyZ.array() });
|
|
33
|
-
const createReqZ = z.object({ workspace: workspaceKeyZ, logs: newZ.array() });
|
|
34
33
|
const renameReqZ = z.object({ key: keyZ, name: z.string() });
|
|
34
|
+
|
|
35
35
|
const setDataReqZ = z.object({ key: keyZ, data: z.string() });
|
|
36
36
|
const deleteReqZ = z.object({ keys: keyZ.array() });
|
|
37
37
|
|
|
38
|
-
const
|
|
38
|
+
const retrieveReqZ = z.object({ keys: keyZ.array() });
|
|
39
|
+
const singleRetrieveArgsZ = z
|
|
40
|
+
.object({ key: keyZ })
|
|
41
|
+
.transform(({ key }) => ({ keys: [key] }));
|
|
42
|
+
|
|
43
|
+
export const retrieveArgsZ = z.union([singleRetrieveArgsZ, retrieveReqZ]);
|
|
44
|
+
export type RetrieveArgs = z.input<typeof retrieveArgsZ>;
|
|
45
|
+
export type RetrieveSingleParams = z.input<typeof singleRetrieveArgsZ>;
|
|
46
|
+
export type RetrieveMultipleParams = z.input<typeof retrieveReqZ>;
|
|
47
|
+
|
|
48
|
+
const retrieveResZ = z.object({ logs: array.nullableZ(logZ) });
|
|
49
|
+
|
|
50
|
+
const createReqZ = z.object({ workspace: workspaceKeyZ, logs: newZ.array() });
|
|
39
51
|
const createResZ = z.object({ logs: logZ.array() });
|
|
52
|
+
|
|
40
53
|
const emptyResZ = z.object({});
|
|
41
54
|
|
|
42
55
|
export class Client {
|
|
@@ -80,22 +93,23 @@ export class Client {
|
|
|
80
93
|
);
|
|
81
94
|
}
|
|
82
95
|
|
|
83
|
-
async retrieve(
|
|
84
|
-
async retrieve(
|
|
85
|
-
async retrieve(
|
|
86
|
-
|
|
96
|
+
async retrieve(args: RetrieveSingleParams): Promise<Log>;
|
|
97
|
+
async retrieve(args: RetrieveMultipleParams): Promise<Log[]>;
|
|
98
|
+
async retrieve(
|
|
99
|
+
args: RetrieveSingleParams | RetrieveMultipleParams,
|
|
100
|
+
): Promise<Log | Log[]> {
|
|
101
|
+
const isSingle = singleRetrieveArgsZ.safeParse(args).success;
|
|
87
102
|
const res = await sendRequired(
|
|
88
103
|
this.client,
|
|
89
104
|
RETRIEVE_ENDPOINT,
|
|
90
|
-
|
|
91
|
-
|
|
105
|
+
args,
|
|
106
|
+
retrieveArgsZ,
|
|
92
107
|
retrieveResZ,
|
|
93
108
|
);
|
|
94
|
-
|
|
109
|
+
checkForMultipleOrNoResults("Log", args, res.logs, isSingle);
|
|
110
|
+
return isSingle ? res.logs[0] : res.logs;
|
|
95
111
|
}
|
|
96
112
|
|
|
97
|
-
async delete(key: Key): Promise<void>;
|
|
98
|
-
async delete(keys: Key[]): Promise<void>;
|
|
99
113
|
async delete(keys: Params): Promise<void> {
|
|
100
114
|
await sendRequired(
|
|
101
115
|
this.client,
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { uuid } from "@synnaxlabs/x";
|
|
11
11
|
import { describe, expect, test } from "vitest";
|
|
12
12
|
|
|
13
|
+
import { NotFoundError } from "@/errors";
|
|
13
14
|
import { createTestClient } from "@/testutil/client";
|
|
14
15
|
|
|
15
16
|
const client = createTestClient();
|
|
@@ -18,7 +19,7 @@ describe("Log", () => {
|
|
|
18
19
|
describe("create", () => {
|
|
19
20
|
test("create one", async () => {
|
|
20
21
|
const ws = await client.workspaces.create({ name: "Log", layout: { one: 1 } });
|
|
21
|
-
const log = await client.workspaces.
|
|
22
|
+
const log = await client.workspaces.logs.create(ws.key, {
|
|
22
23
|
name: "Log",
|
|
23
24
|
data: { one: 1 },
|
|
24
25
|
});
|
|
@@ -30,36 +31,38 @@ describe("Log", () => {
|
|
|
30
31
|
describe("rename", () => {
|
|
31
32
|
test("rename one", async () => {
|
|
32
33
|
const ws = await client.workspaces.create({ name: "Log", layout: { one: 1 } });
|
|
33
|
-
const log = await client.workspaces.
|
|
34
|
+
const log = await client.workspaces.logs.create(ws.key, {
|
|
34
35
|
name: "Log",
|
|
35
36
|
data: { one: 1 },
|
|
36
37
|
});
|
|
37
|
-
await client.workspaces.
|
|
38
|
-
const res = await client.workspaces.
|
|
38
|
+
await client.workspaces.logs.rename(log.key, "Log2");
|
|
39
|
+
const res = await client.workspaces.logs.retrieve({ key: log.key });
|
|
39
40
|
expect(res.name).toEqual("Log2");
|
|
40
41
|
});
|
|
41
42
|
});
|
|
42
43
|
describe("setData", () => {
|
|
43
44
|
test("set data", async () => {
|
|
44
45
|
const ws = await client.workspaces.create({ name: "Log", layout: { one: 1 } });
|
|
45
|
-
const log = await client.workspaces.
|
|
46
|
+
const log = await client.workspaces.logs.create(ws.key, {
|
|
46
47
|
name: "Log",
|
|
47
48
|
data: { one: 1 },
|
|
48
49
|
});
|
|
49
|
-
await client.workspaces.
|
|
50
|
-
const res = await client.workspaces.
|
|
50
|
+
await client.workspaces.logs.setData(log.key, { two: 2 });
|
|
51
|
+
const res = await client.workspaces.logs.retrieve({ key: log.key });
|
|
51
52
|
expect(res.data.two).toEqual(2);
|
|
52
53
|
});
|
|
53
54
|
});
|
|
54
55
|
describe("delete", () => {
|
|
55
56
|
test("delete one", async () => {
|
|
56
57
|
const ws = await client.workspaces.create({ name: "Log", layout: { one: 1 } });
|
|
57
|
-
const log = await client.workspaces.
|
|
58
|
+
const log = await client.workspaces.logs.create(ws.key, {
|
|
58
59
|
name: "Log",
|
|
59
60
|
data: { one: 1 },
|
|
60
61
|
});
|
|
61
|
-
await client.workspaces.
|
|
62
|
-
await expect(client.workspaces.
|
|
62
|
+
await client.workspaces.logs.delete(log.key);
|
|
63
|
+
await expect(client.workspaces.logs.retrieve({ key: log.key })).rejects.toThrow(
|
|
64
|
+
NotFoundError,
|
|
65
|
+
);
|
|
63
66
|
});
|
|
64
67
|
});
|
|
65
68
|
});
|
package/src/workspace/payload.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type Params = Key | Key[];
|
|
|
18
18
|
|
|
19
19
|
export const workspaceZ = z.object({
|
|
20
20
|
key: keyZ,
|
|
21
|
-
name: z.string(),
|
|
21
|
+
name: z.string().min(1, "Name is required"),
|
|
22
22
|
layout: record.unknownZ.or(z.string().transform(parseWithoutKeyConversion)),
|
|
23
23
|
});
|
|
24
24
|
export interface Workspace extends z.infer<typeof workspaceZ> {}
|