@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
package/src/ranger/kv.ts CHANGED
@@ -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.
@@ -17,38 +17,19 @@ import { type Key, keyZ } from "@/ranger/payload";
17
17
  import { signals } from "@/signals";
18
18
  import { nullableArrayZ } from "@/util/zod";
19
19
 
20
- const getReqZ = z.object({
21
- range: keyZ,
22
- keys: z.string().array(),
23
- });
20
+ const kvPairZ = z.object({ range: keyZ, key: z.string(), value: z.string() });
21
+ export interface KVPair extends z.infer<typeof kvPairZ> {}
24
22
 
25
- const kvPairZ = z.object({
26
- range: keyZ,
27
- key: z.string(),
28
- value: z.string(),
29
- });
23
+ const getReqZ = z.object({ range: keyZ, keys: z.string().array() });
24
+ export interface GetRequest extends z.infer<typeof getReqZ> {}
30
25
 
31
- const getResZ = z.object({
32
- pairs: nullableArrayZ(kvPairZ),
33
- });
26
+ const getResZ = z.object({ pairs: nullableArrayZ(kvPairZ) });
34
27
 
35
- export type GetRequest = z.infer<typeof getReqZ>;
28
+ const setReqZ = z.object({ range: keyZ, pairs: kvPairZ.array() });
29
+ export interface SetRequest extends z.infer<typeof setReqZ> {}
36
30
 
37
- const setReqZ = z.object({
38
- range: keyZ,
39
- pairs: kvPairZ.array(),
40
- });
41
-
42
- export type SetRequest = z.infer<typeof setReqZ>;
43
-
44
- const deleteReqZ = z.object({
45
- range: keyZ,
46
- keys: z.string().array(),
47
- });
48
-
49
- export type DeleteRequest = z.infer<typeof deleteReqZ>;
50
-
51
- export type KVPair = z.infer<typeof kvPairZ>;
31
+ const deleteReqZ = z.object({ range: keyZ, keys: z.string().array() });
32
+ export interface DeleteRequest extends z.infer<typeof deleteReqZ> {}
52
33
 
53
34
  export class KV {
54
35
  private static readonly GET_ENDPOINT = "/range/kv/get";
@@ -65,9 +46,7 @@ export class KV {
65
46
  }
66
47
 
67
48
  async get(key: string): Promise<string>;
68
-
69
49
  async get(keys: string[]): Promise<Record<string, string>>;
70
-
71
50
  async get(keys: string | string[]): Promise<string | Record<string, string>> {
72
51
  const res = await sendRequired(
73
52
  this.client,
@@ -85,9 +64,7 @@ export class KV {
85
64
  }
86
65
 
87
66
  async set(key: string, value: string): Promise<void>;
88
-
89
67
  async set(kv: Record<string, string>): Promise<void>;
90
-
91
68
  async set(key: string | Record<string, string>, value: string = ""): Promise<void> {
92
69
  let pairs: KVPair[];
93
70
  if (isObject(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.
@@ -11,48 +11,29 @@ import { TimeRange } from "@synnaxlabs/x/telem";
11
11
  import { toArray } from "@synnaxlabs/x/toArray";
12
12
  import { z } from "zod";
13
13
 
14
- import { ontology } from "@/ontology";
15
-
16
14
  export const keyZ = z.string().uuid();
17
15
  export type Key = z.infer<typeof keyZ>;
18
- export type Name = string;
16
+ export const nameZ = z.string().min(1);
17
+ export type Name = z.infer<typeof nameZ>;
19
18
  export type Keys = Key[];
20
19
  export type Names = Name[];
21
20
  export type Params = Key | Name | Keys | Names;
22
21
 
23
22
  export const payloadZ = z.object({
24
23
  key: keyZ,
25
- name: z.string().min(1),
24
+ name: nameZ,
26
25
  timeRange: TimeRange.z,
27
26
  color: z.string().optional(),
28
27
  });
29
- export type Payload = z.infer<typeof payloadZ>;
28
+ export interface Payload extends z.infer<typeof payloadZ> {}
30
29
 
31
- export const newPayloadZ = payloadZ.extend({ key: z.string().uuid().optional() });
32
- export type NewPayload = z.input<typeof newPayloadZ>;
30
+ export const newZ = payloadZ.partial({ key: true });
31
+ export interface New extends z.input<typeof newZ> {}
33
32
 
34
33
  export type ParamAnalysisResult =
35
- | {
36
- single: true;
37
- variant: "keys";
38
- normalized: Keys;
39
- actual: Key;
40
- empty: never;
41
- }
42
- | {
43
- single: true;
44
- variant: "names";
45
- normalized: Names;
46
- actual: Name;
47
- empty: never;
48
- }
49
- | {
50
- single: false;
51
- variant: "keys";
52
- normalized: Keys;
53
- actual: Keys;
54
- empty: boolean;
55
- }
34
+ | { single: true; variant: "keys"; normalized: Keys; actual: Key; empty: never }
35
+ | { single: true; variant: "names"; normalized: Names; actual: Name; empty: never }
36
+ | { single: false; variant: "keys"; normalized: Keys; actual: Keys; empty: boolean }
56
37
  | {
57
38
  single: false;
58
39
  variant: "names";
@@ -72,14 +53,11 @@ export const analyzeParams = (ranges: Params): ParamAnalysisResult => {
72
53
  normalized: normal,
73
54
  actual: ranges,
74
55
  empty,
75
- } as const as ParamAnalysisResult;
56
+ } as ParamAnalysisResult;
76
57
  };
77
58
 
78
- export const ONTOLOGY_TYPE: ontology.ResourceType = "range";
79
- export const ALIAS_ONTOLOGY_TYPE: ontology.ResourceType = "range-alias";
80
-
81
- export const ontologyID = (key: Key): ontology.ID =>
82
- new ontology.ID({ type: ONTOLOGY_TYPE, key });
59
+ export const ONTOLOGY_TYPE = "range";
60
+ export type OntologyType = typeof ONTOLOGY_TYPE;
83
61
 
84
- export const aliasOntologyID = (key: Key): ontology.ID =>
85
- new ontology.ID({ type: ALIAS_ONTOLOGY_TYPE, key });
62
+ export const ALIAS_ONTOLOGY_TYPE = "range-alias";
63
+ export type AliasOntologyType = typeof ALIAS_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.
@@ -13,7 +13,6 @@ import { describe, expect, it } from "vitest";
13
13
 
14
14
  import { QueryError } from "@/errors";
15
15
  import { type ranger } from "@/ranger";
16
- import { type NewPayload } from "@/ranger/payload";
17
16
  import { newClient } from "@/setupspecs";
18
17
 
19
18
  const client = newClient();
@@ -32,7 +31,7 @@ describe("Ranger", () => {
32
31
  expect(range.color).toEqual("#E774D0");
33
32
  });
34
33
  it("should create multiple ranges", async () => {
35
- const ranges: NewPayload[] = [
34
+ const ranges: ranger.New[] = [
36
35
  {
37
36
  name: "My New One Second Range",
38
37
  timeRange: TimeStamp.now().spanRange(TimeSpan.seconds(1)),
@@ -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,37 +11,19 @@ import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { z } from "zod";
12
12
 
13
13
  import { ontology } from "@/ontology";
14
- import {
15
- keyZ,
16
- type NewPayload,
17
- newPayloadZ,
18
- type Payload,
19
- payloadZ,
20
- } from "@/ranger/payload";
14
+ import { keyZ, nameZ, type New, newZ, type Payload, payloadZ } from "@/ranger/payload";
21
15
 
22
- const createResZ = z.object({
23
- ranges: payloadZ.array(),
24
- });
16
+ const createResZ = z.object({ ranges: payloadZ.array() });
25
17
 
26
- const createReqZ = z.object({
27
- parent: ontology.idZ.optional(),
28
- ranges: newPayloadZ.array(),
29
- });
18
+ const createReqZ = z.object({ parent: ontology.idZ.optional(), ranges: newZ.array() });
30
19
 
31
- type CreateRequest = z.infer<typeof createReqZ>;
32
- export type CreateOptions = Pick<CreateRequest, "parent">;
33
-
34
- const deleteReqZ = z.object({
35
- keys: keyZ.array(),
36
- });
20
+ interface CreateRequest extends z.infer<typeof createReqZ> {}
21
+ export interface CreateOptions extends Pick<CreateRequest, "parent"> {}
37
22
 
23
+ const deleteReqZ = z.object({ keys: keyZ.array() });
38
24
  const deleteResZ = z.object({});
39
25
 
40
- const renameReqZ = z.object({
41
- key: keyZ,
42
- name: z.string(),
43
- });
44
-
26
+ const renameReqZ = z.object({ key: keyZ, name: nameZ });
45
27
  const renameResZ = z.object({});
46
28
 
47
29
  const CREATE_ENDPOINT = "/range/create";
@@ -65,7 +47,7 @@ export class Writer {
65
47
  );
66
48
  }
67
49
 
68
- async create(ranges: NewPayload[], options?: CreateOptions): Promise<Payload[]> {
50
+ async create(ranges: New[], options?: CreateOptions): Promise<Payload[]> {
69
51
  const res = await sendRequired<typeof createReqZ, typeof createResZ>(
70
52
  this.client,
71
53
  CREATE_ENDPOINT,
package/src/setupspecs.ts CHANGED
@@ -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.
@@ -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.
@@ -14,10 +14,9 @@ import { type Series } from "@synnaxlabs/x/telem";
14
14
  import { type channel } from "@/channel";
15
15
  import { framer } from "@/framer";
16
16
 
17
- export type Decoder<K, V> = (
18
- variant: change.Variant,
19
- data: Series,
20
- ) => Array<change.Change<K, V>>;
17
+ export interface Decoder<K, V> {
18
+ (variant: change.Variant, data: Series): Array<change.Change<K, V>>;
19
+ }
21
20
 
22
21
  export interface Observable<K, V>
23
22
  extends observe.ObservableAsyncCloseable<Array<change.Change<K, V>>> {}
package/src/transport.ts CHANGED
@@ -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.
@@ -11,7 +11,8 @@ import { type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { toArray } from "@synnaxlabs/x";
12
12
 
13
13
  import { MultipleFoundError, NotFoundError } from "@/errors";
14
- import { type Key, type NewUser, type User } from "@/user/payload";
14
+ import { ontology } from "@/ontology";
15
+ import { type Key, type New, ONTOLOGY_TYPE, type User } from "@/user/payload";
15
16
  import { Retriever } from "@/user/retriever";
16
17
  import { Writer } from "@/user/writer";
17
18
 
@@ -24,11 +25,11 @@ export class Client {
24
25
  this.reader = new Retriever(client);
25
26
  }
26
27
 
27
- async create(user: NewUser): Promise<User>;
28
+ async create(user: New): Promise<User>;
28
29
 
29
- async create(users: NewUser[]): Promise<User[]>;
30
+ async create(users: New[]): Promise<User[]>;
30
31
 
31
- async create(users: NewUser | NewUser[]): Promise<User | User[]> {
32
+ async create(users: New | New[]): Promise<User | User[]> {
32
33
  const isMany = Array.isArray(users);
33
34
  const res = await this.writer.create(users);
34
35
  return isMany ? res : res[0];
@@ -79,3 +80,6 @@ export class Client {
79
80
  await this.writer.delete(keys);
80
81
  }
81
82
  }
83
+
84
+ export const ontologyID = (key: Key): ontology.ID =>
85
+ new ontology.ID({ 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.
package/src/user/index.ts CHANGED
@@ -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,8 +9,6 @@
9
9
 
10
10
  import { z } from "zod";
11
11
 
12
- import { ontology } from "@/ontology";
13
-
14
12
  export const keyZ = z.string().uuid();
15
13
  export type Key = z.infer<typeof keyZ>;
16
14
 
@@ -24,15 +22,13 @@ export const userZ = z.object({
24
22
  lastName: z.string().default(""),
25
23
  rootUser: z.boolean().default(true),
26
24
  });
27
- export type User = z.infer<typeof userZ>;
25
+ export interface User extends z.infer<typeof userZ> {}
28
26
 
29
- export const newUserZ = userZ
27
+ export const newZ = userZ
30
28
  .partial({ key: true, firstName: true, lastName: true })
31
29
  .omit({ rootUser: true })
32
30
  .extend({ password: z.string().min(1) });
33
- export type NewUser = z.infer<typeof newUserZ>;
34
-
35
- export const ONTOLOGY_TYPE: ontology.ResourceType = "user";
31
+ export interface New extends z.infer<typeof newZ> {}
36
32
 
37
- export const ontologyID = (key: Key): ontology.ID =>
38
- new ontology.ID({ type: ONTOLOGY_TYPE, key });
33
+ export const ONTOLOGY_TYPE = "user";
34
+ 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.
@@ -17,7 +17,7 @@ const reqZ = z.object({
17
17
  keys: keyZ.array().optional(),
18
18
  usernames: z.string().array().optional(),
19
19
  });
20
- type Request = z.infer<typeof reqZ>;
20
+ interface Request extends z.infer<typeof reqZ> {}
21
21
  const resZ = z.object({ users: nullableArrayZ(userZ) });
22
22
  const ENDPOINT = "/user/retrieve";
23
23
 
@@ -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,31 +14,33 @@ import { AuthError, NotFoundError } from "@/errors";
14
14
  import { newClient } from "@/setupspecs";
15
15
  import { type user } from "@/user";
16
16
 
17
- type SortType = { username: string };
17
+ interface SortType {
18
+ username: string;
19
+ }
18
20
 
19
21
  const sort = (a: SortType, b: SortType) => a.username.localeCompare(b.username);
20
22
 
21
23
  const client = newClient();
22
24
 
23
- const userOne: user.NewUser = {
24
- username: id.id(),
25
+ const userOne: user.New = {
26
+ username: id.create(),
25
27
  password: "test",
26
28
  firstName: "George",
27
29
  lastName: "Washington",
28
30
  };
29
31
 
30
- const userTwo: user.NewUser = { username: id.id(), password: "test" };
32
+ const userTwo: user.New = { username: id.create(), password: "test" };
31
33
 
32
- const userThree: user.NewUser = {
33
- username: id.id(),
34
+ const userThree: user.New = {
35
+ username: id.create(),
34
36
  password: "test",
35
37
  firstName: "John",
36
38
  lastName: "Adams",
37
39
  };
38
40
 
39
- const userArray: user.NewUser[] = [
40
- { username: id.id(), password: "secondTest", firstName: "Steve" },
41
- { username: id.id(), password: "testArray" },
41
+ const userArray: user.New[] = [
42
+ { username: id.create(), password: "secondTest", firstName: "Steve" },
43
+ { username: id.create(), password: "testArray" },
42
44
  ].sort(sort);
43
45
 
44
46
  describe("User", () => {
@@ -107,7 +109,7 @@ describe("User", () => {
107
109
  expect(res.lastName).toEqual(userOne.lastName);
108
110
  });
109
111
  test("not found", async () =>
110
- await expect(client.user.retrieveByName(id.id())).rejects.toThrow(
112
+ await expect(client.user.retrieveByName(id.create())).rejects.toThrow(
111
113
  NotFoundError,
112
114
  ));
113
115
  });
@@ -125,13 +127,13 @@ describe("User", () => {
125
127
  });
126
128
  });
127
129
  test("not found", async () => {
128
- const res = await client.user.retrieveByName([id.id()]);
130
+ const res = await client.user.retrieveByName([id.create()]);
129
131
  expect(res).toEqual([]);
130
132
  });
131
133
  test("extra names getting deleted", async () => {
132
134
  const res = await client.user.retrieveByName([
133
135
  ...userArray.map((u) => u.username),
134
- id.id(),
136
+ id.create(),
135
137
  ]);
136
138
  expect(res.sort(sort)).toHaveLength(2);
137
139
  res.forEach((u, i) => {
@@ -205,7 +207,7 @@ describe("User", () => {
205
207
  });
206
208
  describe("Change Username", () => {
207
209
  test("Successful", async () => {
208
- const newUsername = id.id();
210
+ const newUsername = id.create();
209
211
  await expect(
210
212
  client.user.changeUsername(userOne.key as string, newUsername),
211
213
  ).resolves.toBeUndefined();
@@ -221,12 +223,12 @@ describe("User", () => {
221
223
  client.user.changeUsername(userTwo.key as string, userOne.username),
222
224
  ).rejects.toThrow(AuthError));
223
225
  test("Repeated usernames fail", async () => {
224
- const oldUsername = id.id();
226
+ const oldUsername = id.create();
225
227
  const user = await client.user.create({
226
228
  username: oldUsername,
227
229
  password: "test",
228
230
  });
229
- const newUsername = id.id();
231
+ const newUsername = id.create();
230
232
  await client.user.changeUsername(user.key, newUsername);
231
233
  await expect(
232
234
  client.user.create({ username: newUsername, password: "test" }),
@@ -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,16 +11,9 @@ import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { toArray } from "@synnaxlabs/x/toArray";
12
12
  import { z } from "zod";
13
13
 
14
- import {
15
- type Key,
16
- keyZ,
17
- type NewUser,
18
- newUserZ,
19
- type User,
20
- userZ,
21
- } from "@/user/payload";
14
+ import { type Key, keyZ, type New, newZ, type User, userZ } from "@/user/payload";
22
15
 
23
- const createReqZ = z.object({ users: newUserZ.array() });
16
+ const createReqZ = z.object({ users: newZ.array() });
24
17
  const createResZ = z.object({ users: userZ.array() });
25
18
 
26
19
  const changeUsernameReqZ = z.object({ key: keyZ, username: z.string().min(1) });
@@ -48,7 +41,7 @@ export class Writer {
48
41
  this.client = client;
49
42
  }
50
43
 
51
- async create(users: NewUser | NewUser[]): Promise<User[]> {
44
+ async create(users: New | New[]): Promise<User[]> {
52
45
  const res = await sendRequired<typeof createReqZ, typeof createResZ>(
53
46
  this.client,
54
47
  CREATE_ENDPOINT,
@@ -0,0 +1,13 @@
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 { binary, type UnknownRecord } from "@synnaxlabs/x";
11
+
12
+ export const decodeJSONString = (s: string): UnknownRecord =>
13
+ s ? binary.JSON_CODEC.decodeString(s) : {};
@@ -0,0 +1,19 @@
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 { type UnknownRecord } from "@synnaxlabs/x/record";
11
+
12
+ // --- VERY IMPORTANT ---
13
+ // Synnax's encoders (in the binary package inside x) automatically convert the case of
14
+ // keys in objects to snake_case and back to camelCase when encoding and decoding
15
+ // respectively. This is done to ensure that the keys are consistent across all
16
+ // languages and platforms. Sometimes items have keys that are uuids, which have dashes,
17
+ // and those get messed up. So we just use regular JSON for these items.
18
+ export const parseWithoutKeyConversion = (s: string): UnknownRecord =>
19
+ s ? JSON.parse(s) : {};
@@ -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
  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
 
@@ -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.
@@ -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
@@ -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,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/util/zod.ts CHANGED
@@ -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.
package/src/vite-env.d.ts CHANGED
@@ -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,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;