@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.
@@ -10,43 +10,65 @@
10
10
  import { type change, type UnknownRecord } from "@synnaxlabs/x";
11
11
  import { z } from "zod";
12
12
 
13
+ import {
14
+ ALLOW_ALL_ONTOLOGY_TYPE as ALLOW_ALL_TYPE,
15
+ ONTOLOGY_TYPE as POLICY_TYPE,
16
+ } from "@/access/policy/ontology";
17
+ import { ONTOLOGY_TYPE as CHANNEL_TYPE } from "@/channel/payload";
18
+ import { ONTOLOGY_TYPE as FRAMER_TYPE } from "@/framer/frame";
19
+ import { ONTOLOGY_TYPE as DEVICE_TYPE } from "@/hardware/device/payload";
20
+ import { ONTOLOGY_TYPE as RACK_TYPE } from "@/hardware/rack/payload";
21
+ import { ONTOLOGY_TYPE as TASK_TYPE } from "@/hardware/task/payload";
22
+ import { ONTOLOGY_TYPE as LABEL_TYPE } from "@/label/payload";
23
+ import { ONTOLOGY_TYPE as GROUP_TYPE } from "@/ontology/group/payload";
24
+ import {
25
+ ALIAS_ONTOLOGY_TYPE as RANGE_ALIAS_TYPE,
26
+ ONTOLOGY_TYPE as RANGE_TYPE,
27
+ } from "@/ranger/payload";
28
+ import { ONTOLOGY_TYPE as USER_TYPE } from "@/user/payload";
29
+ import { ONTOLOGY_TYPE as LINE_PLOT_TYPE } from "@/workspace/lineplot/payload";
30
+ import { ONTOLOGY_TYPE as LOG_TYPE } from "@/workspace/log/payload";
31
+ import { ONTOLOGY_TYPE as WORKSPACE_TYPE } from "@/workspace/payload";
32
+ import { ONTOLOGY_TYPE as SCHEMATIC_TYPE } from "@/workspace/schematic/payload";
33
+ import { ONTOLOGY_TYPE as TABLE_TYPE } from "@/workspace/table/payload";
34
+
13
35
  export type ResourceChange = change.Change<ID, Resource>;
14
- export type ResourceSet = change.Set<ID, Resource>;
15
- export type ResourceDelete = change.Delete<ID, Resource>;
36
+ export interface ResourceSet extends change.Set<ID, Resource> {}
37
+ export interface ResourceDelete extends change.Delete<ID, Resource> {}
16
38
  export type RelationshipChange = change.Change<Relationship, undefined>;
17
- export type RelationshipSet = change.Set<Relationship, undefined>;
18
- export type RelationshipDelete = change.Delete<Relationship, undefined>;
19
-
20
- export const resourceTypeZ = z.union([
21
- z.literal("label"),
22
- z.literal("log"),
23
- z.literal("allow_all"),
24
- z.literal("builtin"),
25
- z.literal("cluster"),
26
- z.literal("channel"),
27
- z.literal("node"),
28
- z.literal("group"),
29
- z.literal("range"),
30
- z.literal("framer"),
31
- z.literal("range-alias"),
32
- z.literal("user"),
33
- z.literal("workspace"),
34
- z.literal("schematic"),
35
- z.literal("lineplot"),
36
- z.literal("rack"),
37
- z.literal("device"),
38
- z.literal("task"),
39
- z.literal("policy"),
40
- z.literal("table"),
39
+ export interface RelationshipSet extends change.Set<Relationship, undefined> {}
40
+ export interface RelationshipDelete extends change.Delete<Relationship, undefined> {}
41
+
42
+ export const BUILTIN_TYPE = "builtin";
43
+ export const CLUSTER_TYPE = "cluster";
44
+ export const NODE_TYPE = "node";
45
+
46
+ export const resourceTypeZ = z.enum([
47
+ LABEL_TYPE,
48
+ LOG_TYPE,
49
+ ALLOW_ALL_TYPE,
50
+ BUILTIN_TYPE,
51
+ CLUSTER_TYPE,
52
+ CHANNEL_TYPE,
53
+ NODE_TYPE,
54
+ GROUP_TYPE,
55
+ RANGE_TYPE,
56
+ FRAMER_TYPE,
57
+ RANGE_ALIAS_TYPE,
58
+ USER_TYPE,
59
+ WORKSPACE_TYPE,
60
+ SCHEMATIC_TYPE,
61
+ LINE_PLOT_TYPE,
62
+ RACK_TYPE,
63
+ DEVICE_TYPE,
64
+ TASK_TYPE,
65
+ POLICY_TYPE,
66
+ TABLE_TYPE,
41
67
  ]);
42
68
  export type ResourceType = z.infer<typeof resourceTypeZ>;
43
69
 
44
- export const BUILTIN_TYPE: ResourceType = "builtin";
45
- export const CLUSTER_TYPE: ResourceType = "cluster";
46
- export const NODE_TYPE: ResourceType = "node";
47
-
48
70
  export const idZ = z.object({ type: resourceTypeZ, key: z.string() });
49
- export type IDPayload = z.infer<typeof idZ>;
71
+ export interface IDPayload extends z.infer<typeof idZ> {}
50
72
 
51
73
  export const stringIDZ = z.string().transform((v) => {
52
74
  const [type, key] = v.split(":");
@@ -95,19 +117,18 @@ export class ID {
95
117
  static readonly z = z.union([z.instanceof(ID), crudeIDZ.transform((v) => new ID(v))]);
96
118
  }
97
119
 
98
- export const Root = new ID({ type: BUILTIN_TYPE, key: "root" });
120
+ export const ROOT_ID = new ID({ type: BUILTIN_TYPE, key: "root" });
99
121
 
100
122
  export const schemaFieldZ = z.object({ type: z.number() });
101
-
102
- export type SchemaField = z.infer<typeof schemaFieldZ>;
123
+ export interface SchemaField extends z.infer<typeof schemaFieldZ> {}
103
124
 
104
125
  export const schemaZ = z.object({
105
126
  type: resourceTypeZ,
106
127
  fields: z.record(schemaFieldZ),
107
128
  });
108
- export type Schema = z.infer<typeof schemaZ>;
129
+ export interface Schema extends z.infer<typeof schemaZ> {}
109
130
 
110
- export const resourceSchemaZ = z
131
+ export const resourceZ = z
111
132
  .object({
112
133
  id: ID.z,
113
134
  name: z.string(),
@@ -115,16 +136,19 @@ export const resourceSchemaZ = z
115
136
  data: z.record(z.unknown()).optional().nullable(),
116
137
  })
117
138
  .transform((resource) => ({ key: resource.id.toString(), ...resource }));
139
+ export interface Resource<T extends UnknownRecord = UnknownRecord>
140
+ extends Omit<z.output<typeof resourceZ>, "data"> {
141
+ data?: T | null;
142
+ }
118
143
 
119
- export type Resource<T extends UnknownRecord = UnknownRecord> = Omit<
120
- z.output<typeof resourceSchemaZ>,
121
- "data"
122
- > & { data?: T | null };
123
-
124
- export type RelationshipDirection = "from" | "to";
144
+ export const TO_RELATIONSHIP_DIRECTION = "to";
145
+ export const FROM_RELATIONSHIP_DIRECTION = "from";
146
+ export type RelationshipDirection =
147
+ | typeof TO_RELATIONSHIP_DIRECTION
148
+ | typeof FROM_RELATIONSHIP_DIRECTION;
125
149
 
126
150
  export const relationshipSchemaZ = z.object({ from: ID.z, type: z.string(), to: ID.z });
127
- export type Relationship = z.infer<typeof relationshipSchemaZ>;
151
+ export interface Relationship extends z.infer<typeof relationshipSchemaZ> {}
128
152
 
129
153
  export const parseRelationship = (str: string): Relationship => {
130
154
  const [from, type, to] = str.split("->");
@@ -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.
@@ -12,22 +12,15 @@ import { z } from "zod";
12
12
 
13
13
  import { type CrudeID, ID, idZ } from "@/ontology/payload";
14
14
 
15
- const ENDPOINTS = {
16
- ADD_CHILDREN: "/ontology/add-children",
17
- REMOVE_CHILDREN: "/ontology/remove-children",
18
- MOVE_CHILDREN: "/ontology/move-children",
19
- };
15
+ const ADD_CHILDREN_ENDPOINT = "/ontology/add-children";
16
+ const REMOVE_CHILDREN_ENDPOINT = "/ontology/remove-children";
17
+ const MOVE_CHILDREN_ENDPOINT = "/ontology/move-children";
20
18
 
21
- const addRemoveChildrenReqZ = z.object({
22
- id: idZ,
23
- children: idZ.array(),
24
- });
19
+ const addRemoveChildrenReqZ = z.object({ id: idZ, children: idZ.array() });
25
20
 
26
- const moveChildrenReqZ = z.object({
27
- from: idZ,
28
- to: idZ,
29
- children: idZ.array(),
30
- });
21
+ const moveChildrenReqZ = z.object({ from: idZ, to: idZ, children: idZ.array() });
22
+
23
+ const emptyResZ = z.object({});
31
24
 
32
25
  export class Writer {
33
26
  client: UnaryClient;
@@ -37,22 +30,22 @@ export class Writer {
37
30
  }
38
31
 
39
32
  async addChildren(id: CrudeID, ...children: CrudeID[]): Promise<void> {
40
- await sendRequired<typeof addRemoveChildrenReqZ, z.ZodTypeAny>(
33
+ await sendRequired<typeof addRemoveChildrenReqZ, typeof emptyResZ>(
41
34
  this.client,
42
- ENDPOINTS.ADD_CHILDREN,
35
+ ADD_CHILDREN_ENDPOINT,
43
36
  { id: new ID(id).payload, children: children.map((c) => new ID(c).payload) },
44
37
  addRemoveChildrenReqZ,
45
- z.object({}),
38
+ emptyResZ,
46
39
  );
47
40
  }
48
41
 
49
42
  async removeChildren(id: CrudeID, ...children: CrudeID[]): Promise<void> {
50
- await sendRequired<typeof addRemoveChildrenReqZ, z.ZodTypeAny>(
43
+ await sendRequired<typeof addRemoveChildrenReqZ, typeof emptyResZ>(
51
44
  this.client,
52
- ENDPOINTS.REMOVE_CHILDREN,
45
+ REMOVE_CHILDREN_ENDPOINT,
53
46
  { id: new ID(id).payload, children: children.map((c) => new ID(c).payload) },
54
47
  addRemoveChildrenReqZ,
55
- z.object({}),
48
+ emptyResZ,
56
49
  );
57
50
  }
58
51
 
@@ -66,12 +59,12 @@ export class Writer {
66
59
  to: new ID(to).payload,
67
60
  children: children.map((c) => new ID(c).payload),
68
61
  };
69
- await sendRequired(
62
+ await sendRequired<typeof moveChildrenReqZ, typeof emptyResZ>(
70
63
  this.client,
71
- ENDPOINTS.MOVE_CHILDREN,
64
+ MOVE_CHILDREN_ENDPOINT,
72
65
  req,
73
66
  moveChildrenReqZ,
74
- z.object({}),
67
+ emptyResZ,
75
68
  );
76
69
  }
77
70
  }
@@ -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.
@@ -11,73 +11,60 @@ import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { type change } from "@synnaxlabs/x/change";
12
12
  import { z } from "zod";
13
13
 
14
- import { type channel } from "@/channel";
15
- import { type Key as ChannelKey, keyZ as channelKeyZ } from "@/channel/payload";
16
- import { type Client as FrameClient } from "@/framer/client";
14
+ import { channel } from "@/channel";
15
+ import { type framer } from "@/framer";
17
16
  import { type Key, keyZ } from "@/ranger/payload";
18
17
  import { signals } from "@/signals";
19
18
 
20
- export const ALIAS_SET_NAME = "sy_range_alias_set";
21
- export const ALIAS_DELETE_NAME = "sy_range_alias_delete";
19
+ export const SET_ALIAS_CHANNEL_NAME = "sy_range_alias_set";
20
+ export const DELETE_ALIAS_CHANNEL_NAME = "sy_range_alias_delete";
22
21
 
23
- const resolveReqZ = z.object({
24
- range: keyZ,
25
- aliases: z.string().array(),
26
- });
22
+ const resolveReqZ = z.object({ range: keyZ, aliases: z.string().array() });
27
23
 
28
- const resolveResZ = z.object({
29
- aliases: z.record(z.string(), channelKeyZ),
30
- });
24
+ const resolveResZ = z.object({ aliases: z.record(z.string(), channel.keyZ) });
31
25
 
32
26
  const setReqZ = z.object({
33
27
  range: keyZ,
34
- aliases: z.record(channelKeyZ.or(z.string()), z.string()),
28
+ aliases: z.record(channel.keyZ.or(z.string()), z.string()),
35
29
  });
36
30
 
37
31
  const setResZ = z.unknown();
38
32
 
39
- const deleteReqZ = z.object({
40
- range: keyZ,
41
- channels: channelKeyZ.array(),
42
- });
33
+ const deleteReqZ = z.object({ range: keyZ, channels: channel.keyZ.array() });
43
34
 
44
35
  const deleteResZ = z.unknown();
45
36
 
46
- const listReqZ = z.object({
47
- range: keyZ,
48
- });
37
+ const listReqZ = z.object({ range: keyZ });
49
38
 
50
- const listResZ = z.object({
51
- aliases: z.record(z.string(), z.string()),
52
- });
39
+ const listResZ = z.object({ aliases: z.record(z.string(), z.string()) });
53
40
 
54
41
  export class Aliaser {
55
42
  private static readonly SET_ENDPOINT = "/range/alias/set";
56
43
  private static readonly RESOLVE_ENDPOINT = "/range/alias/resolve";
57
44
  private static readonly LIST_ENDPOINT = "/range/alias/list";
58
45
  private static readonly DELETE_ENDPOINT = "/range/alias/delete";
59
- private readonly frameClient: FrameClient;
60
- private readonly cache = new Map<string, ChannelKey>();
46
+ private readonly frameClient: framer.Client;
47
+ private readonly cache = new Map<string, channel.Key>();
61
48
  private readonly client: UnaryClient;
62
49
  private readonly rangeKey: Key;
63
50
 
64
- constructor(rangeKey: Key, frameClient: FrameClient, client: UnaryClient) {
51
+ constructor(rangeKey: Key, frameClient: framer.Client, client: UnaryClient) {
65
52
  this.rangeKey = rangeKey;
66
53
  this.cache = new Map();
67
54
  this.client = client;
68
55
  this.frameClient = frameClient;
69
56
  }
70
57
 
71
- resolve(aliases: string): Promise<ChannelKey>;
58
+ resolve(aliases: string): Promise<channel.Key>;
72
59
 
73
- resolve(aliases: string[]): Promise<Record<string, ChannelKey>>;
60
+ resolve(aliases: string[]): Promise<Record<string, channel.Key>>;
74
61
 
75
62
  async resolve(
76
63
  aliases: string | string[],
77
- ): Promise<ChannelKey | Record<string, ChannelKey>> {
64
+ ): Promise<channel.Key | Record<string, channel.Key>> {
78
65
  const toFetch: string[] = [];
79
66
  const isSingle = typeof aliases === "string";
80
- const cached: Record<string, ChannelKey> = {};
67
+ const cached: Record<string, channel.Key> = {};
81
68
  if (isSingle) {
82
69
  const c = this.cache.get(aliases);
83
70
  if (c != null) return c;
@@ -100,7 +87,7 @@ export class Aliaser {
100
87
  return isSingle ? res.aliases[toFetch[0]] : { ...cached, ...res.aliases };
101
88
  }
102
89
 
103
- async set(aliases: Record<ChannelKey, string>): Promise<void> {
90
+ async set(aliases: Record<channel.Key, string>): Promise<void> {
104
91
  await sendRequired<typeof setReqZ, typeof setResZ>(
105
92
  this.client,
106
93
  Aliaser.SET_ENDPOINT,
@@ -110,7 +97,7 @@ export class Aliaser {
110
97
  );
111
98
  }
112
99
 
113
- async list(): Promise<Record<ChannelKey, string>> {
100
+ async list(): Promise<Record<channel.Key, string>> {
114
101
  return (
115
102
  await sendRequired<typeof listReqZ, typeof listResZ>(
116
103
  this.client,
@@ -122,7 +109,7 @@ export class Aliaser {
122
109
  ).aliases;
123
110
  }
124
111
 
125
- async delete(aliases: ChannelKey[]): Promise<void> {
112
+ async delete(aliases: channel.Key[]): Promise<void> {
126
113
  await sendRequired<typeof deleteReqZ, typeof deleteResZ>(
127
114
  this.client,
128
115
  Aliaser.DELETE_ENDPOINT,
@@ -135,8 +122,8 @@ export class Aliaser {
135
122
  async openChangeTracker(): Promise<signals.Observable<string, Alias>> {
136
123
  return await signals.openObservable<string, Alias>(
137
124
  this.frameClient,
138
- ALIAS_SET_NAME,
139
- ALIAS_DELETE_NAME,
125
+ SET_ALIAS_CHANNEL_NAME,
126
+ DELETE_ALIAS_CHANNEL_NAME,
140
127
  decodeAliasChanges(this.rangeKey),
141
128
  );
142
129
  }
@@ -150,13 +137,9 @@ export interface Alias {
150
137
 
151
138
  export type AliasChange = change.Change<string, Alias>;
152
139
 
153
- const aliasZ = z.object({
154
- range: keyZ,
155
- channel: channelKeyZ,
156
- alias: z.string(),
157
- });
140
+ const aliasZ = z.object({ range: keyZ, channel: channel.keyZ, alias: z.string() });
158
141
 
159
- const aliasSeparator = "---";
142
+ const separator = "---";
160
143
 
161
144
  const decodeAliasChanges =
162
145
  (rangeKey: Key): signals.Decoder<string, Alias> =>
@@ -164,7 +147,7 @@ const decodeAliasChanges =
164
147
  if (variant === "delete")
165
148
  return data
166
149
  .toStrings()
167
- .filter((k) => k.split(aliasSeparator)[0] === rangeKey)
150
+ .filter((k) => k.split(separator)[0] === rangeKey)
168
151
  .map((alias) => ({
169
152
  variant,
170
153
  key: alias,
@@ -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.
@@ -14,25 +14,23 @@ import { type Series } from "@synnaxlabs/x/telem";
14
14
  import { toArray } from "@synnaxlabs/x/toArray";
15
15
  import { z } from "zod";
16
16
 
17
- import { type Key as ChannelKey } from "@/channel/payload";
18
- import { type Retriever as ChannelRetriever } from "@/channel/retriever";
17
+ import { type channel } from "@/channel";
19
18
  import { MultipleFoundError, NotFoundError, QueryError } from "@/errors";
20
19
  import { type framer } from "@/framer";
21
20
  import { type label } from "@/label";
22
- import { type Label } from "@/label/payload";
23
- import { type ontology } from "@/ontology";
24
- import { type Resource } from "@/ontology/payload";
21
+ import { ontology } from "@/ontology";
25
22
  import { type Alias, Aliaser } from "@/ranger/alias";
26
23
  import { KV } from "@/ranger/kv";
27
24
  import {
25
+ ALIAS_ONTOLOGY_TYPE,
28
26
  analyzeParams,
29
27
  type Key,
30
28
  type Keys,
31
29
  keyZ,
32
30
  type Name,
33
31
  type Names,
34
- type NewPayload,
35
- ontologyID,
32
+ type New,
33
+ ONTOLOGY_TYPE,
36
34
  type Params,
37
35
  type Payload,
38
36
  payloadZ,
@@ -47,7 +45,7 @@ export class Range {
47
45
  readonly kv: KV;
48
46
  readonly timeRange: TimeRange;
49
47
  readonly color: string | undefined;
50
- readonly channels: ChannelRetriever;
48
+ readonly channels: channel.Retriever;
51
49
  private readonly aliaser: Aliaser;
52
50
  private readonly frameClient: framer.Client;
53
51
  private readonly labelClient: label.Client;
@@ -62,7 +60,7 @@ export class Range {
62
60
  _frameClient: framer.Client,
63
61
  _kv: KV,
64
62
  _aliaser: Aliaser,
65
- _channels: ChannelRetriever,
63
+ _channels: channel.Retriever,
66
64
  _labelClient: label.Client,
67
65
  _ontologyClient: ontology.Client,
68
66
  _rangeClient: Client,
@@ -93,22 +91,21 @@ export class Range {
93
91
  };
94
92
  }
95
93
 
96
- async setAlias(channel: ChannelKey | Name, alias: string): Promise<void> {
94
+ async setAlias(channel: channel.Key | Name, alias: string): Promise<void> {
97
95
  const ch = await this.channels.retrieve(channel);
98
96
  if (ch.length === 0) throw new QueryError(`Channel ${channel} does not exist`);
99
-
100
97
  await this.aliaser.set({ [ch[0].key]: alias });
101
98
  }
102
99
 
103
- async deleteAlias(...channels: ChannelKey[]): Promise<void> {
100
+ async deleteAlias(...channels: channel.Key[]): Promise<void> {
104
101
  await this.aliaser.delete(channels);
105
102
  }
106
103
 
107
- async listAliases(): Promise<Record<ChannelKey, string>> {
104
+ async listAliases(): Promise<Record<channel.Key, string>> {
108
105
  return await this.aliaser.list();
109
106
  }
110
107
 
111
- async resolveAlias(alias: string): Promise<ChannelKey> {
108
+ async resolveAlias(alias: string): Promise<channel.Key> {
112
109
  return await this.aliaser.resolve(alias);
113
110
  }
114
111
 
@@ -131,14 +128,12 @@ export class Range {
131
128
  }
132
129
 
133
130
  async read(channel: Key | Name): Promise<Series>;
134
-
135
131
  async read(channels: Params): Promise<framer.Frame>;
136
-
137
132
  async read(channels: Params): Promise<Series | framer.Frame> {
138
133
  return await this.frameClient.read(this.timeRange, channels);
139
134
  }
140
135
 
141
- async labels(): Promise<Label[]> {
136
+ async labels(): Promise<label.Label[]> {
142
137
  return await this.labelClient.retrieveFor(ontologyID(this.key));
143
138
  }
144
139
 
@@ -161,7 +156,7 @@ export class Range {
161
156
  dependents: initial,
162
157
  resourceType: "range",
163
158
  });
164
- base.onChange((r: Resource[]) =>
159
+ base.onChange((r: ontology.Resource[]) =>
165
160
  wrapper.notify(this.rangeClient.resourcesToRanges(r)),
166
161
  );
167
162
  wrapper.setCloser(async () => await base.close());
@@ -179,7 +174,7 @@ export class Range {
179
174
  dependents: [resourceP],
180
175
  relationshipDirection: "to",
181
176
  });
182
- base.onChange((resources: Resource[]) => {
177
+ base.onChange((resources: ontology.Resource[]) => {
183
178
  const ranges = this.rangeClient.resourcesToRanges(resources);
184
179
  if (ranges.length === 0) return;
185
180
  const p = ranges[0];
@@ -202,20 +197,18 @@ const retrieveReqZ = z.object({
202
197
  offset: z.number().int().optional(),
203
198
  });
204
199
 
205
- export type RetrieveRequest = z.infer<typeof retrieveReqZ>;
200
+ export interface RetrieveRequest extends z.infer<typeof retrieveReqZ> {}
206
201
 
207
202
  const RETRIEVE_ENDPOINT = "/range/retrieve";
208
203
 
209
- const retrieveResZ = z.object({
210
- ranges: nullableArrayZ(payloadZ),
211
- });
204
+ const retrieveResZ = z.object({ ranges: nullableArrayZ(payloadZ) });
212
205
 
213
206
  export class Client implements AsyncTermSearcher<string, Key, Range> {
214
207
  readonly type: string = "range";
215
208
  private readonly frameClient: framer.Client;
216
209
  private readonly writer: Writer;
217
210
  private readonly unaryClient: UnaryClient;
218
- private readonly channels: ChannelRetriever;
211
+ private readonly channels: channel.Retriever;
219
212
  private readonly labelClient: label.Client;
220
213
  private readonly ontologyClient: ontology.Client;
221
214
 
@@ -223,7 +216,7 @@ export class Client implements AsyncTermSearcher<string, Key, Range> {
223
216
  frameClient: framer.Client,
224
217
  writer: Writer,
225
218
  unary: UnaryClient,
226
- channels: ChannelRetriever,
219
+ channels: channel.Retriever,
227
220
  labelClient: label.Client,
228
221
  ontologyClient: ontology.Client,
229
222
  ) {
@@ -235,14 +228,9 @@ export class Client implements AsyncTermSearcher<string, Key, Range> {
235
228
  this.ontologyClient = ontologyClient;
236
229
  }
237
230
 
238
- async create(range: NewPayload, options?: CreateOptions): Promise<Range>;
239
-
240
- async create(ranges: NewPayload[], options?: CreateOptions): Promise<Range[]>;
241
-
242
- async create(
243
- ranges: NewPayload | NewPayload[],
244
- options?: CreateOptions,
245
- ): Promise<Range | Range[]> {
231
+ async create(range: New, options?: CreateOptions): Promise<Range>;
232
+ async create(ranges: New[], options?: CreateOptions): Promise<Range[]>;
233
+ async create(ranges: New | New[], options?: CreateOptions): Promise<Range | Range[]> {
246
234
  const single = !Array.isArray(ranges);
247
235
  const res = this.sugarMany(await this.writer.create(toArray(ranges), options));
248
236
  return single ? res[0] : res;
@@ -265,11 +253,8 @@ export class Client implements AsyncTermSearcher<string, Key, Range> {
265
253
  }
266
254
 
267
255
  async retrieve(range: CrudeTimeRange): Promise<Range[]>;
268
-
269
256
  async retrieve(range: Key | Name): Promise<Range>;
270
-
271
257
  async retrieve(range: Keys | Names): Promise<Range[]>;
272
-
273
258
  async retrieve(ranges: Params | CrudeTimeRange): Promise<Range | Range[]> {
274
259
  if (typeof ranges === "object" && "start" in ranges)
275
260
  return await this.execRetrieve({ overlapsWith: new TimeRange(ranges) });
@@ -278,9 +263,11 @@ export class Client implements AsyncTermSearcher<string, Key, Range> {
278
263
  const retrieved = await this.execRetrieve({ [variant]: normalized });
279
264
  if (!single) return retrieved;
280
265
  if (retrieved.length === 0)
281
- throw new NotFoundError(`range matching ${actual} not found`);
266
+ throw new NotFoundError(`range matching ${actual as string} not found`);
282
267
  if (retrieved.length > 1)
283
- throw new MultipleFoundError(`multiple ranges matching ${actual} found`);
268
+ throw new MultipleFoundError(
269
+ `multiple ranges matching ${actual as string} found`,
270
+ );
284
271
  return retrieved[0];
285
272
  }
286
273
 
@@ -341,11 +328,11 @@ export class Client implements AsyncTermSearcher<string, Key, Range> {
341
328
  );
342
329
  }
343
330
 
344
- resourcesToRanges(resources: Resource[]): Range[] {
331
+ resourcesToRanges(resources: ontology.Resource[]): Range[] {
345
332
  return resources.map((r) => this.resourceToRange(r));
346
333
  }
347
334
 
348
- resourceToRange(resource: Resource): Range {
335
+ resourceToRange(resource: ontology.Resource): Range {
349
336
  return this.sugarOne({
350
337
  key: resource.id.key,
351
338
  name: resource.data?.name as string,
@@ -354,3 +341,9 @@ export class Client implements AsyncTermSearcher<string, Key, Range> {
354
341
  });
355
342
  }
356
343
  }
344
+
345
+ export const ontologyID = (key: Key): ontology.ID =>
346
+ new ontology.ID({ type: ONTOLOGY_TYPE, key });
347
+
348
+ export const aliasOntologyID = (key: Key): ontology.ID =>
349
+ new ontology.ID({ type: ALIAS_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.
@@ -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
- export type { Alias, AliasChange } from "@/ranger/alias";
10
+ export { type Alias, type AliasChange } from "@/ranger/alias";
11
11
  export * from "@/ranger/client";
12
12
  export * from "@/ranger/kv";
13
13
  export * from "@/ranger/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.