@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,25 +10,25 @@
10
10
  import { DataType, Rate } from "@synnaxlabs/x/telem";
11
11
  import { z } from "zod";
12
12
 
13
- import { ontology } from "@/ontology";
14
13
  import { nullableArrayZ } from "@/util/zod";
15
14
 
16
15
  export const keyZ = z.number();
17
- export type Key = number;
18
- export type Keys = number[];
19
- export type Name = string;
20
- export type Names = string[];
16
+ export type Key = z.infer<typeof keyZ>;
17
+ export type Keys = Key[];
18
+ export const nameZ = z.string();
19
+ export type Name = z.infer<typeof nameZ>;
20
+ export type Names = Name[];
21
21
  export type KeyOrName = Key | Name;
22
22
  export type KeysOrNames = Keys | Names;
23
23
  export type Params = Key | Name | Keys | Names;
24
24
 
25
- export const payload = z.object({
26
- name: z.string(),
27
- key: z.number(),
25
+ export const channelZ = z.object({
26
+ name: nameZ,
27
+ key: keyZ,
28
28
  rate: Rate.z,
29
29
  dataType: DataType.z,
30
30
  leaseholder: z.number(),
31
- index: z.number(),
31
+ index: keyZ,
32
32
  isIndex: z.boolean(),
33
33
  internal: z.boolean(),
34
34
  virtual: z.boolean(),
@@ -36,13 +36,12 @@ export const payload = z.object({
36
36
  expression: z.string().default(""),
37
37
  requires: nullableArrayZ(keyZ),
38
38
  });
39
+ export interface Payload extends z.infer<typeof channelZ> {}
39
40
 
40
- export type Payload = z.infer<typeof payload>;
41
-
42
- export const newPayload = payload.extend({
43
- key: z.number().optional(),
41
+ export const newZ = channelZ.extend({
42
+ key: keyZ.optional(),
44
43
  leaseholder: z.number().optional(),
45
- index: z.number().optional(),
44
+ index: keyZ.optional(),
46
45
  rate: Rate.z.optional().default(0),
47
46
  isIndex: z.boolean().optional(),
48
47
  internal: z.boolean().optional().default(false),
@@ -50,10 +49,7 @@ export const newPayload = payload.extend({
50
49
  expression: z.string().optional().default(""),
51
50
  requires: nullableArrayZ(keyZ).optional().default([]),
52
51
  });
52
+ export interface New extends z.input<typeof newZ> {}
53
53
 
54
- export type NewPayload = z.input<typeof newPayload>;
55
-
56
- export const ONTOLOGY_TYPE: ontology.ResourceType = "channel";
57
-
58
- export const ontologyID = (key: Key): ontology.ID =>
59
- new ontology.ID({ type: ONTOLOGY_TYPE, key: key.toString() });
54
+ export const ONTOLOGY_TYPE = "channel";
55
+ 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.
@@ -6,28 +6,33 @@
6
6
  // As of the Change Date specified in that file, in accordance with the Business Source
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
- import type { UnaryClient } from "@synnaxlabs/freighter";
9
+
10
+ import { type UnaryClient } from "@synnaxlabs/freighter";
10
11
  import { debounce } from "@synnaxlabs/x/debounce";
11
12
  import { DataType } from "@synnaxlabs/x/telem";
12
13
  import { Mutex } from "async-mutex";
13
14
  import { z } from "zod";
14
15
 
15
16
  import {
17
+ channelZ,
16
18
  type Key,
17
19
  type KeyOrName,
18
20
  type Keys,
19
21
  type KeysOrNames,
22
+ keyZ,
20
23
  type Params,
21
24
  type Payload,
22
- payload,
23
25
  } from "@/channel/payload";
24
26
  import { QueryError } from "@/errors";
25
- import { analyzeParams, type ParamAnalysisResult } from "@/util/retrieve";
27
+ import {
28
+ analyzeParams as analyzeParameters,
29
+ type ParamAnalysisResult,
30
+ } from "@/util/retrieve";
26
31
  import { nullableArrayZ } from "@/util/zod";
27
32
 
28
33
  const reqZ = z.object({
29
34
  leaseholder: z.number().optional(),
30
- keys: z.number().array().optional(),
35
+ keys: keyZ.array().optional(),
31
36
  names: z.string().array().optional(),
32
37
  search: z.string().optional(),
33
38
  rangeKey: z.string().optional(),
@@ -39,23 +44,17 @@ const reqZ = z.object({
39
44
  isIndex: z.boolean().optional(),
40
45
  internal: z.boolean().optional(),
41
46
  });
47
+ interface Request extends z.input<typeof reqZ> {}
42
48
 
43
- type Request = z.input<typeof reqZ>;
49
+ export interface RetrieveOptions extends Omit<Request, "keys" | "names" | "search"> {}
50
+ export interface PageOptions extends Omit<RetrieveOptions, "offset" | "limit"> {}
44
51
 
45
- export type RetrieveOptions = Omit<Request, "keys" | "names" | "search">;
46
- export type PageOptions = Omit<RetrieveOptions, "offset" | "limit">;
52
+ const resZ = z.object({ channels: nullableArrayZ(channelZ) });
47
53
 
48
- const resZ = z.object({
49
- channels: nullableArrayZ(payload),
50
- });
51
-
52
- export const analyzeChannelParams = (
54
+ export const analyzeParams = (
53
55
  channels: Params,
54
56
  ): ParamAnalysisResult<KeyOrName, { number: "keys"; string: "names" }> =>
55
- analyzeParams(channels, {
56
- number: "keys",
57
- string: "names",
58
- });
57
+ analyzeParameters(channels, { number: "keys", string: "names" });
59
58
 
60
59
  export interface Retriever {
61
60
  retrieve: (channels: Params, opts?: RetrieveOptions) => Promise<Payload[]>;
@@ -76,7 +75,7 @@ export class ClusterRetriever implements Retriever {
76
75
  }
77
76
 
78
77
  async retrieve(channels: Params, options?: RetrieveOptions): Promise<Payload[]> {
79
- const res = analyzeChannelParams(channels);
78
+ const res = analyzeParams(channels);
80
79
  const { variant } = res;
81
80
  let { normalized } = res;
82
81
  if (variant === "keys" && (normalized as Key[]).indexOf(0) !== -1)
@@ -121,7 +120,7 @@ export class CacheRetriever implements Retriever {
121
120
  }
122
121
 
123
122
  async retrieve(channels: Params, options?: RetrieveOptions): Promise<Payload[]> {
124
- const { normalized } = analyzeParams<string | number>(channels, {
123
+ const { normalized } = analyzeParameters<string | number>(channels, {
125
124
  string: "names",
126
125
  number: "keys",
127
126
  });
@@ -139,7 +138,7 @@ export class CacheRetriever implements Retriever {
139
138
  }
140
139
 
141
140
  delete(channels: Params): void {
142
- const { variant, normalized } = analyzeChannelParams(channels);
141
+ const { variant, normalized } = analyzeParams(channels);
143
142
  if (variant === "names")
144
143
  (normalized as string[]).forEach((name) => {
145
144
  const keys = this.namesToKeys.get(name);
@@ -234,7 +233,7 @@ export class DebouncedBatchRetriever implements Retriever {
234
233
  }
235
234
 
236
235
  async retrieve(channels: Params): Promise<Payload[]> {
237
- const { normalized, variant } = analyzeChannelParams(channels);
236
+ const { normalized, variant } = analyzeParams(channels);
238
237
  // Bypass on name fetches for now.
239
238
  if (variant === "names") return await this.wrapped.retrieve(normalized);
240
239
 
@@ -269,7 +268,7 @@ export const retrieveRequired = async (
269
268
  r: Retriever,
270
269
  channels: Params,
271
270
  ): Promise<Payload[]> => {
272
- const { normalized } = analyzeChannelParams(channels);
271
+ const { normalized } = analyzeParams(channels);
273
272
  const results = await r.retrieve(normalized);
274
273
  const notFound: KeyOrName[] = [];
275
274
  normalized.forEach((v) => {
@@ -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,36 +11,34 @@ import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { z } from "zod";
12
12
 
13
13
  import {
14
+ channelZ,
14
15
  type Key,
15
16
  keyZ,
16
- type NewPayload,
17
- newPayload,
17
+ nameZ,
18
+ type New,
19
+ newZ,
18
20
  type Payload,
19
- payload,
20
21
  } from "@/channel/payload";
21
22
  import { type CacheRetriever } from "@/channel/retriever";
22
23
 
23
- const createReqZ = z.object({ channels: newPayload.array() });
24
- const createResZ = z.object({ channels: payload.array() });
24
+ const createReqZ = z.object({ channels: newZ.array() });
25
+ const createResZ = z.object({ channels: channelZ.array() });
25
26
 
26
27
  const deleteReqZ = z.object({
27
28
  keys: keyZ.array().optional(),
28
- names: z.string().array().optional(),
29
+ names: nameZ.array().optional(),
29
30
  });
30
31
  const deleteResZ = z.object({});
31
32
 
32
- const renameReqZ = z.object({
33
- keys: keyZ.array(),
34
- names: z.string().array(),
35
- });
33
+ const renameReqZ = z.object({ keys: keyZ.array(), names: nameZ.array() });
36
34
  const renameResZ = z.object({});
37
35
 
38
36
  const CREATE_ENDPOINT = "/channel/create";
39
37
  const DELETE_ENDPOINT = "/channel/delete";
40
38
  const RENAME_ENDPOINT = "/channel/rename";
41
39
 
42
- export type DeleteProps = z.input<typeof deleteReqZ>;
43
- export type RenameProps = z.input<typeof renameReqZ>;
40
+ export interface DeleteProps extends z.input<typeof deleteReqZ> {}
41
+ export interface RenameProps extends z.input<typeof renameReqZ> {}
44
42
 
45
43
  export class Writer {
46
44
  private readonly client: UnaryClient;
@@ -51,7 +49,7 @@ export class Writer {
51
49
  this.cache = cache;
52
50
  }
53
51
 
54
- async create(channels: NewPayload[]): Promise<Payload[]> {
52
+ async create(channels: New[]): Promise<Payload[]> {
55
53
  const { channels: created } = await sendRequired<
56
54
  typeof createReqZ,
57
55
  typeof createResZ
package/src/client.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.
@@ -31,20 +31,10 @@ import { user } from "@/user";
31
31
  import { workspace } from "@/workspace";
32
32
 
33
33
  export const synnaxPropsZ = z.object({
34
- host: z
35
- .string({
36
- required_error: "Host is required",
37
- })
38
- .min(1, "Host is required"),
34
+ host: z.string({ required_error: "Host is required" }).min(1, "Host is required"),
39
35
  port: z
40
- .number({
41
- required_error: "Port is required",
42
- })
43
- .or(
44
- z.string({
45
- required_error: "Port is required",
46
- }),
47
- ),
36
+ .number({ required_error: "Port is required" })
37
+ .or(z.string({ required_error: "Port is required" })),
48
38
  username: z.string().min(1, "Username is required"),
49
39
  password: z.string().min(1, "Password is required"),
50
40
  connectivityPollFrequency: TimeSpan.z.default(TimeSpan.seconds(30)),
@@ -53,8 +43,8 @@ export const synnaxPropsZ = z.object({
53
43
  retry: breaker.breakerConfig.optional(),
54
44
  });
55
45
 
56
- export type SynnaxProps = z.input<typeof synnaxPropsZ>;
57
- export type ParsedSynnaxProps = z.output<typeof synnaxPropsZ>;
46
+ export interface SynnaxProps extends z.input<typeof synnaxPropsZ> {}
47
+ export interface ParsedSynnaxProps extends z.output<typeof synnaxPropsZ> {}
58
48
 
59
49
  /**
60
50
  * Client to perform operations against a Synnax cluster.
@@ -161,7 +151,7 @@ export default class Synnax extends framer.Client {
161
151
  this.ontology,
162
152
  this.ranges,
163
153
  );
164
- const racks = new rack.Client(this.transport.unary, this, tasks);
154
+ const racks = new rack.Client(this.transport.unary, tasks);
165
155
  this.hardware = new hardware.Client(tasks, racks, devices);
166
156
  }
167
157
 
@@ -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,12 +12,11 @@ import { migrate } from "@synnaxlabs/x";
12
12
  import { TimeSpan } from "@synnaxlabs/x/telem";
13
13
  import { z } from "zod";
14
14
 
15
- const STATUSES = ["disconnected", "connecting", "connected", "failed"] as const;
16
- export const status = z.enum(STATUSES);
17
- export type Status = z.infer<typeof status>;
15
+ export const statusZ = z.enum(["disconnected", "connecting", "connected", "failed"]);
16
+ export type Status = z.infer<typeof statusZ>;
18
17
 
19
- export const state = z.object({
20
- status,
18
+ export const stateZ = z.object({
19
+ status: statusZ,
21
20
  error: z.instanceof(Error).optional(),
22
21
  message: z.string().optional(),
23
22
  clusterKey: z.string(),
@@ -25,8 +24,7 @@ export const state = z.object({
25
24
  clientServerCompatible: z.boolean(),
26
25
  nodeVersion: z.string().optional(),
27
26
  });
28
-
29
- export type State = z.infer<typeof state>;
27
+ export interface State extends z.infer<typeof stateZ> {}
30
28
 
31
29
  const responseZ = z.object({
32
30
  clusterKey: z.string(),
@@ -42,7 +40,7 @@ const DEFAULT: State = {
42
40
  clientVersion: __VERSION__,
43
41
  };
44
42
 
45
- const generateWarning = (
43
+ const createWarning = (
46
44
  nodeVersion: string | null,
47
45
  clientVersion: string,
48
46
  clientIsNewer: boolean,
@@ -64,7 +62,7 @@ export class Checker {
64
62
  private interval?: NodeJS.Timeout;
65
63
  private readonly clientVersion: string;
66
64
  private readonly onChangeHandlers: Array<(state: State) => void> = [];
67
- static readonly connectionStateZ = state;
65
+ static readonly connectionStateZ = stateZ;
68
66
  private versionWarned = false;
69
67
 
70
68
  /**
@@ -112,7 +110,7 @@ export class Checker {
112
110
  if (nodeVersion == null) {
113
111
  this._state.clientServerCompatible = false;
114
112
  if (!warned) {
115
- console.warn(generateWarning(null, clientVersion, true));
113
+ console.warn(createWarning(null, clientVersion, true));
116
114
  this.versionWarned = true;
117
115
  }
118
116
  } else if (
@@ -125,7 +123,7 @@ export class Checker {
125
123
  this._state.clientServerCompatible = false;
126
124
  if (!warned) {
127
125
  console.warn(
128
- generateWarning(
126
+ createWarning(
129
127
  nodeVersion,
130
128
  clientVersion,
131
129
  migrate.semVerNewer(clientVersion, nodeVersion),
@@ -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,7 +12,7 @@ import { describe, expect, it } from "vitest";
12
12
  import { z } from "zod";
13
13
 
14
14
  import { auth } from "@/auth";
15
- import { Checker } from "@/connection/checker";
15
+ import { connection } from "@/connection";
16
16
  import { HOST, PORT } from "@/setupspecs";
17
17
  import { Transport } from "@/transport";
18
18
 
@@ -24,7 +24,11 @@ describe("connectivity", () => {
24
24
  password: "seldon",
25
25
  });
26
26
  transport.use(client.middleware());
27
- const connectivity = new Checker(transport.unary, undefined, __VERSION__);
27
+ const connectivity = new connection.Checker(
28
+ transport.unary,
29
+ undefined,
30
+ __VERSION__,
31
+ );
28
32
  const state = await connectivity.check();
29
33
  expect(state.status).toEqual("connected");
30
34
  expect(z.string().uuid().safeParse(state.clusterKey).success).toBe(true);
@@ -37,7 +41,11 @@ describe("connectivity", () => {
37
41
  password: "seldon",
38
42
  });
39
43
  transport.use(client.middleware());
40
- const connectivity = new Checker(transport.unary, undefined, __VERSION__);
44
+ const connectivity = new connection.Checker(
45
+ transport.unary,
46
+ undefined,
47
+ __VERSION__,
48
+ );
41
49
  const state = await connectivity.check();
42
50
  expect(state.clientServerCompatible).toBe(true);
43
51
  expect(state.clientVersion).toBe(__VERSION__);
@@ -49,7 +57,11 @@ describe("connectivity", () => {
49
57
  password: "seldon",
50
58
  });
51
59
  transport.use(client.middleware());
52
- const connectivity = new Checker(transport.unary, undefined, "50000.0.0");
60
+ const connectivity = new connection.Checker(
61
+ transport.unary,
62
+ undefined,
63
+ "50000.0.0",
64
+ );
53
65
  const state = await connectivity.check();
54
66
  expect(state.clientServerCompatible).toBe(false);
55
67
  expect(state.clientVersion).toBe("50000.0.0");
@@ -61,7 +73,7 @@ describe("connectivity", () => {
61
73
  password: "seldon",
62
74
  });
63
75
  transport.use(client.middleware());
64
- const connectivity = new Checker(transport.unary, undefined, "0.0.0");
76
+ const connectivity = new connection.Checker(transport.unary, undefined, "0.0.0");
65
77
  const state = await connectivity.check();
66
78
  expect(state.clientServerCompatible).toBe(false);
67
79
  expect(state.clientVersion).toBe("0.0.0");
@@ -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.
@@ -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.
@@ -12,15 +12,14 @@ import { binary } from "@synnaxlabs/x/binary";
12
12
  import { type observe } from "@synnaxlabs/x/observe";
13
13
  import { z } from "zod";
14
14
 
15
- import { type Key as ChannelKey } from "@/channel/payload";
15
+ import { type channel } from "@/channel";
16
16
  import { framer } from "@/framer";
17
- import { type Streamer as FrameStreamer } from "@/framer/streamer";
18
17
 
19
- export type Authority = control.Authority;
18
+ export interface Authority extends control.Authority {}
20
19
  export const Authority = control.Authority;
21
- export type Transfer = control.Transfer<ChannelKey>;
22
- export type State = control.State<ChannelKey>;
23
- export type Subject = control.Subject;
20
+ export type Transfer = control.Transfer<channel.Key>;
21
+ export interface State extends control.State<channel.Key> {}
22
+ export interface Subject extends control.Subject {}
24
23
  export const stateZ = control.stateZ(z.number());
25
24
 
26
25
  export const transferString = (t: Transfer): string => {
@@ -35,17 +34,17 @@ export const transferString = (t: Transfer): string => {
35
34
  };
36
35
 
37
36
  interface Update {
38
- transfers: control.Transfer<ChannelKey>[];
37
+ transfers: control.Transfer<channel.Key>[];
39
38
  }
40
39
 
41
40
  export class StateTracker
42
41
  extends framer.ObservableStreamer<Transfer[]>
43
42
  implements observe.ObservableAsyncCloseable<Transfer[]>
44
43
  {
45
- readonly states: Map<ChannelKey, State>;
44
+ readonly states: Map<channel.Key, State>;
46
45
  private readonly codec: binary.Codec;
47
46
 
48
- constructor(streamer: FrameStreamer) {
47
+ constructor(streamer: framer.Streamer) {
49
48
  super(streamer, (frame) => {
50
49
  const update: Update = this.codec.decode(frame.series[0].buffer);
51
50
  this.merge(update);
@@ -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.
@@ -55,7 +55,7 @@ const client = newClient();
55
55
  test("client", async () => {
56
56
  expect.assertions(2);
57
57
  try {
58
- await client.channels.retrieve(id.id());
58
+ await client.channels.retrieve(id.create());
59
59
  } catch (e) {
60
60
  expect(NotFoundError.matches(e)).toBe(true);
61
61
  }
package/src/errors.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.
@@ -64,6 +64,12 @@ export class InvalidTokenError extends AuthError {
64
64
  static readonly matches = errorMatcher(InvalidTokenError.TYPE);
65
65
  }
66
66
 
67
+ export class ExpiredTokenError extends AuthError {
68
+ static readonly TYPE = `${AuthError.TYPE}.expired-token`;
69
+ type = ExpiredTokenError.TYPE;
70
+ static readonly matches = errorMatcher(ExpiredTokenError.TYPE);
71
+ }
72
+
67
73
  /**
68
74
  * UnexpectedError is raised when an unexpected error occurs.
69
75
  */
@@ -154,6 +160,8 @@ const decode = (payload: ErrorPayload): Error | null => {
154
160
  if (payload.type.startsWith(AuthError.TYPE)) {
155
161
  if (payload.type.startsWith(InvalidTokenError.TYPE))
156
162
  return new InvalidTokenError(payload.data);
163
+ if (payload.type.startsWith(ExpiredTokenError.TYPE))
164
+ return new ExpiredTokenError(payload.data);
157
165
  return new AuthError(payload.data);
158
166
  }
159
167
 
@@ -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,7 @@ import { DataType, Series, TimeStamp } from "@synnaxlabs/x/telem";
11
11
  import { beforeAll, describe, expect, it } from "vitest";
12
12
 
13
13
  import { type channel } from "@/channel";
14
- import { WriteFrameAdapter } from "@/framer/adapter";
14
+ import { WriteAdapter } from "@/framer/adapter";
15
15
  import { Frame } from "@/index";
16
16
  import { newClient } from "@/setupspecs";
17
17
 
@@ -20,7 +20,7 @@ const client = newClient();
20
20
  describe("WriteFrameAdapter", () => {
21
21
  let timeCh: channel.Channel;
22
22
  let dataCh: channel.Channel;
23
- let adapter: WriteFrameAdapter;
23
+ let adapter: WriteAdapter;
24
24
 
25
25
  beforeAll(async () => {
26
26
  timeCh = await client.channels.create({
@@ -34,7 +34,7 @@ describe("WriteFrameAdapter", () => {
34
34
  index: timeCh.key,
35
35
  });
36
36
 
37
- adapter = await WriteFrameAdapter.open(client.channels.retriever, [
37
+ adapter = await WriteAdapter.open(client.channels.retriever, [
38
38
  timeCh.key,
39
39
  dataCh.key,
40
40
  ]);
@@ -42,10 +42,7 @@ describe("WriteFrameAdapter", () => {
42
42
 
43
43
  it("should correctly adapt a record of keys to single values", async () => {
44
44
  const ts = TimeStamp.now().valueOf();
45
- const res = await adapter.adapt({
46
- [timeCh.key]: ts,
47
- [dataCh.key]: 1,
48
- });
45
+ const res = await adapter.adapt({ [timeCh.key]: ts, [dataCh.key]: 1 });
49
46
  expect(res.columns).toHaveLength(2);
50
47
  expect(res.series).toHaveLength(2);
51
48
  expect(res.get(timeCh.key)).toHaveLength(1);
@@ -56,10 +53,7 @@ describe("WriteFrameAdapter", () => {
56
53
 
57
54
  it("should correctly adapt a record of names to single values", async () => {
58
55
  const ts = TimeStamp.now().valueOf();
59
- const res2 = await adapter.adapt({
60
- [timeCh.name]: ts,
61
- [dataCh.name]: 1,
62
- });
56
+ const res2 = await adapter.adapt({ [timeCh.name]: ts, [dataCh.name]: 1 });
63
57
  expect(res2.columns).toHaveLength(2);
64
58
  expect(res2.series).toHaveLength(2);
65
59
  expect(res2.get(timeCh.key)).toHaveLength(1);
@@ -103,10 +97,7 @@ describe("WriteFrameAdapter", () => {
103
97
 
104
98
  it("should not modify a frame keyed by key", async () => {
105
99
  const ts = TimeStamp.now().valueOf();
106
- const fr = new Frame({
107
- [timeCh.key]: new Series(ts),
108
- [dataCh.key]: new Series(1),
109
- });
100
+ const fr = new Frame({ [timeCh.key]: new Series(ts), [dataCh.key]: new Series(1) });
110
101
  const res = await adapter.adapt(fr);
111
102
  expect(res.columns).toHaveLength(2);
112
103
  expect(res.series).toHaveLength(2);
@@ -131,7 +122,7 @@ describe("WriteFrameAdapter", () => {
131
122
  dataType: DataType.JSON,
132
123
  virtual: true,
133
124
  });
134
- const adapter = await WriteFrameAdapter.open(client.channels.retriever, [
125
+ const adapter = await WriteAdapter.open(client.channels.retriever, [
135
126
  jsonChannel.key,
136
127
  ]);
137
128
  const res = await adapter.adapt(jsonChannel.name, [{ dog: "blue" }]);
@@ -147,7 +138,7 @@ describe("WriteFrameAdapter", () => {
147
138
  dataType: DataType.JSON,
148
139
  virtual: true,
149
140
  });
150
- const adapter = await WriteFrameAdapter.open(client.channels.retriever, [
141
+ const adapter = await WriteAdapter.open(client.channels.retriever, [
151
142
  jsonChannel.key,
152
143
  ]);
153
144
  const res = await adapter.adapt(jsonChannel.name, new Series([{ dog: "blue" }]));
@@ -157,12 +148,26 @@ describe("WriteFrameAdapter", () => {
157
148
  expect(res.get(jsonChannel.key).at(0)).toEqual({ dog: "blue" });
158
149
  });
159
150
 
160
- it("should correctly adapt generic object keys", async () => {
161
- const res = await adapter.adaptObjectKeys({
162
- [timeCh.name]: 532,
163
- [dataCh.name]: 123,
151
+ it("should correctly adapt a numeric value to a BigInt keyed by key", async () => {
152
+ const bigIntCh = await client.channels.create({
153
+ name: `bigint-${Math.random()}-${TimeStamp.now().toString()}`,
154
+ dataType: DataType.INT64,
155
+ virtual: true,
156
+ });
157
+ const res = await adapter.adapt({
158
+ [bigIntCh.key]: 12,
159
+ });
160
+ expect(res.get(bigIntCh.key).at(0)).toEqual(12n);
161
+ });
162
+
163
+ describe("adaptObjectKeys", () => {
164
+ it("should correctly adapt generic object keys", async () => {
165
+ const res = await adapter.adaptObjectKeys({
166
+ [timeCh.name]: 532,
167
+ [dataCh.name]: 123,
168
+ });
169
+ expect(res).toHaveProperty(timeCh.key.toString());
170
+ expect(res).toHaveProperty(dataCh.key.toString());
164
171
  });
165
- expect(res).toHaveProperty(timeCh.key.toString());
166
- expect(res).toHaveProperty(dataCh.key.toString());
167
172
  });
168
173
  });