@synnaxlabs/client 0.54.2 → 0.56.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 +10 -13
- package/dist/client.cjs +60 -42
- package/dist/client.js +8037 -6265
- package/dist/src/access/policy/client.d.ts +70 -80
- package/dist/src/access/policy/client.d.ts.map +1 -1
- package/dist/src/access/policy/types.gen.d.ts +18 -20
- package/dist/src/access/policy/types.gen.d.ts.map +1 -1
- package/dist/src/access/role/client.d.ts.map +1 -1
- package/dist/src/access/role/types.gen.d.ts +2 -2
- package/dist/src/actions/actions.d.ts +68 -0
- package/dist/src/actions/actions.d.ts.map +1 -0
- package/dist/src/actions/actions.spec.d.ts +2 -0
- package/dist/src/actions/actions.spec.d.ts.map +1 -0
- package/dist/src/actions/external.d.ts +2 -0
- package/dist/src/actions/external.d.ts.map +1 -0
- package/dist/src/actions/index.d.ts +2 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/src/arc/arc.spec.d.ts +2 -0
- package/dist/src/arc/arc.spec.d.ts.map +1 -0
- package/dist/src/arc/client.d.ts.map +1 -1
- package/dist/src/arc/compiler/types.gen.d.ts +1 -1
- package/dist/src/arc/compiler/types.gen.d.ts.map +1 -1
- package/dist/src/arc/graph/types.gen.d.ts +40 -40
- package/dist/src/arc/graph/types.gen.d.ts.map +1 -1
- package/dist/src/arc/ir/types.gen.d.ts +202 -233
- package/dist/src/arc/ir/types.gen.d.ts.map +1 -1
- package/dist/src/arc/module/types.gen.d.ts +63 -82
- package/dist/src/arc/module/types.gen.d.ts.map +1 -1
- package/dist/src/arc/program/types.gen.d.ts +63 -82
- package/dist/src/arc/program/types.gen.d.ts.map +1 -1
- package/dist/src/arc/types/types.gen.d.ts +11 -11
- package/dist/src/arc/types/types.gen.d.ts.map +1 -1
- package/dist/src/arc/types.gen.d.ts +139 -158
- package/dist/src/arc/types.gen.d.ts.map +1 -1
- package/dist/src/auth/auth.d.ts +3 -3
- package/dist/src/auth/auth.d.ts.map +1 -1
- package/dist/src/channel/client.d.ts +2 -2
- package/dist/src/channel/client.d.ts.map +1 -1
- package/dist/src/channel/retriever.d.ts +5 -8
- package/dist/src/channel/retriever.d.ts.map +1 -1
- package/dist/src/channel/types.gen.d.ts +3 -3
- package/dist/src/channel/types.gen.d.ts.map +1 -1
- package/dist/src/channel/writer.d.ts.map +1 -1
- package/dist/src/client.d.ts +5 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/connection/checker.d.ts +17 -2
- package/dist/src/connection/checker.d.ts.map +1 -1
- package/dist/src/control/state.d.ts.map +1 -1
- package/dist/src/device/client.d.ts.map +1 -1
- package/dist/src/device/types.gen.d.ts +6 -8
- package/dist/src/device/types.gen.d.ts.map +1 -1
- package/dist/src/errors.d.ts +2 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/framer/adapter.d.ts.map +1 -1
- package/dist/src/framer/client.d.ts +2 -2
- package/dist/src/framer/client.d.ts.map +1 -1
- package/dist/src/framer/codec.d.ts +9 -1
- package/dist/src/framer/codec.d.ts.map +1 -1
- package/dist/src/framer/deleter.d.ts.map +1 -1
- package/dist/src/framer/frame.d.ts +1 -1
- package/dist/src/framer/iterator.d.ts +84 -3
- package/dist/src/framer/iterator.d.ts.map +1 -1
- package/dist/src/framer/streamProxy.d.ts.map +1 -1
- package/dist/src/framer/streamer.d.ts +1 -3
- package/dist/src/framer/streamer.d.ts.map +1 -1
- package/dist/src/framer/types.gen.d.ts +18 -0
- package/dist/src/framer/types.gen.d.ts.map +1 -1
- package/dist/src/framer/writer.d.ts +8 -8
- package/dist/src/framer/writer.d.ts.map +1 -1
- package/dist/src/group/client.d.ts +1 -2
- package/dist/src/group/client.d.ts.map +1 -1
- package/dist/src/group/types.gen.d.ts +2 -2
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/label/client.d.ts +5 -8
- package/dist/src/label/client.d.ts.map +1 -1
- package/dist/src/lineplot/client.d.ts.map +1 -1
- package/dist/src/lineplot/types.gen.d.ts +2 -2
- package/dist/src/log/client.d.ts.map +1 -1
- package/dist/src/log/types.gen.d.ts +2 -2
- package/dist/src/ontology/client.d.ts +1 -3
- package/dist/src/ontology/client.d.ts.map +1 -1
- package/dist/src/ontology/payload.d.ts +12 -16
- package/dist/src/ontology/payload.d.ts.map +1 -1
- package/dist/src/ontology/types.gen.d.ts +1 -2
- package/dist/src/ontology/types.gen.d.ts.map +1 -1
- package/dist/src/ontology/writer.d.ts +5 -10
- package/dist/src/ontology/writer.d.ts.map +1 -1
- package/dist/src/rack/client.d.ts.map +1 -1
- package/dist/src/rack/types.gen.d.ts +3 -3
- package/dist/src/ranger/alias/client.d.ts.map +1 -1
- package/dist/src/ranger/client.d.ts.map +1 -1
- package/dist/src/ranger/kv/client.d.ts.map +1 -1
- package/dist/src/ranger/types.gen.d.ts +6 -6
- package/dist/src/ranger/types.gen.d.ts.map +1 -1
- package/dist/src/ranger/writer.d.ts +2 -3
- package/dist/src/ranger/writer.d.ts.map +1 -1
- package/dist/src/schematic/actions.d.ts +147 -0
- package/dist/src/schematic/actions.d.ts.map +1 -0
- package/dist/src/schematic/actions.gen.d.ts +484 -0
- package/dist/src/schematic/actions.gen.d.ts.map +1 -0
- package/dist/src/schematic/actions.spec.d.ts +2 -0
- package/dist/src/schematic/actions.spec.d.ts.map +1 -0
- package/dist/src/schematic/client.d.ts +53 -2
- package/dist/src/schematic/client.d.ts.map +1 -1
- package/dist/src/schematic/external.d.ts +2 -0
- package/dist/src/schematic/external.d.ts.map +1 -1
- package/dist/src/schematic/symbol/client.d.ts.map +1 -1
- package/dist/src/schematic/symbol/types.gen.d.ts +48 -58
- package/dist/src/schematic/symbol/types.gen.d.ts.map +1 -1
- package/dist/src/schematic/types.gen.d.ts +131 -5
- package/dist/src/schematic/types.gen.d.ts.map +1 -1
- package/dist/src/status/client.d.ts.map +1 -1
- package/dist/src/status/payload.d.ts +3 -3
- package/dist/src/table/actions.d.ts +156 -0
- package/dist/src/table/actions.d.ts.map +1 -0
- package/dist/src/table/actions.gen.d.ts +587 -0
- package/dist/src/table/actions.gen.d.ts.map +1 -0
- package/dist/src/table/client.d.ts +28 -2
- package/dist/src/table/client.d.ts.map +1 -1
- package/dist/src/table/external.d.ts +2 -0
- package/dist/src/table/external.d.ts.map +1 -1
- package/dist/src/table/types.gen.d.ts +71 -4
- package/dist/src/table/types.gen.d.ts.map +1 -1
- package/dist/src/task/client.d.ts.map +1 -1
- package/dist/src/task/types.gen.d.ts +7 -7
- package/dist/src/task/types.gen.d.ts.map +1 -1
- package/dist/src/user/client.d.ts +2 -2
- package/dist/src/user/client.d.ts.map +1 -1
- package/dist/src/user/types.gen.d.ts +2 -2
- package/dist/src/view/client.d.ts.map +1 -1
- package/dist/src/view/types.gen.d.ts +2 -2
- package/dist/src/workspace/client.d.ts.map +1 -1
- package/dist/src/workspace/types.gen.d.ts +3 -3
- package/dist/src/workspace/types.gen.d.ts.map +1 -1
- package/package.json +12 -11
- package/src/access/policy/client.ts +4 -7
- package/src/access/role/client.ts +6 -26
- package/src/actions/actions.spec.ts +229 -0
- package/src/actions/actions.ts +104 -0
- package/src/actions/external.ts +10 -0
- package/src/actions/index.ts +10 -0
- package/src/arc/arc.spec.ts +44 -0
- package/src/arc/client.ts +3 -7
- package/src/arc/compiler/types.gen.ts +2 -1
- package/src/arc/ir/types.gen.ts +102 -48
- package/src/arc/lsp.spec.ts +3 -7
- package/src/arc/types/types.gen.ts +3 -3
- package/src/auth/auth.spec.ts +12 -13
- package/src/auth/auth.ts +48 -34
- package/src/channel/batchRetriever.spec.ts +13 -4
- package/src/channel/channel.spec.ts +13 -0
- package/src/channel/client.ts +8 -6
- package/src/channel/retriever.ts +7 -16
- package/src/channel/types.gen.ts +1 -2
- package/src/channel/writer.ts +4 -20
- package/src/client.ts +3 -0
- package/src/connection/checker.ts +48 -10
- package/src/connection/connection.spec.ts +64 -2
- package/src/control/state.ts +5 -4
- package/src/device/client.ts +5 -8
- package/src/device/device.spec.ts +7 -5
- package/src/device/types.gen.ts +4 -4
- package/src/errors.ts +8 -9
- package/src/framer/adapter.ts +2 -4
- package/src/framer/client.ts +12 -0
- package/src/framer/codec.spec.ts +53 -3
- package/src/framer/codec.ts +58 -25
- package/src/framer/deleter.ts +2 -8
- package/src/framer/iterator.ts +42 -39
- package/src/framer/streamProxy.ts +11 -12
- package/src/framer/streamer.spec.ts +1 -1
- package/src/framer/streamer.ts +2 -7
- package/src/framer/types.gen.ts +20 -0
- package/src/framer/writer.spec.ts +221 -1
- package/src/framer/writer.ts +53 -28
- package/src/group/client.ts +4 -7
- package/src/index.ts +3 -2
- package/src/label/client.ts +6 -16
- package/src/label/label.spec.ts +12 -0
- package/src/lineplot/client.ts +6 -21
- package/src/log/client.ts +6 -21
- package/src/ontology/client.ts +2 -3
- package/src/ontology/ontology.spec.ts +10 -0
- package/src/ontology/types.gen.ts +0 -1
- package/src/ontology/writer.ts +4 -7
- package/src/rack/client.ts +4 -7
- package/src/rack/rack.spec.ts +12 -1
- package/src/ranger/alias/client.ts +6 -11
- package/src/ranger/client.ts +2 -3
- package/src/ranger/kv/client.ts +4 -7
- package/src/ranger/ranger.spec.ts +12 -0
- package/src/ranger/writer.ts +4 -17
- package/src/schematic/access.spec.ts +6 -6
- package/src/schematic/actions.gen.ts +200 -0
- package/src/schematic/actions.spec.ts +699 -0
- package/src/schematic/actions.ts +168 -0
- package/src/schematic/client.ts +34 -30
- package/src/schematic/external.ts +2 -0
- package/src/schematic/schematic.spec.ts +233 -69
- package/src/schematic/symbol/client.spec.ts +33 -9
- package/src/schematic/symbol/client.ts +6 -11
- package/src/schematic/symbol/types.gen.ts +1 -10
- package/src/schematic/types.gen.ts +55 -6
- package/src/status/client.ts +4 -10
- package/src/status/status.spec.ts +7 -6
- package/src/table/access.spec.ts +0 -6
- package/src/table/actions.gen.ts +243 -0
- package/src/table/actions.ts +255 -0
- package/src/table/client.ts +21 -25
- package/src/table/external.ts +2 -0
- package/src/table/table.spec.ts +588 -43
- package/src/table/types.gen.ts +58 -5
- package/src/task/client.ts +14 -20
- package/src/task/task.spec.ts +15 -1
- package/src/task/types.gen.ts +8 -6
- package/src/user/client.ts +6 -11
- package/src/view/client.ts +4 -7
- package/src/view/view.spec.ts +9 -5
- package/src/workspace/client.ts +6 -16
- package/src/workspace/types.gen.ts +2 -1
- package/src/workspace/workspace.spec.ts +14 -1
package/src/framer/writer.ts
CHANGED
|
@@ -60,14 +60,14 @@ const baseWriterConfigZ = z.object({
|
|
|
60
60
|
/** controlSubject sets the control subject of the writer. */
|
|
61
61
|
controlSubject: control.subjectZ.optional(),
|
|
62
62
|
/** authorities set the control authority to set for each channel on the writer.
|
|
63
|
-
* Defaults to absolute authority. If not working with concurrent control,
|
|
64
|
-
*
|
|
63
|
+
* Defaults to absolute authority. If not working with concurrent control, it's best
|
|
64
|
+
* to leave this as the default.
|
|
65
65
|
*/
|
|
66
66
|
authorities: z
|
|
67
67
|
.union([control.authorityZ.transform((a) => [a]), control.authorityZ.array()])
|
|
68
68
|
.default([control.ABSOLUTE_AUTHORITY]),
|
|
69
|
-
/** mode sets the persistence and streaming mode of the writer. The default
|
|
70
|
-
*
|
|
69
|
+
/** mode sets the persistence and streaming mode of the writer. The default mode is
|
|
70
|
+
* WriterModePersistStream.
|
|
71
71
|
*/
|
|
72
72
|
mode: writerModeZ.default(WriterMode.PersistStream),
|
|
73
73
|
/**
|
|
@@ -76,19 +76,23 @@ const baseWriterConfigZ = z.object({
|
|
|
76
76
|
*/
|
|
77
77
|
errOnUnauthorized: z.boolean().default(false),
|
|
78
78
|
/**
|
|
79
|
-
* enableAutoCommit determines whether the writer will automatically commit.
|
|
80
|
-
*
|
|
81
|
-
*
|
|
79
|
+
* enableAutoCommit determines whether the writer will automatically commit. If
|
|
80
|
+
* enableAutoCommit is true, then the writer will commit after each write, and will
|
|
81
|
+
* flush that commit to index after the specified autoIndexPersistInterval.
|
|
82
82
|
*/
|
|
83
83
|
enableAutoCommit: z.boolean().default(true),
|
|
84
84
|
/** autoIndexPersistInterval sets the interval at which commits will be flushed to
|
|
85
85
|
* disk. */
|
|
86
86
|
autoIndexPersistInterval: TimeSpan.z.default(TimeSpan.SECOND),
|
|
87
|
-
|
|
88
|
-
*
|
|
89
|
-
*
|
|
87
|
+
/**
|
|
88
|
+
* autoIndex causes Synnax to automatically generate timestamps for any index channel
|
|
89
|
+
* that is not included in a write call. The first sample in each write is stamped at
|
|
90
|
+
* the time the write is received, and subsequent samples are spaced 1 nanosecond
|
|
91
|
+
* apart. Generated timestamps are guaranteed to be strictly monotonic across all
|
|
92
|
+
* writes on the writer. If the writer is opened with data channels whose index
|
|
93
|
+
* channels are not included, those index channels are added implicitly.
|
|
90
94
|
*/
|
|
91
|
-
|
|
95
|
+
autoIndex: z.boolean().default(false),
|
|
92
96
|
});
|
|
93
97
|
|
|
94
98
|
const netWriterConfigZ = baseWriterConfigZ.extend({
|
|
@@ -212,8 +216,7 @@ export class Writer {
|
|
|
212
216
|
): Promise<Writer> {
|
|
213
217
|
const cfg = zod.parse(writerConfigZ, config);
|
|
214
218
|
const adapter = await WriteAdapter.open(retriever, cfg.channels);
|
|
215
|
-
|
|
216
|
-
client = client.withCodec(new WSWriterCodec(adapter.codec));
|
|
219
|
+
client = client.withCodec(new WSWriterCodec(adapter.codec));
|
|
217
220
|
const stream = await client.stream("/frame/write", reqZ, resZ);
|
|
218
221
|
const writer = new Writer(stream, adapter);
|
|
219
222
|
await writer.execute({
|
|
@@ -245,13 +248,14 @@ export class Writer {
|
|
|
245
248
|
* @param frame - The frame to write to the database. The frame must:
|
|
246
249
|
*
|
|
247
250
|
* 1. Have exactly one array for each key in the list of keys provided to the
|
|
248
|
-
*
|
|
251
|
+
* writer's open method.
|
|
249
252
|
* 2. Have equal length arrays for each key.
|
|
250
253
|
* 3. When writing to an index (i.e. TimeStamp) channel, the values must be
|
|
251
|
-
*
|
|
254
|
+
* monotonically increasing.
|
|
252
255
|
*
|
|
253
|
-
* @
|
|
254
|
-
*
|
|
256
|
+
* @throws if the writer has accumulated an error. Once write throws, all subsequent
|
|
257
|
+
* calls to write and commit will also throw, and the writer must be closed and
|
|
258
|
+
* re-opened to continue writing.
|
|
255
259
|
*/
|
|
256
260
|
async write(
|
|
257
261
|
channelsOrData:
|
|
@@ -263,7 +267,11 @@ export class Writer {
|
|
|
263
267
|
if (this.closeErr != null) throw this.closeErr;
|
|
264
268
|
if (this.stream.received()) return await this.close();
|
|
265
269
|
const frame = await this.adapter.adapt(channelsOrData, series);
|
|
266
|
-
|
|
270
|
+
try {
|
|
271
|
+
this.stream.send({ command: WriterCommand.Write, frame: frame.toPayload() });
|
|
272
|
+
} catch (err) {
|
|
273
|
+
if (!EOF.matches(err)) throw err;
|
|
274
|
+
}
|
|
267
275
|
}
|
|
268
276
|
|
|
269
277
|
async setAuthority(
|
|
@@ -283,9 +291,9 @@ export class Writer {
|
|
|
283
291
|
* Commits the written frames to the database. Commit is synchronous, meaning that it
|
|
284
292
|
* will not return until all frames have been committed to the database.
|
|
285
293
|
*
|
|
286
|
-
* @returns
|
|
287
|
-
*
|
|
288
|
-
*
|
|
294
|
+
* @returns the timestamp of the last sample written to the writer.
|
|
295
|
+
* @throws if the commit fails or any previous writer method has thrown. Once commit
|
|
296
|
+
* throws, the writer must be closed and re-opened to continue use.
|
|
289
297
|
*/
|
|
290
298
|
async commit(): Promise<TimeStamp> {
|
|
291
299
|
if (this.closeErr != null) throw this.closeErr;
|
|
@@ -315,18 +323,35 @@ export class Writer {
|
|
|
315
323
|
if (WriterClosedError.matches(this.closeErr)) return null;
|
|
316
324
|
throw this.closeErr;
|
|
317
325
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
326
|
+
try {
|
|
327
|
+
const res = await this.stream.receive();
|
|
328
|
+
this.closeErr = errors.decode(res?.err);
|
|
329
|
+
} catch (err) {
|
|
330
|
+
if (!(err instanceof Error)) throw err;
|
|
331
|
+
this.closeErr = EOF.matches(err) ? new WriterClosedError() : err;
|
|
332
|
+
}
|
|
321
333
|
}
|
|
322
334
|
}
|
|
323
335
|
|
|
324
336
|
private async execute(req: WriteRequest): Promise<Response> {
|
|
325
|
-
|
|
326
|
-
|
|
337
|
+
try {
|
|
338
|
+
this.stream.send(req);
|
|
339
|
+
} catch (err) {
|
|
340
|
+
if (!(err instanceof Error)) throw err;
|
|
341
|
+
// A send failure is always EOF or StreamClosed, never WriterClosedError, so
|
|
342
|
+
// closeInternal re-throws here and the receive loop below is reached only when
|
|
343
|
+
// the send succeeds.
|
|
344
|
+
await this.closeInternal(err);
|
|
345
|
+
}
|
|
327
346
|
while (true) {
|
|
328
|
-
|
|
329
|
-
|
|
347
|
+
let res: Response;
|
|
348
|
+
try {
|
|
349
|
+
res = await this.stream.receive();
|
|
350
|
+
} catch (err) {
|
|
351
|
+
if (!(err instanceof Error)) throw err;
|
|
352
|
+
await this.closeInternal(err);
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
330
355
|
const resErr = errors.decode(res?.err);
|
|
331
356
|
if (resErr != null) await this.closeInternal(resErr);
|
|
332
357
|
if (res?.command == req.command) return res;
|
package/src/group/client.ts
CHANGED
|
@@ -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 {
|
|
10
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { array } from "@synnaxlabs/x";
|
|
12
12
|
import z from "zod";
|
|
13
13
|
|
|
@@ -39,8 +39,7 @@ export class Client {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
async create(args: CreateArgs): Promise<Group> {
|
|
42
|
-
const res = await
|
|
43
|
-
this.client,
|
|
42
|
+
const res = await this.client.send(
|
|
44
43
|
"/ontology/create-group",
|
|
45
44
|
args,
|
|
46
45
|
createReqZ,
|
|
@@ -50,8 +49,7 @@ export class Client {
|
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
async rename(key: Key, name: string): Promise<void> {
|
|
53
|
-
await
|
|
54
|
-
this.client,
|
|
52
|
+
await this.client.send(
|
|
55
53
|
"/ontology/rename-group",
|
|
56
54
|
{ key, name },
|
|
57
55
|
renameReqZ,
|
|
@@ -60,8 +58,7 @@ export class Client {
|
|
|
60
58
|
}
|
|
61
59
|
|
|
62
60
|
async delete(keys: Key | Key[]): Promise<void> {
|
|
63
|
-
await
|
|
64
|
-
this.client,
|
|
61
|
+
await this.client.send(
|
|
65
62
|
"/ontology/delete-group",
|
|
66
63
|
{ keys: array.toArray(keys) },
|
|
67
64
|
deleteReqZ,
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
10
|
export { access } from "@/access";
|
|
11
|
+
export { actions } from "@/actions";
|
|
11
12
|
export { arc } from "@/arc";
|
|
12
13
|
export { channel } from "@/channel";
|
|
13
14
|
export { Channel, isCalculated } from "@/channel/client";
|
|
@@ -67,7 +68,7 @@ export {
|
|
|
67
68
|
TimeRange,
|
|
68
69
|
TimeSpan,
|
|
69
70
|
TimeStamp,
|
|
70
|
-
type
|
|
71
|
+
type TimestampFormat,
|
|
72
|
+
type TimeZone,
|
|
71
73
|
type TypedArray,
|
|
72
|
-
type TZInfo,
|
|
73
74
|
} from "@synnaxlabs/x";
|
package/src/label/client.ts
CHANGED
|
@@ -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 {
|
|
10
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { array } from "@synnaxlabs/x";
|
|
12
12
|
import z from "zod";
|
|
13
13
|
|
|
@@ -66,8 +66,7 @@ export class Client {
|
|
|
66
66
|
async retrieve(args: RetrieveMultipleParams): Promise<Label[]>;
|
|
67
67
|
async retrieve(args: RetrieveArgs): Promise<Label | Label[]> {
|
|
68
68
|
const isSingle = "key" in args;
|
|
69
|
-
const res = await
|
|
70
|
-
this.client,
|
|
69
|
+
const res = await this.client.send(
|
|
71
70
|
"/label/retrieve",
|
|
72
71
|
args,
|
|
73
72
|
retrieveArgsZ,
|
|
@@ -78,8 +77,7 @@ export class Client {
|
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
async label(id: ontology.ID, labels: Key[], opts: SetOptions = {}): Promise<void> {
|
|
81
|
-
await
|
|
82
|
-
this.client,
|
|
80
|
+
await this.client.send(
|
|
83
81
|
"/label/set",
|
|
84
82
|
{ id, labels, replace: opts.replace },
|
|
85
83
|
setReqZ,
|
|
@@ -88,21 +86,14 @@ export class Client {
|
|
|
88
86
|
}
|
|
89
87
|
|
|
90
88
|
async remove(id: ontology.ID, labels: Key[]): Promise<void> {
|
|
91
|
-
await
|
|
92
|
-
this.client,
|
|
93
|
-
"/label/remove",
|
|
94
|
-
{ id, labels },
|
|
95
|
-
removeReqZ,
|
|
96
|
-
emptyResZ,
|
|
97
|
-
);
|
|
89
|
+
await this.client.send("/label/remove", { id, labels }, removeReqZ, emptyResZ);
|
|
98
90
|
}
|
|
99
91
|
|
|
100
92
|
async create(label: New): Promise<Label>;
|
|
101
93
|
async create(labels: New[]): Promise<Label[]>;
|
|
102
94
|
async create(labels: New | New[]): Promise<Label | Label[]> {
|
|
103
95
|
const isMany = Array.isArray(labels);
|
|
104
|
-
const res = await
|
|
105
|
-
this.client,
|
|
96
|
+
const res = await this.client.send(
|
|
106
97
|
"/label/create",
|
|
107
98
|
{ labels: array.toArray(labels) },
|
|
108
99
|
createReqZ,
|
|
@@ -112,8 +103,7 @@ export class Client {
|
|
|
112
103
|
}
|
|
113
104
|
|
|
114
105
|
async delete(keys: Key | Key[]): Promise<void> {
|
|
115
|
-
await
|
|
116
|
-
this.client,
|
|
106
|
+
await this.client.send(
|
|
117
107
|
"/label/delete",
|
|
118
108
|
{ keys: array.toArray(keys) },
|
|
119
109
|
deleteReqZ,
|
package/src/label/label.spec.ts
CHANGED
|
@@ -7,6 +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 { id } from "@synnaxlabs/x";
|
|
10
11
|
import { describe, expect, it } from "vitest";
|
|
11
12
|
|
|
12
13
|
import { label } from "@/label";
|
|
@@ -34,6 +35,17 @@ describe("Label", () => {
|
|
|
34
35
|
const retrieved = await client.labels.retrieve({ key: v.key });
|
|
35
36
|
expect(retrieved).toEqual(v);
|
|
36
37
|
});
|
|
38
|
+
it("should retrieve labels by search term", async () => {
|
|
39
|
+
const prefix = `searchable-label-${id.create()}`;
|
|
40
|
+
const names = [`${prefix}-1`, `${prefix}-2`];
|
|
41
|
+
await client.labels.create(names.map((name) => ({ name, color: "#E774D0" })));
|
|
42
|
+
await expect
|
|
43
|
+
.poll(async () => {
|
|
44
|
+
const results = await client.labels.retrieve({ searchTerm: prefix });
|
|
45
|
+
return results.map((l) => l.name).sort();
|
|
46
|
+
})
|
|
47
|
+
.toEqual(names);
|
|
48
|
+
});
|
|
37
49
|
});
|
|
38
50
|
|
|
39
51
|
describe("delete", () => {
|
package/src/lineplot/client.ts
CHANGED
|
@@ -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 {
|
|
10
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { array, caseconv, record } from "@synnaxlabs/x";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
@@ -61,8 +61,7 @@ export class Client {
|
|
|
61
61
|
linePlots: New | New[],
|
|
62
62
|
): Promise<LinePlot | LinePlot[]> {
|
|
63
63
|
const isMany = Array.isArray(linePlots);
|
|
64
|
-
const res = await
|
|
65
|
-
this.client,
|
|
64
|
+
const res = await this.client.send(
|
|
66
65
|
"/lineplot/create",
|
|
67
66
|
{ workspace, linePlots: array.toArray(linePlots) },
|
|
68
67
|
createReqZ,
|
|
@@ -72,23 +71,11 @@ export class Client {
|
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
async rename(key: Key, name: string): Promise<void> {
|
|
75
|
-
await
|
|
76
|
-
this.client,
|
|
77
|
-
"/lineplot/rename",
|
|
78
|
-
{ key, name },
|
|
79
|
-
renameReqZ,
|
|
80
|
-
emptyResZ,
|
|
81
|
-
);
|
|
74
|
+
await this.client.send("/lineplot/rename", { key, name }, renameReqZ, emptyResZ);
|
|
82
75
|
}
|
|
83
76
|
|
|
84
77
|
async setData(key: Key, data: record.Unknown): Promise<void> {
|
|
85
|
-
await
|
|
86
|
-
this.client,
|
|
87
|
-
"/lineplot/set-data",
|
|
88
|
-
{ key, data },
|
|
89
|
-
setDataReqZ,
|
|
90
|
-
emptyResZ,
|
|
91
|
-
);
|
|
78
|
+
await this.client.send("/lineplot/set-data", { key, data }, setDataReqZ, emptyResZ);
|
|
92
79
|
}
|
|
93
80
|
|
|
94
81
|
async retrieve(args: RetrieveSingleParams): Promise<LinePlot>;
|
|
@@ -97,8 +84,7 @@ export class Client {
|
|
|
97
84
|
args: RetrieveSingleParams | RetrieveMultipleParams,
|
|
98
85
|
): Promise<LinePlot | LinePlot[]> {
|
|
99
86
|
const isSingle = singleRetrieveArgsZ.safeParse(args).success;
|
|
100
|
-
const res = await
|
|
101
|
-
this.client,
|
|
87
|
+
const res = await this.client.send(
|
|
102
88
|
"/lineplot/retrieve",
|
|
103
89
|
args,
|
|
104
90
|
retrieveArgsZ,
|
|
@@ -109,8 +95,7 @@ export class Client {
|
|
|
109
95
|
}
|
|
110
96
|
|
|
111
97
|
async delete(keys: Key | Key[]): Promise<void> {
|
|
112
|
-
await
|
|
113
|
-
this.client,
|
|
98
|
+
await this.client.send(
|
|
114
99
|
"/lineplot/delete",
|
|
115
100
|
{ keys: array.toArray(keys) },
|
|
116
101
|
deleteReqZ,
|
package/src/log/client.ts
CHANGED
|
@@ -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 {
|
|
10
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { array, caseconv, record } from "@synnaxlabs/x";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
@@ -51,8 +51,7 @@ export class Client {
|
|
|
51
51
|
async create(workspace: workspace.Key, logs: New[]): Promise<Log[]>;
|
|
52
52
|
async create(workspace: workspace.Key, logs: New | New[]): Promise<Log | Log[]> {
|
|
53
53
|
const isMany = Array.isArray(logs);
|
|
54
|
-
const res = await
|
|
55
|
-
this.client,
|
|
54
|
+
const res = await this.client.send(
|
|
56
55
|
"/log/create",
|
|
57
56
|
{ workspace, logs: array.toArray(logs) },
|
|
58
57
|
createReqZ,
|
|
@@ -62,23 +61,11 @@ export class Client {
|
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
async rename(key: Key, name: string): Promise<void> {
|
|
65
|
-
await
|
|
66
|
-
this.client,
|
|
67
|
-
"/log/rename",
|
|
68
|
-
{ key, name },
|
|
69
|
-
renameReqZ,
|
|
70
|
-
emptyResZ,
|
|
71
|
-
);
|
|
64
|
+
await this.client.send("/log/rename", { key, name }, renameReqZ, emptyResZ);
|
|
72
65
|
}
|
|
73
66
|
|
|
74
67
|
async setData(key: Key, data: record.Unknown): Promise<void> {
|
|
75
|
-
await
|
|
76
|
-
this.client,
|
|
77
|
-
"/log/set-data",
|
|
78
|
-
{ key, data },
|
|
79
|
-
setDataReqZ,
|
|
80
|
-
emptyResZ,
|
|
81
|
-
);
|
|
68
|
+
await this.client.send("/log/set-data", { key, data }, setDataReqZ, emptyResZ);
|
|
82
69
|
}
|
|
83
70
|
|
|
84
71
|
async retrieve(args: RetrieveSingleParams): Promise<Log>;
|
|
@@ -87,8 +74,7 @@ export class Client {
|
|
|
87
74
|
args: RetrieveSingleParams | RetrieveMultipleParams,
|
|
88
75
|
): Promise<Log | Log[]> {
|
|
89
76
|
const isSingle = singleRetrieveArgsZ.safeParse(args).success;
|
|
90
|
-
const res = await
|
|
91
|
-
this.client,
|
|
77
|
+
const res = await this.client.send(
|
|
92
78
|
"/log/retrieve",
|
|
93
79
|
args,
|
|
94
80
|
retrieveArgsZ,
|
|
@@ -99,8 +85,7 @@ export class Client {
|
|
|
99
85
|
}
|
|
100
86
|
|
|
101
87
|
async delete(keys: Key | Key[]): Promise<void> {
|
|
102
|
-
await
|
|
103
|
-
this.client,
|
|
88
|
+
await this.client.send(
|
|
104
89
|
"/log/delete",
|
|
105
90
|
{ keys: array.toArray(keys) },
|
|
106
91
|
deleteReqZ,
|
package/src/ontology/client.ts
CHANGED
|
@@ -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 {
|
|
10
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { array, strings } from "@synnaxlabs/x";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
@@ -163,8 +163,7 @@ export class Client {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
private async execRetrieve(request: RetrieveRequest): Promise<Resource[]> {
|
|
166
|
-
const { resources } = await
|
|
167
|
-
this.client,
|
|
166
|
+
const { resources } = await this.client.send(
|
|
168
167
|
"/ontology/retrieve",
|
|
169
168
|
request,
|
|
170
169
|
retrieveReqZ,
|
|
@@ -154,6 +154,16 @@ describe("Ontology", () => {
|
|
|
154
154
|
expect(parents.length).toEqual(1);
|
|
155
155
|
expect(parents[0].name).toEqual(name);
|
|
156
156
|
});
|
|
157
|
+
test("retrieve by search term", async () => {
|
|
158
|
+
const name = randomName();
|
|
159
|
+
const g = await client.groups.create({ parent: ontology.ROOT_ID, name });
|
|
160
|
+
await expect
|
|
161
|
+
.poll(async () => {
|
|
162
|
+
const results = await client.ontology.retrieve({ searchTerm: name });
|
|
163
|
+
return results.find((r) => r.id.key === g.key);
|
|
164
|
+
})
|
|
165
|
+
.toMatchObject({ name, id: { type: "group", key: g.key } });
|
|
166
|
+
});
|
|
157
167
|
});
|
|
158
168
|
|
|
159
169
|
describe("write", () => {
|
package/src/ontology/writer.ts
CHANGED
|
@@ -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 {
|
|
10
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
13
|
import { type ID, idZ } from "@/ontology/payload";
|
|
@@ -24,8 +24,7 @@ export class Writer {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
async addChildren(id: ID, ...children: ID[]): Promise<void> {
|
|
27
|
-
await
|
|
28
|
-
this.client,
|
|
27
|
+
await this.client.send(
|
|
29
28
|
"/ontology/add-children",
|
|
30
29
|
{ id, children },
|
|
31
30
|
addRemoveChildrenReqZ,
|
|
@@ -34,8 +33,7 @@ export class Writer {
|
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
async removeChildren(id: ID, ...children: ID[]): Promise<void> {
|
|
37
|
-
await
|
|
38
|
-
this.client,
|
|
36
|
+
await this.client.send(
|
|
39
37
|
"/ontology/remove-children",
|
|
40
38
|
{ id, children },
|
|
41
39
|
addRemoveChildrenReqZ,
|
|
@@ -44,8 +42,7 @@ export class Writer {
|
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
async moveChildren(from: ID, to: ID, ...children: ID[]): Promise<void> {
|
|
47
|
-
await
|
|
48
|
-
this.client,
|
|
45
|
+
await this.client.send(
|
|
49
46
|
"/ontology/move-children",
|
|
50
47
|
{ from, to, children },
|
|
51
48
|
moveChildrenReqZ,
|
package/src/rack/client.ts
CHANGED
|
@@ -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 {
|
|
10
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { array } from "@synnaxlabs/x";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
@@ -82,8 +82,7 @@ export class Client {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
async delete(keys: Key | Key[]): Promise<void> {
|
|
85
|
-
await
|
|
86
|
-
this.client,
|
|
85
|
+
await this.client.send(
|
|
87
86
|
"/rack/delete",
|
|
88
87
|
{ keys: array.toArray(keys) },
|
|
89
88
|
deleteReqZ,
|
|
@@ -95,8 +94,7 @@ export class Client {
|
|
|
95
94
|
async create(racks: New[]): Promise<Rack[]>;
|
|
96
95
|
async create(rack: New | New[]): Promise<Rack | Rack[]> {
|
|
97
96
|
const isSingle = !Array.isArray(rack);
|
|
98
|
-
const res = await
|
|
99
|
-
this.client,
|
|
97
|
+
const res = await this.client.send(
|
|
100
98
|
"/rack/create",
|
|
101
99
|
{ racks: array.toArray(rack) },
|
|
102
100
|
createReqZ,
|
|
@@ -110,8 +108,7 @@ export class Client {
|
|
|
110
108
|
async retrieve(args: RetrieveMultipleParams): Promise<Rack[]>;
|
|
111
109
|
async retrieve(args: RetrieveArgs): Promise<Rack | Rack[]> {
|
|
112
110
|
const isSingle = "key" in args || "name" in args;
|
|
113
|
-
const res = await
|
|
114
|
-
this.client,
|
|
111
|
+
const res = await this.client.send(
|
|
115
112
|
"/rack/retrieve",
|
|
116
113
|
args,
|
|
117
114
|
retrieveArgsZ,
|
package/src/rack/rack.spec.ts
CHANGED
|
@@ -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 { TimeStamp, zod } from "@synnaxlabs/x";
|
|
10
|
+
import { id, TimeStamp, zod } from "@synnaxlabs/x";
|
|
11
11
|
import { describe, expect, it } from "vitest";
|
|
12
12
|
|
|
13
13
|
import { type rack } from "@/rack";
|
|
@@ -77,6 +77,17 @@ describe("Rack", () => {
|
|
|
77
77
|
expect(retrieved.key).toBe(r.key);
|
|
78
78
|
expect(retrieved.name).toEqual(name);
|
|
79
79
|
});
|
|
80
|
+
it("should retrieve racks by search term", async () => {
|
|
81
|
+
const prefix = `searchable-rack-${id.create()}`;
|
|
82
|
+
const names = [`${prefix}-1`, `${prefix}-2`];
|
|
83
|
+
await client.racks.create(names.map((name) => ({ name })));
|
|
84
|
+
await expect
|
|
85
|
+
.poll(async () => {
|
|
86
|
+
const results = await client.racks.retrieve({ searchTerm: prefix });
|
|
87
|
+
return results.map((r) => r.name).sort();
|
|
88
|
+
})
|
|
89
|
+
.toEqual(names);
|
|
90
|
+
});
|
|
80
91
|
});
|
|
81
92
|
describe("integrations", () => {
|
|
82
93
|
it("should create a rack with integrations and retrieve them", async () => {
|
|
@@ -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 {
|
|
10
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { array } from "@synnaxlabs/x";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
@@ -64,8 +64,7 @@ export class Client {
|
|
|
64
64
|
else toFetch.push(alias);
|
|
65
65
|
});
|
|
66
66
|
if (toFetch.length === 0) return cached;
|
|
67
|
-
const res = await
|
|
68
|
-
this.client,
|
|
67
|
+
const res = await this.client.send(
|
|
69
68
|
"/range/alias/resolve",
|
|
70
69
|
{ range: this.rangeKey, aliases: toFetch },
|
|
71
70
|
resolveReqZ,
|
|
@@ -76,8 +75,7 @@ export class Client {
|
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
async set(aliases: Record<channel.Key, string>): Promise<void> {
|
|
79
|
-
await
|
|
80
|
-
this.client,
|
|
78
|
+
await this.client.send(
|
|
81
79
|
"/range/alias/set",
|
|
82
80
|
{ range: this.rangeKey, aliases },
|
|
83
81
|
setReqZ,
|
|
@@ -87,8 +85,7 @@ export class Client {
|
|
|
87
85
|
|
|
88
86
|
async list(): Promise<Record<channel.Key, string>> {
|
|
89
87
|
return (
|
|
90
|
-
await
|
|
91
|
-
this.client,
|
|
88
|
+
await this.client.send(
|
|
92
89
|
"/range/alias/list",
|
|
93
90
|
{ range: this.rangeKey },
|
|
94
91
|
listReqZ,
|
|
@@ -104,8 +101,7 @@ export class Client {
|
|
|
104
101
|
alias: channel.Key | channel.Key[],
|
|
105
102
|
): Promise<string | Record<channel.Key, string>> {
|
|
106
103
|
const isSingle = typeof alias === "number";
|
|
107
|
-
const res = await
|
|
108
|
-
this.client,
|
|
104
|
+
const res = await this.client.send(
|
|
109
105
|
"/range/alias/retrieve",
|
|
110
106
|
{ range: this.rangeKey, channels: array.toArray(alias) },
|
|
111
107
|
retrieveReqZ,
|
|
@@ -115,8 +111,7 @@ export class Client {
|
|
|
115
111
|
}
|
|
116
112
|
|
|
117
113
|
async delete(aliases: channel.Key | channel.Key[]): Promise<void> {
|
|
118
|
-
await
|
|
119
|
-
this.client,
|
|
114
|
+
await this.client.send(
|
|
120
115
|
"/range/alias/delete",
|
|
121
116
|
{ range: this.rangeKey, channels: array.toArray(aliases) },
|
|
122
117
|
deleteReqZ,
|
package/src/ranger/client.ts
CHANGED
|
@@ -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 {
|
|
10
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import {
|
|
12
12
|
array,
|
|
13
13
|
color,
|
|
@@ -249,8 +249,7 @@ export class Client {
|
|
|
249
249
|
async retrieve(params: RetrieveRequest): Promise<Range[]>;
|
|
250
250
|
async retrieve(params: RetrieveArgs): Promise<Range | Range[]> {
|
|
251
251
|
const isSingle = typeof params === "string";
|
|
252
|
-
const { ranges } = await
|
|
253
|
-
this.unaryClient,
|
|
252
|
+
const { ranges } = await this.unaryClient.send(
|
|
254
253
|
"/range/retrieve",
|
|
255
254
|
params,
|
|
256
255
|
retrieveArgsZ,
|