@synnaxlabs/client 0.15.0 → 0.15.2
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/client.cjs.js +8 -8
- package/dist/client.cjs.js.map +1 -1
- package/dist/client.es.js +2921 -2798
- package/dist/client.es.js.map +1 -1
- package/dist/control/authority.d.ts +2 -2
- package/dist/framer/client.d.ts +1 -1
- package/dist/framer/writer.d.ts +20 -7
- package/dist/hardware/device/client.d.ts +5 -2
- package/dist/hardware/device/retriever.d.ts +2 -0
- package/dist/hardware/external.d.ts +0 -1
- package/dist/hardware/rack/client.d.ts +7 -3
- package/dist/hardware/rack/retriever.d.ts +2 -0
- package/dist/hardware/task/client.d.ts +5 -2
- package/dist/hardware/task/payload.d.ts +4 -3
- package/dist/hardware/task/retriever.d.ts +8 -0
- package/dist/index.d.ts +3 -0
- package/dist/workspace/lineplot/payload.d.ts +3 -2
- package/dist/workspace/lineplot/writer.d.ts +2 -2
- package/dist/workspace/payload.d.ts +3 -2
- package/dist/workspace/pid/payload.d.ts +3 -2
- package/dist/workspace/pid/writer.d.ts +2 -2
- package/dist/workspace/writer.d.ts +3 -3
- package/package.json +5 -5
- package/src/client.ts +1 -0
- package/src/control/authority.ts +2 -2
- package/src/framer/adapter.ts +14 -7
- package/src/framer/client.ts +9 -3
- package/src/framer/writer.spec.ts +31 -3
- package/src/framer/writer.ts +23 -5
- package/src/hardware/device/client.ts +22 -3
- package/src/hardware/device/device.spec.ts +9 -0
- package/src/hardware/device/external.ts +9 -0
- package/src/hardware/device/index.ts +10 -1
- package/src/hardware/device/payload.ts +9 -0
- package/src/hardware/device/retriever.ts +22 -1
- package/src/hardware/device/writer.ts +9 -0
- package/src/hardware/external.ts +0 -1
- package/src/hardware/rack/client.ts +20 -4
- package/src/hardware/rack/external.ts +10 -1
- package/src/hardware/rack/index.ts +10 -1
- package/src/hardware/rack/payload.ts +10 -1
- package/src/hardware/rack/rack.spec.ts +9 -0
- package/src/hardware/rack/retriever.ts +34 -1
- package/src/hardware/task/client.ts +13 -3
- package/src/hardware/task/payload.ts +2 -0
- package/src/hardware/task/retriever.ts +22 -0
- package/src/index.ts +3 -0
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
import { AsyncTermSearcher, toArray } from "@synnaxlabs/x";
|
|
2
11
|
|
|
3
12
|
import { type framer } from "@/framer";
|
|
4
|
-
import { type Device, deviceZ } from "@/hardware/device/payload";
|
|
13
|
+
import { type Device, deviceZ, DeviceKey } from "@/hardware/device/payload";
|
|
5
14
|
import { type Retriever } from "@/hardware/device/retriever";
|
|
6
15
|
import { type Writer } from "@/hardware/device/writer";
|
|
7
16
|
import { signals } from "@/signals";
|
|
@@ -9,7 +18,7 @@ import { signals } from "@/signals";
|
|
|
9
18
|
const DEVICE_SET_NAME = "sy_device_set";
|
|
10
19
|
const DEVICE_DELETE_NAME = "sy_device_delete";
|
|
11
20
|
|
|
12
|
-
export class Client {
|
|
21
|
+
export class Client implements AsyncTermSearcher<string, DeviceKey, Device>{
|
|
13
22
|
private readonly retriever: Retriever;
|
|
14
23
|
private readonly writer: Writer;
|
|
15
24
|
private readonly frameClient: framer.Client;
|
|
@@ -33,6 +42,16 @@ export class Client {
|
|
|
33
42
|
return Array.isArray(keys) ? res : res[0];
|
|
34
43
|
}
|
|
35
44
|
|
|
45
|
+
async search(term: string): Promise<Device[]> {
|
|
46
|
+
const res = await this.retriever.search(term);
|
|
47
|
+
return res;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async page(offset: number, limit: number): Promise<Device[]> {
|
|
51
|
+
const res = await this.retriever.page(offset, limit);
|
|
52
|
+
return res;
|
|
53
|
+
}
|
|
54
|
+
|
|
36
55
|
async delete(keys: string[]): Promise<void> {
|
|
37
56
|
await this.writer.delete(keys);
|
|
38
57
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
1
10
|
import { describe, expect, it } from "vitest";
|
|
2
11
|
|
|
3
12
|
import { newClient } from "@/setupspecs";
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
1
10
|
export * from "@/hardware/device/client";
|
|
2
11
|
export * from "@/hardware/device/retriever";
|
|
3
12
|
export * from "@/hardware/device/writer";
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
export * as device from "@/hardware/device/external";
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
1
10
|
import { z } from "zod";
|
|
2
11
|
|
|
3
12
|
import { rackKeyZ } from "@/hardware/rack/payload";
|
|
@@ -11,11 +11,15 @@ import { type UnaryClient, sendRequired } from "@synnaxlabs/freighter";
|
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
13
|
import { type Device, deviceKeyZ, deviceZ } from "@/hardware/device/payload";
|
|
14
|
+
import { AsyncTermSearcher } from "@synnaxlabs/x";
|
|
14
15
|
|
|
15
16
|
const RETRIEVE_ENDPOINT = "/hardware/device/retrieve";
|
|
16
17
|
|
|
17
18
|
const retrieveDeviceReqZ = z.object({
|
|
18
|
-
|
|
19
|
+
search: z.string().optional(),
|
|
20
|
+
limit: z.number().optional(),
|
|
21
|
+
offset: z.number().optional(),
|
|
22
|
+
keys: deviceKeyZ.array().optional(),
|
|
19
23
|
});
|
|
20
24
|
|
|
21
25
|
const retrieveDeviceResZ = z.object({
|
|
@@ -29,6 +33,23 @@ export class Retriever {
|
|
|
29
33
|
this.client = client;
|
|
30
34
|
}
|
|
31
35
|
|
|
36
|
+
async search(term: string): Promise<Device[]> {
|
|
37
|
+
const res = await sendRequired<
|
|
38
|
+
typeof retrieveDeviceReqZ,
|
|
39
|
+
typeof retrieveDeviceResZ
|
|
40
|
+
>(this.client, RETRIEVE_ENDPOINT, { keys: [term] }, retrieveDeviceResZ);
|
|
41
|
+
return res.devices;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async page(offset: number, limit: number): Promise<Device[]> {
|
|
45
|
+
const res = await sendRequired<
|
|
46
|
+
typeof retrieveDeviceReqZ,
|
|
47
|
+
typeof retrieveDeviceResZ
|
|
48
|
+
>(this.client, RETRIEVE_ENDPOINT, { offset, limit }, retrieveDeviceResZ);
|
|
49
|
+
return res.devices;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
32
53
|
async retrieve(keys: string[]): Promise<Device[]> {
|
|
33
54
|
const res = await sendRequired<
|
|
34
55
|
typeof retrieveDeviceReqZ,
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
1
10
|
import { type UnaryClient, sendRequired } from "@synnaxlabs/freighter";
|
|
2
11
|
import { z } from "zod";
|
|
3
12
|
|
package/src/hardware/external.ts
CHANGED
|
@@ -8,14 +8,15 @@
|
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
10
|
import { type framer } from "@/framer";
|
|
11
|
-
import { type NewRack, type RackPayload } from "@/hardware/rack/payload";
|
|
11
|
+
import { RackKey, type NewRack, type RackPayload } from "@/hardware/rack/payload";
|
|
12
12
|
import { type Retriever } from "@/hardware/rack/retriever";
|
|
13
13
|
import { type Writer } from "@/hardware/rack/writer";
|
|
14
14
|
import { type NewTask, type Task } from "@/hardware/task/payload";
|
|
15
15
|
import { type Retriever as TaskRetriever } from "@/hardware/task/retriever";
|
|
16
16
|
import { type Writer as TaskWriter } from "@/hardware/task/writer";
|
|
17
|
+
import { AsyncTermSearcher, toArray } from "@synnaxlabs/x";
|
|
17
18
|
|
|
18
|
-
export class Client {
|
|
19
|
+
export class Client implements AsyncTermSearcher<string, RackKey, Rack> {
|
|
19
20
|
private readonly retriever: Retriever;
|
|
20
21
|
private readonly writer: Writer;
|
|
21
22
|
private readonly frameClient: framer.Client;
|
|
@@ -41,8 +42,23 @@ export class Client {
|
|
|
41
42
|
return this.sugar(res)[0];
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
async
|
|
45
|
-
const res = await this.retriever.
|
|
45
|
+
async search(term: string): Promise<Rack[]> {
|
|
46
|
+
const res = await this.retriever.search(term);
|
|
47
|
+
return this.sugar(res);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async page(offset: number, limit: number): Promise<Rack[]> {
|
|
51
|
+
const res = await this.retriever.page(offset, limit);
|
|
52
|
+
return this.sugar(res);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async retrieve(key: RackKey): Promise<Rack>;
|
|
56
|
+
|
|
57
|
+
async retrieve(keys: RackKey[]): Promise<Rack[]>;
|
|
58
|
+
|
|
59
|
+
async retrieve(key: RackKey | RackKey[]): Promise<Rack | Rack[]> {
|
|
60
|
+
const res = await this.retriever.retrieve(toArray(key));
|
|
61
|
+
if (Array.isArray(key)) return this.sugar(res);
|
|
46
62
|
return this.sugar(res)[0];
|
|
47
63
|
}
|
|
48
64
|
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
1
10
|
export * from "@/hardware/rack/client";
|
|
2
11
|
export * from "@/hardware/rack/writer";
|
|
3
|
-
export * from "@/hardware/rack/retriever";
|
|
12
|
+
export * from "@/hardware/rack/retriever";
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
export * as rack from "@/hardware/rack/external";
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
1
10
|
import { z } from "zod";
|
|
2
11
|
|
|
3
12
|
|
|
@@ -14,4 +23,4 @@ export type RackPayload = z.infer<typeof rackZ>;
|
|
|
14
23
|
|
|
15
24
|
export const newRackZ = rackZ.partial({ key: true });
|
|
16
25
|
|
|
17
|
-
export type NewRack = z.input<typeof newRackZ>;
|
|
26
|
+
export type NewRack = z.input<typeof newRackZ>;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
1
10
|
import { describe, expect, it } from "vitest";
|
|
2
11
|
|
|
3
12
|
import { newClient } from "@/setupspecs";
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
1
10
|
import { type UnaryClient, sendRequired } from "@synnaxlabs/freighter";
|
|
2
11
|
import { z } from "zod";
|
|
3
12
|
|
|
@@ -6,13 +15,17 @@ import { rackKeyZ, rackZ, type RackPayload } from "@/hardware/rack/payload";
|
|
|
6
15
|
const RETRIEVE_ENDPOINT = "/hardware/rack/retrieve";
|
|
7
16
|
|
|
8
17
|
const retrieveRackReqZ = z.object({
|
|
9
|
-
keys: rackKeyZ.array(),
|
|
18
|
+
keys: rackKeyZ.array().optional(),
|
|
19
|
+
search: z.string().optional(),
|
|
20
|
+
offset: z.number().optional(),
|
|
21
|
+
limit: z.number().optional(),
|
|
10
22
|
});
|
|
11
23
|
|
|
12
24
|
const retrieveRackResZ = z.object({
|
|
13
25
|
racks: rackZ.array(),
|
|
14
26
|
});
|
|
15
27
|
|
|
28
|
+
|
|
16
29
|
export class Retriever {
|
|
17
30
|
private readonly client: UnaryClient;
|
|
18
31
|
|
|
@@ -20,6 +33,26 @@ export class Retriever {
|
|
|
20
33
|
this.client = client;
|
|
21
34
|
}
|
|
22
35
|
|
|
36
|
+
async page(offset: number, limit: number): Promise<RackPayload[]> {
|
|
37
|
+
const res = await sendRequired<typeof retrieveRackReqZ, typeof retrieveRackResZ>(
|
|
38
|
+
this.client,
|
|
39
|
+
RETRIEVE_ENDPOINT,
|
|
40
|
+
{ offset, limit },
|
|
41
|
+
retrieveRackResZ,
|
|
42
|
+
);
|
|
43
|
+
return res.racks;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async search(term: string): Promise<RackPayload[]> {
|
|
47
|
+
const res = await sendRequired<typeof retrieveRackReqZ, typeof retrieveRackResZ>(
|
|
48
|
+
this.client,
|
|
49
|
+
RETRIEVE_ENDPOINT,
|
|
50
|
+
{ search: term },
|
|
51
|
+
retrieveRackResZ,
|
|
52
|
+
);
|
|
53
|
+
return res.racks;
|
|
54
|
+
}
|
|
55
|
+
|
|
23
56
|
async retrieve(keys: number[]): Promise<RackPayload[]> {
|
|
24
57
|
const res = await sendRequired<typeof retrieveRackReqZ, typeof retrieveRackResZ>(
|
|
25
58
|
this.client,
|
|
@@ -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 { toArray } from "@synnaxlabs/x";
|
|
10
|
+
import { AsyncTermSearcher, toArray } from "@synnaxlabs/x";
|
|
11
11
|
|
|
12
|
-
import { type NewTask, type Task } from "@/hardware/task/payload";
|
|
12
|
+
import { TaskKey, type NewTask, type Task } from "@/hardware/task/payload";
|
|
13
13
|
import { type RetrieveRequest, type Retriever } from "@/hardware/task/retriever";
|
|
14
14
|
import { type Writer } from "@/hardware/task/writer";
|
|
15
15
|
|
|
16
|
-
export class Client {
|
|
16
|
+
export class Client implements AsyncTermSearcher<string, TaskKey, Task> {
|
|
17
17
|
private readonly retriever: Retriever;
|
|
18
18
|
private readonly writer: Writer;
|
|
19
19
|
|
|
@@ -22,6 +22,16 @@ export class Client {
|
|
|
22
22
|
this.writer = writer;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
async search(term: string): Promise<Task[]> {
|
|
26
|
+
const res = await this.retriever.search(term);
|
|
27
|
+
return res;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async page(offset: number, limit: number): Promise<Task[]> {
|
|
31
|
+
const res = await this.retriever.page(offset, limit);
|
|
32
|
+
return res;
|
|
33
|
+
}
|
|
34
|
+
|
|
25
35
|
async create(task: NewTask): Promise<Task> {
|
|
26
36
|
const res = await this.writer.create([task]);
|
|
27
37
|
return res[0];
|
|
@@ -16,6 +16,8 @@ import { type Task, taskZ } from "@/hardware/task/payload";
|
|
|
16
16
|
const retrieveReqZ = z.object({
|
|
17
17
|
rack: rackKeyZ.optional(),
|
|
18
18
|
keys: z.string().array().optional(),
|
|
19
|
+
offset: z.number().optional(),
|
|
20
|
+
limit: z.number().optional(),
|
|
19
21
|
});
|
|
20
22
|
|
|
21
23
|
const rerieveResS = z.object({
|
|
@@ -42,4 +44,24 @@ export class Retriever {
|
|
|
42
44
|
);
|
|
43
45
|
return res.tasks;
|
|
44
46
|
}
|
|
47
|
+
|
|
48
|
+
async search(term: string): Promise<Task[]> {
|
|
49
|
+
const res = await sendRequired<typeof retrieveReqZ, typeof rerieveResS>(
|
|
50
|
+
this.client,
|
|
51
|
+
RETRIEVE_ENDPOINT,
|
|
52
|
+
{ keys: [term] },
|
|
53
|
+
rerieveResS,
|
|
54
|
+
);
|
|
55
|
+
return res.tasks;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async page(offset: number, limit: number): Promise<Task[]> {
|
|
59
|
+
const res = await sendRequired<typeof retrieveReqZ, typeof rerieveResS>(
|
|
60
|
+
this.client,
|
|
61
|
+
RETRIEVE_ENDPOINT,
|
|
62
|
+
{ offset, limit },
|
|
63
|
+
rerieveResS,
|
|
64
|
+
);
|
|
65
|
+
return res.tasks;
|
|
66
|
+
}
|
|
45
67
|
}
|
package/src/index.ts
CHANGED
|
@@ -52,3 +52,6 @@ export { workspace } from "@/workspace";
|
|
|
52
52
|
export { ranger } from "@/ranger";
|
|
53
53
|
export { label } from "@/label";
|
|
54
54
|
export { hardware } from "@/hardware";
|
|
55
|
+
export { rack } from "@/hardware/rack";
|
|
56
|
+
export { task } from "@/hardware/task";
|
|
57
|
+
export { device } from "@/hardware/device";
|