@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,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.
@@ -8,7 +8,7 @@
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
10
  import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
- import { observe, toArray } from "@synnaxlabs/x";
11
+ import { observe, strings, toArray } from "@synnaxlabs/x";
12
12
  import { type AsyncTermSearcher } from "@synnaxlabs/x/search";
13
13
  import { z } from "zod";
14
14
 
@@ -25,8 +25,8 @@ import {
25
25
  type RelationshipDirection,
26
26
  type Resource,
27
27
  type ResourceChange,
28
- resourceSchemaZ,
29
28
  resourceTypeZ,
29
+ resourceZ,
30
30
  } from "@/ontology/payload";
31
31
  import { Writer } from "@/ontology/writer";
32
32
 
@@ -43,17 +43,12 @@ const retrieveReqZ = z.object({
43
43
  offset: z.number().optional(),
44
44
  types: resourceTypeZ.array().optional(),
45
45
  });
46
+ interface RetrieveRequest extends z.infer<typeof retrieveReqZ> {}
46
47
 
47
- type RetrieveRequest = z.infer<typeof retrieveReqZ>;
48
+ export interface RetrieveOptions
49
+ extends Pick<RetrieveRequest, "includeSchema" | "excludeFieldData" | "types"> {}
48
50
 
49
- export type RetrieveOptions = Pick<
50
- RetrieveRequest,
51
- "includeSchema" | "excludeFieldData" | "types"
52
- >;
53
-
54
- const retrieveResZ = z.object({
55
- resources: resourceSchemaZ.array(),
56
- });
51
+ const retrieveResZ = z.object({ resources: resourceZ.array() });
57
52
 
58
53
  export const parseIDs = (ids: CrudeID | CrudeID[] | string | string[]): IDPayload[] =>
59
54
  toArray(ids).map((id) => new ID(id).payload);
@@ -123,7 +118,11 @@ export class Client implements AsyncTermSearcher<string, string, Resource> {
123
118
  const resources = await this.execRetrieve({ ids: parseIDs(ids), ...options });
124
119
  if (Array.isArray(ids)) return resources;
125
120
  if (resources.length === 0)
126
- throw new QueryError(`No resource found with ID ${ids.toString()}`);
121
+ throw new QueryError(
122
+ `No resource found with ID ${strings.naturalLanguageJoin(
123
+ toArray(ids).map((id) => new ID(id).toString()),
124
+ )}`,
125
+ );
127
126
  return resources[0];
128
127
  }
129
128
 
@@ -250,10 +249,10 @@ export class Client implements AsyncTermSearcher<string, string, Resource> {
250
249
  }
251
250
  }
252
251
 
253
- const RESOURCE_SET_NAME = "sy_ontology_resource_set";
254
- const RESOURCE_DELETE_NAME = "sy_ontology_resource_delete";
255
- const RELATIONSHIP_SET_NAME = "sy_ontology_relationship_set";
256
- const RELATIONSHIP_DELETE_NAME = "sy_ontology_relationship_delete";
252
+ const RESOURCE_SET_CHANNEL_NAME = "sy_ontology_resource_set";
253
+ const RESOURCE_DELETE_CHANNEL_NAME = "sy_ontology_resource_delete";
254
+ const RELATIONSHIP_SET_CHANNEL_NAME = "sy_ontology_relationship_set";
255
+ const RELATIONSHIP_DELETE_CHANNEL_NAME = "sy_ontology_relationship_delete";
257
256
 
258
257
  /**
259
258
  * A class that tracks changes to the ontology's resources and relationships.
@@ -306,7 +305,7 @@ export class ChangeTracker {
306
305
  }
307
306
 
308
307
  private parseRelationshipSets(frame: framer.Frame): RelationshipChange[] {
309
- const relationships = frame.get(RELATIONSHIP_SET_NAME);
308
+ const relationships = frame.get(RELATIONSHIP_SET_CHANNEL_NAME);
310
309
  if (relationships.length === 0) return [];
311
310
  return Array.from(relationships.as("string")).map((rel) => ({
312
311
  variant: "set",
@@ -316,7 +315,7 @@ export class ChangeTracker {
316
315
  }
317
316
 
318
317
  private parseRelationshipDeletes(frame: framer.Frame): RelationshipChange[] {
319
- const relationships = frame.get(RELATIONSHIP_DELETE_NAME);
318
+ const relationships = frame.get(RELATIONSHIP_DELETE_CHANNEL_NAME);
320
319
  if (relationships.length === 0) return [];
321
320
  return Array.from(relationships.as("string")).map((rel) => ({
322
321
  variant: "delete",
@@ -325,7 +324,7 @@ export class ChangeTracker {
325
324
  }
326
325
 
327
326
  private async parseResourceSets(frame: framer.Frame): Promise<ResourceChange[]> {
328
- const sets = frame.get(RESOURCE_SET_NAME);
327
+ const sets = frame.get(RESOURCE_SET_CHANNEL_NAME);
329
328
  if (sets.length === 0) return [];
330
329
  // We should only ever get one series of sets
331
330
  const ids = Array.from(sets.as("string")).map((id: string) => new ID(id));
@@ -343,7 +342,7 @@ export class ChangeTracker {
343
342
  }
344
343
 
345
344
  private parseResourceDeletes(frame: framer.Frame): ResourceChange[] {
346
- const deletes = frame.get(RESOURCE_DELETE_NAME);
345
+ const deletes = frame.get(RESOURCE_DELETE_CHANNEL_NAME);
347
346
  if (deletes.length === 0) return [];
348
347
  // We should only ever get one series of deletes
349
348
  return Array.from(deletes.as("string")).map((str) => ({
@@ -354,10 +353,10 @@ export class ChangeTracker {
354
353
 
355
354
  static async open(client: framer.Client, retriever: Client): Promise<ChangeTracker> {
356
355
  const streamer = await client.openStreamer([
357
- RESOURCE_SET_NAME,
358
- RESOURCE_DELETE_NAME,
359
- RELATIONSHIP_SET_NAME,
360
- RELATIONSHIP_DELETE_NAME,
356
+ RESOURCE_SET_CHANNEL_NAME,
357
+ RESOURCE_DELETE_CHANNEL_NAME,
358
+ RELATIONSHIP_SET_CHANNEL_NAME,
359
+ RELATIONSHIP_DELETE_CHANNEL_NAME,
361
360
  ]);
362
361
  return new ChangeTracker(streamer, retriever);
363
362
  }
@@ -458,10 +457,13 @@ export class DependentTracker
458
457
  c.key[oppositeDirection(this.relDir)].type === this.resourceType),
459
458
  );
460
459
  if (sets.length === 0) return this.notify(this.dependents);
461
- this.client.retrieve(sets.map((s) => s.key.to)).then((resources) => {
462
- this.dependents = this.dependents.concat(resources);
463
- this.notify(this.dependents);
464
- });
460
+ this.client
461
+ .retrieve(sets.map((s) => s.key.to))
462
+ .then((resources) => {
463
+ this.dependents = this.dependents.concat(resources);
464
+ this.notify(this.dependents);
465
+ })
466
+ .catch(console.error);
465
467
  };
466
468
 
467
469
  async close(): Promise<void> {
@@ -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.
@@ -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.
@@ -9,10 +9,10 @@
9
9
 
10
10
  import { type UnaryClient } from "@synnaxlabs/freighter";
11
11
 
12
+ import { type ontology } from "@/ontology";
12
13
  import { Group } from "@/ontology/group/group";
13
- import { type Payload } from "@/ontology/group/payload";
14
+ import { type Key, type Name, type Payload } from "@/ontology/group/payload";
14
15
  import { Writer } from "@/ontology/group/writer";
15
- import { type ID } from "@/ontology/payload";
16
16
 
17
17
  export class Client {
18
18
  private readonly creator: Writer;
@@ -21,15 +21,15 @@ export class Client {
21
21
  this.creator = new Writer(unary);
22
22
  }
23
23
 
24
- async create(parent: ID, name: string, key?: string): Promise<Group> {
24
+ async create(parent: ontology.ID, name: Name, key?: Key): Promise<Group> {
25
25
  return this.sugar(await this.creator.create(parent, name, key));
26
26
  }
27
27
 
28
- async rename(key: string, name: string): Promise<void> {
28
+ async rename(key: Key, name: Name): Promise<void> {
29
29
  return await this.creator.rename(key, name);
30
30
  }
31
31
 
32
- async delete(...keys: string[]): Promise<void> {
32
+ async delete(...keys: Key[]): Promise<void> {
33
33
  return await this.creator.delete(keys);
34
34
  }
35
35
 
@@ -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.
@@ -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,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
 
12
12
  import { QueryError } from "@/errors";
13
13
  import { ontology } from "@/ontology";
@@ -19,14 +19,14 @@ describe("Group", () => {
19
19
  describe("create", () => {
20
20
  it("should correctly create a group", async () => {
21
21
  const name = `group-${Math.random()}`;
22
- const g = await client.ontology.groups.create(ontology.Root, name);
22
+ const g = await client.ontology.groups.create(ontology.ROOT_ID, name);
23
23
  expect(g.name).toEqual(name);
24
24
  });
25
25
  });
26
26
  describe("rename", () => {
27
27
  it("should correctly rename a group", async () => {
28
28
  const name = `group-${Math.random()}`;
29
- const g = await client.ontology.groups.create(ontology.Root, name);
29
+ const g = await client.ontology.groups.create(ontology.ROOT_ID, name);
30
30
  const newName = `group-${Math.random()}`;
31
31
  await client.ontology.groups.rename(g.key, newName);
32
32
  const g2 = await client.ontology.retrieve(g.ontologyID);
@@ -36,7 +36,7 @@ describe("Group", () => {
36
36
  describe("delete", () => {
37
37
  it("should correctly delete the group", async () => {
38
38
  const name = `group-${Math.random()}`;
39
- const g = await client.ontology.groups.create(ontology.Root, name);
39
+ const g = await client.ontology.groups.create(ontology.ROOT_ID, name);
40
40
  await client.ontology.groups.delete(g.key);
41
41
  await expect(
42
42
  async () => await client.ontology.retrieve(g.ontologyID),
@@ -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,19 +7,22 @@
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 { type ontology } from "@/ontology";
11
- import { ontologyID as payloadOntologyID } from "@/ontology/group/payload";
10
+ import { type Key, type Name, ONTOLOGY_TYPE } from "@/ontology/group/payload";
11
+ import { ID as OntologyID } from "@/ontology/payload";
12
12
 
13
13
  export class Group {
14
- key: string;
15
- name: string;
14
+ key: Key;
15
+ name: Name;
16
16
 
17
- constructor(name: string, key: string) {
17
+ constructor(name: Name, key: Key) {
18
18
  this.key = key;
19
19
  this.name = name;
20
20
  }
21
21
 
22
- get ontologyID(): ontology.ID {
23
- return payloadOntologyID(this.key);
22
+ get ontologyID(): OntologyID {
23
+ return ontologyID(this.key);
24
24
  }
25
25
  }
26
+
27
+ export const ontologyID = (key: Key): OntologyID =>
28
+ new OntologyID({ type: ONTOLOGY_TYPE, key });
@@ -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.
@@ -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.
@@ -10,44 +10,22 @@
10
10
  import { toArray } from "@synnaxlabs/x/toArray";
11
11
  import { z } from "zod";
12
12
 
13
- import { ontology } from "@/ontology";
14
-
15
13
  export const keyZ = z.string().uuid();
16
14
  export type Key = z.infer<typeof keyZ>;
17
- export type Name = string;
15
+ export const nameZ = z.string();
16
+ export type Name = z.infer<typeof nameZ>;
18
17
  export type Keys = Key[];
19
18
  export type Names = Name[];
20
19
  export type Params = Key | Name | Keys | Names;
21
20
 
22
- export const groupZ = z.object({ key: keyZ, name: z.string() });
23
-
24
- export type Payload = z.infer<typeof groupZ>;
21
+ export const groupZ = z.object({ key: keyZ, name: nameZ });
22
+ export interface Payload extends z.infer<typeof groupZ> {}
25
23
 
26
24
  export type ParamAnalysisResult =
27
- | {
28
- single: true;
29
- variant: "keys";
30
- normalized: Keys;
31
- actual: Key;
32
- }
33
- | {
34
- single: true;
35
- variant: "names";
36
- normalized: Names;
37
- actual: Name;
38
- }
39
- | {
40
- single: false;
41
- variant: "keys";
42
- normalized: Keys;
43
- actual: Keys;
44
- }
45
- | {
46
- single: false;
47
- variant: "names";
48
- normalized: Names;
49
- actual: Names;
50
- };
25
+ | { single: true; variant: "keys"; normalized: Keys; actual: Key }
26
+ | { single: true; variant: "names"; normalized: Names; actual: Name }
27
+ | { single: false; variant: "keys"; normalized: Keys; actual: Keys }
28
+ | { single: false; variant: "names"; normalized: Names; actual: Names };
51
29
 
52
30
  export const analyzeParams = (groups: Params): ParamAnalysisResult => {
53
31
  const normal = toArray(groups) as Keys | Names;
@@ -58,10 +36,8 @@ export const analyzeParams = (groups: Params): ParamAnalysisResult => {
58
36
  variant: isKey ? "keys" : "names",
59
37
  normalized: normal,
60
38
  actual: groups,
61
- } as const as ParamAnalysisResult;
39
+ } as ParamAnalysisResult;
62
40
  };
63
41
 
64
- export const ONTOLOGY_TYPE: ontology.ResourceType = "group";
65
-
66
- export const ontologyID = (key: Key): ontology.ID =>
67
- new ontology.ID({ type: ONTOLOGY_TYPE, key });
42
+ export const ONTOLOGY_TYPE = "group";
43
+ export type OntologyType = typeof ONTOLOGY_TYPE;
@@ -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.
@@ -10,42 +10,38 @@
10
10
  import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { z } from "zod";
12
12
 
13
- import { groupZ, type Payload } from "@/ontology/group/payload";
14
- import { type ID, idZ } from "@/ontology/payload";
13
+ import {
14
+ groupZ,
15
+ type Key,
16
+ keyZ,
17
+ type Name,
18
+ nameZ,
19
+ type Payload,
20
+ } from "@/ontology/group/payload";
21
+ import { type ID as OntologyID, idZ as ontologyIDZ } from "@/ontology/payload";
15
22
 
16
- const resZ = z.object({
17
- group: groupZ,
18
- });
23
+ const resZ = z.object({ group: groupZ });
19
24
 
20
- const createReqZ = z.object({
21
- parent: idZ,
22
- key: z.string().uuid().optional(),
23
- name: z.string(),
24
- });
25
+ const createReqZ = z.object({ parent: ontologyIDZ, key: keyZ.optional(), name: nameZ });
25
26
 
26
- const renameReqZ = z.object({
27
- key: z.string(),
28
- name: z.string(),
29
- });
27
+ const renameReqZ = z.object({ key: keyZ, name: nameZ });
30
28
 
31
- const deleteReqZ = z.object({
32
- keys: z.array(z.string()),
33
- });
29
+ const deleteReqZ = z.object({ keys: z.array(keyZ) });
34
30
 
35
31
  export class Writer {
36
- private static readonly ENDPOINT = "/ontology/create-group";
37
- private static readonly ENDPOINT_RENAME = "/ontology/rename-group";
38
- private static readonly ENDPOINT_DELETE = "/ontology/delete-group";
32
+ private static readonly CREATE_ENDPOINT = "/ontology/create-group";
33
+ private static readonly RENAME_ENDPOINT = "/ontology/rename-group";
34
+ private static readonly DELETE_ENDPOINT = "/ontology/delete-group";
39
35
  client: UnaryClient;
40
36
 
41
37
  constructor(client: UnaryClient) {
42
38
  this.client = client;
43
39
  }
44
40
 
45
- async create(parent: ID, name: string, key?: string): Promise<Payload> {
41
+ async create(parent: OntologyID, name: Name, key?: Key): Promise<Payload> {
46
42
  const res = await sendRequired(
47
43
  this.client,
48
- Writer.ENDPOINT,
44
+ Writer.CREATE_ENDPOINT,
49
45
  { parent, name, key },
50
46
  createReqZ,
51
47
  resZ,
@@ -53,20 +49,20 @@ export class Writer {
53
49
  return res.group;
54
50
  }
55
51
 
56
- async rename(key: string, name: string): Promise<void> {
52
+ async rename(key: Key, name: Name): Promise<void> {
57
53
  await sendRequired(
58
54
  this.client,
59
- Writer.ENDPOINT_RENAME,
55
+ Writer.RENAME_ENDPOINT,
60
56
  { key, name },
61
57
  renameReqZ,
62
58
  z.object({}),
63
59
  );
64
60
  }
65
61
 
66
- async delete(keys: string[]): Promise<void> {
62
+ async delete(keys: Key[]): Promise<void> {
67
63
  await sendRequired(
68
64
  this.client,
69
- Writer.ENDPOINT_DELETE,
65
+ Writer.DELETE_ENDPOINT,
70
66
  { keys },
71
67
  deleteReqZ,
72
68
  z.object({}),
@@ -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.
@@ -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.
@@ -20,13 +20,13 @@ describe("Ontology", () => {
20
20
  describe("retrieve", () => {
21
21
  test("retrieve", async () => {
22
22
  const name = randomName();
23
- const g = await client.ontology.groups.create(ontology.Root, name);
23
+ const g = await client.ontology.groups.create(ontology.ROOT_ID, name);
24
24
  const g2 = await client.ontology.retrieve(g.ontologyID);
25
25
  expect(g2.name).toEqual(name);
26
26
  });
27
27
  test("retrieve children", async () => {
28
28
  const name = randomName();
29
- const g = await client.ontology.groups.create(ontology.Root, name);
29
+ const g = await client.ontology.groups.create(ontology.ROOT_ID, name);
30
30
  const name2 = randomName();
31
31
  await client.ontology.groups.create(g.ontologyID, name2);
32
32
  const children = await client.ontology.retrieveChildren(g.ontologyID);
@@ -35,7 +35,7 @@ describe("Ontology", () => {
35
35
  });
36
36
  test("retrieve parents", async () => {
37
37
  const name = randomName();
38
- const g = await client.ontology.groups.create(ontology.Root, name);
38
+ const g = await client.ontology.groups.create(ontology.ROOT_ID, name);
39
39
  const name2 = randomName();
40
40
  const g2 = await client.ontology.groups.create(g.ontologyID, name2);
41
41
  const parents = await client.ontology.retrieveParents(g2.ontologyID);
@@ -46,7 +46,7 @@ describe("Ontology", () => {
46
46
  describe("page", () => {
47
47
  it("should return a page of resources", async () => {
48
48
  for (let i = 0; i < 10; i++)
49
- await client.ontology.groups.create(ontology.Root, randomName());
49
+ await client.ontology.groups.create(ontology.ROOT_ID, randomName());
50
50
  const page = await client.ontology.page(0, 5);
51
51
  expect(page.length).toEqual(5);
52
52
  const page2 = await client.ontology.page(5, 5);
@@ -60,9 +60,9 @@ describe("Ontology", () => {
60
60
  describe("write", () => {
61
61
  test("add children", async () => {
62
62
  const name = randomName();
63
- const g = await client.ontology.groups.create(ontology.Root, name);
63
+ const g = await client.ontology.groups.create(ontology.ROOT_ID, name);
64
64
  const name2 = randomName();
65
- const g2 = await client.ontology.groups.create(ontology.Root, name2);
65
+ const g2 = await client.ontology.groups.create(ontology.ROOT_ID, name2);
66
66
  await client.ontology.addChildren(g.ontologyID, g2.ontologyID);
67
67
  const children = await client.ontology.retrieveChildren(g.ontologyID);
68
68
  expect(children.length).toEqual(1);
@@ -70,9 +70,9 @@ describe("Ontology", () => {
70
70
  });
71
71
  test("remove children", async () => {
72
72
  const name = randomName();
73
- const g = await client.ontology.groups.create(ontology.Root, name);
73
+ const g = await client.ontology.groups.create(ontology.ROOT_ID, name);
74
74
  const name2 = randomName();
75
- const g2 = await client.ontology.groups.create(ontology.Root, name2);
75
+ const g2 = await client.ontology.groups.create(ontology.ROOT_ID, name2);
76
76
  await client.ontology.addChildren(g.ontologyID, g2.ontologyID);
77
77
  await client.ontology.removeChildren(g.ontologyID, g2.ontologyID);
78
78
  const children = await client.ontology.retrieveChildren(g.ontologyID);
@@ -80,15 +80,15 @@ describe("Ontology", () => {
80
80
  });
81
81
  test("move children", async () => {
82
82
  const name = randomName();
83
- const g = await client.ontology.groups.create(ontology.Root, name);
83
+ const g = await client.ontology.groups.create(ontology.ROOT_ID, name);
84
84
  const name2 = randomName();
85
- const g2 = await client.ontology.groups.create(ontology.Root, name2);
86
- const oldRootLength = (await client.ontology.retrieveChildren(ontology.Root))
85
+ const g2 = await client.ontology.groups.create(ontology.ROOT_ID, name2);
86
+ const oldRootLength = (await client.ontology.retrieveChildren(ontology.ROOT_ID))
87
87
  .length;
88
- await client.ontology.moveChildren(ontology.Root, g.ontologyID, g2.ontologyID);
88
+ await client.ontology.moveChildren(ontology.ROOT_ID, g.ontologyID, g2.ontologyID);
89
89
  const children = await client.ontology.retrieveChildren(g.ontologyID);
90
90
  expect(children.length).toEqual(1);
91
- const newRootLength = (await client.ontology.retrieveChildren(ontology.Root))
91
+ const newRootLength = (await client.ontology.retrieveChildren(ontology.ROOT_ID))
92
92
  .length;
93
93
  expect(newRootLength).toEqual(oldRootLength - 1);
94
94
  });
@@ -107,7 +107,7 @@ describe("Ontology", () => {
107
107
  const p = new Promise<ontology.ResourceChange[]>((resolve) =>
108
108
  change.resources.onChange((changes) => resolve(changes)),
109
109
  );
110
- await client.ontology.groups.create(ontology.Root, randomName());
110
+ await client.ontology.groups.create(ontology.ROOT_ID, randomName());
111
111
  const c = await p;
112
112
  expect(c.length).toBeGreaterThan(0);
113
113
  await change.close();
@@ -119,7 +119,7 @@ describe("Ontology", () => {
119
119
  resolve(changes);
120
120
  });
121
121
  });
122
- await client.ontology.groups.create(ontology.Root, randomName());
122
+ await client.ontology.groups.create(ontology.ROOT_ID, randomName());
123
123
  const c = await p;
124
124
  expect(c.length).toBeGreaterThan(0);
125
125
  await change.close();