@synnaxlabs/client 0.34.0 → 0.36.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/payload.d.ts +40 -40
- package/dist/access/policy/retriever.d.ts +5 -5
- package/dist/client.cjs +28 -28
- package/dist/client.d.ts +35 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3092 -2820
- package/dist/control/state.d.ts.map +1 -1
- package/dist/framer/deleter.d.ts.map +1 -1
- package/dist/framer/frame.d.ts +14 -7
- package/dist/framer/frame.d.ts.map +1 -1
- package/dist/framer/writer.d.ts +8 -8
- package/dist/framer/writer.d.ts.map +1 -1
- package/dist/hardware/device/client.d.ts +2 -2
- package/dist/hardware/device/client.d.ts.map +1 -1
- package/dist/hardware/device/payload.d.ts +2 -2
- package/dist/hardware/device/payload.d.ts.map +1 -1
- package/dist/hardware/task/client.d.ts +4 -2
- package/dist/hardware/task/client.d.ts.map +1 -1
- package/dist/hardware/task/payload.d.ts +9 -5
- package/dist/hardware/task/payload.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/label/writer.d.ts +5 -5
- package/dist/ontology/client.d.ts +8 -8
- package/dist/ontology/group/payload.d.ts +3 -0
- package/dist/ontology/group/payload.d.ts.map +1 -1
- package/dist/ontology/payload.d.ts +43 -43
- package/dist/ontology/payload.d.ts.map +1 -1
- package/dist/ranger/client.d.ts +1 -0
- package/dist/ranger/client.d.ts.map +1 -1
- package/dist/ranger/payload.d.ts.map +1 -1
- package/dist/ranger/writer.d.ts +5 -5
- package/dist/ranger/writer.d.ts.map +1 -1
- package/dist/transport.d.ts +2 -1
- package/dist/transport.d.ts.map +1 -1
- package/dist/workspace/client.d.ts +70 -11
- package/dist/workspace/client.d.ts.map +1 -1
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/lineplot/client.d.ts +48 -6
- package/dist/workspace/lineplot/client.d.ts.map +1 -1
- package/dist/workspace/lineplot/index.d.ts +1 -1
- package/dist/workspace/lineplot/index.d.ts.map +1 -1
- package/dist/workspace/log/client.d.ts +48 -6
- package/dist/workspace/log/client.d.ts.map +1 -1
- package/dist/workspace/log/index.d.ts +1 -1
- package/dist/workspace/log/index.d.ts.map +1 -1
- package/dist/workspace/schematic/client.d.ts +72 -6
- package/dist/workspace/schematic/client.d.ts.map +1 -1
- package/dist/workspace/schematic/index.d.ts +1 -1
- package/dist/workspace/schematic/index.d.ts.map +1 -1
- package/dist/workspace/table/client.d.ts +71 -0
- package/dist/workspace/table/client.d.ts.map +1 -0
- package/dist/workspace/table/index.d.ts +2 -0
- package/dist/workspace/table/index.d.ts.map +1 -0
- package/dist/workspace/table/table.spec.d.ts +2 -0
- package/dist/workspace/table/table.spec.d.ts.map +1 -0
- package/package.json +10 -10
- package/src/client.ts +16 -2
- package/src/control/state.ts +1 -1
- package/src/framer/frame.spec.ts +32 -3
- package/src/framer/frame.ts +17 -0
- package/src/hardware/device/client.ts +10 -4
- package/src/hardware/task/client.ts +51 -3
- package/src/hardware/task/payload.ts +21 -6
- package/src/index.ts +2 -0
- package/src/ontology/group/payload.ts +8 -7
- package/src/ontology/payload.ts +1 -0
- package/src/ranger/client.ts +4 -1
- package/src/transport.ts +8 -3
- package/src/workspace/client.ts +151 -47
- package/src/workspace/index.ts +1 -1
- package/src/workspace/lineplot/client.ts +96 -28
- package/src/workspace/lineplot/index.ts +1 -1
- package/src/workspace/log/client.ts +93 -28
- package/src/workspace/log/index.ts +1 -1
- package/src/workspace/schematic/client.ts +121 -29
- package/src/workspace/schematic/index.ts +1 -1
- package/src/workspace/table/client.ts +125 -0
- package/src/workspace/{external.ts → table/index.ts} +1 -2
- package/src/workspace/table/table.spec.ts +65 -0
- package/dist/workspace/external.d.ts +0 -3
- package/dist/workspace/external.d.ts.map +0 -1
- package/dist/workspace/lineplot/external.d.ts +0 -3
- package/dist/workspace/lineplot/external.d.ts.map +0 -1
- package/dist/workspace/lineplot/retriever.d.ts +0 -9
- package/dist/workspace/lineplot/retriever.d.ts.map +0 -1
- package/dist/workspace/lineplot/writer.d.ts +0 -35
- package/dist/workspace/lineplot/writer.d.ts.map +0 -1
- package/dist/workspace/log/external.d.ts +0 -3
- package/dist/workspace/log/external.d.ts.map +0 -1
- package/dist/workspace/log/payload.d.ts +0 -36
- package/dist/workspace/log/payload.d.ts.map +0 -1
- package/dist/workspace/log/retriever.d.ts +0 -9
- package/dist/workspace/log/retriever.d.ts.map +0 -1
- package/dist/workspace/log/writer.d.ts +0 -35
- package/dist/workspace/log/writer.d.ts.map +0 -1
- package/dist/workspace/payload.d.ts +0 -38
- package/dist/workspace/payload.d.ts.map +0 -1
- package/dist/workspace/retriever.d.ts +0 -13
- package/dist/workspace/retriever.d.ts.map +0 -1
- package/dist/workspace/schematic/external.d.ts +0 -3
- package/dist/workspace/schematic/external.d.ts.map +0 -1
- package/dist/workspace/schematic/payload.d.ts +0 -42
- package/dist/workspace/schematic/payload.d.ts.map +0 -1
- package/dist/workspace/schematic/retriever.d.ts +0 -9
- package/dist/workspace/schematic/retriever.d.ts.map +0 -1
- package/dist/workspace/schematic/writer.d.ts +0 -41
- package/dist/workspace/schematic/writer.d.ts.map +0 -1
- package/dist/workspace/writer.d.ts +0 -66
- package/dist/workspace/writer.d.ts.map +0 -1
- package/src/workspace/lineplot/external.ts +0 -11
- package/src/workspace/lineplot/retriever.ts +0 -34
- package/src/workspace/lineplot/writer.ts +0 -115
- package/src/workspace/log/external.ts +0 -11
- package/src/workspace/log/payload.ts +0 -36
- package/src/workspace/log/retriever.ts +0 -38
- package/src/workspace/log/writer.ts +0 -116
- package/src/workspace/payload.ts +0 -44
- package/src/workspace/retriever.ts +0 -70
- package/src/workspace/schematic/external.ts +0 -11
- package/src/workspace/schematic/payload.ts +0 -38
- package/src/workspace/schematic/retriever.ts +0 -42
- package/src/workspace/schematic/writer.ts +0 -140
- package/src/workspace/writer.ts +0 -111
package/src/workspace/payload.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
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 { type UnknownRecord, unknownRecordZ } from "@synnaxlabs/x/record";
|
|
11
|
-
import { z } from "zod";
|
|
12
|
-
|
|
13
|
-
import { ontology } from "@/ontology";
|
|
14
|
-
|
|
15
|
-
export const keyZ = z.string().uuid();
|
|
16
|
-
|
|
17
|
-
export type Key = z.infer<typeof keyZ>;
|
|
18
|
-
|
|
19
|
-
export type Params = Key | Key[];
|
|
20
|
-
|
|
21
|
-
// --- VERY IMPORTANT ---
|
|
22
|
-
// Synnax's encoders (in the binary package inside x) automatically convert the case
|
|
23
|
-
// of keys in objects to snake_case and back to camelCase when encoding and decoding
|
|
24
|
-
// respectively. This is done to ensure that the keys are consistent across all
|
|
25
|
-
// languages and platforms. Sometimes workspaces have keys that are uuids, which have
|
|
26
|
-
// dashes, and those get messed up. So we just use regular JSON for workspaces.
|
|
27
|
-
const parse = (s: string): UnknownRecord => JSON.parse(s) as UnknownRecord;
|
|
28
|
-
|
|
29
|
-
export const workspaceZ = z.object({
|
|
30
|
-
name: z.string(),
|
|
31
|
-
key: keyZ,
|
|
32
|
-
layout: unknownRecordZ.or(z.string().transform((s) => parse(s) as UnknownRecord)),
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
export const workspaceRemoteZ = workspaceZ.omit({ layout: true }).extend({
|
|
36
|
-
layout: z.string().transform((s) => parse(s) as UnknownRecord),
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
export type Workspace = z.infer<typeof workspaceZ>;
|
|
40
|
-
|
|
41
|
-
export const ONTOLOGY_TYPE: ontology.ResourceType = "workspace";
|
|
42
|
-
|
|
43
|
-
export const ontologyID = (key: Key): ontology.ID =>
|
|
44
|
-
new ontology.ID({ type: ONTOLOGY_TYPE, key });
|
|
@@ -1,70 +0,0 @@
|
|
|
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 { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
|
-
import { toArray } from "@synnaxlabs/x/toArray";
|
|
12
|
-
import { z } from "zod";
|
|
13
|
-
|
|
14
|
-
import { nullableArrayZ } from "@/util/zod";
|
|
15
|
-
import {
|
|
16
|
-
keyZ,
|
|
17
|
-
type Params,
|
|
18
|
-
type Workspace,
|
|
19
|
-
workspaceRemoteZ,
|
|
20
|
-
} from "@/workspace/payload";
|
|
21
|
-
|
|
22
|
-
const reqZ = z.object({
|
|
23
|
-
keys: keyZ.array().optional(),
|
|
24
|
-
search: z.string().optional(),
|
|
25
|
-
author: z.string().uuid().optional(),
|
|
26
|
-
offset: z.number().optional(),
|
|
27
|
-
limit: z.number().optional(),
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
type Request = z.infer<typeof reqZ>;
|
|
31
|
-
|
|
32
|
-
const resZ = z.object({ workspaces: nullableArrayZ(workspaceRemoteZ) });
|
|
33
|
-
|
|
34
|
-
export class Retriever {
|
|
35
|
-
private static readonly ENDPOINT = "/workspace/retrieve";
|
|
36
|
-
|
|
37
|
-
private readonly client: UnaryClient;
|
|
38
|
-
|
|
39
|
-
constructor(client: UnaryClient) {
|
|
40
|
-
this.client = client;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async retrieve(workspaces: Params): Promise<Workspace[]> {
|
|
44
|
-
const normalized = toArray(workspaces);
|
|
45
|
-
return await this.execute({ keys: normalized });
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async retrieveByAuthor(author: string): Promise<Workspace[]> {
|
|
49
|
-
return await this.execute({ author });
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async search(term: string): Promise<Workspace[]> {
|
|
53
|
-
return await this.execute({ search: term });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async page(offset: number, limit: number): Promise<Workspace[]> {
|
|
57
|
-
return await this.execute({ offset, limit });
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
private async execute(request: Request): Promise<Workspace[]> {
|
|
61
|
-
const res = await sendRequired(
|
|
62
|
-
this.client,
|
|
63
|
-
Retriever.ENDPOINT,
|
|
64
|
-
request,
|
|
65
|
-
reqZ,
|
|
66
|
-
resZ,
|
|
67
|
-
);
|
|
68
|
-
return res.workspaces;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
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 * from "@/workspace/schematic/client";
|
|
11
|
-
export * from "@/workspace/schematic/payload";
|
|
@@ -1,38 +0,0 @@
|
|
|
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 { type UnknownRecord, unknownRecordZ } from "@synnaxlabs/x/record";
|
|
11
|
-
import { z } from "zod";
|
|
12
|
-
|
|
13
|
-
import { ontology } from "@/ontology";
|
|
14
|
-
|
|
15
|
-
export const keyZ = z.string().uuid();
|
|
16
|
-
export type Key = z.infer<typeof keyZ>;
|
|
17
|
-
export type Params = Key | Key[];
|
|
18
|
-
|
|
19
|
-
export const schematicZ = z.object({
|
|
20
|
-
key: z.string(),
|
|
21
|
-
name: z.string(),
|
|
22
|
-
data: unknownRecordZ.or(z.string().transform((s) => JSON.parse(s) as UnknownRecord)),
|
|
23
|
-
snapshot: z.boolean(),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
export const schematicRemoteZ = z.object({
|
|
27
|
-
key: z.string(),
|
|
28
|
-
name: z.string(),
|
|
29
|
-
snapshot: z.boolean(),
|
|
30
|
-
data: z.string().transform((s) => JSON.parse(s) as UnknownRecord),
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
export type Schematic = z.infer<typeof schematicZ>;
|
|
34
|
-
|
|
35
|
-
export const ONTOLOGY_TYPE: ontology.ResourceType = "schematic";
|
|
36
|
-
|
|
37
|
-
export const ontologyID = (key: Key): ontology.ID =>
|
|
38
|
-
new ontology.ID({ type: ONTOLOGY_TYPE, key });
|
|
@@ -1,42 +0,0 @@
|
|
|
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 { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
|
-
import { toArray } from "@synnaxlabs/x/toArray";
|
|
12
|
-
import { z } from "zod";
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
type Params,
|
|
16
|
-
type Schematic,
|
|
17
|
-
schematicRemoteZ,
|
|
18
|
-
} from "@/workspace/schematic/payload";
|
|
19
|
-
|
|
20
|
-
const reqZ = z.object({ keys: z.string().array() });
|
|
21
|
-
const resZ = z.object({ schematics: schematicRemoteZ.array() });
|
|
22
|
-
|
|
23
|
-
export class Retriever {
|
|
24
|
-
private readonly ENDPOINT = "/workspace/schematic/retrieve";
|
|
25
|
-
private readonly client: UnaryClient;
|
|
26
|
-
|
|
27
|
-
constructor(client: UnaryClient) {
|
|
28
|
-
this.client = client;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async retrieve(schematics: Params): Promise<Schematic[]> {
|
|
32
|
-
return (
|
|
33
|
-
await sendRequired(
|
|
34
|
-
this.client,
|
|
35
|
-
this.ENDPOINT,
|
|
36
|
-
{ keys: toArray(schematics) },
|
|
37
|
-
reqZ,
|
|
38
|
-
resZ,
|
|
39
|
-
)
|
|
40
|
-
).schematics;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
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 { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
|
-
import { type UnknownRecord } from "@synnaxlabs/x/record";
|
|
12
|
-
import { toArray } from "@synnaxlabs/x/toArray";
|
|
13
|
-
import { z } from "zod";
|
|
14
|
-
|
|
15
|
-
import { keyZ as workspaceKeyZ } from "@/workspace/payload";
|
|
16
|
-
import {
|
|
17
|
-
type Key,
|
|
18
|
-
keyZ,
|
|
19
|
-
type Params,
|
|
20
|
-
type Schematic,
|
|
21
|
-
schematicRemoteZ,
|
|
22
|
-
schematicZ,
|
|
23
|
-
} from "@/workspace/schematic/payload";
|
|
24
|
-
|
|
25
|
-
export const newSchematicZ = schematicZ
|
|
26
|
-
.partial({ key: true, snapshot: true })
|
|
27
|
-
.transform((p) => ({
|
|
28
|
-
...p,
|
|
29
|
-
data: JSON.stringify(p.data),
|
|
30
|
-
}));
|
|
31
|
-
|
|
32
|
-
export type NewSchematic = z.input<typeof newSchematicZ>;
|
|
33
|
-
|
|
34
|
-
const createReqZ = z.object({
|
|
35
|
-
workspace: workspaceKeyZ,
|
|
36
|
-
schematics: newSchematicZ.array(),
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const createResZ = z.object({
|
|
40
|
-
schematics: schematicRemoteZ.array(),
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const deleteReqZ = z.object({
|
|
44
|
-
keys: keyZ.array(),
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const deleteResZ = z.object({});
|
|
48
|
-
|
|
49
|
-
const renameReqZ = z.object({
|
|
50
|
-
key: keyZ,
|
|
51
|
-
name: z.string(),
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const renameResZ = z.object({});
|
|
55
|
-
|
|
56
|
-
const setDataReqZ = z.object({
|
|
57
|
-
key: keyZ,
|
|
58
|
-
data: z.string(),
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const setDataResZ = z.object({});
|
|
62
|
-
|
|
63
|
-
const copyReqZ = z.object({
|
|
64
|
-
key: keyZ,
|
|
65
|
-
name: z.string(),
|
|
66
|
-
snapshot: z.boolean(),
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const copyResZ = z.object({
|
|
70
|
-
schematic: schematicRemoteZ,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const CREATE_ENDPOINT = "/workspace/schematic/create";
|
|
74
|
-
const DELETE_ENDPOINT = "/workspace/schematic/delete";
|
|
75
|
-
const RENAME_ENDPOINT = "/workspace/schematic/rename";
|
|
76
|
-
const SET_DATA_ENDPOINT = "/workspace/schematic/set-data";
|
|
77
|
-
const COPY_ENDPOINT = "/workspace/schematic/copy";
|
|
78
|
-
|
|
79
|
-
export class Writer {
|
|
80
|
-
private readonly client: UnaryClient;
|
|
81
|
-
|
|
82
|
-
constructor(client: UnaryClient) {
|
|
83
|
-
this.client = client;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async create(workspace: string, schematic: NewSchematic): Promise<Schematic> {
|
|
87
|
-
const schematic_ = { ...schematic, data: JSON.stringify(schematic.data) };
|
|
88
|
-
const res = await sendRequired<typeof createReqZ, typeof createResZ>(
|
|
89
|
-
this.client,
|
|
90
|
-
CREATE_ENDPOINT,
|
|
91
|
-
{ workspace, schematics: [schematic_] },
|
|
92
|
-
createReqZ,
|
|
93
|
-
createResZ,
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
return res.schematics[0];
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async copy(key: Key, name: string, snapshot: boolean): Promise<Schematic> {
|
|
100
|
-
const res = await sendRequired<typeof copyReqZ, typeof copyResZ>(
|
|
101
|
-
this.client,
|
|
102
|
-
COPY_ENDPOINT,
|
|
103
|
-
{ key, name, snapshot },
|
|
104
|
-
copyReqZ,
|
|
105
|
-
copyResZ,
|
|
106
|
-
);
|
|
107
|
-
return res.schematic;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async delete(schematics: Params): Promise<void> {
|
|
111
|
-
const normalized = toArray(schematics);
|
|
112
|
-
await sendRequired<typeof deleteReqZ, typeof deleteResZ>(
|
|
113
|
-
this.client,
|
|
114
|
-
DELETE_ENDPOINT,
|
|
115
|
-
{ keys: normalized },
|
|
116
|
-
deleteReqZ,
|
|
117
|
-
deleteResZ,
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
async rename(schematic: Key, name: string): Promise<void> {
|
|
122
|
-
await sendRequired<typeof renameReqZ, typeof renameResZ>(
|
|
123
|
-
this.client,
|
|
124
|
-
RENAME_ENDPOINT,
|
|
125
|
-
{ key: schematic, name },
|
|
126
|
-
renameReqZ,
|
|
127
|
-
renameResZ,
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
async setData(schematic: Key, data: UnknownRecord): Promise<void> {
|
|
132
|
-
await sendRequired<typeof setDataReqZ, typeof setDataResZ>(
|
|
133
|
-
this.client,
|
|
134
|
-
SET_DATA_ENDPOINT,
|
|
135
|
-
{ key: schematic, data: JSON.stringify(data) },
|
|
136
|
-
setDataReqZ,
|
|
137
|
-
setDataResZ,
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
}
|
package/src/workspace/writer.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
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 { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
|
-
import { type UnknownRecord } from "@synnaxlabs/x/record";
|
|
12
|
-
import { toArray } from "@synnaxlabs/x/toArray";
|
|
13
|
-
import { z } from "zod";
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
keyZ,
|
|
17
|
-
type Workspace,
|
|
18
|
-
workspaceRemoteZ,
|
|
19
|
-
workspaceZ,
|
|
20
|
-
} from "@/workspace/payload";
|
|
21
|
-
|
|
22
|
-
const newWorkspaceZ = workspaceZ.partial({ key: true }).transform((w) => ({
|
|
23
|
-
...w,
|
|
24
|
-
layout: JSON.stringify(w.layout),
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
export type NewWorkspace = z.input<typeof newWorkspaceZ>;
|
|
28
|
-
|
|
29
|
-
const createReqZ = z.object({
|
|
30
|
-
workspaces: newWorkspaceZ.array(),
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const createResZ = z.object({
|
|
34
|
-
workspaces: workspaceRemoteZ.array(),
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const deleteReqZ = z.object({
|
|
38
|
-
keys: keyZ.array(),
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const deleteResZ = z.object({});
|
|
42
|
-
|
|
43
|
-
const renameReqZ = z.object({
|
|
44
|
-
key: keyZ,
|
|
45
|
-
name: z.string(),
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const renameResZ = z.object({});
|
|
49
|
-
|
|
50
|
-
const setLayoutReqZ = z.object({
|
|
51
|
-
key: keyZ,
|
|
52
|
-
layout: z.string(),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const setLayoutResZ = z.object({});
|
|
56
|
-
|
|
57
|
-
export type CreateResponse = z.infer<typeof createResZ>;
|
|
58
|
-
|
|
59
|
-
const CREATE_ENDPOINT = "/workspace/create";
|
|
60
|
-
const DELETE_ENDPOINT = "/workspace/delete";
|
|
61
|
-
const RENAME_ENDPOINT = "/workspace/rename";
|
|
62
|
-
const SET_LAYOUT_ENDPOINT = "/workspace/set-layout";
|
|
63
|
-
|
|
64
|
-
export class Writer {
|
|
65
|
-
private readonly client: UnaryClient;
|
|
66
|
-
|
|
67
|
-
constructor(client: UnaryClient) {
|
|
68
|
-
this.client = client;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async create(workspaces: NewWorkspace | NewWorkspace[]): Promise<Workspace[]> {
|
|
72
|
-
const res = await sendRequired<typeof createReqZ, typeof createResZ>(
|
|
73
|
-
this.client,
|
|
74
|
-
CREATE_ENDPOINT,
|
|
75
|
-
{ workspaces: toArray(workspaces) },
|
|
76
|
-
createReqZ,
|
|
77
|
-
createResZ,
|
|
78
|
-
);
|
|
79
|
-
return res.workspaces;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async delete(keys: string | string[]): Promise<void> {
|
|
83
|
-
await sendRequired<typeof deleteReqZ, typeof deleteResZ>(
|
|
84
|
-
this.client,
|
|
85
|
-
DELETE_ENDPOINT,
|
|
86
|
-
{ keys: toArray(keys) },
|
|
87
|
-
deleteReqZ,
|
|
88
|
-
deleteResZ,
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async rename(key: string, name: string): Promise<void> {
|
|
93
|
-
await sendRequired<typeof renameReqZ, typeof renameResZ>(
|
|
94
|
-
this.client,
|
|
95
|
-
RENAME_ENDPOINT,
|
|
96
|
-
{ key, name },
|
|
97
|
-
renameReqZ,
|
|
98
|
-
renameResZ,
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async setLayout(key: string, layout: UnknownRecord): Promise<void> {
|
|
103
|
-
await sendRequired<typeof setLayoutReqZ, typeof setLayoutResZ>(
|
|
104
|
-
this.client,
|
|
105
|
-
SET_LAYOUT_ENDPOINT,
|
|
106
|
-
{ key, layout: JSON.stringify(layout) },
|
|
107
|
-
setLayoutReqZ,
|
|
108
|
-
setLayoutResZ,
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
}
|