@synnaxlabs/client 0.38.1 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/.turbo/turbo-build.log +7 -7
  2. package/dist/access/payload.d.ts +6 -6
  3. package/dist/access/payload.d.ts.map +1 -1
  4. package/dist/access/policy/client.d.ts +5 -3
  5. package/dist/access/policy/client.d.ts.map +1 -1
  6. package/dist/access/policy/external.d.ts +1 -0
  7. package/dist/access/policy/external.d.ts.map +1 -1
  8. package/dist/access/policy/ontology.d.ts +5 -0
  9. package/dist/access/policy/ontology.d.ts.map +1 -0
  10. package/dist/access/policy/payload.d.ts +86 -89
  11. package/dist/access/policy/payload.d.ts.map +1 -1
  12. package/dist/access/policy/retriever.d.ts +7 -6
  13. package/dist/access/policy/retriever.d.ts.map +1 -1
  14. package/dist/access/policy/writer.d.ts +2 -2
  15. package/dist/access/policy/writer.d.ts.map +1 -1
  16. package/dist/auth/auth.d.ts +2 -1
  17. package/dist/auth/auth.d.ts.map +1 -1
  18. package/dist/channel/client.d.ts +6 -5
  19. package/dist/channel/client.d.ts.map +1 -1
  20. package/dist/channel/payload.d.ts +13 -11
  21. package/dist/channel/payload.d.ts.map +1 -1
  22. package/dist/channel/retriever.d.ts +9 -6
  23. package/dist/channel/retriever.d.ts.map +1 -1
  24. package/dist/channel/writer.d.ts +6 -4
  25. package/dist/channel/writer.d.ts.map +1 -1
  26. package/dist/client.cjs +30 -30
  27. package/dist/client.d.ts +4 -2
  28. package/dist/client.d.ts.map +1 -1
  29. package/dist/client.js +3387 -3433
  30. package/dist/connection/checker.d.ts +5 -4
  31. package/dist/connection/checker.d.ts.map +1 -1
  32. package/dist/control/state.d.ts +10 -8
  33. package/dist/control/state.d.ts.map +1 -1
  34. package/dist/errors.d.ts +5 -0
  35. package/dist/errors.d.ts.map +1 -1
  36. package/dist/framer/adapter.d.ts +14 -15
  37. package/dist/framer/adapter.d.ts.map +1 -1
  38. package/dist/framer/client.d.ts +13 -15
  39. package/dist/framer/client.d.ts.map +1 -1
  40. package/dist/framer/deleter.d.ts +3 -2
  41. package/dist/framer/deleter.d.ts.map +1 -1
  42. package/dist/framer/frame.d.ts +31 -27
  43. package/dist/framer/frame.d.ts.map +1 -1
  44. package/dist/framer/iterator.d.ts +4 -5
  45. package/dist/framer/iterator.d.ts.map +1 -1
  46. package/dist/framer/streamer.d.ts +5 -6
  47. package/dist/framer/streamer.d.ts.map +1 -1
  48. package/dist/framer/writer.d.ts +42 -39
  49. package/dist/framer/writer.d.ts.map +1 -1
  50. package/dist/hardware/device/client.d.ts +20 -12
  51. package/dist/hardware/device/client.d.ts.map +1 -1
  52. package/dist/hardware/device/payload.d.ts +19 -16
  53. package/dist/hardware/device/payload.d.ts.map +1 -1
  54. package/dist/hardware/rack/client.d.ts +15 -15
  55. package/dist/hardware/rack/client.d.ts.map +1 -1
  56. package/dist/hardware/rack/payload.d.ts +9 -8
  57. package/dist/hardware/rack/payload.d.ts.map +1 -1
  58. package/dist/hardware/task/client.d.ts +38 -29
  59. package/dist/hardware/task/client.d.ts.map +1 -1
  60. package/dist/hardware/task/payload.d.ts +58 -53
  61. package/dist/hardware/task/payload.d.ts.map +1 -1
  62. package/dist/label/client.d.ts +4 -3
  63. package/dist/label/client.d.ts.map +1 -1
  64. package/dist/label/payload.d.ts +4 -4
  65. package/dist/label/payload.d.ts.map +1 -1
  66. package/dist/label/retriever.d.ts.map +1 -1
  67. package/dist/label/writer.d.ts +13 -10
  68. package/dist/label/writer.d.ts.map +1 -1
  69. package/dist/ontology/client.d.ts +12 -10
  70. package/dist/ontology/client.d.ts.map +1 -1
  71. package/dist/ontology/group/client.d.ts +5 -4
  72. package/dist/ontology/group/client.d.ts.map +1 -1
  73. package/dist/ontology/group/group.d.ts +7 -5
  74. package/dist/ontology/group/group.d.ts.map +1 -1
  75. package/dist/ontology/group/payload.d.ts +6 -5
  76. package/dist/ontology/group/payload.d.ts.map +1 -1
  77. package/dist/ontology/group/writer.d.ts +8 -8
  78. package/dist/ontology/group/writer.d.ts.map +1 -1
  79. package/dist/ontology/payload.d.ts +72 -62
  80. package/dist/ontology/payload.d.ts.map +1 -1
  81. package/dist/ontology/writer.d.ts.map +1 -1
  82. package/dist/ranger/alias.d.ts +9 -10
  83. package/dist/ranger/alias.d.ts.map +1 -1
  84. package/dist/ranger/client.d.ts +18 -18
  85. package/dist/ranger/client.d.ts.map +1 -1
  86. package/dist/ranger/external.d.ts +1 -1
  87. package/dist/ranger/external.d.ts.map +1 -1
  88. package/dist/ranger/kv.d.ts +18 -14
  89. package/dist/ranger/kv.d.ts.map +1 -1
  90. package/dist/ranger/payload.d.ts +13 -13
  91. package/dist/ranger/payload.d.ts.map +1 -1
  92. package/dist/ranger/writer.d.ts +14 -14
  93. package/dist/ranger/writer.d.ts.map +1 -1
  94. package/dist/setupspecs.d.ts.map +1 -1
  95. package/dist/signals/observable.d.ts +3 -1
  96. package/dist/signals/observable.d.ts.map +1 -1
  97. package/dist/user/client.d.ts +5 -3
  98. package/dist/user/client.d.ts.map +1 -1
  99. package/dist/user/payload.d.ts +7 -6
  100. package/dist/user/payload.d.ts.map +1 -1
  101. package/dist/user/retriever.d.ts +2 -1
  102. package/dist/user/retriever.d.ts.map +1 -1
  103. package/dist/user/writer.d.ts +2 -2
  104. package/dist/user/writer.d.ts.map +1 -1
  105. package/dist/util/decodeJSONString.d.ts +3 -0
  106. package/dist/util/decodeJSONString.d.ts.map +1 -0
  107. package/dist/util/parseWithoutKeyConversion.d.ts +3 -0
  108. package/dist/util/parseWithoutKeyConversion.d.ts.map +1 -0
  109. package/dist/util/retrieve.d.ts +1 -1
  110. package/dist/util/retrieve.d.ts.map +1 -1
  111. package/dist/util/telem.d.ts.map +1 -1
  112. package/dist/util/zod.d.ts.map +1 -1
  113. package/dist/workspace/client.d.ts +6 -60
  114. package/dist/workspace/client.d.ts.map +1 -1
  115. package/dist/workspace/external.d.ts +3 -0
  116. package/dist/workspace/external.d.ts.map +1 -0
  117. package/dist/workspace/index.d.ts +1 -1
  118. package/dist/workspace/index.d.ts.map +1 -1
  119. package/dist/workspace/lineplot/client.d.ts +5 -44
  120. package/dist/workspace/lineplot/client.d.ts.map +1 -1
  121. package/dist/workspace/lineplot/external.d.ts +3 -0
  122. package/dist/workspace/lineplot/external.d.ts.map +1 -0
  123. package/dist/workspace/lineplot/index.d.ts +1 -1
  124. package/dist/workspace/lineplot/index.d.ts.map +1 -1
  125. package/dist/workspace/lineplot/payload.d.ts +45 -0
  126. package/dist/workspace/lineplot/payload.d.ts.map +1 -0
  127. package/dist/workspace/log/client.d.ts +5 -44
  128. package/dist/workspace/log/client.d.ts.map +1 -1
  129. package/dist/workspace/log/external.d.ts +3 -0
  130. package/dist/workspace/log/external.d.ts.map +1 -0
  131. package/dist/workspace/log/index.d.ts +1 -1
  132. package/dist/workspace/log/index.d.ts.map +1 -1
  133. package/dist/workspace/log/payload.d.ts +45 -0
  134. package/dist/workspace/log/payload.d.ts.map +1 -0
  135. package/dist/workspace/payload.d.ts +60 -0
  136. package/dist/workspace/payload.d.ts.map +1 -0
  137. package/dist/workspace/schematic/client.d.ts +5 -68
  138. package/dist/workspace/schematic/client.d.ts.map +1 -1
  139. package/dist/workspace/schematic/external.d.ts +3 -0
  140. package/dist/workspace/schematic/external.d.ts.map +1 -0
  141. package/dist/workspace/schematic/index.d.ts +1 -1
  142. package/dist/workspace/schematic/index.d.ts.map +1 -1
  143. package/dist/workspace/schematic/payload.d.ts +71 -0
  144. package/dist/workspace/schematic/payload.d.ts.map +1 -0
  145. package/dist/workspace/table/client.d.ts +5 -57
  146. package/dist/workspace/table/client.d.ts.map +1 -1
  147. package/dist/workspace/table/external.d.ts +3 -0
  148. package/dist/workspace/table/external.d.ts.map +1 -0
  149. package/dist/workspace/table/index.d.ts +1 -1
  150. package/dist/workspace/table/index.d.ts.map +1 -1
  151. package/dist/workspace/table/payload.d.ts +60 -0
  152. package/dist/workspace/table/payload.d.ts.map +1 -0
  153. package/examples/node/basicReadWrite.js +26 -26
  154. package/examples/node/liveStream.js +15 -15
  155. package/examples/node/seriesAndFrames.js +38 -38
  156. package/examples/node/streamWrite.js +47 -45
  157. package/package.json +15 -13
  158. package/src/access/payload.ts +12 -12
  159. package/src/access/policy/client.ts +13 -12
  160. package/src/access/policy/external.ts +1 -0
  161. package/src/access/policy/ontology.ts +17 -0
  162. package/src/access/policy/payload.ts +7 -19
  163. package/src/access/policy/policy.spec.ts +16 -16
  164. package/src/access/policy/retriever.ts +2 -1
  165. package/src/access/policy/writer.ts +4 -4
  166. package/src/auth/auth.spec.ts +27 -23
  167. package/src/auth/auth.ts +7 -11
  168. package/src/channel/batchRetriever.spec.ts +25 -22
  169. package/src/channel/client.ts +19 -21
  170. package/src/channel/payload.ts +16 -20
  171. package/src/channel/retriever.ts +20 -21
  172. package/src/channel/writer.ts +11 -13
  173. package/src/client.ts +6 -16
  174. package/src/connection/checker.ts +9 -11
  175. package/src/connection/connection.spec.ts +17 -5
  176. package/src/control/state.ts +8 -9
  177. package/src/errors.spec.ts +1 -1
  178. package/src/errors.ts +8 -0
  179. package/src/framer/adapter.spec.ts +28 -23
  180. package/src/framer/adapter.ts +37 -41
  181. package/src/framer/client.spec.ts +5 -11
  182. package/src/framer/client.ts +34 -38
  183. package/src/framer/deleter.ts +5 -6
  184. package/src/framer/frame.ts +62 -50
  185. package/src/framer/iterator.ts +11 -16
  186. package/src/framer/streamer.spec.ts +2 -10
  187. package/src/framer/streamer.ts +15 -19
  188. package/src/framer/writer.spec.ts +48 -7
  189. package/src/framer/writer.ts +39 -31
  190. package/src/hardware/device/client.ts +67 -39
  191. package/src/hardware/device/device.spec.ts +91 -33
  192. package/src/hardware/device/payload.ts +29 -28
  193. package/src/hardware/rack/client.ts +52 -65
  194. package/src/hardware/rack/payload.ts +9 -18
  195. package/src/hardware/rack/rack.spec.ts +12 -0
  196. package/src/hardware/task/client.ts +160 -131
  197. package/src/hardware/task/payload.ts +49 -68
  198. package/src/hardware/task/task.spec.ts +98 -81
  199. package/src/label/client.ts +12 -15
  200. package/src/label/payload.ts +3 -9
  201. package/src/label/retriever.ts +3 -7
  202. package/src/label/writer.ts +8 -15
  203. package/src/ontology/client.ts +17 -22
  204. package/src/ontology/group/client.ts +5 -5
  205. package/src/ontology/group/group.spec.ts +4 -4
  206. package/src/ontology/group/group.ts +10 -7
  207. package/src/ontology/group/payload.ts +11 -35
  208. package/src/ontology/group/writer.ts +22 -26
  209. package/src/ontology/ontology.spec.ts +15 -15
  210. package/src/ontology/payload.ts +67 -43
  211. package/src/ontology/writer.ts +16 -23
  212. package/src/ranger/alias.ts +25 -42
  213. package/src/ranger/client.ts +29 -38
  214. package/src/ranger/external.ts +1 -1
  215. package/src/ranger/kv.ts +9 -32
  216. package/src/ranger/payload.ts +14 -36
  217. package/src/ranger/ranger.spec.ts +1 -2
  218. package/src/ranger/writer.ts +8 -26
  219. package/src/signals/observable.ts +3 -4
  220. package/src/user/client.ts +8 -4
  221. package/src/user/payload.ts +5 -9
  222. package/src/user/retriever.ts +1 -1
  223. package/src/user/user.spec.ts +17 -15
  224. package/src/user/writer.ts +3 -10
  225. package/src/util/decodeJSONString.ts +13 -0
  226. package/src/util/parseWithoutKeyConversion.ts +19 -0
  227. package/src/util/retrieve.spec.ts +3 -13
  228. package/src/util/retrieve.ts +2 -12
  229. package/src/util/telem.ts +1 -1
  230. package/src/vite-env.d.ts +1 -0
  231. package/src/workspace/client.ts +30 -57
  232. package/src/workspace/external.ts +11 -0
  233. package/src/workspace/index.ts +1 -1
  234. package/src/workspace/lineplot/client.ts +22 -36
  235. package/src/workspace/lineplot/external.ts +11 -0
  236. package/src/workspace/lineplot/index.ts +1 -1
  237. package/src/workspace/lineplot/linePlot.spec.ts +1 -2
  238. package/src/workspace/lineplot/payload.ts +32 -0
  239. package/src/workspace/log/client.ts +25 -39
  240. package/src/workspace/log/external.ts +11 -0
  241. package/src/workspace/log/index.ts +1 -1
  242. package/src/workspace/log/log.spec.ts +5 -18
  243. package/src/workspace/log/payload.ts +32 -0
  244. package/src/workspace/payload.ts +36 -0
  245. package/src/workspace/schematic/client.ts +30 -56
  246. package/src/workspace/schematic/external.ts +11 -0
  247. package/src/workspace/schematic/index.ts +1 -1
  248. package/src/workspace/schematic/payload.ts +37 -0
  249. package/src/workspace/schematic/schematic.spec.ts +15 -6
  250. package/src/workspace/table/client.ts +27 -50
  251. package/src/workspace/table/external.ts +11 -0
  252. package/src/workspace/table/index.ts +1 -1
  253. package/src/workspace/table/payload.ts +36 -0
  254. package/src/workspace/workspace.spec.ts +1 -2
  255. package/dist/channel/creator.d.ts +0 -9
  256. package/dist/channel/creator.d.ts.map +0 -1
  257. package/src/channel/creator.ts +0 -37
@@ -0,0 +1,60 @@
1
+ import { z } from 'zod';
2
+ export declare const keyZ: z.ZodString;
3
+ export type Key = z.infer<typeof keyZ>;
4
+ export type Params = Key | Key[];
5
+ export declare const tableZ: z.ZodObject<{
6
+ key: z.ZodString;
7
+ name: z.ZodString;
8
+ data: z.ZodUnion<[z.ZodRecord<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodSymbol]>, z.ZodUnknown>, z.ZodEffects<z.ZodString, import('@synnaxlabs/x').UnknownRecord, string>]>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ name: string;
11
+ key: string;
12
+ data: import('@synnaxlabs/x').UnknownRecord | Record<string | number | symbol, unknown>;
13
+ }, {
14
+ name: string;
15
+ key: string;
16
+ data: string | Record<string | number | symbol, unknown>;
17
+ }>;
18
+ export interface Table extends z.infer<typeof tableZ> {
19
+ }
20
+ export declare const newZ: z.ZodEffects<z.ZodObject<{
21
+ name: z.ZodString;
22
+ key: z.ZodOptional<z.ZodString>;
23
+ data: z.ZodUnion<[z.ZodRecord<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodSymbol]>, z.ZodUnknown>, z.ZodEffects<z.ZodString, import('@synnaxlabs/x').UnknownRecord, string>]>;
24
+ }, "strip", z.ZodTypeAny, {
25
+ name: string;
26
+ data: import('@synnaxlabs/x').UnknownRecord | Record<string | number | symbol, unknown>;
27
+ key?: string | undefined;
28
+ }, {
29
+ name: string;
30
+ data: string | Record<string | number | symbol, unknown>;
31
+ key?: string | undefined;
32
+ }>, {
33
+ data: string;
34
+ name: string;
35
+ key?: string | undefined;
36
+ }, {
37
+ name: string;
38
+ data: string | Record<string | number | symbol, unknown>;
39
+ key?: string | undefined;
40
+ }>;
41
+ export interface New extends z.input<typeof newZ> {
42
+ }
43
+ export declare const remoteZ: z.ZodObject<z.objectUtil.extendShape<{
44
+ key: z.ZodString;
45
+ name: z.ZodString;
46
+ data: z.ZodUnion<[z.ZodRecord<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodSymbol]>, z.ZodUnknown>, z.ZodEffects<z.ZodString, import('@synnaxlabs/x').UnknownRecord, string>]>;
47
+ }, {
48
+ data: z.ZodEffects<z.ZodString, import('@synnaxlabs/x').UnknownRecord, string>;
49
+ }>, "strip", z.ZodTypeAny, {
50
+ name: string;
51
+ key: string;
52
+ data: import('@synnaxlabs/x').UnknownRecord;
53
+ }, {
54
+ name: string;
55
+ key: string;
56
+ data: string;
57
+ }>;
58
+ export declare const ONTOLOGY_TYPE = "table";
59
+ export type OntologyType = typeof ONTOLOGY_TYPE;
60
+ //# sourceMappingURL=payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../../src/workspace/table/payload.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,IAAI,aAAoB,CAAC;AACtC,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AACvC,MAAM,MAAM,MAAM,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC;AAEjC,eAAO,MAAM,MAAM;;;;;;;;;;;;EAIjB,CAAC;AACH,MAAM,WAAW,KAAM,SAAQ,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC;CAAG;AAExD,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;EAE4C,CAAC;AAC9D,MAAM,WAAW,GAAI,SAAQ,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC;CAAG;AAEpD,eAAO,MAAM,OAAO;;;;;;;;;;;;;;EAElB,CAAC;AAEH,eAAO,MAAM,aAAa,UAAU,CAAC;AACrC,MAAM,MAAM,YAAY,GAAG,OAAO,aAAa,CAAC"}
@@ -16,34 +16,34 @@ import { DataType, Synnax, TimeRange, TimeSpan, TimeStamp } from "@synnaxlabs/cl
16
16
  // Connect to a locally running, insecure Synnax cluster. If your connection parameters
17
17
  // are different, enter them here.
18
18
  const client = new Synnax({
19
- host: "localhost",
20
- port: 9090,
21
- username: "synnax",
22
- password: "seldon",
23
- secure: false,
19
+ host: "localhost",
20
+ port: 9090,
21
+ username: "synnax",
22
+ password: "seldon",
23
+ secure: false,
24
24
  });
25
25
 
26
26
  // Create an index channel that will be used to store our timestamps.
27
27
  const timeChannel = await client.channels.create(
28
- {
29
- name: "basic_read_write_time",
30
- isIndex: true,
31
- dataType: DataType.TIMESTAMP,
32
- },
33
- { retrieveIfNameExists: true },
28
+ {
29
+ name: "basic_read_write_time",
30
+ isIndex: true,
31
+ dataType: DataType.TIMESTAMP,
32
+ },
33
+ { retrieveIfNameExists: true },
34
34
  );
35
35
 
36
36
  // Create a channel that will be used to store our data.
37
37
  const dataChannel = await client.channels.create(
38
- {
39
- name: "basic_read_write_data",
40
- isIndex: false,
41
- dataType: DataType.FLOAT32,
42
- // We need to specify the index channel that we want to use to store the timestamps
43
- // for this data channel.
44
- index: timeChannel.key,
45
- },
46
- { retrieveIfNameExists: true },
38
+ {
39
+ name: "basic_read_write_data",
40
+ isIndex: false,
41
+ dataType: DataType.FLOAT32,
42
+ // We need to specify the index channel that we want to use to store the timestamps
43
+ // for this data channel.
44
+ index: timeChannel.key,
45
+ },
46
+ { retrieveIfNameExists: true },
47
47
  );
48
48
 
49
49
  const N_SAMPLES = 5000;
@@ -54,7 +54,7 @@ const start = TimeStamp.now();
54
54
 
55
55
  // Generate a new timestamp every millisecond for N_SAMPLES.
56
56
  const time = BigInt64Array.from({ length: N_SAMPLES }, (_, i) =>
57
- start.add(TimeSpan.milliseconds(i)).valueOf(),
57
+ start.add(TimeSpan.milliseconds(i)).valueOf(),
58
58
  );
59
59
 
60
60
  // Generate a sine wave for N_SAMPLES.
@@ -75,11 +75,11 @@ const readData = await dataChannel.read(tr);
75
75
 
76
76
  // Print out some information.
77
77
  console.log({
78
- firstTimestamp: readTime.at(0),
79
- firstData: readData.at(0),
80
- lastTimestamp: readTime.at(N_SAMPLES - 1),
81
- lastData: readData.at(N_SAMPLES - 1),
82
- returnLength: readData.length,
78
+ firstTimestamp: readTime.at(0),
79
+ firstData: readData.at(0),
80
+ lastTimestamp: readTime.at(N_SAMPLES - 1),
81
+ lastData: readData.at(N_SAMPLES - 1),
82
+ returnLength: readData.length,
83
83
  });
84
84
 
85
85
  // Make sure to close the client when you're done.
@@ -19,18 +19,18 @@ import { Synnax } from "@synnaxlabs/client";
19
19
  // Connect to a locally running, insecure Synnax cluster. If your connection parameters
20
20
  // are different, enter them here.
21
21
  const client = new Synnax({
22
- host: "localhost",
23
- port: 9090,
24
- username: "synnax",
25
- password: "seldon",
26
- secure: false,
22
+ host: "localhost",
23
+ port: 9090,
24
+ username: "synnax",
25
+ password: "seldon",
26
+ secure: false,
27
27
  });
28
28
 
29
29
  // We can just specify the names of the channels we'd like to stream from.
30
30
  const read_from = [
31
- "stream_write_example_time",
32
- "stream_write_example_data_1",
33
- "stream_write_example_data_2",
31
+ "stream_write_example_time",
32
+ "stream_write_example_data_1",
33
+ "stream_write_example_data_2",
34
34
  ];
35
35
 
36
36
  const streamer = await client.openStreamer(read_from);
@@ -39,12 +39,12 @@ const streamer = await client.openStreamer(read_from);
39
39
  // network connections and other resources, so we wrap the streaming loop in a
40
40
  // try-finally block.
41
41
  try {
42
- // Loop through the frames in the streamer. Each iteration will block until a new
43
- // frame is available, and then we'll just print out the last sample for each
44
- // channel in the frame.
45
- for await (const frame of streamer) console.log(frame.at(-1));
42
+ // Loop through the frames in the streamer. Each iteration will block until a new
43
+ // frame is available, and then we'll just print out the last sample for each
44
+ // channel in the frame.
45
+ for await (const frame of streamer) console.log(frame.at(-1));
46
46
  } finally {
47
- streamer.close();
48
- // Close the client when we're done with it.
49
- client.close();
47
+ streamer.close();
48
+ // Close the client when we're done with it.
49
+ client.close();
50
50
  }
@@ -67,9 +67,9 @@ const start = TimeStamp.now();
67
67
  const tr = new TimeRange(start, start.add(TimeSpan.seconds(5)));
68
68
 
69
69
  series = new Series({
70
- data: [1, 2, 3, 4, 5],
71
- dataType: "float64",
72
- timeRange: tr,
70
+ data: [1, 2, 3, 4, 5],
71
+ dataType: "float64",
72
+ timeRange: tr,
73
73
  });
74
74
 
75
75
  series = new Series([1, 2, 3, 4, 5]);
@@ -93,52 +93,52 @@ import { Frame } from "@synnaxlabs/client";
93
93
 
94
94
  // Construct a frame for the given channel names.
95
95
  let frame = new Frame({
96
- channel1: new Series([1, 2, 3, 4, 5]),
97
- channel2: new Series([5, 4, 3, 2, 1]),
98
- channel3: new Series([1, 1, 1, 1, 1]),
96
+ channel1: new Series([1, 2, 3, 4, 5]),
97
+ channel2: new Series([5, 4, 3, 2, 1]),
98
+ channel3: new Series([1, 1, 1, 1, 1]),
99
99
  });
100
100
 
101
101
  // Construct a frame for the given channel keys
102
102
  frame = new Frame({
103
- 1: new Series([1, 2, 3, 4, 5]),
104
- 2: new Series([5, 4, 3, 2, 1]),
105
- // Notice that series do not need to be the same length.
106
- 3: new Series([1, 1, 1]),
103
+ 1: new Series([1, 2, 3, 4, 5]),
104
+ 2: new Series([5, 4, 3, 2, 1]),
105
+ // Notice that series do not need to be the same length.
106
+ 3: new Series([1, 1, 1]),
107
107
  });
108
108
 
109
109
  // Construct a frame from a map
110
110
  frame = new Frame(
111
- new Map([
112
- ["channel1", new Series([1, 2, 3, 4, 5])],
113
- ["channel2", new Series([5, 4, 3, 2, 1])],
114
- ["channel3", new Series([1, 1, 1, 1, 1])],
115
- ]),
111
+ new Map([
112
+ ["channel1", new Series([1, 2, 3, 4, 5])],
113
+ ["channel2", new Series([5, 4, 3, 2, 1])],
114
+ ["channel3", new Series([1, 1, 1, 1, 1])],
115
+ ]),
116
116
  );
117
117
 
118
118
  // Or from an array of keys and series
119
119
  frame = new Frame(
120
- ["channel1", "channel2", "channel3"],
121
- [
122
- new Series([1, 2, 3, 4, 5]),
123
- new Series([5, 4, 3, 2, 1]),
124
- new Series([1, 1, 1, 1, 1]),
125
- ],
120
+ ["channel1", "channel2", "channel3"],
121
+ [
122
+ new Series([1, 2, 3, 4, 5]),
123
+ new Series([5, 4, 3, 2, 1]),
124
+ new Series([1, 1, 1, 1, 1]),
125
+ ],
126
126
  );
127
127
 
128
128
  // Or construct a frame with multiple series for a single channel
129
129
  frame = new Frame({
130
- channel1: [
131
- new Series([1, 2, 3, 4, 5]),
132
- new Series([5, 4, 3, 2, 1]),
133
- new Series([1, 1, 1, 1, 1]),
134
- ],
135
- channel2: [new Series([1, 2, 3, 4, 5])],
130
+ channel1: [
131
+ new Series([1, 2, 3, 4, 5]),
132
+ new Series([5, 4, 3, 2, 1]),
133
+ new Series([1, 1, 1, 1, 1]),
134
+ ],
135
+ channel2: [new Series([1, 2, 3, 4, 5])],
136
136
  });
137
137
 
138
138
  frame = new Frame({
139
- channel1: [new Series([1, 2]), new Series([3, 4, 5])],
140
- channel2: new Series([5, 4, 3, 2, 1]),
141
- channel3: new Series([1, 1, 1, 1, 1]),
139
+ channel1: [new Series([1, 2]), new Series([3, 4, 5])],
140
+ channel2: new Series([5, 4, 3, 2, 1]),
141
+ channel3: new Series([1, 1, 1, 1, 1]),
142
142
  });
143
143
 
144
144
  const multiSeries = frame.get("channel1");
@@ -153,21 +153,21 @@ jsArray = [...multiSeries];
153
153
  console.log(jsArray); // [ 1, 2, 3, 4, 5 ]
154
154
 
155
155
  frame = new Frame({
156
- channel1: new Series([1, 2, 3, 4, 5]),
157
- channel2: new Series([5, 4, 3, 2, 1]),
158
- channel3: new Series([1, 1]),
156
+ channel1: new Series([1, 2, 3, 4, 5]),
157
+ channel2: new Series([5, 4, 3, 2, 1]),
158
+ channel3: new Series([1, 1]),
159
159
  });
160
160
 
161
161
  let obj = frame.at(3);
162
162
  console.log(obj); // { channel1: 1, channel2: 5, channel3: undefined }
163
163
 
164
164
  frame = new Frame({
165
- channel1: new Series([1, 2, 3, 4, 5]),
166
- channel2: new Series([5, 4, 3, 2, 1]),
167
- channel3: new Series([1, 1]),
165
+ channel1: new Series([1, 2, 3, 4, 5]),
166
+ channel2: new Series([5, 4, 3, 2, 1]),
167
+ channel3: new Series([1, 1]),
168
168
  });
169
169
  try {
170
- obj = frame.at(3, true); // Throws an error
170
+ obj = frame.at(3, true); // Throws an error
171
171
  } catch (e) {
172
- console.log(e.message); // no value at index
172
+ console.log(e.message); // no value at index
173
173
  }
@@ -17,39 +17,39 @@ import { Rate, Synnax, TimeStamp } from "@synnaxlabs/client";
17
17
  // Connect to a locally running, insecure Synnax cluster. If your connection parameters
18
18
  // are different, enter them here.
19
19
  const client = new Synnax({
20
- host: "localhost",
21
- port: 9090,
22
- username: "synnax",
23
- password: "seldon",
20
+ host: "localhost",
21
+ port: 9090,
22
+ username: "synnax",
23
+ password: "seldon",
24
24
  });
25
25
 
26
26
  // Create an index channel that will be used to store our timestamps.
27
27
  const timeChannel = await client.channels.create(
28
- {
29
- name: "stream_write_example_time",
30
- isIndex: true,
31
- dataType: "timestamp",
32
- },
33
- { retrieveIfNameExists: true },
28
+ {
29
+ name: "stream_write_example_time",
30
+ isIndex: true,
31
+ dataType: "timestamp",
32
+ },
33
+ { retrieveIfNameExists: true },
34
34
  );
35
35
 
36
36
  // Create a data channel that will be used to store our fake sensor data.
37
37
  const dataChannel1 = await client.channels.create(
38
- {
39
- name: "stream_write_example_data_1",
40
- dataType: "float32",
41
- index: timeChannel.key,
42
- },
43
- { retrieveIfNameExists: true },
38
+ {
39
+ name: "stream_write_example_data_1",
40
+ dataType: "float32",
41
+ index: timeChannel.key,
42
+ },
43
+ { retrieveIfNameExists: true },
44
44
  );
45
45
 
46
46
  const dataChannel2 = await client.channels.create(
47
- {
48
- name: "stream_write_example_data_2",
49
- dataType: "int32",
50
- index: timeChannel.key,
51
- },
52
- { retrieveIfNameExists: true },
47
+ {
48
+ name: "stream_write_example_data_2",
49
+ dataType: "int32",
50
+ index: timeChannel.key,
51
+ },
52
+ { retrieveIfNameExists: true },
53
53
  );
54
54
 
55
55
  // We'll start our write at the current time. This timestamps should be the same as or
@@ -61,32 +61,34 @@ const start = TimeStamp.now();
61
61
  const roughRate = Rate.hz(25);
62
62
 
63
63
  const writer = await client.openWriter({
64
- start,
65
- channels: [timeChannel.key, dataChannel1.key, dataChannel2.key],
66
- enableAutoCommit: true,
64
+ start,
65
+ channels: [timeChannel.key, dataChannel1.key, dataChannel2.key],
66
+ enableAutoCommit: true,
67
67
  });
68
68
 
69
69
  try {
70
- let i = 0;
71
- while (true) {
72
- await new Promise((resolve) =>
73
- setTimeout(resolve, roughRate.period.milliseconds),
74
- );
75
- i++;
76
- const timestamp = TimeStamp.now();
77
- const data1 = Math.sin(i / 10);
78
- const data2 = i % 2;
79
- await writer.write({
80
- [timeChannel.key]: timestamp,
81
- [dataChannel1.key]: data1,
82
- [dataChannel2.key]: data2,
83
- });
84
-
85
- if (i % 60 == 0)
86
- console.log(`Writing sample ${i} at ${timestamp.toISOString()}`);
70
+ let i = 0;
71
+ while (true) {
72
+ await new Promise((resolve) => setTimeout(resolve, roughRate.period.milliseconds));
73
+ i++;
74
+ const timestamp = TimeStamp.now();
75
+ const data1 = Math.sin(i / 10);
76
+ const data2 = i % 2;
77
+ if (
78
+ !(await writer.write({
79
+ [timeChannel.key]: timestamp,
80
+ [dataChannel1.key]: data1,
81
+ [dataChannel2.key]: data2,
82
+ }))
83
+ ) {
84
+ console.error("Failed to write");
85
+ break;
87
86
  }
87
+
88
+ if (i % 60 == 0) console.log(`Writing sample ${i} at ${timestamp.toISOString()}`);
89
+ }
88
90
  } finally {
89
- // Close the writer and the client when you are done
90
- await writer.close();
91
- client.close();
91
+ // Close the writer and the client when you are done
92
+ await writer.close();
93
+ client.close();
92
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synnaxlabs/client",
3
- "version": "0.38.1",
3
+ "version": "0.40.0",
4
4
  "description": "The Synnax Client Library",
5
5
  "keywords": [
6
6
  "synnax",
@@ -25,21 +25,22 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "async-mutex": "^0.5.0",
28
- "uuid": "^11.0.5",
29
- "zod": "^3.24.1",
30
- "@synnaxlabs/freighter": "0.38.1",
31
- "@synnaxlabs/x": "0.38.1"
28
+ "uuid": "^11.1.0",
29
+ "zod": "^3.24.2",
30
+ "@synnaxlabs/freighter": "0.40.0",
31
+ "@synnaxlabs/x": "0.40.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/node": "^22.10.6",
34
+ "@types/node": "^22.13.10",
35
35
  "@types/uuid": "^10.0.0",
36
- "eslint": "^9.18.0",
37
- "typescript": "^5.7.3",
38
- "vite": "^6.0.7",
39
- "vitest": "^2.1.8",
36
+ "eslint": "^9.22.0",
37
+ "madge": "^8.0.0",
38
+ "typescript": "^5.8.2",
39
+ "vite": "^6.2.1",
40
+ "vitest": "^2.1.9",
41
+ "@synnaxlabs/tsconfig": "0.0.2",
40
42
  "@synnaxlabs/vite-plugin": "0.0.1",
41
- "eslint-config-synnaxlabs": "0.0.1",
42
- "@synnaxlabs/tsconfig": "0.0.2"
43
+ "eslint-config-synnaxlabs": "0.0.1"
43
44
  },
44
45
  "type": "module",
45
46
  "types": "dist/index.d.ts",
@@ -49,6 +50,7 @@
49
50
  "watch": "tsc --noEmit && vite build --watch",
50
51
  "test": "vitest",
51
52
  "lint": "eslint --cache",
52
- "fix": "eslint --cache --fix"
53
+ "fix": "eslint --cache --fix",
54
+ "madge": "madge --circular src"
53
55
  }
54
56
  }
@@ -9,17 +9,17 @@
9
9
 
10
10
  import { z } from "zod";
11
11
 
12
- export const actionZ = z.union([
13
- z.literal("all"),
14
- z.literal("create"),
15
- z.literal("delete"),
16
- z.literal("retrieve"),
17
- z.literal("update"),
12
+ export const ALL_ACTION = "all";
13
+ export const CREATE_ACTION = "create";
14
+ export const DELETE_ACTION = "delete";
15
+ export const RETRIEVE_ACTION = "retrieve";
16
+ export const UPDATE_ACTION = "update";
17
+
18
+ export const actionZ = z.enum([
19
+ ALL_ACTION,
20
+ CREATE_ACTION,
21
+ DELETE_ACTION,
22
+ RETRIEVE_ACTION,
23
+ UPDATE_ACTION,
18
24
  ]);
19
25
  export type Action = z.infer<typeof actionZ>;
20
-
21
- export const ALL_ACTION: Action = "all";
22
- export const CREATE_ACTION: Action = "create";
23
- export const DELETE_ACTION: Action = "delete";
24
- export const RETRIEVE_ACTION: Action = "retrieve";
25
- export const UPDATE_ACTION: Action = "update";
@@ -10,7 +10,8 @@
10
10
  import { type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { toArray } from "@synnaxlabs/x/toArray";
12
12
 
13
- import { type Key, type NewPolicy, type Policy } from "@/access/policy/payload";
13
+ import { ALLOW_ALL_ONTOLOGY_TYPE, ONTOLOGY_TYPE } from "@/access/policy/ontology";
14
+ import { type Key, type New, type Policy } from "@/access/policy/payload";
14
15
  import { Retriever } from "@/access/policy/retriever";
15
16
  import { Writer } from "@/access/policy/writer";
16
17
  import { ontology } from "@/ontology";
@@ -24,20 +25,16 @@ export class Client {
24
25
  this.writer = new Writer(client);
25
26
  }
26
27
 
27
- async create(policy: NewPolicy): Promise<Policy>;
28
-
29
- async create(policies: NewPolicy[]): Promise<Policy[]>;
30
-
31
- async create(policies: NewPolicy | NewPolicy[]): Promise<Policy | Policy[]> {
28
+ async create(policy: New): Promise<Policy>;
29
+ async create(policies: New[]): Promise<Policy[]>;
30
+ async create(policies: New | New[]): Promise<Policy | Policy[]> {
32
31
  const isMany = Array.isArray(policies);
33
32
  const createdPolicies = await this.writer.create(policies);
34
33
  return isMany ? createdPolicies : createdPolicies[0];
35
34
  }
36
35
 
37
36
  async retrieve(key: Key): Promise<Policy>;
38
-
39
37
  async retrieve(keys: Key[]): Promise<Policy[]>;
40
-
41
38
  async retrieve(keys: Key | Key[]): Promise<Policy | Policy[]> {
42
39
  const isMany = Array.isArray(keys);
43
40
  const res = await this.retriever.retrieve({ keys: toArray(keys) });
@@ -45,9 +42,7 @@ export class Client {
45
42
  }
46
43
 
47
44
  async retrieveFor(subject: ontology.CrudeID): Promise<Policy[]>;
48
-
49
45
  async retrieveFor(subjects: ontology.CrudeID[]): Promise<Policy[]>;
50
-
51
46
  async retrieveFor(
52
47
  subjects: ontology.CrudeID | ontology.CrudeID[],
53
48
  ): Promise<Policy[]> {
@@ -56,10 +51,16 @@ export class Client {
56
51
  }
57
52
 
58
53
  async delete(key: Key): Promise<void>;
59
-
60
54
  async delete(keys: Key[]): Promise<void>;
61
-
62
55
  async delete(keys: Key | Key[]): Promise<void> {
63
56
  await this.writer.delete(keys);
64
57
  }
65
58
  }
59
+
60
+ export const ontologyID = (key: Key): ontology.ID =>
61
+ new ontology.ID({ type: ONTOLOGY_TYPE, key });
62
+
63
+ export const ALLOW_ALL_ONTOLOGY_ID = new ontology.ID({
64
+ type: ALLOW_ALL_ONTOLOGY_TYPE,
65
+ key: "",
66
+ });
@@ -8,4 +8,5 @@
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
10
  export * from "@/access/policy/client";
11
+ export * from "@/access/policy/ontology";
11
12
  export * from "@/access/policy/payload";
@@ -0,0 +1,17 @@
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
+ // This needs to be a separate file because these types are imported by the ontology
11
+ // module, but the policy module need to import the ID schema from the ontology module.
12
+
13
+ export const ONTOLOGY_TYPE = "policy";
14
+ export type OntologyType = typeof ONTOLOGY_TYPE;
15
+
16
+ export const ALLOW_ALL_ONTOLOGY_TYPE = "allow_all";
17
+ export type AllowAllOntologyType = typeof ALLOW_ALL_ONTOLOGY_TYPE;
@@ -16,30 +16,18 @@ import { nullableArrayZ } from "@/util/zod";
16
16
  export const keyZ = z.string().uuid();
17
17
  export type Key = z.infer<typeof keyZ>;
18
18
 
19
- export const newPolicyZ = z.object({
20
- key: keyZ.optional(),
21
- subjects: ontology.crudeIDZ.array().or(ontology.crudeIDZ),
22
- objects: ontology.crudeIDZ.array().or(ontology.crudeIDZ),
23
- actions: actionZ.array().or(actionZ),
24
- });
25
- export type NewPolicy = z.input<typeof newPolicyZ>;
26
-
27
19
  export const policyZ = z.object({
28
20
  key: keyZ,
29
21
  subjects: nullableArrayZ(ontology.idZ),
30
22
  objects: nullableArrayZ(ontology.idZ),
31
23
  actions: nullableArrayZ(actionZ),
32
24
  });
33
- export type Policy = z.infer<typeof policyZ>;
34
-
35
- export const ONTOLOGY_TYPE: ontology.ResourceType = "policy";
25
+ export interface Policy extends z.infer<typeof policyZ> {}
36
26
 
37
- export const ontologyID = (key: Key): ontology.ID =>
38
- new ontology.ID({ type: ONTOLOGY_TYPE, key });
39
-
40
- export const ALLOW_ALL_ONTOLOGY_TYPE: ontology.ResourceType = "allow_all";
41
-
42
- export const ALLOW_ALL_ONTOLOGY_ID = new ontology.ID({
43
- type: ALLOW_ALL_ONTOLOGY_TYPE,
44
- key: "",
27
+ export const newZ = z.object({
28
+ key: keyZ.optional(),
29
+ subjects: ontology.crudeIDZ.array().or(ontology.crudeIDZ),
30
+ objects: ontology.crudeIDZ.array().or(ontology.crudeIDZ),
31
+ actions: actionZ.array().or(actionZ),
45
32
  });
33
+ export interface New extends z.input<typeof newZ> {}