@synnaxlabs/client 0.32.0 → 0.33.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/channel/client.d.ts +1 -1
- package/dist/client.cjs +26 -26
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2896 -2499
- package/dist/framer/deleter.d.ts.map +1 -1
- package/dist/framer/frame.d.ts.map +1 -1
- package/dist/framer/writer.d.ts.map +1 -1
- package/dist/hardware/task/ni/types.d.ts +13 -13
- package/dist/hardware/task/ni/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/label/writer.d.ts +5 -5
- package/dist/ontology/client.d.ts +9 -9
- package/dist/ontology/payload.d.ts +43 -43
- package/dist/ontology/payload.d.ts.map +1 -1
- 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/workspace/client.d.ts +2 -0
- package/dist/workspace/client.d.ts.map +1 -1
- package/dist/workspace/log/client.d.ts +16 -0
- package/dist/workspace/log/client.d.ts.map +1 -0
- package/dist/workspace/log/external.d.ts +3 -0
- package/dist/workspace/log/external.d.ts.map +1 -0
- package/dist/workspace/log/index.d.ts +2 -0
- package/dist/workspace/log/index.d.ts.map +1 -0
- package/dist/workspace/log/log.spec.d.ts +2 -0
- package/dist/workspace/log/log.spec.d.ts.map +1 -0
- package/dist/workspace/log/payload.d.ts +36 -0
- package/dist/workspace/log/payload.d.ts.map +1 -0
- package/dist/workspace/log/retriever.d.ts +9 -0
- package/dist/workspace/log/retriever.d.ts.map +1 -0
- package/dist/workspace/log/writer.d.ts +35 -0
- package/dist/workspace/log/writer.d.ts.map +1 -0
- package/package.json +12 -13
- package/src/access/policy/policy.spec.ts +6 -6
- package/src/channel/client.ts +1 -1
- package/src/control/state.ts +1 -1
- package/src/errors.spec.ts +19 -0
- package/src/hardware/task/ni/types.ts +13 -13
- package/src/index.ts +2 -2
- package/src/ontology/client.ts +1 -1
- package/src/ontology/payload.ts +1 -0
- package/src/workspace/client.ts +3 -0
- package/src/workspace/log/client.ts +51 -0
- package/src/workspace/log/external.ts +11 -0
- package/src/workspace/log/index.ts +10 -0
- package/src/workspace/log/log.spec.ts +78 -0
- package/src/workspace/log/payload.ts +36 -0
- package/src/workspace/log/retriever.ts +38 -0
- package/src/workspace/log/writer.ts +116 -0
- package/src/workspace/schematic/writer.ts +1 -1
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
type Key,
|
|
17
|
+
keyZ,
|
|
18
|
+
type Log,
|
|
19
|
+
logRemoteZ,
|
|
20
|
+
logZ,
|
|
21
|
+
type Params,
|
|
22
|
+
} from "@/workspace/log/payload";
|
|
23
|
+
import { keyZ as workspaceKeyZ } from "@/workspace/payload";
|
|
24
|
+
|
|
25
|
+
export const newLogZ = logZ.partial({ key: true }).transform((p) => ({
|
|
26
|
+
...p,
|
|
27
|
+
data: JSON.stringify(p.data),
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
export type NewLog = z.input<typeof newLogZ>;
|
|
31
|
+
|
|
32
|
+
const createReqZ = z.object({
|
|
33
|
+
workspace: workspaceKeyZ,
|
|
34
|
+
logs: newLogZ.array(),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const createResZ = z.object({
|
|
38
|
+
logs: logRemoteZ.array(),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const deleteReqZ = z.object({
|
|
42
|
+
keys: keyZ.array(),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const deleteResZ = z.object({});
|
|
46
|
+
|
|
47
|
+
const renameReqZ = z.object({
|
|
48
|
+
key: keyZ,
|
|
49
|
+
name: z.string(),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const renameResZ = z.object({});
|
|
53
|
+
|
|
54
|
+
const setDataReqZ = z.object({
|
|
55
|
+
key: keyZ,
|
|
56
|
+
data: z.string(),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const setDataResZ = z.object({});
|
|
60
|
+
|
|
61
|
+
const CREATE_ENDPOINT = "/workspace/log/create";
|
|
62
|
+
const DELETE_ENDPOINT = "/workspace/log/delete";
|
|
63
|
+
const RENAME_ENDPOINT = "/workspace/log/rename";
|
|
64
|
+
const SET_DATA_ENDPOINT = "/workspace/log/set-data";
|
|
65
|
+
|
|
66
|
+
export class Writer {
|
|
67
|
+
private readonly client: UnaryClient;
|
|
68
|
+
|
|
69
|
+
constructor(client: UnaryClient) {
|
|
70
|
+
this.client = client;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async create(workspace: string, log: NewLog): Promise<Log> {
|
|
74
|
+
const log_ = { ...log, data: JSON.stringify(log.data) };
|
|
75
|
+
const res = await sendRequired<typeof createReqZ, typeof createResZ>(
|
|
76
|
+
this.client,
|
|
77
|
+
CREATE_ENDPOINT,
|
|
78
|
+
{ workspace, logs: [log_] },
|
|
79
|
+
createReqZ,
|
|
80
|
+
createResZ,
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
return res.logs[0];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async delete(logs: Params): Promise<void> {
|
|
87
|
+
const normalized = toArray(logs);
|
|
88
|
+
await sendRequired<typeof deleteReqZ, typeof deleteResZ>(
|
|
89
|
+
this.client,
|
|
90
|
+
DELETE_ENDPOINT,
|
|
91
|
+
{ keys: normalized },
|
|
92
|
+
deleteReqZ,
|
|
93
|
+
deleteResZ,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async rename(log: Key, name: string): Promise<void> {
|
|
98
|
+
await sendRequired<typeof renameReqZ, typeof renameResZ>(
|
|
99
|
+
this.client,
|
|
100
|
+
RENAME_ENDPOINT,
|
|
101
|
+
{ key: log, name },
|
|
102
|
+
renameReqZ,
|
|
103
|
+
renameResZ,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async setData(log: Key, data: UnknownRecord): Promise<void> {
|
|
108
|
+
await sendRequired<typeof setDataReqZ, typeof setDataResZ>(
|
|
109
|
+
this.client,
|
|
110
|
+
SET_DATA_ENDPOINT,
|
|
111
|
+
{ key: log, data: JSON.stringify(data) },
|
|
112
|
+
setDataReqZ,
|
|
113
|
+
setDataResZ,
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|