@synnaxlabs/client 0.38.0 → 0.39.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.
Files changed (304) hide show
  1. package/.turbo/turbo-build.log +7 -7
  2. package/dist/access/payload.d.ts +6 -6
  3. package/dist/access/payload.d.ts.map +1 -1
  4. package/dist/access/policy/client.d.ts +5 -3
  5. package/dist/access/policy/client.d.ts.map +1 -1
  6. package/dist/access/policy/external.d.ts +1 -0
  7. package/dist/access/policy/external.d.ts.map +1 -1
  8. package/dist/access/policy/ontology.d.ts +5 -0
  9. package/dist/access/policy/ontology.d.ts.map +1 -0
  10. package/dist/access/policy/payload.d.ts +86 -89
  11. package/dist/access/policy/payload.d.ts.map +1 -1
  12. package/dist/access/policy/retriever.d.ts +7 -6
  13. package/dist/access/policy/retriever.d.ts.map +1 -1
  14. package/dist/access/policy/writer.d.ts +2 -2
  15. package/dist/access/policy/writer.d.ts.map +1 -1
  16. package/dist/auth/auth.d.ts +2 -1
  17. package/dist/auth/auth.d.ts.map +1 -1
  18. package/dist/channel/client.d.ts +8 -7
  19. package/dist/channel/client.d.ts.map +1 -1
  20. package/dist/channel/payload.d.ts +13 -11
  21. package/dist/channel/payload.d.ts.map +1 -1
  22. package/dist/channel/retriever.d.ts +9 -6
  23. package/dist/channel/retriever.d.ts.map +1 -1
  24. package/dist/channel/writer.d.ts +6 -4
  25. package/dist/channel/writer.d.ts.map +1 -1
  26. package/dist/client.cjs +30 -30
  27. package/dist/client.d.ts +4 -2
  28. package/dist/client.d.ts.map +1 -1
  29. package/dist/client.js +3488 -3500
  30. package/dist/connection/checker.d.ts +5 -4
  31. package/dist/connection/checker.d.ts.map +1 -1
  32. package/dist/control/state.d.ts +10 -8
  33. package/dist/control/state.d.ts.map +1 -1
  34. package/dist/errors.d.ts +5 -0
  35. package/dist/errors.d.ts.map +1 -1
  36. package/dist/framer/adapter.d.ts +14 -15
  37. package/dist/framer/adapter.d.ts.map +1 -1
  38. package/dist/framer/client.d.ts +13 -15
  39. package/dist/framer/client.d.ts.map +1 -1
  40. package/dist/framer/deleter.d.ts +3 -2
  41. package/dist/framer/deleter.d.ts.map +1 -1
  42. package/dist/framer/frame.d.ts +31 -27
  43. package/dist/framer/frame.d.ts.map +1 -1
  44. package/dist/framer/iterator.d.ts +4 -5
  45. package/dist/framer/iterator.d.ts.map +1 -1
  46. package/dist/framer/streamer.d.ts +5 -6
  47. package/dist/framer/streamer.d.ts.map +1 -1
  48. package/dist/framer/writer.d.ts +42 -39
  49. package/dist/framer/writer.d.ts.map +1 -1
  50. package/dist/hardware/device/client.d.ts +17 -12
  51. package/dist/hardware/device/client.d.ts.map +1 -1
  52. package/dist/hardware/device/payload.d.ts +19 -16
  53. package/dist/hardware/device/payload.d.ts.map +1 -1
  54. package/dist/hardware/rack/client.d.ts +15 -15
  55. package/dist/hardware/rack/client.d.ts.map +1 -1
  56. package/dist/hardware/rack/payload.d.ts +9 -8
  57. package/dist/hardware/rack/payload.d.ts.map +1 -1
  58. package/dist/hardware/task/client.d.ts +38 -29
  59. package/dist/hardware/task/client.d.ts.map +1 -1
  60. package/dist/hardware/task/payload.d.ts +58 -53
  61. package/dist/hardware/task/payload.d.ts.map +1 -1
  62. package/dist/label/client.d.ts +4 -3
  63. package/dist/label/client.d.ts.map +1 -1
  64. package/dist/label/payload.d.ts +4 -4
  65. package/dist/label/payload.d.ts.map +1 -1
  66. package/dist/label/retriever.d.ts.map +1 -1
  67. package/dist/label/writer.d.ts +13 -10
  68. package/dist/label/writer.d.ts.map +1 -1
  69. package/dist/ontology/client.d.ts +12 -10
  70. package/dist/ontology/client.d.ts.map +1 -1
  71. package/dist/ontology/group/client.d.ts +5 -4
  72. package/dist/ontology/group/client.d.ts.map +1 -1
  73. package/dist/ontology/group/group.d.ts +7 -5
  74. package/dist/ontology/group/group.d.ts.map +1 -1
  75. package/dist/ontology/group/payload.d.ts +6 -5
  76. package/dist/ontology/group/payload.d.ts.map +1 -1
  77. package/dist/ontology/group/writer.d.ts +8 -8
  78. package/dist/ontology/group/writer.d.ts.map +1 -1
  79. package/dist/ontology/payload.d.ts +72 -62
  80. package/dist/ontology/payload.d.ts.map +1 -1
  81. package/dist/ontology/writer.d.ts.map +1 -1
  82. package/dist/ranger/alias.d.ts +9 -10
  83. package/dist/ranger/alias.d.ts.map +1 -1
  84. package/dist/ranger/client.d.ts +18 -18
  85. package/dist/ranger/client.d.ts.map +1 -1
  86. package/dist/ranger/external.d.ts +1 -1
  87. package/dist/ranger/external.d.ts.map +1 -1
  88. package/dist/ranger/kv.d.ts +18 -14
  89. package/dist/ranger/kv.d.ts.map +1 -1
  90. package/dist/ranger/payload.d.ts +13 -13
  91. package/dist/ranger/payload.d.ts.map +1 -1
  92. package/dist/ranger/writer.d.ts +14 -14
  93. package/dist/ranger/writer.d.ts.map +1 -1
  94. package/dist/setupspecs.d.ts.map +1 -1
  95. package/dist/signals/observable.d.ts +3 -1
  96. package/dist/signals/observable.d.ts.map +1 -1
  97. package/dist/user/client.d.ts +5 -3
  98. package/dist/user/client.d.ts.map +1 -1
  99. package/dist/user/payload.d.ts +7 -6
  100. package/dist/user/payload.d.ts.map +1 -1
  101. package/dist/user/retriever.d.ts +2 -1
  102. package/dist/user/retriever.d.ts.map +1 -1
  103. package/dist/user/writer.d.ts +2 -2
  104. package/dist/user/writer.d.ts.map +1 -1
  105. package/dist/util/decodeJSONString.d.ts +3 -0
  106. package/dist/util/decodeJSONString.d.ts.map +1 -0
  107. package/dist/util/parseWithoutKeyConversion.d.ts +3 -0
  108. package/dist/util/parseWithoutKeyConversion.d.ts.map +1 -0
  109. package/dist/util/retrieve.d.ts +1 -1
  110. package/dist/util/retrieve.d.ts.map +1 -1
  111. package/dist/util/telem.d.ts.map +1 -1
  112. package/dist/util/zod.d.ts.map +1 -1
  113. package/dist/workspace/client.d.ts +6 -60
  114. package/dist/workspace/client.d.ts.map +1 -1
  115. package/dist/workspace/external.d.ts +3 -0
  116. package/dist/workspace/external.d.ts.map +1 -0
  117. package/dist/workspace/index.d.ts +1 -1
  118. package/dist/workspace/index.d.ts.map +1 -1
  119. package/dist/workspace/lineplot/client.d.ts +5 -44
  120. package/dist/workspace/lineplot/client.d.ts.map +1 -1
  121. package/dist/workspace/lineplot/external.d.ts +3 -0
  122. package/dist/workspace/lineplot/external.d.ts.map +1 -0
  123. package/dist/workspace/lineplot/index.d.ts +1 -1
  124. package/dist/workspace/lineplot/index.d.ts.map +1 -1
  125. package/dist/workspace/lineplot/payload.d.ts +45 -0
  126. package/dist/workspace/lineplot/payload.d.ts.map +1 -0
  127. package/dist/workspace/log/client.d.ts +5 -44
  128. package/dist/workspace/log/client.d.ts.map +1 -1
  129. package/dist/workspace/log/external.d.ts +3 -0
  130. package/dist/workspace/log/external.d.ts.map +1 -0
  131. package/dist/workspace/log/index.d.ts +1 -1
  132. package/dist/workspace/log/index.d.ts.map +1 -1
  133. package/dist/workspace/log/payload.d.ts +45 -0
  134. package/dist/workspace/log/payload.d.ts.map +1 -0
  135. package/dist/workspace/payload.d.ts +60 -0
  136. package/dist/workspace/payload.d.ts.map +1 -0
  137. package/dist/workspace/schematic/client.d.ts +5 -68
  138. package/dist/workspace/schematic/client.d.ts.map +1 -1
  139. package/dist/workspace/schematic/external.d.ts +3 -0
  140. package/dist/workspace/schematic/external.d.ts.map +1 -0
  141. package/dist/workspace/schematic/index.d.ts +1 -1
  142. package/dist/workspace/schematic/index.d.ts.map +1 -1
  143. package/dist/workspace/schematic/payload.d.ts +71 -0
  144. package/dist/workspace/schematic/payload.d.ts.map +1 -0
  145. package/dist/workspace/table/client.d.ts +5 -57
  146. package/dist/workspace/table/client.d.ts.map +1 -1
  147. package/dist/workspace/table/external.d.ts +3 -0
  148. package/dist/workspace/table/external.d.ts.map +1 -0
  149. package/dist/workspace/table/index.d.ts +1 -1
  150. package/dist/workspace/table/index.d.ts.map +1 -1
  151. package/dist/workspace/table/payload.d.ts +60 -0
  152. package/dist/workspace/table/payload.d.ts.map +1 -0
  153. package/eslint.config.js +1 -1
  154. package/examples/node/basicReadWrite.js +27 -27
  155. package/examples/node/liveStream.js +16 -16
  156. package/examples/node/seriesAndFrames.js +39 -39
  157. package/examples/node/streamWrite.js +48 -46
  158. package/package.json +14 -12
  159. package/src/access/client.ts +1 -1
  160. package/src/access/external.ts +1 -1
  161. package/src/access/index.ts +1 -1
  162. package/src/access/payload.ts +13 -13
  163. package/src/access/policy/client.ts +14 -13
  164. package/src/access/policy/external.ts +2 -1
  165. package/src/access/policy/index.ts +1 -1
  166. package/src/access/policy/ontology.ts +17 -0
  167. package/src/access/policy/payload.ts +8 -20
  168. package/src/access/policy/policy.spec.ts +17 -17
  169. package/src/access/policy/retriever.ts +3 -2
  170. package/src/access/policy/writer.ts +5 -5
  171. package/src/auth/auth.spec.ts +28 -24
  172. package/src/auth/auth.ts +8 -12
  173. package/src/auth/index.ts +1 -1
  174. package/src/channel/batchRetriever.spec.ts +26 -23
  175. package/src/channel/channel.spec.ts +1 -1
  176. package/src/channel/client.ts +24 -24
  177. package/src/channel/external.ts +1 -1
  178. package/src/channel/index.ts +1 -1
  179. package/src/channel/payload.ts +17 -21
  180. package/src/channel/retriever.ts +21 -22
  181. package/src/channel/writer.ts +12 -14
  182. package/src/client.ts +7 -17
  183. package/src/connection/checker.ts +10 -12
  184. package/src/connection/connection.spec.ts +18 -6
  185. package/src/connection/index.ts +1 -1
  186. package/src/control/client.ts +1 -1
  187. package/src/control/external.ts +1 -1
  188. package/src/control/index.ts +1 -1
  189. package/src/control/state.spec.ts +1 -1
  190. package/src/control/state.ts +9 -10
  191. package/src/errors.spec.ts +2 -2
  192. package/src/errors.ts +9 -1
  193. package/src/framer/adapter.spec.ts +29 -24
  194. package/src/framer/adapter.ts +38 -42
  195. package/src/framer/client.spec.ts +6 -12
  196. package/src/framer/client.ts +35 -39
  197. package/src/framer/deleter.spec.ts +1 -1
  198. package/src/framer/deleter.ts +6 -7
  199. package/src/framer/external.ts +1 -1
  200. package/src/framer/frame.spec.ts +1 -1
  201. package/src/framer/frame.ts +63 -51
  202. package/src/framer/index.ts +1 -1
  203. package/src/framer/iterator.spec.ts +1 -1
  204. package/src/framer/iterator.ts +12 -17
  205. package/src/framer/streamProxy.ts +2 -2
  206. package/src/framer/streamer.spec.ts +3 -11
  207. package/src/framer/streamer.ts +16 -20
  208. package/src/framer/writer.spec.ts +49 -8
  209. package/src/framer/writer.ts +40 -32
  210. package/src/hardware/client.ts +1 -1
  211. package/src/hardware/device/client.ts +65 -40
  212. package/src/hardware/device/device.spec.ts +50 -34
  213. package/src/hardware/device/external.ts +1 -1
  214. package/src/hardware/device/index.ts +1 -1
  215. package/src/hardware/device/payload.ts +30 -30
  216. package/src/hardware/external.ts +1 -1
  217. package/src/hardware/index.ts +1 -1
  218. package/src/hardware/rack/client.ts +53 -66
  219. package/src/hardware/rack/external.ts +1 -1
  220. package/src/hardware/rack/index.ts +1 -1
  221. package/src/hardware/rack/payload.ts +10 -19
  222. package/src/hardware/rack/rack.spec.ts +13 -1
  223. package/src/hardware/task/client.ts +161 -132
  224. package/src/hardware/task/external.ts +1 -1
  225. package/src/hardware/task/index.ts +1 -1
  226. package/src/hardware/task/payload.ts +50 -69
  227. package/src/hardware/task/task.spec.ts +99 -82
  228. package/src/index.ts +1 -1
  229. package/src/label/client.ts +13 -16
  230. package/src/label/external.ts +1 -1
  231. package/src/label/index.ts +1 -1
  232. package/src/label/label.spec.ts +1 -1
  233. package/src/label/payload.ts +4 -10
  234. package/src/label/retriever.ts +4 -8
  235. package/src/label/writer.ts +9 -16
  236. package/src/ontology/client.ts +31 -29
  237. package/src/ontology/external.ts +1 -1
  238. package/src/ontology/group/client.ts +6 -6
  239. package/src/ontology/group/external.ts +1 -1
  240. package/src/ontology/group/group.spec.ts +5 -5
  241. package/src/ontology/group/group.ts +11 -8
  242. package/src/ontology/group/index.ts +1 -1
  243. package/src/ontology/group/payload.ts +12 -36
  244. package/src/ontology/group/writer.ts +23 -27
  245. package/src/ontology/index.ts +1 -1
  246. package/src/ontology/ontology.spec.ts +16 -16
  247. package/src/ontology/payload.ts +68 -44
  248. package/src/ontology/writer.ts +17 -24
  249. package/src/ranger/alias.ts +26 -43
  250. package/src/ranger/client.ts +34 -41
  251. package/src/ranger/external.ts +2 -2
  252. package/src/ranger/index.ts +1 -1
  253. package/src/ranger/kv.ts +10 -33
  254. package/src/ranger/payload.ts +15 -37
  255. package/src/ranger/ranger.spec.ts +2 -3
  256. package/src/ranger/writer.ts +9 -27
  257. package/src/setupspecs.ts +1 -1
  258. package/src/signals/external.ts +1 -1
  259. package/src/signals/index.ts +1 -1
  260. package/src/signals/observable.ts +4 -5
  261. package/src/transport.ts +1 -1
  262. package/src/user/client.ts +9 -5
  263. package/src/user/external.ts +1 -1
  264. package/src/user/index.ts +1 -1
  265. package/src/user/payload.ts +6 -10
  266. package/src/user/retriever.ts +2 -2
  267. package/src/user/user.spec.ts +18 -16
  268. package/src/user/writer.ts +4 -11
  269. package/src/util/decodeJSONString.ts +13 -0
  270. package/src/util/parseWithoutKeyConversion.ts +19 -0
  271. package/src/util/retrieve.spec.ts +4 -14
  272. package/src/util/retrieve.ts +3 -13
  273. package/src/util/telem.ts +2 -2
  274. package/src/util/zod.ts +1 -1
  275. package/src/vite-env.d.ts +2 -1
  276. package/src/workspace/client.ts +39 -57
  277. package/src/workspace/external.ts +11 -0
  278. package/src/workspace/index.ts +2 -2
  279. package/src/workspace/lineplot/client.ts +31 -36
  280. package/src/workspace/lineplot/external.ts +11 -0
  281. package/src/workspace/lineplot/index.ts +2 -2
  282. package/src/workspace/lineplot/linePlot.spec.ts +2 -3
  283. package/src/workspace/lineplot/payload.ts +32 -0
  284. package/src/workspace/log/client.ts +34 -39
  285. package/src/workspace/log/external.ts +11 -0
  286. package/src/workspace/log/index.ts +2 -2
  287. package/src/workspace/log/log.spec.ts +6 -19
  288. package/src/workspace/log/payload.ts +32 -0
  289. package/src/workspace/payload.ts +36 -0
  290. package/src/workspace/schematic/client.ts +39 -56
  291. package/src/workspace/schematic/external.ts +11 -0
  292. package/src/workspace/schematic/index.ts +2 -2
  293. package/src/workspace/schematic/payload.ts +37 -0
  294. package/src/workspace/schematic/schematic.spec.ts +16 -7
  295. package/src/workspace/table/client.ts +36 -50
  296. package/src/workspace/table/external.ts +11 -0
  297. package/src/workspace/table/index.ts +2 -2
  298. package/src/workspace/table/payload.ts +36 -0
  299. package/src/workspace/table/table.spec.ts +1 -1
  300. package/src/workspace/workspace.spec.ts +2 -3
  301. package/vite.config.ts +1 -1
  302. package/dist/channel/creator.d.ts +0 -9
  303. package/dist/channel/creator.d.ts.map +0 -1
  304. package/src/channel/creator.ts +0 -37
@@ -1,76 +1,60 @@
1
+ // Copyright 2025 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 { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
2
11
  import { toArray, type UnknownRecord } from "@synnaxlabs/x";
3
- import { unknownRecordZ } from "@synnaxlabs/x/record";
4
12
  import { type AsyncTermSearcher } from "@synnaxlabs/x/search";
5
13
  import { z } from "zod";
6
14
 
7
15
  import { ontology } from "@/ontology";
16
+ import { type Key as UserKey, keyZ as userKeyZ } from "@/user/payload";
8
17
  import { nullableArrayZ } from "@/util/zod";
9
18
  import { linePlot } from "@/workspace/lineplot";
10
19
  import { log } from "@/workspace/log";
20
+ import {
21
+ type Key,
22
+ keyZ,
23
+ type New,
24
+ newZ,
25
+ ONTOLOGY_TYPE,
26
+ type Params,
27
+ remoteZ,
28
+ type Workspace,
29
+ workspaceZ,
30
+ } from "@/workspace/payload";
11
31
  import { schematic } from "@/workspace/schematic";
12
32
  import { table } from "@/workspace/table";
13
33
 
14
- export const keyZ = z.string().uuid();
15
- export type Key = z.infer<typeof keyZ>;
16
- export type Params = Key | Key[];
17
-
18
- // --- VERY IMPORTANT ---
19
- // Synnax's encoders (in the binary package inside x) automatically convert the case
20
- // of keys in objects to snake_case and back to camelCase when encoding and decoding
21
- // respectively. This is done to ensure that the keys are consistent across all
22
- // languages and platforms. Sometimes workspaces have keys that are uuids, which have
23
- // dashes, and those get messed up. So we just use regular JSON for workspaces.
24
- const parse = (s: string): UnknownRecord => JSON.parse(s) as UnknownRecord;
25
-
26
- export const workspaceZ = z.object({
27
- key: z.string(),
28
- name: z.string(),
29
- layout: unknownRecordZ.or(z.string().transform((s) => parse(s) as UnknownRecord)),
30
- });
31
-
32
- export type Workspace = z.infer<typeof workspaceZ>;
33
-
34
- export const ONTOLOGY_TYPE: ontology.ResourceType = "workspace";
35
-
36
- export const ontologyID = (key: Key): ontology.ID =>
37
- new ontology.ID({ type: ONTOLOGY_TYPE, key });
38
-
39
34
  const RETRIEVE_ENDPOINT = "/workspace/retrieve";
40
35
  const CREATE_ENDPOINT = "/workspace/create";
41
36
  const RENAME_ENDPOINT = "/workspace/rename";
42
37
  const SET_LAYOUT_ENDPOINT = "/workspace/set-layout";
43
38
  const DELETE_ENDPOINT = "/workspace/delete";
44
39
 
45
- export const newWorkspaceZ = workspaceZ.partial({ key: true }).transform((p) => ({
46
- ...p,
47
- layout: JSON.stringify(p.layout),
48
- }));
49
-
50
- export const workspaceRemoteZ = workspaceZ.omit({ layout: true }).extend({
51
- layout: z.string().transform((s) => parse(s) as UnknownRecord),
52
- });
53
-
54
- export type NewWorkspace = z.input<typeof newWorkspaceZ>;
55
-
56
40
  const retrieveReqZ = z.object({
57
- keys: z.string().array().optional(),
41
+ keys: keyZ.array().optional(),
58
42
  search: z.string().optional(),
59
- author: z.string().uuid().optional(),
43
+ author: userKeyZ.optional(),
60
44
  offset: z.number().optional(),
61
45
  limit: z.number().optional(),
62
46
  });
63
- const createReqZ = z.object({ workspaces: newWorkspaceZ.array() });
64
- const renameReqZ = z.object({ key: z.string(), name: z.string() });
65
- const setLayoutReqZ = z.object({ key: z.string(), layout: z.string() });
66
- const deleteReqZ = z.object({ keys: z.string().array() });
47
+ const createReqZ = z.object({ workspaces: newZ.array() });
48
+ const renameReqZ = z.object({ key: keyZ, name: z.string() });
49
+ const setLayoutReqZ = z.object({ key: keyZ, layout: z.string() });
50
+ const deleteReqZ = z.object({ keys: keyZ.array() });
67
51
 
68
52
  const retrieveResZ = z.object({ workspaces: nullableArrayZ(workspaceZ) });
69
- const createResZ = z.object({ workspaces: workspaceRemoteZ.array() });
53
+ const createResZ = z.object({ workspaces: remoteZ.array() });
70
54
  const emptyResZ = z.object({});
71
55
 
72
56
  export class Client implements AsyncTermSearcher<string, Key, Workspace> {
73
- readonly type = "workspace";
57
+ readonly type = ONTOLOGY_TYPE;
74
58
  readonly schematic: schematic.Client;
75
59
  readonly linePlot: linePlot.Client;
76
60
  readonly log: log.Client;
@@ -85,17 +69,14 @@ export class Client implements AsyncTermSearcher<string, Key, Workspace> {
85
69
  this.table = new table.Client(client);
86
70
  }
87
71
 
88
- async create(workspace: NewWorkspace): Promise<Workspace>;
89
- async create(workspaces: NewWorkspace[]): Promise<Workspace[]>;
90
- async create(
91
- workspaces: NewWorkspace | NewWorkspace[],
92
- ): Promise<Workspace | Workspace[]> {
72
+ async create(workspace: New): Promise<Workspace>;
73
+ async create(workspaces: New[]): Promise<Workspace[]>;
74
+ async create(workspaces: New | New[]): Promise<Workspace | Workspace[]> {
93
75
  const isMany = Array.isArray(workspaces);
94
- const normalized = toArray(workspaces);
95
76
  const res = await sendRequired(
96
77
  this.client,
97
78
  CREATE_ENDPOINT,
98
- { workspaces: normalized },
79
+ { workspaces: toArray(workspaces) },
99
80
  createReqZ,
100
81
  createResZ,
101
82
  );
@@ -126,18 +107,17 @@ export class Client implements AsyncTermSearcher<string, Key, Workspace> {
126
107
  async retrieve(keys: Key[]): Promise<Workspace[]>;
127
108
  async retrieve(keys: Params): Promise<Workspace | Workspace[]> {
128
109
  const isMany = Array.isArray(keys);
129
- const normalized = toArray(keys);
130
110
  const res = await sendRequired(
131
111
  this.client,
132
112
  RETRIEVE_ENDPOINT,
133
- { keys: normalized },
113
+ { keys: toArray(keys) },
134
114
  retrieveReqZ,
135
115
  retrieveResZ,
136
116
  );
137
117
  return isMany ? res.workspaces : res.workspaces[0];
138
118
  }
139
119
 
140
- async retrieveByAuthor(author: string): Promise<Workspace[]> {
120
+ async retrieveByAuthor(author: UserKey): Promise<Workspace[]> {
141
121
  const res = await sendRequired(
142
122
  this.client,
143
123
  RETRIEVE_ENDPOINT,
@@ -173,13 +153,15 @@ export class Client implements AsyncTermSearcher<string, Key, Workspace> {
173
153
  async delete(key: Key): Promise<void>;
174
154
  async delete(keys: Key[]): Promise<void>;
175
155
  async delete(keys: Params): Promise<void> {
176
- const normalized = toArray(keys);
177
156
  await sendRequired(
178
157
  this.client,
179
158
  DELETE_ENDPOINT,
180
- { keys: normalized },
159
+ { keys: toArray(keys) },
181
160
  deleteReqZ,
182
161
  emptyResZ,
183
162
  );
184
163
  }
185
164
  }
165
+
166
+ export const ontologyID = (key: Key): ontology.ID =>
167
+ new ontology.ID({ type: ONTOLOGY_TYPE, key });
@@ -0,0 +1,11 @@
1
+ // Copyright 2025 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/client";
11
+ export * from "@/workspace/payload";
@@ -1,4 +1,4 @@
1
- // Copyright 2024 Synnax Labs, Inc.
1
+ // Copyright 2025 Synnax Labs, Inc.
2
2
  //
3
3
  // Use of this software is governed by the Business Source License included in the file
4
4
  // licenses/BSL.txt.
@@ -7,4 +7,4 @@
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
- export * as workspace from "@/workspace/client";
10
+ export * as workspace from "@/workspace/external";
@@ -1,27 +1,29 @@
1
+ // Copyright 2025 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 { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
2
11
  import { toArray, type UnknownRecord } from "@synnaxlabs/x";
3
- import { unknownRecordZ } from "@synnaxlabs/x/record";
4
12
  import { z } from "zod";
5
13
 
6
14
  import { ontology } from "@/ontology";
7
15
  import { nullableArrayZ } from "@/util/zod";
8
-
9
- export const keyZ = z.string().uuid();
10
- export type Key = z.infer<typeof keyZ>;
11
- export type Params = Key | Key[];
12
-
13
- export const linePlotZ = z.object({
14
- key: z.string(),
15
- name: z.string(),
16
- data: unknownRecordZ.or(z.string().transform((s) => JSON.parse(s) as UnknownRecord)),
17
- });
18
-
19
- export type LinePlot = z.infer<typeof linePlotZ>;
20
-
21
- export const ONTOLOGY_TYPE: ontology.ResourceType = "lineplot";
22
-
23
- export const ontologyID = (key: Key): ontology.ID =>
24
- new ontology.ID({ type: ONTOLOGY_TYPE, key });
16
+ import {
17
+ type Key,
18
+ keyZ,
19
+ type LinePlot,
20
+ linePlotZ,
21
+ type New,
22
+ newZ,
23
+ ONTOLOGY_TYPE,
24
+ type Params,
25
+ } from "@/workspace/lineplot/payload";
26
+ import { type Key as WorkspaceKey, keyZ as workspaceKeyZ } from "@/workspace/payload";
25
27
 
26
28
  const RETRIEVE_ENDPOINT = "/workspace/lineplot/retrieve";
27
29
  const CREATE_ENDPOINT = "/workspace/lineplot/create";
@@ -29,15 +31,8 @@ const RENAME_ENDPOINT = "/workspace/lineplot/rename";
29
31
  const SET_DATA_ENDPOINT = "/workspace/lineplot/set-data";
30
32
  const DELETE_ENDPOINT = "/workspace/lineplot/delete";
31
33
 
32
- export const newLinePlotZ = linePlotZ.partial({ key: true }).transform((p) => ({
33
- ...p,
34
- data: JSON.stringify(p.data),
35
- }));
36
-
37
- export type NewLinePlot = z.input<typeof newLinePlotZ>;
38
-
39
34
  const retrieveReqZ = z.object({ keys: keyZ.array() });
40
- const createReqZ = z.object({ workspace: z.string(), linePlots: newLinePlotZ.array() });
35
+ const createReqZ = z.object({ workspace: workspaceKeyZ, linePlots: newZ.array() });
41
36
  const renameReqZ = z.object({ key: keyZ, name: z.string() });
42
37
  const setDataReqZ = z.object({ key: keyZ, data: z.string() });
43
38
  const deleteReqZ = z.object({ keys: keyZ.array() });
@@ -52,18 +47,17 @@ export class Client {
52
47
  this.client = client;
53
48
  }
54
49
 
55
- async create(workspace: string, linePlot: NewLinePlot): Promise<LinePlot>;
56
- async create(workspace: string, linePlots: NewLinePlot[]): Promise<LinePlot[]>;
50
+ async create(workspace: WorkspaceKey, linePlot: New): Promise<LinePlot>;
51
+ async create(workspace: WorkspaceKey, linePlots: New[]): Promise<LinePlot[]>;
57
52
  async create(
58
- workspace: string,
59
- linePlots: NewLinePlot | NewLinePlot[],
53
+ workspace: WorkspaceKey,
54
+ linePlots: New | New[],
60
55
  ): Promise<LinePlot | LinePlot[]> {
61
56
  const isMany = Array.isArray(linePlots);
62
- const normalized = toArray(linePlots);
63
57
  const res = await sendRequired(
64
58
  this.client,
65
59
  CREATE_ENDPOINT,
66
- { workspace, linePlots: normalized },
60
+ { workspace, linePlots: toArray(linePlots) },
67
61
  createReqZ,
68
62
  createResZ,
69
63
  );
@@ -94,11 +88,10 @@ export class Client {
94
88
  async retrieve(keys: Key[]): Promise<LinePlot[]>;
95
89
  async retrieve(keys: Params): Promise<LinePlot | LinePlot[]> {
96
90
  const isMany = Array.isArray(keys);
97
- const normalized = toArray(keys);
98
91
  const res = await sendRequired(
99
92
  this.client,
100
93
  RETRIEVE_ENDPOINT,
101
- { keys: normalized },
94
+ { keys: toArray(keys) },
102
95
  retrieveReqZ,
103
96
  retrieveResZ,
104
97
  );
@@ -108,13 +101,15 @@ export class Client {
108
101
  async delete(key: Key): Promise<void>;
109
102
  async delete(keys: Key[]): Promise<void>;
110
103
  async delete(keys: Params): Promise<void> {
111
- const normalized = toArray(keys);
112
104
  await sendRequired(
113
105
  this.client,
114
106
  DELETE_ENDPOINT,
115
- { keys: normalized },
107
+ { keys: toArray(keys) },
116
108
  deleteReqZ,
117
109
  emptyResZ,
118
110
  );
119
111
  }
120
112
  }
113
+
114
+ export const ontologyID = (key: Key): ontology.ID =>
115
+ new ontology.ID({ type: ONTOLOGY_TYPE, key });
@@ -0,0 +1,11 @@
1
+ // Copyright 2025 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/lineplot/client";
11
+ export * from "@/workspace/lineplot/payload";
@@ -1,4 +1,4 @@
1
- // Copyright 2024 Synnax Labs, Inc.
1
+ // Copyright 2025 Synnax Labs, Inc.
2
2
  //
3
3
  // Use of this software is governed by the Business Source License included in the file
4
4
  // licenses/BSL.txt.
@@ -7,4 +7,4 @@
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
- export * as linePlot from "@/workspace/lineplot/client";
10
+ export * as linePlot from "@/workspace/lineplot/external";
@@ -1,4 +1,4 @@
1
- // Copyright 2024 Synnax Labs, Inc.
1
+ // Copyright 2025 Synnax Labs, Inc.
2
2
  //
3
3
  // Use of this software is governed by the Business Source License included in the file
4
4
  // licenses/BSL.txt.
@@ -7,14 +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 { NIL as ZERO_UUID } from "uuid";
10
11
  import { describe, expect, test } from "vitest";
11
12
 
12
13
  import { newClient } from "@/setupspecs";
13
14
 
14
15
  const client = newClient();
15
16
 
16
- const ZERO_UUID = "00000000-0000-0000-0000-000000000000";
17
-
18
17
  describe("LinePlot", () => {
19
18
  describe("create", () => {
20
19
  test("create one", async () => {
@@ -0,0 +1,32 @@
1
+ // Copyright 2025 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 { unknownRecordZ } from "@synnaxlabs/x/record";
11
+ import { z } from "zod";
12
+
13
+ import { parseWithoutKeyConversion } from "@/util/parseWithoutKeyConversion";
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 linePlotZ = z.object({
20
+ key: keyZ,
21
+ name: z.string(),
22
+ data: unknownRecordZ.or(z.string().transform(parseWithoutKeyConversion)),
23
+ });
24
+ export interface LinePlot extends z.infer<typeof linePlotZ> {}
25
+
26
+ export const newZ = linePlotZ
27
+ .partial({ key: true })
28
+ .transform((p) => ({ ...p, data: JSON.stringify(p.data) }));
29
+ export interface New extends z.input<typeof newZ> {}
30
+
31
+ export const ONTOLOGY_TYPE = "lineplot";
32
+ export type OntologyType = typeof ONTOLOGY_TYPE;
@@ -1,26 +1,28 @@
1
+ // Copyright 2025 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 { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
2
11
  import { toArray, type UnknownRecord } from "@synnaxlabs/x";
3
- import { unknownRecordZ } from "@synnaxlabs/x/record";
4
12
  import { z } from "zod";
5
13
 
6
14
  import { ontology } from "@/ontology";
7
-
8
- export const keyZ = z.string().uuid();
9
- export type Key = z.infer<typeof keyZ>;
10
- export type Params = Key | Key[];
11
-
12
- export const logZ = z.object({
13
- key: z.string(),
14
- name: z.string(),
15
- data: unknownRecordZ.or(z.string().transform((s) => JSON.parse(s) as UnknownRecord)),
16
- });
17
-
18
- export type Log = z.infer<typeof logZ>;
19
-
20
- export const ONTOLOGY_TYPE: ontology.ResourceType = "log";
21
-
22
- export const ontologyID = (key: Key): ontology.ID =>
23
- new ontology.ID({ type: ONTOLOGY_TYPE, key });
15
+ import {
16
+ type Key,
17
+ keyZ,
18
+ type Log,
19
+ logZ,
20
+ type New,
21
+ newZ,
22
+ ONTOLOGY_TYPE,
23
+ type Params,
24
+ } from "@/workspace/log/payload";
25
+ import { type Key as WorkspaceKey, keyZ as workspaceKeyZ } from "@/workspace/payload";
24
26
 
25
27
  const RETRIEVE_ENDPOINT = "/workspace/log/retrieve";
26
28
  const CREATE_ENDPOINT = "/workspace/log/create";
@@ -28,18 +30,11 @@ const RENAME_ENDPOINT = "/workspace/log/rename";
28
30
  const SET_DATA_ENDPOINT = "/workspace/log/set-data";
29
31
  const DELETE_ENDPOINT = "/workspace/log/delete";
30
32
 
31
- export const newLogZ = logZ.partial({ key: true }).transform((p) => ({
32
- ...p,
33
- data: JSON.stringify(p.data),
34
- }));
35
-
36
- export type NewLog = z.input<typeof newLogZ>;
37
-
38
- const retrieveReqZ = z.object({ keys: z.string().array() });
39
- const createReqZ = z.object({ workspace: z.string(), logs: newLogZ.array() });
40
- const renameReqZ = z.object({ key: z.string(), name: z.string() });
41
- const setDataReqZ = z.object({ key: z.string(), data: z.string() });
42
- const deleteReqZ = z.object({ keys: z.string().array() });
33
+ const retrieveReqZ = z.object({ keys: keyZ.array() });
34
+ const createReqZ = z.object({ workspace: workspaceKeyZ, logs: newZ.array() });
35
+ const renameReqZ = z.object({ key: keyZ, name: z.string() });
36
+ const setDataReqZ = z.object({ key: keyZ, data: z.string() });
37
+ const deleteReqZ = z.object({ keys: keyZ.array() });
43
38
 
44
39
  const retrieveResZ = z.object({ logs: logZ.array() });
45
40
  const createResZ = z.object({ logs: logZ.array() });
@@ -52,15 +47,14 @@ export class Client {
52
47
  this.client = client;
53
48
  }
54
49
 
55
- async create(workspace: string, log: NewLog): Promise<Log>;
56
- async create(workspace: string, logs: NewLog[]): Promise<Log[]>;
57
- async create(workspace: string, logs: NewLog | NewLog[]): Promise<Log | Log[]> {
50
+ async create(workspace: WorkspaceKey, log: New): Promise<Log>;
51
+ async create(workspace: WorkspaceKey, logs: New[]): Promise<Log[]>;
52
+ async create(workspace: WorkspaceKey, logs: New | New[]): Promise<Log | Log[]> {
58
53
  const isMany = Array.isArray(logs);
59
- const normalized = toArray(logs);
60
54
  const res = await sendRequired(
61
55
  this.client,
62
56
  CREATE_ENDPOINT,
63
- { workspace, logs: normalized },
57
+ { workspace, logs: toArray(logs) },
64
58
  createReqZ,
65
59
  createResZ,
66
60
  );
@@ -91,11 +85,10 @@ export class Client {
91
85
  async retrieve(keys: Key[]): Promise<Log[]>;
92
86
  async retrieve(keys: Params): Promise<Log | Log[]> {
93
87
  const isMany = Array.isArray(keys);
94
- const normalized = toArray(keys);
95
88
  const res = await sendRequired(
96
89
  this.client,
97
90
  RETRIEVE_ENDPOINT,
98
- { keys: normalized },
91
+ { keys: toArray(keys) },
99
92
  retrieveReqZ,
100
93
  retrieveResZ,
101
94
  );
@@ -105,13 +98,15 @@ export class Client {
105
98
  async delete(key: Key): Promise<void>;
106
99
  async delete(keys: Key[]): Promise<void>;
107
100
  async delete(keys: Params): Promise<void> {
108
- const normalized = toArray(keys);
109
101
  await sendRequired(
110
102
  this.client,
111
103
  DELETE_ENDPOINT,
112
- { keys: normalized },
104
+ { keys: toArray(keys) },
113
105
  deleteReqZ,
114
106
  emptyResZ,
115
107
  );
116
108
  }
117
109
  }
110
+
111
+ export const ontologyID = (key: Key): ontology.ID =>
112
+ new ontology.ID({ type: ONTOLOGY_TYPE, key });
@@ -0,0 +1,11 @@
1
+ // Copyright 2025 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/log/client";
11
+ export * from "@/workspace/log/payload";
@@ -1,4 +1,4 @@
1
- // Copyright 2024 Synnax Labs, Inc.
1
+ // Copyright 2025 Synnax Labs, Inc.
2
2
  //
3
3
  // Use of this software is governed by the Business Source License included in the file
4
4
  // licenses/BSL.txt.
@@ -7,4 +7,4 @@
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
- export * as log from "@/workspace/log/client";
10
+ export * as log from "@/workspace/log/external";
@@ -1,4 +1,4 @@
1
- // Copyright 2024 Synnax Labs, Inc.
1
+ // Copyright 2025 Synnax Labs, Inc.
2
2
  //
3
3
  // Use of this software is governed by the Business Source License included in the file
4
4
  // licenses/BSL.txt.
@@ -7,21 +7,17 @@
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 { NIL as ZERO_UUID } from "uuid";
10
11
  import { describe, expect, test } from "vitest";
11
12
 
12
13
  import { newClient } from "@/setupspecs";
13
14
 
14
15
  const client = newClient();
15
16
 
16
- const ZERO_UUID = "00000000-0000-0000-0000-000000000000";
17
-
18
17
  describe("Log", () => {
19
18
  describe("create", () => {
20
19
  test("create one", async () => {
21
- const ws = await client.workspaces.create({
22
- name: "Log",
23
- layout: { one: 1 },
24
- });
20
+ const ws = await client.workspaces.create({ name: "Log", layout: { one: 1 } });
25
21
  const log = await client.workspaces.log.create(ws.key, {
26
22
  name: "Log",
27
23
  data: { one: 1 },
@@ -33,10 +29,7 @@ describe("Log", () => {
33
29
  });
34
30
  describe("rename", () => {
35
31
  test("rename one", async () => {
36
- const ws = await client.workspaces.create({
37
- name: "Log",
38
- layout: { one: 1 },
39
- });
32
+ const ws = await client.workspaces.create({ name: "Log", layout: { one: 1 } });
40
33
  const log = await client.workspaces.log.create(ws.key, {
41
34
  name: "Log",
42
35
  data: { one: 1 },
@@ -48,10 +41,7 @@ describe("Log", () => {
48
41
  });
49
42
  describe("setData", () => {
50
43
  test("set data", async () => {
51
- const ws = await client.workspaces.create({
52
- name: "Log",
53
- layout: { one: 1 },
54
- });
44
+ const ws = await client.workspaces.create({ name: "Log", layout: { one: 1 } });
55
45
  const log = await client.workspaces.log.create(ws.key, {
56
46
  name: "Log",
57
47
  data: { one: 1 },
@@ -63,10 +53,7 @@ describe("Log", () => {
63
53
  });
64
54
  describe("delete", () => {
65
55
  test("delete one", async () => {
66
- const ws = await client.workspaces.create({
67
- name: "Log",
68
- layout: { one: 1 },
69
- });
56
+ const ws = await client.workspaces.create({ name: "Log", layout: { one: 1 } });
70
57
  const log = await client.workspaces.log.create(ws.key, {
71
58
  name: "Log",
72
59
  data: { one: 1 },
@@ -0,0 +1,32 @@
1
+ // Copyright 2025 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 { unknownRecordZ } from "@synnaxlabs/x/record";
11
+ import { z } from "zod";
12
+
13
+ import { parseWithoutKeyConversion } from "@/util/parseWithoutKeyConversion";
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 logZ = z.object({
20
+ key: keyZ,
21
+ name: z.string(),
22
+ data: unknownRecordZ.or(z.string().transform(parseWithoutKeyConversion)),
23
+ });
24
+ export interface Log extends z.infer<typeof logZ> {}
25
+
26
+ export const newZ = logZ
27
+ .partial({ key: true })
28
+ .transform((p) => ({ ...p, data: JSON.stringify(p.data) }));
29
+ export interface New extends z.input<typeof newZ> {}
30
+
31
+ export const ONTOLOGY_TYPE = "log";
32
+ export type OntologyType = typeof ONTOLOGY_TYPE;
@@ -0,0 +1,36 @@
1
+ // Copyright 2025 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 { unknownRecordZ } from "@synnaxlabs/x/record";
11
+ import { z } from "zod";
12
+
13
+ import { parseWithoutKeyConversion } from "@/util/parseWithoutKeyConversion";
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 workspaceZ = z.object({
20
+ key: keyZ,
21
+ name: z.string(),
22
+ layout: unknownRecordZ.or(z.string().transform(parseWithoutKeyConversion)),
23
+ });
24
+ export interface Workspace extends z.infer<typeof workspaceZ> {}
25
+
26
+ export const ONTOLOGY_TYPE = "workspace";
27
+ export type OntologyType = typeof ONTOLOGY_TYPE;
28
+
29
+ export const newZ = workspaceZ
30
+ .partial({ key: true })
31
+ .transform((p) => ({ ...p, layout: JSON.stringify(p.layout) }));
32
+ export interface New extends z.input<typeof newZ> {}
33
+
34
+ export const remoteZ = workspaceZ
35
+ .omit({ layout: true })
36
+ .extend({ layout: z.string().transform(parseWithoutKeyConversion) });