-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
// SPDX-FileCopyrightText: 2024 Shota FUJI <pockawoooh@gmail.com>
// SPDX-License-Identifier: AGPL-3.0-only
import {
create,
fromBinary,
toBinary,
type DescMessage,
type MessageInitShape,
type MessageShape,
} from "@bufbuild/protobuf";
// TODO: Move these out to services/ or similar.
import { ListRequestSchema } from "@yamori/proto/yamori/workspace/v1/list_request_pb.js";
import { ListResponseSchema } from "@yamori/proto/yamori/workspace/v1/list_response_pb.js";
export function ListRequest() {
return ListRequestSchema;
}
export function ListResponse() {
return ListResponseSchema;
}
export function decode<Message extends DescMessage>(binary: Uint8Array, schema: Message) {
return fromBinary(schema, binary);
}
export function encode<Message extends DescMessage>(
payload: MessageInitShape<Message>,
schema: Message,
) {
return toBinary(schema, create(schema, payload));
}
export function toJSON<Message extends DescMessage>(
message: MessageShape<Message>,
): string {
return JSON.stringify(message, null, 2);
}