@synnaxlabs/client 0.38.1 → 0.40.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 (257) 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 +6 -5
  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 +3387 -3433
  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 +20 -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/examples/node/basicReadWrite.js +26 -26
  154. package/examples/node/liveStream.js +15 -15
  155. package/examples/node/seriesAndFrames.js +38 -38
  156. package/examples/node/streamWrite.js +47 -45
  157. package/package.json +15 -13
  158. package/src/access/payload.ts +12 -12
  159. package/src/access/policy/client.ts +13 -12
  160. package/src/access/policy/external.ts +1 -0
  161. package/src/access/policy/ontology.ts +17 -0
  162. package/src/access/policy/payload.ts +7 -19
  163. package/src/access/policy/policy.spec.ts +16 -16
  164. package/src/access/policy/retriever.ts +2 -1
  165. package/src/access/policy/writer.ts +4 -4
  166. package/src/auth/auth.spec.ts +27 -23
  167. package/src/auth/auth.ts +7 -11
  168. package/src/channel/batchRetriever.spec.ts +25 -22
  169. package/src/channel/client.ts +19 -21
  170. package/src/channel/payload.ts +16 -20
  171. package/src/channel/retriever.ts +20 -21
  172. package/src/channel/writer.ts +11 -13
  173. package/src/client.ts +6 -16
  174. package/src/connection/checker.ts +9 -11
  175. package/src/connection/connection.spec.ts +17 -5
  176. package/src/control/state.ts +8 -9
  177. package/src/errors.spec.ts +1 -1
  178. package/src/errors.ts +8 -0
  179. package/src/framer/adapter.spec.ts +28 -23
  180. package/src/framer/adapter.ts +37 -41
  181. package/src/framer/client.spec.ts +5 -11
  182. package/src/framer/client.ts +34 -38
  183. package/src/framer/deleter.ts +5 -6
  184. package/src/framer/frame.ts +62 -50
  185. package/src/framer/iterator.ts +11 -16
  186. package/src/framer/streamer.spec.ts +2 -10
  187. package/src/framer/streamer.ts +15 -19
  188. package/src/framer/writer.spec.ts +48 -7
  189. package/src/framer/writer.ts +39 -31
  190. package/src/hardware/device/client.ts +67 -39
  191. package/src/hardware/device/device.spec.ts +91 -33
  192. package/src/hardware/device/payload.ts +29 -28
  193. package/src/hardware/rack/client.ts +52 -65
  194. package/src/hardware/rack/payload.ts +9 -18
  195. package/src/hardware/rack/rack.spec.ts +12 -0
  196. package/src/hardware/task/client.ts +160 -131
  197. package/src/hardware/task/payload.ts +49 -68
  198. package/src/hardware/task/task.spec.ts +98 -81
  199. package/src/label/client.ts +12 -15
  200. package/src/label/payload.ts +3 -9
  201. package/src/label/retriever.ts +3 -7
  202. package/src/label/writer.ts +8 -15
  203. package/src/ontology/client.ts +17 -22
  204. package/src/ontology/group/client.ts +5 -5
  205. package/src/ontology/group/group.spec.ts +4 -4
  206. package/src/ontology/group/group.ts +10 -7
  207. package/src/ontology/group/payload.ts +11 -35
  208. package/src/ontology/group/writer.ts +22 -26
  209. package/src/ontology/ontology.spec.ts +15 -15
  210. package/src/ontology/payload.ts +67 -43
  211. package/src/ontology/writer.ts +16 -23
  212. package/src/ranger/alias.ts +25 -42
  213. package/src/ranger/client.ts +29 -38
  214. package/src/ranger/external.ts +1 -1
  215. package/src/ranger/kv.ts +9 -32
  216. package/src/ranger/payload.ts +14 -36
  217. package/src/ranger/ranger.spec.ts +1 -2
  218. package/src/ranger/writer.ts +8 -26
  219. package/src/signals/observable.ts +3 -4
  220. package/src/user/client.ts +8 -4
  221. package/src/user/payload.ts +5 -9
  222. package/src/user/retriever.ts +1 -1
  223. package/src/user/user.spec.ts +17 -15
  224. package/src/user/writer.ts +3 -10
  225. package/src/util/decodeJSONString.ts +13 -0
  226. package/src/util/parseWithoutKeyConversion.ts +19 -0
  227. package/src/util/retrieve.spec.ts +3 -13
  228. package/src/util/retrieve.ts +2 -12
  229. package/src/util/telem.ts +1 -1
  230. package/src/vite-env.d.ts +1 -0
  231. package/src/workspace/client.ts +30 -57
  232. package/src/workspace/external.ts +11 -0
  233. package/src/workspace/index.ts +1 -1
  234. package/src/workspace/lineplot/client.ts +22 -36
  235. package/src/workspace/lineplot/external.ts +11 -0
  236. package/src/workspace/lineplot/index.ts +1 -1
  237. package/src/workspace/lineplot/linePlot.spec.ts +1 -2
  238. package/src/workspace/lineplot/payload.ts +32 -0
  239. package/src/workspace/log/client.ts +25 -39
  240. package/src/workspace/log/external.ts +11 -0
  241. package/src/workspace/log/index.ts +1 -1
  242. package/src/workspace/log/log.spec.ts +5 -18
  243. package/src/workspace/log/payload.ts +32 -0
  244. package/src/workspace/payload.ts +36 -0
  245. package/src/workspace/schematic/client.ts +30 -56
  246. package/src/workspace/schematic/external.ts +11 -0
  247. package/src/workspace/schematic/index.ts +1 -1
  248. package/src/workspace/schematic/payload.ts +37 -0
  249. package/src/workspace/schematic/schematic.spec.ts +15 -6
  250. package/src/workspace/table/client.ts +27 -50
  251. package/src/workspace/table/external.ts +11 -0
  252. package/src/workspace/table/index.ts +1 -1
  253. package/src/workspace/table/payload.ts +36 -0
  254. package/src/workspace/workspace.spec.ts +1 -2
  255. package/dist/channel/creator.d.ts +0 -9
  256. package/dist/channel/creator.d.ts.map +0 -1
  257. package/src/channel/creator.ts +0 -37
@@ -7,7 +7,7 @@
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 { describe, expect,it } from "vitest";
10
+ import { describe, expect, it } from "vitest";
11
11
  import { type Primitive } from "zod";
12
12
 
13
13
  import {
@@ -28,22 +28,12 @@ describe("retrieve utils", () => {
28
28
  {
29
29
  args: "abc",
30
30
  variantMap: { string: "name" },
31
- expected: {
32
- single: true,
33
- variant: "name",
34
- normalized: ["abc"],
35
- actual: "abc",
36
- },
31
+ expected: { single: true, variant: "name", normalized: ["abc"], actual: "abc" },
37
32
  },
38
33
  {
39
34
  args: 123,
40
35
  variantMap: { number: "id" },
41
- expected: {
42
- single: true,
43
- variant: "id",
44
- normalized: [123],
45
- actual: 123,
46
- },
36
+ expected: { single: true, variant: "id", normalized: [123], actual: 123 },
47
37
  },
48
38
  ];
49
39
 
@@ -15,24 +15,14 @@ export type SingleParamAnalysisResult<
15
15
  T extends Primitive,
16
16
  K extends PartialTypeNameRecord<T>,
17
17
  > = T extends any
18
- ? {
19
- single: true;
20
- variant: K[keyof K];
21
- normalized: T[];
22
- actual: T;
23
- }
18
+ ? { single: true; variant: K[keyof K]; normalized: T[]; actual: T }
24
19
  : never;
25
20
 
26
21
  export type MultiParamAnalysisResult<
27
22
  T extends Primitive,
28
23
  K extends PartialTypeNameRecord<T>,
29
24
  > = T extends any
30
- ? {
31
- single: false;
32
- variant: K[keyof K];
33
- normalized: T[];
34
- actual: T[];
35
- }
25
+ ? { single: false; variant: K[keyof K]; normalized: T[]; actual: T[] }
36
26
  : never;
37
27
 
38
28
  type TypeName<T> = T extends string
package/src/util/telem.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  import { type DataType, type TypedArray } from "@synnaxlabs/x/telem";
11
11
 
12
12
  export const randomSeries = (length: number, dataType: DataType): TypedArray => {
13
- // generate random bytes of the correct length
13
+ // create random bytes of the correct length
14
14
  const bytes = new Uint8Array(length * dataType.density.valueOf());
15
15
  for (let i = 0; i < bytes.byteLength; i++) bytes[i] = Math.floor(Math.random() * 256);
16
16
  return new dataType.Array(bytes.buffer);
package/src/vite-env.d.ts CHANGED
@@ -8,4 +8,5 @@
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
10
  /// <reference types="vite/client" />
11
+
11
12
  declare const __VERSION__: string;
@@ -9,77 +9,52 @@
9
9
 
10
10
  import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { toArray, type UnknownRecord } from "@synnaxlabs/x";
12
- import { unknownRecordZ } from "@synnaxlabs/x/record";
13
12
  import { type AsyncTermSearcher } from "@synnaxlabs/x/search";
14
13
  import { z } from "zod";
15
14
 
16
15
  import { ontology } from "@/ontology";
16
+ import { type Key as UserKey, keyZ as userKeyZ } from "@/user/payload";
17
17
  import { nullableArrayZ } from "@/util/zod";
18
18
  import { linePlot } from "@/workspace/lineplot";
19
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";
20
31
  import { schematic } from "@/workspace/schematic";
21
32
  import { table } from "@/workspace/table";
22
33
 
23
- export const keyZ = z.string().uuid();
24
- export type Key = z.infer<typeof keyZ>;
25
- export type Params = Key | Key[];
26
-
27
- // --- VERY IMPORTANT ---
28
- // Synnax's encoders (in the binary package inside x) automatically convert the case
29
- // of keys in objects to snake_case and back to camelCase when encoding and decoding
30
- // respectively. This is done to ensure that the keys are consistent across all
31
- // languages and platforms. Sometimes workspaces have keys that are uuids, which have
32
- // dashes, and those get messed up. So we just use regular JSON for workspaces.
33
- const parse = (s: string): UnknownRecord => JSON.parse(s) as UnknownRecord;
34
-
35
- export const workspaceZ = z.object({
36
- key: z.string(),
37
- name: z.string(),
38
- layout: unknownRecordZ.or(z.string().transform((s) => parse(s))),
39
- });
40
-
41
- export type Workspace = z.infer<typeof workspaceZ>;
42
-
43
- export const ONTOLOGY_TYPE: ontology.ResourceType = "workspace";
44
-
45
- export const ontologyID = (key: Key): ontology.ID =>
46
- new ontology.ID({ type: ONTOLOGY_TYPE, key });
47
-
48
34
  const RETRIEVE_ENDPOINT = "/workspace/retrieve";
49
35
  const CREATE_ENDPOINT = "/workspace/create";
50
36
  const RENAME_ENDPOINT = "/workspace/rename";
51
37
  const SET_LAYOUT_ENDPOINT = "/workspace/set-layout";
52
38
  const DELETE_ENDPOINT = "/workspace/delete";
53
39
 
54
- export const newWorkspaceZ = workspaceZ.partial({ key: true }).transform((p) => ({
55
- ...p,
56
- layout: JSON.stringify(p.layout),
57
- }));
58
-
59
- export const workspaceRemoteZ = workspaceZ.omit({ layout: true }).extend({
60
- layout: z.string().transform((s) => parse(s)),
61
- });
62
-
63
- export type NewWorkspace = z.input<typeof newWorkspaceZ>;
64
-
65
40
  const retrieveReqZ = z.object({
66
- keys: z.string().array().optional(),
41
+ keys: keyZ.array().optional(),
67
42
  search: z.string().optional(),
68
- author: z.string().uuid().optional(),
43
+ author: userKeyZ.optional(),
69
44
  offset: z.number().optional(),
70
45
  limit: z.number().optional(),
71
46
  });
72
- const createReqZ = z.object({ workspaces: newWorkspaceZ.array() });
73
- const renameReqZ = z.object({ key: z.string(), name: z.string() });
74
- const setLayoutReqZ = z.object({ key: z.string(), layout: z.string() });
75
- 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() });
76
51
 
77
52
  const retrieveResZ = z.object({ workspaces: nullableArrayZ(workspaceZ) });
78
- const createResZ = z.object({ workspaces: workspaceRemoteZ.array() });
53
+ const createResZ = z.object({ workspaces: remoteZ.array() });
79
54
  const emptyResZ = z.object({});
80
55
 
81
56
  export class Client implements AsyncTermSearcher<string, Key, Workspace> {
82
- readonly type = "workspace";
57
+ readonly type = ONTOLOGY_TYPE;
83
58
  readonly schematic: schematic.Client;
84
59
  readonly linePlot: linePlot.Client;
85
60
  readonly log: log.Client;
@@ -94,17 +69,14 @@ export class Client implements AsyncTermSearcher<string, Key, Workspace> {
94
69
  this.table = new table.Client(client);
95
70
  }
96
71
 
97
- async create(workspace: NewWorkspace): Promise<Workspace>;
98
- async create(workspaces: NewWorkspace[]): Promise<Workspace[]>;
99
- async create(
100
- workspaces: NewWorkspace | NewWorkspace[],
101
- ): 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[]> {
102
75
  const isMany = Array.isArray(workspaces);
103
- const normalized = toArray(workspaces);
104
76
  const res = await sendRequired(
105
77
  this.client,
106
78
  CREATE_ENDPOINT,
107
- { workspaces: normalized },
79
+ { workspaces: toArray(workspaces) },
108
80
  createReqZ,
109
81
  createResZ,
110
82
  );
@@ -135,18 +107,17 @@ export class Client implements AsyncTermSearcher<string, Key, Workspace> {
135
107
  async retrieve(keys: Key[]): Promise<Workspace[]>;
136
108
  async retrieve(keys: Params): Promise<Workspace | Workspace[]> {
137
109
  const isMany = Array.isArray(keys);
138
- const normalized = toArray(keys);
139
110
  const res = await sendRequired(
140
111
  this.client,
141
112
  RETRIEVE_ENDPOINT,
142
- { keys: normalized },
113
+ { keys: toArray(keys) },
143
114
  retrieveReqZ,
144
115
  retrieveResZ,
145
116
  );
146
117
  return isMany ? res.workspaces : res.workspaces[0];
147
118
  }
148
119
 
149
- async retrieveByAuthor(author: string): Promise<Workspace[]> {
120
+ async retrieveByAuthor(author: UserKey): Promise<Workspace[]> {
150
121
  const res = await sendRequired(
151
122
  this.client,
152
123
  RETRIEVE_ENDPOINT,
@@ -182,13 +153,15 @@ export class Client implements AsyncTermSearcher<string, Key, Workspace> {
182
153
  async delete(key: Key): Promise<void>;
183
154
  async delete(keys: Key[]): Promise<void>;
184
155
  async delete(keys: Params): Promise<void> {
185
- const normalized = toArray(keys);
186
156
  await sendRequired(
187
157
  this.client,
188
158
  DELETE_ENDPOINT,
189
- { keys: normalized },
159
+ { keys: toArray(keys) },
190
160
  deleteReqZ,
191
161
  emptyResZ,
192
162
  );
193
163
  }
194
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";
@@ -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";
@@ -9,28 +9,21 @@
9
9
 
10
10
  import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { toArray, type UnknownRecord } from "@synnaxlabs/x";
12
- import { unknownRecordZ } from "@synnaxlabs/x/record";
13
12
  import { z } from "zod";
14
13
 
15
14
  import { ontology } from "@/ontology";
16
15
  import { nullableArrayZ } from "@/util/zod";
17
-
18
- export const keyZ = z.string().uuid();
19
- export type Key = z.infer<typeof keyZ>;
20
- export type Params = Key | Key[];
21
-
22
- export const linePlotZ = z.object({
23
- key: z.string(),
24
- name: z.string(),
25
- data: unknownRecordZ.or(z.string().transform((s) => JSON.parse(s) as UnknownRecord)),
26
- });
27
-
28
- export type LinePlot = z.infer<typeof linePlotZ>;
29
-
30
- export const ONTOLOGY_TYPE: ontology.ResourceType = "lineplot";
31
-
32
- export const ontologyID = (key: Key): ontology.ID =>
33
- 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";
34
27
 
35
28
  const RETRIEVE_ENDPOINT = "/workspace/lineplot/retrieve";
36
29
  const CREATE_ENDPOINT = "/workspace/lineplot/create";
@@ -38,15 +31,8 @@ const RENAME_ENDPOINT = "/workspace/lineplot/rename";
38
31
  const SET_DATA_ENDPOINT = "/workspace/lineplot/set-data";
39
32
  const DELETE_ENDPOINT = "/workspace/lineplot/delete";
40
33
 
41
- export const newLinePlotZ = linePlotZ.partial({ key: true }).transform((p) => ({
42
- ...p,
43
- data: JSON.stringify(p.data),
44
- }));
45
-
46
- export type NewLinePlot = z.input<typeof newLinePlotZ>;
47
-
48
34
  const retrieveReqZ = z.object({ keys: keyZ.array() });
49
- const createReqZ = z.object({ workspace: z.string(), linePlots: newLinePlotZ.array() });
35
+ const createReqZ = z.object({ workspace: workspaceKeyZ, linePlots: newZ.array() });
50
36
  const renameReqZ = z.object({ key: keyZ, name: z.string() });
51
37
  const setDataReqZ = z.object({ key: keyZ, data: z.string() });
52
38
  const deleteReqZ = z.object({ keys: keyZ.array() });
@@ -61,18 +47,17 @@ export class Client {
61
47
  this.client = client;
62
48
  }
63
49
 
64
- async create(workspace: string, linePlot: NewLinePlot): Promise<LinePlot>;
65
- 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[]>;
66
52
  async create(
67
- workspace: string,
68
- linePlots: NewLinePlot | NewLinePlot[],
53
+ workspace: WorkspaceKey,
54
+ linePlots: New | New[],
69
55
  ): Promise<LinePlot | LinePlot[]> {
70
56
  const isMany = Array.isArray(linePlots);
71
- const normalized = toArray(linePlots);
72
57
  const res = await sendRequired(
73
58
  this.client,
74
59
  CREATE_ENDPOINT,
75
- { workspace, linePlots: normalized },
60
+ { workspace, linePlots: toArray(linePlots) },
76
61
  createReqZ,
77
62
  createResZ,
78
63
  );
@@ -103,11 +88,10 @@ export class Client {
103
88
  async retrieve(keys: Key[]): Promise<LinePlot[]>;
104
89
  async retrieve(keys: Params): Promise<LinePlot | LinePlot[]> {
105
90
  const isMany = Array.isArray(keys);
106
- const normalized = toArray(keys);
107
91
  const res = await sendRequired(
108
92
  this.client,
109
93
  RETRIEVE_ENDPOINT,
110
- { keys: normalized },
94
+ { keys: toArray(keys) },
111
95
  retrieveReqZ,
112
96
  retrieveResZ,
113
97
  );
@@ -117,13 +101,15 @@ export class Client {
117
101
  async delete(key: Key): Promise<void>;
118
102
  async delete(keys: Key[]): Promise<void>;
119
103
  async delete(keys: Params): Promise<void> {
120
- const normalized = toArray(keys);
121
104
  await sendRequired(
122
105
  this.client,
123
106
  DELETE_ENDPOINT,
124
- { keys: normalized },
107
+ { keys: toArray(keys) },
125
108
  deleteReqZ,
126
109
  emptyResZ,
127
110
  );
128
111
  }
129
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";
@@ -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";
@@ -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;
@@ -9,27 +9,20 @@
9
9
 
10
10
  import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { toArray, type UnknownRecord } from "@synnaxlabs/x";
12
- import { unknownRecordZ } from "@synnaxlabs/x/record";
13
12
  import { z } from "zod";
14
13
 
15
14
  import { ontology } from "@/ontology";
16
-
17
- export const keyZ = z.string().uuid();
18
- export type Key = z.infer<typeof keyZ>;
19
- export type Params = Key | Key[];
20
-
21
- export const logZ = z.object({
22
- key: z.string(),
23
- name: z.string(),
24
- data: unknownRecordZ.or(z.string().transform((s) => JSON.parse(s) as UnknownRecord)),
25
- });
26
-
27
- export type Log = z.infer<typeof logZ>;
28
-
29
- export const ONTOLOGY_TYPE: ontology.ResourceType = "log";
30
-
31
- export const ontologyID = (key: Key): ontology.ID =>
32
- 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";
33
26
 
34
27
  const RETRIEVE_ENDPOINT = "/workspace/log/retrieve";
35
28
  const CREATE_ENDPOINT = "/workspace/log/create";
@@ -37,18 +30,11 @@ const RENAME_ENDPOINT = "/workspace/log/rename";
37
30
  const SET_DATA_ENDPOINT = "/workspace/log/set-data";
38
31
  const DELETE_ENDPOINT = "/workspace/log/delete";
39
32
 
40
- export const newLogZ = logZ.partial({ key: true }).transform((p) => ({
41
- ...p,
42
- data: JSON.stringify(p.data),
43
- }));
44
-
45
- export type NewLog = z.input<typeof newLogZ>;
46
-
47
- const retrieveReqZ = z.object({ keys: z.string().array() });
48
- const createReqZ = z.object({ workspace: z.string(), logs: newLogZ.array() });
49
- const renameReqZ = z.object({ key: z.string(), name: z.string() });
50
- const setDataReqZ = z.object({ key: z.string(), data: z.string() });
51
- 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() });
52
38
 
53
39
  const retrieveResZ = z.object({ logs: logZ.array() });
54
40
  const createResZ = z.object({ logs: logZ.array() });
@@ -61,15 +47,14 @@ export class Client {
61
47
  this.client = client;
62
48
  }
63
49
 
64
- async create(workspace: string, log: NewLog): Promise<Log>;
65
- async create(workspace: string, logs: NewLog[]): Promise<Log[]>;
66
- 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[]> {
67
53
  const isMany = Array.isArray(logs);
68
- const normalized = toArray(logs);
69
54
  const res = await sendRequired(
70
55
  this.client,
71
56
  CREATE_ENDPOINT,
72
- { workspace, logs: normalized },
57
+ { workspace, logs: toArray(logs) },
73
58
  createReqZ,
74
59
  createResZ,
75
60
  );
@@ -100,11 +85,10 @@ export class Client {
100
85
  async retrieve(keys: Key[]): Promise<Log[]>;
101
86
  async retrieve(keys: Params): Promise<Log | Log[]> {
102
87
  const isMany = Array.isArray(keys);
103
- const normalized = toArray(keys);
104
88
  const res = await sendRequired(
105
89
  this.client,
106
90
  RETRIEVE_ENDPOINT,
107
- { keys: normalized },
91
+ { keys: toArray(keys) },
108
92
  retrieveReqZ,
109
93
  retrieveResZ,
110
94
  );
@@ -114,13 +98,15 @@ export class Client {
114
98
  async delete(key: Key): Promise<void>;
115
99
  async delete(keys: Key[]): Promise<void>;
116
100
  async delete(keys: Params): Promise<void> {
117
- const normalized = toArray(keys);
118
101
  await sendRequired(
119
102
  this.client,
120
103
  DELETE_ENDPOINT,
121
- { keys: normalized },
104
+ { keys: toArray(keys) },
122
105
  deleteReqZ,
123
106
  emptyResZ,
124
107
  );
125
108
  }
126
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";
@@ -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";
@@ -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;